"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=o(require("react")),c=require("./utils/APITypes.js"),d=m(require("./contexts/ApiHandler/index.js")),e=require("./hooks/createApiHandler.js"),f=require("react-router-dom"),g=m(require("./components/Routing.js")),h=m(require("./components/ExplorerBody.js")),i=require("./utils/navigation.js"),j=require("./contexts/config/index.js"),k=require("carbon-components-react"),l=require("react-i18next");function m(a){return a&&a.__esModule?a:{default:a}}function n(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(n=function(a){return a?c:b})(a)}function o(b,c){if(!c&&b&&b.__esModule)return b;if(null===b||"object"!==a(b)&&"function"!=typeof b)return{default:b};var d=n(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 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,b,c,d){var e=null;if(b&&c&&d&&d[a]){var f=c.indexOf(b);e=d[a][f]||null}return e},w=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:[],b=1<arguments.length?arguments[1]:void 0,d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:a[0];return{currentApi:d,apiType:(0,c.getAPIType)(d),infoSectionEntries:v("infoSectionEntries",d,a,b),documentationEntries:v("documentationEntries",d,a,b)}},x=function(){return b["default"].createElement(f.Route,{path:["/:entity/*","/"],component:function component(a){var c=a.location,m=(0,f.useParams)(),n=(0,b.useMemo)(function(){return m.entity&&"documentation"!==m.entity},[m]),o=(0,j.useConfig)(),q=o.apis,r=o.options,s=(0,b.useState)(function(){return w(q,r,n?(0,i.getApi)(q,m.entity):q[0])}),u=p(s,2),v=u[0],x=u[1],y=(0,e.useCreateApiHandler)(v.currentApi),z=y.originalApi,A=y.apiHandler,B=y.loading,C=y.error,D=(0,l.useTranslation)(),E=D.t;(0,b.useEffect)(function(){x(w(q,r,n?(0,i.getApi)(q,m.entity):q[0]))},[q,r,n,m.entity]),(0,b.useEffect)(function(){try{var a=r.onReady;"string"==typeof a?window[a]():"function"==typeof a&&a()}catch(a){console.error("onReady callback failed:",a)}},[r.onReady]),(0,b.useEffect)(function(){if(n){var a=(0,i.getApi)(q,m.entity);(0,i.apiPath)(v.currentApi)!==(0,i.apiPath)(a)&&x(w(q,r,a))}},[m,q,m.entity,v.currentApi,n,r]);var t=B?b["default"].createElement(k.InlineLoading,null):C&&!c.pathname.includes("parseerror")?b["default"].createElement(k.ToastNotification,{kind:"error",title:E("async_parse_errors"),subtitle:E("async_parse_errors_description"),caption:b["default"].createElement("pre",{className:"validationErrorText"},b["default"].createElement("code",null,C)),className:"errorFrame",hideCloseButton:!0}):b["default"].createElement(g["default"],{apiState:v});var F="GraphQL"!==v.apiType;return b["default"].createElement(d["default"],{api:z,handler:A,loading:B,error:C},b["default"].createElement(h["default"],{splitView:F},t))}})},y=x;exports["default"]=y;