"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.sleep = exports.openUrl = exports.isSpecialKey = exports.isSpecialEvent = exports.isSpecialClick = exports.isProfileType = exports.isIntersectionObserverSupported = exports.isIframe = exports.isIconSizeLarge = exports.importWithRetry = exports.handleOnClick = exports.getPreviewUrlWithTheme = exports.getLazyIcons = exports.getIframeSandboxAttribute = exports.getIconForFileType = exports.downloadUrl = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = _interopRequireDefault(require("react"));
var _reactLoadable = _interopRequireDefault(require("react-loadable"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _tokens = require("@atlaskit/tokens");
var _constants = require("../constants");
var _extractFileFormatIcon = _interopRequireDefault(require("../extractors/flexible/icon/extract-file-formatIcon"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var isSpecialEvent = exports.isSpecialEvent = function isSpecialEvent(evt) {
  return evt.isDefaultPrevented() && (isIframe() || isSpecialKey(evt) || isSpecialClick(evt));
};
var isIframe = exports.isIframe = function isIframe() {
  return window.parent !== parent;
};

/**
 * Meta key = cmd on mac, windows key on windows
 * Ctrl key on mac by default triggers a right click instead of left click
 * Ctrl key on Windows has the same behaviour of cmd key of mac (open in new tab)
 * Shift key is also a "special" key because the default behavior of Chromium-based browsers is to open the
 * link in a new window; Arc browser has custom logic to show links in its "peek" window when shift is held.
 *
 * `isSpecialKey` on a mouse event on mac with default behaviour should be equivalent to opening in new tab
 * On Windows it will be equivalent to opening a new tab, unless its the Window key that is held
 * in which case typically only a standard clickthrough will occur, this is likely a small portion of events
 */
var isSpecialKey = exports.isSpecialKey = function isSpecialKey(event) {
  return (0, _platformFeatureFlags.fg)('platform-smart-card-shift-key') ? event.metaKey || event.ctrlKey || event.shiftKey : event.metaKey || event.ctrlKey;
};
var isSpecialClick = exports.isSpecialClick = function isSpecialClick(event) {
  return event.button === 1;
};
var getIconForFileType = exports.getIconForFileType = function getIconForFileType(fileMimeType, showIconLabel) {
  if (!fileMimeType) {
    return;
  }
  var icon = getTypeToIconMap(fileMimeType.toLowerCase());
  if (!icon) {
    return;
  }
  var _icon = (0, _slicedToArray2.default)(icon, 1),
    importCb = _icon[0];
  if (!importCb) {
    return;
  }
  var Icon = (0, _reactLoadable.default)({
    loader: function loader() {
      return importCb().then(function (module) {
        return module.default;
      });
    },
    loading: function loading() {
      return null;
    }
  }); // because we're using dynamic loading here, TS will not be able to infer the type

  if ((0, _platformFeatureFlags.fg)('platform_navx_smart_link_icon_label_a11y')) {
    var descriptorLabel = icon[1] || ''; // NAVX-4354: Combine into const [importCb] = icon; above
    var label = (showIconLabel !== null && showIconLabel !== void 0 ? showIconLabel : true) ? descriptorLabel : '';
    return /*#__PURE__*/_react.default.createElement(Icon, {
      testId: "document-file-format-icon",
      label: label
    });
  } else {
    return /*#__PURE__*/_react.default.createElement(Icon, {
      testId: "document-file-format-icon"
    });
  }
};
// prettier-ignore
var getLazyIcons = exports.getLazyIcons = function getLazyIcons() {
  var _ref3;
  return _ref3 = {}, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_ref3, _constants.IconType.Document, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_page-icon" */'../common/ui/icons/page-icon'));
      });
    }
  }), _constants.IconType.Blog, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphBlock" */'../common/ui/icons/blog-icon'));
      });
    }
  }), _constants.IconType.Audio, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_audio-icon" */'../common/ui/icons/audio-icon'));
      });
    }
  }), _constants.IconType.Code, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_angle-brackets-icon" */'../common/ui/icons/angle-brackets-icon'));
      });
    }
  }), _constants.IconType.File, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_file-icon" */'../common/ui/icons/file-icon'));
      });
    }
  }), _constants.IconType.Folder, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_folder-icon" */'../common/ui/icons/folder-icon'));
      });
    }
  }), _constants.IconType.Generic, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_file-icon" */'../common/ui/icons/file-icon'));
      });
    }
  }), _constants.IconType.Image, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_image-icon" */'../common/ui/icons/image-icon'));
      });
    }
  }), _constants.IconType.Presentation, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_chart-bar-icon" */'../common/ui/icons/chart-bar-icon'));
      });
    }
  }), _constants.IconType.Spreadsheet, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_list-bullet-icon" */'../common/ui/icons/list-bullet-icon'));
      });
    }
  }), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_ref3, _constants.IconType.Video, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_video-icon" */'../common/ui/icons/video-icon'));
      });
    }
  }), _constants.IconType.Project, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphProject" */'@atlaskit/icon/core/people-group'));
      });
    }
  }), _constants.IconType.Template, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphTemplate" */'@atlaskit/icon/core/file'));
      });
    }
  }), _constants.IconType.Forbidden, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphForbidden" */'@atlaskit/icon/core/lock-locked'));
      });
    }
  }), _constants.IconType.Default, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphDefault" */'@atlaskit/icon/core/link'));
      });
    }
  }), _constants.IconType.Error, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphDefault" */'@atlaskit/icon/core/status-error'));
      });
    }
  }), _constants.IconType.Archive, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphArchive" */'@atlaskit/icon-file-type/glyph/archive/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphArchive" */'@atlaskit/icon-file-type/glyph/archive/24'));
      });
    }
  }), _constants.IconType.Executable, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphExecutable" */'@atlaskit/icon-file-type/glyph/executable/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphExecutable" */'@atlaskit/icon-file-type/glyph/executable/24'));
      });
    }
  }), _constants.IconType.GIF, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphGIF" */'@atlaskit/icon-file-type/glyph/gif/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphGIF" */'@atlaskit/icon-file-type/glyph/gif/24'));
      });
    }
  }), _constants.IconType.GoogleDocs, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphGoogleDocs" */'@atlaskit/icon-file-type/glyph/google-doc/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphGoogleDocs" */'@atlaskit/icon-file-type/glyph/google-doc/24'));
      });
    }
  }), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_ref3, _constants.IconType.GoogleForms, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphGoogleForms" */'@atlaskit/icon-file-type/glyph/google-form/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphGoogleForms" */'@atlaskit/icon-file-type/glyph/google-form/24'));
      });
    }
  }), _constants.IconType.GoogleSheets, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphGoogleSheets" */'@atlaskit/icon-file-type/glyph/google-sheet/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphGoogleSheets" */'@atlaskit/icon-file-type/glyph/google-sheet/24'));
      });
    }
  }), _constants.IconType.GoogleSlides, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphGoogleSlides" */'@atlaskit/icon-file-type/glyph/google-slide/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphGoogleSlides" */'@atlaskit/icon-file-type/glyph/google-slide/24'));
      });
    }
  }), _constants.IconType.MSExcel, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphMSExcel" */'@atlaskit/icon-file-type/glyph/excel-spreadsheet/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphMSExcel" */'@atlaskit/icon-file-type/glyph/excel-spreadsheet/24'));
      });
    }
  }), _constants.IconType.MSPowerpoint, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphMSPowerpoint" */'@atlaskit/icon-file-type/glyph/powerpoint-presentation/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphMSPowerpoint" */'@atlaskit/icon-file-type/glyph/powerpoint-presentation/24'));
      });
    }
  }), _constants.IconType.MSWord, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphMSWord" */'@atlaskit/icon-file-type/glyph/word-document/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphMSWord" */'@atlaskit/icon-file-type/glyph/word-document/24'));
      });
    }
  }), _constants.IconType.PDF, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphPDF" */'@atlaskit/icon-file-type/glyph/pdf-document/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphPDF" */'@atlaskit/icon-file-type/glyph/pdf-document/24'));
      });
    }
  }), _constants.IconType.Sketch, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphSketch" */'@atlaskit/icon-file-type/glyph/sketch/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphSketch" */'@atlaskit/icon-file-type/glyph/sketch/24'));
      });
    }
  }), _constants.IconType.Branch, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphBranch" */'@atlaskit/icon-object/glyph/branch/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphBranch" */'@atlaskit/icon-object/glyph/branch/24'));
      });
    }
  }), _constants.IconType.Commit, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphCommit" */'@atlaskit/icon-object/glyph/commit/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphCommit" */'@atlaskit/icon-object/glyph/commit/24'));
      });
    }
  }), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_ref3, _constants.IconType.PullRequest, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphPullRequest" */'@atlaskit/icon-object/glyph/pull-request/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphPullRequest" */'@atlaskit/icon-object/glyph/pull-request/24'));
      });
    }
  }), _constants.IconType.Repo, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphRepo" */'@atlaskit/icon-object/glyph/code/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphRepo" */'@atlaskit/icon-object/glyph/code/24'));
      });
    }
  }), _constants.IconType.Bug, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphBug" */'@atlaskit/icon-object/glyph/bug/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphBug" */'@atlaskit/icon-object/glyph/bug/24'));
      });
    }
  }), _constants.IconType.Change, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphChange" */'@atlaskit/icon-object/glyph/changes/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphChange" */'@atlaskit/icon-object/glyph/changes/24'));
      });
    }
  }), _constants.IconType.Epic, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphEpic" */'@atlaskit/icon-object/glyph/epic/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphEpic" */'@atlaskit/icon-object/glyph/epic/24'));
      });
    }
  }), _constants.IconType.Incident, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphIncident" */'@atlaskit/icon-object/glyph/incident/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphIncident" */'@atlaskit/icon-object/glyph/incident/24'));
      });
    }
  }), _constants.IconType.Problem, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphProblem" */'@atlaskit/icon-object/glyph/problem/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphProblem" */'@atlaskit/icon-object/glyph/problem/24'));
      });
    }
  }), _constants.IconType.ServiceRequest, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphServiceRequest" */'@atlaskit/icon-object/glyph/issue/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphServiceRequest" */'@atlaskit/icon-object/glyph/issue/24'));
      });
    }
  }), _constants.IconType.Story, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphStory" */'@atlaskit/icon-object/glyph/story/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphStory" */'@atlaskit/icon-object/glyph/story/24'));
      });
    }
  }), _constants.IconType.SubTask, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphSubTask" */'@atlaskit/icon-object/glyph/subtask/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphSubTask" */'@atlaskit/icon-object/glyph/subtask/24'));
      });
    }
  }), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_ref3, _constants.IconType.Task, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphTask" */'@atlaskit/icon-object/glyph/task/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphTask" */'@atlaskit/icon-object/glyph/task/24'));
      });
    }
  }), _constants.IconType.LiveDocument, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphPageLiveDoc" */'@atlaskit/icon-object/glyph/page-live-doc/16'));
      });
    },
    large: function large() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphPageLiveDoc" */'@atlaskit/icon-object/glyph/page-live-doc/24'));
      });
    }
  }), _constants.IconType.Confluence, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphConfluence" */'@atlaskit/logo/confluence-icon'));
      }).then(function (_ref) {
        var ConfluenceIcon = _ref.ConfluenceIcon;
        return {
          default: ConfluenceIcon
        };
      });
    }
  }), _constants.IconType.Jira, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphJira" */'@atlaskit/logo/jira-icon'));
      }).then(function (_ref2) {
        var JiraIcon = _ref2.JiraIcon;
        return {
          default: JiraIcon
        };
      });
    }
  }), _constants.IconType.Attachment, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphAttachment" */'@atlaskit/icon/core/attachment'));
      });
    }
  }), _constants.IconType.CheckItem, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphAttachment" */'@atlaskit/icon/core/task'));
      });
    }
  }), _constants.IconType.Component, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphComponent" */'@atlaskit/icon/core/component'));
      });
    }
  }), _constants.IconType.Comment, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphComment" */'@atlaskit/icon/core/comment'));
      });
    }
  }), _constants.IconType.View, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphComment" */'@atlaskit/icon/core/eye-open'));
      });
    }
  }), _constants.IconType.React, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphComment" */'@atlaskit/icon/core/thumbs-up'));
      });
    }
  }), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_ref3, _constants.IconType.Vote, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphComment" */'@atlaskit/icon/core/arrow-up'));
      });
    }
  }), _constants.IconType.PriorityBlocker, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphBlocker" */'../common/ui/icons/priority-blocker-icon'));
      });
    }
  }), _constants.IconType.PriorityCritical, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphCritical" */'../common/ui/icons/priority-critical-icon'));
      });
    }
  }), _constants.IconType.PriorityHigh, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphHigh" */'../common/ui/icons/priority-high-icon'));
      });
    }
  }), _constants.IconType.PriorityHighest, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphHighest" */'../common/ui/icons/priority-highest-icon'));
      });
    }
  }), _constants.IconType.PriorityLow, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphLow" */'../common/ui/icons/priority-low-icon'));
      });
    }
  }), _constants.IconType.PriorityLowest, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphLowest" */'../common/ui/icons/priority-lowest-icon'));
      });
    }
  }), _constants.IconType.PriorityMajor, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphMajor" */'../common/ui/icons/priority-major-icon'));
      });
    }
  }), _constants.IconType.PriorityMedium, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphMedium" */'../common/ui/icons/priority-medium-icon'));
      });
    }
  }), _constants.IconType.PriorityMinor, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphMinor" */'../common/ui/icons/priority-minor-icon'));
      });
    }
  }), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_ref3, _constants.IconType.PriorityTrivial, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphTrivial" */'../common/ui/icons/priority-trivial-icon'));
      });
    }
  }), _constants.IconType.PriorityUndefined, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphUndefined" */'@atlaskit/icon/core/question-circle'));
      });
    }
  }), _constants.IconType.ProgrammingLanguage, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphProgrammingLanguage" */'@atlaskit/icon/core/angle-brackets'));
      });
    }
  }), _constants.IconType.Subscriber, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphSubscriber" */'@atlaskit/icon/core/people-group'));
      });
    }
  }), _constants.IconType.SubTasksProgress, {
    default: function _default() {
      return Promise.resolve().then(function () {
        return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_glyphSubtaskProgress" */'@atlaskit/icon/core/subtasks'));
      });
    }
  });
};
var getTypeToIconMap = function getTypeToIconMap(fileFormat) {
  var iconDescriptor = (0, _extractFileFormatIcon.default)(fileFormat);
  if (!(iconDescriptor !== null && iconDescriptor !== void 0 && iconDescriptor.icon)) {
    return null;
  }
  var lazyIcons = getLazyIcons();
  if ((0, _platformFeatureFlags.fg)('platform_navx_smart_link_icon_label_a11y')) {
    var _lazyIcons$iconDescri, _iconDescriptor$label;
    return [(_lazyIcons$iconDescri = lazyIcons[iconDescriptor.icon]) === null || _lazyIcons$iconDescri === void 0 ? void 0 : _lazyIcons$iconDescri.default, (_iconDescriptor$label = iconDescriptor.label) !== null && _iconDescriptor$label !== void 0 ? _iconDescriptor$label : ''];
  } else {
    var _lazyIcons$iconDescri2;
    return [(_lazyIcons$iconDescri2 = lazyIcons[iconDescriptor.icon]) === null || _lazyIcons$iconDescri2 === void 0 ? void 0 : _lazyIcons$iconDescri2.default];
  }
};
var getIframeSandboxAttribute = exports.getIframeSandboxAttribute = function getIframeSandboxAttribute(isTrusted) {
  if (isTrusted) {
    return undefined;
  }
  var sandboxPermissions = 'allow-downloads allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts';
  return sandboxPermissions;
};
var handleOnClick = exports.handleOnClick = function handleOnClick(handler) {
  return function (e) {
    e.preventDefault();
    e.stopPropagation();
    handler();
  };
};
var isIntersectionObserverSupported = exports.isIntersectionObserverSupported = function isIntersectionObserverSupported() {
  return typeof IntersectionObserver !== 'undefined';
};
var sleep = exports.sleep = function sleep(ms) {
  return new Promise(function (resolve) {
    return setTimeout(resolve, ms);
  });
};
var _importWithRetry = exports.importWithRetry = /*#__PURE__*/function () {
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(importFn) {
    var retries,
      interval,
      _args = arguments;
    return _regenerator.default.wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          retries = _args.length > 1 && _args[1] !== undefined ? _args[1] : 2;
          interval = _args.length > 2 && _args[2] !== undefined ? _args[2] : 500;
          _context.prev = 2;
          _context.next = 5;
          return importFn();
        case 5:
          return _context.abrupt("return", _context.sent);
        case 8:
          _context.prev = 8;
          _context.t0 = _context["catch"](2);
          if (!(_context.t0.name === 'ChunkLoadError' && retries > 0)) {
            _context.next = 16;
            break;
          }
          _context.next = 13;
          return sleep(interval);
        case 13:
          return _context.abrupt("return", _importWithRetry(importFn, retries - 1, interval));
        case 16:
          throw _context.t0;
        case 17:
        case "end":
          return _context.stop();
      }
    }, _callee, null, [[2, 8]]);
  }));
  return function importWithRetry(_x) {
    return _ref4.apply(this, arguments);
  };
}();
var downloadUrl = exports.downloadUrl = /*#__PURE__*/function () {
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(url) {
    var isIE11, isSafari, iframeName, link, iframe;
    return _regenerator.default.wrap(function _callee2$(_context2) {
      while (1) switch (_context2.prev = _context2.next) {
        case 0:
          if (url) {
            _context2.next = 2;
            break;
          }
          return _context2.abrupt("return");
        case 2:
          isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
          isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
          iframeName = 'media-download-iframe';
          link = document.createElement('a');
          iframe = document.getElementById(iframeName);
          if (!iframe) {
            iframe = document.createElement('iframe');
            iframe.style.display = 'none';
            iframe.id = iframeName;
            iframe.name = iframeName;
            document.body.appendChild(iframe);
          }
          link.href = url;
          link.download = url;
          link.target = isIE11 || isSafari ? '_blank' : iframeName;
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link);
        case 14:
        case "end":
          return _context2.stop();
      }
    }, _callee2);
  }));
  return function downloadUrl(_x2) {
    return _ref5.apply(this, arguments);
  };
}();
var openUrl = exports.openUrl = /*#__PURE__*/function () {
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(url) {
    return _regenerator.default.wrap(function _callee3$(_context3) {
      while (1) switch (_context3.prev = _context3.next) {
        case 0:
          if (url) {
            _context3.next = 2;
            break;
          }
          return _context3.abrupt("return");
        case 2:
          window.open(url, '_blank', 'noopener=yes');
        case 3:
        case "end":
          return _context3.stop();
      }
    }, _callee3);
  }));
  return function openUrl(_x3) {
    return _ref6.apply(this, arguments);
  };
}();

/**
 * Append a theme to the URL if it exists
 * @param previewUrl
 * @param themeState
 */
var getPreviewUrlWithTheme = exports.getPreviewUrlWithTheme = function getPreviewUrlWithTheme(previewUrl, themeState) {
  try {
    var url = new URL(previewUrl);
    url.searchParams.append('themeState', (0, _tokens.themeObjectToString)(themeState));
    return url.href;
  } catch (_unused) {
    return previewUrl;
  }
};
var isIconSizeLarge = exports.isIconSizeLarge = function isIconSizeLarge(size) {
  return size && [_constants.SmartLinkSize.Large, _constants.SmartLinkSize.XLarge].includes(size);
};
var isProfileType = exports.isProfileType = function isProfileType(type) {
  return !!(type && type.includes('Profile'));
};