"use strict";function a(b){"@babel/helpers - typeof";return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},a(b)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var b=n(require("react")),c=require("./../hooks/booleanHooks.js"),d=require("react-i18next"),e=require("carbon-components-react"),f=require("./../utils/CodeViewerLanguageMapper.js"),g=l(require("./ExpandableDisplay")),h=require("./CodeViewer"),i=require("lodash"),j=l(require("classnames")),k=l(require("prop-types"));function l(a){return a&&a.__esModule?a:{default:a}}function m(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(m=function(a){return a?c:b})(a)}function n(b,c){if(!c&&b&&b.__esModule)return b;if(null===b||"object"!==a(b)&&"function"!=typeof b)return{default:b};var d=m(c);if(d&&d.has(b))return d.get(b);var e={},f=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var g in b)if("default"!=g&&Object.prototype.hasOwnProperty.call(b,g)){var h=f?Object.getOwnPropertyDescriptor(b,g):null;h&&(h.get||h.set)?Object.defineProperty(e,g,h):e[g]=b[g]}return e["default"]=b,d&&d.set(b,e),e}function o(a,b){return t(a)||s(a,b)||q(a,b)||p()}function p(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function q(a,b){if(a){if("string"==typeof a)return r(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?r(a,b):void 0}}function r(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function s(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f=[],g=!0,h=!1;try{for(c=c.call(a);!(g=(d=c.next()).done)&&(f.push(d.value),!(b&&f.length===b));g=!0);}catch(a){h=!0,e=a}finally{try{g||null==c["return"]||c["return"]()}finally{if(h)throw e}}return f}}function t(a){if(Array.isArray(a))return a}var u=function(a){var k=a.generating,l=a.dependencyContent,m=a.errorText,n=a.activeCodeLanguage,p=void 0===n?"":n,q=a.label,r=(0,d.useTranslation)(),s=r.t,t=(0,c.useToggle)(!1),u=o(t,2),v=u[0],w=u[1],x=(0,b.useRef)("code-snippet-".concat((0,i.uniqueId)())),y=x.current;return b["default"].createElement("div",null,m?function renderError(a){return b["default"].createElement("div",{"data-testid":"snippet-error"},s("generator_error",{error:a}))}(m):k?function renderLoading(){return b["default"].createElement(e.Loading,{small:!0,withOverlay:!1,"data-testid":"loading-icon"})}():b["default"].createElement("div",null,q&&b["default"].createElement("p",{className:"codeSnippetLabel","data-testid":"dependencies-label"},q),b["default"].createElement(g["default"],{expanded:v,onExpand:w},b["default"].createElement(h.CodeViewer,{"aria-label":s("dependencies"),"data-copytarget":y,"data-testid":"generated-code",codeLanguage:(0,f.getHighlightClassForDependencies)(p),className:(0,j["default"])("codeSnippetContent",{expanded:v})},l))))};u.propTypes={generating:k["default"].bool,dependencyContent:k["default"].string,errorText:k["default"].string,activeCodeLanguage:k["default"].string,label:k["default"].string},u.defaultProps={dependencyContent:"",activeCodeLanguage:""};var v=u;exports["default"]=v;