"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ModalWrapper = void 0;
var _react = require("react");
var _styledModalComponents = require("../styledModalComponents");
var _Button = _interopRequireDefault(require("../../styled/Button"));
var _reactNative = require("react-native");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const ModalWrapper = ({
  iconTitle: IconTitle,
  title,
  description,
  buttonText,
  backgroundColorButton,
  isTextarea,
  textarea,
  setTextarea,
  handleCloseModal,
  handleClick,
  compact = false
}) => {
  const textareaRef = (0, _react.useRef)(null);

  // const handleInput = () => {
  //   const textarea = textareaRef.current;
  //   if (textarea) {
  //     textarea.style.height = "auto";
  //     textarea.style.height = `${textarea.scrollHeight}px`;
  //   }
  // };

  const inner = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styledModalComponents.CloseButton, {
      onPress: handleCloseModal,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
        style: {
          fontSize: 24
        },
        children: "\xD7"
      })
    }), IconTitle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(IconTitle, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledModalComponents.ModalTitle, {
      children: title
    }), description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledModalComponents.ModalDescription, {
      children: description
    }), isTextarea && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledModalComponents.GroupContainer, {
      style: {
        flexDirection: 'column',
        position: 'relative'
      }
    }), !buttonText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledModalComponents.GroupContainer, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styledModalComponents.GroupContainer, {
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
        onPress: handleCloseModal,
        text: 'Cancel',
        style: {
          width: '100%'
        },
        unstyled: true,
        variant: "outlined"
      }), buttonText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
        onPress: handleClick,
        text: buttonText
        // White label on the filled (e.g. red Delete) button. Button
        // applies an inline `color: color || 'black'` that overrides
        // the filled-variant white, so pass it explicitly.
        ,
        color: "#FFFFFF",
        style: {
          width: '100%',
          backgroundColor: backgroundColorButton
        },
        unstyled: true,
        variant: "filled"
      })]
    })]
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
    transparent: true,
    animationType: "fade",
    visible: true,
    onRequestClose: handleCloseModal,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledModalComponents.ModalBackground, {
      children: compact ?
      /*#__PURE__*/
      // Dedicated small centered dialog. The base ModalContainer is
      // flex:1 / width:100% / height:100% (full-screen); style-merge
      // overrides proved unreliable, so confirm-style modals render in
      // their own bounded View instead — never full-screen (#14).
      // (Upstream also shrank this modal; this keeps that intent while
      // adding the white filled-button label via `inner` below.)
      (0, _jsxRuntime.jsx)(_reactNative.View, {
        style: styles.compactDialog,
        children: inner
      }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledModalComponents.ModalContainer, {
        style: {
          maxWidth: 640
        },
        children: inner
      })
    })
  });
};
exports.ModalWrapper = ModalWrapper;
const styles = _reactNative.StyleSheet.create({
  compactDialog: {
    width: '85%',
    maxWidth: 360,
    alignSelf: 'center',
    backgroundColor: '#fff',
    borderRadius: 16,
    padding: 24,
    gap: 16,
    shadowColor: '#000',
    shadowOffset: {
      width: 0,
      height: 4
    },
    shadowOpacity: 0.2,
    shadowRadius: 12,
    elevation: 8
  }
});
//# sourceMappingURL=ModalWrapper.js.map