"use strict";

exports.__esModule = true;
exports.tryGetNewEntityIdKey = exports.resolveEntityId = exports.getValueFromUrlByKey = exports.NEW_ENTITY_URL_KEY = void 0;
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var getValueFromUrlByKey = exports.getValueFromUrlByKey = function getValueFromUrlByKey(url, path, key) {
  var valuesFromUrl = url.split("/");

  // remove the regex of the parameters, the part between parentheses (path to regex syntax)
  var keysFromPath = path.replace(/(\([^/]+?\))/g, "").split("/");
  var keyIndex = keysFromPath.indexOf(key);
  return valuesFromUrl[keyIndex];
};
var NEW_ENTITY_URL_KEY = exports.NEW_ENTITY_URL_KEY = "new";
/* expected url formats for new mode:
	/new => new
	/new/section => new
	/new{number} => new{number}
	/new{number}/section => new{number}
*/
var tryGetNewEntityIdKey = exports.tryGetNewEntityIdKey = function tryGetNewEntityIdKey(url) {
  var valuesFromUrl = url.split("/");
  if (valuesFromUrl.length < 2) return;
  for (var _iterator = _createForOfIteratorHelperLoose(valuesFromUrl), _step; !(_step = _iterator()).done;) {
    var section = _step.value;
    if (section === NEW_ENTITY_URL_KEY) return section;
    var match = section.match("(".concat(NEW_ENTITY_URL_KEY, "[0-9]+$)"));
    if (match) return match[1];
  }
};
var resolveEntityId = exports.resolveEntityId = function resolveEntityId(url, path, entityIdKey) {
  var newKey = tryGetNewEntityIdKey(url);
  var key = entityIdKey === newKey ? entityIdKey : ":".concat(entityIdKey);
  return getValueFromUrlByKey(url, path, key);
};
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(getValueFromUrlByKey, "getValueFromUrlByKey", "/home/vsts/work/1/s/src/utils/urlHelper.js");
  reactHotLoader.register(NEW_ENTITY_URL_KEY, "NEW_ENTITY_URL_KEY", "/home/vsts/work/1/s/src/utils/urlHelper.js");
  reactHotLoader.register(tryGetNewEntityIdKey, "tryGetNewEntityIdKey", "/home/vsts/work/1/s/src/utils/urlHelper.js");
  reactHotLoader.register(resolveEntityId, "resolveEntityId", "/home/vsts/work/1/s/src/utils/urlHelper.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(getValueFromUrlByKey, "getValueFromUrlByKey", "/home/vsts/work/1/s/src/utils/urlHelper.js");
  reactHotLoader.register(NEW_ENTITY_URL_KEY, "NEW_ENTITY_URL_KEY", "/home/vsts/work/1/s/src/utils/urlHelper.js");
  reactHotLoader.register(tryGetNewEntityIdKey, "tryGetNewEntityIdKey", "/home/vsts/work/1/s/src/utils/urlHelper.js");
  reactHotLoader.register(resolveEntityId, "resolveEntityId", "/home/vsts/work/1/s/src/utils/urlHelper.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();