import{as as j,at as D,i as q,aw as w,bZ as F,r as O,aI as W,ci as B,dm as K,c as A,b as o,w as P,e as C,E as s,f as d,a as h,q as E,u as c,ac as u,n as p,t as m,am as T,dn as U}from"./B2UyoCas.js";import{_ as Z}from"./DyQtVBit.js";const G={slots:{root:"",wrapper:"",labelWrapper:"flex content-center items-center justify-between",label:"block font-medium text-default",container:"mt-1 relative",description:"text-muted",error:"mt-2 text-error",hint:"text-muted",help:"mt-2 text-muted"},variants:{size:{xs:{root:"text-xs"},sm:{root:"text-xs"},md:{root:"text-sm"},lg:{root:"text-sm"},xl:{root:"text-base"}},required:{true:{label:"after:content-['*'] after:ms-0.5 after:text-error"}}},defaultVariants:{size:"md"}},H=["id"],J=["id"],L=["id"],R={__name:"UFormField",props:{as:{type:null,required:!1},name:{type:String,required:!1},errorPattern:{type:null,required:!1},label:{type:String,required:!1},description:{type:String,required:!1},help:{type:String,required:!1},error:{type:[String,Boolean],required:!1},hint:{type:String,required:!1},size:{type:null,required:!1},required:{type:Boolean,required:!1},eagerValidation:{type:Boolean,required:!1},validateOnInputDelay:{type:Number,required:!1},class:{type:null,required:!1},ui:{type:null,required:!1}},setup(t){const e=t,l=j(),N=D(),r=q(()=>{var a;return w({extend:w(G),...((a=N.ui)==null?void 0:a.formField)||{}})({size:e.size,required:e.required})}),v=F("form-errors",null),i=q(()=>{var a,b;return e.error||((b=(a=v==null?void 0:v.value)==null?void 0:a.find(n=>n.name&&(n.name===e.name||e.errorPattern&&n.name.match(e.errorPattern))))==null?void 0:b.message)}),y=O(W()),f=y.value;return B(U,y),B(K,q(()=>({error:i.value,name:e.name,size:e.size,eagerValidation:e.eagerValidation,validateOnInputDelay:e.validateOnInputDelay,errorPattern:e.errorPattern,hint:e.hint,description:e.description,help:e.help,ariaId:f}))),(a,b)=>{var n;return o(),A(c(T),{as:t.as,class:s(r.value.root({class:[(n=e.ui)==null?void 0:n.root,e.class]}))},{default:P(()=>{var g,x,$,k,I,S,z,V;return[C("div",{class:s(r.value.wrapper({class:(g=e.ui)==null?void 0:g.wrapper}))},[t.label||l.label?(o(),d("div",{key:0,class:s(r.value.labelWrapper({class:(x=e.ui)==null?void 0:x.labelWrapper}))},[E(c(Z),{for:y.value,class:s(r.value.label({class:($=e.ui)==null?void 0:$.label}))},{default:P(()=>[u(a.$slots,"label",{label:t.label},()=>[p(m(t.label),1)])]),_:3},8,["for","class"]),t.hint||l.hint?(o(),d("span",{key:0,id:`${c(f)}-hint`,class:s(r.value.hint({class:(k=e.ui)==null?void 0:k.hint}))},[u(a.$slots,"hint",{hint:t.hint},()=>[p(m(t.hint),1)])],10,H)):h("",!0)],2)):h("",!0),t.description||l.description?(o(),d("p",{key:1,id:`${c(f)}-description`,class:s(r.value.description({class:(I=e.ui)==null?void 0:I.description}))},[u(a.$slots,"description",{description:t.description},()=>[p(m(t.description),1)])],10,J)):h("",!0)],2),C("div",{class:s([(t.label||!!l.label||t.description||!!l.description)&&r.value.container({class:(S=e.ui)==null?void 0:S.container})])},[u(a.$slots,"default",{error:i.value}),typeof i.value=="string"&&i.value||l.error?(o(),d("div",{key:0,id:`${c(f)}-error`,class:s(r.value.error({class:(z=e.ui)==null?void 0:z.error}))},[u(a.$slots,"error",{error:i.value},()=>[p(m(i.value),1)])],10,L)):t.help||l.help?(o(),d("div",{key:1,class:s(r.value.help({class:(V=e.ui)==null?void 0:V.help}))},[u(a.$slots,"help",{help:t.help},()=>[p(m(t.help),1)])],2)):h("",!0)],2)]}),_:3},8,["as","class"])}}};export{R as _};
