export const BUNDLE_LIFECYCLE_MARK_NAMES = {
  BUNDLE_LIFECYCLE_START: 'bundle_lifecycle_start',
  POST_STUDIO_SESSION_START: 'post_studio_session_start',
  POST_STUDIO_SESSION_END: 'post_studio_session_end',
  ENSURE_STUDIO_BUNDLE_START: 'ensure_studio_bundle_start',
  ENSURE_STUDIO_BUNDLE_END: 'ensure_studio_bundle_end',
  STUDIO_MANAGER_SETUP_START: 'studio_manager_setup_start',
  STUDIO_MANAGER_SETUP_END: 'studio_manager_setup_end',
  STUDIO_PROTOCOL_GET_START: 'studio_protocol_get_start',
  STUDIO_PROTOCOL_GET_END: 'studio_protocol_get_end',
  STUDIO_PROTOCOL_PREPARE_START: 'studio_protocol_prepare_start',
  STUDIO_PROTOCOL_PREPARE_END: 'studio_protocol_prepare_end',
  BUNDLE_LIFECYCLE_END: 'bundle_lifecycle_end',
} as const

type BundleLifecycleMarkName = (typeof BUNDLE_LIFECYCLE_MARK_NAMES)[keyof typeof BUNDLE_LIFECYCLE_MARK_NAMES]

export const BUNDLE_LIFECYCLE_MEASURE_NAMES = {
  BUNDLE_LIFECYCLE_DURATION: 'bundle_lifecycle_duration',
  POST_STUDIO_SESSION_DURATION: 'post_studio_session_duration',
  ENSURE_STUDIO_BUNDLE_DURATION: 'ensure_studio_bundle_duration',
  STUDIO_MANAGER_SETUP_DURATION: 'studio_manager_setup_duration',
  STUDIO_PROTOCOL_GET_DURATION: 'studio_protocol_get_duration',
  STUDIO_PROTOCOL_PREPARE_DURATION: 'studio_protocol_prepare_duration',
} as const

type BundleLifecycleMeasureName = (typeof BUNDLE_LIFECYCLE_MEASURE_NAMES)[keyof typeof BUNDLE_LIFECYCLE_MEASURE_NAMES]

export const BUNDLE_LIFECYCLE_MEASURES: Record<BundleLifecycleMeasureName, [BundleLifecycleMarkName, BundleLifecycleMarkName]> = {
  [BUNDLE_LIFECYCLE_MEASURE_NAMES.BUNDLE_LIFECYCLE_DURATION]: [
    BUNDLE_LIFECYCLE_MARK_NAMES.BUNDLE_LIFECYCLE_START,
    BUNDLE_LIFECYCLE_MARK_NAMES.BUNDLE_LIFECYCLE_END,
  ],
  [BUNDLE_LIFECYCLE_MEASURE_NAMES.POST_STUDIO_SESSION_DURATION]: [
    BUNDLE_LIFECYCLE_MARK_NAMES.POST_STUDIO_SESSION_START,
    BUNDLE_LIFECYCLE_MARK_NAMES.POST_STUDIO_SESSION_END,
  ],
  [BUNDLE_LIFECYCLE_MEASURE_NAMES.ENSURE_STUDIO_BUNDLE_DURATION]: [
    BUNDLE_LIFECYCLE_MARK_NAMES.ENSURE_STUDIO_BUNDLE_START,
    BUNDLE_LIFECYCLE_MARK_NAMES.ENSURE_STUDIO_BUNDLE_END,
  ],
  [BUNDLE_LIFECYCLE_MEASURE_NAMES.STUDIO_MANAGER_SETUP_DURATION]: [
    BUNDLE_LIFECYCLE_MARK_NAMES.STUDIO_MANAGER_SETUP_START,
    BUNDLE_LIFECYCLE_MARK_NAMES.STUDIO_MANAGER_SETUP_END,
  ],
  [BUNDLE_LIFECYCLE_MEASURE_NAMES.STUDIO_PROTOCOL_GET_DURATION]: [
    BUNDLE_LIFECYCLE_MARK_NAMES.STUDIO_PROTOCOL_GET_START,
    BUNDLE_LIFECYCLE_MARK_NAMES.STUDIO_PROTOCOL_GET_END,
  ],
  [BUNDLE_LIFECYCLE_MEASURE_NAMES.STUDIO_PROTOCOL_PREPARE_DURATION]: [
    BUNDLE_LIFECYCLE_MARK_NAMES.STUDIO_PROTOCOL_PREPARE_START,
    BUNDLE_LIFECYCLE_MARK_NAMES.STUDIO_PROTOCOL_PREPARE_END,
  ],
}

export const BUNDLE_LIFECYCLE_TELEMETRY_GROUP_NAMES = {
  COMPLETE_BUNDLE_LIFECYCLE: 'complete-bundle-lifecycle',
} as const

type BundleLifecycleTelemetryGroupName = (typeof BUNDLE_LIFECYCLE_TELEMETRY_GROUP_NAMES)[keyof typeof BUNDLE_LIFECYCLE_TELEMETRY_GROUP_NAMES]

export const BUNDLE_LIFECYCLE_TELEMETRY_GROUPS: Record<BundleLifecycleTelemetryGroupName, BundleLifecycleMeasureName[]> = {
  [BUNDLE_LIFECYCLE_TELEMETRY_GROUP_NAMES.COMPLETE_BUNDLE_LIFECYCLE]: [
    BUNDLE_LIFECYCLE_MEASURE_NAMES.BUNDLE_LIFECYCLE_DURATION,
    BUNDLE_LIFECYCLE_MEASURE_NAMES.POST_STUDIO_SESSION_DURATION,
    BUNDLE_LIFECYCLE_MEASURE_NAMES.ENSURE_STUDIO_BUNDLE_DURATION,
    BUNDLE_LIFECYCLE_MEASURE_NAMES.STUDIO_MANAGER_SETUP_DURATION,
    BUNDLE_LIFECYCLE_MEASURE_NAMES.STUDIO_PROTOCOL_GET_DURATION,
    BUNDLE_LIFECYCLE_MEASURE_NAMES.STUDIO_PROTOCOL_PREPARE_DURATION,
  ],
}
