"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/styles/breakpoints.tsx
var breakpoints_exports = {};
__export(breakpoints_exports, {
  Breakpoint: () => Breakpoint,
  BreakpointRanges: () => BreakpointRanges,
  Breakpoints: () => Breakpoints,
  DisplayBreakpoint: () => DisplayBreakpoint,
  bp: () => bp,
  useBreakpoints: () => useBreakpoints,
  useScreenWidth: () => useScreenWidth
});
module.exports = __toCommonJS(breakpoints_exports);
var import_react = require("@emotion/react");
var import_lodash_es = require("lodash-es");
var import_react2 = require("react");
var import_jsx_runtime = require("@emotion/react/jsx-runtime");
var Breakpoints = /* @__PURE__ */ ((Breakpoints2) => {
  Breakpoints2["sm"] = "sm";
  Breakpoints2["md"] = "md";
  Breakpoints2["lg"] = "lg";
  return Breakpoints2;
})(Breakpoints || {});
var breakpoints = {
  ["sm" /* sm */]: 640,
  ["md" /* md */]: 834,
  ["lg" /* lg */]: 1200
};
var BreakpointRanges = /* @__PURE__ */ ((BreakpointRanges2) => {
  BreakpointRanges2["sm"] = "sm";
  BreakpointRanges2["lg"] = "lg";
  BreakpointRanges2["minSmMaxMd"] = "minSmMaxMd";
  BreakpointRanges2["minMdMaxLg"] = "minMdMaxLg";
  BreakpointRanges2["minSmMaxLg"] = "minSmMaxLg";
  BreakpointRanges2["maxLg"] = "maxLg";
  BreakpointRanges2["maxMd"] = "maxMd";
  BreakpointRanges2["minSm"] = "minSm";
  BreakpointRanges2["minMd"] = "minMd";
  return BreakpointRanges2;
})(BreakpointRanges || {});
var breakpointFn = (mq) => (style) => `@media ${mq} { ${style} }`;
var bp = {
  key: Breakpoints,
  ["sm" /* sm */]: breakpointFn(`(max-width:${breakpoints.sm}px)`),
  ["lg" /* lg */]: breakpointFn(`(min-width:${breakpoints.lg}px)`),
  ["minSmMaxLg" /* minSmMaxLg */]: breakpointFn(
    `(min-width:${breakpoints.sm + 1}px) and (max-width:${breakpoints.lg - 1}px)`
  ),
  ["minSmMaxMd" /* minSmMaxMd */]: breakpointFn(
    `(min-width:${breakpoints.sm + 1}px) and (max-width:${breakpoints.md - 1}px)`
  ),
  ["minMdMaxLg" /* minMdMaxLg */]: breakpointFn(
    `(min-width:${breakpoints.md}px) and (max-width:${breakpoints.lg - 1}px)`
  ),
  ["maxLg" /* maxLg */]: breakpointFn(`(max-width:${breakpoints.lg - 1}px)`),
  ["maxMd" /* maxMd */]: breakpointFn(`(max-width:${breakpoints.md - 1}px)`),
  ["minSm" /* minSm */]: breakpointFn(`(min-width:${breakpoints.sm + 1}px)`),
  ["minMd" /* minMd */]: breakpointFn(`(min-width:${breakpoints.md + 1}px)`),
  current: function(assertBp) {
    const currentBp = (
      /* window is undefined in first server side render for Next apps: */
      typeof window === "undefined" ? "sm" /* sm */ : window.getComputedStyle(document.body, ":before").content.replace(/"/g, "")
    );
    if (assertBp) {
      return inRange(
        currentBp,
        assertBp
      );
    }
    return currentBp;
  },
  switch: (smVal, minSmMaxMdVal, minMdMaxLgVal, lgVal) => {
    const currentBp = bp.current();
    if (currentBp === "sm" /* sm */) {
      return smVal;
    } else if (currentBp === "minSmMaxMd" /* minSmMaxMd */) {
      return minSmMaxMdVal;
    } else if (currentBp === "minMdMaxLg" /* minMdMaxLg */) {
      return minMdMaxLgVal;
    }
    return lgVal;
  },
  isSm: () => bp.current("sm" /* sm */),
  isMinSm: () => bp.current("minSm" /* minSm */),
  isMinSmMaxMd: () => bp.current("minSmMaxMd" /* minSmMaxMd */),
  isMinMdMaxLg: () => bp.current("minMdMaxLg" /* minMdMaxLg */),
  isLg: () => bp.current("lg" /* lg */)
};
function inRange(currentBp, assertBp) {
  const isSm = currentBp === "sm" /* sm */;
  const isMinSmMaxMd = currentBp === "minSmMaxMd" /* minSmMaxMd */;
  const isMinMdMaxLg = currentBp === "minMdMaxLg" /* minMdMaxLg */;
  const isLg = currentBp === "lg" /* lg */;
  if (assertBp) {
    switch (assertBp) {
      case "sm" /* sm */:
        return isSm;
      case "minSmMaxMd" /* minSmMaxMd */:
        return isMinSmMaxMd;
      case "minMdMaxLg" /* minMdMaxLg */:
        return isMinMdMaxLg;
      case "lg" /* lg */:
        return isLg;
      case "minSmMaxLg" /* minSmMaxLg */:
        return isMinSmMaxMd || isMinMdMaxLg;
      case "maxLg" /* maxLg */:
        return isSm || isMinSmMaxMd || isMinMdMaxLg;
      case "maxMd" /* maxMd */:
        return isSm || isMinSmMaxMd;
      case "minSm" /* minSm */:
        return isMinSmMaxMd || isMinMdMaxLg || isLg;
      case "minMd" /* minMd */:
        return isMinMdMaxLg || isLg;
      default:
        return false;
    }
  }
  return false;
}
function useBreakpoints() {
  const [currentBp, setCurrentBp] = (0, import_react2.useState)(bp.current());
  (0, import_react2.useLayoutEffect)(() => {
    const handleResize = () => {
      const newBp = bp.current();
      if (newBp !== currentBp) {
        setCurrentBp(newBp);
      }
    };
    handleResize();
    window.addEventListener("resize", handleResize);
    window.addEventListener("deviceorientation", handleResize);
    return () => {
      window.removeEventListener("resize", handleResize);
      window.removeEventListener("deviceorientation", handleResize);
    };
  });
  return bp;
}
function useScreenWidth() {
  const [screenWidth, setScreenWidth] = (0, import_react2.useState)(window.innerWidth);
  (0, import_react2.useLayoutEffect)(() => {
    const handleResize = (0, import_lodash_es.debounce)(() => {
      setScreenWidth(window.innerWidth);
    }, 200);
    handleResize();
    window.addEventListener("resize", handleResize);
    window.addEventListener("deviceorientation", handleResize);
    return () => {
      window.removeEventListener("resize", handleResize);
      window.removeEventListener("deviceorientation", handleResize);
    };
  });
  return screenWidth;
}
var DisplayBreakpoint = ({
  sm,
  minSmMaxMd,
  minMdMaxLg,
  lg,
  maxLg,
  maxMd,
  minSm,
  minMd,
  cssStr,
  children
}) => {
  const breakpoint = (() => {
    switch (true) {
      case sm:
        return bp.sm;
      case minSmMaxMd:
        return bp.minSmMaxMd;
      case minMdMaxLg:
        return bp.minMdMaxLg;
      case lg:
        return bp.lg;
      case maxLg:
        return bp.maxLg;
      case maxMd:
        return bp.maxMd;
      case minSm:
        return bp.minSm;
      case minMd:
        return bp.minMd;
      default:
        return bp.sm;
    }
  })();
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    "div",
    {
      css: import_react.css`
        display: none;
        ${breakpoint(`display: block; ${cssStr}`)}
      `,
      children
    }
  );
};
function Breakpoint({
  sm,
  minSmMaxMd,
  minMdMaxLg,
  lg,
  maxLg,
  maxMd,
  minSm,
  minMd,
  children
}) {
  const bp2 = useBreakpoints();
  const shouldRender = (() => {
    switch (true) {
      case sm:
        return bp2.current("sm" /* sm */);
      case minSmMaxMd:
        return bp2.current("minSmMaxMd" /* minSmMaxMd */);
      case minMdMaxLg:
        return bp2.current("minMdMaxLg" /* minMdMaxLg */);
      case lg:
        return bp2.current("lg" /* lg */);
      case maxLg:
        return bp2.current("maxLg" /* maxLg */);
      case maxMd:
        return bp2.current("maxMd" /* maxMd */);
      case minSm:
        return bp2.current("minSm" /* minSm */);
      case minMd:
        return bp2.current("minMd" /* minMd */);
      default:
        return bp2.current("sm" /* sm */);
    }
  })();
  return shouldRender ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Fragment, { children }) : null;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Breakpoint,
  BreakpointRanges,
  Breakpoints,
  DisplayBreakpoint,
  bp,
  useBreakpoints,
  useScreenWidth
});
