import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { u as useViewHandler, T as Toggle } from './index-bbdfb97a.js';
import 'react';
import { DivaUtils } from '@crystaldesign/diva-core';
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
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 'classnames';
import 'qrcode.react';
import '@babel/runtime/helpers/typeof';
import 'flat';
import 'react-switch';
import 'react-countup';

var SummaryVariantButton = function SummaryVariantButton(_ref) {
  var _variantPalette$1$gro;
  _ref.item;
  var viewHandler = useViewHandler();
  var variantPalette = viewHandler.settingsState.itemPaletteArr.find(function (item) {
    return item[1].type === 'VARIANTS' && item[1].visible;
  });
  if (!variantPalette) return /*#__PURE__*/jsx(Fragment, {});
  var variants = (_variantPalette$1$gro = variantPalette[1].groups) === null || _variantPalette$1$gro === void 0 || (_variantPalette$1$gro = _variantPalette$1$gro[0]) === null || _variantPalette$1$gro === void 0 ? void 0 : _variantPalette$1$gro.items;
  if (!(variants !== null && variants !== void 0 && variants.length)) return /*#__PURE__*/jsx(Fragment, {});
  var copyTableToClipboard = function copyTableToClipboard() {
    var html = '<h3>' + viewHandler.productState.webConifguratorTitle + ' - ' + Object.values(viewHandler.settingsState.articleInfos).map(function (article) {
      return article.name;
    }).join(', ') + '</h3>' + '<table>' + variants.map(function (variant) {
      if (variant.index === undefined) return '';
      return '<tr>' + '<td>' + 'index: ' + variant.index + '</td>' + variant.variantValues.map(function (values) {
        return (values.optionValueImage ? '<td>' + '<img src="' + values.optionValueImage + '"/>' + '</td>' : '') +
        //::::
        '<td>' + (values.optionName + ' (' + values.opt.substring(3) + '):') + '<br/>' + (values.optionValueName + ' (' + values.opv.substring(3) + ')') + '</td>';
      }).join('') + '<td>' + DivaUtils.formatPrice(variant.price) + '</td>' + '</tr>';
    }).join('') + '</table>';
    var blob = new Blob([html], {
      type: 'text/html'
    });
    navigator.clipboard.write([new ClipboardItem(_defineProperty({}, blob.type, blob))]);
  };
  return /*#__PURE__*/jsxs(Fragment, {
    children: [/*#__PURE__*/jsx("button", {
      onClick: copyTableToClipboard,
      children: "als Tabelle kopieren"
    }), /*#__PURE__*/jsx(Toggle, {
      height: 32,
      handleDiameter: 22,
      width: 60,
      onChange: function onChange() {
        variants[0].onToggle(true);
        viewHandler.paletteViewHandler.updateCurPaletteData(true);
      },
      state: !variants.find(function (variant) {
        return variant.disabled;
      })
    })]
  });
};

export { SummaryVariantButton as default };
