import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { s as styleInject, u as useViewHandler, G as GenericToolTip, P as PricePreview } from './index-bbdfb97a.js';
import classnames from 'classnames';
import { useHover, useLayer } from 'react-laag';
import { observer } from 'mobx-react-lite';
import { useState } from 'react';
import { useDivaCore } from '@crystaldesign/diva-core';
import MetaData from './index-7635bafb.js';
import InfoIcon from './index-04a7a9b4.js';
import { jsxs, jsx } from 'react/jsx-runtime';
import 'react-dynamic-multi-render';
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';

var articleItem = "article-item-i3J2S";
var sel = "sel-3vhEw";
var replacemode = "replacemode-XssaJ";
var wcArticleInfoContainer = "wcArticleInfoContainer-6umFd";
var pricesAreHiddenClass = "pricesAreHiddenClass-5i5mY";
var wcConfiguratorSettingsTitle = "wcConfigurator-settings-title-C-sNn";
var wcConfiguratorSettingsTitleSingleLine = "wcConfigurator-settings-title-single-line-xIggU";
var wcSize = "wcSize-DKVv4";
var wcSizeNormal = "wcSize-normal-H7PI-";
var wcImage = "wcImage-bSQnw";
var wcArticleSize = "wcArticleSize-FGDRM";
var css_248z = "/*Planner*/\n\n.article-item-i3J2S {\n  border-radius: var(--globalBorderRadius);\n  background: white;\n  position: relative;\n  display: flex;\n  z-index: 100;\n  transition: 0.35s ease;\n  cursor: pointer;\n  white-space: pre-line;\n  border: 3px solid transparent;\n  border: 3px solid var(--optionItemBorderColor, transparent);\n}\n.sel-3vhEw {\n  border: 3px solid var(--primaryColor);\n  border: 3px solid var(--optionItemBorderSelColor, var(--primaryColor));\n}\n\n.article-item-i3J2S:hover {\n  box-shadow: 0px 1px 4px rgba(68, 49, 49, 0.15);\n  z-index: 200;\n  transition: 0.15s ease;\n}\n\n.article-item-i3J2S.replacemode-XssaJ:hover {\n  border: 3px solid var(--primaryColor);\n  border: 3px solid var(--optionItemBorderHoverColor, var(--primaryColor));\n}\n\n.article-item-i3J2S:active {\n  box-shadow: 0px 1px 4px rgba(68, 49, 49, 0.6);\n}\n\n.wcArticleInfoContainer-6umFd {\n  display: flex;\n  float: left;\n  margin-top: 8px;\n  margin-left: 8px;\n  height: calc(100% - 14px);\n  max-width: calc(100% - 171.2px);\n  flex-direction: column;\n  justify-content: space-between;\n}\n\n.pricesAreHiddenClass-5i5mY .wcArticleInfoContainer-6umFd {\n  max-width: calc(100% - 100px);\n}\n\n.article-item-i3J2S .wcConfigurator-settings-title-C-sNn {\n  display: -webkit-box;\n  max-height: 64px;\n  min-height: 16px;\n  color: var(--secondaryColor);\n  font-size: 16px;\n  line-height: 20.8px;\n  overflow: hidden;\n  word-wrap: break-word;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 2;\n  position: relative;\n  -webkit-hyphens: auto;\n  hyphens: auto;\n  z-index: 100;\n  user-select: none;\n  -moz-user-select: none;\n  -webkit-user-drag: none;\n  -webkit-user-select: none;\n  -ms-user-select: none;\n}\n\n.article-item-i3J2S .wcConfigurator-settings-title-single-line-xIggU {\n  -webkit-line-clamp: 1;\n}\n.article-item-i3J2S .wcSize-DKVv4 {\n  width: 98%;\n  background: white;\n  position: relative;\n  border-radius: var(--globalBorderRadius);\n  user-select: none;\n  -moz-user-select: none;\n  -webkit-user-drag: none;\n  -webkit-user-select: none;\n  -ms-user-select: none;\n}\n\n.article-item-i3J2S .wcSize-DKVv4.wcSize-normal-H7PI- {\n  max-height: 74px;\n}\n\n.article-item-i3J2S .wcImagePlaceHolder-KQO1T {\n  width: 48px;\n  float: left;\n  height: 48px;\n}\n\n.article-item-i3J2S .wcImage-bSQnw {\n  width: 74px;\n  height: 74px;\n  float: left;\n  border-radius: var(--globalBorderRadius) 0px 0px var(--globalBorderRadius);\n  margin-left: 3.2px;\n  user-select: none;\n  -moz-user-select: none;\n  -webkit-user-drag: none;\n  -webkit-user-select: none;\n  -ms-user-select: none;\n  background-size: contain;\n  background-repeat: no-repeat;\n  background-position: 50% 50%;\n}\n\n.article-item-i3J2S .wcArticleSize-FGDRM {\n  bottom: 8px;\n  font-family: var(--diva-typography-font-family);\n  font-weight: 100;\n  font-size: 13px;\n  line-height: 16px;\n  color: #6f6f6f;\n  z-index: 50;\n\n  overflow: hidden;\n  white-space: nowrap;\n  text-overflow: ellipsis;\n}\n.article-item-i3J2S .wcArticleSize-FGDRM:hover {\n  overflow: visible;\n}\n@media all and (max-width: 1100px) {\n  .article-item-i3J2S .wcSize-normal-H7PI- {\n    height: 96px;\n  }\n\n  .article-item-i3J2S .wcConfigurator-settings-title-C-sNn {\n    -webkit-line-clamp: 2;\n  }\n}\n";
styleInject(css_248z);

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Article = function Article(_ref) {
  var _renderLayer, _item$longDescription;
  var itemP = _ref.item,
    paletteId = _ref.paletteId;
  var item = itemP;
  var viewHandler = useViewHandler();
  var _useDivaCore = useDivaCore(),
    _useDivaCore$state = _useDivaCore.state,
    _useDivaCore$state$di = _useDivaCore$state.dimensions,
    isMobile = _useDivaCore$state$di.isMobile,
    isTablet = _useDivaCore$state$di.isTablet,
    hidePrices = _useDivaCore$state.hidePrices;
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    metaDataVisible = _useState2[0],
    setMetaDataVisible = _useState2[1];

  /* tool tip stuff*/
  var triggerProps = {};
  var layerProps = {};
  var renderLayer = undefined;
  var isOver = false;
  var hoverProps = {};
  var hover = useHover({
    delayEnter: 1500,
    hideOnScroll: true
  });
  var tooltip = useLayer({
    isOpen: hover[0],
    auto: true,
    placement: viewHandler.getViewConfig().tooltipPosition || 'left-center'
  });
  if (!isMobile && !isTablet && !viewHandler.getViewConfig().hideTooltip && !item.contentItemId) {
    isOver = hover[0];
    hoverProps = hover[1];
    triggerProps = tooltip.triggerProps;
    layerProps = tooltip.layerProps;
    renderLayer = tooltip.renderLayer;
  }
  var pricesAreHidden = viewHandler.getViewConfig().dontShowBasePrice || hidePrices || !item.price;
  var isInReplaceMode = viewHandler.settingsState.plannerReplaceMode && !(paletteId == 1 && viewHandler.paletteViewHandler.plannerItems.DoShowAdditionalPlannerElements);
  return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread(_objectSpread({
    className: classnames(articleItem, pricesAreHidden ? pricesAreHiddenClass : undefined, 'wcConfigurator_Article', item.sel ? sel : undefined, isInReplaceMode ? replacemode : undefined),
    onClick: function onClick() {
      return viewHandler.paletteViewHandler.clickedOnPlannerPalette(item, paletteId);
    }
  }, triggerProps), hoverProps), {}, {
    children: [/*#__PURE__*/jsxs("div", {
      className: classnames(wcSize, wcSizeNormal),
      children: [/*#__PURE__*/jsx("div", {
        className: classnames(wcImage),
        style: {
          backgroundImage: "url(".concat(item.image, ")")
        }
      }), /*#__PURE__*/jsxs("div", {
        className: classnames(wcArticleInfoContainer),
        children: [/*#__PURE__*/jsx("div", {
          className: classnames(wcConfiguratorSettingsTitle, metaDataVisible ? wcConfiguratorSettingsTitleSingleLine : undefined),
          dangerouslySetInnerHTML: {
            __html: item.title
          }
        }), /*#__PURE__*/jsx(MetaData, {
          metaData: item.metaData,
          visible: [metaDataVisible, setMetaDataVisible]
        }, item.codex), isOver && ((_renderLayer = renderLayer) === null || _renderLayer === void 0 ? void 0 : _renderLayer(/*#__PURE__*/jsx(GenericToolTip, {
          text: (_item$longDescription = item.longDescription) !== null && _item$longDescription !== void 0 ? _item$longDescription : item.title,
          desciption: metaDataVisible,
          codex: item.articleCodex,
          image: item.image,
          layerProps: layerProps,
          price: item.price
        }, item.codex))), /*#__PURE__*/jsx("div", {
          className: classnames(wcArticleSize),
          children: item.sizeInfo
        })]
      }), item.contentItemId && /*#__PURE__*/jsx(InfoIcon, {
        item: item,
        style: {
          bottom: 8
        }
      }, item.articleCodex)]
    }), !pricesAreHidden && /*#__PURE__*/jsx(PricePreview, {
      price: item.price,
      style: {
        right: -3,
        top: -3,
        paddingTop: 6
      }
    })]
  }));
};
var Article$1 = observer(Article);

export { Article$1 as default };
