"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),i=require("lucide-react"),o=require("../../styles/ScopeTree.module.css.js"),r=require("./TreeTooltip.js");exports.TreeMenu=function(s){var a=s.options,u=void 0===a?[]:a,c=s.buttonClassName,l=void 0===c?"":c,d=s.iconSize,p=void 0===d?16:d,m=n.useState(!1),f=m[0],v=m[1],_=n.useState(!1),g=_[0],b=_[1],h=n.useRef(null),j=n.useRef(null);n.useEffect(function(){var e=function(e){h.current&&!h.current.contains(e.target)&&v(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);return t.jsxs("div",e.__assign({className:o.default.menuContainer,ref:h},{children:[t.jsx("div",{children:t.jsx("button",e.__assign({ref:j,type:"button",className:l||o.default.optionsButton,onClick:function(e){if(e.stopPropagation(),!f&&j.current){var t=j.current.getBoundingClientRect(),n=window.innerHeight-t.bottom,i=40*u.length+20;b(n<i)}v(!f)}},{children:t.jsx(i.MoreVertical,{size:p,"aria-hidden":"true"})}))}),f&&t.jsx("div",e.__assign({className:"".concat(o.default.menuDropdown," ").concat(g?o.default.menuDropdownTop:o.default.menuDropdownBottom),role:"menu","aria-orientation":"vertical"},{children:u.map(function(n,i){var s=t.jsxs("button",e.__assign({disabled:n.disabled,onClick:function(e){var t;(e.stopPropagation(),n.disabled)||((t=n.onClick)&&"function"==typeof t&&t(),v(!1))},className:"".concat(o.default.menuOption," ").concat(n.disabled?o.default.menuOptionDisabled:""," ").concat(n.className||""),role:"menuitem"},{children:[n.icon&&t.jsx(n.icon,{size:16,className:o.default.menuOptionIcon}),n.label]}),"btn-".concat(i));return n.tooltip&&n.disabled?t.jsx("div",e.__assign({className:o.default.tooltipWrapper,onClick:function(e){return e.stopPropagation()}},{children:t.jsx(r.TreeTooltip,e.__assign({content:n.tooltip,placement:"right"},{children:t.jsx("div",e.__assign({style:{width:"100%"}},{children:s}))}))}),i):t.jsx("div",e.__assign({style:{width:"100%"}},{children:s}),i)})}))]}))};
//# sourceMappingURL=TreeMenu.js.map
