import{c as O,a9 as C,b as _,aj as b,d as E,r as y,e as V,w as P,X as N,a as S,ae as k,h as A,k as T}from"./index-971588a5.js";import{p as j,P as x}from"./index-220da4eb.js";const p="000000",I=["title","cancel","confirm","toolbar","columns-top","columns-bottom"],M=["title","loading","readonly","optionHeight","swipeDuration","visibleOptionNum","cancelButtonText","confirmButtonText"],l=(a="",s=p,e=void 0)=>({text:a,value:s,children:e});function R({areaList:a,columnsNum:s,columnsPlaceholder:e}){const{city_list:n={},county_list:r={},province_list:f={}}=a,m=+s>1,u=+s>2,v=()=>{if(m)return e.length?[l(e[0],p,u?[]:void 0)]:[]},t=new Map;Object.keys(f).forEach(o=>{t.set(o.slice(0,2),l(f[o],o,v()))});const i=new Map;if(m){const o=()=>{if(u)return e.length?[l(e[1])]:[]};Object.keys(n).forEach(c=>{const d=l(n[c],c,o());i.set(c.slice(0,4),d);const g=t.get(c.slice(0,2));g&&g.children.push(d)})}u&&Object.keys(r).forEach(o=>{const c=i.get(o.slice(0,4));c&&c.children.push(l(r[o],o))});const h=Array.from(t.values());if(e.length){const o=u?[l(e[2])]:void 0,c=m?[l(e[1],p,o)]:void 0;h.unshift(l(e[0],p,c))}return h}const[D,H]=O("area"),w=C({},j,{modelValue:String,columnsNum:_(3),columnsPlaceholder:b(),areaList:{type:Object,default:()=>({})}});var B=E({name:D,props:w,emits:["change","confirm","cancel","update:modelValue"],setup(a,{emit:s,slots:e}){const n=y([]),r=y(),f=V(()=>R(a)),m=(...t)=>s("change",...t),u=(...t)=>s("cancel",...t),v=(...t)=>s("confirm",...t);return P(n,t=>{const i=t.length?t[t.length-1]:"";i&&i!==a.modelValue&&s("update:modelValue",i)},{deep:!0}),P(()=>a.modelValue,t=>{if(t){const i=n.value.length?n.value[n.value.length-1]:"";t!==i&&(n.value=[`${t.slice(0,2)}0000`,`${t.slice(0,4)}00`,t].slice(0,+a.columnsNum))}else n.value=[]},{immediate:!0}),N({confirm:()=>{var t;return(t=r.value)==null?void 0:t.confirm()},getSelectedOptions:()=>{var t;return((t=r.value)==null?void 0:t.getSelectedOptions())||[]}}),()=>S(x,A({ref:r,modelValue:n.value,"onUpdate:modelValue":t=>n.value=t,class:H(),columns:f.value,onChange:m,onCancel:u,onConfirm:v},k(a,M)),k(e,I))}});const F=T(B);export{F as A};
