playbook_ui 16.4.0.pre.rc.1 → 16.4.0.pre.rc.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c345cce0dcd0c852e142ed33cbf4983f7aee49a841f0b98abf138b69004f0c4
4
- data.tar.gz: 92d44357dc6eabcc2313f3dd3a5eafaaa62506dbdc61b5021029607708d79435
3
+ metadata.gz: e6e2317099ce7cdcf1c23ce70c26f0a51914272dec95c7ef7529921e0c1029f5
4
+ data.tar.gz: 720485d1b32fb893c00fd2167b9b2a7e636fac03df2fa6e1596fa62202803970
5
5
  SHA512:
6
- metadata.gz: d0030675a5d5b62f5240a492dba198238d3020c49e701e666dc6cf55d24a5edfac7b00bb1b454064ff3ad4ec1a8bffb5674f74e801256e843d1cb15078c86c25
7
- data.tar.gz: 7ea57f4bbe76d7f25c9211b0f2d4d37d6e8d461ccc56bfcd746362d329b326e5ae70e56e105274760476c36a224a9f88e1373a320b0293392cf3b4fd6baee19a
6
+ metadata.gz: 121b5a84eff2012cfa17154a770deeae351f475f2cca5768f2bbc3b71b1b71bd6a06488d002289e196b09c4f6d8f78b06441af3106f4382e368f997bb8a90178
7
+ data.tar.gz: 104dec1624b69165f12ccffe0f6312981eaf6f7503eddce88889626bf28ea2e6a27fb6db4e60bf75e01afba81867f47b6a0ea5e6ba61970e661ce91c35e406cc
@@ -1,5 +1,6 @@
1
1
  import PbEnhancedElement from "../pb_enhanced_element";
2
2
  import { updateSelectionActionBar } from "./advanced_table_action_bar";
3
+ import { setArrowVisibility, toggleVisibility } from "../utilities/domHelpers";
3
4
 
4
5
  const ADVANCED_TABLE_SELECTOR = "[data-advanced-table]";
5
6
  const DOWN_ARROW_SELECTOR = "#advanced-table_open_icon";
@@ -20,10 +21,18 @@ export default class PbAdvancedTable extends PbEnhancedElement {
20
21
  this.childRowsMap = new Map();
21
22
  }
22
23
 
24
+ get table() {
25
+ return this.cachedTable || (this.cachedTable = this.element.closest("table"));
26
+ }
27
+
28
+ get mainTable() {
29
+ return this.cachedMainTable || (this.cachedMainTable = this.element.closest(".pb_advanced_table"));
30
+ }
31
+
23
32
  // Fetch and cache child rows for a given parent row ID
