import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
import { u as useViewHandler } from './index-bbdfb97a.js';
import { observer } from 'mobx-react-lite';
import { useState, useEffect } from 'react';
import { p as posnrWrapper, s as swiperWrapper, m as mobile, a as swiperSlide, S as SettingsPosNr$1 } from './index-08388020.js';
import classnames from 'classnames';
import { Swiper, SwiperSlide } from 'swiper/react';
import { jsx, Fragment } from 'react/jsx-runtime';
import '@babel/runtime/helpers/defineProperty';
import 'react-dynamic-multi-render';
import '@crystaldesign/diva-core';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/regenerator';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@babel/runtime/helpers/toConsumableArray';
import '@crystaldesign/diva-utils';
import 'mobx';
import '@crystaldesign/web-planner-logic';
import 'qrcode.react';
import '@babel/runtime/helpers/typeof';
import 'flat';
import 'react-switch';
import 'react-countup';
import 'react-laag';

var SettingsPosNrContainer = function SettingsPosNrContainer(_ref) {
  _objectDestructuringEmpty(_ref);
  var viewHandler = useViewHandler();
  var _useState = useState(null),
    _useState2 = _slicedToArray(_useState, 2),
    swiperRef = _useState2[0],
    setSwiperRef = _useState2[1];
  var keys = Object.keys(viewHandler.settingsState.articleInfos).map(function (key) {
    return Number(key);
  }).sort(function (a, b) {
    return a - b;
  });
  useEffect(function () {
    if (swiperRef) {
      var index = Object.keys(viewHandler.settingsState.articleInfos).findIndex(function (key) {
        return viewHandler.settingsState.articleInfos[key].isActive;
      });
      if (index !== -1) {
        swiperRef.slideTo(index !== 0 ? index - 1 : index);
      }
    }
  }, [viewHandler.settingsState.articleInfos, swiperRef]);
  if (viewHandler.settingsState.posNrAreHidden) return /*#__PURE__*/jsx(Fragment, {});
  return /*#__PURE__*/jsx("div", {
    className: classnames(posnrWrapper, swiperWrapper, viewHandler.uiState.isInMobileView ? mobile : undefined),
    children: /*#__PURE__*/jsx(Swiper, {
      onSwiper: setSwiperRef,
      spaceBetween: 3,
      slidesPerView: 'auto',
      className: 'no-swiping',
      children: keys.map(function (key) {
        return /*#__PURE__*/jsx(SwiperSlide, {
          className: swiperSlide,
          children: /*#__PURE__*/jsx(SettingsPosNr$1, {
            id: key.toString()
          })
        }, key);
      })
    })
  });
};
var SettingsPosNr = observer(SettingsPosNrContainer);

export { SettingsPosNr as default };
