const _excluded = ["children", "borderColor", "backgroundColor", "isSelected", "isFaded", "onClick", "onDoubleClick", "className", "style", "glowColor", "disableGlow"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/*
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

import React, { useCallback } from 'react';
import { Handle, Position } from '@xyflow/react';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * Shared outer shell for all node types.
 * Renders 8 ReactFlow handles (source/target x 4 directions),
 * applies selection state, fade state, and border/background colors.
 * Keyboard-accessible: focusable and activatable via Enter/Space.
 */
export const NodeShell = _ref => {
  let {
      children,
      borderColor,
      backgroundColor,
      isSelected = false,
      isFaded = false,
      onClick,
      onDoubleClick,
      className = '',
      style,
      glowColor,
      disableGlow = false
    } = _ref,
    rest = _objectWithoutProperties(_ref, _excluded);
  const borderStyle = borderColor ? {
    borderColor
  } : {};
  const bgStyle = backgroundColor ? {
    backgroundColor
  } : {};
  const glowStyle = {
    '--osd-node-glow-color': glowColor !== null && glowColor !== void 0 ? glowColor : 'rgba(59, 130, 246, 0.4)'
  };
  const isInteractive = !!onClick;
  const handleKeyDown = useCallback(event => {
    if (onClick && (event.key === 'Enter' || event.key === ' ')) {
      event.preventDefault();
      onClick(event);
    }
  }, [onClick]);
  return /*#__PURE__*/_jsxs("div", {
    className: "osd-resetFocusState osd:rounded-xl osd:border-2 osd:box-border osd:transition-all osd:duration-200\n                ".concat(disableGlow ? 'osd:outline-none osd:shadow-none osd:focus:outline-none osd:focus:shadow-none osd:hover:shadow-none' : isSelected ? 'osd:shadow-node-selected osd:outline-0' : 'osd:hover:shadow-node-hover', "\n                ").concat(isFaded ? 'osd:opacity-30' : 'osd:opacity-100', "\n                ").concat(isInteractive ? 'osd:cursor-pointer' : '', "\n                ").concat(className),
    style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, borderStyle), bgStyle), glowStyle), style),
    onClick: onClick,
    onDoubleClick: onDoubleClick,
    onKeyDown: isInteractive ? handleKeyDown : undefined,
    tabIndex: isInteractive ? 0 : undefined,
    role: isInteractive ? 'button' : undefined,
    "data-test-subj": rest['data-test-subj'],
    "aria-label": rest['aria-label'],
    children: [children, /*#__PURE__*/_jsx(Handle, {
      type: "source",
      position: Position.Right,
      id: "source-right"
    }), /*#__PURE__*/_jsx(Handle, {
      type: "source",
      position: Position.Left,
      id: "source-left"
    }), /*#__PURE__*/_jsx(Handle, {
      type: "source",
      position: Position.Bottom,
      id: "source-bottom"
    }), /*#__PURE__*/_jsx(Handle, {
      type: "source",
      position: Position.Top,
      id: "source-top"
    }), /*#__PURE__*/_jsx(Handle, {
      type: "target",
      position: Position.Right,
      id: "target-right"
    }), /*#__PURE__*/_jsx(Handle, {
      type: "target",
      position: Position.Left,
      id: "target-left"
    }), /*#__PURE__*/_jsx(Handle, {
      type: "target",
      position: Position.Bottom,
      id: "target-bottom"
    }), /*#__PURE__*/_jsx(Handle, {
      type: "target",
      position: Position.Top,
      id: "target-top"
    })]
  });
};