You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

12 lines
26 KiB

import{aG as st,ap as ot,ac as Te,e as Fe,f as te,ay as Ce,k as De,a6 as ze,l as qe,aH as xe,ab as ft,aI as ce,$ as lt,aJ as ut,X as dt,aK as ct,ad as Pe,aL as le,w as pt,s as vt}from"./index.1762932289438.js";import{b as re,a as Ae,r as L,c as E,k as H,R as pe,t as ne,p as Ue,a3 as Ge,l as Je,o as ve,m as Q,E as G,u as x,f as Ke,i as ie,s as Ze,O as He,U as mt,J as ae,F as gt,A as Ye,C as ht,q as Se,H as ue,G as yt,D as je,I as bt,M as Re,V as wt,L as Ve,al as Ft}from"./vue.1762932289438.js";function me(){if(!arguments.length)return[];var i=arguments[0];return st(i)?i:[i]}var qt=4;function Me(i){return ot(i,qt)}const xt=Fe({size:{type:String,values:Ce},disabled:Boolean}),Ot=Fe({...xt,model:Object,rules:{type:te(Object)},labelPosition:{type:String,values:["left","right","top"],default:"right"},requireAsteriskPosition:{type:String,values:["left","right"],default:"left"},labelWidth:{type:[String,Number],default:""},labelSuffix:{type:String,default:""},inline:Boolean,inlineMessage:Boolean,statusIcon:Boolean,showMessage:{type:Boolean,default:!0},validateOnRuleChange:{type:Boolean,default:!0},hideRequiredAsterisk:Boolean,scrollToError:Boolean,scrollIntoViewOptions:{type:te([Object,Boolean]),default:!0}}),Et={validate:(i,e,t)=>(re(i)||Ae(i))&&Te(e)&&Ae(t)};function _t(){const i=L([]),e=E(()=>{if(!i.value.length)return"0";const a=Math.max(...i.value);return a?`${a}px`:""});function t(a){const s=i.value.indexOf(a);return s===-1&&e.value,s}function r(a,s){if(a&&s){const o=t(s);i.value.splice(o,1,a)}else a&&i.value.push(a)}function n(a){const s=t(a);s>-1&&i.value.splice(s,1)}return{autoLabelWidth:e,registerLabelWidth:r,deregisterLabelWidth:n}}const X=(i,e)=>{const t=me(e).map(r=>re(r)?r.join("."):r);return t.length>0?i.filter(r=>r.propString&&t.includes(r.propString)):i},Pt="ElForm",At=H({name:Pt}),St=H({...At,props:Ot,emits:Et,setup(i,{expose:e,emit:t}){const r=i,n=L(),a=pe([]),s=ze(),o=qe("form"),u=E(()=>{const{labelPosition:l,inline:m}=r;return[o.b(),o.m(s.value||"default"),{[o.m(`label-${l}`)]:l,[o.m("inline")]:m}]}),w=l=>X(a,[l])[0],p=l=>{a.push(l)},h=l=>{l.prop&&a.splice(a.indexOf(l),1)},F=(l=[])=>{r.model&&X(a,l).forEach(m=>m.resetField())},O=(l=[])=>{X(a,l).forEach(m=>m.clearValidate())},A=E(()=>!!r.model),c=l=>{if(a.length===0)return[];const m=X(a,l);return m.length?m:[]},y=async l=>R(void 0,l),f=async(l=[])=>{if(!A.value)return!1;const m=c(l);if(m.length===0)return!0;let b={};for(const S of m)try{await S.validate(""),S.validateState==="error"&&!S.error&&S.resetField()}catch(_){b={...b,..._}}return Object.keys(b).length===0?!0:Promise.reject(b)},R=async(l=[],m)=>{let b=!1;const S=!Ke(m);try{return b=await f(l),b===!0&&await(m==null?void 0:m(b)),b}catch(_){if(_ instanceof Error)throw _;const I=_;if(r.scrollToError&&n.value){const B=n.value.querySelector(`.${o.b()}-item.is-error`);B==null||B.scrollIntoView(r.scrollIntoViewOptions)}return!b&&await(m==null?void 0:m(!1,I)),S&&Promise.reject(I)}},v=l=>{var m;const b=w(l);b&&((m=b.$el)==null||m.scrollIntoView(r.scrollIntoViewOptions))};return ne(()=>r.rules,()=>{r.validateOnRuleChange&&y().catch(l=>ft())},{deep:!0,flush:"post"}),Ue(xe,pe({...Ge(r),emit:t,resetFields:F,clearValidate:O,validateField:R,getField:w,addField:p,removeField:h,..._t()})),e({validate:y,validateField:R,resetFields:F,clearValidate:O,scrollToField:v,getField:w,fields:a}),(l,m)=>(ve(),Je("form",{ref_key:"formRef",ref:n,class:G(x(u))},[Q(l.$slots,"default")],2))}});var jt=De(St,[["__file","form.vue"]]);function T(){return T=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},T.apply(this,arguments)}function Rt(i,e){i.prototype=Object.create(e.prototype),i.prototype.constructor=i,Z(i,e)}function ge(i){return ge=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ge(i)}function Z(i,e){return Z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},Z(i,e)}function Vt(){if(typeof Reflect>"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 ee(i,e,t){return Vt()?ee=Reflect.construct.bind():ee=function(n,a,s){var o=[null];o.push.apply(o,a);var u=Function.bind.apply(n,o),w=new u;return s&&Z(w,s.prototype),w},ee.apply(null,arguments)}function Mt(i){return Function.toString.call(i).indexOf("[native code]")!==-1}function he(i){var e=typeof Map=="function"?new Map:void 0;return he=function(r){if(r===null||!Mt(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,n)}function n(){return ee(r,arguments,ge(this).constructor)}return n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Z(n,r)},he(i)}var Nt=/%[sdj%]/g,It=function(){};function ye(i){if(!i||!i.length)return null;var e={};return i.forEach(function(t){var r=t.field;e[r]=e[r]||[],e[r].push(t)}),e}function N(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];var n=0,a=t.length;if(typeof i=="function")return i.apply(null,t);if(typeof i=="string"){var s=i.replace(Nt,function(o){if(o==="%%")return"%";if(n>=a)return o;switch(o){case"%s":return String(t[n++]);case"%d":return Number(t[n++]);case"%j":try{return JSON.stringify(t[n++])}catch{return"[Circular]"}break;default:return o}});return s}return i}function Wt(i){return i==="string"||i==="url"||i==="hex"||i==="email"||i==="date"||i==="pattern"}function P(i,e){return!!(i==null||e==="array"&&Array.isArray(i)&&!i.length||Wt(e)&&typeof i=="string"&&!i)}function $t(i,e,t){var r=[],n=0,a=i.length;function s(o){r.push.apply(r,o||[]),n++,n===a&&t(r)}i.forEach(function(o){e(o,s)})}function Ne(i,e,t){var r=0,n=i.length;function a(s){if(s&&s.length){t(s);return}var o=r;r=r+1,o<n?e(i[o],a):t([])}a([])}function Lt(i){var e=[];return Object.keys(i).forEach(function(t){e.push.apply(e,i[t]||[])}),e}var Ie=function(i){Rt(e,i);function e(t,r){var n;return n=i.call(this,"Async Validation Error")||this,n.errors=t,n.fields=r,n}return e}(he(Error));function Bt(i,e,t,r,n){if(e.first){var a=new Promise(function(F,O){var A=function(f){return r(f),f.length?O(new Ie(f,ye(f))):F(n)},c=Lt(i);Ne(c,t,A)});return a.catch(function(F){return F}),a}var s=e.firstFields===!0?Object.keys(i):e.firstFields||[],o=Object.keys(i),u=o.length,w=0,p=[],h=new Promise(function(F,O){var A=function(y){if(p.push.apply(p,y),w++,w===u)return r(p),p.length?O(new Ie(p,ye(p))):F(n)};o.length||(r(p),F(n)),o.forEach(function(c){var y=i[c];s.indexOf(c)!==-1?Ne(y,t,A):$t(y,t,A)})});return h.catch(function(F){return F}),h}function Tt(i){return!!(i&&i.message!==void 0)}function Ct(i,e){for(var t=i,r=0;r<e.length;r++){if(t==null)return t;t=t[e[r]]}return t}function We(i,e){return function(t){var r;return i.fullFields?r=Ct(e,i.fullFields):r=e[t.field||i.fullField],Tt(t)?(t.field=t.field||i.fullField,t.fieldValue=r,t):{message:typeof t=="function"?t():t,fieldValue:r,field:t.field||i.fullField}}}function $e(i,e){if(e){for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];typeof r=="object"&&typeof i[t]=="object"?i[t]=T({},i[t],r):i[t]=r}}return i}var Xe=function(e,t,r,n,a,s){e.required&&(!r.hasOwnProperty(e.field)||P(t,s||e.type))&&n.push(N(a.messages.required,e.fullField))},Dt=function(e,t,r,n,a){(/^\s+$/.test(t)||t==="")&&n.push(N(a.messages.whitespace,e.fullField))},k,zt=function(){if(k)return k;var i="[a-fA-F\\d:]",e=function(l){return l&&l.includeBoundaries?"(?:(?<=\\s|^)(?="+i+")|(?<="+i+")(?=\\s|$))":""},t="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",r="[a-fA-F\\d]{1,4}",n=(`
(?:
(?:`+r+":){7}(?:"+r+`|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
(?:`+r+":){6}(?:"+t+"|:"+r+`|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
(?:`+r+":){5}(?::"+t+"|(?::"+r+`){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
(?:`+r+":){4}(?:(?::"+r+"){0,1}:"+t+"|(?::"+r+`){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
(?:`+r+":){3}(?:(?::"+r+"){0,2}:"+t+"|(?::"+r+`){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
(?:`+r+":){2}(?:(?::"+r+"){0,3}:"+t+"|(?::"+r+`){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
(?:`+r+":){1}(?:(?::"+r+"){0,4}:"+t+"|(?::"+r+`){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
(?::(?:(?::`+r+"){0,5}:"+t+"|(?::"+r+`){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
`).replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),a=new RegExp("(?:^"+t+"$)|(?:^"+n+"$)"),s=new RegExp("^"+t+"$"),o=new RegExp("^"+n+"$"),u=function(l){return l&&l.exact?a:new RegExp("(?:"+e(l)+t+e(l)+")|(?:"+e(l)+n+e(l)+")","g")};u.v4=function(v){return v&&v.exact?s:new RegExp(""+e(v)+t+e(v),"g")},u.v6=function(v){return v&&v.exact?o:new RegExp(""+e(v)+n+e(v),"g")};var w="(?:(?:[a-z]+:)?//)",p="(?:\\S+(?::\\S*)?@)?",h=u.v4().source,F=u.v6().source,O="(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)",A="(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*",c="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))",y="(?::\\d{2,5})?",f='(?:[/?#][^\\s"]*)?',R="(?:"+w+"|www\\.)"+p+"(?:localhost|"+h+"|"+F+"|"+O+A+c+")"+y+f;return k=new RegExp("(?:^"+R+"$)","i"),k},Le={email:/^(([^<>()\[\]\\.,;:\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(Le.email)},url:function(e){return typeof e=="string"&&e.length<=2048&&!!e.match(zt())},hex:function(e){return typeof e=="string"&&!!e.match(Le.hex)}},Ut=function(e,t,r,n,a){if(e.required&&t===void 0){Xe(e,t,r,n,a);return}var s=["integer","float","array","regexp","object","method","email","number","date","url","hex"],o=e.type;s.indexOf(o)>-1?J[o](t)||n.push(N(a.messages.types[o],e.fullField,e.type)):o&&typeof t!==e.type&&n.push(N(a.messages.types[o],e.fullField,e.type))},Gt=function(e,t,r,n,a){var s=typeof e.len=="number",o=typeof e.min=="number",u=typeof e.max=="number",w=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,p=t,h=null,F=typeof t=="number",O=typeof t=="string",A=Array.isArray(t);if(F?h="number":O?h="string":A&&(h="array"),!h)return!1;A&&(p=t.length),O&&(p=t.replace(w,"_").length),s?p!==e.len&&n.push(N(a.messages[h].len,e.fullField,e.len)):o&&!u&&p<e.min?n.push(N(a.messages[h].min,e.fullField,e.min)):u&&!o&&p>e.max?n.push(N(a.messages[h].max,e.fullField,e.max)):o&&u&&(p<e.min||p>e.max)&&n.push(N(a.messages[h].range,e.fullField,e.min,e.max))},U="enum",Jt=function(e,t,r,n,a){e[U]=Array.isArray(e[U])?e[U]:[],e[U].indexOf(t)===-1&&n.push(N(a.messages[U],e.fullField,e[U].join(", ")))},Kt=function(e,t,r,n,a){if(e.pattern){if(e.pattern instanceof RegExp)e.pattern.lastIndex=0,e.pattern.test(t)||n.push(N(a.messages.pattern.mismatch,e.fullField,t,e.pattern));else if(typeof e.pattern=="string"){var s=new RegExp(e.pattern);s.test(t)||n.push(N(a.messages.pattern.mismatch,e.fullField,t,e.pattern))}}},g={required:Xe,whitespace:Dt,type:Ut,range:Gt,enum:Jt,pattern:Kt},Zt=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t,"string")&&!e.required)return r();g.required(e,t,n,s,a,"string"),P(t,"string")||(g.type(e,t,n,s,a),g.range(e,t,n,s,a),g.pattern(e,t,n,s,a),e.whitespace===!0&&g.whitespace(e,t,n,s,a))}r(s)},Ht=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return r();g.required(e,t,n,s,a),t!==void 0&&g.type(e,t,n,s,a)}r(s)},Yt=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(t===""&&(t=void 0),P(t)&&!e.required)return r();g.required(e,t,n,s,a),t!==void 0&&(g.type(e,t,n,s,a),g.range(e,t,n,s,a))}r(s)},Xt=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return r();g.required(e,t,n,s,a),t!==void 0&&g.type(e,t,n,s,a)}r(s)},kt=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return r();g.required(e,t,n,s,a),P(t)||g.type(e,t,n,s,a)}r(s)},Qt=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return r();g.required(e,t,n,s,a),t!==void 0&&(g.type(e,t,n,s,a),g.range(e,t,n,s,a))}r(s)},er=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return r();g.required(e,t,n,s,a),t!==void 0&&(g.type(e,t,n,s,a),g.range(e,t,n,s,a))}r(s)},tr=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(t==null&&!e.required)return r();g.required(e,t,n,s,a,"array"),t!=null&&(g.type(e,t,n,s,a),g.range(e,t,n,s,a))}r(s)},rr=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return r();g.required(e,t,n,s,a),t!==void 0&&g.type(e,t,n,s,a)}r(s)},nr="enum",ir=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return r();g.required(e,t,n,s,a),t!==void 0&&g[nr](e,t,n,s,a)}r(s)},ar=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t,"string")&&!e.required)return r();g.required(e,t,n,s,a),P(t,"string")||g.pattern(e,t,n,s,a)}r(s)},sr=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t,"date")&&!e.required)return r();if(g.required(e,t,n,s,a),!P(t,"date")){var u;t instanceof Date?u=t:u=new Date(t),g.type(e,u,n,s,a),u&&g.range(e,u.getTime(),n,s,a)}}r(s)},or=function(e,t,r,n,a){var s=[],o=Array.isArray(t)?"array":typeof t;g.required(e,t,n,s,a,o),r(s)},de=function(e,t,r,n,a){var s=e.type,o=[],u=e.required||!e.required&&n.hasOwnProperty(e.field);if(u){if(P(t,s)&&!e.required)return r();g.required(e,t,n,o,a,s),P(t,s)||g.type(e,t,n,o,a)}r(o)},fr=function(e,t,r,n,a){var s=[],o=e.required||!e.required&&n.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return r();g.required(e,t,n,s,a)}r(s)},K={string:Zt,method:Ht,number:Yt,boolean:Xt,regexp:kt,integer:Qt,float:er,array:tr,object:rr,enum:ir,pattern:ar,date:sr,url:de,hex:de,email:de,required:or,any:fr};function be(){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 we=be(),Y=function(){function i(t){this.rules=null,this._messages=we,this.define(t)}var e=i.prototype;return e.define=function(r){var n=this;if(!r)throw new Error("Cannot configure a schema with no rules");if(typeof r!="object"||Array.isArray(r))throw new Error("Rules must be an object");this.rules={},Object.keys(r).forEach(function(a){var s=r[a];n.rules[a]=Array.isArray(s)?s:[s]})},e.messages=function(r){return r&&(this._messages=$e(be(),r)),this._messages},e.validate=function(r,n,a){var s=this;n===void 0&&(n={}),a===void 0&&(a=function(){});var o=r,u=n,w=a;if(typeof u=="function"&&(w=u,u={}),!this.rules||Object.keys(this.rules).length===0)return w&&w(null,o),Promise.resolve(o);function p(c){var y=[],f={};function R(l){if(Array.isArray(l)){var m;y=(m=y).concat.apply(m,l)}else y.push(l)}for(var v=0;v<c.length;v++)R(c[v]);y.length?(f=ye(y),w(y,f)):w(null,o)}if(u.messages){var h=this.messages();h===we&&(h=be()),$e(h,u.messages),u.messages=h}else u.messages=this.messages();var F={},O=u.keys||Object.keys(this.rules);O.forEach(function(c){var y=s.rules[c],f=o[c];y.forEach(function(R){var v=R;typeof v.transform=="function"&&(o===r&&(o=T({},o)),f=o[c]=v.transform(f)),typeof v=="function"?v={validator:v}:v=T({},v),v.validator=s.getValidationMethod(v),v.validator&&(v.field=c,v.fullField=v.fullField||c,v.type=s.getType(v),F[c]=F[c]||[],F[c].push({rule:v,value:f,source:o,field:c}))})});var A={};return Bt(F,u,function(c,y){var f=c.rule,R=(f.type==="object"||f.type==="array")&&(typeof f.fields=="object"||typeof f.defaultField=="object");R=R&&(f.required||!f.required&&c.value),f.field=c.field;function v(b,S){return T({},S,{fullField:f.fullField+"."+b,fullFields:f.fullFields?[].concat(f.fullFields,[b]):[b]})}function l(b){b===void 0&&(b=[]);var S=Array.isArray(b)?b:[b];!u.suppressWarning&&S.length&&i.warning("async-validator:",S),S.length&&f.message!==void 0&&(S=[].concat(f.message));var _=S.map(We(f,o));if(u.first&&_.length)return A[f.field]=1,y(_);if(!R)y(_);else{if(f.required&&!c.value)return f.message!==void 0?_=[].concat(f.message).map(We(f,o)):u.error&&(_=[u.error(f,N(u.messages.required,f.field))]),y(_);var I={};f.defaultField&&Object.keys(c.value).map(function(M){I[M]=f.defaultField}),I=T({},I,c.rule.fields);var B={};Object.keys(I).forEach(function(M){var W=I[M],se=Array.isArray(W)?W:[W];B[M]=se.map(v.bind(null,M))});var C=new i(B);C.messages(u.messages),c.rule.options&&(c.rule.options.messages=u.messages,c.rule.options.error=u.error),C.validate(c.value,c.rule.options||u,function(M){var W=[];_&&_.length&&W.push.apply(W,_),M&&M.length&&W.push.apply(W,M),y(W.length?W:null)})}}var m;if(f.asyncValidator)m=f.asyncValidator(f,c.value,l,c.source,u);else if(f.validator){try{m=f.validator(f,c.value,l,c.source,u)}catch(b){console.error==null||console.error(b),u.suppressValidatorError||setTimeout(function(){throw b},0),l(b.message)}m===!0?l():m===!1?l(typeof f.message=="function"?f.message(f.fullField||f.field):f.message||(f.fullField||f.field)+" fails"):m instanceof Array?l(m):m instanceof Error&&l(m.message)}m&&m.then&&m.then(function(){return l()},function(b){return l(b)})},function(c){p(c)},o)},e.getType=function(r){if(r.type===void 0&&r.pattern instanceof RegExp&&(r.type="pattern"),typeof r.validator!="function"&&r.type&&!K.hasOwnProperty(r.type))throw new Error(N("Unknown rule type %s",r.type));return r.type||"string"},e.getValidationMethod=function(r){if(typeof r.validator=="function")return r.validator;var n=Object.keys(r),a=n.indexOf("message");return a!==-1&&n.splice(a,1),n.length===1&&n[0]==="required"?K.required:K[this.getType(r)]||void 0},i}();Y.register=function(e,t){if(typeof t!="function")throw new Error("Cannot register a validator by type, validator is not a function");K[e]=t};Y.warning=It;Y.messages=we;Y.validators=K;const lr=["","error","validating","success"],ur=Fe({label:String,labelWidth:{type:[String,Number],default:""},labelPosition:{type:String,values:["left","right","top",""],default:""},prop:{type:te([String,Array])},required:{type:Boolean,default:void 0},rules:{type:te([Object,Array])},error:String,validateStatus:{type:String,values:lr},for:String,inlineMessage:{type:[String,Boolean],default:""},showMessage:{type:Boolean,default:!0},size:{type:String,values:Ce}}),Be="ElLabelWrap";var dr=H({name:Be,props:{isAutoWidth:Boolean,updateAll:Boolean},setup(i,{slots:e}){const t=ie(xe,void 0),r=ie(ce);r||lt(Be,"usage: <el-form-item><label-wrap /></el-form-item>");const n=qe("form"),a=L(),s=L(0),o=()=>{var p;if((p=a.value)!=null&&p.firstElementChild){const h=window.getComputedStyle(a.value.firstElementChild).width;return Math.ceil(Number.parseFloat(h))}else return 0},u=(p="update")=>{Ye(()=>{e.default&&i.isAutoWidth&&(p==="update"?s.value=o():p==="remove"&&(t==null||t.deregisterLabelWidth(s.value)))})},w=()=>u("update");return Ze(()=>{w()}),He(()=>{u("remove")}),mt(()=>w()),ne(s,(p,h)=>{i.updateAll&&(t==null||t.registerLabelWidth(p,h))}),ut(E(()=>{var p,h;return(h=(p=a.value)==null?void 0:p.firstElementChild)!=null?h:null}),w),()=>{var p,h;if(!e)return null;const{isAutoWidth:F}=i;if(F){const O=t==null?void 0:t.autoLabelWidth,A=r==null?void 0:r.hasLabel,c={};if(A&&O&&O!=="auto"){const y=Math.max(0,Number.parseInt(O,10)-s.value),R=(r.labelPosition||t.labelPosition)==="left"?"marginRight":"marginLeft";y&&(c[R]=`${y}px`)}return ae("div",{ref:a,class:[n.be("item","label-wrap")],style:c},[(p=e.default)==null?void 0:p.call(e)])}else return ae(gt,{ref:a},[(h=e.default)==null?void 0:h.call(e)])}}});const cr=H({name:"ElFormItem"}),pr=H({...cr,props:ur,setup(i,{expose:e}){const t=i,r=ht(),n=ie(xe,void 0),a=ie(ce,void 0),s=ze(void 0,{formItem:!1}),o=qe("form-item"),u=dt().value,w=L([]),p=L(""),h=ct(p,100),F=L(""),O=L();let A,c=!1;const y=E(()=>t.labelPosition||(n==null?void 0:n.labelPosition)),f=E(()=>{if(y.value==="top")return{};const d=Pe(t.labelWidth||(n==null?void 0:n.labelWidth)||"");return d?{width:d}:{}}),R=E(()=>{if(y.value==="top"||n!=null&&n.inline)return{};if(!t.label&&!t.labelWidth&&B)return{};const d=Pe(t.labelWidth||(n==null?void 0:n.labelWidth)||"");return!t.label&&!r.label?{marginLeft:d}:{}}),v=E(()=>[o.b(),o.m(s.value),o.is("error",p.value==="error"),o.is("validating",p.value==="validating"),o.is("success",p.value==="success"),o.is("required",Qe.value||t.required),o.is("no-asterisk",n==null?void 0:n.hideRequiredAsterisk),(n==null?void 0:n.requireAsteriskPosition)==="right"?"asterisk-right":"asterisk-left",{[o.m("feedback")]:n==null?void 0:n.statusIcon,[o.m(`label-${y.value}`)]:y.value}]),l=E(()=>Te(t.inlineMessage)?t.inlineMessage:(n==null?void 0:n.inlineMessage)||!1),m=E(()=>[o.e("error"),{[o.em("error","inline")]:l.value}]),b=E(()=>t.prop?re(t.prop)?t.prop.join("."):t.prop:""),S=E(()=>!!(t.label||r.label)),_=E(()=>{var d;return(d=t.for)!=null?d:w.value.length===1?w.value[0]:void 0}),I=E(()=>!_.value&&S.value),B=!!a,C=E(()=>{const d=n==null?void 0:n.model;if(!(!d||!t.prop))return le(d,t.prop).value}),M=E(()=>{const{required:d}=t,q=[];t.rules&&q.push(...me(t.rules));const V=n==null?void 0:n.rules;if(V&&t.prop){const j=le(V,t.prop).value;j&&q.push(...me(j))}if(d!==void 0){const j=q.map(($,z)=>[$,z]).filter(([$])=>Object.keys($).includes("required"));if(j.length>0)for(const[$,z]of j)$.required!==d&&(q[z]={...$,required:d});else q.push({required:d})}return q}),W=E(()=>M.value.length>0),se=d=>M.value.filter(V=>!V.trigger||!d?!0:re(V.trigger)?V.trigger.includes(d):V.trigger===d).map(({trigger:V,...j})=>j),Qe=E(()=>M.value.some(d=>d.required)),et=E(()=>{var d;return h.value==="error"&&t.showMessage&&((d=n==null?void 0:n.showMessage)!=null?d:!0)}),Oe=E(()=>`${t.label||""}${(n==null?void 0:n.labelSuffix)||""}`),D=d=>{p.value=d},tt=d=>{var q,V;const{errors:j,fields:$}=d;(!j||!$)&&console.error(d),D("error"),F.value=j?(V=(q=j==null?void 0:j[0])==null?void 0:q.message)!=null?V:`${t.prop} is required`:"",n==null||n.emit("validate",t.prop,!1,F.value)},rt=()=>{D("success"),n==null||n.emit("validate",t.prop,!0,"")},nt=async d=>{const q=b.value;return new Y({[q]:d}).validate({[q]:C.value},{firstFields:!0}).then(()=>(rt(),!0)).catch(j=>(tt(j),Promise.reject(j)))},Ee=async(d,q)=>{if(c||!t.prop)return!1;const V=Ke(q);if(!W.value)return q==null||q(!1),!1;const j=se(d);return j.length===0?(q==null||q(!0),!0):(D("validating"),nt(j).then(()=>(q==null||q(!0),!0)).catch($=>{const{fields:z}=$;return q==null||q(!1,z),V?!1:Promise.reject(z)}))},oe=()=>{D(""),F.value="",c=!1},_e=async()=>{const d=n==null?void 0:n.model;if(!d||!t.prop)return;const q=le(d,t.prop);c=!0,q.value=Me(A),await Ye(),oe(),c=!1},it=d=>{w.value.includes(d)||w.value.push(d)},at=d=>{w.value=w.value.filter(q=>q!==d)};ne(()=>t.error,d=>{F.value=d||"",D(d?"error":"")},{immediate:!0}),ne(()=>t.validateStatus,d=>D(d||""));const fe=pe({...Ge(t),$el:O,size:s,validateMessage:F,validateState:p,labelId:u,inputIds:w,isGroup:I,hasLabel:S,fieldValue:C,addInputId:it,removeInputId:at,resetField:_e,clearValidate:oe,validate:Ee,propString:b});return Ue(ce,fe),Ze(()=>{t.prop&&(n==null||n.addField(fe),A=Me(C.value))}),He(()=>{n==null||n.removeField(fe)}),e({size:s,validateMessage:F,validateState:p,validate:Ee,clearValidate:oe,resetField:_e}),(d,q)=>{var V;return ve(),Je("div",{ref_key:"formItemRef",ref:O,class:G(x(v)),role:x(I)?"group":void 0,"aria-labelledby":x(I)?x(u):void 0},[ae(x(dr),{"is-auto-width":x(f).width==="auto","update-all":((V=x(n))==null?void 0:V.labelWidth)==="auto"},{default:ue(()=>[x(S)?(ve(),yt(bt(x(_)?"label":"div"),{key:0,id:x(u),for:x(_),class:G(x(o).e("label")),style:Re(x(f))},{default:ue(()=>[Q(d.$slots,"label",{label:x(Oe)},()=>[wt(Ve(x(Oe)),1)])]),_:3},8,["id","for","class","style"])):je("v-if",!0)]),_:3},8,["is-auto-width","update-all"]),Se("div",{class:G(x(o).e("content")),style:Re(x(R))},[Q(d.$slots,"default"),ae(Ft,{name:`${x(o).namespace.value}-zoom-in-top`},{default:ue(()=>[x(et)?Q(d.$slots,"error",{key:0,error:F.value},()=>[Se("div",{class:G(x(m))},Ve(F.value),3)]):je("v-if",!0)]),_:3},8,["name"])],6)],10,["role","aria-labelledby"])}}});var ke=De(pr,[["__file","form-item.vue"]]);const gr=pt(jt,{FormItem:ke}),hr=vt(ke);export{gr as E,hr as a,me as c};