import{m as I,n as U,d as j,r as y,da as V,i as z,s as N,a as b,v as w,db as x,dc as F,dd as L,k as D,au as S,H,M as K,z as E,cy as P,af as m,de as q,aF as k,y as G,df as J,dg as C,dh as Q,di as R,A as W}from"./index-BJD7BFLS.js";const A=I("n-popselect"),X=U("popselect-menu",`
 box-shadow: var(--n-menu-box-shadow);
`),M={multiple:Boolean,value:{type:[String,Number,Array],default:null},cancelable:Boolean,options:{type:Array,default:()=>[]},size:String,scrollable:Boolean,"onUpdate:value":[Function,Array],onUpdateValue:[Function,Array],onMouseenter:Function,onMouseleave:Function,renderLabel:Function,showCheckmark:{type:Boolean,default:void 0},nodeProps:Function,virtualScroll:Boolean,onChange:[Function,Array]},T=E(M),Y=j({name:"PopselectPanel",props:M,setup(o){const t=z(A),{mergedClsPrefixRef:s,inlineThemeDisabled:l,mergedComponentPropsRef:u}=N(o),h=b(()=>{var e,i;return o.size||((i=(e=u?.value)===null||e===void 0?void 0:e.Popselect)===null||i===void 0?void 0:i.size)||"medium"}),f=w("Popselect","-pop-select",X,x,t.props,s),a=b(()=>F(o.options,L("value","children")));function n(e,i){const{onUpdateValue:d,"onUpdate:value":c,onChange:p}=o;d&&m(d,e,i),c&&m(c,e,i),p&&m(p,e,i)}function r(e){B(e.key)}function $(e){!P(e,"action")&&!P(e,"empty")&&!P(e,"header")&&e.preventDefault()}function B(e){const{value:{getNode:i}}=a;if(o.multiple)if(Array.isArray(o.value)){const d=[],c=[];let p=!0;o.value.forEach(O=>{if(O===e){p=!1;return}const g=i(O);g&&(d.push(g.key),c.push(g.rawNode))}),p&&(d.push(e),c.push(i(e).rawNode)),n(d,c)}else{const d=i(e);d&&n([e],[d.rawNode])}else if(o.value===e&&o.cancelable)n(null,null);else{const d=i(e);d&&n(e,d.rawNode);const{"onUpdate:show":c,onUpdateShow:p}=t.props;c&&m(c,!1),p&&m(p,!1),t.setShow(!1)}S(()=>{t.syncPosition()})}D(H(o,"options"),()=>{S(()=>{t.syncPosition()})});const _=b(()=>{const{self:{menuBoxShadow:e}}=f.value;return{"--n-menu-box-shadow":e}}),v=l?K("select",void 0,_,t.props):void 0;return{mergedTheme:t.mergedThemeRef,mergedClsPrefix:s,treeMate:a,handleToggle:r,handleMenuMousedown:$,cssVars:l?void 0:_,themeClass:v?.themeClass,onRender:v?.onRender,mergedSize:h,scrollbarProps:t.props.scrollbarProps}},render(){var o;return(o=this.onRender)===null||o===void 0||o.call(this),y(V,{clsPrefix:this.mergedClsPrefix,focusable:!0,nodeProps:this.nodeProps,class:[`${this.mergedClsPrefix}-popselect-menu`,this.themeClass],style:this.cssVars,theme:this.mergedTheme.peers.InternalSelectMenu,themeOverrides:this.mergedTheme.peerOverrides.InternalSelectMenu,multiple:this.multiple,treeMate:this.treeMate,size:this.mergedSize,value:this.value,virtualScroll:this.virtualScroll,scrollable:this.scrollable,scrollbarProps:this.scrollbarProps,renderLabel:this.renderLabel,onToggle:this.handleToggle,onMouseenter:this.onMouseenter,onMouseleave:this.onMouseenter,onMousedown:this.handleMenuMousedown,showCheckmark:this.showCheckmark},{header:()=>{var t,s;return((s=(t=this.$slots).header)===null||s===void 0?void 0:s.call(t))||[]},action:()=>{var t,s;return((s=(t=this.$slots).action)===null||s===void 0?void 0:s.call(t))||[]},empty:()=>{var t,s;return((s=(t=this.$slots).empty)===null||s===void 0?void 0:s.call(t))||[]}})}}),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},w.props),k(R,["showArrow","arrow"])),{placement:Object.assign(Object.assign({},R.placement),{default:"bottom"}),trigger:{type:String,default:"hover"}}),M),{scrollbarProps:Object}),se=j({name:"Popselect",props:Z,slots:Object,inheritAttrs:!1,__popover__:!0,setup(o){const{mergedClsPrefixRef:t}=N(o),s=w("Popselect","-popselect",void 0,x,o,t),l=G(null);function u(){var a;(a=l.value)===null||a===void 0||a.syncPosition()}function h(a){var n;(n=l.value)===null||n===void 0||n.setShow(a)}return W(A,{props:o,mergedThemeRef:s,syncPosition:u,setShow:h}),Object.assign(Object.assign({},{syncPosition:u,setShow:h}),{popoverInstRef:l,mergedTheme:s})},render(){const{mergedTheme:o}=this,t={theme:o.peers.Popover,themeOverrides:o.peerOverrides.Popover,builtinThemeOverrides:{padding:"0"},ref:"popoverInstRef",internalRenderBody:(s,l,u,h,f)=>{const{$attrs:a}=this;return y(Y,Object.assign({},a,{class:[a.class,s],style:[a.style,...u]},J(this.$props,T),{ref:Q(l),onMouseenter:C([h,a.onMouseenter]),onMouseleave:C([f,a.onMouseleave])}),{header:()=>{var n,r;return(r=(n=this.$slots).header)===null||r===void 0?void 0:r.call(n)},action:()=>{var n,r;return(r=(n=this.$slots).action)===null||r===void 0?void 0:r.call(n)},empty:()=>{var n,r;return(r=(n=this.$slots).empty)===null||r===void 0?void 0:r.call(n)}})}};return y(q,Object.assign({},k(this.$props,T),t,{internalDeactivateImmediately:!0}),{trigger:()=>{var s,l;return(l=(s=this.$slots).default)===null||l===void 0?void 0:l.call(s)}})}});export{se as N};
