"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TypeScene = void 0;

var _react = _interopRequireWildcard(require("react"));

var _sdkCodegen = require("@looker/sdk-codegen");

var _reactRouterDom = require("react-router-dom");

var _components = require("@looker/components");

var _components2 = require("../../components");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var TypeScene = _ref => {
  var {
    api
  } = _ref;
  var {
    specKey,
    typeName
  } = (0, _reactRouterDom.useParams)();
  var type = api.types[typeName];
  var history = (0, _reactRouterDom.useHistory)();
  var typesUsed = (0, _sdkCodegen.typeRefs)(api, type === null || type === void 0 ? void 0 : type.customTypes);
  var methodsUsedBy = (0, _sdkCodegen.methodRefs)(api, type === null || type === void 0 ? void 0 : type.methodRefs);
  var typesUsedBy = (0, _sdkCodegen.typeRefs)(api, type === null || type === void 0 ? void 0 : type.parentTypes);
  (0, _react.useEffect)(() => {
    if (!type) {
      history.push("/".concat(specKey, "/types"));
    }
  }, [history, specKey, type]);
  return _react.default.createElement(_react.default.Fragment, null, type && _react.default.createElement(_components2.ApixSection, null, _react.default.createElement(_components.Space, null, _react.default.createElement(_components2.DocTitle, null, type.name), _react.default.createElement(_components2.DocSource, {
    type: type
  })), _react.default.createElement(_components.Box, {
    pb: "xlarge"
  }, _react.default.createElement(_components2.ExploreType, {
    api: api,
    type: type
  })), _react.default.createElement(_components2.DocReferences, {
    typesUsed: typesUsed,
    typesUsedBy: typesUsedBy,
    methodsUsedBy: methodsUsedBy,
    api: api,
    specKey: specKey
  }), _react.default.createElement(_components2.DocSDKs, {
    type: type,
    api: api
  }), _react.default.createElement(_components2.DocSchema, {
    object: type.schema
  })));
};

exports.TypeScene = TypeScene;
//# sourceMappingURL=TypeScene.js.map