import{p as Z,ae as p,bf as ee,n as te,bg as ae,u as ne,ag as le,o as y,O as x,aq as oe,b4 as ue,b8 as ie,aT as m,bh as re,ac as se,ai as ce,aj as _,bi as de,D as o,bj as fe,J as I,a2 as R,ar as z,as as ve,bk as xe,bl as me,a_ as ge,ax as S,bm as he,ad as we,az as Ve}from"./index.f985de17.js";const ye=Z({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"),be=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,A){let{attrs:F,emit:M,slots:i}=A;const u=ne(e,"modelValue"),{isFocused:f,focus:D,blur:G}=le(e),E=y(()=>typeof e.counterValue=="function"?e.counterValue(u.value):(u.value||"").toString().length),U=y(()=>{if(F.maxlength)return F.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter});function O(t,n){var a,l;!e.autofocus||!t||(l=(a=n[0].target)==null?void 0:a.focus)==null||l.call(a)}const T=x(),g=x(),B=oe(""),h=x(),j=y(()=>e.persistentPlaceholder||f.value||e.active);function b(){var t;h.value!==document.activeElement&&((t=h.value)==null||t.focus()),f.value||D()}function $(t){b(),M("click:control",t)}function q(t){M("mousedown:control",t)}function J(t){t.stopPropagation(),b(),S(()=>{u.value="",he(e["onClick:clear"],t)})}function K(t){var a;const n=t.target;if(u.value=n.value,(a=e.modelModifiers)!=null&&a.trim){const l=[n.selectionStart,n.selectionEnd];S(()=>{n.selectionStart=l[0],n.selectionEnd=l[1]})}}const c=x(),w=x(+e.rows),C=y(()=>["plain","underlined"].includes(e.variant));ue(()=>{e.autoGrow||(w.value=+e.rows)});function d(){!e.autoGrow||S(()=>{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")),l=c.value.scrollHeight,V=parseFloat(t.lineHeight),P=Math.max(parseFloat(e.rows)*V+a,parseFloat(n.getPropertyValue("--v-input-control-height"))),k=parseFloat(e.maxRows)*V+a||1/0,s=Ve(l!=null?l:0,P,k);w.value=Math.floor((s-a)/V),B.value=we(s)})}ie(d),m(u,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,l]=ce(F),[{modelValue:V,...P}]=_.filterProps(e),[k]=de(e);return o(_,I({ref:T,modelValue:u.value,"onUpdate:modelValue":s=>u.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":C.value},e.class],style:e.style},a,P,{centerAffix:w.value===1&&!C.value,focused:f.value}),{...i,default:s=>{let{isDisabled:v,isDirty:H,isReadonly:L,isValid:Q}=s;return o(fe,I({ref:g,style:{"--v-textarea-control-height":B.value},onClick:$,onMousedown:q,"onClick:clear":J,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},k,{active:j.value||H.value,centerAffix:w.value===1&&!C.value,dirty:H.value||e.dirty,disabled:v.value,focused:f.value,error:Q.value===!1}),{...i,default:W=>{let{props:{class:N,...X}}=W;return o(R,null,[e.prefix&&o("span",{class:"v-text-field__prefix"},[e.prefix]),z(o("textarea",I({ref:h,class:N,value:u.value,onInput:K,autofocus:e.autofocus,readonly:L.value,disabled:v.value,placeholder:e.placeholder,rows:e.rows,name:e.name,onFocus:b,onBlur:G},X,l),null),[[ve("intersect"),{handler:O},null,{once:!0}]]),e.autoGrow&&z(o("textarea",{class:[N,"v-textarea__sizer"],"onUpdate:modelValue":Y=>u.value=Y,ref:c,readonly:!0,"aria-hidden":"true"},null),[[xe,u.value]]),e.suffix&&o("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:n?s=>{var v;return o(R,null,[(v=i.details)==null?void 0:v.call(i,s),t&&o(R,null,[o("span",null,null),o(me,{active:e.persistentCounter||f.value,value:E.value,max:U.value},i.counter)])])}:void 0})}),ge({},T,g,h)}});export{be as V};
