{"version":3,"file":"TextareaAutosize.mjs","sources":["../../../../../../../../node_modules/@mui/material/TextareaAutosize/TextareaAutosize.js"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { unstable_debounce as debounce, unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_ownerWindow as ownerWindow } from '@mui/utils';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nfunction getStyleValue(value) {\n  return parseInt(value, 10) || 0;\n}\nconst styles = {\n  shadow: {\n    // Visibility needed to hide the extra text area on iPads\n    visibility: 'hidden',\n    // Remove from the content flow\n    position: 'absolute',\n    // Ignore the scrollbar width\n    overflow: 'hidden',\n    height: 0,\n    top: 0,\n    left: 0,\n    // Create a new layer, increase the isolation of the computed values\n    transform: 'translateZ(0)'\n  }\n};\nfunction isEmpty(obj) {\n  return obj === undefined || obj === null || Object.keys(obj).length === 0 || obj.outerHeightStyle === 0 && !obj.overflowing;\n}\n\n/**\n *\n * Demos:\n *\n * - [Textarea Autosize](https://mui.com/material-ui/react-textarea-autosize/)\n *\n * API:\n *\n * - [TextareaAutosize API](https://mui.com/material-ui/api/textarea-autosize/)\n */\nconst TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize(props, forwardedRef) {\n  const {\n    onChange,\n    maxRows,\n    minRows = 1,\n    style,\n    value,\n    ...other\n  } = props;\n  const {\n    current: isControlled\n  } = React.useRef(value != null);\n  const inputRef = React.useRef(null);\n  const handleRef = useForkRef(forwardedRef, inputRef);\n  const heightRef = React.useRef(null);\n  const shadowRef = React.useRef(null);\n  const calculateTextareaStyles = React.useCallback(() => {\n    const input = inputRef.current;\n    const containerWindow = ownerWindow(input);\n    const computedStyle = containerWindow.getComputedStyle(input);\n\n    // If input's width is shrunk and it's not visible, don't sync height.\n    if (computedStyle.width === '0px') {\n      return {\n        outerHeightStyle: 0,\n        overflowing: false\n      };\n    }\n    const inputShallow = shadowRef.current;\n    inputShallow.style.width = computedStyle.width;\n    inputShallow.value = input.value || props.placeholder || 'x';\n    if (inputShallow.value.slice(-1) === '\\n') {\n      // Certain fonts which overflow the line height will cause the textarea\n      // to report a different scrollHeight depending on whether the last line\n      // is empty. Make it non-empty to avoid this issue.\n      inputShallow.value += ' ';\n    }\n    const boxSizing = computedStyle.boxSizing;\n    const padding = getStyleValue(computedStyle.paddingBottom) + getStyleValue(computedStyle.paddingTop);\n    const border = getStyleValue(computedStyle.borderBottomWidth) + getStyleValue(computedStyle.borderTopWidth);\n\n    // The height of the inner content\n    const innerHeight = inputShallow.scrollHeight;\n\n    // Measure height of a textarea with a single row\n    inputShallow.value = 'x';\n    const singleRowHeight = inputShallow.scrollHeight;\n\n    // The height of the outer content\n    let outerHeight = innerHeight;\n    if (minRows) {\n      outerHeight = Math.max(Number(minRows) * singleRowHeight, outerHeight);\n    }\n    if (maxRows) {\n      outerHeight = Math.min(Number(maxRows) * singleRowHeight, outerHeight);\n    }\n    outerHeight = Math.max(outerHeight, singleRowHeight);\n\n    // Take the box sizing into account for applying this value as a style.\n    const outerHeightStyle = outerHeight + (boxSizing === 'border-box' ? padding + border : 0);\n    const overflowing = Math.abs(outerHeight - innerHeight) <= 1;\n    return {\n      outerHeightStyle,\n      overflowing\n    };\n  }, [maxRows, minRows, props.placeholder]);\n  const syncHeight = React.useCallback(() => {\n    const textareaStyles = calculateTextareaStyles();\n    if (isEmpty(textareaStyles)) {\n      return;\n    }\n    const outerHeightStyle = textareaStyles.outerHeightStyle;\n    const input = inputRef.current;\n    if (heightRef.current !== outerHeightStyle) {\n      heightRef.current = outerHeightStyle;\n      input.style.height = `${outerHeightStyle}px`;\n    }\n    input.style.overflow = textareaStyles.overflowing ? 'hidden' : '';\n  }, [calculateTextareaStyles]);\n  useEnhancedEffect(() => {\n    const handleResize = () => {\n      syncHeight();\n    };\n    // Workaround a \"ResizeObserver loop completed with undelivered notifications\" error\n    // in test.\n    // Note that we might need to use this logic in production per https://github.com/WICG/resize-observer/issues/38\n    // Also see https://github.com/mui/mui-x/issues/8733\n    let rAF;\n    const rAFHandleResize = () => {\n      cancelAnimationFrame(rAF);\n      rAF = requestAnimationFrame(() => {\n        handleResize();\n      });\n    };\n    const debounceHandleResize = debounce(handleResize);\n    const input = inputRef.current;\n    const containerWindow = ownerWindow(input);\n    containerWindow.addEventListener('resize', debounceHandleResize);\n    let resizeObserver;\n    if (typeof ResizeObserver !== 'undefined') {\n      resizeObserver = new ResizeObserver(process.env.NODE_ENV === 'test' ? rAFHandleResize : handleResize);\n      resizeObserver.observe(input);\n    }\n    return () => {\n      debounceHandleResize.clear();\n      cancelAnimationFrame(rAF);\n      containerWindow.removeEventListener('resize', debounceHandleResize);\n      if (resizeObserver) {\n        resizeObserver.disconnect();\n      }\n    };\n  }, [calculateTextareaStyles, syncHeight]);\n  useEnhancedEffect(() => {\n    syncHeight();\n  });\n  const handleChange = event => {\n    if (!isControlled) {\n      syncHeight();\n    }\n    if (onChange) {\n      onChange(event);\n    }\n  };\n  return /*#__PURE__*/_jsxs(React.Fragment, {\n    children: [/*#__PURE__*/_jsx(\"textarea\", {\n      value: value,\n      onChange: handleChange,\n      ref: handleRef\n      // Apply the rows prop to get a \"correct\" first SSR paint\n      ,\n      rows: minRows,\n      style: style,\n      ...other\n    }), /*#__PURE__*/_jsx(\"textarea\", {\n      \"aria-hidden\": true,\n      className: props.className,\n      readOnly: true,\n      ref: shadowRef,\n      tabIndex: -1,\n      style: {\n        ...styles.shadow,\n        ...style,\n        paddingTop: 0,\n        paddingBottom: 0\n      }\n    })]\n  });\n});\nprocess.env.NODE_ENV !== \"production\" ? TextareaAutosize.propTypes /* remove-proptypes */ = {\n  // ┌────────────────────────────── Warning ──────────────────────────────┐\n  // │ These PropTypes are generated from the TypeScript type definitions. │\n  // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │\n  // └─────────────────────────────────────────────────────────────────────┘\n  /**\n   * @ignore\n   */\n  className: PropTypes.string,\n  /**\n   * Maximum number of rows to display.\n   */\n  maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n  /**\n   * Minimum number of rows to display.\n   * @default 1\n   */\n  minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n  /**\n   * @ignore\n   */\n  onChange: PropTypes.func,\n  /**\n   * @ignore\n   */\n  placeholder: PropTypes.string,\n  /**\n   * @ignore\n   */\n  style: PropTypes.object,\n  /**\n   * @ignore\n   */\n  value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.number, PropTypes.string])\n} : void 0;\nexport default TextareaAutosize;"],"names":["styles","isEmpty","React.forwardRef","React.useRef","React.useCallback","_jsxs","React.Fragment","_jsx"],"mappings":";;;;;;;;;AAMA,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B,EAAE,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC;AACjC;AACA,MAAMA,QAAM,GAAG;AACf,EAAE,MAAM,EAAE;AACV;AACA,IAAI,UAAU,EAAE,QAAQ;AACxB;AACA,IAAI,QAAQ,EAAE,UAAU;AACxB;AACA,IAAI,QAAQ,EAAE,QAAQ;AACtB,IAAI,MAAM,EAAE,CAAC;AACb,IAAI,GAAG,EAAE,CAAC;AACV,IAAI,IAAI,EAAE,CAAC;AACX;AACA,IAAI,SAAS,EAAE;AACf;AACA,CAAC;AACD,SAASC,SAAO,CAAC,GAAG,EAAE;AACtB,EAAE,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,gBAAgB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW;AAC7H;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACK,MAAC,gBAAgB,gBAAgBC,CAAgB,CAAC,SAAS,gBAAgB,CAAC,KAAK,EAAE,YAAY,EAAE;AACtG,EAAE,MAAM;AACR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