From 26c28b534b4b9990e326aa9cfcd8baeb5da55515 Mon Sep 17 00:00:00 2001 From: karimsemmoud Date: Sat, 14 Feb 2026 13:04:48 +0700 Subject: [PATCH 1/9] lint --- assets/components/accordion.ts | 16 +- assets/components/checkbox.ts | 22 ++- assets/components/clipboard.ts | 21 ++- assets/components/collapsible.ts | 17 ++- assets/components/combobox.ts | 130 ++++++++-------- assets/components/date-picker.ts | 181 ++++++---------------- assets/components/dialog.ts | 28 +++- assets/components/menu.ts | 4 +- assets/components/select.ts | 112 ++++++-------- assets/components/signature-pad.ts | 50 ++++--- assets/components/switch.ts | 20 ++- assets/components/tabs.ts | 15 +- assets/components/toast.ts | 57 ++++--- assets/components/toggle-group.ts | 21 +-- assets/components/tree-view.ts | 50 +++---- assets/hooks/accordion.ts | 120 +++++++-------- assets/hooks/checkbox.ts | 7 +- assets/hooks/clipboard.ts | 17 ++- assets/hooks/collapsible.ts | 13 +- assets/hooks/combobox.ts | 84 ++++++----- assets/hooks/corex.ts | 7 +- assets/hooks/date-picker.ts | 62 ++++---- assets/hooks/dialog.ts | 2 +- assets/hooks/menu.ts | 149 +++++++++--------- assets/hooks/select.ts | 207 +++++++++++--------------- assets/hooks/signature-pad.ts | 23 ++- assets/hooks/tabs.ts | 126 ++++++++-------- assets/hooks/toast.ts | 16 +- assets/hooks/toggle-group.ts | 21 ++- assets/hooks/tree-view.ts | 15 +- assets/lib/util.ts | 1 - e2e/assets/corex/components/toast.css | 3 +- e2e/mix.exs | 2 +- e2e/mix.lock | 1 - eslint.config.mjs | 8 +- lib/components/select.ex | 17 +-- lib/components/select/anatomy.ex | 2 - lib/components/select/connect.ex | 4 +- priv/static/accordion.mjs | 111 +++++++------- priv/static/checkbox.mjs | 16 +- priv/static/clipboard.mjs | 29 ++-- priv/static/collapsible.mjs | 25 +++- priv/static/combobox.mjs | 54 +++---- priv/static/corex.cjs.js.map | 4 +- priv/static/corex.js | 27 ---- priv/static/corex.min.js | 6 +- priv/static/corex.mjs.map | 4 +- priv/static/date-picker.mjs | 178 +++++++--------------- priv/static/dialog.mjs | 24 ++- priv/static/menu.mjs | 131 ++++++++-------- priv/static/select.mjs | 185 +++++++++-------------- priv/static/signature-pad.mjs | 53 +++++-- priv/static/switch.mjs | 8 +- priv/static/tabs.mjs | 113 +++++++------- priv/static/toast.mjs | 4 +- priv/static/toggle-group.mjs | 21 +-- priv/static/tree-view.mjs | 26 ++-- 57 files changed, 1249 insertions(+), 1421 deletions(-) diff --git a/assets/components/accordion.ts b/assets/components/accordion.ts index a6b07e8..7715945 100644 --- a/assets/components/accordion.ts +++ b/assets/components/accordion.ts @@ -1,4 +1,4 @@ -import {connect, machine, type Props, type Api} from "@zag-js/accordion"; +import { connect, machine, type Props, type Api } from "@zag-js/accordion"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; @@ -30,17 +30,23 @@ export class Accordion extends Component { const { value, disabled } = itemData; this.spreadProps(itemEl, this.api.getItemProps({ value, disabled })); - const triggerEl = itemEl.querySelector('[data-scope="accordion"][data-part="item-trigger"]'); + const triggerEl = itemEl.querySelector( + '[data-scope="accordion"][data-part="item-trigger"]' + ); if (triggerEl) { this.spreadProps(triggerEl, this.api.getItemTriggerProps({ value, disabled })); } - const indicatorEl = itemEl.querySelector('[data-scope="accordion"][data-part="item-indicator"]'); + const indicatorEl = itemEl.querySelector( + '[data-scope="accordion"][data-part="item-indicator"]' + ); if (indicatorEl) { this.spreadProps(indicatorEl, this.api.getItemIndicatorProps({ value, disabled })); } - const contentEl = itemEl.querySelector('[data-scope="accordion"][data-part="item-content"]'); + const contentEl = itemEl.querySelector( + '[data-scope="accordion"][data-part="item-content"]' + ); if (contentEl) { this.spreadProps(contentEl, this.api.getItemContentProps({ value, disabled })); } @@ -56,4 +62,4 @@ export class Accordion extends Component { return []; } } -} \ No newline at end of file +} diff --git a/assets/components/checkbox.ts b/assets/components/checkbox.ts index 0e074fb..9b479e1 100644 --- a/assets/components/checkbox.ts +++ b/assets/components/checkbox.ts @@ -1,4 +1,4 @@ -import {connect, machine, type Props, type Api} from "@zag-js/checkbox"; +import { connect, machine, type Props, type Api } from "@zag-js/checkbox"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; @@ -17,24 +17,32 @@ export class Checkbox extends Component { if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const inputEl = rootEl.querySelector(':scope > [data-scope="checkbox"][data-part="hidden-input"]'); + const inputEl = rootEl.querySelector( + ':scope > [data-scope="checkbox"][data-part="hidden-input"]' + ); if (inputEl) { this.spreadProps(inputEl, this.api.getHiddenInputProps()); } - const labelEl = rootEl.querySelector(':scope > [data-scope="checkbox"][data-part="label"]'); + const labelEl = rootEl.querySelector( + ':scope > [data-scope="checkbox"][data-part="label"]' + ); if (labelEl) { this.spreadProps(labelEl, this.api.getLabelProps()); } - const controlEl = rootEl.querySelector(':scope > [data-scope="checkbox"][data-part="control"]'); + const controlEl = rootEl.querySelector( + ':scope > [data-scope="checkbox"][data-part="control"]' + ); if (controlEl) { this.spreadProps(controlEl, this.api.getControlProps()); - - const indicatorEl = controlEl.querySelector(':scope > [data-scope="checkbox"][data-part="indicator"]'); + + const indicatorEl = controlEl.querySelector( + ':scope > [data-scope="checkbox"][data-part="indicator"]' + ); if (indicatorEl) { this.spreadProps(indicatorEl, this.api.getIndicatorProps()); } } } -} \ No newline at end of file +} diff --git a/assets/components/clipboard.ts b/assets/components/clipboard.ts index 6d67d2b..e0e2784 100644 --- a/assets/components/clipboard.ts +++ b/assets/components/clipboard.ts @@ -1,4 +1,4 @@ -import {connect, machine, type Props, type Api} from "@zag-js/clipboard"; +import { connect, machine, type Props, type Api } from "@zag-js/clipboard"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; @@ -17,16 +17,22 @@ export class Clipboard extends Component { if (rootEl) { this.spreadProps(rootEl, this.api.getRootProps()); - const labelEl = rootEl.querySelector('[data-scope="clipboard"][data-part="label"]'); + const labelEl = rootEl.querySelector( + '[data-scope="clipboard"][data-part="label"]' + ); if (labelEl) { this.spreadProps(labelEl, this.api.getLabelProps()); } - const controlEl = rootEl.querySelector('[data-scope="clipboard"][data-part="control"]'); + const controlEl = rootEl.querySelector( + '[data-scope="clipboard"][data-part="control"]' + ); if (controlEl) { this.spreadProps(controlEl, this.api.getControlProps()); - const inputEl = controlEl.querySelector('[data-scope="clipboard"][data-part="input"]'); + const inputEl = controlEl.querySelector( + '[data-scope="clipboard"][data-part="input"]' + ); if (inputEl) { const inputProps = { ...this.api.getInputProps() }; const inputAriaLabel = this.el.dataset.inputAriaLabel; @@ -36,7 +42,9 @@ export class Clipboard extends Component { this.spreadProps(inputEl, inputProps); } - const triggerEl = controlEl.querySelector('[data-scope="clipboard"][data-part="trigger"]'); + const triggerEl = controlEl.querySelector( + '[data-scope="clipboard"][data-part="trigger"]' + ); if (triggerEl) { const triggerProps = { ...this.api.getTriggerProps() }; const ariaLabel = this.el.dataset.triggerAriaLabel; @@ -47,6 +55,5 @@ export class Clipboard extends Component { } } } - } -} \ No newline at end of file +} diff --git a/assets/components/collapsible.ts b/assets/components/collapsible.ts index 0974df7..74fdbf8 100644 --- a/assets/components/collapsible.ts +++ b/assets/components/collapsible.ts @@ -1,4 +1,4 @@ -import {connect, machine, type Props, type Api} from "@zag-js/collapsible"; +import { connect, machine, type Props, type Api } from "@zag-js/collapsible"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; @@ -13,20 +13,25 @@ export class Collapsible extends Component { } render(): void { - const rootEl = this.el.querySelector('[data-scope="collapsible"][data-part="root"]'); + const rootEl = this.el.querySelector( + '[data-scope="collapsible"][data-part="root"]' + ); if (rootEl) { this.spreadProps(rootEl, this.api.getRootProps()); - const triggerEl = rootEl.querySelector('[data-scope="collapsible"][data-part="trigger"]'); + const triggerEl = rootEl.querySelector( + '[data-scope="collapsible"][data-part="trigger"]' + ); if (triggerEl) { this.spreadProps(triggerEl, this.api.getTriggerProps()); } - const contentEl = rootEl.querySelector('[data-scope="collapsible"][data-part="content"]'); + const contentEl = rootEl.querySelector( + '[data-scope="collapsible"][data-part="content"]' + ); if (contentEl) { this.spreadProps(contentEl, this.api.getContentProps()); } } - } -} \ No newline at end of file +} diff --git a/assets/components/combobox.ts b/assets/components/combobox.ts index c6efe57..b872aed 100644 --- a/assets/components/combobox.ts +++ b/assets/components/combobox.ts @@ -1,62 +1,71 @@ -import * as combobox from "@zag-js/combobox"; -import { collection } from "@zag-js/combobox"; +import { + collection, + connect, + machine, + type Props, + type Api, + type OpenChangeDetails, + type InputValueChangeDetails, +} from "@zag-js/combobox"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; -import { OpenChangeDetails, InputValueChangeDetails } from "@zag-js/combobox"; -export class Combobox extends Component { - options: any[] = []; - allOptions: any[] = []; +export type ComboboxItem = { id?: string; label: string; disabled?: boolean; group?: string }; + +export class Combobox extends Component { + options: ComboboxItem[] = []; + allOptions: ComboboxItem[] = []; hasGroups: boolean = false; - setAllOptions(options: any[]) { + setAllOptions(options: ComboboxItem[]) { this.allOptions = options; this.options = options; } private getCollection() { const items = this.options || this.allOptions || []; - + if (this.hasGroups) { return collection({ items: items, - itemToValue: (item: any) => item.id, - itemToString: (item: any) => item.label, - isItemDisabled: (item: any) => item.disabled, - groupBy: (item: any) => item.group, + itemToValue: (item: ComboboxItem) => item.id ?? "", + itemToString: (item: ComboboxItem) => item.label, + isItemDisabled: (item: ComboboxItem) => item.disabled ?? false, + groupBy: (item: ComboboxItem) => item.group, }); } return collection({ items: items, - itemToValue: (item: any) => item.id, - itemToString: (item: any) => item.label, - isItemDisabled: (item: any) => item.disabled, + itemToValue: (item: ComboboxItem) => item.id ?? "", + itemToString: (item: ComboboxItem) => item.label, + isItemDisabled: (item: ComboboxItem) => item.disabled ?? false, }); } - initMachine(props: combobox.Props): VanillaMachine { - const self = this; - - return new VanillaMachine(combobox.machine, { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + initMachine(props: Props): VanillaMachine { + const getCollection = this.getCollection.bind(this); + + return new VanillaMachine(machine, { ...props, get collection() { - return self.getCollection(); + return getCollection(); }, onOpenChange: (details: OpenChangeDetails) => { if (details.open) { - self.options = self.allOptions; + this.options = this.allOptions; } if (props.onOpenChange) { props.onOpenChange(details); } }, onInputValueChange: (details: InputValueChangeDetails) => { - const filtered = self.allOptions.filter((item: any) => + const filtered = this.allOptions.filter((item: ComboboxItem) => item.label.toLowerCase().includes(details.inputValue.toLowerCase()) ); - self.options = filtered.length > 0 ? filtered : self.allOptions; - + this.options = filtered.length > 0 ? filtered : this.allOptions; + if (props.onInputValueChange) { props.onInputValueChange(details); } @@ -64,25 +73,26 @@ export class Combobox extends Component { }); } - initApi(): combobox.Api { - return combobox.connect(this.machine.service, normalizeProps); + initApi(): Api { + return connect(this.machine.service, normalizeProps); } renderItems(): void { - const contentEl = this.el.querySelector('[data-scope="combobox"][data-part="content"]'); + const contentEl = this.el.querySelector( + '[data-scope="combobox"][data-part="content"]' + ); if (!contentEl) return; - const templatesContainer = - this.el.querySelector('[data-templates="combobox"]'); + const templatesContainer = this.el.querySelector('[data-templates="combobox"]'); if (!templatesContainer) return; contentEl .querySelectorAll('[data-scope="combobox"][data-part="item"]:not([data-template])') - .forEach(el => el.remove()); + .forEach((el) => el.remove()); contentEl .querySelectorAll('[data-scope="combobox"][data-part="item-group"]:not([data-template])') - .forEach(el => el.remove()); + .forEach((el) => el.remove()); const items = this.api.collection.items; @@ -99,31 +109,28 @@ export class Combobox extends Component { renderGroupedItems( contentEl: HTMLElement, templatesContainer: HTMLElement, - groups: [string | null, any[]][] + groups: [string | null, ComboboxItem[]][] ): void { for (const [groupId, groupItems] of groups) { if (groupId == null) continue; - + const groupTemplate = templatesContainer.querySelector( `[data-scope="combobox"][data-part="item-group"][data-id="${groupId}"][data-template]` ); if (!groupTemplate) continue; - + const groupEl = groupTemplate.cloneNode(true) as HTMLElement; groupEl.removeAttribute("data-template"); - + this.spreadProps(groupEl, this.api.getItemGroupProps({ id: groupId })); - + const labelEl = groupEl.querySelector( '[data-scope="combobox"][data-part="item-group-label"]' ); if (labelEl) { - this.spreadProps( - labelEl, - this.api.getItemGroupLabelProps({ htmlFor: groupId }) - ); + this.spreadProps(labelEl, this.api.getItemGroupLabelProps({ htmlFor: groupId })); } - + const groupContentEl = groupEl.querySelector( '[data-scope="combobox"][data-part="item-group-content"]' ); @@ -135,16 +142,15 @@ export class Combobox extends Component { const itemEl = this.cloneItem(templatesContainer, item); if (itemEl) groupContentEl.appendChild(itemEl); } - + contentEl.appendChild(groupEl); } } - renderFlatItems( contentEl: HTMLElement, templatesContainer: HTMLElement, - items: any[] + items: ComboboxItem[] ): void { for (const item of items) { const itemEl = this.cloneItem(templatesContainer, item); @@ -152,10 +158,7 @@ export class Combobox extends Component { } } - cloneItem( - templatesContainer: HTMLElement, - item: any - ): HTMLElement | null { + cloneItem(templatesContainer: HTMLElement, item: ComboboxItem): HTMLElement | null { const value = this.api.collection.getItemValue(item); // Find template by data-value (templates are rendered per item in Elixir when custom slots are used) @@ -178,32 +181,22 @@ export class Combobox extends Component { } } - const indicatorEl = - el.querySelector('[data-scope="combobox"][data-part="item-indicator"]'); + const indicatorEl = el.querySelector( + '[data-scope="combobox"][data-part="item-indicator"]' + ); if (indicatorEl) { - this.spreadProps( - indicatorEl, - this.api.getItemIndicatorProps({ item }) - ); + this.spreadProps(indicatorEl, this.api.getItemIndicatorProps({ item })); } return el; } render(): void { - const root = - this.el.querySelector('[data-scope="combobox"][data-part="root"]'); + const root = this.el.querySelector('[data-scope="combobox"][data-part="root"]'); if (!root) return; this.spreadProps(root, this.api.getRootProps()); - [ - "label", - "control", - "input", - "trigger", - "clear-trigger", - "positioner", - ].forEach(part => { + ["label", "control", "input", "trigger", "clear-trigger", "positioner"].forEach((part) => { const el = this.el.querySelector(`[data-scope="combobox"][data-part="${part}"]`); if (!el) return; @@ -211,7 +204,7 @@ export class Combobox extends Component { "get" + part .split("-") - .map(s => s[0].toUpperCase() + s.slice(1)) + .map((s) => s[0].toUpperCase() + s.slice(1)) .join("") + "Props"; @@ -219,11 +212,12 @@ export class Combobox extends Component { this.spreadProps(el, this.api[apiMethod]()); }); - const contentEl = - this.el.querySelector('[data-scope="combobox"][data-part="content"]'); + const contentEl = this.el.querySelector( + '[data-scope="combobox"][data-part="content"]' + ); if (contentEl) { this.spreadProps(contentEl, this.api.getContentProps()); this.renderItems(); } } -} \ No newline at end of file +} diff --git a/assets/components/date-picker.ts b/assets/components/date-picker.ts index f8f736f..e69830f 100644 --- a/assets/components/date-picker.ts +++ b/assets/components/date-picker.ts @@ -1,25 +1,20 @@ -import * as datePicker from "@zag-js/date-picker"; +import { connect, machine, type Props, type Api } from "@zag-js/date-picker"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; -export class DatePicker extends Component { - - initMachine(props: datePicker.Props): VanillaMachine { - return new VanillaMachine(datePicker.machine, { - ...props, - }); +export class DatePicker extends Component { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + initMachine(props: Props): VanillaMachine { + return new VanillaMachine(machine, props); } - initApi(): datePicker.Api { - return datePicker.connect(this.machine.service, normalizeProps); + initApi(): Api { + return connect(this.machine.service, normalizeProps); } - private getDayView = () => - this.el.querySelector('[data-part="day-view"]'); - private getMonthView = () => - this.el.querySelector('[data-part="month-view"]'); - private getYearView = () => - this.el.querySelector('[data-part="year-view"]'); + private getDayView = () => this.el.querySelector('[data-part="day-view"]'); + private getMonthView = () => this.el.querySelector('[data-part="month-view"]'); + private getYearView = () => this.el.querySelector('[data-part="year-view"]'); private renderDayTableHeader = () => { const dayView = this.getDayView(); @@ -52,10 +47,7 @@ export class DatePicker extends Component { const td = this.doc.createElement("td"); this.spreadProps(td, this.api.getDayTableCellProps({ value })); const trigger = this.doc.createElement("div"); - this.spreadProps( - trigger, - this.api.getDayTableCellTriggerProps({ value }), - ); + this.spreadProps(trigger, this.api.getDayTableCellTriggerProps({ value })); trigger.textContent = String(value.day); td.appendChild(trigger); tr.appendChild(td); @@ -76,15 +68,9 @@ export class DatePicker extends Component { this.spreadProps(tr, this.api.getTableRowProps()); months.forEach((month) => { const td = this.doc.createElement("td"); - this.spreadProps( - td, - this.api.getMonthTableCellProps({ ...month, columns: 4 }), - ); + this.spreadProps(td, this.api.getMonthTableCellProps({ ...month, columns: 4 })); const trigger = this.doc.createElement("div"); - this.spreadProps( - trigger, - this.api.getMonthTableCellTriggerProps({ ...month, columns: 4 }), - ); + this.spreadProps(trigger, this.api.getMonthTableCellTriggerProps({ ...month, columns: 4 })); trigger.textContent = month.label; td.appendChild(trigger); tr.appendChild(td); @@ -105,15 +91,9 @@ export class DatePicker extends Component { this.spreadProps(tr, this.api.getTableRowProps({ view: "year" })); years.forEach((year) => { const td = this.doc.createElement("td"); - this.spreadProps( - td, - this.api.getYearTableCellProps({ ...year, columns: 4 }), - ); + this.spreadProps(td, this.api.getYearTableCellProps({ ...year, columns: 4 })); const trigger = this.doc.createElement("div"); - this.spreadProps( - trigger, - this.api.getYearTableCellTriggerProps({ ...year, columns: 4 }), - ); + this.spreadProps(trigger, this.api.getYearTableCellTriggerProps({ ...year, columns: 4 })); trigger.textContent = year.label; td.appendChild(trigger); tr.appendChild(td); @@ -123,42 +103,40 @@ export class DatePicker extends Component { }; render(): void { - const root = this.el.querySelector( - '[data-scope="date-picker"][data-part="root"]', - ); + const root = this.el.querySelector('[data-scope="date-picker"][data-part="root"]'); if (root) this.spreadProps(root, this.api.getRootProps()); const label = this.el.querySelector( - '[data-scope="date-picker"][data-part="label"]', + '[data-scope="date-picker"][data-part="label"]' ); if (label) this.spreadProps(label, this.api.getLabelProps()); const control = this.el.querySelector( - '[data-scope="date-picker"][data-part="control"]', + '[data-scope="date-picker"][data-part="control"]' ); if (control) this.spreadProps(control, this.api.getControlProps()); const input = this.el.querySelector( - '[data-scope="date-picker"][data-part="input"]', + '[data-scope="date-picker"][data-part="input"]' ); if (input) { this.spreadProps(input, this.api.getInputProps()); } const trigger = this.el.querySelector( - '[data-scope="date-picker"][data-part="trigger"]', + '[data-scope="date-picker"][data-part="trigger"]' ); if (trigger) { this.spreadProps(trigger, this.api.getTriggerProps()); } const positioner = this.el.querySelector( - '[data-scope="date-picker"][data-part="positioner"]', + '[data-scope="date-picker"][data-part="positioner"]' ); if (positioner) this.spreadProps(positioner, this.api.getPositionerProps()); const content = this.el.querySelector( - '[data-scope="date-picker"][data-part="content"]', + '[data-scope="date-picker"][data-part="content"]' ); if (content) this.spreadProps(content, this.api.getContentProps()); @@ -171,122 +149,59 @@ export class DatePicker extends Component { if (yearView) yearView.hidden = this.api.view !== "year"; if (this.api.view === "day" && dayView) { - const viewControl = dayView.querySelector( - '[data-part="view-control"]', - ); + const viewControl = dayView.querySelector('[data-part="view-control"]'); if (viewControl) - this.spreadProps( - viewControl, - this.api.getViewControlProps({ view: "year" }), - ); - const prevTrigger = dayView.querySelector( - '[data-part="prev-trigger"]', - ); - if (prevTrigger) - this.spreadProps(prevTrigger, this.api.getPrevTriggerProps()); - const viewTrigger = dayView.querySelector( - '[data-part="view-trigger"]', - ); + this.spreadProps(viewControl, this.api.getViewControlProps({ view: "year" })); + const prevTrigger = dayView.querySelector('[data-part="prev-trigger"]'); + if (prevTrigger) this.spreadProps(prevTrigger, this.api.getPrevTriggerProps()); + const viewTrigger = dayView.querySelector('[data-part="view-trigger"]'); if (viewTrigger) { this.spreadProps(viewTrigger, this.api.getViewTriggerProps()); viewTrigger.textContent = this.api.visibleRangeText.start; } - const nextTrigger = dayView.querySelector( - '[data-part="next-trigger"]', - ); - if (nextTrigger) - this.spreadProps(nextTrigger, this.api.getNextTriggerProps()); + const nextTrigger = dayView.querySelector('[data-part="next-trigger"]'); + if (nextTrigger) this.spreadProps(nextTrigger, this.api.getNextTriggerProps()); const table = dayView.querySelector("table"); - if (table) - this.spreadProps(table, this.api.getTableProps({ view: "day" })); + if (table) this.spreadProps(table, this.api.getTableProps({ view: "day" })); const thead = dayView.querySelector("thead"); - if (thead) - this.spreadProps( - thead, - this.api.getTableHeaderProps({ view: "day" }), - ); + if (thead) this.spreadProps(thead, this.api.getTableHeaderProps({ view: "day" })); this.renderDayTableHeader(); this.renderDayTableBody(); } else if (this.api.view === "month" && monthView) { - const viewControl = monthView.querySelector( - '[data-part="view-control"]', - ); + const viewControl = monthView.querySelector('[data-part="view-control"]'); if (viewControl) - this.spreadProps( - viewControl, - this.api.getViewControlProps({ view: "month" }), - ); - const prevTrigger = monthView.querySelector( - '[data-part="prev-trigger"]', - ); + this.spreadProps(viewControl, this.api.getViewControlProps({ view: "month" })); + const prevTrigger = monthView.querySelector('[data-part="prev-trigger"]'); if (prevTrigger) - this.spreadProps( - prevTrigger, - this.api.getPrevTriggerProps({ view: "month" }), - ); - const viewTrigger = monthView.querySelector( - '[data-part="view-trigger"]', - ); + this.spreadProps(prevTrigger, this.api.getPrevTriggerProps({ view: "month" })); + const viewTrigger = monthView.querySelector('[data-part="view-trigger"]'); if (viewTrigger) { - this.spreadProps( - viewTrigger, - this.api.getViewTriggerProps({ view: "month" }), - ); + this.spreadProps(viewTrigger, this.api.getViewTriggerProps({ view: "month" })); viewTrigger.textContent = String(this.api.visibleRange.start.year); } - const nextTrigger = monthView.querySelector( - '[data-part="next-trigger"]', - ); + const nextTrigger = monthView.querySelector('[data-part="next-trigger"]'); if (nextTrigger) - this.spreadProps( - nextTrigger, - this.api.getNextTriggerProps({ view: "month" }), - ); + this.spreadProps(nextTrigger, this.api.getNextTriggerProps({ view: "month" })); const table = monthView.querySelector("table"); - if (table) - this.spreadProps( - table, - this.api.getTableProps({ view: "month", columns: 4 }), - ); + if (table) this.spreadProps(table, this.api.getTableProps({ view: "month", columns: 4 })); this.renderMonthTableBody(); } else if (this.api.view === "year" && yearView) { - const viewControl = yearView.querySelector( - '[data-part="view-control"]', - ); + const viewControl = yearView.querySelector('[data-part="view-control"]'); if (viewControl) - this.spreadProps( - viewControl, - this.api.getViewControlProps({ view: "year" }), - ); - const prevTrigger = yearView.querySelector( - '[data-part="prev-trigger"]', - ); + this.spreadProps(viewControl, this.api.getViewControlProps({ view: "year" })); + const prevTrigger = yearView.querySelector('[data-part="prev-trigger"]'); if (prevTrigger) - this.spreadProps( - prevTrigger, - this.api.getPrevTriggerProps({ view: "year" }), - ); - const decadeText = yearView.querySelector( - '[data-part="decade"]', - ); + this.spreadProps(prevTrigger, this.api.getPrevTriggerProps({ view: "year" })); + const decadeText = yearView.querySelector('[data-part="decade"]'); if (decadeText) { const decade = this.api.getDecade(); decadeText.textContent = `${decade.start} - ${decade.end}`; } - const nextTrigger = yearView.querySelector( - '[data-part="next-trigger"]', - ); + const nextTrigger = yearView.querySelector('[data-part="next-trigger"]'); if (nextTrigger) - this.spreadProps( - nextTrigger, - this.api.getNextTriggerProps({ view: "year" }), - ); + this.spreadProps(nextTrigger, this.api.getNextTriggerProps({ view: "year" })); const table = yearView.querySelector("table"); - if (table) - this.spreadProps( - table, - this.api.getTableProps({ view: "year", columns: 4 }), - ); + if (table) this.spreadProps(table, this.api.getTableProps({ view: "year", columns: 4 })); this.renderYearTableBody(); } } diff --git a/assets/components/dialog.ts b/assets/components/dialog.ts index ae999a3..99cfcee 100644 --- a/assets/components/dialog.ts +++ b/assets/components/dialog.ts @@ -1,4 +1,4 @@ -import {connect, machine, type Props, type Api} from "@zag-js/dialog"; +import { connect, machine, type Props, type Api } from "@zag-js/dialog"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; @@ -15,25 +15,37 @@ export class Dialog extends Component { render(): void { const rootEl = this.el; - const triggerEl = rootEl.querySelector('[data-scope="dialog"][data-part="trigger"]'); + const triggerEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="trigger"]' + ); if (triggerEl) this.spreadProps(triggerEl, this.api.getTriggerProps()); - const backdropEl = rootEl.querySelector('[data-scope="dialog"][data-part="backdrop"]'); + const backdropEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="backdrop"]' + ); if (backdropEl) this.spreadProps(backdropEl, this.api.getBackdropProps()); - const positionerEl = rootEl.querySelector('[data-scope="dialog"][data-part="positioner"]'); + const positionerEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="positioner"]' + ); if (positionerEl) this.spreadProps(positionerEl, this.api.getPositionerProps()); - const contentEl = rootEl.querySelector('[data-scope="dialog"][data-part="content"]'); + const contentEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="content"]' + ); if (contentEl) this.spreadProps(contentEl, this.api.getContentProps()); const titleEl = rootEl.querySelector('[data-scope="dialog"][data-part="title"]'); if (titleEl) this.spreadProps(titleEl, this.api.getTitleProps()); - const descriptionEl = rootEl.querySelector('[data-scope="dialog"][data-part="description"]'); + const descriptionEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="description"]' + ); if (descriptionEl) this.spreadProps(descriptionEl, this.api.getDescriptionProps()); - const closeTriggerEl = rootEl.querySelector('[data-scope="dialog"][data-part="close-trigger"]'); + const closeTriggerEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="close-trigger"]' + ); if (closeTriggerEl) this.spreadProps(closeTriggerEl, this.api.getCloseTriggerProps()); } -} \ No newline at end of file +} diff --git a/assets/components/menu.ts b/assets/components/menu.ts index c627d29..a37adeb 100644 --- a/assets/components/menu.ts +++ b/assets/components/menu.ts @@ -50,9 +50,7 @@ export class Menu extends Component { const nestedMenuId = triggerEl.dataset.nestedMenu; if (!nestedMenuId) continue; - const childMenu = this.children.find( - (child) => child.el.id === `menu:${nestedMenuId}` - ); + const childMenu = this.children.find((child) => child.el.id === `menu:${nestedMenuId}`); if (!childMenu) continue; const applyProps = () => { diff --git a/assets/components/select.ts b/assets/components/select.ts index 2e87ecb..d3045ef 100644 --- a/assets/components/select.ts +++ b/assets/components/select.ts @@ -1,5 +1,4 @@ -import * as select from "@zag-js/select"; -import { collection } from "@zag-js/select"; +import { collection, connect, machine, type Props, type Api } from "@zag-js/select"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; import { getString } from "../lib/util"; @@ -9,14 +8,15 @@ type Item = { value?: string; label: string; disabled?: boolean; + group?: string; }; -export class Select extends Component { +export class Select extends Component { private _options: Item[] = []; hasGroups: boolean = false; private placeholder: string = ""; - constructor(el: HTMLElement | null, props: select.Props) { + constructor(el: HTMLElement | null, props: Props) { super(el, props); this.placeholder = getString(this.el, "placeholder") || ""; } @@ -29,7 +29,7 @@ export class Select extends Component { this._options = Array.isArray(options) ? options : []; } - getCollection(): any { + getCollection(): ReturnType> { const items = this.options; if (this.hasGroups) { @@ -38,7 +38,7 @@ export class Select extends Component { itemToValue: (item) => item.id ?? item.value ?? "", itemToString: (item) => item.label, isItemDisabled: (item) => !!item.disabled, - groupBy: (item: any) => item.group, + groupBy: (item) => item.group ?? "", }); } @@ -50,19 +50,20 @@ export class Select extends Component { }); } - initMachine(props: select.Props): VanillaMachine { - const self = this; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + initMachine(props: Props): VanillaMachine { + const getCollection = this.getCollection.bind(this); - return new VanillaMachine(select.machine, { + return new VanillaMachine(machine, { ...props, get collection() { - return self.getCollection(); + return getCollection(); }, }); } - initApi(): select.Api { - return select.connect(this.machine.service, normalizeProps); + initApi(): Api { + return connect(this.machine.service, normalizeProps); } renderItems(): void { @@ -71,8 +72,7 @@ export class Select extends Component { ); if (!contentEl) return; - const templatesContainer = - this.el.querySelector('[data-templates="select"]'); + const templatesContainer = this.el.querySelector('[data-templates="select"]'); if (!templatesContainer) return; contentEl @@ -98,7 +98,7 @@ export class Select extends Component { renderGroupedItems( contentEl: HTMLElement, templatesContainer: HTMLElement, - groups: [string | null, any[]][] + groups: [string | null, Item[]][] ): void { for (const [groupId, groupItems] of groups) { if (groupId == null) continue; @@ -117,10 +117,7 @@ export class Select extends Component { '[data-scope="select"][data-part="item-group-label"]' ); if (labelEl) { - this.spreadProps( - labelEl, - this.api.getItemGroupLabelProps({ htmlFor: groupId }) - ); + this.spreadProps(labelEl, this.api.getItemGroupLabelProps({ htmlFor: groupId })); } const templateItems = groupEl.querySelectorAll( @@ -137,21 +134,14 @@ export class Select extends Component { } } - renderFlatItems( - contentEl: HTMLElement, - templatesContainer: HTMLElement, - items: any[] - ): void { + renderFlatItems(contentEl: HTMLElement, templatesContainer: HTMLElement, items: Item[]): void { for (const item of items) { const itemEl = this.cloneItem(templatesContainer, item); if (itemEl) contentEl.appendChild(itemEl); } } - cloneItem( - templatesContainer: HTMLElement, - item: Item - ): HTMLElement | null { + cloneItem(templatesContainer: HTMLElement, item: Item): HTMLElement | null { const value = this.api.collection.getItemValue(item); const template = templatesContainer.querySelector( `[data-scope="select"][data-part="item"][data-value="${value}"][data-template]` @@ -163,9 +153,7 @@ export class Select extends Component { this.spreadProps(el, this.api.getItemProps({ item })); - const textEl = el.querySelector( - '[data-scope="select"][data-part="item-text"]' - ); + const textEl = el.querySelector('[data-scope="select"][data-part="item-text"]'); if (textEl) { this.spreadProps(textEl, this.api.getItemTextProps({ item })); } @@ -174,53 +162,40 @@ export class Select extends Component { '[data-scope="select"][data-part="item-indicator"]' ); if (indicatorEl) { - this.spreadProps( - indicatorEl, - this.api.getItemIndicatorProps({ item }) - ); + this.spreadProps(indicatorEl, this.api.getItemIndicatorProps({ item })); } return el; } render(): void { - const root = - this.el.querySelector('[data-scope="select"][data-part="root"]'); + const root = this.el.querySelector('[data-scope="select"][data-part="root"]'); if (!root) return; this.spreadProps(root, this.api.getRootProps()); - - const hiddenSelect = this.el.querySelector( - '[data-scope="select"][data-part="hidden-select"]' - ); - - const valueInput = this.el.querySelector( - '[data-scope="select"][data-part="value-input"]' - ); - if (valueInput) { - if (!this.api.value || this.api.value.length === 0) { - valueInput.value = ""; - } else if (this.api.value.length === 1) { - valueInput.value = String(this.api.value[0]); - } else { - valueInput.value = this.api.value.map(String).join(","); + + const hiddenSelect = this.el.querySelector( + '[data-scope="select"][data-part="hidden-select"]' + ); + + const valueInput = this.el.querySelector( + '[data-scope="select"][data-part="value-input"]' + ); + if (valueInput) { + if (!this.api.value || this.api.value.length === 0) { + valueInput.value = ""; + } else if (this.api.value.length === 1) { + valueInput.value = String(this.api.value[0]); + } else { + valueInput.value = this.api.value.map(String).join(","); + } } - } - if (hiddenSelect) { - this.spreadProps(hiddenSelect, this.api.getHiddenSelectProps()); - } + if (hiddenSelect) { + this.spreadProps(hiddenSelect, this.api.getHiddenSelectProps()); + } - [ - "label", - "control", - "trigger", - "indicator", - "clear-trigger", - "positioner", - ].forEach((part) => { - const el = this.el.querySelector( - `[data-scope="select"][data-part="${part}"]` - ); + ["label", "control", "trigger", "indicator", "clear-trigger", "positioner"].forEach((part) => { + const el = this.el.querySelector(`[data-scope="select"][data-part="${part}"]`); if (!el) return; const method = @@ -242,7 +217,7 @@ export class Select extends Component { const valueAsString = this.api.valueAsString; if (this.api.value && this.api.value.length > 0 && !valueAsString) { const selectedValue = this.api.value[0]; - const selectedItem = this.options.find((item: any) => { + const selectedItem = this.options.find((item: Item) => { const itemValue = item.id ?? item.value ?? ""; return String(itemValue) === String(selectedValue); }); @@ -265,4 +240,3 @@ export class Select extends Component { } } } - diff --git a/assets/components/signature-pad.ts b/assets/components/signature-pad.ts index 7ffb7f1..069b794 100644 --- a/assets/components/signature-pad.ts +++ b/assets/components/signature-pad.ts @@ -1,17 +1,15 @@ -import { connect, machine } from "@zag-js/signature-pad"; - -import type { Props, Api } from "@zag-js/signature-pad"; - +import { connect, machine, type Props, type Api } from "@zag-js/signature-pad"; +import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; -import { normalizeProps, VanillaMachine } from "@zag-js/vanilla"; export class SignaturePad extends Component { imageURL: string = ""; - paths: any[] = []; + paths: string[] = []; name?: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props: Props): VanillaMachine { - this.name = (props as any).name; + this.name = (props as Props & { name?: string }).name; return new VanillaMachine(machine, props); } @@ -19,7 +17,7 @@ export class SignaturePad extends Component { this.name = name; } - setPaths(paths: any[]) { + setPaths(paths: string[]) { this.paths = paths; } @@ -28,7 +26,9 @@ export class SignaturePad extends Component { } syncPaths = () => { - const segment = this.el.querySelector('[data-scope="signature-pad"][data-part="segment"]'); + const segment = this.el.querySelector( + '[data-scope="signature-pad"][data-part="segment"]' + ); if (!segment) return; const totalPaths = this.api.paths.length + (this.api.currentPath ? 1 : 0); @@ -37,7 +37,9 @@ export class SignaturePad extends Component { segment.innerHTML = ""; this.imageURL = ""; this.paths = []; - const hiddenInput = this.el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = this.el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) hiddenInput.value = ""; return; } @@ -62,30 +64,44 @@ export class SignaturePad extends Component { }; render() { - const rootEl = this.el.querySelector('[data-scope="signature-pad"][data-part="root"]'); + const rootEl = this.el.querySelector( + '[data-scope="signature-pad"][data-part="root"]' + ); if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const label = rootEl.querySelector('[data-scope="signature-pad"][data-part="label"]'); + const label = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="label"]' + ); if (label) this.spreadProps(label, this.api.getLabelProps()); - const control = rootEl.querySelector('[data-scope="signature-pad"][data-part="control"]'); + const control = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="control"]' + ); if (control) this.spreadProps(control, this.api.getControlProps()); - const segment = rootEl.querySelector('[data-scope="signature-pad"][data-part="segment"]'); + const segment = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="segment"]' + ); if (segment) this.spreadProps(segment, this.api.getSegmentProps()); - const guide = rootEl.querySelector('[data-scope="signature-pad"][data-part="guide"]'); + const guide = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="guide"]' + ); if (guide) this.spreadProps(guide, this.api.getGuideProps()); - const clearBtn = rootEl.querySelector('[data-scope="signature-pad"][data-part="clear-trigger"]'); + const clearBtn = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="clear-trigger"]' + ); if (clearBtn) { this.spreadProps(clearBtn, this.api.getClearTriggerProps()); const hasPaths = this.api.paths.length > 0 || !!this.api.currentPath; clearBtn.hidden = !hasPaths; } - const hiddenInput = rootEl.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { const pathsForValue = this.paths.length > 0 ? this.paths : this.api.paths; if (this.paths.length === 0 && this.api.paths.length > 0) { diff --git a/assets/components/switch.ts b/assets/components/switch.ts index bd9d571..efbe1ce 100644 --- a/assets/components/switch.ts +++ b/assets/components/switch.ts @@ -1,15 +1,15 @@ -import * as zagSwitch from "@zag-js/switch"; +import { connect, machine, type Props, type Api } from "@zag-js/switch"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; -export class Switch extends Component { +export class Switch extends Component { // eslint-disable-next-line @typescript-eslint/no-explicit-any - initMachine(props: zagSwitch.Props): VanillaMachine { - return new VanillaMachine(zagSwitch.machine, props); + initMachine(props: Props): VanillaMachine { + return new VanillaMachine(machine, props); } - initApi(): zagSwitch.Api { - return zagSwitch.connect(this.machine.service, normalizeProps); + initApi(): Api { + return connect(this.machine.service, normalizeProps); } render(): void { @@ -17,7 +17,9 @@ export class Switch extends Component { if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const inputEl = this.el.querySelector('[data-scope="switch"][data-part="hidden-input"]'); + const inputEl = this.el.querySelector( + '[data-scope="switch"][data-part="hidden-input"]' + ); if (inputEl) { this.spreadProps(inputEl, this.api.getHiddenInputProps()); } @@ -27,7 +29,9 @@ export class Switch extends Component { this.spreadProps(labelEl, this.api.getLabelProps()); } - const controlEl = this.el.querySelector('[data-scope="switch"][data-part="control"]'); + const controlEl = this.el.querySelector( + '[data-scope="switch"][data-part="control"]' + ); if (controlEl) { this.spreadProps(controlEl, this.api.getControlProps()); } diff --git a/assets/components/tabs.ts b/assets/components/tabs.ts index 12c01d1..80f90ad 100644 --- a/assets/components/tabs.ts +++ b/assets/components/tabs.ts @@ -1,4 +1,4 @@ -import {connect, machine, type Props, type Api} from "@zag-js/tabs"; +import { connect, machine, type Props, type Api } from "@zag-js/tabs"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; @@ -21,19 +21,22 @@ export class Tabs extends Component { if (!listEl) return; this.spreadProps(listEl, this.api.getListProps()); - const itemsData = this.el.getAttribute('data-items'); - const items: Array<{value: string, disabled: boolean}> = itemsData + const itemsData = this.el.getAttribute("data-items"); + const items: Array<{ value: string; disabled: boolean }> = itemsData ? JSON.parse(itemsData) : []; const triggers = listEl.querySelectorAll( '[data-scope="tabs"][data-part="trigger"]' ); - + for (let i = 0; i < triggers.length && i < items.length; i++) { const triggerEl = triggers[i]; const item = items[i]; - this.spreadProps(triggerEl, this.api.getTriggerProps({ value: item.value, disabled: item.disabled })); + this.spreadProps( + triggerEl, + this.api.getTriggerProps({ value: item.value, disabled: item.disabled }) + ); } const contents = rootEl.querySelectorAll( @@ -46,4 +49,4 @@ export class Tabs extends Component { this.spreadProps(contentEl, this.api.getContentProps({ value: item.value })); } } -} \ No newline at end of file +} diff --git a/assets/components/toast.ts b/assets/components/toast.ts index fb1d2ad..59247a1 100644 --- a/assets/components/toast.ts +++ b/assets/components/toast.ts @@ -1,5 +1,16 @@ -import * as toast from "@zag-js/toast"; -import type { Store } from "@zag-js/toast"; +import { + connect, + machine, + group, + createStore, + type Props, + type Api, + type GroupProps, + type GroupApi, + type Store, + type StoreProps, + type Options, +} from "@zag-js/toast"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; import { generateId } from "../lib/util"; @@ -8,14 +19,14 @@ export const toastGroups = new Map(); export const toastStores = new Map(); // eslint-disable-next-line @typescript-eslint/no-explicit-any -type ToastItemProps = toast.Props & { +type ToastItemProps = Props & { // eslint-disable-next-line @typescript-eslint/no-explicit-any parent: any; index: number; }; // eslint-disable-next-line @typescript-eslint/no-explicit-any -export class ToastItem extends Component, toast.Api> { +export class ToastItem extends Component, Api> { private parts!: { title: HTMLElement; description: HTMLElement; @@ -66,12 +77,12 @@ export class ToastItem extends Component, toast.Api> } // eslint-disable-next-line @typescript-eslint/no-explicit-any - initMachine(props: toast.Props): VanillaMachine { - return new VanillaMachine(toast.machine, props); + initMachine(props: Props): VanillaMachine { + return new VanillaMachine(machine, props); } - initApi(): toast.Api { - return toast.connect(this.machine.service, normalizeProps); + initApi(): Api { + return connect(this.machine.service, normalizeProps); } render() { @@ -93,9 +104,12 @@ export class ToastItem extends Component, toast.Api> this.spreadProps(this.parts.description, this.api.getDescriptionProps()); const duration = this.duration; - const isInfinity = duration === "Infinity" || duration === Infinity || duration === Number.POSITIVE_INFINITY; + const isInfinity = + duration === "Infinity" || duration === Infinity || duration === Number.POSITIVE_INFINITY; const toastGroup = this.el.closest('[phx-hook="Toast"]') as HTMLElement; - const loadingIconTemplate = toastGroup?.querySelector('[data-loading-icon-template]') as HTMLElement; + const loadingIconTemplate = toastGroup?.querySelector( + "[data-loading-icon-template]" + ) as HTMLElement; const loadingIcon = loadingIconTemplate?.innerHTML; if (isInfinity) { @@ -118,12 +132,12 @@ export class ToastItem extends Component, toast.Api> }; } -export class ToastGroup extends Component { +export class ToastGroup extends Component { private toastComponents = new Map(); private groupEl: HTMLElement; public store: Store; - constructor(el: HTMLElement, props: toast.GroupProps) { + constructor(el: HTMLElement, props: GroupProps) { super(el, props); this.store = props.store; @@ -140,12 +154,12 @@ export class ToastGroup extends Component { } // eslint-disable-next-line @typescript-eslint/no-explicit-any - initMachine(props: toast.GroupProps): VanillaMachine { - return new VanillaMachine(toast.group.machine, props); + initMachine(props: GroupProps): VanillaMachine { + return new VanillaMachine(group.machine, props); } - initApi(): toast.GroupApi { - return toast.group.connect(this.machine.service, normalizeProps); + initApi(): GroupApi { + return group.connect(this.machine.service, normalizeProps); } render() { @@ -153,7 +167,7 @@ export class ToastGroup extends Component { const toasts = this.api .getToasts() - .filter((t): t is toast.Props & { id: string } => typeof t.id === "string"); + .filter((t): t is Props & { id: string } => typeof t.id === "string"); const nextIds = new Set(toasts.map((t) => t.id)); @@ -201,10 +215,9 @@ export class ToastGroup extends Component { }; } - export function createToastGroup( container: HTMLElement, - options?: Partial & { + options?: Partial & { id?: string; store?: Store; } @@ -213,7 +226,7 @@ export function createToastGroup( const store = options?.store ?? - toast.createStore({ + createStore({ placement: options?.placement ?? "bottom", overlap: options?.overlap, max: options?.max, @@ -244,7 +257,7 @@ export function getToastStore(groupId?: string): Store | undefined { return id ? toastStores.get(id) : undefined; } -export function createToast(options: toast.Options & { groupId?: string }) { +export function createToast(options: Options & { groupId?: string }) { const store = getToastStore(options.groupId); if (!store) throw new Error("No toast store found"); @@ -254,7 +267,7 @@ export function createToast(options: toast.Options & { groupId?: string }) { }); } -export function updateToast(id: string, options: Partial, groupId?: string) { +export function updateToast(id: string, options: Partial, groupId?: string) { getToastStore(groupId)?.update(id, options); } diff --git a/assets/components/toggle-group.ts b/assets/components/toggle-group.ts index 75876ea..8fac7d0 100644 --- a/assets/components/toggle-group.ts +++ b/assets/components/toggle-group.ts @@ -1,24 +1,28 @@ -import * as toggleGroup from "@zag-js/toggle-group"; +import { connect, machine, type Props, type Api } from "@zag-js/toggle-group"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; import { getString, getBoolean } from "../lib/util"; -export class ToggleGroup extends Component { +export class ToggleGroup extends Component { // eslint-disable-next-line @typescript-eslint/no-explicit-any - initMachine(props: toggleGroup.Props): VanillaMachine { - return new VanillaMachine(toggleGroup.machine, props); + initMachine(props: Props): VanillaMachine { + return new VanillaMachine(machine, props); } - initApi(): toggleGroup.Api { - return toggleGroup.connect(this.machine.service, normalizeProps); + initApi(): Api { + return connect(this.machine.service, normalizeProps); } render(): void { - const rootEl = this.el.querySelector('[data-scope="toggle-group"][data-part="root"]'); + const rootEl = this.el.querySelector( + '[data-scope="toggle-group"][data-part="root"]' + ); if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const items = this.el.querySelectorAll('[data-scope="toggle-group"][data-part="item"]'); + const items = this.el.querySelectorAll( + '[data-scope="toggle-group"][data-part="item"]' + ); for (let i = 0; i < items.length; i++) { const itemEl = items[i]; @@ -27,7 +31,6 @@ export class ToggleGroup extends Component { const disabled = getBoolean(itemEl, "disabled"); this.spreadProps(itemEl, this.api.getItemProps({ value, disabled })); - } } } diff --git a/assets/components/tree-view.ts b/assets/components/tree-view.ts index 193feea..28f2a6c 100644 --- a/assets/components/tree-view.ts +++ b/assets/components/tree-view.ts @@ -1,4 +1,10 @@ -import * as tree from "@zag-js/tree-view"; +import { + collection, + connect, + machine, + type Props, + type Api, +} from "@zag-js/tree-view"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; @@ -47,41 +53,40 @@ function buildTreeFromDOM(rootEl: HTMLElement): TreeNode { } const lastIdx = pathArr[pathArr.length - 1]!; if (!parent.children) parent.children = []; - parent.children[lastIdx] = isBranch - ? { id, name, children: [] } - : { id, name }; + parent.children[lastIdx] = isBranch ? { id, name, children: [] } : { id, name }; } return root; } -export class TreeView extends Component { - private collection: ReturnType>; +export class TreeView extends Component { + private treeCollection: ReturnType>; constructor( el: HTMLElement | null, - props: Omit & { treeData?: TreeNode } + props: Omit & { treeData?: TreeNode } ) { const treeData = props.treeData ?? buildTreeFromDOM(el as HTMLElement); - const collection = tree.collection({ + const treeCollection = collection({ nodeToValue: (node) => node.id, nodeToString: (node) => node.name, rootNode: treeData, }); - super(el, { ...props, collection } as tree.Props); - this.collection = collection; + super(el, { ...props, collection: treeCollection } as Props); + this.treeCollection = treeCollection; } - initMachine(props: tree.Props): VanillaMachine { - return new VanillaMachine(tree.machine, { ...props }); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + initMachine(props: Props): VanillaMachine { + return new VanillaMachine(machine, { ...props }); } - initApi(): tree.Api { - return tree.connect(this.machine.service, normalizeProps); + initApi(): Api { + return connect(this.machine.service, normalizeProps); } private getNodeAt(indexPath: number[]): TreeNode | undefined { if (indexPath.length === 0) return undefined; - let current: TreeNode | undefined = this.collection.rootNode as TreeNode; + let current: TreeNode | undefined = this.treeCollection.rootNode as TreeNode; for (const i of indexPath) { current = current?.children?.[i]; if (!current) return undefined; @@ -118,8 +123,7 @@ export class TreeView extends Component { const indicatorEl = branchEl.querySelector( '[data-scope="tree-view"][data-part="branch-indicator"]' ); - if (indicatorEl) - this.spreadProps(indicatorEl, this.api.getBranchIndicatorProps(nodeProps)); + if (indicatorEl) this.spreadProps(indicatorEl, this.api.getBranchIndicatorProps(nodeProps)); const contentEl = branchEl.querySelector( '[data-scope="tree-view"][data-part="branch-content"]' @@ -148,9 +152,7 @@ export class TreeView extends Component { } private syncTree = () => { - const treeEl = this.el.querySelector( - '[data-scope="tree-view"][data-part="tree"]' - ); + const treeEl = this.el.querySelector('[data-scope="tree-view"][data-part="tree"]'); if (!treeEl) return; this.spreadProps(treeEl, this.api.getTreeProps()); @@ -159,14 +161,10 @@ export class TreeView extends Component { render(): void { const rootEl = - this.el.querySelector( - '[data-scope="tree-view"][data-part="root"]' - ) ?? this.el; + this.el.querySelector('[data-scope="tree-view"][data-part="root"]') ?? this.el; this.spreadProps(rootEl, this.api.getRootProps()); - const label = this.el.querySelector( - '[data-scope="tree-view"][data-part="label"]' - ); + const label = this.el.querySelector('[data-scope="tree-view"][data-part="label"]'); if (label) this.spreadProps(label, this.api.getLabelProps()); this.syncTree(); diff --git a/assets/hooks/accordion.ts b/assets/hooks/accordion.ts index fccd3f7..23e09d0 100644 --- a/assets/hooks/accordion.ts +++ b/assets/hooks/accordion.ts @@ -14,67 +14,64 @@ type AccordionHookState = { const AccordionHook: Hook = { mounted(this: object & HookInterface & AccordionHookState) { - const el = this.el; const pushEvent = this.pushEvent.bind(this); - const accordion = new Accordion(el, - { - id: el.id, - ...(getBoolean(el, "controlled") - ? { value: getStringList(el, "value") } - : { defaultValue: getStringList(el, "defaultValue") }), - collapsible: getBoolean(el, "collapsible"), - multiple: getBoolean(el, "multiple"), - orientation: getString(el, "orientation", ["horizontal", "vertical"]), - dir: getDir(el), - onValueChange: (details: ValueChangeDetails) => { - const eventName = getString(el, "onValueChange"); - if (eventName && this.liveSocket.main.isConnected()) { - pushEvent(eventName, { - id: el.id, - value: details.value ?? null, - }); - } - - const eventNameClient = getString(el, "onValueChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: details.value ?? null, - }, - }) - ); - } - }, - - onFocusChange: (details: FocusChangeDetails) => { - const eventName = getString(el, "onFocusChange"); - if (eventName && this.liveSocket.main.isConnected()) { - pushEvent(eventName, { - id: el.id, - value: details.value ?? null, - }); - } - - const eventNameClient = getString(el, "onFocusChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: details.value ?? null, - }, - }) - ); - } - }, - } - ); + const accordion = new Accordion(el, { + id: el.id, + ...(getBoolean(el, "controlled") + ? { value: getStringList(el, "value") } + : { defaultValue: getStringList(el, "defaultValue") }), + collapsible: getBoolean(el, "collapsible"), + multiple: getBoolean(el, "multiple"), + orientation: getString(el, "orientation", ["horizontal", "vertical"]), + dir: getDir(el), + onValueChange: (details: ValueChangeDetails) => { + const eventName = getString(el, "onValueChange"); + if (eventName && this.liveSocket.main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: details.value ?? null, + }); + } + + const eventNameClient = getString(el, "onValueChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: details.value ?? null, + }, + }) + ); + } + }, + + onFocusChange: (details: FocusChangeDetails) => { + const eventName = getString(el, "onFocusChange"); + if (eventName && this.liveSocket.main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: details.value ?? null, + }); + } + + const eventNameClient = getString(el, "onFocusChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: details.value ?? null, + }, + }) + ); + } + }, + }); accordion.init(); this.accordion = accordion; @@ -124,18 +121,15 @@ const AccordionHook: Hook = { ...(controlled ? { value: getStringList(this.el, "value") } : { - defaultValue: - this.accordion?.api?.value ?? getStringList(this.el, "defaultValue"), + defaultValue: this.accordion?.api?.value ?? getStringList(this.el, "defaultValue"), }), collapsible: getBoolean(this.el, "collapsible"), multiple: getBoolean(this.el, "multiple"), orientation: getString(this.el, "orientation", ["horizontal", "vertical"]), - dir: getDir(this.el) + dir: getDir(this.el), } as Props); }, - - destroyed(this: object & HookInterface & AccordionHookState) { if (this.onSetValue) { this.el.removeEventListener("phx:accordion:set-value", this.onSetValue); diff --git a/assets/hooks/checkbox.ts b/assets/hooks/checkbox.ts index 84bf729..fd608ba 100644 --- a/assets/hooks/checkbox.ts +++ b/assets/hooks/checkbox.ts @@ -16,12 +16,12 @@ const CheckboxHook: Hook = { mounted(this: object & HookInterface & CheckboxHookState) { const el = this.el; const pushEvent = this.pushEvent.bind(this); - + const zagCheckbox = new Checkbox(el, { id: el.id, ...(getBoolean(el, "controlled") - ? { checked: getBoolean(el, "checked") } - : { defaultChecked: getBoolean(el, "defaultChecked") }), + ? { checked: getBoolean(el, "checked") } + : { defaultChecked: getBoolean(el, "defaultChecked") }), disabled: getBoolean(el, "disabled"), name: getString(el, "name"), form: getString(el, "form"), @@ -113,7 +113,6 @@ const CheckboxHook: Hook = { }, updated(this: object & HookInterface & CheckboxHookState) { - this.checkbox?.updateProps({ id: this.el.id, ...(getBoolean(this.el, "controlled") diff --git a/assets/hooks/clipboard.ts b/assets/hooks/clipboard.ts index 4403218..b0360f0 100644 --- a/assets/hooks/clipboard.ts +++ b/assets/hooks/clipboard.ts @@ -23,8 +23,8 @@ const ClipboardHook: Hook = { id: el.id, timeout: getNumber(el, "timeout"), ...(getBoolean(el, "controlled") - ? { value: getString(el, "value") } - : { defaultValue: getString(el, "defaultValue") }), + ? { value: getString(el, "value") } + : { defaultValue: getString(el, "defaultValue") }), onValueChange: (details: ValueChangeDetails) => { const eventName = getString(el, "onValueChange"); @@ -79,11 +79,14 @@ const ClipboardHook: Hook = { ); this.handlers.push( - this.handleEvent("clipboard_set_value", (payload: { clipboard_id?: string; value: string }) => { - const targetId = payload.clipboard_id; - if (targetId && targetId !== el.id) return; - clipboard.api.setValue(payload.value); - }) + this.handleEvent( + "clipboard_set_value", + (payload: { clipboard_id?: string; value: string }) => { + const targetId = payload.clipboard_id; + if (targetId && targetId !== el.id) return; + clipboard.api.setValue(payload.value); + } + ) ); this.handlers.push( diff --git a/assets/hooks/collapsible.ts b/assets/hooks/collapsible.ts index a34b325..c977406 100644 --- a/assets/hooks/collapsible.ts +++ b/assets/hooks/collapsible.ts @@ -60,11 +60,14 @@ const CollapsibleHook: Hook = { this.handlers = []; this.handlers.push( - this.handleEvent("collapsible_set_open", (payload: { collapsible_id?: string; open: boolean }) => { - const targetId = payload.collapsible_id; - if (targetId && targetId !== el.id) return; - collapsible.api.setOpen(payload.open); - }) + this.handleEvent( + "collapsible_set_open", + (payload: { collapsible_id?: string; open: boolean }) => { + const targetId = payload.collapsible_id; + if (targetId && targetId !== el.id) return; + collapsible.api.setOpen(payload.open); + } + ) ); this.handlers.push( diff --git a/assets/hooks/combobox.ts b/assets/hooks/combobox.ts index 6583537..3464d7c 100644 --- a/assets/hooks/combobox.ts +++ b/assets/hooks/combobox.ts @@ -1,7 +1,13 @@ import type { Hook } from "phoenix_live_view"; import type { HookInterface, CallbackRef } from "phoenix_live_view/assets/js/types/view_hook"; import { Combobox } from "../components/combobox"; -import type { Props, InputValueChangeDetails, OpenChangeDetails, ValueChangeDetails, PositioningOptions } from "@zag-js/combobox"; +import type { + Props, + InputValueChangeDetails, + OpenChangeDetails, + ValueChangeDetails, + PositioningOptions, +} from "@zag-js/combobox"; import type { Direction } from "@zag-js/types"; import { getString, getBoolean, getStringList } from "../lib/util"; @@ -15,8 +21,8 @@ function snakeToCamel(str: string): string { return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()); } -function transformPositioningOptions(obj: any): PositioningOptions { - const result: any = {}; +function transformPositioningOptions(obj: Record): PositioningOptions { + const result: Record = {}; for (const [key, value] of Object.entries(obj)) { const camelKey = snakeToCamel(key); result[camelKey] = value; @@ -30,7 +36,7 @@ const ComboboxHook: Hook = { const pushEvent = this.pushEvent.bind(this); const allItems = JSON.parse(el.dataset.collection || "[]"); - const hasGroups = allItems.some((item: any) => item.group !== undefined); + const hasGroups = allItems.some((item: { group?: unknown }) => item.group !== undefined); const props: Props = { id: el.id, @@ -92,7 +98,6 @@ const ComboboxHook: Hook = { } }, onInputValueChange: (details: InputValueChangeDetails) => { - const eventName = getString(el, "onInputValueChange"); if (eventName && !this.liveSocket.main.isDead && this.liveSocket.main.isConnected()) { pushEvent(eventName, { @@ -117,58 +122,57 @@ const ComboboxHook: Hook = { } }, onValueChange: (details: ValueChangeDetails) => { - const valueInput = el.querySelector( '[data-scope="combobox"][data-part="value-input"]' ); if (valueInput) { - const idValue = details.value.length === 0 - ? "" - : details.value.length === 1 - ? String(details.value[0]) - : details.value.map(String).join(","); + const idValue = + details.value.length === 0 + ? "" + : details.value.length === 1 + ? String(details.value[0]) + : details.value.map(String).join(","); valueInput.value = idValue; - + const formId = valueInput.getAttribute("form"); let form: HTMLFormElement | null = null; - + if (formId) { form = document.getElementById(formId) as HTMLFormElement; } else { form = valueInput.closest("form"); } - - const changeEvent = new Event("change", { - bubbles: true, - cancelable: true + + const changeEvent = new Event("change", { + bubbles: true, + cancelable: true, }); valueInput.dispatchEvent(changeEvent); - - const inputEvent = new Event("input", { - bubbles: true, - cancelable: true + + const inputEvent = new Event("input", { + bubbles: true, + cancelable: true, }); valueInput.dispatchEvent(inputEvent); - - if (form && form.hasAttribute("phx-change")) { + + if (form && form.hasAttribute("phx-change")) { requestAnimationFrame(() => { - const formElement = form.querySelector('input, select, textarea') as HTMLElement; + const formElement = form.querySelector("input, select, textarea") as HTMLElement; if (formElement) { - const formChangeEvent = new Event("change", { - bubbles: true, - cancelable: true + const formChangeEvent = new Event("change", { + bubbles: true, + cancelable: true, }); formElement.dispatchEvent(formChangeEvent); } else { - const formChangeEvent = new Event("change", { - bubbles: true, - cancelable: true + const formChangeEvent = new Event("change", { + bubbles: true, + cancelable: true, }); form.dispatchEvent(formChangeEvent); } }); } - } const eventName = getString(el, "onValueChange"); @@ -204,13 +208,15 @@ const ComboboxHook: Hook = { const initialValue = getBoolean(el, "controlled") ? getStringList(el, "value") : getStringList(el, "defaultValue"); - + if (initialValue && initialValue.length > 0) { - const selectedItems = allItems.filter((item: any) => - initialValue.includes(item.id) + const selectedItems = allItems.filter( + (item: { id?: string }) => initialValue.includes(item.id ?? "") ); if (selectedItems.length > 0) { - const inputValue = selectedItems.map((item: any) => item.label).join(", "); + const inputValue = selectedItems + .map((item: { label?: string }) => item.label ?? "") + .join(", "); if (combobox.api && typeof combobox.api.setInputValue === "function") { combobox.api.setInputValue(inputValue); } else { @@ -230,8 +236,8 @@ const ComboboxHook: Hook = { updated(this: object & HookInterface & ComboboxHookState) { const newCollection = JSON.parse(this.el.dataset.collection || "[]"); - const hasGroups = newCollection.some((item: any) => item.group !== undefined); - + const hasGroups = newCollection.some((item: { group?: unknown }) => item.group !== undefined); + if (this.combobox) { this.combobox.hasGroups = hasGroups; this.combobox.setAllOptions(newCollection); @@ -248,7 +254,7 @@ const ComboboxHook: Hook = { required: getBoolean(this.el, "required"), readOnly: getBoolean(this.el, "readOnly"), }); - + const inputEl = this.el.querySelector( '[data-scope="combobox"][data-part="input"]' ); @@ -271,4 +277,4 @@ const ComboboxHook: Hook = { }, }; -export { ComboboxHook as Combobox }; \ No newline at end of file +export { ComboboxHook as Combobox }; diff --git a/assets/hooks/corex.ts b/assets/hooks/corex.ts index a2dc197..4a37a3f 100644 --- a/assets/hooks/corex.ts +++ b/assets/hooks/corex.ts @@ -1,11 +1,8 @@ import type { Hook } from "phoenix_live_view"; -type HookModule = Record | undefined>; +type HookModule = Record | undefined>; -function hooks( - importFn: () => Promise, - exportName: string -): Hook { +function hooks(importFn: () => Promise, exportName: string): Hook { return { async mounted() { const mod = await importFn(); diff --git a/assets/hooks/date-picker.ts b/assets/hooks/date-picker.ts index 23af83d..0ca2911 100644 --- a/assets/hooks/date-picker.ts +++ b/assets/hooks/date-picker.ts @@ -28,15 +28,15 @@ const DatePickerHook: Hook = { const min = getString(el, "min"); const max = getString(el, "max"); const positioningJson = getString(el, "positioning"); - const parseList = (v: string[] | undefined) => (v ? v.map((x) => datePicker.parse(x)) : undefined); + const parseList = (v: string[] | undefined) => + v ? v.map((x) => datePicker.parse(x)) : undefined; const parseOne = (v: string | undefined) => (v ? datePicker.parse(v) : undefined); - const datePickerInstance = new DatePicker(el, { id: el.id, ...(getBoolean(el, "controlled") - ? { value: parseList(getStringList(el, "value") ) } - : { defaultValue: parseList(getStringList(el, "defaultValue") )}), + ? { value: parseList(getStringList(el, "value")) } + : { defaultValue: parseList(getStringList(el, "defaultValue")) }), defaultFocusedValue: parseOne(getString(el, "focusedValue")), defaultView: getString<"day" | "month" | "year">(el, "defaultView", ["day", "month", "year"]), dir: getString(el, "dir", ["ltr", "rtl"]), @@ -53,7 +53,11 @@ const DatePickerHook: Hook = { numOfMonths: getNumber(el, "numOfMonths"), startOfWeek: getNumber(el, "startOfWeek"), fixedWeeks: getBoolean(el, "fixedWeeks"), - selectionMode: getString<"single" | "multiple" | "range">(el, "selectionMode", ["single", "multiple", "range"]), + selectionMode: getString<"single" | "multiple" | "range">(el, "selectionMode", [ + "single", + "multiple", + "range", + ]), placeholder: getString(el, "placeholder"), minView: getString<"day" | "month" | "year">(el, "minView", ["day", "month", "year"]), maxView: getString<"day" | "month" | "year">(el, "maxView", ["day", "month", "year"]), @@ -67,9 +71,7 @@ const DatePickerHook: Hook = { .join(",") : ""; - const hiddenInput = el.querySelector( - `#${el.id}-value` - ); + const hiddenInput = el.querySelector(`#${el.id}-value`); if (hiddenInput && hiddenInput.value !== isoStr) { hiddenInput.value = isoStr; hiddenInput.dispatchEvent(new Event("input", { bubbles: true })); @@ -84,7 +86,7 @@ const DatePickerHook: Hook = { }); } }, - onFocusChange: (details: any) => { + onFocusChange: (details: { focused?: boolean }) => { const eventName = getString(el, "onFocusChange"); if (eventName && liveSocket.main.isConnected()) { pushEvent(eventName, { @@ -102,7 +104,7 @@ const DatePickerHook: Hook = { }); } }, - onVisibleRangeChange: (details: any) => { + onVisibleRangeChange: (details: { start?: unknown; end?: unknown }) => { const eventName = getString(el, "onVisibleRangeChange"); if (eventName && liveSocket.main.isConnected()) { pushEvent(eventName, { @@ -112,7 +114,7 @@ const DatePickerHook: Hook = { }); } }, - onOpenChange: (details: any) => { + onOpenChange: (details: { open?: boolean }) => { const eventName = getString(el, "onOpenChange"); if (eventName && liveSocket.main.isConnected()) { pushEvent(eventName, { @@ -127,18 +129,21 @@ const DatePickerHook: Hook = { this.datePicker = datePickerInstance; const inputWrapper = el.querySelector( - '[data-scope="date-picker"][data-part="input-wrapper"]', + '[data-scope="date-picker"][data-part="input-wrapper"]' ); if (inputWrapper) inputWrapper.removeAttribute("data-loading"); this.handlers = []; this.handlers.push( - this.handleEvent("date_picker_set_value", (payload: { date_picker_id?: string; value: string }) => { - const targetId = payload.date_picker_id; - if (targetId && targetId !== el.id) return; - datePickerInstance.api.setValue([datePicker.parse(payload.value)]); - }) + this.handleEvent( + "date_picker_set_value", + (payload: { date_picker_id?: string; value: string }) => { + const targetId = payload.date_picker_id; + if (targetId && targetId !== el.id) return; + datePickerInstance.api.setValue([datePicker.parse(payload.value)]); + } + ) ); this.onSetValue = (event: Event) => { @@ -153,11 +158,12 @@ const DatePickerHook: Hook = { updated(this: object & HookInterface & DatePickerHookState) { const el = this.el; const inputWrapper = el.querySelector( - '[data-scope="date-picker"][data-part="input-wrapper"]', + '[data-scope="date-picker"][data-part="input-wrapper"]' ); if (inputWrapper) inputWrapper.removeAttribute("data-loading"); - const parseList = (v: string[] | undefined) => (v ? v.map((x) => datePicker.parse(x)) : undefined); + const parseList = (v: string[] | undefined) => + v ? v.map((x) => datePicker.parse(x)) : undefined; const min = getString(el, "min"); const max = getString(el, "max"); const positioningJson = getString(el, "positioning"); @@ -166,8 +172,8 @@ const DatePickerHook: Hook = { this.datePicker?.updateProps({ ...(getBoolean(el, "controlled") - ? { value: parseList(getStringList(el, "value") ) } - : { defaultValue: parseList(getStringList(el, "defaultValue") )}), + ? { value: parseList(getStringList(el, "value")) } + : { defaultValue: parseList(getStringList(el, "defaultValue")) }), defaultFocusedValue: focusedStr ? datePicker.parse(focusedStr) : undefined, defaultView: getString<"day" | "month" | "year">(el, "defaultView", ["day", "month", "year"]), dir: getString(this.el, "dir", ["ltr", "rtl"]), @@ -184,7 +190,11 @@ const DatePickerHook: Hook = { numOfMonths: getNumber(this.el, "numOfMonths"), startOfWeek: getNumber(this.el, "startOfWeek"), fixedWeeks: getBoolean(this.el, "fixedWeeks"), - selectionMode: getString<"single" | "multiple" | "range">(this.el, "selectionMode", ["single", "multiple", "range"]), + selectionMode: getString<"single" | "multiple" | "range">(this.el, "selectionMode", [ + "single", + "multiple", + "range", + ]), placeholder: getString(this.el, "placeholder"), minView: getString<"day" | "month" | "year">(this.el, "minView", ["day", "month", "year"]), maxView: getString<"day" | "month" | "year">(this.el, "maxView", ["day", "month", "year"]), @@ -197,12 +207,12 @@ const DatePickerHook: Hook = { const serverIso = serverValues?.join(",") ?? ""; const zagValue = this.datePicker.api.value; const zagIso = zagValue?.length - ? zagValue.map((d: { year: number; month: number; day: number }) => toISOString(d)).join(",") + ? zagValue + .map((d: { year: number; month: number; day: number }) => toISOString(d)) + .join(",") : ""; if (serverIso !== zagIso) { - const parsed = serverValues?.length - ? serverValues.map((x) => datePicker.parse(x)) - : []; + const parsed = serverValues?.length ? serverValues.map((x) => datePicker.parse(x)) : []; this.datePicker.api.setValue(parsed); } } diff --git a/assets/hooks/dialog.ts b/assets/hooks/dialog.ts index 9647796..a348a4a 100644 --- a/assets/hooks/dialog.ts +++ b/assets/hooks/dialog.ts @@ -28,7 +28,7 @@ const DialogHook: Hook = { preventScroll: getBoolean(el, "preventScroll"), restoreFocus: getBoolean(el, "restoreFocus"), dir: getString(el, "dir", ["ltr", "rtl"]), - + onOpenChange: (details: OpenChangeDetails) => { const eventName = getString(el, "onOpenChange"); if (eventName && this.liveSocket.main.isConnected()) { diff --git a/assets/hooks/menu.ts b/assets/hooks/menu.ts index 3104192..1844b43 100644 --- a/assets/hooks/menu.ts +++ b/assets/hooks/menu.ts @@ -21,82 +21,79 @@ const MenuHook: Hook = { return; } - const menu = new Menu( - el, - { - id: el.id.replace("menu:", ""), - ...(getBoolean(el, "controlled") - ? { open: getBoolean(el, "open") } - : { defaultOpen: getBoolean(el, "defaultOpen") }), - closeOnSelect: getBoolean(el, "closeOnSelect"), - loopFocus: getBoolean(el, "loopFocus"), - typeahead: getBoolean(el, "typeahead"), - composite: getBoolean(el, "composite"), - dir: getString(el, "dir", ["ltr", "rtl"]), - onSelect: (details: SelectionDetails) => { - const redirect = getBoolean(el, "redirect"); - const itemEl = [...el.querySelectorAll('[data-scope="menu"][data-part="item"]')].find( - (node) => node.getAttribute("data-value") === details.value - ); - const itemRedirect = itemEl?.getAttribute("data-redirect"); - const itemNewTab = itemEl?.hasAttribute("data-new-tab"); - const doRedirect = - redirect && - details.value && - !this.liveSocket.main.isConnected() && - itemRedirect !== "false"; - if (doRedirect) { - if (itemNewTab) { - window.open(details.value, "_blank", "noopener,noreferrer"); - } else { - window.location.href = details.value; - } - } - const eventName = getString(el, "onSelect"); - if (eventName && this.liveSocket.main.isConnected()) { - this.pushEvent(eventName, { - id: el.id, - value: details.value ?? null, - }); + const menu = new Menu(el, { + id: el.id.replace("menu:", ""), + ...(getBoolean(el, "controlled") + ? { open: getBoolean(el, "open") } + : { defaultOpen: getBoolean(el, "defaultOpen") }), + closeOnSelect: getBoolean(el, "closeOnSelect"), + loopFocus: getBoolean(el, "loopFocus"), + typeahead: getBoolean(el, "typeahead"), + composite: getBoolean(el, "composite"), + dir: getString(el, "dir", ["ltr", "rtl"]), + onSelect: (details: SelectionDetails) => { + const redirect = getBoolean(el, "redirect"); + const itemEl = [ + ...el.querySelectorAll('[data-scope="menu"][data-part="item"]'), + ].find((node) => node.getAttribute("data-value") === details.value); + const itemRedirect = itemEl?.getAttribute("data-redirect"); + const itemNewTab = itemEl?.hasAttribute("data-new-tab"); + const doRedirect = + redirect && + details.value && + !this.liveSocket.main.isConnected() && + itemRedirect !== "false"; + if (doRedirect) { + if (itemNewTab) { + window.open(details.value, "_blank", "noopener,noreferrer"); + } else { + window.location.href = details.value; } + } + const eventName = getString(el, "onSelect"); + if (eventName && this.liveSocket.main.isConnected()) { + this.pushEvent(eventName, { + id: el.id, + value: details.value ?? null, + }); + } - const eventNameClient = getString(el, "onSelectClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: details.value ?? null, - }, - }) - ); - } - }, - onOpenChange: (details: OpenChangeDetails) => { - const eventName = getString(el, "onOpenChange"); - if (eventName && this.liveSocket.main.isConnected()) { - this.pushEvent(eventName, { - id: el.id, - open: details.open ?? false, - }); - } + const eventNameClient = getString(el, "onSelectClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: details.value ?? null, + }, + }) + ); + } + }, + onOpenChange: (details: OpenChangeDetails) => { + const eventName = getString(el, "onOpenChange"); + if (eventName && this.liveSocket.main.isConnected()) { + this.pushEvent(eventName, { + id: el.id, + open: details.open ?? false, + }); + } - const eventNameClient = getString(el, "onOpenChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - open: details.open ?? false, - }, - }) - ); - } - }, - } - ); + const eventNameClient = getString(el, "onOpenChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + open: details.open ?? false, + }, + }) + ); + } + }, + }); menu.init(); this.menu = menu; @@ -104,7 +101,7 @@ const MenuHook: Hook = { const nestedMenuElements = el.querySelectorAll( '[data-scope="menu"][data-nested="menu"]' ); - + const nestedMenuInstances: Menu[] = []; nestedMenuElements.forEach((nestedEl) => { const nestedId = nestedEl.id; @@ -118,13 +115,13 @@ const MenuHook: Hook = { typeahead: getBoolean(nestedEl, "typeahead"), composite: getBoolean(nestedEl, "composite"), }); - + nestedMenu.init(); this.nestedMenus?.set(nestedId, nestedMenu); nestedMenuInstances.push(nestedMenu); } }); - + setTimeout(() => { nestedMenuInstances.forEach((nestedMenu) => { if (this.menu) { diff --git a/assets/hooks/select.ts b/assets/hooks/select.ts index 22715b0..cf31f41 100644 --- a/assets/hooks/select.ts +++ b/assets/hooks/select.ts @@ -17,8 +17,8 @@ function snakeToCamel(str: string): string { return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()); } -function transformPositioningOptions(obj: any): PositioningOptions { - const result: any = {}; +function transformPositioningOptions(obj: Record): PositioningOptions { + const result: Record = {}; for (const [key, value] of Object.entries(obj)) { const camelKey = snakeToCamel(key); result[camelKey] = value; @@ -30,112 +30,94 @@ const SelectHook: Hook = { mounted(this: object & HookInterface & SelectHookState) { const el = this.el; const allItems = JSON.parse(el.dataset.collection || "[]"); - const hasGroups = allItems.some((item: any) => item.group !== undefined); - let selectComponent: Select | undefined; - const hook = this; - this.wasFocused = false; - - - - selectComponent = new Select(el, - { - id: el.id, - ...(getBoolean(el, "controlled") - ? { value: getStringList(el, "value") } - : { defaultValue: getStringList(el, "defaultValue") }), - disabled: getBoolean(el, "disabled"), - closeOnSelect: getBoolean(el, "closeOnSelect"), - dir: getString(el, "dir", ["ltr", "rtl"]), - loopFocus: getBoolean(el, "loopFocus"), - multiple: getBoolean(el, "multiple"), - invalid: getBoolean(el, "invalid"), - name: getString(el, "name"), - form: getString(el, "form"), - readOnly: getBoolean(el, "readOnly"), - required: getBoolean(el, "required"), - positioning: (() => { - const positioningJson = el.dataset.positioning; - if (positioningJson) { - try { - const parsed = JSON.parse(positioningJson); - return transformPositioningOptions(parsed); - } catch { - return undefined; - } - } - return undefined; - })(), - onValueChange: (details: ValueChangeDetails) => { - const redirect = getBoolean(el, "redirect"); - const firstValue = - details.value.length > 0 ? String(details.value[0]) : null; - const firstItem = details.items?.length ? details.items[0] : null; - const itemRedirect = firstItem && typeof firstItem === "object" && firstItem !== null && "redirect" in firstItem ? (firstItem as { redirect?: boolean }).redirect : undefined; - const itemNewTab = firstItem && typeof firstItem === "object" && firstItem !== null && "new_tab" in firstItem ? (firstItem as { new_tab?: boolean }).new_tab : undefined; - const doRedirect = redirect && firstValue && hook.liveSocket.main.isDead && itemRedirect !== false; - const openInNewTab = itemNewTab === true; - if (doRedirect) { - if (openInNewTab) { - window.open(firstValue, "_blank", "noopener,noreferrer"); - } else { - window.location.href = firstValue; - } + const hasGroups = allItems.some((item: { group?: unknown }) => item.group !== undefined); + const selectComponent = new Select(el, { + id: el.id, + ...(getBoolean(el, "controlled") + ? { value: getStringList(el, "value") } + : { defaultValue: getStringList(el, "defaultValue") }), + disabled: getBoolean(el, "disabled"), + closeOnSelect: getBoolean(el, "closeOnSelect"), + dir: getString(el, "dir", ["ltr", "rtl"]), + loopFocus: getBoolean(el, "loopFocus"), + multiple: getBoolean(el, "multiple"), + invalid: getBoolean(el, "invalid"), + name: getString(el, "name"), + form: getString(el, "form"), + readOnly: getBoolean(el, "readOnly"), + required: getBoolean(el, "required"), + positioning: (() => { + const positioningJson = el.dataset.positioning; + if (positioningJson) { + try { + const parsed = JSON.parse(positioningJson); + return transformPositioningOptions(parsed); + } catch { + return undefined; } - const valueInput = el.querySelector( - '[data-scope="select"][data-part="value-input"]' - ); - if (valueInput) { - valueInput.value = - details.value.length === 0 - ? "" - : details.value.length === 1 - ? String(details.value[0]) - : details.value.map(String).join(","); - valueInput.dispatchEvent(new Event("input", { bubbles: true })); - valueInput.dispatchEvent(new Event("change", { bubbles: true })); + } + return undefined; + })(), + onValueChange: (details: ValueChangeDetails) => { + const redirect = getBoolean(el, "redirect"); + const firstValue = details.value.length > 0 ? String(details.value[0]) : null; + const firstItem = details.items?.length ? details.items[0] : null; + const itemRedirect = + firstItem && + typeof firstItem === "object" && + firstItem !== null && + "redirect" in firstItem + ? (firstItem as { redirect?: boolean }).redirect + : undefined; + const itemNewTab = + firstItem && typeof firstItem === "object" && firstItem !== null && "new_tab" in firstItem + ? (firstItem as { new_tab?: boolean }).new_tab + : undefined; + const doRedirect = + redirect && firstValue && this.liveSocket.main.isDead && itemRedirect !== false; + const openInNewTab = itemNewTab === true; + if (doRedirect) { + if (openInNewTab) { + window.open(firstValue, "_blank", "noopener,noreferrer"); + } else { + window.location.href = firstValue; } + } + const valueInput = el.querySelector( + '[data-scope="select"][data-part="value-input"]' + ); + if (valueInput) { + valueInput.value = + details.value.length === 0 + ? "" + : details.value.length === 1 + ? String(details.value[0]) + : details.value.map(String).join(","); + valueInput.dispatchEvent(new Event("input", { bubbles: true })); + valueInput.dispatchEvent(new Event("change", { bubbles: true })); + } - - - const payload: Record = { - value: details.value, - items: details.items, - id: el.id, - }; + const payload: Record = { + value: details.value, + items: details.items, + id: el.id, + }; - const encodedJS = el.getAttribute("data-on-value-change-js"); - if (encodedJS) { - let js = encodedJS; - const indexMatches = [...js.matchAll(/__VALUE_(\d+)__/g)].map((m) => parseInt(m[1], 10)); - const uniqueIndices = [...new Set(indexMatches)].sort((a, b) => b - a); - for (const i of uniqueIndices) { - const val = details.value[i]; - const str = val !== undefined && val !== null ? String(val) : ""; - const escaped = JSON.stringify(str).slice(1, -1); - js = js.split(`__VALUE_${i}__`).join(escaped); - } - js = js.split("__VALUE__").join(JSON.stringify(details.value)); - hook.liveSocket.execJS(el, js); - } - - const clientEventName = getString(el, "onValueChangeClient"); - if (clientEventName) { - el.dispatchEvent( - new CustomEvent(clientEventName, { bubbles: true, detail: payload }) - ); - } + const clientEventName = getString(el, "onValueChangeClient"); + if (clientEventName) { + el.dispatchEvent(new CustomEvent(clientEventName, { bubbles: true, detail: payload })); + } - const serverEventName = getString(el, "onValueChange"); - if ( - serverEventName && - !hook.liveSocket.main.isDead && - hook.liveSocket.main.isConnected() - ) { - this.pushEvent(serverEventName, payload); - } - }, - } as Props - ); + const serverEventName = getString(el, "onValueChange"); + if ( + serverEventName && + !this.liveSocket.main.isDead && + this.liveSocket.main.isConnected() + ) { + this.pushEvent(serverEventName, payload); + } + }, + } as Props); selectComponent.hasGroups = hasGroups; selectComponent.setOptions(allItems); selectComponent.init(); @@ -144,13 +126,9 @@ const SelectHook: Hook = { this.handlers = []; }, - beforeUpdate(this: object & HookInterface & SelectHookState) { - this.wasFocused = this.select?.api?.focused ?? false; - }, - updated(this: object & HookInterface & SelectHookState) { const newCollection = JSON.parse(this.el.dataset.collection || "[]"); - const hasGroups = newCollection.some((item: any) => item.group !== undefined); + const hasGroups = newCollection.some((item: { group?: unknown }) => item.group !== undefined); if (this.select) { this.select.hasGroups = hasGroups; @@ -170,20 +148,9 @@ const SelectHook: Hook = { required: getBoolean(this.el, "required"), readOnly: getBoolean(this.el, "readOnly"), } as Props); - - if (getBoolean(this.el, "controlled")) { - if (this.wasFocused) { - const trigger = this.el.querySelector('[data-scope="select"][data-part="trigger"]') as HTMLElement; - if (trigger && document.activeElement !== trigger) { - trigger.focus(); - } - } - } } }, - - destroyed(this: object & HookInterface & SelectHookState) { if (this.handlers) { for (const handler of this.handlers) { @@ -195,4 +162,4 @@ const SelectHook: Hook = { }, }; -export { SelectHook as Select }; \ No newline at end of file +export { SelectHook as Select }; diff --git a/assets/hooks/signature-pad.ts b/assets/hooks/signature-pad.ts index 9a83231..c200b8f 100644 --- a/assets/hooks/signature-pad.ts +++ b/assets/hooks/signature-pad.ts @@ -5,7 +5,7 @@ import type { Props } from "@zag-js/signature-pad"; import { getString, getBoolean, getNumber } from "../lib/util"; -function getPaths(el: HTMLElement, attr: string): any[] { +function getPaths(el: HTMLElement, attr: string): unknown[] { const value = el.dataset[attr]; if (!value) return []; try { @@ -49,7 +49,9 @@ const SignaturePadHook: Hook = { drawing: buildDrawingOptions(el), onDrawEnd: (details) => { signaturePad.setPaths(details.paths); - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.value = JSON.stringify(details.paths); } @@ -87,7 +89,9 @@ const SignaturePadHook: Hook = { const initialPaths = controlled ? paths : defaultPaths; if (initialPaths.length > 0) { - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.dispatchEvent(new Event("input", { bubbles: true })); hiddenInput.dispatchEvent(new Event("change", { bubbles: true })); @@ -100,7 +104,9 @@ const SignaturePadHook: Hook = { signaturePad.api.clear(); signaturePad.imageURL = ""; signaturePad.setPaths([]); - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.value = ""; } @@ -116,13 +122,14 @@ const SignaturePadHook: Hook = { signaturePad.api.clear(); signaturePad.imageURL = ""; signaturePad.setPaths([]); - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.value = ""; } }) ); - }, updated(this: object & HookInterface & SignaturePadHookState) { @@ -130,11 +137,11 @@ const SignaturePadHook: Hook = { const paths = getPaths(this.el, "paths"); const defaultPaths = getPaths(this.el, "defaultPaths"); const name = getString(this.el, "name"); - + if (name) { this.signaturePad?.setName(name); } - + this.signaturePad?.updateProps({ id: this.el.id, name: name, diff --git a/assets/hooks/tabs.ts b/assets/hooks/tabs.ts index a752f2c..fa580da 100644 --- a/assets/hooks/tabs.ts +++ b/assets/hooks/tabs.ts @@ -14,65 +14,62 @@ type TabsHookState = { const TabsHook: Hook = { mounted(this: object & HookInterface & TabsHookState) { - const el = this.el; const pushEvent = this.pushEvent.bind(this); - const tabs = new Tabs(el, - { - id: el.id, - ...(getBoolean(el, "controlled") - ? { value: getString(el, "value") } - : { defaultValue: getString(el, "defaultValue") }), - orientation: getString(el, "orientation", ["horizontal", "vertical"]), - dir: getString(el, "dir", ["ltr", "rtl"]), - onValueChange: (details: ValueChangeDetails) => { - const eventName = getString(el, "onValueChange"); - if (eventName && this.liveSocket.main.isConnected()) { - pushEvent(eventName, { - id: el.id, - value: details.value ?? null, - }); - } - - const eventNameClient = getString(el, "onValueChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: details.value ?? null, - }, - }) - ); - } - }, - - onFocusChange: (details: FocusChangeDetails) => { - const eventName = getString(el, "onFocusChange"); - if (eventName && this.liveSocket.main.isConnected()) { - pushEvent(eventName, { - id: el.id, - value: details.focusedValue ?? null, - }); - } - - const eventNameClient = getString(el, "onFocusChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: details.focusedValue ?? null, - }, - }) - ); - } - }, - } - ); + const tabs = new Tabs(el, { + id: el.id, + ...(getBoolean(el, "controlled") + ? { value: getString(el, "value") } + : { defaultValue: getString(el, "defaultValue") }), + orientation: getString(el, "orientation", ["horizontal", "vertical"]), + dir: getString(el, "dir", ["ltr", "rtl"]), + onValueChange: (details: ValueChangeDetails) => { + const eventName = getString(el, "onValueChange"); + if (eventName && this.liveSocket.main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: details.value ?? null, + }); + } + + const eventNameClient = getString(el, "onValueChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: details.value ?? null, + }, + }) + ); + } + }, + + onFocusChange: (details: FocusChangeDetails) => { + const eventName = getString(el, "onFocusChange"); + if (eventName && this.liveSocket.main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: details.focusedValue ?? null, + }); + } + + const eventNameClient = getString(el, "onFocusChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: details.focusedValue ?? null, + }, + }) + ); + } + }, + }); tabs.init(); this.tabs = tabs; @@ -85,14 +82,11 @@ const TabsHook: Hook = { this.handlers = []; this.handlers.push( - this.handleEvent( - "tabs_set_value", - (payload: { tabs_id?: string; value: string }) => { - const targetId = payload.tabs_id; - if (targetId && targetId !== el.id) return; - tabs.api.setValue(payload.value); - } - ) + this.handleEvent("tabs_set_value", (payload: { tabs_id?: string; value: string }) => { + const targetId = payload.tabs_id; + if (targetId && targetId !== el.id) return; + tabs.api.setValue(payload.value); + }) ); this.handlers.push( @@ -119,12 +113,10 @@ const TabsHook: Hook = { ? { value: getString(this.el, "value") } : { defaultValue: getString(this.el, "defaultValue") }), orientation: getString(this.el, "orientation", ["horizontal", "vertical"]), - dir: getString(this.el, "dir", ["ltr", "rtl"]) + dir: getString(this.el, "dir", ["ltr", "rtl"]), } as Props); }, - - destroyed(this: object & HookInterface & TabsHookState) { if (this.onSetValue) { this.el.removeEventListener("phx:tabs:set-value", this.onSetValue); diff --git a/assets/hooks/toast.ts b/assets/hooks/toast.ts index 1af7d43..7bddccd 100644 --- a/assets/hooks/toast.ts +++ b/assets/hooks/toast.ts @@ -48,10 +48,15 @@ const ToastHook: Hook = { return duration; }; - const placement = getString(el, "placement", [ - "top-start", "top", "top-end", - "bottom-start", "bottom", "bottom-end", - ]) ?? "bottom-end"; + const placement = + getString(el, "placement", [ + "top-start", + "top", + "top-end", + "bottom-start", + "bottom", + "bottom-end", + ]) ?? "bottom-end"; createToastGroup(el, { id: this.groupId, @@ -167,7 +172,6 @@ const ToastHook: Hook = { console.error("Failed to create toast:", error); } }) as EventListener); - }, destroyed(this: object & HookInterface & ToastHookState) { @@ -179,4 +183,4 @@ const ToastHook: Hook = { }, }; -export { ToastHook as Toast }; \ No newline at end of file +export { ToastHook as Toast }; diff --git a/assets/hooks/toggle-group.ts b/assets/hooks/toggle-group.ts index 5f11ea8..f3966dd 100644 --- a/assets/hooks/toggle-group.ts +++ b/assets/hooks/toggle-group.ts @@ -19,8 +19,8 @@ const ToggleGroupHook: Hook = { const props: Props = { id: el.id, ...(getBoolean(el, "controlled") - ? { value: getStringList(el, "value") } - : { defaultValue: getStringList(el, "defaultValue") }), + ? { value: getStringList(el, "value") } + : { defaultValue: getStringList(el, "defaultValue") }), defaultValue: getStringList(el, "defaultValue"), deselectable: getBoolean(el, "deselectable"), loopFocus: getBoolean(el, "loopFocus"), @@ -66,14 +66,11 @@ const ToggleGroupHook: Hook = { this.handlers = []; this.handlers.push( - this.handleEvent( - "toggle-group_set_value", - (payload: { id?: string; value: string[] }) => { - const targetId = payload.id; - if (targetId && targetId !== el.id) return; - toggleGroup.api.setValue(payload.value); - } - ) + this.handleEvent("toggle-group_set_value", (payload: { id?: string; value: string[] }) => { + const targetId = payload.id; + if (targetId && targetId !== el.id) return; + toggleGroup.api.setValue(payload.value); + }) ); this.handlers.push( @@ -88,8 +85,8 @@ const ToggleGroupHook: Hook = { updated(this: object & HookInterface & ToggleGroupHookState) { this.toggleGroup?.updateProps({ ...(getBoolean(this.el, "controlled") - ? { value: getStringList(this.el, "value") } - : { defaultValue: getStringList(this.el, "defaultValue") }), + ? { value: getStringList(this.el, "value") } + : { defaultValue: getStringList(this.el, "defaultValue") }), deselectable: getBoolean(this.el, "deselectable"), loopFocus: getBoolean(this.el, "loopFocus"), rovingFocus: getBoolean(this.el, "rovingFocus"), diff --git a/assets/hooks/tree-view.ts b/assets/hooks/tree-view.ts index fccf740..b77e011 100644 --- a/assets/hooks/tree-view.ts +++ b/assets/hooks/tree-view.ts @@ -26,15 +26,12 @@ const TreeViewHook: Hook = { defaultExpandedValue: getStringList(el, "defaultExpandedValue"), defaultSelectedValue: getStringList(el, "defaultSelectedValue"), }), - selectionMode: getString< - "single" | "multiple" - >(el, "selectionMode", ["single", "multiple"]) ?? "single", + selectionMode: + getString<"single" | "multiple">(el, "selectionMode", ["single", "multiple"]) ?? "single", dir: getDir(el), onSelectionChange: (details) => { const redirect = getBoolean(el, "redirect"); - const value = details.selectedValue?.length - ? details.selectedValue[0] - : undefined; + const value = details.selectedValue?.length ? details.selectedValue[0] : undefined; const itemEl = [ ...el.querySelectorAll( '[data-scope="tree-view"][data-part="item"], [data-scope="tree-view"][data-part="branch"]' @@ -44,11 +41,7 @@ const TreeViewHook: Hook = { const itemRedirect = itemEl?.getAttribute("data-redirect"); const itemNewTab = itemEl?.hasAttribute("data-new-tab"); const doRedirect = - redirect && - value && - isItem && - this.liveSocket.main.isDead && - itemRedirect !== "false"; + redirect && value && isItem && this.liveSocket.main.isDead && itemRedirect !== "false"; if (doRedirect) { if (itemNewTab) { window.open(value, "_blank", "noopener,noreferrer"); diff --git a/assets/lib/util.ts b/assets/lib/util.ts index 2f17f76..01f8d1e 100644 --- a/assets/lib/util.ts +++ b/assets/lib/util.ts @@ -95,4 +95,3 @@ export const generateId = (element?: HTMLElement, fallbackId: string = "element" if (element?.id) return element.id; return `${fallbackId}-${Math.random().toString(36).substring(2, 9)}`; }; - diff --git a/e2e/assets/corex/components/toast.css b/e2e/assets/corex/components/toast.css index 8889310..c1d5bfa 100644 --- a/e2e/assets/corex/components/toast.css +++ b/e2e/assets/corex/components/toast.css @@ -5,11 +5,12 @@ display: flex; flex-direction: column; gap: var(--spacing-ui-gap); - width: var(--container-ui); + width: var(--container-mini); } .toast [data-scope="toast"][data-part="root"] { @apply ui-root; + max-width: var(--container-mini); translate: var(--x) var(--y); scale: var(--scale); diff --git a/e2e/mix.exs b/e2e/mix.exs index ede3dd9..4a0db12 100644 --- a/e2e/mix.exs +++ b/e2e/mix.exs @@ -67,7 +67,7 @@ defmodule E2e.MixProject do {:jason, "~> 1.2"}, {:dns_cluster, "~> 0.2.0"}, {:bandit, "~> 1.5"}, - {:corex, "~> 0.1.0-alpha.21"}, + {:corex, path: "../../corex"}, {:wallaby, "~> 0.30", only: :test}, {:a11y_audit, "~> 0.3.1", only: :test}, {:flagpack, "~> 0.6.0"} diff --git a/e2e/mix.lock b/e2e/mix.lock index 2f30c7b..3598d27 100644 --- a/e2e/mix.lock +++ b/e2e/mix.lock @@ -3,7 +3,6 @@ "bandit": {:hex, :bandit, "1.10.2", "d15ea32eb853b5b42b965b24221eb045462b2ba9aff9a0bda71157c06338cbff", [:mix], [{:hpax, "~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.18", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "27b2a61b647914b1726c2ced3601473be5f7aa6bb468564a688646a689b3ee45"}, "cc_precompiler": {:hex, :cc_precompiler, "0.1.11", "8c844d0b9fb98a3edea067f94f616b3f6b29b959b6b3bf25fee94ffe34364768", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "3427232caf0835f94680e5bcf082408a70b48ad68a5f5c0b02a3bea9f3a075b9"}, "certifi": {:hex, :certifi, "2.15.0", "0e6e882fcdaaa0a5a9f2b3db55b1394dba07e8d6d9bcad08318fb604c6839712", [:rebar3], [], "hexpm", "b147ed22ce71d72eafdad94f055165c1c182f61a2ff49df28bcc71d1d5b94a60"}, - "corex": {:hex, :corex, "0.1.0-alpha.21", "6a5fb25e5d4dd8ba7b9d970870980b02ea9a5819dd5f4d7fccf1ed94a05897f8", [:mix], [{:ecto, "~> 3.10", [hex: :ecto, repo: "hexpm", optional: false]}, {:gettext, "~> 1.0", [hex: :gettext, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.8.1", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 1.1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "ed5471578d9e389256d798a9f8a941cd38a291b11c2cdc133586485b619d111a"}, "db_connection": {:hex, :db_connection, "2.9.0", "a6a97c5c958a2d7091a58a9be40caf41ab496b0701d21e1d1abff3fa27a7f371", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "17d502eacaf61829db98facf6f20808ed33da6ccf495354a41e64fe42f9c509c"}, "decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"}, "dns_cluster": {:hex, :dns_cluster, "0.2.0", "aa8eb46e3bd0326bd67b84790c561733b25c5ba2fe3c7e36f28e88f384ebcb33", [:mix], [], "hexpm", "ba6f1893411c69c01b9e8e8f772062535a4cf70f3f35bcc964a324078d8c8240"}, diff --git a/eslint.config.mjs b/eslint.config.mjs index e47d862..ee69562 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -19,6 +19,7 @@ export default [ globals: { window: "readonly", document: "readonly", + Document: "readonly", console: "readonly", navigator: "readonly", HTMLElement: "readonly", @@ -28,7 +29,12 @@ export default [ CustomEvent: "readonly", EventListener: "readonly", HTMLInputElement: "readonly", - + HTMLSelectElement: "readonly", + HTMLFormElement: "readonly", + SVGSVGElement: "readonly", + SVGRectElement: "readonly", + requestAnimationFrame: "readonly", + setTimeout: "readonly", }, }, plugins: { diff --git a/lib/components/select.ex b/lib/components/select.ex index b523401..f2b16b8 100644 --- a/lib/components/select.ex +++ b/lib/components/select.ex @@ -503,13 +503,6 @@ defmodule Corex.Select do options_with_prompt = [{"", ""} | options] - {on_value_change_client_name, on_value_change_js_encoded} = - case assigns.on_value_change_client do - name when is_binary(name) -> {name, nil} - %Phoenix.LiveView.JS{} = js -> {nil, Phoenix.json_library().encode!(js.ops)} - _ -> {nil, nil} - end - assigns = assigns |> assign(:grouped_items, grouped_items) @@ -519,15 +512,13 @@ defmodule Corex.Select do |> assign(:selected_for_options, selected_for_options) |> assign(:disabled_values, get_disabled_values(assigns.collection)) |> assign(:value_for_hidden_input, value_for_hidden_input(value_list, assigns.multiple)) - |> assign(:on_value_change_client_name, on_value_change_client_name) - |> assign(:on_value_change_js_encoded, on_value_change_js_encoded) ~H"""
@@ -546,8 +537,8 @@ defmodule Corex.Select do
{render_slot(@label)}
-
- - `,this.parts={title:this.el.querySelector('[data-scope="toast"][data-part="title"]'),description:this.el.querySelector('[data-scope="toast"][data-part="description"]'),close:this.el.querySelector('[data-scope="toast"][data-part="close-trigger"]'),ghostBefore:this.el.querySelector('[data-scope="toast"][data-part="ghost-before"]'),ghostAfter:this.el.querySelector('[data-scope="toast"][data-part="ghost-after"]'),progressbar:this.el.querySelector('[data-scope="toast"][data-part="progressbar"]'),loadingSpinner:this.el.querySelector('[data-scope="toast"][data-part="loading-spinner"]')}}initMachine(t){return new ee(HC,t)}initApi(){return $C(this.machine.service,Q)}render(){var o,a;this.spreadProps(this.el,this.api.getRootProps()),this.spreadProps(this.parts.close,this.api.getCloseTriggerProps()),this.spreadProps(this.parts.ghostBefore,this.api.getGhostBeforeProps()),this.spreadProps(this.parts.ghostAfter,this.api.getGhostAfterProps()),this.parts.title.textContent!==this.api.title&&(this.parts.title.textContent=(o=this.api.title)!=null?o:""),this.parts.description.textContent!==this.api.description&&(this.parts.description.textContent=(a=this.api.description)!=null?a:""),this.spreadProps(this.parts.title,this.api.getTitleProps()),this.spreadProps(this.parts.description,this.api.getDescriptionProps());let t=this.duration,n=t==="Infinity"||t===1/0||t===Number.POSITIVE_INFINITY,r=this.el.closest('[phx-hook="Toast"]'),i=r==null?void 0:r.querySelector("[data-loading-icon-template]"),s=i==null?void 0:i.innerHTML;n?(this.parts.progressbar.style.display="none",this.parts.loadingSpinner.style.display="flex",this.el.setAttribute("data-duration-infinity","true"),s&&this.parts.loadingSpinner.innerHTML!==s&&(this.parts.loadingSpinner.innerHTML=s)):(this.parts.progressbar.style.display="block",this.parts.loadingSpinner.style.display="none",this.el.removeAttribute("data-duration-infinity"))}},KC=class extends te{constructor(t,n){var r;super(t,n);U(this,"toastComponents",new Map);U(this,"groupEl");U(this,"store");U(this,"destroy",()=>{for(let t of this.toastComponents.values())t.destroy();this.toastComponents.clear(),this.machine.stop()});this.store=n.store,this.groupEl=(r=t.querySelector('[data-part="group"]'))!=null?r:(()=>{let i=document.createElement("div");return i.setAttribute("data-scope","toast"),i.setAttribute("data-part","group"),t.appendChild(i),i})()}initMachine(t){return new ee(Md.machine,t)}initApi(){return Md.connect(this.machine.service,Q)}render(){this.spreadProps(this.groupEl,this.api.getGroupProps());let t=this.api.getToasts().filter(r=>typeof r.id=="string"),n=new Set(t.map(r=>r.id));t.forEach((r,i)=>{let s=this.toastComponents.get(r.id);if(s)s.duration=r.duration,s.updateProps(y(m({},r),{parent:this.machine.service,index:i}));else{let o=document.createElement("div");o.setAttribute("data-scope","toast"),o.setAttribute("data-part","root"),this.groupEl.appendChild(o),s=new WC(o,y(m({},r),{parent:this.machine.service,index:i})),s.init(),this.toastComponents.set(r.id,s)}});for(let[r,i]of this.toastComponents)n.has(r)||(i.destroy(),this.toastComponents.delete(r))}};jC={mounted(){var h;let e=this.el;e.id||(e.id=rn(e,"toast")),this.groupId=e.id;let t=p=>{if(p)try{return p.includes("{")?JSON.parse(p):p}catch(d){return p}},n=p=>p==="Infinity"||p===1/0?1/0:typeof p=="string"?parseInt(p,10)||void 0:p,r=(h=x(e,"placement",["top-start","top","top-end","bottom-start","bottom","bottom-end"]))!=null?h:"bottom-end";YC(e,{id:this.groupId,placement:r,overlap:O(e,"overlap"),max:Se(e,"max"),gap:Se(e,"gap"),offsets:t(x(e,"offset")),pauseOnPageIdle:O(e,"pauseOnPageIdle")});let i=jr(this.groupId),s=e.getAttribute("data-flash-info"),o=e.getAttribute("data-flash-info-title"),a=e.getAttribute("data-flash-error"),l=e.getAttribute("data-flash-error-title"),c=e.getAttribute("data-flash-info-duration"),u=e.getAttribute("data-flash-error-duration");if(i&&s)try{i.create({title:o||"Success",description:s,type:"info",id:rn(void 0,"toast"),duration:n(c!=null?c:void 0)})}catch(p){console.error("Failed to create flash info toast:",p)}if(i&&a)try{i.create({title:l||"Error",description:a,type:"error",id:rn(void 0,"toast"),duration:n(u!=null?u:void 0)})}catch(p){console.error("Failed to create flash error toast:",p)}this.handlers=[],this.handlers.push(this.handleEvent("toast-create",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.create({title:p.title,description:p.description,type:p.type||"info",id:p.id||rn(void 0,"toast"),duration:n(p.duration)})}catch(g){console.error("Failed to create toast:",g)}})),this.handlers.push(this.handleEvent("toast-update",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.update(p.id,{title:p.title,description:p.description,type:p.type})}catch(g){console.error("Failed to update toast:",g)}})),this.handlers.push(this.handleEvent("toast-dismiss",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.dismiss(p.id)}catch(g){console.error("Failed to dismiss toast:",g)}})),e.addEventListener("toast:create",p=>{let{detail:d}=p,g=jr(d.groupId||this.groupId);if(g)try{g.create({title:d.title,description:d.description,type:d.type||"info",id:d.id||rn(void 0,"toast"),duration:n(d.duration)})}catch(v){console.error("Failed to create toast:",v)}})},destroyed(){if(this.handlers)for(let e of this.handlers)this.removeHandleEvent(e)}}});var Wd={};Oe(Wd,{ToggleGroup:()=>oI});function eI(e,t){let{context:n,send:r,prop:i,scope:s}=e,o=n.get("value"),a=i("disabled"),l=!i("multiple"),c=i("rovingFocus"),u=i("orientation")==="horizontal";function h(p){let d=JC(s,p.value);return{id:d,disabled:!!(p.disabled||a),pressed:!!o.includes(p.value),focused:n.get("focusedId")===d}}return{value:o,setValue(p){r({type:"VALUE.SET",value:p})},getRootProps(){return t.element(y(m({},Bd.root.attrs),{id:vs(s),dir:i("dir"),role:l?"radiogroup":"group",tabIndex:n.get("isTabbingBackward")?-1:0,"data-disabled":T(a),"data-orientation":i("orientation"),"data-focus":T(n.get("focusedId")!=null),style:{outline:"none"},onMouseDown(){a||r({type:"ROOT.MOUSE_DOWN"})},onFocus(p){a||p.currentTarget===K(p)&&(n.get("isClickFocus")||n.get("isTabbingBackward")||r({type:"ROOT.FOCUS"}))},onBlur(p){let d=p.relatedTarget;pe(p.currentTarget,d)||a||r({type:"ROOT.BLUR"})}}))},getItemState:h,getItemProps(p){let d=h(p),g=d.focused?0:-1;return t.button(y(m({},Bd.item.attrs),{id:d.id,type:"button","data-ownedby":vs(s),"data-focus":T(d.focused),disabled:d.disabled,tabIndex:c?g:void 0,role:l?"radio":void 0,"aria-checked":l?d.pressed:void 0,"aria-pressed":l?void 0:d.pressed,"data-disabled":T(d.disabled),"data-orientation":i("orientation"),dir:i("dir"),"data-state":d.pressed?"on":"off",onFocus(){d.disabled||r({type:"TOGGLE.FOCUS",id:d.id})},onClick(v){d.disabled||(r({type:"TOGGLE.CLICK",id:d.id,value:p.value}),Wt()&&v.currentTarget.focus({preventScroll:!0}))},onKeyDown(v){if(v.defaultPrevented||!pe(v.currentTarget,K(v))||d.disabled)return;let V={Tab(S){let E=S.shiftKey;r({type:"TOGGLE.SHIFT_TAB",isShiftTab:E})},ArrowLeft(){!c||!u||r({type:"TOGGLE.FOCUS_PREV"})},ArrowRight(){!c||!u||r({type:"TOGGLE.FOCUS_NEXT"})},ArrowUp(){!c||u||r({type:"TOGGLE.FOCUS_PREV"})},ArrowDown(){!c||u||r({type:"TOGGLE.FOCUS_NEXT"})},Home(){c&&r({type:"TOGGLE.FOCUS_FIRST"})},End(){c&&r({type:"TOGGLE.FOCUS_LAST"})}}[ve(v)];V&&(V(v),v.key!=="Tab"&&v.preventDefault())}}))}}}var XC,Bd,vs,JC,qd,ys,Gd,ZC,zC,QC,Ud,tI,nI,rI,xO,iI,kO,sI,oI,Kd=fe(()=>{"use strict";me();XC=J("toggle-group").parts("root","item"),Bd=XC.build(),vs=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`toggle-group:${e.id}`},JC=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.item)==null?void 0:r.call(n,t))!=null?i:`toggle-group:${e.id}:${t}`},qd=e=>e.getById(vs(e)),ys=e=>{let n=`[data-ownedby='${CSS.escape(vs(e))}']:not([data-disabled])`;return dt(qd(e),n)},Gd=e=>Ke(ys(e)),ZC=e=>nt(ys(e)),zC=(e,t,n)=>$n(ys(e),t,n),QC=(e,t,n)=>_n(ys(e),t,n);({not:Ud,and:tI}=ye()),nI={props({props:e}){return m({defaultValue:[],orientation:"horizontal",rovingFocus:!0,loopFocus:!0,deselectable:!0},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(n){var r;(r=e("onValueChange"))==null||r({value:n})}})),focusedId:t(()=>({defaultValue:null})),isTabbingBackward:t(()=>({defaultValue:!1})),isClickFocus:t(()=>({defaultValue:!1})),isWithinToolbar:t(()=>({defaultValue:!1}))}},computed:{currentLoopFocus:({context:e,prop:t})=>t("loopFocus")&&!e.get("isWithinToolbar")},entry:["checkIfWithinToolbar"],on:{"VALUE.SET":{actions:["setValue"]},"TOGGLE.CLICK":{actions:["setValue"]},"ROOT.MOUSE_DOWN":{actions:["setClickFocus"]}},states:{idle:{on:{"ROOT.FOCUS":{target:"focused",guard:Ud(tI("isClickFocus","isTabbingBackward")),actions:["focusFirstToggle","clearClickFocus"]},"TOGGLE.FOCUS":{target:"focused",actions:["setFocusedId"]}}},focused:{on:{"ROOT.BLUR":{target:"idle",actions:["clearIsTabbingBackward","clearFocusedId","clearClickFocus"]},"TOGGLE.FOCUS":{actions:["setFocusedId"]},"TOGGLE.FOCUS_NEXT":{actions:["focusNextToggle"]},"TOGGLE.FOCUS_PREV":{actions:["focusPrevToggle"]},"TOGGLE.FOCUS_FIRST":{actions:["focusFirstToggle"]},"TOGGLE.FOCUS_LAST":{actions:["focusLastToggle"]},"TOGGLE.SHIFT_TAB":[{guard:Ud("isFirstToggleFocused"),target:"idle",actions:["setIsTabbingBackward"]},{actions:["setIsTabbingBackward"]}]}}},implementations:{guards:{isClickFocus:({context:e})=>e.get("isClickFocus"),isTabbingBackward:({context:e})=>e.get("isTabbingBackward"),isFirstToggleFocused:({context:e,scope:t})=>{var n;return e.get("focusedId")===((n=Gd(t))==null?void 0:n.id)}},actions:{setIsTabbingBackward({context:e}){e.set("isTabbingBackward",!0)},clearIsTabbingBackward({context:e}){e.set("isTabbingBackward",!1)},setClickFocus({context:e}){e.set("isClickFocus",!0)},clearClickFocus({context:e}){e.set("isClickFocus",!1)},checkIfWithinToolbar({context:e,scope:t}){var r;let n=(r=qd(t))==null?void 0:r.closest("[role=toolbar]");e.set("isWithinToolbar",!!n)},setFocusedId({context:e,event:t}){e.set("focusedId",t.id)},clearFocusedId({context:e}){e.set("focusedId",null)},setValue({context:e,event:t,prop:n}){yi(t,["value"]);let r=e.get("value");Kt(t.value)?r=t.value:n("multiple")?r=it(r,t.value):r=he(r,[t.value])&&n("deselectable")?[]:[t.value],e.set("value",r)},focusNextToggle({context:e,scope:t,prop:n}){H(()=>{var i;let r=e.get("focusedId");r&&((i=zC(t,r,n("loopFocus")))==null||i.focus({preventScroll:!0}))})},focusPrevToggle({context:e,scope:t,prop:n}){H(()=>{var i;let r=e.get("focusedId");r&&((i=QC(t,r,n("loopFocus")))==null||i.focus({preventScroll:!0}))})},focusFirstToggle({scope:e}){H(()=>{var t;(t=Gd(e))==null||t.focus({preventScroll:!0})})},focusLastToggle({scope:e}){H(()=>{var t;(t=ZC(e))==null||t.focus({preventScroll:!0})})}}}},rI=G()(["dir","disabled","getRootNode","id","ids","loopFocus","multiple","onValueChange","orientation","rovingFocus","value","defaultValue","deselectable"]),xO=B(rI),iI=G()(["value","disabled"]),kO=B(iI),sI=class extends te{initMachine(e){return new ee(nI,e)}initApi(){return eI(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="toggle-group"][data-part="root"]');if(!e)return;this.spreadProps(e,this.api.getRootProps());let t=this.el.querySelectorAll('[data-scope="toggle-group"][data-part="item"]');for(let n=0;n{let s=x(e,"onValueChange");s&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(s,{value:i.value,id:e.id});let o=x(e,"onValueChangeClient");o&&e.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:{value:i.value,id:e.id}}))}}),r=new sI(e,n);r.init(),this.toggleGroup=r,this.onSetValue=i=>{let{value:s}=i.detail;r.api.setValue(s)},e.addEventListener("phx:toggle-group:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("toggle-group_set_value",i=>{let s=i.id;s&&s!==e.id||r.api.setValue(i.value)})),this.handlers.push(this.handleEvent("toggle-group:value",()=>{this.pushEvent("toggle-group:value_response",{value:r.api.value})}))},updated(){var e;(e=this.toggleGroup)==null||e.updateProps(y(m({},O(this.el,"controlled")?{value:Y(this.el,"value")}:{defaultValue:Y(this.el,"defaultValue")}),{deselectable:O(this.el,"deselectable"),loopFocus:O(this.el,"loopFocus"),rovingFocus:O(this.el,"rovingFocus"),disabled:O(this.el,"disabled"),multiple:O(this.el,"multiple"),orientation:x(this.el,"orientation",["horizontal","vertical"]),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:toggle-group:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.toggleGroup)==null||e.destroy()}}});var Zd={};Oe(Zd,{TreeView:()=>vI});function Jd(e,t,n){let r=e.getNodeValue(t);if(!e.isBranchNode(t))return n.includes(r);let i=e.getDescendantValues(r),s=i.every(a=>n.includes(a)),o=i.some(a=>n.includes(a));return s?!0:o?"indeterminate":!1}function cI(e,t,n){let r=e.getDescendantValues(t),i=r.every(s=>n.includes(s));return kt(i?ht(n,...r):rt(n,...r))}function uI(e,t){let n=new Map;return e.visit({onEnter:r=>{let i=e.getNodeValue(r),s=e.isBranchNode(r),o=Jd(e,r,t);n.set(i,{type:s?"branch":"leaf",checked:o})}}),n}function dI(e,t){let{context:n,scope:r,computed:i,prop:s,send:o}=e,a=s("collection"),l=Array.from(n.get("expandedValue")),c=Array.from(n.get("selectedValue")),u=Array.from(n.get("checkedValue")),h=i("isTypingAhead"),p=n.get("focusedValue"),d=n.get("loadingStatus"),g=n.get("renamingValue"),v=({indexPath:E})=>a.getValuePath(E).slice(0,-1).some(C=>!l.includes(C)),b=a.getFirstNode(void 0,{skip:v}),V=b?a.getNodeValue(b):null;function S(E){let{node:f,indexPath:C}=E,I=a.getNodeValue(f);return{id:va(r,I),value:I,indexPath:C,valuePath:a.getValuePath(C),disabled:!!f.disabled,focused:p==null?V===I:p===I,selected:c.includes(I),expanded:l.includes(I),loading:d[I]==="loading",depth:C.length,isBranch:a.isBranchNode(f),renaming:g===I,get checked(){return Jd(a,f,u)}}}return{collection:a,expandedValue:l,selectedValue:c,checkedValue:u,toggleChecked(E,f){o({type:"CHECKED.TOGGLE",value:E,isBranch:f})},setChecked(E){o({type:"CHECKED.SET",value:E})},clearChecked(){o({type:"CHECKED.CLEAR"})},getCheckedMap(){return uI(a,u)},expand(E){o({type:E?"BRANCH.EXPAND":"EXPANDED.ALL",value:E})},collapse(E){o({type:E?"BRANCH.COLLAPSE":"EXPANDED.CLEAR",value:E})},deselect(E){o({type:E?"NODE.DESELECT":"SELECTED.CLEAR",value:E})},select(E){o({type:E?"NODE.SELECT":"SELECTED.ALL",value:E,isTrusted:!1})},getVisibleNodes(){return i("visibleNodes")},focus(E){Ce(r,E)},selectParent(E){let f=a.getParentNode(E);if(!f)return;let C=rt(c,a.getNodeValue(f));o({type:"SELECTED.SET",value:C,src:"select.parent"})},expandParent(E){let f=a.getParentNode(E);if(!f)return;let C=rt(l,a.getNodeValue(f));o({type:"EXPANDED.SET",value:C,src:"expand.parent"})},setExpandedValue(E){let f=kt(E);o({type:"EXPANDED.SET",value:f})},setSelectedValue(E){let f=kt(E);o({type:"SELECTED.SET",value:f})},startRenaming(E){o({type:"NODE.RENAME",value:E})},submitRenaming(E,f){o({type:"RENAME.SUBMIT",value:E,label:f})},cancelRenaming(){o({type:"RENAME.CANCEL"})},getRootProps(){return t.element(y(m({},Ne.root.attrs),{id:lI(r),dir:s("dir")}))},getLabelProps(){return t.element(y(m({},Ne.label.attrs),{id:Yd(r),dir:s("dir")}))},getTreeProps(){return t.element(y(m({},Ne.tree.attrs),{id:pa(r),dir:s("dir"),role:"tree","aria-label":"Tree View","aria-labelledby":Yd(r),"aria-multiselectable":s("selectionMode")==="multiple"||void 0,tabIndex:-1,onKeyDown(E){if(E.defaultPrevented||Vt(E))return;let f=K(E);if(Ut(f))return;let C=f==null?void 0:f.closest("[data-part=branch-control], [data-part=item]");if(!C)return;let I=C.dataset.value;if(I==null){console.warn("[zag-js/tree-view] Node id not found for node",C);return}let P=C.matches("[data-part=branch-control]"),A={ArrowDown(R){Fe(R)||(R.preventDefault(),o({type:"NODE.ARROW_DOWN",id:I,shiftKey:R.shiftKey}))},ArrowUp(R){Fe(R)||(R.preventDefault(),o({type:"NODE.ARROW_UP",id:I,shiftKey:R.shiftKey}))},ArrowLeft(R){Fe(R)||C.dataset.disabled||(R.preventDefault(),o({type:P?"BRANCH_NODE.ARROW_LEFT":"NODE.ARROW_LEFT",id:I}))},ArrowRight(R){!P||C.dataset.disabled||(R.preventDefault(),o({type:"BRANCH_NODE.ARROW_RIGHT",id:I}))},Home(R){Fe(R)||(R.preventDefault(),o({type:"NODE.HOME",id:I,shiftKey:R.shiftKey}))},End(R){Fe(R)||(R.preventDefault(),o({type:"NODE.END",id:I,shiftKey:R.shiftKey}))},Space(R){var L;C.dataset.disabled||(h?o({type:"TREE.TYPEAHEAD",key:R.key}):(L=A.Enter)==null||L.call(A,R))},Enter(R){C.dataset.disabled||We(f)&&Fe(R)||(o({type:P?"BRANCH_NODE.CLICK":"NODE.CLICK",id:I,src:"keyboard"}),We(f)||R.preventDefault())},"*"(R){C.dataset.disabled||(R.preventDefault(),o({type:"SIBLINGS.EXPAND",id:I}))},a(R){!R.metaKey||C.dataset.disabled||(R.preventDefault(),o({type:"SELECTED.ALL",moveFocus:!0}))},F2(R){if(C.dataset.disabled)return;let L=s("canRename");if(!L)return;let M=a.getIndexPath(I);if(M){let j=a.at(M);if(j&&!L(j,M))return}R.preventDefault(),o({type:"NODE.RENAME",value:I})}},w=ve(E,{dir:s("dir")}),N=A[w];if(N){N(E);return}tt.isValidEvent(E)&&(o({type:"TREE.TYPEAHEAD",key:E.key,id:I}),E.preventDefault())}}))},getNodeState:S,getItemProps(E){let f=S(E);return t.element(y(m({},Ne.item.attrs),{id:f.id,dir:s("dir"),"data-ownedby":pa(r),"data-path":E.indexPath.join("/"),"data-value":f.value,tabIndex:f.focused?0:-1,"data-focus":T(f.focused),role:"treeitem","aria-current":f.selected?"true":void 0,"aria-selected":f.disabled?void 0:f.selected,"data-selected":T(f.selected),"aria-disabled":re(f.disabled),"data-disabled":T(f.disabled),"data-renaming":T(f.renaming),"aria-level":f.depth,"data-depth":f.depth,style:{"--depth":f.depth},onFocus(C){C.stopPropagation(),o({type:"NODE.FOCUS",id:f.value})},onClick(C){if(f.disabled||!et(C)||We(C.currentTarget)&&Fe(C))return;let I=C.metaKey||C.ctrlKey;o({type:"NODE.CLICK",id:f.value,shiftKey:C.shiftKey,ctrlKey:I}),C.stopPropagation(),We(C.currentTarget)||C.preventDefault()}}))},getItemTextProps(E){let f=S(E);return t.element(y(m({},Ne.itemText.attrs),{"data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused)}))},getItemIndicatorProps(E){let f=S(E);return t.element(y(m({},Ne.itemIndicator.attrs),{"aria-hidden":!0,"data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),hidden:!f.selected}))},getBranchProps(E){let f=S(E);return t.element(y(m({},Ne.branch.attrs),{"data-depth":f.depth,dir:s("dir"),"data-branch":f.value,role:"treeitem","data-ownedby":pa(r),"data-value":f.value,"aria-level":f.depth,"aria-selected":f.disabled?void 0:f.selected,"data-path":E.indexPath.join("/"),"data-selected":T(f.selected),"aria-expanded":f.expanded,"data-state":f.expanded?"open":"closed","aria-disabled":re(f.disabled),"data-disabled":T(f.disabled),"data-loading":T(f.loading),"aria-busy":re(f.loading),style:{"--depth":f.depth}}))},getBranchIndicatorProps(E){let f=S(E);return t.element(y(m({},Ne.branchIndicator.attrs),{"aria-hidden":!0,"data-state":f.expanded?"open":"closed","data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),"data-loading":T(f.loading)}))},getBranchTriggerProps(E){let f=S(E);return t.element(y(m({},Ne.branchTrigger.attrs),{role:"button",dir:s("dir"),"data-disabled":T(f.disabled),"data-state":f.expanded?"open":"closed","data-value":f.value,"data-loading":T(f.loading),disabled:f.loading,onClick(C){f.disabled||f.loading||(o({type:"BRANCH_TOGGLE.CLICK",id:f.value}),C.stopPropagation())}}))},getBranchControlProps(E){let f=S(E);return t.element(y(m({},Ne.branchControl.attrs),{role:"button",id:f.id,dir:s("dir"),tabIndex:f.focused?0:-1,"data-path":E.indexPath.join("/"),"data-state":f.expanded?"open":"closed","data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),"data-renaming":T(f.renaming),"data-value":f.value,"data-depth":f.depth,"data-loading":T(f.loading),"aria-busy":re(f.loading),onFocus(C){o({type:"NODE.FOCUS",id:f.value}),C.stopPropagation()},onClick(C){if(f.disabled||f.loading||!et(C)||We(C.currentTarget)&&Fe(C))return;let I=C.metaKey||C.ctrlKey;o({type:"BRANCH_NODE.CLICK",id:f.value,shiftKey:C.shiftKey,ctrlKey:I}),C.stopPropagation()}}))},getBranchTextProps(E){let f=S(E);return t.element(y(m({},Ne.branchText.attrs),{dir:s("dir"),"data-disabled":T(f.disabled),"data-state":f.expanded?"open":"closed","data-loading":T(f.loading)}))},getBranchContentProps(E){let f=S(E);return t.element(y(m({},Ne.branchContent.attrs),{role:"group",dir:s("dir"),"data-state":f.expanded?"open":"closed","data-depth":f.depth,"data-path":E.indexPath.join("/"),"data-value":f.value,hidden:!f.expanded}))},getBranchIndentGuideProps(E){let f=S(E);return t.element(y(m({},Ne.branchIndentGuide.attrs),{"data-depth":f.depth}))},getNodeCheckboxProps(E){let f=S(E),C=f.checked;return t.element(y(m({},Ne.nodeCheckbox.attrs),{tabIndex:-1,role:"checkbox","data-state":C===!0?"checked":C===!1?"unchecked":"indeterminate","aria-checked":C===!0?"true":C===!1?"false":"mixed","data-disabled":T(f.disabled),onClick(I){if(I.defaultPrevented||f.disabled||!et(I))return;o({type:"CHECKED.TOGGLE",value:f.value,isBranch:f.isBranch}),I.stopPropagation();let P=I.currentTarget.closest("[role=treeitem]");P==null||P.focus({preventScroll:!0})}}))},getNodeRenameInputProps(E){let f=S(E);return t.input(y(m({},Ne.nodeRenameInput.attrs),{id:Xd(r,f.value),type:"text","aria-label":"Rename tree item",hidden:!f.renaming,onKeyDown(C){Vt(C)||(C.key==="Escape"&&(o({type:"RENAME.CANCEL"}),C.preventDefault()),C.key==="Enter"&&(o({type:"RENAME.SUBMIT",label:C.currentTarget.value}),C.preventDefault()),C.stopPropagation())},onBlur(C){o({type:"RENAME.SUBMIT",label:C.currentTarget.value})}}))}}}function bs(e,t){let{context:n,prop:r,refs:i}=e;if(!r("loadChildren")){n.set("expandedValue",v=>kt(rt(v,...t)));return}let s=n.get("loadingStatus"),[o,a]=Ks(t,v=>s[v]==="loaded");if(o.length>0&&n.set("expandedValue",v=>kt(rt(v,...o))),a.length===0)return;let l=r("collection"),[c,u]=Ks(a,v=>{let b=l.findNode(v);return l.getNodeChildren(b).length>0});if(c.length>0&&n.set("expandedValue",v=>kt(rt(v,...c))),u.length===0)return;n.set("loadingStatus",v=>m(m({},v),u.reduce((b,V)=>y(m({},b),{[V]:"loading"}),{})));let h=u.map(v=>{let b=l.getIndexPath(v),V=l.getValuePath(b),S=l.findNode(v);return{id:v,indexPath:b,valuePath:V,node:S}}),p=i.get("pendingAborts"),d=r("loadChildren");qn(d,()=>"[zag-js/tree-view] `loadChildren` is required for async expansion");let g=h.map(({id:v,indexPath:b,valuePath:V,node:S})=>{let E=p.get(v);E&&(E.abort(),p.delete(v));let f=new AbortController;return p.set(v,f),d({valuePath:V,indexPath:b,node:S,signal:f.signal})});Promise.allSettled(g).then(v=>{var f,C;let b=[],V=[],S=n.get("loadingStatus"),E=r("collection");v.forEach((I,P)=>{let{id:A,indexPath:w,node:N,valuePath:R}=h[P];I.status==="fulfilled"?(S[A]="loaded",b.push(A),E=E.replace(w,y(m({},N),{children:I.value}))):(p.delete(A),Reflect.deleteProperty(S,A),V.push({node:N,error:I.reason,indexPath:w,valuePath:R}))}),n.set("loadingStatus",S),b.length&&(n.set("expandedValue",I=>kt(rt(I,...b))),(f=r("onLoadChildrenComplete"))==null||f({collection:E})),V.length&&((C=r("onLoadChildrenError"))==null||C({nodes:V}))})}function Et(e){let{prop:t,context:n}=e;return function({indexPath:i}){return t("collection").getValuePath(i).slice(0,-1).some(o=>!n.get("expandedValue").includes(o))}}function wn(e,t){let{prop:n,scope:r,computed:i}=e,s=n("scrollToIndexFn");if(!s)return!1;let o=n("collection"),a=i("visibleNodes");for(let l=0;lr.getById(va(r,t))}),!0}return!1}function pI(e){var s;let n=e.querySelectorAll('[data-scope="tree-view"][data-part="branch"], [data-scope="tree-view"][data-part="item"]'),r=[];for(let o of n){let a=o.getAttribute("data-path"),l=o.getAttribute("data-value");if(a==null||l==null)continue;let c=a.split("/").map(p=>parseInt(p,10));if(c.some(Number.isNaN))continue;let u=(s=o.getAttribute("data-name"))!=null?s:l,h=o.getAttribute("data-part")==="branch";r.push({pathArr:c,id:l,name:u,isBranch:h})}r.sort((o,a)=>{let l=Math.min(o.pathArr.length,a.pathArr.length);for(let c=0;c{"use strict";Ai();me();aI=J("tree-view").parts("branch","branchContent","branchControl","branchIndentGuide","branchIndicator","branchText","branchTrigger","item","itemIndicator","itemText","label","nodeCheckbox","nodeRenameInput","root","tree"),Ne=aI.build(),ma=e=>new ro(e);ma.empty=()=>new ro({rootNode:{children:[]}});lI=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`tree:${e.id}:root`},Yd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`tree:${e.id}:label`},va=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.node)==null?void 0:r.call(n,t))!=null?i:`tree:${e.id}:node:${t}`},pa=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.tree)!=null?n:`tree:${e.id}:tree`},Ce=(e,t)=>{var n;t!=null&&((n=e.getById(va(e,t)))==null||n.focus())},Xd=(e,t)=>`tree:${e.id}:rename-input:${t}`,jd=(e,t)=>e.getById(Xd(e,t));({and:Ct}=ye()),hI={props({props:e}){return m({selectionMode:"single",collection:ma.empty(),typeahead:!0,expandOnClick:!0,defaultExpandedValue:[],defaultSelectedValue:[]},e)},initialState(){return"idle"},context({prop:e,bindable:t,getContext:n}){return{expandedValue:t(()=>({defaultValue:e("defaultExpandedValue"),value:e("expandedValue"),isEqual:he,onChange(r){var o;let s=n().get("focusedValue");(o=e("onExpandedChange"))==null||o({expandedValue:r,focusedValue:s,get expandedNodes(){return e("collection").findNodes(r)}})}})),selectedValue:t(()=>({defaultValue:e("defaultSelectedValue"),value:e("selectedValue"),isEqual:he,onChange(r){var o;let s=n().get("focusedValue");(o=e("onSelectionChange"))==null||o({selectedValue:r,focusedValue:s,get selectedNodes(){return e("collection").findNodes(r)}})}})),focusedValue:t(()=>({defaultValue:e("defaultFocusedValue")||null,value:e("focusedValue"),onChange(r){var i;(i=e("onFocusChange"))==null||i({focusedValue:r,get focusedNode(){return r?e("collection").findNode(r):null}})}})),loadingStatus:t(()=>({defaultValue:{}})),checkedValue:t(()=>({defaultValue:e("defaultCheckedValue")||[],value:e("checkedValue"),isEqual:he,onChange(r){var i;(i=e("onCheckedChange"))==null||i({checkedValue:r})}})),renamingValue:t(()=>({sync:!0,defaultValue:null}))}},refs(){return{typeaheadState:m({},tt.defaultOptions),pendingAborts:new Map}},computed:{isMultipleSelection:({prop:e})=>e("selectionMode")==="multiple",isTypingAhead:({refs:e})=>e.get("typeaheadState").keysSoFar.length>0,visibleNodes:({prop:e,context:t})=>{let n=[];return e("collection").visit({skip:Et({prop:e,context:t}),onEnter:(r,i)=>{n.push({node:r,indexPath:i})}}),n}},on:{"EXPANDED.SET":{actions:["setExpanded"]},"EXPANDED.CLEAR":{actions:["clearExpanded"]},"EXPANDED.ALL":{actions:["expandAllBranches"]},"BRANCH.EXPAND":{actions:["expandBranches"]},"BRANCH.COLLAPSE":{actions:["collapseBranches"]},"SELECTED.SET":{actions:["setSelected"]},"SELECTED.ALL":[{guard:Ct("isMultipleSelection","moveFocus"),actions:["selectAllNodes","focusTreeLastNode"]},{guard:"isMultipleSelection",actions:["selectAllNodes"]}],"SELECTED.CLEAR":{actions:["clearSelected"]},"NODE.SELECT":{actions:["selectNode"]},"NODE.DESELECT":{actions:["deselectNode"]},"CHECKED.TOGGLE":{actions:["toggleChecked"]},"CHECKED.SET":{actions:["setChecked"]},"CHECKED.CLEAR":{actions:["clearChecked"]},"NODE.FOCUS":{actions:["setFocusedNode"]},"NODE.ARROW_DOWN":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["focusTreeNextNode","extendSelectionToNextNode"]},{actions:["focusTreeNextNode"]}],"NODE.ARROW_UP":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["focusTreePrevNode","extendSelectionToPrevNode"]},{actions:["focusTreePrevNode"]}],"NODE.ARROW_LEFT":{actions:["focusBranchNode"]},"BRANCH_NODE.ARROW_LEFT":[{guard:"isBranchExpanded",actions:["collapseBranch"]},{actions:["focusBranchNode"]}],"BRANCH_NODE.ARROW_RIGHT":[{guard:Ct("isBranchFocused","isBranchExpanded"),actions:["focusBranchFirstNode"]},{actions:["expandBranch"]}],"SIBLINGS.EXPAND":{actions:["expandSiblingBranches"]},"NODE.HOME":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToFirstNode","focusTreeFirstNode"]},{actions:["focusTreeFirstNode"]}],"NODE.END":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToLastNode","focusTreeLastNode"]},{actions:["focusTreeLastNode"]}],"NODE.CLICK":[{guard:Ct("isCtrlKey","isMultipleSelection"),actions:["toggleNodeSelection"]},{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToNode"]},{actions:["selectNode"]}],"BRANCH_NODE.CLICK":[{guard:Ct("isCtrlKey","isMultipleSelection"),actions:["toggleNodeSelection"]},{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToNode"]},{guard:"expandOnClick",actions:["selectNode","toggleBranchNode"]},{actions:["selectNode"]}],"BRANCH_TOGGLE.CLICK":{actions:["toggleBranchNode"]},"TREE.TYPEAHEAD":{actions:["focusMatchedNode"]}},exit:["clearPendingAborts"],states:{idle:{on:{"NODE.RENAME":{target:"renaming",actions:["setRenamingValue"]}}},renaming:{entry:["syncRenameInput","focusRenameInput"],on:{"RENAME.SUBMIT":{guard:"isRenameLabelValid",target:"idle",actions:["submitRenaming"]},"RENAME.CANCEL":{target:"idle",actions:["cancelRenaming"]}}}},implementations:{guards:{isBranchFocused:({context:e,event:t})=>e.get("focusedValue")===t.id,isBranchExpanded:({context:e,event:t})=>e.get("expandedValue").includes(t.id),isShiftKey:({event:e})=>e.shiftKey,isCtrlKey:({event:e})=>e.ctrlKey,hasSelectedItems:({context:e})=>e.get("selectedValue").length>0,isMultipleSelection:({prop:e})=>e("selectionMode")==="multiple",moveFocus:({event:e})=>!!e.moveFocus,expandOnClick:({prop:e})=>!!e("expandOnClick"),isRenameLabelValid:({event:e})=>e.label.trim()!==""},actions:{selectNode({context:e,event:t}){let n=t.id||t.value;e.set("selectedValue",r=>n==null?r:!t.isTrusted&&Kt(n)?r.concat(...n):[Kt(n)?nt(n):n].filter(Boolean))},deselectNode({context:e,event:t}){let n=Tr(t.id||t.value);e.set("selectedValue",r=>ht(r,...n))},setFocusedNode({context:e,event:t}){e.set("focusedValue",t.id)},clearFocusedNode({context:e}){e.set("focusedValue",null)},clearSelectedItem({context:e}){e.set("selectedValue",[])},toggleBranchNode({context:e,event:t,action:n}){let r=e.get("expandedValue").includes(t.id);n(r?["collapseBranch"]:["expandBranch"])},expandBranch(e){let{event:t}=e;bs(e,[t.id])},expandBranches(e){let{context:t,event:n}=e,r=Tr(n.value);bs(e,mi(r,t.get("expandedValue")))},collapseBranch({context:e,event:t}){e.set("expandedValue",n=>ht(n,t.id))},collapseBranches(e){let{context:t,event:n}=e,r=Tr(n.value);t.set("expandedValue",i=>ht(i,...r))},setExpanded({context:e,event:t}){Kt(t.value)&&e.set("expandedValue",t.value)},clearExpanded({context:e}){e.set("expandedValue",[])},setSelected({context:e,event:t}){Kt(t.value)&&e.set("selectedValue",t.value)},clearSelected({context:e}){e.set("selectedValue",[])},focusTreeFirstNode(e){let{prop:t,scope:n}=e,r=t("collection"),i=r.getFirstNode(void 0,{skip:Et(e)});if(!i)return;let s=r.getNodeValue(i);wn(e,s)?H(()=>Ce(n,s)):Ce(n,s)},focusTreeLastNode(e){let{prop:t,scope:n}=e,r=t("collection"),i=r.getLastNode(void 0,{skip:Et(e)}),s=r.getNodeValue(i);wn(e,s)?H(()=>Ce(n,s)):Ce(n,s)},focusBranchFirstNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.findNode(t.id),o=i.getFirstNode(s,{skip:Et(e)});if(!o)return;let a=i.getNodeValue(o);wn(e,a)?H(()=>Ce(r,a)):Ce(r,a)},focusTreeNextNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getNextNode(t.id,{skip:Et(e)});if(!s)return;let o=i.getNodeValue(s);wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},focusTreePrevNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getPreviousNode(t.id,{skip:Et(e)});if(!s)return;let o=i.getNodeValue(s);wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},focusBranchNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getParentNode(t.id),o=s?i.getNodeValue(s):void 0;if(!o)return;wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},selectAllNodes({context:e,prop:t}){e.set("selectedValue",t("collection").getValues())},focusMatchedNode(e){let{context:t,prop:n,refs:r,event:i,scope:s,computed:o}=e,l=o("visibleNodes").map(({node:h})=>({textContent:n("collection").stringifyNode(h),id:n("collection").getNodeValue(h)})),c=tt(l,{state:r.get("typeaheadState"),activeId:t.get("focusedValue"),key:i.key});if(!(c!=null&&c.id))return;wn(e,c.id)?H(()=>Ce(s,c.id)):Ce(s,c.id)},toggleNodeSelection({context:e,event:t}){let n=it(e.get("selectedValue"),t.id);e.set("selectedValue",n)},expandAllBranches(e){let{context:t,prop:n}=e,r=n("collection").getBranchValues(),i=mi(r,t.get("expandedValue"));bs(e,i)},expandSiblingBranches(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getIndexPath(n.id);if(!s)return;let a=i.getSiblingNodes(s).map(c=>i.getNodeValue(c)),l=mi(a,t.get("expandedValue"));bs(e,l)},extendSelectionToNode(e){let{context:t,event:n,prop:r,computed:i}=e,s=r("collection"),o=Ke(t.get("selectedValue"))||s.getNodeValue(s.getFirstNode()),a=n.id,l=[o,a],c=0;i("visibleNodes").forEach(({node:h})=>{let p=s.getNodeValue(h);c===1&&l.push(p),(p===o||p===a)&&c++}),t.set("selectedValue",kt(l))},extendSelectionToNextNode(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getNextNode(n.id,{skip:Et(e)});if(!s)return;let o=new Set(t.get("selectedValue")),a=i.getNodeValue(s);a!=null&&(o.has(n.id)&&o.has(a)?o.delete(n.id):o.has(a)||o.add(a),t.set("selectedValue",Array.from(o)))},extendSelectionToPrevNode(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getPreviousNode(n.id,{skip:Et(e)});if(!s)return;let o=new Set(t.get("selectedValue")),a=i.getNodeValue(s);a!=null&&(o.has(n.id)&&o.has(a)?o.delete(n.id):o.has(a)||o.add(a),t.set("selectedValue",Array.from(o)))},extendSelectionToFirstNode(e){let{context:t,prop:n}=e,r=n("collection"),i=Ke(t.get("selectedValue")),s=[];r.visit({skip:Et(e),onEnter:o=>{let a=r.getNodeValue(o);if(s.push(a),a===i)return"stop"}}),t.set("selectedValue",s)},extendSelectionToLastNode(e){let{context:t,prop:n}=e,r=n("collection"),i=Ke(t.get("selectedValue")),s=[],o=!1;r.visit({skip:Et(e),onEnter:a=>{let l=r.getNodeValue(a);l===i&&(o=!0),o&&s.push(l)}}),t.set("selectedValue",s)},clearPendingAborts({refs:e}){let t=e.get("pendingAborts");t.forEach(n=>n.abort()),t.clear()},toggleChecked({context:e,event:t,prop:n}){let r=n("collection");e.set("checkedValue",i=>t.isBranch?cI(r,t.value,i):it(i,t.value))},setChecked({context:e,event:t}){e.set("checkedValue",t.value)},clearChecked({context:e}){e.set("checkedValue",[])},setRenamingValue({context:e,event:t,prop:n}){e.set("renamingValue",t.value);let r=n("onRenameStart");if(r){let i=n("collection"),s=i.getIndexPath(t.value);if(s){let o=i.at(s);o&&r({value:t.value,node:o,indexPath:s})}}},submitRenaming({context:e,event:t,prop:n,scope:r}){var c;let i=e.get("renamingValue");if(!i)return;let o=n("collection").getIndexPath(i);if(!o)return;let a=t.label.trim(),l=n("onBeforeRename");if(l&&!l({value:i,label:a,indexPath:o})){e.set("renamingValue",null),Ce(r,i);return}(c=n("onRenameComplete"))==null||c({value:i,label:a,indexPath:o}),e.set("renamingValue",null),Ce(r,i)},cancelRenaming({context:e,scope:t}){let n=e.get("renamingValue");e.set("renamingValue",null),n&&Ce(t,n)},syncRenameInput({context:e,scope:t,prop:n}){let r=e.get("renamingValue");if(!r)return;let i=n("collection"),s=i.findNode(r);if(!s)return;let o=i.stringifyNode(s),a=jd(t,r);xt(a,o)},focusRenameInput({context:e,scope:t}){let n=e.get("renamingValue");if(!n)return;let r=jd(t,n);r&&(r.focus(),r.select())}}}};gI=G()(["ids","collection","dir","expandedValue","expandOnClick","defaultFocusedValue","focusedValue","getRootNode","id","onExpandedChange","onFocusChange","onSelectionChange","checkedValue","selectedValue","selectionMode","typeahead","defaultExpandedValue","defaultSelectedValue","defaultCheckedValue","onCheckedChange","onLoadChildrenComplete","onLoadChildrenError","loadChildren","canRename","onRenameStart","onBeforeRename","onRenameComplete","scrollToIndexFn"]),LO=B(gI),fI=G()(["node","indexPath"]),FO=B(fI);mI=class extends te{constructor(t,n){var s;let r=(s=n.treeData)!=null?s:pI(t),i=ma({nodeToValue:o=>o.id,nodeToString:o=>o.name,rootNode:r});super(t,y(m({},n),{collection:i}));U(this,"collection");U(this,"syncTree",()=>{let t=this.el.querySelector('[data-scope="tree-view"][data-part="tree"]');t&&(this.spreadProps(t,this.api.getTreeProps()),this.updateExistingTree(t))});this.collection=i}initMachine(t){return new ee(hI,m({},t))}initApi(){return dI(this.machine.service,Q)}getNodeAt(t){var r;if(t.length===0)return;let n=this.collection.rootNode;for(let i of t)if(n=(r=n==null?void 0:n.children)==null?void 0:r[i],!n)return;return n}updateExistingTree(t){this.spreadProps(t,this.api.getTreeProps());let n=t.querySelectorAll('[data-scope="tree-view"][data-part="branch"]');for(let i of n){let s=i.getAttribute("data-path");if(s==null)continue;let o=s.split("/").map(g=>parseInt(g,10)),a=this.getNodeAt(o);if(!a)continue;let l={indexPath:o,node:a};this.spreadProps(i,this.api.getBranchProps(l));let c=i.querySelector('[data-scope="tree-view"][data-part="branch-control"]');c&&this.spreadProps(c,this.api.getBranchControlProps(l));let u=i.querySelector('[data-scope="tree-view"][data-part="branch-text"]');u&&this.spreadProps(u,this.api.getBranchTextProps(l));let h=i.querySelector('[data-scope="tree-view"][data-part="branch-indicator"]');h&&this.spreadProps(h,this.api.getBranchIndicatorProps(l));let p=i.querySelector('[data-scope="tree-view"][data-part="branch-content"]');p&&this.spreadProps(p,this.api.getBranchContentProps(l));let d=i.querySelector('[data-scope="tree-view"][data-part="branch-indent-guide"]');d&&this.spreadProps(d,this.api.getBranchIndentGuideProps(l))}let r=t.querySelectorAll('[data-scope="tree-view"][data-part="item"]');for(let i of r){let s=i.getAttribute("data-path");if(s==null)continue;let o=s.split("/").map(c=>parseInt(c,10)),a=this.getNodeAt(o);if(!a)continue;let l={indexPath:o,node:a};this.spreadProps(i,this.api.getItemProps(l))}}render(){var r;let t=(r=this.el.querySelector('[data-scope="tree-view"][data-part="root"]'))!=null?r:this.el;this.spreadProps(t,this.api.getRootProps());let n=this.el.querySelector('[data-scope="tree-view"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps()),this.syncTree()}},vI={mounted(){var r;let e=this.el,t=this.pushEvent.bind(this),n=new mI(e,y(m({id:e.id},O(e,"controlled")?{expandedValue:Y(e,"expandedValue"),selectedValue:Y(e,"selectedValue")}:{defaultExpandedValue:Y(e,"defaultExpandedValue"),defaultSelectedValue:Y(e,"defaultSelectedValue")}),{selectionMode:(r=x(e,"selectionMode",["single","multiple"]))!=null?r:"single",dir:Gt(e),onSelectionChange:i=>{var d;let s=O(e,"redirect"),o=(d=i.selectedValue)!=null&&d.length?i.selectedValue[0]:void 0,a=[...e.querySelectorAll('[data-scope="tree-view"][data-part="item"], [data-scope="tree-view"][data-part="branch"]')].find(g=>g.getAttribute("data-value")===o),l=(a==null?void 0:a.getAttribute("data-part"))==="item",c=a==null?void 0:a.getAttribute("data-redirect"),u=a==null?void 0:a.hasAttribute("data-new-tab");s&&o&&l&&this.liveSocket.main.isDead&&c!=="false"&&(u?window.open(o,"_blank","noopener,noreferrer"):window.location.href=o);let p=x(e,"onSelectionChange");p&&this.liveSocket.main.isConnected()&&t(p,{id:e.id,value:y(m({},i),{isItem:l!=null?l:!1})})},onExpandedChange:i=>{let s=x(e,"onExpandedChange");s&&this.liveSocket.main.isConnected()&&t(s,{id:e.id,value:i})}}));n.init(),this.treeView=n,this.onSetExpandedValue=i=>{let{value:s}=i.detail;n.api.setExpandedValue(s)},e.addEventListener("phx:tree-view:set-expanded-value",this.onSetExpandedValue),this.onSetSelectedValue=i=>{let{value:s}=i.detail;n.api.setSelectedValue(s)},e.addEventListener("phx:tree-view:set-selected-value",this.onSetSelectedValue),this.handlers=[],this.handlers.push(this.handleEvent("tree_view_set_expanded_value",i=>{let s=i.tree_view_id;s&&e.id!==s&&e.id!==`tree-view:${s}`||n.api.setExpandedValue(i.value)})),this.handlers.push(this.handleEvent("tree_view_set_selected_value",i=>{let s=i.tree_view_id;s&&e.id!==s&&e.id!==`tree-view:${s}`||n.api.setSelectedValue(i.value)})),this.handlers.push(this.handleEvent("tree_view_expanded_value",()=>{t("tree_view_expanded_value_response",{value:n.api.expandedValue})})),this.handlers.push(this.handleEvent("tree_view_selected_value",()=>{t("tree_view_selected_value_response",{value:n.api.selectedValue})}))},updated(){var e;O(this.el,"controlled")&&((e=this.treeView)==null||e.updateProps({expandedValue:Y(this.el,"expandedValue"),selectedValue:Y(this.el,"selectedValue")}))},destroyed(){var e;if(this.onSetExpandedValue&&this.el.removeEventListener("phx:tree-view:set-expanded-value",this.onSetExpandedValue),this.onSetSelectedValue&&this.el.removeEventListener("phx:tree-view:set-selected-value",this.onSetSelectedValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.treeView)==null||e.destroy()}}});var bI={};Oe(bI,{Hooks:()=>Qd,default:()=>yI,hooks:()=>Pe});function Pe(e,t){return{mounted(){return Ee(this,null,function*(){let i=(yield e())[t];if(this._realHook=i,i!=null&&i.mounted)return i.mounted.call(this)})},updated(){var r,i;(i=(r=this._realHook)==null?void 0:r.updated)==null||i.call(this)},destroyed(){var r,i;(i=(r=this._realHook)==null?void 0:r.destroyed)==null||i.call(this)},disconnected(){var r,i;(i=(r=this._realHook)==null?void 0:r.disconnected)==null||i.call(this)},reconnected(){var r,i;(i=(r=this._realHook)==null?void 0:r.reconnected)==null||i.call(this)},beforeUpdate(){var r,i;(i=(r=this._realHook)==null?void 0:r.beforeUpdate)==null||i.call(this)}}}var Qd={Accordion:Pe(()=>Promise.resolve().then(()=>(yl(),vl)),"Accordion"),Checkbox:Pe(()=>Promise.resolve().then(()=>(Pl(),Sl)),"Checkbox"),Clipboard:Pe(()=>Promise.resolve().then(()=>(Vl(),wl)),"Clipboard"),Collapsible:Pe(()=>Promise.resolve().then(()=>(kl(),xl)),"Collapsible"),Combobox:Pe(()=>Promise.resolve().then(()=>(Vc(),wc)),"Combobox"),DatePicker:Pe(()=>Promise.resolve().then(()=>(Pu(),Su)),"DatePicker"),Dialog:Pe(()=>Promise.resolve().then(()=>(Fu(),Lu)),"Dialog"),Menu:Pe(()=>Promise.resolve().then(()=>(Ku(),Wu)),"Menu"),Select:Pe(()=>Promise.resolve().then(()=>(Qu(),zu)),"Select"),SignaturePad:Pe(()=>Promise.resolve().then(()=>(Ed(),bd)),"SignaturePad"),Switch:Pe(()=>Promise.resolve().then(()=>(Sd(),Od)),"Switch"),Tabs:Pe(()=>Promise.resolve().then(()=>(kd(),xd)),"Tabs"),Toast:Pe(()=>Promise.resolve().then(()=>(Hd(),_d)),"Toast"),ToggleGroup:Pe(()=>Promise.resolve().then(()=>(Kd(),Wd)),"ToggleGroup"),TreeView:Pe(()=>Promise.resolve().then(()=>(zd(),Zd)),"TreeView")};var yI=Qd;return hh(bI);})(); + `,this.parts={title:this.el.querySelector('[data-scope="toast"][data-part="title"]'),description:this.el.querySelector('[data-scope="toast"][data-part="description"]'),close:this.el.querySelector('[data-scope="toast"][data-part="close-trigger"]'),ghostBefore:this.el.querySelector('[data-scope="toast"][data-part="ghost-before"]'),ghostAfter:this.el.querySelector('[data-scope="toast"][data-part="ghost-after"]'),progressbar:this.el.querySelector('[data-scope="toast"][data-part="progressbar"]'),loadingSpinner:this.el.querySelector('[data-scope="toast"][data-part="loading-spinner"]')}}initMachine(t){return new ee(HC,t)}initApi(){return $C(this.machine.service,Q)}render(){var o,a;this.spreadProps(this.el,this.api.getRootProps()),this.spreadProps(this.parts.close,this.api.getCloseTriggerProps()),this.spreadProps(this.parts.ghostBefore,this.api.getGhostBeforeProps()),this.spreadProps(this.parts.ghostAfter,this.api.getGhostAfterProps()),this.parts.title.textContent!==this.api.title&&(this.parts.title.textContent=(o=this.api.title)!=null?o:""),this.parts.description.textContent!==this.api.description&&(this.parts.description.textContent=(a=this.api.description)!=null?a:""),this.spreadProps(this.parts.title,this.api.getTitleProps()),this.spreadProps(this.parts.description,this.api.getDescriptionProps());let t=this.duration,n=t==="Infinity"||t===1/0||t===Number.POSITIVE_INFINITY,r=this.el.closest('[phx-hook="Toast"]'),i=r==null?void 0:r.querySelector("[data-loading-icon-template]"),s=i==null?void 0:i.innerHTML;n?(this.parts.progressbar.style.display="none",this.parts.loadingSpinner.style.display="flex",this.el.setAttribute("data-duration-infinity","true"),s&&this.parts.loadingSpinner.innerHTML!==s&&(this.parts.loadingSpinner.innerHTML=s)):(this.parts.progressbar.style.display="block",this.parts.loadingSpinner.style.display="none",this.el.removeAttribute("data-duration-infinity"))}},KC=class extends te{constructor(t,n){var r;super(t,n);U(this,"toastComponents",new Map);U(this,"groupEl");U(this,"store");U(this,"destroy",()=>{for(let t of this.toastComponents.values())t.destroy();this.toastComponents.clear(),this.machine.stop()});this.store=n.store,this.groupEl=(r=t.querySelector('[data-part="group"]'))!=null?r:(()=>{let i=document.createElement("div");return i.setAttribute("data-scope","toast"),i.setAttribute("data-part","group"),t.appendChild(i),i})()}initMachine(t){return new ee(Md.machine,t)}initApi(){return Md.connect(this.machine.service,Q)}render(){this.spreadProps(this.groupEl,this.api.getGroupProps());let t=this.api.getToasts().filter(r=>typeof r.id=="string"),n=new Set(t.map(r=>r.id));t.forEach((r,i)=>{let s=this.toastComponents.get(r.id);if(s)s.duration=r.duration,s.updateProps(y(m({},r),{parent:this.machine.service,index:i}));else{let o=document.createElement("div");o.setAttribute("data-scope","toast"),o.setAttribute("data-part","root"),this.groupEl.appendChild(o),s=new WC(o,y(m({},r),{parent:this.machine.service,index:i})),s.init(),this.toastComponents.set(r.id,s)}});for(let[r,i]of this.toastComponents)n.has(r)||(i.destroy(),this.toastComponents.delete(r))}};jC={mounted(){var h;let e=this.el;e.id||(e.id=rn(e,"toast")),this.groupId=e.id;let t=p=>{if(p)try{return p.includes("{")?JSON.parse(p):p}catch(d){return p}},n=p=>p==="Infinity"||p===1/0?1/0:typeof p=="string"?parseInt(p,10)||void 0:p,r=(h=x(e,"placement",["top-start","top","top-end","bottom-start","bottom","bottom-end"]))!=null?h:"bottom-end";YC(e,{id:this.groupId,placement:r,overlap:O(e,"overlap"),max:Se(e,"max"),gap:Se(e,"gap"),offsets:t(x(e,"offset")),pauseOnPageIdle:O(e,"pauseOnPageIdle")});let i=jr(this.groupId),s=e.getAttribute("data-flash-info"),o=e.getAttribute("data-flash-info-title"),a=e.getAttribute("data-flash-error"),l=e.getAttribute("data-flash-error-title"),c=e.getAttribute("data-flash-info-duration"),u=e.getAttribute("data-flash-error-duration");if(i&&s)try{i.create({title:o||"Success",description:s,type:"info",id:rn(void 0,"toast"),duration:n(c!=null?c:void 0)})}catch(p){console.error("Failed to create flash info toast:",p)}if(i&&a)try{i.create({title:l||"Error",description:a,type:"error",id:rn(void 0,"toast"),duration:n(u!=null?u:void 0)})}catch(p){console.error("Failed to create flash error toast:",p)}this.handlers=[],this.handlers.push(this.handleEvent("toast-create",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.create({title:p.title,description:p.description,type:p.type||"info",id:p.id||rn(void 0,"toast"),duration:n(p.duration)})}catch(g){console.error("Failed to create toast:",g)}})),this.handlers.push(this.handleEvent("toast-update",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.update(p.id,{title:p.title,description:p.description,type:p.type})}catch(g){console.error("Failed to update toast:",g)}})),this.handlers.push(this.handleEvent("toast-dismiss",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.dismiss(p.id)}catch(g){console.error("Failed to dismiss toast:",g)}})),e.addEventListener("toast:create",p=>{let{detail:d}=p,g=jr(d.groupId||this.groupId);if(g)try{g.create({title:d.title,description:d.description,type:d.type||"info",id:d.id||rn(void 0,"toast"),duration:n(d.duration)})}catch(v){console.error("Failed to create toast:",v)}})},destroyed(){if(this.handlers)for(let e of this.handlers)this.removeHandleEvent(e)}}});var Wd={};Oe(Wd,{ToggleGroup:()=>oI});function eI(e,t){let{context:n,send:r,prop:i,scope:s}=e,o=n.get("value"),a=i("disabled"),l=!i("multiple"),c=i("rovingFocus"),u=i("orientation")==="horizontal";function h(p){let d=ZC(s,p.value);return{id:d,disabled:!!(p.disabled||a),pressed:!!o.includes(p.value),focused:n.get("focusedId")===d}}return{value:o,setValue(p){r({type:"VALUE.SET",value:p})},getRootProps(){return t.element(y(m({},Bd.root.attrs),{id:vs(s),dir:i("dir"),role:l?"radiogroup":"group",tabIndex:n.get("isTabbingBackward")?-1:0,"data-disabled":T(a),"data-orientation":i("orientation"),"data-focus":T(n.get("focusedId")!=null),style:{outline:"none"},onMouseDown(){a||r({type:"ROOT.MOUSE_DOWN"})},onFocus(p){a||p.currentTarget===K(p)&&(n.get("isClickFocus")||n.get("isTabbingBackward")||r({type:"ROOT.FOCUS"}))},onBlur(p){let d=p.relatedTarget;pe(p.currentTarget,d)||a||r({type:"ROOT.BLUR"})}}))},getItemState:h,getItemProps(p){let d=h(p),g=d.focused?0:-1;return t.button(y(m({},Bd.item.attrs),{id:d.id,type:"button","data-ownedby":vs(s),"data-focus":T(d.focused),disabled:d.disabled,tabIndex:c?g:void 0,role:l?"radio":void 0,"aria-checked":l?d.pressed:void 0,"aria-pressed":l?void 0:d.pressed,"data-disabled":T(d.disabled),"data-orientation":i("orientation"),dir:i("dir"),"data-state":d.pressed?"on":"off",onFocus(){d.disabled||r({type:"TOGGLE.FOCUS",id:d.id})},onClick(v){d.disabled||(r({type:"TOGGLE.CLICK",id:d.id,value:p.value}),Wt()&&v.currentTarget.focus({preventScroll:!0}))},onKeyDown(v){if(v.defaultPrevented||!pe(v.currentTarget,K(v))||d.disabled)return;let V={Tab(S){let E=S.shiftKey;r({type:"TOGGLE.SHIFT_TAB",isShiftTab:E})},ArrowLeft(){!c||!u||r({type:"TOGGLE.FOCUS_PREV"})},ArrowRight(){!c||!u||r({type:"TOGGLE.FOCUS_NEXT"})},ArrowUp(){!c||u||r({type:"TOGGLE.FOCUS_PREV"})},ArrowDown(){!c||u||r({type:"TOGGLE.FOCUS_NEXT"})},Home(){c&&r({type:"TOGGLE.FOCUS_FIRST"})},End(){c&&r({type:"TOGGLE.FOCUS_LAST"})}}[ve(v)];V&&(V(v),v.key!=="Tab"&&v.preventDefault())}}))}}}var XC,Bd,vs,ZC,qd,ys,Gd,JC,zC,QC,Ud,tI,nI,rI,xO,iI,kO,sI,oI,Kd=fe(()=>{"use strict";me();XC=Z("toggle-group").parts("root","item"),Bd=XC.build(),vs=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`toggle-group:${e.id}`},ZC=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.item)==null?void 0:r.call(n,t))!=null?i:`toggle-group:${e.id}:${t}`},qd=e=>e.getById(vs(e)),ys=e=>{let n=`[data-ownedby='${CSS.escape(vs(e))}']:not([data-disabled])`;return dt(qd(e),n)},Gd=e=>Ke(ys(e)),JC=e=>nt(ys(e)),zC=(e,t,n)=>$n(ys(e),t,n),QC=(e,t,n)=>_n(ys(e),t,n);({not:Ud,and:tI}=ye()),nI={props({props:e}){return m({defaultValue:[],orientation:"horizontal",rovingFocus:!0,loopFocus:!0,deselectable:!0},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(n){var r;(r=e("onValueChange"))==null||r({value:n})}})),focusedId:t(()=>({defaultValue:null})),isTabbingBackward:t(()=>({defaultValue:!1})),isClickFocus:t(()=>({defaultValue:!1})),isWithinToolbar:t(()=>({defaultValue:!1}))}},computed:{currentLoopFocus:({context:e,prop:t})=>t("loopFocus")&&!e.get("isWithinToolbar")},entry:["checkIfWithinToolbar"],on:{"VALUE.SET":{actions:["setValue"]},"TOGGLE.CLICK":{actions:["setValue"]},"ROOT.MOUSE_DOWN":{actions:["setClickFocus"]}},states:{idle:{on:{"ROOT.FOCUS":{target:"focused",guard:Ud(tI("isClickFocus","isTabbingBackward")),actions:["focusFirstToggle","clearClickFocus"]},"TOGGLE.FOCUS":{target:"focused",actions:["setFocusedId"]}}},focused:{on:{"ROOT.BLUR":{target:"idle",actions:["clearIsTabbingBackward","clearFocusedId","clearClickFocus"]},"TOGGLE.FOCUS":{actions:["setFocusedId"]},"TOGGLE.FOCUS_NEXT":{actions:["focusNextToggle"]},"TOGGLE.FOCUS_PREV":{actions:["focusPrevToggle"]},"TOGGLE.FOCUS_FIRST":{actions:["focusFirstToggle"]},"TOGGLE.FOCUS_LAST":{actions:["focusLastToggle"]},"TOGGLE.SHIFT_TAB":[{guard:Ud("isFirstToggleFocused"),target:"idle",actions:["setIsTabbingBackward"]},{actions:["setIsTabbingBackward"]}]}}},implementations:{guards:{isClickFocus:({context:e})=>e.get("isClickFocus"),isTabbingBackward:({context:e})=>e.get("isTabbingBackward"),isFirstToggleFocused:({context:e,scope:t})=>{var n;return e.get("focusedId")===((n=Gd(t))==null?void 0:n.id)}},actions:{setIsTabbingBackward({context:e}){e.set("isTabbingBackward",!0)},clearIsTabbingBackward({context:e}){e.set("isTabbingBackward",!1)},setClickFocus({context:e}){e.set("isClickFocus",!0)},clearClickFocus({context:e}){e.set("isClickFocus",!1)},checkIfWithinToolbar({context:e,scope:t}){var r;let n=(r=qd(t))==null?void 0:r.closest("[role=toolbar]");e.set("isWithinToolbar",!!n)},setFocusedId({context:e,event:t}){e.set("focusedId",t.id)},clearFocusedId({context:e}){e.set("focusedId",null)},setValue({context:e,event:t,prop:n}){yi(t,["value"]);let r=e.get("value");Kt(t.value)?r=t.value:n("multiple")?r=it(r,t.value):r=he(r,[t.value])&&n("deselectable")?[]:[t.value],e.set("value",r)},focusNextToggle({context:e,scope:t,prop:n}){H(()=>{var i;let r=e.get("focusedId");r&&((i=zC(t,r,n("loopFocus")))==null||i.focus({preventScroll:!0}))})},focusPrevToggle({context:e,scope:t,prop:n}){H(()=>{var i;let r=e.get("focusedId");r&&((i=QC(t,r,n("loopFocus")))==null||i.focus({preventScroll:!0}))})},focusFirstToggle({scope:e}){H(()=>{var t;(t=Gd(e))==null||t.focus({preventScroll:!0})})},focusLastToggle({scope:e}){H(()=>{var t;(t=JC(e))==null||t.focus({preventScroll:!0})})}}}},rI=G()(["dir","disabled","getRootNode","id","ids","loopFocus","multiple","onValueChange","orientation","rovingFocus","value","defaultValue","deselectable"]),xO=B(rI),iI=G()(["value","disabled"]),kO=B(iI),sI=class extends te{initMachine(e){return new ee(nI,e)}initApi(){return eI(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="toggle-group"][data-part="root"]');if(!e)return;this.spreadProps(e,this.api.getRootProps());let t=this.el.querySelectorAll('[data-scope="toggle-group"][data-part="item"]');for(let n=0;n{let s=x(e,"onValueChange");s&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(s,{value:i.value,id:e.id});let o=x(e,"onValueChangeClient");o&&e.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:{value:i.value,id:e.id}}))}}),r=new sI(e,n);r.init(),this.toggleGroup=r,this.onSetValue=i=>{let{value:s}=i.detail;r.api.setValue(s)},e.addEventListener("phx:toggle-group:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("toggle-group_set_value",i=>{let s=i.id;s&&s!==e.id||r.api.setValue(i.value)})),this.handlers.push(this.handleEvent("toggle-group:value",()=>{this.pushEvent("toggle-group:value_response",{value:r.api.value})}))},updated(){var e;(e=this.toggleGroup)==null||e.updateProps(y(m({},O(this.el,"controlled")?{value:Y(this.el,"value")}:{defaultValue:Y(this.el,"defaultValue")}),{deselectable:O(this.el,"deselectable"),loopFocus:O(this.el,"loopFocus"),rovingFocus:O(this.el,"rovingFocus"),disabled:O(this.el,"disabled"),multiple:O(this.el,"multiple"),orientation:x(this.el,"orientation",["horizontal","vertical"]),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:toggle-group:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.toggleGroup)==null||e.destroy()}}});var Jd={};Oe(Jd,{TreeView:()=>vI});function Zd(e,t,n){let r=e.getNodeValue(t);if(!e.isBranchNode(t))return n.includes(r);let i=e.getDescendantValues(r),s=i.every(a=>n.includes(a)),o=i.some(a=>n.includes(a));return s?!0:o?"indeterminate":!1}function cI(e,t,n){let r=e.getDescendantValues(t),i=r.every(s=>n.includes(s));return kt(i?ht(n,...r):rt(n,...r))}function uI(e,t){let n=new Map;return e.visit({onEnter:r=>{let i=e.getNodeValue(r),s=e.isBranchNode(r),o=Zd(e,r,t);n.set(i,{type:s?"branch":"leaf",checked:o})}}),n}function dI(e,t){let{context:n,scope:r,computed:i,prop:s,send:o}=e,a=s("collection"),l=Array.from(n.get("expandedValue")),c=Array.from(n.get("selectedValue")),u=Array.from(n.get("checkedValue")),h=i("isTypingAhead"),p=n.get("focusedValue"),d=n.get("loadingStatus"),g=n.get("renamingValue"),v=({indexPath:E})=>a.getValuePath(E).slice(0,-1).some(C=>!l.includes(C)),b=a.getFirstNode(void 0,{skip:v}),V=b?a.getNodeValue(b):null;function S(E){let{node:f,indexPath:C}=E,I=a.getNodeValue(f);return{id:va(r,I),value:I,indexPath:C,valuePath:a.getValuePath(C),disabled:!!f.disabled,focused:p==null?V===I:p===I,selected:c.includes(I),expanded:l.includes(I),loading:d[I]==="loading",depth:C.length,isBranch:a.isBranchNode(f),renaming:g===I,get checked(){return Zd(a,f,u)}}}return{collection:a,expandedValue:l,selectedValue:c,checkedValue:u,toggleChecked(E,f){o({type:"CHECKED.TOGGLE",value:E,isBranch:f})},setChecked(E){o({type:"CHECKED.SET",value:E})},clearChecked(){o({type:"CHECKED.CLEAR"})},getCheckedMap(){return uI(a,u)},expand(E){o({type:E?"BRANCH.EXPAND":"EXPANDED.ALL",value:E})},collapse(E){o({type:E?"BRANCH.COLLAPSE":"EXPANDED.CLEAR",value:E})},deselect(E){o({type:E?"NODE.DESELECT":"SELECTED.CLEAR",value:E})},select(E){o({type:E?"NODE.SELECT":"SELECTED.ALL",value:E,isTrusted:!1})},getVisibleNodes(){return i("visibleNodes")},focus(E){Ce(r,E)},selectParent(E){let f=a.getParentNode(E);if(!f)return;let C=rt(c,a.getNodeValue(f));o({type:"SELECTED.SET",value:C,src:"select.parent"})},expandParent(E){let f=a.getParentNode(E);if(!f)return;let C=rt(l,a.getNodeValue(f));o({type:"EXPANDED.SET",value:C,src:"expand.parent"})},setExpandedValue(E){let f=kt(E);o({type:"EXPANDED.SET",value:f})},setSelectedValue(E){let f=kt(E);o({type:"SELECTED.SET",value:f})},startRenaming(E){o({type:"NODE.RENAME",value:E})},submitRenaming(E,f){o({type:"RENAME.SUBMIT",value:E,label:f})},cancelRenaming(){o({type:"RENAME.CANCEL"})},getRootProps(){return t.element(y(m({},Ne.root.attrs),{id:lI(r),dir:s("dir")}))},getLabelProps(){return t.element(y(m({},Ne.label.attrs),{id:Yd(r),dir:s("dir")}))},getTreeProps(){return t.element(y(m({},Ne.tree.attrs),{id:pa(r),dir:s("dir"),role:"tree","aria-label":"Tree View","aria-labelledby":Yd(r),"aria-multiselectable":s("selectionMode")==="multiple"||void 0,tabIndex:-1,onKeyDown(E){if(E.defaultPrevented||Vt(E))return;let f=K(E);if(Ut(f))return;let C=f==null?void 0:f.closest("[data-part=branch-control], [data-part=item]");if(!C)return;let I=C.dataset.value;if(I==null){console.warn("[zag-js/tree-view] Node id not found for node",C);return}let w=C.matches("[data-part=branch-control]"),A={ArrowDown(R){Fe(R)||(R.preventDefault(),o({type:"NODE.ARROW_DOWN",id:I,shiftKey:R.shiftKey}))},ArrowUp(R){Fe(R)||(R.preventDefault(),o({type:"NODE.ARROW_UP",id:I,shiftKey:R.shiftKey}))},ArrowLeft(R){Fe(R)||C.dataset.disabled||(R.preventDefault(),o({type:w?"BRANCH_NODE.ARROW_LEFT":"NODE.ARROW_LEFT",id:I}))},ArrowRight(R){!w||C.dataset.disabled||(R.preventDefault(),o({type:"BRANCH_NODE.ARROW_RIGHT",id:I}))},Home(R){Fe(R)||(R.preventDefault(),o({type:"NODE.HOME",id:I,shiftKey:R.shiftKey}))},End(R){Fe(R)||(R.preventDefault(),o({type:"NODE.END",id:I,shiftKey:R.shiftKey}))},Space(R){var L;C.dataset.disabled||(h?o({type:"TREE.TYPEAHEAD",key:R.key}):(L=A.Enter)==null||L.call(A,R))},Enter(R){C.dataset.disabled||We(f)&&Fe(R)||(o({type:w?"BRANCH_NODE.CLICK":"NODE.CLICK",id:I,src:"keyboard"}),We(f)||R.preventDefault())},"*"(R){C.dataset.disabled||(R.preventDefault(),o({type:"SIBLINGS.EXPAND",id:I}))},a(R){!R.metaKey||C.dataset.disabled||(R.preventDefault(),o({type:"SELECTED.ALL",moveFocus:!0}))},F2(R){if(C.dataset.disabled)return;let L=s("canRename");if(!L)return;let M=a.getIndexPath(I);if(M){let j=a.at(M);if(j&&!L(j,M))return}R.preventDefault(),o({type:"NODE.RENAME",value:I})}},P=ve(E,{dir:s("dir")}),N=A[P];if(N){N(E);return}tt.isValidEvent(E)&&(o({type:"TREE.TYPEAHEAD",key:E.key,id:I}),E.preventDefault())}}))},getNodeState:S,getItemProps(E){let f=S(E);return t.element(y(m({},Ne.item.attrs),{id:f.id,dir:s("dir"),"data-ownedby":pa(r),"data-path":E.indexPath.join("/"),"data-value":f.value,tabIndex:f.focused?0:-1,"data-focus":T(f.focused),role:"treeitem","aria-current":f.selected?"true":void 0,"aria-selected":f.disabled?void 0:f.selected,"data-selected":T(f.selected),"aria-disabled":re(f.disabled),"data-disabled":T(f.disabled),"data-renaming":T(f.renaming),"aria-level":f.depth,"data-depth":f.depth,style:{"--depth":f.depth},onFocus(C){C.stopPropagation(),o({type:"NODE.FOCUS",id:f.value})},onClick(C){if(f.disabled||!et(C)||We(C.currentTarget)&&Fe(C))return;let I=C.metaKey||C.ctrlKey;o({type:"NODE.CLICK",id:f.value,shiftKey:C.shiftKey,ctrlKey:I}),C.stopPropagation(),We(C.currentTarget)||C.preventDefault()}}))},getItemTextProps(E){let f=S(E);return t.element(y(m({},Ne.itemText.attrs),{"data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused)}))},getItemIndicatorProps(E){let f=S(E);return t.element(y(m({},Ne.itemIndicator.attrs),{"aria-hidden":!0,"data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),hidden:!f.selected}))},getBranchProps(E){let f=S(E);return t.element(y(m({},Ne.branch.attrs),{"data-depth":f.depth,dir:s("dir"),"data-branch":f.value,role:"treeitem","data-ownedby":pa(r),"data-value":f.value,"aria-level":f.depth,"aria-selected":f.disabled?void 0:f.selected,"data-path":E.indexPath.join("/"),"data-selected":T(f.selected),"aria-expanded":f.expanded,"data-state":f.expanded?"open":"closed","aria-disabled":re(f.disabled),"data-disabled":T(f.disabled),"data-loading":T(f.loading),"aria-busy":re(f.loading),style:{"--depth":f.depth}}))},getBranchIndicatorProps(E){let f=S(E);return t.element(y(m({},Ne.branchIndicator.attrs),{"aria-hidden":!0,"data-state":f.expanded?"open":"closed","data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),"data-loading":T(f.loading)}))},getBranchTriggerProps(E){let f=S(E);return t.element(y(m({},Ne.branchTrigger.attrs),{role:"button",dir:s("dir"),"data-disabled":T(f.disabled),"data-state":f.expanded?"open":"closed","data-value":f.value,"data-loading":T(f.loading),disabled:f.loading,onClick(C){f.disabled||f.loading||(o({type:"BRANCH_TOGGLE.CLICK",id:f.value}),C.stopPropagation())}}))},getBranchControlProps(E){let f=S(E);return t.element(y(m({},Ne.branchControl.attrs),{role:"button",id:f.id,dir:s("dir"),tabIndex:f.focused?0:-1,"data-path":E.indexPath.join("/"),"data-state":f.expanded?"open":"closed","data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),"data-renaming":T(f.renaming),"data-value":f.value,"data-depth":f.depth,"data-loading":T(f.loading),"aria-busy":re(f.loading),onFocus(C){o({type:"NODE.FOCUS",id:f.value}),C.stopPropagation()},onClick(C){if(f.disabled||f.loading||!et(C)||We(C.currentTarget)&&Fe(C))return;let I=C.metaKey||C.ctrlKey;o({type:"BRANCH_NODE.CLICK",id:f.value,shiftKey:C.shiftKey,ctrlKey:I}),C.stopPropagation()}}))},getBranchTextProps(E){let f=S(E);return t.element(y(m({},Ne.branchText.attrs),{dir:s("dir"),"data-disabled":T(f.disabled),"data-state":f.expanded?"open":"closed","data-loading":T(f.loading)}))},getBranchContentProps(E){let f=S(E);return t.element(y(m({},Ne.branchContent.attrs),{role:"group",dir:s("dir"),"data-state":f.expanded?"open":"closed","data-depth":f.depth,"data-path":E.indexPath.join("/"),"data-value":f.value,hidden:!f.expanded}))},getBranchIndentGuideProps(E){let f=S(E);return t.element(y(m({},Ne.branchIndentGuide.attrs),{"data-depth":f.depth}))},getNodeCheckboxProps(E){let f=S(E),C=f.checked;return t.element(y(m({},Ne.nodeCheckbox.attrs),{tabIndex:-1,role:"checkbox","data-state":C===!0?"checked":C===!1?"unchecked":"indeterminate","aria-checked":C===!0?"true":C===!1?"false":"mixed","data-disabled":T(f.disabled),onClick(I){if(I.defaultPrevented||f.disabled||!et(I))return;o({type:"CHECKED.TOGGLE",value:f.value,isBranch:f.isBranch}),I.stopPropagation();let w=I.currentTarget.closest("[role=treeitem]");w==null||w.focus({preventScroll:!0})}}))},getNodeRenameInputProps(E){let f=S(E);return t.input(y(m({},Ne.nodeRenameInput.attrs),{id:Xd(r,f.value),type:"text","aria-label":"Rename tree item",hidden:!f.renaming,onKeyDown(C){Vt(C)||(C.key==="Escape"&&(o({type:"RENAME.CANCEL"}),C.preventDefault()),C.key==="Enter"&&(o({type:"RENAME.SUBMIT",label:C.currentTarget.value}),C.preventDefault()),C.stopPropagation())},onBlur(C){o({type:"RENAME.SUBMIT",label:C.currentTarget.value})}}))}}}function bs(e,t){let{context:n,prop:r,refs:i}=e;if(!r("loadChildren")){n.set("expandedValue",v=>kt(rt(v,...t)));return}let s=n.get("loadingStatus"),[o,a]=Ks(t,v=>s[v]==="loaded");if(o.length>0&&n.set("expandedValue",v=>kt(rt(v,...o))),a.length===0)return;let l=r("collection"),[c,u]=Ks(a,v=>{let b=l.findNode(v);return l.getNodeChildren(b).length>0});if(c.length>0&&n.set("expandedValue",v=>kt(rt(v,...c))),u.length===0)return;n.set("loadingStatus",v=>m(m({},v),u.reduce((b,V)=>y(m({},b),{[V]:"loading"}),{})));let h=u.map(v=>{let b=l.getIndexPath(v),V=l.getValuePath(b),S=l.findNode(v);return{id:v,indexPath:b,valuePath:V,node:S}}),p=i.get("pendingAborts"),d=r("loadChildren");qn(d,()=>"[zag-js/tree-view] `loadChildren` is required for async expansion");let g=h.map(({id:v,indexPath:b,valuePath:V,node:S})=>{let E=p.get(v);E&&(E.abort(),p.delete(v));let f=new AbortController;return p.set(v,f),d({valuePath:V,indexPath:b,node:S,signal:f.signal})});Promise.allSettled(g).then(v=>{var f,C;let b=[],V=[],S=n.get("loadingStatus"),E=r("collection");v.forEach((I,w)=>{let{id:A,indexPath:P,node:N,valuePath:R}=h[w];I.status==="fulfilled"?(S[A]="loaded",b.push(A),E=E.replace(P,y(m({},N),{children:I.value}))):(p.delete(A),Reflect.deleteProperty(S,A),V.push({node:N,error:I.reason,indexPath:P,valuePath:R}))}),n.set("loadingStatus",S),b.length&&(n.set("expandedValue",I=>kt(rt(I,...b))),(f=r("onLoadChildrenComplete"))==null||f({collection:E})),V.length&&((C=r("onLoadChildrenError"))==null||C({nodes:V}))})}function Et(e){let{prop:t,context:n}=e;return function({indexPath:i}){return t("collection").getValuePath(i).slice(0,-1).some(o=>!n.get("expandedValue").includes(o))}}function wn(e,t){let{prop:n,scope:r,computed:i}=e,s=n("scrollToIndexFn");if(!s)return!1;let o=n("collection"),a=i("visibleNodes");for(let l=0;lr.getById(va(r,t))}),!0}return!1}function pI(e){var s;let n=e.querySelectorAll('[data-scope="tree-view"][data-part="branch"], [data-scope="tree-view"][data-part="item"]'),r=[];for(let o of n){let a=o.getAttribute("data-path"),l=o.getAttribute("data-value");if(a==null||l==null)continue;let c=a.split("/").map(p=>parseInt(p,10));if(c.some(Number.isNaN))continue;let u=(s=o.getAttribute("data-name"))!=null?s:l,h=o.getAttribute("data-part")==="branch";r.push({pathArr:c,id:l,name:u,isBranch:h})}r.sort((o,a)=>{let l=Math.min(o.pathArr.length,a.pathArr.length);for(let c=0;c{"use strict";Ai();me();aI=Z("tree-view").parts("branch","branchContent","branchControl","branchIndentGuide","branchIndicator","branchText","branchTrigger","item","itemIndicator","itemText","label","nodeCheckbox","nodeRenameInput","root","tree"),Ne=aI.build(),ma=e=>new ro(e);ma.empty=()=>new ro({rootNode:{children:[]}});lI=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`tree:${e.id}:root`},Yd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`tree:${e.id}:label`},va=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.node)==null?void 0:r.call(n,t))!=null?i:`tree:${e.id}:node:${t}`},pa=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.tree)!=null?n:`tree:${e.id}:tree`},Ce=(e,t)=>{var n;t!=null&&((n=e.getById(va(e,t)))==null||n.focus())},Xd=(e,t)=>`tree:${e.id}:rename-input:${t}`,jd=(e,t)=>e.getById(Xd(e,t));({and:Ct}=ye()),hI={props({props:e}){return m({selectionMode:"single",collection:ma.empty(),typeahead:!0,expandOnClick:!0,defaultExpandedValue:[],defaultSelectedValue:[]},e)},initialState(){return"idle"},context({prop:e,bindable:t,getContext:n}){return{expandedValue:t(()=>({defaultValue:e("defaultExpandedValue"),value:e("expandedValue"),isEqual:he,onChange(r){var o;let s=n().get("focusedValue");(o=e("onExpandedChange"))==null||o({expandedValue:r,focusedValue:s,get expandedNodes(){return e("collection").findNodes(r)}})}})),selectedValue:t(()=>({defaultValue:e("defaultSelectedValue"),value:e("selectedValue"),isEqual:he,onChange(r){var o;let s=n().get("focusedValue");(o=e("onSelectionChange"))==null||o({selectedValue:r,focusedValue:s,get selectedNodes(){return e("collection").findNodes(r)}})}})),focusedValue:t(()=>({defaultValue:e("defaultFocusedValue")||null,value:e("focusedValue"),onChange(r){var i;(i=e("onFocusChange"))==null||i({focusedValue:r,get focusedNode(){return r?e("collection").findNode(r):null}})}})),loadingStatus:t(()=>({defaultValue:{}})),checkedValue:t(()=>({defaultValue:e("defaultCheckedValue")||[],value:e("checkedValue"),isEqual:he,onChange(r){var i;(i=e("onCheckedChange"))==null||i({checkedValue:r})}})),renamingValue:t(()=>({sync:!0,defaultValue:null}))}},refs(){return{typeaheadState:m({},tt.defaultOptions),pendingAborts:new Map}},computed:{isMultipleSelection:({prop:e})=>e("selectionMode")==="multiple",isTypingAhead:({refs:e})=>e.get("typeaheadState").keysSoFar.length>0,visibleNodes:({prop:e,context:t})=>{let n=[];return e("collection").visit({skip:Et({prop:e,context:t}),onEnter:(r,i)=>{n.push({node:r,indexPath:i})}}),n}},on:{"EXPANDED.SET":{actions:["setExpanded"]},"EXPANDED.CLEAR":{actions:["clearExpanded"]},"EXPANDED.ALL":{actions:["expandAllBranches"]},"BRANCH.EXPAND":{actions:["expandBranches"]},"BRANCH.COLLAPSE":{actions:["collapseBranches"]},"SELECTED.SET":{actions:["setSelected"]},"SELECTED.ALL":[{guard:Ct("isMultipleSelection","moveFocus"),actions:["selectAllNodes","focusTreeLastNode"]},{guard:"isMultipleSelection",actions:["selectAllNodes"]}],"SELECTED.CLEAR":{actions:["clearSelected"]},"NODE.SELECT":{actions:["selectNode"]},"NODE.DESELECT":{actions:["deselectNode"]},"CHECKED.TOGGLE":{actions:["toggleChecked"]},"CHECKED.SET":{actions:["setChecked"]},"CHECKED.CLEAR":{actions:["clearChecked"]},"NODE.FOCUS":{actions:["setFocusedNode"]},"NODE.ARROW_DOWN":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["focusTreeNextNode","extendSelectionToNextNode"]},{actions:["focusTreeNextNode"]}],"NODE.ARROW_UP":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["focusTreePrevNode","extendSelectionToPrevNode"]},{actions:["focusTreePrevNode"]}],"NODE.ARROW_LEFT":{actions:["focusBranchNode"]},"BRANCH_NODE.ARROW_LEFT":[{guard:"isBranchExpanded",actions:["collapseBranch"]},{actions:["focusBranchNode"]}],"BRANCH_NODE.ARROW_RIGHT":[{guard:Ct("isBranchFocused","isBranchExpanded"),actions:["focusBranchFirstNode"]},{actions:["expandBranch"]}],"SIBLINGS.EXPAND":{actions:["expandSiblingBranches"]},"NODE.HOME":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToFirstNode","focusTreeFirstNode"]},{actions:["focusTreeFirstNode"]}],"NODE.END":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToLastNode","focusTreeLastNode"]},{actions:["focusTreeLastNode"]}],"NODE.CLICK":[{guard:Ct("isCtrlKey","isMultipleSelection"),actions:["toggleNodeSelection"]},{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToNode"]},{actions:["selectNode"]}],"BRANCH_NODE.CLICK":[{guard:Ct("isCtrlKey","isMultipleSelection"),actions:["toggleNodeSelection"]},{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToNode"]},{guard:"expandOnClick",actions:["selectNode","toggleBranchNode"]},{actions:["selectNode"]}],"BRANCH_TOGGLE.CLICK":{actions:["toggleBranchNode"]},"TREE.TYPEAHEAD":{actions:["focusMatchedNode"]}},exit:["clearPendingAborts"],states:{idle:{on:{"NODE.RENAME":{target:"renaming",actions:["setRenamingValue"]}}},renaming:{entry:["syncRenameInput","focusRenameInput"],on:{"RENAME.SUBMIT":{guard:"isRenameLabelValid",target:"idle",actions:["submitRenaming"]},"RENAME.CANCEL":{target:"idle",actions:["cancelRenaming"]}}}},implementations:{guards:{isBranchFocused:({context:e,event:t})=>e.get("focusedValue")===t.id,isBranchExpanded:({context:e,event:t})=>e.get("expandedValue").includes(t.id),isShiftKey:({event:e})=>e.shiftKey,isCtrlKey:({event:e})=>e.ctrlKey,hasSelectedItems:({context:e})=>e.get("selectedValue").length>0,isMultipleSelection:({prop:e})=>e("selectionMode")==="multiple",moveFocus:({event:e})=>!!e.moveFocus,expandOnClick:({prop:e})=>!!e("expandOnClick"),isRenameLabelValid:({event:e})=>e.label.trim()!==""},actions:{selectNode({context:e,event:t}){let n=t.id||t.value;e.set("selectedValue",r=>n==null?r:!t.isTrusted&&Kt(n)?r.concat(...n):[Kt(n)?nt(n):n].filter(Boolean))},deselectNode({context:e,event:t}){let n=Tr(t.id||t.value);e.set("selectedValue",r=>ht(r,...n))},setFocusedNode({context:e,event:t}){e.set("focusedValue",t.id)},clearFocusedNode({context:e}){e.set("focusedValue",null)},clearSelectedItem({context:e}){e.set("selectedValue",[])},toggleBranchNode({context:e,event:t,action:n}){let r=e.get("expandedValue").includes(t.id);n(r?["collapseBranch"]:["expandBranch"])},expandBranch(e){let{event:t}=e;bs(e,[t.id])},expandBranches(e){let{context:t,event:n}=e,r=Tr(n.value);bs(e,mi(r,t.get("expandedValue")))},collapseBranch({context:e,event:t}){e.set("expandedValue",n=>ht(n,t.id))},collapseBranches(e){let{context:t,event:n}=e,r=Tr(n.value);t.set("expandedValue",i=>ht(i,...r))},setExpanded({context:e,event:t}){Kt(t.value)&&e.set("expandedValue",t.value)},clearExpanded({context:e}){e.set("expandedValue",[])},setSelected({context:e,event:t}){Kt(t.value)&&e.set("selectedValue",t.value)},clearSelected({context:e}){e.set("selectedValue",[])},focusTreeFirstNode(e){let{prop:t,scope:n}=e,r=t("collection"),i=r.getFirstNode(void 0,{skip:Et(e)});if(!i)return;let s=r.getNodeValue(i);wn(e,s)?H(()=>Ce(n,s)):Ce(n,s)},focusTreeLastNode(e){let{prop:t,scope:n}=e,r=t("collection"),i=r.getLastNode(void 0,{skip:Et(e)}),s=r.getNodeValue(i);wn(e,s)?H(()=>Ce(n,s)):Ce(n,s)},focusBranchFirstNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.findNode(t.id),o=i.getFirstNode(s,{skip:Et(e)});if(!o)return;let a=i.getNodeValue(o);wn(e,a)?H(()=>Ce(r,a)):Ce(r,a)},focusTreeNextNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getNextNode(t.id,{skip:Et(e)});if(!s)return;let o=i.getNodeValue(s);wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},focusTreePrevNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getPreviousNode(t.id,{skip:Et(e)});if(!s)return;let o=i.getNodeValue(s);wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},focusBranchNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getParentNode(t.id),o=s?i.getNodeValue(s):void 0;if(!o)return;wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},selectAllNodes({context:e,prop:t}){e.set("selectedValue",t("collection").getValues())},focusMatchedNode(e){let{context:t,prop:n,refs:r,event:i,scope:s,computed:o}=e,l=o("visibleNodes").map(({node:h})=>({textContent:n("collection").stringifyNode(h),id:n("collection").getNodeValue(h)})),c=tt(l,{state:r.get("typeaheadState"),activeId:t.get("focusedValue"),key:i.key});if(!(c!=null&&c.id))return;wn(e,c.id)?H(()=>Ce(s,c.id)):Ce(s,c.id)},toggleNodeSelection({context:e,event:t}){let n=it(e.get("selectedValue"),t.id);e.set("selectedValue",n)},expandAllBranches(e){let{context:t,prop:n}=e,r=n("collection").getBranchValues(),i=mi(r,t.get("expandedValue"));bs(e,i)},expandSiblingBranches(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getIndexPath(n.id);if(!s)return;let a=i.getSiblingNodes(s).map(c=>i.getNodeValue(c)),l=mi(a,t.get("expandedValue"));bs(e,l)},extendSelectionToNode(e){let{context:t,event:n,prop:r,computed:i}=e,s=r("collection"),o=Ke(t.get("selectedValue"))||s.getNodeValue(s.getFirstNode()),a=n.id,l=[o,a],c=0;i("visibleNodes").forEach(({node:h})=>{let p=s.getNodeValue(h);c===1&&l.push(p),(p===o||p===a)&&c++}),t.set("selectedValue",kt(l))},extendSelectionToNextNode(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getNextNode(n.id,{skip:Et(e)});if(!s)return;let o=new Set(t.get("selectedValue")),a=i.getNodeValue(s);a!=null&&(o.has(n.id)&&o.has(a)?o.delete(n.id):o.has(a)||o.add(a),t.set("selectedValue",Array.from(o)))},extendSelectionToPrevNode(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getPreviousNode(n.id,{skip:Et(e)});if(!s)return;let o=new Set(t.get("selectedValue")),a=i.getNodeValue(s);a!=null&&(o.has(n.id)&&o.has(a)?o.delete(n.id):o.has(a)||o.add(a),t.set("selectedValue",Array.from(o)))},extendSelectionToFirstNode(e){let{context:t,prop:n}=e,r=n("collection"),i=Ke(t.get("selectedValue")),s=[];r.visit({skip:Et(e),onEnter:o=>{let a=r.getNodeValue(o);if(s.push(a),a===i)return"stop"}}),t.set("selectedValue",s)},extendSelectionToLastNode(e){let{context:t,prop:n}=e,r=n("collection"),i=Ke(t.get("selectedValue")),s=[],o=!1;r.visit({skip:Et(e),onEnter:a=>{let l=r.getNodeValue(a);l===i&&(o=!0),o&&s.push(l)}}),t.set("selectedValue",s)},clearPendingAborts({refs:e}){let t=e.get("pendingAborts");t.forEach(n=>n.abort()),t.clear()},toggleChecked({context:e,event:t,prop:n}){let r=n("collection");e.set("checkedValue",i=>t.isBranch?cI(r,t.value,i):it(i,t.value))},setChecked({context:e,event:t}){e.set("checkedValue",t.value)},clearChecked({context:e}){e.set("checkedValue",[])},setRenamingValue({context:e,event:t,prop:n}){e.set("renamingValue",t.value);let r=n("onRenameStart");if(r){let i=n("collection"),s=i.getIndexPath(t.value);if(s){let o=i.at(s);o&&r({value:t.value,node:o,indexPath:s})}}},submitRenaming({context:e,event:t,prop:n,scope:r}){var c;let i=e.get("renamingValue");if(!i)return;let o=n("collection").getIndexPath(i);if(!o)return;let a=t.label.trim(),l=n("onBeforeRename");if(l&&!l({value:i,label:a,indexPath:o})){e.set("renamingValue",null),Ce(r,i);return}(c=n("onRenameComplete"))==null||c({value:i,label:a,indexPath:o}),e.set("renamingValue",null),Ce(r,i)},cancelRenaming({context:e,scope:t}){let n=e.get("renamingValue");e.set("renamingValue",null),n&&Ce(t,n)},syncRenameInput({context:e,scope:t,prop:n}){let r=e.get("renamingValue");if(!r)return;let i=n("collection"),s=i.findNode(r);if(!s)return;let o=i.stringifyNode(s),a=jd(t,r);xt(a,o)},focusRenameInput({context:e,scope:t}){let n=e.get("renamingValue");if(!n)return;let r=jd(t,n);r&&(r.focus(),r.select())}}}};gI=G()(["ids","collection","dir","expandedValue","expandOnClick","defaultFocusedValue","focusedValue","getRootNode","id","onExpandedChange","onFocusChange","onSelectionChange","checkedValue","selectedValue","selectionMode","typeahead","defaultExpandedValue","defaultSelectedValue","defaultCheckedValue","onCheckedChange","onLoadChildrenComplete","onLoadChildrenError","loadChildren","canRename","onRenameStart","onBeforeRename","onRenameComplete","scrollToIndexFn"]),LO=B(gI),fI=G()(["node","indexPath"]),FO=B(fI);mI=class extends te{constructor(t,n){var s;let r=(s=n.treeData)!=null?s:pI(t),i=ma({nodeToValue:o=>o.id,nodeToString:o=>o.name,rootNode:r});super(t,y(m({},n),{collection:i}));U(this,"collection");U(this,"syncTree",()=>{let t=this.el.querySelector('[data-scope="tree-view"][data-part="tree"]');t&&(this.spreadProps(t,this.api.getTreeProps()),this.updateExistingTree(t))});this.collection=i}initMachine(t){return new ee(hI,m({},t))}initApi(){return dI(this.machine.service,Q)}getNodeAt(t){var r;if(t.length===0)return;let n=this.collection.rootNode;for(let i of t)if(n=(r=n==null?void 0:n.children)==null?void 0:r[i],!n)return;return n}updateExistingTree(t){this.spreadProps(t,this.api.getTreeProps());let n=t.querySelectorAll('[data-scope="tree-view"][data-part="branch"]');for(let i of n){let s=i.getAttribute("data-path");if(s==null)continue;let o=s.split("/").map(g=>parseInt(g,10)),a=this.getNodeAt(o);if(!a)continue;let l={indexPath:o,node:a};this.spreadProps(i,this.api.getBranchProps(l));let c=i.querySelector('[data-scope="tree-view"][data-part="branch-control"]');c&&this.spreadProps(c,this.api.getBranchControlProps(l));let u=i.querySelector('[data-scope="tree-view"][data-part="branch-text"]');u&&this.spreadProps(u,this.api.getBranchTextProps(l));let h=i.querySelector('[data-scope="tree-view"][data-part="branch-indicator"]');h&&this.spreadProps(h,this.api.getBranchIndicatorProps(l));let p=i.querySelector('[data-scope="tree-view"][data-part="branch-content"]');p&&this.spreadProps(p,this.api.getBranchContentProps(l));let d=i.querySelector('[data-scope="tree-view"][data-part="branch-indent-guide"]');d&&this.spreadProps(d,this.api.getBranchIndentGuideProps(l))}let r=t.querySelectorAll('[data-scope="tree-view"][data-part="item"]');for(let i of r){let s=i.getAttribute("data-path");if(s==null)continue;let o=s.split("/").map(c=>parseInt(c,10)),a=this.getNodeAt(o);if(!a)continue;let l={indexPath:o,node:a};this.spreadProps(i,this.api.getItemProps(l))}}render(){var r;let t=(r=this.el.querySelector('[data-scope="tree-view"][data-part="root"]'))!=null?r:this.el;this.spreadProps(t,this.api.getRootProps());let n=this.el.querySelector('[data-scope="tree-view"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps()),this.syncTree()}},vI={mounted(){var r;let e=this.el,t=this.pushEvent.bind(this),n=new mI(e,y(m({id:e.id},O(e,"controlled")?{expandedValue:Y(e,"expandedValue"),selectedValue:Y(e,"selectedValue")}:{defaultExpandedValue:Y(e,"defaultExpandedValue"),defaultSelectedValue:Y(e,"defaultSelectedValue")}),{selectionMode:(r=x(e,"selectionMode",["single","multiple"]))!=null?r:"single",dir:Gt(e),onSelectionChange:i=>{var d;let s=O(e,"redirect"),o=(d=i.selectedValue)!=null&&d.length?i.selectedValue[0]:void 0,a=[...e.querySelectorAll('[data-scope="tree-view"][data-part="item"], [data-scope="tree-view"][data-part="branch"]')].find(g=>g.getAttribute("data-value")===o),l=(a==null?void 0:a.getAttribute("data-part"))==="item",c=a==null?void 0:a.getAttribute("data-redirect"),u=a==null?void 0:a.hasAttribute("data-new-tab");s&&o&&l&&this.liveSocket.main.isDead&&c!=="false"&&(u?window.open(o,"_blank","noopener,noreferrer"):window.location.href=o);let p=x(e,"onSelectionChange");p&&this.liveSocket.main.isConnected()&&t(p,{id:e.id,value:y(m({},i),{isItem:l!=null?l:!1})})},onExpandedChange:i=>{let s=x(e,"onExpandedChange");s&&this.liveSocket.main.isConnected()&&t(s,{id:e.id,value:i})}}));n.init(),this.treeView=n,this.onSetExpandedValue=i=>{let{value:s}=i.detail;n.api.setExpandedValue(s)},e.addEventListener("phx:tree-view:set-expanded-value",this.onSetExpandedValue),this.onSetSelectedValue=i=>{let{value:s}=i.detail;n.api.setSelectedValue(s)},e.addEventListener("phx:tree-view:set-selected-value",this.onSetSelectedValue),this.handlers=[],this.handlers.push(this.handleEvent("tree_view_set_expanded_value",i=>{let s=i.tree_view_id;s&&e.id!==s&&e.id!==`tree-view:${s}`||n.api.setExpandedValue(i.value)})),this.handlers.push(this.handleEvent("tree_view_set_selected_value",i=>{let s=i.tree_view_id;s&&e.id!==s&&e.id!==`tree-view:${s}`||n.api.setSelectedValue(i.value)})),this.handlers.push(this.handleEvent("tree_view_expanded_value",()=>{t("tree_view_expanded_value_response",{value:n.api.expandedValue})})),this.handlers.push(this.handleEvent("tree_view_selected_value",()=>{t("tree_view_selected_value_response",{value:n.api.selectedValue})}))},updated(){var e;O(this.el,"controlled")&&((e=this.treeView)==null||e.updateProps({expandedValue:Y(this.el,"expandedValue"),selectedValue:Y(this.el,"selectedValue")}))},destroyed(){var e;if(this.onSetExpandedValue&&this.el.removeEventListener("phx:tree-view:set-expanded-value",this.onSetExpandedValue),this.onSetSelectedValue&&this.el.removeEventListener("phx:tree-view:set-selected-value",this.onSetSelectedValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.treeView)==null||e.destroy()}}});var bI={};Oe(bI,{Hooks:()=>Qd,default:()=>yI,hooks:()=>Pe});function Pe(e,t){return{mounted(){return Ee(this,null,function*(){let i=(yield e())[t];if(this._realHook=i,i!=null&&i.mounted)return i.mounted.call(this)})},updated(){var r,i;(i=(r=this._realHook)==null?void 0:r.updated)==null||i.call(this)},destroyed(){var r,i;(i=(r=this._realHook)==null?void 0:r.destroyed)==null||i.call(this)},disconnected(){var r,i;(i=(r=this._realHook)==null?void 0:r.disconnected)==null||i.call(this)},reconnected(){var r,i;(i=(r=this._realHook)==null?void 0:r.reconnected)==null||i.call(this)},beforeUpdate(){var r,i;(i=(r=this._realHook)==null?void 0:r.beforeUpdate)==null||i.call(this)}}}var Qd={Accordion:Pe(()=>Promise.resolve().then(()=>(yl(),vl)),"Accordion"),Checkbox:Pe(()=>Promise.resolve().then(()=>(Pl(),Sl)),"Checkbox"),Clipboard:Pe(()=>Promise.resolve().then(()=>(Vl(),wl)),"Clipboard"),Collapsible:Pe(()=>Promise.resolve().then(()=>(kl(),xl)),"Collapsible"),Combobox:Pe(()=>Promise.resolve().then(()=>(Vc(),wc)),"Combobox"),DatePicker:Pe(()=>Promise.resolve().then(()=>(Pu(),Su)),"DatePicker"),Dialog:Pe(()=>Promise.resolve().then(()=>(Fu(),Lu)),"Dialog"),Menu:Pe(()=>Promise.resolve().then(()=>(Ku(),Wu)),"Menu"),Select:Pe(()=>Promise.resolve().then(()=>(Qu(),zu)),"Select"),SignaturePad:Pe(()=>Promise.resolve().then(()=>(Ed(),bd)),"SignaturePad"),Switch:Pe(()=>Promise.resolve().then(()=>(Sd(),Od)),"Switch"),Tabs:Pe(()=>Promise.resolve().then(()=>(kd(),xd)),"Tabs"),Toast:Pe(()=>Promise.resolve().then(()=>(Hd(),_d)),"Toast"),ToggleGroup:Pe(()=>Promise.resolve().then(()=>(Kd(),Wd)),"ToggleGroup"),TreeView:Pe(()=>Promise.resolve().then(()=>(zd(),Jd)),"TreeView")};var yI=Qd;return hh(bI);})(); diff --git a/priv/static/corex.mjs.map b/priv/static/corex.mjs.map index c4624ba..3258117 100644 --- a/priv/static/corex.mjs.map +++ b/priv/static/corex.mjs.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../assets/hooks/corex.ts"], - "sourcesContent": ["import type { Hook } from \"phoenix_live_view\";\n\ntype HookModule = Record | undefined>;\n\nfunction hooks(\n importFn: () => Promise,\n exportName: string\n): Hook {\n return {\n async mounted() {\n const mod = await importFn();\n const real = mod[exportName];\n (this as { _realHook?: Hook })._realHook = real;\n if (real?.mounted) return real.mounted.call(this);\n },\n updated() {\n (this as { _realHook?: Hook })._realHook?.updated?.call(this);\n },\n destroyed() {\n (this as { _realHook?: Hook })._realHook?.destroyed?.call(this);\n },\n disconnected() {\n (this as { _realHook?: Hook })._realHook?.disconnected?.call(this);\n },\n reconnected() {\n (this as { _realHook?: Hook })._realHook?.reconnected?.call(this);\n },\n beforeUpdate() {\n (this as { _realHook?: Hook })._realHook?.beforeUpdate?.call(this);\n },\n };\n}\n\nexport const Hooks = {\n Accordion: hooks(() => import(\"corex/accordion\"), \"Accordion\"),\n Checkbox: hooks(() => import(\"corex/checkbox\"), \"Checkbox\"),\n Clipboard: hooks(() => import(\"corex/clipboard\"), \"Clipboard\"),\n Collapsible: hooks(() => import(\"corex/collapsible\"), \"Collapsible\"),\n Combobox: hooks(() => import(\"corex/combobox\"), \"Combobox\"),\n DatePicker: hooks(() => import(\"corex/date-picker\"), \"DatePicker\"),\n Dialog: hooks(() => import(\"corex/dialog\"), \"Dialog\"),\n Menu: hooks(() => import(\"corex/menu\"), \"Menu\"),\n Select: hooks(() => import(\"corex/select\"), \"Select\"),\n SignaturePad: hooks(() => import(\"corex/signature-pad\"), \"SignaturePad\"),\n Switch: hooks(() => import(\"corex/switch\"), \"Switch\"),\n Tabs: hooks(() => import(\"corex/tabs\"), \"Tabs\"),\n Toast: hooks(() => import(\"corex/toast\"), \"Toast\"),\n ToggleGroup: hooks(() => import(\"corex/toggle-group\"), \"ToggleGroup\"),\n TreeView: hooks(() => import(\"corex/tree-view\"), \"TreeView\"),\n};\n\nexport { hooks };\n\nexport default Hooks;\n"], - "mappings": ";AAIA,SAAS,MACP,UACA,YACM;AACN,SAAO;AAAA,IACL,MAAM,UAAU;AACd,YAAM,MAAM,MAAM,SAAS;AAC3B,YAAM,OAAO,IAAI,UAAU;AAC3B,MAAC,KAA8B,YAAY;AAC3C,UAAI,MAAM,QAAS,QAAO,KAAK,QAAQ,KAAK,IAAI;AAAA,IAClD;AAAA,IACA,UAAU;AACR,MAAC,KAA8B,WAAW,SAAS,KAAK,IAAI;AAAA,IAC9D;AAAA,IACA,YAAY;AACV,MAAC,KAA8B,WAAW,WAAW,KAAK,IAAI;AAAA,IAChE;AAAA,IACA,eAAe;AACb,MAAC,KAA8B,WAAW,cAAc,KAAK,IAAI;AAAA,IACnE;AAAA,IACA,cAAc;AACZ,MAAC,KAA8B,WAAW,aAAa,KAAK,IAAI;AAAA,IAClE;AAAA,IACA,eAAe;AACb,MAAC,KAA8B,WAAW,cAAc,KAAK,IAAI;AAAA,IACnE;AAAA,EACF;AACF;AAEO,IAAM,QAAQ;AAAA,EACnB,WAAW,MAAM,MAAM,OAAO,iBAAiB,GAAG,WAAW;AAAA,EAC7D,UAAU,MAAM,MAAM,OAAO,gBAAgB,GAAG,UAAU;AAAA,EAC1D,WAAW,MAAM,MAAM,OAAO,iBAAiB,GAAG,WAAW;AAAA,EAC7D,aAAa,MAAM,MAAM,OAAO,mBAAmB,GAAG,aAAa;AAAA,EACnE,UAAU,MAAM,MAAM,OAAO,gBAAgB,GAAG,UAAU;AAAA,EAC1D,YAAY,MAAM,MAAM,OAAO,mBAAmB,GAAG,YAAY;AAAA,EACjE,QAAQ,MAAM,MAAM,OAAO,cAAc,GAAG,QAAQ;AAAA,EACpD,MAAM,MAAM,MAAM,OAAO,YAAY,GAAG,MAAM;AAAA,EAC9C,QAAQ,MAAM,MAAM,OAAO,cAAc,GAAG,QAAQ;AAAA,EACpD,cAAc,MAAM,MAAM,OAAO,qBAAqB,GAAG,cAAc;AAAA,EACvE,QAAQ,MAAM,MAAM,OAAO,cAAc,GAAG,QAAQ;AAAA,EACpD,MAAM,MAAM,MAAM,OAAO,YAAY,GAAG,MAAM;AAAA,EAC9C,OAAO,MAAM,MAAM,OAAO,aAAa,GAAG,OAAO;AAAA,EACjD,aAAa,MAAM,MAAM,OAAO,oBAAoB,GAAG,aAAa;AAAA,EACpE,UAAU,MAAM,MAAM,OAAO,iBAAiB,GAAG,UAAU;AAC7D;AAIA,IAAO,gBAAQ;", + "sourcesContent": ["import type { Hook } from \"phoenix_live_view\";\n\ntype HookModule = Record | undefined>;\n\nfunction hooks(importFn: () => Promise, exportName: string): Hook {\n return {\n async mounted() {\n const mod = await importFn();\n const real = mod[exportName];\n (this as { _realHook?: Hook })._realHook = real;\n if (real?.mounted) return real.mounted.call(this);\n },\n updated() {\n (this as { _realHook?: Hook })._realHook?.updated?.call(this);\n },\n destroyed() {\n (this as { _realHook?: Hook })._realHook?.destroyed?.call(this);\n },\n disconnected() {\n (this as { _realHook?: Hook })._realHook?.disconnected?.call(this);\n },\n reconnected() {\n (this as { _realHook?: Hook })._realHook?.reconnected?.call(this);\n },\n beforeUpdate() {\n (this as { _realHook?: Hook })._realHook?.beforeUpdate?.call(this);\n },\n };\n}\n\nexport const Hooks = {\n Accordion: hooks(() => import(\"corex/accordion\"), \"Accordion\"),\n Checkbox: hooks(() => import(\"corex/checkbox\"), \"Checkbox\"),\n Clipboard: hooks(() => import(\"corex/clipboard\"), \"Clipboard\"),\n Collapsible: hooks(() => import(\"corex/collapsible\"), \"Collapsible\"),\n Combobox: hooks(() => import(\"corex/combobox\"), \"Combobox\"),\n DatePicker: hooks(() => import(\"corex/date-picker\"), \"DatePicker\"),\n Dialog: hooks(() => import(\"corex/dialog\"), \"Dialog\"),\n Menu: hooks(() => import(\"corex/menu\"), \"Menu\"),\n Select: hooks(() => import(\"corex/select\"), \"Select\"),\n SignaturePad: hooks(() => import(\"corex/signature-pad\"), \"SignaturePad\"),\n Switch: hooks(() => import(\"corex/switch\"), \"Switch\"),\n Tabs: hooks(() => import(\"corex/tabs\"), \"Tabs\"),\n Toast: hooks(() => import(\"corex/toast\"), \"Toast\"),\n ToggleGroup: hooks(() => import(\"corex/toggle-group\"), \"ToggleGroup\"),\n TreeView: hooks(() => import(\"corex/tree-view\"), \"TreeView\"),\n};\n\nexport { hooks };\n\nexport default Hooks;\n"], + "mappings": ";AAIA,SAAS,MAAM,UAAqC,YAA0B;AAC5E,SAAO;AAAA,IACL,MAAM,UAAU;AACd,YAAM,MAAM,MAAM,SAAS;AAC3B,YAAM,OAAO,IAAI,UAAU;AAC3B,MAAC,KAA8B,YAAY;AAC3C,UAAI,MAAM,QAAS,QAAO,KAAK,QAAQ,KAAK,IAAI;AAAA,IAClD;AAAA,IACA,UAAU;AACR,MAAC,KAA8B,WAAW,SAAS,KAAK,IAAI;AAAA,IAC9D;AAAA,IACA,YAAY;AACV,MAAC,KAA8B,WAAW,WAAW,KAAK,IAAI;AAAA,IAChE;AAAA,IACA,eAAe;AACb,MAAC,KAA8B,WAAW,cAAc,KAAK,IAAI;AAAA,IACnE;AAAA,IACA,cAAc;AACZ,MAAC,KAA8B,WAAW,aAAa,KAAK,IAAI;AAAA,IAClE;AAAA,IACA,eAAe;AACb,MAAC,KAA8B,WAAW,cAAc,KAAK,IAAI;AAAA,IACnE;AAAA,EACF;AACF;AAEO,IAAM,QAAQ;AAAA,EACnB,WAAW,MAAM,MAAM,OAAO,iBAAiB,GAAG,WAAW;AAAA,EAC7D,UAAU,MAAM,MAAM,OAAO,gBAAgB,GAAG,UAAU;AAAA,EAC1D,WAAW,MAAM,MAAM,OAAO,iBAAiB,GAAG,WAAW;AAAA,EAC7D,aAAa,MAAM,MAAM,OAAO,mBAAmB,GAAG,aAAa;AAAA,EACnE,UAAU,MAAM,MAAM,OAAO,gBAAgB,GAAG,UAAU;AAAA,EAC1D,YAAY,MAAM,MAAM,OAAO,mBAAmB,GAAG,YAAY;AAAA,EACjE,QAAQ,MAAM,MAAM,OAAO,cAAc,GAAG,QAAQ;AAAA,EACpD,MAAM,MAAM,MAAM,OAAO,YAAY,GAAG,MAAM;AAAA,EAC9C,QAAQ,MAAM,MAAM,OAAO,cAAc,GAAG,QAAQ;AAAA,EACpD,cAAc,MAAM,MAAM,OAAO,qBAAqB,GAAG,cAAc;AAAA,EACvE,QAAQ,MAAM,MAAM,OAAO,cAAc,GAAG,QAAQ;AAAA,EACpD,MAAM,MAAM,MAAM,OAAO,YAAY,GAAG,MAAM;AAAA,EAC9C,OAAO,MAAM,MAAM,OAAO,aAAa,GAAG,OAAO;AAAA,EACjD,aAAa,MAAM,MAAM,OAAO,oBAAoB,GAAG,aAAa;AAAA,EACpE,UAAU,MAAM,MAAM,OAAO,iBAAiB,GAAG,UAAU;AAC7D;AAIA,IAAO,gBAAQ;", "names": [] } diff --git a/priv/static/date-picker.mjs b/priv/static/date-picker.mjs index a5cf25e..9bb8348 100644 --- a/priv/static/date-picker.mjs +++ b/priv/static/date-picker.mjs @@ -3906,10 +3906,9 @@ var splitViewProps = createSplitProps(viewProps); // components/date-picker.ts var DatePicker = class extends Component { + // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props2) { - return new VanillaMachine(machine, { - ...props2 - }); + return new VanillaMachine(machine, props2); } initApi() { return connect(this.machine.service, normalizeProps); @@ -3947,10 +3946,7 @@ var DatePicker = class extends Component { const td = this.doc.createElement("td"); this.spreadProps(td, this.api.getDayTableCellProps({ value })); const trigger = this.doc.createElement("div"); - this.spreadProps( - trigger, - this.api.getDayTableCellTriggerProps({ value }) - ); + this.spreadProps(trigger, this.api.getDayTableCellTriggerProps({ value })); trigger.textContent = String(value.day); td.appendChild(trigger); tr.appendChild(td); @@ -3970,15 +3966,9 @@ var DatePicker = class extends Component { this.spreadProps(tr, this.api.getTableRowProps()); months.forEach((month) => { const td = this.doc.createElement("td"); - this.spreadProps( - td, - this.api.getMonthTableCellProps({ ...month, columns: 4 }) - ); + this.spreadProps(td, this.api.getMonthTableCellProps({ ...month, columns: 4 })); const trigger = this.doc.createElement("div"); - this.spreadProps( - trigger, - this.api.getMonthTableCellTriggerProps({ ...month, columns: 4 }) - ); + this.spreadProps(trigger, this.api.getMonthTableCellTriggerProps({ ...month, columns: 4 })); trigger.textContent = month.label; td.appendChild(trigger); tr.appendChild(td); @@ -3998,15 +3988,9 @@ var DatePicker = class extends Component { this.spreadProps(tr, this.api.getTableRowProps({ view: "year" })); years.forEach((year) => { const td = this.doc.createElement("td"); - this.spreadProps( - td, - this.api.getYearTableCellProps({ ...year, columns: 4 }) - ); + this.spreadProps(td, this.api.getYearTableCellProps({ ...year, columns: 4 })); const trigger = this.doc.createElement("div"); - this.spreadProps( - trigger, - this.api.getYearTableCellTriggerProps({ ...year, columns: 4 }) - ); + this.spreadProps(trigger, this.api.getYearTableCellTriggerProps({ ...year, columns: 4 })); trigger.textContent = year.label; td.appendChild(trigger); tr.appendChild(td); @@ -4015,9 +3999,7 @@ var DatePicker = class extends Component { }); }; render() { - const root = this.el.querySelector( - '[data-scope="date-picker"][data-part="root"]' - ); + const root = this.el.querySelector('[data-scope="date-picker"][data-part="root"]'); if (root) this.spreadProps(root, this.api.getRootProps()); const label = this.el.querySelector( '[data-scope="date-picker"][data-part="label"]' @@ -4055,122 +4037,59 @@ var DatePicker = class extends Component { if (monthView) monthView.hidden = this.api.view !== "month"; if (yearView) yearView.hidden = this.api.view !== "year"; if (this.api.view === "day" && dayView) { - const viewControl = dayView.querySelector( - '[data-part="view-control"]' - ); + const viewControl = dayView.querySelector('[data-part="view-control"]'); if (viewControl) - this.spreadProps( - viewControl, - this.api.getViewControlProps({ view: "year" }) - ); - const prevTrigger = dayView.querySelector( - '[data-part="prev-trigger"]' - ); - if (prevTrigger) - this.spreadProps(prevTrigger, this.api.getPrevTriggerProps()); - const viewTrigger = dayView.querySelector( - '[data-part="view-trigger"]' - ); + this.spreadProps(viewControl, this.api.getViewControlProps({ view: "year" })); + const prevTrigger = dayView.querySelector('[data-part="prev-trigger"]'); + if (prevTrigger) this.spreadProps(prevTrigger, this.api.getPrevTriggerProps()); + const viewTrigger = dayView.querySelector('[data-part="view-trigger"]'); if (viewTrigger) { this.spreadProps(viewTrigger, this.api.getViewTriggerProps()); viewTrigger.textContent = this.api.visibleRangeText.start; } - const nextTrigger = dayView.querySelector( - '[data-part="next-trigger"]' - ); - if (nextTrigger) - this.spreadProps(nextTrigger, this.api.getNextTriggerProps()); + const nextTrigger = dayView.querySelector('[data-part="next-trigger"]'); + if (nextTrigger) this.spreadProps(nextTrigger, this.api.getNextTriggerProps()); const table = dayView.querySelector("table"); - if (table) - this.spreadProps(table, this.api.getTableProps({ view: "day" })); + if (table) this.spreadProps(table, this.api.getTableProps({ view: "day" })); const thead = dayView.querySelector("thead"); - if (thead) - this.spreadProps( - thead, - this.api.getTableHeaderProps({ view: "day" }) - ); + if (thead) this.spreadProps(thead, this.api.getTableHeaderProps({ view: "day" })); this.renderDayTableHeader(); this.renderDayTableBody(); } else if (this.api.view === "month" && monthView) { - const viewControl = monthView.querySelector( - '[data-part="view-control"]' - ); + const viewControl = monthView.querySelector('[data-part="view-control"]'); if (viewControl) - this.spreadProps( - viewControl, - this.api.getViewControlProps({ view: "month" }) - ); - const prevTrigger = monthView.querySelector( - '[data-part="prev-trigger"]' - ); + this.spreadProps(viewControl, this.api.getViewControlProps({ view: "month" })); + const prevTrigger = monthView.querySelector('[data-part="prev-trigger"]'); if (prevTrigger) - this.spreadProps( - prevTrigger, - this.api.getPrevTriggerProps({ view: "month" }) - ); - const viewTrigger = monthView.querySelector( - '[data-part="view-trigger"]' - ); + this.spreadProps(prevTrigger, this.api.getPrevTriggerProps({ view: "month" })); + const viewTrigger = monthView.querySelector('[data-part="view-trigger"]'); if (viewTrigger) { - this.spreadProps( - viewTrigger, - this.api.getViewTriggerProps({ view: "month" }) - ); + this.spreadProps(viewTrigger, this.api.getViewTriggerProps({ view: "month" })); viewTrigger.textContent = String(this.api.visibleRange.start.year); } - const nextTrigger = monthView.querySelector( - '[data-part="next-trigger"]' - ); + const nextTrigger = monthView.querySelector('[data-part="next-trigger"]'); if (nextTrigger) - this.spreadProps( - nextTrigger, - this.api.getNextTriggerProps({ view: "month" }) - ); + this.spreadProps(nextTrigger, this.api.getNextTriggerProps({ view: "month" })); const table = monthView.querySelector("table"); - if (table) - this.spreadProps( - table, - this.api.getTableProps({ view: "month", columns: 4 }) - ); + if (table) this.spreadProps(table, this.api.getTableProps({ view: "month", columns: 4 })); this.renderMonthTableBody(); } else if (this.api.view === "year" && yearView) { - const viewControl = yearView.querySelector( - '[data-part="view-control"]' - ); + const viewControl = yearView.querySelector('[data-part="view-control"]'); if (viewControl) - this.spreadProps( - viewControl, - this.api.getViewControlProps({ view: "year" }) - ); - const prevTrigger = yearView.querySelector( - '[data-part="prev-trigger"]' - ); + this.spreadProps(viewControl, this.api.getViewControlProps({ view: "year" })); + const prevTrigger = yearView.querySelector('[data-part="prev-trigger"]'); if (prevTrigger) - this.spreadProps( - prevTrigger, - this.api.getPrevTriggerProps({ view: "year" }) - ); - const decadeText = yearView.querySelector( - '[data-part="decade"]' - ); + this.spreadProps(prevTrigger, this.api.getPrevTriggerProps({ view: "year" })); + const decadeText = yearView.querySelector('[data-part="decade"]'); if (decadeText) { const decade = this.api.getDecade(); decadeText.textContent = `${decade.start} - ${decade.end}`; } - const nextTrigger = yearView.querySelector( - '[data-part="next-trigger"]' - ); + const nextTrigger = yearView.querySelector('[data-part="next-trigger"]'); if (nextTrigger) - this.spreadProps( - nextTrigger, - this.api.getNextTriggerProps({ view: "year" }) - ); + this.spreadProps(nextTrigger, this.api.getNextTriggerProps({ view: "year" })); const table = yearView.querySelector("table"); - if (table) - this.spreadProps( - table, - this.api.getTableProps({ view: "year", columns: 4 }) - ); + if (table) this.spreadProps(table, this.api.getTableProps({ view: "year", columns: 4 })); this.renderYearTableBody(); } } @@ -4211,7 +4130,11 @@ var DatePickerHook = { numOfMonths: getNumber(el, "numOfMonths"), startOfWeek: getNumber(el, "startOfWeek"), fixedWeeks: getBoolean(el, "fixedWeeks"), - selectionMode: getString(el, "selectionMode", ["single", "multiple", "range"]), + selectionMode: getString(el, "selectionMode", [ + "single", + "multiple", + "range" + ]), placeholder: getString(el, "placeholder"), minView: getString(el, "minView", ["day", "month", "year"]), maxView: getString(el, "maxView", ["day", "month", "year"]), @@ -4219,9 +4142,7 @@ var DatePickerHook = { positioning: positioningJson ? JSON.parse(positioningJson) : void 0, onValueChange: (details) => { const isoStr = details.value?.length ? details.value.map((d) => toISOString(d)).join(",") : ""; - const hiddenInput = el.querySelector( - `#${el.id}-value` - ); + const hiddenInput = el.querySelector(`#${el.id}-value`); if (hiddenInput && hiddenInput.value !== isoStr) { hiddenInput.value = isoStr; hiddenInput.dispatchEvent(new Event("input", { bubbles: true })); @@ -4281,11 +4202,14 @@ var DatePickerHook = { if (inputWrapper) inputWrapper.removeAttribute("data-loading"); this.handlers = []; this.handlers.push( - this.handleEvent("date_picker_set_value", (payload) => { - const targetId = payload.date_picker_id; - if (targetId && targetId !== el.id) return; - datePickerInstance.api.setValue([parse(payload.value)]); - }) + this.handleEvent( + "date_picker_set_value", + (payload) => { + const targetId = payload.date_picker_id; + if (targetId && targetId !== el.id) return; + datePickerInstance.api.setValue([parse(payload.value)]); + } + ) ); this.onSetValue = (event) => { const value = event.detail?.value; @@ -4325,7 +4249,11 @@ var DatePickerHook = { numOfMonths: getNumber(this.el, "numOfMonths"), startOfWeek: getNumber(this.el, "startOfWeek"), fixedWeeks: getBoolean(this.el, "fixedWeeks"), - selectionMode: getString(this.el, "selectionMode", ["single", "multiple", "range"]), + selectionMode: getString(this.el, "selectionMode", [ + "single", + "multiple", + "range" + ]), placeholder: getString(this.el, "placeholder"), minView: getString(this.el, "minView", ["day", "month", "year"]), maxView: getString(this.el, "maxView", ["day", "month", "year"]), diff --git a/priv/static/dialog.mjs b/priv/static/dialog.mjs index 794f014..bc6a8f0 100644 --- a/priv/static/dialog.mjs +++ b/priv/static/dialog.mjs @@ -1167,19 +1167,31 @@ var Dialog = class extends Component { } render() { const rootEl = this.el; - const triggerEl = rootEl.querySelector('[data-scope="dialog"][data-part="trigger"]'); + const triggerEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="trigger"]' + ); if (triggerEl) this.spreadProps(triggerEl, this.api.getTriggerProps()); - const backdropEl = rootEl.querySelector('[data-scope="dialog"][data-part="backdrop"]'); + const backdropEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="backdrop"]' + ); if (backdropEl) this.spreadProps(backdropEl, this.api.getBackdropProps()); - const positionerEl = rootEl.querySelector('[data-scope="dialog"][data-part="positioner"]'); + const positionerEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="positioner"]' + ); if (positionerEl) this.spreadProps(positionerEl, this.api.getPositionerProps()); - const contentEl = rootEl.querySelector('[data-scope="dialog"][data-part="content"]'); + const contentEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="content"]' + ); if (contentEl) this.spreadProps(contentEl, this.api.getContentProps()); const titleEl = rootEl.querySelector('[data-scope="dialog"][data-part="title"]'); if (titleEl) this.spreadProps(titleEl, this.api.getTitleProps()); - const descriptionEl = rootEl.querySelector('[data-scope="dialog"][data-part="description"]'); + const descriptionEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="description"]' + ); if (descriptionEl) this.spreadProps(descriptionEl, this.api.getDescriptionProps()); - const closeTriggerEl = rootEl.querySelector('[data-scope="dialog"][data-part="close-trigger"]'); + const closeTriggerEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="close-trigger"]' + ); if (closeTriggerEl) this.spreadProps(closeTriggerEl, this.api.getCloseTriggerProps()); } }; diff --git a/priv/static/menu.mjs b/priv/static/menu.mjs index 85d2f89..6441384 100644 --- a/priv/static/menu.mjs +++ b/priv/static/menu.mjs @@ -1493,9 +1493,7 @@ var Menu = class extends Component { if (!this.isOwnElement(triggerEl)) continue; const nestedMenuId = triggerEl.dataset.nestedMenu; if (!nestedMenuId) continue; - const childMenu = this.children.find( - (child) => child.el.id === `menu:${nestedMenuId}` - ); + const childMenu = this.children.find((child) => child.el.id === `menu:${nestedMenuId}`); if (!childMenu) continue; const applyProps = () => { const triggerProps = this.api.getTriggerItemProps(childMenu.api); @@ -1594,74 +1592,71 @@ var MenuHook = { if (el.hasAttribute("data-nested")) { return; } - const menu = new Menu( - el, - { - id: el.id.replace("menu:", ""), - ...getBoolean(el, "controlled") ? { open: getBoolean(el, "open") } : { defaultOpen: getBoolean(el, "defaultOpen") }, - closeOnSelect: getBoolean(el, "closeOnSelect"), - loopFocus: getBoolean(el, "loopFocus"), - typeahead: getBoolean(el, "typeahead"), - composite: getBoolean(el, "composite"), - dir: getString(el, "dir", ["ltr", "rtl"]), - onSelect: (details) => { - const redirect = getBoolean(el, "redirect"); - const itemEl = [...el.querySelectorAll('[data-scope="menu"][data-part="item"]')].find( - (node) => node.getAttribute("data-value") === details.value - ); - const itemRedirect = itemEl?.getAttribute("data-redirect"); - const itemNewTab = itemEl?.hasAttribute("data-new-tab"); - const doRedirect = redirect && details.value && !this.liveSocket.main.isConnected() && itemRedirect !== "false"; - if (doRedirect) { - if (itemNewTab) { - window.open(details.value, "_blank", "noopener,noreferrer"); - } else { - window.location.href = details.value; - } - } - const eventName = getString(el, "onSelect"); - if (eventName && this.liveSocket.main.isConnected()) { - this.pushEvent(eventName, { - id: el.id, - value: details.value ?? null - }); - } - const eventNameClient = getString(el, "onSelectClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: details.value ?? null - } - }) - ); - } - }, - onOpenChange: (details) => { - const eventName = getString(el, "onOpenChange"); - if (eventName && this.liveSocket.main.isConnected()) { - this.pushEvent(eventName, { - id: el.id, - open: details.open ?? false - }); - } - const eventNameClient = getString(el, "onOpenChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - open: details.open ?? false - } - }) - ); + const menu = new Menu(el, { + id: el.id.replace("menu:", ""), + ...getBoolean(el, "controlled") ? { open: getBoolean(el, "open") } : { defaultOpen: getBoolean(el, "defaultOpen") }, + closeOnSelect: getBoolean(el, "closeOnSelect"), + loopFocus: getBoolean(el, "loopFocus"), + typeahead: getBoolean(el, "typeahead"), + composite: getBoolean(el, "composite"), + dir: getString(el, "dir", ["ltr", "rtl"]), + onSelect: (details) => { + const redirect = getBoolean(el, "redirect"); + const itemEl = [ + ...el.querySelectorAll('[data-scope="menu"][data-part="item"]') + ].find((node) => node.getAttribute("data-value") === details.value); + const itemRedirect = itemEl?.getAttribute("data-redirect"); + const itemNewTab = itemEl?.hasAttribute("data-new-tab"); + const doRedirect = redirect && details.value && !this.liveSocket.main.isConnected() && itemRedirect !== "false"; + if (doRedirect) { + if (itemNewTab) { + window.open(details.value, "_blank", "noopener,noreferrer"); + } else { + window.location.href = details.value; } } + const eventName = getString(el, "onSelect"); + if (eventName && this.liveSocket.main.isConnected()) { + this.pushEvent(eventName, { + id: el.id, + value: details.value ?? null + }); + } + const eventNameClient = getString(el, "onSelectClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: details.value ?? null + } + }) + ); + } + }, + onOpenChange: (details) => { + const eventName = getString(el, "onOpenChange"); + if (eventName && this.liveSocket.main.isConnected()) { + this.pushEvent(eventName, { + id: el.id, + open: details.open ?? false + }); + } + const eventNameClient = getString(el, "onOpenChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + open: details.open ?? false + } + }) + ); + } } - ); + }); menu.init(); this.menu = menu; this.nestedMenus = /* @__PURE__ */ new Map(); diff --git a/priv/static/select.mjs b/priv/static/select.mjs index 97de93b..4cd787e 100644 --- a/priv/static/select.mjs +++ b/priv/static/select.mjs @@ -1221,7 +1221,7 @@ var Select = class extends Component { itemToValue: (item) => item.id ?? item.value ?? "", itemToString: (item) => item.label, isItemDisabled: (item) => !!item.disabled, - groupBy: (item) => item.group + groupBy: (item) => item.group ?? "" }); } return collection({ @@ -1231,12 +1231,13 @@ var Select = class extends Component { isItemDisabled: (item) => !!item.disabled }); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props2) { - const self = this; + const getCollection = this.getCollection.bind(this); return new VanillaMachine(machine, { ...props2, get collection() { - return self.getCollection(); + return getCollection(); } }); } @@ -1275,10 +1276,7 @@ var Select = class extends Component { '[data-scope="select"][data-part="item-group-label"]' ); if (labelEl) { - this.spreadProps( - labelEl, - this.api.getItemGroupLabelProps({ htmlFor: groupId }) - ); + this.spreadProps(labelEl, this.api.getItemGroupLabelProps({ htmlFor: groupId })); } const templateItems = groupEl.querySelectorAll( '[data-scope="select"][data-part="item"][data-template]' @@ -1306,9 +1304,7 @@ var Select = class extends Component { const el = template.cloneNode(true); el.removeAttribute("data-template"); this.spreadProps(el, this.api.getItemProps({ item })); - const textEl = el.querySelector( - '[data-scope="select"][data-part="item-text"]' - ); + const textEl = el.querySelector('[data-scope="select"][data-part="item-text"]'); if (textEl) { this.spreadProps(textEl, this.api.getItemTextProps({ item })); } @@ -1316,10 +1312,7 @@ var Select = class extends Component { '[data-scope="select"][data-part="item-indicator"]' ); if (indicatorEl) { - this.spreadProps( - indicatorEl, - this.api.getItemIndicatorProps({ item }) - ); + this.spreadProps(indicatorEl, this.api.getItemIndicatorProps({ item })); } return el; } @@ -1345,17 +1338,8 @@ var Select = class extends Component { if (hiddenSelect) { this.spreadProps(hiddenSelect, this.api.getHiddenSelectProps()); } - [ - "label", - "control", - "trigger", - "indicator", - "clear-trigger", - "positioner" - ].forEach((part) => { - const el = this.el.querySelector( - `[data-scope="select"][data-part="${part}"]` - ); + ["label", "control", "trigger", "indicator", "clear-trigger", "positioner"].forEach((part) => { + const el = this.el.querySelector(`[data-scope="select"][data-part="${part}"]`); if (!el) return; const method = "get" + part.split("-").map((s) => s[0].toUpperCase() + s.slice(1)).join("") + "Props"; this.spreadProps(el, this.api[method]()); @@ -1407,100 +1391,75 @@ var SelectHook = { const el = this.el; const allItems = JSON.parse(el.dataset.collection || "[]"); const hasGroups = allItems.some((item) => item.group !== void 0); - let selectComponent; - const hook = this; - this.wasFocused = false; - selectComponent = new Select( - el, - { - id: el.id, - ...getBoolean(el, "controlled") ? { value: getStringList(el, "value") } : { defaultValue: getStringList(el, "defaultValue") }, - disabled: getBoolean(el, "disabled"), - closeOnSelect: getBoolean(el, "closeOnSelect"), - dir: getString(el, "dir", ["ltr", "rtl"]), - loopFocus: getBoolean(el, "loopFocus"), - multiple: getBoolean(el, "multiple"), - invalid: getBoolean(el, "invalid"), - name: getString(el, "name"), - form: getString(el, "form"), - readOnly: getBoolean(el, "readOnly"), - required: getBoolean(el, "required"), - positioning: (() => { - const positioningJson = el.dataset.positioning; - if (positioningJson) { - try { - const parsed = JSON.parse(positioningJson); - return transformPositioningOptions(parsed); - } catch { - return void 0; - } - } - return void 0; - })(), - onValueChange: (details) => { - const redirect = getBoolean(el, "redirect"); - const firstValue = details.value.length > 0 ? String(details.value[0]) : null; - const firstItem = details.items?.length ? details.items[0] : null; - const itemRedirect = firstItem && typeof firstItem === "object" && firstItem !== null && "redirect" in firstItem ? firstItem.redirect : void 0; - const itemNewTab = firstItem && typeof firstItem === "object" && firstItem !== null && "new_tab" in firstItem ? firstItem.new_tab : void 0; - const doRedirect = redirect && firstValue && hook.liveSocket.main.isDead && itemRedirect !== false; - const openInNewTab = itemNewTab === true; - if (doRedirect) { - if (openInNewTab) { - window.open(firstValue, "_blank", "noopener,noreferrer"); - } else { - window.location.href = firstValue; - } - } - const valueInput = el.querySelector( - '[data-scope="select"][data-part="value-input"]' - ); - if (valueInput) { - valueInput.value = details.value.length === 0 ? "" : details.value.length === 1 ? String(details.value[0]) : details.value.map(String).join(","); - valueInput.dispatchEvent(new Event("input", { bubbles: true })); - valueInput.dispatchEvent(new Event("change", { bubbles: true })); - } - const payload = { - value: details.value, - items: details.items, - id: el.id - }; - const encodedJS = el.getAttribute("data-on-value-change-js"); - if (encodedJS) { - let js = encodedJS; - const indexMatches = [...js.matchAll(/__VALUE_(\d+)__/g)].map((m) => parseInt(m[1], 10)); - const uniqueIndices = [...new Set(indexMatches)].sort((a, b) => b - a); - for (const i of uniqueIndices) { - const val = details.value[i]; - const str = val !== void 0 && val !== null ? String(val) : ""; - const escaped = JSON.stringify(str).slice(1, -1); - js = js.split(`__VALUE_${i}__`).join(escaped); - } - js = js.split("__VALUE__").join(JSON.stringify(details.value)); - hook.liveSocket.execJS(el, js); - } - const clientEventName = getString(el, "onValueChangeClient"); - if (clientEventName) { - el.dispatchEvent( - new CustomEvent(clientEventName, { bubbles: true, detail: payload }) - ); + const selectComponent = new Select(el, { + id: el.id, + ...getBoolean(el, "controlled") ? { value: getStringList(el, "value") } : { defaultValue: getStringList(el, "defaultValue") }, + disabled: getBoolean(el, "disabled"), + closeOnSelect: getBoolean(el, "closeOnSelect"), + dir: getString(el, "dir", ["ltr", "rtl"]), + loopFocus: getBoolean(el, "loopFocus"), + multiple: getBoolean(el, "multiple"), + invalid: getBoolean(el, "invalid"), + name: getString(el, "name"), + form: getString(el, "form"), + readOnly: getBoolean(el, "readOnly"), + required: getBoolean(el, "required"), + positioning: (() => { + const positioningJson = el.dataset.positioning; + if (positioningJson) { + try { + const parsed = JSON.parse(positioningJson); + return transformPositioningOptions(parsed); + } catch { + return void 0; } - const serverEventName = getString(el, "onValueChange"); - if (serverEventName && !hook.liveSocket.main.isDead && hook.liveSocket.main.isConnected()) { - this.pushEvent(serverEventName, payload); + } + return void 0; + })(), + onValueChange: (details) => { + const redirect = getBoolean(el, "redirect"); + const firstValue = details.value.length > 0 ? String(details.value[0]) : null; + const firstItem = details.items?.length ? details.items[0] : null; + const itemRedirect = firstItem && typeof firstItem === "object" && firstItem !== null && "redirect" in firstItem ? firstItem.redirect : void 0; + const itemNewTab = firstItem && typeof firstItem === "object" && firstItem !== null && "new_tab" in firstItem ? firstItem.new_tab : void 0; + const doRedirect = redirect && firstValue && this.liveSocket.main.isDead && itemRedirect !== false; + const openInNewTab = itemNewTab === true; + if (doRedirect) { + if (openInNewTab) { + window.open(firstValue, "_blank", "noopener,noreferrer"); + } else { + window.location.href = firstValue; } } + const valueInput = el.querySelector( + '[data-scope="select"][data-part="value-input"]' + ); + if (valueInput) { + valueInput.value = details.value.length === 0 ? "" : details.value.length === 1 ? String(details.value[0]) : details.value.map(String).join(","); + valueInput.dispatchEvent(new Event("input", { bubbles: true })); + valueInput.dispatchEvent(new Event("change", { bubbles: true })); + } + const payload = { + value: details.value, + items: details.items, + id: el.id + }; + const clientEventName = getString(el, "onValueChangeClient"); + if (clientEventName) { + el.dispatchEvent(new CustomEvent(clientEventName, { bubbles: true, detail: payload })); + } + const serverEventName = getString(el, "onValueChange"); + if (serverEventName && !this.liveSocket.main.isDead && this.liveSocket.main.isConnected()) { + this.pushEvent(serverEventName, payload); + } } - ); + }); selectComponent.hasGroups = hasGroups; selectComponent.setOptions(allItems); selectComponent.init(); this.select = selectComponent; this.handlers = []; }, - beforeUpdate() { - this.wasFocused = this.select?.api?.focused ?? false; - }, updated() { const newCollection = JSON.parse(this.el.dataset.collection || "[]"); const hasGroups = newCollection.some((item) => item.group !== void 0); @@ -1519,14 +1478,6 @@ var SelectHook = { required: getBoolean(this.el, "required"), readOnly: getBoolean(this.el, "readOnly") }); - if (getBoolean(this.el, "controlled")) { - if (this.wasFocused) { - const trigger = this.el.querySelector('[data-scope="select"][data-part="trigger"]'); - if (trigger && document.activeElement !== trigger) { - trigger.focus(); - } - } - } } }, destroyed() { diff --git a/priv/static/signature-pad.mjs b/priv/static/signature-pad.mjs index 8484405..35537cb 100644 --- a/priv/static/signature-pad.mjs +++ b/priv/static/signature-pad.mjs @@ -525,6 +525,7 @@ var SignaturePad = class extends Component { imageURL = ""; paths = []; name; + // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props2) { this.name = props2.name; return new VanillaMachine(machine, props2); @@ -539,14 +540,18 @@ var SignaturePad = class extends Component { return connect(this.machine.service, normalizeProps); } syncPaths = () => { - const segment = this.el.querySelector('[data-scope="signature-pad"][data-part="segment"]'); + const segment = this.el.querySelector( + '[data-scope="signature-pad"][data-part="segment"]' + ); if (!segment) return; const totalPaths = this.api.paths.length + (this.api.currentPath ? 1 : 0); if (totalPaths === 0) { segment.innerHTML = ""; this.imageURL = ""; this.paths = []; - const hiddenInput = this.el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = this.el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) hiddenInput.value = ""; return; } @@ -567,24 +572,38 @@ var SignaturePad = class extends Component { } }; render() { - const rootEl = this.el.querySelector('[data-scope="signature-pad"][data-part="root"]'); + const rootEl = this.el.querySelector( + '[data-scope="signature-pad"][data-part="root"]' + ); if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const label = rootEl.querySelector('[data-scope="signature-pad"][data-part="label"]'); + const label = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="label"]' + ); if (label) this.spreadProps(label, this.api.getLabelProps()); - const control = rootEl.querySelector('[data-scope="signature-pad"][data-part="control"]'); + const control = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="control"]' + ); if (control) this.spreadProps(control, this.api.getControlProps()); - const segment = rootEl.querySelector('[data-scope="signature-pad"][data-part="segment"]'); + const segment = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="segment"]' + ); if (segment) this.spreadProps(segment, this.api.getSegmentProps()); - const guide = rootEl.querySelector('[data-scope="signature-pad"][data-part="guide"]'); + const guide = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="guide"]' + ); if (guide) this.spreadProps(guide, this.api.getGuideProps()); - const clearBtn = rootEl.querySelector('[data-scope="signature-pad"][data-part="clear-trigger"]'); + const clearBtn = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="clear-trigger"]' + ); if (clearBtn) { this.spreadProps(clearBtn, this.api.getClearTriggerProps()); const hasPaths = this.api.paths.length > 0 || !!this.api.currentPath; clearBtn.hidden = !hasPaths; } - const hiddenInput = rootEl.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { const pathsForValue = this.paths.length > 0 ? this.paths : this.api.paths; if (this.paths.length === 0 && this.api.paths.length > 0) { @@ -636,7 +655,9 @@ var SignaturePadHook = { drawing: buildDrawingOptions(el), onDrawEnd: (details) => { signaturePad.setPaths(details.paths); - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.value = JSON.stringify(details.paths); } @@ -670,7 +691,9 @@ var SignaturePadHook = { this.signaturePad = signaturePad; const initialPaths = controlled ? paths : defaultPaths; if (initialPaths.length > 0) { - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.dispatchEvent(new Event("input", { bubbles: true })); hiddenInput.dispatchEvent(new Event("change", { bubbles: true })); @@ -682,7 +705,9 @@ var SignaturePadHook = { signaturePad.api.clear(); signaturePad.imageURL = ""; signaturePad.setPaths([]); - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.value = ""; } @@ -696,7 +721,9 @@ var SignaturePadHook = { signaturePad.api.clear(); signaturePad.imageURL = ""; signaturePad.setPaths([]); - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.value = ""; } diff --git a/priv/static/switch.mjs b/priv/static/switch.mjs index d4a9aec..e1a3a3e 100644 --- a/priv/static/switch.mjs +++ b/priv/static/switch.mjs @@ -320,7 +320,9 @@ var Switch = class extends Component { const rootEl = this.el.querySelector('[data-scope="switch"][data-part="root"]'); if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const inputEl = this.el.querySelector('[data-scope="switch"][data-part="hidden-input"]'); + const inputEl = this.el.querySelector( + '[data-scope="switch"][data-part="hidden-input"]' + ); if (inputEl) { this.spreadProps(inputEl, this.api.getHiddenInputProps()); } @@ -328,7 +330,9 @@ var Switch = class extends Component { if (labelEl) { this.spreadProps(labelEl, this.api.getLabelProps()); } - const controlEl = this.el.querySelector('[data-scope="switch"][data-part="control"]'); + const controlEl = this.el.querySelector( + '[data-scope="switch"][data-part="control"]' + ); if (controlEl) { this.spreadProps(controlEl, this.api.getControlProps()); } diff --git a/priv/static/tabs.mjs b/priv/static/tabs.mjs index 5c49891..18a7a34 100644 --- a/priv/static/tabs.mjs +++ b/priv/static/tabs.mjs @@ -552,7 +552,10 @@ var Tabs = class extends Component { for (let i = 0; i < triggers.length && i < items.length; i++) { const triggerEl = triggers[i]; const item = items[i]; - this.spreadProps(triggerEl, this.api.getTriggerProps({ value: item.value, disabled: item.disabled })); + this.spreadProps( + triggerEl, + this.api.getTriggerProps({ value: item.value, disabled: item.disabled }) + ); } const contents = rootEl.querySelectorAll( '[data-scope="tabs"][data-part="content"]' @@ -570,57 +573,54 @@ var TabsHook = { mounted() { const el = this.el; const pushEvent = this.pushEvent.bind(this); - const tabs = new Tabs( - el, - { - id: el.id, - ...getBoolean(el, "controlled") ? { value: getString(el, "value") } : { defaultValue: getString(el, "defaultValue") }, - orientation: getString(el, "orientation", ["horizontal", "vertical"]), - dir: getString(el, "dir", ["ltr", "rtl"]), - onValueChange: (details) => { - const eventName = getString(el, "onValueChange"); - if (eventName && this.liveSocket.main.isConnected()) { - pushEvent(eventName, { - id: el.id, - value: details.value ?? null - }); - } - const eventNameClient = getString(el, "onValueChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: details.value ?? null - } - }) - ); - } - }, - onFocusChange: (details) => { - const eventName = getString(el, "onFocusChange"); - if (eventName && this.liveSocket.main.isConnected()) { - pushEvent(eventName, { - id: el.id, - value: details.focusedValue ?? null - }); - } - const eventNameClient = getString(el, "onFocusChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: details.focusedValue ?? null - } - }) - ); - } + const tabs = new Tabs(el, { + id: el.id, + ...getBoolean(el, "controlled") ? { value: getString(el, "value") } : { defaultValue: getString(el, "defaultValue") }, + orientation: getString(el, "orientation", ["horizontal", "vertical"]), + dir: getString(el, "dir", ["ltr", "rtl"]), + onValueChange: (details) => { + const eventName = getString(el, "onValueChange"); + if (eventName && this.liveSocket.main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: details.value ?? null + }); + } + const eventNameClient = getString(el, "onValueChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: details.value ?? null + } + }) + ); + } + }, + onFocusChange: (details) => { + const eventName = getString(el, "onFocusChange"); + if (eventName && this.liveSocket.main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: details.focusedValue ?? null + }); + } + const eventNameClient = getString(el, "onFocusChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: details.focusedValue ?? null + } + }) + ); } } - ); + }); tabs.init(); this.tabs = tabs; this.onSetValue = (event) => { @@ -630,14 +630,11 @@ var TabsHook = { el.addEventListener("phx:tabs:set-value", this.onSetValue); this.handlers = []; this.handlers.push( - this.handleEvent( - "tabs_set_value", - (payload) => { - const targetId = payload.tabs_id; - if (targetId && targetId !== el.id) return; - tabs.api.setValue(payload.value); - } - ) + this.handleEvent("tabs_set_value", (payload) => { + const targetId = payload.tabs_id; + if (targetId && targetId !== el.id) return; + tabs.api.setValue(payload.value); + }) ); this.handlers.push( this.handleEvent("tabs_value", () => { diff --git a/priv/static/toast.mjs b/priv/static/toast.mjs index 4bafe06..72384fb 100644 --- a/priv/static/toast.mjs +++ b/priv/static/toast.mjs @@ -1161,7 +1161,9 @@ var ToastItem = class extends Component { const duration = this.duration; const isInfinity = duration === "Infinity" || duration === Infinity || duration === Number.POSITIVE_INFINITY; const toastGroup = this.el.closest('[phx-hook="Toast"]'); - const loadingIconTemplate = toastGroup?.querySelector("[data-loading-icon-template]"); + const loadingIconTemplate = toastGroup?.querySelector( + "[data-loading-icon-template]" + ); const loadingIcon = loadingIconTemplate?.innerHTML; if (isInfinity) { this.parts.progressbar.style.display = "none"; diff --git a/priv/static/toggle-group.mjs b/priv/static/toggle-group.mjs index e847223..0cd2b96 100644 --- a/priv/static/toggle-group.mjs +++ b/priv/static/toggle-group.mjs @@ -368,10 +368,14 @@ var ToggleGroup = class extends Component { return connect(this.machine.service, normalizeProps); } render() { - const rootEl = this.el.querySelector('[data-scope="toggle-group"][data-part="root"]'); + const rootEl = this.el.querySelector( + '[data-scope="toggle-group"][data-part="root"]' + ); if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const items = this.el.querySelectorAll('[data-scope="toggle-group"][data-part="item"]'); + const items = this.el.querySelectorAll( + '[data-scope="toggle-group"][data-part="item"]' + ); for (let i = 0; i < items.length; i++) { const itemEl = items[i]; const value = getString(itemEl, "value"); @@ -430,14 +434,11 @@ var ToggleGroupHook = { el.addEventListener("phx:toggle-group:set-value", this.onSetValue); this.handlers = []; this.handlers.push( - this.handleEvent( - "toggle-group_set_value", - (payload) => { - const targetId = payload.id; - if (targetId && targetId !== el.id) return; - toggleGroup.api.setValue(payload.value); - } - ) + this.handleEvent("toggle-group_set_value", (payload) => { + const targetId = payload.id; + if (targetId && targetId !== el.id) return; + toggleGroup.api.setValue(payload.value); + }) ); this.handlers.push( this.handleEvent("toggle-group:value", () => { diff --git a/priv/static/tree-view.mjs b/priv/static/tree-view.mjs index 33aa970..d2b3d7f 100644 --- a/priv/static/tree-view.mjs +++ b/priv/static/tree-view.mjs @@ -1340,17 +1340,18 @@ function buildTreeFromDOM(rootEl) { return root; } var TreeView = class extends Component { - collection; + treeCollection; constructor(el, props2) { const treeData = props2.treeData ?? buildTreeFromDOM(el); - const collection2 = collection({ + const treeCollection = collection({ nodeToValue: (node) => node.id, nodeToString: (node) => node.name, rootNode: treeData }); - super(el, { ...props2, collection: collection2 }); - this.collection = collection2; + super(el, { ...props2, collection: treeCollection }); + this.treeCollection = treeCollection; } + // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props2) { return new VanillaMachine(machine, { ...props2 }); } @@ -1359,7 +1360,7 @@ var TreeView = class extends Component { } getNodeAt(indexPath) { if (indexPath.length === 0) return void 0; - let current = this.collection.rootNode; + let current = this.treeCollection.rootNode; for (const i of indexPath) { current = current?.children?.[i]; if (!current) return void 0; @@ -1390,8 +1391,7 @@ var TreeView = class extends Component { const indicatorEl = branchEl.querySelector( '[data-scope="tree-view"][data-part="branch-indicator"]' ); - if (indicatorEl) - this.spreadProps(indicatorEl, this.api.getBranchIndicatorProps(nodeProps)); + if (indicatorEl) this.spreadProps(indicatorEl, this.api.getBranchIndicatorProps(nodeProps)); const contentEl = branchEl.querySelector( '[data-scope="tree-view"][data-part="branch-content"]' ); @@ -1416,21 +1416,15 @@ var TreeView = class extends Component { } } syncTree = () => { - const treeEl = this.el.querySelector( - '[data-scope="tree-view"][data-part="tree"]' - ); + const treeEl = this.el.querySelector('[data-scope="tree-view"][data-part="tree"]'); if (!treeEl) return; this.spreadProps(treeEl, this.api.getTreeProps()); this.updateExistingTree(treeEl); }; render() { - const rootEl = this.el.querySelector( - '[data-scope="tree-view"][data-part="root"]' - ) ?? this.el; + const rootEl = this.el.querySelector('[data-scope="tree-view"][data-part="root"]') ?? this.el; this.spreadProps(rootEl, this.api.getRootProps()); - const label = this.el.querySelector( - '[data-scope="tree-view"][data-part="label"]' - ); + const label = this.el.querySelector('[data-scope="tree-view"][data-part="label"]'); if (label) this.spreadProps(label, this.api.getLabelProps()); this.syncTree(); } From ea261d904ec123c664326e0efdf14f4aeceb8e21 Mon Sep 17 00:00:00 2001 From: karimsemmoud Date: Sat, 14 Feb 2026 13:06:24 +0700 Subject: [PATCH 2/9] format --- assets/components/tree-view.ts | 13 +- assets/hooks/combobox.ts | 4 +- assets/hooks/select.ts | 6 +- priv/static/corex.js | 993 ++++++++++++++++----------------- priv/static/corex.min.js | 4 +- 5 files changed, 496 insertions(+), 524 deletions(-) diff --git a/assets/components/tree-view.ts b/assets/components/tree-view.ts index 28f2a6c..f2eef70 100644 --- a/assets/components/tree-view.ts +++ b/assets/components/tree-view.ts @@ -1,10 +1,4 @@ -import { - collection, - connect, - machine, - type Props, - type Api, -} from "@zag-js/tree-view"; +import { collection, connect, machine, type Props, type Api } from "@zag-js/tree-view"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; @@ -61,10 +55,7 @@ function buildTreeFromDOM(rootEl: HTMLElement): TreeNode { export class TreeView extends Component { private treeCollection: ReturnType>; - constructor( - el: HTMLElement | null, - props: Omit & { treeData?: TreeNode } - ) { + constructor(el: HTMLElement | null, props: Omit & { treeData?: TreeNode }) { const treeData = props.treeData ?? buildTreeFromDOM(el as HTMLElement); const treeCollection = collection({ nodeToValue: (node) => node.id, diff --git a/assets/hooks/combobox.ts b/assets/hooks/combobox.ts index 3464d7c..8501cc1 100644 --- a/assets/hooks/combobox.ts +++ b/assets/hooks/combobox.ts @@ -210,8 +210,8 @@ const ComboboxHook: Hook = { : getStringList(el, "defaultValue"); if (initialValue && initialValue.length > 0) { - const selectedItems = allItems.filter( - (item: { id?: string }) => initialValue.includes(item.id ?? "") + const selectedItems = allItems.filter((item: { id?: string }) => + initialValue.includes(item.id ?? "") ); if (selectedItems.length > 0) { const inputValue = selectedItems diff --git a/assets/hooks/select.ts b/assets/hooks/select.ts index cf31f41..5338938 100644 --- a/assets/hooks/select.ts +++ b/assets/hooks/select.ts @@ -109,11 +109,7 @@ const SelectHook: Hook = { } const serverEventName = getString(el, "onValueChange"); - if ( - serverEventName && - !this.liveSocket.main.isDead && - this.liveSocket.main.isConnected() - ) { + if (serverEventName && !this.liveSocket.main.isDead && this.liveSocket.main.isConnected()) { this.pushEvent(serverEventName, payload); } }, diff --git a/priv/static/corex.js b/priv/static/corex.js index 9ccc098..b2d25b5 100644 --- a/priv/static/corex.js +++ b/priv/static/corex.js @@ -2852,15 +2852,21 @@ var Corex = (() => { if (!(itemData == null ? void 0 : itemData.value)) continue; const { value, disabled } = itemData; this.spreadProps(itemEl, this.api.getItemProps({ value, disabled })); - const triggerEl = itemEl.querySelector('[data-scope="accordion"][data-part="item-trigger"]'); + const triggerEl = itemEl.querySelector( + '[data-scope="accordion"][data-part="item-trigger"]' + ); if (triggerEl) { this.spreadProps(triggerEl, this.api.getItemTriggerProps({ value, disabled })); } - const indicatorEl = itemEl.querySelector('[data-scope="accordion"][data-part="item-indicator"]'); + const indicatorEl = itemEl.querySelector( + '[data-scope="accordion"][data-part="item-indicator"]' + ); if (indicatorEl) { this.spreadProps(indicatorEl, this.api.getItemIndicatorProps({ value, disabled })); } - const contentEl = itemEl.querySelector('[data-scope="accordion"][data-part="item-content"]'); + const contentEl = itemEl.querySelector( + '[data-scope="accordion"][data-part="item-content"]' + ); if (contentEl) { this.spreadProps(contentEl, this.api.getItemContentProps({ value, disabled })); } @@ -2880,61 +2886,58 @@ var Corex = (() => { mounted() { const el = this.el; const pushEvent = this.pushEvent.bind(this); - const accordion = new Accordion( - el, - __spreadProps(__spreadValues({ - id: el.id - }, getBoolean(el, "controlled") ? { value: getStringList(el, "value") } : { defaultValue: getStringList(el, "defaultValue") }), { - collapsible: getBoolean(el, "collapsible"), - multiple: getBoolean(el, "multiple"), - orientation: getString(el, "orientation", ["horizontal", "vertical"]), - dir: getDir(el), - onValueChange: (details) => { - var _a, _b; - const eventName = getString(el, "onValueChange"); - if (eventName && this.liveSocket.main.isConnected()) { - pushEvent(eventName, { - id: el.id, - value: (_a = details.value) != null ? _a : null - }); - } - const eventNameClient = getString(el, "onValueChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: (_b = details.value) != null ? _b : null - } - }) - ); - } - }, - onFocusChange: (details) => { - var _a, _b; - const eventName = getString(el, "onFocusChange"); - if (eventName && this.liveSocket.main.isConnected()) { - pushEvent(eventName, { - id: el.id, - value: (_a = details.value) != null ? _a : null - }); - } - const eventNameClient = getString(el, "onFocusChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: (_b = details.value) != null ? _b : null - } - }) - ); - } + const accordion = new Accordion(el, __spreadProps(__spreadValues({ + id: el.id + }, getBoolean(el, "controlled") ? { value: getStringList(el, "value") } : { defaultValue: getStringList(el, "defaultValue") }), { + collapsible: getBoolean(el, "collapsible"), + multiple: getBoolean(el, "multiple"), + orientation: getString(el, "orientation", ["horizontal", "vertical"]), + dir: getDir(el), + onValueChange: (details) => { + var _a, _b; + const eventName = getString(el, "onValueChange"); + if (eventName && this.liveSocket.main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: (_a = details.value) != null ? _a : null + }); } - }) - ); + const eventNameClient = getString(el, "onValueChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: (_b = details.value) != null ? _b : null + } + }) + ); + } + }, + onFocusChange: (details) => { + var _a, _b; + const eventName = getString(el, "onFocusChange"); + if (eventName && this.liveSocket.main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: (_a = details.value) != null ? _a : null + }); + } + const eventNameClient = getString(el, "onFocusChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: (_b = details.value) != null ? _b : null + } + }) + ); + } + } + })); accordion.init(); this.accordion = accordion; this.onSetValue = (event) => { @@ -3467,18 +3470,26 @@ var Corex = (() => { const rootEl = this.el.querySelector('[data-scope="checkbox"][data-part="root"]'); if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const inputEl = rootEl.querySelector(':scope > [data-scope="checkbox"][data-part="hidden-input"]'); + const inputEl = rootEl.querySelector( + ':scope > [data-scope="checkbox"][data-part="hidden-input"]' + ); if (inputEl) { this.spreadProps(inputEl, this.api.getHiddenInputProps()); } - const labelEl = rootEl.querySelector(':scope > [data-scope="checkbox"][data-part="label"]'); + const labelEl = rootEl.querySelector( + ':scope > [data-scope="checkbox"][data-part="label"]' + ); if (labelEl) { this.spreadProps(labelEl, this.api.getLabelProps()); } - const controlEl = rootEl.querySelector(':scope > [data-scope="checkbox"][data-part="control"]'); + const controlEl = rootEl.querySelector( + ':scope > [data-scope="checkbox"][data-part="control"]' + ); if (controlEl) { this.spreadProps(controlEl, this.api.getControlProps()); - const indicatorEl = controlEl.querySelector(':scope > [data-scope="checkbox"][data-part="indicator"]'); + const indicatorEl = controlEl.querySelector( + ':scope > [data-scope="checkbox"][data-part="indicator"]' + ); if (indicatorEl) { this.spreadProps(indicatorEl, this.api.getIndicatorProps()); } @@ -3847,14 +3858,20 @@ var Corex = (() => { const rootEl = this.el.querySelector('[data-scope="clipboard"][data-part="root"]'); if (rootEl) { this.spreadProps(rootEl, this.api.getRootProps()); - const labelEl = rootEl.querySelector('[data-scope="clipboard"][data-part="label"]'); + const labelEl = rootEl.querySelector( + '[data-scope="clipboard"][data-part="label"]' + ); if (labelEl) { this.spreadProps(labelEl, this.api.getLabelProps()); } - const controlEl = rootEl.querySelector('[data-scope="clipboard"][data-part="control"]'); + const controlEl = rootEl.querySelector( + '[data-scope="clipboard"][data-part="control"]' + ); if (controlEl) { this.spreadProps(controlEl, this.api.getControlProps()); - const inputEl = controlEl.querySelector('[data-scope="clipboard"][data-part="input"]'); + const inputEl = controlEl.querySelector( + '[data-scope="clipboard"][data-part="input"]' + ); if (inputEl) { const inputProps2 = __spreadValues({}, this.api.getInputProps()); const inputAriaLabel = this.el.dataset.inputAriaLabel; @@ -3863,7 +3880,9 @@ var Corex = (() => { } this.spreadProps(inputEl, inputProps2); } - const triggerEl = controlEl.querySelector('[data-scope="clipboard"][data-part="trigger"]'); + const triggerEl = controlEl.querySelector( + '[data-scope="clipboard"][data-part="trigger"]' + ); if (triggerEl) { const triggerProps2 = __spreadValues({}, this.api.getTriggerProps()); const ariaLabel = this.el.dataset.triggerAriaLabel; @@ -3933,11 +3952,14 @@ var Corex = (() => { }) ); this.handlers.push( - this.handleEvent("clipboard_set_value", (payload) => { - const targetId = payload.clipboard_id; - if (targetId && targetId !== el.id) return; - clipboard.api.setValue(payload.value); - }) + this.handleEvent( + "clipboard_set_value", + (payload) => { + const targetId = payload.clipboard_id; + if (targetId && targetId !== el.id) return; + clipboard.api.setValue(payload.value); + } + ) ); this.handlers.push( this.handleEvent("clipboard_copied", () => { @@ -4355,14 +4377,20 @@ var Corex = (() => { return connect4(this.machine.service, normalizeProps); } render() { - const rootEl = this.el.querySelector('[data-scope="collapsible"][data-part="root"]'); + const rootEl = this.el.querySelector( + '[data-scope="collapsible"][data-part="root"]' + ); if (rootEl) { this.spreadProps(rootEl, this.api.getRootProps()); - const triggerEl = rootEl.querySelector('[data-scope="collapsible"][data-part="trigger"]'); + const triggerEl = rootEl.querySelector( + '[data-scope="collapsible"][data-part="trigger"]' + ); if (triggerEl) { this.spreadProps(triggerEl, this.api.getTriggerProps()); } - const contentEl = rootEl.querySelector('[data-scope="collapsible"][data-part="content"]'); + const contentEl = rootEl.querySelector( + '[data-scope="collapsible"][data-part="content"]' + ); if (contentEl) { this.spreadProps(contentEl, this.api.getContentProps()); } @@ -4409,11 +4437,14 @@ var Corex = (() => { el.addEventListener("phx:collapsible:set-open", this.onSetOpen); this.handlers = []; this.handlers.push( - this.handleEvent("collapsible_set_open", (payload) => { - const targetId = payload.collapsible_id; - if (targetId && targetId !== el.id) return; - collapsible.api.setOpen(payload.open); - }) + this.handleEvent( + "collapsible_set_open", + (payload) => { + const targetId = payload.collapsible_id; + if (targetId && targetId !== el.id) return; + collapsible.api.setOpen(payload.open); + } + ) ); this.handlers.push( this.handleEvent("collapsible_open", () => { @@ -9617,38 +9648,51 @@ var Corex = (() => { if (this.hasGroups) { return collection({ items, - itemToValue: (item) => item.id, + itemToValue: (item) => { + var _a; + return (_a = item.id) != null ? _a : ""; + }, itemToString: (item) => item.label, - isItemDisabled: (item) => item.disabled, + isItemDisabled: (item) => { + var _a; + return (_a = item.disabled) != null ? _a : false; + }, groupBy: (item) => item.group }); } return collection({ items, - itemToValue: (item) => item.id, + itemToValue: (item) => { + var _a; + return (_a = item.id) != null ? _a : ""; + }, itemToString: (item) => item.label, - isItemDisabled: (item) => item.disabled + isItemDisabled: (item) => { + var _a; + return (_a = item.disabled) != null ? _a : false; + } }); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props22) { - const self2 = this; + const getCollection = this.getCollection.bind(this); return new VanillaMachine(machine5, __spreadProps(__spreadValues({}, props22), { get collection() { - return self2.getCollection(); + return getCollection(); }, onOpenChange: (details) => { if (details.open) { - self2.options = self2.allOptions; + this.options = this.allOptions; } if (props22.onOpenChange) { props22.onOpenChange(details); } }, onInputValueChange: (details) => { - const filtered = self2.allOptions.filter( + const filtered = this.allOptions.filter( (item) => item.label.toLowerCase().includes(details.inputValue.toLowerCase()) ); - self2.options = filtered.length > 0 ? filtered : self2.allOptions; + this.options = filtered.length > 0 ? filtered : this.allOptions; if (props22.onInputValueChange) { props22.onInputValueChange(details); } @@ -9660,7 +9704,9 @@ var Corex = (() => { } renderItems() { var _a, _b, _c; - const contentEl = this.el.querySelector('[data-scope="combobox"][data-part="content"]'); + const contentEl = this.el.querySelector( + '[data-scope="combobox"][data-part="content"]' + ); if (!contentEl) return; const templatesContainer = this.el.querySelector('[data-templates="combobox"]'); if (!templatesContainer) return; @@ -9689,10 +9735,7 @@ var Corex = (() => { '[data-scope="combobox"][data-part="item-group-label"]' ); if (labelEl) { - this.spreadProps( - labelEl, - this.api.getItemGroupLabelProps({ htmlFor: groupId }) - ); + this.spreadProps(labelEl, this.api.getItemGroupLabelProps({ htmlFor: groupId })); } const groupContentEl = groupEl.querySelector( '[data-scope="combobox"][data-part="item-group-content"]' @@ -9728,12 +9771,11 @@ var Corex = (() => { textEl.textContent = item.label || ""; } } - const indicatorEl = el.querySelector('[data-scope="combobox"][data-part="item-indicator"]'); + const indicatorEl = el.querySelector( + '[data-scope="combobox"][data-part="item-indicator"]' + ); if (indicatorEl) { - this.spreadProps( - indicatorEl, - this.api.getItemIndicatorProps({ item }) - ); + this.spreadProps(indicatorEl, this.api.getItemIndicatorProps({ item })); } return el; } @@ -9741,20 +9783,15 @@ var Corex = (() => { const root = this.el.querySelector('[data-scope="combobox"][data-part="root"]'); if (!root) return; this.spreadProps(root, this.api.getRootProps()); - [ - "label", - "control", - "input", - "trigger", - "clear-trigger", - "positioner" - ].forEach((part) => { + ["label", "control", "input", "trigger", "clear-trigger", "positioner"].forEach((part) => { const el = this.el.querySelector(`[data-scope="combobox"][data-part="${part}"]`); if (!el) return; const apiMethod = "get" + part.split("-").map((s2) => s2[0].toUpperCase() + s2.slice(1)).join("") + "Props"; this.spreadProps(el, this.api[apiMethod]()); }); - const contentEl = this.el.querySelector('[data-scope="combobox"][data-part="content"]'); + const contentEl = this.el.querySelector( + '[data-scope="combobox"][data-part="content"]' + ); if (contentEl) { this.spreadProps(contentEl, this.api.getContentProps()); this.renderItems(); @@ -9919,10 +9956,16 @@ var Corex = (() => { const initialValue = getBoolean(el, "controlled") ? getStringList(el, "value") : getStringList(el, "defaultValue"); if (initialValue && initialValue.length > 0) { const selectedItems = allItems.filter( - (item) => initialValue.includes(item.id) + (item) => { + var _a; + return initialValue.includes((_a = item.id) != null ? _a : ""); + } ); if (selectedItems.length > 0) { - const inputValue = selectedItems.map((item) => item.label).join(", "); + const inputValue = selectedItems.map((item) => { + var _a; + return (_a = item.label) != null ? _a : ""; + }).join(", "); if (combobox.api && typeof combobox.api.setInputValue === "function") { combobox.api.setInputValue(inputValue); } else { @@ -13911,10 +13954,7 @@ var Corex = (() => { const td = this.doc.createElement("td"); this.spreadProps(td, this.api.getDayTableCellProps({ value })); const trigger = this.doc.createElement("div"); - this.spreadProps( - trigger, - this.api.getDayTableCellTriggerProps({ value }) - ); + this.spreadProps(trigger, this.api.getDayTableCellTriggerProps({ value })); trigger.textContent = String(value.day); td.appendChild(trigger); tr.appendChild(td); @@ -13934,15 +13974,9 @@ var Corex = (() => { this.spreadProps(tr, this.api.getTableRowProps()); months.forEach((month) => { const td = this.doc.createElement("td"); - this.spreadProps( - td, - this.api.getMonthTableCellProps(__spreadProps(__spreadValues({}, month), { columns: 4 })) - ); + this.spreadProps(td, this.api.getMonthTableCellProps(__spreadProps(__spreadValues({}, month), { columns: 4 }))); const trigger = this.doc.createElement("div"); - this.spreadProps( - trigger, - this.api.getMonthTableCellTriggerProps(__spreadProps(__spreadValues({}, month), { columns: 4 })) - ); + this.spreadProps(trigger, this.api.getMonthTableCellTriggerProps(__spreadProps(__spreadValues({}, month), { columns: 4 }))); trigger.textContent = month.label; td.appendChild(trigger); tr.appendChild(td); @@ -13962,15 +13996,9 @@ var Corex = (() => { this.spreadProps(tr, this.api.getTableRowProps({ view: "year" })); years.forEach((year) => { const td = this.doc.createElement("td"); - this.spreadProps( - td, - this.api.getYearTableCellProps(__spreadProps(__spreadValues({}, year), { columns: 4 })) - ); + this.spreadProps(td, this.api.getYearTableCellProps(__spreadProps(__spreadValues({}, year), { columns: 4 }))); const trigger = this.doc.createElement("div"); - this.spreadProps( - trigger, - this.api.getYearTableCellTriggerProps(__spreadProps(__spreadValues({}, year), { columns: 4 })) - ); + this.spreadProps(trigger, this.api.getYearTableCellTriggerProps(__spreadProps(__spreadValues({}, year), { columns: 4 }))); trigger.textContent = year.label; td.appendChild(trigger); tr.appendChild(td); @@ -13979,16 +14007,15 @@ var Corex = (() => { }); }); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props22) { - return new VanillaMachine(machine6, __spreadValues({}, props22)); + return new VanillaMachine(machine6, props22); } initApi() { return connect6(this.machine.service, normalizeProps); } render() { - const root = this.el.querySelector( - '[data-scope="date-picker"][data-part="root"]' - ); + const root = this.el.querySelector('[data-scope="date-picker"][data-part="root"]'); if (root) this.spreadProps(root, this.api.getRootProps()); const label = this.el.querySelector( '[data-scope="date-picker"][data-part="label"]' @@ -14026,122 +14053,59 @@ var Corex = (() => { if (monthView) monthView.hidden = this.api.view !== "month"; if (yearView) yearView.hidden = this.api.view !== "year"; if (this.api.view === "day" && dayView) { - const viewControl = dayView.querySelector( - '[data-part="view-control"]' - ); + const viewControl = dayView.querySelector('[data-part="view-control"]'); if (viewControl) - this.spreadProps( - viewControl, - this.api.getViewControlProps({ view: "year" }) - ); - const prevTrigger = dayView.querySelector( - '[data-part="prev-trigger"]' - ); - if (prevTrigger) - this.spreadProps(prevTrigger, this.api.getPrevTriggerProps()); - const viewTrigger = dayView.querySelector( - '[data-part="view-trigger"]' - ); + this.spreadProps(viewControl, this.api.getViewControlProps({ view: "year" })); + const prevTrigger = dayView.querySelector('[data-part="prev-trigger"]'); + if (prevTrigger) this.spreadProps(prevTrigger, this.api.getPrevTriggerProps()); + const viewTrigger = dayView.querySelector('[data-part="view-trigger"]'); if (viewTrigger) { this.spreadProps(viewTrigger, this.api.getViewTriggerProps()); viewTrigger.textContent = this.api.visibleRangeText.start; } - const nextTrigger = dayView.querySelector( - '[data-part="next-trigger"]' - ); - if (nextTrigger) - this.spreadProps(nextTrigger, this.api.getNextTriggerProps()); + const nextTrigger = dayView.querySelector('[data-part="next-trigger"]'); + if (nextTrigger) this.spreadProps(nextTrigger, this.api.getNextTriggerProps()); const table = dayView.querySelector("table"); - if (table) - this.spreadProps(table, this.api.getTableProps({ view: "day" })); + if (table) this.spreadProps(table, this.api.getTableProps({ view: "day" })); const thead = dayView.querySelector("thead"); - if (thead) - this.spreadProps( - thead, - this.api.getTableHeaderProps({ view: "day" }) - ); + if (thead) this.spreadProps(thead, this.api.getTableHeaderProps({ view: "day" })); this.renderDayTableHeader(); this.renderDayTableBody(); } else if (this.api.view === "month" && monthView) { - const viewControl = monthView.querySelector( - '[data-part="view-control"]' - ); + const viewControl = monthView.querySelector('[data-part="view-control"]'); if (viewControl) - this.spreadProps( - viewControl, - this.api.getViewControlProps({ view: "month" }) - ); - const prevTrigger = monthView.querySelector( - '[data-part="prev-trigger"]' - ); + this.spreadProps(viewControl, this.api.getViewControlProps({ view: "month" })); + const prevTrigger = monthView.querySelector('[data-part="prev-trigger"]'); if (prevTrigger) - this.spreadProps( - prevTrigger, - this.api.getPrevTriggerProps({ view: "month" }) - ); - const viewTrigger = monthView.querySelector( - '[data-part="view-trigger"]' - ); + this.spreadProps(prevTrigger, this.api.getPrevTriggerProps({ view: "month" })); + const viewTrigger = monthView.querySelector('[data-part="view-trigger"]'); if (viewTrigger) { - this.spreadProps( - viewTrigger, - this.api.getViewTriggerProps({ view: "month" }) - ); + this.spreadProps(viewTrigger, this.api.getViewTriggerProps({ view: "month" })); viewTrigger.textContent = String(this.api.visibleRange.start.year); } - const nextTrigger = monthView.querySelector( - '[data-part="next-trigger"]' - ); + const nextTrigger = monthView.querySelector('[data-part="next-trigger"]'); if (nextTrigger) - this.spreadProps( - nextTrigger, - this.api.getNextTriggerProps({ view: "month" }) - ); + this.spreadProps(nextTrigger, this.api.getNextTriggerProps({ view: "month" })); const table = monthView.querySelector("table"); - if (table) - this.spreadProps( - table, - this.api.getTableProps({ view: "month", columns: 4 }) - ); + if (table) this.spreadProps(table, this.api.getTableProps({ view: "month", columns: 4 })); this.renderMonthTableBody(); } else if (this.api.view === "year" && yearView) { - const viewControl = yearView.querySelector( - '[data-part="view-control"]' - ); + const viewControl = yearView.querySelector('[data-part="view-control"]'); if (viewControl) - this.spreadProps( - viewControl, - this.api.getViewControlProps({ view: "year" }) - ); - const prevTrigger = yearView.querySelector( - '[data-part="prev-trigger"]' - ); + this.spreadProps(viewControl, this.api.getViewControlProps({ view: "year" })); + const prevTrigger = yearView.querySelector('[data-part="prev-trigger"]'); if (prevTrigger) - this.spreadProps( - prevTrigger, - this.api.getPrevTriggerProps({ view: "year" }) - ); - const decadeText = yearView.querySelector( - '[data-part="decade"]' - ); + this.spreadProps(prevTrigger, this.api.getPrevTriggerProps({ view: "year" })); + const decadeText = yearView.querySelector('[data-part="decade"]'); if (decadeText) { const decade = this.api.getDecade(); decadeText.textContent = `${decade.start} - ${decade.end}`; } - const nextTrigger = yearView.querySelector( - '[data-part="next-trigger"]' - ); + const nextTrigger = yearView.querySelector('[data-part="next-trigger"]'); if (nextTrigger) - this.spreadProps( - nextTrigger, - this.api.getNextTriggerProps({ view: "year" }) - ); + this.spreadProps(nextTrigger, this.api.getNextTriggerProps({ view: "year" })); const table = yearView.querySelector("table"); - if (table) - this.spreadProps( - table, - this.api.getTableProps({ view: "year", columns: 4 }) - ); + if (table) this.spreadProps(table, this.api.getTableProps({ view: "year", columns: 4 })); this.renderYearTableBody(); } } @@ -14176,7 +14140,11 @@ var Corex = (() => { numOfMonths: getNumber(el, "numOfMonths"), startOfWeek: getNumber(el, "startOfWeek"), fixedWeeks: getBoolean(el, "fixedWeeks"), - selectionMode: getString(el, "selectionMode", ["single", "multiple", "range"]), + selectionMode: getString(el, "selectionMode", [ + "single", + "multiple", + "range" + ]), placeholder: getString(el, "placeholder"), minView: getString(el, "minView", ["day", "month", "year"]), maxView: getString(el, "maxView", ["day", "month", "year"]), @@ -14185,9 +14153,7 @@ var Corex = (() => { onValueChange: (details) => { var _a; const isoStr = ((_a = details.value) == null ? void 0 : _a.length) ? details.value.map((d2) => toISOString(d2)).join(",") : ""; - const hiddenInput = el.querySelector( - `#${el.id}-value` - ); + const hiddenInput = el.querySelector(`#${el.id}-value`); if (hiddenInput && hiddenInput.value !== isoStr) { hiddenInput.value = isoStr; hiddenInput.dispatchEvent(new Event("input", { bubbles: true })); @@ -14248,11 +14214,14 @@ var Corex = (() => { if (inputWrapper) inputWrapper.removeAttribute("data-loading"); this.handlers = []; this.handlers.push( - this.handleEvent("date_picker_set_value", (payload) => { - const targetId = payload.date_picker_id; - if (targetId && targetId !== el.id) return; - datePickerInstance.api.setValue([parse(payload.value)]); - }) + this.handleEvent( + "date_picker_set_value", + (payload) => { + const targetId = payload.date_picker_id; + if (targetId && targetId !== el.id) return; + datePickerInstance.api.setValue([parse(payload.value)]); + } + ) ); this.onSetValue = (event) => { var _a; @@ -14293,7 +14262,11 @@ var Corex = (() => { numOfMonths: getNumber(this.el, "numOfMonths"), startOfWeek: getNumber(this.el, "startOfWeek"), fixedWeeks: getBoolean(this.el, "fixedWeeks"), - selectionMode: getString(this.el, "selectionMode", ["single", "multiple", "range"]), + selectionMode: getString(this.el, "selectionMode", [ + "single", + "multiple", + "range" + ]), placeholder: getString(this.el, "placeholder"), minView: getString(this.el, "minView", ["day", "month", "year"]), maxView: getString(this.el, "maxView", ["day", "month", "year"]), @@ -15485,19 +15458,31 @@ var Corex = (() => { } render() { const rootEl = this.el; - const triggerEl = rootEl.querySelector('[data-scope="dialog"][data-part="trigger"]'); + const triggerEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="trigger"]' + ); if (triggerEl) this.spreadProps(triggerEl, this.api.getTriggerProps()); - const backdropEl = rootEl.querySelector('[data-scope="dialog"][data-part="backdrop"]'); + const backdropEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="backdrop"]' + ); if (backdropEl) this.spreadProps(backdropEl, this.api.getBackdropProps()); - const positionerEl = rootEl.querySelector('[data-scope="dialog"][data-part="positioner"]'); + const positionerEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="positioner"]' + ); if (positionerEl) this.spreadProps(positionerEl, this.api.getPositionerProps()); - const contentEl = rootEl.querySelector('[data-scope="dialog"][data-part="content"]'); + const contentEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="content"]' + ); if (contentEl) this.spreadProps(contentEl, this.api.getContentProps()); const titleEl = rootEl.querySelector('[data-scope="dialog"][data-part="title"]'); if (titleEl) this.spreadProps(titleEl, this.api.getTitleProps()); - const descriptionEl = rootEl.querySelector('[data-scope="dialog"][data-part="description"]'); + const descriptionEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="description"]' + ); if (descriptionEl) this.spreadProps(descriptionEl, this.api.getDescriptionProps()); - const closeTriggerEl = rootEl.querySelector('[data-scope="dialog"][data-part="close-trigger"]'); + const closeTriggerEl = rootEl.querySelector( + '[data-scope="dialog"][data-part="close-trigger"]' + ); if (closeTriggerEl) this.spreadProps(closeTriggerEl, this.api.getCloseTriggerProps()); } }; @@ -17081,9 +17066,7 @@ var Corex = (() => { if (!this.isOwnElement(triggerEl)) continue; const nestedMenuId = triggerEl.dataset.nestedMenu; if (!nestedMenuId) continue; - const childMenu = this.children.find( - (child) => child.el.id === `menu:${nestedMenuId}` - ); + const childMenu = this.children.find((child) => child.el.id === `menu:${nestedMenuId}`); if (!childMenu) continue; const applyProps = () => { const triggerProps2 = this.api.getTriggerItemProps(childMenu.api); @@ -17180,76 +17163,73 @@ var Corex = (() => { if (el.hasAttribute("data-nested")) { return; } - const menu = new Menu( - el, - __spreadProps(__spreadValues({ - id: el.id.replace("menu:", "") - }, getBoolean(el, "controlled") ? { open: getBoolean(el, "open") } : { defaultOpen: getBoolean(el, "defaultOpen") }), { - closeOnSelect: getBoolean(el, "closeOnSelect"), - loopFocus: getBoolean(el, "loopFocus"), - typeahead: getBoolean(el, "typeahead"), - composite: getBoolean(el, "composite"), - dir: getString(el, "dir", ["ltr", "rtl"]), - onSelect: (details) => { - var _a, _b; - const redirect = getBoolean(el, "redirect"); - const itemEl = [...el.querySelectorAll('[data-scope="menu"][data-part="item"]')].find( - (node) => node.getAttribute("data-value") === details.value - ); - const itemRedirect = itemEl == null ? void 0 : itemEl.getAttribute("data-redirect"); - const itemNewTab = itemEl == null ? void 0 : itemEl.hasAttribute("data-new-tab"); - const doRedirect = redirect && details.value && !this.liveSocket.main.isConnected() && itemRedirect !== "false"; - if (doRedirect) { - if (itemNewTab) { - window.open(details.value, "_blank", "noopener,noreferrer"); - } else { - window.location.href = details.value; - } - } - const eventName = getString(el, "onSelect"); - if (eventName && this.liveSocket.main.isConnected()) { - this.pushEvent(eventName, { - id: el.id, - value: (_a = details.value) != null ? _a : null - }); - } - const eventNameClient = getString(el, "onSelectClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: (_b = details.value) != null ? _b : null - } - }) - ); - } - }, - onOpenChange: (details) => { - var _a, _b; - const eventName = getString(el, "onOpenChange"); - if (eventName && this.liveSocket.main.isConnected()) { - this.pushEvent(eventName, { - id: el.id, - open: (_a = details.open) != null ? _a : false - }); - } - const eventNameClient = getString(el, "onOpenChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - open: (_b = details.open) != null ? _b : false - } - }) - ); + const menu = new Menu(el, __spreadProps(__spreadValues({ + id: el.id.replace("menu:", "") + }, getBoolean(el, "controlled") ? { open: getBoolean(el, "open") } : { defaultOpen: getBoolean(el, "defaultOpen") }), { + closeOnSelect: getBoolean(el, "closeOnSelect"), + loopFocus: getBoolean(el, "loopFocus"), + typeahead: getBoolean(el, "typeahead"), + composite: getBoolean(el, "composite"), + dir: getString(el, "dir", ["ltr", "rtl"]), + onSelect: (details) => { + var _a, _b; + const redirect = getBoolean(el, "redirect"); + const itemEl = [ + ...el.querySelectorAll('[data-scope="menu"][data-part="item"]') + ].find((node) => node.getAttribute("data-value") === details.value); + const itemRedirect = itemEl == null ? void 0 : itemEl.getAttribute("data-redirect"); + const itemNewTab = itemEl == null ? void 0 : itemEl.hasAttribute("data-new-tab"); + const doRedirect = redirect && details.value && !this.liveSocket.main.isConnected() && itemRedirect !== "false"; + if (doRedirect) { + if (itemNewTab) { + window.open(details.value, "_blank", "noopener,noreferrer"); + } else { + window.location.href = details.value; } } - }) - ); + const eventName = getString(el, "onSelect"); + if (eventName && this.liveSocket.main.isConnected()) { + this.pushEvent(eventName, { + id: el.id, + value: (_a = details.value) != null ? _a : null + }); + } + const eventNameClient = getString(el, "onSelectClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: (_b = details.value) != null ? _b : null + } + }) + ); + } + }, + onOpenChange: (details) => { + var _a, _b; + const eventName = getString(el, "onOpenChange"); + if (eventName && this.liveSocket.main.isConnected()) { + this.pushEvent(eventName, { + id: el.id, + open: (_a = details.open) != null ? _a : false + }); + } + const eventNameClient = getString(el, "onOpenChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + open: (_b = details.open) != null ? _b : false + } + }) + ); + } + } + })); menu.init(); this.menu = menu; this.nestedMenus = /* @__PURE__ */ new Map(); @@ -18606,7 +18586,10 @@ var Corex = (() => { }, itemToString: (item) => item.label, isItemDisabled: (item) => !!item.disabled, - groupBy: (item) => item.group + groupBy: (item) => { + var _a; + return (_a = item.group) != null ? _a : ""; + } }); } return collection2({ @@ -18619,11 +18602,12 @@ var Corex = (() => { isItemDisabled: (item) => !!item.disabled }); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props22) { - const self2 = this; + const getCollection = this.getCollection.bind(this); return new VanillaMachine(machine9, __spreadProps(__spreadValues({}, props22), { get collection() { - return self2.getCollection(); + return getCollection(); } })); } @@ -18663,10 +18647,7 @@ var Corex = (() => { '[data-scope="select"][data-part="item-group-label"]' ); if (labelEl) { - this.spreadProps( - labelEl, - this.api.getItemGroupLabelProps({ htmlFor: groupId }) - ); + this.spreadProps(labelEl, this.api.getItemGroupLabelProps({ htmlFor: groupId })); } const templateItems = groupEl.querySelectorAll( '[data-scope="select"][data-part="item"][data-template]' @@ -18694,9 +18675,7 @@ var Corex = (() => { const el = template.cloneNode(true); el.removeAttribute("data-template"); this.spreadProps(el, this.api.getItemProps({ item })); - const textEl = el.querySelector( - '[data-scope="select"][data-part="item-text"]' - ); + const textEl = el.querySelector('[data-scope="select"][data-part="item-text"]'); if (textEl) { this.spreadProps(textEl, this.api.getItemTextProps({ item })); } @@ -18704,10 +18683,7 @@ var Corex = (() => { '[data-scope="select"][data-part="item-indicator"]' ); if (indicatorEl) { - this.spreadProps( - indicatorEl, - this.api.getItemIndicatorProps({ item }) - ); + this.spreadProps(indicatorEl, this.api.getItemIndicatorProps({ item })); } return el; } @@ -18733,17 +18709,8 @@ var Corex = (() => { if (hiddenSelect) { this.spreadProps(hiddenSelect, this.api.getHiddenSelectProps()); } - [ - "label", - "control", - "trigger", - "indicator", - "clear-trigger", - "positioner" - ].forEach((part) => { - const el = this.el.querySelector( - `[data-scope="select"][data-part="${part}"]` - ); + ["label", "control", "trigger", "indicator", "clear-trigger", "positioner"].forEach((part) => { + const el = this.el.querySelector(`[data-scope="select"][data-part="${part}"]`); if (!el) return; const method = "get" + part.split("-").map((s2) => s2[0].toUpperCase() + s2.slice(1)).join("") + "Props"; this.spreadProps(el, this.api[method]()); @@ -18783,77 +18750,70 @@ var Corex = (() => { const el = this.el; const allItems = JSON.parse(el.dataset.collection || "[]"); const hasGroups = allItems.some((item) => item.group !== void 0); - let selectComponent; - const hook = this; - selectComponent = new Select( - el, - __spreadProps(__spreadValues({ - id: el.id - }, getBoolean(el, "controlled") ? { value: getStringList(el, "value") } : { defaultValue: getStringList(el, "defaultValue") }), { - disabled: getBoolean(el, "disabled"), - closeOnSelect: getBoolean(el, "closeOnSelect"), - dir: getString(el, "dir", ["ltr", "rtl"]), - loopFocus: getBoolean(el, "loopFocus"), - multiple: getBoolean(el, "multiple"), - invalid: getBoolean(el, "invalid"), - name: getString(el, "name"), - form: getString(el, "form"), - readOnly: getBoolean(el, "readOnly"), - required: getBoolean(el, "required"), - positioning: (() => { - const positioningJson = el.dataset.positioning; - if (positioningJson) { - try { - const parsed = JSON.parse(positioningJson); - return transformPositioningOptions2(parsed); - } catch (e2) { - return void 0; - } - } - return void 0; - })(), - onValueChange: (details) => { - var _a; - const redirect = getBoolean(el, "redirect"); - const firstValue = details.value.length > 0 ? String(details.value[0]) : null; - const firstItem = ((_a = details.items) == null ? void 0 : _a.length) ? details.items[0] : null; - const itemRedirect = firstItem && typeof firstItem === "object" && firstItem !== null && "redirect" in firstItem ? firstItem.redirect : void 0; - const itemNewTab = firstItem && typeof firstItem === "object" && firstItem !== null && "new_tab" in firstItem ? firstItem.new_tab : void 0; - const doRedirect = redirect && firstValue && hook.liveSocket.main.isDead && itemRedirect !== false; - const openInNewTab = itemNewTab === true; - if (doRedirect) { - if (openInNewTab) { - window.open(firstValue, "_blank", "noopener,noreferrer"); - } else { - window.location.href = firstValue; - } - } - const valueInput = el.querySelector( - '[data-scope="select"][data-part="value-input"]' - ); - if (valueInput) { - valueInput.value = details.value.length === 0 ? "" : details.value.length === 1 ? String(details.value[0]) : details.value.map(String).join(","); - valueInput.dispatchEvent(new Event("input", { bubbles: true })); - valueInput.dispatchEvent(new Event("change", { bubbles: true })); - } - const payload = { - value: details.value, - items: details.items, - id: el.id - }; - const clientEventName = getString(el, "onValueChangeClient"); - if (clientEventName) { - el.dispatchEvent( - new CustomEvent(clientEventName, { bubbles: true, detail: payload }) - ); + const selectComponent = new Select(el, __spreadProps(__spreadValues({ + id: el.id + }, getBoolean(el, "controlled") ? { value: getStringList(el, "value") } : { defaultValue: getStringList(el, "defaultValue") }), { + disabled: getBoolean(el, "disabled"), + closeOnSelect: getBoolean(el, "closeOnSelect"), + dir: getString(el, "dir", ["ltr", "rtl"]), + loopFocus: getBoolean(el, "loopFocus"), + multiple: getBoolean(el, "multiple"), + invalid: getBoolean(el, "invalid"), + name: getString(el, "name"), + form: getString(el, "form"), + readOnly: getBoolean(el, "readOnly"), + required: getBoolean(el, "required"), + positioning: (() => { + const positioningJson = el.dataset.positioning; + if (positioningJson) { + try { + const parsed = JSON.parse(positioningJson); + return transformPositioningOptions2(parsed); + } catch (e2) { + return void 0; } - const serverEventName = getString(el, "onValueChange"); - if (serverEventName && !hook.liveSocket.main.isDead && hook.liveSocket.main.isConnected()) { - this.pushEvent(serverEventName, payload); + } + return void 0; + })(), + onValueChange: (details) => { + var _a; + const redirect = getBoolean(el, "redirect"); + const firstValue = details.value.length > 0 ? String(details.value[0]) : null; + const firstItem = ((_a = details.items) == null ? void 0 : _a.length) ? details.items[0] : null; + const itemRedirect = firstItem && typeof firstItem === "object" && firstItem !== null && "redirect" in firstItem ? firstItem.redirect : void 0; + const itemNewTab = firstItem && typeof firstItem === "object" && firstItem !== null && "new_tab" in firstItem ? firstItem.new_tab : void 0; + const doRedirect = redirect && firstValue && this.liveSocket.main.isDead && itemRedirect !== false; + const openInNewTab = itemNewTab === true; + if (doRedirect) { + if (openInNewTab) { + window.open(firstValue, "_blank", "noopener,noreferrer"); + } else { + window.location.href = firstValue; } } - }) - ); + const valueInput = el.querySelector( + '[data-scope="select"][data-part="value-input"]' + ); + if (valueInput) { + valueInput.value = details.value.length === 0 ? "" : details.value.length === 1 ? String(details.value[0]) : details.value.map(String).join(","); + valueInput.dispatchEvent(new Event("input", { bubbles: true })); + valueInput.dispatchEvent(new Event("change", { bubbles: true })); + } + const payload = { + value: details.value, + items: details.items, + id: el.id + }; + const clientEventName = getString(el, "onValueChangeClient"); + if (clientEventName) { + el.dispatchEvent(new CustomEvent(clientEventName, { bubbles: true, detail: payload })); + } + const serverEventName = getString(el, "onValueChange"); + if (serverEventName && !this.liveSocket.main.isDead && this.liveSocket.main.isConnected()) { + this.pushEvent(serverEventName, payload); + } + } + })); selectComponent.hasGroups = hasGroups; selectComponent.setOptions(allItems); selectComponent.init(); @@ -19435,14 +19395,18 @@ var Corex = (() => { __publicField(this, "paths", []); __publicField(this, "name"); __publicField(this, "syncPaths", () => { - const segment = this.el.querySelector('[data-scope="signature-pad"][data-part="segment"]'); + const segment = this.el.querySelector( + '[data-scope="signature-pad"][data-part="segment"]' + ); if (!segment) return; const totalPaths = this.api.paths.length + (this.api.currentPath ? 1 : 0); if (totalPaths === 0) { segment.innerHTML = ""; this.imageURL = ""; this.paths = []; - const hiddenInput = this.el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = this.el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) hiddenInput.value = ""; return; } @@ -19463,6 +19427,7 @@ var Corex = (() => { } }); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props22) { this.name = props22.name; return new VanillaMachine(machine10, props22); @@ -19477,24 +19442,38 @@ var Corex = (() => { return connect10(this.machine.service, normalizeProps); } render() { - const rootEl = this.el.querySelector('[data-scope="signature-pad"][data-part="root"]'); + const rootEl = this.el.querySelector( + '[data-scope="signature-pad"][data-part="root"]' + ); if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const label = rootEl.querySelector('[data-scope="signature-pad"][data-part="label"]'); + const label = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="label"]' + ); if (label) this.spreadProps(label, this.api.getLabelProps()); - const control = rootEl.querySelector('[data-scope="signature-pad"][data-part="control"]'); + const control = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="control"]' + ); if (control) this.spreadProps(control, this.api.getControlProps()); - const segment = rootEl.querySelector('[data-scope="signature-pad"][data-part="segment"]'); + const segment = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="segment"]' + ); if (segment) this.spreadProps(segment, this.api.getSegmentProps()); - const guide = rootEl.querySelector('[data-scope="signature-pad"][data-part="guide"]'); + const guide = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="guide"]' + ); if (guide) this.spreadProps(guide, this.api.getGuideProps()); - const clearBtn = rootEl.querySelector('[data-scope="signature-pad"][data-part="clear-trigger"]'); + const clearBtn = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="clear-trigger"]' + ); if (clearBtn) { this.spreadProps(clearBtn, this.api.getClearTriggerProps()); const hasPaths = this.api.paths.length > 0 || !!this.api.currentPath; clearBtn.hidden = !hasPaths; } - const hiddenInput = rootEl.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = rootEl.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { const pathsForValue = this.paths.length > 0 ? this.paths : this.api.paths; if (this.paths.length === 0 && this.api.paths.length > 0) { @@ -19524,7 +19503,9 @@ var Corex = (() => { drawing: buildDrawingOptions(el), onDrawEnd: (details) => { signaturePad.setPaths(details.paths); - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.value = JSON.stringify(details.paths); } @@ -19558,7 +19539,9 @@ var Corex = (() => { this.signaturePad = signaturePad; const initialPaths = controlled ? paths : defaultPaths; if (initialPaths.length > 0) { - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.dispatchEvent(new Event("input", { bubbles: true })); hiddenInput.dispatchEvent(new Event("change", { bubbles: true })); @@ -19570,7 +19553,9 @@ var Corex = (() => { signaturePad.api.clear(); signaturePad.imageURL = ""; signaturePad.setPaths([]); - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.value = ""; } @@ -19584,7 +19569,9 @@ var Corex = (() => { signaturePad.api.clear(); signaturePad.imageURL = ""; signaturePad.setPaths([]); - const hiddenInput = el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]'); + const hiddenInput = el.querySelector( + '[data-scope="signature-pad"][data-part="hidden-input"]' + ); if (hiddenInput) { hiddenInput.value = ""; } @@ -19936,7 +19923,9 @@ var Corex = (() => { const rootEl = this.el.querySelector('[data-scope="switch"][data-part="root"]'); if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const inputEl = this.el.querySelector('[data-scope="switch"][data-part="hidden-input"]'); + const inputEl = this.el.querySelector( + '[data-scope="switch"][data-part="hidden-input"]' + ); if (inputEl) { this.spreadProps(inputEl, this.api.getHiddenInputProps()); } @@ -19944,7 +19933,9 @@ var Corex = (() => { if (labelEl) { this.spreadProps(labelEl, this.api.getLabelProps()); } - const controlEl = this.el.querySelector('[data-scope="switch"][data-part="control"]'); + const controlEl = this.el.querySelector( + '[data-scope="switch"][data-part="control"]' + ); if (controlEl) { this.spreadProps(controlEl, this.api.getControlProps()); } @@ -20629,7 +20620,10 @@ var Corex = (() => { for (let i2 = 0; i2 < triggers.length && i2 < items.length; i2++) { const triggerEl = triggers[i2]; const item = items[i2]; - this.spreadProps(triggerEl, this.api.getTriggerProps({ value: item.value, disabled: item.disabled })); + this.spreadProps( + triggerEl, + this.api.getTriggerProps({ value: item.value, disabled: item.disabled }) + ); } const contents = rootEl.querySelectorAll( '[data-scope="tabs"][data-part="content"]' @@ -20645,59 +20639,56 @@ var Corex = (() => { mounted() { const el = this.el; const pushEvent = this.pushEvent.bind(this); - const tabs = new Tabs( - el, - __spreadProps(__spreadValues({ - id: el.id - }, getBoolean(el, "controlled") ? { value: getString(el, "value") } : { defaultValue: getString(el, "defaultValue") }), { - orientation: getString(el, "orientation", ["horizontal", "vertical"]), - dir: getString(el, "dir", ["ltr", "rtl"]), - onValueChange: (details) => { - var _a, _b; - const eventName = getString(el, "onValueChange"); - if (eventName && this.liveSocket.main.isConnected()) { - pushEvent(eventName, { - id: el.id, - value: (_a = details.value) != null ? _a : null - }); - } - const eventNameClient = getString(el, "onValueChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: (_b = details.value) != null ? _b : null - } - }) - ); - } - }, - onFocusChange: (details) => { - var _a, _b; - const eventName = getString(el, "onFocusChange"); - if (eventName && this.liveSocket.main.isConnected()) { - pushEvent(eventName, { - id: el.id, - value: (_a = details.focusedValue) != null ? _a : null - }); - } - const eventNameClient = getString(el, "onFocusChangeClient"); - if (eventNameClient) { - el.dispatchEvent( - new CustomEvent(eventNameClient, { - bubbles: true, - detail: { - id: el.id, - value: (_b = details.focusedValue) != null ? _b : null - } - }) - ); - } + const tabs = new Tabs(el, __spreadProps(__spreadValues({ + id: el.id + }, getBoolean(el, "controlled") ? { value: getString(el, "value") } : { defaultValue: getString(el, "defaultValue") }), { + orientation: getString(el, "orientation", ["horizontal", "vertical"]), + dir: getString(el, "dir", ["ltr", "rtl"]), + onValueChange: (details) => { + var _a, _b; + const eventName = getString(el, "onValueChange"); + if (eventName && this.liveSocket.main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: (_a = details.value) != null ? _a : null + }); } - }) - ); + const eventNameClient = getString(el, "onValueChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: (_b = details.value) != null ? _b : null + } + }) + ); + } + }, + onFocusChange: (details) => { + var _a, _b; + const eventName = getString(el, "onFocusChange"); + if (eventName && this.liveSocket.main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: (_a = details.focusedValue) != null ? _a : null + }); + } + const eventNameClient = getString(el, "onFocusChangeClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: (_b = details.focusedValue) != null ? _b : null + } + }) + ); + } + } + })); tabs.init(); this.tabs = tabs; this.onSetValue = (event) => { @@ -20707,14 +20698,11 @@ var Corex = (() => { el.addEventListener("phx:tabs:set-value", this.onSetValue); this.handlers = []; this.handlers.push( - this.handleEvent( - "tabs_set_value", - (payload) => { - const targetId = payload.tabs_id; - if (targetId && targetId !== el.id) return; - tabs.api.setValue(payload.value); - } - ) + this.handleEvent("tabs_set_value", (payload) => { + const targetId = payload.tabs_id; + if (targetId && targetId !== el.id) return; + tabs.api.setValue(payload.value); + }) ); this.handlers.push( this.handleEvent("tabs_value", () => { @@ -21937,7 +21925,9 @@ var Corex = (() => { const duration = this.duration; const isInfinity = duration === "Infinity" || duration === Infinity || duration === Number.POSITIVE_INFINITY; const toastGroup = this.el.closest('[phx-hook="Toast"]'); - const loadingIconTemplate = toastGroup == null ? void 0 : toastGroup.querySelector("[data-loading-icon-template]"); + const loadingIconTemplate = toastGroup == null ? void 0 : toastGroup.querySelector( + "[data-loading-icon-template]" + ); const loadingIcon = loadingIconTemplate == null ? void 0 : loadingIconTemplate.innerHTML; if (isInfinity) { this.parts.progressbar.style.display = "none"; @@ -22523,10 +22513,14 @@ var Corex = (() => { return connect14(this.machine.service, normalizeProps); } render() { - const rootEl = this.el.querySelector('[data-scope="toggle-group"][data-part="root"]'); + const rootEl = this.el.querySelector( + '[data-scope="toggle-group"][data-part="root"]' + ); if (!rootEl) return; this.spreadProps(rootEl, this.api.getRootProps()); - const items = this.el.querySelectorAll('[data-scope="toggle-group"][data-part="item"]'); + const items = this.el.querySelectorAll( + '[data-scope="toggle-group"][data-part="item"]' + ); for (let i2 = 0; i2 < items.length; i2++) { const itemEl = items[i2]; const value = getString(itemEl, "value"); @@ -22583,14 +22577,11 @@ var Corex = (() => { el.addEventListener("phx:toggle-group:set-value", this.onSetValue); this.handlers = []; this.handlers.push( - this.handleEvent( - "toggle-group_set_value", - (payload) => { - const targetId = payload.id; - if (targetId && targetId !== el.id) return; - toggleGroup.api.setValue(payload.value); - } - ) + this.handleEvent("toggle-group_set_value", (payload) => { + const targetId = payload.id; + if (targetId && targetId !== el.id) return; + toggleGroup.api.setValue(payload.value); + }) ); this.handlers.push( this.handleEvent("toggle-group:value", () => { @@ -23941,23 +23932,22 @@ var Corex = (() => { constructor(el, props22) { var _a; const treeData = (_a = props22.treeData) != null ? _a : buildTreeFromDOM(el); - const collection22 = collection3({ + const treeCollection = collection3({ nodeToValue: (node) => node.id, nodeToString: (node) => node.name, rootNode: treeData }); - super(el, __spreadProps(__spreadValues({}, props22), { collection: collection22 })); - __publicField(this, "collection"); + super(el, __spreadProps(__spreadValues({}, props22), { collection: treeCollection })); + __publicField(this, "treeCollection"); __publicField(this, "syncTree", () => { - const treeEl = this.el.querySelector( - '[data-scope="tree-view"][data-part="tree"]' - ); + const treeEl = this.el.querySelector('[data-scope="tree-view"][data-part="tree"]'); if (!treeEl) return; this.spreadProps(treeEl, this.api.getTreeProps()); this.updateExistingTree(treeEl); }); - this.collection = collection22; + this.treeCollection = treeCollection; } + // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props22) { return new VanillaMachine(machine15, __spreadValues({}, props22)); } @@ -23967,7 +23957,7 @@ var Corex = (() => { getNodeAt(indexPath) { var _a; if (indexPath.length === 0) return void 0; - let current = this.collection.rootNode; + let current = this.treeCollection.rootNode; for (const i2 of indexPath) { current = (_a = current == null ? void 0 : current.children) == null ? void 0 : _a[i2]; if (!current) return void 0; @@ -23998,8 +23988,7 @@ var Corex = (() => { const indicatorEl = branchEl.querySelector( '[data-scope="tree-view"][data-part="branch-indicator"]' ); - if (indicatorEl) - this.spreadProps(indicatorEl, this.api.getBranchIndicatorProps(nodeProps)); + if (indicatorEl) this.spreadProps(indicatorEl, this.api.getBranchIndicatorProps(nodeProps)); const contentEl = branchEl.querySelector( '[data-scope="tree-view"][data-part="branch-content"]' ); @@ -24025,13 +24014,9 @@ var Corex = (() => { } render() { var _a; - const rootEl = (_a = this.el.querySelector( - '[data-scope="tree-view"][data-part="root"]' - )) != null ? _a : this.el; + const rootEl = (_a = this.el.querySelector('[data-scope="tree-view"][data-part="root"]')) != null ? _a : this.el; this.spreadProps(rootEl, this.api.getRootProps()); - const label = this.el.querySelector( - '[data-scope="tree-view"][data-part="label"]' - ); + const label = this.el.querySelector('[data-scope="tree-view"][data-part="label"]'); if (label) this.spreadProps(label, this.api.getLabelProps()); this.syncTree(); } diff --git a/priv/static/corex.min.js b/priv/static/corex.min.js index b80bbb0..a370927 100644 --- a/priv/static/corex.min.js +++ b/priv/static/corex.min.js @@ -1,5 +1,5 @@ "use strict";var Corex=(()=>{var Zr=Object.defineProperty,oh=Object.defineProperties,ah=Object.getOwnPropertyDescriptor,lh=Object.getOwnPropertyDescriptors,ch=Object.getOwnPropertyNames,Xr=Object.getOwnPropertySymbols;var Os=Object.prototype.hasOwnProperty,ba=Object.prototype.propertyIsEnumerable;var Is=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),uh=e=>{throw TypeError(e)};var Ts=(e,t,n)=>t in e?Zr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))Os.call(t,n)&&Ts(e,n,t[n]);if(Xr)for(var n of Xr(t))ba.call(t,n)&&Ts(e,n,t[n]);return e},y=(e,t)=>oh(e,lh(t));var ze=(e,t)=>{var n={};for(var r in e)Os.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Xr)for(var r of Xr(e))t.indexOf(r)<0&&ba.call(e,r)&&(n[r]=e[r]);return n};var fe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Oe=(e,t)=>{for(var n in t)Zr(e,n,{get:t[n],enumerable:!0})},dh=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ch(t))!Os.call(e,i)&&i!==n&&Zr(e,i,{get:()=>t[i],enumerable:!(r=ah(t,i))||r.enumerable});return e};var hh=e=>dh(Zr({},"__esModule",{value:!0}),e);var U=(e,t,n)=>Ts(e,typeof t!="symbol"?t+"":t,n);var Ee=(e,t,n)=>new Promise((r,i)=>{var s=l=>{try{a(n.next(l))}catch(c){i(c)}},o=l=>{try{a(n.throw(l))}catch(c){i(c)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);a((n=n.apply(e,t)).next())}),gh=function(e,t){this[0]=e,this[1]=t};var Ea=e=>{var t=e[Is("asyncIterator")],n=!1,r,i={};return t==null?(t=e[Is("iterator")](),r=s=>i[s]=o=>t[s](o)):(t=t.call(e),r=s=>i[s]=o=>{if(n){if(n=!1,s==="throw")throw o;return o}return n=!0,{done:!1,value:new gh(new Promise(a=>{var l=t[s](o);l instanceof Object||uh("Object expected"),a(l)}),1)}}),i[Is("iterator")]=()=>i,r("next"),"throw"in t?r("throw"):i.throw=s=>{throw s},"return"in t&&r("return"),i};function Gt(e){let t=e.dataset.dir;if(t!==void 0&&fh.includes(t))return t;let n=document.documentElement.getAttribute("dir");return n==="ltr"||n==="rtl"?n:"ltr"}function Aa(e){if(e)try{if(e.ownerDocument.activeElement!==e)return;let t=e.value.length;e.setSelectionRange(t,t)}catch(t){}}function Th(e){return["html","body","#document"].includes(Da(e))}function ii(e){if(!e)return!1;let t=e.getRootNode();return kn(t)===e}function Ut(e){if(e==null||!ce(e))return!1;try{return Sh(e)&&e.selectionStart!=null||wh.test(e.localName)||e.isContentEditable||e.getAttribute("contenteditable")==="true"||e.getAttribute("contenteditable")===""}catch(t){return!1}}function pe(e,t){var r;if(!e||!t||!ce(e)||!ce(t))return!1;let n=(r=t.getRootNode)==null?void 0:r.call(t);if(e===t||e.contains(t))return!0;if(n&&nn(n)){let i=t;for(;i;){if(e===i)return!0;i=i.parentNode||i.host}}return!1}function we(e){var t;return yr(e)?e:Ih(e)?e.document:(t=e==null?void 0:e.ownerDocument)!=null?t:document}function Vh(e){return we(e).documentElement}function oe(e){var t,n,r;return nn(e)?oe(e.host):yr(e)?(t=e.defaultView)!=null?t:window:ce(e)&&(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window}function kn(e){let t=e.activeElement;for(;t!=null&&t.shadowRoot;){let n=t.shadowRoot.activeElement;if(!n||n===t)break;t=n}return t}function xh(e){if(Da(e)==="html")return e;let t=e.assignedSlot||e.parentNode||nn(e)&&e.host||Vh(e);return nn(t)?t.host:t}function As(e){var n;let t;try{if(t=e.getRootNode({composed:!0}),yr(t)||nn(t))return t}catch(r){}return(n=e.ownerDocument)!=null?n:document}function qt(e){return ws.has(e)||ws.set(e,oe(e).getComputedStyle(e)),ws.get(e)}function li(e,t){let n=new Set,r=As(e),i=s=>{let o=s.querySelectorAll("[aria-controls]");for(let a of o){if(a.getAttribute("aria-expanded")!=="true")continue;let l=La(a);for(let c of l){if(!c||n.has(c))continue;n.add(c);let u=r.getElementById(c);if(u){let h=u.getAttribute("role"),p=u.getAttribute("aria-modal")==="true";if(h&&kh(h)&&!p&&(u===t||u.contains(t)||i(u)))return!0}}}return!1};return i(e)}function Ds(e,t){let n=As(e),r=new Set,i=s=>{let o=s.querySelectorAll("[aria-controls]");for(let a of o){if(a.getAttribute("aria-expanded")!=="true")continue;let l=La(a);for(let c of l){if(!c||r.has(c))continue;r.add(c);let u=n.getElementById(c);if(u){let h=u.getAttribute("role"),p=u.getAttribute("aria-modal")==="true";h&&Rs.has(h)&&!p&&(t(u),i(u))}}}};i(e)}function Fa(e){let t=new Set;return Ds(e,n=>{e.contains(n)||t.add(n)}),Array.from(t)}function Nh(e){let t=e.getAttribute("role");return!!(t&&Rs.has(t))}function Ah(e){return e.hasAttribute("aria-controls")&&e.getAttribute("aria-expanded")==="true"}function Ma(e){var t;return Ah(e)?!0:!!((t=e.querySelector)!=null&&t.call(e,'[aria-controls][aria-expanded="true"]'))}function $a(e){if(!e.id)return!1;let t=As(e),n=CSS.escape(e.id),r=`[aria-controls~="${n}"][aria-expanded="true"], [aria-controls="${n}"][aria-expanded="true"]`;return!!(t.querySelector(r)&&Nh(e))}function _a(e,t){let{type:n,quality:r=.92,background:i}=t;if(!e)throw new Error("[zag-js > getDataUrl]: Could not find the svg element");let s=oe(e),o=s.document,a=e.getBoundingClientRect(),l=e.cloneNode(!0);l.hasAttribute("viewBox")||l.setAttribute("viewBox",`0 0 ${a.width} ${a.height}`);let u=`\r -`+new s.XMLSerializer().serializeToString(l),h="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(u);if(n==="image/svg+xml")return Promise.resolve(h).then(b=>(l.remove(),b));let p=s.devicePixelRatio||1,d=o.createElement("canvas"),g=new s.Image;g.src=h,d.width=a.width*p,d.height=a.height*p;let v=d.getContext("2d");return(n==="image/jpeg"||i)&&(v.fillStyle=i||"white",v.fillRect(0,0,d.width,d.height)),new Promise(b=>{g.onload=()=>{v==null||v.drawImage(g,0,0,d.width,d.height),b(d.toDataURL(n,r)),l.remove()}})}function Rh(){var t;let e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}function Dh(){let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Bh(e){var t,n,r,i;return(i=(t=e.composedPath)==null?void 0:t.call(e))!=null?i:(r=(n=e.nativeEvent)==null?void 0:n.composedPath)==null?void 0:r.call(n)}function K(e){var n;let t=Bh(e);return(n=t==null?void 0:t[0])!=null?n:e.target}function sn(e){let t=e.currentTarget;if(!t||!t.matches("a[href], button[type='submit'], input[type='submit']"))return!1;let r=e.button===1,i=Gh(e);return r||i}function Er(e){let t=e.currentTarget;if(!t)return!1;let n=t.localName;return e.altKey?n==="a"||n==="button"&&t.type==="submit"||n==="input"&&t.type==="submit":!1}function Vt(e){return Ms(e).isComposing||e.keyCode===229}function Gh(e){return Nn()?e.metaKey:e.ctrlKey}function Ba(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey}function Ga(e){return e.pointerType===""&&e.isTrusted?!0:Hh()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function ve(e,t={}){var o;let{dir:n="ltr",orientation:r="horizontal"}=t,i=e.key;return i=(o=qh[i])!=null?o:i,n==="rtl"&&r==="horizontal"&&i in Ia&&(i=Ia[i]),i}function Ms(e){var t;return(t=e.nativeEvent)!=null?t:e}function Pt(e,t="client"){let n=Uh(e)?e.touches[0]||e.changedTouches[0]:e;return{x:n[`${t}X`],y:n[`${t}Y`]}}function Ua(e,t){var s;let{type:n="HTMLInputElement",property:r="value"}=t,i=oe(e)[n].prototype;return(s=Object.getOwnPropertyDescriptor(i,r))!=null?s:{}}function Wh(e){if(e.localName==="input")return"HTMLInputElement";if(e.localName==="textarea")return"HTMLTextAreaElement";if(e.localName==="select")return"HTMLSelectElement"}function xt(e,t,n="value"){var i;if(!e)return;let r=Wh(e);r&&((i=Ua(e,{type:r,property:n}).set)==null||i.call(e,t)),e.setAttribute(n,t)}function Cr(e,t){var r;if(!e)return;(r=Ua(e,{type:"HTMLInputElement",property:"checked"}).set)==null||r.call(e,t),t?e.setAttribute("checked",""):e.removeAttribute("checked")}function ui(e,t){let{checked:n,bubbles:r=!0}=t;if(!e)return;let i=oe(e);e instanceof i.HTMLInputElement&&(Cr(e,n),e.dispatchEvent(new i.Event("click",{bubbles:r})))}function Kh(e){return Yh(e)?e.form:e.closest("form")}function Yh(e){return e.matches("textarea, input, select, button")}function jh(e,t){if(!e)return;let n=Kh(e),r=i=>{i.defaultPrevented||t()};return n==null||n.addEventListener("reset",r,{passive:!0}),()=>n==null?void 0:n.removeEventListener("reset",r)}function Xh(e,t){let n=e==null?void 0:e.closest("fieldset");if(!n)return;t(n.disabled);let r=oe(n),i=new r.MutationObserver(()=>t(n.disabled));return i.observe(n,{attributes:!0,attributeFilter:["disabled"]}),()=>i.disconnect()}function Rn(e,t){if(!e)return;let{onFieldsetDisabledChange:n,onFormReset:r}=t,i=[jh(e,r),Xh(e,n)];return()=>i.forEach(s=>s==null?void 0:s())}function Wa(e){let t=e.getAttribute("tabindex");return t?parseInt(t,10):NaN}function Qh(e,t){if(!t)return null;if(t===!0)return e.shadowRoot||null;let n=t(e);return(n===!0?e.shadowRoot:n)||null}function Ka(e,t,n){let r=[...e],i=[...e],s=new Set,o=new Map;e.forEach((l,c)=>o.set(l,c));let a=0;for(;a{o.set(d,p+g)});for(let d=p+u.length;d{o.set(d,p+g)})}i.push(...u)}}return r}function Qe(e){return!ce(e)||e.closest("[inert]")?!1:e.matches(di)&&Ph(e)}function on(e,t={}){if(!e)return[];let{includeContainer:n,getShadowRoot:r}=t,i=Array.from(e.querySelectorAll(di));n&&Bt(e)&&i.unshift(e);let s=[];for(let o of i)if(Bt(o)){if(qa(o)&&o.contentDocument){let a=o.contentDocument.body;s.push(...on(a,{getShadowRoot:r}));continue}s.push(o)}if(r){let o=Ka(s,r,Bt);return!o.length&&n?i:o}return!s.length&&n?i:s}function Bt(e){return ce(e)&&e.tabIndex>0?!0:Qe(e)&&!zh(e)}function eg(e,t={}){let n=on(e,t),r=n[0]||null,i=n[n.length-1]||null;return[r,i]}function Dn(e){return e.tabIndex<0&&(Zh.test(e.localName)||Ut(e))&&!Jh(e)?0:e.tabIndex}function hi(e){let{root:t,getInitialEl:n,filter:r,enabled:i=!0}=e;if(!i)return;let s=null;if(s||(s=typeof n=="function"?n():n),s||(s=t==null?void 0:t.querySelector("[data-autofocus],[autofocus]")),!s){let o=on(t);s=r?o.filter(r)[0]:o[0]}return s||t||void 0}function gi(e){let t=e.currentTarget;if(!t)return!1;let[n,r]=eg(t);return!(ii(n)&&e.shiftKey||ii(r)&&!e.shiftKey||!n&&!r)}function H(e){let t=$s.create();return t.request(e),t.cleanup}function an(e){let t=new Set;function n(r){let i=globalThis.requestAnimationFrame(r);t.add(()=>globalThis.cancelAnimationFrame(i))}return n(()=>n(e)),function(){t.forEach(i=>i())}}function tg(e,t,n){let r=H(()=>{e.removeEventListener(t,i,!0),n()}),i=()=>{r(),n()};return e.addEventListener(t,i,{once:!0,capture:!0}),r}function ng(e,t){if(!e)return;let{attributes:n,callback:r}=t,i=e.ownerDocument.defaultView||window,s=new i.MutationObserver(o=>{for(let a of o)a.type==="attributes"&&a.attributeName&&n.includes(a.attributeName)&&r(a)});return s.observe(e,{attributes:!0,attributeFilter:n}),()=>s.disconnect()}function Ln(e,t){let{defer:n}=t,r=n?H:s=>s(),i=[];return i.push(r(()=>{let s=typeof e=="function"?e():e;i.push(ng(s,t))})),()=>{i.forEach(s=>s==null?void 0:s())}}function rg(e,t){let{callback:n}=t;if(!e)return;let r=e.ownerDocument.defaultView||window,i=new r.MutationObserver(n);return i.observe(e,{childList:!0,subtree:!0}),()=>i.disconnect()}function ja(e,t){let{defer:n}=t,r=n?H:s=>s(),i=[];return i.push(r(()=>{let s=typeof e=="function"?e():e;i.push(rg(s,t))})),()=>{i.forEach(s=>s==null?void 0:s())}}function Fn(e){let t=()=>{let n=oe(e);e.dispatchEvent(new n.MouseEvent("click"))};_h()?tg(e,"keyup",t):queueMicrotask(t)}function fi(e){let t=xh(e);return Th(t)?we(t).body:ce(t)&&Xa(t)?t:fi(t)}function Xa(e){let t=oe(e),{overflow:n,overflowX:r,overflowY:i,display:s}=t.getComputedStyle(e);return ig.test(n+i+r)&&!sg.has(s)}function og(e){return e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth}function ln(e,t){let i=t||{},{rootEl:n}=i,r=ze(i,["rootEl"]);!e||!n||!Xa(n)||!og(n)||e.scrollIntoView(r)}function _s(e,t){let{left:n,top:r,width:i,height:s}=t.getBoundingClientRect(),o={x:e.x-n,y:e.y-r},a={x:Ca(o.x/i),y:Ca(o.y/s)};function l(c={}){let{dir:u="ltr",orientation:h="horizontal",inverted:p}=c,d=typeof p=="object"?p.x:p,g=typeof p=="object"?p.y:p;return h==="horizontal"?u==="rtl"||d?1-a.x:a.x:g?1-a.y:a.y}return{offset:o,percent:a,getPercentValue:l}}function ag(e={}){let{target:t,doc:n}=e,r=n!=null?n:document,i=r.documentElement;return br()?(xn==="default"&&(xs=i.style.webkitUserSelect,i.style.webkitUserSelect="none"),xn="disabled"):t&&(ei.set(t,t.style.userSelect),t.style.userSelect="none"),()=>Hs({target:t,doc:r})}function Hs(e={}){let{target:t,doc:n}=e,i=(n!=null?n:document).documentElement;if(br()){if(xn!=="disabled")return;xn="restoring",setTimeout(()=>{an(()=>{xn==="restoring"&&(i.style.webkitUserSelect==="none"&&(i.style.webkitUserSelect=xs||""),xs="",xn="default")})},300)}else if(t&&ei.has(t)){let s=ei.get(t);t.style.userSelect==="none"&&(t.style.userSelect=s!=null?s:""),t.getAttribute("style")===""&&t.removeAttribute("style"),ei.delete(t)}}function Bs(e={}){let o=e,{defer:t,target:n}=o,r=ze(o,["defer","target"]),i=t?H:a=>a(),s=[];return s.push(i(()=>{let a=typeof n=="function"?n():n;s.push(ag(y(m({},r),{target:a})))})),()=>{s.forEach(a=>a==null?void 0:a())}}function Za(e,t){let{onPointerMove:n,onPointerUp:r}=t,i=a=>{let l=Pt(a),c=Math.sqrt(l.x**2+l.y**2),u=a.pointerType==="touch"?10:5;if(!(c{let l=Pt(a);r({point:l,event:a})},o=[ie(e,"pointermove",i,!1),ie(e,"pointerup",s,!1),ie(e,"pointercancel",s,!1),ie(e,"contextmenu",s,!1),Bs({doc:e})];return()=>{o.forEach(a=>a())}}function pi(e){let{pointerNode:t,keyboardNode:n=t,onPress:r,onPressStart:i,onPressEnd:s,isValidKey:o=S=>S.key==="Enter"}=e;if(!t)return Tt;let a=oe(t),l=Tt,c=Tt,u=Tt,h=S=>({point:Pt(S),event:S});function p(S){i==null||i(h(S))}function d(S){s==null||s(h(S))}let v=ie(t,"pointerdown",S=>{c();let f=ie(a,"pointerup",I=>{let w=K(I);pe(t,w)?r==null||r(h(I)):s==null||s(h(I))},{passive:!r,once:!0}),C=ie(a,"pointercancel",d,{passive:!s,once:!0});c=Ps(f,C),ii(n)&&S.pointerType==="mouse"&&S.preventDefault(),p(S)},{passive:!i}),b=ie(n,"focus",V);l=Ps(v,b);function V(){let S=I=>{if(!o(I))return;let w=P=>{if(!o(P))return;let N=new a.PointerEvent("pointerup"),R=h(N);r==null||r(R),s==null||s(R)};c(),c=ie(n,"keyup",w);let A=new a.PointerEvent("pointerdown");p(A)},E=()=>{let I=new a.PointerEvent("pointercancel");d(I)},f=ie(n,"keydown",S),C=ie(n,"blur",E);u=Ps(f,C)}return()=>{l(),c(),u()}}function dt(e,t){var n;return Array.from((n=e==null?void 0:e.querySelectorAll(t))!=null?n:[])}function Mn(e,t){var n;return(n=e==null?void 0:e.querySelector(t))!=null?n:null}function Us(e,t,n=Gs){return e.find(r=>n(r)===t)}function qs(e,t,n=Gs){let r=Us(e,t,n);return r?e.indexOf(r):-1}function $n(e,t,n=!0){let r=qs(e,t);return r=n?(r+1)%e.length:Math.min(r+1,e.length-1),e[r]}function _n(e,t,n=!0){let r=qs(e,t);return r===-1?n?e[e.length-1]:null:(r=n?(r-1+e.length)%e.length:Math.max(0,r-1),e[r])}function lg(e){let t=new WeakMap,n,r=new WeakMap,i=a=>n||(n=new a.ResizeObserver(l=>{for(let c of l){r.set(c.target,c);let u=t.get(c.target);if(u)for(let h of u)h(c)}}),n);return{observe:(a,l)=>{let c=t.get(a)||new Set;c.add(l),t.set(a,c);let u=oe(a);return i(u).observe(a,e),()=>{let h=t.get(a);h&&(h.delete(l),h.size===0&&(t.delete(a),i(u).unobserve(a)))}},unobserve:a=>{t.delete(a),n==null||n.unobserve(a)}}}function hg(e,t,n,r=Gs){let i=n?qs(e,n,r):-1,s=n?yh(e,i):e;return t.length===1&&(s=s.filter(a=>r(a)!==n)),s.find(a=>dg(ug(a),t))}function za(e,t,n){let r=e.getAttribute(t),i=r!=null;return r===n?Tt:(e.setAttribute(t,n),()=>{i?e.setAttribute(t,r):e.removeAttribute(t)})}function cn(e,t){if(!e)return Tt;let n=Object.keys(t).reduce((r,i)=>(r[i]=e.style.getPropertyValue(i),r),{});return gg(n,t)?Tt:(Object.assign(e.style,t),()=>{Object.assign(e.style,n),e.style.length===0&&e.removeAttribute("style")})}function Qa(e,t,n){if(!e)return Tt;let r=e.style.getPropertyValue(t);return r===n?Tt:(e.style.setProperty(t,n),()=>{e.style.setProperty(t,r),e.style.length===0&&e.removeAttribute("style")})}function gg(e,t){return Object.keys(e).every(n=>e[n]===t[n])}function fg(e,t){let{state:n,activeId:r,key:i,timeout:s=350,itemToId:o}=t,a=n.keysSoFar+i,c=a.length>1&&Array.from(a).every(g=>g===a[0])?a[0]:a,u=e.slice(),h=hg(u,c,r,o);function p(){clearTimeout(n.timer),n.timer=-1}function d(g){n.keysSoFar=g,p(),g!==""&&(n.timer=+setTimeout(()=>{d(""),p()},s))}return d(a),h}function pg(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey}function mg(e,t,n){let{signal:r}=t;return[new Promise((o,a)=>{let l=setTimeout(()=>{a(new Error(`Timeout of ${n}ms exceeded`))},n);r.addEventListener("abort",()=>{clearTimeout(l),a(new Error("Promise aborted"))}),e.then(c=>{r.aborted||(clearTimeout(l),o(c))}).catch(c=>{r.aborted||(clearTimeout(l),a(c))})}),()=>t.abort()]}function el(e,t){let{timeout:n,rootNode:r}=t,i=oe(r),s=we(r),o=new i.AbortController;return mg(new Promise(a=>{let l=e();if(l){a(l);return}let c=new i.MutationObserver(()=>{let u=e();u&&u.isConnected&&(c.disconnect(),a(u))});c.observe(s.body,{childList:!0,subtree:!0})}),o,n)}function Tr(e){return e==null?[]:Array.isArray(e)?e:[e]}function nl(e,t,n={}){let{step:r=1,loop:i=!0}=n,s=t+r,o=e.length,a=o-1;return t===-1?r>0?0:a:s<0?i?a:0:s>=o?i?0:t>o?o:t:s}function rl(e,t,n={}){return e[nl(e,t,n)]}function Ig(e,t,n={}){let{step:r=1,loop:i=!0}=n;return nl(e,t,{step:-r,loop:i})}function il(e,t,n={}){return e[Ig(e,t,n)]}function Ws(e,t){return e.reduce((n,r,i)=>{var s;return i%t===0?n.push([r]):(s=nt(n))==null||s.push(r),n},[])}function Ks(e,t){return e.reduce(([n,r],i)=>(t(i)?n.push(i):r.push(i),[n,r]),[[],[]])}function Ve(e,t,...n){var i;if(e in t){let s=t[e];return Ot(s)?s(...n):s}let r=new Error(`No matching key: ${JSON.stringify(e)} in ${JSON.stringify(Object.keys(t))}`);throw(i=Error.captureStackTrace)==null||i.call(Error,r,Ve),r}function Gn(e){if(!mr(e)||e===void 0)return e;let t=Reflect.ownKeys(e).filter(r=>typeof r=="string"),n={};for(let r of t){let i=e[r];i!==void 0&&(n[r]=Gn(i))}return n}function Rg(e,t){let n={},r={},i=new Set(t),s=Reflect.ownKeys(e);for(let o of s)i.has(o)?r[o]=e[o]:n[o]=e[o];return[r,n]}function Un(e,t){let n=new Dg(({deltaMs:r})=>{if(r>=t)return e(),!1});return n.start(),()=>n.stop()}function wt(...e){let t=e.length===1?e[0]:e[1];(e.length===2?e[0]:!0)&&console.warn(t)}function qn(e,t){if(e==null)throw new Error(t())}function yi(e,t,n){let r=[];for(let i of t)e[i]==null&&r.push(i);if(r.length>0)throw new Error(`[zag-js${n?` > ${n}`:""}] missing required props: ${r.join(", ")}`)}function hl(...e){let t={};for(let n of e){if(!n)continue;for(let i in t){if(i.startsWith("on")&&typeof t[i]=="function"&&typeof n[i]=="function"){t[i]=Bn(n[i],t[i]);continue}if(i==="className"||i==="class"){t[i]=Lg(t[i],n[i]);continue}if(i==="style"){t[i]=Mg(t[i],n[i]);continue}t[i]=n[i]!==void 0?n[i]:t[i]}for(let i in n)t[i]===void 0&&(t[i]=n[i]);let r=Object.getOwnPropertySymbols(n);for(let i of r)t[i]=n[i]}return t}function gl(e,t,n){let r=[],i;return s=>{var l;let o=e(s);return(o.length!==r.length||o.some((c,u)=>!he(r[u],c)))&&(r=o,i=t(o,s),(l=n==null?void 0:n.onChange)==null||l.call(n,i)),i}}function ye(){return{and:(...e)=>function(n){return e.every(r=>n.guard(r))},or:(...e)=>function(n){return e.some(r=>n.guard(r))},not:e=>function(n){return!n.guard(e)}}}function Wn(){return{guards:ye(),createMachine:e=>e,choose:e=>function({choose:n}){var r;return(r=n(e))==null?void 0:r.actions}}}function $g(e){let t=()=>{var o,a;return(a=(o=e.getRootNode)==null?void 0:o.call(e))!=null?a:document},n=()=>we(t()),r=()=>{var o;return(o=n().defaultView)!=null?o:window},i=()=>kn(t()),s=o=>t().getElementById(o);return y(m({},e),{getRootNode:t,getDoc:n,getWin:r,getActiveElement:i,isActiveElement:ii,getById:s})}function _g(e){return new Proxy({},{get(t,n){return n==="style"?r=>e({style:r}).style:e}})}function Ug(){if(typeof globalThis!="undefined")return globalThis;if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global}function fl(e,t){let n=Ug();return n?(n[e]||(n[e]=t()),n[e]):t()}function pl(e={}){return Xg(e)}function xa(e,t,n){let r=tn.get(e);si()&&!r&&console.warn("Please use proxy object");let i,s=[],o=r[3],a=!1,c=o(u=>{if(s.push(u),n){t(s.splice(0));return}i||(i=Promise.resolve().then(()=>{i=void 0,a&&t(s.splice(0))}))});return a=!0,()=>{a=!1,c()}}function Zg(e){let t=tn.get(e);si()&&!t&&console.warn("Please use proxy object");let[n,r,i]=t;return i(n,r())}function rf(e,t,n){let r=n||"default",i=zr.get(e);i||(i=new Map,zr.set(e,i));let s=i.get(r)||{},o=Object.keys(t),a=(v,b)=>{e.addEventListener(v.toLowerCase(),b)},l=(v,b)=>{e.removeEventListener(v.toLowerCase(),b)},c=v=>v.startsWith("on"),u=v=>!v.startsWith("on"),h=v=>a(v.substring(2),t[v]),p=v=>l(v.substring(2),t[v]),d=v=>{let b=t[v],V=s[v];if(b!==V){if(v==="class"){e.className=b!=null?b:"";return}if(Na.has(v)){e[v]=b!=null?b:"";return}if(typeof b=="boolean"&&!v.includes("aria-")){e.toggleAttribute(Qr(e,v),b);return}if(v==="children"){e.innerHTML=b;return}if(b!=null){e.setAttribute(Qr(e,v),b);return}e.removeAttribute(Qr(e,v))}};for(let v in s)t[v]==null&&(v==="class"?e.className="":Na.has(v)?e[v]="":e.removeAttribute(Qr(e,v)));return Object.keys(s).filter(c).forEach(v=>{l(v.substring(2),s[v])}),o.filter(c).forEach(h),o.filter(u).forEach(d),i.set(r,t),function(){o.filter(c).forEach(p);let b=zr.get(e);b&&(b.delete(r),b.size===0&&zr.delete(e))}}function oi(e){var s,o;let t=(s=e().value)!=null?s:e().defaultValue;e().debug&&console.log(`[bindable > ${e().debug}] initial`,t);let n=(o=e().isEqual)!=null?o:Object.is,r=pl({value:t}),i=()=>e().value!==void 0;return{initial:t,ref:r,get(){return i()?e().value:r.value},set(a){var u,h;let l=r.value,c=Ot(a)?a(l):a;e().debug&&console.log(`[bindable > ${e().debug}] setValue`,{next:c,prev:l}),i()||(r.value=c),n(c,l)||(h=(u=e()).onChange)==null||h.call(u,c,l)},invoke(a,l){var c,u;(u=(c=e()).onChange)==null||u.call(c,a,l)},hash(a){var l,c,u;return(u=(c=(l=e()).hash)==null?void 0:c.call(l,a))!=null?u:String(a)}}}function sf(e){let t={current:e};return{get(n){return t.current[n]},set(n,r){t.current[n]=r}}}function ml(e,t){if(!mr(e)||!mr(t))return t===void 0?e:t;let n=m({},e);for(let r of Object.keys(t)){let i=t[r],s=e[r];i!==void 0&&(mr(s)&&mr(i)?n[r]=ml(s,i):n[r]=i)}return n}var fh,x,Y,Se,O,rn,Z,Vn,ph,mh,vh,Ss,Ca,yh,Ps,Tt,ai,Ra,T,re,bh,Eh,Ch,ce,yr,Ih,Da,Oh,nn,Sh,We,Ph,wh,ws,Rs,kh,La,ci,Ls,Ha,Lh,Fs,Fh,Mh,br,$h,Nn,Wt,_h,Hh,et,An,Fe,Uh,qh,Ia,ie,qa,Zh,Jh,zh,di,Ir,$s,ig,sg,xn,xs,ei,Gs,Ja,cg,ug,dg,tt,Hn,vg,tl,yg,Ht,bg,Ta,Eg,Ke,nt,Cg,rt,ht,kt,mi,it,Oa,Tg,he,Kt,sl,ol,Yt,ti,Ot,al,Me,Og,ll,Sg,mr,Pg,wg,Vg,St,Ys,xg,cl,Bn,js,CI,II,TI,kg,Ng,OI,SI,Ag,ul,vi,dl,Ae,B,Jr,ni,Dg,Lg,Fg,Sa,Mg,vr,Vs,G,PI,Hg,Pa,ks,Bg,Gg,wa,ri,qg,Wg,Kg,Yg,Ns,Va,si,tn,jg,Xg,Jg,zg,ne,ka,Qg,ef,Q,zr,Na,tf,nf,Qr,ee,te,me=fe(()=>{"use strict";fh=["ltr","rtl"];x=(e,t,n)=>{let r=e.dataset[t];if(r!==void 0&&(!n||n.includes(r)))return r},Y=(e,t)=>{let n=e.dataset[t];if(typeof n=="string")return n.split(",").map(r=>r.trim()).filter(r=>r.length>0)},Se=(e,t,n)=>{let r=e.dataset[t];if(r===void 0)return;let i=Number(r);if(!Number.isNaN(i))return n&&!n.includes(i)?0:i},O=(e,t)=>{let n=t.replace(/([A-Z])/g,"-$1").toLowerCase();return e.hasAttribute(`data-${n}`)},rn=(e,t="element")=>e!=null&&e.id?e.id:`${t}-${Math.random().toString(36).substring(2,9)}`,Z=(e,t=[])=>({parts:(...n)=>{if(ph(t))return Z(e,n);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...n)=>Z(e,[...t,...n]),omit:(...n)=>Z(e,t.filter(r=>!n.includes(r))),rename:n=>Z(n,t),keys:()=>t,build:()=>[...new Set(t)].reduce((n,r)=>Object.assign(n,{[r]:{selector:[`&[data-scope="${Vn(e)}"][data-part="${Vn(r)}"]`,`& [data-scope="${Vn(e)}"][data-part="${Vn(r)}"]`].join(", "),attrs:{"data-scope":Vn(e),"data-part":Vn(r)}}}),{})}),Vn=e=>e.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),ph=e=>e.length===0,mh=Object.defineProperty,vh=(e,t,n)=>t in e?mh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ss=(e,t,n)=>vh(e,typeof t!="symbol"?t+"":t,n);Ca=e=>Math.max(0,Math.min(1,e)),yh=(e,t)=>e.map((n,r)=>e[(Math.max(t,0)+r)%e.length]),Ps=(...e)=>t=>e.reduce((n,r)=>r(n),t),Tt=()=>{},ai=e=>typeof e=="object"&&e!==null,Ra=2147483647,T=e=>e?"":void 0,re=e=>e?"true":void 0,bh=1,Eh=9,Ch=11,ce=e=>ai(e)&&e.nodeType===bh&&typeof e.nodeName=="string",yr=e=>ai(e)&&e.nodeType===Eh,Ih=e=>ai(e)&&e===e.window,Da=e=>ce(e)?e.localName||"":"#document";Oh=e=>ai(e)&&e.nodeType!==void 0,nn=e=>Oh(e)&&e.nodeType===Ch&&"host"in e,Sh=e=>ce(e)&&e.localName==="input",We=e=>!!(e!=null&&e.matches("a[href]")),Ph=e=>ce(e)?e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0:!1;wh=/(textarea|select)/;ws=new WeakMap;Rs=new Set(["menu","listbox","dialog","grid","tree","region"]),kh=e=>Rs.has(e),La=e=>{var t;return((t=e.getAttribute("aria-controls"))==null?void 0:t.split(" "))||[]};ci=()=>typeof document!="undefined";Ls=e=>ci()&&e.test(Rh()),Ha=e=>ci()&&e.test(Dh()),Lh=e=>ci()&&e.test(navigator.vendor),Fs=()=>ci()&&!!navigator.maxTouchPoints,Fh=()=>Ls(/^iPhone/i),Mh=()=>Ls(/^iPad/i)||Nn()&&navigator.maxTouchPoints>1,br=()=>Fh()||Mh(),$h=()=>Nn()||br(),Nn=()=>Ls(/^Mac/i),Wt=()=>$h()&&Lh(/apple/i),_h=()=>Ha(/Firefox/i),Hh=()=>Ha(/Android/i);et=e=>e.button===0,An=e=>e.button===2||Nn()&&e.ctrlKey&&e.button===0,Fe=e=>e.ctrlKey||e.altKey||e.metaKey,Uh=e=>"touches"in e&&e.touches.length>0,qh={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"},Ia={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft"};ie=(e,t,n,r)=>{let i=typeof e=="function"?e():e;return i==null||i.addEventListener(t,n,r),()=>{i==null||i.removeEventListener(t,n,r)}};qa=e=>ce(e)&&e.tagName==="IFRAME",Zh=/^(audio|video|details)$/;Jh=e=>!Number.isNaN(Wa(e)),zh=e=>Wa(e)<0;di="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type",Ir=(e,t={})=>{if(!e)return[];let{includeContainer:n=!1,getShadowRoot:r}=t,i=Array.from(e.querySelectorAll(di));(n==!0||n=="if-empty"&&i.length===0)&&ce(e)&&Qe(e)&&i.unshift(e);let o=[];for(let a of i)if(Qe(a)){if(qa(a)&&a.contentDocument){let l=a.contentDocument.body;o.push(...Ir(l,{getShadowRoot:r}));continue}o.push(a)}return r?Ka(o,r,Qe):o};$s=class Ya{constructor(){Ss(this,"id",null),Ss(this,"fn_cleanup"),Ss(this,"cleanup",()=>{this.cancel()})}static create(){return new Ya}request(t){this.cancel(),this.id=globalThis.requestAnimationFrame(()=>{this.id=null,this.fn_cleanup=t==null?void 0:t()})}cancel(){var t;this.id!==null&&(globalThis.cancelAnimationFrame(this.id),this.id=null),(t=this.fn_cleanup)==null||t.call(this),this.fn_cleanup=void 0}isActive(){return this.id!==null}};ig=/auto|scroll|overlay|hidden|clip/,sg=new Set(["inline","contents"]);xn="default",xs="",ei=new WeakMap;Gs=e=>e.id;Ja=lg({box:"border-box"}),cg=e=>e.split("").map(t=>{let n=t.charCodeAt(0);return n>0&&n<128?t:n>=128&&n<=255?`/x${n.toString(16)}`.replace("/","\\"):""}).join("").trim(),ug=e=>{var t,n,r;return cg((r=(n=(t=e.dataset)==null?void 0:t.valuetext)!=null?n:e.textContent)!=null?r:"")},dg=(e,t)=>e.trim().toLowerCase().startsWith(t.toLowerCase());tt=Object.assign(fg,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:pg});Hn={border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"};vg=Object.defineProperty,tl=e=>{throw TypeError(e)},yg=(e,t,n)=>t in e?vg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ht=(e,t,n)=>yg(e,typeof t!="symbol"?t+"":t,n),bg=(e,t,n)=>t.has(e)||tl("Cannot "+n),Ta=(e,t,n)=>(bg(e,t,"read from private field"),t.get(e)),Eg=(e,t,n)=>t.has(e)?tl("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);Ke=e=>e[0],nt=e=>e[e.length-1],Cg=(e,t)=>e.indexOf(t)!==-1,rt=(e,...t)=>e.concat(t),ht=(e,...t)=>e.filter(n=>!t.includes(n)),kt=e=>Array.from(new Set(e)),mi=(e,t)=>{let n=new Set(t);return e.filter(r=>!n.has(r))},it=(e,t)=>Cg(e,t)?ht(e,t):rt(e,t);Oa=e=>(e==null?void 0:e.constructor.name)==="Array",Tg=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n{if(Object.is(e,t))return!0;if(e==null&&t!=null||e!=null&&t==null)return!1;if(typeof(e==null?void 0:e.isEqual)=="function"&&typeof(t==null?void 0:t.isEqual)=="function")return e.isEqual(t);if(typeof e=="function"&&typeof t=="function")return e.toString()===t.toString();if(Oa(e)&&Oa(t))return Tg(Array.from(e),Array.from(t));if(typeof e!="object"||typeof t!="object")return!1;let n=Object.keys(t!=null?t:Object.create(null)),r=n.length;for(let i=0;iArray.isArray(e),sl=e=>e===!0||e===!1,ol=e=>e!=null&&typeof e=="object",Yt=e=>ol(e)&&!Kt(e),ti=e=>typeof e=="string",Ot=e=>typeof e=="function",al=e=>e==null,Me=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Og=e=>Object.prototype.toString.call(e),ll=Function.prototype.toString,Sg=ll.call(Object),mr=e=>{if(!ol(e)||Og(e)!="[object Object]"||Vg(e))return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=Me(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&ll.call(n)==Sg},Pg=e=>typeof e=="object"&&e!==null&&"$$typeof"in e&&"props"in e,wg=e=>typeof e=="object"&&e!==null&&"__v_isVNode"in e,Vg=e=>Pg(e)||wg(e),St=(e,...t)=>{let n=typeof e=="function"?e(...t):e;return n!=null?n:void 0},Ys=e=>e,xg=e=>e(),cl=()=>{},Bn=(...e)=>(...t)=>{e.forEach(function(n){n==null||n(...t)})},js=(()=>{let e=0;return()=>(e++,e.toString(36))})();({floor:CI,abs:II,round:TI,min:kg,max:Ng,pow:OI,sign:SI}=Math),Ag=e=>Number.isNaN(e),ul=e=>Ag(e)?0:e,vi=(e,t,n)=>{let r=ul(e),i=t==null||r>=t,s=n==null||r<=n;return i&&s},dl=(e,t,n)=>kg(Ng(ul(e),t),n),Ae=e=>typeof e=="number"?`${e}px`:e;B=e=>function(n){return Rg(n,e)},Jr=()=>performance.now(),Dg=class{constructor(e){this.onTick=e,Ht(this,"frameId",null),Ht(this,"pausedAtMs",null),Ht(this,"context"),Ht(this,"cancelFrame",()=>{this.frameId!==null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}),Ht(this,"setStartMs",t=>{this.context.startMs=t}),Ht(this,"start",()=>{if(this.frameId!==null)return;let t=Jr();this.pausedAtMs!==null?(this.context.startMs+=t-this.pausedAtMs,this.pausedAtMs=null):this.context.startMs=t,this.frameId=requestAnimationFrame(Ta(this,ni))}),Ht(this,"pause",()=>{this.frameId!==null&&(this.cancelFrame(),this.pausedAtMs=Jr())}),Ht(this,"stop",()=>{this.frameId!==null&&(this.cancelFrame(),this.pausedAtMs=null)}),Eg(this,ni,t=>{if(this.context.now=t,this.context.deltaMs=t-this.context.startMs,this.onTick(this.context)===!1){this.stop();return}this.frameId=requestAnimationFrame(Ta(this,ni))}),this.context={now:0,startMs:Jr(),deltaMs:0}}get elapsedMs(){return this.pausedAtMs!==null?this.pausedAtMs-this.context.startMs:Jr()-this.context.startMs}};ni=new WeakMap;Lg=(...e)=>e.map(t=>{var n;return(n=t==null?void 0:t.trim)==null?void 0:n.call(t)}).filter(Boolean).join(" "),Fg=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,Sa=e=>{let t={},n;for(;n=Fg.exec(e);)t[n[1]]=n[2];return t},Mg=(e,t)=>{if(ti(e)){if(ti(t))return`${e};${t}`;e=Sa(e)}else ti(t)&&(t=Sa(t));return Object.assign({},e!=null?e:{},t!=null?t:{})};vr=(e=>(e.NotStarted="Not Started",e.Started="Started",e.Stopped="Stopped",e))(vr||{}),Vs="__init__";G=()=>e=>Array.from(new Set(e)),PI=Symbol(),Hg=Symbol(),Pa=Object.getPrototypeOf,ks=new WeakMap,Bg=e=>e&&(ks.has(e)?ks.get(e):Pa(e)===Object.prototype||Pa(e)===Array.prototype),Gg=e=>Bg(e)&&e[Hg]||null,wa=(e,t=!0)=>{ks.set(e,t)};ri=fl("__zag__refSet",()=>new WeakSet),qg=e=>typeof e=="object"&&e!==null&&"$$typeof"in e&&"props"in e,Wg=e=>typeof e=="object"&&e!==null&&"__v_isVNode"in e,Kg=e=>typeof e=="object"&&e!==null&&"nodeType"in e&&typeof e.nodeName=="string",Yg=e=>qg(e)||Wg(e)||Kg(e),Ns=e=>e!==null&&typeof e=="object",Va=e=>Ns(e)&&!ri.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!Yg(e)&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)&&!(e instanceof Promise)&&!(e instanceof File)&&!(e instanceof Blob)&&!(e instanceof AbortController),si=()=>!0,tn=fl("__zag__proxyStateMap",()=>new WeakMap),jg=(e=Object.is,t=(a,l)=>new Proxy(a,l),n=new WeakMap,r=(a,l)=>{let c=n.get(a);if((c==null?void 0:c[0])===l)return c[1];let u=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return wa(u,!0),n.set(a,[l,u]),Reflect.ownKeys(a).forEach(h=>{let p=Reflect.get(a,h);ri.has(p)?(wa(p,!1),u[h]=p):tn.has(p)?u[h]=Zg(p):u[h]=p}),Object.freeze(u)},i=new WeakMap,s=[1,1],o=a=>{if(!Ns(a))throw new Error("object required");let l=i.get(a);if(l)return l;let c=s[0],u=new Set,h=(w,A=++s[0])=>{c!==A&&(c=A,u.forEach(P=>P(w,A)))},p=s[1],d=(w=++s[1])=>(p!==w&&!u.size&&(p=w,v.forEach(([A])=>{let P=A[1](w);P>c&&(c=P)})),c),g=w=>(A,P)=>{let N=[...A];N[1]=[w,...N[1]],h(N,P)},v=new Map,b=(w,A)=>{if(si()&&v.has(w))throw new Error("prop listener already exists");if(u.size){let P=A[3](g(w));v.set(w,[A,P])}else v.set(w,[A])},V=w=>{var P;let A=v.get(w);A&&(v.delete(w),(P=A[1])==null||P.call(A))},S=w=>(u.add(w),u.size===1&&v.forEach(([P,N],R)=>{if(si()&&N)throw new Error("remove already exists");let L=P[3](g(R));v.set(R,[P,L])}),()=>{u.delete(w),u.size===0&&v.forEach(([P,N],R)=>{N&&(N(),v.set(R,[P]))})}),E=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),C=t(E,{deleteProperty(w,A){let P=Reflect.get(w,A);V(A);let N=Reflect.deleteProperty(w,A);return N&&h(["delete",[A],P]),N},set(w,A,P,N){var j;let R=Reflect.has(w,A),L=Reflect.get(w,A,N);if(R&&(e(L,P)||i.has(P)&&e(L,i.get(P))))return!0;V(A),Ns(P)&&(P=Gg(P)||P);let M=P;if(!((j=Object.getOwnPropertyDescriptor(w,A))!=null&&j.set)){!tn.has(P)&&Va(P)&&(M=pl(P));let q=!ri.has(M)&&tn.get(M);q&&b(A,q)}return Reflect.set(w,A,M,N),h(["set",[A],P,L]),!0}});i.set(a,C);let I=[E,d,r,S];return tn.set(C,I),Reflect.ownKeys(a).forEach(w=>{let A=Object.getOwnPropertyDescriptor(a,w);A.get||A.set?Object.defineProperty(E,w,A):C[w]=a[w]}),C})=>[o,tn,ri,e,t,Va,n,r,i,s],[Xg]=jg();Jg=Object.defineProperty,zg=(e,t,n)=>t in e?Jg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ne=(e,t,n)=>zg(e,typeof t!="symbol"?t+"":t,n),ka={onFocus:"onFocusin",onBlur:"onFocusout",onChange:"onInput",onDoubleClick:"onDblclick",htmlFor:"for",className:"class",defaultValue:"value",defaultChecked:"checked"},Qg=new Set(["viewBox","preserveAspectRatio"]),ef=e=>{let t="";for(let n in e){let r=e[n];r!=null&&(n.startsWith("--")||(n=n.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)),t+=`${n}:${r};`)}return t},Q=_g(e=>Object.entries(e).reduce((t,[n,r])=>{if(r===void 0)return t;if(n in ka&&(n=ka[n]),n==="style"&&typeof r=="object")return t.style=ef(r),t;let i=Qg.has(n)?n:n.toLowerCase();return t[i]=r,t},{})),zr=new WeakMap,Na=new Set(["value","checked","selected"]),tf=new Set(["viewBox","preserveAspectRatio","clipPath","clipRule","fillRule","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit"]),nf=e=>e.tagName==="svg"||e.namespaceURI==="http://www.w3.org/2000/svg",Qr=(e,t)=>nf(e)&&tf.has(t)?t:t.toLowerCase();oi.cleanup=e=>{};oi.ref=e=>{let t=e;return{get:()=>t,set:n=>{t=n}}};ee=class{constructor(e,t={}){var h,p,d;this.machine=e,ne(this,"scope"),ne(this,"context"),ne(this,"prop"),ne(this,"state"),ne(this,"refs"),ne(this,"computed"),ne(this,"event",{type:""}),ne(this,"previousEvent",{type:""}),ne(this,"effects",new Map),ne(this,"transition",null),ne(this,"cleanups",[]),ne(this,"subscriptions",[]),ne(this,"userPropsRef"),ne(this,"getEvent",()=>y(m({},this.event),{current:()=>this.event,previous:()=>this.previousEvent})),ne(this,"getStateConfig",g=>this.machine.states[g]),ne(this,"getState",()=>y(m({},this.state),{matches:(...g)=>g.includes(this.state.get()),hasTag:g=>{var v,b;return!!((b=(v=this.getStateConfig(this.state.get()))==null?void 0:v.tags)!=null&&b.includes(g))}})),ne(this,"debug",(...g)=>{this.machine.debug&&console.log(...g)}),ne(this,"notify",()=>{this.publish()}),ne(this,"send",g=>{this.status===vr.Started&&queueMicrotask(()=>{var C,I,w,A,P;if(!g)return;this.previousEvent=this.event,this.event=g,this.debug("send",g);let v=this.state.get(),b=g.type,V=(A=(I=(C=this.getStateConfig(v))==null?void 0:C.on)==null?void 0:I[b])!=null?A:(w=this.machine.on)==null?void 0:w[b],S=this.choose(V);if(!S)return;this.transition=S;let E=(P=S.target)!=null?P:v;this.debug("transition",S);let f=E!==v;f?this.state.set(E):S.reenter&&!f?this.state.invoke(v,v):this.action(S.actions)})}),ne(this,"action",g=>{let v=Ot(g)?g(this.getParams()):g;if(!v)return;let b=v.map(V=>{var E,f;let S=(f=(E=this.machine.implementations)==null?void 0:E.actions)==null?void 0:f[V];return S||wt(`[zag-js] No implementation found for action "${JSON.stringify(V)}"`),S});for(let V of b)V==null||V(this.getParams())}),ne(this,"guard",g=>{var v,b;return Ot(g)?g(this.getParams()):(b=(v=this.machine.implementations)==null?void 0:v.guards)==null?void 0:b[g](this.getParams())}),ne(this,"effect",g=>{let v=Ot(g)?g(this.getParams()):g;if(!v)return;let b=v.map(S=>{var f,C;let E=(C=(f=this.machine.implementations)==null?void 0:f.effects)==null?void 0:C[S];return E||wt(`[zag-js] No implementation found for effect "${JSON.stringify(S)}"`),E}),V=[];for(let S of b){let E=S==null?void 0:S(this.getParams());E&&V.push(E)}return()=>V.forEach(S=>S==null?void 0:S())}),ne(this,"choose",g=>Tr(g).find(v=>{let b=!v.guard;return ti(v.guard)?b=!!this.guard(v.guard):Ot(v.guard)&&(b=v.guard(this.getParams())),b})),ne(this,"subscribe",g=>(this.subscriptions.push(g),()=>{let v=this.subscriptions.indexOf(g);v>-1&&this.subscriptions.splice(v,1)})),ne(this,"status",vr.NotStarted),ne(this,"publish",()=>{this.callTrackers(),this.subscriptions.forEach(g=>g(this.service))}),ne(this,"trackers",[]),ne(this,"setupTrackers",()=>{var g,v;(v=(g=this.machine).watch)==null||v.call(g,this.getParams())}),ne(this,"callTrackers",()=>{this.trackers.forEach(({deps:g,fn:v})=>{let b=g.map(V=>V());he(v.prev,b)||(v(),v.prev=b)})}),ne(this,"getParams",()=>({state:this.getState(),context:this.context,event:this.getEvent(),prop:this.prop,send:this.send,action:this.action,guard:this.guard,track:(g,v)=>{v.prev=g.map(b=>b()),this.trackers.push({deps:g,fn:v})},refs:this.refs,computed:this.computed,flush:xg,scope:this.scope,choose:this.choose})),this.userPropsRef={current:t};let{id:n,ids:r,getRootNode:i}=St(t);this.scope=$g({id:n,ids:r,getRootNode:i});let s=g=>{var V,S;let v=St(this.userPropsRef.current);return((S=(V=e.props)==null?void 0:V.call(e,{props:Gn(v),scope:this.scope}))!=null?S:v)[g]};this.prop=s;let o=(h=e.context)==null?void 0:h.call(e,{prop:s,bindable:oi,scope:this.scope,flush(g){queueMicrotask(g)},getContext(){return a},getComputed(){return l},getRefs(){return c},getEvent:this.getEvent.bind(this)});o&&Object.values(o).forEach(g=>{let v=xa(g.ref,()=>this.notify());this.cleanups.push(v)});let a={get(g){return o==null?void 0:o[g].get()},set(g,v){o==null||o[g].set(v)},initial(g){return o==null?void 0:o[g].initial},hash(g){let v=o==null?void 0:o[g].get();return o==null?void 0:o[g].hash(v)}};this.context=a;let l=g=>{var v,b;return(b=(v=e.computed)==null?void 0:v[g]({context:a,event:this.getEvent(),prop:s,refs:this.refs,scope:this.scope,computed:l}))!=null?b:{}};this.computed=l;let c=sf((d=(p=e.refs)==null?void 0:p.call(e,{prop:s,context:a}))!=null?d:{});this.refs=c;let u=oi(()=>({defaultValue:e.initialState({prop:s}),onChange:(g,v)=>{var V,S,E,f;if(v){let C=this.effects.get(v);C==null||C(),this.effects.delete(v)}v&&this.action((V=this.getStateConfig(v))==null?void 0:V.exit),this.action((S=this.transition)==null?void 0:S.actions);let b=this.effect((E=this.getStateConfig(g))==null?void 0:E.effects);if(b&&this.effects.set(g,b),v===Vs){this.action(e.entry);let C=this.effect(e.effects);C&&this.effects.set(Vs,C)}this.action((f=this.getStateConfig(g))==null?void 0:f.entry)}}));this.state=u,this.cleanups.push(xa(this.state.ref,()=>this.notify()))}updateProps(e){let t=this.userPropsRef.current;this.userPropsRef.current=()=>{let n=St(t),r=St(e);return ml(n,r)},this.notify()}start(){this.status=vr.Started,this.debug("initializing..."),this.state.invoke(this.state.initial,Vs),this.setupTrackers()}stop(){this.effects.forEach(e=>e==null?void 0:e()),this.effects.clear(),this.transition=null,this.action(this.machine.exit),this.cleanups.forEach(e=>e()),this.cleanups=[],this.subscriptions=[],this.status=vr.Stopped,this.debug("unmounting...")}get service(){return{state:this.getState(),send:this.send,context:this.context,prop:this.prop,scope:this.scope,refs:this.refs,computed:this.computed,event:this.getEvent(),getStatus:()=>this.status}}},te=class{constructor(e,t){U(this,"el");U(this,"doc");U(this,"machine");U(this,"api");U(this,"init",()=>{this.render(),this.machine.subscribe(()=>{this.api=this.initApi(),this.render()}),this.machine.start()});U(this,"destroy",()=>{this.machine.stop()});U(this,"spreadProps",(e,t)=>{rf(e,t,this.machine.scope.id)});U(this,"updateProps",e=>{this.machine.updateProps(e)});if(!e)throw new Error("Root element not found");this.el=e,this.doc=document,this.machine=this.initMachine(t),this.api=this.initApi()}}});var vl={};Oe(vl,{Accordion:()=>Ef});function gf(e,t){let{send:n,context:r,prop:i,scope:s,computed:o}=e,a=r.get("focusedValue"),l=r.get("value"),c=i("multiple");function u(p){let d=p;!c&&d.length>1&&(d=[d[0]]),n({type:"VALUE.SET",value:d})}function h(p){var d;return{expanded:l.includes(p.value),focused:a===p.value,disabled:!!((d=p.disabled)!=null?d:i("disabled"))}}return{focusedValue:a,value:l,setValue:u,getItemState:h,getRootProps(){return t.element(y(m({},Or.root.attrs),{dir:i("dir"),id:bi(s),"data-orientation":i("orientation")}))},getItemProps(p){let d=h(p);return t.element(y(m({},Or.item.attrs),{dir:i("dir"),id:af(s,p.value),"data-state":d.expanded?"open":"closed","data-focus":T(d.focused),"data-disabled":T(d.disabled),"data-orientation":i("orientation")}))},getItemContentProps(p){let d=h(p);return t.element(y(m({},Or.itemContent.attrs),{dir:i("dir"),role:"region",id:Xs(s,p.value),"aria-labelledby":Ei(s,p.value),hidden:!d.expanded,"data-state":d.expanded?"open":"closed","data-disabled":T(d.disabled),"data-focus":T(d.focused),"data-orientation":i("orientation")}))},getItemIndicatorProps(p){let d=h(p);return t.element(y(m({},Or.itemIndicator.attrs),{dir:i("dir"),"aria-hidden":!0,"data-state":d.expanded?"open":"closed","data-disabled":T(d.disabled),"data-focus":T(d.focused),"data-orientation":i("orientation")}))},getItemTriggerProps(p){let{value:d}=p,g=h(p);return t.button(y(m({},Or.itemTrigger.attrs),{type:"button",dir:i("dir"),id:Ei(s,d),"aria-controls":Xs(s,d),"data-controls":Xs(s,d),"aria-expanded":g.expanded,disabled:g.disabled,"data-orientation":i("orientation"),"aria-disabled":g.disabled,"data-state":g.expanded?"open":"closed","data-ownedby":bi(s),onFocus(){g.disabled||n({type:"TRIGGER.FOCUS",value:d})},onBlur(){g.disabled||n({type:"TRIGGER.BLUR"})},onClick(v){g.disabled||(Wt()&&v.currentTarget.focus(),n({type:"TRIGGER.CLICK",value:d}))},onKeyDown(v){if(v.defaultPrevented||g.disabled)return;let b={ArrowDown(){o("isHorizontal")||n({type:"GOTO.NEXT",value:d})},ArrowUp(){o("isHorizontal")||n({type:"GOTO.PREV",value:d})},ArrowRight(){o("isHorizontal")&&n({type:"GOTO.NEXT",value:d})},ArrowLeft(){o("isHorizontal")&&n({type:"GOTO.PREV",value:d})},Home(){n({type:"GOTO.FIRST",value:d})},End(){n({type:"GOTO.LAST",value:d})}},V=ve(v,{dir:i("dir"),orientation:i("orientation")}),S=b[V];S&&(S(v),v.preventDefault())}}))}}}var of,Or,bi,af,Xs,Ei,lf,Ci,cf,uf,df,hf,ff,pf,mf,vf,RI,yf,DI,bf,Ef,yl=fe(()=>{"use strict";me();of=Z("accordion").parts("root","item","itemTrigger","itemContent","itemIndicator"),Or=of.build(),bi=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`accordion:${e.id}`},af=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.item)==null?void 0:r.call(n,t))!=null?i:`accordion:${e.id}:item:${t}`},Xs=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemContent)==null?void 0:r.call(n,t))!=null?i:`accordion:${e.id}:content:${t}`},Ei=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemTrigger)==null?void 0:r.call(n,t))!=null?i:`accordion:${e.id}:trigger:${t}`},lf=e=>e.getById(bi(e)),Ci=e=>{let n=`[data-controls][data-ownedby='${CSS.escape(bi(e))}']:not([disabled])`;return dt(lf(e),n)},cf=e=>Ke(Ci(e)),uf=e=>nt(Ci(e)),df=(e,t)=>$n(Ci(e),Ei(e,t)),hf=(e,t)=>_n(Ci(e),Ei(e,t));({and:ff,not:pf}=ye()),mf={props({props:e}){return m({collapsible:!1,multiple:!1,orientation:"vertical",defaultValue:[]},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{focusedValue:t(()=>({defaultValue:null,sync:!0,onChange(n){var r;(r=e("onFocusChange"))==null||r({value:n})}})),value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(n){var r;(r=e("onValueChange"))==null||r({value:n})}}))}},computed:{isHorizontal:({prop:e})=>e("orientation")==="horizontal"},on:{"VALUE.SET":{actions:["setValue"]}},states:{idle:{on:{"TRIGGER.FOCUS":{target:"focused",actions:["setFocusedValue"]}}},focused:{on:{"GOTO.NEXT":{actions:["focusNextTrigger"]},"GOTO.PREV":{actions:["focusPrevTrigger"]},"TRIGGER.CLICK":[{guard:ff("isExpanded","canToggle"),actions:["collapse"]},{guard:pf("isExpanded"),actions:["expand"]}],"GOTO.FIRST":{actions:["focusFirstTrigger"]},"GOTO.LAST":{actions:["focusLastTrigger"]},"TRIGGER.BLUR":{target:"idle",actions:["clearFocusedValue"]}}}},implementations:{guards:{canToggle:({prop:e})=>!!e("collapsible")||!!e("multiple"),isExpanded:({context:e,event:t})=>e.get("value").includes(t.value)},actions:{collapse({context:e,prop:t,event:n}){let r=t("multiple")?ht(e.get("value"),n.value):[];e.set("value",r)},expand({context:e,prop:t,event:n}){let r=t("multiple")?rt(e.get("value"),n.value):[n.value];e.set("value",r)},focusFirstTrigger({scope:e}){var t;(t=cf(e))==null||t.focus()},focusLastTrigger({scope:e}){var t;(t=uf(e))==null||t.focus()},focusNextTrigger({context:e,scope:t}){let n=e.get("focusedValue");if(!n)return;let r=df(t,n);r==null||r.focus()},focusPrevTrigger({context:e,scope:t}){let n=e.get("focusedValue");if(!n)return;let r=hf(t,n);r==null||r.focus()},setFocusedValue({context:e,event:t}){e.set("focusedValue",t.value)},clearFocusedValue({context:e}){e.set("focusedValue",null)},setValue({context:e,event:t}){e.set("value",t.value)},coarseValue({context:e,prop:t}){!t("multiple")&&e.get("value").length>1&&(wt("The value of accordion should be a single value when multiple is false."),e.set("value",[e.get("value")[0]]))}}}},vf=G()(["collapsible","dir","disabled","getRootNode","id","ids","multiple","onFocusChange","onValueChange","orientation","value","defaultValue"]),RI=B(vf),yf=G()(["value","disabled"]),DI=B(yf),bf=class extends te{initMachine(e){return new ee(mf,e)}initApi(){return gf(this.machine.service,Q)}render(){var r;let e=(r=this.el.querySelector('[data-scope="accordion"][data-part="root"]'))!=null?r:this.el;this.spreadProps(e,this.api.getRootProps());let t=this.getItemsList(),n=e.querySelectorAll('[data-scope="accordion"][data-part="item"]');for(let i=0;i{var o,a;let i=x(e,"onValueChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,value:(o=r.value)!=null?o:null});let s=x(e,"onValueChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,value:(a=r.value)!=null?a:null}}))},onFocusChange:r=>{var o,a;let i=x(e,"onFocusChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,value:(o=r.value)!=null?o:null});let s=x(e,"onFocusChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,value:(a=r.value)!=null?a:null}}))}}));n.init(),this.accordion=n,this.onSetValue=r=>{let{value:i}=r.detail;n.api.setValue(i)},e.addEventListener("phx:accordion:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("accordion_set_value",r=>{let i=r.accordion_id;i&&!(e.id===i||e.id===`accordion:${i}`)||n.api.setValue(r.value)})),this.handlers.push(this.handleEvent("accordion_value",()=>{this.pushEvent("accordion_value_response",{value:n.api.value})})),this.handlers.push(this.handleEvent("accordion_focused_value",()=>{this.pushEvent("accordion_focused_value_response",{value:n.api.focusedValue})}))},updated(){var t,n,r,i;let e=O(this.el,"controlled");(i=this.accordion)==null||i.updateProps(y(m({id:this.el.id},e?{value:Y(this.el,"value")}:{defaultValue:(r=(n=(t=this.accordion)==null?void 0:t.api)==null?void 0:n.value)!=null?r:Y(this.el,"defaultValue")}),{collapsible:O(this.el,"collapsible"),multiple:O(this.el,"multiple"),orientation:x(this.el,"orientation",["horizontal","vertical"]),dir:Gt(this.el)}))},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:accordion:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.accordion)==null||e.destroy()}}});function Cf(e){return!(e.metaKey||!Nn()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Tf(e,t,n){let r=n?K(n):null,i=oe(r);return e=e||r instanceof i.HTMLInputElement&&!If.has(r==null?void 0:r.type)||r instanceof i.HTMLTextAreaElement||r instanceof i.HTMLElement&&r.isContentEditable,!(e&&t==="keyboard"&&n instanceof i.KeyboardEvent&&!Reflect.has(Of,n.key))}function Oi(e,t){for(let n of Zs)n(e,t)}function Ti(e){un=!0,Cf(e)&&(dn="keyboard",Oi("keyboard",e))}function je(e){dn="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(un=!0,Oi("pointer",e))}function bl(e){Ga(e)&&(un=!0,dn="virtual")}function El(e){let t=K(e);t===oe(t)||t===we(t)||(!un&&!Js&&(dn="virtual",Oi("virtual",e)),un=!1,Js=!1)}function Cl(){un=!1,Js=!0}function Sf(e){if(typeof window=="undefined"||Ii.get(oe(e)))return;let t=oe(e),n=we(e),r=t.HTMLElement.prototype.focus;function i(){dn="virtual",Oi("virtual",null),un=!0,r.apply(this,arguments)}try{Object.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,value:i})}catch(s){}n.addEventListener("keydown",Ti,!0),n.addEventListener("keyup",Ti,!0),n.addEventListener("click",bl,!0),t.addEventListener("focus",El,!0),t.addEventListener("blur",Cl,!1),typeof t.PointerEvent!="undefined"?(n.addEventListener("pointerdown",je,!0),n.addEventListener("pointermove",je,!0),n.addEventListener("pointerup",je,!0)):(n.addEventListener("mousedown",je,!0),n.addEventListener("mousemove",je,!0),n.addEventListener("mouseup",je,!0)),t.addEventListener("beforeunload",()=>{Pf(e)},{once:!0}),Ii.set(t,{focus:r})}function Kn(){return dn==="keyboard"}function Si(e={}){let{isTextInput:t,autoFocus:n,onChange:r,root:i}=e;Sf(i),r==null||r({isFocusVisible:n||Kn(),modality:dn});let s=(o,a)=>{Tf(!!t,o,a)&&(r==null||r({isFocusVisible:Kn(),modality:o}))};return Zs.add(s),()=>{Zs.delete(s)}}var If,dn,Zs,Ii,un,Js,Of,Pf,zs=fe(()=>{"use strict";me();If=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);dn=null,Zs=new Set,Ii=new Map,un=!1,Js=!1,Of={Tab:!0,Escape:!0};Pf=(e,t)=>{let n=oe(e),r=we(e),i=Ii.get(n);if(i){try{Object.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,value:i.focus})}catch(s){}r.removeEventListener("keydown",Ti,!0),r.removeEventListener("keyup",Ti,!0),r.removeEventListener("click",bl,!0),n.removeEventListener("focus",El,!0),n.removeEventListener("blur",Cl,!1),typeof n.PointerEvent!="undefined"?(r.removeEventListener("pointerdown",je,!0),r.removeEventListener("pointermove",je,!0),r.removeEventListener("pointerup",je,!0)):(r.removeEventListener("mousedown",je,!0),r.removeEventListener("mousemove",je,!0),r.removeEventListener("mouseup",je,!0)),Ii.delete(n)}}});var Sl={};Oe(Sl,{Checkbox:()=>Lf});function kf(e,t){let{send:n,context:r,prop:i,computed:s,scope:o}=e,a=!!i("disabled"),l=!!i("readOnly"),c=!!i("required"),u=!!i("invalid"),h=!a&&r.get("focused"),p=!a&&r.get("focusVisible"),d=s("checked"),g=s("indeterminate"),v=r.get("checked"),b={"data-active":T(r.get("active")),"data-focus":T(h),"data-focus-visible":T(p),"data-readonly":T(l),"data-hover":T(r.get("hovered")),"data-disabled":T(a),"data-state":g?"indeterminate":d?"checked":"unchecked","data-invalid":T(u),"data-required":T(c)};return{checked:d,disabled:a,indeterminate:g,focused:h,checkedState:v,setChecked(V){n({type:"CHECKED.SET",checked:V,isTrusted:!1})},toggleChecked(){n({type:"CHECKED.TOGGLE",checked:d,isTrusted:!1})},getRootProps(){return t.label(y(m(m({},Pi.root.attrs),b),{dir:i("dir"),id:Ol(o),htmlFor:Qs(o),onPointerMove(){a||n({type:"CONTEXT.SET",context:{hovered:!0}})},onPointerLeave(){a||n({type:"CONTEXT.SET",context:{hovered:!1}})},onClick(V){K(V)===Sr(o)&&V.stopPropagation()}}))},getLabelProps(){return t.element(y(m(m({},Pi.label.attrs),b),{dir:i("dir"),id:Il(o)}))},getControlProps(){return t.element(y(m(m({},Pi.control.attrs),b),{dir:i("dir"),id:Vf(o),"aria-hidden":!0}))},getIndicatorProps(){return t.element(y(m(m({},Pi.indicator.attrs),b),{dir:i("dir"),hidden:!g&&!d}))},getHiddenInputProps(){return t.input({id:Qs(o),type:"checkbox",required:i("required"),defaultChecked:d,disabled:a,"aria-labelledby":Il(o),"aria-invalid":u,name:i("name"),form:i("form"),value:i("value"),style:Hn,onFocus(){let V=Kn();n({type:"CONTEXT.SET",context:{focused:!0,focusVisible:V}})},onBlur(){n({type:"CONTEXT.SET",context:{focused:!1,focusVisible:!1}})},onClick(V){if(l){V.preventDefault();return}let S=V.currentTarget.checked;n({type:"CHECKED.SET",checked:S,isTrusted:!0})}})}}}function wi(e){return e==="indeterminate"}function Af(e){return wi(e)?!1:!!e}var wf,Pi,Ol,Il,Vf,Qs,xf,Sr,Tl,Nf,Rf,BI,Df,Lf,Pl=fe(()=>{"use strict";zs();me();wf=Z("checkbox").parts("root","label","control","indicator"),Pi=wf.build(),Ol=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`checkbox:${e.id}`},Il=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`checkbox:${e.id}:label`},Vf=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`checkbox:${e.id}:control`},Qs=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.hiddenInput)!=null?n:`checkbox:${e.id}:input`},xf=e=>e.getById(Ol(e)),Sr=e=>e.getById(Qs(e));({not:Tl}=ye()),Nf={props({props:e}){var t;return y(m({value:"on"},e),{defaultChecked:(t=e.defaultChecked)!=null?t:!1})},initialState(){return"ready"},context({prop:e,bindable:t}){return{checked:t(()=>({defaultValue:e("defaultChecked"),value:e("checked"),onChange(n){var r;(r=e("onCheckedChange"))==null||r({checked:n})}})),fieldsetDisabled:t(()=>({defaultValue:!1})),focusVisible:t(()=>({defaultValue:!1})),active:t(()=>({defaultValue:!1})),focused:t(()=>({defaultValue:!1})),hovered:t(()=>({defaultValue:!1}))}},watch({track:e,context:t,prop:n,action:r}){e([()=>n("disabled")],()=>{r(["removeFocusIfNeeded"])}),e([()=>t.get("checked")],()=>{r(["syncInputElement"])})},effects:["trackFormControlState","trackPressEvent","trackFocusVisible"],on:{"CHECKED.TOGGLE":[{guard:Tl("isTrusted"),actions:["toggleChecked","dispatchChangeEvent"]},{actions:["toggleChecked"]}],"CHECKED.SET":[{guard:Tl("isTrusted"),actions:["setChecked","dispatchChangeEvent"]},{actions:["setChecked"]}],"CONTEXT.SET":{actions:["setContext"]}},computed:{indeterminate:({context:e})=>wi(e.get("checked")),checked:({context:e})=>Af(e.get("checked")),disabled:({context:e,prop:t})=>!!t("disabled")||e.get("fieldsetDisabled")},states:{ready:{}},implementations:{guards:{isTrusted:({event:e})=>!!e.isTrusted},effects:{trackPressEvent({context:e,computed:t,scope:n}){if(!t("disabled"))return pi({pointerNode:xf(n),keyboardNode:Sr(n),isValidKey:r=>r.key===" ",onPress:()=>e.set("active",!1),onPressStart:()=>e.set("active",!0),onPressEnd:()=>e.set("active",!1)})},trackFocusVisible({computed:e,scope:t}){var n;if(!e("disabled"))return Si({root:(n=t.getRootNode)==null?void 0:n.call(t)})},trackFormControlState({context:e,scope:t}){return Rn(Sr(t),{onFieldsetDisabledChange(n){e.set("fieldsetDisabled",n)},onFormReset(){e.set("checked",e.initial("checked"))}})}},actions:{setContext({context:e,event:t}){for(let n in t.context)e.set(n,t.context[n])},syncInputElement({context:e,computed:t,scope:n}){let r=Sr(n);r&&(Cr(r,t("checked")),r.indeterminate=wi(e.get("checked")))},removeFocusIfNeeded({context:e,prop:t}){t("disabled")&&e.get("focused")&&(e.set("focused",!1),e.set("focusVisible",!1))},setChecked({context:e,event:t}){e.set("checked",t.checked)},toggleChecked({context:e,computed:t}){let n=wi(t("checked"))?!0:!t("checked");e.set("checked",n)},dispatchChangeEvent({computed:e,scope:t}){queueMicrotask(()=>{let n=Sr(t);ui(n,{checked:e("checked")})})}}}};Rf=G()(["defaultChecked","checked","dir","disabled","form","getRootNode","id","ids","invalid","name","onCheckedChange","readOnly","required","value"]),BI=B(Rf),Df=class extends te{initMachine(e){return new ee(Nf,e)}initApi(){return kf(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="checkbox"][data-part="root"]');if(!e)return;this.spreadProps(e,this.api.getRootProps());let t=e.querySelector(':scope > [data-scope="checkbox"][data-part="hidden-input"]');t&&this.spreadProps(t,this.api.getHiddenInputProps());let n=e.querySelector(':scope > [data-scope="checkbox"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps());let r=e.querySelector(':scope > [data-scope="checkbox"][data-part="control"]');if(r){this.spreadProps(r,this.api.getControlProps());let i=r.querySelector(':scope > [data-scope="checkbox"][data-part="indicator"]');i&&this.spreadProps(i,this.api.getIndicatorProps())}}},Lf={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=new Df(e,y(m({id:e.id},O(e,"controlled")?{checked:O(e,"checked")}:{defaultChecked:O(e,"defaultChecked")}),{disabled:O(e,"disabled"),name:x(e,"name"),form:x(e,"form"),value:x(e,"value"),dir:Gt(e),invalid:O(e,"invalid"),required:O(e,"required"),readOnly:O(e,"readOnly"),onCheckedChange:r=>{let i=x(e,"onCheckedChange");i&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(i,{checked:r.checked,id:e.id});let s=x(e,"onCheckedChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{value:r,id:e.id}}))}}));n.init(),this.checkbox=n,this.onSetChecked=r=>{let{checked:i}=r.detail;n.api.setChecked(i)},e.addEventListener("phx:checkbox:set-checked",this.onSetChecked),this.onToggleChecked=()=>{n.api.toggleChecked()},e.addEventListener("phx:checkbox:toggle-checked",this.onToggleChecked),this.handlers=[],this.handlers.push(this.handleEvent("checkbox_set_checked",r=>{let i=r.id;i&&i!==e.id||n.api.setChecked(r.checked)})),this.handlers.push(this.handleEvent("checkbox_toggle_checked",r=>{let i=r.id;i&&i!==e.id||n.api.toggleChecked()})),this.handlers.push(this.handleEvent("checkbox_checked",()=>{this.pushEvent("checkbox_checked_response",{value:n.api.checked})})),this.handlers.push(this.handleEvent("checkbox_focused",()=>{this.pushEvent("checkbox_focused_response",{value:n.api.focused})})),this.handlers.push(this.handleEvent("checkbox_disabled",()=>{this.pushEvent("checkbox_disabled_response",{value:n.api.disabled})}))},updated(){var e;(e=this.checkbox)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{checked:O(this.el,"checked")}:{defaultChecked:O(this.el,"defaultChecked")}),{disabled:O(this.el,"disabled"),name:x(this.el,"name"),form:x(this.el,"form"),value:x(this.el,"value"),dir:Gt(this.el),invalid:O(this.el,"invalid"),required:O(this.el,"required"),readOnly:O(this.el,"readOnly"),label:x(this.el,"label")}))},destroyed(){var e;if(this.onSetChecked&&this.el.removeEventListener("phx:checkbox:set-checked",this.onSetChecked),this.onToggleChecked&&this.el.removeEventListener("phx:checkbox:toggle-checked",this.onToggleChecked),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.checkbox)==null||e.destroy()}}});var wl={};Oe(wl,{Clipboard:()=>Xf});function Bf(e,t){let n=e.createElement("pre");return Object.assign(n.style,{width:"1px",height:"1px",position:"fixed",top:"5px"}),n.textContent=t,n}function Gf(e){let n=oe(e).getSelection();if(n==null)return Promise.reject(new Error);n.removeAllRanges();let r=e.ownerDocument,i=r.createRange();return i.selectNodeContents(e),n.addRange(i),r.execCommand("copy"),n.removeAllRanges(),Promise.resolve()}function Uf(e,t){var i;let n=e.defaultView||window;if(((i=n.navigator.clipboard)==null?void 0:i.writeText)!==void 0)return n.navigator.clipboard.writeText(t);if(!e.body)return Promise.reject(new Error);let r=Bf(e,t);return e.body.appendChild(r),Gf(r),e.body.removeChild(r),Promise.resolve()}function qf(e,t){let{state:n,send:r,context:i,scope:s}=e,o=n.matches("copied");return{copied:o,value:i.get("value"),setValue(a){r({type:"VALUE.SET",value:a})},copy(){r({type:"COPY"})},getRootProps(){return t.element(y(m({},Yn.root.attrs),{"data-copied":T(o),id:Mf(s)}))},getLabelProps(){return t.label(y(m({},Yn.label.attrs),{htmlFor:eo(s),"data-copied":T(o),id:$f(s)}))},getControlProps(){return t.element(y(m({},Yn.control.attrs),{"data-copied":T(o)}))},getInputProps(){return t.input(y(m({},Yn.input.attrs),{defaultValue:i.get("value"),"data-copied":T(o),readOnly:!0,"data-readonly":"true",id:eo(s),onFocus(a){a.currentTarget.select()},onCopy(){r({type:"INPUT.COPY"})}}))},getTriggerProps(){return t.button(y(m({},Yn.trigger.attrs),{type:"button","aria-label":o?"Copied to clipboard":"Copy to clipboard","data-copied":T(o),onClick(){r({type:"COPY"})}}))},getIndicatorProps(a){return t.element(y(m({},Yn.indicator.attrs),{hidden:a.copied!==o}))}}}var Ff,Yn,Mf,eo,$f,_f,Hf,Wf,Kf,WI,Yf,KI,jf,Xf,Vl=fe(()=>{"use strict";me();Ff=Z("clipboard").parts("root","control","trigger","indicator","input","label"),Yn=Ff.build(),Mf=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`clip:${e.id}`},eo=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.input)!=null?n:`clip:${e.id}:input`},$f=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`clip:${e.id}:label`},_f=e=>e.getById(eo(e)),Hf=(e,t)=>Uf(e.getDoc(),t);Wf={props({props:e}){return m({timeout:3e3,defaultValue:""},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(n){var r;(r=e("onValueChange"))==null||r({value:n})}}))}},watch({track:e,context:t,action:n}){e([()=>t.get("value")],()=>{n(["syncInputElement"])})},on:{"VALUE.SET":{actions:["setValue"]},COPY:{target:"copied",actions:["copyToClipboard","invokeOnCopy"]}},states:{idle:{on:{"INPUT.COPY":{target:"copied",actions:["invokeOnCopy"]}}},copied:{effects:["waitForTimeout"],on:{"COPY.DONE":{target:"idle"},COPY:{target:"copied",actions:["copyToClipboard","invokeOnCopy"]},"INPUT.COPY":{actions:["invokeOnCopy"]}}}},implementations:{effects:{waitForTimeout({prop:e,send:t}){return Un(()=>{t({type:"COPY.DONE"})},e("timeout"))}},actions:{setValue({context:e,event:t}){e.set("value",t.value)},copyToClipboard({context:e,scope:t}){Hf(t,e.get("value"))},invokeOnCopy({prop:e}){var t;(t=e("onStatusChange"))==null||t({copied:!0})},syncInputElement({context:e,scope:t}){let n=_f(t);n&&xt(n,e.get("value"))}}}},Kf=G()(["getRootNode","id","ids","value","defaultValue","timeout","onStatusChange","onValueChange"]),WI=B(Kf),Yf=G()(["copied"]),KI=B(Yf),jf=class extends te{initMachine(e){return new ee(Wf,e)}initApi(){return qf(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="clipboard"][data-part="root"]');if(e){this.spreadProps(e,this.api.getRootProps());let t=e.querySelector('[data-scope="clipboard"][data-part="label"]');t&&this.spreadProps(t,this.api.getLabelProps());let n=e.querySelector('[data-scope="clipboard"][data-part="control"]');if(n){this.spreadProps(n,this.api.getControlProps());let r=n.querySelector('[data-scope="clipboard"][data-part="input"]');if(r){let s=m({},this.api.getInputProps()),o=this.el.dataset.inputAriaLabel;o&&(s["aria-label"]=o),this.spreadProps(r,s)}let i=n.querySelector('[data-scope="clipboard"][data-part="trigger"]');if(i){let s=m({},this.api.getTriggerProps()),o=this.el.dataset.triggerAriaLabel;o&&(s["aria-label"]=o),this.spreadProps(i,s)}}}}},Xf={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=this.liveSocket,r=new jf(e,y(m({id:e.id,timeout:Se(e,"timeout")},O(e,"controlled")?{value:x(e,"value")}:{defaultValue:x(e,"defaultValue")}),{onValueChange:i=>{var o;let s=x(e,"onValueChange");s&&n.main.isConnected()&&t(s,{id:e.id,value:(o=i.value)!=null?o:null})},onStatusChange:i=>{let s=x(e,"onStatusChange");s&&n.main.isConnected()&&t(s,{id:e.id,copied:i.copied});let o=x(e,"onStatusChangeClient");o&&e.dispatchEvent(new CustomEvent(o,{bubbles:!0}))}}));r.init(),this.clipboard=r,this.onCopy=()=>{r.api.copy()},e.addEventListener("phx:clipboard:copy",this.onCopy),this.onSetValue=i=>{let{value:s}=i.detail;r.api.setValue(s)},e.addEventListener("phx:clipboard:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("clipboard_copy",i=>{let s=i.clipboard_id;s&&s!==e.id||r.api.copy()})),this.handlers.push(this.handleEvent("clipboard_set_value",i=>{let s=i.clipboard_id;s&&s!==e.id||r.api.setValue(i.value)})),this.handlers.push(this.handleEvent("clipboard_copied",()=>{this.pushEvent("clipboard_copied_response",{value:r.api.copied})}))},updated(){var e;(e=this.clipboard)==null||e.updateProps(y(m({id:this.el.id,timeout:Se(this.el,"timeout")},O(this.el,"controlled")?{value:x(this.el,"value")}:{defaultValue:x(this.el,"value")}),{dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onCopy&&this.el.removeEventListener("phx:clipboard:copy",this.onCopy),this.onSetValue&&this.el.removeEventListener("phx:clipboard:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.clipboard)==null||e.destroy()}}});var xl={};Oe(xl,{Collapsible:()=>rp});function Qf(e,t){let{state:n,send:r,context:i,scope:s,prop:o}=e,a=n.matches("open")||n.matches("closing"),l=n.matches("open"),c=n.matches("closed"),{width:u,height:h}=i.get("size"),p=!!o("disabled"),d=o("collapsedHeight"),g=o("collapsedWidth"),v=d!=null,b=g!=null,V=v||b,S=!i.get("initial")&&l;return{disabled:p,visible:a,open:l,measureSize(){r({type:"size.measure"})},setOpen(E){n.matches("open")!==E&&r({type:E?"open":"close"})},getRootProps(){return t.element(y(m({},Vi.root.attrs),{"data-state":l?"open":"closed",dir:o("dir"),id:Jf(s)}))},getContentProps(){return t.element(y(m({},Vi.content.attrs),{id:to(s),"data-collapsible":"","data-state":S?void 0:l?"open":"closed","data-disabled":T(p),"data-has-collapsed-size":T(V),hidden:!a&&!V,dir:o("dir"),style:m(m({"--height":Ae(h),"--width":Ae(u),"--collapsed-height":Ae(d),"--collapsed-width":Ae(g)},c&&v&&{overflow:"hidden",minHeight:Ae(d),maxHeight:Ae(d)}),c&&b&&{overflow:"hidden",minWidth:Ae(g),maxWidth:Ae(g)})}))},getTriggerProps(){return t.element(y(m({},Vi.trigger.attrs),{id:zf(s),dir:o("dir"),type:"button","data-state":l?"open":"closed","data-disabled":T(p),"aria-controls":to(s),"aria-expanded":a||!1,onClick(E){E.defaultPrevented||p||r({type:l?"close":"open"})}}))},getIndicatorProps(){return t.element(y(m({},Vi.indicator.attrs),{dir:o("dir"),"data-state":l?"open":"closed","data-disabled":T(p)}))}}}var Zf,Vi,Jf,to,zf,Pr,ep,tp,ZI,np,rp,kl=fe(()=>{"use strict";me();Zf=Z("collapsible").parts("root","trigger","content","indicator"),Vi=Zf.build(),Jf=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`collapsible:${e.id}`},to=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`collapsible:${e.id}:content`},zf=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`collapsible:${e.id}:trigger`},Pr=e=>e.getById(to(e));ep={initialState({prop:e}){return e("open")||e("defaultOpen")?"open":"closed"},context({bindable:e}){return{size:e(()=>({defaultValue:{height:0,width:0},sync:!0})),initial:e(()=>({defaultValue:!1}))}},refs(){return{cleanup:void 0,stylesRef:void 0}},watch({track:e,prop:t,action:n}){e([()=>t("open")],()=>{n(["setInitial","computeSize","toggleVisibility"])})},exit:["cleanupNode"],states:{closed:{effects:["trackTabbableElements"],on:{"controlled.open":{target:"open"},open:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitial","computeSize","invokeOnOpen"]}]}},closing:{effects:["trackExitAnimation"],on:{"controlled.close":{target:"closed"},"controlled.open":{target:"open"},open:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitial","invokeOnOpen"]}],close:[{guard:"isOpenControlled",actions:["invokeOnExitComplete"]},{target:"closed",actions:["setInitial","computeSize","invokeOnExitComplete"]}],"animation.end":{target:"closed",actions:["invokeOnExitComplete","clearInitial"]}}},open:{effects:["trackEnterAnimation"],on:{"controlled.close":{target:"closing"},close:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closing",actions:["setInitial","computeSize","invokeOnClose"]}],"size.measure":{actions:["measureSize"]},"animation.end":{actions:["clearInitial"]}}}},implementations:{guards:{isOpenControlled:({prop:e})=>e("open")!=null},effects:{trackEnterAnimation:({send:e,scope:t})=>{let n,r=H(()=>{let i=Pr(t);if(!i)return;let s=qt(i).animationName;if(!s||s==="none"){e({type:"animation.end"});return}let a=l=>{K(l)===i&&e({type:"animation.end"})};i.addEventListener("animationend",a),n=()=>{i.removeEventListener("animationend",a)}});return()=>{r(),n==null||n()}},trackExitAnimation:({send:e,scope:t})=>{let n,r=H(()=>{let i=Pr(t);if(!i)return;let s=qt(i).animationName;if(!s||s==="none"){e({type:"animation.end"});return}let a=c=>{K(c)===i&&e({type:"animation.end"})};i.addEventListener("animationend",a);let l=cn(i,{animationFillMode:"forwards"});n=()=>{i.removeEventListener("animationend",a),an(()=>l())}});return()=>{r(),n==null||n()}},trackTabbableElements:({scope:e,prop:t})=>{if(!t("collapsedHeight")&&!t("collapsedWidth"))return;let n=Pr(e);if(!n)return;let r=()=>{let a=on(n).map(l=>za(l,"inert",""));return()=>{a.forEach(l=>l())}},i=r(),s=ja(n,{callback(){i(),i=r()}});return()=>{i(),s()}}},actions:{setInitial:({context:e,flush:t})=>{t(()=>{e.set("initial",!0)})},clearInitial:({context:e})=>{e.set("initial",!1)},cleanupNode:({refs:e})=>{e.set("stylesRef",null)},measureSize:({context:e,scope:t})=>{let n=Pr(t);if(!n)return;let{height:r,width:i}=n.getBoundingClientRect();e.set("size",{height:r,width:i})},computeSize:({refs:e,scope:t,context:n})=>{var i;(i=e.get("cleanup"))==null||i();let r=H(()=>{let s=Pr(t);if(!s)return;let o=s.hidden;s.style.animationName="none",s.style.animationDuration="0s",s.hidden=!1;let a=s.getBoundingClientRect();n.set("size",{height:a.height,width:a.width}),n.get("initial")&&(s.style.animationName="",s.style.animationDuration=""),s.hidden=o});e.set("cleanup",r)},invokeOnOpen:({prop:e})=>{var t;(t=e("onOpenChange"))==null||t({open:!0})},invokeOnClose:({prop:e})=>{var t;(t=e("onOpenChange"))==null||t({open:!1})},invokeOnExitComplete:({prop:e})=>{var t;(t=e("onExitComplete"))==null||t()},toggleVisibility:({prop:e,send:t})=>{t({type:e("open")?"controlled.open":"controlled.close"})}}}},tp=G()(["dir","disabled","getRootNode","id","ids","collapsedHeight","collapsedWidth","onExitComplete","onOpenChange","defaultOpen","open"]),ZI=B(tp),np=class extends te{initMachine(e){return new ee(ep,e)}initApi(){return Qf(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="collapsible"][data-part="root"]');if(e){this.spreadProps(e,this.api.getRootProps());let t=e.querySelector('[data-scope="collapsible"][data-part="trigger"]');t&&this.spreadProps(t,this.api.getTriggerProps());let n=e.querySelector('[data-scope="collapsible"][data-part="content"]');n&&this.spreadProps(n,this.api.getContentProps())}}},rp={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=new np(e,y(m({id:e.id},O(e,"controlled")?{open:O(e,"open")}:{defaultOpen:O(e,"defaultOpen")}),{disabled:O(e,"disabled"),dir:x(e,"dir",["ltr","rtl"]),onOpenChange:r=>{let i=x(e,"onOpenChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,open:r.open});let s=x(e,"onOpenChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,open:r.open}}))}}));n.init(),this.collapsible=n,this.onSetOpen=r=>{let{open:i}=r.detail;n.api.setOpen(i)},e.addEventListener("phx:collapsible:set-open",this.onSetOpen),this.handlers=[],this.handlers.push(this.handleEvent("collapsible_set_open",r=>{let i=r.collapsible_id;i&&i!==e.id||n.api.setOpen(r.open)})),this.handlers.push(this.handleEvent("collapsible_open",()=>{this.pushEvent("collapsible_open_response",{value:n.api.open})}))},updated(){var e;(e=this.collapsible)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{open:O(this.el,"open")}:{defaultOpen:O(this.el,"defaultOpen")}),{disabled:O(this.el,"disabled"),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onSetOpen&&this.el.removeEventListener("phx:collapsible:set-open",this.onSetOpen),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.collapsible)==null||e.destroy()}}});function wr(e,t,...n){return[...e.slice(0,t),...n,...e.slice(t)]}function xi(e,t,n){t=[...t].sort((i,s)=>i-s);let r=t.map(i=>e[i]);for(let i=t.length-1;i>=0;i--)e=[...e.slice(0,t[i]),...e.slice(t[i]+1)];return n=Math.max(0,n-t.filter(i=>it[n])return 1}return e.length-t.length}function lp(e){return e.sort(Ll)}function cp(e,t){let n;return $e(e,y(m({},t),{onEnter:(r,i)=>{if(t.predicate(r,i))return n=r,"stop"}})),n}function up(e,t){let n=[];return $e(e,{onEnter:(r,i)=>{t.predicate(r,i)&&n.push(r)},getChildren:t.getChildren}),n}function Nl(e,t){let n;return $e(e,{onEnter:(r,i)=>{if(t.predicate(r,i))return n=[...i],"stop"},getChildren:t.getChildren}),n}function dp(e,t){let n=t.initialResult;return $e(e,y(m({},t),{onEnter:(r,i)=>{n=t.nextResult(n,r,i)}})),n}function hp(e,t){return dp(e,y(m({},t),{initialResult:[],nextResult:(n,r,i)=>(n.push(...t.transform(r,i)),n)}))}function gp(e,t){let{predicate:n,create:r,getChildren:i}=t,s=(o,a)=>{let l=i(o,a),c=[];l.forEach((d,g)=>{let v=[...a,g],b=s(d,v);b&&c.push(b)});let u=a.length===0,h=n(o,a),p=c.length>0;return u||h||p?r(o,c,a):null};return s(e,[])||r(e,[],[])}function fp(e,t){let n=[],r=0,i=new Map,s=new Map;return $e(e,{getChildren:t.getChildren,onEnter:(o,a)=>{i.has(o)||i.set(o,r++);let l=t.getChildren(o,a);l.forEach(d=>{s.has(d)||s.set(d,o),i.has(d)||i.set(d,r++)});let c=l.length>0?l.map(d=>i.get(d)):void 0,u=s.get(o),h=u?i.get(u):void 0,p=i.get(o);n.push(y(m({},o),{_children:c,_parent:h,_index:p}))}}),n}function pp(e,t){return{type:"insert",index:e,nodes:t}}function mp(e){return{type:"remove",indexes:e}}function no(){return{type:"replace"}}function Fl(e){return[e.slice(0,-1),e[e.length-1]]}function Ml(e,t,n=new Map){var o;let[r,i]=Fl(e);for(let a=r.length-1;a>=0;a--){let l=r.slice(0,a).join();switch((o=n.get(l))==null?void 0:o.type){case"remove":continue}n.set(l,no())}let s=n.get(r.join());switch(s==null?void 0:s.type){case"remove":n.set(r.join(),{type:"removeThenInsert",removeIndexes:s.indexes,insertIndex:i,insertNodes:t});break;default:n.set(r.join(),pp(i,t))}return n}function $l(e){var r;let t=new Map,n=new Map;for(let i of e){let s=i.slice(0,-1).join(),o=(r=n.get(s))!=null?r:[];o.push(i[i.length-1]),n.set(s,o.sort((a,l)=>a-l))}for(let i of e)for(let s=i.length-2;s>=0;s--){let o=i.slice(0,s).join();t.has(o)||t.set(o,no())}for(let[i,s]of n)t.set(i,mp(s));return t}function vp(e,t){let n=new Map,[r,i]=Fl(e);for(let s=r.length-1;s>=0;s--){let o=r.slice(0,s).join();n.set(o,no())}return n.set(r.join(),{type:"removeThenInsert",removeIndexes:[i],insertIndex:i,insertNodes:[t]}),n}function Ni(e,t,n){return yp(e,y(m({},n),{getChildren:(r,i)=>{let s=i.join(),o=t.get(s);switch(o==null?void 0:o.type){case"replace":case"remove":case"removeThenInsert":case"insert":return n.getChildren(r,i);default:return[]}},transform:(r,i,s)=>{let o=s.join(),a=t.get(o);switch(a==null?void 0:a.type){case"remove":return n.create(r,i.filter((u,h)=>!a.indexes.includes(h)),s);case"removeThenInsert":let l=i.filter((u,h)=>!a.removeIndexes.includes(h)),c=a.removeIndexes.reduce((u,h)=>h{var u,h;let s=[0,...i],o=s.join(),a=t.transform(r,(u=n[o])!=null?u:[],i),l=s.slice(0,-1).join(),c=(h=n[l])!=null?h:[];c.push(a),n[l]=c}})),n[""][0]}function bp(e,t){let{nodes:n,at:r}=t;if(r.length===0)throw new Error("Can't insert nodes at the root");let i=Ml(r,n);return Ni(e,i,t)}function Ep(e,t){if(t.at.length===0)return t.node;let n=vp(t.at,t.node);return Ni(e,n,t)}function Cp(e,t){if(t.indexPaths.length===0)return e;for(let r of t.indexPaths)if(r.length===0)throw new Error("Can't remove the root node");let n=$l(t.indexPaths);return Ni(e,n,t)}function Ip(e,t){if(t.indexPaths.length===0)return e;for(let s of t.indexPaths)if(s.length===0)throw new Error("Can't move the root node");if(t.to.length===0)throw new Error("Can't move nodes to the root");let n=ap(t.indexPaths),r=n.map(s=>Dl(e,s,t)),i=Ml(t.to,r,$l(n));return Ni(e,i,t)}function $e(e,t){let{onEnter:n,onLeave:r,getChildren:i}=t,s=[],o=[{node:e}],a=t.reuseIndexPath?()=>s:()=>s.slice();for(;o.length>0;){let l=o[o.length-1];if(l.state===void 0){let u=n==null?void 0:n(l.node,a());if(u==="stop")return;l.state=u==="skip"?-1:0}let c=l.children||i(l.node,a());if(l.children||(l.children=c),l.state!==-1){if(l.state{"use strict";me();ip=Object.defineProperty,sp=(e,t,n)=>t in e?ip(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$=(e,t,n)=>sp(e,typeof t!="symbol"?t+"":t,n),ki={itemToValue(e){return typeof e=="string"?e:Yt(e)&&Me(e,"value")?e.value:""},itemToString(e){return typeof e=="string"?e:Yt(e)&&Me(e,"label")?e.label:ki.itemToValue(e)},isItemDisabled(e){return Yt(e)&&Me(e,"disabled")?!!e.disabled:!1}},Xn=class Rl{constructor(t){this.options=t,$(this,"items"),$(this,"indexMap",null),$(this,"copy",n=>new Rl(y(m({},this.options),{items:n!=null?n:[...this.items]}))),$(this,"isEqual",n=>he(this.items,n.items)),$(this,"setItems",n=>this.copy(n)),$(this,"getValues",(n=this.items)=>{let r=[];for(let i of n){let s=this.getItemValue(i);s!=null&&r.push(s)}return r}),$(this,"find",n=>{if(n==null)return null;let r=this.indexOf(n);return r!==-1?this.at(r):null}),$(this,"findMany",n=>{let r=[];for(let i of n){let s=this.find(i);s!=null&&r.push(s)}return r}),$(this,"at",n=>{var s;if(!this.options.groupBy&&!this.options.groupSort)return(s=this.items[n])!=null?s:null;let r=0,i=this.group();for(let[,o]of i)for(let a of o){if(r===n)return a;r++}return null}),$(this,"sortFn",(n,r)=>{let i=this.indexOf(n),s=this.indexOf(r);return(i!=null?i:0)-(s!=null?s:0)}),$(this,"sort",n=>[...n].sort(this.sortFn.bind(this))),$(this,"getItemValue",n=>{var r,i,s;return n==null?null:(s=(i=(r=this.options).itemToValue)==null?void 0:i.call(r,n))!=null?s:ki.itemToValue(n)}),$(this,"getItemDisabled",n=>{var r,i,s;return n==null?!1:(s=(i=(r=this.options).isItemDisabled)==null?void 0:i.call(r,n))!=null?s:ki.isItemDisabled(n)}),$(this,"stringifyItem",n=>{var r,i,s;return n==null?null:(s=(i=(r=this.options).itemToString)==null?void 0:i.call(r,n))!=null?s:ki.itemToString(n)}),$(this,"stringify",n=>n==null?null:this.stringifyItem(this.find(n))),$(this,"stringifyItems",(n,r=", ")=>{let i=[];for(let s of n){let o=this.stringifyItem(s);o!=null&&i.push(o)}return i.join(r)}),$(this,"stringifyMany",(n,r)=>this.stringifyItems(this.findMany(n),r)),$(this,"has",n=>this.indexOf(n)!==-1),$(this,"hasItem",n=>n==null?!1:this.has(this.getItemValue(n))),$(this,"group",()=>{let{groupBy:n,groupSort:r}=this.options;if(!n)return[["",[...this.items]]];let i=new Map;this.items.forEach((o,a)=>{let l=n(o,a);i.has(l)||i.set(l,[]),i.get(l).push(o)});let s=Array.from(i.entries());return r&&s.sort(([o],[a])=>{if(typeof r=="function")return r(o,a);if(Array.isArray(r)){let l=r.indexOf(o),c=r.indexOf(a);return l===-1?1:c===-1?-1:l-c}return r==="asc"?o.localeCompare(a):r==="desc"?a.localeCompare(o):0}),s}),$(this,"getNextValue",(n,r=1,i=!1)=>{let s=this.indexOf(n);if(s===-1)return null;for(s=i?Math.min(s+r,this.size-1):s+r;s<=this.size&&this.getItemDisabled(this.at(s));)s++;return this.getItemValue(this.at(s))}),$(this,"getPreviousValue",(n,r=1,i=!1)=>{let s=this.indexOf(n);if(s===-1)return null;for(s=i?Math.max(s-r,0):s-r;s>=0&&this.getItemDisabled(this.at(s));)s--;return this.getItemValue(this.at(s))}),$(this,"indexOf",n=>{var r;if(n==null)return-1;if(!this.options.groupBy&&!this.options.groupSort)return this.items.findIndex(i=>this.getItemValue(i)===n);if(!this.indexMap){this.indexMap=new Map;let i=0,s=this.group();for(let[,o]of s)for(let a of o){let l=this.getItemValue(a);l!=null&&this.indexMap.set(l,i),i++}}return(r=this.indexMap.get(n))!=null?r:-1}),$(this,"getByText",(n,r)=>{let i=r!=null?this.indexOf(r):-1,s=n.length===1;for(let o=0;o{let{state:i,currentValue:s,timeout:o=350}=r,a=i.keysSoFar+n,c=a.length>1&&Array.from(a).every(g=>g===a[0])?a[0]:a,u=this.getByText(c,s),h=this.getItemValue(u);function p(){clearTimeout(i.timer),i.timer=-1}function d(g){i.keysSoFar=g,p(),g!==""&&(i.timer=+setTimeout(()=>{d(""),p()},o))}return d(a),h}),$(this,"update",(n,r)=>{let i=this.indexOf(n);return i===-1?this:this.copy([...this.items.slice(0,i),r,...this.items.slice(i+1)])}),$(this,"upsert",(n,r,i="append")=>{let s=this.indexOf(n);return s===-1?(i==="append"?this.append:this.prepend)(r):this.copy([...this.items.slice(0,s),r,...this.items.slice(s+1)])}),$(this,"insert",(n,...r)=>this.copy(wr(this.items,n,...r))),$(this,"insertBefore",(n,...r)=>{let i=this.indexOf(n);if(i===-1)if(this.items.length===0)i=0;else return this;return this.copy(wr(this.items,i,...r))}),$(this,"insertAfter",(n,...r)=>{let i=this.indexOf(n);if(i===-1)if(this.items.length===0)i=0;else return this;return this.copy(wr(this.items,i+1,...r))}),$(this,"prepend",(...n)=>this.copy(wr(this.items,0,...n))),$(this,"append",(...n)=>this.copy(wr(this.items,this.items.length,...n))),$(this,"filter",n=>{let r=this.items.filter((i,s)=>n(this.stringifyItem(i),s,i));return this.copy(r)}),$(this,"remove",(...n)=>{let r=n.map(i=>typeof i=="string"?i:this.getItemValue(i));return this.copy(this.items.filter(i=>{let s=this.getItemValue(i);return s==null?!1:!r.includes(s)}))}),$(this,"move",(n,r)=>{let i=this.indexOf(n);return i===-1?this:this.copy(xi(this.items,[i],r))}),$(this,"moveBefore",(n,...r)=>{let i=this.items.findIndex(o=>this.getItemValue(o)===n);if(i===-1)return this;let s=r.map(o=>this.items.findIndex(a=>this.getItemValue(a)===o)).sort((o,a)=>o-a);return this.copy(xi(this.items,s,i))}),$(this,"moveAfter",(n,...r)=>{let i=this.items.findIndex(o=>this.getItemValue(o)===n);if(i===-1)return this;let s=r.map(o=>this.items.findIndex(a=>this.getItemValue(a)===o)).sort((o,a)=>o-a);return this.copy(xi(this.items,s,i+1))}),$(this,"reorder",(n,r)=>this.copy(xi(this.items,[n],r))),$(this,"compareValue",(n,r)=>{let i=this.indexOf(n),s=this.indexOf(r);return is?1:0}),$(this,"range",(n,r)=>{let i=[],s=n;for(;s!=null;){if(this.find(s)&&i.push(s),s===r)return i;s=this.getNextValue(s)}return[]}),$(this,"getValueRange",(n,r)=>n&&r?this.compareValue(n,r)<=0?this.range(n,r):this.range(r,n):[]),$(this,"toString",()=>{let n="";for(let r of this.items){let i=this.getItemValue(r),s=this.stringifyItem(r),o=this.getItemDisabled(r),a=[i,s,o].filter(Boolean).join(":");n+=a+","}return n}),$(this,"toJSON",()=>({size:this.size,first:this.firstValue,last:this.lastValue})),this.items=[...t.items]}get size(){return this.items.length}get firstValue(){let t=0;for(;this.getItemDisabled(this.at(t));)t++;return this.getItemValue(this.at(t))}get lastValue(){let t=this.size-1;for(;this.getItemDisabled(this.at(t));)t--;return this.getItemValue(this.at(t))}*[Symbol.iterator](){yield*Ea(this.items)}},op=(e,t)=>!!(e!=null&&e.toLowerCase().startsWith(t.toLowerCase()));ro=class _l{constructor(t){this.options=t,$(this,"rootNode"),$(this,"isEqual",n=>he(this.rootNode,n.rootNode)),$(this,"getNodeChildren",n=>{var r,i,s,o;return(o=(s=(i=(r=this.options).nodeToChildren)==null?void 0:i.call(r,n))!=null?s:jn.nodeToChildren(n))!=null?o:[]}),$(this,"resolveIndexPath",n=>typeof n=="string"?this.getIndexPath(n):n),$(this,"resolveNode",n=>{let r=this.resolveIndexPath(n);return r?this.at(r):void 0}),$(this,"getNodeChildrenCount",n=>{var r,i,s;return(s=(i=(r=this.options).nodeToChildrenCount)==null?void 0:i.call(r,n))!=null?s:jn.nodeToChildrenCount(n)}),$(this,"getNodeValue",n=>{var r,i,s;return(s=(i=(r=this.options).nodeToValue)==null?void 0:i.call(r,n))!=null?s:jn.nodeToValue(n)}),$(this,"getNodeDisabled",n=>{var r,i,s;return(s=(i=(r=this.options).isNodeDisabled)==null?void 0:i.call(r,n))!=null?s:jn.isNodeDisabled(n)}),$(this,"stringify",n=>{let r=this.findNode(n);return r?this.stringifyNode(r):null}),$(this,"stringifyNode",n=>{var r,i,s;return(s=(i=(r=this.options).nodeToString)==null?void 0:i.call(r,n))!=null?s:jn.nodeToString(n)}),$(this,"getFirstNode",(n=this.rootNode,r={})=>{let i;return $e(n,{getChildren:this.getNodeChildren,onEnter:(s,o)=>{var a;if(!this.isSameNode(s,n)){if((a=r.skip)!=null&&a.call(r,{value:this.getNodeValue(s),node:s,indexPath:o}))return"skip";if(!i&&o.length>0&&!this.getNodeDisabled(s))return i=s,"stop"}}}),i}),$(this,"getLastNode",(n=this.rootNode,r={})=>{let i;return $e(n,{getChildren:this.getNodeChildren,onEnter:(s,o)=>{var a;if(!this.isSameNode(s,n)){if((a=r.skip)!=null&&a.call(r,{value:this.getNodeValue(s),node:s,indexPath:o}))return"skip";o.length>0&&!this.getNodeDisabled(s)&&(i=s)}}}),i}),$(this,"at",n=>Dl(this.rootNode,n,{getChildren:this.getNodeChildren})),$(this,"findNode",(n,r=this.rootNode)=>cp(r,{getChildren:this.getNodeChildren,predicate:i=>this.getNodeValue(i)===n})),$(this,"findNodes",(n,r=this.rootNode)=>{let i=new Set(n.filter(s=>s!=null));return up(r,{getChildren:this.getNodeChildren,predicate:s=>i.has(this.getNodeValue(s))})}),$(this,"sort",n=>n.reduce((r,i)=>{let s=this.getIndexPath(i);return s&&r.push({value:i,indexPath:s}),r},[]).sort((r,i)=>Ll(r.indexPath,i.indexPath)).map(({value:r})=>r)),$(this,"getIndexPath",n=>Nl(this.rootNode,{getChildren:this.getNodeChildren,predicate:r=>this.getNodeValue(r)===n})),$(this,"getValue",n=>{let r=this.at(n);return r?this.getNodeValue(r):void 0}),$(this,"getValuePath",n=>{if(!n)return[];let r=[],i=[...n];for(;i.length>0;){let s=this.at(i);s&&r.unshift(this.getNodeValue(s)),i.pop()}return r}),$(this,"getDepth",n=>{var i;let r=Nl(this.rootNode,{getChildren:this.getNodeChildren,predicate:s=>this.getNodeValue(s)===n});return(i=r==null?void 0:r.length)!=null?i:0}),$(this,"isSameNode",(n,r)=>this.getNodeValue(n)===this.getNodeValue(r)),$(this,"isRootNode",n=>this.isSameNode(n,this.rootNode)),$(this,"contains",(n,r)=>!n||!r?!1:r.slice(0,n.length).every((i,s)=>n[s]===r[s])),$(this,"getNextNode",(n,r={})=>{let i=!1,s;return $e(this.rootNode,{getChildren:this.getNodeChildren,onEnter:(o,a)=>{var c;if(this.isRootNode(o))return;let l=this.getNodeValue(o);if((c=r.skip)!=null&&c.call(r,{value:l,node:o,indexPath:a}))return l===n&&(i=!0),"skip";if(i&&!this.getNodeDisabled(o))return s=o,"stop";l===n&&(i=!0)}}),s}),$(this,"getPreviousNode",(n,r={})=>{let i,s=!1;return $e(this.rootNode,{getChildren:this.getNodeChildren,onEnter:(o,a)=>{var c;if(this.isRootNode(o))return;let l=this.getNodeValue(o);if((c=r.skip)!=null&&c.call(r,{value:l,node:o,indexPath:a}))return"skip";if(l===n)return s=!0,"stop";this.getNodeDisabled(o)||(i=o)}}),s?i:void 0}),$(this,"getParentNodes",n=>{var s;let r=(s=this.resolveIndexPath(n))==null?void 0:s.slice();if(!r)return[];let i=[];for(;r.length>0;){r.pop();let o=this.at(r);o&&!this.isRootNode(o)&&i.unshift(o)}return i}),$(this,"getDescendantNodes",(n,r)=>{let i=this.resolveNode(n);if(!i)return[];let s=[];return $e(i,{getChildren:this.getNodeChildren,onEnter:(o,a)=>{a.length!==0&&(!(r!=null&&r.withBranch)&&this.isBranchNode(o)||s.push(o))}}),s}),$(this,"getDescendantValues",(n,r)=>this.getDescendantNodes(n,r).map(s=>this.getNodeValue(s))),$(this,"getParentIndexPath",n=>n.slice(0,-1)),$(this,"getParentNode",n=>{let r=this.resolveIndexPath(n);return r?this.at(this.getParentIndexPath(r)):void 0}),$(this,"visit",n=>{let s=n,{skip:r}=s,i=ze(s,["skip"]);$e(this.rootNode,y(m({},i),{getChildren:this.getNodeChildren,onEnter:(o,a)=>{var l;if(!this.isRootNode(o))return r!=null&&r({value:this.getNodeValue(o),node:o,indexPath:a})?"skip":(l=i.onEnter)==null?void 0:l.call(i,o,a)}}))}),$(this,"getPreviousSibling",n=>{let r=this.getParentNode(n);if(!r)return;let i=this.getNodeChildren(r),s=n[n.length-1];for(;--s>=0;){let o=i[s];if(!this.getNodeDisabled(o))return o}}),$(this,"getNextSibling",n=>{let r=this.getParentNode(n);if(!r)return;let i=this.getNodeChildren(r),s=n[n.length-1];for(;++s{let r=this.getParentNode(n);return r?this.getNodeChildren(r):[]}),$(this,"getValues",(n=this.rootNode)=>hp(n,{getChildren:this.getNodeChildren,transform:i=>[this.getNodeValue(i)]}).slice(1)),$(this,"isValidDepth",(n,r)=>r==null?!0:typeof r=="function"?r(n.length):n.length===r),$(this,"isBranchNode",n=>this.getNodeChildren(n).length>0||this.getNodeChildrenCount(n)!=null),$(this,"getBranchValues",(n=this.rootNode,r={})=>{let i=[];return $e(n,{getChildren:this.getNodeChildren,onEnter:(s,o)=>{var l;if(o.length===0)return;let a=this.getNodeValue(s);if((l=r.skip)!=null&&l.call(r,{value:a,node:s,indexPath:o}))return"skip";this.isBranchNode(s)&&this.isValidDepth(o,r.depth)&&i.push(this.getNodeValue(s))}}),i}),$(this,"flatten",(n=this.rootNode)=>fp(n,{getChildren:this.getNodeChildren})),$(this,"_create",(n,r)=>this.getNodeChildren(n).length>0||r.length>0?y(m({},n),{children:r}):m({},n)),$(this,"_insert",(n,r,i)=>this.copy(bp(n,{at:r,nodes:i,getChildren:this.getNodeChildren,create:this._create}))),$(this,"copy",n=>new _l(y(m({},this.options),{rootNode:n}))),$(this,"_replace",(n,r,i)=>this.copy(Ep(n,{at:r,node:i,getChildren:this.getNodeChildren,create:this._create}))),$(this,"_move",(n,r,i)=>this.copy(Ip(n,{indexPaths:r,to:i,getChildren:this.getNodeChildren,create:this._create}))),$(this,"_remove",(n,r)=>this.copy(Cp(n,{indexPaths:r,getChildren:this.getNodeChildren,create:this._create}))),$(this,"replace",(n,r)=>this._replace(this.rootNode,n,r)),$(this,"remove",n=>this._remove(this.rootNode,n)),$(this,"insertBefore",(n,r)=>this.getParentNode(n)?this._insert(this.rootNode,n,r):void 0),$(this,"insertAfter",(n,r)=>{if(!this.getParentNode(n))return;let s=[...n.slice(0,-1),n[n.length-1]+1];return this._insert(this.rootNode,s,r)}),$(this,"move",(n,r)=>this._move(this.rootNode,n,r)),$(this,"filter",n=>{let r=gp(this.rootNode,{predicate:n,getChildren:this.getNodeChildren,create:this._create});return this.copy(r)}),$(this,"toJSON",()=>this.getValues(this.rootNode)),this.rootNode=t.rootNode}},jn={nodeToValue(e){return typeof e=="string"?e:Yt(e)&&Me(e,"value")?e.value:""},nodeToString(e){return typeof e=="string"?e:Yt(e)&&Me(e,"label")?e.label:jn.nodeToValue(e)},isNodeDisabled(e){return Yt(e)&&Me(e,"disabled")?!!e.disabled:!1},nodeToChildren(e){return e.children},nodeToChildrenCount(e){if(Yt(e)&&Me(e,"childrenCount"))return e.childrenCount}}});function so(e,t,n){return _e(e,jt(t,n))}function At(e,t){return typeof e=="function"?e(t):e}function Rt(e){return e.split("-")[0]}function zn(e){return e.split("-")[1]}function lo(e){return e==="x"?"y":"x"}function co(e){return e==="y"?"height":"width"}function gt(e){return Pp.has(Rt(e))?"y":"x"}function uo(e){return lo(gt(e))}function wp(e,t,n){n===void 0&&(n=!1);let r=zn(e),i=uo(e),s=co(i),o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=Li(o)),[o,Li(o)]}function Vp(e){let t=Li(e);return[oo(e),t,oo(t)]}function oo(e){return e.replace(/start|end/g,t=>Sp[t])}function Np(e,t,n){switch(e){case"top":case"bottom":return n?t?Bl:Hl:t?Hl:Bl;case"left":case"right":return t?xp:kp;default:return[]}}function Ap(e,t,n,r){let i=zn(e),s=Np(Rt(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(oo)))),s}function Li(e){return e.replace(/left|right|bottom|top/g,t=>Op[t])}function Rp(e){return m({top:0,right:0,bottom:0,left:0},e)}function Jl(e){return typeof e!="number"?Rp(e):{top:e,right:e,bottom:e,left:e}}function Fi(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Gl(e,t,n){let{reference:r,floating:i}=e,s=gt(t),o=uo(t),a=co(o),l=Rt(t),c=s==="y",u=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,p=r[a]/2-i[a]/2,d;switch(l){case"top":d={x:u,y:r.y-i.height};break;case"bottom":d={x:u,y:r.y+r.height};break;case"right":d={x:r.x+r.width,y:h};break;case"left":d={x:r.x-i.width,y:h};break;default:d={x:r.x,y:r.y}}switch(zn(t)){case"start":d[o]-=p*(n&&c?-1:1);break;case"end":d[o]+=p*(n&&c?-1:1);break}return d}function Dp(e,t){return Ee(this,null,function*(){var n;t===void 0&&(t={});let{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:p=!1,padding:d=0}=At(t,e),g=Jl(d),b=a[p?h==="floating"?"reference":"floating":h],V=Fi(yield s.getClippingRect({element:(n=yield s.isElement==null?void 0:s.isElement(b))==null||n?b:b.contextElement||(yield s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),S=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,E=yield s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating),f=(yield s.isElement==null?void 0:s.isElement(E))?(yield s.getScale==null?void 0:s.getScale(E))||{x:1,y:1}:{x:1,y:1},C=Fi(s.convertOffsetParentRelativeRectToViewportRelativeRect?yield s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:S,offsetParent:E,strategy:l}):S);return{top:(V.top-C.top+g.top)/f.y,bottom:(C.bottom-V.bottom+g.bottom)/f.y,left:(V.left-C.left+g.left)/f.x,right:(C.right-V.right+g.right)/f.x}})}function Ul(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ql(e){return Tp.some(t=>e[t]>=0)}function _p(e,t){return Ee(this,null,function*(){let{placement:n,platform:r,elements:i}=e,s=yield r.isRTL==null?void 0:r.isRTL(i.floating),o=Rt(n),a=zn(n),l=gt(n)==="y",c=zl.has(o)?-1:1,u=s&&l?-1:1,h=At(t,e),{mainAxis:p,crossAxis:d,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof g=="number"&&(d=a==="end"?g*-1:g),l?{x:d*u,y:p*c}:{x:p*c,y:d*u}})}function Mi(){return typeof window!="undefined"}function Qn(e){return Ql(e)?(e.nodeName||"").toLowerCase():"#document"}function He(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function mt(e){var t;return(t=(Ql(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ql(e){return Mi()?e instanceof Node||e instanceof He(e).Node:!1}function st(e){return Mi()?e instanceof Element||e instanceof He(e).Element:!1}function pt(e){return Mi()?e instanceof HTMLElement||e instanceof He(e).HTMLElement:!1}function Wl(e){return!Mi()||typeof ShadowRoot=="undefined"?!1:e instanceof ShadowRoot||e instanceof He(e).ShadowRoot}function kr(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=ot(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!qp.has(i)}function Kp(e){return Wp.has(Qn(e))}function $i(e){return Yp.some(t=>{try{return e.matches(t)}catch(n){return!1}})}function ho(e){let t=go(),n=st(e)?ot(e):e;return jp.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Xp.some(r=>(n.willChange||"").includes(r))||Zp.some(r=>(n.contain||"").includes(r))}function Jp(e){let t=Xt(e);for(;pt(t)&&!Jn(t);){if(ho(t))return t;if($i(t))return null;t=Xt(t)}return null}function go(){return typeof CSS=="undefined"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Jn(e){return zp.has(Qn(e))}function ot(e){return He(e).getComputedStyle(e)}function _i(e){return st(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Xt(e){if(Qn(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Wl(e)&&e.host||mt(e);return Wl(t)?t.host:t}function ec(e){let t=Xt(e);return Jn(t)?e.ownerDocument?e.ownerDocument.body:e.body:pt(t)&&kr(t)?t:ec(t)}function xr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let i=ec(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=He(i);if(s){let a=ao(o);return t.concat(o,o.visualViewport||[],kr(i)?i:[],a&&n?xr(a):[])}return t.concat(i,xr(i,[],n))}function ao(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function tc(e){let t=ot(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=pt(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=Di(n)!==s||Di(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function fo(e){return st(e)?e:e.contextElement}function Zn(e){let t=fo(e);if(!pt(t))return ft(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:s}=tc(t),o=(s?Di(n.width):n.width)/r,a=(s?Di(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}function nc(e){let t=He(e);return!go()||!t.visualViewport?Qp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function em(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==He(e)?!1:t}function hn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),s=fo(e),o=ft(1);t&&(r?st(r)&&(o=Zn(r)):o=Zn(e));let a=em(s,n,r)?nc(s):ft(0),l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,h=i.height/o.y;if(s){let p=He(s),d=r&&st(r)?He(r):r,g=p,v=ao(g);for(;v&&r&&d!==g;){let b=Zn(v),V=v.getBoundingClientRect(),S=ot(v),E=V.left+(v.clientLeft+parseFloat(S.paddingLeft))*b.x,f=V.top+(v.clientTop+parseFloat(S.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,h*=b.y,l+=E,c+=f,g=He(v),v=ao(g)}}return Fi({width:u,height:h,x:l,y:c})}function Hi(e,t){let n=_i(e).scrollLeft;return t?t.left+n:hn(mt(e)).left+n}function rc(e,t){let n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Hi(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function tm(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,s=i==="fixed",o=mt(r),a=t?$i(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=ft(1),u=ft(0),h=pt(r);if((h||!h&&!s)&&((Qn(r)!=="body"||kr(o))&&(l=_i(r)),pt(r))){let d=hn(r);c=Zn(r),u.x=d.x+r.clientLeft,u.y=d.y+r.clientTop}let p=o&&!h&&!s?rc(o,l):ft(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+p.x,y:n.y*c.y-l.scrollTop*c.y+u.y+p.y}}function nm(e){return Array.from(e.getClientRects())}function rm(e){let t=mt(e),n=_i(e),r=e.ownerDocument.body,i=_e(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=_e(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Hi(e),a=-n.scrollTop;return ot(r).direction==="rtl"&&(o+=_e(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}function im(e,t){let n=He(e),r=mt(e),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;let u=go();(!u||u&&t==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}let c=Hi(r);if(c<=0){let u=r.ownerDocument,h=u.body,p=getComputedStyle(h),d=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-h.clientWidth-d);g<=Kl&&(s-=g)}else c<=Kl&&(s+=c);return{width:s,height:o,x:a,y:l}}function om(e,t){let n=hn(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=pt(e)?Zn(e):ft(1),o=e.clientWidth*s.x,a=e.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function Yl(e,t,n){let r;if(t==="viewport")r=im(e,n);else if(t==="document")r=rm(mt(e));else if(st(t))r=om(t,n);else{let i=nc(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Fi(r)}function ic(e,t){let n=Xt(e);return n===t||!st(n)||Jn(n)?!1:ot(n).position==="fixed"||ic(n,t)}function am(e,t){let n=t.get(e);if(n)return n;let r=xr(e,[],!1).filter(a=>st(a)&&Qn(a)!=="body"),i=null,s=ot(e).position==="fixed",o=s?Xt(e):e;for(;st(o)&&!Jn(o);){let a=ot(o),l=ho(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&sm.has(i.position)||kr(o)&&!l&&ic(e,o))?r=r.filter(u=>u!==o):i=a,o=Xt(o)}return t.set(e,r),r}function lm(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,o=[...n==="clippingAncestors"?$i(t)?[]:am(t,this._c):[].concat(n),r],a=o[0],l=o.reduce((c,u)=>{let h=Yl(t,u,i);return c.top=_e(h.top,c.top),c.right=jt(h.right,c.right),c.bottom=jt(h.bottom,c.bottom),c.left=_e(h.left,c.left),c},Yl(t,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function cm(e){let{width:t,height:n}=tc(e);return{width:t,height:n}}function um(e,t,n){let r=pt(t),i=mt(t),s=n==="fixed",o=hn(e,!0,s,t),a={scrollLeft:0,scrollTop:0},l=ft(0);function c(){l.x=Hi(i)}if(r||!r&&!s)if((Qn(t)!=="body"||kr(i))&&(a=_i(t)),r){let d=hn(t,!0,s,t);l.x=d.x+t.clientLeft,l.y=d.y+t.clientTop}else i&&c();s&&!r&&i&&c();let u=i&&!r&&!s?rc(i,a):ft(0),h=o.left+a.scrollLeft-l.x-u.x,p=o.top+a.scrollTop-l.y-u.y;return{x:h,y:p,width:o.width,height:o.height}}function io(e){return ot(e).position==="static"}function jl(e,t){if(!pt(e)||ot(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return mt(e)===n&&(n=n.ownerDocument.body),n}function sc(e,t){let n=He(e);if($i(e))return n;if(!pt(e)){let i=Xt(e);for(;i&&!Jn(i);){if(st(i)&&!io(i))return i;i=Xt(i)}return n}let r=jl(e,t);for(;r&&Kp(r)&&io(r);)r=jl(r,t);return r&&Jn(r)&&io(r)&&!ho(r)?n:r||Jp(e)||n}function hm(e){return ot(e).direction==="rtl"}function oc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function fm(e,t){let n=null,r,i=mt(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();let c=e.getBoundingClientRect(),{left:u,top:h,width:p,height:d}=c;if(a||t(),!p||!d)return;let g=Ri(h),v=Ri(i.clientWidth-(u+p)),b=Ri(i.clientHeight-(h+d)),V=Ri(u),E={rootMargin:-g+"px "+-v+"px "+-b+"px "+-V+"px",threshold:_e(0,jt(1,l))||1},f=!0;function C(I){let w=I[0].intersectionRatio;if(w!==l){if(!f)return o();w?o(!1,w):r=setTimeout(()=>{o(!1,1e-7)},1e3)}w===1&&!oc(c,e.getBoundingClientRect())&&o(),f=!1}try{n=new IntersectionObserver(C,y(m({},E),{root:i.ownerDocument}))}catch(I){n=new IntersectionObserver(C,E)}n.observe(e)}return o(!0),s}function pm(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=fo(e),u=i||s?[...c?xr(c):[],...xr(t)]:[];u.forEach(V=>{i&&V.addEventListener("scroll",n,{passive:!0}),s&&V.addEventListener("resize",n)});let h=c&&a?fm(c,n):null,p=-1,d=null;o&&(d=new ResizeObserver(V=>{let[S]=V;S&&S.target===c&&d&&(d.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var E;(E=d)==null||E.observe(t)})),n()}),c&&!l&&d.observe(c),d.observe(t));let g,v=l?hn(e):null;l&&b();function b(){let V=hn(e);v&&!oc(v,V)&&n(),v=V,g=requestAnimationFrame(b)}return n(),()=>{var V;u.forEach(S=>{i&&S.removeEventListener("scroll",n),s&&S.removeEventListener("resize",n)}),h==null||h(),(V=d)==null||V.disconnect(),d=null,l&&cancelAnimationFrame(g)}}function Xl(e=0,t=0,n=0,r=0){if(typeof DOMRect=="function")return new DOMRect(e,t,n,r);let i={x:e,y:t,width:n,height:r,top:t,right:e+n,bottom:t+r,left:e};return y(m({},i),{toJSON:()=>i})}function Om(e){if(!e)return Xl();let{x:t,y:n,width:r,height:i}=e;return Xl(t,n,r,i)}function Sm(e,t){return{contextElement:ce(e)?e:e==null?void 0:e.contextElement,getBoundingClientRect:()=>{let n=e,r=t==null?void 0:t(n);return r||!n?Om(r):n.getBoundingClientRect()}}}function wm(e,t){return{name:"transformOrigin",fn(n){var P,N,R,L,M;let{elements:r,middlewareData:i,placement:s,rects:o,y:a}=n,l=s.split("-")[0],c=Pm(l),u=((P=i.arrow)==null?void 0:P.x)||0,h=((N=i.arrow)==null?void 0:N.y)||0,p=(t==null?void 0:t.clientWidth)||0,d=(t==null?void 0:t.clientHeight)||0,g=u+p/2,v=h+d/2,b=Math.abs(((R=i.shift)==null?void 0:R.y)||0),V=o.reference.height/2,S=d/2,E=(M=(L=e.offset)==null?void 0:L.mainAxis)!=null?M:e.gutter,f=typeof E=="number"?E+S:E!=null?E:S,C=b>f,I={top:`${g}px calc(100% + ${f}px)`,bottom:`${g}px ${-f}px`,left:`calc(100% + ${f}px) ${v}px`,right:`${-f}px ${v}px`}[l],w=`${g}px ${o.reference.y+V-a}px`,A=!!e.overlap&&c==="y"&&C;return r.floating.style.setProperty(Nt.transformOrigin.variable,A?w:I),{data:{transformOrigin:A?w:I}}}}}function km(e){let[t,n]=e.split("-");return{side:t,align:n,hasAlign:n!=null}}function ac(e){return e.split("-")[0]}function Zl(e,t){let n=e.devicePixelRatio||1;return Math.round(t*n)/n}function po(e){return typeof e=="function"?e():e==="clipping-ancestors"?"clippingAncestors":e}function Am(e,t,n){let r=e||t.createElement("div");return Cm({element:r,padding:n.arrowPadding})}function Rm(e,t){var n;if(!al((n=t.offset)!=null?n:t.gutter))return mm(({placement:r})=>{var u,h,p,d;let i=((e==null?void 0:e.clientHeight)||0)/2,s=(h=(u=t.offset)==null?void 0:u.mainAxis)!=null?h:t.gutter,o=typeof s=="number"?s+i:s!=null?s:i,{hasAlign:a}=km(r),l=a?void 0:t.shift,c=(d=(p=t.offset)==null?void 0:p.crossAxis)!=null?d:l;return Gn({crossAxis:c,mainAxis:o,alignmentAxis:t.shift})})}function Dm(e){if(!e.flip)return;let t=po(e.boundary);return ym(y(m({},t?{boundary:t}:void 0),{padding:e.overflowPadding,fallbackPlacements:e.flip===!0?void 0:e.flip}))}function Lm(e){if(!e.slide&&!e.overlap)return;let t=po(e.boundary);return vm(y(m({},t?{boundary:t}:void 0),{mainAxis:e.slide,crossAxis:e.overlap,padding:e.overflowPadding,limiter:Im()}))}function Fm(e){return bm({padding:e.overflowPadding,apply({elements:t,rects:n,availableHeight:r,availableWidth:i}){let s=t.floating,o=Math.round(n.reference.width),a=Math.round(n.reference.height);i=Math.floor(i),r=Math.floor(r),s.style.setProperty("--reference-width",`${o}px`),s.style.setProperty("--reference-height",`${a}px`),s.style.setProperty("--available-width",`${i}px`),s.style.setProperty("--available-height",`${r}px`)}})}function Mm(e){var t;if(e.hideWhenDetached)return Em({strategy:"referenceHidden",boundary:(t=po(e.boundary))!=null?t:"clippingAncestors"})}function $m(e){return e?e===!0?{ancestorResize:!0,ancestorScroll:!0,elementResize:!0,layoutShift:!0}:e:{}}function _m(e,t,n={}){var b,V;let r=(V=(b=n.getAnchorElement)==null?void 0:b.call(n))!=null?V:e,i=Sm(r,n.getAnchorRect);if(!t||!i)return;let s=Object.assign({},Nm,n),o=t.querySelector("[data-part=arrow]"),a=[Rm(o,s),Dm(s),Lm(s),Am(o,t.ownerDocument,s),xm(o),wm({gutter:s.gutter,offset:s.offset,overlap:s.overlap},o),Fm(s),Mm(s),Vm],{placement:l,strategy:c,onComplete:u,onPositioned:h}=s,p=()=>Ee(null,null,function*(){var w;if(!i||!t)return;let S=yield Tm(i,t,{placement:l,middleware:a,strategy:c});u==null||u(S),h==null||h({placed:!0});let E=oe(t),f=Zl(E,S.x),C=Zl(E,S.y);t.style.setProperty("--x",`${f}px`),t.style.setProperty("--y",`${C}px`),s.hideWhenDetached&&(((w=S.middlewareData.hide)==null?void 0:w.referenceHidden)?(t.style.setProperty("visibility","hidden"),t.style.setProperty("pointer-events","none")):(t.style.removeProperty("visibility"),t.style.removeProperty("pointer-events")));let I=t.firstElementChild;if(I){let A=qt(I);t.style.setProperty("--z-index",A.zIndex)}}),d=()=>Ee(null,null,function*(){n.updatePosition?(yield n.updatePosition({updatePosition:p,floatingElement:t}),h==null||h({placed:!0})):yield p()}),g=$m(s.listeners),v=s.listeners?pm(i,t,d,g):cl;return d(),()=>{v==null||v(),h==null||h({placed:!1})}}function at(e,t,n={}){let a=n,{defer:r}=a,i=ze(a,["defer"]),s=r?H:l=>l(),o=[];return o.push(s(()=>{let l=typeof e=="function"?e():e,c=typeof t=="function"?t():t;o.push(_m(l,c,i))})),()=>{o.forEach(l=>l==null?void 0:l())}}function Zt(e={}){let{placement:t,sameWidth:n,fitViewport:r,strategy:i="absolute"}=e;return{arrow:{position:"absolute",width:Nt.arrowSize.reference,height:Nt.arrowSize.reference,[Nt.arrowSizeHalf.variable]:`calc(${Nt.arrowSize.reference} / 2)`,[Nt.arrowOffset.variable]:`calc(${Nt.arrowSizeHalf.reference} * -1)`},arrowTip:{transform:t?Hm[t.split("-")[0]]:void 0,background:Nt.arrowBg.reference,top:"0",left:"0",width:"100%",height:"100%",position:"absolute",zIndex:"inherit"},floating:{position:i,isolation:"isolate",minWidth:n?void 0:"max-content",width:n?"var(--reference-width)":void 0,maxWidth:r?"var(--available-width)":void 0,maxHeight:r?"var(--available-height)":void 0,pointerEvents:t?void 0:"none",top:"0px",left:"0px",transform:t?"translate3d(var(--x), var(--y), 0)":"translate3d(0, -100vh, 0)",zIndex:"var(--z-index)"}}}var Tp,jt,_e,Di,Ri,ft,Op,Sp,Pp,Hl,Bl,xp,kp,Lp,Fp,Mp,$p,zl,Hp,Bp,Gp,Up,qp,Wp,Yp,jp,Xp,Zp,zp,Qp,Kl,sm,dm,gm,mm,vm,ym,bm,Em,Cm,Im,Tm,Vr,Nt,Pm,Vm,xm,Nm,Hm,Nr=fe(()=>{"use strict";me();Tp=["top","right","bottom","left"],jt=Math.min,_e=Math.max,Di=Math.round,Ri=Math.floor,ft=e=>({x:e,y:e}),Op={left:"right",right:"left",bottom:"top",top:"bottom"},Sp={start:"end",end:"start"};Pp=new Set(["top","bottom"]);Hl=["left","right"],Bl=["right","left"],xp=["top","bottom"],kp=["bottom","top"];Lp=(e,t,n)=>Ee(null,null,function*(){let{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=yield o.isRTL==null?void 0:o.isRTL(t),c=yield o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:h}=Gl(c,r,l),p=r,d={},g=0;for(let b=0;b({name:"arrow",options:e,fn(n){return Ee(this,null,function*(){let{x:r,y:i,placement:s,rects:o,platform:a,elements:l,middlewareData:c}=n,{element:u,padding:h=0}=At(e,n)||{};if(u==null)return{};let p=Jl(h),d={x:r,y:i},g=uo(s),v=co(g),b=yield a.getDimensions(u),V=g==="y",S=V?"top":"left",E=V?"bottom":"right",f=V?"clientHeight":"clientWidth",C=o.reference[v]+o.reference[g]-d[g]-o.floating[v],I=d[g]-o.reference[g],w=yield a.getOffsetParent==null?void 0:a.getOffsetParent(u),A=w?w[f]:0;(!A||!(yield a.isElement==null?void 0:a.isElement(w)))&&(A=l.floating[f]||o.floating[v]);let P=C/2-I/2,N=A/2-b[v]/2-1,R=jt(p[S],N),L=jt(p[E],N),M=R,j=A-b[v]-L,q=A/2-b[v]/2+P,J=so(M,q,j),W=!c.arrow&&zn(s)!=null&&q!==J&&o.reference[v]/2-(qJ<=0)){var L,M;let J=(((L=o.flip)==null?void 0:L.index)||0)+1,W=A[J];if(W&&(!(p==="alignment"?E!==gt(W):!1)||R.every(X=>gt(X.placement)===E?X.overflows[0]>0:!0)))return{data:{index:J,overflows:R},reset:{placement:W}};let ge=(M=R.filter(de=>de.overflows[0]<=0).sort((de,X)=>de.overflows[1]-X.overflows[1])[0])==null?void 0:M.placement;if(!ge)switch(g){case"bestFit":{var j;let de=(j=R.filter(X=>{if(w){let ue=gt(X.placement);return ue===E||ue==="y"}return!0}).map(X=>[X.placement,X.overflows.filter(ue=>ue>0).reduce((ue,qe)=>ue+qe,0)]).sort((X,ue)=>X[1]-ue[1])[0])==null?void 0:j[0];de&&(ge=de);break}case"initialPlacement":ge=l;break}if(s!==ge)return{reset:{placement:ge}}}return{}})}}};$p=function(e){return e===void 0&&(e={}),{name:"hide",options:e,fn(n){return Ee(this,null,function*(){let{rects:r,platform:i}=n,a=At(e,n),{strategy:s="referenceHidden"}=a,o=ze(a,["strategy"]);switch(s){case"referenceHidden":{let l=yield i.detectOverflow(n,y(m({},o),{elementContext:"reference"})),c=Ul(l,r.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:ql(c)}}}case"escaped":{let l=yield i.detectOverflow(n,y(m({},o),{altBoundary:!0})),c=Ul(l,r.floating);return{data:{escapedOffsets:c,escaped:ql(c)}}}default:return{}}})}}},zl=new Set(["left","top"]);Hp=function(e){return e===void 0&&(e=0),{name:"offset",options:e,fn(n){return Ee(this,null,function*(){var r,i;let{x:s,y:o,placement:a,middlewareData:l}=n,c=yield _p(n,e);return a===((r=l.offset)==null?void 0:r.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:y(m({},c),{placement:a})}})}}},Bp=function(e){return e===void 0&&(e={}),{name:"shift",options:e,fn(n){return Ee(this,null,function*(){let{x:r,y:i,placement:s,platform:o}=n,S=At(e,n),{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:E=>{let{x:f,y:C}=E;return{x:f,y:C}}}}=S,u=ze(S,["mainAxis","crossAxis","limiter"]),h={x:r,y:i},p=yield o.detectOverflow(n,u),d=gt(Rt(s)),g=lo(d),v=h[g],b=h[d];if(a){let E=g==="y"?"top":"left",f=g==="y"?"bottom":"right",C=v+p[E],I=v-p[f];v=so(C,v,I)}if(l){let E=d==="y"?"top":"left",f=d==="y"?"bottom":"right",C=b+p[E],I=b-p[f];b=so(C,b,I)}let V=c.fn(y(m({},n),{[g]:v,[d]:b}));return y(m({},V),{data:{x:V.x-r,y:V.y-i,enabled:{[g]:a,[d]:l}}})})}}},Gp=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=At(e,t),u={x:n,y:r},h=gt(i),p=lo(h),d=u[p],g=u[h],v=At(a,t),b=typeof v=="number"?{mainAxis:v,crossAxis:0}:m({mainAxis:0,crossAxis:0},v);if(l){let E=p==="y"?"height":"width",f=s.reference[p]-s.floating[E]+b.mainAxis,C=s.reference[p]+s.reference[E]-b.mainAxis;dC&&(d=C)}if(c){var V,S;let E=p==="y"?"width":"height",f=zl.has(Rt(i)),C=s.reference[h]-s.floating[E]+(f&&((V=o.offset)==null?void 0:V[h])||0)+(f?0:b.crossAxis),I=s.reference[h]+s.reference[E]+(f?0:((S=o.offset)==null?void 0:S[h])||0)-(f?b.crossAxis:0);gI&&(g=I)}return{[p]:d,[h]:g}}}},Up=function(e){return e===void 0&&(e={}),{name:"size",options:e,fn(n){return Ee(this,null,function*(){var r,i;let{placement:s,rects:o,platform:a,elements:l}=n,R=At(e,n),{apply:c=()=>{}}=R,u=ze(R,["apply"]),h=yield a.detectOverflow(n,u),p=Rt(s),d=zn(s),g=gt(s)==="y",{width:v,height:b}=o.floating,V,S;p==="top"||p==="bottom"?(V=p,S=d===((yield a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(S=p,V=d==="end"?"top":"bottom");let E=b-h.top-h.bottom,f=v-h.left-h.right,C=jt(b-h[V],E),I=jt(v-h[S],f),w=!n.middlewareData.shift,A=C,P=I;if((r=n.middlewareData.shift)!=null&&r.enabled.x&&(P=f),(i=n.middlewareData.shift)!=null&&i.enabled.y&&(A=E),w&&!d){let L=_e(h.left,0),M=_e(h.right,0),j=_e(h.top,0),q=_e(h.bottom,0);g?P=v-2*(L!==0||M!==0?L+M:_e(h.left,h.right)):A=b-2*(j!==0||q!==0?j+q:_e(h.top,h.bottom))}yield c(y(m({},n),{availableWidth:P,availableHeight:A}));let N=yield a.getDimensions(l.floating);return v!==N.width||b!==N.height?{reset:{rects:!0}}:{}})}}};qp=new Set(["inline","contents"]);Wp=new Set(["table","td","th"]);Yp=[":popover-open",":modal"];jp=["transform","translate","scale","rotate","perspective"],Xp=["transform","translate","scale","rotate","perspective","filter"],Zp=["paint","layout","strict","content"];zp=new Set(["html","body","#document"]);Qp=ft(0);Kl=25;sm=new Set(["absolute","fixed"]);dm=function(e){return Ee(this,null,function*(){let t=this.getOffsetParent||sc,n=this.getDimensions,r=yield n(e.floating);return{reference:um(e.reference,yield t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}})};gm={convertOffsetParentRelativeRectToViewportRelativeRect:tm,getDocumentElement:mt,getClippingRect:lm,getOffsetParent:sc,getElementRects:dm,getClientRects:nm,getDimensions:cm,getScale:Zn,isElement:st,isRTL:hm};mm=Hp,vm=Bp,ym=Mp,bm=Up,Em=$p,Cm=Fp,Im=Gp,Tm=(e,t,n)=>{let r=new Map,i=m({platform:gm},n),s=y(m({},i.platform),{_c:r});return Lp(e,t,y(m({},i),{platform:s}))};Vr=e=>({variable:e,reference:`var(${e})`}),Nt={arrowSize:Vr("--arrow-size"),arrowSizeHalf:Vr("--arrow-size-half"),arrowBg:Vr("--arrow-background"),transformOrigin:Vr("--transform-origin"),arrowOffset:Vr("--arrow-offset")},Pm=e=>e==="top"||e==="bottom"?"y":"x";Vm={name:"rects",fn({rects:e}){return{data:e}}},xm=e=>{if(e)return{name:"shiftArrow",fn({placement:t,middlewareData:n}){if(!n.arrow)return{};let{x:r,y:i}=n.arrow,s=t.split("-")[0];return Object.assign(e.style,{left:r!=null?`${r}px`:"",top:i!=null?`${i}px`:"",[s]:`calc(100% + ${Nt.arrowOffset.reference})`}),{}}}};Nm={strategy:"absolute",placement:"bottom",listeners:!0,gutter:8,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,overflowPadding:8,arrowPadding:4};Hm={bottom:"rotate(45deg)",left:"rotate(135deg)",top:"rotate(225deg)",right:"rotate(315deg)"}});function Bm(e){let t={each(n){var r;for(let i=0;i<((r=e.frames)==null?void 0:r.length);i+=1){let s=e.frames[i];s&&n(s)}},addEventListener(n,r,i){return t.each(s=>{try{s.document.addEventListener(n,r,i)}catch(o){}}),()=>{try{t.removeEventListener(n,r,i)}catch(s){}}},removeEventListener(n,r,i){t.each(s=>{try{s.document.removeEventListener(n,r,i)}catch(o){}})}};return t}function Gm(e){let t=e.frameElement!=null?e.parent:null;return{addEventListener:(n,r,i)=>{try{t==null||t.addEventListener(n,r,i)}catch(s){}return()=>{try{t==null||t.removeEventListener(n,r,i)}catch(s){}}},removeEventListener:(n,r,i)=>{try{t==null||t.removeEventListener(n,r,i)}catch(s){}}}}function Um(e){for(let t of e)if(ce(t)&&Qe(t))return!0;return!1}function qm(e,t){if(!pc(t)||!e)return!1;let n=e.getBoundingClientRect();return n.width===0||n.height===0?!1:n.top<=t.clientY&&t.clientY<=n.top+n.height&&n.left<=t.clientX&&t.clientX<=n.left+n.width}function Wm(e,t){return e.y<=t.y&&t.y<=e.y+e.height&&e.x<=t.x&&t.x<=e.x+e.width}function uc(e,t){if(!t||!pc(e))return!1;let n=t.scrollHeight>t.clientHeight,r=n&&e.clientX>t.offsetLeft+t.clientWidth,i=t.scrollWidth>t.clientWidth,s=i&&e.clientY>t.offsetTop+t.clientHeight,o={x:t.offsetLeft,y:t.offsetTop,width:t.clientWidth+(n?16:0),height:t.clientHeight+(i?16:0)},a={x:e.clientX,y:e.clientY};return Wm(o,a)?r||s:!1}function Km(e,t){let{exclude:n,onFocusOutside:r,onPointerDownOutside:i,onInteractOutside:s,defer:o,followControlledElements:a=!0}=t;if(!e)return;let l=we(e),c=oe(e),u=Bm(c),h=Gm(c);function p(E,f){if(!ce(f)||!f.isConnected||pe(e,f)||qm(e,E)||a&&li(e,f))return!1;let C=l.querySelector(`[aria-controls="${e.id}"]`);if(C){let w=fi(C);if(uc(E,w))return!1}let I=fi(e);return uc(E,I)?!1:!(n!=null&&n(f))}let d=new Set,g=nn(e==null?void 0:e.getRootNode());function v(E){function f(C){var P,N;let I=o&&!Fs()?H:R=>R(),w=C!=null?C:E,A=(N=(P=w==null?void 0:w.composedPath)==null?void 0:P.call(w))!=null?N:[w==null?void 0:w.target];I(()=>{let R=g?A[0]:K(E);if(!(!e||!p(E,R))){if(i||s){let L=Bn(i,s);e.addEventListener(lc,L,{once:!0})}dc(e,lc,{bubbles:!1,cancelable:!0,detail:{originalEvent:w,contextmenu:An(w),focusable:Um(A),target:R}})}})}E.pointerType==="touch"?(d.forEach(C=>C()),d.add(ie(l,"click",f,{once:!0})),d.add(h.addEventListener("click",f,{once:!0})),d.add(u.addEventListener("click",f,{once:!0}))):f()}let b=new Set,V=setTimeout(()=>{b.add(ie(l,"pointerdown",v,!0)),b.add(h.addEventListener("pointerdown",v,!0)),b.add(u.addEventListener("pointerdown",v,!0))},0);function S(E){(o?H:C=>C())(()=>{var w,A;let C=(A=(w=E==null?void 0:E.composedPath)==null?void 0:w.call(E))!=null?A:[E==null?void 0:E.target],I=g?C[0]:K(E);if(!(!e||!p(E,I))){if(r||s){let P=Bn(r,s);e.addEventListener(cc,P,{once:!0})}dc(e,cc,{bubbles:!1,cancelable:!0,detail:{originalEvent:E,contextmenu:!1,focusable:Qe(I),target:I}})}})}return Fs()||(b.add(ie(l,"focusin",S,!0)),b.add(h.addEventListener("focusin",S,!0)),b.add(u.addEventListener("focusin",S,!0))),()=>{clearTimeout(V),d.forEach(E=>E()),b.forEach(E=>E())}}function Ym(e,t){let{defer:n}=t,r=n?H:s=>s(),i=[];return i.push(r(()=>{let s=typeof e=="function"?e():e;i.push(Km(s,t))})),()=>{i.forEach(s=>s==null?void 0:s())}}function dc(e,t,n){let r=e.ownerDocument.defaultView||window,i=new r.CustomEvent(t,n);return e.dispatchEvent(i)}function jm(e,t){let n=r=>{r.key==="Escape"&&(r.isComposing||t==null||t(r))};return ie(we(e),"keydown",n,{capture:!0})}function Xm(e,t,n){let r=e.ownerDocument.defaultView||window,i=new r.CustomEvent(t,{cancelable:!0,bubbles:!0,detail:n});return e.dispatchEvent(i)}function Zm(e,t,n){e.addEventListener(t,n,{once:!0})}function fc(){Re.layers.forEach(({node:e})=>{e.style.pointerEvents=Re.isBelowPointerBlockingLayer(e)?"none":"auto"})}function Jm(e){e.style.pointerEvents=""}function zm(e,t){let n=we(e),r=[];return Re.hasPointerBlockingLayer()&&!n.body.hasAttribute("data-inert")&&(gc=document.body.style.pointerEvents,queueMicrotask(()=>{n.body.style.pointerEvents="none",n.body.setAttribute("data-inert","")})),t==null||t.forEach(i=>{let[s,o]=el(()=>{let a=i();return ce(a)?a:null},{timeout:1e3});s.then(a=>r.push(cn(a,{pointerEvents:"auto"}))),r.push(o)}),()=>{Re.hasPointerBlockingLayer()||(queueMicrotask(()=>{n.body.style.pointerEvents=gc,n.body.removeAttribute("data-inert"),n.body.style.length===0&&n.body.removeAttribute("style")}),r.forEach(i=>i()))}}function Qm(e,t){let{warnOnMissingNode:n=!0}=t;if(n&&!e){wt("[@zag-js/dismissable] node is `null` or `undefined`");return}if(!e)return;let{onDismiss:r,onRequestDismiss:i,pointerBlocking:s,exclude:o,debug:a,type:l="dialog"}=t,c={dismiss:r,node:e,type:l,pointerBlocking:s,requestDismiss:i};Re.add(c),fc();function u(v){var V,S;let b=K(v.detail.originalEvent);Re.isBelowPointerBlockingLayer(e)||Re.isInBranch(b)||((V=t.onPointerDownOutside)==null||V.call(t,v),(S=t.onInteractOutside)==null||S.call(t,v),!v.defaultPrevented&&(a&&console.log("onPointerDownOutside:",v.detail.originalEvent),r==null||r()))}function h(v){var V,S;let b=K(v.detail.originalEvent);Re.isInBranch(b)||((V=t.onFocusOutside)==null||V.call(t,v),(S=t.onInteractOutside)==null||S.call(t,v),!v.defaultPrevented&&(a&&console.log("onFocusOutside:",v.detail.originalEvent),r==null||r()))}function p(v){var b;Re.isTopMost(e)&&((b=t.onEscapeKeyDown)==null||b.call(t,v),!v.defaultPrevented&&r&&(v.preventDefault(),r()))}function d(v){var E;if(!e)return!1;let b=typeof o=="function"?o():o,V=Array.isArray(b)?b:[b],S=(E=t.persistentElements)==null?void 0:E.map(f=>f()).filter(ce);return S&&V.push(...S),V.some(f=>pe(f,v))||Re.isInNestedLayer(e,v)}let g=[s?zm(e,t.persistentElements):void 0,jm(e,p),Ym(e,{exclude:d,onFocusOutside:h,onPointerDownOutside:u,defer:t.defer})];return()=>{Re.remove(e),fc(),Jm(e),g.forEach(v=>v==null?void 0:v())}}function vt(e,t){let{defer:n}=t,r=n?H:s=>s(),i=[];return i.push(r(()=>{let s=Ot(e)?e():e;i.push(Qm(s,t))})),()=>{i.forEach(s=>s==null?void 0:s())}}function mc(e,t={}){let{defer:n}=t,r=n?H:s=>s(),i=[];return i.push(r(()=>{let s=Ot(e)?e():e;if(!s){wt("[@zag-js/dismissable] branch node is `null` or `undefined`");return}Re.addBranch(s),i.push(()=>{Re.removeBranch(s)})})),()=>{i.forEach(s=>s==null?void 0:s())}}var lc,cc,pc,hc,Re,gc,gn=fe(()=>{"use strict";me();lc="pointerdown.outside",cc="focus.outside";pc=e=>"clientY"in e;hc="layer:request-dismiss",Re={layers:[],branches:[],recentlyRemoved:new Set,count(){return this.layers.length},pointerBlockingLayers(){return this.layers.filter(e=>e.pointerBlocking)},topMostPointerBlockingLayer(){return[...this.pointerBlockingLayers()].slice(-1)[0]},hasPointerBlockingLayer(){return this.pointerBlockingLayers().length>0},isBelowPointerBlockingLayer(e){var r;let t=this.indexOf(e),n=this.topMostPointerBlockingLayer()?this.indexOf((r=this.topMostPointerBlockingLayer())==null?void 0:r.node):-1;return tt.type===e)},getNestedLayersByType(e,t){let n=this.indexOf(e);return n===-1?[]:this.layers.slice(n+1).filter(r=>r.type===t)},getParentLayerOfType(e,t){let n=this.indexOf(e);if(!(n<=0))return this.layers.slice(0,n).reverse().find(r=>r.type===t)},countNestedLayersOfType(e,t){return this.getNestedLayersByType(e,t).length},isInNestedLayer(e,t){return!!(this.getNestedLayers(e).some(r=>pe(r.node,t))||this.recentlyRemoved.size>0)},isInBranch(e){return Array.from(this.branches).some(t=>pe(t,e))},add(e){this.layers.push(e),this.syncLayers()},addBranch(e){this.branches.push(e)},remove(e){let t=this.indexOf(e);t<0||(this.recentlyRemoved.add(e),an(()=>this.recentlyRemoved.delete(e)),tRe.dismiss(r.node,e)),this.layers.splice(t,1),this.syncLayers())},removeBranch(e){let t=this.branches.indexOf(e);t>=0&&this.branches.splice(t,1)},syncLayers(){this.layers.forEach((e,t)=>{e.node.style.setProperty("--layer-index",`${t}`),e.node.removeAttribute("data-nested"),e.node.removeAttribute("data-has-nested"),this.getParentLayerOfType(e.node,e.type)&&e.node.setAttribute("data-nested",e.type);let r=this.countNestedLayersOfType(e.node,e.type);r>0&&e.node.setAttribute("data-has-nested",e.type),e.node.style.setProperty("--nested-layer-count",`${r}`)})},indexOf(e){return this.layers.findIndex(t=>t.node===e)},dismiss(e,t){let n=this.indexOf(e);if(n===-1)return;let r=this.layers[n];Zm(e,hc,i=>{var s;(s=r.requestDismiss)==null||s.call(r,i),i.defaultPrevented||r==null||r.dismiss()}),Xm(e,hc,{originalLayer:e,targetLayer:t,originalIndex:n,targetIndex:t?this.indexOf(t):-1}),this.syncLayers()},clear(){this.remove(this.layers[0].node)}}});var wc={};Oe(wc,{Combobox:()=>vv});function sv(e,t){let{context:n,prop:r,state:i,send:s,scope:o,computed:a,event:l}=e,c=r("translations"),u=r("collection"),h=!!r("disabled"),p=a("isInteractive"),d=!!r("invalid"),g=!!r("required"),v=!!r("readOnly"),b=i.hasTag("open"),V=i.hasTag("focused"),S=r("composite"),E=n.get("highlightedValue"),f=Zt(y(m({},r("positioning")),{placement:n.get("currentPlacement")}));function C(I){let w=u.getItemDisabled(I.item),A=u.getItemValue(I.item);return qn(A,()=>`[zag-js] No value found for item ${JSON.stringify(I.item)}`),{value:A,disabled:!!(w||w),highlighted:E===A,selected:n.get("value").includes(A)}}return{focused:V,open:b,inputValue:n.get("inputValue"),highlightedValue:E,highlightedItem:n.get("highlightedItem"),value:n.get("value"),valueAsString:a("valueAsString"),hasSelectedItems:a("hasSelectedItems"),selectedItems:n.get("selectedItems"),collection:r("collection"),multiple:!!r("multiple"),disabled:!!h,syncSelectedItems(){s({type:"SELECTED_ITEMS.SYNC"})},reposition(I={}){s({type:"POSITIONING.SET",options:I})},setHighlightValue(I){s({type:"HIGHLIGHTED_VALUE.SET",value:I})},clearHighlightValue(){s({type:"HIGHLIGHTED_VALUE.CLEAR"})},selectValue(I){s({type:"ITEM.SELECT",value:I})},setValue(I){s({type:"VALUE.SET",value:I})},setInputValue(I,w="script"){s({type:"INPUT_VALUE.SET",value:I,src:w})},clearValue(I){I!=null?s({type:"ITEM.CLEAR",value:I}):s({type:"VALUE.CLEAR"})},focus(){var I;(I=pn(o))==null||I.focus()},setOpen(I,w="script"){i.hasTag("open")!==I&&s({type:I?"OPEN":"CLOSE",src:w})},getRootProps(){return t.element(y(m({},De.root.attrs),{dir:r("dir"),id:tv(o),"data-invalid":T(d),"data-readonly":T(v)}))},getLabelProps(){return t.label(y(m({},De.label.attrs),{dir:r("dir"),htmlFor:Bi(o),id:mo(o),"data-readonly":T(v),"data-disabled":T(h),"data-invalid":T(d),"data-required":T(g),"data-focus":T(V),onClick(I){var w;S||(I.preventDefault(),(w=Ar(o))==null||w.focus({preventScroll:!0}))}}))},getControlProps(){return t.element(y(m({},De.control.attrs),{dir:r("dir"),id:Tc(o),"data-state":b?"open":"closed","data-focus":T(V),"data-disabled":T(h),"data-invalid":T(d)}))},getPositionerProps(){return t.element(y(m({},De.positioner.attrs),{dir:r("dir"),id:Oc(o),style:f.floating}))},getInputProps(){return t.input(y(m({},De.input.attrs),{dir:r("dir"),"aria-invalid":re(d),"data-invalid":T(d),"data-autofocus":T(r("autoFocus")),name:r("name"),form:r("form"),disabled:h,required:r("required"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"none",spellCheck:"false",readOnly:v,placeholder:r("placeholder"),id:Bi(o),type:"text",role:"combobox",defaultValue:n.get("inputValue"),"aria-autocomplete":a("autoComplete")?"both":"list","aria-controls":Gi(o),"aria-expanded":b,"data-state":b?"open":"closed","aria-activedescendant":E?yc(o,E):void 0,onClick(I){I.defaultPrevented||r("openOnClick")&&p&&s({type:"INPUT.CLICK",src:"input-click"})},onFocus(){h||s({type:"INPUT.FOCUS"})},onBlur(){h||s({type:"INPUT.BLUR"})},onChange(I){s({type:"INPUT.CHANGE",value:I.currentTarget.value,src:"input-change"})},onKeyDown(I){if(I.defaultPrevented||!p||I.ctrlKey||I.shiftKey||Vt(I))return;let w=r("openOnKeyPress"),A=I.ctrlKey||I.metaKey||I.shiftKey,P=!0,N={ArrowDown(M){!w&&!b||(s({type:M.altKey?"OPEN":"INPUT.ARROW_DOWN",keypress:P,src:"arrow-key"}),M.preventDefault())},ArrowUp(){!w&&!b||(s({type:I.altKey?"CLOSE":"INPUT.ARROW_UP",keypress:P,src:"arrow-key"}),I.preventDefault())},Home(M){A||(s({type:"INPUT.HOME",keypress:P}),b&&M.preventDefault())},End(M){A||(s({type:"INPUT.END",keypress:P}),b&&M.preventDefault())},Enter(M){var ge;s({type:"INPUT.ENTER",keypress:P,src:"item-select"});let j=a("isCustomValue")&&r("allowCustomValue"),q=E!=null,J=r("alwaysSubmitOnEnter");if(b&&!j&&!J&&q&&M.preventDefault(),E==null)return;let W=er(o,E);We(W)&&((ge=r("navigate"))==null||ge({value:E,node:W,href:W.href}))},Escape(){s({type:"INPUT.ESCAPE",keypress:P,src:"escape-key"}),I.preventDefault()}},R=ve(I,{dir:r("dir")}),L=N[R];L==null||L(I)}}))},getTriggerProps(I={}){return t.button(y(m({},De.trigger.attrs),{dir:r("dir"),id:Sc(o),"aria-haspopup":S?"listbox":"dialog",type:"button",tabIndex:I.focusable?void 0:-1,"aria-label":c.triggerLabel,"aria-expanded":b,"data-state":b?"open":"closed","aria-controls":b?Gi(o):void 0,disabled:h,"data-invalid":T(d),"data-focusable":T(I.focusable),"data-readonly":T(v),"data-disabled":T(h),onFocus(){I.focusable&&s({type:"INPUT.FOCUS",src:"trigger"})},onClick(w){w.defaultPrevented||p&&et(w)&&s({type:"TRIGGER.CLICK",src:"trigger-click"})},onPointerDown(w){p&&w.pointerType!=="touch"&&et(w)&&(w.preventDefault(),queueMicrotask(()=>{var A;(A=pn(o))==null||A.focus({preventScroll:!0})}))},onKeyDown(w){if(w.defaultPrevented||S)return;let A={ArrowDown(){s({type:"INPUT.ARROW_DOWN",src:"arrow-key"})},ArrowUp(){s({type:"INPUT.ARROW_UP",src:"arrow-key"})}},P=ve(w,{dir:r("dir")}),N=A[P];N&&(N(w),w.preventDefault())}}))},getContentProps(){return t.element(y(m({},De.content.attrs),{dir:r("dir"),id:Gi(o),role:S?"listbox":"dialog",tabIndex:-1,hidden:!b,"data-state":b?"open":"closed","data-placement":n.get("currentPlacement"),"aria-labelledby":mo(o),"aria-multiselectable":r("multiple")&&S?!0:void 0,"data-empty":T(u.size===0),onPointerDown(I){et(I)&&I.preventDefault()}}))},getListProps(){return t.element(y(m({},De.list.attrs),{role:S?void 0:"listbox","data-empty":T(u.size===0),"aria-labelledby":mo(o),"aria-multiselectable":r("multiple")&&!S?!0:void 0}))},getClearTriggerProps(){return t.button(y(m({},De.clearTrigger.attrs),{dir:r("dir"),id:Pc(o),type:"button",tabIndex:-1,disabled:h,"data-invalid":T(d),"aria-label":c.clearTriggerLabel,"aria-controls":Bi(o),hidden:!n.get("value").length,onPointerDown(I){et(I)&&I.preventDefault()},onClick(I){I.defaultPrevented||p&&s({type:"VALUE.CLEAR",src:"clear-trigger"})}}))},getItemState:C,getItemProps(I){let w=C(I),A=w.value;return t.element(y(m({},De.item.attrs),{dir:r("dir"),id:yc(o,A),role:"option",tabIndex:-1,"data-highlighted":T(w.highlighted),"data-state":w.selected?"checked":"unchecked","aria-selected":re(w.highlighted),"aria-disabled":re(w.disabled),"data-disabled":T(w.disabled),"data-value":w.value,onPointerMove(){w.disabled||w.highlighted||s({type:"ITEM.POINTER_MOVE",value:A})},onPointerLeave(){if(I.persistFocus||w.disabled)return;let P=l.previous();P!=null&&P.type.includes("POINTER")&&s({type:"ITEM.POINTER_LEAVE",value:A})},onClick(P){Er(P)||sn(P)||An(P)||w.disabled||s({type:"ITEM.CLICK",src:"item-select",value:A})}}))},getItemTextProps(I){let w=C(I);return t.element(y(m({},De.itemText.attrs),{dir:r("dir"),"data-state":w.selected?"checked":"unchecked","data-disabled":T(w.disabled),"data-highlighted":T(w.highlighted)}))},getItemIndicatorProps(I){let w=C(I);return t.element(y(m({"aria-hidden":!0},De.itemIndicator.attrs),{dir:r("dir"),"data-state":w.selected?"checked":"unchecked",hidden:!w.selected}))},getItemGroupProps(I){let{id:w}=I;return t.element(y(m({},De.itemGroup.attrs),{dir:r("dir"),id:nv(o,w),"aria-labelledby":vc(o,w),"data-empty":T(u.size===0),role:"group"}))},getItemGroupLabelProps(I){let{htmlFor:w}=I;return t.element(y(m({},De.itemGroupLabel.attrs),{dir:r("dir"),id:vc(o,w),role:"presentation"}))}}}function Ic(e){return(e.previousEvent||e).src}function pv(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function mv(e){let t={};for(let[n,r]of Object.entries(e)){let i=pv(n);t[i]=r}return t}var ev,De,Ui,tv,mo,Tc,Bi,Gi,Oc,Sc,Pc,nv,vc,yc,fn,pn,bc,Ec,Ar,rv,er,Cc,iv,ov,av,lv,be,Be,cv,uv,dT,dv,hT,hv,gT,gv,fT,fv,vv,Vc=fe(()=>{"use strict";Ai();Nr();gn();me();ev=Z("combobox").parts("root","clearTrigger","content","control","input","item","itemGroup","itemGroupLabel","itemIndicator","itemText","label","list","positioner","trigger"),De=ev.build(),Ui=e=>new Xn(e);Ui.empty=()=>new Xn({items:[]});tv=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`combobox:${e.id}`},mo=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`combobox:${e.id}:label`},Tc=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`combobox:${e.id}:control`},Bi=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.input)!=null?n:`combobox:${e.id}:input`},Gi=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`combobox:${e.id}:content`},Oc=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.positioner)!=null?n:`combobox:${e.id}:popper`},Sc=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`combobox:${e.id}:toggle-btn`},Pc=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.clearTrigger)!=null?n:`combobox:${e.id}:clear-btn`},nv=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemGroup)==null?void 0:r.call(n,t))!=null?i:`combobox:${e.id}:optgroup:${t}`},vc=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemGroupLabel)==null?void 0:r.call(n,t))!=null?i:`combobox:${e.id}:optgroup-label:${t}`},yc=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.item)==null?void 0:r.call(n,t))!=null?i:`combobox:${e.id}:option:${t}`},fn=e=>e.getById(Gi(e)),pn=e=>e.getById(Bi(e)),bc=e=>e.getById(Oc(e)),Ec=e=>e.getById(Tc(e)),Ar=e=>e.getById(Sc(e)),rv=e=>e.getById(Pc(e)),er=(e,t)=>{if(t==null)return null;let n=`[role=option][data-value="${CSS.escape(t)}"]`;return Mn(fn(e),n)},Cc=e=>{let t=pn(e);e.isActiveElement(t)||t==null||t.focus({preventScroll:!0})},iv=e=>{let t=Ar(e);e.isActiveElement(t)||t==null||t.focus({preventScroll:!0})};({guards:ov,createMachine:av,choose:lv}=Wn()),{and:be,not:Be}=ov,cv=av({props({props:e}){return y(m({loopFocus:!0,openOnClick:!1,defaultValue:[],defaultInputValue:"",closeOnSelect:!e.multiple,allowCustomValue:!1,alwaysSubmitOnEnter:!1,inputBehavior:"none",selectionBehavior:e.multiple?"clear":"replace",openOnKeyPress:!0,openOnChange:!0,composite:!0,navigate({node:t}){Fn(t)},collection:Ui.empty()},e),{positioning:m({placement:"bottom",sameWidth:!0},e.positioning),translations:m({triggerLabel:"Toggle suggestions",clearTriggerLabel:"Clear value"},e.translations)})},initialState({prop:e}){return e("open")||e("defaultOpen")?"suggesting":"idle"},context({prop:e,bindable:t,getContext:n,getEvent:r}){return{currentPlacement:t(()=>({defaultValue:void 0})),value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),isEqual:he,hash(i){return i.join(",")},onChange(i){var c;let s=n(),o=s.get("selectedItems"),a=e("collection"),l=i.map(u=>o.find(p=>a.getItemValue(p)===u)||a.find(u));s.set("selectedItems",l),(c=e("onValueChange"))==null||c({value:i,items:l})}})),highlightedValue:t(()=>({defaultValue:e("defaultHighlightedValue")||null,value:e("highlightedValue"),onChange(i){var o;let s=e("collection").find(i);(o=e("onHighlightChange"))==null||o({highlightedValue:i,highlightedItem:s})}})),inputValue:t(()=>{let i=e("inputValue")||e("defaultInputValue"),s=e("value")||e("defaultValue");if(!i.trim()&&!e("multiple")){let o=e("collection").stringifyMany(s);i=Ve(e("selectionBehavior"),{preserve:i||o,replace:o,clear:""})}return{defaultValue:i,value:e("inputValue"),onChange(o){var c;let a=r(),l=(a.previousEvent||a).src;(c=e("onInputValueChange"))==null||c({inputValue:o,reason:l})}}}),highlightedItem:t(()=>{let i=e("highlightedValue");return{defaultValue:e("collection").find(i)}}),selectedItems:t(()=>{let i=e("value")||e("defaultValue")||[];return{defaultValue:e("collection").findMany(i)}})}},computed:{isInputValueEmpty:({context:e})=>e.get("inputValue").length===0,isInteractive:({prop:e})=>!(e("readOnly")||e("disabled")),autoComplete:({prop:e})=>e("inputBehavior")==="autocomplete",autoHighlight:({prop:e})=>e("inputBehavior")==="autohighlight",hasSelectedItems:({context:e})=>e.get("value").length>0,valueAsString:({context:e,prop:t})=>t("collection").stringifyItems(e.get("selectedItems")),isCustomValue:({context:e,computed:t})=>e.get("inputValue")!==t("valueAsString")},watch({context:e,prop:t,track:n,action:r,send:i}){n([()=>e.hash("value")],()=>{r(["syncSelectedItems"])}),n([()=>e.get("inputValue")],()=>{r(["syncInputValue"])}),n([()=>e.get("highlightedValue")],()=>{r(["syncHighlightedItem","autofillInputValue"])}),n([()=>t("open")],()=>{r(["toggleVisibility"])}),n([()=>t("collection").toString()],()=>{i({type:"CHILDREN_CHANGE"})})},on:{"SELECTED_ITEMS.SYNC":{actions:["syncSelectedItems"]},"HIGHLIGHTED_VALUE.SET":{actions:["setHighlightedValue"]},"HIGHLIGHTED_VALUE.CLEAR":{actions:["clearHighlightedValue"]},"ITEM.SELECT":{actions:["selectItem"]},"ITEM.CLEAR":{actions:["clearItem"]},"VALUE.SET":{actions:["setValue"]},"INPUT_VALUE.SET":{actions:["setInputValue"]},"POSITIONING.SET":{actions:["reposition"]}},entry:lv([{guard:"autoFocus",actions:["setInitialFocus"]}]),states:{idle:{tags:["idle","closed"],entry:["scrollContentToTop","clearHighlightedValue"],on:{"CONTROLLED.OPEN":{target:"interacting"},"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"]}],"INPUT.CLICK":[{guard:"isOpenControlled",actions:["highlightFirstSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["highlightFirstSelectedItem","invokeOnOpen"]}],"INPUT.FOCUS":{target:"focused"},OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"interacting",actions:["invokeOnOpen"]}],"VALUE.CLEAR":{target:"focused",actions:["clearInputValue","clearSelectedItems","setInitialFocus"]}}},focused:{tags:["focused","closed"],entry:["scrollContentToTop","clearHighlightedValue"],on:{"CONTROLLED.OPEN":[{guard:"isChangeEvent",target:"suggesting"},{target:"interacting"}],"INPUT.CHANGE":[{guard:be("isOpenControlled","openOnChange"),actions:["setInputValue","invokeOnOpen","highlightFirstItemIfNeeded"]},{guard:"openOnChange",target:"suggesting",actions:["setInputValue","invokeOnOpen","highlightFirstItemIfNeeded"]},{actions:["setInputValue"]}],"LAYER.INTERACT_OUTSIDE":{target:"idle"},"INPUT.ESCAPE":{guard:be("isCustomValue",Be("allowCustomValue")),actions:["revertInputValue"]},"INPUT.BLUR":{target:"idle"},"INPUT.CLICK":[{guard:"isOpenControlled",actions:["highlightFirstSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["highlightFirstSelectedItem","invokeOnOpen"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"]}],"INPUT.ARROW_DOWN":[{guard:be("isOpenControlled","autoComplete"),actions:["invokeOnOpen"]},{guard:"autoComplete",target:"interacting",actions:["invokeOnOpen"]},{guard:"isOpenControlled",actions:["highlightFirstOrSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["highlightFirstOrSelectedItem","invokeOnOpen"]}],"INPUT.ARROW_UP":[{guard:"autoComplete",target:"interacting",actions:["invokeOnOpen"]},{guard:"autoComplete",target:"interacting",actions:["invokeOnOpen"]},{target:"interacting",actions:["highlightLastOrSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["highlightLastOrSelectedItem","invokeOnOpen"]}],OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"interacting",actions:["invokeOnOpen"]}],"VALUE.CLEAR":{actions:["clearInputValue","clearSelectedItems"]}}},interacting:{tags:["open","focused"],entry:["setInitialFocus"],effects:["scrollToHighlightedItem","trackDismissableLayer","trackPlacement"],on:{"CONTROLLED.CLOSE":[{guard:"restoreFocus",target:"focused",actions:["setFinalFocus"]},{target:"idle"}],CHILDREN_CHANGE:[{guard:"isHighlightedItemRemoved",actions:["clearHighlightedValue"]},{actions:["scrollToHighlightedItem"]}],"INPUT.HOME":{actions:["highlightFirstItem"]},"INPUT.END":{actions:["highlightLastItem"]},"INPUT.ARROW_DOWN":[{guard:be("autoComplete","isLastItemHighlighted"),actions:["clearHighlightedValue","scrollContentToTop"]},{actions:["highlightNextItem"]}],"INPUT.ARROW_UP":[{guard:be("autoComplete","isFirstItemHighlighted"),actions:["clearHighlightedValue"]},{actions:["highlightPrevItem"]}],"INPUT.ENTER":[{guard:be("isOpenControlled","isCustomValue",Be("hasHighlightedItem"),Be("allowCustomValue")),actions:["revertInputValue","invokeOnClose"]},{guard:be("isCustomValue",Be("hasHighlightedItem"),Be("allowCustomValue")),target:"focused",actions:["revertInputValue","invokeOnClose"]},{guard:be("isOpenControlled","closeOnSelect"),actions:["selectHighlightedItem","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectHighlightedItem","invokeOnClose","setFinalFocus"]},{actions:["selectHighlightedItem"]}],"INPUT.CHANGE":[{guard:"autoComplete",target:"suggesting",actions:["setInputValue"]},{target:"suggesting",actions:["clearHighlightedValue","setInputValue"]}],"ITEM.POINTER_MOVE":{actions:["setHighlightedValue"]},"ITEM.POINTER_LEAVE":{actions:["clearHighlightedValue"]},"ITEM.CLICK":[{guard:be("isOpenControlled","closeOnSelect"),actions:["selectItem","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectItem","invokeOnClose","setFinalFocus"]},{actions:["selectItem"]}],"LAYER.ESCAPE":[{guard:be("isOpenControlled","autoComplete"),actions:["syncInputValue","invokeOnClose"]},{guard:"autoComplete",target:"focused",actions:["syncInputValue","invokeOnClose"]},{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose","setFinalFocus"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose"]}],"LAYER.INTERACT_OUTSIDE":[{guard:be("isOpenControlled","isCustomValue",Be("allowCustomValue")),actions:["revertInputValue","invokeOnClose"]},{guard:be("isCustomValue",Be("allowCustomValue")),target:"idle",actions:["revertInputValue","invokeOnClose"]},{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"idle",actions:["invokeOnClose"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose","setFinalFocus"]}],"VALUE.CLEAR":[{guard:"isOpenControlled",actions:["clearInputValue","clearSelectedItems","invokeOnClose"]},{target:"focused",actions:["clearInputValue","clearSelectedItems","invokeOnClose","setFinalFocus"]}]}},suggesting:{tags:["open","focused"],effects:["trackDismissableLayer","scrollToHighlightedItem","trackPlacement"],entry:["setInitialFocus"],on:{"CONTROLLED.CLOSE":[{guard:"restoreFocus",target:"focused",actions:["setFinalFocus"]},{target:"idle"}],CHILDREN_CHANGE:[{guard:be("isHighlightedItemRemoved","hasCollectionItems","autoHighlight"),actions:["clearHighlightedValue","highlightFirstItem"]},{guard:"isHighlightedItemRemoved",actions:["clearHighlightedValue"]},{guard:"autoHighlight",actions:["highlightFirstItem"]}],"INPUT.ARROW_DOWN":{target:"interacting",actions:["highlightNextItem"]},"INPUT.ARROW_UP":{target:"interacting",actions:["highlightPrevItem"]},"INPUT.HOME":{target:"interacting",actions:["highlightFirstItem"]},"INPUT.END":{target:"interacting",actions:["highlightLastItem"]},"INPUT.ENTER":[{guard:be("isOpenControlled","isCustomValue",Be("hasHighlightedItem"),Be("allowCustomValue")),actions:["revertInputValue","invokeOnClose"]},{guard:be("isCustomValue",Be("hasHighlightedItem"),Be("allowCustomValue")),target:"focused",actions:["revertInputValue","invokeOnClose"]},{guard:be("isOpenControlled","closeOnSelect"),actions:["selectHighlightedItem","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectHighlightedItem","invokeOnClose","setFinalFocus"]},{actions:["selectHighlightedItem"]}],"INPUT.CHANGE":{actions:["setInputValue"]},"LAYER.ESCAPE":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose"]}],"ITEM.POINTER_MOVE":{target:"interacting",actions:["setHighlightedValue"]},"ITEM.POINTER_LEAVE":{actions:["clearHighlightedValue"]},"LAYER.INTERACT_OUTSIDE":[{guard:be("isOpenControlled","isCustomValue",Be("allowCustomValue")),actions:["revertInputValue","invokeOnClose"]},{guard:be("isCustomValue",Be("allowCustomValue")),target:"idle",actions:["revertInputValue","invokeOnClose"]},{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"idle",actions:["invokeOnClose"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose"]}],"ITEM.CLICK":[{guard:be("isOpenControlled","closeOnSelect"),actions:["selectItem","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectItem","invokeOnClose","setFinalFocus"]},{actions:["selectItem"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose","setFinalFocus"]}],"VALUE.CLEAR":[{guard:"isOpenControlled",actions:["clearInputValue","clearSelectedItems","invokeOnClose"]},{target:"focused",actions:["clearInputValue","clearSelectedItems","invokeOnClose","setFinalFocus"]}]}}},implementations:{guards:{isInputValueEmpty:({computed:e})=>e("isInputValueEmpty"),autoComplete:({computed:e,prop:t})=>e("autoComplete")&&!t("multiple"),autoHighlight:({computed:e})=>e("autoHighlight"),isFirstItemHighlighted:({prop:e,context:t})=>e("collection").firstValue===t.get("highlightedValue"),isLastItemHighlighted:({prop:e,context:t})=>e("collection").lastValue===t.get("highlightedValue"),isCustomValue:({computed:e})=>e("isCustomValue"),allowCustomValue:({prop:e})=>!!e("allowCustomValue"),hasHighlightedItem:({context:e})=>e.get("highlightedValue")!=null,closeOnSelect:({prop:e})=>!!e("closeOnSelect"),isOpenControlled:({prop:e})=>e("open")!=null,openOnChange:({prop:e,context:t})=>{let n=e("openOnChange");return sl(n)?n:!!(n!=null&&n({inputValue:t.get("inputValue")}))},restoreFocus:({event:e})=>{var n,r;let t=(r=e.restoreFocus)!=null?r:(n=e.previousEvent)==null?void 0:n.restoreFocus;return t==null?!0:!!t},isChangeEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="INPUT.CHANGE"},autoFocus:({prop:e})=>!!e("autoFocus"),isHighlightedItemRemoved:({prop:e,context:t})=>!e("collection").has(t.get("highlightedValue")),hasCollectionItems:({prop:e})=>e("collection").size>0},effects:{trackDismissableLayer({send:e,prop:t,scope:n}){return t("disableLayer")?void 0:vt(()=>fn(n),{type:"listbox",defer:!0,exclude:()=>[pn(n),Ar(n),rv(n)],onFocusOutside:t("onFocusOutside"),onPointerDownOutside:t("onPointerDownOutside"),onInteractOutside:t("onInteractOutside"),onEscapeKeyDown(i){i.preventDefault(),i.stopPropagation(),e({type:"LAYER.ESCAPE",src:"escape-key"})},onDismiss(){e({type:"LAYER.INTERACT_OUTSIDE",src:"interact-outside",restoreFocus:!1})}})},trackPlacement({context:e,prop:t,scope:n}){let r=()=>Ec(n)||Ar(n),i=()=>bc(n);return e.set("currentPlacement",t("positioning").placement),at(r,i,y(m({},t("positioning")),{defer:!0,onComplete(s){e.set("currentPlacement",s.placement)}}))},scrollToHighlightedItem({context:e,prop:t,scope:n,event:r}){let i=pn(n),s=[],o=c=>{let u=r.current().type.includes("POINTER"),h=e.get("highlightedValue");if(u||!h)return;let p=fn(n),d=t("scrollToIndexFn");if(d){let b=t("collection").indexOf(h);d({index:b,immediate:c,getElement:()=>er(n,h)});return}let g=er(n,h),v=H(()=>{ln(g,{rootEl:p,block:"nearest"})});s.push(v)},a=H(()=>o(!0));s.push(a);let l=Ln(i,{attributes:["aria-activedescendant"],callback:()=>o(!1)});return s.push(l),()=>{s.forEach(c=>c())}}},actions:{reposition({context:e,prop:t,scope:n,event:r}){at(()=>Ec(n),()=>bc(n),y(m(m({},t("positioning")),r.options),{defer:!0,listeners:!1,onComplete(o){e.set("currentPlacement",o.placement)}}))},setHighlightedValue({context:e,event:t}){t.value!=null&&e.set("highlightedValue",t.value)},clearHighlightedValue({context:e}){e.set("highlightedValue",null)},selectHighlightedItem(e){var a;let{context:t,prop:n}=e,r=n("collection"),i=t.get("highlightedValue");if(!i||!r.has(i))return;let s=n("multiple")?it(t.get("value"),i):[i];(a=n("onSelect"))==null||a({value:s,itemValue:i}),t.set("value",s);let o=Ve(n("selectionBehavior"),{preserve:t.get("inputValue"),replace:r.stringifyMany(s),clear:""});t.set("inputValue",o)},scrollToHighlightedItem({context:e,prop:t,scope:n}){an(()=>{let r=e.get("highlightedValue");if(r==null)return;let i=er(n,r),s=fn(n),o=t("scrollToIndexFn");if(o){let a=t("collection").indexOf(r);o({index:a,immediate:!0,getElement:()=>er(n,r)});return}ln(i,{rootEl:s,block:"nearest"})})},selectItem(e){let{context:t,event:n,flush:r,prop:i}=e;n.value!=null&&r(()=>{var a;let s=i("multiple")?it(t.get("value"),n.value):[n.value];(a=i("onSelect"))==null||a({value:s,itemValue:n.value}),t.set("value",s);let o=Ve(i("selectionBehavior"),{preserve:t.get("inputValue"),replace:i("collection").stringifyMany(s),clear:""});t.set("inputValue",o)})},clearItem(e){let{context:t,event:n,flush:r,prop:i}=e;n.value!=null&&r(()=>{let s=ht(t.get("value"),n.value);t.set("value",s);let o=Ve(i("selectionBehavior"),{preserve:t.get("inputValue"),replace:i("collection").stringifyMany(s),clear:""});t.set("inputValue",o)})},setInitialFocus({scope:e}){H(()=>{Cc(e)})},setFinalFocus({scope:e}){H(()=>{let t=Ar(e);(t==null?void 0:t.dataset.focusable)==null?Cc(e):iv(e)})},syncInputValue({context:e,scope:t,event:n}){let r=pn(t);r&&(r.value=e.get("inputValue"),queueMicrotask(()=>{n.current().type!=="INPUT.CHANGE"&&Aa(r)}))},setInputValue({context:e,event:t}){e.set("inputValue",t.value)},clearInputValue({context:e}){e.set("inputValue","")},revertInputValue({context:e,prop:t,computed:n}){let r=t("selectionBehavior"),i=Ve(r,{replace:n("hasSelectedItems")?n("valueAsString"):"",preserve:e.get("inputValue"),clear:""});e.set("inputValue",i)},setValue(e){let{context:t,flush:n,event:r,prop:i}=e;n(()=>{t.set("value",r.value);let s=Ve(i("selectionBehavior"),{preserve:t.get("inputValue"),replace:i("collection").stringifyMany(r.value),clear:""});t.set("inputValue",s)})},clearSelectedItems(e){let{context:t,flush:n,prop:r}=e;n(()=>{t.set("value",[]);let i=Ve(r("selectionBehavior"),{preserve:t.get("inputValue"),replace:r("collection").stringifyMany([]),clear:""});t.set("inputValue",i)})},scrollContentToTop({prop:e,scope:t}){let n=e("scrollToIndexFn");if(n){let r=e("collection").firstValue;n({index:0,immediate:!0,getElement:()=>er(t,r)})}else{let r=fn(t);if(!r)return;r.scrollTop=0}},invokeOnOpen({prop:e,event:t,context:n}){var i;let r=Ic(t);(i=e("onOpenChange"))==null||i({open:!0,reason:r,value:n.get("value")})},invokeOnClose({prop:e,event:t,context:n}){var i;let r=Ic(t);(i=e("onOpenChange"))==null||i({open:!1,reason:r,value:n.get("value")})},highlightFirstItem({context:e,prop:t,scope:n}){(fn(n)?queueMicrotask:H)(()=>{let i=t("collection").firstValue;i&&e.set("highlightedValue",i)})},highlightFirstItemIfNeeded({computed:e,action:t}){e("autoHighlight")&&t(["highlightFirstItem"])},highlightLastItem({context:e,prop:t,scope:n}){(fn(n)?queueMicrotask:H)(()=>{let i=t("collection").lastValue;i&&e.set("highlightedValue",i)})},highlightNextItem({context:e,prop:t}){let n=null,r=e.get("highlightedValue"),i=t("collection");r?(n=i.getNextValue(r),!n&&t("loopFocus")&&(n=i.firstValue)):n=i.firstValue,n&&e.set("highlightedValue",n)},highlightPrevItem({context:e,prop:t}){let n=null,r=e.get("highlightedValue"),i=t("collection");r?(n=i.getPreviousValue(r),!n&&t("loopFocus")&&(n=i.lastValue)):n=i.lastValue,n&&e.set("highlightedValue",n)},highlightFirstSelectedItem({context:e,prop:t}){H(()=>{let[n]=t("collection").sort(e.get("value"));n&&e.set("highlightedValue",n)})},highlightFirstOrSelectedItem({context:e,prop:t,computed:n}){H(()=>{let r=null;n("hasSelectedItems")?r=t("collection").sort(e.get("value"))[0]:r=t("collection").firstValue,r&&e.set("highlightedValue",r)})},highlightLastOrSelectedItem({context:e,prop:t,computed:n}){H(()=>{let r=t("collection"),i=null;n("hasSelectedItems")?i=r.sort(e.get("value"))[0]:i=r.lastValue,i&&e.set("highlightedValue",i)})},autofillInputValue({context:e,computed:t,prop:n,event:r,scope:i}){let s=pn(i),o=n("collection");if(!t("autoComplete")||!s||!r.keypress)return;let a=o.stringify(e.get("highlightedValue"));H(()=>{s.value=a||e.get("inputValue")})},syncSelectedItems(e){queueMicrotask(()=>{let{context:t,prop:n}=e,r=n("collection"),i=t.get("value"),s=i.map(a=>t.get("selectedItems").find(c=>r.getItemValue(c)===a)||r.find(a));t.set("selectedItems",s);let o=Ve(n("selectionBehavior"),{preserve:t.get("inputValue"),replace:r.stringifyMany(i),clear:""});t.set("inputValue",o)})},syncHighlightedItem({context:e,prop:t}){let n=t("collection").find(e.get("highlightedValue"));e.set("highlightedItem",n)},toggleVisibility({event:e,send:t,prop:n}){t({type:n("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:e})}}}});uv=G()(["allowCustomValue","autoFocus","closeOnSelect","collection","composite","defaultHighlightedValue","defaultInputValue","defaultOpen","defaultValue","dir","disabled","disableLayer","form","getRootNode","highlightedValue","id","ids","inputBehavior","inputValue","invalid","loopFocus","multiple","name","navigate","onFocusOutside","onHighlightChange","onInputValueChange","onInteractOutside","onOpenChange","onOpenChange","onPointerDownOutside","onSelect","onValueChange","open","openOnChange","openOnClick","openOnKeyPress","placeholder","positioning","readOnly","required","scrollToIndexFn","selectionBehavior","translations","value","alwaysSubmitOnEnter"]),dT=B(uv),dv=G()(["htmlFor"]),hT=B(dv),hv=G()(["id"]),gT=B(hv),gv=G()(["item","persistFocus"]),fT=B(gv),fv=class extends te{constructor(){super(...arguments);U(this,"options",[]);U(this,"allOptions",[]);U(this,"hasGroups",!1)}setAllOptions(t){this.allOptions=t,this.options=t}getCollection(){let t=this.options||this.allOptions||[];return this.hasGroups?Ui({items:t,itemToValue:n=>n.id,itemToString:n=>n.label,isItemDisabled:n=>n.disabled,groupBy:n=>n.group}):Ui({items:t,itemToValue:n=>n.id,itemToString:n=>n.label,isItemDisabled:n=>n.disabled})}initMachine(t){let n=this;return new ee(cv,y(m({},t),{get collection(){return n.getCollection()},onOpenChange:r=>{r.open&&(n.options=n.allOptions),t.onOpenChange&&t.onOpenChange(r)},onInputValueChange:r=>{let i=n.allOptions.filter(s=>s.label.toLowerCase().includes(r.inputValue.toLowerCase()));n.options=i.length>0?i:n.allOptions,t.onInputValueChange&&t.onInputValueChange(r)}}))}initApi(){return sv(this.machine.service,Q)}renderItems(){var o,a,l;let t=this.el.querySelector('[data-scope="combobox"][data-part="content"]');if(!t)return;let n=this.el.querySelector('[data-templates="combobox"]');if(!n)return;t.querySelectorAll('[data-scope="combobox"][data-part="item"]:not([data-template])').forEach(c=>c.remove()),t.querySelectorAll('[data-scope="combobox"][data-part="item-group"]:not([data-template])').forEach(c=>c.remove());let r=this.api.collection.items,i=(l=(a=(o=this.api.collection).group)==null?void 0:a.call(o))!=null?l:[];i.some(([c])=>c!=null)?this.renderGroupedItems(t,n,i):this.renderFlatItems(t,n,r)}renderGroupedItems(t,n,r){for(let[i,s]of r){if(i==null)continue;let o=n.querySelector(`[data-scope="combobox"][data-part="item-group"][data-id="${i}"][data-template]`);if(!o)continue;let a=o.cloneNode(!0);a.removeAttribute("data-template"),this.spreadProps(a,this.api.getItemGroupProps({id:i}));let l=a.querySelector('[data-scope="combobox"][data-part="item-group-label"]');l&&this.spreadProps(l,this.api.getItemGroupLabelProps({htmlFor:i}));let c=a.querySelector('[data-scope="combobox"][data-part="item-group-content"]');if(c){c.innerHTML="";for(let u of s){let h=this.cloneItem(n,u);h&&c.appendChild(h)}t.appendChild(a)}}}renderFlatItems(t,n,r){for(let i of r){let s=this.cloneItem(n,i);s&&t.appendChild(s)}}cloneItem(t,n){let r=this.api.collection.getItemValue(n),i=t.querySelector(`[data-scope="combobox"][data-part="item"][data-value="${r}"][data-template]`);if(!i)return null;let s=i.cloneNode(!0);s.removeAttribute("data-template"),this.spreadProps(s,this.api.getItemProps({item:n}));let o=s.querySelector('[data-scope="combobox"][data-part="item-text"]');o&&(this.spreadProps(o,this.api.getItemTextProps({item:n})),o.children.length===0&&(o.textContent=n.label||""));let a=s.querySelector('[data-scope="combobox"][data-part="item-indicator"]');return a&&this.spreadProps(a,this.api.getItemIndicatorProps({item:n})),s}render(){let t=this.el.querySelector('[data-scope="combobox"][data-part="root"]');if(!t)return;this.spreadProps(t,this.api.getRootProps()),["label","control","input","trigger","clear-trigger","positioner"].forEach(r=>{let i=this.el.querySelector(`[data-scope="combobox"][data-part="${r}"]`);if(!i)return;let s="get"+r.split("-").map(o=>o[0].toUpperCase()+o.slice(1)).join("")+"Props";this.spreadProps(i,this.api[s]())});let n=this.el.querySelector('[data-scope="combobox"][data-part="content"]');n&&(this.spreadProps(n,this.api.getContentProps()),this.renderItems())}};vv={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=JSON.parse(e.dataset.collection||"[]"),r=n.some(a=>a.group!==void 0),i=y(m({id:e.id},O(e,"controlled")?{value:Y(e,"value")}:{defaultValue:Y(e,"defaultValue")}),{disabled:O(e,"disabled"),placeholder:x(e,"placeholder"),alwaysSubmitOnEnter:O(e,"alwaysSubmitOnEnter"),autoFocus:O(e,"autoFocus"),closeOnSelect:O(e,"closeOnSelect"),dir:x(e,"dir",["ltr","rtl"]),inputBehavior:x(e,"inputBehavior",["autohighlight","autocomplete","none"]),loopFocus:O(e,"loopFocus"),multiple:O(e,"multiple"),invalid:O(e,"invalid"),allowCustomValue:!1,selectionBehavior:"replace",name:x(e,"name"),form:x(e,"form"),readOnly:O(e,"readOnly"),required:O(e,"required"),positioning:(()=>{let a=e.dataset.positioning;if(a)try{let l=JSON.parse(a);return mv(l)}catch(l){return}})(),onOpenChange:a=>{let l=x(e,"onOpenChange");l&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(l,{open:a.open,reason:a.reason,value:a.value,id:e.id});let c=x(e,"onOpenChangeClient");c&&e.dispatchEvent(new CustomEvent(c,{bubbles:O(e,"bubble"),detail:{open:a.open,reason:a.reason,value:a.value,id:e.id}}))},onInputValueChange:a=>{let l=x(e,"onInputValueChange");l&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(l,{value:a.inputValue,reason:a.reason,id:e.id});let c=x(e,"onInputValueChangeClient");c&&e.dispatchEvent(new CustomEvent(c,{bubbles:O(e,"bubble"),detail:{value:a.inputValue,reason:a.reason,id:e.id}}))},onValueChange:a=>{let l=e.querySelector('[data-scope="combobox"][data-part="value-input"]');if(l){let h=a.value.length===0?"":a.value.length===1?String(a.value[0]):a.value.map(String).join(",");l.value=h;let p=l.getAttribute("form"),d=null;p?d=document.getElementById(p):d=l.closest("form");let g=new Event("change",{bubbles:!0,cancelable:!0});l.dispatchEvent(g);let v=new Event("input",{bubbles:!0,cancelable:!0});l.dispatchEvent(v),d&&d.hasAttribute("phx-change")&&requestAnimationFrame(()=>{let b=d.querySelector("input, select, textarea");if(b){let V=new Event("change",{bubbles:!0,cancelable:!0});b.dispatchEvent(V)}else{let V=new Event("change",{bubbles:!0,cancelable:!0});d.dispatchEvent(V)}})}let c=x(e,"onValueChange");c&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(c,{value:a.value,items:a.items,id:e.id});let u=x(e,"onValueChangeClient");u&&e.dispatchEvent(new CustomEvent(u,{bubbles:O(e,"bubble"),detail:{value:a.value,items:a.items,id:e.id}}))}}),s=new fv(e,i);s.hasGroups=r,s.setAllOptions(n),s.init();let o=O(e,"controlled")?Y(e,"value"):Y(e,"defaultValue");if(o&&o.length>0){let a=n.filter(l=>o.includes(l.id));if(a.length>0){let l=a.map(c=>c.label).join(", ");if(s.api&&typeof s.api.setInputValue=="function")s.api.setInputValue(l);else{let c=e.querySelector('[data-scope="combobox"][data-part="input"]');c&&(c.value=l)}}}this.combobox=s,this.handlers=[]},updated(){let e=JSON.parse(this.el.dataset.collection||"[]"),t=e.some(n=>n.group!==void 0);if(this.combobox){this.combobox.hasGroups=t,this.combobox.setAllOptions(e),this.combobox.updateProps(y(m({},O(this.el,"controlled")?{value:Y(this.el,"value")}:{defaultValue:Y(this.el,"defaultValue")}),{name:x(this.el,"name"),form:x(this.el,"form"),disabled:O(this.el,"disabled"),multiple:O(this.el,"multiple"),dir:x(this.el,"dir",["ltr","rtl"]),invalid:O(this.el,"invalid"),required:O(this.el,"required"),readOnly:O(this.el,"readOnly")}));let n=this.el.querySelector('[data-scope="combobox"][data-part="input"]');n&&(n.removeAttribute("name"),n.removeAttribute("form"),n.name="")}},destroyed(){var e;if(this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.combobox)==null||e.destroy()}}});var Su={};Oe(Su,{DatePicker:()=>lb});function vo(e,t){return e-t*Math.floor(e/t)}function qi(e,t,n,r){t=Do(e,t);let i=t-1,s=-2;return n<=2?s=0:Ji(t)&&(s=-1),qc-1+365*i+Math.floor(i/4)-Math.floor(i/100)+Math.floor(i/400)+Math.floor((367*n-362)/12+s+r)}function Ji(e){return e%4===0&&(e%100!==0||e%400===0)}function Do(e,t){return e==="BC"?1-t:t}function yv(e){let t="AD";return e<=0&&(t="BC",e=1-e),[t,e]}function bn(e,t){return t=Ue(t,e.calendar),e.era===t.era&&e.year===t.year&&e.month===t.month&&e.day===t.day}function Cv(e,t){return t=Ue(t,e.calendar),e=Lt(e),t=Lt(t),e.era===t.era&&e.year===t.year&&e.month===t.month}function Iv(e,t){return t=Ue(t,e.calendar),e=Lr(e),t=Lr(t),e.era===t.era&&e.year===t.year}function Tv(e,t){return ts(e.calendar,t.calendar)&&bn(e,t)}function Ov(e,t){return ts(e.calendar,t.calendar)&&Cv(e,t)}function Sv(e,t){return ts(e.calendar,t.calendar)&&Iv(e,t)}function ts(e,t){var n,r,i,s;return(s=(i=(n=e.isEqual)===null||n===void 0?void 0:n.call(e,t))!==null&&i!==void 0?i:(r=t.isEqual)===null||r===void 0?void 0:r.call(t,e))!==null&&s!==void 0?s:e.identifier===t.identifier}function Pv(e,t){return bn(e,ns(t))}function Wc(e,t,n){let r=e.calendar.toJulianDay(e),i=n?wv[n]:kv(t),s=Math.ceil(r+1-i)%7;return s<0&&(s+=7),s}function Kc(e){return Ft(Date.now(),e)}function ns(e){return mn(Kc(e))}function Yc(e,t){return e.calendar.toJulianDay(e)-t.calendar.toJulianDay(t)}function Vv(e,t){return xc(e)-xc(t)}function xc(e){return e.hour*36e5+e.minute*6e4+e.second*1e3+e.millisecond}function Lo(){return yo==null&&(yo=new Intl.DateTimeFormat().resolvedOptions().timeZone),yo}function Lt(e){return e.subtract({days:e.day-1})}function So(e){return e.add({days:e.calendar.getDaysInMonth(e)-e.day})}function Lr(e){return Lt(e.subtract({months:e.month-1}))}function xv(e){return So(e.add({months:e.calendar.getMonthsInYear(e)-e.month}))}function Fr(e,t,n){let r=Wc(e,t,n);return e.subtract({days:r})}function kc(e,t,n){return Fr(e,t,n).add({days:6})}function jc(e){if(Intl.Locale){let n=Nc.get(e);return n||(n=new Intl.Locale(e).maximize().region,n&&Nc.set(e,n)),n}let t=e.split("-")[1];return t==="u"?void 0:t}function kv(e){let t=bo.get(e);if(!t){if(Intl.Locale){let r=new Intl.Locale(e);if("getWeekInfo"in r&&(t=r.getWeekInfo(),t))return bo.set(e,t),t.firstDay}let n=jc(e);if(e.includes("-fw-")){let r=e.split("-fw-")[1].split("-")[0];r==="mon"?t={firstDay:1}:r==="tue"?t={firstDay:2}:r==="wed"?t={firstDay:3}:r==="thu"?t={firstDay:4}:r==="fri"?t={firstDay:5}:r==="sat"?t={firstDay:6}:t={firstDay:0}}else e.includes("-ca-iso8601")?t={firstDay:1}:t={firstDay:n&&Ev[n]||0};bo.set(e,t)}return t.firstDay}function Nv(e,t,n){let r=e.calendar.getDaysInMonth(e);return Math.ceil((Wc(Lt(e),t,n)+r)/7)}function Xc(e,t){return e&&t?e.compare(t)<=0?e:t:e||t}function Zc(e,t){return e&&t?e.compare(t)>=0?e:t:e||t}function Rv(e,t){let n=e.calendar.toJulianDay(e),r=Math.ceil(n+1)%7;r<0&&(r+=7);let i=jc(t),[s,o]=Av[i]||[6,0];return r===s||r===o}function sr(e){e=Ue(e,new ir);let t=Do(e.era,e.year);return Jc(t,e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function Jc(e,t,n,r,i,s,o){let a=new Date;return a.setUTCHours(r,i,s,o),a.setUTCFullYear(e,t-1,n),a.getTime()}function Po(e,t){if(t==="UTC")return 0;if(e>0&&t===Lo())return new Date(e).getTimezoneOffset()*-6e4;let{year:n,month:r,day:i,hour:s,minute:o,second:a}=zc(e,t);return Jc(n,r,i,s,o,a,0)-Math.floor(e/1e3)*1e3}function zc(e,t){let n=Ac.get(t);n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Ac.set(t,n));let r=n.formatToParts(new Date(e)),i={};for(let s of r)s.type!=="literal"&&(i[s.type]=s.value);return{year:i.era==="BC"||i.era==="B"?-i.year+1:+i.year,month:+i.month,day:+i.day,hour:i.hour==="24"?0:+i.hour,minute:+i.minute,second:+i.second}}function Dv(e,t,n,r){return(n===r?[n]:[n,r]).filter(s=>Lv(e,t,s))}function Lv(e,t,n){let r=zc(n,t);return e.year===r.year&&e.month===r.month&&e.day===r.day&&e.hour===r.hour&&e.minute===r.minute&&e.second===r.second}function Dt(e,t,n="compatible"){let r=vn(e);if(t==="UTC")return sr(r);if(t===Lo()&&n==="compatible"){r=Ue(r,new ir);let l=new Date,c=Do(r.era,r.year);return l.setFullYear(c,r.month-1,r.day),l.setHours(r.hour,r.minute,r.second,r.millisecond),l.getTime()}let i=sr(r),s=Po(i-Rc,t),o=Po(i+Rc,t),a=Dv(r,t,i-s,i-o);if(a.length===1)return a[0];if(a.length>1)switch(n){case"compatible":case"earlier":return a[0];case"later":return a[a.length-1];case"reject":throw new RangeError("Multiple possible absolute times found")}switch(n){case"earlier":return Math.min(i-s,i-o);case"compatible":case"later":return Math.max(i-s,i-o);case"reject":throw new RangeError("No such absolute time found")}}function Qc(e,t,n="compatible"){return new Date(Dt(e,t,n))}function Ft(e,t){let n=Po(e,t),r=new Date(e+n),i=r.getUTCFullYear(),s=r.getUTCMonth()+1,o=r.getUTCDate(),a=r.getUTCHours(),l=r.getUTCMinutes(),c=r.getUTCSeconds(),u=r.getUTCMilliseconds();return new au(i<1?"BC":"AD",i<1?-i+1:i,s,o,t,n,a,l,c,u)}function mn(e){return new or(e.calendar,e.era,e.year,e.month,e.day)}function vn(e,t){let n=0,r=0,i=0,s=0;if("timeZone"in e)({hour:n,minute:r,second:i,millisecond:s}=e);else if("hour"in e&&!t)return e;return t&&({hour:n,minute:r,second:i,millisecond:s}=t),new ny(e.calendar,e.era,e.year,e.month,e.day,n,r,i,s)}function Ue(e,t){if(ts(e.calendar,t))return e;let n=t.fromJulianDay(e.calendar.toJulianDay(e)),r=e.copy();return r.calendar=t,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,yn(r),r}function Fv(e,t,n){if(e instanceof au)return e.timeZone===t?e:$v(e,t);let r=Dt(e,t,n);return Ft(r,t)}function Mv(e){let t=sr(e)-e.offset;return new Date(t)}function $v(e,t){let n=sr(e)-e.offset;return Ue(Ft(n,t),e.calendar)}function rs(e,t){let n=e.copy(),r="hour"in n?Gv(n,t):0;wo(n,t.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,e),n.month+=t.months||0,Vo(n),eu(n),n.day+=(t.weeks||0)*7,n.day+=t.days||0,n.day+=r,_v(n),n.calendar.balanceDate&&n.calendar.balanceDate(n),n.year<1&&(n.year=1,n.month=1,n.day=1);let i=n.calendar.getYearsInEra(n);if(n.year>i){var s,o;let l=(s=(o=n.calendar).isInverseEra)===null||s===void 0?void 0:s.call(o,n);n.year=i,n.month=l?1:n.calendar.getMonthsInYear(n),n.day=l?1:n.calendar.getDaysInMonth(n)}n.month<1&&(n.month=1,n.day=1);let a=n.calendar.getMonthsInYear(n);return n.month>a&&(n.month=a,n.day=n.calendar.getDaysInMonth(n)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day)),n}function wo(e,t){var n,r;!((n=(r=e.calendar).isInverseEra)===null||n===void 0)&&n.call(r,e)&&(t=-t),e.year+=t}function Vo(e){for(;e.month<1;)wo(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,wo(e,1)}function _v(e){for(;e.day<1;)e.month--,Vo(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,Vo(e)}function eu(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function yn(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),eu(e)}function tu(e){let t={};for(let n in e)typeof e[n]=="number"&&(t[n]=-e[n]);return t}function nu(e,t){return rs(e,tu(t))}function Fo(e,t){let n=e.copy();return t.era!=null&&(n.era=t.era),t.year!=null&&(n.year=t.year),t.month!=null&&(n.month=t.month),t.day!=null&&(n.day=t.day),yn(n),n}function es(e,t){let n=e.copy();return t.hour!=null&&(n.hour=t.hour),t.minute!=null&&(n.minute=t.minute),t.second!=null&&(n.second=t.second),t.millisecond!=null&&(n.millisecond=t.millisecond),Bv(n),n}function Hv(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=Wi(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=Wi(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=Wi(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=Wi(e.hour,24),t}function Bv(e){e.millisecond=Math.max(0,Math.min(e.millisecond,1e3)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function Wi(e,t){let n=e%t;return n<0&&(n+=t),n}function Gv(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,Hv(e)}function Mo(e,t,n,r){let i=e.copy();switch(t){case"era":{let a=e.calendar.getEras(),l=a.indexOf(e.era);if(l<0)throw new Error("Invalid era: "+e.era);l=Mt(l,n,0,a.length-1,r==null?void 0:r.round),i.era=a[l],yn(i);break}case"year":var s,o;!((s=(o=i.calendar).isInverseEra)===null||s===void 0)&&s.call(o,i)&&(n=-n),i.year=Mt(e.year,n,-1/0,9999,r==null?void 0:r.round),i.year===-1/0&&(i.year=1),i.calendar.balanceYearMonth&&i.calendar.balanceYearMonth(i,e);break;case"month":i.month=Mt(e.month,n,1,e.calendar.getMonthsInYear(e),r==null?void 0:r.round);break;case"day":i.day=Mt(e.day,n,1,e.calendar.getDaysInMonth(e),r==null?void 0:r.round);break;default:throw new Error("Unsupported field "+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(i),yn(i),i}function ru(e,t,n,r){let i=e.copy();switch(t){case"hour":{let s=e.hour,o=0,a=23;if((r==null?void 0:r.hourCycle)===12){let l=s>=12;o=l?12:0,a=l?23:11}i.hour=Mt(s,n,o,a,r==null?void 0:r.round);break}case"minute":i.minute=Mt(e.minute,n,0,59,r==null?void 0:r.round);break;case"second":i.second=Mt(e.second,n,0,59,r==null?void 0:r.round);break;case"millisecond":i.millisecond=Mt(e.millisecond,n,0,999,r==null?void 0:r.round);break;default:throw new Error("Unsupported field "+t)}return i}function Mt(e,t,n,r,i=!1){if(i){e+=Math.sign(t),e0?e=Math.ceil(e/s)*s:e=Math.floor(e/s)*s,e>r&&(e=n)}else e+=t,er&&(e=n+(e-r-1));return e}function iu(e,t){let n;if(t.years!=null&&t.years!==0||t.months!=null&&t.months!==0||t.weeks!=null&&t.weeks!==0||t.days!=null&&t.days!==0){let i=rs(vn(e),{years:t.years,months:t.months,weeks:t.weeks,days:t.days});n=Dt(i,e.timeZone)}else n=sr(e)-e.offset;n+=t.milliseconds||0,n+=(t.seconds||0)*1e3,n+=(t.minutes||0)*6e4,n+=(t.hours||0)*36e5;let r=Ft(n,e.timeZone);return Ue(r,e.calendar)}function Uv(e,t){return iu(e,tu(t))}function qv(e,t,n,r){switch(t){case"hour":{let i=0,s=23;if((r==null?void 0:r.hourCycle)===12){let g=e.hour>=12;i=g?12:0,s=g?23:11}let o=vn(e),a=Ue(es(o,{hour:i}),new ir),l=[Dt(a,e.timeZone,"earlier"),Dt(a,e.timeZone,"later")].filter(g=>Ft(g,e.timeZone).day===a.day)[0],c=Ue(es(o,{hour:s}),new ir),u=[Dt(c,e.timeZone,"earlier"),Dt(c,e.timeZone,"later")].filter(g=>Ft(g,e.timeZone).day===c.day).pop(),h=sr(e)-e.offset,p=Math.floor(h/Rr),d=h%Rr;return h=Mt(p,n,Math.floor(l/Rr),Math.floor(u/Rr),r==null?void 0:r.round)*Rr+d,Ue(Ft(h,e.timeZone),e.calendar)}case"minute":case"second":case"millisecond":return ru(e,t,n,r);case"era":case"year":case"month":case"day":{let i=Mo(vn(e),t,n,r),s=Dt(i,e.timeZone);return Ue(Ft(s,e.timeZone),e.calendar)}default:throw new Error("Unsupported field "+t)}}function Wv(e,t,n){let r=vn(e),i=es(Fo(r,t),t);if(i.compare(r)===0)return e;let s=Dt(i,e.timeZone,n);return Ue(Ft(s,e.timeZone),e.calendar)}function Xv(e){let t=e.match(Kv);if(!t)throw Yv.test(e)?new Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date string: "+e);let n=new or(Eo(t[1],0,9999),Eo(t[2],1,12),1);return n.day=Eo(t[3],1,n.calendar.getDaysInMonth(n)),n}function Eo(e,t,n){let r=Number(e);if(rn)throw new RangeError(`Value out of range: ${t} <= ${r} <= ${n}`);return r}function Zv(e){return`${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${e.millisecond?String(e.millisecond/1e3).slice(1):""}`}function su(e){let t=Ue(e,new ir),n;return t.era==="BC"?n=t.year===1?"0000":"-"+String(Math.abs(1-t.year)).padStart(6,"00"):n=String(t.year).padStart(4,"0"),`${n}-${String(t.month).padStart(2,"0")}-${String(t.day).padStart(2,"0")}`}function ou(e){return`${su(e)}T${Zv(e)}`}function Jv(e){let t=Math.sign(e)<0?"-":"+";e=Math.abs(e);let n=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),i=Math.floor(e%36e5%6e4/1e3),s=`${t}${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`;return i!==0&&(s+=`:${String(i).padStart(2,"0")}`),s}function zv(e){return`${ou(e)}${Jv(e.offset)}[${e.timeZone}]`}function Qv(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function $o(e,t,n){Qv(e,t),t.set(e,n)}function _o(e){let t=typeof e[0]=="object"?e.shift():new ir,n;if(typeof e[0]=="string")n=e.shift();else{let o=t.getEras();n=o[o.length-1]}let r=e.shift(),i=e.shift(),s=e.shift();return[t,n,r,i,s]}function lu(e,t={}){if(typeof t.hour12=="boolean"&&sy()){t=m({},t);let i=iy[String(t.hour12)][e.split("-")[0]],s=t.hour12?"h12":"h23";t.hourCycle=i!=null?i:s,delete t.hour12}let n=e+(t?Object.entries(t).sort((i,s)=>i[0]s.type==="hour").value,10),i=parseInt(n.formatToParts(new Date(2020,2,3,23)).find(s=>s.type==="hour").value,10);if(r===0&&i===23)return"h23";if(r===24&&i===23)return"h24";if(r===0&&i===11)return"h11";if(r===12&&i===11)return"h12";throw new Error("Unexpected hour cycle result")}function ly(e,t,n,r,i){let s={};for(let a in t){let l=a,c=t[l];c!=null&&(s[l]=Math.floor(c/2),s[l]>0&&c%2===0&&s[l]--)}let o=En(e,t,n).subtract(s);return Mr(e,o,t,n,r,i)}function En(e,t,n,r,i){let s=e;return t.years?s=Lr(e):t.months?s=Lt(e):t.weeks&&(s=Fr(e,n)),Mr(e,s,t,n,r,i)}function Ho(e,t,n,r,i){let s=m({},t);s.days?s.days--:s.weeks?s.weeks--:s.months?s.months--:s.years&&s.years--;let o=En(e,t,n).subtract(s);return Mr(e,o,t,n,r,i)}function Mr(e,t,n,r,i,s){return i&&e.compare(i)>=0&&(t=Zc(t,En(mn(i),n,r))),s&&e.compare(s)<=0&&(t=Xc(t,Ho(mn(s),n,r))),t}function lt(e,t,n){let r=mn(e);return t&&(r=Zc(r,mn(t))),n&&(r=Xc(r,mn(n))),r}function Dc(e,t,n,r,i,s){switch(t){case"start":return En(e,n,r,i,s);case"end":return Ho(e,n,r,i,s);case"center":default:return ly(e,n,r,i,s)}}function Ge(e,t){return e==null||t==null?e===t:bn(e,t)}function Lc(e,t,n,r,i){return e?t!=null&&t(e,n)?!0:yt(e,r,i):!1}function yt(e,t,n){return t!=null&&e.compare(t)<0||n!=null&&e.compare(n)>0}function cy(e,t,n){let r=e.subtract({days:1});return bn(r,e)||yt(r,t,n)}function uy(e,t,n){let r=e.add({days:1});return bn(r,e)||yt(r,t,n)}function Bo(e){let t=m({},e);for(let n in t)t[n]=1;return t}function cu(e,t){let n=m({},t);return n.days?n.days--:n.days=-1,e.add(n)}function uu(e){return(e==null?void 0:e.calendar.identifier)==="gregory"&&e.era==="BC"?"short":void 0}function du(e,t){let n=vn(ns(t));return new ct(e,{weekday:"long",month:"long",year:"numeric",day:"numeric",era:uu(n),timeZone:t})}function Fc(e,t){let n=ns(t);return new ct(e,{month:"long",year:"numeric",era:uu(n),calendar:n==null?void 0:n.calendar.identifier,timeZone:t})}function dy(e,t,n,r,i){let s=n.formatRangeToParts(e.toDate(i),t.toDate(i)),o=-1;for(let c=0;co&&(l+=s[c].value);return r(a,l)}function Ki(e,t,n,r){if(!e)return"";let i=e,s=t!=null?t:e,o=du(n,r);return bn(i,s)?o.format(i.toDate(r)):dy(i,s,o,(a,l)=>`${a} \u2013 ${l}`,r)}function hu(e){return e!=null?hy[e]:void 0}function gu(e,t,n){let r=hu(n);return Fr(e,t,r)}function fu(e,t,n,r){let i=t.add({weeks:e}),s=[],o=gu(i,n,r);for(;s.length<7;){s.push(o);let a=o.add({days:1});if(bn(o,a))break;o=a}return s}function gy(e,t,n,r){let i=hu(r),s=n!=null?n:Nv(e,t,i);return[...new Array(s).keys()].map(a=>fu(a,e,t,r))}function fy(e,t){let n=new ct(e,{weekday:"long",timeZone:t}),r=new ct(e,{weekday:"short",timeZone:t}),i=new ct(e,{weekday:"narrow",timeZone:t});return s=>{let o=s instanceof Date?s:s.toDate(t);return{value:s,short:r.format(o),long:n.format(o),narrow:i.format(o)}}}function py(e,t,n,r){let i=gu(e,r,t),s=[...new Array(7).keys()],o=fy(r,n);return s.map(a=>o(i.add({days:a})))}function my(e,t="long"){let n=new Date(2021,0,1),r=[];for(let i=0;i<12;i++)r.push(n.toLocaleString(e,{month:t})),n.setMonth(n.getMonth()+1);return r}function vy(e){let t=[];for(let n=e.from;n<=e.to;n+=1)t.push(n);return t}function by(e){if(e){if(e.length===3)return e.padEnd(4,"0");if(e.length===2){let t=new Date().getFullYear(),n=Math.floor(t/100)*100,r=parseInt(e.slice(-2),10),i=n+r;return i>t+yy?(i-100).toString():i.toString()}return e}}function rr(e,t){let n=t!=null&&t.strict?10:12,r=e-e%10,i=[];for(let s=0;s0?{startDate:En(a,e,t,n,r),endDate:l,focusedDate:lt(a,n,r)}:{startDate:o,endDate:l,focusedDate:lt(a,n,r)}}}function pu(e,t,n,r,i,s){let o=$r(n,r,i,s),a=t.add(n);return o({focusedDate:e.add(n),startDate:En(Mr(e,a,n,r,i,s),n,r)})}function mu(e,t,n,r,i,s){let o=$r(n,r,i,s),a=t.subtract(n);return o({focusedDate:e.subtract(n),startDate:En(Mr(e,a,n,r,i,s),n,r)})}function Ey(e,t,n,r,i,s,o){let a=$r(r,i,s,o);if(!n&&!r.days)return a({focusedDate:e.add(Bo(r)),startDate:t});if(r.days)return pu(e,t,r,i,s,o);if(r.weeks)return a({focusedDate:e.add({months:1}),startDate:t});if(r.months||r.years)return a({focusedDate:e.add({years:1}),startDate:t})}function Cy(e,t,n,r,i,s,o){let a=$r(r,i,s,o);if(!n&&!r.days)return a({focusedDate:e.subtract(Bo(r)),startDate:t});if(r.days)return mu(e,t,r,i,s,o);if(r.weeks)return a({focusedDate:e.subtract({months:1}),startDate:t});if(r.months||r.years)return a({focusedDate:e.subtract({years:1}),startDate:t})}function Oy(e,t,n){var c;let r=Sy(t,n),{year:i,month:s,day:o}=(c=Py(r,e))!=null?c:{};if(i!=null||s!=null||o!=null){let u=new Date;i||(i=u.getFullYear().toString()),s||(s=(u.getMonth()+1).toString()),o||(o=u.getDate().toString())}if(Mc(i)||(i=by(i)),Mc(i)&&Iy(s)&&Ty(o))return new or(+i,+s,+o);let l=Date.parse(e);if(!isNaN(l)){let u=new Date(l);return new or(u.getFullYear(),u.getMonth()+1,u.getDate())}}function Sy(e,t){return new ct(e,{day:"numeric",month:"numeric",year:"numeric",timeZone:t}).formatToParts(new Date(2e3,11,25)).map(({type:i,value:s})=>i==="literal"?`${s}?`:`((?!=<${i}>)\\d+)?`).join("")}function Py(e,t){var r;let n=t.match(e);return(r=e.toString().match(/<(.+?)>/g))==null?void 0:r.map(i=>{var o;let s=i.match(/<(.+)>/);return!s||s.length<=0?null:(o=i.match(/<(.+)>/))==null?void 0:o[1]}).reduce((i,s,o)=>(s&&(n&&n.length>o?i[s]=n[o+1]:i[s]=null),i),{})}function $c(e,t,n){let r=mn(Kc(n));switch(e){case"thisWeek":return[Fr(r,t),kc(r,t)];case"thisMonth":return[Lt(r),r];case"thisQuarter":return[Lt(r).add({months:-((r.month-1)%3)}),r];case"thisYear":return[Lr(r),r];case"last3Days":return[r.add({days:-2}),r];case"last7Days":return[r.add({days:-6}),r];case"last14Days":return[r.add({days:-13}),r];case"last30Days":return[r.add({days:-29}),r];case"last90Days":return[r.add({days:-89}),r];case"lastMonth":return[Lt(r.add({months:-1})),So(r.add({months:-1}))];case"lastQuarter":return[Lt(r.add({months:-((r.month-1)%3)-3})),So(r.add({months:-((r.month-1)%3)-1}))];case"lastWeek":return[Fr(r,t).add({weeks:-1}),kc(r,t).add({weeks:-1})];case"lastYear":return[Lr(r.add({years:-1})),xv(r.add({years:-1}))];default:throw new Error(`Invalid date range preset: ${e}`)}}function wy(e={}){var c;let{level:t="polite",document:n=document,root:r,delay:i=0}=e,s=(c=n.defaultView)!=null?c:window,o=r!=null?r:n.body;function a(u,h){let p=n.getElementById(Yi);p==null||p.remove(),h=h!=null?h:i;let d=n.createElement("span");d.id=Yi,d.dataset.liveAnnouncer="true";let g=t!=="assertive"?"status":"alert";d.setAttribute("aria-live",t),d.setAttribute("role",g),Object.assign(d.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}),o.appendChild(d),s.setTimeout(()=>{d.textContent=u},h)}function l(){let u=n.getElementById(Yi);u==null||u.remove()}return{announce:a,destroy:l,toJSON(){return Yi}}}function Ro(e){let[t,n]=e,r;return!t||!n?r=e:r=t.compare(n)<=0?e:[n,t],r}function tr(e,t){let[n,r]=t;return!n||!r?!1:n.compare(e)<=0&&r.compare(e)>=0}function ji(e){return e.slice().filter(t=>t!=null).sort((t,n)=>t.compare(n))}function _y(e){return Ve(e,{year:"calendar decade",month:"calendar year",day:"calendar month"})}function By(e){return new ct(e).formatToParts(new Date).map(t=>{var n;return(n=Hy[t.type])!=null?n:t.value}).join("")}function Uy(e){let r=new Intl.DateTimeFormat(e).formatToParts(new Date).find(i=>i.type==="literal");return r?r.value:"/"}function $t(e,t){return e?e==="day"?0:e==="month"?1:2:t||0}function Go(e){return e===0?"day":e===1?"month":"year"}function Uo(e,t,n){return Go(dl($t(e,0),$t(t,0),$t(n,2)))}function Wy(e,t){return $t(e,0)>$t(t,0)}function Ky(e,t){return $t(e,0)<$t(t,0)}function Yy(e,t,n){let r=$t(e,0)+1;return Uo(Go(r),t,n)}function jy(e,t,n){let r=$t(e,0)-1;return Uo(Go(r),t,n)}function Zy(e){Xy.forEach(t=>e(t))}function zy(e,t){let{state:n,context:r,prop:i,send:s,computed:o,scope:a}=e,l=r.get("startValue"),c=o("endValue"),u=r.get("value"),h=r.get("focusedValue"),p=r.get("hoveredValue"),d=p?Ro([u[0],p]):[],g=!!i("disabled"),v=!!i("readOnly"),b=!!i("invalid"),V=o("isInteractive"),S=u.length===0,E=i("min"),f=i("max"),C=i("locale"),I=i("timeZone"),w=i("startOfWeek"),A=n.matches("focused"),P=n.matches("open"),N=i("selectionMode")==="range",R=i("isDateUnavailable"),L=r.get("currentPlacement"),M=Zt(y(m({},i("positioning")),{placement:L})),j=Uy(C),q=m(m({},qy),i("translations"));function J(D=l){let k=i("fixedWeeks")?6:void 0;return gy(D,C,k,w)}function W(D={}){let{format:k}=D;return my(C,k).map((F,_)=>{let z=_+1,Le=h.set({month:z}),Ie=yt(Le,E,f);return{label:F,value:z,disabled:Ie}})}function ge(){var k,F;return vy({from:(k=E==null?void 0:E.year)!=null?k:1900,to:(F=f==null?void 0:f.year)!=null?F:2100}).map(_=>({label:_.toString(),value:_,disabled:!vi(_,E==null?void 0:E.year,f==null?void 0:f.year)}))}function de(D){return Lc(D,R,C,E,f)}function X(D){let k=l!=null?l:nr(I);s({type:"FOCUS.SET",value:k.set({month:D})})}function ue(D){let k=l!=null?l:nr(I);s({type:"FOCUS.SET",value:k.set({year:D})})}function qe(D){let{value:k,disabled:F}=D,_=h.set({year:k}),Le=!rr(l.year,{strict:!0}).includes(k),Ie=vi(k,E==null?void 0:E.year,f==null?void 0:f.year),ut={focused:h.year===D.value,selectable:Le||Ie,outsideRange:Le,selected:!!u.find(fr=>fr&&fr.year===k),valueText:k.toString(),inRange:N&&(tr(_,u)||tr(_,d)),value:_,get disabled(){return F||!ut.selectable}};return ut}function It(D){let{value:k,disabled:F}=D,_=h.set({month:k}),z=Fc(C,I),Le={focused:h.month===D.value,selectable:!yt(_,E,f),selected:!!u.find(Ie=>Ie&&Ie.month===k&&Ie.year===h.year),valueText:z.format(_.toDate(I)),inRange:N&&(tr(_,u)||tr(_,d)),value:_,get disabled(){return F||!Le.selectable}};return Le}function gr(D){let{value:k,disabled:F,visibleRange:_=o("visibleRange")}=D,z=du(C,I),Le=Bo(o("visibleDuration")),Ie=i("outsideDaySelectable"),ut=_.start.add(Le).subtract({days:1}),fr=yt(k,_.start,ut),eh=N&&tr(k,u),th=N&&Ge(k,u[0]),nh=N&&Ge(k,u[1]),Cs=N&&d.length>0,ya=Cs&&tr(k,d),rh=Cs&&Ge(k,d[0]),ih=Cs&&Ge(k,d[1]),pr={invalid:yt(k,E,f),disabled:F||!Ie&&fr||yt(k,E,f),selected:u.some(sh=>Ge(k,sh)),unavailable:Lc(k,R,C,E,f)&&!F,outsideRange:fr,today:Pv(k,I),weekend:Rv(k,C),formattedDate:z.format(k.toDate(I)),get focused(){return Ge(k,h)&&(!pr.outsideRange||Ie)},get ariaLabel(){return q.dayCell(pr)},get selectable(){return!pr.disabled&&!pr.unavailable},inRange:eh||ya,firstInRange:th,lastInRange:nh,inHoveredRange:ya,firstInHoveredRange:rh,lastInHoveredRange:ih};return pr}function Es(D){let{view:k="day",id:F}=D;return[k,F].filter(Boolean).join(" ")}return{focused:A,open:P,disabled:g,invalid:b,readOnly:v,inline:!!i("inline"),numOfMonths:i("numOfMonths"),selectionMode:i("selectionMode"),view:r.get("view"),getRangePresetValue(D){return $c(D,C,I)},getDaysInWeek(D,k=l){return fu(D,k,C,w)},getOffset(D){let k=l.add(D),F=c.add(D),_=Fc(C,I);return{visibleRange:{start:k,end:F},weeks:J(k),visibleRangeText:{start:_.format(k.toDate(I)),end:_.format(F.toDate(I))}}},getMonthWeeks:J,isUnavailable:de,weeks:J(),weekDays:py(nr(I),w,I,C),visibleRangeText:o("visibleRangeText"),value:u,valueAsDate:u.filter(D=>D!=null).map(D=>D.toDate(I)),valueAsString:o("valueAsString"),focusedValue:h,focusedValueAsDate:h==null?void 0:h.toDate(I),focusedValueAsString:i("format")(h,{locale:C,timeZone:I}),visibleRange:o("visibleRange"),selectToday(){let D=lt(nr(I),E,f);s({type:"VALUE.SET",value:D})},setValue(D){let k=D.map(F=>lt(F,E,f));s({type:"VALUE.SET",value:k})},clearValue(){s({type:"VALUE.CLEAR"})},setFocusedValue(D){s({type:"FOCUS.SET",value:D})},setOpen(D){i("inline")||n.matches("open")===D||s({type:D?"OPEN":"CLOSE"})},focusMonth:X,focusYear:ue,getYears:ge,getMonths:W,getYearsGrid(D={}){let{columns:k=1}=D,F=rr(l.year,{strict:!0}).map(_=>({label:_.toString(),value:_,disabled:!vi(_,E==null?void 0:E.year,f==null?void 0:f.year)}));return Ws(F,k)},getDecade(){let D=rr(l.year,{strict:!0});return{start:D.at(0),end:D.at(-1)}},getMonthsGrid(D={}){let{columns:k=1,format:F}=D;return Ws(W({format:F}),k)},format(D,k={month:"long",year:"numeric"}){return new ct(C,k).format(D.toDate(I))},setView(D){s({type:"VIEW.SET",view:D})},goToNext(){s({type:"GOTO.NEXT",view:r.get("view")})},goToPrev(){s({type:"GOTO.PREV",view:r.get("view")})},getRootProps(){return t.element(y(m({},se.root.attrs),{dir:i("dir"),id:ky(a),"data-state":P?"open":"closed","data-disabled":T(g),"data-readonly":T(v),"data-empty":T(S)}))},getLabelProps(D={}){let{index:k=0}=D;return t.label(y(m({},se.label.attrs),{id:xy(a,k),dir:i("dir"),htmlFor:_c(a,k),"data-state":P?"open":"closed","data-index":k,"data-disabled":T(g),"data-readonly":T(v)}))},getControlProps(){return t.element(y(m({},se.control.attrs),{dir:i("dir"),id:yu(a),"data-disabled":T(g),"data-placeholder-shown":T(S)}))},getRangeTextProps(){return t.element(y(m({},se.rangeText.attrs),{dir:i("dir")}))},getContentProps(){return t.element(y(m({},se.content.attrs),{hidden:!P,dir:i("dir"),"data-state":P?"open":"closed","data-placement":L,"data-inline":T(i("inline")),id:Ao(a),tabIndex:-1,role:"application","aria-roledescription":"datepicker","aria-label":q.content}))},getTableProps(D={}){let{view:k="day",columns:F=k==="day"?7:4}=D,_=Es(D);return t.element(y(m({},se.table.attrs),{role:"grid","data-columns":F,"aria-roledescription":_y(k),id:Ny(a,_),"aria-readonly":re(v),"aria-disabled":re(g),"aria-multiselectable":re(i("selectionMode")!=="single"),"data-view":k,dir:i("dir"),tabIndex:-1,onKeyDown(z){if(z.defaultPrevented)return;let Ie={Enter(){k==="day"&&de(h)||k==="month"&&!It({value:h.month}).selectable||k==="year"&&!qe({value:h.year}).selectable||s({type:"TABLE.ENTER",view:k,columns:F,focus:!0})},ArrowLeft(){s({type:"TABLE.ARROW_LEFT",view:k,columns:F,focus:!0})},ArrowRight(){s({type:"TABLE.ARROW_RIGHT",view:k,columns:F,focus:!0})},ArrowUp(){s({type:"TABLE.ARROW_UP",view:k,columns:F,focus:!0})},ArrowDown(){s({type:"TABLE.ARROW_DOWN",view:k,columns:F,focus:!0})},PageUp(ut){s({type:"TABLE.PAGE_UP",larger:ut.shiftKey,view:k,columns:F,focus:!0})},PageDown(ut){s({type:"TABLE.PAGE_DOWN",larger:ut.shiftKey,view:k,columns:F,focus:!0})},Home(){s({type:"TABLE.HOME",view:k,columns:F,focus:!0})},End(){s({type:"TABLE.END",view:k,columns:F,focus:!0})}}[ve(z,{dir:i("dir")})];Ie&&(Ie(z),z.preventDefault(),z.stopPropagation())},onPointerLeave(){s({type:"TABLE.POINTER_LEAVE"})},onPointerDown(){s({type:"TABLE.POINTER_DOWN",view:k})},onPointerUp(){s({type:"TABLE.POINTER_UP",view:k})}}))},getTableHeadProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.tableHead.attrs),{"aria-hidden":!0,dir:i("dir"),"data-view":k,"data-disabled":T(g)}))},getTableHeaderProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.tableHeader.attrs),{dir:i("dir"),"data-view":k,"data-disabled":T(g)}))},getTableBodyProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.tableBody.attrs),{"data-view":k,"data-disabled":T(g)}))},getTableRowProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.tableRow.attrs),{"aria-disabled":re(g),"data-disabled":T(g),"data-view":k}))},getDayTableCellState:gr,getDayTableCellProps(D){let{value:k}=D,F=gr(D);return t.element(y(m({},se.tableCell.attrs),{role:"gridcell","aria-disabled":re(!F.selectable),"aria-selected":F.selected||F.inRange,"aria-invalid":re(F.invalid),"aria-current":F.today?"date":void 0,"data-value":k.toString()}))},getDayTableCellTriggerProps(D){let{value:k}=D,F=gr(D);return t.element(y(m({},se.tableCellTrigger.attrs),{id:Oo(a,k.toString()),role:"button",dir:i("dir"),tabIndex:F.focused?0:-1,"aria-label":F.ariaLabel,"aria-disabled":re(!F.selectable),"aria-invalid":re(F.invalid),"data-disabled":T(!F.selectable),"data-selected":T(F.selected),"data-value":k.toString(),"data-view":"day","data-today":T(F.today),"data-focus":T(F.focused),"data-unavailable":T(F.unavailable),"data-range-start":T(F.firstInRange),"data-range-end":T(F.lastInRange),"data-in-range":T(F.inRange),"data-outside-range":T(F.outsideRange),"data-weekend":T(F.weekend),"data-in-hover-range":T(F.inHoveredRange),"data-hover-range-start":T(F.firstInHoveredRange),"data-hover-range-end":T(F.lastInHoveredRange),onClick(_){_.defaultPrevented||F.selectable&&s({type:"CELL.CLICK",cell:"day",value:k})},onPointerMove:N?_=>{if(_.pointerType==="touch"||!F.selectable)return;let z=!a.isActiveElement(_.currentTarget);p&&Tv(k,p)||s({type:"CELL.POINTER_MOVE",cell:"day",value:k,focus:z})}:void 0}))},getMonthTableCellState:It,getMonthTableCellProps(D){let{value:k,columns:F}=D,_=It(D);return t.element(y(m({},se.tableCell.attrs),{dir:i("dir"),colSpan:F,role:"gridcell","aria-selected":re(_.selected||_.inRange),"data-selected":T(_.selected),"aria-disabled":re(!_.selectable),"data-value":k}))},getMonthTableCellTriggerProps(D){let{value:k}=D,F=It(D);return t.element(y(m({},se.tableCellTrigger.attrs),{dir:i("dir"),role:"button",id:Oo(a,k.toString()),"data-selected":T(F.selected),"aria-disabled":re(!F.selectable),"data-disabled":T(!F.selectable),"data-focus":T(F.focused),"data-in-range":T(F.inRange),"data-outside-range":T(F.outsideRange),"aria-label":F.valueText,"data-view":"month","data-value":k,tabIndex:F.focused?0:-1,onClick(_){_.defaultPrevented||F.selectable&&s({type:"CELL.CLICK",cell:"month",value:k})},onPointerMove:N?_=>{if(_.pointerType==="touch"||!F.selectable)return;let z=!a.isActiveElement(_.currentTarget);p&&F.value&&Ov(F.value,p)||s({type:"CELL.POINTER_MOVE",cell:"month",value:F.value,focus:z})}:void 0}))},getYearTableCellState:qe,getYearTableCellProps(D){let{value:k,columns:F}=D,_=qe(D);return t.element(y(m({},se.tableCell.attrs),{dir:i("dir"),colSpan:F,role:"gridcell","aria-selected":re(_.selected),"data-selected":T(_.selected),"aria-disabled":re(!_.selectable),"data-value":k}))},getYearTableCellTriggerProps(D){let{value:k}=D,F=qe(D);return t.element(y(m({},se.tableCellTrigger.attrs),{dir:i("dir"),role:"button",id:Oo(a,k.toString()),"data-selected":T(F.selected),"data-focus":T(F.focused),"data-in-range":T(F.inRange),"aria-disabled":re(!F.selectable),"data-disabled":T(!F.selectable),"aria-label":F.valueText,"data-outside-range":T(F.outsideRange),"data-value":k,"data-view":"year",tabIndex:F.focused?0:-1,onClick(_){_.defaultPrevented||F.selectable&&s({type:"CELL.CLICK",cell:"year",value:k})},onPointerMove:N?_=>{if(_.pointerType==="touch"||!F.selectable)return;let z=!a.isActiveElement(_.currentTarget);p&&F.value&&Sv(F.value,p)||s({type:"CELL.POINTER_MOVE",cell:"year",value:F.value,focus:z})}:void 0}))},getNextTriggerProps(D={}){let{view:k="day"}=D,F=g||!o("isNextVisibleRangeValid");return t.button(y(m({},se.nextTrigger.attrs),{dir:i("dir"),id:Ry(a,k),type:"button","aria-label":q.nextTrigger(k),disabled:F,"data-disabled":T(F),onClick(_){_.defaultPrevented||s({type:"GOTO.NEXT",view:k})}}))},getPrevTriggerProps(D={}){let{view:k="day"}=D,F=g||!o("isPrevVisibleRangeValid");return t.button(y(m({},se.prevTrigger.attrs),{dir:i("dir"),id:Ay(a,k),type:"button","aria-label":q.prevTrigger(k),disabled:F,"data-disabled":T(F),onClick(_){_.defaultPrevented||s({type:"GOTO.PREV",view:k})}}))},getClearTriggerProps(){return t.button(y(m({},se.clearTrigger.attrs),{id:vu(a),dir:i("dir"),type:"button","aria-label":q.clearTrigger,hidden:!u.length,onClick(D){D.defaultPrevented||s({type:"VALUE.CLEAR"})}}))},getTriggerProps(){return t.button(y(m({},se.trigger.attrs),{id:bu(a),dir:i("dir"),type:"button","data-placement":L,"aria-label":q.trigger(P),"aria-controls":Ao(a),"data-state":P?"open":"closed","data-placeholder-shown":T(S),"aria-haspopup":"grid",disabled:g,onClick(D){D.defaultPrevented||V&&s({type:"TRIGGER.CLICK"})}}))},getViewProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.view.attrs),{"data-view":k,hidden:r.get("view")!==k}))},getViewTriggerProps(D={}){let{view:k="day"}=D;return t.button(y(m({},se.viewTrigger.attrs),{"data-view":k,dir:i("dir"),id:Dy(a,k),type:"button",disabled:g,"aria-label":q.viewTrigger(k),onClick(F){F.defaultPrevented||V&&s({type:"VIEW.TOGGLE",src:"viewTrigger"})}}))},getViewControlProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.viewControl.attrs),{"data-view":k,dir:i("dir")}))},getInputProps(D={}){let{index:k=0,fixOnBlur:F=!0}=D;return t.input(y(m({},se.input.attrs),{id:_c(a,k),autoComplete:"off",autoCorrect:"off",spellCheck:"false",dir:i("dir"),name:i("name"),"data-index":k,"data-state":P?"open":"closed","data-placeholder-shown":T(S),readOnly:v,disabled:g,required:i("required"),"aria-invalid":re(b),"data-invalid":T(b),placeholder:i("placeholder")||By(C),defaultValue:o("valueAsString")[k],onBeforeInput(_){let{data:z}=Ms(_);Ou(z,j)||_.preventDefault()},onFocus(){s({type:"INPUT.FOCUS",index:k})},onBlur(_){let z=_.currentTarget.value.trim();s({type:"INPUT.BLUR",value:z,index:k,fixOnBlur:F})},onKeyDown(_){if(_.defaultPrevented||!V)return;let Le={Enter(Ie){Vt(Ie)||de(h)||Ie.currentTarget.value.trim()!==""&&s({type:"INPUT.ENTER",value:Ie.currentTarget.value,index:k})}}[_.key];Le&&(Le(_),_.preventDefault())},onInput(_){let z=_.currentTarget.value;s({type:"INPUT.CHANGE",value:Gy(z,j),index:k})}}))},getMonthSelectProps(){return t.select(y(m({},se.monthSelect.attrs),{id:Cu(a),"aria-label":q.monthSelect,disabled:g,dir:i("dir"),defaultValue:l.month,onChange(D){X(Number(D.currentTarget.value))}}))},getYearSelectProps(){return t.select(y(m({},se.yearSelect.attrs),{id:Iu(a),disabled:g,"aria-label":q.yearSelect,dir:i("dir"),defaultValue:l.year,onChange(D){ue(Number(D.currentTarget.value))}}))},getPositionerProps(){return t.element(y(m({id:Eu(a)},se.positioner.attrs),{dir:i("dir"),style:M.floating}))},getPresetTriggerProps(D){let k=Array.isArray(D.value)?D.value:$c(D.value,C,I),F=k.filter(_=>_!=null).map(_=>_.toDate(I).toDateString());return t.button(y(m({},se.presetTrigger.attrs),{"aria-label":q.presetTrigger(F),type:"button",onClick(_){_.defaultPrevented||s({type:"PRESET.CLICK",value:k})}}))}}}function Qy(e,t){if((e==null?void 0:e.length)!==(t==null?void 0:t.length))return!1;let n=Math.max(e.length,t.length);for(let r=0;rn==null?"":t("format")(n,{locale:t("locale"),timeZone:t("timeZone")}))}function ae(e,t){let{context:n,prop:r,computed:i}=e;if(!t)return;let s=Qi(e,t);if(Ge(n.get("focusedValue"),s))return;let a=$r(i("visibleDuration"),r("locale"),r("min"),r("max"))({focusedDate:s,startDate:n.get("startValue")});n.set("startValue",a.startDate),n.set("focusedValue",a.focusedDate)}function Zi(e,t){let{context:n}=e;n.set("startValue",t.startDate);let r=n.get("focusedValue");Ge(r,t.focusedDate)||n.set("focusedValue",t.focusedDate)}function Ze(e){return Array.isArray(e)?e.map(t=>Ze(t)):e instanceof Date?new or(e.getFullYear(),e.getMonth()+1,e.getDate()):Xv(e)}function Uc(e){let t=n=>String(n).padStart(2,"0");return`${e.year}-${t(e.month)}-${t(e.day)}`}var qc,bv,ir,Ev,wv,yo,Nc,bo,Av,Ac,Rc,Rr,Kv,Yv,jv,ET,ey,or,ty,ny,ry,au,Co,ct,iy,Io,To,hy,yy,Mc,Iy,Ty,Yi,Vy,se,xy,ky,Ny,Ao,Oo,Ay,Ry,Dy,vu,yu,_c,bu,Eu,Cu,Iu,Hc,Bc,zi,Dr,Ly,Fy,My,$y,Tu,Hy,Ou,Gc,Gy,qy,Xy,Jy,Xe,eb,Qi,tb,CT,nb,IT,rb,TT,ib,OT,sb,ST,ob,PT,ab,lb,Pu=fe(()=>{"use strict";Nr();gn();me();qc=1721426;bv={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]},ir=class{fromJulianDay(e){let t=e,n=t-qc,r=Math.floor(n/146097),i=vo(n,146097),s=Math.floor(i/36524),o=vo(i,36524),a=Math.floor(o/1461),l=vo(o,1461),c=Math.floor(l/365),u=r*400+s*100+a*4+c+(s!==4&&c!==4?1:0),[h,p]=yv(u),d=t-qi(h,p,1,1),g=2;t= start date");return`${this.formatter.format(e)} \u2013 ${this.formatter.format(t)}`}formatRangeToParts(e,t){if(typeof this.formatter.formatRangeToParts=="function")return this.formatter.formatRangeToParts(e,t);if(t= start date");let n=this.formatter.formatToParts(e),r=this.formatter.formatToParts(t);return[...n.map(i=>y(m({},i),{source:"startRange"})),{type:"literal",value:" \u2013 ",source:"shared"},...r.map(i=>y(m({},i),{source:"endRange"}))]}resolvedOptions(){let e=this.formatter.resolvedOptions();return oy()&&(this.resolvedHourCycle||(this.resolvedHourCycle=ay(e.locale,this.options)),e.hourCycle=this.resolvedHourCycle,e.hour12=this.resolvedHourCycle==="h11"||this.resolvedHourCycle==="h12"),e.calendar==="ethiopic-amete-alem"&&(e.calendar="ethioaa"),e}constructor(e,t={}){this.formatter=lu(e,t),this.options=t}},iy={true:{ja:"h11"},false:{}};Io=null;To=null;hy=["sun","mon","tue","wed","thu","fri","sat"];yy=10;Mc=e=>e!=null&&e.length===4,Iy=e=>e!=null&&parseFloat(e)<=12,Ty=e=>e!=null&&parseFloat(e)<=31;Yi="__live-region__";Vy=Z("date-picker").parts("clearTrigger","content","control","input","label","monthSelect","nextTrigger","positioner","presetTrigger","prevTrigger","rangeText","root","table","tableBody","tableCell","tableCellTrigger","tableHead","tableHeader","tableRow","trigger","view","viewControl","viewTrigger","yearSelect"),se=Vy.build(),xy=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.label)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:label:${t}`},ky=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`datepicker:${e.id}`},Ny=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.table)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:table:${t}`},Ao=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`datepicker:${e.id}:content`},Oo=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.cellTrigger)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:cell-trigger:${t}`},Ay=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.prevTrigger)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:prev:${t}`},Ry=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.nextTrigger)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:next:${t}`},Dy=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.viewTrigger)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:view:${t}`},vu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.clearTrigger)!=null?n:`datepicker:${e.id}:clear`},yu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`datepicker:${e.id}:control`},_c=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.input)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:input:${t}`},bu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`datepicker:${e.id}:trigger`},Eu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.positioner)!=null?n:`datepicker:${e.id}:positioner`},Cu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.monthSelect)!=null?n:`datepicker:${e.id}:month-select`},Iu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.yearSelect)!=null?n:`datepicker:${e.id}:year-select`},Hc=(e,t)=>Mn(zi(e),`[data-part=table-cell-trigger][data-view=${t}][data-focus]:not([data-outside-range])`),Bc=e=>e.getById(bu(e)),zi=e=>e.getById(Ao(e)),Dr=e=>dt(Tu(e),"[data-part=input]"),Ly=e=>e.getById(Iu(e)),Fy=e=>e.getById(Cu(e)),My=e=>e.getById(vu(e)),$y=e=>e.getById(Eu(e)),Tu=e=>e.getById(yu(e));Hy={day:"dd",month:"mm",year:"yyyy"};Ou=(e,t)=>e?/\d/.test(e)||e===t||e.length!==1:!0,Gc=e=>!Number.isNaN(e.day)&&!Number.isNaN(e.month)&&!Number.isNaN(e.year),Gy=(e,t)=>e.split("").filter(n=>Ou(n,t)).join("");qy={dayCell(e){return e.unavailable?`Not available. ${e.formattedDate}`:e.selected?`Selected date. ${e.formattedDate}`:`Choose ${e.formattedDate}`},trigger(e){return e?"Close calendar":"Open calendar"},viewTrigger(e){return Ve(e,{year:"Switch to month view",month:"Switch to day view",day:"Switch to year view"})},presetTrigger(e){let[t="",n=""]=e;return`select ${t} to ${n}`},prevTrigger(e){return Ve(e,{year:"Switch to previous decade",month:"Switch to previous year",day:"Switch to previous month"})},nextTrigger(e){return Ve(e,{year:"Switch to next decade",month:"Switch to next year",day:"Switch to next month"})},placeholder(){return{day:"dd",month:"mm",year:"yyyy"}},content:"calendar",monthSelect:"Select month",yearSelect:"Select year",clearTrigger:"Clear selected dates"};Xy=["day","month","year"];Jy=gl(e=>[e.view,e.startValue.toString(),e.endValue.toString(),e.locale],([e],t)=>{let{startValue:n,endValue:r,locale:i,timeZone:s,selectionMode:o}=t;if(e==="year"){let h=rr(n.year,{strict:!0}),p=h.at(0).toString(),d=h.at(-1).toString();return{start:p,end:d,formatted:`${p} - ${d}`}}if(e==="month"){let h=new ct(i,{year:"numeric",timeZone:s}),p=h.format(n.toDate(s)),d=h.format(r.toDate(s)),g=o==="range"?`${p} - ${d}`:p;return{start:p,end:d,formatted:g}}let a=new ct(i,{month:"long",year:"numeric",timeZone:s}),l=a.format(n.toDate(s)),c=a.format(r.toDate(s)),u=o==="range"?`${l} - ${c}`:l;return{start:l,end:c,formatted:u}});({and:Xe}=ye());eb={props({props:e}){let t=e.locale||"en-US",n=e.timeZone||"UTC",r=e.selectionMode||"single",i=e.numOfMonths||1,s=e.defaultValue?ji(e.defaultValue).map(h=>lt(h,e.min,e.max)):void 0,o=e.value?ji(e.value).map(h=>lt(h,e.min,e.max)):void 0,a=e.focusedValue||e.defaultFocusedValue||(o==null?void 0:o[0])||(s==null?void 0:s[0])||nr(n);a=lt(a,e.min,e.max);let l="day",c="year",u=Uo(e.view||l,l,c);return y(m({locale:t,numOfMonths:i,timeZone:n,selectionMode:r,defaultView:u,minView:l,maxView:c,outsideDaySelectable:!1,closeOnSelect:!0,format(h,{locale:p,timeZone:d}){return new ct(p,{timeZone:d,day:"2-digit",month:"2-digit",year:"numeric"}).format(h.toDate(d))},parse(h,{locale:p,timeZone:d}){return Oy(h,p,d)}},e),{focusedValue:typeof e.focusedValue=="undefined"?void 0:a,defaultFocusedValue:a,value:o,defaultValue:s!=null?s:[],positioning:m({placement:"bottom"},e.positioning)})},initialState({prop:e}){return e("open")||e("defaultOpen")||e("inline")?"open":"idle"},refs(){return{announcer:void 0}},context({prop:e,bindable:t,getContext:n}){return{focusedValue:t(()=>({defaultValue:e("defaultFocusedValue"),value:e("focusedValue"),isEqual:Ge,hash:r=>r.toString(),sync:!0,onChange(r){var l;let i=n(),s=i.get("view"),o=i.get("value"),a=Xi(o,e);(l=e("onFocusChange"))==null||l({value:o,valueAsString:a,view:s,focusedValue:r})}})),value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),isEqual:Qy,hash:r=>r.map(i=>{var s;return(s=i==null?void 0:i.toString())!=null?s:""}).join(","),onChange(r){var o;let i=n(),s=Xi(r,e);(o=e("onValueChange"))==null||o({value:r,valueAsString:s,view:i.get("view")})}})),inputValue:t(()=>({defaultValue:""})),activeIndex:t(()=>({defaultValue:0,sync:!0})),hoveredValue:t(()=>({defaultValue:null,isEqual:Ge})),view:t(()=>({defaultValue:e("defaultView"),value:e("view"),onChange(r){var i;(i=e("onViewChange"))==null||i({view:r})}})),startValue:t(()=>{let r=e("focusedValue")||e("defaultFocusedValue");return{defaultValue:Dc(r,"start",{months:e("numOfMonths")},e("locale")),isEqual:Ge,hash:i=>i.toString()}}),currentPlacement:t(()=>({defaultValue:void 0})),restoreFocus:t(()=>({defaultValue:!1}))}},computed:{isInteractive:({prop:e})=>!e("disabled")&&!e("readOnly"),visibleDuration:({prop:e})=>({months:e("numOfMonths")}),endValue:({context:e,computed:t})=>cu(e.get("startValue"),t("visibleDuration")),visibleRange:({context:e,computed:t})=>({start:e.get("startValue"),end:t("endValue")}),visibleRangeText:({context:e,prop:t,computed:n})=>Jy({view:e.get("view"),startValue:e.get("startValue"),endValue:n("endValue"),locale:t("locale"),timeZone:t("timeZone"),selectionMode:t("selectionMode")}),isPrevVisibleRangeValid:({context:e,prop:t})=>!cy(e.get("startValue"),t("min"),t("max")),isNextVisibleRangeValid:({prop:e,computed:t})=>!uy(t("endValue"),e("min"),e("max")),valueAsString:({context:e,prop:t})=>Xi(e.get("value"),t)},effects:["setupLiveRegion"],watch({track:e,prop:t,context:n,action:r,computed:i}){e([()=>t("locale")],()=>{r(["setStartValue","syncInputElement"])}),e([()=>n.hash("focusedValue")],()=>{r(["setStartValue","focusActiveCellIfNeeded","setHoveredValueIfKeyboard"])}),e([()=>n.hash("startValue")],()=>{r(["syncMonthSelectElement","syncYearSelectElement","invokeOnVisibleRangeChange"])}),e([()=>n.get("inputValue")],()=>{r(["syncInputValue"])}),e([()=>n.hash("value")],()=>{r(["syncInputElement"])}),e([()=>i("valueAsString").toString()],()=>{r(["announceValueText"])}),e([()=>n.get("view")],()=>{r(["focusActiveCell"])}),e([()=>t("open")],()=>{r(["toggleVisibility"])})},on:{"VALUE.SET":{actions:["setDateValue","setFocusedDate"]},"VIEW.SET":{actions:["setView"]},"FOCUS.SET":{actions:["setFocusedDate"]},"VALUE.CLEAR":{actions:["clearDateValue","clearFocusedDate","focusFirstInputElement"]},"INPUT.CHANGE":[{guard:"isInputValueEmpty",actions:["setInputValue","clearDateValue","clearFocusedDate"]},{actions:["setInputValue","focusParsedDate"]}],"INPUT.ENTER":{actions:["focusParsedDate","selectFocusedDate"]},"INPUT.FOCUS":{actions:["setActiveIndex"]},"INPUT.BLUR":[{guard:"shouldFixOnBlur",actions:["setActiveIndexToStart","selectParsedDate"]},{actions:["setActiveIndexToStart"]}],"PRESET.CLICK":[{guard:"isOpenControlled",actions:["setDateValue","setFocusedDate","invokeOnClose"]},{target:"focused",actions:["setDateValue","setFocusedDate","focusInputElement"]}],"GOTO.NEXT":[{guard:"isYearView",actions:["focusNextDecade","announceVisibleRange"]},{guard:"isMonthView",actions:["focusNextYear","announceVisibleRange"]},{actions:["focusNextPage"]}],"GOTO.PREV":[{guard:"isYearView",actions:["focusPreviousDecade","announceVisibleRange"]},{guard:"isMonthView",actions:["focusPreviousYear","announceVisibleRange"]},{actions:["focusPreviousPage"]}]},states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":{target:"open",actions:["focusFirstSelectedDate","focusActiveCell"]},"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["focusFirstSelectedDate","focusActiveCell","invokeOnOpen"]}],OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["focusFirstSelectedDate","focusActiveCell","invokeOnOpen"]}]}},focused:{tags:["closed"],on:{"CONTROLLED.OPEN":{target:"open",actions:["focusFirstSelectedDate","focusActiveCell"]},"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["focusFirstSelectedDate","focusActiveCell","invokeOnOpen"]}],OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["focusFirstSelectedDate","focusActiveCell","invokeOnOpen"]}]}},open:{tags:["open"],effects:["trackDismissableElement","trackPositioning"],exit:["clearHoveredDate","resetView"],on:{"CONTROLLED.CLOSE":[{guard:Xe("shouldRestoreFocus","isInteractOutsideEvent"),target:"focused",actions:["focusTriggerElement"]},{guard:"shouldRestoreFocus",target:"focused",actions:["focusInputElement"]},{target:"idle"}],"CELL.CLICK":[{guard:"isAboveMinView",actions:["setFocusedValueForView","setPreviousView"]},{guard:Xe("isRangePicker","hasSelectedRange"),actions:["setActiveIndexToStart","resetSelection","setActiveIndexToEnd"]},{guard:Xe("isRangePicker","isSelectingEndDate","closeOnSelect","isOpenControlled"),actions:["setFocusedDate","setSelectedDate","setActiveIndexToStart","clearHoveredDate","invokeOnClose","setRestoreFocus"]},{guard:Xe("isRangePicker","isSelectingEndDate","closeOnSelect"),target:"focused",actions:["setFocusedDate","setSelectedDate","setActiveIndexToStart","clearHoveredDate","invokeOnClose","focusInputElement"]},{guard:Xe("isRangePicker","isSelectingEndDate"),actions:["setFocusedDate","setSelectedDate","setActiveIndexToStart","clearHoveredDate"]},{guard:"isRangePicker",actions:["setFocusedDate","setSelectedDate","setActiveIndexToEnd"]},{guard:"isMultiPicker",actions:["setFocusedDate","toggleSelectedDate"]},{guard:Xe("closeOnSelect","isOpenControlled"),actions:["setFocusedDate","setSelectedDate","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["setFocusedDate","setSelectedDate","invokeOnClose","focusInputElement"]},{actions:["setFocusedDate","setSelectedDate"]}],"CELL.POINTER_MOVE":{guard:Xe("isRangePicker","isSelectingEndDate"),actions:["setHoveredDate","setFocusedDate"]},"TABLE.POINTER_LEAVE":{guard:"isRangePicker",actions:["clearHoveredDate"]},"TABLE.POINTER_DOWN":{actions:["disableTextSelection"]},"TABLE.POINTER_UP":{actions:["enableTextSelection"]},"TABLE.ESCAPE":[{guard:"isOpenControlled",actions:["focusFirstSelectedDate","invokeOnClose"]},{target:"focused",actions:["focusFirstSelectedDate","invokeOnClose","focusTriggerElement"]}],"TABLE.ENTER":[{guard:"isAboveMinView",actions:["setPreviousView"]},{guard:Xe("isRangePicker","hasSelectedRange"),actions:["setActiveIndexToStart","clearDateValue","setSelectedDate","setActiveIndexToEnd"]},{guard:Xe("isRangePicker","isSelectingEndDate","closeOnSelect","isOpenControlled"),actions:["setSelectedDate","setActiveIndexToStart","clearHoveredDate","invokeOnClose"]},{guard:Xe("isRangePicker","isSelectingEndDate","closeOnSelect"),target:"focused",actions:["setSelectedDate","setActiveIndexToStart","clearHoveredDate","invokeOnClose","focusInputElement"]},{guard:Xe("isRangePicker","isSelectingEndDate"),actions:["setSelectedDate","setActiveIndexToStart","clearHoveredDate"]},{guard:"isRangePicker",actions:["setSelectedDate","setActiveIndexToEnd","focusNextDay"]},{guard:"isMultiPicker",actions:["toggleSelectedDate"]},{guard:Xe("closeOnSelect","isOpenControlled"),actions:["selectFocusedDate","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectFocusedDate","invokeOnClose","focusInputElement"]},{actions:["selectFocusedDate"]}],"TABLE.ARROW_RIGHT":[{guard:"isMonthView",actions:["focusNextMonth"]},{guard:"isYearView",actions:["focusNextYear"]},{actions:["focusNextDay","setHoveredDate"]}],"TABLE.ARROW_LEFT":[{guard:"isMonthView",actions:["focusPreviousMonth"]},{guard:"isYearView",actions:["focusPreviousYear"]},{actions:["focusPreviousDay"]}],"TABLE.ARROW_UP":[{guard:"isMonthView",actions:["focusPreviousMonthColumn"]},{guard:"isYearView",actions:["focusPreviousYearColumn"]},{actions:["focusPreviousWeek"]}],"TABLE.ARROW_DOWN":[{guard:"isMonthView",actions:["focusNextMonthColumn"]},{guard:"isYearView",actions:["focusNextYearColumn"]},{actions:["focusNextWeek"]}],"TABLE.PAGE_UP":{actions:["focusPreviousSection"]},"TABLE.PAGE_DOWN":{actions:["focusNextSection"]},"TABLE.HOME":[{guard:"isMonthView",actions:["focusFirstMonth"]},{guard:"isYearView",actions:["focusFirstYear"]},{actions:["focusSectionStart"]}],"TABLE.END":[{guard:"isMonthView",actions:["focusLastMonth"]},{guard:"isYearView",actions:["focusLastYear"]},{actions:["focusSectionEnd"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose"]}],"VIEW.TOGGLE":{actions:["setNextView"]},INTERACT_OUTSIDE:[{guard:"isOpenControlled",actions:["setActiveIndexToStart","invokeOnClose"]},{guard:"shouldRestoreFocus",target:"focused",actions:["setActiveIndexToStart","invokeOnClose","focusTriggerElement"]},{target:"idle",actions:["setActiveIndexToStart","invokeOnClose"]}],CLOSE:[{guard:"isOpenControlled",actions:["setActiveIndexToStart","invokeOnClose"]},{target:"idle",actions:["setActiveIndexToStart","invokeOnClose"]}]}}},implementations:{guards:{isAboveMinView:({context:e,prop:t})=>Wy(e.get("view"),t("minView")),isDayView:({context:e,event:t})=>(t.view||e.get("view"))==="day",isMonthView:({context:e,event:t})=>(t.view||e.get("view"))==="month",isYearView:({context:e,event:t})=>(t.view||e.get("view"))==="year",isRangePicker:({prop:e})=>e("selectionMode")==="range",hasSelectedRange:({context:e})=>e.get("value").length===2,isMultiPicker:({prop:e})=>e("selectionMode")==="multiple",shouldRestoreFocus:({context:e})=>!!e.get("restoreFocus"),isSelectingEndDate:({context:e})=>e.get("activeIndex")===1,closeOnSelect:({prop:e})=>!!e("closeOnSelect"),isOpenControlled:({prop:e})=>e("open")!=null||!!e("inline"),isInteractOutsideEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="INTERACT_OUTSIDE"},isInputValueEmpty:({event:e})=>e.value.trim()==="",shouldFixOnBlur:({event:e})=>!!e.fixOnBlur},effects:{trackPositioning({context:e,prop:t,scope:n}){if(t("inline"))return;e.get("currentPlacement")||e.set("currentPlacement",t("positioning").placement);let r=Tu(n);return at(r,()=>$y(n),y(m({},t("positioning")),{defer:!0,onComplete(s){e.set("currentPlacement",s.placement)}}))},setupLiveRegion({scope:e,refs:t}){let n=e.getDoc();return t.set("announcer",wy({level:"assertive",document:n})),()=>{var r,i;return(i=(r=t.get("announcer"))==null?void 0:r.destroy)==null?void 0:i.call(r)}},trackDismissableElement({scope:e,send:t,context:n,prop:r}){return r("inline")?void 0:vt(()=>zi(e),{type:"popover",defer:!0,exclude:[...Dr(e),Bc(e),My(e)],onInteractOutside(s){n.set("restoreFocus",!s.detail.focusable)},onDismiss(){t({type:"INTERACT_OUTSIDE"})},onEscapeKeyDown(s){s.preventDefault(),t({type:"TABLE.ESCAPE",src:"dismissable"})}})}},actions:{setNextView({context:e,prop:t}){let n=Yy(e.get("view"),t("minView"),t("maxView"));e.set("view",n)},setPreviousView({context:e,prop:t}){let n=jy(e.get("view"),t("minView"),t("maxView"));e.set("view",n)},setView({context:e,event:t}){e.set("view",t.view)},setRestoreFocus({context:e}){e.set("restoreFocus",!0)},announceValueText({context:e,prop:t,refs:n}){var a;let r=e.get("value"),i=t("locale"),s=t("timeZone"),o;if(t("selectionMode")==="range"){let[l,c]=r;l&&c?o=Ki(l,c,i,s):l?o=Ki(l,null,i,s):c?o=Ki(c,null,i,s):o=""}else o=r.map(l=>Ki(l,null,i,s)).filter(Boolean).join(",");(a=n.get("announcer"))==null||a.announce(o,3e3)},announceVisibleRange({computed:e,refs:t}){var r;let{formatted:n}=e("visibleRangeText");(r=t.get("announcer"))==null||r.announce(n)},disableTextSelection({scope:e}){Bs({target:zi(e),doc:e.getDoc()})},enableTextSelection({scope:e}){Hs({doc:e.getDoc(),target:zi(e)})},focusFirstSelectedDate(e){let{context:t}=e;t.get("value").length&&ae(e,t.get("value")[0])},syncInputElement({scope:e,computed:t}){H(()=>{Dr(e).forEach((r,i)=>{xt(r,t("valueAsString")[i]||"")})})},setFocusedDate(e){let{event:t}=e,n=Array.isArray(t.value)?t.value[0]:t.value;ae(e,n)},setFocusedValueForView(e){let{context:t,event:n}=e;ae(e,t.get("focusedValue").set({[t.get("view")]:n.value}))},focusNextMonth(e){let{context:t}=e;ae(e,t.get("focusedValue").add({months:1}))},focusPreviousMonth(e){let{context:t}=e;ae(e,t.get("focusedValue").subtract({months:1}))},setDateValue({context:e,event:t,prop:n}){if(!Array.isArray(t.value))return;let r=t.value.map(i=>lt(i,n("min"),n("max")));e.set("value",r)},clearDateValue({context:e}){e.set("value",[])},setSelectedDate(e){var i;let{context:t,event:n}=e,r=Array.from(t.get("value"));r[t.get("activeIndex")]=Qi(e,(i=n.value)!=null?i:t.get("focusedValue")),t.set("value",Ro(r))},resetSelection(e){var i;let{context:t,event:n}=e,r=Qi(e,(i=n.value)!=null?i:t.get("focusedValue"));t.set("value",[r])},toggleSelectedDate(e){var s;let{context:t,event:n}=e,r=Qi(e,(s=n.value)!=null?s:t.get("focusedValue")),i=t.get("value").findIndex(o=>Ge(o,r));if(i===-1){let o=[...t.get("value"),r];t.set("value",ji(o))}else{let o=Array.from(t.get("value"));o.splice(i,1),t.set("value",ji(o))}},setHoveredDate({context:e,event:t}){e.set("hoveredValue",t.value)},clearHoveredDate({context:e}){e.set("hoveredValue",null)},selectFocusedDate({context:e,computed:t}){let n=Array.from(e.get("value")),r=e.get("activeIndex");n[r]=e.get("focusedValue").copy(),e.set("value",Ro(n));let i=t("valueAsString");e.set("inputValue",i[r])},focusPreviousDay(e){let{context:t}=e,n=t.get("focusedValue").subtract({days:1});ae(e,n)},focusNextDay(e){let{context:t}=e,n=t.get("focusedValue").add({days:1});ae(e,n)},focusPreviousWeek(e){let{context:t}=e,n=t.get("focusedValue").subtract({weeks:1});ae(e,n)},focusNextWeek(e){let{context:t}=e,n=t.get("focusedValue").add({weeks:1});ae(e,n)},focusNextPage(e){let{context:t,computed:n,prop:r}=e,i=pu(t.get("focusedValue"),t.get("startValue"),n("visibleDuration"),r("locale"),r("min"),r("max"));Zi(e,i)},focusPreviousPage(e){let{context:t,computed:n,prop:r}=e,i=mu(t.get("focusedValue"),t.get("startValue"),n("visibleDuration"),r("locale"),r("min"),r("max"));Zi(e,i)},focusSectionStart(e){let{context:t}=e;ae(e,t.get("startValue").copy())},focusSectionEnd(e){let{computed:t}=e;ae(e,t("endValue").copy())},focusNextSection(e){let{context:t,event:n,computed:r,prop:i}=e,s=Ey(t.get("focusedValue"),t.get("startValue"),n.larger,r("visibleDuration"),i("locale"),i("min"),i("max"));s&&Zi(e,s)},focusPreviousSection(e){let{context:t,event:n,computed:r,prop:i}=e,s=Cy(t.get("focusedValue"),t.get("startValue"),n.larger,r("visibleDuration"),i("locale"),i("min"),i("max"));s&&Zi(e,s)},focusNextYear(e){let{context:t}=e,n=t.get("focusedValue").add({years:1});ae(e,n)},focusPreviousYear(e){let{context:t}=e,n=t.get("focusedValue").subtract({years:1});ae(e,n)},focusNextDecade(e){let{context:t}=e,n=t.get("focusedValue").add({years:10});ae(e,n)},focusPreviousDecade(e){let{context:t}=e,n=t.get("focusedValue").subtract({years:10});ae(e,n)},clearFocusedDate(e){let{prop:t}=e;ae(e,nr(t("timeZone")))},focusPreviousMonthColumn(e){let{context:t,event:n}=e,r=t.get("focusedValue").subtract({months:n.columns});ae(e,r)},focusNextMonthColumn(e){let{context:t,event:n}=e,r=t.get("focusedValue").add({months:n.columns});ae(e,r)},focusPreviousYearColumn(e){let{context:t,event:n}=e,r=t.get("focusedValue").subtract({years:n.columns});ae(e,r)},focusNextYearColumn(e){let{context:t,event:n}=e,r=t.get("focusedValue").add({years:n.columns});ae(e,r)},focusFirstMonth(e){let{context:t}=e,n=t.get("focusedValue").set({month:1});ae(e,n)},focusLastMonth(e){let{context:t}=e,n=t.get("focusedValue").set({month:12});ae(e,n)},focusFirstYear(e){let{context:t}=e,n=rr(t.get("focusedValue").year),r=t.get("focusedValue").set({year:n[0]});ae(e,r)},focusLastYear(e){let{context:t}=e,n=rr(t.get("focusedValue").year),r=t.get("focusedValue").set({year:n[n.length-1]});ae(e,r)},setActiveIndex({context:e,event:t}){e.set("activeIndex",t.index)},setActiveIndexToEnd({context:e}){e.set("activeIndex",1)},setActiveIndexToStart({context:e}){e.set("activeIndex",0)},focusActiveCell({scope:e,context:t}){H(()=>{var r;let n=t.get("view");(r=Hc(e,n))==null||r.focus({preventScroll:!0})})},focusActiveCellIfNeeded({scope:e,context:t,event:n}){n.focus&&H(()=>{var i;let r=t.get("view");(i=Hc(e,r))==null||i.focus({preventScroll:!0})})},setHoveredValueIfKeyboard({context:e,event:t,prop:n}){!t.type.startsWith("TABLE.ARROW")||n("selectionMode")!=="range"||e.get("activeIndex")===0||e.set("hoveredValue",e.get("focusedValue").copy())},focusTriggerElement({scope:e}){H(()=>{var t;(t=Bc(e))==null||t.focus({preventScroll:!0})})},focusFirstInputElement({scope:e}){H(()=>{let[t]=Dr(e);t==null||t.focus({preventScroll:!0})})},focusInputElement({scope:e}){H(()=>{let t=Dr(e),n=t.findLastIndex(s=>s.value!==""),r=Math.max(n,0),i=t[r];i==null||i.focus({preventScroll:!0}),i==null||i.setSelectionRange(i.value.length,i.value.length)})},syncMonthSelectElement({scope:e,context:t}){let n=Fy(e);xt(n,t.get("startValue").month.toString())},syncYearSelectElement({scope:e,context:t}){let n=Ly(e);xt(n,t.get("startValue").year.toString())},setInputValue({context:e,event:t}){e.get("activeIndex")===t.index&&e.set("inputValue",t.value)},syncInputValue({scope:e,context:t,event:n}){queueMicrotask(()=>{var s;let r=Dr(e),i=(s=n.index)!=null?s:t.get("activeIndex");xt(r[i],t.get("inputValue"))})},focusParsedDate(e){let{event:t,prop:n}=e;if(t.index==null)return;let i=n("parse")(t.value,{locale:n("locale"),timeZone:n("timeZone")});!i||!Gc(i)||ae(e,i)},selectParsedDate({context:e,event:t,prop:n}){if(t.index==null)return;let i=n("parse")(t.value,{locale:n("locale"),timeZone:n("timeZone")});if((!i||!Gc(i))&&t.value&&(i=e.get("focusedValue").copy()),!i)return;i=lt(i,n("min"),n("max"));let s=Array.from(e.get("value"));s[t.index]=i,e.set("value",s);let o=Xi(s,n);e.set("inputValue",o[t.index])},resetView({context:e}){e.set("view",e.initial("view"))},setStartValue({context:e,computed:t,prop:n}){let r=e.get("focusedValue");if(!yt(r,e.get("startValue"),t("endValue")))return;let s=Dc(r,"start",{months:n("numOfMonths")},n("locale"));e.set("startValue",s)},invokeOnOpen({prop:e,context:t}){var n;e("inline")||(n=e("onOpenChange"))==null||n({open:!0,value:t.get("value")})},invokeOnClose({prop:e,context:t}){var n;e("inline")||(n=e("onOpenChange"))==null||n({open:!1,value:t.get("value")})},invokeOnVisibleRangeChange({prop:e,context:t,computed:n}){var r;(r=e("onVisibleRangeChange"))==null||r({view:t.get("view"),visibleRange:n("visibleRange")})},toggleVisibility({event:e,send:t,prop:n}){t({type:n("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:e})}}}},Qi=(e,t)=>{let{context:n,prop:r}=e,i=n.get("view"),s=typeof t=="number"?n.get("focusedValue").set({[i]:t}):t;return Zy(o=>{Ky(o,r("minView"))&&(s=s.set({[o]:o==="day"?1:0}))}),s};tb=G()(["closeOnSelect","dir","disabled","fixedWeeks","focusedValue","format","parse","placeholder","getRootNode","id","ids","inline","invalid","isDateUnavailable","locale","max","min","name","numOfMonths","onFocusChange","onOpenChange","onValueChange","onViewChange","onVisibleRangeChange","open","defaultOpen","positioning","readOnly","required","selectionMode","startOfWeek","timeZone","translations","value","defaultView","defaultValue","view","defaultFocusedValue","outsideDaySelectable","minView","maxView"]),CT=B(tb),nb=G()(["index","fixOnBlur"]),IT=B(nb),rb=G()(["value"]),TT=B(rb),ib=G()(["columns","id","view"]),OT=B(ib),sb=G()(["disabled","value","columns"]),ST=B(sb),ob=G()(["view"]),PT=B(ob),ab=class extends te{constructor(){super(...arguments);U(this,"getDayView",()=>this.el.querySelector('[data-part="day-view"]'));U(this,"getMonthView",()=>this.el.querySelector('[data-part="month-view"]'));U(this,"getYearView",()=>this.el.querySelector('[data-part="year-view"]'));U(this,"renderDayTableHeader",()=>{let t=this.getDayView(),n=t==null?void 0:t.querySelector("thead");if(!n||!this.api.weekDays)return;let r=this.doc.createElement("tr");this.spreadProps(r,this.api.getTableRowProps({view:"day"})),this.api.weekDays.forEach(i=>{let s=this.doc.createElement("th");s.scope="col",s.setAttribute("aria-label",i.long),s.textContent=i.narrow,r.appendChild(s)}),n.innerHTML="",n.appendChild(r)});U(this,"renderDayTableBody",()=>{let t=this.getDayView(),n=t==null?void 0:t.querySelector("tbody");n&&(this.spreadProps(n,this.api.getTableBodyProps({view:"day"})),this.api.weeks&&(n.innerHTML="",this.api.weeks.forEach(r=>{let i=this.doc.createElement("tr");this.spreadProps(i,this.api.getTableRowProps({view:"day"})),r.forEach(s=>{let o=this.doc.createElement("td");this.spreadProps(o,this.api.getDayTableCellProps({value:s}));let a=this.doc.createElement("div");this.spreadProps(a,this.api.getDayTableCellTriggerProps({value:s})),a.textContent=String(s.day),o.appendChild(a),i.appendChild(o)}),n.appendChild(i)})))});U(this,"renderMonthTableBody",()=>{let t=this.getMonthView(),n=t==null?void 0:t.querySelector("tbody");if(!n)return;this.spreadProps(n,this.api.getTableBodyProps({view:"month"}));let r=this.api.getMonthsGrid({columns:4,format:"short"});n.innerHTML="",r.forEach(i=>{let s=this.doc.createElement("tr");this.spreadProps(s,this.api.getTableRowProps()),i.forEach(o=>{let a=this.doc.createElement("td");this.spreadProps(a,this.api.getMonthTableCellProps(y(m({},o),{columns:4})));let l=this.doc.createElement("div");this.spreadProps(l,this.api.getMonthTableCellTriggerProps(y(m({},o),{columns:4}))),l.textContent=o.label,a.appendChild(l),s.appendChild(a)}),n.appendChild(s)})});U(this,"renderYearTableBody",()=>{let t=this.getYearView(),n=t==null?void 0:t.querySelector("tbody");if(!n)return;this.spreadProps(n,this.api.getTableBodyProps());let r=this.api.getYearsGrid({columns:4});n.innerHTML="",r.forEach(i=>{let s=this.doc.createElement("tr");this.spreadProps(s,this.api.getTableRowProps({view:"year"})),i.forEach(o=>{let a=this.doc.createElement("td");this.spreadProps(a,this.api.getYearTableCellProps(y(m({},o),{columns:4})));let l=this.doc.createElement("div");this.spreadProps(l,this.api.getYearTableCellTriggerProps(y(m({},o),{columns:4}))),l.textContent=o.label,a.appendChild(l),s.appendChild(a)}),n.appendChild(s)})})}initMachine(t){return new ee(eb,m({},t))}initApi(){return zy(this.machine.service,Q)}render(){let t=this.el.querySelector('[data-scope="date-picker"][data-part="root"]');t&&this.spreadProps(t,this.api.getRootProps());let n=this.el.querySelector('[data-scope="date-picker"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps());let r=this.el.querySelector('[data-scope="date-picker"][data-part="control"]');r&&this.spreadProps(r,this.api.getControlProps());let i=this.el.querySelector('[data-scope="date-picker"][data-part="input"]');i&&this.spreadProps(i,this.api.getInputProps());let s=this.el.querySelector('[data-scope="date-picker"][data-part="trigger"]');s&&this.spreadProps(s,this.api.getTriggerProps());let o=this.el.querySelector('[data-scope="date-picker"][data-part="positioner"]');o&&this.spreadProps(o,this.api.getPositionerProps());let a=this.el.querySelector('[data-scope="date-picker"][data-part="content"]');if(a&&this.spreadProps(a,this.api.getContentProps()),this.api.open){let l=this.getDayView(),c=this.getMonthView(),u=this.getYearView();if(l&&(l.hidden=this.api.view!=="day"),c&&(c.hidden=this.api.view!=="month"),u&&(u.hidden=this.api.view!=="year"),this.api.view==="day"&&l){let h=l.querySelector('[data-part="view-control"]');h&&this.spreadProps(h,this.api.getViewControlProps({view:"year"}));let p=l.querySelector('[data-part="prev-trigger"]');p&&this.spreadProps(p,this.api.getPrevTriggerProps());let d=l.querySelector('[data-part="view-trigger"]');d&&(this.spreadProps(d,this.api.getViewTriggerProps()),d.textContent=this.api.visibleRangeText.start);let g=l.querySelector('[data-part="next-trigger"]');g&&this.spreadProps(g,this.api.getNextTriggerProps());let v=l.querySelector("table");v&&this.spreadProps(v,this.api.getTableProps({view:"day"}));let b=l.querySelector("thead");b&&this.spreadProps(b,this.api.getTableHeaderProps({view:"day"})),this.renderDayTableHeader(),this.renderDayTableBody()}else if(this.api.view==="month"&&c){let h=c.querySelector('[data-part="view-control"]');h&&this.spreadProps(h,this.api.getViewControlProps({view:"month"}));let p=c.querySelector('[data-part="prev-trigger"]');p&&this.spreadProps(p,this.api.getPrevTriggerProps({view:"month"}));let d=c.querySelector('[data-part="view-trigger"]');d&&(this.spreadProps(d,this.api.getViewTriggerProps({view:"month"})),d.textContent=String(this.api.visibleRange.start.year));let g=c.querySelector('[data-part="next-trigger"]');g&&this.spreadProps(g,this.api.getNextTriggerProps({view:"month"}));let v=c.querySelector("table");v&&this.spreadProps(v,this.api.getTableProps({view:"month",columns:4})),this.renderMonthTableBody()}else if(this.api.view==="year"&&u){let h=u.querySelector('[data-part="view-control"]');h&&this.spreadProps(h,this.api.getViewControlProps({view:"year"}));let p=u.querySelector('[data-part="prev-trigger"]');p&&this.spreadProps(p,this.api.getPrevTriggerProps({view:"year"}));let d=u.querySelector('[data-part="decade"]');if(d){let b=this.api.getDecade();d.textContent=`${b.start} - ${b.end}`}let g=u.querySelector('[data-part="next-trigger"]');g&&this.spreadProps(g,this.api.getNextTriggerProps({view:"year"}));let v=u.querySelector("table");v&&this.spreadProps(v,this.api.getTableProps({view:"year",columns:4})),this.renderYearTableBody()}}}};lb={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=this.liveSocket,r=x(e,"min"),i=x(e,"max"),s=x(e,"positioning"),o=u=>u?u.map(h=>Ze(h)):void 0,a=u=>u?Ze(u):void 0,l=new ab(e,y(m({id:e.id},O(e,"controlled")?{value:o(Y(e,"value"))}:{defaultValue:o(Y(e,"defaultValue"))}),{defaultFocusedValue:a(x(e,"focusedValue")),defaultView:x(e,"defaultView",["day","month","year"]),dir:x(e,"dir",["ltr","rtl"]),locale:x(e,"locale"),timeZone:x(e,"timeZone"),disabled:O(e,"disabled"),readOnly:O(e,"readOnly"),required:O(e,"required"),invalid:O(e,"invalid"),outsideDaySelectable:O(e,"outsideDaySelectable"),closeOnSelect:O(e,"closeOnSelect"),min:r?Ze(r):void 0,max:i?Ze(i):void 0,numOfMonths:Se(e,"numOfMonths"),startOfWeek:Se(e,"startOfWeek"),fixedWeeks:O(e,"fixedWeeks"),selectionMode:x(e,"selectionMode",["single","multiple","range"]),placeholder:x(e,"placeholder"),minView:x(e,"minView",["day","month","year"]),maxView:x(e,"maxView",["day","month","year"]),inline:O(e,"inline"),positioning:s?JSON.parse(s):void 0,onValueChange:u=>{var g;let h=(g=u.value)!=null&&g.length?u.value.map(v=>Uc(v)).join(","):"",p=e.querySelector(`#${e.id}-value`);p&&p.value!==h&&(p.value=h,p.dispatchEvent(new Event("input",{bubbles:!0})),p.dispatchEvent(new Event("change",{bubbles:!0})));let d=x(e,"onValueChange");d&&n.main.isConnected()&&t(d,{id:e.id,value:h||null})},onFocusChange:u=>{var p;let h=x(e,"onFocusChange");h&&n.main.isConnected()&&t(h,{id:e.id,focused:(p=u.focused)!=null?p:!1})},onViewChange:u=>{let h=x(e,"onViewChange");h&&n.main.isConnected()&&t(h,{id:e.id,view:u.view})},onVisibleRangeChange:u=>{let h=x(e,"onVisibleRangeChange");h&&n.main.isConnected()&&t(h,{id:e.id,start:u.start,end:u.end})},onOpenChange:u=>{let h=x(e,"onOpenChange");h&&n.main.isConnected()&&t(h,{id:e.id,open:u.open})}}));l.init(),this.datePicker=l;let c=e.querySelector('[data-scope="date-picker"][data-part="input-wrapper"]');c&&c.removeAttribute("data-loading"),this.handlers=[],this.handlers.push(this.handleEvent("date_picker_set_value",u=>{let h=u.date_picker_id;h&&h!==e.id||l.api.setValue([Ze(u.value)])})),this.onSetValue=u=>{var p;let h=(p=u.detail)==null?void 0:p.value;typeof h=="string"&&l.api.setValue([Ze(h)])},e.addEventListener("phx:date-picker:set-value",this.onSetValue)},updated(){var l,c;let e=this.el,t=e.querySelector('[data-scope="date-picker"][data-part="input-wrapper"]');t&&t.removeAttribute("data-loading");let n=u=>u?u.map(h=>Ze(h)):void 0,r=x(e,"min"),i=x(e,"max"),s=x(e,"positioning"),o=O(e,"controlled"),a=x(e,"focusedValue");if((l=this.datePicker)==null||l.updateProps(y(m({},O(e,"controlled")?{value:n(Y(e,"value"))}:{defaultValue:n(Y(e,"defaultValue"))}),{defaultFocusedValue:a?Ze(a):void 0,defaultView:x(e,"defaultView",["day","month","year"]),dir:x(this.el,"dir",["ltr","rtl"]),locale:x(this.el,"locale"),timeZone:x(this.el,"timeZone"),disabled:O(this.el,"disabled"),readOnly:O(this.el,"readOnly"),required:O(this.el,"required"),invalid:O(this.el,"invalid"),outsideDaySelectable:O(this.el,"outsideDaySelectable"),closeOnSelect:O(this.el,"closeOnSelect"),min:r?Ze(r):void 0,max:i?Ze(i):void 0,numOfMonths:Se(this.el,"numOfMonths"),startOfWeek:Se(this.el,"startOfWeek"),fixedWeeks:O(this.el,"fixedWeeks"),selectionMode:x(this.el,"selectionMode",["single","multiple","range"]),placeholder:x(this.el,"placeholder"),minView:x(this.el,"minView",["day","month","year"]),maxView:x(this.el,"maxView",["day","month","year"]),inline:O(this.el,"inline"),positioning:s?JSON.parse(s):void 0})),o&&this.datePicker){let u=Y(e,"value"),h=(c=u==null?void 0:u.join(","))!=null?c:"",p=this.datePicker.api.value,d=p!=null&&p.length?p.map(g=>Uc(g)).join(","):"";if(h!==d){let g=u!=null&&u.length?u.map(v=>Ze(v)):[];this.datePicker.api.setValue(g)}}},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:date-picker:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.datePicker)==null||e.destroy()}}});var Lu={};Oe(Lu,{Dialog:()=>_b});function mb(e,t={}){let{defer:n=!0}=t,r=n?pb:s=>s(),i=[];return i.push(r(()=>{let o=(typeof e=="function"?e():e).filter(Boolean);o.length!==0&&i.push(fb(o))})),()=>{i.forEach(s=>s==null?void 0:s())}}function Sb(e,t={}){let n,r=H(()=>{let s=(Array.isArray(e)?e:[e]).map(a=>typeof a=="function"?a():a).filter(a=>a!=null);if(s.length===0)return;let o=s[0];n=new Eb(s,y(m({escapeDeactivates:!1,allowOutsideClick:!0,preventScroll:!0,returnFocusOnDeactivate:!0,delayInitialFocus:!1,fallbackFocus:o},t),{document:we(o)}));try{n.activate()}catch(a){}});return function(){n==null||n.deactivate(),r()}}function Pb(e){let t=e.getBoundingClientRect().left;return Math.round(t)+e.scrollLeft?"paddingLeft":"paddingRight"}function xu(e){let t=qt(e),n=t==null?void 0:t.scrollbarGutter;return n==="stable"||(n==null?void 0:n.startsWith("stable "))===!0}function wb(e){var d;let t=e!=null?e:document,n=(d=t.defaultView)!=null?d:window,{documentElement:r,body:i}=t;if(i.hasAttribute(Ko))return;let o=xu(r)||xu(i),a=n.innerWidth-r.clientWidth;i.setAttribute(Ko,"");let l=()=>Qa(r,"--scrollbar-width",`${a}px`),c=Pb(r),u=()=>{let g={overflow:"hidden"};return!o&&a>0&&(g[c]=`${a}px`),cn(i,g)},h=()=>{var C,I;let{scrollX:g,scrollY:v,visualViewport:b}=n,V=(C=b==null?void 0:b.offsetLeft)!=null?C:0,S=(I=b==null?void 0:b.offsetTop)!=null?I:0,E={position:"fixed",overflow:"hidden",top:`${-(v-Math.floor(S))}px`,left:`${-(g-Math.floor(V))}px`,right:"0"};!o&&a>0&&(E[c]=`${a}px`);let f=cn(i,E);return()=>{f==null||f(),n.scrollTo({left:g,top:v,behavior:"instant"})}},p=[l(),br()?h():u()];return()=>{p.forEach(g=>g==null?void 0:g()),i.removeAttribute(Ko)}}function Lb(e,t){let{state:n,send:r,context:i,prop:s,scope:o}=e,a=s("aria-label"),l=n.matches("open");return{open:l,setOpen(c){n.matches("open")!==c&&r({type:c?"OPEN":"CLOSE"})},getTriggerProps(){return t.button(y(m({},Cn.trigger.attrs),{dir:s("dir"),id:Ru(o),"aria-haspopup":"dialog",type:"button","aria-expanded":l,"data-state":l?"open":"closed","aria-controls":Yo(o),onClick(c){c.defaultPrevented||r({type:"TOGGLE"})}}))},getBackdropProps(){return t.element(y(m({},Cn.backdrop.attrs),{dir:s("dir"),hidden:!l,id:Au(o),"data-state":l?"open":"closed"}))},getPositionerProps(){return t.element(y(m({},Cn.positioner.attrs),{dir:s("dir"),id:Nu(o),style:{pointerEvents:l?void 0:"none"}}))},getContentProps(){let c=i.get("rendered");return t.element(y(m({},Cn.content.attrs),{dir:s("dir"),role:s("role"),hidden:!l,id:Yo(o),tabIndex:-1,"data-state":l?"open":"closed","aria-modal":!0,"aria-label":a||void 0,"aria-labelledby":a||!c.title?void 0:jo(o),"aria-describedby":c.description?Xo(o):void 0}))},getTitleProps(){return t.element(y(m({},Cn.title.attrs),{dir:s("dir"),id:jo(o)}))},getDescriptionProps(){return t.element(y(m({},Cn.description.attrs),{dir:s("dir"),id:Xo(o)}))},getCloseTriggerProps(){return t.button(y(m({},Cn.closeTrigger.attrs),{dir:s("dir"),id:Du(o),type:"button",onClick(c){c.defaultPrevented||(c.stopPropagation(),r({type:"CLOSE"}))}}))}}}var ar,is,ss,qo,ku,cb,ub,db,hb,gb,fb,pb,vb,yb,le,wu,bb,Eb,Zo,Wo,Cb,Ib,_r,Tb,Vu,Ob,Ko,Vb,Cn,Nu,Au,Yo,Ru,jo,Xo,Du,os,xb,kb,Nb,Ab,Rb,Db,Fb,Mb,RT,$b,_b,Fu=fe(()=>{"use strict";gn();me();ar=new WeakMap,is=new WeakMap,ss={},qo=0,ku=e=>e&&(e.host||ku(e.parentNode)),cb=(e,t)=>t.map(n=>{if(e.contains(n))return n;let r=ku(n);return r&&e.contains(r)?r:(console.error("[zag-js > ariaHidden] target",n,"in not contained inside",e,". Doing nothing"),null)}).filter(n=>!!n),ub=new Set(["script","output","status","next-route-announcer"]),db=e=>ub.has(e.localName)||e.role==="status"||e.hasAttribute("aria-live")?!0:e.matches("[data-live-announcer]"),hb=(e,t)=>{let{parentNode:n,markerName:r,controlAttribute:i,followControlledElements:s=!0}=t,o=cb(n,Array.isArray(e)?e:[e]);ss[r]||(ss[r]=new WeakMap);let a=ss[r],l=[],c=new Set,u=new Set(o),h=d=>{!d||c.has(d)||(c.add(d),h(d.parentNode))};o.forEach(d=>{h(d),s&&ce(d)&&Ds(d,g=>{h(g)})});let p=d=>{!d||u.has(d)||Array.prototype.forEach.call(d.children,g=>{if(c.has(g))p(g);else try{if(db(g))return;let b=g.getAttribute(i)==="true",V=(ar.get(g)||0)+1,S=(a.get(g)||0)+1;ar.set(g,V),a.set(g,S),l.push(g),V===1&&b&&is.set(g,!0),S===1&&g.setAttribute(r,""),b||g.setAttribute(i,"true")}catch(v){console.error("[zag-js > ariaHidden] cannot operate on ",g,v)}})};return p(n),c.clear(),qo++,()=>{l.forEach(d=>{let g=ar.get(d)-1,v=a.get(d)-1;ar.set(d,g),a.set(d,v),g||(is.has(d)||d.removeAttribute(i),is.delete(d)),v||d.removeAttribute(r)}),qo--,qo||(ar=new WeakMap,ar=new WeakMap,is=new WeakMap,ss={})}},gb=e=>(Array.isArray(e)?e[0]:e).ownerDocument.body,fb=(e,t=gb(e),n="data-aria-hidden",r=!0)=>{if(t)return hb(e,{parentNode:t,markerName:n,controlAttribute:"aria-hidden",followControlledElements:r})},pb=e=>{let t=requestAnimationFrame(()=>e());return()=>cancelAnimationFrame(t)};vb=Object.defineProperty,yb=(e,t,n)=>t in e?vb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,le=(e,t,n)=>yb(e,typeof t!="symbol"?t+"":t,n),wu={activateTrap(e,t){if(e.length>0){let r=e[e.length-1];r!==t&&r.pause()}let n=e.indexOf(t);n===-1||e.splice(n,1),e.push(t)},deactivateTrap(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()}},bb=[],Eb=class{constructor(e,t){le(this,"trapStack"),le(this,"config"),le(this,"doc"),le(this,"state",{containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0}),le(this,"portalContainers",new Set),le(this,"listenerCleanups",[]),le(this,"handleFocus",r=>{let i=K(r),s=this.findContainerIndex(i,r)>=0;if(s||yr(i))s&&(this.state.mostRecentlyFocusedNode=i);else{r.stopImmediatePropagation();let o,a=!0;if(this.state.mostRecentlyFocusedNode)if(Dn(this.state.mostRecentlyFocusedNode)>0){let l=this.findContainerIndex(this.state.mostRecentlyFocusedNode),{tabbableNodes:c}=this.state.containerGroups[l];if(c.length>0){let u=c.findIndex(h=>h===this.state.mostRecentlyFocusedNode);u>=0&&(this.config.isKeyForward(this.state.recentNavEvent)?u+1=0&&(o=c[u-1],a=!1))}}else this.state.containerGroups.some(l=>l.tabbableNodes.some(c=>Dn(c)>0))||(a=!1);else a=!1;a&&(o=this.findNextNavNode({target:this.state.mostRecentlyFocusedNode,isBackward:this.config.isKeyBackward(this.state.recentNavEvent)})),o?this.tryFocus(o):this.tryFocus(this.state.mostRecentlyFocusedNode||this.getInitialFocusNode())}this.state.recentNavEvent=void 0}),le(this,"handlePointerDown",r=>{let i=K(r);if(!(this.findContainerIndex(i,r)>=0)){if(_r(this.config.clickOutsideDeactivates,r)){this.deactivate({returnFocus:this.config.returnFocusOnDeactivate});return}_r(this.config.allowOutsideClick,r)||r.preventDefault()}}),le(this,"handleClick",r=>{let i=K(r);this.findContainerIndex(i,r)>=0||_r(this.config.clickOutsideDeactivates,r)||_r(this.config.allowOutsideClick,r)||(r.preventDefault(),r.stopImmediatePropagation())}),le(this,"handleTabKey",r=>{if(this.config.isKeyForward(r)||this.config.isKeyBackward(r)){this.state.recentNavEvent=r;let i=this.config.isKeyBackward(r),s=this.findNextNavNode({event:r,isBackward:i});if(!s)return;Wo(r)&&r.preventDefault(),this.tryFocus(s)}}),le(this,"handleEscapeKey",r=>{Tb(r)&&_r(this.config.escapeDeactivates,r)!==!1&&(r.preventDefault(),this.deactivate())}),le(this,"_mutationObserver"),le(this,"setupMutationObserver",()=>{let r=this.doc.defaultView||window;this._mutationObserver=new r.MutationObserver(i=>{i.some(a=>Array.from(a.removedNodes).some(c=>c===this.state.mostRecentlyFocusedNode))&&this.tryFocus(this.getInitialFocusNode()),i.some(a=>a.type==="attributes"&&(a.attributeName==="aria-controls"||a.attributeName==="aria-expanded")?!0:a.type==="childList"&&a.addedNodes.length>0?Array.from(a.addedNodes).some(l=>{if(l.nodeType!==Node.ELEMENT_NODE)return!1;let c=l;return Ma(c)?!0:c.id&&!this.state.containers.some(u=>u.contains(c))?$a(c):!1}):!1)&&this.state.active&&!this.state.paused&&(this.updateTabbableNodes(),this.updatePortalContainers())})}),le(this,"updateObservedNodes",()=>{var r;(r=this._mutationObserver)==null||r.disconnect(),this.state.active&&!this.state.paused&&(this.state.containers.map(i=>{var s;(s=this._mutationObserver)==null||s.observe(i,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["aria-controls","aria-expanded"]})}),this.portalContainers.forEach(i=>{this.observePortalContainer(i)}))}),le(this,"getInitialFocusNode",()=>{let r=this.getNodeForOption("initialFocus",{hasFallback:!0});if(r===!1)return!1;if(r===void 0||r&&!Qe(r)){let i=kn(this.doc);if(i&&this.findContainerIndex(i)>=0)r=i;else{let s=this.state.tabbableGroups[0];r=s&&s.firstTabbableNode||this.getNodeForOption("fallbackFocus")}}else r===null&&(r=this.getNodeForOption("fallbackFocus"));if(!r)throw new Error("Your focus-trap needs to have at least one focusable element");return r.isConnected||(r=this.getNodeForOption("fallbackFocus")),r}),le(this,"tryFocus",r=>{if(r!==!1&&r!==kn(this.doc)){if(!r||!r.focus){this.tryFocus(this.getInitialFocusNode());return}r.focus({preventScroll:!!this.config.preventScroll}),this.state.mostRecentlyFocusedNode=r,Ob(r)&&r.select()}}),le(this,"deactivate",r=>{if(!this.state.active)return this;let i=m({onDeactivate:this.config.onDeactivate,onPostDeactivate:this.config.onPostDeactivate,checkCanReturnFocus:this.config.checkCanReturnFocus},r);clearTimeout(this.state.delayInitialFocusTimer),this.state.delayInitialFocusTimer=void 0,this.removeListeners(),this.state.active=!1,this.state.paused=!1,this.updateObservedNodes(),wu.deactivateTrap(this.trapStack,this),this.portalContainers.clear();let s=this.getOption(i,"onDeactivate"),o=this.getOption(i,"onPostDeactivate"),a=this.getOption(i,"checkCanReturnFocus"),l=this.getOption(i,"returnFocus","returnFocusOnDeactivate");s==null||s();let c=()=>{Vu(()=>{if(l){let u=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);this.tryFocus(u)}o==null||o()})};if(l&&a){let u=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);return a(u).then(c,c),this}return c(),this}),le(this,"pause",r=>{if(this.state.paused||!this.state.active)return this;let i=this.getOption(r,"onPause"),s=this.getOption(r,"onPostPause");return this.state.paused=!0,i==null||i(),this.removeListeners(),this.updateObservedNodes(),s==null||s(),this}),le(this,"unpause",r=>{if(!this.state.paused||!this.state.active)return this;let i=this.getOption(r,"onUnpause"),s=this.getOption(r,"onPostUnpause");return this.state.paused=!1,i==null||i(),this.updateTabbableNodes(),this.addListeners(),this.updateObservedNodes(),s==null||s(),this}),le(this,"updateContainerElements",r=>(this.state.containers=Array.isArray(r)?r.filter(Boolean):[r].filter(Boolean),this.state.active&&this.updateTabbableNodes(),this.updateObservedNodes(),this)),le(this,"getReturnFocusNode",r=>{let i=this.getNodeForOption("setReturnFocus",{params:[r]});return i||(i===!1?!1:r)}),le(this,"getOption",(r,i,s)=>r&&r[i]!==void 0?r[i]:this.config[s||i]),le(this,"getNodeForOption",(r,{hasFallback:i=!1,params:s=[]}={})=>{let o=this.config[r];if(typeof o=="function"&&(o=o(...s)),o===!0&&(o=void 0),!o){if(o===void 0||o===!1)return o;throw new Error(`\`${r}\` was specified but was not a node, or did not return a node`)}let a=o;if(typeof o=="string"){try{a=this.doc.querySelector(o)}catch(l){throw new Error(`\`${r}\` appears to be an invalid selector; error="${l.message}"`)}if(!a&&!i)throw new Error(`\`${r}\` as selector refers to no known node`)}return a}),le(this,"findNextNavNode",r=>{let{event:i,isBackward:s=!1}=r,o=r.target||K(i);this.updateTabbableNodes();let a=null;if(this.state.tabbableGroups.length>0){let l=this.findContainerIndex(o,i),c=l>=0?this.state.containerGroups[l]:void 0;if(l<0)s?a=this.state.tabbableGroups[this.state.tabbableGroups.length-1].lastTabbableNode:a=this.state.tabbableGroups[0].firstTabbableNode;else if(s){let u=this.state.tabbableGroups.findIndex(({firstTabbableNode:h})=>o===h);if(u<0&&((c==null?void 0:c.container)===o||Qe(o)&&!Bt(o)&&!(c!=null&&c.nextTabbableNode(o,!1)))&&(u=l),u>=0){let h=u===0?this.state.tabbableGroups.length-1:u-1,p=this.state.tabbableGroups[h];a=Dn(o)>=0?p.lastTabbableNode:p.lastDomTabbableNode}else Wo(i)||(a=c==null?void 0:c.nextTabbableNode(o,!1))}else{let u=this.state.tabbableGroups.findIndex(({lastTabbableNode:h})=>o===h);if(u<0&&((c==null?void 0:c.container)===o||Qe(o)&&!Bt(o)&&!(c!=null&&c.nextTabbableNode(o)))&&(u=l),u>=0){let h=u===this.state.tabbableGroups.length-1?0:u+1,p=this.state.tabbableGroups[h];a=Dn(o)>=0?p.firstTabbableNode:p.firstDomTabbableNode}else Wo(i)||(a=c==null?void 0:c.nextTabbableNode(o))}}else a=this.getNodeForOption("fallbackFocus");return a}),this.trapStack=t.trapStack||bb;let n=m({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,followControlledElements:!0,isKeyForward:Cb,isKeyBackward:Ib},t);this.doc=n.document||we(Array.isArray(e)?e[0]:e),this.config=n,this.updateContainerElements(e),this.setupMutationObserver()}addPortalContainer(e){let t=e.parentElement;t&&!this.portalContainers.has(t)&&(this.portalContainers.add(t),this.state.active&&!this.state.paused&&this.observePortalContainer(t))}observePortalContainer(e){var t;(t=this._mutationObserver)==null||t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["aria-controls","aria-expanded"]})}updatePortalContainers(){this.config.followControlledElements&&this.state.containers.forEach(e=>{Fa(e).forEach(n=>{this.addPortalContainer(n)})})}get active(){return this.state.active}get paused(){return this.state.paused}findContainerIndex(e,t){let n=typeof(t==null?void 0:t.composedPath)=="function"?t.composedPath():void 0;return this.state.containerGroups.findIndex(({container:r,tabbableNodes:i})=>r.contains(e)||(n==null?void 0:n.includes(r))||i.find(s=>s===e)||this.isControlledElement(r,e))}isControlledElement(e,t){return this.config.followControlledElements?li(e,t):!1}updateTabbableNodes(){if(this.state.containerGroups=this.state.containers.map(e=>{let t=on(e,{getShadowRoot:this.config.getShadowRoot}),n=Ir(e,{getShadowRoot:this.config.getShadowRoot}),r=t[0],i=t[t.length-1],s=r,o=i,a=!1;for(let c=0;c0){a=!0;break}function l(c,u=!0){let h=t.indexOf(c);if(h>=0)return t[h+(u?1:-1)];let p=n.indexOf(c);if(!(p<0)){if(u){for(let d=p+1;d=0;d--)if(Bt(n[d]))return n[d]}}return{container:e,tabbableNodes:t,focusableNodes:n,posTabIndexesFound:a,firstTabbableNode:r,lastTabbableNode:i,firstDomTabbableNode:s,lastDomTabbableNode:o,nextTabbableNode:l}}),this.state.tabbableGroups=this.state.containerGroups.filter(e=>e.tabbableNodes.length>0),this.state.tabbableGroups.length<=0&&!this.getNodeForOption("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(this.state.containerGroups.find(e=>e.posTabIndexesFound)&&this.state.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")}addListeners(){if(this.state.active)return wu.activateTrap(this.trapStack,this),this.state.delayInitialFocusTimer=this.config.delayInitialFocus?Vu(()=>{this.tryFocus(this.getInitialFocusNode())}):this.tryFocus(this.getInitialFocusNode()),this.listenerCleanups.push(ie(this.doc,"focusin",this.handleFocus,!0),ie(this.doc,"mousedown",this.handlePointerDown,{capture:!0,passive:!1}),ie(this.doc,"touchstart",this.handlePointerDown,{capture:!0,passive:!1}),ie(this.doc,"click",this.handleClick,{capture:!0,passive:!1}),ie(this.doc,"keydown",this.handleTabKey,{capture:!0,passive:!1}),ie(this.doc,"keydown",this.handleEscapeKey)),this}removeListeners(){if(this.state.active)return this.listenerCleanups.forEach(e=>e()),this.listenerCleanups=[],this}activate(e){if(this.state.active)return this;let t=this.getOption(e,"onActivate"),n=this.getOption(e,"onPostActivate"),r=this.getOption(e,"checkCanFocusTrap");r||this.updateTabbableNodes(),this.state.active=!0,this.state.paused=!1,this.state.nodeFocusedBeforeActivation=kn(this.doc),t==null||t();let i=()=>{r&&this.updateTabbableNodes(),this.addListeners(),this.updateObservedNodes(),n==null||n()};return r?(r(this.state.containers.concat()).then(i,i),this):(i(),this)}},Zo=e=>e.type==="keydown",Wo=e=>Zo(e)&&(e==null?void 0:e.key)==="Tab",Cb=e=>Zo(e)&&e.key==="Tab"&&!(e!=null&&e.shiftKey),Ib=e=>Zo(e)&&e.key==="Tab"&&(e==null?void 0:e.shiftKey),_r=(e,...t)=>typeof e=="function"?e(...t):e,Tb=e=>!e.isComposing&&e.key==="Escape",Vu=e=>setTimeout(e,0),Ob=e=>e.localName==="input"&&"select"in e&&typeof e.select=="function";Ko="data-scroll-lock";Vb=Z("dialog").parts("trigger","backdrop","positioner","content","title","description","closeTrigger"),Cn=Vb.build(),Nu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.positioner)!=null?n:`dialog:${e.id}:positioner`},Au=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.backdrop)!=null?n:`dialog:${e.id}:backdrop`},Yo=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`dialog:${e.id}:content`},Ru=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`dialog:${e.id}:trigger`},jo=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.title)!=null?n:`dialog:${e.id}:title`},Xo=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.description)!=null?n:`dialog:${e.id}:description`},Du=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.closeTrigger)!=null?n:`dialog:${e.id}:close`},os=e=>e.getById(Yo(e)),xb=e=>e.getById(Nu(e)),kb=e=>e.getById(Au(e)),Nb=e=>e.getById(Ru(e)),Ab=e=>e.getById(jo(e)),Rb=e=>e.getById(Xo(e)),Db=e=>e.getById(Du(e));Fb={props({props:e,scope:t}){let n=e.role==="alertdialog",r=n?()=>Db(t):void 0,i=typeof e.modal=="boolean"?e.modal:!0;return m({role:"dialog",modal:i,trapFocus:i,preventScroll:i,closeOnInteractOutside:!n,closeOnEscape:!0,restoreFocus:!0,initialFocusEl:r},e)},initialState({prop:e}){return e("open")||e("defaultOpen")?"open":"closed"},context({bindable:e}){return{rendered:e(()=>({defaultValue:{title:!0,description:!0}}))}},watch({track:e,action:t,prop:n}){e([()=>n("open")],()=>{t(["toggleVisibility"])})},states:{open:{entry:["checkRenderedElements","syncZIndex"],effects:["trackDismissableElement","trapFocus","preventScroll","hideContentBelow"],on:{"CONTROLLED.CLOSE":{target:"closed"},CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],TOGGLE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}]}},closed:{on:{"CONTROLLED.OPEN":{target:"open"},OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}],TOGGLE:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}]}}},implementations:{guards:{isOpenControlled:({prop:e})=>e("open")!=null},effects:{trackDismissableElement({scope:e,send:t,prop:n}){return vt(()=>os(e),{type:"dialog",defer:!0,pointerBlocking:n("modal"),exclude:[Nb(e)],onInteractOutside(i){var s;(s=n("onInteractOutside"))==null||s(i),n("closeOnInteractOutside")||i.preventDefault()},persistentElements:n("persistentElements"),onFocusOutside:n("onFocusOutside"),onPointerDownOutside:n("onPointerDownOutside"),onRequestDismiss:n("onRequestDismiss"),onEscapeKeyDown(i){var s;(s=n("onEscapeKeyDown"))==null||s(i),n("closeOnEscape")||i.preventDefault()},onDismiss(){t({type:"CLOSE",src:"interact-outside"})}})},preventScroll({scope:e,prop:t}){if(t("preventScroll"))return wb(e.getDoc())},trapFocus({scope:e,prop:t}){return t("trapFocus")?Sb(()=>os(e),{preventScroll:!0,returnFocusOnDeactivate:!!t("restoreFocus"),initialFocus:t("initialFocusEl"),setReturnFocus:r=>{var i,s;return(s=(i=t("finalFocusEl"))==null?void 0:i())!=null?s:r},getShadowRoot:!0}):void 0},hideContentBelow({scope:e,prop:t}){return t("modal")?mb(()=>[os(e)],{defer:!0}):void 0}},actions:{checkRenderedElements({context:e,scope:t}){H(()=>{e.set("rendered",{title:!!Ab(t),description:!!Rb(t)})})},syncZIndex({scope:e}){H(()=>{let t=os(e);if(!t)return;let n=qt(t);[xb(e),kb(e)].forEach(i=>{i==null||i.style.setProperty("--z-index",n.zIndex),i==null||i.style.setProperty("--layer-index",n.getPropertyValue("--layer-index"))})})},invokeOnClose({prop:e}){var t;(t=e("onOpenChange"))==null||t({open:!1})},invokeOnOpen({prop:e}){var t;(t=e("onOpenChange"))==null||t({open:!0})},toggleVisibility({prop:e,send:t,event:n}){t({type:e("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:n})}}}},Mb=G()(["aria-label","closeOnEscape","closeOnInteractOutside","dir","finalFocusEl","getRootNode","getRootNode","id","id","ids","initialFocusEl","modal","onEscapeKeyDown","onFocusOutside","onInteractOutside","onOpenChange","onPointerDownOutside","onRequestDismiss","defaultOpen","open","persistentElements","preventScroll","restoreFocus","role","trapFocus"]),RT=B(Mb),$b=class extends te{initMachine(e){return new ee(Fb,e)}initApi(){return Lb(this.machine.service,Q)}render(){let e=this.el,t=e.querySelector('[data-scope="dialog"][data-part="trigger"]');t&&this.spreadProps(t,this.api.getTriggerProps());let n=e.querySelector('[data-scope="dialog"][data-part="backdrop"]');n&&this.spreadProps(n,this.api.getBackdropProps());let r=e.querySelector('[data-scope="dialog"][data-part="positioner"]');r&&this.spreadProps(r,this.api.getPositionerProps());let i=e.querySelector('[data-scope="dialog"][data-part="content"]');i&&this.spreadProps(i,this.api.getContentProps());let s=e.querySelector('[data-scope="dialog"][data-part="title"]');s&&this.spreadProps(s,this.api.getTitleProps());let o=e.querySelector('[data-scope="dialog"][data-part="description"]');o&&this.spreadProps(o,this.api.getDescriptionProps());let a=e.querySelector('[data-scope="dialog"][data-part="close-trigger"]');a&&this.spreadProps(a,this.api.getCloseTriggerProps())}},_b={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=new $b(e,y(m({id:e.id},O(e,"controlled")?{open:O(e,"open")}:{defaultOpen:O(e,"defaultOpen")}),{modal:O(e,"modal"),closeOnInteractOutside:O(e,"closeOnInteractOutside"),closeOnEscape:O(e,"closeOnEscapeKeyDown"),preventScroll:O(e,"preventScroll"),restoreFocus:O(e,"restoreFocus"),dir:x(e,"dir",["ltr","rtl"]),onOpenChange:r=>{let i=x(e,"onOpenChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,open:r.open});let s=x(e,"onOpenChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,open:r.open}}))}}));n.init(),this.dialog=n,this.onSetOpen=r=>{let{open:i}=r.detail;n.api.setOpen(i)},e.addEventListener("phx:dialog:set-open",this.onSetOpen),this.handlers=[],this.handlers.push(this.handleEvent("dialog_set_open",r=>{let i=r.dialog_id;i&&i!==e.id||n.api.setOpen(r.open)})),this.handlers.push(this.handleEvent("dialog_open",()=>{this.pushEvent("dialog_open_response",{value:n.api.open})}))},updated(){var e;(e=this.dialog)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{open:O(this.el,"open")}:{defaultOpen:O(this.el,"defaultOpen")}),{modal:O(this.el,"modal"),closeOnInteractOutside:O(this.el,"closeOnInteractOutside"),closeOnEscape:O(this.el,"closeOnEscapeKeyDown"),preventScroll:O(this.el,"preventScroll"),restoreFocus:O(this.el,"restoreFocus"),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onSetOpen&&this.el.removeEventListener("phx:dialog:set-open",this.onSetOpen),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.dialog)==null||e.destroy()}}});var Wu={};Oe(Wu,{Menu:()=>cE});function Hb(e){let{x:t,y:n,width:r,height:i}=e,s=t+r/2,o=n+i/2;return{x:t,y:n,width:r,height:i,minX:t,minY:n,maxX:t+r,maxY:n+i,midX:s,midY:o,center:Hr(s,o)}}function Bb(e){let t=Hr(e.minX,e.minY),n=Hr(e.maxX,e.minY),r=Hr(e.maxX,e.maxY),i=Hr(e.minX,e.maxY);return{top:t,right:n,bottom:r,left:i}}function Gb(e,t){let n=Hb(e),{top:r,right:i,left:s,bottom:o}=Bb(n),[a]=t.split("-");return{top:[s,r,i,o],right:[r,i,o,s],bottom:[r,s,o,i],left:[i,r,s,o]}[a]}function Gu(e,t){let{x:n,y:r}=t,i=!1;for(let s=0,o=e.length-1;sr!=u>r&&n<(c-a)*(r-l)/(u-l)+a&&(i=!i)}return i}function zb(e,t){if(!e)return;let n=oe(e),r=new n.CustomEvent(zo,{detail:{value:t}});e.dispatchEvent(r)}function Qb(e,t){let{context:n,send:r,state:i,computed:s,prop:o,scope:a}=e,l=i.hasTag("open"),c=n.get("isSubmenu"),u=s("isTypingAhead"),h=o("composite"),p=n.get("currentPlacement"),d=n.get("anchorPoint"),g=n.get("highlightedValue"),v=Zt(y(m({},o("positioning")),{placement:d?"bottom":p}));function b(f){return{id:Br(a,f.value),disabled:!!f.disabled,highlighted:g===f.value}}function V(f){var I;let C=(I=f.valueText)!=null?I:f.value;return y(m({},f),{id:f.value,valueText:C})}function S(f){let C=b(V(f));return y(m({},C),{checked:!!f.checked})}function E(f){let{closeOnSelect:C,valueText:I,value:w}=f,A=b(f),P=Br(a,w);return t.element(y(m({},xe.item.attrs),{id:P,role:"menuitem","aria-disabled":re(A.disabled),"data-disabled":T(A.disabled),"data-ownedby":cr(a),"data-highlighted":T(A.highlighted),"data-value":w,"data-valuetext":I,onDragStart(N){N.currentTarget.matches("a[href]")&&N.preventDefault()},onPointerMove(N){if(A.disabled||N.pointerType!=="mouse")return;let R=N.currentTarget;if(A.highlighted)return;let L=Pt(N);r({type:"ITEM_POINTERMOVE",id:P,target:R,closeOnSelect:C,point:L})},onPointerLeave(N){var M;if(A.disabled||N.pointerType!=="mouse"||!((M=e.event.previous())==null?void 0:M.type.includes("POINTER")))return;let L=N.currentTarget;r({type:"ITEM_POINTERLEAVE",id:P,target:L,closeOnSelect:C})},onPointerDown(N){if(A.disabled)return;let R=N.currentTarget;r({type:"ITEM_POINTERDOWN",target:R,id:P,closeOnSelect:C})},onClick(N){if(Er(N)||sn(N)||A.disabled)return;let R=N.currentTarget;r({type:"ITEM_CLICK",target:R,id:P,closeOnSelect:C})}}))}return{highlightedValue:g,open:l,setOpen(f){i.hasTag("open")!==f&&r({type:f?"OPEN":"CLOSE"})},setHighlightedValue(f){r({type:"HIGHLIGHTED.SET",value:f})},setParent(f){r({type:"PARENT.SET",value:f,id:f.prop("id")})},setChild(f){r({type:"CHILD.SET",value:f,id:f.prop("id")})},reposition(f={}){r({type:"POSITIONING.SET",options:f})},addItemListener(f){let C=a.getById(f.id);if(!C)return;let I=()=>{var w;return(w=f.onSelect)==null?void 0:w.call(f)};return C.addEventListener(zo,I),()=>C.removeEventListener(zo,I)},getContextTriggerProps(){return t.element(y(m({},xe.contextTrigger.attrs),{dir:o("dir"),id:Uu(a),"data-state":l?"open":"closed",onPointerDown(f){if(f.pointerType==="mouse")return;let C=Pt(f);r({type:"CONTEXT_MENU_START",point:C})},onPointerCancel(f){f.pointerType!=="mouse"&&r({type:"CONTEXT_MENU_CANCEL"})},onPointerMove(f){f.pointerType!=="mouse"&&r({type:"CONTEXT_MENU_CANCEL"})},onPointerUp(f){f.pointerType!=="mouse"&&r({type:"CONTEXT_MENU_CANCEL"})},onContextMenu(f){let C=Pt(f);r({type:"CONTEXT_MENU",point:C}),f.preventDefault()},style:{WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"}}))},getTriggerItemProps(f){let C=f.getTriggerProps();return hl(E({value:C.id}),C)},getTriggerProps(){return t.button(y(m({},c?xe.triggerItem.attrs:xe.trigger.attrs),{"data-placement":n.get("currentPlacement"),type:"button",dir:o("dir"),id:cs(a),"data-uid":o("id"),"aria-haspopup":h?"menu":"dialog","aria-controls":cr(a),"data-controls":cr(a),"aria-expanded":l||void 0,"data-state":l?"open":"closed",onPointerMove(f){if(f.pointerType!=="mouse"||ls(f.currentTarget)||!c)return;let I=Pt(f);r({type:"TRIGGER_POINTERMOVE",target:f.currentTarget,point:I})},onPointerLeave(f){if(ls(f.currentTarget)||f.pointerType!=="mouse"||!c)return;let C=Pt(f);r({type:"TRIGGER_POINTERLEAVE",target:f.currentTarget,point:C})},onPointerDown(f){ls(f.currentTarget)||An(f)||f.preventDefault()},onClick(f){f.defaultPrevented||ls(f.currentTarget)||r({type:"TRIGGER_CLICK",target:f.currentTarget})},onBlur(){r({type:"TRIGGER_BLUR"})},onFocus(){r({type:"TRIGGER_FOCUS"})},onKeyDown(f){if(f.defaultPrevented)return;let C={ArrowDown(){r({type:"ARROW_DOWN"})},ArrowUp(){r({type:"ARROW_UP"})},Enter(){r({type:"ARROW_DOWN",src:"enter"})},Space(){r({type:"ARROW_DOWN",src:"space"})}},I=ve(f,{orientation:"vertical",dir:o("dir")}),w=C[I];w&&(f.preventDefault(),w(f))}}))},getIndicatorProps(){return t.element(y(m({},xe.indicator.attrs),{dir:o("dir"),"data-state":l?"open":"closed"}))},getPositionerProps(){return t.element(y(m({},xe.positioner.attrs),{dir:o("dir"),id:qu(a),style:v.floating}))},getArrowProps(){return t.element(y(m({id:qb(a)},xe.arrow.attrs),{dir:o("dir"),style:v.arrow}))},getArrowTipProps(){return t.element(y(m({},xe.arrowTip.attrs),{dir:o("dir"),style:v.arrowTip}))},getContentProps(){return t.element(y(m({},xe.content.attrs),{id:cr(a),"aria-label":o("aria-label"),hidden:!l,"data-state":l?"open":"closed",role:h?"menu":"dialog",tabIndex:0,dir:o("dir"),"aria-activedescendant":s("highlightedId")||void 0,"aria-labelledby":cs(a),"data-placement":p,onPointerEnter(f){f.pointerType==="mouse"&&r({type:"MENU_POINTERENTER"})},onKeyDown(f){if(f.defaultPrevented||!pe(f.currentTarget,K(f)))return;let C=K(f);if(!((C==null?void 0:C.closest("[role=menu]"))===f.currentTarget||C===f.currentTarget))return;if(f.key==="Tab"&&!gi(f)){f.preventDefault();return}let w={ArrowDown(){r({type:"ARROW_DOWN"})},ArrowUp(){r({type:"ARROW_UP"})},ArrowLeft(){r({type:"ARROW_LEFT"})},ArrowRight(){r({type:"ARROW_RIGHT"})},Enter(){r({type:"ENTER"})},Space(N){var R;u?r({type:"TYPEAHEAD",key:N.key}):(R=w.Enter)==null||R.call(w,N)},Home(){r({type:"HOME"})},End(){r({type:"END"})}},A=ve(f,{dir:o("dir")}),P=w[A];if(P){P(f),f.stopPropagation(),f.preventDefault();return}o("typeahead")&&Ba(f)&&(Fe(f)||Ut(C)||(r({type:"TYPEAHEAD",key:f.key}),f.preventDefault()))}}))},getSeparatorProps(){return t.element(y(m({},xe.separator.attrs),{role:"separator",dir:o("dir"),"aria-orientation":"horizontal"}))},getItemState:b,getItemProps:E,getOptionItemState:S,getOptionItemProps(f){let{type:C,disabled:I,closeOnSelect:w}=f,A=V(f),P=S(f);return m(m({},E(A)),t.element(y(m({"data-type":C},xe.item.attrs),{dir:o("dir"),"data-value":A.value,role:`menuitem${C}`,"aria-checked":!!P.checked,"data-state":P.checked?"checked":"unchecked",onClick(N){if(I||Er(N)||sn(N))return;let R=N.currentTarget;r({type:"ITEM_CLICK",target:R,option:A,closeOnSelect:w})}})))},getItemIndicatorProps(f){let C=S(Ys(f)),I=C.checked?"checked":"unchecked";return t.element(y(m({},xe.itemIndicator.attrs),{dir:o("dir"),"data-disabled":T(C.disabled),"data-highlighted":T(C.highlighted),"data-state":Me(f,"checked")?I:void 0,hidden:Me(f,"checked")?!C.checked:void 0}))},getItemTextProps(f){let C=S(Ys(f)),I=C.checked?"checked":"unchecked";return t.element(y(m({},xe.itemText.attrs),{dir:o("dir"),"data-disabled":T(C.disabled),"data-highlighted":T(C.highlighted),"data-state":Me(f,"checked")?I:void 0}))},getItemGroupLabelProps(f){return t.element(y(m({},xe.itemGroupLabel.attrs),{id:Mu(a,f.htmlFor),dir:o("dir")}))},getItemGroupProps(f){return t.element(y(m({id:Wb(a,f.id)},xe.itemGroup.attrs),{dir:o("dir"),"aria-labelledby":Mu(a,f.id),role:"group"}))}}}function Hu(e){let t=e.parent;for(;t&&t.context.get("isSubmenu");)t=t.refs.get("parent");t==null||t.send({type:"CLOSE"})}function nE(e,t){return e?Gu(e,t):!1}function rE(e,t,n){let r=Object.keys(e).length>0;if(!t)return null;if(!r)return Br(n,t);for(let i in e){let s=e[i],o=cs(s.scope);if(o===t)return o}return Br(n,t)}var Hr,HT,BT,GT,UT,qT,Ub,xe,cs,Uu,cr,qb,qu,Wb,Br,In,Mu,_t,$u,as,Kb,Jo,Gr,Yb,jb,Qo,Xb,Zb,Jb,ls,_u,zo,Je,lr,eE,tE,iE,WT,sE,KT,oE,YT,aE,jT,lE,XT,Bu,cE,Ku=fe(()=>{"use strict";Nr();gn();me();Hr=(e,t)=>({x:e,y:t});({min:HT,max:BT}=Math);({sign:GT,abs:UT,min:qT}=Math),Ub=Z("menu").parts("arrow","arrowTip","content","contextTrigger","indicator","item","itemGroup","itemGroupLabel","itemIndicator","itemText","positioner","separator","trigger","triggerItem"),xe=Ub.build(),cs=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`menu:${e.id}:trigger`},Uu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.contextTrigger)!=null?n:`menu:${e.id}:ctx-trigger`},cr=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`menu:${e.id}:content`},qb=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.arrow)!=null?n:`menu:${e.id}:arrow`},qu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.positioner)!=null?n:`menu:${e.id}:popper`},Wb=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.group)==null?void 0:r.call(n,t))!=null?i:`menu:${e.id}:group:${t}`},Br=(e,t)=>`${e.id}/${t}`,In=e=>{var t;return(t=e==null?void 0:e.dataset.value)!=null?t:null},Mu=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.groupLabel)==null?void 0:r.call(n,t))!=null?i:`menu:${e.id}:group-label:${t}`},_t=e=>e.getById(cr(e)),$u=e=>e.getById(qu(e)),as=e=>e.getById(cs(e)),Kb=(e,t)=>t?e.getById(Br(e,t)):null,Jo=e=>e.getById(Uu(e)),Gr=e=>{let n=`[role^="menuitem"][data-ownedby=${CSS.escape(cr(e))}]:not([data-disabled])`;return dt(_t(e),n)},Yb=e=>Ke(Gr(e)),jb=e=>nt(Gr(e)),Qo=(e,t)=>t?e.id===t||e.dataset.value===t:!1,Xb=(e,t)=>{var i;let n=Gr(e),r=n.findIndex(s=>Qo(s,t.value));return rl(n,r,{loop:(i=t.loop)!=null?i:t.loopFocus})},Zb=(e,t)=>{var i;let n=Gr(e),r=n.findIndex(s=>Qo(s,t.value));return il(n,r,{loop:(i=t.loop)!=null?i:t.loopFocus})},Jb=(e,t)=>{var i;let n=Gr(e),r=n.find(s=>Qo(s,t.value));return tt(n,{state:t.typeaheadState,key:t.key,activeId:(i=r==null?void 0:r.id)!=null?i:null})},ls=e=>ce(e)&&(e.dataset.disabled===""||e.hasAttribute("disabled")),_u=e=>{var t;return!!((t=e==null?void 0:e.getAttribute("role"))!=null&&t.startsWith("menuitem"))&&!!(e!=null&&e.hasAttribute("data-controls"))},zo="menu:select";({not:Je,and:lr,or:eE}=ye()),tE={props({props:e}){return y(m({closeOnSelect:!0,typeahead:!0,composite:!0,loopFocus:!1,navigate(t){Fn(t.node)}},e),{positioning:m({placement:"bottom-start",gutter:8},e.positioning)})},initialState({prop:e}){return e("open")||e("defaultOpen")?"open":"idle"},context({bindable:e,prop:t}){return{suspendPointer:e(()=>({defaultValue:!1})),highlightedValue:e(()=>({defaultValue:t("defaultHighlightedValue")||null,value:t("highlightedValue"),onChange(n){var r;(r=t("onHighlightChange"))==null||r({highlightedValue:n})}})),lastHighlightedValue:e(()=>({defaultValue:null})),currentPlacement:e(()=>({defaultValue:void 0})),intentPolygon:e(()=>({defaultValue:null})),anchorPoint:e(()=>({defaultValue:null,hash(n){return`x: ${n==null?void 0:n.x}, y: ${n==null?void 0:n.y}`}})),isSubmenu:e(()=>({defaultValue:!1}))}},refs(){return{parent:null,children:{},typeaheadState:m({},tt.defaultOptions),positioningOverride:{}}},computed:{isRtl:({prop:e})=>e("dir")==="rtl",isTypingAhead:({refs:e})=>e.get("typeaheadState").keysSoFar!=="",highlightedId:({context:e,scope:t,refs:n})=>rE(n.get("children"),e.get("highlightedValue"),t)},watch({track:e,action:t,context:n,prop:r}){e([()=>n.get("isSubmenu")],()=>{t(["setSubmenuPlacement"])}),e([()=>n.hash("anchorPoint")],()=>{n.get("anchorPoint")&&t(["reposition"])}),e([()=>r("open")],()=>{t(["toggleVisibility"])})},on:{"PARENT.SET":{actions:["setParentMenu"]},"CHILD.SET":{actions:["setChildMenu"]},OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}],OPEN_AUTOFOCUS:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["highlightFirstItem","invokeOnOpen"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],"HIGHLIGHTED.RESTORE":{actions:["restoreHighlightedItem"]},"HIGHLIGHTED.SET":{actions:["setHighlightedItem"]}},states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed"},CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}],TRIGGER_FOCUS:{guard:Je("isSubmenu"),target:"closed"},TRIGGER_POINTERMOVE:{guard:"isSubmenu",target:"opening"}}},"opening:contextmenu":{tags:["closed"],effects:["waitForLongPress"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed"},CONTEXT_MENU_CANCEL:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],"LONG_PRESS.OPEN":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}]}},opening:{tags:["closed"],effects:["waitForOpenDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed"},BLUR:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],TRIGGER_POINTERLEAVE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],"DELAY.OPEN":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}]}},closing:{tags:["open"],effects:["trackPointerMove","trackInteractOutside","waitForCloseDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]},MENU_POINTERENTER:{target:"open",actions:["clearIntentPolygon"]},POINTER_MOVED_AWAY_FROM_SUBMENU:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]}],"DELAY.CLOSE":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem","invokeOnClose"]}]}},closed:{tags:["closed"],entry:["clearHighlightedItem","focusTrigger","resumePointer","clearAnchorPoint"],on:{"CONTROLLED.OPEN":[{guard:eE("isOpenAutoFocusEvent","isArrowDownEvent"),target:"open",actions:["highlightFirstItem"]},{guard:"isArrowUpEvent",target:"open",actions:["highlightLastItem"]},{target:"open"}],CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",target:"opening"},TRIGGER_BLUR:{target:"idle"},ARROW_DOWN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["highlightFirstItem","invokeOnOpen"]}],ARROW_UP:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["highlightLastItem","invokeOnOpen"]}]}},open:{tags:["open"],effects:["trackInteractOutside","trackPositioning","scrollToHighlightedItem"],entry:["focusMenu","resumePointer"],on:{"CONTROLLED.CLOSE":[{target:"closed",guard:"isArrowLeftEvent",actions:["focusParentMenu"]},{target:"closed"}],TRIGGER_CLICK:[{guard:lr(Je("isTriggerItem"),"isOpenControlled"),actions:["invokeOnClose"]},{guard:Je("isTriggerItem"),target:"closed",actions:["invokeOnClose"]}],CONTEXT_MENU:{actions:["setAnchorPoint","focusMenu"]},ARROW_UP:{actions:["highlightPrevItem","focusMenu"]},ARROW_DOWN:{actions:["highlightNextItem","focusMenu"]},ARROW_LEFT:[{guard:lr("isSubmenu","isOpenControlled"),actions:["invokeOnClose"]},{guard:"isSubmenu",target:"closed",actions:["focusParentMenu","invokeOnClose"]}],HOME:{actions:["highlightFirstItem","focusMenu"]},END:{actions:["highlightLastItem","focusMenu"]},ARROW_RIGHT:{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},ENTER:[{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},{actions:["clickHighlightedItem"]}],ITEM_POINTERMOVE:[{guard:Je("isPointerSuspended"),actions:["setHighlightedItem","focusMenu","closeSiblingMenus"]},{actions:["setLastHighlightedItem","closeSiblingMenus"]}],ITEM_POINTERLEAVE:{guard:lr(Je("isPointerSuspended"),Je("isTriggerItem")),actions:["clearHighlightedItem"]},ITEM_CLICK:[{guard:lr(Je("isTriggerItemHighlighted"),Je("isHighlightedItemEditable"),"closeOnSelect","isOpenControlled"),actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose"]},{guard:lr(Je("isTriggerItemHighlighted"),Je("isHighlightedItemEditable"),"closeOnSelect"),target:"closed",actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose"]},{guard:lr(Je("isTriggerItemHighlighted"),Je("isHighlightedItemEditable")),actions:["invokeOnSelect","setOptionState"]},{actions:["setHighlightedItem"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",actions:["setIntentPolygon"]},TRIGGER_POINTERLEAVE:{target:"closing",actions:["setIntentPolygon"]},ITEM_POINTERDOWN:{actions:["setHighlightedItem"]},TYPEAHEAD:{actions:["highlightMatchedItem"]},FOCUS_MENU:{actions:["focusMenu"]},"POSITIONING.SET":{actions:["reposition"]}}}},implementations:{guards:{closeOnSelect:({prop:e,event:t})=>{var n;return!!((n=t==null?void 0:t.closeOnSelect)!=null?n:e("closeOnSelect"))},isTriggerItem:({event:e})=>_u(e.target),isTriggerItemHighlighted:({event:e,scope:t,computed:n})=>{var i;let r=(i=e.target)!=null?i:t.getById(n("highlightedId"));return!!(r!=null&&r.hasAttribute("data-controls"))},isSubmenu:({context:e})=>e.get("isSubmenu"),isPointerSuspended:({context:e})=>e.get("suspendPointer"),isHighlightedItemEditable:({scope:e,computed:t})=>Ut(e.getById(t("highlightedId"))),isOpenControlled:({prop:e})=>e("open")!==void 0,isArrowLeftEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="ARROW_LEFT"},isArrowUpEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="ARROW_UP"},isArrowDownEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="ARROW_DOWN"},isOpenAutoFocusEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="OPEN_AUTOFOCUS"}},effects:{waitForOpenDelay({send:e}){let t=setTimeout(()=>{e({type:"DELAY.OPEN"})},200);return()=>clearTimeout(t)},waitForCloseDelay({send:e}){let t=setTimeout(()=>{e({type:"DELAY.CLOSE"})},100);return()=>clearTimeout(t)},waitForLongPress({send:e}){let t=setTimeout(()=>{e({type:"LONG_PRESS.OPEN"})},700);return()=>clearTimeout(t)},trackPositioning({context:e,prop:t,scope:n,refs:r}){if(Jo(n))return;let i=m(m({},t("positioning")),r.get("positioningOverride"));e.set("currentPlacement",i.placement);let s=()=>$u(n);return at(as(n),s,y(m({},i),{defer:!0,onComplete(o){e.set("currentPlacement",o.placement)}}))},trackInteractOutside({refs:e,scope:t,prop:n,context:r,send:i}){let s=()=>_t(t),o=!0;return vt(s,{type:"menu",defer:!0,exclude:[as(t)],onInteractOutside:n("onInteractOutside"),onRequestDismiss:n("onRequestDismiss"),onFocusOutside(a){var u;(u=n("onFocusOutside"))==null||u(a);let l=K(a.detail.originalEvent);if(pe(Jo(t),l)){a.preventDefault();return}},onEscapeKeyDown(a){var l;(l=n("onEscapeKeyDown"))==null||l(a),r.get("isSubmenu")&&a.preventDefault(),Hu({parent:e.get("parent")})},onPointerDownOutside(a){var u;(u=n("onPointerDownOutside"))==null||u(a);let l=K(a.detail.originalEvent);if(pe(Jo(t),l)&&a.detail.contextmenu){a.preventDefault();return}o=!a.detail.focusable},onDismiss(){i({type:"CLOSE",src:"interact-outside",restoreFocus:o})}})},trackPointerMove({context:e,scope:t,send:n,refs:r,flush:i}){let s=r.get("parent");i(()=>{s.context.set("suspendPointer",!0)});let o=t.getDoc();return ie(o,"pointermove",a=>{nE(e.get("intentPolygon"),{x:a.clientX,y:a.clientY})||(n({type:"POINTER_MOVED_AWAY_FROM_SUBMENU"}),s.context.set("suspendPointer",!1))})},scrollToHighlightedItem({event:e,scope:t,computed:n}){let r=()=>{if(e.current().type.startsWith("ITEM_POINTER"))return;let s=t.getById(n("highlightedId")),o=_t(t);ln(s,{rootEl:o,block:"nearest"})};return H(()=>r()),Ln(()=>_t(t),{defer:!0,attributes:["aria-activedescendant"],callback:r})}},actions:{setAnchorPoint({context:e,event:t}){e.set("anchorPoint",n=>he(n,t.point)?n:t.point)},setSubmenuPlacement({context:e,computed:t,refs:n}){if(!e.get("isSubmenu"))return;let r=t("isRtl")?"left-start":"right-start";n.set("positioningOverride",{placement:r,gutter:0})},reposition({context:e,scope:t,prop:n,event:r,refs:i}){var c;let s=()=>$u(t),o=e.get("anchorPoint"),a=o?()=>m({width:0,height:0},o):void 0,l=m(m({},n("positioning")),i.get("positioningOverride"));at(as(t),s,y(m(y(m({},l),{defer:!0,getAnchorRect:a}),(c=r.options)!=null?c:{}),{listeners:!1,onComplete(u){e.set("currentPlacement",u.placement)}}))},setOptionState({event:e}){if(!e.option)return;let{checked:t,onCheckedChange:n,type:r}=e.option;r==="radio"?n==null||n(!0):r==="checkbox"&&(n==null||n(!t))},clickHighlightedItem({scope:e,computed:t,prop:n,context:r}){var o;let i=e.getById(t("highlightedId"));if(!i||i.dataset.disabled)return;let s=r.get("highlightedValue");We(i)?(o=n("navigate"))==null||o({value:s,node:i,href:i.href}):queueMicrotask(()=>i.click())},setIntentPolygon({context:e,scope:t,event:n}){let r=_t(t),i=e.get("currentPlacement");if(!r||!i)return;let s=r.getBoundingClientRect(),o=Gb(s,i);if(!o)return;let l=ac(i)==="right"?-5:5;e.set("intentPolygon",[y(m({},n.point),{x:n.point.x+l}),...o])},clearIntentPolygon({context:e}){e.set("intentPolygon",null)},clearAnchorPoint({context:e}){e.set("anchorPoint",null)},resumePointer({refs:e,flush:t}){let n=e.get("parent");n&&t(()=>{n.context.set("suspendPointer",!1)})},setHighlightedItem({context:e,event:t}){let n=t.value||In(t.target);e.set("highlightedValue",n)},clearHighlightedItem({context:e}){e.set("highlightedValue",null)},focusMenu({scope:e}){H(()=>{let t=_t(e),n=hi({root:t,enabled:!pe(t,e.getActiveElement()),filter(r){var i;return!((i=r.role)!=null&&i.startsWith("menuitem"))}});n==null||n.focus({preventScroll:!0})})},highlightFirstItem({context:e,scope:t}){(_t(t)?queueMicrotask:H)(()=>{let r=Yb(t);r&&e.set("highlightedValue",In(r))})},highlightLastItem({context:e,scope:t}){(_t(t)?queueMicrotask:H)(()=>{let r=jb(t);r&&e.set("highlightedValue",In(r))})},highlightNextItem({context:e,scope:t,event:n,prop:r}){let i=Xb(t,{loop:n.loop,value:e.get("highlightedValue"),loopFocus:r("loopFocus")});e.set("highlightedValue",In(i))},highlightPrevItem({context:e,scope:t,event:n,prop:r}){let i=Zb(t,{loop:n.loop,value:e.get("highlightedValue"),loopFocus:r("loopFocus")});e.set("highlightedValue",In(i))},invokeOnSelect({context:e,prop:t,scope:n}){var s;let r=e.get("highlightedValue");if(r==null)return;let i=Kb(n,r);zb(i,r),(s=t("onSelect"))==null||s({value:r})},focusTrigger({scope:e,context:t,event:n}){t.get("isSubmenu")||t.get("anchorPoint")||n.restoreFocus===!1||queueMicrotask(()=>{var r;return(r=as(e))==null?void 0:r.focus({preventScroll:!0})})},highlightMatchedItem({scope:e,context:t,event:n,refs:r}){let i=Jb(e,{key:n.key,value:t.get("highlightedValue"),typeaheadState:r.get("typeaheadState")});i&&t.set("highlightedValue",In(i))},setParentMenu({refs:e,event:t,context:n}){e.set("parent",t.value),n.set("isSubmenu",!0)},setChildMenu({refs:e,event:t}){let n=e.get("children");n[t.id]=t.value,e.set("children",n)},closeSiblingMenus({refs:e,event:t,scope:n}){var o;let r=t.target;if(!_u(r))return;let i=r==null?void 0:r.getAttribute("data-uid"),s=e.get("children");for(let a in s){if(a===i)continue;let l=s[a],c=l.context.get("intentPolygon");c&&t.point&&Gu(c,t.point)||((o=_t(n))==null||o.focus({preventScroll:!0}),l.send({type:"CLOSE"}))}},closeRootMenu({refs:e}){Hu({parent:e.get("parent")})},openSubmenu({refs:e,scope:t,computed:n}){let r=t.getById(n("highlightedId")),i=r==null?void 0:r.getAttribute("data-uid"),s=e.get("children"),o=i?s[i]:null;o==null||o.send({type:"OPEN_AUTOFOCUS"})},focusParentMenu({refs:e}){var t;(t=e.get("parent"))==null||t.send({type:"FOCUS_MENU"})},setLastHighlightedItem({context:e,event:t}){e.set("lastHighlightedValue",In(t.target))},restoreHighlightedItem({context:e}){e.get("lastHighlightedValue")&&(e.set("highlightedValue",e.get("lastHighlightedValue")),e.set("lastHighlightedValue",null))},restoreParentHighlightedItem({refs:e}){var t;(t=e.get("parent"))==null||t.send({type:"HIGHLIGHTED.RESTORE"})},invokeOnOpen({prop:e}){var t;(t=e("onOpenChange"))==null||t({open:!0})},invokeOnClose({prop:e}){var t;(t=e("onOpenChange"))==null||t({open:!1})},toggleVisibility({prop:e,event:t,send:n}){n({type:e("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:t})}}}};iE=G()(["anchorPoint","aria-label","closeOnSelect","composite","defaultHighlightedValue","defaultOpen","dir","getRootNode","highlightedValue","id","ids","loopFocus","navigate","onEscapeKeyDown","onFocusOutside","onHighlightChange","onInteractOutside","onOpenChange","onPointerDownOutside","onRequestDismiss","onSelect","open","positioning","typeahead"]),WT=B(iE),sE=G()(["closeOnSelect","disabled","value","valueText"]),KT=B(sE),oE=G()(["htmlFor"]),YT=B(oE),aE=G()(["id"]),jT=B(aE),lE=G()(["checked","closeOnSelect","disabled","onCheckedChange","type","value","valueText"]),XT=B(lE),Bu=class extends te{constructor(){super(...arguments);U(this,"children",[])}initMachine(t){return new ee(tE,t)}initApi(){return Qb(this.machine.service,Q)}setChild(t){this.api.setChild(t.machine.service),this.children.includes(t)||this.children.push(t)}setParent(t){this.api.setParent(t.machine.service)}isOwnElement(t){return t.closest('[phx-hook="Menu"]')===this.el}renderSubmenuTriggers(){let t=this.el.querySelector('[data-scope="menu"][data-part="content"]');if(!t)return;let n=t.querySelectorAll('[data-scope="menu"][data-nested-menu]');for(let r of n){if(!this.isOwnElement(r))continue;let i=r.dataset.nestedMenu;if(!i)continue;let s=this.children.find(a=>a.el.id===`menu:${i}`);if(!s)continue;let o=()=>{let a=this.api.getTriggerItemProps(s.api);this.spreadProps(r,a)};o(),this.machine.subscribe(o),s.machine.subscribe(o)}}render(){let t=this.el.querySelector('[data-scope="menu"][data-part="trigger"]');t&&this.spreadProps(t,this.api.getTriggerProps());let n=this.el.querySelector('[data-scope="menu"][data-part="positioner"]'),r=this.el.querySelector('[data-scope="menu"][data-part="content"]');n&&r&&(this.spreadProps(n,this.api.getPositionerProps()),this.spreadProps(r,this.api.getContentProps()),n.hidden=!this.api.open,this.api.open&&(r.querySelectorAll('[data-scope="menu"][data-part="item"]').forEach(c=>{if(!this.isOwnElement(c))return;let u=c.dataset.value;if(u){let h=c.hasAttribute("data-disabled");this.spreadProps(c,this.api.getItemProps({value:u,disabled:h||void 0}))}}),r.querySelectorAll('[data-scope="menu"][data-part="option-item"]').forEach(c=>{if(!this.isOwnElement(c))return;let u=c.dataset.value,h=c.dataset.type;if(u&&h){let p=c.hasAttribute("data-checked"),d=c.hasAttribute("data-disabled");this.spreadProps(c,this.api.getOptionItemProps({value:u,type:h,checked:p,disabled:d||void 0}))}}),r.querySelectorAll('[data-scope="menu"][data-part="item-group"]').forEach(c=>{if(!this.isOwnElement(c))return;let u=c.id;u&&this.spreadProps(c,this.api.getItemGroupProps({id:u}))}),r.querySelectorAll('[data-scope="menu"][data-part="separator"]').forEach(c=>{this.isOwnElement(c)&&this.spreadProps(c,this.api.getSeparatorProps())})));let i=this.el.querySelector('[data-scope="menu"][data-part="indicator"]');i&&this.spreadProps(i,this.api.getIndicatorProps())}},cE={mounted(){let e=this.el;if(e.hasAttribute("data-nested"))return;let t=new Bu(e,y(m({id:e.id.replace("menu:","")},O(e,"controlled")?{open:O(e,"open")}:{defaultOpen:O(e,"defaultOpen")}),{closeOnSelect:O(e,"closeOnSelect"),loopFocus:O(e,"loopFocus"),typeahead:O(e,"typeahead"),composite:O(e,"composite"),dir:x(e,"dir",["ltr","rtl"]),onSelect:i=>{var p,d;let s=O(e,"redirect"),o=[...e.querySelectorAll('[data-scope="menu"][data-part="item"]')].find(g=>g.getAttribute("data-value")===i.value),a=o==null?void 0:o.getAttribute("data-redirect"),l=o==null?void 0:o.hasAttribute("data-new-tab");s&&i.value&&!this.liveSocket.main.isConnected()&&a!=="false"&&(l?window.open(i.value,"_blank","noopener,noreferrer"):window.location.href=i.value);let u=x(e,"onSelect");u&&this.liveSocket.main.isConnected()&&this.pushEvent(u,{id:e.id,value:(p=i.value)!=null?p:null});let h=x(e,"onSelectClient");h&&e.dispatchEvent(new CustomEvent(h,{bubbles:!0,detail:{id:e.id,value:(d=i.value)!=null?d:null}}))},onOpenChange:i=>{var a,l;let s=x(e,"onOpenChange");s&&this.liveSocket.main.isConnected()&&this.pushEvent(s,{id:e.id,open:(a=i.open)!=null?a:!1});let o=x(e,"onOpenChangeClient");o&&e.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:{id:e.id,open:(l=i.open)!=null?l:!1}}))}}));t.init(),this.menu=t,this.nestedMenus=new Map;let n=e.querySelectorAll('[data-scope="menu"][data-nested="menu"]'),r=[];n.forEach(i=>{var o;let s=i.id;if(s){let a=s.replace("menu:",""),l=new Bu(i,{id:a,dir:x(i,"dir",["ltr","rtl"]),closeOnSelect:O(i,"closeOnSelect"),loopFocus:O(i,"loopFocus"),typeahead:O(i,"typeahead"),composite:O(i,"composite")});l.init(),(o=this.nestedMenus)==null||o.set(s,l),r.push(l)}}),setTimeout(()=>{r.forEach(i=>{this.menu&&(this.menu.setChild(i),i.setParent(this.menu))}),this.menu&&(this.menu.api=this.menu.initApi(),this.menu.render()),r.forEach(i=>{i.api=i.initApi(),i.render()}),this.menu&&this.menu.children.length>0&&this.menu.renderSubmenuTriggers()},0),this.onSetOpen=i=>{let{open:s}=i.detail;t.api.setOpen(s)},e.addEventListener("phx:menu:set-open",this.onSetOpen),this.handlers=[],this.handlers.push(this.handleEvent("menu_set_open",i=>{let s=i.menu_id;s&&s!==e.id||t.api.setOpen(i.open)})),this.handlers.push(this.handleEvent("menu_open",()=>{this.pushEvent("menu_open_response",{open:t.api.open})}))},updated(){var e;this.el.hasAttribute("data-nested")||(e=this.menu)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{open:O(this.el,"open")}:{defaultOpen:O(this.el,"defaultOpen")}),{closeOnSelect:O(this.el,"closeOnSelect"),loopFocus:O(this.el,"loopFocus"),typeahead:O(this.el,"typeahead"),composite:O(this.el,"composite"),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(!this.el.hasAttribute("data-nested")){if(this.onSetOpen&&this.el.removeEventListener("phx:menu:set-open",this.onSetOpen),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);if(this.nestedMenus)for(let[,t]of this.nestedMenus)t.destroy();(e=this.menu)==null||e.destroy()}}}});var zu={};Oe(zu,{Select:()=>SE});function pE(e,t){let{context:n,prop:r,scope:i,state:s,computed:o,send:a}=e,l=r("disabled")||n.get("fieldsetDisabled"),c=!!r("invalid"),u=!!r("required"),h=!!r("readOnly"),p=r("composite"),d=r("collection"),g=s.hasTag("open"),v=s.matches("focused"),b=n.get("highlightedValue"),V=n.get("highlightedItem"),S=n.get("selectedItems"),E=n.get("currentPlacement"),f=o("isTypingAhead"),C=o("isInteractive"),I=b?ia(i,b):void 0;function w(P){let N=d.getItemDisabled(P.item),R=d.getItemValue(P.item);return qn(R,()=>`[zag-js] No value found for item ${JSON.stringify(P.item)}`),{value:R,disabled:!!(l||N),highlighted:b===R,selected:n.get("value").includes(R)}}let A=Zt(y(m({},r("positioning")),{placement:E}));return{open:g,focused:v,empty:n.get("value").length===0,highlightedItem:V,highlightedValue:b,selectedItems:S,hasSelectedItems:o("hasSelectedItems"),value:n.get("value"),valueAsString:o("valueAsString"),collection:d,multiple:!!r("multiple"),disabled:!!l,reposition(P={}){a({type:"POSITIONING.SET",options:P})},focus(){var P;(P=On(i))==null||P.focus({preventScroll:!0})},setOpen(P){s.hasTag("open")!==P&&a({type:P?"OPEN":"CLOSE"})},selectValue(P){a({type:"ITEM.SELECT",value:P})},setValue(P){a({type:"VALUE.SET",value:P})},selectAll(){a({type:"VALUE.SET",value:d.getValues()})},setHighlightValue(P){a({type:"HIGHLIGHTED_VALUE.SET",value:P})},clearHighlightValue(){a({type:"HIGHLIGHTED_VALUE.CLEAR"})},clearValue(P){a(P?{type:"ITEM.CLEAR",value:P}:{type:"VALUE.CLEAR"})},getItemState:w,getRootProps(){return t.element(y(m({},ke.root.attrs),{dir:r("dir"),id:dE(i),"data-invalid":T(c),"data-readonly":T(h)}))},getLabelProps(){return t.label(y(m({dir:r("dir"),id:us(i)},ke.label.attrs),{"data-disabled":T(l),"data-invalid":T(c),"data-readonly":T(h),"data-required":T(u),htmlFor:sa(i),onClick(P){var N;P.defaultPrevented||l||(N=On(i))==null||N.focus({preventScroll:!0})}}))},getControlProps(){return t.element(y(m({},ke.control.attrs),{dir:r("dir"),id:hE(i),"data-state":g?"open":"closed","data-focus":T(v),"data-disabled":T(l),"data-invalid":T(c)}))},getValueTextProps(){return t.element(y(m({},ke.valueText.attrs),{dir:r("dir"),"data-disabled":T(l),"data-invalid":T(c),"data-focus":T(v)}))},getTriggerProps(){return t.button(y(m({id:ra(i),disabled:l,dir:r("dir"),type:"button",role:"combobox","aria-controls":na(i),"aria-expanded":g,"aria-haspopup":"listbox","data-state":g?"open":"closed","aria-invalid":c,"aria-required":u,"aria-labelledby":us(i)},ke.trigger.attrs),{"data-disabled":T(l),"data-invalid":T(c),"data-readonly":T(h),"data-placement":E,"data-placeholder-shown":T(!o("hasSelectedItems")),onClick(P){C&&(P.defaultPrevented||a({type:"TRIGGER.CLICK"}))},onFocus(){a({type:"TRIGGER.FOCUS"})},onBlur(){a({type:"TRIGGER.BLUR"})},onKeyDown(P){if(P.defaultPrevented||!C)return;let R={ArrowUp(){a({type:"TRIGGER.ARROW_UP"})},ArrowDown(L){a({type:L.altKey?"OPEN":"TRIGGER.ARROW_DOWN"})},ArrowLeft(){a({type:"TRIGGER.ARROW_LEFT"})},ArrowRight(){a({type:"TRIGGER.ARROW_RIGHT"})},Home(){a({type:"TRIGGER.HOME"})},End(){a({type:"TRIGGER.END"})},Enter(){a({type:"TRIGGER.ENTER"})},Space(L){a(f?{type:"TRIGGER.TYPEAHEAD",key:L.key}:{type:"TRIGGER.ENTER"})}}[ve(P,{dir:r("dir"),orientation:"vertical"})];if(R){R(P),P.preventDefault();return}tt.isValidEvent(P)&&(a({type:"TRIGGER.TYPEAHEAD",key:P.key}),P.preventDefault())}}))},getIndicatorProps(){return t.element(y(m({},ke.indicator.attrs),{dir:r("dir"),"aria-hidden":!0,"data-state":g?"open":"closed","data-disabled":T(l),"data-invalid":T(c),"data-readonly":T(h)}))},getItemProps(P){let N=w(P);return t.element(y(m({id:ia(i,N.value),role:"option"},ke.item.attrs),{dir:r("dir"),"data-value":N.value,"aria-selected":N.selected,"data-state":N.selected?"checked":"unchecked","data-highlighted":T(N.highlighted),"data-disabled":T(N.disabled),"aria-disabled":re(N.disabled),onPointerMove(R){N.disabled||R.pointerType!=="mouse"||N.value!==b&&a({type:"ITEM.POINTER_MOVE",value:N.value})},onClick(R){R.defaultPrevented||N.disabled||a({type:"ITEM.CLICK",src:"pointerup",value:N.value})},onPointerLeave(R){var M;N.disabled||P.persistFocus||R.pointerType!=="mouse"||!((M=e.event.previous())!=null&&M.type.includes("POINTER"))||a({type:"ITEM.POINTER_LEAVE"})}}))},getItemTextProps(P){let N=w(P);return t.element(y(m({},ke.itemText.attrs),{"data-state":N.selected?"checked":"unchecked","data-disabled":T(N.disabled),"data-highlighted":T(N.highlighted)}))},getItemIndicatorProps(P){let N=w(P);return t.element(y(m({"aria-hidden":!0},ke.itemIndicator.attrs),{"data-state":N.selected?"checked":"unchecked",hidden:!N.selected}))},getItemGroupLabelProps(P){let{htmlFor:N}=P;return t.element(y(m({},ke.itemGroupLabel.attrs),{id:Yu(i,N),dir:r("dir"),role:"presentation"}))},getItemGroupProps(P){let{id:N}=P;return t.element(y(m({},ke.itemGroup.attrs),{"data-disabled":T(l),id:gE(i,N),"aria-labelledby":Yu(i,N),role:"group",dir:r("dir")}))},getClearTriggerProps(){return t.button(y(m({},ke.clearTrigger.attrs),{id:Zu(i),type:"button","aria-label":"Clear value","data-invalid":T(c),disabled:l,hidden:!o("hasSelectedItems"),dir:r("dir"),onClick(P){P.defaultPrevented||a({type:"CLEAR.CLICK"})}}))},getHiddenSelectProps(){let P=n.get("value"),N=r("multiple")?P:P==null?void 0:P[0];return t.select({name:r("name"),form:r("form"),disabled:l,multiple:r("multiple"),required:r("required"),"aria-hidden":!0,id:sa(i),defaultValue:N,style:Hn,tabIndex:-1,onFocus(){var R;(R=On(i))==null||R.focus({preventScroll:!0})},"aria-labelledby":us(i)})},getPositionerProps(){return t.element(y(m({},ke.positioner.attrs),{dir:r("dir"),id:Ju(i),style:A.floating}))},getContentProps(){return t.element(y(m({hidden:!g,dir:r("dir"),id:na(i),role:p?"listbox":"dialog"},ke.content.attrs),{"data-state":g?"open":"closed","data-placement":E,"data-activedescendant":I,"aria-activedescendant":p?I:void 0,"aria-multiselectable":r("multiple")&&p?!0:void 0,"aria-labelledby":us(i),tabIndex:0,onKeyDown(P){if(!C||!pe(P.currentTarget,K(P)))return;if(P.key==="Tab"&&!gi(P)){P.preventDefault();return}let N={ArrowUp(){a({type:"CONTENT.ARROW_UP"})},ArrowDown(){a({type:"CONTENT.ARROW_DOWN"})},Home(){a({type:"CONTENT.HOME"})},End(){a({type:"CONTENT.END"})},Enter(){a({type:"ITEM.CLICK",src:"keydown.enter"})},Space(M){var j;f?a({type:"CONTENT.TYPEAHEAD",key:M.key}):(j=N.Enter)==null||j.call(N,M)}},R=N[ve(P)];if(R){R(P),P.preventDefault();return}let L=K(P);Ut(L)||tt.isValidEvent(P)&&(a({type:"CONTENT.TYPEAHEAD",key:P.key}),P.preventDefault())}}))},getListProps(){return t.element(y(m({},ke.list.attrs),{tabIndex:0,role:p?void 0:"listbox","aria-labelledby":ra(i),"aria-activedescendant":p?void 0:I,"aria-multiselectable":!p&&r("multiple")?!0:void 0}))}}}function Xu(e){var n,r;let t=(r=e.restoreFocus)!=null?r:(n=e.previousEvent)==null?void 0:n.restoreFocus;return t==null||!!t}function TE(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function OE(e){let t={};for(let[n,r]of Object.entries(e)){let i=TE(n);t[i]=r}return t}var uE,ke,ds,dE,na,ra,Zu,us,hE,ia,sa,Ju,gE,Yu,ea,Ur,On,fE,ju,ta,qr,Tn,mE,vE,yE,nO,bE,rO,EE,iO,CE,sO,IE,SE,Qu=fe(()=>{"use strict";Ai();Nr();gn();me();uE=Z("select").parts("label","positioner","trigger","indicator","clearTrigger","item","itemText","itemIndicator","itemGroup","itemGroupLabel","list","content","root","control","valueText"),ke=uE.build(),ds=e=>new Xn(e);ds.empty=()=>new Xn({items:[]});dE=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`select:${e.id}`},na=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`select:${e.id}:content`},ra=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`select:${e.id}:trigger`},Zu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.clearTrigger)!=null?n:`select:${e.id}:clear-trigger`},us=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`select:${e.id}:label`},hE=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`select:${e.id}:control`},ia=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.item)==null?void 0:r.call(n,t))!=null?i:`select:${e.id}:option:${t}`},sa=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.hiddenSelect)!=null?n:`select:${e.id}:select`},Ju=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.positioner)!=null?n:`select:${e.id}:positioner`},gE=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemGroup)==null?void 0:r.call(n,t))!=null?i:`select:${e.id}:optgroup:${t}`},Yu=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemGroupLabel)==null?void 0:r.call(n,t))!=null?i:`select:${e.id}:optgroup-label:${t}`},ea=e=>e.getById(sa(e)),Ur=e=>e.getById(na(e)),On=e=>e.getById(ra(e)),fE=e=>e.getById(Zu(e)),ju=e=>e.getById(Ju(e)),ta=(e,t)=>t==null?null:e.getById(ia(e,t));({and:qr,not:Tn,or:mE}=ye()),vE={props({props:e}){var t;return y(m({loopFocus:!1,closeOnSelect:!e.multiple,composite:!0,defaultValue:[]},e),{collection:(t=e.collection)!=null?t:ds.empty(),positioning:m({placement:"bottom-start",gutter:8},e.positioning)})},context({prop:e,bindable:t}){return{value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),isEqual:he,onChange(n){var i;let r=e("collection").findMany(n);return(i=e("onValueChange"))==null?void 0:i({value:n,items:r})}})),highlightedValue:t(()=>({defaultValue:e("defaultHighlightedValue")||null,value:e("highlightedValue"),onChange(n){var r;(r=e("onHighlightChange"))==null||r({highlightedValue:n,highlightedItem:e("collection").find(n),highlightedIndex:e("collection").indexOf(n)})}})),currentPlacement:t(()=>({defaultValue:void 0})),fieldsetDisabled:t(()=>({defaultValue:!1})),highlightedItem:t(()=>({defaultValue:null})),selectedItems:t(()=>{var i,s;let n=(s=(i=e("value"))!=null?i:e("defaultValue"))!=null?s:[];return{defaultValue:e("collection").findMany(n)}})}},refs(){return{typeahead:m({},tt.defaultOptions)}},computed:{hasSelectedItems:({context:e})=>e.get("value").length>0,isTypingAhead:({refs:e})=>e.get("typeahead").keysSoFar!=="",isDisabled:({prop:e,context:t})=>!!e("disabled")||!!t.get("fieldsetDisabled"),isInteractive:({prop:e})=>!(e("disabled")||e("readOnly")),valueAsString:({context:e,prop:t})=>t("collection").stringifyItems(e.get("selectedItems"))},initialState({prop:e}){return e("open")||e("defaultOpen")?"open":"idle"},entry:["syncSelectElement"],watch({context:e,prop:t,track:n,action:r}){n([()=>e.get("value").toString()],()=>{r(["syncSelectedItems","syncSelectElement","dispatchChangeEvent"])}),n([()=>t("open")],()=>{r(["toggleVisibility"])}),n([()=>e.get("highlightedValue")],()=>{r(["syncHighlightedItem"])}),n([()=>t("collection").toString()],()=>{r(["syncCollection"])})},on:{"HIGHLIGHTED_VALUE.SET":{actions:["setHighlightedItem"]},"HIGHLIGHTED_VALUE.CLEAR":{actions:["clearHighlightedItem"]},"ITEM.SELECT":{actions:["selectItem"]},"ITEM.CLEAR":{actions:["clearItem"]},"VALUE.SET":{actions:["setSelectedItems"]},"VALUE.CLEAR":{actions:["clearSelectedItems"]},"CLEAR.CLICK":{actions:["clearSelectedItems","focusTriggerEl"]}},effects:["trackFormControlState"],states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":[{guard:"isTriggerClickEvent",target:"open",actions:["setInitialFocus","highlightFirstSelectedItem"]},{target:"open",actions:["setInitialFocus"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen","setInitialFocus","highlightFirstSelectedItem"]}],"TRIGGER.FOCUS":{target:"focused"},OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen"]}]}},focused:{tags:["closed"],on:{"CONTROLLED.OPEN":[{guard:"isTriggerClickEvent",target:"open",actions:["setInitialFocus","highlightFirstSelectedItem"]},{guard:"isTriggerArrowUpEvent",target:"open",actions:["setInitialFocus","highlightComputedLastItem"]},{guard:mE("isTriggerArrowDownEvent","isTriggerEnterEvent"),target:"open",actions:["setInitialFocus","highlightComputedFirstItem"]},{target:"open",actions:["setInitialFocus"]}],OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen"]}],"TRIGGER.BLUR":{target:"idle"},"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen","highlightFirstSelectedItem"]}],"TRIGGER.ENTER":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen","highlightComputedFirstItem"]}],"TRIGGER.ARROW_UP":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen","highlightComputedLastItem"]}],"TRIGGER.ARROW_DOWN":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen","highlightComputedFirstItem"]}],"TRIGGER.ARROW_LEFT":[{guard:qr(Tn("multiple"),"hasSelectedItems"),actions:["selectPreviousItem"]},{guard:Tn("multiple"),actions:["selectLastItem"]}],"TRIGGER.ARROW_RIGHT":[{guard:qr(Tn("multiple"),"hasSelectedItems"),actions:["selectNextItem"]},{guard:Tn("multiple"),actions:["selectFirstItem"]}],"TRIGGER.HOME":{guard:Tn("multiple"),actions:["selectFirstItem"]},"TRIGGER.END":{guard:Tn("multiple"),actions:["selectLastItem"]},"TRIGGER.TYPEAHEAD":{guard:Tn("multiple"),actions:["selectMatchingItem"]}}},open:{tags:["open"],exit:["scrollContentToTop"],effects:["trackDismissableElement","computePlacement","scrollToHighlightedItem"],on:{"CONTROLLED.CLOSE":[{guard:"restoreFocus",target:"focused",actions:["focusTriggerEl","clearHighlightedItem"]},{target:"idle",actions:["clearHighlightedItem"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{guard:"restoreFocus",target:"focused",actions:["invokeOnClose","focusTriggerEl","clearHighlightedItem"]},{target:"idle",actions:["invokeOnClose","clearHighlightedItem"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose","clearHighlightedItem"]}],"ITEM.CLICK":[{guard:qr("closeOnSelect","isOpenControlled"),actions:["selectHighlightedItem","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectHighlightedItem","invokeOnClose","focusTriggerEl","clearHighlightedItem"]},{actions:["selectHighlightedItem"]}],"CONTENT.HOME":{actions:["highlightFirstItem"]},"CONTENT.END":{actions:["highlightLastItem"]},"CONTENT.ARROW_DOWN":[{guard:qr("hasHighlightedItem","loop","isLastItemHighlighted"),actions:["highlightFirstItem"]},{guard:"hasHighlightedItem",actions:["highlightNextItem"]},{actions:["highlightFirstItem"]}],"CONTENT.ARROW_UP":[{guard:qr("hasHighlightedItem","loop","isFirstItemHighlighted"),actions:["highlightLastItem"]},{guard:"hasHighlightedItem",actions:["highlightPreviousItem"]},{actions:["highlightLastItem"]}],"CONTENT.TYPEAHEAD":{actions:["highlightMatchingItem"]},"ITEM.POINTER_MOVE":{actions:["highlightItem"]},"ITEM.POINTER_LEAVE":{actions:["clearHighlightedItem"]},"POSITIONING.SET":{actions:["reposition"]}}}},implementations:{guards:{loop:({prop:e})=>!!e("loopFocus"),multiple:({prop:e})=>!!e("multiple"),hasSelectedItems:({computed:e})=>!!e("hasSelectedItems"),hasHighlightedItem:({context:e})=>e.get("highlightedValue")!=null,isFirstItemHighlighted:({context:e,prop:t})=>e.get("highlightedValue")===t("collection").firstValue,isLastItemHighlighted:({context:e,prop:t})=>e.get("highlightedValue")===t("collection").lastValue,closeOnSelect:({prop:e,event:t})=>{var n;return!!((n=t.closeOnSelect)!=null?n:e("closeOnSelect"))},restoreFocus:({event:e})=>Xu(e),isOpenControlled:({prop:e})=>e("open")!==void 0,isTriggerClickEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="TRIGGER.CLICK"},isTriggerEnterEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="TRIGGER.ENTER"},isTriggerArrowUpEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="TRIGGER.ARROW_UP"},isTriggerArrowDownEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="TRIGGER.ARROW_DOWN"}},effects:{trackFormControlState({context:e,scope:t}){return Rn(ea(t),{onFieldsetDisabledChange(n){e.set("fieldsetDisabled",n)},onFormReset(){let n=e.initial("value");e.set("value",n)}})},trackDismissableElement({scope:e,send:t,prop:n}){let r=()=>Ur(e),i=!0;return vt(r,{type:"listbox",defer:!0,exclude:[On(e),fE(e)],onFocusOutside:n("onFocusOutside"),onPointerDownOutside:n("onPointerDownOutside"),onInteractOutside(s){var o;(o=n("onInteractOutside"))==null||o(s),i=!(s.detail.focusable||s.detail.contextmenu)},onDismiss(){t({type:"CLOSE",src:"interact-outside",restoreFocus:i})}})},computePlacement({context:e,prop:t,scope:n}){let r=t("positioning");return e.set("currentPlacement",r.placement),at(()=>On(n),()=>ju(n),y(m({defer:!0},r),{onComplete(o){e.set("currentPlacement",o.placement)}}))},scrollToHighlightedItem({context:e,prop:t,scope:n,event:r}){let i=o=>{let a=e.get("highlightedValue");if(a==null||r.current().type.includes("POINTER"))return;let l=Ur(n),c=t("scrollToIndexFn");if(c){let h=t("collection").indexOf(a);c==null||c({index:h,immediate:o,getElement:()=>ta(n,a)});return}let u=ta(n,a);ln(u,{rootEl:l,block:"nearest"})};return H(()=>i(!0)),Ln(()=>Ur(n),{defer:!0,attributes:["data-activedescendant"],callback(){i(!1)}})}},actions:{reposition({context:e,prop:t,scope:n,event:r}){let i=()=>ju(n);at(On(n),i,y(m(m({},t("positioning")),r.options),{defer:!0,listeners:!1,onComplete(s){e.set("currentPlacement",s.placement)}}))},toggleVisibility({send:e,prop:t,event:n}){e({type:t("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:n})},highlightPreviousItem({context:e,prop:t}){let n=e.get("highlightedValue");if(n==null)return;let r=t("collection").getPreviousValue(n,1,t("loopFocus"));r!=null&&e.set("highlightedValue",r)},highlightNextItem({context:e,prop:t}){let n=e.get("highlightedValue");if(n==null)return;let r=t("collection").getNextValue(n,1,t("loopFocus"));r!=null&&e.set("highlightedValue",r)},highlightFirstItem({context:e,prop:t}){let n=t("collection").firstValue;e.set("highlightedValue",n)},highlightLastItem({context:e,prop:t}){let n=t("collection").lastValue;e.set("highlightedValue",n)},setInitialFocus({scope:e}){H(()=>{let t=hi({root:Ur(e)});t==null||t.focus({preventScroll:!0})})},focusTriggerEl({event:e,scope:t}){Xu(e)&&H(()=>{let n=On(t);n==null||n.focus({preventScroll:!0})})},selectHighlightedItem({context:e,prop:t,event:n}){var s,o;let r=(s=n.value)!=null?s:e.get("highlightedValue");if(r==null||!t("collection").has(r))return;(o=t("onSelect"))==null||o({value:r}),r=t("deselectable")&&!t("multiple")&&e.get("value").includes(r)?null:r,e.set("value",a=>r==null?[]:t("multiple")?it(a,r):[r])},highlightComputedFirstItem({context:e,prop:t,computed:n}){let r=t("collection"),i=n("hasSelectedItems")?r.sort(e.get("value"))[0]:r.firstValue;e.set("highlightedValue",i)},highlightComputedLastItem({context:e,prop:t,computed:n}){let r=t("collection"),i=n("hasSelectedItems")?r.sort(e.get("value"))[0]:r.lastValue;e.set("highlightedValue",i)},highlightFirstSelectedItem({context:e,prop:t,computed:n}){if(!n("hasSelectedItems"))return;let r=t("collection").sort(e.get("value"))[0];e.set("highlightedValue",r)},highlightItem({context:e,event:t}){e.set("highlightedValue",t.value)},highlightMatchingItem({context:e,prop:t,event:n,refs:r}){let i=t("collection").search(n.key,{state:r.get("typeahead"),currentValue:e.get("highlightedValue")});i!=null&&e.set("highlightedValue",i)},setHighlightedItem({context:e,event:t}){e.set("highlightedValue",t.value)},clearHighlightedItem({context:e}){e.set("highlightedValue",null)},selectItem({context:e,prop:t,event:n}){var s;(s=t("onSelect"))==null||s({value:n.value});let i=t("deselectable")&&!t("multiple")&&e.get("value").includes(n.value)?null:n.value;e.set("value",o=>i==null?[]:t("multiple")?it(o,i):[i])},clearItem({context:e,event:t}){e.set("value",n=>n.filter(r=>r!==t.value))},setSelectedItems({context:e,event:t}){e.set("value",t.value)},clearSelectedItems({context:e}){e.set("value",[])},selectPreviousItem({context:e,prop:t}){let[n]=e.get("value"),r=t("collection").getPreviousValue(n);r&&e.set("value",[r])},selectNextItem({context:e,prop:t}){let[n]=e.get("value"),r=t("collection").getNextValue(n);r&&e.set("value",[r])},selectFirstItem({context:e,prop:t}){let n=t("collection").firstValue;n&&e.set("value",[n])},selectLastItem({context:e,prop:t}){let n=t("collection").lastValue;n&&e.set("value",[n])},selectMatchingItem({context:e,prop:t,event:n,refs:r}){let i=t("collection").search(n.key,{state:r.get("typeahead"),currentValue:e.get("value")[0]});i!=null&&e.set("value",[i])},scrollContentToTop({prop:e,scope:t}){var n,r;if(e("scrollToIndexFn")){let i=e("collection").firstValue;(n=e("scrollToIndexFn"))==null||n({index:0,immediate:!0,getElement:()=>ta(t,i)})}else(r=Ur(t))==null||r.scrollTo(0,0)},invokeOnOpen({prop:e,context:t}){var n;(n=e("onOpenChange"))==null||n({open:!0,value:t.get("value")})},invokeOnClose({prop:e,context:t}){var n;(n=e("onOpenChange"))==null||n({open:!1,value:t.get("value")})},syncSelectElement({context:e,prop:t,scope:n}){let r=ea(n);if(r){if(e.get("value").length===0&&!t("multiple")){r.selectedIndex=-1;return}for(let i of r.options)i.selected=e.get("value").includes(i.value)}},syncCollection({context:e,prop:t}){let n=t("collection"),r=n.find(e.get("highlightedValue"));r&&e.set("highlightedItem",r);let i=n.findMany(e.get("value"));e.set("selectedItems",i)},syncSelectedItems({context:e,prop:t}){let n=t("collection"),r=e.get("selectedItems"),s=e.get("value").map(o=>r.find(l=>n.getItemValue(l)===o)||n.find(o));e.set("selectedItems",s)},syncHighlightedItem({context:e,prop:t}){let n=t("collection"),r=e.get("highlightedValue"),i=r?n.find(r):null;e.set("highlightedItem",i)},dispatchChangeEvent({scope:e}){queueMicrotask(()=>{let t=ea(e);if(!t)return;let n=e.getWin(),r=new n.Event("change",{bubbles:!0,composed:!0});t.dispatchEvent(r)})}}}};yE=G()(["closeOnSelect","collection","composite","defaultHighlightedValue","defaultOpen","defaultValue","deselectable","dir","disabled","form","getRootNode","highlightedValue","id","ids","invalid","loopFocus","multiple","name","onFocusOutside","onHighlightChange","onInteractOutside","onOpenChange","onPointerDownOutside","onSelect","onValueChange","open","positioning","readOnly","required","scrollToIndexFn","value"]),nO=B(yE),bE=G()(["item","persistFocus"]),rO=B(bE),EE=G()(["id"]),iO=B(EE),CE=G()(["htmlFor"]),sO=B(CE),IE=class extends te{constructor(t,n){super(t,n);U(this,"_options",[]);U(this,"hasGroups",!1);U(this,"placeholder","");this.placeholder=x(this.el,"placeholder")||""}get options(){return Array.isArray(this._options)?this._options:[]}setOptions(t){this._options=Array.isArray(t)?t:[]}getCollection(){let t=this.options;return this.hasGroups?ds({items:t,itemToValue:n=>{var r,i;return(i=(r=n.id)!=null?r:n.value)!=null?i:""},itemToString:n=>n.label,isItemDisabled:n=>!!n.disabled,groupBy:n=>n.group}):ds({items:t,itemToValue:n=>{var r,i;return(i=(r=n.id)!=null?r:n.value)!=null?i:""},itemToString:n=>n.label,isItemDisabled:n=>!!n.disabled})}initMachine(t){let n=this;return new ee(vE,y(m({},t),{get collection(){return n.getCollection()}}))}initApi(){return pE(this.machine.service,Q)}renderItems(){var o,a,l;let t=this.el.querySelector('[data-scope="select"][data-part="content"]');if(!t)return;let n=this.el.querySelector('[data-templates="select"]');if(!n)return;t.querySelectorAll('[data-scope="select"][data-part="item"]:not([data-template])').forEach(c=>c.remove()),t.querySelectorAll('[data-scope="select"][data-part="item-group"]:not([data-template])').forEach(c=>c.remove());let r=this.api.collection.items,i=(l=(a=(o=this.api.collection).group)==null?void 0:a.call(o))!=null?l:[];i.some(([c])=>c!=null)?this.renderGroupedItems(t,n,i):this.renderFlatItems(t,n,r)}renderGroupedItems(t,n,r){for(let[i,s]of r){if(i==null)continue;let o=n.querySelector(`[data-scope="select"][data-part="item-group"][data-id="${i}"][data-template]`);if(!o)continue;let a=o.cloneNode(!0);a.removeAttribute("data-template"),this.spreadProps(a,this.api.getItemGroupProps({id:i}));let l=a.querySelector('[data-scope="select"][data-part="item-group-label"]');l&&this.spreadProps(l,this.api.getItemGroupLabelProps({htmlFor:i})),a.querySelectorAll('[data-scope="select"][data-part="item"][data-template]').forEach(u=>u.remove());for(let u of s){let h=this.cloneItem(n,u);h&&a.appendChild(h)}t.appendChild(a)}}renderFlatItems(t,n,r){for(let i of r){let s=this.cloneItem(n,i);s&&t.appendChild(s)}}cloneItem(t,n){let r=this.api.collection.getItemValue(n),i=t.querySelector(`[data-scope="select"][data-part="item"][data-value="${r}"][data-template]`);if(!i)return null;let s=i.cloneNode(!0);s.removeAttribute("data-template"),this.spreadProps(s,this.api.getItemProps({item:n}));let o=s.querySelector('[data-scope="select"][data-part="item-text"]');o&&this.spreadProps(o,this.api.getItemTextProps({item:n}));let a=s.querySelector('[data-scope="select"][data-part="item-indicator"]');return a&&this.spreadProps(a,this.api.getItemIndicatorProps({item:n})),s}render(){let t=this.el.querySelector('[data-scope="select"][data-part="root"]');if(!t)return;this.spreadProps(t,this.api.getRootProps());let n=this.el.querySelector('[data-scope="select"][data-part="hidden-select"]'),r=this.el.querySelector('[data-scope="select"][data-part="value-input"]');r&&(!this.api.value||this.api.value.length===0?r.value="":this.api.value.length===1?r.value=String(this.api.value[0]):r.value=this.api.value.map(String).join(",")),n&&this.spreadProps(n,this.api.getHiddenSelectProps()),["label","control","trigger","indicator","clear-trigger","positioner"].forEach(o=>{let a=this.el.querySelector(`[data-scope="select"][data-part="${o}"]`);if(!a)return;let l="get"+o.split("-").map(c=>c[0].toUpperCase()+c.slice(1)).join("")+"Props";this.spreadProps(a,this.api[l]())});let i=this.el.querySelector('[data-scope="select"][data-part="item-text"]');if(i){let o=this.api.valueAsString;if(this.api.value&&this.api.value.length>0&&!o){let a=this.api.value[0],l=this.options.find(c=>{var h,p;let u=(p=(h=c.id)!=null?h:c.value)!=null?p:"";return String(u)===String(a)});l?i.textContent=l.label:i.textContent=this.placeholder||""}else i.textContent=o||this.placeholder||""}let s=this.el.querySelector('[data-scope="select"][data-part="content"]');s&&(this.spreadProps(s,this.api.getContentProps()),this.renderItems())}};SE={mounted(){let e=this.el,t=JSON.parse(e.dataset.collection||"[]"),n=t.some(s=>s.group!==void 0),r,i=this;r=new IE(e,y(m({id:e.id},O(e,"controlled")?{value:Y(e,"value")}:{defaultValue:Y(e,"defaultValue")}),{disabled:O(e,"disabled"),closeOnSelect:O(e,"closeOnSelect"),dir:x(e,"dir",["ltr","rtl"]),loopFocus:O(e,"loopFocus"),multiple:O(e,"multiple"),invalid:O(e,"invalid"),name:x(e,"name"),form:x(e,"form"),readOnly:O(e,"readOnly"),required:O(e,"required"),positioning:(()=>{let s=e.dataset.positioning;if(s)try{let o=JSON.parse(s);return OE(o)}catch(o){return}})(),onValueChange:s=>{var V;let o=O(e,"redirect"),a=s.value.length>0?String(s.value[0]):null,l=(V=s.items)!=null&&V.length?s.items[0]:null,c=l&&typeof l=="object"&&l!==null&&"redirect"in l?l.redirect:void 0,u=l&&typeof l=="object"&&l!==null&&"new_tab"in l?l.new_tab:void 0;o&&a&&i.liveSocket.main.isDead&&c!==!1&&(u===!0?window.open(a,"_blank","noopener,noreferrer"):window.location.href=a);let d=e.querySelector('[data-scope="select"][data-part="value-input"]');d&&(d.value=s.value.length===0?"":s.value.length===1?String(s.value[0]):s.value.map(String).join(","),d.dispatchEvent(new Event("input",{bubbles:!0})),d.dispatchEvent(new Event("change",{bubbles:!0})));let g={value:s.value,items:s.items,id:e.id},v=x(e,"onValueChangeClient");v&&e.dispatchEvent(new CustomEvent(v,{bubbles:!0,detail:g}));let b=x(e,"onValueChange");b&&!i.liveSocket.main.isDead&&i.liveSocket.main.isConnected()&&this.pushEvent(b,g)}})),r.hasGroups=n,r.setOptions(t),r.init(),this.select=r,this.handlers=[]},updated(){let e=JSON.parse(this.el.dataset.collection||"[]"),t=e.some(n=>n.group!==void 0);this.select&&(this.select.hasGroups=t,this.select.setOptions(e),this.select.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{value:Y(this.el,"value")}:{defaultValue:Y(this.el,"defaultValue")}),{name:x(this.el,"name"),form:x(this.el,"form"),disabled:O(this.el,"disabled"),multiple:O(this.el,"multiple"),dir:x(this.el,"dir",["ltr","rtl"]),invalid:O(this.el,"invalid"),required:O(this.el,"required"),readOnly:O(this.el,"readOnly")})))},destroyed(){var e;if(this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.select)==null||e.destroy()}}});var bd={};Oe(bd,{SignaturePad:()=>zE});function nd(e,t,n,r=i=>i){return e*r(.5-t*(.5-n))}function gd(e,t,n){let r=oa(1,t/n);return oa(1,e+(oa(1,1-r)-e)*(r*.275))}function wE(e){return[-e[0],-e[1]]}function bt(e,t){return[e[0]+t[0],e[1]+t[1]]}function rd(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function en(e,t){return[e[0]-t[0],e[1]-t[1]]}function ca(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function Qt(e,t){return[e[0]*t,e[1]*t]}function aa(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function VE(e,t){return[e[0]/t,e[1]/t]}function fd(e){return[e[1],-e[0]]}function la(e,t){let n=t[0];return e[0]=t[1],e[1]=-n,e}function id(e,t){return e[0]*t[0]+e[1]*t[1]}function xE(e,t){return e[0]===t[0]&&e[1]===t[1]}function kE(e){return Math.hypot(e[0],e[1])}function sd(e,t){let n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function pd(e){return VE(e,kE(e))}function NE(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function ua(e,t,n){let r=Math.sin(n),i=Math.cos(n),s=e[0]-t[0],o=e[1]-t[1],a=s*i-o*r,l=s*r+o*i;return[a+t[0],l+t[1]]}function od(e,t,n,r){let i=Math.sin(r),s=Math.cos(r),o=t[0]-n[0],a=t[1]-n[1],l=o*s-a*i,c=o*i+a*s;return e[0]=l+n[0],e[1]=c+n[1],e}function ad(e,t,n){return bt(e,Qt(en(t,e),n))}function AE(e,t,n,r){let i=n[0]-t[0],s=n[1]-t[1];return e[0]=t[0]+i*r,e[1]=t[1]+s*r,e}function md(e,t,n){return bt(e,Qt(t,n))}function RE(e,t){let n=md(e,pd(fd(en(e,bt(e,[1,1])))),-t),r=[],i=1/13;for(let s=i;s<=1;s+=i)r.push(ua(n,e,Wr*2*s));return r}function DE(e,t,n){let r=[],i=1/n;for(let s=i;s<=1;s+=i)r.push(ua(t,e,Wr*s));return r}function LE(e,t,n){let r=en(t,n),i=Qt(r,.5),s=Qt(r,.51);return[en(e,i),en(e,s),bt(e,s),bt(e,i)]}function FE(e,t,n,r){let i=[],s=md(e,t,n),o=1/r;for(let a=o;a<1;a+=o)i.push(ua(s,e,Wr*3*a));return i}function ME(e,t,n){return[bt(e,Qt(t,n)),bt(e,Qt(t,n*.99)),en(e,Qt(t,n*.99)),en(e,Qt(t,n))]}function ld(e,t,n){return e===!1||e===void 0?0:e===!0?Math.max(t,n):e}function $E(e,t,n){return e.slice(0,10).reduce((r,i)=>{let s=i.pressure;return t&&(s=gd(r,i.distance,n)),(r+s)/2},e[0].pressure)}function _E(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:s=!0,easing:o=W=>W,start:a={},end:l={},last:c=!1}=t,{cap:u=!0,easing:h=W=>W*(2-W)}=a,{cap:p=!0,easing:d=W=>--W*W*W+1}=l;if(e.length===0||n<=0)return[];let g=e[e.length-1].runningLength,v=ld(a.taper,n,g),b=ld(l.taper,n,g),V=(n*r)**2,S=[],E=[],f=$E(e,s,n),C=nd(n,i,e[e.length-1].pressure,o),I,w=e[0].vector,A=e[0].point,P=A,N=A,R=P,L=!1;for(let W=0;WV)&&(S.push(N),A=N),rd(zt,de,Te),R=[zt[0],zt[1]],(W<=1||sd(P,R)>V)&&(E.push(R),P=R),f=ge,w=X}let M=[e[0].point[0],e[0].point[1]],j=e.length>1?[e[e.length-1].point[0],e[e.length-1].point[1]]:bt(e[0].point,[1,1]),q=[],J=[];if(e.length===1){if(!(v||b)||c)return RE(M,I||C)}else{v||b&&e.length===1||(u?q.push(...DE(M,E[0],13)):q.push(...LE(M,S[0],E[0])));let W=fd(wE(e[e.length-1].vector));b||v&&e.length===1?J.push(j):p?J.push(...FE(j,W,C,29)):J.push(...ME(j,W,C))}return S.concat(J,E.reverse(),q)}function ud(e){return e!=null&&e>=0}function HE(e,t={}){var p;let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let s=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:d,y:g,pressure:v=ed})=>[d,g,v]);if(o.length===2){let d=o[1];o=o.slice(0,-1);for(let g=1;g<5;g++)o.push(ad(o[0],d,g/4))}o.length===1&&(o=[...o,[...bt(o[0],td),...o[0].slice(2)]]);let a=[{point:[o[0][0],o[0][1]],pressure:ud(o[0][2])?o[0][2]:.25,vector:[...td],distance:0,runningLength:0}],l=!1,c=0,u=a[0],h=o.length-1;for(let d=1;d{"use strict";me();({PI:PE}=Math),Wr=PE+1e-4,ed=.5,td=[1,1];({min:oa}=Math);Te=[0,0],Jt=[0,0],zt=[0,0];cd=[0,0];GE=BE,UE=Z("signature-pad").parts("root","control","segment","segmentPath","guide","clearTrigger","label"),Sn=UE.build(),qE=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`signature-${e.id}`},vd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`signature-control-${e.id}`},WE=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`signature-label-${e.id}`},dd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.hiddenInput)!=null?n:`signature-input-${e.id}`},fs=e=>e.getById(vd(e)),KE=e=>Mn(fs(e),"[data-part=segment]"),yd=(e,t)=>_a(KE(e),t);hs=(e,t)=>(e+t)/2;XE={props({props:e}){return y(m({defaultPaths:[]},e),{drawing:m({size:2,simulatePressure:!1,thinning:.7,smoothing:.4,streamline:.6},e.drawing),translations:m({control:"signature pad",clearTrigger:"clear signature"},e.translations)})},initialState(){return"idle"},context({prop:e,bindable:t}){return{paths:t(()=>({defaultValue:e("defaultPaths"),value:e("paths"),sync:!0,onChange(n){var r;(r=e("onDraw"))==null||r({paths:n})}})),currentPoints:t(()=>({defaultValue:[]})),currentPath:t(()=>({defaultValue:null}))}},computed:{isInteractive:({prop:e})=>!(e("disabled")||e("readOnly")),isEmpty:({context:e})=>e.get("paths").length===0},on:{CLEAR:{actions:["clearPoints","invokeOnDrawEnd","focusCanvasEl"]}},states:{idle:{on:{POINTER_DOWN:{target:"drawing",actions:["addPoint"]}}},drawing:{effects:["trackPointerMove"],on:{POINTER_MOVE:{actions:["addPoint","invokeOnDraw"]},POINTER_UP:{target:"idle",actions:["endStroke","invokeOnDrawEnd"]}}}},implementations:{effects:{trackPointerMove({scope:e,send:t}){let n=e.getDoc();return Za(n,{onPointerMove({event:r,point:i}){let s=fs(e);if(!s)return;let{offset:o}=_s(i,s);t({type:"POINTER_MOVE",point:o,pressure:r.pressure})},onPointerUp(){t({type:"POINTER_UP"})}})}},actions:{addPoint({context:e,event:t,prop:n}){let r=[...e.get("currentPoints"),t.point];e.set("currentPoints",r);let i=GE(r,n("drawing"));e.set("currentPath",jE(i))},endStroke({context:e}){let t=[...e.get("paths"),e.get("currentPath")];e.set("paths",t),e.set("currentPoints",[]),e.set("currentPath",null)},clearPoints({context:e}){e.set("currentPoints",[]),e.set("paths",[]),e.set("currentPath",null)},focusCanvasEl({scope:e}){queueMicrotask(()=>{var t;(t=e.getActiveElement())==null||t.focus({preventScroll:!0})})},invokeOnDraw({context:e,prop:t}){var n;(n=t("onDraw"))==null||n({paths:[...e.get("paths"),e.get("currentPath")]})},invokeOnDrawEnd({context:e,prop:t,scope:n,computed:r}){var i;(i=t("onDrawEnd"))==null||i({paths:[...e.get("paths")],getDataUrl(s,o=.92){return r("isEmpty")?Promise.resolve(""):yd(n,{type:s,quality:o})}})}}}},ZE=G()(["defaultPaths","dir","disabled","drawing","getRootNode","id","ids","name","onDraw","onDrawEnd","paths","readOnly","required","translations"]),cO=B(ZE),JE=class extends te{constructor(){super(...arguments);U(this,"imageURL","");U(this,"paths",[]);U(this,"name");U(this,"syncPaths",()=>{let t=this.el.querySelector('[data-scope="signature-pad"][data-part="segment"]');if(!t)return;if(this.api.paths.length+(this.api.currentPath?1:0)===0){t.innerHTML="",this.imageURL="",this.paths=[];let r=this.el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');r&&(r.value="");return}if(t.innerHTML="",this.api.paths.forEach(r=>{let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("data-scope","signature-pad"),i.setAttribute("data-part","path"),this.spreadProps(i,this.api.getSegmentPathProps({path:r})),t.appendChild(i)}),this.api.currentPath){let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("data-scope","signature-pad"),r.setAttribute("data-part","current-path"),this.spreadProps(r,this.api.getSegmentPathProps({path:this.api.currentPath})),t.appendChild(r)}})}initMachine(t){return this.name=t.name,new ee(XE,t)}setName(t){this.name=t}setPaths(t){this.paths=t}initApi(){return YE(this.machine.service,Q)}render(){let t=this.el.querySelector('[data-scope="signature-pad"][data-part="root"]');if(!t)return;this.spreadProps(t,this.api.getRootProps());let n=t.querySelector('[data-scope="signature-pad"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps());let r=t.querySelector('[data-scope="signature-pad"][data-part="control"]');r&&this.spreadProps(r,this.api.getControlProps());let i=t.querySelector('[data-scope="signature-pad"][data-part="segment"]');i&&this.spreadProps(i,this.api.getSegmentProps());let s=t.querySelector('[data-scope="signature-pad"][data-part="guide"]');s&&this.spreadProps(s,this.api.getGuideProps());let o=t.querySelector('[data-scope="signature-pad"][data-part="clear-trigger"]');if(o){this.spreadProps(o,this.api.getClearTriggerProps());let l=this.api.paths.length>0||!!this.api.currentPath;o.hidden=!l}let a=t.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');if(a){let l=this.paths.length>0?this.paths:this.api.paths;this.paths.length===0&&this.api.paths.length>0&&(this.paths=[...this.api.paths]);let c=l.length>0?JSON.stringify(l):"";this.spreadProps(a,this.api.getHiddenInputProps({value:c})),this.name&&(a.name=this.name),a.value=c}this.syncPaths()}};zE={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=O(e,"controlled"),r=gs(e,"paths"),i=gs(e,"defaultPaths"),s=new JE(e,y(m(m({id:e.id,name:x(e,"name")},n&&r.length>0?{paths:r}:void 0),!n&&i.length>0?{defaultPaths:i}:void 0),{drawing:hd(e),onDrawEnd:a=>{s.setPaths(a.paths);let l=e.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');l&&(l.value=JSON.stringify(a.paths)),a.getDataUrl("image/png").then(c=>{s.imageURL=c;let u=x(e,"onDrawEnd");u&&this.liveSocket.main.isConnected()&&t(u,{id:e.id,paths:a.paths,url:c});let h=x(e,"onDrawEndClient");h&&e.dispatchEvent(new CustomEvent(h,{bubbles:!0,detail:{id:e.id,paths:a.paths,url:c}}))})}}));if(s.init(),this.signaturePad=s,(n?r:i).length>0){let a=e.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');a&&(a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})))}this.onClear=a=>{let{id:l}=a.detail;if(l&&l!==e.id)return;s.api.clear(),s.imageURL="",s.setPaths([]);let c=e.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');c&&(c.value="")},e.addEventListener("phx:signature-pad:clear",this.onClear),this.handlers=[],this.handlers.push(this.handleEvent("signature_pad_clear",a=>{let l=a.signature_pad_id;if(l&&l!==e.id)return;s.api.clear(),s.imageURL="",s.setPaths([]);let c=e.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');c&&(c.value="")}))},updated(){var i,s;let e=O(this.el,"controlled"),t=gs(this.el,"paths"),n=gs(this.el,"defaultPaths"),r=x(this.el,"name");r&&((i=this.signaturePad)==null||i.setName(r)),(s=this.signaturePad)==null||s.updateProps(y(m(m({id:this.el.id,name:r},e&&t.length>0?{paths:t}:{}),!e&&n.length>0?{defaultPaths:n}:{}),{drawing:hd(this.el)}))},destroyed(){var e;if(this.onClear&&this.el.removeEventListener("phx:signature-pad:clear",this.onClear),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.signaturePad)==null||e.destroy()}}});var Od={};Oe(Od,{Switch:()=>aC});function rC(e,t){let{context:n,send:r,prop:i,scope:s}=e,o=!!i("disabled"),a=!!i("readOnly"),l=!!i("required"),c=!!n.get("checked"),u=!o&&n.get("focused"),h=!o&&n.get("focusVisible"),p=!o&&n.get("active"),d={"data-active":T(p),"data-focus":T(u),"data-focus-visible":T(h),"data-readonly":T(a),"data-hover":T(n.get("hovered")),"data-disabled":T(o),"data-state":c?"checked":"unchecked","data-invalid":T(i("invalid")),"data-required":T(l)};return{checked:c,disabled:o,focused:u,setChecked(g){r({type:"CHECKED.SET",checked:g,isTrusted:!1})},toggleChecked(){r({type:"CHECKED.TOGGLE",checked:c,isTrusted:!1})},getRootProps(){return t.label(y(m(m({},ps.root.attrs),d),{dir:i("dir"),id:Td(s),htmlFor:da(s),onPointerMove(){o||r({type:"CONTEXT.SET",context:{hovered:!0}})},onPointerLeave(){o||r({type:"CONTEXT.SET",context:{hovered:!1}})},onClick(g){var b;if(o)return;K(g)===ur(s)&&g.stopPropagation(),Wt()&&((b=ur(s))==null||b.focus())}}))},getLabelProps(){return t.element(y(m(m({},ps.label.attrs),d),{dir:i("dir"),id:Cd(s)}))},getThumbProps(){return t.element(y(m(m({},ps.thumb.attrs),d),{dir:i("dir"),id:eC(s),"aria-hidden":!0}))},getControlProps(){return t.element(y(m(m({},ps.control.attrs),d),{dir:i("dir"),id:tC(s),"aria-hidden":!0}))},getHiddenInputProps(){return t.input({id:da(s),type:"checkbox",required:i("required"),defaultChecked:c,disabled:o,"aria-labelledby":Cd(s),"aria-invalid":i("invalid"),name:i("name"),form:i("form"),value:i("value"),style:Hn,onFocus(){let g=Kn();r({type:"CONTEXT.SET",context:{focused:!0,focusVisible:g}})},onBlur(){r({type:"CONTEXT.SET",context:{focused:!1,focusVisible:!1}})},onClick(g){if(a){g.preventDefault();return}let v=g.currentTarget.checked;r({type:"CHECKED.SET",checked:v,isTrusted:!0})}})}}}var QE,ps,Td,Cd,eC,tC,da,nC,ur,Id,iC,sC,fO,oC,aC,Sd=fe(()=>{"use strict";zs();me();QE=Z("switch").parts("root","label","control","thumb"),ps=QE.build(),Td=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`switch:${e.id}`},Cd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`switch:${e.id}:label`},eC=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.thumb)!=null?n:`switch:${e.id}:thumb`},tC=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`switch:${e.id}:control`},da=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.hiddenInput)!=null?n:`switch:${e.id}:input`},nC=e=>e.getById(Td(e)),ur=e=>e.getById(da(e));({not:Id}=ye()),iC={props({props:e}){return m({defaultChecked:!1,label:"switch",value:"on"},e)},initialState(){return"ready"},context({prop:e,bindable:t}){return{checked:t(()=>({defaultValue:e("defaultChecked"),value:e("checked"),onChange(n){var r;(r=e("onCheckedChange"))==null||r({checked:n})}})),fieldsetDisabled:t(()=>({defaultValue:!1})),focusVisible:t(()=>({defaultValue:!1})),active:t(()=>({defaultValue:!1})),focused:t(()=>({defaultValue:!1})),hovered:t(()=>({defaultValue:!1}))}},computed:{isDisabled:({context:e,prop:t})=>t("disabled")||e.get("fieldsetDisabled")},watch({track:e,prop:t,context:n,action:r}){e([()=>t("disabled")],()=>{r(["removeFocusIfNeeded"])}),e([()=>n.get("checked")],()=>{r(["syncInputElement"])})},effects:["trackFormControlState","trackPressEvent","trackFocusVisible"],on:{"CHECKED.TOGGLE":[{guard:Id("isTrusted"),actions:["toggleChecked","dispatchChangeEvent"]},{actions:["toggleChecked"]}],"CHECKED.SET":[{guard:Id("isTrusted"),actions:["setChecked","dispatchChangeEvent"]},{actions:["setChecked"]}],"CONTEXT.SET":{actions:["setContext"]}},states:{ready:{}},implementations:{guards:{isTrusted:({event:e})=>!!e.isTrusted},effects:{trackPressEvent({computed:e,scope:t,context:n}){if(!e("isDisabled"))return pi({pointerNode:nC(t),keyboardNode:ur(t),isValidKey:r=>r.key===" ",onPress:()=>n.set("active",!1),onPressStart:()=>n.set("active",!0),onPressEnd:()=>n.set("active",!1)})},trackFocusVisible({computed:e,scope:t}){if(!e("isDisabled"))return Si({root:t.getRootNode()})},trackFormControlState({context:e,send:t,scope:n}){return Rn(ur(n),{onFieldsetDisabledChange(r){e.set("fieldsetDisabled",r)},onFormReset(){let r=e.initial("checked");t({type:"CHECKED.SET",checked:!!r,src:"form-reset"})}})}},actions:{setContext({context:e,event:t}){for(let n in t.context)e.set(n,t.context[n])},syncInputElement({context:e,scope:t}){let n=ur(t);n&&Cr(n,!!e.get("checked"))},removeFocusIfNeeded({context:e,prop:t}){t("disabled")&&e.set("focused",!1)},setChecked({context:e,event:t}){e.set("checked",t.checked)},toggleChecked({context:e}){e.set("checked",!e.get("checked"))},dispatchChangeEvent({context:e,scope:t}){queueMicrotask(()=>{let n=ur(t);ui(n,{checked:e.get("checked")})})}}}},sC=G()(["checked","defaultChecked","dir","disabled","form","getRootNode","id","ids","invalid","label","name","onCheckedChange","readOnly","required","value"]),fO=B(sC),oC=class extends te{initMachine(e){return new ee(iC,e)}initApi(){return rC(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="switch"][data-part="root"]');if(!e)return;this.spreadProps(e,this.api.getRootProps());let t=this.el.querySelector('[data-scope="switch"][data-part="hidden-input"]');t&&this.spreadProps(t,this.api.getHiddenInputProps());let n=this.el.querySelector('[data-scope="switch"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps());let r=this.el.querySelector('[data-scope="switch"][data-part="control"]');r&&this.spreadProps(r,this.api.getControlProps());let i=this.el.querySelector('[data-scope="switch"][data-part="thumb"]');i&&this.spreadProps(i,this.api.getThumbProps())}},aC={mounted(){let e=this.el,t=this.pushEvent.bind(this);this.wasFocused=!1;let n=new oC(e,y(m({id:e.id},O(e,"controlled")?{checked:O(e,"checked")}:{defaultChecked:O(e,"defaultChecked")}),{disabled:O(e,"disabled"),name:x(e,"name"),form:x(e,"form"),value:x(e,"value"),dir:x(e,"dir",["ltr","rtl"]),invalid:O(e,"invalid"),required:O(e,"required"),readOnly:O(e,"readOnly"),label:x(e,"label"),onCheckedChange:r=>{let i=x(e,"onCheckedChange");i&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(i,{checked:r.checked,id:e.id});let s=x(e,"onCheckedChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{value:r,id:e.id}}))}}));n.init(),this.zagSwitch=n,this.onSetChecked=r=>{let{value:i}=r.detail;n.api.setChecked(i)},e.addEventListener("phx:switch:set-checked",this.onSetChecked),this.handlers=[],this.handlers.push(this.handleEvent("switch_set_checked",r=>{let i=r.id;i&&i!==e.id||n.api.setChecked(r.value)})),this.handlers.push(this.handleEvent("switch_toggle_checked",r=>{let i=r.id;i&&i!==e.id||n.api.toggleChecked()})),this.handlers.push(this.handleEvent("switch_checked",()=>{this.pushEvent("switch_checked_response",{value:n.api.checked})})),this.handlers.push(this.handleEvent("switch_focused",()=>{this.pushEvent("switch_focused_response",{value:n.api.focused})})),this.handlers.push(this.handleEvent("switch_disabled",()=>{this.pushEvent("switch_disabled_response",{value:n.api.disabled})}))},beforeUpdate(){var e,t;this.wasFocused=(t=(e=this.zagSwitch)==null?void 0:e.api.focused)!=null?t:!1},updated(){var e;if((e=this.zagSwitch)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{checked:O(this.el,"checked")}:{defaultChecked:O(this.el,"defaultChecked")}),{disabled:O(this.el,"disabled"),name:x(this.el,"name"),form:x(this.el,"form"),value:x(this.el,"value"),dir:x(this.el,"dir",["ltr","rtl"]),invalid:O(this.el,"invalid"),required:O(this.el,"required"),readOnly:O(this.el,"readOnly"),label:x(this.el,"label")})),O(this.el,"controlled")&&this.wasFocused){let t=this.el.querySelector('[data-part="hidden-input"]');t==null||t.focus()}},destroyed(){var e;if(this.onSetChecked&&this.el.removeEventListener("phx:switch:set-checked",this.onSetChecked),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.zagSwitch)==null||e.destroy()}}});var xd={};Oe(xd,{Tabs:()=>OC});function vC(e,t){let{state:n,send:r,context:i,prop:s,scope:o}=e,a=s("translations"),l=n.matches("focused"),c=s("orientation")==="vertical",u=s("orientation")==="horizontal",h=s("composite");function p(d){return{selected:i.get("value")===d.value,focused:i.get("focusedValue")===d.value,disabled:!!d.disabled}}return{value:i.get("value"),focusedValue:i.get("focusedValue"),setValue(d){r({type:"SET_VALUE",value:d})},clearValue(){r({type:"CLEAR_VALUE"})},setIndicatorRect(d){let g=Pn(o,d);r({type:"SET_INDICATOR_RECT",id:g})},syncTabIndex(){r({type:"SYNC_TAB_INDEX"})},selectNext(d){r({type:"TAB_FOCUS",value:d,src:"selectNext"}),r({type:"ARROW_NEXT",src:"selectNext"})},selectPrev(d){r({type:"TAB_FOCUS",value:d,src:"selectPrev"}),r({type:"ARROW_PREV",src:"selectPrev"})},focus(){var g;let d=i.get("value");d&&((g=ms(o,d))==null||g.focus())},getRootProps(){return t.element(y(m({},Kr.root.attrs),{id:cC(o),"data-orientation":s("orientation"),"data-focus":T(l),dir:s("dir")}))},getListProps(){return t.element(y(m({},Kr.list.attrs),{id:Yr(o),role:"tablist",dir:s("dir"),"data-focus":T(l),"aria-orientation":s("orientation"),"data-orientation":s("orientation"),"aria-label":a==null?void 0:a.listLabel,onKeyDown(d){if(d.defaultPrevented||Vt(d)||!pe(d.currentTarget,K(d)))return;let g={ArrowDown(){u||r({type:"ARROW_NEXT",key:"ArrowDown"})},ArrowUp(){u||r({type:"ARROW_PREV",key:"ArrowUp"})},ArrowLeft(){c||r({type:"ARROW_PREV",key:"ArrowLeft"})},ArrowRight(){c||r({type:"ARROW_NEXT",key:"ArrowRight"})},Home(){r({type:"HOME"})},End(){r({type:"END"})}},v=ve(d,{dir:s("dir"),orientation:s("orientation")}),b=g[v];if(b){d.preventDefault(),b(d);return}}}))},getTriggerState:p,getTriggerProps(d){let{value:g,disabled:v}=d,b=p(d);return t.button(y(m({},Kr.trigger.attrs),{role:"tab",type:"button",disabled:v,dir:s("dir"),"data-orientation":s("orientation"),"data-disabled":T(v),"aria-disabled":v,"data-value":g,"aria-selected":b.selected,"data-selected":T(b.selected),"data-focus":T(b.focused),"aria-controls":b.selected?ha(o,g):void 0,"data-ownedby":Yr(o),"data-ssr":T(i.get("ssr")),id:Pn(o,g),tabIndex:b.selected&&h?0:-1,onFocus(){r({type:"TAB_FOCUS",value:g})},onBlur(V){let S=V.relatedTarget;(S==null?void 0:S.getAttribute("role"))!=="tab"&&r({type:"TAB_BLUR"})},onClick(V){V.defaultPrevented||sn(V)||v||(Wt()&&V.currentTarget.focus(),r({type:"TAB_CLICK",value:g}))}}))},getContentProps(d){let{value:g}=d,v=i.get("value")===g;return t.element(y(m({},Kr.content.attrs),{dir:s("dir"),id:ha(o,g),tabIndex:h?0:-1,"aria-labelledby":Pn(o,g),role:"tabpanel","data-ownedby":Yr(o),"data-selected":T(v),"data-orientation":s("orientation"),hidden:!v}))},getIndicatorProps(){let d=i.get("indicatorRect"),g=d==null||d.width===0&&d.height===0&&d.x===0&&d.y===0;return t.element(y(m({id:wd(o)},Kr.indicator.attrs),{dir:s("dir"),"data-orientation":s("orientation"),hidden:g,style:{"--transition-property":"left, right, top, bottom, width, height","--left":Ae(d==null?void 0:d.x),"--top":Ae(d==null?void 0:d.y),"--width":Ae(d==null?void 0:d.width),"--height":Ae(d==null?void 0:d.height),position:"absolute",willChange:"var(--transition-property)",transitionProperty:"var(--transition-property)",transitionDuration:"var(--transition-duration, 150ms)",transitionTimingFunction:"var(--transition-timing-function)",[u?"left":"top"]:u?"var(--left)":"var(--top)"}}))}}}var lC,Kr,cC,Yr,ha,Pn,wd,uC,dC,ms,Pd,dr,hC,gC,fC,pC,Vd,mC,yC,bC,EC,yO,CC,bO,IC,EO,TC,OC,kd=fe(()=>{"use strict";me();lC=Z("tabs").parts("root","list","trigger","content","indicator"),Kr=lC.build(),cC=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`tabs:${e.id}`},Yr=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.list)!=null?n:`tabs:${e.id}:list`},ha=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.content)==null?void 0:r.call(n,t))!=null?i:`tabs:${e.id}:content-${t}`},Pn=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.trigger)==null?void 0:r.call(n,t))!=null?i:`tabs:${e.id}:trigger-${t}`},wd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.indicator)!=null?n:`tabs:${e.id}:indicator`},uC=e=>e.getById(Yr(e)),dC=(e,t)=>e.getById(ha(e,t)),ms=(e,t)=>t!=null?e.getById(Pn(e,t)):null,Pd=e=>e.getById(wd(e)),dr=e=>{let n=`[role=tab][data-ownedby='${CSS.escape(Yr(e))}']:not([disabled])`;return dt(uC(e),n)},hC=e=>Ke(dr(e)),gC=e=>nt(dr(e)),fC=(e,t)=>$n(dr(e),Pn(e,t.value),t.loopFocus),pC=(e,t)=>_n(dr(e),Pn(e,t.value),t.loopFocus),Vd=e=>{var t,n,r,i;return{x:(t=e==null?void 0:e.offsetLeft)!=null?t:0,y:(n=e==null?void 0:e.offsetTop)!=null?n:0,width:(r=e==null?void 0:e.offsetWidth)!=null?r:0,height:(i=e==null?void 0:e.offsetHeight)!=null?i:0}},mC=(e,t)=>{let n=Us(dr(e),Pn(e,t));return Vd(n)};({createMachine:yC}=Wn()),bC=yC({props({props:e}){return m({dir:"ltr",orientation:"horizontal",activationMode:"automatic",loopFocus:!0,composite:!0,navigate(t){Fn(t.node)},defaultValue:null},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(n){var r;(r=e("onValueChange"))==null||r({value:n})}})),focusedValue:t(()=>({defaultValue:e("value")||e("defaultValue"),sync:!0,onChange(n){var r;(r=e("onFocusChange"))==null||r({focusedValue:n})}})),ssr:t(()=>({defaultValue:!0})),indicatorRect:t(()=>({defaultValue:null}))}},watch({context:e,prop:t,track:n,action:r}){n([()=>e.get("value")],()=>{r(["syncIndicatorRect","syncTabIndex","navigateIfNeeded"])}),n([()=>t("dir"),()=>t("orientation")],()=>{r(["syncIndicatorRect"])})},on:{SET_VALUE:{actions:["setValue"]},CLEAR_VALUE:{actions:["clearValue"]},SET_INDICATOR_RECT:{actions:["setIndicatorRect"]},SYNC_TAB_INDEX:{actions:["syncTabIndex"]}},entry:["syncIndicatorRect","syncTabIndex","syncSsr"],exit:["cleanupObserver"],states:{idle:{on:{TAB_FOCUS:{target:"focused",actions:["setFocusedValue"]},TAB_CLICK:{target:"focused",actions:["setFocusedValue","setValue"]}}},focused:{on:{TAB_CLICK:{actions:["setFocusedValue","setValue"]},ARROW_PREV:[{guard:"selectOnFocus",actions:["focusPrevTab","selectFocusedTab"]},{actions:["focusPrevTab"]}],ARROW_NEXT:[{guard:"selectOnFocus",actions:["focusNextTab","selectFocusedTab"]},{actions:["focusNextTab"]}],HOME:[{guard:"selectOnFocus",actions:["focusFirstTab","selectFocusedTab"]},{actions:["focusFirstTab"]}],END:[{guard:"selectOnFocus",actions:["focusLastTab","selectFocusedTab"]},{actions:["focusLastTab"]}],TAB_FOCUS:{actions:["setFocusedValue"]},TAB_BLUR:{target:"idle",actions:["clearFocusedValue"]}}}},implementations:{guards:{selectOnFocus:({prop:e})=>e("activationMode")==="automatic"},actions:{selectFocusedTab({context:e,prop:t}){H(()=>{let n=e.get("focusedValue");if(!n)return;let i=t("deselectable")&&e.get("value")===n?null:n;e.set("value",i)})},setFocusedValue({context:e,event:t,flush:n}){t.value!=null&&n(()=>{e.set("focusedValue",t.value)})},clearFocusedValue({context:e}){e.set("focusedValue",null)},setValue({context:e,event:t,prop:n}){let r=n("deselectable")&&e.get("value")===e.get("focusedValue");e.set("value",r?null:t.value)},clearValue({context:e}){e.set("value",null)},focusFirstTab({scope:e}){H(()=>{var t;(t=hC(e))==null||t.focus()})},focusLastTab({scope:e}){H(()=>{var t;(t=gC(e))==null||t.focus()})},focusNextTab({context:e,prop:t,scope:n,event:r}){var o;let i=(o=r.value)!=null?o:e.get("focusedValue");if(!i)return;let s=fC(n,{value:i,loopFocus:t("loopFocus")});H(()=>{t("composite")?s==null||s.focus():(s==null?void 0:s.dataset.value)!=null&&e.set("focusedValue",s.dataset.value)})},focusPrevTab({context:e,prop:t,scope:n,event:r}){var o;let i=(o=r.value)!=null?o:e.get("focusedValue");if(!i)return;let s=pC(n,{value:i,loopFocus:t("loopFocus")});H(()=>{t("composite")?s==null||s.focus():(s==null?void 0:s.dataset.value)!=null&&e.set("focusedValue",s.dataset.value)})},syncTabIndex({context:e,scope:t}){H(()=>{let n=e.get("value");if(!n)return;let r=dC(t,n);if(!r)return;Ir(r).length>0?r.removeAttribute("tabindex"):r.setAttribute("tabindex","0")})},cleanupObserver({refs:e}){let t=e.get("indicatorCleanup");t&&t()},setIndicatorRect({context:e,event:t,scope:n}){var o;let r=(o=t.id)!=null?o:e.get("value");!Pd(n)||!r||!ms(n,r)||e.set("indicatorRect",mC(n,r))},syncSsr({context:e}){e.set("ssr",!1)},syncIndicatorRect({context:e,refs:t,scope:n}){let r=t.get("indicatorCleanup");if(r&&r(),!Pd(n))return;let s=()=>{let l=ms(n,e.get("value"));if(!l)return;let c=Vd(l);e.set("indicatorRect",u=>he(u,c)?u:c)};s();let o=dr(n),a=Bn(...o.map(l=>Ja.observe(l,s)));t.set("indicatorCleanup",a)},navigateIfNeeded({context:e,prop:t,scope:n}){var s;let r=e.get("value");if(!r)return;let i=ms(n,r);We(i)&&((s=t("navigate"))==null||s({value:r,node:i,href:i.href}))}}}}),EC=G()(["activationMode","composite","deselectable","dir","getRootNode","id","ids","loopFocus","navigate","onFocusChange","onValueChange","orientation","translations","value","defaultValue"]),yO=B(EC),CC=G()(["disabled","value"]),bO=B(CC),IC=G()(["value"]),EO=B(IC),TC=class extends te{initMachine(e){return new ee(bC,e)}initApi(){return vC(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="tabs"][data-part="root"]');if(!e)return;this.spreadProps(e,this.api.getRootProps());let t=e.querySelector('[data-scope="tabs"][data-part="list"]');if(!t)return;this.spreadProps(t,this.api.getListProps());let n=this.el.getAttribute("data-items"),r=n?JSON.parse(n):[],i=t.querySelectorAll('[data-scope="tabs"][data-part="trigger"]');for(let o=0;o{var o,a;let i=x(e,"onValueChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,value:(o=r.value)!=null?o:null});let s=x(e,"onValueChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,value:(a=r.value)!=null?a:null}}))},onFocusChange:r=>{var o,a;let i=x(e,"onFocusChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,value:(o=r.focusedValue)!=null?o:null});let s=x(e,"onFocusChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,value:(a=r.focusedValue)!=null?a:null}}))}}));n.init(),this.tabs=n,this.onSetValue=r=>{let{value:i}=r.detail;n.api.setValue(i)},e.addEventListener("phx:tabs:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("tabs_set_value",r=>{let i=r.tabs_id;i&&i!==e.id||n.api.setValue(r.value)})),this.handlers.push(this.handleEvent("tabs_value",()=>{this.pushEvent("tabs_value_response",{value:n.api.value})})),this.handlers.push(this.handleEvent("tabs_focused_value",()=>{this.pushEvent("tabs_focused_value_response",{value:n.api.focusedValue})}))},updated(){var e;(e=this.tabs)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{value:x(this.el,"value")}:{defaultValue:x(this.el,"defaultValue")}),{orientation:x(this.el,"orientation",["horizontal","vertical"]),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:tabs:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.tabs)==null||e.destroy()}}});var _d={};Oe(_d,{Toast:()=>jC});function ga(e,t){var n;return(n=e!=null?e:Ld[t])!=null?n:Ld.DEFAULT}function xC(e,t){var v;let{prop:n,computed:r,context:i}=e,{offsets:s,gap:o}=n("store").attrs,a=i.get("heights"),l=VC(s),c=n("dir")==="rtl",u=t.replace("-start",c?"-right":"-left").replace("-end",c?"-left":"-right"),h=u.includes("right"),p=u.includes("left"),d={position:"fixed",pointerEvents:r("count")>0?void 0:"none",display:"flex",flexDirection:"column","--gap":`${o}px`,"--first-height":`${((v=a[0])==null?void 0:v.height)||0}px`,"--viewport-offset-left":l.left,"--viewport-offset-right":l.right,"--viewport-offset-top":l.top,"--viewport-offset-bottom":l.bottom,zIndex:Ra},g="center";if(h&&(g="flex-end"),p&&(g="flex-start"),d.alignItems=g,u.includes("top")){let b=l.top;d.top=`max(env(safe-area-inset-top, 0px), ${b})`}if(u.includes("bottom")){let b=l.bottom;d.bottom=`max(env(safe-area-inset-bottom, 0px), ${b})`}if(!u.includes("left")){let b=l.right;d.insetInlineEnd=`calc(env(safe-area-inset-right, 0px) + ${b})`}if(!u.includes("right")){let b=l.left;d.insetInlineStart=`calc(env(safe-area-inset-left, 0px) + ${b})`}return d}function kC(e,t){let{prop:n,context:r,computed:i}=e,s=n("parent"),o=s.computed("placement"),{gap:a}=s.prop("store").attrs,[l]=o.split("-"),c=r.get("mounted"),u=r.get("remainingTime"),h=i("height"),p=i("frontmost"),d=!p,g=!n("stacked"),v=n("stacked"),V=n("type")==="loading"?Number.MAX_SAFE_INTEGER:u,S=i("heightIndex")*a+i("heightBefore"),E={position:"absolute",pointerEvents:"auto","--opacity":"0","--remove-delay":`${n("removeDelay")}ms`,"--duration":`${V}ms`,"--initial-height":`${h}px`,"--offset":`${S}px`,"--index":n("index"),"--z-index":i("zIndex"),"--lift-amount":"calc(var(--lift) * var(--gap))","--y":"100%","--x":"0"},f=C=>Object.assign(E,C);return l==="top"?f({top:"0","--sign":"-1","--y":"-100%","--lift":"1"}):l==="bottom"&&f({bottom:"0","--sign":"1","--y":"100%","--lift":"-1"}),c&&(f({"--y":"0","--opacity":"1"}),v&&f({"--y":"calc(var(--lift) * var(--offset))","--height":"var(--initial-height)"})),t||f({"--opacity":"0",pointerEvents:"none"}),d&&g&&(f({"--base-scale":"var(--index) * 0.05 + 1","--y":"calc(var(--lift-amount) * var(--index))","--scale":"calc(-1 * var(--base-scale))","--height":"var(--first-height)"}),t||f({"--y":"calc(var(--sign) * 40%)"})),d&&v&&!t&&f({"--y":"calc(var(--lift) * var(--offset) + var(--lift) * -100%)"}),p&&!t&&f({"--y":"calc(var(--lift) * -100%)"}),E}function NC(e,t){let{computed:n}=e,r={position:"absolute",inset:"0",scale:"1 2",pointerEvents:t?"none":"auto"},i=s=>Object.assign(r,s);return n("frontmost")&&!t&&i({height:"calc(var(--initial-height) + 80%)"}),r}function AC(){return{position:"absolute",left:"0",height:"calc(var(--gap) + 2px)",bottom:"100%",width:"100%"}}function RC(e,t){let{context:n,prop:r,send:i,refs:s,computed:o}=e;return{getCount(){return n.get("toasts").length},getToasts(){return n.get("toasts")},getGroupProps(a={}){let{label:l="Notifications"}=a,{hotkey:c}=r("store").attrs,u=c.join("+").replace(/Key/g,"").replace(/Digit/g,""),h=o("placement"),[p,d="center"]=h.split("-");return t.element(y(m({},hr.group.attrs),{dir:r("dir"),tabIndex:-1,"aria-label":`${h} ${l} ${u}`,id:PC(h),"data-placement":h,"data-side":p,"data-align":d,"aria-live":"polite",role:"region",style:xC(e,h),onMouseEnter(){s.get("ignoreMouseTimer").isActive()||i({type:"REGION.POINTER_ENTER",placement:h})},onMouseMove(){s.get("ignoreMouseTimer").isActive()||i({type:"REGION.POINTER_ENTER",placement:h})},onMouseLeave(){s.get("ignoreMouseTimer").isActive()||i({type:"REGION.POINTER_LEAVE",placement:h})},onFocus(g){i({type:"REGION.FOCUS",target:g.relatedTarget})},onBlur(g){s.get("isFocusWithin")&&!pe(g.currentTarget,g.relatedTarget)&&queueMicrotask(()=>i({type:"REGION.BLUR"}))}}))},subscribe(a){return r("store").subscribe(()=>a(n.get("toasts")))}}}function $C(e,t){let{state:n,send:r,prop:i,scope:s,context:o,computed:a}=e,l=n.hasTag("visible"),c=n.hasTag("paused"),u=o.get("mounted"),h=a("frontmost"),p=i("parent").computed("placement"),d=i("type"),g=i("stacked"),v=i("title"),b=i("description"),V=i("action"),[S,E="center"]=p.split("-");return{type:d,title:v,description:b,placement:p,visible:l,paused:c,closable:!!i("closable"),pause(){r({type:"PAUSE"})},resume(){r({type:"RESUME"})},dismiss(){r({type:"DISMISS",src:"programmatic"})},getRootProps(){return t.element(y(m({},hr.root.attrs),{dir:i("dir"),id:$d(s),"data-state":l?"open":"closed","data-type":d,"data-placement":p,"data-align":E,"data-side":S,"data-mounted":T(u),"data-paused":T(c),"data-first":T(h),"data-sibling":T(!h),"data-stack":T(g),"data-overlap":T(!g),role:"status","aria-atomic":"true","aria-describedby":b?Dd(s):void 0,"aria-labelledby":v?Rd(s):void 0,tabIndex:0,style:kC(e,l),onKeyDown(f){f.defaultPrevented||f.key=="Escape"&&(r({type:"DISMISS",src:"keyboard"}),f.preventDefault())}}))},getGhostBeforeProps(){return t.element({"data-ghost":"before",style:NC(e,l)})},getGhostAfterProps(){return t.element({"data-ghost":"after",style:AC()})},getTitleProps(){return t.element(y(m({},hr.title.attrs),{id:Rd(s)}))},getDescriptionProps(){return t.element(y(m({},hr.description.attrs),{id:Dd(s)}))},getActionTriggerProps(){return t.button(y(m({},hr.actionTrigger.attrs),{type:"button",onClick(f){var C;f.defaultPrevented||((C=V==null?void 0:V.onClick)==null||C.call(V),r({type:"DISMISS",src:"user"}))}}))},getCloseTriggerProps(){return t.button(y(m({id:wC(s)},hr.closeTrigger.attrs),{type:"button","aria-label":"Dismiss notification",onClick(f){f.defaultPrevented||r({type:"DISMISS",src:"user"})}}))}}}function Fd(e,t){let{id:n,height:r}=t;e.context.set("heights",i=>i.find(o=>o.id===n)?i.map(o=>o.id===n?y(m({},o),{height:r}):o):[{id:n,height:r},...i])}function GC(e={}){let t=BC(e,{placement:"bottom",overlap:!1,max:24,gap:16,offsets:"1rem",hotkey:["altKey","KeyT"],removeDelay:200,pauseOnPageIdle:!0}),n=[],r=[],i=new Set,s=[],o=L=>(n.push(L),()=>{let M=n.indexOf(L);n.splice(M,1)}),a=L=>(n.forEach(M=>M(L)),L),l=L=>{if(r.length>=t.max){s.push(L);return}a(L),r.unshift(L)},c=()=>{for(;s.length>0&&r.length{var q;let M=(q=L.id)!=null?q:`toast:${js()}`,j=r.find(J=>J.id===M);return i.has(M)&&i.delete(M),j?r=r.map(J=>J.id===M?a(y(m(m({},J),L),{id:M})):J):l(y(m({id:M,duration:t.duration,removeDelay:t.removeDelay,type:"info"},L),{stacked:!t.overlap,gap:t.gap})),M},h=L=>(i.add(L),L?(n.forEach(M=>M({id:L,dismiss:!0})),r=r.filter(M=>M.id!==L),c()):(r.forEach(M=>{n.forEach(j=>j({id:M.id,dismiss:!0}))}),r=[],s=[]),L);return{attrs:t,subscribe:o,create:u,update:(L,M)=>u(m({id:L},M)),remove:h,dismiss:L=>{L!=null?r=r.map(M=>M.id===L?a(y(m({},M),{message:"DISMISS"})):M):r=r.map(M=>a(y(m({},M),{message:"DISMISS"})))},error:L=>u(y(m({},L),{type:"error"})),success:L=>u(y(m({},L),{type:"success"})),info:L=>u(y(m({},L),{type:"info"})),warning:L=>u(y(m({},L),{type:"warning"})),loading:L=>u(y(m({},L),{type:"loading"})),getVisibleToasts:()=>r.filter(L=>!i.has(L.id)),getCount:()=>r.length,promise:(L,M,j={})=>{if(!M||!M.loading){wt("[zag-js > toast] toaster.promise() requires at least a 'loading' option to be specified");return}let q=u(y(m(m({},j),M.loading),{promise:L,type:"loading"})),J=!0,W,ge=St(L).then(X=>Ee(null,null,function*(){if(W=["resolve",X],UC(X)&&!X.ok){J=!1;let ue=St(M.error,`HTTP Error! status: ${X.status}`);u(y(m(m({},j),ue),{id:q,type:"error"}))}else if(M.success!==void 0){J=!1;let ue=St(M.success,X);u(y(m(m({},j),ue),{id:q,type:"success"}))}})).catch(X=>Ee(null,null,function*(){if(W=["reject",X],M.error!==void 0){J=!1;let ue=St(M.error,X);u(y(m(m({},j),ue),{id:q,type:"error"}))}})).finally(()=>{var X;J&&h(q),(X=M.finally)==null||X.call(M)});return{id:q,unwrap:()=>new Promise((X,ue)=>ge.then(()=>W[0]==="reject"?ue(W[1]):X(W[1])).catch(ue))}},pause:L=>{L!=null?r=r.map(M=>M.id===L?a(y(m({},M),{message:"PAUSE"})):M):r=r.map(M=>a(y(m({},M),{message:"PAUSE"})))},resume:L=>{L!=null?r=r.map(M=>M.id===L?a(y(m({},M),{message:"RESUME"})):M):r=r.map(M=>a(y(m({},M),{message:"RESUME"})))},isVisible:L=>!i.has(L)&&!!r.find(M=>M.id===L),isDismissed:L=>i.has(L),expand:()=>{r=r.map(L=>a(y(m({},L),{stacked:!0})))},collapse:()=>{r=r.map(L=>a(y(m({},L),{stacked:!1})))}}}function YC(e,t){var s,o,a;let n=(s=t==null?void 0:t.id)!=null?s:rn(e,"toast"),r=(a=t==null?void 0:t.store)!=null?a:GC({placement:(o=t==null?void 0:t.placement)!=null?o:"bottom",overlap:t==null?void 0:t.overlap,max:t==null?void 0:t.max,gap:t==null?void 0:t.gap,offsets:t==null?void 0:t.offsets,pauseOnPageIdle:t==null?void 0:t.pauseOnPageIdle}),i=new KC(e,{id:n,store:r});return i.init(),qC.set(n,i),fa.set(n,r),e.dataset.toastGroup="true",e.dataset.toastGroupId=n,{group:i,store:r}}function jr(e){if(e)return fa.get(e);let t=document.querySelector("[data-toast-group]");if(!t)return;let n=t.dataset.toastGroupId||t.id;return n?fa.get(n):void 0}var SC,hr,PC,Nd,$d,Ad,Rd,Dd,wC,Ld,VC,DC,LC,FC,MC,_C,HC,BC,UC,Md,qC,fa,WC,KC,jC,Hd=fe(()=>{"use strict";gn();me();SC=Z("toast").parts("group","root","title","description","actionTrigger","closeTrigger"),hr=SC.build(),PC=e=>`toast-group:${e}`,Nd=(e,t)=>e.getById(`toast-group:${t}`),$d=e=>`toast:${e.id}`,Ad=e=>e.getById($d(e)),Rd=e=>`toast:${e.id}:title`,Dd=e=>`toast:${e.id}:description`,wC=e=>`toast${e.id}:close`,Ld={info:5e3,error:5e3,success:2e3,loading:1/0,DEFAULT:5e3};VC=e=>typeof e=="string"?{left:e,right:e,bottom:e,top:e}:e;({guards:DC,createMachine:LC}=Wn()),{and:FC}=DC,MC=LC({props({props:e}){return y(m({dir:"ltr",id:js()},e),{store:e.store})},initialState({prop:e}){return e("store").attrs.overlap?"overlap":"stack"},refs(){return{lastFocusedEl:null,isFocusWithin:!1,isPointerWithin:!1,ignoreMouseTimer:$s.create(),dismissableCleanup:void 0}},context({bindable:e}){return{toasts:e(()=>({defaultValue:[],sync:!0,hash:t=>t.map(n=>n.id).join(",")})),heights:e(()=>({defaultValue:[],sync:!0}))}},computed:{count:({context:e})=>e.get("toasts").length,overlap:({prop:e})=>e("store").attrs.overlap,placement:({prop:e})=>e("store").attrs.placement},effects:["subscribeToStore","trackDocumentVisibility","trackHotKeyPress"],watch({track:e,context:t,action:n}){e([()=>t.hash("toasts")],()=>{queueMicrotask(()=>{n(["collapsedIfEmpty","setDismissableBranch"])})})},exit:["clearDismissableBranch","clearLastFocusedEl","clearMouseEventTimer"],on:{"DOC.HOTKEY":{actions:["focusRegionEl"]},"REGION.BLUR":[{guard:FC("isOverlapping","isPointerOut"),target:"overlap",actions:["collapseToasts","resumeToasts","restoreFocusIfPointerOut"]},{guard:"isPointerOut",target:"stack",actions:["resumeToasts","restoreFocusIfPointerOut"]},{actions:["clearFocusWithin"]}],"TOAST.REMOVE":{actions:["removeToast","removeHeight","ignoreMouseEventsTemporarily"]},"TOAST.PAUSE":{actions:["pauseToasts"]}},states:{stack:{on:{"REGION.POINTER_LEAVE":[{guard:"isOverlapping",target:"overlap",actions:["clearPointerWithin","resumeToasts","collapseToasts"]},{actions:["clearPointerWithin","resumeToasts"]}],"REGION.OVERLAP":{target:"overlap",actions:["collapseToasts"]},"REGION.FOCUS":{actions:["setLastFocusedEl","pauseToasts"]},"REGION.POINTER_ENTER":{actions:["setPointerWithin","pauseToasts"]}}},overlap:{on:{"REGION.STACK":{target:"stack",actions:["expandToasts"]},"REGION.POINTER_ENTER":{target:"stack",actions:["setPointerWithin","pauseToasts","expandToasts"]},"REGION.FOCUS":{target:"stack",actions:["setLastFocusedEl","pauseToasts","expandToasts"]}}}},implementations:{guards:{isOverlapping:({computed:e})=>e("overlap"),isPointerOut:({refs:e})=>!e.get("isPointerWithin")},effects:{subscribeToStore({context:e,prop:t}){let n=t("store");return e.set("toasts",n.getVisibleToasts()),n.subscribe(r=>{if(r.dismiss){e.set("toasts",i=>i.filter(s=>s.id!==r.id));return}e.set("toasts",i=>{let s=i.findIndex(o=>o.id===r.id);return s!==-1?[...i.slice(0,s),m(m({},i[s]),r),...i.slice(s+1)]:[r,...i]})})},trackHotKeyPress({prop:e,send:t}){return ie(document,"keydown",r=>{let{hotkey:i}=e("store").attrs;i.every(o=>r[o]||r.code===o)&&t({type:"DOC.HOTKEY"})},{capture:!0})},trackDocumentVisibility({prop:e,send:t,scope:n}){let{pauseOnPageIdle:r}=e("store").attrs;if(!r)return;let i=n.getDoc();return ie(i,"visibilitychange",()=>{let s=i.visibilityState==="hidden";t({type:s?"PAUSE_ALL":"RESUME_ALL"})})}},actions:{setDismissableBranch({refs:e,context:t,computed:n,scope:r}){var c;let i=t.get("toasts"),s=n("placement"),o=i.length>0;if(!o){(c=e.get("dismissableCleanup"))==null||c();return}if(o&&e.get("dismissableCleanup"))return;let l=mc(()=>Nd(r,s),{defer:!0});e.set("dismissableCleanup",l)},clearDismissableBranch({refs:e}){var t;(t=e.get("dismissableCleanup"))==null||t()},focusRegionEl({scope:e,computed:t}){queueMicrotask(()=>{var n;(n=Nd(e,t("placement")))==null||n.focus()})},pauseToasts({prop:e}){e("store").pause()},resumeToasts({prop:e}){e("store").resume()},expandToasts({prop:e}){e("store").expand()},collapseToasts({prop:e}){e("store").collapse()},removeToast({prop:e,event:t}){e("store").remove(t.id)},removeHeight({event:e,context:t}){(e==null?void 0:e.id)!=null&&queueMicrotask(()=>{t.set("heights",n=>n.filter(r=>r.id!==e.id))})},collapsedIfEmpty({send:e,computed:t}){!t("overlap")||t("count")>1||e({type:"REGION.OVERLAP"})},setLastFocusedEl({refs:e,event:t}){e.get("isFocusWithin")||!t.target||(e.set("isFocusWithin",!0),e.set("lastFocusedEl",t.target))},restoreFocusIfPointerOut({refs:e}){var t;!e.get("lastFocusedEl")||e.get("isPointerWithin")||((t=e.get("lastFocusedEl"))==null||t.focus({preventScroll:!0}),e.set("lastFocusedEl",null),e.set("isFocusWithin",!1))},setPointerWithin({refs:e}){e.set("isPointerWithin",!0)},clearPointerWithin({refs:e}){var t;e.set("isPointerWithin",!1),e.get("lastFocusedEl")&&!e.get("isFocusWithin")&&((t=e.get("lastFocusedEl"))==null||t.focus({preventScroll:!0}),e.set("lastFocusedEl",null))},clearFocusWithin({refs:e}){e.set("isFocusWithin",!1)},clearLastFocusedEl({refs:e}){var t;e.get("lastFocusedEl")&&((t=e.get("lastFocusedEl"))==null||t.focus({preventScroll:!0}),e.set("lastFocusedEl",null),e.set("isFocusWithin",!1))},ignoreMouseEventsTemporarily({refs:e}){e.get("ignoreMouseTimer").request()},clearMouseEventTimer({refs:e}){e.get("ignoreMouseTimer").cancel()}}}});({not:_C}=ye()),HC={props({props:e}){return yi(e,["id","type","parent","removeDelay"],"toast"),y(m({closable:!0},e),{duration:ga(e.duration,e.type)})},initialState({prop:e}){return e("type")==="loading"||e("duration")===1/0?"visible:persist":"visible"},context({prop:e,bindable:t}){return{remainingTime:t(()=>({defaultValue:ga(e("duration"),e("type"))})),createdAt:t(()=>({defaultValue:Date.now()})),mounted:t(()=>({defaultValue:!1})),initialHeight:t(()=>({defaultValue:0}))}},refs(){return{closeTimerStartTime:Date.now(),lastCloseStartTimerStartTime:0}},computed:{zIndex:({prop:e})=>{let t=e("parent").context.get("toasts"),n=t.findIndex(r=>r.id===e("id"));return t.length-n},height:({prop:e})=>{var r;let n=e("parent").context.get("heights").find(i=>i.id===e("id"));return(r=n==null?void 0:n.height)!=null?r:0},heightIndex:({prop:e})=>e("parent").context.get("heights").findIndex(n=>n.id===e("id")),frontmost:({prop:e})=>e("index")===0,heightBefore:({prop:e})=>{let t=e("parent").context.get("heights"),n=t.findIndex(r=>r.id===e("id"));return t.reduce((r,i,s)=>s>=n?r:r+i.height,0)},shouldPersist:({prop:e})=>e("type")==="loading"||e("duration")===1/0},watch({track:e,prop:t,send:n}){e([()=>t("message")],()=>{let r=t("message");r&&n({type:r,src:"programmatic"})}),e([()=>t("type"),()=>t("duration")],()=>{n({type:"UPDATE"})})},on:{UPDATE:[{guard:"shouldPersist",target:"visible:persist",actions:["resetCloseTimer"]},{target:"visible:updating",actions:["resetCloseTimer"]}],MEASURE:{actions:["measureHeight"]}},entry:["setMounted","measureHeight","invokeOnVisible"],effects:["trackHeight"],states:{"visible:updating":{tags:["visible","updating"],effects:["waitForNextTick"],on:{SHOW:{target:"visible"}}},"visible:persist":{tags:["visible","paused"],on:{RESUME:{guard:_C("isLoadingType"),target:"visible",actions:["setCloseTimer"]},DISMISS:{target:"dismissing"}}},visible:{tags:["visible"],effects:["waitForDuration"],on:{DISMISS:{target:"dismissing"},PAUSE:{target:"visible:persist",actions:["syncRemainingTime"]}}},dismissing:{entry:["invokeOnDismiss"],effects:["waitForRemoveDelay"],on:{REMOVE:{target:"unmounted",actions:["notifyParentToRemove"]}}},unmounted:{entry:["invokeOnUnmount"]}},implementations:{effects:{waitForRemoveDelay({prop:e,send:t}){return Un(()=>{t({type:"REMOVE",src:"timer"})},e("removeDelay"))},waitForDuration({send:e,context:t,computed:n}){if(!n("shouldPersist"))return Un(()=>{e({type:"DISMISS",src:"timer"})},t.get("remainingTime"))},waitForNextTick({send:e}){return Un(()=>{e({type:"SHOW",src:"timer"})},0)},trackHeight({scope:e,prop:t}){let n;return H(()=>{let r=Ad(e);if(!r)return;let i=()=>{let a=r.style.height;r.style.height="auto";let l=r.getBoundingClientRect().height;r.style.height=a;let c={id:t("id"),height:l};Fd(t("parent"),c)},s=e.getWin(),o=new s.MutationObserver(i);o.observe(r,{childList:!0,subtree:!0,characterData:!0}),n=()=>o.disconnect()}),()=>n==null?void 0:n()}},guards:{isLoadingType:({prop:e})=>e("type")==="loading",shouldPersist:({computed:e})=>e("shouldPersist")},actions:{setMounted({context:e}){H(()=>{e.set("mounted",!0)})},measureHeight({scope:e,prop:t,context:n}){queueMicrotask(()=>{let r=Ad(e);if(!r)return;let i=r.style.height;r.style.height="auto";let s=r.getBoundingClientRect().height;r.style.height=i,n.set("initialHeight",s);let o={id:t("id"),height:s};Fd(t("parent"),o)})},setCloseTimer({refs:e}){e.set("closeTimerStartTime",Date.now())},resetCloseTimer({context:e,refs:t,prop:n}){t.set("closeTimerStartTime",Date.now()),e.set("remainingTime",ga(n("duration"),n("type")))},syncRemainingTime({context:e,refs:t}){e.set("remainingTime",n=>{let r=t.get("closeTimerStartTime"),i=Date.now()-r;return t.set("lastCloseStartTimerStartTime",Date.now()),n-i})},notifyParentToRemove({prop:e}){e("parent").send({type:"TOAST.REMOVE",id:e("id")})},invokeOnDismiss({prop:e,event:t}){var n;(n=e("onStatusChange"))==null||n({status:"dismissing",src:t.src})},invokeOnUnmount({prop:e}){var t;(t=e("onStatusChange"))==null||t({status:"unmounted"})},invokeOnVisible({prop:e}){var t;(t=e("onStatusChange"))==null||t({status:"visible"})}}}};BC=(e,t)=>m(m({},t),Gn(e));UC=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Md={connect:RC,machine:MC},qC=new Map,fa=new Map,WC=class extends te{constructor(t,n){super(t,n);U(this,"parts");U(this,"duration");U(this,"destroy",()=>{this.machine.stop(),this.el.remove()});this.duration=n.duration,this.el.setAttribute("data-scope","toast"),this.el.setAttribute("data-part","root"),this.el.innerHTML=` +`+new s.XMLSerializer().serializeToString(l),h="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(u);if(n==="image/svg+xml")return Promise.resolve(h).then(b=>(l.remove(),b));let p=s.devicePixelRatio||1,d=o.createElement("canvas"),g=new s.Image;g.src=h,d.width=a.width*p,d.height=a.height*p;let v=d.getContext("2d");return(n==="image/jpeg"||i)&&(v.fillStyle=i||"white",v.fillRect(0,0,d.width,d.height)),new Promise(b=>{g.onload=()=>{v==null||v.drawImage(g,0,0,d.width,d.height),b(d.toDataURL(n,r)),l.remove()}})}function Rh(){var t;let e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}function Dh(){let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Bh(e){var t,n,r,i;return(i=(t=e.composedPath)==null?void 0:t.call(e))!=null?i:(r=(n=e.nativeEvent)==null?void 0:n.composedPath)==null?void 0:r.call(n)}function K(e){var n;let t=Bh(e);return(n=t==null?void 0:t[0])!=null?n:e.target}function sn(e){let t=e.currentTarget;if(!t||!t.matches("a[href], button[type='submit'], input[type='submit']"))return!1;let r=e.button===1,i=Gh(e);return r||i}function Er(e){let t=e.currentTarget;if(!t)return!1;let n=t.localName;return e.altKey?n==="a"||n==="button"&&t.type==="submit"||n==="input"&&t.type==="submit":!1}function Vt(e){return Ms(e).isComposing||e.keyCode===229}function Gh(e){return Nn()?e.metaKey:e.ctrlKey}function Ba(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey}function Ga(e){return e.pointerType===""&&e.isTrusted?!0:Hh()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function ve(e,t={}){var o;let{dir:n="ltr",orientation:r="horizontal"}=t,i=e.key;return i=(o=qh[i])!=null?o:i,n==="rtl"&&r==="horizontal"&&i in Ia&&(i=Ia[i]),i}function Ms(e){var t;return(t=e.nativeEvent)!=null?t:e}function Pt(e,t="client"){let n=Uh(e)?e.touches[0]||e.changedTouches[0]:e;return{x:n[`${t}X`],y:n[`${t}Y`]}}function Ua(e,t){var s;let{type:n="HTMLInputElement",property:r="value"}=t,i=oe(e)[n].prototype;return(s=Object.getOwnPropertyDescriptor(i,r))!=null?s:{}}function Wh(e){if(e.localName==="input")return"HTMLInputElement";if(e.localName==="textarea")return"HTMLTextAreaElement";if(e.localName==="select")return"HTMLSelectElement"}function xt(e,t,n="value"){var i;if(!e)return;let r=Wh(e);r&&((i=Ua(e,{type:r,property:n}).set)==null||i.call(e,t)),e.setAttribute(n,t)}function Cr(e,t){var r;if(!e)return;(r=Ua(e,{type:"HTMLInputElement",property:"checked"}).set)==null||r.call(e,t),t?e.setAttribute("checked",""):e.removeAttribute("checked")}function ui(e,t){let{checked:n,bubbles:r=!0}=t;if(!e)return;let i=oe(e);e instanceof i.HTMLInputElement&&(Cr(e,n),e.dispatchEvent(new i.Event("click",{bubbles:r})))}function Kh(e){return Yh(e)?e.form:e.closest("form")}function Yh(e){return e.matches("textarea, input, select, button")}function jh(e,t){if(!e)return;let n=Kh(e),r=i=>{i.defaultPrevented||t()};return n==null||n.addEventListener("reset",r,{passive:!0}),()=>n==null?void 0:n.removeEventListener("reset",r)}function Xh(e,t){let n=e==null?void 0:e.closest("fieldset");if(!n)return;t(n.disabled);let r=oe(n),i=new r.MutationObserver(()=>t(n.disabled));return i.observe(n,{attributes:!0,attributeFilter:["disabled"]}),()=>i.disconnect()}function Rn(e,t){if(!e)return;let{onFieldsetDisabledChange:n,onFormReset:r}=t,i=[jh(e,r),Xh(e,n)];return()=>i.forEach(s=>s==null?void 0:s())}function Wa(e){let t=e.getAttribute("tabindex");return t?parseInt(t,10):NaN}function Qh(e,t){if(!t)return null;if(t===!0)return e.shadowRoot||null;let n=t(e);return(n===!0?e.shadowRoot:n)||null}function Ka(e,t,n){let r=[...e],i=[...e],s=new Set,o=new Map;e.forEach((l,c)=>o.set(l,c));let a=0;for(;a{o.set(d,p+g)});for(let d=p+u.length;d{o.set(d,p+g)})}i.push(...u)}}return r}function Qe(e){return!ce(e)||e.closest("[inert]")?!1:e.matches(di)&&Ph(e)}function on(e,t={}){if(!e)return[];let{includeContainer:n,getShadowRoot:r}=t,i=Array.from(e.querySelectorAll(di));n&&Bt(e)&&i.unshift(e);let s=[];for(let o of i)if(Bt(o)){if(qa(o)&&o.contentDocument){let a=o.contentDocument.body;s.push(...on(a,{getShadowRoot:r}));continue}s.push(o)}if(r){let o=Ka(s,r,Bt);return!o.length&&n?i:o}return!s.length&&n?i:s}function Bt(e){return ce(e)&&e.tabIndex>0?!0:Qe(e)&&!zh(e)}function eg(e,t={}){let n=on(e,t),r=n[0]||null,i=n[n.length-1]||null;return[r,i]}function Dn(e){return e.tabIndex<0&&(Zh.test(e.localName)||Ut(e))&&!Jh(e)?0:e.tabIndex}function hi(e){let{root:t,getInitialEl:n,filter:r,enabled:i=!0}=e;if(!i)return;let s=null;if(s||(s=typeof n=="function"?n():n),s||(s=t==null?void 0:t.querySelector("[data-autofocus],[autofocus]")),!s){let o=on(t);s=r?o.filter(r)[0]:o[0]}return s||t||void 0}function gi(e){let t=e.currentTarget;if(!t)return!1;let[n,r]=eg(t);return!(ii(n)&&e.shiftKey||ii(r)&&!e.shiftKey||!n&&!r)}function H(e){let t=$s.create();return t.request(e),t.cleanup}function an(e){let t=new Set;function n(r){let i=globalThis.requestAnimationFrame(r);t.add(()=>globalThis.cancelAnimationFrame(i))}return n(()=>n(e)),function(){t.forEach(i=>i())}}function tg(e,t,n){let r=H(()=>{e.removeEventListener(t,i,!0),n()}),i=()=>{r(),n()};return e.addEventListener(t,i,{once:!0,capture:!0}),r}function ng(e,t){if(!e)return;let{attributes:n,callback:r}=t,i=e.ownerDocument.defaultView||window,s=new i.MutationObserver(o=>{for(let a of o)a.type==="attributes"&&a.attributeName&&n.includes(a.attributeName)&&r(a)});return s.observe(e,{attributes:!0,attributeFilter:n}),()=>s.disconnect()}function Ln(e,t){let{defer:n}=t,r=n?H:s=>s(),i=[];return i.push(r(()=>{let s=typeof e=="function"?e():e;i.push(ng(s,t))})),()=>{i.forEach(s=>s==null?void 0:s())}}function rg(e,t){let{callback:n}=t;if(!e)return;let r=e.ownerDocument.defaultView||window,i=new r.MutationObserver(n);return i.observe(e,{childList:!0,subtree:!0}),()=>i.disconnect()}function ja(e,t){let{defer:n}=t,r=n?H:s=>s(),i=[];return i.push(r(()=>{let s=typeof e=="function"?e():e;i.push(rg(s,t))})),()=>{i.forEach(s=>s==null?void 0:s())}}function Fn(e){let t=()=>{let n=oe(e);e.dispatchEvent(new n.MouseEvent("click"))};_h()?tg(e,"keyup",t):queueMicrotask(t)}function fi(e){let t=xh(e);return Th(t)?we(t).body:ce(t)&&Xa(t)?t:fi(t)}function Xa(e){let t=oe(e),{overflow:n,overflowX:r,overflowY:i,display:s}=t.getComputedStyle(e);return ig.test(n+i+r)&&!sg.has(s)}function og(e){return e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth}function ln(e,t){let i=t||{},{rootEl:n}=i,r=ze(i,["rootEl"]);!e||!n||!Xa(n)||!og(n)||e.scrollIntoView(r)}function _s(e,t){let{left:n,top:r,width:i,height:s}=t.getBoundingClientRect(),o={x:e.x-n,y:e.y-r},a={x:Ca(o.x/i),y:Ca(o.y/s)};function l(c={}){let{dir:u="ltr",orientation:h="horizontal",inverted:p}=c,d=typeof p=="object"?p.x:p,g=typeof p=="object"?p.y:p;return h==="horizontal"?u==="rtl"||d?1-a.x:a.x:g?1-a.y:a.y}return{offset:o,percent:a,getPercentValue:l}}function ag(e={}){let{target:t,doc:n}=e,r=n!=null?n:document,i=r.documentElement;return br()?(xn==="default"&&(xs=i.style.webkitUserSelect,i.style.webkitUserSelect="none"),xn="disabled"):t&&(ei.set(t,t.style.userSelect),t.style.userSelect="none"),()=>Hs({target:t,doc:r})}function Hs(e={}){let{target:t,doc:n}=e,i=(n!=null?n:document).documentElement;if(br()){if(xn!=="disabled")return;xn="restoring",setTimeout(()=>{an(()=>{xn==="restoring"&&(i.style.webkitUserSelect==="none"&&(i.style.webkitUserSelect=xs||""),xs="",xn="default")})},300)}else if(t&&ei.has(t)){let s=ei.get(t);t.style.userSelect==="none"&&(t.style.userSelect=s!=null?s:""),t.getAttribute("style")===""&&t.removeAttribute("style"),ei.delete(t)}}function Bs(e={}){let o=e,{defer:t,target:n}=o,r=ze(o,["defer","target"]),i=t?H:a=>a(),s=[];return s.push(i(()=>{let a=typeof n=="function"?n():n;s.push(ag(y(m({},r),{target:a})))})),()=>{s.forEach(a=>a==null?void 0:a())}}function Za(e,t){let{onPointerMove:n,onPointerUp:r}=t,i=a=>{let l=Pt(a),c=Math.sqrt(l.x**2+l.y**2),u=a.pointerType==="touch"?10:5;if(!(c{let l=Pt(a);r({point:l,event:a})},o=[ie(e,"pointermove",i,!1),ie(e,"pointerup",s,!1),ie(e,"pointercancel",s,!1),ie(e,"contextmenu",s,!1),Bs({doc:e})];return()=>{o.forEach(a=>a())}}function pi(e){let{pointerNode:t,keyboardNode:n=t,onPress:r,onPressStart:i,onPressEnd:s,isValidKey:o=S=>S.key==="Enter"}=e;if(!t)return Tt;let a=oe(t),l=Tt,c=Tt,u=Tt,h=S=>({point:Pt(S),event:S});function p(S){i==null||i(h(S))}function d(S){s==null||s(h(S))}let v=ie(t,"pointerdown",S=>{c();let f=ie(a,"pointerup",I=>{let w=K(I);pe(t,w)?r==null||r(h(I)):s==null||s(h(I))},{passive:!r,once:!0}),C=ie(a,"pointercancel",d,{passive:!s,once:!0});c=Ps(f,C),ii(n)&&S.pointerType==="mouse"&&S.preventDefault(),p(S)},{passive:!i}),b=ie(n,"focus",V);l=Ps(v,b);function V(){let S=I=>{if(!o(I))return;let w=P=>{if(!o(P))return;let N=new a.PointerEvent("pointerup"),R=h(N);r==null||r(R),s==null||s(R)};c(),c=ie(n,"keyup",w);let A=new a.PointerEvent("pointerdown");p(A)},E=()=>{let I=new a.PointerEvent("pointercancel");d(I)},f=ie(n,"keydown",S),C=ie(n,"blur",E);u=Ps(f,C)}return()=>{l(),c(),u()}}function dt(e,t){var n;return Array.from((n=e==null?void 0:e.querySelectorAll(t))!=null?n:[])}function Mn(e,t){var n;return(n=e==null?void 0:e.querySelector(t))!=null?n:null}function Us(e,t,n=Gs){return e.find(r=>n(r)===t)}function qs(e,t,n=Gs){let r=Us(e,t,n);return r?e.indexOf(r):-1}function $n(e,t,n=!0){let r=qs(e,t);return r=n?(r+1)%e.length:Math.min(r+1,e.length-1),e[r]}function _n(e,t,n=!0){let r=qs(e,t);return r===-1?n?e[e.length-1]:null:(r=n?(r-1+e.length)%e.length:Math.max(0,r-1),e[r])}function lg(e){let t=new WeakMap,n,r=new WeakMap,i=a=>n||(n=new a.ResizeObserver(l=>{for(let c of l){r.set(c.target,c);let u=t.get(c.target);if(u)for(let h of u)h(c)}}),n);return{observe:(a,l)=>{let c=t.get(a)||new Set;c.add(l),t.set(a,c);let u=oe(a);return i(u).observe(a,e),()=>{let h=t.get(a);h&&(h.delete(l),h.size===0&&(t.delete(a),i(u).unobserve(a)))}},unobserve:a=>{t.delete(a),n==null||n.unobserve(a)}}}function hg(e,t,n,r=Gs){let i=n?qs(e,n,r):-1,s=n?yh(e,i):e;return t.length===1&&(s=s.filter(a=>r(a)!==n)),s.find(a=>dg(ug(a),t))}function za(e,t,n){let r=e.getAttribute(t),i=r!=null;return r===n?Tt:(e.setAttribute(t,n),()=>{i?e.setAttribute(t,r):e.removeAttribute(t)})}function cn(e,t){if(!e)return Tt;let n=Object.keys(t).reduce((r,i)=>(r[i]=e.style.getPropertyValue(i),r),{});return gg(n,t)?Tt:(Object.assign(e.style,t),()=>{Object.assign(e.style,n),e.style.length===0&&e.removeAttribute("style")})}function Qa(e,t,n){if(!e)return Tt;let r=e.style.getPropertyValue(t);return r===n?Tt:(e.style.setProperty(t,n),()=>{e.style.setProperty(t,r),e.style.length===0&&e.removeAttribute("style")})}function gg(e,t){return Object.keys(e).every(n=>e[n]===t[n])}function fg(e,t){let{state:n,activeId:r,key:i,timeout:s=350,itemToId:o}=t,a=n.keysSoFar+i,c=a.length>1&&Array.from(a).every(g=>g===a[0])?a[0]:a,u=e.slice(),h=hg(u,c,r,o);function p(){clearTimeout(n.timer),n.timer=-1}function d(g){n.keysSoFar=g,p(),g!==""&&(n.timer=+setTimeout(()=>{d(""),p()},s))}return d(a),h}function pg(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey}function mg(e,t,n){let{signal:r}=t;return[new Promise((o,a)=>{let l=setTimeout(()=>{a(new Error(`Timeout of ${n}ms exceeded`))},n);r.addEventListener("abort",()=>{clearTimeout(l),a(new Error("Promise aborted"))}),e.then(c=>{r.aborted||(clearTimeout(l),o(c))}).catch(c=>{r.aborted||(clearTimeout(l),a(c))})}),()=>t.abort()]}function el(e,t){let{timeout:n,rootNode:r}=t,i=oe(r),s=we(r),o=new i.AbortController;return mg(new Promise(a=>{let l=e();if(l){a(l);return}let c=new i.MutationObserver(()=>{let u=e();u&&u.isConnected&&(c.disconnect(),a(u))});c.observe(s.body,{childList:!0,subtree:!0})}),o,n)}function Tr(e){return e==null?[]:Array.isArray(e)?e:[e]}function nl(e,t,n={}){let{step:r=1,loop:i=!0}=n,s=t+r,o=e.length,a=o-1;return t===-1?r>0?0:a:s<0?i?a:0:s>=o?i?0:t>o?o:t:s}function rl(e,t,n={}){return e[nl(e,t,n)]}function Ig(e,t,n={}){let{step:r=1,loop:i=!0}=n;return nl(e,t,{step:-r,loop:i})}function il(e,t,n={}){return e[Ig(e,t,n)]}function Ws(e,t){return e.reduce((n,r,i)=>{var s;return i%t===0?n.push([r]):(s=nt(n))==null||s.push(r),n},[])}function Ks(e,t){return e.reduce(([n,r],i)=>(t(i)?n.push(i):r.push(i),[n,r]),[[],[]])}function Ve(e,t,...n){var i;if(e in t){let s=t[e];return Ot(s)?s(...n):s}let r=new Error(`No matching key: ${JSON.stringify(e)} in ${JSON.stringify(Object.keys(t))}`);throw(i=Error.captureStackTrace)==null||i.call(Error,r,Ve),r}function Gn(e){if(!mr(e)||e===void 0)return e;let t=Reflect.ownKeys(e).filter(r=>typeof r=="string"),n={};for(let r of t){let i=e[r];i!==void 0&&(n[r]=Gn(i))}return n}function Rg(e,t){let n={},r={},i=new Set(t),s=Reflect.ownKeys(e);for(let o of s)i.has(o)?r[o]=e[o]:n[o]=e[o];return[r,n]}function Un(e,t){let n=new Dg(({deltaMs:r})=>{if(r>=t)return e(),!1});return n.start(),()=>n.stop()}function wt(...e){let t=e.length===1?e[0]:e[1];(e.length===2?e[0]:!0)&&console.warn(t)}function qn(e,t){if(e==null)throw new Error(t())}function yi(e,t,n){let r=[];for(let i of t)e[i]==null&&r.push(i);if(r.length>0)throw new Error(`[zag-js${n?` > ${n}`:""}] missing required props: ${r.join(", ")}`)}function hl(...e){let t={};for(let n of e){if(!n)continue;for(let i in t){if(i.startsWith("on")&&typeof t[i]=="function"&&typeof n[i]=="function"){t[i]=Bn(n[i],t[i]);continue}if(i==="className"||i==="class"){t[i]=Lg(t[i],n[i]);continue}if(i==="style"){t[i]=Mg(t[i],n[i]);continue}t[i]=n[i]!==void 0?n[i]:t[i]}for(let i in n)t[i]===void 0&&(t[i]=n[i]);let r=Object.getOwnPropertySymbols(n);for(let i of r)t[i]=n[i]}return t}function gl(e,t,n){let r=[],i;return s=>{var l;let o=e(s);return(o.length!==r.length||o.some((c,u)=>!he(r[u],c)))&&(r=o,i=t(o,s),(l=n==null?void 0:n.onChange)==null||l.call(n,i)),i}}function ye(){return{and:(...e)=>function(n){return e.every(r=>n.guard(r))},or:(...e)=>function(n){return e.some(r=>n.guard(r))},not:e=>function(n){return!n.guard(e)}}}function Wn(){return{guards:ye(),createMachine:e=>e,choose:e=>function({choose:n}){var r;return(r=n(e))==null?void 0:r.actions}}}function $g(e){let t=()=>{var o,a;return(a=(o=e.getRootNode)==null?void 0:o.call(e))!=null?a:document},n=()=>we(t()),r=()=>{var o;return(o=n().defaultView)!=null?o:window},i=()=>kn(t()),s=o=>t().getElementById(o);return y(m({},e),{getRootNode:t,getDoc:n,getWin:r,getActiveElement:i,isActiveElement:ii,getById:s})}function _g(e){return new Proxy({},{get(t,n){return n==="style"?r=>e({style:r}).style:e}})}function Ug(){if(typeof globalThis!="undefined")return globalThis;if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global}function fl(e,t){let n=Ug();return n?(n[e]||(n[e]=t()),n[e]):t()}function pl(e={}){return Xg(e)}function xa(e,t,n){let r=tn.get(e);si()&&!r&&console.warn("Please use proxy object");let i,s=[],o=r[3],a=!1,c=o(u=>{if(s.push(u),n){t(s.splice(0));return}i||(i=Promise.resolve().then(()=>{i=void 0,a&&t(s.splice(0))}))});return a=!0,()=>{a=!1,c()}}function Zg(e){let t=tn.get(e);si()&&!t&&console.warn("Please use proxy object");let[n,r,i]=t;return i(n,r())}function rf(e,t,n){let r=n||"default",i=zr.get(e);i||(i=new Map,zr.set(e,i));let s=i.get(r)||{},o=Object.keys(t),a=(v,b)=>{e.addEventListener(v.toLowerCase(),b)},l=(v,b)=>{e.removeEventListener(v.toLowerCase(),b)},c=v=>v.startsWith("on"),u=v=>!v.startsWith("on"),h=v=>a(v.substring(2),t[v]),p=v=>l(v.substring(2),t[v]),d=v=>{let b=t[v],V=s[v];if(b!==V){if(v==="class"){e.className=b!=null?b:"";return}if(Na.has(v)){e[v]=b!=null?b:"";return}if(typeof b=="boolean"&&!v.includes("aria-")){e.toggleAttribute(Qr(e,v),b);return}if(v==="children"){e.innerHTML=b;return}if(b!=null){e.setAttribute(Qr(e,v),b);return}e.removeAttribute(Qr(e,v))}};for(let v in s)t[v]==null&&(v==="class"?e.className="":Na.has(v)?e[v]="":e.removeAttribute(Qr(e,v)));return Object.keys(s).filter(c).forEach(v=>{l(v.substring(2),s[v])}),o.filter(c).forEach(h),o.filter(u).forEach(d),i.set(r,t),function(){o.filter(c).forEach(p);let b=zr.get(e);b&&(b.delete(r),b.size===0&&zr.delete(e))}}function oi(e){var s,o;let t=(s=e().value)!=null?s:e().defaultValue;e().debug&&console.log(`[bindable > ${e().debug}] initial`,t);let n=(o=e().isEqual)!=null?o:Object.is,r=pl({value:t}),i=()=>e().value!==void 0;return{initial:t,ref:r,get(){return i()?e().value:r.value},set(a){var u,h;let l=r.value,c=Ot(a)?a(l):a;e().debug&&console.log(`[bindable > ${e().debug}] setValue`,{next:c,prev:l}),i()||(r.value=c),n(c,l)||(h=(u=e()).onChange)==null||h.call(u,c,l)},invoke(a,l){var c,u;(u=(c=e()).onChange)==null||u.call(c,a,l)},hash(a){var l,c,u;return(u=(c=(l=e()).hash)==null?void 0:c.call(l,a))!=null?u:String(a)}}}function sf(e){let t={current:e};return{get(n){return t.current[n]},set(n,r){t.current[n]=r}}}function ml(e,t){if(!mr(e)||!mr(t))return t===void 0?e:t;let n=m({},e);for(let r of Object.keys(t)){let i=t[r],s=e[r];i!==void 0&&(mr(s)&&mr(i)?n[r]=ml(s,i):n[r]=i)}return n}var fh,x,Y,Se,O,rn,Z,Vn,ph,mh,vh,Ss,Ca,yh,Ps,Tt,ai,Ra,T,re,bh,Eh,Ch,ce,yr,Ih,Da,Oh,nn,Sh,We,Ph,wh,ws,Rs,kh,La,ci,Ls,Ha,Lh,Fs,Fh,Mh,br,$h,Nn,Wt,_h,Hh,et,An,Fe,Uh,qh,Ia,ie,qa,Zh,Jh,zh,di,Ir,$s,ig,sg,xn,xs,ei,Gs,Ja,cg,ug,dg,tt,Hn,vg,tl,yg,Ht,bg,Ta,Eg,Ke,nt,Cg,rt,ht,kt,mi,it,Oa,Tg,he,Kt,sl,ol,Yt,ti,Ot,al,Me,Og,ll,Sg,mr,Pg,wg,Vg,St,Ys,xg,cl,Bn,js,CI,II,TI,kg,Ng,OI,SI,Ag,ul,vi,dl,Ae,B,Jr,ni,Dg,Lg,Fg,Sa,Mg,vr,Vs,G,PI,Hg,Pa,ks,Bg,Gg,wa,ri,qg,Wg,Kg,Yg,Ns,Va,si,tn,jg,Xg,Jg,zg,ne,ka,Qg,ef,Q,zr,Na,tf,nf,Qr,ee,te,me=fe(()=>{"use strict";fh=["ltr","rtl"];x=(e,t,n)=>{let r=e.dataset[t];if(r!==void 0&&(!n||n.includes(r)))return r},Y=(e,t)=>{let n=e.dataset[t];if(typeof n=="string")return n.split(",").map(r=>r.trim()).filter(r=>r.length>0)},Se=(e,t,n)=>{let r=e.dataset[t];if(r===void 0)return;let i=Number(r);if(!Number.isNaN(i))return n&&!n.includes(i)?0:i},O=(e,t)=>{let n=t.replace(/([A-Z])/g,"-$1").toLowerCase();return e.hasAttribute(`data-${n}`)},rn=(e,t="element")=>e!=null&&e.id?e.id:`${t}-${Math.random().toString(36).substring(2,9)}`,Z=(e,t=[])=>({parts:(...n)=>{if(ph(t))return Z(e,n);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...n)=>Z(e,[...t,...n]),omit:(...n)=>Z(e,t.filter(r=>!n.includes(r))),rename:n=>Z(n,t),keys:()=>t,build:()=>[...new Set(t)].reduce((n,r)=>Object.assign(n,{[r]:{selector:[`&[data-scope="${Vn(e)}"][data-part="${Vn(r)}"]`,`& [data-scope="${Vn(e)}"][data-part="${Vn(r)}"]`].join(", "),attrs:{"data-scope":Vn(e),"data-part":Vn(r)}}}),{})}),Vn=e=>e.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),ph=e=>e.length===0,mh=Object.defineProperty,vh=(e,t,n)=>t in e?mh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ss=(e,t,n)=>vh(e,typeof t!="symbol"?t+"":t,n);Ca=e=>Math.max(0,Math.min(1,e)),yh=(e,t)=>e.map((n,r)=>e[(Math.max(t,0)+r)%e.length]),Ps=(...e)=>t=>e.reduce((n,r)=>r(n),t),Tt=()=>{},ai=e=>typeof e=="object"&&e!==null,Ra=2147483647,T=e=>e?"":void 0,re=e=>e?"true":void 0,bh=1,Eh=9,Ch=11,ce=e=>ai(e)&&e.nodeType===bh&&typeof e.nodeName=="string",yr=e=>ai(e)&&e.nodeType===Eh,Ih=e=>ai(e)&&e===e.window,Da=e=>ce(e)?e.localName||"":"#document";Oh=e=>ai(e)&&e.nodeType!==void 0,nn=e=>Oh(e)&&e.nodeType===Ch&&"host"in e,Sh=e=>ce(e)&&e.localName==="input",We=e=>!!(e!=null&&e.matches("a[href]")),Ph=e=>ce(e)?e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0:!1;wh=/(textarea|select)/;ws=new WeakMap;Rs=new Set(["menu","listbox","dialog","grid","tree","region"]),kh=e=>Rs.has(e),La=e=>{var t;return((t=e.getAttribute("aria-controls"))==null?void 0:t.split(" "))||[]};ci=()=>typeof document!="undefined";Ls=e=>ci()&&e.test(Rh()),Ha=e=>ci()&&e.test(Dh()),Lh=e=>ci()&&e.test(navigator.vendor),Fs=()=>ci()&&!!navigator.maxTouchPoints,Fh=()=>Ls(/^iPhone/i),Mh=()=>Ls(/^iPad/i)||Nn()&&navigator.maxTouchPoints>1,br=()=>Fh()||Mh(),$h=()=>Nn()||br(),Nn=()=>Ls(/^Mac/i),Wt=()=>$h()&&Lh(/apple/i),_h=()=>Ha(/Firefox/i),Hh=()=>Ha(/Android/i);et=e=>e.button===0,An=e=>e.button===2||Nn()&&e.ctrlKey&&e.button===0,Fe=e=>e.ctrlKey||e.altKey||e.metaKey,Uh=e=>"touches"in e&&e.touches.length>0,qh={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"},Ia={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft"};ie=(e,t,n,r)=>{let i=typeof e=="function"?e():e;return i==null||i.addEventListener(t,n,r),()=>{i==null||i.removeEventListener(t,n,r)}};qa=e=>ce(e)&&e.tagName==="IFRAME",Zh=/^(audio|video|details)$/;Jh=e=>!Number.isNaN(Wa(e)),zh=e=>Wa(e)<0;di="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type",Ir=(e,t={})=>{if(!e)return[];let{includeContainer:n=!1,getShadowRoot:r}=t,i=Array.from(e.querySelectorAll(di));(n==!0||n=="if-empty"&&i.length===0)&&ce(e)&&Qe(e)&&i.unshift(e);let o=[];for(let a of i)if(Qe(a)){if(qa(a)&&a.contentDocument){let l=a.contentDocument.body;o.push(...Ir(l,{getShadowRoot:r}));continue}o.push(a)}return r?Ka(o,r,Qe):o};$s=class Ya{constructor(){Ss(this,"id",null),Ss(this,"fn_cleanup"),Ss(this,"cleanup",()=>{this.cancel()})}static create(){return new Ya}request(t){this.cancel(),this.id=globalThis.requestAnimationFrame(()=>{this.id=null,this.fn_cleanup=t==null?void 0:t()})}cancel(){var t;this.id!==null&&(globalThis.cancelAnimationFrame(this.id),this.id=null),(t=this.fn_cleanup)==null||t.call(this),this.fn_cleanup=void 0}isActive(){return this.id!==null}};ig=/auto|scroll|overlay|hidden|clip/,sg=new Set(["inline","contents"]);xn="default",xs="",ei=new WeakMap;Gs=e=>e.id;Ja=lg({box:"border-box"}),cg=e=>e.split("").map(t=>{let n=t.charCodeAt(0);return n>0&&n<128?t:n>=128&&n<=255?`/x${n.toString(16)}`.replace("/","\\"):""}).join("").trim(),ug=e=>{var t,n,r;return cg((r=(n=(t=e.dataset)==null?void 0:t.valuetext)!=null?n:e.textContent)!=null?r:"")},dg=(e,t)=>e.trim().toLowerCase().startsWith(t.toLowerCase());tt=Object.assign(fg,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:pg});Hn={border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"};vg=Object.defineProperty,tl=e=>{throw TypeError(e)},yg=(e,t,n)=>t in e?vg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ht=(e,t,n)=>yg(e,typeof t!="symbol"?t+"":t,n),bg=(e,t,n)=>t.has(e)||tl("Cannot "+n),Ta=(e,t,n)=>(bg(e,t,"read from private field"),t.get(e)),Eg=(e,t,n)=>t.has(e)?tl("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);Ke=e=>e[0],nt=e=>e[e.length-1],Cg=(e,t)=>e.indexOf(t)!==-1,rt=(e,...t)=>e.concat(t),ht=(e,...t)=>e.filter(n=>!t.includes(n)),kt=e=>Array.from(new Set(e)),mi=(e,t)=>{let n=new Set(t);return e.filter(r=>!n.has(r))},it=(e,t)=>Cg(e,t)?ht(e,t):rt(e,t);Oa=e=>(e==null?void 0:e.constructor.name)==="Array",Tg=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n{if(Object.is(e,t))return!0;if(e==null&&t!=null||e!=null&&t==null)return!1;if(typeof(e==null?void 0:e.isEqual)=="function"&&typeof(t==null?void 0:t.isEqual)=="function")return e.isEqual(t);if(typeof e=="function"&&typeof t=="function")return e.toString()===t.toString();if(Oa(e)&&Oa(t))return Tg(Array.from(e),Array.from(t));if(typeof e!="object"||typeof t!="object")return!1;let n=Object.keys(t!=null?t:Object.create(null)),r=n.length;for(let i=0;iArray.isArray(e),sl=e=>e===!0||e===!1,ol=e=>e!=null&&typeof e=="object",Yt=e=>ol(e)&&!Kt(e),ti=e=>typeof e=="string",Ot=e=>typeof e=="function",al=e=>e==null,Me=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Og=e=>Object.prototype.toString.call(e),ll=Function.prototype.toString,Sg=ll.call(Object),mr=e=>{if(!ol(e)||Og(e)!="[object Object]"||Vg(e))return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=Me(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&ll.call(n)==Sg},Pg=e=>typeof e=="object"&&e!==null&&"$$typeof"in e&&"props"in e,wg=e=>typeof e=="object"&&e!==null&&"__v_isVNode"in e,Vg=e=>Pg(e)||wg(e),St=(e,...t)=>{let n=typeof e=="function"?e(...t):e;return n!=null?n:void 0},Ys=e=>e,xg=e=>e(),cl=()=>{},Bn=(...e)=>(...t)=>{e.forEach(function(n){n==null||n(...t)})},js=(()=>{let e=0;return()=>(e++,e.toString(36))})();({floor:CI,abs:II,round:TI,min:kg,max:Ng,pow:OI,sign:SI}=Math),Ag=e=>Number.isNaN(e),ul=e=>Ag(e)?0:e,vi=(e,t,n)=>{let r=ul(e),i=t==null||r>=t,s=n==null||r<=n;return i&&s},dl=(e,t,n)=>kg(Ng(ul(e),t),n),Ae=e=>typeof e=="number"?`${e}px`:e;B=e=>function(n){return Rg(n,e)},Jr=()=>performance.now(),Dg=class{constructor(e){this.onTick=e,Ht(this,"frameId",null),Ht(this,"pausedAtMs",null),Ht(this,"context"),Ht(this,"cancelFrame",()=>{this.frameId!==null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}),Ht(this,"setStartMs",t=>{this.context.startMs=t}),Ht(this,"start",()=>{if(this.frameId!==null)return;let t=Jr();this.pausedAtMs!==null?(this.context.startMs+=t-this.pausedAtMs,this.pausedAtMs=null):this.context.startMs=t,this.frameId=requestAnimationFrame(Ta(this,ni))}),Ht(this,"pause",()=>{this.frameId!==null&&(this.cancelFrame(),this.pausedAtMs=Jr())}),Ht(this,"stop",()=>{this.frameId!==null&&(this.cancelFrame(),this.pausedAtMs=null)}),Eg(this,ni,t=>{if(this.context.now=t,this.context.deltaMs=t-this.context.startMs,this.onTick(this.context)===!1){this.stop();return}this.frameId=requestAnimationFrame(Ta(this,ni))}),this.context={now:0,startMs:Jr(),deltaMs:0}}get elapsedMs(){return this.pausedAtMs!==null?this.pausedAtMs-this.context.startMs:Jr()-this.context.startMs}};ni=new WeakMap;Lg=(...e)=>e.map(t=>{var n;return(n=t==null?void 0:t.trim)==null?void 0:n.call(t)}).filter(Boolean).join(" "),Fg=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,Sa=e=>{let t={},n;for(;n=Fg.exec(e);)t[n[1]]=n[2];return t},Mg=(e,t)=>{if(ti(e)){if(ti(t))return`${e};${t}`;e=Sa(e)}else ti(t)&&(t=Sa(t));return Object.assign({},e!=null?e:{},t!=null?t:{})};vr=(e=>(e.NotStarted="Not Started",e.Started="Started",e.Stopped="Stopped",e))(vr||{}),Vs="__init__";G=()=>e=>Array.from(new Set(e)),PI=Symbol(),Hg=Symbol(),Pa=Object.getPrototypeOf,ks=new WeakMap,Bg=e=>e&&(ks.has(e)?ks.get(e):Pa(e)===Object.prototype||Pa(e)===Array.prototype),Gg=e=>Bg(e)&&e[Hg]||null,wa=(e,t=!0)=>{ks.set(e,t)};ri=fl("__zag__refSet",()=>new WeakSet),qg=e=>typeof e=="object"&&e!==null&&"$$typeof"in e&&"props"in e,Wg=e=>typeof e=="object"&&e!==null&&"__v_isVNode"in e,Kg=e=>typeof e=="object"&&e!==null&&"nodeType"in e&&typeof e.nodeName=="string",Yg=e=>qg(e)||Wg(e)||Kg(e),Ns=e=>e!==null&&typeof e=="object",Va=e=>Ns(e)&&!ri.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!Yg(e)&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)&&!(e instanceof Promise)&&!(e instanceof File)&&!(e instanceof Blob)&&!(e instanceof AbortController),si=()=>!0,tn=fl("__zag__proxyStateMap",()=>new WeakMap),jg=(e=Object.is,t=(a,l)=>new Proxy(a,l),n=new WeakMap,r=(a,l)=>{let c=n.get(a);if((c==null?void 0:c[0])===l)return c[1];let u=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return wa(u,!0),n.set(a,[l,u]),Reflect.ownKeys(a).forEach(h=>{let p=Reflect.get(a,h);ri.has(p)?(wa(p,!1),u[h]=p):tn.has(p)?u[h]=Zg(p):u[h]=p}),Object.freeze(u)},i=new WeakMap,s=[1,1],o=a=>{if(!Ns(a))throw new Error("object required");let l=i.get(a);if(l)return l;let c=s[0],u=new Set,h=(w,A=++s[0])=>{c!==A&&(c=A,u.forEach(P=>P(w,A)))},p=s[1],d=(w=++s[1])=>(p!==w&&!u.size&&(p=w,v.forEach(([A])=>{let P=A[1](w);P>c&&(c=P)})),c),g=w=>(A,P)=>{let N=[...A];N[1]=[w,...N[1]],h(N,P)},v=new Map,b=(w,A)=>{if(si()&&v.has(w))throw new Error("prop listener already exists");if(u.size){let P=A[3](g(w));v.set(w,[A,P])}else v.set(w,[A])},V=w=>{var P;let A=v.get(w);A&&(v.delete(w),(P=A[1])==null||P.call(A))},S=w=>(u.add(w),u.size===1&&v.forEach(([P,N],R)=>{if(si()&&N)throw new Error("remove already exists");let L=P[3](g(R));v.set(R,[P,L])}),()=>{u.delete(w),u.size===0&&v.forEach(([P,N],R)=>{N&&(N(),v.set(R,[P]))})}),E=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),C=t(E,{deleteProperty(w,A){let P=Reflect.get(w,A);V(A);let N=Reflect.deleteProperty(w,A);return N&&h(["delete",[A],P]),N},set(w,A,P,N){var j;let R=Reflect.has(w,A),L=Reflect.get(w,A,N);if(R&&(e(L,P)||i.has(P)&&e(L,i.get(P))))return!0;V(A),Ns(P)&&(P=Gg(P)||P);let M=P;if(!((j=Object.getOwnPropertyDescriptor(w,A))!=null&&j.set)){!tn.has(P)&&Va(P)&&(M=pl(P));let q=!ri.has(M)&&tn.get(M);q&&b(A,q)}return Reflect.set(w,A,M,N),h(["set",[A],P,L]),!0}});i.set(a,C);let I=[E,d,r,S];return tn.set(C,I),Reflect.ownKeys(a).forEach(w=>{let A=Object.getOwnPropertyDescriptor(a,w);A.get||A.set?Object.defineProperty(E,w,A):C[w]=a[w]}),C})=>[o,tn,ri,e,t,Va,n,r,i,s],[Xg]=jg();Jg=Object.defineProperty,zg=(e,t,n)=>t in e?Jg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ne=(e,t,n)=>zg(e,typeof t!="symbol"?t+"":t,n),ka={onFocus:"onFocusin",onBlur:"onFocusout",onChange:"onInput",onDoubleClick:"onDblclick",htmlFor:"for",className:"class",defaultValue:"value",defaultChecked:"checked"},Qg=new Set(["viewBox","preserveAspectRatio"]),ef=e=>{let t="";for(let n in e){let r=e[n];r!=null&&(n.startsWith("--")||(n=n.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)),t+=`${n}:${r};`)}return t},Q=_g(e=>Object.entries(e).reduce((t,[n,r])=>{if(r===void 0)return t;if(n in ka&&(n=ka[n]),n==="style"&&typeof r=="object")return t.style=ef(r),t;let i=Qg.has(n)?n:n.toLowerCase();return t[i]=r,t},{})),zr=new WeakMap,Na=new Set(["value","checked","selected"]),tf=new Set(["viewBox","preserveAspectRatio","clipPath","clipRule","fillRule","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit"]),nf=e=>e.tagName==="svg"||e.namespaceURI==="http://www.w3.org/2000/svg",Qr=(e,t)=>nf(e)&&tf.has(t)?t:t.toLowerCase();oi.cleanup=e=>{};oi.ref=e=>{let t=e;return{get:()=>t,set:n=>{t=n}}};ee=class{constructor(e,t={}){var h,p,d;this.machine=e,ne(this,"scope"),ne(this,"context"),ne(this,"prop"),ne(this,"state"),ne(this,"refs"),ne(this,"computed"),ne(this,"event",{type:""}),ne(this,"previousEvent",{type:""}),ne(this,"effects",new Map),ne(this,"transition",null),ne(this,"cleanups",[]),ne(this,"subscriptions",[]),ne(this,"userPropsRef"),ne(this,"getEvent",()=>y(m({},this.event),{current:()=>this.event,previous:()=>this.previousEvent})),ne(this,"getStateConfig",g=>this.machine.states[g]),ne(this,"getState",()=>y(m({},this.state),{matches:(...g)=>g.includes(this.state.get()),hasTag:g=>{var v,b;return!!((b=(v=this.getStateConfig(this.state.get()))==null?void 0:v.tags)!=null&&b.includes(g))}})),ne(this,"debug",(...g)=>{this.machine.debug&&console.log(...g)}),ne(this,"notify",()=>{this.publish()}),ne(this,"send",g=>{this.status===vr.Started&&queueMicrotask(()=>{var C,I,w,A,P;if(!g)return;this.previousEvent=this.event,this.event=g,this.debug("send",g);let v=this.state.get(),b=g.type,V=(A=(I=(C=this.getStateConfig(v))==null?void 0:C.on)==null?void 0:I[b])!=null?A:(w=this.machine.on)==null?void 0:w[b],S=this.choose(V);if(!S)return;this.transition=S;let E=(P=S.target)!=null?P:v;this.debug("transition",S);let f=E!==v;f?this.state.set(E):S.reenter&&!f?this.state.invoke(v,v):this.action(S.actions)})}),ne(this,"action",g=>{let v=Ot(g)?g(this.getParams()):g;if(!v)return;let b=v.map(V=>{var E,f;let S=(f=(E=this.machine.implementations)==null?void 0:E.actions)==null?void 0:f[V];return S||wt(`[zag-js] No implementation found for action "${JSON.stringify(V)}"`),S});for(let V of b)V==null||V(this.getParams())}),ne(this,"guard",g=>{var v,b;return Ot(g)?g(this.getParams()):(b=(v=this.machine.implementations)==null?void 0:v.guards)==null?void 0:b[g](this.getParams())}),ne(this,"effect",g=>{let v=Ot(g)?g(this.getParams()):g;if(!v)return;let b=v.map(S=>{var f,C;let E=(C=(f=this.machine.implementations)==null?void 0:f.effects)==null?void 0:C[S];return E||wt(`[zag-js] No implementation found for effect "${JSON.stringify(S)}"`),E}),V=[];for(let S of b){let E=S==null?void 0:S(this.getParams());E&&V.push(E)}return()=>V.forEach(S=>S==null?void 0:S())}),ne(this,"choose",g=>Tr(g).find(v=>{let b=!v.guard;return ti(v.guard)?b=!!this.guard(v.guard):Ot(v.guard)&&(b=v.guard(this.getParams())),b})),ne(this,"subscribe",g=>(this.subscriptions.push(g),()=>{let v=this.subscriptions.indexOf(g);v>-1&&this.subscriptions.splice(v,1)})),ne(this,"status",vr.NotStarted),ne(this,"publish",()=>{this.callTrackers(),this.subscriptions.forEach(g=>g(this.service))}),ne(this,"trackers",[]),ne(this,"setupTrackers",()=>{var g,v;(v=(g=this.machine).watch)==null||v.call(g,this.getParams())}),ne(this,"callTrackers",()=>{this.trackers.forEach(({deps:g,fn:v})=>{let b=g.map(V=>V());he(v.prev,b)||(v(),v.prev=b)})}),ne(this,"getParams",()=>({state:this.getState(),context:this.context,event:this.getEvent(),prop:this.prop,send:this.send,action:this.action,guard:this.guard,track:(g,v)=>{v.prev=g.map(b=>b()),this.trackers.push({deps:g,fn:v})},refs:this.refs,computed:this.computed,flush:xg,scope:this.scope,choose:this.choose})),this.userPropsRef={current:t};let{id:n,ids:r,getRootNode:i}=St(t);this.scope=$g({id:n,ids:r,getRootNode:i});let s=g=>{var V,S;let v=St(this.userPropsRef.current);return((S=(V=e.props)==null?void 0:V.call(e,{props:Gn(v),scope:this.scope}))!=null?S:v)[g]};this.prop=s;let o=(h=e.context)==null?void 0:h.call(e,{prop:s,bindable:oi,scope:this.scope,flush(g){queueMicrotask(g)},getContext(){return a},getComputed(){return l},getRefs(){return c},getEvent:this.getEvent.bind(this)});o&&Object.values(o).forEach(g=>{let v=xa(g.ref,()=>this.notify());this.cleanups.push(v)});let a={get(g){return o==null?void 0:o[g].get()},set(g,v){o==null||o[g].set(v)},initial(g){return o==null?void 0:o[g].initial},hash(g){let v=o==null?void 0:o[g].get();return o==null?void 0:o[g].hash(v)}};this.context=a;let l=g=>{var v,b;return(b=(v=e.computed)==null?void 0:v[g]({context:a,event:this.getEvent(),prop:s,refs:this.refs,scope:this.scope,computed:l}))!=null?b:{}};this.computed=l;let c=sf((d=(p=e.refs)==null?void 0:p.call(e,{prop:s,context:a}))!=null?d:{});this.refs=c;let u=oi(()=>({defaultValue:e.initialState({prop:s}),onChange:(g,v)=>{var V,S,E,f;if(v){let C=this.effects.get(v);C==null||C(),this.effects.delete(v)}v&&this.action((V=this.getStateConfig(v))==null?void 0:V.exit),this.action((S=this.transition)==null?void 0:S.actions);let b=this.effect((E=this.getStateConfig(g))==null?void 0:E.effects);if(b&&this.effects.set(g,b),v===Vs){this.action(e.entry);let C=this.effect(e.effects);C&&this.effects.set(Vs,C)}this.action((f=this.getStateConfig(g))==null?void 0:f.entry)}}));this.state=u,this.cleanups.push(xa(this.state.ref,()=>this.notify()))}updateProps(e){let t=this.userPropsRef.current;this.userPropsRef.current=()=>{let n=St(t),r=St(e);return ml(n,r)},this.notify()}start(){this.status=vr.Started,this.debug("initializing..."),this.state.invoke(this.state.initial,Vs),this.setupTrackers()}stop(){this.effects.forEach(e=>e==null?void 0:e()),this.effects.clear(),this.transition=null,this.action(this.machine.exit),this.cleanups.forEach(e=>e()),this.cleanups=[],this.subscriptions=[],this.status=vr.Stopped,this.debug("unmounting...")}get service(){return{state:this.getState(),send:this.send,context:this.context,prop:this.prop,scope:this.scope,refs:this.refs,computed:this.computed,event:this.getEvent(),getStatus:()=>this.status}}},te=class{constructor(e,t){U(this,"el");U(this,"doc");U(this,"machine");U(this,"api");U(this,"init",()=>{this.render(),this.machine.subscribe(()=>{this.api=this.initApi(),this.render()}),this.machine.start()});U(this,"destroy",()=>{this.machine.stop()});U(this,"spreadProps",(e,t)=>{rf(e,t,this.machine.scope.id)});U(this,"updateProps",e=>{this.machine.updateProps(e)});if(!e)throw new Error("Root element not found");this.el=e,this.doc=document,this.machine=this.initMachine(t),this.api=this.initApi()}}});var vl={};Oe(vl,{Accordion:()=>Ef});function gf(e,t){let{send:n,context:r,prop:i,scope:s,computed:o}=e,a=r.get("focusedValue"),l=r.get("value"),c=i("multiple");function u(p){let d=p;!c&&d.length>1&&(d=[d[0]]),n({type:"VALUE.SET",value:d})}function h(p){var d;return{expanded:l.includes(p.value),focused:a===p.value,disabled:!!((d=p.disabled)!=null?d:i("disabled"))}}return{focusedValue:a,value:l,setValue:u,getItemState:h,getRootProps(){return t.element(y(m({},Or.root.attrs),{dir:i("dir"),id:bi(s),"data-orientation":i("orientation")}))},getItemProps(p){let d=h(p);return t.element(y(m({},Or.item.attrs),{dir:i("dir"),id:af(s,p.value),"data-state":d.expanded?"open":"closed","data-focus":T(d.focused),"data-disabled":T(d.disabled),"data-orientation":i("orientation")}))},getItemContentProps(p){let d=h(p);return t.element(y(m({},Or.itemContent.attrs),{dir:i("dir"),role:"region",id:Xs(s,p.value),"aria-labelledby":Ei(s,p.value),hidden:!d.expanded,"data-state":d.expanded?"open":"closed","data-disabled":T(d.disabled),"data-focus":T(d.focused),"data-orientation":i("orientation")}))},getItemIndicatorProps(p){let d=h(p);return t.element(y(m({},Or.itemIndicator.attrs),{dir:i("dir"),"aria-hidden":!0,"data-state":d.expanded?"open":"closed","data-disabled":T(d.disabled),"data-focus":T(d.focused),"data-orientation":i("orientation")}))},getItemTriggerProps(p){let{value:d}=p,g=h(p);return t.button(y(m({},Or.itemTrigger.attrs),{type:"button",dir:i("dir"),id:Ei(s,d),"aria-controls":Xs(s,d),"data-controls":Xs(s,d),"aria-expanded":g.expanded,disabled:g.disabled,"data-orientation":i("orientation"),"aria-disabled":g.disabled,"data-state":g.expanded?"open":"closed","data-ownedby":bi(s),onFocus(){g.disabled||n({type:"TRIGGER.FOCUS",value:d})},onBlur(){g.disabled||n({type:"TRIGGER.BLUR"})},onClick(v){g.disabled||(Wt()&&v.currentTarget.focus(),n({type:"TRIGGER.CLICK",value:d}))},onKeyDown(v){if(v.defaultPrevented||g.disabled)return;let b={ArrowDown(){o("isHorizontal")||n({type:"GOTO.NEXT",value:d})},ArrowUp(){o("isHorizontal")||n({type:"GOTO.PREV",value:d})},ArrowRight(){o("isHorizontal")&&n({type:"GOTO.NEXT",value:d})},ArrowLeft(){o("isHorizontal")&&n({type:"GOTO.PREV",value:d})},Home(){n({type:"GOTO.FIRST",value:d})},End(){n({type:"GOTO.LAST",value:d})}},V=ve(v,{dir:i("dir"),orientation:i("orientation")}),S=b[V];S&&(S(v),v.preventDefault())}}))}}}var of,Or,bi,af,Xs,Ei,lf,Ci,cf,uf,df,hf,ff,pf,mf,vf,RI,yf,DI,bf,Ef,yl=fe(()=>{"use strict";me();of=Z("accordion").parts("root","item","itemTrigger","itemContent","itemIndicator"),Or=of.build(),bi=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`accordion:${e.id}`},af=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.item)==null?void 0:r.call(n,t))!=null?i:`accordion:${e.id}:item:${t}`},Xs=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemContent)==null?void 0:r.call(n,t))!=null?i:`accordion:${e.id}:content:${t}`},Ei=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemTrigger)==null?void 0:r.call(n,t))!=null?i:`accordion:${e.id}:trigger:${t}`},lf=e=>e.getById(bi(e)),Ci=e=>{let n=`[data-controls][data-ownedby='${CSS.escape(bi(e))}']:not([disabled])`;return dt(lf(e),n)},cf=e=>Ke(Ci(e)),uf=e=>nt(Ci(e)),df=(e,t)=>$n(Ci(e),Ei(e,t)),hf=(e,t)=>_n(Ci(e),Ei(e,t));({and:ff,not:pf}=ye()),mf={props({props:e}){return m({collapsible:!1,multiple:!1,orientation:"vertical",defaultValue:[]},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{focusedValue:t(()=>({defaultValue:null,sync:!0,onChange(n){var r;(r=e("onFocusChange"))==null||r({value:n})}})),value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(n){var r;(r=e("onValueChange"))==null||r({value:n})}}))}},computed:{isHorizontal:({prop:e})=>e("orientation")==="horizontal"},on:{"VALUE.SET":{actions:["setValue"]}},states:{idle:{on:{"TRIGGER.FOCUS":{target:"focused",actions:["setFocusedValue"]}}},focused:{on:{"GOTO.NEXT":{actions:["focusNextTrigger"]},"GOTO.PREV":{actions:["focusPrevTrigger"]},"TRIGGER.CLICK":[{guard:ff("isExpanded","canToggle"),actions:["collapse"]},{guard:pf("isExpanded"),actions:["expand"]}],"GOTO.FIRST":{actions:["focusFirstTrigger"]},"GOTO.LAST":{actions:["focusLastTrigger"]},"TRIGGER.BLUR":{target:"idle",actions:["clearFocusedValue"]}}}},implementations:{guards:{canToggle:({prop:e})=>!!e("collapsible")||!!e("multiple"),isExpanded:({context:e,event:t})=>e.get("value").includes(t.value)},actions:{collapse({context:e,prop:t,event:n}){let r=t("multiple")?ht(e.get("value"),n.value):[];e.set("value",r)},expand({context:e,prop:t,event:n}){let r=t("multiple")?rt(e.get("value"),n.value):[n.value];e.set("value",r)},focusFirstTrigger({scope:e}){var t;(t=cf(e))==null||t.focus()},focusLastTrigger({scope:e}){var t;(t=uf(e))==null||t.focus()},focusNextTrigger({context:e,scope:t}){let n=e.get("focusedValue");if(!n)return;let r=df(t,n);r==null||r.focus()},focusPrevTrigger({context:e,scope:t}){let n=e.get("focusedValue");if(!n)return;let r=hf(t,n);r==null||r.focus()},setFocusedValue({context:e,event:t}){e.set("focusedValue",t.value)},clearFocusedValue({context:e}){e.set("focusedValue",null)},setValue({context:e,event:t}){e.set("value",t.value)},coarseValue({context:e,prop:t}){!t("multiple")&&e.get("value").length>1&&(wt("The value of accordion should be a single value when multiple is false."),e.set("value",[e.get("value")[0]]))}}}},vf=G()(["collapsible","dir","disabled","getRootNode","id","ids","multiple","onFocusChange","onValueChange","orientation","value","defaultValue"]),RI=B(vf),yf=G()(["value","disabled"]),DI=B(yf),bf=class extends te{initMachine(e){return new ee(mf,e)}initApi(){return gf(this.machine.service,Q)}render(){var r;let e=(r=this.el.querySelector('[data-scope="accordion"][data-part="root"]'))!=null?r:this.el;this.spreadProps(e,this.api.getRootProps());let t=this.getItemsList(),n=e.querySelectorAll('[data-scope="accordion"][data-part="item"]');for(let i=0;i{var o,a;let i=x(e,"onValueChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,value:(o=r.value)!=null?o:null});let s=x(e,"onValueChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,value:(a=r.value)!=null?a:null}}))},onFocusChange:r=>{var o,a;let i=x(e,"onFocusChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,value:(o=r.value)!=null?o:null});let s=x(e,"onFocusChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,value:(a=r.value)!=null?a:null}}))}}));n.init(),this.accordion=n,this.onSetValue=r=>{let{value:i}=r.detail;n.api.setValue(i)},e.addEventListener("phx:accordion:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("accordion_set_value",r=>{let i=r.accordion_id;i&&!(e.id===i||e.id===`accordion:${i}`)||n.api.setValue(r.value)})),this.handlers.push(this.handleEvent("accordion_value",()=>{this.pushEvent("accordion_value_response",{value:n.api.value})})),this.handlers.push(this.handleEvent("accordion_focused_value",()=>{this.pushEvent("accordion_focused_value_response",{value:n.api.focusedValue})}))},updated(){var t,n,r,i;let e=O(this.el,"controlled");(i=this.accordion)==null||i.updateProps(y(m({id:this.el.id},e?{value:Y(this.el,"value")}:{defaultValue:(r=(n=(t=this.accordion)==null?void 0:t.api)==null?void 0:n.value)!=null?r:Y(this.el,"defaultValue")}),{collapsible:O(this.el,"collapsible"),multiple:O(this.el,"multiple"),orientation:x(this.el,"orientation",["horizontal","vertical"]),dir:Gt(this.el)}))},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:accordion:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.accordion)==null||e.destroy()}}});function Cf(e){return!(e.metaKey||!Nn()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Tf(e,t,n){let r=n?K(n):null,i=oe(r);return e=e||r instanceof i.HTMLInputElement&&!If.has(r==null?void 0:r.type)||r instanceof i.HTMLTextAreaElement||r instanceof i.HTMLElement&&r.isContentEditable,!(e&&t==="keyboard"&&n instanceof i.KeyboardEvent&&!Reflect.has(Of,n.key))}function Oi(e,t){for(let n of Zs)n(e,t)}function Ti(e){un=!0,Cf(e)&&(dn="keyboard",Oi("keyboard",e))}function je(e){dn="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(un=!0,Oi("pointer",e))}function bl(e){Ga(e)&&(un=!0,dn="virtual")}function El(e){let t=K(e);t===oe(t)||t===we(t)||(!un&&!Js&&(dn="virtual",Oi("virtual",e)),un=!1,Js=!1)}function Cl(){un=!1,Js=!0}function Sf(e){if(typeof window=="undefined"||Ii.get(oe(e)))return;let t=oe(e),n=we(e),r=t.HTMLElement.prototype.focus;function i(){dn="virtual",Oi("virtual",null),un=!0,r.apply(this,arguments)}try{Object.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,value:i})}catch(s){}n.addEventListener("keydown",Ti,!0),n.addEventListener("keyup",Ti,!0),n.addEventListener("click",bl,!0),t.addEventListener("focus",El,!0),t.addEventListener("blur",Cl,!1),typeof t.PointerEvent!="undefined"?(n.addEventListener("pointerdown",je,!0),n.addEventListener("pointermove",je,!0),n.addEventListener("pointerup",je,!0)):(n.addEventListener("mousedown",je,!0),n.addEventListener("mousemove",je,!0),n.addEventListener("mouseup",je,!0)),t.addEventListener("beforeunload",()=>{Pf(e)},{once:!0}),Ii.set(t,{focus:r})}function Kn(){return dn==="keyboard"}function Si(e={}){let{isTextInput:t,autoFocus:n,onChange:r,root:i}=e;Sf(i),r==null||r({isFocusVisible:n||Kn(),modality:dn});let s=(o,a)=>{Tf(!!t,o,a)&&(r==null||r({isFocusVisible:Kn(),modality:o}))};return Zs.add(s),()=>{Zs.delete(s)}}var If,dn,Zs,Ii,un,Js,Of,Pf,zs=fe(()=>{"use strict";me();If=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);dn=null,Zs=new Set,Ii=new Map,un=!1,Js=!1,Of={Tab:!0,Escape:!0};Pf=(e,t)=>{let n=oe(e),r=we(e),i=Ii.get(n);if(i){try{Object.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,value:i.focus})}catch(s){}r.removeEventListener("keydown",Ti,!0),r.removeEventListener("keyup",Ti,!0),r.removeEventListener("click",bl,!0),n.removeEventListener("focus",El,!0),n.removeEventListener("blur",Cl,!1),typeof n.PointerEvent!="undefined"?(r.removeEventListener("pointerdown",je,!0),r.removeEventListener("pointermove",je,!0),r.removeEventListener("pointerup",je,!0)):(r.removeEventListener("mousedown",je,!0),r.removeEventListener("mousemove",je,!0),r.removeEventListener("mouseup",je,!0)),Ii.delete(n)}}});var Sl={};Oe(Sl,{Checkbox:()=>Lf});function kf(e,t){let{send:n,context:r,prop:i,computed:s,scope:o}=e,a=!!i("disabled"),l=!!i("readOnly"),c=!!i("required"),u=!!i("invalid"),h=!a&&r.get("focused"),p=!a&&r.get("focusVisible"),d=s("checked"),g=s("indeterminate"),v=r.get("checked"),b={"data-active":T(r.get("active")),"data-focus":T(h),"data-focus-visible":T(p),"data-readonly":T(l),"data-hover":T(r.get("hovered")),"data-disabled":T(a),"data-state":g?"indeterminate":d?"checked":"unchecked","data-invalid":T(u),"data-required":T(c)};return{checked:d,disabled:a,indeterminate:g,focused:h,checkedState:v,setChecked(V){n({type:"CHECKED.SET",checked:V,isTrusted:!1})},toggleChecked(){n({type:"CHECKED.TOGGLE",checked:d,isTrusted:!1})},getRootProps(){return t.label(y(m(m({},Pi.root.attrs),b),{dir:i("dir"),id:Ol(o),htmlFor:Qs(o),onPointerMove(){a||n({type:"CONTEXT.SET",context:{hovered:!0}})},onPointerLeave(){a||n({type:"CONTEXT.SET",context:{hovered:!1}})},onClick(V){K(V)===Sr(o)&&V.stopPropagation()}}))},getLabelProps(){return t.element(y(m(m({},Pi.label.attrs),b),{dir:i("dir"),id:Il(o)}))},getControlProps(){return t.element(y(m(m({},Pi.control.attrs),b),{dir:i("dir"),id:Vf(o),"aria-hidden":!0}))},getIndicatorProps(){return t.element(y(m(m({},Pi.indicator.attrs),b),{dir:i("dir"),hidden:!g&&!d}))},getHiddenInputProps(){return t.input({id:Qs(o),type:"checkbox",required:i("required"),defaultChecked:d,disabled:a,"aria-labelledby":Il(o),"aria-invalid":u,name:i("name"),form:i("form"),value:i("value"),style:Hn,onFocus(){let V=Kn();n({type:"CONTEXT.SET",context:{focused:!0,focusVisible:V}})},onBlur(){n({type:"CONTEXT.SET",context:{focused:!1,focusVisible:!1}})},onClick(V){if(l){V.preventDefault();return}let S=V.currentTarget.checked;n({type:"CHECKED.SET",checked:S,isTrusted:!0})}})}}}function wi(e){return e==="indeterminate"}function Af(e){return wi(e)?!1:!!e}var wf,Pi,Ol,Il,Vf,Qs,xf,Sr,Tl,Nf,Rf,BI,Df,Lf,Pl=fe(()=>{"use strict";zs();me();wf=Z("checkbox").parts("root","label","control","indicator"),Pi=wf.build(),Ol=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`checkbox:${e.id}`},Il=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`checkbox:${e.id}:label`},Vf=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`checkbox:${e.id}:control`},Qs=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.hiddenInput)!=null?n:`checkbox:${e.id}:input`},xf=e=>e.getById(Ol(e)),Sr=e=>e.getById(Qs(e));({not:Tl}=ye()),Nf={props({props:e}){var t;return y(m({value:"on"},e),{defaultChecked:(t=e.defaultChecked)!=null?t:!1})},initialState(){return"ready"},context({prop:e,bindable:t}){return{checked:t(()=>({defaultValue:e("defaultChecked"),value:e("checked"),onChange(n){var r;(r=e("onCheckedChange"))==null||r({checked:n})}})),fieldsetDisabled:t(()=>({defaultValue:!1})),focusVisible:t(()=>({defaultValue:!1})),active:t(()=>({defaultValue:!1})),focused:t(()=>({defaultValue:!1})),hovered:t(()=>({defaultValue:!1}))}},watch({track:e,context:t,prop:n,action:r}){e([()=>n("disabled")],()=>{r(["removeFocusIfNeeded"])}),e([()=>t.get("checked")],()=>{r(["syncInputElement"])})},effects:["trackFormControlState","trackPressEvent","trackFocusVisible"],on:{"CHECKED.TOGGLE":[{guard:Tl("isTrusted"),actions:["toggleChecked","dispatchChangeEvent"]},{actions:["toggleChecked"]}],"CHECKED.SET":[{guard:Tl("isTrusted"),actions:["setChecked","dispatchChangeEvent"]},{actions:["setChecked"]}],"CONTEXT.SET":{actions:["setContext"]}},computed:{indeterminate:({context:e})=>wi(e.get("checked")),checked:({context:e})=>Af(e.get("checked")),disabled:({context:e,prop:t})=>!!t("disabled")||e.get("fieldsetDisabled")},states:{ready:{}},implementations:{guards:{isTrusted:({event:e})=>!!e.isTrusted},effects:{trackPressEvent({context:e,computed:t,scope:n}){if(!t("disabled"))return pi({pointerNode:xf(n),keyboardNode:Sr(n),isValidKey:r=>r.key===" ",onPress:()=>e.set("active",!1),onPressStart:()=>e.set("active",!0),onPressEnd:()=>e.set("active",!1)})},trackFocusVisible({computed:e,scope:t}){var n;if(!e("disabled"))return Si({root:(n=t.getRootNode)==null?void 0:n.call(t)})},trackFormControlState({context:e,scope:t}){return Rn(Sr(t),{onFieldsetDisabledChange(n){e.set("fieldsetDisabled",n)},onFormReset(){e.set("checked",e.initial("checked"))}})}},actions:{setContext({context:e,event:t}){for(let n in t.context)e.set(n,t.context[n])},syncInputElement({context:e,computed:t,scope:n}){let r=Sr(n);r&&(Cr(r,t("checked")),r.indeterminate=wi(e.get("checked")))},removeFocusIfNeeded({context:e,prop:t}){t("disabled")&&e.get("focused")&&(e.set("focused",!1),e.set("focusVisible",!1))},setChecked({context:e,event:t}){e.set("checked",t.checked)},toggleChecked({context:e,computed:t}){let n=wi(t("checked"))?!0:!t("checked");e.set("checked",n)},dispatchChangeEvent({computed:e,scope:t}){queueMicrotask(()=>{let n=Sr(t);ui(n,{checked:e("checked")})})}}}};Rf=G()(["defaultChecked","checked","dir","disabled","form","getRootNode","id","ids","invalid","name","onCheckedChange","readOnly","required","value"]),BI=B(Rf),Df=class extends te{initMachine(e){return new ee(Nf,e)}initApi(){return kf(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="checkbox"][data-part="root"]');if(!e)return;this.spreadProps(e,this.api.getRootProps());let t=e.querySelector(':scope > [data-scope="checkbox"][data-part="hidden-input"]');t&&this.spreadProps(t,this.api.getHiddenInputProps());let n=e.querySelector(':scope > [data-scope="checkbox"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps());let r=e.querySelector(':scope > [data-scope="checkbox"][data-part="control"]');if(r){this.spreadProps(r,this.api.getControlProps());let i=r.querySelector(':scope > [data-scope="checkbox"][data-part="indicator"]');i&&this.spreadProps(i,this.api.getIndicatorProps())}}},Lf={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=new Df(e,y(m({id:e.id},O(e,"controlled")?{checked:O(e,"checked")}:{defaultChecked:O(e,"defaultChecked")}),{disabled:O(e,"disabled"),name:x(e,"name"),form:x(e,"form"),value:x(e,"value"),dir:Gt(e),invalid:O(e,"invalid"),required:O(e,"required"),readOnly:O(e,"readOnly"),onCheckedChange:r=>{let i=x(e,"onCheckedChange");i&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(i,{checked:r.checked,id:e.id});let s=x(e,"onCheckedChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{value:r,id:e.id}}))}}));n.init(),this.checkbox=n,this.onSetChecked=r=>{let{checked:i}=r.detail;n.api.setChecked(i)},e.addEventListener("phx:checkbox:set-checked",this.onSetChecked),this.onToggleChecked=()=>{n.api.toggleChecked()},e.addEventListener("phx:checkbox:toggle-checked",this.onToggleChecked),this.handlers=[],this.handlers.push(this.handleEvent("checkbox_set_checked",r=>{let i=r.id;i&&i!==e.id||n.api.setChecked(r.checked)})),this.handlers.push(this.handleEvent("checkbox_toggle_checked",r=>{let i=r.id;i&&i!==e.id||n.api.toggleChecked()})),this.handlers.push(this.handleEvent("checkbox_checked",()=>{this.pushEvent("checkbox_checked_response",{value:n.api.checked})})),this.handlers.push(this.handleEvent("checkbox_focused",()=>{this.pushEvent("checkbox_focused_response",{value:n.api.focused})})),this.handlers.push(this.handleEvent("checkbox_disabled",()=>{this.pushEvent("checkbox_disabled_response",{value:n.api.disabled})}))},updated(){var e;(e=this.checkbox)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{checked:O(this.el,"checked")}:{defaultChecked:O(this.el,"defaultChecked")}),{disabled:O(this.el,"disabled"),name:x(this.el,"name"),form:x(this.el,"form"),value:x(this.el,"value"),dir:Gt(this.el),invalid:O(this.el,"invalid"),required:O(this.el,"required"),readOnly:O(this.el,"readOnly"),label:x(this.el,"label")}))},destroyed(){var e;if(this.onSetChecked&&this.el.removeEventListener("phx:checkbox:set-checked",this.onSetChecked),this.onToggleChecked&&this.el.removeEventListener("phx:checkbox:toggle-checked",this.onToggleChecked),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.checkbox)==null||e.destroy()}}});var wl={};Oe(wl,{Clipboard:()=>Xf});function Bf(e,t){let n=e.createElement("pre");return Object.assign(n.style,{width:"1px",height:"1px",position:"fixed",top:"5px"}),n.textContent=t,n}function Gf(e){let n=oe(e).getSelection();if(n==null)return Promise.reject(new Error);n.removeAllRanges();let r=e.ownerDocument,i=r.createRange();return i.selectNodeContents(e),n.addRange(i),r.execCommand("copy"),n.removeAllRanges(),Promise.resolve()}function Uf(e,t){var i;let n=e.defaultView||window;if(((i=n.navigator.clipboard)==null?void 0:i.writeText)!==void 0)return n.navigator.clipboard.writeText(t);if(!e.body)return Promise.reject(new Error);let r=Bf(e,t);return e.body.appendChild(r),Gf(r),e.body.removeChild(r),Promise.resolve()}function qf(e,t){let{state:n,send:r,context:i,scope:s}=e,o=n.matches("copied");return{copied:o,value:i.get("value"),setValue(a){r({type:"VALUE.SET",value:a})},copy(){r({type:"COPY"})},getRootProps(){return t.element(y(m({},Yn.root.attrs),{"data-copied":T(o),id:Mf(s)}))},getLabelProps(){return t.label(y(m({},Yn.label.attrs),{htmlFor:eo(s),"data-copied":T(o),id:$f(s)}))},getControlProps(){return t.element(y(m({},Yn.control.attrs),{"data-copied":T(o)}))},getInputProps(){return t.input(y(m({},Yn.input.attrs),{defaultValue:i.get("value"),"data-copied":T(o),readOnly:!0,"data-readonly":"true",id:eo(s),onFocus(a){a.currentTarget.select()},onCopy(){r({type:"INPUT.COPY"})}}))},getTriggerProps(){return t.button(y(m({},Yn.trigger.attrs),{type:"button","aria-label":o?"Copied to clipboard":"Copy to clipboard","data-copied":T(o),onClick(){r({type:"COPY"})}}))},getIndicatorProps(a){return t.element(y(m({},Yn.indicator.attrs),{hidden:a.copied!==o}))}}}var Ff,Yn,Mf,eo,$f,_f,Hf,Wf,Kf,WI,Yf,KI,jf,Xf,Vl=fe(()=>{"use strict";me();Ff=Z("clipboard").parts("root","control","trigger","indicator","input","label"),Yn=Ff.build(),Mf=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`clip:${e.id}`},eo=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.input)!=null?n:`clip:${e.id}:input`},$f=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`clip:${e.id}:label`},_f=e=>e.getById(eo(e)),Hf=(e,t)=>Uf(e.getDoc(),t);Wf={props({props:e}){return m({timeout:3e3,defaultValue:""},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(n){var r;(r=e("onValueChange"))==null||r({value:n})}}))}},watch({track:e,context:t,action:n}){e([()=>t.get("value")],()=>{n(["syncInputElement"])})},on:{"VALUE.SET":{actions:["setValue"]},COPY:{target:"copied",actions:["copyToClipboard","invokeOnCopy"]}},states:{idle:{on:{"INPUT.COPY":{target:"copied",actions:["invokeOnCopy"]}}},copied:{effects:["waitForTimeout"],on:{"COPY.DONE":{target:"idle"},COPY:{target:"copied",actions:["copyToClipboard","invokeOnCopy"]},"INPUT.COPY":{actions:["invokeOnCopy"]}}}},implementations:{effects:{waitForTimeout({prop:e,send:t}){return Un(()=>{t({type:"COPY.DONE"})},e("timeout"))}},actions:{setValue({context:e,event:t}){e.set("value",t.value)},copyToClipboard({context:e,scope:t}){Hf(t,e.get("value"))},invokeOnCopy({prop:e}){var t;(t=e("onStatusChange"))==null||t({copied:!0})},syncInputElement({context:e,scope:t}){let n=_f(t);n&&xt(n,e.get("value"))}}}},Kf=G()(["getRootNode","id","ids","value","defaultValue","timeout","onStatusChange","onValueChange"]),WI=B(Kf),Yf=G()(["copied"]),KI=B(Yf),jf=class extends te{initMachine(e){return new ee(Wf,e)}initApi(){return qf(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="clipboard"][data-part="root"]');if(e){this.spreadProps(e,this.api.getRootProps());let t=e.querySelector('[data-scope="clipboard"][data-part="label"]');t&&this.spreadProps(t,this.api.getLabelProps());let n=e.querySelector('[data-scope="clipboard"][data-part="control"]');if(n){this.spreadProps(n,this.api.getControlProps());let r=n.querySelector('[data-scope="clipboard"][data-part="input"]');if(r){let s=m({},this.api.getInputProps()),o=this.el.dataset.inputAriaLabel;o&&(s["aria-label"]=o),this.spreadProps(r,s)}let i=n.querySelector('[data-scope="clipboard"][data-part="trigger"]');if(i){let s=m({},this.api.getTriggerProps()),o=this.el.dataset.triggerAriaLabel;o&&(s["aria-label"]=o),this.spreadProps(i,s)}}}}},Xf={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=this.liveSocket,r=new jf(e,y(m({id:e.id,timeout:Se(e,"timeout")},O(e,"controlled")?{value:x(e,"value")}:{defaultValue:x(e,"defaultValue")}),{onValueChange:i=>{var o;let s=x(e,"onValueChange");s&&n.main.isConnected()&&t(s,{id:e.id,value:(o=i.value)!=null?o:null})},onStatusChange:i=>{let s=x(e,"onStatusChange");s&&n.main.isConnected()&&t(s,{id:e.id,copied:i.copied});let o=x(e,"onStatusChangeClient");o&&e.dispatchEvent(new CustomEvent(o,{bubbles:!0}))}}));r.init(),this.clipboard=r,this.onCopy=()=>{r.api.copy()},e.addEventListener("phx:clipboard:copy",this.onCopy),this.onSetValue=i=>{let{value:s}=i.detail;r.api.setValue(s)},e.addEventListener("phx:clipboard:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("clipboard_copy",i=>{let s=i.clipboard_id;s&&s!==e.id||r.api.copy()})),this.handlers.push(this.handleEvent("clipboard_set_value",i=>{let s=i.clipboard_id;s&&s!==e.id||r.api.setValue(i.value)})),this.handlers.push(this.handleEvent("clipboard_copied",()=>{this.pushEvent("clipboard_copied_response",{value:r.api.copied})}))},updated(){var e;(e=this.clipboard)==null||e.updateProps(y(m({id:this.el.id,timeout:Se(this.el,"timeout")},O(this.el,"controlled")?{value:x(this.el,"value")}:{defaultValue:x(this.el,"value")}),{dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onCopy&&this.el.removeEventListener("phx:clipboard:copy",this.onCopy),this.onSetValue&&this.el.removeEventListener("phx:clipboard:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.clipboard)==null||e.destroy()}}});var xl={};Oe(xl,{Collapsible:()=>rp});function Qf(e,t){let{state:n,send:r,context:i,scope:s,prop:o}=e,a=n.matches("open")||n.matches("closing"),l=n.matches("open"),c=n.matches("closed"),{width:u,height:h}=i.get("size"),p=!!o("disabled"),d=o("collapsedHeight"),g=o("collapsedWidth"),v=d!=null,b=g!=null,V=v||b,S=!i.get("initial")&&l;return{disabled:p,visible:a,open:l,measureSize(){r({type:"size.measure"})},setOpen(E){n.matches("open")!==E&&r({type:E?"open":"close"})},getRootProps(){return t.element(y(m({},Vi.root.attrs),{"data-state":l?"open":"closed",dir:o("dir"),id:Jf(s)}))},getContentProps(){return t.element(y(m({},Vi.content.attrs),{id:to(s),"data-collapsible":"","data-state":S?void 0:l?"open":"closed","data-disabled":T(p),"data-has-collapsed-size":T(V),hidden:!a&&!V,dir:o("dir"),style:m(m({"--height":Ae(h),"--width":Ae(u),"--collapsed-height":Ae(d),"--collapsed-width":Ae(g)},c&&v&&{overflow:"hidden",minHeight:Ae(d),maxHeight:Ae(d)}),c&&b&&{overflow:"hidden",minWidth:Ae(g),maxWidth:Ae(g)})}))},getTriggerProps(){return t.element(y(m({},Vi.trigger.attrs),{id:zf(s),dir:o("dir"),type:"button","data-state":l?"open":"closed","data-disabled":T(p),"aria-controls":to(s),"aria-expanded":a||!1,onClick(E){E.defaultPrevented||p||r({type:l?"close":"open"})}}))},getIndicatorProps(){return t.element(y(m({},Vi.indicator.attrs),{dir:o("dir"),"data-state":l?"open":"closed","data-disabled":T(p)}))}}}var Zf,Vi,Jf,to,zf,Pr,ep,tp,ZI,np,rp,kl=fe(()=>{"use strict";me();Zf=Z("collapsible").parts("root","trigger","content","indicator"),Vi=Zf.build(),Jf=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`collapsible:${e.id}`},to=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`collapsible:${e.id}:content`},zf=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`collapsible:${e.id}:trigger`},Pr=e=>e.getById(to(e));ep={initialState({prop:e}){return e("open")||e("defaultOpen")?"open":"closed"},context({bindable:e}){return{size:e(()=>({defaultValue:{height:0,width:0},sync:!0})),initial:e(()=>({defaultValue:!1}))}},refs(){return{cleanup:void 0,stylesRef:void 0}},watch({track:e,prop:t,action:n}){e([()=>t("open")],()=>{n(["setInitial","computeSize","toggleVisibility"])})},exit:["cleanupNode"],states:{closed:{effects:["trackTabbableElements"],on:{"controlled.open":{target:"open"},open:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitial","computeSize","invokeOnOpen"]}]}},closing:{effects:["trackExitAnimation"],on:{"controlled.close":{target:"closed"},"controlled.open":{target:"open"},open:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitial","invokeOnOpen"]}],close:[{guard:"isOpenControlled",actions:["invokeOnExitComplete"]},{target:"closed",actions:["setInitial","computeSize","invokeOnExitComplete"]}],"animation.end":{target:"closed",actions:["invokeOnExitComplete","clearInitial"]}}},open:{effects:["trackEnterAnimation"],on:{"controlled.close":{target:"closing"},close:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closing",actions:["setInitial","computeSize","invokeOnClose"]}],"size.measure":{actions:["measureSize"]},"animation.end":{actions:["clearInitial"]}}}},implementations:{guards:{isOpenControlled:({prop:e})=>e("open")!=null},effects:{trackEnterAnimation:({send:e,scope:t})=>{let n,r=H(()=>{let i=Pr(t);if(!i)return;let s=qt(i).animationName;if(!s||s==="none"){e({type:"animation.end"});return}let a=l=>{K(l)===i&&e({type:"animation.end"})};i.addEventListener("animationend",a),n=()=>{i.removeEventListener("animationend",a)}});return()=>{r(),n==null||n()}},trackExitAnimation:({send:e,scope:t})=>{let n,r=H(()=>{let i=Pr(t);if(!i)return;let s=qt(i).animationName;if(!s||s==="none"){e({type:"animation.end"});return}let a=c=>{K(c)===i&&e({type:"animation.end"})};i.addEventListener("animationend",a);let l=cn(i,{animationFillMode:"forwards"});n=()=>{i.removeEventListener("animationend",a),an(()=>l())}});return()=>{r(),n==null||n()}},trackTabbableElements:({scope:e,prop:t})=>{if(!t("collapsedHeight")&&!t("collapsedWidth"))return;let n=Pr(e);if(!n)return;let r=()=>{let a=on(n).map(l=>za(l,"inert",""));return()=>{a.forEach(l=>l())}},i=r(),s=ja(n,{callback(){i(),i=r()}});return()=>{i(),s()}}},actions:{setInitial:({context:e,flush:t})=>{t(()=>{e.set("initial",!0)})},clearInitial:({context:e})=>{e.set("initial",!1)},cleanupNode:({refs:e})=>{e.set("stylesRef",null)},measureSize:({context:e,scope:t})=>{let n=Pr(t);if(!n)return;let{height:r,width:i}=n.getBoundingClientRect();e.set("size",{height:r,width:i})},computeSize:({refs:e,scope:t,context:n})=>{var i;(i=e.get("cleanup"))==null||i();let r=H(()=>{let s=Pr(t);if(!s)return;let o=s.hidden;s.style.animationName="none",s.style.animationDuration="0s",s.hidden=!1;let a=s.getBoundingClientRect();n.set("size",{height:a.height,width:a.width}),n.get("initial")&&(s.style.animationName="",s.style.animationDuration=""),s.hidden=o});e.set("cleanup",r)},invokeOnOpen:({prop:e})=>{var t;(t=e("onOpenChange"))==null||t({open:!0})},invokeOnClose:({prop:e})=>{var t;(t=e("onOpenChange"))==null||t({open:!1})},invokeOnExitComplete:({prop:e})=>{var t;(t=e("onExitComplete"))==null||t()},toggleVisibility:({prop:e,send:t})=>{t({type:e("open")?"controlled.open":"controlled.close"})}}}},tp=G()(["dir","disabled","getRootNode","id","ids","collapsedHeight","collapsedWidth","onExitComplete","onOpenChange","defaultOpen","open"]),ZI=B(tp),np=class extends te{initMachine(e){return new ee(ep,e)}initApi(){return Qf(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="collapsible"][data-part="root"]');if(e){this.spreadProps(e,this.api.getRootProps());let t=e.querySelector('[data-scope="collapsible"][data-part="trigger"]');t&&this.spreadProps(t,this.api.getTriggerProps());let n=e.querySelector('[data-scope="collapsible"][data-part="content"]');n&&this.spreadProps(n,this.api.getContentProps())}}},rp={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=new np(e,y(m({id:e.id},O(e,"controlled")?{open:O(e,"open")}:{defaultOpen:O(e,"defaultOpen")}),{disabled:O(e,"disabled"),dir:x(e,"dir",["ltr","rtl"]),onOpenChange:r=>{let i=x(e,"onOpenChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,open:r.open});let s=x(e,"onOpenChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,open:r.open}}))}}));n.init(),this.collapsible=n,this.onSetOpen=r=>{let{open:i}=r.detail;n.api.setOpen(i)},e.addEventListener("phx:collapsible:set-open",this.onSetOpen),this.handlers=[],this.handlers.push(this.handleEvent("collapsible_set_open",r=>{let i=r.collapsible_id;i&&i!==e.id||n.api.setOpen(r.open)})),this.handlers.push(this.handleEvent("collapsible_open",()=>{this.pushEvent("collapsible_open_response",{value:n.api.open})}))},updated(){var e;(e=this.collapsible)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{open:O(this.el,"open")}:{defaultOpen:O(this.el,"defaultOpen")}),{disabled:O(this.el,"disabled"),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onSetOpen&&this.el.removeEventListener("phx:collapsible:set-open",this.onSetOpen),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.collapsible)==null||e.destroy()}}});function wr(e,t,...n){return[...e.slice(0,t),...n,...e.slice(t)]}function xi(e,t,n){t=[...t].sort((i,s)=>i-s);let r=t.map(i=>e[i]);for(let i=t.length-1;i>=0;i--)e=[...e.slice(0,t[i]),...e.slice(t[i]+1)];return n=Math.max(0,n-t.filter(i=>it[n])return 1}return e.length-t.length}function lp(e){return e.sort(Ll)}function cp(e,t){let n;return $e(e,y(m({},t),{onEnter:(r,i)=>{if(t.predicate(r,i))return n=r,"stop"}})),n}function up(e,t){let n=[];return $e(e,{onEnter:(r,i)=>{t.predicate(r,i)&&n.push(r)},getChildren:t.getChildren}),n}function Nl(e,t){let n;return $e(e,{onEnter:(r,i)=>{if(t.predicate(r,i))return n=[...i],"stop"},getChildren:t.getChildren}),n}function dp(e,t){let n=t.initialResult;return $e(e,y(m({},t),{onEnter:(r,i)=>{n=t.nextResult(n,r,i)}})),n}function hp(e,t){return dp(e,y(m({},t),{initialResult:[],nextResult:(n,r,i)=>(n.push(...t.transform(r,i)),n)}))}function gp(e,t){let{predicate:n,create:r,getChildren:i}=t,s=(o,a)=>{let l=i(o,a),c=[];l.forEach((d,g)=>{let v=[...a,g],b=s(d,v);b&&c.push(b)});let u=a.length===0,h=n(o,a),p=c.length>0;return u||h||p?r(o,c,a):null};return s(e,[])||r(e,[],[])}function fp(e,t){let n=[],r=0,i=new Map,s=new Map;return $e(e,{getChildren:t.getChildren,onEnter:(o,a)=>{i.has(o)||i.set(o,r++);let l=t.getChildren(o,a);l.forEach(d=>{s.has(d)||s.set(d,o),i.has(d)||i.set(d,r++)});let c=l.length>0?l.map(d=>i.get(d)):void 0,u=s.get(o),h=u?i.get(u):void 0,p=i.get(o);n.push(y(m({},o),{_children:c,_parent:h,_index:p}))}}),n}function pp(e,t){return{type:"insert",index:e,nodes:t}}function mp(e){return{type:"remove",indexes:e}}function no(){return{type:"replace"}}function Fl(e){return[e.slice(0,-1),e[e.length-1]]}function Ml(e,t,n=new Map){var o;let[r,i]=Fl(e);for(let a=r.length-1;a>=0;a--){let l=r.slice(0,a).join();switch((o=n.get(l))==null?void 0:o.type){case"remove":continue}n.set(l,no())}let s=n.get(r.join());switch(s==null?void 0:s.type){case"remove":n.set(r.join(),{type:"removeThenInsert",removeIndexes:s.indexes,insertIndex:i,insertNodes:t});break;default:n.set(r.join(),pp(i,t))}return n}function $l(e){var r;let t=new Map,n=new Map;for(let i of e){let s=i.slice(0,-1).join(),o=(r=n.get(s))!=null?r:[];o.push(i[i.length-1]),n.set(s,o.sort((a,l)=>a-l))}for(let i of e)for(let s=i.length-2;s>=0;s--){let o=i.slice(0,s).join();t.has(o)||t.set(o,no())}for(let[i,s]of n)t.set(i,mp(s));return t}function vp(e,t){let n=new Map,[r,i]=Fl(e);for(let s=r.length-1;s>=0;s--){let o=r.slice(0,s).join();n.set(o,no())}return n.set(r.join(),{type:"removeThenInsert",removeIndexes:[i],insertIndex:i,insertNodes:[t]}),n}function Ni(e,t,n){return yp(e,y(m({},n),{getChildren:(r,i)=>{let s=i.join(),o=t.get(s);switch(o==null?void 0:o.type){case"replace":case"remove":case"removeThenInsert":case"insert":return n.getChildren(r,i);default:return[]}},transform:(r,i,s)=>{let o=s.join(),a=t.get(o);switch(a==null?void 0:a.type){case"remove":return n.create(r,i.filter((u,h)=>!a.indexes.includes(h)),s);case"removeThenInsert":let l=i.filter((u,h)=>!a.removeIndexes.includes(h)),c=a.removeIndexes.reduce((u,h)=>h{var u,h;let s=[0,...i],o=s.join(),a=t.transform(r,(u=n[o])!=null?u:[],i),l=s.slice(0,-1).join(),c=(h=n[l])!=null?h:[];c.push(a),n[l]=c}})),n[""][0]}function bp(e,t){let{nodes:n,at:r}=t;if(r.length===0)throw new Error("Can't insert nodes at the root");let i=Ml(r,n);return Ni(e,i,t)}function Ep(e,t){if(t.at.length===0)return t.node;let n=vp(t.at,t.node);return Ni(e,n,t)}function Cp(e,t){if(t.indexPaths.length===0)return e;for(let r of t.indexPaths)if(r.length===0)throw new Error("Can't remove the root node");let n=$l(t.indexPaths);return Ni(e,n,t)}function Ip(e,t){if(t.indexPaths.length===0)return e;for(let s of t.indexPaths)if(s.length===0)throw new Error("Can't move the root node");if(t.to.length===0)throw new Error("Can't move nodes to the root");let n=ap(t.indexPaths),r=n.map(s=>Dl(e,s,t)),i=Ml(t.to,r,$l(n));return Ni(e,i,t)}function $e(e,t){let{onEnter:n,onLeave:r,getChildren:i}=t,s=[],o=[{node:e}],a=t.reuseIndexPath?()=>s:()=>s.slice();for(;o.length>0;){let l=o[o.length-1];if(l.state===void 0){let u=n==null?void 0:n(l.node,a());if(u==="stop")return;l.state=u==="skip"?-1:0}let c=l.children||i(l.node,a());if(l.children||(l.children=c),l.state!==-1){if(l.state{"use strict";me();ip=Object.defineProperty,sp=(e,t,n)=>t in e?ip(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$=(e,t,n)=>sp(e,typeof t!="symbol"?t+"":t,n),ki={itemToValue(e){return typeof e=="string"?e:Yt(e)&&Me(e,"value")?e.value:""},itemToString(e){return typeof e=="string"?e:Yt(e)&&Me(e,"label")?e.label:ki.itemToValue(e)},isItemDisabled(e){return Yt(e)&&Me(e,"disabled")?!!e.disabled:!1}},Xn=class Rl{constructor(t){this.options=t,$(this,"items"),$(this,"indexMap",null),$(this,"copy",n=>new Rl(y(m({},this.options),{items:n!=null?n:[...this.items]}))),$(this,"isEqual",n=>he(this.items,n.items)),$(this,"setItems",n=>this.copy(n)),$(this,"getValues",(n=this.items)=>{let r=[];for(let i of n){let s=this.getItemValue(i);s!=null&&r.push(s)}return r}),$(this,"find",n=>{if(n==null)return null;let r=this.indexOf(n);return r!==-1?this.at(r):null}),$(this,"findMany",n=>{let r=[];for(let i of n){let s=this.find(i);s!=null&&r.push(s)}return r}),$(this,"at",n=>{var s;if(!this.options.groupBy&&!this.options.groupSort)return(s=this.items[n])!=null?s:null;let r=0,i=this.group();for(let[,o]of i)for(let a of o){if(r===n)return a;r++}return null}),$(this,"sortFn",(n,r)=>{let i=this.indexOf(n),s=this.indexOf(r);return(i!=null?i:0)-(s!=null?s:0)}),$(this,"sort",n=>[...n].sort(this.sortFn.bind(this))),$(this,"getItemValue",n=>{var r,i,s;return n==null?null:(s=(i=(r=this.options).itemToValue)==null?void 0:i.call(r,n))!=null?s:ki.itemToValue(n)}),$(this,"getItemDisabled",n=>{var r,i,s;return n==null?!1:(s=(i=(r=this.options).isItemDisabled)==null?void 0:i.call(r,n))!=null?s:ki.isItemDisabled(n)}),$(this,"stringifyItem",n=>{var r,i,s;return n==null?null:(s=(i=(r=this.options).itemToString)==null?void 0:i.call(r,n))!=null?s:ki.itemToString(n)}),$(this,"stringify",n=>n==null?null:this.stringifyItem(this.find(n))),$(this,"stringifyItems",(n,r=", ")=>{let i=[];for(let s of n){let o=this.stringifyItem(s);o!=null&&i.push(o)}return i.join(r)}),$(this,"stringifyMany",(n,r)=>this.stringifyItems(this.findMany(n),r)),$(this,"has",n=>this.indexOf(n)!==-1),$(this,"hasItem",n=>n==null?!1:this.has(this.getItemValue(n))),$(this,"group",()=>{let{groupBy:n,groupSort:r}=this.options;if(!n)return[["",[...this.items]]];let i=new Map;this.items.forEach((o,a)=>{let l=n(o,a);i.has(l)||i.set(l,[]),i.get(l).push(o)});let s=Array.from(i.entries());return r&&s.sort(([o],[a])=>{if(typeof r=="function")return r(o,a);if(Array.isArray(r)){let l=r.indexOf(o),c=r.indexOf(a);return l===-1?1:c===-1?-1:l-c}return r==="asc"?o.localeCompare(a):r==="desc"?a.localeCompare(o):0}),s}),$(this,"getNextValue",(n,r=1,i=!1)=>{let s=this.indexOf(n);if(s===-1)return null;for(s=i?Math.min(s+r,this.size-1):s+r;s<=this.size&&this.getItemDisabled(this.at(s));)s++;return this.getItemValue(this.at(s))}),$(this,"getPreviousValue",(n,r=1,i=!1)=>{let s=this.indexOf(n);if(s===-1)return null;for(s=i?Math.max(s-r,0):s-r;s>=0&&this.getItemDisabled(this.at(s));)s--;return this.getItemValue(this.at(s))}),$(this,"indexOf",n=>{var r;if(n==null)return-1;if(!this.options.groupBy&&!this.options.groupSort)return this.items.findIndex(i=>this.getItemValue(i)===n);if(!this.indexMap){this.indexMap=new Map;let i=0,s=this.group();for(let[,o]of s)for(let a of o){let l=this.getItemValue(a);l!=null&&this.indexMap.set(l,i),i++}}return(r=this.indexMap.get(n))!=null?r:-1}),$(this,"getByText",(n,r)=>{let i=r!=null?this.indexOf(r):-1,s=n.length===1;for(let o=0;o{let{state:i,currentValue:s,timeout:o=350}=r,a=i.keysSoFar+n,c=a.length>1&&Array.from(a).every(g=>g===a[0])?a[0]:a,u=this.getByText(c,s),h=this.getItemValue(u);function p(){clearTimeout(i.timer),i.timer=-1}function d(g){i.keysSoFar=g,p(),g!==""&&(i.timer=+setTimeout(()=>{d(""),p()},o))}return d(a),h}),$(this,"update",(n,r)=>{let i=this.indexOf(n);return i===-1?this:this.copy([...this.items.slice(0,i),r,...this.items.slice(i+1)])}),$(this,"upsert",(n,r,i="append")=>{let s=this.indexOf(n);return s===-1?(i==="append"?this.append:this.prepend)(r):this.copy([...this.items.slice(0,s),r,...this.items.slice(s+1)])}),$(this,"insert",(n,...r)=>this.copy(wr(this.items,n,...r))),$(this,"insertBefore",(n,...r)=>{let i=this.indexOf(n);if(i===-1)if(this.items.length===0)i=0;else return this;return this.copy(wr(this.items,i,...r))}),$(this,"insertAfter",(n,...r)=>{let i=this.indexOf(n);if(i===-1)if(this.items.length===0)i=0;else return this;return this.copy(wr(this.items,i+1,...r))}),$(this,"prepend",(...n)=>this.copy(wr(this.items,0,...n))),$(this,"append",(...n)=>this.copy(wr(this.items,this.items.length,...n))),$(this,"filter",n=>{let r=this.items.filter((i,s)=>n(this.stringifyItem(i),s,i));return this.copy(r)}),$(this,"remove",(...n)=>{let r=n.map(i=>typeof i=="string"?i:this.getItemValue(i));return this.copy(this.items.filter(i=>{let s=this.getItemValue(i);return s==null?!1:!r.includes(s)}))}),$(this,"move",(n,r)=>{let i=this.indexOf(n);return i===-1?this:this.copy(xi(this.items,[i],r))}),$(this,"moveBefore",(n,...r)=>{let i=this.items.findIndex(o=>this.getItemValue(o)===n);if(i===-1)return this;let s=r.map(o=>this.items.findIndex(a=>this.getItemValue(a)===o)).sort((o,a)=>o-a);return this.copy(xi(this.items,s,i))}),$(this,"moveAfter",(n,...r)=>{let i=this.items.findIndex(o=>this.getItemValue(o)===n);if(i===-1)return this;let s=r.map(o=>this.items.findIndex(a=>this.getItemValue(a)===o)).sort((o,a)=>o-a);return this.copy(xi(this.items,s,i+1))}),$(this,"reorder",(n,r)=>this.copy(xi(this.items,[n],r))),$(this,"compareValue",(n,r)=>{let i=this.indexOf(n),s=this.indexOf(r);return is?1:0}),$(this,"range",(n,r)=>{let i=[],s=n;for(;s!=null;){if(this.find(s)&&i.push(s),s===r)return i;s=this.getNextValue(s)}return[]}),$(this,"getValueRange",(n,r)=>n&&r?this.compareValue(n,r)<=0?this.range(n,r):this.range(r,n):[]),$(this,"toString",()=>{let n="";for(let r of this.items){let i=this.getItemValue(r),s=this.stringifyItem(r),o=this.getItemDisabled(r),a=[i,s,o].filter(Boolean).join(":");n+=a+","}return n}),$(this,"toJSON",()=>({size:this.size,first:this.firstValue,last:this.lastValue})),this.items=[...t.items]}get size(){return this.items.length}get firstValue(){let t=0;for(;this.getItemDisabled(this.at(t));)t++;return this.getItemValue(this.at(t))}get lastValue(){let t=this.size-1;for(;this.getItemDisabled(this.at(t));)t--;return this.getItemValue(this.at(t))}*[Symbol.iterator](){yield*Ea(this.items)}},op=(e,t)=>!!(e!=null&&e.toLowerCase().startsWith(t.toLowerCase()));ro=class _l{constructor(t){this.options=t,$(this,"rootNode"),$(this,"isEqual",n=>he(this.rootNode,n.rootNode)),$(this,"getNodeChildren",n=>{var r,i,s,o;return(o=(s=(i=(r=this.options).nodeToChildren)==null?void 0:i.call(r,n))!=null?s:jn.nodeToChildren(n))!=null?o:[]}),$(this,"resolveIndexPath",n=>typeof n=="string"?this.getIndexPath(n):n),$(this,"resolveNode",n=>{let r=this.resolveIndexPath(n);return r?this.at(r):void 0}),$(this,"getNodeChildrenCount",n=>{var r,i,s;return(s=(i=(r=this.options).nodeToChildrenCount)==null?void 0:i.call(r,n))!=null?s:jn.nodeToChildrenCount(n)}),$(this,"getNodeValue",n=>{var r,i,s;return(s=(i=(r=this.options).nodeToValue)==null?void 0:i.call(r,n))!=null?s:jn.nodeToValue(n)}),$(this,"getNodeDisabled",n=>{var r,i,s;return(s=(i=(r=this.options).isNodeDisabled)==null?void 0:i.call(r,n))!=null?s:jn.isNodeDisabled(n)}),$(this,"stringify",n=>{let r=this.findNode(n);return r?this.stringifyNode(r):null}),$(this,"stringifyNode",n=>{var r,i,s;return(s=(i=(r=this.options).nodeToString)==null?void 0:i.call(r,n))!=null?s:jn.nodeToString(n)}),$(this,"getFirstNode",(n=this.rootNode,r={})=>{let i;return $e(n,{getChildren:this.getNodeChildren,onEnter:(s,o)=>{var a;if(!this.isSameNode(s,n)){if((a=r.skip)!=null&&a.call(r,{value:this.getNodeValue(s),node:s,indexPath:o}))return"skip";if(!i&&o.length>0&&!this.getNodeDisabled(s))return i=s,"stop"}}}),i}),$(this,"getLastNode",(n=this.rootNode,r={})=>{let i;return $e(n,{getChildren:this.getNodeChildren,onEnter:(s,o)=>{var a;if(!this.isSameNode(s,n)){if((a=r.skip)!=null&&a.call(r,{value:this.getNodeValue(s),node:s,indexPath:o}))return"skip";o.length>0&&!this.getNodeDisabled(s)&&(i=s)}}}),i}),$(this,"at",n=>Dl(this.rootNode,n,{getChildren:this.getNodeChildren})),$(this,"findNode",(n,r=this.rootNode)=>cp(r,{getChildren:this.getNodeChildren,predicate:i=>this.getNodeValue(i)===n})),$(this,"findNodes",(n,r=this.rootNode)=>{let i=new Set(n.filter(s=>s!=null));return up(r,{getChildren:this.getNodeChildren,predicate:s=>i.has(this.getNodeValue(s))})}),$(this,"sort",n=>n.reduce((r,i)=>{let s=this.getIndexPath(i);return s&&r.push({value:i,indexPath:s}),r},[]).sort((r,i)=>Ll(r.indexPath,i.indexPath)).map(({value:r})=>r)),$(this,"getIndexPath",n=>Nl(this.rootNode,{getChildren:this.getNodeChildren,predicate:r=>this.getNodeValue(r)===n})),$(this,"getValue",n=>{let r=this.at(n);return r?this.getNodeValue(r):void 0}),$(this,"getValuePath",n=>{if(!n)return[];let r=[],i=[...n];for(;i.length>0;){let s=this.at(i);s&&r.unshift(this.getNodeValue(s)),i.pop()}return r}),$(this,"getDepth",n=>{var i;let r=Nl(this.rootNode,{getChildren:this.getNodeChildren,predicate:s=>this.getNodeValue(s)===n});return(i=r==null?void 0:r.length)!=null?i:0}),$(this,"isSameNode",(n,r)=>this.getNodeValue(n)===this.getNodeValue(r)),$(this,"isRootNode",n=>this.isSameNode(n,this.rootNode)),$(this,"contains",(n,r)=>!n||!r?!1:r.slice(0,n.length).every((i,s)=>n[s]===r[s])),$(this,"getNextNode",(n,r={})=>{let i=!1,s;return $e(this.rootNode,{getChildren:this.getNodeChildren,onEnter:(o,a)=>{var c;if(this.isRootNode(o))return;let l=this.getNodeValue(o);if((c=r.skip)!=null&&c.call(r,{value:l,node:o,indexPath:a}))return l===n&&(i=!0),"skip";if(i&&!this.getNodeDisabled(o))return s=o,"stop";l===n&&(i=!0)}}),s}),$(this,"getPreviousNode",(n,r={})=>{let i,s=!1;return $e(this.rootNode,{getChildren:this.getNodeChildren,onEnter:(o,a)=>{var c;if(this.isRootNode(o))return;let l=this.getNodeValue(o);if((c=r.skip)!=null&&c.call(r,{value:l,node:o,indexPath:a}))return"skip";if(l===n)return s=!0,"stop";this.getNodeDisabled(o)||(i=o)}}),s?i:void 0}),$(this,"getParentNodes",n=>{var s;let r=(s=this.resolveIndexPath(n))==null?void 0:s.slice();if(!r)return[];let i=[];for(;r.length>0;){r.pop();let o=this.at(r);o&&!this.isRootNode(o)&&i.unshift(o)}return i}),$(this,"getDescendantNodes",(n,r)=>{let i=this.resolveNode(n);if(!i)return[];let s=[];return $e(i,{getChildren:this.getNodeChildren,onEnter:(o,a)=>{a.length!==0&&(!(r!=null&&r.withBranch)&&this.isBranchNode(o)||s.push(o))}}),s}),$(this,"getDescendantValues",(n,r)=>this.getDescendantNodes(n,r).map(s=>this.getNodeValue(s))),$(this,"getParentIndexPath",n=>n.slice(0,-1)),$(this,"getParentNode",n=>{let r=this.resolveIndexPath(n);return r?this.at(this.getParentIndexPath(r)):void 0}),$(this,"visit",n=>{let s=n,{skip:r}=s,i=ze(s,["skip"]);$e(this.rootNode,y(m({},i),{getChildren:this.getNodeChildren,onEnter:(o,a)=>{var l;if(!this.isRootNode(o))return r!=null&&r({value:this.getNodeValue(o),node:o,indexPath:a})?"skip":(l=i.onEnter)==null?void 0:l.call(i,o,a)}}))}),$(this,"getPreviousSibling",n=>{let r=this.getParentNode(n);if(!r)return;let i=this.getNodeChildren(r),s=n[n.length-1];for(;--s>=0;){let o=i[s];if(!this.getNodeDisabled(o))return o}}),$(this,"getNextSibling",n=>{let r=this.getParentNode(n);if(!r)return;let i=this.getNodeChildren(r),s=n[n.length-1];for(;++s{let r=this.getParentNode(n);return r?this.getNodeChildren(r):[]}),$(this,"getValues",(n=this.rootNode)=>hp(n,{getChildren:this.getNodeChildren,transform:i=>[this.getNodeValue(i)]}).slice(1)),$(this,"isValidDepth",(n,r)=>r==null?!0:typeof r=="function"?r(n.length):n.length===r),$(this,"isBranchNode",n=>this.getNodeChildren(n).length>0||this.getNodeChildrenCount(n)!=null),$(this,"getBranchValues",(n=this.rootNode,r={})=>{let i=[];return $e(n,{getChildren:this.getNodeChildren,onEnter:(s,o)=>{var l;if(o.length===0)return;let a=this.getNodeValue(s);if((l=r.skip)!=null&&l.call(r,{value:a,node:s,indexPath:o}))return"skip";this.isBranchNode(s)&&this.isValidDepth(o,r.depth)&&i.push(this.getNodeValue(s))}}),i}),$(this,"flatten",(n=this.rootNode)=>fp(n,{getChildren:this.getNodeChildren})),$(this,"_create",(n,r)=>this.getNodeChildren(n).length>0||r.length>0?y(m({},n),{children:r}):m({},n)),$(this,"_insert",(n,r,i)=>this.copy(bp(n,{at:r,nodes:i,getChildren:this.getNodeChildren,create:this._create}))),$(this,"copy",n=>new _l(y(m({},this.options),{rootNode:n}))),$(this,"_replace",(n,r,i)=>this.copy(Ep(n,{at:r,node:i,getChildren:this.getNodeChildren,create:this._create}))),$(this,"_move",(n,r,i)=>this.copy(Ip(n,{indexPaths:r,to:i,getChildren:this.getNodeChildren,create:this._create}))),$(this,"_remove",(n,r)=>this.copy(Cp(n,{indexPaths:r,getChildren:this.getNodeChildren,create:this._create}))),$(this,"replace",(n,r)=>this._replace(this.rootNode,n,r)),$(this,"remove",n=>this._remove(this.rootNode,n)),$(this,"insertBefore",(n,r)=>this.getParentNode(n)?this._insert(this.rootNode,n,r):void 0),$(this,"insertAfter",(n,r)=>{if(!this.getParentNode(n))return;let s=[...n.slice(0,-1),n[n.length-1]+1];return this._insert(this.rootNode,s,r)}),$(this,"move",(n,r)=>this._move(this.rootNode,n,r)),$(this,"filter",n=>{let r=gp(this.rootNode,{predicate:n,getChildren:this.getNodeChildren,create:this._create});return this.copy(r)}),$(this,"toJSON",()=>this.getValues(this.rootNode)),this.rootNode=t.rootNode}},jn={nodeToValue(e){return typeof e=="string"?e:Yt(e)&&Me(e,"value")?e.value:""},nodeToString(e){return typeof e=="string"?e:Yt(e)&&Me(e,"label")?e.label:jn.nodeToValue(e)},isNodeDisabled(e){return Yt(e)&&Me(e,"disabled")?!!e.disabled:!1},nodeToChildren(e){return e.children},nodeToChildrenCount(e){if(Yt(e)&&Me(e,"childrenCount"))return e.childrenCount}}});function so(e,t,n){return _e(e,jt(t,n))}function At(e,t){return typeof e=="function"?e(t):e}function Rt(e){return e.split("-")[0]}function zn(e){return e.split("-")[1]}function lo(e){return e==="x"?"y":"x"}function co(e){return e==="y"?"height":"width"}function gt(e){return Pp.has(Rt(e))?"y":"x"}function uo(e){return lo(gt(e))}function wp(e,t,n){n===void 0&&(n=!1);let r=zn(e),i=uo(e),s=co(i),o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=Li(o)),[o,Li(o)]}function Vp(e){let t=Li(e);return[oo(e),t,oo(t)]}function oo(e){return e.replace(/start|end/g,t=>Sp[t])}function Np(e,t,n){switch(e){case"top":case"bottom":return n?t?Bl:Hl:t?Hl:Bl;case"left":case"right":return t?xp:kp;default:return[]}}function Ap(e,t,n,r){let i=zn(e),s=Np(Rt(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(oo)))),s}function Li(e){return e.replace(/left|right|bottom|top/g,t=>Op[t])}function Rp(e){return m({top:0,right:0,bottom:0,left:0},e)}function Jl(e){return typeof e!="number"?Rp(e):{top:e,right:e,bottom:e,left:e}}function Fi(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Gl(e,t,n){let{reference:r,floating:i}=e,s=gt(t),o=uo(t),a=co(o),l=Rt(t),c=s==="y",u=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,p=r[a]/2-i[a]/2,d;switch(l){case"top":d={x:u,y:r.y-i.height};break;case"bottom":d={x:u,y:r.y+r.height};break;case"right":d={x:r.x+r.width,y:h};break;case"left":d={x:r.x-i.width,y:h};break;default:d={x:r.x,y:r.y}}switch(zn(t)){case"start":d[o]-=p*(n&&c?-1:1);break;case"end":d[o]+=p*(n&&c?-1:1);break}return d}function Dp(e,t){return Ee(this,null,function*(){var n;t===void 0&&(t={});let{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:p=!1,padding:d=0}=At(t,e),g=Jl(d),b=a[p?h==="floating"?"reference":"floating":h],V=Fi(yield s.getClippingRect({element:(n=yield s.isElement==null?void 0:s.isElement(b))==null||n?b:b.contextElement||(yield s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),S=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,E=yield s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating),f=(yield s.isElement==null?void 0:s.isElement(E))?(yield s.getScale==null?void 0:s.getScale(E))||{x:1,y:1}:{x:1,y:1},C=Fi(s.convertOffsetParentRelativeRectToViewportRelativeRect?yield s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:S,offsetParent:E,strategy:l}):S);return{top:(V.top-C.top+g.top)/f.y,bottom:(C.bottom-V.bottom+g.bottom)/f.y,left:(V.left-C.left+g.left)/f.x,right:(C.right-V.right+g.right)/f.x}})}function Ul(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ql(e){return Tp.some(t=>e[t]>=0)}function _p(e,t){return Ee(this,null,function*(){let{placement:n,platform:r,elements:i}=e,s=yield r.isRTL==null?void 0:r.isRTL(i.floating),o=Rt(n),a=zn(n),l=gt(n)==="y",c=zl.has(o)?-1:1,u=s&&l?-1:1,h=At(t,e),{mainAxis:p,crossAxis:d,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof g=="number"&&(d=a==="end"?g*-1:g),l?{x:d*u,y:p*c}:{x:p*c,y:d*u}})}function Mi(){return typeof window!="undefined"}function Qn(e){return Ql(e)?(e.nodeName||"").toLowerCase():"#document"}function He(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function mt(e){var t;return(t=(Ql(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ql(e){return Mi()?e instanceof Node||e instanceof He(e).Node:!1}function st(e){return Mi()?e instanceof Element||e instanceof He(e).Element:!1}function pt(e){return Mi()?e instanceof HTMLElement||e instanceof He(e).HTMLElement:!1}function Wl(e){return!Mi()||typeof ShadowRoot=="undefined"?!1:e instanceof ShadowRoot||e instanceof He(e).ShadowRoot}function kr(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=ot(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!qp.has(i)}function Kp(e){return Wp.has(Qn(e))}function $i(e){return Yp.some(t=>{try{return e.matches(t)}catch(n){return!1}})}function ho(e){let t=go(),n=st(e)?ot(e):e;return jp.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Xp.some(r=>(n.willChange||"").includes(r))||Zp.some(r=>(n.contain||"").includes(r))}function Jp(e){let t=Xt(e);for(;pt(t)&&!Jn(t);){if(ho(t))return t;if($i(t))return null;t=Xt(t)}return null}function go(){return typeof CSS=="undefined"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Jn(e){return zp.has(Qn(e))}function ot(e){return He(e).getComputedStyle(e)}function _i(e){return st(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Xt(e){if(Qn(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Wl(e)&&e.host||mt(e);return Wl(t)?t.host:t}function ec(e){let t=Xt(e);return Jn(t)?e.ownerDocument?e.ownerDocument.body:e.body:pt(t)&&kr(t)?t:ec(t)}function xr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let i=ec(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=He(i);if(s){let a=ao(o);return t.concat(o,o.visualViewport||[],kr(i)?i:[],a&&n?xr(a):[])}return t.concat(i,xr(i,[],n))}function ao(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function tc(e){let t=ot(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=pt(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=Di(n)!==s||Di(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function fo(e){return st(e)?e:e.contextElement}function Zn(e){let t=fo(e);if(!pt(t))return ft(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:s}=tc(t),o=(s?Di(n.width):n.width)/r,a=(s?Di(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}function nc(e){let t=He(e);return!go()||!t.visualViewport?Qp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function em(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==He(e)?!1:t}function hn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),s=fo(e),o=ft(1);t&&(r?st(r)&&(o=Zn(r)):o=Zn(e));let a=em(s,n,r)?nc(s):ft(0),l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,h=i.height/o.y;if(s){let p=He(s),d=r&&st(r)?He(r):r,g=p,v=ao(g);for(;v&&r&&d!==g;){let b=Zn(v),V=v.getBoundingClientRect(),S=ot(v),E=V.left+(v.clientLeft+parseFloat(S.paddingLeft))*b.x,f=V.top+(v.clientTop+parseFloat(S.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,h*=b.y,l+=E,c+=f,g=He(v),v=ao(g)}}return Fi({width:u,height:h,x:l,y:c})}function Hi(e,t){let n=_i(e).scrollLeft;return t?t.left+n:hn(mt(e)).left+n}function rc(e,t){let n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Hi(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function tm(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,s=i==="fixed",o=mt(r),a=t?$i(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=ft(1),u=ft(0),h=pt(r);if((h||!h&&!s)&&((Qn(r)!=="body"||kr(o))&&(l=_i(r)),pt(r))){let d=hn(r);c=Zn(r),u.x=d.x+r.clientLeft,u.y=d.y+r.clientTop}let p=o&&!h&&!s?rc(o,l):ft(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+p.x,y:n.y*c.y-l.scrollTop*c.y+u.y+p.y}}function nm(e){return Array.from(e.getClientRects())}function rm(e){let t=mt(e),n=_i(e),r=e.ownerDocument.body,i=_e(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=_e(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Hi(e),a=-n.scrollTop;return ot(r).direction==="rtl"&&(o+=_e(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}function im(e,t){let n=He(e),r=mt(e),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;let u=go();(!u||u&&t==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}let c=Hi(r);if(c<=0){let u=r.ownerDocument,h=u.body,p=getComputedStyle(h),d=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-h.clientWidth-d);g<=Kl&&(s-=g)}else c<=Kl&&(s+=c);return{width:s,height:o,x:a,y:l}}function om(e,t){let n=hn(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=pt(e)?Zn(e):ft(1),o=e.clientWidth*s.x,a=e.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function Yl(e,t,n){let r;if(t==="viewport")r=im(e,n);else if(t==="document")r=rm(mt(e));else if(st(t))r=om(t,n);else{let i=nc(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Fi(r)}function ic(e,t){let n=Xt(e);return n===t||!st(n)||Jn(n)?!1:ot(n).position==="fixed"||ic(n,t)}function am(e,t){let n=t.get(e);if(n)return n;let r=xr(e,[],!1).filter(a=>st(a)&&Qn(a)!=="body"),i=null,s=ot(e).position==="fixed",o=s?Xt(e):e;for(;st(o)&&!Jn(o);){let a=ot(o),l=ho(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&sm.has(i.position)||kr(o)&&!l&&ic(e,o))?r=r.filter(u=>u!==o):i=a,o=Xt(o)}return t.set(e,r),r}function lm(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,o=[...n==="clippingAncestors"?$i(t)?[]:am(t,this._c):[].concat(n),r],a=o[0],l=o.reduce((c,u)=>{let h=Yl(t,u,i);return c.top=_e(h.top,c.top),c.right=jt(h.right,c.right),c.bottom=jt(h.bottom,c.bottom),c.left=_e(h.left,c.left),c},Yl(t,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function cm(e){let{width:t,height:n}=tc(e);return{width:t,height:n}}function um(e,t,n){let r=pt(t),i=mt(t),s=n==="fixed",o=hn(e,!0,s,t),a={scrollLeft:0,scrollTop:0},l=ft(0);function c(){l.x=Hi(i)}if(r||!r&&!s)if((Qn(t)!=="body"||kr(i))&&(a=_i(t)),r){let d=hn(t,!0,s,t);l.x=d.x+t.clientLeft,l.y=d.y+t.clientTop}else i&&c();s&&!r&&i&&c();let u=i&&!r&&!s?rc(i,a):ft(0),h=o.left+a.scrollLeft-l.x-u.x,p=o.top+a.scrollTop-l.y-u.y;return{x:h,y:p,width:o.width,height:o.height}}function io(e){return ot(e).position==="static"}function jl(e,t){if(!pt(e)||ot(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return mt(e)===n&&(n=n.ownerDocument.body),n}function sc(e,t){let n=He(e);if($i(e))return n;if(!pt(e)){let i=Xt(e);for(;i&&!Jn(i);){if(st(i)&&!io(i))return i;i=Xt(i)}return n}let r=jl(e,t);for(;r&&Kp(r)&&io(r);)r=jl(r,t);return r&&Jn(r)&&io(r)&&!ho(r)?n:r||Jp(e)||n}function hm(e){return ot(e).direction==="rtl"}function oc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function fm(e,t){let n=null,r,i=mt(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();let c=e.getBoundingClientRect(),{left:u,top:h,width:p,height:d}=c;if(a||t(),!p||!d)return;let g=Ri(h),v=Ri(i.clientWidth-(u+p)),b=Ri(i.clientHeight-(h+d)),V=Ri(u),E={rootMargin:-g+"px "+-v+"px "+-b+"px "+-V+"px",threshold:_e(0,jt(1,l))||1},f=!0;function C(I){let w=I[0].intersectionRatio;if(w!==l){if(!f)return o();w?o(!1,w):r=setTimeout(()=>{o(!1,1e-7)},1e3)}w===1&&!oc(c,e.getBoundingClientRect())&&o(),f=!1}try{n=new IntersectionObserver(C,y(m({},E),{root:i.ownerDocument}))}catch(I){n=new IntersectionObserver(C,E)}n.observe(e)}return o(!0),s}function pm(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=fo(e),u=i||s?[...c?xr(c):[],...xr(t)]:[];u.forEach(V=>{i&&V.addEventListener("scroll",n,{passive:!0}),s&&V.addEventListener("resize",n)});let h=c&&a?fm(c,n):null,p=-1,d=null;o&&(d=new ResizeObserver(V=>{let[S]=V;S&&S.target===c&&d&&(d.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var E;(E=d)==null||E.observe(t)})),n()}),c&&!l&&d.observe(c),d.observe(t));let g,v=l?hn(e):null;l&&b();function b(){let V=hn(e);v&&!oc(v,V)&&n(),v=V,g=requestAnimationFrame(b)}return n(),()=>{var V;u.forEach(S=>{i&&S.removeEventListener("scroll",n),s&&S.removeEventListener("resize",n)}),h==null||h(),(V=d)==null||V.disconnect(),d=null,l&&cancelAnimationFrame(g)}}function Xl(e=0,t=0,n=0,r=0){if(typeof DOMRect=="function")return new DOMRect(e,t,n,r);let i={x:e,y:t,width:n,height:r,top:t,right:e+n,bottom:t+r,left:e};return y(m({},i),{toJSON:()=>i})}function Om(e){if(!e)return Xl();let{x:t,y:n,width:r,height:i}=e;return Xl(t,n,r,i)}function Sm(e,t){return{contextElement:ce(e)?e:e==null?void 0:e.contextElement,getBoundingClientRect:()=>{let n=e,r=t==null?void 0:t(n);return r||!n?Om(r):n.getBoundingClientRect()}}}function wm(e,t){return{name:"transformOrigin",fn(n){var P,N,R,L,M;let{elements:r,middlewareData:i,placement:s,rects:o,y:a}=n,l=s.split("-")[0],c=Pm(l),u=((P=i.arrow)==null?void 0:P.x)||0,h=((N=i.arrow)==null?void 0:N.y)||0,p=(t==null?void 0:t.clientWidth)||0,d=(t==null?void 0:t.clientHeight)||0,g=u+p/2,v=h+d/2,b=Math.abs(((R=i.shift)==null?void 0:R.y)||0),V=o.reference.height/2,S=d/2,E=(M=(L=e.offset)==null?void 0:L.mainAxis)!=null?M:e.gutter,f=typeof E=="number"?E+S:E!=null?E:S,C=b>f,I={top:`${g}px calc(100% + ${f}px)`,bottom:`${g}px ${-f}px`,left:`calc(100% + ${f}px) ${v}px`,right:`${-f}px ${v}px`}[l],w=`${g}px ${o.reference.y+V-a}px`,A=!!e.overlap&&c==="y"&&C;return r.floating.style.setProperty(Nt.transformOrigin.variable,A?w:I),{data:{transformOrigin:A?w:I}}}}}function km(e){let[t,n]=e.split("-");return{side:t,align:n,hasAlign:n!=null}}function ac(e){return e.split("-")[0]}function Zl(e,t){let n=e.devicePixelRatio||1;return Math.round(t*n)/n}function po(e){return typeof e=="function"?e():e==="clipping-ancestors"?"clippingAncestors":e}function Am(e,t,n){let r=e||t.createElement("div");return Cm({element:r,padding:n.arrowPadding})}function Rm(e,t){var n;if(!al((n=t.offset)!=null?n:t.gutter))return mm(({placement:r})=>{var u,h,p,d;let i=((e==null?void 0:e.clientHeight)||0)/2,s=(h=(u=t.offset)==null?void 0:u.mainAxis)!=null?h:t.gutter,o=typeof s=="number"?s+i:s!=null?s:i,{hasAlign:a}=km(r),l=a?void 0:t.shift,c=(d=(p=t.offset)==null?void 0:p.crossAxis)!=null?d:l;return Gn({crossAxis:c,mainAxis:o,alignmentAxis:t.shift})})}function Dm(e){if(!e.flip)return;let t=po(e.boundary);return ym(y(m({},t?{boundary:t}:void 0),{padding:e.overflowPadding,fallbackPlacements:e.flip===!0?void 0:e.flip}))}function Lm(e){if(!e.slide&&!e.overlap)return;let t=po(e.boundary);return vm(y(m({},t?{boundary:t}:void 0),{mainAxis:e.slide,crossAxis:e.overlap,padding:e.overflowPadding,limiter:Im()}))}function Fm(e){return bm({padding:e.overflowPadding,apply({elements:t,rects:n,availableHeight:r,availableWidth:i}){let s=t.floating,o=Math.round(n.reference.width),a=Math.round(n.reference.height);i=Math.floor(i),r=Math.floor(r),s.style.setProperty("--reference-width",`${o}px`),s.style.setProperty("--reference-height",`${a}px`),s.style.setProperty("--available-width",`${i}px`),s.style.setProperty("--available-height",`${r}px`)}})}function Mm(e){var t;if(e.hideWhenDetached)return Em({strategy:"referenceHidden",boundary:(t=po(e.boundary))!=null?t:"clippingAncestors"})}function $m(e){return e?e===!0?{ancestorResize:!0,ancestorScroll:!0,elementResize:!0,layoutShift:!0}:e:{}}function _m(e,t,n={}){var b,V;let r=(V=(b=n.getAnchorElement)==null?void 0:b.call(n))!=null?V:e,i=Sm(r,n.getAnchorRect);if(!t||!i)return;let s=Object.assign({},Nm,n),o=t.querySelector("[data-part=arrow]"),a=[Rm(o,s),Dm(s),Lm(s),Am(o,t.ownerDocument,s),xm(o),wm({gutter:s.gutter,offset:s.offset,overlap:s.overlap},o),Fm(s),Mm(s),Vm],{placement:l,strategy:c,onComplete:u,onPositioned:h}=s,p=()=>Ee(null,null,function*(){var w;if(!i||!t)return;let S=yield Tm(i,t,{placement:l,middleware:a,strategy:c});u==null||u(S),h==null||h({placed:!0});let E=oe(t),f=Zl(E,S.x),C=Zl(E,S.y);t.style.setProperty("--x",`${f}px`),t.style.setProperty("--y",`${C}px`),s.hideWhenDetached&&(((w=S.middlewareData.hide)==null?void 0:w.referenceHidden)?(t.style.setProperty("visibility","hidden"),t.style.setProperty("pointer-events","none")):(t.style.removeProperty("visibility"),t.style.removeProperty("pointer-events")));let I=t.firstElementChild;if(I){let A=qt(I);t.style.setProperty("--z-index",A.zIndex)}}),d=()=>Ee(null,null,function*(){n.updatePosition?(yield n.updatePosition({updatePosition:p,floatingElement:t}),h==null||h({placed:!0})):yield p()}),g=$m(s.listeners),v=s.listeners?pm(i,t,d,g):cl;return d(),()=>{v==null||v(),h==null||h({placed:!1})}}function at(e,t,n={}){let a=n,{defer:r}=a,i=ze(a,["defer"]),s=r?H:l=>l(),o=[];return o.push(s(()=>{let l=typeof e=="function"?e():e,c=typeof t=="function"?t():t;o.push(_m(l,c,i))})),()=>{o.forEach(l=>l==null?void 0:l())}}function Zt(e={}){let{placement:t,sameWidth:n,fitViewport:r,strategy:i="absolute"}=e;return{arrow:{position:"absolute",width:Nt.arrowSize.reference,height:Nt.arrowSize.reference,[Nt.arrowSizeHalf.variable]:`calc(${Nt.arrowSize.reference} / 2)`,[Nt.arrowOffset.variable]:`calc(${Nt.arrowSizeHalf.reference} * -1)`},arrowTip:{transform:t?Hm[t.split("-")[0]]:void 0,background:Nt.arrowBg.reference,top:"0",left:"0",width:"100%",height:"100%",position:"absolute",zIndex:"inherit"},floating:{position:i,isolation:"isolate",minWidth:n?void 0:"max-content",width:n?"var(--reference-width)":void 0,maxWidth:r?"var(--available-width)":void 0,maxHeight:r?"var(--available-height)":void 0,pointerEvents:t?void 0:"none",top:"0px",left:"0px",transform:t?"translate3d(var(--x), var(--y), 0)":"translate3d(0, -100vh, 0)",zIndex:"var(--z-index)"}}}var Tp,jt,_e,Di,Ri,ft,Op,Sp,Pp,Hl,Bl,xp,kp,Lp,Fp,Mp,$p,zl,Hp,Bp,Gp,Up,qp,Wp,Yp,jp,Xp,Zp,zp,Qp,Kl,sm,dm,gm,mm,vm,ym,bm,Em,Cm,Im,Tm,Vr,Nt,Pm,Vm,xm,Nm,Hm,Nr=fe(()=>{"use strict";me();Tp=["top","right","bottom","left"],jt=Math.min,_e=Math.max,Di=Math.round,Ri=Math.floor,ft=e=>({x:e,y:e}),Op={left:"right",right:"left",bottom:"top",top:"bottom"},Sp={start:"end",end:"start"};Pp=new Set(["top","bottom"]);Hl=["left","right"],Bl=["right","left"],xp=["top","bottom"],kp=["bottom","top"];Lp=(e,t,n)=>Ee(null,null,function*(){let{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=yield o.isRTL==null?void 0:o.isRTL(t),c=yield o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:h}=Gl(c,r,l),p=r,d={},g=0;for(let b=0;b({name:"arrow",options:e,fn(n){return Ee(this,null,function*(){let{x:r,y:i,placement:s,rects:o,platform:a,elements:l,middlewareData:c}=n,{element:u,padding:h=0}=At(e,n)||{};if(u==null)return{};let p=Jl(h),d={x:r,y:i},g=uo(s),v=co(g),b=yield a.getDimensions(u),V=g==="y",S=V?"top":"left",E=V?"bottom":"right",f=V?"clientHeight":"clientWidth",C=o.reference[v]+o.reference[g]-d[g]-o.floating[v],I=d[g]-o.reference[g],w=yield a.getOffsetParent==null?void 0:a.getOffsetParent(u),A=w?w[f]:0;(!A||!(yield a.isElement==null?void 0:a.isElement(w)))&&(A=l.floating[f]||o.floating[v]);let P=C/2-I/2,N=A/2-b[v]/2-1,R=jt(p[S],N),L=jt(p[E],N),M=R,j=A-b[v]-L,q=A/2-b[v]/2+P,J=so(M,q,j),W=!c.arrow&&zn(s)!=null&&q!==J&&o.reference[v]/2-(qJ<=0)){var L,M;let J=(((L=o.flip)==null?void 0:L.index)||0)+1,W=A[J];if(W&&(!(p==="alignment"?E!==gt(W):!1)||R.every(X=>gt(X.placement)===E?X.overflows[0]>0:!0)))return{data:{index:J,overflows:R},reset:{placement:W}};let ge=(M=R.filter(de=>de.overflows[0]<=0).sort((de,X)=>de.overflows[1]-X.overflows[1])[0])==null?void 0:M.placement;if(!ge)switch(g){case"bestFit":{var j;let de=(j=R.filter(X=>{if(w){let ue=gt(X.placement);return ue===E||ue==="y"}return!0}).map(X=>[X.placement,X.overflows.filter(ue=>ue>0).reduce((ue,qe)=>ue+qe,0)]).sort((X,ue)=>X[1]-ue[1])[0])==null?void 0:j[0];de&&(ge=de);break}case"initialPlacement":ge=l;break}if(s!==ge)return{reset:{placement:ge}}}return{}})}}};$p=function(e){return e===void 0&&(e={}),{name:"hide",options:e,fn(n){return Ee(this,null,function*(){let{rects:r,platform:i}=n,a=At(e,n),{strategy:s="referenceHidden"}=a,o=ze(a,["strategy"]);switch(s){case"referenceHidden":{let l=yield i.detectOverflow(n,y(m({},o),{elementContext:"reference"})),c=Ul(l,r.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:ql(c)}}}case"escaped":{let l=yield i.detectOverflow(n,y(m({},o),{altBoundary:!0})),c=Ul(l,r.floating);return{data:{escapedOffsets:c,escaped:ql(c)}}}default:return{}}})}}},zl=new Set(["left","top"]);Hp=function(e){return e===void 0&&(e=0),{name:"offset",options:e,fn(n){return Ee(this,null,function*(){var r,i;let{x:s,y:o,placement:a,middlewareData:l}=n,c=yield _p(n,e);return a===((r=l.offset)==null?void 0:r.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:y(m({},c),{placement:a})}})}}},Bp=function(e){return e===void 0&&(e={}),{name:"shift",options:e,fn(n){return Ee(this,null,function*(){let{x:r,y:i,placement:s,platform:o}=n,S=At(e,n),{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:E=>{let{x:f,y:C}=E;return{x:f,y:C}}}}=S,u=ze(S,["mainAxis","crossAxis","limiter"]),h={x:r,y:i},p=yield o.detectOverflow(n,u),d=gt(Rt(s)),g=lo(d),v=h[g],b=h[d];if(a){let E=g==="y"?"top":"left",f=g==="y"?"bottom":"right",C=v+p[E],I=v-p[f];v=so(C,v,I)}if(l){let E=d==="y"?"top":"left",f=d==="y"?"bottom":"right",C=b+p[E],I=b-p[f];b=so(C,b,I)}let V=c.fn(y(m({},n),{[g]:v,[d]:b}));return y(m({},V),{data:{x:V.x-r,y:V.y-i,enabled:{[g]:a,[d]:l}}})})}}},Gp=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=At(e,t),u={x:n,y:r},h=gt(i),p=lo(h),d=u[p],g=u[h],v=At(a,t),b=typeof v=="number"?{mainAxis:v,crossAxis:0}:m({mainAxis:0,crossAxis:0},v);if(l){let E=p==="y"?"height":"width",f=s.reference[p]-s.floating[E]+b.mainAxis,C=s.reference[p]+s.reference[E]-b.mainAxis;dC&&(d=C)}if(c){var V,S;let E=p==="y"?"width":"height",f=zl.has(Rt(i)),C=s.reference[h]-s.floating[E]+(f&&((V=o.offset)==null?void 0:V[h])||0)+(f?0:b.crossAxis),I=s.reference[h]+s.reference[E]+(f?0:((S=o.offset)==null?void 0:S[h])||0)-(f?b.crossAxis:0);gI&&(g=I)}return{[p]:d,[h]:g}}}},Up=function(e){return e===void 0&&(e={}),{name:"size",options:e,fn(n){return Ee(this,null,function*(){var r,i;let{placement:s,rects:o,platform:a,elements:l}=n,R=At(e,n),{apply:c=()=>{}}=R,u=ze(R,["apply"]),h=yield a.detectOverflow(n,u),p=Rt(s),d=zn(s),g=gt(s)==="y",{width:v,height:b}=o.floating,V,S;p==="top"||p==="bottom"?(V=p,S=d===((yield a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(S=p,V=d==="end"?"top":"bottom");let E=b-h.top-h.bottom,f=v-h.left-h.right,C=jt(b-h[V],E),I=jt(v-h[S],f),w=!n.middlewareData.shift,A=C,P=I;if((r=n.middlewareData.shift)!=null&&r.enabled.x&&(P=f),(i=n.middlewareData.shift)!=null&&i.enabled.y&&(A=E),w&&!d){let L=_e(h.left,0),M=_e(h.right,0),j=_e(h.top,0),q=_e(h.bottom,0);g?P=v-2*(L!==0||M!==0?L+M:_e(h.left,h.right)):A=b-2*(j!==0||q!==0?j+q:_e(h.top,h.bottom))}yield c(y(m({},n),{availableWidth:P,availableHeight:A}));let N=yield a.getDimensions(l.floating);return v!==N.width||b!==N.height?{reset:{rects:!0}}:{}})}}};qp=new Set(["inline","contents"]);Wp=new Set(["table","td","th"]);Yp=[":popover-open",":modal"];jp=["transform","translate","scale","rotate","perspective"],Xp=["transform","translate","scale","rotate","perspective","filter"],Zp=["paint","layout","strict","content"];zp=new Set(["html","body","#document"]);Qp=ft(0);Kl=25;sm=new Set(["absolute","fixed"]);dm=function(e){return Ee(this,null,function*(){let t=this.getOffsetParent||sc,n=this.getDimensions,r=yield n(e.floating);return{reference:um(e.reference,yield t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}})};gm={convertOffsetParentRelativeRectToViewportRelativeRect:tm,getDocumentElement:mt,getClippingRect:lm,getOffsetParent:sc,getElementRects:dm,getClientRects:nm,getDimensions:cm,getScale:Zn,isElement:st,isRTL:hm};mm=Hp,vm=Bp,ym=Mp,bm=Up,Em=$p,Cm=Fp,Im=Gp,Tm=(e,t,n)=>{let r=new Map,i=m({platform:gm},n),s=y(m({},i.platform),{_c:r});return Lp(e,t,y(m({},i),{platform:s}))};Vr=e=>({variable:e,reference:`var(${e})`}),Nt={arrowSize:Vr("--arrow-size"),arrowSizeHalf:Vr("--arrow-size-half"),arrowBg:Vr("--arrow-background"),transformOrigin:Vr("--transform-origin"),arrowOffset:Vr("--arrow-offset")},Pm=e=>e==="top"||e==="bottom"?"y":"x";Vm={name:"rects",fn({rects:e}){return{data:e}}},xm=e=>{if(e)return{name:"shiftArrow",fn({placement:t,middlewareData:n}){if(!n.arrow)return{};let{x:r,y:i}=n.arrow,s=t.split("-")[0];return Object.assign(e.style,{left:r!=null?`${r}px`:"",top:i!=null?`${i}px`:"",[s]:`calc(100% + ${Nt.arrowOffset.reference})`}),{}}}};Nm={strategy:"absolute",placement:"bottom",listeners:!0,gutter:8,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,overflowPadding:8,arrowPadding:4};Hm={bottom:"rotate(45deg)",left:"rotate(135deg)",top:"rotate(225deg)",right:"rotate(315deg)"}});function Bm(e){let t={each(n){var r;for(let i=0;i<((r=e.frames)==null?void 0:r.length);i+=1){let s=e.frames[i];s&&n(s)}},addEventListener(n,r,i){return t.each(s=>{try{s.document.addEventListener(n,r,i)}catch(o){}}),()=>{try{t.removeEventListener(n,r,i)}catch(s){}}},removeEventListener(n,r,i){t.each(s=>{try{s.document.removeEventListener(n,r,i)}catch(o){}})}};return t}function Gm(e){let t=e.frameElement!=null?e.parent:null;return{addEventListener:(n,r,i)=>{try{t==null||t.addEventListener(n,r,i)}catch(s){}return()=>{try{t==null||t.removeEventListener(n,r,i)}catch(s){}}},removeEventListener:(n,r,i)=>{try{t==null||t.removeEventListener(n,r,i)}catch(s){}}}}function Um(e){for(let t of e)if(ce(t)&&Qe(t))return!0;return!1}function qm(e,t){if(!pc(t)||!e)return!1;let n=e.getBoundingClientRect();return n.width===0||n.height===0?!1:n.top<=t.clientY&&t.clientY<=n.top+n.height&&n.left<=t.clientX&&t.clientX<=n.left+n.width}function Wm(e,t){return e.y<=t.y&&t.y<=e.y+e.height&&e.x<=t.x&&t.x<=e.x+e.width}function uc(e,t){if(!t||!pc(e))return!1;let n=t.scrollHeight>t.clientHeight,r=n&&e.clientX>t.offsetLeft+t.clientWidth,i=t.scrollWidth>t.clientWidth,s=i&&e.clientY>t.offsetTop+t.clientHeight,o={x:t.offsetLeft,y:t.offsetTop,width:t.clientWidth+(n?16:0),height:t.clientHeight+(i?16:0)},a={x:e.clientX,y:e.clientY};return Wm(o,a)?r||s:!1}function Km(e,t){let{exclude:n,onFocusOutside:r,onPointerDownOutside:i,onInteractOutside:s,defer:o,followControlledElements:a=!0}=t;if(!e)return;let l=we(e),c=oe(e),u=Bm(c),h=Gm(c);function p(E,f){if(!ce(f)||!f.isConnected||pe(e,f)||qm(e,E)||a&&li(e,f))return!1;let C=l.querySelector(`[aria-controls="${e.id}"]`);if(C){let w=fi(C);if(uc(E,w))return!1}let I=fi(e);return uc(E,I)?!1:!(n!=null&&n(f))}let d=new Set,g=nn(e==null?void 0:e.getRootNode());function v(E){function f(C){var P,N;let I=o&&!Fs()?H:R=>R(),w=C!=null?C:E,A=(N=(P=w==null?void 0:w.composedPath)==null?void 0:P.call(w))!=null?N:[w==null?void 0:w.target];I(()=>{let R=g?A[0]:K(E);if(!(!e||!p(E,R))){if(i||s){let L=Bn(i,s);e.addEventListener(lc,L,{once:!0})}dc(e,lc,{bubbles:!1,cancelable:!0,detail:{originalEvent:w,contextmenu:An(w),focusable:Um(A),target:R}})}})}E.pointerType==="touch"?(d.forEach(C=>C()),d.add(ie(l,"click",f,{once:!0})),d.add(h.addEventListener("click",f,{once:!0})),d.add(u.addEventListener("click",f,{once:!0}))):f()}let b=new Set,V=setTimeout(()=>{b.add(ie(l,"pointerdown",v,!0)),b.add(h.addEventListener("pointerdown",v,!0)),b.add(u.addEventListener("pointerdown",v,!0))},0);function S(E){(o?H:C=>C())(()=>{var w,A;let C=(A=(w=E==null?void 0:E.composedPath)==null?void 0:w.call(E))!=null?A:[E==null?void 0:E.target],I=g?C[0]:K(E);if(!(!e||!p(E,I))){if(r||s){let P=Bn(r,s);e.addEventListener(cc,P,{once:!0})}dc(e,cc,{bubbles:!1,cancelable:!0,detail:{originalEvent:E,contextmenu:!1,focusable:Qe(I),target:I}})}})}return Fs()||(b.add(ie(l,"focusin",S,!0)),b.add(h.addEventListener("focusin",S,!0)),b.add(u.addEventListener("focusin",S,!0))),()=>{clearTimeout(V),d.forEach(E=>E()),b.forEach(E=>E())}}function Ym(e,t){let{defer:n}=t,r=n?H:s=>s(),i=[];return i.push(r(()=>{let s=typeof e=="function"?e():e;i.push(Km(s,t))})),()=>{i.forEach(s=>s==null?void 0:s())}}function dc(e,t,n){let r=e.ownerDocument.defaultView||window,i=new r.CustomEvent(t,n);return e.dispatchEvent(i)}function jm(e,t){let n=r=>{r.key==="Escape"&&(r.isComposing||t==null||t(r))};return ie(we(e),"keydown",n,{capture:!0})}function Xm(e,t,n){let r=e.ownerDocument.defaultView||window,i=new r.CustomEvent(t,{cancelable:!0,bubbles:!0,detail:n});return e.dispatchEvent(i)}function Zm(e,t,n){e.addEventListener(t,n,{once:!0})}function fc(){Re.layers.forEach(({node:e})=>{e.style.pointerEvents=Re.isBelowPointerBlockingLayer(e)?"none":"auto"})}function Jm(e){e.style.pointerEvents=""}function zm(e,t){let n=we(e),r=[];return Re.hasPointerBlockingLayer()&&!n.body.hasAttribute("data-inert")&&(gc=document.body.style.pointerEvents,queueMicrotask(()=>{n.body.style.pointerEvents="none",n.body.setAttribute("data-inert","")})),t==null||t.forEach(i=>{let[s,o]=el(()=>{let a=i();return ce(a)?a:null},{timeout:1e3});s.then(a=>r.push(cn(a,{pointerEvents:"auto"}))),r.push(o)}),()=>{Re.hasPointerBlockingLayer()||(queueMicrotask(()=>{n.body.style.pointerEvents=gc,n.body.removeAttribute("data-inert"),n.body.style.length===0&&n.body.removeAttribute("style")}),r.forEach(i=>i()))}}function Qm(e,t){let{warnOnMissingNode:n=!0}=t;if(n&&!e){wt("[@zag-js/dismissable] node is `null` or `undefined`");return}if(!e)return;let{onDismiss:r,onRequestDismiss:i,pointerBlocking:s,exclude:o,debug:a,type:l="dialog"}=t,c={dismiss:r,node:e,type:l,pointerBlocking:s,requestDismiss:i};Re.add(c),fc();function u(v){var V,S;let b=K(v.detail.originalEvent);Re.isBelowPointerBlockingLayer(e)||Re.isInBranch(b)||((V=t.onPointerDownOutside)==null||V.call(t,v),(S=t.onInteractOutside)==null||S.call(t,v),!v.defaultPrevented&&(a&&console.log("onPointerDownOutside:",v.detail.originalEvent),r==null||r()))}function h(v){var V,S;let b=K(v.detail.originalEvent);Re.isInBranch(b)||((V=t.onFocusOutside)==null||V.call(t,v),(S=t.onInteractOutside)==null||S.call(t,v),!v.defaultPrevented&&(a&&console.log("onFocusOutside:",v.detail.originalEvent),r==null||r()))}function p(v){var b;Re.isTopMost(e)&&((b=t.onEscapeKeyDown)==null||b.call(t,v),!v.defaultPrevented&&r&&(v.preventDefault(),r()))}function d(v){var E;if(!e)return!1;let b=typeof o=="function"?o():o,V=Array.isArray(b)?b:[b],S=(E=t.persistentElements)==null?void 0:E.map(f=>f()).filter(ce);return S&&V.push(...S),V.some(f=>pe(f,v))||Re.isInNestedLayer(e,v)}let g=[s?zm(e,t.persistentElements):void 0,jm(e,p),Ym(e,{exclude:d,onFocusOutside:h,onPointerDownOutside:u,defer:t.defer})];return()=>{Re.remove(e),fc(),Jm(e),g.forEach(v=>v==null?void 0:v())}}function vt(e,t){let{defer:n}=t,r=n?H:s=>s(),i=[];return i.push(r(()=>{let s=Ot(e)?e():e;i.push(Qm(s,t))})),()=>{i.forEach(s=>s==null?void 0:s())}}function mc(e,t={}){let{defer:n}=t,r=n?H:s=>s(),i=[];return i.push(r(()=>{let s=Ot(e)?e():e;if(!s){wt("[@zag-js/dismissable] branch node is `null` or `undefined`");return}Re.addBranch(s),i.push(()=>{Re.removeBranch(s)})})),()=>{i.forEach(s=>s==null?void 0:s())}}var lc,cc,pc,hc,Re,gc,gn=fe(()=>{"use strict";me();lc="pointerdown.outside",cc="focus.outside";pc=e=>"clientY"in e;hc="layer:request-dismiss",Re={layers:[],branches:[],recentlyRemoved:new Set,count(){return this.layers.length},pointerBlockingLayers(){return this.layers.filter(e=>e.pointerBlocking)},topMostPointerBlockingLayer(){return[...this.pointerBlockingLayers()].slice(-1)[0]},hasPointerBlockingLayer(){return this.pointerBlockingLayers().length>0},isBelowPointerBlockingLayer(e){var r;let t=this.indexOf(e),n=this.topMostPointerBlockingLayer()?this.indexOf((r=this.topMostPointerBlockingLayer())==null?void 0:r.node):-1;return tt.type===e)},getNestedLayersByType(e,t){let n=this.indexOf(e);return n===-1?[]:this.layers.slice(n+1).filter(r=>r.type===t)},getParentLayerOfType(e,t){let n=this.indexOf(e);if(!(n<=0))return this.layers.slice(0,n).reverse().find(r=>r.type===t)},countNestedLayersOfType(e,t){return this.getNestedLayersByType(e,t).length},isInNestedLayer(e,t){return!!(this.getNestedLayers(e).some(r=>pe(r.node,t))||this.recentlyRemoved.size>0)},isInBranch(e){return Array.from(this.branches).some(t=>pe(t,e))},add(e){this.layers.push(e),this.syncLayers()},addBranch(e){this.branches.push(e)},remove(e){let t=this.indexOf(e);t<0||(this.recentlyRemoved.add(e),an(()=>this.recentlyRemoved.delete(e)),tRe.dismiss(r.node,e)),this.layers.splice(t,1),this.syncLayers())},removeBranch(e){let t=this.branches.indexOf(e);t>=0&&this.branches.splice(t,1)},syncLayers(){this.layers.forEach((e,t)=>{e.node.style.setProperty("--layer-index",`${t}`),e.node.removeAttribute("data-nested"),e.node.removeAttribute("data-has-nested"),this.getParentLayerOfType(e.node,e.type)&&e.node.setAttribute("data-nested",e.type);let r=this.countNestedLayersOfType(e.node,e.type);r>0&&e.node.setAttribute("data-has-nested",e.type),e.node.style.setProperty("--nested-layer-count",`${r}`)})},indexOf(e){return this.layers.findIndex(t=>t.node===e)},dismiss(e,t){let n=this.indexOf(e);if(n===-1)return;let r=this.layers[n];Zm(e,hc,i=>{var s;(s=r.requestDismiss)==null||s.call(r,i),i.defaultPrevented||r==null||r.dismiss()}),Xm(e,hc,{originalLayer:e,targetLayer:t,originalIndex:n,targetIndex:t?this.indexOf(t):-1}),this.syncLayers()},clear(){this.remove(this.layers[0].node)}}});var wc={};Oe(wc,{Combobox:()=>vv});function sv(e,t){let{context:n,prop:r,state:i,send:s,scope:o,computed:a,event:l}=e,c=r("translations"),u=r("collection"),h=!!r("disabled"),p=a("isInteractive"),d=!!r("invalid"),g=!!r("required"),v=!!r("readOnly"),b=i.hasTag("open"),V=i.hasTag("focused"),S=r("composite"),E=n.get("highlightedValue"),f=Zt(y(m({},r("positioning")),{placement:n.get("currentPlacement")}));function C(I){let w=u.getItemDisabled(I.item),A=u.getItemValue(I.item);return qn(A,()=>`[zag-js] No value found for item ${JSON.stringify(I.item)}`),{value:A,disabled:!!(w||w),highlighted:E===A,selected:n.get("value").includes(A)}}return{focused:V,open:b,inputValue:n.get("inputValue"),highlightedValue:E,highlightedItem:n.get("highlightedItem"),value:n.get("value"),valueAsString:a("valueAsString"),hasSelectedItems:a("hasSelectedItems"),selectedItems:n.get("selectedItems"),collection:r("collection"),multiple:!!r("multiple"),disabled:!!h,syncSelectedItems(){s({type:"SELECTED_ITEMS.SYNC"})},reposition(I={}){s({type:"POSITIONING.SET",options:I})},setHighlightValue(I){s({type:"HIGHLIGHTED_VALUE.SET",value:I})},clearHighlightValue(){s({type:"HIGHLIGHTED_VALUE.CLEAR"})},selectValue(I){s({type:"ITEM.SELECT",value:I})},setValue(I){s({type:"VALUE.SET",value:I})},setInputValue(I,w="script"){s({type:"INPUT_VALUE.SET",value:I,src:w})},clearValue(I){I!=null?s({type:"ITEM.CLEAR",value:I}):s({type:"VALUE.CLEAR"})},focus(){var I;(I=pn(o))==null||I.focus()},setOpen(I,w="script"){i.hasTag("open")!==I&&s({type:I?"OPEN":"CLOSE",src:w})},getRootProps(){return t.element(y(m({},De.root.attrs),{dir:r("dir"),id:tv(o),"data-invalid":T(d),"data-readonly":T(v)}))},getLabelProps(){return t.label(y(m({},De.label.attrs),{dir:r("dir"),htmlFor:Bi(o),id:mo(o),"data-readonly":T(v),"data-disabled":T(h),"data-invalid":T(d),"data-required":T(g),"data-focus":T(V),onClick(I){var w;S||(I.preventDefault(),(w=Ar(o))==null||w.focus({preventScroll:!0}))}}))},getControlProps(){return t.element(y(m({},De.control.attrs),{dir:r("dir"),id:Tc(o),"data-state":b?"open":"closed","data-focus":T(V),"data-disabled":T(h),"data-invalid":T(d)}))},getPositionerProps(){return t.element(y(m({},De.positioner.attrs),{dir:r("dir"),id:Oc(o),style:f.floating}))},getInputProps(){return t.input(y(m({},De.input.attrs),{dir:r("dir"),"aria-invalid":re(d),"data-invalid":T(d),"data-autofocus":T(r("autoFocus")),name:r("name"),form:r("form"),disabled:h,required:r("required"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"none",spellCheck:"false",readOnly:v,placeholder:r("placeholder"),id:Bi(o),type:"text",role:"combobox",defaultValue:n.get("inputValue"),"aria-autocomplete":a("autoComplete")?"both":"list","aria-controls":Gi(o),"aria-expanded":b,"data-state":b?"open":"closed","aria-activedescendant":E?yc(o,E):void 0,onClick(I){I.defaultPrevented||r("openOnClick")&&p&&s({type:"INPUT.CLICK",src:"input-click"})},onFocus(){h||s({type:"INPUT.FOCUS"})},onBlur(){h||s({type:"INPUT.BLUR"})},onChange(I){s({type:"INPUT.CHANGE",value:I.currentTarget.value,src:"input-change"})},onKeyDown(I){if(I.defaultPrevented||!p||I.ctrlKey||I.shiftKey||Vt(I))return;let w=r("openOnKeyPress"),A=I.ctrlKey||I.metaKey||I.shiftKey,P=!0,N={ArrowDown(M){!w&&!b||(s({type:M.altKey?"OPEN":"INPUT.ARROW_DOWN",keypress:P,src:"arrow-key"}),M.preventDefault())},ArrowUp(){!w&&!b||(s({type:I.altKey?"CLOSE":"INPUT.ARROW_UP",keypress:P,src:"arrow-key"}),I.preventDefault())},Home(M){A||(s({type:"INPUT.HOME",keypress:P}),b&&M.preventDefault())},End(M){A||(s({type:"INPUT.END",keypress:P}),b&&M.preventDefault())},Enter(M){var ge;s({type:"INPUT.ENTER",keypress:P,src:"item-select"});let j=a("isCustomValue")&&r("allowCustomValue"),q=E!=null,J=r("alwaysSubmitOnEnter");if(b&&!j&&!J&&q&&M.preventDefault(),E==null)return;let W=er(o,E);We(W)&&((ge=r("navigate"))==null||ge({value:E,node:W,href:W.href}))},Escape(){s({type:"INPUT.ESCAPE",keypress:P,src:"escape-key"}),I.preventDefault()}},R=ve(I,{dir:r("dir")}),L=N[R];L==null||L(I)}}))},getTriggerProps(I={}){return t.button(y(m({},De.trigger.attrs),{dir:r("dir"),id:Sc(o),"aria-haspopup":S?"listbox":"dialog",type:"button",tabIndex:I.focusable?void 0:-1,"aria-label":c.triggerLabel,"aria-expanded":b,"data-state":b?"open":"closed","aria-controls":b?Gi(o):void 0,disabled:h,"data-invalid":T(d),"data-focusable":T(I.focusable),"data-readonly":T(v),"data-disabled":T(h),onFocus(){I.focusable&&s({type:"INPUT.FOCUS",src:"trigger"})},onClick(w){w.defaultPrevented||p&&et(w)&&s({type:"TRIGGER.CLICK",src:"trigger-click"})},onPointerDown(w){p&&w.pointerType!=="touch"&&et(w)&&(w.preventDefault(),queueMicrotask(()=>{var A;(A=pn(o))==null||A.focus({preventScroll:!0})}))},onKeyDown(w){if(w.defaultPrevented||S)return;let A={ArrowDown(){s({type:"INPUT.ARROW_DOWN",src:"arrow-key"})},ArrowUp(){s({type:"INPUT.ARROW_UP",src:"arrow-key"})}},P=ve(w,{dir:r("dir")}),N=A[P];N&&(N(w),w.preventDefault())}}))},getContentProps(){return t.element(y(m({},De.content.attrs),{dir:r("dir"),id:Gi(o),role:S?"listbox":"dialog",tabIndex:-1,hidden:!b,"data-state":b?"open":"closed","data-placement":n.get("currentPlacement"),"aria-labelledby":mo(o),"aria-multiselectable":r("multiple")&&S?!0:void 0,"data-empty":T(u.size===0),onPointerDown(I){et(I)&&I.preventDefault()}}))},getListProps(){return t.element(y(m({},De.list.attrs),{role:S?void 0:"listbox","data-empty":T(u.size===0),"aria-labelledby":mo(o),"aria-multiselectable":r("multiple")&&!S?!0:void 0}))},getClearTriggerProps(){return t.button(y(m({},De.clearTrigger.attrs),{dir:r("dir"),id:Pc(o),type:"button",tabIndex:-1,disabled:h,"data-invalid":T(d),"aria-label":c.clearTriggerLabel,"aria-controls":Bi(o),hidden:!n.get("value").length,onPointerDown(I){et(I)&&I.preventDefault()},onClick(I){I.defaultPrevented||p&&s({type:"VALUE.CLEAR",src:"clear-trigger"})}}))},getItemState:C,getItemProps(I){let w=C(I),A=w.value;return t.element(y(m({},De.item.attrs),{dir:r("dir"),id:yc(o,A),role:"option",tabIndex:-1,"data-highlighted":T(w.highlighted),"data-state":w.selected?"checked":"unchecked","aria-selected":re(w.highlighted),"aria-disabled":re(w.disabled),"data-disabled":T(w.disabled),"data-value":w.value,onPointerMove(){w.disabled||w.highlighted||s({type:"ITEM.POINTER_MOVE",value:A})},onPointerLeave(){if(I.persistFocus||w.disabled)return;let P=l.previous();P!=null&&P.type.includes("POINTER")&&s({type:"ITEM.POINTER_LEAVE",value:A})},onClick(P){Er(P)||sn(P)||An(P)||w.disabled||s({type:"ITEM.CLICK",src:"item-select",value:A})}}))},getItemTextProps(I){let w=C(I);return t.element(y(m({},De.itemText.attrs),{dir:r("dir"),"data-state":w.selected?"checked":"unchecked","data-disabled":T(w.disabled),"data-highlighted":T(w.highlighted)}))},getItemIndicatorProps(I){let w=C(I);return t.element(y(m({"aria-hidden":!0},De.itemIndicator.attrs),{dir:r("dir"),"data-state":w.selected?"checked":"unchecked",hidden:!w.selected}))},getItemGroupProps(I){let{id:w}=I;return t.element(y(m({},De.itemGroup.attrs),{dir:r("dir"),id:nv(o,w),"aria-labelledby":vc(o,w),"data-empty":T(u.size===0),role:"group"}))},getItemGroupLabelProps(I){let{htmlFor:w}=I;return t.element(y(m({},De.itemGroupLabel.attrs),{dir:r("dir"),id:vc(o,w),role:"presentation"}))}}}function Ic(e){return(e.previousEvent||e).src}function pv(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function mv(e){let t={};for(let[n,r]of Object.entries(e)){let i=pv(n);t[i]=r}return t}var ev,De,Ui,tv,mo,Tc,Bi,Gi,Oc,Sc,Pc,nv,vc,yc,fn,pn,bc,Ec,Ar,rv,er,Cc,iv,ov,av,lv,be,Be,cv,uv,dT,dv,hT,hv,gT,gv,fT,fv,vv,Vc=fe(()=>{"use strict";Ai();Nr();gn();me();ev=Z("combobox").parts("root","clearTrigger","content","control","input","item","itemGroup","itemGroupLabel","itemIndicator","itemText","label","list","positioner","trigger"),De=ev.build(),Ui=e=>new Xn(e);Ui.empty=()=>new Xn({items:[]});tv=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`combobox:${e.id}`},mo=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`combobox:${e.id}:label`},Tc=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`combobox:${e.id}:control`},Bi=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.input)!=null?n:`combobox:${e.id}:input`},Gi=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`combobox:${e.id}:content`},Oc=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.positioner)!=null?n:`combobox:${e.id}:popper`},Sc=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`combobox:${e.id}:toggle-btn`},Pc=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.clearTrigger)!=null?n:`combobox:${e.id}:clear-btn`},nv=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemGroup)==null?void 0:r.call(n,t))!=null?i:`combobox:${e.id}:optgroup:${t}`},vc=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemGroupLabel)==null?void 0:r.call(n,t))!=null?i:`combobox:${e.id}:optgroup-label:${t}`},yc=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.item)==null?void 0:r.call(n,t))!=null?i:`combobox:${e.id}:option:${t}`},fn=e=>e.getById(Gi(e)),pn=e=>e.getById(Bi(e)),bc=e=>e.getById(Oc(e)),Ec=e=>e.getById(Tc(e)),Ar=e=>e.getById(Sc(e)),rv=e=>e.getById(Pc(e)),er=(e,t)=>{if(t==null)return null;let n=`[role=option][data-value="${CSS.escape(t)}"]`;return Mn(fn(e),n)},Cc=e=>{let t=pn(e);e.isActiveElement(t)||t==null||t.focus({preventScroll:!0})},iv=e=>{let t=Ar(e);e.isActiveElement(t)||t==null||t.focus({preventScroll:!0})};({guards:ov,createMachine:av,choose:lv}=Wn()),{and:be,not:Be}=ov,cv=av({props({props:e}){return y(m({loopFocus:!0,openOnClick:!1,defaultValue:[],defaultInputValue:"",closeOnSelect:!e.multiple,allowCustomValue:!1,alwaysSubmitOnEnter:!1,inputBehavior:"none",selectionBehavior:e.multiple?"clear":"replace",openOnKeyPress:!0,openOnChange:!0,composite:!0,navigate({node:t}){Fn(t)},collection:Ui.empty()},e),{positioning:m({placement:"bottom",sameWidth:!0},e.positioning),translations:m({triggerLabel:"Toggle suggestions",clearTriggerLabel:"Clear value"},e.translations)})},initialState({prop:e}){return e("open")||e("defaultOpen")?"suggesting":"idle"},context({prop:e,bindable:t,getContext:n,getEvent:r}){return{currentPlacement:t(()=>({defaultValue:void 0})),value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),isEqual:he,hash(i){return i.join(",")},onChange(i){var c;let s=n(),o=s.get("selectedItems"),a=e("collection"),l=i.map(u=>o.find(p=>a.getItemValue(p)===u)||a.find(u));s.set("selectedItems",l),(c=e("onValueChange"))==null||c({value:i,items:l})}})),highlightedValue:t(()=>({defaultValue:e("defaultHighlightedValue")||null,value:e("highlightedValue"),onChange(i){var o;let s=e("collection").find(i);(o=e("onHighlightChange"))==null||o({highlightedValue:i,highlightedItem:s})}})),inputValue:t(()=>{let i=e("inputValue")||e("defaultInputValue"),s=e("value")||e("defaultValue");if(!i.trim()&&!e("multiple")){let o=e("collection").stringifyMany(s);i=Ve(e("selectionBehavior"),{preserve:i||o,replace:o,clear:""})}return{defaultValue:i,value:e("inputValue"),onChange(o){var c;let a=r(),l=(a.previousEvent||a).src;(c=e("onInputValueChange"))==null||c({inputValue:o,reason:l})}}}),highlightedItem:t(()=>{let i=e("highlightedValue");return{defaultValue:e("collection").find(i)}}),selectedItems:t(()=>{let i=e("value")||e("defaultValue")||[];return{defaultValue:e("collection").findMany(i)}})}},computed:{isInputValueEmpty:({context:e})=>e.get("inputValue").length===0,isInteractive:({prop:e})=>!(e("readOnly")||e("disabled")),autoComplete:({prop:e})=>e("inputBehavior")==="autocomplete",autoHighlight:({prop:e})=>e("inputBehavior")==="autohighlight",hasSelectedItems:({context:e})=>e.get("value").length>0,valueAsString:({context:e,prop:t})=>t("collection").stringifyItems(e.get("selectedItems")),isCustomValue:({context:e,computed:t})=>e.get("inputValue")!==t("valueAsString")},watch({context:e,prop:t,track:n,action:r,send:i}){n([()=>e.hash("value")],()=>{r(["syncSelectedItems"])}),n([()=>e.get("inputValue")],()=>{r(["syncInputValue"])}),n([()=>e.get("highlightedValue")],()=>{r(["syncHighlightedItem","autofillInputValue"])}),n([()=>t("open")],()=>{r(["toggleVisibility"])}),n([()=>t("collection").toString()],()=>{i({type:"CHILDREN_CHANGE"})})},on:{"SELECTED_ITEMS.SYNC":{actions:["syncSelectedItems"]},"HIGHLIGHTED_VALUE.SET":{actions:["setHighlightedValue"]},"HIGHLIGHTED_VALUE.CLEAR":{actions:["clearHighlightedValue"]},"ITEM.SELECT":{actions:["selectItem"]},"ITEM.CLEAR":{actions:["clearItem"]},"VALUE.SET":{actions:["setValue"]},"INPUT_VALUE.SET":{actions:["setInputValue"]},"POSITIONING.SET":{actions:["reposition"]}},entry:lv([{guard:"autoFocus",actions:["setInitialFocus"]}]),states:{idle:{tags:["idle","closed"],entry:["scrollContentToTop","clearHighlightedValue"],on:{"CONTROLLED.OPEN":{target:"interacting"},"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"]}],"INPUT.CLICK":[{guard:"isOpenControlled",actions:["highlightFirstSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["highlightFirstSelectedItem","invokeOnOpen"]}],"INPUT.FOCUS":{target:"focused"},OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"interacting",actions:["invokeOnOpen"]}],"VALUE.CLEAR":{target:"focused",actions:["clearInputValue","clearSelectedItems","setInitialFocus"]}}},focused:{tags:["focused","closed"],entry:["scrollContentToTop","clearHighlightedValue"],on:{"CONTROLLED.OPEN":[{guard:"isChangeEvent",target:"suggesting"},{target:"interacting"}],"INPUT.CHANGE":[{guard:be("isOpenControlled","openOnChange"),actions:["setInputValue","invokeOnOpen","highlightFirstItemIfNeeded"]},{guard:"openOnChange",target:"suggesting",actions:["setInputValue","invokeOnOpen","highlightFirstItemIfNeeded"]},{actions:["setInputValue"]}],"LAYER.INTERACT_OUTSIDE":{target:"idle"},"INPUT.ESCAPE":{guard:be("isCustomValue",Be("allowCustomValue")),actions:["revertInputValue"]},"INPUT.BLUR":{target:"idle"},"INPUT.CLICK":[{guard:"isOpenControlled",actions:["highlightFirstSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["highlightFirstSelectedItem","invokeOnOpen"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"]}],"INPUT.ARROW_DOWN":[{guard:be("isOpenControlled","autoComplete"),actions:["invokeOnOpen"]},{guard:"autoComplete",target:"interacting",actions:["invokeOnOpen"]},{guard:"isOpenControlled",actions:["highlightFirstOrSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["highlightFirstOrSelectedItem","invokeOnOpen"]}],"INPUT.ARROW_UP":[{guard:"autoComplete",target:"interacting",actions:["invokeOnOpen"]},{guard:"autoComplete",target:"interacting",actions:["invokeOnOpen"]},{target:"interacting",actions:["highlightLastOrSelectedItem","invokeOnOpen"]},{target:"interacting",actions:["highlightLastOrSelectedItem","invokeOnOpen"]}],OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"interacting",actions:["invokeOnOpen"]}],"VALUE.CLEAR":{actions:["clearInputValue","clearSelectedItems"]}}},interacting:{tags:["open","focused"],entry:["setInitialFocus"],effects:["scrollToHighlightedItem","trackDismissableLayer","trackPlacement"],on:{"CONTROLLED.CLOSE":[{guard:"restoreFocus",target:"focused",actions:["setFinalFocus"]},{target:"idle"}],CHILDREN_CHANGE:[{guard:"isHighlightedItemRemoved",actions:["clearHighlightedValue"]},{actions:["scrollToHighlightedItem"]}],"INPUT.HOME":{actions:["highlightFirstItem"]},"INPUT.END":{actions:["highlightLastItem"]},"INPUT.ARROW_DOWN":[{guard:be("autoComplete","isLastItemHighlighted"),actions:["clearHighlightedValue","scrollContentToTop"]},{actions:["highlightNextItem"]}],"INPUT.ARROW_UP":[{guard:be("autoComplete","isFirstItemHighlighted"),actions:["clearHighlightedValue"]},{actions:["highlightPrevItem"]}],"INPUT.ENTER":[{guard:be("isOpenControlled","isCustomValue",Be("hasHighlightedItem"),Be("allowCustomValue")),actions:["revertInputValue","invokeOnClose"]},{guard:be("isCustomValue",Be("hasHighlightedItem"),Be("allowCustomValue")),target:"focused",actions:["revertInputValue","invokeOnClose"]},{guard:be("isOpenControlled","closeOnSelect"),actions:["selectHighlightedItem","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectHighlightedItem","invokeOnClose","setFinalFocus"]},{actions:["selectHighlightedItem"]}],"INPUT.CHANGE":[{guard:"autoComplete",target:"suggesting",actions:["setInputValue"]},{target:"suggesting",actions:["clearHighlightedValue","setInputValue"]}],"ITEM.POINTER_MOVE":{actions:["setHighlightedValue"]},"ITEM.POINTER_LEAVE":{actions:["clearHighlightedValue"]},"ITEM.CLICK":[{guard:be("isOpenControlled","closeOnSelect"),actions:["selectItem","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectItem","invokeOnClose","setFinalFocus"]},{actions:["selectItem"]}],"LAYER.ESCAPE":[{guard:be("isOpenControlled","autoComplete"),actions:["syncInputValue","invokeOnClose"]},{guard:"autoComplete",target:"focused",actions:["syncInputValue","invokeOnClose"]},{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose","setFinalFocus"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose"]}],"LAYER.INTERACT_OUTSIDE":[{guard:be("isOpenControlled","isCustomValue",Be("allowCustomValue")),actions:["revertInputValue","invokeOnClose"]},{guard:be("isCustomValue",Be("allowCustomValue")),target:"idle",actions:["revertInputValue","invokeOnClose"]},{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"idle",actions:["invokeOnClose"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose","setFinalFocus"]}],"VALUE.CLEAR":[{guard:"isOpenControlled",actions:["clearInputValue","clearSelectedItems","invokeOnClose"]},{target:"focused",actions:["clearInputValue","clearSelectedItems","invokeOnClose","setFinalFocus"]}]}},suggesting:{tags:["open","focused"],effects:["trackDismissableLayer","scrollToHighlightedItem","trackPlacement"],entry:["setInitialFocus"],on:{"CONTROLLED.CLOSE":[{guard:"restoreFocus",target:"focused",actions:["setFinalFocus"]},{target:"idle"}],CHILDREN_CHANGE:[{guard:be("isHighlightedItemRemoved","hasCollectionItems","autoHighlight"),actions:["clearHighlightedValue","highlightFirstItem"]},{guard:"isHighlightedItemRemoved",actions:["clearHighlightedValue"]},{guard:"autoHighlight",actions:["highlightFirstItem"]}],"INPUT.ARROW_DOWN":{target:"interacting",actions:["highlightNextItem"]},"INPUT.ARROW_UP":{target:"interacting",actions:["highlightPrevItem"]},"INPUT.HOME":{target:"interacting",actions:["highlightFirstItem"]},"INPUT.END":{target:"interacting",actions:["highlightLastItem"]},"INPUT.ENTER":[{guard:be("isOpenControlled","isCustomValue",Be("hasHighlightedItem"),Be("allowCustomValue")),actions:["revertInputValue","invokeOnClose"]},{guard:be("isCustomValue",Be("hasHighlightedItem"),Be("allowCustomValue")),target:"focused",actions:["revertInputValue","invokeOnClose"]},{guard:be("isOpenControlled","closeOnSelect"),actions:["selectHighlightedItem","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectHighlightedItem","invokeOnClose","setFinalFocus"]},{actions:["selectHighlightedItem"]}],"INPUT.CHANGE":{actions:["setInputValue"]},"LAYER.ESCAPE":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose"]}],"ITEM.POINTER_MOVE":{target:"interacting",actions:["setHighlightedValue"]},"ITEM.POINTER_LEAVE":{actions:["clearHighlightedValue"]},"LAYER.INTERACT_OUTSIDE":[{guard:be("isOpenControlled","isCustomValue",Be("allowCustomValue")),actions:["revertInputValue","invokeOnClose"]},{guard:be("isCustomValue",Be("allowCustomValue")),target:"idle",actions:["revertInputValue","invokeOnClose"]},{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"idle",actions:["invokeOnClose"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose"]}],"ITEM.CLICK":[{guard:be("isOpenControlled","closeOnSelect"),actions:["selectItem","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectItem","invokeOnClose","setFinalFocus"]},{actions:["selectItem"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose","setFinalFocus"]}],"VALUE.CLEAR":[{guard:"isOpenControlled",actions:["clearInputValue","clearSelectedItems","invokeOnClose"]},{target:"focused",actions:["clearInputValue","clearSelectedItems","invokeOnClose","setFinalFocus"]}]}}},implementations:{guards:{isInputValueEmpty:({computed:e})=>e("isInputValueEmpty"),autoComplete:({computed:e,prop:t})=>e("autoComplete")&&!t("multiple"),autoHighlight:({computed:e})=>e("autoHighlight"),isFirstItemHighlighted:({prop:e,context:t})=>e("collection").firstValue===t.get("highlightedValue"),isLastItemHighlighted:({prop:e,context:t})=>e("collection").lastValue===t.get("highlightedValue"),isCustomValue:({computed:e})=>e("isCustomValue"),allowCustomValue:({prop:e})=>!!e("allowCustomValue"),hasHighlightedItem:({context:e})=>e.get("highlightedValue")!=null,closeOnSelect:({prop:e})=>!!e("closeOnSelect"),isOpenControlled:({prop:e})=>e("open")!=null,openOnChange:({prop:e,context:t})=>{let n=e("openOnChange");return sl(n)?n:!!(n!=null&&n({inputValue:t.get("inputValue")}))},restoreFocus:({event:e})=>{var n,r;let t=(r=e.restoreFocus)!=null?r:(n=e.previousEvent)==null?void 0:n.restoreFocus;return t==null?!0:!!t},isChangeEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="INPUT.CHANGE"},autoFocus:({prop:e})=>!!e("autoFocus"),isHighlightedItemRemoved:({prop:e,context:t})=>!e("collection").has(t.get("highlightedValue")),hasCollectionItems:({prop:e})=>e("collection").size>0},effects:{trackDismissableLayer({send:e,prop:t,scope:n}){return t("disableLayer")?void 0:vt(()=>fn(n),{type:"listbox",defer:!0,exclude:()=>[pn(n),Ar(n),rv(n)],onFocusOutside:t("onFocusOutside"),onPointerDownOutside:t("onPointerDownOutside"),onInteractOutside:t("onInteractOutside"),onEscapeKeyDown(i){i.preventDefault(),i.stopPropagation(),e({type:"LAYER.ESCAPE",src:"escape-key"})},onDismiss(){e({type:"LAYER.INTERACT_OUTSIDE",src:"interact-outside",restoreFocus:!1})}})},trackPlacement({context:e,prop:t,scope:n}){let r=()=>Ec(n)||Ar(n),i=()=>bc(n);return e.set("currentPlacement",t("positioning").placement),at(r,i,y(m({},t("positioning")),{defer:!0,onComplete(s){e.set("currentPlacement",s.placement)}}))},scrollToHighlightedItem({context:e,prop:t,scope:n,event:r}){let i=pn(n),s=[],o=c=>{let u=r.current().type.includes("POINTER"),h=e.get("highlightedValue");if(u||!h)return;let p=fn(n),d=t("scrollToIndexFn");if(d){let b=t("collection").indexOf(h);d({index:b,immediate:c,getElement:()=>er(n,h)});return}let g=er(n,h),v=H(()=>{ln(g,{rootEl:p,block:"nearest"})});s.push(v)},a=H(()=>o(!0));s.push(a);let l=Ln(i,{attributes:["aria-activedescendant"],callback:()=>o(!1)});return s.push(l),()=>{s.forEach(c=>c())}}},actions:{reposition({context:e,prop:t,scope:n,event:r}){at(()=>Ec(n),()=>bc(n),y(m(m({},t("positioning")),r.options),{defer:!0,listeners:!1,onComplete(o){e.set("currentPlacement",o.placement)}}))},setHighlightedValue({context:e,event:t}){t.value!=null&&e.set("highlightedValue",t.value)},clearHighlightedValue({context:e}){e.set("highlightedValue",null)},selectHighlightedItem(e){var a;let{context:t,prop:n}=e,r=n("collection"),i=t.get("highlightedValue");if(!i||!r.has(i))return;let s=n("multiple")?it(t.get("value"),i):[i];(a=n("onSelect"))==null||a({value:s,itemValue:i}),t.set("value",s);let o=Ve(n("selectionBehavior"),{preserve:t.get("inputValue"),replace:r.stringifyMany(s),clear:""});t.set("inputValue",o)},scrollToHighlightedItem({context:e,prop:t,scope:n}){an(()=>{let r=e.get("highlightedValue");if(r==null)return;let i=er(n,r),s=fn(n),o=t("scrollToIndexFn");if(o){let a=t("collection").indexOf(r);o({index:a,immediate:!0,getElement:()=>er(n,r)});return}ln(i,{rootEl:s,block:"nearest"})})},selectItem(e){let{context:t,event:n,flush:r,prop:i}=e;n.value!=null&&r(()=>{var a;let s=i("multiple")?it(t.get("value"),n.value):[n.value];(a=i("onSelect"))==null||a({value:s,itemValue:n.value}),t.set("value",s);let o=Ve(i("selectionBehavior"),{preserve:t.get("inputValue"),replace:i("collection").stringifyMany(s),clear:""});t.set("inputValue",o)})},clearItem(e){let{context:t,event:n,flush:r,prop:i}=e;n.value!=null&&r(()=>{let s=ht(t.get("value"),n.value);t.set("value",s);let o=Ve(i("selectionBehavior"),{preserve:t.get("inputValue"),replace:i("collection").stringifyMany(s),clear:""});t.set("inputValue",o)})},setInitialFocus({scope:e}){H(()=>{Cc(e)})},setFinalFocus({scope:e}){H(()=>{let t=Ar(e);(t==null?void 0:t.dataset.focusable)==null?Cc(e):iv(e)})},syncInputValue({context:e,scope:t,event:n}){let r=pn(t);r&&(r.value=e.get("inputValue"),queueMicrotask(()=>{n.current().type!=="INPUT.CHANGE"&&Aa(r)}))},setInputValue({context:e,event:t}){e.set("inputValue",t.value)},clearInputValue({context:e}){e.set("inputValue","")},revertInputValue({context:e,prop:t,computed:n}){let r=t("selectionBehavior"),i=Ve(r,{replace:n("hasSelectedItems")?n("valueAsString"):"",preserve:e.get("inputValue"),clear:""});e.set("inputValue",i)},setValue(e){let{context:t,flush:n,event:r,prop:i}=e;n(()=>{t.set("value",r.value);let s=Ve(i("selectionBehavior"),{preserve:t.get("inputValue"),replace:i("collection").stringifyMany(r.value),clear:""});t.set("inputValue",s)})},clearSelectedItems(e){let{context:t,flush:n,prop:r}=e;n(()=>{t.set("value",[]);let i=Ve(r("selectionBehavior"),{preserve:t.get("inputValue"),replace:r("collection").stringifyMany([]),clear:""});t.set("inputValue",i)})},scrollContentToTop({prop:e,scope:t}){let n=e("scrollToIndexFn");if(n){let r=e("collection").firstValue;n({index:0,immediate:!0,getElement:()=>er(t,r)})}else{let r=fn(t);if(!r)return;r.scrollTop=0}},invokeOnOpen({prop:e,event:t,context:n}){var i;let r=Ic(t);(i=e("onOpenChange"))==null||i({open:!0,reason:r,value:n.get("value")})},invokeOnClose({prop:e,event:t,context:n}){var i;let r=Ic(t);(i=e("onOpenChange"))==null||i({open:!1,reason:r,value:n.get("value")})},highlightFirstItem({context:e,prop:t,scope:n}){(fn(n)?queueMicrotask:H)(()=>{let i=t("collection").firstValue;i&&e.set("highlightedValue",i)})},highlightFirstItemIfNeeded({computed:e,action:t}){e("autoHighlight")&&t(["highlightFirstItem"])},highlightLastItem({context:e,prop:t,scope:n}){(fn(n)?queueMicrotask:H)(()=>{let i=t("collection").lastValue;i&&e.set("highlightedValue",i)})},highlightNextItem({context:e,prop:t}){let n=null,r=e.get("highlightedValue"),i=t("collection");r?(n=i.getNextValue(r),!n&&t("loopFocus")&&(n=i.firstValue)):n=i.firstValue,n&&e.set("highlightedValue",n)},highlightPrevItem({context:e,prop:t}){let n=null,r=e.get("highlightedValue"),i=t("collection");r?(n=i.getPreviousValue(r),!n&&t("loopFocus")&&(n=i.lastValue)):n=i.lastValue,n&&e.set("highlightedValue",n)},highlightFirstSelectedItem({context:e,prop:t}){H(()=>{let[n]=t("collection").sort(e.get("value"));n&&e.set("highlightedValue",n)})},highlightFirstOrSelectedItem({context:e,prop:t,computed:n}){H(()=>{let r=null;n("hasSelectedItems")?r=t("collection").sort(e.get("value"))[0]:r=t("collection").firstValue,r&&e.set("highlightedValue",r)})},highlightLastOrSelectedItem({context:e,prop:t,computed:n}){H(()=>{let r=t("collection"),i=null;n("hasSelectedItems")?i=r.sort(e.get("value"))[0]:i=r.lastValue,i&&e.set("highlightedValue",i)})},autofillInputValue({context:e,computed:t,prop:n,event:r,scope:i}){let s=pn(i),o=n("collection");if(!t("autoComplete")||!s||!r.keypress)return;let a=o.stringify(e.get("highlightedValue"));H(()=>{s.value=a||e.get("inputValue")})},syncSelectedItems(e){queueMicrotask(()=>{let{context:t,prop:n}=e,r=n("collection"),i=t.get("value"),s=i.map(a=>t.get("selectedItems").find(c=>r.getItemValue(c)===a)||r.find(a));t.set("selectedItems",s);let o=Ve(n("selectionBehavior"),{preserve:t.get("inputValue"),replace:r.stringifyMany(i),clear:""});t.set("inputValue",o)})},syncHighlightedItem({context:e,prop:t}){let n=t("collection").find(e.get("highlightedValue"));e.set("highlightedItem",n)},toggleVisibility({event:e,send:t,prop:n}){t({type:n("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:e})}}}});uv=G()(["allowCustomValue","autoFocus","closeOnSelect","collection","composite","defaultHighlightedValue","defaultInputValue","defaultOpen","defaultValue","dir","disabled","disableLayer","form","getRootNode","highlightedValue","id","ids","inputBehavior","inputValue","invalid","loopFocus","multiple","name","navigate","onFocusOutside","onHighlightChange","onInputValueChange","onInteractOutside","onOpenChange","onOpenChange","onPointerDownOutside","onSelect","onValueChange","open","openOnChange","openOnClick","openOnKeyPress","placeholder","positioning","readOnly","required","scrollToIndexFn","selectionBehavior","translations","value","alwaysSubmitOnEnter"]),dT=B(uv),dv=G()(["htmlFor"]),hT=B(dv),hv=G()(["id"]),gT=B(hv),gv=G()(["item","persistFocus"]),fT=B(gv),fv=class extends te{constructor(){super(...arguments);U(this,"options",[]);U(this,"allOptions",[]);U(this,"hasGroups",!1)}setAllOptions(t){this.allOptions=t,this.options=t}getCollection(){let t=this.options||this.allOptions||[];return this.hasGroups?Ui({items:t,itemToValue:n=>{var r;return(r=n.id)!=null?r:""},itemToString:n=>n.label,isItemDisabled:n=>{var r;return(r=n.disabled)!=null?r:!1},groupBy:n=>n.group}):Ui({items:t,itemToValue:n=>{var r;return(r=n.id)!=null?r:""},itemToString:n=>n.label,isItemDisabled:n=>{var r;return(r=n.disabled)!=null?r:!1}})}initMachine(t){let n=this.getCollection.bind(this);return new ee(cv,y(m({},t),{get collection(){return n()},onOpenChange:r=>{r.open&&(this.options=this.allOptions),t.onOpenChange&&t.onOpenChange(r)},onInputValueChange:r=>{let i=this.allOptions.filter(s=>s.label.toLowerCase().includes(r.inputValue.toLowerCase()));this.options=i.length>0?i:this.allOptions,t.onInputValueChange&&t.onInputValueChange(r)}}))}initApi(){return sv(this.machine.service,Q)}renderItems(){var o,a,l;let t=this.el.querySelector('[data-scope="combobox"][data-part="content"]');if(!t)return;let n=this.el.querySelector('[data-templates="combobox"]');if(!n)return;t.querySelectorAll('[data-scope="combobox"][data-part="item"]:not([data-template])').forEach(c=>c.remove()),t.querySelectorAll('[data-scope="combobox"][data-part="item-group"]:not([data-template])').forEach(c=>c.remove());let r=this.api.collection.items,i=(l=(a=(o=this.api.collection).group)==null?void 0:a.call(o))!=null?l:[];i.some(([c])=>c!=null)?this.renderGroupedItems(t,n,i):this.renderFlatItems(t,n,r)}renderGroupedItems(t,n,r){for(let[i,s]of r){if(i==null)continue;let o=n.querySelector(`[data-scope="combobox"][data-part="item-group"][data-id="${i}"][data-template]`);if(!o)continue;let a=o.cloneNode(!0);a.removeAttribute("data-template"),this.spreadProps(a,this.api.getItemGroupProps({id:i}));let l=a.querySelector('[data-scope="combobox"][data-part="item-group-label"]');l&&this.spreadProps(l,this.api.getItemGroupLabelProps({htmlFor:i}));let c=a.querySelector('[data-scope="combobox"][data-part="item-group-content"]');if(c){c.innerHTML="";for(let u of s){let h=this.cloneItem(n,u);h&&c.appendChild(h)}t.appendChild(a)}}}renderFlatItems(t,n,r){for(let i of r){let s=this.cloneItem(n,i);s&&t.appendChild(s)}}cloneItem(t,n){let r=this.api.collection.getItemValue(n),i=t.querySelector(`[data-scope="combobox"][data-part="item"][data-value="${r}"][data-template]`);if(!i)return null;let s=i.cloneNode(!0);s.removeAttribute("data-template"),this.spreadProps(s,this.api.getItemProps({item:n}));let o=s.querySelector('[data-scope="combobox"][data-part="item-text"]');o&&(this.spreadProps(o,this.api.getItemTextProps({item:n})),o.children.length===0&&(o.textContent=n.label||""));let a=s.querySelector('[data-scope="combobox"][data-part="item-indicator"]');return a&&this.spreadProps(a,this.api.getItemIndicatorProps({item:n})),s}render(){let t=this.el.querySelector('[data-scope="combobox"][data-part="root"]');if(!t)return;this.spreadProps(t,this.api.getRootProps()),["label","control","input","trigger","clear-trigger","positioner"].forEach(r=>{let i=this.el.querySelector(`[data-scope="combobox"][data-part="${r}"]`);if(!i)return;let s="get"+r.split("-").map(o=>o[0].toUpperCase()+o.slice(1)).join("")+"Props";this.spreadProps(i,this.api[s]())});let n=this.el.querySelector('[data-scope="combobox"][data-part="content"]');n&&(this.spreadProps(n,this.api.getContentProps()),this.renderItems())}};vv={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=JSON.parse(e.dataset.collection||"[]"),r=n.some(a=>a.group!==void 0),i=y(m({id:e.id},O(e,"controlled")?{value:Y(e,"value")}:{defaultValue:Y(e,"defaultValue")}),{disabled:O(e,"disabled"),placeholder:x(e,"placeholder"),alwaysSubmitOnEnter:O(e,"alwaysSubmitOnEnter"),autoFocus:O(e,"autoFocus"),closeOnSelect:O(e,"closeOnSelect"),dir:x(e,"dir",["ltr","rtl"]),inputBehavior:x(e,"inputBehavior",["autohighlight","autocomplete","none"]),loopFocus:O(e,"loopFocus"),multiple:O(e,"multiple"),invalid:O(e,"invalid"),allowCustomValue:!1,selectionBehavior:"replace",name:x(e,"name"),form:x(e,"form"),readOnly:O(e,"readOnly"),required:O(e,"required"),positioning:(()=>{let a=e.dataset.positioning;if(a)try{let l=JSON.parse(a);return mv(l)}catch(l){return}})(),onOpenChange:a=>{let l=x(e,"onOpenChange");l&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(l,{open:a.open,reason:a.reason,value:a.value,id:e.id});let c=x(e,"onOpenChangeClient");c&&e.dispatchEvent(new CustomEvent(c,{bubbles:O(e,"bubble"),detail:{open:a.open,reason:a.reason,value:a.value,id:e.id}}))},onInputValueChange:a=>{let l=x(e,"onInputValueChange");l&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(l,{value:a.inputValue,reason:a.reason,id:e.id});let c=x(e,"onInputValueChangeClient");c&&e.dispatchEvent(new CustomEvent(c,{bubbles:O(e,"bubble"),detail:{value:a.inputValue,reason:a.reason,id:e.id}}))},onValueChange:a=>{let l=e.querySelector('[data-scope="combobox"][data-part="value-input"]');if(l){let h=a.value.length===0?"":a.value.length===1?String(a.value[0]):a.value.map(String).join(",");l.value=h;let p=l.getAttribute("form"),d=null;p?d=document.getElementById(p):d=l.closest("form");let g=new Event("change",{bubbles:!0,cancelable:!0});l.dispatchEvent(g);let v=new Event("input",{bubbles:!0,cancelable:!0});l.dispatchEvent(v),d&&d.hasAttribute("phx-change")&&requestAnimationFrame(()=>{let b=d.querySelector("input, select, textarea");if(b){let V=new Event("change",{bubbles:!0,cancelable:!0});b.dispatchEvent(V)}else{let V=new Event("change",{bubbles:!0,cancelable:!0});d.dispatchEvent(V)}})}let c=x(e,"onValueChange");c&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(c,{value:a.value,items:a.items,id:e.id});let u=x(e,"onValueChangeClient");u&&e.dispatchEvent(new CustomEvent(u,{bubbles:O(e,"bubble"),detail:{value:a.value,items:a.items,id:e.id}}))}}),s=new fv(e,i);s.hasGroups=r,s.setAllOptions(n),s.init();let o=O(e,"controlled")?Y(e,"value"):Y(e,"defaultValue");if(o&&o.length>0){let a=n.filter(l=>{var c;return o.includes((c=l.id)!=null?c:"")});if(a.length>0){let l=a.map(c=>{var u;return(u=c.label)!=null?u:""}).join(", ");if(s.api&&typeof s.api.setInputValue=="function")s.api.setInputValue(l);else{let c=e.querySelector('[data-scope="combobox"][data-part="input"]');c&&(c.value=l)}}}this.combobox=s,this.handlers=[]},updated(){let e=JSON.parse(this.el.dataset.collection||"[]"),t=e.some(n=>n.group!==void 0);if(this.combobox){this.combobox.hasGroups=t,this.combobox.setAllOptions(e),this.combobox.updateProps(y(m({},O(this.el,"controlled")?{value:Y(this.el,"value")}:{defaultValue:Y(this.el,"defaultValue")}),{name:x(this.el,"name"),form:x(this.el,"form"),disabled:O(this.el,"disabled"),multiple:O(this.el,"multiple"),dir:x(this.el,"dir",["ltr","rtl"]),invalid:O(this.el,"invalid"),required:O(this.el,"required"),readOnly:O(this.el,"readOnly")}));let n=this.el.querySelector('[data-scope="combobox"][data-part="input"]');n&&(n.removeAttribute("name"),n.removeAttribute("form"),n.name="")}},destroyed(){var e;if(this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.combobox)==null||e.destroy()}}});var Su={};Oe(Su,{DatePicker:()=>lb});function vo(e,t){return e-t*Math.floor(e/t)}function qi(e,t,n,r){t=Do(e,t);let i=t-1,s=-2;return n<=2?s=0:Ji(t)&&(s=-1),qc-1+365*i+Math.floor(i/4)-Math.floor(i/100)+Math.floor(i/400)+Math.floor((367*n-362)/12+s+r)}function Ji(e){return e%4===0&&(e%100!==0||e%400===0)}function Do(e,t){return e==="BC"?1-t:t}function yv(e){let t="AD";return e<=0&&(t="BC",e=1-e),[t,e]}function bn(e,t){return t=Ue(t,e.calendar),e.era===t.era&&e.year===t.year&&e.month===t.month&&e.day===t.day}function Cv(e,t){return t=Ue(t,e.calendar),e=Lt(e),t=Lt(t),e.era===t.era&&e.year===t.year&&e.month===t.month}function Iv(e,t){return t=Ue(t,e.calendar),e=Lr(e),t=Lr(t),e.era===t.era&&e.year===t.year}function Tv(e,t){return ts(e.calendar,t.calendar)&&bn(e,t)}function Ov(e,t){return ts(e.calendar,t.calendar)&&Cv(e,t)}function Sv(e,t){return ts(e.calendar,t.calendar)&&Iv(e,t)}function ts(e,t){var n,r,i,s;return(s=(i=(n=e.isEqual)===null||n===void 0?void 0:n.call(e,t))!==null&&i!==void 0?i:(r=t.isEqual)===null||r===void 0?void 0:r.call(t,e))!==null&&s!==void 0?s:e.identifier===t.identifier}function Pv(e,t){return bn(e,ns(t))}function Wc(e,t,n){let r=e.calendar.toJulianDay(e),i=n?wv[n]:kv(t),s=Math.ceil(r+1-i)%7;return s<0&&(s+=7),s}function Kc(e){return Ft(Date.now(),e)}function ns(e){return mn(Kc(e))}function Yc(e,t){return e.calendar.toJulianDay(e)-t.calendar.toJulianDay(t)}function Vv(e,t){return xc(e)-xc(t)}function xc(e){return e.hour*36e5+e.minute*6e4+e.second*1e3+e.millisecond}function Lo(){return yo==null&&(yo=new Intl.DateTimeFormat().resolvedOptions().timeZone),yo}function Lt(e){return e.subtract({days:e.day-1})}function So(e){return e.add({days:e.calendar.getDaysInMonth(e)-e.day})}function Lr(e){return Lt(e.subtract({months:e.month-1}))}function xv(e){return So(e.add({months:e.calendar.getMonthsInYear(e)-e.month}))}function Fr(e,t,n){let r=Wc(e,t,n);return e.subtract({days:r})}function kc(e,t,n){return Fr(e,t,n).add({days:6})}function jc(e){if(Intl.Locale){let n=Nc.get(e);return n||(n=new Intl.Locale(e).maximize().region,n&&Nc.set(e,n)),n}let t=e.split("-")[1];return t==="u"?void 0:t}function kv(e){let t=bo.get(e);if(!t){if(Intl.Locale){let r=new Intl.Locale(e);if("getWeekInfo"in r&&(t=r.getWeekInfo(),t))return bo.set(e,t),t.firstDay}let n=jc(e);if(e.includes("-fw-")){let r=e.split("-fw-")[1].split("-")[0];r==="mon"?t={firstDay:1}:r==="tue"?t={firstDay:2}:r==="wed"?t={firstDay:3}:r==="thu"?t={firstDay:4}:r==="fri"?t={firstDay:5}:r==="sat"?t={firstDay:6}:t={firstDay:0}}else e.includes("-ca-iso8601")?t={firstDay:1}:t={firstDay:n&&Ev[n]||0};bo.set(e,t)}return t.firstDay}function Nv(e,t,n){let r=e.calendar.getDaysInMonth(e);return Math.ceil((Wc(Lt(e),t,n)+r)/7)}function Xc(e,t){return e&&t?e.compare(t)<=0?e:t:e||t}function Zc(e,t){return e&&t?e.compare(t)>=0?e:t:e||t}function Rv(e,t){let n=e.calendar.toJulianDay(e),r=Math.ceil(n+1)%7;r<0&&(r+=7);let i=jc(t),[s,o]=Av[i]||[6,0];return r===s||r===o}function sr(e){e=Ue(e,new ir);let t=Do(e.era,e.year);return Jc(t,e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function Jc(e,t,n,r,i,s,o){let a=new Date;return a.setUTCHours(r,i,s,o),a.setUTCFullYear(e,t-1,n),a.getTime()}function Po(e,t){if(t==="UTC")return 0;if(e>0&&t===Lo())return new Date(e).getTimezoneOffset()*-6e4;let{year:n,month:r,day:i,hour:s,minute:o,second:a}=zc(e,t);return Jc(n,r,i,s,o,a,0)-Math.floor(e/1e3)*1e3}function zc(e,t){let n=Ac.get(t);n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Ac.set(t,n));let r=n.formatToParts(new Date(e)),i={};for(let s of r)s.type!=="literal"&&(i[s.type]=s.value);return{year:i.era==="BC"||i.era==="B"?-i.year+1:+i.year,month:+i.month,day:+i.day,hour:i.hour==="24"?0:+i.hour,minute:+i.minute,second:+i.second}}function Dv(e,t,n,r){return(n===r?[n]:[n,r]).filter(s=>Lv(e,t,s))}function Lv(e,t,n){let r=zc(n,t);return e.year===r.year&&e.month===r.month&&e.day===r.day&&e.hour===r.hour&&e.minute===r.minute&&e.second===r.second}function Dt(e,t,n="compatible"){let r=vn(e);if(t==="UTC")return sr(r);if(t===Lo()&&n==="compatible"){r=Ue(r,new ir);let l=new Date,c=Do(r.era,r.year);return l.setFullYear(c,r.month-1,r.day),l.setHours(r.hour,r.minute,r.second,r.millisecond),l.getTime()}let i=sr(r),s=Po(i-Rc,t),o=Po(i+Rc,t),a=Dv(r,t,i-s,i-o);if(a.length===1)return a[0];if(a.length>1)switch(n){case"compatible":case"earlier":return a[0];case"later":return a[a.length-1];case"reject":throw new RangeError("Multiple possible absolute times found")}switch(n){case"earlier":return Math.min(i-s,i-o);case"compatible":case"later":return Math.max(i-s,i-o);case"reject":throw new RangeError("No such absolute time found")}}function Qc(e,t,n="compatible"){return new Date(Dt(e,t,n))}function Ft(e,t){let n=Po(e,t),r=new Date(e+n),i=r.getUTCFullYear(),s=r.getUTCMonth()+1,o=r.getUTCDate(),a=r.getUTCHours(),l=r.getUTCMinutes(),c=r.getUTCSeconds(),u=r.getUTCMilliseconds();return new au(i<1?"BC":"AD",i<1?-i+1:i,s,o,t,n,a,l,c,u)}function mn(e){return new or(e.calendar,e.era,e.year,e.month,e.day)}function vn(e,t){let n=0,r=0,i=0,s=0;if("timeZone"in e)({hour:n,minute:r,second:i,millisecond:s}=e);else if("hour"in e&&!t)return e;return t&&({hour:n,minute:r,second:i,millisecond:s}=t),new ny(e.calendar,e.era,e.year,e.month,e.day,n,r,i,s)}function Ue(e,t){if(ts(e.calendar,t))return e;let n=t.fromJulianDay(e.calendar.toJulianDay(e)),r=e.copy();return r.calendar=t,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,yn(r),r}function Fv(e,t,n){if(e instanceof au)return e.timeZone===t?e:$v(e,t);let r=Dt(e,t,n);return Ft(r,t)}function Mv(e){let t=sr(e)-e.offset;return new Date(t)}function $v(e,t){let n=sr(e)-e.offset;return Ue(Ft(n,t),e.calendar)}function rs(e,t){let n=e.copy(),r="hour"in n?Gv(n,t):0;wo(n,t.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,e),n.month+=t.months||0,Vo(n),eu(n),n.day+=(t.weeks||0)*7,n.day+=t.days||0,n.day+=r,_v(n),n.calendar.balanceDate&&n.calendar.balanceDate(n),n.year<1&&(n.year=1,n.month=1,n.day=1);let i=n.calendar.getYearsInEra(n);if(n.year>i){var s,o;let l=(s=(o=n.calendar).isInverseEra)===null||s===void 0?void 0:s.call(o,n);n.year=i,n.month=l?1:n.calendar.getMonthsInYear(n),n.day=l?1:n.calendar.getDaysInMonth(n)}n.month<1&&(n.month=1,n.day=1);let a=n.calendar.getMonthsInYear(n);return n.month>a&&(n.month=a,n.day=n.calendar.getDaysInMonth(n)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day)),n}function wo(e,t){var n,r;!((n=(r=e.calendar).isInverseEra)===null||n===void 0)&&n.call(r,e)&&(t=-t),e.year+=t}function Vo(e){for(;e.month<1;)wo(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,wo(e,1)}function _v(e){for(;e.day<1;)e.month--,Vo(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,Vo(e)}function eu(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function yn(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),eu(e)}function tu(e){let t={};for(let n in e)typeof e[n]=="number"&&(t[n]=-e[n]);return t}function nu(e,t){return rs(e,tu(t))}function Fo(e,t){let n=e.copy();return t.era!=null&&(n.era=t.era),t.year!=null&&(n.year=t.year),t.month!=null&&(n.month=t.month),t.day!=null&&(n.day=t.day),yn(n),n}function es(e,t){let n=e.copy();return t.hour!=null&&(n.hour=t.hour),t.minute!=null&&(n.minute=t.minute),t.second!=null&&(n.second=t.second),t.millisecond!=null&&(n.millisecond=t.millisecond),Bv(n),n}function Hv(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=Wi(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=Wi(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=Wi(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=Wi(e.hour,24),t}function Bv(e){e.millisecond=Math.max(0,Math.min(e.millisecond,1e3)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function Wi(e,t){let n=e%t;return n<0&&(n+=t),n}function Gv(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,Hv(e)}function Mo(e,t,n,r){let i=e.copy();switch(t){case"era":{let a=e.calendar.getEras(),l=a.indexOf(e.era);if(l<0)throw new Error("Invalid era: "+e.era);l=Mt(l,n,0,a.length-1,r==null?void 0:r.round),i.era=a[l],yn(i);break}case"year":var s,o;!((s=(o=i.calendar).isInverseEra)===null||s===void 0)&&s.call(o,i)&&(n=-n),i.year=Mt(e.year,n,-1/0,9999,r==null?void 0:r.round),i.year===-1/0&&(i.year=1),i.calendar.balanceYearMonth&&i.calendar.balanceYearMonth(i,e);break;case"month":i.month=Mt(e.month,n,1,e.calendar.getMonthsInYear(e),r==null?void 0:r.round);break;case"day":i.day=Mt(e.day,n,1,e.calendar.getDaysInMonth(e),r==null?void 0:r.round);break;default:throw new Error("Unsupported field "+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(i),yn(i),i}function ru(e,t,n,r){let i=e.copy();switch(t){case"hour":{let s=e.hour,o=0,a=23;if((r==null?void 0:r.hourCycle)===12){let l=s>=12;o=l?12:0,a=l?23:11}i.hour=Mt(s,n,o,a,r==null?void 0:r.round);break}case"minute":i.minute=Mt(e.minute,n,0,59,r==null?void 0:r.round);break;case"second":i.second=Mt(e.second,n,0,59,r==null?void 0:r.round);break;case"millisecond":i.millisecond=Mt(e.millisecond,n,0,999,r==null?void 0:r.round);break;default:throw new Error("Unsupported field "+t)}return i}function Mt(e,t,n,r,i=!1){if(i){e+=Math.sign(t),e0?e=Math.ceil(e/s)*s:e=Math.floor(e/s)*s,e>r&&(e=n)}else e+=t,er&&(e=n+(e-r-1));return e}function iu(e,t){let n;if(t.years!=null&&t.years!==0||t.months!=null&&t.months!==0||t.weeks!=null&&t.weeks!==0||t.days!=null&&t.days!==0){let i=rs(vn(e),{years:t.years,months:t.months,weeks:t.weeks,days:t.days});n=Dt(i,e.timeZone)}else n=sr(e)-e.offset;n+=t.milliseconds||0,n+=(t.seconds||0)*1e3,n+=(t.minutes||0)*6e4,n+=(t.hours||0)*36e5;let r=Ft(n,e.timeZone);return Ue(r,e.calendar)}function Uv(e,t){return iu(e,tu(t))}function qv(e,t,n,r){switch(t){case"hour":{let i=0,s=23;if((r==null?void 0:r.hourCycle)===12){let g=e.hour>=12;i=g?12:0,s=g?23:11}let o=vn(e),a=Ue(es(o,{hour:i}),new ir),l=[Dt(a,e.timeZone,"earlier"),Dt(a,e.timeZone,"later")].filter(g=>Ft(g,e.timeZone).day===a.day)[0],c=Ue(es(o,{hour:s}),new ir),u=[Dt(c,e.timeZone,"earlier"),Dt(c,e.timeZone,"later")].filter(g=>Ft(g,e.timeZone).day===c.day).pop(),h=sr(e)-e.offset,p=Math.floor(h/Rr),d=h%Rr;return h=Mt(p,n,Math.floor(l/Rr),Math.floor(u/Rr),r==null?void 0:r.round)*Rr+d,Ue(Ft(h,e.timeZone),e.calendar)}case"minute":case"second":case"millisecond":return ru(e,t,n,r);case"era":case"year":case"month":case"day":{let i=Mo(vn(e),t,n,r),s=Dt(i,e.timeZone);return Ue(Ft(s,e.timeZone),e.calendar)}default:throw new Error("Unsupported field "+t)}}function Wv(e,t,n){let r=vn(e),i=es(Fo(r,t),t);if(i.compare(r)===0)return e;let s=Dt(i,e.timeZone,n);return Ue(Ft(s,e.timeZone),e.calendar)}function Xv(e){let t=e.match(Kv);if(!t)throw Yv.test(e)?new Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date string: "+e);let n=new or(Eo(t[1],0,9999),Eo(t[2],1,12),1);return n.day=Eo(t[3],1,n.calendar.getDaysInMonth(n)),n}function Eo(e,t,n){let r=Number(e);if(rn)throw new RangeError(`Value out of range: ${t} <= ${r} <= ${n}`);return r}function Zv(e){return`${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${e.millisecond?String(e.millisecond/1e3).slice(1):""}`}function su(e){let t=Ue(e,new ir),n;return t.era==="BC"?n=t.year===1?"0000":"-"+String(Math.abs(1-t.year)).padStart(6,"00"):n=String(t.year).padStart(4,"0"),`${n}-${String(t.month).padStart(2,"0")}-${String(t.day).padStart(2,"0")}`}function ou(e){return`${su(e)}T${Zv(e)}`}function Jv(e){let t=Math.sign(e)<0?"-":"+";e=Math.abs(e);let n=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),i=Math.floor(e%36e5%6e4/1e3),s=`${t}${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`;return i!==0&&(s+=`:${String(i).padStart(2,"0")}`),s}function zv(e){return`${ou(e)}${Jv(e.offset)}[${e.timeZone}]`}function Qv(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function $o(e,t,n){Qv(e,t),t.set(e,n)}function _o(e){let t=typeof e[0]=="object"?e.shift():new ir,n;if(typeof e[0]=="string")n=e.shift();else{let o=t.getEras();n=o[o.length-1]}let r=e.shift(),i=e.shift(),s=e.shift();return[t,n,r,i,s]}function lu(e,t={}){if(typeof t.hour12=="boolean"&&sy()){t=m({},t);let i=iy[String(t.hour12)][e.split("-")[0]],s=t.hour12?"h12":"h23";t.hourCycle=i!=null?i:s,delete t.hour12}let n=e+(t?Object.entries(t).sort((i,s)=>i[0]s.type==="hour").value,10),i=parseInt(n.formatToParts(new Date(2020,2,3,23)).find(s=>s.type==="hour").value,10);if(r===0&&i===23)return"h23";if(r===24&&i===23)return"h24";if(r===0&&i===11)return"h11";if(r===12&&i===11)return"h12";throw new Error("Unexpected hour cycle result")}function ly(e,t,n,r,i){let s={};for(let a in t){let l=a,c=t[l];c!=null&&(s[l]=Math.floor(c/2),s[l]>0&&c%2===0&&s[l]--)}let o=En(e,t,n).subtract(s);return Mr(e,o,t,n,r,i)}function En(e,t,n,r,i){let s=e;return t.years?s=Lr(e):t.months?s=Lt(e):t.weeks&&(s=Fr(e,n)),Mr(e,s,t,n,r,i)}function Ho(e,t,n,r,i){let s=m({},t);s.days?s.days--:s.weeks?s.weeks--:s.months?s.months--:s.years&&s.years--;let o=En(e,t,n).subtract(s);return Mr(e,o,t,n,r,i)}function Mr(e,t,n,r,i,s){return i&&e.compare(i)>=0&&(t=Zc(t,En(mn(i),n,r))),s&&e.compare(s)<=0&&(t=Xc(t,Ho(mn(s),n,r))),t}function lt(e,t,n){let r=mn(e);return t&&(r=Zc(r,mn(t))),n&&(r=Xc(r,mn(n))),r}function Dc(e,t,n,r,i,s){switch(t){case"start":return En(e,n,r,i,s);case"end":return Ho(e,n,r,i,s);case"center":default:return ly(e,n,r,i,s)}}function Ge(e,t){return e==null||t==null?e===t:bn(e,t)}function Lc(e,t,n,r,i){return e?t!=null&&t(e,n)?!0:yt(e,r,i):!1}function yt(e,t,n){return t!=null&&e.compare(t)<0||n!=null&&e.compare(n)>0}function cy(e,t,n){let r=e.subtract({days:1});return bn(r,e)||yt(r,t,n)}function uy(e,t,n){let r=e.add({days:1});return bn(r,e)||yt(r,t,n)}function Bo(e){let t=m({},e);for(let n in t)t[n]=1;return t}function cu(e,t){let n=m({},t);return n.days?n.days--:n.days=-1,e.add(n)}function uu(e){return(e==null?void 0:e.calendar.identifier)==="gregory"&&e.era==="BC"?"short":void 0}function du(e,t){let n=vn(ns(t));return new ct(e,{weekday:"long",month:"long",year:"numeric",day:"numeric",era:uu(n),timeZone:t})}function Fc(e,t){let n=ns(t);return new ct(e,{month:"long",year:"numeric",era:uu(n),calendar:n==null?void 0:n.calendar.identifier,timeZone:t})}function dy(e,t,n,r,i){let s=n.formatRangeToParts(e.toDate(i),t.toDate(i)),o=-1;for(let c=0;co&&(l+=s[c].value);return r(a,l)}function Ki(e,t,n,r){if(!e)return"";let i=e,s=t!=null?t:e,o=du(n,r);return bn(i,s)?o.format(i.toDate(r)):dy(i,s,o,(a,l)=>`${a} \u2013 ${l}`,r)}function hu(e){return e!=null?hy[e]:void 0}function gu(e,t,n){let r=hu(n);return Fr(e,t,r)}function fu(e,t,n,r){let i=t.add({weeks:e}),s=[],o=gu(i,n,r);for(;s.length<7;){s.push(o);let a=o.add({days:1});if(bn(o,a))break;o=a}return s}function gy(e,t,n,r){let i=hu(r),s=n!=null?n:Nv(e,t,i);return[...new Array(s).keys()].map(a=>fu(a,e,t,r))}function fy(e,t){let n=new ct(e,{weekday:"long",timeZone:t}),r=new ct(e,{weekday:"short",timeZone:t}),i=new ct(e,{weekday:"narrow",timeZone:t});return s=>{let o=s instanceof Date?s:s.toDate(t);return{value:s,short:r.format(o),long:n.format(o),narrow:i.format(o)}}}function py(e,t,n,r){let i=gu(e,r,t),s=[...new Array(7).keys()],o=fy(r,n);return s.map(a=>o(i.add({days:a})))}function my(e,t="long"){let n=new Date(2021,0,1),r=[];for(let i=0;i<12;i++)r.push(n.toLocaleString(e,{month:t})),n.setMonth(n.getMonth()+1);return r}function vy(e){let t=[];for(let n=e.from;n<=e.to;n+=1)t.push(n);return t}function by(e){if(e){if(e.length===3)return e.padEnd(4,"0");if(e.length===2){let t=new Date().getFullYear(),n=Math.floor(t/100)*100,r=parseInt(e.slice(-2),10),i=n+r;return i>t+yy?(i-100).toString():i.toString()}return e}}function rr(e,t){let n=t!=null&&t.strict?10:12,r=e-e%10,i=[];for(let s=0;s0?{startDate:En(a,e,t,n,r),endDate:l,focusedDate:lt(a,n,r)}:{startDate:o,endDate:l,focusedDate:lt(a,n,r)}}}function pu(e,t,n,r,i,s){let o=$r(n,r,i,s),a=t.add(n);return o({focusedDate:e.add(n),startDate:En(Mr(e,a,n,r,i,s),n,r)})}function mu(e,t,n,r,i,s){let o=$r(n,r,i,s),a=t.subtract(n);return o({focusedDate:e.subtract(n),startDate:En(Mr(e,a,n,r,i,s),n,r)})}function Ey(e,t,n,r,i,s,o){let a=$r(r,i,s,o);if(!n&&!r.days)return a({focusedDate:e.add(Bo(r)),startDate:t});if(r.days)return pu(e,t,r,i,s,o);if(r.weeks)return a({focusedDate:e.add({months:1}),startDate:t});if(r.months||r.years)return a({focusedDate:e.add({years:1}),startDate:t})}function Cy(e,t,n,r,i,s,o){let a=$r(r,i,s,o);if(!n&&!r.days)return a({focusedDate:e.subtract(Bo(r)),startDate:t});if(r.days)return mu(e,t,r,i,s,o);if(r.weeks)return a({focusedDate:e.subtract({months:1}),startDate:t});if(r.months||r.years)return a({focusedDate:e.subtract({years:1}),startDate:t})}function Oy(e,t,n){var c;let r=Sy(t,n),{year:i,month:s,day:o}=(c=Py(r,e))!=null?c:{};if(i!=null||s!=null||o!=null){let u=new Date;i||(i=u.getFullYear().toString()),s||(s=(u.getMonth()+1).toString()),o||(o=u.getDate().toString())}if(Mc(i)||(i=by(i)),Mc(i)&&Iy(s)&&Ty(o))return new or(+i,+s,+o);let l=Date.parse(e);if(!isNaN(l)){let u=new Date(l);return new or(u.getFullYear(),u.getMonth()+1,u.getDate())}}function Sy(e,t){return new ct(e,{day:"numeric",month:"numeric",year:"numeric",timeZone:t}).formatToParts(new Date(2e3,11,25)).map(({type:i,value:s})=>i==="literal"?`${s}?`:`((?!=<${i}>)\\d+)?`).join("")}function Py(e,t){var r;let n=t.match(e);return(r=e.toString().match(/<(.+?)>/g))==null?void 0:r.map(i=>{var o;let s=i.match(/<(.+)>/);return!s||s.length<=0?null:(o=i.match(/<(.+)>/))==null?void 0:o[1]}).reduce((i,s,o)=>(s&&(n&&n.length>o?i[s]=n[o+1]:i[s]=null),i),{})}function $c(e,t,n){let r=mn(Kc(n));switch(e){case"thisWeek":return[Fr(r,t),kc(r,t)];case"thisMonth":return[Lt(r),r];case"thisQuarter":return[Lt(r).add({months:-((r.month-1)%3)}),r];case"thisYear":return[Lr(r),r];case"last3Days":return[r.add({days:-2}),r];case"last7Days":return[r.add({days:-6}),r];case"last14Days":return[r.add({days:-13}),r];case"last30Days":return[r.add({days:-29}),r];case"last90Days":return[r.add({days:-89}),r];case"lastMonth":return[Lt(r.add({months:-1})),So(r.add({months:-1}))];case"lastQuarter":return[Lt(r.add({months:-((r.month-1)%3)-3})),So(r.add({months:-((r.month-1)%3)-1}))];case"lastWeek":return[Fr(r,t).add({weeks:-1}),kc(r,t).add({weeks:-1})];case"lastYear":return[Lr(r.add({years:-1})),xv(r.add({years:-1}))];default:throw new Error(`Invalid date range preset: ${e}`)}}function wy(e={}){var c;let{level:t="polite",document:n=document,root:r,delay:i=0}=e,s=(c=n.defaultView)!=null?c:window,o=r!=null?r:n.body;function a(u,h){let p=n.getElementById(Yi);p==null||p.remove(),h=h!=null?h:i;let d=n.createElement("span");d.id=Yi,d.dataset.liveAnnouncer="true";let g=t!=="assertive"?"status":"alert";d.setAttribute("aria-live",t),d.setAttribute("role",g),Object.assign(d.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}),o.appendChild(d),s.setTimeout(()=>{d.textContent=u},h)}function l(){let u=n.getElementById(Yi);u==null||u.remove()}return{announce:a,destroy:l,toJSON(){return Yi}}}function Ro(e){let[t,n]=e,r;return!t||!n?r=e:r=t.compare(n)<=0?e:[n,t],r}function tr(e,t){let[n,r]=t;return!n||!r?!1:n.compare(e)<=0&&r.compare(e)>=0}function ji(e){return e.slice().filter(t=>t!=null).sort((t,n)=>t.compare(n))}function _y(e){return Ve(e,{year:"calendar decade",month:"calendar year",day:"calendar month"})}function By(e){return new ct(e).formatToParts(new Date).map(t=>{var n;return(n=Hy[t.type])!=null?n:t.value}).join("")}function Uy(e){let r=new Intl.DateTimeFormat(e).formatToParts(new Date).find(i=>i.type==="literal");return r?r.value:"/"}function $t(e,t){return e?e==="day"?0:e==="month"?1:2:t||0}function Go(e){return e===0?"day":e===1?"month":"year"}function Uo(e,t,n){return Go(dl($t(e,0),$t(t,0),$t(n,2)))}function Wy(e,t){return $t(e,0)>$t(t,0)}function Ky(e,t){return $t(e,0)<$t(t,0)}function Yy(e,t,n){let r=$t(e,0)+1;return Uo(Go(r),t,n)}function jy(e,t,n){let r=$t(e,0)-1;return Uo(Go(r),t,n)}function Zy(e){Xy.forEach(t=>e(t))}function zy(e,t){let{state:n,context:r,prop:i,send:s,computed:o,scope:a}=e,l=r.get("startValue"),c=o("endValue"),u=r.get("value"),h=r.get("focusedValue"),p=r.get("hoveredValue"),d=p?Ro([u[0],p]):[],g=!!i("disabled"),v=!!i("readOnly"),b=!!i("invalid"),V=o("isInteractive"),S=u.length===0,E=i("min"),f=i("max"),C=i("locale"),I=i("timeZone"),w=i("startOfWeek"),A=n.matches("focused"),P=n.matches("open"),N=i("selectionMode")==="range",R=i("isDateUnavailable"),L=r.get("currentPlacement"),M=Zt(y(m({},i("positioning")),{placement:L})),j=Uy(C),q=m(m({},qy),i("translations"));function J(D=l){let k=i("fixedWeeks")?6:void 0;return gy(D,C,k,w)}function W(D={}){let{format:k}=D;return my(C,k).map((F,_)=>{let z=_+1,Le=h.set({month:z}),Ie=yt(Le,E,f);return{label:F,value:z,disabled:Ie}})}function ge(){var k,F;return vy({from:(k=E==null?void 0:E.year)!=null?k:1900,to:(F=f==null?void 0:f.year)!=null?F:2100}).map(_=>({label:_.toString(),value:_,disabled:!vi(_,E==null?void 0:E.year,f==null?void 0:f.year)}))}function de(D){return Lc(D,R,C,E,f)}function X(D){let k=l!=null?l:nr(I);s({type:"FOCUS.SET",value:k.set({month:D})})}function ue(D){let k=l!=null?l:nr(I);s({type:"FOCUS.SET",value:k.set({year:D})})}function qe(D){let{value:k,disabled:F}=D,_=h.set({year:k}),Le=!rr(l.year,{strict:!0}).includes(k),Ie=vi(k,E==null?void 0:E.year,f==null?void 0:f.year),ut={focused:h.year===D.value,selectable:Le||Ie,outsideRange:Le,selected:!!u.find(fr=>fr&&fr.year===k),valueText:k.toString(),inRange:N&&(tr(_,u)||tr(_,d)),value:_,get disabled(){return F||!ut.selectable}};return ut}function It(D){let{value:k,disabled:F}=D,_=h.set({month:k}),z=Fc(C,I),Le={focused:h.month===D.value,selectable:!yt(_,E,f),selected:!!u.find(Ie=>Ie&&Ie.month===k&&Ie.year===h.year),valueText:z.format(_.toDate(I)),inRange:N&&(tr(_,u)||tr(_,d)),value:_,get disabled(){return F||!Le.selectable}};return Le}function gr(D){let{value:k,disabled:F,visibleRange:_=o("visibleRange")}=D,z=du(C,I),Le=Bo(o("visibleDuration")),Ie=i("outsideDaySelectable"),ut=_.start.add(Le).subtract({days:1}),fr=yt(k,_.start,ut),eh=N&&tr(k,u),th=N&&Ge(k,u[0]),nh=N&&Ge(k,u[1]),Cs=N&&d.length>0,ya=Cs&&tr(k,d),rh=Cs&&Ge(k,d[0]),ih=Cs&&Ge(k,d[1]),pr={invalid:yt(k,E,f),disabled:F||!Ie&&fr||yt(k,E,f),selected:u.some(sh=>Ge(k,sh)),unavailable:Lc(k,R,C,E,f)&&!F,outsideRange:fr,today:Pv(k,I),weekend:Rv(k,C),formattedDate:z.format(k.toDate(I)),get focused(){return Ge(k,h)&&(!pr.outsideRange||Ie)},get ariaLabel(){return q.dayCell(pr)},get selectable(){return!pr.disabled&&!pr.unavailable},inRange:eh||ya,firstInRange:th,lastInRange:nh,inHoveredRange:ya,firstInHoveredRange:rh,lastInHoveredRange:ih};return pr}function Es(D){let{view:k="day",id:F}=D;return[k,F].filter(Boolean).join(" ")}return{focused:A,open:P,disabled:g,invalid:b,readOnly:v,inline:!!i("inline"),numOfMonths:i("numOfMonths"),selectionMode:i("selectionMode"),view:r.get("view"),getRangePresetValue(D){return $c(D,C,I)},getDaysInWeek(D,k=l){return fu(D,k,C,w)},getOffset(D){let k=l.add(D),F=c.add(D),_=Fc(C,I);return{visibleRange:{start:k,end:F},weeks:J(k),visibleRangeText:{start:_.format(k.toDate(I)),end:_.format(F.toDate(I))}}},getMonthWeeks:J,isUnavailable:de,weeks:J(),weekDays:py(nr(I),w,I,C),visibleRangeText:o("visibleRangeText"),value:u,valueAsDate:u.filter(D=>D!=null).map(D=>D.toDate(I)),valueAsString:o("valueAsString"),focusedValue:h,focusedValueAsDate:h==null?void 0:h.toDate(I),focusedValueAsString:i("format")(h,{locale:C,timeZone:I}),visibleRange:o("visibleRange"),selectToday(){let D=lt(nr(I),E,f);s({type:"VALUE.SET",value:D})},setValue(D){let k=D.map(F=>lt(F,E,f));s({type:"VALUE.SET",value:k})},clearValue(){s({type:"VALUE.CLEAR"})},setFocusedValue(D){s({type:"FOCUS.SET",value:D})},setOpen(D){i("inline")||n.matches("open")===D||s({type:D?"OPEN":"CLOSE"})},focusMonth:X,focusYear:ue,getYears:ge,getMonths:W,getYearsGrid(D={}){let{columns:k=1}=D,F=rr(l.year,{strict:!0}).map(_=>({label:_.toString(),value:_,disabled:!vi(_,E==null?void 0:E.year,f==null?void 0:f.year)}));return Ws(F,k)},getDecade(){let D=rr(l.year,{strict:!0});return{start:D.at(0),end:D.at(-1)}},getMonthsGrid(D={}){let{columns:k=1,format:F}=D;return Ws(W({format:F}),k)},format(D,k={month:"long",year:"numeric"}){return new ct(C,k).format(D.toDate(I))},setView(D){s({type:"VIEW.SET",view:D})},goToNext(){s({type:"GOTO.NEXT",view:r.get("view")})},goToPrev(){s({type:"GOTO.PREV",view:r.get("view")})},getRootProps(){return t.element(y(m({},se.root.attrs),{dir:i("dir"),id:ky(a),"data-state":P?"open":"closed","data-disabled":T(g),"data-readonly":T(v),"data-empty":T(S)}))},getLabelProps(D={}){let{index:k=0}=D;return t.label(y(m({},se.label.attrs),{id:xy(a,k),dir:i("dir"),htmlFor:_c(a,k),"data-state":P?"open":"closed","data-index":k,"data-disabled":T(g),"data-readonly":T(v)}))},getControlProps(){return t.element(y(m({},se.control.attrs),{dir:i("dir"),id:yu(a),"data-disabled":T(g),"data-placeholder-shown":T(S)}))},getRangeTextProps(){return t.element(y(m({},se.rangeText.attrs),{dir:i("dir")}))},getContentProps(){return t.element(y(m({},se.content.attrs),{hidden:!P,dir:i("dir"),"data-state":P?"open":"closed","data-placement":L,"data-inline":T(i("inline")),id:Ao(a),tabIndex:-1,role:"application","aria-roledescription":"datepicker","aria-label":q.content}))},getTableProps(D={}){let{view:k="day",columns:F=k==="day"?7:4}=D,_=Es(D);return t.element(y(m({},se.table.attrs),{role:"grid","data-columns":F,"aria-roledescription":_y(k),id:Ny(a,_),"aria-readonly":re(v),"aria-disabled":re(g),"aria-multiselectable":re(i("selectionMode")!=="single"),"data-view":k,dir:i("dir"),tabIndex:-1,onKeyDown(z){if(z.defaultPrevented)return;let Ie={Enter(){k==="day"&&de(h)||k==="month"&&!It({value:h.month}).selectable||k==="year"&&!qe({value:h.year}).selectable||s({type:"TABLE.ENTER",view:k,columns:F,focus:!0})},ArrowLeft(){s({type:"TABLE.ARROW_LEFT",view:k,columns:F,focus:!0})},ArrowRight(){s({type:"TABLE.ARROW_RIGHT",view:k,columns:F,focus:!0})},ArrowUp(){s({type:"TABLE.ARROW_UP",view:k,columns:F,focus:!0})},ArrowDown(){s({type:"TABLE.ARROW_DOWN",view:k,columns:F,focus:!0})},PageUp(ut){s({type:"TABLE.PAGE_UP",larger:ut.shiftKey,view:k,columns:F,focus:!0})},PageDown(ut){s({type:"TABLE.PAGE_DOWN",larger:ut.shiftKey,view:k,columns:F,focus:!0})},Home(){s({type:"TABLE.HOME",view:k,columns:F,focus:!0})},End(){s({type:"TABLE.END",view:k,columns:F,focus:!0})}}[ve(z,{dir:i("dir")})];Ie&&(Ie(z),z.preventDefault(),z.stopPropagation())},onPointerLeave(){s({type:"TABLE.POINTER_LEAVE"})},onPointerDown(){s({type:"TABLE.POINTER_DOWN",view:k})},onPointerUp(){s({type:"TABLE.POINTER_UP",view:k})}}))},getTableHeadProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.tableHead.attrs),{"aria-hidden":!0,dir:i("dir"),"data-view":k,"data-disabled":T(g)}))},getTableHeaderProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.tableHeader.attrs),{dir:i("dir"),"data-view":k,"data-disabled":T(g)}))},getTableBodyProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.tableBody.attrs),{"data-view":k,"data-disabled":T(g)}))},getTableRowProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.tableRow.attrs),{"aria-disabled":re(g),"data-disabled":T(g),"data-view":k}))},getDayTableCellState:gr,getDayTableCellProps(D){let{value:k}=D,F=gr(D);return t.element(y(m({},se.tableCell.attrs),{role:"gridcell","aria-disabled":re(!F.selectable),"aria-selected":F.selected||F.inRange,"aria-invalid":re(F.invalid),"aria-current":F.today?"date":void 0,"data-value":k.toString()}))},getDayTableCellTriggerProps(D){let{value:k}=D,F=gr(D);return t.element(y(m({},se.tableCellTrigger.attrs),{id:Oo(a,k.toString()),role:"button",dir:i("dir"),tabIndex:F.focused?0:-1,"aria-label":F.ariaLabel,"aria-disabled":re(!F.selectable),"aria-invalid":re(F.invalid),"data-disabled":T(!F.selectable),"data-selected":T(F.selected),"data-value":k.toString(),"data-view":"day","data-today":T(F.today),"data-focus":T(F.focused),"data-unavailable":T(F.unavailable),"data-range-start":T(F.firstInRange),"data-range-end":T(F.lastInRange),"data-in-range":T(F.inRange),"data-outside-range":T(F.outsideRange),"data-weekend":T(F.weekend),"data-in-hover-range":T(F.inHoveredRange),"data-hover-range-start":T(F.firstInHoveredRange),"data-hover-range-end":T(F.lastInHoveredRange),onClick(_){_.defaultPrevented||F.selectable&&s({type:"CELL.CLICK",cell:"day",value:k})},onPointerMove:N?_=>{if(_.pointerType==="touch"||!F.selectable)return;let z=!a.isActiveElement(_.currentTarget);p&&Tv(k,p)||s({type:"CELL.POINTER_MOVE",cell:"day",value:k,focus:z})}:void 0}))},getMonthTableCellState:It,getMonthTableCellProps(D){let{value:k,columns:F}=D,_=It(D);return t.element(y(m({},se.tableCell.attrs),{dir:i("dir"),colSpan:F,role:"gridcell","aria-selected":re(_.selected||_.inRange),"data-selected":T(_.selected),"aria-disabled":re(!_.selectable),"data-value":k}))},getMonthTableCellTriggerProps(D){let{value:k}=D,F=It(D);return t.element(y(m({},se.tableCellTrigger.attrs),{dir:i("dir"),role:"button",id:Oo(a,k.toString()),"data-selected":T(F.selected),"aria-disabled":re(!F.selectable),"data-disabled":T(!F.selectable),"data-focus":T(F.focused),"data-in-range":T(F.inRange),"data-outside-range":T(F.outsideRange),"aria-label":F.valueText,"data-view":"month","data-value":k,tabIndex:F.focused?0:-1,onClick(_){_.defaultPrevented||F.selectable&&s({type:"CELL.CLICK",cell:"month",value:k})},onPointerMove:N?_=>{if(_.pointerType==="touch"||!F.selectable)return;let z=!a.isActiveElement(_.currentTarget);p&&F.value&&Ov(F.value,p)||s({type:"CELL.POINTER_MOVE",cell:"month",value:F.value,focus:z})}:void 0}))},getYearTableCellState:qe,getYearTableCellProps(D){let{value:k,columns:F}=D,_=qe(D);return t.element(y(m({},se.tableCell.attrs),{dir:i("dir"),colSpan:F,role:"gridcell","aria-selected":re(_.selected),"data-selected":T(_.selected),"aria-disabled":re(!_.selectable),"data-value":k}))},getYearTableCellTriggerProps(D){let{value:k}=D,F=qe(D);return t.element(y(m({},se.tableCellTrigger.attrs),{dir:i("dir"),role:"button",id:Oo(a,k.toString()),"data-selected":T(F.selected),"data-focus":T(F.focused),"data-in-range":T(F.inRange),"aria-disabled":re(!F.selectable),"data-disabled":T(!F.selectable),"aria-label":F.valueText,"data-outside-range":T(F.outsideRange),"data-value":k,"data-view":"year",tabIndex:F.focused?0:-1,onClick(_){_.defaultPrevented||F.selectable&&s({type:"CELL.CLICK",cell:"year",value:k})},onPointerMove:N?_=>{if(_.pointerType==="touch"||!F.selectable)return;let z=!a.isActiveElement(_.currentTarget);p&&F.value&&Sv(F.value,p)||s({type:"CELL.POINTER_MOVE",cell:"year",value:F.value,focus:z})}:void 0}))},getNextTriggerProps(D={}){let{view:k="day"}=D,F=g||!o("isNextVisibleRangeValid");return t.button(y(m({},se.nextTrigger.attrs),{dir:i("dir"),id:Ry(a,k),type:"button","aria-label":q.nextTrigger(k),disabled:F,"data-disabled":T(F),onClick(_){_.defaultPrevented||s({type:"GOTO.NEXT",view:k})}}))},getPrevTriggerProps(D={}){let{view:k="day"}=D,F=g||!o("isPrevVisibleRangeValid");return t.button(y(m({},se.prevTrigger.attrs),{dir:i("dir"),id:Ay(a,k),type:"button","aria-label":q.prevTrigger(k),disabled:F,"data-disabled":T(F),onClick(_){_.defaultPrevented||s({type:"GOTO.PREV",view:k})}}))},getClearTriggerProps(){return t.button(y(m({},se.clearTrigger.attrs),{id:vu(a),dir:i("dir"),type:"button","aria-label":q.clearTrigger,hidden:!u.length,onClick(D){D.defaultPrevented||s({type:"VALUE.CLEAR"})}}))},getTriggerProps(){return t.button(y(m({},se.trigger.attrs),{id:bu(a),dir:i("dir"),type:"button","data-placement":L,"aria-label":q.trigger(P),"aria-controls":Ao(a),"data-state":P?"open":"closed","data-placeholder-shown":T(S),"aria-haspopup":"grid",disabled:g,onClick(D){D.defaultPrevented||V&&s({type:"TRIGGER.CLICK"})}}))},getViewProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.view.attrs),{"data-view":k,hidden:r.get("view")!==k}))},getViewTriggerProps(D={}){let{view:k="day"}=D;return t.button(y(m({},se.viewTrigger.attrs),{"data-view":k,dir:i("dir"),id:Dy(a,k),type:"button",disabled:g,"aria-label":q.viewTrigger(k),onClick(F){F.defaultPrevented||V&&s({type:"VIEW.TOGGLE",src:"viewTrigger"})}}))},getViewControlProps(D={}){let{view:k="day"}=D;return t.element(y(m({},se.viewControl.attrs),{"data-view":k,dir:i("dir")}))},getInputProps(D={}){let{index:k=0,fixOnBlur:F=!0}=D;return t.input(y(m({},se.input.attrs),{id:_c(a,k),autoComplete:"off",autoCorrect:"off",spellCheck:"false",dir:i("dir"),name:i("name"),"data-index":k,"data-state":P?"open":"closed","data-placeholder-shown":T(S),readOnly:v,disabled:g,required:i("required"),"aria-invalid":re(b),"data-invalid":T(b),placeholder:i("placeholder")||By(C),defaultValue:o("valueAsString")[k],onBeforeInput(_){let{data:z}=Ms(_);Ou(z,j)||_.preventDefault()},onFocus(){s({type:"INPUT.FOCUS",index:k})},onBlur(_){let z=_.currentTarget.value.trim();s({type:"INPUT.BLUR",value:z,index:k,fixOnBlur:F})},onKeyDown(_){if(_.defaultPrevented||!V)return;let Le={Enter(Ie){Vt(Ie)||de(h)||Ie.currentTarget.value.trim()!==""&&s({type:"INPUT.ENTER",value:Ie.currentTarget.value,index:k})}}[_.key];Le&&(Le(_),_.preventDefault())},onInput(_){let z=_.currentTarget.value;s({type:"INPUT.CHANGE",value:Gy(z,j),index:k})}}))},getMonthSelectProps(){return t.select(y(m({},se.monthSelect.attrs),{id:Cu(a),"aria-label":q.monthSelect,disabled:g,dir:i("dir"),defaultValue:l.month,onChange(D){X(Number(D.currentTarget.value))}}))},getYearSelectProps(){return t.select(y(m({},se.yearSelect.attrs),{id:Iu(a),disabled:g,"aria-label":q.yearSelect,dir:i("dir"),defaultValue:l.year,onChange(D){ue(Number(D.currentTarget.value))}}))},getPositionerProps(){return t.element(y(m({id:Eu(a)},se.positioner.attrs),{dir:i("dir"),style:M.floating}))},getPresetTriggerProps(D){let k=Array.isArray(D.value)?D.value:$c(D.value,C,I),F=k.filter(_=>_!=null).map(_=>_.toDate(I).toDateString());return t.button(y(m({},se.presetTrigger.attrs),{"aria-label":q.presetTrigger(F),type:"button",onClick(_){_.defaultPrevented||s({type:"PRESET.CLICK",value:k})}}))}}}function Qy(e,t){if((e==null?void 0:e.length)!==(t==null?void 0:t.length))return!1;let n=Math.max(e.length,t.length);for(let r=0;rn==null?"":t("format")(n,{locale:t("locale"),timeZone:t("timeZone")}))}function ae(e,t){let{context:n,prop:r,computed:i}=e;if(!t)return;let s=Qi(e,t);if(Ge(n.get("focusedValue"),s))return;let a=$r(i("visibleDuration"),r("locale"),r("min"),r("max"))({focusedDate:s,startDate:n.get("startValue")});n.set("startValue",a.startDate),n.set("focusedValue",a.focusedDate)}function Zi(e,t){let{context:n}=e;n.set("startValue",t.startDate);let r=n.get("focusedValue");Ge(r,t.focusedDate)||n.set("focusedValue",t.focusedDate)}function Ze(e){return Array.isArray(e)?e.map(t=>Ze(t)):e instanceof Date?new or(e.getFullYear(),e.getMonth()+1,e.getDate()):Xv(e)}function Uc(e){let t=n=>String(n).padStart(2,"0");return`${e.year}-${t(e.month)}-${t(e.day)}`}var qc,bv,ir,Ev,wv,yo,Nc,bo,Av,Ac,Rc,Rr,Kv,Yv,jv,ET,ey,or,ty,ny,ry,au,Co,ct,iy,Io,To,hy,yy,Mc,Iy,Ty,Yi,Vy,se,xy,ky,Ny,Ao,Oo,Ay,Ry,Dy,vu,yu,_c,bu,Eu,Cu,Iu,Hc,Bc,zi,Dr,Ly,Fy,My,$y,Tu,Hy,Ou,Gc,Gy,qy,Xy,Jy,Xe,eb,Qi,tb,CT,nb,IT,rb,TT,ib,OT,sb,ST,ob,PT,ab,lb,Pu=fe(()=>{"use strict";Nr();gn();me();qc=1721426;bv={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]},ir=class{fromJulianDay(e){let t=e,n=t-qc,r=Math.floor(n/146097),i=vo(n,146097),s=Math.floor(i/36524),o=vo(i,36524),a=Math.floor(o/1461),l=vo(o,1461),c=Math.floor(l/365),u=r*400+s*100+a*4+c+(s!==4&&c!==4?1:0),[h,p]=yv(u),d=t-qi(h,p,1,1),g=2;t= start date");return`${this.formatter.format(e)} \u2013 ${this.formatter.format(t)}`}formatRangeToParts(e,t){if(typeof this.formatter.formatRangeToParts=="function")return this.formatter.formatRangeToParts(e,t);if(t= start date");let n=this.formatter.formatToParts(e),r=this.formatter.formatToParts(t);return[...n.map(i=>y(m({},i),{source:"startRange"})),{type:"literal",value:" \u2013 ",source:"shared"},...r.map(i=>y(m({},i),{source:"endRange"}))]}resolvedOptions(){let e=this.formatter.resolvedOptions();return oy()&&(this.resolvedHourCycle||(this.resolvedHourCycle=ay(e.locale,this.options)),e.hourCycle=this.resolvedHourCycle,e.hour12=this.resolvedHourCycle==="h11"||this.resolvedHourCycle==="h12"),e.calendar==="ethiopic-amete-alem"&&(e.calendar="ethioaa"),e}constructor(e,t={}){this.formatter=lu(e,t),this.options=t}},iy={true:{ja:"h11"},false:{}};Io=null;To=null;hy=["sun","mon","tue","wed","thu","fri","sat"];yy=10;Mc=e=>e!=null&&e.length===4,Iy=e=>e!=null&&parseFloat(e)<=12,Ty=e=>e!=null&&parseFloat(e)<=31;Yi="__live-region__";Vy=Z("date-picker").parts("clearTrigger","content","control","input","label","monthSelect","nextTrigger","positioner","presetTrigger","prevTrigger","rangeText","root","table","tableBody","tableCell","tableCellTrigger","tableHead","tableHeader","tableRow","trigger","view","viewControl","viewTrigger","yearSelect"),se=Vy.build(),xy=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.label)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:label:${t}`},ky=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`datepicker:${e.id}`},Ny=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.table)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:table:${t}`},Ao=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`datepicker:${e.id}:content`},Oo=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.cellTrigger)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:cell-trigger:${t}`},Ay=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.prevTrigger)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:prev:${t}`},Ry=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.nextTrigger)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:next:${t}`},Dy=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.viewTrigger)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:view:${t}`},vu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.clearTrigger)!=null?n:`datepicker:${e.id}:clear`},yu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`datepicker:${e.id}:control`},_c=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.input)==null?void 0:r.call(n,t))!=null?i:`datepicker:${e.id}:input:${t}`},bu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`datepicker:${e.id}:trigger`},Eu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.positioner)!=null?n:`datepicker:${e.id}:positioner`},Cu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.monthSelect)!=null?n:`datepicker:${e.id}:month-select`},Iu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.yearSelect)!=null?n:`datepicker:${e.id}:year-select`},Hc=(e,t)=>Mn(zi(e),`[data-part=table-cell-trigger][data-view=${t}][data-focus]:not([data-outside-range])`),Bc=e=>e.getById(bu(e)),zi=e=>e.getById(Ao(e)),Dr=e=>dt(Tu(e),"[data-part=input]"),Ly=e=>e.getById(Iu(e)),Fy=e=>e.getById(Cu(e)),My=e=>e.getById(vu(e)),$y=e=>e.getById(Eu(e)),Tu=e=>e.getById(yu(e));Hy={day:"dd",month:"mm",year:"yyyy"};Ou=(e,t)=>e?/\d/.test(e)||e===t||e.length!==1:!0,Gc=e=>!Number.isNaN(e.day)&&!Number.isNaN(e.month)&&!Number.isNaN(e.year),Gy=(e,t)=>e.split("").filter(n=>Ou(n,t)).join("");qy={dayCell(e){return e.unavailable?`Not available. ${e.formattedDate}`:e.selected?`Selected date. ${e.formattedDate}`:`Choose ${e.formattedDate}`},trigger(e){return e?"Close calendar":"Open calendar"},viewTrigger(e){return Ve(e,{year:"Switch to month view",month:"Switch to day view",day:"Switch to year view"})},presetTrigger(e){let[t="",n=""]=e;return`select ${t} to ${n}`},prevTrigger(e){return Ve(e,{year:"Switch to previous decade",month:"Switch to previous year",day:"Switch to previous month"})},nextTrigger(e){return Ve(e,{year:"Switch to next decade",month:"Switch to next year",day:"Switch to next month"})},placeholder(){return{day:"dd",month:"mm",year:"yyyy"}},content:"calendar",monthSelect:"Select month",yearSelect:"Select year",clearTrigger:"Clear selected dates"};Xy=["day","month","year"];Jy=gl(e=>[e.view,e.startValue.toString(),e.endValue.toString(),e.locale],([e],t)=>{let{startValue:n,endValue:r,locale:i,timeZone:s,selectionMode:o}=t;if(e==="year"){let h=rr(n.year,{strict:!0}),p=h.at(0).toString(),d=h.at(-1).toString();return{start:p,end:d,formatted:`${p} - ${d}`}}if(e==="month"){let h=new ct(i,{year:"numeric",timeZone:s}),p=h.format(n.toDate(s)),d=h.format(r.toDate(s)),g=o==="range"?`${p} - ${d}`:p;return{start:p,end:d,formatted:g}}let a=new ct(i,{month:"long",year:"numeric",timeZone:s}),l=a.format(n.toDate(s)),c=a.format(r.toDate(s)),u=o==="range"?`${l} - ${c}`:l;return{start:l,end:c,formatted:u}});({and:Xe}=ye());eb={props({props:e}){let t=e.locale||"en-US",n=e.timeZone||"UTC",r=e.selectionMode||"single",i=e.numOfMonths||1,s=e.defaultValue?ji(e.defaultValue).map(h=>lt(h,e.min,e.max)):void 0,o=e.value?ji(e.value).map(h=>lt(h,e.min,e.max)):void 0,a=e.focusedValue||e.defaultFocusedValue||(o==null?void 0:o[0])||(s==null?void 0:s[0])||nr(n);a=lt(a,e.min,e.max);let l="day",c="year",u=Uo(e.view||l,l,c);return y(m({locale:t,numOfMonths:i,timeZone:n,selectionMode:r,defaultView:u,minView:l,maxView:c,outsideDaySelectable:!1,closeOnSelect:!0,format(h,{locale:p,timeZone:d}){return new ct(p,{timeZone:d,day:"2-digit",month:"2-digit",year:"numeric"}).format(h.toDate(d))},parse(h,{locale:p,timeZone:d}){return Oy(h,p,d)}},e),{focusedValue:typeof e.focusedValue=="undefined"?void 0:a,defaultFocusedValue:a,value:o,defaultValue:s!=null?s:[],positioning:m({placement:"bottom"},e.positioning)})},initialState({prop:e}){return e("open")||e("defaultOpen")||e("inline")?"open":"idle"},refs(){return{announcer:void 0}},context({prop:e,bindable:t,getContext:n}){return{focusedValue:t(()=>({defaultValue:e("defaultFocusedValue"),value:e("focusedValue"),isEqual:Ge,hash:r=>r.toString(),sync:!0,onChange(r){var l;let i=n(),s=i.get("view"),o=i.get("value"),a=Xi(o,e);(l=e("onFocusChange"))==null||l({value:o,valueAsString:a,view:s,focusedValue:r})}})),value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),isEqual:Qy,hash:r=>r.map(i=>{var s;return(s=i==null?void 0:i.toString())!=null?s:""}).join(","),onChange(r){var o;let i=n(),s=Xi(r,e);(o=e("onValueChange"))==null||o({value:r,valueAsString:s,view:i.get("view")})}})),inputValue:t(()=>({defaultValue:""})),activeIndex:t(()=>({defaultValue:0,sync:!0})),hoveredValue:t(()=>({defaultValue:null,isEqual:Ge})),view:t(()=>({defaultValue:e("defaultView"),value:e("view"),onChange(r){var i;(i=e("onViewChange"))==null||i({view:r})}})),startValue:t(()=>{let r=e("focusedValue")||e("defaultFocusedValue");return{defaultValue:Dc(r,"start",{months:e("numOfMonths")},e("locale")),isEqual:Ge,hash:i=>i.toString()}}),currentPlacement:t(()=>({defaultValue:void 0})),restoreFocus:t(()=>({defaultValue:!1}))}},computed:{isInteractive:({prop:e})=>!e("disabled")&&!e("readOnly"),visibleDuration:({prop:e})=>({months:e("numOfMonths")}),endValue:({context:e,computed:t})=>cu(e.get("startValue"),t("visibleDuration")),visibleRange:({context:e,computed:t})=>({start:e.get("startValue"),end:t("endValue")}),visibleRangeText:({context:e,prop:t,computed:n})=>Jy({view:e.get("view"),startValue:e.get("startValue"),endValue:n("endValue"),locale:t("locale"),timeZone:t("timeZone"),selectionMode:t("selectionMode")}),isPrevVisibleRangeValid:({context:e,prop:t})=>!cy(e.get("startValue"),t("min"),t("max")),isNextVisibleRangeValid:({prop:e,computed:t})=>!uy(t("endValue"),e("min"),e("max")),valueAsString:({context:e,prop:t})=>Xi(e.get("value"),t)},effects:["setupLiveRegion"],watch({track:e,prop:t,context:n,action:r,computed:i}){e([()=>t("locale")],()=>{r(["setStartValue","syncInputElement"])}),e([()=>n.hash("focusedValue")],()=>{r(["setStartValue","focusActiveCellIfNeeded","setHoveredValueIfKeyboard"])}),e([()=>n.hash("startValue")],()=>{r(["syncMonthSelectElement","syncYearSelectElement","invokeOnVisibleRangeChange"])}),e([()=>n.get("inputValue")],()=>{r(["syncInputValue"])}),e([()=>n.hash("value")],()=>{r(["syncInputElement"])}),e([()=>i("valueAsString").toString()],()=>{r(["announceValueText"])}),e([()=>n.get("view")],()=>{r(["focusActiveCell"])}),e([()=>t("open")],()=>{r(["toggleVisibility"])})},on:{"VALUE.SET":{actions:["setDateValue","setFocusedDate"]},"VIEW.SET":{actions:["setView"]},"FOCUS.SET":{actions:["setFocusedDate"]},"VALUE.CLEAR":{actions:["clearDateValue","clearFocusedDate","focusFirstInputElement"]},"INPUT.CHANGE":[{guard:"isInputValueEmpty",actions:["setInputValue","clearDateValue","clearFocusedDate"]},{actions:["setInputValue","focusParsedDate"]}],"INPUT.ENTER":{actions:["focusParsedDate","selectFocusedDate"]},"INPUT.FOCUS":{actions:["setActiveIndex"]},"INPUT.BLUR":[{guard:"shouldFixOnBlur",actions:["setActiveIndexToStart","selectParsedDate"]},{actions:["setActiveIndexToStart"]}],"PRESET.CLICK":[{guard:"isOpenControlled",actions:["setDateValue","setFocusedDate","invokeOnClose"]},{target:"focused",actions:["setDateValue","setFocusedDate","focusInputElement"]}],"GOTO.NEXT":[{guard:"isYearView",actions:["focusNextDecade","announceVisibleRange"]},{guard:"isMonthView",actions:["focusNextYear","announceVisibleRange"]},{actions:["focusNextPage"]}],"GOTO.PREV":[{guard:"isYearView",actions:["focusPreviousDecade","announceVisibleRange"]},{guard:"isMonthView",actions:["focusPreviousYear","announceVisibleRange"]},{actions:["focusPreviousPage"]}]},states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":{target:"open",actions:["focusFirstSelectedDate","focusActiveCell"]},"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["focusFirstSelectedDate","focusActiveCell","invokeOnOpen"]}],OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["focusFirstSelectedDate","focusActiveCell","invokeOnOpen"]}]}},focused:{tags:["closed"],on:{"CONTROLLED.OPEN":{target:"open",actions:["focusFirstSelectedDate","focusActiveCell"]},"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["focusFirstSelectedDate","focusActiveCell","invokeOnOpen"]}],OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["focusFirstSelectedDate","focusActiveCell","invokeOnOpen"]}]}},open:{tags:["open"],effects:["trackDismissableElement","trackPositioning"],exit:["clearHoveredDate","resetView"],on:{"CONTROLLED.CLOSE":[{guard:Xe("shouldRestoreFocus","isInteractOutsideEvent"),target:"focused",actions:["focusTriggerElement"]},{guard:"shouldRestoreFocus",target:"focused",actions:["focusInputElement"]},{target:"idle"}],"CELL.CLICK":[{guard:"isAboveMinView",actions:["setFocusedValueForView","setPreviousView"]},{guard:Xe("isRangePicker","hasSelectedRange"),actions:["setActiveIndexToStart","resetSelection","setActiveIndexToEnd"]},{guard:Xe("isRangePicker","isSelectingEndDate","closeOnSelect","isOpenControlled"),actions:["setFocusedDate","setSelectedDate","setActiveIndexToStart","clearHoveredDate","invokeOnClose","setRestoreFocus"]},{guard:Xe("isRangePicker","isSelectingEndDate","closeOnSelect"),target:"focused",actions:["setFocusedDate","setSelectedDate","setActiveIndexToStart","clearHoveredDate","invokeOnClose","focusInputElement"]},{guard:Xe("isRangePicker","isSelectingEndDate"),actions:["setFocusedDate","setSelectedDate","setActiveIndexToStart","clearHoveredDate"]},{guard:"isRangePicker",actions:["setFocusedDate","setSelectedDate","setActiveIndexToEnd"]},{guard:"isMultiPicker",actions:["setFocusedDate","toggleSelectedDate"]},{guard:Xe("closeOnSelect","isOpenControlled"),actions:["setFocusedDate","setSelectedDate","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["setFocusedDate","setSelectedDate","invokeOnClose","focusInputElement"]},{actions:["setFocusedDate","setSelectedDate"]}],"CELL.POINTER_MOVE":{guard:Xe("isRangePicker","isSelectingEndDate"),actions:["setHoveredDate","setFocusedDate"]},"TABLE.POINTER_LEAVE":{guard:"isRangePicker",actions:["clearHoveredDate"]},"TABLE.POINTER_DOWN":{actions:["disableTextSelection"]},"TABLE.POINTER_UP":{actions:["enableTextSelection"]},"TABLE.ESCAPE":[{guard:"isOpenControlled",actions:["focusFirstSelectedDate","invokeOnClose"]},{target:"focused",actions:["focusFirstSelectedDate","invokeOnClose","focusTriggerElement"]}],"TABLE.ENTER":[{guard:"isAboveMinView",actions:["setPreviousView"]},{guard:Xe("isRangePicker","hasSelectedRange"),actions:["setActiveIndexToStart","clearDateValue","setSelectedDate","setActiveIndexToEnd"]},{guard:Xe("isRangePicker","isSelectingEndDate","closeOnSelect","isOpenControlled"),actions:["setSelectedDate","setActiveIndexToStart","clearHoveredDate","invokeOnClose"]},{guard:Xe("isRangePicker","isSelectingEndDate","closeOnSelect"),target:"focused",actions:["setSelectedDate","setActiveIndexToStart","clearHoveredDate","invokeOnClose","focusInputElement"]},{guard:Xe("isRangePicker","isSelectingEndDate"),actions:["setSelectedDate","setActiveIndexToStart","clearHoveredDate"]},{guard:"isRangePicker",actions:["setSelectedDate","setActiveIndexToEnd","focusNextDay"]},{guard:"isMultiPicker",actions:["toggleSelectedDate"]},{guard:Xe("closeOnSelect","isOpenControlled"),actions:["selectFocusedDate","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectFocusedDate","invokeOnClose","focusInputElement"]},{actions:["selectFocusedDate"]}],"TABLE.ARROW_RIGHT":[{guard:"isMonthView",actions:["focusNextMonth"]},{guard:"isYearView",actions:["focusNextYear"]},{actions:["focusNextDay","setHoveredDate"]}],"TABLE.ARROW_LEFT":[{guard:"isMonthView",actions:["focusPreviousMonth"]},{guard:"isYearView",actions:["focusPreviousYear"]},{actions:["focusPreviousDay"]}],"TABLE.ARROW_UP":[{guard:"isMonthView",actions:["focusPreviousMonthColumn"]},{guard:"isYearView",actions:["focusPreviousYearColumn"]},{actions:["focusPreviousWeek"]}],"TABLE.ARROW_DOWN":[{guard:"isMonthView",actions:["focusNextMonthColumn"]},{guard:"isYearView",actions:["focusNextYearColumn"]},{actions:["focusNextWeek"]}],"TABLE.PAGE_UP":{actions:["focusPreviousSection"]},"TABLE.PAGE_DOWN":{actions:["focusNextSection"]},"TABLE.HOME":[{guard:"isMonthView",actions:["focusFirstMonth"]},{guard:"isYearView",actions:["focusFirstYear"]},{actions:["focusSectionStart"]}],"TABLE.END":[{guard:"isMonthView",actions:["focusLastMonth"]},{guard:"isYearView",actions:["focusLastYear"]},{actions:["focusSectionEnd"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose"]}],"VIEW.TOGGLE":{actions:["setNextView"]},INTERACT_OUTSIDE:[{guard:"isOpenControlled",actions:["setActiveIndexToStart","invokeOnClose"]},{guard:"shouldRestoreFocus",target:"focused",actions:["setActiveIndexToStart","invokeOnClose","focusTriggerElement"]},{target:"idle",actions:["setActiveIndexToStart","invokeOnClose"]}],CLOSE:[{guard:"isOpenControlled",actions:["setActiveIndexToStart","invokeOnClose"]},{target:"idle",actions:["setActiveIndexToStart","invokeOnClose"]}]}}},implementations:{guards:{isAboveMinView:({context:e,prop:t})=>Wy(e.get("view"),t("minView")),isDayView:({context:e,event:t})=>(t.view||e.get("view"))==="day",isMonthView:({context:e,event:t})=>(t.view||e.get("view"))==="month",isYearView:({context:e,event:t})=>(t.view||e.get("view"))==="year",isRangePicker:({prop:e})=>e("selectionMode")==="range",hasSelectedRange:({context:e})=>e.get("value").length===2,isMultiPicker:({prop:e})=>e("selectionMode")==="multiple",shouldRestoreFocus:({context:e})=>!!e.get("restoreFocus"),isSelectingEndDate:({context:e})=>e.get("activeIndex")===1,closeOnSelect:({prop:e})=>!!e("closeOnSelect"),isOpenControlled:({prop:e})=>e("open")!=null||!!e("inline"),isInteractOutsideEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="INTERACT_OUTSIDE"},isInputValueEmpty:({event:e})=>e.value.trim()==="",shouldFixOnBlur:({event:e})=>!!e.fixOnBlur},effects:{trackPositioning({context:e,prop:t,scope:n}){if(t("inline"))return;e.get("currentPlacement")||e.set("currentPlacement",t("positioning").placement);let r=Tu(n);return at(r,()=>$y(n),y(m({},t("positioning")),{defer:!0,onComplete(s){e.set("currentPlacement",s.placement)}}))},setupLiveRegion({scope:e,refs:t}){let n=e.getDoc();return t.set("announcer",wy({level:"assertive",document:n})),()=>{var r,i;return(i=(r=t.get("announcer"))==null?void 0:r.destroy)==null?void 0:i.call(r)}},trackDismissableElement({scope:e,send:t,context:n,prop:r}){return r("inline")?void 0:vt(()=>zi(e),{type:"popover",defer:!0,exclude:[...Dr(e),Bc(e),My(e)],onInteractOutside(s){n.set("restoreFocus",!s.detail.focusable)},onDismiss(){t({type:"INTERACT_OUTSIDE"})},onEscapeKeyDown(s){s.preventDefault(),t({type:"TABLE.ESCAPE",src:"dismissable"})}})}},actions:{setNextView({context:e,prop:t}){let n=Yy(e.get("view"),t("minView"),t("maxView"));e.set("view",n)},setPreviousView({context:e,prop:t}){let n=jy(e.get("view"),t("minView"),t("maxView"));e.set("view",n)},setView({context:e,event:t}){e.set("view",t.view)},setRestoreFocus({context:e}){e.set("restoreFocus",!0)},announceValueText({context:e,prop:t,refs:n}){var a;let r=e.get("value"),i=t("locale"),s=t("timeZone"),o;if(t("selectionMode")==="range"){let[l,c]=r;l&&c?o=Ki(l,c,i,s):l?o=Ki(l,null,i,s):c?o=Ki(c,null,i,s):o=""}else o=r.map(l=>Ki(l,null,i,s)).filter(Boolean).join(",");(a=n.get("announcer"))==null||a.announce(o,3e3)},announceVisibleRange({computed:e,refs:t}){var r;let{formatted:n}=e("visibleRangeText");(r=t.get("announcer"))==null||r.announce(n)},disableTextSelection({scope:e}){Bs({target:zi(e),doc:e.getDoc()})},enableTextSelection({scope:e}){Hs({doc:e.getDoc(),target:zi(e)})},focusFirstSelectedDate(e){let{context:t}=e;t.get("value").length&&ae(e,t.get("value")[0])},syncInputElement({scope:e,computed:t}){H(()=>{Dr(e).forEach((r,i)=>{xt(r,t("valueAsString")[i]||"")})})},setFocusedDate(e){let{event:t}=e,n=Array.isArray(t.value)?t.value[0]:t.value;ae(e,n)},setFocusedValueForView(e){let{context:t,event:n}=e;ae(e,t.get("focusedValue").set({[t.get("view")]:n.value}))},focusNextMonth(e){let{context:t}=e;ae(e,t.get("focusedValue").add({months:1}))},focusPreviousMonth(e){let{context:t}=e;ae(e,t.get("focusedValue").subtract({months:1}))},setDateValue({context:e,event:t,prop:n}){if(!Array.isArray(t.value))return;let r=t.value.map(i=>lt(i,n("min"),n("max")));e.set("value",r)},clearDateValue({context:e}){e.set("value",[])},setSelectedDate(e){var i;let{context:t,event:n}=e,r=Array.from(t.get("value"));r[t.get("activeIndex")]=Qi(e,(i=n.value)!=null?i:t.get("focusedValue")),t.set("value",Ro(r))},resetSelection(e){var i;let{context:t,event:n}=e,r=Qi(e,(i=n.value)!=null?i:t.get("focusedValue"));t.set("value",[r])},toggleSelectedDate(e){var s;let{context:t,event:n}=e,r=Qi(e,(s=n.value)!=null?s:t.get("focusedValue")),i=t.get("value").findIndex(o=>Ge(o,r));if(i===-1){let o=[...t.get("value"),r];t.set("value",ji(o))}else{let o=Array.from(t.get("value"));o.splice(i,1),t.set("value",ji(o))}},setHoveredDate({context:e,event:t}){e.set("hoveredValue",t.value)},clearHoveredDate({context:e}){e.set("hoveredValue",null)},selectFocusedDate({context:e,computed:t}){let n=Array.from(e.get("value")),r=e.get("activeIndex");n[r]=e.get("focusedValue").copy(),e.set("value",Ro(n));let i=t("valueAsString");e.set("inputValue",i[r])},focusPreviousDay(e){let{context:t}=e,n=t.get("focusedValue").subtract({days:1});ae(e,n)},focusNextDay(e){let{context:t}=e,n=t.get("focusedValue").add({days:1});ae(e,n)},focusPreviousWeek(e){let{context:t}=e,n=t.get("focusedValue").subtract({weeks:1});ae(e,n)},focusNextWeek(e){let{context:t}=e,n=t.get("focusedValue").add({weeks:1});ae(e,n)},focusNextPage(e){let{context:t,computed:n,prop:r}=e,i=pu(t.get("focusedValue"),t.get("startValue"),n("visibleDuration"),r("locale"),r("min"),r("max"));Zi(e,i)},focusPreviousPage(e){let{context:t,computed:n,prop:r}=e,i=mu(t.get("focusedValue"),t.get("startValue"),n("visibleDuration"),r("locale"),r("min"),r("max"));Zi(e,i)},focusSectionStart(e){let{context:t}=e;ae(e,t.get("startValue").copy())},focusSectionEnd(e){let{computed:t}=e;ae(e,t("endValue").copy())},focusNextSection(e){let{context:t,event:n,computed:r,prop:i}=e,s=Ey(t.get("focusedValue"),t.get("startValue"),n.larger,r("visibleDuration"),i("locale"),i("min"),i("max"));s&&Zi(e,s)},focusPreviousSection(e){let{context:t,event:n,computed:r,prop:i}=e,s=Cy(t.get("focusedValue"),t.get("startValue"),n.larger,r("visibleDuration"),i("locale"),i("min"),i("max"));s&&Zi(e,s)},focusNextYear(e){let{context:t}=e,n=t.get("focusedValue").add({years:1});ae(e,n)},focusPreviousYear(e){let{context:t}=e,n=t.get("focusedValue").subtract({years:1});ae(e,n)},focusNextDecade(e){let{context:t}=e,n=t.get("focusedValue").add({years:10});ae(e,n)},focusPreviousDecade(e){let{context:t}=e,n=t.get("focusedValue").subtract({years:10});ae(e,n)},clearFocusedDate(e){let{prop:t}=e;ae(e,nr(t("timeZone")))},focusPreviousMonthColumn(e){let{context:t,event:n}=e,r=t.get("focusedValue").subtract({months:n.columns});ae(e,r)},focusNextMonthColumn(e){let{context:t,event:n}=e,r=t.get("focusedValue").add({months:n.columns});ae(e,r)},focusPreviousYearColumn(e){let{context:t,event:n}=e,r=t.get("focusedValue").subtract({years:n.columns});ae(e,r)},focusNextYearColumn(e){let{context:t,event:n}=e,r=t.get("focusedValue").add({years:n.columns});ae(e,r)},focusFirstMonth(e){let{context:t}=e,n=t.get("focusedValue").set({month:1});ae(e,n)},focusLastMonth(e){let{context:t}=e,n=t.get("focusedValue").set({month:12});ae(e,n)},focusFirstYear(e){let{context:t}=e,n=rr(t.get("focusedValue").year),r=t.get("focusedValue").set({year:n[0]});ae(e,r)},focusLastYear(e){let{context:t}=e,n=rr(t.get("focusedValue").year),r=t.get("focusedValue").set({year:n[n.length-1]});ae(e,r)},setActiveIndex({context:e,event:t}){e.set("activeIndex",t.index)},setActiveIndexToEnd({context:e}){e.set("activeIndex",1)},setActiveIndexToStart({context:e}){e.set("activeIndex",0)},focusActiveCell({scope:e,context:t}){H(()=>{var r;let n=t.get("view");(r=Hc(e,n))==null||r.focus({preventScroll:!0})})},focusActiveCellIfNeeded({scope:e,context:t,event:n}){n.focus&&H(()=>{var i;let r=t.get("view");(i=Hc(e,r))==null||i.focus({preventScroll:!0})})},setHoveredValueIfKeyboard({context:e,event:t,prop:n}){!t.type.startsWith("TABLE.ARROW")||n("selectionMode")!=="range"||e.get("activeIndex")===0||e.set("hoveredValue",e.get("focusedValue").copy())},focusTriggerElement({scope:e}){H(()=>{var t;(t=Bc(e))==null||t.focus({preventScroll:!0})})},focusFirstInputElement({scope:e}){H(()=>{let[t]=Dr(e);t==null||t.focus({preventScroll:!0})})},focusInputElement({scope:e}){H(()=>{let t=Dr(e),n=t.findLastIndex(s=>s.value!==""),r=Math.max(n,0),i=t[r];i==null||i.focus({preventScroll:!0}),i==null||i.setSelectionRange(i.value.length,i.value.length)})},syncMonthSelectElement({scope:e,context:t}){let n=Fy(e);xt(n,t.get("startValue").month.toString())},syncYearSelectElement({scope:e,context:t}){let n=Ly(e);xt(n,t.get("startValue").year.toString())},setInputValue({context:e,event:t}){e.get("activeIndex")===t.index&&e.set("inputValue",t.value)},syncInputValue({scope:e,context:t,event:n}){queueMicrotask(()=>{var s;let r=Dr(e),i=(s=n.index)!=null?s:t.get("activeIndex");xt(r[i],t.get("inputValue"))})},focusParsedDate(e){let{event:t,prop:n}=e;if(t.index==null)return;let i=n("parse")(t.value,{locale:n("locale"),timeZone:n("timeZone")});!i||!Gc(i)||ae(e,i)},selectParsedDate({context:e,event:t,prop:n}){if(t.index==null)return;let i=n("parse")(t.value,{locale:n("locale"),timeZone:n("timeZone")});if((!i||!Gc(i))&&t.value&&(i=e.get("focusedValue").copy()),!i)return;i=lt(i,n("min"),n("max"));let s=Array.from(e.get("value"));s[t.index]=i,e.set("value",s);let o=Xi(s,n);e.set("inputValue",o[t.index])},resetView({context:e}){e.set("view",e.initial("view"))},setStartValue({context:e,computed:t,prop:n}){let r=e.get("focusedValue");if(!yt(r,e.get("startValue"),t("endValue")))return;let s=Dc(r,"start",{months:n("numOfMonths")},n("locale"));e.set("startValue",s)},invokeOnOpen({prop:e,context:t}){var n;e("inline")||(n=e("onOpenChange"))==null||n({open:!0,value:t.get("value")})},invokeOnClose({prop:e,context:t}){var n;e("inline")||(n=e("onOpenChange"))==null||n({open:!1,value:t.get("value")})},invokeOnVisibleRangeChange({prop:e,context:t,computed:n}){var r;(r=e("onVisibleRangeChange"))==null||r({view:t.get("view"),visibleRange:n("visibleRange")})},toggleVisibility({event:e,send:t,prop:n}){t({type:n("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:e})}}}},Qi=(e,t)=>{let{context:n,prop:r}=e,i=n.get("view"),s=typeof t=="number"?n.get("focusedValue").set({[i]:t}):t;return Zy(o=>{Ky(o,r("minView"))&&(s=s.set({[o]:o==="day"?1:0}))}),s};tb=G()(["closeOnSelect","dir","disabled","fixedWeeks","focusedValue","format","parse","placeholder","getRootNode","id","ids","inline","invalid","isDateUnavailable","locale","max","min","name","numOfMonths","onFocusChange","onOpenChange","onValueChange","onViewChange","onVisibleRangeChange","open","defaultOpen","positioning","readOnly","required","selectionMode","startOfWeek","timeZone","translations","value","defaultView","defaultValue","view","defaultFocusedValue","outsideDaySelectable","minView","maxView"]),CT=B(tb),nb=G()(["index","fixOnBlur"]),IT=B(nb),rb=G()(["value"]),TT=B(rb),ib=G()(["columns","id","view"]),OT=B(ib),sb=G()(["disabled","value","columns"]),ST=B(sb),ob=G()(["view"]),PT=B(ob),ab=class extends te{constructor(){super(...arguments);U(this,"getDayView",()=>this.el.querySelector('[data-part="day-view"]'));U(this,"getMonthView",()=>this.el.querySelector('[data-part="month-view"]'));U(this,"getYearView",()=>this.el.querySelector('[data-part="year-view"]'));U(this,"renderDayTableHeader",()=>{let t=this.getDayView(),n=t==null?void 0:t.querySelector("thead");if(!n||!this.api.weekDays)return;let r=this.doc.createElement("tr");this.spreadProps(r,this.api.getTableRowProps({view:"day"})),this.api.weekDays.forEach(i=>{let s=this.doc.createElement("th");s.scope="col",s.setAttribute("aria-label",i.long),s.textContent=i.narrow,r.appendChild(s)}),n.innerHTML="",n.appendChild(r)});U(this,"renderDayTableBody",()=>{let t=this.getDayView(),n=t==null?void 0:t.querySelector("tbody");n&&(this.spreadProps(n,this.api.getTableBodyProps({view:"day"})),this.api.weeks&&(n.innerHTML="",this.api.weeks.forEach(r=>{let i=this.doc.createElement("tr");this.spreadProps(i,this.api.getTableRowProps({view:"day"})),r.forEach(s=>{let o=this.doc.createElement("td");this.spreadProps(o,this.api.getDayTableCellProps({value:s}));let a=this.doc.createElement("div");this.spreadProps(a,this.api.getDayTableCellTriggerProps({value:s})),a.textContent=String(s.day),o.appendChild(a),i.appendChild(o)}),n.appendChild(i)})))});U(this,"renderMonthTableBody",()=>{let t=this.getMonthView(),n=t==null?void 0:t.querySelector("tbody");if(!n)return;this.spreadProps(n,this.api.getTableBodyProps({view:"month"}));let r=this.api.getMonthsGrid({columns:4,format:"short"});n.innerHTML="",r.forEach(i=>{let s=this.doc.createElement("tr");this.spreadProps(s,this.api.getTableRowProps()),i.forEach(o=>{let a=this.doc.createElement("td");this.spreadProps(a,this.api.getMonthTableCellProps(y(m({},o),{columns:4})));let l=this.doc.createElement("div");this.spreadProps(l,this.api.getMonthTableCellTriggerProps(y(m({},o),{columns:4}))),l.textContent=o.label,a.appendChild(l),s.appendChild(a)}),n.appendChild(s)})});U(this,"renderYearTableBody",()=>{let t=this.getYearView(),n=t==null?void 0:t.querySelector("tbody");if(!n)return;this.spreadProps(n,this.api.getTableBodyProps());let r=this.api.getYearsGrid({columns:4});n.innerHTML="",r.forEach(i=>{let s=this.doc.createElement("tr");this.spreadProps(s,this.api.getTableRowProps({view:"year"})),i.forEach(o=>{let a=this.doc.createElement("td");this.spreadProps(a,this.api.getYearTableCellProps(y(m({},o),{columns:4})));let l=this.doc.createElement("div");this.spreadProps(l,this.api.getYearTableCellTriggerProps(y(m({},o),{columns:4}))),l.textContent=o.label,a.appendChild(l),s.appendChild(a)}),n.appendChild(s)})})}initMachine(t){return new ee(eb,t)}initApi(){return zy(this.machine.service,Q)}render(){let t=this.el.querySelector('[data-scope="date-picker"][data-part="root"]');t&&this.spreadProps(t,this.api.getRootProps());let n=this.el.querySelector('[data-scope="date-picker"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps());let r=this.el.querySelector('[data-scope="date-picker"][data-part="control"]');r&&this.spreadProps(r,this.api.getControlProps());let i=this.el.querySelector('[data-scope="date-picker"][data-part="input"]');i&&this.spreadProps(i,this.api.getInputProps());let s=this.el.querySelector('[data-scope="date-picker"][data-part="trigger"]');s&&this.spreadProps(s,this.api.getTriggerProps());let o=this.el.querySelector('[data-scope="date-picker"][data-part="positioner"]');o&&this.spreadProps(o,this.api.getPositionerProps());let a=this.el.querySelector('[data-scope="date-picker"][data-part="content"]');if(a&&this.spreadProps(a,this.api.getContentProps()),this.api.open){let l=this.getDayView(),c=this.getMonthView(),u=this.getYearView();if(l&&(l.hidden=this.api.view!=="day"),c&&(c.hidden=this.api.view!=="month"),u&&(u.hidden=this.api.view!=="year"),this.api.view==="day"&&l){let h=l.querySelector('[data-part="view-control"]');h&&this.spreadProps(h,this.api.getViewControlProps({view:"year"}));let p=l.querySelector('[data-part="prev-trigger"]');p&&this.spreadProps(p,this.api.getPrevTriggerProps());let d=l.querySelector('[data-part="view-trigger"]');d&&(this.spreadProps(d,this.api.getViewTriggerProps()),d.textContent=this.api.visibleRangeText.start);let g=l.querySelector('[data-part="next-trigger"]');g&&this.spreadProps(g,this.api.getNextTriggerProps());let v=l.querySelector("table");v&&this.spreadProps(v,this.api.getTableProps({view:"day"}));let b=l.querySelector("thead");b&&this.spreadProps(b,this.api.getTableHeaderProps({view:"day"})),this.renderDayTableHeader(),this.renderDayTableBody()}else if(this.api.view==="month"&&c){let h=c.querySelector('[data-part="view-control"]');h&&this.spreadProps(h,this.api.getViewControlProps({view:"month"}));let p=c.querySelector('[data-part="prev-trigger"]');p&&this.spreadProps(p,this.api.getPrevTriggerProps({view:"month"}));let d=c.querySelector('[data-part="view-trigger"]');d&&(this.spreadProps(d,this.api.getViewTriggerProps({view:"month"})),d.textContent=String(this.api.visibleRange.start.year));let g=c.querySelector('[data-part="next-trigger"]');g&&this.spreadProps(g,this.api.getNextTriggerProps({view:"month"}));let v=c.querySelector("table");v&&this.spreadProps(v,this.api.getTableProps({view:"month",columns:4})),this.renderMonthTableBody()}else if(this.api.view==="year"&&u){let h=u.querySelector('[data-part="view-control"]');h&&this.spreadProps(h,this.api.getViewControlProps({view:"year"}));let p=u.querySelector('[data-part="prev-trigger"]');p&&this.spreadProps(p,this.api.getPrevTriggerProps({view:"year"}));let d=u.querySelector('[data-part="decade"]');if(d){let b=this.api.getDecade();d.textContent=`${b.start} - ${b.end}`}let g=u.querySelector('[data-part="next-trigger"]');g&&this.spreadProps(g,this.api.getNextTriggerProps({view:"year"}));let v=u.querySelector("table");v&&this.spreadProps(v,this.api.getTableProps({view:"year",columns:4})),this.renderYearTableBody()}}}};lb={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=this.liveSocket,r=x(e,"min"),i=x(e,"max"),s=x(e,"positioning"),o=u=>u?u.map(h=>Ze(h)):void 0,a=u=>u?Ze(u):void 0,l=new ab(e,y(m({id:e.id},O(e,"controlled")?{value:o(Y(e,"value"))}:{defaultValue:o(Y(e,"defaultValue"))}),{defaultFocusedValue:a(x(e,"focusedValue")),defaultView:x(e,"defaultView",["day","month","year"]),dir:x(e,"dir",["ltr","rtl"]),locale:x(e,"locale"),timeZone:x(e,"timeZone"),disabled:O(e,"disabled"),readOnly:O(e,"readOnly"),required:O(e,"required"),invalid:O(e,"invalid"),outsideDaySelectable:O(e,"outsideDaySelectable"),closeOnSelect:O(e,"closeOnSelect"),min:r?Ze(r):void 0,max:i?Ze(i):void 0,numOfMonths:Se(e,"numOfMonths"),startOfWeek:Se(e,"startOfWeek"),fixedWeeks:O(e,"fixedWeeks"),selectionMode:x(e,"selectionMode",["single","multiple","range"]),placeholder:x(e,"placeholder"),minView:x(e,"minView",["day","month","year"]),maxView:x(e,"maxView",["day","month","year"]),inline:O(e,"inline"),positioning:s?JSON.parse(s):void 0,onValueChange:u=>{var g;let h=(g=u.value)!=null&&g.length?u.value.map(v=>Uc(v)).join(","):"",p=e.querySelector(`#${e.id}-value`);p&&p.value!==h&&(p.value=h,p.dispatchEvent(new Event("input",{bubbles:!0})),p.dispatchEvent(new Event("change",{bubbles:!0})));let d=x(e,"onValueChange");d&&n.main.isConnected()&&t(d,{id:e.id,value:h||null})},onFocusChange:u=>{var p;let h=x(e,"onFocusChange");h&&n.main.isConnected()&&t(h,{id:e.id,focused:(p=u.focused)!=null?p:!1})},onViewChange:u=>{let h=x(e,"onViewChange");h&&n.main.isConnected()&&t(h,{id:e.id,view:u.view})},onVisibleRangeChange:u=>{let h=x(e,"onVisibleRangeChange");h&&n.main.isConnected()&&t(h,{id:e.id,start:u.start,end:u.end})},onOpenChange:u=>{let h=x(e,"onOpenChange");h&&n.main.isConnected()&&t(h,{id:e.id,open:u.open})}}));l.init(),this.datePicker=l;let c=e.querySelector('[data-scope="date-picker"][data-part="input-wrapper"]');c&&c.removeAttribute("data-loading"),this.handlers=[],this.handlers.push(this.handleEvent("date_picker_set_value",u=>{let h=u.date_picker_id;h&&h!==e.id||l.api.setValue([Ze(u.value)])})),this.onSetValue=u=>{var p;let h=(p=u.detail)==null?void 0:p.value;typeof h=="string"&&l.api.setValue([Ze(h)])},e.addEventListener("phx:date-picker:set-value",this.onSetValue)},updated(){var l,c;let e=this.el,t=e.querySelector('[data-scope="date-picker"][data-part="input-wrapper"]');t&&t.removeAttribute("data-loading");let n=u=>u?u.map(h=>Ze(h)):void 0,r=x(e,"min"),i=x(e,"max"),s=x(e,"positioning"),o=O(e,"controlled"),a=x(e,"focusedValue");if((l=this.datePicker)==null||l.updateProps(y(m({},O(e,"controlled")?{value:n(Y(e,"value"))}:{defaultValue:n(Y(e,"defaultValue"))}),{defaultFocusedValue:a?Ze(a):void 0,defaultView:x(e,"defaultView",["day","month","year"]),dir:x(this.el,"dir",["ltr","rtl"]),locale:x(this.el,"locale"),timeZone:x(this.el,"timeZone"),disabled:O(this.el,"disabled"),readOnly:O(this.el,"readOnly"),required:O(this.el,"required"),invalid:O(this.el,"invalid"),outsideDaySelectable:O(this.el,"outsideDaySelectable"),closeOnSelect:O(this.el,"closeOnSelect"),min:r?Ze(r):void 0,max:i?Ze(i):void 0,numOfMonths:Se(this.el,"numOfMonths"),startOfWeek:Se(this.el,"startOfWeek"),fixedWeeks:O(this.el,"fixedWeeks"),selectionMode:x(this.el,"selectionMode",["single","multiple","range"]),placeholder:x(this.el,"placeholder"),minView:x(this.el,"minView",["day","month","year"]),maxView:x(this.el,"maxView",["day","month","year"]),inline:O(this.el,"inline"),positioning:s?JSON.parse(s):void 0})),o&&this.datePicker){let u=Y(e,"value"),h=(c=u==null?void 0:u.join(","))!=null?c:"",p=this.datePicker.api.value,d=p!=null&&p.length?p.map(g=>Uc(g)).join(","):"";if(h!==d){let g=u!=null&&u.length?u.map(v=>Ze(v)):[];this.datePicker.api.setValue(g)}}},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:date-picker:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.datePicker)==null||e.destroy()}}});var Lu={};Oe(Lu,{Dialog:()=>_b});function mb(e,t={}){let{defer:n=!0}=t,r=n?pb:s=>s(),i=[];return i.push(r(()=>{let o=(typeof e=="function"?e():e).filter(Boolean);o.length!==0&&i.push(fb(o))})),()=>{i.forEach(s=>s==null?void 0:s())}}function Sb(e,t={}){let n,r=H(()=>{let s=(Array.isArray(e)?e:[e]).map(a=>typeof a=="function"?a():a).filter(a=>a!=null);if(s.length===0)return;let o=s[0];n=new Eb(s,y(m({escapeDeactivates:!1,allowOutsideClick:!0,preventScroll:!0,returnFocusOnDeactivate:!0,delayInitialFocus:!1,fallbackFocus:o},t),{document:we(o)}));try{n.activate()}catch(a){}});return function(){n==null||n.deactivate(),r()}}function Pb(e){let t=e.getBoundingClientRect().left;return Math.round(t)+e.scrollLeft?"paddingLeft":"paddingRight"}function xu(e){let t=qt(e),n=t==null?void 0:t.scrollbarGutter;return n==="stable"||(n==null?void 0:n.startsWith("stable "))===!0}function wb(e){var d;let t=e!=null?e:document,n=(d=t.defaultView)!=null?d:window,{documentElement:r,body:i}=t;if(i.hasAttribute(Ko))return;let o=xu(r)||xu(i),a=n.innerWidth-r.clientWidth;i.setAttribute(Ko,"");let l=()=>Qa(r,"--scrollbar-width",`${a}px`),c=Pb(r),u=()=>{let g={overflow:"hidden"};return!o&&a>0&&(g[c]=`${a}px`),cn(i,g)},h=()=>{var C,I;let{scrollX:g,scrollY:v,visualViewport:b}=n,V=(C=b==null?void 0:b.offsetLeft)!=null?C:0,S=(I=b==null?void 0:b.offsetTop)!=null?I:0,E={position:"fixed",overflow:"hidden",top:`${-(v-Math.floor(S))}px`,left:`${-(g-Math.floor(V))}px`,right:"0"};!o&&a>0&&(E[c]=`${a}px`);let f=cn(i,E);return()=>{f==null||f(),n.scrollTo({left:g,top:v,behavior:"instant"})}},p=[l(),br()?h():u()];return()=>{p.forEach(g=>g==null?void 0:g()),i.removeAttribute(Ko)}}function Lb(e,t){let{state:n,send:r,context:i,prop:s,scope:o}=e,a=s("aria-label"),l=n.matches("open");return{open:l,setOpen(c){n.matches("open")!==c&&r({type:c?"OPEN":"CLOSE"})},getTriggerProps(){return t.button(y(m({},Cn.trigger.attrs),{dir:s("dir"),id:Ru(o),"aria-haspopup":"dialog",type:"button","aria-expanded":l,"data-state":l?"open":"closed","aria-controls":Yo(o),onClick(c){c.defaultPrevented||r({type:"TOGGLE"})}}))},getBackdropProps(){return t.element(y(m({},Cn.backdrop.attrs),{dir:s("dir"),hidden:!l,id:Au(o),"data-state":l?"open":"closed"}))},getPositionerProps(){return t.element(y(m({},Cn.positioner.attrs),{dir:s("dir"),id:Nu(o),style:{pointerEvents:l?void 0:"none"}}))},getContentProps(){let c=i.get("rendered");return t.element(y(m({},Cn.content.attrs),{dir:s("dir"),role:s("role"),hidden:!l,id:Yo(o),tabIndex:-1,"data-state":l?"open":"closed","aria-modal":!0,"aria-label":a||void 0,"aria-labelledby":a||!c.title?void 0:jo(o),"aria-describedby":c.description?Xo(o):void 0}))},getTitleProps(){return t.element(y(m({},Cn.title.attrs),{dir:s("dir"),id:jo(o)}))},getDescriptionProps(){return t.element(y(m({},Cn.description.attrs),{dir:s("dir"),id:Xo(o)}))},getCloseTriggerProps(){return t.button(y(m({},Cn.closeTrigger.attrs),{dir:s("dir"),id:Du(o),type:"button",onClick(c){c.defaultPrevented||(c.stopPropagation(),r({type:"CLOSE"}))}}))}}}var ar,is,ss,qo,ku,cb,ub,db,hb,gb,fb,pb,vb,yb,le,wu,bb,Eb,Zo,Wo,Cb,Ib,_r,Tb,Vu,Ob,Ko,Vb,Cn,Nu,Au,Yo,Ru,jo,Xo,Du,os,xb,kb,Nb,Ab,Rb,Db,Fb,Mb,RT,$b,_b,Fu=fe(()=>{"use strict";gn();me();ar=new WeakMap,is=new WeakMap,ss={},qo=0,ku=e=>e&&(e.host||ku(e.parentNode)),cb=(e,t)=>t.map(n=>{if(e.contains(n))return n;let r=ku(n);return r&&e.contains(r)?r:(console.error("[zag-js > ariaHidden] target",n,"in not contained inside",e,". Doing nothing"),null)}).filter(n=>!!n),ub=new Set(["script","output","status","next-route-announcer"]),db=e=>ub.has(e.localName)||e.role==="status"||e.hasAttribute("aria-live")?!0:e.matches("[data-live-announcer]"),hb=(e,t)=>{let{parentNode:n,markerName:r,controlAttribute:i,followControlledElements:s=!0}=t,o=cb(n,Array.isArray(e)?e:[e]);ss[r]||(ss[r]=new WeakMap);let a=ss[r],l=[],c=new Set,u=new Set(o),h=d=>{!d||c.has(d)||(c.add(d),h(d.parentNode))};o.forEach(d=>{h(d),s&&ce(d)&&Ds(d,g=>{h(g)})});let p=d=>{!d||u.has(d)||Array.prototype.forEach.call(d.children,g=>{if(c.has(g))p(g);else try{if(db(g))return;let b=g.getAttribute(i)==="true",V=(ar.get(g)||0)+1,S=(a.get(g)||0)+1;ar.set(g,V),a.set(g,S),l.push(g),V===1&&b&&is.set(g,!0),S===1&&g.setAttribute(r,""),b||g.setAttribute(i,"true")}catch(v){console.error("[zag-js > ariaHidden] cannot operate on ",g,v)}})};return p(n),c.clear(),qo++,()=>{l.forEach(d=>{let g=ar.get(d)-1,v=a.get(d)-1;ar.set(d,g),a.set(d,v),g||(is.has(d)||d.removeAttribute(i),is.delete(d)),v||d.removeAttribute(r)}),qo--,qo||(ar=new WeakMap,ar=new WeakMap,is=new WeakMap,ss={})}},gb=e=>(Array.isArray(e)?e[0]:e).ownerDocument.body,fb=(e,t=gb(e),n="data-aria-hidden",r=!0)=>{if(t)return hb(e,{parentNode:t,markerName:n,controlAttribute:"aria-hidden",followControlledElements:r})},pb=e=>{let t=requestAnimationFrame(()=>e());return()=>cancelAnimationFrame(t)};vb=Object.defineProperty,yb=(e,t,n)=>t in e?vb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,le=(e,t,n)=>yb(e,typeof t!="symbol"?t+"":t,n),wu={activateTrap(e,t){if(e.length>0){let r=e[e.length-1];r!==t&&r.pause()}let n=e.indexOf(t);n===-1||e.splice(n,1),e.push(t)},deactivateTrap(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()}},bb=[],Eb=class{constructor(e,t){le(this,"trapStack"),le(this,"config"),le(this,"doc"),le(this,"state",{containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0}),le(this,"portalContainers",new Set),le(this,"listenerCleanups",[]),le(this,"handleFocus",r=>{let i=K(r),s=this.findContainerIndex(i,r)>=0;if(s||yr(i))s&&(this.state.mostRecentlyFocusedNode=i);else{r.stopImmediatePropagation();let o,a=!0;if(this.state.mostRecentlyFocusedNode)if(Dn(this.state.mostRecentlyFocusedNode)>0){let l=this.findContainerIndex(this.state.mostRecentlyFocusedNode),{tabbableNodes:c}=this.state.containerGroups[l];if(c.length>0){let u=c.findIndex(h=>h===this.state.mostRecentlyFocusedNode);u>=0&&(this.config.isKeyForward(this.state.recentNavEvent)?u+1=0&&(o=c[u-1],a=!1))}}else this.state.containerGroups.some(l=>l.tabbableNodes.some(c=>Dn(c)>0))||(a=!1);else a=!1;a&&(o=this.findNextNavNode({target:this.state.mostRecentlyFocusedNode,isBackward:this.config.isKeyBackward(this.state.recentNavEvent)})),o?this.tryFocus(o):this.tryFocus(this.state.mostRecentlyFocusedNode||this.getInitialFocusNode())}this.state.recentNavEvent=void 0}),le(this,"handlePointerDown",r=>{let i=K(r);if(!(this.findContainerIndex(i,r)>=0)){if(_r(this.config.clickOutsideDeactivates,r)){this.deactivate({returnFocus:this.config.returnFocusOnDeactivate});return}_r(this.config.allowOutsideClick,r)||r.preventDefault()}}),le(this,"handleClick",r=>{let i=K(r);this.findContainerIndex(i,r)>=0||_r(this.config.clickOutsideDeactivates,r)||_r(this.config.allowOutsideClick,r)||(r.preventDefault(),r.stopImmediatePropagation())}),le(this,"handleTabKey",r=>{if(this.config.isKeyForward(r)||this.config.isKeyBackward(r)){this.state.recentNavEvent=r;let i=this.config.isKeyBackward(r),s=this.findNextNavNode({event:r,isBackward:i});if(!s)return;Wo(r)&&r.preventDefault(),this.tryFocus(s)}}),le(this,"handleEscapeKey",r=>{Tb(r)&&_r(this.config.escapeDeactivates,r)!==!1&&(r.preventDefault(),this.deactivate())}),le(this,"_mutationObserver"),le(this,"setupMutationObserver",()=>{let r=this.doc.defaultView||window;this._mutationObserver=new r.MutationObserver(i=>{i.some(a=>Array.from(a.removedNodes).some(c=>c===this.state.mostRecentlyFocusedNode))&&this.tryFocus(this.getInitialFocusNode()),i.some(a=>a.type==="attributes"&&(a.attributeName==="aria-controls"||a.attributeName==="aria-expanded")?!0:a.type==="childList"&&a.addedNodes.length>0?Array.from(a.addedNodes).some(l=>{if(l.nodeType!==Node.ELEMENT_NODE)return!1;let c=l;return Ma(c)?!0:c.id&&!this.state.containers.some(u=>u.contains(c))?$a(c):!1}):!1)&&this.state.active&&!this.state.paused&&(this.updateTabbableNodes(),this.updatePortalContainers())})}),le(this,"updateObservedNodes",()=>{var r;(r=this._mutationObserver)==null||r.disconnect(),this.state.active&&!this.state.paused&&(this.state.containers.map(i=>{var s;(s=this._mutationObserver)==null||s.observe(i,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["aria-controls","aria-expanded"]})}),this.portalContainers.forEach(i=>{this.observePortalContainer(i)}))}),le(this,"getInitialFocusNode",()=>{let r=this.getNodeForOption("initialFocus",{hasFallback:!0});if(r===!1)return!1;if(r===void 0||r&&!Qe(r)){let i=kn(this.doc);if(i&&this.findContainerIndex(i)>=0)r=i;else{let s=this.state.tabbableGroups[0];r=s&&s.firstTabbableNode||this.getNodeForOption("fallbackFocus")}}else r===null&&(r=this.getNodeForOption("fallbackFocus"));if(!r)throw new Error("Your focus-trap needs to have at least one focusable element");return r.isConnected||(r=this.getNodeForOption("fallbackFocus")),r}),le(this,"tryFocus",r=>{if(r!==!1&&r!==kn(this.doc)){if(!r||!r.focus){this.tryFocus(this.getInitialFocusNode());return}r.focus({preventScroll:!!this.config.preventScroll}),this.state.mostRecentlyFocusedNode=r,Ob(r)&&r.select()}}),le(this,"deactivate",r=>{if(!this.state.active)return this;let i=m({onDeactivate:this.config.onDeactivate,onPostDeactivate:this.config.onPostDeactivate,checkCanReturnFocus:this.config.checkCanReturnFocus},r);clearTimeout(this.state.delayInitialFocusTimer),this.state.delayInitialFocusTimer=void 0,this.removeListeners(),this.state.active=!1,this.state.paused=!1,this.updateObservedNodes(),wu.deactivateTrap(this.trapStack,this),this.portalContainers.clear();let s=this.getOption(i,"onDeactivate"),o=this.getOption(i,"onPostDeactivate"),a=this.getOption(i,"checkCanReturnFocus"),l=this.getOption(i,"returnFocus","returnFocusOnDeactivate");s==null||s();let c=()=>{Vu(()=>{if(l){let u=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);this.tryFocus(u)}o==null||o()})};if(l&&a){let u=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);return a(u).then(c,c),this}return c(),this}),le(this,"pause",r=>{if(this.state.paused||!this.state.active)return this;let i=this.getOption(r,"onPause"),s=this.getOption(r,"onPostPause");return this.state.paused=!0,i==null||i(),this.removeListeners(),this.updateObservedNodes(),s==null||s(),this}),le(this,"unpause",r=>{if(!this.state.paused||!this.state.active)return this;let i=this.getOption(r,"onUnpause"),s=this.getOption(r,"onPostUnpause");return this.state.paused=!1,i==null||i(),this.updateTabbableNodes(),this.addListeners(),this.updateObservedNodes(),s==null||s(),this}),le(this,"updateContainerElements",r=>(this.state.containers=Array.isArray(r)?r.filter(Boolean):[r].filter(Boolean),this.state.active&&this.updateTabbableNodes(),this.updateObservedNodes(),this)),le(this,"getReturnFocusNode",r=>{let i=this.getNodeForOption("setReturnFocus",{params:[r]});return i||(i===!1?!1:r)}),le(this,"getOption",(r,i,s)=>r&&r[i]!==void 0?r[i]:this.config[s||i]),le(this,"getNodeForOption",(r,{hasFallback:i=!1,params:s=[]}={})=>{let o=this.config[r];if(typeof o=="function"&&(o=o(...s)),o===!0&&(o=void 0),!o){if(o===void 0||o===!1)return o;throw new Error(`\`${r}\` was specified but was not a node, or did not return a node`)}let a=o;if(typeof o=="string"){try{a=this.doc.querySelector(o)}catch(l){throw new Error(`\`${r}\` appears to be an invalid selector; error="${l.message}"`)}if(!a&&!i)throw new Error(`\`${r}\` as selector refers to no known node`)}return a}),le(this,"findNextNavNode",r=>{let{event:i,isBackward:s=!1}=r,o=r.target||K(i);this.updateTabbableNodes();let a=null;if(this.state.tabbableGroups.length>0){let l=this.findContainerIndex(o,i),c=l>=0?this.state.containerGroups[l]:void 0;if(l<0)s?a=this.state.tabbableGroups[this.state.tabbableGroups.length-1].lastTabbableNode:a=this.state.tabbableGroups[0].firstTabbableNode;else if(s){let u=this.state.tabbableGroups.findIndex(({firstTabbableNode:h})=>o===h);if(u<0&&((c==null?void 0:c.container)===o||Qe(o)&&!Bt(o)&&!(c!=null&&c.nextTabbableNode(o,!1)))&&(u=l),u>=0){let h=u===0?this.state.tabbableGroups.length-1:u-1,p=this.state.tabbableGroups[h];a=Dn(o)>=0?p.lastTabbableNode:p.lastDomTabbableNode}else Wo(i)||(a=c==null?void 0:c.nextTabbableNode(o,!1))}else{let u=this.state.tabbableGroups.findIndex(({lastTabbableNode:h})=>o===h);if(u<0&&((c==null?void 0:c.container)===o||Qe(o)&&!Bt(o)&&!(c!=null&&c.nextTabbableNode(o)))&&(u=l),u>=0){let h=u===this.state.tabbableGroups.length-1?0:u+1,p=this.state.tabbableGroups[h];a=Dn(o)>=0?p.firstTabbableNode:p.firstDomTabbableNode}else Wo(i)||(a=c==null?void 0:c.nextTabbableNode(o))}}else a=this.getNodeForOption("fallbackFocus");return a}),this.trapStack=t.trapStack||bb;let n=m({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,followControlledElements:!0,isKeyForward:Cb,isKeyBackward:Ib},t);this.doc=n.document||we(Array.isArray(e)?e[0]:e),this.config=n,this.updateContainerElements(e),this.setupMutationObserver()}addPortalContainer(e){let t=e.parentElement;t&&!this.portalContainers.has(t)&&(this.portalContainers.add(t),this.state.active&&!this.state.paused&&this.observePortalContainer(t))}observePortalContainer(e){var t;(t=this._mutationObserver)==null||t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["aria-controls","aria-expanded"]})}updatePortalContainers(){this.config.followControlledElements&&this.state.containers.forEach(e=>{Fa(e).forEach(n=>{this.addPortalContainer(n)})})}get active(){return this.state.active}get paused(){return this.state.paused}findContainerIndex(e,t){let n=typeof(t==null?void 0:t.composedPath)=="function"?t.composedPath():void 0;return this.state.containerGroups.findIndex(({container:r,tabbableNodes:i})=>r.contains(e)||(n==null?void 0:n.includes(r))||i.find(s=>s===e)||this.isControlledElement(r,e))}isControlledElement(e,t){return this.config.followControlledElements?li(e,t):!1}updateTabbableNodes(){if(this.state.containerGroups=this.state.containers.map(e=>{let t=on(e,{getShadowRoot:this.config.getShadowRoot}),n=Ir(e,{getShadowRoot:this.config.getShadowRoot}),r=t[0],i=t[t.length-1],s=r,o=i,a=!1;for(let c=0;c0){a=!0;break}function l(c,u=!0){let h=t.indexOf(c);if(h>=0)return t[h+(u?1:-1)];let p=n.indexOf(c);if(!(p<0)){if(u){for(let d=p+1;d=0;d--)if(Bt(n[d]))return n[d]}}return{container:e,tabbableNodes:t,focusableNodes:n,posTabIndexesFound:a,firstTabbableNode:r,lastTabbableNode:i,firstDomTabbableNode:s,lastDomTabbableNode:o,nextTabbableNode:l}}),this.state.tabbableGroups=this.state.containerGroups.filter(e=>e.tabbableNodes.length>0),this.state.tabbableGroups.length<=0&&!this.getNodeForOption("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(this.state.containerGroups.find(e=>e.posTabIndexesFound)&&this.state.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")}addListeners(){if(this.state.active)return wu.activateTrap(this.trapStack,this),this.state.delayInitialFocusTimer=this.config.delayInitialFocus?Vu(()=>{this.tryFocus(this.getInitialFocusNode())}):this.tryFocus(this.getInitialFocusNode()),this.listenerCleanups.push(ie(this.doc,"focusin",this.handleFocus,!0),ie(this.doc,"mousedown",this.handlePointerDown,{capture:!0,passive:!1}),ie(this.doc,"touchstart",this.handlePointerDown,{capture:!0,passive:!1}),ie(this.doc,"click",this.handleClick,{capture:!0,passive:!1}),ie(this.doc,"keydown",this.handleTabKey,{capture:!0,passive:!1}),ie(this.doc,"keydown",this.handleEscapeKey)),this}removeListeners(){if(this.state.active)return this.listenerCleanups.forEach(e=>e()),this.listenerCleanups=[],this}activate(e){if(this.state.active)return this;let t=this.getOption(e,"onActivate"),n=this.getOption(e,"onPostActivate"),r=this.getOption(e,"checkCanFocusTrap");r||this.updateTabbableNodes(),this.state.active=!0,this.state.paused=!1,this.state.nodeFocusedBeforeActivation=kn(this.doc),t==null||t();let i=()=>{r&&this.updateTabbableNodes(),this.addListeners(),this.updateObservedNodes(),n==null||n()};return r?(r(this.state.containers.concat()).then(i,i),this):(i(),this)}},Zo=e=>e.type==="keydown",Wo=e=>Zo(e)&&(e==null?void 0:e.key)==="Tab",Cb=e=>Zo(e)&&e.key==="Tab"&&!(e!=null&&e.shiftKey),Ib=e=>Zo(e)&&e.key==="Tab"&&(e==null?void 0:e.shiftKey),_r=(e,...t)=>typeof e=="function"?e(...t):e,Tb=e=>!e.isComposing&&e.key==="Escape",Vu=e=>setTimeout(e,0),Ob=e=>e.localName==="input"&&"select"in e&&typeof e.select=="function";Ko="data-scroll-lock";Vb=Z("dialog").parts("trigger","backdrop","positioner","content","title","description","closeTrigger"),Cn=Vb.build(),Nu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.positioner)!=null?n:`dialog:${e.id}:positioner`},Au=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.backdrop)!=null?n:`dialog:${e.id}:backdrop`},Yo=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`dialog:${e.id}:content`},Ru=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`dialog:${e.id}:trigger`},jo=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.title)!=null?n:`dialog:${e.id}:title`},Xo=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.description)!=null?n:`dialog:${e.id}:description`},Du=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.closeTrigger)!=null?n:`dialog:${e.id}:close`},os=e=>e.getById(Yo(e)),xb=e=>e.getById(Nu(e)),kb=e=>e.getById(Au(e)),Nb=e=>e.getById(Ru(e)),Ab=e=>e.getById(jo(e)),Rb=e=>e.getById(Xo(e)),Db=e=>e.getById(Du(e));Fb={props({props:e,scope:t}){let n=e.role==="alertdialog",r=n?()=>Db(t):void 0,i=typeof e.modal=="boolean"?e.modal:!0;return m({role:"dialog",modal:i,trapFocus:i,preventScroll:i,closeOnInteractOutside:!n,closeOnEscape:!0,restoreFocus:!0,initialFocusEl:r},e)},initialState({prop:e}){return e("open")||e("defaultOpen")?"open":"closed"},context({bindable:e}){return{rendered:e(()=>({defaultValue:{title:!0,description:!0}}))}},watch({track:e,action:t,prop:n}){e([()=>n("open")],()=>{t(["toggleVisibility"])})},states:{open:{entry:["checkRenderedElements","syncZIndex"],effects:["trackDismissableElement","trapFocus","preventScroll","hideContentBelow"],on:{"CONTROLLED.CLOSE":{target:"closed"},CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],TOGGLE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}]}},closed:{on:{"CONTROLLED.OPEN":{target:"open"},OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}],TOGGLE:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}]}}},implementations:{guards:{isOpenControlled:({prop:e})=>e("open")!=null},effects:{trackDismissableElement({scope:e,send:t,prop:n}){return vt(()=>os(e),{type:"dialog",defer:!0,pointerBlocking:n("modal"),exclude:[Nb(e)],onInteractOutside(i){var s;(s=n("onInteractOutside"))==null||s(i),n("closeOnInteractOutside")||i.preventDefault()},persistentElements:n("persistentElements"),onFocusOutside:n("onFocusOutside"),onPointerDownOutside:n("onPointerDownOutside"),onRequestDismiss:n("onRequestDismiss"),onEscapeKeyDown(i){var s;(s=n("onEscapeKeyDown"))==null||s(i),n("closeOnEscape")||i.preventDefault()},onDismiss(){t({type:"CLOSE",src:"interact-outside"})}})},preventScroll({scope:e,prop:t}){if(t("preventScroll"))return wb(e.getDoc())},trapFocus({scope:e,prop:t}){return t("trapFocus")?Sb(()=>os(e),{preventScroll:!0,returnFocusOnDeactivate:!!t("restoreFocus"),initialFocus:t("initialFocusEl"),setReturnFocus:r=>{var i,s;return(s=(i=t("finalFocusEl"))==null?void 0:i())!=null?s:r},getShadowRoot:!0}):void 0},hideContentBelow({scope:e,prop:t}){return t("modal")?mb(()=>[os(e)],{defer:!0}):void 0}},actions:{checkRenderedElements({context:e,scope:t}){H(()=>{e.set("rendered",{title:!!Ab(t),description:!!Rb(t)})})},syncZIndex({scope:e}){H(()=>{let t=os(e);if(!t)return;let n=qt(t);[xb(e),kb(e)].forEach(i=>{i==null||i.style.setProperty("--z-index",n.zIndex),i==null||i.style.setProperty("--layer-index",n.getPropertyValue("--layer-index"))})})},invokeOnClose({prop:e}){var t;(t=e("onOpenChange"))==null||t({open:!1})},invokeOnOpen({prop:e}){var t;(t=e("onOpenChange"))==null||t({open:!0})},toggleVisibility({prop:e,send:t,event:n}){t({type:e("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:n})}}}},Mb=G()(["aria-label","closeOnEscape","closeOnInteractOutside","dir","finalFocusEl","getRootNode","getRootNode","id","id","ids","initialFocusEl","modal","onEscapeKeyDown","onFocusOutside","onInteractOutside","onOpenChange","onPointerDownOutside","onRequestDismiss","defaultOpen","open","persistentElements","preventScroll","restoreFocus","role","trapFocus"]),RT=B(Mb),$b=class extends te{initMachine(e){return new ee(Fb,e)}initApi(){return Lb(this.machine.service,Q)}render(){let e=this.el,t=e.querySelector('[data-scope="dialog"][data-part="trigger"]');t&&this.spreadProps(t,this.api.getTriggerProps());let n=e.querySelector('[data-scope="dialog"][data-part="backdrop"]');n&&this.spreadProps(n,this.api.getBackdropProps());let r=e.querySelector('[data-scope="dialog"][data-part="positioner"]');r&&this.spreadProps(r,this.api.getPositionerProps());let i=e.querySelector('[data-scope="dialog"][data-part="content"]');i&&this.spreadProps(i,this.api.getContentProps());let s=e.querySelector('[data-scope="dialog"][data-part="title"]');s&&this.spreadProps(s,this.api.getTitleProps());let o=e.querySelector('[data-scope="dialog"][data-part="description"]');o&&this.spreadProps(o,this.api.getDescriptionProps());let a=e.querySelector('[data-scope="dialog"][data-part="close-trigger"]');a&&this.spreadProps(a,this.api.getCloseTriggerProps())}},_b={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=new $b(e,y(m({id:e.id},O(e,"controlled")?{open:O(e,"open")}:{defaultOpen:O(e,"defaultOpen")}),{modal:O(e,"modal"),closeOnInteractOutside:O(e,"closeOnInteractOutside"),closeOnEscape:O(e,"closeOnEscapeKeyDown"),preventScroll:O(e,"preventScroll"),restoreFocus:O(e,"restoreFocus"),dir:x(e,"dir",["ltr","rtl"]),onOpenChange:r=>{let i=x(e,"onOpenChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,open:r.open});let s=x(e,"onOpenChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,open:r.open}}))}}));n.init(),this.dialog=n,this.onSetOpen=r=>{let{open:i}=r.detail;n.api.setOpen(i)},e.addEventListener("phx:dialog:set-open",this.onSetOpen),this.handlers=[],this.handlers.push(this.handleEvent("dialog_set_open",r=>{let i=r.dialog_id;i&&i!==e.id||n.api.setOpen(r.open)})),this.handlers.push(this.handleEvent("dialog_open",()=>{this.pushEvent("dialog_open_response",{value:n.api.open})}))},updated(){var e;(e=this.dialog)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{open:O(this.el,"open")}:{defaultOpen:O(this.el,"defaultOpen")}),{modal:O(this.el,"modal"),closeOnInteractOutside:O(this.el,"closeOnInteractOutside"),closeOnEscape:O(this.el,"closeOnEscapeKeyDown"),preventScroll:O(this.el,"preventScroll"),restoreFocus:O(this.el,"restoreFocus"),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onSetOpen&&this.el.removeEventListener("phx:dialog:set-open",this.onSetOpen),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.dialog)==null||e.destroy()}}});var Wu={};Oe(Wu,{Menu:()=>cE});function Hb(e){let{x:t,y:n,width:r,height:i}=e,s=t+r/2,o=n+i/2;return{x:t,y:n,width:r,height:i,minX:t,minY:n,maxX:t+r,maxY:n+i,midX:s,midY:o,center:Hr(s,o)}}function Bb(e){let t=Hr(e.minX,e.minY),n=Hr(e.maxX,e.minY),r=Hr(e.maxX,e.maxY),i=Hr(e.minX,e.maxY);return{top:t,right:n,bottom:r,left:i}}function Gb(e,t){let n=Hb(e),{top:r,right:i,left:s,bottom:o}=Bb(n),[a]=t.split("-");return{top:[s,r,i,o],right:[r,i,o,s],bottom:[r,s,o,i],left:[i,r,s,o]}[a]}function Gu(e,t){let{x:n,y:r}=t,i=!1;for(let s=0,o=e.length-1;sr!=u>r&&n<(c-a)*(r-l)/(u-l)+a&&(i=!i)}return i}function zb(e,t){if(!e)return;let n=oe(e),r=new n.CustomEvent(zo,{detail:{value:t}});e.dispatchEvent(r)}function Qb(e,t){let{context:n,send:r,state:i,computed:s,prop:o,scope:a}=e,l=i.hasTag("open"),c=n.get("isSubmenu"),u=s("isTypingAhead"),h=o("composite"),p=n.get("currentPlacement"),d=n.get("anchorPoint"),g=n.get("highlightedValue"),v=Zt(y(m({},o("positioning")),{placement:d?"bottom":p}));function b(f){return{id:Br(a,f.value),disabled:!!f.disabled,highlighted:g===f.value}}function V(f){var I;let C=(I=f.valueText)!=null?I:f.value;return y(m({},f),{id:f.value,valueText:C})}function S(f){let C=b(V(f));return y(m({},C),{checked:!!f.checked})}function E(f){let{closeOnSelect:C,valueText:I,value:w}=f,A=b(f),P=Br(a,w);return t.element(y(m({},xe.item.attrs),{id:P,role:"menuitem","aria-disabled":re(A.disabled),"data-disabled":T(A.disabled),"data-ownedby":cr(a),"data-highlighted":T(A.highlighted),"data-value":w,"data-valuetext":I,onDragStart(N){N.currentTarget.matches("a[href]")&&N.preventDefault()},onPointerMove(N){if(A.disabled||N.pointerType!=="mouse")return;let R=N.currentTarget;if(A.highlighted)return;let L=Pt(N);r({type:"ITEM_POINTERMOVE",id:P,target:R,closeOnSelect:C,point:L})},onPointerLeave(N){var M;if(A.disabled||N.pointerType!=="mouse"||!((M=e.event.previous())==null?void 0:M.type.includes("POINTER")))return;let L=N.currentTarget;r({type:"ITEM_POINTERLEAVE",id:P,target:L,closeOnSelect:C})},onPointerDown(N){if(A.disabled)return;let R=N.currentTarget;r({type:"ITEM_POINTERDOWN",target:R,id:P,closeOnSelect:C})},onClick(N){if(Er(N)||sn(N)||A.disabled)return;let R=N.currentTarget;r({type:"ITEM_CLICK",target:R,id:P,closeOnSelect:C})}}))}return{highlightedValue:g,open:l,setOpen(f){i.hasTag("open")!==f&&r({type:f?"OPEN":"CLOSE"})},setHighlightedValue(f){r({type:"HIGHLIGHTED.SET",value:f})},setParent(f){r({type:"PARENT.SET",value:f,id:f.prop("id")})},setChild(f){r({type:"CHILD.SET",value:f,id:f.prop("id")})},reposition(f={}){r({type:"POSITIONING.SET",options:f})},addItemListener(f){let C=a.getById(f.id);if(!C)return;let I=()=>{var w;return(w=f.onSelect)==null?void 0:w.call(f)};return C.addEventListener(zo,I),()=>C.removeEventListener(zo,I)},getContextTriggerProps(){return t.element(y(m({},xe.contextTrigger.attrs),{dir:o("dir"),id:Uu(a),"data-state":l?"open":"closed",onPointerDown(f){if(f.pointerType==="mouse")return;let C=Pt(f);r({type:"CONTEXT_MENU_START",point:C})},onPointerCancel(f){f.pointerType!=="mouse"&&r({type:"CONTEXT_MENU_CANCEL"})},onPointerMove(f){f.pointerType!=="mouse"&&r({type:"CONTEXT_MENU_CANCEL"})},onPointerUp(f){f.pointerType!=="mouse"&&r({type:"CONTEXT_MENU_CANCEL"})},onContextMenu(f){let C=Pt(f);r({type:"CONTEXT_MENU",point:C}),f.preventDefault()},style:{WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"}}))},getTriggerItemProps(f){let C=f.getTriggerProps();return hl(E({value:C.id}),C)},getTriggerProps(){return t.button(y(m({},c?xe.triggerItem.attrs:xe.trigger.attrs),{"data-placement":n.get("currentPlacement"),type:"button",dir:o("dir"),id:cs(a),"data-uid":o("id"),"aria-haspopup":h?"menu":"dialog","aria-controls":cr(a),"data-controls":cr(a),"aria-expanded":l||void 0,"data-state":l?"open":"closed",onPointerMove(f){if(f.pointerType!=="mouse"||ls(f.currentTarget)||!c)return;let I=Pt(f);r({type:"TRIGGER_POINTERMOVE",target:f.currentTarget,point:I})},onPointerLeave(f){if(ls(f.currentTarget)||f.pointerType!=="mouse"||!c)return;let C=Pt(f);r({type:"TRIGGER_POINTERLEAVE",target:f.currentTarget,point:C})},onPointerDown(f){ls(f.currentTarget)||An(f)||f.preventDefault()},onClick(f){f.defaultPrevented||ls(f.currentTarget)||r({type:"TRIGGER_CLICK",target:f.currentTarget})},onBlur(){r({type:"TRIGGER_BLUR"})},onFocus(){r({type:"TRIGGER_FOCUS"})},onKeyDown(f){if(f.defaultPrevented)return;let C={ArrowDown(){r({type:"ARROW_DOWN"})},ArrowUp(){r({type:"ARROW_UP"})},Enter(){r({type:"ARROW_DOWN",src:"enter"})},Space(){r({type:"ARROW_DOWN",src:"space"})}},I=ve(f,{orientation:"vertical",dir:o("dir")}),w=C[I];w&&(f.preventDefault(),w(f))}}))},getIndicatorProps(){return t.element(y(m({},xe.indicator.attrs),{dir:o("dir"),"data-state":l?"open":"closed"}))},getPositionerProps(){return t.element(y(m({},xe.positioner.attrs),{dir:o("dir"),id:qu(a),style:v.floating}))},getArrowProps(){return t.element(y(m({id:qb(a)},xe.arrow.attrs),{dir:o("dir"),style:v.arrow}))},getArrowTipProps(){return t.element(y(m({},xe.arrowTip.attrs),{dir:o("dir"),style:v.arrowTip}))},getContentProps(){return t.element(y(m({},xe.content.attrs),{id:cr(a),"aria-label":o("aria-label"),hidden:!l,"data-state":l?"open":"closed",role:h?"menu":"dialog",tabIndex:0,dir:o("dir"),"aria-activedescendant":s("highlightedId")||void 0,"aria-labelledby":cs(a),"data-placement":p,onPointerEnter(f){f.pointerType==="mouse"&&r({type:"MENU_POINTERENTER"})},onKeyDown(f){if(f.defaultPrevented||!pe(f.currentTarget,K(f)))return;let C=K(f);if(!((C==null?void 0:C.closest("[role=menu]"))===f.currentTarget||C===f.currentTarget))return;if(f.key==="Tab"&&!gi(f)){f.preventDefault();return}let w={ArrowDown(){r({type:"ARROW_DOWN"})},ArrowUp(){r({type:"ARROW_UP"})},ArrowLeft(){r({type:"ARROW_LEFT"})},ArrowRight(){r({type:"ARROW_RIGHT"})},Enter(){r({type:"ENTER"})},Space(N){var R;u?r({type:"TYPEAHEAD",key:N.key}):(R=w.Enter)==null||R.call(w,N)},Home(){r({type:"HOME"})},End(){r({type:"END"})}},A=ve(f,{dir:o("dir")}),P=w[A];if(P){P(f),f.stopPropagation(),f.preventDefault();return}o("typeahead")&&Ba(f)&&(Fe(f)||Ut(C)||(r({type:"TYPEAHEAD",key:f.key}),f.preventDefault()))}}))},getSeparatorProps(){return t.element(y(m({},xe.separator.attrs),{role:"separator",dir:o("dir"),"aria-orientation":"horizontal"}))},getItemState:b,getItemProps:E,getOptionItemState:S,getOptionItemProps(f){let{type:C,disabled:I,closeOnSelect:w}=f,A=V(f),P=S(f);return m(m({},E(A)),t.element(y(m({"data-type":C},xe.item.attrs),{dir:o("dir"),"data-value":A.value,role:`menuitem${C}`,"aria-checked":!!P.checked,"data-state":P.checked?"checked":"unchecked",onClick(N){if(I||Er(N)||sn(N))return;let R=N.currentTarget;r({type:"ITEM_CLICK",target:R,option:A,closeOnSelect:w})}})))},getItemIndicatorProps(f){let C=S(Ys(f)),I=C.checked?"checked":"unchecked";return t.element(y(m({},xe.itemIndicator.attrs),{dir:o("dir"),"data-disabled":T(C.disabled),"data-highlighted":T(C.highlighted),"data-state":Me(f,"checked")?I:void 0,hidden:Me(f,"checked")?!C.checked:void 0}))},getItemTextProps(f){let C=S(Ys(f)),I=C.checked?"checked":"unchecked";return t.element(y(m({},xe.itemText.attrs),{dir:o("dir"),"data-disabled":T(C.disabled),"data-highlighted":T(C.highlighted),"data-state":Me(f,"checked")?I:void 0}))},getItemGroupLabelProps(f){return t.element(y(m({},xe.itemGroupLabel.attrs),{id:Mu(a,f.htmlFor),dir:o("dir")}))},getItemGroupProps(f){return t.element(y(m({id:Wb(a,f.id)},xe.itemGroup.attrs),{dir:o("dir"),"aria-labelledby":Mu(a,f.id),role:"group"}))}}}function Hu(e){let t=e.parent;for(;t&&t.context.get("isSubmenu");)t=t.refs.get("parent");t==null||t.send({type:"CLOSE"})}function nE(e,t){return e?Gu(e,t):!1}function rE(e,t,n){let r=Object.keys(e).length>0;if(!t)return null;if(!r)return Br(n,t);for(let i in e){let s=e[i],o=cs(s.scope);if(o===t)return o}return Br(n,t)}var Hr,HT,BT,GT,UT,qT,Ub,xe,cs,Uu,cr,qb,qu,Wb,Br,In,Mu,_t,$u,as,Kb,Jo,Gr,Yb,jb,Qo,Xb,Zb,Jb,ls,_u,zo,Je,lr,eE,tE,iE,WT,sE,KT,oE,YT,aE,jT,lE,XT,Bu,cE,Ku=fe(()=>{"use strict";Nr();gn();me();Hr=(e,t)=>({x:e,y:t});({min:HT,max:BT}=Math);({sign:GT,abs:UT,min:qT}=Math),Ub=Z("menu").parts("arrow","arrowTip","content","contextTrigger","indicator","item","itemGroup","itemGroupLabel","itemIndicator","itemText","positioner","separator","trigger","triggerItem"),xe=Ub.build(),cs=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`menu:${e.id}:trigger`},Uu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.contextTrigger)!=null?n:`menu:${e.id}:ctx-trigger`},cr=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`menu:${e.id}:content`},qb=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.arrow)!=null?n:`menu:${e.id}:arrow`},qu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.positioner)!=null?n:`menu:${e.id}:popper`},Wb=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.group)==null?void 0:r.call(n,t))!=null?i:`menu:${e.id}:group:${t}`},Br=(e,t)=>`${e.id}/${t}`,In=e=>{var t;return(t=e==null?void 0:e.dataset.value)!=null?t:null},Mu=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.groupLabel)==null?void 0:r.call(n,t))!=null?i:`menu:${e.id}:group-label:${t}`},_t=e=>e.getById(cr(e)),$u=e=>e.getById(qu(e)),as=e=>e.getById(cs(e)),Kb=(e,t)=>t?e.getById(Br(e,t)):null,Jo=e=>e.getById(Uu(e)),Gr=e=>{let n=`[role^="menuitem"][data-ownedby=${CSS.escape(cr(e))}]:not([data-disabled])`;return dt(_t(e),n)},Yb=e=>Ke(Gr(e)),jb=e=>nt(Gr(e)),Qo=(e,t)=>t?e.id===t||e.dataset.value===t:!1,Xb=(e,t)=>{var i;let n=Gr(e),r=n.findIndex(s=>Qo(s,t.value));return rl(n,r,{loop:(i=t.loop)!=null?i:t.loopFocus})},Zb=(e,t)=>{var i;let n=Gr(e),r=n.findIndex(s=>Qo(s,t.value));return il(n,r,{loop:(i=t.loop)!=null?i:t.loopFocus})},Jb=(e,t)=>{var i;let n=Gr(e),r=n.find(s=>Qo(s,t.value));return tt(n,{state:t.typeaheadState,key:t.key,activeId:(i=r==null?void 0:r.id)!=null?i:null})},ls=e=>ce(e)&&(e.dataset.disabled===""||e.hasAttribute("disabled")),_u=e=>{var t;return!!((t=e==null?void 0:e.getAttribute("role"))!=null&&t.startsWith("menuitem"))&&!!(e!=null&&e.hasAttribute("data-controls"))},zo="menu:select";({not:Je,and:lr,or:eE}=ye()),tE={props({props:e}){return y(m({closeOnSelect:!0,typeahead:!0,composite:!0,loopFocus:!1,navigate(t){Fn(t.node)}},e),{positioning:m({placement:"bottom-start",gutter:8},e.positioning)})},initialState({prop:e}){return e("open")||e("defaultOpen")?"open":"idle"},context({bindable:e,prop:t}){return{suspendPointer:e(()=>({defaultValue:!1})),highlightedValue:e(()=>({defaultValue:t("defaultHighlightedValue")||null,value:t("highlightedValue"),onChange(n){var r;(r=t("onHighlightChange"))==null||r({highlightedValue:n})}})),lastHighlightedValue:e(()=>({defaultValue:null})),currentPlacement:e(()=>({defaultValue:void 0})),intentPolygon:e(()=>({defaultValue:null})),anchorPoint:e(()=>({defaultValue:null,hash(n){return`x: ${n==null?void 0:n.x}, y: ${n==null?void 0:n.y}`}})),isSubmenu:e(()=>({defaultValue:!1}))}},refs(){return{parent:null,children:{},typeaheadState:m({},tt.defaultOptions),positioningOverride:{}}},computed:{isRtl:({prop:e})=>e("dir")==="rtl",isTypingAhead:({refs:e})=>e.get("typeaheadState").keysSoFar!=="",highlightedId:({context:e,scope:t,refs:n})=>rE(n.get("children"),e.get("highlightedValue"),t)},watch({track:e,action:t,context:n,prop:r}){e([()=>n.get("isSubmenu")],()=>{t(["setSubmenuPlacement"])}),e([()=>n.hash("anchorPoint")],()=>{n.get("anchorPoint")&&t(["reposition"])}),e([()=>r("open")],()=>{t(["toggleVisibility"])})},on:{"PARENT.SET":{actions:["setParentMenu"]},"CHILD.SET":{actions:["setChildMenu"]},OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}],OPEN_AUTOFOCUS:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["highlightFirstItem","invokeOnOpen"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],"HIGHLIGHTED.RESTORE":{actions:["restoreHighlightedItem"]},"HIGHLIGHTED.SET":{actions:["setHighlightedItem"]}},states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed"},CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}],TRIGGER_FOCUS:{guard:Je("isSubmenu"),target:"closed"},TRIGGER_POINTERMOVE:{guard:"isSubmenu",target:"opening"}}},"opening:contextmenu":{tags:["closed"],effects:["waitForLongPress"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed"},CONTEXT_MENU_CANCEL:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],"LONG_PRESS.OPEN":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}]}},opening:{tags:["closed"],effects:["waitForOpenDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed"},BLUR:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],TRIGGER_POINTERLEAVE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],"DELAY.OPEN":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}]}},closing:{tags:["open"],effects:["trackPointerMove","trackInteractOutside","waitForCloseDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]},MENU_POINTERENTER:{target:"open",actions:["clearIntentPolygon"]},POINTER_MOVED_AWAY_FROM_SUBMENU:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]}],"DELAY.CLOSE":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem","invokeOnClose"]}]}},closed:{tags:["closed"],entry:["clearHighlightedItem","focusTrigger","resumePointer","clearAnchorPoint"],on:{"CONTROLLED.OPEN":[{guard:eE("isOpenAutoFocusEvent","isArrowDownEvent"),target:"open",actions:["highlightFirstItem"]},{guard:"isArrowUpEvent",target:"open",actions:["highlightLastItem"]},{target:"open"}],CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",target:"opening"},TRIGGER_BLUR:{target:"idle"},ARROW_DOWN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["highlightFirstItem","invokeOnOpen"]}],ARROW_UP:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["highlightLastItem","invokeOnOpen"]}]}},open:{tags:["open"],effects:["trackInteractOutside","trackPositioning","scrollToHighlightedItem"],entry:["focusMenu","resumePointer"],on:{"CONTROLLED.CLOSE":[{target:"closed",guard:"isArrowLeftEvent",actions:["focusParentMenu"]},{target:"closed"}],TRIGGER_CLICK:[{guard:lr(Je("isTriggerItem"),"isOpenControlled"),actions:["invokeOnClose"]},{guard:Je("isTriggerItem"),target:"closed",actions:["invokeOnClose"]}],CONTEXT_MENU:{actions:["setAnchorPoint","focusMenu"]},ARROW_UP:{actions:["highlightPrevItem","focusMenu"]},ARROW_DOWN:{actions:["highlightNextItem","focusMenu"]},ARROW_LEFT:[{guard:lr("isSubmenu","isOpenControlled"),actions:["invokeOnClose"]},{guard:"isSubmenu",target:"closed",actions:["focusParentMenu","invokeOnClose"]}],HOME:{actions:["highlightFirstItem","focusMenu"]},END:{actions:["highlightLastItem","focusMenu"]},ARROW_RIGHT:{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},ENTER:[{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},{actions:["clickHighlightedItem"]}],ITEM_POINTERMOVE:[{guard:Je("isPointerSuspended"),actions:["setHighlightedItem","focusMenu","closeSiblingMenus"]},{actions:["setLastHighlightedItem","closeSiblingMenus"]}],ITEM_POINTERLEAVE:{guard:lr(Je("isPointerSuspended"),Je("isTriggerItem")),actions:["clearHighlightedItem"]},ITEM_CLICK:[{guard:lr(Je("isTriggerItemHighlighted"),Je("isHighlightedItemEditable"),"closeOnSelect","isOpenControlled"),actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose"]},{guard:lr(Je("isTriggerItemHighlighted"),Je("isHighlightedItemEditable"),"closeOnSelect"),target:"closed",actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose"]},{guard:lr(Je("isTriggerItemHighlighted"),Je("isHighlightedItemEditable")),actions:["invokeOnSelect","setOptionState"]},{actions:["setHighlightedItem"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",actions:["setIntentPolygon"]},TRIGGER_POINTERLEAVE:{target:"closing",actions:["setIntentPolygon"]},ITEM_POINTERDOWN:{actions:["setHighlightedItem"]},TYPEAHEAD:{actions:["highlightMatchedItem"]},FOCUS_MENU:{actions:["focusMenu"]},"POSITIONING.SET":{actions:["reposition"]}}}},implementations:{guards:{closeOnSelect:({prop:e,event:t})=>{var n;return!!((n=t==null?void 0:t.closeOnSelect)!=null?n:e("closeOnSelect"))},isTriggerItem:({event:e})=>_u(e.target),isTriggerItemHighlighted:({event:e,scope:t,computed:n})=>{var i;let r=(i=e.target)!=null?i:t.getById(n("highlightedId"));return!!(r!=null&&r.hasAttribute("data-controls"))},isSubmenu:({context:e})=>e.get("isSubmenu"),isPointerSuspended:({context:e})=>e.get("suspendPointer"),isHighlightedItemEditable:({scope:e,computed:t})=>Ut(e.getById(t("highlightedId"))),isOpenControlled:({prop:e})=>e("open")!==void 0,isArrowLeftEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="ARROW_LEFT"},isArrowUpEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="ARROW_UP"},isArrowDownEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="ARROW_DOWN"},isOpenAutoFocusEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="OPEN_AUTOFOCUS"}},effects:{waitForOpenDelay({send:e}){let t=setTimeout(()=>{e({type:"DELAY.OPEN"})},200);return()=>clearTimeout(t)},waitForCloseDelay({send:e}){let t=setTimeout(()=>{e({type:"DELAY.CLOSE"})},100);return()=>clearTimeout(t)},waitForLongPress({send:e}){let t=setTimeout(()=>{e({type:"LONG_PRESS.OPEN"})},700);return()=>clearTimeout(t)},trackPositioning({context:e,prop:t,scope:n,refs:r}){if(Jo(n))return;let i=m(m({},t("positioning")),r.get("positioningOverride"));e.set("currentPlacement",i.placement);let s=()=>$u(n);return at(as(n),s,y(m({},i),{defer:!0,onComplete(o){e.set("currentPlacement",o.placement)}}))},trackInteractOutside({refs:e,scope:t,prop:n,context:r,send:i}){let s=()=>_t(t),o=!0;return vt(s,{type:"menu",defer:!0,exclude:[as(t)],onInteractOutside:n("onInteractOutside"),onRequestDismiss:n("onRequestDismiss"),onFocusOutside(a){var u;(u=n("onFocusOutside"))==null||u(a);let l=K(a.detail.originalEvent);if(pe(Jo(t),l)){a.preventDefault();return}},onEscapeKeyDown(a){var l;(l=n("onEscapeKeyDown"))==null||l(a),r.get("isSubmenu")&&a.preventDefault(),Hu({parent:e.get("parent")})},onPointerDownOutside(a){var u;(u=n("onPointerDownOutside"))==null||u(a);let l=K(a.detail.originalEvent);if(pe(Jo(t),l)&&a.detail.contextmenu){a.preventDefault();return}o=!a.detail.focusable},onDismiss(){i({type:"CLOSE",src:"interact-outside",restoreFocus:o})}})},trackPointerMove({context:e,scope:t,send:n,refs:r,flush:i}){let s=r.get("parent");i(()=>{s.context.set("suspendPointer",!0)});let o=t.getDoc();return ie(o,"pointermove",a=>{nE(e.get("intentPolygon"),{x:a.clientX,y:a.clientY})||(n({type:"POINTER_MOVED_AWAY_FROM_SUBMENU"}),s.context.set("suspendPointer",!1))})},scrollToHighlightedItem({event:e,scope:t,computed:n}){let r=()=>{if(e.current().type.startsWith("ITEM_POINTER"))return;let s=t.getById(n("highlightedId")),o=_t(t);ln(s,{rootEl:o,block:"nearest"})};return H(()=>r()),Ln(()=>_t(t),{defer:!0,attributes:["aria-activedescendant"],callback:r})}},actions:{setAnchorPoint({context:e,event:t}){e.set("anchorPoint",n=>he(n,t.point)?n:t.point)},setSubmenuPlacement({context:e,computed:t,refs:n}){if(!e.get("isSubmenu"))return;let r=t("isRtl")?"left-start":"right-start";n.set("positioningOverride",{placement:r,gutter:0})},reposition({context:e,scope:t,prop:n,event:r,refs:i}){var c;let s=()=>$u(t),o=e.get("anchorPoint"),a=o?()=>m({width:0,height:0},o):void 0,l=m(m({},n("positioning")),i.get("positioningOverride"));at(as(t),s,y(m(y(m({},l),{defer:!0,getAnchorRect:a}),(c=r.options)!=null?c:{}),{listeners:!1,onComplete(u){e.set("currentPlacement",u.placement)}}))},setOptionState({event:e}){if(!e.option)return;let{checked:t,onCheckedChange:n,type:r}=e.option;r==="radio"?n==null||n(!0):r==="checkbox"&&(n==null||n(!t))},clickHighlightedItem({scope:e,computed:t,prop:n,context:r}){var o;let i=e.getById(t("highlightedId"));if(!i||i.dataset.disabled)return;let s=r.get("highlightedValue");We(i)?(o=n("navigate"))==null||o({value:s,node:i,href:i.href}):queueMicrotask(()=>i.click())},setIntentPolygon({context:e,scope:t,event:n}){let r=_t(t),i=e.get("currentPlacement");if(!r||!i)return;let s=r.getBoundingClientRect(),o=Gb(s,i);if(!o)return;let l=ac(i)==="right"?-5:5;e.set("intentPolygon",[y(m({},n.point),{x:n.point.x+l}),...o])},clearIntentPolygon({context:e}){e.set("intentPolygon",null)},clearAnchorPoint({context:e}){e.set("anchorPoint",null)},resumePointer({refs:e,flush:t}){let n=e.get("parent");n&&t(()=>{n.context.set("suspendPointer",!1)})},setHighlightedItem({context:e,event:t}){let n=t.value||In(t.target);e.set("highlightedValue",n)},clearHighlightedItem({context:e}){e.set("highlightedValue",null)},focusMenu({scope:e}){H(()=>{let t=_t(e),n=hi({root:t,enabled:!pe(t,e.getActiveElement()),filter(r){var i;return!((i=r.role)!=null&&i.startsWith("menuitem"))}});n==null||n.focus({preventScroll:!0})})},highlightFirstItem({context:e,scope:t}){(_t(t)?queueMicrotask:H)(()=>{let r=Yb(t);r&&e.set("highlightedValue",In(r))})},highlightLastItem({context:e,scope:t}){(_t(t)?queueMicrotask:H)(()=>{let r=jb(t);r&&e.set("highlightedValue",In(r))})},highlightNextItem({context:e,scope:t,event:n,prop:r}){let i=Xb(t,{loop:n.loop,value:e.get("highlightedValue"),loopFocus:r("loopFocus")});e.set("highlightedValue",In(i))},highlightPrevItem({context:e,scope:t,event:n,prop:r}){let i=Zb(t,{loop:n.loop,value:e.get("highlightedValue"),loopFocus:r("loopFocus")});e.set("highlightedValue",In(i))},invokeOnSelect({context:e,prop:t,scope:n}){var s;let r=e.get("highlightedValue");if(r==null)return;let i=Kb(n,r);zb(i,r),(s=t("onSelect"))==null||s({value:r})},focusTrigger({scope:e,context:t,event:n}){t.get("isSubmenu")||t.get("anchorPoint")||n.restoreFocus===!1||queueMicrotask(()=>{var r;return(r=as(e))==null?void 0:r.focus({preventScroll:!0})})},highlightMatchedItem({scope:e,context:t,event:n,refs:r}){let i=Jb(e,{key:n.key,value:t.get("highlightedValue"),typeaheadState:r.get("typeaheadState")});i&&t.set("highlightedValue",In(i))},setParentMenu({refs:e,event:t,context:n}){e.set("parent",t.value),n.set("isSubmenu",!0)},setChildMenu({refs:e,event:t}){let n=e.get("children");n[t.id]=t.value,e.set("children",n)},closeSiblingMenus({refs:e,event:t,scope:n}){var o;let r=t.target;if(!_u(r))return;let i=r==null?void 0:r.getAttribute("data-uid"),s=e.get("children");for(let a in s){if(a===i)continue;let l=s[a],c=l.context.get("intentPolygon");c&&t.point&&Gu(c,t.point)||((o=_t(n))==null||o.focus({preventScroll:!0}),l.send({type:"CLOSE"}))}},closeRootMenu({refs:e}){Hu({parent:e.get("parent")})},openSubmenu({refs:e,scope:t,computed:n}){let r=t.getById(n("highlightedId")),i=r==null?void 0:r.getAttribute("data-uid"),s=e.get("children"),o=i?s[i]:null;o==null||o.send({type:"OPEN_AUTOFOCUS"})},focusParentMenu({refs:e}){var t;(t=e.get("parent"))==null||t.send({type:"FOCUS_MENU"})},setLastHighlightedItem({context:e,event:t}){e.set("lastHighlightedValue",In(t.target))},restoreHighlightedItem({context:e}){e.get("lastHighlightedValue")&&(e.set("highlightedValue",e.get("lastHighlightedValue")),e.set("lastHighlightedValue",null))},restoreParentHighlightedItem({refs:e}){var t;(t=e.get("parent"))==null||t.send({type:"HIGHLIGHTED.RESTORE"})},invokeOnOpen({prop:e}){var t;(t=e("onOpenChange"))==null||t({open:!0})},invokeOnClose({prop:e}){var t;(t=e("onOpenChange"))==null||t({open:!1})},toggleVisibility({prop:e,event:t,send:n}){n({type:e("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:t})}}}};iE=G()(["anchorPoint","aria-label","closeOnSelect","composite","defaultHighlightedValue","defaultOpen","dir","getRootNode","highlightedValue","id","ids","loopFocus","navigate","onEscapeKeyDown","onFocusOutside","onHighlightChange","onInteractOutside","onOpenChange","onPointerDownOutside","onRequestDismiss","onSelect","open","positioning","typeahead"]),WT=B(iE),sE=G()(["closeOnSelect","disabled","value","valueText"]),KT=B(sE),oE=G()(["htmlFor"]),YT=B(oE),aE=G()(["id"]),jT=B(aE),lE=G()(["checked","closeOnSelect","disabled","onCheckedChange","type","value","valueText"]),XT=B(lE),Bu=class extends te{constructor(){super(...arguments);U(this,"children",[])}initMachine(t){return new ee(tE,t)}initApi(){return Qb(this.machine.service,Q)}setChild(t){this.api.setChild(t.machine.service),this.children.includes(t)||this.children.push(t)}setParent(t){this.api.setParent(t.machine.service)}isOwnElement(t){return t.closest('[phx-hook="Menu"]')===this.el}renderSubmenuTriggers(){let t=this.el.querySelector('[data-scope="menu"][data-part="content"]');if(!t)return;let n=t.querySelectorAll('[data-scope="menu"][data-nested-menu]');for(let r of n){if(!this.isOwnElement(r))continue;let i=r.dataset.nestedMenu;if(!i)continue;let s=this.children.find(a=>a.el.id===`menu:${i}`);if(!s)continue;let o=()=>{let a=this.api.getTriggerItemProps(s.api);this.spreadProps(r,a)};o(),this.machine.subscribe(o),s.machine.subscribe(o)}}render(){let t=this.el.querySelector('[data-scope="menu"][data-part="trigger"]');t&&this.spreadProps(t,this.api.getTriggerProps());let n=this.el.querySelector('[data-scope="menu"][data-part="positioner"]'),r=this.el.querySelector('[data-scope="menu"][data-part="content"]');n&&r&&(this.spreadProps(n,this.api.getPositionerProps()),this.spreadProps(r,this.api.getContentProps()),n.hidden=!this.api.open,this.api.open&&(r.querySelectorAll('[data-scope="menu"][data-part="item"]').forEach(c=>{if(!this.isOwnElement(c))return;let u=c.dataset.value;if(u){let h=c.hasAttribute("data-disabled");this.spreadProps(c,this.api.getItemProps({value:u,disabled:h||void 0}))}}),r.querySelectorAll('[data-scope="menu"][data-part="option-item"]').forEach(c=>{if(!this.isOwnElement(c))return;let u=c.dataset.value,h=c.dataset.type;if(u&&h){let p=c.hasAttribute("data-checked"),d=c.hasAttribute("data-disabled");this.spreadProps(c,this.api.getOptionItemProps({value:u,type:h,checked:p,disabled:d||void 0}))}}),r.querySelectorAll('[data-scope="menu"][data-part="item-group"]').forEach(c=>{if(!this.isOwnElement(c))return;let u=c.id;u&&this.spreadProps(c,this.api.getItemGroupProps({id:u}))}),r.querySelectorAll('[data-scope="menu"][data-part="separator"]').forEach(c=>{this.isOwnElement(c)&&this.spreadProps(c,this.api.getSeparatorProps())})));let i=this.el.querySelector('[data-scope="menu"][data-part="indicator"]');i&&this.spreadProps(i,this.api.getIndicatorProps())}},cE={mounted(){let e=this.el;if(e.hasAttribute("data-nested"))return;let t=new Bu(e,y(m({id:e.id.replace("menu:","")},O(e,"controlled")?{open:O(e,"open")}:{defaultOpen:O(e,"defaultOpen")}),{closeOnSelect:O(e,"closeOnSelect"),loopFocus:O(e,"loopFocus"),typeahead:O(e,"typeahead"),composite:O(e,"composite"),dir:x(e,"dir",["ltr","rtl"]),onSelect:i=>{var p,d;let s=O(e,"redirect"),o=[...e.querySelectorAll('[data-scope="menu"][data-part="item"]')].find(g=>g.getAttribute("data-value")===i.value),a=o==null?void 0:o.getAttribute("data-redirect"),l=o==null?void 0:o.hasAttribute("data-new-tab");s&&i.value&&!this.liveSocket.main.isConnected()&&a!=="false"&&(l?window.open(i.value,"_blank","noopener,noreferrer"):window.location.href=i.value);let u=x(e,"onSelect");u&&this.liveSocket.main.isConnected()&&this.pushEvent(u,{id:e.id,value:(p=i.value)!=null?p:null});let h=x(e,"onSelectClient");h&&e.dispatchEvent(new CustomEvent(h,{bubbles:!0,detail:{id:e.id,value:(d=i.value)!=null?d:null}}))},onOpenChange:i=>{var a,l;let s=x(e,"onOpenChange");s&&this.liveSocket.main.isConnected()&&this.pushEvent(s,{id:e.id,open:(a=i.open)!=null?a:!1});let o=x(e,"onOpenChangeClient");o&&e.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:{id:e.id,open:(l=i.open)!=null?l:!1}}))}}));t.init(),this.menu=t,this.nestedMenus=new Map;let n=e.querySelectorAll('[data-scope="menu"][data-nested="menu"]'),r=[];n.forEach(i=>{var o;let s=i.id;if(s){let a=s.replace("menu:",""),l=new Bu(i,{id:a,dir:x(i,"dir",["ltr","rtl"]),closeOnSelect:O(i,"closeOnSelect"),loopFocus:O(i,"loopFocus"),typeahead:O(i,"typeahead"),composite:O(i,"composite")});l.init(),(o=this.nestedMenus)==null||o.set(s,l),r.push(l)}}),setTimeout(()=>{r.forEach(i=>{this.menu&&(this.menu.setChild(i),i.setParent(this.menu))}),this.menu&&(this.menu.api=this.menu.initApi(),this.menu.render()),r.forEach(i=>{i.api=i.initApi(),i.render()}),this.menu&&this.menu.children.length>0&&this.menu.renderSubmenuTriggers()},0),this.onSetOpen=i=>{let{open:s}=i.detail;t.api.setOpen(s)},e.addEventListener("phx:menu:set-open",this.onSetOpen),this.handlers=[],this.handlers.push(this.handleEvent("menu_set_open",i=>{let s=i.menu_id;s&&s!==e.id||t.api.setOpen(i.open)})),this.handlers.push(this.handleEvent("menu_open",()=>{this.pushEvent("menu_open_response",{open:t.api.open})}))},updated(){var e;this.el.hasAttribute("data-nested")||(e=this.menu)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{open:O(this.el,"open")}:{defaultOpen:O(this.el,"defaultOpen")}),{closeOnSelect:O(this.el,"closeOnSelect"),loopFocus:O(this.el,"loopFocus"),typeahead:O(this.el,"typeahead"),composite:O(this.el,"composite"),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(!this.el.hasAttribute("data-nested")){if(this.onSetOpen&&this.el.removeEventListener("phx:menu:set-open",this.onSetOpen),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);if(this.nestedMenus)for(let[,t]of this.nestedMenus)t.destroy();(e=this.menu)==null||e.destroy()}}}});var zu={};Oe(zu,{Select:()=>SE});function pE(e,t){let{context:n,prop:r,scope:i,state:s,computed:o,send:a}=e,l=r("disabled")||n.get("fieldsetDisabled"),c=!!r("invalid"),u=!!r("required"),h=!!r("readOnly"),p=r("composite"),d=r("collection"),g=s.hasTag("open"),v=s.matches("focused"),b=n.get("highlightedValue"),V=n.get("highlightedItem"),S=n.get("selectedItems"),E=n.get("currentPlacement"),f=o("isTypingAhead"),C=o("isInteractive"),I=b?ia(i,b):void 0;function w(P){let N=d.getItemDisabled(P.item),R=d.getItemValue(P.item);return qn(R,()=>`[zag-js] No value found for item ${JSON.stringify(P.item)}`),{value:R,disabled:!!(l||N),highlighted:b===R,selected:n.get("value").includes(R)}}let A=Zt(y(m({},r("positioning")),{placement:E}));return{open:g,focused:v,empty:n.get("value").length===0,highlightedItem:V,highlightedValue:b,selectedItems:S,hasSelectedItems:o("hasSelectedItems"),value:n.get("value"),valueAsString:o("valueAsString"),collection:d,multiple:!!r("multiple"),disabled:!!l,reposition(P={}){a({type:"POSITIONING.SET",options:P})},focus(){var P;(P=On(i))==null||P.focus({preventScroll:!0})},setOpen(P){s.hasTag("open")!==P&&a({type:P?"OPEN":"CLOSE"})},selectValue(P){a({type:"ITEM.SELECT",value:P})},setValue(P){a({type:"VALUE.SET",value:P})},selectAll(){a({type:"VALUE.SET",value:d.getValues()})},setHighlightValue(P){a({type:"HIGHLIGHTED_VALUE.SET",value:P})},clearHighlightValue(){a({type:"HIGHLIGHTED_VALUE.CLEAR"})},clearValue(P){a(P?{type:"ITEM.CLEAR",value:P}:{type:"VALUE.CLEAR"})},getItemState:w,getRootProps(){return t.element(y(m({},ke.root.attrs),{dir:r("dir"),id:dE(i),"data-invalid":T(c),"data-readonly":T(h)}))},getLabelProps(){return t.label(y(m({dir:r("dir"),id:us(i)},ke.label.attrs),{"data-disabled":T(l),"data-invalid":T(c),"data-readonly":T(h),"data-required":T(u),htmlFor:sa(i),onClick(P){var N;P.defaultPrevented||l||(N=On(i))==null||N.focus({preventScroll:!0})}}))},getControlProps(){return t.element(y(m({},ke.control.attrs),{dir:r("dir"),id:hE(i),"data-state":g?"open":"closed","data-focus":T(v),"data-disabled":T(l),"data-invalid":T(c)}))},getValueTextProps(){return t.element(y(m({},ke.valueText.attrs),{dir:r("dir"),"data-disabled":T(l),"data-invalid":T(c),"data-focus":T(v)}))},getTriggerProps(){return t.button(y(m({id:ra(i),disabled:l,dir:r("dir"),type:"button",role:"combobox","aria-controls":na(i),"aria-expanded":g,"aria-haspopup":"listbox","data-state":g?"open":"closed","aria-invalid":c,"aria-required":u,"aria-labelledby":us(i)},ke.trigger.attrs),{"data-disabled":T(l),"data-invalid":T(c),"data-readonly":T(h),"data-placement":E,"data-placeholder-shown":T(!o("hasSelectedItems")),onClick(P){C&&(P.defaultPrevented||a({type:"TRIGGER.CLICK"}))},onFocus(){a({type:"TRIGGER.FOCUS"})},onBlur(){a({type:"TRIGGER.BLUR"})},onKeyDown(P){if(P.defaultPrevented||!C)return;let R={ArrowUp(){a({type:"TRIGGER.ARROW_UP"})},ArrowDown(L){a({type:L.altKey?"OPEN":"TRIGGER.ARROW_DOWN"})},ArrowLeft(){a({type:"TRIGGER.ARROW_LEFT"})},ArrowRight(){a({type:"TRIGGER.ARROW_RIGHT"})},Home(){a({type:"TRIGGER.HOME"})},End(){a({type:"TRIGGER.END"})},Enter(){a({type:"TRIGGER.ENTER"})},Space(L){a(f?{type:"TRIGGER.TYPEAHEAD",key:L.key}:{type:"TRIGGER.ENTER"})}}[ve(P,{dir:r("dir"),orientation:"vertical"})];if(R){R(P),P.preventDefault();return}tt.isValidEvent(P)&&(a({type:"TRIGGER.TYPEAHEAD",key:P.key}),P.preventDefault())}}))},getIndicatorProps(){return t.element(y(m({},ke.indicator.attrs),{dir:r("dir"),"aria-hidden":!0,"data-state":g?"open":"closed","data-disabled":T(l),"data-invalid":T(c),"data-readonly":T(h)}))},getItemProps(P){let N=w(P);return t.element(y(m({id:ia(i,N.value),role:"option"},ke.item.attrs),{dir:r("dir"),"data-value":N.value,"aria-selected":N.selected,"data-state":N.selected?"checked":"unchecked","data-highlighted":T(N.highlighted),"data-disabled":T(N.disabled),"aria-disabled":re(N.disabled),onPointerMove(R){N.disabled||R.pointerType!=="mouse"||N.value!==b&&a({type:"ITEM.POINTER_MOVE",value:N.value})},onClick(R){R.defaultPrevented||N.disabled||a({type:"ITEM.CLICK",src:"pointerup",value:N.value})},onPointerLeave(R){var M;N.disabled||P.persistFocus||R.pointerType!=="mouse"||!((M=e.event.previous())!=null&&M.type.includes("POINTER"))||a({type:"ITEM.POINTER_LEAVE"})}}))},getItemTextProps(P){let N=w(P);return t.element(y(m({},ke.itemText.attrs),{"data-state":N.selected?"checked":"unchecked","data-disabled":T(N.disabled),"data-highlighted":T(N.highlighted)}))},getItemIndicatorProps(P){let N=w(P);return t.element(y(m({"aria-hidden":!0},ke.itemIndicator.attrs),{"data-state":N.selected?"checked":"unchecked",hidden:!N.selected}))},getItemGroupLabelProps(P){let{htmlFor:N}=P;return t.element(y(m({},ke.itemGroupLabel.attrs),{id:Yu(i,N),dir:r("dir"),role:"presentation"}))},getItemGroupProps(P){let{id:N}=P;return t.element(y(m({},ke.itemGroup.attrs),{"data-disabled":T(l),id:gE(i,N),"aria-labelledby":Yu(i,N),role:"group",dir:r("dir")}))},getClearTriggerProps(){return t.button(y(m({},ke.clearTrigger.attrs),{id:Zu(i),type:"button","aria-label":"Clear value","data-invalid":T(c),disabled:l,hidden:!o("hasSelectedItems"),dir:r("dir"),onClick(P){P.defaultPrevented||a({type:"CLEAR.CLICK"})}}))},getHiddenSelectProps(){let P=n.get("value"),N=r("multiple")?P:P==null?void 0:P[0];return t.select({name:r("name"),form:r("form"),disabled:l,multiple:r("multiple"),required:r("required"),"aria-hidden":!0,id:sa(i),defaultValue:N,style:Hn,tabIndex:-1,onFocus(){var R;(R=On(i))==null||R.focus({preventScroll:!0})},"aria-labelledby":us(i)})},getPositionerProps(){return t.element(y(m({},ke.positioner.attrs),{dir:r("dir"),id:Ju(i),style:A.floating}))},getContentProps(){return t.element(y(m({hidden:!g,dir:r("dir"),id:na(i),role:p?"listbox":"dialog"},ke.content.attrs),{"data-state":g?"open":"closed","data-placement":E,"data-activedescendant":I,"aria-activedescendant":p?I:void 0,"aria-multiselectable":r("multiple")&&p?!0:void 0,"aria-labelledby":us(i),tabIndex:0,onKeyDown(P){if(!C||!pe(P.currentTarget,K(P)))return;if(P.key==="Tab"&&!gi(P)){P.preventDefault();return}let N={ArrowUp(){a({type:"CONTENT.ARROW_UP"})},ArrowDown(){a({type:"CONTENT.ARROW_DOWN"})},Home(){a({type:"CONTENT.HOME"})},End(){a({type:"CONTENT.END"})},Enter(){a({type:"ITEM.CLICK",src:"keydown.enter"})},Space(M){var j;f?a({type:"CONTENT.TYPEAHEAD",key:M.key}):(j=N.Enter)==null||j.call(N,M)}},R=N[ve(P)];if(R){R(P),P.preventDefault();return}let L=K(P);Ut(L)||tt.isValidEvent(P)&&(a({type:"CONTENT.TYPEAHEAD",key:P.key}),P.preventDefault())}}))},getListProps(){return t.element(y(m({},ke.list.attrs),{tabIndex:0,role:p?void 0:"listbox","aria-labelledby":ra(i),"aria-activedescendant":p?void 0:I,"aria-multiselectable":!p&&r("multiple")?!0:void 0}))}}}function Xu(e){var n,r;let t=(r=e.restoreFocus)!=null?r:(n=e.previousEvent)==null?void 0:n.restoreFocus;return t==null||!!t}function TE(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function OE(e){let t={};for(let[n,r]of Object.entries(e)){let i=TE(n);t[i]=r}return t}var uE,ke,ds,dE,na,ra,Zu,us,hE,ia,sa,Ju,gE,Yu,ea,Ur,On,fE,ju,ta,qr,Tn,mE,vE,yE,nO,bE,rO,EE,iO,CE,sO,IE,SE,Qu=fe(()=>{"use strict";Ai();Nr();gn();me();uE=Z("select").parts("label","positioner","trigger","indicator","clearTrigger","item","itemText","itemIndicator","itemGroup","itemGroupLabel","list","content","root","control","valueText"),ke=uE.build(),ds=e=>new Xn(e);ds.empty=()=>new Xn({items:[]});dE=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`select:${e.id}`},na=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`select:${e.id}:content`},ra=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`select:${e.id}:trigger`},Zu=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.clearTrigger)!=null?n:`select:${e.id}:clear-trigger`},us=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`select:${e.id}:label`},hE=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`select:${e.id}:control`},ia=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.item)==null?void 0:r.call(n,t))!=null?i:`select:${e.id}:option:${t}`},sa=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.hiddenSelect)!=null?n:`select:${e.id}:select`},Ju=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.positioner)!=null?n:`select:${e.id}:positioner`},gE=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemGroup)==null?void 0:r.call(n,t))!=null?i:`select:${e.id}:optgroup:${t}`},Yu=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.itemGroupLabel)==null?void 0:r.call(n,t))!=null?i:`select:${e.id}:optgroup-label:${t}`},ea=e=>e.getById(sa(e)),Ur=e=>e.getById(na(e)),On=e=>e.getById(ra(e)),fE=e=>e.getById(Zu(e)),ju=e=>e.getById(Ju(e)),ta=(e,t)=>t==null?null:e.getById(ia(e,t));({and:qr,not:Tn,or:mE}=ye()),vE={props({props:e}){var t;return y(m({loopFocus:!1,closeOnSelect:!e.multiple,composite:!0,defaultValue:[]},e),{collection:(t=e.collection)!=null?t:ds.empty(),positioning:m({placement:"bottom-start",gutter:8},e.positioning)})},context({prop:e,bindable:t}){return{value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),isEqual:he,onChange(n){var i;let r=e("collection").findMany(n);return(i=e("onValueChange"))==null?void 0:i({value:n,items:r})}})),highlightedValue:t(()=>({defaultValue:e("defaultHighlightedValue")||null,value:e("highlightedValue"),onChange(n){var r;(r=e("onHighlightChange"))==null||r({highlightedValue:n,highlightedItem:e("collection").find(n),highlightedIndex:e("collection").indexOf(n)})}})),currentPlacement:t(()=>({defaultValue:void 0})),fieldsetDisabled:t(()=>({defaultValue:!1})),highlightedItem:t(()=>({defaultValue:null})),selectedItems:t(()=>{var i,s;let n=(s=(i=e("value"))!=null?i:e("defaultValue"))!=null?s:[];return{defaultValue:e("collection").findMany(n)}})}},refs(){return{typeahead:m({},tt.defaultOptions)}},computed:{hasSelectedItems:({context:e})=>e.get("value").length>0,isTypingAhead:({refs:e})=>e.get("typeahead").keysSoFar!=="",isDisabled:({prop:e,context:t})=>!!e("disabled")||!!t.get("fieldsetDisabled"),isInteractive:({prop:e})=>!(e("disabled")||e("readOnly")),valueAsString:({context:e,prop:t})=>t("collection").stringifyItems(e.get("selectedItems"))},initialState({prop:e}){return e("open")||e("defaultOpen")?"open":"idle"},entry:["syncSelectElement"],watch({context:e,prop:t,track:n,action:r}){n([()=>e.get("value").toString()],()=>{r(["syncSelectedItems","syncSelectElement","dispatchChangeEvent"])}),n([()=>t("open")],()=>{r(["toggleVisibility"])}),n([()=>e.get("highlightedValue")],()=>{r(["syncHighlightedItem"])}),n([()=>t("collection").toString()],()=>{r(["syncCollection"])})},on:{"HIGHLIGHTED_VALUE.SET":{actions:["setHighlightedItem"]},"HIGHLIGHTED_VALUE.CLEAR":{actions:["clearHighlightedItem"]},"ITEM.SELECT":{actions:["selectItem"]},"ITEM.CLEAR":{actions:["clearItem"]},"VALUE.SET":{actions:["setSelectedItems"]},"VALUE.CLEAR":{actions:["clearSelectedItems"]},"CLEAR.CLICK":{actions:["clearSelectedItems","focusTriggerEl"]}},effects:["trackFormControlState"],states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":[{guard:"isTriggerClickEvent",target:"open",actions:["setInitialFocus","highlightFirstSelectedItem"]},{target:"open",actions:["setInitialFocus"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen","setInitialFocus","highlightFirstSelectedItem"]}],"TRIGGER.FOCUS":{target:"focused"},OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen"]}]}},focused:{tags:["closed"],on:{"CONTROLLED.OPEN":[{guard:"isTriggerClickEvent",target:"open",actions:["setInitialFocus","highlightFirstSelectedItem"]},{guard:"isTriggerArrowUpEvent",target:"open",actions:["setInitialFocus","highlightComputedLastItem"]},{guard:mE("isTriggerArrowDownEvent","isTriggerEnterEvent"),target:"open",actions:["setInitialFocus","highlightComputedFirstItem"]},{target:"open",actions:["setInitialFocus"]}],OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen"]}],"TRIGGER.BLUR":{target:"idle"},"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen","highlightFirstSelectedItem"]}],"TRIGGER.ENTER":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen","highlightComputedFirstItem"]}],"TRIGGER.ARROW_UP":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen","highlightComputedLastItem"]}],"TRIGGER.ARROW_DOWN":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["setInitialFocus","invokeOnOpen","highlightComputedFirstItem"]}],"TRIGGER.ARROW_LEFT":[{guard:qr(Tn("multiple"),"hasSelectedItems"),actions:["selectPreviousItem"]},{guard:Tn("multiple"),actions:["selectLastItem"]}],"TRIGGER.ARROW_RIGHT":[{guard:qr(Tn("multiple"),"hasSelectedItems"),actions:["selectNextItem"]},{guard:Tn("multiple"),actions:["selectFirstItem"]}],"TRIGGER.HOME":{guard:Tn("multiple"),actions:["selectFirstItem"]},"TRIGGER.END":{guard:Tn("multiple"),actions:["selectLastItem"]},"TRIGGER.TYPEAHEAD":{guard:Tn("multiple"),actions:["selectMatchingItem"]}}},open:{tags:["open"],exit:["scrollContentToTop"],effects:["trackDismissableElement","computePlacement","scrollToHighlightedItem"],on:{"CONTROLLED.CLOSE":[{guard:"restoreFocus",target:"focused",actions:["focusTriggerEl","clearHighlightedItem"]},{target:"idle",actions:["clearHighlightedItem"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{guard:"restoreFocus",target:"focused",actions:["invokeOnClose","focusTriggerEl","clearHighlightedItem"]},{target:"idle",actions:["invokeOnClose","clearHighlightedItem"]}],"TRIGGER.CLICK":[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"focused",actions:["invokeOnClose","clearHighlightedItem"]}],"ITEM.CLICK":[{guard:qr("closeOnSelect","isOpenControlled"),actions:["selectHighlightedItem","invokeOnClose"]},{guard:"closeOnSelect",target:"focused",actions:["selectHighlightedItem","invokeOnClose","focusTriggerEl","clearHighlightedItem"]},{actions:["selectHighlightedItem"]}],"CONTENT.HOME":{actions:["highlightFirstItem"]},"CONTENT.END":{actions:["highlightLastItem"]},"CONTENT.ARROW_DOWN":[{guard:qr("hasHighlightedItem","loop","isLastItemHighlighted"),actions:["highlightFirstItem"]},{guard:"hasHighlightedItem",actions:["highlightNextItem"]},{actions:["highlightFirstItem"]}],"CONTENT.ARROW_UP":[{guard:qr("hasHighlightedItem","loop","isFirstItemHighlighted"),actions:["highlightLastItem"]},{guard:"hasHighlightedItem",actions:["highlightPreviousItem"]},{actions:["highlightLastItem"]}],"CONTENT.TYPEAHEAD":{actions:["highlightMatchingItem"]},"ITEM.POINTER_MOVE":{actions:["highlightItem"]},"ITEM.POINTER_LEAVE":{actions:["clearHighlightedItem"]},"POSITIONING.SET":{actions:["reposition"]}}}},implementations:{guards:{loop:({prop:e})=>!!e("loopFocus"),multiple:({prop:e})=>!!e("multiple"),hasSelectedItems:({computed:e})=>!!e("hasSelectedItems"),hasHighlightedItem:({context:e})=>e.get("highlightedValue")!=null,isFirstItemHighlighted:({context:e,prop:t})=>e.get("highlightedValue")===t("collection").firstValue,isLastItemHighlighted:({context:e,prop:t})=>e.get("highlightedValue")===t("collection").lastValue,closeOnSelect:({prop:e,event:t})=>{var n;return!!((n=t.closeOnSelect)!=null?n:e("closeOnSelect"))},restoreFocus:({event:e})=>Xu(e),isOpenControlled:({prop:e})=>e("open")!==void 0,isTriggerClickEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="TRIGGER.CLICK"},isTriggerEnterEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="TRIGGER.ENTER"},isTriggerArrowUpEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="TRIGGER.ARROW_UP"},isTriggerArrowDownEvent:({event:e})=>{var t;return((t=e.previousEvent)==null?void 0:t.type)==="TRIGGER.ARROW_DOWN"}},effects:{trackFormControlState({context:e,scope:t}){return Rn(ea(t),{onFieldsetDisabledChange(n){e.set("fieldsetDisabled",n)},onFormReset(){let n=e.initial("value");e.set("value",n)}})},trackDismissableElement({scope:e,send:t,prop:n}){let r=()=>Ur(e),i=!0;return vt(r,{type:"listbox",defer:!0,exclude:[On(e),fE(e)],onFocusOutside:n("onFocusOutside"),onPointerDownOutside:n("onPointerDownOutside"),onInteractOutside(s){var o;(o=n("onInteractOutside"))==null||o(s),i=!(s.detail.focusable||s.detail.contextmenu)},onDismiss(){t({type:"CLOSE",src:"interact-outside",restoreFocus:i})}})},computePlacement({context:e,prop:t,scope:n}){let r=t("positioning");return e.set("currentPlacement",r.placement),at(()=>On(n),()=>ju(n),y(m({defer:!0},r),{onComplete(o){e.set("currentPlacement",o.placement)}}))},scrollToHighlightedItem({context:e,prop:t,scope:n,event:r}){let i=o=>{let a=e.get("highlightedValue");if(a==null||r.current().type.includes("POINTER"))return;let l=Ur(n),c=t("scrollToIndexFn");if(c){let h=t("collection").indexOf(a);c==null||c({index:h,immediate:o,getElement:()=>ta(n,a)});return}let u=ta(n,a);ln(u,{rootEl:l,block:"nearest"})};return H(()=>i(!0)),Ln(()=>Ur(n),{defer:!0,attributes:["data-activedescendant"],callback(){i(!1)}})}},actions:{reposition({context:e,prop:t,scope:n,event:r}){let i=()=>ju(n);at(On(n),i,y(m(m({},t("positioning")),r.options),{defer:!0,listeners:!1,onComplete(s){e.set("currentPlacement",s.placement)}}))},toggleVisibility({send:e,prop:t,event:n}){e({type:t("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:n})},highlightPreviousItem({context:e,prop:t}){let n=e.get("highlightedValue");if(n==null)return;let r=t("collection").getPreviousValue(n,1,t("loopFocus"));r!=null&&e.set("highlightedValue",r)},highlightNextItem({context:e,prop:t}){let n=e.get("highlightedValue");if(n==null)return;let r=t("collection").getNextValue(n,1,t("loopFocus"));r!=null&&e.set("highlightedValue",r)},highlightFirstItem({context:e,prop:t}){let n=t("collection").firstValue;e.set("highlightedValue",n)},highlightLastItem({context:e,prop:t}){let n=t("collection").lastValue;e.set("highlightedValue",n)},setInitialFocus({scope:e}){H(()=>{let t=hi({root:Ur(e)});t==null||t.focus({preventScroll:!0})})},focusTriggerEl({event:e,scope:t}){Xu(e)&&H(()=>{let n=On(t);n==null||n.focus({preventScroll:!0})})},selectHighlightedItem({context:e,prop:t,event:n}){var s,o;let r=(s=n.value)!=null?s:e.get("highlightedValue");if(r==null||!t("collection").has(r))return;(o=t("onSelect"))==null||o({value:r}),r=t("deselectable")&&!t("multiple")&&e.get("value").includes(r)?null:r,e.set("value",a=>r==null?[]:t("multiple")?it(a,r):[r])},highlightComputedFirstItem({context:e,prop:t,computed:n}){let r=t("collection"),i=n("hasSelectedItems")?r.sort(e.get("value"))[0]:r.firstValue;e.set("highlightedValue",i)},highlightComputedLastItem({context:e,prop:t,computed:n}){let r=t("collection"),i=n("hasSelectedItems")?r.sort(e.get("value"))[0]:r.lastValue;e.set("highlightedValue",i)},highlightFirstSelectedItem({context:e,prop:t,computed:n}){if(!n("hasSelectedItems"))return;let r=t("collection").sort(e.get("value"))[0];e.set("highlightedValue",r)},highlightItem({context:e,event:t}){e.set("highlightedValue",t.value)},highlightMatchingItem({context:e,prop:t,event:n,refs:r}){let i=t("collection").search(n.key,{state:r.get("typeahead"),currentValue:e.get("highlightedValue")});i!=null&&e.set("highlightedValue",i)},setHighlightedItem({context:e,event:t}){e.set("highlightedValue",t.value)},clearHighlightedItem({context:e}){e.set("highlightedValue",null)},selectItem({context:e,prop:t,event:n}){var s;(s=t("onSelect"))==null||s({value:n.value});let i=t("deselectable")&&!t("multiple")&&e.get("value").includes(n.value)?null:n.value;e.set("value",o=>i==null?[]:t("multiple")?it(o,i):[i])},clearItem({context:e,event:t}){e.set("value",n=>n.filter(r=>r!==t.value))},setSelectedItems({context:e,event:t}){e.set("value",t.value)},clearSelectedItems({context:e}){e.set("value",[])},selectPreviousItem({context:e,prop:t}){let[n]=e.get("value"),r=t("collection").getPreviousValue(n);r&&e.set("value",[r])},selectNextItem({context:e,prop:t}){let[n]=e.get("value"),r=t("collection").getNextValue(n);r&&e.set("value",[r])},selectFirstItem({context:e,prop:t}){let n=t("collection").firstValue;n&&e.set("value",[n])},selectLastItem({context:e,prop:t}){let n=t("collection").lastValue;n&&e.set("value",[n])},selectMatchingItem({context:e,prop:t,event:n,refs:r}){let i=t("collection").search(n.key,{state:r.get("typeahead"),currentValue:e.get("value")[0]});i!=null&&e.set("value",[i])},scrollContentToTop({prop:e,scope:t}){var n,r;if(e("scrollToIndexFn")){let i=e("collection").firstValue;(n=e("scrollToIndexFn"))==null||n({index:0,immediate:!0,getElement:()=>ta(t,i)})}else(r=Ur(t))==null||r.scrollTo(0,0)},invokeOnOpen({prop:e,context:t}){var n;(n=e("onOpenChange"))==null||n({open:!0,value:t.get("value")})},invokeOnClose({prop:e,context:t}){var n;(n=e("onOpenChange"))==null||n({open:!1,value:t.get("value")})},syncSelectElement({context:e,prop:t,scope:n}){let r=ea(n);if(r){if(e.get("value").length===0&&!t("multiple")){r.selectedIndex=-1;return}for(let i of r.options)i.selected=e.get("value").includes(i.value)}},syncCollection({context:e,prop:t}){let n=t("collection"),r=n.find(e.get("highlightedValue"));r&&e.set("highlightedItem",r);let i=n.findMany(e.get("value"));e.set("selectedItems",i)},syncSelectedItems({context:e,prop:t}){let n=t("collection"),r=e.get("selectedItems"),s=e.get("value").map(o=>r.find(l=>n.getItemValue(l)===o)||n.find(o));e.set("selectedItems",s)},syncHighlightedItem({context:e,prop:t}){let n=t("collection"),r=e.get("highlightedValue"),i=r?n.find(r):null;e.set("highlightedItem",i)},dispatchChangeEvent({scope:e}){queueMicrotask(()=>{let t=ea(e);if(!t)return;let n=e.getWin(),r=new n.Event("change",{bubbles:!0,composed:!0});t.dispatchEvent(r)})}}}};yE=G()(["closeOnSelect","collection","composite","defaultHighlightedValue","defaultOpen","defaultValue","deselectable","dir","disabled","form","getRootNode","highlightedValue","id","ids","invalid","loopFocus","multiple","name","onFocusOutside","onHighlightChange","onInteractOutside","onOpenChange","onPointerDownOutside","onSelect","onValueChange","open","positioning","readOnly","required","scrollToIndexFn","value"]),nO=B(yE),bE=G()(["item","persistFocus"]),rO=B(bE),EE=G()(["id"]),iO=B(EE),CE=G()(["htmlFor"]),sO=B(CE),IE=class extends te{constructor(t,n){super(t,n);U(this,"_options",[]);U(this,"hasGroups",!1);U(this,"placeholder","");this.placeholder=x(this.el,"placeholder")||""}get options(){return Array.isArray(this._options)?this._options:[]}setOptions(t){this._options=Array.isArray(t)?t:[]}getCollection(){let t=this.options;return this.hasGroups?ds({items:t,itemToValue:n=>{var r,i;return(i=(r=n.id)!=null?r:n.value)!=null?i:""},itemToString:n=>n.label,isItemDisabled:n=>!!n.disabled,groupBy:n=>{var r;return(r=n.group)!=null?r:""}}):ds({items:t,itemToValue:n=>{var r,i;return(i=(r=n.id)!=null?r:n.value)!=null?i:""},itemToString:n=>n.label,isItemDisabled:n=>!!n.disabled})}initMachine(t){let n=this.getCollection.bind(this);return new ee(vE,y(m({},t),{get collection(){return n()}}))}initApi(){return pE(this.machine.service,Q)}renderItems(){var o,a,l;let t=this.el.querySelector('[data-scope="select"][data-part="content"]');if(!t)return;let n=this.el.querySelector('[data-templates="select"]');if(!n)return;t.querySelectorAll('[data-scope="select"][data-part="item"]:not([data-template])').forEach(c=>c.remove()),t.querySelectorAll('[data-scope="select"][data-part="item-group"]:not([data-template])').forEach(c=>c.remove());let r=this.api.collection.items,i=(l=(a=(o=this.api.collection).group)==null?void 0:a.call(o))!=null?l:[];i.some(([c])=>c!=null)?this.renderGroupedItems(t,n,i):this.renderFlatItems(t,n,r)}renderGroupedItems(t,n,r){for(let[i,s]of r){if(i==null)continue;let o=n.querySelector(`[data-scope="select"][data-part="item-group"][data-id="${i}"][data-template]`);if(!o)continue;let a=o.cloneNode(!0);a.removeAttribute("data-template"),this.spreadProps(a,this.api.getItemGroupProps({id:i}));let l=a.querySelector('[data-scope="select"][data-part="item-group-label"]');l&&this.spreadProps(l,this.api.getItemGroupLabelProps({htmlFor:i})),a.querySelectorAll('[data-scope="select"][data-part="item"][data-template]').forEach(u=>u.remove());for(let u of s){let h=this.cloneItem(n,u);h&&a.appendChild(h)}t.appendChild(a)}}renderFlatItems(t,n,r){for(let i of r){let s=this.cloneItem(n,i);s&&t.appendChild(s)}}cloneItem(t,n){let r=this.api.collection.getItemValue(n),i=t.querySelector(`[data-scope="select"][data-part="item"][data-value="${r}"][data-template]`);if(!i)return null;let s=i.cloneNode(!0);s.removeAttribute("data-template"),this.spreadProps(s,this.api.getItemProps({item:n}));let o=s.querySelector('[data-scope="select"][data-part="item-text"]');o&&this.spreadProps(o,this.api.getItemTextProps({item:n}));let a=s.querySelector('[data-scope="select"][data-part="item-indicator"]');return a&&this.spreadProps(a,this.api.getItemIndicatorProps({item:n})),s}render(){let t=this.el.querySelector('[data-scope="select"][data-part="root"]');if(!t)return;this.spreadProps(t,this.api.getRootProps());let n=this.el.querySelector('[data-scope="select"][data-part="hidden-select"]'),r=this.el.querySelector('[data-scope="select"][data-part="value-input"]');r&&(!this.api.value||this.api.value.length===0?r.value="":this.api.value.length===1?r.value=String(this.api.value[0]):r.value=this.api.value.map(String).join(",")),n&&this.spreadProps(n,this.api.getHiddenSelectProps()),["label","control","trigger","indicator","clear-trigger","positioner"].forEach(o=>{let a=this.el.querySelector(`[data-scope="select"][data-part="${o}"]`);if(!a)return;let l="get"+o.split("-").map(c=>c[0].toUpperCase()+c.slice(1)).join("")+"Props";this.spreadProps(a,this.api[l]())});let i=this.el.querySelector('[data-scope="select"][data-part="item-text"]');if(i){let o=this.api.valueAsString;if(this.api.value&&this.api.value.length>0&&!o){let a=this.api.value[0],l=this.options.find(c=>{var h,p;let u=(p=(h=c.id)!=null?h:c.value)!=null?p:"";return String(u)===String(a)});l?i.textContent=l.label:i.textContent=this.placeholder||""}else i.textContent=o||this.placeholder||""}let s=this.el.querySelector('[data-scope="select"][data-part="content"]');s&&(this.spreadProps(s,this.api.getContentProps()),this.renderItems())}};SE={mounted(){let e=this.el,t=JSON.parse(e.dataset.collection||"[]"),n=t.some(i=>i.group!==void 0),r=new IE(e,y(m({id:e.id},O(e,"controlled")?{value:Y(e,"value")}:{defaultValue:Y(e,"defaultValue")}),{disabled:O(e,"disabled"),closeOnSelect:O(e,"closeOnSelect"),dir:x(e,"dir",["ltr","rtl"]),loopFocus:O(e,"loopFocus"),multiple:O(e,"multiple"),invalid:O(e,"invalid"),name:x(e,"name"),form:x(e,"form"),readOnly:O(e,"readOnly"),required:O(e,"required"),positioning:(()=>{let i=e.dataset.positioning;if(i)try{let s=JSON.parse(i);return OE(s)}catch(s){return}})(),onValueChange:i=>{var b;let s=O(e,"redirect"),o=i.value.length>0?String(i.value[0]):null,a=(b=i.items)!=null&&b.length?i.items[0]:null,l=a&&typeof a=="object"&&a!==null&&"redirect"in a?a.redirect:void 0,c=a&&typeof a=="object"&&a!==null&&"new_tab"in a?a.new_tab:void 0;s&&o&&this.liveSocket.main.isDead&&l!==!1&&(c===!0?window.open(o,"_blank","noopener,noreferrer"):window.location.href=o);let p=e.querySelector('[data-scope="select"][data-part="value-input"]');p&&(p.value=i.value.length===0?"":i.value.length===1?String(i.value[0]):i.value.map(String).join(","),p.dispatchEvent(new Event("input",{bubbles:!0})),p.dispatchEvent(new Event("change",{bubbles:!0})));let d={value:i.value,items:i.items,id:e.id},g=x(e,"onValueChangeClient");g&&e.dispatchEvent(new CustomEvent(g,{bubbles:!0,detail:d}));let v=x(e,"onValueChange");v&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&this.pushEvent(v,d)}}));r.hasGroups=n,r.setOptions(t),r.init(),this.select=r,this.handlers=[]},updated(){let e=JSON.parse(this.el.dataset.collection||"[]"),t=e.some(n=>n.group!==void 0);this.select&&(this.select.hasGroups=t,this.select.setOptions(e),this.select.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{value:Y(this.el,"value")}:{defaultValue:Y(this.el,"defaultValue")}),{name:x(this.el,"name"),form:x(this.el,"form"),disabled:O(this.el,"disabled"),multiple:O(this.el,"multiple"),dir:x(this.el,"dir",["ltr","rtl"]),invalid:O(this.el,"invalid"),required:O(this.el,"required"),readOnly:O(this.el,"readOnly")})))},destroyed(){var e;if(this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.select)==null||e.destroy()}}});var bd={};Oe(bd,{SignaturePad:()=>zE});function nd(e,t,n,r=i=>i){return e*r(.5-t*(.5-n))}function gd(e,t,n){let r=oa(1,t/n);return oa(1,e+(oa(1,1-r)-e)*(r*.275))}function wE(e){return[-e[0],-e[1]]}function bt(e,t){return[e[0]+t[0],e[1]+t[1]]}function rd(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function en(e,t){return[e[0]-t[0],e[1]-t[1]]}function ca(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function Qt(e,t){return[e[0]*t,e[1]*t]}function aa(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function VE(e,t){return[e[0]/t,e[1]/t]}function fd(e){return[e[1],-e[0]]}function la(e,t){let n=t[0];return e[0]=t[1],e[1]=-n,e}function id(e,t){return e[0]*t[0]+e[1]*t[1]}function xE(e,t){return e[0]===t[0]&&e[1]===t[1]}function kE(e){return Math.hypot(e[0],e[1])}function sd(e,t){let n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function pd(e){return VE(e,kE(e))}function NE(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function ua(e,t,n){let r=Math.sin(n),i=Math.cos(n),s=e[0]-t[0],o=e[1]-t[1],a=s*i-o*r,l=s*r+o*i;return[a+t[0],l+t[1]]}function od(e,t,n,r){let i=Math.sin(r),s=Math.cos(r),o=t[0]-n[0],a=t[1]-n[1],l=o*s-a*i,c=o*i+a*s;return e[0]=l+n[0],e[1]=c+n[1],e}function ad(e,t,n){return bt(e,Qt(en(t,e),n))}function AE(e,t,n,r){let i=n[0]-t[0],s=n[1]-t[1];return e[0]=t[0]+i*r,e[1]=t[1]+s*r,e}function md(e,t,n){return bt(e,Qt(t,n))}function RE(e,t){let n=md(e,pd(fd(en(e,bt(e,[1,1])))),-t),r=[],i=1/13;for(let s=i;s<=1;s+=i)r.push(ua(n,e,Wr*2*s));return r}function DE(e,t,n){let r=[],i=1/n;for(let s=i;s<=1;s+=i)r.push(ua(t,e,Wr*s));return r}function LE(e,t,n){let r=en(t,n),i=Qt(r,.5),s=Qt(r,.51);return[en(e,i),en(e,s),bt(e,s),bt(e,i)]}function FE(e,t,n,r){let i=[],s=md(e,t,n),o=1/r;for(let a=o;a<1;a+=o)i.push(ua(s,e,Wr*3*a));return i}function ME(e,t,n){return[bt(e,Qt(t,n)),bt(e,Qt(t,n*.99)),en(e,Qt(t,n*.99)),en(e,Qt(t,n))]}function ld(e,t,n){return e===!1||e===void 0?0:e===!0?Math.max(t,n):e}function $E(e,t,n){return e.slice(0,10).reduce((r,i)=>{let s=i.pressure;return t&&(s=gd(r,i.distance,n)),(r+s)/2},e[0].pressure)}function _E(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:s=!0,easing:o=W=>W,start:a={},end:l={},last:c=!1}=t,{cap:u=!0,easing:h=W=>W*(2-W)}=a,{cap:p=!0,easing:d=W=>--W*W*W+1}=l;if(e.length===0||n<=0)return[];let g=e[e.length-1].runningLength,v=ld(a.taper,n,g),b=ld(l.taper,n,g),V=(n*r)**2,S=[],E=[],f=$E(e,s,n),C=nd(n,i,e[e.length-1].pressure,o),I,w=e[0].vector,A=e[0].point,P=A,N=A,R=P,L=!1;for(let W=0;WV)&&(S.push(N),A=N),rd(zt,de,Te),R=[zt[0],zt[1]],(W<=1||sd(P,R)>V)&&(E.push(R),P=R),f=ge,w=X}let M=[e[0].point[0],e[0].point[1]],j=e.length>1?[e[e.length-1].point[0],e[e.length-1].point[1]]:bt(e[0].point,[1,1]),q=[],J=[];if(e.length===1){if(!(v||b)||c)return RE(M,I||C)}else{v||b&&e.length===1||(u?q.push(...DE(M,E[0],13)):q.push(...LE(M,S[0],E[0])));let W=fd(wE(e[e.length-1].vector));b||v&&e.length===1?J.push(j):p?J.push(...FE(j,W,C,29)):J.push(...ME(j,W,C))}return S.concat(J,E.reverse(),q)}function ud(e){return e!=null&&e>=0}function HE(e,t={}){var p;let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let s=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:d,y:g,pressure:v=ed})=>[d,g,v]);if(o.length===2){let d=o[1];o=o.slice(0,-1);for(let g=1;g<5;g++)o.push(ad(o[0],d,g/4))}o.length===1&&(o=[...o,[...bt(o[0],td),...o[0].slice(2)]]);let a=[{point:[o[0][0],o[0][1]],pressure:ud(o[0][2])?o[0][2]:.25,vector:[...td],distance:0,runningLength:0}],l=!1,c=0,u=a[0],h=o.length-1;for(let d=1;d{"use strict";me();({PI:PE}=Math),Wr=PE+1e-4,ed=.5,td=[1,1];({min:oa}=Math);Te=[0,0],Jt=[0,0],zt=[0,0];cd=[0,0];GE=BE,UE=Z("signature-pad").parts("root","control","segment","segmentPath","guide","clearTrigger","label"),Sn=UE.build(),qE=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`signature-${e.id}`},vd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`signature-control-${e.id}`},WE=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`signature-label-${e.id}`},dd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.hiddenInput)!=null?n:`signature-input-${e.id}`},fs=e=>e.getById(vd(e)),KE=e=>Mn(fs(e),"[data-part=segment]"),yd=(e,t)=>_a(KE(e),t);hs=(e,t)=>(e+t)/2;XE={props({props:e}){return y(m({defaultPaths:[]},e),{drawing:m({size:2,simulatePressure:!1,thinning:.7,smoothing:.4,streamline:.6},e.drawing),translations:m({control:"signature pad",clearTrigger:"clear signature"},e.translations)})},initialState(){return"idle"},context({prop:e,bindable:t}){return{paths:t(()=>({defaultValue:e("defaultPaths"),value:e("paths"),sync:!0,onChange(n){var r;(r=e("onDraw"))==null||r({paths:n})}})),currentPoints:t(()=>({defaultValue:[]})),currentPath:t(()=>({defaultValue:null}))}},computed:{isInteractive:({prop:e})=>!(e("disabled")||e("readOnly")),isEmpty:({context:e})=>e.get("paths").length===0},on:{CLEAR:{actions:["clearPoints","invokeOnDrawEnd","focusCanvasEl"]}},states:{idle:{on:{POINTER_DOWN:{target:"drawing",actions:["addPoint"]}}},drawing:{effects:["trackPointerMove"],on:{POINTER_MOVE:{actions:["addPoint","invokeOnDraw"]},POINTER_UP:{target:"idle",actions:["endStroke","invokeOnDrawEnd"]}}}},implementations:{effects:{trackPointerMove({scope:e,send:t}){let n=e.getDoc();return Za(n,{onPointerMove({event:r,point:i}){let s=fs(e);if(!s)return;let{offset:o}=_s(i,s);t({type:"POINTER_MOVE",point:o,pressure:r.pressure})},onPointerUp(){t({type:"POINTER_UP"})}})}},actions:{addPoint({context:e,event:t,prop:n}){let r=[...e.get("currentPoints"),t.point];e.set("currentPoints",r);let i=GE(r,n("drawing"));e.set("currentPath",jE(i))},endStroke({context:e}){let t=[...e.get("paths"),e.get("currentPath")];e.set("paths",t),e.set("currentPoints",[]),e.set("currentPath",null)},clearPoints({context:e}){e.set("currentPoints",[]),e.set("paths",[]),e.set("currentPath",null)},focusCanvasEl({scope:e}){queueMicrotask(()=>{var t;(t=e.getActiveElement())==null||t.focus({preventScroll:!0})})},invokeOnDraw({context:e,prop:t}){var n;(n=t("onDraw"))==null||n({paths:[...e.get("paths"),e.get("currentPath")]})},invokeOnDrawEnd({context:e,prop:t,scope:n,computed:r}){var i;(i=t("onDrawEnd"))==null||i({paths:[...e.get("paths")],getDataUrl(s,o=.92){return r("isEmpty")?Promise.resolve(""):yd(n,{type:s,quality:o})}})}}}},ZE=G()(["defaultPaths","dir","disabled","drawing","getRootNode","id","ids","name","onDraw","onDrawEnd","paths","readOnly","required","translations"]),cO=B(ZE),JE=class extends te{constructor(){super(...arguments);U(this,"imageURL","");U(this,"paths",[]);U(this,"name");U(this,"syncPaths",()=>{let t=this.el.querySelector('[data-scope="signature-pad"][data-part="segment"]');if(!t)return;if(this.api.paths.length+(this.api.currentPath?1:0)===0){t.innerHTML="",this.imageURL="",this.paths=[];let r=this.el.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');r&&(r.value="");return}if(t.innerHTML="",this.api.paths.forEach(r=>{let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("data-scope","signature-pad"),i.setAttribute("data-part","path"),this.spreadProps(i,this.api.getSegmentPathProps({path:r})),t.appendChild(i)}),this.api.currentPath){let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("data-scope","signature-pad"),r.setAttribute("data-part","current-path"),this.spreadProps(r,this.api.getSegmentPathProps({path:this.api.currentPath})),t.appendChild(r)}})}initMachine(t){return this.name=t.name,new ee(XE,t)}setName(t){this.name=t}setPaths(t){this.paths=t}initApi(){return YE(this.machine.service,Q)}render(){let t=this.el.querySelector('[data-scope="signature-pad"][data-part="root"]');if(!t)return;this.spreadProps(t,this.api.getRootProps());let n=t.querySelector('[data-scope="signature-pad"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps());let r=t.querySelector('[data-scope="signature-pad"][data-part="control"]');r&&this.spreadProps(r,this.api.getControlProps());let i=t.querySelector('[data-scope="signature-pad"][data-part="segment"]');i&&this.spreadProps(i,this.api.getSegmentProps());let s=t.querySelector('[data-scope="signature-pad"][data-part="guide"]');s&&this.spreadProps(s,this.api.getGuideProps());let o=t.querySelector('[data-scope="signature-pad"][data-part="clear-trigger"]');if(o){this.spreadProps(o,this.api.getClearTriggerProps());let l=this.api.paths.length>0||!!this.api.currentPath;o.hidden=!l}let a=t.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');if(a){let l=this.paths.length>0?this.paths:this.api.paths;this.paths.length===0&&this.api.paths.length>0&&(this.paths=[...this.api.paths]);let c=l.length>0?JSON.stringify(l):"";this.spreadProps(a,this.api.getHiddenInputProps({value:c})),this.name&&(a.name=this.name),a.value=c}this.syncPaths()}};zE={mounted(){let e=this.el,t=this.pushEvent.bind(this),n=O(e,"controlled"),r=gs(e,"paths"),i=gs(e,"defaultPaths"),s=new JE(e,y(m(m({id:e.id,name:x(e,"name")},n&&r.length>0?{paths:r}:void 0),!n&&i.length>0?{defaultPaths:i}:void 0),{drawing:hd(e),onDrawEnd:a=>{s.setPaths(a.paths);let l=e.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');l&&(l.value=JSON.stringify(a.paths)),a.getDataUrl("image/png").then(c=>{s.imageURL=c;let u=x(e,"onDrawEnd");u&&this.liveSocket.main.isConnected()&&t(u,{id:e.id,paths:a.paths,url:c});let h=x(e,"onDrawEndClient");h&&e.dispatchEvent(new CustomEvent(h,{bubbles:!0,detail:{id:e.id,paths:a.paths,url:c}}))})}}));if(s.init(),this.signaturePad=s,(n?r:i).length>0){let a=e.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');a&&(a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})))}this.onClear=a=>{let{id:l}=a.detail;if(l&&l!==e.id)return;s.api.clear(),s.imageURL="",s.setPaths([]);let c=e.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');c&&(c.value="")},e.addEventListener("phx:signature-pad:clear",this.onClear),this.handlers=[],this.handlers.push(this.handleEvent("signature_pad_clear",a=>{let l=a.signature_pad_id;if(l&&l!==e.id)return;s.api.clear(),s.imageURL="",s.setPaths([]);let c=e.querySelector('[data-scope="signature-pad"][data-part="hidden-input"]');c&&(c.value="")}))},updated(){var i,s;let e=O(this.el,"controlled"),t=gs(this.el,"paths"),n=gs(this.el,"defaultPaths"),r=x(this.el,"name");r&&((i=this.signaturePad)==null||i.setName(r)),(s=this.signaturePad)==null||s.updateProps(y(m(m({id:this.el.id,name:r},e&&t.length>0?{paths:t}:{}),!e&&n.length>0?{defaultPaths:n}:{}),{drawing:hd(this.el)}))},destroyed(){var e;if(this.onClear&&this.el.removeEventListener("phx:signature-pad:clear",this.onClear),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.signaturePad)==null||e.destroy()}}});var Od={};Oe(Od,{Switch:()=>aC});function rC(e,t){let{context:n,send:r,prop:i,scope:s}=e,o=!!i("disabled"),a=!!i("readOnly"),l=!!i("required"),c=!!n.get("checked"),u=!o&&n.get("focused"),h=!o&&n.get("focusVisible"),p=!o&&n.get("active"),d={"data-active":T(p),"data-focus":T(u),"data-focus-visible":T(h),"data-readonly":T(a),"data-hover":T(n.get("hovered")),"data-disabled":T(o),"data-state":c?"checked":"unchecked","data-invalid":T(i("invalid")),"data-required":T(l)};return{checked:c,disabled:o,focused:u,setChecked(g){r({type:"CHECKED.SET",checked:g,isTrusted:!1})},toggleChecked(){r({type:"CHECKED.TOGGLE",checked:c,isTrusted:!1})},getRootProps(){return t.label(y(m(m({},ps.root.attrs),d),{dir:i("dir"),id:Td(s),htmlFor:da(s),onPointerMove(){o||r({type:"CONTEXT.SET",context:{hovered:!0}})},onPointerLeave(){o||r({type:"CONTEXT.SET",context:{hovered:!1}})},onClick(g){var b;if(o)return;K(g)===ur(s)&&g.stopPropagation(),Wt()&&((b=ur(s))==null||b.focus())}}))},getLabelProps(){return t.element(y(m(m({},ps.label.attrs),d),{dir:i("dir"),id:Cd(s)}))},getThumbProps(){return t.element(y(m(m({},ps.thumb.attrs),d),{dir:i("dir"),id:eC(s),"aria-hidden":!0}))},getControlProps(){return t.element(y(m(m({},ps.control.attrs),d),{dir:i("dir"),id:tC(s),"aria-hidden":!0}))},getHiddenInputProps(){return t.input({id:da(s),type:"checkbox",required:i("required"),defaultChecked:c,disabled:o,"aria-labelledby":Cd(s),"aria-invalid":i("invalid"),name:i("name"),form:i("form"),value:i("value"),style:Hn,onFocus(){let g=Kn();r({type:"CONTEXT.SET",context:{focused:!0,focusVisible:g}})},onBlur(){r({type:"CONTEXT.SET",context:{focused:!1,focusVisible:!1}})},onClick(g){if(a){g.preventDefault();return}let v=g.currentTarget.checked;r({type:"CHECKED.SET",checked:v,isTrusted:!0})}})}}}var QE,ps,Td,Cd,eC,tC,da,nC,ur,Id,iC,sC,fO,oC,aC,Sd=fe(()=>{"use strict";zs();me();QE=Z("switch").parts("root","label","control","thumb"),ps=QE.build(),Td=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`switch:${e.id}`},Cd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`switch:${e.id}:label`},eC=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.thumb)!=null?n:`switch:${e.id}:thumb`},tC=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.control)!=null?n:`switch:${e.id}:control`},da=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.hiddenInput)!=null?n:`switch:${e.id}:input`},nC=e=>e.getById(Td(e)),ur=e=>e.getById(da(e));({not:Id}=ye()),iC={props({props:e}){return m({defaultChecked:!1,label:"switch",value:"on"},e)},initialState(){return"ready"},context({prop:e,bindable:t}){return{checked:t(()=>({defaultValue:e("defaultChecked"),value:e("checked"),onChange(n){var r;(r=e("onCheckedChange"))==null||r({checked:n})}})),fieldsetDisabled:t(()=>({defaultValue:!1})),focusVisible:t(()=>({defaultValue:!1})),active:t(()=>({defaultValue:!1})),focused:t(()=>({defaultValue:!1})),hovered:t(()=>({defaultValue:!1}))}},computed:{isDisabled:({context:e,prop:t})=>t("disabled")||e.get("fieldsetDisabled")},watch({track:e,prop:t,context:n,action:r}){e([()=>t("disabled")],()=>{r(["removeFocusIfNeeded"])}),e([()=>n.get("checked")],()=>{r(["syncInputElement"])})},effects:["trackFormControlState","trackPressEvent","trackFocusVisible"],on:{"CHECKED.TOGGLE":[{guard:Id("isTrusted"),actions:["toggleChecked","dispatchChangeEvent"]},{actions:["toggleChecked"]}],"CHECKED.SET":[{guard:Id("isTrusted"),actions:["setChecked","dispatchChangeEvent"]},{actions:["setChecked"]}],"CONTEXT.SET":{actions:["setContext"]}},states:{ready:{}},implementations:{guards:{isTrusted:({event:e})=>!!e.isTrusted},effects:{trackPressEvent({computed:e,scope:t,context:n}){if(!e("isDisabled"))return pi({pointerNode:nC(t),keyboardNode:ur(t),isValidKey:r=>r.key===" ",onPress:()=>n.set("active",!1),onPressStart:()=>n.set("active",!0),onPressEnd:()=>n.set("active",!1)})},trackFocusVisible({computed:e,scope:t}){if(!e("isDisabled"))return Si({root:t.getRootNode()})},trackFormControlState({context:e,send:t,scope:n}){return Rn(ur(n),{onFieldsetDisabledChange(r){e.set("fieldsetDisabled",r)},onFormReset(){let r=e.initial("checked");t({type:"CHECKED.SET",checked:!!r,src:"form-reset"})}})}},actions:{setContext({context:e,event:t}){for(let n in t.context)e.set(n,t.context[n])},syncInputElement({context:e,scope:t}){let n=ur(t);n&&Cr(n,!!e.get("checked"))},removeFocusIfNeeded({context:e,prop:t}){t("disabled")&&e.set("focused",!1)},setChecked({context:e,event:t}){e.set("checked",t.checked)},toggleChecked({context:e}){e.set("checked",!e.get("checked"))},dispatchChangeEvent({context:e,scope:t}){queueMicrotask(()=>{let n=ur(t);ui(n,{checked:e.get("checked")})})}}}},sC=G()(["checked","defaultChecked","dir","disabled","form","getRootNode","id","ids","invalid","label","name","onCheckedChange","readOnly","required","value"]),fO=B(sC),oC=class extends te{initMachine(e){return new ee(iC,e)}initApi(){return rC(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="switch"][data-part="root"]');if(!e)return;this.spreadProps(e,this.api.getRootProps());let t=this.el.querySelector('[data-scope="switch"][data-part="hidden-input"]');t&&this.spreadProps(t,this.api.getHiddenInputProps());let n=this.el.querySelector('[data-scope="switch"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps());let r=this.el.querySelector('[data-scope="switch"][data-part="control"]');r&&this.spreadProps(r,this.api.getControlProps());let i=this.el.querySelector('[data-scope="switch"][data-part="thumb"]');i&&this.spreadProps(i,this.api.getThumbProps())}},aC={mounted(){let e=this.el,t=this.pushEvent.bind(this);this.wasFocused=!1;let n=new oC(e,y(m({id:e.id},O(e,"controlled")?{checked:O(e,"checked")}:{defaultChecked:O(e,"defaultChecked")}),{disabled:O(e,"disabled"),name:x(e,"name"),form:x(e,"form"),value:x(e,"value"),dir:x(e,"dir",["ltr","rtl"]),invalid:O(e,"invalid"),required:O(e,"required"),readOnly:O(e,"readOnly"),label:x(e,"label"),onCheckedChange:r=>{let i=x(e,"onCheckedChange");i&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(i,{checked:r.checked,id:e.id});let s=x(e,"onCheckedChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{value:r,id:e.id}}))}}));n.init(),this.zagSwitch=n,this.onSetChecked=r=>{let{value:i}=r.detail;n.api.setChecked(i)},e.addEventListener("phx:switch:set-checked",this.onSetChecked),this.handlers=[],this.handlers.push(this.handleEvent("switch_set_checked",r=>{let i=r.id;i&&i!==e.id||n.api.setChecked(r.value)})),this.handlers.push(this.handleEvent("switch_toggle_checked",r=>{let i=r.id;i&&i!==e.id||n.api.toggleChecked()})),this.handlers.push(this.handleEvent("switch_checked",()=>{this.pushEvent("switch_checked_response",{value:n.api.checked})})),this.handlers.push(this.handleEvent("switch_focused",()=>{this.pushEvent("switch_focused_response",{value:n.api.focused})})),this.handlers.push(this.handleEvent("switch_disabled",()=>{this.pushEvent("switch_disabled_response",{value:n.api.disabled})}))},beforeUpdate(){var e,t;this.wasFocused=(t=(e=this.zagSwitch)==null?void 0:e.api.focused)!=null?t:!1},updated(){var e;if((e=this.zagSwitch)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{checked:O(this.el,"checked")}:{defaultChecked:O(this.el,"defaultChecked")}),{disabled:O(this.el,"disabled"),name:x(this.el,"name"),form:x(this.el,"form"),value:x(this.el,"value"),dir:x(this.el,"dir",["ltr","rtl"]),invalid:O(this.el,"invalid"),required:O(this.el,"required"),readOnly:O(this.el,"readOnly"),label:x(this.el,"label")})),O(this.el,"controlled")&&this.wasFocused){let t=this.el.querySelector('[data-part="hidden-input"]');t==null||t.focus()}},destroyed(){var e;if(this.onSetChecked&&this.el.removeEventListener("phx:switch:set-checked",this.onSetChecked),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.zagSwitch)==null||e.destroy()}}});var xd={};Oe(xd,{Tabs:()=>OC});function vC(e,t){let{state:n,send:r,context:i,prop:s,scope:o}=e,a=s("translations"),l=n.matches("focused"),c=s("orientation")==="vertical",u=s("orientation")==="horizontal",h=s("composite");function p(d){return{selected:i.get("value")===d.value,focused:i.get("focusedValue")===d.value,disabled:!!d.disabled}}return{value:i.get("value"),focusedValue:i.get("focusedValue"),setValue(d){r({type:"SET_VALUE",value:d})},clearValue(){r({type:"CLEAR_VALUE"})},setIndicatorRect(d){let g=Pn(o,d);r({type:"SET_INDICATOR_RECT",id:g})},syncTabIndex(){r({type:"SYNC_TAB_INDEX"})},selectNext(d){r({type:"TAB_FOCUS",value:d,src:"selectNext"}),r({type:"ARROW_NEXT",src:"selectNext"})},selectPrev(d){r({type:"TAB_FOCUS",value:d,src:"selectPrev"}),r({type:"ARROW_PREV",src:"selectPrev"})},focus(){var g;let d=i.get("value");d&&((g=ms(o,d))==null||g.focus())},getRootProps(){return t.element(y(m({},Kr.root.attrs),{id:cC(o),"data-orientation":s("orientation"),"data-focus":T(l),dir:s("dir")}))},getListProps(){return t.element(y(m({},Kr.list.attrs),{id:Yr(o),role:"tablist",dir:s("dir"),"data-focus":T(l),"aria-orientation":s("orientation"),"data-orientation":s("orientation"),"aria-label":a==null?void 0:a.listLabel,onKeyDown(d){if(d.defaultPrevented||Vt(d)||!pe(d.currentTarget,K(d)))return;let g={ArrowDown(){u||r({type:"ARROW_NEXT",key:"ArrowDown"})},ArrowUp(){u||r({type:"ARROW_PREV",key:"ArrowUp"})},ArrowLeft(){c||r({type:"ARROW_PREV",key:"ArrowLeft"})},ArrowRight(){c||r({type:"ARROW_NEXT",key:"ArrowRight"})},Home(){r({type:"HOME"})},End(){r({type:"END"})}},v=ve(d,{dir:s("dir"),orientation:s("orientation")}),b=g[v];if(b){d.preventDefault(),b(d);return}}}))},getTriggerState:p,getTriggerProps(d){let{value:g,disabled:v}=d,b=p(d);return t.button(y(m({},Kr.trigger.attrs),{role:"tab",type:"button",disabled:v,dir:s("dir"),"data-orientation":s("orientation"),"data-disabled":T(v),"aria-disabled":v,"data-value":g,"aria-selected":b.selected,"data-selected":T(b.selected),"data-focus":T(b.focused),"aria-controls":b.selected?ha(o,g):void 0,"data-ownedby":Yr(o),"data-ssr":T(i.get("ssr")),id:Pn(o,g),tabIndex:b.selected&&h?0:-1,onFocus(){r({type:"TAB_FOCUS",value:g})},onBlur(V){let S=V.relatedTarget;(S==null?void 0:S.getAttribute("role"))!=="tab"&&r({type:"TAB_BLUR"})},onClick(V){V.defaultPrevented||sn(V)||v||(Wt()&&V.currentTarget.focus(),r({type:"TAB_CLICK",value:g}))}}))},getContentProps(d){let{value:g}=d,v=i.get("value")===g;return t.element(y(m({},Kr.content.attrs),{dir:s("dir"),id:ha(o,g),tabIndex:h?0:-1,"aria-labelledby":Pn(o,g),role:"tabpanel","data-ownedby":Yr(o),"data-selected":T(v),"data-orientation":s("orientation"),hidden:!v}))},getIndicatorProps(){let d=i.get("indicatorRect"),g=d==null||d.width===0&&d.height===0&&d.x===0&&d.y===0;return t.element(y(m({id:wd(o)},Kr.indicator.attrs),{dir:s("dir"),"data-orientation":s("orientation"),hidden:g,style:{"--transition-property":"left, right, top, bottom, width, height","--left":Ae(d==null?void 0:d.x),"--top":Ae(d==null?void 0:d.y),"--width":Ae(d==null?void 0:d.width),"--height":Ae(d==null?void 0:d.height),position:"absolute",willChange:"var(--transition-property)",transitionProperty:"var(--transition-property)",transitionDuration:"var(--transition-duration, 150ms)",transitionTimingFunction:"var(--transition-timing-function)",[u?"left":"top"]:u?"var(--left)":"var(--top)"}}))}}}var lC,Kr,cC,Yr,ha,Pn,wd,uC,dC,ms,Pd,dr,hC,gC,fC,pC,Vd,mC,yC,bC,EC,yO,CC,bO,IC,EO,TC,OC,kd=fe(()=>{"use strict";me();lC=Z("tabs").parts("root","list","trigger","content","indicator"),Kr=lC.build(),cC=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`tabs:${e.id}`},Yr=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.list)!=null?n:`tabs:${e.id}:list`},ha=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.content)==null?void 0:r.call(n,t))!=null?i:`tabs:${e.id}:content-${t}`},Pn=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.trigger)==null?void 0:r.call(n,t))!=null?i:`tabs:${e.id}:trigger-${t}`},wd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.indicator)!=null?n:`tabs:${e.id}:indicator`},uC=e=>e.getById(Yr(e)),dC=(e,t)=>e.getById(ha(e,t)),ms=(e,t)=>t!=null?e.getById(Pn(e,t)):null,Pd=e=>e.getById(wd(e)),dr=e=>{let n=`[role=tab][data-ownedby='${CSS.escape(Yr(e))}']:not([disabled])`;return dt(uC(e),n)},hC=e=>Ke(dr(e)),gC=e=>nt(dr(e)),fC=(e,t)=>$n(dr(e),Pn(e,t.value),t.loopFocus),pC=(e,t)=>_n(dr(e),Pn(e,t.value),t.loopFocus),Vd=e=>{var t,n,r,i;return{x:(t=e==null?void 0:e.offsetLeft)!=null?t:0,y:(n=e==null?void 0:e.offsetTop)!=null?n:0,width:(r=e==null?void 0:e.offsetWidth)!=null?r:0,height:(i=e==null?void 0:e.offsetHeight)!=null?i:0}},mC=(e,t)=>{let n=Us(dr(e),Pn(e,t));return Vd(n)};({createMachine:yC}=Wn()),bC=yC({props({props:e}){return m({dir:"ltr",orientation:"horizontal",activationMode:"automatic",loopFocus:!0,composite:!0,navigate(t){Fn(t.node)},defaultValue:null},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(n){var r;(r=e("onValueChange"))==null||r({value:n})}})),focusedValue:t(()=>({defaultValue:e("value")||e("defaultValue"),sync:!0,onChange(n){var r;(r=e("onFocusChange"))==null||r({focusedValue:n})}})),ssr:t(()=>({defaultValue:!0})),indicatorRect:t(()=>({defaultValue:null}))}},watch({context:e,prop:t,track:n,action:r}){n([()=>e.get("value")],()=>{r(["syncIndicatorRect","syncTabIndex","navigateIfNeeded"])}),n([()=>t("dir"),()=>t("orientation")],()=>{r(["syncIndicatorRect"])})},on:{SET_VALUE:{actions:["setValue"]},CLEAR_VALUE:{actions:["clearValue"]},SET_INDICATOR_RECT:{actions:["setIndicatorRect"]},SYNC_TAB_INDEX:{actions:["syncTabIndex"]}},entry:["syncIndicatorRect","syncTabIndex","syncSsr"],exit:["cleanupObserver"],states:{idle:{on:{TAB_FOCUS:{target:"focused",actions:["setFocusedValue"]},TAB_CLICK:{target:"focused",actions:["setFocusedValue","setValue"]}}},focused:{on:{TAB_CLICK:{actions:["setFocusedValue","setValue"]},ARROW_PREV:[{guard:"selectOnFocus",actions:["focusPrevTab","selectFocusedTab"]},{actions:["focusPrevTab"]}],ARROW_NEXT:[{guard:"selectOnFocus",actions:["focusNextTab","selectFocusedTab"]},{actions:["focusNextTab"]}],HOME:[{guard:"selectOnFocus",actions:["focusFirstTab","selectFocusedTab"]},{actions:["focusFirstTab"]}],END:[{guard:"selectOnFocus",actions:["focusLastTab","selectFocusedTab"]},{actions:["focusLastTab"]}],TAB_FOCUS:{actions:["setFocusedValue"]},TAB_BLUR:{target:"idle",actions:["clearFocusedValue"]}}}},implementations:{guards:{selectOnFocus:({prop:e})=>e("activationMode")==="automatic"},actions:{selectFocusedTab({context:e,prop:t}){H(()=>{let n=e.get("focusedValue");if(!n)return;let i=t("deselectable")&&e.get("value")===n?null:n;e.set("value",i)})},setFocusedValue({context:e,event:t,flush:n}){t.value!=null&&n(()=>{e.set("focusedValue",t.value)})},clearFocusedValue({context:e}){e.set("focusedValue",null)},setValue({context:e,event:t,prop:n}){let r=n("deselectable")&&e.get("value")===e.get("focusedValue");e.set("value",r?null:t.value)},clearValue({context:e}){e.set("value",null)},focusFirstTab({scope:e}){H(()=>{var t;(t=hC(e))==null||t.focus()})},focusLastTab({scope:e}){H(()=>{var t;(t=gC(e))==null||t.focus()})},focusNextTab({context:e,prop:t,scope:n,event:r}){var o;let i=(o=r.value)!=null?o:e.get("focusedValue");if(!i)return;let s=fC(n,{value:i,loopFocus:t("loopFocus")});H(()=>{t("composite")?s==null||s.focus():(s==null?void 0:s.dataset.value)!=null&&e.set("focusedValue",s.dataset.value)})},focusPrevTab({context:e,prop:t,scope:n,event:r}){var o;let i=(o=r.value)!=null?o:e.get("focusedValue");if(!i)return;let s=pC(n,{value:i,loopFocus:t("loopFocus")});H(()=>{t("composite")?s==null||s.focus():(s==null?void 0:s.dataset.value)!=null&&e.set("focusedValue",s.dataset.value)})},syncTabIndex({context:e,scope:t}){H(()=>{let n=e.get("value");if(!n)return;let r=dC(t,n);if(!r)return;Ir(r).length>0?r.removeAttribute("tabindex"):r.setAttribute("tabindex","0")})},cleanupObserver({refs:e}){let t=e.get("indicatorCleanup");t&&t()},setIndicatorRect({context:e,event:t,scope:n}){var o;let r=(o=t.id)!=null?o:e.get("value");!Pd(n)||!r||!ms(n,r)||e.set("indicatorRect",mC(n,r))},syncSsr({context:e}){e.set("ssr",!1)},syncIndicatorRect({context:e,refs:t,scope:n}){let r=t.get("indicatorCleanup");if(r&&r(),!Pd(n))return;let s=()=>{let l=ms(n,e.get("value"));if(!l)return;let c=Vd(l);e.set("indicatorRect",u=>he(u,c)?u:c)};s();let o=dr(n),a=Bn(...o.map(l=>Ja.observe(l,s)));t.set("indicatorCleanup",a)},navigateIfNeeded({context:e,prop:t,scope:n}){var s;let r=e.get("value");if(!r)return;let i=ms(n,r);We(i)&&((s=t("navigate"))==null||s({value:r,node:i,href:i.href}))}}}}),EC=G()(["activationMode","composite","deselectable","dir","getRootNode","id","ids","loopFocus","navigate","onFocusChange","onValueChange","orientation","translations","value","defaultValue"]),yO=B(EC),CC=G()(["disabled","value"]),bO=B(CC),IC=G()(["value"]),EO=B(IC),TC=class extends te{initMachine(e){return new ee(bC,e)}initApi(){return vC(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="tabs"][data-part="root"]');if(!e)return;this.spreadProps(e,this.api.getRootProps());let t=e.querySelector('[data-scope="tabs"][data-part="list"]');if(!t)return;this.spreadProps(t,this.api.getListProps());let n=this.el.getAttribute("data-items"),r=n?JSON.parse(n):[],i=t.querySelectorAll('[data-scope="tabs"][data-part="trigger"]');for(let o=0;o{var o,a;let i=x(e,"onValueChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,value:(o=r.value)!=null?o:null});let s=x(e,"onValueChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,value:(a=r.value)!=null?a:null}}))},onFocusChange:r=>{var o,a;let i=x(e,"onFocusChange");i&&this.liveSocket.main.isConnected()&&t(i,{id:e.id,value:(o=r.focusedValue)!=null?o:null});let s=x(e,"onFocusChangeClient");s&&e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{id:e.id,value:(a=r.focusedValue)!=null?a:null}}))}}));n.init(),this.tabs=n,this.onSetValue=r=>{let{value:i}=r.detail;n.api.setValue(i)},e.addEventListener("phx:tabs:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("tabs_set_value",r=>{let i=r.tabs_id;i&&i!==e.id||n.api.setValue(r.value)})),this.handlers.push(this.handleEvent("tabs_value",()=>{this.pushEvent("tabs_value_response",{value:n.api.value})})),this.handlers.push(this.handleEvent("tabs_focused_value",()=>{this.pushEvent("tabs_focused_value_response",{value:n.api.focusedValue})}))},updated(){var e;(e=this.tabs)==null||e.updateProps(y(m({id:this.el.id},O(this.el,"controlled")?{value:x(this.el,"value")}:{defaultValue:x(this.el,"defaultValue")}),{orientation:x(this.el,"orientation",["horizontal","vertical"]),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:tabs:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.tabs)==null||e.destroy()}}});var _d={};Oe(_d,{Toast:()=>jC});function ga(e,t){var n;return(n=e!=null?e:Ld[t])!=null?n:Ld.DEFAULT}function xC(e,t){var v;let{prop:n,computed:r,context:i}=e,{offsets:s,gap:o}=n("store").attrs,a=i.get("heights"),l=VC(s),c=n("dir")==="rtl",u=t.replace("-start",c?"-right":"-left").replace("-end",c?"-left":"-right"),h=u.includes("right"),p=u.includes("left"),d={position:"fixed",pointerEvents:r("count")>0?void 0:"none",display:"flex",flexDirection:"column","--gap":`${o}px`,"--first-height":`${((v=a[0])==null?void 0:v.height)||0}px`,"--viewport-offset-left":l.left,"--viewport-offset-right":l.right,"--viewport-offset-top":l.top,"--viewport-offset-bottom":l.bottom,zIndex:Ra},g="center";if(h&&(g="flex-end"),p&&(g="flex-start"),d.alignItems=g,u.includes("top")){let b=l.top;d.top=`max(env(safe-area-inset-top, 0px), ${b})`}if(u.includes("bottom")){let b=l.bottom;d.bottom=`max(env(safe-area-inset-bottom, 0px), ${b})`}if(!u.includes("left")){let b=l.right;d.insetInlineEnd=`calc(env(safe-area-inset-right, 0px) + ${b})`}if(!u.includes("right")){let b=l.left;d.insetInlineStart=`calc(env(safe-area-inset-left, 0px) + ${b})`}return d}function kC(e,t){let{prop:n,context:r,computed:i}=e,s=n("parent"),o=s.computed("placement"),{gap:a}=s.prop("store").attrs,[l]=o.split("-"),c=r.get("mounted"),u=r.get("remainingTime"),h=i("height"),p=i("frontmost"),d=!p,g=!n("stacked"),v=n("stacked"),V=n("type")==="loading"?Number.MAX_SAFE_INTEGER:u,S=i("heightIndex")*a+i("heightBefore"),E={position:"absolute",pointerEvents:"auto","--opacity":"0","--remove-delay":`${n("removeDelay")}ms`,"--duration":`${V}ms`,"--initial-height":`${h}px`,"--offset":`${S}px`,"--index":n("index"),"--z-index":i("zIndex"),"--lift-amount":"calc(var(--lift) * var(--gap))","--y":"100%","--x":"0"},f=C=>Object.assign(E,C);return l==="top"?f({top:"0","--sign":"-1","--y":"-100%","--lift":"1"}):l==="bottom"&&f({bottom:"0","--sign":"1","--y":"100%","--lift":"-1"}),c&&(f({"--y":"0","--opacity":"1"}),v&&f({"--y":"calc(var(--lift) * var(--offset))","--height":"var(--initial-height)"})),t||f({"--opacity":"0",pointerEvents:"none"}),d&&g&&(f({"--base-scale":"var(--index) * 0.05 + 1","--y":"calc(var(--lift-amount) * var(--index))","--scale":"calc(-1 * var(--base-scale))","--height":"var(--first-height)"}),t||f({"--y":"calc(var(--sign) * 40%)"})),d&&v&&!t&&f({"--y":"calc(var(--lift) * var(--offset) + var(--lift) * -100%)"}),p&&!t&&f({"--y":"calc(var(--lift) * -100%)"}),E}function NC(e,t){let{computed:n}=e,r={position:"absolute",inset:"0",scale:"1 2",pointerEvents:t?"none":"auto"},i=s=>Object.assign(r,s);return n("frontmost")&&!t&&i({height:"calc(var(--initial-height) + 80%)"}),r}function AC(){return{position:"absolute",left:"0",height:"calc(var(--gap) + 2px)",bottom:"100%",width:"100%"}}function RC(e,t){let{context:n,prop:r,send:i,refs:s,computed:o}=e;return{getCount(){return n.get("toasts").length},getToasts(){return n.get("toasts")},getGroupProps(a={}){let{label:l="Notifications"}=a,{hotkey:c}=r("store").attrs,u=c.join("+").replace(/Key/g,"").replace(/Digit/g,""),h=o("placement"),[p,d="center"]=h.split("-");return t.element(y(m({},hr.group.attrs),{dir:r("dir"),tabIndex:-1,"aria-label":`${h} ${l} ${u}`,id:PC(h),"data-placement":h,"data-side":p,"data-align":d,"aria-live":"polite",role:"region",style:xC(e,h),onMouseEnter(){s.get("ignoreMouseTimer").isActive()||i({type:"REGION.POINTER_ENTER",placement:h})},onMouseMove(){s.get("ignoreMouseTimer").isActive()||i({type:"REGION.POINTER_ENTER",placement:h})},onMouseLeave(){s.get("ignoreMouseTimer").isActive()||i({type:"REGION.POINTER_LEAVE",placement:h})},onFocus(g){i({type:"REGION.FOCUS",target:g.relatedTarget})},onBlur(g){s.get("isFocusWithin")&&!pe(g.currentTarget,g.relatedTarget)&&queueMicrotask(()=>i({type:"REGION.BLUR"}))}}))},subscribe(a){return r("store").subscribe(()=>a(n.get("toasts")))}}}function $C(e,t){let{state:n,send:r,prop:i,scope:s,context:o,computed:a}=e,l=n.hasTag("visible"),c=n.hasTag("paused"),u=o.get("mounted"),h=a("frontmost"),p=i("parent").computed("placement"),d=i("type"),g=i("stacked"),v=i("title"),b=i("description"),V=i("action"),[S,E="center"]=p.split("-");return{type:d,title:v,description:b,placement:p,visible:l,paused:c,closable:!!i("closable"),pause(){r({type:"PAUSE"})},resume(){r({type:"RESUME"})},dismiss(){r({type:"DISMISS",src:"programmatic"})},getRootProps(){return t.element(y(m({},hr.root.attrs),{dir:i("dir"),id:$d(s),"data-state":l?"open":"closed","data-type":d,"data-placement":p,"data-align":E,"data-side":S,"data-mounted":T(u),"data-paused":T(c),"data-first":T(h),"data-sibling":T(!h),"data-stack":T(g),"data-overlap":T(!g),role:"status","aria-atomic":"true","aria-describedby":b?Dd(s):void 0,"aria-labelledby":v?Rd(s):void 0,tabIndex:0,style:kC(e,l),onKeyDown(f){f.defaultPrevented||f.key=="Escape"&&(r({type:"DISMISS",src:"keyboard"}),f.preventDefault())}}))},getGhostBeforeProps(){return t.element({"data-ghost":"before",style:NC(e,l)})},getGhostAfterProps(){return t.element({"data-ghost":"after",style:AC()})},getTitleProps(){return t.element(y(m({},hr.title.attrs),{id:Rd(s)}))},getDescriptionProps(){return t.element(y(m({},hr.description.attrs),{id:Dd(s)}))},getActionTriggerProps(){return t.button(y(m({},hr.actionTrigger.attrs),{type:"button",onClick(f){var C;f.defaultPrevented||((C=V==null?void 0:V.onClick)==null||C.call(V),r({type:"DISMISS",src:"user"}))}}))},getCloseTriggerProps(){return t.button(y(m({id:wC(s)},hr.closeTrigger.attrs),{type:"button","aria-label":"Dismiss notification",onClick(f){f.defaultPrevented||r({type:"DISMISS",src:"user"})}}))}}}function Fd(e,t){let{id:n,height:r}=t;e.context.set("heights",i=>i.find(o=>o.id===n)?i.map(o=>o.id===n?y(m({},o),{height:r}):o):[{id:n,height:r},...i])}function GC(e={}){let t=BC(e,{placement:"bottom",overlap:!1,max:24,gap:16,offsets:"1rem",hotkey:["altKey","KeyT"],removeDelay:200,pauseOnPageIdle:!0}),n=[],r=[],i=new Set,s=[],o=L=>(n.push(L),()=>{let M=n.indexOf(L);n.splice(M,1)}),a=L=>(n.forEach(M=>M(L)),L),l=L=>{if(r.length>=t.max){s.push(L);return}a(L),r.unshift(L)},c=()=>{for(;s.length>0&&r.length{var q;let M=(q=L.id)!=null?q:`toast:${js()}`,j=r.find(J=>J.id===M);return i.has(M)&&i.delete(M),j?r=r.map(J=>J.id===M?a(y(m(m({},J),L),{id:M})):J):l(y(m({id:M,duration:t.duration,removeDelay:t.removeDelay,type:"info"},L),{stacked:!t.overlap,gap:t.gap})),M},h=L=>(i.add(L),L?(n.forEach(M=>M({id:L,dismiss:!0})),r=r.filter(M=>M.id!==L),c()):(r.forEach(M=>{n.forEach(j=>j({id:M.id,dismiss:!0}))}),r=[],s=[]),L);return{attrs:t,subscribe:o,create:u,update:(L,M)=>u(m({id:L},M)),remove:h,dismiss:L=>{L!=null?r=r.map(M=>M.id===L?a(y(m({},M),{message:"DISMISS"})):M):r=r.map(M=>a(y(m({},M),{message:"DISMISS"})))},error:L=>u(y(m({},L),{type:"error"})),success:L=>u(y(m({},L),{type:"success"})),info:L=>u(y(m({},L),{type:"info"})),warning:L=>u(y(m({},L),{type:"warning"})),loading:L=>u(y(m({},L),{type:"loading"})),getVisibleToasts:()=>r.filter(L=>!i.has(L.id)),getCount:()=>r.length,promise:(L,M,j={})=>{if(!M||!M.loading){wt("[zag-js > toast] toaster.promise() requires at least a 'loading' option to be specified");return}let q=u(y(m(m({},j),M.loading),{promise:L,type:"loading"})),J=!0,W,ge=St(L).then(X=>Ee(null,null,function*(){if(W=["resolve",X],UC(X)&&!X.ok){J=!1;let ue=St(M.error,`HTTP Error! status: ${X.status}`);u(y(m(m({},j),ue),{id:q,type:"error"}))}else if(M.success!==void 0){J=!1;let ue=St(M.success,X);u(y(m(m({},j),ue),{id:q,type:"success"}))}})).catch(X=>Ee(null,null,function*(){if(W=["reject",X],M.error!==void 0){J=!1;let ue=St(M.error,X);u(y(m(m({},j),ue),{id:q,type:"error"}))}})).finally(()=>{var X;J&&h(q),(X=M.finally)==null||X.call(M)});return{id:q,unwrap:()=>new Promise((X,ue)=>ge.then(()=>W[0]==="reject"?ue(W[1]):X(W[1])).catch(ue))}},pause:L=>{L!=null?r=r.map(M=>M.id===L?a(y(m({},M),{message:"PAUSE"})):M):r=r.map(M=>a(y(m({},M),{message:"PAUSE"})))},resume:L=>{L!=null?r=r.map(M=>M.id===L?a(y(m({},M),{message:"RESUME"})):M):r=r.map(M=>a(y(m({},M),{message:"RESUME"})))},isVisible:L=>!i.has(L)&&!!r.find(M=>M.id===L),isDismissed:L=>i.has(L),expand:()=>{r=r.map(L=>a(y(m({},L),{stacked:!0})))},collapse:()=>{r=r.map(L=>a(y(m({},L),{stacked:!1})))}}}function YC(e,t){var s,o,a;let n=(s=t==null?void 0:t.id)!=null?s:rn(e,"toast"),r=(a=t==null?void 0:t.store)!=null?a:GC({placement:(o=t==null?void 0:t.placement)!=null?o:"bottom",overlap:t==null?void 0:t.overlap,max:t==null?void 0:t.max,gap:t==null?void 0:t.gap,offsets:t==null?void 0:t.offsets,pauseOnPageIdle:t==null?void 0:t.pauseOnPageIdle}),i=new KC(e,{id:n,store:r});return i.init(),qC.set(n,i),fa.set(n,r),e.dataset.toastGroup="true",e.dataset.toastGroupId=n,{group:i,store:r}}function jr(e){if(e)return fa.get(e);let t=document.querySelector("[data-toast-group]");if(!t)return;let n=t.dataset.toastGroupId||t.id;return n?fa.get(n):void 0}var SC,hr,PC,Nd,$d,Ad,Rd,Dd,wC,Ld,VC,DC,LC,FC,MC,_C,HC,BC,UC,Md,qC,fa,WC,KC,jC,Hd=fe(()=>{"use strict";gn();me();SC=Z("toast").parts("group","root","title","description","actionTrigger","closeTrigger"),hr=SC.build(),PC=e=>`toast-group:${e}`,Nd=(e,t)=>e.getById(`toast-group:${t}`),$d=e=>`toast:${e.id}`,Ad=e=>e.getById($d(e)),Rd=e=>`toast:${e.id}:title`,Dd=e=>`toast:${e.id}:description`,wC=e=>`toast${e.id}:close`,Ld={info:5e3,error:5e3,success:2e3,loading:1/0,DEFAULT:5e3};VC=e=>typeof e=="string"?{left:e,right:e,bottom:e,top:e}:e;({guards:DC,createMachine:LC}=Wn()),{and:FC}=DC,MC=LC({props({props:e}){return y(m({dir:"ltr",id:js()},e),{store:e.store})},initialState({prop:e}){return e("store").attrs.overlap?"overlap":"stack"},refs(){return{lastFocusedEl:null,isFocusWithin:!1,isPointerWithin:!1,ignoreMouseTimer:$s.create(),dismissableCleanup:void 0}},context({bindable:e}){return{toasts:e(()=>({defaultValue:[],sync:!0,hash:t=>t.map(n=>n.id).join(",")})),heights:e(()=>({defaultValue:[],sync:!0}))}},computed:{count:({context:e})=>e.get("toasts").length,overlap:({prop:e})=>e("store").attrs.overlap,placement:({prop:e})=>e("store").attrs.placement},effects:["subscribeToStore","trackDocumentVisibility","trackHotKeyPress"],watch({track:e,context:t,action:n}){e([()=>t.hash("toasts")],()=>{queueMicrotask(()=>{n(["collapsedIfEmpty","setDismissableBranch"])})})},exit:["clearDismissableBranch","clearLastFocusedEl","clearMouseEventTimer"],on:{"DOC.HOTKEY":{actions:["focusRegionEl"]},"REGION.BLUR":[{guard:FC("isOverlapping","isPointerOut"),target:"overlap",actions:["collapseToasts","resumeToasts","restoreFocusIfPointerOut"]},{guard:"isPointerOut",target:"stack",actions:["resumeToasts","restoreFocusIfPointerOut"]},{actions:["clearFocusWithin"]}],"TOAST.REMOVE":{actions:["removeToast","removeHeight","ignoreMouseEventsTemporarily"]},"TOAST.PAUSE":{actions:["pauseToasts"]}},states:{stack:{on:{"REGION.POINTER_LEAVE":[{guard:"isOverlapping",target:"overlap",actions:["clearPointerWithin","resumeToasts","collapseToasts"]},{actions:["clearPointerWithin","resumeToasts"]}],"REGION.OVERLAP":{target:"overlap",actions:["collapseToasts"]},"REGION.FOCUS":{actions:["setLastFocusedEl","pauseToasts"]},"REGION.POINTER_ENTER":{actions:["setPointerWithin","pauseToasts"]}}},overlap:{on:{"REGION.STACK":{target:"stack",actions:["expandToasts"]},"REGION.POINTER_ENTER":{target:"stack",actions:["setPointerWithin","pauseToasts","expandToasts"]},"REGION.FOCUS":{target:"stack",actions:["setLastFocusedEl","pauseToasts","expandToasts"]}}}},implementations:{guards:{isOverlapping:({computed:e})=>e("overlap"),isPointerOut:({refs:e})=>!e.get("isPointerWithin")},effects:{subscribeToStore({context:e,prop:t}){let n=t("store");return e.set("toasts",n.getVisibleToasts()),n.subscribe(r=>{if(r.dismiss){e.set("toasts",i=>i.filter(s=>s.id!==r.id));return}e.set("toasts",i=>{let s=i.findIndex(o=>o.id===r.id);return s!==-1?[...i.slice(0,s),m(m({},i[s]),r),...i.slice(s+1)]:[r,...i]})})},trackHotKeyPress({prop:e,send:t}){return ie(document,"keydown",r=>{let{hotkey:i}=e("store").attrs;i.every(o=>r[o]||r.code===o)&&t({type:"DOC.HOTKEY"})},{capture:!0})},trackDocumentVisibility({prop:e,send:t,scope:n}){let{pauseOnPageIdle:r}=e("store").attrs;if(!r)return;let i=n.getDoc();return ie(i,"visibilitychange",()=>{let s=i.visibilityState==="hidden";t({type:s?"PAUSE_ALL":"RESUME_ALL"})})}},actions:{setDismissableBranch({refs:e,context:t,computed:n,scope:r}){var c;let i=t.get("toasts"),s=n("placement"),o=i.length>0;if(!o){(c=e.get("dismissableCleanup"))==null||c();return}if(o&&e.get("dismissableCleanup"))return;let l=mc(()=>Nd(r,s),{defer:!0});e.set("dismissableCleanup",l)},clearDismissableBranch({refs:e}){var t;(t=e.get("dismissableCleanup"))==null||t()},focusRegionEl({scope:e,computed:t}){queueMicrotask(()=>{var n;(n=Nd(e,t("placement")))==null||n.focus()})},pauseToasts({prop:e}){e("store").pause()},resumeToasts({prop:e}){e("store").resume()},expandToasts({prop:e}){e("store").expand()},collapseToasts({prop:e}){e("store").collapse()},removeToast({prop:e,event:t}){e("store").remove(t.id)},removeHeight({event:e,context:t}){(e==null?void 0:e.id)!=null&&queueMicrotask(()=>{t.set("heights",n=>n.filter(r=>r.id!==e.id))})},collapsedIfEmpty({send:e,computed:t}){!t("overlap")||t("count")>1||e({type:"REGION.OVERLAP"})},setLastFocusedEl({refs:e,event:t}){e.get("isFocusWithin")||!t.target||(e.set("isFocusWithin",!0),e.set("lastFocusedEl",t.target))},restoreFocusIfPointerOut({refs:e}){var t;!e.get("lastFocusedEl")||e.get("isPointerWithin")||((t=e.get("lastFocusedEl"))==null||t.focus({preventScroll:!0}),e.set("lastFocusedEl",null),e.set("isFocusWithin",!1))},setPointerWithin({refs:e}){e.set("isPointerWithin",!0)},clearPointerWithin({refs:e}){var t;e.set("isPointerWithin",!1),e.get("lastFocusedEl")&&!e.get("isFocusWithin")&&((t=e.get("lastFocusedEl"))==null||t.focus({preventScroll:!0}),e.set("lastFocusedEl",null))},clearFocusWithin({refs:e}){e.set("isFocusWithin",!1)},clearLastFocusedEl({refs:e}){var t;e.get("lastFocusedEl")&&((t=e.get("lastFocusedEl"))==null||t.focus({preventScroll:!0}),e.set("lastFocusedEl",null),e.set("isFocusWithin",!1))},ignoreMouseEventsTemporarily({refs:e}){e.get("ignoreMouseTimer").request()},clearMouseEventTimer({refs:e}){e.get("ignoreMouseTimer").cancel()}}}});({not:_C}=ye()),HC={props({props:e}){return yi(e,["id","type","parent","removeDelay"],"toast"),y(m({closable:!0},e),{duration:ga(e.duration,e.type)})},initialState({prop:e}){return e("type")==="loading"||e("duration")===1/0?"visible:persist":"visible"},context({prop:e,bindable:t}){return{remainingTime:t(()=>({defaultValue:ga(e("duration"),e("type"))})),createdAt:t(()=>({defaultValue:Date.now()})),mounted:t(()=>({defaultValue:!1})),initialHeight:t(()=>({defaultValue:0}))}},refs(){return{closeTimerStartTime:Date.now(),lastCloseStartTimerStartTime:0}},computed:{zIndex:({prop:e})=>{let t=e("parent").context.get("toasts"),n=t.findIndex(r=>r.id===e("id"));return t.length-n},height:({prop:e})=>{var r;let n=e("parent").context.get("heights").find(i=>i.id===e("id"));return(r=n==null?void 0:n.height)!=null?r:0},heightIndex:({prop:e})=>e("parent").context.get("heights").findIndex(n=>n.id===e("id")),frontmost:({prop:e})=>e("index")===0,heightBefore:({prop:e})=>{let t=e("parent").context.get("heights"),n=t.findIndex(r=>r.id===e("id"));return t.reduce((r,i,s)=>s>=n?r:r+i.height,0)},shouldPersist:({prop:e})=>e("type")==="loading"||e("duration")===1/0},watch({track:e,prop:t,send:n}){e([()=>t("message")],()=>{let r=t("message");r&&n({type:r,src:"programmatic"})}),e([()=>t("type"),()=>t("duration")],()=>{n({type:"UPDATE"})})},on:{UPDATE:[{guard:"shouldPersist",target:"visible:persist",actions:["resetCloseTimer"]},{target:"visible:updating",actions:["resetCloseTimer"]}],MEASURE:{actions:["measureHeight"]}},entry:["setMounted","measureHeight","invokeOnVisible"],effects:["trackHeight"],states:{"visible:updating":{tags:["visible","updating"],effects:["waitForNextTick"],on:{SHOW:{target:"visible"}}},"visible:persist":{tags:["visible","paused"],on:{RESUME:{guard:_C("isLoadingType"),target:"visible",actions:["setCloseTimer"]},DISMISS:{target:"dismissing"}}},visible:{tags:["visible"],effects:["waitForDuration"],on:{DISMISS:{target:"dismissing"},PAUSE:{target:"visible:persist",actions:["syncRemainingTime"]}}},dismissing:{entry:["invokeOnDismiss"],effects:["waitForRemoveDelay"],on:{REMOVE:{target:"unmounted",actions:["notifyParentToRemove"]}}},unmounted:{entry:["invokeOnUnmount"]}},implementations:{effects:{waitForRemoveDelay({prop:e,send:t}){return Un(()=>{t({type:"REMOVE",src:"timer"})},e("removeDelay"))},waitForDuration({send:e,context:t,computed:n}){if(!n("shouldPersist"))return Un(()=>{e({type:"DISMISS",src:"timer"})},t.get("remainingTime"))},waitForNextTick({send:e}){return Un(()=>{e({type:"SHOW",src:"timer"})},0)},trackHeight({scope:e,prop:t}){let n;return H(()=>{let r=Ad(e);if(!r)return;let i=()=>{let a=r.style.height;r.style.height="auto";let l=r.getBoundingClientRect().height;r.style.height=a;let c={id:t("id"),height:l};Fd(t("parent"),c)},s=e.getWin(),o=new s.MutationObserver(i);o.observe(r,{childList:!0,subtree:!0,characterData:!0}),n=()=>o.disconnect()}),()=>n==null?void 0:n()}},guards:{isLoadingType:({prop:e})=>e("type")==="loading",shouldPersist:({computed:e})=>e("shouldPersist")},actions:{setMounted({context:e}){H(()=>{e.set("mounted",!0)})},measureHeight({scope:e,prop:t,context:n}){queueMicrotask(()=>{let r=Ad(e);if(!r)return;let i=r.style.height;r.style.height="auto";let s=r.getBoundingClientRect().height;r.style.height=i,n.set("initialHeight",s);let o={id:t("id"),height:s};Fd(t("parent"),o)})},setCloseTimer({refs:e}){e.set("closeTimerStartTime",Date.now())},resetCloseTimer({context:e,refs:t,prop:n}){t.set("closeTimerStartTime",Date.now()),e.set("remainingTime",ga(n("duration"),n("type")))},syncRemainingTime({context:e,refs:t}){e.set("remainingTime",n=>{let r=t.get("closeTimerStartTime"),i=Date.now()-r;return t.set("lastCloseStartTimerStartTime",Date.now()),n-i})},notifyParentToRemove({prop:e}){e("parent").send({type:"TOAST.REMOVE",id:e("id")})},invokeOnDismiss({prop:e,event:t}){var n;(n=e("onStatusChange"))==null||n({status:"dismissing",src:t.src})},invokeOnUnmount({prop:e}){var t;(t=e("onStatusChange"))==null||t({status:"unmounted"})},invokeOnVisible({prop:e}){var t;(t=e("onStatusChange"))==null||t({status:"visible"})}}}};BC=(e,t)=>m(m({},t),Gn(e));UC=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Md={connect:RC,machine:MC},qC=new Map,fa=new Map,WC=class extends te{constructor(t,n){super(t,n);U(this,"parts");U(this,"duration");U(this,"destroy",()=>{this.machine.stop(),this.el.remove()});this.duration=n.duration,this.el.setAttribute("data-scope","toast"),this.el.setAttribute("data-part","root"),this.el.innerHTML=`
@@ -16,4 +16,4 @@ - `,this.parts={title:this.el.querySelector('[data-scope="toast"][data-part="title"]'),description:this.el.querySelector('[data-scope="toast"][data-part="description"]'),close:this.el.querySelector('[data-scope="toast"][data-part="close-trigger"]'),ghostBefore:this.el.querySelector('[data-scope="toast"][data-part="ghost-before"]'),ghostAfter:this.el.querySelector('[data-scope="toast"][data-part="ghost-after"]'),progressbar:this.el.querySelector('[data-scope="toast"][data-part="progressbar"]'),loadingSpinner:this.el.querySelector('[data-scope="toast"][data-part="loading-spinner"]')}}initMachine(t){return new ee(HC,t)}initApi(){return $C(this.machine.service,Q)}render(){var o,a;this.spreadProps(this.el,this.api.getRootProps()),this.spreadProps(this.parts.close,this.api.getCloseTriggerProps()),this.spreadProps(this.parts.ghostBefore,this.api.getGhostBeforeProps()),this.spreadProps(this.parts.ghostAfter,this.api.getGhostAfterProps()),this.parts.title.textContent!==this.api.title&&(this.parts.title.textContent=(o=this.api.title)!=null?o:""),this.parts.description.textContent!==this.api.description&&(this.parts.description.textContent=(a=this.api.description)!=null?a:""),this.spreadProps(this.parts.title,this.api.getTitleProps()),this.spreadProps(this.parts.description,this.api.getDescriptionProps());let t=this.duration,n=t==="Infinity"||t===1/0||t===Number.POSITIVE_INFINITY,r=this.el.closest('[phx-hook="Toast"]'),i=r==null?void 0:r.querySelector("[data-loading-icon-template]"),s=i==null?void 0:i.innerHTML;n?(this.parts.progressbar.style.display="none",this.parts.loadingSpinner.style.display="flex",this.el.setAttribute("data-duration-infinity","true"),s&&this.parts.loadingSpinner.innerHTML!==s&&(this.parts.loadingSpinner.innerHTML=s)):(this.parts.progressbar.style.display="block",this.parts.loadingSpinner.style.display="none",this.el.removeAttribute("data-duration-infinity"))}},KC=class extends te{constructor(t,n){var r;super(t,n);U(this,"toastComponents",new Map);U(this,"groupEl");U(this,"store");U(this,"destroy",()=>{for(let t of this.toastComponents.values())t.destroy();this.toastComponents.clear(),this.machine.stop()});this.store=n.store,this.groupEl=(r=t.querySelector('[data-part="group"]'))!=null?r:(()=>{let i=document.createElement("div");return i.setAttribute("data-scope","toast"),i.setAttribute("data-part","group"),t.appendChild(i),i})()}initMachine(t){return new ee(Md.machine,t)}initApi(){return Md.connect(this.machine.service,Q)}render(){this.spreadProps(this.groupEl,this.api.getGroupProps());let t=this.api.getToasts().filter(r=>typeof r.id=="string"),n=new Set(t.map(r=>r.id));t.forEach((r,i)=>{let s=this.toastComponents.get(r.id);if(s)s.duration=r.duration,s.updateProps(y(m({},r),{parent:this.machine.service,index:i}));else{let o=document.createElement("div");o.setAttribute("data-scope","toast"),o.setAttribute("data-part","root"),this.groupEl.appendChild(o),s=new WC(o,y(m({},r),{parent:this.machine.service,index:i})),s.init(),this.toastComponents.set(r.id,s)}});for(let[r,i]of this.toastComponents)n.has(r)||(i.destroy(),this.toastComponents.delete(r))}};jC={mounted(){var h;let e=this.el;e.id||(e.id=rn(e,"toast")),this.groupId=e.id;let t=p=>{if(p)try{return p.includes("{")?JSON.parse(p):p}catch(d){return p}},n=p=>p==="Infinity"||p===1/0?1/0:typeof p=="string"?parseInt(p,10)||void 0:p,r=(h=x(e,"placement",["top-start","top","top-end","bottom-start","bottom","bottom-end"]))!=null?h:"bottom-end";YC(e,{id:this.groupId,placement:r,overlap:O(e,"overlap"),max:Se(e,"max"),gap:Se(e,"gap"),offsets:t(x(e,"offset")),pauseOnPageIdle:O(e,"pauseOnPageIdle")});let i=jr(this.groupId),s=e.getAttribute("data-flash-info"),o=e.getAttribute("data-flash-info-title"),a=e.getAttribute("data-flash-error"),l=e.getAttribute("data-flash-error-title"),c=e.getAttribute("data-flash-info-duration"),u=e.getAttribute("data-flash-error-duration");if(i&&s)try{i.create({title:o||"Success",description:s,type:"info",id:rn(void 0,"toast"),duration:n(c!=null?c:void 0)})}catch(p){console.error("Failed to create flash info toast:",p)}if(i&&a)try{i.create({title:l||"Error",description:a,type:"error",id:rn(void 0,"toast"),duration:n(u!=null?u:void 0)})}catch(p){console.error("Failed to create flash error toast:",p)}this.handlers=[],this.handlers.push(this.handleEvent("toast-create",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.create({title:p.title,description:p.description,type:p.type||"info",id:p.id||rn(void 0,"toast"),duration:n(p.duration)})}catch(g){console.error("Failed to create toast:",g)}})),this.handlers.push(this.handleEvent("toast-update",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.update(p.id,{title:p.title,description:p.description,type:p.type})}catch(g){console.error("Failed to update toast:",g)}})),this.handlers.push(this.handleEvent("toast-dismiss",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.dismiss(p.id)}catch(g){console.error("Failed to dismiss toast:",g)}})),e.addEventListener("toast:create",p=>{let{detail:d}=p,g=jr(d.groupId||this.groupId);if(g)try{g.create({title:d.title,description:d.description,type:d.type||"info",id:d.id||rn(void 0,"toast"),duration:n(d.duration)})}catch(v){console.error("Failed to create toast:",v)}})},destroyed(){if(this.handlers)for(let e of this.handlers)this.removeHandleEvent(e)}}});var Wd={};Oe(Wd,{ToggleGroup:()=>oI});function eI(e,t){let{context:n,send:r,prop:i,scope:s}=e,o=n.get("value"),a=i("disabled"),l=!i("multiple"),c=i("rovingFocus"),u=i("orientation")==="horizontal";function h(p){let d=ZC(s,p.value);return{id:d,disabled:!!(p.disabled||a),pressed:!!o.includes(p.value),focused:n.get("focusedId")===d}}return{value:o,setValue(p){r({type:"VALUE.SET",value:p})},getRootProps(){return t.element(y(m({},Bd.root.attrs),{id:vs(s),dir:i("dir"),role:l?"radiogroup":"group",tabIndex:n.get("isTabbingBackward")?-1:0,"data-disabled":T(a),"data-orientation":i("orientation"),"data-focus":T(n.get("focusedId")!=null),style:{outline:"none"},onMouseDown(){a||r({type:"ROOT.MOUSE_DOWN"})},onFocus(p){a||p.currentTarget===K(p)&&(n.get("isClickFocus")||n.get("isTabbingBackward")||r({type:"ROOT.FOCUS"}))},onBlur(p){let d=p.relatedTarget;pe(p.currentTarget,d)||a||r({type:"ROOT.BLUR"})}}))},getItemState:h,getItemProps(p){let d=h(p),g=d.focused?0:-1;return t.button(y(m({},Bd.item.attrs),{id:d.id,type:"button","data-ownedby":vs(s),"data-focus":T(d.focused),disabled:d.disabled,tabIndex:c?g:void 0,role:l?"radio":void 0,"aria-checked":l?d.pressed:void 0,"aria-pressed":l?void 0:d.pressed,"data-disabled":T(d.disabled),"data-orientation":i("orientation"),dir:i("dir"),"data-state":d.pressed?"on":"off",onFocus(){d.disabled||r({type:"TOGGLE.FOCUS",id:d.id})},onClick(v){d.disabled||(r({type:"TOGGLE.CLICK",id:d.id,value:p.value}),Wt()&&v.currentTarget.focus({preventScroll:!0}))},onKeyDown(v){if(v.defaultPrevented||!pe(v.currentTarget,K(v))||d.disabled)return;let V={Tab(S){let E=S.shiftKey;r({type:"TOGGLE.SHIFT_TAB",isShiftTab:E})},ArrowLeft(){!c||!u||r({type:"TOGGLE.FOCUS_PREV"})},ArrowRight(){!c||!u||r({type:"TOGGLE.FOCUS_NEXT"})},ArrowUp(){!c||u||r({type:"TOGGLE.FOCUS_PREV"})},ArrowDown(){!c||u||r({type:"TOGGLE.FOCUS_NEXT"})},Home(){c&&r({type:"TOGGLE.FOCUS_FIRST"})},End(){c&&r({type:"TOGGLE.FOCUS_LAST"})}}[ve(v)];V&&(V(v),v.key!=="Tab"&&v.preventDefault())}}))}}}var XC,Bd,vs,ZC,qd,ys,Gd,JC,zC,QC,Ud,tI,nI,rI,xO,iI,kO,sI,oI,Kd=fe(()=>{"use strict";me();XC=Z("toggle-group").parts("root","item"),Bd=XC.build(),vs=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`toggle-group:${e.id}`},ZC=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.item)==null?void 0:r.call(n,t))!=null?i:`toggle-group:${e.id}:${t}`},qd=e=>e.getById(vs(e)),ys=e=>{let n=`[data-ownedby='${CSS.escape(vs(e))}']:not([data-disabled])`;return dt(qd(e),n)},Gd=e=>Ke(ys(e)),JC=e=>nt(ys(e)),zC=(e,t,n)=>$n(ys(e),t,n),QC=(e,t,n)=>_n(ys(e),t,n);({not:Ud,and:tI}=ye()),nI={props({props:e}){return m({defaultValue:[],orientation:"horizontal",rovingFocus:!0,loopFocus:!0,deselectable:!0},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(n){var r;(r=e("onValueChange"))==null||r({value:n})}})),focusedId:t(()=>({defaultValue:null})),isTabbingBackward:t(()=>({defaultValue:!1})),isClickFocus:t(()=>({defaultValue:!1})),isWithinToolbar:t(()=>({defaultValue:!1}))}},computed:{currentLoopFocus:({context:e,prop:t})=>t("loopFocus")&&!e.get("isWithinToolbar")},entry:["checkIfWithinToolbar"],on:{"VALUE.SET":{actions:["setValue"]},"TOGGLE.CLICK":{actions:["setValue"]},"ROOT.MOUSE_DOWN":{actions:["setClickFocus"]}},states:{idle:{on:{"ROOT.FOCUS":{target:"focused",guard:Ud(tI("isClickFocus","isTabbingBackward")),actions:["focusFirstToggle","clearClickFocus"]},"TOGGLE.FOCUS":{target:"focused",actions:["setFocusedId"]}}},focused:{on:{"ROOT.BLUR":{target:"idle",actions:["clearIsTabbingBackward","clearFocusedId","clearClickFocus"]},"TOGGLE.FOCUS":{actions:["setFocusedId"]},"TOGGLE.FOCUS_NEXT":{actions:["focusNextToggle"]},"TOGGLE.FOCUS_PREV":{actions:["focusPrevToggle"]},"TOGGLE.FOCUS_FIRST":{actions:["focusFirstToggle"]},"TOGGLE.FOCUS_LAST":{actions:["focusLastToggle"]},"TOGGLE.SHIFT_TAB":[{guard:Ud("isFirstToggleFocused"),target:"idle",actions:["setIsTabbingBackward"]},{actions:["setIsTabbingBackward"]}]}}},implementations:{guards:{isClickFocus:({context:e})=>e.get("isClickFocus"),isTabbingBackward:({context:e})=>e.get("isTabbingBackward"),isFirstToggleFocused:({context:e,scope:t})=>{var n;return e.get("focusedId")===((n=Gd(t))==null?void 0:n.id)}},actions:{setIsTabbingBackward({context:e}){e.set("isTabbingBackward",!0)},clearIsTabbingBackward({context:e}){e.set("isTabbingBackward",!1)},setClickFocus({context:e}){e.set("isClickFocus",!0)},clearClickFocus({context:e}){e.set("isClickFocus",!1)},checkIfWithinToolbar({context:e,scope:t}){var r;let n=(r=qd(t))==null?void 0:r.closest("[role=toolbar]");e.set("isWithinToolbar",!!n)},setFocusedId({context:e,event:t}){e.set("focusedId",t.id)},clearFocusedId({context:e}){e.set("focusedId",null)},setValue({context:e,event:t,prop:n}){yi(t,["value"]);let r=e.get("value");Kt(t.value)?r=t.value:n("multiple")?r=it(r,t.value):r=he(r,[t.value])&&n("deselectable")?[]:[t.value],e.set("value",r)},focusNextToggle({context:e,scope:t,prop:n}){H(()=>{var i;let r=e.get("focusedId");r&&((i=zC(t,r,n("loopFocus")))==null||i.focus({preventScroll:!0}))})},focusPrevToggle({context:e,scope:t,prop:n}){H(()=>{var i;let r=e.get("focusedId");r&&((i=QC(t,r,n("loopFocus")))==null||i.focus({preventScroll:!0}))})},focusFirstToggle({scope:e}){H(()=>{var t;(t=Gd(e))==null||t.focus({preventScroll:!0})})},focusLastToggle({scope:e}){H(()=>{var t;(t=JC(e))==null||t.focus({preventScroll:!0})})}}}},rI=G()(["dir","disabled","getRootNode","id","ids","loopFocus","multiple","onValueChange","orientation","rovingFocus","value","defaultValue","deselectable"]),xO=B(rI),iI=G()(["value","disabled"]),kO=B(iI),sI=class extends te{initMachine(e){return new ee(nI,e)}initApi(){return eI(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="toggle-group"][data-part="root"]');if(!e)return;this.spreadProps(e,this.api.getRootProps());let t=this.el.querySelectorAll('[data-scope="toggle-group"][data-part="item"]');for(let n=0;n{let s=x(e,"onValueChange");s&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(s,{value:i.value,id:e.id});let o=x(e,"onValueChangeClient");o&&e.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:{value:i.value,id:e.id}}))}}),r=new sI(e,n);r.init(),this.toggleGroup=r,this.onSetValue=i=>{let{value:s}=i.detail;r.api.setValue(s)},e.addEventListener("phx:toggle-group:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("toggle-group_set_value",i=>{let s=i.id;s&&s!==e.id||r.api.setValue(i.value)})),this.handlers.push(this.handleEvent("toggle-group:value",()=>{this.pushEvent("toggle-group:value_response",{value:r.api.value})}))},updated(){var e;(e=this.toggleGroup)==null||e.updateProps(y(m({},O(this.el,"controlled")?{value:Y(this.el,"value")}:{defaultValue:Y(this.el,"defaultValue")}),{deselectable:O(this.el,"deselectable"),loopFocus:O(this.el,"loopFocus"),rovingFocus:O(this.el,"rovingFocus"),disabled:O(this.el,"disabled"),multiple:O(this.el,"multiple"),orientation:x(this.el,"orientation",["horizontal","vertical"]),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:toggle-group:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.toggleGroup)==null||e.destroy()}}});var Jd={};Oe(Jd,{TreeView:()=>vI});function Zd(e,t,n){let r=e.getNodeValue(t);if(!e.isBranchNode(t))return n.includes(r);let i=e.getDescendantValues(r),s=i.every(a=>n.includes(a)),o=i.some(a=>n.includes(a));return s?!0:o?"indeterminate":!1}function cI(e,t,n){let r=e.getDescendantValues(t),i=r.every(s=>n.includes(s));return kt(i?ht(n,...r):rt(n,...r))}function uI(e,t){let n=new Map;return e.visit({onEnter:r=>{let i=e.getNodeValue(r),s=e.isBranchNode(r),o=Zd(e,r,t);n.set(i,{type:s?"branch":"leaf",checked:o})}}),n}function dI(e,t){let{context:n,scope:r,computed:i,prop:s,send:o}=e,a=s("collection"),l=Array.from(n.get("expandedValue")),c=Array.from(n.get("selectedValue")),u=Array.from(n.get("checkedValue")),h=i("isTypingAhead"),p=n.get("focusedValue"),d=n.get("loadingStatus"),g=n.get("renamingValue"),v=({indexPath:E})=>a.getValuePath(E).slice(0,-1).some(C=>!l.includes(C)),b=a.getFirstNode(void 0,{skip:v}),V=b?a.getNodeValue(b):null;function S(E){let{node:f,indexPath:C}=E,I=a.getNodeValue(f);return{id:va(r,I),value:I,indexPath:C,valuePath:a.getValuePath(C),disabled:!!f.disabled,focused:p==null?V===I:p===I,selected:c.includes(I),expanded:l.includes(I),loading:d[I]==="loading",depth:C.length,isBranch:a.isBranchNode(f),renaming:g===I,get checked(){return Zd(a,f,u)}}}return{collection:a,expandedValue:l,selectedValue:c,checkedValue:u,toggleChecked(E,f){o({type:"CHECKED.TOGGLE",value:E,isBranch:f})},setChecked(E){o({type:"CHECKED.SET",value:E})},clearChecked(){o({type:"CHECKED.CLEAR"})},getCheckedMap(){return uI(a,u)},expand(E){o({type:E?"BRANCH.EXPAND":"EXPANDED.ALL",value:E})},collapse(E){o({type:E?"BRANCH.COLLAPSE":"EXPANDED.CLEAR",value:E})},deselect(E){o({type:E?"NODE.DESELECT":"SELECTED.CLEAR",value:E})},select(E){o({type:E?"NODE.SELECT":"SELECTED.ALL",value:E,isTrusted:!1})},getVisibleNodes(){return i("visibleNodes")},focus(E){Ce(r,E)},selectParent(E){let f=a.getParentNode(E);if(!f)return;let C=rt(c,a.getNodeValue(f));o({type:"SELECTED.SET",value:C,src:"select.parent"})},expandParent(E){let f=a.getParentNode(E);if(!f)return;let C=rt(l,a.getNodeValue(f));o({type:"EXPANDED.SET",value:C,src:"expand.parent"})},setExpandedValue(E){let f=kt(E);o({type:"EXPANDED.SET",value:f})},setSelectedValue(E){let f=kt(E);o({type:"SELECTED.SET",value:f})},startRenaming(E){o({type:"NODE.RENAME",value:E})},submitRenaming(E,f){o({type:"RENAME.SUBMIT",value:E,label:f})},cancelRenaming(){o({type:"RENAME.CANCEL"})},getRootProps(){return t.element(y(m({},Ne.root.attrs),{id:lI(r),dir:s("dir")}))},getLabelProps(){return t.element(y(m({},Ne.label.attrs),{id:Yd(r),dir:s("dir")}))},getTreeProps(){return t.element(y(m({},Ne.tree.attrs),{id:pa(r),dir:s("dir"),role:"tree","aria-label":"Tree View","aria-labelledby":Yd(r),"aria-multiselectable":s("selectionMode")==="multiple"||void 0,tabIndex:-1,onKeyDown(E){if(E.defaultPrevented||Vt(E))return;let f=K(E);if(Ut(f))return;let C=f==null?void 0:f.closest("[data-part=branch-control], [data-part=item]");if(!C)return;let I=C.dataset.value;if(I==null){console.warn("[zag-js/tree-view] Node id not found for node",C);return}let w=C.matches("[data-part=branch-control]"),A={ArrowDown(R){Fe(R)||(R.preventDefault(),o({type:"NODE.ARROW_DOWN",id:I,shiftKey:R.shiftKey}))},ArrowUp(R){Fe(R)||(R.preventDefault(),o({type:"NODE.ARROW_UP",id:I,shiftKey:R.shiftKey}))},ArrowLeft(R){Fe(R)||C.dataset.disabled||(R.preventDefault(),o({type:w?"BRANCH_NODE.ARROW_LEFT":"NODE.ARROW_LEFT",id:I}))},ArrowRight(R){!w||C.dataset.disabled||(R.preventDefault(),o({type:"BRANCH_NODE.ARROW_RIGHT",id:I}))},Home(R){Fe(R)||(R.preventDefault(),o({type:"NODE.HOME",id:I,shiftKey:R.shiftKey}))},End(R){Fe(R)||(R.preventDefault(),o({type:"NODE.END",id:I,shiftKey:R.shiftKey}))},Space(R){var L;C.dataset.disabled||(h?o({type:"TREE.TYPEAHEAD",key:R.key}):(L=A.Enter)==null||L.call(A,R))},Enter(R){C.dataset.disabled||We(f)&&Fe(R)||(o({type:w?"BRANCH_NODE.CLICK":"NODE.CLICK",id:I,src:"keyboard"}),We(f)||R.preventDefault())},"*"(R){C.dataset.disabled||(R.preventDefault(),o({type:"SIBLINGS.EXPAND",id:I}))},a(R){!R.metaKey||C.dataset.disabled||(R.preventDefault(),o({type:"SELECTED.ALL",moveFocus:!0}))},F2(R){if(C.dataset.disabled)return;let L=s("canRename");if(!L)return;let M=a.getIndexPath(I);if(M){let j=a.at(M);if(j&&!L(j,M))return}R.preventDefault(),o({type:"NODE.RENAME",value:I})}},P=ve(E,{dir:s("dir")}),N=A[P];if(N){N(E);return}tt.isValidEvent(E)&&(o({type:"TREE.TYPEAHEAD",key:E.key,id:I}),E.preventDefault())}}))},getNodeState:S,getItemProps(E){let f=S(E);return t.element(y(m({},Ne.item.attrs),{id:f.id,dir:s("dir"),"data-ownedby":pa(r),"data-path":E.indexPath.join("/"),"data-value":f.value,tabIndex:f.focused?0:-1,"data-focus":T(f.focused),role:"treeitem","aria-current":f.selected?"true":void 0,"aria-selected":f.disabled?void 0:f.selected,"data-selected":T(f.selected),"aria-disabled":re(f.disabled),"data-disabled":T(f.disabled),"data-renaming":T(f.renaming),"aria-level":f.depth,"data-depth":f.depth,style:{"--depth":f.depth},onFocus(C){C.stopPropagation(),o({type:"NODE.FOCUS",id:f.value})},onClick(C){if(f.disabled||!et(C)||We(C.currentTarget)&&Fe(C))return;let I=C.metaKey||C.ctrlKey;o({type:"NODE.CLICK",id:f.value,shiftKey:C.shiftKey,ctrlKey:I}),C.stopPropagation(),We(C.currentTarget)||C.preventDefault()}}))},getItemTextProps(E){let f=S(E);return t.element(y(m({},Ne.itemText.attrs),{"data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused)}))},getItemIndicatorProps(E){let f=S(E);return t.element(y(m({},Ne.itemIndicator.attrs),{"aria-hidden":!0,"data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),hidden:!f.selected}))},getBranchProps(E){let f=S(E);return t.element(y(m({},Ne.branch.attrs),{"data-depth":f.depth,dir:s("dir"),"data-branch":f.value,role:"treeitem","data-ownedby":pa(r),"data-value":f.value,"aria-level":f.depth,"aria-selected":f.disabled?void 0:f.selected,"data-path":E.indexPath.join("/"),"data-selected":T(f.selected),"aria-expanded":f.expanded,"data-state":f.expanded?"open":"closed","aria-disabled":re(f.disabled),"data-disabled":T(f.disabled),"data-loading":T(f.loading),"aria-busy":re(f.loading),style:{"--depth":f.depth}}))},getBranchIndicatorProps(E){let f=S(E);return t.element(y(m({},Ne.branchIndicator.attrs),{"aria-hidden":!0,"data-state":f.expanded?"open":"closed","data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),"data-loading":T(f.loading)}))},getBranchTriggerProps(E){let f=S(E);return t.element(y(m({},Ne.branchTrigger.attrs),{role:"button",dir:s("dir"),"data-disabled":T(f.disabled),"data-state":f.expanded?"open":"closed","data-value":f.value,"data-loading":T(f.loading),disabled:f.loading,onClick(C){f.disabled||f.loading||(o({type:"BRANCH_TOGGLE.CLICK",id:f.value}),C.stopPropagation())}}))},getBranchControlProps(E){let f=S(E);return t.element(y(m({},Ne.branchControl.attrs),{role:"button",id:f.id,dir:s("dir"),tabIndex:f.focused?0:-1,"data-path":E.indexPath.join("/"),"data-state":f.expanded?"open":"closed","data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),"data-renaming":T(f.renaming),"data-value":f.value,"data-depth":f.depth,"data-loading":T(f.loading),"aria-busy":re(f.loading),onFocus(C){o({type:"NODE.FOCUS",id:f.value}),C.stopPropagation()},onClick(C){if(f.disabled||f.loading||!et(C)||We(C.currentTarget)&&Fe(C))return;let I=C.metaKey||C.ctrlKey;o({type:"BRANCH_NODE.CLICK",id:f.value,shiftKey:C.shiftKey,ctrlKey:I}),C.stopPropagation()}}))},getBranchTextProps(E){let f=S(E);return t.element(y(m({},Ne.branchText.attrs),{dir:s("dir"),"data-disabled":T(f.disabled),"data-state":f.expanded?"open":"closed","data-loading":T(f.loading)}))},getBranchContentProps(E){let f=S(E);return t.element(y(m({},Ne.branchContent.attrs),{role:"group",dir:s("dir"),"data-state":f.expanded?"open":"closed","data-depth":f.depth,"data-path":E.indexPath.join("/"),"data-value":f.value,hidden:!f.expanded}))},getBranchIndentGuideProps(E){let f=S(E);return t.element(y(m({},Ne.branchIndentGuide.attrs),{"data-depth":f.depth}))},getNodeCheckboxProps(E){let f=S(E),C=f.checked;return t.element(y(m({},Ne.nodeCheckbox.attrs),{tabIndex:-1,role:"checkbox","data-state":C===!0?"checked":C===!1?"unchecked":"indeterminate","aria-checked":C===!0?"true":C===!1?"false":"mixed","data-disabled":T(f.disabled),onClick(I){if(I.defaultPrevented||f.disabled||!et(I))return;o({type:"CHECKED.TOGGLE",value:f.value,isBranch:f.isBranch}),I.stopPropagation();let w=I.currentTarget.closest("[role=treeitem]");w==null||w.focus({preventScroll:!0})}}))},getNodeRenameInputProps(E){let f=S(E);return t.input(y(m({},Ne.nodeRenameInput.attrs),{id:Xd(r,f.value),type:"text","aria-label":"Rename tree item",hidden:!f.renaming,onKeyDown(C){Vt(C)||(C.key==="Escape"&&(o({type:"RENAME.CANCEL"}),C.preventDefault()),C.key==="Enter"&&(o({type:"RENAME.SUBMIT",label:C.currentTarget.value}),C.preventDefault()),C.stopPropagation())},onBlur(C){o({type:"RENAME.SUBMIT",label:C.currentTarget.value})}}))}}}function bs(e,t){let{context:n,prop:r,refs:i}=e;if(!r("loadChildren")){n.set("expandedValue",v=>kt(rt(v,...t)));return}let s=n.get("loadingStatus"),[o,a]=Ks(t,v=>s[v]==="loaded");if(o.length>0&&n.set("expandedValue",v=>kt(rt(v,...o))),a.length===0)return;let l=r("collection"),[c,u]=Ks(a,v=>{let b=l.findNode(v);return l.getNodeChildren(b).length>0});if(c.length>0&&n.set("expandedValue",v=>kt(rt(v,...c))),u.length===0)return;n.set("loadingStatus",v=>m(m({},v),u.reduce((b,V)=>y(m({},b),{[V]:"loading"}),{})));let h=u.map(v=>{let b=l.getIndexPath(v),V=l.getValuePath(b),S=l.findNode(v);return{id:v,indexPath:b,valuePath:V,node:S}}),p=i.get("pendingAborts"),d=r("loadChildren");qn(d,()=>"[zag-js/tree-view] `loadChildren` is required for async expansion");let g=h.map(({id:v,indexPath:b,valuePath:V,node:S})=>{let E=p.get(v);E&&(E.abort(),p.delete(v));let f=new AbortController;return p.set(v,f),d({valuePath:V,indexPath:b,node:S,signal:f.signal})});Promise.allSettled(g).then(v=>{var f,C;let b=[],V=[],S=n.get("loadingStatus"),E=r("collection");v.forEach((I,w)=>{let{id:A,indexPath:P,node:N,valuePath:R}=h[w];I.status==="fulfilled"?(S[A]="loaded",b.push(A),E=E.replace(P,y(m({},N),{children:I.value}))):(p.delete(A),Reflect.deleteProperty(S,A),V.push({node:N,error:I.reason,indexPath:P,valuePath:R}))}),n.set("loadingStatus",S),b.length&&(n.set("expandedValue",I=>kt(rt(I,...b))),(f=r("onLoadChildrenComplete"))==null||f({collection:E})),V.length&&((C=r("onLoadChildrenError"))==null||C({nodes:V}))})}function Et(e){let{prop:t,context:n}=e;return function({indexPath:i}){return t("collection").getValuePath(i).slice(0,-1).some(o=>!n.get("expandedValue").includes(o))}}function wn(e,t){let{prop:n,scope:r,computed:i}=e,s=n("scrollToIndexFn");if(!s)return!1;let o=n("collection"),a=i("visibleNodes");for(let l=0;lr.getById(va(r,t))}),!0}return!1}function pI(e){var s;let n=e.querySelectorAll('[data-scope="tree-view"][data-part="branch"], [data-scope="tree-view"][data-part="item"]'),r=[];for(let o of n){let a=o.getAttribute("data-path"),l=o.getAttribute("data-value");if(a==null||l==null)continue;let c=a.split("/").map(p=>parseInt(p,10));if(c.some(Number.isNaN))continue;let u=(s=o.getAttribute("data-name"))!=null?s:l,h=o.getAttribute("data-part")==="branch";r.push({pathArr:c,id:l,name:u,isBranch:h})}r.sort((o,a)=>{let l=Math.min(o.pathArr.length,a.pathArr.length);for(let c=0;c{"use strict";Ai();me();aI=Z("tree-view").parts("branch","branchContent","branchControl","branchIndentGuide","branchIndicator","branchText","branchTrigger","item","itemIndicator","itemText","label","nodeCheckbox","nodeRenameInput","root","tree"),Ne=aI.build(),ma=e=>new ro(e);ma.empty=()=>new ro({rootNode:{children:[]}});lI=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`tree:${e.id}:root`},Yd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`tree:${e.id}:label`},va=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.node)==null?void 0:r.call(n,t))!=null?i:`tree:${e.id}:node:${t}`},pa=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.tree)!=null?n:`tree:${e.id}:tree`},Ce=(e,t)=>{var n;t!=null&&((n=e.getById(va(e,t)))==null||n.focus())},Xd=(e,t)=>`tree:${e.id}:rename-input:${t}`,jd=(e,t)=>e.getById(Xd(e,t));({and:Ct}=ye()),hI={props({props:e}){return m({selectionMode:"single",collection:ma.empty(),typeahead:!0,expandOnClick:!0,defaultExpandedValue:[],defaultSelectedValue:[]},e)},initialState(){return"idle"},context({prop:e,bindable:t,getContext:n}){return{expandedValue:t(()=>({defaultValue:e("defaultExpandedValue"),value:e("expandedValue"),isEqual:he,onChange(r){var o;let s=n().get("focusedValue");(o=e("onExpandedChange"))==null||o({expandedValue:r,focusedValue:s,get expandedNodes(){return e("collection").findNodes(r)}})}})),selectedValue:t(()=>({defaultValue:e("defaultSelectedValue"),value:e("selectedValue"),isEqual:he,onChange(r){var o;let s=n().get("focusedValue");(o=e("onSelectionChange"))==null||o({selectedValue:r,focusedValue:s,get selectedNodes(){return e("collection").findNodes(r)}})}})),focusedValue:t(()=>({defaultValue:e("defaultFocusedValue")||null,value:e("focusedValue"),onChange(r){var i;(i=e("onFocusChange"))==null||i({focusedValue:r,get focusedNode(){return r?e("collection").findNode(r):null}})}})),loadingStatus:t(()=>({defaultValue:{}})),checkedValue:t(()=>({defaultValue:e("defaultCheckedValue")||[],value:e("checkedValue"),isEqual:he,onChange(r){var i;(i=e("onCheckedChange"))==null||i({checkedValue:r})}})),renamingValue:t(()=>({sync:!0,defaultValue:null}))}},refs(){return{typeaheadState:m({},tt.defaultOptions),pendingAborts:new Map}},computed:{isMultipleSelection:({prop:e})=>e("selectionMode")==="multiple",isTypingAhead:({refs:e})=>e.get("typeaheadState").keysSoFar.length>0,visibleNodes:({prop:e,context:t})=>{let n=[];return e("collection").visit({skip:Et({prop:e,context:t}),onEnter:(r,i)=>{n.push({node:r,indexPath:i})}}),n}},on:{"EXPANDED.SET":{actions:["setExpanded"]},"EXPANDED.CLEAR":{actions:["clearExpanded"]},"EXPANDED.ALL":{actions:["expandAllBranches"]},"BRANCH.EXPAND":{actions:["expandBranches"]},"BRANCH.COLLAPSE":{actions:["collapseBranches"]},"SELECTED.SET":{actions:["setSelected"]},"SELECTED.ALL":[{guard:Ct("isMultipleSelection","moveFocus"),actions:["selectAllNodes","focusTreeLastNode"]},{guard:"isMultipleSelection",actions:["selectAllNodes"]}],"SELECTED.CLEAR":{actions:["clearSelected"]},"NODE.SELECT":{actions:["selectNode"]},"NODE.DESELECT":{actions:["deselectNode"]},"CHECKED.TOGGLE":{actions:["toggleChecked"]},"CHECKED.SET":{actions:["setChecked"]},"CHECKED.CLEAR":{actions:["clearChecked"]},"NODE.FOCUS":{actions:["setFocusedNode"]},"NODE.ARROW_DOWN":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["focusTreeNextNode","extendSelectionToNextNode"]},{actions:["focusTreeNextNode"]}],"NODE.ARROW_UP":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["focusTreePrevNode","extendSelectionToPrevNode"]},{actions:["focusTreePrevNode"]}],"NODE.ARROW_LEFT":{actions:["focusBranchNode"]},"BRANCH_NODE.ARROW_LEFT":[{guard:"isBranchExpanded",actions:["collapseBranch"]},{actions:["focusBranchNode"]}],"BRANCH_NODE.ARROW_RIGHT":[{guard:Ct("isBranchFocused","isBranchExpanded"),actions:["focusBranchFirstNode"]},{actions:["expandBranch"]}],"SIBLINGS.EXPAND":{actions:["expandSiblingBranches"]},"NODE.HOME":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToFirstNode","focusTreeFirstNode"]},{actions:["focusTreeFirstNode"]}],"NODE.END":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToLastNode","focusTreeLastNode"]},{actions:["focusTreeLastNode"]}],"NODE.CLICK":[{guard:Ct("isCtrlKey","isMultipleSelection"),actions:["toggleNodeSelection"]},{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToNode"]},{actions:["selectNode"]}],"BRANCH_NODE.CLICK":[{guard:Ct("isCtrlKey","isMultipleSelection"),actions:["toggleNodeSelection"]},{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToNode"]},{guard:"expandOnClick",actions:["selectNode","toggleBranchNode"]},{actions:["selectNode"]}],"BRANCH_TOGGLE.CLICK":{actions:["toggleBranchNode"]},"TREE.TYPEAHEAD":{actions:["focusMatchedNode"]}},exit:["clearPendingAborts"],states:{idle:{on:{"NODE.RENAME":{target:"renaming",actions:["setRenamingValue"]}}},renaming:{entry:["syncRenameInput","focusRenameInput"],on:{"RENAME.SUBMIT":{guard:"isRenameLabelValid",target:"idle",actions:["submitRenaming"]},"RENAME.CANCEL":{target:"idle",actions:["cancelRenaming"]}}}},implementations:{guards:{isBranchFocused:({context:e,event:t})=>e.get("focusedValue")===t.id,isBranchExpanded:({context:e,event:t})=>e.get("expandedValue").includes(t.id),isShiftKey:({event:e})=>e.shiftKey,isCtrlKey:({event:e})=>e.ctrlKey,hasSelectedItems:({context:e})=>e.get("selectedValue").length>0,isMultipleSelection:({prop:e})=>e("selectionMode")==="multiple",moveFocus:({event:e})=>!!e.moveFocus,expandOnClick:({prop:e})=>!!e("expandOnClick"),isRenameLabelValid:({event:e})=>e.label.trim()!==""},actions:{selectNode({context:e,event:t}){let n=t.id||t.value;e.set("selectedValue",r=>n==null?r:!t.isTrusted&&Kt(n)?r.concat(...n):[Kt(n)?nt(n):n].filter(Boolean))},deselectNode({context:e,event:t}){let n=Tr(t.id||t.value);e.set("selectedValue",r=>ht(r,...n))},setFocusedNode({context:e,event:t}){e.set("focusedValue",t.id)},clearFocusedNode({context:e}){e.set("focusedValue",null)},clearSelectedItem({context:e}){e.set("selectedValue",[])},toggleBranchNode({context:e,event:t,action:n}){let r=e.get("expandedValue").includes(t.id);n(r?["collapseBranch"]:["expandBranch"])},expandBranch(e){let{event:t}=e;bs(e,[t.id])},expandBranches(e){let{context:t,event:n}=e,r=Tr(n.value);bs(e,mi(r,t.get("expandedValue")))},collapseBranch({context:e,event:t}){e.set("expandedValue",n=>ht(n,t.id))},collapseBranches(e){let{context:t,event:n}=e,r=Tr(n.value);t.set("expandedValue",i=>ht(i,...r))},setExpanded({context:e,event:t}){Kt(t.value)&&e.set("expandedValue",t.value)},clearExpanded({context:e}){e.set("expandedValue",[])},setSelected({context:e,event:t}){Kt(t.value)&&e.set("selectedValue",t.value)},clearSelected({context:e}){e.set("selectedValue",[])},focusTreeFirstNode(e){let{prop:t,scope:n}=e,r=t("collection"),i=r.getFirstNode(void 0,{skip:Et(e)});if(!i)return;let s=r.getNodeValue(i);wn(e,s)?H(()=>Ce(n,s)):Ce(n,s)},focusTreeLastNode(e){let{prop:t,scope:n}=e,r=t("collection"),i=r.getLastNode(void 0,{skip:Et(e)}),s=r.getNodeValue(i);wn(e,s)?H(()=>Ce(n,s)):Ce(n,s)},focusBranchFirstNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.findNode(t.id),o=i.getFirstNode(s,{skip:Et(e)});if(!o)return;let a=i.getNodeValue(o);wn(e,a)?H(()=>Ce(r,a)):Ce(r,a)},focusTreeNextNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getNextNode(t.id,{skip:Et(e)});if(!s)return;let o=i.getNodeValue(s);wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},focusTreePrevNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getPreviousNode(t.id,{skip:Et(e)});if(!s)return;let o=i.getNodeValue(s);wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},focusBranchNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getParentNode(t.id),o=s?i.getNodeValue(s):void 0;if(!o)return;wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},selectAllNodes({context:e,prop:t}){e.set("selectedValue",t("collection").getValues())},focusMatchedNode(e){let{context:t,prop:n,refs:r,event:i,scope:s,computed:o}=e,l=o("visibleNodes").map(({node:h})=>({textContent:n("collection").stringifyNode(h),id:n("collection").getNodeValue(h)})),c=tt(l,{state:r.get("typeaheadState"),activeId:t.get("focusedValue"),key:i.key});if(!(c!=null&&c.id))return;wn(e,c.id)?H(()=>Ce(s,c.id)):Ce(s,c.id)},toggleNodeSelection({context:e,event:t}){let n=it(e.get("selectedValue"),t.id);e.set("selectedValue",n)},expandAllBranches(e){let{context:t,prop:n}=e,r=n("collection").getBranchValues(),i=mi(r,t.get("expandedValue"));bs(e,i)},expandSiblingBranches(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getIndexPath(n.id);if(!s)return;let a=i.getSiblingNodes(s).map(c=>i.getNodeValue(c)),l=mi(a,t.get("expandedValue"));bs(e,l)},extendSelectionToNode(e){let{context:t,event:n,prop:r,computed:i}=e,s=r("collection"),o=Ke(t.get("selectedValue"))||s.getNodeValue(s.getFirstNode()),a=n.id,l=[o,a],c=0;i("visibleNodes").forEach(({node:h})=>{let p=s.getNodeValue(h);c===1&&l.push(p),(p===o||p===a)&&c++}),t.set("selectedValue",kt(l))},extendSelectionToNextNode(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getNextNode(n.id,{skip:Et(e)});if(!s)return;let o=new Set(t.get("selectedValue")),a=i.getNodeValue(s);a!=null&&(o.has(n.id)&&o.has(a)?o.delete(n.id):o.has(a)||o.add(a),t.set("selectedValue",Array.from(o)))},extendSelectionToPrevNode(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getPreviousNode(n.id,{skip:Et(e)});if(!s)return;let o=new Set(t.get("selectedValue")),a=i.getNodeValue(s);a!=null&&(o.has(n.id)&&o.has(a)?o.delete(n.id):o.has(a)||o.add(a),t.set("selectedValue",Array.from(o)))},extendSelectionToFirstNode(e){let{context:t,prop:n}=e,r=n("collection"),i=Ke(t.get("selectedValue")),s=[];r.visit({skip:Et(e),onEnter:o=>{let a=r.getNodeValue(o);if(s.push(a),a===i)return"stop"}}),t.set("selectedValue",s)},extendSelectionToLastNode(e){let{context:t,prop:n}=e,r=n("collection"),i=Ke(t.get("selectedValue")),s=[],o=!1;r.visit({skip:Et(e),onEnter:a=>{let l=r.getNodeValue(a);l===i&&(o=!0),o&&s.push(l)}}),t.set("selectedValue",s)},clearPendingAborts({refs:e}){let t=e.get("pendingAborts");t.forEach(n=>n.abort()),t.clear()},toggleChecked({context:e,event:t,prop:n}){let r=n("collection");e.set("checkedValue",i=>t.isBranch?cI(r,t.value,i):it(i,t.value))},setChecked({context:e,event:t}){e.set("checkedValue",t.value)},clearChecked({context:e}){e.set("checkedValue",[])},setRenamingValue({context:e,event:t,prop:n}){e.set("renamingValue",t.value);let r=n("onRenameStart");if(r){let i=n("collection"),s=i.getIndexPath(t.value);if(s){let o=i.at(s);o&&r({value:t.value,node:o,indexPath:s})}}},submitRenaming({context:e,event:t,prop:n,scope:r}){var c;let i=e.get("renamingValue");if(!i)return;let o=n("collection").getIndexPath(i);if(!o)return;let a=t.label.trim(),l=n("onBeforeRename");if(l&&!l({value:i,label:a,indexPath:o})){e.set("renamingValue",null),Ce(r,i);return}(c=n("onRenameComplete"))==null||c({value:i,label:a,indexPath:o}),e.set("renamingValue",null),Ce(r,i)},cancelRenaming({context:e,scope:t}){let n=e.get("renamingValue");e.set("renamingValue",null),n&&Ce(t,n)},syncRenameInput({context:e,scope:t,prop:n}){let r=e.get("renamingValue");if(!r)return;let i=n("collection"),s=i.findNode(r);if(!s)return;let o=i.stringifyNode(s),a=jd(t,r);xt(a,o)},focusRenameInput({context:e,scope:t}){let n=e.get("renamingValue");if(!n)return;let r=jd(t,n);r&&(r.focus(),r.select())}}}};gI=G()(["ids","collection","dir","expandedValue","expandOnClick","defaultFocusedValue","focusedValue","getRootNode","id","onExpandedChange","onFocusChange","onSelectionChange","checkedValue","selectedValue","selectionMode","typeahead","defaultExpandedValue","defaultSelectedValue","defaultCheckedValue","onCheckedChange","onLoadChildrenComplete","onLoadChildrenError","loadChildren","canRename","onRenameStart","onBeforeRename","onRenameComplete","scrollToIndexFn"]),LO=B(gI),fI=G()(["node","indexPath"]),FO=B(fI);mI=class extends te{constructor(t,n){var s;let r=(s=n.treeData)!=null?s:pI(t),i=ma({nodeToValue:o=>o.id,nodeToString:o=>o.name,rootNode:r});super(t,y(m({},n),{collection:i}));U(this,"collection");U(this,"syncTree",()=>{let t=this.el.querySelector('[data-scope="tree-view"][data-part="tree"]');t&&(this.spreadProps(t,this.api.getTreeProps()),this.updateExistingTree(t))});this.collection=i}initMachine(t){return new ee(hI,m({},t))}initApi(){return dI(this.machine.service,Q)}getNodeAt(t){var r;if(t.length===0)return;let n=this.collection.rootNode;for(let i of t)if(n=(r=n==null?void 0:n.children)==null?void 0:r[i],!n)return;return n}updateExistingTree(t){this.spreadProps(t,this.api.getTreeProps());let n=t.querySelectorAll('[data-scope="tree-view"][data-part="branch"]');for(let i of n){let s=i.getAttribute("data-path");if(s==null)continue;let o=s.split("/").map(g=>parseInt(g,10)),a=this.getNodeAt(o);if(!a)continue;let l={indexPath:o,node:a};this.spreadProps(i,this.api.getBranchProps(l));let c=i.querySelector('[data-scope="tree-view"][data-part="branch-control"]');c&&this.spreadProps(c,this.api.getBranchControlProps(l));let u=i.querySelector('[data-scope="tree-view"][data-part="branch-text"]');u&&this.spreadProps(u,this.api.getBranchTextProps(l));let h=i.querySelector('[data-scope="tree-view"][data-part="branch-indicator"]');h&&this.spreadProps(h,this.api.getBranchIndicatorProps(l));let p=i.querySelector('[data-scope="tree-view"][data-part="branch-content"]');p&&this.spreadProps(p,this.api.getBranchContentProps(l));let d=i.querySelector('[data-scope="tree-view"][data-part="branch-indent-guide"]');d&&this.spreadProps(d,this.api.getBranchIndentGuideProps(l))}let r=t.querySelectorAll('[data-scope="tree-view"][data-part="item"]');for(let i of r){let s=i.getAttribute("data-path");if(s==null)continue;let o=s.split("/").map(c=>parseInt(c,10)),a=this.getNodeAt(o);if(!a)continue;let l={indexPath:o,node:a};this.spreadProps(i,this.api.getItemProps(l))}}render(){var r;let t=(r=this.el.querySelector('[data-scope="tree-view"][data-part="root"]'))!=null?r:this.el;this.spreadProps(t,this.api.getRootProps());let n=this.el.querySelector('[data-scope="tree-view"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps()),this.syncTree()}},vI={mounted(){var r;let e=this.el,t=this.pushEvent.bind(this),n=new mI(e,y(m({id:e.id},O(e,"controlled")?{expandedValue:Y(e,"expandedValue"),selectedValue:Y(e,"selectedValue")}:{defaultExpandedValue:Y(e,"defaultExpandedValue"),defaultSelectedValue:Y(e,"defaultSelectedValue")}),{selectionMode:(r=x(e,"selectionMode",["single","multiple"]))!=null?r:"single",dir:Gt(e),onSelectionChange:i=>{var d;let s=O(e,"redirect"),o=(d=i.selectedValue)!=null&&d.length?i.selectedValue[0]:void 0,a=[...e.querySelectorAll('[data-scope="tree-view"][data-part="item"], [data-scope="tree-view"][data-part="branch"]')].find(g=>g.getAttribute("data-value")===o),l=(a==null?void 0:a.getAttribute("data-part"))==="item",c=a==null?void 0:a.getAttribute("data-redirect"),u=a==null?void 0:a.hasAttribute("data-new-tab");s&&o&&l&&this.liveSocket.main.isDead&&c!=="false"&&(u?window.open(o,"_blank","noopener,noreferrer"):window.location.href=o);let p=x(e,"onSelectionChange");p&&this.liveSocket.main.isConnected()&&t(p,{id:e.id,value:y(m({},i),{isItem:l!=null?l:!1})})},onExpandedChange:i=>{let s=x(e,"onExpandedChange");s&&this.liveSocket.main.isConnected()&&t(s,{id:e.id,value:i})}}));n.init(),this.treeView=n,this.onSetExpandedValue=i=>{let{value:s}=i.detail;n.api.setExpandedValue(s)},e.addEventListener("phx:tree-view:set-expanded-value",this.onSetExpandedValue),this.onSetSelectedValue=i=>{let{value:s}=i.detail;n.api.setSelectedValue(s)},e.addEventListener("phx:tree-view:set-selected-value",this.onSetSelectedValue),this.handlers=[],this.handlers.push(this.handleEvent("tree_view_set_expanded_value",i=>{let s=i.tree_view_id;s&&e.id!==s&&e.id!==`tree-view:${s}`||n.api.setExpandedValue(i.value)})),this.handlers.push(this.handleEvent("tree_view_set_selected_value",i=>{let s=i.tree_view_id;s&&e.id!==s&&e.id!==`tree-view:${s}`||n.api.setSelectedValue(i.value)})),this.handlers.push(this.handleEvent("tree_view_expanded_value",()=>{t("tree_view_expanded_value_response",{value:n.api.expandedValue})})),this.handlers.push(this.handleEvent("tree_view_selected_value",()=>{t("tree_view_selected_value_response",{value:n.api.selectedValue})}))},updated(){var e;O(this.el,"controlled")&&((e=this.treeView)==null||e.updateProps({expandedValue:Y(this.el,"expandedValue"),selectedValue:Y(this.el,"selectedValue")}))},destroyed(){var e;if(this.onSetExpandedValue&&this.el.removeEventListener("phx:tree-view:set-expanded-value",this.onSetExpandedValue),this.onSetSelectedValue&&this.el.removeEventListener("phx:tree-view:set-selected-value",this.onSetSelectedValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.treeView)==null||e.destroy()}}});var bI={};Oe(bI,{Hooks:()=>Qd,default:()=>yI,hooks:()=>Pe});function Pe(e,t){return{mounted(){return Ee(this,null,function*(){let i=(yield e())[t];if(this._realHook=i,i!=null&&i.mounted)return i.mounted.call(this)})},updated(){var r,i;(i=(r=this._realHook)==null?void 0:r.updated)==null||i.call(this)},destroyed(){var r,i;(i=(r=this._realHook)==null?void 0:r.destroyed)==null||i.call(this)},disconnected(){var r,i;(i=(r=this._realHook)==null?void 0:r.disconnected)==null||i.call(this)},reconnected(){var r,i;(i=(r=this._realHook)==null?void 0:r.reconnected)==null||i.call(this)},beforeUpdate(){var r,i;(i=(r=this._realHook)==null?void 0:r.beforeUpdate)==null||i.call(this)}}}var Qd={Accordion:Pe(()=>Promise.resolve().then(()=>(yl(),vl)),"Accordion"),Checkbox:Pe(()=>Promise.resolve().then(()=>(Pl(),Sl)),"Checkbox"),Clipboard:Pe(()=>Promise.resolve().then(()=>(Vl(),wl)),"Clipboard"),Collapsible:Pe(()=>Promise.resolve().then(()=>(kl(),xl)),"Collapsible"),Combobox:Pe(()=>Promise.resolve().then(()=>(Vc(),wc)),"Combobox"),DatePicker:Pe(()=>Promise.resolve().then(()=>(Pu(),Su)),"DatePicker"),Dialog:Pe(()=>Promise.resolve().then(()=>(Fu(),Lu)),"Dialog"),Menu:Pe(()=>Promise.resolve().then(()=>(Ku(),Wu)),"Menu"),Select:Pe(()=>Promise.resolve().then(()=>(Qu(),zu)),"Select"),SignaturePad:Pe(()=>Promise.resolve().then(()=>(Ed(),bd)),"SignaturePad"),Switch:Pe(()=>Promise.resolve().then(()=>(Sd(),Od)),"Switch"),Tabs:Pe(()=>Promise.resolve().then(()=>(kd(),xd)),"Tabs"),Toast:Pe(()=>Promise.resolve().then(()=>(Hd(),_d)),"Toast"),ToggleGroup:Pe(()=>Promise.resolve().then(()=>(Kd(),Wd)),"ToggleGroup"),TreeView:Pe(()=>Promise.resolve().then(()=>(zd(),Jd)),"TreeView")};var yI=Qd;return hh(bI);})(); + `,this.parts={title:this.el.querySelector('[data-scope="toast"][data-part="title"]'),description:this.el.querySelector('[data-scope="toast"][data-part="description"]'),close:this.el.querySelector('[data-scope="toast"][data-part="close-trigger"]'),ghostBefore:this.el.querySelector('[data-scope="toast"][data-part="ghost-before"]'),ghostAfter:this.el.querySelector('[data-scope="toast"][data-part="ghost-after"]'),progressbar:this.el.querySelector('[data-scope="toast"][data-part="progressbar"]'),loadingSpinner:this.el.querySelector('[data-scope="toast"][data-part="loading-spinner"]')}}initMachine(t){return new ee(HC,t)}initApi(){return $C(this.machine.service,Q)}render(){var o,a;this.spreadProps(this.el,this.api.getRootProps()),this.spreadProps(this.parts.close,this.api.getCloseTriggerProps()),this.spreadProps(this.parts.ghostBefore,this.api.getGhostBeforeProps()),this.spreadProps(this.parts.ghostAfter,this.api.getGhostAfterProps()),this.parts.title.textContent!==this.api.title&&(this.parts.title.textContent=(o=this.api.title)!=null?o:""),this.parts.description.textContent!==this.api.description&&(this.parts.description.textContent=(a=this.api.description)!=null?a:""),this.spreadProps(this.parts.title,this.api.getTitleProps()),this.spreadProps(this.parts.description,this.api.getDescriptionProps());let t=this.duration,n=t==="Infinity"||t===1/0||t===Number.POSITIVE_INFINITY,r=this.el.closest('[phx-hook="Toast"]'),i=r==null?void 0:r.querySelector("[data-loading-icon-template]"),s=i==null?void 0:i.innerHTML;n?(this.parts.progressbar.style.display="none",this.parts.loadingSpinner.style.display="flex",this.el.setAttribute("data-duration-infinity","true"),s&&this.parts.loadingSpinner.innerHTML!==s&&(this.parts.loadingSpinner.innerHTML=s)):(this.parts.progressbar.style.display="block",this.parts.loadingSpinner.style.display="none",this.el.removeAttribute("data-duration-infinity"))}},KC=class extends te{constructor(t,n){var r;super(t,n);U(this,"toastComponents",new Map);U(this,"groupEl");U(this,"store");U(this,"destroy",()=>{for(let t of this.toastComponents.values())t.destroy();this.toastComponents.clear(),this.machine.stop()});this.store=n.store,this.groupEl=(r=t.querySelector('[data-part="group"]'))!=null?r:(()=>{let i=document.createElement("div");return i.setAttribute("data-scope","toast"),i.setAttribute("data-part","group"),t.appendChild(i),i})()}initMachine(t){return new ee(Md.machine,t)}initApi(){return Md.connect(this.machine.service,Q)}render(){this.spreadProps(this.groupEl,this.api.getGroupProps());let t=this.api.getToasts().filter(r=>typeof r.id=="string"),n=new Set(t.map(r=>r.id));t.forEach((r,i)=>{let s=this.toastComponents.get(r.id);if(s)s.duration=r.duration,s.updateProps(y(m({},r),{parent:this.machine.service,index:i}));else{let o=document.createElement("div");o.setAttribute("data-scope","toast"),o.setAttribute("data-part","root"),this.groupEl.appendChild(o),s=new WC(o,y(m({},r),{parent:this.machine.service,index:i})),s.init(),this.toastComponents.set(r.id,s)}});for(let[r,i]of this.toastComponents)n.has(r)||(i.destroy(),this.toastComponents.delete(r))}};jC={mounted(){var h;let e=this.el;e.id||(e.id=rn(e,"toast")),this.groupId=e.id;let t=p=>{if(p)try{return p.includes("{")?JSON.parse(p):p}catch(d){return p}},n=p=>p==="Infinity"||p===1/0?1/0:typeof p=="string"?parseInt(p,10)||void 0:p,r=(h=x(e,"placement",["top-start","top","top-end","bottom-start","bottom","bottom-end"]))!=null?h:"bottom-end";YC(e,{id:this.groupId,placement:r,overlap:O(e,"overlap"),max:Se(e,"max"),gap:Se(e,"gap"),offsets:t(x(e,"offset")),pauseOnPageIdle:O(e,"pauseOnPageIdle")});let i=jr(this.groupId),s=e.getAttribute("data-flash-info"),o=e.getAttribute("data-flash-info-title"),a=e.getAttribute("data-flash-error"),l=e.getAttribute("data-flash-error-title"),c=e.getAttribute("data-flash-info-duration"),u=e.getAttribute("data-flash-error-duration");if(i&&s)try{i.create({title:o||"Success",description:s,type:"info",id:rn(void 0,"toast"),duration:n(c!=null?c:void 0)})}catch(p){console.error("Failed to create flash info toast:",p)}if(i&&a)try{i.create({title:l||"Error",description:a,type:"error",id:rn(void 0,"toast"),duration:n(u!=null?u:void 0)})}catch(p){console.error("Failed to create flash error toast:",p)}this.handlers=[],this.handlers.push(this.handleEvent("toast-create",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.create({title:p.title,description:p.description,type:p.type||"info",id:p.id||rn(void 0,"toast"),duration:n(p.duration)})}catch(g){console.error("Failed to create toast:",g)}})),this.handlers.push(this.handleEvent("toast-update",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.update(p.id,{title:p.title,description:p.description,type:p.type})}catch(g){console.error("Failed to update toast:",g)}})),this.handlers.push(this.handleEvent("toast-dismiss",p=>{let d=jr(p.groupId||this.groupId);if(d)try{d.dismiss(p.id)}catch(g){console.error("Failed to dismiss toast:",g)}})),e.addEventListener("toast:create",p=>{let{detail:d}=p,g=jr(d.groupId||this.groupId);if(g)try{g.create({title:d.title,description:d.description,type:d.type||"info",id:d.id||rn(void 0,"toast"),duration:n(d.duration)})}catch(v){console.error("Failed to create toast:",v)}})},destroyed(){if(this.handlers)for(let e of this.handlers)this.removeHandleEvent(e)}}});var Wd={};Oe(Wd,{ToggleGroup:()=>oI});function eI(e,t){let{context:n,send:r,prop:i,scope:s}=e,o=n.get("value"),a=i("disabled"),l=!i("multiple"),c=i("rovingFocus"),u=i("orientation")==="horizontal";function h(p){let d=ZC(s,p.value);return{id:d,disabled:!!(p.disabled||a),pressed:!!o.includes(p.value),focused:n.get("focusedId")===d}}return{value:o,setValue(p){r({type:"VALUE.SET",value:p})},getRootProps(){return t.element(y(m({},Bd.root.attrs),{id:vs(s),dir:i("dir"),role:l?"radiogroup":"group",tabIndex:n.get("isTabbingBackward")?-1:0,"data-disabled":T(a),"data-orientation":i("orientation"),"data-focus":T(n.get("focusedId")!=null),style:{outline:"none"},onMouseDown(){a||r({type:"ROOT.MOUSE_DOWN"})},onFocus(p){a||p.currentTarget===K(p)&&(n.get("isClickFocus")||n.get("isTabbingBackward")||r({type:"ROOT.FOCUS"}))},onBlur(p){let d=p.relatedTarget;pe(p.currentTarget,d)||a||r({type:"ROOT.BLUR"})}}))},getItemState:h,getItemProps(p){let d=h(p),g=d.focused?0:-1;return t.button(y(m({},Bd.item.attrs),{id:d.id,type:"button","data-ownedby":vs(s),"data-focus":T(d.focused),disabled:d.disabled,tabIndex:c?g:void 0,role:l?"radio":void 0,"aria-checked":l?d.pressed:void 0,"aria-pressed":l?void 0:d.pressed,"data-disabled":T(d.disabled),"data-orientation":i("orientation"),dir:i("dir"),"data-state":d.pressed?"on":"off",onFocus(){d.disabled||r({type:"TOGGLE.FOCUS",id:d.id})},onClick(v){d.disabled||(r({type:"TOGGLE.CLICK",id:d.id,value:p.value}),Wt()&&v.currentTarget.focus({preventScroll:!0}))},onKeyDown(v){if(v.defaultPrevented||!pe(v.currentTarget,K(v))||d.disabled)return;let V={Tab(S){let E=S.shiftKey;r({type:"TOGGLE.SHIFT_TAB",isShiftTab:E})},ArrowLeft(){!c||!u||r({type:"TOGGLE.FOCUS_PREV"})},ArrowRight(){!c||!u||r({type:"TOGGLE.FOCUS_NEXT"})},ArrowUp(){!c||u||r({type:"TOGGLE.FOCUS_PREV"})},ArrowDown(){!c||u||r({type:"TOGGLE.FOCUS_NEXT"})},Home(){c&&r({type:"TOGGLE.FOCUS_FIRST"})},End(){c&&r({type:"TOGGLE.FOCUS_LAST"})}}[ve(v)];V&&(V(v),v.key!=="Tab"&&v.preventDefault())}}))}}}var XC,Bd,vs,ZC,qd,ys,Gd,JC,zC,QC,Ud,tI,nI,rI,xO,iI,kO,sI,oI,Kd=fe(()=>{"use strict";me();XC=Z("toggle-group").parts("root","item"),Bd=XC.build(),vs=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`toggle-group:${e.id}`},ZC=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.item)==null?void 0:r.call(n,t))!=null?i:`toggle-group:${e.id}:${t}`},qd=e=>e.getById(vs(e)),ys=e=>{let n=`[data-ownedby='${CSS.escape(vs(e))}']:not([data-disabled])`;return dt(qd(e),n)},Gd=e=>Ke(ys(e)),JC=e=>nt(ys(e)),zC=(e,t,n)=>$n(ys(e),t,n),QC=(e,t,n)=>_n(ys(e),t,n);({not:Ud,and:tI}=ye()),nI={props({props:e}){return m({defaultValue:[],orientation:"horizontal",rovingFocus:!0,loopFocus:!0,deselectable:!0},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(n){var r;(r=e("onValueChange"))==null||r({value:n})}})),focusedId:t(()=>({defaultValue:null})),isTabbingBackward:t(()=>({defaultValue:!1})),isClickFocus:t(()=>({defaultValue:!1})),isWithinToolbar:t(()=>({defaultValue:!1}))}},computed:{currentLoopFocus:({context:e,prop:t})=>t("loopFocus")&&!e.get("isWithinToolbar")},entry:["checkIfWithinToolbar"],on:{"VALUE.SET":{actions:["setValue"]},"TOGGLE.CLICK":{actions:["setValue"]},"ROOT.MOUSE_DOWN":{actions:["setClickFocus"]}},states:{idle:{on:{"ROOT.FOCUS":{target:"focused",guard:Ud(tI("isClickFocus","isTabbingBackward")),actions:["focusFirstToggle","clearClickFocus"]},"TOGGLE.FOCUS":{target:"focused",actions:["setFocusedId"]}}},focused:{on:{"ROOT.BLUR":{target:"idle",actions:["clearIsTabbingBackward","clearFocusedId","clearClickFocus"]},"TOGGLE.FOCUS":{actions:["setFocusedId"]},"TOGGLE.FOCUS_NEXT":{actions:["focusNextToggle"]},"TOGGLE.FOCUS_PREV":{actions:["focusPrevToggle"]},"TOGGLE.FOCUS_FIRST":{actions:["focusFirstToggle"]},"TOGGLE.FOCUS_LAST":{actions:["focusLastToggle"]},"TOGGLE.SHIFT_TAB":[{guard:Ud("isFirstToggleFocused"),target:"idle",actions:["setIsTabbingBackward"]},{actions:["setIsTabbingBackward"]}]}}},implementations:{guards:{isClickFocus:({context:e})=>e.get("isClickFocus"),isTabbingBackward:({context:e})=>e.get("isTabbingBackward"),isFirstToggleFocused:({context:e,scope:t})=>{var n;return e.get("focusedId")===((n=Gd(t))==null?void 0:n.id)}},actions:{setIsTabbingBackward({context:e}){e.set("isTabbingBackward",!0)},clearIsTabbingBackward({context:e}){e.set("isTabbingBackward",!1)},setClickFocus({context:e}){e.set("isClickFocus",!0)},clearClickFocus({context:e}){e.set("isClickFocus",!1)},checkIfWithinToolbar({context:e,scope:t}){var r;let n=(r=qd(t))==null?void 0:r.closest("[role=toolbar]");e.set("isWithinToolbar",!!n)},setFocusedId({context:e,event:t}){e.set("focusedId",t.id)},clearFocusedId({context:e}){e.set("focusedId",null)},setValue({context:e,event:t,prop:n}){yi(t,["value"]);let r=e.get("value");Kt(t.value)?r=t.value:n("multiple")?r=it(r,t.value):r=he(r,[t.value])&&n("deselectable")?[]:[t.value],e.set("value",r)},focusNextToggle({context:e,scope:t,prop:n}){H(()=>{var i;let r=e.get("focusedId");r&&((i=zC(t,r,n("loopFocus")))==null||i.focus({preventScroll:!0}))})},focusPrevToggle({context:e,scope:t,prop:n}){H(()=>{var i;let r=e.get("focusedId");r&&((i=QC(t,r,n("loopFocus")))==null||i.focus({preventScroll:!0}))})},focusFirstToggle({scope:e}){H(()=>{var t;(t=Gd(e))==null||t.focus({preventScroll:!0})})},focusLastToggle({scope:e}){H(()=>{var t;(t=JC(e))==null||t.focus({preventScroll:!0})})}}}},rI=G()(["dir","disabled","getRootNode","id","ids","loopFocus","multiple","onValueChange","orientation","rovingFocus","value","defaultValue","deselectable"]),xO=B(rI),iI=G()(["value","disabled"]),kO=B(iI),sI=class extends te{initMachine(e){return new ee(nI,e)}initApi(){return eI(this.machine.service,Q)}render(){let e=this.el.querySelector('[data-scope="toggle-group"][data-part="root"]');if(!e)return;this.spreadProps(e,this.api.getRootProps());let t=this.el.querySelectorAll('[data-scope="toggle-group"][data-part="item"]');for(let n=0;n{let s=x(e,"onValueChange");s&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(s,{value:i.value,id:e.id});let o=x(e,"onValueChangeClient");o&&e.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:{value:i.value,id:e.id}}))}}),r=new sI(e,n);r.init(),this.toggleGroup=r,this.onSetValue=i=>{let{value:s}=i.detail;r.api.setValue(s)},e.addEventListener("phx:toggle-group:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("toggle-group_set_value",i=>{let s=i.id;s&&s!==e.id||r.api.setValue(i.value)})),this.handlers.push(this.handleEvent("toggle-group:value",()=>{this.pushEvent("toggle-group:value_response",{value:r.api.value})}))},updated(){var e;(e=this.toggleGroup)==null||e.updateProps(y(m({},O(this.el,"controlled")?{value:Y(this.el,"value")}:{defaultValue:Y(this.el,"defaultValue")}),{deselectable:O(this.el,"deselectable"),loopFocus:O(this.el,"loopFocus"),rovingFocus:O(this.el,"rovingFocus"),disabled:O(this.el,"disabled"),multiple:O(this.el,"multiple"),orientation:x(this.el,"orientation",["horizontal","vertical"]),dir:x(this.el,"dir",["ltr","rtl"])}))},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:toggle-group:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.toggleGroup)==null||e.destroy()}}});var Jd={};Oe(Jd,{TreeView:()=>vI});function Zd(e,t,n){let r=e.getNodeValue(t);if(!e.isBranchNode(t))return n.includes(r);let i=e.getDescendantValues(r),s=i.every(a=>n.includes(a)),o=i.some(a=>n.includes(a));return s?!0:o?"indeterminate":!1}function cI(e,t,n){let r=e.getDescendantValues(t),i=r.every(s=>n.includes(s));return kt(i?ht(n,...r):rt(n,...r))}function uI(e,t){let n=new Map;return e.visit({onEnter:r=>{let i=e.getNodeValue(r),s=e.isBranchNode(r),o=Zd(e,r,t);n.set(i,{type:s?"branch":"leaf",checked:o})}}),n}function dI(e,t){let{context:n,scope:r,computed:i,prop:s,send:o}=e,a=s("collection"),l=Array.from(n.get("expandedValue")),c=Array.from(n.get("selectedValue")),u=Array.from(n.get("checkedValue")),h=i("isTypingAhead"),p=n.get("focusedValue"),d=n.get("loadingStatus"),g=n.get("renamingValue"),v=({indexPath:E})=>a.getValuePath(E).slice(0,-1).some(C=>!l.includes(C)),b=a.getFirstNode(void 0,{skip:v}),V=b?a.getNodeValue(b):null;function S(E){let{node:f,indexPath:C}=E,I=a.getNodeValue(f);return{id:va(r,I),value:I,indexPath:C,valuePath:a.getValuePath(C),disabled:!!f.disabled,focused:p==null?V===I:p===I,selected:c.includes(I),expanded:l.includes(I),loading:d[I]==="loading",depth:C.length,isBranch:a.isBranchNode(f),renaming:g===I,get checked(){return Zd(a,f,u)}}}return{collection:a,expandedValue:l,selectedValue:c,checkedValue:u,toggleChecked(E,f){o({type:"CHECKED.TOGGLE",value:E,isBranch:f})},setChecked(E){o({type:"CHECKED.SET",value:E})},clearChecked(){o({type:"CHECKED.CLEAR"})},getCheckedMap(){return uI(a,u)},expand(E){o({type:E?"BRANCH.EXPAND":"EXPANDED.ALL",value:E})},collapse(E){o({type:E?"BRANCH.COLLAPSE":"EXPANDED.CLEAR",value:E})},deselect(E){o({type:E?"NODE.DESELECT":"SELECTED.CLEAR",value:E})},select(E){o({type:E?"NODE.SELECT":"SELECTED.ALL",value:E,isTrusted:!1})},getVisibleNodes(){return i("visibleNodes")},focus(E){Ce(r,E)},selectParent(E){let f=a.getParentNode(E);if(!f)return;let C=rt(c,a.getNodeValue(f));o({type:"SELECTED.SET",value:C,src:"select.parent"})},expandParent(E){let f=a.getParentNode(E);if(!f)return;let C=rt(l,a.getNodeValue(f));o({type:"EXPANDED.SET",value:C,src:"expand.parent"})},setExpandedValue(E){let f=kt(E);o({type:"EXPANDED.SET",value:f})},setSelectedValue(E){let f=kt(E);o({type:"SELECTED.SET",value:f})},startRenaming(E){o({type:"NODE.RENAME",value:E})},submitRenaming(E,f){o({type:"RENAME.SUBMIT",value:E,label:f})},cancelRenaming(){o({type:"RENAME.CANCEL"})},getRootProps(){return t.element(y(m({},Ne.root.attrs),{id:lI(r),dir:s("dir")}))},getLabelProps(){return t.element(y(m({},Ne.label.attrs),{id:Yd(r),dir:s("dir")}))},getTreeProps(){return t.element(y(m({},Ne.tree.attrs),{id:pa(r),dir:s("dir"),role:"tree","aria-label":"Tree View","aria-labelledby":Yd(r),"aria-multiselectable":s("selectionMode")==="multiple"||void 0,tabIndex:-1,onKeyDown(E){if(E.defaultPrevented||Vt(E))return;let f=K(E);if(Ut(f))return;let C=f==null?void 0:f.closest("[data-part=branch-control], [data-part=item]");if(!C)return;let I=C.dataset.value;if(I==null){console.warn("[zag-js/tree-view] Node id not found for node",C);return}let w=C.matches("[data-part=branch-control]"),A={ArrowDown(R){Fe(R)||(R.preventDefault(),o({type:"NODE.ARROW_DOWN",id:I,shiftKey:R.shiftKey}))},ArrowUp(R){Fe(R)||(R.preventDefault(),o({type:"NODE.ARROW_UP",id:I,shiftKey:R.shiftKey}))},ArrowLeft(R){Fe(R)||C.dataset.disabled||(R.preventDefault(),o({type:w?"BRANCH_NODE.ARROW_LEFT":"NODE.ARROW_LEFT",id:I}))},ArrowRight(R){!w||C.dataset.disabled||(R.preventDefault(),o({type:"BRANCH_NODE.ARROW_RIGHT",id:I}))},Home(R){Fe(R)||(R.preventDefault(),o({type:"NODE.HOME",id:I,shiftKey:R.shiftKey}))},End(R){Fe(R)||(R.preventDefault(),o({type:"NODE.END",id:I,shiftKey:R.shiftKey}))},Space(R){var L;C.dataset.disabled||(h?o({type:"TREE.TYPEAHEAD",key:R.key}):(L=A.Enter)==null||L.call(A,R))},Enter(R){C.dataset.disabled||We(f)&&Fe(R)||(o({type:w?"BRANCH_NODE.CLICK":"NODE.CLICK",id:I,src:"keyboard"}),We(f)||R.preventDefault())},"*"(R){C.dataset.disabled||(R.preventDefault(),o({type:"SIBLINGS.EXPAND",id:I}))},a(R){!R.metaKey||C.dataset.disabled||(R.preventDefault(),o({type:"SELECTED.ALL",moveFocus:!0}))},F2(R){if(C.dataset.disabled)return;let L=s("canRename");if(!L)return;let M=a.getIndexPath(I);if(M){let j=a.at(M);if(j&&!L(j,M))return}R.preventDefault(),o({type:"NODE.RENAME",value:I})}},P=ve(E,{dir:s("dir")}),N=A[P];if(N){N(E);return}tt.isValidEvent(E)&&(o({type:"TREE.TYPEAHEAD",key:E.key,id:I}),E.preventDefault())}}))},getNodeState:S,getItemProps(E){let f=S(E);return t.element(y(m({},Ne.item.attrs),{id:f.id,dir:s("dir"),"data-ownedby":pa(r),"data-path":E.indexPath.join("/"),"data-value":f.value,tabIndex:f.focused?0:-1,"data-focus":T(f.focused),role:"treeitem","aria-current":f.selected?"true":void 0,"aria-selected":f.disabled?void 0:f.selected,"data-selected":T(f.selected),"aria-disabled":re(f.disabled),"data-disabled":T(f.disabled),"data-renaming":T(f.renaming),"aria-level":f.depth,"data-depth":f.depth,style:{"--depth":f.depth},onFocus(C){C.stopPropagation(),o({type:"NODE.FOCUS",id:f.value})},onClick(C){if(f.disabled||!et(C)||We(C.currentTarget)&&Fe(C))return;let I=C.metaKey||C.ctrlKey;o({type:"NODE.CLICK",id:f.value,shiftKey:C.shiftKey,ctrlKey:I}),C.stopPropagation(),We(C.currentTarget)||C.preventDefault()}}))},getItemTextProps(E){let f=S(E);return t.element(y(m({},Ne.itemText.attrs),{"data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused)}))},getItemIndicatorProps(E){let f=S(E);return t.element(y(m({},Ne.itemIndicator.attrs),{"aria-hidden":!0,"data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),hidden:!f.selected}))},getBranchProps(E){let f=S(E);return t.element(y(m({},Ne.branch.attrs),{"data-depth":f.depth,dir:s("dir"),"data-branch":f.value,role:"treeitem","data-ownedby":pa(r),"data-value":f.value,"aria-level":f.depth,"aria-selected":f.disabled?void 0:f.selected,"data-path":E.indexPath.join("/"),"data-selected":T(f.selected),"aria-expanded":f.expanded,"data-state":f.expanded?"open":"closed","aria-disabled":re(f.disabled),"data-disabled":T(f.disabled),"data-loading":T(f.loading),"aria-busy":re(f.loading),style:{"--depth":f.depth}}))},getBranchIndicatorProps(E){let f=S(E);return t.element(y(m({},Ne.branchIndicator.attrs),{"aria-hidden":!0,"data-state":f.expanded?"open":"closed","data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),"data-loading":T(f.loading)}))},getBranchTriggerProps(E){let f=S(E);return t.element(y(m({},Ne.branchTrigger.attrs),{role:"button",dir:s("dir"),"data-disabled":T(f.disabled),"data-state":f.expanded?"open":"closed","data-value":f.value,"data-loading":T(f.loading),disabled:f.loading,onClick(C){f.disabled||f.loading||(o({type:"BRANCH_TOGGLE.CLICK",id:f.value}),C.stopPropagation())}}))},getBranchControlProps(E){let f=S(E);return t.element(y(m({},Ne.branchControl.attrs),{role:"button",id:f.id,dir:s("dir"),tabIndex:f.focused?0:-1,"data-path":E.indexPath.join("/"),"data-state":f.expanded?"open":"closed","data-disabled":T(f.disabled),"data-selected":T(f.selected),"data-focus":T(f.focused),"data-renaming":T(f.renaming),"data-value":f.value,"data-depth":f.depth,"data-loading":T(f.loading),"aria-busy":re(f.loading),onFocus(C){o({type:"NODE.FOCUS",id:f.value}),C.stopPropagation()},onClick(C){if(f.disabled||f.loading||!et(C)||We(C.currentTarget)&&Fe(C))return;let I=C.metaKey||C.ctrlKey;o({type:"BRANCH_NODE.CLICK",id:f.value,shiftKey:C.shiftKey,ctrlKey:I}),C.stopPropagation()}}))},getBranchTextProps(E){let f=S(E);return t.element(y(m({},Ne.branchText.attrs),{dir:s("dir"),"data-disabled":T(f.disabled),"data-state":f.expanded?"open":"closed","data-loading":T(f.loading)}))},getBranchContentProps(E){let f=S(E);return t.element(y(m({},Ne.branchContent.attrs),{role:"group",dir:s("dir"),"data-state":f.expanded?"open":"closed","data-depth":f.depth,"data-path":E.indexPath.join("/"),"data-value":f.value,hidden:!f.expanded}))},getBranchIndentGuideProps(E){let f=S(E);return t.element(y(m({},Ne.branchIndentGuide.attrs),{"data-depth":f.depth}))},getNodeCheckboxProps(E){let f=S(E),C=f.checked;return t.element(y(m({},Ne.nodeCheckbox.attrs),{tabIndex:-1,role:"checkbox","data-state":C===!0?"checked":C===!1?"unchecked":"indeterminate","aria-checked":C===!0?"true":C===!1?"false":"mixed","data-disabled":T(f.disabled),onClick(I){if(I.defaultPrevented||f.disabled||!et(I))return;o({type:"CHECKED.TOGGLE",value:f.value,isBranch:f.isBranch}),I.stopPropagation();let w=I.currentTarget.closest("[role=treeitem]");w==null||w.focus({preventScroll:!0})}}))},getNodeRenameInputProps(E){let f=S(E);return t.input(y(m({},Ne.nodeRenameInput.attrs),{id:Xd(r,f.value),type:"text","aria-label":"Rename tree item",hidden:!f.renaming,onKeyDown(C){Vt(C)||(C.key==="Escape"&&(o({type:"RENAME.CANCEL"}),C.preventDefault()),C.key==="Enter"&&(o({type:"RENAME.SUBMIT",label:C.currentTarget.value}),C.preventDefault()),C.stopPropagation())},onBlur(C){o({type:"RENAME.SUBMIT",label:C.currentTarget.value})}}))}}}function bs(e,t){let{context:n,prop:r,refs:i}=e;if(!r("loadChildren")){n.set("expandedValue",v=>kt(rt(v,...t)));return}let s=n.get("loadingStatus"),[o,a]=Ks(t,v=>s[v]==="loaded");if(o.length>0&&n.set("expandedValue",v=>kt(rt(v,...o))),a.length===0)return;let l=r("collection"),[c,u]=Ks(a,v=>{let b=l.findNode(v);return l.getNodeChildren(b).length>0});if(c.length>0&&n.set("expandedValue",v=>kt(rt(v,...c))),u.length===0)return;n.set("loadingStatus",v=>m(m({},v),u.reduce((b,V)=>y(m({},b),{[V]:"loading"}),{})));let h=u.map(v=>{let b=l.getIndexPath(v),V=l.getValuePath(b),S=l.findNode(v);return{id:v,indexPath:b,valuePath:V,node:S}}),p=i.get("pendingAborts"),d=r("loadChildren");qn(d,()=>"[zag-js/tree-view] `loadChildren` is required for async expansion");let g=h.map(({id:v,indexPath:b,valuePath:V,node:S})=>{let E=p.get(v);E&&(E.abort(),p.delete(v));let f=new AbortController;return p.set(v,f),d({valuePath:V,indexPath:b,node:S,signal:f.signal})});Promise.allSettled(g).then(v=>{var f,C;let b=[],V=[],S=n.get("loadingStatus"),E=r("collection");v.forEach((I,w)=>{let{id:A,indexPath:P,node:N,valuePath:R}=h[w];I.status==="fulfilled"?(S[A]="loaded",b.push(A),E=E.replace(P,y(m({},N),{children:I.value}))):(p.delete(A),Reflect.deleteProperty(S,A),V.push({node:N,error:I.reason,indexPath:P,valuePath:R}))}),n.set("loadingStatus",S),b.length&&(n.set("expandedValue",I=>kt(rt(I,...b))),(f=r("onLoadChildrenComplete"))==null||f({collection:E})),V.length&&((C=r("onLoadChildrenError"))==null||C({nodes:V}))})}function Et(e){let{prop:t,context:n}=e;return function({indexPath:i}){return t("collection").getValuePath(i).slice(0,-1).some(o=>!n.get("expandedValue").includes(o))}}function wn(e,t){let{prop:n,scope:r,computed:i}=e,s=n("scrollToIndexFn");if(!s)return!1;let o=n("collection"),a=i("visibleNodes");for(let l=0;lr.getById(va(r,t))}),!0}return!1}function pI(e){var s;let n=e.querySelectorAll('[data-scope="tree-view"][data-part="branch"], [data-scope="tree-view"][data-part="item"]'),r=[];for(let o of n){let a=o.getAttribute("data-path"),l=o.getAttribute("data-value");if(a==null||l==null)continue;let c=a.split("/").map(p=>parseInt(p,10));if(c.some(Number.isNaN))continue;let u=(s=o.getAttribute("data-name"))!=null?s:l,h=o.getAttribute("data-part")==="branch";r.push({pathArr:c,id:l,name:u,isBranch:h})}r.sort((o,a)=>{let l=Math.min(o.pathArr.length,a.pathArr.length);for(let c=0;c{"use strict";Ai();me();aI=Z("tree-view").parts("branch","branchContent","branchControl","branchIndentGuide","branchIndicator","branchText","branchTrigger","item","itemIndicator","itemText","label","nodeCheckbox","nodeRenameInput","root","tree"),Ne=aI.build(),ma=e=>new ro(e);ma.empty=()=>new ro({rootNode:{children:[]}});lI=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`tree:${e.id}:root`},Yd=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`tree:${e.id}:label`},va=(e,t)=>{var n,r,i;return(i=(r=(n=e.ids)==null?void 0:n.node)==null?void 0:r.call(n,t))!=null?i:`tree:${e.id}:node:${t}`},pa=e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.tree)!=null?n:`tree:${e.id}:tree`},Ce=(e,t)=>{var n;t!=null&&((n=e.getById(va(e,t)))==null||n.focus())},Xd=(e,t)=>`tree:${e.id}:rename-input:${t}`,jd=(e,t)=>e.getById(Xd(e,t));({and:Ct}=ye()),hI={props({props:e}){return m({selectionMode:"single",collection:ma.empty(),typeahead:!0,expandOnClick:!0,defaultExpandedValue:[],defaultSelectedValue:[]},e)},initialState(){return"idle"},context({prop:e,bindable:t,getContext:n}){return{expandedValue:t(()=>({defaultValue:e("defaultExpandedValue"),value:e("expandedValue"),isEqual:he,onChange(r){var o;let s=n().get("focusedValue");(o=e("onExpandedChange"))==null||o({expandedValue:r,focusedValue:s,get expandedNodes(){return e("collection").findNodes(r)}})}})),selectedValue:t(()=>({defaultValue:e("defaultSelectedValue"),value:e("selectedValue"),isEqual:he,onChange(r){var o;let s=n().get("focusedValue");(o=e("onSelectionChange"))==null||o({selectedValue:r,focusedValue:s,get selectedNodes(){return e("collection").findNodes(r)}})}})),focusedValue:t(()=>({defaultValue:e("defaultFocusedValue")||null,value:e("focusedValue"),onChange(r){var i;(i=e("onFocusChange"))==null||i({focusedValue:r,get focusedNode(){return r?e("collection").findNode(r):null}})}})),loadingStatus:t(()=>({defaultValue:{}})),checkedValue:t(()=>({defaultValue:e("defaultCheckedValue")||[],value:e("checkedValue"),isEqual:he,onChange(r){var i;(i=e("onCheckedChange"))==null||i({checkedValue:r})}})),renamingValue:t(()=>({sync:!0,defaultValue:null}))}},refs(){return{typeaheadState:m({},tt.defaultOptions),pendingAborts:new Map}},computed:{isMultipleSelection:({prop:e})=>e("selectionMode")==="multiple",isTypingAhead:({refs:e})=>e.get("typeaheadState").keysSoFar.length>0,visibleNodes:({prop:e,context:t})=>{let n=[];return e("collection").visit({skip:Et({prop:e,context:t}),onEnter:(r,i)=>{n.push({node:r,indexPath:i})}}),n}},on:{"EXPANDED.SET":{actions:["setExpanded"]},"EXPANDED.CLEAR":{actions:["clearExpanded"]},"EXPANDED.ALL":{actions:["expandAllBranches"]},"BRANCH.EXPAND":{actions:["expandBranches"]},"BRANCH.COLLAPSE":{actions:["collapseBranches"]},"SELECTED.SET":{actions:["setSelected"]},"SELECTED.ALL":[{guard:Ct("isMultipleSelection","moveFocus"),actions:["selectAllNodes","focusTreeLastNode"]},{guard:"isMultipleSelection",actions:["selectAllNodes"]}],"SELECTED.CLEAR":{actions:["clearSelected"]},"NODE.SELECT":{actions:["selectNode"]},"NODE.DESELECT":{actions:["deselectNode"]},"CHECKED.TOGGLE":{actions:["toggleChecked"]},"CHECKED.SET":{actions:["setChecked"]},"CHECKED.CLEAR":{actions:["clearChecked"]},"NODE.FOCUS":{actions:["setFocusedNode"]},"NODE.ARROW_DOWN":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["focusTreeNextNode","extendSelectionToNextNode"]},{actions:["focusTreeNextNode"]}],"NODE.ARROW_UP":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["focusTreePrevNode","extendSelectionToPrevNode"]},{actions:["focusTreePrevNode"]}],"NODE.ARROW_LEFT":{actions:["focusBranchNode"]},"BRANCH_NODE.ARROW_LEFT":[{guard:"isBranchExpanded",actions:["collapseBranch"]},{actions:["focusBranchNode"]}],"BRANCH_NODE.ARROW_RIGHT":[{guard:Ct("isBranchFocused","isBranchExpanded"),actions:["focusBranchFirstNode"]},{actions:["expandBranch"]}],"SIBLINGS.EXPAND":{actions:["expandSiblingBranches"]},"NODE.HOME":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToFirstNode","focusTreeFirstNode"]},{actions:["focusTreeFirstNode"]}],"NODE.END":[{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToLastNode","focusTreeLastNode"]},{actions:["focusTreeLastNode"]}],"NODE.CLICK":[{guard:Ct("isCtrlKey","isMultipleSelection"),actions:["toggleNodeSelection"]},{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToNode"]},{actions:["selectNode"]}],"BRANCH_NODE.CLICK":[{guard:Ct("isCtrlKey","isMultipleSelection"),actions:["toggleNodeSelection"]},{guard:Ct("isShiftKey","isMultipleSelection"),actions:["extendSelectionToNode"]},{guard:"expandOnClick",actions:["selectNode","toggleBranchNode"]},{actions:["selectNode"]}],"BRANCH_TOGGLE.CLICK":{actions:["toggleBranchNode"]},"TREE.TYPEAHEAD":{actions:["focusMatchedNode"]}},exit:["clearPendingAborts"],states:{idle:{on:{"NODE.RENAME":{target:"renaming",actions:["setRenamingValue"]}}},renaming:{entry:["syncRenameInput","focusRenameInput"],on:{"RENAME.SUBMIT":{guard:"isRenameLabelValid",target:"idle",actions:["submitRenaming"]},"RENAME.CANCEL":{target:"idle",actions:["cancelRenaming"]}}}},implementations:{guards:{isBranchFocused:({context:e,event:t})=>e.get("focusedValue")===t.id,isBranchExpanded:({context:e,event:t})=>e.get("expandedValue").includes(t.id),isShiftKey:({event:e})=>e.shiftKey,isCtrlKey:({event:e})=>e.ctrlKey,hasSelectedItems:({context:e})=>e.get("selectedValue").length>0,isMultipleSelection:({prop:e})=>e("selectionMode")==="multiple",moveFocus:({event:e})=>!!e.moveFocus,expandOnClick:({prop:e})=>!!e("expandOnClick"),isRenameLabelValid:({event:e})=>e.label.trim()!==""},actions:{selectNode({context:e,event:t}){let n=t.id||t.value;e.set("selectedValue",r=>n==null?r:!t.isTrusted&&Kt(n)?r.concat(...n):[Kt(n)?nt(n):n].filter(Boolean))},deselectNode({context:e,event:t}){let n=Tr(t.id||t.value);e.set("selectedValue",r=>ht(r,...n))},setFocusedNode({context:e,event:t}){e.set("focusedValue",t.id)},clearFocusedNode({context:e}){e.set("focusedValue",null)},clearSelectedItem({context:e}){e.set("selectedValue",[])},toggleBranchNode({context:e,event:t,action:n}){let r=e.get("expandedValue").includes(t.id);n(r?["collapseBranch"]:["expandBranch"])},expandBranch(e){let{event:t}=e;bs(e,[t.id])},expandBranches(e){let{context:t,event:n}=e,r=Tr(n.value);bs(e,mi(r,t.get("expandedValue")))},collapseBranch({context:e,event:t}){e.set("expandedValue",n=>ht(n,t.id))},collapseBranches(e){let{context:t,event:n}=e,r=Tr(n.value);t.set("expandedValue",i=>ht(i,...r))},setExpanded({context:e,event:t}){Kt(t.value)&&e.set("expandedValue",t.value)},clearExpanded({context:e}){e.set("expandedValue",[])},setSelected({context:e,event:t}){Kt(t.value)&&e.set("selectedValue",t.value)},clearSelected({context:e}){e.set("selectedValue",[])},focusTreeFirstNode(e){let{prop:t,scope:n}=e,r=t("collection"),i=r.getFirstNode(void 0,{skip:Et(e)});if(!i)return;let s=r.getNodeValue(i);wn(e,s)?H(()=>Ce(n,s)):Ce(n,s)},focusTreeLastNode(e){let{prop:t,scope:n}=e,r=t("collection"),i=r.getLastNode(void 0,{skip:Et(e)}),s=r.getNodeValue(i);wn(e,s)?H(()=>Ce(n,s)):Ce(n,s)},focusBranchFirstNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.findNode(t.id),o=i.getFirstNode(s,{skip:Et(e)});if(!o)return;let a=i.getNodeValue(o);wn(e,a)?H(()=>Ce(r,a)):Ce(r,a)},focusTreeNextNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getNextNode(t.id,{skip:Et(e)});if(!s)return;let o=i.getNodeValue(s);wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},focusTreePrevNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getPreviousNode(t.id,{skip:Et(e)});if(!s)return;let o=i.getNodeValue(s);wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},focusBranchNode(e){let{event:t,prop:n,scope:r}=e,i=n("collection"),s=i.getParentNode(t.id),o=s?i.getNodeValue(s):void 0;if(!o)return;wn(e,o)?H(()=>Ce(r,o)):Ce(r,o)},selectAllNodes({context:e,prop:t}){e.set("selectedValue",t("collection").getValues())},focusMatchedNode(e){let{context:t,prop:n,refs:r,event:i,scope:s,computed:o}=e,l=o("visibleNodes").map(({node:h})=>({textContent:n("collection").stringifyNode(h),id:n("collection").getNodeValue(h)})),c=tt(l,{state:r.get("typeaheadState"),activeId:t.get("focusedValue"),key:i.key});if(!(c!=null&&c.id))return;wn(e,c.id)?H(()=>Ce(s,c.id)):Ce(s,c.id)},toggleNodeSelection({context:e,event:t}){let n=it(e.get("selectedValue"),t.id);e.set("selectedValue",n)},expandAllBranches(e){let{context:t,prop:n}=e,r=n("collection").getBranchValues(),i=mi(r,t.get("expandedValue"));bs(e,i)},expandSiblingBranches(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getIndexPath(n.id);if(!s)return;let a=i.getSiblingNodes(s).map(c=>i.getNodeValue(c)),l=mi(a,t.get("expandedValue"));bs(e,l)},extendSelectionToNode(e){let{context:t,event:n,prop:r,computed:i}=e,s=r("collection"),o=Ke(t.get("selectedValue"))||s.getNodeValue(s.getFirstNode()),a=n.id,l=[o,a],c=0;i("visibleNodes").forEach(({node:h})=>{let p=s.getNodeValue(h);c===1&&l.push(p),(p===o||p===a)&&c++}),t.set("selectedValue",kt(l))},extendSelectionToNextNode(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getNextNode(n.id,{skip:Et(e)});if(!s)return;let o=new Set(t.get("selectedValue")),a=i.getNodeValue(s);a!=null&&(o.has(n.id)&&o.has(a)?o.delete(n.id):o.has(a)||o.add(a),t.set("selectedValue",Array.from(o)))},extendSelectionToPrevNode(e){let{context:t,event:n,prop:r}=e,i=r("collection"),s=i.getPreviousNode(n.id,{skip:Et(e)});if(!s)return;let o=new Set(t.get("selectedValue")),a=i.getNodeValue(s);a!=null&&(o.has(n.id)&&o.has(a)?o.delete(n.id):o.has(a)||o.add(a),t.set("selectedValue",Array.from(o)))},extendSelectionToFirstNode(e){let{context:t,prop:n}=e,r=n("collection"),i=Ke(t.get("selectedValue")),s=[];r.visit({skip:Et(e),onEnter:o=>{let a=r.getNodeValue(o);if(s.push(a),a===i)return"stop"}}),t.set("selectedValue",s)},extendSelectionToLastNode(e){let{context:t,prop:n}=e,r=n("collection"),i=Ke(t.get("selectedValue")),s=[],o=!1;r.visit({skip:Et(e),onEnter:a=>{let l=r.getNodeValue(a);l===i&&(o=!0),o&&s.push(l)}}),t.set("selectedValue",s)},clearPendingAborts({refs:e}){let t=e.get("pendingAborts");t.forEach(n=>n.abort()),t.clear()},toggleChecked({context:e,event:t,prop:n}){let r=n("collection");e.set("checkedValue",i=>t.isBranch?cI(r,t.value,i):it(i,t.value))},setChecked({context:e,event:t}){e.set("checkedValue",t.value)},clearChecked({context:e}){e.set("checkedValue",[])},setRenamingValue({context:e,event:t,prop:n}){e.set("renamingValue",t.value);let r=n("onRenameStart");if(r){let i=n("collection"),s=i.getIndexPath(t.value);if(s){let o=i.at(s);o&&r({value:t.value,node:o,indexPath:s})}}},submitRenaming({context:e,event:t,prop:n,scope:r}){var c;let i=e.get("renamingValue");if(!i)return;let o=n("collection").getIndexPath(i);if(!o)return;let a=t.label.trim(),l=n("onBeforeRename");if(l&&!l({value:i,label:a,indexPath:o})){e.set("renamingValue",null),Ce(r,i);return}(c=n("onRenameComplete"))==null||c({value:i,label:a,indexPath:o}),e.set("renamingValue",null),Ce(r,i)},cancelRenaming({context:e,scope:t}){let n=e.get("renamingValue");e.set("renamingValue",null),n&&Ce(t,n)},syncRenameInput({context:e,scope:t,prop:n}){let r=e.get("renamingValue");if(!r)return;let i=n("collection"),s=i.findNode(r);if(!s)return;let o=i.stringifyNode(s),a=jd(t,r);xt(a,o)},focusRenameInput({context:e,scope:t}){let n=e.get("renamingValue");if(!n)return;let r=jd(t,n);r&&(r.focus(),r.select())}}}};gI=G()(["ids","collection","dir","expandedValue","expandOnClick","defaultFocusedValue","focusedValue","getRootNode","id","onExpandedChange","onFocusChange","onSelectionChange","checkedValue","selectedValue","selectionMode","typeahead","defaultExpandedValue","defaultSelectedValue","defaultCheckedValue","onCheckedChange","onLoadChildrenComplete","onLoadChildrenError","loadChildren","canRename","onRenameStart","onBeforeRename","onRenameComplete","scrollToIndexFn"]),LO=B(gI),fI=G()(["node","indexPath"]),FO=B(fI);mI=class extends te{constructor(t,n){var s;let r=(s=n.treeData)!=null?s:pI(t),i=ma({nodeToValue:o=>o.id,nodeToString:o=>o.name,rootNode:r});super(t,y(m({},n),{collection:i}));U(this,"treeCollection");U(this,"syncTree",()=>{let t=this.el.querySelector('[data-scope="tree-view"][data-part="tree"]');t&&(this.spreadProps(t,this.api.getTreeProps()),this.updateExistingTree(t))});this.treeCollection=i}initMachine(t){return new ee(hI,m({},t))}initApi(){return dI(this.machine.service,Q)}getNodeAt(t){var r;if(t.length===0)return;let n=this.treeCollection.rootNode;for(let i of t)if(n=(r=n==null?void 0:n.children)==null?void 0:r[i],!n)return;return n}updateExistingTree(t){this.spreadProps(t,this.api.getTreeProps());let n=t.querySelectorAll('[data-scope="tree-view"][data-part="branch"]');for(let i of n){let s=i.getAttribute("data-path");if(s==null)continue;let o=s.split("/").map(g=>parseInt(g,10)),a=this.getNodeAt(o);if(!a)continue;let l={indexPath:o,node:a};this.spreadProps(i,this.api.getBranchProps(l));let c=i.querySelector('[data-scope="tree-view"][data-part="branch-control"]');c&&this.spreadProps(c,this.api.getBranchControlProps(l));let u=i.querySelector('[data-scope="tree-view"][data-part="branch-text"]');u&&this.spreadProps(u,this.api.getBranchTextProps(l));let h=i.querySelector('[data-scope="tree-view"][data-part="branch-indicator"]');h&&this.spreadProps(h,this.api.getBranchIndicatorProps(l));let p=i.querySelector('[data-scope="tree-view"][data-part="branch-content"]');p&&this.spreadProps(p,this.api.getBranchContentProps(l));let d=i.querySelector('[data-scope="tree-view"][data-part="branch-indent-guide"]');d&&this.spreadProps(d,this.api.getBranchIndentGuideProps(l))}let r=t.querySelectorAll('[data-scope="tree-view"][data-part="item"]');for(let i of r){let s=i.getAttribute("data-path");if(s==null)continue;let o=s.split("/").map(c=>parseInt(c,10)),a=this.getNodeAt(o);if(!a)continue;let l={indexPath:o,node:a};this.spreadProps(i,this.api.getItemProps(l))}}render(){var r;let t=(r=this.el.querySelector('[data-scope="tree-view"][data-part="root"]'))!=null?r:this.el;this.spreadProps(t,this.api.getRootProps());let n=this.el.querySelector('[data-scope="tree-view"][data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps()),this.syncTree()}},vI={mounted(){var r;let e=this.el,t=this.pushEvent.bind(this),n=new mI(e,y(m({id:e.id},O(e,"controlled")?{expandedValue:Y(e,"expandedValue"),selectedValue:Y(e,"selectedValue")}:{defaultExpandedValue:Y(e,"defaultExpandedValue"),defaultSelectedValue:Y(e,"defaultSelectedValue")}),{selectionMode:(r=x(e,"selectionMode",["single","multiple"]))!=null?r:"single",dir:Gt(e),onSelectionChange:i=>{var d;let s=O(e,"redirect"),o=(d=i.selectedValue)!=null&&d.length?i.selectedValue[0]:void 0,a=[...e.querySelectorAll('[data-scope="tree-view"][data-part="item"], [data-scope="tree-view"][data-part="branch"]')].find(g=>g.getAttribute("data-value")===o),l=(a==null?void 0:a.getAttribute("data-part"))==="item",c=a==null?void 0:a.getAttribute("data-redirect"),u=a==null?void 0:a.hasAttribute("data-new-tab");s&&o&&l&&this.liveSocket.main.isDead&&c!=="false"&&(u?window.open(o,"_blank","noopener,noreferrer"):window.location.href=o);let p=x(e,"onSelectionChange");p&&this.liveSocket.main.isConnected()&&t(p,{id:e.id,value:y(m({},i),{isItem:l!=null?l:!1})})},onExpandedChange:i=>{let s=x(e,"onExpandedChange");s&&this.liveSocket.main.isConnected()&&t(s,{id:e.id,value:i})}}));n.init(),this.treeView=n,this.onSetExpandedValue=i=>{let{value:s}=i.detail;n.api.setExpandedValue(s)},e.addEventListener("phx:tree-view:set-expanded-value",this.onSetExpandedValue),this.onSetSelectedValue=i=>{let{value:s}=i.detail;n.api.setSelectedValue(s)},e.addEventListener("phx:tree-view:set-selected-value",this.onSetSelectedValue),this.handlers=[],this.handlers.push(this.handleEvent("tree_view_set_expanded_value",i=>{let s=i.tree_view_id;s&&e.id!==s&&e.id!==`tree-view:${s}`||n.api.setExpandedValue(i.value)})),this.handlers.push(this.handleEvent("tree_view_set_selected_value",i=>{let s=i.tree_view_id;s&&e.id!==s&&e.id!==`tree-view:${s}`||n.api.setSelectedValue(i.value)})),this.handlers.push(this.handleEvent("tree_view_expanded_value",()=>{t("tree_view_expanded_value_response",{value:n.api.expandedValue})})),this.handlers.push(this.handleEvent("tree_view_selected_value",()=>{t("tree_view_selected_value_response",{value:n.api.selectedValue})}))},updated(){var e;O(this.el,"controlled")&&((e=this.treeView)==null||e.updateProps({expandedValue:Y(this.el,"expandedValue"),selectedValue:Y(this.el,"selectedValue")}))},destroyed(){var e;if(this.onSetExpandedValue&&this.el.removeEventListener("phx:tree-view:set-expanded-value",this.onSetExpandedValue),this.onSetSelectedValue&&this.el.removeEventListener("phx:tree-view:set-selected-value",this.onSetSelectedValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.treeView)==null||e.destroy()}}});var bI={};Oe(bI,{Hooks:()=>Qd,default:()=>yI,hooks:()=>Pe});function Pe(e,t){return{mounted(){return Ee(this,null,function*(){let i=(yield e())[t];if(this._realHook=i,i!=null&&i.mounted)return i.mounted.call(this)})},updated(){var r,i;(i=(r=this._realHook)==null?void 0:r.updated)==null||i.call(this)},destroyed(){var r,i;(i=(r=this._realHook)==null?void 0:r.destroyed)==null||i.call(this)},disconnected(){var r,i;(i=(r=this._realHook)==null?void 0:r.disconnected)==null||i.call(this)},reconnected(){var r,i;(i=(r=this._realHook)==null?void 0:r.reconnected)==null||i.call(this)},beforeUpdate(){var r,i;(i=(r=this._realHook)==null?void 0:r.beforeUpdate)==null||i.call(this)}}}var Qd={Accordion:Pe(()=>Promise.resolve().then(()=>(yl(),vl)),"Accordion"),Checkbox:Pe(()=>Promise.resolve().then(()=>(Pl(),Sl)),"Checkbox"),Clipboard:Pe(()=>Promise.resolve().then(()=>(Vl(),wl)),"Clipboard"),Collapsible:Pe(()=>Promise.resolve().then(()=>(kl(),xl)),"Collapsible"),Combobox:Pe(()=>Promise.resolve().then(()=>(Vc(),wc)),"Combobox"),DatePicker:Pe(()=>Promise.resolve().then(()=>(Pu(),Su)),"DatePicker"),Dialog:Pe(()=>Promise.resolve().then(()=>(Fu(),Lu)),"Dialog"),Menu:Pe(()=>Promise.resolve().then(()=>(Ku(),Wu)),"Menu"),Select:Pe(()=>Promise.resolve().then(()=>(Qu(),zu)),"Select"),SignaturePad:Pe(()=>Promise.resolve().then(()=>(Ed(),bd)),"SignaturePad"),Switch:Pe(()=>Promise.resolve().then(()=>(Sd(),Od)),"Switch"),Tabs:Pe(()=>Promise.resolve().then(()=>(kd(),xd)),"Tabs"),Toast:Pe(()=>Promise.resolve().then(()=>(Hd(),_d)),"Toast"),ToggleGroup:Pe(()=>Promise.resolve().then(()=>(Kd(),Wd)),"ToggleGroup"),TreeView:Pe(()=>Promise.resolve().then(()=>(zd(),Jd)),"TreeView")};var yI=Qd;return hh(bI);})(); From 1896fef8819bb4a2214b9952cf41038b14a231eb Mon Sep 17 00:00:00 2001 From: karimsemmoud Date: Sat, 14 Feb 2026 13:13:46 +0700 Subject: [PATCH 3/9] Update toast.css --- priv/design/components/toast.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/priv/design/components/toast.css b/priv/design/components/toast.css index 8889310..c1d5bfa 100644 --- a/priv/design/components/toast.css +++ b/priv/design/components/toast.css @@ -5,11 +5,12 @@ display: flex; flex-direction: column; gap: var(--spacing-ui-gap); - width: var(--container-ui); + width: var(--container-mini); } .toast [data-scope="toast"][data-part="root"] { @apply ui-root; + max-width: var(--container-mini); translate: var(--x) var(--y); scale: var(--scale); From 833cd1d45f46375ffc85eea2fd80b55b143aa0f6 Mon Sep 17 00:00:00 2001 From: karimsemmoud Date: Sat, 14 Feb 2026 13:37:24 +0700 Subject: [PATCH 4/9] dev --- .../e2e_web/controllers/page_controller.ex | 1 + e2e/lib/e2e_web/controllers/page_html.ex | 48 ++++++ .../controllers/page_html/menu_page.html.heex | 50 ++---- e2e/lib/e2e_web/live/menu_live.ex | 163 +++++++++++++++++- 4 files changed, 224 insertions(+), 38 deletions(-) diff --git a/e2e/lib/e2e_web/controllers/page_controller.ex b/e2e/lib/e2e_web/controllers/page_controller.ex index 97c2261..1e9ed9b 100644 --- a/e2e/lib/e2e_web/controllers/page_controller.ex +++ b/e2e/lib/e2e_web/controllers/page_controller.ex @@ -94,4 +94,5 @@ defmodule E2eWeb.PageController do def tree_view_page(conn, _params) do render(conn, :tree_view_page) end + end diff --git a/e2e/lib/e2e_web/controllers/page_html.ex b/e2e/lib/e2e_web/controllers/page_html.ex index b004e7b..2651896 100644 --- a/e2e/lib/e2e_web/controllers/page_html.ex +++ b/e2e/lib/e2e_web/controllers/page_html.ex @@ -7,4 +7,52 @@ defmodule E2eWeb.PageHTML do use E2eWeb, :html embed_templates "page_html/*" + + def menu_items(locale) do + Corex.Tree.new([ + [ + label: "Accordion", + id: "accordion", + children: [ + [label: "Controller", id: "/#{locale}/accordion"], + [label: "Live", id: "/#{locale}/live/accordion"], + [label: "Playground", id: "/#{locale}/playground/accordion"], + [label: "Controlled", id: "/#{locale}/controlled/accordion"], + [label: "Async", id: "/#{locale}/async/accordion"] + ] + ], + [ + label: "Checkbox", + id: "checkbox", + children: [ + [label: "Controller", id: "/#{locale}/checkbox"], + [label: "Live", id: "/#{locale}/live/checkbox"] + ] + ], + [ + label: "Clipboard", + id: "clipboard", + children: [ + [label: "Controller", id: "/#{locale}/clipboard"], + [label: "Live", id: "/#{locale}/live/clipboard"] + ] + ], + [ + label: "Collapsible", + id: "collapsible", + children: [ + [label: "Controller", id: "/#{locale}/collapsible"], + [label: "Live", id: "/#{locale}/live/collapsible"] + ] + ], + [ + label: "Combobox", + id: "combobox", + children: [ + [label: "Controller", id: "/#{locale}/combobox"], + [label: "Live", id: "/#{locale}/live/combobox"] + ] + ] + ]) + end end diff --git a/e2e/lib/e2e_web/controllers/page_html/menu_page.html.heex b/e2e/lib/e2e_web/controllers/page_html/menu_page.html.heex index bc20911..d55f697 100644 --- a/e2e/lib/e2e_web/controllers/page_html/menu_page.html.heex +++ b/e2e/lib/e2e_web/controllers/page_html/menu_page.html.heex @@ -1,7 +1,6 @@

Menu

Controller View

-

Client Api

<.menu class="menu" @@ -96,38 +95,19 @@ - <.menu - class="menu" - redirect - items={[ - %Corex.Tree.Item{ - id: "accordion", - label: "Accordion", - group: "Components" - }, - %Corex.Tree.Item{ - id: "checkbox", - label: "Checkbox", - group: "Components" - }, - %Corex.Tree.Item{ - id: "users", - label: "Controller", - group: "Phoenix Form" - }, - %Corex.Tree.Item{ - id: "admins", - label: "Live View", - group: "Phoenix Form" - } - ]} - > - <:trigger>Corex - <:indicator> - <.icon name="hero-chevron-down" /> - - <:item :let={item}> - {item.label} - - + <.menu + class="menu" + redirect + items={menu_items(@locale)} + > + <:trigger>Corex + <:indicator> + <.icon name="hero-chevron-down" /> + + <:item :let={item}> + {item.label} + +
+ + diff --git a/e2e/lib/e2e_web/live/menu_live.ex b/e2e/lib/e2e_web/live/menu_live.ex index e411354..fac14fa 100644 --- a/e2e/lib/e2e_web/live/menu_live.ex +++ b/e2e/lib/e2e_web/live/menu_live.ex @@ -9,9 +9,10 @@ defmodule E2eWeb.MenuLive do {:noreply, Corex.Menu.set_open(socket, "my-menu", value == "true")} end - # def handle_event("handle_on_select", %{"id" => _id, "value" => value}, socket) do - # {:noreply, push_navigate(socket, to: "/#{value}")} - # end + def handle_event("handle_on_select", %{"id" => _id, "value" => value}, socket) do + IO.inspect(value, label: "value") + {:noreply, push_navigate(socket, to: "#{value}")} + end def render(assigns) do ~H""" @@ -48,7 +49,163 @@ defmodule E2eWeb.MenuLive do Close menu + + <.menu + class="menu" + items={[ + %Corex.Tree.Item{ + id: "edit", + label: "Edit" + }, + %Corex.Tree.Item{ + id: "duplicate", + label: "Duplicate" + }, + %Corex.Tree.Item{ + id: "delete", + label: "Delete" + } + ]} + > + <:trigger>File + <:indicator> + <.icon name="hero-chevron-down" /> + + + <.menu + class="menu" + items={[ + %Corex.Tree.Item{ + id: "new-tab", + label: "New tab" + }, + %Corex.Tree.Item{ + id: "share", + label: "Share", + children: [ + %Corex.Tree.Item{ + id: "messages", + label: "Messages" + }, + %Corex.Tree.Item{ + id: "airdrop", + label: "Airdrop" + }, + %Corex.Tree.Item{ + id: "whatsapp", + label: "WhatsApp" + } + ] + }, + %Corex.Tree.Item{ + id: "print", + label: "Print..." + } + ]} + > + <:trigger>Menu + <:indicator> + <.icon name="hero-chevron-down" /> + + <:nested_indicator> + <.icon name="hero-chevron-right" /> + + + + <.menu + class="menu" + items={[ + %Corex.Tree.Item{ + id: "edit", + label: "Edit", + group: "Actions" + }, + %Corex.Tree.Item{ + id: "duplicate", + label: "Duplicate", + group: "Actions" + }, + %Corex.Tree.Item{ + id: "account-1", + label: "Account 1", + group: "Accounts" + }, + %Corex.Tree.Item{ + id: "account-2", + label: "Account 2", + group: "Accounts" + } + ]} + > + <:trigger>Actions + <:indicator> + <.icon name="hero-chevron-down" /> + + + + <.menu + class="menu" + redirect + on_select="handle_on_select" + items={menu_items(@locale)} + > + <:trigger>Corex + <:indicator> + <.icon name="hero-chevron-down" /> + + <:item :let={item}> + {item.label} + + """ end + + defp menu_items(locale) do + Corex.Tree.new([ + [ + label: "Accordion", + id: "accordion", + children: [ + [label: "Controller", id: "/#{locale}/accordion"], + [label: "Live", id: "/#{locale}/live/accordion"], + [label: "Playground", id: "/#{locale}/playground/accordion"], + [label: "Controlled", id: "/#{locale}/controlled/accordion"], + [label: "Async", id: "/#{locale}/async/accordion"] + ] + ], + [ + label: "Checkbox", + id: "checkbox", + children: [ + [label: "Controller", id: "/#{locale}/checkbox"], + [label: "Live", id: "/#{locale}/live/checkbox"] + ] + ], + [ + label: "Clipboard", + id: "clipboard", + children: [ + [label: "Controller", id: "/#{locale}/clipboard"], + [label: "Live", id: "/#{locale}/live/clipboard"] + ] + ], + [ + label: "Collapsible", + id: "collapsible", + children: [ + [label: "Controller", id: "/#{locale}/collapsible"], + [label: "Live", id: "/#{locale}/live/collapsible"] + ] + ], + [ + label: "Combobox", + id: "combobox", + children: [ + [label: "Controller", id: "/#{locale}/combobox"], + [label: "Live", id: "/#{locale}/live/combobox"] + ] + ] + ]) + end end From 6a2afae4c395df125f36a4f0e9617e8386262fbd Mon Sep 17 00:00:00 2001 From: karimsemmoud Date: Sat, 14 Feb 2026 16:15:29 +0700 Subject: [PATCH 5/9] fix select menu and tree view --- assets/components/menu.ts | 36 +- assets/components/select.ts | 151 +- assets/hooks/menu.ts | 75 +- assets/hooks/select.ts | 41 +- .../controllers/page_html/menu_page.html.heex | 28 +- e2e/lib/e2e_web/live/menu_live.ex | 13 +- e2e/test/components/menu_test.exs | 16 + e2e/test/components/tree_view_test.exs | 16 + e2e/test/support/models/menu_model.ex | 3 + e2e/test/support/models/tree_view_model.ex | 3 + lib/components/menu.ex | 6 +- lib/components/select.ex | 54 +- priv/static/chunk-GYNMIQP2.mjs | 517 ++++ priv/static/chunk-NYISECP7.mjs | 1075 ++++++++ priv/static/chunk-QD4Z4LOU.mjs | 163 ++ priv/static/chunk-T4BCXOJK.mjs | 1953 +++++++++++++ priv/static/chunk-ZTKS6RKJ.mjs | 2406 +++++++++++++++++ priv/static/corex.js | 277 +- priv/static/corex.min.js | 6 +- priv/static/menu.mjs | 99 +- priv/static/select.mjs | 147 +- 21 files changed, 6647 insertions(+), 438 deletions(-) create mode 100644 e2e/test/components/menu_test.exs create mode 100644 e2e/test/components/tree_view_test.exs create mode 100644 e2e/test/support/models/menu_model.ex create mode 100644 e2e/test/support/models/tree_view_model.ex create mode 100644 priv/static/chunk-GYNMIQP2.mjs create mode 100644 priv/static/chunk-NYISECP7.mjs create mode 100644 priv/static/chunk-QD4Z4LOU.mjs create mode 100644 priv/static/chunk-T4BCXOJK.mjs create mode 100644 priv/static/chunk-ZTKS6RKJ.mjs diff --git a/assets/components/menu.ts b/assets/components/menu.ts index a37adeb..7eef4e0 100644 --- a/assets/components/menu.ts +++ b/assets/components/menu.ts @@ -80,17 +80,17 @@ export class Menu extends Component { ); if (positionerEl && contentEl) { - // Always apply positioner and content props so Zag can manage visibility, - // keyboard handlers, aria-activedescendant, etc. across state transitions. - // getContentProps() includes hidden: !open which controls content visibility. this.spreadProps(positionerEl, this.api.getPositionerProps()); this.spreadProps(contentEl, this.api.getContentProps()); + contentEl.style.pointerEvents = "auto"; - // Also manage positioner hidden state for rendering optimization positionerEl.hidden = !this.api.open; - if (this.api.open) { - // Handle menu items - only process items belonging to THIS menu + const isNested = !this.el.querySelector( + '[data-scope="menu"][data-part="trigger"]' + ); + const shouldApplyItems = this.api.open || isNested; + if (shouldApplyItems) { const items = contentEl.querySelectorAll( '[data-scope="menu"][data-part="item"]' ); @@ -107,30 +107,6 @@ export class Menu extends Component { } }); - // Handle option items (checkbox/radio) - const optionItems = contentEl.querySelectorAll( - '[data-scope="menu"][data-part="option-item"]' - ); - optionItems.forEach((optionItemEl) => { - if (!this.isOwnElement(optionItemEl)) return; - - const value = optionItemEl.dataset.value; - const type = optionItemEl.dataset.type as "checkbox" | "radio" | undefined; - if (value && type) { - const checked = optionItemEl.hasAttribute("data-checked"); - const disabled = optionItemEl.hasAttribute("data-disabled"); - this.spreadProps( - optionItemEl, - this.api.getOptionItemProps({ - value, - type, - checked: checked, - disabled: disabled || undefined, - }) - ); - } - }); - // Handle item groups const itemGroups = contentEl.querySelectorAll( '[data-scope="menu"][data-part="item-group"]' diff --git a/assets/components/select.ts b/assets/components/select.ts index d3045ef..d971a1c 100644 --- a/assets/components/select.ts +++ b/assets/components/select.ts @@ -1,4 +1,5 @@ -import { collection, connect, machine, type Props, type Api } from "@zag-js/select"; +import { connect, machine, collection, type Props, type Api } from "@zag-js/select"; +import type { ListCollection } from "@zag-js/collection"; import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"; import { Component } from "../lib/core"; import { getString } from "../lib/util"; @@ -18,6 +19,8 @@ export class Select extends Component { constructor(el: HTMLElement | null, props: Props) { super(el, props); + const collectionFromProps = (props as Props & { collection?: { items: Item[] } }).collection; + this._options = collectionFromProps?.items ?? []; this.placeholder = getString(this.el, "placeholder") || ""; } @@ -29,7 +32,7 @@ export class Select extends Component { this._options = Array.isArray(options) ? options : []; } - getCollection(): ReturnType> { + getCollection(): ListCollection { const items = this.options; if (this.hasGroups) { @@ -38,7 +41,7 @@ export class Select extends Component { itemToValue: (item) => item.id ?? item.value ?? "", itemToString: (item) => item.label, isItemDisabled: (item) => !!item.disabled, - groupBy: (item) => item.group ?? "", + groupBy: (item: Item) => item.group ?? "", }); } @@ -53,11 +56,12 @@ export class Select extends Component { // eslint-disable-next-line @typescript-eslint/no-explicit-any initMachine(props: Props): VanillaMachine { const getCollection = this.getCollection.bind(this); + const collectionFromProps = (props as Props & { collection?: ListCollection }).collection; return new VanillaMachine(machine, { ...props, get collection() { - return getCollection(); + return collectionFromProps ?? getCollection(); }, }); } @@ -66,111 +70,60 @@ export class Select extends Component { return connect(this.machine.service, normalizeProps); } - renderItems(): void { + init = (): void => { + this.machine.start(); + this.render(); + this.machine.subscribe(() => { + this.api = this.initApi(); + this.render(); + }); + }; + + applyItemProps(): void { const contentEl = this.el.querySelector( '[data-scope="select"][data-part="content"]' ); if (!contentEl) return; - const templatesContainer = this.el.querySelector('[data-templates="select"]'); - if (!templatesContainer) return; - contentEl - .querySelectorAll('[data-scope="select"][data-part="item"]:not([data-template])') - .forEach((el) => el.remove()); + .querySelectorAll('[data-scope="select"][data-part="item-group"]') + .forEach((groupEl) => { + const groupId = groupEl.dataset.id ?? ""; + this.spreadProps(groupEl, this.api.getItemGroupProps({ id: groupId })); + const labelEl = groupEl.querySelector( + '[data-scope="select"][data-part="item-group-label"]' + ); + if (labelEl) { + this.spreadProps(labelEl, this.api.getItemGroupLabelProps({ htmlFor: groupId })); + } + }); contentEl - .querySelectorAll('[data-scope="select"][data-part="item-group"]:not([data-template])') - .forEach((el) => el.remove()); - - const items = this.api.collection.items; - - const groups = this.api.collection.group?.() ?? []; - const hasGroupsInCollection = groups.some(([group]) => group != null); - - if (hasGroupsInCollection) { - this.renderGroupedItems(contentEl, templatesContainer, groups); - } else { - this.renderFlatItems(contentEl, templatesContainer, items); - } - } - - renderGroupedItems( - contentEl: HTMLElement, - templatesContainer: HTMLElement, - groups: [string | null, Item[]][] - ): void { - for (const [groupId, groupItems] of groups) { - if (groupId == null) continue; - - const groupTemplate = templatesContainer.querySelector( - `[data-scope="select"][data-part="item-group"][data-id="${groupId}"][data-template]` - ); - if (!groupTemplate) continue; - - const groupEl = groupTemplate.cloneNode(true) as HTMLElement; - groupEl.removeAttribute("data-template"); - - this.spreadProps(groupEl, this.api.getItemGroupProps({ id: groupId })); - - const labelEl = groupEl.querySelector( - '[data-scope="select"][data-part="item-group-label"]' - ); - if (labelEl) { - this.spreadProps(labelEl, this.api.getItemGroupLabelProps({ htmlFor: groupId })); - } - - const templateItems = groupEl.querySelectorAll( - '[data-scope="select"][data-part="item"][data-template]' - ); - templateItems.forEach((item) => item.remove()); - - for (const item of groupItems) { - const itemEl = this.cloneItem(templatesContainer, item); - if (itemEl) groupEl.appendChild(itemEl); - } - - contentEl.appendChild(groupEl); - } - } - - renderFlatItems(contentEl: HTMLElement, templatesContainer: HTMLElement, items: Item[]): void { - for (const item of items) { - const itemEl = this.cloneItem(templatesContainer, item); - if (itemEl) contentEl.appendChild(itemEl); - } - } - - cloneItem(templatesContainer: HTMLElement, item: Item): HTMLElement | null { - const value = this.api.collection.getItemValue(item); - const template = templatesContainer.querySelector( - `[data-scope="select"][data-part="item"][data-value="${value}"][data-template]` - ); - if (!template) return null; - - const el = template.cloneNode(true) as HTMLElement; - el.removeAttribute("data-template"); - - this.spreadProps(el, this.api.getItemProps({ item })); - - const textEl = el.querySelector('[data-scope="select"][data-part="item-text"]'); - if (textEl) { - this.spreadProps(textEl, this.api.getItemTextProps({ item })); - } - - const indicatorEl = el.querySelector( - '[data-scope="select"][data-part="item-indicator"]' - ); - if (indicatorEl) { - this.spreadProps(indicatorEl, this.api.getItemIndicatorProps({ item })); - } - - return el; + .querySelectorAll('[data-scope="select"][data-part="item"]') + .forEach((itemEl) => { + const value = itemEl.dataset.value ?? ""; + const item = this.options.find((i) => String(i.id ?? i.value ?? "") === String(value)); + if (!item) return; + this.spreadProps(itemEl, this.api.getItemProps({ item })); + const textEl = itemEl.querySelector( + '[data-scope="select"][data-part="item-text"]' + ); + if (textEl) { + this.spreadProps(textEl, this.api.getItemTextProps({ item })); + } + const indicatorEl = itemEl.querySelector( + '[data-scope="select"][data-part="item-indicator"]' + ); + if (indicatorEl) { + this.spreadProps(indicatorEl, this.api.getItemIndicatorProps({ item })); + } + }); } render(): void { - const root = this.el.querySelector('[data-scope="select"][data-part="root"]'); - if (!root) return; + const root = + this.el.querySelector('[data-scope="select"][data-part="root"]') ?? this.el; + this.spreadProps(root, this.api.getRootProps()); const hiddenSelect = this.el.querySelector( @@ -236,7 +189,7 @@ export class Select extends Component { ); if (contentEl) { this.spreadProps(contentEl, this.api.getContentProps()); - this.renderItems(); + this.applyItemProps(); } } } diff --git a/assets/hooks/menu.ts b/assets/hooks/menu.ts index 1844b43..06b6322 100644 --- a/assets/hooks/menu.ts +++ b/assets/hooks/menu.ts @@ -10,6 +10,7 @@ type MenuHookState = { menu?: Menu; handlers?: Array; onSetOpen?: (event: Event) => void; + onSubmenuItemClick?: (event: Event) => void; nestedMenus?: Map; }; @@ -21,6 +22,9 @@ const MenuHook: Hook = { return; } + const pushEvent = this.pushEvent.bind(this); + const getMain = () => this.liveSocket?.main; + const menu = new Menu(el, { id: el.id.replace("menu:", ""), ...(getBoolean(el, "controlled") @@ -38,11 +42,9 @@ const MenuHook: Hook = { ].find((node) => node.getAttribute("data-value") === details.value); const itemRedirect = itemEl?.getAttribute("data-redirect"); const itemNewTab = itemEl?.hasAttribute("data-new-tab"); + const main = getMain(); const doRedirect = - redirect && - details.value && - !this.liveSocket.main.isConnected() && - itemRedirect !== "false"; + redirect && details.value && (main?.isDead ?? true) && itemRedirect !== "false"; if (doRedirect) { if (itemNewTab) { window.open(details.value, "_blank", "noopener,noreferrer"); @@ -51,8 +53,8 @@ const MenuHook: Hook = { } } const eventName = getString(el, "onSelect"); - if (eventName && this.liveSocket.main.isConnected()) { - this.pushEvent(eventName, { + if (eventName && main && !main.isDead && main.isConnected()) { + pushEvent(eventName, { id: el.id, value: details.value ?? null, }); @@ -72,9 +74,10 @@ const MenuHook: Hook = { } }, onOpenChange: (details: OpenChangeDetails) => { + const main = getMain(); const eventName = getString(el, "onOpenChange"); - if (eventName && this.liveSocket.main.isConnected()) { - this.pushEvent(eventName, { + if (eventName && main && !main.isDead && main.isConnected()) { + pushEvent(eventName, { id: el.id, open: details.open ?? false, }); @@ -103,10 +106,10 @@ const MenuHook: Hook = { ); const nestedMenuInstances: Menu[] = []; - nestedMenuElements.forEach((nestedEl) => { + nestedMenuElements.forEach((nestedEl, index) => { const nestedId = nestedEl.id; if (nestedId) { - const nestedMenuId = nestedId.replace("menu:", ""); + const nestedMenuId = `${nestedId}-${index}`; const nestedMenu = new Menu(nestedEl, { id: nestedMenuId, dir: getString(nestedEl, "dir", ["ltr", "rtl"]), @@ -114,6 +117,44 @@ const MenuHook: Hook = { loopFocus: getBoolean(nestedEl, "loopFocus"), typeahead: getBoolean(nestedEl, "typeahead"), composite: getBoolean(nestedEl, "composite"), + onSelect: (details: SelectionDetails) => { + const redirect = getBoolean(el, "redirect"); + const itemEl = [ + ...el.querySelectorAll('[data-scope="menu"][data-part="item"]'), + ].find((node) => node.getAttribute("data-value") === details.value); + const itemRedirect = itemEl?.getAttribute("data-redirect"); + const itemNewTab = itemEl?.hasAttribute("data-new-tab"); + const main = getMain(); + const doRedirect = + redirect && details.value && (main?.isDead ?? true) && itemRedirect !== "false"; + if (doRedirect) { + if (itemNewTab) { + window.open(details.value, "_blank", "noopener,noreferrer"); + } else { + window.location.href = details.value; + } + } + const eventName = getString(el, "onSelect"); + if (eventName && main && !main.isDead && main.isConnected()) { + pushEvent(eventName, { + id: el.id, + value: details.value ?? null, + }); + } + + const eventNameClient = getString(el, "onSelectClient"); + if (eventNameClient) { + el.dispatchEvent( + new CustomEvent(eventNameClient, { + bubbles: true, + detail: { + id: el.id, + value: details.value ?? null, + }, + }) + ); + } + }, }); nestedMenu.init(); @@ -130,15 +171,6 @@ const MenuHook: Hook = { } }); - if (this.menu) { - this.menu.api = this.menu.initApi(); - this.menu.render(); - } - nestedMenuInstances.forEach((nestedMenu) => { - nestedMenu.api = nestedMenu.initApi(); - nestedMenu.render(); - }); - if (this.menu && this.menu.children.length > 0) { this.menu.renderSubmenuTriggers(); } @@ -146,7 +178,7 @@ const MenuHook: Hook = { this.onSetOpen = (event: Event) => { const { open } = (event as CustomEvent<{ open: boolean }>).detail; - menu.api.setOpen(open); + if (menu.api.open !== open) menu.api.setOpen(open); }; el.addEventListener("phx:menu:set-open", this.onSetOpen); @@ -155,7 +187,8 @@ const MenuHook: Hook = { this.handlers.push( this.handleEvent("menu_set_open", (payload: { menu_id?: string; open: boolean }) => { const targetId = payload.menu_id; - if (targetId && targetId !== el.id) return; + const matches = !targetId || el.id === targetId || el.id === `menu:${targetId}`; + if (!matches) return; menu.api.setOpen(payload.open); }) ); diff --git a/assets/hooks/select.ts b/assets/hooks/select.ts index 5338938..b85ecd9 100644 --- a/assets/hooks/select.ts +++ b/assets/hooks/select.ts @@ -1,5 +1,6 @@ import type { Hook } from "phoenix_live_view"; import type { HookInterface, CallbackRef } from "phoenix_live_view/assets/js/types/view_hook"; +import { collection } from "@zag-js/select"; import { Select } from "../components/select"; import type { Props, ValueChangeDetails } from "@zag-js/select"; import type { Direction } from "@zag-js/types"; @@ -7,6 +8,32 @@ import type { PositioningOptions } from "@zag-js/popper"; import { getString, getBoolean, getStringList } from "../lib/util"; +type SelectItem = { + id?: string; + value?: string; + label: string; + disabled?: boolean; + group?: string; +}; + +function buildCollection(items: SelectItem[], hasGroups: boolean) { + if (hasGroups) { + return collection({ + items, + itemToValue: (item: SelectItem) => item.id ?? item.value ?? "", + itemToString: (item: SelectItem) => item.label, + isItemDisabled: (item: SelectItem) => !!item.disabled, + groupBy: (item: SelectItem) => item.group ?? "", + }); + } + return collection({ + items, + itemToValue: (item: SelectItem) => item.id ?? item.value ?? "", + itemToString: (item: SelectItem) => item.label, + isItemDisabled: (item: SelectItem) => !!item.disabled, + }); +} + type SelectHookState = { select?: Select; handlers?: Array; @@ -29,10 +56,12 @@ function transformPositioningOptions(obj: Record): PositioningO const SelectHook: Hook = { mounted(this: object & HookInterface & SelectHookState) { const el = this.el; - const allItems = JSON.parse(el.dataset.collection || "[]"); - const hasGroups = allItems.some((item: { group?: unknown }) => item.group !== undefined); + const allItems = JSON.parse(el.dataset.collection || "[]") as SelectItem[]; + const hasGroups = allItems.some((item: SelectItem) => item.group !== undefined); + const initialCollection = buildCollection(allItems, hasGroups); const selectComponent = new Select(el, { id: el.id, + collection: initialCollection, ...(getBoolean(el, "controlled") ? { value: getStringList(el, "value") } : { defaultValue: getStringList(el, "defaultValue") }), @@ -123,14 +152,14 @@ const SelectHook: Hook = { }, updated(this: object & HookInterface & SelectHookState) { - const newCollection = JSON.parse(this.el.dataset.collection || "[]"); - const hasGroups = newCollection.some((item: { group?: unknown }) => item.group !== undefined); + const newItems = JSON.parse(this.el.dataset.collection || "[]") as SelectItem[]; + const hasGroups = newItems.some((item: SelectItem) => item.group !== undefined); if (this.select) { this.select.hasGroups = hasGroups; - this.select.setOptions(newCollection); - + this.select.setOptions(newItems); this.select.updateProps({ + collection: buildCollection(newItems, hasGroups), id: this.el.id, ...(getBoolean(this.el, "controlled") ? { value: getStringList(this.el, "value") } diff --git a/e2e/lib/e2e_web/controllers/page_html/menu_page.html.heex b/e2e/lib/e2e_web/controllers/page_html/menu_page.html.heex index d55f697..82b049c 100644 --- a/e2e/lib/e2e_web/controllers/page_html/menu_page.html.heex +++ b/e2e/lib/e2e_web/controllers/page_html/menu_page.html.heex @@ -95,19 +95,17 @@ - <.menu - class="menu" - redirect - items={menu_items(@locale)} - > - <:trigger>Corex - <:indicator> - <.icon name="hero-chevron-down" /> - - <:item :let={item}> - {item.label} - - + <.menu + class="menu" + redirect + items={menu_items(@locale)} + > + <:trigger>Corex + <:indicator> + <.icon name="hero-chevron-down" /> + + <:item :let={item}> + {item.label} + + - - diff --git a/e2e/lib/e2e_web/live/menu_live.ex b/e2e/lib/e2e_web/live/menu_live.ex index fac14fa..f39f5bf 100644 --- a/e2e/lib/e2e_web/live/menu_live.ex +++ b/e2e/lib/e2e_web/live/menu_live.ex @@ -52,6 +52,7 @@ defmodule E2eWeb.MenuLive do <.menu class="menu" + id="my-menu" items={[ %Corex.Tree.Item{ id: "edit", @@ -153,6 +154,9 @@ defmodule E2eWeb.MenuLive do <:indicator> <.icon name="hero-chevron-down" /> + <:nested_indicator> + <.icon name="hero-chevron-right" /> + <:item :let={item}> {item.label} @@ -165,14 +169,7 @@ defmodule E2eWeb.MenuLive do Corex.Tree.new([ [ label: "Accordion", - id: "accordion", - children: [ - [label: "Controller", id: "/#{locale}/accordion"], - [label: "Live", id: "/#{locale}/live/accordion"], - [label: "Playground", id: "/#{locale}/playground/accordion"], - [label: "Controlled", id: "/#{locale}/controlled/accordion"], - [label: "Async", id: "/#{locale}/async/accordion"] - ] + id: "/#{locale}/accordion" ], [ label: "Checkbox", diff --git a/e2e/test/components/menu_test.exs b/e2e/test/components/menu_test.exs new file mode 100644 index 0000000..8870284 --- /dev/null +++ b/e2e/test/components/menu_test.exs @@ -0,0 +1,16 @@ +defmodule E2eWeb.MenuTest do + use ExUnit.Case, async: true + use Wallaby.Feature + + alias E2eWeb.MenuModel, as: Menu + + for mode <- [:static, :live] do + @mode mode + + feature "#{@mode} - Menu has no A11y violations", %{session: session} do + session + |> Menu.goto(@mode) + |> Menu.check_accessibility() + end + end +end diff --git a/e2e/test/components/tree_view_test.exs b/e2e/test/components/tree_view_test.exs new file mode 100644 index 0000000..a0ceace --- /dev/null +++ b/e2e/test/components/tree_view_test.exs @@ -0,0 +1,16 @@ +defmodule E2eWeb.TreeViewTest do + use ExUnit.Case, async: true + use Wallaby.Feature + + alias E2eWeb.TreeViewModel, as: TreeView + + for mode <- [:static, :live] do + @mode mode + + feature "#{@mode} - TreeView has no A11y violations", %{session: session} do + session + |> TreeView.goto(@mode) + |> TreeView.check_accessibility() + end + end +end diff --git a/e2e/test/support/models/menu_model.ex b/e2e/test/support/models/menu_model.ex new file mode 100644 index 0000000..11b8f83 --- /dev/null +++ b/e2e/test/support/models/menu_model.ex @@ -0,0 +1,3 @@ +defmodule E2eWeb.MenuModel do + use E2eWeb.Model, component: "menu" +end diff --git a/e2e/test/support/models/tree_view_model.ex b/e2e/test/support/models/tree_view_model.ex new file mode 100644 index 0000000..528bc30 --- /dev/null +++ b/e2e/test/support/models/tree_view_model.ex @@ -0,0 +1,3 @@ +defmodule E2eWeb.TreeViewModel do + use E2eWeb.Model, component: "tree-view" +end diff --git a/lib/components/menu.ex b/lib/components/menu.ex index 19aebb2..77cfb47 100644 --- a/lib/components/menu.ex +++ b/lib/components/menu.ex @@ -383,7 +383,7 @@ defmodule Corex.Menu do on_open_change: @on_open_change, on_open_change_client: @on_open_change_client })}> -
+
@@ -558,27 +556,25 @@ defmodule Corex.Select do
    -
- -
-
+
  • (a || "") <= (b || "") end)} data-scope="select" data-part="item-group" data-id={group || "default"}>
    {group}
    -
  • - - {render_slot(@item, item)} - - - {item.label} - - - {render_slot(@item_indicator)} - -
  • -
    - -
  • +
      +
    • + + {render_slot(@item, item)} + + + {item.label} + + + {render_slot(@item_indicator)} + +
    • +
    +
  • +
  • {render_slot(@item, item)} @@ -589,7 +585,7 @@ defmodule Corex.Select do {render_slot(@item_indicator)}
  • -
    +
    diff --git a/priv/static/chunk-GYNMIQP2.mjs b/priv/static/chunk-GYNMIQP2.mjs new file mode 100644 index 0000000..1778365 --- /dev/null +++ b/priv/static/chunk-GYNMIQP2.mjs @@ -0,0 +1,517 @@ +import { + addDomEvent, + callAll, + contains, + getDocument, + getEventTarget, + getNearestOverflowAncestor, + getWindow, + isContextMenuEvent, + isControlledElement, + isFocusable, + isFunction, + isHTMLElement, + isShadowRoot, + isTouchDevice, + nextTick, + raf, + setStyle, + waitForElement, + warn +} from "./chunk-ZTKS6RKJ.mjs"; + +// ../node_modules/.pnpm/@zag-js+interact-outside@1.33.1/node_modules/@zag-js/interact-outside/dist/index.mjs +function getWindowFrames(win) { + const frames = { + each(cb) { + for (let i = 0; i < win.frames?.length; i += 1) { + const frame = win.frames[i]; + if (frame) cb(frame); + } + }, + addEventListener(event, listener, options) { + frames.each((frame) => { + try { + frame.document.addEventListener(event, listener, options); + } catch { + } + }); + return () => { + try { + frames.removeEventListener(event, listener, options); + } catch { + } + }; + }, + removeEventListener(event, listener, options) { + frames.each((frame) => { + try { + frame.document.removeEventListener(event, listener, options); + } catch { + } + }); + } + }; + return frames; +} +function getParentWindow(win) { + const parent = win.frameElement != null ? win.parent : null; + return { + addEventListener: (event, listener, options) => { + try { + parent?.addEventListener(event, listener, options); + } catch { + } + return () => { + try { + parent?.removeEventListener(event, listener, options); + } catch { + } + }; + }, + removeEventListener: (event, listener, options) => { + try { + parent?.removeEventListener(event, listener, options); + } catch { + } + } + }; +} +var POINTER_OUTSIDE_EVENT = "pointerdown.outside"; +var FOCUS_OUTSIDE_EVENT = "focus.outside"; +function isComposedPathFocusable(composedPath) { + for (const node of composedPath) { + if (isHTMLElement(node) && isFocusable(node)) return true; + } + return false; +} +var isPointerEvent = (event) => "clientY" in event; +function isEventPointWithin(node, event) { + if (!isPointerEvent(event) || !node) return false; + const rect = node.getBoundingClientRect(); + if (rect.width === 0 || rect.height === 0) return false; + return rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width; +} +function isPointInRect(rect, point) { + return rect.y <= point.y && point.y <= rect.y + rect.height && rect.x <= point.x && point.x <= rect.x + rect.width; +} +function isEventWithinScrollbar(event, ancestor) { + if (!ancestor || !isPointerEvent(event)) return false; + const isScrollableY = ancestor.scrollHeight > ancestor.clientHeight; + const onScrollbarY = isScrollableY && event.clientX > ancestor.offsetLeft + ancestor.clientWidth; + const isScrollableX = ancestor.scrollWidth > ancestor.clientWidth; + const onScrollbarX = isScrollableX && event.clientY > ancestor.offsetTop + ancestor.clientHeight; + const rect = { + x: ancestor.offsetLeft, + y: ancestor.offsetTop, + width: ancestor.clientWidth + (isScrollableY ? 16 : 0), + height: ancestor.clientHeight + (isScrollableX ? 16 : 0) + }; + const point = { + x: event.clientX, + y: event.clientY + }; + if (!isPointInRect(rect, point)) return false; + return onScrollbarY || onScrollbarX; +} +function trackInteractOutsideImpl(node, options) { + const { + exclude, + onFocusOutside, + onPointerDownOutside, + onInteractOutside, + defer, + followControlledElements = true + } = options; + if (!node) return; + const doc = getDocument(node); + const win = getWindow(node); + const frames = getWindowFrames(win); + const parentWin = getParentWindow(win); + function isEventOutside(event, target) { + if (!isHTMLElement(target)) return false; + if (!target.isConnected) return false; + if (contains(node, target)) return false; + if (isEventPointWithin(node, event)) return false; + if (followControlledElements && isControlledElement(node, target)) return false; + const triggerEl = doc.querySelector(`[aria-controls="${node.id}"]`); + if (triggerEl) { + const triggerAncestor = getNearestOverflowAncestor(triggerEl); + if (isEventWithinScrollbar(event, triggerAncestor)) return false; + } + const nodeAncestor = getNearestOverflowAncestor(node); + if (isEventWithinScrollbar(event, nodeAncestor)) return false; + return !exclude?.(target); + } + const pointerdownCleanups = /* @__PURE__ */ new Set(); + const isInShadowRoot = isShadowRoot(node?.getRootNode()); + function onPointerDown(event) { + function handler(clickEvent) { + const func = defer && !isTouchDevice() ? raf : (v) => v(); + const evt = clickEvent ?? event; + const composedPath = evt?.composedPath?.() ?? [evt?.target]; + func(() => { + const target = isInShadowRoot ? composedPath[0] : getEventTarget(event); + if (!node || !isEventOutside(event, target)) return; + if (onPointerDownOutside || onInteractOutside) { + const handler2 = callAll(onPointerDownOutside, onInteractOutside); + node.addEventListener(POINTER_OUTSIDE_EVENT, handler2, { once: true }); + } + fireCustomEvent(node, POINTER_OUTSIDE_EVENT, { + bubbles: false, + cancelable: true, + detail: { + originalEvent: evt, + contextmenu: isContextMenuEvent(evt), + focusable: isComposedPathFocusable(composedPath), + target + } + }); + }); + } + if (event.pointerType === "touch") { + pointerdownCleanups.forEach((fn) => fn()); + pointerdownCleanups.add(addDomEvent(doc, "click", handler, { once: true })); + pointerdownCleanups.add(parentWin.addEventListener("click", handler, { once: true })); + pointerdownCleanups.add(frames.addEventListener("click", handler, { once: true })); + } else { + handler(); + } + } + const cleanups = /* @__PURE__ */ new Set(); + const timer = setTimeout(() => { + cleanups.add(addDomEvent(doc, "pointerdown", onPointerDown, true)); + cleanups.add(parentWin.addEventListener("pointerdown", onPointerDown, true)); + cleanups.add(frames.addEventListener("pointerdown", onPointerDown, true)); + }, 0); + function onFocusin(event) { + const func = defer ? raf : (v) => v(); + func(() => { + const composedPath = event?.composedPath?.() ?? [event?.target]; + const target = isInShadowRoot ? composedPath[0] : getEventTarget(event); + if (!node || !isEventOutside(event, target)) return; + if (onFocusOutside || onInteractOutside) { + const handler = callAll(onFocusOutside, onInteractOutside); + node.addEventListener(FOCUS_OUTSIDE_EVENT, handler, { once: true }); + } + fireCustomEvent(node, FOCUS_OUTSIDE_EVENT, { + bubbles: false, + cancelable: true, + detail: { + originalEvent: event, + contextmenu: false, + focusable: isFocusable(target), + target + } + }); + }); + } + if (!isTouchDevice()) { + cleanups.add(addDomEvent(doc, "focusin", onFocusin, true)); + cleanups.add(parentWin.addEventListener("focusin", onFocusin, true)); + cleanups.add(frames.addEventListener("focusin", onFocusin, true)); + } + return () => { + clearTimeout(timer); + pointerdownCleanups.forEach((fn) => fn()); + cleanups.forEach((fn) => fn()); + }; +} +function trackInteractOutside(nodeOrFn, options) { + const { defer } = options; + const func = defer ? raf : (v) => v(); + const cleanups = []; + cleanups.push( + func(() => { + const node = typeof nodeOrFn === "function" ? nodeOrFn() : nodeOrFn; + cleanups.push(trackInteractOutsideImpl(node, options)); + }) + ); + return () => { + cleanups.forEach((fn) => fn?.()); + }; +} +function fireCustomEvent(el, type, init) { + const win = el.ownerDocument.defaultView || window; + const event = new win.CustomEvent(type, init); + return el.dispatchEvent(event); +} + +// ../node_modules/.pnpm/@zag-js+dismissable@1.33.1/node_modules/@zag-js/dismissable/dist/index.mjs +function trackEscapeKeydown(node, fn) { + const handleKeyDown = (event) => { + if (event.key !== "Escape") return; + if (event.isComposing) return; + fn?.(event); + }; + return addDomEvent(getDocument(node), "keydown", handleKeyDown, { capture: true }); +} +var LAYER_REQUEST_DISMISS_EVENT = "layer:request-dismiss"; +var layerStack = { + layers: [], + branches: [], + recentlyRemoved: /* @__PURE__ */ new Set(), + count() { + return this.layers.length; + }, + pointerBlockingLayers() { + return this.layers.filter((layer) => layer.pointerBlocking); + }, + topMostPointerBlockingLayer() { + return [...this.pointerBlockingLayers()].slice(-1)[0]; + }, + hasPointerBlockingLayer() { + return this.pointerBlockingLayers().length > 0; + }, + isBelowPointerBlockingLayer(node) { + const index = this.indexOf(node); + const highestBlockingIndex = this.topMostPointerBlockingLayer() ? this.indexOf(this.topMostPointerBlockingLayer()?.node) : -1; + return index < highestBlockingIndex; + }, + isTopMost(node) { + const layer = this.layers[this.count() - 1]; + return layer?.node === node; + }, + getNestedLayers(node) { + return Array.from(this.layers).slice(this.indexOf(node) + 1); + }, + getLayersByType(type) { + return this.layers.filter((layer) => layer.type === type); + }, + getNestedLayersByType(node, type) { + const index = this.indexOf(node); + if (index === -1) return []; + return this.layers.slice(index + 1).filter((layer) => layer.type === type); + }, + getParentLayerOfType(node, type) { + const index = this.indexOf(node); + if (index <= 0) return void 0; + return this.layers.slice(0, index).reverse().find((layer) => layer.type === type); + }, + countNestedLayersOfType(node, type) { + return this.getNestedLayersByType(node, type).length; + }, + isInNestedLayer(node, target) { + const inNested = this.getNestedLayers(node).some((layer) => contains(layer.node, target)); + if (inNested) return true; + if (this.recentlyRemoved.size > 0) return true; + return false; + }, + isInBranch(target) { + return Array.from(this.branches).some((branch) => contains(branch, target)); + }, + add(layer) { + this.layers.push(layer); + this.syncLayers(); + }, + addBranch(node) { + this.branches.push(node); + }, + remove(node) { + const index = this.indexOf(node); + if (index < 0) return; + this.recentlyRemoved.add(node); + nextTick(() => this.recentlyRemoved.delete(node)); + if (index < this.count() - 1) { + const _layers = this.getNestedLayers(node); + _layers.forEach((layer) => layerStack.dismiss(layer.node, node)); + } + this.layers.splice(index, 1); + this.syncLayers(); + }, + removeBranch(node) { + const index = this.branches.indexOf(node); + if (index >= 0) this.branches.splice(index, 1); + }, + syncLayers() { + this.layers.forEach((layer, index) => { + layer.node.style.setProperty("--layer-index", `${index}`); + layer.node.removeAttribute("data-nested"); + layer.node.removeAttribute("data-has-nested"); + const parentOfSameType = this.getParentLayerOfType(layer.node, layer.type); + if (parentOfSameType) { + layer.node.setAttribute("data-nested", layer.type); + } + const nestedCount = this.countNestedLayersOfType(layer.node, layer.type); + if (nestedCount > 0) { + layer.node.setAttribute("data-has-nested", layer.type); + } + layer.node.style.setProperty("--nested-layer-count", `${nestedCount}`); + }); + }, + indexOf(node) { + return this.layers.findIndex((layer) => layer.node === node); + }, + dismiss(node, parent) { + const index = this.indexOf(node); + if (index === -1) return; + const layer = this.layers[index]; + addListenerOnce(node, LAYER_REQUEST_DISMISS_EVENT, (event) => { + layer.requestDismiss?.(event); + if (!event.defaultPrevented) { + layer?.dismiss(); + } + }); + fireCustomEvent2(node, LAYER_REQUEST_DISMISS_EVENT, { + originalLayer: node, + targetLayer: parent, + originalIndex: index, + targetIndex: parent ? this.indexOf(parent) : -1 + }); + this.syncLayers(); + }, + clear() { + this.remove(this.layers[0].node); + } +}; +function fireCustomEvent2(el, type, detail) { + const win = el.ownerDocument.defaultView || window; + const event = new win.CustomEvent(type, { cancelable: true, bubbles: true, detail }); + return el.dispatchEvent(event); +} +function addListenerOnce(el, type, callback) { + el.addEventListener(type, callback, { once: true }); +} +var originalBodyPointerEvents; +function assignPointerEventToLayers() { + layerStack.layers.forEach(({ node }) => { + node.style.pointerEvents = layerStack.isBelowPointerBlockingLayer(node) ? "none" : "auto"; + }); +} +function clearPointerEvent(node) { + node.style.pointerEvents = ""; +} +function disablePointerEventsOutside(node, persistentElements) { + const doc = getDocument(node); + const cleanups = []; + if (layerStack.hasPointerBlockingLayer() && !doc.body.hasAttribute("data-inert")) { + originalBodyPointerEvents = document.body.style.pointerEvents; + queueMicrotask(() => { + doc.body.style.pointerEvents = "none"; + doc.body.setAttribute("data-inert", ""); + }); + } + persistentElements?.forEach((el) => { + const [promise, abort] = waitForElement( + () => { + const node2 = el(); + return isHTMLElement(node2) ? node2 : null; + }, + { timeout: 1e3 } + ); + promise.then((el2) => cleanups.push(setStyle(el2, { pointerEvents: "auto" }))); + cleanups.push(abort); + }); + return () => { + if (layerStack.hasPointerBlockingLayer()) return; + queueMicrotask(() => { + doc.body.style.pointerEvents = originalBodyPointerEvents; + doc.body.removeAttribute("data-inert"); + if (doc.body.style.length === 0) doc.body.removeAttribute("style"); + }); + cleanups.forEach((fn) => fn()); + }; +} +function trackDismissableElementImpl(node, options) { + const { warnOnMissingNode = true } = options; + if (warnOnMissingNode && !node) { + warn("[@zag-js/dismissable] node is `null` or `undefined`"); + return; + } + if (!node) { + return; + } + const { onDismiss, onRequestDismiss, pointerBlocking, exclude: excludeContainers, debug, type = "dialog" } = options; + const layer = { dismiss: onDismiss, node, type, pointerBlocking, requestDismiss: onRequestDismiss }; + layerStack.add(layer); + assignPointerEventToLayers(); + function onPointerDownOutside(event) { + const target = getEventTarget(event.detail.originalEvent); + if (layerStack.isBelowPointerBlockingLayer(node) || layerStack.isInBranch(target)) return; + options.onPointerDownOutside?.(event); + options.onInteractOutside?.(event); + if (event.defaultPrevented) return; + if (debug) { + console.log("onPointerDownOutside:", event.detail.originalEvent); + } + onDismiss?.(); + } + function onFocusOutside(event) { + const target = getEventTarget(event.detail.originalEvent); + if (layerStack.isInBranch(target)) return; + options.onFocusOutside?.(event); + options.onInteractOutside?.(event); + if (event.defaultPrevented) return; + if (debug) { + console.log("onFocusOutside:", event.detail.originalEvent); + } + onDismiss?.(); + } + function onEscapeKeyDown(event) { + if (!layerStack.isTopMost(node)) return; + options.onEscapeKeyDown?.(event); + if (!event.defaultPrevented && onDismiss) { + event.preventDefault(); + onDismiss(); + } + } + function exclude(target) { + if (!node) return false; + const containers = typeof excludeContainers === "function" ? excludeContainers() : excludeContainers; + const _containers = Array.isArray(containers) ? containers : [containers]; + const persistentElements = options.persistentElements?.map((fn) => fn()).filter(isHTMLElement); + if (persistentElements) _containers.push(...persistentElements); + return _containers.some((node2) => contains(node2, target)) || layerStack.isInNestedLayer(node, target); + } + const cleanups = [ + pointerBlocking ? disablePointerEventsOutside(node, options.persistentElements) : void 0, + trackEscapeKeydown(node, onEscapeKeyDown), + trackInteractOutside(node, { exclude, onFocusOutside, onPointerDownOutside, defer: options.defer }) + ]; + return () => { + layerStack.remove(node); + assignPointerEventToLayers(); + clearPointerEvent(node); + cleanups.forEach((fn) => fn?.()); + }; +} +function trackDismissableElement(nodeOrFn, options) { + const { defer } = options; + const func = defer ? raf : (v) => v(); + const cleanups = []; + cleanups.push( + func(() => { + const node = isFunction(nodeOrFn) ? nodeOrFn() : nodeOrFn; + cleanups.push(trackDismissableElementImpl(node, options)); + }) + ); + return () => { + cleanups.forEach((fn) => fn?.()); + }; +} +function trackDismissableBranch(nodeOrFn, options = {}) { + const { defer } = options; + const func = defer ? raf : (v) => v(); + const cleanups = []; + cleanups.push( + func(() => { + const node = isFunction(nodeOrFn) ? nodeOrFn() : nodeOrFn; + if (!node) { + warn("[@zag-js/dismissable] branch node is `null` or `undefined`"); + return; + } + layerStack.addBranch(node); + cleanups.push(() => { + layerStack.removeBranch(node); + }); + }) + ); + return () => { + cleanups.forEach((fn) => fn?.()); + }; +} + +export { + trackDismissableElement, + trackDismissableBranch +}; diff --git a/priv/static/chunk-NYISECP7.mjs b/priv/static/chunk-NYISECP7.mjs new file mode 100644 index 0000000..a10f7da --- /dev/null +++ b/priv/static/chunk-NYISECP7.mjs @@ -0,0 +1,1075 @@ +import { + hasProp, + isEqual, + isObject +} from "./chunk-ZTKS6RKJ.mjs"; + +// ../node_modules/.pnpm/@zag-js+collection@1.33.1/node_modules/@zag-js/collection/dist/index.mjs +var __defProp = Object.defineProperty; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); +var fallback = { + itemToValue(item) { + if (typeof item === "string") return item; + if (isObject(item) && hasProp(item, "value")) return item.value; + return ""; + }, + itemToString(item) { + if (typeof item === "string") return item; + if (isObject(item) && hasProp(item, "label")) return item.label; + return fallback.itemToValue(item); + }, + isItemDisabled(item) { + if (isObject(item) && hasProp(item, "disabled")) return !!item.disabled; + return false; + } +}; +var ListCollection = class _ListCollection { + constructor(options) { + this.options = options; + __publicField(this, "items"); + __publicField(this, "indexMap", null); + __publicField(this, "copy", (items) => { + return new _ListCollection({ ...this.options, items: items ?? [...this.items] }); + }); + __publicField(this, "isEqual", (other) => { + return isEqual(this.items, other.items); + }); + __publicField(this, "setItems", (items) => { + return this.copy(items); + }); + __publicField(this, "getValues", (items = this.items) => { + const values = []; + for (const item of items) { + const value = this.getItemValue(item); + if (value != null) values.push(value); + } + return values; + }); + __publicField(this, "find", (value) => { + if (value == null) return null; + const index = this.indexOf(value); + return index !== -1 ? this.at(index) : null; + }); + __publicField(this, "findMany", (values) => { + const result = []; + for (const value of values) { + const item = this.find(value); + if (item != null) result.push(item); + } + return result; + }); + __publicField(this, "at", (index) => { + if (!this.options.groupBy && !this.options.groupSort) { + return this.items[index] ?? null; + } + let idx = 0; + const groups = this.group(); + for (const [, items] of groups) { + for (const item of items) { + if (idx === index) return item; + idx++; + } + } + return null; + }); + __publicField(this, "sortFn", (valueA, valueB) => { + const indexA = this.indexOf(valueA); + const indexB = this.indexOf(valueB); + return (indexA ?? 0) - (indexB ?? 0); + }); + __publicField(this, "sort", (values) => { + return [...values].sort(this.sortFn.bind(this)); + }); + __publicField(this, "getItemValue", (item) => { + if (item == null) return null; + return this.options.itemToValue?.(item) ?? fallback.itemToValue(item); + }); + __publicField(this, "getItemDisabled", (item) => { + if (item == null) return false; + return this.options.isItemDisabled?.(item) ?? fallback.isItemDisabled(item); + }); + __publicField(this, "stringifyItem", (item) => { + if (item == null) return null; + return this.options.itemToString?.(item) ?? fallback.itemToString(item); + }); + __publicField(this, "stringify", (value) => { + if (value == null) return null; + return this.stringifyItem(this.find(value)); + }); + __publicField(this, "stringifyItems", (items, separator = ", ") => { + const strs = []; + for (const item of items) { + const str = this.stringifyItem(item); + if (str != null) strs.push(str); + } + return strs.join(separator); + }); + __publicField(this, "stringifyMany", (value, separator) => { + return this.stringifyItems(this.findMany(value), separator); + }); + __publicField(this, "has", (value) => { + return this.indexOf(value) !== -1; + }); + __publicField(this, "hasItem", (item) => { + if (item == null) return false; + return this.has(this.getItemValue(item)); + }); + __publicField(this, "group", () => { + const { groupBy, groupSort } = this.options; + if (!groupBy) return [["", [...this.items]]]; + const groups = /* @__PURE__ */ new Map(); + this.items.forEach((item, index) => { + const groupKey = groupBy(item, index); + if (!groups.has(groupKey)) { + groups.set(groupKey, []); + } + groups.get(groupKey).push(item); + }); + let entries = Array.from(groups.entries()); + if (groupSort) { + entries.sort(([a], [b]) => { + if (typeof groupSort === "function") return groupSort(a, b); + if (Array.isArray(groupSort)) { + const indexA = groupSort.indexOf(a); + const indexB = groupSort.indexOf(b); + if (indexA === -1) return 1; + if (indexB === -1) return -1; + return indexA - indexB; + } + if (groupSort === "asc") return a.localeCompare(b); + if (groupSort === "desc") return b.localeCompare(a); + return 0; + }); + } + return entries; + }); + __publicField(this, "getNextValue", (value, step = 1, clamp = false) => { + let index = this.indexOf(value); + if (index === -1) return null; + index = clamp ? Math.min(index + step, this.size - 1) : index + step; + while (index <= this.size && this.getItemDisabled(this.at(index))) index++; + return this.getItemValue(this.at(index)); + }); + __publicField(this, "getPreviousValue", (value, step = 1, clamp = false) => { + let index = this.indexOf(value); + if (index === -1) return null; + index = clamp ? Math.max(index - step, 0) : index - step; + while (index >= 0 && this.getItemDisabled(this.at(index))) index--; + return this.getItemValue(this.at(index)); + }); + __publicField(this, "indexOf", (value) => { + if (value == null) return -1; + if (!this.options.groupBy && !this.options.groupSort) { + return this.items.findIndex((item) => this.getItemValue(item) === value); + } + if (!this.indexMap) { + this.indexMap = /* @__PURE__ */ new Map(); + let idx = 0; + const groups = this.group(); + for (const [, items] of groups) { + for (const item of items) { + const itemValue = this.getItemValue(item); + if (itemValue != null) { + this.indexMap.set(itemValue, idx); + } + idx++; + } + } + } + return this.indexMap.get(value) ?? -1; + }); + __publicField(this, "getByText", (text, current) => { + const currentIndex = current != null ? this.indexOf(current) : -1; + const isSingleKey = text.length === 1; + for (let i = 0; i < this.items.length; i++) { + const item = this.items[(currentIndex + i + 1) % this.items.length]; + if (isSingleKey && this.getItemValue(item) === current) continue; + if (this.getItemDisabled(item)) continue; + if (match(this.stringifyItem(item), text)) return item; + } + return void 0; + }); + __publicField(this, "search", (queryString, options2) => { + const { state, currentValue, timeout = 350 } = options2; + const search = state.keysSoFar + queryString; + const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]); + const query = isRepeated ? search[0] : search; + const item = this.getByText(query, currentValue); + const value = this.getItemValue(item); + function cleanup() { + clearTimeout(state.timer); + state.timer = -1; + } + function update(value2) { + state.keysSoFar = value2; + cleanup(); + if (value2 !== "") { + state.timer = +setTimeout(() => { + update(""); + cleanup(); + }, timeout); + } + } + update(search); + return value; + }); + __publicField(this, "update", (value, item) => { + let index = this.indexOf(value); + if (index === -1) return this; + return this.copy([...this.items.slice(0, index), item, ...this.items.slice(index + 1)]); + }); + __publicField(this, "upsert", (value, item, mode = "append") => { + let index = this.indexOf(value); + if (index === -1) { + const fn = mode === "append" ? this.append : this.prepend; + return fn(item); + } + return this.copy([...this.items.slice(0, index), item, ...this.items.slice(index + 1)]); + }); + __publicField(this, "insert", (index, ...items) => { + return this.copy(insert(this.items, index, ...items)); + }); + __publicField(this, "insertBefore", (value, ...items) => { + let toIndex = this.indexOf(value); + if (toIndex === -1) { + if (this.items.length === 0) toIndex = 0; + else return this; + } + return this.copy(insert(this.items, toIndex, ...items)); + }); + __publicField(this, "insertAfter", (value, ...items) => { + let toIndex = this.indexOf(value); + if (toIndex === -1) { + if (this.items.length === 0) toIndex = 0; + else return this; + } + return this.copy(insert(this.items, toIndex + 1, ...items)); + }); + __publicField(this, "prepend", (...items) => { + return this.copy(insert(this.items, 0, ...items)); + }); + __publicField(this, "append", (...items) => { + return this.copy(insert(this.items, this.items.length, ...items)); + }); + __publicField(this, "filter", (fn) => { + const filteredItems = this.items.filter((item, index) => fn(this.stringifyItem(item), index, item)); + return this.copy(filteredItems); + }); + __publicField(this, "remove", (...itemsOrValues) => { + const values = itemsOrValues.map( + (itemOrValue) => typeof itemOrValue === "string" ? itemOrValue : this.getItemValue(itemOrValue) + ); + return this.copy( + this.items.filter((item) => { + const value = this.getItemValue(item); + if (value == null) return false; + return !values.includes(value); + }) + ); + }); + __publicField(this, "move", (value, toIndex) => { + const fromIndex = this.indexOf(value); + if (fromIndex === -1) return this; + return this.copy(move(this.items, [fromIndex], toIndex)); + }); + __publicField(this, "moveBefore", (value, ...values) => { + let toIndex = this.items.findIndex((item) => this.getItemValue(item) === value); + if (toIndex === -1) return this; + let indices = values.map((value2) => this.items.findIndex((item) => this.getItemValue(item) === value2)).sort((a, b) => a - b); + return this.copy(move(this.items, indices, toIndex)); + }); + __publicField(this, "moveAfter", (value, ...values) => { + let toIndex = this.items.findIndex((item) => this.getItemValue(item) === value); + if (toIndex === -1) return this; + let indices = values.map((value2) => this.items.findIndex((item) => this.getItemValue(item) === value2)).sort((a, b) => a - b); + return this.copy(move(this.items, indices, toIndex + 1)); + }); + __publicField(this, "reorder", (fromIndex, toIndex) => { + return this.copy(move(this.items, [fromIndex], toIndex)); + }); + __publicField(this, "compareValue", (a, b) => { + const indexA = this.indexOf(a); + const indexB = this.indexOf(b); + if (indexA < indexB) return -1; + if (indexA > indexB) return 1; + return 0; + }); + __publicField(this, "range", (from, to) => { + let keys = []; + let key = from; + while (key != null) { + let item = this.find(key); + if (item) keys.push(key); + if (key === to) return keys; + key = this.getNextValue(key); + } + return []; + }); + __publicField(this, "getValueRange", (from, to) => { + if (from && to) { + if (this.compareValue(from, to) <= 0) { + return this.range(from, to); + } + return this.range(to, from); + } + return []; + }); + __publicField(this, "toString", () => { + let result = ""; + for (const item of this.items) { + const value = this.getItemValue(item); + const label = this.stringifyItem(item); + const disabled = this.getItemDisabled(item); + const itemString = [value, label, disabled].filter(Boolean).join(":"); + result += itemString + ","; + } + return result; + }); + __publicField(this, "toJSON", () => { + return { + size: this.size, + first: this.firstValue, + last: this.lastValue + }; + }); + this.items = [...options.items]; + } + /** + * Returns the number of items in the collection + */ + get size() { + return this.items.length; + } + /** + * Returns the first value in the collection + */ + get firstValue() { + let index = 0; + while (this.getItemDisabled(this.at(index))) index++; + return this.getItemValue(this.at(index)); + } + /** + * Returns the last value in the collection + */ + get lastValue() { + let index = this.size - 1; + while (this.getItemDisabled(this.at(index))) index--; + return this.getItemValue(this.at(index)); + } + *[Symbol.iterator]() { + yield* this.items; + } +}; +var match = (label, query) => { + return !!label?.toLowerCase().startsWith(query.toLowerCase()); +}; +function insert(items, index, ...values) { + return [...items.slice(0, index), ...values, ...items.slice(index)]; +} +function move(items, indices, toIndex) { + indices = [...indices].sort((a, b) => a - b); + const itemsToMove = indices.map((i) => items[i]); + for (let i = indices.length - 1; i >= 0; i--) { + items = [...items.slice(0, indices[i]), ...items.slice(indices[i] + 1)]; + } + toIndex = Math.max(0, toIndex - indices.filter((i) => i < toIndex).length); + return [...items.slice(0, toIndex), ...itemsToMove, ...items.slice(toIndex)]; +} +function access(node, indexPath, options) { + for (let i = 0; i < indexPath.length; i++) node = options.getChildren(node, indexPath.slice(i + 1))[indexPath[i]]; + return node; +} +function ancestorIndexPaths(indexPaths) { + const sortedPaths = sortIndexPaths(indexPaths); + const result = []; + const seen = /* @__PURE__ */ new Set(); + for (const indexPath of sortedPaths) { + const key = indexPath.join(); + if (!seen.has(key)) { + seen.add(key); + result.push(indexPath); + } + } + return result; +} +function compareIndexPaths(a, b) { + for (let i = 0; i < Math.min(a.length, b.length); i++) { + if (a[i] < b[i]) return -1; + if (a[i] > b[i]) return 1; + } + return a.length - b.length; +} +function sortIndexPaths(indexPaths) { + return indexPaths.sort(compareIndexPaths); +} +function find(node, options) { + let found; + visit(node, { + ...options, + onEnter: (child, indexPath) => { + if (options.predicate(child, indexPath)) { + found = child; + return "stop"; + } + } + }); + return found; +} +function findAll(node, options) { + const found = []; + visit(node, { + onEnter: (child, indexPath) => { + if (options.predicate(child, indexPath)) found.push(child); + }, + getChildren: options.getChildren + }); + return found; +} +function findIndexPath(node, options) { + let found; + visit(node, { + onEnter: (child, indexPath) => { + if (options.predicate(child, indexPath)) { + found = [...indexPath]; + return "stop"; + } + }, + getChildren: options.getChildren + }); + return found; +} +function reduce(node, options) { + let result = options.initialResult; + visit(node, { + ...options, + onEnter: (child, indexPath) => { + result = options.nextResult(result, child, indexPath); + } + }); + return result; +} +function flatMap(node, options) { + return reduce(node, { + ...options, + initialResult: [], + nextResult: (result, child, indexPath) => { + result.push(...options.transform(child, indexPath)); + return result; + } + }); +} +function filter(node, options) { + const { predicate, create, getChildren } = options; + const filterRecursive = (node2, indexPath) => { + const children = getChildren(node2, indexPath); + const filteredChildren = []; + children.forEach((child, index) => { + const childIndexPath = [...indexPath, index]; + const filteredChild = filterRecursive(child, childIndexPath); + if (filteredChild) filteredChildren.push(filteredChild); + }); + const isRoot = indexPath.length === 0; + const nodeMatches = predicate(node2, indexPath); + const hasFilteredChildren = filteredChildren.length > 0; + if (isRoot || nodeMatches || hasFilteredChildren) { + return create(node2, filteredChildren, indexPath); + } + return null; + }; + return filterRecursive(node, []) || create(node, [], []); +} +function flatten(rootNode, options) { + const nodes = []; + let idx = 0; + const idxMap = /* @__PURE__ */ new Map(); + const parentMap = /* @__PURE__ */ new Map(); + visit(rootNode, { + getChildren: options.getChildren, + onEnter: (node, indexPath) => { + if (!idxMap.has(node)) { + idxMap.set(node, idx++); + } + const children = options.getChildren(node, indexPath); + children.forEach((child) => { + if (!parentMap.has(child)) { + parentMap.set(child, node); + } + if (!idxMap.has(child)) { + idxMap.set(child, idx++); + } + }); + const _children = children.length > 0 ? children.map((child) => idxMap.get(child)) : void 0; + const parent = parentMap.get(node); + const _parent = parent ? idxMap.get(parent) : void 0; + const _index = idxMap.get(node); + nodes.push({ ...node, _children, _parent, _index }); + } + }); + return nodes; +} +function insertOperation(index, nodes) { + return { type: "insert", index, nodes }; +} +function removeOperation(indexes) { + return { type: "remove", indexes }; +} +function replaceOperation() { + return { type: "replace" }; +} +function splitIndexPath(indexPath) { + return [indexPath.slice(0, -1), indexPath[indexPath.length - 1]]; +} +function getInsertionOperations(indexPath, nodes, operations = /* @__PURE__ */ new Map()) { + const [parentIndexPath, index] = splitIndexPath(indexPath); + for (let i = parentIndexPath.length - 1; i >= 0; i--) { + const parentKey = parentIndexPath.slice(0, i).join(); + switch (operations.get(parentKey)?.type) { + case "remove": + continue; + } + operations.set(parentKey, replaceOperation()); + } + const operation = operations.get(parentIndexPath.join()); + switch (operation?.type) { + case "remove": + operations.set(parentIndexPath.join(), { + type: "removeThenInsert", + removeIndexes: operation.indexes, + insertIndex: index, + insertNodes: nodes + }); + break; + default: + operations.set(parentIndexPath.join(), insertOperation(index, nodes)); + } + return operations; +} +function getRemovalOperations(indexPaths) { + const operations = /* @__PURE__ */ new Map(); + const indexesToRemove = /* @__PURE__ */ new Map(); + for (const indexPath of indexPaths) { + const parentKey = indexPath.slice(0, -1).join(); + const value = indexesToRemove.get(parentKey) ?? []; + value.push(indexPath[indexPath.length - 1]); + indexesToRemove.set( + parentKey, + value.sort((a, b) => a - b) + ); + } + for (const indexPath of indexPaths) { + for (let i = indexPath.length - 2; i >= 0; i--) { + const parentKey = indexPath.slice(0, i).join(); + if (!operations.has(parentKey)) { + operations.set(parentKey, replaceOperation()); + } + } + } + for (const [parentKey, indexes] of indexesToRemove) { + operations.set(parentKey, removeOperation(indexes)); + } + return operations; +} +function getReplaceOperations(indexPath, node) { + const operations = /* @__PURE__ */ new Map(); + const [parentIndexPath, index] = splitIndexPath(indexPath); + for (let i = parentIndexPath.length - 1; i >= 0; i--) { + const parentKey = parentIndexPath.slice(0, i).join(); + operations.set(parentKey, replaceOperation()); + } + operations.set(parentIndexPath.join(), { + type: "removeThenInsert", + removeIndexes: [index], + insertIndex: index, + insertNodes: [node] + }); + return operations; +} +function mutate(node, operations, options) { + return map(node, { + ...options, + getChildren: (node2, indexPath) => { + const key = indexPath.join(); + const operation = operations.get(key); + switch (operation?.type) { + case "replace": + case "remove": + case "removeThenInsert": + case "insert": + return options.getChildren(node2, indexPath); + default: + return []; + } + }, + transform: (node2, children, indexPath) => { + const key = indexPath.join(); + const operation = operations.get(key); + switch (operation?.type) { + case "remove": + return options.create( + node2, + children.filter((_, index) => !operation.indexes.includes(index)), + indexPath + ); + case "removeThenInsert": + const updatedChildren = children.filter((_, index) => !operation.removeIndexes.includes(index)); + const adjustedIndex = operation.removeIndexes.reduce( + (index, removedIndex) => removedIndex < index ? index - 1 : index, + operation.insertIndex + ); + return options.create(node2, splice(updatedChildren, adjustedIndex, 0, ...operation.insertNodes), indexPath); + case "insert": + return options.create(node2, splice(children, operation.index, 0, ...operation.nodes), indexPath); + case "replace": + return options.create(node2, children, indexPath); + default: + return node2; + } + } + }); +} +function splice(array, start, deleteCount, ...items) { + return [...array.slice(0, start), ...items, ...array.slice(start + deleteCount)]; +} +function map(node, options) { + const childrenMap = {}; + visit(node, { + ...options, + onLeave: (child, indexPath) => { + const keyIndexPath = [0, ...indexPath]; + const key = keyIndexPath.join(); + const transformed = options.transform(child, childrenMap[key] ?? [], indexPath); + const parentKey = keyIndexPath.slice(0, -1).join(); + const parentChildren = childrenMap[parentKey] ?? []; + parentChildren.push(transformed); + childrenMap[parentKey] = parentChildren; + } + }); + return childrenMap[""][0]; +} +function insert2(node, options) { + const { nodes, at } = options; + if (at.length === 0) throw new Error(`Can't insert nodes at the root`); + const state = getInsertionOperations(at, nodes); + return mutate(node, state, options); +} +function replace(node, options) { + if (options.at.length === 0) return options.node; + const operations = getReplaceOperations(options.at, options.node); + return mutate(node, operations, options); +} +function remove(node, options) { + if (options.indexPaths.length === 0) return node; + for (const indexPath of options.indexPaths) { + if (indexPath.length === 0) throw new Error(`Can't remove the root node`); + } + const operations = getRemovalOperations(options.indexPaths); + return mutate(node, operations, options); +} +function move2(node, options) { + if (options.indexPaths.length === 0) return node; + for (const indexPath of options.indexPaths) { + if (indexPath.length === 0) throw new Error(`Can't move the root node`); + } + if (options.to.length === 0) throw new Error(`Can't move nodes to the root`); + const _ancestorIndexPaths = ancestorIndexPaths(options.indexPaths); + const nodesToInsert = _ancestorIndexPaths.map((indexPath) => access(node, indexPath, options)); + const operations = getInsertionOperations(options.to, nodesToInsert, getRemovalOperations(_ancestorIndexPaths)); + return mutate(node, operations, options); +} +function visit(node, options) { + const { onEnter, onLeave, getChildren } = options; + let indexPath = []; + let stack = [{ node }]; + const getIndexPath = options.reuseIndexPath ? () => indexPath : () => indexPath.slice(); + while (stack.length > 0) { + let wrapper = stack[stack.length - 1]; + if (wrapper.state === void 0) { + const enterResult = onEnter?.(wrapper.node, getIndexPath()); + if (enterResult === "stop") return; + wrapper.state = enterResult === "skip" ? -1 : 0; + } + const children = wrapper.children || getChildren(wrapper.node, getIndexPath()); + wrapper.children || (wrapper.children = children); + if (wrapper.state !== -1) { + if (wrapper.state < children.length) { + let currentIndex = wrapper.state; + indexPath.push(currentIndex); + stack.push({ node: children[currentIndex] }); + wrapper.state = currentIndex + 1; + continue; + } + const leaveResult = onLeave?.(wrapper.node, getIndexPath()); + if (leaveResult === "stop") return; + } + indexPath.pop(); + stack.pop(); + } +} +var TreeCollection = class _TreeCollection { + constructor(options) { + this.options = options; + __publicField(this, "rootNode"); + __publicField(this, "isEqual", (other) => { + return isEqual(this.rootNode, other.rootNode); + }); + __publicField(this, "getNodeChildren", (node) => { + return this.options.nodeToChildren?.(node) ?? fallbackMethods.nodeToChildren(node) ?? []; + }); + __publicField(this, "resolveIndexPath", (valueOrIndexPath) => { + return typeof valueOrIndexPath === "string" ? this.getIndexPath(valueOrIndexPath) : valueOrIndexPath; + }); + __publicField(this, "resolveNode", (valueOrIndexPath) => { + const indexPath = this.resolveIndexPath(valueOrIndexPath); + return indexPath ? this.at(indexPath) : void 0; + }); + __publicField(this, "getNodeChildrenCount", (node) => { + return this.options.nodeToChildrenCount?.(node) ?? fallbackMethods.nodeToChildrenCount(node); + }); + __publicField(this, "getNodeValue", (node) => { + return this.options.nodeToValue?.(node) ?? fallbackMethods.nodeToValue(node); + }); + __publicField(this, "getNodeDisabled", (node) => { + return this.options.isNodeDisabled?.(node) ?? fallbackMethods.isNodeDisabled(node); + }); + __publicField(this, "stringify", (value) => { + const node = this.findNode(value); + if (!node) return null; + return this.stringifyNode(node); + }); + __publicField(this, "stringifyNode", (node) => { + return this.options.nodeToString?.(node) ?? fallbackMethods.nodeToString(node); + }); + __publicField(this, "getFirstNode", (rootNode = this.rootNode, opts = {}) => { + let firstChild; + visit(rootNode, { + getChildren: this.getNodeChildren, + onEnter: (node, indexPath) => { + if (this.isSameNode(node, rootNode)) return; + if (opts.skip?.({ value: this.getNodeValue(node), node, indexPath })) return "skip"; + if (!firstChild && indexPath.length > 0 && !this.getNodeDisabled(node)) { + firstChild = node; + return "stop"; + } + } + }); + return firstChild; + }); + __publicField(this, "getLastNode", (rootNode = this.rootNode, opts = {}) => { + let lastChild; + visit(rootNode, { + getChildren: this.getNodeChildren, + onEnter: (node, indexPath) => { + if (this.isSameNode(node, rootNode)) return; + if (opts.skip?.({ value: this.getNodeValue(node), node, indexPath })) return "skip"; + if (indexPath.length > 0 && !this.getNodeDisabled(node)) { + lastChild = node; + } + } + }); + return lastChild; + }); + __publicField(this, "at", (indexPath) => { + return access(this.rootNode, indexPath, { + getChildren: this.getNodeChildren + }); + }); + __publicField(this, "findNode", (value, rootNode = this.rootNode) => { + return find(rootNode, { + getChildren: this.getNodeChildren, + predicate: (node) => this.getNodeValue(node) === value + }); + }); + __publicField(this, "findNodes", (values, rootNode = this.rootNode) => { + const v = new Set(values.filter((v2) => v2 != null)); + return findAll(rootNode, { + getChildren: this.getNodeChildren, + predicate: (node) => v.has(this.getNodeValue(node)) + }); + }); + __publicField(this, "sort", (values) => { + return values.reduce((acc, value) => { + const indexPath = this.getIndexPath(value); + if (indexPath) acc.push({ value, indexPath }); + return acc; + }, []).sort((a, b) => compareIndexPaths(a.indexPath, b.indexPath)).map(({ value }) => value); + }); + __publicField(this, "getIndexPath", (value) => { + return findIndexPath(this.rootNode, { + getChildren: this.getNodeChildren, + predicate: (node) => this.getNodeValue(node) === value + }); + }); + __publicField(this, "getValue", (indexPath) => { + const node = this.at(indexPath); + return node ? this.getNodeValue(node) : void 0; + }); + __publicField(this, "getValuePath", (indexPath) => { + if (!indexPath) return []; + const valuePath = []; + let currentPath = [...indexPath]; + while (currentPath.length > 0) { + const node = this.at(currentPath); + if (node) valuePath.unshift(this.getNodeValue(node)); + currentPath.pop(); + } + return valuePath; + }); + __publicField(this, "getDepth", (value) => { + const indexPath = findIndexPath(this.rootNode, { + getChildren: this.getNodeChildren, + predicate: (node) => this.getNodeValue(node) === value + }); + return indexPath?.length ?? 0; + }); + __publicField(this, "isSameNode", (node, other) => { + return this.getNodeValue(node) === this.getNodeValue(other); + }); + __publicField(this, "isRootNode", (node) => { + return this.isSameNode(node, this.rootNode); + }); + __publicField(this, "contains", (parentIndexPath, valueIndexPath) => { + if (!parentIndexPath || !valueIndexPath) return false; + return valueIndexPath.slice(0, parentIndexPath.length).every((_, i) => parentIndexPath[i] === valueIndexPath[i]); + }); + __publicField(this, "getNextNode", (value, opts = {}) => { + let found = false; + let nextNode; + visit(this.rootNode, { + getChildren: this.getNodeChildren, + onEnter: (node, indexPath) => { + if (this.isRootNode(node)) return; + const nodeValue = this.getNodeValue(node); + if (opts.skip?.({ value: nodeValue, node, indexPath })) { + if (nodeValue === value) { + found = true; + } + return "skip"; + } + if (found && !this.getNodeDisabled(node)) { + nextNode = node; + return "stop"; + } + if (nodeValue === value) { + found = true; + } + } + }); + return nextNode; + }); + __publicField(this, "getPreviousNode", (value, opts = {}) => { + let previousNode; + let found = false; + visit(this.rootNode, { + getChildren: this.getNodeChildren, + onEnter: (node, indexPath) => { + if (this.isRootNode(node)) return; + const nodeValue = this.getNodeValue(node); + if (opts.skip?.({ value: nodeValue, node, indexPath })) { + return "skip"; + } + if (nodeValue === value) { + found = true; + return "stop"; + } + if (!this.getNodeDisabled(node)) { + previousNode = node; + } + } + }); + return found ? previousNode : void 0; + }); + __publicField(this, "getParentNodes", (valueOrIndexPath) => { + const indexPath = this.resolveIndexPath(valueOrIndexPath)?.slice(); + if (!indexPath) return []; + const result = []; + while (indexPath.length > 0) { + indexPath.pop(); + const parentNode = this.at(indexPath); + if (parentNode && !this.isRootNode(parentNode)) { + result.unshift(parentNode); + } + } + return result; + }); + __publicField(this, "getDescendantNodes", (valueOrIndexPath, options2) => { + const parentNode = this.resolveNode(valueOrIndexPath); + if (!parentNode) return []; + const result = []; + visit(parentNode, { + getChildren: this.getNodeChildren, + onEnter: (node, nodeIndexPath) => { + if (nodeIndexPath.length === 0) return; + if (!options2?.withBranch && this.isBranchNode(node)) return; + result.push(node); + } + }); + return result; + }); + __publicField(this, "getDescendantValues", (valueOrIndexPath, options2) => { + const children = this.getDescendantNodes(valueOrIndexPath, options2); + return children.map((child) => this.getNodeValue(child)); + }); + __publicField(this, "getParentIndexPath", (indexPath) => { + return indexPath.slice(0, -1); + }); + __publicField(this, "getParentNode", (valueOrIndexPath) => { + const indexPath = this.resolveIndexPath(valueOrIndexPath); + return indexPath ? this.at(this.getParentIndexPath(indexPath)) : void 0; + }); + __publicField(this, "visit", (opts) => { + const { skip, ...rest } = opts; + visit(this.rootNode, { + ...rest, + getChildren: this.getNodeChildren, + onEnter: (node, indexPath) => { + if (this.isRootNode(node)) return; + if (skip?.({ value: this.getNodeValue(node), node, indexPath })) return "skip"; + return rest.onEnter?.(node, indexPath); + } + }); + }); + __publicField(this, "getPreviousSibling", (indexPath) => { + const parentNode = this.getParentNode(indexPath); + if (!parentNode) return; + const siblings = this.getNodeChildren(parentNode); + let idx = indexPath[indexPath.length - 1]; + while (--idx >= 0) { + const sibling = siblings[idx]; + if (!this.getNodeDisabled(sibling)) return sibling; + } + return; + }); + __publicField(this, "getNextSibling", (indexPath) => { + const parentNode = this.getParentNode(indexPath); + if (!parentNode) return; + const siblings = this.getNodeChildren(parentNode); + let idx = indexPath[indexPath.length - 1]; + while (++idx < siblings.length) { + const sibling = siblings[idx]; + if (!this.getNodeDisabled(sibling)) return sibling; + } + return; + }); + __publicField(this, "getSiblingNodes", (indexPath) => { + const parentNode = this.getParentNode(indexPath); + return parentNode ? this.getNodeChildren(parentNode) : []; + }); + __publicField(this, "getValues", (rootNode = this.rootNode) => { + const values = flatMap(rootNode, { + getChildren: this.getNodeChildren, + transform: (node) => [this.getNodeValue(node)] + }); + return values.slice(1); + }); + __publicField(this, "isValidDepth", (indexPath, depth) => { + if (depth == null) return true; + if (typeof depth === "function") return depth(indexPath.length); + return indexPath.length === depth; + }); + __publicField(this, "isBranchNode", (node) => { + return this.getNodeChildren(node).length > 0 || this.getNodeChildrenCount(node) != null; + }); + __publicField(this, "getBranchValues", (rootNode = this.rootNode, opts = {}) => { + let values = []; + visit(rootNode, { + getChildren: this.getNodeChildren, + onEnter: (node, indexPath) => { + if (indexPath.length === 0) return; + const nodeValue = this.getNodeValue(node); + if (opts.skip?.({ value: nodeValue, node, indexPath })) return "skip"; + if (this.isBranchNode(node) && this.isValidDepth(indexPath, opts.depth)) { + values.push(this.getNodeValue(node)); + } + } + }); + return values; + }); + __publicField(this, "flatten", (rootNode = this.rootNode) => { + return flatten(rootNode, { getChildren: this.getNodeChildren }); + }); + __publicField(this, "_create", (node, children) => { + if (this.getNodeChildren(node).length > 0 || children.length > 0) { + return { ...node, children }; + } + return { ...node }; + }); + __publicField(this, "_insert", (rootNode, indexPath, nodes) => { + return this.copy( + insert2(rootNode, { at: indexPath, nodes, getChildren: this.getNodeChildren, create: this._create }) + ); + }); + __publicField(this, "copy", (rootNode) => { + return new _TreeCollection({ ...this.options, rootNode }); + }); + __publicField(this, "_replace", (rootNode, indexPath, node) => { + return this.copy( + replace(rootNode, { at: indexPath, node, getChildren: this.getNodeChildren, create: this._create }) + ); + }); + __publicField(this, "_move", (rootNode, indexPaths, to) => { + return this.copy(move2(rootNode, { indexPaths, to, getChildren: this.getNodeChildren, create: this._create })); + }); + __publicField(this, "_remove", (rootNode, indexPaths) => { + return this.copy(remove(rootNode, { indexPaths, getChildren: this.getNodeChildren, create: this._create })); + }); + __publicField(this, "replace", (indexPath, node) => { + return this._replace(this.rootNode, indexPath, node); + }); + __publicField(this, "remove", (indexPaths) => { + return this._remove(this.rootNode, indexPaths); + }); + __publicField(this, "insertBefore", (indexPath, nodes) => { + const parentNode = this.getParentNode(indexPath); + return parentNode ? this._insert(this.rootNode, indexPath, nodes) : void 0; + }); + __publicField(this, "insertAfter", (indexPath, nodes) => { + const parentNode = this.getParentNode(indexPath); + if (!parentNode) return; + const nextIndex2 = [...indexPath.slice(0, -1), indexPath[indexPath.length - 1] + 1]; + return this._insert(this.rootNode, nextIndex2, nodes); + }); + __publicField(this, "move", (fromIndexPaths, toIndexPath) => { + return this._move(this.rootNode, fromIndexPaths, toIndexPath); + }); + __publicField(this, "filter", (predicate) => { + const filteredRoot = filter(this.rootNode, { + predicate, + getChildren: this.getNodeChildren, + create: this._create + }); + return this.copy(filteredRoot); + }); + __publicField(this, "toJSON", () => { + return this.getValues(this.rootNode); + }); + this.rootNode = options.rootNode; + } +}; +var fallbackMethods = { + nodeToValue(node) { + if (typeof node === "string") return node; + if (isObject(node) && hasProp(node, "value")) return node.value; + return ""; + }, + nodeToString(node) { + if (typeof node === "string") return node; + if (isObject(node) && hasProp(node, "label")) return node.label; + return fallbackMethods.nodeToValue(node); + }, + isNodeDisabled(node) { + if (isObject(node) && hasProp(node, "disabled")) return !!node.disabled; + return false; + }, + nodeToChildren(node) { + return node.children; + }, + nodeToChildrenCount(node) { + if (isObject(node) && hasProp(node, "childrenCount")) return node.childrenCount; + } +}; + +export { + ListCollection, + TreeCollection +}; diff --git a/priv/static/chunk-QD4Z4LOU.mjs b/priv/static/chunk-QD4Z4LOU.mjs new file mode 100644 index 0000000..00e2983 --- /dev/null +++ b/priv/static/chunk-QD4Z4LOU.mjs @@ -0,0 +1,163 @@ +import { + getDocument, + getEventTarget, + getWindow, + isMac, + isVirtualClick +} from "./chunk-ZTKS6RKJ.mjs"; + +// ../node_modules/.pnpm/@zag-js+focus-visible@1.33.1/node_modules/@zag-js/focus-visible/dist/index.mjs +function isValidKey(e) { + return !(e.metaKey || !isMac() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta"); +} +var nonTextInputTypes = /* @__PURE__ */ new Set(["checkbox", "radio", "range", "color", "file", "image", "button", "submit", "reset"]); +function isKeyboardFocusEvent(isTextInput, modality, e) { + const target = e ? getEventTarget(e) : null; + const win = getWindow(target); + isTextInput = isTextInput || target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target?.type) || target instanceof win.HTMLTextAreaElement || target instanceof win.HTMLElement && target.isContentEditable; + return !(isTextInput && modality === "keyboard" && e instanceof win.KeyboardEvent && !Reflect.has(FOCUS_VISIBLE_INPUT_KEYS, e.key)); +} +var currentModality = null; +var changeHandlers = /* @__PURE__ */ new Set(); +var listenerMap = /* @__PURE__ */ new Map(); +var hasEventBeforeFocus = false; +var hasBlurredWindowRecently = false; +var FOCUS_VISIBLE_INPUT_KEYS = { + Tab: true, + Escape: true +}; +function triggerChangeHandlers(modality, e) { + for (let handler of changeHandlers) { + handler(modality, e); + } +} +function handleKeyboardEvent(e) { + hasEventBeforeFocus = true; + if (isValidKey(e)) { + currentModality = "keyboard"; + triggerChangeHandlers("keyboard", e); + } +} +function handlePointerEvent(e) { + currentModality = "pointer"; + if (e.type === "mousedown" || e.type === "pointerdown") { + hasEventBeforeFocus = true; + triggerChangeHandlers("pointer", e); + } +} +function handleClickEvent(e) { + if (isVirtualClick(e)) { + hasEventBeforeFocus = true; + currentModality = "virtual"; + } +} +function handleFocusEvent(e) { + const target = getEventTarget(e); + if (target === getWindow(target) || target === getDocument(target)) { + return; + } + if (!hasEventBeforeFocus && !hasBlurredWindowRecently) { + currentModality = "virtual"; + triggerChangeHandlers("virtual", e); + } + hasEventBeforeFocus = false; + hasBlurredWindowRecently = false; +} +function handleWindowBlur() { + hasEventBeforeFocus = false; + hasBlurredWindowRecently = true; +} +function setupGlobalFocusEvents(root) { + if (typeof window === "undefined" || listenerMap.get(getWindow(root))) { + return; + } + const win = getWindow(root); + const doc = getDocument(root); + let focus = win.HTMLElement.prototype.focus; + function patchedFocus() { + currentModality = "virtual"; + triggerChangeHandlers("virtual", null); + hasEventBeforeFocus = true; + focus.apply(this, arguments); + } + try { + Object.defineProperty(win.HTMLElement.prototype, "focus", { + configurable: true, + value: patchedFocus + }); + } catch { + } + doc.addEventListener("keydown", handleKeyboardEvent, true); + doc.addEventListener("keyup", handleKeyboardEvent, true); + doc.addEventListener("click", handleClickEvent, true); + win.addEventListener("focus", handleFocusEvent, true); + win.addEventListener("blur", handleWindowBlur, false); + if (typeof win.PointerEvent !== "undefined") { + doc.addEventListener("pointerdown", handlePointerEvent, true); + doc.addEventListener("pointermove", handlePointerEvent, true); + doc.addEventListener("pointerup", handlePointerEvent, true); + } else { + doc.addEventListener("mousedown", handlePointerEvent, true); + doc.addEventListener("mousemove", handlePointerEvent, true); + doc.addEventListener("mouseup", handlePointerEvent, true); + } + win.addEventListener( + "beforeunload", + () => { + tearDownWindowFocusTracking(root); + }, + { once: true } + ); + listenerMap.set(win, { focus }); +} +var tearDownWindowFocusTracking = (root, loadListener) => { + const win = getWindow(root); + const doc = getDocument(root); + const listenerData = listenerMap.get(win); + if (!listenerData) { + return; + } + try { + Object.defineProperty(win.HTMLElement.prototype, "focus", { + configurable: true, + value: listenerData.focus + }); + } catch { + } + doc.removeEventListener("keydown", handleKeyboardEvent, true); + doc.removeEventListener("keyup", handleKeyboardEvent, true); + doc.removeEventListener("click", handleClickEvent, true); + win.removeEventListener("focus", handleFocusEvent, true); + win.removeEventListener("blur", handleWindowBlur, false); + if (typeof win.PointerEvent !== "undefined") { + doc.removeEventListener("pointerdown", handlePointerEvent, true); + doc.removeEventListener("pointermove", handlePointerEvent, true); + doc.removeEventListener("pointerup", handlePointerEvent, true); + } else { + doc.removeEventListener("mousedown", handlePointerEvent, true); + doc.removeEventListener("mousemove", handlePointerEvent, true); + doc.removeEventListener("mouseup", handlePointerEvent, true); + } + listenerMap.delete(win); +}; +function isFocusVisible() { + return currentModality === "keyboard"; +} +function trackFocusVisible(props = {}) { + const { isTextInput, autoFocus, onChange, root } = props; + setupGlobalFocusEvents(root); + onChange?.({ isFocusVisible: autoFocus || isFocusVisible(), modality: currentModality }); + const handler = (modality, e) => { + if (!isKeyboardFocusEvent(!!isTextInput, modality, e)) return; + onChange?.({ isFocusVisible: isFocusVisible(), modality }); + }; + changeHandlers.add(handler); + return () => { + changeHandlers.delete(handler); + }; +} + +export { + isFocusVisible, + trackFocusVisible +}; diff --git a/priv/static/chunk-T4BCXOJK.mjs b/priv/static/chunk-T4BCXOJK.mjs new file mode 100644 index 0000000..634578d --- /dev/null +++ b/priv/static/chunk-T4BCXOJK.mjs @@ -0,0 +1,1953 @@ +import { + compact, + getComputedStyle as getComputedStyle2, + getWindow, + isHTMLElement, + isNull, + noop, + raf +} from "./chunk-ZTKS6RKJ.mjs"; + +// ../node_modules/.pnpm/@floating-ui+utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs +var sides = ["top", "right", "bottom", "left"]; +var min = Math.min; +var max = Math.max; +var round = Math.round; +var floor = Math.floor; +var createCoords = (v) => ({ + x: v, + y: v +}); +var oppositeSideMap = { + left: "right", + right: "left", + bottom: "top", + top: "bottom" +}; +var oppositeAlignmentMap = { + start: "end", + end: "start" +}; +function clamp(start, value, end) { + return max(start, min(value, end)); +} +function evaluate(value, param) { + return typeof value === "function" ? value(param) : value; +} +function getSide(placement) { + return placement.split("-")[0]; +} +function getAlignment(placement) { + return placement.split("-")[1]; +} +function getOppositeAxis(axis) { + return axis === "x" ? "y" : "x"; +} +function getAxisLength(axis) { + return axis === "y" ? "height" : "width"; +} +var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]); +function getSideAxis(placement) { + return yAxisSides.has(getSide(placement)) ? "y" : "x"; +} +function getAlignmentAxis(placement) { + return getOppositeAxis(getSideAxis(placement)); +} +function getAlignmentSides(placement, rects, rtl) { + if (rtl === void 0) { + rtl = false; + } + const alignment = getAlignment(placement); + const alignmentAxis = getAlignmentAxis(placement); + const length = getAxisLength(alignmentAxis); + let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; + if (rects.reference[length] > rects.floating[length]) { + mainAlignmentSide = getOppositePlacement(mainAlignmentSide); + } + return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; +} +function getExpandedPlacements(placement) { + const oppositePlacement = getOppositePlacement(placement); + return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; +} +function getOppositeAlignmentPlacement(placement) { + return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]); +} +var lrPlacement = ["left", "right"]; +var rlPlacement = ["right", "left"]; +var tbPlacement = ["top", "bottom"]; +var btPlacement = ["bottom", "top"]; +function getSideList(side, isStart, rtl) { + switch (side) { + case "top": + case "bottom": + if (rtl) return isStart ? rlPlacement : lrPlacement; + return isStart ? lrPlacement : rlPlacement; + case "left": + case "right": + return isStart ? tbPlacement : btPlacement; + default: + return []; + } +} +function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { + const alignment = getAlignment(placement); + let list = getSideList(getSide(placement), direction === "start", rtl); + if (alignment) { + list = list.map((side) => side + "-" + alignment); + if (flipAlignment) { + list = list.concat(list.map(getOppositeAlignmentPlacement)); + } + } + return list; +} +function getOppositePlacement(placement) { + return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]); +} +function expandPaddingObject(padding) { + return { + top: 0, + right: 0, + bottom: 0, + left: 0, + ...padding + }; +} +function getPaddingObject(padding) { + return typeof padding !== "number" ? expandPaddingObject(padding) : { + top: padding, + right: padding, + bottom: padding, + left: padding + }; +} +function rectToClientRect(rect) { + const { + x, + y, + width, + height + } = rect; + return { + width, + height, + top: y, + left: x, + right: x + width, + bottom: y + height, + x, + y + }; +} + +// ../node_modules/.pnpm/@floating-ui+core@1.7.4/node_modules/@floating-ui/core/dist/floating-ui.core.mjs +function computeCoordsFromPlacement(_ref, placement, rtl) { + let { + reference, + floating + } = _ref; + const sideAxis = getSideAxis(placement); + const alignmentAxis = getAlignmentAxis(placement); + const alignLength = getAxisLength(alignmentAxis); + const side = getSide(placement); + const isVertical = sideAxis === "y"; + const commonX = reference.x + reference.width / 2 - floating.width / 2; + const commonY = reference.y + reference.height / 2 - floating.height / 2; + const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; + let coords; + switch (side) { + case "top": + coords = { + x: commonX, + y: reference.y - floating.height + }; + break; + case "bottom": + coords = { + x: commonX, + y: reference.y + reference.height + }; + break; + case "right": + coords = { + x: reference.x + reference.width, + y: commonY + }; + break; + case "left": + coords = { + x: reference.x - floating.width, + y: commonY + }; + break; + default: + coords = { + x: reference.x, + y: reference.y + }; + } + switch (getAlignment(placement)) { + case "start": + coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); + break; + case "end": + coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); + break; + } + return coords; +} +async function detectOverflow(state, options) { + var _await$platform$isEle; + if (options === void 0) { + options = {}; + } + const { + x, + y, + platform: platform2, + rects, + elements, + strategy + } = state; + const { + boundary = "clippingAncestors", + rootBoundary = "viewport", + elementContext = "floating", + altBoundary = false, + padding = 0 + } = evaluate(options, state); + const paddingObject = getPaddingObject(padding); + const altContext = elementContext === "floating" ? "reference" : "floating"; + const element = elements[altBoundary ? altContext : elementContext]; + const clippingClientRect = rectToClientRect(await platform2.getClippingRect({ + element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)), + boundary, + rootBoundary, + strategy + })); + const rect = elementContext === "floating" ? { + x, + y, + width: rects.floating.width, + height: rects.floating.height + } : rects.reference; + const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating)); + const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || { + x: 1, + y: 1 + } : { + x: 1, + y: 1 + }; + const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({ + elements, + rect, + offsetParent, + strategy + }) : rect); + return { + top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, + bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, + left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, + right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x + }; +} +var computePosition = async (reference, floating, config) => { + const { + placement = "bottom", + strategy = "absolute", + middleware = [], + platform: platform2 + } = config; + const validMiddleware = middleware.filter(Boolean); + const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating)); + let rects = await platform2.getElementRects({ + reference, + floating, + strategy + }); + let { + x, + y + } = computeCoordsFromPlacement(rects, placement, rtl); + let statefulPlacement = placement; + let middlewareData = {}; + let resetCount = 0; + for (let i = 0; i < validMiddleware.length; i++) { + var _platform$detectOverf; + const { + name, + fn + } = validMiddleware[i]; + const { + x: nextX, + y: nextY, + data, + reset + } = await fn({ + x, + y, + initialPlacement: placement, + placement: statefulPlacement, + strategy, + middlewareData, + rects, + platform: { + ...platform2, + detectOverflow: (_platform$detectOverf = platform2.detectOverflow) != null ? _platform$detectOverf : detectOverflow + }, + elements: { + reference, + floating + } + }); + x = nextX != null ? nextX : x; + y = nextY != null ? nextY : y; + middlewareData = { + ...middlewareData, + [name]: { + ...middlewareData[name], + ...data + } + }; + if (reset && resetCount <= 50) { + resetCount++; + if (typeof reset === "object") { + if (reset.placement) { + statefulPlacement = reset.placement; + } + if (reset.rects) { + rects = reset.rects === true ? await platform2.getElementRects({ + reference, + floating, + strategy + }) : reset.rects; + } + ({ + x, + y + } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); + } + i = -1; + } + } + return { + x, + y, + placement: statefulPlacement, + strategy, + middlewareData + }; +}; +var arrow = (options) => ({ + name: "arrow", + options, + async fn(state) { + const { + x, + y, + placement, + rects, + platform: platform2, + elements, + middlewareData + } = state; + const { + element, + padding = 0 + } = evaluate(options, state) || {}; + if (element == null) { + return {}; + } + const paddingObject = getPaddingObject(padding); + const coords = { + x, + y + }; + const axis = getAlignmentAxis(placement); + const length = getAxisLength(axis); + const arrowDimensions = await platform2.getDimensions(element); + const isYAxis = axis === "y"; + const minProp = isYAxis ? "top" : "left"; + const maxProp = isYAxis ? "bottom" : "right"; + const clientProp = isYAxis ? "clientHeight" : "clientWidth"; + const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; + const startDiff = coords[axis] - rects.reference[axis]; + const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element)); + let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0; + if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) { + clientSize = elements.floating[clientProp] || rects.floating[length]; + } + const centerToReference = endDiff / 2 - startDiff / 2; + const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; + const minPadding = min(paddingObject[minProp], largestPossiblePadding); + const maxPadding = min(paddingObject[maxProp], largestPossiblePadding); + const min$1 = minPadding; + const max2 = clientSize - arrowDimensions[length] - maxPadding; + const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; + const offset3 = clamp(min$1, center, max2); + const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset3 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; + const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0; + return { + [axis]: coords[axis] + alignmentOffset, + data: { + [axis]: offset3, + centerOffset: center - offset3 - alignmentOffset, + ...shouldAddOffset && { + alignmentOffset + } + }, + reset: shouldAddOffset + }; + } +}); +var flip = function(options) { + if (options === void 0) { + options = {}; + } + return { + name: "flip", + options, + async fn(state) { + var _middlewareData$arrow, _middlewareData$flip; + const { + placement, + middlewareData, + rects, + initialPlacement, + platform: platform2, + elements + } = state; + const { + mainAxis: checkMainAxis = true, + crossAxis: checkCrossAxis = true, + fallbackPlacements: specifiedFallbackPlacements, + fallbackStrategy = "bestFit", + fallbackAxisSideDirection = "none", + flipAlignment = true, + ...detectOverflowOptions + } = evaluate(options, state); + if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { + return {}; + } + const side = getSide(placement); + const initialSideAxis = getSideAxis(initialPlacement); + const isBasePlacement = getSide(initialPlacement) === initialPlacement; + const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)); + const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); + const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none"; + if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) { + fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); + } + const placements2 = [initialPlacement, ...fallbackPlacements]; + const overflow = await platform2.detectOverflow(state, detectOverflowOptions); + const overflows = []; + let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; + if (checkMainAxis) { + overflows.push(overflow[side]); + } + if (checkCrossAxis) { + const sides2 = getAlignmentSides(placement, rects, rtl); + overflows.push(overflow[sides2[0]], overflow[sides2[1]]); + } + overflowsData = [...overflowsData, { + placement, + overflows + }]; + if (!overflows.every((side2) => side2 <= 0)) { + var _middlewareData$flip2, _overflowsData$filter; + const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; + const nextPlacement = placements2[nextIndex]; + if (nextPlacement) { + const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false; + if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis + // overflows the main axis. + overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) { + return { + data: { + index: nextIndex, + overflows: overflowsData + }, + reset: { + placement: nextPlacement + } + }; + } + } + let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; + if (!resetPlacement) { + switch (fallbackStrategy) { + case "bestFit": { + var _overflowsData$filter2; + const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => { + if (hasFallbackAxisSideDirection) { + const currentSideAxis = getSideAxis(d.placement); + return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal + // reading directions favoring greater width. + currentSideAxis === "y"; + } + return true; + }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0]; + if (placement2) { + resetPlacement = placement2; + } + break; + } + case "initialPlacement": + resetPlacement = initialPlacement; + break; + } + } + if (placement !== resetPlacement) { + return { + reset: { + placement: resetPlacement + } + }; + } + } + return {}; + } + }; +}; +function getSideOffsets(overflow, rect) { + return { + top: overflow.top - rect.height, + right: overflow.right - rect.width, + bottom: overflow.bottom - rect.height, + left: overflow.left - rect.width + }; +} +function isAnySideFullyClipped(overflow) { + return sides.some((side) => overflow[side] >= 0); +} +var hide = function(options) { + if (options === void 0) { + options = {}; + } + return { + name: "hide", + options, + async fn(state) { + const { + rects, + platform: platform2 + } = state; + const { + strategy = "referenceHidden", + ...detectOverflowOptions + } = evaluate(options, state); + switch (strategy) { + case "referenceHidden": { + const overflow = await platform2.detectOverflow(state, { + ...detectOverflowOptions, + elementContext: "reference" + }); + const offsets = getSideOffsets(overflow, rects.reference); + return { + data: { + referenceHiddenOffsets: offsets, + referenceHidden: isAnySideFullyClipped(offsets) + } + }; + } + case "escaped": { + const overflow = await platform2.detectOverflow(state, { + ...detectOverflowOptions, + altBoundary: true + }); + const offsets = getSideOffsets(overflow, rects.floating); + return { + data: { + escapedOffsets: offsets, + escaped: isAnySideFullyClipped(offsets) + } + }; + } + default: { + return {}; + } + } + } + }; +}; +var originSides = /* @__PURE__ */ new Set(["left", "top"]); +async function convertValueToCoords(state, options) { + const { + placement, + platform: platform2, + elements + } = state; + const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)); + const side = getSide(placement); + const alignment = getAlignment(placement); + const isVertical = getSideAxis(placement) === "y"; + const mainAxisMulti = originSides.has(side) ? -1 : 1; + const crossAxisMulti = rtl && isVertical ? -1 : 1; + const rawValue = evaluate(options, state); + let { + mainAxis, + crossAxis, + alignmentAxis + } = typeof rawValue === "number" ? { + mainAxis: rawValue, + crossAxis: 0, + alignmentAxis: null + } : { + mainAxis: rawValue.mainAxis || 0, + crossAxis: rawValue.crossAxis || 0, + alignmentAxis: rawValue.alignmentAxis + }; + if (alignment && typeof alignmentAxis === "number") { + crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; + } + return isVertical ? { + x: crossAxis * crossAxisMulti, + y: mainAxis * mainAxisMulti + } : { + x: mainAxis * mainAxisMulti, + y: crossAxis * crossAxisMulti + }; +} +var offset = function(options) { + if (options === void 0) { + options = 0; + } + return { + name: "offset", + options, + async fn(state) { + var _middlewareData$offse, _middlewareData$arrow; + const { + x, + y, + placement, + middlewareData + } = state; + const diffCoords = await convertValueToCoords(state, options); + if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { + return {}; + } + return { + x: x + diffCoords.x, + y: y + diffCoords.y, + data: { + ...diffCoords, + placement + } + }; + } + }; +}; +var shift = function(options) { + if (options === void 0) { + options = {}; + } + return { + name: "shift", + options, + async fn(state) { + const { + x, + y, + placement, + platform: platform2 + } = state; + const { + mainAxis: checkMainAxis = true, + crossAxis: checkCrossAxis = false, + limiter = { + fn: (_ref) => { + let { + x: x2, + y: y2 + } = _ref; + return { + x: x2, + y: y2 + }; + } + }, + ...detectOverflowOptions + } = evaluate(options, state); + const coords = { + x, + y + }; + const overflow = await platform2.detectOverflow(state, detectOverflowOptions); + const crossAxis = getSideAxis(getSide(placement)); + const mainAxis = getOppositeAxis(crossAxis); + let mainAxisCoord = coords[mainAxis]; + let crossAxisCoord = coords[crossAxis]; + if (checkMainAxis) { + const minSide = mainAxis === "y" ? "top" : "left"; + const maxSide = mainAxis === "y" ? "bottom" : "right"; + const min2 = mainAxisCoord + overflow[minSide]; + const max2 = mainAxisCoord - overflow[maxSide]; + mainAxisCoord = clamp(min2, mainAxisCoord, max2); + } + if (checkCrossAxis) { + const minSide = crossAxis === "y" ? "top" : "left"; + const maxSide = crossAxis === "y" ? "bottom" : "right"; + const min2 = crossAxisCoord + overflow[minSide]; + const max2 = crossAxisCoord - overflow[maxSide]; + crossAxisCoord = clamp(min2, crossAxisCoord, max2); + } + const limitedCoords = limiter.fn({ + ...state, + [mainAxis]: mainAxisCoord, + [crossAxis]: crossAxisCoord + }); + return { + ...limitedCoords, + data: { + x: limitedCoords.x - x, + y: limitedCoords.y - y, + enabled: { + [mainAxis]: checkMainAxis, + [crossAxis]: checkCrossAxis + } + } + }; + } + }; +}; +var limitShift = function(options) { + if (options === void 0) { + options = {}; + } + return { + options, + fn(state) { + const { + x, + y, + placement, + rects, + middlewareData + } = state; + const { + offset: offset3 = 0, + mainAxis: checkMainAxis = true, + crossAxis: checkCrossAxis = true + } = evaluate(options, state); + const coords = { + x, + y + }; + const crossAxis = getSideAxis(placement); + const mainAxis = getOppositeAxis(crossAxis); + let mainAxisCoord = coords[mainAxis]; + let crossAxisCoord = coords[crossAxis]; + const rawOffset = evaluate(offset3, state); + const computedOffset = typeof rawOffset === "number" ? { + mainAxis: rawOffset, + crossAxis: 0 + } : { + mainAxis: 0, + crossAxis: 0, + ...rawOffset + }; + if (checkMainAxis) { + const len = mainAxis === "y" ? "height" : "width"; + const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; + const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; + if (mainAxisCoord < limitMin) { + mainAxisCoord = limitMin; + } else if (mainAxisCoord > limitMax) { + mainAxisCoord = limitMax; + } + } + if (checkCrossAxis) { + var _middlewareData$offse, _middlewareData$offse2; + const len = mainAxis === "y" ? "width" : "height"; + const isOriginSide = originSides.has(getSide(placement)); + const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); + const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); + if (crossAxisCoord < limitMin) { + crossAxisCoord = limitMin; + } else if (crossAxisCoord > limitMax) { + crossAxisCoord = limitMax; + } + } + return { + [mainAxis]: mainAxisCoord, + [crossAxis]: crossAxisCoord + }; + } + }; +}; +var size = function(options) { + if (options === void 0) { + options = {}; + } + return { + name: "size", + options, + async fn(state) { + var _state$middlewareData, _state$middlewareData2; + const { + placement, + rects, + platform: platform2, + elements + } = state; + const { + apply = () => { + }, + ...detectOverflowOptions + } = evaluate(options, state); + const overflow = await platform2.detectOverflow(state, detectOverflowOptions); + const side = getSide(placement); + const alignment = getAlignment(placement); + const isYAxis = getSideAxis(placement) === "y"; + const { + width, + height + } = rects.floating; + let heightSide; + let widthSide; + if (side === "top" || side === "bottom") { + heightSide = side; + widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; + } else { + widthSide = side; + heightSide = alignment === "end" ? "top" : "bottom"; + } + const maximumClippingHeight = height - overflow.top - overflow.bottom; + const maximumClippingWidth = width - overflow.left - overflow.right; + const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); + const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); + const noShift = !state.middlewareData.shift; + let availableHeight = overflowAvailableHeight; + let availableWidth = overflowAvailableWidth; + if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) { + availableWidth = maximumClippingWidth; + } + if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) { + availableHeight = maximumClippingHeight; + } + if (noShift && !alignment) { + const xMin = max(overflow.left, 0); + const xMax = max(overflow.right, 0); + const yMin = max(overflow.top, 0); + const yMax = max(overflow.bottom, 0); + if (isYAxis) { + availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); + } else { + availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); + } + } + await apply({ + ...state, + availableWidth, + availableHeight + }); + const nextDimensions = await platform2.getDimensions(elements.floating); + if (width !== nextDimensions.width || height !== nextDimensions.height) { + return { + reset: { + rects: true + } + }; + } + return {}; + } + }; +}; + +// ../node_modules/.pnpm/@floating-ui+utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs +function hasWindow() { + return typeof window !== "undefined"; +} +function getNodeName(node) { + if (isNode(node)) { + return (node.nodeName || "").toLowerCase(); + } + return "#document"; +} +function getWindow2(node) { + var _node$ownerDocument; + return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; +} +function getDocumentElement(node) { + var _ref; + return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; +} +function isNode(value) { + if (!hasWindow()) { + return false; + } + return value instanceof Node || value instanceof getWindow2(value).Node; +} +function isElement(value) { + if (!hasWindow()) { + return false; + } + return value instanceof Element || value instanceof getWindow2(value).Element; +} +function isHTMLElement2(value) { + if (!hasWindow()) { + return false; + } + return value instanceof HTMLElement || value instanceof getWindow2(value).HTMLElement; +} +function isShadowRoot(value) { + if (!hasWindow() || typeof ShadowRoot === "undefined") { + return false; + } + return value instanceof ShadowRoot || value instanceof getWindow2(value).ShadowRoot; +} +var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]); +function isOverflowElement(element) { + const { + overflow, + overflowX, + overflowY, + display + } = getComputedStyle3(element); + return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display); +} +var tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]); +function isTableElement(element) { + return tableElements.has(getNodeName(element)); +} +var topLayerSelectors = [":popover-open", ":modal"]; +function isTopLayer(element) { + return topLayerSelectors.some((selector) => { + try { + return element.matches(selector); + } catch (_e) { + return false; + } + }); +} +var transformProperties = ["transform", "translate", "scale", "rotate", "perspective"]; +var willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"]; +var containValues = ["paint", "layout", "strict", "content"]; +function isContainingBlock(elementOrCss) { + const webkit = isWebKit(); + const css = isElement(elementOrCss) ? getComputedStyle3(elementOrCss) : elementOrCss; + return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value)); +} +function getContainingBlock(element) { + let currentNode = getParentNode(element); + while (isHTMLElement2(currentNode) && !isLastTraversableNode(currentNode)) { + if (isContainingBlock(currentNode)) { + return currentNode; + } else if (isTopLayer(currentNode)) { + return null; + } + currentNode = getParentNode(currentNode); + } + return null; +} +function isWebKit() { + if (typeof CSS === "undefined" || !CSS.supports) return false; + return CSS.supports("-webkit-backdrop-filter", "none"); +} +var lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]); +function isLastTraversableNode(node) { + return lastTraversableNodeNames.has(getNodeName(node)); +} +function getComputedStyle3(element) { + return getWindow2(element).getComputedStyle(element); +} +function getNodeScroll(element) { + if (isElement(element)) { + return { + scrollLeft: element.scrollLeft, + scrollTop: element.scrollTop + }; + } + return { + scrollLeft: element.scrollX, + scrollTop: element.scrollY + }; +} +function getParentNode(node) { + if (getNodeName(node) === "html") { + return node; + } + const result = ( + // Step into the shadow DOM of the parent of a slotted node. + node.assignedSlot || // DOM Element detected. + node.parentNode || // ShadowRoot detected. + isShadowRoot(node) && node.host || // Fallback. + getDocumentElement(node) + ); + return isShadowRoot(result) ? result.host : result; +} +function getNearestOverflowAncestor(node) { + const parentNode = getParentNode(node); + if (isLastTraversableNode(parentNode)) { + return node.ownerDocument ? node.ownerDocument.body : node.body; + } + if (isHTMLElement2(parentNode) && isOverflowElement(parentNode)) { + return parentNode; + } + return getNearestOverflowAncestor(parentNode); +} +function getOverflowAncestors(node, list, traverseIframes) { + var _node$ownerDocument2; + if (list === void 0) { + list = []; + } + if (traverseIframes === void 0) { + traverseIframes = true; + } + const scrollableAncestor = getNearestOverflowAncestor(node); + const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); + const win = getWindow2(scrollableAncestor); + if (isBody) { + const frameElement = getFrameElement(win); + return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []); + } + return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); +} +function getFrameElement(win) { + return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null; +} + +// ../node_modules/.pnpm/@floating-ui+dom@1.7.5/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs +function getCssDimensions(element) { + const css = getComputedStyle3(element); + let width = parseFloat(css.width) || 0; + let height = parseFloat(css.height) || 0; + const hasOffset = isHTMLElement2(element); + const offsetWidth = hasOffset ? element.offsetWidth : width; + const offsetHeight = hasOffset ? element.offsetHeight : height; + const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; + if (shouldFallback) { + width = offsetWidth; + height = offsetHeight; + } + return { + width, + height, + $: shouldFallback + }; +} +function unwrapElement(element) { + return !isElement(element) ? element.contextElement : element; +} +function getScale(element) { + const domElement = unwrapElement(element); + if (!isHTMLElement2(domElement)) { + return createCoords(1); + } + const rect = domElement.getBoundingClientRect(); + const { + width, + height, + $ + } = getCssDimensions(domElement); + let x = ($ ? round(rect.width) : rect.width) / width; + let y = ($ ? round(rect.height) : rect.height) / height; + if (!x || !Number.isFinite(x)) { + x = 1; + } + if (!y || !Number.isFinite(y)) { + y = 1; + } + return { + x, + y + }; +} +var noOffsets = /* @__PURE__ */ createCoords(0); +function getVisualOffsets(element) { + const win = getWindow2(element); + if (!isWebKit() || !win.visualViewport) { + return noOffsets; + } + return { + x: win.visualViewport.offsetLeft, + y: win.visualViewport.offsetTop + }; +} +function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { + if (isFixed === void 0) { + isFixed = false; + } + if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow2(element)) { + return false; + } + return isFixed; +} +function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { + if (includeScale === void 0) { + includeScale = false; + } + if (isFixedStrategy === void 0) { + isFixedStrategy = false; + } + const clientRect = element.getBoundingClientRect(); + const domElement = unwrapElement(element); + let scale = createCoords(1); + if (includeScale) { + if (offsetParent) { + if (isElement(offsetParent)) { + scale = getScale(offsetParent); + } + } else { + scale = getScale(element); + } + } + const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); + let x = (clientRect.left + visualOffsets.x) / scale.x; + let y = (clientRect.top + visualOffsets.y) / scale.y; + let width = clientRect.width / scale.x; + let height = clientRect.height / scale.y; + if (domElement) { + const win = getWindow2(domElement); + const offsetWin = offsetParent && isElement(offsetParent) ? getWindow2(offsetParent) : offsetParent; + let currentWin = win; + let currentIFrame = getFrameElement(currentWin); + while (currentIFrame && offsetParent && offsetWin !== currentWin) { + const iframeScale = getScale(currentIFrame); + const iframeRect = currentIFrame.getBoundingClientRect(); + const css = getComputedStyle3(currentIFrame); + const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; + const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; + x *= iframeScale.x; + y *= iframeScale.y; + width *= iframeScale.x; + height *= iframeScale.y; + x += left; + y += top; + currentWin = getWindow2(currentIFrame); + currentIFrame = getFrameElement(currentWin); + } + } + return rectToClientRect({ + width, + height, + x, + y + }); +} +function getWindowScrollBarX(element, rect) { + const leftScroll = getNodeScroll(element).scrollLeft; + if (!rect) { + return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; + } + return rect.left + leftScroll; +} +function getHTMLOffset(documentElement, scroll) { + const htmlRect = documentElement.getBoundingClientRect(); + const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect); + const y = htmlRect.top + scroll.scrollTop; + return { + x, + y + }; +} +function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { + let { + elements, + rect, + offsetParent, + strategy + } = _ref; + const isFixed = strategy === "fixed"; + const documentElement = getDocumentElement(offsetParent); + const topLayer = elements ? isTopLayer(elements.floating) : false; + if (offsetParent === documentElement || topLayer && isFixed) { + return rect; + } + let scroll = { + scrollLeft: 0, + scrollTop: 0 + }; + let scale = createCoords(1); + const offsets = createCoords(0); + const isOffsetParentAnElement = isHTMLElement2(offsetParent); + if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { + if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { + scroll = getNodeScroll(offsetParent); + } + if (isHTMLElement2(offsetParent)) { + const offsetRect = getBoundingClientRect(offsetParent); + scale = getScale(offsetParent); + offsets.x = offsetRect.x + offsetParent.clientLeft; + offsets.y = offsetRect.y + offsetParent.clientTop; + } + } + const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); + return { + width: rect.width * scale.x, + height: rect.height * scale.y, + x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x, + y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y + }; +} +function getClientRects(element) { + return Array.from(element.getClientRects()); +} +function getDocumentRect(element) { + const html = getDocumentElement(element); + const scroll = getNodeScroll(element); + const body = element.ownerDocument.body; + const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); + const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); + let x = -scroll.scrollLeft + getWindowScrollBarX(element); + const y = -scroll.scrollTop; + if (getComputedStyle3(body).direction === "rtl") { + x += max(html.clientWidth, body.clientWidth) - width; + } + return { + width, + height, + x, + y + }; +} +var SCROLLBAR_MAX = 25; +function getViewportRect(element, strategy) { + const win = getWindow2(element); + const html = getDocumentElement(element); + const visualViewport = win.visualViewport; + let width = html.clientWidth; + let height = html.clientHeight; + let x = 0; + let y = 0; + if (visualViewport) { + width = visualViewport.width; + height = visualViewport.height; + const visualViewportBased = isWebKit(); + if (!visualViewportBased || visualViewportBased && strategy === "fixed") { + x = visualViewport.offsetLeft; + y = visualViewport.offsetTop; + } + } + const windowScrollbarX = getWindowScrollBarX(html); + if (windowScrollbarX <= 0) { + const doc = html.ownerDocument; + const body = doc.body; + const bodyStyles = getComputedStyle(body); + const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0; + const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline); + if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) { + width -= clippingStableScrollbarWidth; + } + } else if (windowScrollbarX <= SCROLLBAR_MAX) { + width += windowScrollbarX; + } + return { + width, + height, + x, + y + }; +} +var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]); +function getInnerBoundingClientRect(element, strategy) { + const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); + const top = clientRect.top + element.clientTop; + const left = clientRect.left + element.clientLeft; + const scale = isHTMLElement2(element) ? getScale(element) : createCoords(1); + const width = element.clientWidth * scale.x; + const height = element.clientHeight * scale.y; + const x = left * scale.x; + const y = top * scale.y; + return { + width, + height, + x, + y + }; +} +function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { + let rect; + if (clippingAncestor === "viewport") { + rect = getViewportRect(element, strategy); + } else if (clippingAncestor === "document") { + rect = getDocumentRect(getDocumentElement(element)); + } else if (isElement(clippingAncestor)) { + rect = getInnerBoundingClientRect(clippingAncestor, strategy); + } else { + const visualOffsets = getVisualOffsets(element); + rect = { + x: clippingAncestor.x - visualOffsets.x, + y: clippingAncestor.y - visualOffsets.y, + width: clippingAncestor.width, + height: clippingAncestor.height + }; + } + return rectToClientRect(rect); +} +function hasFixedPositionAncestor(element, stopNode) { + const parentNode = getParentNode(element); + if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { + return false; + } + return getComputedStyle3(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); +} +function getClippingElementAncestors(element, cache) { + const cachedResult = cache.get(element); + if (cachedResult) { + return cachedResult; + } + let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); + let currentContainingBlockComputedStyle = null; + const elementIsFixed = getComputedStyle3(element).position === "fixed"; + let currentNode = elementIsFixed ? getParentNode(element) : element; + while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { + const computedStyle = getComputedStyle3(currentNode); + const currentNodeIsContaining = isContainingBlock(currentNode); + if (!currentNodeIsContaining && computedStyle.position === "fixed") { + currentContainingBlockComputedStyle = null; + } + const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); + if (shouldDropCurrentNode) { + result = result.filter((ancestor) => ancestor !== currentNode); + } else { + currentContainingBlockComputedStyle = computedStyle; + } + currentNode = getParentNode(currentNode); + } + cache.set(element, result); + return result; +} +function getClippingRect(_ref) { + let { + element, + boundary, + rootBoundary, + strategy + } = _ref; + const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); + const clippingAncestors = [...elementClippingAncestors, rootBoundary]; + const firstClippingAncestor = clippingAncestors[0]; + const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => { + const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy); + accRect.top = max(rect.top, accRect.top); + accRect.right = min(rect.right, accRect.right); + accRect.bottom = min(rect.bottom, accRect.bottom); + accRect.left = max(rect.left, accRect.left); + return accRect; + }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy)); + return { + width: clippingRect.right - clippingRect.left, + height: clippingRect.bottom - clippingRect.top, + x: clippingRect.left, + y: clippingRect.top + }; +} +function getDimensions(element) { + const { + width, + height + } = getCssDimensions(element); + return { + width, + height + }; +} +function getRectRelativeToOffsetParent(element, offsetParent, strategy) { + const isOffsetParentAnElement = isHTMLElement2(offsetParent); + const documentElement = getDocumentElement(offsetParent); + const isFixed = strategy === "fixed"; + const rect = getBoundingClientRect(element, true, isFixed, offsetParent); + let scroll = { + scrollLeft: 0, + scrollTop: 0 + }; + const offsets = createCoords(0); + function setLeftRTLScrollbarOffset() { + offsets.x = getWindowScrollBarX(documentElement); + } + if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { + if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { + scroll = getNodeScroll(offsetParent); + } + if (isOffsetParentAnElement) { + const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); + offsets.x = offsetRect.x + offsetParent.clientLeft; + offsets.y = offsetRect.y + offsetParent.clientTop; + } else if (documentElement) { + setLeftRTLScrollbarOffset(); + } + } + if (isFixed && !isOffsetParentAnElement && documentElement) { + setLeftRTLScrollbarOffset(); + } + const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); + const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; + const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; + return { + x, + y, + width: rect.width, + height: rect.height + }; +} +function isStaticPositioned(element) { + return getComputedStyle3(element).position === "static"; +} +function getTrueOffsetParent(element, polyfill) { + if (!isHTMLElement2(element) || getComputedStyle3(element).position === "fixed") { + return null; + } + if (polyfill) { + return polyfill(element); + } + let rawOffsetParent = element.offsetParent; + if (getDocumentElement(element) === rawOffsetParent) { + rawOffsetParent = rawOffsetParent.ownerDocument.body; + } + return rawOffsetParent; +} +function getOffsetParent(element, polyfill) { + const win = getWindow2(element); + if (isTopLayer(element)) { + return win; + } + if (!isHTMLElement2(element)) { + let svgOffsetParent = getParentNode(element); + while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { + if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { + return svgOffsetParent; + } + svgOffsetParent = getParentNode(svgOffsetParent); + } + return win; + } + let offsetParent = getTrueOffsetParent(element, polyfill); + while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { + offsetParent = getTrueOffsetParent(offsetParent, polyfill); + } + if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { + return win; + } + return offsetParent || getContainingBlock(element) || win; +} +var getElementRects = async function(data) { + const getOffsetParentFn = this.getOffsetParent || getOffsetParent; + const getDimensionsFn = this.getDimensions; + const floatingDimensions = await getDimensionsFn(data.floating); + return { + reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), + floating: { + x: 0, + y: 0, + width: floatingDimensions.width, + height: floatingDimensions.height + } + }; +}; +function isRTL(element) { + return getComputedStyle3(element).direction === "rtl"; +} +var platform = { + convertOffsetParentRelativeRectToViewportRelativeRect, + getDocumentElement, + getClippingRect, + getOffsetParent, + getElementRects, + getClientRects, + getDimensions, + getScale, + isElement, + isRTL +}; +function rectsAreEqual(a, b) { + return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height; +} +function observeMove(element, onMove) { + let io = null; + let timeoutId; + const root = getDocumentElement(element); + function cleanup() { + var _io; + clearTimeout(timeoutId); + (_io = io) == null || _io.disconnect(); + io = null; + } + function refresh(skip, threshold) { + if (skip === void 0) { + skip = false; + } + if (threshold === void 0) { + threshold = 1; + } + cleanup(); + const elementRectForRootMargin = element.getBoundingClientRect(); + const { + left, + top, + width, + height + } = elementRectForRootMargin; + if (!skip) { + onMove(); + } + if (!width || !height) { + return; + } + const insetTop = floor(top); + const insetRight = floor(root.clientWidth - (left + width)); + const insetBottom = floor(root.clientHeight - (top + height)); + const insetLeft = floor(left); + const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; + const options = { + rootMargin, + threshold: max(0, min(1, threshold)) || 1 + }; + let isFirstUpdate = true; + function handleObserve(entries) { + const ratio = entries[0].intersectionRatio; + if (ratio !== threshold) { + if (!isFirstUpdate) { + return refresh(); + } + if (!ratio) { + timeoutId = setTimeout(() => { + refresh(false, 1e-7); + }, 1e3); + } else { + refresh(false, ratio); + } + } + if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) { + refresh(); + } + isFirstUpdate = false; + } + try { + io = new IntersectionObserver(handleObserve, { + ...options, + // Handle