@angular/material 21.0.0-next.9 → 21.0.0-rc.1

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 (202) hide show
  1. package/core/tokens/_classes.scss +1 -1
  2. package/core/tokens/m2/_md-sys-color.scss +17 -17
  3. package/fesm2022/_animation-chunk.mjs +10 -16
  4. package/fesm2022/_animation-chunk.mjs.map +1 -1
  5. package/fesm2022/_date-formats-chunk.mjs +68 -164
  6. package/fesm2022/_date-formats-chunk.mjs.map +1 -1
  7. package/fesm2022/_date-range-input-harness-chunk.mjs +284 -463
  8. package/fesm2022/_date-range-input-harness-chunk.mjs.map +1 -1
  9. package/fesm2022/_error-options-chunk.mjs +56 -19
  10. package/fesm2022/_error-options-chunk.mjs.map +1 -1
  11. package/fesm2022/_error-state-chunk.mjs +24 -31
  12. package/fesm2022/_error-state-chunk.mjs.map +1 -1
  13. package/fesm2022/_form-field-chunk.mjs +1224 -1017
  14. package/fesm2022/_form-field-chunk.mjs.map +1 -1
  15. package/fesm2022/_icon-button-chunk.mjs +243 -187
  16. package/fesm2022/_icon-button-chunk.mjs.map +1 -1
  17. package/fesm2022/_icon-registry-chunk.mjs +350 -575
  18. package/fesm2022/_icon-registry-chunk.mjs.map +1 -1
  19. package/fesm2022/_input-harness-chunk.mjs +56 -107
  20. package/fesm2022/_input-harness-chunk.mjs.map +1 -1
  21. package/fesm2022/_input-value-accessor-chunk.mjs +0 -6
  22. package/fesm2022/_input-value-accessor-chunk.mjs.map +1 -1
  23. package/fesm2022/_internal-form-field-chunk.mjs +59 -19
  24. package/fesm2022/_internal-form-field-chunk.mjs.map +1 -1
  25. package/fesm2022/_line-chunk.mjs +83 -43
  26. package/fesm2022/_line-chunk.mjs.map +1 -1
  27. package/fesm2022/_option-chunk.mjs +348 -311
  28. package/fesm2022/_option-chunk.mjs.map +1 -1
  29. package/fesm2022/_option-harness-chunk.mjs +23 -39
  30. package/fesm2022/_option-harness-chunk.mjs.map +1 -1
  31. package/fesm2022/_option-module-chunk.mjs +36 -10
  32. package/fesm2022/_option-module-chunk.mjs.map +1 -1
  33. package/fesm2022/_pseudo-checkbox-chunk.mjs +79 -44
  34. package/fesm2022/_pseudo-checkbox-chunk.mjs.map +1 -1
  35. package/fesm2022/_pseudo-checkbox-module-chunk.mjs +36 -10
  36. package/fesm2022/_pseudo-checkbox-module-chunk.mjs.map +1 -1
  37. package/fesm2022/_public-api-chunk.mjs +71 -134
  38. package/fesm2022/_public-api-chunk.mjs.map +1 -1
  39. package/fesm2022/_ripple-chunk.mjs +504 -600
  40. package/fesm2022/_ripple-chunk.mjs.map +1 -1
  41. package/fesm2022/_ripple-loader-chunk.mjs +120 -138
  42. package/fesm2022/_ripple-loader-chunk.mjs.map +1 -1
  43. package/fesm2022/_ripple-module-chunk.mjs +36 -10
  44. package/fesm2022/_ripple-module-chunk.mjs.map +1 -1
  45. package/fesm2022/_structural-styles-chunk.mjs +37 -10
  46. package/fesm2022/_structural-styles-chunk.mjs.map +1 -1
  47. package/fesm2022/_tooltip-chunk.mjs +811 -888
  48. package/fesm2022/_tooltip-chunk.mjs.map +1 -1
  49. package/fesm2022/autocomplete-testing.mjs +62 -86
  50. package/fesm2022/autocomplete-testing.mjs.map +1 -1
  51. package/fesm2022/autocomplete.mjs +965 -1126
  52. package/fesm2022/autocomplete.mjs.map +1 -1
  53. package/fesm2022/badge-testing.mjs +38 -54
  54. package/fesm2022/badge-testing.mjs.map +1 -1
  55. package/fesm2022/badge.mjs +321 -272
  56. package/fesm2022/badge.mjs.map +1 -1
  57. package/fesm2022/bottom-sheet-testing.mjs +10 -24
  58. package/fesm2022/bottom-sheet-testing.mjs.map +1 -1
  59. package/fesm2022/bottom-sheet.mjs +349 -344
  60. package/fesm2022/bottom-sheet.mjs.map +1 -1
  61. package/fesm2022/button-testing.mjs +60 -94
  62. package/fesm2022/button-testing.mjs.map +1 -1
  63. package/fesm2022/button-toggle-testing.mjs +76 -125
  64. package/fesm2022/button-toggle-testing.mjs.map +1 -1
  65. package/fesm2022/button-toggle.mjs +752 -662
  66. package/fesm2022/button-toggle.mjs.map +1 -1
  67. package/fesm2022/button.mjs +263 -158
  68. package/fesm2022/button.mjs.map +1 -1
  69. package/fesm2022/card-testing.mjs +19 -33
  70. package/fesm2022/card-testing.mjs.map +1 -1
  71. package/fesm2022/card.mjs +576 -272
  72. package/fesm2022/card.mjs.map +1 -1
  73. package/fesm2022/checkbox-testing.mjs +71 -123
  74. package/fesm2022/checkbox-testing.mjs.map +1 -1
  75. package/fesm2022/checkbox.mjs +515 -477
  76. package/fesm2022/checkbox.mjs.map +1 -1
  77. package/fesm2022/chips-testing.mjs +201 -344
  78. package/fesm2022/chips-testing.mjs.map +1 -1
  79. package/fesm2022/chips.mjs +2552 -2289
  80. package/fesm2022/chips.mjs.map +1 -1
  81. package/fesm2022/core-testing.mjs +14 -28
  82. package/fesm2022/core-testing.mjs.map +1 -1
  83. package/fesm2022/core.mjs +357 -328
  84. package/fesm2022/core.mjs.map +1 -1
  85. package/fesm2022/datepicker-testing.mjs +15 -25
  86. package/fesm2022/datepicker-testing.mjs.map +1 -1
  87. package/fesm2022/datepicker.mjs +4826 -4563
  88. package/fesm2022/datepicker.mjs.map +1 -1
  89. package/fesm2022/dialog-testing.mjs +93 -129
  90. package/fesm2022/dialog-testing.mjs.map +1 -1
  91. package/fesm2022/dialog.mjs +810 -829
  92. package/fesm2022/dialog.mjs.map +1 -1
  93. package/fesm2022/divider-testing.mjs +10 -11
  94. package/fesm2022/divider-testing.mjs.map +1 -1
  95. package/fesm2022/divider.mjs +119 -43
  96. package/fesm2022/divider.mjs.map +1 -1
  97. package/fesm2022/expansion-testing.mjs +74 -130
  98. package/fesm2022/expansion-testing.mjs.map +1 -1
  99. package/fesm2022/expansion.mjs +703 -515
  100. package/fesm2022/expansion.mjs.map +1 -1
  101. package/fesm2022/form-field-testing-control.mjs +16 -33
  102. package/fesm2022/form-field-testing-control.mjs.map +1 -1
  103. package/fesm2022/form-field-testing.mjs +118 -179
  104. package/fesm2022/form-field-testing.mjs.map +1 -1
  105. package/fesm2022/form-field.mjs +36 -10
  106. package/fesm2022/form-field.mjs.map +1 -1
  107. package/fesm2022/grid-list-testing.mjs +65 -113
  108. package/fesm2022/grid-list-testing.mjs.map +1 -1
  109. package/fesm2022/grid-list.mjs +559 -494
  110. package/fesm2022/grid-list.mjs.map +1 -1
  111. package/fesm2022/icon-testing.mjs +148 -127
  112. package/fesm2022/icon-testing.mjs.map +1 -1
  113. package/fesm2022/icon.mjs +325 -351
  114. package/fesm2022/icon.mjs.map +1 -1
  115. package/fesm2022/input-testing.mjs +59 -99
  116. package/fesm2022/input-testing.mjs.map +1 -1
  117. package/fesm2022/input.mjs +457 -520
  118. package/fesm2022/input.mjs.map +1 -1
  119. package/fesm2022/list-testing.mjs +251 -434
  120. package/fesm2022/list-testing.mjs.map +1 -1
  121. package/fesm2022/list.mjs +1522 -1204
  122. package/fesm2022/list.mjs.map +1 -1
  123. package/fesm2022/material.mjs +0 -5
  124. package/fesm2022/material.mjs.map +1 -1
  125. package/fesm2022/menu-testing.mjs +159 -228
  126. package/fesm2022/menu-testing.mjs.map +1 -1
  127. package/fesm2022/menu.mjs +1338 -1343
  128. package/fesm2022/menu.mjs.map +1 -1
  129. package/fesm2022/paginator-testing.mjs +55 -79
  130. package/fesm2022/paginator-testing.mjs.map +1 -1
  131. package/fesm2022/paginator.mjs +381 -309
  132. package/fesm2022/paginator.mjs.map +1 -1
  133. package/fesm2022/progress-bar-testing.mjs +12 -21
  134. package/fesm2022/progress-bar-testing.mjs.map +1 -1
  135. package/fesm2022/progress-bar.mjs +224 -169
  136. package/fesm2022/progress-bar.mjs.map +1 -1
  137. package/fesm2022/progress-spinner-testing.mjs +13 -23
  138. package/fesm2022/progress-spinner-testing.mjs.map +1 -1
  139. package/fesm2022/progress-spinner.mjs +235 -160
  140. package/fesm2022/progress-spinner.mjs.map +1 -1
  141. package/fesm2022/radio-testing.mjs +133 -208
  142. package/fesm2022/radio-testing.mjs.map +1 -1
  143. package/fesm2022/radio.mjs +712 -679
  144. package/fesm2022/radio.mjs.map +1 -1
  145. package/fesm2022/select-testing.mjs +83 -117
  146. package/fesm2022/select-testing.mjs.map +1 -1
  147. package/fesm2022/select.mjs +1116 -1246
  148. package/fesm2022/select.mjs.map +1 -1
  149. package/fesm2022/sidenav-testing.mjs +54 -120
  150. package/fesm2022/sidenav-testing.mjs.map +1 -1
  151. package/fesm2022/sidenav.mjs +1078 -995
  152. package/fesm2022/sidenav.mjs.map +1 -1
  153. package/fesm2022/slide-toggle-testing.mjs +57 -92
  154. package/fesm2022/slide-toggle-testing.mjs.map +1 -1
  155. package/fesm2022/slide-toggle.mjs +369 -279
  156. package/fesm2022/slide-toggle.mjs.map +1 -1
  157. package/fesm2022/slider-testing.mjs +90 -138
  158. package/fesm2022/slider-testing.mjs.map +1 -1
  159. package/fesm2022/slider.mjs +1651 -1716
  160. package/fesm2022/slider.mjs.map +1 -1
  161. package/fesm2022/snack-bar-testing.mjs +40 -87
  162. package/fesm2022/snack-bar-testing.mjs.map +1 -1
  163. package/fesm2022/snack-bar.mjs +763 -714
  164. package/fesm2022/snack-bar.mjs.map +1 -1
  165. package/fesm2022/sort-testing.mjs +45 -66
  166. package/fesm2022/sort-testing.mjs.map +1 -1
  167. package/fesm2022/sort.mjs +419 -344
  168. package/fesm2022/sort.mjs.map +1 -1
  169. package/fesm2022/stepper-testing.mjs +78 -154
  170. package/fesm2022/stepper-testing.mjs.map +1 -1
  171. package/fesm2022/stepper.mjs +790 -498
  172. package/fesm2022/stepper.mjs.map +1 -1
  173. package/fesm2022/table-testing.mjs +120 -213
  174. package/fesm2022/table-testing.mjs.map +1 -1
  175. package/fesm2022/table.mjs +1026 -684
  176. package/fesm2022/table.mjs.map +1 -1
  177. package/fesm2022/tabs-testing.mjs +125 -197
  178. package/fesm2022/tabs-testing.mjs.map +1 -1
  179. package/fesm2022/tabs.mjs +2351 -2028
  180. package/fesm2022/tabs.mjs.map +1 -1
  181. package/fesm2022/timepicker-testing.mjs +113 -172
  182. package/fesm2022/timepicker-testing.mjs.map +1 -1
  183. package/fesm2022/timepicker.mjs +1019 -826
  184. package/fesm2022/timepicker.mjs.map +1 -1
  185. package/fesm2022/toolbar-testing.mjs +16 -27
  186. package/fesm2022/toolbar-testing.mjs.map +1 -1
  187. package/fesm2022/toolbar.mjs +163 -78
  188. package/fesm2022/toolbar.mjs.map +1 -1
  189. package/fesm2022/tooltip-testing.mjs +41 -52
  190. package/fesm2022/tooltip-testing.mjs.map +1 -1
  191. package/fesm2022/tooltip.mjs +36 -10
  192. package/fesm2022/tooltip.mjs.map +1 -1
  193. package/fesm2022/tree-testing.mjs +86 -162
  194. package/fesm2022/tree-testing.mjs.map +1 -1
  195. package/fesm2022/tree.mjs +638 -466
  196. package/fesm2022/tree.mjs.map +1 -1
  197. package/package.json +2 -2
  198. package/schematics/ng-add/index.js +1 -1
  199. package/types/expansion.d.ts +4 -2
  200. package/types/menu-testing.d.ts +2 -0
  201. package/types/select.d.ts +1 -1
  202. package/types/timepicker.d.ts +1 -0
