@m3e/web 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (966) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +85 -0
  3. package/dist/all.js +28231 -0
  4. package/dist/all.js.map +1 -0
  5. package/dist/all.min.js +482 -0
  6. package/dist/all.min.js.map +1 -0
  7. package/dist/app-bar.js +763 -0
  8. package/dist/app-bar.js.map +1 -0
  9. package/dist/app-bar.min.js +40 -0
  10. package/dist/app-bar.min.js.map +1 -0
  11. package/dist/autocomplete.js +883 -0
  12. package/dist/autocomplete.js.map +1 -0
  13. package/dist/autocomplete.min.js +29 -0
  14. package/dist/autocomplete.min.js.map +1 -0
  15. package/dist/avatar.js +416 -0
  16. package/dist/avatar.js.map +1 -0
  17. package/dist/avatar.min.js +23 -0
  18. package/dist/avatar.min.js.map +1 -0
  19. package/dist/badge.js +583 -0
  20. package/dist/badge.js.map +1 -0
  21. package/dist/badge.min.js +29 -0
  22. package/dist/badge.min.js.map +1 -0
  23. package/dist/bottom-sheet.js +1193 -0
  24. package/dist/bottom-sheet.js.map +1 -0
  25. package/dist/bottom-sheet.min.js +29 -0
  26. package/dist/bottom-sheet.min.js.map +1 -0
  27. package/dist/button-group.js +643 -0
  28. package/dist/button-group.js.map +1 -0
  29. package/dist/button-group.min.js +44 -0
  30. package/dist/button-group.min.js.map +1 -0
  31. package/dist/button.js +1690 -0
  32. package/dist/button.js.map +1 -0
  33. package/dist/button.min.js +40 -0
  34. package/dist/button.min.js.map +1 -0
  35. package/dist/card.js +821 -0
  36. package/dist/card.js.map +1 -0
  37. package/dist/card.min.js +40 -0
  38. package/dist/card.min.js.map +1 -0
  39. package/dist/checkbox.js +608 -0
  40. package/dist/checkbox.js.map +1 -0
  41. package/dist/checkbox.min.js +40 -0
  42. package/dist/checkbox.min.js.map +1 -0
  43. package/dist/chips.js +1761 -0
  44. package/dist/chips.js.map +1 -0
  45. package/dist/chips.min.js +46 -0
  46. package/dist/chips.min.js.map +1 -0
  47. package/dist/core-a11y.js +1810 -0
  48. package/dist/core-a11y.js.map +1 -0
  49. package/dist/core-a11y.min.js +74 -0
  50. package/dist/core-a11y.min.js.map +1 -0
  51. package/dist/core-anchoring.js +1747 -0
  52. package/dist/core-anchoring.js.map +1 -0
  53. package/dist/core-anchoring.min.js +7 -0
  54. package/dist/core-anchoring.min.js.map +1 -0
  55. package/dist/core-bidi.js +105 -0
  56. package/dist/core-bidi.js.map +1 -0
  57. package/dist/core-bidi.min.js +16 -0
  58. package/dist/core-bidi.min.js.map +1 -0
  59. package/dist/core-layout.js +64 -0
  60. package/dist/core-layout.js.map +1 -0
  61. package/dist/core-layout.min.js +15 -0
  62. package/dist/core-layout.min.js.map +1 -0
  63. package/dist/core-platform.js +46 -0
  64. package/dist/core-platform.js.map +1 -0
  65. package/dist/core-platform.min.js +15 -0
  66. package/dist/core-platform.min.js.map +1 -0
  67. package/dist/core.js +5641 -0
  68. package/dist/core.js.map +1 -0
  69. package/dist/core.min.js +55 -0
  70. package/dist/core.min.js.map +1 -0
  71. package/dist/css-custom-data.json +11892 -0
  72. package/dist/custom-elements.json +63037 -0
  73. package/dist/dialog.js +1079 -0
  74. package/dist/dialog.js.map +1 -0
  75. package/dist/dialog.min.js +51 -0
  76. package/dist/dialog.min.js.map +1 -0
  77. package/dist/divider.js +489 -0
  78. package/dist/divider.js.map +1 -0
  79. package/dist/divider.min.js +29 -0
  80. package/dist/divider.min.js.map +1 -0
  81. package/dist/drawer-container.js +861 -0
  82. package/dist/drawer-container.js.map +1 -0
  83. package/dist/drawer-container.min.js +34 -0
  84. package/dist/drawer-container.min.js.map +1 -0
  85. package/dist/expansion-panel.js +878 -0
  86. package/dist/expansion-panel.js.map +1 -0
  87. package/dist/expansion-panel.min.js +40 -0
  88. package/dist/expansion-panel.min.js.map +1 -0
  89. package/dist/fab-menu.js +850 -0
  90. package/dist/fab-menu.js.map +1 -0
  91. package/dist/fab-menu.min.js +40 -0
  92. package/dist/fab-menu.min.js.map +1 -0
  93. package/dist/fab.js +1459 -0
  94. package/dist/fab.js.map +1 -0
  95. package/dist/fab.min.js +40 -0
  96. package/dist/fab.min.js.map +1 -0
  97. package/dist/form-field.js +919 -0
  98. package/dist/form-field.js.map +1 -0
  99. package/dist/form-field.min.js +61 -0
  100. package/dist/form-field.min.js.map +1 -0
  101. package/dist/heading.js +597 -0
  102. package/dist/heading.js.map +1 -0
  103. package/dist/heading.min.js +29 -0
  104. package/dist/heading.min.js.map +1 -0
  105. package/dist/html-custom-data.json +2628 -0
  106. package/dist/icon-button.js +1419 -0
  107. package/dist/icon-button.js.map +1 -0
  108. package/dist/icon-button.min.js +40 -0
  109. package/dist/icon-button.min.js.map +1 -0
  110. package/dist/icon.js +547 -0
  111. package/dist/icon.js.map +1 -0
  112. package/dist/icon.min.js +40 -0
  113. package/dist/icon.min.js.map +1 -0
  114. package/dist/index.js +7 -0
  115. package/dist/index.js.map +1 -0
  116. package/dist/list.js +1840 -0
  117. package/dist/list.js.map +1 -0
  118. package/dist/list.min.js +52 -0
  119. package/dist/list.min.js.map +1 -0
  120. package/dist/loading-indicator.js +533 -0
  121. package/dist/loading-indicator.js.map +1 -0
  122. package/dist/loading-indicator.min.js +40 -0
  123. package/dist/loading-indicator.min.js.map +1 -0
  124. package/dist/menu.js +1509 -0
  125. package/dist/menu.js.map +1 -0
  126. package/dist/menu.min.js +45 -0
  127. package/dist/menu.min.js.map +1 -0
  128. package/dist/nav-bar.js +738 -0
  129. package/dist/nav-bar.js.map +1 -0
  130. package/dist/nav-bar.min.js +45 -0
  131. package/dist/nav-bar.min.js.map +1 -0
  132. package/dist/nav-menu.js +1498 -0
  133. package/dist/nav-menu.js.map +1 -0
  134. package/dist/nav-menu.min.js +50 -0
  135. package/dist/nav-menu.min.js.map +1 -0
  136. package/dist/nav-rail.js +565 -0
  137. package/dist/nav-rail.js.map +1 -0
  138. package/dist/nav-rail.min.js +23 -0
  139. package/dist/nav-rail.min.js.map +1 -0
  140. package/dist/option.js +802 -0
  141. package/dist/option.js.map +1 -0
  142. package/dist/option.min.js +40 -0
  143. package/dist/option.min.js.map +1 -0
  144. package/dist/paginator.js +700 -0
  145. package/dist/paginator.js.map +1 -0
  146. package/dist/paginator.min.js +37 -0
  147. package/dist/paginator.min.js.map +1 -0
  148. package/dist/progress-indicator.js +1405 -0
  149. package/dist/progress-indicator.js.map +1 -0
  150. package/dist/progress-indicator.min.js +108 -0
  151. package/dist/progress-indicator.min.js.map +1 -0
  152. package/dist/radio-group.js +757 -0
  153. package/dist/radio-group.js.map +1 -0
  154. package/dist/radio-group.min.js +40 -0
  155. package/dist/radio-group.min.js.map +1 -0
  156. package/dist/segmented-button.js +782 -0
  157. package/dist/segmented-button.js.map +1 -0
  158. package/dist/segmented-button.min.js +40 -0
  159. package/dist/segmented-button.min.js.map +1 -0
  160. package/dist/select.js +1235 -0
  161. package/dist/select.js.map +1 -0
  162. package/dist/select.min.js +57 -0
  163. package/dist/select.min.js.map +1 -0
  164. package/dist/shape.js +543 -0
  165. package/dist/shape.js.map +1 -0
  166. package/dist/shape.min.js +29 -0
  167. package/dist/shape.min.js.map +1 -0
  168. package/dist/slide-group.js +655 -0
  169. package/dist/slide-group.js.map +1 -0
  170. package/dist/slide-group.min.js +45 -0
  171. package/dist/slide-group.min.js.map +1 -0
  172. package/dist/slider.js +1343 -0
  173. package/dist/slider.js.map +1 -0
  174. package/dist/slider.min.js +50 -0
  175. package/dist/slider.min.js.map +1 -0
  176. package/dist/snackbar.js +632 -0
  177. package/dist/snackbar.js.map +1 -0
  178. package/dist/snackbar.min.js +29 -0
  179. package/dist/snackbar.min.js.map +1 -0
  180. package/dist/split-button.js +661 -0
  181. package/dist/split-button.js.map +1 -0
  182. package/dist/split-button.min.js +40 -0
  183. package/dist/split-button.min.js.map +1 -0
  184. package/dist/src/all.d.ts +47 -0
  185. package/dist/src/all.d.ts.map +1 -0
  186. package/dist/src/app-bar/AppBarElement.d.ts +139 -0
  187. package/dist/src/app-bar/AppBarElement.d.ts.map +1 -0
  188. package/dist/src/app-bar/AppBarSize.d.ts +3 -0
  189. package/dist/src/app-bar/AppBarSize.d.ts.map +1 -0
  190. package/dist/src/app-bar/index.d.ts +3 -0
  191. package/dist/src/app-bar/index.d.ts.map +1 -0
  192. package/dist/src/app-bar/styles/AppBarSizeStyle.d.ts +7 -0
  193. package/dist/src/app-bar/styles/AppBarSizeStyle.d.ts.map +1 -0
  194. package/dist/src/app-bar/styles/AppBarSizeToken.d.ts +28 -0
  195. package/dist/src/app-bar/styles/AppBarSizeToken.d.ts.map +1 -0
  196. package/dist/src/app-bar/styles/AppBarStyle.d.ts +7 -0
  197. package/dist/src/app-bar/styles/AppBarStyle.d.ts.map +1 -0
  198. package/dist/src/app-bar/styles/AppBarToken.d.ts +15 -0
  199. package/dist/src/app-bar/styles/AppBarToken.d.ts.map +1 -0
  200. package/dist/src/app-bar/styles/index.d.ts +3 -0
  201. package/dist/src/app-bar/styles/index.d.ts.map +1 -0
  202. package/dist/src/autocomplete/AutocompleteElement.d.ts +79 -0
  203. package/dist/src/autocomplete/AutocompleteElement.d.ts.map +1 -0
  204. package/dist/src/autocomplete/index.d.ts +2 -0
  205. package/dist/src/autocomplete/index.d.ts.map +1 -0
  206. package/dist/src/avatar/AvatarElement.d.ts +54 -0
  207. package/dist/src/avatar/AvatarElement.d.ts.map +1 -0
  208. package/dist/src/avatar/index.d.ts +2 -0
  209. package/dist/src/avatar/index.d.ts.map +1 -0
  210. package/dist/src/badge/BadgeElement.d.ts +76 -0
  211. package/dist/src/badge/BadgeElement.d.ts.map +1 -0
  212. package/dist/src/badge/BadgePosition.d.ts +3 -0
  213. package/dist/src/badge/BadgePosition.d.ts.map +1 -0
  214. package/dist/src/badge/BadgeSize.d.ts +3 -0
  215. package/dist/src/badge/BadgeSize.d.ts.map +1 -0
  216. package/dist/src/badge/index.d.ts +4 -0
  217. package/dist/src/badge/index.d.ts.map +1 -0
  218. package/dist/src/bottom-sheet/BottomSheetActionElement.d.ts +17 -0
  219. package/dist/src/bottom-sheet/BottomSheetActionElement.d.ts.map +1 -0
  220. package/dist/src/bottom-sheet/BottomSheetElement.d.ts +189 -0
  221. package/dist/src/bottom-sheet/BottomSheetElement.d.ts.map +1 -0
  222. package/dist/src/bottom-sheet/BottomSheetTriggerElement.d.ts +36 -0
  223. package/dist/src/bottom-sheet/BottomSheetTriggerElement.d.ts.map +1 -0
  224. package/dist/src/bottom-sheet/index.d.ts +4 -0
  225. package/dist/src/bottom-sheet/index.d.ts.map +1 -0
  226. package/dist/src/button/ButtonElement.d.ts +429 -0
  227. package/dist/src/button/ButtonElement.d.ts.map +1 -0
  228. package/dist/src/button/ButtonShape.d.ts +3 -0
  229. package/dist/src/button/ButtonShape.d.ts.map +1 -0
  230. package/dist/src/button/ButtonSize.d.ts +3 -0
  231. package/dist/src/button/ButtonSize.d.ts.map +1 -0
  232. package/dist/src/button/ButtonVariant.d.ts +3 -0
  233. package/dist/src/button/ButtonVariant.d.ts.map +1 -0
  234. package/dist/src/button/index.d.ts +5 -0
  235. package/dist/src/button/index.d.ts.map +1 -0
  236. package/dist/src/button/styles/ButtonSizeStyle.d.ts +7 -0
  237. package/dist/src/button/styles/ButtonSizeStyle.d.ts.map +1 -0
  238. package/dist/src/button/styles/ButtonSizeToken.d.ts +27 -0
  239. package/dist/src/button/styles/ButtonSizeToken.d.ts.map +1 -0
  240. package/dist/src/button/styles/ButtonStyle.d.ts +7 -0
  241. package/dist/src/button/styles/ButtonStyle.d.ts.map +1 -0
  242. package/dist/src/button/styles/ButtonVariantStyle.d.ts +7 -0
  243. package/dist/src/button/styles/ButtonVariantStyle.d.ts.map +1 -0
  244. package/dist/src/button/styles/ButtonVariantToken.d.ts +75 -0
  245. package/dist/src/button/styles/ButtonVariantToken.d.ts.map +1 -0
  246. package/dist/src/button/styles/index.d.ts +4 -0
  247. package/dist/src/button/styles/index.d.ts.map +1 -0
  248. package/dist/src/button-group/ButtonGroupElement.d.ts +98 -0
  249. package/dist/src/button-group/ButtonGroupElement.d.ts.map +1 -0
  250. package/dist/src/button-group/ButtonGroupSize.d.ts +3 -0
  251. package/dist/src/button-group/ButtonGroupSize.d.ts.map +1 -0
  252. package/dist/src/button-group/ButtonGroupVariant.d.ts +3 -0
  253. package/dist/src/button-group/ButtonGroupVariant.d.ts.map +1 -0
  254. package/dist/src/button-group/index.d.ts +4 -0
  255. package/dist/src/button-group/index.d.ts.map +1 -0
  256. package/dist/src/card/CardElement.d.ts +171 -0
  257. package/dist/src/card/CardElement.d.ts.map +1 -0
  258. package/dist/src/card/CardOrientation.d.ts +3 -0
  259. package/dist/src/card/CardOrientation.d.ts.map +1 -0
  260. package/dist/src/card/CardVariant.d.ts +3 -0
  261. package/dist/src/card/CardVariant.d.ts.map +1 -0
  262. package/dist/src/card/index.d.ts +4 -0
  263. package/dist/src/card/index.d.ts.map +1 -0
  264. package/dist/src/card/styles/CardStyle.d.ts +7 -0
  265. package/dist/src/card/styles/CardStyle.d.ts.map +1 -0
  266. package/dist/src/card/styles/CardToken.d.ts +9 -0
  267. package/dist/src/card/styles/CardToken.d.ts.map +1 -0
  268. package/dist/src/card/styles/CardVariantStyle.d.ts +7 -0
  269. package/dist/src/card/styles/CardVariantStyle.d.ts.map +1 -0
  270. package/dist/src/card/styles/CardVariantToken.d.ts +50 -0
  271. package/dist/src/card/styles/CardVariantToken.d.ts.map +1 -0
  272. package/dist/src/card/styles/index.d.ts +3 -0
  273. package/dist/src/card/styles/index.d.ts.map +1 -0
  274. package/dist/src/checkbox/CheckboxElement.d.ts +100 -0
  275. package/dist/src/checkbox/CheckboxElement.d.ts.map +1 -0
  276. package/dist/src/checkbox/index.d.ts +2 -0
  277. package/dist/src/checkbox/index.d.ts.map +1 -0
  278. package/dist/src/chips/AssistChipElement.d.ts +83 -0
  279. package/dist/src/chips/AssistChipElement.d.ts.map +1 -0
  280. package/dist/src/chips/ChipElement.d.ts +83 -0
  281. package/dist/src/chips/ChipElement.d.ts.map +1 -0
  282. package/dist/src/chips/ChipSetElement.d.ts +42 -0
  283. package/dist/src/chips/ChipSetElement.d.ts.map +1 -0
  284. package/dist/src/chips/ChipVariant.d.ts +3 -0
  285. package/dist/src/chips/ChipVariant.d.ts.map +1 -0
  286. package/dist/src/chips/FilterChipElement.d.ts +105 -0
  287. package/dist/src/chips/FilterChipElement.d.ts.map +1 -0
  288. package/dist/src/chips/FilterChipSetElement.d.ts +81 -0
  289. package/dist/src/chips/FilterChipSetElement.d.ts.map +1 -0
  290. package/dist/src/chips/InputChipElement.d.ts +117 -0
  291. package/dist/src/chips/InputChipElement.d.ts.map +1 -0
  292. package/dist/src/chips/InputChipSetElement.d.ts +74 -0
  293. package/dist/src/chips/InputChipSetElement.d.ts.map +1 -0
  294. package/dist/src/chips/SuggestionChipElement.d.ts +84 -0
  295. package/dist/src/chips/SuggestionChipElement.d.ts.map +1 -0
  296. package/dist/src/chips/index.d.ts +10 -0
  297. package/dist/src/chips/index.d.ts.map +1 -0
  298. package/dist/src/core/a11y/AriaDescriber.d.ts +31 -0
  299. package/dist/src/core/a11y/AriaDescriber.d.ts.map +1 -0
  300. package/dist/src/core/a11y/FocusTrapElement.d.ts +25 -0
  301. package/dist/src/core/a11y/FocusTrapElement.d.ts.map +1 -0
  302. package/dist/src/core/a11y/InteractivityChecker.d.ts +22 -0
  303. package/dist/src/core/a11y/InteractivityChecker.d.ts.map +1 -0
  304. package/dist/src/core/a11y/LiveAnnouncer.d.ts +56 -0
  305. package/dist/src/core/a11y/LiveAnnouncer.d.ts.map +1 -0
  306. package/dist/src/core/a11y/aria-reference.d.ts +30 -0
  307. package/dist/src/core/a11y/aria-reference.d.ts.map +1 -0
  308. package/dist/src/core/a11y/index.d.ts +8 -0
  309. package/dist/src/core/a11y/index.d.ts.map +1 -0
  310. package/dist/src/core/a11y/keycodes/KeyCode.d.ts +118 -0
  311. package/dist/src/core/a11y/keycodes/KeyCode.d.ts.map +1 -0
  312. package/dist/src/core/a11y/keycodes/ModifierKeys.d.ts +5 -0
  313. package/dist/src/core/a11y/keycodes/ModifierKeys.d.ts.map +1 -0
  314. package/dist/src/core/a11y/keycodes/getKeyCode.d.ts +7 -0
  315. package/dist/src/core/a11y/keycodes/getKeyCode.d.ts.map +1 -0
  316. package/dist/src/core/a11y/keycodes/hasModifierKey.d.ts +9 -0
  317. package/dist/src/core/a11y/keycodes/hasModifierKey.d.ts.map +1 -0
  318. package/dist/src/core/a11y/keycodes/index.d.ts +6 -0
  319. package/dist/src/core/a11y/keycodes/index.d.ts.map +1 -0
  320. package/dist/src/core/a11y/keycodes/isModifierAllowed.d.ts +9 -0
  321. package/dist/src/core/a11y/keycodes/isModifierAllowed.d.ts.map +1 -0
  322. package/dist/src/core/a11y/list-key/FocusKeyManager.d.ts +17 -0
  323. package/dist/src/core/a11y/list-key/FocusKeyManager.d.ts.map +1 -0
  324. package/dist/src/core/a11y/list-key/ListKeyManager.d.ts +125 -0
  325. package/dist/src/core/a11y/list-key/ListKeyManager.d.ts.map +1 -0
  326. package/dist/src/core/a11y/list-key/ListManager.d.ts +37 -0
  327. package/dist/src/core/a11y/list-key/ListManager.d.ts.map +1 -0
  328. package/dist/src/core/a11y/list-key/RadioKeyManager.d.ts +20 -0
  329. package/dist/src/core/a11y/list-key/RadioKeyManager.d.ts.map +1 -0
  330. package/dist/src/core/a11y/list-key/RovingTabIndexManager.d.ts +22 -0
  331. package/dist/src/core/a11y/list-key/RovingTabIndexManager.d.ts.map +1 -0
  332. package/dist/src/core/a11y/list-key/SelectionManager.d.ts +46 -0
  333. package/dist/src/core/a11y/list-key/SelectionManager.d.ts.map +1 -0
  334. package/dist/src/core/a11y/list-key/Typeahead.d.ts +64 -0
  335. package/dist/src/core/a11y/list-key/Typeahead.d.ts.map +1 -0
  336. package/dist/src/core/a11y/list-key/index.d.ts +8 -0
  337. package/dist/src/core/a11y/list-key/index.d.ts.map +1 -0
  338. package/dist/src/core/a11y/visuallyHide.d.ts +6 -0
  339. package/dist/src/core/a11y/visuallyHide.d.ts.map +1 -0
  340. package/dist/src/core/anchoring/AnchorOptions.d.ts +15 -0
  341. package/dist/src/core/anchoring/AnchorOptions.d.ts.map +1 -0
  342. package/dist/src/core/anchoring/AnchorPosition.d.ts +3 -0
  343. package/dist/src/core/anchoring/AnchorPosition.d.ts.map +1 -0
  344. package/dist/src/core/anchoring/index.d.ts +4 -0
  345. package/dist/src/core/anchoring/index.d.ts.map +1 -0
  346. package/dist/src/core/anchoring/positionAnchor.d.ts +12 -0
  347. package/dist/src/core/anchoring/positionAnchor.d.ts.map +1 -0
  348. package/dist/src/core/bidi/Directionality.d.ts +27 -0
  349. package/dist/src/core/bidi/Directionality.d.ts.map +1 -0
  350. package/dist/src/core/bidi/index.d.ts +2 -0
  351. package/dist/src/core/bidi/index.d.ts.map +1 -0
  352. package/dist/src/core/index.d.ts +2 -0
  353. package/dist/src/core/index.d.ts.map +1 -0
  354. package/dist/src/core/layout/Breakpoint.d.ts +26 -0
  355. package/dist/src/core/layout/Breakpoint.d.ts.map +1 -0
  356. package/dist/src/core/layout/BreakpointObserver.d.ts +18 -0
  357. package/dist/src/core/layout/BreakpointObserver.d.ts.map +1 -0
  358. package/dist/src/core/layout/index.d.ts +3 -0
  359. package/dist/src/core/layout/index.d.ts.map +1 -0
  360. package/dist/src/core/platform/Platform.d.ts +34 -0
  361. package/dist/src/core/platform/Platform.d.ts.map +1 -0
  362. package/dist/src/core/platform/index.d.ts +2 -0
  363. package/dist/src/core/platform/index.d.ts.map +1 -0
  364. package/dist/src/core/shared/controllers/AnimationLoopController.d.ts +13 -0
  365. package/dist/src/core/shared/controllers/AnimationLoopController.d.ts.map +1 -0
  366. package/dist/src/core/shared/controllers/FocusController.d.ts +34 -0
  367. package/dist/src/core/shared/controllers/FocusController.d.ts.map +1 -0
  368. package/dist/src/core/shared/controllers/HoverController.d.ts +40 -0
  369. package/dist/src/core/shared/controllers/HoverController.d.ts.map +1 -0
  370. package/dist/src/core/shared/controllers/IntersectionController.d.ts +40 -0
  371. package/dist/src/core/shared/controllers/IntersectionController.d.ts.map +1 -0
  372. package/dist/src/core/shared/controllers/LongPressController.d.ts +32 -0
  373. package/dist/src/core/shared/controllers/LongPressController.d.ts.map +1 -0
  374. package/dist/src/core/shared/controllers/MonitorControllerBase.d.ts +62 -0
  375. package/dist/src/core/shared/controllers/MonitorControllerBase.d.ts.map +1 -0
  376. package/dist/src/core/shared/controllers/MutationController.d.ts +37 -0
  377. package/dist/src/core/shared/controllers/MutationController.d.ts.map +1 -0
  378. package/dist/src/core/shared/controllers/PressedController.d.ts +47 -0
  379. package/dist/src/core/shared/controllers/PressedController.d.ts.map +1 -0
  380. package/dist/src/core/shared/controllers/ResizeController.d.ts +40 -0
  381. package/dist/src/core/shared/controllers/ResizeController.d.ts.map +1 -0
  382. package/dist/src/core/shared/controllers/ScrollController.d.ts +34 -0
  383. package/dist/src/core/shared/controllers/ScrollController.d.ts.map +1 -0
  384. package/dist/src/core/shared/controllers/ScrollLockController.d.ts +16 -0
  385. package/dist/src/core/shared/controllers/ScrollLockController.d.ts.map +1 -0
  386. package/dist/src/core/shared/controllers/index.d.ts +11 -0
  387. package/dist/src/core/shared/controllers/index.d.ts.map +1 -0
  388. package/dist/src/core/shared/converters/index.d.ts +2 -0
  389. package/dist/src/core/shared/converters/index.d.ts.map +1 -0
  390. package/dist/src/core/shared/converters/spaceSeparatedStringConverter.d.ts +4 -0
  391. package/dist/src/core/shared/converters/spaceSeparatedStringConverter.d.ts.map +1 -0
  392. package/dist/src/core/shared/decorators/debounce.d.ts +7 -0
  393. package/dist/src/core/shared/decorators/debounce.d.ts.map +1 -0
  394. package/dist/src/core/shared/decorators/index.d.ts +2 -0
  395. package/dist/src/core/shared/decorators/index.d.ts.map +1 -0
  396. package/dist/src/core/shared/directives/index.d.ts +2 -0
  397. package/dist/src/core/shared/directives/index.d.ts.map +1 -0
  398. package/dist/src/core/shared/directives/safeStyleMap.d.ts +44 -0
  399. package/dist/src/core/shared/directives/safeStyleMap.d.ts.map +1 -0
  400. package/dist/src/core/shared/index.d.ts +9 -0
  401. package/dist/src/core/shared/index.d.ts.map +1 -0
  402. package/dist/src/core/shared/mixins/AttachInternals.d.ts +24 -0
  403. package/dist/src/core/shared/mixins/AttachInternals.d.ts.map +1 -0
  404. package/dist/src/core/shared/mixins/Checked.d.ts +24 -0
  405. package/dist/src/core/shared/mixins/Checked.d.ts.map +1 -0
  406. package/dist/src/core/shared/mixins/CheckedIndeterminate.d.ts +25 -0
  407. package/dist/src/core/shared/mixins/CheckedIndeterminate.d.ts.map +1 -0
  408. package/dist/src/core/shared/mixins/CheckedOrSelected.d.ts +23 -0
  409. package/dist/src/core/shared/mixins/CheckedOrSelected.d.ts.map +1 -0
  410. package/dist/src/core/shared/mixins/ConstraintValidation.d.ts +48 -0
  411. package/dist/src/core/shared/mixins/ConstraintValidation.d.ts.map +1 -0
  412. package/dist/src/core/shared/mixins/Constructor.d.ts +3 -0
  413. package/dist/src/core/shared/mixins/Constructor.d.ts.map +1 -0
  414. package/dist/src/core/shared/mixins/Dirty.d.ts +27 -0
  415. package/dist/src/core/shared/mixins/Dirty.d.ts.map +1 -0
  416. package/dist/src/core/shared/mixins/Disabled.d.ts +25 -0
  417. package/dist/src/core/shared/mixins/Disabled.d.ts.map +1 -0
  418. package/dist/src/core/shared/mixins/DisabledInteractive.d.ts +25 -0
  419. package/dist/src/core/shared/mixins/DisabledInteractive.d.ts.map +1 -0
  420. package/dist/src/core/shared/mixins/EventAttribute.d.ts +11 -0
  421. package/dist/src/core/shared/mixins/EventAttribute.d.ts.map +1 -0
  422. package/dist/src/core/shared/mixins/Focusable.d.ts +11 -0
  423. package/dist/src/core/shared/mixins/Focusable.d.ts.map +1 -0
  424. package/dist/src/core/shared/mixins/FormAssociated.d.ts +34 -0
  425. package/dist/src/core/shared/mixins/FormAssociated.d.ts.map +1 -0
  426. package/dist/src/core/shared/mixins/FormSubmitter.d.ts +34 -0
  427. package/dist/src/core/shared/mixins/FormSubmitter.d.ts.map +1 -0
  428. package/dist/src/core/shared/mixins/HtmlFor.d.ts +30 -0
  429. package/dist/src/core/shared/mixins/HtmlFor.d.ts.map +1 -0
  430. package/dist/src/core/shared/mixins/KeyboardClick.d.ts +11 -0
  431. package/dist/src/core/shared/mixins/KeyboardClick.d.ts.map +1 -0
  432. package/dist/src/core/shared/mixins/Labelled.d.ts +26 -0
  433. package/dist/src/core/shared/mixins/Labelled.d.ts.map +1 -0
  434. package/dist/src/core/shared/mixins/LinkButton.d.ts +46 -0
  435. package/dist/src/core/shared/mixins/LinkButton.d.ts.map +1 -0
  436. package/dist/src/core/shared/mixins/ReadOnly.d.ts +25 -0
  437. package/dist/src/core/shared/mixins/ReadOnly.d.ts.map +1 -0
  438. package/dist/src/core/shared/mixins/Required.d.ts +26 -0
  439. package/dist/src/core/shared/mixins/Required.d.ts.map +1 -0
  440. package/dist/src/core/shared/mixins/RequiredConstraintValidation.d.ts +21 -0
  441. package/dist/src/core/shared/mixins/RequiredConstraintValidation.d.ts.map +1 -0
  442. package/dist/src/core/shared/mixins/Role.d.ts +13 -0
  443. package/dist/src/core/shared/mixins/Role.d.ts.map +1 -0
  444. package/dist/src/core/shared/mixins/Selected.d.ts +24 -0
  445. package/dist/src/core/shared/mixins/Selected.d.ts.map +1 -0
  446. package/dist/src/core/shared/mixins/Touched.d.ts +27 -0
  447. package/dist/src/core/shared/mixins/Touched.d.ts.map +1 -0
  448. package/dist/src/core/shared/mixins/Vertical.d.ts +24 -0
  449. package/dist/src/core/shared/mixins/Vertical.d.ts.map +1 -0
  450. package/dist/src/core/shared/mixins/hasKeys.d.ts +9 -0
  451. package/dist/src/core/shared/mixins/hasKeys.d.ts.map +1 -0
  452. package/dist/src/core/shared/mixins/index.d.ts +25 -0
  453. package/dist/src/core/shared/mixins/index.d.ts.map +1 -0
  454. package/dist/src/core/shared/primitives/ActionElementBase.d.ts +22 -0
  455. package/dist/src/core/shared/primitives/ActionElementBase.d.ts.map +1 -0
  456. package/dist/src/core/shared/primitives/CollapsibleElement.d.ts +58 -0
  457. package/dist/src/core/shared/primitives/CollapsibleElement.d.ts.map +1 -0
  458. package/dist/src/core/shared/primitives/ElevationElement.d.ts +87 -0
  459. package/dist/src/core/shared/primitives/ElevationElement.d.ts.map +1 -0
  460. package/dist/src/core/shared/primitives/ElevationLevel.d.ts +3 -0
  461. package/dist/src/core/shared/primitives/ElevationLevel.d.ts.map +1 -0
  462. package/dist/src/core/shared/primitives/ElevationToken.d.ts +15 -0
  463. package/dist/src/core/shared/primitives/ElevationToken.d.ts.map +1 -0
  464. package/dist/src/core/shared/primitives/FocusRingElement.d.ts +77 -0
  465. package/dist/src/core/shared/primitives/FocusRingElement.d.ts.map +1 -0
  466. package/dist/src/core/shared/primitives/FocusRingToken.d.ts +17 -0
  467. package/dist/src/core/shared/primitives/FocusRingToken.d.ts.map +1 -0
  468. package/dist/src/core/shared/primitives/PseudoCheckboxElement.d.ts +49 -0
  469. package/dist/src/core/shared/primitives/PseudoCheckboxElement.d.ts.map +1 -0
  470. package/dist/src/core/shared/primitives/PseudoRadioElement.d.ts +40 -0
  471. package/dist/src/core/shared/primitives/PseudoRadioElement.d.ts.map +1 -0
  472. package/dist/src/core/shared/primitives/RippleElement.d.ts +97 -0
  473. package/dist/src/core/shared/primitives/RippleElement.d.ts.map +1 -0
  474. package/dist/src/core/shared/primitives/RippleToken.d.ts +12 -0
  475. package/dist/src/core/shared/primitives/RippleToken.d.ts.map +1 -0
  476. package/dist/src/core/shared/primitives/ScrollContainerElement.d.ts +61 -0
  477. package/dist/src/core/shared/primitives/ScrollContainerElement.d.ts.map +1 -0
  478. package/dist/src/core/shared/primitives/ScrollDividers.d.ts +3 -0
  479. package/dist/src/core/shared/primitives/ScrollDividers.d.ts.map +1 -0
  480. package/dist/src/core/shared/primitives/SlideElement.d.ts +45 -0
  481. package/dist/src/core/shared/primitives/SlideElement.d.ts.map +1 -0
  482. package/dist/src/core/shared/primitives/StateLayerElement.d.ts +83 -0
  483. package/dist/src/core/shared/primitives/StateLayerElement.d.ts.map +1 -0
  484. package/dist/src/core/shared/primitives/StateLayerToken.d.ts +13 -0
  485. package/dist/src/core/shared/primitives/StateLayerToken.d.ts.map +1 -0
  486. package/dist/src/core/shared/primitives/TextHighlightElement.d.ts +81 -0
  487. package/dist/src/core/shared/primitives/TextHighlightElement.d.ts.map +1 -0
  488. package/dist/src/core/shared/primitives/TextOverflowElement.d.ts +38 -0
  489. package/dist/src/core/shared/primitives/TextOverflowElement.d.ts.map +1 -0
  490. package/dist/src/core/shared/primitives/index.d.ts +15 -0
  491. package/dist/src/core/shared/primitives/index.d.ts.map +1 -0
  492. package/dist/src/core/shared/tokens/ColorToken.d.ts +96 -0
  493. package/dist/src/core/shared/tokens/ColorToken.d.ts.map +1 -0
  494. package/dist/src/core/shared/tokens/DensityToken.d.ts +15 -0
  495. package/dist/src/core/shared/tokens/DensityToken.d.ts.map +1 -0
  496. package/dist/src/core/shared/tokens/DesignToken.d.ts +366 -0
  497. package/dist/src/core/shared/tokens/DesignToken.d.ts.map +1 -0
  498. package/dist/src/core/shared/tokens/ElevationToken.d.ts +16 -0
  499. package/dist/src/core/shared/tokens/ElevationToken.d.ts.map +1 -0
  500. package/dist/src/core/shared/tokens/MotionToken.d.ts +69 -0
  501. package/dist/src/core/shared/tokens/MotionToken.d.ts.map +1 -0
  502. package/dist/src/core/shared/tokens/ScrollbarToken.d.ts +10 -0
  503. package/dist/src/core/shared/tokens/ScrollbarToken.d.ts.map +1 -0
  504. package/dist/src/core/shared/tokens/ShapeToken.d.ts +79 -0
  505. package/dist/src/core/shared/tokens/ShapeToken.d.ts.map +1 -0
  506. package/dist/src/core/shared/tokens/StateToken.d.ts +10 -0
  507. package/dist/src/core/shared/tokens/StateToken.d.ts.map +1 -0
  508. package/dist/src/core/shared/tokens/TypescaleToken.d.ts +220 -0
  509. package/dist/src/core/shared/tokens/TypescaleToken.d.ts.map +1 -0
  510. package/dist/src/core/shared/tokens/index.d.ts +2 -0
  511. package/dist/src/core/shared/tokens/index.d.ts.map +1 -0
  512. package/dist/src/core/shared/utils/VelocityTracker.d.ts +22 -0
  513. package/dist/src/core/shared/utils/VelocityTracker.d.ts.map +1 -0
  514. package/dist/src/core/shared/utils/computeCssSize.d.ts +8 -0
  515. package/dist/src/core/shared/utils/computeCssSize.d.ts.map +1 -0
  516. package/dist/src/core/shared/utils/computeLineCount.d.ts +7 -0
  517. package/dist/src/core/shared/utils/computeLineCount.d.ts.map +1 -0
  518. package/dist/src/core/shared/utils/focusWhenReady.d.ts +8 -0
  519. package/dist/src/core/shared/utils/focusWhenReady.d.ts.map +1 -0
  520. package/dist/src/core/shared/utils/forcedColorsActive.d.ts +6 -0
  521. package/dist/src/core/shared/utils/forcedColorsActive.d.ts.map +1 -0
  522. package/dist/src/core/shared/utils/generateClipPaths.d.ts +8 -0
  523. package/dist/src/core/shared/utils/generateClipPaths.d.ts.map +1 -0
  524. package/dist/src/core/shared/utils/getTextContent.d.ts +8 -0
  525. package/dist/src/core/shared/utils/getTextContent.d.ts.map +1 -0
  526. package/dist/src/core/shared/utils/guid.d.ts +6 -0
  527. package/dist/src/core/shared/utils/guid.d.ts.map +1 -0
  528. package/dist/src/core/shared/utils/hasAssignedNodes.d.ts +7 -0
  529. package/dist/src/core/shared/utils/hasAssignedNodes.d.ts.map +1 -0
  530. package/dist/src/core/shared/utils/index.d.ts +15 -0
  531. package/dist/src/core/shared/utils/index.d.ts.map +1 -0
  532. package/dist/src/core/shared/utils/interceptProperty.d.ts +17 -0
  533. package/dist/src/core/shared/utils/interceptProperty.d.ts.map +1 -0
  534. package/dist/src/core/shared/utils/prefersReducedMotion.d.ts +6 -0
  535. package/dist/src/core/shared/utils/prefersReducedMotion.d.ts.map +1 -0
  536. package/dist/src/core/shared/utils/resolveElementById.d.ts +8 -0
  537. package/dist/src/core/shared/utils/resolveElementById.d.ts.map +1 -0
  538. package/dist/src/core/shared/utils/resolveFragmentUrl.d.ts +22 -0
  539. package/dist/src/core/shared/utils/resolveFragmentUrl.d.ts.map +1 -0
  540. package/dist/src/core/shared/utils/scrollIntoViewIfNeeded.d.ts +8 -0
  541. package/dist/src/core/shared/utils/scrollIntoViewIfNeeded.d.ts.map +1 -0
  542. package/dist/src/dialog/DialogActionElement.d.ts +24 -0
  543. package/dist/src/dialog/DialogActionElement.d.ts.map +1 -0
  544. package/dist/src/dialog/DialogElement.d.ts +142 -0
  545. package/dist/src/dialog/DialogElement.d.ts.map +1 -0
  546. package/dist/src/dialog/DialogTriggerElement.d.ts +21 -0
  547. package/dist/src/dialog/DialogTriggerElement.d.ts.map +1 -0
  548. package/dist/src/dialog/index.d.ts +4 -0
  549. package/dist/src/dialog/index.d.ts.map +1 -0
  550. package/dist/src/divider/DividerElement.d.ts +63 -0
  551. package/dist/src/divider/DividerElement.d.ts.map +1 -0
  552. package/dist/src/divider/index.d.ts +2 -0
  553. package/dist/src/divider/index.d.ts.map +1 -0
  554. package/dist/src/drawer-container/DrawerContainerElement.d.ts +107 -0
  555. package/dist/src/drawer-container/DrawerContainerElement.d.ts.map +1 -0
  556. package/dist/src/drawer-container/DrawerMode.d.ts +3 -0
  557. package/dist/src/drawer-container/DrawerMode.d.ts.map +1 -0
  558. package/dist/src/drawer-container/DrawerPosition.d.ts +3 -0
  559. package/dist/src/drawer-container/DrawerPosition.d.ts.map +1 -0
  560. package/dist/src/drawer-container/DrawerToggleElement.d.ts +42 -0
  561. package/dist/src/drawer-container/DrawerToggleElement.d.ts.map +1 -0
  562. package/dist/src/drawer-container/index.d.ts +5 -0
  563. package/dist/src/drawer-container/index.d.ts.map +1 -0
  564. package/dist/src/drawer-container/styles/DrawerContainerStyle.d.ts +7 -0
  565. package/dist/src/drawer-container/styles/DrawerContainerStyle.d.ts.map +1 -0
  566. package/dist/src/drawer-container/styles/DrawerContainerToken.d.ts +16 -0
  567. package/dist/src/drawer-container/styles/DrawerContainerToken.d.ts.map +1 -0
  568. package/dist/src/drawer-container/styles/index.d.ts +2 -0
  569. package/dist/src/drawer-container/styles/index.d.ts.map +1 -0
  570. package/dist/src/expansion-panel/AccordionElement.d.ts +53 -0
  571. package/dist/src/expansion-panel/AccordionElement.d.ts.map +1 -0
  572. package/dist/src/expansion-panel/ExpansionHeaderElement.d.ts +62 -0
  573. package/dist/src/expansion-panel/ExpansionHeaderElement.d.ts.map +1 -0
  574. package/dist/src/expansion-panel/ExpansionPanelElement.d.ts +132 -0
  575. package/dist/src/expansion-panel/ExpansionPanelElement.d.ts.map +1 -0
  576. package/dist/src/expansion-panel/ExpansionToggleDirection.d.ts +3 -0
  577. package/dist/src/expansion-panel/ExpansionToggleDirection.d.ts.map +1 -0
  578. package/dist/src/expansion-panel/ExpansionTogglePosition.d.ts +3 -0
  579. package/dist/src/expansion-panel/ExpansionTogglePosition.d.ts.map +1 -0
  580. package/dist/src/expansion-panel/index.d.ts +6 -0
  581. package/dist/src/expansion-panel/index.d.ts.map +1 -0
  582. package/dist/src/expansion-panel/styles/ExpansionHeaderStyle.d.ts +6 -0
  583. package/dist/src/expansion-panel/styles/ExpansionHeaderStyle.d.ts.map +1 -0
  584. package/dist/src/expansion-panel/styles/ExpansionHeaderToken.d.ts +17 -0
  585. package/dist/src/expansion-panel/styles/ExpansionHeaderToken.d.ts.map +1 -0
  586. package/dist/src/expansion-panel/styles/ExpansionPanelStyle.d.ts +6 -0
  587. package/dist/src/expansion-panel/styles/ExpansionPanelStyle.d.ts.map +1 -0
  588. package/dist/src/expansion-panel/styles/ExpansionPanelToken.d.ts +21 -0
  589. package/dist/src/expansion-panel/styles/ExpansionPanelToken.d.ts.map +1 -0
  590. package/dist/src/expansion-panel/styles/index.d.ts +3 -0
  591. package/dist/src/expansion-panel/styles/index.d.ts.map +1 -0
  592. package/dist/src/fab/FabElement.d.ts +356 -0
  593. package/dist/src/fab/FabElement.d.ts.map +1 -0
  594. package/dist/src/fab/FabSize.d.ts +3 -0
  595. package/dist/src/fab/FabSize.d.ts.map +1 -0
  596. package/dist/src/fab/FabVariant.d.ts +3 -0
  597. package/dist/src/fab/FabVariant.d.ts.map +1 -0
  598. package/dist/src/fab/index.d.ts +4 -0
  599. package/dist/src/fab/index.d.ts.map +1 -0
  600. package/dist/src/fab/styles/FabSizeStyle.d.ts +7 -0
  601. package/dist/src/fab/styles/FabSizeStyle.d.ts.map +1 -0
  602. package/dist/src/fab/styles/FabSizeToken.d.ts +25 -0
  603. package/dist/src/fab/styles/FabSizeToken.d.ts.map +1 -0
  604. package/dist/src/fab/styles/FabStyle.d.ts +7 -0
  605. package/dist/src/fab/styles/FabStyle.d.ts.map +1 -0
  606. package/dist/src/fab/styles/FabVariantStyle.d.ts +7 -0
  607. package/dist/src/fab/styles/FabVariantStyle.d.ts.map +1 -0
  608. package/dist/src/fab/styles/FabVariantToken.d.ts +52 -0
  609. package/dist/src/fab/styles/FabVariantToken.d.ts.map +1 -0
  610. package/dist/src/fab/styles/index.d.ts +4 -0
  611. package/dist/src/fab/styles/index.d.ts.map +1 -0
  612. package/dist/src/fab-menu/FabMenuElement.d.ts +110 -0
  613. package/dist/src/fab-menu/FabMenuElement.d.ts.map +1 -0
  614. package/dist/src/fab-menu/FabMenuItemElement.d.ts +74 -0
  615. package/dist/src/fab-menu/FabMenuItemElement.d.ts.map +1 -0
  616. package/dist/src/fab-menu/FabMenuTriggerElement.d.ts +43 -0
  617. package/dist/src/fab-menu/FabMenuTriggerElement.d.ts.map +1 -0
  618. package/dist/src/fab-menu/FabMenuVariant.d.ts +3 -0
  619. package/dist/src/fab-menu/FabMenuVariant.d.ts.map +1 -0
  620. package/dist/src/fab-menu/index.d.ts +5 -0
  621. package/dist/src/fab-menu/index.d.ts.map +1 -0
  622. package/dist/src/form-field/FloatLabelType.d.ts +3 -0
  623. package/dist/src/form-field/FloatLabelType.d.ts.map +1 -0
  624. package/dist/src/form-field/FormFieldControl.d.ts +48 -0
  625. package/dist/src/form-field/FormFieldControl.d.ts.map +1 -0
  626. package/dist/src/form-field/FormFieldElement.d.ts +145 -0
  627. package/dist/src/form-field/FormFieldElement.d.ts.map +1 -0
  628. package/dist/src/form-field/FormFieldVariant.d.ts +3 -0
  629. package/dist/src/form-field/FormFieldVariant.d.ts.map +1 -0
  630. package/dist/src/form-field/HideSubscriptType.d.ts +3 -0
  631. package/dist/src/form-field/HideSubscriptType.d.ts.map +1 -0
  632. package/dist/src/form-field/index.d.ts +6 -0
  633. package/dist/src/form-field/index.d.ts.map +1 -0
  634. package/dist/src/heading/HeadingElement.d.ts +176 -0
  635. package/dist/src/heading/HeadingElement.d.ts.map +1 -0
  636. package/dist/src/heading/HeadingLevel.d.ts +3 -0
  637. package/dist/src/heading/HeadingLevel.d.ts.map +1 -0
  638. package/dist/src/heading/HeadingSize.d.ts +3 -0
  639. package/dist/src/heading/HeadingSize.d.ts.map +1 -0
  640. package/dist/src/heading/HeadingVariant.d.ts +3 -0
  641. package/dist/src/heading/HeadingVariant.d.ts.map +1 -0
  642. package/dist/src/heading/index.d.ts +5 -0
  643. package/dist/src/heading/index.d.ts.map +1 -0
  644. package/dist/src/icon/IconElement.d.ts +83 -0
  645. package/dist/src/icon/IconElement.d.ts.map +1 -0
  646. package/dist/src/icon/IconGrade.d.ts +3 -0
  647. package/dist/src/icon/IconGrade.d.ts.map +1 -0
  648. package/dist/src/icon/IconVariant.d.ts +3 -0
  649. package/dist/src/icon/IconVariant.d.ts.map +1 -0
  650. package/dist/src/icon/index.d.ts +4 -0
  651. package/dist/src/icon/index.d.ts.map +1 -0
  652. package/dist/src/icon-button/IconButtonElement.d.ts +316 -0
  653. package/dist/src/icon-button/IconButtonElement.d.ts.map +1 -0
  654. package/dist/src/icon-button/IconButtonShape.d.ts +3 -0
  655. package/dist/src/icon-button/IconButtonShape.d.ts.map +1 -0
  656. package/dist/src/icon-button/IconButtonSize.d.ts +3 -0
  657. package/dist/src/icon-button/IconButtonSize.d.ts.map +1 -0
  658. package/dist/src/icon-button/IconButtonVariant.d.ts +3 -0
  659. package/dist/src/icon-button/IconButtonVariant.d.ts.map +1 -0
  660. package/dist/src/icon-button/IconButtonWidth.d.ts +3 -0
  661. package/dist/src/icon-button/IconButtonWidth.d.ts.map +1 -0
  662. package/dist/src/icon-button/index.d.ts +6 -0
  663. package/dist/src/icon-button/index.d.ts.map +1 -0
  664. package/dist/src/icon-button/styles/IconButtonSizeStyle.d.ts +7 -0
  665. package/dist/src/icon-button/styles/IconButtonSizeStyle.d.ts.map +1 -0
  666. package/dist/src/icon-button/styles/IconButtonSizeToken.d.ts +26 -0
  667. package/dist/src/icon-button/styles/IconButtonSizeToken.d.ts.map +1 -0
  668. package/dist/src/icon-button/styles/IconButtonStyle.d.ts +7 -0
  669. package/dist/src/icon-button/styles/IconButtonStyle.d.ts.map +1 -0
  670. package/dist/src/icon-button/styles/IconButtonVariantStyle.d.ts +7 -0
  671. package/dist/src/icon-button/styles/IconButtonVariantStyle.d.ts.map +1 -0
  672. package/dist/src/icon-button/styles/IconButtonVariantToken.d.ts +61 -0
  673. package/dist/src/icon-button/styles/IconButtonVariantToken.d.ts.map +1 -0
  674. package/dist/src/icon-button/styles/index.d.ts +4 -0
  675. package/dist/src/icon-button/styles/index.d.ts.map +1 -0
  676. package/dist/src/index.d.ts +1 -0
  677. package/dist/src/index.d.ts.map +1 -0
  678. package/dist/src/list/ActionListElement.d.ts +46 -0
  679. package/dist/src/list/ActionListElement.d.ts.map +1 -0
  680. package/dist/src/list/ExpandableListItemElement.d.ts +152 -0
  681. package/dist/src/list/ExpandableListItemElement.d.ts.map +1 -0
  682. package/dist/src/list/ListActionElement.d.ts +111 -0
  683. package/dist/src/list/ListActionElement.d.ts.map +1 -0
  684. package/dist/src/list/ListElement.d.ts +89 -0
  685. package/dist/src/list/ListElement.d.ts.map +1 -0
  686. package/dist/src/list/ListItemButtonElement.d.ts +25 -0
  687. package/dist/src/list/ListItemButtonElement.d.ts.map +1 -0
  688. package/dist/src/list/ListItemContentType.d.ts +3 -0
  689. package/dist/src/list/ListItemContentType.d.ts.map +1 -0
  690. package/dist/src/list/ListItemElement.d.ts +112 -0
  691. package/dist/src/list/ListItemElement.d.ts.map +1 -0
  692. package/dist/src/list/ListOptionElement.d.ts +127 -0
  693. package/dist/src/list/ListOptionElement.d.ts.map +1 -0
  694. package/dist/src/list/ListVariant.d.ts +3 -0
  695. package/dist/src/list/ListVariant.d.ts.map +1 -0
  696. package/dist/src/list/SelectionListElement.d.ts +77 -0
  697. package/dist/src/list/SelectionListElement.d.ts.map +1 -0
  698. package/dist/src/list/index.d.ts +11 -0
  699. package/dist/src/list/index.d.ts.map +1 -0
  700. package/dist/src/loading-indicator/LoadingIndicatorElement.d.ts +56 -0
  701. package/dist/src/loading-indicator/LoadingIndicatorElement.d.ts.map +1 -0
  702. package/dist/src/loading-indicator/LoadingIndicatorToken.d.ts +9 -0
  703. package/dist/src/loading-indicator/LoadingIndicatorToken.d.ts.map +1 -0
  704. package/dist/src/loading-indicator/LoadingIndicatorVariant.d.ts +3 -0
  705. package/dist/src/loading-indicator/LoadingIndicatorVariant.d.ts.map +1 -0
  706. package/dist/src/loading-indicator/ShapePolygon.d.ts +7 -0
  707. package/dist/src/loading-indicator/ShapePolygon.d.ts.map +1 -0
  708. package/dist/src/loading-indicator/index.d.ts +3 -0
  709. package/dist/src/loading-indicator/index.d.ts.map +1 -0
  710. package/dist/src/menu/MenuElement.d.ts +156 -0
  711. package/dist/src/menu/MenuElement.d.ts.map +1 -0
  712. package/dist/src/menu/MenuItemCheckboxElement.d.ts +94 -0
  713. package/dist/src/menu/MenuItemCheckboxElement.d.ts.map +1 -0
  714. package/dist/src/menu/MenuItemElement.d.ts +130 -0
  715. package/dist/src/menu/MenuItemElement.d.ts.map +1 -0
  716. package/dist/src/menu/MenuItemElementBase.d.ts +21 -0
  717. package/dist/src/menu/MenuItemElementBase.d.ts.map +1 -0
  718. package/dist/src/menu/MenuItemGroupElement.d.ts +27 -0
  719. package/dist/src/menu/MenuItemGroupElement.d.ts.map +1 -0
  720. package/dist/src/menu/MenuItemRadioElement.d.ts +95 -0
  721. package/dist/src/menu/MenuItemRadioElement.d.ts.map +1 -0
  722. package/dist/src/menu/MenuPosition.d.ts +5 -0
  723. package/dist/src/menu/MenuPosition.d.ts.map +1 -0
  724. package/dist/src/menu/MenuTriggerElement.d.ts +78 -0
  725. package/dist/src/menu/MenuTriggerElement.d.ts.map +1 -0
  726. package/dist/src/menu/MenuVariant.d.ts +3 -0
  727. package/dist/src/menu/MenuVariant.d.ts.map +1 -0
  728. package/dist/src/menu/index.d.ts +9 -0
  729. package/dist/src/menu/index.d.ts.map +1 -0
  730. package/dist/src/nav-bar/NavBarElement.d.ts +73 -0
  731. package/dist/src/nav-bar/NavBarElement.d.ts.map +1 -0
  732. package/dist/src/nav-bar/NavBarMode.d.ts +3 -0
  733. package/dist/src/nav-bar/NavBarMode.d.ts.map +1 -0
  734. package/dist/src/nav-bar/NavItemElement.d.ts +105 -0
  735. package/dist/src/nav-bar/NavItemElement.d.ts.map +1 -0
  736. package/dist/src/nav-bar/NavItemOrientation.d.ts +3 -0
  737. package/dist/src/nav-bar/NavItemOrientation.d.ts.map +1 -0
  738. package/dist/src/nav-bar/index.d.ts +5 -0
  739. package/dist/src/nav-bar/index.d.ts.map +1 -0
  740. package/dist/src/nav-menu/NavMenuElement.d.ts +113 -0
  741. package/dist/src/nav-menu/NavMenuElement.d.ts.map +1 -0
  742. package/dist/src/nav-menu/NavMenuItemElement.d.ts +189 -0
  743. package/dist/src/nav-menu/NavMenuItemElement.d.ts.map +1 -0
  744. package/dist/src/nav-menu/NavMenuItemGroupElement.d.ts +63 -0
  745. package/dist/src/nav-menu/NavMenuItemGroupElement.d.ts.map +1 -0
  746. package/dist/src/nav-menu/index.d.ts +4 -0
  747. package/dist/src/nav-menu/index.d.ts.map +1 -0
  748. package/dist/src/nav-rail/NavRailElement.d.ts +69 -0
  749. package/dist/src/nav-rail/NavRailElement.d.ts.map +1 -0
  750. package/dist/src/nav-rail/NavRailToggleElement.d.ts +46 -0
  751. package/dist/src/nav-rail/NavRailToggleElement.d.ts.map +1 -0
  752. package/dist/src/nav-rail/index.d.ts +3 -0
  753. package/dist/src/nav-rail/index.d.ts.map +1 -0
  754. package/dist/src/option/OptGroupElement.d.ts +42 -0
  755. package/dist/src/option/OptGroupElement.d.ts.map +1 -0
  756. package/dist/src/option/OptionElement.d.ts +79 -0
  757. package/dist/src/option/OptionElement.d.ts.map +1 -0
  758. package/dist/src/option/OptionPanelElement.d.ts +82 -0
  759. package/dist/src/option/OptionPanelElement.d.ts.map +1 -0
  760. package/dist/src/option/index.d.ts +4 -0
  761. package/dist/src/option/index.d.ts.map +1 -0
  762. package/dist/src/paginator/PageEventDetail.d.ts +12 -0
  763. package/dist/src/paginator/PageEventDetail.d.ts.map +1 -0
  764. package/dist/src/paginator/PaginatorElement.d.ts +170 -0
  765. package/dist/src/paginator/PaginatorElement.d.ts.map +1 -0
  766. package/dist/src/paginator/index.d.ts +3 -0
  767. package/dist/src/paginator/index.d.ts.map +1 -0
  768. package/dist/src/progress-indicator/CircularProgressIndicatorElement.d.ts +65 -0
  769. package/dist/src/progress-indicator/CircularProgressIndicatorElement.d.ts.map +1 -0
  770. package/dist/src/progress-indicator/LinearProgressIndicatorElement.d.ts +70 -0
  771. package/dist/src/progress-indicator/LinearProgressIndicatorElement.d.ts.map +1 -0
  772. package/dist/src/progress-indicator/LinearProgressMode.d.ts +3 -0
  773. package/dist/src/progress-indicator/LinearProgressMode.d.ts.map +1 -0
  774. package/dist/src/progress-indicator/ProgressElementIndicatorBase.d.ts +29 -0
  775. package/dist/src/progress-indicator/ProgressElementIndicatorBase.d.ts.map +1 -0
  776. package/dist/src/progress-indicator/ProgressIndicatorVariant.d.ts +3 -0
  777. package/dist/src/progress-indicator/ProgressIndicatorVariant.d.ts.map +1 -0
  778. package/dist/src/progress-indicator/index.d.ts +6 -0
  779. package/dist/src/progress-indicator/index.d.ts.map +1 -0
  780. package/dist/src/radio-group/RadioElement.d.ts +88 -0
  781. package/dist/src/radio-group/RadioElement.d.ts.map +1 -0
  782. package/dist/src/radio-group/RadioGroupElement.d.ts +77 -0
  783. package/dist/src/radio-group/RadioGroupElement.d.ts.map +1 -0
  784. package/dist/src/radio-group/index.d.ts +3 -0
  785. package/dist/src/radio-group/index.d.ts.map +1 -0
  786. package/dist/src/segmented-button/ButtonSegmentElement.d.ts +105 -0
  787. package/dist/src/segmented-button/ButtonSegmentElement.d.ts.map +1 -0
  788. package/dist/src/segmented-button/SegmentedButtonElement.d.ts +90 -0
  789. package/dist/src/segmented-button/SegmentedButtonElement.d.ts.map +1 -0
  790. package/dist/src/segmented-button/index.d.ts +3 -0
  791. package/dist/src/segmented-button/index.d.ts.map +1 -0
  792. package/dist/src/select/SelectElement.d.ts +119 -0
  793. package/dist/src/select/SelectElement.d.ts.map +1 -0
  794. package/dist/src/select/index.d.ts +2 -0
  795. package/dist/src/select/index.d.ts.map +1 -0
  796. package/dist/src/shape/ShapeElement.d.ts +48 -0
  797. package/dist/src/shape/ShapeElement.d.ts.map +1 -0
  798. package/dist/src/shape/ShapeName.d.ts +3 -0
  799. package/dist/src/shape/ShapeName.d.ts.map +1 -0
  800. package/dist/src/shape/ShapeNameStyle.d.ts +7 -0
  801. package/dist/src/shape/ShapeNameStyle.d.ts.map +1 -0
  802. package/dist/src/shape/ShapePolygon.d.ts +8 -0
  803. package/dist/src/shape/ShapePolygon.d.ts.map +1 -0
  804. package/dist/src/shape/ShapeStyle.d.ts +7 -0
  805. package/dist/src/shape/ShapeStyle.d.ts.map +1 -0
  806. package/dist/src/shape/ShapeToken.d.ts +13 -0
  807. package/dist/src/shape/ShapeToken.d.ts.map +1 -0
  808. package/dist/src/shape/index.d.ts +3 -0
  809. package/dist/src/shape/index.d.ts.map +1 -0
  810. package/dist/src/slide-group/SlideGroupElement.d.ts +91 -0
  811. package/dist/src/slide-group/SlideGroupElement.d.ts.map +1 -0
  812. package/dist/src/slide-group/index.d.ts +2 -0
  813. package/dist/src/slide-group/index.d.ts.map +1 -0
  814. package/dist/src/slider/SliderElement.d.ts +144 -0
  815. package/dist/src/slider/SliderElement.d.ts.map +1 -0
  816. package/dist/src/slider/SliderSize.d.ts +3 -0
  817. package/dist/src/slider/SliderSize.d.ts.map +1 -0
  818. package/dist/src/slider/SliderThumbElement.d.ts +80 -0
  819. package/dist/src/slider/SliderThumbElement.d.ts.map +1 -0
  820. package/dist/src/slider/index.d.ts +4 -0
  821. package/dist/src/slider/index.d.ts.map +1 -0
  822. package/dist/src/snackbar/Snackbar.d.ts +62 -0
  823. package/dist/src/snackbar/Snackbar.d.ts.map +1 -0
  824. package/dist/src/snackbar/SnackbarElement.d.ts +79 -0
  825. package/dist/src/snackbar/SnackbarElement.d.ts.map +1 -0
  826. package/dist/src/snackbar/index.d.ts +3 -0
  827. package/dist/src/snackbar/index.d.ts.map +1 -0
  828. package/dist/src/split-button/SplitButtonElement.d.ts +106 -0
  829. package/dist/src/split-button/SplitButtonElement.d.ts.map +1 -0
  830. package/dist/src/split-button/SplitButtonVariant.d.ts +3 -0
  831. package/dist/src/split-button/SplitButtonVariant.d.ts.map +1 -0
  832. package/dist/src/split-button/index.d.ts +3 -0
  833. package/dist/src/split-button/index.d.ts.map +1 -0
  834. package/dist/src/stepper/StepElement.d.ts +161 -0
  835. package/dist/src/stepper/StepElement.d.ts.map +1 -0
  836. package/dist/src/stepper/StepHeaderPosition.d.ts +3 -0
  837. package/dist/src/stepper/StepHeaderPosition.d.ts.map +1 -0
  838. package/dist/src/stepper/StepLabelPosition.d.ts +3 -0
  839. package/dist/src/stepper/StepLabelPosition.d.ts.map +1 -0
  840. package/dist/src/stepper/StepPanelElement.d.ts +76 -0
  841. package/dist/src/stepper/StepPanelElement.d.ts.map +1 -0
  842. package/dist/src/stepper/StepperButtonElementBase.d.ts +9 -0
  843. package/dist/src/stepper/StepperButtonElementBase.d.ts.map +1 -0
  844. package/dist/src/stepper/StepperElement.d.ts +139 -0
  845. package/dist/src/stepper/StepperElement.d.ts.map +1 -0
  846. package/dist/src/stepper/StepperNextElement.d.ts +16 -0
  847. package/dist/src/stepper/StepperNextElement.d.ts.map +1 -0
  848. package/dist/src/stepper/StepperOrientation.d.ts +3 -0
  849. package/dist/src/stepper/StepperOrientation.d.ts.map +1 -0
  850. package/dist/src/stepper/StepperPreviousElement.d.ts +16 -0
  851. package/dist/src/stepper/StepperPreviousElement.d.ts.map +1 -0
  852. package/dist/src/stepper/StepperResetElement.d.ts +16 -0
  853. package/dist/src/stepper/StepperResetElement.d.ts.map +1 -0
  854. package/dist/src/stepper/index.d.ts +11 -0
  855. package/dist/src/stepper/index.d.ts.map +1 -0
  856. package/dist/src/switch/SwitchElement.d.ts +147 -0
  857. package/dist/src/switch/SwitchElement.d.ts.map +1 -0
  858. package/dist/src/switch/SwitchIcons.d.ts +3 -0
  859. package/dist/src/switch/SwitchIcons.d.ts.map +1 -0
  860. package/dist/src/switch/index.d.ts +3 -0
  861. package/dist/src/switch/index.d.ts.map +1 -0
  862. package/dist/src/switch/styles/SwitchHandleStyle.d.ts +6 -0
  863. package/dist/src/switch/styles/SwitchHandleStyle.d.ts.map +1 -0
  864. package/dist/src/switch/styles/SwitchIconStyle.d.ts +6 -0
  865. package/dist/src/switch/styles/SwitchIconStyle.d.ts.map +1 -0
  866. package/dist/src/switch/styles/SwitchStateLayerStyle.d.ts +6 -0
  867. package/dist/src/switch/styles/SwitchStateLayerStyle.d.ts.map +1 -0
  868. package/dist/src/switch/styles/SwitchStyle.d.ts +6 -0
  869. package/dist/src/switch/styles/SwitchStyle.d.ts.map +1 -0
  870. package/dist/src/switch/styles/SwitchToken.d.ts +76 -0
  871. package/dist/src/switch/styles/SwitchToken.d.ts.map +1 -0
  872. package/dist/src/switch/styles/SwitchTrackStyle.d.ts +6 -0
  873. package/dist/src/switch/styles/SwitchTrackStyle.d.ts.map +1 -0
  874. package/dist/src/switch/styles/index.d.ts +6 -0
  875. package/dist/src/switch/styles/index.d.ts.map +1 -0
  876. package/dist/src/tabs/TabElement.d.ts +90 -0
  877. package/dist/src/tabs/TabElement.d.ts.map +1 -0
  878. package/dist/src/tabs/TabHeaderPosition.d.ts +3 -0
  879. package/dist/src/tabs/TabHeaderPosition.d.ts.map +1 -0
  880. package/dist/src/tabs/TabPanelElement.d.ts +45 -0
  881. package/dist/src/tabs/TabPanelElement.d.ts.map +1 -0
  882. package/dist/src/tabs/TabVariant.d.ts +3 -0
  883. package/dist/src/tabs/TabVariant.d.ts.map +1 -0
  884. package/dist/src/tabs/TabsElement.d.ts +118 -0
  885. package/dist/src/tabs/TabsElement.d.ts.map +1 -0
  886. package/dist/src/tabs/index.d.ts +6 -0
  887. package/dist/src/tabs/index.d.ts.map +1 -0
  888. package/dist/src/textarea-autosize/TextareaAutosizeElement.d.ts +81 -0
  889. package/dist/src/textarea-autosize/TextareaAutosizeElement.d.ts.map +1 -0
  890. package/dist/src/textarea-autosize/index.d.ts +2 -0
  891. package/dist/src/textarea-autosize/index.d.ts.map +1 -0
  892. package/dist/src/theme/ColorScheme.d.ts +3 -0
  893. package/dist/src/theme/ColorScheme.d.ts.map +1 -0
  894. package/dist/src/theme/ContrastLevel.d.ts +3 -0
  895. package/dist/src/theme/ContrastLevel.d.ts.map +1 -0
  896. package/dist/src/theme/MotionScheme.d.ts +3 -0
  897. package/dist/src/theme/MotionScheme.d.ts.map +1 -0
  898. package/dist/src/theme/ThemeElement.d.ts +91 -0
  899. package/dist/src/theme/ThemeElement.d.ts.map +1 -0
  900. package/dist/src/theme/index.d.ts +5 -0
  901. package/dist/src/theme/index.d.ts.map +1 -0
  902. package/dist/src/toc/TocElement.d.ts +86 -0
  903. package/dist/src/toc/TocElement.d.ts.map +1 -0
  904. package/dist/src/toc/TocGenerator.d.ts +25 -0
  905. package/dist/src/toc/TocGenerator.d.ts.map +1 -0
  906. package/dist/src/toc/TocItemElement.d.ts +49 -0
  907. package/dist/src/toc/TocItemElement.d.ts.map +1 -0
  908. package/dist/src/toc/index.d.ts +4 -0
  909. package/dist/src/toc/index.d.ts.map +1 -0
  910. package/dist/src/toolbar/ToolbarElement.d.ts +89 -0
  911. package/dist/src/toolbar/ToolbarElement.d.ts.map +1 -0
  912. package/dist/src/toolbar/ToolbarShape.d.ts +3 -0
  913. package/dist/src/toolbar/ToolbarShape.d.ts.map +1 -0
  914. package/dist/src/toolbar/ToolbarVariant.d.ts +3 -0
  915. package/dist/src/toolbar/ToolbarVariant.d.ts.map +1 -0
  916. package/dist/src/toolbar/index.d.ts +4 -0
  917. package/dist/src/toolbar/index.d.ts.map +1 -0
  918. package/dist/src/tooltip/RichTooltipActionElement.d.ts +21 -0
  919. package/dist/src/tooltip/RichTooltipActionElement.d.ts.map +1 -0
  920. package/dist/src/tooltip/RichTooltipElement.d.ts +116 -0
  921. package/dist/src/tooltip/RichTooltipElement.d.ts.map +1 -0
  922. package/dist/src/tooltip/RichTooltipPosition.d.ts +3 -0
  923. package/dist/src/tooltip/RichTooltipPosition.d.ts.map +1 -0
  924. package/dist/src/tooltip/TooltipElement.d.ts +73 -0
  925. package/dist/src/tooltip/TooltipElement.d.ts.map +1 -0
  926. package/dist/src/tooltip/TooltipElementBase.d.ts +69 -0
  927. package/dist/src/tooltip/TooltipElementBase.d.ts.map +1 -0
  928. package/dist/src/tooltip/TooltipPosition.d.ts +3 -0
  929. package/dist/src/tooltip/TooltipPosition.d.ts.map +1 -0
  930. package/dist/src/tooltip/TooltipTouchGestures.d.ts +3 -0
  931. package/dist/src/tooltip/TooltipTouchGestures.d.ts.map +1 -0
  932. package/dist/src/tooltip/index.d.ts +8 -0
  933. package/dist/src/tooltip/index.d.ts.map +1 -0
  934. package/dist/stepper.js +1498 -0
  935. package/dist/stepper.js.map +1 -0
  936. package/dist/stepper.min.js +57 -0
  937. package/dist/stepper.min.js.map +1 -0
  938. package/dist/switch.js +758 -0
  939. package/dist/switch.js.map +1 -0
  940. package/dist/switch.min.js +40 -0
  941. package/dist/switch.min.js.map +1 -0
  942. package/dist/tabs.js +1173 -0
  943. package/dist/tabs.js.map +1 -0
  944. package/dist/tabs.min.js +51 -0
  945. package/dist/tabs.min.js.map +1 -0
  946. package/dist/textarea-autosize.js +688 -0
  947. package/dist/textarea-autosize.js.map +1 -0
  948. package/dist/textarea-autosize.min.js +37 -0
  949. package/dist/textarea-autosize.min.js.map +1 -0
  950. package/dist/theme.js +3712 -0
  951. package/dist/theme.js.map +1 -0
  952. package/dist/theme.min.js +339 -0
  953. package/dist/theme.min.js.map +1 -0
  954. package/dist/toc.js +795 -0
  955. package/dist/toc.js.map +1 -0
  956. package/dist/toc.min.js +45 -0
  957. package/dist/toc.min.js.map +1 -0
  958. package/dist/toolbar.js +557 -0
  959. package/dist/toolbar.js.map +1 -0
  960. package/dist/toolbar.min.js +29 -0
  961. package/dist/toolbar.min.js.map +1 -0
  962. package/dist/tooltip.js +1378 -0
  963. package/dist/tooltip.js.map +1 -0
  964. package/dist/tooltip.min.js +57 -0
  965. package/dist/tooltip.min.js.map +1 -0
  966. package/package.json +287 -0
