import"./vue.db505ee4.js";import{c as u}from"./@vueuse.952f4739.js";import{z as C,c as b}from"./index.b35f53c6.js";import{l as g}from"./lodash.c9cf1bdb.js";import{u as y}from"./remoteOptions.c846a4ad.js";import{F,a as S}from"./ant-design-vue.6b10f349.js";import{d as A,h as E}from"./@vue.cb43a243.js";import"./@babel.6cd0804c.js";import"./regenerator-runtime.8e24db72.js";import"./vue-demi.5fb18120.js";import"./js-md5.5179c6be.js";import"./vue-router.a08742b9.js";import"./js-cookie.31874410.js";import"./spark-md5.2cc5764b.js";import"./axios.e3200588.js";import"./@ant-design.bcfb08ae.js";import"./@ctrl.fa7cbd46.js";/* empty css                     */import"./dayjs.38e390ea.js";import"./sortablejs.412b554c.js";import"./clipboard.099d05c9.js";import"./markdown-it.80c3a67b.js";import"./entities.0d2c0164.js";import"./uc.micro.981ceb7b.js";import"./mdurl.ef76b4dc.js";import"./linkify-it.92c30060.js";import"./markdown-it-emoji.e3e91710.js";import"./escape-html.e5dfadb9.js";import"./prismjs.c97a8414.js";import"./diacritics.6be19c75.js";import"./markdown-it-container.512a5043.js";import"./markdown-it-anchor.c88e5394.js";import"./markdown-it-attrs.3af5ab50.js";import"./markdown-it-table-of-contents.8a4ce16f.js";import"./@kangc.86f7507c.js";import"./resize-observer-polyfill.8deb1e21.js";import"./vue-types.6e6d84ba.js";import"./dom-align.f1b5d360.js";import"./lodash-es.0ea26897.js";import"./async-validator.5d25c98b.js";import"./scroll-into-view-if-needed.5191fdbf.js";import"./compute-scroll-into-view.6058b3be.js";import"./context.6c9ae94a.js";var vr=A({name:"ExCascader",props:{value:[String,Number,Array],options:Array,remote:Object,cascaderValue:{type:Array,default:[]},single:Boolean},setup(t,o){const n=F.useInjectFormItemContext(),m=u(t,"value",o.emit),s=u(t,"options",o.emit),{remoteOptionsDebounce:f,remoteOptions:l}=y(t,s),i=o.attrs.fieldNames||{label:"label",value:"value",children:"children",pid:"pid"},c=u(t,"cascaderValue",o.emit);function h(r){if(r===void 0)m.value=o.attrs.multiple?[]:null;else{let e=JSON.parse(JSON.stringify(r));o.attrs.multiple?m.value=v(e):m.value=e.pop()}n.onFieldChange()}t.single&&l(m.value).then(r=>{c.value=O(m.value)});function v(r){let e=[];return r.forEach(a=>{const p=a.pop();e=e.concat(V(p))}),g.exports.uniq(e)}function V(r){const e=[r],a=b(t.options,i.value,r,-1,i.children);if(a&&a[i.children])a[i.children].forEach(p=>{d(p,e)});else return[r];return e}function d(r,e=[]){return e.push(r[i.value]),r[i.children]&&r[i.children].forEach(a=>{d(a,e)}),e}function O(r){Array.isArray(r)||(r?r=[r]:r=[]);const e=[];return r.forEach(a=>{e.push(C(s.value,a,i.value,i.pid,i.children).map(p=>p[i.value]))}),o.attrs.changeOnSelect?e:e.pop()}return{options:s,remoteOptionsDebounce:f,remoteOptions:l,cascaderValue:c,updateValue:h}},render(t){let o=Object.assign({options:this.options},t.$attrs,{value:t.cascaderValue,"onUpdate:value":n=>{t.cascaderValue=n,this.updateValue(n)}});return this.remote&&(o.onSearch=n=>{this.remoteOptionsDebounce(n)},o.showSearch=!0),E(S,o,t.$slots)}});export{vr as default};
