'use strict';

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var CodeBlock = require('react-syntax-highlighter/dist/esm/prism-light.js');
var prism = require('react-syntax-highlighter/dist/esm/styles/prism');
var CopyToClipboardButton = require('./CopyToClipboardButton.js');
var jsxRuntime = require('react/jsx-runtime');
require('@babel/runtime/helpers/slicedToArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('react');
require('classnames');
require('@bigbinary/neeto-commons-frontend/utils/general');
require('@bigbinary/neeto-icons/Copy');
require('@bigbinary/neeto-icons/Check');
require('@bigbinary/neetoui/Button');
require('ramda');
require('react-i18next');
require('./inject-css-B6qYtOJe.js');

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), true).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 Codeblock = function Codeblock(_ref) {
  var code = _ref.code,
    _ref$showCopyButton = _ref.showCopyButton,
    showCopyButton = _ref$showCopyButton === void 0 ? true : _ref$showCopyButton,
    codeblockProps = _ref.codeblockProps,
    _ref$copyButtonProps = _ref.copyButtonProps,
    copyButtonProps = _ref$copyButtonProps === void 0 ? {
      label: "Copy"
    } : _ref$copyButtonProps;
  var isLargerScreen = window.innerWidth > 768;
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
    className: "relative",
    children: [/*#__PURE__*/jsxRuntime.jsx(CodeBlock, _objectSpread(_objectSpread({
      wrapLines: true,
      className: "neeto-molecules-code-block p-4 pr-12 md:pr-4",
      codeTagProps: {
        "data-testid": "code-block-content"
      },
      "data-testid": "code-block",
      language: "javascript",
      style: prism.dracula
    }, codeblockProps), {}, {
      children: code
    })), showCopyButton && /*#__PURE__*/jsxRuntime.jsx(CopyToClipboardButton, _objectSpread(_objectSpread({
      className: "absolute right-2 top-2",
      "data-testid": "copy-to-clipboard-button",
      size: "small",
      style: "secondary",
      value: code
    }, copyButtonProps), {}, {
      label: isLargerScreen ? copyButtonProps.label : ""
    }))]
  });
};

module.exports = Codeblock;
//# sourceMappingURL=Codeblock.js.map
