const isValidURL = str => {
  let url;
  try {
    url = new URL(str);
  }
  catch (_) {
    return false;
  }
  return url.protocol === 'http:' || url.protocol === 'https:';
};
const getValueFromUrl = (key) => {
  const queryString = window.location.search;
  const urlParams = new URLSearchParams(queryString);
  return urlParams.get(key);
};
const sortByArray = (item, key, orderArray) => (item || []).sort((a, b) => {
  if (orderArray.indexOf(a === null || a === void 0 ? void 0 : a[key]) === -1)
    return 1;
  if (orderArray.indexOf(b === null || b === void 0 ? void 0 : b[key]) === -1)
    return -1;
  return orderArray.indexOf(a === null || a === void 0 ? void 0 : a[key]) - orderArray.indexOf(b === null || b === void 0 ? void 0 : b[key]);
});

export { getValueFromUrl as g, isValidURL as i, sortByArray as s };
