import{t as ae,a0 as ne,v as se,bb as ue,a1 as le,x as ie,r as w,z as l,y as re,bj as ce,bk as fe,bc as de,a3 as ve,bl as ge,T as A,bm as he,bn as M,bo as me,Q as be,bp as ye,aw as Pe,bq as Te,s as D,A as ke,Z as xe,O as Ce,br as Se,bs as Oe,U as qe}from"./entry.5131710f.js";import{u as Be,v as R,a as Ee,b as Fe,c as we,p as H,d as Ae,r as K,s as Me}from"./position-engine.3cd7a5a0.js";const He=ae({name:"QMenu",inheritAttrs:!1,props:{...Be,...ne,...se,...ue,persistent:Boolean,autoClose:Boolean,separateClosePopup:Boolean,noRouteDismiss:Boolean,noRefocus:Boolean,noFocus:Boolean,fit:Boolean,cover:Boolean,square:Boolean,anchor:{type:String,validator:R},self:{type:String,validator:R},offset:{type:Array,validator:Ee},scrollTarget:{default:void 0},touchPosition:Boolean,maxHeight:{type:String,default:null},maxWidth:{type:String,default:null}},emits:[...le,"click","escapeKey"],setup(t,{slots:Q,emit:c,attrs:d}){let n=null,f,i,v;const P=ie(),{proxy:g}=P,{$q:o}=g,a=w(null),s=w(!1),W=l(()=>t.persistent!==!0&&t.noRouteDismiss!==!0),j=re(t,o),{registerTick:U,removeTick:_}=ce(),{registerTimeout:T}=fe(),{transitionProps:z,transitionStyle:I}=de(t),{localScrollTarget:k,changeScrollEvent:L,unconfigureScrollTarget:Z}=Fe(t,E),{anchorEl:u,canShow:$}=we({showing:s}),{hide:x}=ve({showing:s,canShow:$,handleShow:X,handleHide:Y,hideOnRouteChange:W,processOnMount:!0}),{showPortal:C,hidePortal:S,renderPortal:G}=ge(P,a,ee,"menu"),h={anchorEl:u,innerRef:a,onClickOutside(e){if(t.persistent!==!0&&s.value===!0)return x(e),(e.type==="touchstart"||e.target.classList.contains("q-dialog__backdrop"))&&qe(e),!0}},O=l(()=>H(t.anchor||(t.cover===!0?"center middle":"bottom start"),o.lang.rtl)),J=l(()=>t.cover===!0?O.value:H(t.self||"top start",o.lang.rtl)),N=l(()=>(t.square===!0?" q-menu--square":"")+(j.value===!0?" q-menu--dark q-dark":"")),V=l(()=>t.autoClose===!0?{onClick:p}:{}),q=l(()=>s.value===!0&&t.persistent!==!0);A(q,e=>{e===!0?(he(b),Ae(h)):(M(b),K(h))});function m(){Se(()=>{let e=a.value;e&&e.contains(document.activeElement)!==!0&&(e=e.querySelector("[autofocus][tabindex], [data-autofocus][tabindex]")||e.querySelector("[autofocus] [tabindex], [data-autofocus] [tabindex]")||e.querySelector("[autofocus], [data-autofocus]")||e,e.focus({preventScroll:!0}))})}function X(e){if(n=t.noRefocus===!1?document.activeElement:null,me(F),C(),E(),f=void 0,e!==void 0&&(t.touchPosition||t.contextMenu)){const y=be(e);if(y.left!==void 0){const{top:te,left:oe}=u.value.getBoundingClientRect();f={left:y.left-oe,top:y.top-te}}}i===void 0&&(i=A(()=>o.screen.width+"|"+o.screen.height+"|"+t.self+"|"+t.anchor+"|"+o.lang.rtl,r)),t.noFocus!==!0&&document.activeElement.blur(),U(()=>{r(),t.noFocus!==!0&&m()}),T(()=>{o.platform.is.ios===!0&&(v=t.autoClose,a.value.click()),r(),C(!0),c("show",e)},t.transitionDuration)}function Y(e){_(),S(),B(!0),n!==null&&(e===void 0||e.qClickOutside!==!0)&&(((e&&e.type.indexOf("key")===0?n.closest('[tabindex]:not([tabindex^="-"])'):void 0)||n).focus(),n=null),T(()=>{S(!0),c("hide",e)},t.transitionDuration)}function B(e){f=void 0,i!==void 0&&(i(),i=void 0),(e===!0||s.value===!0)&&(ye(F),Z(),K(h),M(b)),e!==!0&&(n=null)}function E(){(u.value!==null||t.scrollTarget!==void 0)&&(k.value=Pe(u.value,t.scrollTarget),L(k.value,r))}function p(e){v!==!0?(Te(g,e),c("click",e)):v=!1}function F(e){q.value===!0&&t.noFocus!==!0&&Oe(a.value,e.target)!==!0&&m()}function b(e){c("escapeKey"),x(e)}function r(){const e=a.value;e===null||u.value===null||Me({el:e,offset:t.offset,anchorEl:u.value,anchorOrigin:O.value,selfOrigin:J.value,absoluteOffset:f,fit:t.fit,cover:t.cover,maxHeight:t.maxHeight,maxWidth:t.maxWidth})}function ee(){return D(xe,z.value,()=>s.value===!0?D("div",{role:"menu",...d,ref:a,tabindex:-1,class:["q-menu q-position-engine scroll"+N.value,d.class],style:[d.style,I.value],...V.value},ke(Q.default)):null)}return Ce(B),Object.assign(g,{focus:m,updatePosition:r}),G}});export{He as Q};
