import React from "react";
import { Typography } from "@mui/material";
import Search from "../Search";
class Betriebspunkte extends Search {
  constructor() {
    super();
    this.showInPlaceholder = false;
    this.dataProjection = "EPSG:3857";
  }

  // eslint-disable-next-line class-methods-use-this
  search(value) {
    if (this.abortController) {
      this.abortController.abort();
    }
    this.abortController = new AbortController();
    const {
      signal
    } = this.abortController;
    return fetch("".concat(this.searchUrl, "/search/bps?name=").concat(encodeURIComponent(value)), {
      signal
    }).then(data => data.json()).then(featureCollection => {
      return (featureCollection === null || featureCollection === void 0 ? void 0 : featureCollection.features) || [];
    }).catch(() => {
      return [];
    });
  }
  render(item) {
    const {
      bezeichnung: name,
      abkuerzung: abbreviated
    } = item.properties;
    return /*#__PURE__*/React.createElement("div", {
      className: "wkp-search-suggestion"
    }, /*#__PURE__*/React.createElement(Typography, null, name, abbreviated ? " (".concat(abbreviated, ")") : ""));
  }

  // eslint-disable-next-line class-methods-use-this
  value(item) {
    return item.properties.bezeichnung;
  }
}
export default Betriebspunkte;
//# sourceMappingURL=Betriebspunkte.js.map