import React, { useEffect } from 'react';
import { typeRefs, methodRefs } from '@looker/sdk-codegen';
import { useHistory, useParams } from 'react-router-dom';
import { Space, Box } from '@looker/components';
import { ApixSection, DocReferences, DocSDKs, DocSource, DocTitle, ExploreType, DocSchema } from '../../components';
export var TypeScene = _ref => {
  var {
    api
  } = _ref;
  var {
    specKey,
    typeName
  } = useParams();
  var type = api.types[typeName];
  var history = useHistory();
  var typesUsed = typeRefs(api, type === null || type === void 0 ? void 0 : type.customTypes);
  var methodsUsedBy = methodRefs(api, type === null || type === void 0 ? void 0 : type.methodRefs);
  var typesUsedBy = typeRefs(api, type === null || type === void 0 ? void 0 : type.parentTypes);
  useEffect(() => {
    if (!type) {
      history.push("/".concat(specKey, "/types"));
    }
  }, [history, specKey, type]);
  return React.createElement(React.Fragment, null, type && React.createElement(ApixSection, null, React.createElement(Space, null, React.createElement(DocTitle, null, type.name), React.createElement(DocSource, {
    type: type
  })), React.createElement(Box, {
    pb: "xlarge"
  }, React.createElement(ExploreType, {
    api: api,
    type: type
  })), React.createElement(DocReferences, {
    typesUsed: typesUsed,
    typesUsedBy: typesUsedBy,
    methodsUsedBy: methodsUsedBy,
    api: api,
    specKey: specKey
  }), React.createElement(DocSDKs, {
    type: type,
    api: api
  }), React.createElement(DocSchema, {
    object: type.schema
  })));
};
//# sourceMappingURL=TypeScene.js.map