'use strict';
'use client';
import { c } from 'react/compiler-runtime';
import { jsxs, jsx } from 'react/jsx-runtime';
import { useState } from 'react';
import { cn } from '../../../../../fd-toolbox/lib/utils.js';
import { TopMenuItem } from '../top-menu-item/TopMenuItem.js';
import { Button } from '../../../../fd-component-toolbox/button/Button.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function TopMenuGroup(t0) {
  const $ = c(6);
  const {
    group
  } = t0;
  const [open, setOpen] = useState(false);
  let t1;
  if ($[0] !== group.groupName || $[1] !== group.subgroupsOrMenuItems || $[2] !== open) {
    const subgroupsOrMenuItems = group?.subgroupsOrMenuItems?.map(_temp);
    let t2;
    let t3;
    if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
      t2 = () => setOpen(true);
      t3 = () => setOpen(false);
      $[4] = t2;
      $[5] = t3;
    } else {
      t2 = $[4];
      t3 = $[5];
    }
    t1 = jsxs("li", {
      className: "relative p-2",
      onMouseEnter: t2,
      onMouseLeave: t3,
      children: [jsx(Button, {
        variant: "ghost",
        className: "flex size-full flex-row items-start justify-center py-1 text-xs font-bold text-black",
        children: group.groupName
      }), jsx("div", {
        className: cn("absolute top-full left-0 w-52 divide-y rounded-md p-3 shadow", !open && "hidden"),
        children: jsx("ul", {
          children: subgroupsOrMenuItems
        })
      })]
    });
    $[0] = group.groupName;
    $[1] = group.subgroupsOrMenuItems;
    $[2] = open;
    $[3] = t1;
  } else {
    t1 = $[3];
  }
  return t1;
}
function _temp(subItem) {
  return jsx(TopMenuItem, {
    item: subItem
  }, `${subItem.text}_${subItem.type}`);
}
__name(TopMenuGroup, "TopMenuGroup");

export { TopMenuGroup };
