import React__default,{useState,useEffect}from"react";import PropTypes from"prop-types";import{I as Icon}from"./Icon.component-BVkaZqpA.js";import{p as pr}from"./headlessui-float-lyiwAWIX.js";import{o as offset,a as autoPlacement,s as size,b as shift}from"./floating-ui.react-dom-DmTNS6Kr.js";import{q as qe}from"./menu-DiwXZMR-.js";const menuStyles=`
  jn-overflow-hidden
  jn-flex
  jn-flex-col
  jn-rounded
  jn-bg-theme-background-lvl-1
`,toggleStyles=`
	hover:jn-text-theme-accent
	active:jn-text-theme-accent
`,toggleOpenStyle=`
	jn-text-theme-accent
`,ContextMenu=a=>{let{children:b=null,open:c=!1}=a;const[d,e]=useState(!1);useEffect(()=>{e(c)},[c]);const f=[offset(4),autoPlacement({crossAxis:!0,allowedPlacements:["top-start","top-end","bottom-start","bottom-end"]}),size({boundary:"viewport",apply(a){let{availableWidth:b,availableHeight:c,elements:d}=a;Object.assign(d.floating.style,{maxWidth:`${b}px`,maxHeight:`${c}px`,overflowY:"auto"})}}),shift()];return React__default.createElement(qe,null,React__default.createElement(pr,{middleware:f},React__default.createElement(qe.Button,{onClick:()=>{e(!d)},className:`
              juno-contextmenu-toggle 
              ${toggleStyles} 
              ${d?toggleOpenStyle:""}
            `},React__default.createElement(Icon,{icon:"moreVert"})),React__default.createElement(qe.Items,{className:`${menuStyles}`},b)))};ContextMenu.propTypes={className:PropTypes.string,children:PropTypes.node,icon:PropTypes.any,open:PropTypes.bool};export{ContextMenu as C};