'use strict';

var React = require('react');
var tailwindMerge = require('tailwind-merge');
var lodashEs = require('lodash-es');
var react = require('@tw-classed/react');
var core = require('@tw-classed/core');
require('clsx');
var createVariatGroupTransfomer = require('tailwind-group-variant');
var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
var jsxRuntime = require('react/jsx-runtime');
var AutoSizer = require('react-virtualized-auto-sizer');
var dotDiver = require('@clickbar/dot-diver');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var React__namespace = /*#__PURE__*/_interopNamespace(React);
var createVariatGroupTransfomer__default = /*#__PURE__*/_interopDefault(createVariatGroupTransfomer);
var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
var AutoSizer__default = /*#__PURE__*/_interopDefault(AutoSizer);

var __defProp = Object.defineProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};

// src/components/ScrollViewport/ScrollViewport.tsx
var ScrollViewport_exports = {};
__export(ScrollViewport_exports, {
  Container: () => Container,
  FooterSection: () => FooterSection,
  HeaderSection: () => HeaderSection,
  ScrollArea: () => ScrollArea,
  ScrollAreaContainer: () => ScrollAreaContainer,
  ScrollAreaViewport: () => ScrollAreaViewport
});
var twMerge = tailwindMerge.extendTailwindMerge({
  classGroups: {
    "font-size": [
      {
        // Fixes incorect merging of text size
        text: ["h1", "h2", "h3", "h4", "h5", "h6"]
      }
    ]
  }
});
var { classed } = react.createClassed({ merger: twMerge });
core.createClassed({ merger: twMerge });

// src/utils/notEmpty.ts
function notEmpty(value) {
  return value !== null && value !== void 0;
}

// src/utils/classed/expandVariant.ts
createVariatGroupTransfomer__default.default({});
var ScrollBarElement = classed(
  ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
  "flex touch-none select-none transition-colors relative z-30",
  {
    variants: {
      orientation: {
        vertical: "h-full w-12 border-l border-l-transparent p-[1.5px] animate-slide-left-fade",
        horizontal: "h-8 border-t border-t-transparent p-[1.5px] animate-slide-up-fade"
      }
    },
    defaultVariants: {
      orientation: "vertical"
    }
  }
);
var ScrolllBarThumbElement = classed(
  ScrollAreaPrimitive__namespace.ScrollAreaThumb,
  "bg-content-ghost relative flex-1 rounded-full overflow-hidden backdrop-contrast-100 min-h-[44px] transition-[height] will-change-[height]"
);
var ScrollBar = React__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(ScrollBarElement, { ref, orientation, ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ScrolllBarThumbElement, {}) }));
ScrollBar.displayName = ScrollAreaPrimitive__namespace.ScrollAreaScrollbar.displayName;

// src/utils/environment-utils.ts
function isDevelopment() {
  if (typeof window === "undefined" && typeof process !== "undefined" && process.env.NODE_ENV === "development") {
    return true;
  }
  if (typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1")) {
    return true;
  }
  return false;
}
function getByPath(object, path, _maxDepth) {
  return dotDiver.getByPath(object, path);
}

// src/utils/objectMap.ts
function objectMap(obj, fn) {
  return Object.fromEntries(
    Object.entries(obj).map(([k, v], index) => fn({ key: k, value: v, index, get: getByPath })).filter(notEmpty)
  );
}

// src/utils/pickProps.ts
var NO_DEFAULT_VALUE = "_pick_";
function pickProps(props, pickedProps, options) {
  const { shouldValidatePickProp = true } = options ?? {};
  const entries = Object.entries(pickedProps).map(([path, defaultValue]) => {
    const prop = lodashEs.get(props, path);
    if (defaultValue === NO_DEFAULT_VALUE) {
      return [path, prop];
    }
    if (shouldValidatePickProp) {
      validatePickProp(defaultValue, pickedProps);
    }
    return [path, prop ?? defaultValue];
  });
  return Object.fromEntries(entries);
}
function validatePickProp(input, pickedProps) {
  if (isDevelopment()) {
    const startsWith = ["_p", "pick"];
    const isLikelyTypo = typeof input === "string" && startsWith.some((typo) => input.startsWith(typo));
    if (isLikelyTypo) {
      const functionName = "`pickProps`";
      throw new Error(`
      Error thrown from ${functionName}
      
      A possible typo was detected in the arguments passed to the ${functionName} function.

      Expected value: "${NO_DEFAULT_VALUE}"

      Received value: "${input}" \u274C

      ${JSON.stringify(
        objectMap(pickedProps, ({ key, value }) => [
          key,
          value === input ? `${value} \u274C` : value
        ]),
        null,
        2
      )}
 
      If this is intended, add \`shouldValidatePickProp: true\` to the options.

      Note: This error is thrown only during development.

      `);
    }
  }
}
var ScrollAreaContainer = ({
  scrollAreaClassName,
  autoSizerClassName,
  ...props
}) => {
  const scrollAreaProps = pickProps(props, {
    asChild: "_pick_",
    dir: "_pick_",
    scrollHideDelay: "_pick_",
    type: "_pick_"
  });
  const autoSizerProps = pickProps(props, {
    defaultHeight: "_pick_",
    defaultWidth: "_pick_",
    disableHeight: "_pick_",
    disableWidth: "_pick_"
  });
  const { children, className, ...rest } = lodashEs.omit(props, [
    ...Object.keys(scrollAreaProps),
    ...Object.keys(autoSizerProps)
  ]);
  return /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaContainerElement, { className, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(
    AutoSizer__default.default,
    {
      className: tailwindMerge.twMerge(
        "bg-inherit rounded-[inherit] rounded-b-[inherit] rounded-t-[inherit]",
        autoSizerClassName
      ),
      ...autoSizerProps,
      children: ({ width, height }) => /* @__PURE__ */ jsxRuntime.jsxs(
        ScrollAreaPrimitive__namespace.Root,
        {
          className: tailwindMerge.twMerge("bg-inherit", scrollAreaClassName),
          ...scrollAreaProps,
          style: { width, height, overflow: "hidden" },
          children: [
            children,
            /* @__PURE__ */ jsxRuntime.jsx(ScrollBar, {}),
            /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Corner, {})
          ]
        }
      )
    }
  ) });
};
var ScrollAreaContainerElement = classed("div", "w-full  bg-inherit", {
  variants: {
    grow: {
      true: "!grow",
      false: "!grow"
    }
  },
  defaultVariants: {
    grow: true
  }
});
var ScrollArea = React.forwardRef(
  ({ children, ...props }, forwardedRef) => {
    return /* @__PURE__ */ jsxRuntime.jsxs(ScrollAreaPrimitive__namespace.Root, { ...props, className: "overflow-hidden grow", children: [
      /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Viewport, { className: "h-full w-full", ref: forwardedRef, children }),
      /* @__PURE__ */ jsxRuntime.jsx(ScrollBar, {})
    ] });
  }
);
var ScrollAreaViewport = classed(ScrollAreaPrimitive__namespace.Viewport, "w-full h-full");
var Container = classed("div", "grow flex flex-col");
var HeaderSection = classed("div", "shrink-0");
var FooterSection = classed("div", "shrink-0");

exports.ScrollViewport = ScrollViewport_exports;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.cjs.map