import{g as ne,p as le,aV as E,aj as oe,al as y,an as x,ap as ue,aU as ie,aL as re,aq as f,bi as se,c as ce,ar as de,d as R,i as r,F as S,E as N,K as G,ch as fe,e as ve,as as me,at as B,aC as xe,bm as ge,au as he}from"./index-GaWRVcb2.js";import{u as we,a as U,b as D,c as Ve,j as ye,m as Ce,d as Fe}from"./VTextField-CIjc2Rnv.js";const Pe=le({autoGrow:Boolean,autofocus:Boolean,counter:[Boolean,Number,String],counterValue:Function,prefix:String,placeholder:String,persistentPlaceholder:Boolean,persistentCounter:Boolean,noResize:Boolean,rows:{type:[Number,String],default:5,validator:e=>!isNaN(parseFloat(e))},maxRows:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},suffix:String,modelModifiers:Object,...Fe(),...Ce()},"VTextarea"),ke=ne()({name:"VTextarea",directives:{vIntersect:E},inheritAttrs:!1,props:Pe(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0,"update:rows":e=>!0},setup(e,j){let{attrs:C,emit:F,slots:l}=j;const a=oe(e,"modelValue"),{isFocused:v,focus:O,blur:$}=we(e),{onIntersect:q}=ye(e),K=y(()=>typeof e.counterValue=="function"?e.counterValue(a.value):(a.value||"").toString().length),L=y(()=>{if(C.maxlength)return C.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),M=x(),g=x(),z=ue(""),h=x(),p=y(()=>e.persistentPlaceholder||v.value||e.active);function P(){var t;h.value!==document.activeElement&&((t=h.value)==null||t.focus()),v.value||O()}function J(t){P(),F("click:control",t)}function Q(t){F("mousedown:control",t)}function W(t){t.stopPropagation(),P(),B(()=>{a.value="",he(e["onClick:clear"],t)})}function X(t){var u;const n=t.target;if(a.value=n.value,(u=e.modelModifiers)!=null&&u.trim){const d=[n.selectionStart,n.selectionEnd];B(()=>{n.selectionStart=d[0],n.selectionEnd=d[1]})}}const s=x(),m=x(Number(e.rows)),b=y(()=>["plain","underlined"].includes(e.variant));ie(()=>{e.autoGrow||(m.value=Number(e.rows))});function c(){e.autoGrow&&B(()=>{if(!s.value||!g.value)return;const t=getComputedStyle(s.value),n=getComputedStyle(g.value.$el),u=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),d=s.value.scrollHeight,w=parseFloat(t.lineHeight),I=Math.max(parseFloat(e.rows)*w+u,parseFloat(n.getPropertyValue("--v-input-control-height"))),k=parseFloat(e.maxRows)*w+u||1/0,i=ge(d??0,I,k);m.value=Math.floor((i-u)/w),z.value=xe(i)})}re(c),f(a,c),f(()=>e.rows,c),f(()=>e.maxRows,c),f(()=>e.density,c),f(m,t=>{F("update:rows",t)});let o;return f(s,t=>{t?(o=new ResizeObserver(c),o.observe(s.value)):o==null||o.disconnect()}),se(()=>{o==null||o.disconnect()}),ce(()=>{const t=!!(l.counter||e.counter||e.counterValue),n=!!(t||l.details),[u,d]=de(C),{modelValue:w,...I}=U.filterProps(e),k={...D.filterProps(e),"onClick:clear":W};return R(U,N({ref:M,modelValue:a.value,"onUpdate:modelValue":i=>a.value=i,class:["v-textarea v-text-field",{"v-textarea--prefixed":e.prefix,"v-textarea--suffixed":e.suffix,"v-text-field--prefixed":e.prefix,"v-text-field--suffixed":e.suffix,"v-textarea--auto-grow":e.autoGrow,"v-textarea--no-resize":e.noResize||e.autoGrow,"v-input--plain-underlined":b.value},e.class],style:e.style},u,I,{centerAffix:m.value===1&&!b.value,focused:v.value}),{...l,default:i=>{let{id:V,isDisabled:A,isDirty:H,isReadonly:Y,isValid:Z,hasDetails:ee}=i;return R(D,N({ref:g,style:{"--v-textarea-control-height":z.value},onClick:J,onMousedown:Q,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},k,{id:V.value,active:p.value||H.value,centerAffix:m.value===1&&!b.value,dirty:H.value||e.dirty,disabled:A.value,focused:v.value,details:ee.value,error:Z.value===!1}),{...l,default:te=>{let{props:{class:T,..._}}=te;return r(S,null,[e.prefix&&r("span",{class:"v-text-field__prefix"},[e.prefix]),G(r("textarea",N({ref:h,class:T,value:a.value,onInput:X,autofocus:e.autofocus,readonly:Y.value,disabled:A.value,placeholder:e.placeholder,rows:e.rows,name:e.name,onFocus:P,onBlur:$},_,d),null),[[E,{handler:q},null,{once:!0}]]),e.autoGrow&&G(r("textarea",{class:ve([T,"v-textarea__sizer"]),id:`${_.id}-sizer`,"onUpdate:modelValue":ae=>a.value=ae,ref:s,readonly:!0,"aria-hidden":"true"},null),[[fe,a.value]]),e.suffix&&r("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:n?i=>{var V;return r(S,null,[(V=l.details)==null?void 0:V.call(l,i),t&&r(S,null,[r("span",null,null),R(Ve,{active:e.persistentCounter||v.value,value:K.value,max:L.value,disabled:e.disabled},l.counter)])])}:void 0})}),me({},M,g,h)}});export{ke as V};
