{"version":3,"file":"maplibre-gl-directions.cjs","sources":["../src/directions/events.ts","../src/directions/types.ts","../src/directions/layers.ts","../node_modules/nanoid/url-alphabet/index.js","../node_modules/nanoid/index.browser.js","../node_modules/@placemarkio/polyline/dist/polyline.es.mjs","../src/directions/helpers.ts","../src/directions/utils.ts","../src/directions/main.ts","../node_modules/svelte/src/runtime/internal/utils.js","../node_modules/svelte/src/runtime/internal/dom.js","../node_modules/svelte/src/runtime/internal/lifecycle.js","../node_modules/svelte/src/runtime/internal/scheduler.js","../node_modules/svelte/src/runtime/internal/transitions.js","../node_modules/svelte/src/runtime/internal/each.js","../node_modules/svelte/src/runtime/internal/Component.js","../node_modules/svelte/src/shared/version.js","../node_modules/svelte/src/runtime/internal/disclose-version/index.js","../src/controls/loading-indicator/LoadingIndicatorControl.svelte","../src/controls/loading-indicator/types.ts","../src/controls/loading-indicator/main.ts","../src/controls/bearings/BearingsControl.svelte","../src/controls/bearings/types.ts","../src/controls/bearings/main.ts"],"sourcesContent":["import type { Map, MapMouseEvent, MapTouchEvent } from \"maplibre-gl\";\nimport type { Directions } from \"./types\";\n\nexport class MapLibreGlDirectionsEvented {\n  constructor(map: Map) {\n    this.map = map;\n  }\n\n  protected readonly map: Map;\n\n  private listeners: ListenersStore = {};\n  private oneTimeListeners: ListenersStore = {};\n\n  protected fire<T extends keyof MapLibreGlDirectionsEventType>(event: MapLibreGlDirectionsEventType[T]) {\n    event.target = this.map;\n\n    const type: T = event.type as T;\n\n    this.listeners[type]?.forEach((listener) => listener(event));\n    this.oneTimeListeners[type]?.forEach((listener) => {\n      listener(event);\n\n      const index = this.oneTimeListeners[type]?.indexOf(listener);\n      if (index !== undefined && ~index) this.oneTimeListeners[type]?.splice(index, 1);\n    });\n  }\n\n  /**\n   * Registers an event listener.\n   */\n  on<T extends keyof MapLibreGlDirectionsEventType>(type: T, listener: MapLibreGlDirectionsEventListener<T>) {\n    this.listeners[type] = this.listeners[type] ?? [];\n    this.listeners[type]!.push(listener);\n  }\n\n  /**\n   * Un-registers an event listener.\n   */\n  off<T extends keyof MapLibreGlDirectionsEventType>(type: T, listener: (e: MapLibreGlDirectionsEventType[T]) => void) {\n    const index = this.listeners[type]?.indexOf(listener);\n    if (index !== undefined && ~index) this.listeners[type]?.splice(index, 1);\n  }\n\n  /**\n   * Registers an event listener to be invoked only once.\n   */\n  once<T extends keyof MapLibreGlDirectionsEventType>(type: T, listener: MapLibreGlDirectionsEventListener<T>) {\n    this.oneTimeListeners[type] = this.oneTimeListeners[type] ?? [];\n    this.oneTimeListeners[type]!.push(listener);\n  }\n}\n\n/**\n * Supported event types.\n */\nexport interface MapLibreGlDirectionsEventType {\n  /**\n   * Emitted after the waypoints are set using the {@link default.setWaypoints|`setWaypoints`} method.\n   */\n  setwaypoints: MapLibreGlDirectionsWaypointEvent;\n\n  /**\n   * Emitted after the waypoints' bearings values are changed using the\n   * {@link default.waypointsBearings|`waypointsBearings`} setter.\n   */\n  rotatewaypoints: MapLibreGlDirectionsWaypointEvent;\n\n  /**\n   * Emitted when a waypoint is added.\n   */\n  addwaypoint: MapLibreGlDirectionsWaypointEvent;\n\n  /**\n   * Emitted when a waypoint is removed.\n   */\n  removewaypoint: MapLibreGlDirectionsWaypointEvent;\n\n  /**\n   * Emitted when a waypoint is moved. __Note__ that the event is not emitted if the waypoint has been dragged for an\n   * amount of pixels less than specified by the {@link MapLibreGlDirectionsConfiguration.dragThreshold|`dragThreshold`}\n   * configuration property.\n   */\n  movewaypoint: MapLibreGlDirectionsWaypointEvent;\n\n  /**\n   * Emitted when there appears an ongoing routing-request.\n   */\n  fetchroutesstart: MapLibreGlDirectionsRoutingEvent;\n\n  /**\n   * Emitted after the ongoing routing-request has finished.\n   */\n  fetchroutesend: MapLibreGlDirectionsRoutingEvent;\n}\n\nexport type MapLibreGlDirectionsEventListener<T extends keyof MapLibreGlDirectionsEventType> = (\n  event: MapLibreGlDirectionsEventType[T],\n) => void;\n\ntype ListenersStore = Partial<{\n  [T in keyof MapLibreGlDirectionsEventType]: MapLibreGlDirectionsEventListener<T>[];\n}>;\n\nexport interface MapLibreGlDirectionsEvent<TOrig, T extends keyof MapLibreGlDirectionsEventType> {\n  type: T;\n  target: Map;\n  originalEvent: TOrig;\n}\n\nexport interface MapLibreGlDirectionsWaypointEventData {\n  /**\n   * Index of the added/removed/moved waypoint.\n   *\n   * Never presents for {@link MapLibreGlDirectionsEventType.setwaypoints|`setwaypoints`} and\n   * {@link MapLibreGlDirectionsEventType.rotatewaypoints|`rotatewaypoints`} events.\n   */\n  index: number;\n\n  /**\n   * Coordinates from which the waypoint has been moved.\n   *\n   * Only presents when it's the {@link MapLibreGlDirectionsEventType.movewaypoint|`movewaypoint`} event.\n   */\n  initialCoordinates: [number, number];\n}\n\nexport class MapLibreGlDirectionsWaypointEvent\n  implements\n    MapLibreGlDirectionsEvent<\n      MapMouseEvent | MapTouchEvent | undefined,\n      \"setwaypoints\" | \"rotatewaypoints\" | \"addwaypoint\" | \"removewaypoint\" | \"movewaypoint\"\n    >\n{\n  /**\n   * @private\n   */\n  constructor(\n    type: \"setwaypoints\" | \"rotatewaypoints\" | \"addwaypoint\" | \"removewaypoint\" | \"movewaypoint\",\n    originalEvent: MapMouseEvent | MapTouchEvent | undefined,\n    data?: Partial<MapLibreGlDirectionsWaypointEventData>,\n  ) {\n    this.type = type;\n    this.originalEvent = originalEvent;\n    this.data = data;\n  }\n\n  type;\n  target!: Map;\n  originalEvent: MapMouseEvent | MapTouchEvent | undefined;\n  data?: Partial<MapLibreGlDirectionsWaypointEventData>;\n}\n\nexport type MapLibreGlDirectionsRoutingEventData = Directions;\n\nexport class MapLibreGlDirectionsRoutingEvent\n  implements MapLibreGlDirectionsEvent<MapLibreGlDirectionsWaypointEvent, \"fetchroutesstart\" | \"fetchroutesend\">\n{\n  /**\n   * @private\n   */\n  constructor(\n    type: \"fetchroutesstart\" | \"fetchroutesend\",\n    originalEvent: MapLibreGlDirectionsWaypointEvent,\n    data?: MapLibreGlDirectionsRoutingEventData,\n  ) {\n    this.type = type;\n    this.originalEvent = originalEvent;\n    this.data = data;\n  }\n\n  type;\n  target!: Map;\n  originalEvent: MapLibreGlDirectionsWaypointEvent;\n  /**\n   * The server's response.\n   *\n   * Only presents when it's the {@link MapLibreGlDirectionsEventType.fetchroutesend|`fetchroutesend`} event, but might\n   * be `undefined` in case the request to fetch directions failed.\n   *\n   * @see http://project-osrm.org/docs/v5.24.0/api/#responses\n   */\n  data?: MapLibreGlDirectionsRoutingEventData;\n}\n","import type { LayerSpecification } from \"maplibre-gl\";\n\n/**\n * The {@link default|MapLibreGlDirections} configuration object's interface.\n */\nexport interface MapLibreGlDirectionsConfiguration {\n  /**\n   * An API-provider URL to make the routing requests to.\n   *\n   * Any {@link http://project-osrm.org/|OSRM}-compatible or\n   * {@link https://docs.mapbox.com/api/navigation/directions/|Mapbox Directions API}-compatible API-provider is\n   * supported.\n   *\n   * @default `\"https://router.project-osrm.org/route/v1\"`\n   *\n   * @example\n   * ```\n   * api: \"https://router.project-osrm.org/route/v1\"\n   * ```\n   *\n   * @example\n   * ```\n   * api: \"https://api.mapbox.com/directions/v5\"\n   * ```\n   */\n  api: string;\n\n  /**\n   * A routing profile to use. The value depends on the API-provider of choice.\n   *\n   * @see {@link http://project-osrm.org/docs/v5.24.0/api/#requests|OSRM #Requests}\n   * @see {@link https://docs.mapbox.com/api/navigation/directions/#routing-profiles|Mapbox Direction API #Routing profiles}\n   *\n   * @default `\"driving\"`\n   *\n   * @example\n   * ```\n   * api: \"https://router.project-osrm.org/route/v1\",\n   * profile: \"driving\"\n   * ```\n   *\n   * @example\n   * ```\n   * api: \"https://api.mapbox.com/directions/v5\",\n   * profile: \"mapbox/driving-traffic\"\n   * ```\n   */\n  profile: string;\n\n  /**\n   * A list of the request-payload parameters that are passed along with routing requests.\n   *\n   * __Note__ that the `access-token` request-parameter has a special treatment when used along with\n   * {@link makePostRequest|`makePostRequest: true`}. It's automatically removed from the `FormData` and passed as a URL\n   * query-parameter as the Mapbox Directions API {@link https://docs.mapbox.com/api/navigation/http-post/|requires}.\n   *\n   * @default `{}`\n   *\n   * @example\n   * ```\n   * requestOptions: {\n   *   overview: \"full\",\n   *   steps: \"true\"\n   * }\n   * ```\n   *\n   * @example\n   * ```\n   * api: \"https://api.mapbox.com/directions/v5\",\n   * profile: \"mapbox/driving-traffic\",\n   * requestOptions: {\n   *   access_token: \"<mapbox-access-token>\",\n   *   annotations: \"congestion\",\n   *   geometries: \"polyline6\"\n   * }\n   * ```\n   */\n  requestOptions: Partial<Record<string, string>>;\n\n  /**\n   * A timeout in ms after which a still-unresolved routing-request automatically gets aborted.\n   *\n   * @default `null` (no timeout)\n   *\n   * @example\n   * ```\n   * // abort requests that take longer then 5s to complete\n   * requestTimeout: 5000\n   * ```\n   */\n  requestTimeout: number | null;\n\n  /**\n   * Whether to make a {@link https://docs.mapbox.com/api/navigation/http-post/|POST request} instead of a GET one.\n   *\n   * __Note__ that this is only supported by the Mapbox Directions API. Don't set the value to `true` if using an\n   * OSRM-compatible API-provider.\n   *\n   * @default `false`\n   *\n   * @example\n   * ```\n   * api: \"https://api.mapbox.com/directions/v5\",\n   * profile: \"mapbox/driving-traffic\",\n   * makePostRequest: true\n   * ```\n   */\n  makePostRequest: boolean;\n\n  /**\n   * A name of the source used by the instance. Also used as a prefix for the default layers' names.\n   *\n   * __Note__ that if you decide to set this field to some custom value, you'd also need to update the following\n   * settings accordingly: {@link sensitiveWaypointLayers}, {@link sensitiveSnappointLayers},\n   * {@link sensitiveRoutelineLayers} and {@link sensitiveAltRoutelineLayers}.\n   *\n   * @default `\"maplibre-gl-directions\"`\n   *\n   * @example\n   * ```\n   * sourceName: \"my-directions\"\n   * ```\n   */\n  sourceName: string;\n\n  /**\n   * The layers used by the plugin.\n   *\n   * @default The value returned by the {@link layersFactory|`layersFactory`} invoked with the passed\n   * {@link pointsScalingFactor|`options.pointsScalingFactor`} and\n   * {@link linesScalingFactor|`options.linesScalingFactor`}\n   *\n   * __Note__ that you don't have to create layers with the {@link layersFactory|`layersFactory`}. Any\n   * `LayerSpecification[]` value is OK.\n   *\n   * __Note__ that if you add custom layers then you'd most probably want to register them as sensitive layers using\n   * the {@link sensitiveWaypointLayers|`options.sensitiveWaypointLayers`},\n   * {@link sensitiveSnappointLayers|`options.sensitiveSnappointLayers`},\n   * {@link sensitiveAltRoutelineLayers|`options.sensitiveAltRoutelineLayers`} and\n   * {@link sensitiveRoutelineLayers|`options.sensitiveRoutelineLayers`} options.\n   *\n   * @example\n   * ```\n   * // Use the default layers with all the points increased by 1.5 times and all the lines increased by 2 times and an additional `\"my-custom-layer\"` layer.\n   * {\n   *   layers: layersFactory(1.5, 2).concat([\n   *     {\n   *       id: \"my-custom-layer\",\n   *       // ...\n   *     }\n   *   ])\n   * }\n   * ```\n   */\n  layers: LayerSpecification[];\n\n  /**\n   * A factor by which all the default points' dimensions should be increased. The value is passed as is to the\n   * {@link layersFactory|`layersFactory`}'s first argument.\n   *\n   * __Note__ that the option has no effect when the `layers` option is provided.\n   *\n   * @default `1`\n   *\n   * @example\n   * ```\n   * // Increase all the points by 1.5 times when the map is used on a touch-enabled device\n   * linesScalingFactor: isTouchDevice ? 1.5 : 1\n   * ```\n   */\n  pointsScalingFactor: number;\n\n  /**\n   * A factor by which all the default lines' dimensions should be increased. The value is passed as is to the\n   * {@link layersFactory|`layersFactory`}'s second argument.\n   *\n   * __Note__ that the option has no effect on the snaplines.\n   *\n   * __Note__ that the option has no effect when the `layers` option is provided.\n   *\n   * @default `1`\n   *\n   * @example\n   * ```\n   * // Increase all the lines by 2 times when the map is used on a touch-enabled device\n   * linesScalingFactor: isTouchDevice ? 2 : 1\n   * ```\n   */\n  linesScalingFactor: number;\n\n  /**\n   * IDs of the layers that are used to represent the waypoints which should be interactive.\n   *\n   * @default `[\"maplibre-gl-directions-waypoint\", \"maplibre-gl-directions-waypoint-casing\"]`\n   *\n   * @example\n   * ```\n   * sensitiveSnappointLayers: [\n   *   \"maplibre-gl-directions-waypoint\",\n   *   \"maplibre-gl-directions-waypoint-casing\",\n   *   \"my-custom-waypoint-layer\"\n   * ]\n   * ```\n   */\n  sensitiveWaypointLayers: string[];\n\n  /**\n   * IDs of the layers that are used to represent the snappoints which should be interactive.\n   *\n   * @default `[\"maplibre-gl-directions-snappoint\", \"maplibre-gl-directions-snappoint-casing\"]`\n   *\n   * @example\n   * ```\n   * sensitiveSnappointLayers: [\n   *   \"maplibre-gl-directions-snappoint\",\n   *   \"maplibre-gl-directions-snappoint-casing\",\n   *   \"my-custom-snappoint-layer\"\n   * ]\n   * ```\n   */\n  sensitiveSnappointLayers: string[];\n\n  /**\n   * IDs of the layers that are used to represent the selected route line which should be interactive.\n   *\n   * @default `[\"maplibre-gl-directions-routeline\", \"maplibre-gl-directions-routeline-casing\"]`\n   *\n   * @example\n   * ```\n   * sensitiveRoutelineLayers: [\n   *   \"maplibre-gl-directions-routeline\",\n   *   \"maplibre-gl-directions-routeline-casing\",\n   *   \"my-custom-routeline-layer\"\n   * ]\n   * ```\n   */\n  sensitiveRoutelineLayers: string[];\n\n  /**\n   * IDs of the layers that are used to represent the alternative route lines which should be interactive.\n   *\n   * @default `[\"maplibre-gl-directions-alt-routeline\", \"maplibre-gl-directions-alt-routeline-casing\"]`\n   *\n   * @example\n   * ```\n   * sensitiveAltRoutelineLayers: [\n   *   \"maplibre-gl-directions-alt-routeline\",\n   *   \"maplibre-gl-directions-alt-routeline-casing\",\n   *   \"my-custom-alt-routeline-layer\"\n   * ]\n   * ```\n   */\n  sensitiveAltRoutelineLayers: string[];\n\n  /**\n   * A minimal amount of pixels a waypoint or the hoverpoint must be dragged in order for the drag-event to be\n   * respected, and for network requests to be made when using {@link refreshOnMove|`refreshOnMove: true`}. Should be a number >= `0`.\n   * Any negative value is treated as `0`.\n   *\n   * @default `10`\n   *\n   * @example\n   * ```\n   * // Don't respect drag-events where a point was dragged for less than 5px away from its initial location\n   * dragThreshold: 5\n   * ```\n   */\n  dragThreshold: number;\n\n  /**\n   * Whether to update a route while dragging a waypoint/hoverpoint instead of only when dropping it\n   *\n   * @default `false`\n   *\n   * @example\n   * ```\n   * // make the route update while dragging\n   * refreshOnMove: true\n   * ```\n   */\n  refreshOnMove: boolean;\n\n  /**\n   * Whether to support waypoints' {@link https://docs.mapbox.com/api/navigation/directions/#optional-parameters|bearings}.\n   *\n   * @see {@link http://project-osrm.org/docs/v5.24.0/api/#requests|OSRM #Requests}\n   * @see {@link https://docs.mapbox.com/api/navigation/directions/#optional-parameters|Mapbox Direction API #Optional parameters}\n   *\n   * @default `false`\n   *\n   * @example\n   * ```\n   * // enable the bearings support\n   * bearings: true\n   * ```\n   */\n  bearings: boolean;\n}\n\nexport const MapLibreGlDirectionsDefaultConfiguration: Omit<MapLibreGlDirectionsConfiguration, \"layers\"> = {\n  api: \"https://router.project-osrm.org/route/v1\",\n  profile: \"driving\",\n  requestOptions: {},\n  requestTimeout: null, // can't use Infinity here because of this: https://github.com/denysdovhan/wtfjs/issues/61#issuecomment-325321753\n  makePostRequest: false,\n  sourceName: \"maplibre-gl-directions\",\n  pointsScalingFactor: 1,\n  linesScalingFactor: 1,\n  sensitiveWaypointLayers: [\"maplibre-gl-directions-waypoint\", \"maplibre-gl-directions-waypoint-casing\"],\n  sensitiveSnappointLayers: [\"maplibre-gl-directions-snappoint\", \"maplibre-gl-directions-snappoint-casing\"],\n  sensitiveRoutelineLayers: [\"maplibre-gl-directions-routeline\", \"maplibre-gl-directions-routeline-casing\"],\n  sensitiveAltRoutelineLayers: [\"maplibre-gl-directions-alt-routeline\", \"maplibre-gl-directions-alt-routeline-casing\"],\n  dragThreshold: 10,\n  refreshOnMove: false,\n  bearings: false,\n};\n\nexport type PointType = \"WAYPOINT\" | \"SNAPPOINT\" | \"HOVERPOINT\" | string;\n\n// server response. Only the necessary for the plugin fields\n\nexport interface Directions {\n  code: \"Ok\" | string;\n  message?: string;\n  routes: Route[];\n  waypoints: Snappoint[];\n}\n\nexport type Geometry = PolylineGeometry | GeoJSONGeometry;\nexport type GeoJSONGeometry = {\n  coordinates: [number, number][];\n};\nexport type PolylineGeometry = string;\n\nexport interface Route {\n  [P: string]: unknown;\n  geometry: Geometry;\n  legs: Leg[];\n}\n\nexport interface Leg {\n  [P: string]: unknown;\n  annotation?: {\n    congestion?: (\"unknown\" | \"low\" | \"moderate\" | \"heavy\" | \"severe\")[];\n    congestion_numeric?: (number | null)[];\n  };\n}\n\nexport interface Snappoint {\n  [P: string]: unknown;\n  location: [number, number];\n}\n","import type { LayerSpecification, LineLayerSpecification } from \"maplibre-gl\";\nimport type { CircleLayerSpecification } from \"@maplibre/maplibre-gl-style-spec\";\n\nexport const colors = {\n  snapline: \"#34343f\",\n  altRouteline: \"#9e91be\",\n  routelineFoot: \"#3665ff\",\n  routelineBike: \"#63c4ff\",\n  routeline: \"#7b51f8\",\n  congestionLow: \"#42c74c\",\n  congestionHigh: \"#d72359\",\n  hoverpoint: \"#30a856\",\n  snappoint: \"#cb3373\",\n  snappointHighlight: \"#e50d3f\",\n  waypointFoot: \"#3665ff\",\n  waypointFootHighlight: \"#0942ff\",\n  waypointBike: \"#63c4ff\",\n  waypointBikeHighlight: \"#0bb8ff\",\n  waypoint: \"#7b51f8\",\n  waypointHighlight: \"#6d26d7\",\n};\n\nconst routelineColor: NonNullable<LineLayerSpecification[\"paint\"]>[\"line-color\"] = [\n  \"case\",\n  [\"==\", [\"get\", \"profile\", [\"get\", \"arriveSnappointProperties\"]], \"foot\"],\n  colors.routelineFoot,\n  [\"==\", [\"get\", \"profile\", [\"get\", \"arriveSnappointProperties\"]], \"bike\"],\n  colors.routelineBike,\n  [\n    \"interpolate-hcl\",\n    [\"linear\"],\n    [\"get\", \"congestion\"],\n    0,\n    colors.routeline,\n    1,\n    colors.congestionLow,\n    100,\n    colors.congestionHigh,\n  ],\n];\n\nconst waypointColor: NonNullable<CircleLayerSpecification[\"paint\"]>[\"circle-color\"] = [\n  \"case\",\n  [\"==\", [\"get\", \"profile\"], \"foot\"],\n  [\"case\", [\"boolean\", [\"get\", \"highlight\"], false], colors.waypointFootHighlight, colors.waypointFoot],\n  [\"==\", [\"get\", \"profile\"], \"bike\"],\n  [\"case\", [\"boolean\", [\"get\", \"highlight\"], false], colors.waypointBikeHighlight, colors.waypointBike],\n  [\"case\", [\"boolean\", [\"get\", \"highlight\"], false], colors.waypointHighlight, colors.waypoint],\n];\n\nconst snappointColor: NonNullable<CircleLayerSpecification[\"paint\"]>[\"circle-color\"] = [\n  \"case\",\n  [\"boolean\", [\"get\", \"highlight\"], false],\n  colors.snappointHighlight,\n  colors.snappoint,\n];\n\n/**\n * Builds the\n * {@link https://github.com/smellyshovel/maplibre-gl-directions/blob/main/src/directions/layers.ts#L3|standard\n * `MapLibreGlDirections` layers} with optionally scaled features.\n *\n * @param pointsScalingFactor A number to multiply the initial points' dimensions by\n * @param linesScalingFactor A number to multiply the initial lines' dimensions by\n * @param sourceName A name of the source used by the instance and layers names' prefix\n */\nexport default function layersFactory(\n  pointsScalingFactor = 1,\n  linesScalingFactor = 1,\n  sourceName = \"maplibre-gl-directions\",\n): LayerSpecification[] {\n  const pointCasingCircleRadius: NonNullable<CircleLayerSpecification[\"paint\"]>[\"circle-radius\"] = [\n    \"interpolate\",\n    [\"exponential\", 1.5],\n    [\"zoom\"],\n    // don't forget it's the radius! The visible value is diameter (which is 2x)\n    // on zoom levels 0-5 should be 5px more than the routeline casing. 7 + 5 = 12.\n    // When highlighted should be +2px more. 12 + 2 = 14\n    0,\n    // highlighted to default ratio (epsilon) = 14 / 12 ~= 1.16\n    [\n      \"case\",\n      [\"boolean\", [\"get\", \"highlight\"], [\"==\", [\"get\", \"type\"], \"HOVERPOINT\"]],\n      14 * pointsScalingFactor,\n      12 * pointsScalingFactor,\n    ],\n    5,\n    [\n      \"case\",\n      [\"boolean\", [\"get\", \"highlight\"], [\"==\", [\"get\", \"type\"], \"HOVERPOINT\"]],\n      14 * pointsScalingFactor,\n      12 * pointsScalingFactor,\n    ],\n    // exponentially grows on zoom levels 5-18 finally becoming the same 5px wider than the routeline's casing on\n    // the same zoom level: 23 + 5 = 28px\n    18,\n    // highlighted = default ~= 33\n    [\n      \"case\",\n      [\"boolean\", [\"get\", \"highlight\"], [\"==\", [\"get\", \"type\"], \"HOVERPOINT\"]],\n      33 * pointsScalingFactor,\n      28 * pointsScalingFactor,\n    ],\n  ];\n\n  const pointCircleRadius: NonNullable<CircleLayerSpecification[\"paint\"]>[\"circle-radius\"] = [\n    \"interpolate\",\n    [\"exponential\", 1.5],\n    [\"zoom\"],\n    // on zoom levels 0-5 - 5px smaller than the casing. 12 - 5 = 7.\n    0,\n    // feature to casing ratio (psi) = 7 / 12 ~= 0.58\n    // highlighted to default ratio (epsilon) = 9 / 7 ~= 1.28\n    [\n      \"case\",\n      [\"boolean\", [\"get\", \"highlight\"], [\"==\", [\"get\", \"type\"], \"HOVERPOINT\"]],\n      9 * pointsScalingFactor,\n      7 * pointsScalingFactor,\n    ],\n    5,\n    [\n      \"case\",\n      [\"boolean\", [\"get\", \"highlight\"], [\"==\", [\"get\", \"type\"], \"HOVERPOINT\"]],\n      9 * pointsScalingFactor,\n      7 * pointsScalingFactor,\n    ],\n    // exponentially grows on zoom levels 5-18 finally becoming psi times the casing\n    18,\n    // psi * 28 ~= 16\n    // when highlighted multiply by epsilon ~= 21\n    [\n      \"case\",\n      [\"boolean\", [\"get\", \"highlight\"], [\"==\", [\"get\", \"type\"], \"HOVERPOINT\"]],\n      21 * pointsScalingFactor,\n      16 * pointsScalingFactor,\n    ],\n  ];\n\n  const lineWidth: NonNullable<LineLayerSpecification[\"paint\"]>[\"line-width\"] = [\n    \"interpolate\",\n    [\"exponential\", 1.5],\n    [\"zoom\"],\n    // on zoom levels 0-5 - 4px smaller than the casing (2px on each side). 7 - 4 = 3.\n    // Doesn't change when highlighted\n    0,\n    // feature to casing ratio (psi) = 3 / 7 ~= 0.42\n    3 * linesScalingFactor,\n    5,\n    3 * linesScalingFactor,\n    // exponentially grows on zoom levels 5-18 finally becoming psi times the casing\n    18,\n    // psi * 23  ~= 10\n    10 * linesScalingFactor,\n  ];\n\n  const lineCasingWidth: NonNullable<LineLayerSpecification[\"paint\"]>[\"line-width\"] = [\n    \"interpolate\",\n    [\"exponential\", 1.5],\n    [\"zoom\"],\n    // on zoom levels 0-5 - 7px by default and 10px when highlighted\n    0,\n    // highlighted to default ratio (epsilon) = 10 / 7 ~= 1.42\n    [\"case\", [\"boolean\", [\"get\", \"highlight\"], false], 10 * linesScalingFactor, 7 * linesScalingFactor],\n    5,\n    [\"case\", [\"boolean\", [\"get\", \"highlight\"], false], 10 * linesScalingFactor, 7 * linesScalingFactor],\n    // exponentially grows on zoom levels 5-18 finally becoming 32px when highlighted\n    18,\n    // default = 32 / epsilon ~= 23\n    [\"case\", [\"boolean\", [\"get\", \"highlight\"], false], 32 * linesScalingFactor, 23 * linesScalingFactor],\n  ];\n\n  return [\n    {\n      id: `${sourceName}-snapline`,\n      type: \"line\",\n      source: sourceName,\n      layout: {\n        \"line-cap\": \"round\",\n        \"line-join\": \"round\",\n      },\n      paint: {\n        \"line-dasharray\": [3, 3],\n        \"line-color\": colors.snapline,\n        \"line-opacity\": 0.65,\n        \"line-width\": 3,\n      },\n      filter: [\"==\", [\"get\", \"type\"], \"SNAPLINE\"],\n    },\n\n    {\n      id: `${sourceName}-alt-routeline-casing`,\n      type: \"line\",\n      source: sourceName,\n      layout: {\n        \"line-cap\": \"butt\",\n        \"line-join\": \"round\",\n      },\n      paint: {\n        \"line-color\": colors.altRouteline,\n        \"line-opacity\": 0.55,\n        \"line-width\": lineCasingWidth,\n      },\n      filter: [\"==\", [\"get\", \"route\"], \"ALT\"],\n    },\n    {\n      id: `${sourceName}-alt-routeline`,\n      type: \"line\",\n      source: sourceName,\n      layout: {\n        \"line-cap\": \"butt\",\n        \"line-join\": \"round\",\n      },\n      paint: {\n        \"line-color\": colors.altRouteline,\n        \"line-opacity\": 0.85,\n        \"line-width\": lineWidth,\n      },\n      filter: [\"==\", [\"get\", \"route\"], \"ALT\"],\n    },\n\n    {\n      id: `${sourceName}-routeline-casing`,\n      type: \"line\",\n      source: sourceName,\n      layout: {\n        \"line-cap\": \"butt\",\n        \"line-join\": \"round\",\n      },\n      paint: {\n        \"line-color\": routelineColor,\n        \"line-opacity\": 0.55,\n        \"line-width\": lineCasingWidth,\n      },\n      filter: [\"==\", [\"get\", \"route\"], \"SELECTED\"],\n    },\n    {\n      id: `${sourceName}-routeline`,\n      type: \"line\",\n      source: sourceName,\n      layout: {\n        \"line-cap\": \"butt\",\n        \"line-join\": \"round\",\n      },\n      paint: {\n        \"line-color\": routelineColor,\n        \"line-opacity\": 0.85,\n        \"line-width\": lineWidth,\n      },\n      filter: [\"==\", [\"get\", \"route\"], \"SELECTED\"],\n    },\n\n    {\n      id: `${sourceName}-hoverpoint-casing`,\n      type: \"circle\",\n      source: sourceName,\n      paint: {\n        \"circle-radius\": pointCasingCircleRadius,\n        \"circle-color\": colors.hoverpoint,\n        \"circle-opacity\": 0.65,\n      },\n      filter: [\"==\", [\"get\", \"type\"], \"HOVERPOINT\"],\n    },\n    {\n      id: `${sourceName}-hoverpoint`,\n      type: \"circle\",\n      source: sourceName,\n      paint: {\n        // same as snappoint, but always hig(since it's always highlighted while present on the map)\n        \"circle-radius\": pointCircleRadius,\n        \"circle-color\": colors.hoverpoint,\n      },\n      filter: [\"==\", [\"get\", \"type\"], \"HOVERPOINT\"],\n    },\n\n    {\n      id: `${sourceName}-snappoint-casing`,\n      type: \"circle\",\n      source: sourceName,\n      paint: {\n        \"circle-radius\": pointCasingCircleRadius,\n        \"circle-color\": snappointColor,\n        \"circle-opacity\": 0.65,\n      },\n      filter: [\"==\", [\"get\", \"type\"], \"SNAPPOINT\"],\n    },\n    {\n      id: `${sourceName}-snappoint`,\n      type: \"circle\",\n      source: sourceName,\n      paint: {\n        \"circle-radius\": pointCircleRadius,\n        \"circle-color\": snappointColor,\n      },\n      filter: [\"==\", [\"get\", \"type\"], \"SNAPPOINT\"],\n    },\n\n    {\n      id: `${sourceName}-waypoint-casing`,\n      type: \"circle\",\n      source: sourceName,\n      paint: {\n        \"circle-radius\": pointCasingCircleRadius,\n        \"circle-color\": waypointColor,\n        \"circle-opacity\": 0.65,\n      },\n      filter: [\"==\", [\"get\", \"type\"], \"WAYPOINT\"],\n    },\n\n    {\n      id: `${sourceName}-waypoint`,\n      type: \"circle\",\n      source: sourceName,\n      paint: {\n        \"circle-radius\": pointCircleRadius,\n        \"circle-color\": waypointColor,\n      },\n      filter: [\"==\", [\"get\", \"type\"], \"WAYPOINT\"],\n    },\n  ] satisfies LayerSpecification[];\n}\n","export const urlAlphabet =\n  'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n  let mask = (2 << Math.log2(alphabet.length - 1)) - 1\n  let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n  return (size = defaultSize) => {\n    let id = ''\n    while (true) {\n      let bytes = getRandom(step)\n      let j = step | 0\n      while (j--) {\n        id += alphabet[bytes[j] & mask] || ''\n        if (id.length >= size) return id\n      }\n    }\n  }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n  customRandom(alphabet, size | 0, random)\nexport let nanoid = (size = 21) => {\n  let id = ''\n  let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n  while (size--) {\n    id += scopedUrlAlphabet[bytes[size] & 63]\n  }\n  return id\n}\n","// https://github.com/mapbox/polyline/blob/master/src/polyline.js\n// Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)\n//\n// Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js)\n// by [Mark McClure](http://facstaff.unca.edu/mcmcclur/)\nfunction py2_round(value) {\n    // Google's polyline algorithm uses the same rounding strategy as Python 2,\n    // which is different from JS for negative values\n    return Math.floor(Math.abs(value) + 0.5) * (value >= 0 ? 1 : -1);\n}\nfunction encodeNumber(current, previous, factor) {\n    current = py2_round(current * factor);\n    previous = py2_round(previous * factor);\n    let coordinate = current - previous;\n    coordinate <<= 1;\n    if (current - previous < 0) {\n        coordinate = ~coordinate;\n    }\n    let output = \"\";\n    while (coordinate >= 0x20) {\n        output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63);\n        coordinate >>= 5;\n    }\n    output += String.fromCharCode(coordinate + 63);\n    return output;\n}\nfunction resultChange(result) {\n    return result & 1 ? ~(result >> 1) : result >> 1;\n}\n/**\n * Decodes any string into a [longitude, latitude] coordinates array.\n *\n * Any string is a valid polyline, but if you provide this\n * with an arbitrary string, it'll produce coordinates well\n * outside of the normal range.\n */\nfunction decode(str, precision = 5) {\n    const factor = Math.pow(10, precision);\n    let index = 0;\n    let lat = 0;\n    let lng = 0;\n    const coordinates = [];\n    let shift = 0;\n    let result = 0;\n    let byte = null;\n    let latitude_change;\n    let longitude_change;\n    // Coordinates have variable length when encoded, so just keep\n    // track of whether we've hit the end of the string. In each\n    // loop iteration, a single coordinate is decoded.\n    while (index < str.length) {\n        // Reset shift, result, and byte\n        byte = null;\n        shift = 0;\n        result = 0;\n        do {\n            byte = str.charCodeAt(index++) - 63;\n            result |= (byte & 0x1f) << shift;\n            shift += 5;\n        } while (byte >= 0x20);\n        latitude_change = resultChange(result);\n        shift = result = 0;\n        do {\n            byte = str.charCodeAt(index++) - 63;\n            result |= (byte & 0x1f) << shift;\n            shift += 5;\n        } while (byte >= 0x20);\n        longitude_change = resultChange(result);\n        lat += latitude_change;\n        lng += longitude_change;\n        coordinates.push([lng / factor, lat / factor]);\n    }\n    return coordinates;\n}\n/**\n * Encodes the given [latitude, longitude] coordinates array.\n *\n * @param coordinates Coordinates, in longitude, latitude order\n * @returns encoded polyline\n */\nfunction encode(coordinates, precision = 5) {\n    if (!coordinates.length) {\n        return \"\";\n    }\n    const factor = Math.pow(10, precision);\n    let output = encodeNumber(coordinates[0][1], 0, factor) +\n        encodeNumber(coordinates[0][0], 0, factor);\n    for (let i = 1; i < coordinates.length; i++) {\n        const a = coordinates[i];\n        const b = coordinates[i - 1];\n        output += encodeNumber(a[1], b[1], factor);\n        output += encodeNumber(a[0], b[0], factor);\n    }\n    return output;\n}\n/**\n * Encodes a GeoJSON LineString feature/geometry.\n *\n * @param geojson A LineString\n */\nfunction geoJSONToPolyline(geojson, precision = 5) {\n    return encode(geojson.coordinates, precision);\n}\n/**\n * Decodes to a GeoJSON LineString geometry.\n *\n * @param str An encoded polyline as a string.\n */\nfunction polylineToGeoJSON(str, precision = 5) {\n    const coords = decode(str, precision);\n    return {\n        type: \"LineString\",\n        coordinates: coords,\n    };\n}\n\nexport { decode, encode, geoJSONToPolyline, polylineToGeoJSON };\n//# sourceMappingURL=polyline.es.mjs.map\n","import type { GeoJSONGeometry, Geometry, Leg, MapLibreGlDirectionsConfiguration, PolylineGeometry } from \"./types\";\nimport { decode } from \"@placemarkio/polyline\";\nimport type { Position, Feature, Point } from \"geojson\";\n\n/**\n * Decodes the geometry of a route to the form of a coordinates array.\n */\nexport function geometryDecoder(\n  requestOptions: MapLibreGlDirectionsConfiguration[\"requestOptions\"],\n  geometry: Geometry,\n): Position[] {\n  if (requestOptions.geometries === \"geojson\") {\n    return (geometry as GeoJSONGeometry).coordinates;\n  } else if (requestOptions.geometries === \"polyline6\") {\n    return decode(geometry as PolylineGeometry, 6);\n  } else {\n    return decode(geometry as PolylineGeometry, 5);\n  }\n}\n\n/**\n * Decodes the congestion level of a specific segment of a route leg.\n */\nexport function congestionLevelDecoder(\n  requestOptions: MapLibreGlDirectionsConfiguration[\"requestOptions\"],\n  annotation: Leg[\"annotation\"] | undefined,\n  segmentIndex: number,\n): number {\n  if (requestOptions.annotations?.includes(\"congestion_numeric\")) {\n    return annotation?.congestion_numeric?.[segmentIndex] ?? 0;\n  } else if (requestOptions.annotations?.includes(\"congestion\")) {\n    switch (annotation?.congestion?.[segmentIndex] ?? \"\") {\n      case \"unknown\":\n        return 0;\n      case \"low\":\n        return 1;\n      case \"moderate\":\n        return 34;\n      case \"heavy\":\n        return 77;\n      case \"severe\":\n        return 100;\n      default:\n        return 0;\n    }\n  } else {\n    return 0;\n  }\n}\n\n/**\n * Compares two coordinates and returns `true` if they are equal taking into account that there's an allowable error in\n * 0.00001 degree when using \"polyline\" geometries (5 fractional-digits precision).\n */\nexport function coordinatesComparator(\n  requestOptions: MapLibreGlDirectionsConfiguration[\"requestOptions\"],\n  a: Position,\n  b: Position,\n): boolean {\n  if (!requestOptions.geometries || requestOptions.geometries === \"polyline\") {\n    return Math.abs(a[0] - b[0]) <= 0.00001 && Math.abs(a[1] - b[1]) <= 0.00001;\n  } else {\n    return a[0] === b[0] && a[1] === b[1];\n  }\n}\n\n/**\n * Gets coordinates of a point feature\n */\nexport function getWaypointsCoordinates(waypoints: Feature<Point>[]): [number, number][] {\n  return waypoints.map((waypoint) => {\n    return [waypoint.geometry.coordinates[0], waypoint.geometry.coordinates[1]];\n  });\n}\n\n/**\n * Gets bearings out of properties of point features\n */\nexport function getWaypointsBearings(waypoints: Feature<Point>[]): ([number, number] | undefined)[] {\n  return waypoints.map((waypoint) => {\n    return Array.isArray(waypoint.properties?.bearing)\n      ? [waypoint.properties?.bearing[0], waypoint.properties?.bearing[1]]\n      : undefined;\n  });\n}\n","import type { MapLibreGlDirectionsConfiguration, PointType, Route } from \"./types\";\nimport type { Feature, LineString, Point } from \"geojson\";\nimport { MapLibreGlDirectionsDefaultConfiguration } from \"./types\";\nimport layersFactory from \"./layers\";\nimport { nanoid } from \"nanoid\";\nimport { congestionLevelDecoder, coordinatesComparator, geometryDecoder } from \"./helpers\";\n\n/**\n * @protected\n *\n * Takes a missing or an incomplete {@link MapLibreGlDirectionsConfiguration|configuration object}, augments it with the\n * default values and returns the complete configuration object.\n */\nexport function buildConfiguration(\n  customConfiguration?: Partial<MapLibreGlDirectionsConfiguration>,\n): MapLibreGlDirectionsConfiguration {\n  const layers = layersFactory(\n    customConfiguration?.pointsScalingFactor,\n    customConfiguration?.linesScalingFactor,\n    customConfiguration?.sourceName,\n  );\n  return Object.assign({}, MapLibreGlDirectionsDefaultConfiguration, { layers }, customConfiguration);\n}\n\nexport type RequestData = {\n  method: \"get\" | \"post\";\n  url: string;\n  payload: URLSearchParams;\n};\n\n/**\n * @protected\n *\n * Builds the routing-request method, URL and payload based on the provided\n * {@link MapLibreGlDirectionsConfiguration|configuration} and the waypoints' coordinates.\n */\nexport function buildRequest(\n  configuration: MapLibreGlDirectionsConfiguration,\n  waypointsCoordinates: [number, number][],\n  waypointsBearings?: ([number, number] | undefined)[],\n): RequestData {\n  const method = configuration.makePostRequest ? \"post\" : \"get\";\n\n  let url: string;\n  let payload: URLSearchParams;\n\n  if (method === \"get\") {\n    url = `${configuration.api}/${configuration.profile}/${waypointsCoordinates.join(\";\")}`;\n    payload = new URLSearchParams(configuration.requestOptions as Record<string, string>);\n  } else {\n    url = `${configuration.api}/${configuration.profile}${\n      configuration.requestOptions.access_token ? `?access_token=${configuration.requestOptions.access_token}` : \"\"\n    }`;\n\n    const formData = new FormData();\n\n    Object.entries(configuration.requestOptions as Record<string, string>).forEach(([key, value]) => {\n      if (key !== \"access_token\") {\n        formData.set(key, value);\n      }\n    });\n\n    formData.set(\"coordinates\", waypointsCoordinates.join(\";\"));\n\n    // the URLSearchParams constructor works perfectly fine with FormData, so ignore the TypeScript's complaint\n    // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n    // @ts-ignore\n    payload = new URLSearchParams(formData);\n  }\n\n  if (configuration.bearings && waypointsBearings) {\n    payload.set(\n      \"bearings\",\n      waypointsBearings\n        .map((waypointBearing) => {\n          if (waypointBearing) {\n            return `${waypointBearing[0]},${waypointBearing[1]}`;\n          } else {\n            return \"\";\n          }\n        })\n        .join(\";\"),\n    );\n  }\n\n  return {\n    method,\n    url,\n    payload,\n  };\n}\n\n/**\n * @protected\n *\n * Creates a {@link Feature<Point>|GeoJSON Point Feature} of one of the ${@link PointType|known types} with a given\n * coordinate.\n */\nexport function buildPoint(\n  coordinate: [number, number],\n  type: PointType,\n  properties?: Record<string, unknown>,\n): Feature<Point> {\n  return {\n    type: \"Feature\",\n    geometry: {\n      type: \"Point\",\n      coordinates: coordinate,\n    },\n    properties: {\n      type,\n      id: nanoid(),\n      ...(properties ?? {}),\n    },\n  };\n}\n\n/**\n * @protected\n *\n * Creates a ${@link Feature<LineString>|GeoJSON LineString Features} array where each feature represents a\n * line connecting a waypoint with its respective snappoint and the hoverpoint with its respective snappoints.\n */\nexport function buildSnaplines(\n  waypointsCoordinates: [number, number][],\n  snappointsCoordinates: [number, number][],\n  hoverpointCoordinates: [number, number] | undefined,\n  departSnappointIndex: number, // might be -1\n  showHoverpointSnaplines = false,\n): Feature<LineString>[] {\n  if (waypointsCoordinates.length !== snappointsCoordinates.length) return [];\n\n  const snaplines = waypointsCoordinates.map((waypointCoordinates, index) => {\n    return {\n      type: \"Feature\",\n      geometry: {\n        type: \"LineString\",\n        coordinates: [\n          [waypointCoordinates[0], waypointCoordinates[1]],\n          [snappointsCoordinates[index][0], snappointsCoordinates[index][1]],\n        ],\n      },\n      properties: {\n        type: \"SNAPLINE\",\n      },\n    } as Feature<LineString>;\n  });\n\n  if (~departSnappointIndex && hoverpointCoordinates !== undefined && showHoverpointSnaplines) {\n    snaplines.push({\n      type: \"Feature\",\n      geometry: {\n        type: \"LineString\",\n        coordinates: [\n          [hoverpointCoordinates[0], hoverpointCoordinates[1]],\n          [snappointsCoordinates[departSnappointIndex][0], snappointsCoordinates[departSnappointIndex][1]],\n        ],\n      },\n      properties: {\n        type: \"SNAPLINE\",\n      },\n    });\n\n    snaplines.push({\n      type: \"Feature\",\n      geometry: {\n        type: \"LineString\",\n        coordinates: [\n          [hoverpointCoordinates[0], hoverpointCoordinates[1]],\n          [snappointsCoordinates[departSnappointIndex + 1][0], snappointsCoordinates[departSnappointIndex + 1][1]],\n        ],\n      },\n      properties: {\n        type: \"SNAPLINE\",\n      },\n    });\n  }\n\n  return snaplines;\n}\n\n/**\n * @protected\n *\n * Creates route lines from the server response.\n *\n * Each route line is an array of legs, where each leg is an array of segments. A segment is a\n * {@link Feature<LineString>|GeoJSON LineString Feature}. Route legs are divided into segments by their congestion\n * levels. If there's no congestions, each route leg consists of a single segment.\n */\nexport function buildRoutelines(\n  requestOptions: MapLibreGlDirectionsConfiguration[\"requestOptions\"],\n  routes: Route[],\n  selectedRouteIndex: number,\n  snappoints: Feature<Point>[],\n): Feature<LineString>[][] {\n  // do the following stuff for each route (there are multiple when `alternatives=true` request option is set)\n  return routes.map((route, routeIndex) => {\n    // a list of coordinates pairs (longitude-latitude) the route goes by\n    const coordinates = geometryDecoder(requestOptions, route.geometry);\n\n    // get coordinates from the snappoint-features\n    const snappointsCoordinates = snappoints.map((snappoint) => snappoint.geometry.coordinates);\n\n    // add a variable to watch the current index to start the search from\n    let currentIndex = 0;\n\n    // indices of coordinate pairs that match existing snappoints (except for the first one)\n    const snappointsCoordinatesIndices = snappointsCoordinates\n      .map((snappointLngLat, index) => {\n        // use the currentIndex to start the search from the place where the last snappoint's coordinate was found\n        const waypointCoordinatesIndex = coordinates.slice(currentIndex).findIndex((lngLat) => {\n          // there might be an error in 0.00001 degree between snappoint and decoded coordinate when using the\n          // \"polyline\" geometries. The comparator neglects that\n          return coordinatesComparator(requestOptions, lngLat, snappointLngLat as [number, number]);\n        });\n\n        const isLast = index === snappointsCoordinates.length - 1;\n\n        // update the current index if something's found\n        if (waypointCoordinatesIndex !== -1) {\n          currentIndex += waypointCoordinatesIndex;\n        } else if (isLast) {\n          return coordinates.length - 1;\n        }\n\n        return currentIndex;\n      })\n      .slice(1); // because the first one is always 0 (first leg always starts with the first snappoint)\n\n    // split the coordinates array by legs. Each leg consists of coordinates between snappoints\n    let initialIndex = 0;\n    const legsCoordinates = snappointsCoordinatesIndices.map((waypointCoordinatesIndex) => {\n      return coordinates.slice(initialIndex, (initialIndex = waypointCoordinatesIndex + 1));\n    });\n\n    // an array to store the resulting route's features in\n    const features: Feature<LineString>[] = [];\n\n    legsCoordinates.forEach((legCoordinates, legIndex) => {\n      const legId = nanoid();\n\n      // for each pair of leg's coordinates\n      legCoordinates.forEach((lngLat, i) => {\n        // find the previous segment\n        const previousSegment = features[features.length - 1];\n        // determine the current segment's congestion level\n        const segmentCongestion = congestionLevelDecoder(requestOptions, route.legs[legIndex]?.annotation, i);\n\n        // only allow to continue the previous segment if it exists and if it's the same leg and if it's the same\n        // congestion level\n        if (\n          legIndex === previousSegment?.properties?.legIndex &&\n          previousSegment.properties?.congestion === segmentCongestion\n        ) {\n          previousSegment.geometry.coordinates.push(lngLat);\n        } else {\n          const departSnappointProperties = snappoints[legIndex].properties ?? {};\n          const arriveSnappointProperties = snappoints[legIndex + 1].properties ?? {};\n\n          const segment = {\n            type: \"Feature\",\n            geometry: {\n              type: \"LineString\",\n              coordinates: [],\n            },\n            properties: {\n              id: legId, // used to highlight the whole leg when hovered, not a single segment\n              routeIndex, // used to switch between alternative and selected routes\n              route: routeIndex === selectedRouteIndex ? \"SELECTED\" : \"ALT\",\n              legIndex, // used across forEach iterations to check whether it's safe to continue a segment\n              congestion: segmentCongestion, // the current segment's congestion level\n              departSnappointProperties, // include depart and arrive snappoints' properties to allow customization...\n              arriveSnappointProperties, // ...of behavior via a subclass\n            },\n          } as Feature<LineString>;\n\n          // a new segment starts with previous segment's last coordinate\n          if (previousSegment) {\n            segment.geometry.coordinates.push(\n              previousSegment.geometry.coordinates[previousSegment.geometry.coordinates.length - 1],\n            );\n          }\n\n          segment.geometry.coordinates.push(lngLat);\n\n          features.push(segment);\n        }\n      });\n    });\n\n    return features;\n  });\n}\n","import type { Map, MapGeoJSONFeature, MapMouseEvent, MapTouchEvent } from \"maplibre-gl\";\nimport type { Directions, MapLibreGlDirectionsConfiguration } from \"./types\";\nimport type { Feature, FeatureCollection, LineString, Point } from \"geojson\";\nimport {\n  MapLibreGlDirectionsEvented,\n  MapLibreGlDirectionsRoutingEvent,\n  MapLibreGlDirectionsWaypointEvent,\n} from \"./events\";\nimport {\n  buildConfiguration,\n  buildRequest,\n  buildPoint,\n  buildSnaplines,\n  buildRoutelines,\n  type RequestData,\n} from \"./utils\";\nimport { getWaypointsBearings, getWaypointsCoordinates } from \"./helpers\";\n\n/**\n * The main class responsible for all the user interaction and for the routing itself.\n */\nexport default class MapLibreGlDirections extends MapLibreGlDirectionsEvented {\n  constructor(map: Map, configuration?: Partial<MapLibreGlDirectionsConfiguration>) {\n    super(map);\n\n    this.map = map;\n    this.configuration = buildConfiguration(configuration);\n\n    /*\n     * Bind the event listeners to `this` since e.g. `map.off(\"type\", onMove)` won't work if it was registered\n     * as `map.on(\"type\", onMove.bind(this))`. `onMove !== onMove.bind(this)`, but\n     * `onMoveHandler === onMoveHandler`!\n     */\n    this.onMoveHandler = this.onMove.bind(this);\n    this.onDragDownHandler = this.onDragDown.bind(this);\n    this.onDragMoveHandler = this.onDragMove.bind(this);\n    this.onDragUpHandler = this.onDragUp.bind(this);\n    this.onClickHandler = this.onClick.bind(this);\n    this.liveRefreshHandler = this.liveRefresh.bind(this);\n\n    this.init();\n  }\n\n  /*\n   * Everything is `protected` to allow access from a subclass.\n   */\n  protected declare readonly map: Map;\n  protected readonly configuration: MapLibreGlDirectionsConfiguration;\n\n  protected _interactive = false;\n  protected _hoverable = false;\n  protected buildRequest = buildRequest;\n  protected buildPoint = buildPoint;\n  protected buildSnaplines = buildSnaplines;\n  protected buildRoutelines = buildRoutelines;\n\n  protected onMoveHandler: (e: MapMouseEvent | MapTouchEvent) => void;\n  protected onDragDownHandler: (e: MapMouseEvent | MapTouchEvent) => void;\n  protected onDragMoveHandler: (e: MapMouseEvent | MapTouchEvent) => void;\n  protected onDragUpHandler: (e: MapMouseEvent | MapTouchEvent) => void;\n  protected onClickHandler: (e: MapMouseEvent | MapTouchEvent) => void;\n  protected liveRefreshHandler: (e: MapMouseEvent | MapTouchEvent) => void;\n\n  protected profiles: string[] = [];\n  protected _waypoints: Feature<Point>[] = [];\n  protected snappoints: Feature<Point>[] = [];\n  protected routelines: Feature<LineString>[][] = [];\n  protected selectedRouteIndex = 0;\n  protected hoverpoint: Feature<Point> | undefined = undefined;\n\n  /**\n   * @alias {@link waypoints}\n   *\n   * Aliased for the sakes of naming-consistency.\n   */\n  protected get waypointsCoordinates(): [number, number][] {\n    return getWaypointsCoordinates(this._waypoints);\n  }\n\n  protected get snappointsCoordinates(): [number, number][] {\n    return this.snappoints.map((snappoint) => {\n      return [snappoint.geometry.coordinates[0], snappoint.geometry.coordinates[1]];\n    });\n  }\n\n  protected get snaplines(): Feature<LineString>[] {\n    return this.buildSnaplines(\n      this.waypointsCoordinates,\n      this.snappointsCoordinates,\n      this.hoverpoint?.geometry.coordinates as [number, number] | undefined,\n      this.departSnappointIndex,\n      this.hoverpoint?.properties?.showSnaplines,\n    );\n  }\n\n  protected init() {\n    this.map.addSource(this.configuration.sourceName, {\n      type: \"geojson\",\n      data: {\n        type: \"FeatureCollection\",\n        features: [],\n      },\n    });\n\n    this.configuration.layers.forEach((layer) => {\n      this.map.addLayer(layer);\n    });\n  }\n\n  protected async fetch({ method, url, payload }: RequestData) {\n    const response = (await (\n      method === \"get\"\n        ? await fetch(`${url}?${payload}`, { signal: this.abortController?.signal })\n        : await fetch(`${url}`, {\n            signal: this.abortController?.signal,\n            method: \"POST\",\n            headers: {\n              \"Content-Type\": \"application/x-www-form-urlencoded\",\n            },\n            body: payload,\n          })\n    ).json()) as Directions;\n\n    if (response.code !== \"Ok\") throw new Error(response.message ?? \"An unexpected error occurred.\");\n\n    return response;\n  }\n\n  protected async fetchDirections(originalEvent: MapLibreGlDirectionsWaypointEvent) {\n    /*\n     * If a request from a previous fetchDirections is already running (there's no such a check really, but this is\n     * implied be calling this method), we abort it as we don't need the previous value anymore.\n     */\n    this.abortController?.abort();\n\n    if (this._waypoints.length >= 2) {\n      this.fire(new MapLibreGlDirectionsRoutingEvent(\"fetchroutesstart\", originalEvent));\n\n      this.abortController = new AbortController();\n\n      let timer;\n      if (this.configuration.requestTimeout !== null) {\n        timer = setTimeout(() => this.abortController?.abort(), this.configuration.requestTimeout);\n      }\n\n      if (!this.profiles.length) {\n        this.profiles = [this.configuration.profile];\n      }\n\n      // Profiles for requests\n      const profiles: string[] = [];\n      // Waypoints split by profile\n      const waypoints: Feature<Point>[][] = [];\n\n      /**\n       * Prepares data for the requests\n       */\n      this.profiles.reduce((waypointsIndex, profile, index) => {\n        const isLast = index === this.profiles.length - 1;\n        const prevProfile = index > 0 ? this.profiles[index - 1] : undefined;\n        const isSameProfile = profile === prevProfile;\n        const waypointsEnd = isLast\n          ? /**\n             * If it's the last supplied profile include all remaining waypoints\n             */\n            this._waypoints.length\n          : isSameProfile\n            ? /**\n               * If profile is same as previous one add a slice of one element only\n               */\n              waypointsIndex + 1\n            : /**\n               * If profile is different slice corresponding pair of coordinates\n               */\n              waypointsIndex + 2;\n\n        if (isSameProfile) {\n          /**\n           * If route to the next waypoint is to be found with the same profile, add waypoints to the previous chunk to\n           * fetch them in one request\n           */\n          waypoints[waypoints.length - 1].push(...this._waypoints.slice(waypointsIndex, waypointsEnd));\n        } else {\n          /**\n           * Otherwise add waypoints as the next chunk and push new profile\n           */\n          waypoints.push(this._waypoints.slice(waypointsIndex, waypointsEnd));\n          profiles.push(profile);\n        }\n\n        return waypointsEnd;\n      }, 0);\n\n      const requests = profiles.map((profile, index) => {\n        return this.buildRequest(\n          { ...this.configuration, profile },\n          getWaypointsCoordinates(waypoints[index]),\n          this.configuration.bearings ? getWaypointsBearings(waypoints[index]) : undefined,\n        );\n      });\n\n      let responses: Directions[];\n\n      try {\n        responses = await Promise.all(\n          requests.map(async (request) => {\n            let response: Directions | undefined = undefined;\n            try {\n              response = await this.fetch(request);\n            } finally {\n              this.fire(new MapLibreGlDirectionsRoutingEvent(\"fetchroutesend\", originalEvent, response));\n            }\n            return response;\n          }),\n        );\n      } finally {\n        clearTimeout(timer);\n      }\n\n      const features = responses.flatMap((response, index) => {\n        const profile = profiles[index];\n\n        const snappoints = response.waypoints.map((snappoint, i) =>\n          this.buildPoint(snappoint.location, \"SNAPPOINT\", {\n            profile,\n            waypointProperties: waypoints[index][i].properties ?? {},\n          }),\n        );\n\n        const routelines = this.buildRoutelines(\n          this.configuration.requestOptions,\n          response.routes,\n          this.selectedRouteIndex,\n          snappoints,\n        );\n\n        return { snappoints, routelines };\n      });\n      const routes = responses.flatMap((response) => response.routes);\n\n      this.snappoints = features.flatMap((features) => features.snappoints);\n      this.routelines = features.flatMap((features) => features.routelines);\n      if (routes.length <= this.selectedRouteIndex) this.selectedRouteIndex = 0;\n    } else {\n      this.snappoints = [];\n      this.routelines = [];\n    }\n\n    // the selected route index might have changed\n    this.draw(false);\n  }\n\n  protected draw(skipSelectedRouteRedraw = true) {\n    const features = [\n      ...this._waypoints,\n      ...this.snappoints,\n      ...this.snaplines,\n      ...this.routelines.reduce((acc, routeLegs) => {\n        /*\n         * `.map` inside `.reduce` is a pretty expensive operation, so by default it's disabled. If the `draw` method is\n         * called from a place where the selected route index might potentially have changed (e.g. `onClick`), the\n         * respective parameter is set to `false` and the currently selected route will be redrawn.\n         */\n        if (!skipSelectedRouteRedraw) {\n          return acc.concat(\n            ...routeLegs.map((routeLeg) => {\n              if (routeLeg.properties) {\n                routeLeg.properties.route =\n                  routeLeg.properties.routeIndex === this.selectedRouteIndex ? \"SELECTED\" : \"ALT\";\n              }\n\n              return routeLeg;\n            }),\n          );\n        }\n\n        return acc.concat(...routeLegs);\n      }, [] as Feature<LineString>[]),\n    ];\n\n    if (this.hoverpoint) features.push(this.hoverpoint);\n\n    const geoJson: FeatureCollection = {\n      type: \"FeatureCollection\",\n      features,\n    };\n\n    if (this.map.getSource(this.configuration.sourceName)) {\n      (this.map.getSource(this.configuration.sourceName) as maplibregl.GeoJSONSource).setData(geoJson);\n    }\n  }\n\n  protected highlightedWaypoints: Feature<Point>[] = [];\n  protected highlightedSnappoints: Feature<Point>[] = [];\n\n  protected deHighlight() {\n    this.highlightedWaypoints.forEach((waypoint) => {\n      if (waypoint?.properties) {\n        waypoint.properties.highlight = false;\n      }\n    });\n\n    this.highlightedSnappoints.forEach((snappoint) => {\n      if (snappoint?.properties) {\n        snappoint.properties.highlight = false;\n      }\n    });\n\n    this.routelines.forEach((routeline) => {\n      routeline.forEach((leg) => {\n        if (leg.properties) {\n          leg.properties.highlight = false;\n        }\n      });\n    });\n  }\n\n  protected onMove(e: MapMouseEvent | MapTouchEvent) {\n    const feature: MapGeoJSONFeature | undefined = this.map.queryRenderedFeatures(e.point, {\n      layers: [\n        ...this.configuration.sensitiveWaypointLayers,\n        ...this.configuration.sensitiveSnappointLayers,\n        ...this.configuration.sensitiveRoutelineLayers,\n        ...this.configuration.sensitiveAltRoutelineLayers,\n      ],\n    })[0];\n\n    /*\n     * De-highlight everything first in order to be able to highlight only the necessary features.\n     */\n    this.deHighlight();\n\n    if (this.configuration.sensitiveWaypointLayers.includes(feature?.layer.id ?? \"\")) {\n      /*\n       *  If the cursor moves over a waypoint then change its shape to \"pointer\", disable the map's standard drag-pan\n       *  functionality (the user should be able to drag the waypoint itself, not the map), set the waypoint's\n       *  \"highlight\" property to `true`. Set its respective snappoint's \"highlight\" property to `true` as well. Save\n       *  the highlighted features outside to be able to de-highlight them the next time the `onMove` is called. Remove\n       *  the existing hoverpoint.\n       */\n\n      this.map.getCanvas().style.cursor = \"pointer\";\n\n      if (this.interactive) {\n        this.map.dragPan.disable();\n      }\n\n      const highlightedWaypoint = this._waypoints.find((waypoint) => {\n        return waypoint.properties?.id === feature?.properties?.id;\n      });\n      const highlightedSnappoint =\n        highlightedWaypoint &&\n        this.snappoints.find(\n          (snappoint) => snappoint.properties?.waypointProperties?.id === highlightedWaypoint.properties?.id,\n        );\n\n      highlightedWaypoint && (this.highlightedWaypoints = [highlightedWaypoint]);\n      highlightedSnappoint && (this.highlightedSnappoints = [highlightedSnappoint]);\n\n      if (this.highlightedWaypoints[0]?.properties) {\n        this.highlightedWaypoints[0].properties.highlight = true;\n      }\n\n      if (this.highlightedSnappoints[0]?.properties) {\n        this.highlightedSnappoints[0].properties.highlight = true;\n      }\n\n      if (this.hoverpoint) this.hoverpoint = undefined;\n    } else if (this.configuration.sensitiveSnappointLayers.includes(feature?.layer.id ?? \"\")) {\n      /*\n       *  If the cursor moves over a snappoint then change its shape to \"pointer\" and set the snappoint's \"highlight\"\n       *  property to `true`. Set its respective waypoint's \"highlight\" property to `true` as well. Save the highlighted\n       *  features outside to be able to de-highlight them the next time the `onMove` is called. Remove the existing\n       *  hoverpoint.\n       */\n\n      this.map.getCanvas().style.cursor = \"pointer\";\n\n      const highlightedSnappointIndex = this.snappoints.findIndex((snappoint) => {\n        return snappoint.properties?.id === feature?.properties?.id;\n      });\n\n      this.highlightedSnappoints = [this.snappoints[highlightedSnappointIndex]];\n      this.highlightedWaypoints = [this._waypoints[highlightedSnappointIndex]];\n\n      if (this.highlightedSnappoints[0].properties) {\n        this.highlightedSnappoints[0].properties.highlight = true;\n      }\n\n      if (this.highlightedWaypoints[0].properties) {\n        this.highlightedWaypoints[0].properties.highlight = true;\n      }\n\n      if (this.hoverpoint) this.hoverpoint = undefined;\n    } else if (this.configuration.sensitiveRoutelineLayers.includes(feature?.layer.id ?? \"\")) {\n      /*\n       * If the cursor moves over the selected route line then change its shape to \"pointer\",  disable the map's\n       * standard drag-pan functionality (the user should be able to drag the routeline itself, not the map), add a\n       * hoverpoint (or change its position accordingly), and set the routeline's \"highlight\" property to `true`.\n       */\n\n      this.map.getCanvas().style.cursor = \"pointer\";\n\n      if (this.interactive) {\n        this.map.dragPan.disable();\n\n        if (this.hoverpoint) {\n          this.hoverpoint.geometry.coordinates = [e.lngLat.lng, e.lngLat.lat];\n        } else {\n          this.hoverpoint = this.buildPoint([e.lngLat.lng, e.lngLat.lat], \"HOVERPOINT\", {\n            departSnappointProperties: {\n              ...JSON.parse(feature?.properties?.departSnappointProperties ?? \"{}\"),\n            },\n            arriveSnappointProperties: {\n              ...JSON.parse(feature?.properties?.arriveSnappointProperties ?? \"{}\"),\n            },\n          });\n        }\n      }\n\n      this.routelines.forEach((routeline) => {\n        routeline.forEach((leg) => {\n          if (leg.properties && leg.properties?.id === feature?.properties?.id) {\n            leg.properties.highlight = true;\n          }\n        });\n      });\n    } else if (this.configuration.sensitiveAltRoutelineLayers.includes(feature?.layer.id ?? \"\")) {\n      /*\n       * If the cursor moves over an alternative route line then change its shape to \"pointer\" and set the routeline's\n       * \"highlight\" property to `true`. Remove the existing hoverpoint.\n       */\n\n      this.map.getCanvas().style.cursor = \"pointer\";\n\n      this.routelines.forEach((routeline) => {\n        routeline.forEach((leg) => {\n          if (leg.properties && leg.properties?.id === feature?.properties?.id) {\n            leg.properties.highlight = true;\n          }\n        });\n      });\n\n      if (this.hoverpoint) this.hoverpoint = undefined;\n    } else {\n      /*\n       * If the cursor moves somewhere else then re-enable the drag-pan functionality, restore the cursor original shape\n       * and remove the hoverpoint.\n       */\n\n      this.map.dragPan.enable();\n      this.map.getCanvas().style.cursor = \"\";\n\n      this.hoverpoint = undefined;\n    }\n\n    this.draw();\n  }\n\n  protected dragDownPosition = {\n    x: 0,\n    y: 0,\n  };\n  protected waypointBeingDragged?: Feature<Point>;\n  protected waypointBeingDraggedInitialCoordinates?: [number, number];\n  protected departSnappointIndex = -1;\n  protected currentMousePosition = {\n    x: 0,\n    y: 0,\n  };\n\n  protected onDragDown(e: MapMouseEvent | MapTouchEvent) {\n    if (e.type === \"touchstart\" && e.originalEvent.touches.length !== 1) return;\n    if (e.type === \"mousedown\" && e.originalEvent.which !== 1) return;\n\n    const features: MapGeoJSONFeature[] | undefined = this.map.queryRenderedFeatures(e.point);\n    // check if the user is trying to drag a layer from our source\n    if (features.length && features[0].source === this.configuration.sourceName) {\n      // he is. let's find the top most feature that might interest us\n\n      const feature: MapGeoJSONFeature | undefined = features.filter((feature) => {\n        return (\n          this.configuration.sensitiveWaypointLayers.includes(feature?.layer.id ?? \"\") ||\n          this.configuration.sensitiveSnappointLayers.includes(feature?.layer.id ?? \"\") ||\n          this.configuration.sensitiveRoutelineLayers.includes(feature?.layer.id ?? \"\")\n        );\n      })[0];\n      /*\n       * Save the cursor's position to be able to check later whether the dragged feature moved at all.\n       */\n      this.dragDownPosition = e.point;\n      this.currentMousePosition = e.point;\n\n      if (this.configuration.sensitiveWaypointLayers.includes(feature?.layer.id ?? \"\")) {\n        /*\n         * When a waypoint is being dragged, save it and its current coordinates outside.\n         */\n\n        this.waypointBeingDragged = this._waypoints.find((waypoint) => {\n          return waypoint.properties?.id === feature?.properties?.id;\n        });\n\n        this.waypointBeingDraggedInitialCoordinates = this.waypointBeingDragged?.geometry.coordinates as\n          | [number, number]\n          | undefined;\n      } else if (this.configuration.sensitiveRoutelineLayers.includes(feature?.layer.id ?? \"\")) {\n        /*\n         * When a routeline (a leg in particular) is being dragged, find its respective depart snappoint's index and save\n         * it outside. Since a route is divided into legs by the snappoints, the leg's index is always equal to the\n         * depart snappoint's index.\n         */\n        this.departSnappointIndex = JSON.parse(feature?.properties?.legIndex);\n\n        /*\n         * the \"touchstart\" event (\"mousemove\" equivalent) is not always fired before this `onDragDown` (which is also the\n         * \"touchstart\"), therefore the hoverpoint might not exist yet. If it indeed does not, then create it and then\n         * enable showing its snaplines.\n         */\n\n        if (this.hoverpoint) {\n          if (this.configuration.refreshOnMove) {\n            /*\n             * If dragging a hoverpoint and refreshOnMove is active, we must convert it to a waypoint instead\n             */\n            const departedSnapPointIndex =\n              this.departSnappointIndex !== undefined ? this.departSnappointIndex + 1 : undefined;\n            this._addWaypoint([e.lngLat.lng, e.lngLat.lat], departedSnapPointIndex, e);\n            /*\n             * This new waypoint is set as the one now being dragged, in order to not interrupt the user's dragging action\n             */\n            this.waypointBeingDragged = departedSnapPointIndex ? this._waypoints[departedSnapPointIndex] : undefined;\n            this.hoverpoint = undefined;\n          } else {\n            this.hoverpoint.geometry.coordinates = [e.lngLat.lng, e.lngLat.lat];\n          }\n        } else {\n          this.hoverpoint = this.buildPoint([e.lngLat.lng, e.lngLat.lat], \"HOVERPOINT\", {\n            departSnappointProperties: {\n              ...JSON.parse(feature?.properties?.departSnappointProperties ?? \"{}\"),\n            },\n            arriveSnappointProperties: {\n              ...JSON.parse(feature?.properties?.arriveSnappointProperties ?? \"{}\"),\n            },\n          });\n        }\n\n        if (this.hoverpoint?.properties) {\n          this.hoverpoint.properties.showSnaplines = true;\n        }\n\n        /*\n         * Highlight the respective leg's depart and arrive snappoints.\n         */\n        if (~this.departSnappointIndex && this.snappoints[this.departSnappointIndex]?.properties) {\n          // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n          // @ts-ignore\n          this.snappoints[this.departSnappointIndex].properties.highlight = true;\n          this.highlightedSnappoints.push(this.snappoints[this.departSnappointIndex]);\n          // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n          // @ts-ignore\n          this.snappoints[this.departSnappointIndex + 1].properties.highlight = true;\n          this.highlightedSnappoints.push(this.snappoints[this.departSnappointIndex + 1]);\n        }\n      }\n\n      /*\n       * Disable the global `onMove` handlers for them not to interfere with the new ones which are added further down.\n       */\n      this.map.off(\"touchstart\", this.onMoveHandler);\n      this.map.off(\"mousemove\", this.onMoveHandler);\n\n      /*\n       * Add specific drag-only listeners.\n       */\n      if (e.type === \"touchstart\") {\n        this.map.on(\"touchmove\", this.onDragMoveHandler);\n        this.map.on(\"touchend\", this.onDragUpHandler);\n      } else if (e.type === \"mousedown\") {\n        this.map.on(\"mousemove\", this.onDragMoveHandler);\n        this.map.on(\"mouseup\", this.onDragUpHandler);\n      }\n\n      this.draw();\n    }\n  }\n\n  protected refreshOnMoveIsRefreshing = false;\n\n  protected onDragMove(e: MapMouseEvent | MapTouchEvent) {\n    /*\n     * When the `updateOnMove` option is on, if this timeout ever triggers, it means we are dragging, but not moving the\n     * mouse.\n     */\n    if (this.configuration.refreshOnMove) {\n      clearTimeout(this.noMouseMovementTimer);\n      this.noMouseMovementTimer = setTimeout(this.liveRefreshHandler, 300, e);\n    }\n\n    /*\n     * `preventDefault` here prevents drag down gesture in mobile Chrome from updating the page.\n     */\n    if (e.type === \"touchmove\" && e.originalEvent.touches.length !== 1) return e.originalEvent.preventDefault();\n    if (e.type === \"mousemove\" && e.originalEvent.which !== 1) return;\n\n    if (this.waypointBeingDragged) {\n      /*\n       * If it's a waypoint that's being dragged then update accordingly its coordinates.\n       */\n\n      this.waypointBeingDragged.geometry.coordinates = [e.lngLat.lng, e.lngLat.lat];\n    } else if (this.hoverpoint) {\n      /*\n       * When dragging a route line, redraw the hoverpoint at the new coordinates.\n       */\n\n      this.hoverpoint.geometry.coordinates = [e.lngLat.lng, e.lngLat.lat];\n    }\n\n    this.currentMousePosition = e.point;\n    this.draw();\n\n    /*\n     * If the user selected a waypoint or a routeline and routes should update while dragging, we initiate the live\n     * updating process.\n     */\n    if (this.configuration.refreshOnMove && !this.refreshOnMoveIsRefreshing) {\n      this.liveRefreshHandler(e);\n    }\n  }\n\n  protected noMouseMovementTimer?: ReturnType<typeof setTimeout>;\n\n  protected onDragUp(e: MapMouseEvent | MapTouchEvent) {\n    /*\n     * If the routes should update while dragging, there's some cleanup to do when releasing the mouse.\n     */\n    if (this.configuration.refreshOnMove) {\n      clearTimeout(this.noMouseMovementTimer);\n    }\n\n    if (e.type === \"mouseup\" && e.originalEvent.which !== 1) return;\n\n    if (this.hoverpoint?.properties) this.hoverpoint.properties.showSnaplines = false;\n\n    /*\n     * Only add a new waypoint or change the dragged one's position if the mouse has been dragged for more than the\n     * configured threshold. If the specified threshold's value is less than zero then treat it as if it was zero.\n     */\n    if (\n      Math.abs(e.point.x - this.dragDownPosition?.x) >\n        (this.configuration.dragThreshold >= 0 ? this.configuration.dragThreshold : 0) ||\n      Math.abs(e.point.y - this.dragDownPosition?.y) >\n        (this.configuration.dragThreshold >= 0 ? this.configuration.dragThreshold : 0)\n    ) {\n      if (this.waypointBeingDragged) {\n        /*\n         * If a waypoint has been dragged, update its position accordingly and re-fetch the directions.\n         */\n\n        this.waypointBeingDragged.geometry.coordinates = [e.lngLat.lng, e.lngLat.lat];\n\n        const waypointEvent = new MapLibreGlDirectionsWaypointEvent(\"movewaypoint\", e, {\n          index: this._waypoints.indexOf(this.waypointBeingDragged),\n          initialCoordinates: this.waypointBeingDraggedInitialCoordinates,\n        });\n        this.fire(waypointEvent);\n\n        /*\n         * If the routing request has failed for some reason, restore the waypoint's original position.\n         */\n\n        this.fetchDirections(waypointEvent).catch((err) => {\n          if (!(err instanceof DOMException && err.name == \"AbortError\")) {\n            if (this.waypointBeingDragged && this.waypointBeingDraggedInitialCoordinates) {\n              this.waypointBeingDragged.geometry.coordinates = this.waypointBeingDraggedInitialCoordinates;\n            }\n          }\n        });\n\n        this.waypointBeingDragged = undefined;\n        this.waypointBeingDraggedInitialCoordinates = undefined;\n      } else if (this.hoverpoint) {\n        /*\n         * If the selected routeline has been dragged then add a waypoint at the previously saved index and remove the\n         * hoverpoint.\n         */\n\n        this._addWaypoint(\n          [e.lngLat.lng, e.lngLat.lat],\n          this.departSnappointIndex !== undefined ? this.departSnappointIndex + 1 : undefined,\n          e,\n        );\n\n        this.hoverpoint = undefined;\n      }\n    } else {\n      /*\n       * If the waypoint or the selected routeline has been dragged not far enough, restore its initial location.\n       */\n\n      if (this.waypointBeingDragged && this.waypointBeingDraggedInitialCoordinates) {\n        this.waypointBeingDragged.geometry.coordinates = this.waypointBeingDraggedInitialCoordinates;\n\n        this.waypointBeingDragged = undefined;\n        this.waypointBeingDraggedInitialCoordinates = undefined;\n      } else if (this.hoverpoint) {\n        this.hoverpoint = undefined;\n      }\n    }\n\n    /*\n     * De-highlight everything.\n     */\n    this.deHighlight();\n\n    /*\n     * Remove the listeners assigned specifically for the drag-related events.\n     */\n    if (e.type === \"touchend\") {\n      this.map.off(\"touchmove\", this.onDragMoveHandler);\n      this.map.off(\"touchend\", this.onDragUpHandler);\n    } else if (e.type === \"mouseup\") {\n      this.map.off(\"mousemove\", this.onDragMoveHandler);\n      this.map.off(\"mouseup\", this.onDragUpHandler);\n    }\n\n    /*\n     * Restore the removed global `onMove` listeners.\n     */\n    this.map.on(\"touchstart\", this.onMoveHandler);\n    this.map.on(\"mousemove\", this.onMoveHandler);\n\n    // Re-enable original dragPan functionality. Might have already been re-enabled, but there are cases when it's\n    // not the case. See https://github.com/maplibre/maplibre-gl-directions/issues/186\n    this.map.dragPan.enable();\n\n    this.draw();\n\n    // After the moved waypoint was rendered, imitate hovering the mouse over it (because it actually keeps being\n    // hovered right after the drug-up event ends).\n    this.map.once(\"idle\", () => {\n      this.onMove(e);\n    });\n  }\n\n  protected lastRequestMousePosition = {\n    x: 0,\n    y: 0,\n  };\n\n  protected async liveRefresh(e: MapMouseEvent | MapTouchEvent) {\n    if (\n      Math.abs(this.lastRequestMousePosition?.x - this.currentMousePosition?.x) >\n        (this.configuration.dragThreshold >= 0 ? this.configuration.dragThreshold : 0) ||\n      Math.abs(this.lastRequestMousePosition?.y - this.currentMousePosition?.y) >\n        (this.configuration.dragThreshold >= 0 ? this.configuration.dragThreshold : 0)\n    ) {\n      this.refreshOnMoveIsRefreshing = true;\n      this.lastRequestMousePosition = this.currentMousePosition;\n\n      /*\n       * During liveRefresh, we only care about waypoints, because if dragging a hoverpoint\n       * then it has already been converted to a waypoint on dragDown\n       */\n      if (this.waypointBeingDragged) {\n        /*\n         * If a waypoint has been dragged, we fire a \"movewaypoint\" just like \"onDragUp\" does.\n         */\n        const waypointEvent = new MapLibreGlDirectionsWaypointEvent(\"movewaypoint\", e, {\n          index: this._waypoints.indexOf(this.waypointBeingDragged),\n          initialCoordinates: this.waypointBeingDraggedInitialCoordinates,\n        });\n        this.fire(waypointEvent);\n\n        try {\n          await this.fetchDirections(waypointEvent);\n        } catch (err) {\n          // noop\n        }\n      }\n      this.refreshOnMoveIsRefreshing = false;\n    }\n  }\n\n  protected onClick(e: MapMouseEvent | MapTouchEvent) {\n    const feature: MapGeoJSONFeature | undefined = this.map.queryRenderedFeatures(e.point, {\n      layers: [\n        ...this.configuration.sensitiveWaypointLayers,\n        ...this.configuration.sensitiveSnappointLayers,\n        ...this.configuration.sensitiveAltRoutelineLayers,\n        ...this.configuration.sensitiveRoutelineLayers,\n      ],\n    })[0];\n\n    if (this.interactive && this.configuration.sensitiveWaypointLayers.includes(feature?.layer.id ?? \"\")) {\n      /*\n       * If a waypoint is clicked, remove it.\n       */\n\n      const respectiveWaypointIndex = this._waypoints.findIndex((waypoint) => {\n        return waypoint.properties?.id === feature?.properties?.id;\n      });\n\n      if (~respectiveWaypointIndex) {\n        this._removeWaypoint(respectiveWaypointIndex, e);\n      }\n    } else if (this.interactive && this.configuration.sensitiveSnappointLayers.includes(feature?.layer.id ?? \"\")) {\n      /*\n       * If a snappoint is clicked, find its respective waypoint and remove it.\n       */\n\n      const respectiveWaypointIndex = this.snappoints.findIndex((snappoint) => {\n        return snappoint.properties?.id === feature?.properties?.id;\n      });\n\n      if (~respectiveWaypointIndex) {\n        this._removeWaypoint(respectiveWaypointIndex, e);\n      }\n    } else if (\n      (this.interactive || this.allowRouteSwitch) &&\n      this.configuration.sensitiveAltRoutelineLayers.includes(feature?.layer.id ?? \"\")\n    ) {\n      /*\n       * If an alternative routeline is clicked, set its index as the selected route's one.\n       */\n\n      this.selectedRouteIndex = this.routelines.findIndex((routeline) => {\n        return !!routeline.find((segment) => {\n          return segment.properties?.id === feature?.properties?.id;\n        });\n      });\n    } else if (this.interactive && !this.configuration.sensitiveRoutelineLayers.includes(feature?.layer.id ?? \"\")) {\n      /*\n       * If the selected routeline is clicked, don't add a new waypoint. Else do.\n       */\n\n      this._addWaypoint([e.lngLat.lng, e.lngLat.lat], undefined, e);\n    }\n\n    // The selected route might have changed, so it's important not to skip its redraw.\n    this.draw(false);\n\n    // After the added waypoint was rendered, imitate hovering the mouse over it (because it actually keeps being\n    // hovered right after the click event ends).\n    this.map.once(\"idle\", () => {\n      this.onMove(e);\n    });\n  }\n\n  protected assignWaypointsCategories() {\n    this._waypoints.forEach((waypoint, index) => {\n      const category = index === 0 ? \"ORIGIN\" : index === this._waypoints.length - 1 ? \"DESTINATION\" : undefined;\n\n      if (waypoint.properties) {\n        waypoint.properties.index = index;\n        waypoint.properties.category = category;\n      }\n    });\n  }\n\n  protected async _addWaypoint(\n    waypoint: [number, number],\n    index?: number,\n    originalEvent?: MapMouseEvent | MapTouchEvent,\n  ) {\n    this.abortController?.abort();\n\n    index = index ?? this._waypoints.length;\n\n    this._waypoints.splice(\n      index,\n      0,\n      this.buildPoint(\n        waypoint,\n        \"WAYPOINT\",\n        this.configuration.bearings\n          ? {\n              bearing: undefined,\n            }\n          : undefined,\n      ),\n    );\n\n    this.assignWaypointsCategories();\n\n    const waypointEvent = new MapLibreGlDirectionsWaypointEvent(\"addwaypoint\", originalEvent, {\n      index,\n    });\n    this.fire(waypointEvent);\n\n    this.draw();\n\n    try {\n      await this.fetchDirections(waypointEvent);\n    } catch (err) {\n      // noop\n    }\n  }\n\n  protected async _removeWaypoint(index: number, originalEvent?: MapMouseEvent | MapTouchEvent) {\n    this.abortController?.abort();\n\n    this._waypoints.splice(index, 1);\n    this.snappoints.splice(index, 1);\n\n    this.assignWaypointsCategories();\n\n    const waypointEvent = new MapLibreGlDirectionsWaypointEvent(\"removewaypoint\", originalEvent, {\n      index,\n    });\n    this.fire(waypointEvent);\n\n    this.draw();\n\n    try {\n      await this.fetchDirections(waypointEvent);\n    } catch (err) {\n      // noop\n    }\n  }\n\n  // the public interface begins here\n\n  /**\n   * The interactivity state of the instance. When `true`, the user is allowed to interact with the features drawn on\n   * the map and to add waypoints by clicking the map. Automatically set to `false` whenever there's an ongoing\n   * routing request.\n   */\n  get interactive() {\n    return this._interactive;\n  }\n\n  set interactive(interactive) {\n    this._interactive = interactive;\n\n    if (interactive) {\n      this.map.on(\"touchstart\", this.onMoveHandler);\n      this.map.on(\"touchstart\", this.onDragDownHandler);\n      this.map.on(\"mousedown\", this.onDragDownHandler);\n      this.map.on(\"click\", this.onClickHandler);\n\n      if (!this.hoverable) {\n        this.map.on(\"mousemove\", this.onMoveHandler);\n        this.map.on(\"click\", this.onClickHandler);\n      }\n    } else {\n      this.map.off(\"touchstart\", this.onMoveHandler);\n      this.map.off(\"touchstart\", this.onDragDownHandler);\n      this.map.off(\"mousedown\", this.onDragDownHandler);\n\n      if (!this.hoverable) {\n        this.map.off(\"mousemove\", this.onMoveHandler);\n        this.map.off(\"click\", this.onClickHandler);\n      }\n\n      // see #192 (https://github.com/maplibre/maplibre-gl-directions/issues/192)\n      // There may be cases when the interactivity gets disabled while fetching the routes. In this case it's important\n      // to manually restore the map's drag-pan functionality, because after the map becomes non-interactive, the event\n      // listeners responsible for doing that won't be fired anymore.\n      this.map.dragPan.enable();\n    }\n  }\n\n  /**\n   * Allows hover effects in non-interactive mode. Can be set to `true` while `interactive` is `false` for the features\n   * to be highlighted when hovered over by the user. Does nothing when `interactive` is `true`.\n   */\n  get hoverable() {\n    return this._hoverable;\n  }\n\n  set hoverable(hoverable) {\n    this._hoverable = hoverable;\n\n    if (hoverable && !this.interactive) {\n      this.map.on(\"mousemove\", this.onMoveHandler);\n      this.map.on(\"click\", this.onClickHandler);\n    } else if (!this.interactive) {\n      this.map.off(\"mousemove\", this.onMoveHandler);\n      this.map.off(\"click\", this.onClickHandler);\n    }\n  }\n\n  /**\n   * Allows user to switch to alternative routes while in non-interactive mode. Only takes effect when `hoverable` is\n   * `true`.\n   */\n  public allowRouteSwitch = false;\n\n  /**\n   * Returns all the waypoints' coordinates in the order they appear.\n   */\n  get waypoints() {\n    return this.waypointsCoordinates;\n  }\n\n  /**\n   * @alias Synchronous analogue of {@link setWaypoints}.\n   */\n  set waypoints(waypoints: [number, number][]) {\n    this.setWaypoints(waypoints);\n  }\n\n  /**\n   * Returns all the waypoints' bearings values or an empty array if the `bearings` configuration option is not\n   * enabled.\n   */\n  get waypointsBearings(): ([number, number] | undefined)[] {\n    if (!this.configuration.bearings) {\n      console.warn(\n        \"The `waypointsBearings` getter was referred to, but the `bearings` configuration option is not enabled!\",\n      );\n      return [];\n    }\n\n    return getWaypointsBearings(this._waypoints);\n  }\n\n  /**\n   * Sets the waypoints' bearings values. Does not produce any effect in case the `bearings` configuration option is\n   * disabled.\n   */\n  set waypointsBearings(bearings: ([number, number] | undefined)[]) {\n    if (!this.configuration.bearings) {\n      console.warn(\n        \"The `waypointsBearings` setter was referred to, but the `bearings` configuration option is not enabled!\",\n      );\n      return;\n    }\n\n    this._waypoints.forEach((waypoint, i) => {\n      (waypoint.properties || (waypoint.properties = {})).bearing = bearings[i];\n    });\n\n    const waypointEvent = new MapLibreGlDirectionsWaypointEvent(\"rotatewaypoints\", undefined);\n    this.fire(waypointEvent);\n\n    this.draw();\n\n    try {\n      this.fetchDirections(waypointEvent);\n    } catch (err) {\n      // noop\n    }\n  }\n\n  /**\n   * Replaces all the waypoints with the specified ones and re-fetches the routes.\n   *\n   * @param waypoints The coordinates at which the waypoints should be added\n   * @param profiles Profiles for fetching directions between waypoints.\n   * @return Resolved after the routing request has finished\n   */\n  async setWaypoints(waypoints: [number, number][], profiles: string[] = []) {\n    this.abortController?.abort();\n\n    this.profiles = profiles.slice(0, waypoints.length - 1);\n\n    if (this.profiles.length === 0) {\n      /**\n       * Set profile from config if override is not provided\n       */\n      this.profiles.push(this.configuration.profile);\n    }\n\n    this._waypoints = this.profiles.flatMap((profile, index) => {\n      const isLast = index === this.profiles.length - 1;\n      const prevProfile = index > 0 ? this.profiles[index - 1] : undefined;\n      const isSameProfile = profile === prevProfile;\n      const waypointsStart = isSameProfile ? index + 1 : index;\n      const waypointsEnd = isLast ? waypoints.length : index + 2;\n\n      return waypoints.slice(waypointsStart, waypointsEnd).map((waypoint, index) => {\n        return this.buildPoint(waypoint, \"WAYPOINT\", {\n          profile,\n          ...(this.configuration.bearings\n            ? {\n                bearing: this.waypointsBearings[index],\n              }\n            : undefined),\n        });\n      });\n    });\n\n    this.assignWaypointsCategories();\n\n    const waypointEvent = new MapLibreGlDirectionsWaypointEvent(\"setwaypoints\", undefined);\n    this.fire(waypointEvent);\n\n    this.draw();\n\n    try {\n      await this.fetchDirections(waypointEvent);\n    } catch (err) {\n      // noop\n    }\n  }\n\n  /**\n   * Adds a waypoint at the specified coordinates to the map and re-fetches the routes.\n   *\n   * @param waypoint The coordinates at which the waypoint should be added\n   * @param index The index the waypoint should be inserted at. If omitted, the waypoint is inserted at the end\n   * @return Resolved after the routing request has finished\n   */\n  async addWaypoint(waypoint: [number, number], index?: number) {\n    await this._addWaypoint(waypoint, index);\n  }\n\n  /**\n   * Removes a waypoint and its related snappoint by the waypoint's index from the map and re-fetches the routes.\n   *\n   * @param index The index of the waypoint to remove\n   * @return Resolved after the routing request has finished\n   */\n  async removeWaypoint(index: number) {\n    await this._removeWaypoint(index);\n  }\n\n  /**\n   * A publicly-available abort-controller that allows to manually abort an ongoing routing-request.\n   *\n   * Only exists (`!== undefined`) when there's an ongoing routing-request.\n   *\n   * @example\n   * ```\n   * direсtions.abortController.abort();\n   * ```\n   */\n  abortController: AbortController | undefined;\n\n  /**\n   * Clears the map from all the instance's traces: waypoints, snappoints, routes, etc.\n   */\n  clear() {\n    this.setWaypoints([]);\n    this.routelines = [];\n  }\n\n  /**\n   * Removes all the added `MapLibreGlDirections`-specific layers and sources. Must be called manually before\n   * de-initializing the instance.\n   */\n  destroy() {\n    this.abortController?.abort();\n\n    this.clear();\n    this.hoverable = false;\n    this.interactive = false;\n\n    this.configuration.layers.forEach((layer) => {\n      this.map.removeLayer(layer.id);\n    });\n\n    this.map.removeSource(this.configuration.sourceName);\n  }\n}\n","/** @returns {void} */\nexport function noop() {}\n\nexport const identity = (x) => x;\n\n/**\n * @template T\n * @template S\n * @param {T} tar\n * @param {S} src\n * @returns {T & S}\n */\nexport function assign(tar, src) {\n\t// @ts-ignore\n\tfor (const k in src) tar[k] = src[k];\n\treturn /** @type {T & S} */ (tar);\n}\n\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\n/**\n * @param {any} value\n * @returns {value is PromiseLike<any>}\n */\nexport function is_promise(value) {\n\treturn (\n\t\t!!value &&\n\t\t(typeof value === 'object' || typeof value === 'function') &&\n\t\ttypeof (/** @type {any} */ (value).then) === 'function'\n\t);\n}\n\n/** @returns {void} */\nexport function add_location(element, file, line, column, char) {\n\telement.__svelte_meta = {\n\t\tloc: { file, line, column, char }\n\t};\n}\n\nexport function run(fn) {\n\treturn fn();\n}\n\nexport function blank_object() {\n\treturn Object.create(null);\n}\n\n/**\n * @param {Function[]} fns\n * @returns {void}\n */\nexport function run_all(fns) {\n\tfns.forEach(run);\n}\n\n/**\n * @param {any} thing\n * @returns {thing is Function}\n */\nexport function is_function(thing) {\n\treturn typeof thing === 'function';\n}\n\n/** @returns {boolean} */\nexport function safe_not_equal(a, b) {\n\treturn a != a ? b == b : a !== b || (a && typeof a === 'object') || typeof a === 'function';\n}\n\nlet src_url_equal_anchor;\n\n/**\n * @param {string} element_src\n * @param {string} url\n * @returns {boolean}\n */\nexport function src_url_equal(element_src, url) {\n\tif (element_src === url) return true;\n\tif (!src_url_equal_anchor) {\n\t\tsrc_url_equal_anchor = document.createElement('a');\n\t}\n\t// This is actually faster than doing URL(..).href\n\tsrc_url_equal_anchor.href = url;\n\treturn element_src === src_url_equal_anchor.href;\n}\n\n/** @param {string} srcset */\nfunction split_srcset(srcset) {\n\treturn srcset.split(',').map((src) => src.trim().split(' ').filter(Boolean));\n}\n\n/**\n * @param {HTMLSourceElement | HTMLImageElement} element_srcset\n * @param {string | undefined | null} srcset\n * @returns {boolean}\n */\nexport function srcset_url_equal(element_srcset, srcset) {\n\tconst element_urls = split_srcset(element_srcset.srcset);\n\tconst urls = split_srcset(srcset || '');\n\n\treturn (\n\t\turls.length === element_urls.length &&\n\t\turls.every(\n\t\t\t([url, width], i) =>\n\t\t\t\twidth === element_urls[i][1] &&\n\t\t\t\t// We need to test both ways because Vite will create an a full URL with\n\t\t\t\t// `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the\n\t\t\t\t// relative URLs inside srcset are not automatically resolved to absolute URLs by\n\t\t\t\t// browsers (in contrast to img.src). This means both SSR and DOM code could\n\t\t\t\t// contain relative or absolute URLs.\n\t\t\t\t(src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0]))\n\t\t)\n\t);\n}\n\n/** @returns {boolean} */\nexport function not_equal(a, b) {\n\treturn a != a ? b == b : a !== b;\n}\n\n/** @returns {boolean} */\nexport function is_empty(obj) {\n\treturn Object.keys(obj).length === 0;\n}\n\n/** @returns {void} */\nexport function validate_store(store, name) {\n\tif (store != null && typeof store.subscribe !== 'function') {\n\t\tthrow new Error(`'${name}' is not a store with a 'subscribe' method`);\n\t}\n}\n\nexport function subscribe(store, ...callbacks) {\n\tif (store == null) {\n\t\tfor (const callback of callbacks) {\n\t\t\tcallback(undefined);\n\t\t}\n\t\treturn noop;\n\t}\n\tconst unsub = store.subscribe(...callbacks);\n\treturn unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\n\n/**\n * Get the current value from a store by subscribing and immediately unsubscribing.\n *\n * https://svelte.dev/docs/svelte-store#get\n * @template T\n * @param {import('../store/public.js').Readable<T>} store\n * @returns {T}\n */\nexport function get_store_value(store) {\n\tlet value;\n\tsubscribe(store, (_) => (value = _))();\n\treturn value;\n}\n\n/** @returns {void} */\nexport function component_subscribe(component, store, callback) {\n\tcomponent.$$.on_destroy.push(subscribe(store, callback));\n}\n\nexport function create_slot(definition, ctx, $$scope, fn) {\n\tif (definition) {\n\t\tconst slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n\t\treturn definition[0](slot_ctx);\n\t}\n}\n\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n\treturn definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;\n}\n\nexport function get_slot_changes(definition, $$scope, dirty, fn) {\n\tif (definition[2] && fn) {\n\t\tconst lets = definition[2](fn(dirty));\n\t\tif ($$scope.dirty === undefined) {\n\t\t\treturn lets;\n\t\t}\n\t\tif (typeof lets === 'object') {\n\t\t\tconst merged = [];\n\t\t\tconst len = Math.max($$scope.dirty.length, lets.length);\n\t\t\tfor (let i = 0; i < len; i += 1) {\n\t\t\t\tmerged[i] = $$scope.dirty[i] | lets[i];\n\t\t\t}\n\t\t\treturn merged;\n\t\t}\n\t\treturn $$scope.dirty | lets;\n\t}\n\treturn $$scope.dirty;\n}\n\n/** @returns {void} */\nexport function update_slot_base(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tslot_changes,\n\tget_slot_context_fn\n) {\n\tif (slot_changes) {\n\t\tconst slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n\t\tslot.p(slot_context, slot_changes);\n\t}\n}\n\n/** @returns {void} */\nexport function update_slot(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tdirty,\n\tget_slot_changes_fn,\n\tget_slot_context_fn\n) {\n\tconst slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n\tupdate_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\n\n/** @returns {any[] | -1} */\nexport function get_all_dirty_from_scope($$scope) {\n\tif ($$scope.ctx.length > 32) {\n\t\tconst dirty = [];\n\t\tconst length = $$scope.ctx.length / 32;\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tdirty[i] = -1;\n\t\t}\n\t\treturn dirty;\n\t}\n\treturn -1;\n}\n\n/** @returns {{}} */\nexport function exclude_internal_props(props) {\n\tconst result = {};\n\tfor (const k in props) if (k[0] !== '$') result[k] = props[k];\n\treturn result;\n}\n\n/** @returns {{}} */\nexport function compute_rest_props(props, keys) {\n\tconst rest = {};\n\tkeys = new Set(keys);\n\tfor (const k in props) if (!keys.has(k) && k[0] !== '$') rest[k] = props[k];\n\treturn rest;\n}\n\n/** @returns {{}} */\nexport function compute_slots(slots) {\n\tconst result = {};\n\tfor (const key in slots) {\n\t\tresult[key] = true;\n\t}\n\treturn result;\n}\n\n/** @returns {(this: any, ...args: any[]) => void} */\nexport function once(fn) {\n\tlet ran = false;\n\treturn function (...args) {\n\t\tif (ran) return;\n\t\tran = true;\n\t\tfn.call(this, ...args);\n\t};\n}\n\nexport function null_to_empty(value) {\n\treturn value == null ? '' : value;\n}\n\nexport function set_store_value(store, ret, value) {\n\tstore.set(value);\n\treturn ret;\n}\n\nexport const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\n\nexport function action_destroyer(action_result) {\n\treturn action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\n\n/** @param {number | string} value\n * @returns {[number, string]}\n */\nexport function split_css_unit(value) {\n\tconst split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n\treturn split ? [parseFloat(split[1]), split[2] || 'px'] : [/** @type {number} */ (value), 'px'];\n}\n\nexport const contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n","import { contenteditable_truthy_values, has_prop } from './utils.js';\n\nimport { ResizeObserverSingleton } from './ResizeObserverSingleton.js';\n\n// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM\n// at the end of hydration without touching the remaining nodes.\nlet is_hydrating = false;\n\n/**\n * @returns {void}\n */\nexport function start_hydrating() {\n\tis_hydrating = true;\n}\n\n/**\n * @returns {void}\n */\nexport function end_hydrating() {\n\tis_hydrating = false;\n}\n\n/**\n * @param {number} low\n * @param {number} high\n * @param {(index: number) => number} key\n * @param {number} value\n * @returns {number}\n */\nfunction upper_bound(low, high, key, value) {\n\t// Return first index of value larger than input value in the range [low, high)\n\twhile (low < high) {\n\t\tconst mid = low + ((high - low) >> 1);\n\t\tif (key(mid) <= value) {\n\t\t\tlow = mid + 1;\n\t\t} else {\n\t\t\thigh = mid;\n\t\t}\n\t}\n\treturn low;\n}\n\n/**\n * @param {NodeEx} target\n * @returns {void}\n */\nfunction init_hydrate(target) {\n\tif (target.hydrate_init) return;\n\ttarget.hydrate_init = true;\n\t// We know that all children have claim_order values since the unclaimed have been detached if target is not <head>\n\n\tlet children = /** @type {ArrayLike<NodeEx2>} */ (target.childNodes);\n\t// If target is <head>, there may be children without claim_order\n\tif (target.nodeName === 'HEAD') {\n\t\tconst my_children = [];\n\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\tconst node = children[i];\n\t\t\tif (node.claim_order !== undefined) {\n\t\t\t\tmy_children.push(node);\n\t\t\t}\n\t\t}\n\t\tchildren = my_children;\n\t}\n\t/*\n\t * Reorder claimed children optimally.\n\t * We can reorder claimed children optimally by finding the longest subsequence of\n\t * nodes that are already claimed in order and only moving the rest. The longest\n\t * subsequence of nodes that are claimed in order can be found by\n\t * computing the longest increasing subsequence of .claim_order values.\n\t *\n\t * This algorithm is optimal in generating the least amount of reorder operations\n\t * possible.\n\t *\n\t * Proof:\n\t * We know that, given a set of reordering operations, the nodes that do not move\n\t * always form an increasing subsequence, since they do not move among each other\n\t * meaning that they must be already ordered among each other. Thus, the maximal\n\t * set of nodes that do not move form a longest increasing subsequence.\n\t */\n\t// Compute longest increasing subsequence\n\t// m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j\n\tconst m = new Int32Array(children.length + 1);\n\t// Predecessor indices + 1\n\tconst p = new Int32Array(children.length);\n\tm[0] = -1;\n\tlet longest = 0;\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst current = children[i].claim_order;\n\t\t// Find the largest subsequence length such that it ends in a value less than our current value\n\t\t// upper_bound returns first greater value, so we subtract one\n\t\t// with fast path for when we are on the current longest subsequence\n\t\tconst seq_len =\n\t\t\t(longest > 0 && children[m[longest]].claim_order <= current\n\t\t\t\t? longest + 1\n\t\t\t\t: upper_bound(1, longest, (idx) => children[m[idx]].claim_order, current)) - 1;\n\t\tp[i] = m[seq_len] + 1;\n\t\tconst new_len = seq_len + 1;\n\t\t// We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.\n\t\tm[new_len] = i;\n\t\tlongest = Math.max(new_len, longest);\n\t}\n\t// The longest increasing subsequence of nodes (initially reversed)\n\n\t/**\n\t * @type {NodeEx2[]}\n\t */\n\tconst lis = [];\n\t// The rest of the nodes, nodes that will be moved\n\n\t/**\n\t * @type {NodeEx2[]}\n\t */\n\tconst to_move = [];\n\tlet last = children.length - 1;\n\tfor (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {\n\t\tlis.push(children[cur - 1]);\n\t\tfor (; last >= cur; last--) {\n\t\t\tto_move.push(children[last]);\n\t\t}\n\t\tlast--;\n\t}\n\tfor (; last >= 0; last--) {\n\t\tto_move.push(children[last]);\n\t}\n\tlis.reverse();\n\t// We sort the nodes being moved to guarantee that their insertion order matches the claim order\n\tto_move.sort((a, b) => a.claim_order - b.claim_order);\n\t// Finally, we move the nodes\n\tfor (let i = 0, j = 0; i < to_move.length; i++) {\n\t\twhile (j < lis.length && to_move[i].claim_order >= lis[j].claim_order) {\n\t\t\tj++;\n\t\t}\n\t\tconst anchor = j < lis.length ? lis[j] : null;\n\t\ttarget.insertBefore(to_move[i], anchor);\n\t}\n}\n\n/**\n * @param {Node} target\n * @param {Node} node\n * @returns {void}\n */\nexport function append(target, node) {\n\ttarget.appendChild(node);\n}\n\n/**\n * @param {Node} target\n * @param {string} style_sheet_id\n * @param {string} styles\n * @returns {void}\n */\nexport function append_styles(target, style_sheet_id, styles) {\n\tconst append_styles_to = get_root_for_style(target);\n\tif (!append_styles_to.getElementById(style_sheet_id)) {\n\t\tconst style = element('style');\n\t\tstyle.id = style_sheet_id;\n\t\tstyle.textContent = styles;\n\t\tappend_stylesheet(append_styles_to, style);\n\t}\n}\n\n/**\n * @param {Node} node\n * @returns {ShadowRoot | Document}\n */\nexport function get_root_for_style(node) {\n\tif (!node) return document;\n\tconst root = node.getRootNode ? node.getRootNode() : node.ownerDocument;\n\tif (root && /** @type {ShadowRoot} */ (root).host) {\n\t\treturn /** @type {ShadowRoot} */ (root);\n\t}\n\treturn node.ownerDocument;\n}\n\n/**\n * @param {Node} node\n * @returns {CSSStyleSheet}\n */\nexport function append_empty_stylesheet(node) {\n\tconst style_element = element('style');\n\t// For transitions to work without 'style-src: unsafe-inline' Content Security Policy,\n\t// these empty tags need to be allowed with a hash as a workaround until we move to the Web Animations API.\n\t// Using the hash for the empty string (for an empty tag) works in all browsers except Safari.\n\t// So as a workaround for the workaround, when we append empty style tags we set their content to /* empty */.\n\t// The hash 'sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=' will then work even in Safari.\n\tstyle_element.textContent = '/* empty */';\n\tappend_stylesheet(get_root_for_style(node), style_element);\n\treturn style_element.sheet;\n}\n\n/**\n * @param {ShadowRoot | Document} node\n * @param {HTMLStyleElement} style\n * @returns {CSSStyleSheet}\n */\nfunction append_stylesheet(node, style) {\n\tappend(/** @type {Document} */ (node).head || node, style);\n\treturn style.sheet;\n}\n\n/**\n * @param {NodeEx} target\n * @param {NodeEx} node\n * @returns {void}\n */\nexport function append_hydration(target, node) {\n\tif (is_hydrating) {\n\t\tinit_hydrate(target);\n\t\tif (\n\t\t\ttarget.actual_end_child === undefined ||\n\t\t\t(target.actual_end_child !== null && target.actual_end_child.parentNode !== target)\n\t\t) {\n\t\t\ttarget.actual_end_child = target.firstChild;\n\t\t}\n\t\t// Skip nodes of undefined ordering\n\t\twhile (target.actual_end_child !== null && target.actual_end_child.claim_order === undefined) {\n\t\t\ttarget.actual_end_child = target.actual_end_child.nextSibling;\n\t\t}\n\t\tif (node !== target.actual_end_child) {\n\t\t\t// We only insert if the ordering of this node should be modified or the parent node is not target\n\t\t\tif (node.claim_order !== undefined || node.parentNode !== target) {\n\t\t\t\ttarget.insertBefore(node, target.actual_end_child);\n\t\t\t}\n\t\t} else {\n\t\t\ttarget.actual_end_child = node.nextSibling;\n\t\t}\n\t} else if (node.parentNode !== target || node.nextSibling !== null) {\n\t\ttarget.appendChild(node);\n\t}\n}\n\n/**\n * @param {Node} target\n * @param {Node} node\n * @param {Node} [anchor]\n * @returns {void}\n */\nexport function insert(target, node, anchor) {\n\ttarget.insertBefore(node, anchor || null);\n}\n\n/**\n * @param {NodeEx} target\n * @param {NodeEx} node\n * @param {NodeEx} [anchor]\n * @returns {void}\n */\nexport function insert_hydration(target, node, anchor) {\n\tif (is_hydrating && !anchor) {\n\t\tappend_hydration(target, node);\n\t} else if (node.parentNode !== target || node.nextSibling != anchor) {\n\t\ttarget.insertBefore(node, anchor || null);\n\t}\n}\n\n/**\n * @param {Node} node\n * @returns {void}\n */\nexport function detach(node) {\n\tif (node.parentNode) {\n\t\tnode.parentNode.removeChild(node);\n\t}\n}\n\n/**\n * @returns {void} */\nexport function destroy_each(iterations, detaching) {\n\tfor (let i = 0; i < iterations.length; i += 1) {\n\t\tif (iterations[i]) iterations[i].d(detaching);\n\t}\n}\n\n/**\n * @template {keyof HTMLElementTagNameMap} K\n * @param {K} name\n * @returns {HTMLElementTagNameMap[K]}\n */\nexport function element(name) {\n\treturn document.createElement(name);\n}\n\n/**\n * @template {keyof HTMLElementTagNameMap} K\n * @param {K} name\n * @param {string} is\n * @returns {HTMLElementTagNameMap[K]}\n */\nexport function element_is(name, is) {\n\treturn document.createElement(name, { is });\n}\n\n/**\n * @template T\n * @template {keyof T} K\n * @param {T} obj\n * @param {K[]} exclude\n * @returns {Pick<T, Exclude<keyof T, K>>}\n */\nexport function object_without_properties(obj, exclude) {\n\tconst target = /** @type {Pick<T, Exclude<keyof T, K>>} */ ({});\n\tfor (const k in obj) {\n\t\tif (\n\t\t\thas_prop(obj, k) &&\n\t\t\t// @ts-ignore\n\t\t\texclude.indexOf(k) === -1\n\t\t) {\n\t\t\t// @ts-ignore\n\t\t\ttarget[k] = obj[k];\n\t\t}\n\t}\n\treturn target;\n}\n\n/**\n * @template {keyof SVGElementTagNameMap} K\n * @param {K} name\n * @returns {SVGElement}\n */\nexport function svg_element(name) {\n\treturn document.createElementNS('http://www.w3.org/2000/svg', name);\n}\n\n/**\n * @param {string} data\n * @returns {Text}\n */\nexport function text(data) {\n\treturn document.createTextNode(data);\n}\n\n/**\n * @returns {Text} */\nexport function space() {\n\treturn text(' ');\n}\n\n/**\n * @returns {Text} */\nexport function empty() {\n\treturn text('');\n}\n\n/**\n * @param {string} content\n * @returns {Comment}\n */\nexport function comment(content) {\n\treturn document.createComment(content);\n}\n\n/**\n * @param {EventTarget} node\n * @param {string} event\n * @param {EventListenerOrEventListenerObject} handler\n * @param {boolean | AddEventListenerOptions | EventListenerOptions} [options]\n * @returns {() => void}\n */\nexport function listen(node, event, handler, options) {\n\tnode.addEventListener(event, handler, options);\n\treturn () => node.removeEventListener(event, handler, options);\n}\n\n/**\n * @returns {(event: any) => any} */\nexport function prevent_default(fn) {\n\treturn function (event) {\n\t\tevent.preventDefault();\n\t\t// @ts-ignore\n\t\treturn fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => any} */\nexport function stop_propagation(fn) {\n\treturn function (event) {\n\t\tevent.stopPropagation();\n\t\t// @ts-ignore\n\t\treturn fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => any} */\nexport function stop_immediate_propagation(fn) {\n\treturn function (event) {\n\t\tevent.stopImmediatePropagation();\n\t\t// @ts-ignore\n\t\treturn fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => void} */\nexport function self(fn) {\n\treturn function (event) {\n\t\t// @ts-ignore\n\t\tif (event.target === this) fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => void} */\nexport function trusted(fn) {\n\treturn function (event) {\n\t\t// @ts-ignore\n\t\tif (event.isTrusted) fn.call(this, event);\n\t};\n}\n\n/**\n * @param {Element} node\n * @param {string} attribute\n * @param {string} [value]\n * @returns {void}\n */\nexport function attr(node, attribute, value) {\n\tif (value == null) node.removeAttribute(attribute);\n\telse if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value);\n}\n/**\n * List of attributes that should always be set through the attr method,\n * because updating them through the property setter doesn't work reliably.\n * In the example of `width`/`height`, the problem is that the setter only\n * accepts numeric values, but the attribute can also be set to a string like `50%`.\n * If this list becomes too big, rethink this approach.\n */\nconst always_set_through_set_attribute = ['width', 'height'];\n\n/**\n * @param {Element & ElementCSSInlineStyle} node\n * @param {{ [x: string]: string }} attributes\n * @returns {void}\n */\nexport function set_attributes(node, attributes) {\n\t// @ts-ignore\n\tconst descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n\tfor (const key in attributes) {\n\t\tif (attributes[key] == null) {\n\t\t\tnode.removeAttribute(key);\n\t\t} else if (key === 'style') {\n\t\t\tnode.style.cssText = attributes[key];\n\t\t} else if (key === '__value') {\n\t\t\t/** @type {any} */ (node).value = node[key] = attributes[key];\n\t\t} else if (\n\t\t\tdescriptors[key] &&\n\t\t\tdescriptors[key].set &&\n\t\t\talways_set_through_set_attribute.indexOf(key) === -1\n\t\t) {\n\t\t\tnode[key] = attributes[key];\n\t\t} else {\n\t\t\tattr(node, key, attributes[key]);\n\t\t}\n\t}\n}\n\n/**\n * @param {Element & ElementCSSInlineStyle} node\n * @param {{ [x: string]: string }} attributes\n * @returns {void}\n */\nexport function set_svg_attributes(node, attributes) {\n\tfor (const key in attributes) {\n\t\tattr(node, key, attributes[key]);\n\t}\n}\n\n/**\n * @param {Record<string, unknown>} data_map\n * @returns {void}\n */\nexport function set_custom_element_data_map(node, data_map) {\n\tObject.keys(data_map).forEach((key) => {\n\t\tset_custom_element_data(node, key, data_map[key]);\n\t});\n}\n\n/**\n * @returns {void} */\nexport function set_custom_element_data(node, prop, value) {\n\tconst lower = prop.toLowerCase(); // for backwards compatibility with existing behavior we do lowercase first\n\tif (lower in node) {\n\t\tnode[lower] = typeof node[lower] === 'boolean' && value === '' ? true : value;\n\t} else if (prop in node) {\n\t\tnode[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;\n\t} else {\n\t\tattr(node, prop, value);\n\t}\n}\n\n/**\n * @param {string} tag\n */\nexport function set_dynamic_element_data(tag) {\n\treturn /-/.test(tag) ? set_custom_element_data_map : set_attributes;\n}\n\n/**\n * @returns {void}\n */\nexport function xlink_attr(node, attribute, value) {\n\tnode.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\n\n/**\n * @param {HTMLElement} node\n * @returns {string}\n */\nexport function get_svelte_dataset(node) {\n\treturn node.dataset.svelteH;\n}\n\n/**\n * @returns {unknown[]} */\nexport function get_binding_group_value(group, __value, checked) {\n\tconst value = new Set();\n\tfor (let i = 0; i < group.length; i += 1) {\n\t\tif (group[i].checked) value.add(group[i].__value);\n\t}\n\tif (!checked) {\n\t\tvalue.delete(__value);\n\t}\n\treturn Array.from(value);\n}\n\n/**\n * @param {HTMLInputElement[]} group\n * @returns {{ p(...inputs: HTMLInputElement[]): void; r(): void; }}\n */\nexport function init_binding_group(group) {\n\t/**\n\t * @type {HTMLInputElement[]} */\n\tlet _inputs;\n\treturn {\n\t\t/* push */ p(...inputs) {\n\t\t\t_inputs = inputs;\n\t\t\t_inputs.forEach((input) => group.push(input));\n\t\t},\n\t\t/* remove */ r() {\n\t\t\t_inputs.forEach((input) => group.splice(group.indexOf(input), 1));\n\t\t}\n\t};\n}\n\n/**\n * @param {number[]} indexes\n * @returns {{ u(new_indexes: number[]): void; p(...inputs: HTMLInputElement[]): void; r: () => void; }}\n */\nexport function init_binding_group_dynamic(group, indexes) {\n\t/**\n\t * @type {HTMLInputElement[]} */\n\tlet _group = get_binding_group(group);\n\n\t/**\n\t * @type {HTMLInputElement[]} */\n\tlet _inputs;\n\n\tfunction get_binding_group(group) {\n\t\tfor (let i = 0; i < indexes.length; i++) {\n\t\t\tgroup = group[indexes[i]] = group[indexes[i]] || [];\n\t\t}\n\t\treturn group;\n\t}\n\n\t/**\n\t * @returns {void} */\n\tfunction push() {\n\t\t_inputs.forEach((input) => _group.push(input));\n\t}\n\n\t/**\n\t * @returns {void} */\n\tfunction remove() {\n\t\t_inputs.forEach((input) => _group.splice(_group.indexOf(input), 1));\n\t}\n\treturn {\n\t\t/* update */ u(new_indexes) {\n\t\t\tindexes = new_indexes;\n\t\t\tconst new_group = get_binding_group(group);\n\t\t\tif (new_group !== _group) {\n\t\t\t\tremove();\n\t\t\t\t_group = new_group;\n\t\t\t\tpush();\n\t\t\t}\n\t\t},\n\t\t/* push */ p(...inputs) {\n\t\t\t_inputs = inputs;\n\t\t\tpush();\n\t\t},\n\t\t/* remove */ r: remove\n\t};\n}\n\n/** @returns {number} */\nexport function to_number(value) {\n\treturn value === '' ? null : +value;\n}\n\n/** @returns {any[]} */\nexport function time_ranges_to_array(ranges) {\n\tconst array = [];\n\tfor (let i = 0; i < ranges.length; i += 1) {\n\t\tarray.push({ start: ranges.start(i), end: ranges.end(i) });\n\t}\n\treturn array;\n}\n\n/**\n * @param {Element} element\n * @returns {ChildNode[]}\n */\nexport function children(element) {\n\treturn Array.from(element.childNodes);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @returns {void}\n */\nfunction init_claim_info(nodes) {\n\tif (nodes.claim_info === undefined) {\n\t\tnodes.claim_info = { last_index: 0, total_claimed: 0 };\n\t}\n}\n\n/**\n * @template {ChildNodeEx} R\n * @param {ChildNodeArray} nodes\n * @param {(node: ChildNodeEx) => node is R} predicate\n * @param {(node: ChildNodeEx) => ChildNodeEx | undefined} process_node\n * @param {() => R} create_node\n * @param {boolean} dont_update_last_index\n * @returns {R}\n */\nfunction claim_node(nodes, predicate, process_node, create_node, dont_update_last_index = false) {\n\t// Try to find nodes in an order such that we lengthen the longest increasing subsequence\n\tinit_claim_info(nodes);\n\tconst result_node = (() => {\n\t\t// We first try to find an element after the previous one\n\t\tfor (let i = nodes.claim_info.last_index; i < nodes.length; i++) {\n\t\t\tconst node = nodes[i];\n\t\t\tif (predicate(node)) {\n\t\t\t\tconst replacement = process_node(node);\n\t\t\t\tif (replacement === undefined) {\n\t\t\t\t\tnodes.splice(i, 1);\n\t\t\t\t} else {\n\t\t\t\t\tnodes[i] = replacement;\n\t\t\t\t}\n\t\t\t\tif (!dont_update_last_index) {\n\t\t\t\t\tnodes.claim_info.last_index = i;\n\t\t\t\t}\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\t// Otherwise, we try to find one before\n\t\t// We iterate in reverse so that we don't go too far back\n\t\tfor (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {\n\t\t\tconst node = nodes[i];\n\t\t\tif (predicate(node)) {\n\t\t\t\tconst replacement = process_node(node);\n\t\t\t\tif (replacement === undefined) {\n\t\t\t\t\tnodes.splice(i, 1);\n\t\t\t\t} else {\n\t\t\t\t\tnodes[i] = replacement;\n\t\t\t\t}\n\t\t\t\tif (!dont_update_last_index) {\n\t\t\t\t\tnodes.claim_info.last_index = i;\n\t\t\t\t} else if (replacement === undefined) {\n\t\t\t\t\t// Since we spliced before the last_index, we decrease it\n\t\t\t\t\tnodes.claim_info.last_index--;\n\t\t\t\t}\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\t// If we can't find any matching node, we create a new one\n\t\treturn create_node();\n\t})();\n\tresult_node.claim_order = nodes.claim_info.total_claimed;\n\tnodes.claim_info.total_claimed += 1;\n\treturn result_node;\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @param {string} name\n * @param {{ [key: string]: boolean }} attributes\n * @param {(name: string) => Element | SVGElement} create_element\n * @returns {Element | SVGElement}\n */\nfunction claim_element_base(nodes, name, attributes, create_element) {\n\treturn claim_node(\n\t\tnodes,\n\t\t/** @returns {node is Element | SVGElement} */\n\t\t(node) => node.nodeName === name,\n\t\t/** @param {Element} node */\n\t\t(node) => {\n\t\t\tconst remove = [];\n\t\t\tfor (let j = 0; j < node.attributes.length; j++) {\n\t\t\t\tconst attribute = node.attributes[j];\n\t\t\t\tif (!attributes[attribute.name]) {\n\t\t\t\t\tremove.push(attribute.name);\n\t\t\t\t}\n\t\t\t}\n\t\t\tremove.forEach((v) => node.removeAttribute(v));\n\t\t\treturn undefined;\n\t\t},\n\t\t() => create_element(name)\n\t);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @param {string} name\n * @param {{ [key: string]: boolean }} attributes\n * @returns {Element | SVGElement}\n */\nexport function claim_element(nodes, name, attributes) {\n\treturn claim_element_base(nodes, name, attributes, element);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @param {string} name\n * @param {{ [key: string]: boolean }} attributes\n * @returns {Element | SVGElement}\n */\nexport function claim_svg_element(nodes, name, attributes) {\n\treturn claim_element_base(nodes, name, attributes, svg_element);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @returns {Text}\n */\nexport function claim_text(nodes, data) {\n\treturn claim_node(\n\t\tnodes,\n\t\t/** @returns {node is Text} */\n\t\t(node) => node.nodeType === 3,\n\t\t/** @param {Text} node */\n\t\t(node) => {\n\t\t\tconst data_str = '' + data;\n\t\t\tif (node.data.startsWith(data_str)) {\n\t\t\t\tif (node.data.length !== data_str.length) {\n\t\t\t\t\treturn node.splitText(data_str.length);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnode.data = data_str;\n\t\t\t}\n\t\t},\n\t\t() => text(data),\n\t\ttrue // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements\n\t);\n}\n\n/**\n * @returns {Text} */\nexport function claim_space(nodes) {\n\treturn claim_text(nodes, ' ');\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @returns {Comment}\n */\nexport function claim_comment(nodes, data) {\n\treturn claim_node(\n\t\tnodes,\n\t\t/** @returns {node is Comment} */\n\t\t(node) => node.nodeType === 8,\n\t\t/** @param {Comment} node */\n\t\t(node) => {\n\t\t\tnode.data = '' + data;\n\t\t\treturn undefined;\n\t\t},\n\t\t() => comment(data),\n\t\ttrue\n\t);\n}\n\nfunction get_comment_idx(nodes, text, start) {\n\tfor (let i = start; i < nodes.length; i += 1) {\n\t\tconst node = nodes[i];\n\t\tif (node.nodeType === 8 /* comment node */ && node.textContent.trim() === text) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n * @param {boolean} is_svg\n * @returns {HtmlTagHydration}\n */\nexport function claim_html_tag(nodes, is_svg) {\n\t// find html opening tag\n\tconst start_index = get_comment_idx(nodes, 'HTML_TAG_START', 0);\n\tconst end_index = get_comment_idx(nodes, 'HTML_TAG_END', start_index + 1);\n\tif (start_index === -1 || end_index === -1) {\n\t\treturn new HtmlTagHydration(is_svg);\n\t}\n\n\tinit_claim_info(nodes);\n\tconst html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);\n\tdetach(html_tag_nodes[0]);\n\tdetach(html_tag_nodes[html_tag_nodes.length - 1]);\n\tconst claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);\n\tif (claimed_nodes.length === 0) {\n\t\treturn new HtmlTagHydration(is_svg);\n\t}\n\tfor (const n of claimed_nodes) {\n\t\tn.claim_order = nodes.claim_info.total_claimed;\n\t\tnodes.claim_info.total_claimed += 1;\n\t}\n\treturn new HtmlTagHydration(is_svg, claimed_nodes);\n}\n\n/**\n * @param {Text} text\n * @param {unknown} data\n * @returns {void}\n */\nexport function set_data(text, data) {\n\tdata = '' + data;\n\tif (text.data === data) return;\n\ttext.data = /** @type {string} */ (data);\n}\n\n/**\n * @param {Text} text\n * @param {unknown} data\n * @returns {void}\n */\nexport function set_data_contenteditable(text, data) {\n\tdata = '' + data;\n\tif (text.wholeText === data) return;\n\ttext.data = /** @type {string} */ (data);\n}\n\n/**\n * @param {Text} text\n * @param {unknown} data\n * @param {string} attr_value\n * @returns {void}\n */\nexport function set_data_maybe_contenteditable(text, data, attr_value) {\n\tif (~contenteditable_truthy_values.indexOf(attr_value)) {\n\t\tset_data_contenteditable(text, data);\n\t} else {\n\t\tset_data(text, data);\n\t}\n}\n\n/**\n * @returns {void} */\nexport function set_input_value(input, value) {\n\tinput.value = value == null ? '' : value;\n}\n\n/**\n * @returns {void} */\nexport function set_input_type(input, type) {\n\ttry {\n\t\tinput.type = type;\n\t} catch (e) {\n\t\t// do nothing\n\t}\n}\n\n/**\n * @returns {void} */\nexport function set_style(node, key, value, important) {\n\tif (value == null) {\n\t\tnode.style.removeProperty(key);\n\t} else {\n\t\tnode.style.setProperty(key, value, important ? 'important' : '');\n\t}\n}\n\n/**\n * @returns {void} */\nexport function select_option(select, value, mounting) {\n\tfor (let i = 0; i < select.options.length; i += 1) {\n\t\tconst option = select.options[i];\n\t\tif (option.__value === value) {\n\t\t\toption.selected = true;\n\t\t\treturn;\n\t\t}\n\t}\n\tif (!mounting || value !== undefined) {\n\t\tselect.selectedIndex = -1; // no option should be selected\n\t}\n}\n\n/**\n * @returns {void} */\nexport function select_options(select, value) {\n\tfor (let i = 0; i < select.options.length; i += 1) {\n\t\tconst option = select.options[i];\n\t\toption.selected = ~value.indexOf(option.__value);\n\t}\n}\n\nexport function select_value(select) {\n\tconst selected_option = select.querySelector(':checked');\n\treturn selected_option && selected_option.__value;\n}\n\nexport function select_multiple_value(select) {\n\treturn [].map.call(select.querySelectorAll(':checked'), (option) => option.__value);\n}\n// unfortunately this can't be a constant as that wouldn't be tree-shakeable\n// so we cache the result instead\n\n/**\n * @type {boolean} */\nlet crossorigin;\n\n/**\n * @returns {boolean} */\nexport function is_crossorigin() {\n\tif (crossorigin === undefined) {\n\t\tcrossorigin = false;\n\t\ttry {\n\t\t\tif (typeof window !== 'undefined' && window.parent) {\n\t\t\t\tvoid window.parent.document;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tcrossorigin = true;\n\t\t}\n\t}\n\treturn crossorigin;\n}\n\n/**\n * @param {HTMLElement} node\n * @param {() => void} fn\n * @returns {() => void}\n */\nexport function add_iframe_resize_listener(node, fn) {\n\tconst computed_style = getComputedStyle(node);\n\tif (computed_style.position === 'static') {\n\t\tnode.style.position = 'relative';\n\t}\n\tconst iframe = element('iframe');\n\tiframe.setAttribute(\n\t\t'style',\n\t\t'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +\n\t\t\t'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;'\n\t);\n\tiframe.setAttribute('aria-hidden', 'true');\n\tiframe.tabIndex = -1;\n\tconst crossorigin = is_crossorigin();\n\n\t/**\n\t * @type {() => void}\n\t */\n\tlet unsubscribe;\n\tif (crossorigin) {\n\t\tiframe.src = \"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}</script>\";\n\t\tunsubscribe = listen(\n\t\t\twindow,\n\t\t\t'message',\n\t\t\t/** @param {MessageEvent} event */ (event) => {\n\t\t\t\tif (event.source === iframe.contentWindow) fn();\n\t\t\t}\n\t\t);\n\t} else {\n\t\tiframe.src = 'about:blank';\n\t\tiframe.onload = () => {\n\t\t\tunsubscribe = listen(iframe.contentWindow, 'resize', fn);\n\t\t\t// make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n\t\t\t// see https://github.com/sveltejs/svelte/issues/4233\n\t\t\tfn();\n\t\t};\n\t}\n\tappend(node, iframe);\n\treturn () => {\n\t\tif (crossorigin) {\n\t\t\tunsubscribe();\n\t\t} else if (unsubscribe && iframe.contentWindow) {\n\t\t\tunsubscribe();\n\t\t}\n\t\tdetach(iframe);\n\t};\n}\nexport const resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({\n\tbox: 'content-box'\n});\nexport const resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({\n\tbox: 'border-box'\n});\nexport const resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton(\n\t{ box: 'device-pixel-content-box' }\n);\nexport { ResizeObserverSingleton };\n\n/**\n * @returns {void} */\nexport function toggle_class(element, name, toggle) {\n\t// The `!!` is required because an `undefined` flag means flipping the current state.\n\telement.classList.toggle(name, !!toggle);\n}\n\n/**\n * @template T\n * @param {string} type\n * @param {T} [detail]\n * @param {{ bubbles?: boolean, cancelable?: boolean }} [options]\n * @returns {CustomEvent<T>}\n */\nexport function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n\treturn new CustomEvent(type, { detail, bubbles, cancelable });\n}\n\n/**\n * @param {string} selector\n * @param {HTMLElement} parent\n * @returns {ChildNodeArray}\n */\nexport function query_selector_all(selector, parent = document.body) {\n\treturn Array.from(parent.querySelectorAll(selector));\n}\n\n/**\n * @param {string} nodeId\n * @param {HTMLElement} head\n * @returns {any[]}\n */\nexport function head_selector(nodeId, head) {\n\tconst result = [];\n\tlet started = 0;\n\tfor (const node of head.childNodes) {\n\t\tif (node.nodeType === 8 /* comment node */) {\n\t\t\tconst comment = node.textContent.trim();\n\t\t\tif (comment === `HEAD_${nodeId}_END`) {\n\t\t\t\tstarted -= 1;\n\t\t\t\tresult.push(node);\n\t\t\t} else if (comment === `HEAD_${nodeId}_START`) {\n\t\t\t\tstarted += 1;\n\t\t\t\tresult.push(node);\n\t\t\t}\n\t\t} else if (started > 0) {\n\t\t\tresult.push(node);\n\t\t}\n\t}\n\treturn result;\n}\n/** */\nexport class HtmlTag {\n\t/**\n\t * @private\n\t * @default false\n\t */\n\tis_svg = false;\n\t/** parent for creating node */\n\te = undefined;\n\t/** html tag nodes */\n\tn = undefined;\n\t/** target */\n\tt = undefined;\n\t/** anchor */\n\ta = undefined;\n\tconstructor(is_svg = false) {\n\t\tthis.is_svg = is_svg;\n\t\tthis.e = this.n = null;\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @returns {void}\n\t */\n\tc(html) {\n\t\tthis.h(html);\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @param {HTMLElement | SVGElement} target\n\t * @param {HTMLElement | SVGElement} anchor\n\t * @returns {void}\n\t */\n\tm(html, target, anchor = null) {\n\t\tif (!this.e) {\n\t\t\tif (this.is_svg)\n\t\t\t\tthis.e = svg_element(/** @type {keyof SVGElementTagNameMap} */ (target.nodeName));\n\t\t\t/** #7364  target for <template> may be provided as #document-fragment(11) */ else\n\t\t\t\tthis.e = element(\n\t\t\t\t\t/** @type {keyof HTMLElementTagNameMap} */ (\n\t\t\t\t\t\ttarget.nodeType === 11 ? 'TEMPLATE' : target.nodeName\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\tthis.t =\n\t\t\t\ttarget.tagName !== 'TEMPLATE'\n\t\t\t\t\t? target\n\t\t\t\t\t: /** @type {HTMLTemplateElement} */ (target).content;\n\t\t\tthis.c(html);\n\t\t}\n\t\tthis.i(anchor);\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @returns {void}\n\t */\n\th(html) {\n\t\tthis.e.innerHTML = html;\n\t\tthis.n = Array.from(\n\t\t\tthis.e.nodeName === 'TEMPLATE' ? this.e.content.childNodes : this.e.childNodes\n\t\t);\n\t}\n\n\t/**\n\t * @returns {void} */\n\ti(anchor) {\n\t\tfor (let i = 0; i < this.n.length; i += 1) {\n\t\t\tinsert(this.t, this.n[i], anchor);\n\t\t}\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @returns {void}\n\t */\n\tp(html) {\n\t\tthis.d();\n\t\tthis.h(html);\n\t\tthis.i(this.a);\n\t}\n\n\t/**\n\t * @returns {void} */\n\td() {\n\t\tthis.n.forEach(detach);\n\t}\n}\n\nexport class HtmlTagHydration extends HtmlTag {\n\t/** @type {Element[]} hydration claimed nodes */\n\tl = undefined;\n\n\tconstructor(is_svg = false, claimed_nodes) {\n\t\tsuper(is_svg);\n\t\tthis.e = this.n = null;\n\t\tthis.l = claimed_nodes;\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @returns {void}\n\t */\n\tc(html) {\n\t\tif (this.l) {\n\t\t\tthis.n = this.l;\n\t\t} else {\n\t\t\tsuper.c(html);\n\t\t}\n\t}\n\n\t/**\n\t * @returns {void} */\n\ti(anchor) {\n\t\tfor (let i = 0; i < this.n.length; i += 1) {\n\t\t\tinsert_hydration(this.t, this.n[i], anchor);\n\t\t}\n\t}\n}\n\n/**\n * @param {NamedNodeMap} attributes\n * @returns {{}}\n */\nexport function attribute_to_object(attributes) {\n\tconst result = {};\n\tfor (const attribute of attributes) {\n\t\tresult[attribute.name] = attribute.value;\n\t}\n\treturn result;\n}\n\nconst escaped = {\n\t'\"': '&quot;',\n\t'&': '&amp;',\n\t'<': '&lt;'\n};\n\nconst regex_attribute_characters_to_escape = /[\"&<]/g;\n\n/**\n * Note that the attribute itself should be surrounded in double quotes\n * @param {any} attribute\n */\nfunction escape_attribute(attribute) {\n\treturn String(attribute).replace(regex_attribute_characters_to_escape, (match) => escaped[match]);\n}\n\n/**\n * @param {Record<string, string>} attributes\n */\nexport function stringify_spread(attributes) {\n\tlet str = ' ';\n\tfor (const key in attributes) {\n\t\tif (attributes[key] != null) {\n\t\t\tstr += `${key}=\"${escape_attribute(attributes[key])}\" `;\n\t\t}\n\t}\n\n\treturn str;\n}\n\n/**\n * @param {HTMLElement} element\n * @returns {{}}\n */\nexport function get_custom_elements_slots(element) {\n\tconst result = {};\n\telement.childNodes.forEach(\n\t\t/** @param {Element} node */ (node) => {\n\t\t\tresult[node.slot || 'default'] = true;\n\t\t}\n\t);\n\treturn result;\n}\n\nexport function construct_svelte_component(component, props) {\n\treturn new component(props);\n}\n\n/**\n * @typedef {Node & {\n * \tclaim_order?: number;\n * \thydrate_init?: true;\n * \tactual_end_child?: NodeEx;\n * \tchildNodes: NodeListOf<NodeEx>;\n * }} NodeEx\n */\n\n/** @typedef {ChildNode & NodeEx} ChildNodeEx */\n\n/** @typedef {NodeEx & { claim_order: number }} NodeEx2 */\n\n/**\n * @typedef {ChildNodeEx[] & {\n * \tclaim_info?: {\n * \t\tlast_index: number;\n * \t\ttotal_claimed: number;\n * \t};\n * }} ChildNodeArray\n */\n","import { custom_event } from './dom.js';\n\nexport let current_component;\n\n/** @returns {void} */\nexport function set_current_component(component) {\n\tcurrent_component = component;\n}\n\nexport function get_current_component() {\n\tif (!current_component) throw new Error('Function called outside component initialization');\n\treturn current_component;\n}\n\n/**\n * Schedules a callback to run immediately before the component is updated after any state change.\n *\n * The first time the callback runs will be before the initial `onMount`\n *\n * https://svelte.dev/docs/svelte#beforeupdate\n * @param {() => any} fn\n * @returns {void}\n */\nexport function beforeUpdate(fn) {\n\tget_current_component().$$.before_update.push(fn);\n}\n\n/**\n * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.\n * It must be called during the component's initialisation (but doesn't need to live *inside* the component;\n * it can be called from an external module).\n *\n * If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted.\n *\n * `onMount` does not run inside a [server-side component](https://svelte.dev/docs#run-time-server-side-component-api).\n *\n * https://svelte.dev/docs/svelte#onmount\n * @template T\n * @param {() => import('./private.js').NotFunction<T> | Promise<import('./private.js').NotFunction<T>> | (() => any)} fn\n * @returns {void}\n */\nexport function onMount(fn) {\n\tget_current_component().$$.on_mount.push(fn);\n}\n\n/**\n * Schedules a callback to run immediately after the component has been updated.\n *\n * The first time the callback runs will be after the initial `onMount`\n *\n * https://svelte.dev/docs/svelte#afterupdate\n * @param {() => any} fn\n * @returns {void}\n */\nexport function afterUpdate(fn) {\n\tget_current_component().$$.after_update.push(fn);\n}\n\n/**\n * Schedules a callback to run immediately before the component is unmounted.\n *\n * Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the\n * only one that runs inside a server-side component.\n *\n * https://svelte.dev/docs/svelte#ondestroy\n * @param {() => any} fn\n * @returns {void}\n */\nexport function onDestroy(fn) {\n\tget_current_component().$$.on_destroy.push(fn);\n}\n\n/**\n * Creates an event dispatcher that can be used to dispatch [component events](https://svelte.dev/docs#template-syntax-component-directives-on-eventname).\n * Event dispatchers are functions that can take two arguments: `name` and `detail`.\n *\n * Component events created with `createEventDispatcher` create a\n * [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent).\n * These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture).\n * The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail)\n * property and can contain any type of data.\n *\n * The event dispatcher can be typed to narrow the allowed event names and the type of the `detail` argument:\n * ```ts\n * const dispatch = createEventDispatcher<{\n *  loaded: never; // does not take a detail argument\n *  change: string; // takes a detail argument of type string, which is required\n *  optional: number | null; // takes an optional detail argument of type number\n * }>();\n * ```\n *\n * https://svelte.dev/docs/svelte#createeventdispatcher\n * @template {Record<string, any>} [EventMap=any]\n * @returns {import('./public.js').EventDispatcher<EventMap>}\n */\nexport function createEventDispatcher() {\n\tconst component = get_current_component();\n\treturn (type, detail, { cancelable = false } = {}) => {\n\t\tconst callbacks = component.$$.callbacks[type];\n\t\tif (callbacks) {\n\t\t\t// TODO are there situations where events could be dispatched\n\t\t\t// in a server (non-DOM) environment?\n\t\t\tconst event = custom_event(/** @type {string} */ (type), detail, { cancelable });\n\t\t\tcallbacks.slice().forEach((fn) => {\n\t\t\t\tfn.call(component, event);\n\t\t\t});\n\t\t\treturn !event.defaultPrevented;\n\t\t}\n\t\treturn true;\n\t};\n}\n\n/**\n * Associates an arbitrary `context` object with the current component and the specified `key`\n * and returns that object. The context is then available to children of the component\n * (including slotted content) with `getContext`.\n *\n * Like lifecycle functions, this must be called during component initialisation.\n *\n * https://svelte.dev/docs/svelte#setcontext\n * @template T\n * @param {any} key\n * @param {T} context\n * @returns {T}\n */\nexport function setContext(key, context) {\n\tget_current_component().$$.context.set(key, context);\n\treturn context;\n}\n\n/**\n * Retrieves the context that belongs to the closest parent component with the specified `key`.\n * Must be called during component initialisation.\n *\n * https://svelte.dev/docs/svelte#getcontext\n * @template T\n * @param {any} key\n * @returns {T}\n */\nexport function getContext(key) {\n\treturn get_current_component().$$.context.get(key);\n}\n\n/**\n * Retrieves the whole context map that belongs to the closest parent component.\n * Must be called during component initialisation. Useful, for example, if you\n * programmatically create a component and want to pass the existing context to it.\n *\n * https://svelte.dev/docs/svelte#getallcontexts\n * @template {Map<any, any>} [T=Map<any, any>]\n * @returns {T}\n */\nexport function getAllContexts() {\n\treturn get_current_component().$$.context;\n}\n\n/**\n * Checks whether a given `key` has been set in the context of a parent component.\n * Must be called during component initialisation.\n *\n * https://svelte.dev/docs/svelte#hascontext\n * @param {any} key\n * @returns {boolean}\n */\nexport function hasContext(key) {\n\treturn get_current_component().$$.context.has(key);\n}\n\n// TODO figure out if we still want to support\n// shorthand events, or if we want to implement\n// a real bubbling mechanism\n/**\n * @param component\n * @param event\n * @returns {void}\n */\nexport function bubble(component, event) {\n\tconst callbacks = component.$$.callbacks[event.type];\n\tif (callbacks) {\n\t\t// @ts-ignore\n\t\tcallbacks.slice().forEach((fn) => fn.call(this, event));\n\t}\n}\n","import { run_all } from './utils.js';\nimport { current_component, set_current_component } from './lifecycle.js';\n\nexport const dirty_components = [];\nexport const intros = { enabled: false };\nexport const binding_callbacks = [];\n\nlet render_callbacks = [];\n\nconst flush_callbacks = [];\n\nconst resolved_promise = /* @__PURE__ */ Promise.resolve();\n\nlet update_scheduled = false;\n\n/** @returns {void} */\nexport function schedule_update() {\n\tif (!update_scheduled) {\n\t\tupdate_scheduled = true;\n\t\tresolved_promise.then(flush);\n\t}\n}\n\n/** @returns {Promise<void>} */\nexport function tick() {\n\tschedule_update();\n\treturn resolved_promise;\n}\n\n/** @returns {void} */\nexport function add_render_callback(fn) {\n\trender_callbacks.push(fn);\n}\n\n/** @returns {void} */\nexport function add_flush_callback(fn) {\n\tflush_callbacks.push(fn);\n}\n\n// flush() calls callbacks in this order:\n// 1. All beforeUpdate callbacks, in order: parents before children\n// 2. All bind:this callbacks, in reverse order: children before parents.\n// 3. All afterUpdate callbacks, in order: parents before children. EXCEPT\n//    for afterUpdates called during the initial onMount, which are called in\n//    reverse order: children before parents.\n// Since callbacks might update component values, which could trigger another\n// call to flush(), the following steps guard against this:\n// 1. During beforeUpdate, any updated components will be added to the\n//    dirty_components array and will cause a reentrant call to flush(). Because\n//    the flush index is kept outside the function, the reentrant call will pick\n//    up where the earlier call left off and go through all dirty components. The\n//    current_component value is saved and restored so that the reentrant call will\n//    not interfere with the \"parent\" flush() call.\n// 2. bind:this callbacks cannot trigger new flush() calls.\n// 3. During afterUpdate, any updated components will NOT have their afterUpdate\n//    callback called a second time; the seen_callbacks set, outside the flush()\n//    function, guarantees this behavior.\nconst seen_callbacks = new Set();\n\nlet flushidx = 0; // Do *not* move this inside the flush() function\n\n/** @returns {void} */\nexport function flush() {\n\t// Do not reenter flush while dirty components are updated, as this can\n\t// result in an infinite loop. Instead, let the inner flush handle it.\n\t// Reentrancy is ok afterwards for bindings etc.\n\tif (flushidx !== 0) {\n\t\treturn;\n\t}\n\tconst saved_component = current_component;\n\tdo {\n\t\t// first, call beforeUpdate functions\n\t\t// and update components\n\t\ttry {\n\t\t\twhile (flushidx < dirty_components.length) {\n\t\t\t\tconst component = dirty_components[flushidx];\n\t\t\t\tflushidx++;\n\t\t\t\tset_current_component(component);\n\t\t\t\tupdate(component.$$);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t// reset dirty state to not end up in a deadlocked state and then rethrow\n\t\t\tdirty_components.length = 0;\n\t\t\tflushidx = 0;\n\t\t\tthrow e;\n\t\t}\n\t\tset_current_component(null);\n\t\tdirty_components.length = 0;\n\t\tflushidx = 0;\n\t\twhile (binding_callbacks.length) binding_callbacks.pop()();\n\t\t// then, once components are updated, call\n\t\t// afterUpdate functions. This may cause\n\t\t// subsequent updates...\n\t\tfor (let i = 0; i < render_callbacks.length; i += 1) {\n\t\t\tconst callback = render_callbacks[i];\n\t\t\tif (!seen_callbacks.has(callback)) {\n\t\t\t\t// ...so guard against infinite loops\n\t\t\t\tseen_callbacks.add(callback);\n\t\t\t\tcallback();\n\t\t\t}\n\t\t}\n\t\trender_callbacks.length = 0;\n\t} while (dirty_components.length);\n\twhile (flush_callbacks.length) {\n\t\tflush_callbacks.pop()();\n\t}\n\tupdate_scheduled = false;\n\tseen_callbacks.clear();\n\tset_current_component(saved_component);\n}\n\n/** @returns {void} */\nfunction update($$) {\n\tif ($$.fragment !== null) {\n\t\t$$.update();\n\t\trun_all($$.before_update);\n\t\tconst dirty = $$.dirty;\n\t\t$$.dirty = [-1];\n\t\t$$.fragment && $$.fragment.p($$.ctx, dirty);\n\t\t$$.after_update.forEach(add_render_callback);\n\t}\n}\n\n/**\n * Useful for example to execute remaining `afterUpdate` callbacks before executing `destroy`.\n * @param {Function[]} fns\n * @returns {void}\n */\nexport function flush_render_callbacks(fns) {\n\tconst filtered = [];\n\tconst targets = [];\n\trender_callbacks.forEach((c) => (fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c)));\n\ttargets.forEach((c) => c());\n\trender_callbacks = filtered;\n}\n","import { identity as linear, is_function, noop, run_all } from './utils.js';\nimport { now } from './environment.js';\nimport { loop } from './loop.js';\nimport { create_rule, delete_rule } from './style_manager.js';\nimport { custom_event } from './dom.js';\nimport { add_render_callback } from './scheduler.js';\n\n/**\n * @type {Promise<void> | null}\n */\nlet promise;\n\n/**\n * @returns {Promise<void>}\n */\nfunction wait() {\n\tif (!promise) {\n\t\tpromise = Promise.resolve();\n\t\tpromise.then(() => {\n\t\t\tpromise = null;\n\t\t});\n\t}\n\treturn promise;\n}\n\n/**\n * @param {Element} node\n * @param {INTRO | OUTRO | boolean} direction\n * @param {'start' | 'end'} kind\n * @returns {void}\n */\nfunction dispatch(node, direction, kind) {\n\tnode.dispatchEvent(custom_event(`${direction ? 'intro' : 'outro'}${kind}`));\n}\n\nconst outroing = new Set();\n\n/**\n * @type {Outro}\n */\nlet outros;\n\n/**\n * @returns {void} */\nexport function group_outros() {\n\toutros = {\n\t\tr: 0,\n\t\tc: [],\n\t\tp: outros // parent group\n\t};\n}\n\n/**\n * @returns {void} */\nexport function check_outros() {\n\tif (!outros.r) {\n\t\trun_all(outros.c);\n\t}\n\toutros = outros.p;\n}\n\n/**\n * @param {import('./private.js').Fragment} block\n * @param {0 | 1} [local]\n * @returns {void}\n */\nexport function transition_in(block, local) {\n\tif (block && block.i) {\n\t\toutroing.delete(block);\n\t\tblock.i(local);\n\t}\n}\n\n/**\n * @param {import('./private.js').Fragment} block\n * @param {0 | 1} local\n * @param {0 | 1} [detach]\n * @param {() => void} [callback]\n * @returns {void}\n */\nexport function transition_out(block, local, detach, callback) {\n\tif (block && block.o) {\n\t\tif (outroing.has(block)) return;\n\t\toutroing.add(block);\n\t\toutros.c.push(() => {\n\t\t\toutroing.delete(block);\n\t\t\tif (callback) {\n\t\t\t\tif (detach) block.d(1);\n\t\t\t\tcallback();\n\t\t\t}\n\t\t});\n\t\tblock.o(local);\n\t} else if (callback) {\n\t\tcallback();\n\t}\n}\n\n/**\n * @type {import('../transition/public.js').TransitionConfig}\n */\nconst null_transition = { duration: 0 };\n\n/**\n * @param {Element & ElementCSSInlineStyle} node\n * @param {TransitionFn} fn\n * @param {any} params\n * @returns {{ start(): void; invalidate(): void; end(): void; }}\n */\nexport function create_in_transition(node, fn, params) {\n\t/**\n\t * @type {TransitionOptions} */\n\tconst options = { direction: 'in' };\n\tlet config = fn(node, params, options);\n\tlet running = false;\n\tlet animation_name;\n\tlet task;\n\tlet uid = 0;\n\n\t/**\n\t * @returns {void} */\n\tfunction cleanup() {\n\t\tif (animation_name) delete_rule(node, animation_name);\n\t}\n\n\t/**\n\t * @returns {void} */\n\tfunction go() {\n\t\tconst {\n\t\t\tdelay = 0,\n\t\t\tduration = 300,\n\t\t\teasing = linear,\n\t\t\ttick = noop,\n\t\t\tcss\n\t\t} = config || null_transition;\n\t\tif (css) animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++);\n\t\ttick(0, 1);\n\t\tconst start_time = now() + delay;\n\t\tconst end_time = start_time + duration;\n\t\tif (task) task.abort();\n\t\trunning = true;\n\t\tadd_render_callback(() => dispatch(node, true, 'start'));\n\t\ttask = loop((now) => {\n\t\t\tif (running) {\n\t\t\t\tif (now >= end_time) {\n\t\t\t\t\ttick(1, 0);\n\t\t\t\t\tdispatch(node, true, 'end');\n\t\t\t\t\tcleanup();\n\t\t\t\t\treturn (running = false);\n\t\t\t\t}\n\t\t\t\tif (now >= start_time) {\n\t\t\t\t\tconst t = easing((now - start_time) / duration);\n\t\t\t\t\ttick(t, 1 - t);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn running;\n\t\t});\n\t}\n\tlet started = false;\n\treturn {\n\t\tstart() {\n\t\t\tif (started) return;\n\t\t\tstarted = true;\n\t\t\tdelete_rule(node);\n\t\t\tif (is_function(config)) {\n\t\t\t\tconfig = config(options);\n\t\t\t\twait().then(go);\n\t\t\t} else {\n\t\t\t\tgo();\n\t\t\t}\n\t\t},\n\t\tinvalidate() {\n\t\t\tstarted = false;\n\t\t},\n\t\tend() {\n\t\t\tif (running) {\n\t\t\t\tcleanup();\n\t\t\t\trunning = false;\n\t\t\t}\n\t\t}\n\t};\n}\n\n/**\n * @param {Element & ElementCSSInlineStyle} node\n * @param {TransitionFn} fn\n * @param {any} params\n * @returns {{ end(reset: any): void; }}\n */\nexport function create_out_transition(node, fn, params) {\n\t/** @type {TransitionOptions} */\n\tconst options = { direction: 'out' };\n\tlet config = fn(node, params, options);\n\tlet running = true;\n\tlet animation_name;\n\tconst group = outros;\n\tgroup.r += 1;\n\t/** @type {boolean} */\n\tlet original_inert_value;\n\n\t/**\n\t * @returns {void} */\n\tfunction go() {\n\t\tconst {\n\t\t\tdelay = 0,\n\t\t\tduration = 300,\n\t\t\teasing = linear,\n\t\t\ttick = noop,\n\t\t\tcss\n\t\t} = config || null_transition;\n\n\t\tif (css) animation_name = create_rule(node, 1, 0, duration, delay, easing, css);\n\n\t\tconst start_time = now() + delay;\n\t\tconst end_time = start_time + duration;\n\t\tadd_render_callback(() => dispatch(node, false, 'start'));\n\n\t\tif ('inert' in node) {\n\t\t\toriginal_inert_value = /** @type {HTMLElement} */ (node).inert;\n\t\t\tnode.inert = true;\n\t\t}\n\n\t\tloop((now) => {\n\t\t\tif (running) {\n\t\t\t\tif (now >= end_time) {\n\t\t\t\t\ttick(0, 1);\n\t\t\t\t\tdispatch(node, false, 'end');\n\t\t\t\t\tif (!--group.r) {\n\t\t\t\t\t\t// this will result in `end()` being called,\n\t\t\t\t\t\t// so we don't need to clean up here\n\t\t\t\t\t\trun_all(group.c);\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (now >= start_time) {\n\t\t\t\t\tconst t = easing((now - start_time) / duration);\n\t\t\t\t\ttick(1 - t, t);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn running;\n\t\t});\n\t}\n\n\tif (is_function(config)) {\n\t\twait().then(() => {\n\t\t\t// @ts-ignore\n\t\t\tconfig = config(options);\n\t\t\tgo();\n\t\t});\n\t} else {\n\t\tgo();\n\t}\n\n\treturn {\n\t\tend(reset) {\n\t\t\tif (reset && 'inert' in node) {\n\t\t\t\tnode.inert = original_inert_value;\n\t\t\t}\n\t\t\tif (reset && config.tick) {\n\t\t\t\tconfig.tick(1, 0);\n\t\t\t}\n\t\t\tif (running) {\n\t\t\t\tif (animation_name) delete_rule(node, animation_name);\n\t\t\t\trunning = false;\n\t\t\t}\n\t\t}\n\t};\n}\n\n/**\n * @param {Element & ElementCSSInlineStyle} node\n * @param {TransitionFn} fn\n * @param {any} params\n * @param {boolean} intro\n * @returns {{ run(b: 0 | 1): void; end(): void; }}\n */\nexport function create_bidirectional_transition(node, fn, params, intro) {\n\t/**\n\t * @type {TransitionOptions} */\n\tconst options = { direction: 'both' };\n\tlet config = fn(node, params, options);\n\tlet t = intro ? 0 : 1;\n\n\t/**\n\t * @type {Program | null} */\n\tlet running_program = null;\n\n\t/**\n\t * @type {PendingProgram | null} */\n\tlet pending_program = null;\n\tlet animation_name = null;\n\n\t/** @type {boolean} */\n\tlet original_inert_value;\n\n\t/**\n\t * @returns {void} */\n\tfunction clear_animation() {\n\t\tif (animation_name) delete_rule(node, animation_name);\n\t}\n\n\t/**\n\t * @param {PendingProgram} program\n\t * @param {number} duration\n\t * @returns {Program}\n\t */\n\tfunction init(program, duration) {\n\t\tconst d = /** @type {Program['d']} */ (program.b - t);\n\t\tduration *= Math.abs(d);\n\t\treturn {\n\t\t\ta: t,\n\t\t\tb: program.b,\n\t\t\td,\n\t\t\tduration,\n\t\t\tstart: program.start,\n\t\t\tend: program.start + duration,\n\t\t\tgroup: program.group\n\t\t};\n\t}\n\n\t/**\n\t * @param {INTRO | OUTRO} b\n\t * @returns {void}\n\t */\n\tfunction go(b) {\n\t\tconst {\n\t\t\tdelay = 0,\n\t\t\tduration = 300,\n\t\t\teasing = linear,\n\t\t\ttick = noop,\n\t\t\tcss\n\t\t} = config || null_transition;\n\n\t\t/**\n\t\t * @type {PendingProgram} */\n\t\tconst program = {\n\t\t\tstart: now() + delay,\n\t\t\tb\n\t\t};\n\n\t\tif (!b) {\n\t\t\t// @ts-ignore todo: improve typings\n\t\t\tprogram.group = outros;\n\t\t\toutros.r += 1;\n\t\t}\n\n\t\tif ('inert' in node) {\n\t\t\tif (b) {\n\t\t\t\tif (original_inert_value !== undefined) {\n\t\t\t\t\t// aborted/reversed outro — restore previous inert value\n\t\t\t\t\tnode.inert = original_inert_value;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\toriginal_inert_value = /** @type {HTMLElement} */ (node).inert;\n\t\t\t\tnode.inert = true;\n\t\t\t}\n\t\t}\n\n\t\tif (running_program || pending_program) {\n\t\t\tpending_program = program;\n\t\t} else {\n\t\t\t// if this is an intro, and there's a delay, we need to do\n\t\t\t// an initial tick and/or apply CSS animation immediately\n\t\t\tif (css) {\n\t\t\t\tclear_animation();\n\t\t\t\tanimation_name = create_rule(node, t, b, duration, delay, easing, css);\n\t\t\t}\n\t\t\tif (b) tick(0, 1);\n\t\t\trunning_program = init(program, duration);\n\t\t\tadd_render_callback(() => dispatch(node, b, 'start'));\n\t\t\tloop((now) => {\n\t\t\t\tif (pending_program && now > pending_program.start) {\n\t\t\t\t\trunning_program = init(pending_program, duration);\n\t\t\t\t\tpending_program = null;\n\t\t\t\t\tdispatch(node, running_program.b, 'start');\n\t\t\t\t\tif (css) {\n\t\t\t\t\t\tclear_animation();\n\t\t\t\t\t\tanimation_name = create_rule(\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tt,\n\t\t\t\t\t\t\trunning_program.b,\n\t\t\t\t\t\t\trunning_program.duration,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\teasing,\n\t\t\t\t\t\t\tconfig.css\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (running_program) {\n\t\t\t\t\tif (now >= running_program.end) {\n\t\t\t\t\t\ttick((t = running_program.b), 1 - t);\n\t\t\t\t\t\tdispatch(node, running_program.b, 'end');\n\t\t\t\t\t\tif (!pending_program) {\n\t\t\t\t\t\t\t// we're done\n\t\t\t\t\t\t\tif (running_program.b) {\n\t\t\t\t\t\t\t\t// intro — we can tidy up immediately\n\t\t\t\t\t\t\t\tclear_animation();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// outro — needs to be coordinated\n\t\t\t\t\t\t\t\tif (!--running_program.group.r) run_all(running_program.group.c);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\trunning_program = null;\n\t\t\t\t\t} else if (now >= running_program.start) {\n\t\t\t\t\t\tconst p = now - running_program.start;\n\t\t\t\t\t\tt = running_program.a + running_program.d * easing(p / running_program.duration);\n\t\t\t\t\t\ttick(t, 1 - t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn !!(running_program || pending_program);\n\t\t\t});\n\t\t}\n\t}\n\treturn {\n\t\trun(b) {\n\t\t\tif (is_function(config)) {\n\t\t\t\twait().then(() => {\n\t\t\t\t\tconst opts = { direction: b ? 'in' : 'out' };\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tconfig = config(opts);\n\t\t\t\t\tgo(b);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tgo(b);\n\t\t\t}\n\t\t},\n\t\tend() {\n\t\t\tclear_animation();\n\t\t\trunning_program = pending_program = null;\n\t\t}\n\t};\n}\n\n/** @typedef {1} INTRO */\n/** @typedef {0} OUTRO */\n/** @typedef {{ direction: 'in' | 'out' | 'both' }} TransitionOptions */\n/** @typedef {(node: Element, params: any, options: TransitionOptions) => import('../transition/public.js').TransitionConfig} TransitionFn */\n\n/**\n * @typedef {Object} Outro\n * @property {number} r\n * @property {Function[]} c\n * @property {Object} p\n */\n\n/**\n * @typedef {Object} PendingProgram\n * @property {number} start\n * @property {INTRO|OUTRO} b\n * @property {Outro} [group]\n */\n\n/**\n * @typedef {Object} Program\n * @property {number} a\n * @property {INTRO|OUTRO} b\n * @property {1|-1} d\n * @property {number} duration\n * @property {number} start\n * @property {number} end\n * @property {Outro} [group]\n */\n","import { transition_in, transition_out } from './transitions.js';\nimport { run_all } from './utils.js';\n\n// general each functions:\n\nexport function ensure_array_like(array_like_or_iterator) {\n\treturn array_like_or_iterator?.length !== undefined\n\t\t? array_like_or_iterator\n\t\t: Array.from(array_like_or_iterator);\n}\n\n// keyed each functions:\n\n/** @returns {void} */\nexport function destroy_block(block, lookup) {\n\tblock.d(1);\n\tlookup.delete(block.key);\n}\n\n/** @returns {void} */\nexport function outro_and_destroy_block(block, lookup) {\n\ttransition_out(block, 1, 1, () => {\n\t\tlookup.delete(block.key);\n\t});\n}\n\n/** @returns {void} */\nexport function fix_and_destroy_block(block, lookup) {\n\tblock.f();\n\tdestroy_block(block, lookup);\n}\n\n/** @returns {void} */\nexport function fix_and_outro_and_destroy_block(block, lookup) {\n\tblock.f();\n\toutro_and_destroy_block(block, lookup);\n}\n\n/** @returns {any[]} */\nexport function update_keyed_each(\n\told_blocks,\n\tdirty,\n\tget_key,\n\tdynamic,\n\tctx,\n\tlist,\n\tlookup,\n\tnode,\n\tdestroy,\n\tcreate_each_block,\n\tnext,\n\tget_context\n) {\n\tlet o = old_blocks.length;\n\tlet n = list.length;\n\tlet i = o;\n\tconst old_indexes = {};\n\twhile (i--) old_indexes[old_blocks[i].key] = i;\n\tconst new_blocks = [];\n\tconst new_lookup = new Map();\n\tconst deltas = new Map();\n\tconst updates = [];\n\ti = n;\n\twhile (i--) {\n\t\tconst child_ctx = get_context(ctx, list, i);\n\t\tconst key = get_key(child_ctx);\n\t\tlet block = lookup.get(key);\n\t\tif (!block) {\n\t\t\tblock = create_each_block(key, child_ctx);\n\t\t\tblock.c();\n\t\t} else if (dynamic) {\n\t\t\t// defer updates until all the DOM shuffling is done\n\t\t\tupdates.push(() => block.p(child_ctx, dirty));\n\t\t}\n\t\tnew_lookup.set(key, (new_blocks[i] = block));\n\t\tif (key in old_indexes) deltas.set(key, Math.abs(i - old_indexes[key]));\n\t}\n\tconst will_move = new Set();\n\tconst did_move = new Set();\n\t/** @returns {void} */\n\tfunction insert(block) {\n\t\ttransition_in(block, 1);\n\t\tblock.m(node, next);\n\t\tlookup.set(block.key, block);\n\t\tnext = block.first;\n\t\tn--;\n\t}\n\twhile (o && n) {\n\t\tconst new_block = new_blocks[n - 1];\n\t\tconst old_block = old_blocks[o - 1];\n\t\tconst new_key = new_block.key;\n\t\tconst old_key = old_block.key;\n\t\tif (new_block === old_block) {\n\t\t\t// do nothing\n\t\t\tnext = new_block.first;\n\t\t\to--;\n\t\t\tn--;\n\t\t} else if (!new_lookup.has(old_key)) {\n\t\t\t// remove old block\n\t\t\tdestroy(old_block, lookup);\n\t\t\to--;\n\t\t} else if (!lookup.has(new_key) || will_move.has(new_key)) {\n\t\t\tinsert(new_block);\n\t\t} else if (did_move.has(old_key)) {\n\t\t\to--;\n\t\t} else if (deltas.get(new_key) > deltas.get(old_key)) {\n\t\t\tdid_move.add(new_key);\n\t\t\tinsert(new_block);\n\t\t} else {\n\t\t\twill_move.add(old_key);\n\t\t\to--;\n\t\t}\n\t}\n\twhile (o--) {\n\t\tconst old_block = old_blocks[o];\n\t\tif (!new_lookup.has(old_block.key)) destroy(old_block, lookup);\n\t}\n\twhile (n) insert(new_blocks[n - 1]);\n\trun_all(updates);\n\treturn new_blocks;\n}\n\n/** @returns {void} */\nexport function validate_each_keys(ctx, list, get_context, get_key) {\n\tconst keys = new Map();\n\tfor (let i = 0; i < list.length; i++) {\n\t\tconst key = get_key(get_context(ctx, list, i));\n\t\tif (keys.has(key)) {\n\t\t\tlet value = '';\n\t\t\ttry {\n\t\t\t\tvalue = `with value '${String(key)}' `;\n\t\t\t} catch (e) {\n\t\t\t\t// can't stringify\n\t\t\t}\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot have duplicate keys in a keyed each: Keys at index ${keys.get(\n\t\t\t\t\tkey\n\t\t\t\t)} and ${i} ${value}are duplicates`\n\t\t\t);\n\t\t}\n\t\tkeys.set(key, i);\n\t}\n}\n","import {\n\tadd_render_callback,\n\tflush,\n\tflush_render_callbacks,\n\tschedule_update,\n\tdirty_components\n} from './scheduler.js';\nimport { current_component, set_current_component } from './lifecycle.js';\nimport { blank_object, is_empty, is_function, run, run_all, noop } from './utils.js';\nimport {\n\tchildren,\n\tdetach,\n\tstart_hydrating,\n\tend_hydrating,\n\tget_custom_elements_slots,\n\tinsert,\n\telement,\n\tattr\n} from './dom.js';\nimport { transition_in } from './transitions.js';\n\n/** @returns {void} */\nexport function bind(component, name, callback) {\n\tconst index = component.$$.props[name];\n\tif (index !== undefined) {\n\t\tcomponent.$$.bound[index] = callback;\n\t\tcallback(component.$$.ctx[index]);\n\t}\n}\n\n/** @returns {void} */\nexport function create_component(block) {\n\tblock && block.c();\n}\n\n/** @returns {void} */\nexport function claim_component(block, parent_nodes) {\n\tblock && block.l(parent_nodes);\n}\n\n/** @returns {void} */\nexport function mount_component(component, target, anchor) {\n\tconst { fragment, after_update } = component.$$;\n\tfragment && fragment.m(target, anchor);\n\t// onMount happens before the initial afterUpdate\n\tadd_render_callback(() => {\n\t\tconst new_on_destroy = component.$$.on_mount.map(run).filter(is_function);\n\t\t// if the component was destroyed immediately\n\t\t// it will update the `$$.on_destroy` reference to `null`.\n\t\t// the destructured on_destroy may still reference to the old array\n\t\tif (component.$$.on_destroy) {\n\t\t\tcomponent.$$.on_destroy.push(...new_on_destroy);\n\t\t} else {\n\t\t\t// Edge case - component was destroyed immediately,\n\t\t\t// most likely as a result of a binding initialising\n\t\t\trun_all(new_on_destroy);\n\t\t}\n\t\tcomponent.$$.on_mount = [];\n\t});\n\tafter_update.forEach(add_render_callback);\n}\n\n/** @returns {void} */\nexport function destroy_component(component, detaching) {\n\tconst $$ = component.$$;\n\tif ($$.fragment !== null) {\n\t\tflush_render_callbacks($$.after_update);\n\t\trun_all($$.on_destroy);\n\t\t$$.fragment && $$.fragment.d(detaching);\n\t\t// TODO null out other refs, including component.$$ (but need to\n\t\t// preserve final state?)\n\t\t$$.on_destroy = $$.fragment = null;\n\t\t$$.ctx = [];\n\t}\n}\n\n/** @returns {void} */\nfunction make_dirty(component, i) {\n\tif (component.$$.dirty[0] === -1) {\n\t\tdirty_components.push(component);\n\t\tschedule_update();\n\t\tcomponent.$$.dirty.fill(0);\n\t}\n\tcomponent.$$.dirty[(i / 31) | 0] |= 1 << i % 31;\n}\n\n// TODO: Document the other params\n/**\n * @param {SvelteComponent} component\n * @param {import('./public.js').ComponentConstructorOptions} options\n *\n * @param {import('./utils.js')['not_equal']} not_equal Used to compare props and state values.\n * @param {(target: Element | ShadowRoot) => void} [append_styles] Function that appends styles to the DOM when the component is first initialised.\n * This will be the `add_css` function from the compiled component.\n *\n * @returns {void}\n */\nexport function init(\n\tcomponent,\n\toptions,\n\tinstance,\n\tcreate_fragment,\n\tnot_equal,\n\tprops,\n\tappend_styles = null,\n\tdirty = [-1]\n) {\n\tconst parent_component = current_component;\n\tset_current_component(component);\n\t/** @type {import('./private.js').T$$} */\n\tconst $$ = (component.$$ = {\n\t\tfragment: null,\n\t\tctx: [],\n\t\t// state\n\t\tprops,\n\t\tupdate: noop,\n\t\tnot_equal,\n\t\tbound: blank_object(),\n\t\t// lifecycle\n\t\ton_mount: [],\n\t\ton_destroy: [],\n\t\ton_disconnect: [],\n\t\tbefore_update: [],\n\t\tafter_update: [],\n\t\tcontext: new Map(options.context || (parent_component ? parent_component.$$.context : [])),\n\t\t// everything else\n\t\tcallbacks: blank_object(),\n\t\tdirty,\n\t\tskip_bound: false,\n\t\troot: options.target || parent_component.$$.root\n\t});\n\tappend_styles && append_styles($$.root);\n\tlet ready = false;\n\t$$.ctx = instance\n\t\t? instance(component, options.props || {}, (i, ret, ...rest) => {\n\t\t\t\tconst value = rest.length ? rest[0] : ret;\n\t\t\t\tif ($$.ctx && not_equal($$.ctx[i], ($$.ctx[i] = value))) {\n\t\t\t\t\tif (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);\n\t\t\t\t\tif (ready) make_dirty(component, i);\n\t\t\t\t}\n\t\t\t\treturn ret;\n\t\t  })\n\t\t: [];\n\t$$.update();\n\tready = true;\n\trun_all($$.before_update);\n\t// `false` as a special case of no DOM component\n\t$$.fragment = create_fragment ? create_fragment($$.ctx) : false;\n\tif (options.target) {\n\t\tif (options.hydrate) {\n\t\t\tstart_hydrating();\n\t\t\t// TODO: what is the correct type here?\n\t\t\t// @ts-expect-error\n\t\t\tconst nodes = children(options.target);\n\t\t\t$$.fragment && $$.fragment.l(nodes);\n\t\t\tnodes.forEach(detach);\n\t\t} else {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t$$.fragment && $$.fragment.c();\n\t\t}\n\t\tif (options.intro) transition_in(component.$$.fragment);\n\t\tmount_component(component, options.target, options.anchor);\n\t\tend_hydrating();\n\t\tflush();\n\t}\n\tset_current_component(parent_component);\n}\n\nexport let SvelteElement;\n\nif (typeof HTMLElement === 'function') {\n\tSvelteElement = class extends HTMLElement {\n\t\t/** The Svelte component constructor */\n\t\t$$ctor;\n\t\t/** Slots */\n\t\t$$s;\n\t\t/** The Svelte component instance */\n\t\t$$c;\n\t\t/** Whether or not the custom element is connected */\n\t\t$$cn = false;\n\t\t/** Component props data */\n\t\t$$d = {};\n\t\t/** `true` if currently in the process of reflecting component props back to attributes */\n\t\t$$r = false;\n\t\t/** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */\n\t\t$$p_d = {};\n\t\t/** @type {Record<string, Function[]>} Event listeners */\n\t\t$$l = {};\n\t\t/** @type {Map<Function, Function>} Event listener unsubscribe functions */\n\t\t$$l_u = new Map();\n\n\t\tconstructor($$componentCtor, $$slots, use_shadow_dom) {\n\t\t\tsuper();\n\t\t\tthis.$$ctor = $$componentCtor;\n\t\t\tthis.$$s = $$slots;\n\t\t\tif (use_shadow_dom) {\n\t\t\t\tthis.attachShadow({ mode: 'open' });\n\t\t\t}\n\t\t}\n\n\t\taddEventListener(type, listener, options) {\n\t\t\t// We can't determine upfront if the event is a custom event or not, so we have to\n\t\t\t// listen to both. If someone uses a custom event with the same name as a regular\n\t\t\t// browser event, this fires twice - we can't avoid that.\n\t\t\tthis.$$l[type] = this.$$l[type] || [];\n\t\t\tthis.$$l[type].push(listener);\n\t\t\tif (this.$$c) {\n\t\t\t\tconst unsub = this.$$c.$on(type, listener);\n\t\t\t\tthis.$$l_u.set(listener, unsub);\n\t\t\t}\n\t\t\tsuper.addEventListener(type, listener, options);\n\t\t}\n\n\t\tremoveEventListener(type, listener, options) {\n\t\t\tsuper.removeEventListener(type, listener, options);\n\t\t\tif (this.$$c) {\n\t\t\t\tconst unsub = this.$$l_u.get(listener);\n\t\t\t\tif (unsub) {\n\t\t\t\t\tunsub();\n\t\t\t\t\tthis.$$l_u.delete(listener);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tasync connectedCallback() {\n\t\t\tthis.$$cn = true;\n\t\t\tif (!this.$$c) {\n\t\t\t\t// We wait one tick to let possible child slot elements be created/mounted\n\t\t\t\tawait Promise.resolve();\n\t\t\t\tif (!this.$$cn || this.$$c) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfunction create_slot(name) {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tlet node;\n\t\t\t\t\t\tconst obj = {\n\t\t\t\t\t\t\tc: function create() {\n\t\t\t\t\t\t\t\tnode = element('slot');\n\t\t\t\t\t\t\t\tif (name !== 'default') {\n\t\t\t\t\t\t\t\t\tattr(node, 'name', name);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * @param {HTMLElement} target\n\t\t\t\t\t\t\t * @param {HTMLElement} [anchor]\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tm: function mount(target, anchor) {\n\t\t\t\t\t\t\t\tinsert(target, node, anchor);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\td: function destroy(detaching) {\n\t\t\t\t\t\t\t\tif (detaching) {\n\t\t\t\t\t\t\t\t\tdetach(node);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn obj;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tconst $$slots = {};\n\t\t\t\tconst existing_slots = get_custom_elements_slots(this);\n\t\t\t\tfor (const name of this.$$s) {\n\t\t\t\t\tif (name in existing_slots) {\n\t\t\t\t\t\t$$slots[name] = [create_slot(name)];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const attribute of this.attributes) {\n\t\t\t\t\t// this.$$data takes precedence over this.attributes\n\t\t\t\t\tconst name = this.$$g_p(attribute.name);\n\t\t\t\t\tif (!(name in this.$$d)) {\n\t\t\t\t\t\tthis.$$d[name] = get_custom_element_value(name, attribute.value, this.$$p_d, 'toProp');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Port over props that were set programmatically before ce was initialized\n\t\t\t\tfor (const key in this.$$p_d) {\n\t\t\t\t\tif (!(key in this.$$d) && this[key] !== undefined) {\n\t\t\t\t\t\tthis.$$d[key] = this[key]; // don't transform, these were set through JavaScript\n\t\t\t\t\t\tdelete this[key]; // remove the property that shadows the getter/setter\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.$$c = new this.$$ctor({\n\t\t\t\t\ttarget: this.shadowRoot || this,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...this.$$d,\n\t\t\t\t\t\t$$slots,\n\t\t\t\t\t\t$$scope: {\n\t\t\t\t\t\t\tctx: []\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t// Reflect component props as attributes\n\t\t\t\tconst reflect_attributes = () => {\n\t\t\t\t\tthis.$$r = true;\n\t\t\t\t\tfor (const key in this.$$p_d) {\n\t\t\t\t\t\tthis.$$d[key] = this.$$c.$$.ctx[this.$$c.$$.props[key]];\n\t\t\t\t\t\tif (this.$$p_d[key].reflect) {\n\t\t\t\t\t\t\tconst attribute_value = get_custom_element_value(\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tthis.$$d[key],\n\t\t\t\t\t\t\t\tthis.$$p_d,\n\t\t\t\t\t\t\t\t'toAttribute'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (attribute_value == null) {\n\t\t\t\t\t\t\t\tthis.removeAttribute(this.$$p_d[key].attribute || key);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.setAttribute(this.$$p_d[key].attribute || key, attribute_value);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis.$$r = false;\n\t\t\t\t};\n\t\t\t\tthis.$$c.$$.after_update.push(reflect_attributes);\n\t\t\t\treflect_attributes(); // once initially because after_update is added too late for first render\n\n\t\t\t\tfor (const type in this.$$l) {\n\t\t\t\t\tfor (const listener of this.$$l[type]) {\n\t\t\t\t\t\tconst unsub = this.$$c.$on(type, listener);\n\t\t\t\t\t\tthis.$$l_u.set(listener, unsub);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.$$l = {};\n\t\t\t}\n\t\t}\n\n\t\t// We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte\n\t\t// and setting attributes through setAttribute etc, this is helpful\n\t\tattributeChangedCallback(attr, _oldValue, newValue) {\n\t\t\tif (this.$$r) return;\n\t\t\tattr = this.$$g_p(attr);\n\t\t\tthis.$$d[attr] = get_custom_element_value(attr, newValue, this.$$p_d, 'toProp');\n\t\t\tthis.$$c?.$set({ [attr]: this.$$d[attr] });\n\t\t}\n\n\t\tdisconnectedCallback() {\n\t\t\tthis.$$cn = false;\n\t\t\t// In a microtask, because this could be a move within the DOM\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tif (!this.$$cn && this.$$c) {\n\t\t\t\t\tthis.$$c.$destroy();\n\t\t\t\t\tthis.$$c = undefined;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t$$g_p(attribute_name) {\n\t\t\treturn (\n\t\t\t\tObject.keys(this.$$p_d).find(\n\t\t\t\t\t(key) =>\n\t\t\t\t\t\tthis.$$p_d[key].attribute === attribute_name ||\n\t\t\t\t\t\t(!this.$$p_d[key].attribute && key.toLowerCase() === attribute_name)\n\t\t\t\t) || attribute_name\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * @param {string} prop\n * @param {any} value\n * @param {Record<string, CustomElementPropDefinition>} props_definition\n * @param {'toAttribute' | 'toProp'} [transform]\n */\nfunction get_custom_element_value(prop, value, props_definition, transform) {\n\tconst type = props_definition[prop]?.type;\n\tvalue = type === 'Boolean' && typeof value !== 'boolean' ? value != null : value;\n\tif (!transform || !props_definition[prop]) {\n\t\treturn value;\n\t} else if (transform === 'toAttribute') {\n\t\tswitch (type) {\n\t\t\tcase 'Object':\n\t\t\tcase 'Array':\n\t\t\t\treturn value == null ? null : JSON.stringify(value);\n\t\t\tcase 'Boolean':\n\t\t\t\treturn value ? '' : null;\n\t\t\tcase 'Number':\n\t\t\t\treturn value == null ? null : value;\n\t\t\tdefault:\n\t\t\t\treturn value;\n\t\t}\n\t} else {\n\t\tswitch (type) {\n\t\t\tcase 'Object':\n\t\t\tcase 'Array':\n\t\t\t\treturn value && JSON.parse(value);\n\t\t\tcase 'Boolean':\n\t\t\t\treturn value; // conversion already handled above\n\t\t\tcase 'Number':\n\t\t\t\treturn value != null ? +value : value;\n\t\t\tdefault:\n\t\t\t\treturn value;\n\t\t}\n\t}\n}\n\n/**\n * @internal\n *\n * Turn a Svelte component into a custom element.\n * @param {import('./public.js').ComponentType} Component  A Svelte component constructor\n * @param {Record<string, CustomElementPropDefinition>} props_definition  The props to observe\n * @param {string[]} slots  The slots to create\n * @param {string[]} accessors  Other accessors besides the ones for props the component has\n * @param {boolean} use_shadow_dom  Whether to use shadow DOM\n * @param {(ce: new () => HTMLElement) => new () => HTMLElement} [extend]\n */\nexport function create_custom_element(\n\tComponent,\n\tprops_definition,\n\tslots,\n\taccessors,\n\tuse_shadow_dom,\n\textend\n) {\n\tlet Class = class extends SvelteElement {\n\t\tconstructor() {\n\t\t\tsuper(Component, slots, use_shadow_dom);\n\t\t\tthis.$$p_d = props_definition;\n\t\t}\n\t\tstatic get observedAttributes() {\n\t\t\treturn Object.keys(props_definition).map((key) =>\n\t\t\t\t(props_definition[key].attribute || key).toLowerCase()\n\t\t\t);\n\t\t}\n\t};\n\tObject.keys(props_definition).forEach((prop) => {\n\t\tObject.defineProperty(Class.prototype, prop, {\n\t\t\tget() {\n\t\t\t\treturn this.$$c && prop in this.$$c ? this.$$c[prop] : this.$$d[prop];\n\t\t\t},\n\t\t\tset(value) {\n\t\t\t\tvalue = get_custom_element_value(prop, value, props_definition);\n\t\t\t\tthis.$$d[prop] = value;\n\t\t\t\tthis.$$c?.$set({ [prop]: value });\n\t\t\t}\n\t\t});\n\t});\n\taccessors.forEach((accessor) => {\n\t\tObject.defineProperty(Class.prototype, accessor, {\n\t\t\tget() {\n\t\t\t\treturn this.$$c?.[accessor];\n\t\t\t}\n\t\t});\n\t});\n\tif (extend) {\n\t\t// @ts-expect-error - assigning here is fine\n\t\tClass = extend(Class);\n\t}\n\tComponent.element = /** @type {any} */ (Class);\n\treturn Class;\n}\n\n/**\n * Base class for Svelte components. Used when dev=false.\n *\n * @template {Record<string, any>} [Props=any]\n * @template {Record<string, any>} [Events=any]\n */\nexport class SvelteComponent {\n\t/**\n\t * ### PRIVATE API\n\t *\n\t * Do not use, may change at any time\n\t *\n\t * @type {any}\n\t */\n\t$$ = undefined;\n\t/**\n\t * ### PRIVATE API\n\t *\n\t * Do not use, may change at any time\n\t *\n\t * @type {any}\n\t */\n\t$$set = undefined;\n\n\t/** @returns {void} */\n\t$destroy() {\n\t\tdestroy_component(this, 1);\n\t\tthis.$destroy = noop;\n\t}\n\n\t/**\n\t * @template {Extract<keyof Events, string>} K\n\t * @param {K} type\n\t * @param {((e: Events[K]) => void) | null | undefined} callback\n\t * @returns {() => void}\n\t */\n\t$on(type, callback) {\n\t\tif (!is_function(callback)) {\n\t\t\treturn noop;\n\t\t}\n\t\tconst callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);\n\t\tcallbacks.push(callback);\n\t\treturn () => {\n\t\t\tconst index = callbacks.indexOf(callback);\n\t\t\tif (index !== -1) callbacks.splice(index, 1);\n\t\t};\n\t}\n\n\t/**\n\t * @param {Partial<Props>} props\n\t * @returns {void}\n\t */\n\t$set(props) {\n\t\tif (this.$$set && !is_empty(props)) {\n\t\t\tthis.$$.skip_bound = true;\n\t\t\tthis.$$set(props);\n\t\t\tthis.$$.skip_bound = false;\n\t\t}\n\t}\n}\n\n/**\n * @typedef {Object} CustomElementPropDefinition\n * @property {string} [attribute]\n * @property {boolean} [reflect]\n * @property {'String'|'Boolean'|'Number'|'Array'|'Object'} [type]\n */\n","// generated during release, do not modify\n\n/**\n * The current version, as set in package.json.\n *\n * https://svelte.dev/docs/svelte-compiler#svelte-version\n * @type {string}\n */\nexport const VERSION = '4.2.19';\nexport const PUBLIC_VERSION = '4';\n","import { PUBLIC_VERSION } from '../../../shared/version.js';\n\nif (typeof window !== 'undefined')\n\t// @ts-ignore\n\t(window.__svelte || (window.__svelte = { v: new Set() })).v.add(PUBLIC_VERSION);\n","<script lang=\"ts\">\n  import type MapLibreGlDirections from \"../../directions/main\";\n  import type { LoadingIndicatorControlConfiguration } from \"./types\";\n\n  export let directions: MapLibreGlDirections;\n  export let configuration: LoadingIndicatorControlConfiguration;\n\n  let loading: boolean;\n\n  directions.on(\"fetchroutesstart\", () => {\n    loading = true;\n  });\n\n  directions.on(\"fetchroutesend\", () => {\n    loading = false;\n  });\n</script>\n\n{#if loading}\n  <svg\n    xmlns=\"http://www.w3.org/2000/svg\"\n    width={configuration.size}\n    height={configuration.size}\n    viewBox=\"0 0 128 128\"\n    xml:space=\"preserve\"\n    class={configuration.class}\n  >\n    <circle cx=\"64.13\" cy=\"64.13\" r=\"27.63\" fill={configuration.fill} />\n    <path\n      d=\"M64.13 18.5A45.63 45.63 0 1 1 18.5 64.13 45.63 45.63 0 0 1 64.13 18.5zm0 7.85a37.78 37.78 0 1 1-37.78 37.78 37.78 37.78 0 0 1 37.78-37.78z\"\n      fill-rule=\"evenodd\"\n      fill={configuration.fill}\n    />\n    <g>\n      <path d=\"M95.25 17.4a56.26 56.26 0 0 0-76.8 13.23L12.1 26.2a64 64 0 0 1 87.6-15.17z\" fill={configuration.fill} />\n      <path\n        d=\"M95.25 17.4a56.26 56.26 0 0 0-76.8 13.23L12.1 26.2a64 64 0 0 1 87.6-15.17z\"\n        fill={configuration.fill}\n        transform=\"rotate(120 64 64)\"\n      />\n      <path\n        d=\"M95.25 17.4a56.26 56.26 0 0 0-76.8 13.23L12.1 26.2a64 64 0 0 1 87.6-15.17z\"\n        fill={configuration.fill}\n        transform=\"rotate(240 64 64)\"\n      />\n      <animateTransform\n        attributeName=\"transform\"\n        type=\"rotate\"\n        from=\"0 64 64\"\n        to=\"120 64 64\"\n        dur=\"360ms\"\n        repeatCount=\"indefinite\"\n      />\n    </g>\n  </svg>\n{/if}\n","export interface LoadingIndicatorControlConfiguration {\n  /**\n   * Fill-color for the loader. Any valid CSS-value.\n   *\n   * @default \"#6d26d7\"\n   */\n  fill: string;\n\n  /**\n   * The size of the loader. Any valid CSS-value.\n   *\n   * @default \"24px\"\n   */\n  size: string;\n\n  /**\n   * Class-string passed as-is to the `class=\"\"` attribute of the loader SVG.\n   *\n   * @default \"\"\n   */\n  class: string;\n}\n\nexport const LoadingIndicatorControlDefaultConfiguration: LoadingIndicatorControlConfiguration = {\n  fill: \"#6d26d7\",\n  size: \"24px\",\n  class: \"\",\n};\n","import type { IControl } from \"maplibre-gl\";\nimport LoadingIndicatorControlComponent from \"./LoadingIndicatorControl.svelte\";\nimport { LoadingIndicatorControlDefaultConfiguration } from \"./types\";\nimport type { LoadingIndicatorControlConfiguration } from \"./types\";\nimport type MapLibreGlDirections from \"../../directions/main\";\n\n/**\n * Creates an instance of LoadingControl that could be added to the map using the\n * {@link https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addcontrol|`addControl`} method.\n *\n * @example\n * ```typescript\n * import MapLibreGlDirections, { LoadingControl } from \"@maplibre/maplibre-gl-directions\";\n * map.addControl(new LoadingControl(new MapLibreGlDirections(map)));\n * ```\n */\nexport default class LoadingControl implements IControl {\n  constructor(directions: MapLibreGlDirections, configuration?: Partial<LoadingIndicatorControlConfiguration>) {\n    this.directions = directions;\n    this.configuration = Object.assign({}, LoadingIndicatorControlDefaultConfiguration, configuration);\n  }\n\n  private controlElement!: HTMLElement;\n  private readonly directions: MapLibreGlDirections;\n  private readonly configuration: LoadingIndicatorControlConfiguration;\n\n  /**\n   * @private\n   */\n  onAdd() {\n    this.controlElement = document.createElement(\"div\");\n\n    new LoadingIndicatorControlComponent({\n      target: this.controlElement,\n      props: {\n        directions: this.directions,\n        configuration: this.configuration,\n      },\n    });\n\n    return this.controlElement;\n  }\n\n  /**\n   * @private\n   */\n  onRemove() {\n    this.controlElement.remove();\n  }\n}\n","<script lang=\"ts\">\n  import { onDestroy } from \"svelte\";\n  import type { Map } from \"maplibre-gl\";\n  import type MapLibreGlDirections from \"../../directions/main\";\n  import type { BearingsControlConfiguration } from \"./types\";\n\n  export let directions: MapLibreGlDirections;\n  export let configuration: BearingsControlConfiguration;\n\n  // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n  // @ts-ignore\n  if (!directions.configuration.bearings) {\n    console.warn(\"The Bearings Control is used, but the `bearings` configuration option is not enabled!\");\n  }\n\n  let waypointsBearings: {\n    enabled: boolean;\n    angle: number;\n    degrees: number;\n  }[] = [];\n\n  directions.on(\"addwaypoint\", onWaypointsChanged);\n  directions.on(\"removewaypoint\", onWaypointsChanged);\n  directions.on(\"movewaypoint\", onWaypointsChanged);\n  directions.on(\"setwaypoints\", onWaypointsChanged);\n\n  function onWaypointsChanged() {\n    waypointsBearings = directions.waypointsBearings.map((waypointBearing, index) => {\n      if (waypointsBearings[index]) return waypointsBearings[index];\n\n      return {\n        enabled: configuration.defaultEnabled || !!waypointBearing,\n        angle: waypointBearing ? waypointBearing[0] : configuration.angleDefault,\n        degrees: waypointBearing\n          ? waypointBearing[1]\n          : configuration.fixedDegrees\n            ? configuration.fixedDegrees\n            : configuration.degreesDefault,\n      };\n    });\n  }\n\n  onWaypointsChanged();\n\n  let timeout: number | undefined;\n\n  $: {\n    // update the directions' value with simple debouncing to avoid `fetchDirections` spamming\n    if (timeout) clearTimeout(timeout);\n\n    timeout = setTimeout(() => {\n      directions.waypointsBearings = waypointsBearings.map((waypointBearing) => {\n        return waypointBearing.enabled ? [waypointBearing.angle, waypointBearing.degrees] : undefined;\n      });\n    }, configuration.debounceTimeout);\n  }\n\n  const images = [] as (HTMLDivElement | null)[];\n  let imageBeingRotatedIndex = -1;\n\n  function onImageMousedown(event: MouseEvent, i: number) {\n    if (!waypointsBearings[i]?.enabled) return;\n\n    imageBeingRotatedIndex = i;\n\n    document.addEventListener(\"mouseup\", onDocumentMouseup);\n    document.addEventListener(\"mousemove\", onDocumentMousemove);\n  }\n\n  function onDocumentMouseup() {\n    imageBeingRotatedIndex = -1;\n\n    document.removeEventListener(\"mouseup\", onDocumentMouseup);\n    document.removeEventListener(\"mousemove\", onDocumentMousemove);\n  }\n\n  function onDocumentMousemove(e: MouseEvent) {\n    const image = images[imageBeingRotatedIndex];\n    if (image) {\n      const centerX = image.getBoundingClientRect().x + configuration.imageSize / 2;\n      const centerY = image.getBoundingClientRect().y + configuration.imageSize / 2;\n\n      const mouse_x = e.pageX;\n      const mouse_y = e.pageY;\n\n      const radians = Math.atan2(mouse_x - centerX, mouse_y - centerY);\n      const angle = radians * (180 / Math.PI) * -1 + 90;\n\n      waypointsBearings[imageBeingRotatedIndex].angle = (90 + angle + angleAdjustment) | 0;\n    }\n  }\n\n  onDestroy(() => {\n    document.removeEventListener(\"mouseup\", onDocumentMouseup);\n    document.removeEventListener(\"mousemove\", onDocumentMousemove);\n  });\n\n  let angleAdjustment = 0;\n\n  // adjust the angle of control's waypoints based on the map's current bearing\n  if (configuration.respectMapBearing) {\n    // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n    // @ts-ignore\n    (directions.map as Map).on(\"rotate\", () => (angleAdjustment = directions.map.getBearing()));\n  }\n</script>\n\n<div\n  class=\"maplibre-gl-directions-bearings-control maplibregl-ctrl maplibregl-ctrl-group p-4 {waypointsBearings.length\n    ? 'block'\n    : 'hidden'} bg-white text-base rounded\"\n>\n  <div class=\"maplibre-gl-directions-bearings-control__list flex flex-col max-h-96 overflow-y-auto\">\n    {#each waypointsBearings as waypointBearing, i}\n      <div\n        class=\"\n        maplibre-gl-directions-bearings-control__list-item\n        {waypointBearing.enabled\n          ? 'maplibre-gl-directions-bearings-control__list-item--enabled'\n          : 'maplibre-gl-directions-bearings-control__list-item--disabled'}\n        flex items-center gap-2 text-slate-800{waypointBearing.enabled ? '' : '/50'}\"\n      >\n        <span class=\"maplibre-gl-directions-bearings-control__number text-slate-800\">{i + 1}. </span>\n        <input\n          type=\"checkbox\"\n          bind:checked={waypointBearing.enabled}\n          class=\"maplibre-gl-directions-bearings-control__checkbox\"\n        />\n        <div bind:this={images[i]} on:mousedown={(e) => onImageMousedown(e, i)} role=\"spinbutton\" tabindex=\"0\">\n          <svg\n            height=\"20\"\n            width=\"20\"\n            viewBox=\"0 0 20 20\"\n            class=\"maplibre-gl-directions-bearings-control__waypoint-image\"\n            style=\"width: {configuration.imageSize}px; height: {configuration.imageSize}px; opacity: {waypointBearing.enabled\n              ? 1\n              : 0.25};\"\n          >\n            <circle\n              r=\"5\"\n              cx=\"10\"\n              cy=\"10\"\n              fill=\"transparent\"\n              stroke=\"rgba(109, 38, 215, 0.65)\"\n              stroke-width=\"10\"\n              stroke-dasharray=\"{((waypointBearing.degrees / 3.6) * 31.42) / 100} 31.42\"\n              transform=\"rotate({-90 - waypointBearing.degrees / 2 + waypointBearing.angle - angleAdjustment})\"\n              style=\"transform-origin: 10px 10px\"\n            />\n            <circle r=\"6\" cx=\"10\" cy=\"10\" fill=\"rgb(109, 38, 215)\" />\n          </svg>\n        </div>\n        <input\n          type=\"number\"\n          disabled={!waypointBearing.enabled}\n          bind:value={waypointBearing.angle}\n          min={configuration.angleMin}\n          max={configuration.angleMax}\n          step={configuration.angleStep}\n          class=\"maplibre-gl-directions-bearings-control__input\"\n        />\n        <span class=\"maplibre-gl-directions-bearings-control__text\">°</span>\n        <span class=\"maplibre-gl-directions-bearings-control__text\">±</span>\n        {#if configuration.fixedDegrees}\n          <span class=\"maplibre-gl-directions-bearings-control__text\">{configuration.fixedDegrees}°</span>\n        {:else}\n          <input\n            type=\"number\"\n            disabled={!waypointBearing.enabled}\n            bind:value={waypointBearing.degrees}\n            min={configuration.degreesMin}\n            max={configuration.degreesMax}\n            step={configuration.degreesStep}\n            class=\"maplibre-gl-directions-bearings-control__input\"\n          />\n          <span class=\"maplibre-gl-directions-bearings-control__text\">°</span>\n        {/if}\n      </div>\n    {/each}\n  </div>\n</div>\n","export interface BearingsControlConfiguration {\n  /**\n   * Whether the bearings support is enabled by default for new waypoints.\n   *\n   * @default `false`\n   */\n  defaultEnabled: boolean;\n\n  /**\n   * Debounce requests by the specified amount of milliseconds.\n   *\n   * @default `150`\n   */\n  debounceTimeout: number;\n\n  /**\n   * The default angle for a waypoint when it's added.\n   *\n   * @default `0`\n   */\n  angleDefault: number;\n\n  /**\n   * Minimal allowed angle for a waypoint (affects the control's respective numeric input behavior).\n   *\n   * @default `0`\n   */\n  angleMin: number;\n\n  /**\n   * Maximal allowed angle for a waypoint (affects the control's respective numeric input behavior).\n   *\n   * @default `359`\n   */\n  angleMax: number;\n\n  /**\n   * How many degrees to add/remove to/from the bearing's angle value when the control's respective numeric input's\n   * up/down button is clicked.\n   *\n   * @default `1`\n   */\n  angleStep: number;\n\n  /**\n   * Whether to allow changing the bearings' degrees. When 0 - allow to change degrees, when any other value - use that\n   * value instead.\n   *\n   * @default `0`\n   */\n  fixedDegrees: number;\n\n  /**\n   * The default degree for a waypoint when it's added.\n   *\n   * @default `45`\n   */\n  degreesDefault: number;\n\n  /**\n   * Minimal allowed degree for a waypoint (affects the control's respective numeric input behavior).\n   *\n   * @default `15`\n   */\n  degreesMin: number;\n\n  /**\n   * Maximal allowed degree for a waypoint (affects the control's respective numeric input behavior).\n   *\n   * @default `360`\n   */\n  degreesMax: number;\n\n  /**\n   * How many degrees to add/remove to/from the bearing's degrees value when the control's respective numeric input's\n   * up/down button is clicked.\n   *\n   * @default `15`\n   */\n  degreesStep: number;\n\n  /**\n   * Whether the waypoint-images in the control should be rotated according to the map's current bearing.\n   *\n   * @default `false`\n   */\n  respectMapBearing: boolean;\n\n  /**\n   * The size of the waypoint-images in the control (in pixels).\n   *\n   * @default `50`\n   */\n  imageSize: number;\n}\n\nexport const BearingsControlDefaultConfiguration: BearingsControlConfiguration = {\n  defaultEnabled: false,\n  debounceTimeout: 150,\n  angleDefault: 0,\n  angleMin: 0,\n  angleMax: 359,\n  angleStep: 1,\n  fixedDegrees: 0,\n  degreesDefault: 45,\n  degreesMin: 15,\n  degreesMax: 360,\n  degreesStep: 15,\n  respectMapBearing: false,\n  imageSize: 50,\n};\n","import type { IControl } from \"maplibre-gl\";\nimport BearingsControlComponent from \"./BearingsControl.svelte\";\nimport { BearingsControlDefaultConfiguration } from \"./types\";\nimport type { BearingsControlConfiguration } from \"./types\";\nimport type MapLibreGlDirections from \"../../directions/main\";\n\n/**\n * Creates an instance of BearingsControl that could be added to the map using the\n * {@link https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addcontrol|`addControl`} method.\n *\n * @example\n * ```typescript\n * import MapLibreGlDirections, { BearingsControl } from \"@maplibre/maplibre-gl-directions\";\n * map.addControl(new BearingsControl(new MapLibreGlDirections(map)));\n * ```\n */\nexport default class BearingsControl implements IControl {\n  constructor(directions: MapLibreGlDirections, configuration?: Partial<BearingsControlConfiguration>) {\n    this.directions = directions;\n    this.configuration = Object.assign({}, BearingsControlDefaultConfiguration, configuration);\n  }\n\n  private controlElement!: HTMLElement;\n  private readonly directions: MapLibreGlDirections;\n  private readonly configuration: BearingsControlConfiguration;\n\n  /**\n   * @private\n   */\n  onAdd() {\n    this.controlElement = document.createElement(\"div\");\n\n    new BearingsControlComponent({\n      target: this.controlElement,\n      props: {\n        directions: this.directions,\n        configuration: this.configuration,\n      },\n    });\n\n    return this.controlElement;\n  }\n\n  /**\n   * @private\n   */\n  onRemove() {\n    this.controlElement.remove();\n  }\n}\n"],"names":["MapLibreGlDirectionsEvented","map","__publicField","event","type","_a","listener","_b","index","MapLibreGlDirectionsWaypointEvent","originalEvent","data","MapLibreGlDirectionsRoutingEvent","MapLibreGlDirectionsDefaultConfiguration","colors","routelineColor","waypointColor","snappointColor","layersFactory","pointsScalingFactor","linesScalingFactor","sourceName","pointCasingCircleRadius","pointCircleRadius","lineWidth","lineCasingWidth","urlAlphabet","nanoid","size","id","bytes","scopedUrlAlphabet","resultChange","result","decode","str","precision","factor","lat","lng","coordinates","shift","byte","latitude_change","longitude_change","geometryDecoder","requestOptions","geometry","congestionLevelDecoder","annotation","segmentIndex","_c","_d","coordinatesComparator","a","b","getWaypointsCoordinates","waypoints","waypoint","getWaypointsBearings","buildConfiguration","customConfiguration","layers","buildRequest","configuration","waypointsCoordinates","waypointsBearings","method","url","payload","formData","key","value","waypointBearing","buildPoint","coordinate","properties","buildSnaplines","snappointsCoordinates","hoverpointCoordinates","departSnappointIndex","showHoverpointSnaplines","snaplines","waypointCoordinates","buildRoutelines","routes","selectedRouteIndex","snappoints","route","routeIndex","snappoint","currentIndex","snappointsCoordinatesIndices","snappointLngLat","waypointCoordinatesIndex","lngLat","isLast","initialIndex","legsCoordinates","features","legCoordinates","legIndex","legId","i","previousSegment","segmentCongestion","departSnappointProperties","arriveSnappointProperties","segment","MapLibreGlDirections","layer","response","timer","profiles","waypointsIndex","profile","prevProfile","isSameProfile","waypointsEnd","requests","responses","request","routelines","skipSelectedRouteRedraw","acc","routeLegs","routeLeg","geoJson","routeline","leg","feature","highlightedWaypoint","highlightedSnappoint","highlightedSnappointIndex","departedSnapPointIndex","_e","_f","waypointEvent","err","respectiveWaypointIndex","category","interactive","hoverable","bearings","waypointsStart","noop","run","fn","blank_object","run_all","fns","is_function","thing","safe_not_equal","is_empty","obj","append","target","node","insert","anchor","detach","destroy_each","iterations","detaching","element","name","svg_element","text","space","empty","listen","handler","options","attr","attribute","to_number","children","set_data","set_input_value","input","set_style","important","current_component","set_current_component","component","get_current_component","onDestroy","dirty_components","binding_callbacks","render_callbacks","flush_callbacks","resolved_promise","update_scheduled","schedule_update","flush","add_render_callback","seen_callbacks","flushidx","saved_component","update","e","callback","$$","dirty","flush_render_callbacks","filtered","targets","c","outroing","transition_in","block","local","ensure_array_like","array_like_or_iterator","mount_component","fragment","after_update","new_on_destroy","destroy_component","make_dirty","init","instance","create_fragment","not_equal","props","append_styles","parent_component","ready","ret","rest","nodes","SvelteComponent","callbacks","PUBLIC_VERSION","circle","circle_fill_value","ctx","path0","path0_fill_value","path1","path1_fill_value","path2","path2_fill_value","path3","path3_fill_value","svg","svg_width_value","svg_height_value","svg_class_value","g","animateTransform","create_if_block","directions","$$props","loading","$$invalidate","LoadingIndicatorControlDefaultConfiguration","LoadingControl","LoadingIndicatorControlComponent","input_disabled_value","input_min_value","input_max_value","input_step_value","span","t0_value","t0","span0","circle0","circle0_stroke_dasharray_value","input1","input1_disabled_value","input1_min_value","input1_max_value","input1_step_value","div1","div1_class_value","input0","div0","circle1","span1","span2","onWaypointsChanged","timeout","images","imageBeingRotatedIndex","onImageMousedown","onDocumentMouseup","onDocumentMousemove","image","centerX","centerY","mouse_x","mouse_y","angle","angleAdjustment","$$value","mousedown_handler","BearingsControlDefaultConfiguration","BearingsControl","BearingsControlComponent"],"mappings":"wRAGO,MAAMA,EAA4B,CACvC,YAAYC,EA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