{"version":3,"file":"legacyUtils.mjs","sources":["../../../src/button/legacyUtils/legacyUtils.ts"],"sourcesContent":["import { ControlType, Priority, Size, Type } from '../../common';\nimport { logActionRequired, logActionRequiredIf } from '../../utilities';\n\nconst deprecatedTypeMap: Record<Type, ControlType> = {\n  [Type.PRIMARY]: ControlType.ACCENT,\n  [Type.SECONDARY]: ControlType.ACCENT,\n  [Type.LINK]: ControlType.ACCENT,\n  [Type.PAY]: ControlType.POSITIVE,\n  [Type.DANGER]: ControlType.NEGATIVE,\n};\n\ntype OldTypeKeys = Type.DANGER | Type.LINK | Type.SECONDARY;\nconst oldTypePriorityMap: Record<OldTypeKeys, Priority> = {\n  [Type.DANGER]: Priority.SECONDARY,\n  [Type.LINK]: Priority.TERTIARY,\n  [Type.SECONDARY]: Priority.SECONDARY,\n};\n\nconst deprecatedTypeMapMessage = {\n  [Type.DANGER]: 'Type.NEGATIVE',\n  [Type.LINK]: 'ControlType.ACCENT with priority Priority.TERTIARY',\n  [Type.PAY]: 'ControlType.POSITIVE',\n  [Type.PRIMARY]: 'ControlType.ACCENT',\n  [Type.SECONDARY]: 'ControlType.ACCENT with priority Priority.SECONDARY',\n};\n\nconst deprecatedTypes = Object.keys(deprecatedTypeMap);\n\ntype EstablishNewTypeType = (\n  originalType: Type | (string & Record<never, never>) | null,\n) => `${ControlType}` | string | null;\n\nexport const establishNewType: EstablishNewTypeType = (originalType) =>\n  originalType && originalType in deprecatedTypeMap\n    ? deprecatedTypeMap[originalType as Type]\n    : originalType;\n\ntype EstablishNewPriorityType = (\n  originalPriority?: Priority | (string & Record<never, never>) | null,\n  originalType?: OldTypeKeys | (string & Record<never, never>) | null,\n) => `${ControlType}` | string | null | undefined;\n\nexport const establishNewPriority: EstablishNewPriorityType = (originalPriority, originalType) => {\n  const type = originalType ? establishNewType(originalType) : '';\n\n  // The old SECONDARY and LINK types now map to priorities. If they're still using one of\n  // these old types, ignore whatever priority they've passed and use this instead.\n  if (originalType && originalType in oldTypePriorityMap) {\n    return oldTypePriorityMap[originalType as OldTypeKeys];\n  }\n  // Only ControlType.ACCENT supports tertiary styles\n  if (originalPriority === Priority.TERTIARY && type !== ControlType.ACCENT) {\n    return Priority.SECONDARY;\n  }\n  return originalPriority;\n};\n\ntype DeprecatedTypeMapMessageType = keyof typeof deprecatedTypeMapMessage;\ntype LogDeprecationNoticesType = (params: {\n  size?: `${Size}`;\n  type?: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;\n}) => void;\nexport const logDeprecationNotices: LogDeprecationNoticesType = ({ size, type }) => {\n  logActionRequiredIf(\n    'Button has deprecated the `Size.EXTRA_SMALL` value for the `size` prop. Please use Size.SMALL instead.',\n    size === Size.EXTRA_SMALL,\n  );\n\n  if (type && deprecatedTypes.includes(type) && type in deprecatedTypeMapMessage) {\n    logActionRequired(\n      `Button has deprecated the ${type} value for the \\`type\\` prop. Please update to ${deprecatedTypeMapMessage[type as DeprecatedTypeMapMessageType]}.`,\n    );\n  }\n};\n"],"names":["deprecatedTypeMap","Type","PRIMARY","ControlType","ACCENT","SECONDARY","LINK","PAY","POSITIVE","DANGER","NEGATIVE","oldTypePriorityMap","Priority","TERTIARY","deprecatedTypeMapMessage","deprecatedTypes","Object","keys","establishNewType","originalType","establishNewPriority","originalPriority","type","logDeprecationNotices","size","logActionRequiredIf","Size","EXTRA_SMALL","includes","logActionRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAMA,iBAAiB,GAA8B;AACnD,EAAA,CAACC,IAAI,CAACC,OAAO,GAAGC,WAAW,CAACC,MAAM;AAClC,EAAA,CAACH,IAAI,CAACI,SAAS,GAAGF,WAAW,CAACC,MAAM;AACpC,EAAA,CAACH,IAAI,CAACK,IAAI,GAAGH,WAAW,CAACC,MAAM;AAC/B,EAAA,CAACH,IAAI,CAACM,GAAG,GAAGJ,WAAW,CAACK,QAAQ;AAChC,EAAA,CAACP,IAAI,CAACQ,MAAM,GAAGN,WAAW,CAACO;CAC5B;AAGD,MAA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