"use strict";var e=Object.defineProperty,l=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(l,a,o)=>a in l?e(l,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):l[a]=o,d=(e,d)=>{for(var t in d||(d={}))a.call(d,t)&&s(e,t,d[t]);if(l)for(var t of l(d))o.call(d,t)&&s(e,t,d[t]);return e};const t=require("../../../../common/vendor.js"),r=require("../../../../hooks/useColPickerData.js");if(!Array){(t.resolveComponent("wd-input")+t.resolveComponent("wd-picker")+t.resolveComponent("wd-col-picker")+t.resolveComponent("wd-form"))()}Math||((()=>"../../../../node-modules/wot-design-uni/components/wd-input/wd-input.js")+(()=>"../../../../node-modules/wot-design-uni/components/wd-picker/wd-picker.js")+(()=>"../../../../node-modules/wot-design-uni/components/wd-col-picker/wd-col-picker.js")+(()=>"../../../../node-modules/wot-design-uni/components/wd-form/wd-form.js"))();const u={__name:"AddAddress",props:{initialAddress:{type:Object,default:()=>({name:"",phone:"",address:"",detailAddress:"",type:"",customType:""})}},emits:["save-address"],setup(e,{emit:l}){const{colPickerData:a,findChildrenByCode:o}=r.useColPickerData(),s=t.ref([]),u=e;t.ref([]);const n=t.ref([a.map((e=>({value:e.value,label:e.text})))]),i=t.ref(["家","公司","自定义"]),p=t.ref(!1),v=({selectedItem:e,resolve:l,finish:s})=>{const d=o(a,e.value);d&&d.length?l(d.map((e=>({value:e.value,label:e.text})))):s()},c=e=>e.map((e=>e.label)).join("-");function m({value:e,selectedItems:l}){w.value.address=l.map((e=>e.label)).join("-")}function f({value:e}){p.value="自定义"===e,p.value||(w.value.customType="")}const y=l,w=t.ref(d({},u.initialAddress));t.watch((()=>u.initialAddress),(e=>{w.value=d({},e),p.value="自定义"===e.type}));const b=()=>{w.value.name&&w.value.phone&&w.value.detailAddress&&("自定义"!==w.value.type||w.value.customType)?(y("save-address",w.value),h()):t.index.showToast({title:"请填写完整的地址信息",icon:"error"})},h=()=>{w.value={name:"",phone:"",address:"",detailAddress:"",type:"",customType:""},s.value=[],p.value=!1};return(e,l)=>t.e({a:t.o((e=>w.value.name=e)),b:t.p({label:"姓名",required:!0,modelValue:w.value.name}),c:t.o((e=>w.value.phone=e)),d:t.p({label:"电话",required:!0,type:"tel",modelValue:w.value.phone}),e:t.o(f),f:t.o((e=>w.value.type=e)),g:t.p({columns:i.value,label:"地址类型",modelValue:w.value.type}),h:p.value},p.value?{i:t.o((e=>w.value.customType=e)),j:t.p({label:"自定义类型",required:!0,modelValue:w.value.customType})}:{},{k:t.o(m),l:t.o((e=>s.value=e)),m:t.p({label:"选择地址",columns:n.value,"column-change":v,"display-format":c,modelValue:s.value}),n:w.value.address.length&&w.value.address&&!s.value.length},w.value.address.length&&w.value.address&&!s.value.length?{o:t.t(w.value.address)}:{},{p:t.o((e=>w.value.detailAddress=e)),q:t.p({label:"详细地址",required:!0,modelValue:w.value.detailAddress}),r:t.o(b),s:t.sr("addressForm","7ad4cd84-0")})}},n=t._export_sfc(u,[["__scopeId","data-v-7ad4cd84"]]);wx.createComponent(n);