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7D,CAuCA,OA7HA,EAAI,WAAW,SAAS,EAAe,IAwFvC,EAAI,cAAc,SAAS,EAAe,CAAC,CACzC,IAAK,oBACL,MAAO,WAEL,KAAK,aAAa,KAAK,OACvB,KAAK,aAAa,KAAK,MACzB,GACC,CACD,IAAK,4BACL,MAAO,SAAmC,GAExC,KAAK,aAAa,GAClB,KAAK,aAAa,EACpB,GAGC,CACD,IAAK,SACL,MAAO,WACL,IAAI,EAAS,KAAK,MACd,EAAM,EAAO,IACb,EAAK,EAAO,GACZ,EAAc,EAAO,YACrB,EAAY,EAAO,UACnB,EAAQ,EAAO,MAEnB,OAAO,QAAQ,QAAQ,cAAc,SAAU,CAC7C,IAAK,QACL,IAAK,EACL,GAAI,EACJ,YAAa,EACb,UAAW,EACX,MAAO,EACP,OAAQ,KAAK,QAEjB,KAEK,CACT,CA/HoB,CA+HlB,QAAQ,QAAQ,WAElB,cAAc,UAAY,CAGxB,QAAS,YAAY,QAAQ,UAAU,CAAC,YAAY,QAAQ,OAAQ,YAAY,QAAQ,UAExF,IAAK,YAAY,QAAQ,OAEzB,oBAAqB,YAAY,QAAQ,KACzC,yBAA0B,YAAY,QAAQ,KAC9C,qBAAsB,YAAY,QAAQ,OAC1C,iBAAkB,YAAY,QAAQ,UAAU,CAAC,YAAY,QAAQ,OACrE,YAAY,QAAQ,OAGpB,GAAI,YAAY,QAAQ,OACxB,YAAa,YAAY,QAAQ,OACjC,UAAW,YAAY,QAAQ,OAC/B,MAAO,YAAY,QAAQ,QAI7B,cAAc,aAAe,CAE3B,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAsB,CAQpB,QAAS,EACT,MAAO,KAET,iBAAkB,iGAElB,YAAa,EACb,MAAO,CACL,MAAO,OACP,UAAW,KAIf,QAAQ,QAAU","file":"/npm/quarks-ui-iframe-resizer@0.0.2/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/quarks-ui-iframe-resizer@0.0.2/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');\n\nvar _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = require('babel-runtime/helpers/createClass');\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');\n\nvar _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);\n\nvar _inherits2 = require('babel-runtime/helpers/inherits');\n\nvar _inherits3 = _interopRequireDefault(_inherits2);\n\nvar _promise = require('babel-runtime/core-js/promise');\n\nvar _promise2 = _interopRequireDefault(_promise);\n\nvar _react = require('react');\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _propTypes = require('prop-types');\n\nvar _propTypes2 = _interopRequireDefault(_propTypes);\n\nvar _reactDom = require('react-dom');\n\nvar _reactDom2 = _interopRequireDefault(_reactDom);\n\nvar _iframeResizer = require('iframe-resizer');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n *\n * inject script to facilitate iframe resizing\n * https://github.com/davidjbradshaw/iframe-resizer\n *\n */\nvar pause = function pause(duration) {\n  return new _promise2.default(function (res) {\n    return setTimeout(res, duration);\n  });\n};\n\nvar backoff = function backoff(fn, retries, delay) {\n  return fn().then(function (msg) {\n    return retries > 1 ? pause(delay).then(function () {\n      return backoff(retries - 1, fn, delay * 2);\n    }) : _promise2.default.reject(err);\n  });\n};\n\nvar IframeResizer = function (_React$Component) {\n  (0, _inherits3.default)(IframeResizer, _React$Component);\n\n  function IframeResizer() {\n    var _ref;\n\n    var _temp, _this, _ret;\n\n    (0, _classCallCheck3.default)(this, IframeResizer);\n\n    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n      args[_key] = arguments[_key];\n    }\n\n    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = IframeResizer.__proto__ || (0, _getPrototypeOf2.default)(IframeResizer)).call.apply(_ref, [this].concat(args))), _this), _this.updateIframe = function (props) {\n      // has src - no injected content\n      if (props.src) return;\n      // do we have content to inject (content or children)\n      var content = props.content || props.children;\n      if (!content) return;\n      // get frame to inject into\n      var frame = _this.refs.frame;\n      if (!frame) return;\n      // verify frame document access\n      // Due to browser security, this will fail with the following error\n      //   Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement':\n      //   Blocked a frame with origin \"http://<hostname>\" from accessing a cross-origin frame.\n      // resolve this by loading documents from the same domain name,\n      // or injecting HTML `content` vs. loading via `src`\n      var doc = frame.contentDocument;\n      if (!doc) return;\n      // replace iframe document content\n      if (typeof content === 'string') {\n        // assume this is a HTML block\n        //   we could send this in via REACT dangerously set HTML\n        //   but we are in an iframe anyway, already a red-headed step-child.\n        doc.open();\n        doc.write(content);\n        doc.close();\n      } else {\n        // assume this is a REACT component\n        doc.open();\n        doc.write('<div id=\"iframe-root\"></div>');\n        doc.close();\n        _reactDom2.default.render(content, doc.getElementById('iframe-root'));\n      }\n    }, _this.injectIframeResizerUrl = function () {\n      if (!_this.props.iframeResizerUrl) return;\n      var frame = _this.refs.frame;\n      if (!frame) return;\n      // verify frame document access\n      // Due to browser security, this will fail with the following error\n      //   Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement':\n      //   Blocked a frame with origin \"http://<hostname>\" from accessing a cross-origin frame.\n      // resolve this by loading documents from the same domain name,\n      // or injecting HTML `content` vs. loading via `src`\n      var doc = frame.contentDocument;\n      if (!doc) return;\n      // where can we insert into? (fail into whatever we can find)\n      var injectTarget = null;\n      ['head', 'HEAD', 'body', 'BODY', 'div', 'DIV'].forEach(function (tagName) {\n        if (injectTarget) return;\n        var found = doc.getElementsByTagName(tagName);\n        if (!(found && found.length)) return;\n        injectTarget = found[0];\n      });\n      if (!injectTarget) {\n        console.error('Unable to inject iframe resizer script');\n        return;\n      }\n      var resizerScriptElement = document.createElement('script');\n      resizerScriptElement.type = 'text/javascript';\n      resizerScriptElement.src = _this.props.iframeResizerUrl;\n      injectTarget.appendChild(resizerScriptElement);\n    }, _this.onLoad = function () {\n      _this.injectIframeResizerUrl();\n      // DISABLED because it's causing a loading loop :(\n      // if (this.props.onIframeLoaded) this.props.onIframeLoaded();\n    }, _this.resizeIframe = function (props) {\n      var frame = _this.refs.frame;\n      if (!frame) return;\n      if (iframeResizerEnableRetry) {\n        backoff((0, _iframeResizer.iframeResizer)(props.iframeResizerOptions, frame), props.iframeResizerOptions.retries, props.iframeResizerOptions.delay);\n      } else if (props.iframeResizerEnable) {\n        (0, _iframeResizer.iframeResizer)(props.iframeResizerOptions, frame);\n      }\n    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);\n  }\n\n  (0, _createClass3.default)(IframeResizer, [{\n    key: 'componentDidMount',\n    value: function componentDidMount() {\n      // can't update until we have a mounted iframe\n      this.updateIframe(this.props);\n      this.resizeIframe(this.props);\n    }\n  }, {\n    key: 'componentWillReceiveProps',\n    value: function componentWillReceiveProps(nextProps) {\n      // can replace content if we got new props\n      this.updateIframe(nextProps);\n      this.resizeIframe(nextProps);\n    }\n    // inject the iframe resizer \"content window\" script\n\n  }, {\n    key: 'render',\n    value: function render() {\n      var _props = this.props,\n          src = _props.src,\n          id = _props.id,\n          frameBorder = _props.frameBorder,\n          className = _props.className,\n          style = _props.style;\n\n      return _react2.default.createElement('iframe', {\n        ref: 'frame',\n        src: src,\n        id: id,\n        frameBorder: frameBorder,\n        className: className,\n        style: style,\n        onLoad: this.onLoad\n      });\n    }\n  }]);\n  return IframeResizer;\n}(_react2.default.Component);\n\nIframeResizer.propTypes = {\n  // iframe content/document\n  // option 1. content of HTML to load in the iframe\n  content: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]),\n  // option 2. src to a URL to load in the iframe\n  src: _propTypes2.default.string,\n  // iframe-resizer controls and helpers\n  iframeResizerEnable: _propTypes2.default.bool,\n  iframeResizerEnableRetry: _propTypes2.default.bool,\n  iframeResizerOptions: _propTypes2.default.object,\n  iframeResizerUrl: _propTypes2.default.oneOfType([_propTypes2.default.string, // URL to inject\n  _propTypes2.default.bool] // false = disable inject\n  ),\n  // misc props to pass through to iframe\n  id: _propTypes2.default.string,\n  frameBorder: _propTypes2.default.number,\n  className: _propTypes2.default.string,\n  style: _propTypes2.default.object\n  // optional extra callback when iframe is loaded\n  // onIframeLoaded: PropTypes.func,\n};\nIframeResizer.defaultProps = {\n  // resize iframe\n  iframeResizerEnable: true,\n  iframeResizerEnableRetry: false,\n  iframeResizerOptions: {\n    // log: true,\n    // autoResize: true,\n    // checkOrigin: false,\n    // resizeFrom: 'parent',\n    // heightCalculationMethod: 'max',\n    // initCallback: () => { console.log('ready!'); },\n    // resizedCallback: () => { console.log('resized!'); },\n    retries: 3,\n    delay: 500\n  },\n  iframeResizerUrl: 'https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/3.5.8/iframeResizer.contentWindow.min.js',\n  // misc props to pass through to iframe\n  frameBorder: 0,\n  style: {\n    width: '100%',\n    minHeight: 20\n  }\n};\n\nexports.default = IframeResizer;"]}