"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.isDate = isDate;
exports.isDef = isDef;
exports.isFunction = isFunction;
exports.isIOS = isIOS;
exports.isId = isId;
exports.isMobile = isMobile;
exports.isNumeric = isNumeric;
exports.isObject = isObject;
exports.isPromise = isPromise;

var _checkIdent = _interopRequireDefault(require("./checkIdent"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function isDef(val) {
  return val !== undefined && val !== null;
} // eslint-disable-next-line @typescript-eslint/ban-types


function isFunction(val) {
  return typeof val === 'function';
}

function isObject(val) {
  return val !== null && _typeof(val) === 'object';
}

function isPromise(val) {
  return isObject(val) && isFunction(val.then) && isFunction(val.catch);
}

function isDate(val) {
  return Object.prototype.toString.call(val) === '[object Date]' && !Number.isNaN(val.getTime());
}

function isMobile(value) {
  value = value.replace(/[^-|\d]/g, '');
  return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
}

function isNumeric(val) {
  return typeof val === 'number' || /^\d+(\.\d+)?$/.test(val);
}

function isId(val) {
  var data = val.toUpperCase();
  return (0, _checkIdent.default)(data);
}

function isIOS() {
  var inBrowser = typeof window !== 'undefined';
  return inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
}