"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.AutoHeightScrollView = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/**
 * A ScrollView that automatically adjusts its height to match its content,
 * but shrinks if constrained by a parent (e.g., a Max Height Bottom Sheet).
 * 
 * This solves the "collapsed to 0 height" issue when using ScrollView inside an auto-height container.
 */
const AutoHeightScrollView = exports.AutoHeightScrollView = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
  const [contentHeight, setContentHeight] = (0, _react.useState)(0);
  const {
    style,
    onContentSizeChange,
    ...rest
  } = props;
  const handleContentSizeChange = (w, h) => {
    setContentHeight(h);
    onContentSizeChange?.(w, h);
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
    ref: ref,
    style: [styles.defaultStyle, style, {
      height: contentHeight > 0 ? contentHeight : undefined
    }],
    onContentSizeChange: handleContentSizeChange,
    ...rest
  });
});
const styles = _reactNative.StyleSheet.create({
  defaultStyle: {
    flexShrink: 1,
    flexGrow: 0,
    // Ensure we don't force expansion beyond content unless needed
    minHeight: 0
  }
});
AutoHeightScrollView.displayName = 'AutoHeightScrollView';
//# sourceMappingURL=AutoHeightScrollView.js.map