basecoat-cli 0.2.0-beta.1 → 0.2.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.
@@ -4,53 +4,66 @@
4
4
  @param id {string} [optional] - Unique identifier for the select component.
5
5
  @param selected {string} [optional] - The initially selected value.
6
6
  @param name {string} [optional] - The name attribute for the hidden input storing the selected value.
7
- @param items {array} [optional] - An array of items (objects with type, label, value, attrs, and items) to render.
8
7
  @param main_attrs {object} [optional] - Additional HTML attributes for the main container div.
9
8
  @param trigger_attrs {object} [optional] - Additional HTML attributes for the trigger button.
10
9
  @param content_attrs {object} [optional] - Additional HTML attributes for the popover content div.
11
10
  @param listbox_attrs {object} [optional] - Additional HTML attributes for the listbox div.
12
11
  @param input_attrs {object} [optional] - Additional HTML attributes for the hidden input.
13
12
  @param search_placeholder {string} [optional] [default="Search entries..."] - Placeholder text for the search input (combobox only).
14
- @param is_combobox {boolean} [optional] [default=False] - Renders a combobox with search functionality if True.
13
+ @param is_combobox {boolean} [optional] [default=false] - Renders a combobox with search functionality if true.
15
14
  #}
16
15
  {% macro select(
17
16
  id=None,
18
17
  selected=None,
19
18
  name=None,
20
19
  items=None,
21
- main_attrs={},
22
20
  trigger_attrs={},
23
- content_attrs={},
21
+ popover_attrs={},
24
22
  listbox_attrs={},
25
- input_attrs={},
26
23
  search_placeholder="Search entries...",
27
- is_combobox=False
24
+ is_combobox=false
28
25
  ) %}
