import{t as $,v as P,z as T,w as N,u as M,d as V,Q as B,R as D,x as H,ap as K,y as z,a1 as j,as as F,a0 as L,c as l,at as Q,an as U,au as Y,av as Z,O as E,r as q,C as G,W as J,aw as X,ax as ee,ac as oe,ay as te,P as ne,E as ae,a5 as se,D as W}from"./index.332c7f08.js";import{C as le}from"./index.91135ff9.js";const[R,h]=$("dropdown-menu"),re={overlay:P,zIndex:T,duration:N(.2),direction:M("down"),activeColor:String,closeOnClickOutside:P,closeOnClickOverlay:P},A=Symbol(R);var ce=V({name:R,props:re,setup(o,{slots:c}){const i=B(),u=D(),n=D(),r=D(0),{children:d,linkChildren:p}=H(A),g=K(u),v=z(()=>d.some(t=>t.state.showWrapper)),b=z(()=>{if(v.value&&j(o.zIndex))return{zIndex:+o.zIndex+1}}),O=()=>{o.closeOnClickOutside&&d.forEach(t=>{t.toggle(!1)})},w=()=>{if(n.value){const t=U(n);o.direction==="down"?r.value=t.bottom:r.value=Y.value-t.top}},k=()=>{v.value&&w()},x=t=>{d.forEach((e,a)=>{a===t?(w(),e.toggle()):e.state.showPopup&&e.toggle(!1,{immediate:!0})})},I=(t,e)=>{const{showPopup:a}=t.state,{disabled:s,titleClass:f}=t;return l("div",{id:`${i}-${e}`,role:"button",tabindex:s?void 0:0,class:[h("item",{disabled:s}),{[Q]:!s}],onClick:()=>{s||x(e)}},[l("span",{class:[h("title",{down:a===(o.direction==="down"),active:a}),f],style:{color:a?o.activeColor:""}},[l("div",{class:"van-ellipsis"},[t.renderTitle()])])])};return p({id:i,props:o,offset:r}),F(u,O),L("scroll",k,{target:g,passive:!0}),()=>{var t;return l("div",{ref:u,class:h()},[l("div",{ref:n,style:b.value,class:h("bar",{opened:v.value})},[d.map(I)]),(t=c.default)==null?void 0:t.call(c)])}}});const[ie,y]=$("dropdown-item"),de={title:String,options:Z(),disabled:Boolean,teleport:[String,Object],lazyRender:P,modelValue:E,titleClass:E};var ue=V({name:ie,inheritAttrs:!1,props:de,emits:["open","opened","close","closed","change","update:modelValue"],setup(o,{emit:c,slots:i,attrs:u}){const n=q({showPopup:!1,transition:!0,showWrapper:!1}),{parent:r,index:d}=G(A);if(!r){console.error("[Vant] must be a child component of .");return}const p=e=>()=>c(e),g=p("open"),v=p("close"),b=p("opened"),O=()=>{n.showWrapper=!1,c("closed")},w=e=>{o.teleport&&e.stopPropagation()},k=(e=!n.showPopup,a={})=>{e!==n.showPopup&&(n.showPopup=e,n.transition=!a.immediate,e&&(n.showWrapper=!0))},x=()=>{if(i.title)return i.title();if(o.title)return o.title;const e=o.options.find(a=>a.value===o.modelValue);return e?e.text:""},I=e=>{const{activeColor:a}=r.props,s=e.value===o.modelValue,f=()=>{n.showPopup=!1,e.value!==o.modelValue&&(c("update:modelValue",e.value),c("change",e.value))},m=()=>{if(s)return l(se,{class:y("icon"),color:a,name:"success"},null)};return l(le,{role:"menuitem",key:e.value,icon:e.icon,title:e.text,class:y("option",{active:s}),style:{color:s?a:""},tabindex:s?0:-1,clickable:!0,onClick:f},{value:m})},t=()=>{const{offset:e}=r,{zIndex:a,overlay:s,duration:f,direction:m,closeOnClickOverlay:_}=r.props,S=ee(a);return m==="down"?S.top=`${e.value}px`:S.bottom=`${e.value}px`,oe(l("div",ae({style:S,class:y([m]),onClick:w},u),[l(ne,{show:n.showPopup,"onUpdate:show":C=>n.showPopup=C,role:"menu",class:y("content"),overlay:s,position:m==="down"?"top":"bottom",duration:n.transition?f:0,lazyRender:o.lazyRender,overlayStyle:{position:"absolute"},"aria-labelledby":`${r.id}-${d.value}`,closeOnClickOverlay:_,onOpen:g,onClose:v,onOpened:b,onClosed:O},{default:()=>{var C;return[o.options.map(I),(C=i.default)==null?void 0:C.call(i)]}})]),[[te,n.showWrapper]])};return J({state:n,toggle:k,renderTitle:x}),()=>o.teleport?l(X,{to:o.teleport},{default:()=>[t()]}):t()}});const fe=W(ue),me=W(ce);export{me as D,fe as a};