import { u as useViewHandler, P as PricePreview, T as Toggle } from './index-bbdfb97a.js';
import 'react';
import classnames from 'classnames';
import { r as row, b as columToggleName, t as title, n as name, s as sel, a as toggle } from './index.module-d6f043d2.js';
import { getLogger } from '@crystaldesign/diva-core';
import InfoIcon from './index-04a7a9b4.js';
import ReverseCheck from './index-755074ae.js';
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
import '@babel/runtime/helpers/defineProperty';
import 'react-dynamic-multi-render';
import 'mobx-react-lite';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/helpers/slicedToArray';
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 LOG = getLogger('Planner', 'ToggleName');
var ToggleName = function ToggleName(_ref) {
  var _item$selectedElement;
  var item = _ref.item,
    paletteId = _ref.paletteId,
    style = _ref.style;
  var viewHandler = useViewHandler();
  var items = item.groups[0].items;
  var yesItem;
  var noItem;
  if (!items) {
    return /*#__PURE__*/jsx(Fragment, {});
  }
  for (var i = 0; i < items.length; i++) {
    var _items$i$codex, _items$i$codex2;
    if ((_items$i$codex = items[i].codex) !== null && _items$i$codex !== void 0 && _items$i$codex.startsWith('OPVNEIN')) {
      noItem = items[i];
    }
    if ((_items$i$codex2 = items[i].codex) !== null && _items$i$codex2 !== void 0 && _items$i$codex2.startsWith('OPVJA')) {
      yesItem = items[i];
    }
  }
  if (!noItem || !yesItem) {
    if (items.length == 2) {
      noItem = items[0];
      yesItem = items[1];
    }
    if (!noItem || !yesItem) {
      LOG.warn('Achtung! Bei der Option: ' + items[0].op + ' gibt es keine eindeutige werte für JA und NEIN', 'WC_0011');
      item.isVisited = true;
      return /*#__PURE__*/jsx(Fragment, {});
    }
  }
  var checked = noItem.sel == false;
  var contentItem = (_item$selectedElement = item.selectedElements) !== null && _item$selectedElement !== void 0 && _item$selectedElement[0].contentItemId ? item.selectedElements[0] : item.optionContentItemId ? {
    contentItemId: item.optionContentItemId,
    codex: item.configStepKey
  } : undefined;
  return /*#__PURE__*/jsxs("div", {
    className: row,
    ref: function ref(_ref2) {
      return item.htmlRef = _ref2;
    },
    style: style,
    children: [/*#__PURE__*/jsxs("div", {
      className: classnames(columToggleName, title, name),
      onClick: function onClick() {
        viewHandler.paletteViewHandler.clickedOnConfigPalette(noItem, undefined, paletteId);
      },
      children: [noItem.pricePreviewPromise !== undefined && /*#__PURE__*/jsx(PricePreview, {
        asyncPricePreview: noItem.pricePreviewPromise,
        sel: noItem.sel
      }), /*#__PURE__*/jsx("div", {
        className: !checked ? sel : undefined,
        dangerouslySetInnerHTML: {
          __html: noItem.text
        }
      })]
    }), /*#__PURE__*/jsx("div", {
      className: classnames(columToggleName, toggle),
      children: /*#__PURE__*/jsx(Toggle, {
        onChange: function onChange() {
          viewHandler.paletteViewHandler.clickedOnConfigPalette(noItem.sel ? yesItem : noItem, undefined, paletteId);
        },
        val: item,
        alwaysActiveColor: true,
        state: checked
      })
    }), /*#__PURE__*/jsxs("div", {
      className: classnames(columToggleName, title, name),
      onClick: function onClick() {
        viewHandler.paletteViewHandler.clickedOnConfigPalette(yesItem, undefined, paletteId);
      },
      children: [yesItem.pricePreviewPromise !== undefined && /*#__PURE__*/jsx(PricePreview, {
        asyncPricePreview: yesItem.pricePreviewPromise,
        sel: yesItem.sel
      }), yesItem.checkForReversingChanges !== undefined && /*#__PURE__*/jsx(ReverseCheck, {
        item: yesItem,
        paletteId: paletteId
      }), /*#__PURE__*/jsx("div", {
        className: checked ? sel : undefined,
        dangerouslySetInnerHTML: {
          __html: yesItem.text
        }
      })]
    }), contentItem && /*#__PURE__*/jsx(InfoIcon, {
      item: contentItem,
      style: {
        position: 'relative'
      }
    }, item.configStepKey)]
  });
};

export { ToggleName as default };
