"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.succeedMediaFileUfoExperience = exports.startMediaFileUfoExperience = exports.failMediaFileUfoExperience = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _ufo = require("@atlaskit/ufo");
var _mediaClient = require("@atlaskit/media-client");
var _mediaCommon = require("@atlaskit/media-common");
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
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) { (0, _defineProperty2.default)(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; }
var packageName = "@atlaskit/media-viewer";
var packageVersion = "0.0.0-development";
var ufoExperience;
var getExperience = function getExperience() {
  if (!ufoExperience) {
    var inlineExperience = {
      platform: {
        component: 'media-viewer'
      },
      type: _ufo.ExperienceTypes.Experience,
      performanceType: _ufo.ExperiencePerformanceTypes.InlineResult,
      featureFlags: (0, _mediaCommon.getFeatureFlagKeysAllProducts)()
    };
    ufoExperience = new _ufo.UFOExperience('media-file', inlineExperience);
  }
  return ufoExperience;
};
var startMediaFileUfoExperience = exports.startMediaFileUfoExperience = function startMediaFileUfoExperience() {
  getExperience().start();
};
var succeedMediaFileUfoExperience = exports.succeedMediaFileUfoExperience = function succeedMediaFileUfoExperience(properties) {
  getExperience().success({
    metadata: _objectSpread(_objectSpread({}, properties), {}, {
      packageName: packageName,
      packageVersion: packageVersion,
      mediaEnvironment: (0, _mediaClient.getMediaEnvironment)(),
      mediaRegion: (0, _mediaClient.getMediaRegion)(),
      isMediaDocumentViewerEnabled: (0, _platformFeatureFlags.fg)('media_document_viewer')
    })
  });
};
var failMediaFileUfoExperience = exports.failMediaFileUfoExperience = function failMediaFileUfoExperience(properties) {
  var refinedMetadata = _objectSpread(_objectSpread({}, properties), {}, {
    packageName: packageName,
    packageVersion: packageVersion,
    mediaEnvironment: (0, _mediaClient.getMediaEnvironment)(),
    mediaRegion: (0, _mediaClient.getMediaRegion)(),
    isMediaDocumentViewerEnabled: (0, _platformFeatureFlags.fg)('media_document_viewer')
  });
  getExperience().failure({
    metadata: refinedMetadata
  });
};