import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { s as styleInject, u as useViewHandler } from './index-bbdfb97a.js';
import 'react';
import { observer } from 'mobx-react-lite';
import ToolContainer from './index-f01ffae4.js';
import { useDivaCore, DivaUtils } from '@crystaldesign/diva-core';
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
import '@babel/runtime/helpers/defineProperty';
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 'classnames';
import 'qrcode.react';
import '@babel/runtime/helpers/typeof';
import 'flat';
import 'react-switch';
import 'react-countup';
import '@babel/runtime/helpers/objectDestructuringEmpty';
import 'react-dom';
import './index-78918709.js';
import 'react-rnd';

var container = "container-43rJg";
var item = "item-JRY9h";
var itemActive = "itemActive-t605y";
var badge = "badge-5hKWt";
var badgeError = "badgeError-9Bm52";
var badgeWarning = "badgeWarning-OJfXJ";
var css_248z = ".container-43rJg {\n  display: flex;\n  height: 42px;\n  gap: 12px;\n  justify-content: flex-start;\n  align-items: center;\n  overflow-x: auto;\n  overflow-y: hidden;\n  min-width: 0;\n  flex-shrink: 0;\n  position: relative;\n  z-index: 1500;\n  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n  border-top: 1px solid #e6e6e6;\n  background-color: #f3f3f3;\n}\n\n.item-JRY9h {\n  cursor: pointer;\n  min-width: 80px;\n  flex-shrink: 0;\n  padding-left: 12px;\n  padding-right: 12px;\n  padding-top: 6px;\n  padding-bottom: 6px;\n  text-align: center;\n  border-radius: 4px;\n  border-radius: var(--globalBorderRadius, 4px);\n  transition: background-color 0.15s ease;\n}\n\n.item-JRY9h:hover {\n  background-color: #e8e8e8;\n}\n\n.item-JRY9h.focus-visible-3dEl- {\n  outline: 2px solid #df2927;\n  outline: 2px solid var(--primaryColor, #df2927);\n  outline-offset: 2px;\n}\n\n.item-JRY9h.focus-visible-3dEl- {\n  outline: 2px solid #df2927;\n  outline: 2px solid #df2927;\n  outline: 2px solid var(--primaryColor, #df2927);\n  outline-offset: 2px;\n}\n\n.item-JRY9h:focus-visible {\n  outline: 2px solid #df2927;\n  outline: 2px solid var(--primaryColor, #df2927);\n  outline-offset: 2px;\n}\n\n.itemActive-t605y {\n  background-color: #e0e0e0;\n  font-weight: 600;\n}\n\n.itemActive-t605y:hover {\n  background-color: #d5d5d5;\n}\n\n.badge-5hKWt {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  min-width: 18px;\n  height: 18px;\n  padding: 0 5px;\n  margin-left: 6px;\n  font-size: 11px;\n  font-weight: 600;\n  color: #fff;\n  border-radius: 9px;\n}\n\n.badgeError-9Bm52 {\n  background-color: #e53e3e;\n}\n\n.badgeWarning-OJfXJ {\n  background-color: #d69e2e;\n}\n\n/* Dark mode – matches backoffice */\n.darkmode .container-43rJg,\nbody.darkmode .container-43rJg {\n  background-color: rgb(20, 20, 20);\n  border-top-color: rgba(255, 255, 255, 0.12);\n  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);\n  color: rgb(255, 255, 255);\n}\n\n.darkmode .item-JRY9h:hover,\nbody.darkmode .item-JRY9h:hover {\n  background-color: rgba(255, 255, 255, 0.08);\n}\n\n.darkmode .itemActive-t605y,\nbody.darkmode .itemActive-t605y {\n  background-color: rgba(255, 255, 255, 0.12);\n}\n\n.darkmode .itemActive-t605y:hover,\nbody.darkmode .itemActive-t605y:hover {\n  background-color: rgba(255, 255, 255, 0.16);\n}\n";
styleInject(css_248z);