@@ -1,217 +1,142 @@
1
1
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
2
2
  import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
3
3
 
4
- /** Harness for interacting with a mat-radio-group in tests. */
5
4
  class MatRadioGroupHarness extends ComponentHarness {
6
- /** The selector for the host element of a `MatRadioGroup` instance. */
7
- static hostSelector = '.mat-mdc-radio-group';
8
- _buttonClass = MatRadioButtonHarness;
9
- /**
10
- * Gets a `HarnessPredicate` that can be used to search for a radio group with specific
11
- * attributes.
12
- * @param options Options for filtering which radio group instances are considered a match.
13
- * @return a `HarnessPredicate` configured with the given options.
14
- */
15
- static with(options = {}) {
16
- return new HarnessPredicate(this, options).addOption('name', options.name, MatRadioGroupHarness._checkRadioGroupName);
17
- }
18
- /** Gets the name of the radio-group. */
19
- async getName() {
20
- const hostName = await this._getGroupNameFromHost();
21
- // It's not possible to always determine the "name" of a radio-group by reading
22
- // the attribute. This is because the radio-group does not set the "name" as an
23
- // element attribute if the "name" value is set through a binding.
24
- if (hostName !== null) {
25
- return hostName;
26
- }
27
- // In case we couldn't determine the "name" of a radio-group by reading the
28
- // "name" attribute, we try to determine the "name" of the group by going
29
- // through all radio buttons.
30
- const radioNames = await this._getNamesFromRadioButtons();
31
- if (!radioNames.length) {
32
- return null;
33
- }
34
- if (!this._checkRadioNamesInGroupEqual(radioNames)) {
35
- throw Error('Radio buttons in radio-group have mismatching names.');
36
- }
37
- return radioNames[0];
38
- }
39
- /** Gets the id of the radio-group. */
40
- async getId() {
41
- return (await this.host()).getProperty('id');
42
- }
43
- /** Gets the checked radio-button in a radio-group. */
44
- async getCheckedRadioButton() {
45
- for (let radioButton of await this.getRadioButtons()) {
46
- if (await radioButton.isChecked()) {
47
- return radioButton;
48
- }
49
- }
50
- return null;
51
- }
52
- /** Gets the checked value of the radio-group. */
53
- async getCheckedValue() {
54
- const checkedRadio = await this.getCheckedRadioButton();
55
- if (!checkedRadio) {
56
- return null;
57
- }
58
- return checkedRadio.getValue();
59
- }
60
- /**
61
- * Gets a list of radio buttons which are part of the radio-group.
62
- * @param filter Optionally filters which radio buttons are included.
63
- */
64
- async getRadioButtons(filter) {
65
- return this.locatorForAll(this._buttonClass.with(filter))();
66
- }
67
- /**
68
- * Checks a radio button in this group.
69
- * @param filter An optional filter to apply to the child radio buttons. The first tab matching
70
- * the filter will be selected.
71
- */
72
- async checkRadioButton(filter) {
73
- const radioButtons = await this.getRadioButtons(filter);
74
- if (!radioButtons.length) {
75
- throw Error(`Could not find radio button matching ${JSON.stringify(filter)}`);
76
- }
77
- return radioButtons[0].check();
78
- }
79
- /** Gets the name attribute of the host element. */
80
- async _getGroupNameFromHost() {
81
- return (await this.host()).getAttribute('name');
82
- }
83
- /** Gets a list of the name attributes of all child radio buttons. */
84
- async _getNamesFromRadioButtons() {
85
- const groupNames = [];
86
- for (let radio of await this.getRadioButtons()) {
87
- const radioName = await radio.getName();
88
- if (radioName !== null) {
89
- groupNames.push(radioName);
90
- }
91
- }
92
- return groupNames;
93
- }
94
- /** Checks if the specified radio names are all equal. */
95
- _checkRadioNamesInGroupEqual(radioNames) {
96
- let groupName = null;
97
- for (let radioName of radioNames) {
98
- if (groupName === null) {
99
- groupName = radioName;
100
- }
101
- else if (groupName !== radioName) {
102
- return false;
103
- }
104
- }
105
- return true;
106
- }
107
- /**
108
- * Checks if a radio-group harness has the given name. Throws if a radio-group with
109
- * matching name could be found but has mismatching radio-button names.
110
- */
111
- static async _checkRadioGroupName(harness, name) {
112
- // Check if there is a radio-group which has the "name" attribute set
113
- // to the expected group name. It's not possible to always determine
114
- // the "name" of a radio-group by reading the attribute. This is because
115
- // the radio-group does not set the "name" as an element attribute if the
116
- // "name" value is set through a binding.
117
- if ((await harness._getGroupNameFromHost()) === name) {
118
- return true;
119
- }
120
- // Check if there is a group with radio-buttons that all have the same
121
- // expected name. This implies that the group has the given name. It's
122
- // not possible to always determine the name of a radio-group through
123
- // the attribute because there is
124
- const radioNames = await harness._getNamesFromRadioButtons();
125
- if (radioNames.indexOf(name) === -1) {
126
- return false;
127
- }
128
- if (!harness._checkRadioNamesInGroupEqual(radioNames)) {
129
- throw Error(`The locator found a radio-group with name "${name}", but some ` +
130
- `radio-button's within the group have mismatching names, which is invalid.`);
131
- }
132
- return true;
133
- }
5
+ static hostSelector = '.mat-mdc-radio-group';
6
+ _buttonClass = MatRadioButtonHarness;
7
+ static with(options = {}) {
8
+ return new HarnessPredicate(this, options).addOption('name', options.name, MatRadioGroupHarness._checkRadioGroupName);
9
+ }
10
+ async getName() {
11
+ const hostName = await this._getGroupNameFromHost();
12
+ if (hostName !== null) {
13
+ return hostName;
14
+ }
15
+ const radioNames = await this._getNamesFromRadioButtons();
16
+ if (!radioNames.length) {
17
+ return null;
18
+ }
19
+ if (!this._checkRadioNamesInGroupEqual(radioNames)) {
20
+ throw Error('Radio buttons in radio-group have mismatching names.');
21
+ }
22
+ return radioNames[0];
23
+ }
24
+ async getId() {
25
+ return (await this.host()).getProperty('id');
26
+ }
27
+ async getCheckedRadioButton() {
28
+ for (let radioButton of await this.getRadioButtons()) {
29
+ if (await radioButton.isChecked()) {
30
+ return radioButton;
31
+ }
32
+ }
33
+ return null;
34
+ }
35
+ async getCheckedValue() {
36
+ const checkedRadio = await this.getCheckedRadioButton();
37
+ if (!checkedRadio) {
38
+ return null;
39
+ }
40
+ return checkedRadio.getValue();
41
+ }
42
+ async getRadioButtons(filter) {
43
+ return this.locatorForAll(this._buttonClass.with(filter))();
44
+ }
45
+ async checkRadioButton(filter) {
46
+ const radioButtons = await this.getRadioButtons(filter);
47
+ if (!radioButtons.length) {
48
+ throw Error(`Could not find radio button matching ${JSON.stringify(filter)}`);
49
+ }
50
+ return radioButtons[0].check();
51
+ }
52
+ async _getGroupNameFromHost() {
53
+ return (await this.host()).getAttribute('name');
54
+ }
55
+ async _getNamesFromRadioButtons() {
56
+ const groupNames = [];
57
+ for (let radio of await this.getRadioButtons()) {
58
+ const radioName = await radio.getName();
59
+ if (radioName !== null) {
60
+ groupNames.push(radioName);
61
+ }
62
+ }
63
+ return groupNames;
64
+ }
65
+ _checkRadioNamesInGroupEqual(radioNames) {
66
+ let groupName = null;
67
+ for (let radioName of radioNames) {
68
+ if (groupName === null) {
69
+ groupName = radioName;
70
+ } else if (groupName !== radioName) {
71
+ return false;
72
+ }
73
+ }
74
+ return true;
75
+ }
76
+ static async _checkRadioGroupName(harness, name) {
77
+ if ((await harness._getGroupNameFromHost()) === name) {
78
+ return true;
79
+ }
80
+ const radioNames = await harness._getNamesFromRadioButtons();
81
+ if (radioNames.indexOf(name) === -1) {
82
+ return false;
83
+ }
84
+ if (!harness._checkRadioNamesInGroupEqual(radioNames)) {
85
+ throw Error(`The locator found a radio-group with name "${name}", but some ` + `radio-button's within the group have mismatching names, which is invalid.`);
86
+ }
87
+ return true;
88
+ }
134
89
  }
