text: var j=Object.defineProperty,D=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var C=(e,t,s)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,g=(e,t)=>{for(var s in t||(t={}))O.call(t,s)&&C(e,s,t[s]);if(_)for(var s of _(t))S.call(t,s)&&C(e,s,t[s]);return e},w=(e,t)=>D(e,N(t));import{a as A,v as I,f as P,N as F,al as H,b_ as E,i as y,n as c,b6 as v,F as R,cA as V,b5 as W,e_ as z,e$ as B,as as T}from"./index.d2ddfb50.js";import{D as U}from"./index.4a24671e.js";function X(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!V(e)}const b="context-menu",Y={width:{type:Number,default:156},customEvent:{type:Object,default:null},styles:{type:Object},showIcon:{type:Boolean,default:!0},axis:{type:Object,default(){return{x:0,y:0}}},items:{type:Array,default(){return[]}}},M=e=>{const{item:t}=e;return c("span",{style:"display: inline-block; width: 100%; ",class:"px-4",onClick:e.handler.bind(null,t)},[e.showIcon&&t.icon&&c(W,{class:"mr-2",icon:t.icon},null),c("span",null,[t.label])])};var q=A({name:"ContextMenu",props:Y,setup(e){const t=I(null),s=I(!1),i=P(()=>{const{axis:o,items:n,styles:r,width:l}=e,{x:a,y:m}=o||{x:0,y:0},p=(n||[]).length*40,h=l,x=document.body,L=x.clientWidth<a+h?a-h:a,$=x.clientHeight<m+p?m-p:m;return w(g({},r),{position:"absolute",width:`${l}px`,left:`${L+1}px`,top:`${$+1}px`,zIndex:9999})});F(()=>{H(()=>s.value=!0)}),E(()=>{const o=y(t);o&&document.body.removeChild(o)});function f(o,n){const{handler:r,disabled:l}=o;l||(s.value=!1,n==null||n.stopPropagation(),n==null||n.preventDefault(),r==null||r())}function u(o){return o.map(n=>{const{disabled:r,label:l,children:a,divider:m=!1}=n,p={item:n,handler:f,showIcon:e.showIcon};return!a||a.length===0?c(R,null,[c(v.Item,{disabled:r,class:`${b}__item`,key:l},{default:()=>[c(M,p,null)]}),m?c(U,{key:`d-${l}`},null):null]):y(s)?c(v.SubMenu,{key:l,disabled:r,popupClassName:`${b}__popup`},{title:()=>c(M,p,null),default:()=>u(a)}):null})}return()=>{let o;if(!y(s))return null;const{items:n}=e;return c("div",{class:b},[c(v,{inlineIndent:12,mode:"vertical",ref:t,style:y(i)},X(o=u(n))?o:{default:()=>[o]})])}}});const d={domList:[],resolve:()=>{}},G=function(e){const{event:t}=e||{};if(t&&(t==null||t.preventDefault()),!!z)return new Promise(s=>{const i=document.body,f=document.createElement("div"),u={};e.styles&&(u.styles=e.styles),e.items&&(u.items=e.items),e.event&&(u.customEvent=t,u.axis={x:t.clientX,y:t.clientY});const o=c(q,u);B(o,f);const n=function(){d.resolve("")};d.domList.push(f);const r=function(){d.domList.forEach(l=>{try{l&&i.removeChild(l)}catch(a){}}),i.removeEventListener("click",n),i.removeEventListener("scroll",n)};d.resolve=function(l){r(),s(l)},r(),i.appendChild(f),i.addEventListener("click",n),i.addEventListener("scroll",n)})},k=function(){d&&(d.resolve(""),d.domList=[])};function Z(e=!0){return T()&&e&&E(()=>{k()}),[G,k]}export{Z as u};
  