24
33
  childRowsFor(parentId) {
25
34
  if (!this.childRowsMap.has(parentId)) {
26
- const table = this.element.closest("table");
35
+ const table = this.table;
27
36
  const rows = Array.from(
28
37
  table.querySelectorAll(`tr[data-row-parent="${parentId}"]`)
29
38
  );
@@ -33,7 +42,8 @@ export default class PbAdvancedTable extends PbEnhancedElement {
33
42
  }
34
43
 
35
44
  updateTableSelectedRowsAttribute() {
36
- const mainTable = this.element.closest(".pb_advanced_table");
45
+ const mainTable = this.mainTable;
46
+ if (!mainTable) return;
37
47
  mainTable.dataset.selectedRows = JSON.stringify(
38
48
  Array.from(PbAdvancedTable.selectedRows)
39
49
  );
@@ -41,7 +51,8 @@ export default class PbAdvancedTable extends PbEnhancedElement {
41
51
 
42
52
  // Recalculate selected count based on all checked checkboxes
43
53
  recalculateSelectedCount() {
44
- const table = this.element.closest("table");
54
+ const table = this.table;
55
+ if (!table) return;
45
56
 
46
57
  // Get all checkboxes that could be part of the selection
47
58
  // This includes row checkboxes and any parent checkboxes that might be programmatically checked
@@ -95,7 +106,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
95
106
  });
96
107
 
97
108
  this.updateTableSelectedRowsAttribute();
98
- updateSelectionActionBar(table.closest(".pb_advanced_table"), PbAdvancedTable.selectedRows.size);
109
+ updateSelectionActionBar(this.mainTable, PbAdvancedTable.selectedRows.size);
99
110
 
100
111
  // Sync header select-all state
101
112
  if (selectAllCheckbox) {
@@ -139,7 +150,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
139
150
 
140
151
  this.updateTableSelectedRowsAttribute();
141
152
 
142
- const table = checkbox.closest("table");
153
+ const table = this.table;
143
154
  const selectAllCheckbox = table.querySelector("#select-all-rows");
144
155
 
145
156
  if (selectAllCheckbox) {
@@ -153,7 +164,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
153
164
  );
154
165
  selectAllInput.checked = allChecked;
155
166
  }
156
- updateSelectionActionBar(table.closest(".pb_advanced_table"), PbAdvancedTable.selectedRows.size);
167
+ updateSelectionActionBar(this.mainTable, PbAdvancedTable.selectedRows.size);
157
168
  }
158
169
 
159
170
  get target() {
@@ -161,10 +172,11 @@ export default class PbAdvancedTable extends PbEnhancedElement {
161
172
  }
162
173
 
163
174
  connect() {
164
- const table = this.element.closest("table");
175
+ const table = this.table;
176
+ if (!table) return;
165
177
 
166
178
  this.hideCloseIcon();
167
- const mainTable = this.element.closest(".pb_advanced_table");
179
+ const mainTable = this.mainTable;
168
180
 
169
181
  // This so it is hidden on first render
170
182
  if (mainTable) {
@@ -271,9 +283,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
271
283
  }
272
284
 
273
285
  // Find direct child rows
274
- const childRows = Array.from(
275
- table.querySelectorAll(`[data-row-parent="${toggleBtn.id}"]`)
276
- );
286
+ const childRows = this.childRowsFor(toggleBtn.id);
277
287
  this.toggleElement(childRows);
278
288
 
279
289
  // Restore original element context
@@ -284,7 +294,8 @@ export default class PbAdvancedTable extends PbEnhancedElement {
284
294
  }
285
295
 
286
296
  addBorderRadiusOnLastVisibleRow() {
287
- const parentElement = this.element.closest(".pb_advanced_table");
297
+ const parentElement = this.mainTable;
298
+ if (!parentElement) return;
288
299
 
289
300
  const table = document.getElementById(parentElement.id);
290
301
 
@@ -316,11 +327,9 @@ export default class PbAdvancedTable extends PbEnhancedElement {
316
327
  elements.forEach((elem) => {
317
328
  elem.style.display = "table-row";
318
329
  elem.classList.add("is-visible");
319
- const childRowsAll = this.element
320
- .closest("table")
321
- .querySelectorAll(
322
- `[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`
323
- );
330
+ const childRowsAll = this.table.querySelectorAll(
331
+ `[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`
332
+ );
324
333
 
325
334
  childRowsAll.forEach((childRow) => {
326
335
  const dataContent = childRow.dataset.advancedTableContent;
@@ -382,8 +391,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
382
391
  const currentDepth = parseInt(elem.dataset.rowDepth);
383
392
  if (childrenArray.length > currentDepth) {
384
393
  // Find the child rows corresponding to this parent row
385
- const childRows = this.element
386
- .closest("table")
394
+ const childRows = this.table
387
395
  .querySelectorAll(
388
396
  `[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`
389
397
  );
@@ -401,28 +409,39 @@ export default class PbAdvancedTable extends PbEnhancedElement {
401
409
 
402
410
  const isVisible = elements[0].classList.contains("is-visible");
403
411
 
404
- isVisible ? this.hideElement(elements) : this.showElement(elements);
405
- isVisible ? this.displayDownArrow() : this.displayUpArrow();
412
+ const isExpanded = toggleVisibility({
413
+ isVisible,
414
+ onHide: () => this.hideElement(elements),
415
+ onShow: () => this.showElement(elements),
416
+ });
417
+
418
+ isExpanded ? this.displayUpArrow() : this.displayDownArrow();
406
419
 
407
420
  const row = this.element.closest("tr");
408
421
  if (row) {
409
- row.classList.toggle("bg-silver", !isVisible);
410
- row.classList.toggle("pb-bg-row-white", isVisible);
422
+ row.classList.toggle("bg-silver", isExpanded);
423
+ row.classList.toggle("pb-bg-row-white", !isExpanded);
411
424
  }
412
425
 
413
426
  this.addBorderRadiusOnLastVisibleRow();
414
427
  }
415
428
 
416
429
  displayDownArrow() {
417
- this.element.querySelector(DOWN_ARROW_SELECTOR).style.display =
418
- "inline-block";
419
- this.element.querySelector(UP_ARROW_SELECTOR).style.display = "none";
430
+ setArrowVisibility({
431
+ rootElement: this.element,
432
+ downSelector: DOWN_ARROW_SELECTOR,
433
+ upSelector: UP_ARROW_SELECTOR,
434
+ showDownArrow: true,
435
+ });
420
436
  }
421
437
 
422
438
  displayUpArrow() {
423
- this.element.querySelector(UP_ARROW_SELECTOR).style.display =
424
- "inline-block";
425
- this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = "none";
439
+ setArrowVisibility({
440
+ rootElement: this.element,
441
+ downSelector: DOWN_ARROW_SELECTOR,
442
+ upSelector: UP_ARROW_SELECTOR,
443
+ showDownArrow: false,
444
+ });
426
445
  }
427
446
 
428
447
  static handleToggleAllHeaders(element) {
@@ -1,4 +1,5 @@
1
1
  import PbEnhancedElement from '../pb_enhanced_element'
2
+ import { getElementHeight, setArrowVisibility, toggleVisibility } from '../utilities/domHelpers'
2
3
 
3
4
  const MAIN_SELECTOR = '[data-collapsible-main]'
4
5
  const CONTENT_SELECTOR = '[data-collapsible-content]'
@@ -43,15 +44,7 @@ export default class PbCollapsible extends PbEnhancedElement {
43
44
  }
44
45
 
45
46
  showElement(elem) {
46
- // Get the natural height of the element
47
- const getHeight = () => {
48
- elem.style.display = 'block'
49
- const height = elem.scrollHeight + 'px' // Get it's height
50
- elem.style.display = '' // Hide it again
51
- return height
52
- }
53
-
54
- const height = getHeight()
47
+ const height = getElementHeight(elem)
55
48
  elem.classList.add('is-visible')
56
49
  elem.style.height = height // Update the max-height
57
50
  elem.style.overflow = "hidden"
@@ -82,26 +75,22 @@ export default class PbCollapsible extends PbEnhancedElement {
82
75
  }
83
76
 
84
77
  toggleElement(elem) {
85
- if (elem.classList.contains('is-visible')) {
86
- this.hideElement(elem)
87
- this.displayDownArrow()
88
- return
89
- }
90
- // Otherwise, show it
91
- this.showElement(elem)
92
- this.displayUpArrow()
78
+ const isExpanded = toggleVisibility({
79
+ isVisible: elem.classList.contains('is-visible'),
80
+ onHide: () => this.hideElement(elem),
81
+ onShow: () => this.showElement(elem),
82
+ })
83
+
84
+ isExpanded ? this.displayUpArrow() : this.displayDownArrow()
93
85
  }
94
86
 
95
87
  toggleArrows(showDownArrow) {
96
- const downArrow = this.element.querySelector(DOWN_ARROW_SELECTOR);
97
- const upArrow = this.element.querySelector(UP_ARROW_SELECTOR);
98
-
99
- if (downArrow) {
100
- downArrow.style.display = showDownArrow ? 'inline-block' : 'none';
101
- }
102
- if (upArrow) {
103
- upArrow.style.display = showDownArrow ? 'none' : 'inline-block';
104
- }
88
+ setArrowVisibility({
89
+ rootElement: this.element,
90
+ downSelector: DOWN_ARROW_SELECTOR,
91
+ upSelector: UP_ARROW_SELECTOR,
92
+ showDownArrow,
93
+ })
105
94
  }
106
95
 
107
96
  displayDownArrow() {
@@ -1,5 +1,6 @@
1
1
  import PbEnhancedElement from "../pb_enhanced_element";
2
2
  import { PbDropdownKeyboard } from "./keyboard_accessibility";
3
+ import { setArrowVisibility, toggleVisibility } from "../utilities/domHelpers";
3
4
 
4
5
  const DROPDOWN_SELECTOR = "[data-pb-dropdown]";
5
6
  const TRIGGER_SELECTOR = "[data-dropdown-trigger]";
@@ -23,7 +24,38 @@ export default class PbDropdown extends PbEnhancedElement {
23
24
  }
24
25
 
25
26
  get target() {
26
- return this.element.querySelector(CONTAINER_SELECTOR);
27
+ return this.cachedElements?.target || this.element.querySelector(CONTAINER_SELECTOR);
28
+ }
29
+
30
+ get baseInput() {
31
+ return this.cachedElements?.baseInput || this.element.querySelector(DROPDOWN_INPUT);
32
+ }
33
+
34
+ get trigger() {
35
+ return this.cachedElements?.trigger || this.element.querySelector(TRIGGER_SELECTOR);
36
+ }
37
+
38
+ get customTrigger() {
39
+ return this.cachedElements?.customTrigger || this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);
40
+ }
41
+
42
+ get dropdownWrapper() {
43
+ return this.cachedElements?.dropdownWrapper || this.element.querySelector(".dropdown_wrapper");
44
+ }
45
+
46
+ get placeholder() {
47
+ return this.cachedElements?.placeholder || this.element.querySelector(DROPDOWN_PLACEHOLDER);
48
+ }
49
+
50
+ cacheElements() {
51
+ this.cachedElements = {
52
+ target: this.element.querySelector(CONTAINER_SELECTOR),
53
+ baseInput: this.element.querySelector(DROPDOWN_INPUT),
54
+ trigger: this.element.querySelector(TRIGGER_SELECTOR),
55
+ customTrigger: this.element.querySelector(CUSTOM_DISPLAY_SELECTOR),
56
+ dropdownWrapper: this.element.querySelector(".dropdown_wrapper"),
57
+ placeholder: this.element.querySelector(DROPDOWN_PLACEHOLDER),
58
+ };
27
59
  }
28
60
 
29
61
  selectedOptions = new Set();
@@ -32,6 +64,7 @@ export default class PbDropdown extends PbEnhancedElement {
32
64
  connect() {
33
65
  // Store instance on element for DatePicker sync
34
66
  this.element._pbDropdownInstance = this;
67
+ this.cacheElements();
35
68
 
36
69
  this.keyboardHandler = new PbDropdownKeyboard(this);
37
70
  this.isMultiSelect = this.element.dataset.pbDropdownMultiSelect === "true";
@@ -39,7 +72,7 @@ export default class PbDropdown extends PbEnhancedElement {
39
72
  this.formPillProps = this.element.dataset.formPillProps
40
73
  ? JSON.parse(this.element.dataset.formPillProps)
41
74
  : {};
42
- const baseInput = this.element.querySelector(DROPDOWN_INPUT);
75
+ const baseInput = this.baseInput;
43
76
  this.wasOriginallyRequired =
44
77
  baseInput && baseInput.hasAttribute("required");
45
78
  this.setDefaultValue();
@@ -77,7 +110,7 @@ export default class PbDropdown extends PbEnhancedElement {
77
110
 
78
111
  // Clean up custom trigger click listener
79
112
  if (this.customTriggerClickHandler) {
80
- const customTrigger = this.element.querySelector(CUSTOM_DISPLAY_SELECTOR) || this.element
113
+ const customTrigger = this.customTrigger || this.element
81
114
  customTrigger.removeEventListener('click', this.customTriggerClickHandler)
82
115
  }
83
116
 
@@ -99,7 +132,7 @@ export default class PbDropdown extends PbEnhancedElement {
99
132
  // Clean up search input listeners
100
133
  if (this.searchInput) {
101
134
  if (this.searchInputFocusHandler) {
102
- const trigger = this.element.querySelector(TRIGGER_SELECTOR)
135
+ const trigger = this.trigger
103
136
  if (trigger) {
104
137
  trigger.removeEventListener('click', this.searchInputFocusHandler)
105
138
  }
@@ -123,14 +156,13 @@ export default class PbDropdown extends PbEnhancedElement {
123
156
  }
124
157
  const hasSelection = this.isMultiSelect
125
158
  ? this.selectedOptions.size > 0
126
- : Boolean(this.element.querySelector(DROPDOWN_INPUT).value);
159
+ : Boolean(this.baseInput?.value);
127
160
 
128
161
  this.clearBtn.style.display = hasSelection ? "" : "none";
129
162
  }
130
163
 
131
164
  bindEventListeners() {
132
- const customTrigger =
133
- this.element.querySelector(CUSTOM_DISPLAY_SELECTOR) || this.element;
165
+ const customTrigger = this.customTrigger || this.element;
134
166
  this.customTriggerClickHandler = (e) => {
135
167
  const label = e.target.closest(LABEL_SELECTOR);
136
168
  if (label && label.htmlFor) {
@@ -176,9 +208,7 @@ export default class PbDropdown extends PbEnhancedElement {
176
208
 
177
209
  // Focus the input when anyone clicks the wrapper
178
210
  this.searchInputFocusHandler = () => this.searchInput.focus()
179
- this.element
180
- .querySelector(TRIGGER_SELECTOR)
181
- ?.addEventListener('click', this.searchInputFocusHandler);
211
+ this.trigger?.addEventListener('click', this.searchInputFocusHandler);
182
212
 
183
213
  // Live filter
184
214
  this.searchInputHandler = (e) => this.handleSearch(e.target.value)
@@ -210,7 +240,7 @@ export default class PbDropdown extends PbEnhancedElement {
210
240
  adjustDropdownPosition(container) {
211
241
  if (!container) return;
212
242
 
213
- const wrapper = this.element.querySelector(".dropdown_wrapper");
243
+ const wrapper = this.dropdownWrapper;
214
244
  if (!wrapper) return;
215
245
 
216
246
  const wrapperRect = wrapper.getBoundingClientRect();
@@ -283,7 +313,7 @@ export default class PbDropdown extends PbEnhancedElement {
283
313
 
284
314
  handleOptionClick(event) {
285
315
  const option = event.target.closest(OPTION_SELECTOR);
286
- const hiddenInput = this.element.querySelector(DROPDOWN_INPUT);
316
+ const hiddenInput = this.baseInput;
287
317
 
288
318
  if (option) {
289
319
  const value = option.dataset.dropdownOptionLabel;
@@ -327,13 +357,13 @@ export default class PbDropdown extends PbEnhancedElement {
327
357
  isClickOutside(event) {
328
358
  const label = event.target.closest(LABEL_SELECTOR);
329
359
  if (label && this.element.contains(label)) return false;
330
- const customTrigger = this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);
360
+ const customTrigger = this.customTrigger;
331
361
  if (customTrigger) {
332
362
  const clickInTrigger = customTrigger.contains(event.target);
333
363
  const clickInContainer = this.target?.contains(event.target);
334
364
  return !clickInTrigger && !clickInContainer;
335
365
  } else {
336
- const triggerElement = this.element.querySelector(TRIGGER_SELECTOR);
366
+ const triggerElement = this.trigger;
337
367
  const containerElement = this.element.querySelector(CONTAINER_SELECTOR);
338
368
 
339
369
  const isOutsideTrigger = triggerElement
@@ -353,7 +383,7 @@ export default class PbDropdown extends PbEnhancedElement {
353
383
  if (this.isMultiSelect) {
354
384
  detail = Array.from(this.selectedOptions).map(JSON.parse);
355
385
  } else {
356
- const hiddenInput = this.element.querySelector(DROPDOWN_INPUT);
386
+ const hiddenInput = this.baseInput;
357
387
  detail = hiddenInput.value
358
388
  ? JSON.parse(
359
389
  this.element.querySelector(
@@ -472,7 +502,7 @@ export default class PbDropdown extends PbEnhancedElement {
472
502
  this.emitSelectionChange();
473
503
  }
474
504
 
475
- const customTrigger = this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);
505
+ const customTrigger = this.customTrigger;
476
506
  const shouldCloseOnOptionSelect =
477
507
  this.closeOnClick === "any" || this.closeOnClick === "inside";
478
508
  if (
@@ -496,7 +526,7 @@ export default class PbDropdown extends PbEnhancedElement {
496
526
  this.adjustDropdownHeight();
497
527
  }
498
528
  });
499
- this.element.querySelector(DROPDOWN_INPUT).value = Array.from(
529
+ this.baseInput.value = Array.from(
500
530
  this.selectedOptions,
501
531
  )
502
532
  .map((opt) => JSON.parse(opt).id)
@@ -550,26 +580,26 @@ export default class PbDropdown extends PbEnhancedElement {
550
580
  }
551
581
 
552
582
  toggleElement(elem) {
553
- if (elem.classList.contains("open")) {
554
- this.hideElement(elem);
555
- this.updateArrowDisplay(false);
556
- return;
557
- }
558
- this.showElement(elem);
559
- this.updateArrowDisplay(true);
583
+ const isOpen = toggleVisibility({
584
+ isVisible: elem.classList.contains("open"),
585
+ onHide: () => this.hideElement(elem),
586
+ onShow: () => this.showElement(elem),
587
+ });
588
+
589
+ this.updateArrowDisplay(isOpen);
560
590
  }
561
591
 
562
592
  updateArrowDisplay(isOpen) {
563
- const downArrow = this.element.querySelector(DOWN_ARROW_SELECTOR);
564
- const upArrow = this.element.querySelector(UP_ARROW_SELECTOR);
565
- if (downArrow && upArrow) {
566
- downArrow.style.display = isOpen ? "none" : "inline-block";
567
- upArrow.style.display = isOpen ? "inline-block" : "none";
568
- }
593
+ setArrowVisibility({
594
+ rootElement: this.element,
595
+ downSelector: DOWN_ARROW_SELECTOR,
596
+ upSelector: UP_ARROW_SELECTOR,
597
+ showDownArrow: !isOpen,
598
+ });
569
599
  }
570
600
 
571
601
  handleFormValidation() {
572
- const hiddenInput = this.element.querySelector(DROPDOWN_INPUT);
602
+ const hiddenInput = this.baseInput;
573
603
 
574
604
  hiddenInput.addEventListener(
575
605
  "invalid",
@@ -612,7 +642,7 @@ export default class PbDropdown extends PbEnhancedElement {
612
642
  }
613
643
 
614
644
  setDefaultValue() {
615
- const hiddenInput = this.element.querySelector(DROPDOWN_INPUT);
645
+ const hiddenInput = this.baseInput;
616
646
  const optionEls = Array.from(
617
647
  this.element.querySelectorAll(OPTION_SELECTOR),
618
648
  );
@@ -725,7 +755,7 @@ export default class PbDropdown extends PbEnhancedElement {
725
755
  }
726
756
 
727
757
  resetDropdownValue() {
728
- const hiddenInput = this.element.querySelector(DROPDOWN_INPUT);
758
+ const hiddenInput = this.baseInput;
729
759
  const options = this.element.querySelectorAll(OPTION_SELECTOR);
730
760
  options.forEach((option) => {
731
761
  option.classList.remove("pb_dropdown_option_selected");
@@ -734,7 +764,7 @@ export default class PbDropdown extends PbEnhancedElement {
734
764
 
735
765
  hiddenInput.value = "";
736
766
 
737
- const defaultPlaceholder = this.element.querySelector(DROPDOWN_PLACEHOLDER);
767
+ const defaultPlaceholder = this.placeholder;
738
768
  this.setTriggerElementText(defaultPlaceholder.dataset.dropdownPlaceholder);
739
769
 
740
770
  if (this.searchInput) {
@@ -933,7 +963,7 @@ export default class PbDropdown extends PbEnhancedElement {
933
963
  .querySelectorAll('input[data-generated="true"]')
934
964
  .forEach((n) => n.remove());
935
965
 
936
- const baseInput = this.element.querySelector(DROPDOWN_INPUT);
966
+ const baseInput = this.baseInput;
937
967
  if (!baseInput) return;
938
968
  // for multi_select, for each selectedOption, create a hidden input
939
969
  const name = baseInput.getAttribute("name");
@@ -971,10 +1001,10 @@ export default class PbDropdown extends PbEnhancedElement {
971
1001
  this.adjustDropdownHeight();
972
1002
  });
973
1003
 
974
- const hiddenInput = this.element.querySelector(DROPDOWN_INPUT);
1004
+ const hiddenInput = this.baseInput;
975
1005
  if (hiddenInput) hiddenInput.value = "";
976
1006
 
977
- const placeholder = this.element.querySelector(DROPDOWN_PLACEHOLDER);
1007
+ const placeholder = this.placeholder;
978
1008
  if (placeholder)
979
1009
  this.setTriggerElementText(placeholder.dataset.dropdownPlaceholder);
980
1010
  }
@@ -1,3 +1,4 @@
1
+ <%== deprecated_kit_warning('RichTextEditor') %>
1
2
  <%= react_component('RichTextEditor',
2
3
  object.rich_text_options,
3
4
  aria: object.aria,
@@ -0,0 +1,50 @@
1
+ type ToggleVisibilityOptions = {
2
+ isVisible: boolean,
3
+ onHide: () => void,
4
+ onShow: () => void,
5
+ }
6
+
7
+ type ArrowVisibilityOptions = {
8
+ rootElement: ParentNode,
9
+ downSelector: string,
10
+ upSelector: string,
11
+ showDownArrow: boolean,
12
+ displayValue?: string,
13
+ }
14
+
15
+ export const toggleVisibility = ({ isVisible, onHide, onShow }: ToggleVisibilityOptions): boolean => {
16
+ if (isVisible) {
17
+ onHide()
18
+ return false
19
+ }
20
+
21
+ onShow()
22
+ return true
23
+ }
24
+
25
+ export const getElementHeight = (element: HTMLElement, displayValue = 'block'): string => {
26
+ const originalDisplay = element.style.display
27
+ element.style.display = displayValue
28
+ const height = `${element.scrollHeight}px`
29
+ element.style.display = originalDisplay
30
+ return height
31
+ }
32
+
33
+ export const setArrowVisibility = ({
34
+ rootElement,
35
+ downSelector,
36
+ upSelector,
37
+ showDownArrow,
38
+ displayValue = 'inline-block',
39
+ }: ArrowVisibilityOptions): void => {
40
+ const downArrow = rootElement.querySelector<HTMLElement>(downSelector)
41
+ const upArrow = rootElement.querySelector<HTMLElement>(upSelector)
42
+
43
+ if (downArrow) {
44
+ downArrow.style.display = showDownArrow ? displayValue : 'none'
45
+ }
46
+
47
+ if (upArrow) {
48
+ upArrow.style.display = showDownArrow ? 'none' : displayValue
49
+ }
50
+ }
data/dist/menu.yml CHANGED
@@ -505,6 +505,7 @@ kits:
505
505
  platforms: *1
506
506
  description:
507
507
  status: stable
508
+ platforms_status: { rails: deprecated }
508
509
  icons_used: true
509
510
  react_rendered: true
510
511
  enhanced_element_used: false
@@ -1 +1 @@
1
- var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:true,configurable:true,writable:true,value:value}):obj[key]=value;var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!=="symbol"?key+"":key,value);import{P as PbEnhancedElement,s as stripEmojisForPaste,a as applyEmojiMask,d as debounce,b as PbPopover,e as PbTooltip,h as PbTypeahead,i as PbTable,j as PbTextarea,k as formHelper,l as datePickerHelper}from"./chunks/lib-DspaUdlc.js";import{I as INPUTMASKS}from"./chunks/_typeahead-DdGKR1rQ.js";import"./chunks/lazysizes-B7xYodB-.js";import"./playbook-rails-react-bindings.js";import"react";import"react/jsx-runtime";import"./chunks/globalProps-CK2YuA9O.js";import"react-trix";import"trix";import"react-dom";import"react-is";import"./chunks/componentRegistry-DRSp5D_e.js";class PbKitRegistry{constructor(){this.kits=new Map;this.mutationObserver=null;this.initialized=false;this.queued=false;this.pendingMutations=[]}static getInstance(){if(!PbKitRegistry.instance){PbKitRegistry.instance=new PbKitRegistry}return PbKitRegistry.instance}register(kit){const selector=kit.selector;if(!selector){console.warn("[PbKitRegistry] Kit missing selector:",kit.name);return}const list=this.kits.get(selector)||[];list.push(kit);this.kits.set(selector,list)}start(){if(this.initialized)return;this.initialized=true;const target=document.documentElement||document;this.mutationObserver=new MutationObserver((muts=>this.onMutations(muts)));this.mutationObserver.observe(target,{childList:true,subtree:true});this.scan(document)}stop(){var _a;if(!this.initialized)return;(_a=this.mutationObserver)==null?void 0:_a.disconnect();this.mutationObserver=null;this.kits.forEach((kitsForSelector=>{kitsForSelector.forEach((kit=>{if(!kit.elements)return;const els=Array.from(kit.elements.keys());els.forEach((el=>kit.removeMatch(el)))}))}));this.pendingMutations=[];this.queued=false;this.initialized=false}onMutations(muts){this.pendingMutations.push(...muts);if(this.queued)return;this.queued=true;requestAnimationFrame((()=>{this.queued=false;const batch=this.pendingMutations;this.pendingMutations=[];this.processMutations(batch)}))}processMutations(mutations){const addedRoots=[];for(const mutation of mutations){if(mutation.type!=="childList")continue;mutation.addedNodes.forEach((node=>{if(node.nodeType===Node.ELEMENT_NODE){addedRoots.push(node)}}))}if(addedRoots.length){for(const root of addedRoots){this.scan(root)}}this.cleanupDisconnected()}scan(root){this.kits.forEach(((kitsForSelector,selector)=>{var _a;let matches;try{matches=root.querySelectorAll?root.querySelectorAll(selector):document.querySelectorAll(selector)}catch(error){console.debug(`[PbKitRegistry] Invalid selector "${selector}"`,error);return}if(matches&&matches.length){matches.forEach((el=>{kitsForSelector.forEach((kit=>kit.addMatch(el)))}))}if((_a=root.matches)==null?void 0:_a.call(root,selector)){kitsForSelector.forEach((kit=>kit.addMatch(root)))}}))}cleanupDisconnected(){this.kits.forEach((kitsForSelector=>{kitsForSelector.forEach((kit=>{if(!kit.elements)return;const els=Array.from(kit.elements.keys());for(const el of els){if(!el.isConnected){kit.removeMatch(el)}}}))}))}getRegisteredSelectors(){return Array.from(this.kits.keys())}rescan(root=document){if(!this.initialized)return;this.scan(root)}}const PbKitRegistry$1=PbKitRegistry.getInstance();class PbTextInput extends PbEnhancedElement{static get selector(){return'[data-pb-input-mask="true"], [data-pb-emoji-mask="true"]'}connect(){this.handleInput=this.handleInput.bind(this);this.handlePaste=this.handlePaste.bind(this);this.element.addEventListener("input",this.handleInput);this.element.addEventListener("paste",this.handlePaste);this.handleInput()}disconnect(){this.element.removeEventListener("input",this.handleInput);this.element.removeEventListener("paste",this.handlePaste)}hasEmojiMask(){return this.element.dataset.pbEmojiMask==="true"}handlePaste(event){if(!this.hasEmojiMask())return;const pastedText=event.clipboardData.getData("text");const filteredText=stripEmojisForPaste(pastedText);if(pastedText!==filteredText){event.preventDefault();const input=this.element;const start=input.selectionStart||0;const end=input.selectionEnd||0;const currentValue=input.value;const newValue=currentValue.slice(0,start)+filteredText+currentValue.slice(end);const newCursor=start+filteredText.length;input.value=newValue;input.selectionStart=input.selectionEnd=newCursor;this.handleInput({skipEmojiFilter:true})}}handleInput({skipEmojiFilter:skipEmojiFilter=false}={}){var _a;const cursorPosition=this.element.selectionStart;let baseValue=this.element.value;if(this.hasEmojiMask()&&!skipEmojiFilter){const result=applyEmojiMask(this.element);baseValue=result.value}const maskType=this.element.getAttribute("mask");let formattedValue=baseValue;const maskKey={currency:"currency",ssn:"ssn",postal_code:"postalCode",zip_code:"zipCode",credit_card:"creditCard",cvv:"cvv"}[maskType];if(maskKey&&INPUTMASKS[maskKey]){formattedValue=INPUTMASKS[maskKey].format(baseValue)}const sanitizedInput=(_a=this.element.closest(".text_input_wrapper"))==null?void 0:_a.querySelector('[data="sanitized-pb-input"]');if(sanitizedInput){switch(maskType){case"ssn":sanitizedInput.value=sanitizeSSN(formattedValue);break;case"currency":sanitizedInput.value=sanitizeCurrency(formattedValue);break;case"credit_card":sanitizedInput.value=sanitizeCreditCard(formattedValue);break;default:sanitizedInput.value=formattedValue}}if(maskType){this.element.value=formattedValue;setCursorPosition(this.element,cursorPosition,baseValue,formattedValue)}}}function sanitizeSSN(input){return input.replace(/\D/g,"")}function sanitizeCurrency(input){return input.replace(/[$,]/g,"")}function sanitizeCreditCard(input){return input.replace(/\D/g,"")}function setCursorPosition(inputElement,cursorPosition,rawValue,formattedValue){const difference=formattedValue.length-rawValue.length;const newPosition=Math.max(0,cursorPosition+difference);requestAnimationFrame((()=>{inputElement.setSelectionRange(newPosition,newPosition)}))}function getTextFromElement(element){if(!element)return"";return element.tagName.toLowerCase()==="input"?element.value:element.innerText}function copyTextToClipboard(text){if(!text)return;navigator.clipboard.writeText(text).catch((err=>console.error("Failed to copy text:",err)))}function handleExternalControlCopyClick(element){const value=element.getAttribute("data-external-copy-value");const fromId=element.getAttribute("data-external-copy-from");if(value){copyTextToClipboard(value)}else if(fromId){const fromElement=document.querySelector(`#${fromId}`);copyTextToClipboard(getTextFromElement(fromElement))}else{console.warn("Failed to copy:",element)}}class PbCopyButton extends PbEnhancedElement{static get selector(){return".pb_copy_button_kit"}connect(){this.handleClick=this.handleClick.bind(this);this.button=this.element.querySelector("button");if(this.button){this.button.addEventListener("click",this.handleClick)}}disconnect(){if(this.button){this.button.removeEventListener("click",this.handleClick)}}handleClick(){const value=this.element.getAttribute("data-copy-value");const fromId=this.element.getAttribute("data-from");if(value){copyTextToClipboard(value)}else if(fromId){const fromElement=document.querySelector(`#${fromId}`);copyTextToClipboard(getTextFromElement(fromElement))}else{console.warn("No data-copy-value or data-from attribute found")}}}function addCopyEventListeners(){const externalCopyElements=[...document.querySelectorAll("div[data-external-copy-value]"),...document.querySelectorAll("div[data-external-copy-from]")];externalCopyElements.forEach((element=>{element.addEventListener("click",(()=>handleExternalControlCopyClick(element)))}))}const MAIN_SELECTOR="[data-collapsible-main]";const CONTENT_SELECTOR="[data-collapsible-content]";const DOWN_ARROW_SELECTOR$2="#collapsible_open_icon";const UP_ARROW_SELECTOR$2="#collapsible_close_icon";class PbCollapsible extends PbEnhancedElement{static get selector(){return MAIN_SELECTOR}connect(){this.clickHandler=()=>{this.toggleElement(this.target)};this.element.addEventListener("click",this.clickHandler);if(this.target.classList.contains("is-visible")){this.displayUpArrow()}else{this.displayDownArrow()}this.customEventHandler=()=>{this.toggleElement(this.target)};document.addEventListener(`${this.target.id}`,this.customEventHandler)}disconnect(){if(this.clickHandler){this.element.removeEventListener("click",this.clickHandler)}if(this.customEventHandler&&this.target){document.removeEventListener(`${this.target.id}`,this.customEventHandler)}}get target(){return this.element.parentNode.querySelector(CONTENT_SELECTOR)}showElement(elem){const getHeight=()=>{elem.style.display="block";const height2=elem.scrollHeight+"px";elem.style.display="";return height2};const height=getHeight();elem.classList.add("is-visible");elem.style.height=height;elem.style.overflow="hidden";window.setTimeout((()=>{elem.style.height="";elem.style.overflow="visible"}),300)}hideElement(elem){elem.style.height=elem.scrollHeight+"px";window.setTimeout((()=>{elem.style.height="0";elem.style.paddingTop="0";elem.style.paddingBottom="0";elem.style.overflow="hidden"}),1);window.setTimeout((()=>{elem.classList.remove("is-visible");elem.style.overflow=""}),300)}toggleElement(elem){if(elem.classList.contains("is-visible")){this.hideElement(elem);this.displayDownArrow();return}this.showElement(elem);this.displayUpArrow()}toggleArrows(showDownArrow){const downArrow=this.element.querySelector(DOWN_ARROW_SELECTOR$2);const upArrow=this.element.querySelector(UP_ARROW_SELECTOR$2);if(downArrow){downArrow.style.display=showDownArrow?"inline-block":"none"}if(upArrow){upArrow.style.display=showDownArrow?"none":"inline-block"}}displayDownArrow(){this.toggleArrows(true)}displayUpArrow(){this.toggleArrows(false)}}class PbFixedConfirmationToast extends PbEnhancedElement{static get selector(){return'[class*="pb_fixed_confirmation_toast_kit"]'}connect(){this.self=this.element;this.autoCloseToast(this.self);if(this.self.classList.contains("remove_toast")){this.self.addEventListener("click",(()=>{this.removeToast(this.self)}))}}removeToast(elem){elem.parentNode.removeChild(elem)}autoCloseToast(element){const autoCloseDataAttr=element.getAttribute("data-pb-auto-close");if(autoCloseDataAttr){setTimeout((()=>{this.removeToast(element)}),parseInt(autoCloseDataAttr))}}}const OPTION_SELECTOR$1="[data-dropdown-option-label]";const SEARCH_INPUT_SELECTOR$1="[data-dropdown-autocomplete]";class PbDropdownKeyboard{constructor(dropdown){this.dropdown=dropdown;this.dropdownElement=dropdown.element;this.options=Array.from(this.dropdownElement.querySelectorAll(OPTION_SELECTOR$1));this.focusedOptionIndex=-1;this.searchInput=this.dropdownElement.querySelector(SEARCH_INPUT_SELECTOR$1);this.handleKeyDownBound=this.handleKeyDown.bind(this);this.handleSearchInputBound=()=>this.openDropdownIfClosed();this.init()}init(){this.dropdownElement.addEventListener("keydown",this.handleKeyDownBound);if(this.searchInput){this.searchInput.addEventListener("input",this.handleSearchInputBound)}}disconnect(){if(this.dropdownElement&&this.handleKeyDownBound){this.dropdownElement.removeEventListener("keydown",this.handleKeyDownBound)}if(this.searchInput&&this.handleSearchInputBound){this.searchInput.removeEventListener("input",this.handleSearchInputBound)}}getVisibleOptions(){return Array.from(this.dropdownElement.querySelectorAll(OPTION_SELECTOR$1)).filter((opt=>opt.style.display!=="none"))}openDropdownIfClosed(){if(!this.dropdown.target.classList.contains("open")){this.dropdown.showElement(this.dropdown.target);this.dropdown.updateArrowDisplay(true)}}handleKeyDown(event){switch(event.key){case"ArrowDown":event.preventDefault();if(!this.dropdown.target.classList.contains("open")){this.dropdown.showElement(this.dropdown.target);this.dropdown.updateArrowDisplay(true)}this.moveFocus(1);break;case"ArrowUp":event.preventDefault();this.moveFocus(-1);break;case"Enter":event.preventDefault();if(this.focusedOptionIndex!==-1){this.selectOption()}else{if(!this.dropdown.target.classList.contains("open")){this.dropdown.showElement(this.dropdown.target);this.dropdown.updateArrowDisplay(true)}}break;case"Escape":this.dropdown.hideElement(this.dropdown.target);break;case"Tab":this.dropdown.hideElement(this.dropdown.target);this.dropdown.updateArrowDisplay(false);this.resetFocus();break;case"Backspace":if(this.searchInput){setTimeout((()=>{if(this.searchInput.value.trim()===""){this.dropdown.handleBackspaceClear()}}),0)}break}}moveFocus(direction){const allOptions=Array.from(this.dropdownElement.querySelectorAll(OPTION_SELECTOR$1));const visible=this.getVisibleOptions();if(!visible.length)return;if(this.focusedOptionIndex!==-1){allOptions[this.focusedOptionIndex].classList.remove("pb_dropdown_option_focused")}const prevVisibleIndex=this.focusedOptionIndex===-1?-1:visible.indexOf(allOptions[this.focusedOptionIndex]);const nextVisibleIndex=(prevVisibleIndex+direction+visible.length)%visible.length;const nextEl=visible[nextVisibleIndex];nextEl.classList.add("pb_dropdown_option_focused");this.focusedOptionIndex=allOptions.indexOf(nextEl)}selectOption(){const allOptions=Array.from(this.dropdownElement.querySelectorAll(OPTION_SELECTOR$1));if(this.focusedOptionIndex<0)return;const optionEl=allOptions[this.focusedOptionIndex];this.dropdown.handleOptionClick({target:optionEl});this.dropdown.toggleElement(this.dropdown.target);this.dropdown.updateClearButton()}}const DROPDOWN_SELECTOR="[data-pb-dropdown]";const TRIGGER_SELECTOR="[data-dropdown-trigger]";const CONTAINER_SELECTOR="[data-dropdown-container]";const DOWN_ARROW_SELECTOR$1="[data-dropdown-open-icon]";const UP_ARROW_SELECTOR$1="[data-dropdown-close-icon]";const OPTION_SELECTOR="[data-dropdown-option-label]";const CUSTOM_DISPLAY_SELECTOR="[data-dropdown-custom-trigger]";const DROPDOWN_TRIGGER_DISPLAY="[data-dropdown-trigger-display]";const DROPDOWN_PLACEHOLDER="[data-dropdown-placeholder]";const DROPDOWN_INPUT="[data-dropdown-selected-option]";const SEARCH_INPUT_SELECTOR="[data-dropdown-autocomplete]";const SEARCH_BAR_SELECTOR="[data-dropdown-search]";const CLEAR_ICON_SELECTOR="[data-dropdown-clear-icon]";const LABEL_SELECTOR='[data-dropdown="pb-dropdown-label"]';class PbDropdown extends PbEnhancedElement{constructor(){super(...arguments);__publicField(this,"selectedOptions",new Set);__publicField(this,"clearBtn",null)}static get selector(){return DROPDOWN_SELECTOR}get target(){return this.element.querySelector(CONTAINER_SELECTOR)}connect(){this.element._pbDropdownInstance=this;this.keyboardHandler=new PbDropdownKeyboard(this);this.isMultiSelect=this.element.dataset.pbDropdownMultiSelect==="true";this.closeOnClick=this.element.dataset.pbDropdownCloseOnClick||"any";this.formPillProps=this.element.dataset.formPillProps?JSON.parse(this.element.dataset.formPillProps):{};const baseInput=this.element.querySelector(DROPDOWN_INPUT);this.wasOriginallyRequired=baseInput&&baseInput.hasAttribute("required");this.setDefaultValue();this.bindEventListeners();this.bindSearchInput();this.updateArrowDisplay(false);this.handleFormValidation();this.handleFormReset();this.bindSearchBar();this.updatePills();this.clearBtn=this.element.querySelector(CLEAR_ICON_SELECTOR);this.isClearable=this.element.dataset.pbDropdownClearable!=="false";if(this.clearBtn){this.clearBtn.style.display="none";this.clearBtnHandler=e=>{e.stopPropagation();this.clearSelection()};this.clearBtn.addEventListener("click",this.clearBtnHandler)}this.updateClearButton()}disconnect(){if(this.element._pbDropdownInstance===this){delete this.element._pbDropdownInstance}if(this.keyboardHandler&&typeof this.keyboardHandler.disconnect==="function"){this.keyboardHandler.disconnect()}if(this.customTriggerClickHandler){const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR)||this.element;customTrigger.removeEventListener("click",this.customTriggerClickHandler)}if(this.handleOptionClickBound){this.target.removeEventListener("click",this.handleOptionClickBound)}if(this.handleDocumentClickBound){document.removeEventListener("click",this.handleDocumentClickBound,true)}if(this.searchBar&&this.searchBarHandler){this.searchBar.removeEventListener("input",this.searchBarHandler)}if(this.searchInput){if(this.searchInputFocusHandler){const trigger=this.element.querySelector(TRIGGER_SELECTOR);if(trigger){trigger.removeEventListener("click",this.searchInputFocusHandler)}}if(this.searchInputHandler){this.searchInput.removeEventListener("input",this.searchInputHandler)}}if(this.clearBtn&&this.clearBtnHandler){this.clearBtn.removeEventListener("click",this.clearBtnHandler)}}updateClearButton(){if(!this.clearBtn)return;if(!this.isClearable){this.clearBtn.style.display="none";return}const hasSelection=this.isMultiSelect?this.selectedOptions.size>0:Boolean(this.element.querySelector(DROPDOWN_INPUT).value);this.clearBtn.style.display=hasSelection?"":"none"}bindEventListeners(){const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR)||this.element;this.customTriggerClickHandler=e=>{var _a;const label=e.target.closest(LABEL_SELECTOR);if(label&&label.htmlFor){const trigger=this.element.querySelector(`#${CSS.escape(label.htmlFor)}`);if(trigger){trigger.focus()}}if(this.closeOnClick==="outside"&&((_a=this.target)==null?void 0:_a.contains(e.target))){return}this.toggleElement(this.target)};customTrigger.addEventListener("click",this.customTriggerClickHandler);this.handleOptionClickBound=this.handleOptionClick.bind(this);this.target.addEventListener("click",this.handleOptionClickBound);this.handleDocumentClickBound=this.handleDocumentClick.bind(this);document.addEventListener("click",this.handleDocumentClickBound,true)}bindSearchBar(){this.searchBar=this.element.querySelector(SEARCH_BAR_SELECTOR);if(!this.searchBar)return;this.searchBarHandler=e=>this.handleSearch(e.target.value);this.searchBar.addEventListener("input",this.searchBarHandler)}bindSearchInput(){var _a;this.searchInput=this.element.querySelector(SEARCH_INPUT_SELECTOR);if(!this.searchInput)return;this.searchInputFocusHandler=()=>this.searchInput.focus();(_a=this.element.querySelector(TRIGGER_SELECTOR))==null?void 0:_a.addEventListener("click",this.searchInputFocusHandler);this.searchInputHandler=e=>this.handleSearch(e.target.value);this.searchInput.addEventListener("input",this.searchInputHandler)}adjustDropdownHeight(){if(this.target.classList.contains("open")){const el=this.target;const shouldConstrain=el.classList.contains("constrain_height");el.style.height="auto";requestAnimationFrame((()=>{if(shouldConstrain){const fontSize=parseFloat(getComputedStyle(el).fontSize)||16;const maxHeight=fontSize*18;const scrollHeight=el.scrollHeight;const newHeight=Math.min(scrollHeight,maxHeight);el.offsetHeight;el.style.height=newHeight+"px"}else{el.offsetHeight;el.style.height=el.scrollHeight+"px"}}))}}adjustDropdownPosition(container){if(!container)return;const wrapper=this.element.querySelector(".dropdown_wrapper");if(!wrapper)return;const wrapperRect=wrapper.getBoundingClientRect();const h=container.getBoundingClientRect().height||container.scrollHeight;const spaceBelow=window.innerHeight-wrapperRect.bottom;const spaceAbove=wrapperRect.top;if(spaceBelow<h+10&&spaceAbove>=h+10){container.style.top="auto";container.style.bottom="calc(100% + 5px)";container.style.marginTop="0";container.style.marginBottom="0"}else{container.style.top="";container.style.bottom="";container.style.marginTop="";container.style.marginBottom=""}}handleSearch(term=""){const lcTerm=term.toLowerCase();let hasMatch=false;this.element.querySelectorAll(OPTION_SELECTOR).forEach((opt=>{if(this.isMultiSelect&&this.selectedOptions.has(opt.dataset.dropdownOptionLabel)){opt.style.display="none";return}const label=JSON.parse(opt.dataset.dropdownOptionLabel).label.toString().toLowerCase();const match=label.includes(lcTerm);opt.style.display=match?"":"none";if(match)hasMatch=true}));this.adjustDropdownHeight();this.removeNoOptionsMessage();if(!hasMatch){this.showNoOptionsMessage()}}showNoOptionsMessage(){if(this.element.querySelector(".dropdown_no_options"))return;const noOptionElement=document.createElement("div");noOptionElement.className="pb_body_kit_light dropdown_no_options pb_item_kit p_xs display_flex justify_content_center";noOptionElement.textContent="no option";this.target.appendChild(noOptionElement)}removeNoOptionsMessage(){const existing=this.element.querySelector(".dropdown_no_options");if(existing){existing.remove()}}handleOptionClick(event){const option=event.target.closest(OPTION_SELECTOR);const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);if(option){const value=option.dataset.dropdownOptionLabel;if(this.isMultiSelect){const alreadySelected=this.selectedOptions.has(value);if(alreadySelected){this.selectedOptions.delete(value)}else{this.selectedOptions.add(value)}this.updatePills();this.syncHiddenInputs();if(this.searchInput&&this.isMultiSelect){this.searchInput.value="";this.handleBackspaceClear()}}else{hiddenInput.value=JSON.parse(value).id}this.clearFormValidation(hiddenInput);this.onOptionSelected(value,option);this.updateClearButton()}}handleDocumentClick(event){if(event.target.closest(SEARCH_BAR_SELECTOR))return;const shouldCloseOnOutsideClick=this.closeOnClick==="outside"||this.closeOnClick==="any";if(shouldCloseOnOutsideClick&&this.isClickOutside(event)&&this.target.classList.contains("open")){this.hideElement(this.target);this.updateArrowDisplay(false)}}isClickOutside(event){var _a;const label=event.target.closest(LABEL_SELECTOR);if(label&&this.element.contains(label))return false;const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);if(customTrigger){const clickInTrigger=customTrigger.contains(event.target);const clickInContainer=(_a=this.target)==null?void 0:_a.contains(event.target);return!clickInTrigger&&!clickInContainer}else{const triggerElement=this.element.querySelector(TRIGGER_SELECTOR);const containerElement=this.element.querySelector(CONTAINER_SELECTOR);const isOutsideTrigger=triggerElement?!triggerElement.contains(event.target):true;const isOutsideContainer=containerElement?!containerElement.contains(event.target):true;return isOutsideTrigger&&isOutsideContainer}}emitSelectionChange(){let detail;if(this.isMultiSelect){detail=Array.from(this.selectedOptions).map(JSON.parse)}else{const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);detail=hiddenInput.value?JSON.parse(this.element.querySelector(OPTION_SELECTOR+`[data-dropdown-option-label*='"id":"${hiddenInput.value}"']`).dataset.dropdownOptionLabel):null}this.element.setAttribute("data-option-selected",JSON.stringify(detail));this.element.dispatchEvent(new CustomEvent("pb:dropdown:selected",{detail:detail,bubbles:true}))}onOptionSelected(value,selectedOption){var _a,_b,_c,_d;const triggerElement=this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);const customDisplayElement=this.element.querySelector("[data-dropdown-trigger-custom-display]");if(triggerElement){if(!this.isMultiSelect){const selectedLabel=JSON.parse(value).label;triggerElement.textContent=selectedLabel;this.emitSelectionChange();const optionData=JSON.parse(value);const startDateId=this.element.dataset.startDateId;const endDateId=this.element.dataset.endDateId;const controlsStartId=this.element.dataset.controlsStartId;const controlsEndId=this.element.dataset.controlsEndId;if(optionData.formatted_start_date&&optionData.formatted_end_date){if(startDateId){const startDateInput=document.getElementById(startDateId);if(startDateInput)startDateInput.value=optionData.formatted_start_date}if(endDateId){const endDateInput=document.getElementById(endDateId);if(endDateInput)endDateInput.value=optionData.formatted_end_date}if(controlsStartId){const startPicker=(_a=document.querySelector(`#${controlsStartId}`))==null?void 0:_a._flatpickr;if(startPicker){startPicker.setDate(optionData.formatted_start_date,true,"m/d/Y")}}if(controlsEndId){const endPicker=(_b=document.querySelector(`#${controlsEndId}`))==null?void 0:_b._flatpickr;if(endPicker){endPicker.setDate(optionData.formatted_end_date,true,"m/d/Y")}}}else if(startDateId||endDateId){if(startDateId){const startDateInput=document.getElementById(startDateId);if(startDateInput)startDateInput.value=""}if(endDateId){const endDateInput=document.getElementById(endDateId);if(endDateInput)endDateInput.value=""}if(controlsStartId){const startPicker=(_c=document.querySelector(`#${controlsStartId}`))==null?void 0:_c._flatpickr;if(startPicker){startPicker.clear()}}if(controlsEndId){const endPicker=(_d=document.querySelector(`#${controlsEndId}`))==null?void 0:_d._flatpickr;if(endPicker){endPicker.clear()}}}}if(customDisplayElement){triggerElement.textContent="";customDisplayElement.style.display="block";customDisplayElement.style.paddingRight="8px"}}const autocompleteInput=this.element.querySelector(SEARCH_INPUT_SELECTOR);if(autocompleteInput&&!this.isMultiSelect){autocompleteInput.value=JSON.parse(value).label;this.emitSelectionChange()}const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);const shouldCloseOnOptionSelect=this.closeOnClick==="any"||this.closeOnClick==="inside";if(customTrigger&&shouldCloseOnOptionSelect&&this.target.classList.contains("open")){this.hideElement(this.target);this.updateArrowDisplay(false)}const options=this.element.querySelectorAll(OPTION_SELECTOR);if(this.isMultiSelect){this.emitSelectionChange();Array.from(this.selectedOptions).map((option=>{if(JSON.parse(option).id===JSON.parse(selectedOption.dataset.dropdownOptionLabel).id){selectedOption.style.display="none";this.adjustDropdownHeight()}}));this.element.querySelector(DROPDOWN_INPUT).value=Array.from(this.selectedOptions).map((opt=>JSON.parse(opt).id)).join(",")}else{options.forEach((option=>{option.classList.remove("pb_dropdown_option_selected")}));selectedOption.classList.add("pb_dropdown_option_selected")}this.updateClearButton()}showElement(elem){elem.classList.remove("close");elem.classList.add("open");const shouldConstrain=elem.classList.contains("constrain_height");if(shouldConstrain){const fontSize=parseFloat(getComputedStyle(elem).fontSize)||16;const maxHeight=fontSize*18;const scrollHeight=elem.scrollHeight;const height=Math.min(scrollHeight,maxHeight);elem.style.height=height+"px"}else{elem.style.height=elem.scrollHeight+"px"}this.adjustDropdownPosition(elem)}hideElement(elem){elem.style.height=elem.scrollHeight+"px";window.setTimeout((()=>{elem.classList.add("close");elem.classList.remove("open");this.resetFocus()}),0)}resetFocus(){if(this.keyboardHandler){this.keyboardHandler.focusedOptionIndex=-1;const options=this.element.querySelectorAll(OPTION_SELECTOR);options.forEach((option=>option.classList.remove("pb_dropdown_option_focused")))}}toggleElement(elem){if(elem.classList.contains("open")){this.hideElement(elem);this.updateArrowDisplay(false);return}this.showElement(elem);this.updateArrowDisplay(true)}updateArrowDisplay(isOpen){const downArrow=this.element.querySelector(DOWN_ARROW_SELECTOR$1);const upArrow=this.element.querySelector(UP_ARROW_SELECTOR$1);if(downArrow&&upArrow){downArrow.style.display=isOpen?"none":"inline-block";upArrow.style.display=isOpen?"inline-block":"none"}}handleFormValidation(){const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);hiddenInput.addEventListener("invalid",(function(event){if(hiddenInput.hasAttribute("required")&&hiddenInput.value===""){event.preventDefault();hiddenInput.closest(".dropdown_wrapper").classList.add("error")}}),true)}clearFormValidation(input){if(this.isMultiSelect){if(this.selectedOptions.size>0){const dropdownWrapperElement=input.closest(".dropdown_wrapper");dropdownWrapperElement.classList.remove("error");const errorLabelElement=dropdownWrapperElement.querySelector(".pb_body_kit_negative");if(errorLabelElement){errorLabelElement.remove()}return}}if(input.checkValidity()){const dropdownWrapperElement=input.closest(".dropdown_wrapper");dropdownWrapperElement.classList.remove("error");const errorLabelElement=dropdownWrapperElement.querySelector(".pb_body_kit_negative");if(errorLabelElement){errorLabelElement.remove()}}}setDefaultValue(){const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);const optionEls=Array.from(this.element.querySelectorAll(OPTION_SELECTOR));const defaultValue=hiddenInput.dataset.defaultValue||"";if(!defaultValue)return;if(this.isMultiSelect){const ids=defaultValue.split(",");ids.forEach((id=>{const selectedOption=optionEls.find((opt=>{try{return JSON.parse(opt.dataset.dropdownOptionLabel).id===id}catch{return false}}));if(!selectedOption){console.warn(`Dropdown default ID ${id} not found`);return}const raw=selectedOption.dataset.dropdownOptionLabel;this.selectedOptions.add(raw);selectedOption.style.display="none"}));this.updatePills();this.updateClearButton();this.adjustDropdownHeight();this.syncHiddenInputs()}else{hiddenInput.value=defaultValue;const selectedOption=optionEls.find((opt=>{try{return JSON.parse(opt.dataset.dropdownOptionLabel).id===defaultValue}catch{return false}}));if(!selectedOption)return;selectedOption.classList.add("pb_dropdown_option_selected");const optionData=JSON.parse(selectedOption.dataset.dropdownOptionLabel);this.setTriggerElementText(optionData.label);if(optionData.formatted_start_date&&optionData.formatted_end_date){const startDateId=this.element.dataset.startDateId;const endDateId=this.element.dataset.endDateId;const controlsStartId=this.element.dataset.controlsStartId;const controlsEndId=this.element.dataset.controlsEndId;if(startDateId){const startDateInput=document.getElementById(startDateId);if(startDateInput)startDateInput.value=optionData.formatted_start_date}if(endDateId){const endDateInput=document.getElementById(endDateId);if(endDateInput)endDateInput.value=optionData.formatted_end_date}const syncDatePickers=()=>{var _a,_b;if(controlsStartId){const startPicker=(_a=document.querySelector(`#${controlsStartId}`))==null?void 0:_a._flatpickr;if(startPicker){startPicker.setDate(optionData.formatted_start_date,true,"m/d/Y")}}if(controlsEndId){const endPicker=(_b=document.querySelector(`#${controlsEndId}`))==null?void 0:_b._flatpickr;if(endPicker){endPicker.setDate(optionData.formatted_end_date,true,"m/d/Y")}}};syncDatePickers();setTimeout(syncDatePickers,100);setTimeout(syncDatePickers,300)}}}handleFormReset(){const form=this.element.closest("form");if(form){form.addEventListener("reset",(()=>{this.resetDropdownValue()}))}}resetDropdownValue(){const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);const options=this.element.querySelectorAll(OPTION_SELECTOR);options.forEach((option=>{option.classList.remove("pb_dropdown_option_selected");option.style.display=""}));hiddenInput.value="";const defaultPlaceholder=this.element.querySelector(DROPDOWN_PLACEHOLDER);this.setTriggerElementText(defaultPlaceholder.dataset.dropdownPlaceholder);if(this.searchInput){this.searchInput.value="";if(this.target.classList.contains("open")){const el=this.target;el.style.height="auto";requestAnimationFrame((()=>{const newHeight=el.scrollHeight+"px";el.offsetHeight;el.style.height=newHeight}))}}if(this.isMultiSelect){this.selectedOptions.clear();this.updatePills();this.updateClearButton();this.syncHiddenInputs()}}setTriggerElementText(text){const triggerElement=this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);if(triggerElement){triggerElement.textContent=text}}updatePills(){if(!this.isMultiSelect)return;const wrapper=this.element.querySelector("[data-dropdown-pills-wrapper]");const placeholder=this.element.querySelector("[data-dropdown-trigger-display-multi-select]");if(!wrapper)return;wrapper.innerHTML="";if(placeholder){if(this.selectedOptions.size>0){placeholder.style.display="none"}else{placeholder.style.display=""}}Array.from(this.selectedOptions).map((option=>{const pill=document.createElement("div");const color=this.formPillProps.color||"primary";pill.classList.add("pb_form_pill_kit",`pb_form_pill_${color}`,"pb_form_pill_none","mr_xs");if(this.formPillProps.size==="small"){pill.classList.add("pb_form_pill_small")}pill.tabIndex=0;pill.dataset.pillId=JSON.parse(option).id;const innerDiv=document.createElement("h3");innerDiv.className="pb_title_kit pb_title_4 pb_form_pill_text";innerDiv.textContent=JSON.parse(option).label;pill.appendChild(innerDiv);const closeIcon=document.createElement("div");closeIcon.className="pb_form_pill_close";closeIcon.innerHTML=`<svg class="pb_custom_icon svg-inline--fa svg_${this.formPillProps.size==="small"?"xs":"sm"} svg_fw" xmlns="http://www.w3.org/2000/svg" width="auto" height="auto" viewBox="0 0 31 25"><path fill="currentColor" d="M23.0762 6.77734L17.4512 12.4023L23.0293 17.9805C23.498 18.4023 23.498 19.1055 23.0293 19.5273C22.6074 19.9961 21.9043 19.9961 21.4824 19.5273L15.8574 13.9492L10.2793 19.5273C9.85742 19.9961 9.1543 19.9961 8.73242 19.5273C8.26367 19.1055 8.26367 18.4023 8.73242 17.9336L14.3105 12.3555L8.73242 6.77734C8.26367 6.35547 8.26367 5.65234 8.73242 5.18359C9.1543 4.76172 9.85742 4.76172 10.3262 5.18359L15.9043 10.8086L21.4824 5.23047C21.9043 4.76172 22.6074 4.76172 23.0762 5.23047C23.498 5.65234 23.498 6.35547 23.0762 6.77734Z"/></svg>`;pill.appendChild(closeIcon);closeIcon.addEventListener("click",(e=>{e.stopPropagation();const id=pill.dataset.pillId;this.selectedOptions.delete(option);const optEl=this.element.querySelector(`${OPTION_SELECTOR}[data-dropdown-option-label*='"id":${JSON.stringify(id)}']`);if(optEl){optEl.style.display="";if(this.target.classList.contains("open")){this.showElement(this.target)}}this.updatePills();this.updateClearButton();this.emitSelectionChange();this.syncHiddenInputs()}));wrapper.appendChild(pill)}))}clearSelection(){var _a,_b;if(this.isMultiSelect){this.selectedOptions.clear();this.element.querySelectorAll(OPTION_SELECTOR).forEach((opt=>{opt.style.display=""}));if(this.target.classList.contains("open")){this.showElement(this.target)}}const customDisplay=this.element.querySelector("[data-dropdown-trigger-custom-display]");if(customDisplay){customDisplay.style.display="none"}const startDateId=this.element.dataset.startDateId;const endDateId=this.element.dataset.endDateId;const controlsStartId=this.element.dataset.controlsStartId;const controlsEndId=this.element.dataset.controlsEndId;if(startDateId){const startDateInput=document.getElementById(startDateId);if(startDateInput)startDateInput.value=""}if(endDateId){const endDateInput=document.getElementById(endDateId);if(endDateInput)endDateInput.value=""}if(controlsStartId){const startPicker=(_a=document.querySelector(`#${controlsStartId}`))==null?void 0:_a._flatpickr;if(startPicker){startPicker.clear()}}if(controlsEndId){const endPicker=(_b=document.querySelector(`#${controlsEndId}`))==null?void 0:_b._flatpickr;if(endPicker){endPicker.clear()}}this.resetDropdownValue();this.updatePills();this.updateClearButton();this.syncHiddenInputs();this.emitSelectionChange()}clearSelected(){if(this.element.dataset.pbDropdownVariant!=="quickpick"||this.isMultiSelect){return}const customDisplay=this.element.querySelector("[data-dropdown-trigger-custom-display]");if(customDisplay){customDisplay.style.display="none"}const startDateId=this.element.dataset.startDateId;const endDateId=this.element.dataset.endDateId;if(startDateId){const startDateInput=document.getElementById(startDateId);if(startDateInput)startDateInput.value=""}if(endDateId){const endDateInput=document.getElementById(endDateId);if(endDateInput)endDateInput.value=""}this.resetDropdownValue();this.updateClearButton();this.emitSelectionChange()}syncHiddenInputs(){if(!this.isMultiSelect)return;this.element.querySelectorAll('input[data-generated="true"]').forEach((n=>n.remove()));const baseInput=this.element.querySelector(DROPDOWN_INPUT);if(!baseInput)return;const name=baseInput.getAttribute("name");this.selectedOptions.forEach((raw=>{const optionData=JSON.parse(raw);const id=optionData.id||optionData.value;const inp=document.createElement("input");inp.type="hidden";inp.name=name;inp.value=id;inp.dataset.generated="true";baseInput.insertAdjacentElement("afterend",inp)}));if(this.selectedOptions.size>0){baseInput.value="";baseInput.removeAttribute("required")}else{baseInput.value="";if(this.wasOriginallyRequired){baseInput.setAttribute("required","")}}}handleBackspaceClear(){if(!this.isMultiSelect){this.element.querySelectorAll(OPTION_SELECTOR).forEach((opt=>{opt.classList.remove("pb_dropdown_option_selected");opt.style.display="";this.adjustDropdownHeight()}));const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);if(hiddenInput)hiddenInput.value="";const placeholder=this.element.querySelector(DROPDOWN_PLACEHOLDER);if(placeholder)this.setTriggerElementText(placeholder.dataset.dropdownPlaceholder)}if(this.isMultiSelect){this.element.querySelectorAll(OPTION_SELECTOR).forEach((opt=>{const optValue=opt.dataset.dropdownOptionLabel;if(this.selectedOptions.size>0&&this.selectedOptions.has(optValue)){opt.style.display="none"}else{opt.style.display=""}this.adjustDropdownHeight()}))}}}function showActionBar(actionBar,selectedCount){const tableContainer=actionBar.closest(".pb_advanced_table");actionBar.style.height="auto";actionBar.style.overflow="visible";actionBar.style.opacity="1";actionBar.style.transitionProperty="all";actionBar.style.transitionTimingFunction="ease-in-out";actionBar.classList.remove("p_none");actionBar.classList.add("p_xs","is-visible","show-action-card");if(tableContainer){tableContainer.classList.remove("hidden-action-bar")}const countElement=actionBar.querySelector(".selected-count");if(countElement){countElement.textContent=`${selectedCount} Selected`}}function hideActionBar(actionBar){const tableContainer=actionBar.closest(".pb_advanced_table");actionBar.style.height="0px";actionBar.style.overflow="hidden";actionBar.style.opacity="0";actionBar.classList.add("p_none");actionBar.classList.remove("p_xs","is-visible","show-action-card");if(tableContainer){tableContainer.classList.add("hidden-action-bar")}}function updateSelectionActionBar(table,selectedCount){const actionBar=table.querySelector(".row-selection-actions-card");if(!actionBar)return;if(selectedCount>0){showActionBar(actionBar,selectedCount)}else{hideActionBar(actionBar)}}const ADVANCED_TABLE_SELECTOR="[data-advanced-table]";const DOWN_ARROW_SELECTOR="#advanced-table_open_icon";const UP_ARROW_SELECTOR="#advanced-table_close_icon";const _PbAdvancedTable=class _PbAdvancedTable extends PbEnhancedElement{static get selector(){return ADVANCED_TABLE_SELECTOR}constructor(...args){super(...args);this.childRowsMap=new Map}childRowsFor(parentId){if(!this.childRowsMap.has(parentId)){const table=this.element.closest("table");const rows=Array.from(table.querySelectorAll(`tr[data-row-parent="${parentId}"]`));this.childRowsMap.set(parentId,rows)}return this.childRowsMap.get(parentId)}updateTableSelectedRowsAttribute(){const mainTable=this.element.closest(".pb_advanced_table");mainTable.dataset.selectedRows=JSON.stringify(Array.from(_PbAdvancedTable.selectedRows))}recalculateSelectedCount(){const table=this.element.closest("table");const rowCheckboxes=table.querySelectorAll('label[data-row-id] input[type="checkbox"]');const parentCheckboxes=table.querySelectorAll('[data-pb-checkbox-indeterminate-main="true"] input[type="checkbox"]');const selectAllCheckbox=table.querySelector('#select-all-rows input[type="checkbox"]');const filteredParentCheckboxes=Array.from(parentCheckboxes).filter((checkbox=>checkbox!==selectAllCheckbox&&!checkbox.id.includes("select-all-rows")));const allCheckboxes=new Set([...rowCheckboxes,...filteredParentCheckboxes]);_PbAdvancedTable.selectedRows.clear();allCheckboxes.forEach((checkbox=>{const rowEl=checkbox.closest("tr");const isChecked=checkbox.checked;if(isChecked){_PbAdvancedTable.selectedRows.add(checkbox.id);if(rowEl){rowEl.classList.add("bg-row-selection");rowEl.classList.remove("pb-bg-row-white","bg-silver")}}else{if(rowEl){rowEl.classList.remove("bg-row-selection");if(this.isRowExpanded(rowEl)){rowEl.classList.remove("bg-silver");rowEl.classList.add("pb-bg-row-white")}else{rowEl.classList.remove("pb-bg-row-white");rowEl.classList.add("bg-silver")}}}}));this.updateTableSelectedRowsAttribute();updateSelectionActionBar(table.closest(".pb_advanced_table"),_PbAdvancedTable.selectedRows.size);if(selectAllCheckbox){selectAllCheckbox.checked=Array.from(rowCheckboxes).every((cb=>cb.checked))}}isRowExpanded(rowEl){const closeIcon=rowEl.querySelector(UP_ARROW_SELECTOR);return(closeIcon==null?void 0:closeIcon.style.display)==="none"||!closeIcon}handleCheckboxClick(event){const checkbox=event.currentTarget;const rowId=checkbox.id;const isChecked=checkbox.checked;const rowEl=checkbox.closest("tr");if(isChecked){_PbAdvancedTable.selectedRows.add(rowId);rowEl.classList.add("bg-row-selection");rowEl.classList.remove("pb-bg-row-white","bg-silver")}else{_PbAdvancedTable.selectedRows.delete(rowId)}if(!isChecked){rowEl.classList.remove("bg-row-selection");if(this.isRowExpanded(rowEl)){rowEl.classList.remove("bg-silver");rowEl.classList.add("pb-bg-row-white")}else{rowEl.classList.remove("pb-bg-row-white");rowEl.classList.add("bg-silver")}}this.updateTableSelectedRowsAttribute();const table=checkbox.closest("table");const selectAllCheckbox=table.querySelector("#select-all-rows");if(selectAllCheckbox){const allCheckboxes=table.querySelectorAll("label[data-row-id] input[type='checkbox']");const allChecked=Array.from(allCheckboxes).every((cb=>cb.checked));const selectAllInput=selectAllCheckbox.querySelector('input[type="checkbox"]');selectAllInput.checked=allChecked}updateSelectionActionBar(table.closest(".pb_advanced_table"),_PbAdvancedTable.selectedRows.size)}get target(){return this.childRowsFor(this.element.id)||[]}connect(){const table=this.element.closest("table");this.hideCloseIcon();const mainTable=this.element.closest(".pb_advanced_table");if(mainTable){updateSelectionActionBar(mainTable)}table.querySelectorAll("tr[data-row-parent]").forEach((row=>{const parentId=row.dataset.rowParent;if(!this.childRowsMap.has(parentId)){this.childRowsMap.set(parentId,[])}this.childRowsMap.get(parentId).push(row)}));if(table.dataset.pbAdvancedTableInitialized)return;table.dataset.pbAdvancedTableInitialized="true";table.addEventListener("change",(event=>{const checkbox=event.target.closest('input[type="checkbox"]');if(!checkbox)return;if(checkbox.closest("#select-all-rows")){const checkAll=checkbox.checked;const rowCheckboxes=table.querySelectorAll('label[data-row-id] input[type="checkbox"]');rowCheckboxes.forEach((cb=>{if(cb.checked!==checkAll){cb.checked=checkAll;this.handleCheckboxClick({currentTarget:cb})}}));setTimeout((()=>{this.recalculateSelectedCount()}),0);return}const rowLabel=checkbox.closest("label[data-row-id]");if(rowLabel){this.handleCheckboxClick({currentTarget:checkbox});setTimeout((()=>{this.recalculateSelectedCount()}),0)}}));table.addEventListener("checkbox-programmatic-change",(event=>{const checkbox=event.target;if(!checkbox||checkbox.type!=="checkbox")return;const rowLabel=checkbox.closest("label[data-row-id]");if(rowLabel){this.handleCheckboxClick({currentTarget:checkbox})}setTimeout((()=>{this.recalculateSelectedCount()}),10)}));table.addEventListener("change",(event=>{const checkbox=event.target;if(checkbox&&checkbox.type==="checkbox"){setTimeout((()=>{this.recalculateSelectedCount()}),50)}}));table.addEventListener("click",(event=>{const toggleBtn=event.target.closest("[data-advanced-table]");if(!toggleBtn||_PbAdvancedTable.isCollapsing)return;const prevElement=this.element;this.element=toggleBtn;const isExpanded=toggleBtn.querySelector(UP_ARROW_SELECTOR).style.display==="inline-block";if(!isExpanded){_PbAdvancedTable.expandedRows.add(toggleBtn.id)}else{_PbAdvancedTable.expandedRows.delete(toggleBtn.id)}const childRows=Array.from(table.querySelectorAll(`[data-row-parent="${toggleBtn.id}"]`));this.toggleElement(childRows);this.element=prevElement}));this.addBorderRadiusOnLastVisibleRow()}addBorderRadiusOnLastVisibleRow(){const parentElement=this.element.closest(".pb_advanced_table");const table=document.getElementById(parentElement.id);if(table){const visibleRows=table.querySelectorAll("tr.is-visible, tr:not(.toggle-content)");visibleRows.forEach((row=>{row.classList.remove("last-visible-row");row.classList.remove("last-row-cell")}));const lastVisibleRow=visibleRows[visibleRows.length-1];if(lastVisibleRow){lastVisibleRow.classList.add("last-visible-row");lastVisibleRow.classList.add("last-row-cell")}}}hideCloseIcon(){const closeIcon=this.element.querySelector(UP_ARROW_SELECTOR);closeIcon.style.display="none"}showElement(elements){elements.forEach((elem=>{elem.style.display="table-row";elem.classList.add("is-visible");const childRowsAll=this.element.closest("table").querySelectorAll(`[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`);childRowsAll.forEach((childRow=>{const dataContent=childRow.dataset.advancedTableContent;if(!dataContent){return}const ancestorIds=dataContent.split("-").slice(0,-1);const parentRowId=childRow.dataset.rowParent;const tableId=parentRowId?parentRowId.split("_").slice(0,-1).join("_"):"";const prefixedAncestorIds=ancestorIds.map((id=>`${tableId}_${id}`));const allAncestorsExpanded=prefixedAncestorIds.every((id=>_PbAdvancedTable.expandedRows.has(id)));const checkIfParentIsExpanded=()=>{if(dataContent.endsWith("sr")){const parentRowId2=childRow.dataset.rowParent;const isParentVisible=childRow.previousElementSibling.classList.contains("is-visible");if(parentRowId2){const isInSet=_PbAdvancedTable.expandedRows.has(parentRowId2);if(isInSet&&isParentVisible){return true}}}return false};if(allAncestorsExpanded||checkIfParentIsExpanded()){childRow.style.display="table-row";childRow.classList.add("is-visible")}else{childRow.style.display="none";childRow.classList.remove("is-visible")}}))}))}hideElement(elements){elements.forEach((elem=>{elem.style.display="none";elem.classList.remove("is-visible");if(_PbAdvancedTable.expandedRows.has(elem.id)){_PbAdvancedTable.expandedRows.delete(elem.id)}const childrenArray=elem.dataset.advancedTableContent.split("-");const currentDepth=parseInt(elem.dataset.rowDepth);if(childrenArray.length>currentDepth){const childRows=this.element.closest("table").querySelectorAll(`[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`);childRows.forEach((childRow=>{childRow.style.display="none";childRow.classList.remove("is-visible")}))}}))}toggleElement(elements){if(!elements.length)return;const isVisible=elements[0].classList.contains("is-visible");isVisible?this.hideElement(elements):this.showElement(elements);isVisible?this.displayDownArrow():this.displayUpArrow();const row=this.element.closest("tr");if(row){row.classList.toggle("bg-silver",!isVisible);row.classList.toggle("pb-bg-row-white",isVisible)}this.addBorderRadiusOnLastVisibleRow()}displayDownArrow(){this.element.querySelector(DOWN_ARROW_SELECTOR).style.display="inline-block";this.element.querySelector(UP_ARROW_SELECTOR).style.display="none"}displayUpArrow(){this.element.querySelector(UP_ARROW_SELECTOR).style.display="inline-block";this.element.querySelector(DOWN_ARROW_SELECTOR).style.display="none"}static handleToggleAllHeaders(element){const table=element.closest(".pb_table");const firstLevelButtons=table.querySelectorAll(".pb_advanced_table_body > .pb_table_tr[data-row-depth='0'] [data-advanced-table]");const allExpanded=Array.from(firstLevelButtons).every((button=>button.querySelector(UP_ARROW_SELECTOR).style.display==="inline-block"));if(allExpanded){firstLevelButtons.forEach((button=>{button.click();_PbAdvancedTable.expandedRows.delete(button.id)}))}else{firstLevelButtons.forEach((button=>{if(!_PbAdvancedTable.expandedRows.has(button.id)){button.click();_PbAdvancedTable.expandedRows.add(button.id)}}));_PbAdvancedTable.expandedRows.forEach((rowId=>{const nestedButton=table.querySelector(`[data-advanced-table][id="${rowId}"]`);if(nestedButton&&!firstLevelButtons.contains(nestedButton)){nestedButton.click()}}))}}static handleToggleAllSubRows(element,rowDepth){const table=element.closest(".pb_table");const parentRow=element.closest("tr");if(!parentRow){return}const rowParentId=parentRow.dataset.rowParent;const subRowButtons=table.querySelectorAll(`.pb_advanced_table_body > .pb_table_tr[data-row-depth='${rowDepth}'].pb_table_tr[data-row-parent='${rowParentId}'] [data-advanced-table]`);const allExpanded=Array.from(subRowButtons).every((button=>button.querySelector(UP_ARROW_SELECTOR).style.display==="inline-block"));if(allExpanded){subRowButtons.forEach((button=>{button.click();_PbAdvancedTable.expandedRows.delete(button.id)}))}else{subRowButtons.forEach((button=>{if(!_PbAdvancedTable.expandedRows.has(button.id)){button.click();_PbAdvancedTable.expandedRows.add(button.id)}}))}}};__publicField(_PbAdvancedTable,"expandedRows",new Set);__publicField(_PbAdvancedTable,"selectedRows",new Set);__publicField(_PbAdvancedTable,"isCollapsing",false);let PbAdvancedTable=_PbAdvancedTable;window.expandAllRows=element=>{PbAdvancedTable.handleToggleAllHeaders(element)};window.expandAllSubRows=(element,rowDepth)=>{PbAdvancedTable.handleToggleAllSubRows(element,rowDepth)};const FLAT_SELECTOR="[data-flat-advanced-table-select='true']";class PbFlatAdvancedTable extends PbEnhancedElement{static get selector(){return FLAT_SELECTOR}constructor(...args){super(...args);this.selectedRows=new Set}connect(){const table=this.element.closest("table");if(!table||table.dataset.flatAdvancedInit)return;table.dataset.flatAdvancedInit="true";const mainTable=this.element.closest(".pb_advanced_table");if(mainTable){updateSelectionActionBar(mainTable,0)}const updateCheckboxState=()=>{if(mainTable){mainTable.dataset.selectedRows=JSON.stringify(Array.from(this.selectedRows));updateSelectionActionBar(mainTable,this.selectedRows.size)}};const selectAllId=this.element.getAttribute("data-pb-checkbox-indeterminate-parent");const selectAllSelector=`#${selectAllId} input[type='checkbox']`;table.addEventListener("change",(e=>{const rowCb=e.target.closest(FLAT_SELECTOR+" input[type='checkbox']");const allCb=e.target.closest(selectAllSelector);if(!rowCb&&!allCb)return;if(rowCb){const id=rowCb.id;if(rowCb.checked)this.selectedRows.add(id);else this.selectedRows.delete(id);const tr=rowCb.closest("tr");tr==null?void 0:tr.classList.toggle("bg-row-selection",rowCb.checked);tr==null?void 0:tr.classList.toggle("pb-bg-row-white",!rowCb.checked)}if(allCb){const checked=allCb.checked;Array.from(table.querySelectorAll(FLAT_SELECTOR+" input[type='checkbox']")).forEach((cb=>{cb.checked=checked;const tr=cb.closest("tr");tr==null?void 0:tr.classList.toggle("bg-row-selection",checked);tr==null?void 0:tr.classList.toggle("pb-bg-row-white",!checked);const id=cb.id;if(checked)this.selectedRows.add(id);else this.selectedRows.delete(id)}))}updateCheckboxState()}))}}const NAV_SELECTOR="[data-pb-nav-tab]";const NAV_ITEM_SELECTOR="[data-pb-tab-target]";class PbNav extends PbEnhancedElement{static get selector(){return NAV_SELECTOR}connect(){this.hideAndAddEventListeners()}hideAndAddEventListeners(){const navItems=this.element.querySelectorAll(NAV_ITEM_SELECTOR);navItems.forEach((navItem=>{if(!navItem.className.includes("active")){this.changeContentDisplay(navItem.dataset.pbTabTarget,"none")}navItem.addEventListener("click",(event=>this.handleNavItemClick(event)))}))}handleNavItemClick(event){event.preventDefault();const navItem=event.target.closest(NAV_ITEM_SELECTOR);this.changeContentDisplay(navItem.dataset.pbTabTarget,"block");const navItems=this.element.querySelectorAll(NAV_ITEM_SELECTOR);navItems.forEach((navItemSelected=>{if(navItem!==navItemSelected){this.changeContentDisplay(navItemSelected.dataset.pbTabTarget,"none")}}))}changeContentDisplay(contentId,display){const content=document.getElementById(contentId);content.style.display=display}}const STAR_RATING_WRAPPER_SELECTOR="[data-pb-star-rating-wrapper]";const STAR_RATING_SELECTOR="[data-pb-star-rating]";const STAR_RATING_INPUT_DATA_SELECTOR="[data-pb-star-rating-input]";class PbStarRating extends PbEnhancedElement{static get selector(){return STAR_RATING_WRAPPER_SELECTOR}connect(){this.addEventListeners();this.handleFormReset();this.setDefaultValue()}addEventListeners(){this.element.querySelectorAll(STAR_RATING_SELECTOR).forEach((star=>{star.addEventListener("click",(event=>{const clickedStarId=event.currentTarget.id;this.updateStarColors(clickedStarId);this.updateHiddenInputValue(clickedStarId);this.clearFormValidation()}));star.addEventListener("mouseenter",(event=>{const hoveredStarId=event.currentTarget.id;this.updateStarHoverColors(hoveredStarId)}));star.addEventListener("mouseleave",(()=>{this.removeStarHoverColors()}));star.addEventListener("keydown",(event=>{if(event.key==="Enter"||event.key===" "){event.preventDefault();this.handleStarClick(star.id)}}))}))}handleStarClick(starId){this.updateStarColors(starId);this.updateHiddenInputValue(starId)}updateStarColors(clickedStarId){const allStars=this.element.querySelectorAll(STAR_RATING_SELECTOR);allStars.forEach((star=>{const starId=star.id;const icon=star.querySelector(".interactive-star-icon");if(icon){if(starId<=clickedStarId){if(star.classList.contains("yellow_star")){icon.classList.add("yellow-star-selected")}else if(star.classList.contains("primary_star_light")){icon.classList.add("primary-star-selected")}else if(star.classList.contains("primary_star_dark")){icon.classList.add("primary-star-selected")}else if(star.classList.contains("subtle_star_light")){icon.classList.add("subtle-star-selected")}else if(star.classList.contains("subtle_star_dark")){icon.classList.add("subtle-star-selected")}else{icon.classList.add("yellow-star-selected")}}else{icon.classList.remove("yellow-star-selected","primary-star-selected","subtle-star-selected")}icon.classList.remove("star-hovered")}}))}updateHiddenInputValue(value){const hiddenInput=this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR);if(hiddenInput){hiddenInput.value=value}}updateStarHoverColors(hoveredStarId){const allStars=this.element.querySelectorAll(STAR_RATING_SELECTOR);allStars.forEach((star=>{const starId=star.id;const icon=star.querySelector(".interactive-star-icon");if(icon){if(starId<=hoveredStarId){if(!icon.classList.contains("yellow-star-selected")&&!icon.classList.contains("primary-star-selected")&&!icon.classList.contains("subtle-star-selected")){icon.classList.add("star-hovered")}}else{icon.classList.remove("star-hovered")}}}))}removeStarHoverColors(){const allStars=this.element.querySelectorAll(STAR_RATING_SELECTOR);allStars.forEach((star=>{const icon=star.querySelector(".interactive-star-icon");if(icon){if(!icon.classList.contains("yellow-star-selected")&&!icon.classList.contains("primary-star-selected")&&!icon.classList.contains("subtle-star-selected")){icon.classList.remove("star-hovered")}}}))}isStarSelected(){return this.element.querySelectorAll(".yellow-star-selected, .primary-star-selected, .subtle-star-selected").length>0}handleFormReset(){const form=this.element.closest("form");if(form){form.addEventListener("reset",(()=>{var _a;(_a=this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR))==null?void 0:_a.setAttribute("value","");this.resetStarRatingValues()}))}}resetStarRatingValues(){const allStars=this.element.querySelectorAll(STAR_RATING_SELECTOR);allStars.forEach((star=>{const icon=star.querySelector(".interactive-star-icon");if(icon){icon.classList.remove("yellow-star-selected","primary-star-selected","subtle-star-selected")}}))}clearFormValidation(){const hiddenInput=this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR);if(hiddenInput.checkValidity()){const errorLabelElement=this.element.querySelector(".pb_body_kit_negative");if(errorLabelElement){errorLabelElement.remove()}}}setDefaultValue(){const hiddenInput=this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR);const defaultValue=hiddenInput.value;if(defaultValue){this.updateStarColors(defaultValue)}}}const RADIO_SELECTOR="[data-pb-radio-children]";const RADIO_WRAPPER_SELECTOR="[data-pb-radio-children-wrapper]";class PbRadio extends PbEnhancedElement{static get selector(){return RADIO_SELECTOR}connect(){const radioWrapperElement=this.element.parentElement.querySelector(RADIO_WRAPPER_SELECTOR);radioWrapperElement.addEventListener("click",(()=>{this.element.querySelector("input[type='radio']").click()}))}}const DRAGGABLE_SELECTOR="[data-pb-draggable]";const DRAGGABLE_CONTAINER=".pb_draggable_container";const NEEDS_CLONE=["shadow","outline","line"];class PbDraggable extends PbEnhancedElement{static get selector(){return DRAGGABLE_SELECTOR}connect(){this.state={items:[],dragData:{id:"",initialGroup:""},isDragging:"",activeContainer:""};this.draggedItem=null;this.draggedItemId=null;this.dragGhost=null;this.hasMultipleContainers=false;this.dragZoneType="";this.dragZoneColor="";document.addEventListener("DOMContentLoaded",(()=>this.bindEventListeners()))}setState(newState){this.state={...this.state,...newState};if(newState.items){this.element.dispatchEvent(new CustomEvent("pb-draggable-reorder",{detail:{reorderedItems:this.state.items,containerId:this.element.querySelector(DRAGGABLE_CONTAINER).id}}))}}bindEventListeners(){const containers=this.element.querySelectorAll(DRAGGABLE_CONTAINER);this.hasMultipleContainers=containers.length>1;this.element.querySelectorAll(".pb_draggable_item img").forEach((img=>img.setAttribute("draggable","false")));this.element.querySelectorAll(".pb_draggable_item").forEach((item=>{item.addEventListener("dragstart",this.handleDragStart.bind(this));item.addEventListener("dragend",this.handleDragEnd.bind(this));item.addEventListener("dragenter",this.handleDragEnter.bind(this))}));containers.forEach((c=>{c.addEventListener("dragover",this.handleDragOver.bind(this));c.addEventListener("drop",this.handleDrop.bind(this))}))}handleDragStart(event){if(event.target.tagName.toLowerCase()==="img"){event.preventDefault();return}const container=event.target.closest(DRAGGABLE_CONTAINER);this.draggedItem=event.target;this.draggedItemId=event.target.id;this.dragZoneType=this.element.dataset.dropZoneType||"";this.dragZoneColor=this.element.dataset.dropZoneColor||"";this.setState({dragData:{id:this.draggedItemId,initialGroup:container.id},isDragging:this.draggedItemId});this.draggedItem.classList.add("is_dragging",`drop_zone_${this.dragZoneType}`,`drop_zone_color_${this.dragZoneColor}`);if(event.dataTransfer){event.dataTransfer.effectAllowed="move";event.dataTransfer.setData("text/plain",this.draggedItemId);if(NEEDS_CLONE.includes(this.dragZoneType)){const ghost=this.draggedItem.cloneNode(true);ghost.classList.remove("is_dragging",`drop_zone_${this.dragZoneType}`,`drop_zone_color_${this.dragZoneColor}`);const{width:width,height:height}=this.draggedItem.getBoundingClientRect();Object.assign(ghost.style,{border:"none",width:`${width}px`,height:`${height}px`,position:"absolute",top:"-9999px",left:"-9999px",boxSizing:"border-box",zIndex:"9999"});document.body.appendChild(ghost);this.dragGhost=ghost;event.dataTransfer.setDragImage(ghost,width/2,height/2)}}if(this.dragZoneType!=="line"){requestAnimationFrame((()=>event.target.style.opacity="0.5"))}}handleDragEnter(event){if(!this.draggedItem||event.target===this.draggedItem)return;this.hasMultipleContainers?this.handleMultiContainerDragEnter(event):this.handleSingleContainerDragEnter(event)}handleSingleContainerDragEnter(event){const targetItem=event.target.closest(".pb_draggable_item");if(!targetItem)return;const container=targetItem.parentNode;const items=Array.from(container.children);const fromIdx=items.indexOf(this.draggedItem);const toIdx=items.indexOf(targetItem);if(fromIdx>toIdx){container.insertBefore(this.draggedItem,targetItem)}else{container.insertBefore(this.draggedItem,targetItem.nextSibling)}}handleMultiContainerDragEnter(event){const targetContainer=event.target.closest(DRAGGABLE_CONTAINER);const targetItem=event.target.closest(".pb_draggable_item");if(!targetContainer)return;if(!targetItem){const last=targetContainer.querySelector(".pb_draggable_item:last-child");last?targetContainer.insertBefore(this.draggedItem,last.nextSibling):targetContainer.appendChild(this.draggedItem);return}const items=Array.from(targetContainer.children);this.setState({items:items.map((i=>({id:i.id,container:targetContainer.id})))});const midY=targetItem.getBoundingClientRect().top+targetItem.getBoundingClientRect().height/2;if(event.clientY<midY){targetContainer.insertBefore(this.draggedItem,targetItem)}else{targetContainer.insertBefore(this.draggedItem,targetItem.nextSibling)}}handleDragOver(event){event.preventDefault();event.stopPropagation();this.hasMultipleContainers?this.handleMultiContainerDragOver(event):this.handleSingleContainerDragOver(event)}handleSingleContainerDragOver(event){const container=event.target.closest(DRAGGABLE_CONTAINER);if(container)container.classList.add("active_container")}handleMultiContainerDragOver(event){const container=event.target.matches(DRAGGABLE_CONTAINER)?event.target:event.target.closest(DRAGGABLE_CONTAINER);if(!container)return;this.setState({activeContainer:container.id});container.classList.add("active_container");const last=container.querySelector(".pb_draggable_item:last-child");if(!last||event.clientY>last.getBoundingClientRect().bottom){if(this.draggedItem&&this.draggedItem.parentNode!==container){container.appendChild(this.draggedItem)}}}handleDrop(event){event.preventDefault();event.stopPropagation();const container=event.target.matches(DRAGGABLE_CONTAINER)?event.target:event.target.closest(DRAGGABLE_CONTAINER);if(!container||!this.draggedItem)return;container.classList.remove("active_container");this.draggedItem.style.opacity="1";if(this.hasMultipleContainers&&!container.querySelector(".pb_draggable_item")){container.appendChild(this.draggedItem)}const reorderedItems=Array.from(this.element.querySelectorAll(".pb_draggable_item")).map((i=>({id:i.id,container:i.closest(DRAGGABLE_CONTAINER).id})));container.dataset.reorderedItems=JSON.stringify(reorderedItems);this.element.dispatchEvent(new CustomEvent("pb-draggable-reorder",{detail:{reorderedItems:reorderedItems,containerId:container.id}}));this.setState({items:reorderedItems,isDragging:"",activeContainer:""});this.draggedItem=null;this.draggedItemId=null}handleDragEnd(event){event.target.classList.remove("is_dragging",`drop_zone_${this.dragZoneType}`,`drop_zone_color_${this.dragZoneColor}`);event.target.style.opacity="1";if(this.dragGhost){document.body.removeChild(this.dragGhost);this.dragGhost=null}this.setState({isDragging:"",activeContainer:""});this.element.querySelectorAll(DRAGGABLE_CONTAINER).forEach((c=>c.classList.remove("active_container")));this.draggedItem=null;this.draggedItemId=null}}const OVERLAY_SELECTOR="[data-pb-overlay]";const OVERLAY_SCROLL_ELEMENT="[data-overlay-scroll-element]";const PREVIOUS_OVERLAY_CLASSNAME="[data-previous-overlay-classname]";const SUBSEQUENT_OVERLAY_CLASSNAME="[data-subsequent-overlay-classname]";class PbOverlay extends PbEnhancedElement{static get selector(){return OVERLAY_SELECTOR}get target(){return this.element.querySelector(OVERLAY_SCROLL_ELEMENT).children[0]}connect(){this.handleOverlayDynamic()}handleOverlayDynamic(){var _a,_b,_c;const isOverlayDynamic=(_a=this.element.dataset)==null?void 0:_a.overlayDynamic;if(isOverlayDynamic){const previousOverlayElement=this.element.querySelector(PREVIOUS_OVERLAY_CLASSNAME);const previousOverlayClassname=(_b=previousOverlayElement==null?void 0:previousOverlayElement.dataset)==null?void 0:_b.previousOverlayClassname;const subsequentOverlayElement=this.element.querySelector(SUBSEQUENT_OVERLAY_CLASSNAME);const subsequentOverlayClassname=(_c=subsequentOverlayElement==null?void 0:subsequentOverlayElement.dataset)==null?void 0:_c.subsequentOverlayClassname;const handleScrollChange=target=>{const{scrollLeft:scrollLeft,scrollWidth:scrollWidth,clientWidth:clientWidth}=target;const isScrollAtStart=scrollLeft===0;const isScrollAtEnd=scrollLeft+clientWidth>=scrollWidth-1;if(isScrollAtStart){previousOverlayElement.classList.remove(previousOverlayClassname)}else{previousOverlayElement.classList.add(previousOverlayClassname)}if(isScrollAtEnd){subsequentOverlayElement.classList.remove(subsequentOverlayClassname)}else{subsequentOverlayElement.classList.add(subsequentOverlayClassname)}};this.target.addEventListener("scroll",(event=>{handleScrollChange(event.target)}));handleScrollChange(this.target)}}disconnect(){var _a;if((_a=this.element.dataset)==null?void 0:_a.overlayDynamic){this.target.removeEventListener("scroll")}}}const SELECT_WRAPPER_SELECTOR="[data-pb-select]";const SELECT_VALIDATION_MESSAGE_CLASS$1=".pb_body_kit_negative";class PbSelect extends PbEnhancedElement{static get selector(){return SELECT_WRAPPER_SELECTOR}connect(){this.setValidationMessage()}setValidationMessage(){var _a;const validationMessage=(_a=this.element.dataset)==null?void 0:_a.validationMessage;if(validationMessage){const selectElement=this.element.querySelector("select");const setErrorTextContent=(text,timeout)=>{setTimeout((()=>{const errorMessageElement=this.element.querySelector(SELECT_VALIDATION_MESSAGE_CLASS$1);if(errorMessageElement){errorMessageElement.textContent=text}else{setErrorTextContent(text,100)}}),timeout)};selectElement.addEventListener("change",(e=>{if(!e.target.checkValidity()){setErrorTextContent(validationMessage,300)}}))}}}const DIALOG_WRAPPER_SELECTOR="[data-pb-dialog-wrapper]";class PbDialog extends PbEnhancedElement{constructor(){super(...arguments);__publicField(this,"handleCustomEvent",(event=>{var _a,_b,_c,_d,_e,_f;const dialogId=((_a=event.detail)==null?void 0:_a.dialogId)||((_b=this.element.querySelector("dialog"))==null?void 0:_b.id);const dialog=dialogId&&document.getElementById(dialogId);if(!dialog){console.warn(`[PbDialog] Could not find dialog with ID '${dialogId}'`);return}this.setupDialog();const action=((_c=event.detail)==null?void 0:_c.action)||"open";const knownActions=["open","close","clickConfirm","clickCancel"];if(knownActions.includes(action)){switch(action){case"open":if(!dialog.open)dialog.showModal();break;case"close":if(dialog.open)dialog.close((_d=event.detail)==null?void 0:_d.returnValue);break;case"clickConfirm":this.triggerButtonClick(dialog,event,"confirm");break;case"clickCancel":this.triggerButtonClick(dialog,event,"cancel");break}}else if(typeof((_e=event.detail)==null?void 0:_e.customAction)==="function"){event.detail.customAction({dialog:dialog,event:event})}else if((_f=window.pbDialogActions)==null?void 0:_f[action]){window.pbDialogActions[action]({dialog:dialog,event:event})}else{console.warn(`[PbDialog] Unknown action: ${action}`)}}))}static get selector(){return DIALOG_WRAPPER_SELECTOR}connect(){var _a;this.dialogElement=this.element.querySelector(".pb_dialog_rails");this.dialogId=(_a=this.dialogElement)==null?void 0:_a.id;this.managedTriggers=new Set;this.domContentLoadedHandler=()=>this.setupDialog();this.turboFrameLoadHandler=()=>this.setupDialog();window.addEventListener("DOMContentLoaded",this.domContentLoadedHandler);window.addEventListener("turbo:frame-load",this.turboFrameLoadHandler);const customEventTypeString=this.element.dataset.customEventType;if(customEventTypeString&&!this.element.hasAttribute("data-custom-event-handled")){this.customEventTypes=customEventTypeString.split(",").map((e=>e.trim())).filter(Boolean);this.customEventTypes.forEach((eventType=>{window.addEventListener(eventType,this.handleCustomEvent)}));this.element.setAttribute("data-custom-event-handled","true")}}disconnect(){if(this.domContentLoadedHandler){window.removeEventListener("DOMContentLoaded",this.domContentLoadedHandler)}if(this.turboFrameLoadHandler){window.removeEventListener("turbo:frame-load",this.turboFrameLoadHandler)}if(this.customEventTypes&&Array.isArray(this.customEventTypes)){this.customEventTypes.forEach((eventType=>{window.removeEventListener(eventType,this.handleCustomEvent)}))}this.managedTriggers.forEach((trigger=>{if(trigger._openDialogClickHandler){trigger.removeEventListener("click",trigger._openDialogClickHandler);delete trigger._openDialogClickHandler}if(trigger._closeDialogClickHandler){trigger.removeEventListener("click",trigger._closeDialogClickHandler);delete trigger._closeDialogClickHandler}}));if(this.dialogElement&&this.dialogElement._outsideClickHandler){this.dialogElement.removeEventListener("mousedown",this.dialogElement._outsideClickHandler);delete this.dialogElement._outsideClickHandler}}triggerButtonClick(dialog,event,type){var _a,_b;const buttonId=((_a=event.detail)==null?void 0:_a[`${type}ButtonId`])||((_b=dialog.closest("[data-pb-dialog-wrapper]"))==null?void 0:_b.dataset[`${type}ButtonId`]);const button=buttonId?document.getElementById(buttonId):dialog.querySelector(`[data-${type}-button]`);if(button){button.click()}else{console.warn(`[PbDialog] Could not find ${type} button for dialog`)}}setupDialog(){if(!this.dialogId)return;const openTrigger=document.querySelectorAll(`[data-open-dialog="${this.dialogId}"]`);const closeTrigger=document.querySelectorAll(`[data-close-dialog="${this.dialogId}"]`);const dialogs=this.dialogElement?[this.dialogElement]:[];const loadingButton=document.querySelector('[data-disable-with="Loading"]');if(loadingButton&&!loadingButton.dataset.listenerAttached){loadingButton.addEventListener("click",(function(){const okayLoadingButton=document.querySelector('[data-disable-with="Loading"]');const cancelButton=document.querySelector('[data-disable-cancel-with="Loading"]');let currentClass=okayLoadingButton.className;let cancelClass=cancelButton?cancelButton.className:"";let newClass=currentClass.replace("_enabled","_disabled_loading");let newCancelClass=cancelClass.replace("_enabled","_disabled");okayLoadingButton.disabled=true;if(cancelButton)cancelButton.disabled=true;okayLoadingButton.className=newClass;if(cancelButton)cancelButton.className=newCancelClass}));loadingButton.dataset.listenerAttached="true"}openTrigger.forEach((open=>{const originalClickHandler=open._openDialogClickHandler;if(originalClickHandler)open.removeEventListener("click",originalClickHandler);open._openDialogClickHandler=()=>{const openTriggerData=open.dataset.openDialog;const targetDialogOpen=document.getElementById(openTriggerData);if(targetDialogOpen&&!targetDialogOpen.open)targetDialogOpen.showModal()};open.addEventListener("click",open._openDialogClickHandler);this.managedTriggers.add(open)}));closeTrigger.forEach((close=>{const originalClickHandler=close._closeDialogClickHandler;if(originalClickHandler)close.removeEventListener("click",originalClickHandler);close._closeDialogClickHandler=()=>{const closeTriggerData=close.dataset.closeDialog;const targetDialogClose=document.getElementById(closeTriggerData);if(targetDialogClose)targetDialogClose.close()};close.addEventListener("click",close._closeDialogClickHandler);this.managedTriggers.add(close)}));dialogs.forEach((dialogElement=>{const originalMousedownHandler=dialogElement._outsideClickHandler;if(originalMousedownHandler)dialogElement.removeEventListener("mousedown",originalMousedownHandler);dialogElement._outsideClickHandler=event=>{const dialogParentDataset=dialogElement.parentElement.dataset;if(dialogParentDataset.overlayClick==="overlay_close")return;const dialogModal=event.target.getBoundingClientRect();const clickedOutsideDialogModal=event.clientX<dialogModal.left||event.clientX>dialogModal.right||event.clientY<dialogModal.top||event.clientY>dialogModal.bottom;if(clickedOutsideDialogModal){dialogElement.close();event.stopPropagation()}};dialogElement.addEventListener("mousedown",dialogElement._outsideClickHandler)}))}}const DATE_PICKER_WRAPPER_SELECTOR="[data-pb-date-picker]";const SELECT_VALIDATION_MESSAGE_CLASS=".pb_body_kit_negative";class PbDatePicker extends PbEnhancedElement{static get selector(){return DATE_PICKER_WRAPPER_SELECTOR}connect(){this.setValidationMessage()}setValidationMessage(){var _a;const validationMessage=(_a=this.element.dataset)==null?void 0:_a.validationMessage;const inputElement=this.element.querySelector("input");if(validationMessage){const setErrorTextContent=(text,timeout)=>{setTimeout((()=>{const errorMessageElement=this.element.querySelector(SELECT_VALIDATION_MESSAGE_CLASS);if(errorMessageElement){errorMessageElement.textContent=text}else{setErrorTextContent(text,100)}}),timeout)};inputElement.addEventListener("change",(e=>{if(!e.target.checkValidity()){setErrorTextContent(validationMessage,300)}}))}}}const MULTI_LEVEL_SELECT_SELECTOR="[data-multi_level_select_form]";class PbMultiLevelSelect extends PbEnhancedElement{static get selector(){return MULTI_LEVEL_SELECT_SELECTOR}get target(){return this.element.querySelector(".pb_body_kit_negative")}connect(){this.addEventListeners();this.observeHiddenInputs();this.observeRogueErrorInsideInnerContainer()}addEventListeners(){const inputElement=this.element.querySelector("input");inputElement.addEventListener("invalid",(()=>{this.handleErrorLabel(300)}));inputElement.addEventListener("blur",(()=>{this.justBlurred=true;setTimeout((()=>{this.justBlurred=false}),300)}))}handleErrorLabel(delay){setTimeout((()=>{const errorLabelElement=this.target;const wrapper=this.element.querySelector(".wrapper");if(errorLabelElement){errorLabelElement.remove();if(wrapper){if(wrapper.querySelector(".pb_body_kit_negative")){wrapper.querySelector(".pb_body_kit_negative").remove()}wrapper.appendChild(errorLabelElement)}this.element.classList.add("error")}else{this.handleErrorLabel(100)}}),delay)}observeHiddenInputs(){const container=this.element.querySelector(".input_inner_container");if(!container)return;this.mutationObserver=new MutationObserver((()=>{const hiddenInputs=container.querySelectorAll('input[type="hidden"]');if(hiddenInputs.length>0){this.clearError()}}));this.mutationObserver.observe(container,{childList:true})}observeRogueErrorInsideInnerContainer(){const container=this.element.querySelector(".input_inner_container");this.rogueErrorObserver=new MutationObserver((mutations=>{for(const mutation of mutations){for(const node of mutation.addedNodes){if(node.nodeType===Node.ELEMENT_NODE&&node.classList.contains("pb_body_kit_negative")){if(this.justBlurred){node.remove()}}}}}));this.rogueErrorObserver.observe(container,{childList:true,subtree:true})}clearError(e){const errorLabelElement=this.target;if(errorLabelElement){errorLabelElement.remove();this.element.classList.remove("error");this.element.querySelector("input").value=e.detail.value}}}const INDETERMINATE_MAIN_CHECKBOX_SELECTOR="[data-pb-checkbox-indeterminate-main='true']";class PbCheckbox extends PbEnhancedElement{static get selector(){return INDETERMINATE_MAIN_CHECKBOX_SELECTOR}connect(){const mainCheckboxWrapper=this.element;const mainCheckbox=mainCheckboxWrapper.querySelector("input");const directChildCheckboxes=document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);const getAllDescendantCheckboxes=()=>{const descendants=[];const queue=[...directChildCheckboxes];while(queue.length>0){const checkbox=queue.shift();descendants.push(checkbox);const checkboxWrapper=checkbox.closest('[data-pb-checkbox-indeterminate-main="true"]');if(checkboxWrapper){const childCheckboxes=document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${checkboxWrapper.id}"] input[type="checkbox"]`);queue.push(...childCheckboxes)}}const nonMainChildCheckboxes=document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);nonMainChildCheckboxes.forEach((cb=>{if(!descendants.includes(cb)){descendants.push(cb)}}));return descendants};const getCheckboxState=checkboxes=>{const checkedCount=checkboxes.filter((cb=>cb.checked)).length;const totalCount=checkboxes.length;return{allChecked:checkedCount===totalCount,noneChecked:checkedCount===0,indeterminate:!(checkedCount===totalCount||checkedCount===0),checkedCount:checkedCount,totalCount:totalCount}};const updateCheckboxVisualState=(checkbox,isIndeterminate,isChecked)=>{checkbox.indeterminate=isIndeterminate;checkbox.checked=isChecked};const updateCheckboxLabelAndIcons=(wrapper,isIndeterminate,checkedCount)=>{const checkAllLabel=wrapper.dataset.pbCheckboxIndeterminateMainLabelCheck??"Check All";const uncheckAllLabel=wrapper.dataset.pbCheckboxIndeterminateMainLabelUncheck??"Uncheck All";const text=checkedCount===0?checkAllLabel:uncheckAllLabel;const bodyKitElement=wrapper.getElementsByClassName("pb_body_kit")[0];if(bodyKitElement){bodyKitElement.textContent=text}const iconSpan=wrapper.querySelector("[data-pb-checkbox-icon-span]");if(iconSpan){const iconClassToAdd=isIndeterminate?"pb_checkbox_indeterminate":"pb_checkbox_checkmark";const iconClassToRemove=isIndeterminate?"pb_checkbox_checkmark":"pb_checkbox_indeterminate";iconSpan.classList.add(iconClassToAdd);iconSpan.classList.remove(iconClassToRemove)}const indeterminateIcon=wrapper.getElementsByClassName("indeterminate_icon")[0];const checkIcon=wrapper.getElementsByClassName("check_icon")[0];if(indeterminateIcon){indeterminateIcon.classList.toggle("hidden",!isIndeterminate)}if(checkIcon){checkIcon.classList.toggle("hidden",isIndeterminate)}};const updateMainCheckbox=()=>{const allDescendantCheckboxes2=getAllDescendantCheckboxes();const state=getCheckboxState(allDescendantCheckboxes2);updateCheckboxVisualState(mainCheckbox,state.indeterminate,state.allChecked);updateCheckboxLabelAndIcons(mainCheckboxWrapper,state.indeterminate,state.checkedCount)};const updateParentCheckboxes=()=>{const parentId=mainCheckboxWrapper.dataset.pbCheckboxIndeterminateParent;if(parentId){const parentCheckbox=document.getElementById(parentId);if(parentCheckbox){const parentWrapper=parentCheckbox.closest('[data-pb-checkbox-indeterminate-main="true"]');if(parentWrapper){const parentInstance=parentWrapper.pbCheckboxInstance;if(parentInstance&&parentInstance.updateMainCheckbox){parentInstance.updateMainCheckbox();parentInstance.updateParentCheckboxes()}}}}};const setupNonMainCheckboxUpdates=()=>{const allCheckboxesWithChildren=document.querySelectorAll('input[type="checkbox"]');allCheckboxesWithChildren.forEach((cb=>{const checkboxWrapper=cb.closest('[data-pb-checkbox-indeterminate-main="true"]');if(checkboxWrapper&&checkboxWrapper!==mainCheckboxWrapper){return}const childCheckboxes=document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${cb.id}"] input[type="checkbox"]`);if(childCheckboxes.length>0){childCheckboxes.forEach((childCb=>{childCb.addEventListener("change",(()=>{const state=getCheckboxState(Array.from(childCheckboxes));updateCheckboxVisualState(cb,state.indeterminate,state.allChecked);const mainCheckboxes=document.querySelectorAll('[data-pb-checkbox-indeterminate-main="true"]');mainCheckboxes.forEach((mainCb=>{const mainInstance=mainCb.pbCheckboxInstance;if(mainInstance&&mainInstance.updateMainCheckbox){setTimeout((()=>{mainInstance.updateMainCheckbox()}),0)}}))}))}))}}))};updateMainCheckbox();mainCheckbox.addEventListener("change",(function(){const allDescendantCheckboxes2=getAllDescendantCheckboxes();const state=getCheckboxState(allDescendantCheckboxes2);if(state.indeterminate){allDescendantCheckboxes2.forEach((cb=>{cb.checked=false;cb.dispatchEvent(new Event("checkbox-programmatic-change",{bubbles:true}))}));this.checked=false}else{allDescendantCheckboxes2.forEach((cb=>{cb.checked=this.checked;cb.dispatchEvent(new Event("checkbox-programmatic-change",{bubbles:true}))}))}updateMainCheckbox();setTimeout((()=>{updateParentCheckboxes()}),0);triggerAllMainCheckboxUpdates()}));directChildCheckboxes.forEach((cb=>{cb.addEventListener("change",updateMainCheckbox)}));const allDescendantCheckboxes=getAllDescendantCheckboxes();allDescendantCheckboxes.forEach((cb=>{if(!Array.from(directChildCheckboxes).includes(cb)){cb.addEventListener("change",updateMainCheckbox)}}));const allChildCheckboxes=document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);allChildCheckboxes.forEach((cb=>{if(!allDescendantCheckboxes.includes(cb)){cb.addEventListener("change",updateMainCheckbox)}}));let updateTimeout=null;const triggerAllMainCheckboxUpdates=()=>{if(updateTimeout){clearTimeout(updateTimeout)}updateTimeout=setTimeout((()=>{const mainCheckboxes=document.querySelectorAll('[data-pb-checkbox-indeterminate-main="true"]');mainCheckboxes.forEach((mainCb=>{const mainInstance=mainCb.pbCheckboxInstance;if(mainInstance&&mainInstance.updateMainCheckbox){mainInstance.updateMainCheckbox()}}))}),10)};const originalUpdateMainCheckbox=updateMainCheckbox;const enhancedUpdateMainCheckbox=()=>{originalUpdateMainCheckbox();triggerAllMainCheckboxUpdates()};mainCheckboxWrapper.pbCheckboxInstance={updateMainCheckbox:enhancedUpdateMainCheckbox,updateParentCheckboxes:updateParentCheckboxes};setupNonMainCheckboxUpdates()}}const BUTTON_SELECTOR="[data-pb-button-managed]";class PbButton extends PbEnhancedElement{static get selector(){return BUTTON_SELECTOR}connect(){this._attrManaged=this._attributesPresent();this.element._pbButton=this;this._onClick=e=>{if(this.isDisabled()){e.preventDefault();e.stopImmediatePropagation()}};this.element.addEventListener("click",this._onClick,true);if(this._attrManaged)this._syncClassesFromAttributes();this._observer=new MutationObserver((()=>{this._attrManaged=true;this._syncClassesFromAttributes()}));this._observer.observe(this.element,{attributes:true,attributeFilter:["disabled","aria-disabled"]})}disconnect(){var _a;this.element.removeEventListener("click",this._onClick,true);(_a=this._observer)==null?void 0:_a.disconnect();delete this.element._pbButton}disable(){this.setDisabled(true)}enable(){this.setDisabled(false)}setDisabled(state){if(this._isButton()){state?this.element.setAttribute("disabled","disabled"):this.element.removeAttribute("disabled")}else{state?this.element.setAttribute("aria-disabled","true"):this.element.removeAttribute("aria-disabled")}this._attrManaged=true;this._applyClassState(state)}isDisabled(){if(this._isButton()){if(this.element.hasAttribute("disabled"))return true;if(this._attrManaged&&!this.element.hasAttribute("disabled"))return false}else{const aria=this.element.getAttribute("aria-disabled");if(aria==="true")return true;if(this._attrManaged&&aria!=="true")return false}return this.element.classList.contains("pb_button_disabled")}_isButton(){return this.element.tagName==="BUTTON"}_attributesPresent(){return this.element.hasAttribute("disabled")||this.element.hasAttribute("aria-disabled")}_syncClassesFromAttributes(){const state=this._attrDisabledState();const disabled=state===null?false:state;this._applyClassState(disabled)}_attrDisabledState(){if(this._isButton()){return this.element.hasAttribute("disabled")?true:null}else{const aria=this.element.getAttribute("aria-disabled");if(aria==="true")return true;if(aria==="false")return false;return this.element.hasAttribute("aria-disabled")?false:null}}_applyClassState(disabled){this.element.classList.toggle("pb_button_disabled",!!disabled);this.element.classList.toggle("pb_button_enabled",!disabled)}}const TIME_PICKER_SELECTOR="[data-pb-time-picker]";const VALIDATION_MESSAGE_CLASS=".pb_body_kit_negative";class PbTimePicker extends PbEnhancedElement{static get selector(){return TIME_PICKER_SELECTOR}connect(){this.setValidationMessage()}setValidationMessage(){var _a;const element=this.element;const validationMessage=(_a=element.dataset)==null?void 0:_a.validationMessage;const inputElement=element.querySelector("input");if(validationMessage){const setErrorTextContent=(text,timeout)=>{setTimeout((()=>{const errorMessageElement=element.querySelector(VALIDATION_MESSAGE_CLASS);if(errorMessageElement){errorMessageElement.textContent=text}else{setErrorTextContent(text,100)}}),timeout)};inputElement==null?void 0:inputElement.addEventListener("change",(e=>{const target=e.target;if(!target.checkValidity()){setErrorTextContent(validationMessage,300)}}))}}}const KIT_SELECTOR='[class^="pb_"][class*="_kit"]';const ERROR_MESSAGE_SELECTOR=".pb_body_kit_negative";const FORM_SELECTOR='form[data-pb-form-validation="true"]';const REQUIRED_FIELDS_SELECTOR="input[required],textarea[required],select[required]";const PHONE_NUMBER_VALIDATION_ERROR_SELECTOR='[data-pb-phone-validation-error="true"]';const FIELD_EVENTS=["change","valid","invalid"];class PbFormValidation extends PbEnhancedElement{static get selector(){return FORM_SELECTOR}connect(){this.formValidationFields.forEach((field=>{const isPhoneNumberInput=field.closest(".pb_phone_number_input");if(isPhoneNumberInput)return;const isTimePickerInput=field.closest(".pb_time_picker");if(isTimePickerInput)return;FIELD_EVENTS.forEach((e=>{field.addEventListener(e,debounce((event=>{this.validateFormField(event)}),250),false)}))}));this.element.addEventListener("submit",(event=>{setTimeout((()=>{if(this.hasPhoneNumberValidationErrors()){event.preventDefault();return false}}),0)}))}validateFormField(event){event.preventDefault();const{target:target}=event;target.setCustomValidity("");const isValid=event.target.validity.valid;if(isValid){this.clearError(target)}else{this.showValidationMessage(target)}}showValidationMessage(target){const{parentElement:parentElement}=target;const kitElement=parentElement.closest(KIT_SELECTOR);if(!kitElement)return;const isPhoneNumberInput=kitElement.classList.contains("pb_phone_number_input");const isTimePickerInput=kitElement.classList.contains("pb_time_picker");this.clearError(target);kitElement.classList.add("error");if(!isPhoneNumberInput&&!isTimePickerInput){const errorMessageContainer=this.errorMessageContainer;if(target.dataset.message)target.setCustomValidity(target.dataset.message);errorMessageContainer.innerHTML=target.validationMessage;parentElement.appendChild(errorMessageContainer)}}clearError(target){const{parentElement:parentElement}=target;const kitElement=parentElement.closest(KIT_SELECTOR);if(kitElement)kitElement.classList.remove("error");const errorMessageContainer=parentElement.querySelector(ERROR_MESSAGE_SELECTOR);if(errorMessageContainer)errorMessageContainer.remove()}hasPhoneNumberValidationErrors(){const phoneNumberErrors=this.element.querySelectorAll(PHONE_NUMBER_VALIDATION_ERROR_SELECTOR);return phoneNumberErrors.length>0}get errorMessageContainer(){const errorContainer=document.createElement("div");const kitClassName=ERROR_MESSAGE_SELECTOR.replace(/\./,"");errorContainer.classList.add(kitClassName);return errorContainer}get formValidationFields(){return this._formValidationFields=this._formValidationFields||this.element.querySelectorAll(REQUIRED_FIELDS_SELECTOR)}}window.PbFormValidation=PbFormValidation;const kits=[PbTextInput,PbCopyButton,PbCollapsible,PbPopover,PbTooltip,PbFixedConfirmationToast,PbTypeahead,PbTable,PbTextarea,PbDropdown,PbAdvancedTable,PbFlatAdvancedTable,PbNav,PbStarRating,PbRadio,PbDraggable,PbOverlay,PbSelect,PbDialog,PbDatePicker,PbMultiLevelSelect,PbCheckbox,PbButton,PbTimePicker];kits.forEach((kit=>PbKitRegistry$1.register(kit)));PbKitRegistry$1.start();addCopyEventListeners();window.formHelper=formHelper;window.datePickerHelper=datePickerHelper;
1
+ var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:true,configurable:true,writable:true,value:value}):obj[key]=value;var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!=="symbol"?key+"":key,value);import{P as PbEnhancedElement,s as stripEmojisForPaste,a as applyEmojiMask,d as debounce,b as PbPopover,e as PbTooltip,h as PbTypeahead,i as PbTable,j as PbTextarea,k as formHelper,l as datePickerHelper}from"./chunks/lib-DspaUdlc.js";import{I as INPUTMASKS}from"./chunks/_typeahead-DdGKR1rQ.js";import"./chunks/lazysizes-B7xYodB-.js";import"./playbook-rails-react-bindings.js";import"react";import"react/jsx-runtime";import"./chunks/globalProps-CK2YuA9O.js";import"react-trix";import"trix";import"react-dom";import"react-is";import"./chunks/componentRegistry-DRSp5D_e.js";class PbKitRegistry{constructor(){this.kits=new Map;this.mutationObserver=null;this.initialized=false;this.queued=false;this.pendingMutations=[]}static getInstance(){if(!PbKitRegistry.instance){PbKitRegistry.instance=new PbKitRegistry}return PbKitRegistry.instance}register(kit){const selector=kit.selector;if(!selector){console.warn("[PbKitRegistry] Kit missing selector:",kit.name);return}const list=this.kits.get(selector)||[];list.push(kit);this.kits.set(selector,list)}start(){if(this.initialized)return;this.initialized=true;const target=document.documentElement||document;this.mutationObserver=new MutationObserver((muts=>this.onMutations(muts)));this.mutationObserver.observe(target,{childList:true,subtree:true});this.scan(document)}stop(){var _a;if(!this.initialized)return;(_a=this.mutationObserver)==null?void 0:_a.disconnect();this.mutationObserver=null;this.kits.forEach((kitsForSelector=>{kitsForSelector.forEach((kit=>{if(!kit.elements)return;const els=Array.from(kit.elements.keys());els.forEach((el=>kit.removeMatch(el)))}))}));this.pendingMutations=[];this.queued=false;this.initialized=false}onMutations(muts){this.pendingMutations.push(...muts);if(this.queued)return;this.queued=true;requestAnimationFrame((()=>{this.queued=false;const batch=this.pendingMutations;this.pendingMutations=[];this.processMutations(batch)}))}processMutations(mutations){const addedRoots=[];for(const mutation of mutations){if(mutation.type!=="childList")continue;mutation.addedNodes.forEach((node=>{if(node.nodeType===Node.ELEMENT_NODE){addedRoots.push(node)}}))}if(addedRoots.length){for(const root of addedRoots){this.scan(root)}}this.cleanupDisconnected()}scan(root){this.kits.forEach(((kitsForSelector,selector)=>{var _a;let matches;try{matches=root.querySelectorAll?root.querySelectorAll(selector):document.querySelectorAll(selector)}catch(error){console.debug(`[PbKitRegistry] Invalid selector "${selector}"`,error);return}if(matches&&matches.length){matches.forEach((el=>{kitsForSelector.forEach((kit=>kit.addMatch(el)))}))}if((_a=root.matches)==null?void 0:_a.call(root,selector)){kitsForSelector.forEach((kit=>kit.addMatch(root)))}}))}cleanupDisconnected(){this.kits.forEach((kitsForSelector=>{kitsForSelector.forEach((kit=>{if(!kit.elements)return;const els=Array.from(kit.elements.keys());for(const el of els){if(!el.isConnected){kit.removeMatch(el)}}}))}))}getRegisteredSelectors(){return Array.from(this.kits.keys())}rescan(root=document){if(!this.initialized)return;this.scan(root)}}const PbKitRegistry$1=PbKitRegistry.getInstance();class PbTextInput extends PbEnhancedElement{static get selector(){return'[data-pb-input-mask="true"], [data-pb-emoji-mask="true"]'}connect(){this.handleInput=this.handleInput.bind(this);this.handlePaste=this.handlePaste.bind(this);this.element.addEventListener("input",this.handleInput);this.element.addEventListener("paste",this.handlePaste);this.handleInput()}disconnect(){this.element.removeEventListener("input",this.handleInput);this.element.removeEventListener("paste",this.handlePaste)}hasEmojiMask(){return this.element.dataset.pbEmojiMask==="true"}handlePaste(event){if(!this.hasEmojiMask())return;const pastedText=event.clipboardData.getData("text");const filteredText=stripEmojisForPaste(pastedText);if(pastedText!==filteredText){event.preventDefault();const input=this.element;const start=input.selectionStart||0;const end=input.selectionEnd||0;const currentValue=input.value;const newValue=currentValue.slice(0,start)+filteredText+currentValue.slice(end);const newCursor=start+filteredText.length;input.value=newValue;input.selectionStart=input.selectionEnd=newCursor;this.handleInput({skipEmojiFilter:true})}}handleInput({skipEmojiFilter:skipEmojiFilter=false}={}){var _a;const cursorPosition=this.element.selectionStart;let baseValue=this.element.value;if(this.hasEmojiMask()&&!skipEmojiFilter){const result=applyEmojiMask(this.element);baseValue=result.value}const maskType=this.element.getAttribute("mask");let formattedValue=baseValue;const maskKey={currency:"currency",ssn:"ssn",postal_code:"postalCode",zip_code:"zipCode",credit_card:"creditCard",cvv:"cvv"}[maskType];if(maskKey&&INPUTMASKS[maskKey]){formattedValue=INPUTMASKS[maskKey].format(baseValue)}const sanitizedInput=(_a=this.element.closest(".text_input_wrapper"))==null?void 0:_a.querySelector('[data="sanitized-pb-input"]');if(sanitizedInput){switch(maskType){case"ssn":sanitizedInput.value=sanitizeSSN(formattedValue);break;case"currency":sanitizedInput.value=sanitizeCurrency(formattedValue);break;case"credit_card":sanitizedInput.value=sanitizeCreditCard(formattedValue);break;default:sanitizedInput.value=formattedValue}}if(maskType){this.element.value=formattedValue;setCursorPosition(this.element,cursorPosition,baseValue,formattedValue)}}}function sanitizeSSN(input){return input.replace(/\D/g,"")}function sanitizeCurrency(input){return input.replace(/[$,]/g,"")}function sanitizeCreditCard(input){return input.replace(/\D/g,"")}function setCursorPosition(inputElement,cursorPosition,rawValue,formattedValue){const difference=formattedValue.length-rawValue.length;const newPosition=Math.max(0,cursorPosition+difference);requestAnimationFrame((()=>{inputElement.setSelectionRange(newPosition,newPosition)}))}function getTextFromElement(element){if(!element)return"";return element.tagName.toLowerCase()==="input"?element.value:element.innerText}function copyTextToClipboard(text){if(!text)return;navigator.clipboard.writeText(text).catch((err=>console.error("Failed to copy text:",err)))}function handleExternalControlCopyClick(element){const value=element.getAttribute("data-external-copy-value");const fromId=element.getAttribute("data-external-copy-from");if(value){copyTextToClipboard(value)}else if(fromId){const fromElement=document.querySelector(`#${fromId}`);copyTextToClipboard(getTextFromElement(fromElement))}else{console.warn("Failed to copy:",element)}}class PbCopyButton extends PbEnhancedElement{static get selector(){return".pb_copy_button_kit"}connect(){this.handleClick=this.handleClick.bind(this);this.button=this.element.querySelector("button");if(this.button){this.button.addEventListener("click",this.handleClick)}}disconnect(){if(this.button){this.button.removeEventListener("click",this.handleClick)}}handleClick(){const value=this.element.getAttribute("data-copy-value");const fromId=this.element.getAttribute("data-from");if(value){copyTextToClipboard(value)}else if(fromId){const fromElement=document.querySelector(`#${fromId}`);copyTextToClipboard(getTextFromElement(fromElement))}else{console.warn("No data-copy-value or data-from attribute found")}}}function addCopyEventListeners(){const externalCopyElements=[...document.querySelectorAll("div[data-external-copy-value]"),...document.querySelectorAll("div[data-external-copy-from]")];externalCopyElements.forEach((element=>{element.addEventListener("click",(()=>handleExternalControlCopyClick(element)))}))}const toggleVisibility=({isVisible:isVisible,onHide:onHide,onShow:onShow})=>{if(isVisible){onHide();return false}onShow();return true};const getElementHeight=(element,displayValue="block")=>{const originalDisplay=element.style.display;element.style.display=displayValue;const height=`${element.scrollHeight}px`;element.style.display=originalDisplay;return height};const setArrowVisibility=({rootElement:rootElement,downSelector:downSelector,upSelector:upSelector,showDownArrow:showDownArrow,displayValue:displayValue="inline-block"})=>{const downArrow=rootElement.querySelector(downSelector);const upArrow=rootElement.querySelector(upSelector);if(downArrow){downArrow.style.display=showDownArrow?displayValue:"none"}if(upArrow){upArrow.style.display=showDownArrow?"none":displayValue}};const MAIN_SELECTOR="[data-collapsible-main]";const CONTENT_SELECTOR="[data-collapsible-content]";const DOWN_ARROW_SELECTOR$2="#collapsible_open_icon";const UP_ARROW_SELECTOR$2="#collapsible_close_icon";class PbCollapsible extends PbEnhancedElement{static get selector(){return MAIN_SELECTOR}connect(){this.clickHandler=()=>{this.toggleElement(this.target)};this.element.addEventListener("click",this.clickHandler);if(this.target.classList.contains("is-visible")){this.displayUpArrow()}else{this.displayDownArrow()}this.customEventHandler=()=>{this.toggleElement(this.target)};document.addEventListener(`${this.target.id}`,this.customEventHandler)}disconnect(){if(this.clickHandler){this.element.removeEventListener("click",this.clickHandler)}if(this.customEventHandler&&this.target){document.removeEventListener(`${this.target.id}`,this.customEventHandler)}}get target(){return this.element.parentNode.querySelector(CONTENT_SELECTOR)}showElement(elem){const height=getElementHeight(elem);elem.classList.add("is-visible");elem.style.height=height;elem.style.overflow="hidden";window.setTimeout((()=>{elem.style.height="";elem.style.overflow="visible"}),300)}hideElement(elem){elem.style.height=elem.scrollHeight+"px";window.setTimeout((()=>{elem.style.height="0";elem.style.paddingTop="0";elem.style.paddingBottom="0";elem.style.overflow="hidden"}),1);window.setTimeout((()=>{elem.classList.remove("is-visible");elem.style.overflow=""}),300)}toggleElement(elem){const isExpanded=toggleVisibility({isVisible:elem.classList.contains("is-visible"),onHide:()=>this.hideElement(elem),onShow:()=>this.showElement(elem)});isExpanded?this.displayUpArrow():this.displayDownArrow()}toggleArrows(showDownArrow){setArrowVisibility({rootElement:this.element,downSelector:DOWN_ARROW_SELECTOR$2,upSelector:UP_ARROW_SELECTOR$2,showDownArrow:showDownArrow})}displayDownArrow(){this.toggleArrows(true)}displayUpArrow(){this.toggleArrows(false)}}class PbFixedConfirmationToast extends PbEnhancedElement{static get selector(){return'[class*="pb_fixed_confirmation_toast_kit"]'}connect(){this.self=this.element;this.autoCloseToast(this.self);if(this.self.classList.contains("remove_toast")){this.self.addEventListener("click",(()=>{this.removeToast(this.self)}))}}removeToast(elem){elem.parentNode.removeChild(elem)}autoCloseToast(element){const autoCloseDataAttr=element.getAttribute("data-pb-auto-close");if(autoCloseDataAttr){setTimeout((()=>{this.removeToast(element)}),parseInt(autoCloseDataAttr))}}}const OPTION_SELECTOR$1="[data-dropdown-option-label]";const SEARCH_INPUT_SELECTOR$1="[data-dropdown-autocomplete]";class PbDropdownKeyboard{constructor(dropdown){this.dropdown=dropdown;this.dropdownElement=dropdown.element;this.options=Array.from(this.dropdownElement.querySelectorAll(OPTION_SELECTOR$1));this.focusedOptionIndex=-1;this.searchInput=this.dropdownElement.querySelector(SEARCH_INPUT_SELECTOR$1);this.handleKeyDownBound=this.handleKeyDown.bind(this);this.handleSearchInputBound=()=>this.openDropdownIfClosed();this.init()}init(){this.dropdownElement.addEventListener("keydown",this.handleKeyDownBound);if(this.searchInput){this.searchInput.addEventListener("input",this.handleSearchInputBound)}}disconnect(){if(this.dropdownElement&&this.handleKeyDownBound){this.dropdownElement.removeEventListener("keydown",this.handleKeyDownBound)}if(this.searchInput&&this.handleSearchInputBound){this.searchInput.removeEventListener("input",this.handleSearchInputBound)}}getVisibleOptions(){return Array.from(this.dropdownElement.querySelectorAll(OPTION_SELECTOR$1)).filter((opt=>opt.style.display!=="none"))}openDropdownIfClosed(){if(!this.dropdown.target.classList.contains("open")){this.dropdown.showElement(this.dropdown.target);this.dropdown.updateArrowDisplay(true)}}handleKeyDown(event){switch(event.key){case"ArrowDown":event.preventDefault();if(!this.dropdown.target.classList.contains("open")){this.dropdown.showElement(this.dropdown.target);this.dropdown.updateArrowDisplay(true)}this.moveFocus(1);break;case"ArrowUp":event.preventDefault();this.moveFocus(-1);break;case"Enter":event.preventDefault();if(this.focusedOptionIndex!==-1){this.selectOption()}else{if(!this.dropdown.target.classList.contains("open")){this.dropdown.showElement(this.dropdown.target);this.dropdown.updateArrowDisplay(true)}}break;case"Escape":this.dropdown.hideElement(this.dropdown.target);break;case"Tab":this.dropdown.hideElement(this.dropdown.target);this.dropdown.updateArrowDisplay(false);this.resetFocus();break;case"Backspace":if(this.searchInput){setTimeout((()=>{if(this.searchInput.value.trim()===""){this.dropdown.handleBackspaceClear()}}),0)}break}}moveFocus(direction){const allOptions=Array.from(this.dropdownElement.querySelectorAll(OPTION_SELECTOR$1));const visible=this.getVisibleOptions();if(!visible.length)return;if(this.focusedOptionIndex!==-1){allOptions[this.focusedOptionIndex].classList.remove("pb_dropdown_option_focused")}const prevVisibleIndex=this.focusedOptionIndex===-1?-1:visible.indexOf(allOptions[this.focusedOptionIndex]);const nextVisibleIndex=(prevVisibleIndex+direction+visible.length)%visible.length;const nextEl=visible[nextVisibleIndex];nextEl.classList.add("pb_dropdown_option_focused");this.focusedOptionIndex=allOptions.indexOf(nextEl)}selectOption(){const allOptions=Array.from(this.dropdownElement.querySelectorAll(OPTION_SELECTOR$1));if(this.focusedOptionIndex<0)return;const optionEl=allOptions[this.focusedOptionIndex];this.dropdown.handleOptionClick({target:optionEl});this.dropdown.toggleElement(this.dropdown.target);this.dropdown.updateClearButton()}}const DROPDOWN_SELECTOR="[data-pb-dropdown]";const TRIGGER_SELECTOR="[data-dropdown-trigger]";const CONTAINER_SELECTOR="[data-dropdown-container]";const DOWN_ARROW_SELECTOR$1="[data-dropdown-open-icon]";const UP_ARROW_SELECTOR$1="[data-dropdown-close-icon]";const OPTION_SELECTOR="[data-dropdown-option-label]";const CUSTOM_DISPLAY_SELECTOR="[data-dropdown-custom-trigger]";const DROPDOWN_TRIGGER_DISPLAY="[data-dropdown-trigger-display]";const DROPDOWN_PLACEHOLDER="[data-dropdown-placeholder]";const DROPDOWN_INPUT="[data-dropdown-selected-option]";const SEARCH_INPUT_SELECTOR="[data-dropdown-autocomplete]";const SEARCH_BAR_SELECTOR="[data-dropdown-search]";const CLEAR_ICON_SELECTOR="[data-dropdown-clear-icon]";const LABEL_SELECTOR='[data-dropdown="pb-dropdown-label"]';class PbDropdown extends PbEnhancedElement{constructor(){super(...arguments);__publicField(this,"selectedOptions",new Set);__publicField(this,"clearBtn",null)}static get selector(){return DROPDOWN_SELECTOR}get target(){var _a;return((_a=this.cachedElements)==null?void 0:_a.target)||this.element.querySelector(CONTAINER_SELECTOR)}get baseInput(){var _a;return((_a=this.cachedElements)==null?void 0:_a.baseInput)||this.element.querySelector(DROPDOWN_INPUT)}get trigger(){var _a;return((_a=this.cachedElements)==null?void 0:_a.trigger)||this.element.querySelector(TRIGGER_SELECTOR)}get customTrigger(){var _a;return((_a=this.cachedElements)==null?void 0:_a.customTrigger)||this.element.querySelector(CUSTOM_DISPLAY_SELECTOR)}get dropdownWrapper(){var _a;return((_a=this.cachedElements)==null?void 0:_a.dropdownWrapper)||this.element.querySelector(".dropdown_wrapper")}get placeholder(){var _a;return((_a=this.cachedElements)==null?void 0:_a.placeholder)||this.element.querySelector(DROPDOWN_PLACEHOLDER)}cacheElements(){this.cachedElements={target:this.element.querySelector(CONTAINER_SELECTOR),baseInput:this.element.querySelector(DROPDOWN_INPUT),trigger:this.element.querySelector(TRIGGER_SELECTOR),customTrigger:this.element.querySelector(CUSTOM_DISPLAY_SELECTOR),dropdownWrapper:this.element.querySelector(".dropdown_wrapper"),placeholder:this.element.querySelector(DROPDOWN_PLACEHOLDER)}}connect(){this.element._pbDropdownInstance=this;this.cacheElements();this.keyboardHandler=new PbDropdownKeyboard(this);this.isMultiSelect=this.element.dataset.pbDropdownMultiSelect==="true";this.closeOnClick=this.element.dataset.pbDropdownCloseOnClick||"any";this.formPillProps=this.element.dataset.formPillProps?JSON.parse(this.element.dataset.formPillProps):{};const baseInput=this.baseInput;this.wasOriginallyRequired=baseInput&&baseInput.hasAttribute("required");this.setDefaultValue();this.bindEventListeners();this.bindSearchInput();this.updateArrowDisplay(false);this.handleFormValidation();this.handleFormReset();this.bindSearchBar();this.updatePills();this.clearBtn=this.element.querySelector(CLEAR_ICON_SELECTOR);this.isClearable=this.element.dataset.pbDropdownClearable!=="false";if(this.clearBtn){this.clearBtn.style.display="none";this.clearBtnHandler=e=>{e.stopPropagation();this.clearSelection()};this.clearBtn.addEventListener("click",this.clearBtnHandler)}this.updateClearButton()}disconnect(){if(this.element._pbDropdownInstance===this){delete this.element._pbDropdownInstance}if(this.keyboardHandler&&typeof this.keyboardHandler.disconnect==="function"){this.keyboardHandler.disconnect()}if(this.customTriggerClickHandler){const customTrigger=this.customTrigger||this.element;customTrigger.removeEventListener("click",this.customTriggerClickHandler)}if(this.handleOptionClickBound){this.target.removeEventListener("click",this.handleOptionClickBound)}if(this.handleDocumentClickBound){document.removeEventListener("click",this.handleDocumentClickBound,true)}if(this.searchBar&&this.searchBarHandler){this.searchBar.removeEventListener("input",this.searchBarHandler)}if(this.searchInput){if(this.searchInputFocusHandler){const trigger=this.trigger;if(trigger){trigger.removeEventListener("click",this.searchInputFocusHandler)}}if(this.searchInputHandler){this.searchInput.removeEventListener("input",this.searchInputHandler)}}if(this.clearBtn&&this.clearBtnHandler){this.clearBtn.removeEventListener("click",this.clearBtnHandler)}}updateClearButton(){var _a;if(!this.clearBtn)return;if(!this.isClearable){this.clearBtn.style.display="none";return}const hasSelection=this.isMultiSelect?this.selectedOptions.size>0:Boolean((_a=this.baseInput)==null?void 0:_a.value);this.clearBtn.style.display=hasSelection?"":"none"}bindEventListeners(){const customTrigger=this.customTrigger||this.element;this.customTriggerClickHandler=e=>{var _a;const label=e.target.closest(LABEL_SELECTOR);if(label&&label.htmlFor){const trigger=this.element.querySelector(`#${CSS.escape(label.htmlFor)}`);if(trigger){trigger.focus()}}if(this.closeOnClick==="outside"&&((_a=this.target)==null?void 0:_a.contains(e.target))){return}this.toggleElement(this.target)};customTrigger.addEventListener("click",this.customTriggerClickHandler);this.handleOptionClickBound=this.handleOptionClick.bind(this);this.target.addEventListener("click",this.handleOptionClickBound);this.handleDocumentClickBound=this.handleDocumentClick.bind(this);document.addEventListener("click",this.handleDocumentClickBound,true)}bindSearchBar(){this.searchBar=this.element.querySelector(SEARCH_BAR_SELECTOR);if(!this.searchBar)return;this.searchBarHandler=e=>this.handleSearch(e.target.value);this.searchBar.addEventListener("input",this.searchBarHandler)}bindSearchInput(){var _a;this.searchInput=this.element.querySelector(SEARCH_INPUT_SELECTOR);if(!this.searchInput)return;this.searchInputFocusHandler=()=>this.searchInput.focus();(_a=this.trigger)==null?void 0:_a.addEventListener("click",this.searchInputFocusHandler);this.searchInputHandler=e=>this.handleSearch(e.target.value);this.searchInput.addEventListener("input",this.searchInputHandler)}adjustDropdownHeight(){if(this.target.classList.contains("open")){const el=this.target;const shouldConstrain=el.classList.contains("constrain_height");el.style.height="auto";requestAnimationFrame((()=>{if(shouldConstrain){const fontSize=parseFloat(getComputedStyle(el).fontSize)||16;const maxHeight=fontSize*18;const scrollHeight=el.scrollHeight;const newHeight=Math.min(scrollHeight,maxHeight);el.offsetHeight;el.style.height=newHeight+"px"}else{el.offsetHeight;el.style.height=el.scrollHeight+"px"}}))}}adjustDropdownPosition(container){if(!container)return;const wrapper=this.dropdownWrapper;if(!wrapper)return;const wrapperRect=wrapper.getBoundingClientRect();const h=container.getBoundingClientRect().height||container.scrollHeight;const spaceBelow=window.innerHeight-wrapperRect.bottom;const spaceAbove=wrapperRect.top;if(spaceBelow<h+10&&spaceAbove>=h+10){container.style.top="auto";container.style.bottom="calc(100% + 5px)";container.style.marginTop="0";container.style.marginBottom="0"}else{container.style.top="";container.style.bottom="";container.style.marginTop="";container.style.marginBottom=""}}handleSearch(term=""){const lcTerm=term.toLowerCase();let hasMatch=false;this.element.querySelectorAll(OPTION_SELECTOR).forEach((opt=>{if(this.isMultiSelect&&this.selectedOptions.has(opt.dataset.dropdownOptionLabel)){opt.style.display="none";return}const label=JSON.parse(opt.dataset.dropdownOptionLabel).label.toString().toLowerCase();const match=label.includes(lcTerm);opt.style.display=match?"":"none";if(match)hasMatch=true}));this.adjustDropdownHeight();this.removeNoOptionsMessage();if(!hasMatch){this.showNoOptionsMessage()}}showNoOptionsMessage(){if(this.element.querySelector(".dropdown_no_options"))return;const noOptionElement=document.createElement("div");noOptionElement.className="pb_body_kit_light dropdown_no_options pb_item_kit p_xs display_flex justify_content_center";noOptionElement.textContent="no option";this.target.appendChild(noOptionElement)}removeNoOptionsMessage(){const existing=this.element.querySelector(".dropdown_no_options");if(existing){existing.remove()}}handleOptionClick(event){const option=event.target.closest(OPTION_SELECTOR);const hiddenInput=this.baseInput;if(option){const value=option.dataset.dropdownOptionLabel;if(this.isMultiSelect){const alreadySelected=this.selectedOptions.has(value);if(alreadySelected){this.selectedOptions.delete(value)}else{this.selectedOptions.add(value)}this.updatePills();this.syncHiddenInputs();if(this.searchInput&&this.isMultiSelect){this.searchInput.value="";this.handleBackspaceClear()}}else{hiddenInput.value=JSON.parse(value).id}this.clearFormValidation(hiddenInput);this.onOptionSelected(value,option);this.updateClearButton()}}handleDocumentClick(event){if(event.target.closest(SEARCH_BAR_SELECTOR))return;const shouldCloseOnOutsideClick=this.closeOnClick==="outside"||this.closeOnClick==="any";if(shouldCloseOnOutsideClick&&this.isClickOutside(event)&&this.target.classList.contains("open")){this.hideElement(this.target);this.updateArrowDisplay(false)}}isClickOutside(event){var _a;const label=event.target.closest(LABEL_SELECTOR);if(label&&this.element.contains(label))return false;const customTrigger=this.customTrigger;if(customTrigger){const clickInTrigger=customTrigger.contains(event.target);const clickInContainer=(_a=this.target)==null?void 0:_a.contains(event.target);return!clickInTrigger&&!clickInContainer}else{const triggerElement=this.trigger;const containerElement=this.element.querySelector(CONTAINER_SELECTOR);const isOutsideTrigger=triggerElement?!triggerElement.contains(event.target):true;const isOutsideContainer=containerElement?!containerElement.contains(event.target):true;return isOutsideTrigger&&isOutsideContainer}}emitSelectionChange(){let detail;if(this.isMultiSelect){detail=Array.from(this.selectedOptions).map(JSON.parse)}else{const hiddenInput=this.baseInput;detail=hiddenInput.value?JSON.parse(this.element.querySelector(OPTION_SELECTOR+`[data-dropdown-option-label*='"id":"${hiddenInput.value}"']`).dataset.dropdownOptionLabel):null}this.element.setAttribute("data-option-selected",JSON.stringify(detail));this.element.dispatchEvent(new CustomEvent("pb:dropdown:selected",{detail:detail,bubbles:true}))}onOptionSelected(value,selectedOption){var _a,_b,_c,_d;const triggerElement=this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);const customDisplayElement=this.element.querySelector("[data-dropdown-trigger-custom-display]");if(triggerElement){if(!this.isMultiSelect){const selectedLabel=JSON.parse(value).label;triggerElement.textContent=selectedLabel;this.emitSelectionChange();const optionData=JSON.parse(value);const startDateId=this.element.dataset.startDateId;const endDateId=this.element.dataset.endDateId;const controlsStartId=this.element.dataset.controlsStartId;const controlsEndId=this.element.dataset.controlsEndId;if(optionData.formatted_start_date&&optionData.formatted_end_date){if(startDateId){const startDateInput=document.getElementById(startDateId);if(startDateInput)startDateInput.value=optionData.formatted_start_date}if(endDateId){const endDateInput=document.getElementById(endDateId);if(endDateInput)endDateInput.value=optionData.formatted_end_date}if(controlsStartId){const startPicker=(_a=document.querySelector(`#${controlsStartId}`))==null?void 0:_a._flatpickr;if(startPicker){startPicker.setDate(optionData.formatted_start_date,true,"m/d/Y")}}if(controlsEndId){const endPicker=(_b=document.querySelector(`#${controlsEndId}`))==null?void 0:_b._flatpickr;if(endPicker){endPicker.setDate(optionData.formatted_end_date,true,"m/d/Y")}}}else if(startDateId||endDateId){if(startDateId){const startDateInput=document.getElementById(startDateId);if(startDateInput)startDateInput.value=""}if(endDateId){const endDateInput=document.getElementById(endDateId);if(endDateInput)endDateInput.value=""}if(controlsStartId){const startPicker=(_c=document.querySelector(`#${controlsStartId}`))==null?void 0:_c._flatpickr;if(startPicker){startPicker.clear()}}if(controlsEndId){const endPicker=(_d=document.querySelector(`#${controlsEndId}`))==null?void 0:_d._flatpickr;if(endPicker){endPicker.clear()}}}}if(customDisplayElement){triggerElement.textContent="";customDisplayElement.style.display="block";customDisplayElement.style.paddingRight="8px"}}const autocompleteInput=this.element.querySelector(SEARCH_INPUT_SELECTOR);if(autocompleteInput&&!this.isMultiSelect){autocompleteInput.value=JSON.parse(value).label;this.emitSelectionChange()}const customTrigger=this.customTrigger;const shouldCloseOnOptionSelect=this.closeOnClick==="any"||this.closeOnClick==="inside";if(customTrigger&&shouldCloseOnOptionSelect&&this.target.classList.contains("open")){this.hideElement(this.target);this.updateArrowDisplay(false)}const options=this.element.querySelectorAll(OPTION_SELECTOR);if(this.isMultiSelect){this.emitSelectionChange();Array.from(this.selectedOptions).map((option=>{if(JSON.parse(option).id===JSON.parse(selectedOption.dataset.dropdownOptionLabel).id){selectedOption.style.display="none";this.adjustDropdownHeight()}}));this.baseInput.value=Array.from(this.selectedOptions).map((opt=>JSON.parse(opt).id)).join(",")}else{options.forEach((option=>{option.classList.remove("pb_dropdown_option_selected")}));selectedOption.classList.add("pb_dropdown_option_selected")}this.updateClearButton()}showElement(elem){elem.classList.remove("close");elem.classList.add("open");const shouldConstrain=elem.classList.contains("constrain_height");if(shouldConstrain){const fontSize=parseFloat(getComputedStyle(elem).fontSize)||16;const maxHeight=fontSize*18;const scrollHeight=elem.scrollHeight;const height=Math.min(scrollHeight,maxHeight);elem.style.height=height+"px"}else{elem.style.height=elem.scrollHeight+"px"}this.adjustDropdownPosition(elem)}hideElement(elem){elem.style.height=elem.scrollHeight+"px";window.setTimeout((()=>{elem.classList.add("close");elem.classList.remove("open");this.resetFocus()}),0)}resetFocus(){if(this.keyboardHandler){this.keyboardHandler.focusedOptionIndex=-1;const options=this.element.querySelectorAll(OPTION_SELECTOR);options.forEach((option=>option.classList.remove("pb_dropdown_option_focused")))}}toggleElement(elem){const isOpen=toggleVisibility({isVisible:elem.classList.contains("open"),onHide:()=>this.hideElement(elem),onShow:()=>this.showElement(elem)});this.updateArrowDisplay(isOpen)}updateArrowDisplay(isOpen){setArrowVisibility({rootElement:this.element,downSelector:DOWN_ARROW_SELECTOR$1,upSelector:UP_ARROW_SELECTOR$1,showDownArrow:!isOpen})}handleFormValidation(){const hiddenInput=this.baseInput;hiddenInput.addEventListener("invalid",(function(event){if(hiddenInput.hasAttribute("required")&&hiddenInput.value===""){event.preventDefault();hiddenInput.closest(".dropdown_wrapper").classList.add("error")}}),true)}clearFormValidation(input){if(this.isMultiSelect){if(this.selectedOptions.size>0){const dropdownWrapperElement=input.closest(".dropdown_wrapper");dropdownWrapperElement.classList.remove("error");const errorLabelElement=dropdownWrapperElement.querySelector(".pb_body_kit_negative");if(errorLabelElement){errorLabelElement.remove()}return}}if(input.checkValidity()){const dropdownWrapperElement=input.closest(".dropdown_wrapper");dropdownWrapperElement.classList.remove("error");const errorLabelElement=dropdownWrapperElement.querySelector(".pb_body_kit_negative");if(errorLabelElement){errorLabelElement.remove()}}}setDefaultValue(){const hiddenInput=this.baseInput;const optionEls=Array.from(this.element.querySelectorAll(OPTION_SELECTOR));const defaultValue=hiddenInput.dataset.defaultValue||"";if(!defaultValue)return;if(this.isMultiSelect){const ids=defaultValue.split(",");ids.forEach((id=>{const selectedOption=optionEls.find((opt=>{try{return JSON.parse(opt.dataset.dropdownOptionLabel).id===id}catch{return false}}));if(!selectedOption){console.warn(`Dropdown default ID ${id} not found`);return}const raw=selectedOption.dataset.dropdownOptionLabel;this.selectedOptions.add(raw);selectedOption.style.display="none"}));this.updatePills();this.updateClearButton();this.adjustDropdownHeight();this.syncHiddenInputs()}else{hiddenInput.value=defaultValue;const selectedOption=optionEls.find((opt=>{try{return JSON.parse(opt.dataset.dropdownOptionLabel).id===defaultValue}catch{return false}}));if(!selectedOption)return;selectedOption.classList.add("pb_dropdown_option_selected");const optionData=JSON.parse(selectedOption.dataset.dropdownOptionLabel);this.setTriggerElementText(optionData.label);if(optionData.formatted_start_date&&optionData.formatted_end_date){const startDateId=this.element.dataset.startDateId;const endDateId=this.element.dataset.endDateId;const controlsStartId=this.element.dataset.controlsStartId;const controlsEndId=this.element.dataset.controlsEndId;if(startDateId){const startDateInput=document.getElementById(startDateId);if(startDateInput)startDateInput.value=optionData.formatted_start_date}if(endDateId){const endDateInput=document.getElementById(endDateId);if(endDateInput)endDateInput.value=optionData.formatted_end_date}const syncDatePickers=()=>{var _a,_b;if(controlsStartId){const startPicker=(_a=document.querySelector(`#${controlsStartId}`))==null?void 0:_a._flatpickr;if(startPicker){startPicker.setDate(optionData.formatted_start_date,true,"m/d/Y")}}if(controlsEndId){const endPicker=(_b=document.querySelector(`#${controlsEndId}`))==null?void 0:_b._flatpickr;if(endPicker){endPicker.setDate(optionData.formatted_end_date,true,"m/d/Y")}}};syncDatePickers();setTimeout(syncDatePickers,100);setTimeout(syncDatePickers,300)}}}handleFormReset(){const form=this.element.closest("form");if(form){form.addEventListener("reset",(()=>{this.resetDropdownValue()}))}}resetDropdownValue(){const hiddenInput=this.baseInput;const options=this.element.querySelectorAll(OPTION_SELECTOR);options.forEach((option=>{option.classList.remove("pb_dropdown_option_selected");option.style.display=""}));hiddenInput.value="";const defaultPlaceholder=this.placeholder;this.setTriggerElementText(defaultPlaceholder.dataset.dropdownPlaceholder);if(this.searchInput){this.searchInput.value="";if(this.target.classList.contains("open")){const el=this.target;el.style.height="auto";requestAnimationFrame((()=>{const newHeight=el.scrollHeight+"px";el.offsetHeight;el.style.height=newHeight}))}}if(this.isMultiSelect){this.selectedOptions.clear();this.updatePills();this.updateClearButton();this.syncHiddenInputs()}}setTriggerElementText(text){const triggerElement=this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);if(triggerElement){triggerElement.textContent=text}}updatePills(){if(!this.isMultiSelect)return;const wrapper=this.element.querySelector("[data-dropdown-pills-wrapper]");const placeholder=this.element.querySelector("[data-dropdown-trigger-display-multi-select]");if(!wrapper)return;wrapper.innerHTML="";if(placeholder){if(this.selectedOptions.size>0){placeholder.style.display="none"}else{placeholder.style.display=""}}Array.from(this.selectedOptions).map((option=>{const pill=document.createElement("div");const color=this.formPillProps.color||"primary";pill.classList.add("pb_form_pill_kit",`pb_form_pill_${color}`,"pb_form_pill_none","mr_xs");if(this.formPillProps.size==="small"){pill.classList.add("pb_form_pill_small")}pill.tabIndex=0;pill.dataset.pillId=JSON.parse(option).id;const innerDiv=document.createElement("h3");innerDiv.className="pb_title_kit pb_title_4 pb_form_pill_text";innerDiv.textContent=JSON.parse(option).label;pill.appendChild(innerDiv);const closeIcon=document.createElement("div");closeIcon.className="pb_form_pill_close";closeIcon.innerHTML=`<svg class="pb_custom_icon svg-inline--fa svg_${this.formPillProps.size==="small"?"xs":"sm"} svg_fw" xmlns="http://www.w3.org/2000/svg" width="auto" height="auto" viewBox="0 0 31 25"><path fill="currentColor" d="M23.0762 6.77734L17.4512 12.4023L23.0293 17.9805C23.498 18.4023 23.498 19.1055 23.0293 19.5273C22.6074 19.9961 21.9043 19.9961 21.4824 19.5273L15.8574 13.9492L10.2793 19.5273C9.85742 19.9961 9.1543 19.9961 8.73242 19.5273C8.26367 19.1055 8.26367 18.4023 8.73242 17.9336L14.3105 12.3555L8.73242 6.77734C8.26367 6.35547 8.26367 5.65234 8.73242 5.18359C9.1543 4.76172 9.85742 4.76172 10.3262 5.18359L15.9043 10.8086L21.4824 5.23047C21.9043 4.76172 22.6074 4.76172 23.0762 5.23047C23.498 5.65234 23.498 6.35547 23.0762 6.77734Z"/></svg>`;pill.appendChild(closeIcon);closeIcon.addEventListener("click",(e=>{e.stopPropagation();const id=pill.dataset.pillId;this.selectedOptions.delete(option);const optEl=this.element.querySelector(`${OPTION_SELECTOR}[data-dropdown-option-label*='"id":${JSON.stringify(id)}']`);if(optEl){optEl.style.display="";if(this.target.classList.contains("open")){this.showElement(this.target)}}this.updatePills();this.updateClearButton();this.emitSelectionChange();this.syncHiddenInputs()}));wrapper.appendChild(pill)}))}clearSelection(){var _a,_b;if(this.isMultiSelect){this.selectedOptions.clear();this.element.querySelectorAll(OPTION_SELECTOR).forEach((opt=>{opt.style.display=""}));if(this.target.classList.contains("open")){this.showElement(this.target)}}const customDisplay=this.element.querySelector("[data-dropdown-trigger-custom-display]");if(customDisplay){customDisplay.style.display="none"}const startDateId=this.element.dataset.startDateId;const endDateId=this.element.dataset.endDateId;const controlsStartId=this.element.dataset.controlsStartId;const controlsEndId=this.element.dataset.controlsEndId;if(startDateId){const startDateInput=document.getElementById(startDateId);if(startDateInput)startDateInput.value=""}if(endDateId){const endDateInput=document.getElementById(endDateId);if(endDateInput)endDateInput.value=""}if(controlsStartId){const startPicker=(_a=document.querySelector(`#${controlsStartId}`))==null?void 0:_a._flatpickr;if(startPicker){startPicker.clear()}}if(controlsEndId){const endPicker=(_b=document.querySelector(`#${controlsEndId}`))==null?void 0:_b._flatpickr;if(endPicker){endPicker.clear()}}this.resetDropdownValue();this.updatePills();this.updateClearButton();this.syncHiddenInputs();this.emitSelectionChange()}clearSelected(){if(this.element.dataset.pbDropdownVariant!=="quickpick"||this.isMultiSelect){return}const customDisplay=this.element.querySelector("[data-dropdown-trigger-custom-display]");if(customDisplay){customDisplay.style.display="none"}const startDateId=this.element.dataset.startDateId;const endDateId=this.element.dataset.endDateId;if(startDateId){const startDateInput=document.getElementById(startDateId);if(startDateInput)startDateInput.value=""}if(endDateId){const endDateInput=document.getElementById(endDateId);if(endDateInput)endDateInput.value=""}this.resetDropdownValue();this.updateClearButton();this.emitSelectionChange()}syncHiddenInputs(){if(!this.isMultiSelect)return;this.element.querySelectorAll('input[data-generated="true"]').forEach((n=>n.remove()));const baseInput=this.baseInput;if(!baseInput)return;const name=baseInput.getAttribute("name");this.selectedOptions.forEach((raw=>{const optionData=JSON.parse(raw);const id=optionData.id||optionData.value;const inp=document.createElement("input");inp.type="hidden";inp.name=name;inp.value=id;inp.dataset.generated="true";baseInput.insertAdjacentElement("afterend",inp)}));if(this.selectedOptions.size>0){baseInput.value="";baseInput.removeAttribute("required")}else{baseInput.value="";if(this.wasOriginallyRequired){baseInput.setAttribute("required","")}}}handleBackspaceClear(){if(!this.isMultiSelect){this.element.querySelectorAll(OPTION_SELECTOR).forEach((opt=>{opt.classList.remove("pb_dropdown_option_selected");opt.style.display="";this.adjustDropdownHeight()}));const hiddenInput=this.baseInput;if(hiddenInput)hiddenInput.value="";const placeholder=this.placeholder;if(placeholder)this.setTriggerElementText(placeholder.dataset.dropdownPlaceholder)}if(this.isMultiSelect){this.element.querySelectorAll(OPTION_SELECTOR).forEach((opt=>{const optValue=opt.dataset.dropdownOptionLabel;if(this.selectedOptions.size>0&&this.selectedOptions.has(optValue)){opt.style.display="none"}else{opt.style.display=""}this.adjustDropdownHeight()}))}}}function showActionBar(actionBar,selectedCount){const tableContainer=actionBar.closest(".pb_advanced_table");actionBar.style.height="auto";actionBar.style.overflow="visible";actionBar.style.opacity="1";actionBar.style.transitionProperty="all";actionBar.style.transitionTimingFunction="ease-in-out";actionBar.classList.remove("p_none");actionBar.classList.add("p_xs","is-visible","show-action-card");if(tableContainer){tableContainer.classList.remove("hidden-action-bar")}const countElement=actionBar.querySelector(".selected-count");if(countElement){countElement.textContent=`${selectedCount} Selected`}}function hideActionBar(actionBar){const tableContainer=actionBar.closest(".pb_advanced_table");actionBar.style.height="0px";actionBar.style.overflow="hidden";actionBar.style.opacity="0";actionBar.classList.add("p_none");actionBar.classList.remove("p_xs","is-visible","show-action-card");if(tableContainer){tableContainer.classList.add("hidden-action-bar")}}function updateSelectionActionBar(table,selectedCount){const actionBar=table.querySelector(".row-selection-actions-card");if(!actionBar)return;if(selectedCount>0){showActionBar(actionBar,selectedCount)}else{hideActionBar(actionBar)}}const ADVANCED_TABLE_SELECTOR="[data-advanced-table]";const DOWN_ARROW_SELECTOR="#advanced-table_open_icon";const UP_ARROW_SELECTOR="#advanced-table_close_icon";const _PbAdvancedTable=class _PbAdvancedTable extends PbEnhancedElement{static get selector(){return ADVANCED_TABLE_SELECTOR}constructor(...args){super(...args);this.childRowsMap=new Map}get table(){return this.cachedTable||(this.cachedTable=this.element.closest("table"))}get mainTable(){return this.cachedMainTable||(this.cachedMainTable=this.element.closest(".pb_advanced_table"))}childRowsFor(parentId){if(!this.childRowsMap.has(parentId)){const table=this.table;const rows=Array.from(table.querySelectorAll(`tr[data-row-parent="${parentId}"]`));this.childRowsMap.set(parentId,rows)}return this.childRowsMap.get(parentId)}updateTableSelectedRowsAttribute(){const mainTable=this.mainTable;if(!mainTable)return;mainTable.dataset.selectedRows=JSON.stringify(Array.from(_PbAdvancedTable.selectedRows))}recalculateSelectedCount(){const table=this.table;if(!table)return;const rowCheckboxes=table.querySelectorAll('label[data-row-id] input[type="checkbox"]');const parentCheckboxes=table.querySelectorAll('[data-pb-checkbox-indeterminate-main="true"] input[type="checkbox"]');const selectAllCheckbox=table.querySelector('#select-all-rows input[type="checkbox"]');const filteredParentCheckboxes=Array.from(parentCheckboxes).filter((checkbox=>checkbox!==selectAllCheckbox&&!checkbox.id.includes("select-all-rows")));const allCheckboxes=new Set([...rowCheckboxes,...filteredParentCheckboxes]);_PbAdvancedTable.selectedRows.clear();allCheckboxes.forEach((checkbox=>{const rowEl=checkbox.closest("tr");const isChecked=checkbox.checked;if(isChecked){_PbAdvancedTable.selectedRows.add(checkbox.id);if(rowEl){rowEl.classList.add("bg-row-selection");rowEl.classList.remove("pb-bg-row-white","bg-silver")}}else{if(rowEl){rowEl.classList.remove("bg-row-selection");if(this.isRowExpanded(rowEl)){rowEl.classList.remove("bg-silver");rowEl.classList.add("pb-bg-row-white")}else{rowEl.classList.remove("pb-bg-row-white");rowEl.classList.add("bg-silver")}}}}));this.updateTableSelectedRowsAttribute();updateSelectionActionBar(this.mainTable,_PbAdvancedTable.selectedRows.size);if(selectAllCheckbox){selectAllCheckbox.checked=Array.from(rowCheckboxes).every((cb=>cb.checked))}}isRowExpanded(rowEl){const closeIcon=rowEl.querySelector(UP_ARROW_SELECTOR);return(closeIcon==null?void 0:closeIcon.style.display)==="none"||!closeIcon}handleCheckboxClick(event){const checkbox=event.currentTarget;const rowId=checkbox.id;const isChecked=checkbox.checked;const rowEl=checkbox.closest("tr");if(isChecked){_PbAdvancedTable.selectedRows.add(rowId);rowEl.classList.add("bg-row-selection");rowEl.classList.remove("pb-bg-row-white","bg-silver")}else{_PbAdvancedTable.selectedRows.delete(rowId)}if(!isChecked){rowEl.classList.remove("bg-row-selection");if(this.isRowExpanded(rowEl)){rowEl.classList.remove("bg-silver");rowEl.classList.add("pb-bg-row-white")}else{rowEl.classList.remove("pb-bg-row-white");rowEl.classList.add("bg-silver")}}this.updateTableSelectedRowsAttribute();const table=this.table;const selectAllCheckbox=table.querySelector("#select-all-rows");if(selectAllCheckbox){const allCheckboxes=table.querySelectorAll("label[data-row-id] input[type='checkbox']");const allChecked=Array.from(allCheckboxes).every((cb=>cb.checked));const selectAllInput=selectAllCheckbox.querySelector('input[type="checkbox"]');selectAllInput.checked=allChecked}updateSelectionActionBar(this.mainTable,_PbAdvancedTable.selectedRows.size)}get target(){return this.childRowsFor(this.element.id)||[]}connect(){const table=this.table;if(!table)return;this.hideCloseIcon();const mainTable=this.mainTable;if(mainTable){updateSelectionActionBar(mainTable)}table.querySelectorAll("tr[data-row-parent]").forEach((row=>{const parentId=row.dataset.rowParent;if(!this.childRowsMap.has(parentId)){this.childRowsMap.set(parentId,[])}this.childRowsMap.get(parentId).push(row)}));if(table.dataset.pbAdvancedTableInitialized)return;table.dataset.pbAdvancedTableInitialized="true";table.addEventListener("change",(event=>{const checkbox=event.target.closest('input[type="checkbox"]');if(!checkbox)return;if(checkbox.closest("#select-all-rows")){const checkAll=checkbox.checked;const rowCheckboxes=table.querySelectorAll('label[data-row-id] input[type="checkbox"]');rowCheckboxes.forEach((cb=>{if(cb.checked!==checkAll){cb.checked=checkAll;this.handleCheckboxClick({currentTarget:cb})}}));setTimeout((()=>{this.recalculateSelectedCount()}),0);return}const rowLabel=checkbox.closest("label[data-row-id]");if(rowLabel){this.handleCheckboxClick({currentTarget:checkbox});setTimeout((()=>{this.recalculateSelectedCount()}),0)}}));table.addEventListener("checkbox-programmatic-change",(event=>{const checkbox=event.target;if(!checkbox||checkbox.type!=="checkbox")return;const rowLabel=checkbox.closest("label[data-row-id]");if(rowLabel){this.handleCheckboxClick({currentTarget:checkbox})}setTimeout((()=>{this.recalculateSelectedCount()}),10)}));table.addEventListener("change",(event=>{const checkbox=event.target;if(checkbox&&checkbox.type==="checkbox"){setTimeout((()=>{this.recalculateSelectedCount()}),50)}}));table.addEventListener("click",(event=>{const toggleBtn=event.target.closest("[data-advanced-table]");if(!toggleBtn||_PbAdvancedTable.isCollapsing)return;const prevElement=this.element;this.element=toggleBtn;const isExpanded=toggleBtn.querySelector(UP_ARROW_SELECTOR).style.display==="inline-block";if(!isExpanded){_PbAdvancedTable.expandedRows.add(toggleBtn.id)}else{_PbAdvancedTable.expandedRows.delete(toggleBtn.id)}const childRows=this.childRowsFor(toggleBtn.id);this.toggleElement(childRows);this.element=prevElement}));this.addBorderRadiusOnLastVisibleRow()}addBorderRadiusOnLastVisibleRow(){const parentElement=this.mainTable;if(!parentElement)return;const table=document.getElementById(parentElement.id);if(table){const visibleRows=table.querySelectorAll("tr.is-visible, tr:not(.toggle-content)");visibleRows.forEach((row=>{row.classList.remove("last-visible-row");row.classList.remove("last-row-cell")}));const lastVisibleRow=visibleRows[visibleRows.length-1];if(lastVisibleRow){lastVisibleRow.classList.add("last-visible-row");lastVisibleRow.classList.add("last-row-cell")}}}hideCloseIcon(){const closeIcon=this.element.querySelector(UP_ARROW_SELECTOR);closeIcon.style.display="none"}showElement(elements){elements.forEach((elem=>{elem.style.display="table-row";elem.classList.add("is-visible");const childRowsAll=this.table.querySelectorAll(`[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`);childRowsAll.forEach((childRow=>{const dataContent=childRow.dataset.advancedTableContent;if(!dataContent){return}const ancestorIds=dataContent.split("-").slice(0,-1);const parentRowId=childRow.dataset.rowParent;const tableId=parentRowId?parentRowId.split("_").slice(0,-1).join("_"):"";const prefixedAncestorIds=ancestorIds.map((id=>`${tableId}_${id}`));const allAncestorsExpanded=prefixedAncestorIds.every((id=>_PbAdvancedTable.expandedRows.has(id)));const checkIfParentIsExpanded=()=>{if(dataContent.endsWith("sr")){const parentRowId2=childRow.dataset.rowParent;const isParentVisible=childRow.previousElementSibling.classList.contains("is-visible");if(parentRowId2){const isInSet=_PbAdvancedTable.expandedRows.has(parentRowId2);if(isInSet&&isParentVisible){return true}}}return false};if(allAncestorsExpanded||checkIfParentIsExpanded()){childRow.style.display="table-row";childRow.classList.add("is-visible")}else{childRow.style.display="none";childRow.classList.remove("is-visible")}}))}))}hideElement(elements){elements.forEach((elem=>{elem.style.display="none";elem.classList.remove("is-visible");if(_PbAdvancedTable.expandedRows.has(elem.id)){_PbAdvancedTable.expandedRows.delete(elem.id)}const childrenArray=elem.dataset.advancedTableContent.split("-");const currentDepth=parseInt(elem.dataset.rowDepth);if(childrenArray.length>currentDepth){const childRows=this.table.querySelectorAll(`[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`);childRows.forEach((childRow=>{childRow.style.display="none";childRow.classList.remove("is-visible")}))}}))}toggleElement(elements){if(!elements.length)return;const isVisible=elements[0].classList.contains("is-visible");const isExpanded=toggleVisibility({isVisible:isVisible,onHide:()=>this.hideElement(elements),onShow:()=>this.showElement(elements)});isExpanded?this.displayUpArrow():this.displayDownArrow();const row=this.element.closest("tr");if(row){row.classList.toggle("bg-silver",isExpanded);row.classList.toggle("pb-bg-row-white",!isExpanded)}this.addBorderRadiusOnLastVisibleRow()}displayDownArrow(){setArrowVisibility({rootElement:this.element,downSelector:DOWN_ARROW_SELECTOR,upSelector:UP_ARROW_SELECTOR,showDownArrow:true})}displayUpArrow(){setArrowVisibility({rootElement:this.element,downSelector:DOWN_ARROW_SELECTOR,upSelector:UP_ARROW_SELECTOR,showDownArrow:false})}static handleToggleAllHeaders(element){const table=element.closest(".pb_table");const firstLevelButtons=table.querySelectorAll(".pb_advanced_table_body > .pb_table_tr[data-row-depth='0'] [data-advanced-table]");const allExpanded=Array.from(firstLevelButtons).every((button=>button.querySelector(UP_ARROW_SELECTOR).style.display==="inline-block"));if(allExpanded){firstLevelButtons.forEach((button=>{button.click();_PbAdvancedTable.expandedRows.delete(button.id)}))}else{firstLevelButtons.forEach((button=>{if(!_PbAdvancedTable.expandedRows.has(button.id)){button.click();_PbAdvancedTable.expandedRows.add(button.id)}}));_PbAdvancedTable.expandedRows.forEach((rowId=>{const nestedButton=table.querySelector(`[data-advanced-table][id="${rowId}"]`);if(nestedButton&&!firstLevelButtons.contains(nestedButton)){nestedButton.click()}}))}}static handleToggleAllSubRows(element,rowDepth){const table=element.closest(".pb_table");const parentRow=element.closest("tr");if(!parentRow){return}const rowParentId=parentRow.dataset.rowParent;const subRowButtons=table.querySelectorAll(`.pb_advanced_table_body > .pb_table_tr[data-row-depth='${rowDepth}'].pb_table_tr[data-row-parent='${rowParentId}'] [data-advanced-table]`);const allExpanded=Array.from(subRowButtons).every((button=>button.querySelector(UP_ARROW_SELECTOR).style.display==="inline-block"));if(allExpanded){subRowButtons.forEach((button=>{button.click();_PbAdvancedTable.expandedRows.delete(button.id)}))}else{subRowButtons.forEach((button=>{if(!_PbAdvancedTable.expandedRows.has(button.id)){button.click();_PbAdvancedTable.expandedRows.add(button.id)}}))}}};__publicField(_PbAdvancedTable,"expandedRows",new Set);__publicField(_PbAdvancedTable,"selectedRows",new Set);__publicField(_PbAdvancedTable,"isCollapsing",false);let PbAdvancedTable=_PbAdvancedTable;window.expandAllRows=element=>{PbAdvancedTable.handleToggleAllHeaders(element)};window.expandAllSubRows=(element,rowDepth)=>{PbAdvancedTable.handleToggleAllSubRows(element,rowDepth)};const FLAT_SELECTOR="[data-flat-advanced-table-select='true']";class PbFlatAdvancedTable extends PbEnhancedElement{static get selector(){return FLAT_SELECTOR}constructor(...args){super(...args);this.selectedRows=new Set}connect(){const table=this.element.closest("table");if(!table||table.dataset.flatAdvancedInit)return;table.dataset.flatAdvancedInit="true";const mainTable=this.element.closest(".pb_advanced_table");if(mainTable){updateSelectionActionBar(mainTable,0)}const updateCheckboxState=()=>{if(mainTable){mainTable.dataset.selectedRows=JSON.stringify(Array.from(this.selectedRows));updateSelectionActionBar(mainTable,this.selectedRows.size)}};const selectAllId=this.element.getAttribute("data-pb-checkbox-indeterminate-parent");const selectAllSelector=`#${selectAllId} input[type='checkbox']`;table.addEventListener("change",(e=>{const rowCb=e.target.closest(FLAT_SELECTOR+" input[type='checkbox']");const allCb=e.target.closest(selectAllSelector);if(!rowCb&&!allCb)return;if(rowCb){const id=rowCb.id;if(rowCb.checked)this.selectedRows.add(id);else this.selectedRows.delete(id);const tr=rowCb.closest("tr");tr==null?void 0:tr.classList.toggle("bg-row-selection",rowCb.checked);tr==null?void 0:tr.classList.toggle("pb-bg-row-white",!rowCb.checked)}if(allCb){const checked=allCb.checked;Array.from(table.querySelectorAll(FLAT_SELECTOR+" input[type='checkbox']")).forEach((cb=>{cb.checked=checked;const tr=cb.closest("tr");tr==null?void 0:tr.classList.toggle("bg-row-selection",checked);tr==null?void 0:tr.classList.toggle("pb-bg-row-white",!checked);const id=cb.id;if(checked)this.selectedRows.add(id);else this.selectedRows.delete(id)}))}updateCheckboxState()}))}}const NAV_SELECTOR="[data-pb-nav-tab]";const NAV_ITEM_SELECTOR="[data-pb-tab-target]";class PbNav extends PbEnhancedElement{static get selector(){return NAV_SELECTOR}connect(){this.hideAndAddEventListeners()}hideAndAddEventListeners(){const navItems=this.element.querySelectorAll(NAV_ITEM_SELECTOR);navItems.forEach((navItem=>{if(!navItem.className.includes("active")){this.changeContentDisplay(navItem.dataset.pbTabTarget,"none")}navItem.addEventListener("click",(event=>this.handleNavItemClick(event)))}))}handleNavItemClick(event){event.preventDefault();const navItem=event.target.closest(NAV_ITEM_SELECTOR);this.changeContentDisplay(navItem.dataset.pbTabTarget,"block");const navItems=this.element.querySelectorAll(NAV_ITEM_SELECTOR);navItems.forEach((navItemSelected=>{if(navItem!==navItemSelected){this.changeContentDisplay(navItemSelected.dataset.pbTabTarget,"none")}}))}changeContentDisplay(contentId,display){const content=document.getElementById(contentId);content.style.display=display}}const STAR_RATING_WRAPPER_SELECTOR="[data-pb-star-rating-wrapper]";const STAR_RATING_SELECTOR="[data-pb-star-rating]";const STAR_RATING_INPUT_DATA_SELECTOR="[data-pb-star-rating-input]";class PbStarRating extends PbEnhancedElement{static get selector(){return STAR_RATING_WRAPPER_SELECTOR}connect(){this.addEventListeners();this.handleFormReset();this.setDefaultValue()}addEventListeners(){this.element.querySelectorAll(STAR_RATING_SELECTOR).forEach((star=>{star.addEventListener("click",(event=>{const clickedStarId=event.currentTarget.id;this.updateStarColors(clickedStarId);this.updateHiddenInputValue(clickedStarId);this.clearFormValidation()}));star.addEventListener("mouseenter",(event=>{const hoveredStarId=event.currentTarget.id;this.updateStarHoverColors(hoveredStarId)}));star.addEventListener("mouseleave",(()=>{this.removeStarHoverColors()}));star.addEventListener("keydown",(event=>{if(event.key==="Enter"||event.key===" "){event.preventDefault();this.handleStarClick(star.id)}}))}))}handleStarClick(starId){this.updateStarColors(starId);this.updateHiddenInputValue(starId)}updateStarColors(clickedStarId){const allStars=this.element.querySelectorAll(STAR_RATING_SELECTOR);allStars.forEach((star=>{const starId=star.id;const icon=star.querySelector(".interactive-star-icon");if(icon){if(starId<=clickedStarId){if(star.classList.contains("yellow_star")){icon.classList.add("yellow-star-selected")}else if(star.classList.contains("primary_star_light")){icon.classList.add("primary-star-selected")}else if(star.classList.contains("primary_star_dark")){icon.classList.add("primary-star-selected")}else if(star.classList.contains("subtle_star_light")){icon.classList.add("subtle-star-selected")}else if(star.classList.contains("subtle_star_dark")){icon.classList.add("subtle-star-selected")}else{icon.classList.add("yellow-star-selected")}}else{icon.classList.remove("yellow-star-selected","primary-star-selected","subtle-star-selected")}icon.classList.remove("star-hovered")}}))}updateHiddenInputValue(value){const hiddenInput=this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR);if(hiddenInput){hiddenInput.value=value}}updateStarHoverColors(hoveredStarId){const allStars=this.element.querySelectorAll(STAR_RATING_SELECTOR);allStars.forEach((star=>{const starId=star.id;const icon=star.querySelector(".interactive-star-icon");if(icon){if(starId<=hoveredStarId){if(!icon.classList.contains("yellow-star-selected")&&!icon.classList.contains("primary-star-selected")&&!icon.classList.contains("subtle-star-selected")){icon.classList.add("star-hovered")}}else{icon.classList.remove("star-hovered")}}}))}removeStarHoverColors(){const allStars=this.element.querySelectorAll(STAR_RATING_SELECTOR);allStars.forEach((star=>{const icon=star.querySelector(".interactive-star-icon");if(icon){if(!icon.classList.contains("yellow-star-selected")&&!icon.classList.contains("primary-star-selected")&&!icon.classList.contains("subtle-star-selected")){icon.classList.remove("star-hovered")}}}))}isStarSelected(){return this.element.querySelectorAll(".yellow-star-selected, .primary-star-selected, .subtle-star-selected").length>0}handleFormReset(){const form=this.element.closest("form");if(form){form.addEventListener("reset",(()=>{var _a;(_a=this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR))==null?void 0:_a.setAttribute("value","");this.resetStarRatingValues()}))}}resetStarRatingValues(){const allStars=this.element.querySelectorAll(STAR_RATING_SELECTOR);allStars.forEach((star=>{const icon=star.querySelector(".interactive-star-icon");if(icon){icon.classList.remove("yellow-star-selected","primary-star-selected","subtle-star-selected")}}))}clearFormValidation(){const hiddenInput=this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR);if(hiddenInput.checkValidity()){const errorLabelElement=this.element.querySelector(".pb_body_kit_negative");if(errorLabelElement){errorLabelElement.remove()}}}setDefaultValue(){const hiddenInput=this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR);const defaultValue=hiddenInput.value;if(defaultValue){this.updateStarColors(defaultValue)}}}const RADIO_SELECTOR="[data-pb-radio-children]";const RADIO_WRAPPER_SELECTOR="[data-pb-radio-children-wrapper]";class PbRadio extends PbEnhancedElement{static get selector(){return RADIO_SELECTOR}connect(){const radioWrapperElement=this.element.parentElement.querySelector(RADIO_WRAPPER_SELECTOR);radioWrapperElement.addEventListener("click",(()=>{this.element.querySelector("input[type='radio']").click()}))}}const DRAGGABLE_SELECTOR="[data-pb-draggable]";const DRAGGABLE_CONTAINER=".pb_draggable_container";const NEEDS_CLONE=["shadow","outline","line"];class PbDraggable extends PbEnhancedElement{static get selector(){return DRAGGABLE_SELECTOR}connect(){this.state={items:[],dragData:{id:"",initialGroup:""},isDragging:"",activeContainer:""};this.draggedItem=null;this.draggedItemId=null;this.dragGhost=null;this.hasMultipleContainers=false;this.dragZoneType="";this.dragZoneColor="";document.addEventListener("DOMContentLoaded",(()=>this.bindEventListeners()))}setState(newState){this.state={...this.state,...newState};if(newState.items){this.element.dispatchEvent(new CustomEvent("pb-draggable-reorder",{detail:{reorderedItems:this.state.items,containerId:this.element.querySelector(DRAGGABLE_CONTAINER).id}}))}}bindEventListeners(){const containers=this.element.querySelectorAll(DRAGGABLE_CONTAINER);this.hasMultipleContainers=containers.length>1;this.element.querySelectorAll(".pb_draggable_item img").forEach((img=>img.setAttribute("draggable","false")));this.element.querySelectorAll(".pb_draggable_item").forEach((item=>{item.addEventListener("dragstart",this.handleDragStart.bind(this));item.addEventListener("dragend",this.handleDragEnd.bind(this));item.addEventListener("dragenter",this.handleDragEnter.bind(this))}));containers.forEach((c=>{c.addEventListener("dragover",this.handleDragOver.bind(this));c.addEventListener("drop",this.handleDrop.bind(this))}))}handleDragStart(event){if(event.target.tagName.toLowerCase()==="img"){event.preventDefault();return}const container=event.target.closest(DRAGGABLE_CONTAINER);this.draggedItem=event.target;this.draggedItemId=event.target.id;this.dragZoneType=this.element.dataset.dropZoneType||"";this.dragZoneColor=this.element.dataset.dropZoneColor||"";this.setState({dragData:{id:this.draggedItemId,initialGroup:container.id},isDragging:this.draggedItemId});this.draggedItem.classList.add("is_dragging",`drop_zone_${this.dragZoneType}`,`drop_zone_color_${this.dragZoneColor}`);if(event.dataTransfer){event.dataTransfer.effectAllowed="move";event.dataTransfer.setData("text/plain",this.draggedItemId);if(NEEDS_CLONE.includes(this.dragZoneType)){const ghost=this.draggedItem.cloneNode(true);ghost.classList.remove("is_dragging",`drop_zone_${this.dragZoneType}`,`drop_zone_color_${this.dragZoneColor}`);const{width:width,height:height}=this.draggedItem.getBoundingClientRect();Object.assign(ghost.style,{border:"none",width:`${width}px`,height:`${height}px`,position:"absolute",top:"-9999px",left:"-9999px",boxSizing:"border-box",zIndex:"9999"});document.body.appendChild(ghost);this.dragGhost=ghost;event.dataTransfer.setDragImage(ghost,width/2,height/2)}}if(this.dragZoneType!=="line"){requestAnimationFrame((()=>event.target.style.opacity="0.5"))}}handleDragEnter(event){if(!this.draggedItem||event.target===this.draggedItem)return;this.hasMultipleContainers?this.handleMultiContainerDragEnter(event):this.handleSingleContainerDragEnter(event)}handleSingleContainerDragEnter(event){const targetItem=event.target.closest(".pb_draggable_item");if(!targetItem)return;const container=targetItem.parentNode;const items=Array.from(container.children);const fromIdx=items.indexOf(this.draggedItem);const toIdx=items.indexOf(targetItem);if(fromIdx>toIdx){container.insertBefore(this.draggedItem,targetItem)}else{container.insertBefore(this.draggedItem,targetItem.nextSibling)}}handleMultiContainerDragEnter(event){const targetContainer=event.target.closest(DRAGGABLE_CONTAINER);const targetItem=event.target.closest(".pb_draggable_item");if(!targetContainer)return;if(!targetItem){const last=targetContainer.querySelector(".pb_draggable_item:last-child");last?targetContainer.insertBefore(this.draggedItem,last.nextSibling):targetContainer.appendChild(this.draggedItem);return}const items=Array.from(targetContainer.children);this.setState({items:items.map((i=>({id:i.id,container:targetContainer.id})))});const midY=targetItem.getBoundingClientRect().top+targetItem.getBoundingClientRect().height/2;if(event.clientY<midY){targetContainer.insertBefore(this.draggedItem,targetItem)}else{targetContainer.insertBefore(this.draggedItem,targetItem.nextSibling)}}handleDragOver(event){event.preventDefault();event.stopPropagation();this.hasMultipleContainers?this.handleMultiContainerDragOver(event):this.handleSingleContainerDragOver(event)}handleSingleContainerDragOver(event){const container=event.target.closest(DRAGGABLE_CONTAINER);if(container)container.classList.add("active_container")}handleMultiContainerDragOver(event){const container=event.target.matches(DRAGGABLE_CONTAINER)?event.target:event.target.closest(DRAGGABLE_CONTAINER);if(!container)return;this.setState({activeContainer:container.id});container.classList.add("active_container");const last=container.querySelector(".pb_draggable_item:last-child");if(!last||event.clientY>last.getBoundingClientRect().bottom){if(this.draggedItem&&this.draggedItem.parentNode!==container){container.appendChild(this.draggedItem)}}}handleDrop(event){event.preventDefault();event.stopPropagation();const container=event.target.matches(DRAGGABLE_CONTAINER)?event.target:event.target.closest(DRAGGABLE_CONTAINER);if(!container||!this.draggedItem)return;container.classList.remove("active_container");this.draggedItem.style.opacity="1";if(this.hasMultipleContainers&&!container.querySelector(".pb_draggable_item")){container.appendChild(this.draggedItem)}const reorderedItems=Array.from(this.element.querySelectorAll(".pb_draggable_item")).map((i=>({id:i.id,container:i.closest(DRAGGABLE_CONTAINER).id})));container.dataset.reorderedItems=JSON.stringify(reorderedItems);this.element.dispatchEvent(new CustomEvent("pb-draggable-reorder",{detail:{reorderedItems:reorderedItems,containerId:container.id}}));this.setState({items:reorderedItems,isDragging:"",activeContainer:""});this.draggedItem=null;this.draggedItemId=null}handleDragEnd(event){event.target.classList.remove("is_dragging",`drop_zone_${this.dragZoneType}`,`drop_zone_color_${this.dragZoneColor}`);event.target.style.opacity="1";if(this.dragGhost){document.body.removeChild(this.dragGhost);this.dragGhost=null}this.setState({isDragging:"",activeContainer:""});this.element.querySelectorAll(DRAGGABLE_CONTAINER).forEach((c=>c.classList.remove("active_container")));this.draggedItem=null;this.draggedItemId=null}}const OVERLAY_SELECTOR="[data-pb-overlay]";const OVERLAY_SCROLL_ELEMENT="[data-overlay-scroll-element]";const PREVIOUS_OVERLAY_CLASSNAME="[data-previous-overlay-classname]";const SUBSEQUENT_OVERLAY_CLASSNAME="[data-subsequent-overlay-classname]";class PbOverlay extends PbEnhancedElement{static get selector(){return OVERLAY_SELECTOR}get target(){return this.element.querySelector(OVERLAY_SCROLL_ELEMENT).children[0]}connect(){this.handleOverlayDynamic()}handleOverlayDynamic(){var _a,_b,_c;const isOverlayDynamic=(_a=this.element.dataset)==null?void 0:_a.overlayDynamic;if(isOverlayDynamic){const previousOverlayElement=this.element.querySelector(PREVIOUS_OVERLAY_CLASSNAME);const previousOverlayClassname=(_b=previousOverlayElement==null?void 0:previousOverlayElement.dataset)==null?void 0:_b.previousOverlayClassname;const subsequentOverlayElement=this.element.querySelector(SUBSEQUENT_OVERLAY_CLASSNAME);const subsequentOverlayClassname=(_c=subsequentOverlayElement==null?void 0:subsequentOverlayElement.dataset)==null?void 0:_c.subsequentOverlayClassname;const handleScrollChange=target=>{const{scrollLeft:scrollLeft,scrollWidth:scrollWidth,clientWidth:clientWidth}=target;const isScrollAtStart=scrollLeft===0;const isScrollAtEnd=scrollLeft+clientWidth>=scrollWidth-1;if(isScrollAtStart){previousOverlayElement.classList.remove(previousOverlayClassname)}else{previousOverlayElement.classList.add(previousOverlayClassname)}if(isScrollAtEnd){subsequentOverlayElement.classList.remove(subsequentOverlayClassname)}else{subsequentOverlayElement.classList.add(subsequentOverlayClassname)}};this.target.addEventListener("scroll",(event=>{handleScrollChange(event.target)}));handleScrollChange(this.target)}}disconnect(){var _a;if((_a=this.element.dataset)==null?void 0:_a.overlayDynamic){this.target.removeEventListener("scroll")}}}const SELECT_WRAPPER_SELECTOR="[data-pb-select]";const SELECT_VALIDATION_MESSAGE_CLASS$1=".pb_body_kit_negative";class PbSelect extends PbEnhancedElement{static get selector(){return SELECT_WRAPPER_SELECTOR}connect(){this.setValidationMessage()}setValidationMessage(){var _a;const validationMessage=(_a=this.element.dataset)==null?void 0:_a.validationMessage;if(validationMessage){const selectElement=this.element.querySelector("select");const setErrorTextContent=(text,timeout)=>{setTimeout((()=>{const errorMessageElement=this.element.querySelector(SELECT_VALIDATION_MESSAGE_CLASS$1);if(errorMessageElement){errorMessageElement.textContent=text}else{setErrorTextContent(text,100)}}),timeout)};selectElement.addEventListener("change",(e=>{if(!e.target.checkValidity()){setErrorTextContent(validationMessage,300)}}))}}}const DIALOG_WRAPPER_SELECTOR="[data-pb-dialog-wrapper]";class PbDialog extends PbEnhancedElement{constructor(){super(...arguments);__publicField(this,"handleCustomEvent",(event=>{var _a,_b,_c,_d,_e,_f;const dialogId=((_a=event.detail)==null?void 0:_a.dialogId)||((_b=this.element.querySelector("dialog"))==null?void 0:_b.id);const dialog=dialogId&&document.getElementById(dialogId);if(!dialog){console.warn(`[PbDialog] Could not find dialog with ID '${dialogId}'`);return}this.setupDialog();const action=((_c=event.detail)==null?void 0:_c.action)||"open";const knownActions=["open","close","clickConfirm","clickCancel"];if(knownActions.includes(action)){switch(action){case"open":if(!dialog.open)dialog.showModal();break;case"close":if(dialog.open)dialog.close((_d=event.detail)==null?void 0:_d.returnValue);break;case"clickConfirm":this.triggerButtonClick(dialog,event,"confirm");break;case"clickCancel":this.triggerButtonClick(dialog,event,"cancel");break}}else if(typeof((_e=event.detail)==null?void 0:_e.customAction)==="function"){event.detail.customAction({dialog:dialog,event:event})}else if((_f=window.pbDialogActions)==null?void 0:_f[action]){window.pbDialogActions[action]({dialog:dialog,event:event})}else{console.warn(`[PbDialog] Unknown action: ${action}`)}}))}static get selector(){return DIALOG_WRAPPER_SELECTOR}connect(){var _a;this.dialogElement=this.element.querySelector(".pb_dialog_rails");this.dialogId=(_a=this.dialogElement)==null?void 0:_a.id;this.managedTriggers=new Set;this.domContentLoadedHandler=()=>this.setupDialog();this.turboFrameLoadHandler=()=>this.setupDialog();window.addEventListener("DOMContentLoaded",this.domContentLoadedHandler);window.addEventListener("turbo:frame-load",this.turboFrameLoadHandler);const customEventTypeString=this.element.dataset.customEventType;if(customEventTypeString&&!this.element.hasAttribute("data-custom-event-handled")){this.customEventTypes=customEventTypeString.split(",").map((e=>e.trim())).filter(Boolean);this.customEventTypes.forEach((eventType=>{window.addEventListener(eventType,this.handleCustomEvent)}));this.element.setAttribute("data-custom-event-handled","true")}}disconnect(){if(this.domContentLoadedHandler){window.removeEventListener("DOMContentLoaded",this.domContentLoadedHandler)}if(this.turboFrameLoadHandler){window.removeEventListener("turbo:frame-load",this.turboFrameLoadHandler)}if(this.customEventTypes&&Array.isArray(this.customEventTypes)){this.customEventTypes.forEach((eventType=>{window.removeEventListener(eventType,this.handleCustomEvent)}))}this.managedTriggers.forEach((trigger=>{if(trigger._openDialogClickHandler){trigger.removeEventListener("click",trigger._openDialogClickHandler);delete trigger._openDialogClickHandler}if(trigger._closeDialogClickHandler){trigger.removeEventListener("click",trigger._closeDialogClickHandler);delete trigger._closeDialogClickHandler}}));if(this.dialogElement&&this.dialogElement._outsideClickHandler){this.dialogElement.removeEventListener("mousedown",this.dialogElement._outsideClickHandler);delete this.dialogElement._outsideClickHandler}}triggerButtonClick(dialog,event,type){var _a,_b;const buttonId=((_a=event.detail)==null?void 0:_a[`${type}ButtonId`])||((_b=dialog.closest("[data-pb-dialog-wrapper]"))==null?void 0:_b.dataset[`${type}ButtonId`]);const button=buttonId?document.getElementById(buttonId):dialog.querySelector(`[data-${type}-button]`);if(button){button.click()}else{console.warn(`[PbDialog] Could not find ${type} button for dialog`)}}setupDialog(){if(!this.dialogId)return;const openTrigger=document.querySelectorAll(`[data-open-dialog="${this.dialogId}"]`);const closeTrigger=document.querySelectorAll(`[data-close-dialog="${this.dialogId}"]`);const dialogs=this.dialogElement?[this.dialogElement]:[];const loadingButton=document.querySelector('[data-disable-with="Loading"]');if(loadingButton&&!loadingButton.dataset.listenerAttached){loadingButton.addEventListener("click",(function(){const okayLoadingButton=document.querySelector('[data-disable-with="Loading"]');const cancelButton=document.querySelector('[data-disable-cancel-with="Loading"]');let currentClass=okayLoadingButton.className;let cancelClass=cancelButton?cancelButton.className:"";let newClass=currentClass.replace("_enabled","_disabled_loading");let newCancelClass=cancelClass.replace("_enabled","_disabled");okayLoadingButton.disabled=true;if(cancelButton)cancelButton.disabled=true;okayLoadingButton.className=newClass;if(cancelButton)cancelButton.className=newCancelClass}));loadingButton.dataset.listenerAttached="true"}openTrigger.forEach((open=>{const originalClickHandler=open._openDialogClickHandler;if(originalClickHandler)open.removeEventListener("click",originalClickHandler);open._openDialogClickHandler=()=>{const openTriggerData=open.dataset.openDialog;const targetDialogOpen=document.getElementById(openTriggerData);if(targetDialogOpen&&!targetDialogOpen.open)targetDialogOpen.showModal()};open.addEventListener("click",open._openDialogClickHandler);this.managedTriggers.add(open)}));closeTrigger.forEach((close=>{const originalClickHandler=close._closeDialogClickHandler;if(originalClickHandler)close.removeEventListener("click",originalClickHandler);close._closeDialogClickHandler=()=>{const closeTriggerData=close.dataset.closeDialog;const targetDialogClose=document.getElementById(closeTriggerData);if(targetDialogClose)targetDialogClose.close()};close.addEventListener("click",close._closeDialogClickHandler);this.managedTriggers.add(close)}));dialogs.forEach((dialogElement=>{const originalMousedownHandler=dialogElement._outsideClickHandler;if(originalMousedownHandler)dialogElement.removeEventListener("mousedown",originalMousedownHandler);dialogElement._outsideClickHandler=event=>{const dialogParentDataset=dialogElement.parentElement.dataset;if(dialogParentDataset.overlayClick==="overlay_close")return;const dialogModal=event.target.getBoundingClientRect();const clickedOutsideDialogModal=event.clientX<dialogModal.left||event.clientX>dialogModal.right||event.clientY<dialogModal.top||event.clientY>dialogModal.bottom;if(clickedOutsideDialogModal){dialogElement.close();event.stopPropagation()}};dialogElement.addEventListener("mousedown",dialogElement._outsideClickHandler)}))}}const DATE_PICKER_WRAPPER_SELECTOR="[data-pb-date-picker]";const SELECT_VALIDATION_MESSAGE_CLASS=".pb_body_kit_negative";class PbDatePicker extends PbEnhancedElement{static get selector(){return DATE_PICKER_WRAPPER_SELECTOR}connect(){this.setValidationMessage()}setValidationMessage(){var _a;const validationMessage=(_a=this.element.dataset)==null?void 0:_a.validationMessage;const inputElement=this.element.querySelector("input");if(validationMessage){const setErrorTextContent=(text,timeout)=>{setTimeout((()=>{const errorMessageElement=this.element.querySelector(SELECT_VALIDATION_MESSAGE_CLASS);if(errorMessageElement){errorMessageElement.textContent=text}else{setErrorTextContent(text,100)}}),timeout)};inputElement.addEventListener("change",(e=>{if(!e.target.checkValidity()){setErrorTextContent(validationMessage,300)}}))}}}const MULTI_LEVEL_SELECT_SELECTOR="[data-multi_level_select_form]";class PbMultiLevelSelect extends PbEnhancedElement{static get selector(){return MULTI_LEVEL_SELECT_SELECTOR}get target(){return this.element.querySelector(".pb_body_kit_negative")}connect(){this.addEventListeners();this.observeHiddenInputs();this.observeRogueErrorInsideInnerContainer()}addEventListeners(){const inputElement=this.element.querySelector("input");inputElement.addEventListener("invalid",(()=>{this.handleErrorLabel(300)}));inputElement.addEventListener("blur",(()=>{this.justBlurred=true;setTimeout((()=>{this.justBlurred=false}),300)}))}handleErrorLabel(delay){setTimeout((()=>{const errorLabelElement=this.target;const wrapper=this.element.querySelector(".wrapper");if(errorLabelElement){errorLabelElement.remove();if(wrapper){if(wrapper.querySelector(".pb_body_kit_negative")){wrapper.querySelector(".pb_body_kit_negative").remove()}wrapper.appendChild(errorLabelElement)}this.element.classList.add("error")}else{this.handleErrorLabel(100)}}),delay)}observeHiddenInputs(){const container=this.element.querySelector(".input_inner_container");if(!container)return;this.mutationObserver=new MutationObserver((()=>{const hiddenInputs=container.querySelectorAll('input[type="hidden"]');if(hiddenInputs.length>0){this.clearError()}}));this.mutationObserver.observe(container,{childList:true})}observeRogueErrorInsideInnerContainer(){const container=this.element.querySelector(".input_inner_container");this.rogueErrorObserver=new MutationObserver((mutations=>{for(const mutation of mutations){for(const node of mutation.addedNodes){if(node.nodeType===Node.ELEMENT_NODE&&node.classList.contains("pb_body_kit_negative")){if(this.justBlurred){node.remove()}}}}}));this.rogueErrorObserver.observe(container,{childList:true,subtree:true})}clearError(e){const errorLabelElement=this.target;if(errorLabelElement){errorLabelElement.remove();this.element.classList.remove("error");this.element.querySelector("input").value=e.detail.value}}}const INDETERMINATE_MAIN_CHECKBOX_SELECTOR="[data-pb-checkbox-indeterminate-main='true']";class PbCheckbox extends PbEnhancedElement{static get selector(){return INDETERMINATE_MAIN_CHECKBOX_SELECTOR}connect(){const mainCheckboxWrapper=this.element;const mainCheckbox=mainCheckboxWrapper.querySelector("input");const directChildCheckboxes=document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);const getAllDescendantCheckboxes=()=>{const descendants=[];const queue=[...directChildCheckboxes];while(queue.length>0){const checkbox=queue.shift();descendants.push(checkbox);const checkboxWrapper=checkbox.closest('[data-pb-checkbox-indeterminate-main="true"]');if(checkboxWrapper){const childCheckboxes=document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${checkboxWrapper.id}"] input[type="checkbox"]`);queue.push(...childCheckboxes)}}const nonMainChildCheckboxes=document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);nonMainChildCheckboxes.forEach((cb=>{if(!descendants.includes(cb)){descendants.push(cb)}}));return descendants};const getCheckboxState=checkboxes=>{const checkedCount=checkboxes.filter((cb=>cb.checked)).length;const totalCount=checkboxes.length;return{allChecked:checkedCount===totalCount,noneChecked:checkedCount===0,indeterminate:!(checkedCount===totalCount||checkedCount===0),checkedCount:checkedCount,totalCount:totalCount}};const updateCheckboxVisualState=(checkbox,isIndeterminate,isChecked)=>{checkbox.indeterminate=isIndeterminate;checkbox.checked=isChecked};const updateCheckboxLabelAndIcons=(wrapper,isIndeterminate,checkedCount)=>{const checkAllLabel=wrapper.dataset.pbCheckboxIndeterminateMainLabelCheck??"Check All";const uncheckAllLabel=wrapper.dataset.pbCheckboxIndeterminateMainLabelUncheck??"Uncheck All";const text=checkedCount===0?checkAllLabel:uncheckAllLabel;const bodyKitElement=wrapper.getElementsByClassName("pb_body_kit")[0];if(bodyKitElement){bodyKitElement.textContent=text}const iconSpan=wrapper.querySelector("[data-pb-checkbox-icon-span]");if(iconSpan){const iconClassToAdd=isIndeterminate?"pb_checkbox_indeterminate":"pb_checkbox_checkmark";const iconClassToRemove=isIndeterminate?"pb_checkbox_checkmark":"pb_checkbox_indeterminate";iconSpan.classList.add(iconClassToAdd);iconSpan.classList.remove(iconClassToRemove)}const indeterminateIcon=wrapper.getElementsByClassName("indeterminate_icon")[0];const checkIcon=wrapper.getElementsByClassName("check_icon")[0];if(indeterminateIcon){indeterminateIcon.classList.toggle("hidden",!isIndeterminate)}if(checkIcon){checkIcon.classList.toggle("hidden",isIndeterminate)}};const updateMainCheckbox=()=>{const allDescendantCheckboxes2=getAllDescendantCheckboxes();const state=getCheckboxState(allDescendantCheckboxes2);updateCheckboxVisualState(mainCheckbox,state.indeterminate,state.allChecked);updateCheckboxLabelAndIcons(mainCheckboxWrapper,state.indeterminate,state.checkedCount)};const updateParentCheckboxes=()=>{const parentId=mainCheckboxWrapper.dataset.pbCheckboxIndeterminateParent;if(parentId){const parentCheckbox=document.getElementById(parentId);if(parentCheckbox){const parentWrapper=parentCheckbox.closest('[data-pb-checkbox-indeterminate-main="true"]');if(parentWrapper){const parentInstance=parentWrapper.pbCheckboxInstance;if(parentInstance&&parentInstance.updateMainCheckbox){parentInstance.updateMainCheckbox();parentInstance.updateParentCheckboxes()}}}}};const setupNonMainCheckboxUpdates=()=>{const allCheckboxesWithChildren=document.querySelectorAll('input[type="checkbox"]');allCheckboxesWithChildren.forEach((cb=>{const checkboxWrapper=cb.closest('[data-pb-checkbox-indeterminate-main="true"]');if(checkboxWrapper&&checkboxWrapper!==mainCheckboxWrapper){return}const childCheckboxes=document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${cb.id}"] input[type="checkbox"]`);if(childCheckboxes.length>0){childCheckboxes.forEach((childCb=>{childCb.addEventListener("change",(()=>{const state=getCheckboxState(Array.from(childCheckboxes));updateCheckboxVisualState(cb,state.indeterminate,state.allChecked);const mainCheckboxes=document.querySelectorAll('[data-pb-checkbox-indeterminate-main="true"]');mainCheckboxes.forEach((mainCb=>{const mainInstance=mainCb.pbCheckboxInstance;if(mainInstance&&mainInstance.updateMainCheckbox){setTimeout((()=>{mainInstance.updateMainCheckbox()}),0)}}))}))}))}}))};updateMainCheckbox();mainCheckbox.addEventListener("change",(function(){const allDescendantCheckboxes2=getAllDescendantCheckboxes();const state=getCheckboxState(allDescendantCheckboxes2);if(state.indeterminate){allDescendantCheckboxes2.forEach((cb=>{cb.checked=false;cb.dispatchEvent(new Event("checkbox-programmatic-change",{bubbles:true}))}));this.checked=false}else{allDescendantCheckboxes2.forEach((cb=>{cb.checked=this.checked;cb.dispatchEvent(new Event("checkbox-programmatic-change",{bubbles:true}))}))}updateMainCheckbox();setTimeout((()=>{updateParentCheckboxes()}),0);triggerAllMainCheckboxUpdates()}));directChildCheckboxes.forEach((cb=>{cb.addEventListener("change",updateMainCheckbox)}));const allDescendantCheckboxes=getAllDescendantCheckboxes();allDescendantCheckboxes.forEach((cb=>{if(!Array.from(directChildCheckboxes).includes(cb)){cb.addEventListener("change",updateMainCheckbox)}}));const allChildCheckboxes=document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);allChildCheckboxes.forEach((cb=>{if(!allDescendantCheckboxes.includes(cb)){cb.addEventListener("change",updateMainCheckbox)}}));let updateTimeout=null;const triggerAllMainCheckboxUpdates=()=>{if(updateTimeout){clearTimeout(updateTimeout)}updateTimeout=setTimeout((()=>{const mainCheckboxes=document.querySelectorAll('[data-pb-checkbox-indeterminate-main="true"]');mainCheckboxes.forEach((mainCb=>{const mainInstance=mainCb.pbCheckboxInstance;if(mainInstance&&mainInstance.updateMainCheckbox){mainInstance.updateMainCheckbox()}}))}),10)};const originalUpdateMainCheckbox=updateMainCheckbox;const enhancedUpdateMainCheckbox=()=>{originalUpdateMainCheckbox();triggerAllMainCheckboxUpdates()};mainCheckboxWrapper.pbCheckboxInstance={updateMainCheckbox:enhancedUpdateMainCheckbox,updateParentCheckboxes:updateParentCheckboxes};setupNonMainCheckboxUpdates()}}const BUTTON_SELECTOR="[data-pb-button-managed]";class PbButton extends PbEnhancedElement{static get selector(){return BUTTON_SELECTOR}connect(){this._attrManaged=this._attributesPresent();this.element._pbButton=this;this._onClick=e=>{if(this.isDisabled()){e.preventDefault();e.stopImmediatePropagation()}};this.element.addEventListener("click",this._onClick,true);if(this._attrManaged)this._syncClassesFromAttributes();this._observer=new MutationObserver((()=>{this._attrManaged=true;this._syncClassesFromAttributes()}));this._observer.observe(this.element,{attributes:true,attributeFilter:["disabled","aria-disabled"]})}disconnect(){var _a;this.element.removeEventListener("click",this._onClick,true);(_a=this._observer)==null?void 0:_a.disconnect();delete this.element._pbButton}disable(){this.setDisabled(true)}enable(){this.setDisabled(false)}setDisabled(state){if(this._isButton()){state?this.element.setAttribute("disabled","disabled"):this.element.removeAttribute("disabled")}else{state?this.element.setAttribute("aria-disabled","true"):this.element.removeAttribute("aria-disabled")}this._attrManaged=true;this._applyClassState(state)}isDisabled(){if(this._isButton()){if(this.element.hasAttribute("disabled"))return true;if(this._attrManaged&&!this.element.hasAttribute("disabled"))return false}else{const aria=this.element.getAttribute("aria-disabled");if(aria==="true")return true;if(this._attrManaged&&aria!=="true")return false}return this.element.classList.contains("pb_button_disabled")}_isButton(){return this.element.tagName==="BUTTON"}_attributesPresent(){return this.element.hasAttribute("disabled")||this.element.hasAttribute("aria-disabled")}_syncClassesFromAttributes(){const state=this._attrDisabledState();const disabled=state===null?false:state;this._applyClassState(disabled)}_attrDisabledState(){if(this._isButton()){return this.element.hasAttribute("disabled")?true:null}else{const aria=this.element.getAttribute("aria-disabled");if(aria==="true")return true;if(aria==="false")return false;return this.element.hasAttribute("aria-disabled")?false:null}}_applyClassState(disabled){this.element.classList.toggle("pb_button_disabled",!!disabled);this.element.classList.toggle("pb_button_enabled",!disabled)}}const TIME_PICKER_SELECTOR="[data-pb-time-picker]";const VALIDATION_MESSAGE_CLASS=".pb_body_kit_negative";class PbTimePicker extends PbEnhancedElement{static get selector(){return TIME_PICKER_SELECTOR}connect(){this.setValidationMessage()}setValidationMessage(){var _a;const element=this.element;const validationMessage=(_a=element.dataset)==null?void 0:_a.validationMessage;const inputElement=element.querySelector("input");if(validationMessage){const setErrorTextContent=(text,timeout)=>{setTimeout((()=>{const errorMessageElement=element.querySelector(VALIDATION_MESSAGE_CLASS);if(errorMessageElement){errorMessageElement.textContent=text}else{setErrorTextContent(text,100)}}),timeout)};inputElement==null?void 0:inputElement.addEventListener("change",(e=>{const target=e.target;if(!target.checkValidity()){setErrorTextContent(validationMessage,300)}}))}}}const KIT_SELECTOR='[class^="pb_"][class*="_kit"]';const ERROR_MESSAGE_SELECTOR=".pb_body_kit_negative";const FORM_SELECTOR='form[data-pb-form-validation="true"]';const REQUIRED_FIELDS_SELECTOR="input[required],textarea[required],select[required]";const PHONE_NUMBER_VALIDATION_ERROR_SELECTOR='[data-pb-phone-validation-error="true"]';const FIELD_EVENTS=["change","valid","invalid"];class PbFormValidation extends PbEnhancedElement{static get selector(){return FORM_SELECTOR}connect(){this.formValidationFields.forEach((field=>{const isPhoneNumberInput=field.closest(".pb_phone_number_input");if(isPhoneNumberInput)return;const isTimePickerInput=field.closest(".pb_time_picker");if(isTimePickerInput)return;FIELD_EVENTS.forEach((e=>{field.addEventListener(e,debounce((event=>{this.validateFormField(event)}),250),false)}))}));this.element.addEventListener("submit",(event=>{setTimeout((()=>{if(this.hasPhoneNumberValidationErrors()){event.preventDefault();return false}}),0)}))}validateFormField(event){event.preventDefault();const{target:target}=event;target.setCustomValidity("");const isValid=event.target.validity.valid;if(isValid){this.clearError(target)}else{this.showValidationMessage(target)}}showValidationMessage(target){const{parentElement:parentElement}=target;const kitElement=parentElement.closest(KIT_SELECTOR);if(!kitElement)return;const isPhoneNumberInput=kitElement.classList.contains("pb_phone_number_input");const isTimePickerInput=kitElement.classList.contains("pb_time_picker");this.clearError(target);kitElement.classList.add("error");if(!isPhoneNumberInput&&!isTimePickerInput){const errorMessageContainer=this.errorMessageContainer;if(target.dataset.message)target.setCustomValidity(target.dataset.message);errorMessageContainer.innerHTML=target.validationMessage;parentElement.appendChild(errorMessageContainer)}}clearError(target){const{parentElement:parentElement}=target;const kitElement=parentElement.closest(KIT_SELECTOR);if(kitElement)kitElement.classList.remove("error");const errorMessageContainer=parentElement.querySelector(ERROR_MESSAGE_SELECTOR);if(errorMessageContainer)errorMessageContainer.remove()}hasPhoneNumberValidationErrors(){const phoneNumberErrors=this.element.querySelectorAll(PHONE_NUMBER_VALIDATION_ERROR_SELECTOR);return phoneNumberErrors.length>0}get errorMessageContainer(){const errorContainer=document.createElement("div");const kitClassName=ERROR_MESSAGE_SELECTOR.replace(/\./,"");errorContainer.classList.add(kitClassName);return errorContainer}get formValidationFields(){return this._formValidationFields=this._formValidationFields||this.element.querySelectorAll(REQUIRED_FIELDS_SELECTOR)}}window.PbFormValidation=PbFormValidation;const kits=[PbTextInput,PbCopyButton,PbCollapsible,PbPopover,PbTooltip,PbFixedConfirmationToast,PbTypeahead,PbTable,PbTextarea,PbDropdown,PbAdvancedTable,PbFlatAdvancedTable,PbNav,PbStarRating,PbRadio,PbDraggable,PbOverlay,PbSelect,PbDialog,PbDatePicker,PbMultiLevelSelect,PbCheckbox,PbButton,PbTimePicker];kits.forEach((kit=>PbKitRegistry$1.register(kit)));PbKitRegistry$1.start();addCopyEventListeners();window.formHelper=formHelper;window.datePickerHelper=datePickerHelper;
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "16.3.0"
5
- VERSION = "16.4.0.pre.rc.1"
5
+ VERSION = "16.4.0.pre.rc.2"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.4.0.pre.rc.1
4
+ version: 16.4.0.pre.rc.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2026-03-04 00:00:00.000000000 Z
12
+ date: 2026-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -3867,6 +3867,7 @@ files:
3867
3867
  - app/pb_kits/playbook/utilities/_vertical_align.scss
3868
3868
  - app/pb_kits/playbook/utilities/_width.scss
3869
3869
  - app/pb_kits/playbook/utilities/deprecated.ts
3870
+ - app/pb_kits/playbook/utilities/domHelpers.ts
3870
3871
  - app/pb_kits/playbook/utilities/emojiMask.ts
3871
3872
  - app/pb_kits/playbook/utilities/flexbox_global_props/_align_content.scss
3872
3873
  - app/pb_kits/playbook/utilities/flexbox_global_props/_align_items.scss