@ember-joinery/test-support 0.0.0-stage → 1.0.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 (285) hide show
  1. package/CHANGELOG.md +550 -0
  2. package/LICENSE.md +9 -0
  3. package/NOTICE +532 -0
  4. package/README.md +356 -2
  5. package/addon-main.cjs +4 -0
  6. package/dist/-private/checkable.d.ts +21 -0
  7. package/dist/-private/checkable.d.ts.map +1 -0
  8. package/dist/-private/checkable.js +80 -0
  9. package/dist/-private/control.d.ts +18 -0
  10. package/dist/-private/control.d.ts.map +1 -0
  11. package/dist/-private/control.js +55 -0
  12. package/dist/-private/menu.d.ts +145 -0
  13. package/dist/-private/menu.d.ts.map +1 -0
  14. package/dist/-private/menu.js +322 -0
  15. package/dist/-private/overlay.d.ts +9 -0
  16. package/dist/-private/overlay.d.ts.map +1 -0
  17. package/dist/-private/overlay.js +39 -0
  18. package/dist/-private/showing.d.ts +7 -0
  19. package/dist/-private/showing.d.ts.map +1 -0
  20. package/dist/-private/showing.js +10 -0
  21. package/dist/-private/size.d.ts +10 -0
  22. package/dist/-private/size.d.ts.map +1 -0
  23. package/dist/-private/size.js +24 -0
  24. package/dist/-private/tree.d.ts +34 -0
  25. package/dist/-private/tree.d.ts.map +1 -0
  26. package/dist/-private/tree.js +80 -0
  27. package/dist/accordion.d.ts +62 -0
  28. package/dist/accordion.d.ts.map +1 -0
  29. package/dist/accordion.js +112 -0
  30. package/dist/alert-dialog.d.ts +24 -0
  31. package/dist/alert-dialog.d.ts.map +1 -0
  32. package/dist/alert-dialog.js +37 -0
  33. package/dist/alert.d.ts +27 -0
  34. package/dist/alert.d.ts.map +1 -0
  35. package/dist/alert.js +43 -0
  36. package/dist/aspect-ratio.d.ts +21 -0
  37. package/dist/aspect-ratio.d.ts.map +1 -0
  38. package/dist/aspect-ratio.js +30 -0
  39. package/dist/attachment.d.ts +86 -0
  40. package/dist/attachment.d.ts.map +1 -0
  41. package/dist/attachment.js +156 -0
  42. package/dist/avatar.d.ts +65 -0
  43. package/dist/avatar.d.ts.map +1 -0
  44. package/dist/avatar.js +106 -0
  45. package/dist/badge.d.ts +29 -0
  46. package/dist/badge.d.ts.map +1 -0
  47. package/dist/badge.js +49 -0
  48. package/dist/breadcrumb.d.ts +36 -0
  49. package/dist/breadcrumb.d.ts.map +1 -0
  50. package/dist/breadcrumb.js +80 -0
  51. package/dist/bubble.d.ts +56 -0
  52. package/dist/bubble.d.ts.map +1 -0
  53. package/dist/bubble.js +94 -0
  54. package/dist/button-group.d.ts +34 -0
  55. package/dist/button-group.d.ts.map +1 -0
  56. package/dist/button-group.js +62 -0
  57. package/dist/button.d.ts +37 -0
  58. package/dist/button.d.ts.map +1 -0
  59. package/dist/button.js +77 -0
  60. package/dist/calendar.d.ts +115 -0
  61. package/dist/calendar.d.ts.map +1 -0
  62. package/dist/calendar.js +276 -0
  63. package/dist/card.d.ts +31 -0
  64. package/dist/card.d.ts.map +1 -0
  65. package/dist/card.js +49 -0
  66. package/dist/checkbox.d.ts +46 -0
  67. package/dist/checkbox.d.ts.map +1 -0
  68. package/dist/checkbox.js +84 -0
  69. package/dist/child.d.ts +29 -0
  70. package/dist/child.d.ts.map +1 -0
  71. package/dist/child.js +27 -0
  72. package/dist/collapsible.d.ts +44 -0
  73. package/dist/collapsible.d.ts.map +1 -0
  74. package/dist/collapsible.js +83 -0
  75. package/dist/color-scheme.d.ts +44 -0
  76. package/dist/color-scheme.d.ts.map +1 -0
  77. package/dist/color-scheme.js +123 -0
  78. package/dist/combobox.d.ts +114 -0
  79. package/dist/combobox.d.ts.map +1 -0
  80. package/dist/combobox.js +293 -0
  81. package/dist/command.d.ts +92 -0
  82. package/dist/command.d.ts.map +1 -0
  83. package/dist/command.js +183 -0
  84. package/dist/context-menu.d.ts +37 -0
  85. package/dist/context-menu.d.ts.map +1 -0
  86. package/dist/context-menu.js +59 -0
  87. package/dist/date-picker.d.ts +48 -0
  88. package/dist/date-picker.d.ts.map +1 -0
  89. package/dist/date-picker.js +136 -0
  90. package/dist/dialog.d.ts +64 -0
  91. package/dist/dialog.d.ts.map +1 -0
  92. package/dist/dialog.js +142 -0
  93. package/dist/drawer.d.ts +63 -0
  94. package/dist/drawer.d.ts.map +1 -0
  95. package/dist/drawer.js +136 -0
  96. package/dist/dropdown-menu.d.ts +35 -0
  97. package/dist/dropdown-menu.d.ts.map +1 -0
  98. package/dist/dropdown-menu.js +49 -0
  99. package/dist/empty.d.ts +29 -0
  100. package/dist/empty.d.ts.map +1 -0
  101. package/dist/empty.js +47 -0
  102. package/dist/field.d.ts +86 -0
  103. package/dist/field.d.ts.map +1 -0
  104. package/dist/field.js +150 -0
  105. package/dist/file-drop.d.ts +74 -0
  106. package/dist/file-drop.d.ts.map +1 -0
  107. package/dist/file-drop.js +137 -0
  108. package/dist/focus.d.ts +54 -0
  109. package/dist/focus.d.ts.map +1 -0
  110. package/dist/focus.js +174 -0
  111. package/dist/harness.d.ts +90 -0
  112. package/dist/harness.d.ts.map +1 -0
  113. package/dist/harness.js +189 -0
  114. package/dist/heading.d.ts +16 -0
  115. package/dist/heading.d.ts.map +1 -0
  116. package/dist/heading.js +19 -0
  117. package/dist/hero.d.ts +21 -0
  118. package/dist/hero.d.ts.map +1 -0
  119. package/dist/hero.js +28 -0
  120. package/dist/hover-card.d.ts +46 -0
  121. package/dist/hover-card.d.ts.map +1 -0
  122. package/dist/hover-card.js +85 -0
  123. package/dist/icon.d.ts +10 -0
  124. package/dist/icon.d.ts.map +1 -0
  125. package/dist/icon.js +13 -0
  126. package/dist/index.d.ts +86 -0
  127. package/dist/index.d.ts.map +1 -0
  128. package/dist/index.js +87 -0
  129. package/dist/input-group.d.ts +55 -0
  130. package/dist/input-group.d.ts.map +1 -0
  131. package/dist/input-group.js +103 -0
  132. package/dist/input-otp.d.ts +103 -0
  133. package/dist/input-otp.d.ts.map +1 -0
  134. package/dist/input-otp.js +293 -0
  135. package/dist/input.d.ts +53 -0
  136. package/dist/input.d.ts.map +1 -0
  137. package/dist/input.js +90 -0
  138. package/dist/item.d.ts +63 -0
  139. package/dist/item.d.ts.map +1 -0
  140. package/dist/item.js +104 -0
  141. package/dist/kbd.d.ts +28 -0
  142. package/dist/kbd.d.ts.map +1 -0
  143. package/dist/kbd.js +36 -0
  144. package/dist/keys.d.ts +20 -0
  145. package/dist/keys.d.ts.map +1 -0
  146. package/dist/keys.js +32 -0
  147. package/dist/label.d.ts +24 -0
  148. package/dist/label.d.ts.map +1 -0
  149. package/dist/label.js +39 -0
  150. package/dist/layers.d.ts +42 -0
  151. package/dist/layers.d.ts.map +1 -0
  152. package/dist/layers.js +70 -0
  153. package/dist/link.d.ts +44 -0
  154. package/dist/link.d.ts.map +1 -0
  155. package/dist/link.js +60 -0
  156. package/dist/marker.d.ts +42 -0
  157. package/dist/marker.d.ts.map +1 -0
  158. package/dist/marker.js +73 -0
  159. package/dist/menubar.d.ts +76 -0
  160. package/dist/menubar.d.ts.map +1 -0
  161. package/dist/menubar.js +139 -0
  162. package/dist/message-scroller.d.ts +101 -0
  163. package/dist/message-scroller.d.ts.map +1 -0
  164. package/dist/message-scroller.js +215 -0
  165. package/dist/message.d.ts +48 -0
  166. package/dist/message.d.ts.map +1 -0
  167. package/dist/message.js +72 -0
  168. package/dist/native-form.d.ts +44 -0
  169. package/dist/native-form.d.ts.map +1 -0
  170. package/dist/native-form.js +111 -0
  171. package/dist/native-select.d.ts +56 -0
  172. package/dist/native-select.d.ts.map +1 -0
  173. package/dist/native-select.js +100 -0
  174. package/dist/navigation-menu.d.ts +97 -0
  175. package/dist/navigation-menu.d.ts.map +1 -0
  176. package/dist/navigation-menu.js +207 -0
  177. package/dist/observers.d.ts +21 -0
  178. package/dist/observers.d.ts.map +1 -0
  179. package/dist/observers.js +34 -0
  180. package/dist/pagination.d.ts +39 -0
  181. package/dist/pagination.d.ts.map +1 -0
  182. package/dist/pagination.js +71 -0
  183. package/dist/pointer.d.ts +38 -0
  184. package/dist/pointer.d.ts.map +1 -0
  185. package/dist/pointer.js +82 -0
  186. package/dist/popover.d.ts +50 -0
  187. package/dist/popover.d.ts.map +1 -0
  188. package/dist/popover.js +90 -0
  189. package/dist/progress.d.ts +38 -0
  190. package/dist/progress.d.ts.map +1 -0
  191. package/dist/progress.js +81 -0
  192. package/dist/questionnaire.d.ts +117 -0
  193. package/dist/questionnaire.d.ts.map +1 -0
  194. package/dist/questionnaire.js +240 -0
  195. package/dist/radio-group.d.ts +53 -0
  196. package/dist/radio-group.d.ts.map +1 -0
  197. package/dist/radio-group.js +95 -0
  198. package/dist/rating.d.ts +67 -0
  199. package/dist/rating.d.ts.map +1 -0
  200. package/dist/rating.js +160 -0
  201. package/dist/resizable.d.ts +76 -0
  202. package/dist/resizable.d.ts.map +1 -0
  203. package/dist/resizable.js +138 -0
  204. package/dist/routing.d.ts +36 -0
  205. package/dist/routing.d.ts.map +1 -0
  206. package/dist/routing.js +50 -0
  207. package/dist/roving-focus.d.ts +38 -0
  208. package/dist/roving-focus.d.ts.map +1 -0
  209. package/dist/roving-focus.js +60 -0
  210. package/dist/scroll-area.d.ts +58 -0
  211. package/dist/scroll-area.d.ts.map +1 -0
  212. package/dist/scroll-area.js +153 -0
  213. package/dist/scroller.d.ts +41 -0
  214. package/dist/scroller.d.ts.map +1 -0
  215. package/dist/scroller.js +65 -0
  216. package/dist/select.d.ts +98 -0
  217. package/dist/select.d.ts.map +1 -0
  218. package/dist/select.js +203 -0
  219. package/dist/selectors.d.ts +44 -0
  220. package/dist/selectors.d.ts.map +1 -0
  221. package/dist/selectors.js +63 -0
  222. package/dist/send-pointer.d.ts +17 -0
  223. package/dist/send-pointer.d.ts.map +1 -0
  224. package/dist/send-pointer.js +35 -0
  225. package/dist/separator.d.ts +26 -0
  226. package/dist/separator.d.ts.map +1 -0
  227. package/dist/separator.js +40 -0
  228. package/dist/shadowed.d.ts +55 -0
  229. package/dist/shadowed.d.ts.map +1 -0
  230. package/dist/shadowed.js +97 -0
  231. package/dist/sheet.d.ts +14 -0
  232. package/dist/sheet.d.ts.map +1 -0
  233. package/dist/sheet.js +15 -0
  234. package/dist/sidebar.d.ts +159 -0
  235. package/dist/sidebar.d.ts.map +1 -0
  236. package/dist/sidebar.js +299 -0
  237. package/dist/skeleton.d.ts +18 -0
  238. package/dist/skeleton.d.ts.map +1 -0
  239. package/dist/skeleton.js +25 -0
  240. package/dist/slider.d.ts +66 -0
  241. package/dist/slider.d.ts.map +1 -0
  242. package/dist/slider.js +155 -0
  243. package/dist/spinner.d.ts +10 -0
  244. package/dist/spinner.d.ts.map +1 -0
  245. package/dist/spinner.js +13 -0
  246. package/dist/sticky-footer.d.ts +33 -0
  247. package/dist/sticky-footer.d.ts.map +1 -0
  248. package/dist/sticky-footer.js +65 -0
  249. package/dist/switch.d.ts +44 -0
  250. package/dist/switch.d.ts.map +1 -0
  251. package/dist/switch.js +77 -0
  252. package/dist/table.d.ts +41 -0
  253. package/dist/table.d.ts.map +1 -0
  254. package/dist/table.js +100 -0
  255. package/dist/tabs.d.ts +66 -0
  256. package/dist/tabs.d.ts.map +1 -0
  257. package/dist/tabs.js +149 -0
  258. package/dist/test-hooks.d.ts +9 -0
  259. package/dist/test-hooks.d.ts.map +1 -0
  260. package/dist/test-hooks.js +1 -0
  261. package/dist/textarea.d.ts +47 -0
  262. package/dist/textarea.d.ts.map +1 -0
  263. package/dist/textarea.js +78 -0
  264. package/dist/toaster.d.ts +172 -0
  265. package/dist/toaster.d.ts.map +1 -0
  266. package/dist/toaster.js +307 -0
  267. package/dist/toggle-group.d.ts +51 -0
  268. package/dist/toggle-group.d.ts.map +1 -0
  269. package/dist/toggle-group.js +97 -0
  270. package/dist/toggle.d.ts +21 -0
  271. package/dist/toggle.d.ts.map +1 -0
  272. package/dist/toggle.js +26 -0
  273. package/dist/tooltip.d.ts +48 -0
  274. package/dist/tooltip.d.ts.map +1 -0
  275. package/dist/tooltip.js +91 -0
  276. package/dist/trace.d.ts +118 -0
  277. package/dist/trace.d.ts.map +1 -0
  278. package/dist/trace.js +196 -0
  279. package/dist/translator.d.ts +34 -0
  280. package/dist/translator.d.ts.map +1 -0
  281. package/dist/translator.js +75 -0
  282. package/dist/zoetrope.d.ts +51 -0
  283. package/dist/zoetrope.d.ts.map +1 -0
  284. package/dist/zoetrope.js +94 -0
  285. package/package.json +68 -3
