"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _slotContext = _interopRequireDefault(require("./slotContext"));
var _common = require("./common");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//

const SlotComp = ({
  slot,
  key,
  visible,
  children,
  insertSite
}) => {
  const ctx = (0, _react.useContext)(_slotContext.default);
  const uuid = key ? key : (0, _common.generateUUID)();

  // 不在插槽作用域下
  if (!ctx) {
    throw new Error('use Slot Component must in MapView scope！');
  }

  // 不存在 children
  if (!children) {
    throw new Error('Slot need children node(type is ReactNode)');
  }

  // 处理唤起
  (0, _react.useEffect)(() => {
    ctx.changeComponentVisible(slot, uuid, visible);
  }, [visible]);
  (0, _react.useEffect)(() => {
    ctx.registerSlot(slot, uuid, children, {
      start: insertSite === 'start' ? true : undefined
    });
  }, [slot]);

  // Since the component is not rendering anything directly
  return null;
};
var _default = exports.default = SlotComp;
//# sourceMappingURL=SlotComp.js.map