import{b as tt,d as ge,I as rt,c as nt,q as it,z as Oe,A as ve,O as Lt,ae as Nt,e as Ie}from"./index-72686045.js";import{B as Rt,j as me,r as C,c as T,d as H,w as ne,E as at,M as st,Y as ot,b as ye,e as ft,g as ee,n as K,u as j,R as ut,D as ie,o as lt,J as dt,W as Bt,q as ae,F as Ct,A as ct,G as Wt,p as de,m as Vt,U as Dt,h as Me,v as Ut,x as Le,C as Ne,f as Re}from"./runtime-core.esm-bundler-67034826.js";import{z as qe,A as zt,B as pt,e as gt,r as Gt,S as Be,c as vt,u as Ee,_ as mt,C as ce,w as Kt,a as Jt}from"./base-0e92f4db.js";import{q as yt,s as Yt,x as Zt,y as Ht,z as ht,A as bt,B as Qt,m as Xt,D as kt,E as Ce,F as je,G as se,H as wt,J as er,K as tr,L as rr,f as nr,t as ir,e as ar,M as sr}from"./event-a537c4cb.js";var We=Object.create,or=function(){function r(){}return function(e){if(!qe(e))return{};if(We)return We(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}();const fr=or;function ur(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t(Rt(r)||me(r))&&nt(e)&&me(t)};function Bn(){const r=C([]),e=T(()=>{if(!r.value.length)return"0";const s=Math.max(...r.value);return s?`${s}px`:""});function t(s){const a=r.value.indexOf(s);return a===-1&&e.value,a}function n(s,a){if(s&&a){const o=t(a);r.value.splice(o,1,s)}else s&&r.value.push(s)}function i(s){const a=t(s);a>-1&&r.value.splice(a,1)}return{autoLabelWidth:e,registerLabelWidth:n,deregisterLabelWidth:i}}const X=(r,e)=>{const t=he(e);return t.length>0?r.filter(n=>n.prop&&t.includes(n.prop)):r},Cn="ElForm",Wn=H({name:Cn}),Vn=H({...Wn,props:Nn,emits:Rn,setup(r,{expose:e,emit:t}){const n=r,i=[],s=it(),a=Ee("form"),o=T(()=>{const{labelPosition:m,inline:l}=n;return[a.b(),a.m(s.value||"default"),{[a.m(`label-${m}`)]:m,[a.m("inline")]:l}]}),u=m=>{i.push(m)},w=m=>{m.prop&&i.splice(i.indexOf(m),1)},c=(m=[])=>{n.model&&X(i,m).forEach(l=>l.resetField())},g=(m=[])=>{X(i,m).forEach(l=>l.clearValidate())},b=T(()=>!!n.model),q=m=>{if(i.length===0)return[];const l=X(i,m);return l.length?l:[]},E=async m=>v(void 0,m),d=async(m=[])=>{if(!b.value)return!1;const l=q(m);if(l.length===0)return!0;let h={};for(const x of l)try{await x.validate("")}catch(O){h={...h,...O}}return Object.keys(h).length===0?!0:Promise.reject(h)},v=async(m=[],l)=>{const h=!ut(l);try{const x=await d(m);return x===!0&&(l==null||l(x)),x}catch(x){if(x instanceof Error)throw x;const O=x;return n.scrollToError&&f(Object.keys(O)[0]),l==null||l(!1,O),h&&Promise.reject(O)}},f=m=>{var l;const h=X(i,m)[0];h&&((l=h.$el)==null||l.scrollIntoView())};return ne(()=>n.rules,()=>{n.validateOnRuleChange&&E().catch(m=>nr())},{deep:!0}),at(Oe,st({...ot(n),emit:t,resetFields:c,clearValidate:g,validateField:v,addField:u,removeField:w,...Bn()})),e({validate:E,validateField:v,resetFields:c,clearValidate:g,scrollToField:f}),(m,l)=>(ye(),ft("form",{class:K(j(o))},[ee(m.$slots,"default")],2))}});var Dn=mt(Vn,[["__file","/home/runner/work/element-plus/element-plus/packages/components/form/src/form.vue"]]);function W(){return W=Object.assign?Object.assign.bind():function(r){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function re(r,e,t){return zn()?re=Reflect.construct.bind():re=function(i,s,a){var o=[null];o.push.apply(o,s);var u=Function.bind.apply(i,o),w=new u;return a&&Z(w,a.prototype),w},re.apply(null,arguments)}function Gn(r){return Function.toString.call(r).indexOf("[native code]")!==-1}function we(r){var e=typeof Map=="function"?new Map:void 0;return we=function(n){if(n===null||!Gn(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(n))return e.get(n);e.set(n,i)}function i(){return re(n,arguments,be(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Z(i,n)},we(r)}var Kn=/%[sdj%]/g,Jn=function(){};typeof process<"u"&&process.env;function Fe(r){if(!r||!r.length)return null;var e={};return r.forEach(function(t){var n=t.field;e[n]=e[n]||[],e[n].push(t)}),e}function I(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n=s)return o;switch(o){case"%s":return String(t[i++]);case"%d":return Number(t[i++]);case"%j":try{return JSON.stringify(t[i++])}catch{return"[Circular]"}break;default:return o}});return a}return r}function Yn(r){return r==="string"||r==="url"||r==="hex"||r==="email"||r==="date"||r==="pattern"}function S(r,e){return!!(r==null||e==="array"&&Array.isArray(r)&&!r.length||Yn(e)&&typeof r=="string"&&!r)}function Zn(r,e,t){var n=[],i=0,s=r.length;function a(o){n.push.apply(n,o||[]),i++,i===s&&t(n)}r.forEach(function(o){e(o,a)})}function Ze(r,e,t){var n=0,i=r.length;function s(a){if(a&&a.length){t(a);return}var o=n;n=n+1,o()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,hex:/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i},J={integer:function(e){return J.number(e)&&parseInt(e,10)===e},float:function(e){return J.number(e)&&!J.integer(e)},array:function(e){return Array.isArray(e)},regexp:function(e){if(e instanceof RegExp)return!0;try{return!!new RegExp(e)}catch{return!1}},date:function(e){return typeof e.getTime=="function"&&typeof e.getMonth=="function"&&typeof e.getYear=="function"&&!isNaN(e.getTime())},number:function(e){return isNaN(e)?!1:typeof e=="number"},object:function(e){return typeof e=="object"&&!J.array(e)},method:function(e){return typeof e=="function"},email:function(e){return typeof e=="string"&&e.length<=320&&!!e.match(ke.email)},url:function(e){return typeof e=="string"&&e.length<=2048&&!!e.match(ti())},hex:function(e){return typeof e=="string"&&!!e.match(ke.hex)}},ri=function(e,t,n,i,s){if(e.required&&t===void 0){jt(e,t,n,i,s);return}var a=["integer","float","array","regexp","object","method","email","number","date","url","hex"],o=e.type;a.indexOf(o)>-1?J[o](t)||i.push(I(s.messages.types[o],e.fullField,e.type)):o&&typeof t!==e.type&&i.push(I(s.messages.types[o],e.fullField,e.type))},ni=function(e,t,n,i,s){var a=typeof e.len=="number",o=typeof e.min=="number",u=typeof e.max=="number",w=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,c=t,g=null,b=typeof t=="number",q=typeof t=="string",E=Array.isArray(t);if(b?g="number":q?g="string":E&&(g="array"),!g)return!1;E&&(c=t.length),q&&(c=t.replace(w,"_").length),a?c!==e.len&&i.push(I(s.messages[g].len,e.fullField,e.len)):o&&!u&&ce.max?i.push(I(s.messages[g].max,e.fullField,e.max)):o&&u&&(ce.max)&&i.push(I(s.messages[g].range,e.fullField,e.min,e.max))},z="enum",ii=function(e,t,n,i,s){e[z]=Array.isArray(e[z])?e[z]:[],e[z].indexOf(t)===-1&&i.push(I(s.messages[z],e.fullField,e[z].join(", ")))},ai=function(e,t,n,i,s){if(e.pattern){if(e.pattern instanceof RegExp)e.pattern.lastIndex=0,e.pattern.test(t)||i.push(I(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if(typeof e.pattern=="string"){var a=new RegExp(e.pattern);a.test(t)||i.push(I(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}},y={required:jt,whitespace:ei,type:ri,range:ni,enum:ii,pattern:ai},si=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t,"string")&&!e.required)return n();y.required(e,t,i,a,s,"string"),S(t,"string")||(y.type(e,t,i,a,s),y.range(e,t,i,a,s),y.pattern(e,t,i,a,s),e.whitespace===!0&&y.whitespace(e,t,i,a,s))}n(a)},oi=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t)&&!e.required)return n();y.required(e,t,i,a,s),t!==void 0&&y.type(e,t,i,a,s)}n(a)},fi=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(t===""&&(t=void 0),S(t)&&!e.required)return n();y.required(e,t,i,a,s),t!==void 0&&(y.type(e,t,i,a,s),y.range(e,t,i,a,s))}n(a)},ui=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t)&&!e.required)return n();y.required(e,t,i,a,s),t!==void 0&&y.type(e,t,i,a,s)}n(a)},li=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t)&&!e.required)return n();y.required(e,t,i,a,s),S(t)||y.type(e,t,i,a,s)}n(a)},di=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t)&&!e.required)return n();y.required(e,t,i,a,s),t!==void 0&&(y.type(e,t,i,a,s),y.range(e,t,i,a,s))}n(a)},ci=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t)&&!e.required)return n();y.required(e,t,i,a,s),t!==void 0&&(y.type(e,t,i,a,s),y.range(e,t,i,a,s))}n(a)},pi=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(t==null&&!e.required)return n();y.required(e,t,i,a,s,"array"),t!=null&&(y.type(e,t,i,a,s),y.range(e,t,i,a,s))}n(a)},gi=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t)&&!e.required)return n();y.required(e,t,i,a,s),t!==void 0&&y.type(e,t,i,a,s)}n(a)},vi="enum",mi=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t)&&!e.required)return n();y.required(e,t,i,a,s),t!==void 0&&y[vi](e,t,i,a,s)}n(a)},yi=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t,"string")&&!e.required)return n();y.required(e,t,i,a,s),S(t,"string")||y.pattern(e,t,i,a,s)}n(a)},hi=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t,"date")&&!e.required)return n();if(y.required(e,t,i,a,s),!S(t,"date")){var u;t instanceof Date?u=t:u=new Date(t),y.type(e,u,i,a,s),u&&y.range(e,u.getTime(),i,a,s)}}n(a)},bi=function(e,t,n,i,s){var a=[],o=Array.isArray(t)?"array":typeof t;y.required(e,t,i,a,s,o),n(a)},pe=function(e,t,n,i,s){var a=e.type,o=[],u=e.required||!e.required&&i.hasOwnProperty(e.field);if(u){if(S(t,a)&&!e.required)return n();y.required(e,t,i,o,s,a),S(t,a)||y.type(e,t,i,o,s)}n(o)},wi=function(e,t,n,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(S(t)&&!e.required)return n();y.required(e,t,i,a,s)}n(a)},Y={string:si,method:oi,number:fi,boolean:ui,regexp:li,integer:di,float:ci,array:pi,object:gi,enum:mi,pattern:yi,date:hi,url:pe,hex:pe,email:pe,required:bi,any:wi};function xe(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone:function(){var e=JSON.parse(JSON.stringify(this));return e.clone=this.clone,e}}}var Ae=xe(),Q=function(){function r(t){this.rules=null,this._messages=Ae,this.define(t)}var e=r.prototype;return e.define=function(n){var i=this;if(!n)throw new Error("Cannot configure a schema with no rules");if(typeof n!="object"||Array.isArray(n))throw new Error("Rules must be an object");this.rules={},Object.keys(n).forEach(function(s){var a=n[s];i.rules[s]=Array.isArray(a)?a:[a]})},e.messages=function(n){return n&&(this._messages=Xe(xe(),n)),this._messages},e.validate=function(n,i,s){var a=this;i===void 0&&(i={}),s===void 0&&(s=function(){});var o=n,u=i,w=s;if(typeof u=="function"&&(w=u,u={}),!this.rules||Object.keys(this.rules).length===0)return w&&w(null,o),Promise.resolve(o);function c(d){var v=[],f={};function m(h){if(Array.isArray(h)){var x;v=(x=v).concat.apply(x,h)}else v.push(h)}for(var l=0;l");const i=Ee("form"),s=C(),a=C(0),o=()=>{var c;if((c=s.value)!=null&&c.firstElementChild){const g=window.getComputedStyle(s.value.firstElementChild).width;return Math.ceil(Number.parseFloat(g))}else return 0},u=(c="update")=>{ct(()=>{e.default&&r.isAutoWidth&&(c==="update"?a.value=o():c==="remove"&&(t==null||t.deregisterLabelWidth(a.value)))})},w=()=>u("update");return lt(()=>{w()}),dt(()=>{u("remove")}),Bt(()=>w()),ne(a,(c,g)=>{r.updateAll&&(t==null||t.registerLabelWidth(c,g))}),ar(T(()=>{var c,g;return(g=(c=s.value)==null?void 0:c.firstElementChild)!=null?g:null}),w),()=>{var c,g;if(!e)return null;const{isAutoWidth:b}=r;if(b){const q=t==null?void 0:t.autoLabelWidth,E=n==null?void 0:n.hasLabel,d={};if(E&&q&&q!=="auto"){const v=Math.max(0,Number.parseInt(q,10)-a.value),f=t.labelPosition==="left"?"marginRight":"marginLeft";v&&(d[f]=`${v}px`)}return ae("div",{ref:s,class:[i.be("item","label-wrap")],style:d},[(c=e.default)==null?void 0:c.call(e)])}else return ae(Ct,{ref:s},[(g=e.default)==null?void 0:g.call(e)])}}});const Oi=["role","aria-labelledby"],qi=H({name:"ElFormItem"}),Ei=H({...qi,props:xi,setup(r,{expose:e}){const t=r,n=Wt(),i=ie(Oe,void 0),s=ie(ve,void 0),a=it(void 0,{formItem:!1}),o=Ee("form-item"),u=Lt().value,w=C([]),c=C(""),g=Nt(c,100),b=C(""),q=C();let E,d=!1;const v=T(()=>{if((i==null?void 0:i.labelPosition)==="top")return{};const p=Ie(t.labelWidth||(i==null?void 0:i.labelWidth)||"");return p?{width:p}:{}}),f=T(()=>{if((i==null?void 0:i.labelPosition)==="top"||i!=null&&i.inline)return{};if(!t.label&&!t.labelWidth&&B)return{};const p=Ie(t.labelWidth||(i==null?void 0:i.labelWidth)||"");return!t.label&&!n.label?{marginLeft:p}:{}}),m=T(()=>[o.b(),o.m(a.value),o.is("error",c.value==="error"),o.is("validating",c.value==="validating"),o.is("success",c.value==="success"),o.is("required",fe.value||t.required),o.is("no-asterisk",i==null?void 0:i.hideRequiredAsterisk),(i==null?void 0:i.requireAsteriskPosition)==="right"?"asterisk-right":"asterisk-left",{[o.m("feedback")]:i==null?void 0:i.statusIcon}]),l=T(()=>nt(t.inlineMessage)?t.inlineMessage:(i==null?void 0:i.inlineMessage)||!1),h=T(()=>[o.e("error"),{[o.em("error","inline")]:l.value}]),x=T(()=>t.prop?me(t.prop)?t.prop:t.prop.join("."):""),O=T(()=>!!(t.label||n.label)),L=T(()=>t.for||w.value.length===1?w.value[0]:void 0),$=T(()=>!L.value&&O.value),B=!!s,G=T(()=>{const p=i==null?void 0:i.model;if(!(!p||!t.prop))return ce(p,t.prop).value}),V=T(()=>{const{required:p}=t,F=[];t.rules&&F.push(...he(t.rules));const P=i==null?void 0:i.rules;if(P&&t.prop){const _=ce(P,t.prop).value;_&&F.push(...he(_))}if(p!==void 0){const _=F.map((R,U)=>[R,U]).filter(([R])=>Object.keys(R).includes("required"));if(_.length>0)for(const[R,U]of _)R.required!==p&&(F[U]={...R,required:p});else F.push({required:p})}return F}),N=T(()=>V.value.length>0),M=p=>V.value.filter(P=>!P.trigger||!p?!0:Array.isArray(P.trigger)?P.trigger.includes(p):P.trigger===p).map(({trigger:P,..._})=>_),fe=T(()=>V.value.some(p=>p.required)),St=T(()=>{var p;return g.value==="error"&&t.showMessage&&((p=i==null?void 0:i.showMessage)!=null?p:!0)}),_e=T(()=>`${t.label||""}${(i==null?void 0:i.labelSuffix)||""}`),D=p=>{c.value=p},_t=p=>{var F,P;const{errors:_,fields:R}=p;(!_||!R)&&console.error(p),D("error"),b.value=_?(P=(F=_==null?void 0:_[0])==null?void 0:F.message)!=null?P:`${t.prop} is required`:"",i==null||i.emit("validate",t.prop,!1,b.value)},Pt=()=>{D("success"),i==null||i.emit("validate",t.prop,!0,"")},$t=async p=>{const F=x.value;return new Q({[F]:p}).validate({[F]:G.value},{firstFields:!0}).then(()=>(Pt(),!0)).catch(_=>(_t(_),Promise.reject(_)))},Pe=async(p,F)=>{if(d||!t.prop)return!1;const P=ut(F);if(!N.value)return F==null||F(!1),!1;const _=M(p);return _.length===0?(F==null||F(!0),!0):(D("validating"),$t(_).then(()=>(F==null||F(!0),!0)).catch(R=>{const{fields:U}=R;return F==null||F(!1,U),P?!1:Promise.reject(U)}))},ue=()=>{D(""),b.value="",d=!1},$e=async()=>{const p=i==null?void 0:i.model;if(!p||!t.prop)return;const F=ce(p,t.prop);d=!0,F.value=Ye(E),await ct(),ue(),d=!1},It=p=>{w.value.includes(p)||w.value.push(p)},Mt=p=>{w.value=w.value.filter(F=>F!==p)};ne(()=>t.error,p=>{b.value=p||"",D(p?"error":"")},{immediate:!0}),ne(()=>t.validateStatus,p=>D(p||""));const le=st({...ot(t),$el:q,size:a,validateState:c,labelId:u,inputIds:w,isGroup:$,hasLabel:O,addInputId:It,removeInputId:Mt,resetField:$e,clearValidate:ue,validate:Pe});return at(ve,le),lt(()=>{t.prop&&(i==null||i.addField(le),E=Ye(G.value))}),dt(()=>{i==null||i.removeField(le)}),e({size:a,validateMessage:b,validateState:c,validate:Pe,clearValidate:ue,resetField:$e}),(p,F)=>{var P;return ye(),ft("div",{ref_key:"formItemRef",ref:q,class:K(j(m)),role:j($)?"group":void 0,"aria-labelledby":j($)?j(u):void 0},[ae(j(Ai),{"is-auto-width":j(v).width==="auto","update-all":((P=j(i))==null?void 0:P.labelWidth)==="auto"},{default:de(()=>[j(O)?(ye(),Vt(Dt(j(L)?"label":"div"),{key:0,id:j(u),for:j(L),class:K(j(o).e("label")),style:Me(j(v))},{default:de(()=>[ee(p.$slots,"label",{label:j(_e)},()=>[Ut(Le(j(_e)),1)])]),_:3},8,["id","for","class","style"])):Ne("v-if",!0)]),_:3},8,["is-auto-width","update-all"]),Re("div",{class:K(j(o).e("content")),style:Me(j(f))},[ee(p.$slots,"default"),ae(sr,{name:`${j(o).namespace.value}-zoom-in-top`},{default:de(()=>[j(St)?ee(p.$slots,"error",{key:0,error:b.value},()=>[Re("div",{class:K(j(h))},Le(b.value),3)]):Ne("v-if",!0)]),_:3},8,["name"])],6)],10,Oi)}}});var Tt=mt(Ei,[["__file","/home/runner/work/element-plus/element-plus/packages/components/form/src/form-item.vue"]]);const Pi=Kt(Dn,{FormItem:Tt}),$i=Jt(Tt);export{Pi as E,$i as a,oe as b,he as c,ur as d,br as e,$r as f,Ft as g,te as h,kr as i,Te as k};