playbook_ui 15.0.0.pre.alpha.popovertesting10431 → 15.0.0.pre.alpha.removewebpacker10432

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.
@@ -1 +1 @@
1
- import WebpackerReact from"webpacker-react";import{g as getDefaultExportFromCjs}from"./chunks/lib-82dcKEqL.js";import{G as Gauge,L as LineGraph,C as CircleChart,B as BarGraph}from"./chunks/_line_graph-smu35i9u.js";import{P as PhoneNumberInput,T as Typeahead,R as RichTextEditor,a as Passphrase,L as Legend,M as MultiLevelSelect,D as DistributionBar}from"./chunks/_typeahead-C5hUPymw.js";import"react";import"react/jsx-runtime";import"react-trix";import"trix";import"react-dom";import"react-is";var ujs$1={};var hasRequiredUjs;function requireUjs(){if(hasRequiredUjs)return ujs$1;hasRequiredUjs=1;Object.defineProperty(ujs$1,"__esModule",{value:true});var ujs2={handleEvent:function handleEvent(eventName,callback){var _ref=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{once:false},once=_ref.once;var $=typeof window.jQuery!=="undefined"&&window.jQuery;if($){if(once){$(document).one(eventName,callback)}else{$(document).on(eventName,callback)}}else{document.addEventListener(eventName,callback,{once:once})}},setup:function setup(onMount,onUnmount){var $=typeof window.jQuery!=="undefined"&&window.jQuery;var Turbolinks=window.Turbolinks;if(typeof Turbolinks!=="undefined"&&Turbolinks.supported){if(typeof Turbolinks.EVENTS!=="undefined"){this.turbolinksClassic(onMount,onUnmount)}else if(typeof Turbolinks.controller!=="undefined"){this.turbolinks5(onMount,onUnmount)}else{this.turbolinksClassicDeprecated(onMount,onUnmount)}}else if($&&typeof $.pjax==="function"){this.pjax(onMount,onUnmount)}else{this.native(onMount)}},turbolinks5:function turbolinks5(onMount,onUnmount){this.handleEvent("turbolinks:load",onMount,{once:true});this.handleEvent("turbolinks:render",onMount);this.handleEvent("turbolinks:before-render",onUnmount)},turbolinksClassic:function turbolinksClassic(onMount,onUnmount){var Turbolinks=window.Turbolinks;this.handleEvent(Turbolinks.EVENTS.CHANGE,onMount);this.handleEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,onUnmount)},turbolinksClassicDeprecated:function turbolinksClassicDeprecated(onMount,onUnmount){var Turbolinks=window.Turbolinks;Turbolinks.pagesCached(0);this.handleEvent("page:change",onMount);this.handleEvent("page:receive",onUnmount)},pjax:function pjax(onMount,onUnmount){this.handleEvent("ready",onMount);this.handleEvent("pjax:end",onMount);this.handleEvent("pjax:beforeReplace",onUnmount)},native:function native(onMount){var $=typeof window.jQuery!=="undefined"&&window.jQuery;if($){$((function(){return onMount()}))}else if("addEventListener"in window){document.addEventListener("DOMContentLoaded",onMount)}else{window.attachEvent("onload",onMount)}}};ujs$1.default=ujs2;return ujs$1}var ujsExports=requireUjs();const ujs=getDefaultExportFromCjs(ujsExports);WebpackerReact.registerComponents({BarGraph:BarGraph,CircleChart:CircleChart,DistributionBar:DistributionBar,MultiLevelSelect:MultiLevelSelect,Legend:Legend,LineGraph:LineGraph,Passphrase:Passphrase,RichTextEditor:RichTextEditor,Typeahead:Typeahead,Gauge:Gauge,PhoneNumberInput:PhoneNumberInput});const mountPlaybookReactKits=()=>{WebpackerReact.mountComponents()};const unmountPlaybookReactKits=()=>{WebpackerReact.unmountComponents()};ujs.setup(mountPlaybookReactKits,unmountPlaybookReactKits);const observer=new MutationObserver((()=>{mountPlaybookReactKits()}));observer.observe(document.body,{childList:true,subtree:true});
1
+ import{C as ComponentRegistry}from"./chunks/componentRegistry-DtWHGZb5.js";import{G as Gauge,L as LineGraph,C as CircleChart,B as BarGraph}from"./chunks/_line_graph-C0LUCC-Z.js";import{P as PhoneNumberInput,T as Typeahead,R as RichTextEditor,a as Passphrase,L as Legend,M as MultiLevelSelect,D as DistributionBar}from"./chunks/_typeahead-BGJ0eMvl.js";import"react";import"react-dom";import"react/jsx-runtime";import"./chunks/lib-QZuu1ltS.js";import"react-trix";import"trix";import"react-is";function mountComponents(){ComponentRegistry.mountComponents()}if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",mountComponents)}else{mountComponents()}document.addEventListener("turbo:load",mountComponents);document.addEventListener("turbo:render",mountComponents);document.addEventListener("page:load",mountComponents);ComponentRegistry.registerComponents({BarGraph:BarGraph,CircleChart:CircleChart,DistributionBar:DistributionBar,MultiLevelSelect:MultiLevelSelect,Legend:Legend,LineGraph:LineGraph,Passphrase:Passphrase,RichTextEditor:RichTextEditor,Typeahead:Typeahead,Gauge:Gauge,PhoneNumberInput:PhoneNumberInput});const mountPlaybookReactKits=()=>{ComponentRegistry.mountComponents()};const observer=new MutationObserver((()=>{mountPlaybookReactKits()}));observer.observe(document.body,{childList:true,subtree:true});
@@ -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,f as formHelper,b as datePickerHelper,e as PbPopover,i as PbTooltip,j as PbTypeahead,k as PbTable,l as PbTextarea}from"./chunks/lib-82dcKEqL.js";import{I as INPUTMASKS}from"./chunks/_typeahead-C5hUPymw.js";import"./chunks/pb_form_validation-CYLBbwKB.js";import"./chunks/lazysizes-B7xYodB-.js";import"./playbook-rails-react-bindings.js";import"react";import"react/jsx-runtime";import"react-trix";import"trix";import"react-dom";import"react-is";import"webpacker-react";import"./chunks/_line_graph-smu35i9u.js";class PbTextInput extends PbEnhancedElement{static get selector(){return'[data-pb-input-mask="true"]'}connect(){this.handleInput=this.handleInput.bind(this);this.element.addEventListener("input",this.handleInput);this.handleInput()}disconnect(){this.element.removeEventListener("input",this.handleInput)}handleInput(){var _a;const maskType=this.element.getAttribute("mask");const cursorPosition=this.element.selectionStart;const rawValue=this.element.value;let formattedValue=rawValue;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(rawValue)}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}}this.element.value=formattedValue;setCursorPosition(this.element,cursorPosition,rawValue,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.element.addEventListener("click",(()=>{this.toggleElement(this.target)}));if(this.target.classList.contains("is-visible")){this.displayUpArrow()}else{this.displayDownArrow()}document.addEventListener(`${this.target.id}`,(()=>{this.toggleElement(this.target)}))}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 classListValues=element.classList.value;const hasAutoCloseClass=classListValues.includes("auto_close");if(hasAutoCloseClass){const classList=classListValues.split(" ");const autoCloseValue=classList[classList.length-1].split("_")[2];const autoCloseIntValue=parseInt(autoCloseValue);setTimeout((()=>{this.removeToast(element)}),autoCloseIntValue)}}}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.init()}init(){this.dropdownElement.addEventListener("keydown",this.handleKeyDown.bind(this));if(this.searchInput){this.searchInput.addEventListener("input",(()=>this.openDropdownIfClosed()))}}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="#dropdown_open_icon";const UP_ARROW_SELECTOR$1="#dropdown_close_icon";const OPTION_SELECTOR="[data-dropdown-option-label]";const CUSTOM_DISPLAY_SELECTOR="[data-dropdown-custom-trigger]";const DROPDOWN_TRIGGER_DISPLAY="#dropdown_trigger_display";const DROPDOWN_PLACEHOLDER="[data-dropdown-placeholder]";const DROPDOWN_INPUT="#dropdown-selected-option";const SEARCH_INPUT_SELECTOR="[data-dropdown-autocomplete]";const SEARCH_BAR_SELECTOR="[data-dropdown-search]";const CLEAR_ICON_SELECTOR="#dropdown_clear_icon";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.keyboardHandler=new PbDropdownKeyboard(this);this.isMultiSelect=this.element.dataset.pbDropdownMultiSelect==="true";this.formPillProps=this.element.dataset.formPillProps?JSON.parse(this.element.dataset.formPillProps):{};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);if(this.clearBtn){this.clearBtn.style.display="none";this.clearBtn.addEventListener("click",(e=>{e.stopPropagation();this.clearSelection()}))}this.updateClearButton()}updateClearButton(){if(!this.clearBtn)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;customTrigger.addEventListener("click",(()=>this.toggleElement(this.target)));this.target.addEventListener("click",this.handleOptionClick.bind(this));document.addEventListener("click",this.handleDocumentClick.bind(this),true)}bindSearchBar(){this.searchBar=this.element.querySelector(SEARCH_BAR_SELECTOR);if(!this.searchBar)return;this.searchBar.addEventListener("input",(e=>this.handleSearch(e.target.value)))}bindSearchInput(){var _a;this.searchInput=this.element.querySelector(SEARCH_INPUT_SELECTOR);if(!this.searchInput)return;(_a=this.element.querySelector(TRIGGER_SELECTOR))==null?void 0:_a.addEventListener("click",(()=>this.searchInput.focus()));this.searchInput.addEventListener("input",(e=>this.handleSearch(e.target.value)))}adjustDropdownHeight(){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}))}}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;if(this.isClickOutside(event)&&this.target.classList.contains("open")){this.hideElement(this.target);this.updateArrowDisplay(false)}}isClickOutside(event){const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);if(customTrigger){return!customTrigger.contains(event.target)}else{const triggerElement=this.element.querySelector(TRIGGER_SELECTOR);const containerElement=this.element.parentNode.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){const triggerElement=this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);const customDisplayElement=this.element.querySelector("#dropdown_trigger_custom_display");if(triggerElement){if(!this.isMultiSelect){const selectedLabel=JSON.parse(value).label;triggerElement.textContent=selectedLabel;this.emitSelectionChange()}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);if(customTrigger){if(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");elem.style.height=elem.scrollHeight+"px"}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(input.checkValidity()){const dropdownWrapperElement=input.closest(".dropdown_wrapper");dropdownWrapperElement.classList.remove("error");const errorLabelElement=dropdownWrapperElement.querySelector(".pb_body_kit_negative");if(errorLabelElement){errorLabelElement.remove()}}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()}}}}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");this.setTriggerElementText(JSON.parse(selectedOption.dataset.dropdownOptionLabel).label)}}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("#dropdown_pills_wrapper");const placeholder=this.element.querySelector("#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(){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("#dropdown_trigger_custom_display");if(customDisplay){customDisplay.style.display="none"}this.resetDropdownValue();this.updatePills();this.updateClearButton();this.syncHiddenInputs();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 id=JSON.parse(raw).id;const inp=document.createElement("input");inp.type="hidden";inp.name=name;inp.value=id;inp.dataset.generated="true";baseInput.insertAdjacentElement("afterend",inp)}));baseInput.value=""}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("bg-white","bg-silver")}}else{if(rowEl){rowEl.classList.remove("bg-row-selection");if(this.isRowExpanded(rowEl)){rowEl.classList.remove("bg-silver");rowEl.classList.add("bg-white")}else{rowEl.classList.remove("bg-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("bg-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("bg-white")}else{rowEl.classList.remove("bg-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 prefixedAncestorIds=ancestorIds.map((id=>`${childRow.id}_${id}`));const allAncestorsExpanded=prefixedAncestorIds.every((id=>_PbAdvancedTable.expandedRows.has(id)));const checkIfParentIsExpanded=()=>{if(dataContent.endsWith("sr")){const parentRowId=childRow.dataset.rowParent;const isParentVisible=childRow.previousElementSibling.classList.contains("is-visible");if(parentRowId){const isInSet=_PbAdvancedTable.expandedRows.has(parentRowId);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("bg-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("bg-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("bg-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(){window.addEventListener("DOMContentLoaded",(()=>this.setupDialog()));window.addEventListener("turbo:frame-load",(()=>this.setupDialog()));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.customEventTypes&&Array.isArray(this.customEventTypes)){this.customEventTypes.forEach((eventType=>{window.removeEventListener(eventType,this.handleCustomEvent)}))}}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(){const openTrigger=document.querySelectorAll("[data-open-dialog]");const closeTrigger=document.querySelectorAll("[data-close-dialog]");const dialogs=document.querySelectorAll(".pb_dialog_rails");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)}));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)}));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()}}PbTextInput.start();PbCopyButton.start();addCopyEventListeners();window.formHelper=formHelper;window.datePickerHelper=datePickerHelper;PbCollapsible.start();PbPopover.start();PbTooltip.start();PbFixedConfirmationToast.start();PbTypeahead.start();PbTable.start();PbTextarea.start();PbDropdown.start();PbAdvancedTable.start();PbFlatAdvancedTable.start();PbNav.start();PbStarRating.start();PbRadio.start();PbDraggable.start();PbOverlay.start();PbSelect.start();PbDialog.start();PbDatePicker.start();PbMultiLevelSelect.start();PbCheckbox.start();
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,f as formHelper,b as datePickerHelper,e as PbPopover,g as PbTooltip,i as PbTypeahead,j as PbTable,k as PbTextarea}from"./chunks/lib-QZuu1ltS.js";import{I as INPUTMASKS}from"./chunks/_typeahead-BGJ0eMvl.js";import"./chunks/pb_form_validation-CleM960_.js";import"./chunks/lazysizes-B7xYodB-.js";import"./playbook-rails-react-bindings.js";import"react";import"react/jsx-runtime";import"react-trix";import"trix";import"react-dom";import"react-is";import"./chunks/componentRegistry-DtWHGZb5.js";import"./chunks/_line_graph-C0LUCC-Z.js";class PbTextInput extends PbEnhancedElement{static get selector(){return'[data-pb-input-mask="true"]'}connect(){this.handleInput=this.handleInput.bind(this);this.element.addEventListener("input",this.handleInput);this.handleInput()}disconnect(){this.element.removeEventListener("input",this.handleInput)}handleInput(){var _a;const maskType=this.element.getAttribute("mask");const cursorPosition=this.element.selectionStart;const rawValue=this.element.value;let formattedValue=rawValue;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(rawValue)}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}}this.element.value=formattedValue;setCursorPosition(this.element,cursorPosition,rawValue,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.element.addEventListener("click",(()=>{this.toggleElement(this.target)}));if(this.target.classList.contains("is-visible")){this.displayUpArrow()}else{this.displayDownArrow()}document.addEventListener(`${this.target.id}`,(()=>{this.toggleElement(this.target)}))}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 classListValues=element.classList.value;const hasAutoCloseClass=classListValues.includes("auto_close");if(hasAutoCloseClass){const classList=classListValues.split(" ");const autoCloseValue=classList[classList.length-1].split("_")[2];const autoCloseIntValue=parseInt(autoCloseValue);setTimeout((()=>{this.removeToast(element)}),autoCloseIntValue)}}}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.init()}init(){this.dropdownElement.addEventListener("keydown",this.handleKeyDown.bind(this));if(this.searchInput){this.searchInput.addEventListener("input",(()=>this.openDropdownIfClosed()))}}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="#dropdown_open_icon";const UP_ARROW_SELECTOR$1="#dropdown_close_icon";const OPTION_SELECTOR="[data-dropdown-option-label]";const CUSTOM_DISPLAY_SELECTOR="[data-dropdown-custom-trigger]";const DROPDOWN_TRIGGER_DISPLAY="#dropdown_trigger_display";const DROPDOWN_PLACEHOLDER="[data-dropdown-placeholder]";const DROPDOWN_INPUT="#dropdown-selected-option";const SEARCH_INPUT_SELECTOR="[data-dropdown-autocomplete]";const SEARCH_BAR_SELECTOR="[data-dropdown-search]";const CLEAR_ICON_SELECTOR="#dropdown_clear_icon";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.keyboardHandler=new PbDropdownKeyboard(this);this.isMultiSelect=this.element.dataset.pbDropdownMultiSelect==="true";this.formPillProps=this.element.dataset.formPillProps?JSON.parse(this.element.dataset.formPillProps):{};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);if(this.clearBtn){this.clearBtn.style.display="none";this.clearBtn.addEventListener("click",(e=>{e.stopPropagation();this.clearSelection()}))}this.updateClearButton()}updateClearButton(){if(!this.clearBtn)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;customTrigger.addEventListener("click",(()=>this.toggleElement(this.target)));this.target.addEventListener("click",this.handleOptionClick.bind(this));document.addEventListener("click",this.handleDocumentClick.bind(this),true)}bindSearchBar(){this.searchBar=this.element.querySelector(SEARCH_BAR_SELECTOR);if(!this.searchBar)return;this.searchBar.addEventListener("input",(e=>this.handleSearch(e.target.value)))}bindSearchInput(){var _a;this.searchInput=this.element.querySelector(SEARCH_INPUT_SELECTOR);if(!this.searchInput)return;(_a=this.element.querySelector(TRIGGER_SELECTOR))==null?void 0:_a.addEventListener("click",(()=>this.searchInput.focus()));this.searchInput.addEventListener("input",(e=>this.handleSearch(e.target.value)))}adjustDropdownHeight(){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}))}}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;if(this.isClickOutside(event)&&this.target.classList.contains("open")){this.hideElement(this.target);this.updateArrowDisplay(false)}}isClickOutside(event){const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);if(customTrigger){return!customTrigger.contains(event.target)}else{const triggerElement=this.element.querySelector(TRIGGER_SELECTOR);const containerElement=this.element.parentNode.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){const triggerElement=this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);const customDisplayElement=this.element.querySelector("#dropdown_trigger_custom_display");if(triggerElement){if(!this.isMultiSelect){const selectedLabel=JSON.parse(value).label;triggerElement.textContent=selectedLabel;this.emitSelectionChange()}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);if(customTrigger){if(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");elem.style.height=elem.scrollHeight+"px"}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(input.checkValidity()){const dropdownWrapperElement=input.closest(".dropdown_wrapper");dropdownWrapperElement.classList.remove("error");const errorLabelElement=dropdownWrapperElement.querySelector(".pb_body_kit_negative");if(errorLabelElement){errorLabelElement.remove()}}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()}}}}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");this.setTriggerElementText(JSON.parse(selectedOption.dataset.dropdownOptionLabel).label)}}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("#dropdown_pills_wrapper");const placeholder=this.element.querySelector("#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(){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("#dropdown_trigger_custom_display");if(customDisplay){customDisplay.style.display="none"}this.resetDropdownValue();this.updatePills();this.updateClearButton();this.syncHiddenInputs();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 id=JSON.parse(raw).id;const inp=document.createElement("input");inp.type="hidden";inp.name=name;inp.value=id;inp.dataset.generated="true";baseInput.insertAdjacentElement("afterend",inp)}));baseInput.value=""}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("bg-white","bg-silver")}}else{if(rowEl){rowEl.classList.remove("bg-row-selection");if(this.isRowExpanded(rowEl)){rowEl.classList.remove("bg-silver");rowEl.classList.add("bg-white")}else{rowEl.classList.remove("bg-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("bg-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("bg-white")}else{rowEl.classList.remove("bg-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 prefixedAncestorIds=ancestorIds.map((id=>`${childRow.id}_${id}`));const allAncestorsExpanded=prefixedAncestorIds.every((id=>_PbAdvancedTable.expandedRows.has(id)));const checkIfParentIsExpanded=()=>{if(dataContent.endsWith("sr")){const parentRowId=childRow.dataset.rowParent;const isParentVisible=childRow.previousElementSibling.classList.contains("is-visible");if(parentRowId){const isInSet=_PbAdvancedTable.expandedRows.has(parentRowId);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("bg-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("bg-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("bg-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(){window.addEventListener("DOMContentLoaded",(()=>this.setupDialog()));window.addEventListener("turbo:frame-load",(()=>this.setupDialog()));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.customEventTypes&&Array.isArray(this.customEventTypes)){this.customEventTypes.forEach((eventType=>{window.removeEventListener(eventType,this.handleCustomEvent)}))}}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(){const openTrigger=document.querySelectorAll("[data-open-dialog]");const closeTrigger=document.querySelectorAll("[data-close-dialog]");const dialogs=document.querySelectorAll(".pb_dialog_rails");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)}));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)}));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()}}PbTextInput.start();PbCopyButton.start();addCopyEventListeners();window.formHelper=formHelper;window.datePickerHelper=datePickerHelper;PbCollapsible.start();PbPopover.start();PbTooltip.start();PbFixedConfirmationToast.start();PbTypeahead.start();PbTable.start();PbTextarea.start();PbDropdown.start();PbAdvancedTable.start();PbFlatAdvancedTable.start();PbNav.start();PbStarRating.start();PbRadio.start();PbDraggable.start();PbOverlay.start();PbSelect.start();PbDialog.start();PbDatePicker.start();PbMultiLevelSelect.start();PbCheckbox.start();
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "action_view/railtie"
4
- require "webpacker/react"
5
4
  require "view_component"
6
5
 
7
6
  module Playbook
@@ -122,7 +122,7 @@ module Playbook
122
122
  html_options.each do |key, value|
123
123
  if key == :style && value.is_a?(Hash)
124
124
  # Convert style hash to CSS string
125
- merged[:style] = value.map { |k, v| "#{k.to_s.gsub('_', '-')}: #{v}" }.join("; ")
125
+ merged[:style] = value.map { |k, v| "#{k.to_s.tr('_', '-')}: #{v}" }.join("; ")
126
126
  else
127
127
  merged[key] = value
128
128
  end
@@ -136,6 +136,24 @@ module Playbook
136
136
  merged.deep_merge(data_attributes)
137
137
  end
138
138
 
139
+ # Custom react_component helper to replace Webpacker React
140
+ def react_component(component_name, props = {}, html_options = {})
141
+ # Convert props to JSON for the data attribute
142
+ props_json = props.to_json
143
+
144
+ # Build the HTML attributes
145
+ html_attrs = {
146
+ "data-react-component" => component_name,
147
+ "data-react-props" => props_json,
148
+ }
149
+
150
+ # Merge with any additional HTML options
151
+ html_attrs.merge!(html_options)
152
+
153
+ # Return the div element
154
+ content_tag(:div, "", html_attrs)
155
+ end
156
+
139
157
  def global_inline_props
140
158
  {
141
159
  height: height,
@@ -172,7 +190,7 @@ module Playbook
172
190
  end
173
191
 
174
192
  def dynamic_inline_props
175
- styles = global_inline_props.map { |key, value| "#{key.to_s.gsub('_', '-')}: #{value}" if inline_validator(key, value) }.compact
193
+ styles = global_inline_props.map { |key, value| "#{key.to_s.tr('_', '-')}: #{value}" if inline_validator(key, value) }.compact
176
194
  styles.join("; ").presence
177
195
  end
178
196
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "15.0.0"
5
- VERSION = "15.0.0.pre.alpha.popovertesting10431"
5
+ VERSION = "15.0.0.pre.alpha.removewebpacker10432"
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: 15.0.0.pre.alpha.popovertesting10431
4
+ version: 15.0.0.pre.alpha.removewebpacker10432
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: 2025-09-12 00:00:00.000000000 Z
12
+ date: 2025-09-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -53,20 +53,6 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: 5.2.4.5
56
- - !ruby/object:Gem::Dependency
57
- name: react-rails
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - '='
61
- - !ruby/object:Gem::Version
62
- version: 2.6.1
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - '='
68
- - !ruby/object:Gem::Version
69
- version: 2.6.1
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: view_component
72
58
  requirement: !ruby/object:Gem::Requirement
@@ -82,19 +68,19 @@ dependencies:
82
68
  - !ruby/object:Gem::Version
83
69
  version: 2.83.0
84
70
  - !ruby/object:Gem::Dependency
85
- name: webpacker-react
71
+ name: vite_rails
86
72
  requirement: !ruby/object:Gem::Requirement
87
73
  requirements:
88
- - - "~>"
74
+ - - ">="
89
75
  - !ruby/object:Gem::Version
90
- version: 0.3.2
76
+ version: '0'
91
77
  type: :runtime
92
78
  prerelease: false
93
79
  version_requirements: !ruby/object:Gem::Requirement
94
80
  requirements:
95
- - - "~>"
81
+ - - ">="
96
82
  - !ruby/object:Gem::Version
97
- version: 0.3.2
83
+ version: '0'
98
84
  - !ruby/object:Gem::Dependency
99
85
  name: brakeman
100
86
  requirement: !ruby/object:Gem::Requirement
@@ -3624,12 +3610,13 @@ files:
3624
3610
  - app/pb_kits/playbook/utilities/test/globalProps/truncate.test.js
3625
3611
  - app/pb_kits/playbook/utilities/text.ts
3626
3612
  - app/pb_kits/playbook/utilities/validEmojiChecker.ts
3627
- - dist/chunks/_line_graph-smu35i9u.js
3628
- - dist/chunks/_typeahead-C5hUPymw.js
3629
- - dist/chunks/_weekday_stacked-BXuXb72b.js
3613
+ - dist/chunks/_line_graph-C0LUCC-Z.js
3614
+ - dist/chunks/_typeahead-BGJ0eMvl.js
3615
+ - dist/chunks/_weekday_stacked-Dpjg2Qwg.js
3616
+ - dist/chunks/componentRegistry-DtWHGZb5.js
3630
3617
  - dist/chunks/lazysizes-B7xYodB-.js
3631
- - dist/chunks/lib-82dcKEqL.js
3632
- - dist/chunks/pb_form_validation-CYLBbwKB.js
3618
+ - dist/chunks/lib-QZuu1ltS.js
3619
+ - dist/chunks/pb_form_validation-CleM960_.js
3633
3620
  - dist/chunks/vendor.js
3634
3621
  - dist/menu.yml
3635
3622
  - dist/playbook-doc.js