"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),p=require("@aplus-frontend/antdv"),B=require("lodash-unified");require("../../hooks/index.js");const V=require("../hooks/use-default-placeholder.js"),I=require("./use-options.js"),M=require("../../hooks/useControllableValue.js"),R={key:0},E=e.defineComponent({name:"ApFieldCascader",__name:"index",props:{mode:{default:"edit"},class:{},style:{},emptyText:{default:"--"},customReadMode:{},multiple:{type:Boolean,default:void 0},size:{},bordered:{type:Boolean,default:!0},placement:{},suffixIcon:{},status:{},options:{},popupClassName:{},dropdownClassName:{},"onUpdate:value":{},variant:{},value:{},children:{},onMouseenter:{},onMouseleave:{},tabindex:{},onClick:{},onFocus:{},onBlur:{},onChange:{},onKeydown:{},onKeyup:{},onMousedown:{},open:{type:Boolean,default:void 0},animation:{},direction:{},disabled:{type:Boolean},prefixCls:{},id:{},autofocus:{type:Boolean},getPopupContainer:{},dropdownMatchSelectWidth:{type:[Number,Boolean]},placeholder:{},loading:{type:Boolean},defaultValue:{},prefix:{},clearIcon:{},allowClear:{type:Boolean,default:!0},getInputElement:{},getRawInputElement:{},fieldNames:{},searchValue:{},onSearch:{},maxCount:{},showSearch:{type:[Boolean,Object],default:!1},tagRender:{},optionLabelRender:{},notFoundContent:{},onClear:{},choiceTransitionName:{},defaultOpen:{type:Boolean,default:void 0},onDropdownVisibleChange:{},maxTagTextLength:{},maxTagCount:{},maxTagPlaceholder:{},removeIcon:{},transitionName:{},dropdownStyle:{},dropdownRender:{},dropdownAlign:{},showAction:{},onPopupScroll:{},onInputKeyDown:{},onPopupVisibleChange:{},popupStyle:{},popupPlacement:{},popupVisible:{type:Boolean,default:void 0},expandIcon:{},changeOnSelect:{type:Boolean},displayRender:{},showCheckedStrategy:{},expandTrigger:{},dropdownPrefixCls:{},dropdownMenuColumnStyle:{},loadingIcon:{},request:{},lazy:{type:Boolean},params:{},loadData:{type:Boolean}},emits:["update:value"],setup(r,{expose:C,emit:b}){const n=r,k=e.computed(()=>B.omit(n,["onUpdate:value","value","options","loadData"])),w=e.useSlots(),x=b,i=e.ref(),{value:f,updateValue:S}=M.useControllableValue(n,x),N=V.useDefaultPlaceholder("Cascader",n),{options:m,request:h,loading:g}=I.useOptions(n),v=e.computed(()=>{const t=e.unref(f);if(!t?.length)return[];const y=n.fieldNames?.label||"label",u=n.fieldNames?.value||"value";function o(c,a){const l=[];for(const d of c||[]){if(a.find(D=>D===d[u])&&l.push(d[y]),l.length===a.length)return l;d.children?.length&&l.push(...o(d.children,a))}return l}const s=[],q=B.isArray(t[0])?t:[t];for(const c of q){const a=o(m.value,c);a.length&&s.push(a)}return s});function P(){i.value?.focus?.()}function T(){i.value?.blur?.()}return C({focus:P,blur:T,request:h}),(t,y)=>r.mode==="read"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[v.value.length?(e.openBlock(),e.createBlock(e.unref(p.Space),{key:1,size:4},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,(u,o)=>(e.openBlock(),e.createElementBlock("span",{key:o},e.toDisplayString(u.join(", ")),1))),128))]),_:1})):(e.openBlock(),e.createElementBlock("span",R,e.toDisplayString(r.emptyText),1))],64)):(e.openBlock(),e.createBlock(e.unref(p.Cascader),e.mergeProps({key:1},k.value,{ref:i.value,value:e.unref(f),loading:e.unref(g),options:e.unref(m),placeholder:e.unref(N),"load-data":r.loadData?e.unref(h):void 0,"onUpdate:value":e.unref(S)}),e.createSlots({_:2},[e.renderList(w,(u,o)=>({name:o,fn:e.withCtx(s=>[e.renderSlot(t.$slots,o,e.normalizeProps(e.guardReactiveProps(s||{})))])})),e.unref(g)?{name:"notFoundContent",fn:e.withCtx(()=>[e.createVNode(e.unref(p.Spin),{size:"small"})]),key:"0"}:void 0]),1040,["value","loading","options","placeholder","load-data","onUpdate:value"]))}});exports.default=E;
