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/loading-states/LoadingAndErrorComponent.tsx
var LoadingAndErrorComponent_exports = {};
__export(LoadingAndErrorComponent_exports, {
  LoadingAndErrorComponent: () => LoadingAndErrorComponent
});
module.exports = __toCommonJS(LoadingAndErrorComponent_exports);
var import_react = require("react");

// src/components/loading-states/LoadingContainer.tsx
var import_clsx = require("clsx");
var import_jsx_runtime = require("react/jsx-runtime");
var LoadingContainer = ({ className }) => {
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_clsx.clsx)("relative overflow-hidden shimmer bg-disabled-background rounded-md", className) });
};

// src/components/loading-states/LoadingAndErrorComponent.tsx
var import_clsx2 = require("clsx");
var import_jsx_runtime2 = require("react/jsx-runtime");
var LoadingAndErrorComponent = ({
  children,
  isLoading = false,
  hasError = false,
  loadingComponent,
  errorComponent,
  minimumLoadingDuration = 200,
  className
}) => {
  const [isInMinimumLoading, setIsInMinimumLoading] = (0, import_react.useState)(false);
  const [hasUsedMinimumLoading, setHasUsedMinimumLoading] = (0, import_react.useState)(false);
  if (minimumLoadingDuration && !isInMinimumLoading && !hasUsedMinimumLoading) {
    setIsInMinimumLoading(true);
    setTimeout(() => {
      setIsInMinimumLoading(false);
      setHasUsedMinimumLoading(true);
    }, minimumLoadingDuration);
  }
  if (isLoading || minimumLoadingDuration && isInMinimumLoading) {
    return loadingComponent ?? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingContainer, { className: (0, import_clsx2.clsx)(className) });
  }
  if (hasError) {
    return errorComponent ?? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingContainer, { className: (0, import_clsx2.clsx)("bg-negative", className) });
  }
  return children;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  LoadingAndErrorComponent
});
//# sourceMappingURL=LoadingAndErrorComponent.cjs.map