"use strict";

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

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

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

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

var _icons = require("@looker/icons");

var _reactRedux = require("react-redux");

var _state = require("../../state");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var DocSource = _ref => {
  var {
    method,
    type
  } = _ref;
  var declarations = (0, _reactRedux.useSelector)(_state.selectDeclarationsLode);
  var sourceLink;
  var declaration;

  if (declarations) {
    ;
    ({
      declaration,
      link: sourceLink
    } = (0, _sdkCodegen.findDeclaration)(declarations, method === null || method === void 0 ? void 0 : method.id, type === null || type === void 0 ? void 0 : type.name));
  }

  return _react.default.createElement(_react.default.Fragment, null, sourceLink && declaration && _react.default.createElement(_components.Tooltip, {
    content: "".concat(declaration.sourceFile, "#L").concat(declaration.line),
    width: "none"
  }, _react.default.createElement(_components.Link, {
    href: sourceLink,
    target: "_blank"
  }, _react.default.createElement(_components.Icon, {
    icon: _react.default.createElement(_icons.IdeFileDocument, null)
  }))));
};

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