import{u as te,g as le,V as B,d as D,e as ae,m as ne,h as ue,f as oe,i as ie}from"./C1aoz2cp.js";import{f as se}from"./D_qxKlPu.js";import{g as re,k as ce,a as de,aX as fe,b as h,l as y,i as m,a4 as b,p as ve,o as M,c as a,F as C,w as me,n as xe,cO as Ve,ae as F,bp as ge}from"#entry";import{I as T}from"./CIr4U5gS.js";const he=["color","file","time","date","datetime-local","week","month"],ye=ve({autofocus:Boolean,counter:[Boolean,Number,String],counterValue:[Number,Function],prefix:String,placeholder:String,persistentPlaceholder:Boolean,persistentCounter:Boolean,suffix:String,role:String,type:{type:String,default:"text"},modelModifiers:Object,...ue(),...M(ne(),["direction"]),...ae()},"VTextField"),ke=re()({name:"VTextField",directives:{vIntersect:T},inheritAttrs:!1,props:ye(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,E){let{attrs:x,emit:P,slots:n}=E;const u=ce(e,"modelValue",void 0,t=>Object.is(t,-0)?"-0":t),{isFocused:o,focus:k,blur:O}=te(e),{onIntersect:j}=ie(e),z=m(()=>typeof e.counterValue=="function"?e.counterValue(u.value):typeof e.counterValue=="number"?e.counterValue:(u.value??"").toString().length),U=m(()=>{if(x.maxlength)return x.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),_=m(()=>["plain","underlined"].includes(e.variant)),I=b(),S=b(),i=b(),d=le(e),$=m(()=>he.includes(e.type)||e.persistentPlaceholder||o.value||e.active);function A(){d.isSuppressing.value&&d.update(),o.value||k(),F(()=>{i.value!==document.activeElement&&i.value?.focus()})}function X(t){P("mousedown:control",t),t.target!==i.value&&(A(),t.preventDefault())}function q(t){P("click:control",t)}function G(t,l){t.stopPropagation(),A(),F(()=>{l(),ge(e["onClick:clear"],t)})}function H(t){const l=t.target;if(!(e.modelModifiers?.trim&&["text","search","password","tel","url"].includes(e.type))){u.value=l.value;return}const s=l.value,f=l.selectionStart,V=l.selectionEnd;u.value=s,F(()=>{let r=0;s.trimStart().length===l.value.length&&(r=s.length-l.value.length),f!=null&&(l.selectionStart=f-r),V!=null&&(l.selectionEnd=V-r)})}return de(()=>{const t=!!(n.counter||e.counter!==!1&&e.counter!=null),l=!!(t||n.details),[s,f]=fe(x),{modelValue:V,...r}=B.filterProps(e),J=D.filterProps(e);return h(B,y({ref:I,modelValue:u.value,"onUpdate:modelValue":c=>u.value=c,class:["v-text-field",{"v-text-field--prefixed":e.prefix,"v-text-field--suffixed":e.suffix,"v-input--plain-underlined":_.value},e.class],style:e.style},s,r,{centerAffix:!_.value,focused:o.value}),{...n,default:c=>{let{id:v,isDisabled:p,isDirty:w,isReadonly:K,isValid:L,hasDetails:Q,reset:W}=c;return h(D,y({ref:S,onMousedown:X,onClick:q,"onClick:clear":g=>G(g,W),role:e.role},M(J,["onClick:clear"]),{id:v.value,labelId:`${v.value}-label`,active:$.value||w.value,dirty:w.value||e.dirty,disabled:p.value,focused:o.value,details:Q.value,error:L.value===!1}),{...n,default:g=>{let{props:{class:N,...Y},controlRef:Z}=g;const R=a("input",y({ref:ee=>i.value=Z.value=ee,value:u.value,onInput:H,autofocus:e.autofocus,readonly:K.value,disabled:p.value,name:d.fieldName.value,autocomplete:d.fieldAutocomplete.value,placeholder:e.placeholder,size:1,role:e.role,type:e.type,onFocus:k,onBlur:O,"aria-labelledby":`${v.value}-label`},Y,f),null);return a(C,null,[e.prefix&&a("span",{class:"v-text-field__prefix"},[a("span",{class:"v-text-field__prefix__text"},[e.prefix])]),me(n.default?a("div",{class:xe(N),"data-no-activator":""},[n.default({id:v}),R]):Ve(R,{class:N}),[[T,j,null,{once:!0}]]),e.suffix&&a("span",{class:"v-text-field__suffix"},[a("span",{class:"v-text-field__suffix__text"},[e.suffix])])])}})},details:l?c=>a(C,null,[n.details?.(c),t&&a(C,null,[a("span",null,null),h(oe,{active:e.persistentCounter||o.value,value:z.value,max:U.value,disabled:e.disabled},n.counter)])]):void 0})}),se({},I,S,i)}});export{ke as V,ye as m};
