import{r as d,dv as A,dw as k,dx as I}from"./setLogger-C8lBmfK5.js";var B=function(e){var t=d.useRef(e);return A(function(){t.current=e}),t},w=function(e,t){if(typeof e=="function"){e(t);return}e.current=t},M=function(e,t){var r=d.useRef();return d.useCallback(function(i){e.current=i,r.current&&w(r.current,null),r.current=t,t&&w(t,i)},[t])},R={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0"},H=function(e){Object.keys(R).forEach(function(t){e.style.setProperty(t,R[t],"important")})},o=null,L=function(e,t){var r=e.scrollHeight;return t.sizingStyle.boxSizing==="border-box"?r+t.borderSize:r-t.paddingSize};function N(n,e,t,r){t===void 0&&(t=1),r===void 0&&(r=1/0),o||(o=document.createElement("textarea"),o.setAttribute("tabindex","-1"),o.setAttribute("aria-hidden","true"),H(o)),o.parentNode===null&&document.body.appendChild(o);var i=n.paddingSize,h=n.borderSize,a=n.sizingStyle,g=a.boxSizing;Object.keys(a).forEach(function(v){var p=v;o.style[p]=a[p]}),H(o),o.value=e;var u=L(o,n);o.value=e,u=L(o,n),o.value="x";var f=o.scrollHeight-i,s=f*t;g==="border-box"&&(s=s+i+h),u=Math.max(s,u);var c=f*r;return g==="border-box"&&(c=c+i+h),u=Math.min(c,u),[u,f]}var C=function(){},P=function(e,t){return e.reduce(function(r,i){return r[i]=t[i],r},{})},_=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak"],j=!!document.documentElement.currentStyle,U=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var r=P(_,t),i=r.boxSizing;if(i==="")return null;j&&i==="border-box"&&(r.width=parseFloat(r.width)+parseFloat(r.borderRightWidth)+parseFloat(r.borderLeftWidth)+parseFloat(r.paddingRight)+parseFloat(r.paddingLeft)+"px");var h=parseFloat(r.paddingBottom)+parseFloat(r.paddingTop),a=parseFloat(r.borderBottomWidth)+parseFloat(r.borderTopWidth);return{sizingStyle:r,paddingSize:h,borderSize:a}};function E(n,e,t){var r=B(t);d.useLayoutEffect(function(){var i=function(a){return r.current(a)};return n.addEventListener(e,i),function(){return n.removeEventListener(e,i)}},[])}var $=function(e){E(window,"resize",e)},O=function(e){E(document.fonts,"loadingdone",e)},Y=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],G=function(e,t){var r=e.cacheMeasurements,i=e.maxRows,h=e.minRows,a=e.onChange,g=a===void 0?C:a,u=e.onHeightChange,f=u===void 0?C:u,s=k(e,Y);if(s.style){if("maxHeight"in s.style)throw new Error("Using `style.maxHeight` for <TextareaAutosize/> is not supported. Please use `maxRows`.");if("minHeight"in s.style)throw new Error("Using `style.minHeight` for <TextareaAutosize/> is not supported. Please use `minRows`.")}var c=s.value!==void 0,v=d.useRef(null),p=M(v,t),y=d.useRef(0),b=d.useRef(),x=function(){var l=v.current,S=r&&b.current?b.current:U(l);if(S){b.current=S;var z=N(S,l.value||l.placeholder||"x",h,i),m=z[0],W=z[1];y.current!==m&&(y.current=m,l.style.setProperty("height",m+"px","important"),f(m,{rowHeight:W}))}},T=function(l){c||x(),g(l)};return d.useLayoutEffect(x),$(x),O(x),d.createElement("textarea",I({},s,{onChange:T,ref:p}))},Z=d.forwardRef(G);export{Z as i};
//# sourceMappingURL=react-textarea-autosize.browser.esm-B5fpyPlg.js.map
