"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),V=require("../../_util/classNames.js"),l=require("../../_util/raf.js"),A=require("../../_util/transition.js"),D=require("../../vc-trigger/Trigger.js");require("../../_util/vue-types/index.js");const m=require("./hooks/useMenuContext.js"),f=require("./placements.js"),j={horizontal:"bottomLeft",vertical:"rightTop","vertical-left":"rightTop","vertical-right":"leftTop"},x=t.defineComponent({compatConfig:{MODE:3},name:"PopupTrigger",inheritAttrs:!1,props:{prefixCls:String,mode:String,visible:Boolean,popupClassName:String,popupOffset:Array,disabled:Boolean,onVisibleChange:Function},slots:Object,emits:["visibleChange"],setup(n,{slots:a,emit:d}){const i=t.shallowRef(!1),{getPopupContainer:v,rtl:s,subMenuOpenDelay:g,subMenuCloseDelay:b,builtinPlacements:r,triggerSubMenuAction:C,forceSubMenuRender:h,motion:M,defaultMotions:p,rootClassName:P}=m.useInjectMenu(),q=m.useInjectForceRender(),R=t.computed(()=>s.value?{...f.placementsRtl,...r.value}:{...f.placements,...r.value}),T=t.computed(()=>j[n.mode]),u=t.shallowRef();t.watch(()=>n.visible,e=>{l.default.cancel(u.value),u.value=l.default(()=>{i.value=e})},{immediate:!0}),t.onBeforeUnmount(()=>{l.default.cancel(u.value)});const y=e=>{d("visibleChange",e)},S=t.computed(()=>{const e=M.value||p.value?.[n.mode]||p.value?.other,o=typeof e=="function"?e():e;return o?A.getTransitionProps(o.name,{css:!0}):void 0});return()=>{const{prefixCls:e,popupClassName:o,mode:N,popupOffset:c,disabled:O}=n;return t.createVNode(D.default,{prefixCls:e,popupClassName:V.default(`${e}-popup`,{[`${e}-rtl`]:s.value},o,P.value),stretch:N==="horizontal"?"minWidth":null,getPopupContainer:v.value,builtinPlacements:R.value,popupPlacement:T.value,popupVisible:i.value,popupAlign:c&&{offset:c},action:O?[]:[C.value],mouseEnterDelay:g.value,mouseLeaveDelay:b.value,onPopupVisibleChange:y,forceRender:q||h.value,popupAnimation:S.value},{popup:a.popup,default:a.default})}}});exports.default=x;
