{"ast":null,"code":"import _Reflect$construct from \"@babel/runtime-corejs2/core-js/reflect/construct\";\nimport _Object$isFrozen from \"@babel/runtime-corejs2/core-js/object/is-frozen\";\nimport _classCallCheck from \"@babel/runtime-corejs2/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime-corejs2/helpers/createClass\";\nimport _assertThisInitialized from \"@babel/runtime-corejs2/helpers/assertThisInitialized\";\nimport _inherits from \"@babel/runtime-corejs2/helpers/inherits\";\nimport _possibleConstructorReturn from \"@babel/runtime-corejs2/helpers/possibleConstructorReturn\";\nimport _getPrototypeOf from \"@babel/runtime-corejs2/helpers/getPrototypeOf\";\nimport _defineProperty from \"@babel/runtime-corejs2/helpers/defineProperty\";\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(_Reflect$construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nimport * as React from \"react\";\nimport { cloneDeep } from \"lodash\";\nvar NULL_MIMETYPE = \"text/vnd.plotly.v1+html\";\nvar MIMETYPE = \"application/vnd.plotly.v1+json\";\n/*\n * As part of the init notebook mode, Plotly sneaks a <script> tag in to load\n * the plotlyjs lib. We have already loaded this though, so we \"handle\" the\n * transform by doing nothing and returning null.\n */\n\nvar PlotlyNullTransform = function PlotlyNullTransform() {\n  return null;\n};\n\nPlotlyNullTransform.MIMETYPE = NULL_MIMETYPE;\n\nvar PlotlyTransform = /*#__PURE__*/function (_React$Component) {\n  _inherits(PlotlyTransform, _React$Component);\n\n  var _super = _createSuper(PlotlyTransform);\n\n  function PlotlyTransform() {\n    var _this;\n\n    _classCallCheck(this, PlotlyTransform);\n\n    _this = _super.call(this);\n\n    _defineProperty(_assertThisInitialized(_this), \"props\", void 0);\n\n    _defineProperty(_assertThisInitialized(_this), \"plotDiv\", void 0);\n\n    _this.getFigure = _this.getFigure.bind(_assertThisInitialized(_this));\n    _this.plotDivRef = _this.plotDivRef.bind(_assertThisInitialized(_this));\n    return _this;\n  }\n\n  _createClass(PlotlyTransform, [{\n    key: \"componentDidMount\",\n    value: function componentDidMount() {\n      // Handle case of either string to be `JSON.parse`d or pure object\n      var figure = this.getFigure();\n      Plotly.newPlot(this.plotDiv, figure.data, figure.layout);\n    }\n  }, {\n    key: \"shouldComponentUpdate\",\n    value: function shouldComponentUpdate(nextProps) {\n      return this.props.data !== nextProps.data;\n    }\n  }, {\n    key: \"componentDidUpdate\",\n    value: function componentDidUpdate() {\n      var figure = this.getFigure();\n      this.plotDiv.data = figure.data;\n      this.plotDiv.layout = figure.layout;\n      Plotly.redraw(this.plotDiv);\n    }\n  }, {\n    key: \"plotDivRef\",\n    value: function plotDivRef(plotDiv) {\n      if (plotDiv) {\n        this.plotDiv = plotDiv;\n      }\n    }\n  }, {\n    key: \"getFigure\",\n    value: function getFigure() {\n      var figure = this.props.data;\n\n      if (typeof figure === \"string\") {\n        return JSON.parse(figure);\n      } // The Plotly API *mutates* the figure to include a UID, which means\n      // they won't take our frozen objects\n\n\n      if (_Object$isFrozen(figure)) {\n        return cloneDeep(figure);\n      }\n\n      return figure;\n    }\n  }, {\n    key: \"render\",\n    value: function render() {\n      var _this$getFigure = this.getFigure(),\n          layout = _this$getFigure.layout;\n\n      var style = {};\n\n      if (layout && layout.height && !layout.autosize) {\n        style.height = layout.height;\n      } // $FlowFixMe: Add typings to ref.\n\n\n      return /*#__PURE__*/React.createElement(\"div\", {\n        ref: this.plotDivRef,\n        style: style\n      });\n    }\n  }]);\n\n  return PlotlyTransform;\n}(React.Component);\n\n_defineProperty(PlotlyTransform, \"MIMETYPE\", MIMETYPE);\n\nexport { PlotlyNullTransform };\nexport default PlotlyTransform;","map":null,"metadata":{},"sourceType":"module"}