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/components/utils/Transition.tsx
var Transition_exports = {};
__export(Transition_exports, {
  Transition: () => Transition
});
module.exports = __toCommonJS(Transition_exports);
var import_react = require("react");

// src/utils/bagFunctions.ts
var resolve = (children, bag) => {
  if (typeof children === "function") {
    return children(bag);
  }
  return children ?? void 0;
};
var BagFunctionUtil = {
  resolve
};

// src/components/utils/Transition.tsx
function Transition({
  children,
  show,
  includeAnimation = true
}) {
  const [isOpen, setIsOpen] = (0, import_react.useState)(show);
  const [isTransitioning, setIsTransitioning] = (0, import_react.useState)(!isOpen);
  const isUsingReducedMotion = typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)").matches : true;
  (0, import_react.useEffect)(() => {
    setIsOpen(show);
    setIsTransitioning(true);
  }, [show]);
  const onAnimationEnd = () => setIsTransitioning(false);
  const bag = {
    isOpen,
    isTransitioning,
    isUsingReducedMotion,
    data: {
      "data-open": isOpen && !isTransitioning ? "" : void 0,
      "data-opening": isOpen && isTransitioning ? "" : void 0,
      "data-closing": !isOpen && isTransitioning ? "" : void 0,
      "data-closed": !isOpen && !isTransitioning ? "" : void 0
    },
    handlers: {
      onTransitionEnd: () => setIsTransitioning(false),
      onTransitionCancel: () => setIsTransitioning(false),
      onAnimationEnd: includeAnimation ? onAnimationEnd : void 0
    }
  };
  return BagFunctionUtil.resolve(children, bag);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Transition
});
//# sourceMappingURL=Transition.cjs.map