var Toolbar = function Toolbar(_props) {
  var _viewHandler$divaWebP, _viewHandler$divaWebP2, _viewHandler$divaWebP3, _viewHandler$productS;
  var viewHandler = useViewHandler();
  var articles = (_viewHandler$divaWebP = (_viewHandler$divaWebP2 = viewHandler.divaWebPlanner) === null || _viewHandler$divaWebP2 === void 0 || (_viewHandler$divaWebP3 = _viewHandler$divaWebP2.getDivaArticles) === null || _viewHandler$divaWebP3 === void 0 ? void 0 : _viewHandler$divaWebP3.call(_viewHandler$divaWebP2, undefined, true)) !== null && _viewHandler$divaWebP !== void 0 ? _viewHandler$divaWebP : {};
  var dataCreationIssues = Object.values(articles).flatMap(function (a) {
    var _a$dataCreationErrors;
    return (_a$dataCreationErrors = a.dataCreationErrors) !== null && _a$dataCreationErrors !== void 0 ? _a$dataCreationErrors : [];
  });
  var errorCount = dataCreationIssues.filter(function (e) {
    var _e$severity;
    return ((_e$severity = e.severity) !== null && _e$severity !== void 0 ? _e$severity : 'error') === 'error';
  }).length;
  var warningCount = dataCreationIssues.filter(function (e) {
    return e.severity === 'warning';
  }).length + viewHandler.productState.plannerMessagesArr.filter(function (_ref) {
    var _ref2 = _slicedToArray(_ref, 2),
      item = _ref2[1];
    return item.type === 'WARNING';
  }).length;
  var infoCount = viewHandler.productState.plannerMessagesArr.filter(function (_ref3) {
    var _ref4 = _slicedToArray(_ref3, 2),
      item = _ref4[1];
    return item.type === 'INFO';
  }).length;
  var _useDivaCore = useDivaCore(),
    wwsClient = _useDivaCore.state.organization.settings.wwsClient;
  var toggleWindow = function toggleWindow(type) {
    if (viewHandler.wysiwygDebugState.activeWysiwygWindows.has(type)) {
      viewHandler.wysiwygDebugState.removeWysiwygWindow(type);
    } else {
      viewHandler.wysiwygDebugState.addWysiwygWindow(type);
    }
  };
  var isActive = function isActive(type) {
    return viewHandler.wysiwygDebugState.activeWysiwygWindows.has(type);
  };
  var handleInspectViewChange = function handleInspectViewChange() {
    var newValue = !viewHandler.wysiwygDebugState.wysiwygInspectView;
    viewHandler.wysiwygDebugState.setWysiwygInspectView(newValue);
    var actSet = viewHandler.divaWebPlanner.actSet();
    if (actSet) actSet.inspectMode = newValue;
    viewHandler.divaWebPlanner.updateConfiguratorStructureOfActSet();
    viewHandler.paletteViewHandler.updateCurPaletteData(true);
  };
  return /*#__PURE__*/jsxs(Fragment, {
    children: [/*#__PURE__*/jsx(ToolContainer, {}), /*#__PURE__*/jsxs("div", {
      className: container,
      children: [/*#__PURE__*/jsx("div", {
        className: item,
        children: DivaUtils.formatPrice((_viewHandler$productS = viewHandler.productState.formatedTotalPrice) !== null && _viewHandler$productS !== void 0 ? _viewHandler$productS : 0, viewHandler.productState.priceFormat)
      }), /*#__PURE__*/jsx("div", {
        className: viewHandler.wysiwygDebugState.wysiwygInspectView ? "".concat(item, " ").concat(itemActive) : item,
        onClick: handleInspectViewChange,
        role: "button",
        tabIndex: 0,
        onKeyDown: function onKeyDown(e) {
          return e.key === 'Enter' && handleInspectViewChange();
        },
        children: "Inspect"
      }), /*#__PURE__*/jsx("div", {
        className: isActive('PartList') ? "".concat(item, " ").concat(itemActive) : item,
        onClick: function onClick() {
          return toggleWindow('PartList');
        },
        role: "button",
        tabIndex: 0,
        onKeyDown: function onKeyDown(e) {
          return e.key === 'Enter' && toggleWindow('PartList');
        },
        children: "St\xFCckliste"
      }), /*#__PURE__*/jsx("div", {
        className: isActive('PriceAnalyzer') ? "".concat(item, " ").concat(itemActive) : item,
        onClick: function onClick() {
          return toggleWindow('PriceAnalyzer');
        },
        role: "button",
        tabIndex: 0,
        onKeyDown: function onKeyDown(e) {
          return e.key === 'Enter' && toggleWindow('PriceAnalyzer');
        },
        children: "Preise"
      }), /*#__PURE__*/jsx("div", {
        className: isActive('PriceList') ? "".concat(item, " ").concat(itemActive) : item,
        onClick: function onClick() {
          return toggleWindow('PriceList');
        },
        role: "button",
        tabIndex: 0,
        onKeyDown: function onKeyDown(e) {
          return e.key === 'Enter' && toggleWindow('PriceList');
        },
        children: "Preisliste"
      }), /*#__PURE__*/jsx("div", {
        className: isActive('DecisionAnalyzer') ? "".concat(item, " ").concat(itemActive) : item,
        onClick: function onClick() {
          return toggleWindow('DecisionAnalyzer');
        },
        role: "button",
        tabIndex: 0,
        onKeyDown: function onKeyDown(e) {
          return e.key === 'Enter' && toggleWindow('DecisionAnalyzer');
        },
        children: "Decisions"
      }), /*#__PURE__*/jsx("div", {
        className: isActive('OptionTreeTable') ? "".concat(item, " ").concat(itemActive) : item,
        onClick: function onClick() {
          return toggleWindow('OptionTreeTable');
        },
        role: "button",
        tabIndex: 0,
        onKeyDown: function onKeyDown(e) {
          return e.key === 'Enter' && toggleWindow('OptionTreeTable');
        },
        children: "Option Tree"
      }), /*#__PURE__*/jsxs("div", {
        className: isActive('ErrorWarningOverview') ? "".concat(item, " ").concat(itemActive) : item,
        onClick: function onClick() {
          return toggleWindow('ErrorWarningOverview');
        },
        role: "button",
        tabIndex: 0,
        onKeyDown: function onKeyDown(e) {
          return e.key === 'Enter' && toggleWindow('ErrorWarningOverview');
        },
        children: ["Errors & Warnings", errorCount > 0 && /*#__PURE__*/jsx("span", {
          className: "".concat(badge, " ").concat(badgeError),
          children: errorCount
        }), warningCount > 0 && /*#__PURE__*/jsx("span", {
          className: "".concat(badge, " ").concat(badgeWarning),
          children: warningCount
        }), errorCount === 0 && warningCount === 0 && infoCount > 0 && /*#__PURE__*/jsx("span", {
          className: "".concat(badge, " ").concat(badgeWarning),
          children: infoCount
        })]
      }), wwsClient === 'Pfister' && /*#__PURE__*/jsx("div", {
        className: isActive('ekText') ? "".concat(item, " ").concat(itemActive) : item,
        onClick: function onClick() {
          return toggleWindow('ekText');
        },
        role: "button",
        tabIndex: 0,
        onKeyDown: function onKeyDown(e) {
          return e.key === 'Enter' && toggleWindow('ekText');
        },
        children: "Ek Text"
      })]
    })]
  });
};
var Toolbar$1 = observer(Toolbar);

export { Toolbar$1 as default };
