import{a6 as X,bQ as p,c5 as ee,ag as te,c6 as ae,bl as ne,bT as le,an as y,r as x,b_ as oe,c7 as ue,W as ie,w as m,c8 as re,as as se,bJ as ce,bK as I,at as de,bV as fe,bW as z,c9 as ve,f as l,ca as xe,L as R,F as S,Y as A,aZ as me,cb as ge,cc as he,cd as we,c0 as Ve}from"./index.737529e8.1750111005555.js";const ye=X({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,...p(),...ee()},"VTextarea"),Ce=te()({name:"VTextarea",directives:{Intersect:ae},inheritAttrs:!1,props:ye(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,G){let{attrs:F,emit:M,slots:i}=G;const o=ne(e,"modelValue"),{isFocused:f,focus:D,blur:E}=le(e),U=y(()=>typeof e.counterValue=="function"?e.counterValue(o.value):(o.value||"").toString().length),O=y(()=>{if(F.maxlength)return F.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter});function $(t,n){var a,u;!e.autofocus||!t||(u=(a=n[0].target)==null?void 0:a.focus)==null||u.call(a)}const T=x(),g=x(),B=oe(""),h=x(),W=y(()=>e.persistentPlaceholder||f.value||e.active);function C(){var t;h.value!==document.activeElement&&((t=h.value)==null||t.focus()),f.value||D()}function j(t){C(),M("click:control",t)}function J(t){M("mousedown:control",t)}function K(t){t.stopPropagation(),C(),I(()=>{o.value="",we(e["onClick:clear"],t)})}function L(t){var a;const n=t.target;if(o.value=n.value,(a=e.modelModifiers)!=null&&a.trim){const u=[n.selectionStart,n.selectionEnd];I(()=>{n.selectionStart=u[0],n.selectionEnd=u[1]})}}const c=x(),w=x(+e.rows),P=y(()=>["plain","underlined"].includes(e.variant));ue(()=>{e.autoGrow||(w.value=+e.rows)});function d(){e.autoGrow&&I(()=>{if(!c.value||!g.value)return;const t=getComputedStyle(c.value),n=getComputedStyle(g.value.$el),a=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),u=c.value.scrollHeight,V=parseFloat(t.lineHeight),b=Math.max(parseFloat(e.rows)*V+a,parseFloat(n.getPropertyValue("--v-input-control-height"))),k=parseFloat(e.maxRows)*V+a||1/0,s=Ve(u??0,b,k);w.value=Math.floor((s-a)/V),B.value=de(s)})}ie(d),m(o,d),m(()=>e.rows,d),m(()=>e.maxRows,d),m(()=>e.density,d);let r;return m(c,t=>{t?(r=new ResizeObserver(d),r.observe(c.value)):r==null||r.disconnect()}),re(()=>{r==null||r.disconnect()}),se(()=>{const t=!!(i.counter||e.counter||e.counterValue),n=!!(t||i.details),[a,u]=fe(F),[{modelValue:V,...b}]=z.filterProps(e),[k]=ve(e);return l(z,R({ref:T,modelValue:o.value,"onUpdate:modelValue":s=>o.value=s,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-text-field--plain-underlined":P.value},e.class],style:e.style},a,b,{centerAffix:w.value===1&&!P.value,focused:f.value}),{...i,default:s=>{let{isDisabled:v,isDirty:H,isReadonly:Q,isValid:Y}=s;return l(xe,R({ref:g,style:{"--v-textarea-control-height":B.value},onClick:j,onMousedown:J,"onClick:clear":K,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},k,{active:W.value||H.value,centerAffix:w.value===1&&!P.value,dirty:H.value||e.dirty,disabled:v.value,focused:f.value,error:Y.value===!1}),{...i,default:Z=>{let{props:{class:N,..._}}=Z;return l(S,null,[e.prefix&&l("span",{class:"v-text-field__prefix"},[e.prefix]),A(l("textarea",R({ref:h,class:N,value:o.value,onInput:L,autofocus:e.autofocus,readonly:Q.value,disabled:v.value,placeholder:e.placeholder,rows:e.rows,name:e.name,onFocus:C,onBlur:E},_,u),null),[[me("intersect"),{handler:$},null,{once:!0}]]),e.autoGrow&&A(l("textarea",{class:[N,"v-textarea__sizer"],id:`${_.id}-sizer`,"onUpdate:modelValue":q=>o.value=q,ref:c,readonly:!0,"aria-hidden":"true"},null),[[ge,o.value]]),e.suffix&&l("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:n?s=>{var v;return l(S,null,[(v=i.details)==null?void 0:v.call(i,s),t&&l(S,null,[l("span",null,null),l(he,{active:e.persistentCounter||f.value,value:U.value,max:O.value},i.counter)])])}:void 0})}),ce({},T,g,h)}});export{Ce as V};