135
- /** Harness for interacting with a mat-radio-button in tests. */
136
90
  class MatRadioButtonHarness extends ComponentHarness {
137
- /** The selector for the host element of a `MatRadioButton` instance. */
138
- static hostSelector = '.mat-mdc-radio-button';
139
- /**
140
- * Gets a `HarnessPredicate` that can be used to search for a radio button with specific
141
- * attributes.
142
- * @param options Options for filtering which radio button instances are considered a match.
143
- * @return a `HarnessPredicate` configured with the given options.
144
- */
145
- static with(options = {}) {
146
- return new HarnessPredicate(this, options)
147
- .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabelText(), label))
148
- .addOption('name', options.name, async (harness, name) => (await harness.getName()) === name)
149
- .addOption('checked', options.checked, async (harness, checked) => (await harness.isChecked()) == checked);
150
- }
151
- _textLabel = this.locatorFor('label');
152
- _clickLabel = this._textLabel;
153
- _input = this.locatorFor('input');
154
- /** Whether the radio-button is checked. */
155
- async isChecked() {
156
- const checked = (await this._input()).getProperty('checked');
157
- return coerceBooleanProperty(await checked);
158
- }
159
- /** Whether the radio-button is disabled. */
160
- async isDisabled() {
161
- const input = await this._input();
162
- const disabled = await input.getAttribute('disabled');
163
- if (disabled !== null) {
164
- return coerceBooleanProperty(disabled);
165
- }
166
- return (await input.getAttribute('aria-disabled')) === 'true';
167
- }
168
- /** Whether the radio-button is required. */
169
- async isRequired() {
170
- const required = (await this._input()).getAttribute('required');
171
- return coerceBooleanProperty(await required);
172
- }
173
- /** Gets the radio-button's name. */
174
- async getName() {
175
- return (await this._input()).getAttribute('name');
176
- }
177
- /** Gets the radio-button's id. */
178
- async getId() {
179
- return (await this.host()).getProperty('id');
180
- }
181
- /**
182
- * Gets the value of the radio-button. The radio-button value will be converted to a string.
183
- *
184
- * Note: This means that for radio-button's with an object as a value `[object Object]` is
185
- * intentionally returned.
186
- */
187
- async getValue() {
188
- return (await this._input()).getProperty('value');
189
- }
190
- /** Gets the radio-button's label text. */
191
- async getLabelText() {
192
- return (await this._textLabel()).text();
193
- }
194
- /** Focuses the radio-button. */
195
- async focus() {
196
- return (await this._input()).focus();
197
- }
198
- /** Blurs the radio-button. */
199
- async blur() {
200
- return (await this._input()).blur();
201
- }
202
- /** Whether the radio-button is focused. */
203
- async isFocused() {
204
- return (await this._input()).isFocused();
205
- }
206
- /**
207
- * Puts the radio-button in a checked state by clicking it if it is currently unchecked,
208
- * or doing nothing if it is already checked.
209
- */
210
- async check() {
211
- if (!(await this.isChecked())) {
212
- return (await this._clickLabel()).click();
213
- }
214
- }
91
+ static hostSelector = '.mat-mdc-radio-button';
92
+ static with(options = {}) {
93
+ return new HarnessPredicate(this, options).addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabelText(), label)).addOption('name', options.name, async (harness, name) => (await harness.getName()) === name).addOption('checked', options.checked, async (harness, checked) => (await harness.isChecked()) == checked);
94
+ }
95
+ _textLabel = this.locatorFor('label');
96
+ _clickLabel = this._textLabel;
97
+ _input = this.locatorFor('input');
98
+ async isChecked() {
99
+ const checked = (await this._input()).getProperty('checked');
100
+ return coerceBooleanProperty(await checked);
101
+ }
102
+ async isDisabled() {
103
+ const input = await this._input();
104
+ const disabled = await input.getAttribute('disabled');
105
+ if (disabled !== null) {
106
+ return coerceBooleanProperty(disabled);
107
+ }
108
+ return (await input.getAttribute('aria-disabled')) === 'true';
109
+ }
110
+ async isRequired() {
111
+ const required = (await this._input()).getAttribute('required');
112
+ return coerceBooleanProperty(await required);
113
+ }
114
+ async getName() {
115
+ return (await this._input()).getAttribute('name');
116
+ }
117
+ async getId() {
118
+ return (await this.host()).getProperty('id');
119
+ }
120
+ async getValue() {
121
+ return (await this._input()).getProperty('value');
122
+ }
123
+ async getLabelText() {
124
+ return (await this._textLabel()).text();
125
+ }
126
+ async focus() {
127
+ return (await this._input()).focus();
128
+ }
129
+ async blur() {
130
+ return (await this._input()).blur();
131
+ }
132
+ async isFocused() {
133
+ return (await this._input()).isFocused();
134
+ }
135
+ async check() {
136
+ if (!(await this.isChecked())) {
137
+ return (await this._clickLabel()).click();
138
+ }
139
+ }
215
140
  }
