"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=m(require("react")),c=k(require("prop-types")),d=require("react-i18next"),e=require("carbon-components-react"),f=k(require("./Copier")),g=k(require("js-yaml")),h=k(require("classnames")),i=require("../utils/common"),j=require("./CodeViewer");require("../css/json-schema-view.css");function k(a){return a&&a.__esModule?a:{default:a}}function l(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(l=function(a){return a?c:b})(a)}function m(b,c){if(!c&&b&&b.__esModule)return b;if(null===b||"object"!==a(b)&&"function"!=typeof b)return{default:b};var d=l(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 n(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function o(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){n(h,d,e,f,g,"next",a)}function g(a){n(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function p(a,b){return u(a)||t(a,b)||r(a,b)||q()}function q(){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 r(a,b){if(a){if("string"==typeof a)return s(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)?s(a,b):void 0}}function s(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 t(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 u(a){if(Array.isArray(a))return a}var v=function(a){var c=a.extensionBody,k=a.extensionName,l=(0,b.useState)(null),m=p(l,2),n=m[0],q=m[1],r=(0,b.useState)(!1),s=p(r,2),u=s[0],v=s[1],w=(0,d.useTranslation)(),x=w.t,t=(0,b.useRef)(!1);(0,b.useEffect)(function(){return t.current=!0,function(){t.current=!1}},[]),(0,b.useEffect)(function(){c&&("false"===c?y(!1):y(c))},[c]);var y=function(){var a=o(regeneratorRuntime.mark(function a(b){var c;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:try{c=g["default"].dump(b,null,2),t.current&&c&&q(c)}catch(a){console.error(a),q(null)}case 1:case"end":return a.stop();}},a)}));return function(){return a.apply(this,arguments)}}();k&&k.startsWith("x-")&&(k=k.substr(2));var z=(0,i.isExpandable)(n,8);return b["default"].createElement("div",{className:(0,h["default"])("extensionDisplay","extension-".concat((0,i.cleanUpKey)(k)))},b["default"].createElement("div",{className:"extensionName"},k),!n&&b["default"].createElement(e.Loading,{small:!0,withOverlay:!1,"data-testid":"extension-loading"}),n&&b["default"].createElement("div",{className:(0,h["default"])("extensionBody","bx--snippet","bx--snippet--multi","bx--snippet--expand")},b["default"].createElement("div",{className:(0,h["default"])("extension_".concat((0,i.cleanUpKey)(k)),{expanded:u},{small:!z})},b["default"].createElement(j.CodeViewer,{codeLanguage:"yaml"},n)),b["default"].createElement(f["default"],{element:".extension_".concat((0,i.cleanUpKey)(k))}),b["default"].createElement(e.Link,{className:(0,h["default"])("expandCollapseLink",{hidden:!z}),onClick:function expand(){v(!u)},"data-testid":"expand-link"},u?x("show_less"):x("show_more"))))};v.propTypes={extensionBody:c["default"].any,extensionName:c["default"].string};var w=v;exports["default"]=w;