import { defineComponent, openBlock, createBlock, unref, ref, computed, useSlots, watch, createElementBlock, createElementVNode, createVNode, normalizeStyle, Fragment, renderList, toDisplayString, renderSlot, createCommentVNode, nextTick } from "vue";
import WlSvg from "@wltech/svg";
const __default__$1 = {
  name: "WlSvgIcon"
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    type: { default: "" },
    color: { default: "var(--wl-text-color-title-1)" },
    width: { default: "16" },
    height: { default: "16" }
  },
  setup(__props) {
    const sub = location.origin;
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(WlSvg), {
        type: __props.type,
        width: __props.width,
        height: __props.height,
        color: __props.color,
        sub: unref(sub)
      }, null, 8, ["type", "width", "height", "color", "sub"]);
    };
  }
});
var index_vue_vue_type_style_index_0_scoped_true_lang = "";
var _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const _hoisted_1 = {
  key: 0,
  class: "text-swiper"
};
const _hoisted_2 = {
  key: 0,
  class: "text-swiper-list-item"
};
const __default__ = {
  name: "WlTextSwiper"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    data: { default: () => [] },
    distance: { default: 30 }
  },
  setup(__props) {
    const props = __props;
    const leftArrowDisabled = ref(false);
    const rightArrowDisabled = ref(false);
    const scrollDiatance = ref(0);
    const swiperListRef = ref();
    const swiperScrollRef = ref();
    const hasSlot = computed(() => {
      let slots = useSlots();
      return !!slots.default;
    });
    const onChangeArrowColor = () => {
      nextTick(() => {
        var _a, _b;
        const scroll = ((_a = swiperScrollRef.value) == null ? void 0 : _a.clientWidth) - ((_b = swiperListRef.value) == null ? void 0 : _b.clientWidth);
        const isMore = Math.abs(scrollDiatance.value) >= scroll;
        leftArrowDisabled.value = scrollDiatance.value === 0;
        rightArrowDisabled.value = scroll < 0 || isMore;
      });
    };
    const scrollStyle = computed(() => {
      return {
        transform: `translateX(${scrollDiatance.value}px)`
      };
    });
    const scrollListLen = computed(() => props.data.length);
    const onScrollLeft = () => {
      if (!leftArrowDisabled.value) {
        scrollDiatance.value += props.distance;
        onChangeArrowColor();
      }
    };
    const onScrollRight = () => {
      if (!rightArrowDisabled.value) {
        scrollDiatance.value -= props.distance;
        onChangeArrowColor();
      }
    };
    watch(
      () => scrollListLen.value,
      () => {
        onChangeArrowColor();
      },
      { immediate: true }
    );
    return (_ctx, _cache) => {
      return __props.data.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", {
          class: "left-arrow",
          onClick: onScrollLeft
        }, [
          createVNode(_sfc_main$1, {
            type: "leftFill",
            width: "36",
            height: "36",
            color: leftArrowDisabled.value ? "#e3e3e3" : "var(--wl-primary-color)"
          }, null, 8, ["color"])
        ]),
        createElementVNode("div", {
          class: "text-swiper-list",
          ref_key: "swiperListRef",
          ref: swiperListRef
        }, [
          createElementVNode("div", {
            class: "text-swiper-list-container",
            style: normalizeStyle(unref(scrollStyle)),
            ref_key: "swiperScrollRef",
            ref: swiperScrollRef
          }, [
            (openBlock(true), createElementBlock(Fragment, null, renderList(__props.data, (item) => {
              return openBlock(), createElementBlock(Fragment, {
                key: item.id
              }, [
                !unref(hasSlot) ? (openBlock(), createElementBlock("p", _hoisted_2, toDisplayString(item.name), 1)) : renderSlot(_ctx.$slots, "default", {
                  key: 1,
                  row: item
                }, void 0, true)
              ], 64);
            }), 128))
          ], 4)
        ], 512),
        createElementVNode("div", {
          class: "right-arrow",
          onClick: onScrollRight
        }, [
          createVNode(_sfc_main$1, {
            type: "rightFill",
            width: "36",
            height: "36",
            color: rightArrowDisabled.value ? "#e3e3e3" : "var(--wl-primary-color)"
          }, null, 8, ["color"])
        ])
      ])) : createCommentVNode("", true);
    };
  }
});
var Comp = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2c842030"]]);
var __uno = "";
Comp.install = (app) => {
  app.component(Comp.name, Comp);
};
export { Comp as default };
