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