import "../styles/reset.css";
import "./swiper.less";
import { PropTypes as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__, withInstall as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_withInstall__ } from "../shared";
import { computed as __WEBPACK_EXTERNAL_MODULE_vue_computed__, createVNode as __WEBPACK_EXTERNAL_MODULE_vue_createVNode__, defineComponent as __WEBPACK_EXTERNAL_MODULE_vue_defineComponent__, onBeforeUnmount as __WEBPACK_EXTERNAL_MODULE_vue_onBeforeUnmount__, onMounted as __WEBPACK_EXTERNAL_MODULE_vue_onMounted__, ref as __WEBPACK_EXTERNAL_MODULE_vue_ref__, toRefs as __WEBPACK_EXTERNAL_MODULE_vue_toRefs__, watch as __WEBPACK_EXTERNAL_MODULE_vue_watch__ } from "vue";
import { usePrefix as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_config_provider_fe8577a3_usePrefix__ } from "../config-provider";

;// external "../shared"

;// external "vue"

;// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
function _typeof(o) {
  "@babel/helpers - typeof";

  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
    return typeof o;
  } : function (o) {
    return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  }, _typeof(o);
}

;// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js

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);
}

;// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js


function toPropertyKey(t) {
  var i = toPrimitive(t, "string");
  return "symbol" == _typeof(i) ? i : i + "";
}

;// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js

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;
}

;// external "../config-provider"

;// ../../packages/swiper/src/swiper.tsx


/*
 * Tencent is pleased to support the open source community by making
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
 *
 * Copyright (C) 2025 Tencent.  All rights reserved.
 *
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
 *
 * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
 *
 * ---------------------------------------------------
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
 * the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */



