var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellImageCarousels/index.tsx
var pisellImageCarousels_exports = {};
__export(pisellImageCarousels_exports, {
  default: () => pisellImageCarousels_default
});
module.exports = __toCommonJS(pisellImageCarousels_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_swiper = require("swiper");
var import_swiper_bundle = require("swiper/swiper-bundle.css");
var import_iconfont = __toESM(require("../iconfont"));
var import_classnames = __toESM(require("classnames"));
var import_index = require("./index.less");
var PisellImageCarousels = ({
  dataSource = [],
  width = 640,
  height = 400,
  showArrows = true,
  showDots = true,
  autoplay = true,
  interval = 3e3,
  borderRadius = 8,
  loop = true,
  className,
  style
}) => {
  const swiperRef = (0, import_react.useRef)(null);
  const swiperInstance = (0, import_react.useRef)(null);
  (0, import_react.useEffect)(() => {
    if (swiperRef.current) {
      swiperInstance.current = new import_swiper.Swiper(swiperRef.current, {
        modules: [import_swiper.Navigation, import_swiper.Pagination, import_swiper.Autoplay],
        slidesPerView: 1,
        spaceBetween: 0,
        loop,
        // 导航箭头
        navigation: showArrows ? {
          nextEl: ".pisell-carousel-next",
          prevEl: ".pisell-carousel-prev"
        } : false,
        // 分页点
        pagination: showDots ? {
          el: ".pisell-carousel-pagination",
          clickable: true
        } : false,
        // 自动播放
        autoplay: autoplay ? {
          delay: interval,
          disableOnInteraction: false
        } : false
      });
    }
    return () => {
      if (swiperInstance.current) {
        swiperInstance.current.destroy();
      }
    };
  }, [showArrows, showDots, autoplay, interval, loop]);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)("pisell-image-carousel", className),
      style: { width, height, ...style }
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "swiper", ref: swiperRef }, /* @__PURE__ */ import_react.default.createElement("div", { className: "swiper-wrapper" }, dataSource == null ? void 0 : dataSource.map((item, index) => /* @__PURE__ */ import_react.default.createElement("div", { key: index, className: "swiper-slide" }, /* @__PURE__ */ import_react.default.createElement(
      import_antd.Image,
      {
        preview: false,
        src: item,
        width,
        height,
        loading: "lazy",
        style: {
          borderRadius: `${borderRadius}px`
        }
      }
    )))), showArrows && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-carousel-prev" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "carousel-arrow" }, /* @__PURE__ */ import_react.default.createElement(import_iconfont.default, { type: "pisell2-chevron-left" }))), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-carousel-next" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "carousel-arrow" }, /* @__PURE__ */ import_react.default.createElement(import_iconfont.default, { type: "pisell2-chevron-right" })))), showDots && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-carousel-pagination" }))
  );
};
var pisellImageCarousels_default = PisellImageCarousels;