package/dist/theme.js ADDED
@@ -0,0 +1,3712 @@
1
+ /**
2
+ * @license MIT
3
+ * Copyright (c) 2025 matraic
4
+ * See LICENSE file in the project root for full license text.
5
+ */
6
+ import { css, LitElement, html } from 'lit';
7
+ import { DesignToken } from '@m3e/web/core';
8
+
9
+ /******************************************************************************
10
+ Copyright (c) Microsoft Corporation.
11
+
12
+ Permission to use, copy, modify, and/or distribute this software for any
13
+ purpose with or without fee is hereby granted.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
+ PERFORMANCE OF THIS SOFTWARE.
22
+ ***************************************************************************** */
23
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
24
+
25
+ function __decorate(decorators, target, key, desc) {
26
+ var c = arguments.length,
27
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
28
+ d;
29
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
31
+ }
32
+ function __classPrivateFieldGet(receiver, state, kind, f) {
33
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
34
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
35
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
36
+ }
37
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
38
+ if (kind === "m") throw new TypeError("Private method is not writable");
39
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
40
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
41
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
42
+ }
43
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
44
+ var e = new Error(message);
45
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
46
+ };
47
+
48
+ /**
49
+ * @license
50
+ * Copyright 2017 Google LLC
51
+ * SPDX-License-Identifier: BSD-3-Clause
52
+ */
53
+ const t$1 = t => (e, o) => {
54
+ void 0 !== o ? o.addInitializer(() => {
55
+ customElements.define(t, e);
56
+ }) : customElements.define(t, e);
57
+ };
58
+
59
+ /**
60
+ * @license
61
+ * Copyright 2019 Google LLC
62
+ * SPDX-License-Identifier: BSD-3-Clause
63
+ */
64
+ const t = globalThis,
65
+ e$1 = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype,
66
+ s = Symbol(),
67
+ o$2 = new WeakMap();
68
+ let n$2 = class n {
69
+ constructor(t, e, o) {
70
+ if (this._$cssResult$ = true, o !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
71
+ this.cssText = t, this.t = e;
72
+ }
73
+ get styleSheet() {
74
+ let t = this.o;
75
+ const s = this.t;
76
+ if (e$1 && void 0 === t) {
77
+ const e = void 0 !== s && 1 === s.length;
78
+ e && (t = o$2.get(s)), void 0 === t && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), e && o$2.set(s, t));
79
+ }
80
+ return t;
81
+ }
82
+ toString() {
83
+ return this.cssText;
84
+ }
85
+ };
86
+ const r$2 = t => new n$2("string" == typeof t ? t : t + "", void 0, s),
87
+ S = (s, o) => {
88
+ if (e$1) s.adoptedStyleSheets = o.map(t => t instanceof CSSStyleSheet ? t : t.styleSheet);else for (const e of o) {
89
+ const o = document.createElement("style"),
90
+ n = t.litNonce;
91
+ void 0 !== n && o.setAttribute("nonce", n), o.textContent = e.cssText, s.appendChild(o);
92
+ }
93
+ },
94
+ c$1 = e$1 ? t => t : t => t instanceof CSSStyleSheet ? (t => {
95
+ let e = "";
96
+ for (const s of t.cssRules) e += s.cssText;
97
+ return r$2(e);
98
+ })(t) : t;
99
+
100
+ /**
101
+ * @license
102
+ * Copyright 2017 Google LLC
103
+ * SPDX-License-Identifier: BSD-3-Clause
104
+ */
105
+ const {
106
+ is: i,
107
+ defineProperty: e,
108
+ getOwnPropertyDescriptor: h,
109
+ getOwnPropertyNames: r$1,
110
+ getOwnPropertySymbols: o$1,
111
+ getPrototypeOf: n$1
112
+ } = Object,
113
+ a = globalThis,
114
+ c = a.trustedTypes,
115
+ l = c ? c.emptyScript : "",
116
+ p = a.reactiveElementPolyfillSupport,
117
+ d = (t, s) => t,
118
+ u = {
119
+ toAttribute(t, s) {
120
+ switch (s) {
121
+ case Boolean:
122
+ t = t ? l : null;
123
+ break;
124
+ case Object:
125
+ case Array:
126
+ t = null == t ? t : JSON.stringify(t);
127
+ }
128
+ return t;
129
+ },
130
+ fromAttribute(t, s) {
131
+ let i = t;
132
+ switch (s) {
133
+ case Boolean:
134
+ i = null !== t;
135
+ break;
136
+ case Number:
137
+ i = null === t ? null : Number(t);
138
+ break;
139
+ case Object:
140
+ case Array:
141
+ try {
142
+ i = JSON.parse(t);
143
+ } catch (t) {
144
+ i = null;
145
+ }
146
+ }
147
+ return i;
148
+ }
149
+ },
150
+ f = (t, s) => !i(t, s),
151
+ b = {
152
+ attribute: true,
153
+ type: String,
154
+ converter: u,
155
+ reflect: false,
156
+ useDefault: false,
157
+ hasChanged: f
158
+ };
159
+ Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= new WeakMap();
160
+ class y extends HTMLElement {
161
+ static addInitializer(t) {
162
+ this._$Ei(), (this.l ??= []).push(t);
163
+ }
164
+ static get observedAttributes() {
165
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
166
+ }
167
+ static createProperty(t, s = b) {
168
+ if (s.state && (s.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t) && ((s = Object.create(s)).wrapped = true), this.elementProperties.set(t, s), !s.noAccessor) {
169
+ const i = Symbol(),
170
+ h = this.getPropertyDescriptor(t, i, s);
171
+ void 0 !== h && e(this.prototype, t, h);
172
+ }
173
+ }
174
+ static getPropertyDescriptor(t, s, i) {
175
+ const {
176
+ get: e,
177
+ set: r
178
+ } = h(this.prototype, t) ?? {
179
+ get() {
180
+ return this[s];
181
+ },
182
+ set(t) {
183
+ this[s] = t;
184
+ }
185
+ };
186
+ return {
187
+ get: e,
188
+ set(s) {
189
+ const h = e?.call(this);
190
+ r?.call(this, s), this.requestUpdate(t, h, i);
191
+ },
192
+ configurable: true,
193
+ enumerable: true
194
+ };
195
+ }
196
+ static getPropertyOptions(t) {
197
+ return this.elementProperties.get(t) ?? b;
198
+ }
199
+ static _$Ei() {
200
+ if (this.hasOwnProperty(d("elementProperties"))) return;
201
+ const t = n$1(this);
202
+ t.finalize(), void 0 !== t.l && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
203
+ }
204
+ static finalize() {
205
+ if (this.hasOwnProperty(d("finalized"))) return;
206
+ if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d("properties"))) {
207
+ const t = this.properties,
208
+ s = [...r$1(t), ...o$1(t)];
209
+ for (const i of s) this.createProperty(i, t[i]);
210
+ }
211
+ const t = this[Symbol.metadata];
212
+ if (null !== t) {
213
+ const s = litPropertyMetadata.get(t);
214
+ if (void 0 !== s) for (const [t, i] of s) this.elementProperties.set(t, i);
215
+ }
216
+ this._$Eh = new Map();
217
+ for (const [t, s] of this.elementProperties) {
218
+ const i = this._$Eu(t, s);
219
+ void 0 !== i && this._$Eh.set(i, t);
220
+ }
221
+ this.elementStyles = this.finalizeStyles(this.styles);
222
+ }
223
+ static finalizeStyles(s) {
224
+ const i = [];
225
+ if (Array.isArray(s)) {
226
+ const e = new Set(s.flat(1 / 0).reverse());
227
+ for (const s of e) i.unshift(c$1(s));
228
+ } else void 0 !== s && i.push(c$1(s));
229
+ return i;
230
+ }
231
+ static _$Eu(t, s) {
232
+ const i = s.attribute;
233
+ return false === i ? void 0 : "string" == typeof i ? i : "string" == typeof t ? t.toLowerCase() : void 0;
234
+ }
235
+ constructor() {
236
+ super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
237
+ }
238
+ _$Ev() {
239
+ this._$ES = new Promise(t => this.enableUpdating = t), this._$AL = new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(t => t(this));
240
+ }
241
+ addController(t) {
242
+ (this._$EO ??= new Set()).add(t), void 0 !== this.renderRoot && this.isConnected && t.hostConnected?.();
243
+ }
244
+ removeController(t) {
245
+ this._$EO?.delete(t);
246
+ }
247
+ _$E_() {
248
+ const t = new Map(),
249
+ s = this.constructor.elementProperties;
250
+ for (const i of s.keys()) this.hasOwnProperty(i) && (t.set(i, this[i]), delete this[i]);
251
+ t.size > 0 && (this._$Ep = t);
252
+ }
253
+ createRenderRoot() {
254
+ const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
255
+ return S(t, this.constructor.elementStyles), t;
256
+ }
257
+ connectedCallback() {
258
+ this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach(t => t.hostConnected?.());
259
+ }
260
+ enableUpdating(t) {}
261
+ disconnectedCallback() {
262
+ this._$EO?.forEach(t => t.hostDisconnected?.());
263
+ }
264
+ attributeChangedCallback(t, s, i) {
265
+ this._$AK(t, i);
266
+ }
267
+ _$ET(t, s) {
268
+ const i = this.constructor.elementProperties.get(t),
269
+ e = this.constructor._$Eu(t, i);
270
+ if (void 0 !== e && true === i.reflect) {
271
+ const h = (void 0 !== i.converter?.toAttribute ? i.converter : u).toAttribute(s, i.type);
272
+ this._$Em = t, null == h ? this.removeAttribute(e) : this.setAttribute(e, h), this._$Em = null;
273
+ }
274
+ }
275
+ _$AK(t, s) {
276
+ const i = this.constructor,
277
+ e = i._$Eh.get(t);
278
+ if (void 0 !== e && this._$Em !== e) {
279
+ const t = i.getPropertyOptions(e),
280
+ h = "function" == typeof t.converter ? {
281
+ fromAttribute: t.converter
282
+ } : void 0 !== t.converter?.fromAttribute ? t.converter : u;
283
+ this._$Em = e;
284
+ const r = h.fromAttribute(s, t.type);
285
+ this[e] = r ?? this._$Ej?.get(e) ?? r, this._$Em = null;
286
+ }
287
+ }
288
+ requestUpdate(t, s, i) {
289
+ if (void 0 !== t) {
290
+ const e = this.constructor,
291
+ h = this[t];
292
+ if (i ??= e.getPropertyOptions(t), !((i.hasChanged ?? f)(h, s) || i.useDefault && i.reflect && h === this._$Ej?.get(t) && !this.hasAttribute(e._$Eu(t, i)))) return;
293
+ this.C(t, s, i);
294
+ }
295
+ false === this.isUpdatePending && (this._$ES = this._$EP());
296
+ }
297
+ C(t, s, {
298
+ useDefault: i,
299
+ reflect: e,
300
+ wrapped: h
301
+ }, r) {
302
+ i && !(this._$Ej ??= new Map()).has(t) && (this._$Ej.set(t, r ?? s ?? this[t]), true !== h || void 0 !== r) || (this._$AL.has(t) || (this.hasUpdated || i || (s = void 0), this._$AL.set(t, s)), true === e && this._$Em !== t && (this._$Eq ??= new Set()).add(t));
303
+ }
304
+ async _$EP() {
305
+ this.isUpdatePending = true;
306
+ try {
307
+ await this._$ES;
308
+ } catch (t) {
309
+ Promise.reject(t);
310
+ }
311
+ const t = this.scheduleUpdate();
312
+ return null != t && (await t), !this.isUpdatePending;
313
+ }
314
+ scheduleUpdate() {
315
+ return this.performUpdate();
316
+ }
317
+ performUpdate() {
318
+ if (!this.isUpdatePending) return;
319
+ if (!this.hasUpdated) {
320
+ if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
321
+ for (const [t, s] of this._$Ep) this[t] = s;
322
+ this._$Ep = void 0;
323
+ }
324
+ const t = this.constructor.elementProperties;
325
+ if (t.size > 0) for (const [s, i] of t) {
326
+ const {
327
+ wrapped: t
328
+ } = i,
329
+ e = this[s];
330
+ true !== t || this._$AL.has(s) || void 0 === e || this.C(s, void 0, i, e);
331
+ }
332
+ }
333
+ let t = false;
334
+ const s = this._$AL;
335
+ try {
336
+ t = this.shouldUpdate(s), t ? (this.willUpdate(s), this._$EO?.forEach(t => t.hostUpdate?.()), this.update(s)) : this._$EM();
337
+ } catch (s) {
338
+ throw t = false, this._$EM(), s;
339
+ }
340
+ t && this._$AE(s);
341
+ }
342
+ willUpdate(t) {}
343
+ _$AE(t) {
344
+ this._$EO?.forEach(t => t.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t)), this.updated(t);
345
+ }
346
+ _$EM() {
347
+ this._$AL = new Map(), this.isUpdatePending = false;
348
+ }
349
+ get updateComplete() {
350
+ return this.getUpdateComplete();
351
+ }
352
+ getUpdateComplete() {
353
+ return this._$ES;
354
+ }
355
+ shouldUpdate(t) {
356
+ return true;
357
+ }
358
+ update(t) {
359
+ this._$Eq &&= this._$Eq.forEach(t => this._$ET(t, this[t])), this._$EM();
360
+ }
361
+ updated(t) {}
362
+ firstUpdated(t) {}
363
+ }
364
+ y.elementStyles = [], y.shadowRootOptions = {
365
+ mode: "open"
366
+ }, y[d("elementProperties")] = new Map(), y[d("finalized")] = new Map(), p?.({
367
+ ReactiveElement: y
368
+ }), (a.reactiveElementVersions ??= []).push("2.1.1");
369
+
370
+ /**
371
+ * @license
372
+ * Copyright 2017 Google LLC
373
+ * SPDX-License-Identifier: BSD-3-Clause
374
+ */
375
+ const o = {
376
+ attribute: true,
377
+ type: String,
378
+ converter: u,
379
+ reflect: false,
380
+ hasChanged: f
381
+ },
382
+ r = (t = o, e, r) => {
383
+ const {
384
+ kind: n,
385
+ metadata: i
386
+ } = r;
387
+ let s = globalThis.litPropertyMetadata.get(i);
388
+ if (void 0 === s && globalThis.litPropertyMetadata.set(i, s = new Map()), "setter" === n && ((t = Object.create(t)).wrapped = true), s.set(r.name, t), "accessor" === n) {
389
+ const {
390
+ name: o
391
+ } = r;
392
+ return {
393
+ set(r) {
394
+ const n = e.get.call(this);
395
+ e.set.call(this, r), this.requestUpdate(o, n, t);
396
+ },
397
+ init(e) {
398
+ return void 0 !== e && this.C(o, void 0, t, e), e;
399
+ }
400
+ };
401
+ }
402
+ if ("setter" === n) {
403
+ const {
404
+ name: o
405
+ } = r;
406
+ return function (r) {
407
+ const n = this[o];
408
+ e.call(this, r), this.requestUpdate(o, n, t);
409
+ };
410
+ }
411
+ throw Error("Unsupported decorator location: " + n);
412
+ };
413
+ function n(t) {
414
+ return (e, o) => "object" == typeof o ? r(t, e, o) : ((t, e, o) => {
415
+ const r = e.hasOwnProperty(o);
416
+ return e.constructor.createProperty(o, t), r ? Object.getOwnPropertyDescriptor(e, o) : void 0;
417
+ })(t, e, o);
418
+ }
419
+
420
+ /**
421
+ * @license
422
+ * Copyright 2021 Google LLC
423
+ *
424
+ * Licensed under the Apache License, Version 2.0 (the "License");
425
+ * you may not use this file except in compliance with the License.
426
+ * You may obtain a copy of the License at
427
+ *
428
+ * http://www.apache.org/licenses/LICENSE-2.0
429
+ *
430
+ * Unless required by applicable law or agreed to in writing, software
431
+ * distributed under the License is distributed on an "AS IS" BASIS,
432
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
433
+ * See the License for the specific language governing permissions and
434
+ * limitations under the License.
435
+ */
436
+ // This file is automatically generated. Do not modify it.
437
+ /**
438
+ * Utility methods for mathematical operations.
439
+ */
440
+ /**
441
+ * The signum function.
442
+ *
443
+ * @return 1 if num > 0, -1 if num < 0, and 0 if num = 0
444
+ */
445
+ function signum(num) {
446
+ if (num < 0) {
447
+ return -1;
448
+ } else if (num === 0) {
449
+ return 0;
450
+ } else {
451
+ return 1;
452
+ }
453
+ }
454
+ /**
455
+ * The linear interpolation function.
456
+ *
457
+ * @return start if amount = 0 and stop if amount = 1
458
+ */
459
+ function lerp(start, stop, amount) {
460
+ return (1.0 - amount) * start + amount * stop;
461
+ }
462
+ /**
463
+ * Clamps an integer between two integers.
464
+ *
465
+ * @return input when min <= input <= max, and either min or max
466
+ * otherwise.
467
+ */
468
+ function clampInt(min, max, input) {
469
+ if (input < min) {
470
+ return min;
471
+ } else if (input > max) {
472
+ return max;
473
+ }
474
+ return input;
475
+ }
476
+ /**
477
+ * Clamps an integer between two floating-point numbers.
478
+ *
479
+ * @return input when min <= input <= max, and either min or max
480
+ * otherwise.
481
+ */
482
+ function clampDouble(min, max, input) {
483
+ if (input < min) {
484
+ return min;
485
+ } else if (input > max) {
486
+ return max;
487
+ }
488
+ return input;
489
+ }
490
+ /**
491
+ * Sanitizes a degree measure as a floating-point number.
492
+ *
493
+ * @return a degree measure between 0.0 (inclusive) and 360.0
494
+ * (exclusive).
495
+ */
496
+ function sanitizeDegreesDouble(degrees) {
497
+ degrees = degrees % 360.0;
498
+ if (degrees < 0) {
499
+ degrees = degrees + 360.0;
500
+ }
501
+ return degrees;
502
+ }
503
+ /**
504
+ * Multiplies a 1x3 row vector with a 3x3 matrix.
505
+ */
506
+ function matrixMultiply(row, matrix) {
507
+ const a = row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2];
508
+ const b = row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2];
509
+ const c = row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];
510
+ return [a, b, c];
511
+ }
512
+
513
+ /**
514
+ * @license
515
+ * Copyright 2021 Google LLC
516
+ *
517
+ * Licensed under the Apache License, Version 2.0 (the "License");
518
+ * you may not use this file except in compliance with the License.
519
+ * You may obtain a copy of the License at
520
+ *
521
+ * http://www.apache.org/licenses/LICENSE-2.0
522
+ *
523
+ * Unless required by applicable law or agreed to in writing, software
524
+ * distributed under the License is distributed on an "AS IS" BASIS,
525
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
526
+ * See the License for the specific language governing permissions and
527
+ * limitations under the License.
528
+ */
529
+ // This file is automatically generated. Do not modify it.
530
+ /**
531
+ * Color science utilities.
532
+ *
533
+ * Utility methods for color science constants and color space
534
+ * conversions that aren't HCT or CAM16.
535
+ */
536
+ const SRGB_TO_XYZ = [[0.41233895, 0.35762064, 0.18051042], [0.2126, 0.7152, 0.0722], [0.01932141, 0.11916382, 0.95034478]];
537
+ const XYZ_TO_SRGB = [[3.2413774792388685, -1.5376652402851851, -0.49885366846268053], [-0.9691452513005321, 1.8758853451067872, 0.04156585616912061], [0.05562093689691305, -0.20395524564742123, 1.0571799111220335]];
538
+ const WHITE_POINT_D65 = [95.047, 100.0, 108.883];
539
+ /**
540
+ * Converts a color from RGB components to ARGB format.
541
+ */
542
+ function argbFromRgb(red, green, blue) {
543
+ return (255 << 24 | (red & 255) << 16 | (green & 255) << 8 | blue & 255) >>> 0;
544
+ }
545
+ /**
546
+ * Converts a color from linear RGB components to ARGB format.
547
+ */
548
+ function argbFromLinrgb(linrgb) {
549
+ const r = delinearized(linrgb[0]);
550
+ const g = delinearized(linrgb[1]);
551
+ const b = delinearized(linrgb[2]);
552
+ return argbFromRgb(r, g, b);
553
+ }
554
+ /**
555
+ * Returns the red component of a color in ARGB format.
556
+ */
557
+ function redFromArgb(argb) {
558
+ return argb >> 16 & 255;
559
+ }
560
+ /**
561
+ * Returns the green component of a color in ARGB format.
562
+ */
563
+ function greenFromArgb(argb) {
564
+ return argb >> 8 & 255;
565
+ }
566
+ /**
567
+ * Returns the blue component of a color in ARGB format.
568
+ */
569
+ function blueFromArgb(argb) {
570
+ return argb & 255;
571
+ }
572
+ /**
573
+ * Converts a color from ARGB to XYZ.
574
+ */
575
+ function argbFromXyz(x, y, z) {
576
+ const matrix = XYZ_TO_SRGB;
577
+ const linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z;
578
+ const linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z;
579
+ const linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z;
580
+ const r = delinearized(linearR);
581
+ const g = delinearized(linearG);
582
+ const b = delinearized(linearB);
583
+ return argbFromRgb(r, g, b);
584
+ }
585
+ /**
586
+ * Converts a color from XYZ to ARGB.
587
+ */
588
+ function xyzFromArgb(argb) {
589
+ const r = linearized(redFromArgb(argb));
590
+ const g = linearized(greenFromArgb(argb));
591
+ const b = linearized(blueFromArgb(argb));
592
+ return matrixMultiply([r, g, b], SRGB_TO_XYZ);
593
+ }
594
+ /**
595
+ * Converts an L* value to an ARGB representation.
596
+ *
597
+ * @param lstar L* in L*a*b*
598
+ * @return ARGB representation of grayscale color with lightness
599
+ * matching L*
600
+ */
601
+ function argbFromLstar(lstar) {
602
+ const y = yFromLstar(lstar);
603
+ const component = delinearized(y);
604
+ return argbFromRgb(component, component, component);
605
+ }
606
+ /**
607
+ * Computes the L* value of a color in ARGB representation.
608
+ *
609
+ * @param argb ARGB representation of a color
610
+ * @return L*, from L*a*b*, coordinate of the color
611
+ */
612
+ function lstarFromArgb(argb) {
613
+ const y = xyzFromArgb(argb)[1];
614
+ return 116.0 * labF(y / 100.0) - 16.0;
615
+ }
616
+ /**
617
+ * Converts an L* value to a Y value.
618
+ *
619
+ * L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
620
+ *
621
+ * L* measures perceptual luminance, a linear scale. Y in XYZ
622
+ * measures relative luminance, a logarithmic scale.
623
+ *
624
+ * @param lstar L* in L*a*b*
625
+ * @return Y in XYZ
626
+ */
627
+ function yFromLstar(lstar) {
628
+ return 100.0 * labInvf((lstar + 16.0) / 116.0);
629
+ }
630
+ /**
631
+ * Converts a Y value to an L* value.
632
+ *
633
+ * L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
634
+ *
635
+ * L* measures perceptual luminance, a linear scale. Y in XYZ
636
+ * measures relative luminance, a logarithmic scale.
637
+ *
638
+ * @param y Y in XYZ
639
+ * @return L* in L*a*b*
640
+ */
641
+ function lstarFromY(y) {
642
+ return labF(y / 100.0) * 116.0 - 16.0;
643
+ }
644
+ /**
645
+ * Linearizes an RGB component.
646
+ *
647
+ * @param rgbComponent 0 <= rgb_component <= 255, represents R/G/B
648
+ * channel
649
+ * @return 0.0 <= output <= 100.0, color channel converted to
650
+ * linear RGB space
651
+ */
652
+ function linearized(rgbComponent) {
653
+ const normalized = rgbComponent / 255.0;
654
+ if (normalized <= 0.040449936) {
655
+ return normalized / 12.92 * 100.0;
656
+ } else {
657
+ return Math.pow((normalized + 0.055) / 1.055, 2.4) * 100.0;
658
+ }
659
+ }
660
+ /**
661
+ * Delinearizes an RGB component.
662
+ *
663
+ * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents
664
+ * linear R/G/B channel
665
+ * @return 0 <= output <= 255, color channel converted to regular
666
+ * RGB space
667
+ */
668
+ function delinearized(rgbComponent) {
669
+ const normalized = rgbComponent / 100.0;
670
+ let delinearized = 0.0;
671
+ if (normalized <= 0.0031308) {
672
+ delinearized = normalized * 12.92;
673
+ } else {
674
+ delinearized = 1.055 * Math.pow(normalized, 1.0 / 2.4) - 0.055;
675
+ }
676
+ return clampInt(0, 255, Math.round(delinearized * 255.0));
677
+ }
678
+ /**
679
+ * Returns the standard white point; white on a sunny day.
680
+ *
681
+ * @return The white point
682
+ */
683
+ function whitePointD65() {
684
+ return WHITE_POINT_D65;
685
+ }
686
+ function labF(t) {
687
+ const e = 216.0 / 24389.0;
688
+ const kappa = 24389.0 / 27.0;
689
+ if (t > e) {
690
+ return Math.pow(t, 1.0 / 3.0);
691
+ } else {
692
+ return (kappa * t + 16) / 116;
693
+ }
694
+ }
695
+ function labInvf(ft) {
696
+ const e = 216.0 / 24389.0;
697
+ const kappa = 24389.0 / 27.0;
698
+ const ft3 = ft * ft * ft;
699
+ if (ft3 > e) {
700
+ return ft3;
701
+ } else {
702
+ return (116 * ft - 16) / kappa;
703
+ }
704
+ }
705
+
706
+ /**
707
+ * @license
708
+ * Copyright 2021 Google LLC
709
+ *
710
+ * Licensed under the Apache License, Version 2.0 (the "License");
711
+ * you may not use this file except in compliance with the License.
712
+ * You may obtain a copy of the License at
713
+ *
714
+ * http://www.apache.org/licenses/LICENSE-2.0
715
+ *
716
+ * Unless required by applicable law or agreed to in writing, software
717
+ * distributed under the License is distributed on an "AS IS" BASIS,
718
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
719
+ * See the License for the specific language governing permissions and
720
+ * limitations under the License.
721
+ */
722
+ /**
723
+ * In traditional color spaces, a color can be identified solely by the
724
+ * observer's measurement of the color. Color appearance models such as CAM16
725
+ * also use information about the environment where the color was
726
+ * observed, known as the viewing conditions.
727
+ *
728
+ * For example, white under the traditional assumption of a midday sun white
729
+ * point is accurately measured as a slightly chromatic blue by CAM16. (roughly,
730
+ * hue 203, chroma 3, lightness 100)
731
+ *
732
+ * This class caches intermediate values of the CAM16 conversion process that
733
+ * depend only on viewing conditions, enabling speed ups.
734
+ */
735
+ class ViewingConditions {
736
+ /**
737
+ * Create ViewingConditions from a simple, physically relevant, set of
738
+ * parameters.
739
+ *
740
+ * @param whitePoint White point, measured in the XYZ color space.
741
+ * default = D65, or sunny day afternoon
742
+ * @param adaptingLuminance The luminance of the adapting field. Informally,
743
+ * how bright it is in the room where the color is viewed. Can be
744
+ * calculated from lux by multiplying lux by 0.0586. default = 11.72,
745
+ * or 200 lux.
746
+ * @param backgroundLstar The lightness of the area surrounding the color.
747
+ * measured by L* in L*a*b*. default = 50.0
748
+ * @param surround A general description of the lighting surrounding the
749
+ * color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a
750
+ * dimly light room, like watching TV at home at night. 2.0 means there
751
+ * is no difference between the lighting on the color and around it.
752
+ * default = 2.0
753
+ * @param discountingIlluminant Whether the eye accounts for the tint of the
754
+ * ambient lighting, such as knowing an apple is still red in green light.
755
+ * default = false, the eye does not perform this process on
756
+ * self-luminous objects like displays.
757
+ */
758
+ static make(whitePoint = whitePointD65(), adaptingLuminance = 200.0 / Math.PI * yFromLstar(50.0) / 100.0, backgroundLstar = 50.0, surround = 2.0, discountingIlluminant = false) {
759
+ const xyz = whitePoint;
760
+ const rW = xyz[0] * 0.401288 + xyz[1] * 0.650173 + xyz[2] * -0.051461;
761
+ const gW = xyz[0] * -0.250268 + xyz[1] * 1.204414 + xyz[2] * 0.045854;
762
+ const bW = xyz[0] * -2079e-6 + xyz[1] * 0.048952 + xyz[2] * 0.953127;
763
+ const f = 0.8 + surround / 10.0;
764
+ const c = f >= 0.9 ? lerp(0.59, 0.69, (f - 0.9) * 10.0) : lerp(0.525, 0.59, (f - 0.8) * 10.0);
765
+ let d = discountingIlluminant ? 1.0 : f * (1.0 - 1.0 / 3.6 * Math.exp((-adaptingLuminance - 42.0) / 92.0));
766
+ d = d > 1.0 ? 1.0 : d < 0.0 ? 0.0 : d;
767
+ const nc = f;
768
+ const rgbD = [d * (100.0 / rW) + 1.0 - d, d * (100.0 / gW) + 1.0 - d, d * (100.0 / bW) + 1.0 - d];
769
+ const k = 1.0 / (5.0 * adaptingLuminance + 1.0);
770
+ const k4 = k * k * k * k;
771
+ const k4F = 1.0 - k4;
772
+ const fl = k4 * adaptingLuminance + 0.1 * k4F * k4F * Math.cbrt(5.0 * adaptingLuminance);
773
+ const n = yFromLstar(backgroundLstar) / whitePoint[1];
774
+ const z = 1.48 + Math.sqrt(n);
775
+ const nbb = 0.725 / Math.pow(n, 0.2);
776
+ const ncb = nbb;
777
+ const rgbAFactors = [Math.pow(fl * rgbD[0] * rW / 100.0, 0.42), Math.pow(fl * rgbD[1] * gW / 100.0, 0.42), Math.pow(fl * rgbD[2] * bW / 100.0, 0.42)];
778
+ const rgbA = [400.0 * rgbAFactors[0] / (rgbAFactors[0] + 27.13), 400.0 * rgbAFactors[1] / (rgbAFactors[1] + 27.13), 400.0 * rgbAFactors[2] / (rgbAFactors[2] + 27.13)];
779
+ const aw = (2.0 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]) * nbb;
780
+ return new ViewingConditions(n, aw, nbb, ncb, c, nc, rgbD, fl, Math.pow(fl, 0.25), z);
781
+ }
782
+ /**
783
+ * Parameters are intermediate values of the CAM16 conversion process. Their
784
+ * names are shorthand for technical color science terminology, this class
785
+ * would not benefit from documenting them individually. A brief overview
786
+ * is available in the CAM16 specification, and a complete overview requires
787
+ * a color science textbook, such as Fairchild's Color Appearance Models.
788
+ */
789
+ constructor(n, aw, nbb, ncb, c, nc, rgbD, fl, fLRoot, z) {
790
+ this.n = n;
791
+ this.aw = aw;
792
+ this.nbb = nbb;
793
+ this.ncb = ncb;
794
+ this.c = c;
795
+ this.nc = nc;
796
+ this.rgbD = rgbD;
797
+ this.fl = fl;
798
+ this.fLRoot = fLRoot;
799
+ this.z = z;
800
+ }
801
+ }
802
+ /** sRGB-like viewing conditions. */
803
+ ViewingConditions.DEFAULT = ViewingConditions.make();
804
+
805
+ /**
806
+ * @license
807
+ * Copyright 2021 Google LLC
808
+ *
809
+ * Licensed under the Apache License, Version 2.0 (the "License");
810
+ * you may not use this file except in compliance with the License.
811
+ * You may obtain a copy of the License at
812
+ *
813
+ * http://www.apache.org/licenses/LICENSE-2.0
814
+ *
815
+ * Unless required by applicable law or agreed to in writing, software
816
+ * distributed under the License is distributed on an "AS IS" BASIS,
817
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
818
+ * See the License for the specific language governing permissions and
819
+ * limitations under the License.
820
+ */
821
+ /**
822
+ * CAM16, a color appearance model. Colors are not just defined by their hex
823
+ * code, but rather, a hex code and viewing conditions.
824
+ *
825
+ * CAM16 instances also have coordinates in the CAM16-UCS space, called J*, a*,
826
+ * b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16
827
+ * specification, and should be used when measuring distances between colors.
828
+ *
829
+ * In traditional color spaces, a color can be identified solely by the
830
+ * observer's measurement of the color. Color appearance models such as CAM16
831
+ * also use information about the environment where the color was
832
+ * observed, known as the viewing conditions.
833
+ *
834
+ * For example, white under the traditional assumption of a midday sun white
835
+ * point is accurately measured as a slightly chromatic blue by CAM16. (roughly,
836
+ * hue 203, chroma 3, lightness 100)
837
+ */
838
+ class Cam16 {
839
+ /**
840
+ * All of the CAM16 dimensions can be calculated from 3 of the dimensions, in
841
+ * the following combinations:
842
+ * - {j or q} and {c, m, or s} and hue
843
+ * - jstar, astar, bstar
844
+ * Prefer using a static method that constructs from 3 of those dimensions.
845
+ * This constructor is intended for those methods to use to return all
846
+ * possible dimensions.
847
+ *
848
+ * @param hue
849
+ * @param chroma informally, colorfulness / color intensity. like saturation
850
+ * in HSL, except perceptually accurate.
851
+ * @param j lightness
852
+ * @param q brightness; ratio of lightness to white point's lightness
853
+ * @param m colorfulness
854
+ * @param s saturation; ratio of chroma to white point's chroma
855
+ * @param jstar CAM16-UCS J coordinate
856
+ * @param astar CAM16-UCS a coordinate
857
+ * @param bstar CAM16-UCS b coordinate
858
+ */
859
+ constructor(hue, chroma, j, q, m, s, jstar, astar, bstar) {
860
+ this.hue = hue;
861
+ this.chroma = chroma;
862
+ this.j = j;
863
+ this.q = q;
864
+ this.m = m;
865
+ this.s = s;
866
+ this.jstar = jstar;
867
+ this.astar = astar;
868
+ this.bstar = bstar;
869
+ }
870
+ /**
871
+ * CAM16 instances also have coordinates in the CAM16-UCS space, called J*,
872
+ * a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16
873
+ * specification, and is used to measure distances between colors.
874
+ */
875
+ distance(other) {
876
+ const dJ = this.jstar - other.jstar;
877
+ const dA = this.astar - other.astar;
878
+ const dB = this.bstar - other.bstar;
879
+ const dEPrime = Math.sqrt(dJ * dJ + dA * dA + dB * dB);
880
+ const dE = 1.41 * Math.pow(dEPrime, 0.63);
881
+ return dE;
882
+ }
883
+ /**
884
+ * @param argb ARGB representation of a color.
885
+ * @return CAM16 color, assuming the color was viewed in default viewing
886
+ * conditions.
887
+ */
888
+ static fromInt(argb) {
889
+ return Cam16.fromIntInViewingConditions(argb, ViewingConditions.DEFAULT);
890
+ }
891
+ /**
892
+ * @param argb ARGB representation of a color.
893
+ * @param viewingConditions Information about the environment where the color
894
+ * was observed.
895
+ * @return CAM16 color.
896
+ */
897
+ static fromIntInViewingConditions(argb, viewingConditions) {
898
+ const red = (argb & 0x00ff0000) >> 16;
899
+ const green = (argb & 0x0000ff00) >> 8;
900
+ const blue = argb & 0x000000ff;
901
+ const redL = linearized(red);
902
+ const greenL = linearized(green);
903
+ const blueL = linearized(blue);
904
+ const x = 0.41233895 * redL + 0.35762064 * greenL + 0.18051042 * blueL;
905
+ const y = 0.2126 * redL + 0.7152 * greenL + 0.0722 * blueL;
906
+ const z = 0.01932141 * redL + 0.11916382 * greenL + 0.95034478 * blueL;
907
+ const rC = 0.401288 * x + 0.650173 * y - 0.051461 * z;
908
+ const gC = -0.250268 * x + 1.204414 * y + 0.045854 * z;
909
+ const bC = -2079e-6 * x + 0.048952 * y + 0.953127 * z;
910
+ const rD = viewingConditions.rgbD[0] * rC;
911
+ const gD = viewingConditions.rgbD[1] * gC;
912
+ const bD = viewingConditions.rgbD[2] * bC;
913
+ const rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100.0, 0.42);
914
+ const gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100.0, 0.42);
915
+ const bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100.0, 0.42);
916
+ const rA = signum(rD) * 400.0 * rAF / (rAF + 27.13);
917
+ const gA = signum(gD) * 400.0 * gAF / (gAF + 27.13);
918
+ const bA = signum(bD) * 400.0 * bAF / (bAF + 27.13);
919
+ const a = (11.0 * rA + -12 * gA + bA) / 11.0;
920
+ const b = (rA + gA - 2.0 * bA) / 9.0;
921
+ const u = (20.0 * rA + 20.0 * gA + 21.0 * bA) / 20.0;
922
+ const p2 = (40.0 * rA + 20.0 * gA + bA) / 20.0;
923
+ const atan2 = Math.atan2(b, a);
924
+ const atanDegrees = atan2 * 180.0 / Math.PI;
925
+ const hue = atanDegrees < 0 ? atanDegrees + 360.0 : atanDegrees >= 360 ? atanDegrees - 360.0 : atanDegrees;
926
+ const hueRadians = hue * Math.PI / 180.0;
927
+ const ac = p2 * viewingConditions.nbb;
928
+ const j = 100.0 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z);
929
+ const q = 4.0 / viewingConditions.c * Math.sqrt(j / 100.0) * (viewingConditions.aw + 4.0) * viewingConditions.fLRoot;
930
+ const huePrime = hue < 20.14 ? hue + 360 : hue;
931
+ const eHue = 0.25 * (Math.cos(huePrime * Math.PI / 180.0 + 2.0) + 3.8);
932
+ const p1 = 50000.0 / 13.0 * eHue * viewingConditions.nc * viewingConditions.ncb;
933
+ const t = p1 * Math.sqrt(a * a + b * b) / (u + 0.305);
934
+ const alpha = Math.pow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);
935
+ const c = alpha * Math.sqrt(j / 100.0);
936
+ const m = c * viewingConditions.fLRoot;
937
+ const s = 50.0 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4.0));
938
+ const jstar = (1.0 + 100.0 * 0.007) * j / (1.0 + 0.007 * j);
939
+ const mstar = 1.0 / 0.0228 * Math.log(1.0 + 0.0228 * m);
940
+ const astar = mstar * Math.cos(hueRadians);
941
+ const bstar = mstar * Math.sin(hueRadians);
942
+ return new Cam16(hue, c, j, q, m, s, jstar, astar, bstar);
943
+ }
944
+ /**
945
+ * @param j CAM16 lightness
946
+ * @param c CAM16 chroma
947
+ * @param h CAM16 hue
948
+ */
949
+ static fromJch(j, c, h) {
950
+ return Cam16.fromJchInViewingConditions(j, c, h, ViewingConditions.DEFAULT);
951
+ }
952
+ /**
953
+ * @param j CAM16 lightness
954
+ * @param c CAM16 chroma
955
+ * @param h CAM16 hue
956
+ * @param viewingConditions Information about the environment where the color
957
+ * was observed.
958
+ */
959
+ static fromJchInViewingConditions(j, c, h, viewingConditions) {
960
+ const q = 4.0 / viewingConditions.c * Math.sqrt(j / 100.0) * (viewingConditions.aw + 4.0) * viewingConditions.fLRoot;
961
+ const m = c * viewingConditions.fLRoot;
962
+ const alpha = c / Math.sqrt(j / 100.0);
963
+ const s = 50.0 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4.0));
964
+ const hueRadians = h * Math.PI / 180.0;
965
+ const jstar = (1.0 + 100.0 * 0.007) * j / (1.0 + 0.007 * j);
966
+ const mstar = 1.0 / 0.0228 * Math.log(1.0 + 0.0228 * m);
967
+ const astar = mstar * Math.cos(hueRadians);
968
+ const bstar = mstar * Math.sin(hueRadians);
969
+ return new Cam16(h, c, j, q, m, s, jstar, astar, bstar);
970
+ }
971
+ /**
972
+ * @param jstar CAM16-UCS lightness.
973
+ * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian
974
+ * coordinate on the Y axis.
975
+ * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian
976
+ * coordinate on the X axis.
977
+ */
978
+ static fromUcs(jstar, astar, bstar) {
979
+ return Cam16.fromUcsInViewingConditions(jstar, astar, bstar, ViewingConditions.DEFAULT);
980
+ }
981
+ /**
982
+ * @param jstar CAM16-UCS lightness.
983
+ * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian
984
+ * coordinate on the Y axis.
985
+ * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian
986
+ * coordinate on the X axis.
987
+ * @param viewingConditions Information about the environment where the color
988
+ * was observed.
989
+ */
990
+ static fromUcsInViewingConditions(jstar, astar, bstar, viewingConditions) {
991
+ const a = astar;
992
+ const b = bstar;
993
+ const m = Math.sqrt(a * a + b * b);
994
+ const M = (Math.exp(m * 0.0228) - 1.0) / 0.0228;
995
+ const c = M / viewingConditions.fLRoot;
996
+ let h = Math.atan2(b, a) * (180.0 / Math.PI);
997
+ if (h < 0.0) {
998
+ h += 360.0;
999
+ }
1000
+ const j = jstar / (1 - (jstar - 100) * 0.007);
1001
+ return Cam16.fromJchInViewingConditions(j, c, h, viewingConditions);
1002
+ }
1003
+ /**
1004
+ * @return ARGB representation of color, assuming the color was viewed in
1005
+ * default viewing conditions, which are near-identical to the default
1006
+ * viewing conditions for sRGB.
1007
+ */
1008
+ toInt() {
1009
+ return this.viewed(ViewingConditions.DEFAULT);
1010
+ }
1011
+ /**
1012
+ * @param viewingConditions Information about the environment where the color
1013
+ * will be viewed.
1014
+ * @return ARGB representation of color
1015
+ */
1016
+ viewed(viewingConditions) {
1017
+ const alpha = this.chroma === 0.0 || this.j === 0.0 ? 0.0 : this.chroma / Math.sqrt(this.j / 100.0);
1018
+ const t = Math.pow(alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), 1.0 / 0.9);
1019
+ const hRad = this.hue * Math.PI / 180.0;
1020
+ const eHue = 0.25 * (Math.cos(hRad + 2.0) + 3.8);
1021
+ const ac = viewingConditions.aw * Math.pow(this.j / 100.0, 1.0 / viewingConditions.c / viewingConditions.z);
1022
+ const p1 = eHue * (50000.0 / 13.0) * viewingConditions.nc * viewingConditions.ncb;
1023
+ const p2 = ac / viewingConditions.nbb;
1024
+ const hSin = Math.sin(hRad);
1025
+ const hCos = Math.cos(hRad);
1026
+ const gamma = 23.0 * (p2 + 0.305) * t / (23.0 * p1 + 11.0 * t * hCos + 108.0 * t * hSin);
1027
+ const a = gamma * hCos;
1028
+ const b = gamma * hSin;
1029
+ const rA = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;
1030
+ const gA = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;
1031
+ const bA = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;
1032
+ const rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400.0 - Math.abs(rA)));
1033
+ const rC = signum(rA) * (100.0 / viewingConditions.fl) * Math.pow(rCBase, 1.0 / 0.42);
1034
+ const gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400.0 - Math.abs(gA)));
1035
+ const gC = signum(gA) * (100.0 / viewingConditions.fl) * Math.pow(gCBase, 1.0 / 0.42);
1036
+ const bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400.0 - Math.abs(bA)));
1037
+ const bC = signum(bA) * (100.0 / viewingConditions.fl) * Math.pow(bCBase, 1.0 / 0.42);
1038
+ const rF = rC / viewingConditions.rgbD[0];
1039
+ const gF = gC / viewingConditions.rgbD[1];
1040
+ const bF = bC / viewingConditions.rgbD[2];
1041
+ const x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF;
1042
+ const y = 0.38752654 * rF + 0.62144744 * gF - 0.00897398 * bF;
1043
+ const z = -0.0158415 * rF - 0.03412294 * gF + 1.04996444 * bF;
1044
+ const argb = argbFromXyz(x, y, z);
1045
+ return argb;
1046
+ }
1047
+ /// Given color expressed in XYZ and viewed in [viewingConditions], convert to
1048
+ /// CAM16.
1049
+ static fromXyzInViewingConditions(x, y, z, viewingConditions) {
1050
+ // Transform XYZ to 'cone'/'rgb' responses
1051
+ const rC = 0.401288 * x + 0.650173 * y - 0.051461 * z;
1052
+ const gC = -0.250268 * x + 1.204414 * y + 0.045854 * z;
1053
+ const bC = -2079e-6 * x + 0.048952 * y + 0.953127 * z;
1054
+ // Discount illuminant
1055
+ const rD = viewingConditions.rgbD[0] * rC;
1056
+ const gD = viewingConditions.rgbD[1] * gC;
1057
+ const bD = viewingConditions.rgbD[2] * bC;
1058
+ // chromatic adaptation
1059
+ const rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100.0, 0.42);
1060
+ const gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100.0, 0.42);
1061
+ const bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100.0, 0.42);
1062
+ const rA = signum(rD) * 400.0 * rAF / (rAF + 27.13);
1063
+ const gA = signum(gD) * 400.0 * gAF / (gAF + 27.13);
1064
+ const bA = signum(bD) * 400.0 * bAF / (bAF + 27.13);
1065
+ // redness-greenness
1066
+ const a = (11.0 * rA + -12 * gA + bA) / 11.0;
1067
+ // yellowness-blueness
1068
+ const b = (rA + gA - 2.0 * bA) / 9.0;
1069
+ // auxiliary components
1070
+ const u = (20.0 * rA + 20.0 * gA + 21.0 * bA) / 20.0;
1071
+ const p2 = (40.0 * rA + 20.0 * gA + bA) / 20.0;
1072
+ // hue
1073
+ const atan2 = Math.atan2(b, a);
1074
+ const atanDegrees = atan2 * 180.0 / Math.PI;
1075
+ const hue = atanDegrees < 0 ? atanDegrees + 360.0 : atanDegrees >= 360 ? atanDegrees - 360 : atanDegrees;
1076
+ const hueRadians = hue * Math.PI / 180.0;
1077
+ // achromatic response to color
1078
+ const ac = p2 * viewingConditions.nbb;
1079
+ // CAM16 lightness and brightness
1080
+ const J = 100.0 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z);
1081
+ const Q = 4.0 / viewingConditions.c * Math.sqrt(J / 100.0) * (viewingConditions.aw + 4.0) * viewingConditions.fLRoot;
1082
+ const huePrime = hue < 20.14 ? hue + 360 : hue;
1083
+ const eHue = 1.0 / 4.0 * (Math.cos(huePrime * Math.PI / 180.0 + 2.0) + 3.8);
1084
+ const p1 = 50000.0 / 13.0 * eHue * viewingConditions.nc * viewingConditions.ncb;
1085
+ const t = p1 * Math.sqrt(a * a + b * b) / (u + 0.305);
1086
+ const alpha = Math.pow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);
1087
+ // CAM16 chroma, colorfulness, chroma
1088
+ const C = alpha * Math.sqrt(J / 100.0);
1089
+ const M = C * viewingConditions.fLRoot;
1090
+ const s = 50.0 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4.0));
1091
+ // CAM16-UCS components
1092
+ const jstar = (1.0 + 100.0 * 0.007) * J / (1.0 + 0.007 * J);
1093
+ const mstar = Math.log(1.0 + 0.0228 * M) / 0.0228;
1094
+ const astar = mstar * Math.cos(hueRadians);
1095
+ const bstar = mstar * Math.sin(hueRadians);
1096
+ return new Cam16(hue, C, J, Q, M, s, jstar, astar, bstar);
1097
+ }
1098
+ /// XYZ representation of CAM16 seen in [viewingConditions].
1099
+ xyzInViewingConditions(viewingConditions) {
1100
+ const alpha = this.chroma === 0.0 || this.j === 0.0 ? 0.0 : this.chroma / Math.sqrt(this.j / 100.0);
1101
+ const t = Math.pow(alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), 1.0 / 0.9);
1102
+ const hRad = this.hue * Math.PI / 180.0;
1103
+ const eHue = 0.25 * (Math.cos(hRad + 2.0) + 3.8);
1104
+ const ac = viewingConditions.aw * Math.pow(this.j / 100.0, 1.0 / viewingConditions.c / viewingConditions.z);
1105
+ const p1 = eHue * (50000.0 / 13.0) * viewingConditions.nc * viewingConditions.ncb;
1106
+ const p2 = ac / viewingConditions.nbb;
1107
+ const hSin = Math.sin(hRad);
1108
+ const hCos = Math.cos(hRad);
1109
+ const gamma = 23.0 * (p2 + 0.305) * t / (23.0 * p1 + 11 * t * hCos + 108.0 * t * hSin);
1110
+ const a = gamma * hCos;
1111
+ const b = gamma * hSin;
1112
+ const rA = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;
1113
+ const gA = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;
1114
+ const bA = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;
1115
+ const rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400.0 - Math.abs(rA)));
1116
+ const rC = signum(rA) * (100.0 / viewingConditions.fl) * Math.pow(rCBase, 1.0 / 0.42);
1117
+ const gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400.0 - Math.abs(gA)));
1118
+ const gC = signum(gA) * (100.0 / viewingConditions.fl) * Math.pow(gCBase, 1.0 / 0.42);
1119
+ const bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400.0 - Math.abs(bA)));
1120
+ const bC = signum(bA) * (100.0 / viewingConditions.fl) * Math.pow(bCBase, 1.0 / 0.42);
1121
+ const rF = rC / viewingConditions.rgbD[0];
1122
+ const gF = gC / viewingConditions.rgbD[1];
1123
+ const bF = bC / viewingConditions.rgbD[2];
1124
+ const x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF;
1125
+ const y = 0.38752654 * rF + 0.62144744 * gF - 0.00897398 * bF;
1126
+ const z = -0.0158415 * rF - 0.03412294 * gF + 1.04996444 * bF;
1127
+ return [x, y, z];
1128
+ }
1129
+ }
1130
+
1131
+ /**
1132
+ * @license
1133
+ * Copyright 2021 Google LLC
1134
+ *
1135
+ * Licensed under the Apache License, Version 2.0 (the "License");
1136
+ * you may not use this file except in compliance with the License.
1137
+ * You may obtain a copy of the License at
1138
+ *
1139
+ * http://www.apache.org/licenses/LICENSE-2.0
1140
+ *
1141
+ * Unless required by applicable law or agreed to in writing, software
1142
+ * distributed under the License is distributed on an "AS IS" BASIS,
1143
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1144
+ * See the License for the specific language governing permissions and
1145
+ * limitations under the License.
1146
+ */
1147
+ // This file is automatically generated. Do not modify it.
1148
+ // material_color_utilities is designed to have a consistent API across
1149
+ // platforms and modular components that can be moved around easily. Using a
1150
+ // class as a namespace facilitates this.
1151
+ //
1152
+ // tslint:disable:class-as-namespace
1153
+ /**
1154
+ * A class that solves the HCT equation.
1155
+ */
1156
+ class HctSolver {
1157
+ /**
1158
+ * Sanitizes a small enough angle in radians.
1159
+ *
1160
+ * @param angle An angle in radians; must not deviate too much
1161
+ * from 0.
1162
+ * @return A coterminal angle between 0 and 2pi.
1163
+ */
1164
+ static sanitizeRadians(angle) {
1165
+ return (angle + Math.PI * 8) % (Math.PI * 2);
1166
+ }
1167
+ /**
1168
+ * Delinearizes an RGB component, returning a floating-point
1169
+ * number.
1170
+ *
1171
+ * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents
1172
+ * linear R/G/B channel
1173
+ * @return 0.0 <= output <= 255.0, color channel converted to
1174
+ * regular RGB space
1175
+ */
1176
+ static trueDelinearized(rgbComponent) {
1177
+ const normalized = rgbComponent / 100.0;
1178
+ let delinearized = 0.0;
1179
+ if (normalized <= 0.0031308) {
1180
+ delinearized = normalized * 12.92;
1181
+ } else {
1182
+ delinearized = 1.055 * Math.pow(normalized, 1.0 / 2.4) - 0.055;
1183
+ }
1184
+ return delinearized * 255.0;
1185
+ }
1186
+ static chromaticAdaptation(component) {
1187
+ const af = Math.pow(Math.abs(component), 0.42);
1188
+ return signum(component) * 400.0 * af / (af + 27.13);
1189
+ }
1190
+ /**
1191
+ * Returns the hue of a linear RGB color in CAM16.
1192
+ *
1193
+ * @param linrgb The linear RGB coordinates of a color.
1194
+ * @return The hue of the color in CAM16, in radians.
1195
+ */
1196
+ static hueOf(linrgb) {
1197
+ const scaledDiscount = matrixMultiply(linrgb, HctSolver.SCALED_DISCOUNT_FROM_LINRGB);
1198
+ const rA = HctSolver.chromaticAdaptation(scaledDiscount[0]);
1199
+ const gA = HctSolver.chromaticAdaptation(scaledDiscount[1]);
1200
+ const bA = HctSolver.chromaticAdaptation(scaledDiscount[2]);
1201
+ // redness-greenness
1202
+ const a = (11.0 * rA + -12 * gA + bA) / 11.0;
1203
+ // yellowness-blueness
1204
+ const b = (rA + gA - 2.0 * bA) / 9.0;
1205
+ return Math.atan2(b, a);
1206
+ }
1207
+ static areInCyclicOrder(a, b, c) {
1208
+ const deltaAB = HctSolver.sanitizeRadians(b - a);
1209
+ const deltaAC = HctSolver.sanitizeRadians(c - a);
1210
+ return deltaAB < deltaAC;
1211
+ }
1212
+ /**
1213
+ * Solves the lerp equation.
1214
+ *
1215
+ * @param source The starting number.
1216
+ * @param mid The number in the middle.
1217
+ * @param target The ending number.
1218
+ * @return A number t such that lerp(source, target, t) = mid.
1219
+ */
1220
+ static intercept(source, mid, target) {
1221
+ return (mid - source) / (target - source);
1222
+ }
1223
+ static lerpPoint(source, t, target) {
1224
+ return [source[0] + (target[0] - source[0]) * t, source[1] + (target[1] - source[1]) * t, source[2] + (target[2] - source[2]) * t];
1225
+ }
1226
+ /**
1227
+ * Intersects a segment with a plane.
1228
+ *
1229
+ * @param source The coordinates of point A.
1230
+ * @param coordinate The R-, G-, or B-coordinate of the plane.
1231
+ * @param target The coordinates of point B.
1232
+ * @param axis The axis the plane is perpendicular with. (0: R, 1:
1233
+ * G, 2: B)
1234
+ * @return The intersection point of the segment AB with the plane
1235
+ * R=coordinate, G=coordinate, or B=coordinate
1236
+ */
1237
+ static setCoordinate(source, coordinate, target, axis) {
1238
+ const t = HctSolver.intercept(source[axis], coordinate, target[axis]);
1239
+ return HctSolver.lerpPoint(source, t, target);
1240
+ }
1241
+ static isBounded(x) {
1242
+ return 0.0 <= x && x <= 100.0;
1243
+ }
1244
+ /**
1245
+ * Returns the nth possible vertex of the polygonal intersection.
1246
+ *
1247
+ * @param y The Y value of the plane.
1248
+ * @param n The zero-based index of the point. 0 <= n <= 11.
1249
+ * @return The nth possible vertex of the polygonal intersection
1250
+ * of the y plane and the RGB cube, in linear RGB coordinates, if
1251
+ * it exists. If this possible vertex lies outside of the cube,
1252
+ * [-1.0, -1.0, -1.0] is returned.
1253
+ */
1254
+ static nthVertex(y, n) {
1255
+ const kR = HctSolver.Y_FROM_LINRGB[0];
1256
+ const kG = HctSolver.Y_FROM_LINRGB[1];
1257
+ const kB = HctSolver.Y_FROM_LINRGB[2];
1258
+ const coordA = n % 4 <= 1 ? 0.0 : 100.0;
1259
+ const coordB = n % 2 === 0 ? 0.0 : 100.0;
1260
+ if (n < 4) {
1261
+ const g = coordA;
1262
+ const b = coordB;
1263
+ const r = (y - g * kG - b * kB) / kR;
1264
+ if (HctSolver.isBounded(r)) {
1265
+ return [r, g, b];
1266
+ } else {
1267
+ return [-1, -1, -1];
1268
+ }
1269
+ } else if (n < 8) {
1270
+ const b = coordA;
1271
+ const r = coordB;
1272
+ const g = (y - r * kR - b * kB) / kG;
1273
+ if (HctSolver.isBounded(g)) {
1274
+ return [r, g, b];
1275
+ } else {
1276
+ return [-1, -1, -1];
1277
+ }
1278
+ } else {
1279
+ const r = coordA;
1280
+ const g = coordB;
1281
+ const b = (y - r * kR - g * kG) / kB;
1282
+ if (HctSolver.isBounded(b)) {
1283
+ return [r, g, b];
1284
+ } else {
1285
+ return [-1, -1, -1];
1286
+ }
1287
+ }
1288
+ }
1289
+ /**
1290
+ * Finds the segment containing the desired color.
1291
+ *
1292
+ * @param y The Y value of the color.
1293
+ * @param targetHue The hue of the color.
1294
+ * @return A list of two sets of linear RGB coordinates, each
1295
+ * corresponding to an endpoint of the segment containing the
1296
+ * desired color.
1297
+ */
1298
+ static bisectToSegment(y, targetHue) {
1299
+ let left = [-1, -1, -1];
1300
+ let right = left;
1301
+ let leftHue = 0.0;
1302
+ let rightHue = 0.0;
1303
+ let initialized = false;
1304
+ let uncut = true;
1305
+ for (let n = 0; n < 12; n++) {
1306
+ const mid = HctSolver.nthVertex(y, n);
1307
+ if (mid[0] < 0) {
1308
+ continue;
1309
+ }
1310
+ const midHue = HctSolver.hueOf(mid);
1311
+ if (!initialized) {
1312
+ left = mid;
1313
+ right = mid;
1314
+ leftHue = midHue;
1315
+ rightHue = midHue;
1316
+ initialized = true;
1317
+ continue;
1318
+ }
1319
+ if (uncut || HctSolver.areInCyclicOrder(leftHue, midHue, rightHue)) {
1320
+ uncut = false;
1321
+ if (HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {
1322
+ right = mid;
1323
+ rightHue = midHue;
1324
+ } else {
1325
+ left = mid;
1326
+ leftHue = midHue;
1327
+ }
1328
+ }
1329
+ }
1330
+ return [left, right];
1331
+ }
1332
+ static midpoint(a, b) {
1333
+ return [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];
1334
+ }
1335
+ static criticalPlaneBelow(x) {
1336
+ return Math.floor(x - 0.5);
1337
+ }
1338
+ static criticalPlaneAbove(x) {
1339
+ return Math.ceil(x - 0.5);
1340
+ }
1341
+ /**
1342
+ * Finds a color with the given Y and hue on the boundary of the
1343
+ * cube.
1344
+ *
1345
+ * @param y The Y value of the color.
1346
+ * @param targetHue The hue of the color.
1347
+ * @return The desired color, in linear RGB coordinates.
1348
+ */
1349
+ static bisectToLimit(y, targetHue) {
1350
+ const segment = HctSolver.bisectToSegment(y, targetHue);
1351
+ let left = segment[0];
1352
+ let leftHue = HctSolver.hueOf(left);
1353
+ let right = segment[1];
1354
+ for (let axis = 0; axis < 3; axis++) {
1355
+ if (left[axis] !== right[axis]) {
1356
+ let lPlane = -1;
1357
+ let rPlane = 255;
1358
+ if (left[axis] < right[axis]) {
1359
+ lPlane = HctSolver.criticalPlaneBelow(HctSolver.trueDelinearized(left[axis]));
1360
+ rPlane = HctSolver.criticalPlaneAbove(HctSolver.trueDelinearized(right[axis]));
1361
+ } else {
1362
+ lPlane = HctSolver.criticalPlaneAbove(HctSolver.trueDelinearized(left[axis]));
1363
+ rPlane = HctSolver.criticalPlaneBelow(HctSolver.trueDelinearized(right[axis]));
1364
+ }
1365
+ for (let i = 0; i < 8; i++) {
1366
+ if (Math.abs(rPlane - lPlane) <= 1) {
1367
+ break;
1368
+ } else {
1369
+ const mPlane = Math.floor((lPlane + rPlane) / 2.0);
1370
+ const midPlaneCoordinate = HctSolver.CRITICAL_PLANES[mPlane];
1371
+ const mid = HctSolver.setCoordinate(left, midPlaneCoordinate, right, axis);
1372
+ const midHue = HctSolver.hueOf(mid);
1373
+ if (HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {
1374
+ right = mid;
1375
+ rPlane = mPlane;
1376
+ } else {
1377
+ left = mid;
1378
+ leftHue = midHue;
1379
+ lPlane = mPlane;
1380
+ }
1381
+ }
1382
+ }
1383
+ }
1384
+ }
1385
+ return HctSolver.midpoint(left, right);
1386
+ }
1387
+ static inverseChromaticAdaptation(adapted) {
1388
+ const adaptedAbs = Math.abs(adapted);
1389
+ const base = Math.max(0, 27.13 * adaptedAbs / (400.0 - adaptedAbs));
1390
+ return signum(adapted) * Math.pow(base, 1.0 / 0.42);
1391
+ }
1392
+ /**
1393
+ * Finds a color with the given hue, chroma, and Y.
1394
+ *
1395
+ * @param hueRadians The desired hue in radians.
1396
+ * @param chroma The desired chroma.
1397
+ * @param y The desired Y.
1398
+ * @return The desired color as a hexadecimal integer, if found; 0
1399
+ * otherwise.
1400
+ */
1401
+ static findResultByJ(hueRadians, chroma, y) {
1402
+ // Initial estimate of j.
1403
+ let j = Math.sqrt(y) * 11.0;
1404
+ // ===========================================================
1405
+ // Operations inlined from Cam16 to avoid repeated calculation
1406
+ // ===========================================================
1407
+ const viewingConditions = ViewingConditions.DEFAULT;
1408
+ const tInnerCoeff = 1 / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);
1409
+ const eHue = 0.25 * (Math.cos(hueRadians + 2.0) + 3.8);
1410
+ const p1 = eHue * (50000.0 / 13.0) * viewingConditions.nc * viewingConditions.ncb;
1411
+ const hSin = Math.sin(hueRadians);
1412
+ const hCos = Math.cos(hueRadians);
1413
+ for (let iterationRound = 0; iterationRound < 5; iterationRound++) {
1414
+ // ===========================================================
1415
+ // Operations inlined from Cam16 to avoid repeated calculation
1416
+ // ===========================================================
1417
+ const jNormalized = j / 100.0;
1418
+ const alpha = chroma === 0.0 || j === 0.0 ? 0.0 : chroma / Math.sqrt(jNormalized);
1419
+ const t = Math.pow(alpha * tInnerCoeff, 1.0 / 0.9);
1420
+ const ac = viewingConditions.aw * Math.pow(jNormalized, 1.0 / viewingConditions.c / viewingConditions.z);
1421
+ const p2 = ac / viewingConditions.nbb;
1422
+ const gamma = 23.0 * (p2 + 0.305) * t / (23.0 * p1 + 11 * t * hCos + 108.0 * t * hSin);
1423
+ const a = gamma * hCos;
1424
+ const b = gamma * hSin;
1425
+ const rA = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;
1426
+ const gA = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;
1427
+ const bA = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;
1428
+ const rCScaled = HctSolver.inverseChromaticAdaptation(rA);
1429
+ const gCScaled = HctSolver.inverseChromaticAdaptation(gA);
1430
+ const bCScaled = HctSolver.inverseChromaticAdaptation(bA);
1431
+ const linrgb = matrixMultiply([rCScaled, gCScaled, bCScaled], HctSolver.LINRGB_FROM_SCALED_DISCOUNT);
1432
+ // ===========================================================
1433
+ // Operations inlined from Cam16 to avoid repeated calculation
1434
+ // ===========================================================
1435
+ if (linrgb[0] < 0 || linrgb[1] < 0 || linrgb[2] < 0) {
1436
+ return 0;
1437
+ }
1438
+ const kR = HctSolver.Y_FROM_LINRGB[0];
1439
+ const kG = HctSolver.Y_FROM_LINRGB[1];
1440
+ const kB = HctSolver.Y_FROM_LINRGB[2];
1441
+ const fnj = kR * linrgb[0] + kG * linrgb[1] + kB * linrgb[2];
1442
+ if (fnj <= 0) {
1443
+ return 0;
1444
+ }
1445
+ if (iterationRound === 4 || Math.abs(fnj - y) < 0.002) {
1446
+ if (linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01) {
1447
+ return 0;
1448
+ }
1449
+ return argbFromLinrgb(linrgb);
1450
+ }
1451
+ // Iterates with Newton method,
1452
+ // Using 2 * fn(j) / j as the approximation of fn'(j)
1453
+ j = j - (fnj - y) * j / (2 * fnj);
1454
+ }
1455
+ return 0;
1456
+ }
1457
+ /**
1458
+ * Finds an sRGB color with the given hue, chroma, and L*, if
1459
+ * possible.
1460
+ *
1461
+ * @param hueDegrees The desired hue, in degrees.
1462
+ * @param chroma The desired chroma.
1463
+ * @param lstar The desired L*.
1464
+ * @return A hexadecimal representing the sRGB color. The color
1465
+ * has sufficiently close hue, chroma, and L* to the desired
1466
+ * values, if possible; otherwise, the hue and L* will be
1467
+ * sufficiently close, and chroma will be maximized.
1468
+ */
1469
+ static solveToInt(hueDegrees, chroma, lstar) {
1470
+ if (chroma < 0.0001 || lstar < 0.0001 || lstar > 99.9999) {
1471
+ return argbFromLstar(lstar);
1472
+ }
1473
+ hueDegrees = sanitizeDegreesDouble(hueDegrees);
1474
+ const hueRadians = hueDegrees / 180 * Math.PI;
1475
+ const y = yFromLstar(lstar);
1476
+ const exactAnswer = HctSolver.findResultByJ(hueRadians, chroma, y);
1477
+ if (exactAnswer !== 0) {
1478
+ return exactAnswer;
1479
+ }
1480
+ const linrgb = HctSolver.bisectToLimit(y, hueRadians);
1481
+ return argbFromLinrgb(linrgb);
1482
+ }
1483
+ /**
1484
+ * Finds an sRGB color with the given hue, chroma, and L*, if
1485
+ * possible.
1486
+ *
1487
+ * @param hueDegrees The desired hue, in degrees.
1488
+ * @param chroma The desired chroma.
1489
+ * @param lstar The desired L*.
1490
+ * @return An CAM16 object representing the sRGB color. The color
1491
+ * has sufficiently close hue, chroma, and L* to the desired
1492
+ * values, if possible; otherwise, the hue and L* will be
1493
+ * sufficiently close, and chroma will be maximized.
1494
+ */
1495
+ static solveToCam(hueDegrees, chroma, lstar) {
1496
+ return Cam16.fromInt(HctSolver.solveToInt(hueDegrees, chroma, lstar));
1497
+ }
1498
+ }
1499
+ HctSolver.SCALED_DISCOUNT_FROM_LINRGB = [[0.001200833568784504, 0.002389694492170889, 0.0002795742885861124], [0.0005891086651375999, 0.0029785502573438758, 0.0003270666104008398], [0.00010146692491640572, 0.0005364214359186694, 0.0032979401770712076]];
1500
+ HctSolver.LINRGB_FROM_SCALED_DISCOUNT = [[1373.2198709594231, -1100.4251190754821, -7.278681089101213], [-271.815969077903, 559.6580465940733, -32.46047482791194], [1.9622899599665666, -57.173814538844006, 308.7233197812385]];
1501
+ HctSolver.Y_FROM_LINRGB = [0.2126, 0.7152, 0.0722];
1502
+ HctSolver.CRITICAL_PLANES = [0.015176349177441876, 0.045529047532325624, 0.07588174588720938, 0.10623444424209313, 0.13658714259697685, 0.16693984095186062, 0.19729253930674434, 0.2276452376616281, 0.2579979360165119, 0.28835063437139563, 0.3188300904430532, 0.350925934958123, 0.3848314933096426, 0.42057480301049466, 0.458183274052838, 0.4976837250274023, 0.5391024159806381, 0.5824650784040898, 0.6277969426914107, 0.6751227633498623, 0.7244668422128921, 0.775853049866786, 0.829304845476233, 0.8848452951698498, 0.942497089126609, 1.0022825574869039, 1.0642236851973577, 1.1283421258858297, 1.1946592148522128, 1.2631959812511864, 1.3339731595349034, 1.407011200216447, 1.4823302800086415, 1.5599503113873272, 1.6398909516233677, 1.7221716113234105, 1.8068114625156377, 1.8938294463134073, 1.9832442801866852, 2.075074464868551, 2.1693382909216234, 2.2660538449872063, 2.36523901573795, 2.4669114995532007, 2.5710888059345764, 2.6777882626779785, 2.7870270208169257, 2.898822059350997, 3.0131901897720907, 3.1301480604002863, 3.2497121605402226, 3.3718988244681087, 3.4967242352587946, 3.624204428461639, 3.754355295633311, 3.887192587735158, 4.022731918402185, 4.160988767090289, 4.301978482107941, 4.445716283538092, 4.592217266055746, 4.741496401646282, 4.893568542229298, 5.048448422192488, 5.20615066083972, 5.3666897647573375, 5.5300801301023865, 5.696336044816294, 5.865471690767354, 6.037501145825082, 6.212438385869475, 6.390297286737924, 6.571091626112461, 6.7548350853498045, 6.941541251256611, 7.131223617812143, 7.323895587840543, 7.5195704746346665, 7.7182615035334345, 7.919981813454504, 8.124744458384042, 8.332562408825165, 8.543448553206703, 8.757415699253682, 8.974476575321063, 9.194643831691977, 9.417930041841839, 9.644347703669503, 9.873909240696694, 10.106627003236781, 10.342513269534024, 10.58158024687427, 10.8238400726681, 11.069304815507364, 11.317986476196008, 11.569896988756009, 11.825048221409341, 12.083451977536606, 12.345119996613247, 12.610063955123938, 12.878295467455942, 13.149826086772048, 13.42466730586372, 13.702830557985108, 13.984327217668513, 14.269168601521828, 14.55736596900856, 14.848930523210871, 15.143873411576273, 15.44220572664832, 15.743938506781891, 16.04908273684337, 16.35764934889634, 16.66964922287304, 16.985093187232053, 17.30399201960269, 17.62635644741625, 17.95219714852476, 18.281524751807332, 18.614349837764564, 18.95068293910138, 19.290534541298456, 19.633915083172692, 19.98083495742689, 20.331304511189067, 20.685334046541502, 21.042933821039977, 21.404114048223256, 21.76888489811322, 22.137256497705877, 22.50923893145328, 22.884842241736916, 23.264076429332462, 23.6469514538663, 24.033477234264016, 24.42366364919083, 24.817520537484558, 25.21505769858089, 25.61628489293138, 26.021211842414342, 26.429848230738664, 26.842203703840827, 27.258287870275353, 27.678110301598522, 28.10168053274597, 28.529008062403893, 28.96010235337422, 29.39497283293396, 29.83362889318845, 30.276079891419332, 30.722335150426627, 31.172403958865512, 31.62629557157785, 32.08401920991837, 32.54558406207592, 33.010999283389665, 33.4802739966603, 33.953417292456834, 34.430438229418264, 34.911345834551085, 35.39614910352207, 35.88485700094671, 36.37747846067349, 36.87402238606382, 37.37449765026789, 37.87891309649659, 38.38727753828926, 38.89959975977785, 39.41588851594697, 39.93615253289054, 40.460400508064545, 40.98864111053629, 41.520882981230194, 42.05713473317016, 42.597404951718396, 43.141702194811224, 43.6900349931913, 44.24241185063697, 44.798841244188324, 45.35933162437017, 45.92389141541209, 46.49252901546552, 47.065252796817916, 47.64207110610409, 48.22299226451468, 48.808024568002054, 49.3971762874833, 49.9904556690408, 50.587870934119984, 51.189430279724725, 51.79514187861014, 52.40501387947288, 53.0190544071392, 53.637271562750364, 54.259673423945976, 54.88626804504493, 55.517063457223934, 56.15206766869424, 56.79128866487574, 57.43473440856916, 58.08241284012621, 58.734331877617365, 59.39049941699807, 60.05092333227251, 60.715611475655585, 61.38457167773311, 62.057811747619894, 62.7353394731159, 63.417162620860914, 64.10328893648692, 64.79372614476921, 65.48848194977529, 66.18756403501224, 66.89098006357258, 67.59873767827808, 68.31084450182222, 69.02730813691093, 69.74813616640164, 70.47333615344107, 71.20291564160104, 71.93688215501312, 72.67524319850172, 73.41800625771542, 74.16517879925733, 74.9167682708136, 75.67278210128072, 76.43322770089146, 77.1981124613393, 77.96744375590167, 78.74122893956174, 79.51947534912904, 80.30219030335869, 81.08938110306934, 81.88105503125999, 82.67721935322541, 83.4778813166706, 84.28304815182372, 85.09272707154808, 85.90692527145302, 86.72564993000343, 87.54890820862819, 88.3767072518277, 89.2090541872801, 90.04595612594655, 90.88742016217518, 91.73345337380438, 92.58406282226491, 93.43925555268066, 94.29903859396902, 95.16341895893969, 96.03240364439274, 96.9059996312159, 97.78421388448044, 98.6670533535366, 99.55452497210776];
1503
+
1504
+ /**
1505
+ * @license
1506
+ * Copyright 2021 Google LLC
1507
+ *
1508
+ * Licensed under the Apache License, Version 2.0 (the "License");
1509
+ * you may not use this file except in compliance with the License.
1510
+ * You may obtain a copy of the License at
1511
+ *
1512
+ * http://www.apache.org/licenses/LICENSE-2.0
1513
+ *
1514
+ * Unless required by applicable law or agreed to in writing, software
1515
+ * distributed under the License is distributed on an "AS IS" BASIS,
1516
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1517
+ * See the License for the specific language governing permissions and
1518
+ * limitations under the License.
1519
+ */
1520
+ /**
1521
+ * A color system built using CAM16 hue and chroma, and L* from
1522
+ * L*a*b*.
1523
+ *
1524
+ * Using L* creates a link between the color system, contrast, and thus
1525
+ * accessibility. Contrast ratio depends on relative luminance, or Y in the XYZ
1526
+ * color space. L*, or perceptual luminance can be calculated from Y.
1527
+ *
1528
+ * Unlike Y, L* is linear to human perception, allowing trivial creation of
1529
+ * accurate color tones.
1530
+ *
1531
+ * Unlike contrast ratio, measuring contrast in L* is linear, and simple to
1532
+ * calculate. A difference of 40 in HCT tone guarantees a contrast ratio >= 3.0,
1533
+ * and a difference of 50 guarantees a contrast ratio >= 4.5.
1534
+ */
1535
+ /**
1536
+ * HCT, hue, chroma, and tone. A color system that provides a perceptually
1537
+ * accurate color measurement system that can also accurately render what colors
1538
+ * will appear as in different lighting environments.
1539
+ */
1540
+ class Hct {
1541
+ static from(hue, chroma, tone) {
1542
+ return new Hct(HctSolver.solveToInt(hue, chroma, tone));
1543
+ }
1544
+ /**
1545
+ * @param argb ARGB representation of a color.
1546
+ * @return HCT representation of a color in default viewing conditions
1547
+ */
1548
+ static fromInt(argb) {
1549
+ return new Hct(argb);
1550
+ }
1551
+ toInt() {
1552
+ return this.argb;
1553
+ }
1554
+ /**
1555
+ * A number, in degrees, representing ex. red, orange, yellow, etc.
1556
+ * Ranges from 0 <= hue < 360.
1557
+ */
1558
+ get hue() {
1559
+ return this.internalHue;
1560
+ }
1561
+ /**
1562
+ * @param newHue 0 <= newHue < 360; invalid values are corrected.
1563
+ * Chroma may decrease because chroma has a different maximum for any given
1564
+ * hue and tone.
1565
+ */
1566
+ set hue(newHue) {
1567
+ this.setInternalState(HctSolver.solveToInt(newHue, this.internalChroma, this.internalTone));
1568
+ }
1569
+ get chroma() {
1570
+ return this.internalChroma;
1571
+ }
1572
+ /**
1573
+ * @param newChroma 0 <= newChroma < ?
1574
+ * Chroma may decrease because chroma has a different maximum for any given
1575
+ * hue and tone.
1576
+ */
1577
+ set chroma(newChroma) {
1578
+ this.setInternalState(HctSolver.solveToInt(this.internalHue, newChroma, this.internalTone));
1579
+ }
1580
+ /** Lightness. Ranges from 0 to 100. */
1581
+ get tone() {
1582
+ return this.internalTone;
1583
+ }
1584
+ /**
1585
+ * @param newTone 0 <= newTone <= 100; invalid valids are corrected.
1586
+ * Chroma may decrease because chroma has a different maximum for any given
1587
+ * hue and tone.
1588
+ */
1589
+ set tone(newTone) {
1590
+ this.setInternalState(HctSolver.solveToInt(this.internalHue, this.internalChroma, newTone));
1591
+ }
1592
+ constructor(argb) {
1593
+ this.argb = argb;
1594
+ const cam = Cam16.fromInt(argb);
1595
+ this.internalHue = cam.hue;
1596
+ this.internalChroma = cam.chroma;
1597
+ this.internalTone = lstarFromArgb(argb);
1598
+ this.argb = argb;
1599
+ }
1600
+ setInternalState(argb) {
1601
+ const cam = Cam16.fromInt(argb);
1602
+ this.internalHue = cam.hue;
1603
+ this.internalChroma = cam.chroma;
1604
+ this.internalTone = lstarFromArgb(argb);
1605
+ this.argb = argb;
1606
+ }
1607
+ /**
1608
+ * Translates a color into different [ViewingConditions].
1609
+ *
1610
+ * Colors change appearance. They look different with lights on versus off,
1611
+ * the same color, as in hex code, on white looks different when on black.
1612
+ * This is called color relativity, most famously explicated by Josef Albers
1613
+ * in Interaction of Color.
1614
+ *
1615
+ * In color science, color appearance models can account for this and
1616
+ * calculate the appearance of a color in different settings. HCT is based on
1617
+ * CAM16, a color appearance model, and uses it to make these calculations.
1618
+ *
1619
+ * See [ViewingConditions.make] for parameters affecting color appearance.
1620
+ */
1621
+ inViewingConditions(vc) {
1622
+ // 1. Use CAM16 to find XYZ coordinates of color in specified VC.
1623
+ const cam = Cam16.fromInt(this.toInt());
1624
+ const viewedInVc = cam.xyzInViewingConditions(vc);
1625
+ // 2. Create CAM16 of those XYZ coordinates in default VC.
1626
+ const recastInVc = Cam16.fromXyzInViewingConditions(viewedInVc[0], viewedInVc[1], viewedInVc[2], ViewingConditions.make());
1627
+ // 3. Create HCT from:
1628
+ // - CAM16 using default VC with XYZ coordinates in specified VC.
1629
+ // - L* converted from Y in XYZ coordinates in specified VC.
1630
+ const recastHct = Hct.from(recastInVc.hue, recastInVc.chroma, lstarFromY(viewedInVc[1]));
1631
+ return recastHct;
1632
+ }
1633
+ }
1634
+
1635
+ /**
1636
+ * @license
1637
+ * Copyright 2022 Google LLC
1638
+ *
1639
+ * Licensed under the Apache License, Version 2.0 (the "License");
1640
+ * you may not use this file except in compliance with the License.
1641
+ * You may obtain a copy of the License at
1642
+ *
1643
+ * http://www.apache.org/licenses/LICENSE-2.0
1644
+ *
1645
+ * Unless required by applicable law or agreed to in writing, software
1646
+ * distributed under the License is distributed on an "AS IS" BASIS,
1647
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1648
+ * See the License for the specific language governing permissions and
1649
+ * limitations under the License.
1650
+ */
1651
+ // material_color_utilities is designed to have a consistent API across
1652
+ // platforms and modular components that can be moved around easily. Using a
1653
+ // class as a namespace facilitates this.
1654
+ //
1655
+ // tslint:disable:class-as-namespace
1656
+ /**
1657
+ * Utility methods for calculating contrast given two colors, or calculating a
1658
+ * color given one color and a contrast ratio.
1659
+ *
1660
+ * Contrast ratio is calculated using XYZ's Y. When linearized to match human
1661
+ * perception, Y becomes HCT's tone and L*a*b*'s' L*. Informally, this is the
1662
+ * lightness of a color.
1663
+ *
1664
+ * Methods refer to tone, T in the the HCT color space.
1665
+ * Tone is equivalent to L* in the L*a*b* color space, or L in the LCH color
1666
+ * space.
1667
+ */
1668
+ class Contrast {
1669
+ /**
1670
+ * Returns a contrast ratio, which ranges from 1 to 21.
1671
+ *
1672
+ * @param toneA Tone between 0 and 100. Values outside will be clamped.
1673
+ * @param toneB Tone between 0 and 100. Values outside will be clamped.
1674
+ */
1675
+ static ratioOfTones(toneA, toneB) {
1676
+ toneA = clampDouble(0.0, 100.0, toneA);
1677
+ toneB = clampDouble(0.0, 100.0, toneB);
1678
+ return Contrast.ratioOfYs(yFromLstar(toneA), yFromLstar(toneB));
1679
+ }
1680
+ static ratioOfYs(y1, y2) {
1681
+ const lighter = y1 > y2 ? y1 : y2;
1682
+ const darker = lighter === y2 ? y1 : y2;
1683
+ return (lighter + 5.0) / (darker + 5.0);
1684
+ }
1685
+ /**
1686
+ * Returns a tone >= tone parameter that ensures ratio parameter.
1687
+ * Return value is between 0 and 100.
1688
+ * Returns -1 if ratio cannot be achieved with tone parameter.
1689
+ *
1690
+ * @param tone Tone return value must contrast with.
1691
+ * Range is 0 to 100. Invalid values will result in -1 being returned.
1692
+ * @param ratio Contrast ratio of return value and tone.
1693
+ * Range is 1 to 21, invalid values have undefined behavior.
1694
+ */
1695
+ static lighter(tone, ratio) {
1696
+ if (tone < 0.0 || tone > 100.0) {
1697
+ return -1;
1698
+ }
1699
+ const darkY = yFromLstar(tone);
1700
+ const lightY = ratio * (darkY + 5.0) - 5.0;
1701
+ const realContrast = Contrast.ratioOfYs(lightY, darkY);
1702
+ const delta = Math.abs(realContrast - ratio);
1703
+ if (realContrast < ratio && delta > 0.04) {
1704
+ return -1;
1705
+ }
1706
+ // Ensure gamut mapping, which requires a 'range' on tone, will still result
1707
+ // the correct ratio by darkening slightly.
1708
+ const returnValue = lstarFromY(lightY) + 0.4;
1709
+ if (returnValue < 0 || returnValue > 100) {
1710
+ return -1;
1711
+ }
1712
+ return returnValue;
1713
+ }
1714
+ /**
1715
+ * Returns a tone <= tone parameter that ensures ratio parameter.
1716
+ * Return value is between 0 and 100.
1717
+ * Returns -1 if ratio cannot be achieved with tone parameter.
1718
+ *
1719
+ * @param tone Tone return value must contrast with.
1720
+ * Range is 0 to 100. Invalid values will result in -1 being returned.
1721
+ * @param ratio Contrast ratio of return value and tone.
1722
+ * Range is 1 to 21, invalid values have undefined behavior.
1723
+ */
1724
+ static darker(tone, ratio) {
1725
+ if (tone < 0.0 || tone > 100.0) {
1726
+ return -1;
1727
+ }
1728
+ const lightY = yFromLstar(tone);
1729
+ const darkY = (lightY + 5.0) / ratio - 5.0;
1730
+ const realContrast = Contrast.ratioOfYs(lightY, darkY);
1731
+ const delta = Math.abs(realContrast - ratio);
1732
+ if (realContrast < ratio && delta > 0.04) {
1733
+ return -1;
1734
+ }
1735
+ // Ensure gamut mapping, which requires a 'range' on tone, will still result
1736
+ // the correct ratio by darkening slightly.
1737
+ const returnValue = lstarFromY(darkY) - 0.4;
1738
+ if (returnValue < 0 || returnValue > 100) {
1739
+ return -1;
1740
+ }
1741
+ return returnValue;
1742
+ }
1743
+ /**
1744
+ * Returns a tone >= tone parameter that ensures ratio parameter.
1745
+ * Return value is between 0 and 100.
1746
+ * Returns 100 if ratio cannot be achieved with tone parameter.
1747
+ *
1748
+ * This method is unsafe because the returned value is guaranteed to be in
1749
+ * bounds for tone, i.e. between 0 and 100. However, that value may not reach
1750
+ * the ratio with tone. For example, there is no color lighter than T100.
1751
+ *
1752
+ * @param tone Tone return value must contrast with.
1753
+ * Range is 0 to 100. Invalid values will result in 100 being returned.
1754
+ * @param ratio Desired contrast ratio of return value and tone parameter.
1755
+ * Range is 1 to 21, invalid values have undefined behavior.
1756
+ */
1757
+ static lighterUnsafe(tone, ratio) {
1758
+ const lighterSafe = Contrast.lighter(tone, ratio);
1759
+ return lighterSafe < 0.0 ? 100.0 : lighterSafe;
1760
+ }
1761
+ /**
1762
+ * Returns a tone >= tone parameter that ensures ratio parameter.
1763
+ * Return value is between 0 and 100.
1764
+ * Returns 100 if ratio cannot be achieved with tone parameter.
1765
+ *
1766
+ * This method is unsafe because the returned value is guaranteed to be in
1767
+ * bounds for tone, i.e. between 0 and 100. However, that value may not reach
1768
+ * the [ratio with [tone]. For example, there is no color darker than T0.
1769
+ *
1770
+ * @param tone Tone return value must contrast with.
1771
+ * Range is 0 to 100. Invalid values will result in 0 being returned.
1772
+ * @param ratio Desired contrast ratio of return value and tone parameter.
1773
+ * Range is 1 to 21, invalid values have undefined behavior.
1774
+ */
1775
+ static darkerUnsafe(tone, ratio) {
1776
+ const darkerSafe = Contrast.darker(tone, ratio);
1777
+ return darkerSafe < 0.0 ? 0.0 : darkerSafe;
1778
+ }
1779
+ }
1780
+
1781
+ /**
1782
+ * @license
1783
+ * Copyright 2023 Google LLC
1784
+ *
1785
+ * Licensed under the Apache License, Version 2.0 (the "License");
1786
+ * you may not use this file except in compliance with the License.
1787
+ * You may obtain a copy of the License at
1788
+ *
1789
+ * http://www.apache.org/licenses/LICENSE-2.0
1790
+ *
1791
+ * Unless required by applicable law or agreed to in writing, software
1792
+ * distributed under the License is distributed on an "AS IS" BASIS,
1793
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1794
+ * See the License for the specific language governing permissions and
1795
+ * limitations under the License.
1796
+ */
1797
+ // material_color_utilities is designed to have a consistent API across
1798
+ // platforms and modular components that can be moved around easily. Using a
1799
+ // class as a namespace facilitates this.
1800
+ //
1801
+ // tslint:disable:class-as-namespace
1802
+ /**
1803
+ * Check and/or fix universally disliked colors.
1804
+ * Color science studies of color preference indicate universal distaste for
1805
+ * dark yellow-greens, and also show this is correlated to distate for
1806
+ * biological waste and rotting food.
1807
+ *
1808
+ * See Palmer and Schloss, 2010 or Schloss and Palmer's Chapter 21 in Handbook
1809
+ * of Color Psychology (2015).
1810
+ */
1811
+ class DislikeAnalyzer {
1812
+ /**
1813
+ * Returns true if a color is disliked.
1814
+ *
1815
+ * @param hct A color to be judged.
1816
+ * @return Whether the color is disliked.
1817
+ *
1818
+ * Disliked is defined as a dark yellow-green that is not neutral.
1819
+ */
1820
+ static isDisliked(hct) {
1821
+ const huePasses = Math.round(hct.hue) >= 90.0 && Math.round(hct.hue) <= 111.0;
1822
+ const chromaPasses = Math.round(hct.chroma) > 16.0;
1823
+ const tonePasses = Math.round(hct.tone) < 65.0;
1824
+ return huePasses && chromaPasses && tonePasses;
1825
+ }
1826
+ /**
1827
+ * If a color is disliked, lighten it to make it likable.
1828
+ *
1829
+ * @param hct A color to be judged.
1830
+ * @return A new color if the original color is disliked, or the original
1831
+ * color if it is acceptable.
1832
+ */
1833
+ static fixIfDisliked(hct) {
1834
+ if (DislikeAnalyzer.isDisliked(hct)) {
1835
+ return Hct.from(hct.hue, hct.chroma, 70.0);
1836
+ }
1837
+ return hct;
1838
+ }
1839
+ }
1840
+
1841
+ /**
1842
+ * @license
1843
+ * Copyright 2022 Google LLC
1844
+ *
1845
+ * Licensed under the Apache License, Version 2.0 (the "License");
1846
+ * you may not use this file except in compliance with the License.
1847
+ * You may obtain a copy of the License at
1848
+ *
1849
+ * http://www.apache.org/licenses/LICENSE-2.0
1850
+ *
1851
+ * Unless required by applicable law or agreed to in writing, software
1852
+ * distributed under the License is distributed on an "AS IS" BASIS,
1853
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1854
+ * See the License for the specific language governing permissions and
1855
+ * limitations under the License.
1856
+ */
1857
+ /**
1858
+ * A color that adjusts itself based on UI state provided by DynamicScheme.
1859
+ *
1860
+ * Colors without backgrounds do not change tone when contrast changes. Colors
1861
+ * with backgrounds become closer to their background as contrast lowers, and
1862
+ * further when contrast increases.
1863
+ *
1864
+ * Prefer static constructors. They require either a hexcode, a palette and
1865
+ * tone, or a hue and chroma. Optionally, they can provide a background
1866
+ * DynamicColor.
1867
+ */
1868
+ class DynamicColor {
1869
+ /**
1870
+ * Create a DynamicColor defined by a TonalPalette and HCT tone.
1871
+ *
1872
+ * @param args Functions with DynamicScheme as input. Must provide a palette
1873
+ * and tone. May provide a background DynamicColor and ToneDeltaConstraint.
1874
+ */
1875
+ static fromPalette(args) {
1876
+ return new DynamicColor(args.name ?? '', args.palette, args.tone, args.isBackground ?? false, args.background, args.secondBackground, args.contrastCurve, args.toneDeltaPair);
1877
+ }
1878
+ /**
1879
+ * The base constructor for DynamicColor.
1880
+ *
1881
+ * _Strongly_ prefer using one of the convenience constructors. This class is
1882
+ * arguably too flexible to ensure it can support any scenario. Functional
1883
+ * arguments allow overriding without risks that come with subclasses.
1884
+ *
1885
+ * For example, the default behavior of adjust tone at max contrast
1886
+ * to be at a 7.0 ratio with its background is principled and
1887
+ * matches accessibility guidance. That does not mean it's the desired
1888
+ * approach for _every_ design system, and every color pairing,
1889
+ * always, in every case.
1890
+ *
1891
+ * @param name The name of the dynamic color. Defaults to empty.
1892
+ * @param palette Function that provides a TonalPalette given
1893
+ * DynamicScheme. A TonalPalette is defined by a hue and chroma, so this
1894
+ * replaces the need to specify hue/chroma. By providing a tonal palette, when
1895
+ * contrast adjustments are made, intended chroma can be preserved.
1896
+ * @param tone Function that provides a tone, given a DynamicScheme.
1897
+ * @param isBackground Whether this dynamic color is a background, with
1898
+ * some other color as the foreground. Defaults to false.
1899
+ * @param background The background of the dynamic color (as a function of a
1900
+ * `DynamicScheme`), if it exists.
1901
+ * @param secondBackground A second background of the dynamic color (as a
1902
+ * function of a `DynamicScheme`), if it
1903
+ * exists.
1904
+ * @param contrastCurve A `ContrastCurve` object specifying how its contrast
1905
+ * against its background should behave in various contrast levels options.
1906
+ * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
1907
+ * constraint between two colors. One of them must be the color being
1908
+ * constructed.
1909
+ */
1910
+ constructor(name, palette, tone, isBackground, background, secondBackground, contrastCurve, toneDeltaPair) {
1911
+ this.name = name;
1912
+ this.palette = palette;
1913
+ this.tone = tone;
1914
+ this.isBackground = isBackground;
1915
+ this.background = background;
1916
+ this.secondBackground = secondBackground;
1917
+ this.contrastCurve = contrastCurve;
1918
+ this.toneDeltaPair = toneDeltaPair;
1919
+ this.hctCache = new Map();
1920
+ if (!background && secondBackground) {
1921
+ throw new Error(`Color ${name} has secondBackground` + `defined, but background is not defined.`);
1922
+ }
1923
+ if (!background && contrastCurve) {
1924
+ throw new Error(`Color ${name} has contrastCurve` + `defined, but background is not defined.`);
1925
+ }
1926
+ if (background && !contrastCurve) {
1927
+ throw new Error(`Color ${name} has background` + `defined, but contrastCurve is not defined.`);
1928
+ }
1929
+ }
1930
+ /**
1931
+ * Return a ARGB integer (i.e. a hex code).
1932
+ *
1933
+ * @param scheme Defines the conditions of the user interface, for example,
1934
+ * whether or not it is dark mode or light mode, and what the desired
1935
+ * contrast level is.
1936
+ */
1937
+ getArgb(scheme) {
1938
+ return this.getHct(scheme).toInt();
1939
+ }
1940
+ /**
1941
+ * Return a color, expressed in the HCT color space, that this
1942
+ * DynamicColor is under the conditions in scheme.
1943
+ *
1944
+ * @param scheme Defines the conditions of the user interface, for example,
1945
+ * whether or not it is dark mode or light mode, and what the desired
1946
+ * contrast level is.
1947
+ */
1948
+ getHct(scheme) {
1949
+ const cachedAnswer = this.hctCache.get(scheme);
1950
+ if (cachedAnswer != null) {
1951
+ return cachedAnswer;
1952
+ }
1953
+ const tone = this.getTone(scheme);
1954
+ const answer = this.palette(scheme).getHct(tone);
1955
+ if (this.hctCache.size > 4) {
1956
+ this.hctCache.clear();
1957
+ }
1958
+ this.hctCache.set(scheme, answer);
1959
+ return answer;
1960
+ }
1961
+ /**
1962
+ * Return a tone, T in the HCT color space, that this DynamicColor is under
1963
+ * the conditions in scheme.
1964
+ *
1965
+ * @param scheme Defines the conditions of the user interface, for example,
1966
+ * whether or not it is dark mode or light mode, and what the desired
1967
+ * contrast level is.
1968
+ */
1969
+ getTone(scheme) {
1970
+ const decreasingContrast = scheme.contrastLevel < 0;
1971
+ // Case 1: dual foreground, pair of colors with delta constraint.
1972
+ if (this.toneDeltaPair) {
1973
+ const toneDeltaPair = this.toneDeltaPair(scheme);
1974
+ const roleA = toneDeltaPair.roleA;
1975
+ const roleB = toneDeltaPair.roleB;
1976
+ const delta = toneDeltaPair.delta;
1977
+ const polarity = toneDeltaPair.polarity;
1978
+ const stayTogether = toneDeltaPair.stayTogether;
1979
+ const bg = this.background(scheme);
1980
+ const bgTone = bg.getTone(scheme);
1981
+ const aIsNearer = polarity === 'nearer' || polarity === 'lighter' && !scheme.isDark || polarity === 'darker' && scheme.isDark;
1982
+ const nearer = aIsNearer ? roleA : roleB;
1983
+ const farther = aIsNearer ? roleB : roleA;
1984
+ const amNearer = this.name === nearer.name;
1985
+ const expansionDir = scheme.isDark ? 1 : -1;
1986
+ // 1st round: solve to min, each
1987
+ const nContrast = nearer.contrastCurve.get(scheme.contrastLevel);
1988
+ const fContrast = farther.contrastCurve.get(scheme.contrastLevel);
1989
+ // If a color is good enough, it is not adjusted.
1990
+ // Initial and adjusted tones for `nearer`
1991
+ const nInitialTone = nearer.tone(scheme);
1992
+ let nTone = Contrast.ratioOfTones(bgTone, nInitialTone) >= nContrast ? nInitialTone : DynamicColor.foregroundTone(bgTone, nContrast);
1993
+ // Initial and adjusted tones for `farther`
1994
+ const fInitialTone = farther.tone(scheme);
1995
+ let fTone = Contrast.ratioOfTones(bgTone, fInitialTone) >= fContrast ? fInitialTone : DynamicColor.foregroundTone(bgTone, fContrast);
1996
+ if (decreasingContrast) {
1997
+ // If decreasing contrast, adjust color to the "bare minimum"
1998
+ // that satisfies contrast.
1999
+ nTone = DynamicColor.foregroundTone(bgTone, nContrast);
2000
+ fTone = DynamicColor.foregroundTone(bgTone, fContrast);
2001
+ }
2002
+ if ((fTone - nTone) * expansionDir >= delta) ; else {
2003
+ // 2nd round: expand farther to match delta.
2004
+ fTone = clampDouble(0, 100, nTone + delta * expansionDir);
2005
+ if ((fTone - nTone) * expansionDir >= delta) ; else {
2006
+ // 3rd round: contract nearer to match delta.
2007
+ nTone = clampDouble(0, 100, fTone - delta * expansionDir);
2008
+ }
2009
+ }
2010
+ // Avoids the 50-59 awkward zone.
2011
+ if (50 <= nTone && nTone < 60) {
2012
+ // If `nearer` is in the awkward zone, move it away, together with
2013
+ // `farther`.
2014
+ if (expansionDir > 0) {
2015
+ nTone = 60;
2016
+ fTone = Math.max(fTone, nTone + delta * expansionDir);
2017
+ } else {
2018
+ nTone = 49;
2019
+ fTone = Math.min(fTone, nTone + delta * expansionDir);
2020
+ }
2021
+ } else if (50 <= fTone && fTone < 60) {
2022
+ if (stayTogether) {
2023
+ // Fixes both, to avoid two colors on opposite sides of the "awkward
2024
+ // zone".
2025
+ if (expansionDir > 0) {
2026
+ nTone = 60;
2027
+ fTone = Math.max(fTone, nTone + delta * expansionDir);
2028
+ } else {
2029
+ nTone = 49;
2030
+ fTone = Math.min(fTone, nTone + delta * expansionDir);
2031
+ }
2032
+ } else {
2033
+ // Not required to stay together; fixes just one.
2034
+ if (expansionDir > 0) {
2035
+ fTone = 60;
2036
+ } else {
2037
+ fTone = 49;
2038
+ }
2039
+ }
2040
+ }
2041
+ // Returns `nTone` if this color is `nearer`, otherwise `fTone`.
2042
+ return amNearer ? nTone : fTone;
2043
+ } else {
2044
+ // Case 2: No contrast pair; just solve for itself.
2045
+ let answer = this.tone(scheme);
2046
+ if (this.background == null) {
2047
+ return answer; // No adjustment for colors with no background.
2048
+ }
2049
+ const bgTone = this.background(scheme).getTone(scheme);
2050
+ const desiredRatio = this.contrastCurve.get(scheme.contrastLevel);
2051
+ if (Contrast.ratioOfTones(bgTone, answer) >= desiredRatio) ; else {
2052
+ // Rough improvement.
2053
+ answer = DynamicColor.foregroundTone(bgTone, desiredRatio);
2054
+ }
2055
+ if (decreasingContrast) {
2056
+ answer = DynamicColor.foregroundTone(bgTone, desiredRatio);
2057
+ }
2058
+ if (this.isBackground && 50 <= answer && answer < 60) {
2059
+ // Must adjust
2060
+ if (Contrast.ratioOfTones(49, bgTone) >= desiredRatio) {
2061
+ answer = 49;
2062
+ } else {
2063
+ answer = 60;
2064
+ }
2065
+ }
2066
+ if (this.secondBackground) {
2067
+ // Case 3: Adjust for dual backgrounds.
2068
+ const [bg1, bg2] = [this.background, this.secondBackground];
2069
+ const [bgTone1, bgTone2] = [bg1(scheme).getTone(scheme), bg2(scheme).getTone(scheme)];
2070
+ const [upper, lower] = [Math.max(bgTone1, bgTone2), Math.min(bgTone1, bgTone2)];
2071
+ if (Contrast.ratioOfTones(upper, answer) >= desiredRatio && Contrast.ratioOfTones(lower, answer) >= desiredRatio) {
2072
+ return answer;
2073
+ }
2074
+ // The darkest light tone that satisfies the desired ratio,
2075
+ // or -1 if such ratio cannot be reached.
2076
+ const lightOption = Contrast.lighter(upper, desiredRatio);
2077
+ // The lightest dark tone that satisfies the desired ratio,
2078
+ // or -1 if such ratio cannot be reached.
2079
+ const darkOption = Contrast.darker(lower, desiredRatio);
2080
+ // Tones suitable for the foreground.
2081
+ const availables = [];
2082
+ if (lightOption !== -1) availables.push(lightOption);
2083
+ if (darkOption !== -1) availables.push(darkOption);
2084
+ const prefersLight = DynamicColor.tonePrefersLightForeground(bgTone1) || DynamicColor.tonePrefersLightForeground(bgTone2);
2085
+ if (prefersLight) {
2086
+ return lightOption < 0 ? 100 : lightOption;
2087
+ }
2088
+ if (availables.length === 1) {
2089
+ return availables[0];
2090
+ }
2091
+ return darkOption < 0 ? 0 : darkOption;
2092
+ }
2093
+ return answer;
2094
+ }
2095
+ }
2096
+ /**
2097
+ * Given a background tone, find a foreground tone, while ensuring they reach
2098
+ * a contrast ratio that is as close to [ratio] as possible.
2099
+ *
2100
+ * @param bgTone Tone in HCT. Range is 0 to 100, undefined behavior when it
2101
+ * falls outside that range.
2102
+ * @param ratio The contrast ratio desired between bgTone and the return
2103
+ * value.
2104
+ */
2105
+ static foregroundTone(bgTone, ratio) {
2106
+ const lighterTone = Contrast.lighterUnsafe(bgTone, ratio);
2107
+ const darkerTone = Contrast.darkerUnsafe(bgTone, ratio);
2108
+ const lighterRatio = Contrast.ratioOfTones(lighterTone, bgTone);
2109
+ const darkerRatio = Contrast.ratioOfTones(darkerTone, bgTone);
2110
+ const preferLighter = DynamicColor.tonePrefersLightForeground(bgTone);
2111
+ if (preferLighter) {
2112
+ // This handles an edge case where the initial contrast ratio is high
2113
+ // (ex. 13.0), and the ratio passed to the function is that high
2114
+ // ratio, and both the lighter and darker ratio fails to pass that
2115
+ // ratio.
2116
+ //
2117
+ // This was observed with Tonal Spot's On Primary Container turning
2118
+ // black momentarily between high and max contrast in light mode. PC's
2119
+ // standard tone was T90, OPC's was T10, it was light mode, and the
2120
+ // contrast value was 0.6568521221032331.
2121
+ const negligibleDifference = Math.abs(lighterRatio - darkerRatio) < 0.1 && lighterRatio < ratio && darkerRatio < ratio;
2122
+ return lighterRatio >= ratio || lighterRatio >= darkerRatio || negligibleDifference ? lighterTone : darkerTone;
2123
+ } else {
2124
+ return darkerRatio >= ratio || darkerRatio >= lighterRatio ? darkerTone : lighterTone;
2125
+ }
2126
+ }
2127
+ /**
2128
+ * Returns whether [tone] prefers a light foreground.
2129
+ *
2130
+ * People prefer white foregrounds on ~T60-70. Observed over time, and also
2131
+ * by Andrew Somers during research for APCA.
2132
+ *
2133
+ * T60 used as to create the smallest discontinuity possible when skipping
2134
+ * down to T49 in order to ensure light foregrounds.
2135
+ * Since `tertiaryContainer` in dark monochrome scheme requires a tone of
2136
+ * 60, it should not be adjusted. Therefore, 60 is excluded here.
2137
+ */
2138
+ static tonePrefersLightForeground(tone) {
2139
+ return Math.round(tone) < 60.0;
2140
+ }
2141
+ /**
2142
+ * Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter
2143
+ * color.
2144
+ */
2145
+ static toneAllowsLightForeground(tone) {
2146
+ return Math.round(tone) <= 49.0;
2147
+ }
2148
+ /**
2149
+ * Adjust a tone such that white has 4.5 contrast, if the tone is
2150
+ * reasonably close to supporting it.
2151
+ */
2152
+ static enableLightForeground(tone) {
2153
+ if (DynamicColor.tonePrefersLightForeground(tone) && !DynamicColor.toneAllowsLightForeground(tone)) {
2154
+ return 49.0;
2155
+ }
2156
+ return tone;
2157
+ }
2158
+ }
2159
+
2160
+ /**
2161
+ * @license
2162
+ * Copyright 2021 Google LLC
2163
+ *
2164
+ * Licensed under the Apache License, Version 2.0 (the "License");
2165
+ * you may not use this file except in compliance with the License.
2166
+ * You may obtain a copy of the License at
2167
+ *
2168
+ * http://www.apache.org/licenses/LICENSE-2.0
2169
+ *
2170
+ * Unless required by applicable law or agreed to in writing, software
2171
+ * distributed under the License is distributed on an "AS IS" BASIS,
2172
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2173
+ * See the License for the specific language governing permissions and
2174
+ * limitations under the License.
2175
+ */
2176
+ /**
2177
+ * A convenience class for retrieving colors that are constant in hue and
2178
+ * chroma, but vary in tone.
2179
+ */
2180
+ class TonalPalette {
2181
+ /**
2182
+ * @param argb ARGB representation of a color
2183
+ * @return Tones matching that color's hue and chroma.
2184
+ */
2185
+ static fromInt(argb) {
2186
+ const hct = Hct.fromInt(argb);
2187
+ return TonalPalette.fromHct(hct);
2188
+ }
2189
+ /**
2190
+ * @param hct Hct
2191
+ * @return Tones matching that color's hue and chroma.
2192
+ */
2193
+ static fromHct(hct) {
2194
+ return new TonalPalette(hct.hue, hct.chroma, hct);
2195
+ }
2196
+ /**
2197
+ * @param hue HCT hue
2198
+ * @param chroma HCT chroma
2199
+ * @return Tones matching hue and chroma.
2200
+ */
2201
+ static fromHueAndChroma(hue, chroma) {
2202
+ const keyColor = new KeyColor(hue, chroma).create();
2203
+ return new TonalPalette(hue, chroma, keyColor);
2204
+ }
2205
+ constructor(hue, chroma, keyColor) {
2206
+ this.hue = hue;
2207
+ this.chroma = chroma;
2208
+ this.keyColor = keyColor;
2209
+ this.cache = new Map();
2210
+ }
2211
+ /**
2212
+ * @param tone HCT tone, measured from 0 to 100.
2213
+ * @return ARGB representation of a color with that tone.
2214
+ */
2215
+ tone(tone) {
2216
+ let argb = this.cache.get(tone);
2217
+ if (argb === undefined) {
2218
+ argb = Hct.from(this.hue, this.chroma, tone).toInt();
2219
+ this.cache.set(tone, argb);
2220
+ }
2221
+ return argb;
2222
+ }
2223
+ /**
2224
+ * @param tone HCT tone.
2225
+ * @return HCT representation of a color with that tone.
2226
+ */
2227
+ getHct(tone) {
2228
+ return Hct.fromInt(this.tone(tone));
2229
+ }
2230
+ }
2231
+ /**
2232
+ * Key color is a color that represents the hue and chroma of a tonal palette
2233
+ */
2234
+ class KeyColor {
2235
+ constructor(hue, requestedChroma) {
2236
+ this.hue = hue;
2237
+ this.requestedChroma = requestedChroma;
2238
+ // Cache that maps tone to max chroma to avoid duplicated HCT calculation.
2239
+ this.chromaCache = new Map();
2240
+ this.maxChromaValue = 200.0;
2241
+ }
2242
+ /**
2243
+ * Creates a key color from a [hue] and a [chroma].
2244
+ * The key color is the first tone, starting from T50, matching the given hue
2245
+ * and chroma.
2246
+ *
2247
+ * @return Key color [Hct]
2248
+ */
2249
+ create() {
2250
+ // Pivot around T50 because T50 has the most chroma available, on
2251
+ // average. Thus it is most likely to have a direct answer.
2252
+ const pivotTone = 50;
2253
+ const toneStepSize = 1;
2254
+ // Epsilon to accept values slightly higher than the requested chroma.
2255
+ const epsilon = 0.01;
2256
+ // Binary search to find the tone that can provide a chroma that is closest
2257
+ // to the requested chroma.
2258
+ let lowerTone = 0;
2259
+ let upperTone = 100;
2260
+ while (lowerTone < upperTone) {
2261
+ const midTone = Math.floor((lowerTone + upperTone) / 2);
2262
+ const isAscending = this.maxChroma(midTone) < this.maxChroma(midTone + toneStepSize);
2263
+ const sufficientChroma = this.maxChroma(midTone) >= this.requestedChroma - epsilon;
2264
+ if (sufficientChroma) {
2265
+ // Either range [lowerTone, midTone] or [midTone, upperTone] has
2266
+ // the answer, so search in the range that is closer the pivot tone.
2267
+ if (Math.abs(lowerTone - pivotTone) < Math.abs(upperTone - pivotTone)) {
2268
+ upperTone = midTone;
2269
+ } else {
2270
+ if (lowerTone === midTone) {
2271
+ return Hct.from(this.hue, this.requestedChroma, lowerTone);
2272
+ }
2273
+ lowerTone = midTone;
2274
+ }
2275
+ } else {
2276
+ // As there is no sufficient chroma in the midTone, follow the direction
2277
+ // to the chroma peak.
2278
+ if (isAscending) {
2279
+ lowerTone = midTone + toneStepSize;
2280
+ } else {
2281
+ // Keep midTone for potential chroma peak.
2282
+ upperTone = midTone;
2283
+ }
2284
+ }
2285
+ }
2286
+ return Hct.from(this.hue, this.requestedChroma, lowerTone);
2287
+ }
2288
+ // Find the maximum chroma for a given tone
2289
+ maxChroma(tone) {
2290
+ if (this.chromaCache.has(tone)) {
2291
+ return this.chromaCache.get(tone);
2292
+ }
2293
+ const chroma = Hct.from(this.hue, this.maxChromaValue, tone).chroma;
2294
+ this.chromaCache.set(tone, chroma);
2295
+ return chroma;
2296
+ }
2297
+ }
2298
+
2299
+ /**
2300
+ * @license
2301
+ * Copyright 2023 Google LLC
2302
+ *
2303
+ * Licensed under the Apache License, Version 2.0 (the "License");
2304
+ * you may not use this file except in compliance with the License.
2305
+ * You may obtain a copy of the License at
2306
+ *
2307
+ * http://www.apache.org/licenses/LICENSE-2.0
2308
+ *
2309
+ * Unless required by applicable law or agreed to in writing, software
2310
+ * distributed under the License is distributed on an "AS IS" BASIS,
2311
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2312
+ * See the License for the specific language governing permissions and
2313
+ * limitations under the License.
2314
+ */
2315
+ /**
2316
+ * A class containing a value that changes with the contrast level.
2317
+ *
2318
+ * Usually represents the contrast requirements for a dynamic color on its
2319
+ * background. The four values correspond to values for contrast levels -1.0,
2320
+ * 0.0, 0.5, and 1.0, respectively.
2321
+ */
2322
+ class ContrastCurve {
2323
+ /**
2324
+ * Creates a `ContrastCurve` object.
2325
+ *
2326
+ * @param low Value for contrast level -1.0
2327
+ * @param normal Value for contrast level 0.0
2328
+ * @param medium Value for contrast level 0.5
2329
+ * @param high Value for contrast level 1.0
2330
+ */
2331
+ constructor(low, normal, medium, high) {
2332
+ this.low = low;
2333
+ this.normal = normal;
2334
+ this.medium = medium;
2335
+ this.high = high;
2336
+ }
2337
+ /**
2338
+ * Returns the value at a given contrast level.
2339
+ *
2340
+ * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
2341
+ * is the lowest; 1.0 is the highest.
2342
+ * @return The value. For contrast ratios, a number between 1.0 and 21.0.
2343
+ */
2344
+ get(contrastLevel) {
2345
+ if (contrastLevel <= -1) {
2346
+ return this.low;
2347
+ } else if (contrastLevel < 0.0) {
2348
+ return lerp(this.low, this.normal, (contrastLevel - -1) / 1);
2349
+ } else if (contrastLevel < 0.5) {
2350
+ return lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5);
2351
+ } else if (contrastLevel < 1.0) {
2352
+ return lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5);
2353
+ } else {
2354
+ return this.high;
2355
+ }
2356
+ }
2357
+ }
2358
+
2359
+ /**
2360
+ * @license
2361
+ * Copyright 2023 Google LLC
2362
+ *
2363
+ * Licensed under the Apache License, Version 2.0 (the "License");
2364
+ * you may not use this file except in compliance with the License.
2365
+ * You may obtain a copy of the License at
2366
+ *
2367
+ * http://www.apache.org/licenses/LICENSE-2.0
2368
+ *
2369
+ * Unless required by applicable law or agreed to in writing, software
2370
+ * distributed under the License is distributed on an "AS IS" BASIS,
2371
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2372
+ * See the License for the specific language governing permissions and
2373
+ * limitations under the License.
2374
+ */
2375
+ /**
2376
+ * Documents a constraint between two DynamicColors, in which their tones must
2377
+ * have a certain distance from each other.
2378
+ *
2379
+ * Prefer a DynamicColor with a background, this is for special cases when
2380
+ * designers want tonal distance, literally contrast, between two colors that
2381
+ * don't have a background / foreground relationship or a contrast guarantee.
2382
+ */
2383
+ class ToneDeltaPair {
2384
+ /**
2385
+ * Documents a constraint in tone distance between two DynamicColors.
2386
+ *
2387
+ * The polarity is an adjective that describes "A", compared to "B".
2388
+ *
2389
+ * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
2390
+ * A's tone should be at least 15 darker than B's.
2391
+ *
2392
+ * 'nearer' and 'farther' describes closeness to the surface roles. For
2393
+ * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
2394
+ * should be 10 lighter than B in light mode, and 10 darker than B in dark
2395
+ * mode.
2396
+ *
2397
+ * @param roleA The first role in a pair.
2398
+ * @param roleB The second role in a pair.
2399
+ * @param delta Required difference between tones. Absolute value, negative
2400
+ * values have undefined behavior.
2401
+ * @param polarity The relative relation between tones of roleA and roleB,
2402
+ * as described above.
2403
+ * @param stayTogether Whether these two roles should stay on the same side of
2404
+ * the "awkward zone" (T50-59). This is necessary for certain cases where
2405
+ * one role has two backgrounds.
2406
+ */
2407
+ constructor(roleA, roleB, delta, polarity, stayTogether) {
2408
+ this.roleA = roleA;
2409
+ this.roleB = roleB;
2410
+ this.delta = delta;
2411
+ this.polarity = polarity;
2412
+ this.stayTogether = stayTogether;
2413
+ }
2414
+ }
2415
+
2416
+ /**
2417
+ * @license
2418
+ * Copyright 2022 Google LLC
2419
+ *
2420
+ * Licensed under the Apache License, Version 2.0 (the "License");
2421
+ * you may not use this file except in compliance with the License.
2422
+ * You may obtain a copy of the License at
2423
+ *
2424
+ * http://www.apache.org/licenses/LICENSE-2.0
2425
+ *
2426
+ * Unless required by applicable law or agreed to in writing, software
2427
+ * distributed under the License is distributed on an "AS IS" BASIS,
2428
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2429
+ * See the License for the specific language governing permissions and
2430
+ * limitations under the License.
2431
+ */
2432
+ /**
2433
+ * Set of themes supported by Dynamic Color.
2434
+ * Instantiate the corresponding subclass, ex. SchemeTonalSpot, to create
2435
+ * colors corresponding to the theme.
2436
+ */
2437
+ var Variant;
2438
+ (function (Variant) {
2439
+ Variant[Variant["MONOCHROME"] = 0] = "MONOCHROME";
2440
+ Variant[Variant["NEUTRAL"] = 1] = "NEUTRAL";
2441
+ Variant[Variant["TONAL_SPOT"] = 2] = "TONAL_SPOT";
2442
+ Variant[Variant["VIBRANT"] = 3] = "VIBRANT";
2443
+ Variant[Variant["EXPRESSIVE"] = 4] = "EXPRESSIVE";
2444
+ Variant[Variant["FIDELITY"] = 5] = "FIDELITY";
2445
+ Variant[Variant["CONTENT"] = 6] = "CONTENT";
2446
+ Variant[Variant["RAINBOW"] = 7] = "RAINBOW";
2447
+ Variant[Variant["FRUIT_SALAD"] = 8] = "FRUIT_SALAD";
2448
+ })(Variant || (Variant = {}));
2449
+
2450
+ /**
2451
+ * @license
2452
+ * Copyright 2022 Google LLC
2453
+ *
2454
+ * Licensed under the Apache License, Version 2.0 (the "License");
2455
+ * you may not use this file except in compliance with the License.
2456
+ * You may obtain a copy of the License at
2457
+ *
2458
+ * http://www.apache.org/licenses/LICENSE-2.0
2459
+ *
2460
+ * Unless required by applicable law or agreed to in writing, software
2461
+ * distributed under the License is distributed on an "AS IS" BASIS,
2462
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2463
+ * See the License for the specific language governing permissions and
2464
+ * limitations under the License.
2465
+ */
2466
+ function isFidelity(scheme) {
2467
+ return scheme.variant === Variant.FIDELITY || scheme.variant === Variant.CONTENT;
2468
+ }
2469
+ function isMonochrome(scheme) {
2470
+ return scheme.variant === Variant.MONOCHROME;
2471
+ }
2472
+ function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
2473
+ let answer = tone;
2474
+ let closestToChroma = Hct.from(hue, chroma, tone);
2475
+ if (closestToChroma.chroma < chroma) {
2476
+ let chromaPeak = closestToChroma.chroma;
2477
+ while (closestToChroma.chroma < chroma) {
2478
+ answer += byDecreasingTone ? -1 : 1.0;
2479
+ const potentialSolution = Hct.from(hue, chroma, answer);
2480
+ if (chromaPeak > potentialSolution.chroma) {
2481
+ break;
2482
+ }
2483
+ if (Math.abs(potentialSolution.chroma - chroma) < 0.4) {
2484
+ break;
2485
+ }
2486
+ const potentialDelta = Math.abs(potentialSolution.chroma - chroma);
2487
+ const currentDelta = Math.abs(closestToChroma.chroma - chroma);
2488
+ if (potentialDelta < currentDelta) {
2489
+ closestToChroma = potentialSolution;
2490
+ }
2491
+ chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);
2492
+ }
2493
+ }
2494
+ return answer;
2495
+ }
2496
+ /**
2497
+ * DynamicColors for the colors in the Material Design system.
2498
+ */
2499
+ // Material Color Utilities namespaces the various utilities it provides.
2500
+ // tslint:disable-next-line:class-as-namespace
2501
+ class MaterialDynamicColors {
2502
+ static highestSurface(s) {
2503
+ return s.isDark ? MaterialDynamicColors.surfaceBright : MaterialDynamicColors.surfaceDim;
2504
+ }
2505
+ }
2506
+ MaterialDynamicColors.contentAccentToneDelta = 15.0;
2507
+ MaterialDynamicColors.primaryPaletteKeyColor = DynamicColor.fromPalette({
2508
+ name: 'primary_palette_key_color',
2509
+ palette: s => s.primaryPalette,
2510
+ tone: s => s.primaryPalette.keyColor.tone
2511
+ });
2512
+ MaterialDynamicColors.secondaryPaletteKeyColor = DynamicColor.fromPalette({
2513
+ name: 'secondary_palette_key_color',
2514
+ palette: s => s.secondaryPalette,
2515
+ tone: s => s.secondaryPalette.keyColor.tone
2516
+ });
2517
+ MaterialDynamicColors.tertiaryPaletteKeyColor = DynamicColor.fromPalette({
2518
+ name: 'tertiary_palette_key_color',
2519
+ palette: s => s.tertiaryPalette,
2520
+ tone: s => s.tertiaryPalette.keyColor.tone
2521
+ });
2522
+ MaterialDynamicColors.neutralPaletteKeyColor = DynamicColor.fromPalette({
2523
+ name: 'neutral_palette_key_color',
2524
+ palette: s => s.neutralPalette,
2525
+ tone: s => s.neutralPalette.keyColor.tone
2526
+ });
2527
+ MaterialDynamicColors.neutralVariantPaletteKeyColor = DynamicColor.fromPalette({
2528
+ name: 'neutral_variant_palette_key_color',
2529
+ palette: s => s.neutralVariantPalette,
2530
+ tone: s => s.neutralVariantPalette.keyColor.tone
2531
+ });
2532
+ MaterialDynamicColors.background = DynamicColor.fromPalette({
2533
+ name: 'background',
2534
+ palette: s => s.neutralPalette,
2535
+ tone: s => s.isDark ? 6 : 98,
2536
+ isBackground: true
2537
+ });
2538
+ MaterialDynamicColors.onBackground = DynamicColor.fromPalette({
2539
+ name: 'on_background',
2540
+ palette: s => s.neutralPalette,
2541
+ tone: s => s.isDark ? 90 : 10,
2542
+ background: s => MaterialDynamicColors.background,
2543
+ contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
2544
+ });
2545
+ MaterialDynamicColors.surface = DynamicColor.fromPalette({
2546
+ name: 'surface',
2547
+ palette: s => s.neutralPalette,
2548
+ tone: s => s.isDark ? 6 : 98,
2549
+ isBackground: true
2550
+ });
2551
+ MaterialDynamicColors.surfaceDim = DynamicColor.fromPalette({
2552
+ name: 'surface_dim',
2553
+ palette: s => s.neutralPalette,
2554
+ tone: s => s.isDark ? 6 : new ContrastCurve(87, 87, 80, 75).get(s.contrastLevel),
2555
+ isBackground: true
2556
+ });
2557
+ MaterialDynamicColors.surfaceBright = DynamicColor.fromPalette({
2558
+ name: 'surface_bright',
2559
+ palette: s => s.neutralPalette,
2560
+ tone: s => s.isDark ? new ContrastCurve(24, 24, 29, 34).get(s.contrastLevel) : 98,
2561
+ isBackground: true
2562
+ });
2563
+ MaterialDynamicColors.surfaceContainerLowest = DynamicColor.fromPalette({
2564
+ name: 'surface_container_lowest',
2565
+ palette: s => s.neutralPalette,
2566
+ tone: s => s.isDark ? new ContrastCurve(4, 4, 2, 0).get(s.contrastLevel) : 100,
2567
+ isBackground: true
2568
+ });
2569
+ MaterialDynamicColors.surfaceContainerLow = DynamicColor.fromPalette({
2570
+ name: 'surface_container_low',
2571
+ palette: s => s.neutralPalette,
2572
+ tone: s => s.isDark ? new ContrastCurve(10, 10, 11, 12).get(s.contrastLevel) : new ContrastCurve(96, 96, 96, 95).get(s.contrastLevel),
2573
+ isBackground: true
2574
+ });
2575
+ MaterialDynamicColors.surfaceContainer = DynamicColor.fromPalette({
2576
+ name: 'surface_container',
2577
+ palette: s => s.neutralPalette,
2578
+ tone: s => s.isDark ? new ContrastCurve(12, 12, 16, 20).get(s.contrastLevel) : new ContrastCurve(94, 94, 92, 90).get(s.contrastLevel),
2579
+ isBackground: true
2580
+ });
2581
+ MaterialDynamicColors.surfaceContainerHigh = DynamicColor.fromPalette({
2582
+ name: 'surface_container_high',
2583
+ palette: s => s.neutralPalette,
2584
+ tone: s => s.isDark ? new ContrastCurve(17, 17, 21, 25).get(s.contrastLevel) : new ContrastCurve(92, 92, 88, 85).get(s.contrastLevel),
2585
+ isBackground: true
2586
+ });
2587
+ MaterialDynamicColors.surfaceContainerHighest = DynamicColor.fromPalette({
2588
+ name: 'surface_container_highest',
2589
+ palette: s => s.neutralPalette,
2590
+ tone: s => s.isDark ? new ContrastCurve(22, 22, 26, 30).get(s.contrastLevel) : new ContrastCurve(90, 90, 84, 80).get(s.contrastLevel),
2591
+ isBackground: true
2592
+ });
2593
+ MaterialDynamicColors.onSurface = DynamicColor.fromPalette({
2594
+ name: 'on_surface',
2595
+ palette: s => s.neutralPalette,
2596
+ tone: s => s.isDark ? 90 : 10,
2597
+ background: s => MaterialDynamicColors.highestSurface(s),
2598
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2599
+ });
2600
+ MaterialDynamicColors.surfaceVariant = DynamicColor.fromPalette({
2601
+ name: 'surface_variant',
2602
+ palette: s => s.neutralVariantPalette,
2603
+ tone: s => s.isDark ? 30 : 90,
2604
+ isBackground: true
2605
+ });
2606
+ MaterialDynamicColors.onSurfaceVariant = DynamicColor.fromPalette({
2607
+ name: 'on_surface_variant',
2608
+ palette: s => s.neutralVariantPalette,
2609
+ tone: s => s.isDark ? 80 : 30,
2610
+ background: s => MaterialDynamicColors.highestSurface(s),
2611
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2612
+ });
2613
+ MaterialDynamicColors.inverseSurface = DynamicColor.fromPalette({
2614
+ name: 'inverse_surface',
2615
+ palette: s => s.neutralPalette,
2616
+ tone: s => s.isDark ? 90 : 20
2617
+ });
2618
+ MaterialDynamicColors.inverseOnSurface = DynamicColor.fromPalette({
2619
+ name: 'inverse_on_surface',
2620
+ palette: s => s.neutralPalette,
2621
+ tone: s => s.isDark ? 20 : 95,
2622
+ background: s => MaterialDynamicColors.inverseSurface,
2623
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2624
+ });
2625
+ MaterialDynamicColors.outline = DynamicColor.fromPalette({
2626
+ name: 'outline',
2627
+ palette: s => s.neutralVariantPalette,
2628
+ tone: s => s.isDark ? 60 : 50,
2629
+ background: s => MaterialDynamicColors.highestSurface(s),
2630
+ contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
2631
+ });
2632
+ MaterialDynamicColors.outlineVariant = DynamicColor.fromPalette({
2633
+ name: 'outline_variant',
2634
+ palette: s => s.neutralVariantPalette,
2635
+ tone: s => s.isDark ? 30 : 80,
2636
+ background: s => MaterialDynamicColors.highestSurface(s),
2637
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5)
2638
+ });
2639
+ MaterialDynamicColors.shadow = DynamicColor.fromPalette({
2640
+ name: 'shadow',
2641
+ palette: s => s.neutralPalette,
2642
+ tone: s => 0
2643
+ });
2644
+ MaterialDynamicColors.scrim = DynamicColor.fromPalette({
2645
+ name: 'scrim',
2646
+ palette: s => s.neutralPalette,
2647
+ tone: s => 0
2648
+ });
2649
+ MaterialDynamicColors.surfaceTint = DynamicColor.fromPalette({
2650
+ name: 'surface_tint',
2651
+ palette: s => s.primaryPalette,
2652
+ tone: s => s.isDark ? 80 : 40,
2653
+ isBackground: true
2654
+ });
2655
+ MaterialDynamicColors.primary = DynamicColor.fromPalette({
2656
+ name: 'primary',
2657
+ palette: s => s.primaryPalette,
2658
+ tone: s => {
2659
+ if (isMonochrome(s)) {
2660
+ return s.isDark ? 100 : 0;
2661
+ }
2662
+ return s.isDark ? 80 : 40;
2663
+ },
2664
+ isBackground: true,
2665
+ background: s => MaterialDynamicColors.highestSurface(s),
2666
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 7),
2667
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary, 10, 'nearer', false)
2668
+ });
2669
+ MaterialDynamicColors.onPrimary = DynamicColor.fromPalette({
2670
+ name: 'on_primary',
2671
+ palette: s => s.primaryPalette,
2672
+ tone: s => {
2673
+ if (isMonochrome(s)) {
2674
+ return s.isDark ? 10 : 90;
2675
+ }
2676
+ return s.isDark ? 20 : 100;
2677
+ },
2678
+ background: s => MaterialDynamicColors.primary,
2679
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2680
+ });
2681
+ MaterialDynamicColors.primaryContainer = DynamicColor.fromPalette({
2682
+ name: 'primary_container',
2683
+ palette: s => s.primaryPalette,
2684
+ tone: s => {
2685
+ if (isFidelity(s)) {
2686
+ return s.sourceColorHct.tone;
2687
+ }
2688
+ if (isMonochrome(s)) {
2689
+ return s.isDark ? 85 : 25;
2690
+ }
2691
+ return s.isDark ? 30 : 90;
2692
+ },
2693
+ isBackground: true,
2694
+ background: s => MaterialDynamicColors.highestSurface(s),
2695
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2696
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary, 10, 'nearer', false)
2697
+ });
2698
+ MaterialDynamicColors.onPrimaryContainer = DynamicColor.fromPalette({
2699
+ name: 'on_primary_container',
2700
+ palette: s => s.primaryPalette,
2701
+ tone: s => {
2702
+ if (isFidelity(s)) {
2703
+ return DynamicColor.foregroundTone(MaterialDynamicColors.primaryContainer.tone(s), 4.5);
2704
+ }
2705
+ if (isMonochrome(s)) {
2706
+ return s.isDark ? 0 : 100;
2707
+ }
2708
+ return s.isDark ? 90 : 30;
2709
+ },
2710
+ background: s => MaterialDynamicColors.primaryContainer,
2711
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2712
+ });
2713
+ MaterialDynamicColors.inversePrimary = DynamicColor.fromPalette({
2714
+ name: 'inverse_primary',
2715
+ palette: s => s.primaryPalette,
2716
+ tone: s => s.isDark ? 40 : 80,
2717
+ background: s => MaterialDynamicColors.inverseSurface,
2718
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 7)
2719
+ });
2720
+ MaterialDynamicColors.secondary = DynamicColor.fromPalette({
2721
+ name: 'secondary',
2722
+ palette: s => s.secondaryPalette,
2723
+ tone: s => s.isDark ? 80 : 40,
2724
+ isBackground: true,
2725
+ background: s => MaterialDynamicColors.highestSurface(s),
2726
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 7),
2727
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.secondaryContainer, MaterialDynamicColors.secondary, 10, 'nearer', false)
2728
+ });
2729
+ MaterialDynamicColors.onSecondary = DynamicColor.fromPalette({
2730
+ name: 'on_secondary',
2731
+ palette: s => s.secondaryPalette,
2732
+ tone: s => {
2733
+ if (isMonochrome(s)) {
2734
+ return s.isDark ? 10 : 100;
2735
+ } else {
2736
+ return s.isDark ? 20 : 100;
2737
+ }
2738
+ },
2739
+ background: s => MaterialDynamicColors.secondary,
2740
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2741
+ });
2742
+ MaterialDynamicColors.secondaryContainer = DynamicColor.fromPalette({
2743
+ name: 'secondary_container',
2744
+ palette: s => s.secondaryPalette,
2745
+ tone: s => {
2746
+ const initialTone = s.isDark ? 30 : 90;
2747
+ if (isMonochrome(s)) {
2748
+ return s.isDark ? 30 : 85;
2749
+ }
2750
+ if (!isFidelity(s)) {
2751
+ return initialTone;
2752
+ }
2753
+ return findDesiredChromaByTone(s.secondaryPalette.hue, s.secondaryPalette.chroma, initialTone, s.isDark ? false : true);
2754
+ },
2755
+ isBackground: true,
2756
+ background: s => MaterialDynamicColors.highestSurface(s),
2757
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2758
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.secondaryContainer, MaterialDynamicColors.secondary, 10, 'nearer', false)
2759
+ });
2760
+ MaterialDynamicColors.onSecondaryContainer = DynamicColor.fromPalette({
2761
+ name: 'on_secondary_container',
2762
+ palette: s => s.secondaryPalette,
2763
+ tone: s => {
2764
+ if (isMonochrome(s)) {
2765
+ return s.isDark ? 90 : 10;
2766
+ }
2767
+ if (!isFidelity(s)) {
2768
+ return s.isDark ? 90 : 30;
2769
+ }
2770
+ return DynamicColor.foregroundTone(MaterialDynamicColors.secondaryContainer.tone(s), 4.5);
2771
+ },
2772
+ background: s => MaterialDynamicColors.secondaryContainer,
2773
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2774
+ });
2775
+ MaterialDynamicColors.tertiary = DynamicColor.fromPalette({
2776
+ name: 'tertiary',
2777
+ palette: s => s.tertiaryPalette,
2778
+ tone: s => {
2779
+ if (isMonochrome(s)) {
2780
+ return s.isDark ? 90 : 25;
2781
+ }
2782
+ return s.isDark ? 80 : 40;
2783
+ },
2784
+ isBackground: true,
2785
+ background: s => MaterialDynamicColors.highestSurface(s),
2786
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 7),
2787
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary, 10, 'nearer', false)
2788
+ });
2789
+ MaterialDynamicColors.onTertiary = DynamicColor.fromPalette({
2790
+ name: 'on_tertiary',
2791
+ palette: s => s.tertiaryPalette,
2792
+ tone: s => {
2793
+ if (isMonochrome(s)) {
2794
+ return s.isDark ? 10 : 90;
2795
+ }
2796
+ return s.isDark ? 20 : 100;
2797
+ },
2798
+ background: s => MaterialDynamicColors.tertiary,
2799
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2800
+ });
2801
+ MaterialDynamicColors.tertiaryContainer = DynamicColor.fromPalette({
2802
+ name: 'tertiary_container',
2803
+ palette: s => s.tertiaryPalette,
2804
+ tone: s => {
2805
+ if (isMonochrome(s)) {
2806
+ return s.isDark ? 60 : 49;
2807
+ }
2808
+ if (!isFidelity(s)) {
2809
+ return s.isDark ? 30 : 90;
2810
+ }
2811
+ const proposedHct = s.tertiaryPalette.getHct(s.sourceColorHct.tone);
2812
+ return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
2813
+ },
2814
+ isBackground: true,
2815
+ background: s => MaterialDynamicColors.highestSurface(s),
2816
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2817
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary, 10, 'nearer', false)
2818
+ });
2819
+ MaterialDynamicColors.onTertiaryContainer = DynamicColor.fromPalette({
2820
+ name: 'on_tertiary_container',
2821
+ palette: s => s.tertiaryPalette,
2822
+ tone: s => {
2823
+ if (isMonochrome(s)) {
2824
+ return s.isDark ? 0 : 100;
2825
+ }
2826
+ if (!isFidelity(s)) {
2827
+ return s.isDark ? 90 : 30;
2828
+ }
2829
+ return DynamicColor.foregroundTone(MaterialDynamicColors.tertiaryContainer.tone(s), 4.5);
2830
+ },
2831
+ background: s => MaterialDynamicColors.tertiaryContainer,
2832
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2833
+ });
2834
+ MaterialDynamicColors.error = DynamicColor.fromPalette({
2835
+ name: 'error',
2836
+ palette: s => s.errorPalette,
2837
+ tone: s => s.isDark ? 80 : 40,
2838
+ isBackground: true,
2839
+ background: s => MaterialDynamicColors.highestSurface(s),
2840
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 7),
2841
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 10, 'nearer', false)
2842
+ });
2843
+ MaterialDynamicColors.onError = DynamicColor.fromPalette({
2844
+ name: 'on_error',
2845
+ palette: s => s.errorPalette,
2846
+ tone: s => s.isDark ? 20 : 100,
2847
+ background: s => MaterialDynamicColors.error,
2848
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2849
+ });
2850
+ MaterialDynamicColors.errorContainer = DynamicColor.fromPalette({
2851
+ name: 'error_container',
2852
+ palette: s => s.errorPalette,
2853
+ tone: s => s.isDark ? 30 : 90,
2854
+ isBackground: true,
2855
+ background: s => MaterialDynamicColors.highestSurface(s),
2856
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2857
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 10, 'nearer', false)
2858
+ });
2859
+ MaterialDynamicColors.onErrorContainer = DynamicColor.fromPalette({
2860
+ name: 'on_error_container',
2861
+ palette: s => s.errorPalette,
2862
+ tone: s => {
2863
+ if (isMonochrome(s)) {
2864
+ return s.isDark ? 90 : 10;
2865
+ }
2866
+ return s.isDark ? 90 : 30;
2867
+ },
2868
+ background: s => MaterialDynamicColors.errorContainer,
2869
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2870
+ });
2871
+ MaterialDynamicColors.primaryFixed = DynamicColor.fromPalette({
2872
+ name: 'primary_fixed',
2873
+ palette: s => s.primaryPalette,
2874
+ tone: s => isMonochrome(s) ? 40.0 : 90.0,
2875
+ isBackground: true,
2876
+ background: s => MaterialDynamicColors.highestSurface(s),
2877
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2878
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.primaryFixed, MaterialDynamicColors.primaryFixedDim, 10, 'lighter', true)
2879
+ });
2880
+ MaterialDynamicColors.primaryFixedDim = DynamicColor.fromPalette({
2881
+ name: 'primary_fixed_dim',
2882
+ palette: s => s.primaryPalette,
2883
+ tone: s => isMonochrome(s) ? 30.0 : 80.0,
2884
+ isBackground: true,
2885
+ background: s => MaterialDynamicColors.highestSurface(s),
2886
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2887
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.primaryFixed, MaterialDynamicColors.primaryFixedDim, 10, 'lighter', true)
2888
+ });
2889
+ MaterialDynamicColors.onPrimaryFixed = DynamicColor.fromPalette({
2890
+ name: 'on_primary_fixed',
2891
+ palette: s => s.primaryPalette,
2892
+ tone: s => isMonochrome(s) ? 100.0 : 10.0,
2893
+ background: s => MaterialDynamicColors.primaryFixedDim,
2894
+ secondBackground: s => MaterialDynamicColors.primaryFixed,
2895
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2896
+ });
2897
+ MaterialDynamicColors.onPrimaryFixedVariant = DynamicColor.fromPalette({
2898
+ name: 'on_primary_fixed_variant',
2899
+ palette: s => s.primaryPalette,
2900
+ tone: s => isMonochrome(s) ? 90.0 : 30.0,
2901
+ background: s => MaterialDynamicColors.primaryFixedDim,
2902
+ secondBackground: s => MaterialDynamicColors.primaryFixed,
2903
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2904
+ });
2905
+ MaterialDynamicColors.secondaryFixed = DynamicColor.fromPalette({
2906
+ name: 'secondary_fixed',
2907
+ palette: s => s.secondaryPalette,
2908
+ tone: s => isMonochrome(s) ? 80.0 : 90.0,
2909
+ isBackground: true,
2910
+ background: s => MaterialDynamicColors.highestSurface(s),
2911
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2912
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.secondaryFixed, MaterialDynamicColors.secondaryFixedDim, 10, 'lighter', true)
2913
+ });
2914
+ MaterialDynamicColors.secondaryFixedDim = DynamicColor.fromPalette({
2915
+ name: 'secondary_fixed_dim',
2916
+ palette: s => s.secondaryPalette,
2917
+ tone: s => isMonochrome(s) ? 70.0 : 80.0,
2918
+ isBackground: true,
2919
+ background: s => MaterialDynamicColors.highestSurface(s),
2920
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2921
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.secondaryFixed, MaterialDynamicColors.secondaryFixedDim, 10, 'lighter', true)
2922
+ });
2923
+ MaterialDynamicColors.onSecondaryFixed = DynamicColor.fromPalette({
2924
+ name: 'on_secondary_fixed',
2925
+ palette: s => s.secondaryPalette,
2926
+ tone: s => 10.0,
2927
+ background: s => MaterialDynamicColors.secondaryFixedDim,
2928
+ secondBackground: s => MaterialDynamicColors.secondaryFixed,
2929
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2930
+ });
2931
+ MaterialDynamicColors.onSecondaryFixedVariant = DynamicColor.fromPalette({
2932
+ name: 'on_secondary_fixed_variant',
2933
+ palette: s => s.secondaryPalette,
2934
+ tone: s => isMonochrome(s) ? 25.0 : 30.0,
2935
+ background: s => MaterialDynamicColors.secondaryFixedDim,
2936
+ secondBackground: s => MaterialDynamicColors.secondaryFixed,
2937
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2938
+ });
2939
+ MaterialDynamicColors.tertiaryFixed = DynamicColor.fromPalette({
2940
+ name: 'tertiary_fixed',
2941
+ palette: s => s.tertiaryPalette,
2942
+ tone: s => isMonochrome(s) ? 40.0 : 90.0,
2943
+ isBackground: true,
2944
+ background: s => MaterialDynamicColors.highestSurface(s),
2945
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2946
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.tertiaryFixed, MaterialDynamicColors.tertiaryFixedDim, 10, 'lighter', true)
2947
+ });
2948
+ MaterialDynamicColors.tertiaryFixedDim = DynamicColor.fromPalette({
2949
+ name: 'tertiary_fixed_dim',
2950
+ palette: s => s.tertiaryPalette,
2951
+ tone: s => isMonochrome(s) ? 30.0 : 80.0,
2952
+ isBackground: true,
2953
+ background: s => MaterialDynamicColors.highestSurface(s),
2954
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2955
+ toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.tertiaryFixed, MaterialDynamicColors.tertiaryFixedDim, 10, 'lighter', true)
2956
+ });
2957
+ MaterialDynamicColors.onTertiaryFixed = DynamicColor.fromPalette({
2958
+ name: 'on_tertiary_fixed',
2959
+ palette: s => s.tertiaryPalette,
2960
+ tone: s => isMonochrome(s) ? 100.0 : 10.0,
2961
+ background: s => MaterialDynamicColors.tertiaryFixedDim,
2962
+ secondBackground: s => MaterialDynamicColors.tertiaryFixed,
2963
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2964
+ });
2965
+ MaterialDynamicColors.onTertiaryFixedVariant = DynamicColor.fromPalette({
2966
+ name: 'on_tertiary_fixed_variant',
2967
+ palette: s => s.tertiaryPalette,
2968
+ tone: s => isMonochrome(s) ? 90.0 : 30.0,
2969
+ background: s => MaterialDynamicColors.tertiaryFixedDim,
2970
+ secondBackground: s => MaterialDynamicColors.tertiaryFixed,
2971
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2972
+ });
2973
+
2974
+ /**
2975
+ * @license
2976
+ * Copyright 2022 Google LLC
2977
+ *
2978
+ * Licensed under the Apache License, Version 2.0 (the "License");
2979
+ * you may not use this file except in compliance with the License.
2980
+ * You may obtain a copy of the License at
2981
+ *
2982
+ * http://www.apache.org/licenses/LICENSE-2.0
2983
+ *
2984
+ * Unless required by applicable law or agreed to in writing, software
2985
+ * distributed under the License is distributed on an "AS IS" BASIS,
2986
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2987
+ * See the License for the specific language governing permissions and
2988
+ * limitations under the License.
2989
+ */
2990
+ /**
2991
+ * Constructed by a set of values representing the current UI state (such as
2992
+ * whether or not its dark theme, what the theme style is, etc.), and
2993
+ * provides a set of TonalPalettes that can create colors that fit in
2994
+ * with the theme style. Used by DynamicColor to resolve into a color.
2995
+ */
2996
+ class DynamicScheme {
2997
+ constructor(args) {
2998
+ this.sourceColorArgb = args.sourceColorArgb;
2999
+ this.variant = args.variant;
3000
+ this.contrastLevel = args.contrastLevel;
3001
+ this.isDark = args.isDark;
3002
+ this.sourceColorHct = Hct.fromInt(args.sourceColorArgb);
3003
+ this.primaryPalette = args.primaryPalette;
3004
+ this.secondaryPalette = args.secondaryPalette;
3005
+ this.tertiaryPalette = args.tertiaryPalette;
3006
+ this.neutralPalette = args.neutralPalette;
3007
+ this.neutralVariantPalette = args.neutralVariantPalette;
3008
+ this.errorPalette = TonalPalette.fromHueAndChroma(25.0, 84.0);
3009
+ }
3010
+ /**
3011
+ * Support design spec'ing Dynamic Color by schemes that specify hue
3012
+ * rotations that should be applied at certain breakpoints.
3013
+ * @param sourceColor the source color of the theme, in HCT.
3014
+ * @param hues The "breakpoints", i.e. the hues at which a rotation should
3015
+ * be apply.
3016
+ * @param rotations The rotation that should be applied when source color's
3017
+ * hue is >= the same index in hues array, and <= the hue at the next index
3018
+ * in hues array.
3019
+ */
3020
+ static getRotatedHue(sourceColor, hues, rotations) {
3021
+ const sourceHue = sourceColor.hue;
3022
+ if (hues.length !== rotations.length) {
3023
+ throw new Error(`mismatch between hue length ${hues.length} & rotations ${rotations.length}`);
3024
+ }
3025
+ if (rotations.length === 1) {
3026
+ return sanitizeDegreesDouble(sourceColor.hue + rotations[0]);
3027
+ }
3028
+ const size = hues.length;
3029
+ for (let i = 0; i <= size - 2; i++) {
3030
+ const thisHue = hues[i];
3031
+ const nextHue = hues[i + 1];
3032
+ if (thisHue < sourceHue && sourceHue < nextHue) {
3033
+ return sanitizeDegreesDouble(sourceHue + rotations[i]);
3034
+ }
3035
+ }
3036
+ // If this statement executes, something is wrong, there should have been a
3037
+ // rotation found using the arrays.
3038
+ return sourceHue;
3039
+ }
3040
+ getArgb(dynamicColor) {
3041
+ return dynamicColor.getArgb(this);
3042
+ }
3043
+ getHct(dynamicColor) {
3044
+ return dynamicColor.getHct(this);
3045
+ }
3046
+ get primaryPaletteKeyColor() {
3047
+ return this.getArgb(MaterialDynamicColors.primaryPaletteKeyColor);
3048
+ }
3049
+ get secondaryPaletteKeyColor() {
3050
+ return this.getArgb(MaterialDynamicColors.secondaryPaletteKeyColor);
3051
+ }
3052
+ get tertiaryPaletteKeyColor() {
3053
+ return this.getArgb(MaterialDynamicColors.tertiaryPaletteKeyColor);
3054
+ }
3055
+ get neutralPaletteKeyColor() {
3056
+ return this.getArgb(MaterialDynamicColors.neutralPaletteKeyColor);
3057
+ }
3058
+ get neutralVariantPaletteKeyColor() {
3059
+ return this.getArgb(MaterialDynamicColors.neutralVariantPaletteKeyColor);
3060
+ }
3061
+ get background() {
3062
+ return this.getArgb(MaterialDynamicColors.background);
3063
+ }
3064
+ get onBackground() {
3065
+ return this.getArgb(MaterialDynamicColors.onBackground);
3066
+ }
3067
+ get surface() {
3068
+ return this.getArgb(MaterialDynamicColors.surface);
3069
+ }
3070
+ get surfaceDim() {
3071
+ return this.getArgb(MaterialDynamicColors.surfaceDim);
3072
+ }
3073
+ get surfaceBright() {
3074
+ return this.getArgb(MaterialDynamicColors.surfaceBright);
3075
+ }
3076
+ get surfaceContainerLowest() {
3077
+ return this.getArgb(MaterialDynamicColors.surfaceContainerLowest);
3078
+ }
3079
+ get surfaceContainerLow() {
3080
+ return this.getArgb(MaterialDynamicColors.surfaceContainerLow);
3081
+ }
3082
+ get surfaceContainer() {
3083
+ return this.getArgb(MaterialDynamicColors.surfaceContainer);
3084
+ }
3085
+ get surfaceContainerHigh() {
3086
+ return this.getArgb(MaterialDynamicColors.surfaceContainerHigh);
3087
+ }
3088
+ get surfaceContainerHighest() {
3089
+ return this.getArgb(MaterialDynamicColors.surfaceContainerHighest);
3090
+ }
3091
+ get onSurface() {
3092
+ return this.getArgb(MaterialDynamicColors.onSurface);
3093
+ }
3094
+ get surfaceVariant() {
3095
+ return this.getArgb(MaterialDynamicColors.surfaceVariant);
3096
+ }
3097
+ get onSurfaceVariant() {
3098
+ return this.getArgb(MaterialDynamicColors.onSurfaceVariant);
3099
+ }
3100
+ get inverseSurface() {
3101
+ return this.getArgb(MaterialDynamicColors.inverseSurface);
3102
+ }
3103
+ get inverseOnSurface() {
3104
+ return this.getArgb(MaterialDynamicColors.inverseOnSurface);
3105
+ }
3106
+ get outline() {
3107
+ return this.getArgb(MaterialDynamicColors.outline);
3108
+ }
3109
+ get outlineVariant() {
3110
+ return this.getArgb(MaterialDynamicColors.outlineVariant);
3111
+ }
3112
+ get shadow() {
3113
+ return this.getArgb(MaterialDynamicColors.shadow);
3114
+ }
3115
+ get scrim() {
3116
+ return this.getArgb(MaterialDynamicColors.scrim);
3117
+ }
3118
+ get surfaceTint() {
3119
+ return this.getArgb(MaterialDynamicColors.surfaceTint);
3120
+ }
3121
+ get primary() {
3122
+ return this.getArgb(MaterialDynamicColors.primary);
3123
+ }
3124
+ get onPrimary() {
3125
+ return this.getArgb(MaterialDynamicColors.onPrimary);
3126
+ }
3127
+ get primaryContainer() {
3128
+ return this.getArgb(MaterialDynamicColors.primaryContainer);
3129
+ }
3130
+ get onPrimaryContainer() {
3131
+ return this.getArgb(MaterialDynamicColors.onPrimaryContainer);
3132
+ }
3133
+ get inversePrimary() {
3134
+ return this.getArgb(MaterialDynamicColors.inversePrimary);
3135
+ }
3136
+ get secondary() {
3137
+ return this.getArgb(MaterialDynamicColors.secondary);
3138
+ }
3139
+ get onSecondary() {
3140
+ return this.getArgb(MaterialDynamicColors.onSecondary);
3141
+ }
3142
+ get secondaryContainer() {
3143
+ return this.getArgb(MaterialDynamicColors.secondaryContainer);
3144
+ }
3145
+ get onSecondaryContainer() {
3146
+ return this.getArgb(MaterialDynamicColors.onSecondaryContainer);
3147
+ }
3148
+ get tertiary() {
3149
+ return this.getArgb(MaterialDynamicColors.tertiary);
3150
+ }
3151
+ get onTertiary() {
3152
+ return this.getArgb(MaterialDynamicColors.onTertiary);
3153
+ }
3154
+ get tertiaryContainer() {
3155
+ return this.getArgb(MaterialDynamicColors.tertiaryContainer);
3156
+ }
3157
+ get onTertiaryContainer() {
3158
+ return this.getArgb(MaterialDynamicColors.onTertiaryContainer);
3159
+ }
3160
+ get error() {
3161
+ return this.getArgb(MaterialDynamicColors.error);
3162
+ }
3163
+ get onError() {
3164
+ return this.getArgb(MaterialDynamicColors.onError);
3165
+ }
3166
+ get errorContainer() {
3167
+ return this.getArgb(MaterialDynamicColors.errorContainer);
3168
+ }
3169
+ get onErrorContainer() {
3170
+ return this.getArgb(MaterialDynamicColors.onErrorContainer);
3171
+ }
3172
+ get primaryFixed() {
3173
+ return this.getArgb(MaterialDynamicColors.primaryFixed);
3174
+ }
3175
+ get primaryFixedDim() {
3176
+ return this.getArgb(MaterialDynamicColors.primaryFixedDim);
3177
+ }
3178
+ get onPrimaryFixed() {
3179
+ return this.getArgb(MaterialDynamicColors.onPrimaryFixed);
3180
+ }
3181
+ get onPrimaryFixedVariant() {
3182
+ return this.getArgb(MaterialDynamicColors.onPrimaryFixedVariant);
3183
+ }
3184
+ get secondaryFixed() {
3185
+ return this.getArgb(MaterialDynamicColors.secondaryFixed);
3186
+ }
3187
+ get secondaryFixedDim() {
3188
+ return this.getArgb(MaterialDynamicColors.secondaryFixedDim);
3189
+ }
3190
+ get onSecondaryFixed() {
3191
+ return this.getArgb(MaterialDynamicColors.onSecondaryFixed);
3192
+ }
3193
+ get onSecondaryFixedVariant() {
3194
+ return this.getArgb(MaterialDynamicColors.onSecondaryFixedVariant);
3195
+ }
3196
+ get tertiaryFixed() {
3197
+ return this.getArgb(MaterialDynamicColors.tertiaryFixed);
3198
+ }
3199
+ get tertiaryFixedDim() {
3200
+ return this.getArgb(MaterialDynamicColors.tertiaryFixedDim);
3201
+ }
3202
+ get onTertiaryFixed() {
3203
+ return this.getArgb(MaterialDynamicColors.onTertiaryFixed);
3204
+ }
3205
+ get onTertiaryFixedVariant() {
3206
+ return this.getArgb(MaterialDynamicColors.onTertiaryFixedVariant);
3207
+ }
3208
+ }
3209
+
3210
+ /**
3211
+ * @license
3212
+ * Copyright 2021 Google LLC
3213
+ *
3214
+ * Licensed under the Apache License, Version 2.0 (the "License");
3215
+ * you may not use this file except in compliance with the License.
3216
+ * You may obtain a copy of the License at
3217
+ *
3218
+ * http://www.apache.org/licenses/LICENSE-2.0
3219
+ *
3220
+ * Unless required by applicable law or agreed to in writing, software
3221
+ * distributed under the License is distributed on an "AS IS" BASIS,
3222
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3223
+ * See the License for the specific language governing permissions and
3224
+ * limitations under the License.
3225
+ */
3226
+ /**
3227
+ * An intermediate concept between the key color for a UI theme, and a full
3228
+ * color scheme. 5 sets of tones are generated, all except one use the same hue
3229
+ * as the key color, and all vary in chroma.
3230
+ */
3231
+ class CorePalette {
3232
+ /**
3233
+ * @param argb ARGB representation of a color
3234
+ */
3235
+ static of(argb) {
3236
+ return new CorePalette(argb, false);
3237
+ }
3238
+ /**
3239
+ * @param argb ARGB representation of a color
3240
+ */
3241
+ static contentOf(argb) {
3242
+ return new CorePalette(argb, true);
3243
+ }
3244
+ /**
3245
+ * Create a [CorePalette] from a set of colors
3246
+ */
3247
+ static fromColors(colors) {
3248
+ return CorePalette.createPaletteFromColors(false, colors);
3249
+ }
3250
+ /**
3251
+ * Create a content [CorePalette] from a set of colors
3252
+ */
3253
+ static contentFromColors(colors) {
3254
+ return CorePalette.createPaletteFromColors(true, colors);
3255
+ }
3256
+ static createPaletteFromColors(content, colors) {
3257
+ const palette = new CorePalette(colors.primary, content);
3258
+ if (colors.secondary) {
3259
+ const p = new CorePalette(colors.secondary, content);
3260
+ palette.a2 = p.a1;
3261
+ }
3262
+ if (colors.tertiary) {
3263
+ const p = new CorePalette(colors.tertiary, content);
3264
+ palette.a3 = p.a1;
3265
+ }
3266
+ if (colors.error) {
3267
+ const p = new CorePalette(colors.error, content);
3268
+ palette.error = p.a1;
3269
+ }
3270
+ if (colors.neutral) {
3271
+ const p = new CorePalette(colors.neutral, content);
3272
+ palette.n1 = p.n1;
3273
+ }
3274
+ if (colors.neutralVariant) {
3275
+ const p = new CorePalette(colors.neutralVariant, content);
3276
+ palette.n2 = p.n2;
3277
+ }
3278
+ return palette;
3279
+ }
3280
+ constructor(argb, isContent) {
3281
+ const hct = Hct.fromInt(argb);
3282
+ const hue = hct.hue;
3283
+ const chroma = hct.chroma;
3284
+ if (isContent) {
3285
+ this.a1 = TonalPalette.fromHueAndChroma(hue, chroma);
3286
+ this.a2 = TonalPalette.fromHueAndChroma(hue, chroma / 3);
3287
+ this.a3 = TonalPalette.fromHueAndChroma(hue + 60, chroma / 2);
3288
+ this.n1 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 12, 4));
3289
+ this.n2 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 6, 8));
3290
+ } else {
3291
+ this.a1 = TonalPalette.fromHueAndChroma(hue, Math.max(48, chroma));
3292
+ this.a2 = TonalPalette.fromHueAndChroma(hue, 16);
3293
+ this.a3 = TonalPalette.fromHueAndChroma(hue + 60, 24);
3294
+ this.n1 = TonalPalette.fromHueAndChroma(hue, 4);
3295
+ this.n2 = TonalPalette.fromHueAndChroma(hue, 8);
3296
+ }
3297
+ this.error = TonalPalette.fromHueAndChroma(25, 84);
3298
+ }
3299
+ }
3300
+
3301
+ /**
3302
+ * @license
3303
+ * Copyright 2022 Google LLC
3304
+ *
3305
+ * Licensed under the Apache License, Version 2.0 (the "License");
3306
+ * you may not use this file except in compliance with the License.
3307
+ * You may obtain a copy of the License at
3308
+ *
3309
+ * http://www.apache.org/licenses/LICENSE-2.0
3310
+ *
3311
+ * Unless required by applicable law or agreed to in writing, software
3312
+ * distributed under the License is distributed on an "AS IS" BASIS,
3313
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3314
+ * See the License for the specific language governing permissions and
3315
+ * limitations under the License.
3316
+ */
3317
+ /**
3318
+ * A Dynamic Color theme that is intentionally detached from the source color.
3319
+ */
3320
+ class SchemeExpressive extends DynamicScheme {
3321
+ constructor(sourceColorHct, isDark, contrastLevel) {
3322
+ super({
3323
+ sourceColorArgb: sourceColorHct.toInt(),
3324
+ variant: Variant.EXPRESSIVE,
3325
+ contrastLevel,
3326
+ isDark,
3327
+ primaryPalette: TonalPalette.fromHueAndChroma(sanitizeDegreesDouble(sourceColorHct.hue + 240.0), 40.0),
3328
+ secondaryPalette: TonalPalette.fromHueAndChroma(DynamicScheme.getRotatedHue(sourceColorHct, SchemeExpressive.hues, SchemeExpressive.secondaryRotations), 24.0),
3329
+ tertiaryPalette: TonalPalette.fromHueAndChroma(DynamicScheme.getRotatedHue(sourceColorHct, SchemeExpressive.hues, SchemeExpressive.tertiaryRotations), 32.0),
3330
+ neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue + 15, 8.0),
3331
+ neutralVariantPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue + 15, 12.0)
3332
+ });
3333
+ }
3334
+ }
3335
+ /**
3336
+ * Hues (in degrees) used at breakpoints such that designers can specify a
3337
+ * hue rotation that occurs at a given break point.
3338
+ */
3339
+ SchemeExpressive.hues = [0.0, 21.0, 51.0, 121.0, 151.0, 191.0, 271.0, 321.0, 360.0];
3340
+ /**
3341
+ * Hue rotations (in degrees) of the Secondary [TonalPalette],
3342
+ * corresponding to the breakpoints in [hues].
3343
+ */
3344
+ SchemeExpressive.secondaryRotations = [45.0, 95.0, 45.0, 20.0, 45.0, 90.0, 45.0, 45.0, 45.0];
3345
+ /**
3346
+ * Hue rotations (in degrees) of the Tertiary [TonalPalette],
3347
+ * corresponding to the breakpoints in [hues].
3348
+ */
3349
+ SchemeExpressive.tertiaryRotations = [120.0, 120.0, 20.0, 45.0, 20.0, 15.0, 20.0, 120.0, 120.0];
3350
+
3351
+ /**
3352
+ * @license
3353
+ * Copyright 2022 Google LLC
3354
+ *
3355
+ * Licensed under the Apache License, Version 2.0 (the "License");
3356
+ * you may not use this file except in compliance with the License.
3357
+ * You may obtain a copy of the License at
3358
+ *
3359
+ * http://www.apache.org/licenses/LICENSE-2.0
3360
+ *
3361
+ * Unless required by applicable law or agreed to in writing, software
3362
+ * distributed under the License is distributed on an "AS IS" BASIS,
3363
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3364
+ * See the License for the specific language governing permissions and
3365
+ * limitations under the License.
3366
+ */
3367
+ /**
3368
+ * A Dynamic Color theme that maxes out colorfulness at each position in the
3369
+ * Primary Tonal Palette.
3370
+ */
3371
+ class SchemeVibrant extends DynamicScheme {
3372
+ constructor(sourceColorHct, isDark, contrastLevel) {
3373
+ super({
3374
+ sourceColorArgb: sourceColorHct.toInt(),
3375
+ variant: Variant.VIBRANT,
3376
+ contrastLevel,
3377
+ isDark,
3378
+ primaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 200.0),
3379
+ secondaryPalette: TonalPalette.fromHueAndChroma(DynamicScheme.getRotatedHue(sourceColorHct, SchemeVibrant.hues, SchemeVibrant.secondaryRotations), 24.0),
3380
+ tertiaryPalette: TonalPalette.fromHueAndChroma(DynamicScheme.getRotatedHue(sourceColorHct, SchemeVibrant.hues, SchemeVibrant.tertiaryRotations), 32.0),
3381
+ neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 10.0),
3382
+ neutralVariantPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 12.0)
3383
+ });
3384
+ }
3385
+ }
3386
+ /**
3387
+ * Hues (in degrees) used at breakpoints such that designers can specify a
3388
+ * hue rotation that occurs at a given break point.
3389
+ */
3390
+ SchemeVibrant.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
3391
+ /**
3392
+ * Hue rotations (in degrees) of the Secondary [TonalPalette],
3393
+ * corresponding to the breakpoints in [hues].
3394
+ */
3395
+ SchemeVibrant.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
3396
+ /**
3397
+ * Hue rotations (in degrees) of the Tertiary [TonalPalette],
3398
+ * corresponding to the breakpoints in [hues].
3399
+ */
3400
+ SchemeVibrant.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
3401
+
3402
+ /**
3403
+ * @license
3404
+ * Copyright 2021 Google LLC
3405
+ *
3406
+ * Licensed under the Apache License, Version 2.0 (the "License");
3407
+ * you may not use this file except in compliance with the License.
3408
+ * You may obtain a copy of the License at
3409
+ *
3410
+ * http://www.apache.org/licenses/LICENSE-2.0
3411
+ *
3412
+ * Unless required by applicable law or agreed to in writing, software
3413
+ * distributed under the License is distributed on an "AS IS" BASIS,
3414
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3415
+ * See the License for the specific language governing permissions and
3416
+ * limitations under the License.
3417
+ */
3418
+ /**
3419
+ * Utility methods for hexadecimal representations of colors.
3420
+ */
3421
+ /**
3422
+ * @param argb ARGB representation of a color.
3423
+ * @return Hex string representing color, ex. #ff0000 for red.
3424
+ */
3425
+ function hexFromArgb(argb) {
3426
+ const r = redFromArgb(argb);
3427
+ const g = greenFromArgb(argb);
3428
+ const b = blueFromArgb(argb);
3429
+ const outParts = [r.toString(16), g.toString(16), b.toString(16)];
3430
+ // Pad single-digit output values
3431
+ for (const [i, part] of outParts.entries()) {
3432
+ if (part.length === 1) {
3433
+ outParts[i] = '0' + part;
3434
+ }
3435
+ }
3436
+ return '#' + outParts.join('');
3437
+ }
3438
+ /**
3439
+ * @param hex String representing color as hex code. Accepts strings with or
3440
+ * without leading #, and string representing the color using 3, 6, or 8
3441
+ * hex characters.
3442
+ * @return ARGB representation of color.
3443
+ */
3444
+ function argbFromHex(hex) {
3445
+ hex = hex.replace('#', '');
3446
+ const isThree = hex.length === 3;
3447
+ const isSix = hex.length === 6;
3448
+ const isEight = hex.length === 8;
3449
+ if (!isThree && !isSix && !isEight) {
3450
+ throw new Error('unexpected hex ' + hex);
3451
+ }
3452
+ let r = 0;
3453
+ let g = 0;
3454
+ let b = 0;
3455
+ if (isThree) {
3456
+ r = parseIntHex(hex.slice(0, 1).repeat(2));
3457
+ g = parseIntHex(hex.slice(1, 2).repeat(2));
3458
+ b = parseIntHex(hex.slice(2, 3).repeat(2));
3459
+ } else if (isSix) {
3460
+ r = parseIntHex(hex.slice(0, 2));
3461
+ g = parseIntHex(hex.slice(2, 4));
3462
+ b = parseIntHex(hex.slice(4, 6));
3463
+ } else if (isEight) {
3464
+ r = parseIntHex(hex.slice(2, 4));
3465
+ g = parseIntHex(hex.slice(4, 6));
3466
+ b = parseIntHex(hex.slice(6, 8));
3467
+ }
3468
+ return (255 << 24 | (r & 0x0ff) << 16 | (g & 0x0ff) << 8 | b & 0x0ff) >>> 0;
3469
+ }
3470
+ function parseIntHex(value) {
3471
+ // tslint:disable-next-line:ban
3472
+ return parseInt(value, 16);
3473
+ }
3474
+
3475
+ var _M3eThemeElement_instances, _M3eThemeElement_styleSheet, _M3eThemeElement_firstUpdated, _M3eThemeElement_light, _M3eThemeElement_dark, _M3eThemeElement_forcedColor, _M3eThemeElement_colorSchemeChangeHandler, _M3eThemeElement_apply, _M3eThemeElement_getContrastLevel;
3476
+ /**
3477
+ * A non-visual element responsible for application-level theming.
3478
+ *
3479
+ * @description
3480
+ * The `m3e-theme` component is a non-visual element used to apply dynamic color, expressive motion, density, and strong focus indicators
3481
+ * to nested, theme-aware elements.
3482
+ *
3483
+ * When `m3e-theme` is nested directly beneath the `<body>` of a document, the `<body>`'s `background-color` is set to the computed
3484
+ * value of `--md-sys-color-background` and `color` is set to the computed value of `--md-sys-color-on-background`. In addition,
3485
+ * the document's `scrollbar-color` is set to the computed values of `--m3e-scrollbar-thumb-color` and `--m3e-scrollbar-track-color` which,
3486
+ * when supported, cascades to all viewport scrollbars.
3487
+ *
3488
+ * @example
3489
+ * The following example adds a top-level `m3e-theme` directly beneath a document's `<body>` element to
3490
+ * apply application-level theming. In this example, `color` and `scheme` are used to create a dynamic color
3491
+ * palette which automatically adjusts to a user's light or dark color preference. In addition, expressive motion
3492
+ * and strong focus indicators are enabled.
3493
+ *
3494
+ * ```html
3495
+ * <body>
3496
+ * <m3e-theme color="#6750A4" scheme="auto" motion="expressive" strong-focus>
3497
+ * <!-- Normal body content here. -->
3498
+ * </m3e-theme>
3499
+ * <body/>
3500
+ * ```
3501
+ * @tag m3e-theme
3502
+ *
3503
+ * @attr color - The hex color from which to derive dynamic color palettes.
3504
+ * @attr contrast - The contrast level of the theme.
3505
+ * @attr density - The density scale (0, -1, -2).
3506
+ * @attr scheme - The color scheme of the theme.
3507
+ * @attr strong-focus - Whether to enable strong focus indicators.
3508
+ *
3509
+ * @fires change - Dispatched when the theme changes.
3510
+ */
3511
+ let M3eThemeElement = class M3eThemeElement extends LitElement {
3512
+ constructor() {
3513
+ super(...arguments);
3514
+ _M3eThemeElement_instances.add(this);
3515
+ /** @private */
3516
+ _M3eThemeElement_styleSheet.set(this, new CSSStyleSheet());
3517
+ /** @private */
3518
+ _M3eThemeElement_firstUpdated.set(this, false);
3519
+ /** @private */
3520
+ _M3eThemeElement_light.set(this, void 0);
3521
+ /** @private */
3522
+ _M3eThemeElement_dark.set(this, void 0);
3523
+ /** @private */
3524
+ _M3eThemeElement_forcedColor.set(this, void 0);
3525
+ /** @private */
3526
+ _M3eThemeElement_colorSchemeChangeHandler.set(this, () => __classPrivateFieldGet(this, _M3eThemeElement_instances, "m", _M3eThemeElement_apply).call(this, true));
3527
+ /**
3528
+ * The hex color from which to derive dynamic color palettes.
3529
+ * @default "#6750A4"
3530
+ */
3531
+ this.color = "#6750A4";
3532
+ /**
3533
+ * The color scheme of the theme.
3534
+ * @default "auto"
3535
+ */
3536
+ this.scheme = "auto";
3537
+ /**
3538
+ * The contrast level of the theme.
3539
+ * @default "standard"
3540
+ */
3541
+ this.contrast = "standard";
3542
+ /**
3543
+ * Whether to enable strong focus indicators.
3544
+ * @default false
3545
+ */
3546
+ this.strongFocus = false;
3547
+ /**
3548
+ * The density scale (0, -1, -2).
3549
+ * @default 0
3550
+ */
3551
+ this.density = 0;
3552
+ /** The motion scheme.
3553
+ * @default "standard"
3554
+ */
3555
+ this.motion = "standard";
3556
+ }
3557
+ /** Whether a dark theme is applied. */
3558
+ get isDark() {
3559
+ switch (this.scheme) {
3560
+ case "light":
3561
+ return false;
3562
+ case "dark":
3563
+ return true;
3564
+ default:
3565
+ // auto
3566
+ if (this.parentElement instanceof HTMLBodyElement) {
3567
+ switch (document.documentElement.style.colorScheme) {
3568
+ case "light":
3569
+ return false;
3570
+ case "dark":
3571
+ return true;
3572
+ }
3573
+ }
3574
+ return __classPrivateFieldGet(this, _M3eThemeElement_dark, "f")?.matches ?? false;
3575
+ }
3576
+ }
3577
+ /** @inheritdoc */
3578
+ connectedCallback() {
3579
+ super.connectedCallback();
3580
+ if (this.shadowRoot && !this.shadowRoot.adoptedStyleSheets.includes(__classPrivateFieldGet(this, _M3eThemeElement_styleSheet, "f"))) {
3581
+ this.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, __classPrivateFieldGet(this, _M3eThemeElement_styleSheet, "f")];
3582
+ }
3583
+ __classPrivateFieldSet(this, _M3eThemeElement_light, matchMedia("(prefers-color-scheme: light)"), "f");
3584
+ __classPrivateFieldSet(this, _M3eThemeElement_dark, matchMedia("(prefers-color-scheme: dark)"), "f");
3585
+ __classPrivateFieldSet(this, _M3eThemeElement_forcedColor, matchMedia("(forced-colors: active)"), "f");
3586
+ [__classPrivateFieldGet(this, _M3eThemeElement_light, "f"), __classPrivateFieldGet(this, _M3eThemeElement_dark, "f"), __classPrivateFieldGet(this, _M3eThemeElement_forcedColor, "f")].forEach(x => x.addEventListener("change", __classPrivateFieldGet(this, _M3eThemeElement_colorSchemeChangeHandler, "f")));
3587
+ }
3588
+ /** @inheritdoc */
3589
+ disconnectedCallback() {
3590
+ super.disconnectedCallback();
3591
+ [__classPrivateFieldGet(this, _M3eThemeElement_light, "f"), __classPrivateFieldGet(this, _M3eThemeElement_dark, "f"), __classPrivateFieldGet(this, _M3eThemeElement_forcedColor, "f")].forEach(x => x?.removeEventListener("change", __classPrivateFieldGet(this, _M3eThemeElement_colorSchemeChangeHandler, "f")));
3592
+ __classPrivateFieldSet(this, _M3eThemeElement_light, __classPrivateFieldSet(this, _M3eThemeElement_dark, __classPrivateFieldSet(this, _M3eThemeElement_forcedColor, undefined, "f"), "f"), "f");
3593
+ }
3594
+ /** @inheritdoc */
3595
+ updated(_changedProperties) {
3596
+ super.updated(_changedProperties);
3597
+ __classPrivateFieldGet(this, _M3eThemeElement_instances, "m", _M3eThemeElement_apply).call(this, __classPrivateFieldGet(this, _M3eThemeElement_firstUpdated, "f") && ["color", "scheme", "contrast"].some(x => _changedProperties.has(x)));
3598
+ }
3599
+ /** @inheritdoc */
3600
+ firstUpdated(_changedProperties) {
3601
+ super.firstUpdated(_changedProperties);
3602
+ __classPrivateFieldSet(this, _M3eThemeElement_firstUpdated, true, "f");
3603
+ }
3604
+ /** @inheritdoc */
3605
+ render() {
3606
+ return html`<slot></slot>`;
3607
+ }
3608
+ };
3609
+ _M3eThemeElement_styleSheet = new WeakMap();
3610
+ _M3eThemeElement_firstUpdated = new WeakMap();
3611
+ _M3eThemeElement_light = new WeakMap();
3612
+ _M3eThemeElement_dark = new WeakMap();
3613
+ _M3eThemeElement_forcedColor = new WeakMap();
3614
+ _M3eThemeElement_colorSchemeChangeHandler = new WeakMap();
3615
+ _M3eThemeElement_instances = new WeakSet();
3616
+ _M3eThemeElement_apply = function _M3eThemeElement_apply(forceReflow) {
3617
+ const color = argbFromHex(this.color);
3618
+ const palette = CorePalette.of(color);
3619
+ const scheme = new DynamicScheme({
3620
+ sourceColorArgb: color,
3621
+ variant: 1,
3622
+ contrastLevel: __classPrivateFieldGet(this, _M3eThemeElement_instances, "m", _M3eThemeElement_getContrastLevel).call(this),
3623
+ isDark: this.isDark,
3624
+ primaryPalette: palette.a1,
3625
+ secondaryPalette: palette.a2,
3626
+ tertiaryPalette: palette.a3,
3627
+ neutralPalette: palette.n1,
3628
+ neutralVariantPalette: palette.n2
3629
+ });
3630
+ let css = "";
3631
+ for (const key in MaterialDynamicColors) {
3632
+ if (!key.endsWith("PaletteKeyColor")) {
3633
+ const dynamicColor = MaterialDynamicColors[key];
3634
+ if (dynamicColor instanceof DynamicColor) {
3635
+ css += `--md-sys-color-${key.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}: ${hexFromArgb(dynamicColor.getArgb(scheme))};`;
3636
+ }
3637
+ }
3638
+ }
3639
+ if (this.motion === "expressive") {
3640
+ css += "--md-sys-motion-spring-fast-spatial: 350ms cubic-bezier(0.42, 1.67, 0.21, 0.90);";
3641
+ css += "--md-sys-motion-spring-default-spatial: 500ms cubic-bezier(0.38, 1.21, 0.22, 1.00);";
3642
+ css += "--md-sys-motion-spring-slow-spatial: 650ms cubic-bezier(0.39, 1.29, 0.35, 0.98);";
3643
+ css += "--md-sys-motion-spring-fast-effects: 150ms cubic-bezier(0.31, 0.94, 0.34, 1.00);";
3644
+ css += "--md-sys-motion-spring-default-effects: 200ms cubic-bezier(0.34, 0.80, 0.34, 1.00);";
3645
+ css += "--md-sys-motion-spring-slow-effects: 300ms cubic-bezier(0.34, 0.88, 0.34, 1.00);";
3646
+ }
3647
+ css += `--md-sys-density-scale: ${this.density};`;
3648
+ css += `--m3e-scrollbar-thumb-color: ${hexFromArgb(scheme.neutralPalette.tone(60))};`;
3649
+ css += `--m3e-focus-ring-visibility: ${this.strongFocus ? "visible" : "hidden"};`;
3650
+ __classPrivateFieldGet(this, _M3eThemeElement_styleSheet, "f").replaceSync(`:host { ${css} }`);
3651
+ if (this.parentElement instanceof HTMLBodyElement) {
3652
+ const computedStyle = getComputedStyle(this);
3653
+ switch (this.scheme) {
3654
+ case "light":
3655
+ document.documentElement.style.colorScheme = "light";
3656
+ break;
3657
+ case "dark":
3658
+ document.documentElement.style.colorScheme = "dark";
3659
+ break;
3660
+ default:
3661
+ switch (document.documentElement.style.colorScheme) {
3662
+ case "light":
3663
+ case "dark":
3664
+ document.documentElement.style.colorScheme = "light dark";
3665
+ break;
3666
+ }
3667
+ }
3668
+ if (__classPrivateFieldGet(this, _M3eThemeElement_forcedColor, "f")?.matches) {
3669
+ this.parentElement.style.backgroundColor = this.parentElement.style.color = this.parentElement.ownerDocument.documentElement.style.scrollbarColor = this.parentElement.style.scrollbarColor = "";
3670
+ } else {
3671
+ this.parentElement.style.backgroundColor = computedStyle.getPropertyValue("--md-sys-color-background");
3672
+ this.parentElement.style.color = computedStyle.getPropertyValue("--md-sys-color-on-background");
3673
+ this.parentElement.ownerDocument.documentElement.style.scrollbarColor = this.parentElement.style.scrollbarColor = `${computedStyle.getPropertyValue("--m3e-scrollbar-thumb-color")} ${computedStyle.getPropertyValue("--m3e-scrollbar-track-color")}`;
3674
+ }
3675
+ }
3676
+ if (__classPrivateFieldGet(this, _M3eThemeElement_firstUpdated, "f")) {
3677
+ this.dispatchEvent(new Event("change", {
3678
+ bubbles: true
3679
+ }));
3680
+ }
3681
+ if (forceReflow) {
3682
+ void document.body.offsetHeight;
3683
+ }
3684
+ };
3685
+ _M3eThemeElement_getContrastLevel = function _M3eThemeElement_getContrastLevel() {
3686
+ switch (this.contrast) {
3687
+ case "high":
3688
+ return 1;
3689
+ case "medium":
3690
+ return 0.5;
3691
+ default:
3692
+ // standard
3693
+ return 0;
3694
+ }
3695
+ };
3696
+ /** The styles of the element. */
3697
+ M3eThemeElement.styles = css`:host { display: contents; font-size: ${DesignToken.typescale.standard.body.large.fontSize}; font-weight: ${DesignToken.typescale.standard.body.large.fontWeight}; line-height: ${DesignToken.typescale.standard.body.large.lineHeight}; letter-spacing: ${DesignToken.typescale.standard.body.large.tracking}; }`;
3698
+ __decorate([n()], M3eThemeElement.prototype, "color", void 0);
3699
+ __decorate([n()], M3eThemeElement.prototype, "scheme", void 0);
3700
+ __decorate([n()], M3eThemeElement.prototype, "contrast", void 0);
3701
+ __decorate([n({
3702
+ attribute: "strong-focus",
3703
+ type: Boolean
3704
+ })], M3eThemeElement.prototype, "strongFocus", void 0);
3705
+ __decorate([n({
3706
+ type: Number
3707
+ })], M3eThemeElement.prototype, "density", void 0);
3708
+ __decorate([n()], M3eThemeElement.prototype, "motion", void 0);
3709
+ M3eThemeElement = __decorate([t$1("m3e-theme")], M3eThemeElement);
3710
+
3711
+ export { M3eThemeElement };
3712
+ //# sourceMappingURL=theme.js.map