import { e as BreakpointKeys } from './ui-93922c59.js';
import { B as Breakpoints } from './breakpoints-d9faf11c.js';

/**
 * Get current breakpoint according current window size
 *
 * @returns {BreakpointsTokenType} - current breakpoint
 */
const getCurrentBreakpoint = () => {
  let index = BreakpointKeys.length - 1;
  const windowWidth = window.innerWidth;
  for (index; index >= 0; index--) {
    const breakpointKey = BreakpointKeys[index];
    if (breakpointKey === 'default')
      break;
    if (windowWidth >= Breakpoints[breakpointKey])
      return breakpointKey;
  }
  return 'default';
};
/**
 * Completion breakponts, eg:
 * {
 *   default: 'size-12',
 *   M: 'size-24'
 * }
 * it will convert to
 * {
 *   default: 'size-12',
 *   S: 'size-12',
 *   M: 'size-24',
 *   L: 'size-24',
 *   XL: 'size-24',
 * }
 *
 * @typedef T generic type
 * @param {ResponsiveType<ResponsiveScope>} breakpoints - responsive token
 * @returns {ResponsiveType<T>} - completed breakpointss
 */
const createCompleteResponsiveMap = (breakpoints) => {
  let responsiveScope;
  BreakpointKeys.forEach((breakpoint) => {
    if (Object.prototype.hasOwnProperty.call(breakpoints, breakpoint)) {
      responsiveScope = breakpoints[breakpoint];
    }
    else {
      breakpoints[breakpoint] = responsiveScope;
    }
  });
  return breakpoints;
};

export { createCompleteResponsiveMap as c, getCurrentBreakpoint as g };
