"use strict";

import { useEffect, useRef } from 'react';
import NativeBanner from '../specs/ATBannerViewNativeComponent';
import { ATAdEvents } from "../events/ATAdEvents.js";

/**
 * Banner Fabric 组件封装。
 * 位置/布局由 RN style 控制；width/height 为请求广告尺寸（dp）。
 * 事件 V1 走唯一 BannerCall 通道，按本视图 placementID 过滤后回调 onAdEvent。
 */
import { jsx as _jsx } from "react/jsx-runtime";
export function ATBannerViewComponent(props) {
  const {
    placementID,
    width,
    height,
    isAdaptiveHeight,
    onAdEvent,
    style,
    ...rest
  } = props;
  const cb = useRef(onAdEvent);
  cb.current = onAdEvent;
  useEffect(() => {
    ATAdEvents.setAdListener(placementID, p => cb.current?.(p));
    return () => ATAdEvents.removeAdListener(placementID);
  }, [placementID]);
  return /*#__PURE__*/_jsx(NativeBanner, {
    placementID: placementID,
    adWidth: width,
    adHeight: height,
    isAdaptiveHeight: isAdaptiveHeight,
    style: [{
      width,
      height: isAdaptiveHeight ? undefined : height
    }, style],
    ...rest
  });
}
//# sourceMappingURL=ATBannerViewComponent.js.map