export const isTouchable = () => {
  const userAgent = window.navigator.userAgent;
  return (
    !!userAgent && userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i)
  );
};

export const isIphone = () => {
  return (
    !!navigator.platform &&
    /iPad|iPhone|iPod/.test(navigator.platform)
  );
};

export const isMobile = () => {
  return isTouchable() ? window.outerWidth <= 776 : window.innerWidth <= 776;
};

export const isIpad = () => {
  return (
    (/iPad/.test(navigator.platform) ||
      (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&
    !window.MSStream
  );
};

export const isTablet = () => {
  return isTouchable()
    ? window.outerWidth <= 1024 && window.outerWidth > 776
    : window.innerWidth <= 1024 && window.innerWidth > 776;
};

export const isDesktop = () => {
  return isTouchable() ? window.outerWidth > 1024 : window.innerWidth > 1024;
};

export const isSafari = () => {
  const userAgent = window.navigator.userAgent.toLowerCase();
  return userAgent.indexOf('safari') > -1 && userAgent.indexOf('chrome') < 0;
};