"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.extractState = void 0;
var _utils = require("./utils");
// Maps accent color short names to their corresponding background and text colors
var lozengeAccentStyles = {
  blue: {
    backgroundColor: "var(--ds-background-accent-blue-subtler, #CFE1FD)",
    color: "var(--ds-text-accent-blue, #1558BC)"
  },
  gray: {
    backgroundColor: "var(--ds-background-accent-gray-subtler, #DDDEE1)",
    color: "var(--ds-text-accent-gray, #505258)"
  },
  green: {
    backgroundColor: "var(--ds-background-accent-green-subtler, #BAF3DB)",
    color: "var(--ds-text-accent-green, #216E4E)"
  },
  lime: {
    backgroundColor: "var(--ds-background-accent-lime-subtler, #D3F1A7)",
    color: "var(--ds-text-accent-lime, #4C6B1F)"
  },
  magenta: {
    backgroundColor: "var(--ds-background-accent-magenta-subtler, #FDD0EC)",
    color: "var(--ds-text-accent-magenta, #943D73)"
  },
  orange: {
    backgroundColor: "var(--ds-background-accent-orange-subtler, #FCE4A6)",
    color: "var(--ds-text-accent-orange, #9E4C00)"
  },
  purple: {
    backgroundColor: "var(--ds-background-accent-purple-subtler, #EED7FC)",
    color: "var(--ds-text-accent-purple, #803FA5)"
  },
  red: {
    backgroundColor: "var(--ds-background-accent-red-subtler, #FFD5D2)",
    color: "var(--ds-text-accent-red, #AE2E24)"
  },
  teal: {
    backgroundColor: "var(--ds-background-accent-teal-subtler, #C6EDFB)",
    color: "var(--ds-text-accent-teal, #206A83)"
  },
  yellow: {
    backgroundColor: "var(--ds-background-accent-yellow-subtler, #F5E989)",
    color: "var(--ds-text-accent-yellow, #7F5F01)"
  }
};
var capitalize = function capitalize(str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
};
var extractState = exports.extractState = function extractState(jsonLd) {
  var state = jsonLd['atlassian:state'];
  if (state) {
    if (typeof state === 'string') {
      var linkState = state.toLowerCase();
      if (!_utils.OMIT_STATES.includes(linkState)) {
        return {
          text: capitalize(linkState),
          appearance: _utils.VALID_STATES[linkState] || 'default'
        };
      }
    } else if (state['@type'] === 'Link' || state['@type'] === 'Object') {
      if (state.name) {
        var accent = state.accent;
        return {
          text: state.name,
          appearance: state.appearance || 'default',
          style: accent ? lozengeAccentStyles[accent] : undefined
        };
      }
    }
  }
};