"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
/**
 * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
 *
 * Generates Typescript types for analytics events from analytics.spec.yaml
 *
 * @codegen <<SignedSource::f914fb83fac56e7154ef460866628f7d>>
 * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen smart-card
 */

var createEventPayload = function createEventPayload(eventKey) {
  for (var _len = arguments.length, _ref = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    _ref[_key - 1] = arguments[_key];
  }
  var attributes = _ref[0];
  var _eventKey$split = eventKey.split('.'),
    _eventKey$split2 = (0, _slicedToArray2.default)(_eventKey$split, 4),
    eventType = _eventKey$split2[0],
    actionSubject = _eventKey$split2[1],
    action = _eventKey$split2[2],
    actionSubjectId = _eventKey$split2[3];
  if (eventType === 'screen') {
    return {
      eventType: eventType,
      name: actionSubject,
      action: 'viewed',
      attributes: attributes
    };
  }
  return {
    eventType: eventType,
    actionSubject: actionSubject,
    action: action,
    actionSubjectId: actionSubjectId,
    attributes: attributes
  };
};
var _default = exports.default = createEventPayload;