function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { transform } from "ol/proj";
import qs from "query-string";
export const zoomEquivalent = {
  7: 1,
  8: 1,
  9: 2,
  10: 3,
  11: 4,
  12: 5,
  13: 6,
  14: 7,
  15: 8,
  16: 8,
  17: 9,
  18: 10
};

// Convert zoom from new wkp to old one.
export function convertToOldZoom(zoom) {
  return zoomEquivalent[Math.min(Math.max(Math.round(zoom), 7), 18)];
}
export function convertUrlParams(urlParams) {
  const params = _objectSpread({}, urlParams);
  if (params.z) {
    // Convert the zoom level to match the different scale on the old wkp.
    params.zoom = convertToOldZoom(params.z);
    delete params.z;
  }
  if (params.x || params.y) {
    // Reproject the coordinates to the old wkp projection: EPSG:21781.
    const [newX, newY] = transform([parseInt(params.x, 10), parseInt(params.y, 10)], "EPSG:3857", "EPSG:21781");
    params.x = newX;
    params.y = newY;
  }
  return params;
}
export function redirect(appBaseUrl, topicKey, overrideParams) {
  const params = _objectSpread(_objectSpread({}, convertUrlParams(qs.parse(window.location.search))), overrideParams);
  window.location.href = "".concat(appBaseUrl, "/#/").concat(topicKey, "?").concat(qs.stringify(params));
}
export function redirectToLogin(appBaseUrl) {
  window.location.href = "".concat(appBaseUrl, "/login?next=").concat(encodeURIComponent(window.location.href));
}
export function isOpenedByMapset() {
  return document.referrer && /(mapset)/.test(document.referrer) || false;
}
//# sourceMappingURL=redirectHelper.js.map