216
141
 
217
142
  export { MatRadioButtonHarness, MatRadioGroupHarness };
@@ -1 +1 @@
1
- {"version":3,"file":"radio-testing.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/material/radio/testing/radio-harness.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {coerceBooleanProperty} from '@angular/cdk/coercion';\nimport {\n ComponentHarness,\n ComponentHarnessConstructor,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {RadioButtonHarnessFilters, RadioGroupHarnessFilters} from './radio-harness-filters';\n\n/** Harness for interacting with a mat-radio-group in tests. */\nexport class MatRadioGroupHarness extends ComponentHarness {\n /** The selector for the host element of a `MatRadioGroup` instance. */\n static hostSelector = '.mat-mdc-radio-group';\n\n private _buttonClass = MatRadioButtonHarness;\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a radio group with specific\n * attributes.\n * @param options Options for filtering which radio group instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with<T extends MatRadioGroupHarness>(\n this: ComponentHarnessConstructor<T>,\n options: RadioGroupHarnessFilters = {},\n ): HarnessPredicate<T> {\n return new HarnessPredicate(this, options).addOption(\n 'name',\n options.name,\n MatRadioGroupHarness._checkRadioGroupName,\n );\n }\n\n /** Gets the name of the radio-group. */\n async getName(): Promise<string | null> {\n const hostName = await this._getGroupNameFromHost();\n // It's not possible to always determine the \"name\" of a radio-group by reading\n // the attribute. This is because the radio-group does not set the \"name\" as an\n // element attribute if the \"name\" value is set through a binding.\n if (hostName !== null) {\n return hostName;\n }\n // In case we couldn't determine the \"name\" of a radio-group by reading the\n // \"name\" attribute, we try to determine the \"name\" of the group by going\n // through all radio buttons.\n const radioNames = await this._getNamesFromRadioButtons();\n if (!radioNames.length) {\n return null;\n }\n if (!this._checkRadioNamesInGroupEqual(radioNames)) {\n throw Error('Radio buttons in radio-group have mismatching names.');\n }\n return radioNames[0]!;\n }\n\n /** Gets the id of the radio-group. */\n async getId(): Promise<string | null> {\n return (await this.host()).getProperty<string | null>('id');\n }\n\n /** Gets the checked radio-button in a radio-group. */\n async getCheckedRadioButton(): Promise<MatRadioButtonHarness | null> {\n for (let radioButton of await this.getRadioButtons()) {\n if (await radioButton.isChecked()) {\n return radioButton;\n }\n }\n return null;\n }\n\n /** Gets the checked value of the radio-group. */\n async getCheckedValue(): Promise<string | null> {\n const checkedRadio = await this.getCheckedRadioButton();\n if (!checkedRadio) {\n return null;\n }\n return checkedRadio.getValue();\n }\n\n /**\n * Gets a list of radio buttons which are part of the radio-group.\n * @param filter Optionally filters which radio buttons are included.\n */\n async getRadioButtons(filter?: RadioButtonHarnessFilters): Promise<MatRadioButtonHarness[]> {\n return this.locatorForAll(this._buttonClass.with(filter))();\n }\n\n /**\n * Checks a radio button in this group.\n * @param filter An optional filter to apply to the child radio buttons. The first tab matching\n * the filter will be selected.\n */\n async checkRadioButton(filter?: RadioButtonHarnessFilters): Promise<void> {\n const radioButtons = await this.getRadioButtons(filter);\n if (!radioButtons.length) {\n throw Error(`Could not find radio button matching ${JSON.stringify(filter)}`);\n }\n return radioButtons[0].check();\n }\n\n /** Gets the name attribute of the host element. */\n private async _getGroupNameFromHost() {\n return (await this.host()).getAttribute('name');\n }\n\n /** Gets a list of the name attributes of all child radio buttons. */\n private async _getNamesFromRadioButtons(): Promise<string[]> {\n const groupNames: string[] = [];\n for (let radio of await this.getRadioButtons()) {\n const radioName = await radio.getName();\n if (radioName !== null) {\n groupNames.push(radioName);\n }\n }\n return groupNames;\n }\n\n /** Checks if the specified radio names are all equal. */\n private _checkRadioNamesInGroupEqual(radioNames: string[]): boolean {\n let groupName: string | null = null;\n for (let radioName of radioNames) {\n if (groupName === null) {\n groupName = radioName;\n } else if (groupName !== radioName) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Checks if a radio-group harness has the given name. Throws if a radio-group with\n * matching name could be found but has mismatching radio-button names.\n */\n protected static async _checkRadioGroupName(harness: MatRadioGroupHarness, name: string) {\n // Check if there is a radio-group which has the \"name\" attribute set\n // to the expected group name. It's not possible to always determine\n // the \"name\" of a radio-group by reading the attribute. This is because\n // the radio-group does not set the \"name\" as an element attribute if the\n // \"name\" value is set through a binding.\n if ((await harness._getGroupNameFromHost()) === name) {\n return true;\n }\n // Check if there is a group with radio-buttons that all have the same\n // expected name. This implies that the group has the given name. It's\n // not possible to always determine the name of a radio-group through\n // the attribute because there is\n const radioNames = await harness._getNamesFromRadioButtons();\n if (radioNames.indexOf(name) === -1) {\n return false;\n }\n if (!harness._checkRadioNamesInGroupEqual(radioNames)) {\n throw Error(\n `The locator found a radio-group with name \"${name}\", but some ` +\n `radio-button's within the group have mismatching names, which is invalid.`,\n );\n }\n return true;\n }\n}\n\n/** Harness for interacting with a mat-radio-button in tests. */\nexport class MatRadioButtonHarness extends ComponentHarness {\n /** The selector for the host element of a `MatRadioButton` instance. */\n static hostSelector = '.mat-mdc-radio-button';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a radio button with specific\n * attributes.\n * @param options Options for filtering which radio button instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with<T extends MatRadioButtonHarness>(\n this: ComponentHarnessConstructor<T>,\n options: RadioButtonHarnessFilters = {},\n ): HarnessPredicate<T> {\n return new HarnessPredicate(this, options)\n .addOption('label', options.label, (harness, label) =>\n HarnessPredicate.stringMatches(harness.getLabelText(), label),\n )\n .addOption('name', options.name, async (harness, name) => (await harness.getName()) === name)\n .addOption(\n 'checked',\n options.checked,\n async (harness, checked) => (await harness.isChecked()) == checked,\n );\n }\n\n protected _textLabel = this.locatorFor('label');\n protected _clickLabel = this._textLabel;\n private _input = this.locatorFor('input');\n\n /** Whether the radio-button is checked. */\n async isChecked(): Promise<boolean> {\n const checked = (await this._input()).getProperty<boolean>('checked');\n return coerceBooleanProperty(await checked);\n }\n\n /** Whether the radio-button is disabled. */\n async isDisabled(): Promise<boolean> {\n const input = await this._input();\n const disabled = await input.getAttribute('disabled');\n\n if (disabled !== null) {\n return coerceBooleanProperty(disabled);\n }\n\n return (await input.getAttribute('aria-disabled')) === 'true';\n }\n\n /** Whether the radio-button is required. */\n async isRequired(): Promise<boolean> {\n const required = (await this._input()).getAttribute('required');\n return coerceBooleanProperty(await required);\n }\n\n /** Gets the radio-button's name. */\n async getName(): Promise<string | null> {\n return (await this._input()).getAttribute('name');\n }\n\n /** Gets the radio-button's id. */\n async getId(): Promise<string | null> {\n return (await this.host()).getProperty<string>('id');\n }\n\n /**\n * Gets the value of the radio-button. The radio-button value will be converted to a string.\n *\n * Note: This means that for radio-button's with an object as a value `[object Object]` is\n * intentionally returned.\n */\n async getValue(): Promise<string | null> {\n return (await this._input()).getProperty('value');\n }\n\n /** Gets the radio-button's label text. */\n async getLabelText(): Promise<string> {\n return (await this._textLabel()).text();\n }\n\n /** Focuses the radio-button. */\n async focus(): Promise<void> {\n return (await this._input()).focus();\n }\n\n /** Blurs the radio-button. */\n async blur(): Promise<void> {\n return (await this._input()).blur();\n }\n\n /** Whether the radio-button is focused. */\n async isFocused(): Promise<boolean> {\n return (await this._input()).isFocused();\n }\n\n /**\n * Puts the radio-button in a checked state by clicking it if it is currently unchecked,\n * or doing nothing if it is already checked.\n */\n async check(): Promise<void> {\n if (!(await this.isChecked())) {\n return (await this._clickLabel()).click();\n }\n }\n}\n"],"names":[],"mappings":";;;AAgBA;AACM,MAAO,oBAAqB,SAAQ,gBAAgB,CAAA;;AAExD,IAAA,OAAO,YAAY,GAAG,sBAAsB;IAEpC,YAAY,GAAG,qBAAqB;AAE5C;;;;;AAKG;AACH,IAAA,OAAO,IAAI,CAET,OAAA,GAAoC,EAAE,EAAA;QAEtC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS,CAClD,MAAM,EACN,OAAO,CAAC,IAAI,EACZ,oBAAoB,CAAC,oBAAoB,CAC1C;;;AAIH,IAAA,MAAM,OAAO,GAAA;AACX,Q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E,SAAS,EAAE;;AAG1C;;;AAGG;AACH,IAAA,MAAM,KAAK,GAAA;QACT,IAAI,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE;YAC7B,OAAO,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE;;;;;;;"}
1
+ {"version":3,"file":"radio-testing.mjs","sources":["../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/material/radio/testing/radio-harness.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {coerceBooleanProperty} from '@angular/cdk/coercion';\nimport {\n ComponentHarness,\n ComponentHarnessConstructor,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {RadioButtonHarnessFilters, RadioGroupHarnessFilters} from './radio-harness-filters';\n\n/** Harness for interacting with a mat-radio-group in tests. */\nexport class MatRadioGroupHarness extends ComponentHarness {\n /** The selector for the host element of a `MatRadioGroup` instance. */\n static hostSelector = '.mat-mdc-radio-group';\n\n private _buttonClass = MatRadioButtonHarness;\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a radio group with specific\n * attributes.\n * @param options Options for filtering which radio group instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with<T extends MatRadioGroupHarness>(\n this: ComponentHarnessConstructor<T>,\n options: RadioGroupHarnessFilters = {},\n ): HarnessPredicate<T> {\n return new HarnessPredicate(this, options).addOption(\n 'name',\n options.name,\n MatRadioGroupHarness._checkRadioGroupName,\n );\n }\n\n /** Gets the name of the radio-group. */\n async getName(): Promise<string | null> {\n const hostName = await this._getGroupNameFromHost();\n // It's not possible to always determine the \"name\" of a radio-group by reading\n // the attribute. This is because the radio-group does not set the \"name\" as an\n // element attribute if the \"name\" value is set through a binding.\n if (hostName !== null) {\n return hostName;\n }\n // In case we couldn't determine the \"name\" of a radio-group by reading the\n // \"name\" attribute, we try to determine the \"name\" of the group by going\n // through all radio buttons.\n const radioNames = await this._getNamesFromRadioButtons();\n if (!radioNames.length) {\n return null;\n }\n if (!this._checkRadioNamesInGroupEqual(radioNames)) {\n throw Error('Radio buttons in radio-group have mismatching names.');\n }\n return radioNames[0]!;\n }\n\n /** Gets the id of the radio-group. */\n async getId(): Promise<string | null> {\n return (await this.host()).getProperty<string | null>('id');\n }\n\n /** Gets the checked radio-button in a radio-group. */\n async getCheckedRadioButton(): Promise<MatRadioButtonHarness | null> {\n for (let radioButton of await this.getRadioButtons()) {\n if (await radioButton.isChecked()) {\n return radioButton;\n }\n }\n return null;\n }\n\n /** Gets the checked value of the radio-group. */\n async getCheckedValue(): Promise<string | null> {\n const checkedRadio = await this.getCheckedRadioButton();\n if (!checkedRadio) {\n return null;\n }\n return checkedRadio.getValue();\n }\n\n /**\n * Gets a list of radio buttons which are part of the radio-group.\n * @param filter Optionally filters which radio buttons are included.\n */\n async getRadioButtons(filter?: RadioButtonHarnessFilters): Promise<MatRadioButtonHarness[]> {\n return this.locatorForAll(this._buttonClass.with(filter))();\n }\n\n /**\n * Checks a radio button in this group.\n * @param filter An optional filter to apply to the child radio buttons. The first tab matching\n * the filter will be selected.\n */\n async checkRadioButton(filter?: RadioButtonHarnessFilters): Promise<void> {\n const radioButtons = await this.getRadioButtons(filter);\n if (!radioButtons.length) {\n throw Error(`Could not find radio button matching ${JSON.stringify(filter)}`);\n }\n return radioButtons[0].check();\n }\n\n /** Gets the name attribute of the host element. */\n private async _getGroupNameFromHost() {\n return (await this.host()).getAttribute('name');\n }\n\n /** Gets a list of the name attributes of all child radio buttons. */\n private async _getNamesFromRadioButtons(): Promise<string[]> {\n const groupNames: string[] = [];\n for (let radio of await this.getRadioButtons()) {\n const radioName = await radio.getName();\n if (radioName !== null) {\n groupNames.push(radioName);\n }\n }\n return groupNames;\n }\n\n /** Checks if the specified radio names are all equal. */\n private _checkRadioNamesInGroupEqual(radioNames: string[]): boolean {\n let groupName: string | null = null;\n for (let radioName of radioNames) {\n if (groupName === null) {\n groupName = radioName;\n } else if (groupName !== radioName) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Checks if a radio-group harness has the given name. Throws if a radio-group with\n * matching name could be found but has mismatching radio-button names.\n */\n protected static async _checkRadioGroupName(harness: MatRadioGroupHarness, name: string) {\n // Check if there is a radio-group which has the \"name\" attribute set\n // to the expected group name. It's not possible to always determine\n // the \"name\" of a radio-group by reading the attribute. This is because\n // the radio-group does not set the \"name\" as an element attribute if the\n // \"name\" value is set through a binding.\n if ((await harness._getGroupNameFromHost()) === name) {\n return true;\n }\n // Check if there is a group with radio-buttons that all have the same\n // expected name. This implies that the group has the given name. It's\n // not possible to always determine the name of a radio-group through\n // the attribute because there is\n const radioNames = await harness._getNamesFromRadioButtons();\n if (radioNames.indexOf(name) === -1) {\n return false;\n }\n if (!harness._checkRadioNamesInGroupEqual(radioNames)) {\n throw Error(\n `The locator found a radio-group with name \"${name}\", but some ` +\n `radio-button's within the group have mismatching names, which is invalid.`,\n );\n }\n return true;\n }\n}\n\n/** Harness for interacting with a mat-radio-button in tests. */\nexport class MatRadioButtonHarness extends ComponentHarness {\n /** The selector for the host element of a `MatRadioButton` instance. */\n static hostSelector = '.mat-mdc-radio-button';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a radio button with specific\n * attributes.\n * @param options Options for filtering which radio button instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with<T extends MatRadioButtonHarness>(\n this: ComponentHarnessConstructor<T>,\n options: RadioButtonHarnessFilters = {},\n ): HarnessPredicate<T> {\n return new HarnessPredicate(this, options)\n .addOption('label', options.label, (harness, label) =>\n HarnessPredicate.stringMatches(harness.getLabelText(), label),\n )\n .addOption('name', options.name, async (harness, name) => (await harness.getName()) === name)\n .addOption(\n 'checked',\n options.checked,\n async (harness, checked) => (await harness.isChecked()) == checked,\n );\n }\n\n protected _textLabel = this.locatorFor('label');\n protected _clickLabel = this._textLabel;\n private _input = this.locatorFor('input');\n\n /** Whether the radio-button is checked. */\n async isChecked(): Promise<boolean> {\n const checked = (await this._input()).getProperty<boolean>('checked');\n return coerceBooleanProperty(await checked);\n }\n\n /** Whether the radio-button is disabled. */\n async isDisabled(): Promise<boolean> {\n const input = await this._input();\n const disabled = await input.getAttribute('disabled');\n\n if (disabled !== null) {\n return coerceBooleanProperty(disabled);\n }\n\n return (await input.getAttribute('aria-disabled')) === 'true';\n }\n\n /** Whether the radio-button is required. */\n async isRequired(): Promise<boolean> {\n const required = (await this._input()).getAttribute('required');\n return coerceBooleanProperty(await required);\n }\n\n /** Gets the radio-button's name. */\n async getName(): Promise<string | null> {\n return (await this._input()).getAttribute('name');\n }\n\n /** Gets the radio-button's id. */\n async getId(): Promise<string | null> {\n return (await this.host()).getProperty<string>('id');\n }\n\n /**\n * Gets the value of the radio-button. The radio-button value will be converted to a string.\n *\n * Note: This means that for radio-button's with an object as a value `[object Object]` is\n * intentionally returned.\n */\n async getValue(): Promise<string | null> {\n return (await this._input()).getProperty('value');\n }\n\n /** Gets the radio-button's label text. */\n async getLabelText(): Promise<string> {\n return (await this._textLabel()).text();\n }\n\n /** Focuses the radio-button. */\n async focus(): Promise<void> {\n return (await this._input()).focus();\n }\n\n /** Blurs the radio-button. */\n async blur(): Promise<void> {\n return (await this._input()).blur();\n }\n\n /** Whether the radio-button is focused. */\n async isFocused(): Promise<boolean> {\n return (await this._input()).isFocused();\n }\n\n /**\n * Puts the radio-button in a checked state by clicking it if it is currently unchecked,\n * or doing nothing if it is already checked.\n */\n async check(): Promise<void> {\n if (!(await this.isChecked())) {\n return (await this._clickLabel()).click();\n }\n }\n}\n"],"names":["MatRadioGroupHarness","ComponentHarness","hostSelector","_buttonClass","MatRadioButtonHarness","with","options","HarnessPredicate","addOption","name","_checkRadioGroupName","getName","hostName","_getGroupNameFromHost","radioNames","_getNamesFromRadioButtons","length","_checkRadioNamesInGroupEqual","Error","getId","host","getProperty","getCheckedRadioButton","radioButton","getRadioButtons","isChecked","getCheckedValue","checkedRadio","getValue","filter","locatorForAll","checkRadioButton","radioButtons","JSON","stringify","check","getAttribute","groupNames","radio","radioName","push","groupName","harness","indexOf","label","stringMatches","getLabelText","checked","_textLabel","locatorFor","_clickLabel","_input","coerceBooleanProperty","isDisabled","input","disabled","isRequired","required","text","focus","blur","isFocused","click"],"mappings":";;;AAiBM,MAAOA,oBAAqB,SAAQC,gBAAgB,CAAA;EAExD,OAAOC,YAAY,GAAG,sBAAsB;AAEpCC,EAAAA,YAAY,GAAGC,qBAAqB;AAQ5C,EAAA,OAAOC,IAAIA,CAETC,OAAA,GAAoC,EAAE,EAAA;AAEtC,IAAA,OAAO,IAAIC,gBAAgB,CAAC,IAAI,EAAED,OAAO,CAAC,CAACE,SAAS,CAClD,MAAM,EACNF,OAAO,CAACG,IAAI,EACZT,oBAAoB,CAACU,oBAAoB,CAC1C;AACH;EAGA,MAAMC,OAAOA,GAAA;AACX,IAAA,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACC,qBAAqB,EAAE;IAInD,IAAID,QAAQ,KAAK,IAAI,EAAE;AACrB,MAAA,OAAOA,QAAQ;AACjB;AAIA,IAAA,MAAME,UAAU,GAAG,MAAM,IAAI,CAACC,yBAAyB,EAAE;AACzD,IAAA,IAAI,CAACD,UAAU,CAACE,MAAM,EAAE;AACtB,MAAA,OAAO,IAAI;AACb;AACA,IAAA,IAAI,CAAC,IAAI,CAACC,4BAA4B,CAACH,UAAU,CAAC,EAAE;MAClD,MAAMI,KAAK,CAAC,sDAAsD,CAAC;AACrE;IACA,OAAOJ,UAAU,CAAC,CAAC,CAAE;AACvB;EAGA,MAAMK,KAAKA,GAAA;IACT,OAAO,CAAC,MAAM,IAAI,CAACC,IAAI,EAAE,EAAEC,WAAW,CAAgB,IAAI,CAAC;AAC7D;EAGA,MAAMC,qBAAqBA,GAAA;IACzB,KAAK,IAAIC,WAAW,IAAI,MAAM,IAAI,CAACC,eAAe,EAAE,EAAE;AACpD,MAAA,IAAI,MAAMD,WAAW,C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