/* harmony default export */ const swiper = (__WEBPACK_EXTERNAL_MODULE_vue_defineComponent__({
  name: 'Swiper',
  props: {
    isLoop: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.bool.def(true),
    loopTime: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number.def(8000),
    pics: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.array.def([]),
    list: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.array.def([]),
    height: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number,
    width: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number
  },
  emits: ['index-change'],
  setup: function setup(props, _ref) {
    var emit = _ref.emit,
      slots = _ref.slots;
    // 属性
    var _toRefs = __WEBPACK_EXTERNAL_MODULE_vue_toRefs__(props),
      isLoop = _toRefs.isLoop,
      loopTime = _toRefs.loopTime,
      pics = _toRefs.pics,
      list = _toRefs.list,
      height = _toRefs.height,
      width = _toRefs.width;
    // 声明变量
    var swiperRef = __WEBPACK_EXTERNAL_MODULE_vue_ref__();
    var swiperIndex = __WEBPACK_EXTERNAL_MODULE_vue_ref__(0);
    var renderWidth = __WEBPACK_EXTERNAL_MODULE_vue_ref__(0);
    var renderHeight = __WEBPACK_EXTERNAL_MODULE_vue_ref__(0);
    var loopId = __WEBPACK_EXTERNAL_MODULE_vue_ref__(0);
    var resizeObserver;
    var _usePrefix = __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_config_provider_fe8577a3_usePrefix__(),
      resolveClassName = _usePrefix.resolveClassName;
    // 计算属性
    var computedRenderDataList = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      var _list$value;
      return ((_list$value = list.value) === null || _list$value === void 0 ? void 0 : _list$value.length) > 0 ? list.value : pics.value;
    });
    var computedSwiperTranslateStyle = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      return {
        width: "".concat(renderWidth.value * computedRenderDataList.value.length, "px"),
        transform: "translateX(-".concat(renderWidth.value * swiperIndex.value, "px)")
      };
    });
    var computedSwiperRenderStyle = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      return {
        width: "".concat(renderWidth.value, "px"),
        height: "".concat(renderHeight.value, "px")
      };
    });
    // 方法
    var changeIndex = function changeIndex(index) {
      var showIndex = index;
      // 边界处理
      if (index >= computedRenderDataList.value.length) {
        showIndex = 0;
      }
      if (index < 0) {
        showIndex = computedRenderDataList.value.length - 1;
      }
      swiperIndex.value = showIndex;
      emit('index-change', showIndex);
    };
    var goToLink = function goToLink(link) {
      if (!link) return;
      window.open(link, '_blank');
    };
    var getRenderItemClass = function getRenderItemClass(renderData) {
      return ["".concat(resolveClassName('swiper-img')), _defineProperty({}, "".concat(resolveClassName('swiper-link')), renderData.link), renderData["class"]];
    };
    var getRenderItemStyle = function getRenderItemStyle(renderData) {
      return {
        'background-image': "url(".concat(renderData.url, ")"),
        'background-color': renderData.color
      };
    };
    var getRenderIndexStyle = function getRenderIndexStyle(index) {
      return _defineProperty({}, "".concat(resolveClassName('current-index')), swiperIndex.value === index);
    };
    var _startLoop = function startLoop() {
      if (isLoop.value) {
        loopId.value = window.setTimeout(function () {
          changeIndex(swiperIndex.value + 1);
          _startLoop();
        }, loopTime.value);
      }
    };
    var endLoop = function endLoop() {
      window.clearTimeout(loopId.value);
    };
    // 如果没有传递高宽属性，组件的高宽需要随着父元素的变化而变化
    var watchParentSizeChange = function watchParentSizeChange() {
      var _swiperRef$value;
      var parentEle = (_swiperRef$value = swiperRef.value) === null || _swiperRef$value === void 0 ? void 0 : _swiperRef$value.parentElement;
      if (!parentEle || !window.ResizeObserver) {
        return;
      }
      resizeObserver = new ResizeObserver(function () {
        calcSize();
      });
      resizeObserver.observe(parentEle);
    };
    var endWatchParentSizeChange = function endWatchParentSizeChange() {
      var _resizeObserver$disco, _resizeObserver;
      (_resizeObserver$disco = (_resizeObserver = resizeObserver).disconnect) === null || _resizeObserver$disco === void 0 || _resizeObserver$disco.call(_resizeObserver);
    };
    var getElementSize = function getElementSize(node) {
      if (node === undefined) {
        return {
          height: 0,
          width: 0
        };
      }
      var computedStyle = getComputedStyle(node);
      var width = node.clientWidth - parseFloat(computedStyle.paddingTop) - parseFloat(computedStyle.paddingBottom);
      var height = node.clientHeight - parseFloat(computedStyle.paddingLeft) - parseFloat(computedStyle.paddingRight);
      return {
        height: height,
        width: width
      };
    };
    // 计算组件的高宽 & 宽度
    var calcSize = function calcSize() {
      var _swiperRef$value2;
      var swiperParentSize = getElementSize((_swiperRef$value2 = swiperRef.value) === null || _swiperRef$value2 === void 0 ? void 0 : _swiperRef$value2.parentElement);
      renderWidth.value = +width.value > 0 ? width.value : swiperParentSize.width;
      renderHeight.value = +height.value > 0 ? height.value : swiperParentSize.height;
    };
    __WEBPACK_EXTERNAL_MODULE_vue_watch__([height, width], calcSize);
    __WEBPACK_EXTERNAL_MODULE_vue_onMounted__(function () {
      calcSize();
      _startLoop();
      watchParentSizeChange();
    });
    __WEBPACK_EXTERNAL_MODULE_vue_onBeforeUnmount__(function () {
      endLoop();
      endWatchParentSizeChange();
    });
    // render
    return function () {
      return __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("section", {
        "ref": swiperRef,
        "style": computedSwiperRenderStyle.value,
        "class": "".concat(resolveClassName('swiper-home'))
      }, [__WEBPACK_EXTERNAL_MODULE_vue_createVNode__("hgroup", {
        "style": computedSwiperTranslateStyle.value,
        "class": "".concat(resolveClassName('transition'), " ").concat(resolveClassName('swiper-main'))
      }, [computedRenderDataList.value.map(function (renderData) {
        var _slots$default, _slots$default2;
        return __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("h3", {
          "style": computedSwiperRenderStyle.value,
          "class": "".concat(resolveClassName('swiper-card'))
        }, [(_slots$default = (_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots, renderData)) !== null && _slots$default !== void 0 ? _slots$default : __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("span", {
          "style": getRenderItemStyle(renderData),
          "class": getRenderItemClass(renderData),
          "onClick": function onClick() {
            return goToLink(renderData.link);
          }
        }, null)]);
      })]), __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("ul", {
        "class": "".concat(resolveClassName('swiper-index'))
      }, [computedRenderDataList.value.map(function (_, index) {
        return __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("li", {
          "class": getRenderIndexStyle(index),
          "onMouseover": function onMouseover() {
            return changeIndex(index);
          }
        }, null);
      })]), __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("span", {
        "class": "".concat(resolveClassName('swiper-nav'), " ").concat(resolveClassName('nav-prev')),
        "onClick": function onClick() {
          return changeIndex(swiperIndex.value - 1);
        }
      }, [__WEBPACK_EXTERNAL_MODULE_vue_createVNode__("i", {
        "class": "".concat(resolveClassName('swiper-nav-icon'))
      }, null)]), __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("span", {
        "class": "".concat(resolveClassName('swiper-nav'), " ").concat(resolveClassName('nav-next')),
        "onClick": function onClick() {
          return changeIndex(swiperIndex.value + 1);
        }
      }, [__WEBPACK_EXTERNAL_MODULE_vue_createVNode__("i", {
        "class": "".concat(resolveClassName('swiper-nav-icon'))
      }, null)])]);
    };
  }
}));
;// ../../packages/swiper/src/index.ts
/*
 * Tencent is pleased to support the open source community by making
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
 *
 * Copyright (C) 2025 Tencent.  All rights reserved.
 *
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
 *
 * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
 *
 * ---------------------------------------------------
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
 * the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */


var BkSwiper = __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_withInstall__(swiper);
/* harmony default export */ const src = (BkSwiper);
export { src as default };
