const CUSTOMER_INTERACTION_ENTITY_ID = "customers:customer_interaction";
const CUSTOMER_INTERACTION_TASK_SOURCE = "customers:interaction";
const CUSTOMER_INTERACTION_TASK_TYPE = "task";
const CUSTOMER_INTERACTION_ACTIVITY_ADAPTER_SOURCE = "adapter:activity";
const CUSTOMER_INTERACTION_TODO_ADAPTER_SOURCE = "adapter:todo";
const EXAMPLE_TODO_SOURCE = "example:todo";
function isTaskInteractionType(value) {
  return typeof value === "string" && value.trim().toLowerCase() === CUSTOMER_INTERACTION_TASK_TYPE;
}
function isAdapterActivitySource(value) {
  return value === CUSTOMER_INTERACTION_ACTIVITY_ADAPTER_SOURCE;
}
function isAdapterTodoSource(value) {
  return value === CUSTOMER_INTERACTION_TODO_ADAPTER_SOURCE;
}
function mapInteractionRecordToActivitySummary(interaction) {
  return {
    id: interaction.id,
    activityType: interaction.interactionType,
    subject: interaction.title ?? null,
    body: interaction.body ?? null,
    occurredAt: interaction.occurredAt ?? interaction.scheduledAt ?? null,
    createdAt: interaction.createdAt,
    appearanceIcon: interaction.appearanceIcon ?? null,
    appearanceColor: interaction.appearanceColor ?? null,
    entityId: interaction.entityId ?? null,
    authorUserId: interaction.authorUserId ?? null,
    authorName: interaction.authorName ?? null,
    authorEmail: interaction.authorEmail ?? null,
    dealId: interaction.dealId ?? null,
    dealTitle: interaction.dealTitle ?? null,
    customValues: interaction.customValues ?? null
  };
}
function mapInteractionRecordToTodoSummary(interaction) {
  const customValues = { ...interaction.customValues ?? {} };
  const externalHref = resolveExampleIntegrationHref(interaction);
  if (interaction.priority !== void 0) customValues.priority = interaction.priority;
  if (interaction.body !== void 0 && customValues.description === void 0) {
    customValues.description = interaction.body ?? null;
  }
  if (interaction.scheduledAt !== void 0 && customValues.due_at === void 0) {
    customValues.due_at = interaction.scheduledAt ?? null;
  }
  return {
    id: interaction.id,
    todoId: interaction.id,
    todoSource: CUSTOMER_INTERACTION_TASK_SOURCE,
    createdAt: interaction.createdAt,
    title: interaction.title ?? null,
    isDone: interaction.status === "done",
    status: interaction.status,
    priority: interaction.priority ?? null,
    severity: typeof customValues.severity === "string" && customValues.severity.trim().length ? customValues.severity.trim() : null,
    description: interaction.body ?? null,
    dueAt: interaction.scheduledAt ?? null,
    todoOrganizationId: null,
    customValues: Object.keys(customValues).length > 0 ? customValues : null,
    externalHref
  };
}
function resolveExampleIntegrationHref(item) {
  const example = item._integrations?.example;
  if (!example || typeof example !== "object") return null;
  return typeof example.href === "string" && example.href.trim().length > 0 ? example.href : null;
}
export {
  CUSTOMER_INTERACTION_ACTIVITY_ADAPTER_SOURCE,
  CUSTOMER_INTERACTION_ENTITY_ID,
  CUSTOMER_INTERACTION_TASK_SOURCE,
  CUSTOMER_INTERACTION_TASK_TYPE,
  CUSTOMER_INTERACTION_TODO_ADAPTER_SOURCE,
  EXAMPLE_TODO_SOURCE,
  isAdapterActivitySource,
  isAdapterTodoSource,
  isTaskInteractionType,
  mapInteractionRecordToActivitySummary,
  mapInteractionRecordToTodoSummary,
  resolveExampleIntegrationHref
};
//# sourceMappingURL=interactionCompatibility.js.map
