"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),M=require("../_util/BaseInput.js"),N=require("../_util/classNames.js"),_=require("../_util/omit.js"),i=require("../_util/raf.js"),B=require("../_util/warning.js"),F=require("../vc-resize-observer/index.js"),U=require("./calculateNodeHeight.js"),V=require("./inputProps.js"),S=0,m=1,z=2,Z=e.defineComponent({compatConfig:{MODE:3},name:"ResizableTextArea",inheritAttrs:!1,props:V.textAreaProps(),setup(u,{attrs:c,emit:g,expose:w}){let h,T;const a=e.ref(),p=e.ref({}),l=e.ref(z);e.onBeforeUnmount(()=>{i.default.cancel(h),i.default.cancel(T)});const q=()=>{try{if(a.value&&document.activeElement===a.value.input){const t=a.value.getSelectionStart(),d=a.value.getSelectionEnd(),v=a.value.getScrollTop();a.value.setSelectionRange(t,d),a.value.setScrollTop(v)}}catch{}},s=e.ref(),r=e.ref();e.watchEffect(()=>{const t=u.autoSize||u.autosize;t?(s.value=t.minRows,r.value=t.maxRows):(s.value=void 0,r.value=void 0)});const n=e.computed(()=>!!(u.autoSize||u.autosize)),f=()=>{l.value=S};e.watch([()=>u.value,s,r,n],()=>{n.value&&f()},{immediate:!0});const x=e.ref();e.watch([l,a],()=>{if(a.value)if(l.value===S)l.value=m;else if(l.value===m){const t=U.default(a.value.input,!1,s.value,r.value);l.value=z,x.value=t}else q()},{immediate:!0,flush:"post"});const y=e.getCurrentInstance(),R=e.ref(),A=()=>{i.default.cancel(R.value)},I=t=>{l.value===z&&(g("resize",t),n.value&&(A(),R.value=i.default(()=>{f()})))};e.onBeforeUnmount(()=>{A()}),w({resizeTextarea:()=>{f()},textArea:e.computed(()=>a.value?.input),instance:y}),B.default(u.autosize===void 0);const b=()=>{const{prefixCls:t,disabled:d}=u,v=_.default(u,["prefixCls","onPressEnter","autoSize","autosize","defaultValue","allowClear","type","maxlength","valueModifiers"]),C=N.default(t,c.class,{[`${t}-disabled`]:d}),P=n.value?x.value:null,E=[c.style,p.value,P],o={...v,...c,style:E,class:C};return(l.value===S||l.value===m)&&E.push({overflowX:"hidden",overflowY:"hidden"}),o.autofocus||delete o.autofocus,o.rows===0&&delete o.rows,e.createVNode(F.default,{onResize:I,disabled:!n.value},{default:()=>[e.createVNode(M.default,{...o,ref:a,tag:"textarea"},null)]})};return()=>b()}});exports.default=Z;
