import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _regeneratorRuntime from "@babel/runtime/regenerator";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import React from 'react';
import Loadable from 'react-loadable';
import { fg } from '@atlaskit/platform-feature-flags';
import { themeObjectToString } from '@atlaskit/tokens';
import { IconType, SmartLinkSize } from '../constants';
import extractFileFormatIcon from '../extractors/flexible/icon/extract-file-formatIcon';
export var isSpecialEvent = function isSpecialEvent(evt) {
  return evt.isDefaultPrevented() && (isIframe() || isSpecialKey(evt) || isSpecialClick(evt));
};
export var 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
 */
export var isSpecialKey = function isSpecialKey(event) {
  return fg('platform-smart-card-shift-key') ? event.metaKey || event.ctrlKey || event.shiftKey : event.metaKey || event.ctrlKey;
};
export var isSpecialClick = function isSpecialClick(event) {
  return event.button === 1;
};
export var getIconForFileType = function getIconForFileType(fileMimeType, showIconLabel) {
  if (!fileMimeType) {
    return;
  }
  var icon = getTypeToIconMap(fileMimeType.toLowerCase());
  if (!icon) {
    return;
  }
  var _icon = _slicedToArray(icon, 1),
    importCb = _icon[0];
  if (!importCb) {
    return;
  }
  var Icon = Loadable({
    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 (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.createElement(Icon, {
      testId: "document-file-format-icon",
      label: label
    });
  } else {
    return /*#__PURE__*/React.createElement(Icon, {
      testId: "document-file-format-icon"
    });
  }
};
// prettier-ignore
export var getLazyIcons = function getLazyIcons() {
  var _objectSpread2, _objectSpread3;
  return _objectSpread(_objectSpread((_objectSpread2 = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_objectSpread2, IconType.Document, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_page-icon" */'../common/ui/icons/page-icon');
    }
  }), IconType.Audio, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_audio-icon" */'../common/ui/icons/audio-icon');
    }
  }), IconType.Code, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_angle-brackets-icon" */'../common/ui/icons/angle-brackets-icon');
    }
  }), IconType.File, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_file-icon" */'../common/ui/icons/file-icon');
    }
  }), IconType.Folder, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_folder-icon" */'../common/ui/icons/folder-icon');
    }
  }), IconType.Generic, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_file-icon" */'../common/ui/icons/file-icon');
    }
  }), IconType.Image, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_image-icon" */'../common/ui/icons/image-icon');
    }
  }), IconType.Presentation, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_chart-bar-icon" */'../common/ui/icons/chart-bar-icon');
    }
  }), IconType.Spreadsheet, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_list-bullet-icon" */'../common/ui/icons/list-bullet-icon');
    }
  }), IconType.Video, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_video-icon" */'../common/ui/icons/video-icon');
    }
  }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_objectSpread2, IconType.Project, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphProject" */'@atlaskit/icon/core/people-group');
    }
  }), IconType.Template, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphTemplate" */'@atlaskit/icon/core/file');
    }
  }), IconType.Forbidden, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphForbidden" */'@atlaskit/icon/core/lock-locked');
    }
  }), IconType.Default, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphDefault" */'@atlaskit/icon/core/link');
    }
  }), IconType.Error, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphDefault" */'@atlaskit/icon/core/status-error');
    }
  }), IconType.Attachment, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphAttachment" */'@atlaskit/icon/core/attachment');
    }
  }), IconType.CheckItem, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphAttachment" */'@atlaskit/icon/core/task');
    }
  }), IconType.Component, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphComponent" */'@atlaskit/icon/core/component');
    }
  }), IconType.Comment, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphComment" */'@atlaskit/icon/core/comment');
    }
  }), IconType.View, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphComment" */'@atlaskit/icon/core/eye-open');
    }
  }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_objectSpread2, IconType.React, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphComment" */'@atlaskit/icon/core/thumbs-up');
    }
  }), IconType.Vote, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphComment" */'@atlaskit/icon/core/arrow-up');
    }
  }), IconType.PriorityUndefined, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphUndefined" */'@atlaskit/icon/core/question-circle');
    }
  }), IconType.ProgrammingLanguage, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphProgrammingLanguage" */'@atlaskit/icon/core/angle-brackets');
    }
  }), IconType.Subscriber, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphSubscriber" */'@atlaskit/icon/core/people-group');
    }
  }), IconType.SubTasksProgress, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphSubtaskProgress" */'@atlaskit/icon/core/subtasks');
    }
  }), IconType.Archive, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphArchive" */'@atlaskit/icon-file-type/glyph/archive/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphArchive" */'@atlaskit/icon-file-type/glyph/archive/24');
    }
  }), IconType.Executable, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphExecutable" */'@atlaskit/icon-file-type/glyph/executable/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphExecutable" */'@atlaskit/icon-file-type/glyph/executable/24');
    }
  }), IconType.GIF, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphGIF" */'@atlaskit/icon-file-type/glyph/gif/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphGIF" */'@atlaskit/icon-file-type/glyph/gif/24');
    }
  }), IconType.GoogleDocs, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphGoogleDocs" */'@atlaskit/icon-file-type/glyph/google-doc/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphGoogleDocs" */'@atlaskit/icon-file-type/glyph/google-doc/24');
    }
  }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_objectSpread2, IconType.GoogleForms, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphGoogleForms" */'@atlaskit/icon-file-type/glyph/google-form/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphGoogleForms" */'@atlaskit/icon-file-type/glyph/google-form/24');
    }
  }), IconType.GoogleSheets, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphGoogleSheets" */'@atlaskit/icon-file-type/glyph/google-sheet/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphGoogleSheets" */'@atlaskit/icon-file-type/glyph/google-sheet/24');
    }
  }), IconType.GoogleSlides, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphGoogleSlides" */'@atlaskit/icon-file-type/glyph/google-slide/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphGoogleSlides" */'@atlaskit/icon-file-type/glyph/google-slide/24');
    }
  }), IconType.MSExcel, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphMSExcel" */'@atlaskit/icon-file-type/glyph/excel-spreadsheet/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphMSExcel" */'@atlaskit/icon-file-type/glyph/excel-spreadsheet/24');
    }
  }), IconType.MSPowerpoint, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphMSPowerpoint" */'@atlaskit/icon-file-type/glyph/powerpoint-presentation/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphMSPowerpoint" */'@atlaskit/icon-file-type/glyph/powerpoint-presentation/24');
    }
  }), IconType.MSWord, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphMSWord" */'@atlaskit/icon-file-type/glyph/word-document/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphMSWord" */'@atlaskit/icon-file-type/glyph/word-document/24');
    }
  }), IconType.PDF, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphPDF" */'@atlaskit/icon-file-type/glyph/pdf-document/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphPDF" */'@atlaskit/icon-file-type/glyph/pdf-document/24');
    }
  }), IconType.Sketch, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphSketch" */'@atlaskit/icon-file-type/glyph/sketch/16');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphSketch" */'@atlaskit/icon-file-type/glyph/sketch/24');
    }
  })), fg('platform_sl_icons_refactor') ? _defineProperty(_defineProperty({}, IconType.Blog, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphBlog" */'@atlaskit/object/blog');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphBlog" */'@atlaskit/object/tile/blog').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.LiveDocument, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphPageLiveDoc" */'@atlaskit/object/page-live-doc');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphPageLiveDoc" */'@atlaskit/object/tile/page-live-doc').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }) : _defineProperty(_defineProperty({}, IconType.Blog, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphBlock" */'../common/ui/icons/blog-icon');
    }
  }), IconType.LiveDocument, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphPageLiveDoc" */'../common/ui/icons/live-document-icon');
    }
  })), {}, (_objectSpread3 = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_objectSpread3, IconType.Branch, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphBranch" */'@atlaskit/object/branch');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphBranch" */'@atlaskit/object/tile/branch').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.Commit, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphCommit" */'@atlaskit/object/commit');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphCommit" */'@atlaskit/object/tile/commit').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.PullRequest, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphPullRequest" */'@atlaskit/object/pull-request');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphPullRequest" */'@atlaskit/object/tile/pull-request').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.Repo, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphRepo" */'@atlaskit/object/code');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphRepo" */'@atlaskit/object/tile/code').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.Bug, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphBug" */'@atlaskit/object/bug');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphBug" */'@atlaskit/object/tile/bug').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.Change, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphChange" */'@atlaskit/object/changes');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphChange" */'@atlaskit/object/tile/changes').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.Epic, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphEpic" */'@atlaskit/object/epic');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphEpic" */'@atlaskit/object/tile/epic').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.Incident, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphIncident" */'@atlaskit/object/incident');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphIncident" */'@atlaskit/object/tile/incident').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.Problem, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphProblem" */'@atlaskit/object/problem');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphProblem" */'@atlaskit/object/tile/problem').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.ServiceRequest, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphServiceRequest" */'@atlaskit/object/work-item');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphServiceRequest" */'@atlaskit/object/tile/work-item').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_objectSpread3, IconType.Story, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphStory" */'@atlaskit/object/story');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphStory" */'@atlaskit/object/tile/story').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.SubTask, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphSubTask" */'@atlaskit/object/subtask');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphSubTask" */'@atlaskit/object/tile/subtask').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.Task, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphTask" */'@atlaskit/object/task');
    },
    large: function large() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphTask" */'@atlaskit/object/tile/task').then(function (module) {
        return {
          default: function _default(props) {
            return /*#__PURE__*/React.createElement(module.default, _extends({}, props, {
              size: "small"
            }));
          }
        };
      });
    }
  }), IconType.Confluence, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphConfluence" */'@atlaskit/logo/confluence-icon').then(function (_ref3) {
        var ConfluenceIcon = _ref3.ConfluenceIcon;
        return {
          default: ConfluenceIcon
        };
      });
    }
  }), IconType.Jira, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphJira" */'@atlaskit/logo/jira-icon').then(function (_ref4) {
        var JiraIcon = _ref4.JiraIcon;
        return {
          default: JiraIcon
        };
      });
    }
  }), IconType.PriorityBlocker, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphBlocker" */'../common/ui/icons/priority-blocker-icon');
    }
  }), IconType.PriorityCritical, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphCritical" */'../common/ui/icons/priority-critical-icon');
    }
  }), IconType.PriorityHigh, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphHigh" */'../common/ui/icons/priority-high-icon');
    }
  }), IconType.PriorityHighest, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphHighest" */'../common/ui/icons/priority-highest-icon');
    }
  }), IconType.PriorityLow, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphLow" */'../common/ui/icons/priority-low-icon');
    }
  }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_objectSpread3, IconType.PriorityLowest, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphLowest" */'../common/ui/icons/priority-lowest-icon');
    }
  }), IconType.PriorityMajor, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphMajor" */'../common/ui/icons/priority-major-icon');
    }
  }), IconType.PriorityMedium, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphMedium" */'../common/ui/icons/priority-medium-icon');
    }
  }), IconType.PriorityMinor, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphMinor" */'../common/ui/icons/priority-minor-icon');
    }
  }), IconType.PriorityTrivial, {
    default: function _default() {
      return import( /* webpackChunkName: "@atlaskit-internal_glyphTrivial" */'../common/ui/icons/priority-trivial-icon');
    }
  })));
};
var getTypeToIconMap = function getTypeToIconMap(fileFormat) {
  var iconDescriptor = extractFileFormatIcon(fileFormat);
  if (!(iconDescriptor !== null && iconDescriptor !== void 0 && iconDescriptor.icon)) {
    return null;
  }
  var lazyIcons = getLazyIcons();
  if (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];
  }
};
export var 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;
};
export var handleOnClick = function handleOnClick(handler) {
  return function (e) {
    e.preventDefault();
    e.stopPropagation();
    handler();
  };
};
export var isIntersectionObserverSupported = function isIntersectionObserverSupported() {
  return typeof IntersectionObserver !== 'undefined';
};
export var sleep = function sleep(ms) {
  return new Promise(function (resolve) {
    return setTimeout(resolve, ms);
  });
};
var _importWithRetry = /*#__PURE__*/function () {
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(importFn) {
    var retries,
      interval,
      _args = arguments;
    return _regeneratorRuntime.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 _ref5.apply(this, arguments);
  };
}();
export { _importWithRetry as importWithRetry };
export var downloadUrl = /*#__PURE__*/function () {
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url) {
    var isIE11, isSafari, iframeName, link, iframe;
    return _regeneratorRuntime.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 _ref6.apply(this, arguments);
  };
}();
export var openUrl = /*#__PURE__*/function () {
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(url) {
    return _regeneratorRuntime.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 _ref7.apply(this, arguments);
  };
}();

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