import{r as t,c as s,h as i,g as e}from"./p-78e3ebb9.js";const h=class{constructor(i){t(this,i);this.onSubmit=s(this,"submit",7);this.value={}}onButtonSubmit(t){t.stopPropagation();this.value=this.getFormValue();this.onSubmit.emit({value:this.value})}onButtonReset(t){t.stopPropagation();this.form.reset()}componentDidLoad(){this.value=this.getFormValue();Object.defineProperty(this.el,"value",{get:()=>this.value,configurable:true})}componentDidRender(){if(!this.originalAppendChild){this.originalAppendChild=this.el.appendChild;this.originalInsertBefore=this.el.insertBefore;this.originalReplaceChild=this.el.replaceChild;this.originalRemoveChild=this.el.removeChild}if(!this.form){this.el.appendChild=this.originalAppendChild;this.el.insertBefore=this.originalInsertBefore;this.el.replaceChild=this.originalReplaceChild;this.el.removeChild=this.originalRemoveChild;return}this.el.appendChild=t=>this.form.appendChild(t);this.el.insertBefore=(t,s)=>this.form.insertBefore(t,s);this.el.replaceChild=(t,s)=>this.form.replaceChild(t,s);this.el.removeChild=t=>this.form.removeChild(t)}getFormValue(){const t=this.el;const s=[];const i=t.getElementsByTagName("input");for(let t=0;t<i.length;t++){s.push(i[t])}const e={};const h={};s.forEach((t=>{if(typeof t.name!=="string")return;if(t.className.indexOf("weui-switch")!==-1){e[t.name]=t.checked;return}if(t.type==="radio"){if(t.checked){h[t.name]=true;e[t.name]=t.value}else{if(!h[t.name]){e[t.name]=""}}return}if(t.type==="checkbox"){if(t.checked){if(h[t.name]){e[t.name].push(t.value)}else{h[t.name]=true;e[t.name]=[t.value]}}else{if(!h[t.name]){e[t.name]=[]}}return}e[t.name]=t.value}));const r=t.getElementsByTagName("textarea");const o=[];for(let t=0;t<r.length;t++){o.push(r[t])}o.forEach((t=>{if(typeof t.name!=="string")return;e[t.name]=t.value}));return e}render(){return i("form",{ref:t=>{this.form=t}},i("slot",null))}get el(){return e(this)}};export{h as taro_form_core};
//# sourceMappingURL=p-efe31b23.entry.js.map