@@ -0,0 +1,97 @@
1
+ import { Harness } from './harness.ts';
2
+ /** One item of a navigation menu that opens a content: its trigger, and its content's links. */
3
+ export declare class NavigationMenuItemLevel {
4
+ #private;
5
+ constructor(trigger: () => HTMLElement);
6
+ /** Its trigger. */
7
+ get trigger(): HTMLElement;
8
+ /** Its value (`data-test-jn-value`). */
9
+ get value(): string | null;
10
+ /** Whether its content is open, from the trigger's `aria-expanded`. */
11
+ get isOpen(): boolean;
12
+ /** Its content, through the trigger's `aria-controls`, or `null` while it isn't rendered. */
13
+ get content(): HTMLElement | null;
14
+ /** The content's accessible name: its trigger's text. */
15
+ get label(): string;
16
+ /** Which way the content is moving (`data-motion`): `from-start`, `to-end`…, or `null`. */
17
+ get motion(): string | null;
18
+ /** The content's links, as elements, in order. */
19
+ get linkElements(): HTMLElement[];
20
+ /** Each of the content's links' text. */
21
+ get links(): string[];
22
+ /** The content's link whose text is `label` (or the only one starting with it). */
23
+ link(label: string): HTMLElement;
24
+ /** Clicks the trigger: it opens the content, or closes it when it is open. */
25
+ toggle(): Promise<void>;
26
+ /** Opens it with a click on the trigger, unless it is open. */
27
+ open(): Promise<void>;
28
+ /** Closes it with a click on the trigger, unless it is closed. */
29
+ close(): Promise<void>;
30
+ /** Rests the pointer on the trigger, which opens it after the menu's delay. */
31
+ hover(): Promise<void>;
32
+ /** Moves the pointer off the trigger (downwards, towards the content, unless `side` says). */
33
+ unhover(side?: 'top' | 'right' | 'bottom' | 'left'): Promise<void>;
34
+ /**
35
+ * Toggles it from the keyboard: focus on the trigger, then Enter (or Space), which presses
36
+ * the button, as a browser does (`pressKey` sends only the key's events). Focus stays on the
37
+ * trigger; Tab or ArrowDown goes on into the content.
38
+ */
39
+ openWithKeyboard(key?: 'Enter' | ' '): Promise<void>;
40
+ /** Clicks the content's link `label`: it follows it, and closes the content. */
41
+ select(label: string): Promise<void>;
42
+ }
43
+ /**
44
+ * Drives a `<NavigationMenu>` from `@ember-joinery/ember` or
45
+ * `@ember-joinery/primitives/navigation-menu`. Its items are found by their triggers' text and
46
+ * its links by theirs, and read through ARIA (a trigger's `aria-expanded`, a link's
47
+ * `aria-current`).
48
+ *
49
+ * const nav = new NavigationMenuHarness()
50
+ * assert.deepEqual(nav.triggerLabels, ['Getting started', 'Components'])
51
+ * const start = nav.item('Getting started')
52
+ * await start.open()
53
+ * assert.deepEqual(start.links.length, 3)
54
+ * await nav.item('Components').hover()
55
+ * assert.strictEqual(nav.openItem, 'Components')
56
+ */
57
+ export declare class NavigationMenuHarness extends Harness {
58
+ static component: string;
59
+ /** The `<ul>` of items. */
60
+ get list(): HTMLElement;
61
+ /** Each trigger, in order. */
62
+ get triggers(): HTMLElement[];
63
+ /** Each trigger's text, in order. */
64
+ get triggerLabels(): string[];
65
+ /** The links in the list itself (not in a content), as elements, in order. */
66
+ get listLinkElements(): HTMLElement[];
67
+ /** Each of the list's own links' text. */
68
+ get listLinks(): string[];
69
+ /** The list's own link whose text is `label`. */
70
+ listLink(label: string): HTMLElement;
71
+ /** The trigger whose text is `label`. Throws when there is none. */
72
+ trigger(label: string): HTMLElement;
73
+ /** The item whose trigger's text is `label`. */
74
+ item(label: string): NavigationMenuItemLevel;
75
+ /** The text of the trigger whose content is open, or `null`. */
76
+ get openItem(): string | null;
77
+ /** Whether a content is open. */
78
+ get isOpen(): boolean;
79
+ /** The open item, or `null`. */
80
+ get open(): NavigationMenuItemLevel | null;
81
+ /** The viewport, while it is rendered (a content is open), or `null`. */
82
+ get viewport(): HTMLElement | null;
83
+ /** The viewport's size, as the open content gives it (`--radix-navigation-menu-viewport-*`). */
84
+ get viewportSize(): {
85
+ width: number;
86
+ height: number;
87
+ } | null;
88
+ /** The indicator, while it is rendered, or `null`. */
89
+ get indicator(): HTMLElement | null;
90
+ /** The text of the trigger or link that has focus, or `null`. */
91
+ get focused(): string | null;
92
+ /** Presses Escape where focus is: it closes the open content. */
93
+ pressEscape(): Promise<void>;
94
+ /** A press outside the menu. */
95
+ pressOutside(): Promise<void>;
96
+ }
97
+ //# sourceMappingURL=navigation-menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-menu.d.ts","sourceRoot":"","sources":["../src/navigation-menu.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,207 @@
1
+ import { click, focus } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { pressEscape, pressOutside } from "./layers.js";
4
+ import { hover, unhover } from "./pointer.js";
5
+ import { pressKey } from "./focus.js";
6
+ import { NotFoundError } from "./-private/tree.js";
7
+ import { accessibleName, text } from "./-private/overlay.js";
8
+ const LINK = '[data-test-jn-part="link"]';
9
+ /**
10
+ * The link among `links` whose text is `label`, or else the only one whose text starts with it
11
+ * (a link with a title and a description: `"Introduction"` for "Introduction Re-usable
12
+ * components…"). Throws when there is none, or more than one.
13
+ */
14
+ function findLink(links, label, where) {
15
+ const exact = links.find(element => text(element) === label);
16
+ if (exact)
17
+ return exact;
18
+ const starting = links.filter(element => text(element).startsWith(`${label} `));
19
+ if (starting.length === 1)
20
+ return starting[0];
21
+ const names = links.map(each => `"${text(each)}"`).join(', ');
22
+ throw new NotFoundError(starting.length
23
+ ? `more than one link starts with "${label}" in ${where}`
24
+ : `no link "${label}" in ${where} (there are: ${names})`);
25
+ }
26
+ /** One item of a navigation menu that opens a content: its trigger, and its content's links. */
27
+ export class NavigationMenuItemLevel {
28
+ #trigger;
29
+ constructor(trigger) {
30
+ this.#trigger = trigger;
31
+ }
32
+ /** Its trigger. */
33
+ get trigger() {
34
+ return this.#trigger();
35
+ }
36
+ /** Its value (`data-test-jn-value`). */
37
+ get value() {
38
+ return this.trigger.getAttribute('data-test-jn-value');
39
+ }
40
+ /** Whether its content is open, from the trigger's `aria-expanded`. */
41
+ get isOpen() {
42
+ return this.trigger.getAttribute('aria-expanded') === 'true';
43
+ }
44
+ /** Its content, through the trigger's `aria-controls`, or `null` while it isn't rendered. */
45
+ get content() {
46
+ const id = this.trigger.getAttribute('aria-controls');
47
+ return id ? document.getElementById(id) : null;
48
+ }
49
+ /** The content's accessible name: its trigger's text. */
50
+ get label() {
51
+ const content = this.content;
52
+ return content ? accessibleName(content) : '';
53
+ }
54
+ /** Which way the content is moving (`data-motion`): `from-start`, `to-end`…, or `null`. */
55
+ get motion() {
56
+ return this.content?.getAttribute('data-motion') ?? null;
57
+ }
58
+ /** The content's links, as elements, in order. */
59
+ get linkElements() {
60
+ const content = this.content;
61
+ return content ? [...content.querySelectorAll(LINK)] : [];
62
+ }
63
+ /** Each of the content's links' text. */
64
+ get links() {
65
+ return this.linkElements.map(text);
66
+ }
67
+ /** The content's link whose text is `label` (or the only one starting with it). */
68
+ link(label) {
69
+ return findLink(this.linkElements, label, `the content of "${text(this.trigger)}"`);
70
+ }
71
+ /** Clicks the trigger: it opens the content, or closes it when it is open. */
72
+ async toggle() {
73
+ await click(this.trigger);
74
+ }
75
+ /** Opens it with a click on the trigger, unless it is open. */
76
+ async open() {
77
+ if (!this.isOpen)
78
+ await this.toggle();
79
+ }
80
+ /** Closes it with a click on the trigger, unless it is closed. */
81
+ async close() {
82
+ if (this.isOpen)
83
+ await this.toggle();
84
+ }
85
+ /** Rests the pointer on the trigger, which opens it after the menu's delay. */
86
+ async hover() {
87
+ await hover(this.trigger);
88
+ }
89
+ /** Moves the pointer off the trigger (downwards, towards the content, unless `side` says). */
90
+ async unhover(side = 'top') {
91
+ await unhover(this.trigger, { side });
92
+ }
93
+ /**
94
+ * Toggles it from the keyboard: focus on the trigger, then Enter (or Space), which presses
95
+ * the button, as a browser does (`pressKey` sends only the key's events). Focus stays on the
96
+ * trigger; Tab or ArrowDown goes on into the content.
97
+ */
98
+ async openWithKeyboard(key = 'Enter') {
99
+ await focus(this.trigger);
100
+ const prevented = await pressKey(key);
101
+ if (!prevented)
102
+ await click(this.trigger);
103
+ }
104
+ /** Clicks the content's link `label`: it follows it, and closes the content. */
105
+ async select(label) {
106
+ await click(this.link(label));
107
+ }
108
+ }
109
+ /**
110
+ * Drives a `<NavigationMenu>` from `@ember-joinery/ember` or
111
+ * `@ember-joinery/primitives/navigation-menu`. Its items are found by their triggers' text and
112
+ * its links by theirs, and read through ARIA (a trigger's `aria-expanded`, a link's
113
+ * `aria-current`).
114
+ *
115
+ * const nav = new NavigationMenuHarness()
116
+ * assert.deepEqual(nav.triggerLabels, ['Getting started', 'Components'])
117
+ * const start = nav.item('Getting started')
118
+ * await start.open()
119
+ * assert.deepEqual(start.links.length, 3)
120
+ * await nav.item('Components').hover()
121
+ * assert.strictEqual(nav.openItem, 'Components')
122
+ */
123
+ export class NavigationMenuHarness extends Harness {
124
+ static component = 'navigation-menu';
125
+ /** The `<ul>` of items. */
126
+ get list() {
127
+ return this.part('list');
128
+ }
129
+ /** Each trigger, in order. */
130
+ get triggers() {
131
+ return this.parts('trigger');
132
+ }
133
+ /** Each trigger's text, in order. */
134
+ get triggerLabels() {
135
+ return this.triggers.map(text);
136
+ }
137
+ /** The links in the list itself (not in a content), as elements, in order. */
138
+ get listLinkElements() {
139
+ return [...this.list.querySelectorAll(LINK)].filter(link => !link.closest('[data-test-jn-part="content"]'));
140
+ }
141
+ /** Each of the list's own links' text. */
142
+ get listLinks() {
143
+ return this.listLinkElements.map(text);
144
+ }
145
+ /** The list's own link whose text is `label`. */
146
+ listLink(label) {
147
+ return findLink(this.listLinkElements, label, `${this}`);
148
+ }
149
+ /** The trigger whose text is `label`. Throws when there is none. */
150
+ trigger(label) {
151
+ const trigger = this.triggers.find(element => text(element) === label);
152
+ if (!trigger) {
153
+ const names = this.triggerLabels.map(each => `"${each}"`).join(', ');
154
+ throw new NotFoundError(`no trigger "${label}" in ${this} (there are: ${names})`);
155
+ }
156
+ return trigger;
157
+ }
158
+ /** The item whose trigger's text is `label`. */
159
+ item(label) {
160
+ return new NavigationMenuItemLevel(() => this.trigger(label));
161
+ }
162
+ /** The text of the trigger whose content is open, or `null`. */
163
+ get openItem() {
164
+ const open = this.triggers.find(trigger => trigger.getAttribute('aria-expanded') === 'true');
165
+ return open ? text(open) : null;
166
+ }
167
+ /** Whether a content is open. */
168
+ get isOpen() {
169
+ return this.openItem !== null;
170
+ }
171
+ /** The open item, or `null`. */
172
+ get open() {
173
+ const label = this.openItem;
174
+ return label === null ? null : this.item(label);
175
+ }
176
+ /** The viewport, while it is rendered (a content is open), or `null`. */
177
+ get viewport() {
178
+ return this.queryPart('viewport');
179
+ }
180
+ /** The viewport's size, as the open content gives it (`--radix-navigation-menu-viewport-*`). */
181
+ get viewportSize() {
182
+ const viewport = this.viewport;
183
+ if (!viewport)
184
+ return null;
185
+ const read = (name) => Number.parseFloat(viewport.style.getPropertyValue(`--radix-navigation-menu-viewport-${name}`));
186
+ return { width: read('width'), height: read('height') };
187
+ }
188
+ /** The indicator, while it is rendered, or `null`. */
189
+ get indicator() {
190
+ return this.queryPart('indicator');
191
+ }
192
+ /** The text of the trigger or link that has focus, or `null`. */
193
+ get focused() {
194
+ const active = document.activeElement;
195
+ if (!(active instanceof HTMLElement) || !this.element.contains(active))
196
+ return null;
197
+ return text(active);
198
+ }
199
+ /** Presses Escape where focus is: it closes the open content. */
200
+ async pressEscape() {
201
+ await pressEscape();
202
+ }
203
+ /** A press outside the menu. */
204
+ async pressOutside() {
205
+ await pressOutside();
206
+ }
207
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Waits until `IntersectionObserver` and `ResizeObserver` have reported what changed: two
3
+ * frames, then `settled()`. `settled()` alone waits for an element's first report (Joinery's
4
+ * `viewport` and `onResize` register it), but not for the reports a scroll or a resize causes
5
+ * later, which the browser delivers in the next frame.
6
+ *
7
+ * box.style.width = '300px'
8
+ * await waitForObservers()
9
+ * assert.dom('output').hasText('300 × 120')
10
+ */
11
+ export declare function waitForObservers(): Promise<void>;
12
+ /**
13
+ * Scrolls `target` (an element, or a selector in the test's root) to the middle of its
14
+ * scrolling boxes and the window, as a user scrolling to it would, then waits for the observers
15
+ * to report it: what an `InViewport` holds renders.
16
+ *
17
+ * await scrollIntoView('[data-test-comments]')
18
+ * assert.dom('[data-test-comment]').exists({ count: 3 })
19
+ */
20
+ export declare function scrollIntoView(target: Element | string): Promise<void>;
21
+ //# sourceMappingURL=observers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observers.d.ts","sourceRoot":"","sources":["../src/observers.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKtD;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK5E"}
@@ -0,0 +1,34 @@
1
+ import { isString } from '@sindresorhus/is';
2
+ import { find, settled } from '@ember/test-helpers';
3
+ const frame = () => new Promise(resolve => requestAnimationFrame(() => resolve()));
4
+ /**
5
+ * Waits until `IntersectionObserver` and `ResizeObserver` have reported what changed: two
6
+ * frames, then `settled()`. `settled()` alone waits for an element's first report (Joinery's
7
+ * `viewport` and `onResize` register it), but not for the reports a scroll or a resize causes
8
+ * later, which the browser delivers in the next frame.
9
+ *
10
+ * box.style.width = '300px'
11
+ * await waitForObservers()
12
+ * assert.dom('output').hasText('300 × 120')
13
+ */
14
+ export async function waitForObservers() {
15
+ await settled();
16
+ await frame();
17
+ await frame();
18
+ await settled();
19
+ }
20
+ /**
21
+ * Scrolls `target` (an element, or a selector in the test's root) to the middle of its
22
+ * scrolling boxes and the window, as a user scrolling to it would, then waits for the observers
23
+ * to report it: what an `InViewport` holds renders.
24
+ *
25
+ * await scrollIntoView('[data-test-comments]')
26
+ * assert.dom('[data-test-comment]').exists({ count: 3 })
27
+ */
28
+ export async function scrollIntoView(target) {
29
+ const element = isString(target) ? find(target) : target;
30
+ if (!element)
31
+ throw new Error(`Joinery: scrollIntoView found nothing for ${String(target)}`);
32
+ element.scrollIntoView({ block: 'center', inline: 'center' });
33
+ await waitForObservers();
34
+ }
@@ -0,0 +1,39 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Pagination>` from `@ember-joinery/ember`: its page links, the previous and next
4
+ * links, and the current page, read through `aria-current` as a screen reader reads it.
5
+ *
6
+ * const pages = new PaginationHarness()
7
+ * assert.deepEqual(pages.pages, ['1', '2', '3'])
8
+ * assert.strictEqual(pages.current, '2')
9
+ * await pages.goTo('3')
10
+ * await pages.goToNext()
11
+ */
12
+ export declare class PaginationHarness extends Harness {
13
+ static component: string;
14
+ /** Its accessible name, the `nav`'s `aria-label`. */
15
+ get label(): string;
16
+ /** The page links, in order (not the previous and next links). */
17
+ get pageElements(): HTMLElement[];
18
+ /** The text of each page link, in order: the page numbers. */
19
+ get pages(): string[];
20
+ /** The current page's text (the link with `aria-current="page"`), or `null` with none. */
21
+ get current(): string | null;
22
+ /** The previous page's link. Throws when there is none. */
23
+ get previous(): HTMLElement;
24
+ /** The next page's link. Throws when there is none. */
25
+ get next(): HTMLElement;
26
+ /** Whether some pages are left out, shown as an ellipsis. */
27
+ get hasEllipsis(): boolean;
28
+ /** The link to the page whose text is `page`. Throws when there is none. */
29
+ page(page: string): HTMLElement;
30
+ /** Whether the page whose text is `page` is the current one. */
31
+ isCurrent(page: string): boolean;
32
+ /** Clicks the link to the page whose text is `page`, as a user would. */
33
+ goTo(page: string): Promise<void>;
34
+ /** Clicks the previous page's link. */
35
+ goToPrevious(): Promise<void>;
36
+ /** Clicks the next page's link. */
37
+ goToNext(): Promise<void>;
38
+ }
39
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAOtC;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,SAAQ,OAAO;IAC5C,OAAgB,SAAS,SAAe;IAExC,qDAAqD;IACrD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,kEAAkE;IAClE,IAAI,YAAY,IAAI,WAAW,EAAE,CAEhC;IAED,8DAA8D;IAC9D,IAAI,KAAK,IAAI,MAAM,EAAE,CAEpB;IAED,0FAA0F;IAC1F,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAG3B;IAED,2DAA2D;IAC3D,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED,uDAAuD;IACvD,IAAI,IAAI,IAAI,WAAW,CAEtB;IAED,6DAA6D;IAC7D,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,4EAA4E;IAC5E,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW;IAO/B,gEAAgE;IAChE,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIhC,yEAAyE;IACnE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,uCAAuC;IACjC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,mCAAmC;IAC7B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
@@ -0,0 +1,71 @@
1
+ import { click } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { NotFoundError } from "./-private/tree.js";
4
+ function text(element) {
5
+ return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
6
+ }
7
+ /**
8
+ * Drives a `<Pagination>` from `@ember-joinery/ember`: its page links, the previous and next
9
+ * links, and the current page, read through `aria-current` as a screen reader reads it.
10
+ *
11
+ * const pages = new PaginationHarness()
12
+ * assert.deepEqual(pages.pages, ['1', '2', '3'])
13
+ * assert.strictEqual(pages.current, '2')
14
+ * await pages.goTo('3')
15
+ * await pages.goToNext()
16
+ */
17
+ export class PaginationHarness extends Harness {
18
+ static component = 'pagination';
19
+ /** Its accessible name, the `nav`'s `aria-label`. */
20
+ get label() {
21
+ return this.element.getAttribute('aria-label') ?? '';
22
+ }
23
+ /** The page links, in order (not the previous and next links). */
24
+ get pageElements() {
25
+ return this.parts('link');
26
+ }
27
+ /** The text of each page link, in order: the page numbers. */
28
+ get pages() {
29
+ return this.pageElements.map(text);
30
+ }
31
+ /** The current page's text (the link with `aria-current="page"`), or `null` with none. */
32
+ get current() {
33
+ const current = this.pageElements.find(link => link.getAttribute('aria-current') === 'page');
34
+ return current ? text(current) : null;
35
+ }
36
+ /** The previous page's link. Throws when there is none. */
37
+ get previous() {
38
+ return this.part('previous');
39
+ }
40
+ /** The next page's link. Throws when there is none. */
41
+ get next() {
42
+ return this.part('next');
43
+ }
44
+ /** Whether some pages are left out, shown as an ellipsis. */
45
+ get hasEllipsis() {
46
+ return this.queryPart('ellipsis') !== null;
47
+ }
48
+ /** The link to the page whose text is `page`. Throws when there is none. */
49
+ page(page) {
50
+ const found = this.pageElements.find(link => text(link) === page);
51
+ if (!found)
52
+ throw new NotFoundError(`no page "${page}" in ${this} (it has ${this.pages.join(', ')})`);
53
+ return found;
54
+ }
55
+ /** Whether the page whose text is `page` is the current one. */
56
+ isCurrent(page) {
57
+ return this.page(page).getAttribute('aria-current') === 'page';
58
+ }
59
+ /** Clicks the link to the page whose text is `page`, as a user would. */
60
+ async goTo(page) {
61
+ await click(this.page(page));
62
+ }
63
+ /** Clicks the previous page's link. */
64
+ async goToPrevious() {
65
+ await click(this.previous);
66
+ }
67
+ /** Clicks the next page's link. */
68
+ async goToNext() {
69
+ await click(this.next);
70
+ }
71
+ }
@@ -0,0 +1,38 @@
1
+ /** Which kind of pointer moves. */
2
+ export interface HoverOptions {
3
+ /** `mouse` (the default), `pen` or `touch`. Tooltips and hover cards ignore a touch. */
4
+ pointerType?: 'mouse' | 'pen' | 'touch';
5
+ }
6
+ /** Which way the pointer leaves an element, and how far it goes. */
7
+ export interface UnhoverOptions extends HoverOptions {
8
+ /**
9
+ * The side it leaves through. Default: the side away from where `away` is, or else `top`.
10
+ */
11
+ side?: 'top' | 'right' | 'bottom' | 'left';
12
+ /**
13
+ * An element it moves away from, such as a tooltip: it leaves through the side facing away
14
+ * from it, and so out of the grace area between the two.
15
+ */
16
+ away?: Element | null;
17
+ /** How far past the edge it ends up, in pixels. Default 40. */
18
+ distance?: number;
19
+ }
20
+ /**
21
+ * Moves the pointer onto an element and rests it there, as a mouse does: `pointerover`,
22
+ * `pointerenter`, `mouseover` and `mouseenter`, then `pointermove` and `mousemove`, at its
23
+ * centre. `click()` sends none of them. It waits for what that sets off, such as a tooltip's
24
+ * open delay.
25
+ *
26
+ * await hover(tooltip.trigger)
27
+ */
28
+ export declare function hover(target: Element, options?: HoverOptions): Promise<void>;
29
+ /**
30
+ * Moves the pointer off an element, as a mouse does: `pointerout`, `pointerleave`, `mouseout`
31
+ * and `mouseleave` where it crosses the edge, then a `pointermove` and `mousemove` on whatever
32
+ * is under it further on. Give `away` (a tooltip, say) to leave through the side facing away
33
+ * from it. It waits for what that sets off, such as a hover card's close delay.
34
+ *
35
+ * await unhover(tooltip.trigger, { away: tooltip.content })
36
+ */
37
+ export declare function unhover(target: Element, options?: UnhoverOptions): Promise<void>;
38
+ //# sourceMappingURL=pointer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../src/pointer.ts"],"names":[],"mappings":"AAEA,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC3B,wFAAwF;IACxF,WAAW,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO,CAAA;CACxC;AAED,oEAAoE;AACpE,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IAC1C;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AA4BD;;;;;;;GAOG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAStF;AAUD;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B1F"}
@@ -0,0 +1,82 @@
1
+ import { settled } from '@ember/test-helpers';
2
+ function pointer(type, target, point, { pointerType = 'mouse' }, bubbles = true) {
3
+ const init = {
4
+ bubbles,
5
+ cancelable: true,
6
+ composed: true,
7
+ view: window,
8
+ clientX: point.x,
9
+ clientY: point.y,
10
+ };
11
+ const event = type.startsWith('pointer')
12
+ ? new PointerEvent(type, { ...init, pointerType, isPrimary: true, pointerId: 1 })
13
+ : new MouseEvent(type, init);
14
+ target.dispatchEvent(event);
15
+ }
16
+ function centre(element) {
17
+ const rect = element.getBoundingClientRect();
18
+ return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
19
+ }
20
+ /**
21
+ * Moves the pointer onto an element and rests it there, as a mouse does: `pointerover`,
22
+ * `pointerenter`, `mouseover` and `mouseenter`, then `pointermove` and `mousemove`, at its
23
+ * centre. `click()` sends none of them. It waits for what that sets off, such as a tooltip's
24
+ * open delay.
25
+ *
26
+ * await hover(tooltip.trigger)
27
+ */
28
+ export async function hover(target, options = {}) {
29
+ const point = centre(target);
30
+ pointer('pointerover', target, point, options);
31
+ pointer('pointerenter', target, point, options, false);
32
+ pointer('mouseover', target, point, options);
33
+ pointer('mouseenter', target, point, options, false);
34
+ pointer('pointermove', target, point, options);
35
+ pointer('mousemove', target, point, options);
36
+ await settled();
37
+ }
38
+ /** The side of `from` that faces away from `away`. */
39
+ function sideAwayFrom(from, away) {
40
+ const dx = away.left + away.width / 2 - (from.left + from.width / 2);
41
+ const dy = away.top + away.height / 2 - (from.top + from.height / 2);
42
+ if (Math.abs(dy) >= Math.abs(dx))
43
+ return dy > 0 ? 'top' : 'bottom';
44
+ return dx > 0 ? 'left' : 'right';
45
+ }
46
+ /**
47
+ * Moves the pointer off an element, as a mouse does: `pointerout`, `pointerleave`, `mouseout`
48
+ * and `mouseleave` where it crosses the edge, then a `pointermove` and `mousemove` on whatever
49
+ * is under it further on. Give `away` (a tooltip, say) to leave through the side facing away
50
+ * from it. It waits for what that sets off, such as a hover card's close delay.
51
+ *
52
+ * await unhover(tooltip.trigger, { away: tooltip.content })
53
+ */
54
+ export async function unhover(target, options = {}) {
55
+ const rect = target.getBoundingClientRect();
56
+ const side = options.side ??
57
+ (options.away ? sideAwayFrom(rect, options.away.getBoundingClientRect()) : 'top');
58
+ const distance = options.distance ?? 40;
59
+ const { x, y } = centre(target);
60
+ const edge = {
61
+ top: { x, y: rect.top },
62
+ bottom: { x, y: rect.bottom },
63
+ left: { x: rect.left, y },
64
+ right: { x: rect.right, y },
65
+ }[side];
66
+ const step = {
67
+ top: { x: 0, y: -1 },
68
+ bottom: { x: 0, y: 1 },
69
+ left: { x: -1, y: 0 },
70
+ right: { x: 1, y: 0 },
71
+ }[side];
72
+ const exit = { x: edge.x + step.x, y: edge.y + step.y };
73
+ const beyond = { x: edge.x + step.x * distance, y: edge.y + step.y * distance };
74
+ pointer('pointerout', target, exit, options);
75
+ pointer('pointerleave', target, exit, options, false);
76
+ pointer('mouseout', target, exit, options);
77
+ pointer('mouseleave', target, exit, options, false);
78
+ const under = document.elementFromPoint(beyond.x, beyond.y) ?? document.body;
79
+ pointer('pointermove', under, beyond, options);
80
+ pointer('mousemove', under, beyond, options);
81
+ await settled();
82
+ }
@@ -0,0 +1,50 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Popover>` from `@ember-joinery/ember` or `@ember-joinery/primitives/popover`. It
4
+ * reads the state from the trigger's ARIA (`aria-expanded`) and the content's, and acts as a
5
+ * user does: a click on the trigger, Escape, a press outside.
6
+ *
7
+ * const popover = new PopoverHarness('dimensions') // <Popover @name="dimensions">
8
+ * await popover.open()
9
+ * assert.strictEqual(popover.label, 'Dimensions')
10
+ * await popover.pressEscape()
11
+ * assert.false(popover.isOpen)
12
+ */
13
+ export declare class PopoverHarness extends Harness {
14
+ static component: string;
15
+ /** The trigger: the `Trigger` part, or your own element with the `trigger` modifier. */
16
+ get trigger(): HTMLElement;
17
+ /** The content, or `null` while it isn't rendered. */
18
+ get content(): HTMLElement | null;
19
+ /** Whether it is open, from the trigger's `aria-expanded`. */
20
+ get isOpen(): boolean;
21
+ /** Whether the content is showing in the browser's top layer. */
22
+ get isShown(): boolean;
23
+ /** The content's accessible name: its Title, or else its trigger, or your `aria-label`. */
24
+ get label(): string;
25
+ /** The content's accessible description: its Description's text, or `''`. */
26
+ get description(): string;
27
+ /** The Title's text, or `''`. */
28
+ get title(): string;
29
+ /** The content's text, whitespace collapsed. */
30
+ get text(): string;
31
+ /** The side the content was placed on, after any flip (`data-side`). */
32
+ get side(): string | null;
33
+ /** The content's alignment along that side (`data-align`). */
34
+ get align(): string | null;
35
+ /** The arrow's element (Radix's arrow is a `<span>` around an `<svg>`), or `null`. */
36
+ get arrow(): HTMLElement | null;
37
+ /** Clicks the trigger. */
38
+ toggle(): Promise<void>;
39
+ /** Opens it with a click on the trigger, unless it is open. */
40
+ open(): Promise<void>;
41
+ /** Closes it with a click on the trigger, unless it is closed. */
42
+ close(): Promise<void>;
43
+ /** Clicks its Close part (the first, if there are several). */
44
+ clickClose(): Promise<void>;
45
+ /** Presses Escape where focus is. */
46
+ pressEscape(): Promise<void>;
47
+ /** A press outside the popover, as a user dismissing it makes. */
48
+ pressOutside(): Promise<void>;
49
+ }
50
+ //# sourceMappingURL=popover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../src/popover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAItC;;;;;;;;;;GAUG;AACH,qBAAa,cAAe,SAAQ,OAAO;IACzC,OAAgB,SAAS,SAAY;IAErC,wFAAwF;IACxF,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,sDAAsD;IACtD,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,8DAA8D;IAC9D,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,iEAAiE;IACjE,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,2FAA2F;IAC3F,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,6EAA6E;IAC7E,IAAI,WAAW,IAAI,MAAM,CAGxB;IAED,iCAAiC;IACjC,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,gDAAgD;IAChD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,wEAAwE;IACxE,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,8DAA8D;IAC9D,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,sFAAsF;IACtF,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAE9B;IAED,0BAA0B;IACpB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,+DAA+D;IACzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,kEAAkE;IAC5D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,+DAA+D;IACzD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,qCAAqC;IAC/B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC,kEAAkE;IAC5D,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}