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