import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { s as styleInject, u as useViewHandler, P as PricePreview, G as GenericToolTip } from './index-bbdfb97a.js';
import classnames from 'classnames';
import { observer } from 'mobx-react-lite';
import { useState } from 'react';
import { w as wcFavoriteSel, a as wcFavorite } from './index.module-25687dd9.js';
import { useHover, useLayer } from 'react-laag';
import MetaData from './index-7635bafb.js';
import { useDivaCore } from '@crystaldesign/diva-core';
import InfoIcon from './index-04a7a9b4.js';
import ReverseCheck from './index-755074ae.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';
import '@mui/icons-material/Block';
import '@mui/icons-material/Warning';

var paletteItem = "palette-item-IUL0m";
var wcVCodexText = "wcVCodexText-GN3-8";
var sel = "sel-3ZIRz";
var imageWrapper = "imageWrapper-QwsRE";
var small = "small-Ynrzj";
var wcImage = "wcImage-eveCj";
var titleWrapper = "titleWrapper-89f-B";
var title = "title-mFBM6";
var big = "big-wADuy";
var css_248z = "/*Size Normal */\n\n.palette-item-IUL0m {\n  border-radius: var(--globalBorderRadius);\n  position: relative;\n  z-index: 100;\n  transition: all 0.15s ease;\n  cursor: pointer;\n  display: flex;\n  flex-direction: column;\n  gap: 4px;\n}\n\n.palette-item-IUL0m:active,\n.palette-item-IUL0m:hover {\n  z-index: 200;\n  transition: 0.15s ease;\n}\n\n.wcVCodexText-GN3-8 {\n  position: absolute;\n  top: 50%;\n  transform: translateY(-50%);\n  width: 100%;\n  color: white;\n  display: none;\n  text-align: center;\n}\n\n.palette-item-IUL0m:hover .wcVCodexText-GN3-8,\n.sel-3ZIRz .wcVCodexText-GN3-8 {\n  display: block;\n}\n\n.imageWrapper-QwsRE {\n  border-radius: 50%;\n  border: 1px rgb(230, 230, 230) solid;\n  display: flex;\n  transition: 0.15s ease;\n  position: relative;\n}\n.palette-item-IUL0m:hover .imageWrapper-QwsRE {\n  box-shadow: 0px 1px 4px rgba(68, 49, 49, 0.15);\n  border: 1px var(--primaryColor) solid;\n  border: 1px var(--optionItemBorderSelColor, var(--primaryColor)) solid;\n}\n.sel-3ZIRz.palette-item-IUL0m:hover .imageWrapper-QwsRE,\n.small-Ynrzj.sel-3ZIRz.palette-item-IUL0m:hover .imageWrapper-QwsRE {\n  box-shadow: 0px 1px 4px rgba(68, 49, 49, 0.15);\n  border: 1px rgb(230, 230, 230) solid;\n}\n.sel-3ZIRz .imageWrapper-QwsRE,\n.small-Ynrzj.sel-3ZIRz .imageWrapper-QwsRE {\n  box-shadow: 0px 1px 4px rgba(68, 49, 49, 0.15);\n}\n\n.wcImage-eveCj {\n  width: calc(100% - 8px);\n  aspect-ratio: 1;\n  border: 4px white solid;\n  border-radius: 50%;\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  transition: border 0.3s ease;\n}\n.sel-3ZIRz .wcImage-eveCj,\n.small-Ynrzj.sel-3ZIRz .wcImage-eveCj {\n  border: 4px var(--primaryColor) solid;\n  border: 4px var(--optionItemBorderSelColor, var(--primaryColor)) solid;\n}\n\n.hexColor-NBrjx {\n  width: 80px;\n  height: 80px;\n}\n\n.titleWrapper-89f-B {\n  display: flex;\n  justify-content: center;\n  overflow: visible;\n  max-height: 32px;\n}\n\n.title-mFBM6 {\n  text-align: center;\n  width: 100%;\n  height: 32px;\n  min-height: -moz-fit-content;\n  min-height: fit-content;\n  max-height: -moz-fit-content;\n  max-height: fit-content;\n  font-size: 14px;\n  line-height: 16px;\n  overflow: hidden;\n  display: -webkit-box;\n  word-wrap: break-word;\n  -webkit-box-orient: vertical;\n  -webkit-hyphens: auto;\n  hyphens: auto;\n  -webkit-line-clamp: 2;\n  transition: height 0.3s ease-out;\n}\n\n.palette-item-IUL0m:hover .title-mFBM6,\n.palette-item-IUL0m:focus .title-mFBM6 {\n  max-height: -moz-fit-content;\n  max-height: fit-content;\n  min-height: -moz-fit-content;\n  min-height: fit-content;\n  -webkit-line-clamp: 30;\n  height: 50px;\n  z-index: 200;\n  background-color: var(--settingsBackgroundColor);\n  border-bottom-left-radius: 6px;\n  border-bottom-right-radius: 6px;\n  transition: height 0.3s ease-in;\n}\n\n@supports (-moz-appearance: none) {\n  .palette-item-IUL0m:hover .title-mFBM6,\n  .palette-item-IUL0m:focus .title-mFBM6 {\n    height: -moz-fit-content;\n    height: fit-content;\n  }\n}\n\n/* Size Small */\n\n.small-Ynrzj .wcVCodexText-GN3-8 {\n  font-size: 12px;\n}\n\n.small-Ynrzj .title-mFBM6 {\n  font-size: 12px;\n  height: 14px;\n  -webkit-line-clamp: 1;\n}\n\n.small-Ynrzj .titleWrapper-89f-B {\n  max-height: 14px;\n}\n/* Size very Small */\n\n.very-small-XTQPS .wcVCodexText-GN3-8 {\n  font-size: 10px;\n}\n\n.very-small-XTQPS .title-mFBM6 {\n  font-size: 10px;\n  -webkit-line-clamp: 1;\n}\n\n.very-small-XTQPS .titleWrapper-89f-B {\n  max-height: 20px;\n}\n\n/* Size big */\n\n.big-wADuy .wcVCodexText-GN3-8 {\n  font-size: 15px;\n}\n\n.big-wADuy .title-mFBM6 {\n  font-size: 15px;\n  -webkit-line-clamp: 2;\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 Option = function Option(_ref) {
  var _item$hexColor, _renderLayer;
  var itemP = _ref.item,
    type = _ref.type,
    paletteId = _ref.paletteId,
    hidePricePreview = _ref.hidePricePreview,
    namePostFix = _ref.namePostFix;
  var item = itemP;
  var viewHandler = useViewHandler();
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    metaDataVisible = _useState2[0],
    setMetaDataVisible = _useState2[1];
  var onClick = function onClick() {
    viewHandler.paletteViewHandler.clickedOnConfigPalette(item, undefined, paletteId);
  };
  var _useDivaCore = useDivaCore(),
    _useDivaCore$state$di = _useDivaCore.state.dimensions,
    isMobile = _useDivaCore$state$di.isMobile,
    isTablet = _useDivaCore$state$di.isTablet;

  /* 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.image || item.hexColor) && !item.contentItemId) {
    isOver = hover[0];
    hoverProps = hover[1];
    triggerProps = tooltip.triggerProps;
    layerProps = tooltip.layerProps;
    renderLayer = tooltip.renderLayer;
  }
  return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread(_objectSpread({
    id: item.codex,
    className: classnames(type == 'small' || type == 'verysmall' ? small : undefined, type == 'big' ? big : undefined, paletteItem, item.sel ? sel : undefined),
    onClick: onClick
  }, triggerProps), hoverProps), {}, {
    children: [/*#__PURE__*/jsxs("div", {
      className: classnames(imageWrapper),
      children: [viewHandler.getViewConfig().showVCodexInGallery && item.vCodex && /*#__PURE__*/jsx("div", {
        className: classnames(wcVCodexText),
        children: item.vCodex
      }), item.image ? /*#__PURE__*/jsx("img", {
        className: classnames(wcImage),
        src: type != 'small' && type != 'verysmall' ? item.image.replace('_gal', '') : item.image
      }) : /*#__PURE__*/jsx("div", {
        className: classnames(wcImage),
        style: {
          backgroundColor: '#' + ((_item$hexColor = item.hexColor) !== null && _item$hexColor !== void 0 ? _item$hexColor : 'dfdfdf')
        }
      }), item.contentItemId && /*#__PURE__*/jsx(InfoIcon, {
        item: item
      }, item.codex)]
    }), /*#__PURE__*/jsx("div", {
      className: titleWrapper,
      children: /*#__PURE__*/jsx("div", {
        className: title,
        dangerouslySetInnerHTML: {
          __html: item.text + (namePostFix ? namePostFix : '')
        }
      })
    }), item.doShowFav && /*#__PURE__*/jsx("div", {
      className: item.isFav ? wcFavoriteSel : wcFavorite,
      onClick: function onClick() {
        return viewHandler.paletteViewHandler.clickedOnFavIcon(item);
      }
    }), /*#__PURE__*/jsx(MetaData, {
      style: {
        position: 'relative',
        "float": 'left',
        display: 'none'
      },
      metaData: item.metaData,
      visible: [metaDataVisible, setMetaDataVisible]
    }, item.codex), !hidePricePreview && item.pricePreviewPromise !== undefined && /*#__PURE__*/jsx(PricePreview, {
      asyncPricePreview: item.pricePreviewPromise,
      sel: item.sel,
      style: type == 'small' || type == 'verysmall' ? {
        fontSize: 9
      } : undefined
    }), item.checkForReversingChanges !== undefined && /*#__PURE__*/jsx(ReverseCheck, {
      item: item,
      paletteId: paletteId
    }), isOver && ((_renderLayer = renderLayer) === null || _renderLayer === void 0 ? void 0 : _renderLayer(/*#__PURE__*/jsx(GenericToolTip, {
      text: item.text + (item.freeText ? item.freeText : '') + (namePostFix ? namePostFix : ''),
      hexColor: item.hexColor,
      desciption: metaDataVisible,
      pricePreviewPromise: item.pricePreviewPromise,
      image: item.image,
      layerProps: layerProps
    }, item.codex)))]
  }));
};
var GalleryText = observer(Option);

export { GalleryText as default };
