import _complement from "ramda/src/complement";
import _equals from "ramda/src/equals";
import _toString from "ramda/src/toString";
import _pipe from "ramda/src/pipe";
import _isNil from "ramda/src/isNil";
import _anyPass from "ramda/src/anyPass";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
import React from 'react';
export var assert = function assert(expression, errorMessage, options) {
  if (process.env.NODE_ENV !== 'production') {
    if (!expression) {
      if (options && options.level === 'warn') {
        console.warn(errorMessage);
      } else {
        throw new Error(errorMessage);
      }
    }
  }
  return true;
};
export var deprecate = function deprecate(message) {
  return function (target) {
    if (process.env.NODE_ENV !== 'production') {
      return typeof Proxy === 'undefined' ? target : new Proxy(target, {
        get: function get(getTarget, getProp) {
          console.warn("Deprecated: ".concat(message));
          return getTarget[getProp];
        },
        apply: function apply(applyTarget, thisArg, argumentsList) {
          return applyTarget.apply(thisArg, argumentsList);
        }
      });
    }
    return target;
  };
};
export var isUndefined = function isUndefined(x) {
  return typeof x === 'undefined';
};
export var isElement = function isElement(x) {
  return React.isValidElement(x);
};
export var isNumber = function isNumber(x) {
  return typeof x === 'number' && !Number.isNaN(x);
};
export var isString = function isString(x) {
  return typeof x === 'string';
};
export var isBoolean = function isBoolean(x) {
  return typeof x === 'boolean';
};
export var isArray = function isArray(x) {
  return Array.isArray(x);
};
export var isFunction = function isFunction(x) {
  return typeof x === 'function';
};
export var isHTMLElement = function isHTMLElement(x) {
  return typeof HTMLElement !== 'undefined' ? x instanceof HTMLElement : false;
};
var convertToDate = function convertToDate(value) {
  return new Date(value);
};
var isInvalid = _anyPass([_isNil, _pipe(convertToDate, _toString, _equals('Invalid Date'))]);
export var isValidDateTimeNumber = _complement(isInvalid);
export var getValueFromNumberOrString = function getValueFromNumberOrString(value, theme) {
  if (value && theme) {
    return "".concat(isNumber(value) ? "".concat(theme.spacing.unit(value), "px") : value);
  }
  return null;
};
export var numberWithLimit = function numberWithLimit(amount, limit) {
  var isOverLimit = amount > limit;
  return isOverLimit ? "".concat(limit, "+") : "".concat(amount);
};
export var mergeRefs = function mergeRefs(refs) {
  return function (value) {
    refs.forEach(function (ref) {
      if (typeof ref === 'function') {
        ref(value);
      } else if (ref != null) {
        ref.current = value;
      }
    });
  };
};
export function wrapEvent(theirHandler, ourHandler) {
  return function (event) {
    if (theirHandler) theirHandler(event);
    if (!event.defaultPrevented) {
      ourHandler(event);
    }
  };
}
export var fromKebabToCamelCase = function fromKebabToCamelCase(str) {
  return str.replace(/-./g, function (match) {
    return match[1].toUpperCase();
  });
};
export var secondsToTimeString = function secondsToTimeString(seconds) {
  var h = Math.floor(seconds / 3600);
  var m = Math.floor(seconds % 3600 / 60);
  var s = Math.round(seconds % 60);
  return [h, m > 9 ? m : "0".concat(m), s > 9 ? s : "0".concat(s)].filter(Boolean).join(':');
};
export var flattenObject = function flattenObject(obj) {
  var flattened = {};
  Object.keys(obj).forEach(function (key) {
    if (_typeof(obj[key]) === 'object' && obj[key] !== null) {
      var nested = flattenObject(obj[key]);
      Object.keys(nested).forEach(function (nestedKey) {
        flattened["".concat(key, ".").concat(nestedKey)] = nested[nestedKey];
      });
    } else {
      flattened[key] = obj[key];
    }
  });
  return flattened;
};
export function getAriaProps(props) {
  var filteredProps = {};
  Object.keys(props).forEach(function (prop) {
    if (prop.startsWith('aria-')) {
      filteredProps[prop] = props[prop];
    }
  });
  return filteredProps;
}
export function getDataProps(props) {
  var filteredProps = {};
  Object.keys(props).forEach(function (prop) {
    if (prop.startsWith('data-')) {
      filteredProps[prop] = props[prop];
    }
  });
  return filteredProps;
}