29
- <div
30
- class="popover {{ main_attrs.class }}"
31
- x-data="select('{{ name }}', '{{ selected or '' }}')"
32
- @click.away="open = false"
33
- {% if id %}id="{{ id }}"{% endif %}
34
- {% for key, value in main_attrs.items() %}
35
- {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
36
- {% endfor %}
37
- >
26
+ {% set id = id or ("select-" + (range(100000, 999999) | random | string)) %}
27
+
28
+ {% set first_option = [] %}
29
+ {% set selected_option = [] %}
30
+
31
+ {% for item in items.items() %}
32
+ {% if item.type == "group" %}
33
+ {% for sub_item in item.items.items() %}
34
+ {% if not first_option[0] %}
35
+ {% set first_option = (first_option.push(sub_item), first_option) %}
36
+ {% endif %}
37
+ {% if selected and sub_item.value == selected and not selected_option[0] %}
38
+ {% set selected_option = (selected_option.push(sub_item), selected_option) %}
39
+ {% endif %}
40
+ {% endfor %}
41
+ {% else %}
42
+ {% if not first_option[0] %}
43
+ {% set first_option = (first_option.push(item), first_option) %}
44
+ {% endif %}
45
+ {% if selected and item.value == selected and not selected_option[0] %}
46
+ {% set selected_option = (selected_option.push(item), selected_option) %}
47
+ {% endif %}
48
+ {% endif %}
49
+ {% endfor %}
50
+
51
+ {% set default_option = selected_option[0] or first_option[0] or None %}
52
+
53
+ <div class="select">
38
54
  <button
39
55
  type="button"
56
+ class="btn-outline justify-between font-normal {{ trigger_attrs.class }}"
57
+ id="{{ id }}-trigger"
58
+ popovertarget="{{ id }}"
40
59
  aria-haspopup="listbox"
41
60
  aria-expanded="false"
42
- x-bind="$trigger"
43
- {% if id %}
44
- id="{{ id }}-trigger"
45
- aria-controls="{{ id }}-content"
46
- {% endif %}
47
- class="btn-outline justify-between font-normal {{ trigger_attrs.class }}"
48
- {% for key, value in trigger_attrs.items() %}
61
+ aria-controls="{{ id }}-listbox"
62
+ {% for key, value in trigger_attrs %}
49
63
  {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
50
64
  {% endfor %}
51
65
  >
52
- <div x-html="selectedLabel" class="flex items-center gap-x-2"
53
- ></div>
66
+ <span class="truncate">{{ default_option.label }}</span>
54
67
  {% if is_combobox %}
55
68
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevrons-up-down-icon lucide-chevrons-up-down text-muted-foreground opacity-50 shrink-0"><path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/></svg>
56
69
  {% else %}
@@ -58,12 +71,11 @@
58
71
  {% endif %}
59
72
  </button>
60
73
  <div
61
- data-popover
62
- aria-hidden="true"
63
- x-bind="$content"
64
- {% if id %}id="{{ id }}-content"{% endif %}
65
- {% for key, value in content_attrs.items() %}
66
- {{ key }}="{{ value }}"
74
+ popover
75
+ id="{{ id }}"
76
+ class="popover {{ popover_attrs.class }}"
77
+ {% for key, value in popover_attrs.items() %}
78
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
67
79
  {% endfor %}
68
80
  >
69
81
  {% if is_combobox %}
@@ -81,35 +93,33 @@
81
93
  aria-expanded="true"
82
94
  aria-controls="{{ id }}-content"
83
95
  aria-labelledby="{{ id }}-trigger"
84
- x-model="query"
85
- x-bind="$filter"
86
96
  >
87
97
  </header>
88
98
  {% endif %}
89
99
  <div
90
100
  role="listbox"
101
+ id="{{ id }}-listbox"
91
102
  aria-orientation="vertical"
92
- {% for key, value in listbox_attrs.items() %}
103
+ aria-labelledby="{{ id }}-trigger"
104
+ {% for key, value in listbox_attrs %}
93
105
  {{ key }}="{{ value }}"
94
106
  {% endfor %}
95
107
  >
96
- {% if items %}
97
- {{ render_select_items(items, id ~ "-items" if id else "items") }}
108
+ {% if items.length > 0 %}
109
+ {{ render_select_items(items, default_option.value, id ~ "-items" if id else "items") }}
98
110
  {% else %}
99
111
  {{ caller() if caller }}
100
112
  {% endif %}
101
113
  </div>
102
114
  </div>
103
- {% if name is defined %}
104
- <input
105
- type="hidden"
106
- name="{{ name }}"
107
- x-model="selectedValue"
108
- {% for key, value in input_attrs.items() %}
109
- {% if key != 'name' %}{{ key }}="{{ value }}"{% endif %}
110
- {% endfor %}
111
- >
112
- {% endif %}
115
+ <input
116
+ type="hidden"
117
+ name="{{ name or id ~ '-value' }}"
118
+ value="{{ selected or '' }}"
119
+ {% for key, value in input_attrs.items() %}
120
+ {% if key != 'name' and key != 'value' %}{{ key }}="{{ value }}"{% endif %}
121
+ {% endfor %}
122
+ >
113
123
  </div>
114
124
  {% endmacro %}
115
125
 
@@ -119,29 +129,30 @@
119
129
  @param items {array} - The array of items to render.
120
130
  @param parent_id_prefix {string} [optional] - The prefix for the item id.
121
131
  #}
122
- {% macro render_select_items(items, parent_id_prefix="items") %}
132
+ {% macro render_select_items(items, selected, parent_id_prefix="items") %}
123
133
  {% for item in items.items() %}
124
134
  {% set item_id = parent_id_prefix ~ "-" ~ loop.index %}
125
-
126
135
  {% if item.type == "group" %}
127
136
  {% set group_label_id = item.id if item.id else "group-label-" + item_id %}
128
137
  <div
129
138
  role="group"
130
139
  aria-labelledby="{{ group_label_id }}"
131
- {% for key, value in item.attrs.items() %}
140
+ {% for key, value in item.attrs %}
132
141
  {{ key }}="{{ value }}"
133
142
  {% endfor %}
134
143
  >
135
144
  <div role="heading" id="{{ group_label_id }}">{{ item.label }}</div>
136
- {{ render_select_items(item.items, item_id) if item.items }}
145
+ {{ render_select_items(item.items, selected, item_id) if item.items }}
137
146
  </div>
138
147
  {% elif item.type == "separator" %}
139
148
  <hr role="separator" />
140
149
  {% elif item.type == "item" or not item.type %}
141
150
  <div
151
+ id="{{ item_id }}"
142
152
  role="option"
143
153
  data-value="{{ item.value }}"
144
- {% for key, value in item.attrs.items() %}
154
+ {% if selected == item.value %}aria-selected="true"{% endif %}
155
+ {% for key, value in item.attrs %}
145
156
  {{ key }}="{{ value }}"
146
157
  {% endfor %}
147
158
  >
@@ -1,13 +1,35 @@
1
1
  (() => {
2
2
  const initDropdownMenu = (dropdownMenuComponent) => {
3
- const trigger = dropdownMenuComponent.querySelector('[popovertarget]');
4
- const popover = dropdownMenuComponent.querySelector('[popover]');
5
- const menu = popover?.querySelector('[role="menu"]');
6
- if (!trigger || !popover || !menu) return;
3
+ const trigger = dropdownMenuComponent.querySelector(':scope > button');
4
+ const popover = dropdownMenuComponent.querySelector(':scope > [data-popover]');
5
+ const menu = popover.querySelector('[role="menu"]');
6
+
7
+ if (!trigger || !menu || !popover) {
8
+ console.error('Dropdown menu component is missing a trigger, a menu, or a popover content element.', dropdownMenuComponent);
9
+ return;
10
+ }
7
11
 
8
12
  let menuItems = [];
9
13
  let activeIndex = -1;
10
14
 
15
+ const closeMenu = () => {
16
+ if (trigger.getAttribute('aria-expanded') === 'false') return;
17
+ trigger.setAttribute('aria-expanded', 'false');
18
+ trigger.removeAttribute('aria-activedescendant');
19
+ popover.setAttribute('aria-hidden', 'true');
20
+ trigger.focus();
21
+ activeIndex = -1;
22
+ };
23
+
24
+ const openMenu = () => {
25
+ trigger.setAttribute('aria-expanded', 'true');
26
+ popover.setAttribute('aria-hidden', 'false');
27
+ menuItems = Array.from(menu.querySelectorAll('[role^="menuitem"]:not([disabled])'));
28
+ if (menuItems.length > 0) {
29
+ setActiveItem(0);
30
+ }
31
+ };
32
+
11
33
  const setActiveItem = (index) => {
12
34
  if (activeIndex > -1 && menuItems[activeIndex]) {
13
35
  menuItems[activeIndex].classList.remove('active');
@@ -17,36 +39,48 @@
17
39
  const activeItem = menuItems[activeIndex];
18
40
  activeItem.classList.add('active');
19
41
  trigger.setAttribute('aria-activedescendant', activeItem.id);
20
- activeItem.scrollIntoView({ block: 'nearest' });
21
42
  } else {
22
43
  trigger.removeAttribute('aria-activedescendant');
23
44
  }
24
45
  };
25
46
 
26
- const handleKeyDown = (e) => {
27
- if (!popover.matches(':popover-open')) {
47
+ trigger.addEventListener('click', () => {
48
+ const isExpanded = trigger.getAttribute('aria-expanded') === 'true';
49
+ if (isExpanded) {
50
+ closeMenu();
51
+ } else {
52
+ openMenu();
53
+ }
54
+ });
55
+
56
+ dropdownMenuComponent.addEventListener('keydown', (e) => {
57
+ const isExpanded = trigger.getAttribute('aria-expanded') === 'true';
58
+
59
+ if (e.key === 'Escape') {
60
+ if (isExpanded) closeMenu();
61
+ return;
62
+ }
63
+
64
+ if (!isExpanded) {
28
65
  if (['ArrowDown', 'ArrowUp', 'Enter', ' '].includes(e.key)) {
29
66
  e.preventDefault();
30
- trigger.click();
67
+ openMenu();
31
68
  }
32
69
  return;
33
70
  }
34
71
 
35
- let nextIndex = activeIndex;
36
72
  if (menuItems.length === 0) return;
37
73
 
74
+ let nextIndex = activeIndex;
75
+
38
76
  switch (e.key) {
39
77
  case 'ArrowDown':
40
78
  e.preventDefault();
41
- if (activeIndex < menuItems.length - 1) {
42
- nextIndex = activeIndex + 1;
43
- }
79
+ nextIndex = activeIndex < menuItems.length - 1 ? activeIndex + 1 : 0;
44
80
  break;
45
81
  case 'ArrowUp':
46
82
  e.preventDefault();
47
- if (activeIndex > 0) {
48
- nextIndex = activeIndex - 1;
49
- }
83
+ nextIndex = activeIndex > 0 ? activeIndex - 1 : menuItems.length - 1;
50
84
  break;
51
85
  case 'Home':
52
86
  e.preventDefault();
@@ -60,42 +94,24 @@
60
94
  case ' ':
61
95
  e.preventDefault();
62
96
  menuItems[activeIndex]?.click();
63
- break;
97
+ closeMenu();
98
+ return;
64
99
  }
65
100
 
66
101
  if (nextIndex !== activeIndex) {
67
102
  setActiveItem(nextIndex);
68
103
  }
69
- };
70
-
71
- trigger.addEventListener('keydown', handleKeyDown);
72
-
73
- popover.addEventListener('toggle', (e) => {
74
- trigger.setAttribute('aria-expanded', e.newState === 'open');
75
- if (e.newState === 'open') {
76
- menuItems = Array.from(menu.querySelectorAll('[role^="menuitem"]:not([disabled])'));
77
- menuItems.forEach((item, index) => {
78
- if (!item.id) item.id = `${menu.id}-item-${index}`;
79
- });
80
- setActiveItem(0);
81
- } else {
82
- setActiveItem(-1);
83
- }
84
104
  });
85
105
 
86
106
  menu.addEventListener('click', (e) => {
87
107
  if (e.target.closest('[role^="menuitem"]')) {
88
- popover.hidePopover();
108
+ closeMenu();
89
109
  }
90
110
  });
91
111
 
92
- menu.addEventListener('mouseover', (e) => {
93
- const item = e.target.closest('[role^="menuitem"]:not([disabled])');
94
- if (item) {
95
- const index = menuItems.indexOf(item);
96
- if (index > -1 && index !== activeIndex) {
97
- setActiveItem(index);
98
- }
112
+ document.addEventListener('click', (e) => {
113
+ if (!dropdownMenuComponent.contains(e.target)) {
114
+ closeMenu();
99
115
  }
100
116
  });
101
117
 
@@ -107,23 +123,92 @@
107
123
  const observer = new MutationObserver((mutations) => {
108
124
  mutations.forEach((mutation) => {
109
125
  mutation.addedNodes.forEach((node) => {
110
- if (node.nodeType === Node.ELEMENT_NODE) {
111
- if (node.matches('.dropdown-menu:not([data-dropdown-menu-initialized])')) {
112
- initDropdownMenu(node);
113
- }
114
- node.querySelectorAll('.dropdown-menu:not([data-dropdown-menu-initialized])').forEach(initDropdownMenu);
126
+ if (node.nodeType !== Node.ELEMENT_NODE) return;
127
+ if (node.matches('.dropdown-menu:not([data-dropdown-menu-initialized])')) {
128
+ initDropdownMenu(node);
115
129
  }
130
+ node.querySelectorAll('.dropdown-menu:not([data-dropdown-menu-initialized])').forEach(initDropdownMenu);
116
131
  });
117
132
  });
118
133
  });
134
+
135
+ observer.observe(document.body, { childList: true, subtree: true });
136
+ })();
137
+ (() => {
138
+ const initPopover = (popoverComponent) => {
139
+ const trigger = popoverComponent.querySelector(':scope > button');
140
+ const content = popoverComponent.querySelector(':scope > [data-popover]');
141
+
142
+ if (!trigger || !content) {
143
+ console.error('Popover component is missing a trigger button or a content element.', popoverComponent);
144
+ return;
145
+ }
146
+
147
+ const closePopover = () => {
148
+ if (trigger.getAttribute('aria-expanded') === 'false') return;
149
+ trigger.setAttribute('aria-expanded', 'false');
150
+ content.setAttribute('aria-hidden', 'true');
151
+ trigger.focus();
152
+ };
153
+
154
+ const openPopover = () => {
155
+ const elementToFocus = content.querySelector('[autofocus]');
156
+ if (elementToFocus) {
157
+ content.addEventListener('transitionend', () => {
158
+ elementToFocus.focus();
159
+ }, { once: true });
160
+ }
161
+
162
+ trigger.setAttribute('aria-expanded', 'true');
163
+ content.setAttribute('aria-hidden', 'false');
164
+ };
119
165
 
166
+ trigger.addEventListener('click', () => {
167
+ const isExpanded = trigger.getAttribute('aria-expanded') === 'true';
168
+ if (isExpanded) {
169
+ closePopover();
170
+ } else {
171
+ openPopover();
172
+ }
173
+ });
174
+
175
+ popoverComponent.addEventListener('keydown', (e) => {
176
+ if (e.key === 'Escape') {
177
+ closePopover();
178
+ }
179
+ });
180
+
181
+ document.addEventListener('click', (e) => {
182
+ if (!popoverComponent.contains(e.target)) {
183
+ closePopover();
184
+ }
185
+ });
186
+
187
+ popoverComponent.dataset.popoverInitialized = true;
188
+ };
189
+
190
+ document.querySelectorAll('.popover:not([data-popover-initialized])').forEach(initPopover);
191
+
192
+ const observer = new MutationObserver((mutations) => {
193
+ mutations.forEach((mutation) => {
194
+ mutation.addedNodes.forEach((node) => {
195
+ if (node.nodeType !== Node.ELEMENT_NODE) return;
196
+ if (node.matches('.popover:not([data-popover-initialized])')) {
197
+ initPopover(node);
198
+ }
199
+ node.querySelectorAll('.popover:not([data-popover-initialized])').forEach(initPopover);
200
+ });
201
+ });
202
+ });
203
+
120
204
  observer.observe(document.body, { childList: true, subtree: true });
121
205
  })();
206
+
122
207
  (() => {
123
208
  const initSelect = (selectComponent) => {
124
- const trigger = selectComponent.querySelector(':scope > [popovertarget]');
209
+ const trigger = selectComponent.querySelector(':scope > button');
125
210
  const selectedValue = trigger.querySelector(':scope > span');
126
- const popover = selectComponent.querySelector(':scope > [popover]');
211
+ const popover = selectComponent.querySelector(':scope > [data-popover]');
127
212
  const listbox = popover.querySelector('[role="listbox"]');
128
213
  const input = selectComponent.querySelector(':scope > input[type="hidden"]');
129
214
  const filter = selectComponent.querySelector('header input[type="text"]');
@@ -142,15 +227,26 @@
142
227
  }
143
228
  };
144
229
 
230
+ const closePopover = () => {
231
+ popover.setAttribute('aria-hidden', 'true');
232
+ trigger.setAttribute('aria-expanded', 'false');
233
+ if (filter) {
234
+ filter.value = '';
235
+ visibleOptions = [...options];
236
+ options.forEach(opt => opt.setAttribute('aria-hidden', 'false'));
237
+ }
238
+ trigger.removeAttribute('aria-activedescendant');
239
+ if (activeIndex > -1) options[activeIndex]?.classList.remove('active');
240
+ activeIndex = -1;
241
+ }
242
+
145
243
  const selectOption = (option) => {
146
244
  if (!option) return;
147
245
 
148
- updateValue(option);
149
-
150
- trigger.removeAttribute('aria-activedescendant');
151
- options.forEach(opt => opt.classList.remove('active'));
152
- activeIndex = -1;
153
- popover.hidePopover();
246
+ if (option.dataset.value) {
247
+ updateValue(option);
248
+ }
249
+ closePopover();
154
250
  };
155
251
 
156
252
  if (filter) {
@@ -183,12 +279,14 @@
183
279
  updateValue(initialOption);
184
280
 
185
281
  const handleKeyNavigation = (e) => {
186
- if (!['ArrowDown', 'ArrowUp', 'Enter', 'Home', 'End'].includes(e.key)) {
282
+ const isPopoverOpen = popover.getAttribute('aria-hidden') === 'false';
283
+
284
+ if (!['ArrowDown', 'ArrowUp', 'Enter', 'Home', 'End', 'Escape'].includes(e.key)) {
187
285
  return;
188
286
  }
189
287
 
190
- if (!popover.matches(':popover-open')) {
191
- if (e.currentTarget === trigger && e.key !== 'Enter') {
288
+ if (!isPopoverOpen) {
289
+ if (e.key !== 'Enter' && e.key !== 'Escape') {
192
290
  e.preventDefault();
193
291
  trigger.click();
194
292
  }
@@ -197,9 +295,14 @@
197
295
 
198
296
  e.preventDefault();
199
297
 
298
+ if (e.key === 'Escape') {
299
+ closePopover();
300
+ return;
301
+ }
302
+
200
303
  if (e.key === 'Enter') {
201
304
  if (activeIndex > -1) {
202
- selectOption(options[activeIndex]);
305
+ selectOption(visibleOptions[activeIndex]);
203
306
  }
204
307
  return;
205
308
  }
@@ -251,6 +354,31 @@
251
354
  filter.addEventListener('keydown', handleKeyNavigation);
252
355
  }
253
356
 
357
+ trigger.addEventListener('click', () => {
358
+ const isExpanded = trigger.getAttribute('aria-expanded') === 'true';
359
+
360
+ if (isExpanded) {
361
+ closePopover();
362
+ } else {
363
+ popover.setAttribute('aria-hidden', 'false');
364
+ trigger.setAttribute('aria-expanded', 'true');
365
+ if (filter) filter.focus();
366
+
367
+ const selectedOption = listbox.querySelector('[role="option"][aria-selected="true"]');
368
+ if (selectedOption) {
369
+ if (activeIndex > -1) {
370
+ options[activeIndex]?.classList.remove('active');
371
+ }
372
+ activeIndex = options.indexOf(selectedOption);
373
+ selectedOption.classList.add('active');
374
+ if (selectedOption.id) {
375
+ trigger.setAttribute('aria-activedescendant', selectedOption.id);
376
+ }
377
+ selectedOption.scrollIntoView({ block: 'nearest' });
378
+ }
379
+ }
380
+ });
381
+
254
382
  listbox.addEventListener('click', (e) => {
255
383
  const clickedOption = e.target.closest('[role="option"]');
256
384
  if (clickedOption) {
@@ -258,46 +386,13 @@
258
386
  }
259
387
  });
260
388
 
261
- popover.addEventListener('toggle', (e) => {
262
- trigger.setAttribute('aria-expanded', e.newState === 'open');
263
-
264
- if (e.newState === 'open') {
265
- if (filter) filter.focus();
266
-
267
- const selectedOption = listbox.querySelector('[role="option"][aria-selected="true"]');
268
- let startingOption = null;
269
-
270
- if (selectedOption && visibleOptions.includes(selectedOption)) {
271
- startingOption = selectedOption;
272
- } else if (visibleOptions.length > 0) {
273
- startingOption = visibleOptions[0];
274
- }
275
-
276
- if (activeIndex > -1) options[activeIndex]?.classList.remove('active');
277
-
278
- if (startingOption) {
279
- activeIndex = options.indexOf(startingOption);
280
- startingOption.classList.add('active');
281
- if (startingOption.id) {
282
- trigger.setAttribute('aria-activedescendant', startingOption.id);
283
- }
284
- startingOption.scrollIntoView({ block: 'nearest' });
285
- } else {
286
- activeIndex = -1;
287
- }
288
- } else if (e.newState === 'closed') {
289
- if (filter) {
290
- filter.value = '';
291
- visibleOptions = [...options];
292
- options.forEach(opt => opt.setAttribute('aria-hidden', 'false'));
293
- }
294
-
295
- trigger.removeAttribute('aria-activedescendant');
296
- if (activeIndex > -1) options[activeIndex]?.classList.remove('active');
297
- activeIndex = -1;
389
+ document.addEventListener('click', (e) => {
390
+ if (!selectComponent.contains(e.target)) {
391
+ closePopover();
298
392
  }
299
393
  });
300
394
 
395
+ popover.setAttribute('aria-hidden', 'true');
301
396
  selectComponent.dataset.selectInitialized = true;
302
397
  };
303
398
 
@@ -1 +1 @@
1
- (()=>{const e=e=>{const t=e.querySelector("[popovertarget]"),n=e.querySelector("[popover]"),a=n?.querySelector('[role="menu"]');if(!t||!n||!a)return;let o=[],r=-1;const i=e=>{if(r>-1&&o[r]&&o[r].classList.remove("active"),r=e,r>-1&&o[r]){const e=o[r];e.classList.add("active"),t.setAttribute("aria-activedescendant",e.id),e.scrollIntoView({block:"nearest"})}else t.removeAttribute("aria-activedescendant")};t.addEventListener("keydown",(e=>{if(!n.matches(":popover-open"))return void(["ArrowDown","ArrowUp","Enter"," "].includes(e.key)&&(e.preventDefault(),t.click()));let a=r;if(0!==o.length){switch(e.key){case"ArrowDown":e.preventDefault(),r<o.length-1&&(a=r+1);break;case"ArrowUp":e.preventDefault(),r>0&&(a=r-1);break;case"Home":e.preventDefault(),a=0;break;case"End":e.preventDefault(),a=o.length-1;break;case"Enter":case" ":e.preventDefault(),o[r]?.click()}a!==r&&i(a)}})),n.addEventListener("toggle",(e=>{t.setAttribute("aria-expanded","open"===e.newState),"open"===e.newState?(o=Array.from(a.querySelectorAll('[role^="menuitem"]:not([disabled])')),o.forEach(((e,t)=>{e.id||(e.id=`${a.id}-item-${t}`)})),i(0)):i(-1)})),a.addEventListener("click",(e=>{e.target.closest('[role^="menuitem"]')&&n.hidePopover()})),a.addEventListener("mouseover",(e=>{const t=e.target.closest('[role^="menuitem"]:not([disabled])');if(t){const e=o.indexOf(t);e>-1&&e!==r&&i(e)}})),e.dataset.dropdownMenuInitialized=!0};document.querySelectorAll(".dropdown-menu:not([data-dropdown-menu-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches(".dropdown-menu:not([data-dropdown-menu-initialized])")&&e(t),t.querySelectorAll(".dropdown-menu:not([data-dropdown-menu-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})(),(()=>{const e=e=>{const t=e.querySelector(":scope > [popovertarget]"),n=t.querySelector(":scope > span"),a=e.querySelector(":scope > [popover]"),o=a.querySelector('[role="listbox"]'),r=e.querySelector(':scope > input[type="hidden"]'),i=e.querySelector('header input[type="text"]');if(!(t&&a&&o&&r))return;const d=Array.from(o.querySelectorAll('[role="option"]'));let s=[...d],c=-1;const l=e=>{e&&(n.innerHTML=e.dataset.label||e.innerHTML,r.value=e.dataset.value,o.querySelector('[role="option"][aria-selected="true"]')?.removeAttribute("aria-selected"),e.setAttribute("aria-selected","true"))},u=e=>{e&&(l(e),t.removeAttribute("aria-activedescendant"),d.forEach((e=>e.classList.remove("active"))),c=-1,a.hidePopover())};if(i){const e=()=>{const e=i.value.trim().toLowerCase();c>-1&&(d[c].classList.remove("active"),t.removeAttribute("aria-activedescendant"),c=-1),s=[],d.forEach((t=>{const n=(t.dataset.label||t.textContent).trim().toLowerCase().includes(e);t.setAttribute("aria-hidden",String(!n)),n&&s.push(t)}))};i.addEventListener("input",e)}let h=d.find((e=>r.value&&e.dataset.value===r.value));!h&&d.length>0&&(h=d[0]),l(h);const v=e=>{if(!["ArrowDown","ArrowUp","Enter","Home","End"].includes(e.key))return;if(!a.matches(":popover-open"))return void(e.currentTarget===t&&"Enter"!==e.key&&(e.preventDefault(),t.click()));if(e.preventDefault(),"Enter"===e.key)return void(c>-1&&u(d[c]));if(0===s.length)return;const n=c>-1?s.indexOf(d[c]):-1;let o=n;switch(e.key){case"ArrowDown":n<s.length-1&&(o=n+1);break;case"ArrowUp":n>0?o=n-1:-1===n&&(o=0);break;case"Home":o=0;break;case"End":o=s.length-1}if(o!==n){n>-1&&s[n].classList.remove("active");const e=s[o];e.classList.add("active"),c=d.indexOf(e),e.id&&t.setAttribute("aria-activedescendant",e.id),e.scrollIntoView({block:"nearest",behavior:"smooth"})}};t.addEventListener("keydown",v),i&&i.addEventListener("keydown",v),o.addEventListener("click",(e=>{const t=e.target.closest('[role="option"]');t&&u(t)})),a.addEventListener("toggle",(e=>{if(t.setAttribute("aria-expanded","open"===e.newState),"open"===e.newState){i&&i.focus();const e=o.querySelector('[role="option"][aria-selected="true"]');let n=null;e&&s.includes(e)?n=e:s.length>0&&(n=s[0]),c>-1&&d[c]?.classList.remove("active"),n?(c=d.indexOf(n),n.classList.add("active"),n.id&&t.setAttribute("aria-activedescendant",n.id),n.scrollIntoView({block:"nearest"})):c=-1}else"closed"===e.newState&&(i&&(i.value="",s=[...d],d.forEach((e=>e.setAttribute("aria-hidden","false")))),t.removeAttribute("aria-activedescendant"),c>-1&&d[c]?.classList.remove("active"),c=-1)})),e.dataset.selectInitialized=!0};document.querySelectorAll("div.select:not([data-select-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches("div.select:not([data-select-initialized])")&&e(t),t.querySelectorAll("div.select:not([data-select-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})(),(()=>{if(!window.history.__basecoatPatched){const e=window.history.pushState;window.history.pushState=function(...t){e.apply(this,t),window.dispatchEvent(new Event("basecoat:locationchange"))};const t=window.history.replaceState;window.history.replaceState=function(...e){t.apply(this,e),window.dispatchEvent(new Event("basecoat:locationchange"))},window.history.__basecoatPatched=!0}const e=e=>{const t="false"!==e.dataset.initialOpen,n="true"===e.dataset.initialMobileOpen,a=parseInt(e.dataset.breakpoint)||768;let o=a>0?window.innerWidth>=a?t:n:t;const r=()=>{const t=window.location.pathname.replace(/\/$/,"");e.querySelectorAll("a").forEach((e=>{if(e.hasAttribute("data-ignore-current"))return;new URL(e.href).pathname.replace(/\/$/,"")===t?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current")}))},i=()=>{e.setAttribute("aria-hidden",!o),o?e.removeAttribute("inert"):e.setAttribute("inert","")},d=e=>{o=e,i()},s=e.id;window.addEventListener("sidebar:open",(e=>{e.detail?.id&&e.detail.id!==s||d(!0)})),window.addEventListener("sidebar:close",(e=>{e.detail?.id&&e.detail.id!==s||d(!1)})),window.addEventListener("sidebar:toggle",(e=>{e.detail?.id&&e.detail.id!==s||d(!o)})),e.addEventListener("click",(t=>{const n=t.target,o=e.querySelector("nav");if(window.innerWidth<a&&n.closest("a, button")&&!n.closest("[data-keep-mobile-sidebar-open]"))return document.activeElement&&document.activeElement.blur(),void d(!1);(n===e||o&&!o.contains(n))&&(document.activeElement&&document.activeElement.blur(),d(!1))})),window.addEventListener("popstate",r),window.addEventListener("basecoat:locationchange",r),i(),r(),e.dataset.sidebarInitialized=!0};document.querySelectorAll(".sidebar:not([data-sidebar-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches(".sidebar:not([data-sidebar-initialized])")&&e(t),t.querySelectorAll(".sidebar:not([data-sidebar-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})(),(()=>{const e=e=>{const t=e.querySelector('[role="tablist"]');if(!t)return;const n=Array.from(t.querySelectorAll('[role="tab"]')),a=n.map((e=>document.getElementById(e.getAttribute("aria-controls")))).filter(Boolean),o=e=>{n.forEach(((e,t)=>{e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),a[t]&&(a[t].hidden=!0)})),e.setAttribute("aria-selected","true"),e.setAttribute("tabindex","0");const t=document.getElementById(e.getAttribute("aria-controls"));t&&(t.hidden=!1)};t.addEventListener("click",(e=>{const t=e.target.closest('[role="tab"]');t&&o(t)})),t.addEventListener("keydown",(e=>{const t=e.target;if(!n.includes(t))return;let a;const r=n.indexOf(t);switch(e.key){case"ArrowRight":a=n[(r+1)%n.length];break;case"ArrowLeft":a=n[(r-1+n.length)%n.length];break;case"Home":a=n[0];break;case"End":a=n[n.length-1];break;default:return}e.preventDefault(),o(a),a.focus()})),e.dataset.tabsInitialized=!0};document.querySelectorAll(".tabs:not([data-tabs-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches(".tabs:not([data-tabs-initialized])")&&e(t),t.querySelectorAll(".tabs:not([data-tabs-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})(),(()=>{let e;const t=new WeakMap;let n=!1;const a={success:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>',error:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>',info:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>',warning:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>'};function o(t){t.dataset.toasterInitialized||(e=t,e.addEventListener("mouseenter",i),e.addEventListener("mouseleave",d),e.addEventListener("click",(e=>{const t=e.target.closest(".toast footer a"),n=e.target.closest(".toast footer button");(t||n)&&s(e.target.closest(".toast"))})),e.querySelectorAll(".toast:not([data-toast-initialized])").forEach(r),e.dataset.toasterInitialized="true")}function r(e){if(e.dataset.toastInitialized)return;const a=parseInt(e.dataset.duration),o=-1!==a?a||("error"===e.dataset.category?5e3:3e3):-1,r={remainingTime:o,timeoutId:null,startTime:null};-1!==o&&(n?r.timeoutId=null:(r.startTime=Date.now(),r.timeoutId=setTimeout((()=>s(e)),o))),t.set(e,r),e.dataset.toastInitialized="true"}function i(){n||(n=!0,e.querySelectorAll('.toast:not([aria-hidden="true"])').forEach((e=>{if(!t.has(e))return;const n=t.get(e);n.timeoutId&&(clearTimeout(n.timeoutId),n.timeoutId=null,n.remainingTime-=Date.now()-n.startTime)})))}function d(){n&&(n=!1,e.querySelectorAll('.toast:not([aria-hidden="true"])').forEach((e=>{if(!t.has(e))return;const n=t.get(e);-1===n.remainingTime||n.timeoutId||(n.remainingTime>0?(n.startTime=Date.now(),n.timeoutId=setTimeout((()=>s(e)),n.remainingTime)):s(e))})))}function s(e){if(!t.has(e))return;const n=t.get(e);clearTimeout(n.timeoutId),t.delete(e),document.activeElement&&document.activeElement.blur(),e.setAttribute("aria-hidden","true"),e.addEventListener("transitionend",(()=>e.remove()),{once:!0})}const c=document.getElementById("toaster");c&&o(c),window.addEventListener("basecoat:toast",(t=>{if(!e)return void console.error("Cannot create toast: toaster container not found on page.");const n=function(e){const{category:t="info",title:n,description:o,action:r,cancel:i,duration:d,icon:s}=e,c=s||t&&a[t]||"",l=n?`<h2>${n}</h2>`:"",u=o?`<p>${o}</p>`:"",h=r?.href?`<a href="${r.href}" class="btn" data-toast-action>${r.label}</a>`:r?.onclick?`<button type="button" class="btn" data-toast-action onclick="${r.onclick}">${r.label}</button>`:"",v=i?`<button type="button" class="btn-outline h-6 text-xs px-2.5 rounded-sm" data-toast-cancel onclick="${i?.onclick}">${i.label}</button>`:"",m=`\n <div\n class="toast"\n role="${"error"===t?"alert":"status"}"\n aria-atomic="true"\n ${t?`data-category="${t}"`:""}\n ${void 0!==d?`data-duration="${d}"`:""}\n >\n <div class="toast-content">\n ${c}\n <section>\n ${l}\n ${u}\n </section>\n ${h||v?`<footer>${h}${v}</footer>`:""}\n </div>\n </div>\n </div>\n `,b=document.createElement("template");return b.innerHTML=m.trim(),b.content.firstChild}(t.detail?.config||{});e.appendChild(n)}));new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches("#toaster")&&o(t),e&&t.matches(".toast:not([data-toast-initialized])")&&r(t))}))}))})).observe(document.body,{childList:!0,subtree:!0})})();
1
+ (()=>{const e=e=>{const t=e.querySelector(":scope > button"),a=e.querySelector(":scope > [data-popover]"),n=a.querySelector('[role="menu"]');if(!t||!n||!a)return void console.error("Dropdown menu component is missing a trigger, a menu, or a popover content element.",e);let r=[],i=-1;const o=()=>{"false"!==t.getAttribute("aria-expanded")&&(t.setAttribute("aria-expanded","false"),t.removeAttribute("aria-activedescendant"),a.setAttribute("aria-hidden","true"),t.focus(),i=-1)},d=()=>{t.setAttribute("aria-expanded","true"),a.setAttribute("aria-hidden","false"),r=Array.from(n.querySelectorAll('[role^="menuitem"]:not([disabled])')),r.length>0&&s(0)},s=e=>{if(i>-1&&r[i]&&r[i].classList.remove("active"),i=e,i>-1&&r[i]){const e=r[i];e.classList.add("active"),t.setAttribute("aria-activedescendant",e.id)}else t.removeAttribute("aria-activedescendant")};t.addEventListener("click",(()=>{"true"===t.getAttribute("aria-expanded")?o():d()})),e.addEventListener("keydown",(e=>{const a="true"===t.getAttribute("aria-expanded");if("Escape"===e.key)return void(a&&o());if(!a)return void(["ArrowDown","ArrowUp","Enter"," "].includes(e.key)&&(e.preventDefault(),d()));if(0===r.length)return;let n=i;switch(e.key){case"ArrowDown":e.preventDefault(),n=i<r.length-1?i+1:0;break;case"ArrowUp":e.preventDefault(),n=i>0?i-1:r.length-1;break;case"Home":e.preventDefault(),n=0;break;case"End":e.preventDefault(),n=r.length-1;break;case"Enter":case" ":return e.preventDefault(),r[i]?.click(),void o()}n!==i&&s(n)})),n.addEventListener("click",(e=>{e.target.closest('[role^="menuitem"]')&&o()})),document.addEventListener("click",(t=>{e.contains(t.target)||o()})),e.dataset.dropdownMenuInitialized=!0};document.querySelectorAll(".dropdown-menu:not([data-dropdown-menu-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches(".dropdown-menu:not([data-dropdown-menu-initialized])")&&e(t),t.querySelectorAll(".dropdown-menu:not([data-dropdown-menu-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})(),(()=>{const e=e=>{const t=e.querySelector(":scope > button"),a=e.querySelector(":scope > [data-popover]");if(!t||!a)return void console.error("Popover component is missing a trigger button or a content element.",e);const n=()=>{"false"!==t.getAttribute("aria-expanded")&&(t.setAttribute("aria-expanded","false"),a.setAttribute("aria-hidden","true"),t.focus())};t.addEventListener("click",(()=>{"true"===t.getAttribute("aria-expanded")?n():(()=>{const e=a.querySelector("[autofocus]");e&&a.addEventListener("transitionend",(()=>{e.focus()}),{once:!0}),t.setAttribute("aria-expanded","true"),a.setAttribute("aria-hidden","false")})()})),e.addEventListener("keydown",(e=>{"Escape"===e.key&&n()})),document.addEventListener("click",(t=>{e.contains(t.target)||n()})),e.dataset.popoverInitialized=!0};document.querySelectorAll(".popover:not([data-popover-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches(".popover:not([data-popover-initialized])")&&e(t),t.querySelectorAll(".popover:not([data-popover-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})(),(()=>{const e=e=>{const t=e.querySelector(":scope > button"),a=t.querySelector(":scope > span"),n=e.querySelector(":scope > [data-popover]"),r=n.querySelector('[role="listbox"]'),i=e.querySelector(':scope > input[type="hidden"]'),o=e.querySelector('header input[type="text"]');if(!(t&&n&&r&&i))return;const d=Array.from(r.querySelectorAll('[role="option"]'));let s=[...d],c=-1;const l=e=>{e&&(a.innerHTML=e.dataset.label||e.innerHTML,i.value=e.dataset.value,r.querySelector('[role="option"][aria-selected="true"]')?.removeAttribute("aria-selected"),e.setAttribute("aria-selected","true"))},u=()=>{n.setAttribute("aria-hidden","true"),t.setAttribute("aria-expanded","false"),o&&(o.value="",s=[...d],d.forEach((e=>e.setAttribute("aria-hidden","false")))),t.removeAttribute("aria-activedescendant"),c>-1&&d[c]?.classList.remove("active"),c=-1},h=e=>{e&&(e.dataset.value&&l(e),u())};if(o){const e=()=>{const e=o.value.trim().toLowerCase();c>-1&&(d[c].classList.remove("active"),t.removeAttribute("aria-activedescendant"),c=-1),s=[],d.forEach((t=>{const a=(t.dataset.label||t.textContent).trim().toLowerCase().includes(e);t.setAttribute("aria-hidden",String(!a)),a&&s.push(t)}))};o.addEventListener("input",e)}let v=d.find((e=>i.value&&e.dataset.value===i.value));!v&&d.length>0&&(v=d[0]),l(v);const p=e=>{const a="false"===n.getAttribute("aria-hidden");if(!["ArrowDown","ArrowUp","Enter","Home","End","Escape"].includes(e.key))return;if(!a)return void("Enter"!==e.key&&"Escape"!==e.key&&(e.preventDefault(),t.click()));if(e.preventDefault(),"Escape"===e.key)return void u();if("Enter"===e.key)return void(c>-1&&h(s[c]));if(0===s.length)return;const r=c>-1?s.indexOf(d[c]):-1;let i=r;switch(e.key){case"ArrowDown":r<s.length-1&&(i=r+1);break;case"ArrowUp":r>0?i=r-1:-1===r&&(i=0);break;case"Home":i=0;break;case"End":i=s.length-1}if(i!==r){r>-1&&s[r].classList.remove("active");const e=s[i];e.classList.add("active"),c=d.indexOf(e),e.id&&t.setAttribute("aria-activedescendant",e.id),e.scrollIntoView({block:"nearest",behavior:"smooth"})}};t.addEventListener("keydown",p),o&&o.addEventListener("keydown",p),t.addEventListener("click",(()=>{if("true"===t.getAttribute("aria-expanded"))u();else{n.setAttribute("aria-hidden","false"),t.setAttribute("aria-expanded","true"),o&&o.focus();const e=r.querySelector('[role="option"][aria-selected="true"]');e&&(c>-1&&d[c]?.classList.remove("active"),c=d.indexOf(e),e.classList.add("active"),e.id&&t.setAttribute("aria-activedescendant",e.id),e.scrollIntoView({block:"nearest"}))}})),r.addEventListener("click",(e=>{const t=e.target.closest('[role="option"]');t&&h(t)})),document.addEventListener("click",(t=>{e.contains(t.target)||u()})),n.setAttribute("aria-hidden","true"),e.dataset.selectInitialized=!0};document.querySelectorAll("div.select:not([data-select-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches("div.select:not([data-select-initialized])")&&e(t),t.querySelectorAll("div.select:not([data-select-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})(),(()=>{if(!window.history.__basecoatPatched){const e=window.history.pushState;window.history.pushState=function(...t){e.apply(this,t),window.dispatchEvent(new Event("basecoat:locationchange"))};const t=window.history.replaceState;window.history.replaceState=function(...e){t.apply(this,e),window.dispatchEvent(new Event("basecoat:locationchange"))},window.history.__basecoatPatched=!0}const e=e=>{const t="false"!==e.dataset.initialOpen,a="true"===e.dataset.initialMobileOpen,n=parseInt(e.dataset.breakpoint)||768;let r=n>0?window.innerWidth>=n?t:a:t;const i=()=>{const t=window.location.pathname.replace(/\/$/,"");e.querySelectorAll("a").forEach((e=>{if(e.hasAttribute("data-ignore-current"))return;new URL(e.href).pathname.replace(/\/$/,"")===t?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current")}))},o=()=>{e.setAttribute("aria-hidden",!r),r?e.removeAttribute("inert"):e.setAttribute("inert","")},d=e=>{r=e,o()},s=e.id;window.addEventListener("sidebar:open",(e=>{e.detail?.id&&e.detail.id!==s||d(!0)})),window.addEventListener("sidebar:close",(e=>{e.detail?.id&&e.detail.id!==s||d(!1)})),window.addEventListener("sidebar:toggle",(e=>{e.detail?.id&&e.detail.id!==s||d(!r)})),e.addEventListener("click",(t=>{const a=t.target,r=e.querySelector("nav");if(window.innerWidth<n&&a.closest("a, button")&&!a.closest("[data-keep-mobile-sidebar-open]"))return document.activeElement&&document.activeElement.blur(),void d(!1);(a===e||r&&!r.contains(a))&&(document.activeElement&&document.activeElement.blur(),d(!1))})),window.addEventListener("popstate",i),window.addEventListener("basecoat:locationchange",i),o(),i(),e.dataset.sidebarInitialized=!0};document.querySelectorAll(".sidebar:not([data-sidebar-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches(".sidebar:not([data-sidebar-initialized])")&&e(t),t.querySelectorAll(".sidebar:not([data-sidebar-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})(),(()=>{const e=e=>{const t=e.querySelector('[role="tablist"]');if(!t)return;const a=Array.from(t.querySelectorAll('[role="tab"]')),n=a.map((e=>document.getElementById(e.getAttribute("aria-controls")))).filter(Boolean),r=e=>{a.forEach(((e,t)=>{e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),n[t]&&(n[t].hidden=!0)})),e.setAttribute("aria-selected","true"),e.setAttribute("tabindex","0");const t=document.getElementById(e.getAttribute("aria-controls"));t&&(t.hidden=!1)};t.addEventListener("click",(e=>{const t=e.target.closest('[role="tab"]');t&&r(t)})),t.addEventListener("keydown",(e=>{const t=e.target;if(!a.includes(t))return;let n;const i=a.indexOf(t);switch(e.key){case"ArrowRight":n=a[(i+1)%a.length];break;case"ArrowLeft":n=a[(i-1+a.length)%a.length];break;case"Home":n=a[0];break;case"End":n=a[a.length-1];break;default:return}e.preventDefault(),r(n),n.focus()})),e.dataset.tabsInitialized=!0};document.querySelectorAll(".tabs:not([data-tabs-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches(".tabs:not([data-tabs-initialized])")&&e(t),t.querySelectorAll(".tabs:not([data-tabs-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})(),(()=>{let e;const t=new WeakMap;let a=!1;const n={success:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>',error:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>',info:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>',warning:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>'};function r(t){t.dataset.toasterInitialized||(e=t,e.addEventListener("mouseenter",o),e.addEventListener("mouseleave",d),e.addEventListener("click",(e=>{const t=e.target.closest(".toast footer a"),a=e.target.closest(".toast footer button");(t||a)&&s(e.target.closest(".toast"))})),e.querySelectorAll(".toast:not([data-toast-initialized])").forEach(i),e.dataset.toasterInitialized="true")}function i(e){if(e.dataset.toastInitialized)return;const n=parseInt(e.dataset.duration),r=-1!==n?n||("error"===e.dataset.category?5e3:3e3):-1,i={remainingTime:r,timeoutId:null,startTime:null};-1!==r&&(a?i.timeoutId=null:(i.startTime=Date.now(),i.timeoutId=setTimeout((()=>s(e)),r))),t.set(e,i),e.dataset.toastInitialized="true"}function o(){a||(a=!0,e.querySelectorAll('.toast:not([aria-hidden="true"])').forEach((e=>{if(!t.has(e))return;const a=t.get(e);a.timeoutId&&(clearTimeout(a.timeoutId),a.timeoutId=null,a.remainingTime-=Date.now()-a.startTime)})))}function d(){a&&(a=!1,e.querySelectorAll('.toast:not([aria-hidden="true"])').forEach((e=>{if(!t.has(e))return;const a=t.get(e);-1===a.remainingTime||a.timeoutId||(a.remainingTime>0?(a.startTime=Date.now(),a.timeoutId=setTimeout((()=>s(e)),a.remainingTime)):s(e))})))}function s(e){if(!t.has(e))return;const a=t.get(e);clearTimeout(a.timeoutId),t.delete(e),document.activeElement&&document.activeElement.blur(),e.setAttribute("aria-hidden","true"),e.addEventListener("transitionend",(()=>e.remove()),{once:!0})}const c=document.getElementById("toaster");c&&r(c),window.addEventListener("basecoat:toast",(t=>{if(!e)return void console.error("Cannot create toast: toaster container not found on page.");const a=function(e){const{category:t="info",title:a,description:r,action:i,cancel:o,duration:d,icon:s}=e,c=s||t&&n[t]||"",l=a?`<h2>${a}</h2>`:"",u=r?`<p>${r}</p>`:"",h=i?.href?`<a href="${i.href}" class="btn" data-toast-action>${i.label}</a>`:i?.onclick?`<button type="button" class="btn" data-toast-action onclick="${i.onclick}">${i.label}</button>`:"",v=o?`<button type="button" class="btn-outline h-6 text-xs px-2.5 rounded-sm" data-toast-cancel onclick="${o?.onclick}">${o.label}</button>`:"",p=`\n <div\n class="toast"\n role="${"error"===t?"alert":"status"}"\n aria-atomic="true"\n ${t?`data-category="${t}"`:""}\n ${void 0!==d?`data-duration="${d}"`:""}\n >\n <div class="toast-content">\n ${c}\n <section>\n ${l}\n ${u}\n </section>\n ${h||v?`<footer>${h}${v}</footer>`:""}\n </div>\n </div>\n </div>\n `,b=document.createElement("template");return b.innerHTML=p.trim(),b.content.firstChild}(t.detail?.config||{});e.appendChild(a)}));new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches("#toaster")&&r(t),e&&t.matches(".toast:not([data-toast-initialized])")&&i(t))}))}))})).observe(document.body,{childList:!0,subtree:!0})})();