@zeyos/zx 5.7.1 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +296 -0
- package/README.md +47 -9
- package/dist/types/components/activity-item/activity-item.d.ts +14 -3
- package/dist/types/components/agent-avatar/agent-avatar.d.ts +165 -0
- package/dist/types/components/agent-avatar/agent-face.d.ts +93 -0
- package/dist/types/components/agent-thread/ag-ui.d.ts +21 -9
- package/dist/types/components/agent-thread/agent-thread.d.ts +26 -0
- package/dist/types/components/agent-thread/ui-message-stream.d.ts +3 -1
- package/dist/types/components/approval-card/approval-card.d.ts +31 -2
- package/dist/types/components/aurora/aurora.d.ts +31 -5
- package/dist/types/components/calendar/calendar.d.ts +39 -26
- package/dist/types/components/chart/chart.d.ts +250 -20
- package/dist/types/components/chart/color.d.ts +66 -0
- package/dist/types/components/chart/svg-adapter.d.ts +103 -0
- package/dist/types/components/chart/svg-geometry.d.ts +203 -0
- package/dist/types/components/check-button/check-button.d.ts +1 -4
- package/dist/types/components/checklist/checklist.d.ts +19 -5
- package/dist/types/components/code-editor/code-editor.d.ts +55 -1
- package/dist/types/components/composer/composer.d.ts +41 -6
- package/dist/types/components/context-menu/context-menu.d.ts +36 -8
- package/dist/types/components/copy/copy-button.d.ts +6 -0
- package/dist/types/components/copy/copy-input.d.ts +1 -0
- package/dist/types/components/date-picker/date-picker.d.ts +14 -0
- package/dist/types/components/date-picker/time-picker.d.ts +26 -17
- package/dist/types/components/datebox/datebox.d.ts +8 -4
- package/dist/types/components/dialog/dialog.d.ts +13 -2
- package/dist/types/components/empty-state/empty-state.d.ts +10 -1
- package/dist/types/components/field/field.d.ts +4 -2
- package/dist/types/components/form/form.d.ts +2 -1
- package/dist/types/components/kanban-view/kanban-card.d.ts +7 -0
- package/dist/types/components/kanban-view/kanban-view.d.ts +15 -3
- package/dist/types/components/launcher/launcher.d.ts +26 -0
- package/dist/types/components/master-panel/master-panel.d.ts +9 -4
- package/dist/types/components/menu-button/menu-button.d.ts +29 -5
- package/dist/types/components/message/message.d.ts +308 -5
- package/dist/types/components/modal/modal.d.ts +11 -0
- package/dist/types/components/modal/native-dialog.d.ts +40 -0
- package/dist/types/components/module-bar/module-bar.d.ts +9 -2
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +5 -4
- package/dist/types/components/number-field/number-field.d.ts +7 -0
- package/dist/types/components/pagination/pagination.d.ts +341 -19
- package/dist/types/components/run-status/run-status.d.ts +26 -0
- package/dist/types/components/run-trace/run-trace.d.ts +10 -6
- package/dist/types/components/search/search.d.ts +16 -4
- package/dist/types/components/select/select.d.ts +19 -1
- package/dist/types/components/sheet/sheet.d.ts +18 -4
- package/dist/types/components/slider/slider.d.ts +2 -1
- package/dist/types/components/stat-tile/stat-tile.d.ts +20 -3
- package/dist/types/components/stepper/stepper.d.ts +17 -4
- package/dist/types/components/surface/catalog.d.ts +61 -17
- package/dist/types/components/surface/surface.d.ts +6 -4
- package/dist/types/components/table/table.d.ts +207 -5
- package/dist/types/components/table/window.d.ts +25 -1
- package/dist/types/components/toggle/toggle.d.ts +38 -6
- package/dist/types/components/tooltip/tooltip.d.ts +5 -4
- package/dist/types/components/tree/tree.d.ts +43 -6
- package/dist/types/components/truncate/truncate.d.ts +4 -2
- package/dist/types/components/value-list/value-list.d.ts +9 -2
- package/dist/types/core/date.d.ts +2 -1
- package/dist/types/core/drag-axis.d.ts +10 -5
- package/dist/types/core/export.d.ts +2 -2
- package/dist/types/core/format.d.ts +3 -1
- package/dist/types/core/icons.d.ts +36 -3
- package/dist/types/core/keyboard.d.ts +7 -3
- package/dist/types/core/messages.d.ts +3 -0
- package/dist/types/core/storage.d.ts +4 -3
- package/dist/types/core/util.d.ts +3 -1
- package/dist/types/elements/define.d.ts +5 -2
- package/dist/types/index.d.ts +6 -4
- package/dist/types/internal/agent-model.d.ts +99 -0
- package/dist/types/internal/app-rail.d.ts +37 -2
- package/dist/types/internal/collections.d.ts +18 -0
- package/dist/types/internal/menu-items.d.ts +27 -0
- package/dist/types/internal/overlay-content.d.ts +23 -0
- package/dist/types/internal/presence-loop.d.ts +5 -2
- package/dist/types/locales/index.d.ts +3 -0
- package/dist/types/zeyos/calendar.d.ts +43 -7
- package/dist/types/zeyos/connect.d.ts +4 -0
- package/dist/types/zeyos/form.d.ts +13 -5
- package/dist/types/zeyos/select.d.ts +5 -2
- package/dist/types/zeyos/table.d.ts +16 -8
- package/dist/types/zeyos/view.d.ts +2 -1
- package/dist/zx-zeyos.esm.js +2998 -451
- package/dist/zx-zeyos.esm.min.js +4 -4
- package/dist/zx.core.css +4 -0
- package/dist/zx.core.min.css +1 -1
- package/dist/zx.css +948 -48
- package/dist/zx.esm.js +7432 -3408
- package/dist/zx.esm.min.js +26 -26
- package/dist/zx.global.js +7432 -3408
- package/dist/zx.global.min.js +26 -26
- package/dist/zx.layered.css +950 -48
- package/dist/zx.layered.min.css +1 -1
- package/dist/zx.min.css +1 -1
- package/docs/agent-catalog.json +159 -1
- package/docs/agent-surfaces.md +21 -21
- package/docs/api.json +3122 -528
- package/docs/components/account-menu.md +24 -0
- package/docs/components/activity-item.md +23 -0
- package/docs/components/activity-list.md +28 -0
- package/docs/components/agent-avatar.md +59 -0
- package/docs/components/agent-thread.md +275 -0
- package/docs/components/app-icon.md +36 -0
- package/docs/components/app-sidebar.md +92 -0
- package/docs/components/approval-card.md +71 -0
- package/docs/components/aurora.md +34 -0
- package/docs/components/avatar.md +37 -0
- package/docs/components/badge.md +36 -0
- package/docs/components/block-view.md +34 -0
- package/docs/components/breadcrumb.md +20 -0
- package/docs/components/button.md +23 -0
- package/docs/components/calendar.md +68 -0
- package/docs/components/card-view.md +73 -0
- package/docs/components/card.md +25 -0
- package/docs/components/chart.md +109 -0
- package/docs/components/check-button.md +16 -0
- package/docs/components/checklist.md +19 -0
- package/docs/components/code-editor.md +38 -0
- package/docs/components/composer.md +107 -0
- package/docs/components/context-menu.md +32 -0
- package/docs/components/copy.md +37 -0
- package/docs/components/data-filter.md +16 -0
- package/docs/components/date-picker.md +31 -0
- package/docs/components/date-range.md +21 -0
- package/docs/components/datebox.md +31 -0
- package/docs/components/dialog.md +25 -0
- package/docs/components/dock.md +57 -0
- package/docs/components/dropdown.md +39 -0
- package/docs/components/elements.md +63 -0
- package/docs/components/empty-state.md +17 -0
- package/docs/components/entity-ref.md +26 -0
- package/docs/components/field-upload.md +18 -0
- package/docs/components/file-item.md +27 -0
- package/docs/components/file-list.md +23 -0
- package/docs/components/filter-panel.md +45 -0
- package/docs/components/filter.md +47 -0
- package/docs/components/finder.md +25 -0
- package/docs/components/form-widgets.md +42 -0
- package/docs/components/form.md +80 -0
- package/docs/components/grid.md +26 -0
- package/docs/components/groupbox.md +11 -0
- package/docs/components/helpers.md +359 -0
- package/docs/components/icons.md +87 -0
- package/docs/components/index.md +99 -0
- package/docs/components/kanban-view.md +42 -0
- package/docs/components/kbd.md +23 -0
- package/docs/components/kernel.md +41 -0
- package/docs/components/launcher.md +66 -0
- package/docs/components/layout.md +33 -0
- package/docs/components/list-toolbar.md +38 -0
- package/docs/components/loading.md +48 -0
- package/docs/components/menu-button.md +47 -0
- package/docs/components/message.md +76 -0
- package/docs/components/modal.md +27 -0
- package/docs/components/module-bar.md +71 -0
- package/docs/components/multi-value-editor.md +16 -0
- package/docs/components/navigation-bar.md +22 -0
- package/docs/components/number-field.md +34 -0
- package/docs/components/pagination.md +73 -0
- package/docs/components/panel.md +28 -0
- package/docs/components/prompt-starters.md +40 -0
- package/docs/components/prose.md +38 -0
- package/docs/components/questionnaire.md +115 -0
- package/docs/components/rating.md +19 -0
- package/docs/components/run-status.md +50 -0
- package/docs/components/run-trace.md +72 -0
- package/docs/components/search.md +11 -0
- package/docs/components/select.md +129 -0
- package/docs/components/sheet-stack.md +39 -0
- package/docs/components/sheet.md +77 -0
- package/docs/components/skeleton.md +27 -0
- package/docs/components/slider.md +29 -0
- package/docs/components/sort-control.md +21 -0
- package/docs/components/source-list.md +30 -0
- package/docs/components/split-view.md +12 -0
- package/docs/components/stat-tile.md +49 -0
- package/docs/components/stepper.md +27 -0
- package/docs/components/surface.md +152 -0
- package/docs/components/tabbox.md +33 -0
- package/docs/components/table-view.md +43 -0
- package/docs/components/table.md +232 -0
- package/docs/components/tag-picker.md +39 -0
- package/docs/components/timebox.md +16 -0
- package/docs/components/toggle.md +21 -0
- package/docs/components/tokens.md +82 -0
- package/docs/components/toolbar.md +26 -0
- package/docs/components/tooltip.md +16 -0
- package/docs/components/tree.md +48 -0
- package/docs/components/truncate.md +21 -0
- package/docs/components/value-list.md +14 -0
- package/docs/components/view-settings.md +56 -0
- package/docs/components/workspace-switcher.md +42 -0
- package/docs/components/zeyos.md +196 -0
- package/docs/llms-small.txt +299 -0
- package/docs/llms.md +697 -100
- package/docs/llms.txt +46 -19
- package/package.json +9 -4
- package/src/components/activity-item/activity-item.js +21 -2
- package/src/components/agent-avatar/agent-avatar.css +195 -0
- package/src/components/agent-avatar/agent-avatar.js +333 -0
- package/src/components/agent-avatar/agent-face.js +292 -0
- package/src/components/agent-thread/ag-ui.js +44 -11
- package/src/components/agent-thread/agent-thread.js +103 -11
- package/src/components/agent-thread/ui-message-stream.js +3 -1
- package/src/components/app-rail/app-rail.css +5 -0
- package/src/components/app-sidebar/app-sidebar.css +3 -0
- package/src/components/app-sidebar/app-sidebar.js +4 -3
- package/src/components/approval-card/approval-card.css +6 -0
- package/src/components/approval-card/approval-card.js +55 -7
- package/src/components/aurora/aurora.css +149 -14
- package/src/components/aurora/aurora.js +49 -6
- package/src/components/calendar/calendar.css +6 -2
- package/src/components/calendar/calendar.js +127 -47
- package/src/components/card-view/card-view.js +5 -6
- package/src/components/chart/chart.css +159 -1
- package/src/components/chart/chart.js +450 -62
- package/src/components/chart/color.js +297 -0
- package/src/components/chart/svg-adapter.js +576 -0
- package/src/components/chart/svg-geometry.js +323 -0
- package/src/components/check-button/check-button.js +3 -18
- package/src/components/checklist/checklist.js +46 -17
- package/src/components/checklist/field-adapter.js +4 -1
- package/src/components/code-editor/code-editor.css +33 -0
- package/src/components/code-editor/code-editor.js +97 -8
- package/src/components/code-editor/field-adapter.js +3 -0
- package/src/components/composer/composer.css +3 -0
- package/src/components/composer/composer.js +100 -22
- package/src/components/context-menu/context-menu.js +41 -5
- package/src/components/copy/copy-button.js +9 -1
- package/src/components/copy/copy-input.js +5 -0
- package/src/components/data-filter/filter-core.js +0 -1
- package/src/components/date-picker/date-picker.css +8 -0
- package/src/components/date-picker/date-picker.js +47 -8
- package/src/components/date-picker/date-range-picker.js +1 -1
- package/src/components/date-picker/month-picker.js +19 -3
- package/src/components/date-picker/time-picker.js +54 -19
- package/src/components/datebox/date-range-box.js +7 -3
- package/src/components/datebox/datebox.js +32 -6
- package/src/components/dialog/dialog.css +6 -0
- package/src/components/dialog/dialog.js +22 -30
- package/src/components/dropdown/dropdown.js +1 -18
- package/src/components/empty-state/empty-state.js +21 -2
- package/src/components/field/field.js +19 -3
- package/src/components/fieldset/fieldset.js +3 -1
- package/src/components/filter/filter.js +9 -0
- package/src/components/form/form.js +19 -2
- package/src/components/kanban-view/kanban-card.js +15 -2
- package/src/components/kanban-view/kanban-view.css +21 -0
- package/src/components/kanban-view/kanban-view.js +29 -16
- package/src/components/launcher/launcher.css +14 -0
- package/src/components/launcher/launcher.js +54 -9
- package/src/components/master-panel/master-panel.js +24 -22
- package/src/components/menu-button/menu-button.js +26 -4
- package/src/components/message/message.css +228 -29
- package/src/components/message/message.js +664 -30
- package/src/components/modal/modal.js +70 -25
- package/src/components/modal/native-dialog.js +91 -0
- package/src/components/module-bar/module-bar.css +3 -0
- package/src/components/module-bar/module-bar.js +17 -4
- package/src/components/multi-value-editor/multi-value-editor.css +7 -2
- package/src/components/multi-value-editor/multi-value-editor.js +3 -2
- package/src/components/navigation-bar/navigation-bar.js +13 -1
- package/src/components/number-field/field-adapter.js +3 -0
- package/src/components/number-field/number-field.js +2 -1
- package/src/components/pagination/pagination.css +26 -2
- package/src/components/pagination/pagination.js +551 -65
- package/src/components/prose/prose.js +7 -1
- package/src/components/rating/field-adapter.js +3 -0
- package/src/components/run-status/run-status.js +43 -3
- package/src/components/run-trace/run-trace.js +15 -7
- package/src/components/search/search.js +3 -18
- package/src/components/select/field-adapter.js +8 -1
- package/src/components/select/select.js +68 -13
- package/src/components/sheet/sheet.js +27 -8
- package/src/components/slider/field-adapter.js +3 -0
- package/src/components/slider/slider.js +4 -6
- package/src/components/stat-tile/stat-tile.js +24 -9
- package/src/components/stepper/stepper.css +15 -0
- package/src/components/stepper/stepper.js +34 -2
- package/src/components/surface/catalog.js +185 -28
- package/src/components/surface/surface.js +10 -5
- package/src/components/tabbox/tabbox.js +13 -1
- package/src/components/table/table.css +160 -2
- package/src/components/table/table.js +479 -52
- package/src/components/table/window.js +46 -4
- package/src/components/table-view/table-view.js +1 -10
- package/src/components/tag-picker/field-adapter.js +3 -0
- package/src/components/tag-picker/tag-picker.js +2 -0
- package/src/components/timebox/field-adapter.js +3 -0
- package/src/components/toggle/toggle.js +51 -27
- package/src/components/tooltip/tooltip.js +21 -14
- package/src/components/tree/tree.js +87 -14
- package/src/components/truncate/truncate.js +21 -5
- package/src/components/value-list/value-list.js +37 -9
- package/src/components/view-settings/view-settings.js +1 -5
- package/src/core/component.js +34 -2
- package/src/core/date.js +5 -4
- package/src/core/drag-axis.js +24 -7
- package/src/core/export.js +4 -4
- package/src/core/fontawesome.js +34 -3
- package/src/core/format.js +3 -1
- package/src/core/http.js +23 -11
- package/src/core/icons.js +51 -10
- package/src/core/keyboard.js +83 -9
- package/src/core/messages.js +3 -0
- package/src/core/position.js +2 -2
- package/src/core/storage.js +80 -31
- package/src/core/util.js +16 -5
- package/src/elements/define.js +82 -47
- package/src/elements/kit.js +46 -35
- package/src/index.js +8 -4
- package/src/internal/agent-model.js +152 -0
- package/src/internal/app-rail.js +53 -2
- package/src/internal/collections.js +25 -0
- package/src/internal/menu-items.js +59 -0
- package/src/internal/overlay-content.js +35 -0
- package/src/internal/presence-loop.js +61 -14
- package/src/locales/de.js +3 -0
- package/src/zeyos/calendar.js +81 -19
- package/src/zeyos/connect.js +5 -1
- package/src/zeyos/form.js +29 -10
- package/src/zeyos/select.js +36 -12
- package/src/zeyos/table.js +43 -11
- package/src/zeyos/view.js +2 -1
- package/styles/tokens/semantic.css +7 -1
- package/styles/zx.css +1 -0
package/dist/zx-zeyos.esm.min.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var Ut=Object.freeze({"accountMenu.fallback":"Account","accountMenu.label":"Account menu","accountMenu.labelFor":"Account menu for %1","activityItem.actions":"Actions for %1","activityItem.attachments":"Attachments","activityItem.failed":"Failed","activityItem.label":"Activity","activityItem.metadata":"Activity metadata","activityItem.pending":"Sending\u2026","activityItem.untitled":"activity","activityList.empty":"No activity yet","activityList.label":"Activity","activityList.loading":"Loading activity","activityList.other":"Other","agent.activity.blocked":"Blocked","agent.activity.idle":"Idle","agent.activity.needsYou":"Needs you","agent.activity.offline":"Offline","agent.activity.thinking":"Thinking","agent.activity.working":"Working","agent.status.done":"Done","agent.status.failed":"Failed","agent.status.paused":"Paused","agent.status.queued":"Not started","agent.status.running":"Running","agent.status.skipped":"Skipped","agent.status.stopped":"Stopped","agent.status.waiting":"Waiting for you","agent.status.blocked":"Blocked","agentThread.agent":"Agent","agentThread.answered":"%1 answered","agentThread.attachments":"Attachments","agentThread.branch":"Branch into a new conversation","agentThread.copy":"Copy answer","agentThread.label":"Conversation","agentThread.latest":"Jump to latest","agentThread.needsApproval":"%1 needs your approval","agentThread.nextVersion":"Next version","agentThread.previousVersion":"Previous version","agentThread.rateDown":"Not helpful","agentThread.rateUp":"Helpful","agentThread.regenerate":"Regenerate answer","agentThread.sources":"Sources","agentThread.stopped":"Stopped","agentThread.stoppedAnnounce":"Stopped","agentThread.version":"Version %1 of %2","agentThread.via":"via %1","agentThread.working":"%1 is working","agentThread.writing":"%1 is writing an answer","agentThread.you":"You","agentThread.writingNow":"%1 is writing\u2026","agentThread.edit":"Edit message","agentThread.copyMessage":"Copy message","agUi.approve":"Run %1?","agUi.asked":"Asked for your answer","agUi.called":"Called %1","agUi.calling":"Calling %1","agUi.runFailed":"The run failed","agUi.runFailedWith":"The run failed: %1","agUi.showTile":"Show in conversation","agUi.thinking":"Thinking","agUi.thought":"Thought for %1","agUi.thoughtComplete":"Thought complete","appRail.subNavigation":"%1 sub-navigation","appSidebar.expand":"Expand application sidebar","appSidebar.itemBadge":"%1 (%2)","appSidebar.label":"Applications","appSidebar.minimize":"Minimize application sidebar","appSidebar.more":"More actions","appSidebar.presentation":"Navigation layout","appSidebar.presentationCollapsed":"Both menus collapsed","appSidebar.presentationCompact":"Module menu collapsed","appSidebar.presentationExpanded":"Both menus expanded","approvalCard.approve":"Approve","approvalCard.approvedBy":"Approved by %1 at %2","approvalCard.approvedByUndated":"Approved by %1","approvalCard.cancel":"Cancel","approvalCard.dateTimeFormat":"%e %b, %H:%M","approvalCard.edit":"Edit","approvalCard.editTitle":"Edit the request","approvalCard.editedBy":"Edited by %1","approvalCard.expiredAt":"Expired at %1","approvalCard.expiredUndated":"Expired without an answer","approvalCard.fullDateTimeFormat":"%e %b %Y, %H:%M","approvalCard.paused":"The run is paused until you answer.","approvalCard.preview":"Preview","approvalCard.reason":"Reason","approvalCard.reasonLabel":"Why not?","approvalCard.reasonMissing":"Say why, so the agent can do better next time.","approvalCard.reasonOptional":"Optional. Your reason stays with the request.","approvalCard.reasonRequired":"Your reason stays with the request.","approvalCard.reject":"Reject","approvalCard.rejectTitle":"Reject the request?","approvalCard.rejectedBy":"Rejected by %1 at %2","approvalCard.rejectedByUndated":"Rejected by %1","approvalCard.required":"Fill this in to save.","approvalCard.save":"Save changes","approvalCard.status.approved":"Approved","approvalCard.status.expired":"Expired","approvalCard.status.pending":"Waiting for you","approvalCard.status.rejected":"Rejected","approvalCard.you":"you","blockView.cite":"Source %1","blockView.citeTitled":"Source %1: %2","blockView.code":"Code","blockView.copyCode":"Copy code","blockView.document":"Document","blockView.stopped":"Stopped here.","blockView.table":"Table","blockView.version":"1 version","blockView.versions":"%1 versions","breadcrumb.label":"Breadcrumb","breadcrumb.more":"Show hidden levels","calendar.agenda":"Agenda","calendar.allDay":"All day","calendar.day":"Day","calendar.dayEvent":"%1, %2 event","calendar.dayEvents":"%1, %2 events","calendar.editCancelled":"Calendar edit cancelled.","calendar.editCommitted":"%1 updated.","calendar.editPreview":"%1, %2 to %3","calendar.eventLabel":"%1, %2 to %3","calendar.label":"Calendar","calendar.loading":"Loading calendar\u2026","calendar.month":"Month","calendar.more":"+%1 more","calendar.moveStarted":"Moving %1. Use arrow keys, Space to drop, or Escape to cancel.","calendar.new":"New","calendar.next":"Next period","calendar.noEvents":"No events","calendar.previous":"Previous period","calendar.resize":"Resize %1","calendar.resizeStarted":"Resizing %1. Use arrow keys, Space to drop, or Escape to cancel.","calendar.today":"Today","calendar.untitled":"Untitled event","calendar.viewSwitch":"Calendar view","calendar.week":"Week","calendar.weekNumber":"Week %1","calendar.year":"Year","card.actions":"Card actions","cardView.groupEmpty":"No records in this group.","cardView.label":"Card view","cardView.sort":"Sort","cardView.sortAscending":"%1 (ascending)","cardView.sortCards":"Sort cards","cardView.sortDescending":"%1 (descending)","cardView.ungrouped":"Ungrouped","cardView.unsorted":"Unsorted","chart.empty":"No chart data","chart.error":"Unable to render chart","chart.label":"Chart","chart.loading":"Loading chart\u2026","chart.series":"Series %1","chart.summary":"Chart data","chart.summaryLabel":"Label","checklist.empty":"No matches","checklist.label":"Checklist","checklist.search":"Search","codeEditor.label":"Code editor","codeEditor.position":"Ln %1, Col %2","codeEditor.selection":"Ln %1, Col %2 \xB7 %3 lines selected","codeEditor.selection.one":"Ln %1, Col %2 \xB7 %3 line selected","codeEditor.selection.other":"Ln %1, Col %2 \xB7 %3 lines selected","composer.attach":"Attach files","composer.attachments":"Attachments","composer.commands":"Commands","composer.commandsPlaceholder":"Search commands","composer.context":"Context","composer.drop":"Drop files to attach","composer.label":"Message","composer.match":"1 suggestion","composer.matches":"%1 suggestions","composer.queue":"Queued (%1)","composer.queued":"Queued; sends when the agent finishes","composer.queueEdit":"Edit","composer.queueFile":"1 file","composer.queueFiles":"%1 files","composer.queueFull":"Queue full (limit %1)","composer.queueRemove":"Remove","composer.queueReplaceConfirm":"Replace","composer.queueReplaceMessage":"The queued message takes its place in the message box.","composer.queueReplaceTitle":"Replace what you have written?","composer.remove":"Remove %1","composer.send":"Send","composer.stop":"Stop","composer.suggestions":"Suggestions","copy.copied":"Copied","copy.copy":"Copy","countryPicker.label":"Country","countryPicker.placeholder":"Choose a country","dataFilter.all":"All","dataFilter.clear":"Clear","datebox.choose":"Choose date","datebox.clear":"Clear date","datebox.placeholder.day":"DD","datebox.placeholder.dayShort":"D","datebox.placeholder.hour":"HH","datebox.placeholder.minute":"MM","datebox.placeholder.month":"MM","datebox.placeholder.second":"SS","datebox.placeholder.year":"YYYY","datebox.placeholder.yearShort":"YY","datebox.required":"Please enter a date.","datePicker.calendar":"Calendar","datePicker.chooseMonthYear":"Choose month and year, %1","datePicker.dayLabel":"%e %B %Y","datePicker.nextMonth":"Next month","datePicker.nextYear":"Next year","datePicker.previousMonth":"Previous month","datePicker.previousYear":"Previous year","datePicker.week":"Week %1","datePicker.weekNumber":"Week number","daterange.choose":"Choose date range","daterange.clear":"Clear date range","daterange.day.end":"range end","daterange.day.middle":"in selected range","daterange.day.start":"range start","daterange.dayLabel":"%A, %e %B %Y","daterange.label":"Date range","daterange.nextMonth":"Next month","daterange.night":"1 night","daterange.nights":"%1 nights","daterange.preset.last30":"Last 30 days","daterange.preset.last7":"Last 7 days","daterange.preset.lastMonth":"Last month","daterange.preset.thisMonth":"This month","daterange.preset.thisQuarter":"This quarter","daterange.preset.thisYear":"This year","daterange.preset.today":"Today","daterange.preset.yesterday":"Yesterday","daterange.presets":"Date range presets","daterange.previousMonth":"Previous month","daterange.span.day":"%e","daterange.span.full":"%e %B %Y","daterange.span.month":"%e %B","daterange.status.empty":"No date range selected","daterange.status.start":"%1 selected, choose an end date","daterange.week":"Week %1","daterange.weekNumber":"Week number","dialog.cancel":"Cancel","dialog.close":"Close","dialog.ok":"OK","dialog.promptValue":"Prompt value","dialog.typeToConfirm":"Type %1 to confirm","dock.resize":"Resize panes","entityRef.actions":"Entity actions","field.float":"Enter a valid number.","field.int":"Enter a whole number.","field.unknown":"Unknown field type: %1","fieldUpload.abort":"Abort","fieldUpload.aborted":"Upload aborted.","fieldUpload.choose":"Choose a file or drop it here","fieldUpload.chooseMany":"Choose files or drop them here","fieldUpload.complete":"Upload complete.","fieldUpload.drop":"Drop a file here or choose a file","fieldUpload.dropMany":"Drop files here or choose files","fieldUpload.hint":"Choose from this device","fieldUpload.httpFailed":"Upload failed with HTTP %1","fieldUpload.maxSize":"up to %1","fieldUpload.preview":"Preview of %1","fieldUpload.progress":"Upload progress","fieldUpload.rejectedSize":"%1 exceeds the maximum file size.","fieldUpload.rejectedType":"%1 is not an accepted file type.","fieldUpload.requestFailed":"Upload request failed","fieldUpload.uploading":"Uploading\u2026","fileItem.actions":"File actions","fileItem.file":"File","fileItem.kind.audio":"Audio","fileItem.kind.calendar":"Calendar","fileItem.kind.contact":"Contact","fileItem.kind.document":"Document","fileItem.kind.email":"Email","fileItem.kind.font":"Font","fileItem.kind.image":"Image","fileItem.kind.presentation":"Presentation","fileItem.kind.spreadsheet":"Spreadsheet","fileItem.kind.text":"Text","fileItem.kind.video":"Video","fileItem.progress":"Progress","fileItem.size":"Size","fileItem.status.error":"Failed","fileItem.status.processing":"Processing","fileItem.status.success":"Complete","fileItem.status.temporary":"Temporary","fileItem.status.uploading":"Uploading","fileItem.status.waiting":"Waiting","fileItem.type":"Type","fileList.empty":"No files","fileList.label":"Files","fileList.loading":"Loading files","filter.addFilter":"Add filter","filter.addGroup":"Add group","filter.addSubgroup":"Add subgroup","filter.and":"and","filter.apply":"Apply filters","filter.booleanFalse":"False","filter.booleanTrue":"True","filter.choose":"Choose\u2026","filter.chooseField":"Choose a field\u2026","filter.chooseOperator":"Choose an operator\u2026","filter.choosePart.field":"Choose field\u2026","filter.choosePart.operator":"Choose operator\u2026","filter.choosePart.value":"Choose value\u2026","filter.clear":"Clear","filter.commaSeparated":"Comma-separated values","filter.conditionNoun":"Filter","filter.conditions":"conditions","filter.emptyGroup":"Nested groups need at least one condition","filter.field":"Filter field","filter.fieldRequired":"Choose a field","filter.fieldUnavailable":"Unavailable field: %1","filter.fieldValue":"%1 value","filter.fieldValueAt":"%1 value %2","filter.filterNoun":"filter","filter.groupLogic":"Group filter logic","filter.groupNoun":"Filter group","filter.inThisGroup":"in this group","filter.matchAll":"Match all","filter.matchAllConditions":"Match all conditions","filter.matchAny":"Match any","filter.matchAnyConditions":"Match any conditions","filter.noValue":"No value","filter.op.after":"is after","filter.op.anyOf":"is any of","filter.op.before":"is before","filter.op.between":"is between","filter.op.contains":"contains","filter.op.containsAll":"contains all","filter.op.containsAny":"contains any","filter.op.containsNone":"contains none","filter.op.endsWith":"ends with","filter.op.eq":"is","filter.op.gt":"is greater than","filter.op.gte":"is at least","filter.op.isEmpty":"is empty","filter.op.isNotEmpty":"is not empty","filter.op.lt":"is less than","filter.op.lte":"is at most","filter.op.neq":"is not","filter.op.noneOf":"is none of","filter.op.notBetween":"is not between","filter.op.notContains":"does not contain","filter.op.notOn":"is not on","filter.op.on":"is on","filter.op.onOrAfter":"is on or after","filter.op.onOrBefore":"is on or before","filter.op.startsWith":"starts with","filter.op.withinLast":"is within the last","filter.op.withinNext":"is within the next","filter.operator":"Filter operator","filter.operatorRequired":"Choose an operator","filter.operatorType":"%1 is not available for %2","filter.operatorUnavailable":"Unavailable operator: %1","filter.or":"or","filter.relativeAmount":"%1: number of units","filter.relativeInvalid":"Enter a whole number of days, weeks or months","filter.relativeUnit":"%1: unit","filter.remove":"Remove %1","filter.removed":"%1 removed","filter.removeGroup":"Remove group","filter.requiresAll":"This filter requires match all conditions.","filter.requiresAny":"This filter requires match any conditions.","filter.rootLogic":"Root filter logic","filter.switchToAll":"%1 \u2014 switch to all","filter.switchToAny":"%1 \u2014 switch to any","filter.unavailable":"Unavailable: %1","filter.unit.days":"days","filter.unit.months":"months","filter.unit.weeks":"weeks","filter.valueMany":"Choose at least one value","filter.valueNone":"This operator does not accept a value","filter.valueOne":"Enter a value","filter.valuePair":"Enter both values","filterPanel.apply":"Apply","filterPanel.clear":"Clear all","filterPanel.empty":"No filters are available here.","filterPanel.from":"From","filterPanel.label":"Filters","filterPanel.rangeFrom":"%1 from","filterPanel.rangeTo":"%1 to","filterPanel.to":"To","filterPanel.unsupported":"Unsupported filter type: %1","finder.loading":"Loading\u2026","finder.noItems":"Empty","finder.root":"Root","form.action":"Action","form.float":"Enter a valid number.","form.int":"Enter a whole number.","form.required":"This field is required.","grid.currency":"Currency","grid.item":"Item","grid.lineTotal":"Line total","grid.quantity":"Quantity","grid.unit":"Unit","grid.unitPrice":"Unit price","kanbanView.add":"Add card","kanbanView.addTo":"Add card to %target%","kanbanView.assigneeOverflow":"+%count%","kanbanView.assignees":"Assigned to %names%","kanbanView.collapseColumn":"Collapse column %label%","kanbanView.collapseLane":"Collapse swim lane %label%","kanbanView.columnEmpty":"Drop a card here","kanbanView.count":"%count% records","kanbanView.count.one":"%count% record","kanbanView.count.other":"%count% records","kanbanView.countFiltered":"%count% of %total% records","kanbanView.countFiltered.one":"%count% of %total% record","kanbanView.countFiltered.other":"%count% of %total% records","kanbanView.countLimit":"%count% records, work-in-progress limit %limit%","kanbanView.countLimit.one":"%count% record, work-in-progress limit %limit%","kanbanView.countLimit.other":"%count% records, work-in-progress limit %limit%","kanbanView.countLimitInLane":"%count% records in this lane, %total% of work-in-progress limit %limit% in the column","kanbanView.countLimitInLane.one":"%count% record in this lane, %total% of work-in-progress limit %limit% in the column","kanbanView.countLimitInLane.other":"%count% records in this lane, %total% of work-in-progress limit %limit% in the column","kanbanView.dragPreview":"%count% cards","kanbanView.dragPreview.one":"%count% card","kanbanView.dragPreview.other":"%count% cards","kanbanView.empty":"No records","kanbanView.expandColumn":"Expand column %label%","kanbanView.expandLane":"Expand swim lane %label%","kanbanView.fields":"Fields","kanbanView.grabbed":"Grabbed %name%. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.","kanbanView.grabbedMultiple":"Grabbed %count% cards. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.","kanbanView.identifier":"Record","kanbanView.label":"Kanban board","kanbanView.limitExceeded":" Work-in-progress limit %limit% exceeded.","kanbanView.limitReached":" Work-in-progress limit %limit% reached.","kanbanView.menuMoveTo":"Move to %target%","kanbanView.menuMoveToLane":"Move to lane %target%","kanbanView.move":"Move %name%","kanbanView.moveCanceled":"Move canceled for %name%.","kanbanView.moveCanceledPlain":"Move canceled.","kanbanView.moved":"Moved %name% to %target%.%wip%","kanbanView.movedMultiple":"Moved %count% cards to %target%.%wip%","kanbanView.moveMultiple":"Move %count% selected cards","kanbanView.moveRequested":"Move requested for %name% to %target%.%wip%","kanbanView.noMatches":"No cards match the current search.","kanbanView.nothingToRedo":"Nothing to redo.","kanbanView.nothingToUndo":"Nothing to undo.","kanbanView.notSelected":"Not selected","kanbanView.priorityLabel":"Priority","kanbanView.progress":"Progress","kanbanView.progressValue":"%percent%%","kanbanView.record":"record","kanbanView.redo":"Redo","kanbanView.redone":"Move redone.","kanbanView.rejectAccept":"Move rejected: %target% does not accept %name%.","kanbanView.rejectDestination":"Move rejected: the destination is not available.","kanbanView.rejectGrouping":"Move rejected: callback grouping requires external move mode.","kanbanView.rejectTransition":"Move rejected: %target% does not accept cards from %origin%.","kanbanView.rejectWip":"Move rejected: %target% is at its work-in-progress limit of %limit%.","kanbanView.search":"Search board","kanbanView.searchPlaceholder":"Search cards","kanbanView.selected":"Selected","kanbanView.statusLabel":"Status","kanbanView.target":"Target %target%, position %position% of %total%.","kanbanView.unassigned":"Unassigned","kanbanView.undo":"Undo","kanbanView.undone":"Move undone.","launcher.back":"Back to %1","launcher.close":"Close launcher","launcher.empty":"No results","launcher.hintBack":"Back","launcher.hintClose":"Close","launcher.hintMove":"Move","launcher.hintOpen":"Open","launcher.label":"Launcher","launcher.loading":"Searching\u2026","launcher.pageEmpty":"%1, no results","launcher.pageLabel":"Search %1","launcher.pagePlaceholder":"Search","launcher.pageResult":"%1, 1 result","launcher.pageResults":"%1, %2 results","launcher.placeholder":"Search applications and records","launcher.results":"Launcher results","listToolbar.label":"List controls","listToolbar.results":"%1 results","listToolbar.results.one":"%1 result","listToolbar.results.other":"%1 results","listToolbar.search":"Search","listToolbar.toolBadge":"%1 (%2)","listToolbar.viewAuto":"Auto","listToolbar.viewBoard":"Board","listToolbar.viewCards":"Cards","listToolbar.viewGallery":"Gallery","listToolbar.viewList":"List","listToolbar.views":"View","listToolbar.viewTable":"Table","localePicker.label":"Language","localePicker.placeholder":"Choose a language","mcp.askedBy":"Asked by %1","mcp.decline":"Decline","mcp.urlAddress":"Full address: %1","mcp.urlHost":"The page is on %1.","mcp.urlInternational":"This address uses an internationalised domain name, which can look like another one. Check the host before you open it.","mcp.urlNote":"It opens in a new tab. Nothing from this application is sent to it.","mcp.urlOpen":"Open page","mcp.urlTitle":"Open a page on another site?","message.close":"Close message","message.closeTitle":"Close","moduleBar.empty":"No modules","moduleBar.filter":"Filter modules","moduleBar.itemBadge":"%1 (%2)","moduleBar.label":"Modules","moduleBar.more":"All modules","monthPicker.chooseMonth":"Choose month","monthPicker.nextYear":"Next year","monthPicker.previousYear":"Previous year","multiValueEditor.add":"Add value","multiValueEditor.moveDown":"Move value %1 down","multiValueEditor.moveUp":"Move value %1 up","multiValueEditor.remove":"Remove value %1","multiValueEditor.reorder":"Reorder value %1. Use the arrow keys to move it.","multiValueEditor.value":"Value %1","navigationBar.actions":"Application actions","navigationBar.more":"More","navigationBar.primary":"Primary navigation","numberField.empty":"Empty","pagination.empty":"0 of 0","pagination.label":"Pagination","pagination.loaded":"%1 of %2","pagination.loadMore":"Load more","pagination.next":"Next page","pagination.page":"Page %1","pagination.pageSize":"Rows per page","pagination.previous":"Previous page","pagination.summary":"%1\u2013%2 of %3","panel.actions":"Panel actions","panel.footerActions":"Panel footer actions","permission.private":"Private","permission.public":"Public","priority.high":"High","priority.highest":"Highest","priority.low":"Low","priority.lowest":"Lowest","priority.none":"No priority","priority.normal":"Medium","promptStarters.label":"Suggestions","prose.copied":"Link copied","prose.copyLink":"Copy link","prose.copyLinkTo":"Copy link to %1","questionnaire.counter":"Question %1 of %2","questionnaire.edit":"Edit","questionnaire.empty":"There is nothing to answer.","questionnaire.next":"Continue","questionnaire.noAnswer":"Skipped","questionnaire.other":"Other","questionnaire.previous":"Back","questionnaire.required":"Choose an answer to continue.","questionnaire.requiredInput":"Enter an answer to continue.","questionnaire.review":"Review answers","questionnaire.reviewTitle":"Check your answers","questionnaire.skip":"Skip","questionnaire.submit":"Submit","rating.count":"%1 ratings","rating.count.one":"%1 rating","rating.count.other":"%1 ratings","rating.label":"Rating","rating.value":"%1 of %2","recordCard.actions":"Actions for %1","recordCard.notSelected":"Not selected","recordCard.select":"Select %1","recordCard.selected":"Selected","recordCard.untitled":"record","recordView.fieldMoved":"%1 moved to position %2 of %3","recordView.fields":"Fields","recordView.moveFieldDown":"Move %1 down","recordView.moveFieldUp":"Move %1 up","runStatus.cost":"%1 of %2","runStatus.costLabel":"Cost","runStatus.dateTimeFormat":"%e %b, %H:%M","runStatus.failedAt":"Failed at","runStatus.finished":"Finished","runStatus.model":"Model","runStatus.started":"Started","runStatus.steps":"%1 of %2 steps","runStatus.steps.one":"%1 of %2 step","runStatus.steps.other":"%1 of %2 steps","runStatus.stepsLabel":"Steps done","runStatus.stoppedAt":"Stopped at","runStatus.timeFormat":"%H:%M","runStatus.tokens":"Tokens","runStatus.tokensValue":"%1 in \xB7 %2 out","runStatus.waitingSince":"Waiting since","runStatus.workingTime":"Working time","runStatus.blockedSince":"Blocked since","runStatus.tokenBudget":"%1 of %2 tokens","runTrace.arguments":"Arguments","runTrace.awaiting":"Waiting for the result\u2026","runTrace.call":"1 tool call","runTrace.calls":"%1 tool calls","runTrace.copied":"Copied","runTrace.copyArguments":"Copy arguments","runTrace.copyError":"Copy error","runTrace.copyResult":"Copy result","runTrace.doing":"%1\u2026","runTrace.error":"Error","runTrace.failedAfter":"Failed after %1","runTrace.handoff":"%1 handed over to %2","runTrace.label":"Steps","runTrace.result":"Result","runTrace.retried":"Retried","runTrace.retries":"%1 retries","runTrace.retry":"1 retry","runTrace.showAll":"Show all","runTrace.source":"1 source","runTrace.sources":"%1 sources","runTrace.step":"1 step","runTrace.steps":"%1 steps","runTrace.stoppedAfter":"Stopped after %1","runTrace.worked":"Worked for %1","runTrace.working":"Working\u2026","runTrace.blockedAfter":"Blocked after %1","runTrace.token":"1 token","runTrace.tokens":"%1 tokens","search.clear":"Clear search","search.label":"Search","search.submit":"Submit search","search.submitTitle":"Search","select.clear":"Clear selection","select.create":"Create new\u2026","select.createGroup":"New","select.empty":"No matches","select.label":"Select","select.loading":"Loading","select.none":"No selection","select.recent":"Recent","select.required":"Please select a value.","select.toggle":"Toggle options","sheet.resize":"Resize sheet","slider.value":"Value","sortControl.ascending":"Ascending","sortControl.descending":"Descending","sortControl.label":"Sort by","sourceList.label":"Sources","sourceList.source":"Source","splitView.resize":"Resize panes","statTile.down":"down %1","statTile.loading":"Loading","statTile.unchanged":"no change","statTile.up":"up %1","stepper.completed":"Completed","stepper.counter":"Step %1 of %2","status.backlog":"Backlog","status.canceled":"Canceled","status.done":"Done","status.duplicate":"Duplicate","status.inProgress":"In Progress","status.inReview":"In Review","status.ready":"Ready to Merge","status.todo":"Todo","status.waiting":"Waiting for feedback","stepper.current":"Current step","stepper.error":"Error","stepper.optional":"Optional","tabbox.close":"Close","table.cellInput":"%1 row %2","table.collapseRow":"Collapse %1","table.columnMoved":"Moved %1 to position %2 of %3.","table.columns":"Columns","table.empty":"No records","table.label":"Table","table.expandRow":"Expand %1","table.invalid":"Invalid value","table.more":"Show %1 more","table.moveColumn":"Move %1","table.moveColumnEarlier":"Move %1 earlier","table.moveColumnLater":"Move %1 later","table.moveRow":"Move %1","table.reorderBlocked":"Clear sorting to reorder rows","table.row":"row %1","table.rowDropped":"Row dropped","table.rowGrabbed":"Row grabbed. Use the arrow keys to move it.","table.rowMoved":"Moved row to position %1 of %2.","table.rowOrder":"Row order","table.selectAll":"Select all rows","table.selectRow":"Select %1","tagPicker.create":"Create \u201C%1\u201D","tagPicker.empty":"No matches","tagPicker.input":"Add a value","tagPicker.loading":"Loading\u2026","tagPicker.remove":"Remove %1","tagPicker.toggle":"Toggle options","timebox.duration":"Duration in hours and minutes","timebox.durationWithSeconds":"Duration in hours, minutes, and seconds","timebox.hours":"Hours","timebox.minutes":"Minutes","timebox.seconds":"Seconds","timebox.toggleSign":"Toggle duration sign","timePicker.clock":"Pick the time on a clock","timePicker.hour":"Hour","timePicker.label":"Time","timePicker.minute":"Minute","timePicker.minutes":"Minutes","timePicker.second":"Second","timePicker.selectHour":"Select the hour","timePicker.selectMinutes":"Select the minutes","toolbar.label":"Toolbar","toolbar.more":"More","tree.label":"Tree","tree.more":"More actions","tree.noItems":"Nothing to show","uiMessageStream.approvalTitle":"Run %1?","uiMessageStream.file":"File","uiMessageStream.showTile":"Show %1","uiMessageStream.thinking":"Thinking","uiMessageStream.thought":"Thought for %1","valueList.add":"Add value","valueList.duplicate":"This value already exists.","valueList.instructions":"Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder.","valueList.invalid":"This value is not valid.","valueList.removable":"%1. Press Delete to remove.","valueList.values":"Values","viewSettings.add":"Add","viewSettings.added":"%1 added at position %2 of %3","viewSettings.addField":"Add %1","viewSettings.allShown":"Every field is shown.","viewSettings.board":"Board","viewSettings.canceled":"Move canceled. %1 is back at position %2 of %3","viewSettings.chooseField":"Choose a field","viewSettings.columns":"Columns","viewSettings.dragging":"%1 picked up, position %2 of %3","viewSettings.dropped":"%1 dropped at position %2 of %3","viewSettings.emptyColumns":"Show empty columns","viewSettings.fields":"Fields","viewSettings.grabbed":"%1 picked up, position %2 of %3. Use the arrow keys to move it, Space to drop it, Escape to cancel.","viewSettings.group":"Group by","viewSettings.hidden":"Hidden (%1)","viewSettings.hiddenField":"%1 hidden","viewSettings.hide":"Hide %1","viewSettings.instructions":"Press Space to pick the field up, the arrow keys to move it, Space again to drop it, or Escape to cancel.","viewSettings.label":"View settings","viewSettings.lastField":"At least one field stays shown","viewSettings.locked":"Always shown","viewSettings.moved":"%1 moved to position %2 of %3","viewSettings.noMatch":"No hidden field matches \u201C%1\u201D.","viewSettings.none":"None","viewSettings.reorder":"Reorder %1","viewSettings.search":"Find a field","viewSettings.shown":"Shown (%1)","viewSettings.swimlanes":"Swim lanes","viewSettings.typeBoolean":"Checkbox","viewSettings.typeDate":"Date","viewSettings.typeDatetime":"Date and time","viewSettings.typeEmail":"Email","viewSettings.typeEntity":"Linked record","viewSettings.typeFile":"File","viewSettings.typeImage":"Image","viewSettings.typeMoney":"Money","viewSettings.typeNumber":"Number","viewSettings.typePriority":"Priority","viewSettings.typeRating":"Rating","viewSettings.typeSelect":"Select","viewSettings.typeStatus":"Status","viewSettings.typeTags":"Tags","viewSettings.typeText":"Text","viewSettings.typeTime":"Time","viewSettings.typeUrl":"URL","workspaceSwitcher.heading":"Workspaces","workspaceSwitcher.label":"Switch workspace: %1","workspaceSwitcher.labelEmpty":"Switch workspace","surface.byline":"Composed by %1","surface.submit":"Submit","surface.cancel":"Cancel","surface.confirm":"Confirm","surface.approve":"Approve selected","surface.reject":"Reject","surface.decline":"Decline","surface.fallback":"This part could not be shown","surface.choiceRequired":"Choose an answer to continue.","surface.noAnswer":"No answer","surface.yes":"Yes","surface.no":"No","surface.selected":"Selected","surface.field":"Field","surface.before":"Before","surface.after":"After","surface.dataTable":"Data table","surface.requested":"Information requested","surface.submitted":"Submitted","surface.confirmed":"Confirmed","surface.approved":"Approved","surface.rejected":"Rejected","surface.cancelled":"Cancelled","surface.dismissed":"Dismissed","surface.chose":"Chose \u201C%1\u201D","surface.verdictAt":"%1 at %2","surface.typeToConfirm":"confirm","surface.choose":"Choose\u2026","zeyosForm.saved":"%1 saved successfully.","zeyosLauncher.applications":"Applications","zeyosLauncher.recent":"Recent","zeyosLauncher.results":"Top results","zeyosLauncher.move":"Move","zeyosLauncher.open":"Open","zeyosLauncher.close":"Close","zeyosModuleBar.forks":"Forks","zeyosModuleBar.weblets":"Weblets","zeyosCalendar.untitled":"Untitled appointment","questionnaire.rule.minLength":"Enter at least %1 characters.","questionnaire.rule.minLength.one":"Enter at least %1 character.","questionnaire.rule.minLength.other":"Enter at least %1 characters.","questionnaire.rule.maxLength":"Enter at most %1 characters.","questionnaire.rule.minItems":"Choose at least %1.","questionnaire.rule.maxItems":"Choose at most %1.","questionnaire.rule.minimum":"Enter a number of at least %1.","questionnaire.rule.maximum":"Enter a number of at most %1.","questionnaire.rule.oneOf":"Choose one of the offered answers.","questionnaire.rule.date":"Enter a date as YYYY-MM-DD.","questionnaire.rule.dateTime":"Enter a date and time as YYYY-MM-DDTHH:MM.","questionnaire.rule.time":"Enter a time as HH:MM.","questionnaire.rule.email":"Enter an email address.","questionnaire.rule.uri":"Enter a full address, such as https://example.com.","agentThread.needsAnswer":"%1 needs your answer"}),gs=Object.freeze({"calendar.agenda":"agenda","calendar.allDay":"allDay","calendar.day":"day","calendar.editCancelled":"editCancelled","calendar.editCommitted":"editCommitted","calendar.editPreview":"editPreview","calendar.label":"calendar","calendar.loading":"loading","calendar.month":"month","calendar.more":"more","calendar.moveStarted":"moveStarted","calendar.new":"new","calendar.next":"next","calendar.noEvents":"noEvents","calendar.previous":"previous","calendar.resize":"resize","calendar.resizeStarted":"resizeStarted","calendar.today":"today","calendar.week":"week","calendar.weekNumber":"weekNumber","calendar.year":"year"});var Xn=null,tr="en",er=new Map;function _s(i){tr=String(i||"en")}function X(){return tr}function be(i){if(!Xn)return null;let e=Xn(i);if(e==null)return null;let t=String(e);return t===i?null:t}function Kt(i){return Object.prototype.hasOwnProperty.call(Ut,i)?Ut[i]:null}function Yt(i){return Object.prototype.hasOwnProperty.call(gs,i)?gs[i]:null}function R(i,e){let t=Yt(i),s=be(i)??(t?be(t):null)??Kt(i)??i;return F(s,e)}function K(i,e=Intl.NumberFormat){for(let t of[i,X(),"en"])if(t!=null)try{let s=e.supportedLocalesOf(Intl.getCanonicalLocales(t));if(s.length)return Array.isArray(t)?s:s[0]}catch{}return"en"}function bs(i,e,t){if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("Plural count must be a finite number");let s=K(t,Intl.PluralRules),n=String(s),r=er.get(n);r||(r=new Intl.PluralRules(s),er.set(n,r));let o=r.select(e),a=Yt(i);return[...new Set([`${i}.${o}`,`${i}.other`,i,...a?[a]:[]])]}function gt(i,e){for(let t of i){let s=e(t);if(s!==null)return s}return null}function F(i,e){if(e==null)return String(i);let t=Array.isArray(e)?e:typeof e=="object"?null:[e],s=0;return String(i).replace(/%(\d+)|%([A-Za-z_][\w.-]*)%(?!\d)/g,(n,r,o)=>{if(r!==void 0){let a=Number(r)-1,l;return t?l=t[a]:Object.prototype.hasOwnProperty.call(e,r)&&(l=e[r]),l==null?n:String(l)}if(!t&&Object.prototype.hasOwnProperty.call(e,o)){let a=e[o];return a==null?n:String(a)}if(t&&s<t.length){let a=t[s];return s+=1,a==null?n:String(a)}return n})}var oc=0,ac=20,lc=3;var ir=new Map;function Oe(i,e={}){let t=vs(i);if(t===null)return"";let{locale:s,decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=e;return ys(s,ws({decimals:n,minDecimals:r,maxDecimals:o,group:a}),t)}function We(i,e,t={}){let s=vs(i);if(s===null)return"";let{locale:n,decimals:r}=t,o=uc(e);if(o===null)return Oe(s,{locale:n,decimals:r});let a=ws({decimals:r,group:!0});return ys(n,{...a,style:"currency",currency:o},s)}function nr(i,e={}){let t=vs(i);if(t===null)return"";let{locale:s,decimals:n=0}=e;return ys(s,{...ws({decimals:n,group:!0}),style:"percent"},t)}function ys(i,e,t){i=K(i);let s=`${i}\0${JSON.stringify(e)}`,n=ir.get(s);return n===void 0&&(n=cc(i,e),ir.set(s,n)),n.format(t)}function cc(i,e){try{return new Intl.NumberFormat(i,e)}catch{try{return new Intl.NumberFormat(K(),e)}catch{return new Intl.NumberFormat(K())}}}function ws({decimals:i,minDecimals:e,maxDecimals:t,group:s=!0}){let n={useGrouping:s!==!1},r=sr(e??i),o=sr(t??i);return r!==null&&(n.minimumFractionDigits=r),o!==null?(n.maximumFractionDigits=o,r!==null&&r>o&&(n.minimumFractionDigits=o)):r!==null&&(n.maximumFractionDigits=Math.max(r,lc)),n}function sr(i){if(i==null)return null;let e=Number(i);return Number.isFinite(e)?Math.min(ac,Math.max(oc,Math.round(e))):null}function vs(i){if(i==null||i==="")return null;let e=typeof i=="number"?i:Number(i);return Number.isFinite(e)?e:null}function uc(i){if(typeof i!="string")return null;let e=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(e)?e:null}function ye(i){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");let e=i.getTime();if(!Number.isFinite(e))throw new RangeError("Invalid Date");return Math.floor(e/1e3)}function Te(i){if(i==null)return null;let e=Number(i);if(!Number.isFinite(e))throw new TypeError("Expected finite Unix seconds");return new Date(e*1e3)}function xs(i,e){if(i==null||i==="")return null;let t=Number(i);if(!Number.isFinite(t))throw new TypeError("Expected finite Unix seconds");let{year:s,month:n,day:r}=_t(e).dayOf(t*1e3);return or(s,n,r)}function Wt(i,e){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");if(!Number.isFinite(i.getTime()))throw new RangeError("Invalid Date");let t=_t(e).midnightOf(i.getFullYear(),i.getMonth(),i.getDate());return Math.floor(t/1e3)}function Zt(i){if(!(i==null||i===""))try{return new Intl.DateTimeFormat("en-US",{timeZone:String(i)}).resolvedOptions().timeZone}catch{throw new RangeError(`Unknown time zone "${String(i)}"`)}}function _t(i){let e=Zt(i);if(!e)return{timeZone:void 0,dayOf:r=>{let o=new Date(r);return{year:o.getFullYear(),month:o.getMonth(),day:o.getDate()}},midnightOf:(r,o,a)=>or(r,o,a).getTime()};let t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),s=r=>{let o={};for(let a of t.formatToParts(new Date(r)))o[a.type]=Number(a.value);return{year:o.year,month:o.month-1,day:o.day,seconds:o.hour%24*3600+o.minute*60+o.second}},n=r=>{let o=s(r);return rr(o.year,o.month,o.day)+o.seconds*1e3-Math.floor(r/1e3)*1e3};return{timeZone:e,dayOf:r=>{let{year:o,month:a,day:l}=s(r);return{year:o,month:a,day:l}},midnightOf:(r,o,a)=>{let l=rr(r,o,a),c=l-n(l),d=l-n(c),h=null;for(let p of[d,c]){let f=s(p);f.year!==r||f.month!==o||f.day!==a||(!h||f.seconds<h.seconds)&&(h={candidate:p,seconds:f.seconds})}return h?h.candidate:d}}}function or(i,e,t){let s=new Date(2e3,0,1);return s.setFullYear(i,e,t),s.setHours(0,0,0,0),s}function rr(i,e,t){let s=new Date(0);return s.setUTCFullYear(i,e,t),s.getTime()}function ar(i){return(Array.isArray(i)?i:i?[i]:[]).flatMap(t=>{if(!t||typeof t!="object")return[];let s=t.rawField??t.field??t.id;if(s==null||String(s).trim()==="")return[];let n=String(s).trim().replace(/^[+-]/,"");return[`${t.dir==="desc"?"-":"+"}${n}`]})}function dc(i,e=[],t={}){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("DataFilter state must be an object");let s=!!t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"timeZone"),n=s?Zt(t.timeZone):void 0,r=hc(i,e),o={},a=0;for(let l of r){if(!l.id||!Object.prototype.hasOwnProperty.call(i,l.id))continue;let c=i[l.id];if(c===void 0||c===null&&l.includeNull!==!0||typeof c=="string"&&c.trim()===""&&l.includeEmpty!==!0)continue;if(typeof l.toFilter=="function"){let f=l.toFilter(c,i);f&&typeof f=="object"&&!Array.isArray(f)&&Object.assign(o,f);continue}let d=typeof l.transform=="function"?l.transform(c,i):fc(c,l,s?{timeZone:n}:null);if(d===void 0)continue;l.operator&&(d={[l.operator]:d});let h=Array.isArray(l.fields)?l.fields.filter(f=>typeof f=="string"&&f):[];if(h.length>1){for(;Object.prototype.hasOwnProperty.call(o,String(a));)a+=1;o[String(a)]=["OR",...h.map(f=>({[f]:d}))],a+=1;continue}let p=h[0]??l.rawField??l.field??l.id;typeof p=="string"&&p&&(o[p]=d)}return o}function bt(i={}){let{fields:e,sort:t,filters:s={},search:n,limit:r,offset:o,visibility:a=0,count:l=!1}=i;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ZeyOS filters must be an object");let c={};Array.isArray(e)?c.fields=[...e]:e&&typeof e=="object"&&(c.fields={...e});let d={...s},h=Object.prototype.hasOwnProperty.call(i,"visibility");a!==void 0&&(h||!Object.prototype.hasOwnProperty.call(d,"visibility"))&&(d.visibility=a),Object.keys(d).length&&(c.filters=d);let p=pc(t,e),f=ar(p);return f.length&&(c.sort=f),n!=null&&String(n).trim()&&(c.query=String(n).trim()),r!=null&&(c.limit=r),o!=null&&(c.offset=o),l&&(c.count=!0),c}function hc(i,e){return Array.isArray(e)&&e.length?e.map(t=>({...t})):e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length?Object.entries(e).map(([t,s])=>typeof s=="string"?{id:t,field:s}:{...s,id:t}):Object.keys(i).map(t=>({id:t,field:t}))}function fc(i,e,t=null){let s=String(e.format??e.type??"").toLowerCase();if(!["date","datetime","date-time"].includes(s))return i;let n=r=>{if(t&&s==="date"){if(r instanceof Date)return Wt(r,t.timeZone);let o=typeof r=="string"?/^(\d{4})-(\d{2})-(\d{2})$/.exec(r.trim()):null;if(o){let a=_t(t.timeZone).midnightOf(Number(o[1]),Number(o[2])-1,Number(o[3]));return Math.floor(a/1e3)}return r}return r instanceof Date?ye(r):r};return Array.isArray(i)?i.map(n):n(i)}function pc(i,e){if(!i||!e||Array.isArray(e)||typeof e!="object")return i;let t=s=>{if(!s||typeof s!="object")return s;let n=s.id;return!n||!Object.prototype.hasOwnProperty.call(e,n)?s:{...s,rawField:e[n]}};return Array.isArray(i)?i.map(t):t(i)}var Jt=Object.create(null),mc=new Set(["date","duedate","birthdate","datefrom","dateto","datecancel","lastbilling"]),lr=new Set(["appointments.datefrom","appointments.dateto","events.datefrom","events.dateto","comments.date","documentversions.date","records.date"]),gc=Object.freeze({AWAITINGACCEPTANCE:"awaiting acceptance",AWAITINGAPPROVAL:"awaiting approval",BILLINGONLY:"billing only",CUSTOMERANDSUPPLIER:"customer and supplier",FEEDBACKREQUIRED:"feedback required",INEVALUATION:"in evaluation",INNEGOTIATION:"in negotiation",INREVISION:"in revision",NOSTOCK:"no stock",NOTSTARTED:"not started",PARTLYDELIVERED:"partly delivered",PARTLYINVOICED:"partly invoiced",PARTLYORDERED:"partly ordered",PARTLYPAID:"partly paid",PROCUREMENTONLY:"procurement only",REMOTECALL:"remote call",SERIALSANDCHARGES:"serials and charges"}),_c=Object.freeze({0:"Lowest",1:"Low",2:"Medium",3:"High",4:"Highest"}),bc=/^[A-Z][A-Z\d]*(?:_[A-Z\d]+)*$/,cr=new Set;function U(i,e){let t=Qt(i);if(!t)throw new TypeError("ZeyOS field type must not be empty");if(!e||typeof e!="object")throw new TypeError("Field type strategy must be an object");for(let s of["field","column"]){let n=e[s];if(typeof n!="function"&&(!n||typeof n!="object"||Array.isArray(n)))throw new TypeError(`Field type strategy requires a ${s} builder or descriptor`)}return Jt[t]=e,e}function Ss(i){let e=pr(i),t=fr(e),s=mr(t.field,e),n={id:e.id,type:"text",label:gr(e),...s};return e.description!=null&&(n.description=String(e.description)),(e.required===!0||e.nullable===!1)&&(n.required=!0),Dc(e)&&(n.readonly=!0,n.disabled=!0,n.props={...n.props??{},readOnly:!0}),n}function As(i){let e=pr(i),t=fr(e);return{id:e.id,label:gr(e),sortable:e.sortable!==!1,...mr(t.column,e)}}function yt(i,e,t={}){let s=i?.schema;if(!s||typeof s.fields!="function"||typeof s.describe!="function")throw new TypeError("ZeyOS client must expose schema.fields() and schema.describe()");let n=s.describe(e),r=ur(n?.fields),o=ur(s.fields(e)),a=new Map;for(let[m,g]of o)a.set(m,{...g,...r.get(m)??{}});for(let[m,g]of r)a.has(m)||a.set(m,{...g});let l=Array.isArray(t.fields)?t.fields.map(String):[...a.keys()],c=new Set(Array.isArray(t.exclude)?t.exclude.map(String):[]),d=t.labels&&typeof t.labels=="object"?t.labels:{},h=t.formats&&typeof t.formats=="object"?t.formats:{},p=Zt(t.timeZone),f=[];for(let m of l){if(c.has(m)||!a.has(m))continue;let g=a.get(m)??{},_={...g,id:m,name:m,resource:String(e)},b=g.enums??g.enum??Oc(s,e,m);b!=null&&(_.enums=b,_.enum==null&&(_.enum=b)),Object.prototype.hasOwnProperty.call(d,m)&&(_.label=String(d[m])),Object.prototype.hasOwnProperty.call(h,m)&&h[m]&&(_.format=String(h[m])),p&&(_.timeZone=p),f.push(_)}return f}var dr={field:{type:"text"},column:{}},yc={field:{type:"int"},column:{align:"right"}},wc={field:{type:"float"},column:i=>({align:"right",render:wr(i)})},vc={field:{type:"float"},column:i=>({align:"right",render:wr(i,!0)})},xc={field:i=>({type:"zxselect",props:{entity:_r(i)}}),column:i=>({render:e=>jc(fe(e,i),e,i)})},Sc={field:{type:"toggle"},column:i=>({align:"center",render:e=>fe(e,i)?"\u2713":"",sortValue:e=>+!!fe(e,i)})},Ac={field:i=>({type:Rc(i),options:ks(i)}),column:i=>({render:yr(i)})},kc={field:{type:"zxselect",props:{preset:"priority"}},column:i=>({render:yr(i,_c)})},Cc={field:{type:"float",props:{min:0,max:100}},column:i=>({align:"right",render:e=>Lc(fe(e,i),i.locale),sortValue:e=>Cs(fe(e,i))})},Tc=hr("date"),zc=hr("datetime");for(let i of["string","text","character","character varying","varchar","email","tel","url","uri"])U(i,dr);for(let i of["integer","smallint","bigint","int","int2","int4","int8","int32","int64"])U(i,yc);for(let i of["number","numeric","decimal","real","double","double precision","float"])U(i,wc);for(let i of["money","currency","price","pricebilling","priceprocurement","priceproduction"])U(i,vc);for(let i of["entity","t_entity"])U(i,xc);for(let i of["boolean","checked"])U(i,Sc);for(let i of["list","enum"])U(i,Ac);for(let i of["progress","percent"])U(i,Cc);for(let i of["date"])U(i,Tc);for(let i of["datetime","date-time"])U(i,zc);U("priority",kc);U("text[]",{field:{type:"valuelist"},column:{}});U("json",{field:{type:"textarea"},column:{}});U("longtext",{field:{type:"textarea"},column:{}});for(let i of["email","tel","url","uri"])U(i,{field:{type:"text",props:{type:i==="uri"?"url":i}},column:{}});function hr(i){return{field:{type:i},column:e=>{let t=i==="datetime"?Fc(e.locale):Pc(e.timeZone,e.locale);return{render:s=>t(fe(s,e)),sortValue:s=>Vc(fe(s,e))}}}}function fr(i){let e=Ec(i),t=Jt[e];return t||(cr.has(e)||(cr.add(e),console.warn(`[zx.zeyos] Unknown field type or format "${e||"unknown"}" for "${i.id}"; using text.`)),dr)}function Ec(i){let e=Qt(i.format??i.semanticFormat??i.semanticType??i.widget);if(e&&Jt[e])return e;if(_r(i)||Qt(i.type)==="t_entity")return"entity";if(String(i.id).toLowerCase()==="priority")return"priority";if(i.enums!=null||i.enum!=null)return"enum";let t=Qt(i.type);if(t==="bigint"||t==="int64"){let s=Ic(i);if(s)return s}return Nc(i,t)?"longtext":t&&Jt[t]?t:t.endsWith("[]")?"text[]":t==="json"||t==="jsonb"?"json":/^character varying(?:\(\d+\))?$/.test(t)?"character varying":t||e}function Ic(i){let e=String(i.id).toLowerCase(),t=String(i.resource??"").toLowerCase();return mc.has(e)&&!lr.has(`${t}.${e}`)&&(e!=="date"||i.indexed)?"date":lr.has(`${t}.${e}`)||/(?:date|time)$|^lastmodified$/.test(e)?"datetime":null}function pr(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Field metadata must be an object");let e=i.id??i.name??i.field??i.identifier??i.reference;if(e==null||String(e).trim()==="")throw new TypeError("Field metadata requires an id or name");return{...i,id:String(e)}}function mr(i,e){let t=typeof i=="function"?i(e):i;return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}function Qt(i){return String(i??"").trim().toLowerCase().replace(/\s+/g," ")}function gr(i){let e=i.label??i.title??i.displayName;return e==null||e===""?Mc(i.id):String(e)}function Mc(i){let e=String(i??"").split(".").at(-1)??"";if(e==="ID")return"ID";let t=e.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):e}function Dc(i){return i.readonly===!0||i.readOnly===!0||i.writable===!1||i.mutable===!1}function Nc(i,e){if(i.long===!0||i.multiline===!0)return!0;let t=Number(i.maxLength??e.match(/^character varying\((\d+)\)$/)?.[1]);return Number.isFinite(t)&&t>255}function _r(i){for(let e of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"){let t=e.resource??e.target??e.table??e.entity;if(typeof t=="string"&&t)return t}}return null}function ur(i){let e=new Map;if(Array.isArray(i)){for(let t of i)if(typeof t=="string")e.set(t,{});else if(t&&typeof t=="object"){let s=t.id??t.name??t.field;s!=null&&e.set(String(s),{...t})}}else if(i&&typeof i=="object")for(let[t,s]of Object.entries(i))e.set(t,s&&typeof s=="object"?{...s}:{});return e}function Oc(i,e,t){if(typeof i.enums!="function")return null;let s=i.enums(e,t);return s&&typeof s=="object"&&!Array.isArray(s)&&Object.prototype.hasOwnProperty.call(s,t)?s[t]:s??null}function ks(i){return br(i.enums??i.enum??i.options)}function br(i){if(typeof i=="string")try{return br(JSON.parse(i))}catch{return{}}return Array.isArray(i)?Object.fromEntries(i.map((e,t)=>{if(Array.isArray(e)){let[s=t,n=s]=e;return[String(s),Gt(n)]}if(e&&typeof e=="object"){let s=e.value??e.id??t;return[String(s),e.label!=null?String(e.label):Gt(e.name??s)]}return[String(t),Gt(e)]})):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,Gt(t)])):{}}function Gt(i){let e=String(i??"");if(!bc.test(e))return e;let t=e.split("_").map(s=>gc[s]??s.toLowerCase()).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function Rc(i){return Object.keys(ks(i)).length<=5?"optionlist":"select"}function yr(i,e={}){let t={...e,...ks(i)};return s=>{let n=fe(s,i);return n==null?"":t[String(n)]??String(n)}}function wr(i,e=!1){return t=>e&&i.currency?We(fe(t,i),String(i.currency),{locale:i.locale}):Oe(fe(t,i),{locale:i.locale})}function Cs(i){if(i==null||i==="")return null;let e=Number(i);return Number.isFinite(e)?e:null}function Lc(i,e){let t=Cs(i);return t==null?"":`${Oe(t,{locale:e})}%`}function Fc(i){let e=vr(i,{dateStyle:"medium",timeStyle:"short"});return t=>{let s=xr(t);return s?e(s):""}}function Pc(i,e){let t=_t(i??void 0),s=vr(e,{dateStyle:"medium",timeZone:"UTC"});return n=>{let r=xr(n);if(!r)return"";let{year:o,month:a,day:l}=n instanceof Date?{year:r.getFullYear(),month:r.getMonth(),day:r.getDate()}:t.dayOf(r.getTime()),c=new Date(0);return c.setUTCFullYear(o,a,l),s(c)}}function vr(i,e){let t,s;return n=>{let r=K(i,Intl.DateTimeFormat);return(!s||t!==String(r))&&(t=String(r),s=new Intl.DateTimeFormat(r,e)),s.format(n)}}function xr(i){if(i==null||i==="")return null;try{let e=i instanceof Date?i:Te(i);return e&&Number.isFinite(e.getTime())?e:null}catch{return null}}function Vc(i){return i instanceof Date?ye(i):Cs(i)}function fe(i,e){if(!i||typeof i!="object")return;if(Object.prototype.hasOwnProperty.call(i,e.id))return i[e.id];let t=String(e.path??e.field??e.id).split("."),s=i;for(let n of t){if(!s||typeof s!="object")return;s=s[n]}return s}function jc(i,e,t){if(i&&typeof i=="object"){let n=i.label??i.name??i.title??i.number??i.ID??i.id;return n==null?"":String(n)}let s=t.labelField;if(typeof s=="string"&&e[s]!=null)return String(e[s]);for(let n of[`${t.id}.name`,`${t.id}_label`,`${t.id}Label`])if(e[n]!=null)return String(e[n]);return i==null?"":String(i)}var Sr=0;function E(i="zx"){return Sr+=1,`${i}-${Date.now().toString(36)}-${Sr.toString(36)}`}function Ze(i,e){let t=wt(i)?Ar(i):{};if(!wt(e))return Xt(e);for(let[s,n]of Object.entries(e))wt(n)&&wt(t[s])?t[s]=Ze(t[s],n):t[s]=Xt(n);return t}function P(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function ze(i){if(typeof i!="string")return!1;let e=i.trim();if(!e||e.length>256||/[;{}\u0000-\u001f\u007f]/.test(e)||/(?:url|image|image-set|cross-fade|element|var)\s*\(/i.test(e))return!1;let t=globalThis.CSS?.supports;if(typeof t=="function")try{return t.call(globalThis.CSS,"color",e)}catch{return!1}return/^(?:#[\da-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix)\([^;{}]+\))$/i.test(e)}function vt(i,e,t){return Math.min(t,Math.max(e,i))}function Ts(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wt(i){if(i===null||typeof i!="object")return!1;let e=Object.getPrototypeOf(i);return e===Object.prototype||e===null}function Ar(i){let e={};for(let[t,s]of Object.entries(i))e[t]=Xt(s);return e}function Xt(i){return wt(i)?Ar(i):Array.isArray(i)?i.map(Xt):i}var xt=null;var Bc=new Set(["innerhtml","outerhtml","srcdoc"]);function Re(i){if(typeof i!="string")return null;let e=i.trim();if(!e)return null;try{let t=new URL(e,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(t.toLowerCase()))return null}catch{return null}return e}function u(i,e,...t){let s=e;qc(s)||(t.unshift(s),s={});let n=Object.entries(s);for(let[o]of n)if(Bc.has(o.toLowerCase()))throw new TypeError(`HTML property ${o} requires trusted h.raw() content`);let r=document.createElement(i);for(let[o,a]of n)Hc(r,o,a);return Uc(r,t),r}u.scope=function(e,t){let s=xt;xt=e;try{return t()}finally{xt=s}};u.raw=function(e){let t=document.createElement("template");return t.innerHTML=String(e),t.content};function Z(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,e=>[e.name,e.value])}}function G(i,e){if(!e)return;let t=i,s=typeof t.style?.cssText=="string",n=new Map(e.attributes),r=e.attributes.every(([o])=>i.hasAttribute(o));for(let o of Array.from(i.attributes))(!r||!n.has(o.name))&&(o.name==="style"&&s?ei(t,null):i.removeAttribute(o.name));for(let[o,a]of e.attributes)o==="style"&&s?ei(t,a):i.getAttribute(o)!==a&&i.setAttribute(o,a);i.replaceChildren(...e.children)}function ei(i,e){let t=i.getAttribute("style");t===e||!e&&t===null||(i.style.cssText=e??"",i.getAttribute("style"),e||i.removeAttribute("style"))}function Q(i){if(i==null)return null;if(P(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let e=i.toElement();return P(e)?e:null}return null}function qc(i){if(i===null||typeof i!="object"||Array.isArray(i))return!1;let e=i;return typeof e.nodeType=="number"?!1:typeof e.toElement!="function"}function Hc(i,e,t){if(e.toLowerCase()==="href"){let n=Re(t);if(n!==null){if("href"in i)try{i.href=n;return}catch{}i.setAttribute("href",n)}return}if(e==="ref"){xt&&typeof t=="string"&&(xt[t]=i);return}if(e==="class"){i.className=Array.isArray(t)?t.flat(1/0).filter(Boolean).join(" "):String(t??"");return}if(e==="style"){if(typeof t=="string")i.style.cssText=t;else if(t&&typeof t=="object")for(let[n,r]of Object.entries(t))n.startsWith("--")||n.includes("-")?i.style.setProperty(n,String(r)):i.style[n]=r;return}if(e==="dataset"&&t&&typeof t=="object"){for(let[n,r]of Object.entries(t))r==null?delete i.dataset[n]:i.dataset[n]=String(r);return}if(/^on[a-z]/.test(e)&&typeof t=="function"){i.addEventListener(e.slice(2),t);return}if(t==null)return;let s=$c(e);if(s!==null)i.setAttribute(s,String(t));else if(e in i)try{i[e]=t}catch{i.setAttribute(e,String(t))}else typeof t=="boolean"?t?i.setAttribute(e,""):i.removeAttribute(e):i.setAttribute(e,String(t))}function $c(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function Uc(i,e){let t=i;for(let s of e.flat(1/0)){if(s==null)continue;if(typeof s=="string"||typeof s=="number"){t.append(document.createTextNode(String(s)));continue}if(typeof s!="object")continue;let n=s;if(typeof n.nodeType=="number")t.append(s);else if(typeof n.toElement=="function"){let r=n.toElement();r&&t.append(r)}}}var ti=new WeakMap,zs=new WeakMap,S=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#e=new AbortController;#t=!1;#i=!1;#s=!1;constructor(e,t={}){super();let s=this.constructor;this.#t=e===null;let n=Q(e);if(e!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=Kc(s,t);zs.set(this,{own:ii(t?.msg)?Object.freeze(Ze({},t.msg)):null,inherited:Yc(s)});let o=[];for(let[c,d]of Object.entries(r))/^on[a-z]/.test(c)&&typeof d=="function"&&(o.push([c.slice(2),d]),delete r[c]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[c,d]of o)this.on(c,d);let a;try{a=u.scope(this.refs,()=>this.render())}catch(c){throw this.#e.abort(),c}if(this.#t){let c=P(a)?a:this.el;if(!P(c))throw this.#e.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=c}if(!P(this.el))throw this.#e.abort(),new TypeError("Component requires a root Element");let l=s.cssName;if(typeof l=="string"&&l){let c=`zx-${l}`;this.#s=!this.el.classList.contains(c),this.el.classList.add(c)}ti.set(this.el,this)}render(){return this.el??null}on(e,t){return this.addEventListener(e,t,{signal:this.#e.signal}),this}off(e,t){return this.removeEventListener(e,t),this}once(e,t){return this.addEventListener(e,t,{once:!0,signal:this.#e.signal}),this}addEvent(e,t){return this.on(e,t)}emit(e,t={},s={}){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("Event detail must be an object");let n=kr(e,t,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=kr(`zx-${e}`,t,{bubbles:!0,composed:!0,cancelable:!0});this.el.dispatchEvent(r),s.honorDomCancellation&&r.defaultPrevented&&n.preventDefault()}return n}listen(e,t,s,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return e.addEventListener(t,s,{...r,signal:this.#e.signal}),this}toElement(){return this.el}msg(e,...t){let s=this.options?.lang??this.options?.language??X(),n=Yt(e),r=zs.get(this)??{own:ii(this.options?.msg)?this.options.msg:null,inherited:null},o=r.own,a=St(o,s,e)??(n?St(o,s,n):null)??be(e)??(n?be(n):null)??St(r.inherited,s,e)??Kt(e)??e;return F(a,t)}msgPlural(e,t,...s){let n=this.options?.lang??this.options?.language??X(),r=bs(e,t,n),o=zs.get(this)??{own:ii(this.options?.msg)?this.options.msg:null,inherited:null},a=gt(r,l=>St(o.own,n,l))??gt(r,be)??gt(r,l=>St(o.inherited,n,l))??gt(bs(e,t,"en"),Kt)??e;return F(a,s)}destroy(){if(this.#i)return;this.#i=!0,this.#e.abort(),ti.get(this.el)===this&&ti.delete(this.el);let e=this.constructor.cssName;this.#s&&typeof e=="string"&&this.el&&this.el.classList.remove(`zx-${e}`),this.#t&&this.el&&this.el.remove()}static from(e){return ti.get(e)??null}};function Kc(i,e){let t=Cr(i),s={},n={},r=!1;for(let o of t)!o||typeof o!="object"||(Object.assign(s,o),o.msg&&typeof o.msg=="object"&&(r=!0,n=Ze(n,o.msg)));return Object.assign(s,e&&typeof e=="object"?e:{}),e?.msg&&typeof e.msg=="object"&&(r=!0,n=Ze(n,e.msg)),r&&(s.msg=n),s}function Cr(i){let e=[],t=i;for(;t&&t!==Function.prototype;)Object.prototype.hasOwnProperty.call(t,"defaults")&&e.unshift(t.defaults),t=Object.getPrototypeOf(t);return e}function ii(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function Yc(i){let e=null;for(let t of Cr(i))t&&typeof t=="object"&&ii(t.msg)&&(e=Ze(e??{},t.msg));return e?Object.freeze(e):null}function St(i,e,t){if(!i)return null;let s=i[e]?.[t];if(s!=null&&typeof s!="object")return String(s);let n=Object.prototype.hasOwnProperty.call(i,t)?i[t]:null;return n!=null&&typeof n!="object"?String(n):null}function kr(i,e,t){if(typeof CustomEvent=="function")return new CustomEvent(i,{...t,detail:e});let s=new Event(i,t);return Object.defineProperty(s,"detail",{configurable:!0,enumerable:!0,value:e}),s}var C=class i extends S{static cssName="field";static defaults={id:null,name:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,readonly:!1,options:null,layout:"stack",props:{},msg:{"field.int":"Enter a whole number.","field.float":"Enter a valid number.","field.unknown":"Unknown field type: %1"}};static#e=new Map;static register(e,t){let s=String(e).trim().toLowerCase();if(!s)throw new TypeError("Field adapter type must not be empty");if(typeof t!="function")throw new TypeError("Field adapter must be a function");return i.#e.set(s,t),this}static has(e){return i.#e.has(String(e).trim().toLowerCase())}render(){let e=this.el??u("div");this.el=e;let t=String(this.options.type||"text").toLowerCase(),s=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=Qc(e,["data-layout","data-field-type","data-disabled","data-readonly","data-state"]),e.dataset.layout=s,e.dataset.fieldType=t,this.controlId=this.options.id?String(this.options.id):E("zx-field"),this.name=String(this.options.name??this.options.id??"");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=u("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?u("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),l=u("div",{class:"zx-field__control"}),c=u("div",{class:"zx-field__description",id:r},String(this.options.description??"")),d=u("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),h=u("div",{class:"zx-field__body"},l,c,d);this._ownedNodes.push(a,h),e.append(a,h);let p=i.#e.get(t);if(p)try{this.adapter=Zc(p(this,this.options))}catch(g){let _=g instanceof Error?g.message:String(g);console.warn(`[zx.Field] Adapter "${t}" failed: ${_}`),this.adapter=zr(_,this.controlId)}else{let g=this.msg("field.unknown",t);console.warn(`[zx.Field] ${g}`),this.adapter=zr(g,this.controlId)}let f=this.adapter.el;f.id||(f.id=this.controlId);let m=this.adapter.labelTarget??(si(f)?f:Gc(f))??f;return this._labelled=m,m!==f&&si(m)&&!m.id&&(m.id=`${this.controlId}-input`),a.htmlFor=si(m)?m.id:f.id,si(m)||m.setAttribute("aria-labelledby",n),this._baseDescribedBy=m.getAttribute("aria-describedby")??"",l.append(f),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=d,this._syncDescription(),this.initialValue=Wc(t,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.options.readonly&&this.setReadonly(!0),this.listen(f,"change",()=>{this.emit("change",{value:this.getValue()})}),e}getValue(){return this.adapter.get()}setValue(e,{silent:t=!1}={}){return this.adapter.set(e,{silent:t}),t||this.emit("change",{value:this.getValue()}),this}focus(){return this.adapter.focus(),this}reset(){return this.setValue(this.initialValue,{silent:!0}),this.clearHighlight(),this}setDisabled(e){let t=!!e;return this.adapter.setDisabled(t),this.el.dataset.disabled=String(t),this}setReadonly(e){let t=!!e;return this.adapter.setReadonly?.(t),this.el.dataset.readonly=String(t),this}setHighlight(e,t="danger"){if(!e)return this.clearHighlight();let s=["danger","warning","success"].includes(t)?t:"danger";return this.el.dataset.state=s,this._highlight.textContent=String(e??""),this._highlight.hidden=!e,s==="danger"&&e?(this._highlight.setAttribute("role","alert"),this._labelled.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(e)})):(this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid")),this._syncDescription(!!e),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(e){if(!(e instanceof S))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(e),e}_syncDescription(e=!1){let t=[this._baseDescribedBy,this._descriptionId,e?this._highlightId:""].flatMap(s=>s.split(/\s+/)).filter(Boolean);t.length?this._labelled.setAttribute("aria-describedby",[...new Set(t)].join(" ")):this._labelled.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let e of this._ownedComponents??[])e.destroy();this._ownedComponents?.clear();for(let e of this._ownedNodes??[])e.remove();Jc(this.el,this._rootAttributes??new Map),super.destroy()}};function Es(i){if(typeof i=="number")return Number.isInteger(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let e=String(i??"").trim();if(e==="")return{valid:!0,value:""};let t=Ir(e);return t!==null&&Number.isInteger(t)?{valid:!0,value:t}:{valid:!1,value:e}}function Is(i){if(typeof i=="number")return Number.isFinite(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let e=String(i??"").trim();if(e==="")return{valid:!0,value:""};let t=Ir(e);return t!==null?{valid:!0,value:t}:{valid:!1,value:e}}function Ir(i){let e=i.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(e))return null;let t=/^[+-]/.test(e)?e[0]:"",s=t?e.slice(1):e;if(!/\d/.test(s))return null;let n=[...s.matchAll(/\./g)].map(l=>l.index),r=[...s.matchAll(/,/g)].map(l=>l.index),o;if(n.length&&r.length){let l=n.at(-1)>r.at(-1)?".":",",c=l==="."?",":".",d=s.lastIndexOf(l),h=s.slice(0,d),p=s.slice(d+1);if(!/^\d+$/.test(p)||!Tr(h,c))return null;o=h.split(c).join("")+"."+p}else if(r.length>1||n.length>1){let l=r.length?",":".";if(!Tr(s,l))return null;o=s.split(l).join("")}else r.length===1?o=s.replace(",","."):o=s;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let a=Number(t+o);return Number.isFinite(a)?a:null}function Tr(i,e){let t=i.split(e);return t.length>0&&/^\d{1,3}$/.test(t[0])&&t.slice(1).every(s=>/^\d{3}$/.test(s))}function Wc(i,e){return e!==void 0?e:i==="checkbox"?!1:""}function Zc(i){if(!i||typeof i!="object")throw new TypeError("Adapter must return an object");if(!(i.el&&i.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let e of["get","set","focus","setDisabled"])if(typeof i[e]!="function")throw new TypeError(`Adapter is missing ${e}()`);return i}function zr(i,e){let t=u("div",{class:"zx-field__error-control",id:e,role:"alert",tabIndex:-1},i);return{el:t,get:()=>null,set:()=>{},focus:()=>t.focus(),setDisabled:()=>{}}}function si(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function Gc(i){for(let e of i.querySelectorAll('input:not([type="hidden"]), select, textarea'))if(!(e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby")||[...e.labels??[]].some(s=>s.textContent?.trim())))return e;return null}function Qc(i,e){return new Map(e.map(t=>[t,i.getAttribute(t)]))}function Jc(i,e){for(let[t,s]of e)s===null?i.removeAttribute(t):i.setAttribute(t,s)}function At(i,e,t){let s={...e.props??{}};for(let n of Object.keys(s))(/^on[a-z]/i.test(n)||n==="content")&&delete s[n];return{name:i.name||void 0,...s,...t}}function ni(i,e){return(t,s)=>{let n=u(i,At(t,s,{type:i==="input"?e:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return{...Ms(n),setReadonly:r=>{n.readOnly=r}}}}function Ms(i){return{el:i,get:()=>i.value,set:e=>{i.value=e==null?"":String(e)},focus:()=>i.focus(),setDisabled:e=>{i.disabled=e}}}function Mr(i){return(e,t)=>{let s=i==="int"?Es:Is,n=u("input",At(e,t,{type:"text",inputMode:i==="int"?"numeric":"decimal",placeholder:t.placeholder,required:t.required,disabled:t.disabled}));return e.listen(n,"blur",()=>{let r=s(n.value);if(!r.valid){e.setHighlight(e.msg(`field.${i}`),"danger");return}r.value!==""&&(n.value=String(r.value)),e.clearHighlight()}),{...Ms(n),get:()=>s(n.value).value,setReadonly:r=>{n.readOnly=r}}}}var Xc=(i,e)=>{let t=u("input",At(i,e,{type:"checkbox",required:e.required,disabled:e.disabled}));return{el:t,get:()=>t.checked,set:s=>{t.checked=!!s},focus:()=>t.focus(),setDisabled:s=>{t.disabled=s}}},eu=(i,e)=>{let t=u("select",At(i,e,{required:e.required,disabled:e.disabled}));for(let[s,n]of Dr(e.options))t.append(u("option",{value:s},n));return Ms(t)},tu=(i,e)=>{let t=u("div",{class:"zx-field__option-list",role:"radiogroup"}),s=i.controlId,n=Dr(e.options).map(([r,o],a)=>{let l=u("input",{type:"radio",name:s,value:r,required:!!e.required&&a===0,disabled:e.disabled});return t.append(u("label",{class:"zx-field__option"},l,u("span",{},o))),l});return{el:t,get:()=>n.find(r=>r.checked)?.value??"",set:r=>{for(let o of n)o.checked=String(r??"")===o.value},focus:()=>(n.find(r=>r.checked)??n[0])?.focus(),setDisabled:r=>{for(let o of n)o.disabled=r;t.setAttribute("aria-disabled",String(r))}}},iu=(i,e)=>{let t=u("div",At(i,e,{class:"zx-field__static",name:void 0})),s=null;return{el:t,get:()=>t.textContent,set:r=>{Er(s),s=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(s={node:r,parent:r.parentNode,next:r.nextSibling},t.replaceChildren(r)):t.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{t.setAttribute("aria-disabled",String(r))},destroy:()=>Er(s)}};function Er(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var su=(i,e)=>{if(typeof e.adapter!="function")throw new TypeError("Custom fields require options.adapter");return e.adapter(i,e)};function Dr(i){return Array.isArray(i)?i.map(e=>[String(e),String(e)]):i&&typeof i=="object"?Object.entries(i).map(([e,t])=>[e,String(t)]):[]}C.register("text",ni("input","text"));C.register("password",ni("input","password"));C.register("textarea",ni("textarea","text"));C.register("checkbox",Xc);C.register("int",Mr("int"));C.register("float",Mr("float"));C.register("select",eu);C.register("optionlist",tu);C.register("hidden",ni("input","hidden"));C.register("html",iu);C.register("custom",su);function Ee(i,e,t){let s=Nr(e).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(n=>{let r=nu(n,t).map(Nr);return s.every(o=>r.some(a=>a.includes(o)))})}function nu(i,e){return i===null||typeof i!="object"?[i]:!Array.isArray(e)||e.length===0?[i]:e.map(t=>typeof t=="function"?t(i):i[t])}function Nr(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var ri=class extends S{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,label:null,disabled:!1,hideLabel:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let e=this.el??u("div");this.el=e,this._createdRoot||(this._originalChildren=Array.from(e.childNodes)),this._disabled=!!this.options.disabled;for(let a of["role","aria-label","aria-labelledby","aria-disabled","data-state"])this._originalAttributes.set(a,e.getAttribute(a));let t=this._labelText(this.options.label),s=E("zx-checklist-label"),n=this.options.hideLabel?null:u("div",{ref:"label",class:"zx-checklist__label",id:s},t),r=u("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search,disabled:this._disabled}),o=u("div",{ref:"list",class:"zx-checklist__list"});return o.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,e.replaceChildren(...[n,r,o].filter(Boolean)),e.setAttribute("role","group"),n?e.setAttribute("aria-labelledby",s):e.setAttribute("aria-label",t),this.listen(r,"input",()=>this.search(r.value)),this.listen(o,"change",a=>{let l=a.target;if(!l?.matches?.('input[type="checkbox"][data-index]'))return;let c=this._visibleItems[Number(l.dataset.index)];if(c===void 0)return;let d=this._itemValue(c);l.checked?this._checked.add(d):this._checked.delete(d),this.emit("change",{values:this.getValues()})}),this._replaceItems(this.options.items),this._syncDisabled(),typeof this.options.load=="function"&&queueMicrotask(()=>{this._active&&this.reload().catch(()=>{})}),e}setItems(e){return this._replaceItems(e),this}setLabel(e){let t=this._labelText(e);return this.refs.label?this.refs.label.textContent=t:this.el.setAttribute("aria-label",t),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}isDisabled(){return this._disabled}getValues(){return this._items.map(e=>this._itemValue(e)).filter(e=>this._checked.has(e))}setValues(e){let t=new Set(e==null?[]:Array.from(e)),s=new Set(this._items.map(n=>this._itemValue(n)).filter(n=>t.has(n)));return this._replaceChecked(s),this}checkAll(){return this._replaceChecked(new Set(this._items.map(e=>this._itemValue(e)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(e){this._query=String(e??"");let t=this.refs.search;return t.value!==this._query&&(t.value=this._query),this._visibleItems=Ee(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let e=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let t=await this.options.load();if(e!==this._loadSequence)return this;this._replaceItems(t),this.emit("loaded",{items:this._items.slice()})}finally{e===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let e=this.el;if(!this._createdRoot&&e){e.replaceChildren(...this._originalChildren);for(let[t,s]of this._originalAttributes)s===null?e.removeAttribute(t):e.setAttribute(t,s)}super.destroy()}_replaceItems(e){this._items=Array.isArray(e)?e.slice():[],this._checked=new Set(this._items.filter(t=>!!this._initialChecked(t)).map(t=>this._itemValue(t))),this._visibleItems=Ee(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let e=this._visibleItems.map((t,s)=>{let n=E("zx-checklist-item"),r=u("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(t)),disabled:this._disabled,dataset:{index:s}});return u("label",{class:"zx-checklist__item",for:n},r,u("span",{},this._itemLabel(t)))});e.length===0&&e.push(u("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...e)}_syncDisabled(){this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled"),this.refs.search.disabled=this._disabled;for(let e of this.refs.list.querySelectorAll('input[type="checkbox"]'))e.disabled=this._disabled}_labelText(e){return e==null||e===""?this._message("checklist.label","Checklist"):String(e)}_replaceChecked(e){ru(this._checked,e)||(this._checked=e,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(e){return this._read(e,this.options.valueKey)}_itemLabel(e){return String(this._read(e,this.options.labelKey)??"")}_initialChecked(e){let t;return typeof this.options.checkedKey=="function"?t=this.options.checkedKey(e):e!==null&&typeof e=="object"&&(t=e[this.options.checkedKey]),t??this.options.defaultChecked}_read(e,t){return typeof t=="function"?t(e):e===null||typeof e!="object"?e:e[t]}_message(e,t){let s=this.msg(e);return s===e?t:s}};function ru(i,e){return i.size===e.size&&Array.from(i).every(t=>e.has(t))}function Or(){C.register("checklist",(i,e)=>{let t=i.own(new ri(null,{hideLabel:!0,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.values})}),{el:t.el,get:()=>t.getValues(),set:n=>{s=!0;try{t.setValues(Array.isArray(n)?n:[])}finally{s=!1}},focus:()=>{(t.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??t.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:n=>{n?t.disable():t.enable()}}})}var ou=new Set(["Shift","Control","Alt","Meta","AltGraph","CapsLock","Fn","OS"]),oi=class extends S{static cssName="code-editor";static defaults={value:"",name:"",language:"text",label:null,placeholder:"",rows:12,indent:" ",wrap:"off",spellcheck:!1,readOnly:!1,disabled:!1,status:!0};render(){this._createdRoot=this.el===null;let e=this.el??u("div");this.el=e,this._initialChildren=this._createdRoot?[]:[...e.childNodes],this._initialAttributes=new Map(["data-language","data-readonly","data-disabled"].map(t=>[t,e.getAttribute(t)])),this._language=Rr(this.options.language),this._languageLabel=u("span",{class:"zx-code-editor__language"},this._language),this._position=u("span",{class:"zx-code-editor__position",role:"status",ariaLive:"polite"}),this._header=u("div",{class:"zx-code-editor__header"},this._languageLabel,this.options.status?this._position:null),this._input=u("textarea",{class:"zx-code-editor__input",name:this.options.name?String(this.options.name):void 0,ariaLabel:String(this.options.label??this.msg("codeEditor.label")),placeholder:String(this.options.placeholder??""),rows:uu(this.options.rows),wrap:du(this.options.wrap),spellcheck:!!this.options.spellcheck,readOnly:!!this.options.readOnly,disabled:!!this.options.disabled,autocomplete:"off",autocapitalize:"off"}),this._input.value=String(this.options.value??""),this._committedValue=this._input.value,this._indentEditing=!1,e.dataset.language=this._language,e.dataset.readonly=String(!!this.options.readOnly),e.dataset.disabled=String(!!this.options.disabled),e.replaceChildren(this._header,this._input),this._tabReleased=!1,this.listen(this._input,"keydown",t=>this._handleKeydown(t)),this.listen(this._input,"blur",()=>{this._tabReleased=!1,this._commitValue()}),this.listen(this._input,"input",()=>{this._indentEditing||(this._updatePosition(),this.emit("input",{value:this.getValue()}))}),this.listen(this._input,"change",()=>this._commitValue());for(let t of["click","keyup","select","focus"])this.listen(this._input,t,()=>this._updatePosition());return this._updatePosition(),e}getValue(){return this._input.value}setValue(e,{silent:t=!1}={}){let s=String(e??"");return this._input.value===s?this:(this._input.value=s,this._committedValue=s,this._updatePosition(),t||this.emit("change",{value:s}),this)}setLanguage(e){return this._language=Rr(e),this.el.dataset.language=this._language,this._languageLabel.textContent=this._language,this}focus(){return this._input.focus(),this}enable(){return this._input.disabled=!1,this.el.dataset.disabled="false",this}disable(){return this._input.disabled=!0,this.el.dataset.disabled="true",this}setReadOnly(e){return this._input.readOnly=!!e,this.el.dataset.readonly=String(!!e),this}_handleKeydown(e){if(e.isComposing||ou.has(e.key))return;if(e.key==="Escape"){this._tabReleased=!0;return}let t=this._tabReleased;if(this._tabReleased=!1,t||e.key!=="Tab"||e.altKey||e.ctrlKey||e.metaKey||this._input.readOnly||this._input.disabled)return;let s=String(this.options.indent??" ");if(!s)return;e.preventDefault();let n=au(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0,s,e.shiftKey);if(n.value===this._input.value)return;let r=this._input.value,o=0;for(;o<r.length&&r[o]===n.value[o];)o+=1;let a=0;for(;a<r.length-o&&a<n.value.length-o&&r[r.length-a-1]===n.value[n.value.length-a-1];)a+=1;this._input.setSelectionRange(o,r.length-a),this._indentEditing=!0;try{let l=this._input.ownerDocument,c=n.value.slice(o,n.value.length-a);l?.execCommand?.(c?"insertText":"delete",!1,c)}catch{}finally{this._indentEditing=!1}this._input.value!==n.value&&(this._input.value=n.value),this._input.setSelectionRange(n.start,n.end),this._updatePosition(),this.emit("input",{value:this.getValue()})}_commitValue(){let e=this.getValue();e!==this._committedValue&&(this._committedValue=e,this.emit("change",{value:e}))}_updatePosition(){if(!this.options.status)return;let e=lu(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0);this._position.textContent=e.lines>1?this.msgPlural("codeEditor.selection",e.lines,e.line,e.column,e.lines):this.msg("codeEditor.position",e.line,e.column)}destroy(){if(!this._createdRoot){this.el.replaceChildren(...this._initialChildren);for(let[e,t]of this._initialAttributes)t===null?this.el.removeAttribute(e):this.el.setAttribute(e,t)}super.destroy()}};function au(i,e,t,s=" ",n=!1){let r=String(i??""),o=String(s??""),a=ai(e,r.length),l=ai(t,r.length);if(!o)return{value:r,start:a,end:l};if(a===l&&!n)return{value:r.slice(0,a)+o+r.slice(l),start:a+o.length,end:a+o.length};let c=r.lastIndexOf(`
|
|
1
|
+
var ri=Object.freeze({"accountMenu.fallback":"Account","accountMenu.label":"Account menu","accountMenu.labelFor":"Account menu for %1","activityItem.actions":"Actions for %1","activityItem.attachments":"Attachments","activityItem.failed":"Failed","activityItem.label":"Activity","activityItem.metadata":"Activity metadata","activityItem.pending":"Sending\u2026","activityItem.untitled":"activity","activityList.empty":"No activity yet","activityList.label":"Activity","activityList.loading":"Loading activity","activityList.other":"Other","agent.activity.blocked":"Blocked","agent.activity.idle":"Idle","agent.activity.needsYou":"Needs you","agent.activity.offline":"Offline","agent.activity.thinking":"Thinking","agent.activity.working":"Working","agent.status.done":"Done","agent.status.failed":"Failed","agent.status.paused":"Paused","agent.status.queued":"Not started","agent.status.running":"Running","agent.status.skipped":"Skipped","agent.status.stopped":"Stopped","agent.status.waiting":"Waiting for you","agent.status.blocked":"Blocked","agentThread.agent":"Agent","agentThread.answered":"%1 answered","agentThread.attachments":"Attachments","agentThread.branch":"Branch into a new conversation","agentThread.copy":"Copy answer","agentThread.label":"Conversation","agentThread.latest":"Jump to latest","agentThread.needsApproval":"%1 needs your approval","agentThread.nextVersion":"Next version","agentThread.previousVersion":"Previous version","agentThread.rateDown":"Not helpful","agentThread.rateUp":"Helpful","agentThread.regenerate":"Regenerate answer","agentThread.sources":"Sources","agentThread.stopped":"Stopped","agentThread.stoppedAnnounce":"Stopped","agentThread.version":"Version %1 of %2","agentThread.via":"via %1","agentThread.working":"%1 is working","agentThread.writing":"%1 is writing an answer","agentThread.you":"You","agentThread.writingNow":"%1 is writing\u2026","agentThread.edit":"Edit message","agentThread.copyMessage":"Copy message","agUi.approve":"Run %1?","agUi.asked":"Asked for your answer","agUi.called":"Called %1","agUi.calling":"Calling %1","agUi.runFailed":"The run failed","agUi.runFailedWith":"The run failed: %1","agUi.showTile":"Show in conversation","agUi.thinking":"Thinking","agUi.thought":"Thought for %1","agUi.thoughtComplete":"Thought complete","appRail.subNavigation":"%1 sub-navigation","appSidebar.expand":"Expand application sidebar","appSidebar.itemBadge":"%1 (%2)","appSidebar.label":"Applications","appSidebar.minimize":"Minimize application sidebar","appSidebar.more":"More actions","appSidebar.presentation":"Navigation layout","appSidebar.presentationCollapsed":"Both menus collapsed","appSidebar.presentationCompact":"Module menu collapsed","appSidebar.presentationExpanded":"Both menus expanded","approvalCard.approve":"Approve","approvalCard.approvedBy":"Approved by %1 at %2","approvalCard.approvedByUndated":"Approved by %1","approvalCard.cancel":"Cancel","approvalCard.dateTimeFormat":"%e %b, %H:%M","approvalCard.edit":"Edit","approvalCard.editTitle":"Edit the request","approvalCard.editedBy":"Edited by %1","approvalCard.expiredAt":"Expired at %1","approvalCard.expiredUndated":"Expired without an answer","approvalCard.fullDateTimeFormat":"%e %b %Y, %H:%M","approvalCard.paused":"The run is paused until you answer.","approvalCard.preview":"Preview","approvalCard.reason":"Reason","approvalCard.reasonLabel":"Why not?","approvalCard.reasonMissing":"Say why, so the agent can do better next time.","approvalCard.reasonOptional":"Optional. Your reason stays with the request.","approvalCard.reasonRequired":"Your reason stays with the request.","approvalCard.reject":"Reject","approvalCard.rejectTitle":"Reject the request?","approvalCard.rejectedBy":"Rejected by %1 at %2","approvalCard.rejectedByUndated":"Rejected by %1","approvalCard.required":"Fill this in to save.","approvalCard.save":"Save changes","approvalCard.status.approved":"Approved","approvalCard.status.expired":"Expired","approvalCard.status.pending":"Waiting for you","approvalCard.status.rejected":"Rejected","approvalCard.you":"you","blockView.cite":"Source %1","blockView.citeTitled":"Source %1: %2","blockView.code":"Code","blockView.copyCode":"Copy code","blockView.document":"Document","blockView.stopped":"Stopped here.","blockView.table":"Table","blockView.version":"1 version","blockView.versions":"%1 versions","breadcrumb.label":"Breadcrumb","breadcrumb.more":"Show hidden levels","calendar.agenda":"Agenda","calendar.allDay":"All day","calendar.day":"Day","calendar.dayEvent":"%1, %2 event","calendar.dayEvents":"%1, %2 events","calendar.editCancelled":"Calendar edit cancelled.","calendar.editCommitted":"%1 updated.","calendar.editPreview":"%1, %2 to %3","calendar.eventLabel":"%1, %2 to %3","calendar.label":"Calendar","calendar.loading":"Loading calendar\u2026","calendar.month":"Month","calendar.more":"+%1 more","calendar.moveStarted":"Moving %1. Use arrow keys, Space to drop, or Escape to cancel.","calendar.new":"New","calendar.next":"Next period","calendar.noEvents":"No events","calendar.previous":"Previous period","calendar.resize":"Resize %1","calendar.resizeStarted":"Resizing %1. Use arrow keys, Space to drop, or Escape to cancel.","calendar.today":"Today","calendar.untitled":"Untitled event","calendar.viewSwitch":"Calendar view","calendar.week":"Week","calendar.weekNumber":"Week %1","calendar.year":"Year","card.actions":"Card actions","cardView.groupEmpty":"No records in this group.","cardView.label":"Card view","cardView.sort":"Sort","cardView.sortAscending":"%1 (ascending)","cardView.sortCards":"Sort cards","cardView.sortDescending":"%1 (descending)","cardView.ungrouped":"Ungrouped","cardView.unsorted":"Unsorted","chart.empty":"No chart data","chart.error":"Unable to render chart","chart.label":"Chart","chart.loading":"Loading chart\u2026","chart.series":"Series %1","chart.summary":"Chart data","chart.summaryLabel":"Label","checklist.empty":"No matches","checklist.label":"Checklist","checklist.search":"Search","codeEditor.label":"Code editor","codeEditor.position":"Ln %1, Col %2","codeEditor.selection":"Ln %1, Col %2 \xB7 %3 lines selected","codeEditor.selection.one":"Ln %1, Col %2 \xB7 %3 line selected","codeEditor.selection.other":"Ln %1, Col %2 \xB7 %3 lines selected","composer.attach":"Attach files","composer.attachments":"Attachments","composer.commands":"Commands","composer.commandsPlaceholder":"Search commands","composer.context":"Context","composer.drop":"Drop files to attach","composer.label":"Message","composer.match":"1 suggestion","composer.matches":"%1 suggestions","composer.queue":"Queued (%1)","composer.queued":"Queued; sends when the agent finishes","composer.queueEdit":"Edit","composer.queueFile":"1 file","composer.queueFiles":"%1 files","composer.queueFull":"Queue full (limit %1)","composer.queueRemove":"Remove","composer.queueReplaceConfirm":"Replace","composer.queueReplaceMessage":"The queued message takes its place in the message box.","composer.queueReplaceTitle":"Replace what you have written?","composer.remove":"Remove %1","composer.send":"Send","composer.stop":"Stop","composer.suggestions":"Suggestions","copy.copied":"Copied","copy.copy":"Copy","countryPicker.label":"Country","countryPicker.placeholder":"Choose a country","dataFilter.all":"All","dataFilter.clear":"Clear","datebox.choose":"Choose date","datebox.clear":"Clear date","datebox.placeholder.day":"DD","datebox.placeholder.dayShort":"D","datebox.placeholder.hour":"HH","datebox.placeholder.minute":"MM","datebox.placeholder.month":"MM","datebox.placeholder.second":"SS","datebox.placeholder.year":"YYYY","datebox.placeholder.yearShort":"YY","datebox.required":"Please enter a date.","datePicker.calendar":"Calendar","datePicker.chooseMonthYear":"Choose month and year, %1","datePicker.dayLabel":"%e %B %Y","datePicker.nextMonth":"Next month","datePicker.nextYear":"Next year","datePicker.previousMonth":"Previous month","datePicker.previousYear":"Previous year","datePicker.week":"Week %1","datePicker.weekNumber":"Week number","daterange.choose":"Choose date range","daterange.clear":"Clear date range","daterange.day.end":"range end","daterange.day.middle":"in selected range","daterange.day.start":"range start","daterange.dayLabel":"%A, %e %B %Y","daterange.label":"Date range","daterange.nextMonth":"Next month","daterange.night":"1 night","daterange.nights":"%1 nights","daterange.preset.last30":"Last 30 days","daterange.preset.last7":"Last 7 days","daterange.preset.lastMonth":"Last month","daterange.preset.thisMonth":"This month","daterange.preset.thisQuarter":"This quarter","daterange.preset.thisYear":"This year","daterange.preset.today":"Today","daterange.preset.yesterday":"Yesterday","daterange.presets":"Date range presets","daterange.previousMonth":"Previous month","daterange.span.day":"%e","daterange.span.full":"%e %B %Y","daterange.span.month":"%e %B","daterange.status.empty":"No date range selected","daterange.status.start":"%1 selected, choose an end date","daterange.week":"Week %1","daterange.weekNumber":"Week number","dialog.cancel":"Cancel","dialog.close":"Close","dialog.ok":"OK","dialog.promptValue":"Prompt value","dialog.typeToConfirm":"Type %1 to confirm","dock.resize":"Resize panes","entityRef.actions":"Entity actions","field.float":"Enter a valid number.","field.int":"Enter a whole number.","field.unknown":"Unknown field type: %1","fieldUpload.abort":"Abort","fieldUpload.aborted":"Upload aborted.","fieldUpload.choose":"Choose a file or drop it here","fieldUpload.chooseMany":"Choose files or drop them here","fieldUpload.complete":"Upload complete.","fieldUpload.drop":"Drop a file here or choose a file","fieldUpload.dropMany":"Drop files here or choose files","fieldUpload.hint":"Choose from this device","fieldUpload.httpFailed":"Upload failed with HTTP %1","fieldUpload.maxSize":"up to %1","fieldUpload.preview":"Preview of %1","fieldUpload.progress":"Upload progress","fieldUpload.rejectedSize":"%1 exceeds the maximum file size.","fieldUpload.rejectedType":"%1 is not an accepted file type.","fieldUpload.requestFailed":"Upload request failed","fieldUpload.uploading":"Uploading\u2026","fileItem.actions":"File actions","fileItem.file":"File","fileItem.kind.audio":"Audio","fileItem.kind.calendar":"Calendar","fileItem.kind.contact":"Contact","fileItem.kind.document":"Document","fileItem.kind.email":"Email","fileItem.kind.font":"Font","fileItem.kind.image":"Image","fileItem.kind.presentation":"Presentation","fileItem.kind.spreadsheet":"Spreadsheet","fileItem.kind.text":"Text","fileItem.kind.video":"Video","fileItem.progress":"Progress","fileItem.size":"Size","fileItem.status.error":"Failed","fileItem.status.processing":"Processing","fileItem.status.success":"Complete","fileItem.status.temporary":"Temporary","fileItem.status.uploading":"Uploading","fileItem.status.waiting":"Waiting","fileItem.type":"Type","fileList.empty":"No files","fileList.label":"Files","fileList.loading":"Loading files","filter.addFilter":"Add filter","filter.addGroup":"Add group","filter.addSubgroup":"Add subgroup","filter.and":"and","filter.apply":"Apply filters","filter.booleanFalse":"False","filter.booleanTrue":"True","filter.choose":"Choose\u2026","filter.chooseField":"Choose a field\u2026","filter.chooseOperator":"Choose an operator\u2026","filter.choosePart.field":"Choose field\u2026","filter.choosePart.operator":"Choose operator\u2026","filter.choosePart.value":"Choose value\u2026","filter.clear":"Clear","filter.commaSeparated":"Comma-separated values","filter.conditionNoun":"Filter","filter.conditions":"conditions","filter.emptyGroup":"Nested groups need at least one condition","filter.field":"Filter field","filter.fieldRequired":"Choose a field","filter.fieldUnavailable":"Unavailable field: %1","filter.fieldValue":"%1 value","filter.fieldValueAt":"%1 value %2","filter.filterNoun":"filter","filter.groupLogic":"Group filter logic","filter.groupNoun":"Filter group","filter.inThisGroup":"in this group","filter.matchAll":"Match all","filter.matchAllConditions":"Match all conditions","filter.matchAny":"Match any","filter.matchAnyConditions":"Match any conditions","filter.noValue":"No value","filter.op.after":"is after","filter.op.anyOf":"is any of","filter.op.before":"is before","filter.op.between":"is between","filter.op.contains":"contains","filter.op.containsAll":"contains all","filter.op.containsAny":"contains any","filter.op.containsNone":"contains none","filter.op.endsWith":"ends with","filter.op.eq":"is","filter.op.gt":"is greater than","filter.op.gte":"is at least","filter.op.isEmpty":"is empty","filter.op.isNotEmpty":"is not empty","filter.op.lt":"is less than","filter.op.lte":"is at most","filter.op.neq":"is not","filter.op.noneOf":"is none of","filter.op.notBetween":"is not between","filter.op.notContains":"does not contain","filter.op.notOn":"is not on","filter.op.on":"is on","filter.op.onOrAfter":"is on or after","filter.op.onOrBefore":"is on or before","filter.op.startsWith":"starts with","filter.op.withinLast":"is within the last","filter.op.withinNext":"is within the next","filter.operator":"Filter operator","filter.operatorRequired":"Choose an operator","filter.operatorType":"%1 is not available for %2","filter.operatorUnavailable":"Unavailable operator: %1","filter.or":"or","filter.relativeAmount":"%1: number of units","filter.relativeInvalid":"Enter a whole number of days, weeks or months","filter.relativeUnit":"%1: unit","filter.remove":"Remove %1","filter.removed":"%1 removed","filter.removeGroup":"Remove group","filter.requiresAll":"This filter requires match all conditions.","filter.requiresAny":"This filter requires match any conditions.","filter.rootLogic":"Root filter logic","filter.switchToAll":"%1 \u2014 switch to all","filter.switchToAny":"%1 \u2014 switch to any","filter.unavailable":"Unavailable: %1","filter.unit.days":"days","filter.unit.months":"months","filter.unit.weeks":"weeks","filter.valueMany":"Choose at least one value","filter.valueNone":"This operator does not accept a value","filter.valueOne":"Enter a value","filter.valuePair":"Enter both values","filterPanel.apply":"Apply","filterPanel.clear":"Clear all","filterPanel.empty":"No filters are available here.","filterPanel.from":"From","filterPanel.label":"Filters","filterPanel.rangeFrom":"%1 from","filterPanel.rangeTo":"%1 to","filterPanel.to":"To","filterPanel.unsupported":"Unsupported filter type: %1","finder.loading":"Loading\u2026","finder.noItems":"Empty","finder.root":"Root","form.action":"Action","form.float":"Enter a valid number.","form.int":"Enter a whole number.","form.required":"This field is required.","grid.currency":"Currency","grid.item":"Item","grid.lineTotal":"Line total","grid.quantity":"Quantity","grid.unit":"Unit","grid.unitPrice":"Unit price","kanbanView.add":"Add card","kanbanView.addTo":"Add card to %target%","kanbanView.assigneeOverflow":"+%count%","kanbanView.assignees":"Assigned to %names%","kanbanView.collapseColumn":"Collapse column %label%","kanbanView.collapseLane":"Collapse swim lane %label%","kanbanView.columnEmpty":"Drop a card here","kanbanView.count":"%count% records","kanbanView.count.one":"%count% record","kanbanView.count.other":"%count% records","kanbanView.countFiltered":"%count% of %total% records","kanbanView.countFiltered.one":"%count% of %total% record","kanbanView.countFiltered.other":"%count% of %total% records","kanbanView.countLimit":"%count% records, work-in-progress limit %limit%","kanbanView.countLimit.one":"%count% record, work-in-progress limit %limit%","kanbanView.countLimit.other":"%count% records, work-in-progress limit %limit%","kanbanView.countLimitInLane":"%count% records in this lane, %total% of work-in-progress limit %limit% in the column","kanbanView.countLimitInLane.one":"%count% record in this lane, %total% of work-in-progress limit %limit% in the column","kanbanView.countLimitInLane.other":"%count% records in this lane, %total% of work-in-progress limit %limit% in the column","kanbanView.dragPreview":"%count% cards","kanbanView.dragPreview.one":"%count% card","kanbanView.dragPreview.other":"%count% cards","kanbanView.empty":"No records","kanbanView.expandColumn":"Expand column %label%","kanbanView.expandLane":"Expand swim lane %label%","kanbanView.fields":"Fields","kanbanView.grabbed":"Grabbed %name%. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.","kanbanView.grabbedMultiple":"Grabbed %count% cards. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.","kanbanView.identifier":"Record","kanbanView.label":"Kanban board","kanbanView.limitExceeded":" Work-in-progress limit %limit% exceeded.","kanbanView.limitReached":" Work-in-progress limit %limit% reached.","kanbanView.menuMoveTo":"Move to %target%","kanbanView.menuMoveToLane":"Move to lane %target%","kanbanView.move":"Move %name%","kanbanView.moveCanceled":"Move canceled for %name%.","kanbanView.moveCanceledPlain":"Move canceled.","kanbanView.moved":"Moved %name% to %target%.%wip%","kanbanView.movedMultiple":"Moved %count% cards to %target%.%wip%","kanbanView.moveMultiple":"Move %count% selected cards","kanbanView.moveRequested":"Move requested for %name% to %target%.%wip%","kanbanView.noMatches":"No cards match the current search.","kanbanView.nothingToRedo":"Nothing to redo.","kanbanView.nothingToUndo":"Nothing to undo.","kanbanView.notSelected":"Not selected","kanbanView.priorityLabel":"Priority","kanbanView.progress":"Progress","kanbanView.progressValue":"%percent%%","kanbanView.record":"record","kanbanView.redo":"Redo","kanbanView.redone":"Move redone.","kanbanView.rejectAccept":"Move rejected: %target% does not accept %name%.","kanbanView.rejectDestination":"Move rejected: the destination is not available.","kanbanView.rejectGrouping":"Move rejected: callback grouping requires external move mode.","kanbanView.rejectTransition":"Move rejected: %target% does not accept cards from %origin%.","kanbanView.rejectWip":"Move rejected: %target% is at its work-in-progress limit of %limit%.","kanbanView.search":"Search board","kanbanView.searchPlaceholder":"Search cards","kanbanView.selected":"Selected","kanbanView.statusLabel":"Status","kanbanView.target":"Target %target%, position %position% of %total%.","kanbanView.unassigned":"Unassigned","kanbanView.undo":"Undo","kanbanView.undone":"Move undone.","launcher.back":"Back to %1","launcher.close":"Close launcher","launcher.empty":"No results","launcher.hintBack":"Back","launcher.hintClose":"Close","launcher.hintMove":"Move","launcher.hintOpen":"Open","launcher.label":"Launcher","launcher.loading":"Searching\u2026","launcher.pageEmpty":"%1, no results","launcher.pageLabel":"Search %1","launcher.pagePlaceholder":"Search","launcher.pageResult":"%1, 1 result","launcher.pageResults":"%1, %2 results","launcher.placeholder":"Search applications and records","launcher.results":"Launcher results","listToolbar.label":"List controls","listToolbar.results":"%1 results","listToolbar.results.one":"%1 result","listToolbar.results.other":"%1 results","listToolbar.search":"Search","listToolbar.toolBadge":"%1 (%2)","listToolbar.viewAuto":"Auto","listToolbar.viewBoard":"Board","listToolbar.viewCards":"Cards","listToolbar.viewGallery":"Gallery","listToolbar.viewList":"List","listToolbar.views":"View","listToolbar.viewTable":"Table","localePicker.label":"Language","localePicker.placeholder":"Choose a language","mcp.askedBy":"Asked by %1","mcp.decline":"Decline","mcp.urlAddress":"Full address: %1","mcp.urlHost":"The page is on %1.","mcp.urlInternational":"This address uses an internationalised domain name, which can look like another one. Check the host before you open it.","mcp.urlNote":"It opens in a new tab. Nothing from this application is sent to it.","mcp.urlOpen":"Open page","mcp.urlTitle":"Open a page on another site?","message.close":"Close message","message.closeTitle":"Close","moduleBar.empty":"No modules","moduleBar.filter":"Filter modules","moduleBar.itemBadge":"%1 (%2)","moduleBar.label":"Modules","moduleBar.more":"All modules","monthPicker.chooseMonth":"Choose month","monthPicker.nextYear":"Next year","monthPicker.previousYear":"Previous year","multiValueEditor.add":"Add value","multiValueEditor.moveDown":"Move value %1 down","multiValueEditor.moveUp":"Move value %1 up","multiValueEditor.remove":"Remove value %1","multiValueEditor.reorder":"Reorder value %1. Use the arrow keys to move it.","multiValueEditor.value":"Value %1","navigationBar.actions":"Application actions","navigationBar.more":"More","navigationBar.primary":"Primary navigation","numberField.empty":"Empty","pagination.auto":"Auto","pagination.autoLoad":"Auto-load","pagination.autoSize":"Auto (%1)","pagination.empty":"0 of 0","pagination.label":"Pagination","pagination.loaded":"%1 of %2","pagination.loadMore":"Load more","pagination.next":"Next page","pagination.page":"Page %1","pagination.pageSize":"Rows per page","pagination.previous":"Previous page","pagination.summary":"%1\u2013%2 of %3","panel.actions":"Panel actions","panel.footerActions":"Panel footer actions","permission.private":"Private","permission.public":"Public","priority.high":"High","priority.highest":"Highest","priority.low":"Low","priority.lowest":"Lowest","priority.none":"No priority","priority.normal":"Medium","promptStarters.label":"Suggestions","prose.copied":"Link copied","prose.copyLink":"Copy link","prose.copyLinkTo":"Copy link to %1","questionnaire.counter":"Question %1 of %2","questionnaire.edit":"Edit","questionnaire.empty":"There is nothing to answer.","questionnaire.next":"Continue","questionnaire.noAnswer":"Skipped","questionnaire.other":"Other","questionnaire.previous":"Back","questionnaire.required":"Choose an answer to continue.","questionnaire.requiredInput":"Enter an answer to continue.","questionnaire.review":"Review answers","questionnaire.reviewTitle":"Check your answers","questionnaire.skip":"Skip","questionnaire.submit":"Submit","rating.count":"%1 ratings","rating.count.one":"%1 rating","rating.count.other":"%1 ratings","rating.label":"Rating","rating.value":"%1 of %2","recordCard.actions":"Actions for %1","recordCard.notSelected":"Not selected","recordCard.select":"Select %1","recordCard.selected":"Selected","recordCard.untitled":"record","recordView.fieldMoved":"%1 moved to position %2 of %3","recordView.fields":"Fields","recordView.moveFieldDown":"Move %1 down","recordView.moveFieldUp":"Move %1 up","runStatus.cost":"%1 of %2","runStatus.costLabel":"Cost","runStatus.dateTimeFormat":"%e %b, %H:%M","runStatus.failedAt":"Failed at","runStatus.finished":"Finished","runStatus.model":"Model","runStatus.started":"Started","runStatus.steps":"%1 of %2 steps","runStatus.steps.one":"%1 of %2 step","runStatus.steps.other":"%1 of %2 steps","runStatus.stepsLabel":"Steps done","runStatus.stoppedAt":"Stopped at","runStatus.timeFormat":"%H:%M","runStatus.tokens":"Tokens","runStatus.tokensValue":"%1 in \xB7 %2 out","runStatus.waitingSince":"Waiting since","runStatus.workingTime":"Working time","runStatus.blockedSince":"Blocked since","runStatus.tokenBudget":"%1 of %2 tokens","runTrace.arguments":"Arguments","runTrace.awaiting":"Waiting for the result\u2026","runTrace.call":"1 tool call","runTrace.calls":"%1 tool calls","runTrace.copied":"Copied","runTrace.copyArguments":"Copy arguments","runTrace.copyError":"Copy error","runTrace.copyResult":"Copy result","runTrace.doing":"%1\u2026","runTrace.error":"Error","runTrace.failedAfter":"Failed after %1","runTrace.handoff":"%1 handed over to %2","runTrace.label":"Steps","runTrace.result":"Result","runTrace.retried":"Retried","runTrace.retries":"%1 retries","runTrace.retry":"1 retry","runTrace.showAll":"Show all","runTrace.source":"1 source","runTrace.sources":"%1 sources","runTrace.step":"1 step","runTrace.steps":"%1 steps","runTrace.stoppedAfter":"Stopped after %1","runTrace.worked":"Worked for %1","runTrace.working":"Working\u2026","runTrace.blockedAfter":"Blocked after %1","runTrace.token":"1 token","runTrace.tokens":"%1 tokens","search.clear":"Clear search","search.label":"Search","search.submit":"Submit search","search.submitTitle":"Search","select.clear":"Clear selection","select.create":"Create new\u2026","select.createGroup":"New","select.empty":"No matches","select.label":"Select","select.loading":"Loading","select.none":"No selection","select.recent":"Recent","select.required":"Please select a value.","select.toggle":"Toggle options","sheet.resize":"Resize sheet","slider.value":"Value","sortControl.ascending":"Ascending","sortControl.descending":"Descending","sortControl.label":"Sort by","sourceList.label":"Sources","sourceList.source":"Source","splitView.resize":"Resize panes","statTile.down":"down %1","statTile.loading":"Loading","statTile.unchanged":"no change","statTile.up":"up %1","stepper.completed":"Completed","stepper.counter":"Step %1 of %2","status.backlog":"Backlog","status.canceled":"Canceled","status.done":"Done","status.duplicate":"Duplicate","status.inProgress":"In Progress","status.inReview":"In Review","status.ready":"Ready to Merge","status.todo":"Todo","status.waiting":"Waiting for feedback","stepper.current":"Current step","stepper.error":"Error","stepper.optional":"Optional","tabbox.close":"Close","table.cellInput":"%1 row %2","table.collapseRow":"Collapse %1","table.columnMoved":"Moved %1 to position %2 of %3.","table.columns":"Columns","table.empty":"No records","table.label":"Table","table.expandRow":"Expand %1","table.invalid":"Invalid value","table.more":"Show %1 more","table.moveColumn":"Move %1","table.moveColumnEarlier":"Move %1 earlier","table.moveColumnLater":"Move %1 later","table.moveRow":"Move %1","table.reorderBlocked":"Clear sorting to reorder rows","table.row":"row %1","table.rowDropped":"Row dropped","table.rowGrabbed":"Row grabbed. Use the arrow keys to move it.","table.rowMoved":"Moved row to position %1 of %2.","table.rowOrder":"Row order","table.selectAll":"Select all rows","table.selectRow":"Select %1","tagPicker.create":"Create \u201C%1\u201D","tagPicker.empty":"No matches","tagPicker.input":"Add a value","tagPicker.loading":"Loading\u2026","tagPicker.remove":"Remove %1","tagPicker.toggle":"Toggle options","timebox.duration":"Duration in hours and minutes","timebox.durationWithSeconds":"Duration in hours, minutes, and seconds","timebox.hours":"Hours","timebox.minutes":"Minutes","timebox.seconds":"Seconds","timebox.toggleSign":"Toggle duration sign","timePicker.clock":"Pick the time on a clock","timePicker.hour":"Hour","timePicker.label":"Time","timePicker.minute":"Minute","timePicker.minutes":"Minutes","timePicker.second":"Second","timePicker.selectHour":"Select the hour","timePicker.selectMinutes":"Select the minutes","toolbar.label":"Toolbar","toolbar.more":"More","tree.label":"Tree","tree.more":"More actions","tree.noItems":"Nothing to show","uiMessageStream.approvalTitle":"Run %1?","uiMessageStream.file":"File","uiMessageStream.showTile":"Show %1","uiMessageStream.thinking":"Thinking","uiMessageStream.thought":"Thought for %1","valueList.add":"Add value","valueList.duplicate":"This value already exists.","valueList.instructions":"Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder.","valueList.invalid":"This value is not valid.","valueList.removable":"%1. Press Delete to remove.","valueList.values":"Values","viewSettings.add":"Add","viewSettings.added":"%1 added at position %2 of %3","viewSettings.addField":"Add %1","viewSettings.allShown":"Every field is shown.","viewSettings.board":"Board","viewSettings.canceled":"Move canceled. %1 is back at position %2 of %3","viewSettings.chooseField":"Choose a field","viewSettings.columns":"Columns","viewSettings.dragging":"%1 picked up, position %2 of %3","viewSettings.dropped":"%1 dropped at position %2 of %3","viewSettings.emptyColumns":"Show empty columns","viewSettings.fields":"Fields","viewSettings.grabbed":"%1 picked up, position %2 of %3. Use the arrow keys to move it, Space to drop it, Escape to cancel.","viewSettings.group":"Group by","viewSettings.hidden":"Hidden (%1)","viewSettings.hiddenField":"%1 hidden","viewSettings.hide":"Hide %1","viewSettings.instructions":"Press Space to pick the field up, the arrow keys to move it, Space again to drop it, or Escape to cancel.","viewSettings.label":"View settings","viewSettings.lastField":"At least one field stays shown","viewSettings.locked":"Always shown","viewSettings.moved":"%1 moved to position %2 of %3","viewSettings.noMatch":"No hidden field matches \u201C%1\u201D.","viewSettings.none":"None","viewSettings.reorder":"Reorder %1","viewSettings.search":"Find a field","viewSettings.shown":"Shown (%1)","viewSettings.swimlanes":"Swim lanes","viewSettings.typeBoolean":"Checkbox","viewSettings.typeDate":"Date","viewSettings.typeDatetime":"Date and time","viewSettings.typeEmail":"Email","viewSettings.typeEntity":"Linked record","viewSettings.typeFile":"File","viewSettings.typeImage":"Image","viewSettings.typeMoney":"Money","viewSettings.typeNumber":"Number","viewSettings.typePriority":"Priority","viewSettings.typeRating":"Rating","viewSettings.typeSelect":"Select","viewSettings.typeStatus":"Status","viewSettings.typeTags":"Tags","viewSettings.typeText":"Text","viewSettings.typeTime":"Time","viewSettings.typeUrl":"URL","workspaceSwitcher.heading":"Workspaces","workspaceSwitcher.label":"Switch workspace: %1","workspaceSwitcher.labelEmpty":"Switch workspace","surface.byline":"Composed by %1","surface.submit":"Submit","surface.cancel":"Cancel","surface.confirm":"Confirm","surface.approve":"Approve selected","surface.reject":"Reject","surface.decline":"Decline","surface.fallback":"This part could not be shown","surface.choiceRequired":"Choose an answer to continue.","surface.noAnswer":"No answer","surface.yes":"Yes","surface.no":"No","surface.selected":"Selected","surface.field":"Field","surface.before":"Before","surface.after":"After","surface.dataTable":"Data table","surface.requested":"Information requested","surface.submitted":"Submitted","surface.confirmed":"Confirmed","surface.approved":"Approved","surface.rejected":"Rejected","surface.cancelled":"Cancelled","surface.dismissed":"Dismissed","surface.chose":"Chose \u201C%1\u201D","surface.verdictAt":"%1 at %2","surface.typeToConfirm":"confirm","surface.choose":"Choose\u2026","zeyosForm.saved":"%1 saved successfully.","zeyosLauncher.applications":"Applications","zeyosLauncher.recent":"Recent","zeyosLauncher.results":"Top results","zeyosLauncher.move":"Move","zeyosLauncher.open":"Open","zeyosLauncher.close":"Close","zeyosModuleBar.forks":"Forks","zeyosModuleBar.weblets":"Weblets","zeyosCalendar.untitled":"Untitled appointment","questionnaire.rule.minLength":"Enter at least %1 characters.","questionnaire.rule.minLength.one":"Enter at least %1 character.","questionnaire.rule.minLength.other":"Enter at least %1 characters.","questionnaire.rule.maxLength":"Enter at most %1 characters.","questionnaire.rule.minItems":"Choose at least %1.","questionnaire.rule.maxItems":"Choose at most %1.","questionnaire.rule.minimum":"Enter a number of at least %1.","questionnaire.rule.maximum":"Enter a number of at most %1.","questionnaire.rule.oneOf":"Choose one of the offered answers.","questionnaire.rule.date":"Enter a date as YYYY-MM-DD.","questionnaire.rule.dateTime":"Enter a date and time as YYYY-MM-DDTHH:MM.","questionnaire.rule.time":"Enter a time as HH:MM.","questionnaire.rule.email":"Enter an email address.","questionnaire.rule.uri":"Enter a full address, such as https://example.com.","agentThread.needsAnswer":"%1 needs your answer"}),Rs=Object.freeze({"calendar.agenda":"agenda","calendar.allDay":"allDay","calendar.day":"day","calendar.editCancelled":"editCancelled","calendar.editCommitted":"editCommitted","calendar.editPreview":"editPreview","calendar.label":"calendar","calendar.loading":"loading","calendar.month":"month","calendar.more":"more","calendar.moveStarted":"moveStarted","calendar.new":"new","calendar.next":"next","calendar.noEvents":"noEvents","calendar.previous":"previous","calendar.resize":"resize","calendar.resizeStarted":"resizeStarted","calendar.today":"today","calendar.week":"week","calendar.weekNumber":"weekNumber","calendar.year":"year"});var Dr=null,Nr="en",Or=new Map;function Ls(i){Nr=String(i||"en")}function ne(){return Nr}function we(i){if(!Dr)return null;let e=Dr(i);if(e==null)return null;let t=String(e);return t===i?null:t}function oi(i){return Object.prototype.hasOwnProperty.call(ri,i)?ri[i]:null}function ai(i){return Object.prototype.hasOwnProperty.call(Rs,i)?Rs[i]:null}function V(i,e){let t=ai(i),s=we(i)??(t?we(t):null)??oi(i)??i;return q(s,e)}function ee(i,e=Intl.NumberFormat){for(let t of[i,ne(),"en"])if(t!=null)try{let s=e.supportedLocalesOf(Intl.getCanonicalLocales(t));if(s.length)return Array.isArray(t)?s:s[0]}catch{}return"en"}function Fs(i,e,t){if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("Plural count must be a finite number");let s=ee(t,Intl.PluralRules),n=String(s),r=Or.get(n);r||(r=new Intl.PluralRules(s),Or.set(n,r));let o=r.select(e),a=ai(i);return[...new Set([`${i}.${o}`,`${i}.other`,i,...a?[a]:[]])]}function kt(i,e){for(let t of i){let s=e(t);if(s!==null)return s}return null}function q(i,e){if(e==null)return String(i);let t=Array.isArray(e)?e:typeof e=="object"?null:[e],s=0;return String(i).replace(/%(\d+)|%([A-Za-z_][\w.-]*)%(?!\d)/g,(n,r,o)=>{if(r!==void 0){let a=Number(r)-1,l;return t?l=t[a]:Object.prototype.hasOwnProperty.call(e,r)&&(l=e[r]),l==null?n:String(l)}if(!t&&Object.prototype.hasOwnProperty.call(e,o)){let a=e[o];return a==null?n:String(a)}if(t&&s<t.length){let a=t[s];return s+=1,a==null?n:String(a)}return n})}var wu=0,vu=20,xu=3;var Rr=new Map;function Fe(i,e={}){let t=Vs(i);if(t===null)return"";let{locale:s,decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=e;return Ps(s,js({decimals:n,minDecimals:r,maxDecimals:o,group:a}),t)}function it(i,e,t={}){let s=Vs(i);if(s===null)return"";let{locale:n,decimals:r}=t,o=Au(e);if(o===null)return Fe(s,{locale:n,decimals:r});let a=js({decimals:r,group:!0});return Ps(n,{...a,style:"currency",currency:o},s)}function Fr(i,e={}){let t=Vs(i);if(t===null)return"";let{locale:s,decimals:n=0}=e;return Ps(s,{...js({decimals:n,group:!0}),style:"percent"},t)}function Ps(i,e,t){i=ee(i);let s=`${i}\0${JSON.stringify(e)}`,n=Rr.get(s);return n===void 0&&(n=Su(i,e),Rr.set(s,n)),n.format(t)}function Su(i,e){try{return new Intl.NumberFormat(i,e)}catch{try{return new Intl.NumberFormat(ee(),e)}catch{return new Intl.NumberFormat(ee())}}}function js({decimals:i,minDecimals:e,maxDecimals:t,group:s=!0}){let n={useGrouping:s!==!1},r=Lr(e??i),o=Lr(t??i);return r!==null&&(n.minimumFractionDigits=r),o!==null?(n.maximumFractionDigits=o,r!==null&&r>o&&(n.minimumFractionDigits=o)):r!==null&&(n.maximumFractionDigits=Math.max(r,xu)),n}function Lr(i){if(i==null)return null;let e=Number(i);return Number.isFinite(e)?Math.min(vu,Math.max(wu,Math.round(e))):null}function Vs(i){if(i==null||i==="")return null;let e=typeof i=="number"?i:Number(i);return Number.isFinite(e)?e:null}function Au(i){if(typeof i!="string")return null;let e=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(e)?e:null}function ve(i){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");let e=i.getTime();if(!Number.isFinite(e))throw new RangeError("Invalid Date");return Math.floor(e/1e3)}function Me(i){if(i==null)return null;let e=Number(i);if(!Number.isFinite(e))throw new TypeError("Expected finite Unix seconds");return new Date(e*1e3)}function Bs(i,e){if(i==null||i==="")return null;let t=Number(i);if(!Number.isFinite(t))throw new TypeError("Expected finite Unix seconds");let{year:s,month:n,day:r}=je(e).dayOf(t*1e3);return jr(s,n,r)}function Pe(i,e){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");if(!Number.isFinite(i.getTime()))throw new RangeError("Invalid Date");let t=je(e).midnightOf(i.getFullYear(),i.getMonth(),i.getDate());return Math.floor(t/1e3)}function li(i){if(!(i==null||i===""))try{return new Intl.DateTimeFormat("en-US",{timeZone:String(i)}).resolvedOptions().timeZone}catch{throw new RangeError(`Unknown time zone "${String(i)}"`)}}function je(i){let e=li(i);if(!e)return{timeZone:void 0,dayOf:r=>{let o=new Date(r);return{year:o.getFullYear(),month:o.getMonth(),day:o.getDate()}},midnightOf:(r,o,a)=>jr(r,o,a).getTime()};let t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),s=r=>{let o={};for(let a of t.formatToParts(new Date(r)))o[a.type]=Number(a.value);return{year:o.year,month:o.month-1,day:o.day,seconds:o.hour%24*3600+o.minute*60+o.second}},n=r=>{let o=s(r);return Pr(o.year,o.month,o.day)+o.seconds*1e3-Math.floor(r/1e3)*1e3};return{timeZone:e,dayOf:r=>{let{year:o,month:a,day:l}=s(r);return{year:o,month:a,day:l}},midnightOf:(r,o,a)=>{let l=Pr(r,o,a),c=l-n(l),d=l-n(c),h=null;for(let p of[d,c]){let f=s(p);f.year!==r||f.month!==o||f.day!==a||(!h||f.seconds<h.seconds)&&(h={candidate:p,seconds:f.seconds})}return h?h.candidate:d}}}function jr(i,e,t){let s=new Date(2e3,0,1);return s.setFullYear(i,e,t),s.setHours(0,0,0,0),s}function Pr(i,e,t){let s=new Date(0);return s.setUTCFullYear(i,e,t),s.getTime()}function Vr(i){return(Array.isArray(i)?i:i?[i]:[]).flatMap(t=>{if(!t||typeof t!="object")return[];let s=t.rawField??t.field??t.id;if(s==null||String(s).trim()==="")return[];let n=String(s).trim().replace(/^[+-]/,"");return[`${t.dir==="desc"?"-":"+"}${n}`]})}function ku(i,e=[],t={}){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("DataFilter state must be an object");let s=!!t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"timeZone"),n=s?li(t.timeZone):void 0,r=Cu(i,e),o={},a=0;for(let l of r){if(!l.id||!Object.prototype.hasOwnProperty.call(i,l.id))continue;let c=i[l.id];if(c===void 0||c===null&&l.includeNull!==!0||typeof c=="string"&&c.trim()===""&&l.includeEmpty!==!0)continue;if(typeof l.toFilter=="function"){let f=l.toFilter(c,i);f&&typeof f=="object"&&!Array.isArray(f)&&Object.assign(o,f);continue}let d=typeof l.transform=="function"?l.transform(c,i):zu(c,l,s?{timeZone:n}:null);if(d===void 0)continue;l.operator&&(d={[l.operator]:d});let h=Array.isArray(l.fields)?l.fields.filter(f=>typeof f=="string"&&f):[];if(h.length>1){for(;Object.prototype.hasOwnProperty.call(o,String(a));)a+=1;o[String(a)]=["OR",...h.map(f=>({[f]:d}))],a+=1;continue}let p=h[0]??l.rawField??l.field??l.id;typeof p=="string"&&p&&(o[p]=d)}return o}function Ct(i={}){let{fields:e,sort:t,filters:s={},search:n,limit:r,offset:o,visibility:a=0,count:l=!1}=i;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ZeyOS filters must be an object");let c={};Array.isArray(e)?c.fields=[...e]:e&&typeof e=="object"&&(c.fields={...e});let d={...s},h=Object.prototype.hasOwnProperty.call(i,"visibility");a!==void 0&&(h||!Object.prototype.hasOwnProperty.call(d,"visibility"))&&(d.visibility=a),Object.keys(d).length&&(c.filters=d);let p=Eu(t,e),f=Vr(p);return f.length&&(c.sort=f),n!=null&&String(n).trim()&&(c.query=String(n).trim()),r!=null&&(c.limit=r),o!=null&&(c.offset=o),l&&(c.count=!0),c}function Cu(i,e){return Array.isArray(e)&&e.length?e.map(t=>({...t})):e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length?Object.entries(e).map(([t,s])=>typeof s=="string"?{id:t,field:s}:{...s,id:t}):Object.keys(i).map(t=>({id:t,field:t}))}function zu(i,e,t=null){let s=String(e.format??e.type??"").toLowerCase();if(!["date","datetime","date-time"].includes(s))return i;let n=r=>{if(t&&s==="date"){if(r instanceof Date)return Pe(r,t.timeZone);let o=typeof r=="string"?/^(\d{4})-(\d{2})-(\d{2})$/.exec(r.trim()):null;if(o){let a=je(t.timeZone).midnightOf(Number(o[1]),Number(o[2])-1,Number(o[3]));return Math.floor(a/1e3)}return r}return r instanceof Date?ve(r):r};return Array.isArray(i)?i.map(n):n(i)}function Eu(i,e){if(!i||!e||Array.isArray(e)||typeof e!="object")return i;let t=s=>{if(!s||typeof s!="object")return s;let n=s.id;return!n||!Object.prototype.hasOwnProperty.call(e,n)?s:{...s,rawField:e[n]}};return Array.isArray(i)?i.map(t):t(i)}var di=Object.create(null),Tu=new Set(["date","duedate","birthdate","datefrom","dateto","datecancel","lastbilling"]),Br=new Set(["appointments.datefrom","appointments.dateto","events.datefrom","events.dateto","comments.date","documentversions.date","records.date"]),Mu=Object.freeze({AWAITINGACCEPTANCE:"awaiting acceptance",AWAITINGAPPROVAL:"awaiting approval",BILLINGONLY:"billing only",CUSTOMERANDSUPPLIER:"customer and supplier",FEEDBACKREQUIRED:"feedback required",INEVALUATION:"in evaluation",INNEGOTIATION:"in negotiation",INREVISION:"in revision",NOSTOCK:"no stock",NOTSTARTED:"not started",PARTLYDELIVERED:"partly delivered",PARTLYINVOICED:"partly invoiced",PARTLYORDERED:"partly ordered",PARTLYPAID:"partly paid",PROCUREMENTONLY:"procurement only",REMOTECALL:"remote call",SERIALSANDCHARGES:"serials and charges"}),Iu=Object.freeze({0:"Lowest",1:"Low",2:"Medium",3:"High",4:"Highest"}),Du=/^[A-Z][A-Z\d]*(?:_[A-Z\d]+)*$/,qr=new Set;function Q(i,e){let t=ui(i);if(!t)throw new TypeError("ZeyOS field type must not be empty");if(!e||typeof e!="object")throw new TypeError("Field type strategy must be an object");for(let s of["field","column"]){let n=e[s];if(typeof n!="function"&&(!n||typeof n!="object"||Array.isArray(n)))throw new TypeError(`Field type strategy requires a ${s} builder or descriptor`)}return di[t]=e,e}function qs(i){let e=Yr(i),t=Kr(e),s=Wr(t.field,e),n={id:e.id,type:"text",label:Gr(e),...s};return e.description!=null&&(n.description=String(e.description)),(e.required===!0||e.nullable===!1)&&(n.required=!0),Ku(e)&&(n.readonly=!0,n.disabled=!0,n.props={...n.props??{},readOnly:!0}),n}function $s(i){let e=Yr(i),t=Kr(e);return{id:e.id,label:Gr(e),sortable:e.sortable!==!1,...Wr(t.column,e)}}function zt(i,e,t={}){let s=i?.schema;if(!s||typeof s.fields!="function"||typeof s.describe!="function")throw new TypeError("ZeyOS client must expose schema.fields() and schema.describe()");let n=s.describe(e),r=$r(n?.fields),o=$r(s.fields(e)),a=new Map;for(let[m,g]of o)a.set(m,{...g,...r.get(m)??{}});for(let[m,g]of r)a.has(m)||a.set(m,{...g});let l=Array.isArray(t.fields)?t.fields.map(String):[...a.keys()],c=new Set(Array.isArray(t.exclude)?t.exclude.map(String):[]),d=t.labels&&typeof t.labels=="object"?t.labels:{},h=t.formats&&typeof t.formats=="object"?t.formats:{},p=li(t.timeZone),f=[];for(let m of l){if(c.has(m)||!a.has(m))continue;let g=a.get(m)??{},_={...g,id:m,name:m,resource:String(e)},y=g.enums??g.enum??Wu(s,e,m);y!=null&&(_.enums=y,_.enum==null&&(_.enum=y)),Object.prototype.hasOwnProperty.call(d,m)&&(_.label=String(d[m])),Object.prototype.hasOwnProperty.call(h,m)&&h[m]&&(_.format=String(h[m])),p&&(_.timeZone=p),f.push(_)}return f}var Hr={field:{type:"text"},column:{}},Ou={field:{type:"int"},column:{align:"right"}},Nu={field:{type:"float"},column:i=>({align:"right",render:Xr(i)})},Ru={field:{type:"float"},column:i=>({align:"right",render:Xr(i,!0)})},Lu={field:i=>({type:"zxselect",props:{entity:Zr(i)}}),column:i=>({render:e=>ed(me(e,i),e,i)})},Fu={field:{type:"toggle"},column:i=>({align:"center",render:e=>me(e,i)?"\u2713":"",sortValue:e=>+!!me(e,i)})},Pu={field:i=>({type:Gu(i),options:Hs(i)}),column:i=>({render:Jr(i)})},ju={field:{type:"zxselect",props:{preset:"priority"}},column:i=>({render:Jr(i,Iu)})},Vu={field:{type:"float",props:{min:0,max:100}},column:i=>({align:"right",render:e=>Zu(me(e,i),i.locale),sortValue:e=>Us(me(e,i))})},Bu=Ur("date"),qu=Ur("datetime");for(let i of["string","text","character","character varying","varchar","email","tel","url","uri"])Q(i,Hr);for(let i of["integer","smallint","bigint","int","int2","int4","int8","int32","int64"])Q(i,Ou);for(let i of["number","numeric","decimal","real","double","double precision","float"])Q(i,Nu);for(let i of["money","currency","price","pricebilling","priceprocurement","priceproduction"])Q(i,Ru);for(let i of["entity","t_entity"])Q(i,Lu);for(let i of["boolean","checked"])Q(i,Fu);for(let i of["list","enum"])Q(i,Pu);for(let i of["progress","percent"])Q(i,Vu);for(let i of["date"])Q(i,Bu);for(let i of["datetime","date-time"])Q(i,qu);Q("priority",ju);Q("text[]",{field:{type:"valuelist"},column:{}});Q("json",{field:{type:"textarea"},column:{}});Q("longtext",{field:{type:"textarea"},column:{}});for(let i of["email","tel","url","uri"])Q(i,{field:{type:"text",props:{type:i==="uri"?"url":i}},column:{}});function Ur(i){return{field:{type:i},column:e=>{let t=i==="datetime"?Qu(e.locale):Ju(e.timeZone,e.locale);return{render:s=>t(me(s,e)),sortValue:s=>Xu(me(s,e))}}}}function Kr(i){let e=$u(i),t=di[e];return t||(qr.has(e)||(qr.add(e),console.warn(`[zx.zeyos] Unknown field type or format "${e||"unknown"}" for "${i.id}"; using text.`)),Hr)}function $u(i){let e=ui(i.format??i.semanticFormat??i.semanticType??i.widget);if(e&&di[e])return e;if(Zr(i)||ui(i.type)==="t_entity")return"entity";if(String(i.id).toLowerCase()==="priority")return"priority";if(i.enums!=null||i.enum!=null)return"enum";let t=ui(i.type);if(t==="bigint"||t==="int64"){let s=Hu(i);if(s)return s}return Yu(i,t)?"longtext":t&&di[t]?t:t.endsWith("[]")?"text[]":t==="json"||t==="jsonb"?"json":/^character varying(?:\(\d+\))?$/.test(t)?"character varying":t||e}function Hu(i){let e=String(i.id).toLowerCase(),t=String(i.resource??"").toLowerCase();return Tu.has(e)&&!Br.has(`${t}.${e}`)&&(e!=="date"||i.indexed)?"date":Br.has(`${t}.${e}`)||/(?:date|time)$|^lastmodified$/.test(e)?"datetime":null}function Yr(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Field metadata must be an object");let e=i.id??i.name??i.field??i.identifier??i.reference;if(e==null||String(e).trim()==="")throw new TypeError("Field metadata requires an id or name");return{...i,id:String(e)}}function Wr(i,e){let t=typeof i=="function"?i(e):i;return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}function ui(i){return String(i??"").trim().toLowerCase().replace(/\s+/g," ")}function Gr(i){let e=i.label??i.title??i.displayName;return e==null||e===""?Uu(i.id):String(e)}function Uu(i){let e=String(i??"").split(".").at(-1)??"";if(e==="ID")return"ID";let t=e.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):e}function Ku(i){return i.readonly===!0||i.readOnly===!0||i.writable===!1||i.mutable===!1}function Yu(i,e){if(i.long===!0||i.multiline===!0)return!0;let t=Number(i.maxLength??e.match(/^character varying\((\d+)\)$/)?.[1]);return Number.isFinite(t)&&t>255}function Zr(i){for(let e of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"){let t=e.resource??e.target??e.table??e.entity;if(typeof t=="string"&&t)return t}}return null}function $r(i){let e=new Map;if(Array.isArray(i)){for(let t of i)if(typeof t=="string")e.set(t,{});else if(t&&typeof t=="object"){let s=t.id??t.name??t.field;s!=null&&e.set(String(s),{...t})}}else if(i&&typeof i=="object")for(let[t,s]of Object.entries(i))e.set(t,s&&typeof s=="object"?{...s}:{});return e}function Wu(i,e,t){if(typeof i.enums!="function")return null;let s=i.enums(e,t);return s&&typeof s=="object"&&!Array.isArray(s)&&Object.prototype.hasOwnProperty.call(s,t)?s[t]:s??null}function Hs(i){return Qr(i.enums??i.enum??i.options)}function Qr(i){if(typeof i=="string")try{return Qr(JSON.parse(i))}catch{return{}}return Array.isArray(i)?Object.fromEntries(i.map((e,t)=>{if(Array.isArray(e)){let[s=t,n=s]=e;return[String(s),ci(n)]}if(e&&typeof e=="object"){let s=e.value??e.id??t;return[String(s),e.label!=null?String(e.label):ci(e.name??s)]}return[String(t),ci(e)]})):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,ci(t)])):{}}function ci(i){let e=String(i??"");if(!Du.test(e))return e;let t=e.split("_").map(s=>Mu[s]??s.toLowerCase()).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function Gu(i){return Object.keys(Hs(i)).length<=5?"optionlist":"select"}function Jr(i,e={}){let t={...e,...Hs(i)};return s=>{let n=me(s,i);return n==null?"":t[String(n)]??String(n)}}function Xr(i,e=!1){return t=>e&&i.currency?it(me(t,i),String(i.currency),{locale:i.locale}):Fe(me(t,i),{locale:i.locale})}function Us(i){if(i==null||i==="")return null;let e=Number(i);return Number.isFinite(e)?e:null}function Zu(i,e){let t=Us(i);return t==null?"":`${Fe(t,{locale:e})}%`}function Qu(i){let e=eo(i,{dateStyle:"medium",timeStyle:"short"});return t=>{let s=to(t);return s?e(s):""}}function Ju(i,e){let t=je(i??void 0),s=eo(e,{dateStyle:"medium",timeZone:"UTC"});return n=>{let r=to(n);if(!r)return"";let{year:o,month:a,day:l}=n instanceof Date?{year:r.getFullYear(),month:r.getMonth(),day:r.getDate()}:t.dayOf(r.getTime()),c=new Date(0);return c.setUTCFullYear(o,a,l),s(c)}}function eo(i,e){let t,s;return n=>{let r=ee(i,Intl.DateTimeFormat);return(!s||t!==String(r))&&(t=String(r),s=new Intl.DateTimeFormat(r,e)),s.format(n)}}function to(i){if(i==null||i==="")return null;try{let e=i instanceof Date?i:Me(i);return e&&Number.isFinite(e.getTime())?e:null}catch{return null}}function Xu(i){return i instanceof Date?ve(i):Us(i)}function me(i,e){if(!i||typeof i!="object")return;if(Object.prototype.hasOwnProperty.call(i,e.id))return i[e.id];let t=String(e.path??e.field??e.id).split("."),s=i;for(let n of t){if(!s||typeof s!="object")return;s=s[n]}return s}function ed(i,e,t){if(i&&typeof i=="object"){let n=i.label??i.name??i.title??i.number??i.ID??i.id;return n==null?"":String(n)}let s=t.labelField;if(typeof s=="string"&&e[s]!=null)return String(e[s]);for(let n of[`${t.id}.name`,`${t.id}_label`,`${t.id}Label`])if(e[n]!=null)return String(e[n]);return i==null?"":String(i)}var io=0;function z(i="zx"){return io+=1,`${i}-${Date.now().toString(36)}-${io.toString(36)}`}function st(i,e){let t=Et(i)?so(i):{};if(!Et(e))return hi(e);for(let[s,n]of Object.entries(e)){let r=Object.hasOwn(t,s)?t[s]:void 0;Et(n)&&Et(r)?Ks(t,s,st(r,n)):Ks(t,s,hi(n))}return t}function U(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function Ie(i){if(typeof i!="string")return!1;let e=i.trim();if(!e||e.length>256||/[;{}\u0000-\u001f\u007f]/.test(e)||/(?:url|image|image-set|cross-fade|element|var)\s*\(/i.test(e))return!1;let t=globalThis.CSS?.supports;if(typeof t=="function")try{return t.call(globalThis.CSS,"color",e)}catch{return!1}return/^(?:#[\da-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix)\([^;{}]+\))$/i.test(e)}function Tt(i,e,t){return Math.min(t,Math.max(e,i))}function Ys(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Et(i){if(i===null||typeof i!="object")return!1;let e=Object.getPrototypeOf(i);return e===Object.prototype||e===null}function so(i){let e={};for(let[t,s]of Object.entries(i))Ks(e,t,hi(s));return e}function Ks(i,e,t){Object.defineProperty(i,e,{value:t,enumerable:!0,writable:!0,configurable:!0})}function hi(i){return Et(i)?so(i):Array.isArray(i)?i.map(hi):i}var Mt=null;var td=new Set(["innerhtml","outerhtml","srcdoc"]);function Ve(i){if(typeof i!="string")return null;let e=i.trim();if(!e)return null;try{let t=new URL(e,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(t.toLowerCase()))return null}catch{return null}return e}function u(i,e,...t){let s=e;id(s)||(t.unshift(s),s={});let n=Object.entries(s);for(let[o]of n)if(td.has(o.toLowerCase()))throw new TypeError(`HTML property ${o} requires trusted h.raw() content`);let r=document.createElement(i);for(let[o,a]of n)sd(r,o,a);return rd(r,t),r}u.scope=function(e,t){let s=Mt;Mt=e;try{return t()}finally{Mt=s}};u.raw=function(e){let t=document.createElement("template");return t.innerHTML=String(e),t.content};function $(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,e=>[e.name,e.value])}}function H(i,e){if(!e)return;let t=i,s=typeof t.style?.cssText=="string",n=new Map(e.attributes),r=e.attributes.every(([o])=>i.hasAttribute(o));for(let o of Array.from(i.attributes))(!r||!n.has(o.name))&&(o.name==="style"&&s?fi(t,null):i.removeAttribute(o.name));for(let[o,a]of e.attributes)o==="style"&&s?fi(t,a):i.getAttribute(o)!==a&&i.setAttribute(o,a);i.replaceChildren(...e.children)}function fi(i,e){let t=i.getAttribute("style");t===e||!e&&t===null||(i.style.cssText=e??"",i.getAttribute("style"),e||i.removeAttribute("style"))}function te(i){if(i==null)return null;if(U(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let e=i.toElement();return U(e)?e:null}return null}function id(i){if(i===null||typeof i!="object"||Array.isArray(i))return!1;let e=i;return typeof e.nodeType=="number"?!1:typeof e.toElement!="function"}function sd(i,e,t){if(e.toLowerCase()==="href"){let n=Ve(t);if(n!==null){if("href"in i)try{i.href=n;return}catch{}i.setAttribute("href",n)}return}if(e==="ref"){Mt&&typeof t=="string"&&(Mt[t]=i);return}if(e==="class"){i.className=Array.isArray(t)?t.flat(1/0).filter(Boolean).join(" "):String(t??"");return}if(e==="style"){if(typeof t=="string")i.style.cssText=t;else if(t&&typeof t=="object")for(let[n,r]of Object.entries(t))n.startsWith("--")||n.includes("-")?i.style.setProperty(n,String(r)):i.style[n]=r;return}if(e==="dataset"&&t&&typeof t=="object"){for(let[n,r]of Object.entries(t))r==null?delete i.dataset[n]:i.dataset[n]=String(r);return}if(/^on[a-z]/.test(e)&&typeof t=="function"){i.addEventListener(e.slice(2),t);return}if(t==null)return;let s=nd(e);if(s!==null)i.setAttribute(s,String(t));else if(e in i)try{i[e]=t}catch{i.setAttribute(e,String(t))}else typeof t=="boolean"?t?i.setAttribute(e,""):i.removeAttribute(e):i.setAttribute(e,String(t))}function nd(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function rd(i,e){let t=i;for(let s of e.flat(1/0)){if(s==null)continue;if(typeof s=="string"||typeof s=="number"){t.append(document.createTextNode(String(s)));continue}if(typeof s!="object")continue;let n=s;if(typeof n.nodeType=="number")t.append(s);else if(typeof n.toElement=="function"){let r=n.toElement();r&&t.append(r)}}}var pi=new WeakMap,Ws=new WeakMap,k=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#e=new AbortController;#t=!1;#i=!1;#s=!1;constructor(e,t={}){super();let s=this.constructor;this.#t=e===null;let n=te(e);if(e!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=od(s,t);Ws.set(this,{own:nt(t?.msg)?Object.freeze(st({},t.msg)):null,inherited:ad(s)});let o=[];for(let[c,d]of Object.entries(r))/^on[a-z]/.test(c)&&typeof d=="function"&&(o.push([c.slice(2),d]),delete r[c]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[c,d]of o)this.on(c,d);let a;try{a=u.scope(this.refs,()=>this.render())}catch(c){throw this.#e.abort(),c}if(this.#t){let c=U(a)?a:this.el;if(!U(c))throw this.#e.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=c}if(!U(this.el))throw this.#e.abort(),new TypeError("Component requires a root Element");let l=s.cssName;if(typeof l=="string"&&l){let c=`zx-${l}`;this.#s=!this.el.classList.contains(c),this.el.classList.add(c)}pi.set(this.el,this)}render(){return this.el??null}on(e,t){return this.addEventListener(e,t,{signal:this.#e.signal}),this}off(e,t){return this.removeEventListener(e,t),this}once(e,t){return this.addEventListener(e,t,{once:!0,signal:this.#e.signal}),this}addEvent(e,t){return this.on(e,t)}emit(e,t={},s={}){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("Event detail must be an object");let n=no(e,t,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=no(`zx-${e}`,t,{bubbles:!0,composed:!0,cancelable:!0});this.el.dispatchEvent(r),s.honorDomCancellation&&r.defaultPrevented&&n.preventDefault()}return n}listen(e,t,s,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return e.addEventListener(t,s,{...r,signal:this.#e.signal}),this}toElement(){return this.el}msg(e,...t){let s=this.options?.lang??this.options?.language??ne(),n=ai(e),r=Ws.get(this)??{own:nt(this.options?.msg)?this.options.msg:null,inherited:null},o=r.own,a=It(o,s,e)??(n?It(o,s,n):null)??we(e)??(n?we(n):null)??It(r.inherited,s,e)??oi(e)??e;return q(a,t)}msgPlural(e,t,...s){let n=this.options?.lang??this.options?.language??ne(),r=Fs(e,t,n),o=Ws.get(this)??{own:nt(this.options?.msg)?this.options.msg:null,inherited:null},a=kt(r,l=>It(o.own,n,l))??kt(r,we)??kt(r,l=>It(o.inherited,n,l))??kt(Fs(e,t,"en"),oi)??e;return q(a,s)}destroy(){if(this.#i)return;this.#i=!0,this.#e.abort(),pi.get(this.el)===this&&pi.delete(this.el);let e=this.constructor.cssName;this.#s&&typeof e=="string"&&this.el&&this.el.classList.remove(`zx-${e}`),this.#t&&this.el&&this.el.remove()}static from(e){return pi.get(e)??null}};function od(i,e){let t=oo(i),s={},n={},r=!1;for(let o of t)!o||typeof o!="object"||(Object.assign(s,o),o.msg&&typeof o.msg=="object"&&(r=!0,n=st(n,o.msg)));if(e&&typeof e=="object"){let o=Object.assign({},e),a=s;for(let l of Reflect.ownKeys(o))o[l]!==void 0&&(a[l]=o[l])}return e?.msg&&typeof e.msg=="object"&&(r=!0,n=st(n,ro(e.msg))),r&&(s.msg=n),s}function ro(i){if(!nt(i))return i;let e={};for(let[t,s]of Object.entries(i))s!==void 0&&(e[t]=nt(s)?ro(s):s);return e}function oo(i){let e=[],t=i;for(;t&&t!==Function.prototype;)Object.prototype.hasOwnProperty.call(t,"defaults")&&e.unshift(t.defaults),t=Object.getPrototypeOf(t);return e}function nt(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function ad(i){let e=null;for(let t of oo(i))t&&typeof t=="object"&&nt(t.msg)&&(e=st(e??{},t.msg));return e?Object.freeze(e):null}function It(i,e,t){if(!i)return null;let s=i[e]?.[t];if(s!=null&&typeof s!="object")return String(s);let n=Object.prototype.hasOwnProperty.call(i,t)?i[t]:null;return n!=null&&typeof n!="object"?String(n):null}function no(i,e,t){if(typeof CustomEvent=="function")return new CustomEvent(i,{...t,detail:e});let s=new Event(i,t);return Object.defineProperty(s,"detail",{configurable:!0,enumerable:!0,value:e}),s}var E=class i extends k{static cssName="field";static defaults={id:null,name:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,readonly:!1,options:null,layout:"stack",props:{},msg:{"field.int":"Enter a whole number.","field.float":"Enter a valid number.","field.unknown":"Unknown field type: %1"}};static#e=new Map;static register(e,t){let s=String(e).trim().toLowerCase();if(!s)throw new TypeError("Field adapter type must not be empty");if(typeof t!="function")throw new TypeError("Field adapter must be a function");return i.#e.set(s,t),this}static has(e){return i.#e.has(String(e).trim().toLowerCase())}render(){let e=this.el??u("div");this.el=e;let t=String(this.options.type||"text").toLowerCase(),s=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=dd(e,["data-layout","data-field-type","data-disabled","data-readonly","data-state"]),e.dataset.layout=s,e.dataset.fieldType=t,this.controlId=this.options.id?String(this.options.id):z("zx-field"),this.name=String(this.options.name??this.options.id??"");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=u("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?u("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),l=u("div",{class:"zx-field__control"}),c=u("div",{class:"zx-field__description",id:r},String(this.options.description??"")),d=u("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),h=u("div",{class:"zx-field__body"},l,c,d);this._ownedNodes.push(a,h),e.append(a,h);let p=i.#e.get(t);if(p)try{this.adapter=cd(p(this,this.options))}catch(g){let _=g instanceof Error?g.message:String(g);console.warn(`[zx.Field] Adapter "${t}" failed: ${_}`),this.adapter=lo(_,this.controlId)}else{let g=this.msg("field.unknown",t);console.warn(`[zx.Field] ${g}`),this.adapter=lo(g,this.controlId)}let f=this.adapter.el;f.id||(f.id=this.controlId);let m=this.adapter.labelTarget??(Dt(f)?f:ud(f))??f;return this._labelled=m,m!==f&&Dt(m)&&!m.id&&(m.id=`${this.controlId}-input`),a.htmlFor=Dt(m)?m.id:f.id,(!Dt(m)||m!==f||m.hasAttribute("aria-label"))&&m.setAttribute("aria-labelledby",n),Dt(m)||this.listen(a,"click",g=>{g.defaultPrevented||(g.preventDefault(),this.adapter.focus())}),this._baseDescribedBy=m.getAttribute("aria-describedby")??"",l.append(f),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=d,this._syncDescription(),this.initialValue=ld(t,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.options.readonly&&this.setReadonly(!0),this.listen(f,"change",()=>{this.emit("change",{value:this.getValue()})}),e}getValue(){return this.adapter.get()}setValue(e,{silent:t=!1}={}){return this.adapter.set(e,{silent:t}),t||this.emit("change",{value:this.getValue()}),this}focus(){return this.adapter.focus(),this}reset(){return this.setValue(this.initialValue,{silent:!0}),this.clearHighlight(),this}setDisabled(e){let t=!!e;return this.adapter.setDisabled(t),this.el.dataset.disabled=String(t),this}setReadonly(e){let t=!!e;return this.adapter.setReadonly?.(t),this.el.dataset.readonly=String(t),this}setHighlight(e,t="danger"){if(!e)return this.clearHighlight();let s=["danger","warning","success"].includes(t)?t:"danger";return this.el.dataset.state=s,this._highlight.textContent=String(e??""),this._highlight.hidden=!e,s==="danger"&&e?(this._highlight.setAttribute("role","alert"),this._labelled.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(e)})):(this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid")),this._syncDescription(!!e),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(e){if(!(e instanceof k))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(e),e}_syncDescription(e=!1){let t=[this._baseDescribedBy,this._descriptionId,e?this._highlightId:""].flatMap(s=>s.split(/\s+/)).filter(Boolean);t.length?this._labelled.setAttribute("aria-describedby",[...new Set(t)].join(" ")):this._labelled.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let e of this._ownedComponents??[])e.destroy();this._ownedComponents?.clear();for(let e of this._ownedNodes??[])e.remove();hd(this.el,this._rootAttributes??new Map),super.destroy()}};function Gs(i){if(typeof i=="number")return Number.isInteger(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let e=String(i??"").trim();if(e==="")return{valid:!0,value:""};let t=uo(e);return t!==null&&Number.isInteger(t)?{valid:!0,value:t}:{valid:!1,value:e}}function Zs(i){if(typeof i=="number")return Number.isFinite(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let e=String(i??"").trim();if(e==="")return{valid:!0,value:""};let t=uo(e);return t!==null?{valid:!0,value:t}:{valid:!1,value:e}}function uo(i){let e=i.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(e))return null;let t=/^[+-]/.test(e)?e[0]:"",s=t?e.slice(1):e;if(!/\d/.test(s))return null;let n=[...s.matchAll(/\./g)].map(l=>l.index),r=[...s.matchAll(/,/g)].map(l=>l.index),o;if(n.length&&r.length){let l=n.at(-1)>r.at(-1)?".":",",c=l==="."?",":".",d=s.lastIndexOf(l),h=s.slice(0,d),p=s.slice(d+1);if(!/^\d+$/.test(p)||!ao(h,c))return null;o=h.split(c).join("")+"."+p}else if(r.length>1||n.length>1){let l=r.length?",":".";if(!ao(s,l))return null;o=s.split(l).join("")}else r.length===1?o=s.replace(",","."):o=s;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let a=Number(t+o);return Number.isFinite(a)?a:null}function ao(i,e){let t=i.split(e);return t.length>0&&/^\d{1,3}$/.test(t[0])&&t.slice(1).every(s=>/^\d{3}$/.test(s))}function ld(i,e){return e!==void 0?e:i==="checkbox"?!1:""}function cd(i){if(!i||typeof i!="object")throw new TypeError("Adapter must return an object");if(!(i.el&&i.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let e of["get","set","focus","setDisabled"])if(typeof i[e]!="function")throw new TypeError(`Adapter is missing ${e}()`);return i}function lo(i,e){let t=u("div",{class:"zx-field__error-control",id:e,role:"alert",tabIndex:-1},i);return{el:t,get:()=>null,set:()=>{},focus:()=>t.focus(),setDisabled:()=>{}}}function Dt(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function ud(i){for(let e of i.querySelectorAll('input:not([type="hidden"]), select, textarea'))if(!(e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby")||[...e.labels??[]].some(s=>s.textContent?.trim())))return e;return null}function dd(i,e){return new Map(e.map(t=>[t,i.getAttribute(t)]))}function hd(i,e){for(let[t,s]of e)s===null?i.removeAttribute(t):i.setAttribute(t,s)}function Ot(i,e,t){let s={...e.props??{}};for(let n of Object.keys(s))(/^on[a-z]/i.test(n)||n==="content")&&delete s[n];return{name:i.name||void 0,...s,...t}}function mi(i,e){return(t,s)=>{let n=u(i,Ot(t,s,{type:i==="input"?e:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return{...Qs(n),setReadonly:r=>{n.readOnly=r}}}}function Qs(i){return{el:i,get:()=>i.value,set:e=>{i.value=e==null?"":String(e)},focus:()=>i.focus(),setDisabled:e=>{i.disabled=e}}}function ho(i){return(e,t)=>{let s=i==="int"?Gs:Zs,n=u("input",Ot(e,t,{type:"text",inputMode:i==="int"?"numeric":"decimal",placeholder:t.placeholder,required:t.required,disabled:t.disabled}));return e.listen(n,"blur",()=>{let r=s(n.value);if(!r.valid){e.setHighlight(e.msg(`field.${i}`),"danger");return}r.value!==""&&(n.value=String(r.value)),e.clearHighlight()}),{...Qs(n),get:()=>s(n.value).value,setReadonly:r=>{n.readOnly=r}}}}var fd=(i,e)=>{let t=u("input",Ot(i,e,{type:"checkbox",required:e.required,disabled:e.disabled}));return{el:t,get:()=>t.checked,set:s=>{t.checked=!!s},focus:()=>t.focus(),setDisabled:s=>{t.disabled=s}}},pd=(i,e)=>{let t=u("select",Ot(i,e,{required:e.required,disabled:e.disabled}));for(let[s,n]of fo(e.options))t.append(u("option",{value:s},n));return Qs(t)},md=(i,e)=>{let t=u("div",{class:"zx-field__option-list",role:"radiogroup"}),s=i.controlId,n=fo(e.options).map(([r,o],a)=>{let l=u("input",{type:"radio",name:s,value:r,required:!!e.required&&a===0,disabled:e.disabled});return t.append(u("label",{class:"zx-field__option"},l,u("span",{},o))),l});return{el:t,get:()=>n.find(r=>r.checked)?.value??"",set:r=>{for(let o of n)o.checked=String(r??"")===o.value},focus:()=>(n.find(r=>r.checked)??n[0])?.focus(),setDisabled:r=>{for(let o of n)o.disabled=r;t.setAttribute("aria-disabled",String(r))}}},gd=(i,e)=>{let t=u("div",Ot(i,e,{class:"zx-field__static",name:void 0})),s=null;return{el:t,get:()=>t.textContent,set:r=>{co(s),s=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(s={node:r,parent:r.parentNode,next:r.nextSibling},t.replaceChildren(r)):t.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{t.setAttribute("aria-disabled",String(r))},destroy:()=>co(s)}};function co(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var _d=(i,e)=>{if(typeof e.adapter!="function")throw new TypeError("Custom fields require options.adapter");return e.adapter(i,e)};function fo(i){return Array.isArray(i)?i.map(e=>[String(e),String(e)]):i&&typeof i=="object"?Object.entries(i).map(([e,t])=>[e,String(t)]):[]}E.register("text",mi("input","text"));E.register("password",mi("input","password"));E.register("textarea",mi("textarea","text"));E.register("checkbox",fd);E.register("int",ho("int"));E.register("float",ho("float"));E.register("select",pd);E.register("optionlist",md);E.register("hidden",mi("input","hidden"));E.register("html",gd);E.register("custom",_d);function xe(i,e,t){let s=po(e).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(n=>{let r=bd(n,t).map(po);return s.every(o=>r.some(a=>a.includes(o)))})}function bd(i,e){return i===null||typeof i!="object"?[i]:!Array.isArray(e)||e.length===0?[i]:e.map(t=>typeof t=="function"?t(i):i[t])}function po(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var gi=class extends k{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,label:null,disabled:!1,hideLabel:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._pending=null,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let e=this.el??u("div");this.el=e,this._createdRoot||(this._originalChildren=Array.from(e.childNodes)),this._disabled=!!this.options.disabled;for(let a of["role","aria-label","aria-labelledby","aria-disabled","data-state"])this._originalAttributes.set(a,e.getAttribute(a));let t=this._labelText(this.options.label),s=z("zx-checklist-label"),n=this.options.hideLabel?null:u("div",{ref:"label",class:"zx-checklist__label",id:s},t),r=u("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search,disabled:this._disabled}),o=u("div",{ref:"list",class:"zx-checklist__list"});return o.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,e.replaceChildren(...[n,r,o].filter(Boolean)),e.setAttribute("role","group"),n?e.setAttribute("aria-labelledby",s):e.setAttribute("aria-label",t),this.listen(r,"input",()=>this.search(r.value)),this.listen(o,"change",a=>{let l=a.target;if(!l?.matches?.('input[type="checkbox"][data-index]'))return;let c=this._visibleItems[Number(l.dataset.index)];if(c===void 0)return;let d=this._itemValue(c);l.checked?this._checked.add(d):this._checked.delete(d),this.emit("change",{values:this.getValues()})}),this._replaceItems(this.options.items),this._syncDisabled(),typeof this.options.load=="function"&&queueMicrotask(()=>{this._active&&this.reload().catch(()=>{})}),e}setItems(e){return this._replaceItems(e),this}setLabel(e){let t=this._labelText(e);return this.refs.label?this.refs.label.textContent=t:this.el.setAttribute("aria-label",t),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}isDisabled(){return this._disabled}getValues(){let e=this._items.map(t=>this._itemValue(t)).filter(t=>this._checked.has(t));return this._pending?[...e,...this._pending]:e}setValues(e){let t=new Set(e==null?[]:Array.from(e)),s=new Set(this._items.map(o=>this._itemValue(o))),n=new Set([...s].filter(o=>t.has(o))),r=[...t].filter(o=>!s.has(o));return this._replaceChecked(n,r.length||this._items.length===0?r:null),this}checkAll(){return this._replaceChecked(new Set(this._items.map(e=>this._itemValue(e))),null),this}uncheckAll(){return this._replaceChecked(new Set,null),this}search(e){this._query=String(e??"");let t=this.refs.search;return t.value!==this._query&&(t.value=this._query),this._visibleItems=xe(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let e=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let t=await this.options.load();if(e!==this._loadSequence)return this;this._replaceItems(t),this.emit("loaded",{items:this._items.slice()})}finally{e===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let e=this.el;if(!this._createdRoot&&e){e.replaceChildren(...this._originalChildren);for(let[t,s]of this._originalAttributes)s===null?e.removeAttribute(t):e.setAttribute(t,s)}super.destroy()}_replaceItems(e){if(this._items=Array.isArray(e)?e.slice():[],this._pending!==null){let t=new Set([...this._checked,...this._pending]),s=new Set(this._items.map(r=>this._itemValue(r)));this._checked=new Set([...s].filter(r=>t.has(r)));let n=this._pending.filter(r=>!s.has(r));this._pending=n.length?n:null}else this._checked=new Set(this._items.filter(t=>!!this._initialChecked(t)).map(t=>this._itemValue(t)));this._visibleItems=xe(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let e=this._visibleItems.map((t,s)=>{let n=z("zx-checklist-item"),r=u("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(t)),disabled:this._disabled,dataset:{index:s}});return u("label",{class:"zx-checklist__item",for:n},r,u("span",{},this._itemLabel(t)))});e.length===0&&e.push(u("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...e)}_syncDisabled(){this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled"),this.refs.search.disabled=this._disabled;for(let e of this.refs.list.querySelectorAll('input[type="checkbox"]'))e.disabled=this._disabled}_labelText(e){return e==null||e===""?this._message("checklist.label","Checklist"):String(e)}_replaceChecked(e,t){let s=t,n=!mo(new Set(this._pending??[]),new Set(s??[])),r=mo(this._checked,e)&&!n;this._pending=s,!r&&(this._checked=e,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(e){return this._read(e,this.options.valueKey)}_itemLabel(e){return String(this._read(e,this.options.labelKey)??"")}_initialChecked(e){let t;return typeof this.options.checkedKey=="function"?t=this.options.checkedKey(e):e!==null&&typeof e=="object"&&(t=e[this.options.checkedKey]),t??this.options.defaultChecked}_read(e,t){return typeof t=="function"?t(e):e===null||typeof e!="object"?e:e[t]}_message(e,t){let s=this.msg(e);return s===e?t:s}};function mo(i,e){return i.size===e.size&&Array.from(i).every(t=>e.has(t))}function go(){E.register("checklist",(i,e)=>{let t=i.own(new gi(null,{hideLabel:!0,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.values})}),{el:t.el,get:()=>t.getValues(),set:n=>{s=!0;try{Array.isArray(n)?t.setValues(n):t.uncheckAll()}finally{s=!1}},focus:()=>{(t.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??t.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:n=>{n?t.disable():t.enable()}}})}var yd=new Set(["Shift","Control","Alt","Meta","AltGraph","CapsLock","Fn","OS"]),_i=class extends k{static cssName="code-editor";static defaults={value:"",name:"",language:"text",label:null,placeholder:"",rows:12,indent:" ",wrap:"off",spellcheck:!1,readOnly:!1,disabled:!1,status:!0};render(){this._createdRoot=this.el===null;let e=this.el??u("div");this.el=e,this._initialChildren=this._createdRoot?[]:[...e.childNodes],this._initialAttributes=new Map(["data-language","data-readonly","data-disabled","data-state"].map(t=>[t,e.getAttribute(t)])),this._language=_o(this.options.language),this._languageLabel=u("span",{class:"zx-code-editor__language"},this._language),this._position=u("span",{class:"zx-code-editor__position"}),this._header=u("div",{class:"zx-code-editor__header"},this._languageLabel,this.options.status?this._position:null),this._input=u("textarea",{class:"zx-code-editor__input",name:this.options.name?String(this.options.name):void 0,ariaLabel:String(this.options.label??this.msg("codeEditor.label")),placeholder:String(this.options.placeholder??""),rows:Sd(this.options.rows),wrap:Ad(this.options.wrap),spellcheck:!!this.options.spellcheck,readOnly:!!this.options.readOnly,disabled:!!this.options.disabled,autocomplete:"off",autocapitalize:"off"}),this._highlight=u("div",{class:"zx-code-editor__highlight",id:z("zx-code-editor-highlight"),ariaLive:"polite",hidden:!0}),this._input.value=String(this.options.value??""),this._committedValue=this._input.value,this._indentEditing=!1,e.dataset.language=this._language,e.dataset.readonly=String(!!this.options.readOnly),e.dataset.disabled=String(!!this.options.disabled),e.replaceChildren(this._header,this._input,this._highlight),this._tabReleased=!1,this.listen(this._input,"keydown",t=>this._handleKeydown(t)),this.listen(this._input,"blur",()=>{this._tabReleased=!1,this._commitValue()}),this.listen(this._input,"input",()=>{this._indentEditing||(this._updatePosition(),this.emit("input",{value:this.getValue()}))}),this.listen(this._input,"change",()=>this._commitValue());for(let t of["click","keyup","select","focus"])this.listen(this._input,t,()=>this._updatePosition());return this._updatePosition(),e}getValue(){return this._input.value}setValue(e,{silent:t=!1}={}){let s=String(e??"");return this._input.value===s?this:(this._input.value=s,this._committedValue=s,this._updatePosition(),t||this.emit("change",{value:s}),this)}setLanguage(e){return this._language=_o(e),this.el.dataset.language=this._language,this._languageLabel.textContent=this._language,this}getInput(){return this._input}setHighlight(e,t="danger"){if(!e)return this.clearHighlight();let s=["danger","warning","success"].includes(t)?t:"danger";return this.el.dataset.state=s,this._highlight.textContent=String(e),this._highlight.hidden=!1,this._describe(!0),s==="danger"?(this._highlight.setAttribute("role","alert"),this._input.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(e)})):(this._highlight.removeAttribute("role"),this._input.removeAttribute("aria-invalid")),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this._input.removeAttribute("aria-invalid"),this._describe(!1),this}focus(){return this._input.focus(),this}enable(){return this._input.disabled=!1,this.el.dataset.disabled="false",this}disable(){return this._input.disabled=!0,this.el.dataset.disabled="true",this}setReadOnly(e){return this._input.readOnly=!!e,this.el.dataset.readonly=String(!!e),this}_handleKeydown(e){if(e.isComposing||yd.has(e.key))return;if(e.key==="Escape"){this._tabReleased=!0;return}let t=this._tabReleased;if(this._tabReleased=!1,t||e.key!=="Tab"||e.altKey||e.ctrlKey||e.metaKey||this._input.readOnly||this._input.disabled)return;let s=String(this.options.indent??" ");if(!s)return;e.preventDefault();let n=wd(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0,s,e.shiftKey);if(n.value===this._input.value)return;let r=this._input.value,o=0;for(;o<r.length&&r[o]===n.value[o];)o+=1;let a=0;for(;a<r.length-o&&a<n.value.length-o&&r[r.length-a-1]===n.value[n.value.length-a-1];)a+=1;this._input.setSelectionRange(o,r.length-a),this._indentEditing=!0;try{let l=this._input.ownerDocument,c=n.value.slice(o,n.value.length-a);l?.execCommand?.(c?"insertText":"delete",!1,c)}catch{}finally{this._indentEditing=!1}this._input.value!==n.value&&(this._input.value=n.value),this._input.setSelectionRange(n.start,n.end),this._updatePosition(),this.emit("input",{value:this.getValue()})}_describe(e){let t=this._highlight.id,s=(this._input.getAttribute("aria-describedby")??"").split(/\s+/).filter(n=>n&&n!==t);e&&s.push(t),s.length?this._input.setAttribute("aria-describedby",s.join(" ")):this._input.removeAttribute("aria-describedby")}_commitValue(){let e=this.getValue();e!==this._committedValue&&(this._committedValue=e,this.emit("change",{value:e}))}_updatePosition(){if(!this.options.status)return;let e=vd(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0);this._position.textContent=e.lines>1?this.msgPlural("codeEditor.selection",e.lines,e.line,e.column,e.lines):this.msg("codeEditor.position",e.line,e.column)}destroy(){if(!this._createdRoot){this.el.replaceChildren(...this._initialChildren);for(let[e,t]of this._initialAttributes)t===null?this.el.removeAttribute(e):this.el.setAttribute(e,t)}super.destroy()}};function wd(i,e,t,s=" ",n=!1){let r=String(i??""),o=String(s??""),a=bi(e,r.length),l=bi(t,r.length);if(!o)return{value:r,start:a,end:l};if(a===l&&!n)return{value:r.slice(0,a)+o+r.slice(l),start:a+o.length,end:a+o.length};let c=r.lastIndexOf(`
|
|
2
2
|
`,Math.max(0,a-1))+1,d=r.indexOf(`
|
|
3
3
|
`,l);d<0&&(d=r.length);let p=r.slice(c,d).split(`
|
|
4
|
-
`),f=0,m=0,g=p.map((b
|
|
5
|
-
`),_=n?Math.max(c,a-Math.min(f,a-c)):a+o.length;return{value:r.slice(0,c)+g+r.slice(d),start:_,end:Math.max(_,l+m)}}function
|
|
4
|
+
`),f=0,m=0,g=p.map((y,b)=>{if(!n)return m+=o.length,o+y;let w=xd(y,o);return b===0&&(f=w),m-=w,y.slice(w)}).join(`
|
|
5
|
+
`),_=n?Math.max(c,a-Math.min(f,a-c)):a+o.length;return{value:r.slice(0,c)+g+r.slice(d),start:_,end:Math.max(_,l+m)}}function vd(i,e,t=e){let s=String(i??""),n=bi(e,s.length),r=bi(t,s.length),o=s.slice(0,n);return{line:o.split(`
|
|
6
6
|
`).length,column:n-o.lastIndexOf(`
|
|
7
7
|
`),lines:s.slice(n,r).split(`
|
|
8
|
-
`).length}}function cu(i,e){return i.startsWith(e)?e.length:e===" "?i.startsWith(" ")?1:Math.min(/^ +/.exec(i)?.[0].length??0,2):Math.min(/^\s+/.exec(i)?.[0].length??0,e.length)}function Rr(i){let e=String(i??"text").trim().toLowerCase();return/^[a-z0-9][a-z0-9+_.-]*$/.test(e)?e:"text"}function uu(i){let e=Number(i);return Number.isFinite(e)?Math.max(2,Math.min(100,Math.round(e))):12}function du(i){return["off","soft","hard"].includes(String(i))?i:"off"}function ai(i,e){let t=Number(i);return Math.max(0,Math.min(e,Number.isFinite(t)?Math.round(t):0))}function Lr(){C.register("code",(i,e)=>{let t=i.own(new oi(null,{label:e.label?String(e.label):null,placeholder:e.placeholder,readOnly:!!e.props?.readOnly,disabled:!!e.disabled,...e.props??{},value:e.value})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),t.on("input",n=>i.emit("input",{value:n.detail.value})),{el:t.el,get:()=>t.getValue(),set:n=>{s=!0;try{t.setValue(n,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadOnly(n)}}})}var hu=["January","February","March","April","May","June","July","August","September","October","November","December"],fu=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Br={month:hu,weekday:fu},qr=/%[demYyHMSaAbBs]/g,Fr=new Map;function M(i,e,t){let s=K(t?.locale,Intl.DateTimeFormat),n=t?.locale==null;return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(e).replace(qr,r=>{switch(r){case"%d":return Ge(i.getDate());case"%e":return String(i.getDate());case"%m":return Ge(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return Ge(i.getFullYear()%100);case"%H":return Ge(i.getHours());case"%M":return Ge(i.getMinutes());case"%S":return Ge(i.getSeconds());case"%a":return Vr("weekday",i,s,n);case"%A":return Pr("weekday",i,s,n);case"%b":return Vr("month",i,s,n);case"%B":return Pr("month",i,s,n);case"%s":return String(Math.floor(i.getTime()/1e3));default:return r}})}function pe(i,e){let t=[],s="^",n=0;for(let m of String(e).matchAll(qr)){s+=jr(String(e).slice(n,m.index));let g=m[0],_=pu(g);if(_===null)return null;s+=`(${_})`,t.push(g),n=m.index+g.length}s+=jr(String(e).slice(n))+"$";let r=new RegExp(s).exec(String(i));if(!r)return null;let o=Object.create(null);if(t.forEach((m,g)=>{o[m]=Number(r[g+1])}),o["%s"]!==void 0){let m=o["%s"]*1e3,g=new Date(m);return Number.isNaN(g.getTime())?null:g}let a=o["%Y"]??mu(o["%y"])??1970,l=(o["%m"]??1)-1,c=o["%d"]??o["%e"]??1,d=o["%H"]??0,h=o["%M"]??0,p=o["%S"]??0,f=new Date(0);return f.setHours(0,0,0,0),f.setFullYear(a,l,c),f.setHours(d,h,p,0),Number.isNaN(f.getTime())||o["%Y"]!==void 0&&f.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&f.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&f.getMonth()!==l||o["%d"]!==void 0&&f.getDate()!==c||o["%e"]!==void 0&&f.getDate()!==c||o["%H"]!==void 0&&f.getHours()!==d||o["%M"]!==void 0&&f.getMinutes()!==h||o["%S"]!==void 0&&f.getSeconds()!==p?null:f}function Hr(i,e,t){let s=i.getTime(),n=e instanceof Date?e.getTime():-1/0,r=t instanceof Date?t.getTime():1/0;return new Date(Math.min(r,Math.max(n,s)))}function B(i,e){return i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()}function N(i,e){let t=new Date(i.getTime());return t.setDate(t.getDate()+e),t}function Le(i,e){let t=new Date(i.getTime()),s=t.getDate();t.setDate(1),t.setMonth(t.getMonth()+e);let n=new Date(t.getFullYear(),t.getMonth()+1,0).getDate();return t.setDate(Math.min(s,n)),t}function li(i=X()){if(!i||i.toLowerCase()==="en")return 1;try{let e=new Intl.Locale(i),t=e.getWeekInfo?.()??e.weekInfo;if(t?.firstDay)return t.firstDay%7}catch{}return 1}function Ge(i){return String(i).padStart(2,"0")}function $r(i,e){return i==="month"?e.getMonth():e.getDay()}function Pr(i,e,t,s){let n=$r(i,e),r=`date.${i}.${n}`,o=s?be(r):null;return o!==null?o:Ur(i,"long",t)?.format(e)??Br[i][n]}function Vr(i,e,t,s){let n=$r(i,e),r=s?be(`date.${i}.short.${n}`):null;return r!==null?r:Ur(i,"short",t)?.format(e)??Br[i][n].slice(0,3)}function Ur(i,e,t){let s=`${t}\0${i}\0${e}`,n=Fr.get(s);if(n===void 0){try{n=Intl.DateTimeFormat.supportedLocalesOf(t).length>0?new Intl.DateTimeFormat(t,{[i]:e,calendar:"gregory"}):null}catch{n=null}Fr.set(s,n)}return n}function pu(i){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[i]??null}function mu(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function jr(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Kr=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),gu=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),Yr=Object.freeze({fa:null,fas:"solid",far:"regular",fal:"light",fat:"thin",fad:"duotone",fab:"brands",fak:"kit",solid:"solid",regular:"regular",light:"light",thin:"thin",duotone:"duotone",brands:"brands",kit:"kit",custom:"kit"}),_u=Object.freeze({x:"xmark",search:"magnifying-glass",calendar:"calendar-days",reload:"arrows-rotate",dots:"ellipsis",info:"circle-info",warning:"triangle-exclamation",error:"circle-exclamation",success:"circle-check",drag:"grip-vertical",type:"font",hash:"hashtag",mail:"envelope","link-2":"link"}),Ds=new Map;function Wr(i){let e=String(i).trim();if(/\s/.test(e)||e.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:e.split(/\s+/).filter(Boolean)};let t=e.indexOf(":");if(t>0){let s=e.slice(0,t).toLowerCase(),n=e.slice(t+1);if(s==="builtin"||s==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(Yr,s))return{provider:"fa",name:n,style:Yr[s],classes:null}}return{provider:null,name:e,style:null,classes:null}}function Ns(i,e={}){let{style:t="solid",family:s="classic",fixedWidth:n=!1,translate:r=!0}=e,o=String(i).replace(/^fa-/,""),a=r?_u[o]??o:o,l=[],c=gu[s];return c&&l.push(c),l.push(Kr[t]??Kr.solid,`fa-${a}`),n&&l.push("fa-fw"),l}function Os(i){let e=String(i).trim();if(/^(https?:)?\/\//.test(e)||e.startsWith("/")||e.endsWith(".js"))return e;if(!/^[a-z0-9]+$/.test(e))throw new RangeError(`Invalid Font Awesome kit token: ${i}`);return`https://kit.fontawesome.com/${e}.js`}function Zr(i){let e=Os(i),t=Ds.get(e);if(t)return t;let s=new Promise((n,r)=>{let o=new URL(e,document.baseURI).href,a=[...document.scripts].find(c=>c.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let l=a??document.createElement("script");l.addEventListener("load",()=>n(),{once:!0}),l.addEventListener("error",()=>{Ds.delete(e),r(new Error(`Font Awesome kit failed to load: ${e}`))},{once:!0}),!a&&(l.src=e,l.async=!0,l.crossOrigin="anonymous",document.head.append(l))});return Ds.set(e,s),s}var Jr="http://www.w3.org/2000/svg",T=Object.freeze({control:16,chevron:14,dismiss:14,check:14,sort:14,chip:12,marker:8}),Xr="0 0 24 24",bu=1.75,yu=1,k=i=>[Xr,i,"stroke"];var eo=Object.freeze({"arrow-up-wide-short":k("M3 8l4-4 4 4M7 4v16M11 12h10M11 16h7M11 20h4"),"arrow-down-wide-short":k("M3 16l4 4 4-4M7 20V4M11 4h10M11 8h7M11 12h4"),"arrow-up":k("M5 12l7-7 7 7M12 19V5"),"arrow-down":k("M12 5v14M19 12l-7 7-7-7"),"chevron-down":k("M6 9l6 6 6-6"),"chevron-up":k("M18 15l-6-6-6 6"),"chevron-left":k("M15 18l-6-6 6-6"),"chevron-right":k("M9 18l6-6-6-6"),check:k("M20 6 9 17l-5-5"),x:k("M18 6 6 18M6 6l12 12"),plus:k("M5 12h14M12 5v14"),minus:k("M5 12h14"),search:k("M21 21l-4.34-4.34M3 11a8 8 0 1 0 16 0a8 8 0 1 0-16 0z"),calendar:k("M8 2v3M16 2v3M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18"),clock:k("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 6v6l4 2"),trash:k("M10 11v6M14 11v6M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"),gear:k("M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),eye:k("M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),lock:k("M5 11h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zM7 11V7a5 5 0 0 1 10 0v4"),reload:k("M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8M21 3v5h-5"),list:k("M3 5h.01M3 12h.01M3 19h.01M8 5h13M8 12h13M8 19h13"),filter:k("M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"),dots:k("M11 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM18 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM4 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),info:k("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 16v-4M12 8h.01"),warning:k("M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4M12 17h.01"),error:k("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 8V12M12 16H12.01"),success:k("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 9l-5.5 5.5L8 12"),upload:k("M12 3v12M17 8l-5-5-5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"),download:k("M12 15V3M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5"),"box-archive":k("M3 3h18a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-18a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1zM4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8M10 12h4"),pencil:k("M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497zM15 5l4 4"),"pen-to-square":k("M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"),drag:k("M8 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),star:k("M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"),heart:k("M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"),tag:k("M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42zM7 7.5a.5 .5 0 1 0 1 0a.5 .5 0 1 0-1 0z"),folder:k("M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"),"folder-open":k("M6 14l1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"),file:k("M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2zM14 2v5a1 1 0 0 0 1 1h5"),copy:k("M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-10a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2zM4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"),square:k("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2z"),code:k("M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16"),book:k("M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20"),"table-cells-large":k("M4 3h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM15 3h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM15 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM4 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1z"),table:k("M12 3v18M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18M3 15h18"),image:k("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM7 9a2 2 0 1 0 4 0a2 2 0 1 0-4 0zM21 15l-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),columns:k("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM9 3v18M15 3v18"),type:k("M12 4v16M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2M9 20h6"),hash:k("M4 9h16M4 15h16M10 3L8 21M16 3l-2 18"),mail:k("M22 7l-8.991 5.727a2 2 0 0 1-2.009 0L2 7M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-16a2 2 0 0 1-2-2v-12a2 2 0 0 1 2-2z"),"link-2":k("M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 1 1 0 10h-2M8 12h8"),"circle-chevron-down":k("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 10l-4 4-4-4")}),wu=Object.freeze({archive:"box-archive",edit:"pen-to-square",settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list",grid:"table-cells-large"}),to=Object.create(null),we={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function Ls(){return{...we}}function Fs(i={}){for(let e of["provider","style","family","fixedWidth","kit"])i[e]!==void 0&&(we[e]=i[e]);return Ls()}function io(i={}){return Fs({...i,provider:"fontawesome"})}async function Ps(i){let e=typeof i=="string"?{kit:i}:{...i},{kit:t,activate:s=!0,...n}=e;if(!t)throw new TypeError("loadFontAwesome() needs a kit token or URL");return Fs({...n,kit:Os(t)}),await Zr(t),s?io():Ls()}function v(i,e={}){let t=Wr(i);if(t.classes)return Rs(t.classes,e);let s=Object.hasOwn(to,t.name)?t.name:wu[t.name]??t.name;return t.provider==="builtin"?Gr(s,e):t.provider==="fa"?Rs(Ns(s,{style:t.style??e.style??we.style,family:e.family??we.family,fixedWidth:e.fixedWidth??we.fixedWidth}),e):we.provider==="fontawesome"?Rs(Ns(s,{style:e.style??we.style,family:e.family??we.family,fixedWidth:e.fixedWidth??we.fixedWidth}),e):Gr(s,e)}function Gr(i,e){let t=to[i]??eo[i];if(!t){if(e.strict)throw new RangeError(`Unknown icon: ${i}`);return Au(i),Su(i,e)}let[s,n,r="fill"]=t,o=so(s,r,e),a=document.createElementNS(Jr,"path");return a.setAttribute("d",n),o.append(a),o}function so(i,e,t){let{size:s=T.control}=t,n=document.createElementNS(Jr,"svg");return n.setAttribute("class",ro("zx-icon",t.class)),n.setAttribute("viewBox",i),n.setAttribute("width",String(s)),n.setAttribute("height",String(s)),e==="stroke"?(n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width",vu(i,s)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round")):n.setAttribute("fill","currentColor"),n.setAttribute("focusable","false"),no(n,t.label??null),n}function vu(i,e){let[,,t,s]=i.trim().split(/[\s,]+/).map(Number),n=Math.max(t,s)||24,r=bu*n/24,o=typeof e=="number"?e:/^\d*\.?\d+(px)?$/.test(String(e).trim())?parseFloat(String(e)):NaN;return o>0&&(r=Math.max(r,yu*n/o)),String(Math.round(r*1e3)/1e3)}var xu=Xr;function Su(i,e){let t=so(xu,"stroke",e);return t.setAttribute("data-zx-icon-missing",i),t}var Qr=new Set;function Au(i){Qr.has(i)||(Qr.add(i),console.warn(`[zx.icon] Unknown icon "${i}" \u2014 rendered an empty placeholder. Add it with registerIcons(), or render Font Awesome with useFontAwesome().`))}function Rs(i,e){let{size:t=T.control}=e,s=document.createElement("i");return s.className=ro("zx-icon",...i,e.class),s.style.fontSize=typeof t=="number"?`${t}px`:String(t),no(s,e.label??null),s}function no(i,e){if(e===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",e)}function ro(...i){return i.flat().filter(Boolean).join(" ")}var ku=5,ci=class extends S{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let e=this.el??u("div");this.el=e;let t=oo(this.options.value);this._value=t,this._display=t??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let s=u("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:this._message("timePicker.label","Time")});if(this._content=s,this._addSpin(s,"h",this._message("timePicker.hour","Hour"),23),s.append(u("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"m",this._message("timePicker.minute","Minute"),59),this.options.seconds&&(s.append(u("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"s",this._message("timePicker.second","Second"),59)),e.append(s),this.options.clock){let n=E("zx-time-picker-clock");s.append(u("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:this._message("timePicker.clock","Pick the time on a clock"),ariaExpanded:"false",ariaControls:n},v("clock",{size:15}))),this._clock=this._buildClock(n),e.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),e}get(){return this._value?{...this._value}:null}set(e,{silent:t=!1}={}){let s=oo(e);return this._value=s,this._display=s??{h:0,m:0,s:0},this._writeInputs(),!t&&s&&this.emit("change",{time:{...s}}),this}openClock(e="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=e==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(e,t,s,n){let r=u("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:s,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:t}});this._inputs.push(r),e.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,t,n)),this.listen(r,"input",()=>this._onInput(r,t,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(e,t,s){if(e.key!=="ArrowUp"&&e.key!=="ArrowDown")return;e.preventDefault();let n=e.key==="ArrowUp"?1:-1,r=t==="m"?Eu(this.options.step):1,o=Qe(e.currentTarget.value,0,s),a=s+1,l=(o+n*r+a*r)%a;e.currentTarget.value=Fe(l),this._commitFromInputs()}_onInput(e,t,s){if(e.value=e.value.replace(/\D/g,"").slice(0,2),e.value.length<2)return;e.value=Fe(Qe(e.value,0,s)),this._commitFromInputs();let n=this._inputs.indexOf(e);this._inputs[n+1]?.focus()}_commitFromInputs(){let e={h:0,m:0,s:0};for(let s of this._inputs){let n=s.dataset.segment,r=n==="h"?23:59;e[n]=Qe(s.value,0,r)}let t=!this._value||!Iu(this._value,e);this._value=e,this._display=e,this._writeInputs(),t&&this.emit("change",{time:{...e}})}_writeInputs(){for(let e of this._inputs){let t=e.dataset.segment;e.value=Fe(this._display[t]),e.setAttribute("aria-valuenow",String(this._display[t])),e.setAttribute("aria-valuetext",e.value)}this._syncClock()}_buildClock(e){let t=u("div",{class:"zx-time-picker__clock",id:e,hidden:!0},u("div",{class:"zx-time-picker__clock-head"},u("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectHour","Select the hour"),dataset:{unit:"h"}}),u("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),u("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectMinutes","Select the minutes"),dataset:{unit:"m"}})),u("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},u("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),u("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",s=>{let n=s.target.closest?.(".zx-time-picker__mark");n&&this._pick(Number(n.dataset.value))}),this.listen(this.refs.dial,"keydown",s=>this._onDialKeydown(s)),t}_pick(e){let t={...this._display,[this._clockUnit]:e},s=this._clockUnit==="h";this.set(t),s&&this.openClock("m")}_onDialKeydown(e){let t=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],s=e.target.closest?.(".zx-time-picker__mark"),n=t.indexOf(s);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key],o=null;r!==void 0?o=(n+r+t.length)%t.length:e.key==="Home"?o=0:e.key==="End"&&(o=t.length-1),o!==null&&(e.preventDefault(),this._pick(Number(t[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${t[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let e=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=Fe(this._display.h),this.refs.headMinute.textContent=Fe(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(e)),this.refs.headMinute.setAttribute("aria-pressed",String(!e)),this.refs.dial.setAttribute("aria-label",e?this._message("timePicker.hour","Hour"):this._message("timePicker.minutes","Minutes")),!this._clockOpen)return;let t=e?this._display.h:this._display.m,s=e?Cu():Tu(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==s.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of n)a.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...s.map(a=>this._buildMark(a,t)))}else s.forEach((a,l)=>this._syncMark(n[l],a,t));let r=e&&!zu(t)?"inner":"outer",o=e?t%12*30:t*6;this.refs.hand.dataset.ring=r,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(e,t){let s=u("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(e.value),ring:e.ring}},e.label);return s.style.setProperty("--zx-clock-angle",`${e.angle}deg`),this._syncMark(s,e,t),s}_syncMark(e,t,s){let n=t.value===s;e.setAttribute("aria-checked",String(n)),e.tabIndex=n?0:-1}_message(e,t){let s=this.msg(e);return s===e?t:s}};function Cu(){let i=[];for(let e=1;e<=12;e+=1)i.push({value:e,label:String(e),angle:e%12*30,ring:"outer"});for(let e=0;e<12;e+=1){let t=e===0?0:12+e;i.push({value:t,label:Fe(t),angle:e*30,ring:"inner"})}return i}function Tu(){let i=[];for(let e=0;e<60;e+=ku)i.push({value:e,label:Fe(e),angle:e*6,ring:"outer"});return i}function zu(i){return i>=1&&i<=12}function oo(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:Qe(i.h,0,23),m:Qe(i.m,0,59),s:Qe(i.s,0,59)}}function Qe(i,e,t){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(e,Math.min(t,s)):e}function Eu(i){let e=Math.round(Number(i));return Number.isFinite(e)&&e>0&&e<=59?e:5}function Fe(i){return String(i).padStart(2,"0")}function Iu(i,e){return i.h===e.h&&i.m===e.m&&i.s===e.s}var Je=class extends S{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let e=this.el??u("div");this._min=le(ui(this.options.min)),this._max=le(ui(this.options.max)),this._value=this._normalizeValue(ui(this.options.value)),this._focused=le(this._value)??this._clampFocus(le(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=Mu(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let t=u("div",{class:"zx-date-picker__surface"},u("div",{class:"zx-date-picker__header"},u("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousMonth","Previous month")},v("chevron-left",{size:T.chevron})),u("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),u("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextMonth","Next month")},v("chevron-right",{size:T.chevron}))),u("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},u("div",{class:"zx-date-picker__quick-header"},u("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousYear","Previous year")},v("chevron-left",{size:T.chevron})),u("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),u("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextYear","Next year")},v("chevron-right",{size:T.chevron}))),u("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),u("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:this._message("datePicker.calendar","Calendar")},u("thead",{ref:"weekdays"}),u("tbody",{ref:"days"})));return this._content=t,e.append(t),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",s=>this._onQuickClick(s)),this.listen(this.refs.quickGrid,"keydown",s=>this._onQuickKeydown(s)),this.listen(this.refs.days,"click",s=>this._onDayClick(s)),this.listen(this.refs.days,"keydown",s=>this._onDayKeydown(s)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new ci(null,{value:this._value,seconds:!1}),this._timePicker.on("change",s=>{let n=s.detail.time,r=this._value??this._focused,o=new Date(r.getTime());o.setHours(n.h,n.m,n.s,0),this.set(o)}),t.append(this._timePicker.el)),e}get(){return Vs(this._value)}set(e,{silent:t=!1}={}){let s=this._normalizeValue(ui(e));return this._value=s,s&&(this._focused=le(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),t||this.emit("change",{date:Vs(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(e){if(!e)return null;let t=new Date(e.getTime()),s=le(t);return this._min&&s<this._min&&ao(t,this._min),this._max&&s>this._max&&ao(t,this._max),t}_clampFocus(e){return this._min&&e<this._min?new Date(this._min.getTime()):this._max&&e>this._max?new Date(this._max.getTime()):e}_renderWeekdays(){let e=u("tr");this.options.showWeekNumbers&&e.append(u("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:this._message("datePicker.weekNumber","Week number")},"#"));let t=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=N(t,(this._weekStart+s)%7);e.append(u("th",{scope:"col",ariaLabel:M(n,"%A")},M(n,"%a")))}this.refs.weekdays.replaceChildren(e)}_renderCalendar(){if(!this.refs?.days)return;let e=new Date(this._viewYear,this._viewMonth,1),t=(e.getDay()-this._weekStart+7)%7,s=N(e,-t);this.refs.heading.textContent=M(e,"%B %Y"),this.refs.heading.setAttribute("aria-label",this._message("datePicker.chooseMonthYear","Choose month and year, %1",M(e,"%B %Y")));let n=this._message("datePicker.dayLabel","%e %B %Y"),r=[];for(let o=0;o<6;o+=1){let a=N(s,o*7),l=u("tr");this.options.showWeekNumbers&&l.append(u("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:this._message("datePicker.week","Week %1",lo(a))},String(lo(a))));for(let c=0;c<7;c+=1){let d=N(a,c),h=!!(this._value&&B(d,this._value)),p=!this._inRange(d),f=u("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:B(d,this._focused)?0:-1,ariaSelected:String(h),ariaDisabled:String(p),ariaCurrent:B(d,new Date)?"date":null,ariaLabel:M(d,n),dataset:{date:M(d,"%Y-%m-%d"),otherMonth:d.getMonth()===this._viewMonth?null:"true"}},M(d,"%e"));l.append(u("td",{role:"presentation"},f))}r.push(l)}this.refs.days.replaceChildren(...r),this._quickOpen&&this._renderQuickPick()}_onDayClick(e){let t=e.target?.closest?.("[data-date]");if(!t||!this.refs.days.contains(t))return;let s=pe(t.dataset.date,"%Y-%m-%d");s&&this._inRange(s)&&this._selectDate(s)}_onDayKeydown(e){let t=e.target?.closest?.("[data-date]");if(!t||!this.refs.days.contains(t))return;let s=pe(t.dataset.date,"%Y-%m-%d");if(!s)return;let n=null;if(e.key==="ArrowLeft")n=N(s,-1);else if(e.key==="ArrowRight")n=N(s,1);else if(e.key==="ArrowUp")n=N(s,-7);else if(e.key==="ArrowDown")n=N(s,7);else if(e.key==="PageUp")n=Le(s,e.shiftKey?-12:-1);else if(e.key==="PageDown")n=Le(s,e.shiftKey?12:1);else if(e.key==="Home")n=N(s,-((s.getDay()-this._weekStart+7)%7));else if(e.key==="End")n=N(s,6-(s.getDay()-this._weekStart+7)%7);else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._inRange(s)&&this._selectDate(s);return}n&&(e.preventDefault(),this._moveFocus(n))}_moveFocus(e){let t=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._focused=le(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),t&&this._emitMonthChange(),this._buttonForDate(e)?.focus()}_selectDate(e){let t=new Date(e.getTime()),s=this._timePicker?.get();s?t.setHours(s.h,s.m,s.s,0):this._value&&t.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let n=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._value=t,this._focused=le(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._timePicker?.set(t,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:Vs(t)})}_pageMonth(e){this._closeQuickPick();let t=Le(this._focused,e);this._focused=le(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let e=[];for(let t=0;t<12;t+=1){let s=new Date(this._viewYear,t,1);e.push(u("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:t===this._viewMonth?0:-1,ariaSelected:String(t===this._viewMonth),dataset:{month:t}},M(s,"%b")))}this.refs.quickGrid.replaceChildren(...e)}_stepQuickYear(e){this._viewYear+=e,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(e){let t=e.target?.closest?.("[data-month]");!t||!this.refs.quickGrid.contains(t)||this._chooseQuickMonth(Number(t.dataset.month))}_onQuickKeydown(e){let t=e.target?.closest?.("[data-month]");if(!t||!this.refs.quickGrid.contains(t))return;let s=Number(t.dataset.month),n=null;if(e.key==="ArrowLeft")n=s-1;else if(e.key==="ArrowRight")n=s+1;else if(e.key==="ArrowUp")n=s-3;else if(e.key==="ArrowDown")n=s+3;else if(e.key==="Home")n=0;else if(e.key==="End")n=11;else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._chooseQuickMonth(s);return}else if(e.key==="Escape"){e.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(n===null)return;e.preventDefault(),n=Math.max(0,Math.min(11,n));let r=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of r)o.tabIndex=Number(o.dataset.month)===n?0:-1;r[n]?.focus()}_chooseQuickMonth(e){let t=new Date(this._viewYear,e,Math.min(this._focused.getDate(),new Date(this._viewYear,e+1,0).getDate()));this._focused=le(t),this._viewMonth=e,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(e){let t=le(e);return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_buttonForDate(e){return this.refs.days.querySelector(`[data-date="${M(e,"%Y-%m-%d")}"]`)}_message(e,t,...s){let n=this.msg(e,...s);return n===e?F(t,s):n}};function ui(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function le(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function Vs(i){return i?new Date(i.getTime()):null}function ao(i,e){i.setFullYear(e.getFullYear(),e.getMonth(),e.getDate())}function Mu(i){let e=Number(i);return Number.isInteger(e)&&e>=0&&e<=6?e:li()}function lo(i){let e=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let s=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-s.getTime())/864e5+1)/7)}var fi=class extends Je{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(e,t={}){super(e,t)}render(){let e=this.el??u("div");this._min=hi(di(this.options.min)),this._max=hi(di(this.options.max)),this._value=this._normalizeMonth(di(this.options.value));let t=this._value??hi(new Date);this._year=t.getFullYear(),this._focusedMonth=t.getMonth();let s=u("div",{class:"zx-month-picker__surface"},u("div",{class:"zx-month-picker__header"},u("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.previousYear","Previous year")},v("chevron-left",{size:T.chevron})),u("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),u("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.nextYear","Next year")},v("chevron-right",{size:T.chevron}))),u("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:this._message("monthPicker.chooseMonth","Choose month")}));return this._content=s,e.append(s),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",n=>this._onMonthClick(n)),this.listen(this.refs.grid,"keydown",n=>this._onMonthKeydown(n)),this._renderMonths(),e}get(){return this._value?new Date(this._value.getTime()):null}set(e,{silent:t=!1}={}){return this._value=this._normalizeMonth(di(e)),this._value&&(this._year=this._value.getFullYear(),this._focusedMonth=this._value.getMonth()),this._renderMonths(),t||this.emit("change",{date:this.get()}),this}focus(){return this._button(this._focusedMonth)?.focus(),this}destroy(){this._content?.remove(),super.destroy()}_normalizeMonth(e){if(!e)return null;let t=hi(e);return this._min&&t<this._min&&(t=new Date(this._min.getTime())),this._max&&t>this._max&&(t=new Date(this._max.getTime())),t}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let e=[];for(let t=0;t<12;t+=1){let s=new Date(this._year,t,1),n=!!(this._value&&Du(s,this._value));e.push(u("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:t===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(s)),ariaLabel:M(s,"%B %Y"),dataset:{month:t}},M(s,"%b")))}this.refs.grid.replaceChildren(...e)}_stepYear(e){this._year+=e,this._renderMonths()}_onMonthClick(e){let t=e.target?.closest?.("[data-month]");!t||!this.refs.grid.contains(t)||this._selectMonth(Number(t.dataset.month))}_onMonthKeydown(e){let t=e.target?.closest?.("[data-month]");if(!t||!this.refs.grid.contains(t))return;let s=Number(t.dataset.month),n=null;if(e.key==="ArrowLeft")n=-1;else if(e.key==="ArrowRight")n=1;else if(e.key==="ArrowUp")n=-3;else if(e.key==="ArrowDown")n=3;else if(e.key==="Home")n=-(s%3);else if(e.key==="End")n=2-s%3;else if(e.key==="PageUp"){e.preventDefault(),this._stepYear(-1),this.focus();return}else if(e.key==="PageDown"){e.preventDefault(),this._stepYear(1),this.focus();return}else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._selectMonth(s);return}if(n===null)return;e.preventDefault();let r=this._year*12+s+n;this._year=Math.floor(r/12),this._focusedMonth=(r%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(e){let t=new Date(this._year,e,1);this._inRange(t)&&(this._focusedMonth=e,this._value=t,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(e){return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_button(e){return this.refs.grid.querySelector(`[data-month="${e}"]`)}};function di(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function hi(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function Du(i,e){return i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()}function co(){C.register("month",(i,e)=>{let t=i.own(new fi(null,{...e.props??{},value:e.value})),s=!1,n=()=>{t.el.setAttribute("aria-disabled",String(s));for(let r of t.el.querySelectorAll("button"))r.disabled=s};return i.listen(t.el,"change",r=>r.stopImmediatePropagation()),t.on("change",r=>i.emit("change",{value:r.detail.date})),{el:t.el,get:()=>t.get(),set:r=>{t.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>t.focus(),setDisabled:r=>{s=!!r,n()}}})}var Nu=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function ne(i,e,t={}){if(!(i instanceof Element)||!(e instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=Nu.has(t.placement)?t.placement:"bottom-start",n=Number(t.offset??4),r=t.flip??!0,o=t.matchWidth??!1,a=i.getAttribute("style"),l=e.getAttribute("style"),c=e.getAttribute("popover"),d=!1,h=null,p=()=>{},f=()=>{};e.setAttribute("popover","manual");let m=typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a"),g=`--${E("zx-a")}`;if(m){let _=uo(i);i.style.setProperty("anchor-name",[..._,g].join(", ")),e.style.position="fixed",e.style.inset="auto",e.style.margin="0",e.style.setProperty("position-anchor",g);let b=Ou(s,getComputedStyle(i).direction==="rtl");e.style.setProperty("position-area",b),e.style.setProperty("inset-area",b),e.style.setProperty("position-try-fallbacks",r?"flip-block, flip-inline, flip-block flip-inline":"none");let w=s.startsWith("top")?"margin-bottom":s.startsWith("bottom")?"margin-top":s.startsWith("left")?"margin-right":"margin-left";e.style.setProperty(w,`${n}px`),p=()=>{o&&(e.style.minWidth=`${i.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(h=new ResizeObserver(p),h.observe(i))}else e.style.position="fixed",e.style.inset="auto",e.style.margin="0",p=()=>Ru(i,e,{placement:s,offset:n,flip:r,matchWidth:o}),window.addEventListener("scroll",p,{capture:!0,passive:!0}),window.addEventListener("resize",p,{passive:!0}),typeof ResizeObserver=="function"&&(h=new ResizeObserver(p),h.observe(i)),f=()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)};return Lu(e),p(),{update(){d||p()},destroy(){if(!d){if(d=!0,h?.disconnect(),f(),Fu(e),m){let _=uo(i).filter(b=>b!==g);_.length?i.style.setProperty("anchor-name",_.join(", ")):i.style.removeProperty("anchor-name"),!a&&i.getAttribute("style")===""&&i.removeAttribute("style")}ei(e,l),Pu(e,"popover",c)}}}}function uo(i){return String(i.style?.getPropertyValue("anchor-name")??"").split(",").map(e=>e.trim()).filter(e=>e&&e!=="none")}function Ou(i,e){return{"bottom-start":e?"bottom span-left":"bottom span-right","bottom-end":e?"bottom span-right":"bottom span-left","top-start":e?"top span-left":"top span-right","top-end":e?"top span-right":"top span-left","right-start":"right span-bottom","right-end":"right span-top","left-start":"left span-bottom","left-end":"left span-top",bottom:"bottom",top:"top",right:"right",left:"left"}[i]}function Ru(i,e,{placement:t,offset:s,flip:n,matchWidth:r}){let o=i.getBoundingClientRect();r&&(e.style.minWidth=`${o.width}px`);let a=e.getBoundingClientRect(),l=document.documentElement.clientWidth||window.innerWidth,c=document.documentElement.clientHeight||window.innerHeight,d=t,h=ho(t),p=o.bottom+s,f=o.top-s-a.height,m=o.right+s,g=o.left-s-a.width;n&&(h==="bottom"&&p+a.height>c&&f>=0?d=pi(t,"bottom","top"):h==="top"&&f<0&&p+a.height<=c?d=pi(t,"top","bottom"):h==="right"&&m+a.width>l&&g>=0?d=pi(t,"right","left"):h==="left"&&g<0&&m+a.width<=l&&(d=pi(t,"left","right")));let _=ho(d),b,w;if(_==="bottom"||_==="top"){let A=getComputedStyle(i).direction==="rtl";d.endsWith("-end")?b=A?o.left:o.right-a.width:d.endsWith("-start")?b=A?o.right-a.width:o.left:b=o.left+(o.width-a.width)/2,w=_==="bottom"?p:f}else b=_==="right"?m:g,d.endsWith("-end")?w=o.bottom-a.height:d.endsWith("-start")?w=o.top:w=o.top+(o.height-a.height)/2;e.style.left=`${Math.round(vt(b,0,Math.max(0,l-a.width)))}px`,e.style.top=`${Math.round(vt(w,0,Math.max(0,c-a.height)))}px`}function ho(i){return i.split("-")[0]}function pi(i,e,t){return i.replace(e,t)}function Lu(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function Fu(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function Pu(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}var Vu=6,bo=864e5;function kt(i,e){let t=J(Pe(i)),s=J(Pe(e));return t&&s&&t.getTime()>s.getTime()?{start:s,end:t}:{start:t,end:s}}function mi(i,e){let t=kt(i,e);return!t.start||!t.end?0:Math.round((mo(t.end)-mo(t.start))/bo)}function ju(i,e,t){let s=J(Pe(i));if(!s)return null;let n=kt(e,t);return!n.start&&!n.end?null:n.end?n.start?s.getTime()<n.start.getTime()||s.getTime()>n.end.getTime()?null:B(s,n.start)?"start":B(s,n.end)?"end":"middle":B(s,n.end)?"end":null:B(s,n.start)?"start":null}function gi(i,e={}){let t=J(Pe(e.min)),s=J(Pe(e.max)),n=bi(e.minNights)??0,r=bi(e.maxNights),{start:o,end:a}=kt(i?.start,i?.end);return o&&(o=Bs(o,t,s)),a&&(a=Bs(a,t,s)),!o||!a?{start:o,end:a}:(r!==null&&mi(o,a)>r&&(a=N(o,r)),n>0&&mi(o,a)<n&&(a=N(o,n),s&&a.getTime()>s.getTime()&&(a=new Date(s.getTime()),o=N(a,-n),t&&o.getTime()<t.getTime()))?{start:null,end:null}:{start:o,end:a})}var _i=class extends S{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let e=this.el??u("div");this.el=e,this._rootAttributes=Yu(e,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=J(Pe(this.options.min)),this._max=J(Pe(this.options.max)),this._minNights=bi(this.options.minNights)??0,this._maxNights=bi(this.options.maxNights),this._weekStart=$u(this.options.weekStart),this._monthCount=Uu(this.options.months),this._presets=Hu(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let t=gi({start:this.options.start,end:this.options.end},this._bounds());this._start=t.start,this._end=t.end,this._picking=!!(t.start&&!t.end),this._remember(),this._focused=Ie(this._start)??this._clampFocus(J(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),e.setAttribute("role","group"),e.setAttribute("aria-label",O("daterange.label","Date range")),e.dataset.months=String(this._monthCount),this._presets.length&&(e.dataset.presets="true");let s=u("div",{class:"zx-date-range-picker__surface"},this._presets.length?u("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:O("daterange.presets","Date range presets")},this._presets.map(r=>u("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,u("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=u("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[s,n],e.append(s,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),e}get(){return{start:Ie(this._start),end:Ie(this._end)}}set(e={},{silent:t=!1}={}){let s=gi({start:e?.start??null,end:e?.end??null},this._bounds());return this._start=s.start,this._end=s.end,this._picking=!!(s.start&&!s.end),this._remember(),this._hover=null,s.start?(this._focused=Ie(s.start),this._setView(s.start)):this._paint(),this._announce(),t||this.emit("change",this.get()),this}clear({silent:e=!1}={}){return this.set({start:null,end:null},{silent:e})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let e of this._nodes??[])e.remove();this._nodes=[],this._dayCells=[],Wu(this.el,this._rootAttributes??new Map),super.destroy()}_bounds(){return{min:this._min,max:this._max,minNights:this._minNights,maxNights:this._maxNights}}_selectable(e){let t=J(e);if(!t||this._min&&t.getTime()<this._min.getTime()||this._max&&t.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||t.getTime()<=this._start.getTime())return!0;let s=mi(this._start,t);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(e){let t=J(e);if(this._disabled||!t||!this._selectable(t))return;this._picking&&this._start&&t.getTime()>this._start.getTime()?(this._end=t,this._picking=!1,this._remember()):(this._start=t,this._end=null,this._picking=!0),this._focused=t,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),this._picking||this.emit("change",this.get())}_remember(){let e=!!(this._start&&this._end);this._committedStart=e?Ie(this._start):null,this._committedEnd=e?Ie(this._end):null}_abandon(){return this._picking?(this._start=Ie(this._committedStart),this._end=Ie(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(e){return Bs(e,this._min,this._max)}_visibleMonthCount(){let e=this.refs.calendars?.children??[],t=0;for(let s of e)s.getClientRects().length>0&&(t+=1);return t||this._monthCount}_setView(e){let t=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;if(this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),!t){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(e){let t=this._visibleMonthCount(),s=go(e)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<t)return!1;let n=s<0?s:s-(t-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.getMonth(),!0}_pageView(e){if(this._disabled)return;let t=new Date(this._viewYear,this._viewMonth+e,1);this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(e){let t=this._visibleMonthCount(),s=go(e)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<t)return e;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(e.getDate(),n))}_moveFocus(e){let t=J(e);this._focused=t,this._ensureVisible(t)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(t)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(e){let t=e.target?.closest?.("[data-preset]");if(!t||this._disabled)return;let s=this._presets.find(r=>r.name===t.dataset.preset);if(!s)return;let n=s.range();this.set({start:n?.start??null,end:n?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(e){let t=e.target,s=t?.closest?.("[data-nav]");if(s){this._pageView(s.dataset.nav==="next"?1:-1);return}let n=this._cellFor(t);n&&this._choose(n.date)}_onDayHover(e){let t=this._cellFor(e.target);this._setHover(t?t.date:null)}_setHover(e){if(this._disabled||!this._picking)return;let t=e?J(e):null;!t&&!this._hover||t&&this._hover&&B(t,this._hover)||(this._hover=t,this._paint())}_onDayKeydown(e){let t=this._cellFor(e.target);if(!t)return;let s=t.date,n=null;if(e.key==="ArrowLeft")n=N(s,-1);else if(e.key==="ArrowRight")n=N(s,1);else if(e.key==="ArrowUp")n=N(s,-7);else if(e.key==="ArrowDown")n=N(s,7);else if(e.key==="PageUp")n=Le(s,e.shiftKey?-12:-1);else if(e.key==="PageDown")n=Le(s,e.shiftKey?12:1);else if(e.key==="Home")n=N(s,-((s.getDay()-this._weekStart+7)%7));else if(e.key==="End")n=N(s,6-(s.getDay()-this._weekStart+7)%7);else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._choose(s);return}else if(e.key==="Escape"){if(!this._abandon())return;e.preventDefault(),e.stopPropagation();return}!n||this._disabled||(e.preventDefault(),this._moveFocus(n))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let e=[];for(let t=0;t<this._monthCount;t+=1)e.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+t,1)));this.refs.calendars.replaceChildren(...e),this._paint(),this._syncDisabled()}_renderMonth(e){let t=M(e,"%B %Y"),s=(e.getDay()-this._weekStart+7)%7,n=N(e,-s),r=[];for(let o=0;o<Vu;o+=1){let a=N(n,o*7),l=u("tr"),c=Ku(a,e);this.options.showWeekNumbers&&l.append(u("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:c?O("daterange.week","Week %1",[_o(a)]):null},c?String(_o(a)):""));for(let d=0;d<7;d+=1){let h=N(a,d),p=u("td",{role:"presentation"});if(h.getMonth()===e.getMonth()&&h.getFullYear()===e.getFullYear()){let f=u("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:M(h,"%Y-%m-%d")}},M(h,"%e"));p.append(f),this._dayCells.push({date:h,cell:p,button:f})}l.append(p)}r.push(l)}return u("div",{class:"zx-date-range-picker__month"},u("div",{class:"zx-date-range-picker__header"},u("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:O("daterange.previousMonth","Previous month")},v("chevron-left",{size:T.chevron})),u("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},t),u("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:O("daterange.nextMonth","Next month")},v("chevron-right",{size:T.chevron}))),u("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:t},u("thead",{},this._weekdayRow()),u("tbody",{},...r)))}_weekdayRow(){let e=u("tr");this.options.showWeekNumbers&&e.append(u("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:O("daterange.weekNumber","Week number")},"#"));let t=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=N(t,(this._weekStart+s)%7);e.append(u("th",{scope:"col",ariaLabel:M(n,"%A")},M(n,"%a")))}return e}_paint(){let e=new Date,t=null;for(let s of this._dayCells)B(s.date,this._focused)&&(t=s);t||(t=this._dayCells[0]??null);for(let s of this._dayCells){let{date:n,cell:r,button:o}=s,a=this._dayState(n);js(r,"range",a.range),js(r,"rangeEdge",a.edge),js(o,"range",a.range),o.tabIndex=s===t?0:-1,o.setAttribute("aria-selected",String(a.range!==null&&a.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),B(n,e)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(e){if(this._start&&this._end){let s=ju(e,this._start,this._end);if(!s)return{range:null,edge:null};let n=B(this._start,this._end);return s==="start"?{range:s,edge:n?"both":"start"}:s==="end"?{range:s,edge:n?"both":"end"}:{range:s,edge:null}}if(!this._start)return{range:null,edge:null};let t=this._previewEnd();return B(e,this._start)?{range:"start",edge:t?"start":"both"}:t?e.getTime()>this._start.getTime()&&e.getTime()<=t.getTime()?{range:"preview",edge:B(e,t)?"end":null}:{range:null,edge:null}:{range:null,edge:null}}_previewEnd(){if(!this._picking||!this._start||this._disabled)return null;let e=this._hover??this._focused;if(!e)return null;let t=J(e);return t.getTime()<=this._start.getTime()?null:this._selectable(t)?t:null}_dayLabel(e,t){let s=M(e,O("daterange.dayLabel","%A, %e %B %Y"));return t==="start"?`${s}, ${O("daterange.day.start","range start")}`:t==="end"?`${s}, ${O("daterange.day.end","range end")}`:t==="middle"?`${s}, ${O("daterange.day.middle","in selected range")}`:s}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let e of this.el.querySelectorAll("button"))e.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return O("daterange.status.empty","No date range selected");if(!this._end)return O("daterange.status.start","%1 selected, choose an end date",[M(this._start,O("daterange.span.full","%e %B %Y"))]);let e=mi(this._start,this._end),t=e===1?O("daterange.night","1 night"):O("daterange.nights","%1 nights",[e]);return`${qu(this._start,this._end)}, ${t}`}_cellFor(e){let t=e?.closest?.("[data-date]");return t?this._dayCells.find(s=>s.button===t)??null:null}_buttonForDate(e){return this._dayCells.find(t=>B(t.date,e))?.button??null}};function Bu(){return[{name:"today",label:O("daterange.preset.today","Today"),range:()=>fo(me())},{name:"yesterday",label:O("daterange.preset.yesterday","Yesterday"),range:()=>fo(N(me(),-1))},{name:"last7",label:O("daterange.preset.last7","Last 7 days"),range:()=>({start:N(me(),-6),end:me()})},{name:"last30",label:O("daterange.preset.last30","Last 30 days"),range:()=>({start:N(me(),-29),end:me()})},{name:"thisMonth",label:O("daterange.preset.thisMonth","This month"),range:()=>po(me(),0)},{name:"lastMonth",label:O("daterange.preset.lastMonth","Last month"),range:()=>po(me(),-1)},{name:"thisQuarter",label:O("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=me(),e=Math.floor(i.getMonth()/3)*3;return{start:new Date(i.getFullYear(),e,1),end:new Date(i.getFullYear(),e+3,0)}}},{name:"thisYear",label:O("daterange.preset.thisYear","This year"),range:()=>{let i=me();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function O(i,e,t){let s=R(i);return F(s===i?e:s,t)}function qu(i,e){let t=O("daterange.span.full","%e %B %Y");if(B(i,e))return M(i,t);let s=M(e,t);return i.getFullYear()!==e.getFullYear()?`${M(i,t)} \u2013 ${s}`:i.getMonth()!==e.getMonth()?`${M(i,O("daterange.span.month","%e %B"))} \u2013 ${s}`:`${M(i,O("daterange.span.day","%e"))} \u2013 ${s}`}function Hu(i){return i===!0?Bu():Array.isArray(i)?i.filter(e=>e&&typeof e.range=="function").map((e,t)=>({name:String(e.name??`preset-${t}`),label:String(e.label??e.name??""),range:e.range})):[]}function me(){return J(new Date)}function fo(i){return{start:i,end:new Date(i.getTime())}}function po(i,e){return{start:new Date(i.getFullYear(),i.getMonth()+e,1),end:new Date(i.getFullYear(),i.getMonth()+e+1,0)}}function Pe(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function J(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function Ie(i){return i?new Date(i.getTime()):null}function Bs(i,e,t){return e&&i.getTime()<e.getTime()?new Date(e.getTime()):t&&i.getTime()>t.getTime()?new Date(t.getTime()):new Date(i.getTime())}function mo(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function go(i){return i.getFullYear()*12+i.getMonth()}function bi(i){if(i==null||i==="")return null;let e=Number(i);return Number.isFinite(e)?Math.max(0,Math.trunc(e)):null}function $u(i){let e=Number(i);return Number.isInteger(e)&&e>=0&&e<=6?e:li()}function Uu(i){let e=Number(i);return Number.isInteger(e)&&e>=1&&e<=4?e:2}function Ku(i,e){for(let t=0;t<7;t+=1){let s=N(i,t);if(s.getMonth()===e.getMonth()&&s.getFullYear()===e.getFullYear())return!0}return!1}function _o(i){let e=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let s=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-s.getTime())/bo+1)/7)}function js(i,e,t){t==null?delete i.dataset[e]:i.dataset[e]=t}function Yu(i,e){return new Map(e.map(t=>[t,i.getAttribute(t)]))}function Wu(i,e){for(let[t,s]of e)s===null?i.removeAttribute(t):i.setAttribute(t,s)}function yi(i){return{"%d":i("datebox.placeholder.day"),"%e":i("datebox.placeholder.dayShort"),"%m":i("datebox.placeholder.month"),"%Y":i("datebox.placeholder.year"),"%y":i("datebox.placeholder.yearShort"),"%H":i("datebox.placeholder.hour"),"%M":i("datebox.placeholder.minute"),"%S":i("datebox.placeholder.second")}}function yo(i,e,t){let s=String(i??"").trim();if(s==="")return{start:null,end:null};let n=String(t??" \u2013 "),r=n.trim(),o=r!==""&&String(e).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",l=o?"(?:\\s+|$)":"\\s*",c=r===""?[s]:s.split(new RegExp(`${a}${Ts(r)}${l}`));if(c.length>2)return null;let d=pe(c[0].trim(),e);if(!d)return null;if(c.length===1)return{start:d,end:new Date(d.getTime())};if(c[1].trim()==="")return{start:d,end:null};let h=pe(c[1].trim(),e);return h?kt(d,h):null}function wo(i,e,t){let s=i?.start??null,n=i?.end??null;return!s&&!n?"":n?s?`${M(s,e)}${t}${M(n,e)}`:M(n,e):M(s,e)}var vi=class extends S{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",displayFormat:null,separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let e=this.el??u("div");this.el=e,this._originalState=e.getAttribute("data-state"),this._originalAriaDisabled=e.getAttribute("aria-disabled"),this._originalClearable=e.getAttribute("data-clearable"),e.toggleAttribute("data-clearable",!!this.options.clearable),this._format=String(this.options.format||"%d.%m.%Y"),this._displayFormat=this.options.displayFormat?String(this.options.displayFormat):this._format,this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._focused=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let t=E("zx-date-range-box-popover"),s=u("div",{class:"zx-date-range-box__content"},u("div",{ref:"control",class:"zx-date-range-box__control"},u("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:t,ariaExpanded:"false"}),u("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:vo("daterange.clear","Clear date range")},v("x",{size:T.dismiss})),u("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:vo("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:t,ariaExpanded:"false"},v("calendar"))),u("div",{ref:"popover",id:t,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,e.append(s),this._picker=new _i(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",n=>{this._range={start:n.detail.start,end:n.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",n=>{this._apply({start:n.detail.start,end:n.detail.end},{push:!1}),n.detail.start&&n.detail.end&&this._close(!0)}),this.listen(this.refs.input,"focus",()=>{this._focused=!0,this.el.dataset.state!=="invalid"&&this._syncDisplay()}),this.listen(this.refs.input,"blur",()=>{this._focused=!1,this._open?this.refs.input.value===wo(this._range,this._format,this._separator)&&this._syncDisplay():this._commitText()}),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!e.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),e}get(e="date"){return e==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(e,{silent:t=!1}={}){return this._apply(this._coerce(e),{silent:t}),this}clear({silent:e=!1}={}){return this.set({start:null,end:null},{silent:e})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=ne(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),wi(this.el,"data-state",this._originalState),wi(this.el,"aria-disabled",this._originalAriaDisabled),wi(this.el,"data-clearable",this._originalClearable),super.destroy()}_apply(e,{silent:t=!1,push:s=!0}={}){this._range=e,s&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),t||this.emit("change",this.get())}_onInputKeydown(e){e.key==="ArrowDown"?(e.preventDefault(),this.open()):e.key==="Enter"?(e.preventDefault(),this._commitText()):e.key==="Escape"&&this._open&&(e.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let e=this.refs.input.value.trim();if(e===""){this.set({start:null,end:null});return}let t=yo(e,this._format,this._separator);if(!t){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:e});return}this._apply(this._clamp(t))}_coerce(e){return e==null?{start:null,end:null}:typeof e=="string"?this._clamp(yo(e,this._format,this._separator)??{start:null,end:null}):Array.isArray(e)?this._clamp({start:this._toDate(e[0]),end:this._toDate(e[1])}):typeof e!="object"?{start:null,end:null}:this._clamp({start:this._toDate(e.start),end:this._toDate(e.end)})}_toDate(e){return e instanceof Date?Number.isNaN(e.getTime())?null:new Date(e.getTime()):typeof e=="number"&&Number.isFinite(e)?new Date(e*1e3):typeof e=="string"&&e.trim()!==""?pe(e.trim(),this._format):null}_clamp(e){return gi(e,{min:this.options.min,max:this.options.max,minNights:this.options.minNights,maxNights:this.options.maxNights})}_placeholder(){let e=yi(s=>this.msg(s)),t=this._format.replace(/%[demYy]/g,s=>e[s]??s);return`${t}${this._separator}${t}`}_syncDisplay(){let e=this.refs.input,t=this._focused?this._format:this._displayFormat,s=wo(this._range,t,this._separator);e.value!==s&&(e.value=s),this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!(this._range.start||this._range.end)||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear(),this._disabled?this._picker?.disable():this._picker?.enable()}_setValid(){this.el.dataset.state==="invalid"&&wi(this.el,"data-state",this._originalState),this.refs.input.removeAttribute("aria-invalid")}_close(e){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),e&&this.focus(),this.emit("close"))}};function vo(i,e,t){let s=R(i);return F(s===i?e:s,t)}function wi(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}function xo(){C.register("daterange",(i,e)=>{let t=i.own(new vi(null,{...e.props??{},disabled:!!e.disabled,start:e.value?.start??null,end:e.value?.end??null}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:{start:s.detail.start,end:s.detail.end}})),{el:t.el,get:()=>t.get(),set:s=>t.set(s,{silent:!0}),focus:()=>t.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var Ve=class extends S{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",displayFormat:null,time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let e=this.el??u("div");this.el=e,this._originalState=e.getAttribute("data-state"),this._originalAriaDisabled=e.getAttribute("aria-disabled"),this._originalClearable=e.getAttribute("data-clearable"),e.toggleAttribute("data-clearable",!!this.options.clearable);let t=Zu(this.options);this._format=t.format,this._displayFormat=t.display,this._disabled=!!this.options.disabled,this._open=!1,this._focused=!1,this._position=null,this._min=So(this.options.min),this._max=So(this.options.max),this._value=this._normalizeValue(this.options.value);let s=E("zx-datebox-popover"),n=u("div",{class:"zx-datebox__content"},u("div",{ref:"control",class:"zx-datebox__control"},u("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??Gu(this._format,r=>this.msg(r)),"aria-haspopup":"grid",ariaControls:s,ariaExpanded:"false"}),u("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:this.msg("datebox.clear")},v("x",{size:T.dismiss})),u("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:this.msg("datebox.choose"),"aria-haspopup":"grid",ariaControls:s,ariaExpanded:"false"},v("calendar"))),u("div",{ref:"popover",id:s,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=n,e.append(n),this._picker=new Je(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",r=>{this.set(r.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"focus",()=>{this._focused=!0,this.el.dataset.state!=="invalid"&&this._syncDisplay()}),this.listen(this.refs.input,"blur",()=>{this._focused=!1,this._commitText()}),this.listen(this.refs.input,"keydown",r=>this._onInputKeydown(r)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",r=>{r.key==="ArrowDown"&&(r.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",r=>{!this._open||r.defaultPrevented||r.key!=="Escape"||(r.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",r=>{this._open&&!e.contains(r.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),e}get(e="date"){return this._value?e==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(e,{silent:t=!1}={}){return this._value=this._normalizeValue(e),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),t||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=ne(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),this._originalClearable===null?this.el.removeAttribute("data-clearable"):this.el.setAttribute("data-clearable",this._originalClearable),super.destroy()}_onInputKeydown(e){e.key==="ArrowDown"?(e.preventDefault(),this.open()):e.key==="Enter"?(e.preventDefault(),this._commitText()):e.key==="Escape"&&this._open&&(e.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let e=this.refs.input.value.trim(),t=this._value?M(this._value,this._format):"";if(e===t){this._setValid(),this._syncDisplay();return}let s=e===""?null:pe(e,this._format);if(e!==""&&!s){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:e});return}let n=this._normalizeValue(s),r=(n?.getTime()??null)===(this._value?.getTime()??null);this.set(n,{silent:r})}_normalizeValue(e){let t=null;return e instanceof Date&&!Number.isNaN(e.getTime())?t=new Date(e.getTime()):typeof e=="number"&&Number.isFinite(e)?t=new Date(e*1e3):typeof e=="string"&&(t=pe(e,this._format)),!t||Number.isNaN(t.getTime())?null:Hr(t,this._min,this._max)}_syncDisplay(){let e=this.refs.input,t=this._focused?this._format:this._displayFormat,s=this._value?M(this._value,t):"";e.value!==s&&(e.value=s),this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!this._value||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear()}_setValid(){this.el.dataset.state==="invalid"&&(this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState)),this.refs.input.removeAttribute("aria-invalid")}_close(e){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),e&&this.focus(),this.emit("close"))}_copyValue(){return this._value?new Date(this._value.getTime()):null}},ko=function(e,t={}){return new Ve(e,{...t,time:!0})};function So(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Zu({format:i=null,displayFormat:e=null,time:t=!1}={}){let s=Ao(i,t);return{format:s,display:e?Ao(e,t):s}}function Ao(i,e){let t=String(i||"%d.%m.%Y");return e&&!/%[HM]/.test(t)?`${t} %H:%M`:t}function Gu(i,e){let t=yi(e);return i.replace(/%[demYyHMS]/g,s=>t[s]??s)}function To(){Co("date",i=>new Ve(null,i)),Co("datetime",i=>ko(null,i))}function Co(i,e){C.register(i,(t,s)=>{let n=t.own(e({...s.props??{},value:s.value}));return t.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>t.emit("change",{value:r.detail.date})),{el:n.el,get:()=>n.get(),set:r=>n.set(r,{silent:!0}),focus:()=>n.focus(),setDisabled:r=>r?n.disable():n.enable()}})}var Ct=class{base;headers;onError;timeout;constructor({base:e="",headers:t={},onError:s=null,timeout:n=3e4}={}){this.base=String(e),this.headers=Object.freeze({...t}),this.onError=s,this.timeout=Number(n)}async request(e,t={}){let{method:s="GET",data:n=null,files:r=null,query:o=null,headers:a={},signal:l=null,paramName:c="files"}=t,d=new AbortController,h=()=>d.abort(l?.reason);l?.aborted?h():l?.addEventListener("abort",h,{once:!0});let p=this.timeout>0?setTimeout(()=>{d.abort(new DOMException("Request timed out","TimeoutError"))},this.timeout):null;try{d.signal.throwIfAborted();let f=new Headers(this.headers);for(let[A,y]of Object.entries(a))f.set(A,y);f.set("Accept",f.get("Accept")??"application/json");let m;r!==null?(m=Ju(n,r,String(c)),f.delete("Content-Type")):n!==null&&s.toUpperCase()!=="GET"&&s.toUpperCase()!=="HEAD"&&(m=JSON.stringify(n),f.set("Content-Type",f.get("Content-Type")??"application/json"));let g=Qu(this.base+e,o),_=await fetch(g,{method:s.toUpperCase(),headers:f,body:m,signal:d.signal}),b=await _.text();d.signal.throwIfAborted();let w=null;if(b!=="")try{w=JSON.parse(b)}catch(A){let y=new Error("Invalid JSON response",{cause:A});throw y.response=_,y}if(!_.ok){try{xi(w)}catch(y){throw y.response=_,y}let A=new Error(`HTTP ${_.status} ${_.statusText}`.trim());throw A.response=_,A}return xi(w)}catch(f){let m=f instanceof Error?f:new Error(String(f));if(this.onError)try{this.onError(m,{path:e,options:t})}catch{}throw m}finally{p!==null&&clearTimeout(p),l?.removeEventListener("abort",h)}}get(e,t=null){return this.request(e,{method:"GET",query:t})}post(e,t=null){return this.request(e,{method:"POST",data:t})}put(e,t=null){return this.request(e,{method:"PUT",data:t})}delete(e,t=null){return this.request(e,{method:"DELETE",data:t})}};function xi(i){if(i&&typeof i=="object"){if(Object.prototype.hasOwnProperty.call(i,"error")&&i.error!=null&&i.error!==!1&&i.error!==0){let e=typeof i.error=="string"?i.error:JSON.stringify(i.error);throw new Error(e||"Server error")}if(Object.prototype.hasOwnProperty.call(i,"result"))return i.result}return i}function Qu(i,e){if(e==null)return i;let t;if(typeof e=="string")t=e.replace(/^\?/,"");else if(e instanceof URLSearchParams)t=e.toString();else{let s=new URLSearchParams;for(let[n,r]of Object.entries(e))zo(s,n,r);t=s.toString()}return t?i+(i.includes("?")?"&":"?")+t:i}function zo(i,e,t){if(t!=null)if(Array.isArray(t))for(let s of t)zo(i,e,s);else i.append(e,typeof t=="object"?JSON.stringify(t):String(t))}function Ju(i,e,t){let s=new FormData;if(i&&typeof i=="object"&&!Array.isArray(i))for(let[r,o]of Object.entries(i))Eo(s,r,o);else i!=null&&s.append("data",typeof i=="string"?i:JSON.stringify(i));let n=Xu(e)||Array.isArray(e)?Array.from(e):[e];for(let r of n)s.append(t,r);return s}function Eo(i,e,t){if(t!=null)if(Array.isArray(t))for(let s of t)Eo(i,e,s);else{let s=typeof Blob=="function"&&t instanceof Blob;i.append(e,typeof t=="object"&&!s?JSON.stringify(t):t)}}function Xu(i){return typeof FileList=="function"&&i instanceof FileList}var Si=class extends S{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let e=this.el??u("div");this.el=e,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=e.getAttribute("data-state"),this._initialDisabled=e.getAttribute("data-disabled");let t=E("zx-upload");return this._input=u("input",{class:"zx-field-upload__input",id:t,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=u("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:t,ariaLabel:this.msg(this.options.multiple?"fieldUpload.chooseMany":"fieldUpload.choose")},u("span",{class:"zx-field-upload__prompt"},this.msg(this.options.multiple?"fieldUpload.dropMany":"fieldUpload.drop")),u("span",{class:"zx-field-upload__hint"},ed(this))),this._preview=u("div",{class:"zx-field-upload__preview"}),this._progress=u("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:this.msg("fieldUpload.progress")}),this._progressText=u("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=u("button",{class:"zx-btn zx-field-upload__abort",type:"button"},this.msg("fieldUpload.abort")),this._progressWrap=u("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=u("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),e.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragover",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragleave",s=>{(!(s.relatedTarget instanceof Node)||!this._dropzone.contains(s.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",s=>{s.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(s.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),e}async upload(e=null){if(e!==null&&!this._setFiles(e)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let t=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent=this.msg("fieldUpload.uploading");try{let s=this.options.http?await this._uploadInjected():await this._uploadXhr();return t!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent=this.msg("fieldUpload.complete"),this.emit("success",{response:s}),s)}catch(s){if(t!==this._runId)return null;let n=s instanceof Error?s:new Error(String(s));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(e){return this._disabled=!!e,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(e){this._setFiles(e)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(e){if(this._disabled||this._running)return!1;let t=Array.from(e??[]),s=this.options.multiple?t:t.slice(0,1);if(s.length===0)return!1;let n=s.find(o=>!id(o,this.options.accept));if(n)return this._selectionError(new Error(this.msg("fieldUpload.rejectedType",n.name))),!1;let r=this.options.maxSize==null?null:s.find(o=>o.size>Number(this.options.maxSize));return r?(this._selectionError(new Error(this.msg("fieldUpload.rejectedSize",r.name))),!1):(this._files=s,this._renderPreview(),this._status.textContent=s.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(e){e.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let e=this.options.http;if(e instanceof Ct&&e.request===Ct.prototype.request&&typeof e.upload!="function")return this._uploadXhr(e);this._transportController=new AbortController;let t=this._runId,s={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:n=>{this._running&&t===this._runId&&this._setProgress(n)}};return typeof e.upload=="function"?e.upload(String(this.options.url),s):typeof e.request=="function"?e.request(String(this.options.url),{method:"POST",data:s.params,files:s.files,headers:s.headers,signal:s.signal,onProgress:s.onProgress,paramName:s.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}async _uploadXhr(e=null){let t=String(this.options.url),s={method:"POST",data:this.options.params,files:this._files.slice(),headers:this.options.headers,paramName:String(this.options.paramName)},n=this._runId,r=[],o=(a,l,c)=>{this.listen(a,l,c),r.push(()=>a.removeEventListener(l,c))};try{if(typeof XMLHttpRequest!="function")throw new Error("XMLHttpRequest is not available");return await new Promise((a,l)=>{let c=new XMLHttpRequest;this._xhr=c,c.open("POST",(e?.base??"")+t),e&&(c.timeout=e.timeout>0?e.timeout:0);let d=new Headers(e?.headers);for(let[h,p]of Object.entries(s.headers??{}))d.set(h,String(p));e&&!d.has("Accept")&&d.set("Accept","application/json"),d.delete("Content-Type");for(let[h,p]of d)c.setRequestHeader(h,p);o(c.upload,"progress",h=>{this._running&&n===this._runId&&h.lengthComputable&&this._setProgress(h.loaded/h.total*100)}),o(c,"load",()=>{try{let h=nd(c.responseText);if(e){try{h=c.responseText?JSON.parse(c.responseText):null}catch(p){throw new Error("Invalid JSON response",{cause:p})}h=xi(h)}if(c.status<200||c.status>=300)throw new Error(this.msg("fieldUpload.httpFailed",c.status));a(h)}catch(h){h.response=c,l(h)}}),o(c,"error",()=>l(new Error(this.msg("fieldUpload.requestFailed")))),o(c,"abort",()=>l(rd())),o(c,"timeout",()=>l(new DOMException("Request timed out","TimeoutError"))),c.send(sd(s.files,s.paramName,s.data))})}catch(a){try{e?.onError?.(a,{path:t,options:s})}catch{}throw a}finally{for(let a of r)a()}}_setProgress(e){let t=Math.max(0,Math.min(100,Number(e)||0));this._progress.value=t,this._progressText.textContent=`${Math.round(t)}%`,this.emit("progress",{percent:t})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent=this.msg("fieldUpload.aborted"),this.emit("abort",{}))}_selectionError(e){this._setState("error"),this._status.textContent=e.message,this.emit("error",{error:e})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let e=this._files[0];!this.options.preview||!e?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(e),this._preview.append(u("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:this.msg("fieldUpload.preview",e.name)})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(e){e==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=e}destroy(){this._running&&this.abort(),this._revokePreview();for(let e of this._ownedNodes??[])e.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function ed(i){let{accept:e,maxSize:t}=i.options,s=[];return e&&s.push(String(e)),t!=null&&s.push(i.msg("fieldUpload.maxSize",td(Number(t)))),s.join(" \xB7 ")||i.msg("fieldUpload.hint")}function td(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function id(i,e){if(!e)return!0;let t=String(i.type??"").toLowerCase();return String(e).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean).some(s=>s.startsWith(".")?i.name.toLowerCase().endsWith(s):s.endsWith("/*")?t.startsWith(s.slice(0,-1)):t===s)}function sd(i,e,t){let s=new FormData;for(let n of i)s.append(e,n);for(let[n,r]of Object.entries(t??{}))Io(s,n,r);return s}function Io(i,e,t){if(t==null)return;if(Array.isArray(t)){for(let n of t)Io(i,e,n);return}typeof Blob=="function"&&t instanceof Blob?i.append(e,t):i.append(e,typeof t=="object"?JSON.stringify(t):String(t))}function nd(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function rd(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function Mo(){C.register("upload",(i,e)=>{let t=i.own(new Si(null,{...e.props??{}}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("select",()=>i.emit("change",{value:null})),{el:t.el,get:()=>null,set:()=>t.clear(),focus:()=>t.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:s=>t.setDisabled(s)}})}var Do=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),No=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),Ai=class extends S{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:null,reorder:"both"};render(){let e=this.el??u("div");return this.el=e,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=e.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=u("div",{class:"zx-multi-value-editor__rows"}),this._add=u("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??this.msg("multiValueEditor.add"))),this._ownedNodes.push(this._rows,this._add),e.append(this._rows,this._add),this.listen(e,"click",t=>this._handleClick(t)),this.listen(this._rows,"change",t=>this._handleChange(t)),this.listen(this._rows,"keydown",t=>this._handleKeydown(t)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",t=>this._handlePointerDown(t)),this.listen(this._rows,"dragstart",t=>this._handleDragStart(t)),this.listen(this._rows,"dragover",t=>this._handleDragOver(t)),this.listen(this._rows,"dragleave",t=>this._handleDragLeave(t)),this.listen(this._rows,"drop",t=>this._handleDrop(t)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),e}getValues(){return this._values.slice()}setValues(e,{silent:t=!1}={}){return this._values=Array.isArray(e)?e.map(String):[],this._renderRows(),t||this.emit("change",{values:this.getValues()}),this}_reorder(){return Do[this.options.reorder]??Do.both}_renderRows(e=-1,t="value"){let s=Oo(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,l=this._values.map((c,d)=>{let h=!n||s.some(([f])=>f===c)?s:[[c,c],...s],p=n?u("select",{class:"zx-multi-value-editor__value",ariaLabel:this.msg("multiValueEditor.value",d+1),dataset:{index:d}},h.map(([f,m])=>u("option",{value:f,selected:f===c},m))):u("input",{class:"zx-multi-value-editor__value",type:"text",value:c,ariaLabel:this.msg("multiValueEditor.value",d+1),dataset:{index:d}});return u("div",{class:"zx-multi-value-editor__row",dataset:{row:d}},r?u("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:this.msg("multiValueEditor.reorder",d+1),dataset:{action:"grab",index:d}},v("drag",{size:12})):null,p,u("div",{class:"zx-multi-value-editor__controls"},o?u("button",{class:"zx-btn",type:"button",ariaDisabled:String(d===0),ariaLabel:this.msg("multiValueEditor.moveUp",d+1),dataset:{action:"up",index:d}},v("chevron-up",{size:T.chevron})):null,o?u("button",{class:"zx-btn",type:"button",ariaDisabled:String(d===a),ariaLabel:this.msg("multiValueEditor.moveDown",d+1),dataset:{action:"down",index:d}},v("chevron-down",{size:T.chevron})):null,u("button",{class:"zx-btn",type:"button",ariaLabel:this.msg("multiValueEditor.remove",d+1),dataset:{action:"remove",index:d}},v("x",{size:T.dismiss}))))});this._rows.replaceChildren(...l),e>=0&&l[Math.min(e,l.length-1)]?.querySelector(No[t]??No.value)?.focus()}_handleClick(e){let t=e.target instanceof Element?e.target.closest("[data-action]"):null;if(!t||!this.el.contains(t)||t.getAttribute("aria-disabled")==="true")return;let s=t.dataset.action,n=Number(t.dataset.index);if(s==="add"){let r=Oo(this.options.options);this._values.push(this.options.options===null?"":r[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else s==="remove"&&Number.isInteger(n)?(this._values.splice(n,1),this._renderRows(Math.min(n,this._values.length-1)),this._emitChange()):(s==="up"||s==="down")&&Number.isInteger(n)&&this._move(n,n+(s==="up"?-1:1),s)}_handleChange(e){let t=e.target instanceof Element?e.target.closest("[data-index]"):null;if(!t||!("value"in t))return;let s=Number(t.dataset.index);!Number.isInteger(s)||s<0||s>=this._values.length||(this._values[s]=t.value,this._emitChange())}_handleKeydown(e){let t=e.target instanceof Element?e.target.closest(".zx-multi-value-editor__handle"):null;if(!t)return;let s=Number(t.dataset.index),n=e.key==="ArrowUp"?s-1:e.key==="ArrowDown"?s+1:e.key==="Home"?0:e.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(e.preventDefault(),this._move(s,n,"handle"))}_handlePointerDown(e){let t=e.target instanceof Element?e.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!t||t.disabled)return;let s=t.closest(".zx-multi-value-editor__row");s&&(s.draggable=!0,this._armed=s)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(e){let t=e.target instanceof Element?e.target.closest(".zx-multi-value-editor__row"):null;if(!t||t!==this._armed){e.preventDefault();return}this._dragIndex=Number(t.dataset.row),t.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),e.dataTransfer?.setData("text/plain",String(this._dragIndex)),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")}_handleDragOver(e){this._dragIndex<0||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(e.clientY)))}_handleDragLeave(e){let t=e.relatedTarget;t instanceof Node&&this._rows.contains(t)||this._clearDrop()}_handleDrop(e){if(this._dragIndex<0)return;e.preventDefault();let t=this._dragIndex,s=this._dropTarget(e.clientY);this._finishDrag(),this._move(t,s>t?s-1:s,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let e of this._rows.children)delete e.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(e){let t=[...this._rows.children];for(let[s,n]of t.entries()){let r=n.getBoundingClientRect();if(e<r.top+r.height/2)return s}return t.length}_showDrop(e){let t=[...this._rows.children],s=e===this._dragIndex||e===this._dragIndex+1;for(let[n,r]of t.entries()){let o=r;!s&&n===e?o.dataset.drop="before":!s&&e===t.length&&n===t.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let e of this._rows.children)delete e.dataset.drop}_move(e,t,s){let n=this._values.length;if(e===t||e<0||t<0||e>=n||t>=n)return!1;let[r]=this._values.splice(e,1);return this._values.splice(t,0,r),this._renderRows(t,s),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let e of this._ownedNodes??[])e.remove();super.destroy()}};function Oo(i){return Array.isArray(i)?i.map(e=>[String(e),String(e)]):i&&typeof i=="object"?Object.entries(i).map(([e,t])=>[e,String(t)]):[]}function Ro(){C.register("multivalueeditor",(i,e)=>{let t=i.own(new Ai(null,{...e.props??{},values:Array.isArray(e.value)?e.value:[]})),s=new WeakMap,n=!1,r=()=>{t.el.setAttribute("aria-disabled",String(n));for(let o of t.el.querySelectorAll("input, button, select, textarea"))n?(s.has(o)||s.set(o,!!o.disabled),o.disabled=!0):s.has(o)&&(o.disabled=s.get(o),s.delete(o))};return i.listen(t.el,"change",o=>o.stopImmediatePropagation()),t.on("change",o=>i.emit("change",{value:o.detail.values})),{el:t.el,get:()=>t.getValues(),set:o=>{t.setValues(Array.isArray(o)?o:[],{silent:!0}),r()},focus:()=>t.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var Xe=class extends S{static cssName="number-field";static defaults={value:null,min:null,max:null,step:1,largeStep:10,precision:null,snap:!0,wrap:!1,placeholder:"",label:null,unit:null,disabled:!1,readonly:!1,required:!1,name:null,group:!1,locale:null};render(){this._value=null,this._disabled=!1,this._readonly=!1,this._editing=!1,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:Z(this.el);let e=this.el??u("div");this.el=e;let t=od(this.options.step);this._step=t,this._snap=this.options.snap!==!1;let s=this.options.precision!==null&&this.options.precision!==void 0;this._precision=s?Math.max(0,Math.trunc(Number(this.options.precision)||0)):Fo(t),this._fixedPrecision=this._snap||s;let n=this._stepButton("down","minus"),r=this._stepButton("up","plus"),o=u("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0||!this._fixedPrecision?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),a=[n,o];return this.options.unit!==null&&a.push(u("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),a.push(r),e.replaceChildren(...a),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"input",()=>this._onInput()),this.listen(o,"keydown",l=>this._onKeydown(l)),this.listen(o,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(o,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(n,"click",()=>this._stepBy(-1)),this.listen(r,"click",()=>this._stepBy(1)),this.listen(o,"wheel",l=>{document.activeElement!==o||this._disabled||this._readonly||(l.preventDefault(),this._stepBy(l.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),e}get value(){return this._value}set value(e){this.set(e)}get(){return this._value}set(e,{silent:t=!1}={}){let s=this._coerce(e),n=s!==this._value;return this._value=s,this._syncInput(),n&&!t&&this.emit("change",{value:this._value}),this}stepUp(e=1){return this._stepBy(e)}stepDown(e=1){return this._stepBy(-e)}reset({silent:e=!1}={}){return this.set(this.options.value,{silent:e})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(e){return this._readonly=!!e,this._syncDisabled(),this}setRange(e,t){return this._min=e==null?null:Number(e),this._max=t==null?null:Number(t),this.set(this._value,{silent:!0})}_stepButton(e,t){return u("button",{ref:e,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:e}},v(t,{size:13}))}get _rangeMin(){return this._min!==void 0?this._min:this.options.min===null||this.options.min===void 0?null:Number(this.options.min)}get _rangeMax(){return this._max!==void 0?this._max:this.options.max===null||this.options.max===void 0?null:Number(this.options.max)}_coerce(e){let t=ki(e,this.options.group?this._separators():null);return t===null?null:this._snap?Ci(t,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision}):this._decimalsFor(t)>Lo?ld(t,this._rangeMin,this._rangeMax):Ci(t,{min:this._rangeMin,max:this._rangeMax,step:0,precision:this._decimalsFor(t)})}_stepBy(e){if(this._disabled||this._readonly)return this;let t=this._rangeMin,s=this._rangeMax,r=ki(this.refs.input.value,this.options.group?this._separators(this._inputLocale):null)??this._value,o=r===null?t??0:r,a=r===null&&e>0&&t!==null?t-this._step*e:o,l=this._decimalsFor(a),c=l>Lo?a+this._step*e:Po(a+this._step*e,l);return this.options.wrap&&t!==null&&s!==null&&(c>s?c=t:c<t&&(c=s)),this.set(c),this}_separators(e=K(this.options.locale)){let t=String(e);if(this._localeSeparators&&this._separatorLocale===t)return this._localeSeparators;this._separatorLocale=t;let s=new Intl.NumberFormat(e,{minimumFractionDigits:1}).formatToParts(1234.5),n=new Intl.NumberFormat(e,{useGrouping:!1});return this._localeSeparators={group:s.find(r=>r.type==="group")?.value??",",decimal:s.find(r=>r.type==="decimal")?.value??".",minus:n.formatToParts(-1).find(r=>r.type==="minusSign")?.value??"-",digits:Object.fromEntries(Array.from({length:10},(r,o)=>[n.formatToParts(o).find(a=>a.type==="integer")?.value??String(o),String(o)]))},this._localeSeparators}_onInput(){let e=ki(this.refs.input.value,this.options.group?this._separators(this._inputLocale):null);this._syncAria(e),this.emit("input",{value:e})}_onKeydown(e){if(this._disabled||this._readonly||e.altKey||e.ctrlKey||e.metaKey)return;let t=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),n={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(t),PageDown:()=>this._stepBy(-t),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[e.key];n&&(e.key==="Home"&&this._rangeMin===null||e.key==="End"&&this._rangeMax===null||(e.preventDefault(),n()))}_commit(){this.set(ki(this.refs.input.value,this.options.group?this._separators(this._inputLocale):null))}_syncInput(){let e=this.refs.input;this._inputLocale=K(this.options.locale);let t=this._value===null?"":this._format(this._value,this._editing);e.value!==t&&(e.value=t),this._syncAria(this._value)}_syncAria(e){let t=this.refs.input,s=this._rangeMin,n=this._rangeMax;if(s===null?t.removeAttribute("aria-valuemin"):t.setAttribute("aria-valuemin",String(s)),n===null?t.removeAttribute("aria-valuemax"):t.setAttribute("aria-valuemax",String(n)),e===null)t.removeAttribute("aria-valuenow"),t.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{t.setAttribute("aria-valuenow",String(e));let r=this.options.unit===null?"":` ${this.options.unit}`;t.setAttribute("aria-valuetext",`${this._format(e,!1)}${r}`)}this.el.toggleAttribute("data-empty",e===null)}_format(e,t){let s=this._decimalsFor(e);return this.options.group?new Intl.NumberFormat(K(this.options.locale),{minimumFractionDigits:s,maximumFractionDigits:s,useGrouping:!t}).format(e):e.toFixed(s)}_decimalsFor(e){return this._fixedPrecision?this._precision:Math.min(ad,Math.max(this._precision,Fo(e)))}_message(e,t){let s=this.msg(e);return s===e?t:s}_syncDisabled(){let e=this.refs.input;e.disabled=this._disabled,e.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let e=this.el;super.destroy(),!this._createdRoot&&e&&G(e,this._snapshot)}};function ki(i,e=null){if(typeof i=="number")return Number.isFinite(i)?i:null;if(i==null)return null;let t=String(i).trim();if(t==="")return null;let s;if(e){s=t;for(let[r,o]of Object.entries(e.digits??{}))s=s.split(r).join(o);s=s.split(e.group).join("").replace(e.decimal,".").replace(e.minus??"-","-").replace(/[^\d.\-+eE]/g,"")}else{let r=t.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");s=r,o>=0&&o>a?s=r.replace(/\./g,"").replace(",","."):o>=0&&(s=r.replace(/,/g,""))}if(!/\d/.test(s))return null;let n=Number(s);return Number.isFinite(n)?n:null}function Ci(i,{min:e,max:t,step:s,precision:n}){let r=i;if(s>0){let o=e??0;r=o+Math.round((i-o)/s)*s}return r=Po(r,n),e!==null&&r<e?e:t!==null&&r>t?t:r}function od(i){let e=Number(i);return Number.isFinite(e)&&e>0?e:1}var ad=100,Lo=15;function ld(i,e,t){return e!==null&&i<e?e:t!==null&&i>t?t:i}function Fo(i){let[e,t="0"]=String(i).toLowerCase().split("e"),s=e.split(".")[1]?.length??0;return Math.max(0,s-Number(t))}function Po(i,e){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,e)))):i}function Vo(){C.register("number",(i,e)=>{let t=i.own(new Xe(null,{label:e.label?String(e.label):void 0,placeholder:e.placeholder,required:e.required,name:i.name||null,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:t.el,get:()=>t.get(),set:n=>{s=!0;try{t.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}var Ti=class extends S{static cssName="rating";static defaults={value:0,max:5,allowHalf:!1,clearable:!0,readonly:!1,disabled:!1,label:null,icon:"star",labels:null,showValue:!1,count:null,size:"md"};render(){this._value=0,this._preview=null,this._disabled=!1,this._readonly=!1,this._radios=[],this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:Z(this.el);let e=this.el??u("div");this.el=e,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=E("zx-rating");let t=u("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??this.msg("rating.label"))});for(let s=1;s<=this._max;s+=1){let n=u("span",{class:"zx-rating__symbol"},u("span",{class:"zx-rating__glyph",ariaHidden:"true"},v(this.options.icon,{size:Tt[this.options.size]??Tt.md})),u("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},v(this.options.icon,{size:Tt[this.options.size]??Tt.md})));this.options.allowHalf?n.append(this._radio(s-.5,"half"),this._radio(s,"full")):n.append(this._radio(s,"full")),t.append(n)}return e.replaceChildren(t,u("span",{ref:"readout",class:"zx-rating__readout"})),e.dataset.size=Tt[this.options.size]?this.options.size:"md",this.listen(t,"keydown",s=>this._onKeydown(s)),this.listen(t,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),e}get value(){return this._value}set value(e){this.set(e)}get(){return this._value}set(e,{silent:t=!1}={}){let s=this._clamp(e),n=s!==this._value;return this._value=s,this._preview=null,this._sync(),n&&!t&&this.emit("change",{value:this._value}),this}clear({silent:e=!1}={}){return this.set(0,{silent:e})}reset({silent:e=!1}={}){return this.set(this.options.value,{silent:e})}setCount(e){return this._count=e,this._syncReadout(),this}focus(){return(this._radios.find(t=>t.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(e){return this._readonly=!!e,this._syncDisabled(),this}_radio(e,t){let s=u("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(e),dataset:{value:String(e),part:t}});return this.listen(s,"click",n=>{this._choose(e,n.detail>0)}),this.listen(s,"pointerenter",()=>this._setPreview(e)),this.listen(s,"focus",()=>this._setPreview(e)),this.listen(s,"blur",()=>this._setPreview(null)),this._radios.push(s),s}_stepLabel(e){let t=this.options.labels;if(Array.isArray(t)){let s=Math.round(e/this._step)-1;if(t[s]!=null)return String(t[s])}return this._message("rating.value","%1 of %2",[e,this._max])}_message(e,t,s){let n=this.msg(e,...s);return n===e?F(t,s):n}_choose(e,t){this._disabled||this._readonly||(t&&this.options.clearable&&e===this._value?this.set(0):this.set(e))}_onKeydown(e){if(this._disabled||this._readonly)return;let t=["ArrowRight","ArrowDown"],s=["ArrowLeft","ArrowUp"];if(t.includes(e.key))e.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(s.includes(e.key))e.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(e.key==="Home")e.preventDefault(),this.set(this._step);else if(e.key==="End")e.preventDefault(),this.set(this._max);else if((e.key==="Delete"||e.key==="Backspace")&&this.options.clearable)e.preventDefault(),this.set(0);else return;this.focus()}_setPreview(e){let t=this._disabled||this._readonly?null:e;t!==this._preview&&(this._preview=t,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return 0;let s=Math.round(t/this._step)*this._step;return Math.min(this._max,Math.max(0,s))}_sync(){for(let t of this._radios){let s=Number(t.dataset.value);t.setAttribute("aria-checked",String(s===this._value))}let e=this._radios.find(t=>t.getAttribute("aria-checked")==="true");for(let t of this._radios)t.tabIndex=-1;(e??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let e=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((s,n)=>{let r=Math.min(1,Math.max(0,e-n));s.style.setProperty("--zx-rating-fill",`${r*100}%`),s.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(e)}_syncReadout(){let e=this.refs.readout;if(!e)return;let t=this._count===void 0?this.options.count:this._count,s=[];this.options.showValue&&s.push(cd(this._value,this._step)),t!=null&&s.push(this.msgPlural("rating.count",Number(t),t)),e.textContent=s.join(" \xB7 ")}_syncDisabled(){let e=this._disabled||this._readonly;for(let t of this._radios)t.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",e),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let e=this.el;super.destroy(),!this._createdRoot&&e&&G(e,this._snapshot)}},Tt={sm:14,md:18,lg:24};function cd(i,e){return e<1?i.toFixed(1):String(i)}function jo(){C.register("rating",(i,e)=>{let t=i.own(new Ti(null,{label:e.label?String(e.label):void 0,...e.props??{}})),s=!1;return t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:t.el,get:()=>t.get()||null,set:n=>{s=!0;try{t.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}var N_=["a[href]","area[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(",");function Bo(i,e){let t="",s=null,n=null;return function(o){let a=typeof o=="string"?o:o.key;if(typeof o!="string"&&(o.ctrlKey||o.metaKey||o.altKey)||!a||a.length!==1||/\s/.test(a))return;s!==null&&clearTimeout(s);let l=a.toLocaleLowerCase(),c=t===l;t=c?l:t+l,s=setTimeout(()=>{t="",s=null},500);let d=i(),h=c?d.indexOf(n)+1:0;for(let p=0;p<d.length;p+=1){let f=(h+p)%d.length;if(ud(d[f]).startsWith(t)){n=d[f],e(n,f);break}}}}function ud(i){if(typeof i=="string"||typeof i=="number")return String(i).trim().toLocaleLowerCase();if(i&&typeof i=="object"&&"textContent"in i)return String(i.textContent??"").trim().toLocaleLowerCase();if(i&&typeof i=="object"){let e=i,t=e.label??e.text??e.value;if(t!=null)return String(t).trim().toLocaleLowerCase()}return String(i??"").trim().toLocaleLowerCase()}var dd=/^var\(\s*--[\w-]+\s*\)$/;function zi(i){if(typeof i!="string")return null;let e=i.trim();return dd.test(e)||ze(e)?e:null}var qs=Object.freeze("AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS XK YE YT ZA ZM ZW".split(" ")),hd=127397;function ee(i){let e=typeof i=="string"?i.trim():"";return/^[a-z]{2}$/i.test(e)?e.toUpperCase():null}function qo(i){let e=ee(i);return e?String.fromCodePoint(...[...e].map(t=>t.charCodeAt(0)+hd)):""}function Ho(i=globalThis.document){let e=i?.createElement?.("canvas")??null,t=null;try{t=e?.getContext?.("2d",{willReadFrequently:!0})??null}catch{t=null}if(!e||!t)return!1;let s=24;e.width=s,e.height=s,t.textBaseline="top",t.font=`${s-4}px sans-serif`,t.fillText(qo("DE"),0,0);let n;try{n=t.getImageData(0,0,s,s).data}catch{return!1}for(let r=0;r<n.length;r+=4)if(n[r+3]>0&&(n[r]!==n[r+1]||n[r+1]!==n[r+2]))return!0;return!1}function fd(i,e){return String(i).replaceAll("{code}",e.toLowerCase()).replaceAll("{CODE}",e.toUpperCase())}function pd(i,e={}){let{kind:t="auto",src:s=null,text:n=null,label:r=null}=e??{},o=ee(i),a=s?"image":t;a==="auto"&&(a=Ho()?"emoji":"code"),(!o||a==="image"&&!s)&&(a="code");let l;a==="image"?l=u("img",{class:"zx-flag__image",src:fd(s,o),alt:"",loading:"lazy",decoding:"async"}):a==="emoji"?l=qo(o):(a="code",l=String(n??o??"").trim());let c=u("span",{class:"zx-flag",dataset:{kind:a,...o?{region:o}:{}}},l),d=r==null?"":String(r).trim();return d?(c.setAttribute("role","img"),c.setAttribute("aria-label",d)):c.setAttribute("aria-hidden","true"),c}function Ei(i,e){if(typeof i=="function")return(s,n,r)=>i(s,r);if(i==="none"||i===!1)return()=>null;let t=i==="emoji"||i==="code"?i:"auto";return e&&t!=="code"?t="image":t==="auto"&&(t=Ho()?"emoji":"code"),(s,n)=>pd(s,{kind:t,src:t==="image"?e:null,text:n||null})}var md=Object.freeze(["en","de","fr","es","it","pt","nl","pl","cs","sv","da","fi","nb","tr","ru","uk","el","ar","he","hi","ja","ko","zh"]);function Ii(i,e={}){let t=e.displayLocale||X()||"en",s=e.display??"both",n=e.flagRegions??{},r=$o(t,"language"),o=new Set,a=[];for(let l of Array.isArray(i)?i:[]){let c=typeof l=="string"?{code:l}:l,d=Mi(c?.code);if(!d||o.has(d))continue;o.add(d);let h=new Intl.Locale(d),p=h.baseName,f=Uo($o(p,"language")?.of(p)??p,p),m=Uo(r?.of(p)??p,t),g=c.name??(s==="localized"?m:f),_=c.description??(s==="both"&&m.toLocaleLowerCase()!==f.toLocaleLowerCase()?m:"");a.push({ID:d,name:String(g),nameLang:c.name!=null?null:s==="localized"?t:d,description:String(_),region:"region"in c?ee(c.region):_d(h,d,n),language:h.language})}if(e.sort){let l=new Intl.Collator(t);a.sort((c,d)=>l.compare(c.name,d.name))}return a}function Yo(i){let{locales:e=md,preferred:t=[],preferredLabel:s=null,displayLocale:n=null,display:r="both",flags:o="auto",flagUrl:a=null,flagRegions:l={},sort:c=!1,value:d=null,...h}=i??{},p={displayLocale:n||h.lang||h.language||X(),display:r,flagRegions:l,sort:c},f=Ii(e,p),m=Ii(t,{...p,sort:!1}),g=Ei(o,a),_=b=>g(b.region,b.language.toUpperCase(),b);return{filter:f.length+m.length>7?"local":!1,...h,label:h.label||Ko("localePicker.label",i),placeholder:h.placeholder||Ko("localePicker.placeholder",i),items:f,fixedItems:m,fixedLabel:m.length?s:null,valueKey:"ID",labelKey:"name",searchKeys:["name","description","ID"],value:typeof d=="string"?Mi(d)??d:d,renderItem:b=>gd(_(b),b.name,b.description,b.nameLang),renderValueAdornment:b=>_(b)}}function gd(i,e,t,s){return u("span",{class:"zx-select__entity"},i?u("span",{class:"zx-select__entity-icon",ariaHidden:"true"},i):null,u("span",{class:"zx-select__entity-copy"},u("span",{class:"zx-select__entity-label",...s?{lang:s}:{}},e),t?u("span",{class:"zx-select__entity-subtitle"},t):null))}function Mi(i){if(typeof i!="string"||!i.trim())return null;try{return Intl.getCanonicalLocales(i.trim().replaceAll("_","-"))[0]??null}catch{return null}}function _d(i,e,t){if(Object.hasOwn(t,e))return ee(t[e]);if(i.region)return ee(i.region);if(Object.hasOwn(t,i.language))return ee(t[i.language]);try{return ee(i.maximize().region)}catch{return null}}function $o(i,e){try{return new Intl.DisplayNames([i,"en"],{type:e,fallback:"code",languageDisplay:"standard"})}catch{return null}}function Uo(i,e){let[t="",...s]=String(i);try{return t.toLocaleUpperCase(e)+s.join("")}catch{return t.toUpperCase()+s.join("")}}function Ko(i,e){return S.prototype.msg.call({options:e},i)}function Di(i=qs,e={}){let t=e.displayLocale||X()||"en",s=Wo(t),n=Wo("en"),r=new Set,o=[];for(let a of Array.isArray(i)?i:[]){let l=typeof a=="string"?{code:a}:a,c=ee(l?.code);!c||r.has(c)||(r.add(c),o.push({ID:c,name:String(l.name??s?.of(c)??c),description:String(l.description??(e.showCode?c:"")),alias:String(n?.of(c)??c)}))}if(e.sort??!0){let a=new Intl.Collator(t);o.sort((l,c)=>a.compare(l.name,c.name))}return o}function Go(i){let{countries:e=qs,preferred:t=[],preferredLabel:s=null,displayLocale:n=null,flags:r="auto",flagUrl:o=null,showCode:a=!1,sort:l=!0,value:c=null,...d}=i??{},h={displayLocale:n||d.lang||d.language||X(),showCode:a},p=Di(e,{...h,sort:l}),f=Di(t,{...h,sort:!1}),m=Ei(r,o),g=_=>m(_.ID,_.ID,_);return{filter:"local",...d,label:d.label||Zo("countryPicker.label",i),placeholder:d.placeholder||Zo("countryPicker.placeholder",i),items:p,fixedItems:f,fixedLabel:f.length?s:null,valueKey:"ID",labelKey:"name",searchKeys:["name","ID","alias","description"],value:typeof c=="string"?ee(c)??c:c,renderItem:_=>bd(g(_),_.name,_.description),renderValueAdornment:_=>g(_)}}function bd(i,e,t){return u("span",{class:"zx-select__entity"},i?u("span",{class:"zx-select__entity-icon",ariaHidden:"true"},i):null,u("span",{class:"zx-select__entity-copy"},u("span",{class:"zx-select__entity-label"},e),t?u("span",{class:"zx-select__entity-subtitle"},t):null))}function Wo(i){try{return new Intl.DisplayNames([i,"en"],{type:"region",fallback:"code"})}catch{return null}}function Zo(i,e){return S.prototype.msg.call({options:e},i)}var $s=Object.freeze(["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"]),Us=Object.freeze(["muted","neutral","warning","info","accent","success","danger"]),Ks=Object.freeze([["backlog","status.backlog","Backlog","dotted","muted"],["todo","status.todo","Todo","ring","neutral"],["in-progress","status.inProgress","In Progress","progress","warning"],["in-review","status.inReview","In Review","review","info"],["ready","status.ready","Ready to Merge","ready","accent"],["waiting","status.waiting","Waiting for feedback","waiting","warning"],["done","status.done","Done","done","info"],["canceled","status.canceled","Canceled","canceled","muted"],["duplicate","status.duplicate","Duplicate","duplicate","muted"]]),yd=Object.freeze({review:"in-review",cancelled:"canceled"}),Hs=4;function wd(i,e={}){let t=i&&typeof i=="object"?i:null,s=vd(t?t.ID??t.id:i),n=Ks.find(([a])=>a===s),r=String(e.indicator??t?.indicator??n?.[3]??"ring"),o=String(e.tone??t?.tone??n?.[4]??"muted");return{indicator:$s.includes(r)?r:"ring",tone:Us.includes(o)?o:"muted"}}function vd(i){let e=String(i??"").trim().toLowerCase();return yd[e]??e}function Ys(i){return i==null||i===""?null:Math.max(0,Math.min(Hs,Math.trunc(Number(i)||0)))}function Qo(i,e={}){let{indicator:t,tone:s}=wd(i,e??{}),n=u("span",{class:"zx-status-icon",dataset:{indicator:t,tone:s}});return t==="done"&&n.append(v("check",{size:T.marker})),t==="canceled"&&n.append(v("x",{size:T.marker})),Xo(n,e?.label)}function Jo(i,e={}){let t=Ys(i),s=u("span",{class:"zx-priority-icon",dataset:{level:t===null?"none":t}},t===Hs?null:Array.from({length:Hs},(n,r)=>u("span",{dataset:{filled:String(t!==null&&r<=t)}})));return Xo(s,e?.label)}function Xo(i,e){let t=e==null?"":String(e).trim();return t?(i.setAttribute("role","img"),i.setAttribute("aria-label",t)):i.setAttribute("aria-hidden","true"),i}var Ws=Symbol("normalizeSelectValue"),xd=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],ea=["Lowest","Low","Medium","High","Highest"],q=class i extends S{static cssName="select";static defaults={items:[],fixedItems:[],fixedLabel:null,valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],value:null,disabled:!1,placeholder:"",label:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._actions=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._snapshot=null,this._pointerModality=!1,this._normalizeValue=this.options[Ws]??(h=>h),this._createdRoot=this.el===null;let e=this.el??u("div");this.el=e,this._root=e,this._snapshot=this._createdRoot?null:Z(e);let t=E("zx-select-list"),s=u("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",ariaLabel:String(this.options.label||this.options.placeholder||this._message("select.label","Select")),autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:t,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),n=u("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),r=u("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},v("x",{size:T.dismiss})),o=u("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=u("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},v("chevron-down",{size:T.chevron})),l=u("div",{ref:"control",class:"zx-select__control"},n,s,r,o,a),c=u("div",{ref:"list",class:"zx-select__list",id:t,role:"listbox"});c.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let d=u("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},c);return e.replaceChildren(l,d),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=ta(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=Bo(()=>this._optionEntries.filter(h=>!h.clear&&!h.action).map(h=>h.element),(h,p)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(p))}),this.listen(s,"click",()=>this.open()),this.listen(s,"input",()=>this._onInput()),this.listen(s,"keydown",h=>{sa(h)||e.removeAttribute("data-focus-origin"),this._onKeydown(h)}),this.listen(s,"focus",()=>{this._pointerModality&&s.readOnly?e.setAttribute("data-focus-origin","pointer"):e.removeAttribute("data-focus-origin")}),this.listen(s,"blur",()=>e.removeAttribute("data-focus-origin")),this.listen(document,"keydown",h=>{sa(h)||(this._pointerModality=!1)},{capture:!0}),this.listen(a,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(d,"pointerdown",h=>h.preventDefault()),this.listen(d,"click",h=>this._onOptionClick(h)),this.listen(document,"pointerdown",h=>{this._pointerModality=!0,this._open&&!e.contains(h.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),e}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(e){this.set(e)}get(){return this.value}get selected(){return this._selected}set(e,{silent:t=!1}={}){let s=this.value,n=typeof e=="string"?this._normalizeValue(e):e,r=n==null?null:this._findItem(n);this._selected=r,this._syncInputValue(),this._renderOptions();let o=this.value;return!t&&!Object.is(s,o)&&this.emit("change",{value:o,item:r}),this}setItems(e){let t=this.value;return this._cancelQuery(),this._setLoading(!1),this._items=Array.isArray(e)?e.slice():[],this._visibleItems=this._items.slice(),this._selected=t==null?null:this._findItem(t),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(e){let t=this.value;return this._fixedItems=Array.isArray(e)?e.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=t==null?null:this._findItem(t),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setActions(e){return this._actions=ta(e),this._renderOptions(),this._position?.update(),this}reset({silent:e=!1}={}){return this.set(this.options.value,{silent:e}),this}open(){return this._openPanel(!0)}_openPanel(e){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=ne(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),e&&this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static locale(e,t={}){let s=new i(e,{...Yo(t),[Ws]:n=>Mi(n)??n});return s.el.setAttribute("data-preset","locale"),s}static localeItems(e,t={}){return Ii(e,t)}static country(e,t={}){let s=new i(e,{...Go(t),[Ws]:n=>ee(n)??n});return s.el.setAttribute("data-preset","country"),s}static countryItems(e,t={}){return Di(e,t)}static priority(e,t={}){let s=t.value??null,n=t.clearable??!0,r=null,o=()=>t.noneLabel??(r?r._message("priority.none","No priority"):"No priority");r=new i(e,{...t,clearable:n,value:null,items:[],renderItem(l){return ia(l,!0)},renderNone:t.renderNone??(()=>ia({level:null,name:o()},!0)),renderValueAdornment(l){return ra(l.level)}}),n&&!t.placeholder&&(r.refs.input.placeholder=o());let a=r;return r.setItems(xd.map((l,c)=>{let d=c===2?a.msg("priority.medium"):l;return(d==="priority.medium"||c!==2)&&(d=a._message(l,ea[c])),{ID:c,name:d,level:c}})),r.set(s,{silent:!0}),r}static status(e,t={}){let{items:s=null,value:n=null,...r}=t,o=new i(e,{...r,value:null,items:[],renderItem(l){return Cd(l)},renderValueAdornment(l){return oa(l)}}),a=Array.isArray(s)?s.map(kd).filter(Boolean):Ks.map(([l,c,d,h,p],f)=>({ID:l,name:o._message(c,d),indicator:h,tone:p,shortcut:String(f+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static entity(e,t={}){let{recent:s=[],recentLabel:n=Qs("select.recent",t),create:r=!1,iconKey:o="icon",colorKey:a="color",subtitleKey:l="description",renderIcon:c=null,fixedItems:d=[],actions:h=[],renderItem:p=null,renderValueAdornment:f=null,...m}=t,g=(w,A=!1)=>{if(typeof c=="function")return c(w,{selected:A});let y=Ni(w,o);if(y&&typeof y=="object"&&typeof y.nodeType=="number")return y.cloneNode(!0);if(typeof y!="string"||!y)return null;let x=zi(Ni(w,a));return u("span",{class:"zx-select__entity-glyph",style:x?{"--zx-select-entity-color":x}:null,ariaHidden:"true"},v(y,{size:14}))},_=r?Sd(r,t):null,b=new i(e,{...m,fixedItems:[...Array.isArray(s)?s:[],...Array.isArray(d)?d:[]],fixedLabel:Array.isArray(s)&&s.length?n:m.fixedLabel??null,actions:[...Array.isArray(h)?h:[],..._?[_]:[]],renderItem:p??(w=>{let A=g(w,!1),y=Ni(w,l),x=u("span",{class:"zx-select__entity-copy"},u("span",{class:"zx-select__entity-label"},String(Ni(w,m.labelKey??"name")??"")),y==null||y===""?null:u("span",{class:"zx-select__entity-subtitle"},String(y)));return u("span",{class:"zx-select__entity"},A?u("span",{class:"zx-select__entity-icon",ariaHidden:"true"},A):null,x)}),renderValueAdornment:f??(w=>g(w,!0))});return b.el.dataset.preset="entity",b}static permission(e,t={}){let{groups:s=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...l}=t,c=typeof s=="function"?s:null,d=c?[]:s,h=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],p=new i(e,{filter:c??a,...l,value:null,items:d,fixedItems:[],valueKey:f=>h.includes(f)?f.ID:Gs(f,r),labelKey:f=>h.includes(f)?f.name:String(Gs(f,o)??"")});return h[0].name=p._message("permission.private","Private"),h[1].name=p._message("permission.public","Public"),p.setFixedItems(h),p.set(n,{silent:!0}),p}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let e=this.el;!this._createdRoot&&e&&G(e,this._snapshot),super.destroy()}_onKeydown(e){if(!this._disabled){if(this._open&&na(e)){let t=this._optionEntries.findIndex(s=>!s.clear&&!s.action&&String(s.item?.shortcut??"")===e.key);if(t>=0){e.preventDefault(),this._setActive(t),this._chooseEntry(this._optionEntries[t]);return}}if(e.key==="ArrowDown"){e.preventDefault(),this._open?this._moveActive(1):this.open();return}if(e.key==="ArrowUp"){e.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(e.key==="Home"&&this._open){e.preventDefault(),this._setActive(0);return}if(e.key==="End"&&this._open){e.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(e.key==="Enter"&&this._open){e.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(e.key==="Escape"&&this._open){e.preventDefault(),this.close();return}if(e.key==="Tab"&&this._open){this.close();return}!this.options.filter&&na(e)&&this._handleTypeahead(e)}}_onInput(){if(!this.options.filter)return;let e=this.refs.input.value;this._syncValueAdornment(),this._open||this._openPanel(!1),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(e),this._visibleItems=Ee(this._items,e,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(e)}_onOptionClick(e){let t=e.target?.closest?.('[role="option"]');!t||!this.refs.panel.contains(t)||this._chooseEntry(this._optionEntries[Number(t.getAttribute("data-index"))])}_chooseEntry(e){if(e){if(e.action){let t={id:e.action.id,action:e.action,query:this.refs.input.value,select:this};this.emit("action",t).defaultPrevented||e.action.invoke?.(t),this.close(),this.focus();return}this.set(e.clear?null:e.item),this.close(),this.focus()}}_moveActive(e){let t=this._optionEntries.length;t!==0&&this._setActive((this._activeIndex+e+t)%t)}_setActive(e){this._activeIndex=e>=0&&e<this._optionEntries.length?e:-1,this._optionEntries.forEach((s,n)=>{n===this._activeIndex?s.element.setAttribute("data-active","true"):s.element.removeAttribute("data-active")});let t=this._optionEntries[this._activeIndex]?.element;t?(this.refs.input.setAttribute("aria-activedescendant",t.id),t.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let e=this.refs.list;if(!e)return;e.replaceChildren(),this._optionEntries=[];let t=Symbol("initial-group"),s=this._uniqueItems(this._visibleFixed),n=this._uniqueItems(this._visibleItems,s);this.options.clearable&&this._appendOption(null,!0,this.options.noneLabel??this._message("select.none","No selection")),s.length>0&&this.options.fixedLabel&&e.append(u("div",{class:"zx-select__group",role:"presentation"},String(this.options.fixedLabel)));for(let r of s)this._appendOption(r,!1);s.length>0&&n.length>0&&!this.options.groupKey&&e.append(u("div",{class:"zx-select__separator",role:"presentation"}));for(let r of n){if(this.options.groupKey){let o=this._read(r,this.options.groupKey);Object.is(o,t)||(e.append(u("div",{class:"zx-select__group",role:"presentation"},String(o??""))),t=o)}this._appendOption(r,!1)}if(this._actions.length>0){(s.length>0||n.length>0||this.options.clearable)&&e.append(u("div",{class:"zx-select__separator",role:"presentation"}));let r=Symbol("initial-action-group");for(let o of this._actions)o.group&&o.group!==r&&(e.append(u("div",{class:"zx-select__group",role:"presentation"},o.group)),r=o.group),this._appendAction(o)}n.length===0&&s.length===0&&this._actions.length===0&&!this._loading&&e.append(u("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(e,t,s){let n=t?this._selected===null:this._selected!==null&&Object.is(this._itemValue(e),this.value),r=this._optionEntries.length,o=t&&typeof this.options.renderNone=="function"?Zs(this.options.renderNone(String(s??""))):t?String(s??""):this._renderItem(e),a=u("div",{class:"zx-select__option",id:E("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},u("span",{class:"zx-select__option-content"},o));n&&a.append(v("check",{size:T.check})),this.refs.list.append(a),this._optionEntries.push({item:e,clear:t,action:null,element:a})}_appendAction(e){let t=this._optionEntries.length,s=Ad(e.icon),n=u("div",{class:"zx-select__option zx-select__action",id:E("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:t,kind:"action"}},u("span",{class:"zx-select__option-content zx-select__action-content"},s?u("span",{class:"zx-select__action-icon",ariaHidden:"true"},s):null,u("span",{class:"zx-select__action-copy"},u("span",{class:"zx-select__action-label"},e.label),e.description?u("span",{class:"zx-select__action-description"},e.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:e,element:n})}_renderItem(e){if(typeof this.options.renderItem=="function"){let t=this.options.renderItem(e);return Zs(t)}return this._itemLabel(e)}_scheduleAsyncQuery(e){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let t=this._requestSequence;if(this._visibleFixed=this._matchFixed(e),e.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(e,t)},s)}async _runAsyncQuery(e,t){if(!(t!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:e});try{let s=await this.options.filter(e);if(t!==this._requestSequence||!this._open)return;this._items=Array.isArray(s)?s.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(t!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(e){this._loading=e,this.refs.loading.hidden=!e,this.refs.input.setAttribute("aria-busy",String(e)),this.refs.list.setAttribute("aria-busy",String(e)),e?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let e=this.refs.input;e.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncValueAdornment(){let e=this.refs.valueAdornment;if(!e)return;let t=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),s=String(this.refs.input?.value??"");if(this._selected===null||typeof this.options.renderValueAdornment!="function"||this.options.filter&&s!==t){e.replaceChildren(),e.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=Zs(n);e.replaceChildren(r instanceof Node?r:document.createTextNode(r)),e.hidden=n==null||typeof r=="string"&&r===""}_syncDisabled(){let e=this.refs.input,t=this.refs.clear,s=this.refs.toggle;e.disabled=this._disabled,t.disabled=this._disabled,s.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(e){let t=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],s=t.find(r=>r===e);if(s!==void 0)return s;let n=e!==null&&typeof e=="object"?this._itemValue(e):e;return t.find(r=>Object.is(this._itemValue(r),n))??null}_itemValue(e){return this._read(e,this.options.valueKey)}_itemLabel(e){let t=this._read(e,this.options.labelKey);return String(t??"")}_read(e,t){return Gs(e,t)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(e){return Ee(this._fixedItems,e,this._searchKeys())}_uniqueItems(e,t=[]){let s=t.map(n=>this._itemValue(n));return e.filter(n=>{let r=this._itemValue(n);return s.some(o=>Object.is(o,r))?!1:(s.push(r),!0)})}_selectedEntryIndex(){return this._selected===null?this.options.clearable?0:-1:this._optionEntries.findIndex(e=>!e.clear&&Object.is(this._itemValue(e.item),this.value))}_itemEntryIndex(e){return e+(this.options.clearable?1:0)}_message(e,t){let s=this.msg(e);return s===e?t:s}};function Ni(i,e){return typeof e=="function"?e(i):i!==null&&typeof i=="object"&&typeof e=="string"?i[e]:null}function Qs(i,e){return S.prototype.msg.call({options:e},i)}function Sd(i,e){let t=i===!0?{}:i;return{id:t.id??"create",label:t.label??Qs("select.create",e),description:t.description,group:t.group??Qs("select.createGroup",e),icon:t.icon??"plus",invoke:t.invoke}}function Zs(i){return i&&typeof i=="object"&&"nodeType"in i?i:String(i??"")}function ta(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&e.label!=null).map(e=>({...e,label:String(e.label),description:e.description==null?void 0:String(e.description),group:e.group==null?void 0:String(e.group)})):[]}function Ad(i){return typeof i=="string"?v(i):i instanceof Node?i.cloneNode(!0):null}function ia(i,e){return u("span",{class:"zx-select__priority"},ra(i.level),e?u("span",{},String(i.name)):null)}function ra(i){let e=Jo(Ys(i));return e.classList.add("zx-select__priority-icon"),e}function kd(i){return!i||typeof i!="object"||i.ID==null||i.name==null?null:{...i,name:String(i.name),indicator:$s.includes(String(i.indicator))?String(i.indicator):"ring",tone:Us.includes(String(i.tone))?String(i.tone):"muted",description:i.description==null?"":String(i.description),shortcut:i.shortcut==null?"":String(i.shortcut)}}function Cd(i){return u("span",{class:"zx-select__status"},oa(i),u("span",{class:"zx-select__status-copy"},u("span",{class:"zx-select__status-label"},String(i.name)),i.description?u("span",{class:"zx-select__status-description"},i.description):null),i.shortcut?u("kbd",{class:"zx-select__status-shortcut"},i.shortcut):null)}function oa(i){let e=Qo({indicator:i.indicator??"ring",tone:i.tone??"muted"});return e.classList.add("zx-select__status-indicator"),e}function Gs(i,e){return typeof e=="function"?e(i):i===null||typeof i!="object"?i:i[e]}function sa(i){return["Shift","Control","Alt","Meta","CapsLock"].includes(i.key)||i.ctrlKey||i.metaKey}function na(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function aa(){C.register("zxselect",(i,e)=>{let t=e.props??{},s=t.preset,n={...t,value:e.value,label:e.label||t.label,placeholder:t.placeholder??e.placeholder};i.listen(i.el,"click",o=>{o.target.closest?.(".zx-field__label")&&i.adapter.focus()}),delete n.preset,s==="priority"&&t.clearable===void 0&&(n.clearable=!e.required);let r=i.own(s==="priority"?q.priority(null,n):s==="status"?q.status(null,n):s==="locale"?q.locale(null,n):s==="country"?q.country(null,n):new q(null,n));return i.listen(r.el,"change",o=>o.stopImmediatePropagation()),r.on("change",o=>i.emit("change",{value:o.detail.value})),{el:r.el,get:()=>r.value,set:o=>r.set(o,{silent:!0}),focus:()=>r.focus(),setDisabled:o=>o?r.disable():r.enable()}})}var Oi=class extends S{static cssName="slider";static defaults={value:0,min:0,max:100,step:1,label:"",hideLabel:!1,showValue:!0,showBounds:!1,showInput:!1,unit:"",marks:null,disabled:!1,readonly:!1,size:"md",formatValue:null};render(){this._value=0,this._readonly=!!this.options.readonly,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:Z(this.el);let e=this.el??u("div");this.el=e,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=E("zx-slider");let t=u("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),s=u("div",{class:"zx-slider__track"},t,this._marks()),n=u("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(u("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(s),this.options.showBounds&&n.append(u("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.append(this._numberBox()),e.replaceChildren(u("div",{class:"zx-slider__head"},u("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),u("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),n),e.dataset.size=this.options.size==="sm"?"sm":"md",e.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(t,"input",()=>this._onInput()),this.listen(t,"change",()=>this._onCommit()),this.listen(t,"keydown",r=>{this._readonly&&Td.has(r.key)&&r.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),e}get value(){return this._value}set value(e){this.set(e)}get(){return this._value}set(e,{silent:t=!1}={}){let s=this._snap(e),n=s!==this._value;return this._value=s,this._committedValue=s,this._paint(),n&&!t&&this.emit("change",{value:s}),this}setRange(e,t,s){let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,s!==void 0&&(this._step=Math.abs(Number(s))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[a,l]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())l.textContent=this._format(a===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(e){return this._readonly=!!e,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(e){return this.refs.label.textContent=String(e??""),this}_numberBox(){let e=u("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??this.msg("slider.value"))});return this.listen(e,"input",()=>{if(this._readonly)return;let t=Number(e.value);e.value===""||!Number.isFinite(t)||(this._value=this._snap(t),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(e,"change",()=>{if(this._readonly){e.value=String(this._value);return}let t=this._snap(e.value===""?this._min:Number(e.value)),s=t!==this._committedValue;this.set(t,{silent:!0}),s&&this.emit("change",{value:t})}),e}_marks(){let e=this.options.marks;if(!Array.isArray(e)||e.length===0)return null;let t=u("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let s of e){let n=typeof s=="number"?s:Number(s?.value);if(!Number.isFinite(n))continue;let r=typeof s=="number"?this._format(n):String(s.label??this._format(n));t.append(u("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":String(this._ratio(n))}},r))}return t}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this._committedValue=this._value,this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:e}=this.refs;e.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let e=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",e),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(e){let t=Number(e);return Number.isFinite(t)?Ci(t,{min:this._min,max:this._max,step:this._step,precision:zd(this._step)}):this._min}_ratio(e){return vt((e-this._min)/(this._max-this._min),0,1)}_format(e){let t=this.options.formatValue;return typeof t=="function"?String(t(e)):`${Ed(e)}${this.options.unit??""}`}destroy(){let e=this.el;super.destroy(),!this._createdRoot&&e&&G(e,this._snapshot)}},Td=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function zd(i){let e=String(i),t=/e-(\d+)$/i.exec(e);return t?Number(t[1]):(e.split(".")[1]??"").length}function Ed(i){return String(Number(i.toFixed(6)))}function la(){C.register("slider",(i,e)=>{let t=i.own(new Oi(null,{label:e.label?String(e.label):void 0,hideLabel:!0,disabled:!!e.disabled,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),t.on("input",n=>i.emit("input",{value:n.detail.value})),{el:t.el,get:()=>t.get(),set:n=>{s=!0;try{t.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}var Id=Object.freeze(["neutral","accent","success","warning","danger","info"]),Md=Object.freeze(["soft","solid","outline"]),Dd=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),Nd=Object.freeze({label:"",icon:null,kind:"neutral",tone:null,variant:"soft",size:"md",dot:!1});function ca(i={}){let e={...Nd,...i},t=u("span",{class:"zx-badge",title:e.title,dataset:{kind:Od(e.kind),variant:Rd(e.variant),size:Ld(e.size),tone:Js(e.tone)??void 0}});return e.dot?t.append(u("span",{class:"zx-badge__dot",ariaHidden:"true"})):e.icon&&t.append(v(e.icon,{size:12,class:"zx-badge__icon"})),e.label!==""&&e.label!=null?t.append(u("span",{class:"zx-badge__label"},String(e.label))):e.title&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.title)),t}function Od(i){return Id.includes(i)?i:"neutral"}function Rd(i){return Md.includes(i)?i:"soft"}function Js(i){return Dd.includes(i)?i:null}function Ld(i){return i==="sm"?"sm":"md"}var Ri=class extends S{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",iconKey:"icon",colorKey:"color",toneKey:"tone",searchKeys:null,filter:"local",minQuery:0,debounce:200,allowCreate:!1,max:null,closeOnSelect:!1,placeholder:"",listHeight:260,disabled:!1,readonly:!1,renderItem:null,renderTag:null};render(){this._items=[],this._selected=[],this._visible=[],this._entries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._readonly=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._activeId=null,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:Z(this.el);let e=this.el??u("div");this.el=e;let t=E("zx-tag-picker-list"),s=u("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=u("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:t,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),r=u("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},v("chevron-down",{size:T.chevron})),o=u("div",{ref:"control",class:"zx-tag-picker__control"},s,n,r),a=u("div",{ref:"list",class:"zx-tag-picker__list",id:t,role:"listbox",ariaMultiSelectable:"true"});a.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let l=u("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},a);return e.replaceChildren(o,l),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",c=>{let d=c.target;d.closest(".zx-tag-picker__remove")||d.closest(".zx-tag-picker__toggle")||(c.target!==n&&(c.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",c=>{let d=c.target.closest(".zx-tag-picker__remove");if(!d||this._disabled||this._readonly)return;c.stopPropagation();let h=[...s.children].indexOf(d.closest(".zx-tag-picker__tag")),p=this._selected[h];p!==void 0&&(this.removeValue(this._valueOf(p)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",c=>this._onKeydown(c)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(l,"pointerdown",c=>c.preventDefault()),this.listen(l,"click",c=>this._onOptionClick(c)),this.listen(document,"pointerdown",c=>{this._open&&!e.contains(c.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),e}get values(){return this.getValues()}set values(e){this.setValues(e)}getValues(){return this._selected.map(e=>this._valueOf(e))}getItems(){return this._selected.slice()}setValues(e,{silent:t=!1}={}){let s=Array.isArray(e)?e:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of s){if(r.length>=n)break;let l=this._resolve(a);l!==null&&!r.some(c=>this._sameValue(c,l))&&r.push(l)}let o=!Fd(r,this._selected,a=>this._valueOf(a));return this._selected=r,this._renderTags(),this._renderOptions(),o&&!t&&this._emitChange(),this}addValue(e,{silent:t=!1}={}){if(this.isFull())return this;let s=this._resolve(e);return s===null?this:this._selected.some(n=>this._sameValue(n,s))?this:(this._selected.push(s),this._renderTags(),this._renderOptions(),t||(this.emit("add",{value:this._valueOf(s),item:s}),this._emitChange()),this)}removeValue(e,{silent:t=!1}={}){let s=this._valueOf(this._resolve(e)??e),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),s));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),t||(this.emit("remove",{value:this._valueOf(r),item:r}),this._emitChange()),this}clear({silent:e=!1}={}){return this.setValues([],{silent:e})}reset({silent:e=!1}={}){return this.setValues(this.options.values,{silent:e})}setItems(e){return this._cancelQuery(),this._items=Array.isArray(e)?e.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let e=this.options.max;return e!=null&&this._selected.length>=Number(e)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=ne(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._entries.length>0?0:-1),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(this.refs.input.value),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._activeId=null,this.refs.input.value="",this._syncInputWidth(),this._applyLocalFilter(""),this.emit("close",{}),this):this}focus(){return this.refs.input.focus(),this}enable(){return this._disabled=!1,this._renderTags(),this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._renderTags(),this._syncDisabled(),this}setReadonly(e){return e&&this.close(),this._readonly=!!e,this._renderTags(),this._syncDisabled(),this}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let e=this.el;super.destroy(),!this._createdRoot&&e&&G(e,this._snapshot)}_renderTags(){let e=this._selected.map(t=>{let s=this._labelOf(t),n=this._toneOf(t),r=n?null:this._colorOf(t),o=this.options.renderTag?[this.options.renderTag(t)]:[this._iconOf(t),u("span",{class:"zx-badge__label zx-tag-picker__tag-label"},s)],a=ca({tone:n});return a.classList.add("zx-tag-picker__tag"),a.dataset.colored=String(!!r),r&&a.style.setProperty("--zx-tag-color",r),a.append(...o.filter(l=>l!=null)),!this._readonly&&!this._disabled&&a.append(u("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[s])},v("x",{size:T.chip}))),a});this.refs.tags.replaceChildren(...e),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let e=this.refs.list;this._entries=[];let t=[];for(let r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),l=u("div",{class:"zx-tag-picker__option",id:E("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},u("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?v("check",{size:T.check}):null),u("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(r):[this._iconOf(r),u("span",{},this._labelOf(r))]));!a&&this.isFull()&&l.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:l,create:!1}),t.push(l)}let s=this.refs.input.value.trim();if(this._canCreate(s)){let r=u("div",{class:"zx-tag-picker__option",id:E("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},u("span",{class:"zx-tag-picker__check",ariaHidden:"true"},v("plus",{size:T.check})),u("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[s])));this._entries.push({item:null,element:r,create:!0}),t.push(r)}t.length===0&&t.push(u("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),e.replaceChildren(...t);let n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n:this._entries.length>0?0:-1)}_entryId(e){return e.create?"\0create":String(this._valueOf(e.item))}_syncPlaceholder(){let e=this.refs.input;e.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let e=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(e):this._applyLocalFilter(e),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(e){if(this._disabled||this._readonly)return;let t=this.refs.input;switch(e.key){case"ArrowDown":e.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":e.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&t.value===""&&(e.preventDefault(),this._setActive(0));return;case"End":this._open&&t.value===""&&(e.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;e.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(e.preventDefault(),this.close());return;case"Backspace":t.value===""&&this._selected.length>0&&(e.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(e){let t=e.target.closest(".zx-tag-picker__option");if(!t)return;let s=this._entries.find(n=>n.element===t);s&&this._commitEntry(s)}_commitEntry(e){if(!e)return;let t=this.refs.input;if(e.create){let s=t.value.trim(),n=this._createItem(s);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}else{let s=this._valueOf(e.item);if(this._isSelected(s))this.removeValue(s);else if(!this.isFull())this.addValue(e.item);else return}t.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(e){if(this._entries.length===0)return;let t=this._activeIndex<0?e>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+e));this._setActive(t)}_setActive(e){this._activeIndex=e,this._activeId=this._entries[e]?this._entryId(this._entries[e]):null;for(let[t,s]of this._entries.entries()){let n=t===e;s.element.toggleAttribute("data-active",n),n&&(this.refs.input.setAttribute("aria-activedescendant",s.element.id),s.element.scrollIntoView({block:"nearest"}))}e<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(e){if(typeof this.options.filter=="function")return;let t=this.options.searchKeys??[this.options.labelKey];this._visible=Ee(this._items,e,t)}_scheduleAsyncQuery(e){this._cancelQuery();let t=String(e??"");if(t.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(t)},s)}async _runQuery(e){let t=this._requestSequence+1;this._requestSequence=t,this._setLoading(!0),this.emit("query",{query:e});try{let s=await this.options.filter(e);if(t!==this._requestSequence)return;this._items=Array.isArray(s)?s.slice():[],this._visible=this._items.slice()}catch(s){if(t!==this._requestSequence)return;this._visible=[],this.emit("error",{error:s})}finally{t===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(e){this._loading=e,this.el.toggleAttribute("data-loading",e)}_isSelected(e){return this._selected.some(t=>Object.is(this._valueOf(t),e))}_canCreate(e){if(!this.options.allowCreate||e===""||this.isFull())return!1;let t=s=>s.some(n=>ua(this._labelOf(n))===ua(e));return!t(this._items)&&!t(this._selected)}_createItem(e,t=e){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?e:{[this.options.valueKey]:t,[this.options.labelKey]:e,created:!0}}_resolve(e){if(e==null)return null;let t=this._valueOf(e),s=this._items.find(r=>Object.is(this._valueOf(r),t));if(s!==void 0)return s;let n=this._selected.find(r=>Object.is(this._valueOf(r),t));return n!==void 0?n:typeof e=="object"?e:this._createItem(String(e),e)}_sameValue(e,t){return Object.is(this._valueOf(e),this._valueOf(t))}_valueOf(e){let t=this.options.valueKey;return typeof t=="function"?t(e):e!==null&&typeof e=="object"?e[t]:e}_labelOf(e){let t=this.options.labelKey;return String(typeof t=="function"?t(e):e!==null&&typeof e=="object"?e[t]??"":e??"")}_iconOf(e){let t=this._readItem(e,this.options.iconKey),s=t&&typeof t=="object"&&typeof t.nodeType=="number"?t.cloneNode(!0):typeof t=="string"&&t.trim()?v(t,{size:12}):null;if(!s)return null;let n=this._toneOf(e),r=n?null:this._colorOf(e);return u("span",{class:"zx-tag-picker__visual",dataset:{tone:n??void 0},style:r?{"--zx-tag-color":r}:null,ariaHidden:"true"},s)}_colorOf(e){return zi(this._readItem(e,this.options.colorKey))}_toneOf(e){return Js(this._readItem(e,this.options.toneKey))}_readItem(e,t){return typeof t=="function"?t(e):e!==null&&typeof e=="object"&&typeof t=="string"?e[t]:null}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let e=this.refs.input,t=e.value.length;e.style.inlineSize=t===0?"":`${Math.min(40,t+1)}ch`}_syncDisabled(){let e=this.refs.input;e.disabled=this._disabled,e.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(e,t,s=[]){let n=this.msg(e,...s);return n!==e?n:s.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),t)}};function ua(i){return String(i??"").trim().toLocaleLowerCase()}function Fd(i,e,t){return i.length!==e.length?!1:i.every((s,n)=>Object.is(t(s),t(e[n])))}function da(){C.register("tagpicker",(i,e)=>{let t=i.own(new Ri(null,{placeholder:e.placeholder,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.values})}),{el:t.el,get:()=>t.getValues(),set:n=>{s=!0;try{t.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}function Pd(i,e="minutes"){let t=Math.round(Math.abs(ha(je(i),e)));return{hours:Math.floor(t/3600),minutes:Math.floor(t/60)%60,seconds:t%60,negative:je(i)<0}}function Vd(i,e="minutes"){zt(e);let t=Math.abs(Math.trunc(je(i?.hours))),s=Math.abs(Math.trunc(je(i?.minutes))),n=Math.abs(Math.trunc(je(i?.seconds))),r=i?.negative?-1:1;return fa(r*(t*3600+s*60+n),e)}var Li=class extends S{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){zt(this.options.unit);let e=this.el??u("div");this.el=e,this._originalAriaDisabled=e.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let t=u("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?this._message("timebox.durationWithSeconds","Duration in hours, minutes, and seconds"):this._message("timebox.duration","Duration in hours and minutes")});return this._content=t,this.options.signed&&(t.append(u("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:this._message("timebox.toggleSign","Toggle duration sign"),ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(t,"hours",this._message("timebox.hours","Hours"),!1),t.append(u("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(t,"minutes",this._message("timebox.minutes","Minutes"),!0),this.options.seconds&&(t.append(u("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(t,"seconds",this._message("timebox.seconds","Seconds"),!0)),e.append(t),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),e}get(e=this.options.unit){return Vd(this._readParts(),e)}set(e,t=this.options.unit,s={}){t&&typeof t=="object"&&(s=t,t=this.options.unit),zt(t);let n=je(e);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=fa(Math.round(ha(n,t)/60)*60,t)),this._parts=Pd(n,t),this.options.signed||(this._parts.negative=!1),this._writeParts(),s.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(e,t,s,n){let r=u("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,maxLength:n?2:null,dataset:{segment:t,bounded:String(n)}});this._inputs.push(r),e.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{t==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let e={...this._parts};for(let t of this._inputs){let s=t.dataset.segment,n=t.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;e[s]=Math.max(0,Math.min(n,Math.trunc(je(t.value))))}return e}_commitSegments(){this._parts=this._readParts(),this._writeParts(),this._emitChange()}_writeParts(){for(let e of this._inputs){let t=e.dataset.segment;e.value=t==="hours"?String(this._parts[t]):jd(this._parts[t])}this.refs.sign&&(this.refs.sign.textContent=this._parts.negative?"-":"+",this.refs.sign.setAttribute("aria-pressed",String(this._parts.negative)),this.refs.sign.dataset.state=this._parts.negative?"negative":"positive")}_syncDisabled(){for(let e of this._inputs)e.disabled=this._disabled;this.refs.sign&&(this.refs.sign.disabled=this._disabled),this.el.setAttribute("aria-disabled",String(this._disabled))}_emitChange(){this.emit("change",{value:this.get(this.options.unit)})}_message(e,t){let s=this.msg(e);return s===e?t:s}};function je(i){let e=Number(i);return Number.isFinite(e)?e:0}function ha(i,e){return zt(e),e==="hours"?i*3600:e==="minutes"?i*60:i}function fa(i,e){return zt(e),e==="hours"?i/3600:e==="minutes"?i/60:i}function zt(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function jd(i){return String(i).padStart(2,"0")}function pa(){C.register("time",(i,e)=>{let t=i.own(new Li(null,{...e.props??{},value:e.value}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:s.detail.value})),{el:t.el,get:()=>t.get(),set:s=>t.set(Number(s)||0,{silent:!0}),focus:()=>t.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var et=class extends S{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let e=!this.el,t=this.el??u("button");if(this.el=t,t.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=e,this._original=e?null:Bd(t),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,t.type="button",t.setAttribute("role","switch");let s=[u("span",{class:"zx-toggle__track",ariaHidden:"true"},u("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&s.push(u("span",{class:"zx-toggle__label"},String(this.options.label))),t.replaceChildren(...s),this._sync(),this.listen(t,"click",()=>this.toggle()),t}get(){return this._checked}set(e,{silent:t=!1}={}){let s=!!e;return s===this._checked?this:(this._checked=s,this._sync(),t||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&qd(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Bd(i){return{attributes:Array.from(i.attributes,e=>[e.name,e.value]),children:Array.from(i.childNodes)}}function qd(i,e){for(let t of Array.from(i.attributes))i.removeAttribute(t.name);for(let[t,s]of e.attributes)i.setAttribute(t,s);i.replaceChildren(...e.children)}function ma(){C.register("toggle",(i,e)=>{let t=i.own(new et(null,{...e.props??{},checked:!!e.value}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:s.detail.value})),{el:t.el,get:()=>t.getValue(),set:s=>t.set(!!s,{silent:!0}),focus:()=>t.el.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var Fi=class extends S{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let e=this.el??u("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=e.getAttribute("data-state"),this._initialDisabled=e.getAttribute("data-disabled"),this._values=ga(this.options.values,!!this.options.unique);let t=E("zx-value-list-instructions");return this._list=u("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:this._message("valueList.values","Values"),ariaOrientation:"horizontal"}),this._input=u("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:this._message("valueList.add","Add value"),ariaDescribedby:t}),this._status=u("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=u("span",{class:"zx-value-list__instructions",id:t},this._message("valueList.instructions","Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder.")),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),e.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",s=>this._handleInputKeydown(s)),this.listen(this._list,"keydown",s=>this._handleChipKeydown(s)),this.listen(this._list,"click",s=>this._handleChipClick(s)),this.listen(this._list,"dragstart",s=>this._handleDragStart(s)),this.listen(this._list,"dragover",s=>{this._dragIndex>=0&&!this._disabled&&s.preventDefault()}),this.listen(this._list,"drop",s=>this._handleDrop(s)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(e,"click",s=>{s.target===e&&!this._disabled&&this.focus()}),this._renderChips(),e}getValues(){return this._values.slice()}setValues(e,{silent:t=!1}={}){return this._values=ga(e,!!this.options.unique),this._renderChips(),t||this.emit("change",{values:this.getValues()}),this}addValue(e){if(this._disabled)return!1;let t=String(e??"").trim();if(!t)return!1;if(this.options.unique&&this._values.includes(t))return this._showError(this._message("valueList.duplicate","This value already exists.")),!1;if(typeof this.options.validate=="function"){let s=this.options.validate(t);if(s!==!0)return this._showError(typeof s=="string"?s:this._message("valueList.invalid","This value is not valid.")),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(t),this._renderChips(),this.emit("add",{value:t}),this.emit("change",{values:this.getValues()}),!0}removeValue(e){if(this._disabled||!this.options.deletable)return!1;let t=this._values.indexOf(String(e));return t<0?!1:(this._removeAt(t),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(e=-1){let t=this._values.map((s,n)=>u("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?this._message("valueList.removable","%1. Press Delete to remove.",s):s,dataset:{index:n}},u("span",{class:"zx-value-list__value"},s),this.options.deletable?u("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},v("x",{size:T.chip})):null));this._list.replaceChildren(...t),e>=0&&t[Math.min(e,t.length-1)]?.focus()}_handleInputKeydown(e){this._disabled||(e.key==="Enter"?(e.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):e.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(e.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(e){if(this._disabled)return;let t=e.target instanceof Element?e.target.closest("[data-index]"):null;if(!t)return;let s=Number(t.dataset.index);if((e.key==="Delete"||e.key==="Backspace")&&this.options.deletable){e.preventDefault(),this._removeAt(s,Math.min(s,this._values.length-2));return}let n=e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:0,r=e.key==="ArrowUp"?-1:e.key==="ArrowDown"?1:0,o=n||r;if(!o)return;e.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,s+o));e.ctrlKey&&n&&this.options.sortable?this._move(s,a,!0):this._list.querySelector(`[data-index="${a}"]`)?.focus()}_handleChipClick(e){let t=e.target instanceof Element?e.target:null,s=t?.closest("[data-index]");!s||this._disabled||(t.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(s.dataset.index)):s.focus())}_handleDragStart(e){if(this._disabled||!this.options.sortable)return;let t=e.target instanceof Element?e.target.closest("[data-index]"):null;t&&(this._dragIndex=Number(t.dataset.index),this.el.dataset.state="dragging",e.dataTransfer?.setData("text/plain",String(this._dragIndex)),e.dataTransfer&&(e.dataTransfer.effectAllowed="move"))}_handleDrop(e){if(this._dragIndex<0||this._disabled)return;e.preventDefault();let t=e.target instanceof Element?e.target.closest("[data-index]"):null,s=t?Number(t.dataset.index):this._values.length-1;this._move(this._dragIndex,s,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(e,t,s){if(e===t||e<0||t<0||e>=this._values.length||t>=this._values.length)return;let[n]=this._values.splice(e,1);this._values.splice(t,0,n),this._renderChips(s?t:-1),this.emit("change",{values:this.getValues()})}_removeAt(e,t=-1){let[s]=this._values.splice(e,1);s!==void 0&&(this._renderChips(t),t<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:s}),this.emit("change",{values:this.getValues()}))}_showError(e){this._status.textContent=e,this._input.setAttribute("aria-invalid","true")}_message(e,t,...s){let n=this.msg(e,...s);return n===e?F(t,s):n}destroy(){for(let e of this._ownedNodes??[])e.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function ga(i,e){if(!Array.isArray(i))return[];let t=i.map(s=>String(s));return e?[...new Set(t)]:t}function _a(){C.register("valuelist",(i,e)=>{let t=i.own(new Fi(null,{...e.props??{},values:Array.isArray(e.value)?e.value:[]}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:s.detail.values})),{el:t.el,get:()=>t.getValues(),set:s=>t.setValues(Array.isArray(s)?s:[],{silent:!0}),focus:()=>t.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var Pi=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),Hd=["xl","lg","md","sm"];function ba(i){let e=Number(i);if(!Number.isFinite(e))return"xs";for(let t of Hd)if(e>=Pi[t])return t;return"xs"}function ya(i,e={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in e&&!P(e.target)&&e.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let t=e.target??globalThis,s=P(t)?t:null,n=null,r=!1,o=null,a=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,l=()=>{if(r)return;let h=a();if(s&&h===0)return;let p=ba(h);p!==n&&(n=p,i(n,h))};l();let c=0,d=()=>{c||r||(c=requestAnimationFrame(()=>{c=0,l()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(d),o.observe(s)):globalThis.addEventListener?.("resize",l,{passive:!0}),{current:()=>n??ba(a()),destroy:()=>{r||(r=!0,c&&cancelAnimationFrame(c),o?.disconnect(),globalThis.removeEventListener?.("resize",l))}}}var $d=".zx-scope, [data-zx-theme], [data-zx-preset]",Ud="dialog:modal, dialog[open], dialog:popover-open";function ce(i=null){return va(wa(i))}function Et(i=null){let e=wa(i);return(i==null?null:it(e))??va(e)}function tt(i=null,e={}){let t=e.dialog===!1?ce:Et;if(i==null)return t(null);let s=Q(i);return s?.isConnected?t(s):null}function it(i){if(!i||typeof i.closest!="function")return null;try{return i.closest(Ud)}catch{return i.closest("dialog[open]")}}function wa(i){return i==null?document.activeElement instanceof Element?document.activeElement:null:Q(i)}function va(i){let e=i?.closest?.($d)??null;return!e||e===document.documentElement||e===document.body?document.body:e}var Aa=new Set(["tooltip","toast"]);function Me(i,e){if(!i||!e)return!1;for(let t=e;t;t=t.parentNode??t.host??null)if(t===i)return!0;return!1}function Kd(i,e){for(let t=i.length-1;t>=0;t-=1){let s=i[t];if(!Aa.has(s.kind)&&e.some(n=>Me(s.root,n)))return s}return null}function It(i,e,t){return t?Me(e.root,t)||e.inside.some(s=>Me(s,t))?!0:i.some(s=>s.parent===e&&It(i,s,t)):!1}function Xs(i,e=()=>!0){for(let t=i.length-1;t>=0;t-=1){let s=i[t];if(s.kind!=="toast"&&e(s))return s}return null}function Yd(i,e=null){let t=[];for(let s=i.length-1;s>=0;s-=1){let n=i[s];if(n.kind==="modal")break;e&&!Me(e,n.root)||typeof n.onEscape=="function"&&t.push(n)}return t}function Wd(i,e,t=null){if(i.some(n=>n.kind==="toast"&&Me(n.root,e)))return[];let s=[];for(let n=i.length-1;n>=0;n-=1){let r=i[n];r.kind==="tooltip"&&!It(i,r,e)&&r.onOutsidePointer&&s.push(r)}for(let n=i.length-1;n>=0;n-=1){let r=i[n];if(!Aa.has(r.kind)){if(It(i,r,e)||r.kind==="modal")break;t&&!Me(t,r.root)||r.onOutsidePointer&&s.push(r)}}return s}var tn=class{#e=[];#t=0;#i=null;#s=new Set;#n;#r=new WeakMap;constructor(e={}){this.#n=e.target===void 0?typeof document>"u"?null:document:e.target}push(e){let t=xa(e.anchor),s={order:++this.#t,kind:e.kind,root:e.root,owner:e.owner??null,anchors:t,inside:xa(e.inside),parent:e.kind==="toast"?null:Kd(this.#e,t),onEscape:e.onEscape,onOutsidePointer:e.onOutsidePointer,onFocusOutside:e.onFocusOutside,onParentClose:e.onParentClose};this.#e.push(s);let n={entry:s,order:s.order,isOpen:()=>this.#e.includes(s),isTopmost:()=>Xs(this.#e)===s,contains:r=>this.#e.includes(s)&&It(this.#e,s,r),release:()=>this.#o(s)};return this.#r.set(s,n),this.#c(),this.#a(),n}entries(){return this.#e.slice()}topmost(e){return Xs(this.#e,e)}topmostModal(){let e=Xs(this.#e,s=>s.kind==="modal"&&s.root.isConnected&&Zd(s.root,":modal",!0));if(e)return e.root;if(typeof document>"u"||typeof document.querySelectorAll!="function")return null;let t;try{t=document.querySelectorAll("dialog:modal")}catch{return null}return t.length?t[t.length-1]:null}containsNode(e){return this.#e.some(t=>Me(t.root,e)||t.inside.some(s=>Me(s,e)))}subscribe(e){return this.#s.add(e),()=>{this.#s.delete(e)}}handleKeydown(e){if(e.key!=="Escape"||e.defaultPrevented||e.isComposing)return null;for(let t of Yd(this.#e,Sa(en(e)))){let s=this.#r.get(t);if(!(!s||!this.#e.includes(t))&&t.onEscape?.(e,s)!==!1)return e.preventDefault(),t}return null}handlePointerdown(e){let t=en(e),s=Wd(this.#e,t,Sa(t));for(let n of s){let r=this.#r.get(n);r&&this.#e.includes(n)&&n.onOutsidePointer?.(e,r)}return s}handleFocusin(e){let t=en(e);for(let s of this.#e.slice().reverse()){if(typeof s.onFocusOutside!="function"||!this.#e.includes(s)||It(this.#e,s,t))continue;let n=this.#r.get(s);n&&s.onFocusOutside(e,n)}}#o(e){let t=this.#e.indexOf(e);if(t<0)return;this.#e.splice(t,1);let s=this.#e.filter(n=>n.parent===e);for(let n of s)n.parent=e.parent;this.#e.length===0&&this.#l(),this.#a();for(let n of s.reverse()){let r=this.#r.get(n);r&&this.#e.includes(n)&&n.onParentClose?.(r)}}#c(){if(this.#i||!this.#n||typeof this.#n.addEventListener!="function")return;let e=new AbortController;this.#i=e;let{signal:t}=e;this.#n.addEventListener("keydown",s=>this.handleKeydown(s),{signal:t}),this.#n.addEventListener("pointerdown",s=>this.handlePointerdown(s),{capture:!0,signal:t}),this.#n.addEventListener("focusin",s=>this.handleFocusin(s),{signal:t})}#l(){this.#i?.abort(),this.#i=null}#a(){let e=this.#e.slice();for(let t of[...this.#s])try{t(e)}catch(s){queueMicrotask(()=>{throw s})}}},st=new tn;function nt(i){return st.push(i)}function xa(i){let e=Array.isArray(i)?i:[i];return e.filter((t,s)=>t!=null&&e.indexOf(t)===s)}function Sa(i){for(let e=i;e;e=e.parentNode??e.host??null)if(e.localName==="dialog"&&typeof e.matches=="function")try{if(e.matches(":modal"))return e}catch{return null}return null}function en(i){return(typeof i.composedPath=="function"?i.composedPath():[])[0]??i.target??null}function Zd(i,e,t){if(typeof i.matches!="function")return t;try{return i.matches(e)}catch{return t}}var ka=Object.freeze({mod:["\u2318","Ctrl"],meta:["\u2318","Meta"],cmd:["\u2318","Ctrl"],command:["\u2318","Ctrl"],ctrl:["\u2303","Ctrl"],control:["\u2303","Ctrl"],alt:["\u2325","Alt"],option:["\u2325","Alt"],shift:["\u21E7","Shift"],backspace:["\u232B","Backspace"],delete:["\u2326","Del"],tab:["\u21E5","Tab"]}),Ca=Object.freeze({enter:"\u21B5",return:"\u21B5",escape:"Esc",esc:"Esc",space:"Space",arrowup:"\u2191",up:"\u2191",arrowdown:"\u2193",down:"\u2193",arrowleft:"\u2190",left:"\u2190",arrowright:"\u2192",right:"\u2192",pageup:"PgUp",pagedown:"PgDn",home:"Home",end:"End"});function Gd(){let i=globalThis.navigator;if(!i)return!1;let e=i.userAgentData?.platform||i.platform||"";return/mac|iphone|ipad|ios/i.test(e)}function Qd(i){if(i==="+")return["+"];let e=i.split("+");return i.endsWith("++")&&e.splice(-2,2,"+"),e.map(t=>t.trim()).filter(t=>t!=="")}function Jd(i,e){let t=i.toLowerCase();return Object.hasOwn(ka,t)?ka[t][e?0:1]:Object.hasOwn(Ca,t)?Ca[t]:i.length===1?i.toUpperCase():i}function Xd(i,{apple:e=Gd()}={}){return(Array.isArray(i)?i.map(String):Qd(String(i))).map(s=>Jd(s,e))}function ve(i,e={}){return u("kbd",{class:"zx-kbd",dataset:{size:e.size==="sm"?"sm":void 0,tone:e.tone==="inherit"?"inherit":void 0}},Xd(i).map(t=>u("kbd",{class:"zx-kbd__key"},t)))}var eh=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),th=Object.freeze({sm:!0,md:!0,lg:!0});function Ta(i={}){let e={...eh,...i},t=String(e.label??""),s=u("span",{class:"zx-spinner",dataset:{size:th[e.size]?e.size:"md",kind:e.kind==="current"?"current":"accent"}},u("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return t?(s.setAttribute("role","status"),s.append(u("span",{class:"zx-spinner__label",dataset:{visible:e.showLabel?"true":null}},t))):s.setAttribute("aria-hidden","true"),s}var ih=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function za(i={}){let e={...ih,...i},t=u("button",{class:"zx-btn",type:"button",disabled:!!e.disabled,title:e.title??(e.shortcut?`${e.label} (${e.shortcut.label})`:void 0),ariaKeyshortcuts:e.shortcut?.keys,dataset:{kind:rh(e.kind),size:oh(e.size)}});return e.icon&&t.append(v(e.icon,{size:16})),e.label!==""&&t.append(u("span",{class:"zx-btn__label"},String(e.label))),e.shortcut&&t.append(nh(e.shortcut.label)),!e.label&&e.title&&t.setAttribute("aria-label",e.title),typeof e.onclick=="function"&&(t.onclick=e.onclick),e.busy&&sh(t,!0),t}function sh(i,e){if(i.hasAttribute("data-busy-guard")||(i.setAttribute("data-busy-guard",""),i.addEventListener("click",t=>{i.getAttribute("aria-busy")==="true"&&(t.preventDefault(),t.stopImmediatePropagation())},{capture:!0})),i.querySelector(":scope > .zx-btn__spinner")?.remove(),e){i.setAttribute("aria-busy","true"),i.setAttribute("aria-disabled","true");let t=Ta({size:"sm",kind:"current"});t.classList.add("zx-btn__spinner"),i.prepend(t)}else i.removeAttribute("aria-busy"),i.removeAttribute("aria-disabled");return i}function nh(i){let e=ve(String(i),{size:"sm"});return e.classList.add("zx-btn__shortcut"),e.setAttribute("aria-hidden","true"),e}function rh(i){return["primary","danger","ghost"].includes(String(i))?i:"default"}function oh(i){return i==="sm"?"sm":"md"}function ah(i,e){return String(i).localeCompare(String(e))}function lh(i,e){return i-e}function ch(i,e){return i.getTime()-e.getTime()}function uh(i,e,t="asc"){let s=i==null,n=e==null;if(s||n)return s&&n?0:s?1:-1;let r;return i instanceof Date&&e instanceof Date?r=ch(i,e):typeof i=="number"&&typeof e=="number"?r=lh(i,e):r=ah(i,e),t==="desc"?-r:r}function dh(i,e="asc"){return(t,s)=>uh(i(t),i(s),e)}function sn(i,e,t="asc"){let s=dh(e,t);return i.map((n,r)=>({row:n,index:r})).sort((n,r)=>s(n.row,r.row)||n.index-r.index).map(({row:n})=>n)}var hh=36,fh=600;function ph({total:i,rowHeight:e,scrollTop:t,viewport:s,overscan:n=1}){let r=Math.max(0,Math.trunc(Number(i)||0)),o=Number(e);if(r===0)return{start:0,end:0};if(!(o>0))return{start:0,end:1};let a=Math.max(Number(s)||0,o),l=Math.min(Math.max(Number(t)||0,0),Math.max(0,r*o-a)),c=Math.floor(l/o),d=Math.ceil((l+a)/o),h=Math.ceil(a*Math.max(0,Number(n)||0)/o);return{start:Math.max(0,c-h),end:Math.min(r,d+h)}}function mh(i,e,t,s=[]){let n=t>e?[{from:e,to:t}]:[];for(let l of s)!Number.isInteger(l)||l<0||l>=i||(l<e||l>=t)&&n.push({from:l,to:l+1});n.sort((l,c)=>l.from-c.from);let r=[],o=null,a=0;for(let{from:l,to:c}of n)o&&l<=a?o.to=Math.max(o.to,c):(l>a&&r.push({gap:l-a}),o={from:l,to:c},r.push(o)),a=o.to;return a<i&&r.push({gap:i-a}),r}function gh({index:i,rowHeight:e,scrollTop:t,viewport:s}){let n=i*e,r=n+e;return n<t?n:r>t+s?Math.max(0,Math.min(n,r-s)):t}var Vi=class{constructor(e){this.host=e,this.entries=[],this.drawn=new Map,this.spacers=[],this.rowHeight=hh,this.viewport=fh,this.offset=0,this.measured=!1,this.live=!1,this.frame=0,this.observer=null,this.probe=u("div",{class:"zx-table__row-probe",ariaHidden:"true"}),e.scroller.append(this.probe)}get total(){return this.entries.length}start(){this.live=!0,this.observer=new ResizeObserver(()=>this.schedule()),this.observer.observe(this.host.scroller),this.observer.observe(this.probe)}schedule(){cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>this.measure())}stop(){this.live=!1,cancelAnimationFrame(this.frame),this.observer?.disconnect(),this.observer=null}clear(){this.entries=[],this.drawn=new Map,this.spacers=[]}fill(e,t){this.clear(),this.entries=e,this._lay(this._segments(),s=>t.append(s))}settle(){this.live&&!this.measured&&this.measure()}measure(){let{start:e,end:t}=this._range(),s=this.drawn.get(Math.floor((e+t-1)/2))??this.drawn.values().next().value;if(!s?.isConnected)return;let{scroller:n,head:r,sticky:o}=this.host,a=s.getBoundingClientRect().height,l=n.clientHeight;if(!(a>0)||!(l>0))return;let c=r.getBoundingClientRect().height,d=Math.max(a,l-(o?c:0)),h=o?0:c,p=a!==this.rowHeight||d!==this.viewport||h!==this.offset;this.rowHeight=a,this.viewport=d,this.offset=h,this.measured=!0,p&&this.update()}update(){if(this.total===0)return;let e=this._segments(),{drawn:t,spacers:s}=this,{body:n,release:r,changed:o}=this.host;for(let[l,c]of t)e.some(d=>"from"in d&&l>=d.from&&l<d.to)||(t.delete(l),c.remove(),r(c));for(let l of s)l.remove();let a=n.firstChild;this._lay(e,l=>{l===a?a=a.nextSibling:n.insertBefore(l,a)}),o()}reveal(e){if(e<0||e>=this.total)return null;this.measure();let t=this._position(),s=gh({index:e,rowHeight:this.rowHeight,scrollTop:t,viewport:this.viewport});return s!==t&&(this.host.scroller.scrollTop=s+this.offset),this.update(),this.drawn.get(e)??null}_position(){return Math.max(0,this.host.scroller.scrollTop-this.offset)}_range(){return ph({total:this.total,rowHeight:this.rowHeight,scrollTop:this._position(),viewport:this.viewport})}_segments(){let{start:e,end:t}=this._range();return mh(this.total,e,t,this.host.pins())}_lay(e,t){let s=0;for(let n of e){if("gap"in n){t(this._spacer(s,n.gap)),s+=1;continue}for(let r=n.from;r<n.to;r+=1){let o=this.drawn.get(r);o||(o=this.host.draw(this.entries[r]),this.drawn.set(r,o)),t(o)}}}_spacer(e,t){let s=this.spacers[e];return s||(s=u("tr",{class:"zx-table__spacer",ariaHidden:"true"},u("td",{colspan:this.host.colspan()})),this.spacers[e]=s),s.firstElementChild.style.blockSize=`${t*this.rowHeight}px`,s}};var _h=new Set(["text","number","select","date","checkbox","textarea"]),bh='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',Dt=class extends S{static cssName="table";static defaults={columns:[],data:[],rowId:"ID",sort:null,sortMode:"local",selectable:!1,stickyHeader:!0,responsive:!1,growing:!1,virtual:!1,height:null,emptyText:null,rowClass:null,rowKind:null,rowKinds:null,zebra:!0,variant:"default",editMode:!1,editTrigger:"double",hierarchy:!1,interactive:!1,label:null,labelledBy:null,rowReorder:!1,columnVisibility:!1,columnReorder:!1,hiddenColumns:[]};constructor(e,t={}){super(e,t)}render(){let e=this.el===null,t=this.el??u("div");if(this.el=t,this._createdRoot=e,this._original=e?null:Z(t),this._columns=Ia(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._rowKind=Oh(this.options.rowKind),this._rowKinds=Rh(this.options.rowKinds),this._spanning=this._hasSpanningRow(),this._sortWarned=!1,this._selected=new Set,this._selectionAnchorId=null,this._sort=Da(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Ph(this.options.editMode),this._editTrigger=this.options.editTrigger==="single"?"single":"double",this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._virtual=!!this.options.virtual,this._virtual&&Oa(this.options.growing)&&console.warn("[zx.Table] `growing` is ignored: `virtual` already decides which rows are drawn."),this._growStep=this._virtual?null:Oa(this.options.growing),this._indexed=!!(this._growStep||this._virtual),this._rendered=this._growStep??1/0,this._more=null,this._focusMode=this._editMode===!1?"row":"cell",this._interactive=!!(this.options.interactive||this.options.selectable||this._virtual||this._editMode!==!1||Bi(this.options.hierarchy,this._columns)||this._clickListened),this._current=null,this._rovingEl=null,this._extendBase=null,this._hierarchy=Bi(this.options.hierarchy,this._columns),this._hiddenColumns=new Set((Array.isArray(this.options.hiddenColumns)?this.options.hiddenColumns:[]).map(String).filter(s=>this._columns.some(n=>n.id===s))),this._hiddenColumns.size>=this._columns.length&&this._columns[0]&&this._hiddenColumns.delete(this._columns[0].id),this._dragId=null,this._grabbedId=null,this._columnControlIds=new Map,this._columnStatus=null,this._expanded=Lh(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let s of ji(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(s);return this._reconcileExpanded(),Fh(this.options.variant)==="plain"&&(t.dataset.variant="plain"),this._table=u("table",{class:"zx-table__table"}),this._syncGridRole(),this._colgroup=u("colgroup",{class:"zx-table__columns"}),this._thead=u("thead",{class:"zx-table__head"}),this._tbody=u("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=u("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:this._virtual&&this.options.zebra?"index":String(!!this.options.zebra)}},this._table),this._window=null,this._virtual&&(t.dataset.virtual="",this._window=new Vi({scroller:this._scroll,body:this._tbody,head:this._thead,sticky:!!this.options.stickyHeader,draw:s=>this._createRow(s.row,s.index,s),release:s=>this._releaseRow(s),pins:()=>this._windowPins(),colspan:()=>this._spanColspan(),changed:()=>{this._stacked&&this._applyStackedRoles(!0)}})),this._rowMoveMessage=this.options.rowReorder?u("div",{class:"zx-table__reorder-status",role:"status",ariaLive:"polite"}):null,this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._columnControls=this.options.columnVisibility||this.options.columnReorder?this._createColumnControls():null,this._editMode===!1?t.replaceChildren(...[this._columnControls,this._scroll,this._rowMoveMessage].filter(Boolean)):(t.dataset.editMode=this._editMode,this._editMessage=u("div",{class:"zx-table__message",id:E("zx-table-message"),role:"status",ariaLive:"polite"}),t.replaceChildren(...[this._columnControls,this._scroll,this._editMessage,this._rowMoveMessage].filter(Boolean))),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this._window&&(this._window.start(),this.listen(this._scroll,"scroll",()=>this._window.update(),{passive:!0})),this.listen(this._tbody,"click",s=>this._handleBodyClick(s)),this.listen(this._tbody,"dblclick",s=>this._handleBodyDoubleClick(s)),this.options.rowReorder&&(this.listen(this._tbody,"dragstart",s=>this._handleRowDragStart(s)),this.listen(this._tbody,"dragover",s=>this._handleRowDragOver(s)),this.listen(this._tbody,"drop",s=>this._handleRowDrop(s)),this.listen(this._tbody,"dragend",()=>this._clearRowDrag()),this.listen(this._tbody,"keydown",s=>this._handleRowHandleKeydown(s))),this._columnControls&&(this.listen(this._columnControls,"change",s=>{let n=s.target;n?.classList.contains("zx-table__column-toggle")&&this.setColumnVisible(n.value,n.checked)}),this.listen(this._columnControls,"click",s=>this._handleColumnControlClick(s)),this.listen(this._columnControls,"keydown",s=>this._handleColumnControlKeydown(s))),this._editMode!==!1&&(this.listen(this._tbody,"keydown",s=>this._handleEditKeydown(s)),this.listen(document,"pointerdown",s=>this._handleDocumentPointerDown(s),{capture:!0})),this.listen(this._tbody,"keydown",s=>this._handleGridKeydown(s)),this.listen(this._tbody,"focusin",s=>this._handleFocusIn(s)),t}setLoading(e=!0){return e?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!e)),this}setData(e){this._rendered=this._growStep??1/0,this.setLoading(!1),Na(e),this._data=[...e],this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded();let t=this._pruneSelection();return this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}addData(e){return Na(e),this._data.push(...e),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(e,t){let s=this._data.findIndex(r=>Object.is(this._idFor(r),e));if(s<0)return this;let n=this._selected.delete(e);return this._data[s]=t,n&&this._selected.add(this._idFor(t)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(e,this._idFor(t))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(e){let t=this._data.findIndex(n=>Object.is(this._idFor(n),e));if(t<0)return this;this._data.splice(t,1),this._reconcileExpanded();let s=this._selected.delete(e);return Object.is(this._selectionAnchorId,e)&&(this._selectionAnchorId=null),this._extendBase=null,this._renderBody(),s&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(e){return this._data.find(t=>Object.is(this._idFor(t),e))??null}getData(){return[...this._data]}getColumns(){return this._columns.map(e=>({...e}))}setColumns(e,t={}){let s=Ia(e),n=this.getColumnOrder(),r=this.getHiddenColumns(),o=this.getSort();return this._abortEdit({focus:!1}),this._columns=s,this._hiddenColumns=new Set(r.filter(a=>s.some(l=>l.id===a))),this._hiddenColumns.size>=s.length&&s[0]&&this._hiddenColumns.delete(s[0].id),this._sort=Da(o,s),this._hierarchy=Bi(this.options.hierarchy,s),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),t.silent||(qi(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),qi(r,this.getHiddenColumns())||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()})),this}getColumnOrder(){return this._columns.map(e=>e.id)}setColumnOrder(e,t={}){let s=qh(this._columns,e);if(qi(s,this.getColumnOrder()))return this;let n=this._activeColumnControl(),r=new Map(this._columns.map(o=>[o.id,o]));return this._abortEdit({focus:!1}),this._columns=s.map(o=>r.get(o)),this._hierarchy=Bi(this.options.hierarchy,this._columns),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(n),t.silent||this.emit("columnorderchange",{order:this.getColumnOrder()}),this}moveColumn(e,t,s="before",n={}){if(s!=="before"&&s!=="after")throw new TypeError('Table column position must be "before" or "after"');let r=Hh(this.getColumnOrder(),String(e),String(t),s);if(qi(r,this.getColumnOrder()))return this;if(this.setColumnOrder(r,n),this._columnStatus){let o=this._columns.find(l=>l.id===String(e)),a=this.getColumnOrder().indexOf(String(e));o&&a>=0&&(this._columnStatus.textContent=this._message("table.columnMoved","Moved %1 to position %2 of %3.",[Hi(o),a+1,this._columns.length]))}return this}getVisibleColumns(){return this._visibleColumns().map(e=>e.id)}getHiddenColumns(){return this._columns.filter(e=>this._hiddenColumns.has(e.id)).map(e=>e.id)}setColumnVisible(e,t=!0,s={}){let n=String(e);if(!this._columns.find(l=>l.id===n))throw new RangeError(`Unknown table column: ${n}`);let o=this._activeColumnControl();if(!t&&!this._hiddenColumns.has(n)&&this._visibleColumns().length<=1)return this._renderColumnControls(o),this;let a=t?this._hiddenColumns.delete(n):!this._hiddenColumns.has(n);return!t&&a&&this._hiddenColumns.add(n),a?(this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(o),s.silent||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()}),this):this}toggleColumn(e,t={}){return this.setColumnVisible(e,this._hiddenColumns.has(String(e)),t)}moveRow(e,t,s="before"){if(!this.options.rowReorder||this._sort&&this.options.sortMode==="local")return this;let n=this.getRow(e),r=this.getRow(t);if(!n||!r||Object.is(e,t))return this;if(this._isSpanningRow(n))return this;let o=Pa(this._data,this.options.rowId,e,t,s,this._hierarchy?.parentId);if(!o)return this;if(this.emit("rowmove",{row:n,id:e,target:r,targetId:t,position:s}).defaultPrevented)return this;if(this._data=o,this._renderBody(),this._rowMoveMessage){let l=this._siblingIds(e),c=l.findIndex(d=>Object.is(d,e));this._rowMoveMessage.textContent=this._message("table.rowMoved","Moved row to position %1 of %2.",[c+1,l.length])}return this._emitDataChange(),queueMicrotask(()=>this._rowHandle(e)?.focus()),this}empty(){let e=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._extendBase=null,this._renderBody(),e&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(e,t,s={}){if(this._spanning)return this._sortWarned||(this._sortWarned=!0,console.warn("[zx.Table] setSort() is inert while the data contains spanning rowKinds rows: sorting would scatter the rows out of the sections that group them.")),this;if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===e))throw new RangeError(`Unknown table column: ${e}`);let r=t??(this._sort?.id===e&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:e,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),s.silent||this.emit("sort",{id:e,dir:r}),this}getSort(){return this._sort?{...this._sort}:null}clearSort(e={}){return this._sort?(this._abortEdit({focus:!1}),this._sort=null,this._syncSortHeader(),e.silent||this.emit("sort",{id:null,dir:null}),this):this}getSelection(){return this._data.filter(e=>this._selected.has(this._idFor(e)))}setSelection(e){if(!Array.isArray(e))throw new TypeError("Table selection must be an array of row ids");let t=this._selectableIds(),s=new Set;if(this.options.selectable!==!1){for(let n of e)if(t.has(n)&&s.add(n),this.options.selectable==="single"&&s.size>0)break}return this._extendBase=null,nn(this._selected,s)?this:(this._selected=s,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._extendBase=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(e,t={}){return this._expanded.has(e)?this.collapseRow(e,t):this.expandRow(e,t)}expandRow(e,t={}){return this._setRowExpanded(e,!0,t)}collapseRow(e,t={}){return this._setRowExpanded(e,!1,t)}expandAll(e={}){if(!this._hierarchy)return this;let s=ji(this._data,this.options.rowId,this._hierarchy.parentId).filter(n=>!this._expanded.has(n));for(let n of s)this._expanded.add(n);if(s.length&&this._renderBody(),!e.silent)for(let n of s)this._emitRowToggle(n,!0);return this}collapseAll(e={}){if(!this._hierarchy||this._expanded.size===0)return this;let t=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!e.silent)for(let s of t)this._emitRowToggle(s,!1);return this}getExpanded(){return this._data.map(e=>this._idFor(e)).filter(e=>this._expanded.has(e))}startEdit(e,t){if(this._editMode===!1)return this;let s=this._columns.find(p=>p.id===t);if(!s)return this;let n=this._data.find(p=>Object.is(this._idFor(p),e));if(n===void 0)return this;if(this._isSpanningRow(n))return this;let r=this._editMode==="row"&&this._hiddenColumns.has(s.id)?this._visibleColumns().find(p=>rt(p,n)!==!1)??null:s;if(!r||rt(r,n)===!1)return this;let o=r.id;if(this._edit){if(Object.is(this._edit.id,e)&&this._edit.cells.has(o))return this._edit.columnId=o,this._focusEditor(o),this;if(this.commitEdit(),this._edit)return this}let a=this._data.findIndex(p=>Object.is(this._idFor(p),e));if(a<0)return this;let l=this._data[a],c=this._rowById(e);if(!c)return this;let d=this._editMode==="row"?this._visibleColumns().filter(p=>rt(p,l)!==!1):[r],h=new Map;for(let p of d){let f=Ma(c,p.id);if(!f)continue;let m=this._createEditor(f,p,l,a);m&&h.set(p.id,m)}return h.size===0?this:(this._edit={id:e,columnId:o,row:l,cells:h,tr:c},c.dataset.editing="true",this.emit("editstart",{row:l,id:e,column:r,columnId:o,value:l?.[o]}),this._focusEditor(o),this)}commitEdit(){let e=this._edit;if(!e)return this;let t=this.getRow(e.id)??e.row,s={};for(let[h,p]of e.cells)s[h]=p.read();let n=this._columns.filter(h=>e.cells.has(h.id)),r=Nh(s,n,t,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),e.columnId=r.columnId,this.emit("editinvalid",{row:t,id:e.id,column:this._columns.find(h=>h.id===r.columnId)??null,columnId:r.columnId,value:s[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=Dh(t,s),a=e.columnId;if(this.emit("editcommit",{row:t,id:e.id,column:this._columns.find(h=>h.id===a)??null,columnId:a,value:s[a],previous:t?.[a],changes:o}).defaultPrevented)return this;let c=this._editHasFocus(),d={...t,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(e.id,d),c&&this._focusCell(this._idFor(d),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(e=>e.row)}_projectedData(){return this._hierarchy?Th(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((e,t)=>({row:e,id:this._idFor(e),index:t,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let e=this._projectedData();return this._rendered===1/0?e:e.slice(0,this._rendered)}growBy(e){if(!this._growStep)return this;let t=Number(e)>0?Math.trunc(Number(e)):this._growStep,s=this._rendered,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+t),this._rendered===s?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),this)}showAll(){return this.growBy(this._projectedData().length)}getRenderedCount(){return this._window?this._window.drawn.size:Math.min(this._rendered,this._projectedData().length)}reveal(e){if(this._window)return!!this._rowById(e,!0);let t=this._rowElements.get(e)?.[0];return t?.scrollIntoView({block:"nearest"}),!!t}_rowById(e,t=!1){let s=this._rowElements.get(e)?.[0];if(!this._window||s&&!t)return s;let n=this._hierarchyMeta?.get(e)?.visibleIndex;if(n!==void 0)return this._window.reveal(n)??void 0}_windowPins(){let e=t=>this._hierarchyMeta?.get(t)?.visibleIndex;return[this._currentPosition(),this._edit?e(this._edit.id):void 0,this._dragId==null?void 0:e(this._dragId)]}_currentPosition(){if(!this._current)return 0;let e=this._hierarchyMeta,t=e?.get(this._current.id)?.visibleIndex;if(t!==void 0)return t;let s=new Set,n=this._hierarchy?this.getRow(this._current.id):null;for(;n;){let r=te(this._hierarchy.parentId,n);if(r==null||s.has(r))break;s.add(r);let o=e?.get(r)?.visibleIndex;if(o!==void 0)return o;n=this.getRow(r)}return Math.min(Math.max(this._current.visibleIndex??0,0),Math.max(0,this._window.total-1))}_releaseRow(e){let t=this._rowMeta.get(e)?.id,s=this._rowElements.get(t)?.filter(n=>n!==e);s?.length?this._rowElements.set(t,s):this._rowElements.delete(t)}_syncGrowing(){if(!this._growStep)return;let e=this._projectedData().length-this.getRenderedCount();if(e<=0){this._more?.remove(),this._more=null;return}let t=this._message("table.more","Show %1 more",[e]);this._more||(this._more=u("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=t,this._more.setAttribute("aria-label",t)}_message(e,t,s){let n=this.msg(e,...s);return n===e?F(t,s):n}_watchWidth(){this._width?.destroy(),this._width=null;let e=this.options.responsive;!e||!(e in Pi)||(this._width=ya((t,s)=>this._setStacked(s>0&&s<Pi[e]),{target:this.el}))}_setStacked(e){this._stacked!==e&&(this._stacked=e,this.el.toggleAttribute("data-stacked",e),this._applyStackedRoles(e),this._window?.schedule(),this.emit("stackedchange",{stacked:e}))}addEventListener(e,t,s){super.addEventListener(e,t,s),!(!t||e!=="rowclick"&&e!=="rowdblclick")&&(this._clickListened=!0,this._table&&!this._interactive&&(this._interactive=!0,this._syncGridRole(),this._renderBody()))}_gridRole(){return this._interactive?this._hierarchy?"treegrid":"grid":null}_syncGridRole(){let e=this._table,t=this._gridRole();t?e.setAttribute("role",t):e.removeAttribute("role"),this.options.labelledBy?e.setAttribute("aria-labelledby",String(this.options.labelledBy)):(this.options.label!=null||t)&&e.setAttribute("aria-label",this.options.label??this._message("table.label","Table",[])),t&&this.options.selectable==="multi"&&e.setAttribute("aria-multiselectable","true"),t?this.el.dataset.focus=this._focusMode:delete this.el.dataset.focus}_applyStackedRoles(e){let t=this._gridRole();t?this._table.setAttribute("role",t):e?this._table.setAttribute("role","table"):this._table.removeAttribute("role");for(let s of[this._thead,this._tbody])e?s.setAttribute("role","rowgroup"):s.removeAttribute("role");for(let[s,n]of[["tr","row"],["td",t?"gridcell":"cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(s))e?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._window?.stop(),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(G(this.el,this._original),this._restored=!0),super.destroy()}_visibleColumns(){return this._columns.filter(e=>!this._hiddenColumns.has(e.id))}_isSpanningRow(e){return this._rowKind===null||this._rowKinds===null?!1:Fa(e,this._rowKind,this._rowKinds)}_hasSpanningRow(){return Sh(this._data,this._rowKind,this._rowKinds)}_spanColspan(){return Ah(this._visibleColumns().length,{selectable:this.options.selectable,rowReorder:this.options.rowReorder})}_selectableData(){let e=this._visibleData();return this._rowKind===null?e:e.filter(t=>!this._isSpanningRow(t))}_createColumnControls(){let e=u("div",{class:"zx-table__column-list"});this._columnList=e,this._columnStatus=u("div",{class:"zx-table__column-status",role:"status",ariaLive:"polite"});let t=u("details",{class:"zx-table__column-controls"},u("summary",{class:"zx-btn",dataset:{size:"sm"}},v("fields"),this._message("table.columns","Columns",[])),e);return this._renderColumnControls(),t}_renderColumnControls(e=null){if(!this._columnList)return;let t=this._visibleColumns(),s=this._columns.map((n,r)=>{let o=!this._hiddenColumns.has(n.id),a=this._columnControlIds.get(n.id);a||(a=E("zx-table-column"),this._columnControlIds.set(n.id,a));let l=this.options.columnVisibility?u("input",{id:a,class:"zx-table__column-toggle",type:"checkbox",value:n.id,checked:o,disabled:o&&t.length===1,dataset:{columnId:n.id,columnAction:"toggle"}}):null,c=Hi(n),d=l?u("label",{for:a},l,u("span",{},c)):u("span",{class:"zx-table__column-label"},c),h=this.options.columnReorder?u("span",{class:"zx-table__column-order",role:"group",ariaLabel:this._message("table.moveColumn","Move %1",[c])},u("button",{class:"zx-table__column-move",type:"button",disabled:r===0,ariaLabel:this._message("table.moveColumnEarlier","Move %1 earlier",[c]),dataset:{columnId:n.id,columnAction:"up"}},v("chevron-up",{size:T.chevron})),u("button",{class:"zx-table__column-move",type:"button",disabled:r===this._columns.length-1,ariaLabel:this._message("table.moveColumnLater","Move %1 later",[c]),dataset:{columnId:n.id,columnAction:"down"}},v("chevron-down",{size:T.chevron}))):null;return u("div",{class:"zx-table__column-option",dataset:{columnId:n.id}},d,h)});if(this._columnList.replaceChildren(...s,this._columnStatus),e!==null){let n=[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===e.id&&o.dataset.columnAction===e.action});n?.disabled&&(n=[...this._columnList.querySelectorAll(".zx-table__column-move[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===e.id&&!o.disabled})??[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===e.id&&!o.disabled})),queueMicrotask(()=>{n?.isConnected&&n.focus()})}}_activeColumnControl(){let e=typeof document>"u"?null:document.activeElement;if(!e||!this._columnList?.contains(e))return null;let t=e.dataset.columnId,s=e.dataset.columnAction;return t&&s?{id:t,action:s}:null}_handleColumnControlClick(e){let t=e.target?.closest?.(".zx-table__column-move");if(!t||!this._columnList?.contains(t))return;let s=t.dataset.columnId,n=t.dataset.columnAction,r=this.getColumnOrder().indexOf(String(s));n==="up"&&r>0&&this.moveColumn(String(s),this._columns[r-1].id,"before"),n==="down"&&r>=0&&r<this._columns.length-1&&this.moveColumn(String(s),this._columns[r+1].id,"after")}_handleColumnControlKeydown(e){let t=e.target?.closest?.(".zx-table__column-move");if(!t||!this._columnList?.contains(t))return;let s=String(t.dataset.columnId),n=this.getColumnOrder(),r=n.indexOf(s);r<0||(e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),r>0&&this.moveColumn(s,n[r-1],"before")):e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),r<n.length-1&&this.moveColumn(s,n[r+1],"after")):e.key==="Home"?(e.preventDefault(),r>0&&this.moveColumn(s,n[0],"before")):e.key==="End"&&(e.preventDefault(),r<n.length-1&&this.moveColumn(s,n.at(-1),"after")))}_handleRowDragStart(e){let t=e.target?.closest?.(".zx-table__row-handle"),s=t?.closest("tr[data-row]"),n=s?this._rowMeta.get(s):null;if(!t||!n||this._sort&&this.options.sortMode==="local"){e.preventDefault();return}this._dragId=n.id,s.dataset.dragging="true",e.dataTransfer?.setData("text/plain","zx-table-row"),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")}_handleRowDragOver(e){if(this._dragId==null)return;let t=e.target?.closest?.("tr[data-row]"),s=t?this._rowMeta.get(t):null;if(!s||Object.is(s.id,this._dragId)||!this._canMoveTogether(this._dragId,s.id))return;e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),this._clearDropMarkers();let n=t.getBoundingClientRect();t.dataset.drop=e.clientY>=n.top+n.height/2?"after":"before"}_handleRowDrop(e){if(this._dragId==null)return;let t=e.target?.closest?.("tr[data-row]"),s=t?this._rowMeta.get(t):null,n=t?.dataset.drop==="after"?"after":"before";s&&this._canMoveTogether(this._dragId,s.id)&&(e.preventDefault(),this.moveRow(this._dragId,s.id,n)),this._clearRowDrag()}_handleRowHandleKeydown(e){let t=e.target?.closest?.(".zx-table__row-handle"),s=t?.closest("tr[data-row]"),n=s?this._rowMeta.get(s):null;if(!t||!n)return;if(e.key===" "||e.key==="Enter"){e.preventDefault(),this._grabbedId=Object.is(this._grabbedId,n.id)?null:n.id,t.setAttribute("aria-pressed",String(this._grabbedId!=null));let l=this._rowMoveMessage??this._editMessage;l&&(l.textContent=this._grabbedId==null?this._message("table.rowDropped","Row dropped",[]):this._message("table.rowGrabbed","Row grabbed. Use the arrow keys to move it.",[]));return}if(e.key==="Escape"&&this._grabbedId!=null){e.preventDefault(),this._grabbedId=null,t.setAttribute("aria-pressed","false");return}if(!Object.is(this._grabbedId,n.id)||!["ArrowUp","ArrowDown"].includes(e.key))return;e.preventDefault();let r=this._siblingIds(n.id),o=r.findIndex(l=>Object.is(l,n.id)),a=r[o+(e.key==="ArrowUp"?-1:1)];a!==void 0&&this.moveRow(n.id,a,e.key==="ArrowUp"?"before":"after")}_siblingIds(e){let t=this.getRow(e);if(!t)return[];let s=this._hierarchy?te(this._hierarchy.parentId,t):null;return this._data.filter(n=>!this._hierarchy||on(te(this._hierarchy.parentId,n),s)).map(n=>this._idFor(n))}_canMoveTogether(e,t){if(!this._hierarchy)return!0;let s=this.getRow(e),n=this.getRow(t);return!!(s&&n&&on(te(this._hierarchy.parentId,s),te(this._hierarchy.parentId,n)))}_rowHandle(e){return this._rowElements.get(e)?.[0]?.querySelector(".zx-table__row-handle")??null}_clearDropMarkers(){for(let e of this._tbody.querySelectorAll("tr[data-drop]"))delete e.dataset.drop}_clearRowDrag(){for(let e of this._tbody.querySelectorAll("tr[data-dragging]"))delete e.dataset.dragging;this._clearDropMarkers(),this._dragId=null}_hierarchyColumn(){return this._hierarchy?this._visibleColumns().some(e=>e.id===this._hierarchy.column)?this._hierarchy.column:this._visibleColumns()[0]?.id??null:null}_renderColumns(){let e=document.createDocumentFragment();this.options.rowReorder&&e.append(u("col",{class:"zx-table__reorder-column"})),this.options.selectable==="multi"&&e.append(u("col",{class:"zx-table__selection-column"}));let t=this._visibleColumns(),s=t.map(r=>$h(r.width)),n=s.reduce((r,o)=>r+o,0);this._table.dataset.layout=n>0||this._virtual?"fixed":"auto",t.forEach((r,o)=>{let a=u("col");s[o]>0?a.style.width=`${s[o]/n*100}%`:r.width&&r.width!=="auto"&&(a.style.width=String(r.width)),e.append(a)}),this._colgroup.replaceChildren(e)}_renderHeader(){let e=u("tr",{class:"zx-table__header-row"});if(this._indexed&&e.setAttribute("aria-rowindex","1"),this.options.rowReorder&&e.append(u("th",{class:"zx-table__reorder-header",scope:"col",ariaLabel:this._message("table.rowOrder","Row order",[])})),this.options.selectable==="multi"){this._selectAll=u("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:this._message("table.selectAll","Select all rows",[])});let t=u("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);e.append(t),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let s of this._selectableData())this._selected.add(this._idFor(s));else for(let s of this._selectableData())this._selected.delete(this._idFor(s));this._selectionAnchorId=null,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map,this._headerSpanning=this._spanning;for(let t of this._visibleColumns()){let s=u("th",{scope:"col",dataset:{column:t.id}}),n=t.align??(rn(t)?"end":null);n&&(s.dataset.align=n),t.headerTitle&&(s.title=t.headerTitle);let r=jh(t);if(r!==null&&s.setAttribute("aria-label",r),t.sortable&&!this._spanning){let o=u("button",{class:"zx-table__sort-button",type:"button",ariaLabel:r??void 0},u("span",{class:"zx-table__header-label"},t.label),u("span",{class:"zx-table__sort-icon",ariaHidden:"true"},v("arrow-up",{size:T.sort})));this.listen(o,"click",()=>{let a=this._sort?.id===t.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(t.id,a)}),s.append(o)}else s.append(u("span",{class:"zx-table__header-label"},t.label));this._headers.set(t.id,s),e.append(s)}this._thead.replaceChildren(e),this._syncSortHeader()}_renderBody(){let e=this._captureFocus();this._abortEdit({focus:!1}),this._extendBase=null,this._selectionAnchorId=null,this._spanning=this._hasSpanningRow(),this._headers&&this._spanning!==this._headerSpanning&&this._renderHeader();let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._rovingEl=null;let s=this._projectedData();this._hierarchyMeta=new Map(s.map(n=>[n.id,n])),this._data.length===0?(this._window?.clear(),t.append(u("tr",{class:"zx-table__empty-row"},u("td",{class:"zx-table__empty",colspan:this._spanColspan()},this._emptyContent())))):this._window?(s.forEach((n,r)=>{n.visibleIndex=r}),this._window.fill(s,t)):this._visibleEntries().forEach((n,r)=>{t.append(this._createRow(n.row,n.index,{...n,visibleIndex:r}))}),this._tbody.replaceChildren(t),this._table.setAttribute("aria-colcount",String(this._visibleColumns().length+(this.options.selectable==="multi"?1:0)+(this.options.rowReorder?1:0))),this._indexed&&this._table.setAttribute("aria-rowcount",String(s.length+1)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0),this._window?.settle(),this._syncRoving(e)}_emptyContent(){let e=this.options.emptyText;return e==null?this.msg("table.empty"):typeof e=="function"?e():e}_createRow(e,t,s){let n=this._idFor(e),r=u("tr",{dataset:{row:""}});this._indexed&&r.setAttribute("aria-rowindex",String(s.visibleIndex+2)),this._virtual&&s.visibleIndex%2===1&&(r.dataset.stripe="");let o=typeof this.options.rowClass=="function"?this.options.rowClass(e):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean));let a=this._rowKind===null?null:Ra(e,this._rowKind),l=a===null?null:La(this._rowKinds,a),c=!!l?.span;a!==null&&(r.dataset.rowKind=a),l?.class&&r.classList.add(...String(l.class).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&!c&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(s.depth+1)),s.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._interactive&&(this._focusMode==="row"||this._hierarchy)&&(r.tabIndex=-1),this._rowMeta.set(r,{row:e,id:n,index:t,visibleIndex:s.visibleIndex});let d=this._rowElements.get(n)??[];if(d.push(r),this._rowElements.set(n,d),c){r.dataset.span="true";let h=u("th",{class:"zx-table__section-cell",scope:"colgroup",colspan:this._spanColspan()}),p=kh(e,l,this._visibleColumns(),t);return p&&typeof p=="object"&&typeof p.nodeType=="number"?h.append(p):p!=null&&h.append(document.createTextNode(String(p))),this._focusMode==="cell"&&(h.tabIndex=-1),r.append(h),r}if(this.options.rowReorder){let h=u("button",{class:"zx-table__row-handle",type:"button",draggable:!0,dataset:{rowHandle:""},ariaPressed:String(Object.is(this._grabbedId,n)),disabled:!!(this._sort&&this.options.sortMode==="local"),title:this._sort&&this.options.sortMode==="local"?this._message("table.reorderBlocked","Clear sorting to reorder rows",[]):null},v("drag",{size:14}));r.append(u("td",{class:"zx-table__reorder-cell"},h))}if(this.options.selectable==="multi"){let h=u("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",tabIndex:-1,checked:this._selected.has(n)});r.append(u("td",{class:"zx-table__selection-cell"},h))}return this._visibleColumns().forEach(h=>{let p=u("td"),f=h.align??(rn(h)?"end":null);f&&(p.dataset.align=f),p.dataset.label=h.label,p.dataset.column=h.id,h.popin===!1&&(p.dataset.popin="false"),this._focusMode==="cell"&&(p.tabIndex=-1),this._editMode!==!1&&rt(h,e)!==!1&&(p.dataset.editable="true"),this._renderCellContent(p,h,e,t,s),r.append(p)}),this._rowNames.set(r,xh([...r.cells].map(h=>h.textContent))),this._labelRowControls(r),r}_labelRowControls(e){let t=this._rowMeta.get(e);if(!t)return;let s=this._rowNames.get(e)??this._message("table.row","row %1",[t.index+1]);e.querySelector(".zx-table__row-checkbox")?.setAttribute("aria-label",this._message("table.selectRow","Select %1",[s])),e.querySelector(".zx-table__row-handle")?.setAttribute("aria-label",this._message("table.moveRow","Move %1",[s]));let r=e.querySelector(".zx-table__tree-toggle");if(r){let o=r.getAttribute("aria-expanded")==="true";r.setAttribute("aria-label",o?this._message("table.collapseRow","Collapse %1",[s]):this._message("table.expandRow","Expand %1",[s]))}}_renderCellContent(e,t,s,n,r=this._hierarchyMeta?.get(this._idFor(s))){let o=Ch(t,s,n),a=u("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?a.append(o):o!=null&&a.append(document.createTextNode(String(o))),!this._hierarchy||t.id!==this._hierarchyColumn()||!r){e.replaceChildren(...a.childNodes);return}let l=u("span",{class:"zx-table__tree-cell"});if(l.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let c=this._expanded.has(r.id);l.append(u("button",{class:"zx-table__tree-toggle",type:"button",tabIndex:-1,ariaExpanded:String(c)},v(c?"chevron-down":"chevron-right",{size:T.chevron})))}else l.append(u("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));l.append(a),e.replaceChildren(l),e.parentElement&&this._labelRowControls(e.parentElement)}_handleBodyClick(e){let t=e.target?.nodeType===1?e.target:e.target?.parentElement;if(this._edit&&Mt(t))return;let s=t?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(!n||t.closest(".zx-table__row-handle")||this._edit&&(this.commitEdit(),this._edit))return;if(t.closest(".zx-table__tree-toggle")){this.toggleRow(n.id);return}let o=t.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(n,o.checked,e.shiftKey);return}if(!(this._editMode!==!1&&Ea(t))){if(this._editMode!==!1&&this._editTrigger==="single"){let a=t?.closest('td[data-editable="true"]');if(a&&this._tbody.contains(a)){this.startEdit(n.id,String(a.dataset.column));return}}this._activateRow(n,e)}}_activateRow(e,t){this.emit("rowclick",{...e,event:t}),this.options.selectable==="single"&&!this._selected.has(e.id)&&!this._isSpanningRow(e.row)&&(this._selected=new Set([e.id]),this._selectionAnchorId=e.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange())}_handleBodyDoubleClick(e){let t=e.target?.nodeType===1?e.target:e.target?.parentElement;if(t?.closest(".zx-table__row-checkbox")||this._edit&&Mt(t))return;let s=t?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(n&&!(this._editMode!==!1&&Ea(t))){if(this._editMode!==!1&&this._editTrigger==="double"){let r=t?.closest('td[data-editable="true"]');if(r&&this._tbody.contains(r)){this.startEdit(n.id,String(r.dataset.column));return}}this.emit("rowdblclick",{...n,event:e})}}_createEditor(e,t,s,n){let r=rt(t,s);if(r===!1)return null;let o=s?.[t.id],a=t.editorProps&&typeof t.editorProps=="object"?t.editorProps:{},l=u("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});l.append(...e.childNodes);let c=u("div",{class:"zx-table__editor",dataset:{editor:r}});e.replaceChildren(l,c),e.dataset.editing="true";let d={column:t,type:r,td:e,host:c,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){d.custom=o,d.read=()=>Be(t,d.custom,s);let f={value:o,row:s,column:t,commit:g=>{d.custom=g,this.commitEdit()},cancel:()=>this.cancelEdit()},m=t.editor(s,f);return m&&typeof m.toElement=="function"?(typeof m.destroy=="function"&&(d.component=m),c.append(m.toElement())):m&&c.append(m),d.control=c.querySelector(bh)??c,d}if(r==="number"){let f=qe(t.locale,s),m=Va(t,s),g=t.type==="currency"?qe(t.currency,s):t.type==="unit"?qe(t.unit,s):null,_={...f!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:f}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:m}:{},...g!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(g)}:{}},b=new Xe(null,{..._,...a,value:o??null});return c.append(b.el),d.component=b,d.control=b.getInput(),d.read=()=>(b.set(b.getInput().value,{silent:!0}),Be(t,b.get(),s)),d}if(r==="select"){let f=Eh(t.options,s),m=f.find(_=>Object.is(_.value,o))??f.find(_=>String(_.value)===String(o??"")),g=new q(null,{...a,items:f,valueKey:"value",labelKey:"label",value:m?m.value:null});return c.append(g.el),d.component=g,d.control=g.refs.input,d.read=()=>Be(t,g.value,s),d}if(r==="date"){let f=new Ve(null,{...a,value:o??null});c.append(f.el),d.component=f;let m=f.refs.input;return d.control=m,d.read=()=>{let g=String(m.value??"").trim(),_=f.get();return g===""?Be(t,null,s):(f.set(g,{silent:!0}),f.get()===null&&f.set(_,{silent:!0}),Be(t,f.get(),s))},d}if(r==="checkbox"){let f=new et(null,{...a,checked:!!o});return c.append(f.el),d.component=f,d.control=f.el,d.read=()=>Be(t,f.get(),s),d}let h=r==="textarea",p=u(h?"textarea":"input",{...a,class:h?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...h?{}:{type:"text"},ariaLabel:a.ariaLabel??this._message("table.cellInput","%1 row %2",[Hi(t),n+1]),value:Ih(t,o,s)});return c.append(p),d.control=p,d.read=()=>Be(t,p.value,s),d}_focusEditor(e){let t=this._edit?.cells.get(e),s=t?.control;!s||typeof s.focus!="function"||(s.focus(),Bh(t.type)&&typeof s.select=="function"&&s.select())}_focusCell(e,t){let s=this._rowById(e);(s?Ma(s,t):null)?.focus()}_teardownEdit(){let e=this._edit;if(!e)return;this._edit=null;let t=this._data.findIndex(n=>Object.is(this._idFor(n),e.id)),s=t<0?e.row:this._data[t];for(let n of e.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.column,s,t<0?0:t);e.cells.clear(),delete e.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:e=!0}={}){let t=this._edit;if(!t)return;let s=e&&this._editHasFocus(),n=this.getRow(t.id)??t.row,r=this._columns.find(o=>o.id===t.columnId)??null;this._teardownEdit(),s&&this._focusCell(t.id,t.columnId),this.emit("editcancel",{row:n,id:t.id,column:r,columnId:t.columnId})}_editHasFocus(){let e=document.activeElement;return!!(e&&this.el?.contains(e))}_markInvalid(e,t){this._clearInvalid();let s=this._edit?.cells.get(e);s&&(s.td.dataset.invalid="true",s.control?.setAttribute("aria-invalid","true"),this._editMessage&&(s.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=t))}_clearInvalid(){if(this._edit)for(let e of this._edit.cells.values())delete e.td.dataset.invalid,e.control?.removeAttribute("aria-invalid"),e.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(e){let t=e.target?.nodeType===1?e.target:e.target?.parentElement;if(!t)return;if(this._edit&&Mt(t)){if(Vh(t))return;if(e.key==="Escape"){if(e.defaultPrevented)return;e.preventDefault(),this.cancelEdit();return}if(e.key==="Enter"){if(t.localName==="textarea"&&e.shiftKey)return;e.preventDefault(),this.commitEdit();return}e.key==="Tab"&&this._moveEdit(e);return}if(e.key!=="Enter"&&e.key!=="F2")return;let s=t.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s.parentElement);n&&(e.preventDefault(),this.startEdit(n.id,String(s.dataset.column)))}_moveEdit(e){let t=this._edit;if(!t)return;let s=e.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),t.id)),r=this._nextEditableCell(n,t.columnId,s);if(r&&Object.is(r.id,t.id)&&t.cells.has(r.columnId)){e.preventDefault(),t.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&e.preventDefault();return}e.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(e,t,s){let n=this._visibleColumns(),r=n.length;if(e<0||r===0)return null;let o=this._visibleData(),a=this._idFor(this._data[e]),l=o.findIndex(h=>Object.is(this._idFor(h),a));if(l<0)return null;let c=n.findIndex(h=>h.id===t),d=o.length*r+r;for(let h=0;h<d;h+=1){if(c+=s,c>=r?(l+=1,c=0):c<0&&(l-=1,c=r-1),l<0||l>=o.length)return null;let p=o[l],f=n[c];if(!this._isSpanningRow(p)&&rt(f,p)!==!1)return{id:this._idFor(p),columnId:f.id,index:this._data.indexOf(p)}}return null}_handleDocumentPointerDown(e){if(!this._edit)return;let t=e.target?.nodeType===1?e.target:e.target?.parentElement;t&&Mt(t)||t&&this._tbody.contains(t)||this.commitEdit()}_navRows(){return[...this._tbody.children].filter(e=>e.hasAttribute("data-row"))}_navCells(e){return[...e.cells].filter(t=>t.hasAttribute("data-column")||t.classList.contains("zx-table__section-cell"))}_cellFor(e){let t=this._navCells(e);if(t.length===0)return e;let s=this._current?.columnId;return(s==null?null:t.find(r=>r.dataset.column===s))??t[Math.min(Math.max(this._current?.columnIndex??0,0),t.length-1)]}_rovingTarget(e){return this._focusMode==="row"||this._hierarchy&&this._current?.onRow?e:this._cellFor(e)}_setRoving(e){this._rovingEl&&this._rovingEl!==e&&(this._rovingEl.tabIndex=-1),e.tabIndex=0,this._rovingEl=e}_captureFocus(){let e=typeof document>"u"?null:document.activeElement;if(e&&e===this._scroll&&this._scroll.hasAttribute("data-empty-focus"))return{part:"row"};if(!e||!this._tbody?.contains(e))return null;let t=e.closest("tr[data-row]");return t?e===t?{part:"row"}:e.closest(".zx-table__row-checkbox")?{part:"checkbox"}:e.closest(".zx-table__tree-toggle")?{part:"toggle"}:e.closest(".zx-table__row-handle")?{part:"handle"}:{part:this._focusMode==="cell"?"cell":"row"}:null}_syncRoving(e){if(!this._interactive)return;let t=this._navRows();if(this._syncEmptyFocus(t.length===0&&e!==null),t.length===0)return;let s=this._current?this._rowElements.get(this._current.id)?.[0]:void 0;if(!s&&this._current&&this._hierarchy&&(s=this._renderedAncestor(this._current.id),s)){let a=this._rowMeta.get(s);this._current={...this._current,id:a.id,visibleIndex:a.visibleIndex,onRow:!0}}if(!s&&(s=this._window?this._window.drawn.get(this._currentPosition()):t[Math.min(Math.max(this._current?.visibleIndex??0,0),t.length-1)],this._current)){let a=this._rowMeta.get(s);this._current={...this._current,id:a.id,visibleIndex:a.visibleIndex}}let n=this._rovingTarget(s);if(this._setRoving(n),!e)return;let r={checkbox:".zx-table__row-checkbox",toggle:".zx-table__tree-toggle",handle:".zx-table__row-handle:not(:disabled)"}[e.part];(r?s.querySelector(r)??n:n).focus({preventScroll:!0})}_renderedAncestor(e){if(!this._hierarchy)return;let t=new Set,s=this.getRow(e);for(;s;){let n=te(this._hierarchy.parentId,s);if(n==null||t.has(n))return;t.add(n);let r=this._rowElements.get(n)?.[0];if(r)return r;s=this.getRow(n)}}_syncEmptyFocus(e){let t=this._scroll;e?(t.hasAttribute("tabindex")||(t.tabIndex=-1,t.setAttribute("data-empty-focus","")),t.focus({preventScroll:!0})):t.hasAttribute("data-empty-focus")&&(t.removeAttribute("tabindex"),t.removeAttribute("data-empty-focus"))}_handleFocusIn(e){if(!this._interactive)return;let t=e.target?.nodeType===1?e.target:null,s=t?.closest("tr[data-row]")??null;if(!s||s.parentElement!==this._tbody)return;let n=this._rowMeta.get(s);if(!n)return;let r={id:n.id,visibleIndex:n.visibleIndex,columnId:this._current?.columnId??null,columnIndex:this._current?.columnIndex??0,onRow:!1},o=s;if(this._focusMode==="cell"){let a=this._navCells(s),l=a.find(c=>c===t||c.contains(t))??null;t===s&&this._hierarchy?r.onRow=!0:l?(o=l,l.dataset.column&&(r.columnId=l.dataset.column,r.columnIndex=a.indexOf(l))):(this._current=r,o=this._cellFor(s))}this._current=r,this._setRoving(o)}_handleGridKeydown(e){if(!this._interactive||e.defaultPrevented||e.altKey)return;let t=e.target?.nodeType===1?e.target:null;if(!t||this._edit&&Mt(t))return;let s=t.closest("tr[data-row]");if(!s||s.parentElement!==this._tbody)return;let n=this._rowMeta.get(s);if(!n)return;let r=this._focusMode==="cell",o=r?this._navCells(s):[],a=t===s,l=o.includes(t),c=t.matches(".zx-table__row-checkbox, .zx-table__tree-toggle");if(!a&&!l&&!c)return;let d=e.key,h=e.ctrlKey||e.metaKey;if(h&&(d==="a"||d==="A")){if(this.options.selectable!=="multi")return;e.preventDefault(),this._selectAllRendered();return}if((d==="Enter"||d===" ")&&!c){if(h)return;e.preventDefault(),d===" "&&this.options.selectable!==!1&&!this._isSpanningRow(n.row)?this._toggleRowSelection(n):this._activateRow(n,e);return}if(this._hierarchy&&(d==="ArrowLeft"||d==="ArrowRight")&&!h){let w=this._hierarchyMeta?.get(n.id);if(!w)return;e.preventDefault();let A=vh(d,{focus:l?"cell":"row",cells:r,column:l?o.indexOf(t):0,columns:o.length,hasChildren:w.hasChildren,expanded:this._expanded.has(n.id),hasParent:w.parentId!=null});A&&this._applyTreeAction(A,s,n,w.parentId);return}let p=this._navRows(),f=this._window?n.visibleIndex:p.indexOf(s),m=r&&!a,g=l?o.indexOf(t):Math.max(0,o.indexOf(this._cellFor(s))),_=yh({row:f,column:g},d,{rows:this._window?.total??p.length,columns:m?o.length:1,page:this._pageSize(p),ctrl:h,cells:m});if(!_)return;e.preventDefault();let b=this._window?this._window.reveal(_.row):p[_.row];if(!m)b.focus();else if(_.row===f||d==="Home"||d==="End"){let w=this._navCells(b),A=_.column>=o.length-1&&d!=="Home";w[A?w.length-1:Math.min(_.column,w.length-1)]?.focus()}else this._cellFor(b).focus();e.shiftKey&&this.options.selectable==="multi"&&_.row!==f&&this._extendSelection(n,this._rowMeta.get(b))}_applyTreeAction(e,t,s,n){if(e.action==="expand")this.expandRow(s.id);else if(e.action==="collapse")this.collapseRow(s.id);else if(e.action==="parent")this._rowById(n)?.focus();else if(e.action==="child"){let r=this._navRows();(this._window?this._window.reveal(s.visibleIndex+1):r[r.indexOf(t)+1])?.focus()}else e.action==="row"?t.focus():e.action==="cell"&&this._navCells(t)[e.column??0]?.focus()}_pageSize(e){let t=this._scroll;if(!t||!e[0]||t.scrollHeight<=t.clientHeight+1)return 10;let s=this.options.stickyHeader?this._thead.getBoundingClientRect().height:0;return wh(t.clientHeight-s,e[0].getBoundingClientRect().height)}_toggleRowSelection(e){let t=this._selected.has(e.id);if(this.options.selectable==="multi"){this._toggleMultiSelection(e,!t,!1);return}this._selected=t?new Set:new Set([e.id]),this._selectionAnchorId=e.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()}_selectAllRendered(){let e=new Set(this._selected);for(let t of this._selectableData())e.add(this._idFor(t));this._extendBase=null,!nn(e,this._selected)&&(this._selected=e,this._syncSelection(),this._emitSelectionChange())}_extendSelection(e,t){if(!t)return;let s=this._visibleData(),n=l=>s.findIndex(c=>Object.is(this._idFor(c),l));this._extendBase===null&&(this._extendBase=new Set(this._selected),n(this._selectionAnchorId)<0&&(this._selectionAnchorId=e.id));let r=n(this._selectionAnchorId),o=n(t.id);if(r<0||o<0)return;let a=new Set(this._extendBase);for(let l=Math.min(r,o);l<=Math.max(r,o);l+=1)this._isSpanningRow(s[l])||a.add(this._idFor(s[l]));nn(a,this._selected)||(this._selected=a,this._syncSelection(),this._emitSelectionChange())}_msgOr(e,t){let s=this.msg(e);return s===e?t:s}_toggleMultiSelection(e,t,s){let n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(s&&r>=0){let o=e.visibleIndex??n.findIndex(c=>Object.is(this._idFor(c),e.id)),a=Math.min(r,o),l=Math.max(r,o);for(let c=a;c<=l;c+=1){if(this._isSpanningRow(n[c]))continue;let d=this._idFor(n[c]);t?this._selected.add(d):this._selected.delete(d)}}else t?this._selected.add(e.id):this._selected.delete(e.id);this._selectionAnchorId=e.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[e,t]of this._rowElements){let s=this._selected.has(e);for(let n of t){if(n.hasAttribute("data-span"))continue;n.setAttribute("aria-selected",String(s));let r=n.querySelector(".zx-table__row-checkbox");r&&(r.checked=s)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let e=this._selectableData(),t=e.reduce((s,n)=>s+Number(this._selected.has(this._idFor(n))),0);this._selectAll.disabled=e.length===0,this._selectAll.checked=e.length>0&&t===e.length,this._selectAll.indeterminate=t>0&&t<e.length}_syncSortHeader(){if(this._headers)for(let[e,t]of this._headers)!this._spanning&&this._sort?.id===e?t.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):t.removeAttribute("aria-sort")}_sortData(){if(this._spanning=this._hasSpanningRow(),!this._sort||this._spanning)return;let e=this._columns.find(s=>s.id===this._sort.id);if(!e)return;let t=typeof e.sortValue=="function"?e.sortValue:s=>s?.[e.id];this._data=this._hierarchy?zh(this._data,this.options.rowId,this._hierarchy.parentId,t,this._sort.dir):sn(this._data,t,this._sort.dir)}_setRowExpanded(e,t,s){return this._hierarchy?ji(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,e))?this._expanded.has(e)===t?this:(t?this._expanded.add(e):this._expanded.delete(e),this._renderBody(),s.silent||this._emitRowToggle(e,t),this):this:this}_emitRowToggle(e,t){let s=this.getRow(e);s&&this.emit("rowtoggle",{row:s,id:e,expanded:t})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let e=ji(this._data,this.options.rowId,this._hierarchy.parentId),t=new Set(e);for(let s of this._expanded)t.has(s)||this._expanded.delete(s)}_selectableIds(){let e=new Set;for(let t of this._data)this._isSpanningRow(t)||e.add(this._idFor(t));return e}_pruneSelection(){let e=this._selectableIds(),t=this._selected.size;for(let s of this._selected)e.has(s)||this._selected.delete(s);return e.has(this._selectionAnchorId)||(this._selectionAnchorId=null),this._extendBase=null,t!==this._selected.size}_idFor(e){return typeof this.options.rowId=="function"?this.options.rowId(e):e?.[this.options.rowId]}_emitSelectionChange(){let e=this.getSelection();this.emit("selectionchange",{rows:e,ids:e.map(t=>this._idFor(t))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function yh(i,e,t){let s=Math.trunc(Number(t?.rows)||0);if(s<=0)return null;let n=Math.max(1,Math.trunc(Number(t?.columns)||1)),r=Math.max(1,Math.trunc(Number(t?.page)||10)),o=(h,p)=>Math.min(Math.max(Math.trunc(Number(h)||0),0),p),a=o(i?.row,s-1),l=o(i?.column,n-1),c=!!t?.cells,d=!!t?.ctrl;switch(e){case"ArrowUp":return{row:Math.max(0,a-1),column:l};case"ArrowDown":return{row:Math.min(s-1,a+1),column:l};case"PageUp":return{row:Math.max(0,a-r),column:l};case"PageDown":return{row:Math.min(s-1,a+r),column:l};case"ArrowLeft":return c?{row:a,column:Math.max(0,l-1)}:null;case"ArrowRight":return c?{row:a,column:Math.min(n-1,l+1)}:null;case"Home":return c?d?{row:0,column:0}:{row:a,column:0}:{row:0,column:l};case"End":return c?d?{row:s-1,column:n-1}:{row:a,column:n-1}:{row:s-1,column:l};default:return null}}function wh(i,e,t=10){let s=Number(i),n=Number(e);return!(s>0)||!(n>0)?Math.max(1,Math.trunc(t)||10):Math.max(1,Math.floor(s/n)-1)}function vh(i,e){let t=i==="ArrowRight";if(!t&&i!=="ArrowLeft")return null;if(e?.focus==="cell"){let r=Math.max(0,Math.trunc(Number(e.column)||0)),o=Math.max(1,Math.trunc(Number(e.columns)||1));return t?r<o-1?{action:"cell",column:r+1}:null:r>0?{action:"cell",column:r-1}:{action:"row"}}let s=!!e?.hasChildren,n=s&&!!e?.expanded;return t?s&&!n?{action:"expand"}:e?.cells?{action:"cell",column:0}:n?{action:"child"}:null:n?{action:"collapse"}:e?.hasParent?{action:"parent"}:null}function xh(i,e=80){for(let t of Array.isArray(i)?i:[]){let s=String(t??"").replace(/\s+/g," ").trim();if(s)return s.length>e?`${s.slice(0,Math.max(1,e-1)).trimEnd()}\u2026`:s}return null}function Ra(i,e){if(e==null||e==="")return null;let t=typeof e=="function"?e(i):i?.[e];return t==null?null:String(t)}function La(i,e){if(e===null||i==null||typeof i!="object"||!Object.prototype.hasOwnProperty.call(i,e))return null;let t=i[e];return t&&typeof t=="object"?t:null}function Fa(i,e,t){return!!La(t,Ra(i,e))?.span}function Sh(i,e,t){return!Array.isArray(i)||e==null||t==null?!1:i.some(s=>Fa(s,e,t))}function Ah(i,e={}){let t=Number.isFinite(Number(i))?Math.max(0,Math.trunc(Number(i))):0,s=(e.selectable==="multi"?1:0)+(e.rowReorder?1:0);return Math.max(1,t+s)}function kh(i,e,t,s=0){if(typeof e?.render=="function")return e.render(i,s);let n=t?.[0];return n?i?.[n.id]:null}function Ch(i,e,t=0){if(typeof i?.render=="function")return i.render(e,t);let s=e?.[i?.id],n=i?.type??"text";if(n==="text")return s;let r=qe(i.locale,e),o=Va(i,e),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return Oe(s,a);if(n==="currency"){let l=qe(i.currency,e);return We(s,l==null?null:String(l),a)}if(n==="percent")return nr(s,a);if(n==="unit"){let l=Oe(s,a),c=qe(i.unit,e);return l&&c!=null&&String(c)!==""?`${l}\xA0${c}`:l}return s}function Th(i,e,t,s=[]){let n=$i(i,e,t),r=s instanceof Set?s:new Set(s),o=[],a=n.roots.slice().reverse().map(l=>({node:l,depth:0}));for(;a.length;){let{node:l,depth:c}=a.pop();if(o.push({row:l.row,id:l.id,index:l.index,depth:c,hasChildren:l.children.length>0,parentId:l.parent?.id??null}),!!r.has(l.id))for(let d=l.children.length-1;d>=0;d-=1)a.push({node:l.children[d],depth:c+1})}return o}function zh(i,e,t,s,n){let r=$i(i,e,t),o=c=>sn(c,d=>s(d.row),n),a=[],l=o(r.roots).reverse();for(;l.length;){let c=l.pop();a.push(c.row);let d=o(c.children);for(let h=d.length-1;h>=0;h-=1)l.push(d[h])}return a}function Pa(i,e,t,s,n="before",r=null){if(!Array.isArray(i)||Object.is(t,s))return null;let o=i.findIndex(h=>Object.is(te(e,h),t)),a=i.findIndex(h=>Object.is(te(e,h),s));if(o<0||a<0||r&&!on(te(r,i[o]),te(r,i[a])))return null;if(r){let h=$i(i,e,r),p=h.nodes[o],f=h.nodes[a];if(!p||!f||p.parent!==f.parent)return null;let m=x=>{let z=[],Y=[x];for(;Y.length;){let ae=Y.pop();z.push(ae);for(let se=ae.children.length-1;se>=0;se-=1)Y.push(ae.children[se])}return z},g=new Set(m(p).map(x=>x.index)),_=new Set(m(f).map(x=>x.index)),b=i.filter((x,z)=>g.has(z)),w=i.filter((x,z)=>!g.has(z)),A=i.map((x,z)=>z).filter(x=>!g.has(x)),y=A.findIndex(x=>x===a);if(n==="after"){let x=A.map((z,Y)=>_.has(z)?Y:-1).filter(z=>z>=0);y=Math.max(...x)+1}return y<0?null:(w.splice(y,0,...b),w)}let l=[...i],[c]=l.splice(o,1),d=l.findIndex(h=>Object.is(te(e,h),s));return l.splice(d+(n==="after"?1:0),0,c),l}function rt(i,e){if(!i||typeof i!="object")return!1;if(typeof i.editor=="function")return typeof i.editable=="function"&&i.editable(e)===!1?!1:"custom";let t=typeof i.editable=="function"?i.editable(e):i.editable;return t===!0?rn(i)?"number":"text":typeof t=="string"&&_h.has(t)?t:!1}function Eh(i,e){let t=typeof i=="function"?i(e):i;return Array.isArray(t)?t.map(s=>s!==null&&typeof s=="object"?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}):t!==null&&typeof t=="object"?Object.entries(t).map(([s,n])=>({value:s,label:String(n??"")})):[]}function Ih(i,e,t){if(typeof i?.format=="function"){let s=i.format(e,t);return s==null?"":String(s)}return e==null?"":String(e)}function Be(i,e,t){return typeof i?.parse=="function"?i.parse(e,t):e}function Mh(i,e){return Object.is(i,e)?!0:i instanceof Date&&e instanceof Date?i.getTime()===e.getTime():!1}function Dh(i,e){let t={};for(let[s,n]of Object.entries(e??{}))Mh(i?.[s],n)||(t[s]=n);return t}function Nh(i,e,t,s="Invalid value"){for(let n of e??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(i??{},n.id))continue;let r=n.validate(i[n.id],t);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:s}}return null}function qe(i,e){return typeof i=="function"?i(e):i}function Va(i,e){let t=qe(i?.decimals,e);if(t==null)return null;let s=Number(t);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function rn(i){return["number","currency","percent","unit"].includes(i?.type)}function $i(i,e,t){let s=(Array.isArray(i)?i:[]).map((a,l)=>({row:a,id:te(e,a),index:l,parent:null,children:[]})),n=new Map;for(let a of s)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of s){let l=te(t,a.row),c=l==null?null:n.get(l)??null;r.set(a,c===a?null:c)}for(let a of s){let l=new Set([a]),c=r.get(a)??null;for(;c;){if(l.has(c)){r.set(c,null);break}l.add(c),c=r.get(c)??null}}let o=[];for(let a of s)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:s}}function ji(i,e,t){return $i(i,e,t).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function te(i,e){return typeof i=="function"?i(e):e?.[i]}function on(i,e){return i==null&&e==null||Object.is(i,e)}function Bi(i,e){if(!i||typeof i!="object")return null;let t=i.parentId;if(typeof t!="string"&&typeof t!="function")return null;let s=typeof i.column=="string"?i.column:null,n=e.some(r=>r.id===s)?s:e[0]?.id;return n?{...i,parentId:t,column:n}:null}function Oh(i){return typeof i=="function"||typeof i=="string"&&i!==""?i:null}function Rh(i){return!i||typeof i!="object"||Array.isArray(i)?null:i}function Lh(i){return new Set(Array.isArray(i)?i:[])}function Fh(i){return i==="plain"?"plain":"default"}function Ph(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function Mt(i){return!!i?.closest?.(".zx-table__editor")}function Ea(i){let e=i?.closest?.("td[data-column]"),t=i?.closest?.(["a[href]","button","input","select","textarea","summary",'[contenteditable="true"]','[role="button"]','[role="link"]','[tabindex]:not([tabindex="-1"])',"[data-zx-table-no-edit]"].join(","));return!!(e&&t&&t!==e&&e.contains(t))}function Vh(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function Ia(i){if(!Array.isArray(i))throw new TypeError("Table columns must be an array");let e=new Set;return i.map((t,s)=>{if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`Table column at index ${s} must be an object`);let n=String(t.id??"").trim();if(!n)throw new TypeError(`Table column at index ${s} requires an id`);if(e.has(n))throw new TypeError(`Duplicate table column: ${n}`);return e.add(n),{...t,id:n,label:String(t.label??n)}})}function Hi(i){for(let e of[i?.ariaLabel,i?.label]){let t=e==null?"":String(e).trim();if(t)return t}return String(i?.id??"")}function jh(i){let e=i?.label==null?"":String(i.label).trim(),t=i?.ariaLabel==null?"":String(i.ariaLabel).trim();return t||(e?null:Hi(i)||null)}function Bh(i){return i==="text"||i==="number"||i==="date"}function qh(i,e){let t=i.map(a=>a.id),s=new Set(t),n=Array.isArray(e)?e.map(String):[],r=new Set,o=[];for(let a of n)s.has(a)&&!r.has(a)&&(r.add(a),o.push(a));for(let a of t)r.has(a)||o.push(a);return o}function Hh(i,e,t,s="before"){let n=[...i],r=n.indexOf(e),o=n.indexOf(t);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(t)+(s==="after"?1:0);return n.splice(a,0,e),n}function Ma(i,e){for(let t of i.cells)if(t.dataset.column===e)return t;return null}function Da(i,e){return!i||typeof i!="object"||!e.some(t=>t.id===i.id)?null:{id:i.id,dir:i.dir==="desc"?"desc":"asc"}}function $h(i){if(typeof i!="string")return 0;let e=/^(\d*\.?\d+)fr$/.exec(i.trim());return e?Math.max(0,Number(e[1])):0}function Na(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function nn(i,e){return i.size===e.size&&[...i].every(t=>e.has(t))}function qi(i,e){return i.length===e.length&&i.every((t,s)=>Object.is(t,e[s]))}function Oa(i){let e=Math.trunc(Number(i));return Number.isFinite(e)&&e>0?e:null}var ja=Object.freeze([Object.freeze(["getValue","setValue"]),Object.freeze(["get","set"]),Object.freeze(["getValues","setValues"]),Object.freeze(["isChecked","setChecked"])]),Uh=Object.freeze(["value","values","checked"]),Ba="input, select, textarea, button",Kh="input, textarea";function Ui(i){if(P(i))return i;let e=i;if(typeof e.toElement=="function")return e.toElement();if(P(e.el))return e.el;throw new TypeError("External field source must be an Element or a Component")}function qa(i){return $a(i,Ui(i)).get()}function an(i){let e=Ui(i),t=P(i)?null:i;if(t&&xe(t,"isDisabled",0))return!!t.isDisabled();if(t&&typeof t.disabled=="boolean")return t.disabled;if(ot(e,"disabled"))return!!e.disabled||e.hasAttribute("disabled");if(e.getAttribute("aria-disabled")==="true")return!0;let s=e.getAttribute("data-disabled");if(s!==null&&s!=="false")return!0;let n=[...e.querySelectorAll(Ba)];return n.length>0&&n.every(r=>r.disabled)}function ln(i){let e=Ui(i),t=P(i)?null:i;for(let n of["readonly","readOnly"])if(t&&typeof t[n]=="boolean")return t[n];if(ot(e,"readOnly"))return!!e.readOnly||e.hasAttribute("readonly");if(e.getAttribute("aria-readonly")==="true")return!0;let s=e.getAttribute("data-readonly");return s!==null&&s!=="false"}function Ha(i,e=null){let t=Ui(i),s=P(i)?null:i,n=t.parentNode,r=t.nextSibling,o=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(x=>[x,t.getAttribute(x)])),a=s===null,l=a&&ot(t,"value")?t.value:void 0,c=a&&Ka(t)?t.checked:void 0,d=an(i),h=ln(i),p=new Map,f=$a(i,t),m=Yh(s,t,p),g=Wh(s,t,p),_=d,b=h,w=!1,A=f.get();e&&s&&typeof s.addEventListener=="function"&&(e.listen(s,"change",()=>{w||(A=f.get(),e.emit("change",{value:A}))}),e.listen(t,"change",x=>{let z=f.get();Zh(z,A)?x.stopImmediatePropagation():A=z}));let y={el:t,get:()=>f.get(),set:(x,z)=>{w=!0;try{f.set(x,z)}finally{w=!1}A=f.get()},focus:()=>{s&&xe(s,"focus",0)?s.focus():typeof t.focus=="function"&&t.focus()},setDisabled:x=>{_=!!x,m(_)},destroy:()=>{b!==h&&g&&g(h),_!==d&&m(d);for(let[x,z]of p)z.disabled!==void 0&&(x.disabled=z.disabled),z.readOnly!==void 0&&(x.readOnly=z.readOnly);p.clear();for(let[x,z]of o)z===null?t.removeAttribute(x):t.setAttribute(x,z);l!==void 0&&(t.value=l),c!==void 0&&(t.checked=c),n?n.insertBefore(t,r?.parentNode===n?r:null):t.remove()}};return g&&(y.setReadonly=x=>{b=!!x,g(b)}),y}function $a(i,e){let t=P(i)?null:i;if(t){let s=ja.find(([o])=>xe(t,o,0)),n=s?xe(t,s[1],2)?s[1]:ja.map(([,o])=>o).find(o=>xe(t,o,1)):void 0;if(s)return{get:()=>t[s[0]](),set:(o,a={})=>{n&&t[n](o,{...a,silent:!!a.silent})}};let r=Uh.find(o=>o in t);if(r)return{get:()=>t[r],set:o=>{t[r]=o}}}return Ka(e)?{get:()=>!!e.checked,set:s=>{e.checked=!!s}}:ot(e,"value")?{get:()=>e.value,set:s=>{e.value=s??""}}:{get:()=>null,set:()=>{}}}function Yh(i,e,t){return i&&xe(i,"setDisabled",1)?s=>i.setDisabled(s):i&&xe(i,"enable",0)&&xe(i,"disable",0)?s=>s?i.disable():i.enable():i&&typeof i.disabled=="boolean"?s=>{i.disabled=s}:ot(e,"disabled")?s=>{e.disabled=s}:s=>{e.setAttribute("aria-disabled",String(s));for(let n of e.querySelectorAll(Ba))Ua(t,n,"disabled"),n.disabled=s||!!t.get(n)?.disabled}}function Wh(i,e,t){if(i){for(let n of["setReadonly","setReadOnly"])if(xe(i,n,1))return r=>i[n](r);for(let n of["readonly","readOnly"])if(typeof i[n]=="boolean")return r=>{i[n]=r};return null}if(ot(e,"readOnly"))return n=>{e.readOnly=n};let s=[...e.querySelectorAll(Kh)];return s.length?n=>{for(let r of s)Ua(t,r,"readOnly"),r.readOnly=n||!!t.get(r)?.readOnly}:null}function Ua(i,e,t){let s=i.get(e)??{};s[t]===void 0&&(s[t]=!!e[t]),i.set(e,s)}function xe(i,e,t){let s=i[e];return typeof s=="function"&&s.length<=t}function ot(i,e){return["INPUT","SELECT","TEXTAREA","BUTTON","FIELDSET","OUTPUT"].includes(i.tagName)&&e in i}function Ka(i){let e=String(i.type??"").toLowerCase();return i.tagName==="INPUT"&&(e==="checkbox"||e==="radio")}function Zh(i,e){if(Object.is(i,e))return!0;if(i instanceof Date&&e instanceof Date)return i.getTime()===e.getTime();if(i&&e&&typeof i=="object"&&typeof e=="object")try{return JSON.stringify(i)===JSON.stringify(e)}catch{return!1}return!1}var Nt=class extends S{static cssName="fieldset";static defaults={title:"",columns:1,fields:{},idPrefix:null};render(){let e=this.el??u("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):E("zx-fieldset"),this._columnAttribute=e.getAttribute("data-columns");let t=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(e.dataset.columns=String(t),this.options.title){let n=u("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),e.append(n)}this._grid=u("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),e.append(this._grid);let s=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[n,r]of Object.entries(s))this.addField(n,r);return e}addField(e,t){let s=String(e);if(this._fields.has(s))throw new Error(`Field "${s}" already exists`);let n,r=!1;if(t instanceof C)n=t;else if(P(t)||t instanceof S){let o=t;n=new C(null,{id:this._controlId(s),name:s,type:"custom",label:s,value:qa(o),disabled:an(o),readonly:ln(o),adapter:a=>Ha(o,a)}),r=!0}else{let o=t&&typeof t=="object"?t:{},a=o.id!=null&&String(o.id)!==""&&String(o.id)!==s;n=new C(null,{...o,id:a?String(o.id):this._controlId(s),name:o.name??s}),r=!0}return r?this._ownedFields.add(n):this._origins.set(n,{parent:n.el.parentNode,next:n.el.nextSibling}),this._fields.set(s,n),this._fieldIdAttributes.set(n,n.el.getAttribute("data-field-id")),n.el.dataset.fieldId=s,this._grid.append(n.el),n}getField(e){return this._fields.get(String(e))??null}hasField(e){return this._fields.has(String(e))}getFields(){return Object.fromEntries(this._fields)}getValues(){let e={};for(let[t,s]of this._fields)e[t]=s.getValue();return e}setValues(e,{silent:t=!1}={}){if(!e||typeof e!="object")return this;for(let[s,n]of Object.entries(e))this._fields.get(s)?.setValue(n,{silent:t});return this}getValue(e){return this._fields.get(String(e))?.getValue()??null}setValue(e,t){return this._fields.get(String(e))?.setValue(t),this}reset(){for(let e of this._fields.values())e.reset();return this}clear(){for(let e of[...this._fields.values()])this._releaseField(e);return this._fields.clear(),this}focus(e){return this._fields.get(String(e))?.focus(),this}setHighlights(e={},t="danger"){let s=0;for(let[n,r]of this._fields){let o=e?.[n];o?(r.setHighlight(String(o),t),s+=1):r.clearHighlight()}return s}clearHighlights(){for(let e of this._fields.values())e.clearHighlight();return this}_controlId(e){return`${this._idPrefix}-${e.trim().replace(/\s+/g,"-")}`}_releaseField(e){let t=this._fieldIdAttributes.get(e);if(t==null?e.el.removeAttribute("data-field-id"):e.el.setAttribute("data-field-id",t),this._fieldIdAttributes.delete(e),this._ownedFields.has(e)){e.destroy(),this._ownedFields.delete(e);return}let s=this._origins.get(e);s?.parent?s.parent.insertBefore(e.el,s.next?.parentNode===s.parent?s.next:null):e.el.remove(),this._origins.delete(e)}destroy(){this.clear();for(let e of this._ownedNodes??[])e.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};var Gh=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),Qh=new Set(["hover","focus","both","manual"]),at=class extends S{static cssName="tooltip";static defaults={content:"",placement:"top",offset:6,delay:400,hideDelay:80,maxWidth:260,trigger:"both",disabled:!1};#e;#t;#i=null;#s=null;#n=0;#r=0;#o=!1;#c=!1;#l=!1;#a=!1;#u=!1;#d=null;#h=!1;#p=!1;constructor(e,t={}){let s=Q(e);if(!s)throw new TypeError("Tooltip anchor could not be resolved");super(null,t),this.#e=s,tt(s,{dialog:!1})?.append(this.el),this.#t=this.options.content,this.#h=!!this.options.disabled,this.#s=s.getAttribute("aria-describedby"),this.el.style.setProperty("--zx-tooltip-max-inline-size",Xh(this.options.maxWidth));let n=Qh.has(this.options.trigger)?this.options.trigger:"both";if(n!=="manual"){this.#u=!0,(n==="hover"||n==="both")&&(this.listen(this.#e,"pointerenter",r=>{r.pointerType!=="touch"&&(this.#c=!0,this.#g(Number(this.options.delay)))}),this.listen(this.#e,"pointerleave",r=>{r.pointerType!=="touch"&&(this.#c=!1,this.#m(Number(this.options.hideDelay)))})),this.listen(this.el,"pointerenter",r=>{r.pointerType!=="touch"&&(this.#l=!0,this.#f())}),this.listen(this.el,"pointerleave",()=>{this.#l=!1,this.#m(Number(this.options.hideDelay))}),(n==="focus"||n==="both")&&(this.listen(this.#e,"focusin",()=>{this.#o||!ef(this.#e)||(this.#a=!0,this.#g(0))}),this.listen(this.#e,"focusout",()=>{this.#a=!1,this.#m(Number(this.options.hideDelay))})),this.listen(this.#e,"pointerdown",()=>{this.#o=!0,this.#f(),this.hide()});for(let r of["pointerup","pointercancel","pointerleave"])this.listen(this.#e,r,()=>{this.#o=!1})}}render(){let e=u("div",{id:E("zx-tooltip"),role:"tooltip",popover:"manual"});return e.dataset.state="closed",e}show(){if(this.#p||this.#h||this.isOpen())return this;this.#f();let e=Et(this.#e);this.el.parentElement!==e&&e.append(this.el);let t=Ya(this.#t);if(t===null)return this;this.el.replaceChildren(t);let s=Gh.has(this.options.placement)?this.options.placement:"top";return this.#i=ne(this.#e,this.el,{placement:s,offset:Number(this.options.offset),flip:!0}),/^(left|right)/.test(s)&&this.el.style.getPropertyValue("position-try-fallbacks")&&this.el.style.setProperty("position-try-fallbacks","flip-inline, top span-all, bottom span-all"),this.el.dataset.state="open",this.#e.setAttribute("aria-describedby",Jh(this.#s,this.el.id)),this.#d=nt({kind:"tooltip",root:this.el,owner:this,anchor:this.#e,inside:[this.#e],onEscape:this.#u?()=>{this.hide()}:void 0,onOutsidePointer:this.#u?()=>this.hide():void 0,onFocusOutside:this.#u?()=>{this.#a=!1,this.#m(Number(this.options.hideDelay))}:void 0,onParentClose:()=>this.hide()}),this.emit("open"),this}hide(){if(this.#f(),!this.isOpen())return this;this.#i?.destroy(),this.#i=null,this.#l=!1,this.el.dataset.state="closed",this.el.replaceChildren(),this.#_();let e=this.#d;return this.#d=null,e?.release(),this.emit("close"),this}toggle(){return this.isOpen()?this.hide():this.show()}isOpen(){return this.#i!==null}setContent(e){if(this.#t=e,!this.isOpen())return this;let t=Ya(e);return t===null?this.hide():(this.el.replaceChildren(t),this.#i?.update(),this)}enable(){return this.#h=!1,this}disable(){return this.#h=!0,this.hide()}isDisabled(){return this.#h}getAnchor(){return this.#e}destroy(){this.#p||(this.#p=!0,this.hide(),this.#_(),super.destroy())}#g(e){if(this.#f(),this.#p||this.#h||this.isOpen())return;let t=Number.isFinite(e)?Math.max(0,e):0;if(t===0){this.show();return}this.#n=setTimeout(()=>{this.#n=0,this.show()},t)}#m(e){if(this.#f(),this.#c||this.#l||this.#a||!this.isOpen())return;let t=Number.isFinite(e)?Math.max(0,e):0;if(t===0){this.hide();return}this.#r=setTimeout(()=>{this.#r=0,this.hide()},t)}#f(){this.#n!==0&&clearTimeout(this.#n),this.#r!==0&&clearTimeout(this.#r),this.#n=0,this.#r=0}#_(){this.#s===null?this.#e.removeAttribute("aria-describedby"):this.#e.setAttribute("aria-describedby",this.#s)}};function Ya(i){let e=typeof i=="function"?i():i;if(e==null)return null;if(typeof e=="object"&&typeof e.nodeType=="number")return e;if(typeof e=="object"&&typeof e.toElement=="function")return e.toElement();let t=String(e);return t===""?null:document.createTextNode(t)}function Jh(i,e){let t=String(i??"").split(/\s+/).filter(Boolean);return t.includes(e)||t.push(e),t.join(" ")}function Xh(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function ef(i){try{return i.matches(":focus-visible")}catch{return!0}}function Wa(i){return K(i,Intl.DateTimeFormat)}var Wi=class extends S{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:null,label:null,closeLabel:null,resultsLabel:null,emptyText:null,loadingText:null,shortcut:"mod+k",hints:null,scope:null};constructor(e=null,t={}){super(e,t)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null,this._overlay=null;let e=this.el??u("dialog");this.el=e,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes,m=>[m.name,m.value]),children:Array.from(e.childNodes)},this._items=Ot(this.options.items),this._sources=Ja(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._settled=!0,this._pages=[],this._restoreActiveId=null,this._announcePending=!1,this._announceToggle=!1,this._destroyed=!1,this._presentation=0,this._closingPresentations=[];let t=E("zx-launcher-results"),s=String(this.options.label??this._message("launcher.label","Launcher")),n=String(this.options.placeholder??this._message("launcher.placeholder","Search applications and records"));this._label=s,this._placeholder=n;let r=u("input",{ref:"input",class:"zx-launcher__input",type:"search",role:"combobox",autocomplete:"off",spellcheck:!1,ariaAutocomplete:"list",ariaControls:t,ariaExpanded:"false",ariaLabel:s,placeholder:n,value:this._query}),o=u("button",{ref:"scopeBack",class:"zx-icon-btn zx-launcher__scope-back",type:"button"},v("x",{size:T.dismiss})),a=u("span",{ref:"scope",class:"zx-launcher__scope",hidden:!0},u("span",{ref:"scopeLabel",class:"zx-launcher__scope-label"}),o),l=u("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel??this._message("launcher.close","Close launcher")},v("x",{size:T.dismiss})),c=u("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),d=u("div",{ref:"announce",class:"zx-launcher__announce",role:"status",ariaLive:"polite",ariaAtomic:"true"}),h=u("div",{ref:"results",class:"zx-launcher__results",id:t,role:"listbox",ariaLabel:this.options.resultsLabel??this._message("launcher.results","Launcher results")}),p=this.options.shortcut==="mod+k"?u("span",{class:"zx-launcher__shortcut",ariaHidden:"true"},ve("Mod+K")):null,f=tf(this.options.hints,{move:this._message("launcher.hintMove","Move"),open:this._message("launcher.hintOpen","Open"),back:this._message("launcher.hintBack","Back"),close:this._message("launcher.hintClose","Close")});return e.setAttribute("aria-label",s),e.replaceChildren(u("div",{class:"zx-launcher__surface"},u("div",{class:"zx-launcher__search",dataset:{shortcut:p?"true":"false"}},v("search"),a,r,p,l),c,h,f,d)),e.dataset.state="closed",this._createdRoot&&tt(this.options.scope,{dialog:!1})?.append(e),this.listen(r,"input",()=>{this._query=r.value,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(r,"keydown",m=>this._onKeydown(m)),this.listen(o,"click",()=>{this.back(),r.focus()}),this.listen(l,"click",()=>this.close()),this.listen(h,"click",m=>{let g=m.target?.closest?.("[data-launcher-index]");!g||!h.contains(g)||this._activate(Number(g.getAttribute("data-launcher-index")),m)}),this.listen(h,"pointermove",m=>{let g=m.target?.closest?.("[data-launcher-index]");if(!g||!h.contains(g))return;let _=Number(g.getAttribute("data-launcher-index"));!Number.isInteger(_)||this._results[_]?.disabled||_===this._active||(this._active=_,this._syncActive())}),this.listen(e,"cancel",m=>{m.preventDefault(),this.close()}),this.listen(e,"close",()=>{let m=this._closingPresentations.shift();m!==void 0&&m!==this._presentation||e.open||(this._releaseOverlay(),e.dataset.state="closed",r.setAttribute("aria-expanded","false"),this._abortRequest(),this._pages.length&&!e.open&&(this._unwind(),this._announcePending=!1,this._syncPage(),this._renderResults(),this._emitPage()),this.emit("close"))}),this.listen(document,"keydown",m=>this._onDocumentKeydown(m)),this._renderResults(),e}open(e={}){if(this._destroyed)return this;let t=e&&typeof e=="object"?e.page:void 0;if(this.isOpen()){let r=t==null?[]:this._pagePath(t);return r.length&&this._goTo(r),this}if(this.el.dataset.state==="open"&&!this._closingPresentations.includes(this._presentation)&&this._closingPresentations.push(this._presentation),this._createdRoot){let r=ce(this.options.scope);this.el.parentElement!==r&&r.append(this.el)}let s=this._pages.map(r=>r.page),n=document.activeElement;return this.el.showModal(),this._presentation+=1,this._releaseOverlay(),this._overlay=nt({kind:"modal",root:this.el,owner:this,anchor:n}),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._goTo(t==null?[]:this._pagePath(t),{emit:!1}),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),Za(s,this._pages.map(r=>r.page))||this._emitPage(),this}back(){if(!this._pages.length)return this;let e=this._popPage();return this._syncPage(),this._announcePending=this.isOpen(),e?this._renderResults():this._refresh(!0),this._emitPage(),this}getPage(){return this._pages.at(-1)?.page??null}close(){return this.isOpen()&&(this._closingPresentations.push(this._presentation),this.el.close()),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(e){return this._query=String(e??""),this.refs.input.value=this._query,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(e){return this._items=Ot(e),this._renderResults(),this}setCurrent(e){let t=e==null?null:String(e);return this._items=this._items.map(s=>({...s,current:t!==null&&String(s.id)===t})),this._renderResults(),this}setSources(e){return this._sources=Ja(e),this._pages.length?(this._pages[0].parent.sourceItems=null,this):(this._abortRequest(),this._sourceItems.clear(),this._refresh(),this)}_releaseOverlay(){let e=this._overlay;this._overlay=null,e?.release()}destroy(){if(this._destroyed)return;this._destroyed=!0;let e=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),this._releaseOverlay(),super.destroy(),!this._createdRoot&&e){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,s]of e.attributes)this.el.setAttribute(t,s);this.el.replaceChildren(...e.children)}}_refresh(e=!1){this._abortRequest(),this._sourceItems.clear();let{sources:t}=this._level();if(this._settled=t.length===0,e&&t.length&&this._loadSources(),this._renderResults(),e||t.length===0)return;let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),s)}async _loadSources(){this._queryTimer=null;let e=this._query.trim(),t=this._pages?.at(-1)?.page??null,s=this._level().sources.filter(o=>Ki(o.when,e)&&e.length>=Math.max(o._page?0:Number(this.options.minQuery)||0,Number(o.minQuery)||0));if(s.length===0){this._settled=!0;return}let n=new AbortController,r=++this._requestSequence;this._request=n,this._setBusy(!0),await Promise.all(s.map(async o=>{try{let a=await o.load(e,{signal:n.signal});if(n.signal.aborted||r!==this._requestSequence)return;this._sourceItems.set(o.id,Ot(a).map((l,c)=>({...l,_source:o._page?null:o.id,_sourceOrder:o.order==="source",group:l.group??o.label??"",itemOrder:l.itemOrder??(o.order==="source"?c:void 0)}))),this._renderResults()}catch(a){if(n.signal.aborted||r!==this._requestSequence)return;this.emit("error",{source:o,error:a,page:t})}})),!(n.signal.aborted||r!==this._requestSequence)&&(this._request=null,this._settled=!0,this._setBusy(!1))}_level(){return this._pages?.at(-1)??{items:this._items,sources:this._sources}}_openPage(e){this._pushPage(e),this._syncPage(),this._announcePending=this.isOpen(),this._refresh(!0),this._emitPage()}_goTo(e,{emit:t=!0}={}){let s=this._pages.map(n=>n.page);if(this._unwind(),e.length){this._abortRequest(),this._sourceItems.clear(),this._settled=!1;for(let n of e)this._pushPage(n)}this._syncPage(),this._announcePending=this.isOpen()&&e.length>0,this._refresh(e.length>0),t&&!Za(s,e)&&this._emitPage()}_unwind(){for(;this._pages.length;)this._popPage()}_pushPage(e){let t=this._active>=0?this._results[this._active]:null;this._pages.push({page:e,items:Array.isArray(e.items)?Ot(e.items):[],sources:typeof e.items=="function"?[of(e)]:[],parent:{query:this._query,activeId:t?String(t.id):null,sourceItems:this._settled?new Map(this._sourceItems):null}}),this._setInputQuery("")}_popPage(){let e=this._pages.pop();if(!e)return!0;this._announcePending=!1,this._abortRequest();let{parent:t}=e;return this._setInputQuery(t.query),this._sourceItems=t.sourceItems?new Map(t.sourceItems):new Map,this._settled=t.sourceItems!==null,this._restoreActiveId=t.activeId,this._settled}_setInputQuery(e){this._query=e,this.refs.input.value=e,this._renderedQuery=null}_syncPage(){let e=this.getPage(),{input:t,scope:s,scopeLabel:n,scopeBack:r,backHint:o}=this.refs;if(s.hidden=e===null,o&&(o.hidden=e===null),this.el.toggleAttribute("data-page",e!==null),e===null){t.setAttribute("aria-label",this._label),t.setAttribute("placeholder",this._placeholder),n.textContent="";return}let a=this._pages.at(-2)?.page.label??this._label;n.textContent=e.label,r.setAttribute("aria-label",this._message("launcher.back","Back to %1",a)),t.setAttribute("aria-label",this._message("launcher.pageLabel","Search %1",e.label)),t.setAttribute("placeholder",e.placeholder!=null?String(e.placeholder):this._message("launcher.pagePlaceholder","Search"))}_emitPage(){let e=this._pages.map(t=>t.page);this.emit("page",{page:e.at(-1)??null,path:e})}_pagePath(e){if(e&&typeof e=="object"){let t=e;return!lt(t)||t.label==null?[]:[Xa({...t,id:t.id??t.label})]}return sf(this._items,e)}_pageStatus(){let e=this.getPage()?.label??this._label,t=this._results.length;return t===0?this._message("launcher.pageEmpty","%1, no results",e):t===1?this._message("launcher.pageResult","%1, 1 result",e):this._message("launcher.pageResults","%1, %2 results",e,t)}_setBusy(e){this._busy=e,this.el.setAttribute("aria-busy",String(e)),this._renderStatus()}_abortRequest(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._request?.abort(),this._request=null,this._requestSequence+=1,this._busy&&this._setBusy(!1)}_renderResults(){let e=this._query,t=this._restoreActiveId??null;this._restoreActiveId=null;let s=t??(this._renderedQuery===e&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null),n=this._query.trim(),r=this._level(),o=r.items.filter(g=>Ki(g.when,n)),a=Ga(o,n,this.options.maxResults),l=r.sources.flatMap(g=>{let _=this._sourceItems.get(String(g.id))??[];return g.order==="source"?_.filter(b=>Ki(b.when,n)):Ga(_.filter(b=>Ki(b.when,n)),n,this.options.maxResults)}),c=new Set,d=[...a.map(g=>({...g,_source:null})),...l].filter(g=>{let _=String(g.id);return c.has(_)?!1:(c.add(_),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),h=new Map;for(let g of d){let _=String(g.group??"");h.has(_)||h.set(_,[]),h.get(_).push(g)}this._results=[...h.values()].flat(),this._renderedQuery=e;let p=s===null?-1:this._results.findIndex(g=>!g.disabled&&String(g.id)===s);this._active=p>=0?p:this._results.findIndex(g=>!g.disabled);let f=[],m=0;for(let[g,_]of h){let b=_.map(w=>this._option(w,m++));g?f.push(u("div",{class:"zx-launcher__group",role:"group",ariaLabel:g,dataset:{layout:_.every(w=>w.kind==="application")?"grid":"list"}},u("div",{class:"zx-launcher__group-label",ariaHidden:"true"},g),b)):f.push(...b)}this.refs.results.replaceChildren(...f),this._syncActive(),this._renderStatus()}_option(e,t){let s=lt(e),n=s?null:Re(e.href),r=n?"a":"button",o=[],a=af(e);a&&o.push(u("span",{class:"zx-launcher__icon",ariaHidden:"true"},a)),o.push(u("span",{class:"zx-launcher__copy"},u("span",{class:"zx-launcher__label"},e.label),e.description?u("span",{class:"zx-launcher__description"},e.description):null)),e.badge!=null&&o.push(u("span",{class:"zx-launcher__badge"},String(e.badge))),e.hint!=null&&e.hint!==""&&o.push(u("span",{class:"zx-launcher__hint"},String(e.hint)));let l=rf(e),c=nf(e.shortcut);return c.length&&o.push(u("span",{class:"zx-launcher__keys",ariaHidden:l?"true":null},ve(c,{size:"sm"}))),s&&o.push(u("span",{class:"zx-launcher__chevron",ariaHidden:"true"},v("chevron-right",{size:T.chevron}))),u(r,{class:"zx-launcher__option",type:r==="button"?"button":null,href:n,target:e.target??null,rel:r==="a"?"noopener":null,role:"option",id:E("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:e.disabled?"true":null,ariaCurrent:e.current?"page":null,ariaKeyShortcuts:l,dataset:{launcherIndex:t,pinned:e.pinned!==void 0&&e.pinned!==!1?"true":null,kind:lf(e.kind),page:s?"true":null}},o)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText??this._message("launcher.loading","Searching\u2026")):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText??this._message("launcher.empty","No results")):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent,this._announcePending&&!this._busy&&this._renderedQuery===this._query&&(this._announcePending=!1,this._announceToggle=!this._announceToggle,this.refs.announce.textContent=this._pageStatus()+(this._announceToggle?"\xA0":""))}_syncActive(){let e=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let s of e){let n=Number(s.getAttribute("data-launcher-index"))===this._active;s.setAttribute("aria-selected",String(n))}let t=e.find(s=>Number(s.getAttribute("data-launcher-index"))===this._active);t?this.refs.input.setAttribute("aria-activedescendant",t.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(e){if(e.key==="Escape"){this.close();return}let t=!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey;if(e.key==="Backspace"&&t&&!e.repeat&&this._pages.length&&this._query===""){e.preventDefault(),this.back();return}if(e.key==="Enter"){if(this._active<0)return;e.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let s=this._results.map((r,o)=>r.disabled?-1:o).filter(r=>r>=0);if(/^Arrow(?:Left|Right|Up|Down)$/.test(e.key)){let r=s.length?this._spatialIndex(e.key,s):null;if(r!==null){e.preventDefault(),this._active=r,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(e.key==="ArrowLeft"||e.key==="ArrowRight"){t&&!e.repeat&&this._pageKey(e.key)&&e.preventDefault();return}}if(s.length===0)return;let n=s.indexOf(this._active);if(e.key==="Home"||e.key==="PageUp")n=0;else if(e.key==="End"||e.key==="PageDown")n=s.length-1;else if(e.key==="ArrowDown")n=(n+1+s.length)%s.length;else if(e.key==="ArrowUp")n=(n-1+s.length)%s.length;else return;e.preventDefault(),this._active=s[n],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_pageKey(e){if(e==="ArrowLeft")return!this._pages.length||this._query!==""?!1:(this.back(),!0);let t=this._active>=0?this._results[this._active]:null;if(!t||t.disabled||!lt(t)||t.kind==="application")return!1;let s=this.refs.input,n=s.value.length;return s.selectionStart!==n||s.selectionEnd!==n?!1:(this._openPage(t),!0)}_spatialIndex(e,t){let s=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(s instanceof HTMLElement)||(e==="ArrowLeft"||e==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>t.includes(Number(o.getAttribute("data-launcher-index")))&&(e!=="ArrowLeft"&&e!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=cf(n,s,e);return r?Number(r.getAttribute("data-launcher-index")):null}_activate(e,t){let s=this._results[e];if(!s||s.disabled){t.preventDefault();return}if(lt(s)){t.preventDefault(),this._openPage(s),this.refs.input.focus();return}if(this.emit("select",{item:s,value:s.value??s.id,source:s._source??null,query:this._query.trim(),page:this.getPage()}).defaultPrevented){t.preventDefault();return}this.close(),s.href||(t.preventDefault(),s.invoke?.())}_onDocumentKeydown(e){if(this.options.shortcut!=="mod+k"||e.isComposing||e.key.toLowerCase()!=="k"||Number(e.metaKey)+Number(e.ctrlKey)!==1||e.altKey||e.shiftKey)return;let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLElement&&t.isContentEditable)return;let s=document.querySelector("dialog:modal");s&&s!==this.el||(e.preventDefault(),this.open())}_message(e,t,...s){let n=this.msg(e,...s);return n===e?F(t,s):n}};function tf(i,e){if(i===!1)return null;let t=i&&typeof i=="object"?i:{};return u("footer",{class:"zx-launcher__hints",ariaHidden:"true"},u("span",{},ve(["\u2191\u2193\u2190\u2192"]),t.move??e.move),u("span",{},ve("Enter"),t.open??e.open),u("span",{ref:"backHint",hidden:!0},ve("Backspace"),t.back??e.back),u("span",{},ve("Escape"),t.close??e.close))}function lt(i){let e=i?.items;return!!i&&typeof i=="object"&&(Array.isArray(e)||typeof e=="function")}function sf(i,e){if(e==null)return[];let t=String(e),s=new Set,n=(r,o)=>{if(!Array.isArray(r)||s.has(r))return null;s.add(r);for(let a of Ot(r)){if(!lt(a))continue;let l=[...o,a];if(String(a.id)===t)return l;let c=n(a.items,l);if(c)return c}return null};return n(i,[])??[]}function nf(i){let e=i&&typeof i=="object"&&!Array.isArray(i)?i.label:i;return(Array.isArray(e)?e:e==null?[]:[e]).filter(s=>s!=null&&String(s).trim()!=="").map(s=>String(s).trim())}function rf(i){let e=i.shortcut,t=i.keys??(e&&typeof e=="object"&&!Array.isArray(e)?e.keys:null);return typeof t=="string"&&t.trim()?t.trim():null}function of(i){return{id:`page:${String(i.id)}`,load:i.items,order:i.order==="source"?"source":"rank",_page:!0}}function Za(i,e){return i.length===e.length&&i.every((t,s)=>t===e[s]||String(t.id)===String(e[s].id))}function af(i){let e=i.icon;if(typeof e=="function"&&(e=e(i)),typeof e=="string")return v(e);if(e instanceof Node)return e.cloneNode(!0);if(e&&typeof e=="object"&&typeof e.toElement=="function"){let t=e.toElement();return t instanceof Node?t.cloneNode(!0):null}return null}function lf(i){return i==="application"||i==="record"?i:"action"}function Ki(i,e){return i==="empty"?e==="":i==="query"?e!=="":!0}function cf(i,e,t){let s=e.getBoundingClientRect();if(s.width===0&&s.height===0)return null;let n=s.left+s.width/2,r=s.top+s.height/2,o=null,a=1/0;for(let l of i){if(l===e)continue;let c=l.getBoundingClientRect(),d=c.left+c.width/2-n,h=c.top+c.height/2-r,p=!1,f=1/0;t==="ArrowLeft"?(p=d<-2&&Math.abs(h)<Math.max(s.height,c.height)/2,f=Math.abs(d)+Math.abs(h)*4):t==="ArrowRight"?(p=d>2&&Math.abs(h)<Math.max(s.height,c.height)/2,f=Math.abs(d)+Math.abs(h)*4):t==="ArrowUp"?(p=h<-2,f=Math.abs(h)*10+Math.abs(d)):t==="ArrowDown"&&(p=h>2,f=Math.abs(h)*10+Math.abs(d)),p&&f<a&&(o=l,a=f)}return o}function Ga(i,e,t=100){let s=ct(e).trim(),n=i.map((o,a)=>({item:o,order:a,score:uf(o,s)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let l=Yi(o.item.groupOrder),c=Yi(a.item.groupOrder);if(l!==c)return l-c;if(s===""){let d=Qa(o.item.pinned,o.order),h=Qa(a.item.pinned,a.order);if(d!==h)return d-h}return o.score-a.score||Yi(o.item.itemOrder)-Yi(a.item.itemOrder)||df(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(t)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function uf(i,e){if(!e)return i.pinned?-1:0;let t=ct(i.label),s=ct(i.id),n=ct(Array.isArray(i.keywords)?i.keywords.join(" "):i.keywords??"");return t===e?0:t.startsWith(e)?10:t.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(e))?20:t.includes(e)||n.includes(e)?30:s.includes(e)?40:t.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(e)?50:1/0}function Qa(i,e){return typeof i=="number"&&Number.isFinite(i)?i:i?e:Number.MAX_SAFE_INTEGER}function Yi(i){return typeof i=="number"&&Number.isFinite(i)?i:Number.MAX_SAFE_INTEGER}function ct(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function df(i,e){let t=ct(i),s=ct(e);if(t<s)return-1;if(t>s)return 1;let n=String(i??"").normalize("NFC"),r=String(e??"").normalize("NFC");return n<r?-1:n>r?1:0}function Ot(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&e.label!=null).map(e=>Xa(e)):[]}function Xa(i){let e={...i,label:String(i.label)};if(i.href==null)return e;let t=Re(i.href);return t!==null?e.href=t:(delete e.href,typeof e.invoke!="function"&&!lt(e)&&(e.disabled=!0)),e}function Ja(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&typeof e.load=="function").map(e=>({...e,id:String(e.id)})):[]}var hf=["a[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe",'[contenteditable="true"]',"[tabindex]"].map(i=>`${i}:not([tabindex^="-"])`).join(","),ut=class extends S{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1,scope:null};#e;#t=null;#i=new Map;#s=null;#n=null;#r=!0;#o=!1;constructor(e,t={}){let s=Q(e);if(!s)throw new TypeError("Dropdown anchor could not be resolved");super(null,t),this.#e=s,tt(this.options.scope??s,{dialog:!1})?.append(this.el),this.#d("aria-expanded"),this.#d("aria-controls"),this.#e.setAttribute("aria-expanded","false"),this.#e.setAttribute("aria-controls",this.el.id),this.setContent(this.options.content),this.options.openOn==="click"&&this.listen(this.#e,"click",()=>this.toggle()),this.listen(this.el,"click",()=>{this.options.closeOnSelect&&this.close()}),this.listen(this.#e,"keydown",n=>this.#a(n)),this.listen(this.el,"keydown",n=>this.#u(n))}render(){let e=u("div",{id:E("zx-dropdown"),popover:"manual"});return e.dataset.state="closed",e}open(){if(this.isOpen()||this.#o)return this;let e=this.#c();return this.el.parentElement!==e&&e.append(this.el),this.#t=ne(this.#e,this.el,{placement:this.options.placement,offset:Number(this.options.offset),matchWidth:!!this.options.matchWidth}),this.el.dataset.state="open",this.#s=nt({kind:"popup",root:this.el,owner:this,anchor:[this.#e,Q(this.options.scope)],inside:[this.#e],onEscape:t=>this.#l(t),onOutsidePointer:()=>this.close(),onParentClose:()=>this.close()}),this.el.dataset.zxOverlayOrder=String(this.#s.order),this.#e.setAttribute("aria-expanded","true"),this.emit("open"),this}close(){if(!this.isOpen())return this;let e=this.el.contains(document.activeElement);this.#t?.destroy(),this.#t=null,this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder;let t=this.#s;return this.#s=null,this.#e.setAttribute("aria-expanded","false"),e&&this.#r&&this.#e instanceof HTMLElement&&this.#e.focus(),it(this.el.parentElement)&&this.el.parentElement?.isConnected&&ce(this.options.scope??this.#e).append(this.el),t?.release(),this.emit("close"),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#t!==null}setContent(e){return ff(this.el,e),this.#t?.update(),this}getPanel(){return this.el}destroy(){if(!this.#o){this.#o=!0,this.close();for(let[e,t]of this.#i)gf(this.#e,e,t);super.destroy()}}_configure(e){return"onEscape"in e&&(this.#n=e.onEscape??null),"tabReach"in e&&(this.#r=!!e.tabReach),this}#c(){return it(this.#e)??it(Q(this.options.scope))??Et(this.options.scope??this.#e)}#l(e){if(this.#n){this.#n(e);return}let t=this.el.contains(document.activeElement);this.close(),t&&this.#e instanceof HTMLElement&&this.#e.focus()}#a(e){if(e.key!=="Tab"||e.shiftKey||e.defaultPrevented||!this.#r||!this.isOpen())return;let t=cn(this.el)[0]??(this.el.hasAttribute("tabindex")?this.el:null);t instanceof HTMLElement&&(e.preventDefault(),t.focus())}#u(e){if(e.key!=="Tab"||e.defaultPrevented||!this.#r||!this.isOpen())return;let t=cn(this.el),s=document.activeElement;if((s&&s!==this.el?t.filter(o=>!o.contains(s)&&(e.shiftKey?!!(s.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_PRECEDING):!!(s.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)&&!s.contains(o))):e.shiftKey?[]:t).length>0)return;if(e.shiftKey){if(!(this.#e instanceof HTMLElement))return;e.preventDefault(),this.#e.focus();return}let r=pf(this.#e,this.el);r&&(e.preventDefault(),r.focus())}#d(e){this.#i.set(e,this.#e.getAttribute(e))}};function ff(i,e){if(i.replaceChildren(),e!=null)if(typeof e=="string"||typeof e=="number")i.append(document.createTextNode(String(e)));else if(typeof e.toElement=="function"){let t=e.toElement();t&&i.append(t)}else typeof e.nodeType=="number"&&i.append(e)}function cn(i){return Array.from(i.querySelectorAll(hf)).filter(e=>mf(e))}function pf(i,e){let t=it(i)??i.ownerDocument.body??i.ownerDocument.documentElement,s=cn(t).filter(o=>!e.contains(o)),n=s.findIndex(o=>o===i||i.contains(o));if(n<0)return null;let r=n+1;for(;r<s.length&&i.contains(s[r]);)r+=1;return s[r]??null}function mf(i){let e=i;if(typeof e.focus!="function"||e.tabIndex<0||e.disabled||i.closest('[inert], [hidden], [aria-hidden="true"], fieldset[disabled]'))return!1;if(e instanceof HTMLInputElement&&e.type==="radio"&&e.name&&!e.checked){let t=e.form??e.getRootNode(),s=Array.from(t.querySelectorAll?.('input[type="radio"]')??[]).filter(n=>n.name===e.name&&(n.form??n.getRootNode())===t);if(s.some(n=>n.checked)||s[0]!==e)return!1}return typeof e.checkVisibility=="function"?e.checkVisibility({visibilityProperty:!0}):e.getClientRects().length>0}function gf(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}var dn=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),un=class extends S{static cssName="app-icon";static defaults={icon:null,color:null,tone:null,size:36,iconSize:"52%",label:null,badge:null,selected:!1,shape:"tile",glass:"subtle",class:[]};render(){this._createdRoot=this.el===null;let e=this.el??u("span");return this.el=e,this._snapshot=this._createdRoot?null:Z(e),this._interactiveRoot=e.matches('a[href], button, input, select, textarea, [role="button"], [role="link"]'),this._state={...this.options},this._appliedClasses=[],this._sync(),e}set(e={}){return!e||typeof e!="object"?this:(Object.assign(this._state,e),this._sync(),this)}destroy(){let e=this.el,t=this._snapshot;super.destroy(),!this._createdRoot&&e&&G(e,t)}_sync(){let e=this._state;this.el.classList.remove(...this._appliedClasses),this._appliedClasses=[e.class].flat().flatMap(c=>String(c??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let t=el(e.size,"36px"),s=el(e.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",t),this.el.style.setProperty("--zx-app-icon-glyph-size",s),ze(e.color)?this.el.style.setProperty("--zx-app-icon-color",String(e.color)):this.el.style.removeProperty("--zx-app-icon-color"),dn.includes(e.tone)?this.el.dataset.tone=e.tone:delete this.el.dataset.tone,this.el.dataset.glass=bf(e.glass),this.el.dataset.shape=yf(e.shape),this.el.toggleAttribute("data-selected",!!e.selected);let n=e.label==null?"":String(e.label).trim();if(this._interactiveRoot){let c=tl(this._snapshot,"role"),d=tl(this._snapshot,"aria-label");c===null?this.el.removeAttribute("role"):this.el.setAttribute("role",c),n?this.el.setAttribute("aria-label",n):d===null?this.el.removeAttribute("aria-label"):this.el.setAttribute("aria-label",d),this.el.removeAttribute("aria-hidden")}else n?(this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",n),this.el.removeAttribute("aria-hidden")):(this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true"));let r=_f(e.icon),o=e.badge==null||e.badge===""?null:u("span",{class:"zx-app-icon__badge",ariaHidden:"true"},String(e.badge)),l=[u("span",{class:"zx-app-icon__surface",ariaHidden:"true"},u("span",{class:"zx-app-icon__shine",ariaHidden:"true"}),u("span",{class:"zx-app-icon__glyph",ariaHidden:"true"},r))];o&&l.push(o),this.el.replaceChildren(...l)}};function Zi(i={}){return new un(null,i).toElement()}function _f(i){let e=typeof i=="function"?i():i;return typeof e=="string"?v(e,{size:"1em"}):e&&typeof e=="object"&&typeof e.nodeType=="number"?e:null}function el(i,e){if(typeof i=="number"&&Number.isFinite(i))return`${Math.max(1,i)}px`;let t=String(i??"").trim();return t&&!/[;{}]/.test(t)?t:e}function bf(i){return i===!1||i==="none"?"none":i==="strong"?"strong":"subtle"}function yf(i){return i==="circle"?"circle":"tile"}function tl(i,e){return i?.attributes.find(([t])=>t===e)?.[1]??null}var Gi=class extends S{static cssName="app-rail";static partBlock="zx-app-rail";static defaults={items:[],active:null,orientation:"vertical",side:"left",label:"Applications",header:null,footer:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(e=null,t={}){super(e,t),this._rebuild()}render(){this._createdRoot=this.el===null;let e=this.el??u("nav");this.el=e,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes,o=>[o.name,o.value]),children:Array.from(e.childNodes)},this._items=He(this.options.items),this._active=this.options.active,this._flyouts=new Map,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._openTimers=new Map,this._closeTimers=new Map,this._pointerFocus=new WeakSet,this._silenceFlyoutEvents=!1,e.setAttribute("aria-label",String(this.options.label)),e.tagName!=="NAV"&&e.setAttribute("role","navigation"),e.dataset.orientation=this.options.orientation==="horizontal"?"horizontal":"vertical";let t=e.dataset.orientation==="horizontal"?["top","bottom"]:["left","right"];e.dataset.side=t.includes(this.options.side)?this.options.side:t[0];let s=this._partBlock(),n=u("div",{class:`${s}__header`}),r=u("div",{class:`${s}__footer`});return nl(n,this.options.header),nl(r,this.options.footer),n.hidden=!n.hasChildNodes(),r.hidden=!r.hasChildNodes(),e.replaceChildren(n,u("ul",{ref:"list",class:`${s}__list`}),r),this.listen(e,"keydown",o=>this._onRailKeydown(o)),e}setItems(e){return this._items=He(e),this._rebuild(),this}setActive(e){return this._active=e,this._syncActive(),this}getItems(){return this._items.map(e=>({...e,children:e.children?.map(t=>({...t}))}))}openFlyout(e,{focus:t=!1}={}){let s=this._resolveFlyout(e);if(!s)return this;let n=[s],r=s.parentKey===null?null:this._flyouts.get(s.parentKey)??null;for(;r;)n.unshift(r),r=r.parentKey===null?null:this._flyouts.get(r.parentKey)??null;if(n.some(o=>o.item.disabled))return this;this._cancelFlyoutTimers(s,!0);for(let[o,a]of this._flyouts)o!==s.key&&a.dropdown.isOpen()&&!this._isAncestor(a,s)&&this.closeFlyout(o);for(let o of n)this._tooltipById.get(String(o.item.id))?.hide(),o.dropdown.open();return t&&sl(s.panel)?.focus(),this}closeFlyout(e){let t=this._resolveFlyout(e);if(!t)return this;for(let s of[...this._flyouts.values()].reverse())s!==t&&this._isAncestor(t,s)&&(this._cancelTimers(s.key),s.dropdown.close());return this._cancelTimers(t.key),t.dropdown.close(),this}closeAllFlyouts(){for(let e of this._flyouts.values())e.parentKey===null&&this.closeFlyout(e.key);for(let e of[...this._flyouts.values()].reverse())this._cancelTimers(e.key),e.dropdown.isOpen()&&e.dropdown.close();return this}isFlyoutOpen(e){return this._resolveFlyout(e)?.dropdown.isOpen()??!1}focus(){return sl(this.refs.list)?.focus(),this}_containsNode(e){return!!(e&&(this.el.contains(e)||[...this._flyouts.values()].some(t=>t.panel.contains(e))))}destroy(){let e=this._original;if(this._clearArtifacts(),super.destroy(),!this._createdRoot&&e){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,s]of e.attributes)this.el.setAttribute(t,s);this.el.replaceChildren(...e.children)}}_rebuild(){this._clearArtifacts(),this.refs.list.replaceChildren(),this._interaction=new hn(this.el);let e=!1;for(let t of fn(this._items)){if(t===rl){e&&this.refs.list.append(u("li",{class:`${this._partBlock()}__separator`,ariaHidden:"true"}));continue}e=!0;let s=Array.isArray(t.children)&&t.children.length>0&&this._flyoutsFor(t),n=this._renderControl(t,s),r=u("li",{class:`${this._partBlock()}__row`},n);if(this.refs.list.append(r),this._tooltipFor(t)){let o=new at(n,{content:t.label,placement:Af(this.el.dataset.side),delay:450});this._tooltips.push(o),this._tooltipById.set(String(t.id),o)}s?this._buildFlyout(t,n,String(t.id),null):this._interaction.listen(n,"click",o=>{if(!this._select(t,o).defaultPrevented)for(let l of this._flyouts.values())l.parentKey===null&&l.dropdown.isOpen()&&this.closeFlyout(l.key)})}this._afterRebuild(),this._syncActive()}_partBlock(){return this.constructor.partBlock}_renderControl(e,t){return il(e,{className:"zx-app-rail__item",index:String(e.id),iconOnly:!0,disclosure:t,disclosureIcon:wf(this.el.dataset.side),visual:Qi(e,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:"root"})})}_flyoutsFor(e){return!0}_tooltipFor(e){return!0}_afterRebuild(){}_buildFlyout(e,t,s,n){let r=u("ul",{class:"zx-app-rail__flyout-list"});for(let h of fn(e.children??[],!0)){if(h.section){r.append(u("li",{class:"zx-app-rail__flyout-section"},h.label));continue}let p=`${s}/${h.id}`,f=!!h.children?.length,m=il(h,{className:"zx-app-rail__flyout-item",index:p,iconOnly:!1,disclosure:f,disclosureIcon:vf(this.el.dataset.side),visual:Qi(h,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:p.split("/").length,location:"flyout"})});r.append(u("li",{},m)),f?this._buildFlyout(h,m,p,s):this._interaction.listen(m,"click",g=>{this._select(h,g).defaultPrevented||this._closeFlyoutChain(s)})}let o=u("div",{class:"zx-app-rail__flyout"},u("div",{class:"zx-app-rail__flyout-title"},e.label),r),a=new ut(t,{openOn:"manual",placement:n===null?xf(this.el.dataset.side):Sf(this.el.dataset.side),content:o,offset:6}),l=a.getPanel();a._configure({tabReach:!1,onEscape:()=>{let h=l.contains(document.activeElement);this.closeFlyout(s),h&&this._restoreFocus(t)}}),l.classList.add("zx-app-rail__popover"),l.dataset.side=this.el.dataset.side,l.setAttribute("role","region"),l.setAttribute("aria-label",this._message("appRail.subNavigation","%1 sub-navigation",e.label));let c={key:s,parentKey:n,item:e,trigger:t,panel:l,dropdown:a};this._flyouts.set(s,c);let d=n===null?this._tooltipById.get(String(e.id)):null;a.on("open",()=>{d?.disable(),this._silenceFlyoutEvents||this.emit("flyoutchange",{item:e,id:e.id,open:!0})}),a.on("close",()=>{d?.enable(),this._silenceFlyoutEvents||this.emit("flyoutchange",{item:e,id:e.id,open:!1})}),this._interaction.listen(t,"pointerdown",()=>{this._pointerFocus.add(t),queueMicrotask(()=>this._pointerFocus.delete(t))}),this._interaction.listen(t,"pointerenter",h=>{h.pointerType!=="touch"&&this._scheduleOpen(s)}),this._interaction.listen(t,"pointerleave",()=>this._scheduleClose(s)),this._interaction.listen(t,"focus",()=>{this._pointerFocus.has(t)||this.openFlyout(s)}),this._interaction.listen(t,"focusout",h=>{l.contains(h.relatedTarget)||this._scheduleClose(s)}),this._interaction.listen(t,"click",h=>{h.preventDefault(),h instanceof MouseEvent&&h.detail===0?this.openFlyout(s,{focus:!0}):this.openFlyout(s)}),this._interaction.listen(l,"pointerenter",()=>this._cancelFlyoutTimers(c,!0)),this._interaction.listen(l,"pointerleave",()=>this._scheduleFlyoutClose(c,!0)),this._interaction.listen(l,"focusin",()=>this._cancelFlyoutTimers(c,!0)),this._interaction.listen(l,"focusout",h=>{h.relatedTarget!==t&&!l.contains(h.relatedTarget)&&this._scheduleFlyoutClose(c,!0)}),this._interaction.listen(l,"keydown",h=>this._onFlyoutKeydown(h,c))}_select(e,t){if(e.disabled){t.preventDefault();let n=new Event("select",{cancelable:!0});return n.preventDefault(),n}let s=this.emit("select",{item:e,id:e.id,value:e.value??e.id,href:e.href??null,event:t});return s.defaultPrevented?t.preventDefault():e.href||(t.preventDefault(),e.invoke?.()),s}_onRailKeydown(e){let t=kf(this.refs.list),s=e.target?.closest?.("[data-app-nav-id]"),n=t.indexOf(s);if(n<0)return;let r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",l={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],c=s.getAttribute("data-app-nav-id");if(e.key===l&&this._flyouts.has(String(c))){e.preventDefault(),this.openFlyout(String(c),{focus:!0});return}let d;if(e.key==="Home")d=0;else if(e.key==="End")d=t.length-1;else if(e.key===o)d=(n-1+t.length)%t.length;else if(e.key===a)d=(n+1)%t.length;else return;e.preventDefault(),t[d]?.focus()}_onFlyoutKeydown(e,t){let s=ol(t.panel),n=e.target?.closest?.("a, button"),r=s.indexOf(n),o=[...this._flyouts.values()].find(d=>d.trigger===n),a=this.el.dataset.side==="right"?"ArrowLeft":"ArrowRight",l=a==="ArrowRight"?"ArrowLeft":"ArrowRight";if(o&&e.key===a){e.preventDefault(),e.stopPropagation(),this.openFlyout(o.key,{focus:!0});return}if((t.parentKey!==null||this.el.dataset.orientation==="vertical")&&e.key===l){e.preventDefault(),e.stopPropagation(),this.closeFlyout(t.key),this._restoreFocus(t.trigger);return}if(s.length===0)return;let c;if(e.key==="Home")c=0;else if(e.key==="End")c=s.length-1;else if(e.key==="ArrowDown")c=(r+1+s.length)%s.length;else if(e.key==="ArrowUp")c=(r-1+s.length)%s.length;else return;e.preventDefault(),s[c]?.focus()}_scheduleOpen(e){let t=String(e);this._cancelTimer(this._closeTimers,t),this._cancelTimer(this._openTimers,t);let s=Math.max(0,Number(this.options.openDelay)||0);this._openTimers.set(t,setTimeout(()=>{this._openTimers.delete(t),this.openFlyout(e)},s))}_scheduleClose(e){let t=String(e);this._cancelTimer(this._openTimers,t),this._cancelTimer(this._closeTimers,t);let s=Math.max(0,Number(this.options.closeDelay)||0);this._closeTimers.set(t,setTimeout(()=>{this._closeTimers.delete(t);let n=this._flyouts.get(t);n&&(this._branchInteracting(n)||this.closeFlyout(t))},s))}_scheduleFlyoutClose(e,t){let s=e;for(;s&&(this._scheduleClose(s.key),!(!t||s.parentKey===null));)s=this._flyouts.get(s.parentKey)??null}_resolveFlyout(e){let t=String(e);return this._flyouts.get(t)??[...this._flyouts.values()].find(s=>String(s.item.id)===t)??null}_closeFlyoutChain(e){let t=this._flyouts.get(e)??null;for(;t?.parentKey!==null;)t=this._flyouts.get(t.parentKey)??null;t&&this.closeFlyout(t.key)}_isAncestor(e,t){let s=t.parentKey;for(;s!==null;){if(s===e.key)return!0;s=this._flyouts.get(s)?.parentKey??null}return!1}_cancelFlyoutTimers(e,t){let s=e;for(;s&&(this._cancelTimers(s.key),!(!t||s.parentKey===null));)s=this._flyouts.get(s.parentKey)??null}_branchInteracting(e){return e.trigger.matches(":hover")||e.panel.matches(":hover")||e.trigger===document.activeElement||e.panel.contains(document.activeElement)?!0:[...this._flyouts.values()].some(t=>this._isAncestor(e,t)&&t.dropdown.isOpen()&&(t.trigger.matches(":hover")||t.panel.matches(":hover")||t.trigger===document.activeElement||t.panel.contains(document.activeElement)))}_restoreFocus(e){this._pointerFocus.add(e),e.focus(),queueMicrotask(()=>this._pointerFocus.delete(e))}_cancelTimers(e){this._cancelTimer(this._openTimers,e),this._cancelTimer(this._closeTimers,e)}_cancelTimer(e,t){let s=e.get(t);s!==void 0&&clearTimeout(s),e.delete(t)}_syncActive(){let e=this._active==null?null:String(this._active);for(let t of this.refs.list.querySelectorAll("[data-app-nav-id]")){let s=e!==null&&t.getAttribute("data-app-nav-value-id")===e,n=this._flyouts.get(String(t.getAttribute("data-app-nav-id"))),r=e!==null&&n?pn(n.item.children??[],e):!1;s?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current"),r?t.dataset.activeDescendant="true":delete t.dataset.activeDescendant}for(let t of this._flyouts.values()){e!==null&&pn(t.item.children??[],e)?t.trigger.dataset.activeDescendant="true":delete t.trigger.dataset.activeDescendant;for(let n of t.panel.querySelectorAll("[data-app-nav-value-id]"))e!==null&&n.getAttribute("data-app-nav-value-id")===e?n.setAttribute("aria-current","page"):n.removeAttribute("aria-current")}}_clearArtifacts(){for(let e of this._openTimers?this._openTimers.values():[])clearTimeout(e);for(let e of this._closeTimers?this._closeTimers.values():[])clearTimeout(e);this._openTimers?.clear?.(),this._closeTimers?.clear?.(),this._interaction?.destroy?.();for(let e of this._tooltips??[])e.destroy();this._silenceFlyoutEvents=!0;for(let e of this._flyouts?.values?.()??[])e.dropdown.destroy();this._silenceFlyoutEvents=!1,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._flyouts=new Map}_message(e,t,...s){let n=this.msg(e,...s);return n===e?F(t,s):n}},hn=class extends S{constructor(e){super(null),e.append(this.el)}render(){return u("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}},rl=Object.freeze({});function fn(i,e=!1){return i.flatMap(t=>t.section?[e?t:rl,...fn(t.children??[],e)]:[t])}function He(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.label!=null&&(e.id!=null||e.section===!0)).map((e,t)=>{let s={...e,id:e.id??`section:${t}:${e.label}`,label:String(e.label),children:Array.isArray(e.children)?He(e.children):[]};if(e.section===!0)return s.section=!0,delete s.href,s;if(e.href==null)return s;let n=Re(e.href);return n!==null?s.href=n:(delete s.href,s.children.length===0&&typeof s.invoke!="function"&&(s.disabled=!0)),s}):[]}function Qi(i,e,t){let s=typeof e=="function"?e(i,t):null;if(s==null&&(s=i.icon),typeof s=="function"&&(s=s(t,i)),typeof s=="string")return v(s);if(s instanceof Node)return s.cloneNode(!0);if(s&&typeof s=="object"&&typeof s.toElement=="function"){let n=s.toElement();return n instanceof Node?n.cloneNode(!0):null}return null}function il(i,{className:e,index:t,iconOnly:s,disclosure:n,disclosureIcon:r,visual:o}){let a=Re(i.href),l=a&&!n?"a":"button";return u(l,{class:e,type:l==="button"?"button":null,href:l==="a"?a:null,target:l==="a"?i.target??null:null,rel:l==="a"?"noopener":null,ariaLabel:s?i.label:null,ariaDisabled:i.disabled?"true":null,dataset:{appNavId:t,appNavValueId:String(i.id)}},o?u("span",{class:`${e}-icon`,ariaHidden:"true"},o):null,u("span",{class:`${e}-label`},i.label),i.badge!=null?u("span",{class:`${e}-badge`},String(i.badge)):null,n?u("span",{class:`${e}-disclosure`,ariaHidden:"true"},v(r)):null)}function wf(i){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[i]??"chevron-right"}function vf(i){return i==="right"?"chevron-left":"chevron-right"}function xf(i){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[i]??"right-start"}function Sf(i){return i==="right"?"left-start":"right-start"}function Af(i){return{left:"right",right:"left",top:"bottom",bottom:"top"}[i]??"right"}function ol(i){return[...i.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function sl(i){return ol(i)[0]??null}function kf(i){return[...i.children].map(e=>e.querySelector("[data-app-nav-id]")).filter(Boolean)}function pn(i,e){return i.some(t=>String(t.id)===e||pn(t.children??[],e))}function nl(i,e){if(e!=null)if(typeof e=="string"||typeof e=="number")i.append(document.createTextNode(String(e)));else if(typeof e=="object"&&typeof e.toElement=="function"){let t=e.toElement();t&&i.append(t)}else typeof e=="object"&&typeof e.nodeType=="number"&&i.append(e)}var Cf=["tint","solid","plain"],Tf=12,zf=600,Xi=class extends Gi{static cssName="module-bar";static partBlock="zx-module-bar";static defaults={items:[],active:null,orientation:"vertical",side:"left",appearance:"tint",labels:"hidden",menus:"flyout",expanded:null,controls:null,allModules:"auto",header:null,footer:null,label:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(e=null,t={}){super(e,t)}render(){let e=super.render();return this._sections=new Map,this._items=_n(this._items,this._sections),this._appearance=Cf.includes(this.options.appearance)?this.options.appearance:"tint",this._menus=this.options.menus==="none"?"none":"flyout",this._expandedId=this.options.expanded??null,this._labels=this.options.labels,this._promoted=null,this._catalogue=null,this._silenceCatalogue=!1,this._catalogueTooltip=null,this._observer=null,this._partition={visible:[],overflow:[]},this._rovingId=null,this._typeahead={text:"",at:0},e.setAttribute("aria-label",this._labelText()),e.dataset.appearance=this._appearance,e.dataset.menus=this._menus,e.dataset.allModules=["always","never"].includes(this.options.allModules)?this.options.allModules:"auto",e.dataset.labels=mn(this.options.labels,e.dataset.orientation),e}setItems(e){let t=new Map,s=_n(He(e),t);return this._sections=t,super.setItems(s)}getItems(){return super.getItems()}setActive(e){return super.setActive(e)}openFlyout(e,t={}){return super.openFlyout(e,t)}closeFlyout(e){return super.closeFlyout(e)}closeAllFlyouts(){return super.closeAllFlyouts()}isFlyoutOpen(e){return super.isFlyoutOpen(e)}setExpanded(e){return this._expandedId=e??null,this._syncExpanded(),this._layout(),this}setBadge(e,t){let s=Se(this._items,e);if(!s)return this;t==null||t===""?delete s.badge:s.badge=t;let n=String(e);for(let o of this.refs.list.querySelectorAll(".zx-module-bar__item[data-app-nav-value-id]"))o.getAttribute("data-app-nav-value-id")===n&&this._applyTileBadge(o,s);for(let o of this._flyouts.values())for(let a of o.panel.querySelectorAll("[data-app-nav-value-id]"))a.getAttribute("data-app-nav-value-id")===n&&gn(a,s,"zx-app-rail__flyout-item");let r=this._catalogueEntry(n);return r&&gn(r,s,"zx-module-bar__entry"),this}setLayout(e={}){let t=e.orientation==="horizontal"||e.orientation==="vertical"?e.orientation:this.el.dataset.orientation,s=t==="horizontal"?["top","bottom"]:["left","right"],n=s.includes(e.side??this.el.dataset.side)?e.side??this.el.dataset.side:s[0];return t===this.el.dataset.orientation&&n===this.el.dataset.side?this:(this.el.dataset.orientation=t,this.el.dataset.side=n,this.el.dataset.labels=mn(this._labels,t),this._rebuild(),this)}setLabels(e){this._labels=e;let t=mn(e,this.el.dataset.orientation);if(t===this.el.dataset.labels)return this;let s=document.activeElement,n=s instanceof HTMLElement&&this.refs.list.contains(s)&&s.matches(".zx-module-bar__item")?Ji(s):null;return this.el.dataset.labels=t,this._rebuild(),n!==null&&[...this.refs.list.querySelectorAll(".zx-module-bar__item")].find(r=>Ji(r)===n)?.focus(),this}openAllModules(){return this._catalogue?.open(),this._focusCatalogue(),this}closeAllModules(){return this._catalogue?.close(),this}isAllModulesOpen(){return this._catalogue?.isOpen()??!1}focus(){return this._rovingStop()?.focus(),this}destroy(){super.destroy()}_containsNode(e){return super._containsNode(e)||!!(e&&this._catalogue?.getPanel().contains(e))}_clearArtifacts(){super._clearArtifacts(),this._observer?.disconnect(),this._observer=null,this._catalogueTooltip?.destroy(),this._catalogueTooltip=null,this._silenceCatalogue=!0,this._catalogue?.destroy(),this._silenceCatalogue=!1,this._catalogue=null}_flyoutsFor(e){return this._menus==="flyout"&&!e.disabled}_tooltipFor(){return this.el.dataset.labels==="hidden"}_renderControl(e){let t=!!e.children?.length,s=e.href&&!t?"a":"button",n=this.el.dataset.labels!=="hidden",r=u(s,{class:"zx-module-bar__item",type:s==="button"?"button":null,href:s==="a"?e.href:null,target:s==="a"?e.target??null:null,rel:s==="a"&&e.target?"noopener":null,ariaDisabled:e.disabled?"true":null,tabIndex:-1,dataset:{appNavId:String(e.id),appNavValueId:String(e.id)}},this._renderTile(e,"bar"),n?u("span",{class:"zx-module-bar__label"},e.label):null);return this._applyTileBadge(r,e),r}_afterRebuild(){let e=this.refs.list,t=ul(this._items),s=new Map;for(let r of[...e.children]){let o=r.querySelector("[data-app-nav-value-id]")?.getAttribute("data-app-nav-value-id");o!=null&&(r.dataset.moduleId=o,s.set(o,r))}let n=null;for(let r of t){let o=s.get(String(r.id));if(!o)continue;let a=this._sections.get(String(r.id))??null;a!==null&&a!==n&&e.append(u("li",{class:"zx-module-bar__heading",dataset:{section:a}},u("span",{class:"zx-module-bar__heading-label"},a))),n=a,e.append(o)}this._promoted!==null&&!Se(this._items,this._promoted)&&(this._promoted=null),this._buildCatalogue(),this._interaction.listen(e,"focusin",r=>{let o=r.target.closest?.(".zx-module-bar__item");o instanceof HTMLElement&&this._setRovingStop(o)}),this._interaction.listen(e,"focusout",r=>{e.contains(r.relatedTarget)||(this._rovingId=null,this._syncRoving())}),typeof ResizeObserver=="function"&&(this._observer=new ResizeObserver(()=>this._layout()),this._observer.observe(e))}_syncActive(){super._syncActive();let e=this._active==null?null:String(this._active);for(let t of this._tiles()){let s=Se(this._items,t.getAttribute("data-app-nav-value-id"));if(!s)continue;let n=cl(s,e);n?t.setAttribute("aria-current",n):t.removeAttribute("aria-current"),n==="true"?t.dataset.activeDescendant="true":delete t.dataset.activeDescendant}for(let t of this._catalogueEntries()){let s=Se(this._items,t.dataset.moduleId),n=s?cl(s,e):null;n?t.setAttribute("aria-current",n):t.removeAttribute("aria-current")}this._syncExpanded(),this._layout()}_layout(){let e=this.refs.list;if(!e||!this._items)return;let t=[...e.querySelectorAll(":scope > [data-module-id]")],s=e.querySelector(":scope > [data-module-bar-more]"),n=this.el.dataset.allModules,r=[Nf(this._items,this._active)?.id,this._expandedId,this._promoted],o=1/0;if(n!=="never"&&e.isConnected){for(let h of t)h.hidden=!1;s&&(s.hidden=!1),al(e),o=Mf(e,this.el.dataset.orientation==="horizontal",t.length+1)}let a=Ef(this._items,o,r,n==="always"),l=new Set(a.visible.map(h=>String(h.id)));for(let h of t)h.hidden=!l.has(h.dataset.moduleId);al(e),s&&(s.hidden=n==="never"||n==="auto"&&!a.more);let c={visible:a.visible.map(h=>h.id),overflow:a.overflow.map(h=>h.id)},d=c.visible.join("\0")!==this._partition.visible.join("\0")||c.overflow.join("\0")!==this._partition.overflow.join("\0");this._partition=c,this._syncRoving(),d&&e.isConnected&&this.emit("overflowchange",{...c})}_renderTile(e,t){let s=Qi(e,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:t==="bar"?"module":"catalogue"})??u("span",{class:"zx-module-bar__initial"},e.label.trim().charAt(0).toUpperCase()),{tone:n,color:r}=If(e),o=u("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{appearance:this._appearance,...n?{tone:n}:{},...r?{color:""}:{}}});return this._appearance==="solid"?o.append(Zi({icon:s,color:r,tone:n??(r?null:"slate"),size:"var(--zx-module-bar-tile)",iconSize:"58%",glass:"subtle"})):(r&&o.style.setProperty("--zx-module-bar-color",r),o.append(s)),o}_applyTileBadge(e,t){e.querySelector(":scope > .zx-module-bar__badge")?.remove();let s=t.badge==null||t.badge===""?null:String(t.badge);e.setAttribute("aria-label",s===null?t.label:this._message("moduleBar.itemBadge","%1 (%2)",t.label,s)),s!==null&&e.append(u("span",{class:"zx-module-bar__badge",ariaHidden:"true",dataset:{zxBadge:s.length>2&&this.el.dataset.labels!=="beside"?"dot":"count"}},s))}_buildCatalogue(){let e=this._message("moduleBar.more","All modules"),t=this.el.dataset.labels!=="hidden",s=u("button",{class:"zx-module-bar__item",type:"button",ariaLabel:e,tabIndex:-1,dataset:{moduleBarMore:""}},u("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{appearance:"plain"}},v("grid")),t?u("span",{class:"zx-module-bar__label"},e):null);this.refs.list.append(u("li",{class:"zx-module-bar__row",dataset:{moduleBarMore:""}},s)),t||(this._catalogueTooltip=new at(s,{content:e,placement:{left:"right",right:"left",top:"bottom",bottom:"top"}[this.el.dataset.side]??"right",delay:450}));let n=this._items.length>Tf?u("input",{class:"zx-module-bar__filter",type:"search",autocomplete:"off",placeholder:this._message("moduleBar.filter","Filter modules"),ariaLabel:this._message("moduleBar.filter","Filter modules")}):null,r=new Map;for(let p of this._items){let f=typeof p.group=="string"?p.group:this._sections.get(String(p.id))??"";r.has(f)||r.set(f,[]),r.get(f).push(p)}let o=[...r].map(([p,f])=>{let m=p?E("zx-module-bar-group"):null;return u("div",{class:"zx-module-bar__group"},p?u("div",{class:"zx-module-bar__group-label",id:m},p):null,u("ul",{class:"zx-module-bar__grid",ariaLabelledby:m},f.map(g=>u("li",{dataset:{moduleId:String(g.id)}},this._catalogueControl(g)))))}),a=u("p",{class:"zx-module-bar__empty",hidden:!0},this._message("moduleBar.empty","No modules")),l=u("div",{class:"zx-module-bar__catalogue"},n,...o,a),c={left:"right-start",right:"left-start",top:"bottom-end",bottom:"top-end"}[this.el.dataset.side]??"right-start",d=new ut(s,{content:l,placement:c,offset:6}),h=d.getPanel();h.classList.add("zx-module-bar__popover"),h.setAttribute("role","region"),h.setAttribute("aria-label",e),this._catalogue=d,d.on("open",()=>{this.closeAllFlyouts(),this._catalogueTooltip?.hide(),this.emit("allmodules",{open:!0})}),d.on("close",()=>{n instanceof HTMLInputElement&&n.value&&(n.value="",this._filterCatalogue("")),this._silenceCatalogue||this.emit("allmodules",{open:!1})}),this._interaction.listen(s,"click",()=>{d.isOpen()&&this._focusCatalogue()}),n&&this._interaction.listen(n,"input",()=>this._filterCatalogue(n.value)),this._interaction.listen(h,"click",p=>this._onCatalogueClick(p)),this._interaction.listen(h,"focusout",p=>{let f=p.relatedTarget;f&&!h.contains(f)&&f!==s&&d.close()}),this._interaction.listen(h,"keydown",p=>this._onCatalogueKeydown(p)),this._interaction.listen(h,"focusin",p=>{let f=p.target.closest?.(".zx-module-bar__entry");f instanceof HTMLElement&&this._syncCatalogueStop(f)}),this._syncCatalogueStop()}_syncCatalogueStop(e){let t=this._catalogueEntries(),s=t.filter(r=>!r.closest("li")?.hidden),n=(e&&s.includes(e)?e:null)??s.find(r=>r.tabIndex===0&&r.dataset.catalogueStop==="true")??s.find(r=>r.hasAttribute("aria-current"))??s[0];for(let r of t)r.tabIndex=r===n?0:-1,r===n?r.dataset.catalogueStop="true":delete r.dataset.catalogueStop}_catalogueControl(e){let t=!!e.children?.length,s=e.href&&!t?"a":"button",n=u(s,{class:"zx-module-bar__entry",type:s==="button"?"button":null,href:s==="a"?e.href:null,target:s==="a"?e.target??null:null,rel:s==="a"&&e.target?"noopener":null,title:typeof e.description=="string"?e.description:null,ariaDisabled:e.disabled?"true":null,dataset:{moduleId:String(e.id)}},this._renderTile(e,"catalogue"),u("span",{class:"zx-module-bar__entry-label"},e.label));return gn(n,e,"zx-module-bar__entry"),n}_onCatalogueClick(e){let t=e.target.closest?.(".zx-module-bar__entry");if(!(t instanceof HTMLElement))return;let s=Se(this._items,t.dataset.moduleId);if(!s||s.disabled){e.preventDefault();return}if(s.children?.length&&this._menus==="flyout"){e.preventDefault(),this._catalogue?.close(),this._promoted=s.id,this._layout();let o=e instanceof MouseEvent&&e.detail===0;this.openFlyout(s.id,{focus:o}),o||this._tiles().find(a=>a.getAttribute("data-app-nav-value-id")===String(s.id))?.focus();return}this._select(s,e);let n=this._catalogue?.getPanel();this._catalogue?.close();let r=document.activeElement;(!r||r===document.body||n?.contains(r))&&(this._tiles().find(a=>a.getAttribute("data-app-nav-value-id")===String(s.id)&&!a.closest("li")?.hidden)??this.refs.list.querySelector("[data-module-bar-more] .zx-module-bar__item"))?.focus()}_onCatalogueKeydown(e){let t=this._catalogue?.getPanel();if(!t||e.altKey||e.ctrlKey||e.metaKey)return;let s=t.querySelector(".zx-module-bar__filter"),n=this._catalogueEntries().filter(l=>!l.closest("li")?.hidden),r=e.target.closest?.(".zx-module-bar__entry");if(e.target===s){e.key==="ArrowDown"&&n[0]&&(e.preventDefault(),n[0].focus());return}if(!(r instanceof HTMLElement))return;let o=n.indexOf(r),a=null;if(e.key==="ArrowRight")a=n[Math.min(n.length-1,o+1)];else if(e.key==="ArrowLeft")a=n[Math.max(0,o-1)];else if(e.key==="Home")a=n[0];else if(e.key==="End")a=n.at(-1);else if(e.key==="ArrowDown"||e.key==="ArrowUp")a=Df(n,r,e.key==="ArrowDown"?1:-1),!a&&e.key==="ArrowUp"&&s instanceof HTMLElement&&(a=s);else if(s instanceof HTMLElement&&e.key.length===1&&e.key!==" "){s.focus();return}else return;e.preventDefault(),a?.focus()}_filterCatalogue(e){let t=this._catalogue?.getPanel();if(!t)return;let s=e.trim().toLocaleLowerCase(),n=0;for(let o of t.querySelectorAll(".zx-module-bar__group")){let a=0;for(let l of o.querySelectorAll("li[data-module-id]")){let c=Se(this._items,l.dataset.moduleId),d=`${c?.label??""} ${c?.description??""} ${c?.group??""}`.toLocaleLowerCase(),h=!s||d.includes(s);l.hidden=!h,h&&(a+=1)}o.hidden=a===0,n+=a}let r=t.querySelector(".zx-module-bar__empty");r instanceof HTMLElement&&(r.hidden=n>0),this._syncCatalogueStop()}_focusCatalogue(){let e=this._catalogue?.getPanel();if(!e||!this._catalogue?.isOpen())return;let s=e.querySelector(".zx-module-bar__filter")??this._catalogueEntries().find(n=>n.hasAttribute("aria-current"))??this._catalogueEntries()[0];s instanceof HTMLElement&&s.focus()}_onRailKeydown(e){let t=e.target.closest?.(".zx-module-bar__item");if(!(t instanceof HTMLElement)||!this.refs.list.contains(t)||e.altKey||e.ctrlKey||e.metaKey)return;let s=this._rovingControls(),n=s.indexOf(t),r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",l={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],c=t.getAttribute("data-app-nav-id");if(e.key===l&&c!==null&&this._flyouts.has(c)){e.preventDefault(),this.openFlyout(c,{focus:!0});return}let d=null;if(e.key==="Home")d=s[0];else if(e.key==="End")d=s.at(-1);else if(e.key===o)d=s[(n-1+s.length)%s.length];else if(e.key===a)d=s[(n+1)%s.length];else if(e.key.length===1&&e.key!==" ")d=this._typeaheadTarget(e.key,s,n);else return;d&&(e.preventDefault(),this._setRovingStop(d),d.focus())}_typeaheadTarget(e,t,s){let n=Date.now(),r=n-this._typeahead.at>zf?e:this._typeahead.text+e;this._typeahead={text:r,at:n};let o=r.toLocaleLowerCase(),a=[...o].every(h=>h===o[0]),l=h=>(Se(this._items,h.getAttribute("data-app-nav-value-id"))?.label??h.getAttribute("aria-label")??"").toLocaleLowerCase(),c=[...t.slice(s+1),...t.slice(0,s+1)],d=c.find(h=>l(h).startsWith(o))??(a?c.find(h=>l(h).startsWith(o[0])):null);return d||r.length===1?d??null:(this._typeahead={text:e,at:n},c.find(h=>l(h).startsWith(e.toLocaleLowerCase()))??null)}_tiles(){return[...this.refs.list.querySelectorAll(":scope > li > .zx-module-bar__item[data-app-nav-value-id]")]}_rovingControls(){return[...this.refs.list.querySelectorAll(":scope > li:not([hidden]) > .zx-module-bar__item")]}_rovingStop(){let e=this._rovingControls();if(this._rovingId!==null){let t=e.find(s=>Ji(s)===this._rovingId);if(t)return t}return e.find(t=>t.hasAttribute("aria-current"))??e.find(t=>t.getAttribute("aria-expanded")==="true"&&t.hasAttribute("data-app-nav-value-id"))??e[0]??null}_setRovingStop(e){this._rovingId=Ji(e),this._syncRoving()}_syncRoving(){let e=this._rovingStop();for(let t of this.refs.list.querySelectorAll(":scope > li > .zx-module-bar__item"))t.tabIndex=t===e?0:-1}_syncExpanded(){if(this._menus!=="none")return;let e=this._expandedId==null?null:String(this._expandedId);for(let t of this._tiles()){let s=t.getAttribute("data-app-nav-value-id"),n=Se(this._items,s);(n?.children?.length||n?.header||n?.content||s===e)&&(t.setAttribute("aria-expanded",String(s===e)),this.options.controls&&t.setAttribute("aria-controls",String(this.options.controls)))}}_catalogueEntries(){let e=this._catalogue?.getPanel();return e?[...e.querySelectorAll(".zx-module-bar__entry")]:[]}_catalogueEntry(e){return this._catalogueEntries().find(t=>t.dataset.moduleId===e)??null}_labelText(){let e=this.options.label;return e==null||e===""?this._message("moduleBar.label","Modules"):String(e)}};function Ef(i,e=1/0,t=[],s=!1){let n=Array.isArray(i)?i.filter(m=>m&&m.id!=null):[],r=ul(n),a=n.some(ll)?r.filter(ll):r,l=Number.isFinite(e)?Math.max(1,Math.floor(e)):1/0,d=s||a.length<n.length||a.length>l?Math.max(0,l-1):l,h=a.slice(0,d),p=new Set([t].flat().filter(m=>m!=null).map(String));for(let m of p){let g=n.find(_=>String(_.id)===m);if(!(!g||h.includes(g))){if(h.length>=d){let _=h.findLastIndex(b=>!p.has(String(b.id)));_>=0&&h.splice(_,1)}h.push(g)}}h.sort((m,g)=>r.indexOf(m)-r.indexOf(g));let f=n.filter(m=>!h.includes(m));return{visible:h,overflow:f,more:f.length>0}}function If(i){let e=ze(i?.color)?String(i.color).trim():null;return e?{tone:null,color:e}:{tone:dn.includes(i?.tone)?i.tone:null,color:null}}function _n(i,e=new Map,t=null){return i.flatMap(s=>s.section?_n(s.children??[],e,s.label):(t!==null&&e.set(String(s.id),t),[s]))}function al(i){let e=null,t=!1,s=!0,n=()=>{e&&(e.hidden=!t)};for(let r of[...i.children]){if(r.classList.contains("zx-module-bar__heading")){n(),e=r,t=!1,s?r.dataset.leading="":delete r.dataset.leading;continue}r.hasAttribute("data-module-id")&&!r.hidden&&(t=!0,s=!1)}n()}function mn(i,e){return e!=="vertical"?"hidden":i==="below"||i==="beside"?i:"hidden"}function ll(i){return i.pinned===!0||typeof i.pinned=="number"&&Number.isFinite(i.pinned)}function ul(i){let e=t=>typeof t.pinned=="number"&&Number.isFinite(t.pinned)?t.pinned:t.pinned===!0?Number.MAX_SAFE_INTEGER-1:Number.MAX_SAFE_INTEGER;return i.map((t,s)=>({item:t,index:s})).sort((t,s)=>e(t.item)-e(s.item)||t.index-s.index).map(({item:t})=>t)}function Mf(i,e,t){if(!(e?i.scrollWidth>i.clientWidth+1:i.scrollHeight>i.clientHeight+1))return 1/0;let n=[...i.querySelectorAll(":scope > li:not([hidden]):not(.zx-module-bar__heading)")];if(!n.length)return 1/0;let r=[...i.querySelectorAll(":scope > li.zx-module-bar__heading:not([hidden])")],o=getComputedStyle(i),a=Number.parseFloat(e?o.columnGap:o.rowGap)||0,l=e?(Number.parseFloat(o.paddingInlineStart)||0)+(Number.parseFloat(o.paddingInlineEnd)||0):(Number.parseFloat(o.paddingBlockStart)||0)+(Number.parseFloat(o.paddingBlockEnd)||0),c=Math.max(...n.map(p=>e?p.offsetWidth:p.offsetHeight)),d=r.reduce((p,f)=>p+a+(e?f.offsetWidth:f.offsetHeight)+(Number.parseFloat(e?getComputedStyle(f).marginInlineStart:getComputedStyle(f).marginBlockStart)||0)+(Number.parseFloat(e?getComputedStyle(f).marginInlineEnd:getComputedStyle(f).marginBlockEnd)||0),0),h=(e?i.clientWidth:i.clientHeight)-l-d;return c<=0||h<=0?t:Math.max(1,Math.floor((h+a)/(c+a)))}function Df(i,e,t){let s=e.getBoundingClientRect(),n=s.left+s.width/2,r=null,o=1/0,a=1/0;for(let l of i){if(l===e)continue;let c=l.getBoundingClientRect(),d=t>0?c.top-s.bottom+1:s.top-c.bottom+1;if(d<0)continue;let h=Math.abs(c.left+c.width/2-n);(d<o-1||Math.abs(d-o)<=1&&h<a)&&(r=l,o=d,a=h)}return r}function Ji(i){return i.getAttribute("data-app-nav-value-id")??"\0more"}function cl(i,e){return e===null?null:String(i.id)===e?"page":bn(i.children??[],e)?"true":null}function gn(i,e,t){let s=i.querySelector(`:scope > .${t}-badge`),n=e.badge==null||e.badge===""?null:String(e.badge);if(n===null){s?.remove();return}s?s.textContent=n:i.querySelector(`:scope > .${t}-label`)?.after(u("span",{class:`${t}-badge`},n))}function Nf(i,e){if(e==null||!Array.isArray(i))return null;let t=String(e);return i.find(s=>String(s.id)===t||bn(s.children??[],t))??null}function Se(i,e){if(e==null)return null;for(let t of i??[]){if(String(t.id)===String(e))return t;let s=Se(t.children??[],e);if(s)return s}return null}function bn(i,e){return i.some(t=>String(t.id)===e||bn(t.children??[],e))}var Of=8e3,wn=class{#e;#t=[];#i=[];#s;constructor(e=5,t=()=>{}){if(!Number.isInteger(e)||e<1)throw new RangeError("Queue limit must be positive");if(typeof t!="function")throw new TypeError("Activation callback must be a function");this.#e=e,this.#s=t}enqueue(e){return this.#t.length<this.#e?(this.#t.push(e),this.#s(e),"active"):(this.#i.push(e),"pending")}remove(e){let t=this.#i.indexOf(e);if(t!==-1)return this.#i.splice(t,1),"pending";let s=this.#t.indexOf(e);if(s===-1)return null;if(this.#t.splice(s,1),this.#i.length>0){let n=this.#i.shift();this.#t.push(n),this.#s(n)}return"active"}isActive(e){return this.#t.includes(e)}clear(){let e={active:this.#t.slice(),pending:this.#i.slice()};return this.#t.length=0,this.#i.length=0,e}get activeCount(){return this.#t.length}get pendingCount(){return this.#i.length}},De=class i extends S{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};render(){let e=!this.el,t=this.el??u("div");return this._createdRoot=e,this._original=e?null:$f(t),this._entries=new Set,this._floatingHost=null,this._placedIn=null,this._overlay=null,this._unfollow=null,this._queue=new wn(Bf(this.options.maxVisible),s=>{this._activate(s)}),t.replaceChildren(),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t}show(e,t={}){let s=Pf(t.action),n={kind:Rf(t.kind??this.options.kind),timeout:Ff(t.timeout??this.options.timeout,s!==null),closable:t.closable??!!this.options.closable,action:s,leading:Vf(t.leading)},r=this._createEntry(e,n);return this._entries.add(r),this._queue.enqueue(r),{close:()=>this._close(r)}}static info(e,t={}){return this.show(e,{...t,kind:"info"})}static success(e,t={}){return this.show(e,{...t,kind:"success"})}static warning(e,t={}){return this.show(e,{...t,kind:"warning"})}static error(e,t={}){return this.show(e,{...t,kind:"error"})}static show(e,t={}){return this.#e(t.scope).show(e,t)}static progress(e,t={}){return this.#e(t.scope)._progress(e)}static disposeRegion(e){if(e==null)return!1;let t=Q(e);if(!t)return!1;let s=i.#t(ce(t));return s?(s._disposeFloating(),!0):!1}destroy(){if(this._cleaned)return;this._cleaned=!0,this._unfollow?.(),this._unfollow=null;let e=this._overlay;this._overlay=null,e?.release(),this._floatingHost=null,this._placedIn=null;for(let t of this._entries)yn(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Uf(this.el,this._original)}_progress(e){let t={pct:0,text:String(e)},s=this._createEntry(t.text,{kind:"info",timeout:0,closable:!1},t);this._entries.add(s),this._queue.enqueue(s);let n=!1;return{update:(r,o)=>{n||s.closed||(t.pct=qf(r),o!==void 0&&(t.text=String(o)),es(s,t))},done:()=>{n||s.closed||(n=!0,t.pct=100,es(s,t),s.timeout=600,s.remaining=600,this._queue.isActive(s)&&this._schedule(s))},fail:r=>{n||s.closed||(n=!0,r!==void 0&&(t.text=String(r)),s.kind="error",s.node.dataset.kind="error",s.node.setAttribute("role","alert"),s.iconHost.replaceChildren(v("error",{size:18})),es(s,t),s.timeout=4e3,s.remaining=4e3,this._queue.isActive(s)&&this._schedule(s))}}}_createEntry(e,t,s=null){let n=u("span",{class:"zx-message__icon",ariaHidden:"true"},t.leading??v(t.kind,{size:18})),r=u("div",{class:"zx-message__content"});Rt(e)?r.append(e):r.append(document.createTextNode(String(e)));let o=u("div",{class:"zx-message__toast",role:t.kind==="error"?"alert":"status",dataset:{kind:t.kind,state:"queued"}},n,r),a={node:o,content:r,iconHost:n,kind:t.kind,timeout:t.timeout,remaining:t.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,hovered:!1,focused:!1,returnFocus:null,progressBar:null,progressFill:null};if(t.leading&&(o.dataset.leading=""),s){o.dataset.progress="";let l=u("span",{class:"zx-message__progress-fill"}),c=u("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},l);r.append(c),a.progressBar=c,a.progressFill=l,es(a,s)}if(t.action){let{label:l,kind:c,onclick:d}=t.action,h=za({label:l,kind:c,size:"sm"});h.classList.add("zx-message__action"),o.append(h),this.listen(h,"click",p=>{if(!a.closed)try{d?.(p)}finally{this._close(a)}})}if(t.closable){let l=u("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:this._message("message.close","Close message"),title:this._message("message.closeTitle","Close")},v("x",{size:T.dismiss}));o.append(l),this.listen(l,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>{a.hovered=!0,this._pause(a)}),this.listen(o,"mouseleave",()=>{a.hovered=!1,this._resume(a)}),this.listen(o,"focusin",l=>{if(!a.focused){let c=l.relatedTarget;a.returnFocus=Rt(c)&&!o.contains(c)?c:null}a.focused=!0,this._pause(a)}),this.listen(o,"focusout",l=>{let c=l.relatedTarget;Rt(c)&&o.contains(c)||(a.focused=!1,this._resume(a))}),a}_activate(e){e.closed||(e.node.dataset.state="open",this.el.append(e.node),this._schedule(e))}_schedule(e){e.closed||e.remaining<=0||e.hovered||e.focused||(e.startedAt=Date.now(),e.timer=setTimeout(()=>this._close(e),e.remaining))}_pause(e){e.closed||e.timer===null||(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(0,e.remaining-(Date.now()-e.startedAt)))}_resume(e){if(!(e.closed||e.timer!==null||e.hovered||e.focused)&&e.timeout!==0){if(e.remaining<=0){this._close(e);return}this._schedule(e)}}_close(e){if(e.closed)return;if(e.closed=!0,yn(e),jf(e),!this._queue.isActive(e)){this._queue.remove(e),e.node.remove(),this._entries.delete(e),this._releaseIfEmpty();return}if(e.node.dataset.state="closing",!Hf()){this._finish(e);return}let t=s=>{s.target===e.node&&this._finish(e)};this.listen(e.node,"animationend",t,{once:!0}),e.exitTimer=setTimeout(()=>this._finish(e),260)}_finish(e){this._entries.has(e)&&(yn(e),e.node.remove(),this._entries.delete(e),this._queue.remove(e),this._releaseIfEmpty())}_releaseIfEmpty(){!this._floatingHost||this._entries.size>0||i.#i(this)}_rehome(){let e=this._floatingHost;if(!e)return;let t=st.topmostModal()??e;if(this.el.parentElement===t&&this._placedIn===t)return;t.append(this.el),this._placedIn=t;let s=this.el;typeof s.showPopover=="function"&&!s.matches(":popover-open")&&s.showPopover()}_disposeFloating(){let e=this.el;this.destroy(),e.remove()}_message(e,t){let s=this.msg(e);return s===e?t:s}static#e(e){let t=ce(e??null);t.isConnected||(t=ce(null));let s=this.#t(t);if(s&&s.el.isConnected&&s.el.parentElement===s._placedIn)return s._rehome(),s;s?._disposeFloating();let n=u("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"}),r=new i(n);return r._floatingHost=t,r._overlay=st.push({kind:"toast",root:n,owner:r}),r._unfollow=st.subscribe(()=>r._rehome()),r._rehome(),r}static#t(e){for(let t of st.entries())if(t.kind==="toast"&&t.owner instanceof i&&t.owner._floatingHost===e)return t.owner;return null}static#i(e){e._disposeFloating()}};function Rf(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function Lf(i){let e=Number(i);return Number.isFinite(e)?Math.max(0,e):4e3}function Ff(i,e=!1){let t=Lf(i);return e&&t>0?Math.max(t,Of):t}function Pf(i){if(!i||typeof i!="object")return null;let e=i,t=e.label==null?"":String(e.label).trim();if(!t)return null;let s=["primary","danger","ghost"].includes(String(e.kind))?e.kind:"default";return{label:t,kind:s,onclick:typeof e.onclick=="function"?e.onclick:null}}function Vf(i){if(Rt(i))return i;if(i&&typeof i=="object"&&typeof i.toElement=="function"){let e=i.toElement();return Rt(e)?e:null}return null}function jf(i){let t=i.node.getRootNode?.()?.activeElement??globalThis.document?.activeElement;if(!t||!i.node.contains(t))return;let s=i.returnFocus;i.returnFocus=null,s?.isConnected&&typeof s.focus=="function"&&s.focus({preventScroll:!0})}function Bf(i){let e=Number(i);return Number.isInteger(e)&&e>0?e:5}function Rt(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function qf(i){let e=Number(i);return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function es(i,e){i.content.firstChild.textContent=e.text,i.progressBar?.setAttribute("aria-valuenow",String(e.pct)),i.progressBar?.setAttribute("aria-label",e.text),i.progressFill&&(i.progressFill.style.inlineSize=`${e.pct}%`)}function yn(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function Hf(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function $f(i){return{attributes:Array.from(i.attributes,e=>[e.name,e.value]),children:Array.from(i.childNodes)}}function Uf(i,e){for(let t of Array.from(i.attributes))i.removeAttribute(t.name);for(let[t,s]of e.attributes)i.setAttribute(t,s);i.replaceChildren(...e.children)}var is=Object.freeze(["agenda","day","week","month","year"]),Kf=864e5;function xn(i,e,t={}){let s=$e(e,"Calendar date"),n=_l(t.weekStart??1),r,o;if(i==="agenda")r=V(s),o=D(r,ns(t.agendaDays??14,"agendaDays"));else if(i==="day")r=V(s),o=D(r,1);else if(i==="week")r=ts(s,n),o=D(r,7);else if(i==="month"){let a=new Date(s.getFullYear(),s.getMonth(),1),l=new Date(s.getFullYear(),s.getMonth()+1,0);r=ts(a,n),o=D(ts(l,n),7)}else if(i==="year")r=new Date(s.getFullYear(),0,1),o=new Date(s.getFullYear()+1,0,1);else throw new RangeError(`Unknown calendar view: ${i}`);return{start:r,end:o}}function Sn(i,e,t,s={}){let n=$e(e,"Calendar date"),r=ke(t,"direction");if(i==="day")n.setDate(n.getDate()+r);else if(i==="agenda")n.setDate(n.getDate()+r*ns(s.agendaDays??14,"agendaDays"));else if(i==="week")n.setDate(n.getDate()+r*7);else{if(i==="month")return vn(n,r);if(i==="year")return vn(n,r*12);throw new RangeError(`Unknown calendar view: ${i}`)}return n}function vn(i,e){let t=$e(i,"Calendar date"),s=t.getDate();return t.setDate(1),t.setMonth(t.getMonth()+ke(e,"month amount")),t.setDate(Math.min(s,Yf(t.getFullYear(),t.getMonth()))),t}function Yf(i,e){return new Date(i,e+1,0).getDate()}function dt(i,e={}){if(!Array.isArray(i))throw new TypeError("Calendar events must be an array");let t={id:e.eventId??"id",title:e.eventTitle??"title",start:e.eventStart??"start",end:e.eventEnd??"end",allDay:e.eventAllDay??"allDay",color:e.eventColor??"color",location:e.eventLocation??"location",editable:e.eventEditable??"editable",durationEditable:e.eventDurationEditable??"durationEditable"},s=e.dateUnit==="seconds"?"seconds":"milliseconds",n=new Set;return i.map((r,o)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError(`Calendar event at index ${o} must be an object`);let a=Ae(r,t.id);if(a==null||a==="")throw new TypeError(`Calendar event at index ${o} requires an id`);let l=String(a);if(n.has(l))throw new RangeError(`Duplicate Calendar event id: ${l}`);n.add(l);let c=hl(Ae(r,t.start),s,`event ${l} start`),d=Ae(r,t.end),h=d==null||d===""?new Date(c.getTime()):hl(d,s,`event ${l} end`);if(h<c)throw new RangeError(`Calendar event ${l} ends before it starts`);let p=String(Ae(r,t.title)??"").trim()||(e.untitledTitle??R("calendar.untitled")),f=String(Ae(r,t.location)??"").trim(),m=fl(Ae(r,t.editable)),g=fl(Ae(r,t.durationEditable));return{id:a,title:p,start:c,end:h,allDay:!!Ae(r,t.allDay),color:Zf(Ae(r,t.color)),location:f,editable:m,durationEditable:g,data:r}})}function j(i){return{...i,start:new Date(i.start.getTime()),end:new Date(i.end.getTime())}}function An(i,e,t={}){let s=gl(t.minMinutes??0,"minMinutes"),n=gl(t.maxMinutes??1440,"maxMinutes",!0),r=ns(t.minimumMinutes??30,"minimumMinutes");if(n<=s)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=V(e),a=pl(o,s),l=pl(o,n),c=i.filter(f=>!ge(f)&&kn(f,a,l)).map(f=>{let m=new Date(Math.max(f.start.getTime(),a.getTime())),g=new Date(Math.min(f.end.getTime(),l.getTime()));return g<=m&&(g=new Date(Math.min(l.getTime(),m.getTime()+r*6e4))),{event:f,start:m,end:g,startMinutes:ml(o,m),endMinutes:ml(o,g),column:0,columns:1}}).sort((f,m)=>f.start-m.start||m.end-f.end||String(f.event.id).localeCompare(String(m.event.id))),d=[],h=-1/0,p=()=>{if(!d.length)return;let f=[],m=1;for(let g of d){let _=f.findIndex(b=>b<=g.start.getTime());_===-1&&(_=f.length),f[_]=g.end.getTime(),g.column=_,m=Math.max(m,_+1)}for(let g of d)g.columns=m;d=[],h=-1/0};for(let f of c)d.length&&f.start.getTime()>=h&&p(),d.push(f),h=Math.max(h,f.end.getTime());return p(),c}function ss(i,e,t){let s=V(e),n=D(s,ns(t,"days")),r=i.filter(a=>ge(a)&&kn(a,s,n)).map(a=>{let l=V(a.start),c=Wf(a);return{event:a,start:Math.max(0,ie(s,l)),end:Math.min(t,ie(s,c)),lane:0}}).filter(a=>a.end>a.start).sort((a,l)=>a.start-l.start||l.end-a.end||String(a.event.id).localeCompare(String(l.event.id))),o=[];for(let a of r){let l=o.findIndex(c=>c<=a.start);l===-1&&(l=o.length),a.lane=l,o[l]=a.end}return r}function Lt(i,e={}){let t=ke(e.days??0,"days"),s=ke(e.minutes??0,"minutes"),n=ke(e.endDays??t,"endDays"),r=ke(e.endMinutes??s,"endMinutes"),o=j(i);if(o.start=dl(o.start,t,s),o.end=dl(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function V(i){let e=$e(i,"Calendar date");return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function D(i,e){let t=$e(i,"Calendar date"),s=new Date(t.getTime());return s.setDate(s.getDate()+ke(e,"day amount")),s}function ts(i,e=1){let t=V(i),s=_l(e);return D(t,-((t.getDay()-s+7)%7))}function ie(i,e){let t=V(i),s=V(e),n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate());return Math.round((r-n)/Kf)}function H(i){let e=$e(i,"Calendar date"),t=s=>String(s).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function ge(i){if(i.allDay)return!0;if(i.end<=i.start)return!1;let e=new Date(i.end.getTime()-1);return H(i.start)!==H(e)}function Ft(i,e,t){return kn(i,e,t)}function dl(i,e,t){let s=new Date(i.getTime());return s.setDate(s.getDate()+e),s.setMinutes(s.getMinutes()+t),s}function Wf(i){if(i.end<=i.start)return D(V(i.start),1);let e=V(i.end);return i.end.getTime()===e.getTime()?e:D(e,1)}function kn(i,e,t){let s=i.end>i.start?i.end:new Date(i.start.getTime()+1);return i.start<t&&s>e}function Ae(i,e){return typeof e=="function"?e(i):i[e]}function hl(i,e,t){let s;if(i instanceof Date)s=new Date(i.getTime());else if(typeof i=="number"||typeof i=="string"&&/^-?\d+(?:\.\d+)?$/.test(i.trim())){let n=Number(i);s=new Date(n*(e==="seconds"?1e3:1))}else s=new Date(i);return $e(s,t)}function fl(i){return i==null?null:!!i}function Zf(i){let e=String(i??"").trim();return!e||e.length>100||/[;{}]|url\s*\(|image\s*\(/i.test(e)?null:/^#[\da-f]{3,8}$/i.test(e)||/^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\([^{};]+\)$/i.test(e)||/^var\(--[\w-]+\)$/i.test(e)||/^[a-z]+$/i.test(e)?e:null}function pl(i,e){let t=V(i);return t.setMinutes(e),t}function ml(i,e){return ie(i,e)*1440+e.getHours()*60+e.getMinutes()+e.getSeconds()/60+e.getMilliseconds()/6e4}function $e(i,e){if(!(i instanceof Date)||Number.isNaN(i.getTime()))throw new TypeError(`${e} must be a valid Date`);return new Date(i.getTime())}function _l(i){let e=Number(i);if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("weekStart must be from 0 through 6");return e}function ke(i,e){let t=Number(i);if(!Number.isInteger(t))throw new TypeError(`${e} must be an integer`);return t}function ns(i,e){let t=ke(i,e);if(t<=0)throw new RangeError(`${e} must be greater than zero`);return t}function gl(i,e,t=!1){let s=ke(i,e),n=t?1440:1439;if(s<0||s>n)throw new RangeError(`${e} must be from 0 through ${n}`);return s}var Vt=class extends S{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:[...is],weekStart:1,weekNumbers:!0,workweek:!1,agendaDays:14,slotDuration:30,slotMinTime:0,slotMaxTime:1440,scrollTime:480,eventLimit:3,selectable:!1,editable:!1,eventStartEditable:null,eventDurationEditable:null,optimistic:!0,nowIndicator:!0,now:null,disabled:!1,eventId:"id",eventTitle:"title",eventStart:"start",eventEnd:"end",eventAllDay:"allDay",eventColor:"color",eventLocation:"location",eventEditable:"editable",eventDurationEditable:"durationEditable",dateUnit:"milliseconds"};render(){let e=!this.el,t=this.el??u("section");this.el||(this.el=t),this._createdRoot=e,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes).map(({name:h,value:p})=>[h,p]),children:Array.from(t.childNodes)},this._views=Gf(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=bl(this.options.date,this.options.dateUnit,this._now()),this._events=dt(this.options.events,this._normalizeOptions()),this._loading=!1,this._destroyed=!1,this._pointer=null,this._keyboardEdit=null,this._mutationVersions=new Map,this._mutationSerial=0,this._suppressClickId=null,this._suppressDateClick=!1,this._focusedSlot=null,this._selection=null,this._nowTimer=null;let s=u("div",{class:"zx-calendar__navigation"},this._toolbarButton("previous",this.msg("calendar.previous"),"chevron-left"),this._toolbarButton("today",this.msg("calendar.today")),this._toolbarButton("next",this.msg("calendar.next"),"chevron-right")),n=u("h2",{ref:"heading",class:"zx-calendar__heading",ariaLive:"polite"}),r=u("div",{ref:"views",class:"zx-calendar__views",role:"group",ariaLabel:this._message("calendar.viewSwitch","Calendar view")},this._views.map(h=>u("button",{type:"button",class:"zx-calendar__view-button",dataset:{calendarAction:"view",view:h},disabled:this.options.disabled},this.msg(`calendar.${h}`)))),o=u("div",{class:"zx-calendar__commands"},r,u("button",{type:"button",class:"zx-calendar__new",dataset:{calendarAction:"new"},disabled:this.options.disabled},v("plus"),u("span",{},this.msg("calendar.new")))),a=u("header",{class:"zx-calendar__toolbar"},s,n,o),l=u("div",{ref:"body",class:"zx-calendar__body"}),c=u("div",{ref:"loading",class:"zx-calendar__loading",role:"status",hidden:!0},this.msg("calendar.loading")),d=u("div",{ref:"status",class:"zx-calendar__status",role:"status",ariaLive:"polite",ariaAtomic:"true"});return t.replaceChildren(a,l,c,d),t.setAttribute("aria-label",this.msg("calendar.label")),t.dataset.view=this._view,t.dataset.state="ready",this.listen(t,"click",h=>this._onClick(h)),this.listen(t,"dblclick",h=>this._onDoubleClick(h)),this.listen(t,"keydown",h=>this._onKeydown(h)),this.listen(t,"pointerdown",h=>this._onPointerDown(h)),this.listen(t,"pointermove",h=>this._onPointerMove(h)),this.listen(t,"pointerup",h=>this._onPointerUp(h)),this.listen(t,"pointercancel",h=>this._cancelPointer(h)),this.listen(t,"dragstart",h=>h.preventDefault()),this._renderView({emitDates:!0,scroll:!0}),this.options.nowIndicator&&(this._nowTimer=setInterval(()=>this._refreshNowIndicator(),6e4)),t}getEvents(){return this._events.map(j)}setEvents(e,t={}){let s=dt(e,this._normalizeOptions());return this._events=s,this._mutationVersions.clear(),this._renderView({preserveFocus:!0}),t.silent||this.emit("eventschange",{events:this.getEvents()}),this}addEvent(e,t={}){let[s]=dt([e],this._normalizeOptions());if(this._eventById(s.id))throw new RangeError(`Duplicate Calendar event id: ${s.id}`);return this._events=[...this._events,s],this._renderView({preserveFocus:!0}),t.silent||this.emit("eventschange",{events:this.getEvents()}),this}updateEvent(e,t,s={}){let n=this._eventIndex(e);if(n<0)throw new RangeError(`Unknown Calendar event id: ${e}`);let r=this._events[n],o={id:r.id,title:t.title??r.title,start:t.start??r.start,end:t.end??r.end,allDay:t.allDay??r.allDay,color:Object.prototype.hasOwnProperty.call(t,"color")?t.color:r.color,location:t.location??r.location,editable:Object.prototype.hasOwnProperty.call(t,"editable")?t.editable:r.editable,durationEditable:Object.prototype.hasOwnProperty.call(t,"durationEditable")?t.durationEditable:r.durationEditable,data:t.data??r.data},[a]=dt([o],{dateUnit:this.options.dateUnit,untitledTitle:this.msg("calendar.untitled")});return a.data=o.data,this._events=this._events.map((l,c)=>c===n?a:l),this._mutationVersions.delete(String(e)),this._renderView({preserveFocus:!0}),s.silent||this.emit("eventschange",{events:this.getEvents()}),this}removeEvent(e,t={}){let s=String(e),n=this._events.filter(r=>String(r.id)!==s);return n.length===this._events.length?this:(this._events=n,this._mutationVersions.delete(s),this._renderView({preserveFocus:!0}),t.silent||this.emit("eventschange",{events:this.getEvents()}),this)}getDate(){return new Date(this._date.getTime())}setDate(e,t={}){return this._date=bl(e,this.options.dateUnit,this._now()),this._renderView({emitDates:!t.silent,preserveFocus:!0,scroll:!0}),this}getView(){return this._view}setView(e,t={}){if(!this._views.includes(e))throw new RangeError(`Calendar view is not enabled: ${e}`);if(e===this._view)return this;let s=this._view;return this._view=e,this.el.dataset.view=e,this._renderView({emitDates:!0,preserveFocus:!0,scroll:!0}),t.silent||this.emit("viewchange",{view:e,oldView:s}),this}prev(){return this._page(-1)}next(){return this._page(1)}today(){return this.setDate(this._now())}setLoading(e=!0){return this._loading=!!e,this.el.dataset.state=this._loading?"loading":"ready",this.el.setAttribute("aria-busy",String(this._loading)),this.refs.loading.hidden=!this._loading,this}focusEvent(e){return this.el.querySelector(`[data-event-action][data-event-id="${Tn(String(e))}"]`)?.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0,this._nowTimer&&clearInterval(this._nowTimer),this._nowTimer=null;let e=this._original;if(super.destroy(),!this._createdRoot&&e){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,s]of e.attributes)this.el.setAttribute(t,s);this.el.replaceChildren(...e.children)}}_toolbarButton(e,t,s=null){return u("button",{type:"button",class:"zx-calendar__toolbar-button",dataset:{calendarAction:e},ariaLabel:s?t:null,disabled:this.options.disabled},s?v(s):t)}_normalizeOptions(){return{eventId:this.options.eventId,eventTitle:this.options.eventTitle,eventStart:this.options.eventStart,eventEnd:this.options.eventEnd,eventAllDay:this.options.eventAllDay,eventColor:this.options.eventColor,eventLocation:this.options.eventLocation,eventEditable:this.options.eventEditable,eventDurationEditable:this.options.eventDurationEditable,untitledTitle:this.msg("calendar.untitled"),dateUnit:this.options.dateUnit}}_renderView(e={}){if(!this.refs?.body||this._destroyed)return;let t=e.preserveFocus?this._focusIdentity():null,s=xn(this._view,this._date,{weekStart:this.options.weekStart,agendaDays:this.options.agendaDays});this._range=s,this.refs.heading.textContent=this._rangeTitle(s);for(let r of this.refs.views.querySelectorAll("[data-view]"))r.setAttribute("aria-pressed",String(r.dataset.view===this._view));let n=this._view==="agenda"?this._renderAgenda(s):this._view==="day"||this._view==="week"?this._renderTimeGrid(s):this._view==="month"?this._renderMonth(s):this._renderYear(s);this.refs.body.replaceChildren(n),e.scroll&&this._scrollTimeGrid(),t&&this._restoreFocus(t),e.emitDates&&this.emit("dateschange",{view:this._view,start:new Date(s.start.getTime()),end:new Date(s.end.getTime())})}_renderAgenda(e){let t=u("div",{class:"zx-calendar__agenda",role:"grid",ariaLabel:this._rangeTitle(e)}),s=ie(e.start,e.end);for(let n=0;n<s;n+=1){let r=D(e.start,n),o=D(r,1),a=this._events.filter(d=>Ft(d,r,o)?d.start>=r||n===0:!1).sort(Xf),l=u("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:H(r)}},u("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:H(r),dateCell:"true"},ariaCurrent:Ke(r,this._now())?"date":null,disabled:this.options.disabled},this._format(r,{weekday:"long",day:"numeric",month:"long"}))),c=u("div",{class:"zx-calendar__agenda-events",role:"gridcell"});if(!a.length)c.append(u("p",{class:"zx-calendar__agenda-empty"},this.msg("calendar.noEvents")));else for(let d of a)c.append(this._eventElement(d,{variant:"agenda",day:r}));l.append(c),t.append(l)}return t}_renderTimeGrid(e){let t=Array.from({length:ie(e.start,e.end)},(b,w)=>D(e.start,w)),s=this._view==="week"&&this.options.workweek?t.filter(b=>b.getDay()>0&&b.getDay()<6):t,n=Ce(this.options.slotMinTime,0),r=Ce(this.options.slotMaxTime,1440,!0),o=ue(this.options.slotDuration);if(r<=n)throw new RangeError("slotMaxTime must exceed slotMinTime");let a=Math.ceil((r-n)/o),l=u("div",{class:"zx-calendar__time-surface",style:{"--zx-calendar-day-count":String(s.length)}}),c=u("div",{class:"zx-calendar__time-header"},u("span",{class:"zx-calendar__time-corner",ariaHidden:"true"}),u("div",{class:"zx-calendar__day-headings",role:"row"},s.map(b=>u("button",{type:"button",class:"zx-calendar__day-heading",role:"columnheader",dataset:{calendarAction:"date",date:H(b),dateCell:"true"},ariaCurrent:Ke(b,this._now())?"date":null,disabled:this.options.disabled},u("span",{class:"zx-calendar__day-weekday"},this._format(b,{weekday:"short"})),u("span",{class:"zx-calendar__day-number"},this._format(b,{day:"numeric",month:"short"})))))),d=this._renderAllDayRail(s),h=u("div",{ref:"timeScroller",class:"zx-calendar__time-scroller"}),p=u("div",{class:"zx-calendar__time-axis",ariaHidden:"true"}),f=u("div",{class:"zx-calendar__time-grid",role:"grid",ariaLabel:this._rangeTitle(e),ariaRowcount:String(a),ariaColcount:String(s.length),style:{"--zx-calendar-slot-count":String(a)}}),m=u("div",{ref:"slots",class:"zx-calendar__slots"}),g=!0;for(let b=0;b<a;b+=1){let w=n+b*o;p.append(u("span",{class:"zx-calendar__time-label"},w%60===0?Cn(w,this._locale()):""));for(let A=0;A<s.length;A+=1){let y=Jf(s[A],w),x=String(y.getTime()),z=g&&(!this._focusedSlot||this._focusedSlot===x);z&&(g=!1),m.append(u("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:z?0:-1,dataset:{calendarAction:"date",slot:x,dateTime:x,dayIndex:String(A),rowIndex:String(b),major:w%60===0?"true":null},ariaLabel:this._dateTimeLabel(y),disabled:this.options.disabled}))}}g&&m.firstElementChild&&(m.firstElementChild.tabIndex=0);let _=u("div",{class:"zx-calendar__timed-events",ariaHidden:"false"});return s.forEach((b,w)=>{let A=An(this._events,b,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let y of A){let x=(y.startMinutes-n)/(r-n)*100,z=Math.max(o/(r-n)*100,(y.endMinutes-y.startMinutes)/(r-n)*100),Y=100/s.length,ae=Y/y.columns,se=w*Y+y.column*ae,W=this._eventElement(y.event,{variant:"timed",day:b,resizable:!0});W.style.insetInlineStart=`${se}%`,W.style.inlineSize=`${ae}%`,W.style.insetBlockStart=`${x}%`,W.style.blockSize=`${z}%`,_.append(W)}}),f.append(m,_,this._nowLine(s,n,r)),h.append(p,f),l.append(c,d,h),l}_renderAllDayRail(e){let t=u("div",{class:"zx-calendar__all-day"},u("span",{class:"zx-calendar__all-day-label"},this.msg("calendar.allDay"))),s=u("div",{class:"zx-calendar__all-day-grid",role:"row",style:{"--zx-calendar-day-count":String(e.length)}});for(let r of e)s.append(u("span",{class:"zx-calendar__all-day-cell",dataset:{date:H(r)},ariaHidden:"true"}));let n=ss(this._events,e[0],e.length);for(let r of n){let o=this._eventElement(r.event,{variant:"span",day:e[r.start]});o.style.gridColumn=`${r.start+1} / ${r.end+1}`,o.style.gridRow=String(r.lane+1),s.append(o)}return t.append(s),t}_renderMonth(e){let t=u("div",{class:"zx-calendar__month"}),s=u("div",{class:"zx-calendar__month-weekdays",role:"row"});this.options.weekNumbers&&s.append(u("span",{class:"zx-calendar__month-week-gutter",ariaHidden:"true"}));for(let r=0;r<7;r+=1){let o=D(e.start,r);s.append(u("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}t.append(s);let n=ie(e.start,e.end)/7;for(let r=0;r<n;r+=1){let o=D(e.start,r*7),a=ss(this._events.map(g=>({...g,allDay:!0})),o,7),l=Qf(this.options.eventLimit),c=a.filter(g=>g.lane<l),d=a.filter(g=>g.lane>=l),h=u("div",{class:"zx-calendar__month-week",role:"row",dataset:{weekStart:H(o)}});this.options.weekNumbers&&h.append(u("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:H(o)},ariaLabel:this.msg("calendar.weekNumber",wl(o)),disabled:this.options.disabled},String(wl(o))));let p=u("div",{class:"zx-calendar__month-days"});for(let g=0;g<7;g+=1){let _=D(o,g),b=this._events.filter(w=>Ft(w,_,D(_,1))).length;p.append(u("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",dataset:{calendarAction:"date",date:H(_),dateCell:"true",otherMonth:_.getMonth()===this._date.getMonth()?null:"true",eventCount:String(b)},ariaCurrent:Ke(_,this._now())?"date":null,ariaLabel:this._dayCountLabel(_,b),disabled:this.options.disabled},this._format(_,{day:"numeric"})))}let f=u("div",{class:"zx-calendar__month-events"});for(let g of c){let _=this._eventElement(g.event,{variant:"month",day:D(o,g.start)});_.style.gridColumn=`${g.start+1} / ${g.end+1}`,_.style.gridRow=String(g.lane+1),f.append(_)}let m=Array.from({length:7},(g,_)=>d.filter(b=>b.start<=_&&b.end>_).length);for(let g=0;g<m.length;g+=1){let _=m[g];if(!_)continue;let b=D(o,g);f.append(u("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:H(b),count:String(_)},style:{gridColumn:String(g+1),gridRow:String(l+1)},disabled:this.options.disabled},this.msg("calendar.more",_)))}h.append(p,f),t.append(h)}return t.setAttribute("role","grid"),t.setAttribute("aria-label",this._rangeTitle(e)),t}_renderYear(e){let t=e.start.getFullYear(),s=u("div",{class:"zx-calendar__year",ariaLabel:String(t)});for(let n=0;n<12;n+=1){let r=new Date(t,n,1),o=(r.getDay()-this.options.weekStart+7)%7,a=D(r,-o),l=u("div",{class:"zx-calendar__year-grid",role:"grid",ariaLabel:this._format(r,{month:"long"})},u("h3",{class:"zx-calendar__year-heading"},this._format(r,{month:"long"})));for(let c=0;c<7;c+=1){let d=D(a,c);l.append(u("span",{class:"zx-calendar__year-weekday",role:"columnheader"},this._format(d,{weekday:"narrow"})))}for(let c=0;c<42;c+=1){let d=D(a,c);if(d.getMonth()!==n){l.append(u("span",{class:"zx-calendar__year-blank",role:"gridcell",ariaHidden:"true"}));continue}let h=this._events.filter(p=>Ft(p,d,D(d,1))).length;l.append(u("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",dataset:{calendarAction:"date",date:H(d),dateCell:"true",activity:String(Math.min(3,h))},ariaCurrent:Ke(d,this._now())?"date":null,ariaLabel:this._dayCountLabel(d,h),disabled:this.options.disabled},String(d.getDate())))}s.append(l)}return s}_eventElement(e,t){let s=String(e.id),n=u("div",{class:"zx-calendar__event",dataset:{eventId:s,variant:t.variant,allDay:e.allDay?"true":null,draggable:this._canMove(e)?"true":null},style:e.color?{"--zx-calendar-event-color":e.color}:null}),r=u("button",{type:"button",class:"zx-calendar__event-action",dataset:{eventAction:"activate",eventId:s},ariaLabel:this._eventLabel(e),disabled:this.options.disabled}),o=typeof this.options.renderEvent=="function"?this.options.renderEvent(j(e)):null;if(o instanceof Node)r.append(o);else if(typeof o=="string")r.append(document.createTextNode(o));else{let a=u("span",{class:"zx-calendar__event-time"},this._eventTime(e,t.day)),l=u("span",{class:"zx-calendar__event-title"},e.title);r.append(a,l),e.location&&r.append(u("span",{class:"zx-calendar__event-location"},e.location))}return n.append(r),t.resizable&&this._canResize(e)&&n.append(u("button",{type:"button",class:"zx-calendar__event-resize",dataset:{eventAction:"resize",eventId:s},ariaLabel:this.msg("calendar.resize",e.title),disabled:this.options.disabled},u("span",{ariaHidden:"true"}))),n}_nowLine(e,t,s){let n=this._now(),r=e.findIndex(l=>Ke(l,n)),o=n.getHours()*60+n.getMinutes(),a=this.options.nowIndicator&&r>=0&&o>=t&&o<=s;return u("div",{ref:"nowLine",class:"zx-calendar__now",hidden:!a,ariaHidden:"true",style:a?{insetBlockStart:`${(o-t)/(s-t)*100}%`,"--zx-calendar-now-day":String(r)}:null},u("span",{class:"zx-calendar__now-time"},Cn(o,this._locale())))}_onClick(e){let t=e.target?.closest?.("button");if(!t||!this.el.contains(t))return;let s=t.dataset.eventId;if(s!=null&&this._suppressClickId===s){this._suppressClickId=null,e.preventDefault();return}if(t.dataset.eventAction==="activate"){let r=this._eventById(s);r&&this.emit("eventclick",{event:j(r),jsEvent:e});return}if(t.dataset.eventAction==="resize")return;let n=t.dataset.calendarAction;if(n){if(n==="previous")this.prev();else if(n==="next")this.next();else if(n==="today")this.today();else if(n==="view")this.setView(t.dataset.view);else if(n==="new")this.emit("new",{date:this.getDate(),view:this._view,jsEvent:e});else if(n==="week"){let r=Ne(t.dataset.date);r&&this.setDate(r).setView("week")}else if(n==="more"){let r=Ne(t.dataset.date);if(!r)return;!this.emit("moreclick",{date:r,count:Number(t.dataset.count),jsEvent:e}).defaultPrevented&&this._views.includes("agenda")&&this.setDate(r).setView("agenda")}else if(n==="date"){if(this._suppressDateClick){this._suppressDateClick=!1,e.preventDefault();return}let r=this._dateFromTarget(t);if(!r)return;this._rememberFocusedDate(t),this.emit("dateclick",{date:r,allDay:!t.dataset.dateTime,view:this._view,jsEvent:e})}}}_onDoubleClick(e){let t=e.target?.closest?.('[data-event-action="activate"]');if(t){let a=this._eventById(t.dataset.eventId);a&&this.emit("eventdblclick",{event:j(a),jsEvent:e});return}let s=e.target?.closest?.('[data-calendar-action="date"]');if(!s)return;let n=this._dateFromTarget(s);if(!n)return;let r=!s.dataset.dateTime,o=r?D(n,1):Ue(n,ue(this.options.slotDuration));this.emit("select",{start:n,end:o,allDay:r,view:this._view,jsEvent:e})}_onKeydown(e){let t=e.target?.closest?.("[data-event-action]");if(t){this._onEventKeydown(e,t);return}let s=e.target?.closest?.("[data-slot]");if(s){this._onSlotKeydown(e,s);return}let n=e.target?.closest?.("[data-date-cell]");n&&this._onDayKeydown(e,n)}_onEventKeydown(e,t){let s=this._eventById(t.dataset.eventId);if(!s)return;let n=t.dataset.eventAction==="resize";if(e.key==="Enter"&&!this._keyboardEdit&&!n){e.preventDefault(),this.emit("eventclick",{event:j(s),jsEvent:e});return}if(e.key===" "&&!this._keyboardEdit){if(n?!this._canResize(s):!this._canMove(s))return;e.preventDefault(),this._keyboardEdit={oldEvent:j(s),event:j(s),action:n?"resize":"move",control:t},t.setAttribute("aria-grabbed","true"),t.closest(".zx-calendar__event")?.setAttribute("data-state","grabbed"),this._announce(this.msg(n?"calendar.resizeStarted":"calendar.moveStarted",s.title));return}if(!this._keyboardEdit||String(this._keyboardEdit.event.id)!==String(s.id))return;if(e.key==="Escape"){e.preventDefault(),this._cancelKeyboardEdit();return}if(e.key===" "){e.preventDefault();let c=this._keyboardEdit;this._keyboardEdit=null,c.control.removeAttribute("aria-grabbed"),this._commitMutation(c.oldEvent,c.event,c.action,e);return}let r=0,o=0,a=!ge(s)&&(this._view==="day"||this._view==="week");if(e.key==="ArrowLeft")r=-1;else if(e.key==="ArrowRight")r=1;else if(e.key==="ArrowUp")a?o=-ue(this.options.slotDuration):r=-7;else if(e.key==="ArrowDown")a?o=ue(this.options.slotDuration):r=7;else return;e.preventDefault();let l=this._keyboardEdit;if(l.action==="move")l.event=Lt(l.event,{days:r,minutes:o});else{let c=D(l.event.end,r);if(c.setMinutes(c.getMinutes()+o),c<=l.event.start)return;let d=Lt(l.event,{days:0,minutes:0,endDays:r,endMinutes:o});d.end>d.start&&(l.event=d)}l.control.closest(".zx-calendar__event")?.setAttribute("data-preview",this._eventTime(l.event,l.event.start)),this._announce(this.msg("calendar.editPreview",l.event.title,this._dateTimeLabel(l.event.start),this._dateTimeLabel(l.event.end)))}_onSlotKeydown(e,t){let s=Number(t.dataset.rowIndex),n=Number(t.dataset.dayIndex),r=t.closest('[role="grid"]'),o=Number(r?.getAttribute("aria-colcount"))||1,a=Number(r?.getAttribute("aria-rowcount"))||1,l=s,c=n;if(e.key==="ArrowLeft")c-=1;else if(e.key==="ArrowRight")c+=1;else if(e.key==="ArrowUp")l-=1;else if(e.key==="ArrowDown")l+=1;else if(e.key==="Home")c=0;else if(e.key==="End")c=o-1;else if(e.key==="PageUp"){e.preventDefault(),this.prev();return}else if(e.key==="PageDown"){e.preventDefault(),this.next();return}else if(e.key==="Enter"||e.key===" "){e.preventDefault();let h=this._dateFromTarget(t);h&&this.emit("dateclick",{date:h,allDay:!1,view:this._view,jsEvent:e});return}else return;e.preventDefault(),l=Math.max(0,Math.min(a-1,l)),c=Math.max(0,Math.min(o-1,c));let d=r?.querySelector(`[data-row-index="${l}"][data-day-index="${c}"]`);d&&(t.tabIndex=-1,d.tabIndex=0,this._focusedSlot=d.dataset.slot,d.focus())}_onDayKeydown(e,t){let s=Ne(t.dataset.date);if(!s)return;let n=0;if(e.key==="ArrowLeft")n=-1;else if(e.key==="ArrowRight")n=1;else if(e.key==="ArrowUp")n=-7;else if(e.key==="ArrowDown")n=7;else if(e.key==="Home")n=-((s.getDay()-this.options.weekStart+7)%7);else if(e.key==="End")n=6-(s.getDay()-this.options.weekStart+7)%7;else if(e.key==="PageUp"){e.preventDefault(),this.prev();return}else if(e.key==="PageDown"){e.preventDefault(),this.next();return}else return;e.preventDefault();let r=D(s,n),o=this.el.querySelector(`[data-date-cell][data-date="${H(r)}"]`);o?o.focus():this.setDate(r)}_onPointerDown(e){if(this.options.disabled||e.button!==0)return;let t=e.target?.closest?.("[data-event-action]");if(t){let r=this._eventById(t.dataset.eventId),o=t.dataset.eventAction==="resize"?"resize":"move";if(!r||(o==="move"?!this._canMove(r):!this._canResize(r)))return;e.preventDefault(),this._capturePointer(e.pointerId);let a=o==="move"?this._dragOffsetForEvent(r,e.clientX,e.clientY):null;this._pointer={type:"event",pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,oldEvent:j(r),event:j(r),action:o,control:t,timeOffsetMinutes:a?.minutes??0,dayOffset:a?.days??0,moved:!1};return}let s=e.target?.closest?.("[data-slot]");if(!s||!this.options.selectable)return;let n=this._dateFromTarget(s);n&&(e.preventDefault(),this._capturePointer(e.pointerId),this._pointer={type:"selection",pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,start:n,end:Ue(n,ue(this.options.slotDuration)),control:s,moved:!1})}_onPointerMove(e){let t=this._pointer;if(!t||t.pointerId!==e.pointerId||!t.moved&&Math.hypot(e.clientX-t.startX,e.clientY-t.startY)<5)return;if(t.moved=!0,e.preventDefault(),t.type==="selection"){let r=this._timeAtPoint(e.clientX,e.clientY);if(!r)return;let o=ue(this.options.slotDuration);t.end=Ue(r,o),this._previewSelection(t.start,t.end);return}let s=this._proposalAtPoint(t.oldEvent,t.action,e.clientX,e.clientY);if(!s)return;t.event=s;let n=t.control.closest(".zx-calendar__event");if(n){if(n.dataset.state="dragging",t.action==="resize"){n.style.transform="";let r=this._timedPreviewHeight(s);r&&(n.style.blockSize=r)}else n.style.transform=`translate(${e.clientX-t.startX}px, ${e.clientY-t.startY}px)`;n.dataset.preview=this._eventTime(s,s.start)}this._announce(this.msg("calendar.editPreview",s.title,this._dateTimeLabel(s.start),this._dateTimeLabel(s.end)))}_onPointerUp(e){let t=this._pointer;if(!(!t||t.pointerId!==e.pointerId)&&(this._pointer=null,this._releasePointerCapture(t.pointerId),this._clearSelectionPreview(),!!t.moved)){if(e.preventDefault(),t.type==="selection"){this._suppressDateClick=!0;let s=t.start<t.end?t.start:Ue(t.end,-ue(this.options.slotDuration)),n=t.start<t.end?t.end:Ue(t.start,ue(this.options.slotDuration));this.emit("select",{start:new Date(s),end:new Date(n),allDay:!1,view:this._view,jsEvent:e});return}this._suppressClickId=String(t.oldEvent.id),this._commitMutation(t.oldEvent,t.event,t.action,e)}}_cancelPointer(e){if(!this._pointer||this._pointer.pointerId!==e.pointerId)return;let t=this._pointer.control;this._releasePointerCapture(this._pointer.pointerId),this._pointer=null,this._clearSelectionPreview(),t.closest?.(".zx-calendar__event")?.removeAttribute("data-state"),this._renderView({preserveFocus:!0})}_proposalAtPoint(e,t,s,n){let r=t==="resize"&&!ge(e),o=this._timeAtPoint(s,n,r?e.start:null);if(o&&!ge(e)){if(t==="move"){let f=e.end.getTime()-e.start.getTime(),m=j(e);return m.start=Ue(o,-Number(this._pointer?.timeOffsetMinutes??0)),m.end=new Date(m.start.getTime()+f),m}let p=j(e);return p.end=Ue(o,ue(this.options.slotDuration)),p.end>p.start?p:null}let a=this._dayAtPoint(s,n);if(!a)return null;let l=D(a,-Number(this._pointer?.dayOffset??0)),c=ie(V(e.start),l);if(t==="move")return Lt(e,{days:c,minutes:0});let d=j(e),h=D(a,1);return d.end=new Date(h.getTime()),d.end>d.start?d:null}_timeAtPoint(e,t,s=null){let n=this.refs.body.querySelector(".zx-calendar__slots");if(!n)return null;let r=n.getBoundingClientRect(),a=n.closest(".zx-calendar__time-scroller")?.getBoundingClientRect(),l=a?Math.max(r.left,a.left):r.left,c=a?Math.min(r.right,a.right):r.right,d=a?Math.max(r.top,a.top):r.top,h=a?Math.min(r.bottom,a.bottom):r.bottom;if(e<l||e>c||t<d||t>h||r.width<=0||r.height<=0)return null;let p=Number(n.closest('[role="grid"]')?.getAttribute("aria-colcount"))||1,f=Number(n.closest('[role="grid"]')?.getAttribute("aria-rowcount"))||1,m=s?this._timeGridDayIndex(s):-1,g=m>=0?m:Math.max(0,Math.min(p-1,Math.floor((e-r.left)/r.width*p))),_=Math.max(0,Math.min(f-1,Math.floor((t-r.top)/r.height*f))),b=n.querySelector(`[data-row-index="${_}"][data-day-index="${g}"]`);return b?this._dateFromTarget(b):null}_dayAtPoint(e,t){let s=this.refs.body.querySelector(".zx-calendar__all-day-grid");if(s){let r=s.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom){let o=s.querySelectorAll("[data-date]"),a=Math.max(0,Math.min(o.length-1,Math.floor((e-r.left)/r.width*o.length)));return Ne(o[a]?.dataset.date)}}for(let r of this.refs.body.querySelectorAll(".zx-calendar__month-events")){let o=r.getBoundingClientRect();if(e<o.left||e>o.right||t<o.top||t>o.bottom||o.width<=0)continue;let a=Ne(r.closest(".zx-calendar__month-week")?.dataset.weekStart);if(!a)continue;let l=Math.max(0,Math.min(6,Math.floor((e-o.left)/o.width*7)));return D(a,l)}for(let r of this.refs.body.querySelectorAll(".zx-calendar__agenda-day")){let o=r.getBoundingClientRect();if(!(e<o.left||e>o.right||t<o.top||t>o.bottom))return Ne(r.dataset.date)}let n=typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[];for(let r of n){let o=r instanceof HTMLElement?r.closest("[data-date]"):null,a=o instanceof HTMLElement?o.dataset.date:null;if(a)return Ne(a)}return null}_dragOffsetForEvent(e,t,s){if(!ge(e)){let o=this._timeAtPoint(t,s);if(o){let a=ue(this.options.slotDuration),l=Math.max(0,Math.round((e.end.getTime()-e.start.getTime())/6e4)),c=Math.max(0,l-a),d=Math.round((o.getTime()-e.start.getTime())/6e4);return{minutes:Math.max(0,Math.min(c,d)),days:0}}}let n=this._dayAtPoint(t,s),r=n?ie(V(e.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(e){let t=H(e);return[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")].findIndex(n=>n.dataset.date===t)}_timedPreviewHeight(e){if(!this.refs.body.querySelector(".zx-calendar__time-grid")||ge(e))return null;let s=Ce(this.options.slotMinTime,0),n=Ce(this.options.slotMaxTime,1440,!0),r=ue(this.options.slotDuration),o=e.start.getHours()*60+e.start.getMinutes(),a=e.end.getHours()*60+e.end.getMinutes();return`${Math.max(r,Math.min(n,a)-Math.max(s,o))/(n-s)*100}%`}_capturePointer(e){try{this.el.setPointerCapture?.(e)}catch{}}_releasePointerCapture(e){this.el.hasPointerCapture?.(e)&&this.el.releasePointerCapture?.(e)}_previewSelection(e,t){let s=Math.min(e.getTime(),t.getTime()),n=Math.max(e.getTime(),t.getTime());for(let r of this.refs.body.querySelectorAll("[data-slot]")){let o=Number(r.dataset.dateTime);r.setAttribute("aria-selected",String(o>=s&&o<n))}}_clearSelectionPreview(){for(let e of this.refs.body.querySelectorAll("[data-slot][aria-selected]"))e.removeAttribute("aria-selected")}_cancelKeyboardEdit(){let e=this._keyboardEdit;e&&(e.control.removeAttribute("aria-grabbed"),e.control.closest(".zx-calendar__event")?.removeAttribute("data-state"),this._keyboardEdit=null,this._announce(this.msg("calendar.editCancelled")),this._renderView({preserveFocus:!0}))}_commitMutation(e,t,s,n){if(!(e.start.getTime()!==t.start.getTime()||e.end.getTime()!==t.end.getTime())){this._renderView({preserveFocus:!0});return}let o=String(e.id),a=++this._mutationSerial,l=!1;this.options.optimistic?(this._replaceNormalizedEvent(t),this._mutationVersions.set(o,a),this._renderView({preserveFocus:!0})):this._renderView({preserveFocus:!0});let c=()=>{if(l||!this.options.optimistic||this._mutationVersions.get(o)!==a)return!1;let p=this._eventById(o);return!p||p.start.getTime()!==t.start.getTime()||p.end.getTime()!==t.end.getTime()?!1:(l=!0,this._replaceNormalizedEvent(e),this._mutationVersions.delete(o),this._renderView({preserveFocus:!0}),this._announce(this.msg("calendar.editCancelled")),!0)},d={event:j(t),oldEvent:j(e),action:s,delta:ep(e,t),jsEvent:n,revert:c};this.emit("eventchange",d).defaultPrevented?c():this._announce(this.msg("calendar.editCommitted",t.title))}_replaceNormalizedEvent(e){let t=String(e.id);this._events=this._events.map(s=>String(s.id)===t?j(e):s)}_canMove(e){return this.options.disabled?!1:e.editable!=null?e.editable:this.options.eventStartEditable!=null?!!this.options.eventStartEditable:!!this.options.editable}_canResize(e){return this.options.disabled?!1:e.durationEditable!=null?e.durationEditable:this.options.eventDurationEditable!=null?!!this.options.eventDurationEditable:!!this.options.editable}_eventById(e){let t=this._eventIndex(e);return t<0?null:this._events[t]}_eventIndex(e){let t=String(e);return this._events.findIndex(s=>String(s.id)===t)}_page(e){return this.setDate(Sn(this._view,this._date,e,{agendaDays:this.options.agendaDays}))}_rangeTitle(e){if(this._view==="day")return this._format(e.start,{weekday:"long",day:"numeric",month:"long",year:"numeric"});if(this._view==="month")return this._format(this._date,{month:"long",year:"numeric"});if(this._view==="year")return this._format(this._date,{year:"numeric"});let t=D(e.end,-1),s=new Intl.DateTimeFormat(this._locale(),{day:"numeric",month:"long",year:"numeric"});return typeof s.formatRange=="function"?s.formatRange(e.start,t):e.start.getFullYear()!==t.getFullYear()?`${this._format(e.start,{day:"numeric",month:"short",year:"numeric"})} \u2013 ${this._format(t,{day:"numeric",month:"short",year:"numeric"})}`:e.start.getMonth()!==t.getMonth()?`${this._format(e.start,{day:"numeric",month:"short"})} \u2013 ${this._format(t,{day:"numeric",month:"short",year:"numeric"})}`:`${this._format(e.start,{day:"numeric"})}\u2013${this._format(t,{day:"numeric",month:"long",year:"numeric"})}`}_eventTime(e,t){if(e.allDay)return this.msg("calendar.allDay");if(ge(e))return Ke(e.start,t)?`${Pt(e.start,this._locale())} \u2192`:Ke(e.end,t)?`\u2192 ${Pt(e.end,this._locale())}`:this.msg("calendar.allDay");let s=zn(e.start,this._locale());return e.end<=e.start?s:`${s}\u2013${zn(e.end,this._locale())}`}_eventLabel(e){let t=e.location?`, ${e.location}`:"";return`${this.msg("calendar.eventLabel",e.title,Pt(e.start,this._locale()),Pt(e.end,this._locale()))}${t}`}_dateTimeLabel(e){return Pt(e,this._locale())}_locale(){return Wa(this.options.locale)}_format(e,t){return new Intl.DateTimeFormat(this._locale(),t).format(e)}_now(){let e=typeof this.options.now=="function"?this.options.now():this.options.now,t=e??new Date;if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new TypeError("Calendar now must return a valid Date");return new Date(t.getTime())}_dateFromTarget(e){if(e.dataset.dateTime){let t=new Date(Number(e.dataset.dateTime));return Number.isNaN(t.getTime())?null:t}return Ne(e.dataset.date)}_rememberFocusedDate(e){e.dataset.slot&&(this._focusedSlot=e.dataset.slot)}_focusIdentity(){let e=document.activeElement;return!(e instanceof HTMLElement)||!this.el.contains(e)?null:{eventId:e.dataset.eventId,eventAction:e.dataset.eventAction,date:e.dataset.date,slot:e.dataset.slot,row:e.dataset.rowIndex,column:e.dataset.dayIndex}}_restoreFocus(e){let t=null;if(e.eventId&&(t=this.el.querySelector(`[data-event-id="${Tn(e.eventId)}"][data-event-action="${e.eventAction??"activate"}"]`)),!t&&e.slot){let s=[...this.el.querySelectorAll("[data-slot]:not(:disabled)")];if(t=s.find(n=>n.dataset.slot===e.slot)??null,!t){let n=Number(e.row)||0,r=Number(e.column)||0;t=s.sort((o,a)=>Math.abs(Number(o.dataset.rowIndex)-n)-Math.abs(Number(a.dataset.rowIndex)-n)||Math.abs(Number(o.dataset.dayIndex)-r)-Math.abs(Number(a.dataset.dayIndex)-r))[0]??null}if(t){for(let n of s)n.tabIndex=n===t?0:-1;this._focusedSlot=t.dataset.slot}}!t&&e.date&&(t=this.el.querySelector(`[data-date-cell][data-date="${Tn(e.date)}"]`)),t?.focus?.()}_scrollTimeGrid(){let e=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!e)return;let t=Ce(this.options.slotMinTime,0),s=Ce(this.options.slotMaxTime,1440,!0),n=Ce(this.options.scrollTime,480,!0),r=Math.max(0,Math.min(1,(n-t)/(s-t)));requestAnimationFrame(()=>{e.isConnected&&(e.scrollTop=Math.max(0,r*e.scrollHeight-e.clientHeight/4))})}_refreshNowIndicator(){if(this._destroyed||!this.options.nowIndicator||!["day","week"].includes(this._view))return;let e=this.refs.body.querySelector(".zx-calendar__now"),t=[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")];if(!e||!t.length)return;let s=this._now(),n=t.findIndex(c=>c.dataset.date===H(s)),r=Ce(this.options.slotMinTime,0),o=Ce(this.options.slotMaxTime,1440,!0),a=s.getHours()*60+s.getMinutes(),l=n>=0&&a>=r&&a<=o;e.hidden=!l,l&&(e.style.insetBlockStart=`${(a-r)/(o-r)*100}%`,e.style.setProperty("--zx-calendar-now-day",String(n)),e.querySelector(".zx-calendar__now-time").textContent=Cn(a,this._locale()))}_announce(e){this.refs.status.textContent="",requestAnimationFrame(()=>{this._destroyed||(this.refs.status.textContent=e)})}_dayCountLabel(e,t){let s=this._format(e,{dateStyle:"full"});return t===1?this._message("calendar.dayEvent","%1, %2 event",s,t):this._message("calendar.dayEvents","%1, %2 events",s,t)}_message(e,t,...s){let n=this.msg(e,...s);return n===e?F(t,s):n}};function Gf(i){if(!Array.isArray(i)||i.length===0)throw new TypeError("Calendar views must be a non-empty array");let e=[...new Set(i.map(String))];for(let t of e)if(!is.includes(t))throw new RangeError(`Unknown Calendar view: ${t}`);return e}function bl(i,e,t){if(i==null)return t;if(i instanceof Date){if(Number.isNaN(i.getTime()))throw new TypeError("Calendar date must be valid");return new Date(i.getTime())}let s=typeof i=="number"?i:typeof i=="string"&&/^-?\d+(?:\.\d+)?$/.test(i.trim())?Number(i):null,n=s==null?new Date(i):new Date(s*(e==="seconds"?1e3:1));if(Number.isNaN(n.getTime()))throw new TypeError("Calendar date must be valid");return n}function ue(i){let e=Number(i);if(!Number.isInteger(e)||e<=0||e>720||1440%e!==0)throw new RangeError("Calendar slotDuration must be a positive divisor of 1440");return e}function Qf(i){let e=Number(i);if(!Number.isInteger(e)||e<1||e>20)throw new RangeError("Calendar eventLimit must be an integer from 1 through 20");return e}function Ce(i,e,t=!1){let s=Number(i??e),n=t?1440:1439;if(!Number.isInteger(s)||s<0||s>n)throw new RangeError(`Calendar minute must be from 0 through ${n}`);return s}function Jf(i,e){let t=V(i);return t.setMinutes(e),t}function Ue(i,e){let t=new Date(i.getTime());return t.setMinutes(t.getMinutes()+e),t}function yl(i){return`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`}function Ke(i,e){return yl(i)===yl(e)}function Ne(i){let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(i??""));if(!e)return null;let t=new Date(Number(e[1]),Number(e[2])-1,Number(e[3]));return H(t)===i?t:null}function Xf(i,e){return i.start-e.start||e.end-i.end||i.title.localeCompare(e.title)}function Cn(i,e){let t=new Date(2026,0,1);return t.setHours(Math.floor(i/60)%24,i%60,0,0),zn(t,e)}function zn(i,e){return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(i)}function Pt(i,e){return new Intl.DateTimeFormat(e,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(i)}function wl(i){let e=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let s=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e-s)/864e5+1)/7)}function ep(i,e){let t=e.start.getTime()-i.start.getTime();return{milliseconds:t,days:ie(V(i.start),V(e.start)),minutes:Math.round(t/6e4),endMilliseconds:e.end.getTime()-i.end.getTime()}}function Tn(i){return globalThis.CSS?.escape?CSS.escape(i):i.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}var jt=class extends S{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,idPrefix:null,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let e=this.el??u("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):E("zx-form"),this._novalidateAttribute=e.getAttribute("novalidate"),e.toggleAttribute("novalidate",!!this.options.novalidate),this._body=u("div",{class:"zx-form__body"}),this._actions=u("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),e.append(this._body,this._actions),this.listen(e,"submit",s=>{s.preventDefault(),this.submit()}),this.listen(e,"reset",s=>{s.preventDefault(),this.reset()}),this.listen(this._actions,"click",s=>this._handleAction(s));let t=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let s of t)this.addFieldset(s);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),e}addFieldset(e){let t=!(e instanceof Nt),s=t?new Nt(null,{...e??{},idPrefix:e?.idPrefix??this._idPrefix}):e;return this._fieldsets.includes(s)||(t?this._ownedFieldsets.add(s):this._origins.set(s,{parent:s.el.parentNode,next:s.el.nextSibling}),this._fieldsets.push(s),this._body.append(s.el),this.listen(s.el,"zx-change",n=>{let r=n.target,o=r instanceof Element?r.dataset.fieldId:null;o&&this.emit("change",{id:o,value:s.getValue(o)})})),s}setActions(e){return this._actionDescriptors=Array.isArray(e)?e.map(t=>({...t})):[],this._actions.replaceChildren(...this._actionDescriptors.map((t,s)=>{let n=String(t.label??t.id??this.msg("form.action"));return u("button",{class:"zx-btn",type:["submit","reset"].includes(t.type)?t.type:"button",disabled:!!t.disabled,title:t.title,ariaLabel:!n&&t.title?t.title:void 0,dataset:{actionIndex:s,kind:["primary","danger","ghost"].includes(t.kind)?t.kind:"default",size:t.size==="sm"?"sm":"md"}},t.icon?v(t.icon,{size:16}):null,n?u("span",{class:"zx-btn__label"},n):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(e=>e.getValues()))}setValues(e,{silent:t=!1}={}){for(let s of this._fieldsets)s.setValues(e,{silent:t});return this}getField(e){for(let t of this._fieldsets){let s=t.getField(e);if(s)return s}return null}setValue(e,t){return this.getField(e)?.setValue(t),this}getValue(e){return this.getField(e)?.getValue()??null}reset(){for(let e of this._fieldsets)e.reset().clearHighlights();return this}setHighlights(e,t="danger"){return this._fieldsets.reduce((s,n)=>s+n.setHighlights(e,t),0)}clearHighlights(){for(let e of this._fieldsets)e.clearHighlights();return this}submit(){let e={},t=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let a=o.getValue(),l="";if(o.options.required&&En(a))l=this.msg("form.required");else if(!En(a)&&o.options.type==="int"){let c=Es(a);c.valid?o.setValue(c.value,{silent:!0}):l=this.msg("form.int")}else if(!En(a)&&o.options.type==="float"){let c=Is(a);c.valid?o.setValue(c.value,{silent:!0}):l=this.msg("form.float")}l?(e[r]=l,o.setHighlight(l,"danger"),t??=o):o.clearHighlight()}return Object.keys(e).length?(this.emit("invalid",{errors:e}),t?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(e){let t=e.target instanceof Element?e.target.closest("[data-action-index]"):null;if(!t||!this._actions.contains(t))return;let s=this._actionDescriptors[Number(t.dataset.actionIndex)],n=s?.onClick??s?.onclick??s?.handler;typeof n=="function"&&n(e,this)}destroy(){for(let e of this._fieldsets??[])if(this._ownedFieldsets.has(e))e.destroy();else{let t=this._origins.get(e);t?.parent?t.parent.insertBefore(e.el,t.next?.parentNode===t.parent?t.next:null):e.el.remove()}this._fieldsets=[];for(let e of this._ownedNodes??[])e.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function En(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}function tp(){aa(),Or(),Lr(),To(),co(),xo(),pa(),_a(),Ro(),Mo(),ma(),Vo(),jo(),da(),la()}tp();function _e(i,{onError:e,locale:t}={}){if(!i||typeof i!="object"||!i.api||typeof i.api!="object")throw new TypeError("connect() requires a ZeyOS client with an api namespace");if(e!=null&&typeof e!="function")throw new TypeError("onError must be a function");let s=t??ip(i);s&&_s(String(s));let n=(o,a)=>e?e(o,a):De.error(Mn(o)),r=async(o,a,l)=>{let c=sp(i,o,a);try{return await i.api[c](l)}catch(d){try{n(d,{operation:c,resource:a})}catch{}throw d}};return{client:i,list:(o,a={})=>r("list",o,a),get:(o,a,l={})=>r("get",o,vl(a)?a:{ID:a,...l}),create:(o,a)=>r("create",o,a),update:(o,a,l)=>r("update",o,l===void 0&&vl(a)?a:{ID:a,body:l??{}}),reportError:n}}function ip(i){return i.locale??i.language??i.config?.locale??i.metadata?.locale??null}function sp(i,e,t){let s=String(t??"").trim();if(!s)throw new TypeError("ZeyOS resource must not be empty");let n=typeof i.schema?.operations=="function"?i.schema.operations(s):[];if(Array.isArray(n)&&n.length){let p=n.filter(f=>typeof f=="string"&&f.toLowerCase().startsWith(e)).sort((f,m)=>f.length-m.length);if(p.length)return p[0]}let r=Array.isArray(n)&&n.length?n:typeof i.schema?.operationIds=="function"?i.schema.operationIds():Object.keys(i.api);if(r.includes(s)&&s.toLowerCase().startsWith(e))return s;let o=xl(s),a=Sl(o),l=r.filter(p=>{if(typeof p!="string"||!p.toLowerCase().startsWith(e))return!1;let f=xl(p.slice(e.length));return f===o||f===a||Sl(f)===a});if(l.length)return l.sort((p,f)=>p.length-f.length)[0];let c=e==="list"?[`list${In(s)}`]:[`${e}${In(np(s))}`,`${e}${In(s)}`],d=new Set(Object.keys(i.api)),h=c.find(p=>d.has(p));if(h)return h;throw new RangeError(`No ${e} operation found for ZeyOS resource "${s}"`)}function vl(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function Mn(i){return i instanceof Error&&i.message||i&&typeof i=="object"&&typeof i.message=="string"?i.message:String(i??"ZeyOS request failed")}function xl(i){return String(i).replace(/[^a-z\d]/gi,"").toLowerCase()}function Sl(i){return i.endsWith("ies")?`${i.slice(0,-3)}y`:i.endsWith("sses")?i.slice(0,-2):i.endsWith("s")&&!i.endsWith("ss")?i.slice(0,-1):i}function np(i){let e=String(i);return/ies$/i.test(e)?`${e.slice(0,-3)}y`:/s$/i.test(e)&&!/ss$/i.test(e)?e.slice(0,-1):e}function In(i){return String(i).split(/[^a-z\d]+/i).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}var Ye=Object.freeze({accounts:{label:"Accounts",icon:"zeyos-accounts",color:"#bc3885",fa:"building"},actionsteps:{label:"Action Steps",icon:"zeyos-actionsteps",color:"#f67f00",fa:"clock"},appointments:{label:"Appointments",icon:"zeyos-appointments",color:"#bd1e32",fa:"calendar-check"},billing:{label:"Billing",icon:"zeyos-billing",color:"#535494",fa:"file-invoice-dollar"},calendar:{label:"Calendar",icon:"zeyos-calendar",color:"#bd1e32",fa:"calendar-days"},campaigns:{label:"Campaigns",icon:"zeyos-campaigns",color:"#f16528",fa:"bullhorn"},collection:{label:"Collection",icon:"zeyos-collection",color:"#0d60ae",fa:"hand-holding-dollar"},contacts:{label:"Contacts",icon:"zeyos-contacts",color:"#8c6641",fa:"address-book"},contracts:{label:"Contracts",icon:"zeyos-contracts",color:"#823e89",fa:"file-contract"},coupons:{label:"Coupons",icon:"zeyos-coupons",color:"#10775c",fa:"ticket-simple"},devices:{label:"Devices",icon:"zeyos-devices",color:"#064e4f",fa:"desktop"},documents:{label:"Documents",icon:"zeyos-documents",color:"#808000",fa:"file"},dunning:{label:"Dunning",icon:"zeyos-dunning",color:"#0d60ae",fa:"file-invoice-dollar"},events:{label:"Events",icon:"zeyos-events",color:"#bd1e32",fa:"calendar-day"},inventory:{label:"Inventory",icon:"zeyos-inventory",color:"#064e4f",fa:"warehouse"},items:{label:"Items",icon:"zeyos-items",color:"#064e4f",fa:"box-open"},ledgers:{label:"Ledgers",icon:"zeyos-ledgers",color:"#4679c8",fa:"book-open"},line:{label:"Line Items",icon:"zeyos-line",color:"#064e4f",fa:"list-ul"},links:{label:"Links",icon:"zeyos-links",color:"#405e76",fa:"bookmark"},mailinglists:{label:"Mailing Lists",icon:"zeyos-mailinglists",color:"#0299ac",fa:"envelope-open-text"},messages:{label:"Messages",icon:"zeyos-messages",color:"#31a8e0",fa:"message"},"messages-unread":{label:"Unread Messages",icon:"zeyos-messages-unread",color:"#31a8e0",fa:"envelope"},notes:{label:"Notes",icon:"zeyos-notes",color:"#008853",fa:"note-sticky"},opportunities:{label:"Opportunities",icon:"zeyos-opportunities",color:"#7b67ae",fa:"handshake"},payments:{label:"Payments",icon:"zeyos-payments",color:"#4679c8",fa:"sack-dollar"},pricelists:{label:"Price Lists",icon:"zeyos-pricelists",color:"#10775c",fa:"clipboard-list"},procurement:{label:"Procurement",icon:"zeyos-procurement",color:"#006e9f",fa:"truck"},production:{label:"Production",icon:"zeyos-production",color:"#226375",fa:"industry"},projects:{label:"Projects",icon:"zeyos-projects",color:"#db532d",fa:"diagram-project"},stocktransactions:{label:"Stock Transactions",icon:"zeyos-stocktransactions",color:"#064e4f",fa:"arrow-right-arrow-left"},storages:{label:"Storages",icon:"zeyos-storages",color:"#064e4f",fa:"boxes-stacked"},tasks:{label:"Tasks",icon:"zeyos-tasks",color:"#e2b301",fa:"list-check"},text:{label:"Text Blocks",icon:"zeyos-text",color:"#064e4f",fa:"file-lines"},tickets:{label:"Tickets",icon:"zeyos-tickets",color:"#f04639",fa:"ticket"},"transactions-billing":{label:"Billing Transactions",icon:"zeyos-transactions-billing",color:"#535494",fa:"file-invoice"},"transactions-collection":{label:"Collection Transactions",icon:"zeyos-transactions-collection",color:"#0d60ae",fa:"money-bill-transfer"},"transactions-procurement":{label:"Procurement Transactions",icon:"zeyos-transactions-procurement",color:"#006e9f",fa:"cart-shopping"},"transactions-production":{label:"Production Transactions",icon:"zeyos-transactions-production",color:"#226375",fa:"gears"},zeyos:{label:"ZeyOS",icon:"zeyos",color:"#007a55",fa:"cloud"},default:{label:"Default",icon:"zeyos-default",color:"#21cc75",fa:"cube"},admin:{label:"Administration",icon:"zeyos-admin",color:"#4b5563",fa:"screwdriver-wrench"},applications:{label:"Applications",icon:"zeyos-applications",color:"#2563eb",fa:"window-maximize"},auth:{label:"Credentials",icon:"zeyos-auth",color:"#a16207",fa:"shield-halved"},categories:{label:"Categories",icon:"zeyos-categories",color:"#9a3412",fa:"folder-tree"},channels:{label:"Channels",icon:"zeyos-channels",color:"#0891b2",fa:"share-nodes"},control:{label:"Control Center",icon:"zeyos-control",color:"#0f766e",fa:"sliders"},davservers:{label:"DAV Servers",icon:"zeyos-davservers",color:"#475569",fa:"server"},dev:{label:"Development",icon:"zeyos-dev",color:"#1f2937",fa:"code"},error:{label:"Errors",icon:"zeyos-error",color:"#b91c1c",fa:"triangle-exclamation"},global:{label:"Global",icon:"zeyos-global",color:"#0369a1",fa:"globe"},groups:{label:"Groups",icon:"zeyos-groups",color:"#007a55",fa:"users"},logout:{label:"Logout",icon:"zeyos-logout",color:"#9f1239",fa:"right-from-bracket"},objects:{label:"Custom Objects",icon:"zeyos-objects",color:"#7e22ce",fa:"cubes"},participants:{label:"Participants",icon:"zeyos-participants",color:"#4338ca",fa:"user-group"},permissions:{label:"Permissions",icon:"zeyos-permissions",color:"#5b21b6",fa:"user-lock"},records:{label:"Records",icon:"zeyos-records",color:"#57534e",fa:"database"},resources:{label:"Resources",icon:"zeyos-resources",color:"#15803d",fa:"layer-group"},services:{label:"Services",icon:"zeyos-services",color:"#b45309",fa:"bell-concierge"},system:{label:"System",icon:"zeyos-system",color:"#374151",fa:"gear"},users:{label:"Users",icon:"zeyos-users",color:"#007a55",fa:"user"},weblets:{label:"Weblets",icon:"zeyos-weblets",color:"#4f46e5",fa:"window-restore"}}),kl=Object.freeze({main:"zeyos",addresses:"contacts",clocking:"actionsteps",comments:"notes",couponcodes:"coupons",customers:"accounts",customfields:"objects",davids:"davservers",documentversions:"documents",enhancements:"applications",extdata:"objects",feedservers:"channels",files:"documents",filters:"records",forks:"applications",imports:"records",invoices:"transactions-billing",linecoupon:"line",logins:"auth",mailservers:"channels",notifications:"messages","participants-campaigns":"participants","participants-mailinglists":"participants",prices:"pricelists",pwd:"auth",purchaseorders:"transactions-procurement",sessions:"auth",settings:"system",suppliers:"accounts",tags:"categories",tokens:"auth",transactions:"transactions-billing",usergroups:"groups",usermgmt:"users",usersettings:"system",userfields:"objects",userfilters:"records"}),Bt=Object.freeze({light:"#ffffff",dark:"#141414"}),qt=Object.create(null);function rs(i){let e=String(i??"").trim().toLowerCase().replaceAll(/[._\s]+/g,"-");if(!e)return"default";if(Object.hasOwn(qt,e)||Object.hasOwn(Ye,e))return e;let t=kl[e];return t||"default"}function re(i){let e=rs(i);return qt[e]??Ye[e]??Ye.default}function rp(i){return re(i).color}function op(i,{standard:e=!1}={}){let t=re(i);return e?t.fa:t.icon}function ap(){return[...new Set([...Object.keys(Ye),...Object.keys(qt)])].sort()}function lp(i){for(let[e,t]of Object.entries(i)){let s=String(e).trim().toLowerCase().replaceAll(/[._\s]+/g,"-"),n=typeof t=="string"?{color:t}:t,r=qt[s]??Ye[s]??Ye.default;qt[s]=Object.freeze({label:n.label??r.label,icon:n.icon??r.icon,color:n.color??r.color,fa:n.fa??r.fa})}}function cp(i){let e=Dn(i);if(e===null)return Bt.light;let t=Al(e,Dn(Bt.light)??1),s=Al(e,Dn(Bt.dark)??0);return t>=s?Bt.light:Bt.dark}function Dn(i){let e=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(String(i).trim());if(!e)return null;let t=e[1].length===3?[...e[1]].map(o=>o+o).join(""):e[1],[s,n,r]=[0,2,4].map(o=>{let a=Number.parseInt(t.slice(o,o+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4});return .2126*s+.7152*n+.0722*r}function Al(i,e){return(Math.max(i,e)+.05)/(Math.min(i,e)+.05)}var Cl="https://kit.fontawesome.com/ae8320b210.js";function up(i={}){return Ps({kit:Cl,...i})}function os(i,e={}){let{standard:t=!1,...s}=e,n=re(i);return v(t?`fa:${n.fa}`:`kit:${n.icon}`,s)}function ht(i,e={}){let{size:t=24,iconSize:s="52%",label:n=null,title:r=!1,standard:o=!1,color:a=null,badge:l=null,selected:c=!1}=e,d=rs(i),h=re(i),p=ze(a)?a:h.color,f=Zi({icon:e.icon??os(i,{size:"1em",standard:o}),size:t,iconSize:s,color:p,label:n,badge:l,selected:c,shape:e.shape??"tile",glass:e.glass??"subtle",class:["zx-module-icon",e.class].flat().filter(Boolean)});return f.dataset.module=d,f.style.setProperty("--zx-module-color",p),f.style.setProperty("--zx-module-glyph","var(--zx-color-app-icon-glyph)"),f.style.setProperty("--zx-app-icon-glyph","var(--zx-color-app-icon-glyph)"),r&&(f.title=h.label),f}function Nn(i,e={}){return ht(i,{shape:"circle",...e})}var dp=Object.freeze(["accounts","actionsteps","admin","auth","billing","calendar","campaigns","collection","contacts","contracts","control","coupons","dev","documents","inventory","mailinglists","main","messages","links","notes","objects","opportunities","payments","pricelists","procurement","production","projects","tasks","tickets"]);function Tl(i={},e={}){let{standardIcons:t=!1,items:s=[],sources:n=[],...r}=e,o=Ln(i.labels),a={standardIcons:t,renderApplicationIcon:i.renderApplicationIcon,renderWebletIcon:i.renderWebletIcon},l=zl(i,a),c=typeof i.loadRecent=="function"?[]:as(i.recent??[],{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:t}),d=[];return typeof i.loadRecent=="function"&&d.push({id:"zeyos-recent",minQuery:0,when:"empty",order:"source",load:async(h,p)=>as(await i.loadRecent(p),{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:t})}),typeof i.search=="function"&&d.push({id:"zeyos-records",minQuery:1,when:"query",order:"source",load:async(h,p)=>as(await i.search(h,p),{query:h,labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:t})}),d.push(...n),{...r,items:[...l,...c,...s],sources:d,hints:e.hints??{move:o.move,open:o.open,close:o.close}}}function hp(i={},e={}){return new Wi(null,Tl(i,e))}function zl(i={},e={}){let t=Ln(i.labels),s=Array.isArray(i.pinned)?i.pinned.map(String):[],n=new Set,r=[],o=(a,l=null,c=null)=>{let d=Rn(a,l,c);if(!d||n.has(d.identifier)||d.type==="module"&&typeof i.canUseModule=="function"&&!i.canUseModule(d.module))return;n.add(d.identifier);let h=ls(d.raw,i.resolveApplication),p=s.indexOf(d.identifier),f=()=>(typeof e.renderApplicationIcon=="function"?e.renderApplicationIcon(d.raw,d):d.type==="weblet"&&typeof e.renderWebletIcon=="function"?e.renderWebletIcon(d.raw,d):null)??Nn(d.module,{size:36,standard:!!e.standardIcons,color:d.color});r.push({id:d.identifier,label:d.label,keywords:[d.identifier,d.module],group:t.applications,groupOrder:0,kind:"application",icon:f,pinned:p>=0?p:void 0,current:d.identifier===i.activeIdentifier,disabled:!h.href&&typeof h.invoke!="function",...h,_zeyos:d})};for(let a of Array.isArray(i.menuApps)?i.menuApps:[])o(a);if(Array.isArray(i.modules))for(let a of i.modules)typeof a=="string"?o([a,re(a).label]):o(a,a?.id??a?.module,a?.label);else for(let[a,l]of Object.entries(i.modules??{}))o([a,l]);return r}function as(i,e={}){let t=String(e.query??""),s=Ln(e.labels),n=pp(i,t),r=new Map;return n.flatMap(({raw:o,group:a},l)=>{let c=mp(o,a,t);if(!c)return[];let d=t===""?s.recent:c.group===""?s.results:s.entities[c.group]??c.group;r.has(d)||r.set(d,r.size+1);let h=ls(c.raw,e.resolveRecord);return[{id:`record:${c.entity}:${c.fork??""}:${c.ID}`,label:c.name,description:c.sec,keywords:[c.entity,c.ID,c.fork??""],group:d,groupOrder:r.get(d),itemOrder:l,kind:"record",when:t===""?"empty":"query",icon:()=>(typeof e.renderRecordIcon=="function"?e.renderRecordIcon(c.raw,c):null)??ht(c.entity,{size:28,standard:!!e.standardIcons}),disabled:!h.href&&typeof h.invoke!="function",...h,_zeyos:c}]})}function fp(i={}){return i.weblet!=null&&i.weblet!==""?`weblet#${i.weblet}`:i.fork!=null&&i.fork!==""?`fork#${i.fork}`:String(i.module??"")}function Rn(i,e,t){if(Array.isArray(i)){if(i.length<2)return null;if(i.length===2){let r=String(i[0]);return{raw:i,identifier:r,label:String(i[1]),module:r,type:"module",color:null}}if(i.length===4){let r=String(i[2]||"default");return{raw:i,identifier:`fork#${i[0]}`,label:String(i[1]),module:r,type:"fork",color:On(i[3])}}return{raw:i,identifier:`weblet#${i[0]}`,label:String(i[1]),module:"weblets",type:"weblet",color:On(i[8])}}if(!i||typeof i!="object")return null;let s=String(i.identifier??i.id??e??"");if(!s)return null;let n=s.startsWith("fork#")?"fork":s.startsWith("weblet#")?"weblet":"module";return{raw:i,identifier:s,label:String(i.label??t??re(s).label),module:String(i.module??(n==="module"?s:n==="fork"?"default":"weblets")),type:n,color:On(i.color)}}function pp(i,e){if(Array.isArray(i))return i.map(s=>({raw:s,group:s?.group??""}));if(!i||typeof i!="object")return[];let t=[];for(let[s,n]of Object.entries(i))if(Array.isArray(n))for(let r of n){if(!Array.isArray(r)){t.push({raw:r,group:s});continue}let o=s===""&&r.length>=5?{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:r[4],group:s}:{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:s,group:s};t.push({raw:o,group:s})}return t}function mp(i,e,t){return Array.isArray(i)?t===""&&i.length>=4?{raw:i,entity:String(i[0]),ID:i[1],fork:i[2]??null,name:String(i[3]),sec:String(i[4]??""),group:""}:null:!i||typeof i!="object"||i.ID==null||i.name==null?null:{raw:i,entity:String(i.entity??e??"records"),ID:i.ID,fork:i.fork??null,name:String(i.name),sec:String(i.sec??""),group:String(i.group??e??"")}}function ls(i,e){let t=i&&typeof i=="object"&&!Array.isArray(i)?i:{},s=typeof e=="function"?e(i):null,n=s&&typeof s=="object"?s:{};return Object.fromEntries(["href","target","invoke","value"].flatMap(r=>{let o=n[r]??t[r];return o===void 0?[]:[[r,o]]}))}function On(i){let e=String(i??"").trim();if(!e)return null;let t=e.startsWith("#")?e:`#${e}`;return/^#[\da-f]{3}(?:[\da-f]{3})?$/i.test(t)?t:null}function Ln(i){let e=i&&typeof i=="object"?i:{};return{applications:String(e.applications??R("zeyosLauncher.applications")),recent:String(e.recent??R("zeyosLauncher.recent")),results:String(e.results??R("zeyosLauncher.results")),entities:e.entities&&typeof e.entities=="object"?e.entities:{},move:String(e.move??R("zeyosLauncher.move")),open:String(e.open??R("zeyosLauncher.open")),close:String(e.close??R("zeyosLauncher.close"))}}function Fn(i={},e={}){let t=Array.isArray(i.pinned)?i.pinned.map(String):null,s=i.menus&&typeof i.menus=="object"?i.menus:{},n=i.badges&&typeof i.badges=="object"?i.badges:{},r=i.groups&&typeof i.groups=="object"?i.groups:{},o={forks:R("zeyosModuleBar.forks"),weblets:R("zeyosModuleBar.weblets"),...i.labels??{}},a=new Set,l=[],c=(d,h=null,p=null)=>{let f=Rn(d,h,p);if(!f||a.has(f.identifier)||f.type==="module"&&typeof i.canUseModule=="function"&&!i.canUseModule(f.module))return;a.add(f.identifier);let m=Il(s[f.identifier],n),g=m.length?{}:ls(f.raw,i.resolveApplication),_=t?t.indexOf(f.identifier):-1,b=r[f.identifier]??(f.type==="fork"?o.forks:f.type==="weblet"?o.weblets:void 0);l.push({id:f.identifier,label:f.label,icon:()=>(typeof i.renderApplicationIcon=="function"?i.renderApplicationIcon(f.raw,f):null)??os(f.module,{size:"1em",standard:!!e.standardIcons}),color:f.color??re(f.module).color,module:f.module,...b?{group:b}:{},...n[f.identifier]!=null?{badge:n[f.identifier]}:{},...t?{pinned:_>=0?_:!1}:{},...m.length?{children:m}:g})};for(let d of Array.isArray(i.menuApps)?i.menuApps:[])c(d);if(Array.isArray(i.modules))for(let d of i.modules)typeof d=="string"?c([d,re(d).label]):c(d,d?.id??d?.module,d?.label);else for(let[d,h]of Object.entries(i.modules??{}))c([d,h]);return He(l)}function El(i={},e={}){let{standardIcons:t=!1,appearance:s="solid",...n}=e;return{...n,items:Fn(i,{standardIcons:t}),active:i.active??i.activeIdentifier??null,appearance:s}}function gp(i={},e={}){let{standardIcons:t=!1,appearance:s="solid",moduleBar:n={},...r}=e;return{label:"ZeyOS",...r,layout:"modules",items:Fn(i,{standardIcons:t}),active:i.active??i.activeIdentifier??null,moduleBar:{appearance:s,...n}}}function _p(i,e={},t={}){return new Xi(i,El(e,t))}function Il(i,e){return Array.isArray(i)?i.flatMap(t=>{if(Array.isArray(t)){let[o,a,l]=t;return o==null||a==null?[]:[{id:o,label:String(a),...l!=null?{href:String(l)}:{},...e[String(o)]!=null?{badge:e[String(o)]}:{}}]}if(!t||typeof t!="object"||t.label==null)return[];let s=Il(t.children,e);if(t.section===!0)return s.length?[{...t.id!=null?{id:t.id}:{},section:!0,label:String(t.label),children:s}]:[];if(t.id==null)return[];let n=Object.fromEntries(["id","href","target","invoke","icon","value","disabled"].filter(o=>t[o]!==void 0).map(o=>[o,t[o]])),r=e[String(t.id)]??t.badge;return[{...n,label:String(t.label),...r!=null?{badge:r}:{},...s.length?{children:s}:{}}]}):[]}function Ht(i,e,t={}){let{fields:s,labelKey:n=Rl(i,e),valueKey:r="ID",searchFields:o=Ll(i,e),limit:a=50,filters:l={},value:c=null,...d}=t,h=_e(i),p=s??Ol(r,n,o);return{...d,valueKey:r,labelKey:n,value:c,filter:async f=>{let m=await h.list(e,bt({search:f,filters:l,fields:p,searchFields:o,limit:a}));return Pn(i,m).data}}}function bp(i,e,t={}){let s=Ht(i,e,t),n=t.value??null,r=new q(null,s);return r.ready=Nl(r,i,e,n),r}function Dl(i,e,t={}){let{fields:s,labelKey:n=Rl(i,e),valueKey:r="ID",searchFields:o=Ll(i,e),subtitleKey:a=null,moduleKey:l=()=>e,groupKey:c=null,none:d=!0,recent:h=[],create:p=!1,renderIcon:f=vp,renderItem:m,renderValueAdornment:g,..._}=t,b=s??Ol(r,n,[...o,...[a,l,c].filter(y=>typeof y=="string")]),w=Ht(i,e,{..._,fields:b,labelKey:n,valueKey:r,searchFields:o,groupKey:c,clearable:d===!1?!!_.clearable:!0});w.recent=Array.isArray(h)?h:[];let A=(y,x=!1)=>{if(f===null)return null;let z=cs(y,l)??e;return f(y,{resource:e,module:String(z),selected:x})};if(w.renderItem=m??(y=>{let x=A(y);return u("span",{class:"zx-select__entity"},x?u("span",{class:"zx-select__entity-icon",ariaHidden:"true"},x):null,u("span",{class:"zx-select__entity-copy"},u("span",{class:"zx-select__entity-label"},String(cs(y,n)??"")),a&&cs(y,a)!=null?u("span",{class:"zx-select__entity-subtitle"},String(cs(y,a))):null))}),w.renderValueAdornment=g??(y=>A(y,!0)),d!==!1&&(w.noneLabel=typeof d=="string"?d:_.noneLabel??R("select.none"),w.renderNone=_.renderNone??(y=>u("span",{class:"zx-select__entity-none"},u("span",{class:"zx-select__entity-none-icon",ariaHidden:"true"}),u("span",{},y)))),p){let y=p===!0?{}:p,x=typeof y.oninvoke=="function"?y.oninvoke:null;w.actions=[...Array.isArray(w.actions)?w.actions:[],{id:y.id??"create",label:y.label??R("select.create"),group:y.group??R("select.createGroup"),icon:y.icon??"plus",invoke:z=>x?.({...z,resource:e})}]}return w}function yp(i,e,t={}){let s=Dl(i,e,t),n=t.value??null,r=q.entity(null,s);return r.ready=Nl(r,i,e,n),r}function Pn(i,e){return typeof i?.normalizeListResult=="function"?Ml(i.normalizeListResult(e)):Ml(e)}function Ml(i){if(Array.isArray(i))return{data:i};if(!i||typeof i!="object")return{data:[]};let e=Array.isArray(i.data)?i.data:[],t=i.count==null||i.count===""?null:Number(i.count);return Number.isFinite(t)?{data:e,count:t}:{data:e}}async function Nl(i,e,t,s){if(s==null)return i;let n=s&&typeof s=="object"?s:await _e(e).get(t,s),r=wp(n);return i.setItems([r]),i.set(r,{silent:!0}),i}function wp(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let e=i.data;return e&&typeof e=="object"&&!Array.isArray(e)?e:i}throw new TypeError("ZeyOS get operation did not return a record")}function cs(i,e){return typeof e=="function"?e(i):i&&typeof i=="object"&&typeof e=="string"?i[e]:null}function vp(i,e){return ht(String(e.module??"default"),{size:20})}function Ol(i,e,t){let s=[i,e,...t].filter(n=>typeof n=="string"&&n);return s.length?[...new Set(s)]:void 0}function Rl(i,e){let t=xp(i,e);for(let s of["name","lastname","customernum","transactionnum","number","title","ID"])if(t.includes(s))return s;return t[0]??"ID"}function Ll(i,e){let t=i?.schema?.describe?.(e)?.fields;return!t||typeof t!="object"||Array.isArray(t)?[]:Object.entries(t).flatMap(([s,n])=>{if(!n||typeof n!="object")return[];let r=String(n.type??"").toLowerCase();return n.indexed&&/text|character|varchar/.test(r)?[s]:[]})}function xp(i,e){let t=i?.schema?.fields?.(e);if(Array.isArray(t))return t.map(String);if(t&&typeof t=="object")return Object.keys(t);let s=i?.schema?.describe?.(e)?.fields;return s&&typeof s=="object"?Object.keys(s):[]}function Sp(i,e,t={}){let s=yt(i,e,t),n={},r=[],o=new Map;for(let a of s){let l=Ss(a);(l.type==="date"||l.type==="datetime")&&o.set(String(a.id),l.type);let c=l.type==="zxselect"&&typeof l.props?.entity=="string"?l.props.entity:null;c&&(r.push({id:String(a.id),resource:c}),l.props={...Ht(i,c,{clearable:!l.required,placeholder:`Select ${String(l.label).toLowerCase()}`})}),n[String(a.id)]=l}return{fieldMeta:s,fields:n,entityFields:r,formOptions:{fieldsets:[{title:String(t.title??""),columns:Ep(t.columns),fields:n}]},mapFromRecord:a=>kp(a,s,o),mapToRecord:a=>Cp(a,s,o)}}function Ap(i,e,t={}){if(t.onSaved!=null&&typeof t.onSaved!="function")throw new TypeError("zeyosForm onSaved must be a function");let s=t.notify!==!1,n=Sp(i,e,t),r=()=>t.scope??a.el,o=_e(i,{onError:g=>s?De.error(Mn(g),{scope:r()}):void 0}),a=new jt(null,n.formOptions),l=t.value?.ID??t.id??null,c=!1,d=null,h=async g=>{if(!g||typeof g!="object"||Array.isArray(g))throw new TypeError("ZeyOS form value must be a record");return await Promise.all(n.entityFields.map(async({id:_,resource:b})=>{let w=g[_];if(w==null)return;let A=w&&typeof w=="object"?w:Vn(await o.get(b,w)),y=q.from(a.getField(_)?.getInput());y instanceof q&&y.setItems([A])})),c||a.setValues(n.mapFromRecord(g),{silent:!0}),g},p=async g=>{if(g==null||g==="")throw new TypeError("zeyosForm.load() requires an id");let _=Vn(await o.get(e,g));return l=_.ID??g,await h(_),_},f=()=>{if(c)return Promise.reject(new Error("Cannot save a destroyed ZeyOS form"));if(d)return d;if(!a.submit())return Promise.resolve(null);let g=s?ce(r()):null;return d=(async()=>{let _;try{_=n.mapToRecord(a.getValues()),delete _.ID}catch(A){throw o.reportError(A,{operation:"serialize",resource:e}),A}let b=l==null?await o.create(e,_):await o.update(e,{ID:l,..._}),w=Vn(b);if(l=w.ID??l,t.onSaved)try{await t.onSaved(w)}catch(A){throw o.reportError(A,{operation:"onSaved",resource:e}),A}return g&&De.success(R("zeyosForm.saved",[Ip(w,e)]),{scope:g}),w})().finally(()=>{d=null}),d},m=Object.prototype.hasOwnProperty.call(t,"id")?p(t.id):t.value?h(t.value):Promise.resolve(null);return{form:a,ready:m,load:p,save:f,getForm:()=>a,destroy(){c||(c=!0,a.destroy())}}}function kp(i,e,t){let s={};for(let n of e){let r=String(n.id),o=i[r],a=t.get(r);!a||o==null||o===""?s[r]=o:a==="date"?s[r]=xs(o,n.timeZone):s[r]=Te(o)}return s}function Cp(i,e,t){let s={};for(let n of e){let r=String(n.id),o=i[r],a=t.get(r);if(a)o==null||o===""?o=null:a==="date"?o=Wt(o,n.timeZone):o=ye(o);else if(Tp(n)&&zp(n.type)&&o!==""&&o!=null){let l=Number(o);Number.isFinite(l)&&(o=l)}s[r]=o}return s}function Tp(i){return i.enums!=null||i.enum!=null}function zp(i){return/^(?:smallint|integer|bigint|int|int2|int4|int8|numeric|decimal)$/i.test(String(i??""))}function Ep(i){let e=Number(i??2);return[1,2,3].includes(e)?e:2}function Vn(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let e=i.data;return e&&typeof e=="object"&&!Array.isArray(e)?e:i}throw new TypeError("ZeyOS operation did not return a record")}function Ip(i,e){for(let t of["transactionnum","name","lastname","customernum","number","ID"])if(i[t]!=null&&i[t]!=="")return String(i[t]);return String(e)}var Mp=["variant","zebra","stickyHeader","responsive","growing","emptyText","rowClass","rowKind","rowKinds","columnVisibility","columnReorder","hiddenColumns","onrowdblclick","onsort","onselectionchange","ondatachange","onstackedchange","ongrow","oncolumnvisibilitychange","oncolumnorderchange"];function Bn(i,e,t={}){let s=yt(i,e,{fields:t.fields,labels:t.labels,formats:t.formats,timeZone:t.timeZone}),n={},r=s.map(l=>{let c={...l},d=Op(c);if(d){let f=Rp(i,d);c.labelField=`${c.id}_label`,n[c.labelField]=`${c.id}.${f}`}n[c.id]=c.id;let h=Lp(c),p=As(h?{...c,format:"money"}:c);return h&&(p.render=f=>We(f?.[c.id],f?.currency,{locale:c.locale}),Fp(i,e,"currency")&&(n.currency="currency")),p}),o=t.rowId??"ID";typeof o=="string"&&!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=o);let a={};for(let l of Mp)t[l]!==void 0&&(a[l]=t[l]);return{fieldMeta:s,columns:r,projection:n,tableOptions:{...a,columns:r,data:[],rowId:o,sort:t.sort??null,sortMode:"server",selectable:t.selectable??!1,height:t.height??null,onrowclick:Np(t)}}}function Dp(i,e,t={}){let s=Bn(i,e,t),n=_e(i),r=new Dt(null,s.tableOptions),o;try{o=qn({client:i,facade:n,resource:e,projection:s.projection,target:r,pageSize:t.pageSize,sort:t.sort??null,filters:t.filters??{},search:t.search,label:"ZeyOS table"})}catch(l){throw r.destroy(),l}let a={table:r,load:o.load,setSearch:l=>o.load({search:l,page:0}),setFilters:l=>o.load({filters:l,page:0}),loadMore:o.loadMore,get count(){return o.count},get page(){return o.page},get pageSize(){return o.pageSize},get hasMore(){return o.hasMore},destroy:()=>{o.destroyed||(o.destroy(),r.destroy())}};return r.on("sort",l=>{if(o.destroyed)return;let c=l.detail?.id;o.setSort(c==null?null:{id:String(c),dir:l.detail.dir==="desc"?"desc":"asc"}),o.load({page:0}).catch(()=>{})}),a}function qn(i){let{client:e,facade:t,resource:s,projection:n,target:r,searchFields:o}=i,a=String(i.label??"ZeyOS binding"),l=Fl(i.pageSize,a),c=i.sort??null,d=jn(i.filters??{},a),h=String(i.search??""),p=0,f=null,m=!1,g=0,_=!1,b=y=>bt({fields:n,sort:c,filters:d,search:h,searchFields:o,limit:l,offset:y*l,count:!0}),w=(y={})=>{let x=y&&typeof y=="object"?y:{},z=Y=>Object.prototype.hasOwnProperty.call(x,Y);return{page:Vp(x.page??0,a),pageSize:z("pageSize")&&x.pageSize!==void 0?Fl(x.pageSize,a):l,filters:z("filters")?jn(x.filters??{},a):d,search:z("search")?String(x.search??""):h}},A=async(y={})=>{if(_)throw new Error(`${a} binding has been destroyed`);let x=w(y),z=x.page;l=x.pageSize,d=x.filters,h=x.search;let Y=z===0||y.replace===!0,ae=b(z),se=++g;r.setLoading(!0);try{let W=Pn(e,await t.list(s,ae)),I=W.count??null,L=I==null?W.data.length===l:z*l+W.data.length<I;return!_&&se===g&&(p=z,f=I,m=L,Y?r.setData(W.data):r.addData(W.data)),{data:W.data,count:I,page:z,hasMore:L,query:ae}}finally{!_&&se===g&&r.setLoading(!1)}};return{load:A,check:w,loadMore:()=>m?A({page:p+1}):_?Promise.reject(new Error(`${a} binding has been destroyed`)):Promise.resolve({data:[],count:f,page:p,hasMore:!1,query:b(p)}),setSort:y=>{c=y??null},setQuery:(y={})=>{let x=Object.prototype.hasOwnProperty.call(y,"filters")?jn(y.filters??{},a):d;Object.prototype.hasOwnProperty.call(y,"search")&&(h=String(y.search??"")),d=x},reset:()=>{p=0,f=null,m=!1},destroy:()=>{_||(_=!0,g+=1)},get destroyed(){return _},get count(){return f},get page(){return p},get pageSize(){return l},get hasMore(){return m},get sort(){return c},get filters(){return{...d}},get search(){return h}}}function Np(i){let e=typeof i.onrowclick=="function"?i.onrowclick:null,t=typeof i.onRowClick=="function"?i.onRowClick:null;if(!(!e&&!t))return s=>{e?.(s),t?.(s.detail.row,s)}}function Op(i){for(let e of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"){let t=e.resource??e.target??e.table??e.entity;if(typeof t=="string"&&t)return t}}return null}function Rp(i,e){let t=i?.schema?.fields?.(e),s=Array.isArray(t)?t.map(String):Object.keys(t??{});for(let n of["name","lastname","customernum","transactionnum","number","title","ID"])if(s.includes(n))return n;return s[0]??"ID"}function Lp(i){let e=String(i.format??"").toLowerCase();return/money|currency|price/.test(e)||/(?:amount|price)$/.test(String(i.id).toLowerCase())}function Fp(i,e,t){let s=i?.schema?.fields?.(e);return Array.isArray(s)?s.includes(t):!!(s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,t))}var Pp=50;function Fl(i,e="ZeyOS table"){if(i==null)return Pp;let t=Number(i);if(!Number.isInteger(t)||t<1)throw new RangeError(`${e} page size must be a positive integer`);return t}function Vp(i,e="ZeyOS table"){let t=Number(i);if(!Number.isInteger(t)||t<0)throw new RangeError(`${e} page must be a non-negative integer`);return t}function jn(i,e="ZeyOS table"){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} filters must be an object`);return{...i}}function Vl(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ZeyOS appointment must be an object");let e=i.ID??i.id;if(e==null||e==="")throw new TypeError("ZeyOS appointment requires ID");let t=Te(i.datefrom),s=Te(i.dateto??i.datefrom);if(!(t instanceof Date)||!(s instanceof Date))throw new TypeError("ZeyOS appointment requires datefrom and dateto");let n=String(i.assoc_name??"").trim(),r=String(i.name??"").trim()||R("zeyosCalendar.untitled"),o=i.entity&&n?`${n}: ${r}`:r,a=i.allDay!=null?!!i.allDay:Pl(t)&&Pl(s)&&ie(t,s)>=1;return{id:String(i.occurrenceid??`${e}@${i.datefrom}`),title:o,start:t,end:s,allDay:a,color:qp(i.color),location:String(i.location??"").trim(),editable:i.editable==null?null:!!i.editable,durationEditable:i.durationEditable==null?null:!!i.durationEditable,data:i}}function jl(i){if(!Array.isArray(i))throw new TypeError("ZeyOS appointments must be an array");return i.map(Vl)}function jp(i){if(!i||!(i.start instanceof Date)||!(i.end instanceof Date))throw new TypeError("Calendar event patch requires start and end Dates");let e={datefrom:ye(i.start),dateto:ye(i.end)};return i.data?.ID!=null?{ID:i.data.ID,...e}:e}function Bl(i={}){let{appointments:e,...t}=i;return{weekStart:1,optimistic:!0,...t,events:e==null?Array.isArray(t.events)?t.events:[]:jl(e)}}function Bp(i,e={}){return new Vt(i,Bl(e))}function qp(i){let e=String(i??"").trim();return e?/^[\da-f]{3,8}$/i.test(e)?`#${e}`:e:null}function Pl(i){return i.getHours()===0&&i.getMinutes()===0&&i.getSeconds()===0&&i.getMilliseconds()===0}var Hp=1,$p=new Set(["table","card","kanban"]),ql="1970-01-01T00:00:00.000Z",Up=new Set(["__proto__","constructor","prototype"]),Kp=new Set(["cursor","data","offset","page","pagination","records","rows","selection","selectedRecords"]),pt=class extends Error{constructor(e){super(`A saved view named "${e}" already exists`),this.name="SavedViewDuplicateNameError"}},ds=class extends Error{constructor(e,t){super(`Saved-view scope mismatch: expected ${mt(e)}, received ${mt(t)}`),this.name="SavedViewScopeMismatchError",this.expected={...e},this.actual={...t}}},hs=class{constructor(e,t,s={}){if(!e||typeof e.load!="function"||typeof e.save!="function")throw new TypeError("SavedViewRegistry transport requires load() and save()");this.transport=e,this.scope=fs(t),this.options=Gp(s),this._document=$n(this.scope),this._loaded=!1,this._loading=null,this._loadSequence=0,this._mutation=Promise.resolve(),this._destroyed=!1}async ready(){return this.load()}async load(e={}){if(this._assertActive(),this._loaded&&!e.force)return this;if(this._loading&&!e.force)return await this._loading,this;let t=++this._loadSequence,s=Promise.resolve(this.transport.load({...this.scope})).then(n=>{if(this._assertActive(),t!==this._loadSequence)return;let r=Hn(n,this.scope,this.options);this._document=r,this._loaded=!0});this._loading=s;try{await s}finally{this._loading===s&&(this._loading=null)}return this}async list(){return await this.ready(),this._document.views.map(ft)}async get(e){await this.ready();let t=us(this._document,e);return t?ft(t):null}async getDefault(){await this.ready();let e=this._document.views.find(t=>t.id===this._document.defaultId)??null;return e?ft(e):null}async save(e,t={}){return this._mutate(async s=>{let n=Yn(e?.name),r=Zn(t.onDuplicate??this.options.duplicateNames),o=e?.id==null?null:Wn(e.id),a=o?s.views.find(y=>y.id===o)??null:null,l=s.views.find(y=>oe(y.name)===oe(n))??null;if(a&&l&&a!==l&&r==="reject")throw new pt(n);if(!a&&l&&r==="reject")throw new pt(n);let c=a??(r==="replace"?l:null),d=r==="replace"&&a&&l!==a?l:null,h=this._now(),p=Kn(e?.type??c?.type),f=Object.prototype.hasOwnProperty.call(e??{},"state")?Wl(e.state):c?de(c.state,"Saved view state"):null;if(!f)throw new TypeError("A new saved view requires state");let m=Object.prototype.hasOwnProperty.call(e??{},"filters")?Zl(e.filters):c?de(c.filters,"Saved view filters"):{},g=Object.prototype.hasOwnProperty.call(e??{},"search")?Gl(e.search):c?.search??"",_=c?.createdAt??h,b=c?.id??o??this._createId(s,{name:n,type:p,createdAt:_}),w={id:b,name:n,type:p,state:f,filters:m,search:g,createdAt:_,updatedAt:h},A=s.views.filter(y=>y!==c&&y!==d&&y.id!==b);return A.push(w),s.views=Un(A),d&&s.defaultId===d.id&&(s.defaultId=b),t.setDefault&&(s.defaultId=b),{changed:!0,result:w}})}async rename(e,t,s={}){return this._mutate(async n=>{let r=us(n,e);if(!r)return{changed:!1,result:null};let o=Yn(t);if(r.name===o)return{changed:!1,result:r};let a=n.views.find(c=>c!==r&&oe(c.name)===oe(o))??null,l=Zn(s.onDuplicate??this.options.duplicateNames);if(a&&l==="reject")throw new pt(o);return a&&(n.views=n.views.filter(c=>c!==a),n.defaultId===a.id&&(n.defaultId=r.id)),r.name=o,r.updatedAt=this._now(),n.views=Un(n.views),{changed:!0,result:r}})}async remove(e){return this._mutate(async t=>{let s=us(t,e);return s?(t.views=t.views.filter(n=>n!==s),t.defaultId===s.id&&(t.defaultId=null),{changed:!0,removeDocument:t.views.length===0,result:!0}):{changed:!1,result:!1}})}async setDefault(e){return this._mutate(async t=>{if(e==null)return t.defaultId===null?{changed:!1,result:null}:(t.defaultId=null,{changed:!0,result:null});let s=us(t,e);return s?t.defaultId===s.id?{changed:!1,result:s}:(t.defaultId=s.id,{changed:!0,result:s}):{changed:!1,result:null}})}async capture(e,t,s={}){if(!e||typeof e.getViewState!="function")throw new TypeError("capture() requires a view with getViewState()");return this.save({...t,state:e.getViewState()},s)}async apply(e,t,s={}){let n=await this.get(e);if(!n)return{status:"missing",applied:!1,entry:null};if(s.type!=null){let r=Kn(s.type);if(n.type!==r)return{status:"type-mismatch",applied:!1,entry:n,expectedType:n.type,currentType:r}}if(!t||typeof t.setViewState!="function")throw new TypeError("apply() requires a view with setViewState()");if(s.onQuery!=null&&typeof s.onQuery!="function")throw new TypeError("apply() onQuery must be a function");return t.setViewState(de(n.state,"Saved view state")),s.onQuery&&await s.onQuery({filters:de(n.filters,"Saved view filters"),search:n.search,entry:ft(n)}),{status:"applied",applied:!0,entry:n}}destroy(){this._destroyed=!0,this._loadSequence+=1,this._loading=null}_assertActive(){if(this._destroyed)throw new Error("SavedViewRegistry has been destroyed")}_now(){let e=this.options.clock(),t=e instanceof Date?e:new Date(e);if(!Number.isFinite(t.getTime()))throw new TypeError("Saved-view clock returned an invalid timestamp");return t.toISOString()}_createId(e,t){let s=this.options.idFactory?this.options.idFactory({scope:{...this.scope},...t}):`view-${Ql(`${mt(this.scope)}\0${t.name}\0${t.type}\0${t.createdAt}`)}`,n=Wn(s),r=new Set(e.views.map(a=>a.id));if(!r.has(n))return n;let o=2;for(;r.has(`${n}-${o}`);)o+=1;return`${n}-${o}`}_mutate(e){this._assertActive();let t=this._mutation.catch(()=>{}).then(async()=>{await this.ready();let s=Hl(this._document),n=await e(s);if(this._assertActive(),!n.changed)return $l(n.result);let r=Hn(s,this.scope,this.options);return this._loadSequence+=1,n.removeDocument&&typeof this.transport.remove=="function"?(await this.transport.remove({...this.scope}),this._assertActive(),this._loadSequence+=1,this._document=$n(this.scope)):(await this.transport.save({...this.scope},Hl(r)),this._assertActive(),this._loadSequence+=1,this._document=r),$l(n.result)});return this._mutation=t.then(()=>{},()=>{}),t}};function Jn(i,e,t={}){return new hs(i,e,t)}function fs(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Saved-view scope must be an object");return{userId:Qn(i.userId,"userId"),workspaceId:Qp(i.workspaceId),resource:Qn(i.resource,"resource")}}function Hn(i,e,t={}){let s=fs(e);if(i==null)return $n(s);let n=Yl(i,t.migrations);if(n.scope!=null){let p=fs(n.scope);if(mt(p)!==mt(s))throw new ds(s,p)}let o=(Array.isArray(n.views)?n.views:[]).map((p,f)=>Wp(p,f,s)),a=Zp(o),l=a.aliases,c=Un(a.views),d=n.defaultId==null?null:String(n.defaultId),h=c.some(p=>p.id===d)?d:l.get(d)??null;return{version:1,scope:s,defaultId:c.some(p=>p.id===h)?h:null,views:c}}function Yl(i,e={}){let t=Array.isArray(i)?{version:0,savedViews:i}:de(i,"Saved-view document"),s=Kl(t.version);if(s>1)throw new RangeError(`Unsupported saved-view document version: ${s}`);for(;s<1;){let n=e?.[s]??(s===0?Yp:null);if(typeof n!="function")throw new RangeError(`Missing saved-view migration from version ${s}`);t=de(n(de(t,"Saved-view document")),`Saved-view migration ${s}`);let r=Kl(t.version);if(r<=s)throw new RangeError(`Saved-view migration ${s} did not advance the version`);s=r}return t}function Yp(i){let t=(Array.isArray(i.savedViews)?i.savedViews:Array.isArray(i.entries)?i.entries:Array.isArray(i.views)?i.views:[]).map(s=>{let n=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return{id:n.id??null,name:n.name??n.label??"",type:n.type??n.presentation??n.view??"",state:n.state??n.viewState??{},filters:n.filters??n.filter??{},search:n.search??n.query??"",createdAt:n.createdAt??n.created??null,updatedAt:n.updatedAt??n.updated??null}});return{version:1,scope:i.scope??null,defaultId:i.defaultId??i.defaultView??i.default??null,views:t}}function Wp(i,e,t){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`Saved view at index ${e} must be an object`);let s=i,n=Yn(s.name),r=Kn(s.type),o=Wl(s.state??{}),a=Zl(s.filters??{}),l=Gl(s.search),c=Ul(s.createdAt),d=Ul(s.updatedAt??c),h=d<c?c:d;return{id:s.id==null||String(s.id).trim()===""?`legacy-${Ql(`${mt(t)}\0${n}\0${r}\0${e}`)}`:Wn(s.id),name:n,type:r,state:o,filters:a,search:l,createdAt:c,updatedAt:h}}function Zp(i){let e=[...i].sort((o,a)=>$t(a.updatedAt,o.updatedAt)||$t(o.id,a.id)),t=new Set,s=new Set,n=new Map,r=[];for(let o of e){let a=r.find(l=>l.id===o.id||oe(l.name)===oe(o.name));if(t.has(o.id)||s.has(oe(o.name))){a&&n.set(o.id,a.id);continue}t.add(o.id),s.add(oe(o.name)),r.push(o)}return{views:r,aliases:n}}function Gp(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Saved-view registry options must be an object");if(i.clock!=null&&typeof i.clock!="function")throw new TypeError("Saved-view clock must be a function");if(i.idFactory!=null&&typeof i.idFactory!="function")throw new TypeError("Saved-view idFactory must be a function");return{...i,duplicateNames:Zn(i.duplicateNames??"reject"),clock:i.clock??(()=>new Date)}}function $n(i){return{version:1,scope:{...i},defaultId:null,views:[]}}function Hl(i){return{version:1,scope:{...i.scope},defaultId:i.defaultId,views:i.views.map(ft)}}function ft(i){return{...i,state:de(i.state,"Saved view state"),filters:de(i.filters,"Saved view filters")}}function $l(i){return Jp(i)?ft(i):i}function us(i,e){if(typeof e!="string")return null;let t=e.trim();return t?i.views.find(s=>s.id===t)??i.views.find(s=>oe(s.name)===oe(t))??null:null}function Un(i){return[...i].sort((e,t)=>$t(oe(e.name),oe(t.name))||$t(e.name,t.name)||$t(e.id,t.id))}function Kn(i){if(typeof i!="string")throw new TypeError('Saved view type must be "table", "card", or "kanban"');let e=i.trim().toLowerCase();if(!$p.has(e))throw new TypeError('Saved view type must be "table", "card", or "kanban"');return e}function Yn(i){if(typeof i!="string")throw new TypeError("Saved view name must be a string");let e=i.normalize("NFKC").trim().replace(/\s+/g," ");if(!e)throw new TypeError("Saved view name cannot be empty");if(e.length>160)throw new RangeError("Saved view name cannot exceed 160 characters");return e}function oe(i){return i.normalize("NFKC").toLocaleLowerCase("en-US")}function Wn(i){if(typeof i!="string")throw new TypeError("Saved view id must be a string");let e=i.normalize("NFKC").trim();if(!e)throw new TypeError("Saved view id cannot be empty");if(e.length>180)throw new RangeError("Saved view id cannot exceed 180 characters");return e}function Zn(i){if(i!=="reject"&&i!=="replace")throw new TypeError('Duplicate saved-view policy must be "reject" or "replace"');return i}function Wl(i){let e=de(i,"Saved view state"),t=Number(e.version);if(!Number.isInteger(t)||t<1)throw new TypeError("Saved view state requires a positive integer version");e.version=t;for(let s of Kp)if(Object.prototype.hasOwnProperty.call(e,s))throw new TypeError(`Saved view state cannot serialize ${s}`);return e}function Zl(i){return de(i??{},"Saved view filters")}function Gl(i){if(i==null)return"";if(typeof i!="string")throw new TypeError("Saved view search must be a string");return i}function de(i,e){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} must be a plain object`);return Gn(i,e,new WeakSet)}function Gn(i,e,t){if(i===null||typeof i=="string"||typeof i=="boolean")return i;if(typeof i=="number"){if(!Number.isFinite(i))throw new TypeError(`${e} cannot contain non-finite numbers`);return i}if(typeof i!="object")throw new TypeError(`${e} must be JSON-safe`);if(typeof i.nodeType=="number")throw new TypeError(`${e} cannot contain DOM nodes`);if(t.has(i))throw new TypeError(`${e} cannot contain cycles`);t.add(i);try{if(Array.isArray(i))return i.map(o=>Gn(o,e,t));let s=Object.getPrototypeOf(i);if(s!==Object.prototype&&s!==null)throw new TypeError(`${e} can contain only plain objects and arrays`);let n={},r=i;if(Object.getOwnPropertySymbols(i).length>0)throw new TypeError(`${e} cannot contain symbols`);for(let o of Object.keys(i).sort()){if(Up.has(o))throw new TypeError(`${e} cannot contain prototype-pollution keys`);let a=Object.getOwnPropertyDescriptor(r,o);if(!a||!Object.prototype.hasOwnProperty.call(a,"value"))throw new TypeError(`${e} cannot contain property accessors`);n[o]=Gn(a.value,e,t)}return n}finally{t.delete(i)}}function Ul(i){if(i==null||i==="")return ql;let e=new Date(i);return Number.isFinite(e.getTime())?e.toISOString():ql}function Kl(i){if(i==null)return 0;let e=Number(i);if(!Number.isInteger(e)||e<0)throw new TypeError("Saved-view document version must be a non-negative integer");return e}function Qn(i,e){if(typeof i!="string"&&typeof i!="number")throw new TypeError(`Saved-view scope ${e} must be a string or number`);let t=String(i).normalize("NFKC").trim();if(!t)throw new TypeError(`Saved-view scope ${e} cannot be empty`);return t}function Qp(i){return i===null?null:Qn(i,"workspaceId")}function mt(i){let e=i.workspaceId===null?"":`${i.workspaceId}`;return`${i.userId}\0${e}\0${i.resource}`}function $t(i,e){return i<e?-1:i>e?1:0}function Jp(i){return!!(i&&typeof i=="object"&&"id"in i&&typeof i.id=="string")}function Ql(i){let e=2166136261;for(let t=0;t<i.length;t+=1)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return(e>>>0).toString(36)}var Xp=["titleField","subtitleField","preview","previewAlt","link","actions","groupBy","groupOrder","columnBy","columns","swimlaneBy","swimlanes","moveMode","columnOrder","swimlaneOrder","collapsedColumns","collapsedSwimlanes","showCounts","showEmptyColumns","hiddenFields","fieldOrder","fieldControls","selectable","selection","emptyText"];function Xl(i,e,t={}){let s=tm(i,e,t),n=Bn(i,e,{fields:s,labels:t.labels,formats:t.formats,timeZone:t.timeZone,rowId:t.recordId??"ID",sort:t.sort??null}),r=t.fieldOverrides&&typeof t.fieldOverrides=="object"?t.fieldOverrides:{},o=Array.isArray(t.fields)?new Set(t.fields.map(String)):null,a=n.columns.map(d=>({...d,...o&&!o.has(d.id)?{visible:!1}:{},...r[d.id]??{},id:d.id})),l={...n.projection};for(let d of ec(t))Object.prototype.hasOwnProperty.call(l,d)||(l[d]=d);let c={...t.viewOptions??{}};for(let d of Xp)Object.prototype.hasOwnProperty.call(t,d)&&(c[d]=t[d]);return Object.assign(c,{fields:a,data:[],recordId:t.recordId??"ID",sort:t.sort??null,sortMode:"server"}),typeof t.onRecordClick=="function"&&(c.onrecordclick=d=>t.onRecordClick(d.detail.record,d)),{fieldMeta:n.fieldMeta,fields:a,projection:l,viewOptions:c}}function em(i,e,t,s={}){if(typeof t!="function")throw new TypeError("zeyosView() requires a view constructor");let n=Xl(i,e,s),r=new t(s.target??null,n.viewOptions);for(let I of["setData","addData","setLoading","on","destroy"])if(typeof r?.[I]!="function"){try{r?.destroy?.()}catch{}throw new TypeError(`zeyosView() constructor must provide ${I}()`)}let o=_e(i),a;try{a=qn({client:i,facade:o,resource:e,projection:n.projection,target:r,pageSize:s.pageSize,sort:s.sort??null,filters:s.filters??{},search:s.search,searchFields:s.searchFields,label:"ZeyOS view"})}catch(I){throw r.destroy(),I}let l;try{l=nm(s.savedViews,t,e)}catch(I){throw r.destroy(),I}let c=l?.registry??null,d=l?.type??tc(t);if(c){for(let I of["getViewState","setViewState"])if(typeof r?.[I]!="function")throw l?.owned&&c.destroy?.(),r.destroy(),new TypeError(`zeyosView() saved views require ${I}()`)}let h=!1,p=a.load,f=!1,m=async(I,L={})=>{if(!c||!d)throw new Error("This ZeyOS view binding has no saved-view registry");if(h)throw new Error("ZeyOS view binding has been destroyed");let $=await c.apply(I,r,{type:d,onQuery:async({filters:he,search:ms})=>{h||a.setQuery({filters:sm(he),search:ms})}});return!$.applied||h||(a.setSort(am(r,$.entry)),a.reset(),L.load!==!1&&await p({page:0})),$},g=async(I={},L=()=>{})=>{if(!c)return null;try{await om(c)}catch($){if(!h&&(L(),s.savedViewFallback==="baseline"))try{o.reportError($,{operation:"savedViews.read",resource:e})}catch{}throw $}if(h)throw new Error("ZeyOS view binding has been destroyed");try{let $=await c.getDefault();if(h)throw new Error("ZeyOS view binding has been destroyed");return $?await m($.id,I):{status:"missing",applied:!1,entry:null}}catch($){throw f=!0,$}},_=c?g({load:!1}):Promise.resolve(null),b=!c,w=null;_.then(()=>{b=!0},()=>{});let A=async(I={load:!1},L=!1)=>{if(h)throw new Error("ZeyOS view binding has been destroyed");if(b)return null;try{let he=await _;return b=!0,he}catch{}if(h)throw new Error("ZeyOS view binding has been destroyed");if(!w){let he={readFailed:!1,promise:null},ms=g(I,()=>{he.readFailed=!0}).then(rc=>(b=!0,rc));he.promise=ms.finally(()=>{w===he&&(w=null)}),w=he}let $=w;try{return await $.promise}catch(he){if(L&&s.savedViewFallback==="baseline"&&$.readFailed&&!f&&!h)return null;throw he}},y=async(I={})=>(a.check(I),await A({load:!1},!0),p(I)),x=I=>{if(h)throw new Error("ZeyOS view binding has been destroyed");if(c&&!b)throw new Error("Saved-view initialization has not succeeded");if(!d||typeof r.getViewState!="function")throw new Error("This view does not expose serializable saved-view state");let L=I&&typeof I=="object"?I:{};return{...L.id==null?{}:{id:String(L.id)},name:String(L.name??""),type:d,state:r.getViewState(),filters:a.filters,search:a.search}},z=async I=>{if(!c||!d)throw new Error("This ZeyOS view binding has no saved-view registry");if(await A({load:!1}),h)throw new Error("ZeyOS view binding has been destroyed");let L=x(I);return await c.capture(r,{...L.id==null?{}:{id:L.id},name:L.name,type:d,filters:L.filters,search:L.search},{onDuplicate:I?.onDuplicate,setDefault:!!I?.setDefault})},Y=async(I,L={})=>(await A({load:!1}),m(I,L)),ae=async(I={})=>b?g(I):A(I),se=I=>{if(h)return;let L=I.detail?.id;a.setSort(L==null?null:{id:String(L),dir:I.detail.dir==="desc"?"desc":"asc"}),y({page:0}).catch(()=>{})},W={view:r,load:y,setSearch:I=>y({search:I,page:0}),setFilters:I=>y({filters:I,page:0}),loadMore:async()=>(await A({load:!1},!0),a.loadMore()),get count(){return a.count},get page(){return a.page},get pageSize(){return a.pageSize},get hasMore(){return a.hasMore},savedViews:c,ready:_,restoreDefault:ae,captureView:x,saveView:z,applyView:Y,destroy:()=>{h||(h=!0,a.destroy(),typeof r.off=="function"?r.off("sortchange",se):r.removeEventListener?.("sortchange",se),l?.owned&&c?.destroy?.(),r.destroy())}};return r.on("sortchange",se),W}function tm(i,e,t){if(!Array.isArray(t.fields)&&!Array.isArray(t.exclude))return;let s=new Set(Array.isArray(t.exclude)?t.exclude.map(String):[]),n=Array.isArray(t.fields)?t.fields.map(String):im(i,e);return[...new Set([...n,...ec(t)])].filter(r=>!s.has(r))}function im(i,e){let t=i?.schema?.fields?.(e);return Array.isArray(t)?t.map(s=>typeof s=="string"?s:String(s?.id??s?.name??s?.field??"")).filter(Boolean):t&&typeof t=="object"?Object.keys(t):[]}function ec(i){let e=[];for(let t of["titleField","subtitleField","preview","groupBy","columnBy","swimlaneBy"]){let s=i[t];typeof s=="string"&&s.trim()&&e.push(s.trim())}return[...new Set(e)]}function sm(i){return i&&typeof i=="object"&&!Array.isArray(i)?{...i}:{}}function nm(i,e,t){if(i==null||i===!1)return null;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("savedViews must be a registry or transport/scope configuration");let s=i,n=s.controller??s.registry,r=Jl(s)?s:Jl(n)?n:null,o=rm(s.type??tc(e));if(!o)throw new TypeError("savedViews requires a table, card, or kanban presentation type");if(r)return{registry:r,type:o,owned:!1};if(!s.transport||!s.scope||typeof s.scope!="object")throw new TypeError("savedViews requires a controller or injected transport and scope");let a={...s.scope,resource:s.scope.resource??t};return{registry:Jn(s.transport,a,s.options??{}),type:o,owned:!0}}function Jl(i){return!!(i&&typeof i=="object"&&typeof i.apply=="function"&&typeof i.capture=="function"&&typeof i.getDefault=="function")}function tc(i){let e=String(i.cssName??"").toLowerCase().replace(/-view$/,"");if(["table","card","kanban"].includes(e))return e;let t=String(i.name??"").toLowerCase().replace(/view$/,"");return["table","card","kanban"].includes(t)?t:null}function rm(i){let e=String(i??"").toLowerCase();return["table","card","kanban"].includes(e)?e:null}async function om(i){typeof i.ready=="function"?await i.ready():typeof i.load=="function"&&await i.load()}function am(i,e){let t=typeof i.getSort=="function"?i.getSort():typeof i.getViewState=="function"?i.getViewState()?.sort:e?.state?.sort;return!t||typeof t!="object"||Array.isArray(t)||t.id==null?null:{id:String(t.id),dir:t.dir==="desc"?"desc":"asc"}}function lm(i){if(typeof i!="function")throw new TypeError("Legacy saved-view loader must be a function");return e=>new Promise((t,s)=>{i(e,t,(n,r,o)=>{let a=new Error(String(n??"ZeyOS saved-view request failed"));return Object.assign(a,{type:r,info:o}),s(a),!0})})}function cm(i,e={}){if(typeof i!="function")throw new TypeError("Saved-view request must be a function");let t=ic(e.recordName,"__zx_record_views_v1__","recordName"),s=ic(e.viewPrefix,"zx.record-views:","viewPrefix"),n=e.module==null?"":String(e.module),r=(o,a)=>{let l=um(o);return{umi:n,page:a,fork:l.workspaceId,view:`${s}${l.resource}`}};return{async load(o){let a=await i(r(o,"fields")),l=dm(a,t);if(l==null||l==="")return null;if(typeof l=="string")try{let c=JSON.parse(l);return ps(c)?c:null}catch{return null}return ps(l)?sc(l):null},async save(o,a){if(!ps(a))throw new TypeError("Saved-view document must be an object");let l=sc(a);return await i({...r(o,"fields_save"),name:t,data:JSON.stringify(l)}),l},async remove(o){await i({...r(o,"fields_remove"),name:t})}}}function um(i){if(!ps(i))throw new TypeError("Saved-view scope must be an object");if(i.userId==null||String(i.userId).trim()==="")throw new TypeError("Saved-view scope requires userId");let e=String(i.resource??"").trim();if(!e)throw new TypeError("Saved-view scope requires resource");let t=i.workspaceId==null||i.workspaceId===""?null:i.workspaceId;return{userId:String(i.userId),workspaceId:t,resource:e}}function dm(i,e){if(!Array.isArray(i)||!Array.isArray(i[0])||!Array.isArray(i[1]))return null;let t=i[0].findIndex(s=>String(s)===e);return t<0?null:i[1][t]}function ic(i,e,t){let s=i==null?e:String(i).trim();if(!s)throw new TypeError(`${t} must not be empty`);return s}function ps(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function sc(i){nc(i,new Set);try{return JSON.parse(JSON.stringify(i))}catch{throw new TypeError("Saved-view document must be JSON-serializable")}}function nc(i,e){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"&&Number.isFinite(i))return;if(typeof i!="object")throw new TypeError("Saved-view document must be JSON-serializable");if(e.has(i))throw new TypeError("Saved-view document must be JSON-serializable");if(!Array.isArray(i)&&Object.getPrototypeOf(i)!==Object.prototype&&Object.getPrototypeOf(i)!==null)throw new TypeError("Saved-view document must be JSON-serializable");e.add(i);let t=Array.isArray(i)?i:Object.values(i);for(let s of t)nc(s,e);e.delete(i)}export{Hp as SAVED_VIEWS_VERSION,pt as SavedViewDuplicateNameError,hs as SavedViewRegistry,ds as SavedViewScopeMismatchError,Cl as ZEYOS_ICON_KIT,dp as ZEYOS_LAUNCHER_APPLICATIONS,bt as buildListQuery,gp as buildZeyosAppSidebarConfig,Bl as buildZeyosCalendarOptions,Dl as buildZeyosEntitySelectConfig,Tl as buildZeyosLauncherConfig,El as buildZeyosModuleBarConfig,Ht as buildZeyosSelectConfig,Xl as buildZeyosViewConfig,Wt as calendarDayToUnixSeconds,jp as calendarEventToZeyosPatch,_e as connect,cm as createLegacySavedViewTransport,Jn as createSavedViewRegistry,dc as dataFilterStateToFilters,ye as dateToUnixSeconds,As as fieldToZxColumn,Ss as fieldToZxField,lm as legacySavedViewRequest,Yl as migrateSavedViewDocument,kl as moduleAliases,ht as moduleChip,rp as moduleColor,cp as moduleGlyphColor,os as moduleIcon,op as moduleIconName,re as moduleInfo,ap as moduleKeys,rs as normalizeModuleName,Hn as normalizeSavedViewDocument,fs as normalizeSavedViewScope,zl as normalizeZeyosLauncherApplications,as as normalizeZeyosLauncherRecords,U as registerFieldType,lp as registerModules,yt as resolveFields,ar as tableSortToQuery,xs as unixSecondsToCalendarDay,Te as unixSecondsToDate,up as useZeyosIcons,fp as zeyosActiveIdentifier,Nn as zeyosAppIcon,Vl as zeyosAppointmentToEvent,jl as zeyosAppointmentsToEvents,Bp as zeyosCalendar,yp as zeyosEntitySelect,Ap as zeyosForm,hp as zeyosLauncher,_p as zeyosModuleBar,Fn as zeyosModuleItems,Ye as zeyosModules,bp as zeyosSelect,Dp as zeyosTable,em as zeyosView};
|
|
8
|
+
`).length}}function xd(i,e){return i.startsWith(e)?e.length:e===" "?i.startsWith(" ")?1:Math.min(/^ +/.exec(i)?.[0].length??0,2):Math.min(/^\s+/.exec(i)?.[0].length??0,e.length)}function _o(i){let e=String(i??"text").trim().toLowerCase();return/^[a-z0-9][a-z0-9+_.-]*$/.test(e)?e:"text"}function Sd(i){let e=Number(i);return Number.isFinite(e)?Math.max(2,Math.min(100,Math.round(e))):12}function Ad(i){return["off","soft","hard"].includes(String(i))?i:"off"}function bi(i,e){let t=Number(i);return Math.max(0,Math.min(e,Number.isFinite(t)?Math.round(t):0))}function bo(){E.register("code",(i,e)=>{let t=i.own(new _i(null,{label:e.label?String(e.label):null,placeholder:e.placeholder,readOnly:!!e.props?.readOnly,disabled:!!e.disabled,...e.props??{},value:e.value})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),t.on("input",n=>i.emit("input",{value:n.detail.value})),{el:t.el,labelTarget:t.getInput(),get:()=>t.getValue(),set:n=>{s=!0;try{t.setValue(n,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadOnly(n)}}})}var kd=["January","February","March","April","May","June","July","August","September","October","November","December"],Cd=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],So={month:kd,weekday:Cd},Ao=/%[demYyHMSaAbBs]/g,yo=new Map;function D(i,e,t){let s=ee(t?.locale,Intl.DateTimeFormat),n=t?.locale==null;return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(e).replace(Ao,r=>{switch(r){case"%d":return rt(i.getDate());case"%e":return String(i.getDate());case"%m":return rt(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return rt(i.getFullYear()%100);case"%H":return rt(i.getHours());case"%M":return rt(i.getMinutes());case"%S":return rt(i.getSeconds());case"%a":return vo("weekday",i,s,n);case"%A":return wo("weekday",i,s,n);case"%b":return vo("month",i,s,n);case"%B":return wo("month",i,s,n);case"%s":return String(Math.floor(i.getTime()/1e3));default:return r}})}function ge(i,e){let t=[],s="^",n=0;for(let m of String(e).matchAll(Ao)){s+=xo(String(e).slice(n,m.index));let g=m[0],_=zd(g);if(_===null)return null;s+=`(${_})`,t.push(g),n=m.index+g.length}s+=xo(String(e).slice(n))+"$";let r=new RegExp(s).exec(String(i));if(!r)return null;let o=Object.create(null);if(t.forEach((m,g)=>{o[m]=Number(r[g+1])}),o["%s"]!==void 0){let m=o["%s"]*1e3,g=new Date(m);return Number.isNaN(g.getTime())?null:g}let a=o["%Y"]??Ed(o["%y"])??1970,l=(o["%m"]??1)-1,c=o["%d"]??o["%e"]??1,d=o["%H"]??0,h=o["%M"]??0,p=o["%S"]??0;if(d>23||h>59||p>59)return null;let f=new Date(0);return f.setHours(0,0,0,0),f.setFullYear(a,l,c),f.setHours(d,h,p,0),Number.isNaN(f.getTime())||o["%Y"]!==void 0&&f.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&f.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&f.getMonth()!==l||o["%d"]!==void 0&&f.getDate()!==c||o["%e"]!==void 0&&f.getDate()!==c?null:f}function Z(i,e){return i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()}function N(i,e){let t=new Date(i.getTime());return t.setDate(t.getDate()+e),t}function Be(i,e){let t=new Date(i.getTime()),s=t.getDate();t.setDate(1),t.setMonth(t.getMonth()+e);let n=new Date(t.getFullYear(),t.getMonth()+1,0).getDate();return t.setDate(Math.min(s,n)),t}function yi(i=ne()){if(!i||i.toLowerCase()==="en")return 1;try{let e=new Intl.Locale(i),t=e.getWeekInfo?.()??e.weekInfo;if(t?.firstDay)return t.firstDay%7}catch{}return 1}function rt(i){return String(i).padStart(2,"0")}function ko(i,e){return i==="month"?e.getMonth():e.getDay()}function wo(i,e,t,s){let n=ko(i,e),r=`date.${i}.${n}`,o=s?we(r):null;return o!==null?o:Co(i,"long",t)?.format(e)??So[i][n]}function vo(i,e,t,s){let n=ko(i,e),r=s?we(`date.${i}.short.${n}`):null;return r!==null?r:Co(i,"short",t)?.format(e)??So[i][n].slice(0,3)}function Co(i,e,t){let s=`${t}\0${i}\0${e}`,n=yo.get(s);if(n===void 0){try{n=Intl.DateTimeFormat.supportedLocalesOf(t).length>0?new Intl.DateTimeFormat(t,{[i]:e,calendar:"gregory"}):null}catch{n=null}yo.set(s,n)}return n}function zd(i){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[i]??null}function Ed(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function xo(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var zo=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),Td=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),Eo=Object.freeze({fa:null,fas:"solid",far:"regular",fal:"light",fat:"thin",fad:"duotone",fab:"brands",fak:"kit",solid:"solid",regular:"regular",light:"light",thin:"thin",duotone:"duotone",brands:"brands",kit:"kit",custom:"kit"}),Md=Object.freeze({x:"xmark",search:"magnifying-glass",calendar:"calendar-days",reload:"arrows-rotate",dots:"ellipsis",info:"circle-info",warning:"triangle-exclamation",error:"circle-exclamation",success:"circle-check",drag:"grip-vertical",type:"font",hash:"hashtag",mail:"envelope","link-2":"link"}),Js=new Map;function To(i){let e=String(i).trim();if(/\s/.test(e)||e.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:e.split(/\s+/).filter(Boolean)};let t=e.indexOf(":");if(t>0){let s=e.slice(0,t).toLowerCase(),n=e.slice(t+1);if(s==="builtin"||s==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(Eo,s))return{provider:"fa",name:n,style:Eo[s],classes:null}}return{provider:null,name:e,style:null,classes:null}}function Xs(i,e={}){let{style:t="solid",family:s="classic",fixedWidth:n=!1,translate:r=!0}=e,o=String(i).replace(/^fa-/,""),a=r?Md[o]??o:o,l=[],c=Td[s];return c&&l.push(c),l.push(zo[t]??zo.solid,`fa-${a}`),n&&l.push("fa-fw"),l}function en(i){let e=String(i).trim();if(/^(https?:)?\/\//.test(e)||e.startsWith("/")||e.endsWith(".js"))return e;if(!/^[a-z0-9]+$/.test(e))throw new RangeError(`Invalid Font Awesome kit token: ${i}`);return`https://kit.fontawesome.com/${e}.js`}function Mo(i){let e=en(i),t=Js.get(e);if(t)return t;let s=new Promise((n,r)=>{let o=new URL(e,document.baseURI).href,a=[...document.scripts].find(c=>c.src===o);if(a&&Id(o)){n();return}let l=a??document.createElement("script");l.addEventListener("load",()=>n(),{once:!0}),l.addEventListener("error",()=>{Js.delete(e),r(new Error(`Font Awesome kit failed to load: ${e}`))},{once:!0}),!a&&(l.src=e,l.async=!0,l.crossOrigin="anonymous",document.head.append(l))});return Js.set(e,s),s}function Id(i){if(globalThis.FontAwesomeKitConfig||globalThis.FontAwesome)return!0;try{return globalThis.performance?.getEntriesByName?.(i,"resource").some(e=>{let t=e;return t.initiatorType!=="script"||!(t.responseEnd>0)?!1:typeof t.responseStatus=="number"&&t.responseStatus>0?t.responseStatus>=200&&t.responseStatus<300:t.decodedBodySize>0})??!1}catch{return!1}}var Oo="http://www.w3.org/2000/svg",T=Object.freeze({control:16,chevron:14,dismiss:14,check:14,sort:14,chip:12,marker:8}),No="0 0 24 24",Dd=1.75,Od=1,C=i=>[No,i,"stroke"];var sn=Object.freeze({"arrow-up-wide-short":C("M3 8l4-4 4 4M7 4v16M11 12h10M11 16h7M11 20h4"),"arrow-down-wide-short":C("M3 16l4 4 4-4M7 20V4M11 4h10M11 8h7M11 12h4"),"arrow-up":C("M5 12l7-7 7 7M12 19V5"),"arrow-down":C("M12 5v14M19 12l-7 7-7-7"),"chevron-down":C("M6 9l6 6 6-6"),"chevron-up":C("M18 15l-6-6-6 6"),"chevron-left":C("M15 18l-6-6 6-6"),"chevron-right":C("M9 18l6-6-6-6"),check:C("M20 6 9 17l-5-5"),x:C("M18 6 6 18M6 6l12 12"),plus:C("M5 12h14M12 5v14"),minus:C("M5 12h14"),search:C("M21 21l-4.34-4.34M3 11a8 8 0 1 0 16 0a8 8 0 1 0-16 0z"),calendar:C("M8 2v3M16 2v3M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18"),clock:C("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 6v6l4 2"),trash:C("M10 11v6M14 11v6M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"),gear:C("M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),eye:C("M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),lock:C("M5 11h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zM7 11V7a5 5 0 0 1 10 0v4"),reload:C("M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8M21 3v5h-5"),list:C("M3 5h.01M3 12h.01M3 19h.01M8 5h13M8 12h13M8 19h13"),filter:C("M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"),dots:C("M11 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM18 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM4 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),info:C("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 16v-4M12 8h.01"),warning:C("M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4M12 17h.01"),error:C("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 8V12M12 16H12.01"),success:C("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 9l-5.5 5.5L8 12"),upload:C("M12 3v12M17 8l-5-5-5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"),download:C("M12 15V3M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5"),"box-archive":C("M3 3h18a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-18a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1zM4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8M10 12h4"),pencil:C("M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497zM15 5l4 4"),"pen-to-square":C("M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"),drag:C("M8 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),star:C("M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"),heart:C("M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"),tag:C("M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42zM7 7.5a.5 .5 0 1 0 1 0a.5 .5 0 1 0-1 0z"),folder:C("M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"),"folder-open":C("M6 14l1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"),file:C("M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2zM14 2v5a1 1 0 0 0 1 1h5"),copy:C("M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-10a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2zM4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"),square:C("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2z"),code:C("M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16"),book:C("M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20"),"table-cells-large":C("M4 3h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM15 3h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM15 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM4 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1z"),table:C("M12 3v18M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18M3 15h18"),image:C("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM7 9a2 2 0 1 0 4 0a2 2 0 1 0-4 0zM21 15l-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),columns:C("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM9 3v18M15 3v18"),type:C("M12 4v16M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2M9 20h6"),hash:C("M4 9h16M4 15h16M10 3L8 21M16 3l-2 18"),mail:C("M22 7l-8.991 5.727a2 2 0 0 1-2.009 0L2 7M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-16a2 2 0 0 1-2-2v-12a2 2 0 0 1 2-2z"),"link-2":C("M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 1 1 0 10h-2M8 12h8"),"circle-chevron-down":C("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 10l-4 4-4-4")}),nn=Object.freeze({archive:"box-archive",edit:"pen-to-square",settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list",grid:"table-cells-large"}),Ro=Object.create(null),Se={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function rn(){return{...Se}}function on(i={}){for(let e of["provider","style","family","fixedWidth","kit"])i[e]!==void 0&&(Se[e]=i[e]);return rn()}function Lo(i={}){return on({...i,provider:"fontawesome"})}async function an(i){let e=typeof i=="string"?{kit:i}:{...i},{kit:t,activate:s=!0,...n}=e;if(!t)throw new TypeError("loadFontAwesome() needs a kit token or URL");return on({...n,kit:en(t)}),await Mo(t),s?Lo():rn()}function Nd(i){return Object.hasOwn(Ro,i)?i:Object.hasOwn(nn,i)?nn[i]:i}function x(i,e={}){let t=To(i);if(t.classes)return tn(t.classes,e);let s=Nd(t.name);return t.provider==="builtin"?Io(s,e):t.provider==="fa"?tn(Xs(s,{style:t.style??e.style??Se.style,family:e.family??Se.family,fixedWidth:e.fixedWidth??Se.fixedWidth}),e):Se.provider==="fontawesome"?tn(Xs(s,{style:e.style??Se.style,family:e.family??Se.family,fixedWidth:e.fixedWidth??Se.fixedWidth}),e):Io(s,e)}function Io(i,e){let t=Ro[i]??(Object.hasOwn(sn,i)?sn[i]:void 0);if(!t){if(e.strict)throw new RangeError(`Unknown icon: ${i}`);return Pd(i),Fd(i,e)}let[s,n,r="fill"]=t,o=Fo(s,r,e),a=document.createElementNS(Oo,"path");return a.setAttribute("d",n),o.append(a),o}function Fo(i,e,t){let{size:s=T.control}=t,n=document.createElementNS(Oo,"svg");return n.setAttribute("class",jo("zx-icon",t.class)),n.setAttribute("viewBox",i),n.setAttribute("width",String(s)),n.setAttribute("height",String(s)),e==="stroke"?(n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width",Rd(i,s)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round")):n.setAttribute("fill","currentColor"),n.setAttribute("focusable","false"),Po(n,t.label??null),n}function Rd(i,e){let[,,t,s]=i.trim().split(/[\s,]+/).map(Number),n=Math.max(t,s)||24,r=Dd*n/24,o=typeof e=="number"?e:/^\d*\.?\d+(px)?$/.test(String(e).trim())?parseFloat(String(e)):NaN;return o>0&&(r=Math.max(r,Od*n/o)),String(Math.round(r*1e3)/1e3)}var Ld=No;function Fd(i,e){let t=Fo(Ld,"stroke",e);return t.setAttribute("data-zx-icon-missing",i),t}var Do=new Set;function Pd(i){Do.has(i)||(Do.add(i),console.warn(`[zx.icon] Unknown icon "${i}" \u2014 rendered an empty placeholder. Add it with registerIcons(), or render Font Awesome with useFontAwesome().`))}function tn(i,e){let{size:t=T.control}=e,s=document.createElement("i");return s.className=jo("zx-icon",...i,e.class),s.style.fontSize=typeof t=="number"?`${t}px`:String(t),Po(s,e.label??null),s}function Po(i,e){if(e===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",e)}function jo(...i){return i.flat().filter(Boolean).join(" ")}var jd=5,wi=class extends k{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let e=this.el??u("div");this.el=e;let t=Vo(this.options.value);this._value=t,this._display=t??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let s=u("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:this._message("timePicker.label","Time")});if(this._content=s,this._addSpin(s,"h",this._message("timePicker.hour","Hour"),23),s.append(u("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"m",this._message("timePicker.minute","Minute"),59),this.options.seconds&&(s.append(u("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"s",this._message("timePicker.second","Second"),59)),e.append(s),this.options.clock){let n=z("zx-time-picker-clock");s.append(u("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:this._message("timePicker.clock","Pick the time on a clock"),ariaExpanded:"false",ariaControls:n},x("clock",{size:15}))),this._clock=this._buildClock(n),e.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),e}get(){return this._value?{...this._value}:null}set(e,{silent:t=!1}={}){let s=Vo(e);return this._value=s,this._display=s??{h:0,m:0,s:0},this._writeInputs(),!t&&s&&this.emit("change",{time:{...s}}),this}openClock(e="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=e==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(e,t,s,n){let r=u("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:s,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:t}});this._inputs.push(r),e.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,t,n)),this.listen(r,"input",()=>this._onInput(r,t,n)),this.listen(r,"blur",()=>{this._inputs.some(o=>o.value!==De(this._display[o.dataset.segment]))&&this._commitFromInputs()})}_onKeydown(e,t,s){if(e.key!=="ArrowUp"&&e.key!=="ArrowDown")return;e.preventDefault();let n=e.key==="ArrowUp"?1:-1,r=t==="m"?Hd(this.options.step):1,o=ot(e.currentTarget.value,0,s),a=s+1,l=(o+n*r+a*r)%a;e.currentTarget.value=De(l),this._commitFromInputs()}_onInput(e,t,s){if(e.value=e.value.replace(/\D/g,"").slice(0,2),e.value.length<2)return;e.value=De(ot(e.value,0,s)),this._commitFromInputs();let n=this._inputs.indexOf(e);this._inputs[n+1]?.focus()}_commitFromInputs(){let e={...this._display};for(let s of this._inputs){let n=s.dataset.segment,r=n==="h"?23:59;e[n]=ot(s.value,0,r)}let t=!this._value||!Ud(this._value,e);this._value=e,this._display=e,this._writeInputs(),t&&this.emit("change",{time:{...e}})}_writeInputs(){for(let e of this._inputs){let t=e.dataset.segment;e.value=De(this._display[t]),e.setAttribute("aria-valuenow",String(this._display[t])),e.setAttribute("aria-valuetext",e.value)}this._syncClock()}_buildClock(e){let t=u("div",{class:"zx-time-picker__clock",id:e,hidden:!0},u("div",{class:"zx-time-picker__clock-head"},u("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectHour","Select the hour"),dataset:{unit:"h"}}),u("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),u("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectMinutes","Select the minutes"),dataset:{unit:"m"}})),u("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},u("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),u("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",s=>{let n=s.target.closest?.(".zx-time-picker__mark");n&&this._pick(Number(n.dataset.value))}),this.listen(this.refs.dial,"keydown",s=>this._onDialKeydown(s)),t}_pick(e,{advance:t=!0}={}){let s={...this._display,[this._clockUnit]:e},n=t&&this._clockUnit==="h";this.set(s),n&&this.openClock("m")}_onDialKeydown(e){let t=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],s=e.target.closest?.(".zx-time-picker__mark"),n=t.indexOf(s);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key],o=null;r!==void 0?o=(n+r+t.length)%t.length:e.key==="Home"?o=0:e.key==="End"&&(o=t.length-1),o!==null&&(e.preventDefault(),this._pick(Number(t[o].dataset.value),{advance:!1}),this.refs.dial.querySelector(`[data-value="${t[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let e=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=De(this._display.h),this.refs.headMinute.textContent=De(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(e)),this.refs.headMinute.setAttribute("aria-pressed",String(!e)),this.refs.dial.setAttribute("aria-label",e?this._message("timePicker.hour","Hour"):this._message("timePicker.minutes","Minutes")),!this._clockOpen)return;let t=e?this._display.h:this._display.m,s=e?Vd():Bd(),n=qd(s,t,e?24:60),r=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(r.length!==s.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let l of r)l.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...s.map(l=>this._buildMark(l,t,n)))}else s.forEach((l,c)=>this._syncMark(r[c],l,t,n));let o=e&&!$d(t)?"inner":"outer",a=e?t%12*30:t*6;this.refs.hand.dataset.ring=o,this.refs.hand.style.setProperty("--zx-clock-angle",`${a}deg`)}_buildMark(e,t,s){let n=u("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(e.value),ring:e.ring}},e.label);return n.style.setProperty("--zx-clock-angle",`${e.angle}deg`),this._syncMark(n,e,t,s),n}_syncMark(e,t,s,n){e.setAttribute("aria-checked",String(t.value===s)),e.tabIndex=t.value===n?0:-1}_message(e,t){let s=this.msg(e);return s===e?t:s}};function Vd(){let i=[];for(let e=1;e<=12;e+=1)i.push({value:e,label:String(e),angle:e%12*30,ring:"outer"});for(let e=0;e<12;e+=1){let t=e===0?0:12+e;i.push({value:t,label:De(t),angle:e*30,ring:"inner"})}return i}function Bd(){let i=[];for(let e=0;e<60;e+=jd)i.push({value:e,label:De(e),angle:e*6,ring:"outer"});return i}function qd(i,e,t){let s=i[0]?.value??0,n=1/0;for(let{value:r}of i){let o=Math.abs(r-e),a=Math.min(o,t-o);a<n&&(s=r,n=a)}return s}function $d(i){return i>=1&&i<=12}function Vo(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:ot(i.h,0,23),m:ot(i.m,0,59),s:ot(i.s,0,59)}}function ot(i,e,t){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(e,Math.min(t,s)):e}function Hd(i){let e=Math.round(Number(i));return Number.isFinite(e)&&e>0&&e<=59?e:5}function De(i){return String(i).padStart(2,"0")}function Ud(i,e){return i.h===e.h&&i.m===e.m&&i.s===e.s}var at=class extends k{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let e=this.el??u("div");this._min=de(vi(this.options.min)),this._max=de(vi(this.options.max)),this._value=this._normalizeValue(vi(this.options.value)),this._focused=de(this._value)??this._clampFocus(de(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=Yd(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let t=u("div",{class:"zx-date-picker__surface"},u("div",{class:"zx-date-picker__header"},u("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousMonth","Previous month")},x("chevron-left",{size:T.chevron})),u("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),u("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextMonth","Next month")},x("chevron-right",{size:T.chevron}))),u("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},u("div",{class:"zx-date-picker__quick-header"},u("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousYear","Previous year")},x("chevron-left",{size:T.chevron})),u("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),u("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextYear","Next year")},x("chevron-right",{size:T.chevron}))),u("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),u("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:this._message("datePicker.calendar","Calendar")},u("thead",{ref:"weekdays"}),u("tbody",{ref:"days"})));return this._content=t,e.append(t),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",s=>this._onQuickClick(s)),this.listen(this.refs.quickGrid,"keydown",s=>this._onQuickKeydown(s)),this.listen(this.refs.days,"click",s=>this._onDayClick(s)),this.listen(this.refs.days,"keydown",s=>this._onDayKeydown(s)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new wi(null,{value:this._value,seconds:!1}),this._timePicker.on("change",s=>{let n=s.detail.time,r=this._value??this._focused,o=new Date(r.getTime());o.setHours(n.h,n.m,n.s,0),this.set(o)}),t.append(this._timePicker.el)),e}get(){return ln(this._value)}set(e,{silent:t=!1}={}){let s=this._normalizeValue(vi(e));return this._value=s,s&&(this._focused=de(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),t||this.emit("change",{date:ln(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(e){if(!e)return null;let t=new Date(e.getTime()),s=de(t);return this._min&&s<this._min&&Bo(t,this._min),this._max&&s>this._max&&Bo(t,this._max),t}_clampFocus(e){return this._min&&e<this._min?new Date(this._min.getTime()):this._max&&e>this._max?new Date(this._max.getTime()):e}_renderWeekdays(){let e=u("tr");this.options.showWeekNumbers&&e.append(u("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:this._message("datePicker.weekNumber","Week number")},"#"));let t=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=N(t,(this._weekStart+s)%7);e.append(u("th",{scope:"col",ariaLabel:D(n,"%A")},D(n,"%a")))}this.refs.weekdays.replaceChildren(e)}_renderCalendar(){if(!this.refs?.days)return;let e=new Date(this._viewYear,this._viewMonth,1),t=(e.getDay()-this._weekStart+7)%7,s=N(e,-t);this.refs.heading.textContent=D(e,"%B %Y"),this.refs.heading.setAttribute("aria-label",this._message("datePicker.chooseMonthYear","Choose month and year, %1",D(e,"%B %Y")));let n=this._message("datePicker.dayLabel","%e %B %Y"),r=[];for(let a=0;a<6;a+=1){let l=N(s,a*7),c=u("tr");if(this.options.showWeekNumbers){let d=Gd(l);c.append(u("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:this._message("datePicker.week","Week %1",d)},String(d)))}for(let d=0;d<7;d+=1){let h=N(l,d),p=!!(this._value&&Z(h,this._value)),f=!this._inRange(h),m=u("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:Z(h,this._focused)?0:-1,ariaSelected:String(p),ariaDisabled:String(f),ariaCurrent:Z(h,new Date)?"date":null,ariaLabel:D(h,n),dataset:{date:D(h,"%Y-%m-%d"),otherMonth:h.getMonth()===this._viewMonth?null:"true"}},D(h,"%e"));c.append(u("td",{role:"presentation"},m))}r.push(c)}let o=Kd(this.refs.days);this.refs.days.replaceChildren(...r),o&&this._buttonForDate(this._focused)?.focus(),this._quickOpen&&this._renderQuickPick()}_onDayClick(e){let t=e.target?.closest?.("[data-date]");if(!t||!this.refs.days.contains(t))return;let s=ge(t.dataset.date,"%Y-%m-%d");s&&this._inRange(s)&&this._selectDate(s)}_onDayKeydown(e){let t=e.target?.closest?.("[data-date]");if(!t||!this.refs.days.contains(t))return;let s=ge(t.dataset.date,"%Y-%m-%d");if(!s)return;let n=null;if(e.key==="ArrowLeft")n=N(s,-1);else if(e.key==="ArrowRight")n=N(s,1);else if(e.key==="ArrowUp")n=N(s,-7);else if(e.key==="ArrowDown")n=N(s,7);else if(e.key==="PageUp")n=Be(s,e.shiftKey?-12:-1);else if(e.key==="PageDown")n=Be(s,e.shiftKey?12:1);else if(e.key==="Home")n=N(s,-((s.getDay()-this._weekStart+7)%7));else if(e.key==="End")n=N(s,6-(s.getDay()-this._weekStart+7)%7);else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._inRange(s)&&this._selectDate(s);return}n&&(e.preventDefault(),this._moveFocus(n))}_moveFocus(e){let t=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._focused=de(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),t&&this._emitMonthChange(),this._buttonForDate(e)?.focus()}_selectDate(e){let t=new Date(e.getTime()),s=this._timePicker?.get();s?t.setHours(s.h,s.m,s.s,0):this._value&&t.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let n=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._value=t,this._focused=de(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._timePicker?.set(t,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:ln(t)})}_pageMonth(e){this._closeQuickPick();let t=Be(this._focused,e);this._focused=de(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"),(this._focused.getFullYear()!==this._viewYear||this._focused.getMonth()!==this._viewMonth)&&(this._focused=new Date(this._viewYear,this._viewMonth,Math.min(this._focused.getDate(),new Date(this._viewYear,this._viewMonth+1,0).getDate()))),this._renderCalendar())}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let e=[];for(let t=0;t<12;t+=1){let s=new Date(this._viewYear,t,1);t%3===0&&e.push(u("div",{class:"zx-date-picker__quick-row",role:"row"})),e[e.length-1].append(u("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:t===this._viewMonth?0:-1,ariaSelected:String(t===this._viewMonth),dataset:{month:t}},D(s,"%b")))}this.refs.quickGrid.replaceChildren(...e)}_stepQuickYear(e){this._viewYear+=e,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(e){let t=e.target?.closest?.("[data-month]");!t||!this.refs.quickGrid.contains(t)||this._chooseQuickMonth(Number(t.dataset.month))}_onQuickKeydown(e){let t=e.target?.closest?.("[data-month]");if(!t||!this.refs.quickGrid.contains(t))return;let s=Number(t.dataset.month),n=null;if(e.key==="ArrowLeft")n=s-1;else if(e.key==="ArrowRight")n=s+1;else if(e.key==="ArrowUp")n=s-3;else if(e.key==="ArrowDown")n=s+3;else if(e.key==="Home")n=0;else if(e.key==="End")n=11;else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._chooseQuickMonth(s);return}else if(e.key==="Escape"){e.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(n===null)return;e.preventDefault(),n=Math.max(0,Math.min(11,n));let r=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of r)o.tabIndex=Number(o.dataset.month)===n?0:-1;r[n]?.focus()}_chooseQuickMonth(e){let t=new Date(this._viewYear,e,Math.min(this._focused.getDate(),new Date(this._viewYear,e+1,0).getDate()));this._focused=de(t),this._viewMonth=e,this._closeQuickPick(),this._emitMonthChange(),this.focus()}_inRange(e){let t=de(e);return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_buttonForDate(e){return this.refs.days.querySelector(`[data-date="${D(e,"%Y-%m-%d")}"]`)}_message(e,t,...s){let n=this.msg(e,...s);return n===e?q(t,s):n}};function vi(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function de(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function Kd(i){let e=i.getRootNode?.()?.activeElement;return!!e&&i.contains(e)}function ln(i){return i?new Date(i.getTime()):null}function Bo(i,e){i.setFullYear(e.getFullYear(),e.getMonth(),e.getDate())}function Yd(i){let e=Number(i);return Number.isInteger(e)&&e>=0&&e<=6?e:yi()}function Wd(i){let e=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let s=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-s.getTime())/864e5+1)/7)}function Gd(i){return Wd(N(i,(4-i.getDay()+7)%7))}var Ai=class extends at{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(e,t={}){super(e,t)}render(){let e=this.el??u("div");this._min=Si(xi(this.options.min)),this._max=Si(xi(this.options.max)),this._value=this._normalizeMonth(xi(this.options.value));let t=this._value??Si(new Date);this._year=t.getFullYear(),this._focusedMonth=t.getMonth();let s=u("div",{class:"zx-month-picker__surface"},u("div",{class:"zx-month-picker__header"},u("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.previousYear","Previous year")},x("chevron-left",{size:T.chevron})),u("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),u("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.nextYear","Next year")},x("chevron-right",{size:T.chevron}))),u("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:this._message("monthPicker.chooseMonth","Choose month")}));return this._content=s,e.append(s),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",n=>this._onMonthClick(n)),this.listen(this.refs.grid,"keydown",n=>this._onMonthKeydown(n)),this._renderMonths(),e}get(){return this._value?new Date(this._value.getTime()):null}set(e,{silent:t=!1}={}){return this._value=this._normalizeMonth(xi(e)),this._value&&(this._year=this._value.getFullYear(),this._focusedMonth=this._value.getMonth()),this._renderMonths(),t||this.emit("change",{date:this.get()}),this}focus(){return this._button(this._focusedMonth)?.focus(),this}destroy(){this._content?.remove(),super.destroy()}_normalizeMonth(e){if(!e)return null;let t=Si(e);return this._min&&t<this._min&&(t=new Date(this._min.getTime())),this._max&&t>this._max&&(t=new Date(this._max.getTime())),t}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let e=[];for(let s=0;s<12;s+=1){let n=new Date(this._year,s,1),r=!!(this._value&&Qd(n,this._value));s%3===0&&e.push(u("div",{class:"zx-month-picker__row",role:"row"})),e[e.length-1].append(u("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:s===this._focusedMonth?0:-1,ariaSelected:String(r),ariaDisabled:String(!this._inRange(n)),ariaLabel:D(n,"%B %Y"),dataset:{month:s}},D(n,"%b")))}let t=Zd(this.refs.grid);this.refs.grid.replaceChildren(...e),t&&this._button(this._focusedMonth)?.focus()}_stepYear(e){this._year+=e,this._renderMonths()}_onMonthClick(e){let t=e.target?.closest?.("[data-month]");!t||!this.refs.grid.contains(t)||this._selectMonth(Number(t.dataset.month))}_onMonthKeydown(e){let t=e.target?.closest?.("[data-month]");if(!t||!this.refs.grid.contains(t))return;let s=Number(t.dataset.month),n=null;if(e.key==="ArrowLeft")n=-1;else if(e.key==="ArrowRight")n=1;else if(e.key==="ArrowUp")n=-3;else if(e.key==="ArrowDown")n=3;else if(e.key==="Home")n=-(s%3);else if(e.key==="End")n=2-s%3;else if(e.key==="PageUp"){e.preventDefault(),this._stepYear(-1),this.focus();return}else if(e.key==="PageDown"){e.preventDefault(),this._stepYear(1),this.focus();return}else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._selectMonth(s);return}if(n===null)return;e.preventDefault();let r=this._year*12+s+n;this._year=Math.floor(r/12),this._focusedMonth=(r%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(e){let t=new Date(this._year,e,1);this._inRange(t)&&(this._focusedMonth=e,this._value=t,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(e){return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_button(e){return this.refs.grid.querySelector(`[data-month="${e}"]`)}};function xi(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Si(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function Zd(i){let e=i.getRootNode?.()?.activeElement;return!!e&&i.contains(e)}function Qd(i,e){return i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()}function qo(){E.register("month",(i,e)=>{let t=i.own(new Ai(null,{...e.props??{},value:e.value})),s=!1,n=()=>{t.el.setAttribute("aria-disabled",String(s));for(let r of t.el.querySelectorAll("button"))r.disabled=s};return i.listen(t.el,"change",r=>r.stopImmediatePropagation()),t.on("change",r=>i.emit("change",{value:r.detail.date})),{el:t.el,get:()=>t.get(),set:r=>{t.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>t.focus(),setDisabled:r=>{s=!!r,n()}}})}var Jd=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function ae(i,e,t={}){if(!(i instanceof Element)||!(e instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=Jd.has(t.placement)?t.placement:"bottom-start",n=Number(t.offset??4),r=t.flip??!0,o=t.matchWidth??!1,a=e.getAttribute("style"),l=e.getAttribute("popover"),c=!1,d=null,h=()=>{},p=()=>{};e.setAttribute("popover","manual");let f=typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a"),m=`--${z("zx-a")}`;if(f){let g=$o(i);i.style.setProperty("anchor-name",[...g,m].join(", ")),e.style.position="fixed",e.style.inset="auto",e.style.margin="0",e.style.setProperty("position-anchor",m);let _=Xd(s,getComputedStyle(i).direction==="rtl");e.style.setProperty("position-area",_),e.style.setProperty("inset-area",_),e.style.setProperty("position-try-fallbacks",r?"flip-block, flip-inline, flip-block flip-inline":"none");let y=s.startsWith("top")?"margin-bottom":s.startsWith("bottom")?"margin-top":s.startsWith("left")?"margin-right":"margin-left";e.style.setProperty(y,`${n}px`),h=()=>{o&&(e.style.minWidth=`${i.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(d=new ResizeObserver(h),d.observe(i))}else e.style.position="fixed",e.style.inset="auto",e.style.margin="0",h=()=>eh(i,e,{placement:s,offset:n,flip:r,matchWidth:o}),window.addEventListener("scroll",h,{capture:!0,passive:!0}),window.addEventListener("resize",h,{passive:!0}),typeof ResizeObserver=="function"&&(d=new ResizeObserver(h),d.observe(i)),p=()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)};return th(e),h(),{update(){c||h()},destroy(){if(!c){if(c=!0,d?.disconnect(),p(),ih(e),f){let g=$o(i).filter(_=>_!==m);g.length?i.style.setProperty("anchor-name",g.join(", ")):i.style.removeProperty("anchor-name"),i.getAttribute("style")===""&&i.removeAttribute("style")}fi(e,a),sh(e,"popover",l)}}}}function $o(i){return String(i.style?.getPropertyValue("anchor-name")??"").split(",").map(e=>e.trim()).filter(e=>e&&e!=="none")}function Xd(i,e){return{"bottom-start":e?"bottom span-left":"bottom span-right","bottom-end":e?"bottom span-right":"bottom span-left","top-start":e?"top span-left":"top span-right","top-end":e?"top span-right":"top span-left","right-start":"right span-bottom","right-end":"right span-top","left-start":"left span-bottom","left-end":"left span-top",bottom:"bottom",top:"top",right:"right",left:"left"}[i]}function eh(i,e,{placement:t,offset:s,flip:n,matchWidth:r}){let o=i.getBoundingClientRect();r&&(e.style.minWidth=`${o.width}px`);let a=e.getBoundingClientRect(),l=document.documentElement.clientWidth||window.innerWidth,c=document.documentElement.clientHeight||window.innerHeight,d=t,h=Ho(t),p=o.bottom+s,f=o.top-s-a.height,m=o.right+s,g=o.left-s-a.width;n&&(h==="bottom"&&p+a.height>c&&f>=0?d=ki(t,"bottom","top"):h==="top"&&f<0&&p+a.height<=c?d=ki(t,"top","bottom"):h==="right"&&m+a.width>l&&g>=0?d=ki(t,"right","left"):h==="left"&&g<0&&m+a.width<=l&&(d=ki(t,"left","right")));let _=Ho(d),y,b;if(_==="bottom"||_==="top"){let w=getComputedStyle(i).direction==="rtl";d.endsWith("-end")?y=w?o.left:o.right-a.width:d.endsWith("-start")?y=w?o.right-a.width:o.left:y=o.left+(o.width-a.width)/2,b=_==="bottom"?p:f}else y=_==="right"?m:g,d.endsWith("-end")?b=o.bottom-a.height:d.endsWith("-start")?b=o.top:b=o.top+(o.height-a.height)/2;e.style.left=`${Math.round(Tt(y,0,Math.max(0,l-a.width)))}px`,e.style.top=`${Math.round(Tt(b,0,Math.max(0,c-a.height)))}px`}function Ho(i){return i.split("-")[0]}function ki(i,e,t){return i.replace(e,t)}function th(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function ih(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function sh(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}var nh=6,Zo=864e5;function Nt(i,e){let t=ie(qe(i)),s=ie(qe(e));return t&&s&&t.getTime()>s.getTime()?{start:s,end:t}:{start:t,end:s}}function Ci(i,e){let t=Nt(i,e);return!t.start||!t.end?0:Math.round((Yo(t.end)-Yo(t.start))/Zo)}function rh(i,e,t){let s=ie(qe(i));if(!s)return null;let n=Nt(e,t);return!n.start&&!n.end?null:n.end?n.start?s.getTime()<n.start.getTime()||s.getTime()>n.end.getTime()?null:Z(s,n.start)?"start":Z(s,n.end)?"end":"middle":Z(s,n.end)?"end":null:Z(s,n.start)?"start":null}function zi(i,e={}){let t=ie(qe(e.min)),s=ie(qe(e.max)),n=Ti(e.minNights)??0,r=Ti(e.maxNights),{start:o,end:a}=Nt(i?.start,i?.end);return o&&(o=un(o,t,s)),a&&(a=un(a,t,s)),!o||!a?{start:o,end:a}:(r!==null&&Ci(o,a)>r&&(a=N(o,r)),n>0&&Ci(o,a)<n&&(a=N(o,n),s&&a.getTime()>s.getTime()&&(a=new Date(s.getTime()),o=N(a,-n),t&&o.getTime()<t.getTime()))?{start:null,end:null}:{start:o,end:a})}var Ei=class extends k{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let e=this.el??u("div");this.el=e,this._rootAttributes=hh(e,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=ie(qe(this.options.min)),this._max=ie(qe(this.options.max)),this._minNights=Ti(this.options.minNights)??0,this._maxNights=Ti(this.options.maxNights),this._weekStart=ch(this.options.weekStart),this._monthCount=uh(this.options.months),this._presets=lh(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let t=zi({start:this.options.start,end:this.options.end},this._bounds());this._start=t.start,this._end=t.end,this._picking=!!(t.start&&!t.end),this._remember(),this._focused=Oe(this._start)??this._clampFocus(ie(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),e.setAttribute("role","group"),e.setAttribute("aria-label",P("daterange.label","Date range")),e.dataset.months=String(this._monthCount),this._presets.length&&(e.dataset.presets="true");let s=u("div",{class:"zx-date-range-picker__surface"},this._presets.length?u("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:P("daterange.presets","Date range presets")},this._presets.map(r=>u("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,u("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=u("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[s,n],e.append(s,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),e}get(){return{start:Oe(this._start),end:Oe(this._end)}}set(e={},{silent:t=!1}={}){let s=zi({start:e?.start??null,end:e?.end??null},this._bounds());return this._start=s.start,this._end=s.end,this._picking=!!(s.start&&!s.end),this._remember(),this._hover=null,s.start?(this._focused=Oe(s.start),this._setView(s.start)):this._paint(),this._announce(),t||this.emit("change",this.get()),this}clear({silent:e=!1}={}){return this.set({start:null,end:null},{silent:e})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let e of this._nodes??[])e.remove();this._nodes=[],this._dayCells=[],fh(this.el,this._rootAttributes??new Map),super.destroy()}_bounds(){return{min:this._min,max:this._max,minNights:this._minNights,maxNights:this._maxNights}}_selectable(e){let t=ie(e);if(!t||this._min&&t.getTime()<this._min.getTime()||this._max&&t.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||t.getTime()<=this._start.getTime())return!0;let s=Ci(this._start,t);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(e){let t=ie(e);if(this._disabled||!t||!this._selectable(t))return;this._picking&&this._start&&t.getTime()>this._start.getTime()?(this._end=t,this._picking=!1,this._remember()):(this._start=t,this._end=null,this._picking=!0),this._focused=t,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),this._picking||this.emit("change",this.get())}_remember(){let e=!!(this._start&&this._end);this._committedStart=e?Oe(this._start):null,this._committedEnd=e?Oe(this._end):null}_abandon(){return this._picking?(this._start=Oe(this._committedStart),this._end=Oe(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(e){return un(e,this._min,this._max)}_visibleMonthCount(){let e=this.refs.calendars?.children??[],t=0;for(let s of e)s.getClientRects().length>0&&(t+=1);return t||this._monthCount}_setView(e){let t=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;if(this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),!t){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(e){let t=this._visibleMonthCount(),s=Wo(e)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<t)return!1;let n=s<0?s:s-(t-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.getMonth(),!0}_pageView(e){if(this._disabled)return;let t=new Date(this._viewYear,this._viewMonth+e,1);this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(e){let t=this._visibleMonthCount(),s=Wo(e)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<t)return e;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(e.getDate(),n))}_moveFocus(e){let t=ie(e);this._focused=t,this._ensureVisible(t)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(t)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(e){let t=e.target?.closest?.("[data-preset]");if(!t||this._disabled)return;let s=this._presets.find(r=>r.name===t.dataset.preset);if(!s)return;let n=s.range();this.set({start:n?.start??null,end:n?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(e){let t=e.target,s=t?.closest?.("[data-nav]");if(s){this._pageView(s.dataset.nav==="next"?1:-1);return}let n=this._cellFor(t);n&&this._choose(n.date)}_onDayHover(e){let t=this._cellFor(e.target);this._setHover(t?t.date:null)}_setHover(e){if(this._disabled||!this._picking)return;let t=e?ie(e):null;!t&&!this._hover||t&&this._hover&&Z(t,this._hover)||(this._hover=t,this._paint())}_onDayKeydown(e){let t=this._cellFor(e.target);if(!t)return;let s=t.date,n=null;if(e.key==="ArrowLeft")n=N(s,-1);else if(e.key==="ArrowRight")n=N(s,1);else if(e.key==="ArrowUp")n=N(s,-7);else if(e.key==="ArrowDown")n=N(s,7);else if(e.key==="PageUp")n=Be(s,e.shiftKey?-12:-1);else if(e.key==="PageDown")n=Be(s,e.shiftKey?12:1);else if(e.key==="Home")n=N(s,-((s.getDay()-this._weekStart+7)%7));else if(e.key==="End")n=N(s,6-(s.getDay()-this._weekStart+7)%7);else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._choose(s);return}else if(e.key==="Escape"){if(!this._abandon())return;e.preventDefault(),e.stopPropagation();return}!n||this._disabled||(e.preventDefault(),this._moveFocus(n))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let e=[];for(let t=0;t<this._monthCount;t+=1)e.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+t,1)));this.refs.calendars.replaceChildren(...e),this._paint(),this._syncDisabled()}_renderMonth(e){let t=D(e,"%B %Y"),s=(e.getDay()-this._weekStart+7)%7,n=N(e,-s),r=[];for(let o=0;o<nh;o+=1){let a=N(n,o*7),l=u("tr"),c=dh(a,e);this.options.showWeekNumbers&&l.append(u("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:c?P("daterange.week","Week %1",[Go(a)]):null},c?String(Go(a)):""));for(let d=0;d<7;d+=1){let h=N(a,d),p=u("td",{role:"presentation"});if(h.getMonth()===e.getMonth()&&h.getFullYear()===e.getFullYear()){let f=u("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:D(h,"%Y-%m-%d")}},D(h,"%e"));p.append(f),this._dayCells.push({date:h,cell:p,button:f})}l.append(p)}r.push(l)}return u("div",{class:"zx-date-range-picker__month"},u("div",{class:"zx-date-range-picker__header"},u("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:P("daterange.previousMonth","Previous month")},x("chevron-left",{size:T.chevron})),u("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},t),u("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:P("daterange.nextMonth","Next month")},x("chevron-right",{size:T.chevron}))),u("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:t},u("thead",{},this._weekdayRow()),u("tbody",{},...r)))}_weekdayRow(){let e=u("tr");this.options.showWeekNumbers&&e.append(u("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:P("daterange.weekNumber","Week number")},"#"));let t=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=N(t,(this._weekStart+s)%7);e.append(u("th",{scope:"col",ariaLabel:D(n,"%A")},D(n,"%a")))}return e}_paint(){let e=new Date,t=null;for(let s of this._dayCells)Z(s.date,this._focused)&&(t=s);t||(t=this._dayCells[0]??null);for(let s of this._dayCells){let{date:n,cell:r,button:o}=s,a=this._dayState(n);cn(r,"range",a.range),cn(r,"rangeEdge",a.edge),cn(o,"range",a.range),o.tabIndex=s===t?0:-1,o.setAttribute("aria-selected",String(a.range!==null&&a.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),Z(n,e)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(e){if(this._start&&this._end){let s=rh(e,this._start,this._end);if(!s)return{range:null,edge:null};let n=Z(this._start,this._end);return s==="start"?{range:s,edge:n?"both":"start"}:s==="end"?{range:s,edge:n?"both":"end"}:{range:s,edge:null}}if(!this._start)return{range:null,edge:null};let t=this._previewEnd();return Z(e,this._start)?{range:"start",edge:t?"start":"both"}:t?e.getTime()>this._start.getTime()&&e.getTime()<=t.getTime()?{range:"preview",edge:Z(e,t)?"end":null}:{range:null,edge:null}:{range:null,edge:null}}_previewEnd(){if(!this._picking||!this._start||this._disabled)return null;let e=this._hover??this._focused;if(!e)return null;let t=ie(e);return t.getTime()<=this._start.getTime()?null:this._selectable(t)?t:null}_dayLabel(e,t){let s=D(e,P("daterange.dayLabel","%A, %e %B %Y"));return t==="start"?`${s}, ${P("daterange.day.start","range start")}`:t==="end"?`${s}, ${P("daterange.day.end","range end")}`:t==="middle"?`${s}, ${P("daterange.day.middle","in selected range")}`:s}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let e of this.el.querySelectorAll("button"))e.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return P("daterange.status.empty","No date range selected");if(!this._end)return P("daterange.status.start","%1 selected, choose an end date",[D(this._start,P("daterange.span.full","%e %B %Y"))]);let e=Ci(this._start,this._end),t=e===1?P("daterange.night","1 night"):P("daterange.nights","%1 nights",[e]);return`${ah(this._start,this._end)}, ${t}`}_cellFor(e){let t=e?.closest?.("[data-date]");return t?this._dayCells.find(s=>s.button===t)??null:null}_buttonForDate(e){return this._dayCells.find(t=>Z(t.date,e))?.button??null}};function oh(){return[{name:"today",label:P("daterange.preset.today","Today"),range:()=>Uo(_e())},{name:"yesterday",label:P("daterange.preset.yesterday","Yesterday"),range:()=>Uo(N(_e(),-1))},{name:"last7",label:P("daterange.preset.last7","Last 7 days"),range:()=>({start:N(_e(),-6),end:_e()})},{name:"last30",label:P("daterange.preset.last30","Last 30 days"),range:()=>({start:N(_e(),-29),end:_e()})},{name:"thisMonth",label:P("daterange.preset.thisMonth","This month"),range:()=>Ko(_e(),0)},{name:"lastMonth",label:P("daterange.preset.lastMonth","Last month"),range:()=>Ko(_e(),-1)},{name:"thisQuarter",label:P("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=_e(),e=Math.floor(i.getMonth()/3)*3;return{start:new Date(i.getFullYear(),e,1),end:new Date(i.getFullYear(),e+3,0)}}},{name:"thisYear",label:P("daterange.preset.thisYear","This year"),range:()=>{let i=_e();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function P(i,e,t){let s=V(i);return q(s===i?e:s,t)}function ah(i,e){let t=P("daterange.span.full","%e %B %Y");if(Z(i,e))return D(i,t);let s=D(e,t);return i.getFullYear()!==e.getFullYear()?`${D(i,t)} \u2013 ${s}`:i.getMonth()!==e.getMonth()?`${D(i,P("daterange.span.month","%e %B"))} \u2013 ${s}`:`${D(i,P("daterange.span.day","%e"))} \u2013 ${s}`}function lh(i){return i===!0?oh():Array.isArray(i)?i.filter(e=>e&&typeof e.range=="function").map((e,t)=>({name:String(e.name??`preset-${t}`),label:String(e.label??e.name??""),range:e.range})):[]}function _e(){return ie(new Date)}function Uo(i){return{start:i,end:new Date(i.getTime())}}function Ko(i,e){return{start:new Date(i.getFullYear(),i.getMonth()+e,1),end:new Date(i.getFullYear(),i.getMonth()+e+1,0)}}function qe(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function ie(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function Oe(i){return i?new Date(i.getTime()):null}function un(i,e,t){return e&&i.getTime()<e.getTime()?new Date(e.getTime()):t&&i.getTime()>t.getTime()?new Date(t.getTime()):new Date(i.getTime())}function Yo(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function Wo(i){return i.getFullYear()*12+i.getMonth()}function Ti(i){if(i==null||i==="")return null;let e=Number(i);return Number.isFinite(e)?Math.max(0,Math.trunc(e)):null}function ch(i){let e=Number(i);return Number.isInteger(e)&&e>=0&&e<=6?e:yi()}function uh(i){let e=Number(i);return Number.isInteger(e)&&e>=1&&e<=4?e:2}function dh(i,e){for(let t=0;t<7;t+=1){let s=N(i,t);if(s.getMonth()===e.getMonth()&&s.getFullYear()===e.getFullYear())return!0}return!1}function Go(i){let e=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let s=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-s.getTime())/Zo+1)/7)}function cn(i,e,t){t==null?delete i.dataset[e]:i.dataset[e]=t}function hh(i,e){return new Map(e.map(t=>[t,i.getAttribute(t)]))}function fh(i,e){for(let[t,s]of e)s===null?i.removeAttribute(t):i.setAttribute(t,s)}function Mi(i){return{"%d":i("datebox.placeholder.day"),"%e":i("datebox.placeholder.dayShort"),"%m":i("datebox.placeholder.month"),"%Y":i("datebox.placeholder.year"),"%y":i("datebox.placeholder.yearShort"),"%H":i("datebox.placeholder.hour"),"%M":i("datebox.placeholder.minute"),"%S":i("datebox.placeholder.second")}}function Qo(i,e,t){let s=String(i??"").trim();if(s==="")return{start:null,end:null};let n=String(t??" \u2013 "),r=n.trim(),o=r!==""&&String(e).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",l=o?"(?:\\s+|$)":"\\s*",c=r===""?[s]:s.split(new RegExp(`${a}${Ys(r)}${l}`));if(c.length>2)return null;let d=ge(c[0].trim(),e);if(!d)return null;if(c.length===1)return{start:d,end:new Date(d.getTime())};if(c[1].trim()==="")return{start:d,end:null};let h=ge(c[1].trim(),e);return h?Nt(d,h):null}function Jo(i,e,t){let s=i?.start??null,n=i?.end??null;return!s&&!n?"":n?s?`${D(s,e)}${t}${D(n,e)}`:D(n,e):D(s,e)}var Di=class extends k{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",displayFormat:null,separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let e=this.el??u("div");this.el=e,this._originalState=e.getAttribute("data-state"),this._originalAriaDisabled=e.getAttribute("aria-disabled"),this._originalClearable=e.getAttribute("data-clearable"),e.toggleAttribute("data-clearable",!!this.options.clearable),this._format=String(this.options.format||"%d.%m.%Y"),this._displayFormat=this.options.displayFormat?String(this.options.displayFormat):this._format,this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._focused=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let t=z("zx-date-range-box-popover"),s=u("div",{class:"zx-date-range-box__content"},u("div",{ref:"control",class:"zx-date-range-box__control"},u("input",{ref:"input",class:"zx-date-range-box__input",type:"text",role:"combobox",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"dialog",ariaControls:t,ariaExpanded:"false"}),u("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:dn("daterange.clear","Clear date range")},x("x",{size:T.dismiss})),u("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:dn("daterange.choose","Choose date range"),"aria-haspopup":"dialog",ariaControls:t,ariaExpanded:"false"},x("calendar"))),u("div",{ref:"popover",id:t,class:"zx-date-range-box__popover",role:"dialog",ariaLabel:dn("daterange.choose","Choose date range"),popover:"manual",dataset:{state:"closed"}}));return this._content=s,e.append(s),this._picker=new Ei(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",n=>{this._range={start:n.detail.start,end:n.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",n=>{this._apply({start:n.detail.start,end:n.detail.end},{push:!1}),n.detail.start&&n.detail.end&&this._close(!0)}),this.listen(this.refs.input,"focus",()=>{this._focused=!0,this.el.dataset.state!=="invalid"&&this._syncDisplay()}),this.listen(this.refs.input,"blur",()=>{this._focused=!1,this._open?this.refs.input.value===Jo(this._range,this._format,this._separator)&&this._syncDisplay():this._commitText()}),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!e.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),e}get(e="date"){return e==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(e,{silent:t=!1}={}){return this._apply(this._coerce(e),{silent:t}),this}clear({silent:e=!1}={}){return this.set({start:null,end:null},{silent:e})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=ae(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),Ii(this.el,"data-state",this._originalState),Ii(this.el,"aria-disabled",this._originalAriaDisabled),Ii(this.el,"data-clearable",this._originalClearable),super.destroy()}_apply(e,{silent:t=!1,push:s=!0}={}){this._range=e,s&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),t||this.emit("change",this.get())}_onInputKeydown(e){e.key==="ArrowDown"?(e.preventDefault(),this.open()):e.key==="Enter"?(e.preventDefault(),this._commitText()):e.key==="Escape"&&this._open&&(e.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let e=this.refs.input.value.trim();if(e===""){this.set({start:null,end:null});return}let t=Qo(e,this._format,this._separator);if(!t){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:e});return}this._apply(this._clamp(t))}_coerce(e){return e==null?{start:null,end:null}:typeof e=="string"?this._clamp(Qo(e,this._format,this._separator)??{start:null,end:null}):Array.isArray(e)?this._clamp({start:this._toDate(e[0]),end:this._toDate(e[1])}):typeof e!="object"?{start:null,end:null}:this._clamp({start:this._toDate(e.start),end:this._toDate(e.end)})}_toDate(e){return e instanceof Date?Number.isNaN(e.getTime())?null:new Date(e.getTime()):typeof e=="number"&&Number.isFinite(e)?new Date(e*1e3):typeof e=="string"&&e.trim()!==""?ge(e.trim(),this._format):null}_clamp(e){return zi(e,{min:this.options.min,max:this.options.max,minNights:this.options.minNights,maxNights:this.options.maxNights})}_placeholder(){let e=Mi(s=>this.msg(s)),t=this._format.replace(/%[demYy]/g,s=>e[s]??s);return`${t}${this._separator}${t}`}_syncDisplay(){let e=this.refs.input,t=this._focused?this._format:this._displayFormat,s=Jo(this._range,t,this._separator);e.value!==s&&(e.value=s),this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!(this._range.start||this._range.end)||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear(),this._disabled?this._picker?.disable():this._picker?.enable()}_setValid(){this.el.dataset.state==="invalid"&&Ii(this.el,"data-state",this._originalState),this.refs.input.removeAttribute("aria-invalid")}_close(e){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),e&&this.focus(),this.emit("close"))}};function dn(i,e,t){let s=V(i);return q(s===i?e:s,t)}function Ii(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}function Xo(){E.register("daterange",(i,e)=>{let t=i.own(new Di(null,{...e.props??{},disabled:!!e.disabled,start:e.value?.start??null,end:e.value?.end??null}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:{start:s.detail.start,end:s.detail.end}})),{el:t.el,get:()=>t.get(),set:s=>t.set(s,{silent:!0}),focus:()=>t.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var $e=class extends k{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",displayFormat:null,time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let e=this.el??u("div");this.el=e,this._originalState=e.getAttribute("data-state"),this._originalAriaDisabled=e.getAttribute("aria-disabled"),this._originalClearable=e.getAttribute("data-clearable"),e.toggleAttribute("data-clearable",!!this.options.clearable);let t=mh(this.options);this._format=t.format,this._displayFormat=t.display,this._disabled=!!this.options.disabled,this._open=!1,this._focused=!1,this._position=null,this._min=ea(this.options.min),this._max=ea(this.options.max),this._value=this._normalizeValue(this.options.value);let s=z("zx-datebox-popover"),n=u("div",{class:"zx-datebox__content"},u("div",{ref:"control",class:"zx-datebox__control"},u("input",{ref:"input",class:"zx-datebox__input",type:"text",role:"combobox",autocomplete:"off",placeholder:this.options.placeholder??gh(this._format,r=>this.msg(r)),"aria-haspopup":"dialog",ariaControls:s,ariaExpanded:"false"}),u("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:this.msg("datebox.clear")},x("x",{size:T.dismiss})),u("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:this.msg("datebox.choose"),"aria-haspopup":"dialog",ariaControls:s,ariaExpanded:"false"},x("calendar"))),u("div",{ref:"popover",id:s,class:"zx-datebox__popover",role:"dialog",ariaLabel:this.msg("datebox.choose"),popover:"manual",dataset:{state:"closed"}}));return this._content=n,e.append(n),this._picker=new at(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",r=>{this.set(r.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"focus",()=>{this._focused=!0,this.el.dataset.state!=="invalid"&&this._syncDisplay()}),this.listen(this.refs.input,"blur",()=>{this._focused=!1,this._commitText()}),this.listen(this.refs.input,"keydown",r=>this._onInputKeydown(r)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",r=>{r.key==="ArrowDown"&&(r.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",r=>{!this._open||r.defaultPrevented||r.key!=="Escape"||(r.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",r=>{this._open&&!e.contains(r.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),e}get(e="date"){return this._value?e==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(e,{silent:t=!1}={}){return this._value=this._normalizeValue(e),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),t||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=ae(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),this._originalClearable===null?this.el.removeAttribute("data-clearable"):this.el.setAttribute("data-clearable",this._originalClearable),super.destroy()}_onInputKeydown(e){e.key==="ArrowDown"?(e.preventDefault(),this.open()):e.key==="Enter"?(e.preventDefault(),this._commitText()):e.key==="Escape"&&this._open&&(e.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let e=this.refs.input.value.trim(),t=this._value?D(this._value,this._format):"";if(e===t){this._setValid(),this._syncDisplay();return}let s=e===""?null:ge(e,this._format);if(e!==""&&!s){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:e});return}let n=this._normalizeValue(s),r=(n?.getTime()??null)===(this._value?.getTime()??null);this.set(n,{silent:r})}_normalizeValue(e){let t=null;return e instanceof Date&&!Number.isNaN(e.getTime())?t=new Date(e.getTime()):typeof e=="number"&&Number.isFinite(e)?t=new Date(e*1e3):typeof e=="string"&&(t=ge(e,this._format)),!t||Number.isNaN(t.getTime())?null:ph(t,this._min,this._max)}_syncDisplay(){let e=this.refs.input,t=this._focused?this._format:this._displayFormat,s=this._value?D(this._value,t):"";e.value!==s&&(e.value=s),this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!this._value||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear()}_setValid(){this.el.dataset.state==="invalid"&&(this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState)),this.refs.input.removeAttribute("aria-invalid")}_close(e){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),e&&this.focus(),this.emit("close"))}_copyValue(){return this._value?new Date(this._value.getTime()):null}},ia=function(e,t={}){return new $e(e,{...t,time:!0})};function ea(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function ph(i,e,t){let s=hn(i),n=e&&s<hn(e)?e:t&&s>hn(t)?t:null;return n&&i.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),i}function hn(i){return new Date(i.getFullYear(),i.getMonth(),i.getDate()).getTime()}function mh({format:i=null,displayFormat:e=null,time:t=!1}={}){let s=ta(i,t);return{format:s,display:e?ta(e,t):s}}function ta(i,e){let t=String(i||"%d.%m.%Y");return e&&!/%[HM]/.test(t)?`${t} %H:%M`:t}function gh(i,e){let t=Mi(e);return i.replace(/%[demYyHMS]/g,s=>t[s]??s)}function na(){sa("date",i=>new $e(null,i)),sa("datetime",i=>ia(null,i))}function sa(i,e){E.register(i,(t,s)=>{let n=t.own(e({...s.props??{},value:s.value}));return t.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>t.emit("change",{value:r.detail.date})),{el:n.el,get:()=>n.get(),set:r=>n.set(r,{silent:!0}),focus:()=>n.focus(),setDisabled:r=>r?n.disable():n.enable()}})}var Rt=class{base;headers;onError;timeout;constructor({base:e="",headers:t={},onError:s=null,timeout:n=3e4}={}){this.base=String(e),this.headers=Object.freeze({...t}),this.onError=s,this.timeout=Number(n)}async request(e,t={}){let{method:s="GET",data:n=null,files:r=null,query:o=null,headers:a={},signal:l=null,paramName:c="files"}=t,d=new AbortController,h=()=>d.abort(l?.reason);l?.aborted?h():l?.addEventListener("abort",h,{once:!0});let p=this.timeout>0?setTimeout(()=>{d.abort(new DOMException("Request timed out","TimeoutError"))},this.timeout):null;try{d.signal.throwIfAborted();let f=new Headers(this.headers);for(let[v,A]of Object.entries(a))f.set(v,A);f.set("Accept",f.get("Accept")??"application/json");let m;r!==null?(m=bh(n,r,String(c)),f.delete("Content-Type")):n!==null&&s.toUpperCase()!=="GET"&&s.toUpperCase()!=="HEAD"&&(m=JSON.stringify(n),f.set("Content-Type",f.get("Content-Type")??"application/json"));let g=_h(this.base+e,o),_=await fetch(g,{method:s.toUpperCase(),headers:f,body:m,signal:d.signal}),y=await _.text();d.signal.throwIfAborted();let b=null,w=null;if(y!=="")try{b=JSON.parse(y)}catch(v){w=v}if(!_.ok){if(w===null)try{Oi(b)}catch(A){throw A.response=_,A}let v=new Error(`HTTP ${_.status} ${_.statusText}`.trim());throw v.response=_,v}if(w!==null){let v=new Error("Invalid JSON response",{cause:w});throw v.response=_,v}return Oi(b)}catch(f){let m=f instanceof Error?f:new Error(String(f));if(this.onError)try{this.onError(m,{path:e,options:t})}catch{}throw m}finally{p!==null&&clearTimeout(p),l?.removeEventListener("abort",h)}}get(e,t=null){return this.request(e,{method:"GET",query:t})}post(e,t=null){return this.request(e,{method:"POST",data:t})}put(e,t=null){return this.request(e,{method:"PUT",data:t})}delete(e,t=null){return this.request(e,{method:"DELETE",data:t})}};function Oi(i){if(i&&typeof i=="object"){if(Object.prototype.hasOwnProperty.call(i,"error")&&i.error!=null&&i.error!==!1&&i.error!==0){let e=typeof i.error=="string"?i.error:JSON.stringify(i.error);throw new Error(e||"Server error")}if(Object.prototype.hasOwnProperty.call(i,"result"))return i.result}return i}function _h(i,e){if(e==null)return i;let t;if(typeof e=="string")t=e.replace(/^\?/,"");else if(e instanceof URLSearchParams)t=e.toString();else{let o=new URLSearchParams;for(let[a,l]of Object.entries(e))ra(o,a,l);t=o.toString()}if(!t)return i;let s=i.indexOf("#"),n=s<0?i:i.slice(0,s),r=s<0?"":i.slice(s);return n+(n.includes("?")?"&":"?")+t+r}function ra(i,e,t){if(t!=null)if(Array.isArray(t))for(let s of t)ra(i,e,s);else i.append(e,typeof t=="object"?JSON.stringify(t):String(t))}function bh(i,e,t){let s=new FormData;if(i&&typeof i=="object"&&!Array.isArray(i))for(let[r,o]of Object.entries(i))oa(s,r,o);else i!=null&&s.append("data",typeof i=="string"?i:JSON.stringify(i));let n=yh(e)||Array.isArray(e)?Array.from(e):[e];for(let r of n)s.append(t,r);return s}function oa(i,e,t){if(t!=null)if(Array.isArray(t))for(let s of t)oa(i,e,s);else{let s=typeof Blob=="function"&&t instanceof Blob;i.append(e,typeof t=="object"&&!s?JSON.stringify(t):t)}}function yh(i){return typeof FileList=="function"&&i instanceof FileList}var Ni=class extends k{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let e=this.el??u("div");this.el=e,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=e.getAttribute("data-state"),this._initialDisabled=e.getAttribute("data-disabled");let t=z("zx-upload");return this._input=u("input",{class:"zx-field-upload__input",id:t,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=u("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:t,ariaLabel:this.msg(this.options.multiple?"fieldUpload.chooseMany":"fieldUpload.choose")},u("span",{class:"zx-field-upload__prompt"},this.msg(this.options.multiple?"fieldUpload.dropMany":"fieldUpload.drop")),u("span",{class:"zx-field-upload__hint"},wh(this))),this._preview=u("div",{class:"zx-field-upload__preview"}),this._progress=u("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:this.msg("fieldUpload.progress")}),this._progressText=u("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=u("button",{class:"zx-btn zx-field-upload__abort",type:"button"},this.msg("fieldUpload.abort")),this._progressWrap=u("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=u("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),e.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragover",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragleave",s=>{(!(s.relatedTarget instanceof Node)||!this._dropzone.contains(s.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",s=>{s.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(s.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),e}async upload(e=null){if(e!==null&&!this._setFiles(e)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let t=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent=this.msg("fieldUpload.uploading");try{let s=this.options.http?await this._uploadInjected():await this._uploadXhr();return t!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent=this.msg("fieldUpload.complete"),this.emit("success",{response:s}),s)}catch(s){if(t!==this._runId)return null;let n=s instanceof Error?s:new Error(String(s));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(e){return this._disabled=!!e,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(e){this._setFiles(e)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(e){if(this._disabled||this._running)return!1;let t=Array.from(e??[]),s=this.options.multiple?t:t.slice(0,1);if(s.length===0)return!1;let n=s.find(o=>!xh(o,this.options.accept));if(n)return this._selectionError(new Error(this.msg("fieldUpload.rejectedType",n.name))),!1;let r=this.options.maxSize==null?null:s.find(o=>o.size>Number(this.options.maxSize));return r?(this._selectionError(new Error(this.msg("fieldUpload.rejectedSize",r.name))),!1):(this._files=s,this._renderPreview(),this._status.textContent=s.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(e){e.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let e=this.options.http;if(e instanceof Rt&&e.request===Rt.prototype.request&&typeof e.upload!="function")return this._uploadXhr(e);this._transportController=new AbortController;let t=this._runId,s={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:n=>{this._running&&t===this._runId&&this._setProgress(n)}};return typeof e.upload=="function"?e.upload(String(this.options.url),s):typeof e.request=="function"?e.request(String(this.options.url),{method:"POST",data:s.params,files:s.files,headers:s.headers,signal:s.signal,onProgress:s.onProgress,paramName:s.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}async _uploadXhr(e=null){let t=String(this.options.url),s={method:"POST",data:this.options.params,files:this._files.slice(),headers:this.options.headers,paramName:String(this.options.paramName)},n=this._runId,r=[],o=(a,l,c)=>{this.listen(a,l,c),r.push(()=>a.removeEventListener(l,c))};try{if(typeof XMLHttpRequest!="function")throw new Error("XMLHttpRequest is not available");return await new Promise((a,l)=>{let c=new XMLHttpRequest;this._xhr=c,c.open("POST",(e?.base??"")+t),e&&(c.timeout=e.timeout>0?e.timeout:0);let d=new Headers(e?.headers);for(let[h,p]of Object.entries(s.headers??{}))d.set(h,String(p));e&&!d.has("Accept")&&d.set("Accept","application/json"),d.delete("Content-Type");for(let[h,p]of d)c.setRequestHeader(h,p);o(c.upload,"progress",h=>{this._running&&n===this._runId&&h.lengthComputable&&this._setProgress(h.loaded/h.total*100)}),o(c,"load",()=>{try{let h=Ah(c.responseText);if(e){try{h=c.responseText?JSON.parse(c.responseText):null}catch(p){throw new Error("Invalid JSON response",{cause:p})}h=Oi(h)}if(c.status<200||c.status>=300)throw new Error(this.msg("fieldUpload.httpFailed",c.status));a(h)}catch(h){h.response=c,l(h)}}),o(c,"error",()=>l(new Error(this.msg("fieldUpload.requestFailed")))),o(c,"abort",()=>l(kh())),o(c,"timeout",()=>l(new DOMException("Request timed out","TimeoutError"))),c.send(Sh(s.files,s.paramName,s.data))})}catch(a){try{e?.onError?.(a,{path:t,options:s})}catch{}throw a}finally{for(let a of r)a()}}_setProgress(e){let t=Math.max(0,Math.min(100,Number(e)||0));this._progress.value=t,this._progressText.textContent=`${Math.round(t)}%`,this.emit("progress",{percent:t})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent=this.msg("fieldUpload.aborted"),this.emit("abort",{}))}_selectionError(e){this._setState("error"),this._status.textContent=e.message,this.emit("error",{error:e})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let e=this._files[0];!this.options.preview||!e?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(e),this._preview.append(u("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:this.msg("fieldUpload.preview",e.name)})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(e){e==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=e}destroy(){this._running&&this.abort(),this._revokePreview();for(let e of this._ownedNodes??[])e.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function wh(i){let{accept:e,maxSize:t}=i.options,s=[];return e&&s.push(String(e)),t!=null&&s.push(i.msg("fieldUpload.maxSize",vh(Number(t)))),s.join(" \xB7 ")||i.msg("fieldUpload.hint")}function vh(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function xh(i,e){if(!e)return!0;let t=String(i.type??"").toLowerCase();return String(e).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean).some(s=>s.startsWith(".")?i.name.toLowerCase().endsWith(s):s.endsWith("/*")?t.startsWith(s.slice(0,-1)):t===s)}function Sh(i,e,t){let s=new FormData;for(let n of i)s.append(e,n);for(let[n,r]of Object.entries(t??{}))aa(s,n,r);return s}function aa(i,e,t){if(t==null)return;if(Array.isArray(t)){for(let n of t)aa(i,e,n);return}typeof Blob=="function"&&t instanceof Blob?i.append(e,t):i.append(e,typeof t=="object"?JSON.stringify(t):String(t))}function Ah(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function kh(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function la(){E.register("upload",(i,e)=>{let t=i.own(new Ni(null,{...e.props??{}}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("select",()=>i.emit("change",{value:null})),{el:t.el,get:()=>null,set:()=>t.clear(),focus:()=>t.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:s=>t.setDisabled(s)}})}var ca=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),ua=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),Ri=class extends k{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:null,reorder:"both"};render(){let e=this.el??u("div");return this.el=e,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=e.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=u("div",{class:"zx-multi-value-editor__rows"}),this._add=u("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??this.msg("multiValueEditor.add"))),this._ownedNodes.push(this._rows,this._add),e.append(this._rows,this._add),this.listen(e,"click",t=>this._handleClick(t)),this.listen(this._rows,"change",t=>this._handleChange(t)),this.listen(this._rows,"keydown",t=>this._handleKeydown(t)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",t=>this._handlePointerDown(t)),this.listen(this._rows,"dragstart",t=>this._handleDragStart(t)),this.listen(this._rows,"dragover",t=>this._handleDragOver(t)),this.listen(this._rows,"dragleave",t=>this._handleDragLeave(t)),this.listen(this._rows,"drop",t=>this._handleDrop(t)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),e}getValues(){return this._values.slice()}setValues(e,{silent:t=!1}={}){return this._values=Array.isArray(e)?e.map(String):[],this._renderRows(),t||this.emit("change",{values:this.getValues()}),this}_reorder(){return ca[this.options.reorder]??ca.both}_renderRows(e=-1,t="value"){let s=da(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,l=this._values.map((c,d)=>{let h=!n||s.some(([f])=>f===c)?s:[[c,c],...s],p=n?u("select",{class:"zx-multi-value-editor__value",ariaLabel:this.msg("multiValueEditor.value",d+1),dataset:{index:d}},h.map(([f,m])=>u("option",{value:f,selected:f===c},m))):u("input",{class:"zx-multi-value-editor__value",type:"text",value:c,ariaLabel:this.msg("multiValueEditor.value",d+1),dataset:{index:d}});return u("div",{class:"zx-multi-value-editor__row",dataset:{row:d}},r?u("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:this.msg("multiValueEditor.reorder",d+1),dataset:{action:"grab",index:d}},x("drag",{size:12})):null,p,u("div",{class:"zx-multi-value-editor__controls"},o?u("button",{class:"zx-btn",type:"button",ariaDisabled:String(d===0),ariaLabel:this.msg("multiValueEditor.moveUp",d+1),dataset:{action:"up",index:d}},x("chevron-up",{size:T.chevron})):null,o?u("button",{class:"zx-btn",type:"button",ariaDisabled:String(d===a),ariaLabel:this.msg("multiValueEditor.moveDown",d+1),dataset:{action:"down",index:d}},x("chevron-down",{size:T.chevron})):null,u("button",{class:"zx-btn",type:"button",ariaLabel:this.msg("multiValueEditor.remove",d+1),dataset:{action:"remove",index:d}},x("x",{size:T.dismiss}))))});this._rows.replaceChildren(...l),e>=0&&l[Math.min(e,l.length-1)]?.querySelector(ua[t]??ua.value)?.focus()}_handleClick(e){let t=e.target instanceof Element?e.target.closest("[data-action]"):null;if(!t||!this.el.contains(t)||t.getAttribute("aria-disabled")==="true")return;let s=t.dataset.action,n=Number(t.dataset.index);if(s==="add"){let r=da(this.options.options);this._values.push(this.options.options===null?"":r[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else s==="remove"&&Number.isInteger(n)?(this._values.splice(n,1),this._renderRows(Math.min(n,this._values.length-1)),this._emitChange()):(s==="up"||s==="down")&&Number.isInteger(n)&&this._move(n,n+(s==="up"?-1:1),s)}_handleChange(e){let t=e.target instanceof Element?e.target.closest("[data-index]"):null;if(!t||!("value"in t))return;let s=Number(t.dataset.index);!Number.isInteger(s)||s<0||s>=this._values.length||(this._values[s]=t.value,this._emitChange())}_handleKeydown(e){let t=e.target instanceof Element?e.target.closest(".zx-multi-value-editor__handle"):null;if(!t)return;let s=Number(t.dataset.index),n=e.key==="ArrowUp"?s-1:e.key==="ArrowDown"?s+1:e.key==="Home"?0:e.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(e.preventDefault(),this._move(s,n,"handle"))}_handlePointerDown(e){let t=e.target instanceof Element?e.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!t||t.disabled)return;let s=t.closest(".zx-multi-value-editor__row");s&&(s.draggable=!0,this._armed=s)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(e){let t=e.target instanceof Element?e.target.closest(".zx-multi-value-editor__row"):null;if(!t||t!==this._armed){e.preventDefault();return}this._dragIndex=Number(t.dataset.row),t.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),e.dataTransfer?.setData("text/plain",String(this._dragIndex)),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")}_handleDragOver(e){this._dragIndex<0||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(e.clientY)))}_handleDragLeave(e){let t=e.relatedTarget;t instanceof Node&&this._rows.contains(t)||this._clearDrop()}_handleDrop(e){if(this._dragIndex<0)return;e.preventDefault();let t=this._dragIndex,s=this._dropTarget(e.clientY);this._finishDrag(),this._move(t,s>t?s-1:s,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let e of this._rows.children)delete e.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(e){let t=[...this._rows.children];for(let[s,n]of t.entries()){let r=n.getBoundingClientRect();if(e<r.top+r.height/2)return s}return t.length}_showDrop(e){let t=[...this._rows.children],s=e===this._dragIndex||e===this._dragIndex+1;for(let[n,r]of t.entries()){let o=r;!s&&n===e?o.dataset.drop="before":!s&&e===t.length&&n===t.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let e of this._rows.children)delete e.dataset.drop}_move(e,t,s){let n=this._values.length;if(e===t||e<0||t<0||e>=n||t>=n)return!1;let[r]=this._values.splice(e,1);return this._values.splice(t,0,r),this._renderRows(t,s),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let e of this._ownedNodes??[])e.remove();super.destroy()}};function da(i){return Array.isArray(i)?i.map(e=>[String(e),String(e)]):i&&typeof i=="object"?Object.entries(i).map(([e,t])=>[e,String(t)]):[]}function ha(){E.register("multivalueeditor",(i,e)=>{let t=i.own(new Ri(null,{...e.props??{},values:Array.isArray(e.value)?e.value:[]})),s=new WeakMap,n=!1,r=()=>{t.el.setAttribute("aria-disabled",String(n));for(let o of t.el.querySelectorAll("input, button, select, textarea"))n?(s.has(o)||s.set(o,!!o.disabled),o.disabled=!0):s.has(o)&&(o.disabled=s.get(o),s.delete(o))};return i.listen(t.el,"change",o=>o.stopImmediatePropagation()),t.on("change",o=>i.emit("change",{value:o.detail.values})),{el:t.el,get:()=>t.getValues(),set:o=>{t.setValues(Array.isArray(o)?o:[],{silent:!0}),r()},focus:()=>t.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var lt=class extends k{static cssName="number-field";static defaults={value:null,min:null,max:null,step:1,largeStep:10,precision:null,snap:!0,wrap:!1,placeholder:"",label:null,unit:null,disabled:!1,readonly:!1,required:!1,name:null,group:!1,locale:null};render(){this._value=null,this._disabled=!1,this._readonly=!1,this._editing=!1,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:$(this.el);let e=this.el??u("div");this.el=e;let t=Ch(this.options.step);this._step=t,this._snap=this.options.snap!==!1;let s=this.options.precision!==null&&this.options.precision!==void 0;this._precision=s?Math.max(0,Math.trunc(Number(this.options.precision)||0)):Pi(t),this._fixedPrecision=this._snap||s;let n=this._stepButton("down","minus"),r=this._stepButton("up","plus"),o=u("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0||!this._fixedPrecision?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),a=[n,o];return this.options.unit!==null&&a.push(u("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),a.push(r),e.replaceChildren(...a),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"input",()=>this._onInput()),this.listen(o,"keydown",l=>this._onKeydown(l)),this.listen(o,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(o,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(n,"click",()=>this._stepBy(-1)),this.listen(r,"click",()=>this._stepBy(1)),this.listen(o,"wheel",l=>{document.activeElement!==o||this._disabled||this._readonly||(l.preventDefault(),this._stepBy(l.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),e}get value(){return this._value}set value(e){this.set(e)}get(){return this._value}set(e,{silent:t=!1}={}){let s=this._coerce(e),n=s!==this._value;return this._value=s,this._syncInput(),n&&!t&&this.emit("change",{value:this._value}),this}stepUp(e=1){return this._stepBy(e)}stepDown(e=1){return this._stepBy(-e)}reset({silent:e=!1}={}){return this.set(this.options.value,{silent:e})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(e){return this._readonly=!!e,this._syncDisabled(),this}setRange(e,t){return this._min=e==null?null:Number(e),this._max=t==null?null:Number(t),this.set(this._value,{silent:!0})}_stepButton(e,t){return u("button",{ref:e,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:e}},x(t,{size:13}))}get _rangeMin(){return this._min!==void 0?this._min:this.options.min===null||this.options.min===void 0?null:Number(this.options.min)}get _rangeMax(){return this._max!==void 0?this._max:this.options.max===null||this.options.max===void 0?null:Number(this.options.max)}_coerce(e){let t=Li(e,this.options.group?this._separators():null);return t===null?null:this._snap?Fi(t,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision}):this._decimalsFor(t)>fa?Eh(t,this._rangeMin,this._rangeMax):Fi(t,{min:this._rangeMin,max:this._rangeMax,step:0,precision:this._decimalsFor(t)})}_stepBy(e){if(this._disabled||this._readonly)return this;let t=this._rangeMin,s=this._rangeMax,r=Li(this.refs.input.value,this.options.group?this._separators(this._inputLocale):null)??this._value,o=r===null?t??0:r,a=r===null&&e>0&&t!==null?t-this._step*e:o,l=this._decimalsFor(a),c=l>fa?a+this._step*e:pa(a+this._step*e,l);return this.options.wrap&&t!==null&&s!==null&&(c>s?c=t:c<t&&(c=s)),this.set(c),this}_separators(e=ee(this.options.locale)){let t=String(e);if(this._localeSeparators&&this._separatorLocale===t)return this._localeSeparators;this._separatorLocale=t;let s=new Intl.NumberFormat(e,{minimumFractionDigits:1}).formatToParts(1234.5),n=new Intl.NumberFormat(e,{useGrouping:!1});return this._localeSeparators={group:s.find(r=>r.type==="group")?.value??",",decimal:s.find(r=>r.type==="decimal")?.value??".",minus:n.formatToParts(-1).find(r=>r.type==="minusSign")?.value??"-",digits:Object.fromEntries(Array.from({length:10},(r,o)=>[n.formatToParts(o).find(a=>a.type==="integer")?.value??String(o),String(o)]))},this._localeSeparators}_onInput(){let e=Li(this.refs.input.value,this.options.group?this._separators(this._inputLocale):null);this._syncAria(e),this.emit("input",{value:e})}_onKeydown(e){if(this._disabled||this._readonly||e.altKey||e.ctrlKey||e.metaKey)return;let t=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),n={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(t),PageDown:()=>this._stepBy(-t),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[e.key];n&&(e.key==="Home"&&this._rangeMin===null||e.key==="End"&&this._rangeMax===null||(e.preventDefault(),n()))}_commit(){this.set(Li(this.refs.input.value,this.options.group?this._separators(this._inputLocale):null))}_syncInput(){let e=this.refs.input;this._inputLocale=ee(this.options.locale);let t=this._value===null?"":this._format(this._value,this._editing);e.value!==t&&(e.value=t),this._syncAria(this._value)}_syncAria(e){let t=this.refs.input,s=this._rangeMin,n=this._rangeMax;if(s===null?t.removeAttribute("aria-valuemin"):t.setAttribute("aria-valuemin",String(s)),n===null?t.removeAttribute("aria-valuemax"):t.setAttribute("aria-valuemax",String(n)),e===null)t.removeAttribute("aria-valuenow"),t.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{t.setAttribute("aria-valuenow",String(e));let r=this.options.unit===null?"":` ${this.options.unit}`;t.setAttribute("aria-valuetext",`${this._format(e,!1)}${r}`)}this.el.toggleAttribute("data-empty",e===null)}_format(e,t){let s=this._decimalsFor(e);return this.options.group?new Intl.NumberFormat(ee(this.options.locale),{minimumFractionDigits:s,maximumFractionDigits:s,useGrouping:!t}).format(e):e.toFixed(s)}_decimalsFor(e){return this._fixedPrecision?this._precision:Math.min(zh,Math.max(this._precision,Pi(e)))}_message(e,t){let s=this.msg(e);return s===e?t:s}_syncDisabled(){let e=this.refs.input;e.disabled=this._disabled,e.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let e=this.el;super.destroy(),!this._createdRoot&&e&&H(e,this._snapshot)}};function Li(i,e=null){if(typeof i=="number")return Number.isFinite(i)?i:null;if(i==null)return null;let t=String(i).trim();if(t==="")return null;let s;if(e){s=t;for(let[r,o]of Object.entries(e.digits??{}))s=s.split(r).join(o);s=s.split(e.group).join("").replace(e.decimal,".").replace(e.minus??"-","-").replace(/[^\d.\-+eE]/g,"")}else{let r=t.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");s=r,o>=0&&o>a?s=r.replace(/\./g,"").replace(",","."):o>=0&&(s=r.replace(/,/g,""))}if(!/\d/.test(s))return null;let n=Number(s);return Number.isFinite(n)?n:null}function Fi(i,{min:e,max:t,step:s,precision:n}){let r=i;if(s>0){let o=e??0;r=o+Math.round((i-o)/s)*s}return r=pa(r,n),e!==null&&r<e?e:t!==null&&r>t?t:r}function Ch(i){let e=Number(i);return Number.isFinite(e)&&e>0?e:1}var zh=100,fa=15;function Eh(i,e,t){return e!==null&&i<e?e:t!==null&&i>t?t:i}function Pi(i){let[e,t="0"]=String(i).toLowerCase().split("e"),s=e.split(".")[1]?.length??0;return Math.max(0,s-Number(t))}function pa(i,e){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,e)))):i}function ma(){E.register("number",(i,e)=>{let t=i.own(new lt(null,{label:e.label?String(e.label):void 0,placeholder:e.placeholder,required:e.required,name:i.name||null,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:t.el,labelTarget:t.getInput(),get:()=>t.get(),set:n=>{s=!0;try{t.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}var ji=class extends k{static cssName="rating";static defaults={value:0,max:5,allowHalf:!1,clearable:!0,readonly:!1,disabled:!1,label:null,icon:"star",labels:null,showValue:!1,count:null,size:"md"};render(){this._value=0,this._preview=null,this._disabled=!1,this._readonly=!1,this._radios=[],this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:$(this.el);let e=this.el??u("div");this.el=e,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=z("zx-rating");let t=u("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??this.msg("rating.label"))});for(let s=1;s<=this._max;s+=1){let n=u("span",{class:"zx-rating__symbol"},u("span",{class:"zx-rating__glyph",ariaHidden:"true"},x(this.options.icon,{size:Lt[this.options.size]??Lt.md})),u("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},x(this.options.icon,{size:Lt[this.options.size]??Lt.md})));this.options.allowHalf?n.append(this._radio(s-.5,"half"),this._radio(s,"full")):n.append(this._radio(s,"full")),t.append(n)}return e.replaceChildren(t,u("span",{ref:"readout",class:"zx-rating__readout"})),e.dataset.size=Lt[this.options.size]?this.options.size:"md",this.listen(t,"keydown",s=>this._onKeydown(s)),this.listen(t,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),e}get value(){return this._value}set value(e){this.set(e)}get(){return this._value}set(e,{silent:t=!1}={}){let s=this._clamp(e),n=s!==this._value;return this._value=s,this._preview=null,this._sync(),n&&!t&&this.emit("change",{value:this._value}),this}clear({silent:e=!1}={}){return this.set(0,{silent:e})}reset({silent:e=!1}={}){return this.set(this.options.value,{silent:e})}setCount(e){return this._count=e,this._syncReadout(),this}focus(){return(this._radios.find(t=>t.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(e){return this._readonly=!!e,this._syncDisabled(),this}_radio(e,t){let s=u("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(e),dataset:{value:String(e),part:t}});return this.listen(s,"click",n=>{this._choose(e,n.detail>0)}),this.listen(s,"pointerenter",()=>this._setPreview(e)),this.listen(s,"focus",()=>this._setPreview(e)),this.listen(s,"blur",()=>this._setPreview(null)),this._radios.push(s),s}_stepLabel(e){let t=this.options.labels;if(Array.isArray(t)){let s=Math.round(e/this._step)-1;if(t[s]!=null)return String(t[s])}return this._message("rating.value","%1 of %2",[e,this._max])}_message(e,t,s){let n=this.msg(e,...s);return n===e?q(t,s):n}_choose(e,t){this._disabled||this._readonly||(t&&this.options.clearable&&e===this._value?this.set(0):this.set(e))}_onKeydown(e){if(this._disabled||this._readonly)return;let t=["ArrowRight","ArrowDown"],s=["ArrowLeft","ArrowUp"];if(t.includes(e.key))e.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(s.includes(e.key))e.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(e.key==="Home")e.preventDefault(),this.set(this._step);else if(e.key==="End")e.preventDefault(),this.set(this._max);else if((e.key==="Delete"||e.key==="Backspace")&&this.options.clearable)e.preventDefault(),this.set(0);else return;this.focus()}_setPreview(e){let t=this._disabled||this._readonly?null:e;t!==this._preview&&(this._preview=t,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return 0;let s=Math.round(t/this._step)*this._step;return Math.min(this._max,Math.max(0,s))}_sync(){for(let t of this._radios){let s=Number(t.dataset.value);t.setAttribute("aria-checked",String(s===this._value))}let e=this._radios.find(t=>t.getAttribute("aria-checked")==="true");for(let t of this._radios)t.tabIndex=-1;(e??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let e=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((s,n)=>{let r=Math.min(1,Math.max(0,e-n));s.style.setProperty("--zx-rating-fill",`${r*100}%`),s.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(e)}_syncReadout(){let e=this.refs.readout;if(!e)return;let t=this._count===void 0?this.options.count:this._count,s=[];this.options.showValue&&s.push(Th(this._value,this._step)),t!=null&&s.push(this.msgPlural("rating.count",Number(t),t)),e.textContent=s.join(" \xB7 ")}_syncDisabled(){let e=this._disabled||this._readonly;for(let t of this._radios)t.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",e),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let e=this.el;super.destroy(),!this._createdRoot&&e&&H(e,this._snapshot)}},Lt={sm:14,md:18,lg:24};function Th(i,e){return e<1?i.toFixed(1):String(i)}function ga(){E.register("rating",(i,e)=>{let t=i.own(new ji(null,{label:e.label?String(e.label):void 0,...e.props??{}})),s=!1;return t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:t.el,labelTarget:t.refs.symbols,get:()=>t.get()||null,set:n=>{s=!0;try{t.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}var Hy=["a[href]","area[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),Mh=["hidden","inert","disabled","aria-disabled","aria-hidden"],Ih=new Set(["button","checkbox","color","file","image","reset","submit"]);function _a(i,e,{orientation:t="vertical",wrap:s=!0,rtl:n="auto"}={}){let r=new AbortController,o=new Map,a=new Map,l=!1;function c(b){if(o.has(b)){if(b.getAttribute("tabindex")===a.get(b)){let w=o.get(b);w===null?b.removeAttribute("tabindex"):b.setAttribute("tabindex",w)}o.delete(b),a.delete(b)}}function d(b){for(let w of b)if(w.type==="childList")for(let v of w.removedNodes)for(let A of o.keys())(v===A||v.contains(A))&&c(A)}function h(){let b=_?.takeRecords()??[],w=b.some(y);d(b),w&&queueMicrotask(()=>{l||f()});let v=Array.from(i.querySelectorAll(e)),A=new Set(v);for(let M of o.keys())A.has(M)||c(M);let S=Fh(i);return v.filter(M=>(p(M),Lh(M,i,S)))}function p(b){if(!o.has(b)){let w=b.getAttribute("tabindex");o.set(b,w),a.set(b,w)}}function f(b=null){let w=h(),v=b&&w.includes(b)?b:w.find(S=>S.tabIndex===0)??w[0];for(let S of w){let M=S===v?0:-1;S.tabIndex!==M&&(S.tabIndex=M),a.set(S,S.getAttribute("tabindex"))}let A=new Set(w);for(let S of o.keys())A.has(S)||!ya(S)||!i.contains(S)||(S.tabIndex!==-1&&(S.tabIndex=-1),a.set(S,S.getAttribute("tabindex")))}function m(b){let w=h(),v=b.target?.closest?.(e)??null,A=w.indexOf(v);if(A<0)return;let S=t==="horizontal"&&Rh(i,n),M=Dh(b.key,t,S);if(M===null||!Nh(b.target,M))return;let L=M==="first"?0:M==="last"?w.length-1:M==="previous"?A-1:A+1;w.length!==0&&(s?L=(L+w.length)%w.length:L=Math.max(0,Math.min(w.length-1,L)),b.preventDefault(),f(w[L]),w[L].focus())}function g(b){let w=b.target?.closest?.(e)??null;w&&i.contains(w)&&f(w)}i.addEventListener("keydown",m,{signal:r.signal}),i.addEventListener("focusin",g,{signal:r.signal});let _=typeof MutationObserver=="function"?new MutationObserver(b=>{let w=b.some(y);d(b),w&&f()}):null;_?.observe(i,{childList:!0,subtree:!0,attributes:!0,attributeFilter:Mh}),f();function y(b){if(b.type==="attributes")return b.target instanceof Element&&(b.target.matches(e)||b.target.querySelector(e)!==null);for(let w of b.addedNodes)if(w instanceof Element&&(w.matches(e)||w.querySelector(e)))return!0;for(let w of b.removedNodes)if(w instanceof Element){if(o.has(w))return!0;for(let v of o.keys())if(w.contains(v))return!0}return!1}return{focusFirst(){let b=h()[0];b&&(f(b),b.focus())},focusLast(){let b=h(),w=b[b.length-1];w&&(f(w),w.focus())},destroy(){if(!l){l=!0,r.abort(),d(_?.takeRecords()??[]),_?.disconnect();for(let[b,w]of o)w===null?b.removeAttribute("tabindex"):b.setAttribute("tabindex",w);o.clear(),a.clear()}}}}function ba(i,e){let t="",s=null,n=null;return function(o){let a=typeof o=="string"?o:o.key;if(typeof o!="string"&&(o.ctrlKey||o.metaKey||o.altKey)||!a||a.length!==1||/\s/.test(a))return;s!==null&&clearTimeout(s);let l=a.toLocaleLowerCase(),c=t===l;t=c?l:t+l,s=setTimeout(()=>{t="",s=null},500);let d=i(),h=c?d.indexOf(n)+1:0;for(let p=0;p<d.length;p+=1){let f=(h+p)%d.length;if(Ph(d[f]).startsWith(t)){n=d[f],e(n,f);break}}}}function Dh(i,e,t=!1){return i==="Home"?"first":i==="End"?"last":e==="horizontal"?i==="ArrowLeft"?t?"next":"previous":i==="ArrowRight"?t?"previous":"next":null:i==="ArrowUp"?"previous":i==="ArrowDown"?"next":null}function Oh(i){if(!i||typeof i!="object")return!1;let e=String(i.tagName??"").toUpperCase();return e==="TEXTAREA"||e==="SELECT"?!0:e==="INPUT"?!Ih.has(String(i.type??"text").toLowerCase()):!!i.isContentEditable}function Nh(i,e){if(!Oh(i))return!0;if(e==="first"||e==="last"||String(i?.tagName??"").toUpperCase()!=="INPUT")return!1;let t=i,s,n;try{s=t.selectionStart,n=t.selectionEnd}catch{return!1}return typeof s!="number"||typeof n!="number"||s!==n?!1:e==="previous"?s===0:n===String(t.value??"").length}function Rh(i,e){if(e===!0||e===!1)return e;try{return globalThis.getComputedStyle?.(i)?.direction==="rtl"}catch{return!1}}function Lh(i,e,t){if(!ya(i))return!1;let s=i.closest("[hidden], [inert]");return s&&s!==e&&e.contains(s)?!1:!t||i.getClientRects().length>0}function Fh(i){return i.isConnected&&typeof i.getClientRects=="function"&&i.getClientRects().length>0}function ya(i){return!(!(i instanceof HTMLElement)||i.hidden||i.getAttribute("aria-hidden")==="true"||i.matches(":disabled"))}function Ph(i){if(typeof i=="string"||typeof i=="number")return String(i).trim().toLocaleLowerCase();if(i&&typeof i=="object"&&"textContent"in i)return String(i.textContent??"").trim().toLocaleLowerCase();if(i&&typeof i=="object"){let e=i,t=e.label??e.text??e.value;if(t!=null)return String(t).trim().toLocaleLowerCase()}return String(i??"").trim().toLocaleLowerCase()}var jh=/^var\(\s*--[\w-]+\s*\)$/;function Vi(i){if(typeof i!="string")return null;let e=i.trim();return jh.test(e)||Ie(e)?e:null}var fn=Object.freeze("AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS XK YE YT ZA ZM ZW".split(" ")),Vh=127397;function re(i){let e=typeof i=="string"?i.trim():"";return/^[a-z]{2}$/i.test(e)?e.toUpperCase():null}function wa(i){let e=re(i);return e?String.fromCodePoint(...[...e].map(t=>t.charCodeAt(0)+Vh)):""}function va(i=globalThis.document){let e=i?.createElement?.("canvas")??null,t=null;try{t=e?.getContext?.("2d",{willReadFrequently:!0})??null}catch{t=null}if(!e||!t)return!1;let s=24;e.width=s,e.height=s,t.textBaseline="top",t.font=`${s-4}px sans-serif`,t.fillText(wa("DE"),0,0);let n;try{n=t.getImageData(0,0,s,s).data}catch{return!1}for(let r=0;r<n.length;r+=4)if(n[r+3]>0&&(n[r]!==n[r+1]||n[r+1]!==n[r+2]))return!0;return!1}function Bh(i,e){return String(i).replaceAll("{code}",e.toLowerCase()).replaceAll("{CODE}",e.toUpperCase())}function qh(i,e={}){let{kind:t="auto",src:s=null,text:n=null,label:r=null}=e??{},o=re(i),a=s?"image":t;a==="auto"&&(a=va()?"emoji":"code"),(!o||a==="image"&&!s)&&(a="code");let l;a==="image"?l=u("img",{class:"zx-flag__image",src:Bh(s,o),alt:"",loading:"lazy",decoding:"async"}):a==="emoji"?l=wa(o):(a="code",l=String(n??o??"").trim());let c=u("span",{class:"zx-flag",dataset:{kind:a,...o?{region:o}:{}}},l),d=r==null?"":String(r).trim();return d?(c.setAttribute("role","img"),c.setAttribute("aria-label",d)):c.setAttribute("aria-hidden","true"),c}function Bi(i,e){if(typeof i=="function")return(s,n,r)=>i(s,r);if(i==="none"||i===!1)return()=>null;let t=i==="emoji"||i==="code"?i:"auto";return e&&t!=="code"?t="image":t==="auto"&&(t=va()?"emoji":"code"),(s,n)=>qh(s,{kind:t,src:t==="image"?e:null,text:n||null})}var $h=Object.freeze(["en","de","fr","es","it","pt","nl","pl","cs","sv","da","fi","nb","tr","ru","uk","el","ar","he","hi","ja","ko","zh"]);function qi(i,e={}){let t=e.displayLocale||ne()||"en",s=e.display??"both",n=e.flagRegions??{},r=xa(t,"language"),o=new Set,a=[];for(let l of Array.isArray(i)?i:[]){let c=typeof l=="string"?{code:l}:l,d=$i(c?.code);if(!d||o.has(d))continue;o.add(d);let h=new Intl.Locale(d),p=h.baseName,f=Sa(xa(p,"language")?.of(p)??p,p),m=Sa(r?.of(p)??p,t),g=c.name??(s==="localized"?m:f),_=c.description??(s==="both"&&m.toLocaleLowerCase()!==f.toLocaleLowerCase()?m:"");a.push({ID:d,name:String(g),nameLang:c.name!=null?null:s==="localized"?t:d,description:String(_),region:"region"in c?re(c.region):Uh(h,d,n),language:h.language})}if(e.sort){let l=new Intl.Collator(t);a.sort((c,d)=>l.compare(c.name,d.name))}return a}function ka(i){let{locales:e=$h,preferred:t=[],preferredLabel:s=null,displayLocale:n=null,display:r="both",flags:o="auto",flagUrl:a=null,flagRegions:l={},sort:c=!1,value:d=null,...h}=i??{},p={displayLocale:n||h.lang||h.language||ne(),display:r,flagRegions:l,sort:c},f=qi(e,p),m=qi(t,{...p,sort:!1}),g=Bi(o,a),_=y=>g(y.region,y.language.toUpperCase(),y);return{filter:f.length+m.length>7?"local":!1,...h,label:h.label||Aa("localePicker.label",i),placeholder:h.placeholder||Aa("localePicker.placeholder",i),items:f,fixedItems:m,fixedLabel:m.length?s:null,valueKey:"ID",labelKey:"name",searchKeys:["name","description","ID"],value:typeof d=="string"?$i(d)??d:d,renderItem:y=>Hh(_(y),y.name,y.description,y.nameLang),renderValueAdornment:y=>_(y)}}function Hh(i,e,t,s){return u("span",{class:"zx-select__entity"},i?u("span",{class:"zx-select__entity-icon",ariaHidden:"true"},i):null,u("span",{class:"zx-select__entity-copy"},u("span",{class:"zx-select__entity-label",...s?{lang:s}:{}},e),t?u("span",{class:"zx-select__entity-subtitle"},t):null))}function $i(i){if(typeof i!="string"||!i.trim())return null;try{return Intl.getCanonicalLocales(i.trim().replaceAll("_","-"))[0]??null}catch{return null}}function Uh(i,e,t){if(Object.hasOwn(t,e))return re(t[e]);if(i.region)return re(i.region);if(Object.hasOwn(t,i.language))return re(t[i.language]);try{return re(i.maximize().region)}catch{return null}}function xa(i,e){try{return new Intl.DisplayNames([i,"en"],{type:e,fallback:"code",languageDisplay:"standard"})}catch{return null}}function Sa(i,e){let[t="",...s]=String(i);try{return t.toLocaleUpperCase(e)+s.join("")}catch{return t.toUpperCase()+s.join("")}}function Aa(i,e){return k.prototype.msg.call({options:e},i)}function Hi(i=fn,e={}){let t=e.displayLocale||ne()||"en",s=Ca(t),n=Ca("en"),r=new Set,o=[];for(let a of Array.isArray(i)?i:[]){let l=typeof a=="string"?{code:a}:a,c=re(l?.code);!c||r.has(c)||(r.add(c),o.push({ID:c,name:String(l.name??s?.of(c)??c),description:String(l.description??(e.showCode?c:"")),alias:String(n?.of(c)??c)}))}if(e.sort??!0){let a=new Intl.Collator(t);o.sort((l,c)=>a.compare(l.name,c.name))}return o}function Ea(i){let{countries:e=fn,preferred:t=[],preferredLabel:s=null,displayLocale:n=null,flags:r="auto",flagUrl:o=null,showCode:a=!1,sort:l=!0,value:c=null,...d}=i??{},h={displayLocale:n||d.lang||d.language||ne(),showCode:a},p=Hi(e,{...h,sort:l}),f=Hi(t,{...h,sort:!1}),m=Bi(r,o),g=_=>m(_.ID,_.ID,_);return{filter:"local",...d,label:d.label||za("countryPicker.label",i),placeholder:d.placeholder||za("countryPicker.placeholder",i),items:p,fixedItems:f,fixedLabel:f.length?s:null,valueKey:"ID",labelKey:"name",searchKeys:["name","ID","alias","description"],value:typeof c=="string"?re(c)??c:c,renderItem:_=>Kh(g(_),_.name,_.description),renderValueAdornment:_=>g(_)}}function Kh(i,e,t){return u("span",{class:"zx-select__entity"},i?u("span",{class:"zx-select__entity-icon",ariaHidden:"true"},i):null,u("span",{class:"zx-select__entity-copy"},u("span",{class:"zx-select__entity-label"},e),t?u("span",{class:"zx-select__entity-subtitle"},t):null))}function Ca(i){try{return new Intl.DisplayNames([i,"en"],{type:"region",fallback:"code"})}catch{return null}}function za(i,e){return k.prototype.msg.call({options:e},i)}var mn=Object.freeze(["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"]),gn=Object.freeze(["muted","neutral","warning","info","accent","success","danger"]),_n=Object.freeze([["backlog","status.backlog","Backlog","dotted","muted"],["todo","status.todo","Todo","ring","neutral"],["in-progress","status.inProgress","In Progress","progress","warning"],["in-review","status.inReview","In Review","review","info"],["ready","status.ready","Ready to Merge","ready","accent"],["waiting","status.waiting","Waiting for feedback","waiting","warning"],["done","status.done","Done","done","info"],["canceled","status.canceled","Canceled","canceled","muted"],["duplicate","status.duplicate","Duplicate","duplicate","muted"]]),Yh=Object.freeze({review:"in-review",cancelled:"canceled"}),pn=4;function Wh(i,e={}){let t=i&&typeof i=="object"?i:null,s=Gh(t?t.ID??t.id:i),n=_n.find(([a])=>a===s),r=String(e.indicator??t?.indicator??n?.[3]??"ring"),o=String(e.tone??t?.tone??n?.[4]??"muted");return{indicator:mn.includes(r)?r:"ring",tone:gn.includes(o)?o:"muted"}}function Gh(i){let e=String(i??"").trim().toLowerCase();return Yh[e]??e}function bn(i){return i==null||i===""?null:Math.max(0,Math.min(pn,Math.trunc(Number(i)||0)))}function Ta(i,e={}){let{indicator:t,tone:s}=Wh(i,e??{}),n=u("span",{class:"zx-status-icon",dataset:{indicator:t,tone:s}});return t==="done"&&n.append(x("check",{size:T.marker})),t==="canceled"&&n.append(x("x",{size:T.marker})),Ia(n,e?.label)}function Ma(i,e={}){let t=bn(i),s=u("span",{class:"zx-priority-icon",dataset:{level:t===null?"none":t}},t===pn?null:Array.from({length:pn},(n,r)=>u("span",{dataset:{filled:String(t!==null&&r<=t)}})));return Ia(s,e?.label)}function Ia(i,e){let t=e==null?"":String(e).trim();return t?(i.setAttribute("role","img"),i.setAttribute("aria-label",t)):i.setAttribute("aria-hidden","true"),i}var yn=Symbol("normalizeSelectValue"),Zh=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],Da=["Lowest","Low","Medium","High","Highest"],Y=class i extends k{static cssName="select";static defaults={items:[],fixedItems:[],fixedLabel:null,valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],value:null,disabled:!1,placeholder:"",label:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._actions=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._snapshot=null,this._pointerModality=!1,this._normalizeValue=this.options[yn]??(h=>h),this._createdRoot=this.el===null;let e=this.el??u("div");this.el=e,this._root=e,this._snapshot=this._createdRoot?null:$(e);let t=z("zx-select-list"),s=u("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",ariaLabel:String(this.options.label||this.options.placeholder||this._message("select.label","Select")),autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:t,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),n=u("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),r=u("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},x("x",{size:T.dismiss})),o=u("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=u("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},x("chevron-down",{size:T.chevron})),l=u("div",{ref:"control",class:"zx-select__control"},n,s,r,o,a),c=u("div",{ref:"list",class:"zx-select__list",id:t,role:"listbox"});c.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let d=u("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},c);return e.replaceChildren(l,d),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=Oa(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=ba(()=>this._optionEntries.filter(h=>!h.clear&&!h.action).map(h=>h.element),(h,p)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(p))}),this.listen(s,"click",()=>this.open()),this.listen(s,"input",()=>this._onInput()),this.listen(s,"keydown",h=>{Ra(h)||e.removeAttribute("data-focus-origin"),this._onKeydown(h)}),this.listen(s,"focus",()=>{this._pointerModality&&s.readOnly?e.setAttribute("data-focus-origin","pointer"):e.removeAttribute("data-focus-origin")}),this.listen(s,"blur",()=>e.removeAttribute("data-focus-origin")),this.listen(document,"keydown",h=>{Ra(h)||(this._pointerModality=!1)},{capture:!0}),this.listen(a,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(d,"pointerdown",h=>h.preventDefault()),this.listen(d,"click",h=>this._onOptionClick(h)),this.listen(document,"pointerdown",h=>{this._pointerModality=!0,this._open&&!e.contains(h.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),e}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(e){this.set(e)}get(){return this.value}get selected(){return this._selected}set(e,{silent:t=!1}={}){let s=this.value,n=typeof e=="string"?this._normalizeValue(e):e,r=n==null?null:this._findItem(n);r===null&&n!==null&&typeof n=="object"&&this._itemValue(n)!=null&&(r=n),this._selected=r,this._syncInputValue(),this._renderOptions();let o=this.value;return!t&&!Object.is(s,o)&&this.emit("change",{value:o,item:r}),this}setItems(e){let t=this.value,s=this._typedQuery();return this._cancelQuery(),this._setLoading(!1),this._items=Array.isArray(e)?e.slice():[],this._visibleItems=this._items.slice(),this._selected=t==null?null:this._findItem(t),this._refreshAfterItemChange(s),this}setFixedItems(e){let t=this.value,s=this._typedQuery();return this._fixedItems=Array.isArray(e)?e.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=t==null?null:this._findItem(t),this._refreshAfterItemChange(s),this}_typedQuery(){if(!this._open||!this.options.filter)return null;let e=this.refs.input.value;return e===this._selectedLabel()?null:e}_refreshAfterItemChange(e){e!==null?(this._visibleFixed=this._matchFixed(e),this.options.filter==="local"&&(this._visibleItems=xe(this._items,e,this._searchKeys())),this._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null,this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1)):(this._syncInputValue(),this._renderOptions()),this._position?.update()}_selectedLabel(){return this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected)}setActions(e){return this._actions=Oa(e),this._renderOptions(),this._position?.update(),this}reset({silent:e=!1}={}){return this.set(this.options.value,{silent:e}),this}open(){return this._openPanel(!0)}_openPanel(e){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=ae(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),e&&this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static locale(e,t={}){let s=new i(e,{...ka(t),[yn]:n=>$i(n)??n});return s.el.setAttribute("data-preset","locale"),s}static localeItems(e,t={}){return qi(e,t)}static country(e,t={}){let s=new i(e,{...Ea(t),[yn]:n=>re(n)??n});return s.el.setAttribute("data-preset","country"),s}static countryItems(e,t={}){return Hi(e,t)}static priority(e,t={}){let s=t.value??null,n=t.clearable??!0,r=null,o=()=>t.noneLabel??(r?r._message("priority.none","No priority"):"No priority");r=new i(e,{...t,clearable:n,value:s,items:[],renderItem(l){return Na(l,!0)},renderNone:t.renderNone??(()=>Na({level:null,name:o()},!0)),renderValueAdornment(l){return Fa(l.level)}}),n&&!t.placeholder&&(r.refs.input.placeholder=o());let a=r;return r.setItems(Zh.map((l,c)=>{let d=c===2?a.msg("priority.medium"):l;return(d==="priority.medium"||c!==2)&&(d=a._message(l,Da[c])),{ID:c,name:d,level:c}})),r.set(s,{silent:!0}),r}static status(e,t={}){let{items:s=null,value:n=null,...r}=t,o=new i(e,{...r,value:n,items:[],renderItem(l){return ef(l)},renderValueAdornment(l){return Pa(l)}}),a=Array.isArray(s)?s.map(Xh).filter(Boolean):_n.map(([l,c,d,h,p],f)=>({ID:l,name:o._message(c,d),indicator:h,tone:p,shortcut:String(f+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static entity(e,t={}){let{recent:s=[],recentLabel:n=xn("select.recent",t),create:r=!1,iconKey:o="icon",colorKey:a="color",subtitleKey:l="description",renderIcon:c=null,fixedItems:d=[],actions:h=[],renderItem:p=null,renderValueAdornment:f=null,...m}=t,g=(b,w=!1)=>{if(typeof c=="function")return c(b,{selected:w});let v=Ui(b,o);if(v&&typeof v=="object"&&typeof v.nodeType=="number")return v.cloneNode(!0);if(typeof v!="string"||!v)return null;let A=Vi(Ui(b,a));return u("span",{class:"zx-select__entity-glyph",style:A?{"--zx-select-entity-color":A}:null,ariaHidden:"true"},x(v,{size:14}))},_=r?Qh(r,t):null,y=new i(e,{...m,fixedItems:[...Array.isArray(s)?s:[],...Array.isArray(d)?d:[]],fixedLabel:Array.isArray(s)&&s.length?n:m.fixedLabel??null,actions:[...Array.isArray(h)?h:[],..._?[_]:[]],renderItem:p??(b=>{let w=g(b,!1),v=Ui(b,l),A=u("span",{class:"zx-select__entity-copy"},u("span",{class:"zx-select__entity-label"},String(Ui(b,m.labelKey??"name")??"")),v==null||v===""?null:u("span",{class:"zx-select__entity-subtitle"},String(v)));return u("span",{class:"zx-select__entity"},w?u("span",{class:"zx-select__entity-icon",ariaHidden:"true"},w):null,A)}),renderValueAdornment:f??(b=>g(b,!0))});return y.el.dataset.preset="entity",y}static permission(e,t={}){let{groups:s=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...l}=t,c=typeof s=="function"?s:null,d=c?[]:s,h=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],p=new i(e,{filter:c??a,...l,value:n,items:d,fixedItems:[],valueKey:f=>h.includes(f)?f.ID:vn(f,r),labelKey:f=>h.includes(f)?f.name:String(vn(f,o)??"")});return h[0].name=p._message("permission.private","Private"),h[1].name=p._message("permission.public","Public"),p.setFixedItems(h),p.set(n,{silent:!0}),p}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let e=this.el;!this._createdRoot&&e&&H(e,this._snapshot),super.destroy()}_onKeydown(e){if(this._disabled||e.isComposing||e.keyCode===229)return;if(this._open&&La(e)){let s=this._optionEntries.findIndex(n=>!n.clear&&!n.action&&String(n.item?.shortcut??"")===e.key);if(s>=0){e.preventDefault(),this._setActive(s),this._chooseEntry(this._optionEntries[s]);return}}if(e.key==="ArrowDown"){e.preventDefault(),this._open?this._moveActive(1):this.open();return}if(e.key==="ArrowUp"){e.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}let t=this._open&&!this._typedQuery();if(e.key==="Home"&&t){e.preventDefault(),this._setActive(0);return}if(e.key==="End"&&t){e.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(e.key==="Enter"&&this._open){e.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(e.key==="Escape"&&this._open){e.preventDefault(),this.close();return}if(e.key==="Tab"&&this._open){this.close();return}!this.options.filter&&La(e)&&this._handleTypeahead(e)}_onInput(){if(!this.options.filter)return;let e=this.refs.input.value;this._syncValueAdornment(),this._open||this._openPanel(!1),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(e),this._visibleItems=xe(this._items,e,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(e)}_onOptionClick(e){let t=e.target?.closest?.('[role="option"]');!t||!this.refs.panel.contains(t)||this._chooseEntry(this._optionEntries[Number(t.getAttribute("data-index"))])}_chooseEntry(e){if(e){if(e.action){let t={id:e.action.id,action:e.action,query:this.refs.input.value,select:this};this.emit("action",t).defaultPrevented||e.action.invoke?.(t),this.close(),this.focus();return}this.set(e.clear?null:e.item),this.close(),this.focus()}}_moveActive(e){let t=this._optionEntries.length;t!==0&&this._setActive((this._activeIndex+e+t)%t)}_setActive(e){this._activeIndex=e>=0&&e<this._optionEntries.length?e:-1,this._optionEntries.forEach((s,n)=>{n===this._activeIndex?s.element.setAttribute("data-active","true"):s.element.removeAttribute("data-active")});let t=this._optionEntries[this._activeIndex]?.element;t?(this.refs.input.setAttribute("aria-activedescendant",t.id),t.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let e=this.refs.list;if(!e)return;e.replaceChildren(),this._optionEntries=[];let t=Symbol("initial-group"),s=this._uniqueItems(this._visibleFixed),n=this._uniqueItems(this._visibleItems,s);this.options.clearable&&this._appendOption(null,!0,this.options.noneLabel??this._message("select.none","No selection")),s.length>0&&this.options.fixedLabel&&e.append(u("div",{class:"zx-select__group",role:"presentation"},String(this.options.fixedLabel)));for(let r of s)this._appendOption(r,!1);s.length>0&&n.length>0&&!this.options.groupKey&&e.append(u("div",{class:"zx-select__separator",role:"presentation"}));for(let r of n){if(this.options.groupKey){let o=this._read(r,this.options.groupKey);Object.is(o,t)||(e.append(u("div",{class:"zx-select__group",role:"presentation"},String(o??""))),t=o)}this._appendOption(r,!1)}if(this._actions.length>0){(s.length>0||n.length>0||this.options.clearable)&&e.append(u("div",{class:"zx-select__separator",role:"presentation"}));let r=Symbol("initial-action-group");for(let o of this._actions)o.group&&o.group!==r&&(e.append(u("div",{class:"zx-select__group",role:"presentation"},o.group)),r=o.group),this._appendAction(o)}n.length===0&&s.length===0&&this._actions.length===0&&!this._loading&&e.append(u("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(e,t,s){let n=t?this._selected===null:this._selected!==null&&Object.is(this._itemValue(e),this.value),r=this._optionEntries.length,o=t&&typeof this.options.renderNone=="function"?wn(this.options.renderNone(String(s??""))):t?String(s??""):this._renderItem(e),a=u("div",{class:"zx-select__option",id:z("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},u("span",{class:"zx-select__option-content"},o));n&&a.append(x("check",{size:T.check})),this.refs.list.append(a),this._optionEntries.push({item:e,clear:t,action:null,element:a})}_appendAction(e){let t=this._optionEntries.length,s=Jh(e.icon),n=u("div",{class:"zx-select__option zx-select__action",id:z("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:t,kind:"action"}},u("span",{class:"zx-select__option-content zx-select__action-content"},s?u("span",{class:"zx-select__action-icon",ariaHidden:"true"},s):null,u("span",{class:"zx-select__action-copy"},u("span",{class:"zx-select__action-label"},e.label),e.description?u("span",{class:"zx-select__action-description"},e.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:e,element:n})}_renderItem(e){if(typeof this.options.renderItem=="function"){let t=this.options.renderItem(e);return wn(t)}return this._itemLabel(e)}_scheduleAsyncQuery(e){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let t=this._requestSequence;if(this._visibleFixed=this._matchFixed(e),e.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(e,t)},s)}async _runAsyncQuery(e,t){if(!(t!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:e});try{let s=await this.options.filter(e);if(t!==this._requestSequence||!this._open)return;this._items=Array.isArray(s)?s.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(t!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(e){this._loading=e,this.refs.loading.hidden=!e,this.refs.input.setAttribute("aria-busy",String(e)),this.refs.list.setAttribute("aria-busy",String(e)),e?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let e=this.refs.input;e.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncValueAdornment(){let e=this.refs.valueAdornment;if(!e)return;let t=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),s=String(this.refs.input?.value??"");if(this._selected===null||typeof this.options.renderValueAdornment!="function"||this.options.filter&&s!==t){e.replaceChildren(),e.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=wn(n);e.replaceChildren(r instanceof Node?r:document.createTextNode(r)),e.hidden=n==null||typeof r=="string"&&r===""}_syncDisabled(){let e=this.refs.input,t=this.refs.clear,s=this.refs.toggle;e.disabled=this._disabled,t.disabled=this._disabled,s.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(e){let t=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],s=t.find(r=>r===e);if(s!==void 0)return s;let n=e!==null&&typeof e=="object"?this._itemValue(e):e;return t.find(r=>Object.is(this._itemValue(r),n))??null}_itemValue(e){return this._read(e,this.options.valueKey)}_itemLabel(e){let t=this._read(e,this.options.labelKey);return String(t??"")}_read(e,t){return vn(e,t)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(e){return xe(this._fixedItems,e,this._searchKeys())}_uniqueItems(e,t=[]){let s=t.map(n=>this._itemValue(n));return e.filter(n=>{let r=this._itemValue(n);return s.some(o=>Object.is(o,r))?!1:(s.push(r),!0)})}_selectedEntryIndex(){return this._selected===null?this.options.clearable?0:-1:this._optionEntries.findIndex(e=>!e.clear&&Object.is(this._itemValue(e.item),this.value))}_itemEntryIndex(e){return e+(this.options.clearable?1:0)}_message(e,t){let s=this.msg(e);return s===e?t:s}};function Ui(i,e){return typeof e=="function"?e(i):i!==null&&typeof i=="object"&&typeof e=="string"?i[e]:null}function xn(i,e){return k.prototype.msg.call({options:e},i)}function Qh(i,e){let t=i===!0?{}:i;return{id:t.id??"create",label:t.label??xn("select.create",e),description:t.description,group:t.group??xn("select.createGroup",e),icon:t.icon??"plus",invoke:t.invoke}}function wn(i){return i&&typeof i=="object"&&"nodeType"in i?i:String(i??"")}function Oa(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&e.label!=null).map(e=>({...e,label:String(e.label),description:e.description==null?void 0:String(e.description),group:e.group==null?void 0:String(e.group)})):[]}function Jh(i){return typeof i=="string"?x(i):i instanceof Node?i.cloneNode(!0):null}function Na(i,e){return u("span",{class:"zx-select__priority"},Fa(i.level),e?u("span",{},String(i.name)):null)}function Fa(i){let e=Ma(bn(i));return e.classList.add("zx-select__priority-icon"),e}function Xh(i){return!i||typeof i!="object"||i.ID==null||i.name==null?null:{...i,name:String(i.name),indicator:mn.includes(String(i.indicator))?String(i.indicator):"ring",tone:gn.includes(String(i.tone))?String(i.tone):"muted",description:i.description==null?"":String(i.description),shortcut:i.shortcut==null?"":String(i.shortcut)}}function ef(i){return u("span",{class:"zx-select__status"},Pa(i),u("span",{class:"zx-select__status-copy"},u("span",{class:"zx-select__status-label"},String(i.name)),i.description?u("span",{class:"zx-select__status-description"},i.description):null),i.shortcut?u("kbd",{class:"zx-select__status-shortcut"},i.shortcut):null)}function Pa(i){let e=Ta({indicator:i.indicator??"ring",tone:i.tone??"muted"});return e.classList.add("zx-select__status-indicator"),e}function vn(i,e){return typeof e=="function"?e(i):i===null||typeof i!="object"?i:i[e]}function Ra(i){return["Shift","Control","Alt","Meta","CapsLock"].includes(i.key)||i.ctrlKey||i.metaKey}function La(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function ja(){E.register("zxselect",(i,e)=>{let t=e.props??{},s=t.preset,n={...t,value:e.value,label:e.label||t.label,placeholder:t.placeholder??e.placeholder};i.listen(i.el,"click",o=>{o.target.closest?.(".zx-field__label")&&(o.preventDefault(),i.adapter.focus())}),delete n.preset,s==="priority"&&t.clearable===void 0&&(n.clearable=!e.required);let r=i.own(s==="priority"?Y.priority(null,n):s==="status"?Y.status(null,n):s==="locale"?Y.locale(null,n):s==="country"?Y.country(null,n):new Y(null,n));return i.listen(r.el,"change",o=>o.stopImmediatePropagation()),r.on("change",o=>i.emit("change",{value:o.detail.value})),{el:r.el,labelTarget:r.refs.input,get:()=>r.value,set:o=>r.set(o,{silent:!0}),focus:()=>r.focus(),setDisabled:o=>o?r.disable():r.enable()}})}var Ki=class extends k{static cssName="slider";static defaults={value:0,min:0,max:100,step:1,label:"",hideLabel:!1,showValue:!0,showBounds:!1,showInput:!1,unit:"",marks:null,disabled:!1,readonly:!1,size:"md",formatValue:null};render(){this._value=0,this._readonly=!!this.options.readonly,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:$(this.el);let e=this.el??u("div");this.el=e,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=z("zx-slider");let t=u("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),s=u("div",{class:"zx-slider__track"},t,this._marks()),n=u("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(u("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(s),this.options.showBounds&&n.append(u("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.append(this._numberBox()),e.replaceChildren(u("div",{class:"zx-slider__head"},u("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),u("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),n),e.dataset.size=this.options.size==="sm"?"sm":"md",e.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(t,"input",()=>this._onInput()),this.listen(t,"change",()=>this._onCommit()),this.listen(t,"keydown",r=>{this._readonly&&tf.has(r.key)&&r.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),e}get value(){return this._value}set value(e){this.set(e)}get(){return this._value}set(e,{silent:t=!1}={}){let s=this._snap(e),n=s!==this._value;return this._value=s,this._committedValue=s,this._paint(),n&&!t&&this.emit("change",{value:s}),this}setRange(e,t,s){let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,s!==void 0&&(this._step=Math.abs(Number(s))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[a,l]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())l.textContent=this._format(a===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(e){return this._readonly=!!e,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(e){return this.refs.label.textContent=String(e??""),this}_numberBox(){let e=u("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??this.msg("slider.value"))});return this.listen(e,"input",()=>{if(this._readonly)return;let t=Number(e.value);e.value===""||!Number.isFinite(t)||(this._value=this._snap(t),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(e,"change",()=>{if(this._readonly){e.value=String(this._value);return}let t=this._snap(e.value===""?this._min:Number(e.value)),s=t!==this._committedValue;this.set(t,{silent:!0}),s&&this.emit("change",{value:t})}),e}_marks(){let e=this.options.marks;if(!Array.isArray(e)||e.length===0)return null;let t=u("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let s of e){let n=typeof s=="number"?s:Number(s?.value);if(!Number.isFinite(n))continue;let r=typeof s=="number"?this._format(n):String(s.label??this._format(n));t.append(u("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":String(this._ratio(n))}},r))}return t}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this._committedValue=this._value,this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:e}=this.refs;e.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let e=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",e),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(e){let t=Number(e);return Number.isFinite(t)?Fi(t,{min:this._min,max:this._max,step:this._step,precision:sf(this._step)}):this._min}_ratio(e){return Tt((e-this._min)/(this._max-this._min),0,1)}_format(e){let t=this.options.formatValue;return typeof t=="function"?String(t(e)):`${nf(e)}${this.options.unit??""}`}destroy(){let e=this.el;super.destroy(),!this._createdRoot&&e&&H(e,this._snapshot)}},tf=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function sf(i){return Pi(i)}function nf(i){return String(Number(i.toFixed(6)))}function Va(){E.register("slider",(i,e)=>{let t=i.own(new Ki(null,{label:e.label?String(e.label):void 0,hideLabel:!0,disabled:!!e.disabled,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),t.on("input",n=>i.emit("input",{value:n.detail.value})),{el:t.el,labelTarget:t.refs.input,get:()=>t.get(),set:n=>{s=!0;try{t.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}var rf=Object.freeze(["neutral","accent","success","warning","danger","info"]),of=Object.freeze(["soft","solid","outline"]),af=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),lf=Object.freeze({label:"",icon:null,kind:"neutral",tone:null,variant:"soft",size:"md",dot:!1});function Ba(i={}){let e={...lf,...i},t=u("span",{class:"zx-badge",title:e.title,dataset:{kind:cf(e.kind),variant:uf(e.variant),size:df(e.size),tone:Sn(e.tone)??void 0}});return e.dot?t.append(u("span",{class:"zx-badge__dot",ariaHidden:"true"})):e.icon&&t.append(x(e.icon,{size:12,class:"zx-badge__icon"})),e.label!==""&&e.label!=null?t.append(u("span",{class:"zx-badge__label"},String(e.label))):e.title&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.title)),t}function cf(i){return rf.includes(i)?i:"neutral"}function uf(i){return of.includes(i)?i:"soft"}function Sn(i){return af.includes(i)?i:null}function df(i){return i==="sm"?"sm":"md"}var Yi=class extends k{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",iconKey:"icon",colorKey:"color",toneKey:"tone",searchKeys:null,filter:"local",minQuery:0,debounce:200,allowCreate:!1,max:null,closeOnSelect:!1,placeholder:"",listHeight:260,disabled:!1,readonly:!1,renderItem:null,renderTag:null};render(){this._items=[],this._selected=[],this._visible=[],this._entries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._readonly=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._activeId=null,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:$(this.el);let e=this.el??u("div");this.el=e;let t=z("zx-tag-picker-list"),s=u("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=u("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:t,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),r=u("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},x("chevron-down",{size:T.chevron})),o=u("div",{ref:"control",class:"zx-tag-picker__control"},s,n,r),a=u("div",{ref:"list",class:"zx-tag-picker__list",id:t,role:"listbox",ariaMultiSelectable:"true"});a.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let l=u("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},a);return e.replaceChildren(o,l),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",c=>{let d=c.target;d.closest(".zx-tag-picker__remove")||d.closest(".zx-tag-picker__toggle")||(c.target!==n&&(c.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",c=>{let d=c.target.closest(".zx-tag-picker__remove");if(!d||this._disabled||this._readonly)return;c.stopPropagation();let h=[...s.children].indexOf(d.closest(".zx-tag-picker__tag")),p=this._selected[h];p!==void 0&&(this.removeValue(this._valueOf(p)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",c=>this._onKeydown(c)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(l,"pointerdown",c=>c.preventDefault()),this.listen(l,"click",c=>this._onOptionClick(c)),this.listen(document,"pointerdown",c=>{this._open&&!e.contains(c.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),e}get values(){return this.getValues()}set values(e){this.setValues(e)}getValues(){return this._selected.map(e=>this._valueOf(e))}getItems(){return this._selected.slice()}setValues(e,{silent:t=!1}={}){let s=Array.isArray(e)?e:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of s){if(r.length>=n)break;let l=this._resolve(a);l!==null&&!r.some(c=>this._sameValue(c,l))&&r.push(l)}let o=!hf(r,this._selected,a=>this._valueOf(a));return this._selected=r,this._renderTags(),this._renderOptions(),o&&!t&&this._emitChange(),this}addValue(e,{silent:t=!1}={}){if(this.isFull())return this;let s=this._resolve(e);return s===null?this:this._selected.some(n=>this._sameValue(n,s))?this:(this._selected.push(s),this._renderTags(),this._renderOptions(),t||(this.emit("add",{value:this._valueOf(s),item:s}),this._emitChange()),this)}removeValue(e,{silent:t=!1}={}){let s=this._valueOf(this._resolve(e)??e),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),s));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),t||(this.emit("remove",{value:this._valueOf(r),item:r}),this._emitChange()),this}clear({silent:e=!1}={}){return this.setValues([],{silent:e})}reset({silent:e=!1}={}){return this.setValues(this.options.values,{silent:e})}setItems(e){return this._cancelQuery(),this._items=Array.isArray(e)?e.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let e=this.options.max;return e!=null&&this._selected.length>=Number(e)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=ae(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._entries.length>0?0:-1),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(this.refs.input.value),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._activeId=null,this.refs.input.value="",this._syncInputWidth(),this._applyLocalFilter(""),this.emit("close",{}),this):this}focus(){return this.refs.input.focus(),this}enable(){return this._disabled=!1,this._renderTags(),this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._renderTags(),this._syncDisabled(),this}setReadonly(e){return e&&this.close(),this._readonly=!!e,this._renderTags(),this._syncDisabled(),this}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let e=this.el;super.destroy(),!this._createdRoot&&e&&H(e,this._snapshot)}_renderTags(){let e=this._selected.map(t=>{let s=this._labelOf(t),n=this._toneOf(t),r=n?null:this._colorOf(t),o=this.options.renderTag?[this.options.renderTag(t)]:[this._iconOf(t),u("span",{class:"zx-badge__label zx-tag-picker__tag-label"},s)],a=Ba({tone:n});return a.classList.add("zx-tag-picker__tag"),a.dataset.colored=String(!!r),r&&a.style.setProperty("--zx-tag-color",r),a.append(...o.filter(l=>l!=null)),!this._readonly&&!this._disabled&&a.append(u("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[s])},x("x",{size:T.chip}))),a});this.refs.tags.replaceChildren(...e),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let e=this.refs.list;this._entries=[];let t=[];for(let r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),l=u("div",{class:"zx-tag-picker__option",id:z("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},u("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?x("check",{size:T.check}):null),u("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(r):[this._iconOf(r),u("span",{},this._labelOf(r))]));!a&&this.isFull()&&l.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:l,create:!1}),t.push(l)}let s=this.refs.input.value.trim();if(this._canCreate(s)){let r=u("div",{class:"zx-tag-picker__option",id:z("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},u("span",{class:"zx-tag-picker__check",ariaHidden:"true"},x("plus",{size:T.check})),u("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[s])));this._entries.push({item:null,element:r,create:!0}),t.push(r)}t.length===0&&t.push(u("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),e.replaceChildren(...t);let n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n:this._entries.length>0?0:-1)}_entryId(e){return e.create?"\0create":String(this._valueOf(e.item))}_syncPlaceholder(){let e=this.refs.input;e.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let e=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(e):this._applyLocalFilter(e),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(e){if(this._disabled||this._readonly||e.isComposing||e.keyCode===229)return;let t=this.refs.input;switch(e.key){case"ArrowDown":e.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":e.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&t.value===""&&(e.preventDefault(),this._setActive(0));return;case"End":this._open&&t.value===""&&(e.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;e.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(e.preventDefault(),this.close());return;case"Backspace":t.value===""&&this._selected.length>0&&(e.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(e){let t=e.target.closest(".zx-tag-picker__option");if(!t)return;let s=this._entries.find(n=>n.element===t);s&&this._commitEntry(s)}_commitEntry(e){if(!e)return;let t=this.refs.input;if(e.create){let s=t.value.trim(),n=this._createItem(s);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}else{let s=this._valueOf(e.item);if(this._isSelected(s))this.removeValue(s);else if(!this.isFull())this.addValue(e.item);else return}t.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(e){if(this._entries.length===0)return;let t=this._activeIndex<0?e>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+e));this._setActive(t)}_setActive(e){this._activeIndex=e,this._activeId=this._entries[e]?this._entryId(this._entries[e]):null;for(let[t,s]of this._entries.entries()){let n=t===e;s.element.toggleAttribute("data-active",n),n&&(this.refs.input.setAttribute("aria-activedescendant",s.element.id),s.element.scrollIntoView({block:"nearest"}))}e<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(e){if(typeof this.options.filter=="function")return;let t=this.options.searchKeys??[this.options.labelKey];this._visible=xe(this._items,e,t)}_scheduleAsyncQuery(e){this._cancelQuery();let t=String(e??"");if(t.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(t)},s)}async _runQuery(e){let t=this._requestSequence+1;this._requestSequence=t,this._setLoading(!0),this.emit("query",{query:e});try{let s=await this.options.filter(e);if(t!==this._requestSequence)return;this._items=Array.isArray(s)?s.slice():[],this._visible=this._items.slice()}catch(s){if(t!==this._requestSequence)return;this._visible=[],this.emit("error",{error:s})}finally{t===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(e){this._loading=e,this.el.toggleAttribute("data-loading",e)}_isSelected(e){return this._selected.some(t=>Object.is(this._valueOf(t),e))}_canCreate(e){if(!this.options.allowCreate||e===""||this.isFull())return!1;let t=s=>s.some(n=>qa(this._labelOf(n))===qa(e));return!t(this._items)&&!t(this._selected)}_createItem(e,t=e){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?e:{[this.options.valueKey]:t,[this.options.labelKey]:e,created:!0}}_resolve(e){if(e==null)return null;let t=this._valueOf(e),s=this._items.find(r=>Object.is(this._valueOf(r),t));if(s!==void 0)return s;let n=this._selected.find(r=>Object.is(this._valueOf(r),t));return n!==void 0?n:typeof e=="object"?e:this._createItem(String(e),e)}_sameValue(e,t){return Object.is(this._valueOf(e),this._valueOf(t))}_valueOf(e){let t=this.options.valueKey;return typeof t=="function"?t(e):e!==null&&typeof e=="object"?e[t]:e}_labelOf(e){let t=this.options.labelKey;return String(typeof t=="function"?t(e):e!==null&&typeof e=="object"?e[t]??"":e??"")}_iconOf(e){let t=this._readItem(e,this.options.iconKey),s=t&&typeof t=="object"&&typeof t.nodeType=="number"?t.cloneNode(!0):typeof t=="string"&&t.trim()?x(t,{size:12}):null;if(!s)return null;let n=this._toneOf(e),r=n?null:this._colorOf(e);return u("span",{class:"zx-tag-picker__visual",dataset:{tone:n??void 0},style:r?{"--zx-tag-color":r}:null,ariaHidden:"true"},s)}_colorOf(e){return Vi(this._readItem(e,this.options.colorKey))}_toneOf(e){return Sn(this._readItem(e,this.options.toneKey))}_readItem(e,t){return typeof t=="function"?t(e):e!==null&&typeof e=="object"&&typeof t=="string"?e[t]:null}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let e=this.refs.input,t=e.value.length;e.style.inlineSize=t===0?"":`${Math.min(40,t+1)}ch`}_syncDisabled(){let e=this.refs.input;e.disabled=this._disabled,e.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(e,t,s=[]){let n=this.msg(e,...s);return n!==e?n:s.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),t)}};function qa(i){return String(i??"").trim().toLocaleLowerCase()}function hf(i,e,t){return i.length!==e.length?!1:i.every((s,n)=>Object.is(t(s),t(e[n])))}function $a(){E.register("tagpicker",(i,e)=>{let t=i.own(new Yi(null,{placeholder:e.placeholder,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.values})}),{el:t.el,labelTarget:t.refs.input,get:()=>t.getValues(),set:n=>{s=!0;try{t.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}function ff(i,e="minutes"){let t=Math.round(Math.abs(Ha(He(i),e)));return{hours:Math.floor(t/3600),minutes:Math.floor(t/60)%60,seconds:t%60,negative:He(i)<0}}function pf(i,e="minutes"){Ft(e);let t=Math.abs(Math.trunc(He(i?.hours))),s=Math.abs(Math.trunc(He(i?.minutes))),n=Math.abs(Math.trunc(He(i?.seconds))),r=i?.negative?-1:1;return Ua(r*(t*3600+s*60+n),e)}var Wi=class extends k{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){Ft(this.options.unit);let e=this.el??u("div");this.el=e,this._originalAriaDisabled=e.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let t=u("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?this._message("timebox.durationWithSeconds","Duration in hours, minutes, and seconds"):this._message("timebox.duration","Duration in hours and minutes")});return this._content=t,this.options.signed&&(t.append(u("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:this._message("timebox.toggleSign","Toggle duration sign"),ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(t,"hours",this._message("timebox.hours","Hours"),!1),t.append(u("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(t,"minutes",this._message("timebox.minutes","Minutes"),!0),this.options.seconds&&(t.append(u("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(t,"seconds",this._message("timebox.seconds","Seconds"),!0)),e.append(t),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),e}get(e=this.options.unit){return pf(this._readParts(),e)}set(e,t=this.options.unit,s={}){t&&typeof t=="object"&&(s=t,t=this.options.unit),Ft(t);let n=He(e);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=Ua(Math.round(Ha(n,t)/60)*60,t)),this._parts=ff(n,t),this.options.signed||(this._parts.negative=!1),this._writeParts(),s.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(e,t,s,n){let r=u("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,maxLength:n?2:null,dataset:{segment:t,bounded:String(n)}});this._inputs.push(r),e.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{t==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let e={...this._parts};for(let t of this._inputs){let s=t.dataset.segment,n=t.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;e[s]=Math.max(0,Math.min(n,Math.trunc(He(t.value))))}return e}_commitSegments(){this._parts=this._readParts(),this._writeParts(),this._emitChange()}_writeParts(){for(let e of this._inputs){let t=e.dataset.segment;e.value=t==="hours"?String(this._parts[t]):mf(this._parts[t])}this.refs.sign&&(this.refs.sign.textContent=this._parts.negative?"-":"+",this.refs.sign.setAttribute("aria-pressed",String(this._parts.negative)),this.refs.sign.dataset.state=this._parts.negative?"negative":"positive")}_syncDisabled(){for(let e of this._inputs)e.disabled=this._disabled;this.refs.sign&&(this.refs.sign.disabled=this._disabled),this.el.setAttribute("aria-disabled",String(this._disabled))}_emitChange(){this.emit("change",{value:this.get(this.options.unit)})}_message(e,t){let s=this.msg(e);return s===e?t:s}};function He(i){let e=Number(i);return Number.isFinite(e)?e:0}function Ha(i,e){return Ft(e),e==="hours"?i*3600:e==="minutes"?i*60:i}function Ua(i,e){return Ft(e),e==="hours"?i/3600:e==="minutes"?i/60:i}function Ft(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function mf(i){return String(i).padStart(2,"0")}function Ka(){E.register("time",(i,e)=>{let t=i.own(new Wi(null,{...e.props??{},value:e.value}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:s.detail.value})),{el:t.el,labelTarget:t.el.querySelector(".zx-timebox__content")??void 0,get:()=>t.get(),set:s=>t.set(Number(s)||0,{silent:!0}),focus:()=>t.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var ct=class extends k{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,hideLabel:!1,disabled:!1};render(){let e=!this.el,t=this.el??u("button");if(this.el=t,t.localName!=="button")throw new TypeError("Toggle target must be a button element");return this._createdRoot=e,this._original=e?null:$(t),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,t.type="button",t.setAttribute("role","switch"),this._ariaLabel=t.getAttribute("aria-label"),this._labelEl=null,t.replaceChildren(u("span",{class:"zx-toggle__track",ariaHidden:"true"},u("span",{class:"zx-toggle__thumb"}))),this._syncLabel(this.options.label??null),this._sync(),this.listen(t,"click",()=>this.toggle()),t}get(){return this._checked}set(e,{silent:t=!1}={}){let s=!!e;return s===this._checked?this:(this._checked=s,this._sync(),t||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}setLabel(e){return this._syncLabel(e??null),this}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&H(this.el,this._original))}_syncLabel(e){let t=e===null?"":String(e),s=!!this.options.hideLabel;t&&!s?(this._labelEl||(this._labelEl=u("span",{class:"zx-toggle__label"}),this.el.append(this._labelEl)),this._labelEl.textContent=t):(this._labelEl?.remove(),this._labelEl=null),t&&s?this.el.setAttribute("aria-label",t):this._ariaLabel===null?this.el.removeAttribute("aria-label"):this.el.setAttribute("aria-label",this._ariaLabel)}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Ya(){E.register("toggle",(i,e)=>{let t=i.own(new ct(null,{...e.props??{},checked:!!e.value}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:s.detail.value})),{el:t.el,get:()=>t.getValue(),set:s=>t.set(!!s,{silent:!0}),focus:()=>t.el.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var Gi=class extends k{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let e=this.el??u("div");this._ownedNodes=[],this._disabled=!1,this._roving=null,this._dragIndex=-1,this._initialState=e.getAttribute("data-state"),this._initialDisabled=e.getAttribute("data-disabled"),this._values=Wa(this.options.values,!!this.options.unique);let t=z("zx-value-list-instructions");return this._list=u("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:this._message("valueList.values","Values"),ariaOrientation:"horizontal"}),this._input=u("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:this._message("valueList.add","Add value"),ariaDescribedby:t}),this._status=u("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=u("span",{class:"zx-value-list__instructions",id:t},this._message("valueList.instructions","Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder.")),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),e.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",s=>this._handleInputKeydown(s)),this.listen(this._list,"keydown",s=>this._handleChipKeydown(s)),this.listen(this._list,"click",s=>this._handleChipClick(s)),this.listen(this._list,"dragstart",s=>this._handleDragStart(s)),this.listen(this._list,"dragover",s=>{this._dragIndex>=0&&!this._disabled&&s.preventDefault()}),this.listen(this._list,"drop",s=>this._handleDrop(s)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(e,"click",s=>{s.target===e&&!this._disabled&&this.focus()}),this._renderChips(),this._syncRoving(),e}getValues(){return this._values.slice()}setValues(e,{silent:t=!1}={}){return this._values=Wa(e,!!this.options.unique),this._renderChips(),t||this.emit("change",{values:this.getValues()}),this}addValue(e){if(this._disabled)return!1;let t=String(e??"").trim();if(!t)return!1;if(this.options.unique&&this._values.includes(t))return this._showError(this._message("valueList.duplicate","This value already exists.")),!1;if(typeof this.options.validate=="function"){let s=this.options.validate(t);if(s!==!0)return this._showError(typeof s=="string"?s:this._message("valueList.invalid","This value is not valid.")),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(t),this._renderChips(),this.emit("add",{value:t}),this.emit("change",{values:this.getValues()}),!0}removeValue(e){if(this._disabled||!this.options.deletable)return!1;let t=this._values.indexOf(String(e));return t<0?!1:(this._removeAt(t),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this._syncRoving(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._syncRoving(),this._renderChips(),this}_syncRoving(){this._disabled?(this._roving?.destroy(),this._roving=null):this._roving??=_a(this._list,".zx-value-list__chip",{orientation:"horizontal",wrap:!1})}_renderChips(e=-1){let t=[...this._list.children].findIndex(r=>r.tabIndex===0),s=Math.min(e>=0?e:Math.max(0,t),this._values.length-1),n=this._values.map((r,o)=>u("li",{class:"zx-value-list__chip",role:"option",tabIndex:!this._disabled&&o===s?0:-1,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?this._message("valueList.removable","%1. Press Delete to remove.",r):r,dataset:{index:o}},u("span",{class:"zx-value-list__value"},r),this.options.deletable?u("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},x("x",{size:T.chip})):null));this._list.replaceChildren(...n),e>=0&&n[Math.min(e,n.length-1)]?.focus()}_handleInputKeydown(e){this._disabled||(e.key==="Enter"?(e.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):e.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(e.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(e){if(this._disabled)return;let t=e.target instanceof Element?e.target.closest("[data-index]"):null;if(!t)return;let s=Number(t.dataset.index);if((e.key==="Delete"||e.key==="Backspace")&&this.options.deletable){e.preventDefault(),this._removeAt(s,Math.min(s,this._values.length-2));return}let n=e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:0,r=e.key==="ArrowUp"?-1:e.key==="ArrowDown"?1:0,o=Math.max(0,Math.min(this._values.length-1,s+(n||r)));e.ctrlKey&&n&&this.options.sortable?(e.preventDefault(),this._move(s,o,!0)):r&&(e.preventDefault(),this._list.querySelector(`[data-index="${o}"]`)?.focus())}_handleChipClick(e){let t=e.target instanceof Element?e.target:null,s=t?.closest("[data-index]");!s||this._disabled||(t.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(s.dataset.index)):s.focus())}_handleDragStart(e){if(this._disabled||!this.options.sortable)return;let t=e.target instanceof Element?e.target.closest("[data-index]"):null;t&&(this._dragIndex=Number(t.dataset.index),this.el.dataset.state="dragging",e.dataTransfer?.setData("text/plain",String(this._dragIndex)),e.dataTransfer&&(e.dataTransfer.effectAllowed="move"))}_handleDrop(e){if(this._dragIndex<0||this._disabled)return;e.preventDefault();let t=e.target instanceof Element?e.target.closest("[data-index]"):null,s=t?Number(t.dataset.index):this._values.length-1;this._move(this._dragIndex,s,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(e,t,s){if(e===t||e<0||t<0||e>=this._values.length||t>=this._values.length)return;let[n]=this._values.splice(e,1);this._values.splice(t,0,n),this._renderChips(s?t:-1),this.emit("change",{values:this.getValues()})}_removeAt(e,t=-1){let[s]=this._values.splice(e,1);s!==void 0&&(this._renderChips(t),t<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:s}),this.emit("change",{values:this.getValues()}))}_showError(e){this._status.textContent=e,this._input.setAttribute("aria-invalid","true")}_message(e,t,...s){let n=this.msg(e,...s);return n===e?q(t,s):n}destroy(){this._roving?.destroy(),this._roving=null;for(let e of this._ownedNodes??[])e.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function Wa(i,e){if(!Array.isArray(i))return[];let t=i.map(s=>String(s));return e?[...new Set(t)]:t}function Ga(){E.register("valuelist",(i,e)=>{let t=i.own(new Gi(null,{...e.props??{},values:Array.isArray(e.value)?e.value:[]}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:s.detail.values})),{el:t.el,get:()=>t.getValues(),set:s=>t.setValues(Array.isArray(s)?s:[],{silent:!0}),focus:()=>t.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var Zi=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),gf=["xl","lg","md","sm"];function Za(i){let e=Number(i);if(!Number.isFinite(e))return"xs";for(let t of gf)if(e>=Zi[t])return t;return"xs"}function Qa(i,e={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in e&&!U(e.target)&&e.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let t=e.target??globalThis,s=U(t)?t:null,n=null,r=!1,o=null,a=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,l=()=>{if(r)return;let h=a();if(s&&h===0)return;let p=Za(h);p!==n&&(n=p,i(n,h))};l();let c=0,d=()=>{c||r||(c=requestAnimationFrame(()=>{c=0,l()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(d),o.observe(s)):globalThis.addEventListener?.("resize",l,{passive:!0}),{current:()=>n??Za(a()),destroy:()=>{r||(r=!0,c&&cancelAnimationFrame(c),o?.disconnect(),globalThis.removeEventListener?.("resize",l))}}}var Ja="data-zx-motion",_f='[data-zx-motion="reduced"]',bf="(prefers-reduced-motion: reduce)";function Qi(i){if(yf())return!0;let e=i??globalThis.document?.documentElement??null;return wf(e)}function yf(){return typeof globalThis.matchMedia=="function"&&globalThis.matchMedia(bf).matches}function wf(i){let e=i;for(;e&&typeof e.closest=="function";){if(e.closest(_f))return!0;let t=e.getRootNode?.();e=vf(t)?t.host:null}return!1}function vf(i){return!!i&&i.nodeType===11&&"host"in i}function Xa(i,e){i.replaceChildren(),xf(i,e)}function xf(i,e){if(e!=null)if(typeof e=="string"||typeof e=="number")i.append(document.createTextNode(String(e)));else if(typeof e.toElement=="function"){let t=e.toElement();t&&i.append(t)}else typeof e.nodeType=="number"&&i.append(e)}var Sf=".zx-scope, [data-zx-theme], [data-zx-preset]",Af="dialog:modal, dialog[open], dialog:popover-open";function he(i=null){return tl(el(i))}function Pt(i=null){let e=el(i);return(i==null?null:dt(e))??tl(e)}function ut(i=null,e={}){let t=e.dialog===!1?he:Pt;if(i==null)return t(null);let s=te(i);return s?.isConnected?t(s):null}function dt(i){if(!i||typeof i.closest!="function")return null;try{return i.closest(Af)}catch{return i.closest("dialog[open]")}}function el(i){return i==null?document.activeElement instanceof Element?document.activeElement:null:te(i)}function tl(i){let e=i?.closest?.(Sf)??null;return!e||e===document.documentElement||e===document.body?document.body:e}var nl=new Set(["tooltip","toast"]);function Ne(i,e){if(!i||!e)return!1;for(let t=e;t;t=t.parentNode??t.host??null)if(t===i)return!0;return!1}function kf(i,e){for(let t=i.length-1;t>=0;t-=1){let s=i[t];if(!nl.has(s.kind)&&e.some(n=>Ne(s.root,n)))return s}return null}function jt(i,e,t){return t?Ne(e.root,t)||e.inside.some(s=>Ne(s,t))?!0:i.some(s=>s.parent===e&&jt(i,s,t)):!1}function An(i,e=()=>!0){for(let t=i.length-1;t>=0;t-=1){let s=i[t];if(s.kind!=="toast"&&e(s))return s}return null}function Cf(i,e=null){let t=[];for(let s=i.length-1;s>=0;s-=1){let n=i[s];if(n.kind==="modal")break;e&&!Ne(e,n.root)||typeof n.onEscape=="function"&&t.push(n)}return t}function zf(i,e,t=null){if(i.some(n=>n.kind==="toast"&&Ne(n.root,e)))return[];let s=[];for(let n=i.length-1;n>=0;n-=1){let r=i[n];r.kind==="tooltip"&&!jt(i,r,e)&&r.onOutsidePointer&&s.push(r)}for(let n=i.length-1;n>=0;n-=1){let r=i[n];if(!nl.has(r.kind)){if(jt(i,r,e)||r.kind==="modal")break;t&&!Ne(t,r.root)||r.onOutsidePointer&&s.push(r)}}return s}var Cn=class{#e=[];#t=0;#i=null;#s=new Set;#n;#r=new WeakMap;constructor(e={}){this.#n=e.target===void 0?typeof document>"u"?null:document:e.target}push(e){let t=il(e.anchor),s={order:++this.#t,kind:e.kind,root:e.root,owner:e.owner??null,anchors:t,inside:il(e.inside),parent:e.kind==="toast"?null:kf(this.#e,t),onEscape:e.onEscape,onOutsidePointer:e.onOutsidePointer,onFocusOutside:e.onFocusOutside,onParentClose:e.onParentClose};this.#e.push(s);let n={entry:s,order:s.order,isOpen:()=>this.#e.includes(s),isTopmost:()=>An(this.#e)===s,contains:r=>this.#e.includes(s)&&jt(this.#e,s,r),release:()=>this.#o(s)};return this.#r.set(s,n),this.#c(),this.#a(),n}entries(){return this.#e.slice()}topmost(e){return An(this.#e,e)}topmostModal(){let e=An(this.#e,s=>s.kind==="modal"&&s.root.isConnected&&Ef(s.root,":modal",!0));if(e)return e.root;if(typeof document>"u"||typeof document.querySelectorAll!="function")return null;let t;try{t=document.querySelectorAll("dialog:modal")}catch{return null}return t.length?t[t.length-1]:null}containsNode(e){return this.#e.some(t=>Ne(t.root,e)||t.inside.some(s=>Ne(s,e)))}subscribe(e){return this.#s.add(e),()=>{this.#s.delete(e)}}handleKeydown(e){if(e.key!=="Escape"||e.defaultPrevented||e.isComposing)return null;for(let t of Cf(this.#e,sl(kn(e)))){let s=this.#r.get(t);if(!(!s||!this.#e.includes(t))&&t.onEscape?.(e,s)!==!1)return e.preventDefault(),t}return null}handlePointerdown(e){let t=kn(e),s=zf(this.#e,t,sl(t));for(let n of s){let r=this.#r.get(n);r&&this.#e.includes(n)&&n.onOutsidePointer?.(e,r)}return s}handleFocusin(e){let t=kn(e);for(let s of this.#e.slice().reverse()){if(typeof s.onFocusOutside!="function"||!this.#e.includes(s)||jt(this.#e,s,t))continue;let n=this.#r.get(s);n&&s.onFocusOutside(e,n)}}#o(e){let t=this.#e.indexOf(e);if(t<0)return;this.#e.splice(t,1);let s=this.#e.filter(n=>n.parent===e);for(let n of s)n.parent=e.parent;this.#e.length===0&&this.#u(),this.#a();for(let n of s.reverse()){let r=this.#r.get(n);r&&this.#e.includes(n)&&n.onParentClose?.(r)}}#c(){if(this.#i||!this.#n||typeof this.#n.addEventListener!="function")return;let e=new AbortController;this.#i=e;let{signal:t}=e;this.#n.addEventListener("keydown",s=>this.handleKeydown(s),{signal:t}),this.#n.addEventListener("pointerdown",s=>this.handlePointerdown(s),{capture:!0,signal:t}),this.#n.addEventListener("focusin",s=>this.handleFocusin(s),{signal:t})}#u(){this.#i?.abort(),this.#i=null}#a(){let e=this.#e.slice();for(let t of[...this.#s])try{t(e)}catch(s){queueMicrotask(()=>{throw s})}}},Ue=new Cn;function ht(i){return Ue.push(i)}function il(i){let e=Array.isArray(i)?i:[i];return e.filter((t,s)=>t!=null&&e.indexOf(t)===s)}function sl(i){for(let e=i;e;e=e.parentNode??e.host??null)if(e.localName==="dialog"&&typeof e.matches=="function")try{if(e.matches(":modal"))return e}catch{return null}return null}function kn(i){return(typeof i.composedPath=="function"?i.composedPath():[])[0]??i.target??null}function Ef(i,e,t){if(typeof i.matches!="function")return t;try{return i.matches(e)}catch{return t}}function rl(i){try{return Array.from(i.querySelectorAll("dialog:modal"))}catch{return[]}}function Vt(i){return!!i.open||i.hasAttribute("open")}function ol(i){let e=i;return typeof e.showModal=="function"?(e.showModal(),!0):(e.setAttribute("open",""),!1)}function zn(i,e){let t=i;if(typeof t.close=="function"){e===void 0?t.close():t.close(e);return}Vt(t)&&(e!==void 0&&(t.returnValue=String(e)),t.removeAttribute("open"),queueMicrotask(()=>t.dispatchEvent(new Event("close"))))}var al=Object.freeze({mod:["\u2318","Ctrl"],meta:["\u2318","Meta"],cmd:["\u2318","Ctrl"],command:["\u2318","Ctrl"],ctrl:["\u2303","Ctrl"],control:["\u2303","Ctrl"],alt:["\u2325","Alt"],option:["\u2325","Alt"],shift:["\u21E7","Shift"],backspace:["\u232B","Backspace"],delete:["\u2326","Del"],tab:["\u21E5","Tab"]}),ll=Object.freeze({enter:"\u21B5",return:"\u21B5",escape:"Esc",esc:"Esc",space:"Space",arrowup:"\u2191",up:"\u2191",arrowdown:"\u2193",down:"\u2193",arrowleft:"\u2190",left:"\u2190",arrowright:"\u2192",right:"\u2192",pageup:"PgUp",pagedown:"PgDn",home:"Home",end:"End"});function Tf(){let i=globalThis.navigator;if(!i)return!1;let e=i.userAgentData?.platform||i.platform||"";return/mac|iphone|ipad|ios/i.test(e)}function Mf(i){if(i==="+")return["+"];let e=i.split("+");return i.endsWith("++")&&e.splice(-2,2,"+"),e.map(t=>t.trim()).filter(t=>t!=="")}function If(i,e){let t=i.toLowerCase();return Object.hasOwn(al,t)?al[t][e?0:1]:Object.hasOwn(ll,t)?ll[t]:i.length===1?i.toUpperCase():i}function Df(i,{apple:e=Tf()}={}){return(Array.isArray(i)?i.map(String):Mf(String(i))).map(s=>If(s,e))}function Ae(i,e={}){return u("kbd",{class:"zx-kbd",dataset:{size:e.size==="sm"?"sm":void 0,tone:e.tone==="inherit"?"inherit":void 0}},Df(i).map(t=>u("kbd",{class:"zx-kbd__key"},t)))}var Of=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),Nf=Object.freeze({sm:!0,md:!0,lg:!0});function cl(i={}){let e={...Of,...i},t=String(e.label??""),s=u("span",{class:"zx-spinner",dataset:{size:Nf[e.size]?e.size:"md",kind:e.kind==="current"?"current":"accent"}},u("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return t?(s.setAttribute("role","status"),s.append(u("span",{class:"zx-spinner__label",dataset:{visible:e.showLabel?"true":null}},t))):s.setAttribute("aria-hidden","true"),s}var Rf=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function ul(i={}){let e={...Rf,...i},t=u("button",{class:"zx-btn",type:"button",disabled:!!e.disabled,title:e.title??(e.shortcut?`${e.label} (${e.shortcut.label})`:void 0),ariaKeyshortcuts:e.shortcut?.keys,dataset:{kind:Pf(e.kind),size:jf(e.size)}});return e.icon&&t.append(x(e.icon,{size:16})),e.label!==""&&t.append(u("span",{class:"zx-btn__label"},String(e.label))),e.shortcut&&t.append(Ff(e.shortcut.label)),!e.label&&e.title&&t.setAttribute("aria-label",e.title),typeof e.onclick=="function"&&(t.onclick=e.onclick),e.busy&&Lf(t,!0),t}function Lf(i,e){if(i.hasAttribute("data-busy-guard")||(i.setAttribute("data-busy-guard",""),i.addEventListener("click",t=>{i.getAttribute("aria-busy")==="true"&&(t.preventDefault(),t.stopImmediatePropagation())},{capture:!0})),i.querySelector(":scope > .zx-btn__spinner")?.remove(),e){i.setAttribute("aria-busy","true"),i.setAttribute("aria-disabled","true");let t=cl({size:"sm",kind:"current"});t.classList.add("zx-btn__spinner"),i.prepend(t)}else i.removeAttribute("aria-busy"),i.removeAttribute("aria-disabled");return i}function Ff(i){let e=Ae(String(i),{size:"sm"});return e.classList.add("zx-btn__shortcut"),e.setAttribute("aria-hidden","true"),e}function Pf(i){return["primary","danger","ghost"].includes(String(i))?i:"default"}function jf(i){return i==="sm"?"sm":"md"}function Ji(i,e){return i.size===e.size&&[...i].every(t=>e.has(t))}function Bt(i,e){return i.length===e.length&&i.every((t,s)=>Object.is(t,e[s]))}function Vf(i,e){return String(i).localeCompare(String(e))}function Bf(i,e){return i-e}function qf(i,e){return i.getTime()-e.getTime()}function $f(i,e,t="asc"){let s=i==null,n=e==null;if(s||n)return s&&n?0:s?1:-1;let r;return i instanceof Date&&e instanceof Date?r=qf(i,e):typeof i=="number"&&typeof e=="number"?r=Bf(i,e):r=Vf(i,e),t==="desc"?-r:r}function Hf(i,e="asc"){return(t,s)=>$f(i(t),i(s),e)}function En(i,e,t="asc"){let s=Hf(e,t);return i.map((n,r)=>({row:n,index:r})).sort((n,r)=>s(n.row,r.row)||n.index-r.index).map(({row:n})=>n)}var Uf=36,Kf=600;function Tn(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(i):setTimeout(i,16)}function qt(i){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(i):clearTimeout(i)}function dl(i,e,t=10){let s=Number(i),n=Number(e);return!(s>0)||!(n>0)?Math.max(1,Math.trunc(t)||10):Math.max(1,Math.floor(s/n)-1)}function Yf({total:i,rowHeight:e,scrollTop:t,viewport:s,overscan:n=1}){let r=Math.max(0,Math.trunc(Number(i)||0)),o=Number(e);if(r===0)return{start:0,end:0};if(!(o>0))return{start:0,end:1};let a=Math.max(Number(s)||0,o),l=Math.min(Math.max(Number(t)||0,0),Math.max(0,r*o-a)),c=Math.floor(l/o),d=Math.ceil((l+a)/o),h=Math.ceil(a*Math.max(0,Number(n)||0)/o);return{start:Math.max(0,c-h),end:Math.min(r,d+h)}}function Wf(i,e,t,s=[]){let n=t>e?[{from:e,to:t}]:[];for(let l of s)!Number.isInteger(l)||l<0||l>=i||(l<e||l>=t)&&n.push({from:l,to:l+1});n.sort((l,c)=>l.from-c.from);let r=[],o=null,a=0;for(let{from:l,to:c}of n)o&&l<=a?o.to=Math.max(o.to,c):(l>a&&r.push({gap:l-a}),o={from:l,to:c},r.push(o)),a=o.to;return a<i&&r.push({gap:i-a}),r}function Gf({index:i,rowHeight:e,scrollTop:t,viewport:s}){let n=i*e,r=n+e;return n<t?n:r>t+s?Math.max(0,Math.min(n,r-s)):t}var Xi=class{constructor(e){this.host=e,this.entries=[],this.drawn=new Map,this.spacers=[],this.rowHeight=Uf,this.viewport=Kf,this.offset=0,this.measured=!1,this.live=!1,this.frame=0,this.observer=null,this.probe=u("div",{class:"zx-table__row-probe",ariaHidden:"true"}),e.scroller.append(this.probe)}get total(){return this.entries.length}start(){if(this.live=!0,typeof ResizeObserver!="function"){this.schedule();return}this.observer=new ResizeObserver(()=>this.schedule()),this.observer.observe(this.host.scroller),this.observer.observe(this.probe)}schedule(){qt(this.frame),this.frame=Tn(()=>this.measure())}stop(){this.live=!1,qt(this.frame),this.observer?.disconnect(),this.observer=null}clear(){this.entries=[],this.drawn=new Map,this.spacers=[]}fill(e,t){this.clear(),this.entries=e,this._lay(this._segments(),s=>t.append(s))}settle(){this.live&&!this.measured&&this.measure()}measure(){let{start:e,end:t}=this._range(),s=this.drawn.get(Math.floor((e+t-1)/2))??this.drawn.values().next().value;if(!s?.isConnected)return;let{scroller:n,head:r,sticky:o}=this.host,a=s.getBoundingClientRect().height,l=n.clientHeight;if(!(a>0)||!(l>0))return;let c=r.getBoundingClientRect().height,d=Math.max(a,l-(o?c:0)),h=o?0:c,p=a!==this.rowHeight||d!==this.viewport||h!==this.offset;this.rowHeight=a,this.viewport=d,this.offset=h,this.measured=!0,p&&this.update()}update(){if(this.total===0)return;let e=this._segments(),{drawn:t,spacers:s}=this,{body:n,release:r,changed:o}=this.host;for(let[l,c]of t)e.some(d=>"from"in d&&l>=d.from&&l<d.to)||(t.delete(l),c.remove(),r(c));for(let l of s)l.remove();let a=n.firstChild;this._lay(e,l=>{l===a?a=a.nextSibling:n.insertBefore(l,a)}),o()}reveal(e){if(e<0||e>=this.total)return null;this.measure();let t=this._position(),s=Gf({index:e,rowHeight:this.rowHeight,scrollTop:t,viewport:this.viewport});return s!==t&&(this.host.scroller.scrollTop=s+this.offset),this.update(),this.drawn.get(e)??null}_position(){return Math.max(0,this.host.scroller.scrollTop-this.offset)}_range(){return Yf({total:this.total,rowHeight:this.rowHeight,scrollTop:this._position(),viewport:this.viewport})}_segments(){let{start:e,end:t}=this._range();return Wf(this.total,e,t,this.host.pins())}_lay(e,t){let s=0;for(let n of e){if("gap"in n){t(this._spacer(s,n.gap)),s+=1;continue}for(let r=n.from;r<n.to;r+=1){let o=this.drawn.get(r);o||(o=this.host.draw(this.entries[r]),this.drawn.set(r,o)),t(o)}}}_spacer(e,t){let s=this.spacers[e];return s||(s=u("tr",{class:"zx-table__spacer",ariaHidden:"true"},u("td",{colspan:this.host.colspan()})),this.spacers[e]=s),s.firstElementChild.style.blockSize=`${t*this.rowHeight}px`,s}};var Zf=new Set(["text","number","select","date","checkbox","textarea"]),Qf='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',Ut=class extends k{static cssName="table";static defaults={columns:[],data:[],rowId:"ID",sort:null,sortMode:"local",selectable:!1,stickyHeader:!0,responsive:!1,growing:!1,virtual:!1,height:null,emptyText:null,rowClass:null,rowKind:null,rowKinds:null,zebra:!0,variant:"default",editMode:!1,editTrigger:"double",hierarchy:!1,interactive:!1,label:null,labelledBy:null,rowReorder:!1,columnVisibility:!1,columnReorder:!1,hiddenColumns:[]};constructor(e,t={}){super(e,t)}render(){let e=this.el===null,t=this.el??u("div");if(this.el=t,this._createdRoot=e,this._original=e?null:$(t),this._columns=fl(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._rowKind=fp(this.options.rowKind),this._rowKinds=pp(this.options.rowKinds),this._spanning=this._hasSpanningRow(),this._sortWarned=!1,this._selected=new Set,this._selectionAnchorId=null,this._sort=ml(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=_p(this.options.editMode),this._editTrigger=this.options.editTrigger==="single"?"single":"double",this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._virtual=!!this.options.virtual,this._virtual&&bl(this.options.growing)&&console.warn("[zx.Table] `growing` is ignored: `virtual` already decides which rows are drawn."),this._growStep=this._virtual?null:bl(this.options.growing),this._indexed=!!(this._growStep||this._virtual),this._rendered=this._growStep??1/0,this._more=null,this._focusMode=this._editMode===!1?"row":"cell",this._interactive=!!(this.options.interactive||this.options.selectable||this._virtual||this._editMode!==!1||es(this.options.hierarchy,this._columns)||this._clickListened),this._current=null,this._rovingEl=null,this._extendBase=null,this._hierarchy=es(this.options.hierarchy,this._columns),this._hiddenColumns=new Set((Array.isArray(this.options.hiddenColumns)?this.options.hiddenColumns:[]).map(String).filter(s=>this._columns.some(n=>n.id===s))),this._hiddenColumns.size>=this._columns.length&&this._columns[0]&&this._hiddenColumns.delete(this._columns[0].id),this._dragId=null,this._grabbedId=null,this._columnControlIds=new Map,this._columnStatus=null,this._expanded=mp(this._hierarchy?.expanded),this._pinLayout=gl([],0),this._headerRows=1,this._headerRow=null,this._groupRow=null,this._pinObserver=null,this._pinFrame=0,this._pinProps=[],this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let s of $t(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(s);return this._reconcileExpanded(),gp(this.options.variant)==="plain"&&(t.dataset.variant="plain"),this._table=u("table",{class:"zx-table__table"}),this._syncGridRole(),this._colgroup=u("colgroup",{class:"zx-table__columns"}),this._thead=u("thead",{class:"zx-table__head"}),this._tbody=u("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=u("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:this._virtual&&this.options.zebra?"index":String(!!this.options.zebra)}},this._table),this._window=null,this._virtual&&(t.dataset.virtual="",this._window=new Xi({scroller:this._scroll,body:this._tbody,head:this._thead,sticky:!!this.options.stickyHeader,draw:s=>this._createRow(s.row,s.index,s),release:s=>this._releaseRow(s),pins:()=>this._windowPins(),colspan:()=>this._spanColspan(),changed:()=>{this._stacked&&this._applyStackedRoles(!0)}})),this._rowMoveMessage=this.options.rowReorder?u("div",{class:"zx-table__reorder-status",role:"status",ariaLive:"polite"}):null,this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._columnControls=this.options.columnVisibility||this.options.columnReorder?this._createColumnControls():null,this._editMode===!1?t.replaceChildren(...[this._columnControls,this._scroll,this._rowMoveMessage].filter(Boolean)):(t.dataset.editMode=this._editMode,this._editMessage=u("div",{class:"zx-table__message",id:z("zx-table-message"),role:"status",ariaLive:"polite"}),t.replaceChildren(...[this._columnControls,this._scroll,this._editMessage,this._rowMoveMessage].filter(Boolean))),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this._window&&(this._window.start(),this.listen(this._scroll,"scroll",()=>this._window.update(),{passive:!0})),typeof ResizeObserver!="function"&&typeof window<"u"&&this.listen(window,"resize",()=>{this._window?.schedule(),this._schedulePins()}),this.listen(this._tbody,"click",s=>this._handleBodyClick(s)),this.listen(this._tbody,"dblclick",s=>this._handleBodyDoubleClick(s)),this.options.rowReorder&&(this.listen(this._tbody,"dragstart",s=>this._handleRowDragStart(s)),this.listen(this._tbody,"dragover",s=>this._handleRowDragOver(s)),this.listen(this._tbody,"drop",s=>this._handleRowDrop(s)),this.listen(this._tbody,"dragend",()=>this._clearRowDrag()),this.listen(this._tbody,"keydown",s=>this._handleRowHandleKeydown(s))),this._columnControls&&(this.listen(this._columnControls,"change",s=>{let n=s.target;n?.classList.contains("zx-table__column-toggle")&&this.setColumnVisible(n.value,n.checked)}),this.listen(this._columnControls,"click",s=>this._handleColumnControlClick(s)),this.listen(this._columnControls,"keydown",s=>this._handleColumnControlKeydown(s))),this._editMode!==!1&&(this.listen(this._tbody,"keydown",s=>this._handleEditKeydown(s)),this.listen(document,"pointerdown",s=>this._handleDocumentPointerDown(s),{capture:!0})),this.listen(this._tbody,"keydown",s=>this._handleGridKeydown(s)),this.listen(this._tbody,"focusin",s=>this._handleFocusIn(s)),t}setLoading(e=!0){return e?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!e)),this}setData(e){this._rendered=this._growStep??1/0,this.setLoading(!1),_l(e),this._data=[...e],this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded();let t=this._pruneSelection();return this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}addData(e){return _l(e),this._data.push(...e),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(e,t){let s=this._data.findIndex(r=>Object.is(this._idFor(r),e));if(s<0)return this;let n=this._selected.delete(e);return this._data[s]=t,n&&this._selected.add(this._idFor(t)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(e,this._idFor(t))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(e){let t=this._data.findIndex(n=>Object.is(this._idFor(n),e));if(t<0)return this;this._data.splice(t,1),this._reconcileExpanded();let s=this._selected.delete(e);return Object.is(this._selectionAnchorId,e)&&(this._selectionAnchorId=null),this._extendBase=null,this._renderBody(),s&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(e){return this._data.find(t=>Object.is(this._idFor(t),e))??null}getData(){return[...this._data]}getColumns(){return this._columns.map(e=>({...e}))}setColumns(e,t={}){let s=fl(e),n=this.getColumnOrder(),r=this.getHiddenColumns(),o=this.getSort();return this._abortEdit({focus:!1}),this._columns=s,this._hiddenColumns=new Set(r.filter(a=>s.some(l=>l.id===a))),this._hiddenColumns.size>=s.length&&s[0]&&this._hiddenColumns.delete(s[0].id),this._sort=ml(o,s),this._hierarchy=es(this.options.hierarchy,s),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),t.silent||(Bt(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),Bt(r,this.getHiddenColumns())||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()})),this}getColumnOrder(){return this._columns.map(e=>e.id)}setColumnOrder(e,t={}){let s=xp(this._columns,e);if(Bt(s,this.getColumnOrder()))return this;let n=this._activeColumnControl(),r=new Map(this._columns.map(o=>[o.id,o]));return this._abortEdit({focus:!1}),this._columns=s.map(o=>r.get(o)),this._hierarchy=es(this.options.hierarchy,this._columns),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(n),t.silent||this.emit("columnorderchange",{order:this.getColumnOrder()}),this}moveColumn(e,t,s="before",n={}){if(s!=="before"&&s!=="after")throw new TypeError('Table column position must be "before" or "after"');let r=Sp(this.getColumnOrder(),String(e),String(t),s);if(Bt(r,this.getColumnOrder()))return this;if(this.setColumnOrder(r,n),this._columnStatus){let o=this._columns.find(l=>l.id===String(e)),a=this.getColumnOrder().indexOf(String(e));o&&a>=0&&(this._columnStatus.textContent=this._message("table.columnMoved","Moved %1 to position %2 of %3.",[ts(o),a+1,this._columns.length]))}return this}getVisibleColumns(){return this._visibleColumns().map(e=>e.id)}getHiddenColumns(){return this._columns.filter(e=>this._hiddenColumns.has(e.id)).map(e=>e.id)}setColumnVisible(e,t=!0,s={}){let n=String(e);if(!this._columns.find(l=>l.id===n))throw new RangeError(`Unknown table column: ${n}`);let o=this._activeColumnControl();if(!t&&!this._hiddenColumns.has(n)&&this._visibleColumns().length<=1)return this._renderColumnControls(o),this;let a=t?this._hiddenColumns.delete(n):!this._hiddenColumns.has(n);return!t&&a&&this._hiddenColumns.add(n),a?(this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(o),s.silent||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()}),this):this}toggleColumn(e,t={}){return this.setColumnVisible(e,this._hiddenColumns.has(String(e)),t)}moveRow(e,t,s="before"){if(!this.options.rowReorder||this._sort&&this.options.sortMode==="local")return this;let n=this.getRow(e),r=this.getRow(t);if(!n||!r||Object.is(e,t))return this;if(this._isSpanningRow(n))return this;let o=xl(this._data,this.options.rowId,e,t,s,this._hierarchy?.parentId);if(!o)return this;if(this.emit("rowmove",{row:n,id:e,target:r,targetId:t,position:s}).defaultPrevented)return this;if(this._data=o,this._renderBody(),this._rowMoveMessage){let l=this._siblingIds(e),c=l.findIndex(d=>Object.is(d,e));this._rowMoveMessage.textContent=this._message("table.rowMoved","Moved row to position %1 of %2.",[c+1,l.length])}return this._emitDataChange(),queueMicrotask(()=>this._rowHandle(e)?.focus()),this}empty(){let e=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._extendBase=null,this._renderBody(),e&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(e,t,s={}){if(this._spanning)return this._sortWarned||(this._sortWarned=!0,console.warn("[zx.Table] setSort() is inert while the data contains spanning rowKinds rows: sorting would scatter the rows out of the sections that group them.")),this;if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===e))throw new RangeError(`Unknown table column: ${e}`);let r=t??(this._sort?.id===e&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:e,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),s.silent||this.emit("sort",{id:e,dir:r}),this}getSort(){return this._sort?{...this._sort}:null}clearSort(e={}){return this._sort?(this._abortEdit({focus:!1}),this._sort=null,this._syncSortHeader(),e.silent||this.emit("sort",{id:null,dir:null}),this):this}getSelection(){return this._data.filter(e=>this._selected.has(this._idFor(e)))}setSelection(e){if(!Array.isArray(e))throw new TypeError("Table selection must be an array of row ids");let t=this._selectableIds(),s=new Set;if(this.options.selectable!==!1){for(let n of e)if(t.has(n)&&s.add(n),this.options.selectable==="single"&&s.size>0)break}return this._extendBase=null,Ji(this._selected,s)?this:(this._selected=s,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._extendBase=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(e,t={}){return this._expanded.has(e)?this.collapseRow(e,t):this.expandRow(e,t)}expandRow(e,t={}){return this._setRowExpanded(e,!0,t)}collapseRow(e,t={}){return this._setRowExpanded(e,!1,t)}expandAll(e={}){if(!this._hierarchy)return this;let s=$t(this._data,this.options.rowId,this._hierarchy.parentId).filter(n=>!this._expanded.has(n));for(let n of s)this._expanded.add(n);if(s.length&&this._renderBody(),!e.silent)for(let n of s)this._emitRowToggle(n,!0);return this}collapseAll(e={}){if(!this._hierarchy||this._expanded.size===0)return this;let t=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!e.silent)for(let s of t)this._emitRowToggle(s,!1);return this}setExpanded(e,t={}){if(!this._hierarchy)return this;let s=$t(this._data,this.options.rowId,this._hierarchy.parentId),n=Ep(s,this._expanded,e);if(n.opened.length===0&&n.closed.length===0)return this;if(this._expanded=n.expanded,this._renderBody(),!t.silent){for(let r of n.closed)this._emitRowToggle(r,!1);for(let r of n.opened)this._emitRowToggle(r,!0)}return this}getExpanded(){return this._data.map(e=>this._idFor(e)).filter(e=>this._expanded.has(e))}startEdit(e,t){if(this._editMode===!1)return this;let s=this._columns.find(p=>p.id===t);if(!s)return this;let n=this._data.find(p=>Object.is(this._idFor(p),e));if(n===void 0)return this;if(this._isSpanningRow(n))return this;let r=this._editMode==="row"&&this._hiddenColumns.has(s.id)?this._visibleColumns().find(p=>ft(p,n)!==!1)??null:s;if(!r||ft(r,n)===!1)return this;let o=r.id;if(this._edit){if(Object.is(this._edit.id,e)&&this._edit.cells.has(o))return this._edit.columnId=o,this._focusEditor(o),this;if(this.commitEdit(),this._edit)return this}let a=this._data.findIndex(p=>Object.is(this._idFor(p),e));if(a<0)return this;let l=this._data[a],c=this._rowById(e);if(!c)return this;let d=this._editMode==="row"?this._visibleColumns().filter(p=>ft(p,l)!==!1):[r],h=new Map;for(let p of d){let f=pl(c,p.id);if(!f)continue;let m=this._createEditor(f,p,l,a);m&&h.set(p.id,m)}return h.size===0?this:(this._edit={id:e,columnId:o,row:l,cells:h,tr:c},c.dataset.editing="true",this.emit("editstart",{row:l,id:e,column:r,columnId:o,value:l?.[o]}),this._focusEditor(o),this)}commitEdit(){let e=this._edit;if(!e)return this;let t=this.getRow(e.id)??e.row,s={};for(let[h,p]of e.cells)s[h]=p.read();let n=this._columns.filter(h=>e.cells.has(h.id)),r=hp(s,n,t,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),e.columnId=r.columnId,this.emit("editinvalid",{row:t,id:e.id,column:this._columns.find(h=>h.id===r.columnId)??null,columnId:r.columnId,value:s[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=dp(t,s),a=e.columnId;if(this.emit("editcommit",{row:t,id:e.id,column:this._columns.find(h=>h.id===a)??null,columnId:a,value:s[a],previous:t?.[a],changes:o}).defaultPrevented)return this;let c=this._editHasFocus(),d={...t,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(e.id,d),c&&this._focusCell(this._idFor(d),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(e=>e.row)}_projectedData(){return this._hierarchy?op(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((e,t)=>({row:e,id:this._idFor(e),index:t,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let e=this._projectedData();return this._rendered===1/0?e:e.slice(0,this._rendered)}growBy(e){if(!this._growStep)return this;let t=Number(e)>0?Math.trunc(Number(e)):this._growStep,s=this._rendered,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+t),this._rendered===s?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),this)}showAll(){return this.growBy(this._projectedData().length)}getRenderedCount(){return this._window?this._window.drawn.size:Math.min(this._rendered,this._projectedData().length)}reveal(e){if(this._window)return!!this._rowById(e,!0);let t=this._rowElements.get(e)?.[0];return t?.scrollIntoView({block:"nearest"}),!!t}_rowById(e,t=!1){let s=this._rowElements.get(e)?.[0];if(!this._window||s&&!t)return s;let n=this._hierarchyMeta?.get(e)?.visibleIndex;if(n!==void 0)return this._window.reveal(n)??void 0}_windowPins(){let e=t=>this._hierarchyMeta?.get(t)?.visibleIndex;return[this._currentPosition(),this._edit?e(this._edit.id):void 0,this._dragId==null?void 0:e(this._dragId)]}_currentPosition(){if(!this._current)return 0;let e=this._hierarchyMeta,t=e?.get(this._current.id)?.visibleIndex;if(t!==void 0)return t;let s=new Set,n=this._hierarchy?this.getRow(this._current.id):null;for(;n;){let r=oe(this._hierarchy.parentId,n);if(r==null||s.has(r))break;s.add(r);let o=e?.get(r)?.visibleIndex;if(o!==void 0)return o;n=this.getRow(r)}return Math.min(Math.max(this._current.visibleIndex??0,0),Math.max(0,this._window.total-1))}_releaseRow(e){let t=this._rowMeta.get(e)?.id,s=this._rowElements.get(t)?.filter(n=>n!==e);s?.length?this._rowElements.set(t,s):this._rowElements.delete(t)}_syncGrowing(){if(!this._growStep)return;let e=this._projectedData().length-this.getRenderedCount();if(e<=0){this._more?.remove(),this._more=null;return}let t=this._message("table.more","Show %1 more",[e]);this._more||(this._more=u("button",{class:"zx-table__more",type:"button"}),this.listen(this._more,"click",()=>this.growBy()),this.el.append(this._more)),this._more.textContent=t,this._more.setAttribute("aria-label",t)}_message(e,t,s){let n=this.msg(e,...s);return n===e?q(t,s):n}_watchWidth(){this._width?.destroy(),this._width=null;let e=this.options.responsive;!e||!(e in Zi)||(this._width=Qa((t,s)=>this._setStacked(s>0&&s<Zi[e]),{target:this.el}))}_setStacked(e){this._stacked!==e&&(this._stacked=e,this.el.toggleAttribute("data-stacked",e),this._applyStackedRoles(e),this._window?.schedule(),this.emit("stackedchange",{stacked:e}))}addEventListener(e,t,s){super.addEventListener(e,t,s),!(!t||e!=="rowclick"&&e!=="rowdblclick")&&(this._clickListened=!0,this._table&&!this._interactive&&(this._interactive=!0,this._syncGridRole(),this._renderBody()))}_gridRole(){return this._interactive?this._hierarchy?"treegrid":"grid":null}_syncGridRole(){let e=this._table,t=this._gridRole();t?e.setAttribute("role",t):e.removeAttribute("role"),this.options.labelledBy?e.setAttribute("aria-labelledby",String(this.options.labelledBy)):(this.options.label!=null||t)&&e.setAttribute("aria-label",this.options.label??this._message("table.label","Table",[])),t&&this.options.selectable==="multi"&&e.setAttribute("aria-multiselectable","true"),t?this.el.dataset.focus=this._focusMode:delete this.el.dataset.focus}_applyStackedRoles(e){let t=this._gridRole();t?this._table.setAttribute("role",t):e?this._table.setAttribute("role","table"):this._table.removeAttribute("role");for(let s of[this._thead,this._tbody])e?s.setAttribute("role","rowgroup"):s.removeAttribute("role");for(let[s,n]of[["tr","row"],["td",t?"gridcell":"cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(s))e?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._window?.stop(),this._pinObserver?.disconnect(),this._pinObserver=null,qt(this._pinFrame),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(H(this.el,this._original),this._restored=!0),super.destroy()}_visibleColumns(){return this._columns.filter(e=>!this._hiddenColumns.has(e.id))}_isSpanningRow(e){return this._rowKind===null||this._rowKinds===null?!1:vl(e,this._rowKind,this._rowKinds)}_hasSpanningRow(){return ip(this._data,this._rowKind,this._rowKinds)}_spanColspan(){return sp(this._visibleColumns().length,{selectable:this.options.selectable,rowReorder:this.options.rowReorder})}_selectableData(){let e=this._visibleData();return this._rowKind===null?e:e.filter(t=>!this._isSpanningRow(t))}_createColumnControls(){let e=u("div",{class:"zx-table__column-list"});this._columnList=e,this._columnStatus=u("div",{class:"zx-table__column-status",role:"status",ariaLive:"polite"});let t=u("details",{class:"zx-table__column-controls"},u("summary",{class:"zx-btn",dataset:{size:"sm"}},x("fields"),this._message("table.columns","Columns",[])),e);return this._renderColumnControls(),t}_renderColumnControls(e=null){if(!this._columnList)return;let t=this._visibleColumns(),s=this._columns.map((n,r)=>{let o=!this._hiddenColumns.has(n.id),a=this._columnControlIds.get(n.id);a||(a=z("zx-table-column"),this._columnControlIds.set(n.id,a));let l=this.options.columnVisibility?u("input",{id:a,class:"zx-table__column-toggle",type:"checkbox",value:n.id,checked:o,disabled:o&&t.length===1,dataset:{columnId:n.id,columnAction:"toggle"}}):null,c=ts(n),d=l?u("label",{for:a},l,u("span",{},c)):u("span",{class:"zx-table__column-label"},c),h=this.options.columnReorder?u("span",{class:"zx-table__column-order",role:"group",ariaLabel:this._message("table.moveColumn","Move %1",[c])},u("button",{class:"zx-table__column-move",type:"button",disabled:r===0,ariaLabel:this._message("table.moveColumnEarlier","Move %1 earlier",[c]),dataset:{columnId:n.id,columnAction:"up"}},x("chevron-up",{size:T.chevron})),u("button",{class:"zx-table__column-move",type:"button",disabled:r===this._columns.length-1,ariaLabel:this._message("table.moveColumnLater","Move %1 later",[c]),dataset:{columnId:n.id,columnAction:"down"}},x("chevron-down",{size:T.chevron}))):null;return u("div",{class:"zx-table__column-option",dataset:{columnId:n.id}},d,h)});if(this._columnList.replaceChildren(...s,this._columnStatus),e!==null){let n=[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===e.id&&o.dataset.columnAction===e.action});n?.disabled&&(n=[...this._columnList.querySelectorAll(".zx-table__column-move[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===e.id&&!o.disabled})??[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===e.id&&!o.disabled})),queueMicrotask(()=>{n?.isConnected&&n.focus()})}}_activeColumnControl(){let e=typeof document>"u"?null:document.activeElement;if(!e||!this._columnList?.contains(e))return null;let t=e.dataset.columnId,s=e.dataset.columnAction;return t&&s?{id:t,action:s}:null}_handleColumnControlClick(e){let t=e.target?.closest?.(".zx-table__column-move");if(!t||!this._columnList?.contains(t))return;let s=t.dataset.columnId,n=t.dataset.columnAction,r=this.getColumnOrder().indexOf(String(s));n==="up"&&r>0&&this.moveColumn(String(s),this._columns[r-1].id,"before"),n==="down"&&r>=0&&r<this._columns.length-1&&this.moveColumn(String(s),this._columns[r+1].id,"after")}_handleColumnControlKeydown(e){let t=e.target?.closest?.(".zx-table__column-move");if(!t||!this._columnList?.contains(t))return;let s=String(t.dataset.columnId),n=this.getColumnOrder(),r=n.indexOf(s);r<0||(e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),r>0&&this.moveColumn(s,n[r-1],"before")):e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),r<n.length-1&&this.moveColumn(s,n[r+1],"after")):e.key==="Home"?(e.preventDefault(),r>0&&this.moveColumn(s,n[0],"before")):e.key==="End"&&(e.preventDefault(),r<n.length-1&&this.moveColumn(s,n.at(-1),"after")))}_handleRowDragStart(e){let t=e.target?.closest?.(".zx-table__row-handle"),s=t?.closest("tr[data-row]"),n=s?this._rowMeta.get(s):null;if(!t||!n||this._sort&&this.options.sortMode==="local"){e.preventDefault();return}this._dragId=n.id,s.dataset.dragging="true",e.dataTransfer?.setData("text/plain","zx-table-row"),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")}_handleRowDragOver(e){if(this._dragId==null)return;let t=e.target?.closest?.("tr[data-row]"),s=t?this._rowMeta.get(t):null;if(!s||Object.is(s.id,this._dragId)||!this._canMoveTogether(this._dragId,s.id))return;e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),this._clearDropMarkers();let n=t.getBoundingClientRect();t.dataset.drop=e.clientY>=n.top+n.height/2?"after":"before"}_handleRowDrop(e){if(this._dragId==null)return;let t=e.target?.closest?.("tr[data-row]"),s=t?this._rowMeta.get(t):null,n=t?.dataset.drop==="after"?"after":"before";s&&this._canMoveTogether(this._dragId,s.id)&&(e.preventDefault(),this.moveRow(this._dragId,s.id,n)),this._clearRowDrag()}_handleRowHandleKeydown(e){let t=e.target?.closest?.(".zx-table__row-handle"),s=t?.closest("tr[data-row]"),n=s?this._rowMeta.get(s):null;if(!t||!n)return;if(e.key===" "||e.key==="Enter"){e.preventDefault(),this._grabbedId=Object.is(this._grabbedId,n.id)?null:n.id,t.setAttribute("aria-pressed",String(this._grabbedId!=null));let l=this._rowMoveMessage??this._editMessage;l&&(l.textContent=this._grabbedId==null?this._message("table.rowDropped","Row dropped",[]):this._message("table.rowGrabbed","Row grabbed. Use the arrow keys to move it.",[]));return}if(e.key==="Escape"&&this._grabbedId!=null){e.preventDefault(),this._grabbedId=null,t.setAttribute("aria-pressed","false");return}if(!Object.is(this._grabbedId,n.id)||!["ArrowUp","ArrowDown"].includes(e.key))return;e.preventDefault();let r=this._siblingIds(n.id),o=r.findIndex(l=>Object.is(l,n.id)),a=r[o+(e.key==="ArrowUp"?-1:1)];a!==void 0&&this.moveRow(n.id,a,e.key==="ArrowUp"?"before":"after")}_siblingIds(e){let t=this.getRow(e);if(!t)return[];let s=this._hierarchy?oe(this._hierarchy.parentId,t):null;return this._data.filter(n=>!this._hierarchy||In(oe(this._hierarchy.parentId,n),s)).map(n=>this._idFor(n))}_canMoveTogether(e,t){if(!this._hierarchy)return!0;let s=this.getRow(e),n=this.getRow(t);return!!(s&&n&&In(oe(this._hierarchy.parentId,s),oe(this._hierarchy.parentId,n)))}_rowHandle(e){return this._rowElements.get(e)?.[0]?.querySelector(".zx-table__row-handle")??null}_clearDropMarkers(){for(let e of this._tbody.querySelectorAll("tr[data-drop]"))delete e.dataset.drop}_clearRowDrag(){for(let e of this._tbody.querySelectorAll("tr[data-dragging]"))delete e.dataset.dragging;this._clearDropMarkers(),this._dragId=null}_hierarchyColumn(){return this._hierarchy?this._visibleColumns().some(e=>e.id===this._hierarchy.column)?this._hierarchy.column:this._visibleColumns()[0]?.id??null:null}_renderColumns(){let e=document.createDocumentFragment();this.options.rowReorder&&e.append(u("col",{class:"zx-table__reorder-column"})),this.options.selectable==="multi"&&e.append(u("col",{class:"zx-table__selection-column"}));let t=this._visibleColumns(),s=this._structuralColumns(),n=Cp(t,{virtual:this._virtual,structural:s});this._table.dataset.layout=n.layout,n.minInlineSize?this._table.style.setProperty("--zx-table-min-inline-size",n.minInlineSize):this._table.style.removeProperty("--zx-table-min-inline-size"),n.widths.forEach(r=>{let o=u("col");r&&(o.style.width=r),e.append(o)}),this._colgroup.replaceChildren(e),this._pinLayout=gl(t,s)}_structuralColumns(){return(this.options.rowReorder?1:0)+(this.options.selectable==="multi"?1:0)}_markPin(e,t,s,n=!1){e.dataset.pin=t,e.style.setProperty("--zx-table-pin-offset",`var(--zx-table-pin-${t}-${s}, 0px)`),n&&(e.dataset.pinEdge="")}_renderGroupRow(){let e=zp(this._visibleColumns());if(e.length===0)return null;let t=this._pinLayout,s=u("tr",{class:"zx-table__group-row"}),n=this._structuralColumns();if(n>0){let r=u("td",{class:"zx-table__group-blank",colspan:n});t.structural&&this._markPin(r,"start",0),s.append(r)}for(let r of e){let o=r.label===null?u("td",{class:"zx-table__group-blank",colspan:r.columns.length}):u("th",{class:"zx-table__group",scope:"col",colspan:r.columns.length,dataset:{group:r.label}},u("span",{class:"zx-table__group-label"},r.label));if(r.pin){let a=r.columns.map(c=>t.columns.get(c)),l=r.pin==="start"?a[0]:a[a.length-1];this._markPin(o,r.pin,l.slot,a.some(c=>c.edge))}s.append(o)}return s}_watchPins(){this._pinObserver?.disconnect();let e=this._headerRow?[...this._headerRow.cells].filter(t=>t.dataset.pin):[];if(this._groupRow?.cells[0]&&e.push(this._groupRow.cells[0]),e.length===0){this._measurePins();return}if(typeof ResizeObserver!="function"){this._schedulePins();return}this._pinObserver??=new ResizeObserver(()=>this._measurePins());for(let t of e)this._pinObserver.observe(t)}_schedulePins(){qt(this._pinFrame),this._pinFrame=Tn(()=>this._measurePins())}_measurePins(){let e=this._scroll.style,t=this._headerRow?[...this._headerRow.cells]:[];if(!t.some(a=>a.dataset.pin)&&!this._groupRow){for(let a of this._pinProps)e.removeProperty(a);this._pinProps=[];return}let n=t.map(a=>a.getBoundingClientRect().width);if(!n.some(a=>a>0))return;let r=[];for(let a of["start","end"]){let l=a==="start"?t.map((h,p)=>p):t.map((h,p)=>t.length-1-p),c=0,d=0;for(let h of l)t[h].dataset.pin===a&&(r.push([`--zx-table-pin-${a}-${c}`,`${Math.floor(d)}px`]),c+=1,d+=n[h]);c>0&&r.push([`--zx-table-pin-${a}`,`${Math.ceil(d)}px`])}if(this._groupRow){let a=this._groupRow.getBoundingClientRect().height;a>0&&r.push(["--zx-table-group-row-size",`${a}px`])}let o=new Set(r.map(([a])=>a));for(let a of this._pinProps)o.has(a)||e.removeProperty(a);for(let[a,l]of r)e.getPropertyValue(a)!==l&&e.setProperty(a,l);this._pinProps=[...o]}_renderHeader(){let e=u("tr",{class:"zx-table__header-row"}),t=this._pinLayout,s=this._renderGroupRow();if(this._headerRows=s?2:1,this._groupRow=s,this._headerRow=e,this.el.toggleAttribute("data-header-groups",!!s),this._indexed&&(s?.setAttribute("aria-rowindex","1"),e.setAttribute("aria-rowindex",String(this._headerRows))),this.options.rowReorder){let n=u("th",{class:"zx-table__reorder-header",scope:"col",ariaLabel:this._message("table.rowOrder","Row order",[])});t.structural&&this._markPin(n,"start",0),e.append(n)}if(this.options.selectable==="multi"){this._selectAll=u("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:this._message("table.selectAll","Select all rows",[])});let n=u("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.structural&&this._markPin(n,"start",this.options.rowReorder?1:0),e.append(n),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let r of this._selectableData())this._selected.add(this._idFor(r));else for(let r of this._selectableData())this._selected.delete(this._idFor(r));this._selectionAnchorId=null,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map,this._headerSpanning=this._spanning;for(let n of this._visibleColumns()){let r=u("th",{scope:"col",dataset:{column:n.id}}),o=n.align??(Mn(n)?"end":null);o&&(r.dataset.align=o),n.headerTitle&&(r.title=n.headerTitle);let a=wp(n);a!==null&&r.setAttribute("aria-label",a);let l=t.columns.get(n.id);if(l&&this._markPin(r,l.side,l.slot,l.edge),n.sortable&&!this._spanning){let c=u("button",{class:"zx-table__sort-button",type:"button",ariaLabel:a??void 0},u("span",{class:"zx-table__header-label"},n.label),u("span",{class:"zx-table__sort-icon",ariaHidden:"true"},x("arrow-up",{size:T.sort})));this.listen(c,"click",()=>{let d=this._sort?.id===n.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(n.id,d)}),r.append(c)}else r.append(u("span",{class:"zx-table__header-label"},n.label));this._headers.set(n.id,r),e.append(r)}this._thead.replaceChildren(...s?[s,e]:[e]),this._syncSortHeader(),this._watchPins()}_renderBody(){let e=this._captureFocus();this._abortEdit({focus:!1}),this._extendBase=null,this._selectionAnchorId=null,this._spanning=this._hasSpanningRow(),this._headers&&this._spanning!==this._headerSpanning&&this._renderHeader();let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._rovingEl=null;let s=this._projectedData();this._hierarchyMeta=new Map(s.map(n=>[n.id,n])),this._data.length===0?(this._window?.clear(),t.append(u("tr",{class:"zx-table__empty-row"},u("td",{class:"zx-table__empty",colspan:this._spanColspan()},this._emptyContent())))):this._window?(s.forEach((n,r)=>{n.visibleIndex=r}),this._window.fill(s,t)):this._visibleEntries().forEach((n,r)=>{t.append(this._createRow(n.row,n.index,{...n,visibleIndex:r}))}),this._tbody.replaceChildren(t),this._table.setAttribute("aria-colcount",String(this._visibleColumns().length+(this.options.selectable==="multi"?1:0)+(this.options.rowReorder?1:0))),this._indexed&&this._table.setAttribute("aria-rowcount",String(s.length+this._headerRows)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0),this._window?.settle(),this._syncRoving(e)}_emptyContent(){let e=this.options.emptyText;return e==null?this.msg("table.empty"):typeof e=="function"?e():e}_createRow(e,t,s){let n=this._idFor(e),r=u("tr",{dataset:{row:""}});this._indexed&&r.setAttribute("aria-rowindex",String(s.visibleIndex+1+this._headerRows)),this._virtual&&s.visibleIndex%2===1&&(r.dataset.stripe="");let o=typeof this.options.rowClass=="function"?this.options.rowClass(e):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean));let a=this._rowKind===null?null:yl(e,this._rowKind),l=a===null?null:wl(this._rowKinds,a),c=!!l?.span;a!==null&&(r.dataset.rowKind=a),l?.class&&r.classList.add(...String(l.class).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&!c&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(s.depth+1)),s.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._interactive&&(this._focusMode==="row"||this._hierarchy)&&(r.tabIndex=-1),this._rowMeta.set(r,{row:e,id:n,index:t,visibleIndex:s.visibleIndex});let d=this._rowElements.get(n)??[];if(d.push(r),this._rowElements.set(n,d),c){r.dataset.span="true";let h=u("th",{class:"zx-table__section-cell",scope:"colgroup",colspan:this._spanColspan()}),p=np(e,l,this._visibleColumns(),t);return p&&typeof p=="object"&&typeof p.nodeType=="number"?h.append(p):p!=null&&h.append(document.createTextNode(String(p))),this._focusMode==="cell"&&(h.tabIndex=-1),r.append(h),r}if(this.options.rowReorder){let h=u("button",{class:"zx-table__row-handle",type:"button",draggable:!0,dataset:{rowHandle:""},ariaPressed:String(Object.is(this._grabbedId,n)),disabled:!!(this._sort&&this.options.sortMode==="local"),title:this._sort&&this.options.sortMode==="local"?this._message("table.reorderBlocked","Clear sorting to reorder rows",[]):null},x("drag",{size:14})),p=u("td",{class:"zx-table__reorder-cell"},h);this._pinLayout.structural&&this._markPin(p,"start",0),r.append(p)}if(this.options.selectable==="multi"){let h=u("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",tabIndex:-1,checked:this._selected.has(n)}),p=u("td",{class:"zx-table__selection-cell"},h);this._pinLayout.structural&&this._markPin(p,"start",this.options.rowReorder?1:0),r.append(p)}return this._visibleColumns().forEach(h=>{let p=u("td"),f=h.align??(Mn(h)?"end":null);f&&(p.dataset.align=f),p.dataset.label=h.label,p.dataset.column=h.id,h.popin===!1&&(p.dataset.popin="false");let m=this._pinLayout.columns.get(h.id);m&&this._markPin(p,m.side,m.slot,m.edge),this._focusMode==="cell"&&(p.tabIndex=-1),this._editMode!==!1&&ft(h,e)!==!1&&(p.dataset.editable="true"),this._renderCellContent(p,h,e,t,s),r.append(p)}),this._rowNames.set(r,tp([...r.cells].map(h=>h.textContent))),this._labelRowControls(r),r}_labelRowControls(e){let t=this._rowMeta.get(e);if(!t)return;let s=this._rowNames.get(e)??this._message("table.row","row %1",[t.index+1]);e.querySelector(".zx-table__row-checkbox")?.setAttribute("aria-label",this._message("table.selectRow","Select %1",[s])),e.querySelector(".zx-table__row-handle")?.setAttribute("aria-label",this._message("table.moveRow","Move %1",[s]));let r=e.querySelector(".zx-table__tree-toggle");if(r){let o=r.getAttribute("aria-expanded")==="true";r.setAttribute("aria-label",o?this._message("table.collapseRow","Collapse %1",[s]):this._message("table.expandRow","Expand %1",[s]))}}_renderCellContent(e,t,s,n,r=this._hierarchyMeta?.get(this._idFor(s))){let o=rp(t,s,n),a=u("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?a.append(o):o!=null&&a.append(document.createTextNode(String(o))),!this._hierarchy||t.id!==this._hierarchyColumn()||!r){e.replaceChildren(...a.childNodes);return}let l=u("span",{class:"zx-table__tree-cell"});if(l.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let c=this._expanded.has(r.id);l.append(u("button",{class:"zx-table__tree-toggle",type:"button",tabIndex:-1,ariaExpanded:String(c)},x(c?"chevron-down":"chevron-right",{size:T.chevron})))}else l.append(u("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));l.append(a),e.replaceChildren(l),e.parentElement&&this._labelRowControls(e.parentElement)}_handleBodyClick(e){let t=e.target?.nodeType===1?e.target:e.target?.parentElement;if(this._edit&&Ht(t))return;let s=t?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(!n||t.closest(".zx-table__row-handle")||this._edit&&(this.commitEdit(),this._edit))return;if(t.closest(".zx-table__tree-toggle")){this.toggleRow(n.id);return}let o=t.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(n,o.checked,e.shiftKey);return}if(!hl(t)){if(this._editMode!==!1&&this._editTrigger==="single"){let a=t?.closest('td[data-editable="true"]');if(a&&this._tbody.contains(a)){this.startEdit(n.id,String(a.dataset.column));return}}this._activateRow(n,e)}}_activateRow(e,t){this.emit("rowclick",{...e,event:t}),this.options.selectable==="single"&&!this._selected.has(e.id)&&!this._isSpanningRow(e.row)&&(this._selected=new Set([e.id]),this._selectionAnchorId=e.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange())}_handleBodyDoubleClick(e){let t=e.target?.nodeType===1?e.target:e.target?.parentElement;if(t?.closest(".zx-table__row-checkbox")||this._edit&&Ht(t))return;let s=t?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(n&&!hl(t)){if(this._editMode!==!1&&this._editTrigger==="double"){let r=t?.closest('td[data-editable="true"]');if(r&&this._tbody.contains(r)){this.startEdit(n.id,String(r.dataset.column));return}}this.emit("rowdblclick",{...n,event:e})}}_createEditor(e,t,s,n){let r=ft(t,s);if(r===!1)return null;let o=s?.[t.id],a=t.editorProps&&typeof t.editorProps=="object"?t.editorProps:{},l=u("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});l.append(...e.childNodes);let c=u("div",{class:"zx-table__editor",dataset:{editor:r}});e.replaceChildren(l,c),e.dataset.editing="true";let d={column:t,type:r,td:e,host:c,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){d.custom=o,d.read=()=>Ke(t,d.custom,s);let f={value:o,row:s,column:t,commit:g=>{d.custom=g,this.commitEdit()},cancel:()=>this.cancelEdit()},m=t.editor(s,f);return m&&typeof m.toElement=="function"?(typeof m.destroy=="function"&&(d.component=m),c.append(m.toElement())):m&&c.append(m),d.control=c.querySelector(Qf)??c,d}if(r==="number"){let f=Ye(t.locale,s),m=Sl(t,s),g=t.type==="currency"?Ye(t.currency,s):t.type==="unit"?Ye(t.unit,s):null,_={...f!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:f}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:m}:{},...g!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(g)}:{}},y=new lt(null,{..._,...a,value:o??null});return c.append(y.el),d.component=y,d.control=y.getInput(),d.read=()=>(y.set(y.getInput().value,{silent:!0}),Ke(t,y.get(),s)),d}if(r==="select"){let f=lp(t.options,s),m=f.find(_=>Object.is(_.value,o))??f.find(_=>String(_.value)===String(o??"")),g=new Y(null,{...a,items:f,valueKey:"value",labelKey:"label",value:m?m.value:null});return c.append(g.el),d.component=g,d.control=g.refs.input,d.read=()=>Ke(t,g.value,s),d}if(r==="date"){let f=new $e(null,{...a,value:o??null});c.append(f.el),d.component=f;let m=f.refs.input;return d.control=m,d.read=()=>{let g=String(m.value??"").trim(),_=f.get();return g===""?Ke(t,null,s):(f.set(g,{silent:!0}),f.get()===null&&f.set(_,{silent:!0}),Ke(t,f.get(),s))},d}if(r==="checkbox"){let f=new ct(null,{...a,checked:!!o});return c.append(f.el),d.component=f,d.control=f.el,d.read=()=>Ke(t,f.get(),s),d}let h=r==="textarea",p=u(h?"textarea":"input",{...a,class:h?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...h?{}:{type:"text"},ariaLabel:a.ariaLabel??this._message("table.cellInput","%1 row %2",[ts(t),n+1]),value:cp(t,o,s)});return c.append(p),d.control=p,d.read=()=>Ke(t,p.value,s),d}_focusEditor(e){let t=this._edit?.cells.get(e),s=t?.control;!s||typeof s.focus!="function"||(s.focus(),vp(t.type)&&typeof s.select=="function"&&s.select())}_focusCell(e,t){let s=this._rowById(e);(s?pl(s,t):null)?.focus()}_teardownEdit(){let e=this._edit;if(!e)return;this._edit=null;let t=this._data.findIndex(n=>Object.is(this._idFor(n),e.id)),s=t<0?e.row:this._data[t];for(let n of e.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.column,s,t<0?0:t);e.cells.clear(),delete e.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:e=!0}={}){let t=this._edit;if(!t)return;let s=e&&this._editHasFocus(),n=this.getRow(t.id)??t.row,r=this._columns.find(o=>o.id===t.columnId)??null;this._teardownEdit(),s&&this._focusCell(t.id,t.columnId),this.emit("editcancel",{row:n,id:t.id,column:r,columnId:t.columnId})}_editHasFocus(){let e=document.activeElement;return!!(e&&this.el?.contains(e))}_markInvalid(e,t){this._clearInvalid();let s=this._edit?.cells.get(e);s&&(s.td.dataset.invalid="true",s.control?.setAttribute("aria-invalid","true"),this._editMessage&&(s.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=t))}_clearInvalid(){if(this._edit)for(let e of this._edit.cells.values())delete e.td.dataset.invalid,e.control?.removeAttribute("aria-invalid"),e.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(e){let t=e.target?.nodeType===1?e.target:e.target?.parentElement;if(!t)return;if(this._edit&&Ht(t)){if(yp(t))return;if(e.key==="Escape"){if(e.defaultPrevented)return;e.preventDefault(),this.cancelEdit();return}if(e.key==="Enter"){if(t.localName==="textarea"&&e.shiftKey)return;e.preventDefault(),this.commitEdit();return}e.key==="Tab"&&this._moveEdit(e);return}if(e.key!=="Enter"&&e.key!=="F2")return;let s=t.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s.parentElement);n&&(e.preventDefault(),this.startEdit(n.id,String(s.dataset.column)))}_moveEdit(e){let t=this._edit;if(!t)return;let s=e.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),t.id)),r=this._nextEditableCell(n,t.columnId,s);if(r&&Object.is(r.id,t.id)&&t.cells.has(r.columnId)){e.preventDefault(),t.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&e.preventDefault();return}e.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(e,t,s){let n=this._visibleColumns(),r=n.length;if(e<0||r===0)return null;let o=this._visibleData(),a=this._idFor(this._data[e]),l=o.findIndex(h=>Object.is(this._idFor(h),a));if(l<0)return null;let c=n.findIndex(h=>h.id===t),d=o.length*r+r;for(let h=0;h<d;h+=1){if(c+=s,c>=r?(l+=1,c=0):c<0&&(l-=1,c=r-1),l<0||l>=o.length)return null;let p=o[l],f=n[c];if(!this._isSpanningRow(p)&&ft(f,p)!==!1)return{id:this._idFor(p),columnId:f.id,index:this._data.indexOf(p)}}return null}_handleDocumentPointerDown(e){if(!this._edit)return;let t=e.target?.nodeType===1?e.target:e.target?.parentElement;t&&Ht(t)||t&&this._tbody.contains(t)||this.commitEdit()}_navRows(){return[...this._tbody.children].filter(e=>e.hasAttribute("data-row"))}_navCells(e){return[...e.cells].filter(t=>t.hasAttribute("data-column")||t.classList.contains("zx-table__section-cell"))}_cellFor(e){let t=this._navCells(e);if(t.length===0)return e;let s=this._current?.columnId;return(s==null?null:t.find(r=>r.dataset.column===s))??t[Math.min(Math.max(this._current?.columnIndex??0,0),t.length-1)]}_rovingTarget(e){return this._focusMode==="row"||this._hierarchy&&this._current?.onRow?e:this._cellFor(e)}_setRoving(e){this._rovingEl&&this._rovingEl!==e&&(this._rovingEl.tabIndex=-1),e.tabIndex=0,this._rovingEl=e}_captureFocus(){let e=typeof document>"u"?null:document.activeElement;if(e&&e===this._scroll&&this._scroll.hasAttribute("data-empty-focus"))return{part:"row"};if(!e||!this._tbody?.contains(e))return null;let t=e.closest("tr[data-row]");return t?e===t?{part:"row"}:e.closest(".zx-table__row-checkbox")?{part:"checkbox"}:e.closest(".zx-table__tree-toggle")?{part:"toggle"}:e.closest(".zx-table__row-handle")?{part:"handle"}:{part:this._focusMode==="cell"?"cell":"row"}:null}_syncRoving(e){if(!this._interactive)return;let t=this._navRows();if(this._syncEmptyFocus(t.length===0&&e!==null),t.length===0)return;let s=this._current?this._rowElements.get(this._current.id)?.[0]:void 0;if(!s&&this._current&&this._hierarchy&&(s=this._renderedAncestor(this._current.id),s)){let a=this._rowMeta.get(s);this._current={...this._current,id:a.id,visibleIndex:a.visibleIndex,onRow:!0}}if(!s&&(s=this._window?this._window.drawn.get(this._currentPosition()):t[Math.min(Math.max(this._current?.visibleIndex??0,0),t.length-1)],this._current)){let a=this._rowMeta.get(s);this._current={...this._current,id:a.id,visibleIndex:a.visibleIndex}}let n=this._rovingTarget(s);if(this._setRoving(n),!e)return;let r={checkbox:".zx-table__row-checkbox",toggle:".zx-table__tree-toggle",handle:".zx-table__row-handle:not(:disabled)"}[e.part];(r?s.querySelector(r)??n:n).focus({preventScroll:!0})}_renderedAncestor(e){if(!this._hierarchy)return;let t=new Set,s=this.getRow(e);for(;s;){let n=oe(this._hierarchy.parentId,s);if(n==null||t.has(n))return;t.add(n);let r=this._rowElements.get(n)?.[0];if(r)return r;s=this.getRow(n)}}_syncEmptyFocus(e){let t=this._scroll;e?(t.hasAttribute("tabindex")||(t.tabIndex=-1,t.setAttribute("data-empty-focus","")),t.focus({preventScroll:!0})):t.hasAttribute("data-empty-focus")&&(t.removeAttribute("tabindex"),t.removeAttribute("data-empty-focus"))}_handleFocusIn(e){if(!this._interactive)return;let t=e.target?.nodeType===1?e.target:null,s=t?.closest("tr[data-row]")??null;if(!s||s.parentElement!==this._tbody)return;let n=this._rowMeta.get(s);if(!n)return;let r={id:n.id,visibleIndex:n.visibleIndex,columnId:this._current?.columnId??null,columnIndex:this._current?.columnIndex??0,onRow:!1},o=s;if(this._focusMode==="cell"){let a=this._navCells(s),l=a.find(c=>c===t||c.contains(t))??null;t===s&&this._hierarchy?r.onRow=!0:l?(o=l,l.dataset.column&&(r.columnId=l.dataset.column,r.columnIndex=a.indexOf(l))):(this._current=r,o=this._cellFor(s))}this._current=r,this._setRoving(o)}_handleGridKeydown(e){if(!this._interactive||e.defaultPrevented||e.altKey)return;let t=e.target?.nodeType===1?e.target:null;if(!t||this._edit&&Ht(t))return;let s=t.closest("tr[data-row]");if(!s||s.parentElement!==this._tbody)return;let n=this._rowMeta.get(s);if(!n)return;let r=this._focusMode==="cell",o=r?this._navCells(s):[],a=t===s,l=o.includes(t),c=t.matches(".zx-table__row-checkbox, .zx-table__tree-toggle");if(!a&&!l&&!c)return;let d=e.key,h=e.ctrlKey||e.metaKey;if(h&&(d==="a"||d==="A")){if(this.options.selectable!=="multi")return;e.preventDefault(),this._selectAllRendered();return}if((d==="Enter"||d===" ")&&!c){if(h)return;e.preventDefault(),d===" "&&this.options.selectable!==!1&&!this._isSpanningRow(n.row)?this._toggleRowSelection(n):this._activateRow(n,e);return}if(this._hierarchy&&(d==="ArrowLeft"||d==="ArrowRight")&&!h){let b=this._hierarchyMeta?.get(n.id);if(!b)return;e.preventDefault();let w=ep(d,{focus:l?"cell":"row",cells:r,column:l?o.indexOf(t):0,columns:o.length,hasChildren:b.hasChildren,expanded:this._expanded.has(n.id),hasParent:b.parentId!=null});w&&this._applyTreeAction(w,s,n,b.parentId);return}let p=this._navRows(),f=this._window?n.visibleIndex:p.indexOf(s),m=r&&!a,g=l?o.indexOf(t):Math.max(0,o.indexOf(this._cellFor(s))),_=Jf({row:f,column:g},d,{rows:this._window?.total??p.length,columns:m?o.length:1,page:this._pageSize(p),ctrl:h,cells:m});if(!_)return;e.preventDefault();let y=this._window?this._window.reveal(_.row):p[_.row];if(!m)y.focus();else if(_.row===f||d==="Home"||d==="End"){let b=this._navCells(y),w=_.column>=o.length-1&&d!=="Home";b[w?b.length-1:Math.min(_.column,b.length-1)]?.focus()}else this._cellFor(y).focus();e.shiftKey&&this.options.selectable==="multi"&&_.row!==f&&this._extendSelection(n,this._rowMeta.get(y))}_applyTreeAction(e,t,s,n){if(e.action==="expand")this.expandRow(s.id);else if(e.action==="collapse")this.collapseRow(s.id);else if(e.action==="parent")this._rowById(n)?.focus();else if(e.action==="child"){let r=this._navRows();(this._window?this._window.reveal(s.visibleIndex+1):r[r.indexOf(t)+1])?.focus()}else e.action==="row"?t.focus():e.action==="cell"&&this._navCells(t)[e.column??0]?.focus()}_pageSize(e){let t=this._scroll;if(!t||!e[0]||t.scrollHeight<=t.clientHeight+1)return 10;let s=this.options.stickyHeader?this._thead.getBoundingClientRect().height:0;return Xf(t.clientHeight-s,e[0].getBoundingClientRect().height)}_toggleRowSelection(e){let t=this._selected.has(e.id);if(this.options.selectable==="multi"){this._toggleMultiSelection(e,!t,!1);return}this._selected=t?new Set:new Set([e.id]),this._selectionAnchorId=e.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()}_selectAllRendered(){let e=new Set(this._selected);for(let t of this._selectableData())e.add(this._idFor(t));this._extendBase=null,!Ji(e,this._selected)&&(this._selected=e,this._syncSelection(),this._emitSelectionChange())}_extendSelection(e,t){if(!t)return;let s=this._visibleData(),n=l=>s.findIndex(c=>Object.is(this._idFor(c),l));this._extendBase===null&&(this._extendBase=new Set(this._selected),n(this._selectionAnchorId)<0&&(this._selectionAnchorId=e.id));let r=n(this._selectionAnchorId),o=n(t.id);if(r<0||o<0)return;let a=new Set(this._extendBase);for(let l=Math.min(r,o);l<=Math.max(r,o);l+=1)this._isSpanningRow(s[l])||a.add(this._idFor(s[l]));Ji(a,this._selected)||(this._selected=a,this._syncSelection(),this._emitSelectionChange())}_msgOr(e,t){let s=this.msg(e);return s===e?t:s}_toggleMultiSelection(e,t,s){let n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(s&&r>=0){let o=e.visibleIndex??n.findIndex(c=>Object.is(this._idFor(c),e.id)),a=Math.min(r,o),l=Math.max(r,o);for(let c=a;c<=l;c+=1){if(this._isSpanningRow(n[c]))continue;let d=this._idFor(n[c]);t?this._selected.add(d):this._selected.delete(d)}}else t?this._selected.add(e.id):this._selected.delete(e.id);this._selectionAnchorId=e.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[e,t]of this._rowElements){let s=this._selected.has(e);for(let n of t){if(n.hasAttribute("data-span"))continue;n.setAttribute("aria-selected",String(s));let r=n.querySelector(".zx-table__row-checkbox");r&&(r.checked=s)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let e=this._selectableData(),t=e.reduce((s,n)=>s+Number(this._selected.has(this._idFor(n))),0);this._selectAll.disabled=e.length===0,this._selectAll.checked=e.length>0&&t===e.length,this._selectAll.indeterminate=t>0&&t<e.length}_syncSortHeader(){if(this._headers)for(let[e,t]of this._headers)!this._spanning&&this._sort?.id===e?t.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):t.removeAttribute("aria-sort")}_sortData(){if(this._spanning=this._hasSpanningRow(),!this._sort||this._spanning)return;let e=this._columns.find(s=>s.id===this._sort.id);if(!e)return;let t=typeof e.sortValue=="function"?e.sortValue:s=>s?.[e.id];this._data=this._hierarchy?ap(this._data,this.options.rowId,this._hierarchy.parentId,t,this._sort.dir):En(this._data,t,this._sort.dir)}_setRowExpanded(e,t,s){return this._hierarchy?$t(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,e))?this._expanded.has(e)===t?this:(t?this._expanded.add(e):this._expanded.delete(e),this._renderBody(),s.silent||this._emitRowToggle(e,t),this):this:this}_emitRowToggle(e,t){let s=this.getRow(e);s&&this.emit("rowtoggle",{row:s,id:e,expanded:t})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let e=$t(this._data,this.options.rowId,this._hierarchy.parentId),t=new Set(e);for(let s of this._expanded)t.has(s)||this._expanded.delete(s)}_selectableIds(){let e=new Set;for(let t of this._data)this._isSpanningRow(t)||e.add(this._idFor(t));return e}_pruneSelection(){let e=this._selectableIds(),t=this._selected.size;for(let s of this._selected)e.has(s)||this._selected.delete(s);return e.has(this._selectionAnchorId)||(this._selectionAnchorId=null),this._extendBase=null,t!==this._selected.size}_idFor(e){return typeof this.options.rowId=="function"?this.options.rowId(e):e?.[this.options.rowId]}_emitSelectionChange(){let e=this.getSelection();this.emit("selectionchange",{rows:e,ids:e.map(t=>this._idFor(t))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function Jf(i,e,t){let s=Math.trunc(Number(t?.rows)||0);if(s<=0)return null;let n=Math.max(1,Math.trunc(Number(t?.columns)||1)),r=Math.max(1,Math.trunc(Number(t?.page)||10)),o=(h,p)=>Math.min(Math.max(Math.trunc(Number(h)||0),0),p),a=o(i?.row,s-1),l=o(i?.column,n-1),c=!!t?.cells,d=!!t?.ctrl;switch(e){case"ArrowUp":return{row:Math.max(0,a-1),column:l};case"ArrowDown":return{row:Math.min(s-1,a+1),column:l};case"PageUp":return{row:Math.max(0,a-r),column:l};case"PageDown":return{row:Math.min(s-1,a+r),column:l};case"ArrowLeft":return c?{row:a,column:Math.max(0,l-1)}:null;case"ArrowRight":return c?{row:a,column:Math.min(n-1,l+1)}:null;case"Home":return c?d?{row:0,column:0}:{row:a,column:0}:{row:0,column:l};case"End":return c?d?{row:s-1,column:n-1}:{row:a,column:n-1}:{row:s-1,column:l};default:return null}}function Xf(i,e,t=10){return dl(i,e,t)}function ep(i,e){let t=i==="ArrowRight";if(!t&&i!=="ArrowLeft")return null;if(e?.focus==="cell"){let r=Math.max(0,Math.trunc(Number(e.column)||0)),o=Math.max(1,Math.trunc(Number(e.columns)||1));return t?r<o-1?{action:"cell",column:r+1}:null:r>0?{action:"cell",column:r-1}:{action:"row"}}let s=!!e?.hasChildren,n=s&&!!e?.expanded;return t?s&&!n?{action:"expand"}:e?.cells?{action:"cell",column:0}:n?{action:"child"}:null:n?{action:"collapse"}:e?.hasParent?{action:"parent"}:null}function tp(i,e=80){for(let t of Array.isArray(i)?i:[]){let s=String(t??"").replace(/\s+/g," ").trim();if(s)return s.length>e?`${s.slice(0,Math.max(1,e-1)).trimEnd()}\u2026`:s}return null}function yl(i,e){if(e==null||e==="")return null;let t=typeof e=="function"?e(i):i?.[e];return t==null?null:String(t)}function wl(i,e){if(e===null||i==null||typeof i!="object"||!Object.prototype.hasOwnProperty.call(i,e))return null;let t=i[e];return t&&typeof t=="object"?t:null}function vl(i,e,t){return!!wl(t,yl(i,e))?.span}function ip(i,e,t){return!Array.isArray(i)||e==null||t==null?!1:i.some(s=>vl(s,e,t))}function sp(i,e={}){let t=Number.isFinite(Number(i))?Math.max(0,Math.trunc(Number(i))):0,s=(e.selectable==="multi"?1:0)+(e.rowReorder?1:0);return Math.max(1,t+s)}function np(i,e,t,s=0){if(typeof e?.render=="function")return e.render(i,s);let n=t?.[0];return n?i?.[n.id]:null}function rp(i,e,t=0){if(typeof i?.render=="function")return i.render(e,t);let s=e?.[i?.id],n=i?.type??"text";if(n==="text")return s;let r=Ye(i.locale,e),o=Sl(i,e),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return Fe(s,a);if(n==="currency"){let l=Ye(i.currency,e);return it(s,l==null?null:String(l),a)}if(n==="percent")return Fr(s,a);if(n==="unit"){let l=Fe(s,a),c=Ye(i.unit,e);return l&&c!=null&&String(c)!==""?`${l}\xA0${c}`:l}return s}function op(i,e,t,s=[]){let n=is(i,e,t),r=s instanceof Set?s:new Set(s),o=[],a=n.roots.slice().reverse().map(l=>({node:l,depth:0}));for(;a.length;){let{node:l,depth:c}=a.pop();if(o.push({row:l.row,id:l.id,index:l.index,depth:c,hasChildren:l.children.length>0,parentId:l.parent?.id??null}),!!r.has(l.id))for(let d=l.children.length-1;d>=0;d-=1)a.push({node:l.children[d],depth:c+1})}return o}function ap(i,e,t,s,n){let r=is(i,e,t),o=c=>En(c,d=>s(d.row),n),a=[],l=o(r.roots).reverse();for(;l.length;){let c=l.pop();a.push(c.row);let d=o(c.children);for(let h=d.length-1;h>=0;h-=1)l.push(d[h])}return a}function xl(i,e,t,s,n="before",r=null){if(!Array.isArray(i)||Object.is(t,s))return null;let o=i.findIndex(h=>Object.is(oe(e,h),t)),a=i.findIndex(h=>Object.is(oe(e,h),s));if(o<0||a<0||r&&!In(oe(r,i[o]),oe(r,i[a])))return null;if(r){let h=is(i,e,r),p=h.nodes[o],f=h.nodes[a];if(!p||!f||p.parent!==f.parent)return null;let m=A=>{let S=[],M=[A];for(;M.length;){let L=M.pop();S.push(L);for(let J=L.children.length-1;J>=0;J-=1)M.push(L.children[J])}return S},g=new Set(m(p).map(A=>A.index)),_=new Set(m(f).map(A=>A.index)),y=i.filter((A,S)=>g.has(S)),b=i.filter((A,S)=>!g.has(S)),w=i.map((A,S)=>S).filter(A=>!g.has(A)),v=w.findIndex(A=>A===a);if(n==="after"){let A=w.map((S,M)=>_.has(S)?M:-1).filter(S=>S>=0);v=Math.max(...A)+1}return v<0?null:(b.splice(v,0,...y),b)}let l=[...i],[c]=l.splice(o,1),d=l.findIndex(h=>Object.is(oe(e,h),s));return l.splice(d+(n==="after"?1:0),0,c),l}function ft(i,e){if(!i||typeof i!="object")return!1;if(typeof i.editor=="function")return typeof i.editable=="function"&&i.editable(e)===!1?!1:"custom";let t=typeof i.editable=="function"?i.editable(e):i.editable;return t===!0?Mn(i)?"number":"text":typeof t=="string"&&Zf.has(t)?t:!1}function lp(i,e){let t=typeof i=="function"?i(e):i;return Array.isArray(t)?t.map(s=>s!==null&&typeof s=="object"?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}):t!==null&&typeof t=="object"?Object.entries(t).map(([s,n])=>({value:s,label:String(n??"")})):[]}function cp(i,e,t){if(typeof i?.format=="function"){let s=i.format(e,t);return s==null?"":String(s)}return e==null?"":String(e)}function Ke(i,e,t){return typeof i?.parse=="function"?i.parse(e,t):e}function up(i,e){return Object.is(i,e)?!0:i instanceof Date&&e instanceof Date?i.getTime()===e.getTime():!1}function dp(i,e){let t={};for(let[s,n]of Object.entries(e??{}))up(i?.[s],n)||(t[s]=n);return t}function hp(i,e,t,s="Invalid value"){for(let n of e??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(i??{},n.id))continue;let r=n.validate(i[n.id],t);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:s}}return null}function Ye(i,e){return typeof i=="function"?i(e):i}function Sl(i,e){let t=Ye(i?.decimals,e);if(t==null)return null;let s=Number(t);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function Mn(i){return["number","currency","percent","unit"].includes(i?.type)}function is(i,e,t){let s=(Array.isArray(i)?i:[]).map((a,l)=>({row:a,id:oe(e,a),index:l,parent:null,children:[]})),n=new Map;for(let a of s)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of s){let l=oe(t,a.row),c=l==null?null:n.get(l)??null;r.set(a,c===a?null:c)}for(let a of s){let l=new Set([a]),c=r.get(a)??null;for(;c;){if(l.has(c)){r.set(c,null);break}l.add(c),c=r.get(c)??null}}let o=[];for(let a of s)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:s}}function $t(i,e,t){return is(i,e,t).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function oe(i,e){return typeof i=="function"?i(e):e?.[i]}function In(i,e){return i==null&&e==null||Object.is(i,e)}function es(i,e){if(!i||typeof i!="object")return null;let t=i.parentId;if(typeof t!="string"&&typeof t!="function")return null;let s=typeof i.column=="string"?i.column:null,n=e.some(r=>r.id===s)?s:e[0]?.id;return n?{...i,parentId:t,column:n}:null}function fp(i){return typeof i=="function"||typeof i=="string"&&i!==""?i:null}function pp(i){return!i||typeof i!="object"||Array.isArray(i)?null:i}function mp(i){return new Set(Array.isArray(i)?i:[])}function gp(i){return i==="plain"?"plain":"default"}function _p(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function Ht(i){return!!i?.closest?.(".zx-table__editor")}var bp=["a[href]","button","input","select","textarea","summary","label",'[contenteditable]:not([contenteditable="false"])',...["button","link","checkbox","switch","radio","menuitem","menuitemcheckbox","menuitemradio","tab","option","combobox","listbox","slider","spinbutton","textbox","searchbox"].map(i=>`[role="${i}"]`),'[tabindex]:not([tabindex="-1"])',"[data-zx-table-no-edit]"].join(",");function hl(i){let e=i?.closest?.("td[data-column], th.zx-table__section-cell"),t=i?.closest?.(bp);return!!(e&&t&&t!==e&&e.contains(t))}function yp(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function fl(i){if(!Array.isArray(i))throw new TypeError("Table columns must be an array");let e=new Set;return i.map((t,s)=>{if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`Table column at index ${s} must be an object`);let n=String(t.id??"").trim();if(!n)throw new TypeError(`Table column at index ${s} requires an id`);if(e.has(n))throw new TypeError(`Duplicate table column: ${n}`);return e.add(n),{...t,id:n,label:String(t.label??n)}})}function ts(i){for(let e of[i?.ariaLabel,i?.label]){let t=e==null?"":String(e).trim();if(t)return t}return String(i?.id??"")}function wp(i){let e=i?.label==null?"":String(i.label).trim(),t=i?.ariaLabel==null?"":String(i.ariaLabel).trim();return t||(e?null:ts(i)||null)}function vp(i){return i==="text"||i==="number"||i==="date"}function xp(i,e){let t=i.map(a=>a.id),s=new Set(t),n=Array.isArray(e)?e.map(String):[],r=new Set,o=[];for(let a of n)s.has(a)&&!r.has(a)&&(r.add(a),o.push(a));for(let a of t)r.has(a)||o.push(a);return o}function Sp(i,e,t,s="before"){let n=[...i],r=n.indexOf(e),o=n.indexOf(t);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(t)+(s==="after"?1:0);return n.splice(a,0,e),n}function pl(i,e){for(let t of i.cells)if(t.dataset.column===e)return t;return null}function ml(i,e){return!i||typeof i!="object"||!e.some(t=>t.id===i.id)?null:{id:i.id,dir:i.dir==="desc"?"desc":"asc"}}var Ap="5rem";function Al(i){if(typeof i!="string")return!1;let e=i.trim();return/^\d*\.?\d+[a-z]+$/i.test(e)?!/fr$/i.test(e):/^(?:calc|min|max|clamp|var)\(.*\)$/i.test(e)&&!e.includes("%")}function kp(i){return i===0||i==="0"||i===!1?null:typeof i=="number"?Number.isFinite(i)&&i>0?`${i}px`:void 0:Al(i)?i.trim():void 0}function Cp(i,e={}){let t=Array.isArray(i)?i:[],s=t.map(f=>Tp(f?.width)),n=s.reduce((f,m)=>f+m,0),r=n>0||e.virtual?"fixed":"auto",o=t.map((f,m)=>s[m]>0?`${s[m]/n*100}%`:f?.width&&f.width!=="auto"?String(f.width):null);if(r!=="fixed")return{layout:r,widths:o,minInlineSize:null};let a=[],l=new Map,c=!1;if(t.forEach((f,m)=>{let g=kp(f?.minWidth);if(s[m]>0){let _=g===void 0?Ap:g;if(_===null)return;c=!0,l.set(_,Math.max(l.get(_)??0,n/s[m]))}else Al(f?.width)?a.push(String(f.width).trim()):g&&(!f?.width||f.width==="auto")&&(c=!0,a.push(g))}),!c)return{layout:r,widths:o,minInlineSize:null};let d=Math.max(0,Math.trunc(Number(e.structural)||0));d>0&&a.unshift(d===1?"var(--zx-control-height)":`var(--zx-control-height) * ${d}`);let h=[...l].map(([f,m])=>{let g=Math.ceil(m*1e3)/1e3;return g===1?f:`${f} * ${g}`});h.length===1?a.push(h[0]):h.length>1&&a.push(`max(${h.join(", ")})`);let p=a.length===1&&!a[0].includes("*")?a[0]:`calc(${a.join(" + ")})`;return{layout:r,widths:o,minInlineSize:p}}function kl(i){return i?.pin==="start"||i?.pin==="end"?i.pin:null}function gl(i,e=0){let t=Array.isArray(i)?i:[],s=t.map(h=>kl(h)),n=new Map,r=Math.max(0,Math.trunc(Number(e)||0)),o=r>0&&s.includes("start"),a=o?r:0,l=s.lastIndexOf("start"),c=s.indexOf("end");s.forEach((h,p)=>{h==="start"&&(n.set(String(t[p].id),{side:h,slot:a,edge:p===l}),a+=1)});let d=0;for(let h=t.length-1;h>=0;h-=1)s[h]==="end"&&(n.set(String(t[h].id),{side:"end",slot:d,edge:h===c}),d+=1);return{start:a,end:d,structural:o,columns:n}}function zp(i){let e=Array.isArray(i)?i:[],t=[],s=!1;for(let n of e){let r=n?.group==null?null:String(n.group).trim()||null,o=kl(n);r!==null&&(s=!0);let a=t[t.length-1];a&&a.label===r&&a.pin===o?a.columns.push(String(n.id)):t.push({label:r,pin:o,columns:[String(n.id)]})}return s?t:[]}function Ep(i,e,t){let s=Array.isArray(i)?i:[],n=e instanceof Set?e:new Set,r=t!=null&&typeof t=="object"&&typeof t[Symbol.iterator]=="function",o=t===!0?null:new Set(r?t:[]),a=new Set(s.filter(l=>o===null||o.has(l)));return{expanded:a,opened:s.filter(l=>a.has(l)&&!n.has(l)),closed:s.filter(l=>n.has(l)&&!a.has(l))}}function Tp(i){if(typeof i!="string")return 0;let e=/^(\d*\.?\d+)fr$/.exec(i.trim());return e?Math.max(0,Number(e[1])):0}function _l(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function bl(i){let e=Math.trunc(Number(i));return Number.isFinite(e)&&e>0?e:null}var Jv=Object.freeze({queued:{status:"todo",tone:"neutral",key:"agent.status.queued"},running:{status:"in-progress",tone:"info",key:"agent.status.running"},waiting:{status:"waiting",tone:"warning",key:"agent.status.waiting"},paused:{status:"in-progress",tone:"muted",key:"agent.status.paused"},blocked:{status:"waiting",tone:"danger",key:"agent.status.blocked"},done:{status:"done",tone:"success",key:"agent.status.done"},failed:{status:"canceled",tone:"danger",key:"agent.status.failed"},stopped:{status:"canceled",tone:"muted",key:"agent.status.stopped"},skipped:{status:"canceled",tone:"muted",key:"agent.status.skipped"}}),Dn=Object.freeze({"needs-you":{tone:"warning",key:"agent.activity.needsYou"},blocked:{tone:"danger",key:"agent.activity.blocked"},working:{tone:"success",key:"agent.activity.working"},thinking:{tone:"info",key:"agent.activity.thinking"},idle:{tone:"neutral",key:"agent.activity.idle"},offline:{tone:"muted",key:"agent.activity.offline"}}),Xv=Object.freeze({queued:"idle",running:"working",waiting:"needs-you",paused:"idle",blocked:"blocked",done:"idle",failed:"blocked",stopped:"idle",skipped:"idle"}),Cl=Object.freeze({"agent.status.queued":"Not started","agent.status.running":"Running","agent.status.waiting":"Waiting for you","agent.status.paused":"Paused","agent.status.blocked":"Blocked","agent.status.done":"Done","agent.status.failed":"Failed","agent.status.stopped":"Stopped","agent.status.skipped":"Skipped","agent.activity.needsYou":"Needs you","agent.activity.blocked":"Blocked","agent.activity.working":"Working","agent.activity.thinking":"Thinking","agent.activity.idle":"Idle","agent.activity.offline":"Offline"});function ss(i){return typeof i=="string"&&Object.hasOwn(Dn,i)?i:null}var Mp=Object.freeze(["seed","tone","body","eyes","material","spacing"]),ns=Object.freeze(["activity","activityLabel","indicator","msg"]);function Ip(i,e){if(i===!0)return{};if(!i||typeof i!="object"||Array.isArray(i))return null;let t={};for(let s of e){let n=i[s];s==="spacing"?(n===0||n===1||n===2)&&(t.spacing=n):s==="seed"&&typeof n=="number"&&Number.isFinite(n)?t.seed=String(n):typeof n=="string"&&n&&(t[s]=n)}return t}function Dp(i){return Ip(i,[...Mp,"name"])}function rs(i,e={},t={}){let s=Dp(i);if(!s)return null;let n={};if(i&&typeof i=="object")for(let r of t.carry??[]){let o=i[r];o!==void 0&&(n[r]=o)}return{...t.fallback??{},...s,...n,...e}}var Op=50,zl=Object.freeze({idle:4.8,thinking:3.4,working:1.1,"needs-you":3.6}),Np=8,Rp=Object.freeze({y:0,r:0,s:1,w:0,blink:0}),os=Symbol("zx.presenceLoop"),Lp="(prefers-reduced-motion: reduce)",On=Object.freeze({attributes:!0,attributeFilter:[Ja],subtree:!0}),Fp=Object.freeze({set(){},untrack(){}});function Pp(i,e){let t=Number.isFinite(e)?e:0,s=n=>.5-.5*Math.cos(2*Math.PI*t/n);switch(i){case"idle":return{y:0,r:0,s:1+.035*s(4.8),w:0,blink:0};case"thinking":return{y:0,r:4*Math.sin(2*Math.PI*t/3.4),s:1,w:0,blink:0};case"working":return{y:-1.6*s(1.1),r:0,s:1,w:0,blink:0};case"needs-you":{let n=(t%3.6+3.6)%3.6,r=n<.18?Math.sin(Math.PI*n/.18):0;return{y:0,r:-8+Math.sin(2*Math.PI*t/2.6),s:1,w:1,blink:.28*r}}default:return{...Rp}}}function Ml(i){let e=0;for(let t of String(i??""))e=(e*31+(t.codePointAt(0)??0))%997;return e/997}function pt(i){if(typeof i!="number"||!Number.isFinite(i))return null;let e=i%1;return e<0?e+1:e}function Il(i){return typeof i=="string"&&Object.hasOwn(zl,i)?zl[i]:0}function jp(i,e){return(pt(e)??0)*Il(i)}function Vp(i){return Math.abs(i.y)<.01&&Math.abs(i.r)<.01&&Math.abs(i.s-1)<5e-4&&Math.abs(i.w)<.01}function Dl(i,e,t={}){let s=i?.ownerDocument;if(!s||typeof globalThis.requestAnimationFrame!="function"||typeof globalThis.IntersectionObserver!="function")return Fp;let n=Bp(s),r=n.entries.get(i);if(r)return r.activity=e??null,t&&Object.hasOwn(t,"phase")&&(r.phase=pt(t.phase)??0),Kt(n),El(n,i);let o={activity:e??null,phase:pt(t?.phase)??0,pose:{y:0,r:0,s:1,w:0},visible:!1,reduced:Qi(i),moved:!1};n.entries.set(i,o);for(let a of Ol(i))n.motion?.observe(a,On);return n.observer.observe(i),El(n,i)}function El(i,e){return{set(t,s){let n=i.entries.get(e);n&&(n.activity=t??null,s&&Object.hasOwn(s,"phase")&&(n.phase=pt(s.phase)??0),Kt(i))},untrack(){let t=i.entries.get(e);t&&(i.entries.delete(e),i.observer.unobserve(e),as(e,t),i.entries.size===0&&qp(i))}}}function Bp(i){let e=i,t=e[os];if(t)return t;let s={document:i,entries:new Map,observer:new IntersectionObserver(r=>{for(let o of r){let a=s.entries.get(o.target);if(a){if(a.visible=o.isIntersecting,a.visible){a.reduced=Qi(o.target);for(let l of Ol(o.target))s.motion?.observe(l,On)}a.reduced&&as(o.target,a)}}Kt(s)}),motion:typeof MutationObserver=="function"?new MutationObserver(()=>Tl(s)):null,abort:new AbortController,frame:0,last:0,time:0};return i.addEventListener("visibilitychange",()=>{i.hidden?Nl(s):Kt(s)},{signal:s.abort.signal}),i.documentElement&&s.motion?.observe(i.documentElement,On),(typeof globalThis.matchMedia=="function"?globalThis.matchMedia(Lp):null)?.addEventListener?.("change",()=>Tl(s),{signal:s.abort.signal}),e[os]=s,s}function qp(i){Nl(i),i.observer.disconnect(),i.motion?.disconnect(),i.abort.abort();let e=i.document;e[os]===i&&delete e[os]}function Tl(i){for(let[e,t]of i.entries){let s=Qi(e);s!==t.reduced&&(t.reduced=s,s&&as(e,t))}Kt(i)}function Ol(i){let e=[],t=i;for(;t&&typeof t.getRootNode=="function";){let s=t.getRootNode();if(!s||s.nodeType!==11||!("host"in s))break;e.push(s),t=s.host}return e}function $p(i){if(i.document.hidden)return!1;for(let e of i.entries.values())if(e.visible&&!e.reduced)return!0;return!1}function Kt(i){i.frame||!$p(i)||(i.last=performance.now(),i.frame=requestAnimationFrame(e=>Rl(i,e)))}function Nl(i){i.frame&&cancelAnimationFrame(i.frame),i.frame=0}function as(i,e){e.pose={y:0,r:0,s:1,w:0},e.moved&&i.style.removeProperty("transform"),e.moved=!1}function Rl(i,e){if(i.frame=0,i.document.hidden)return;let t=Math.min(Math.max(e-i.last,0),Op)/1e3;i.last=e,i.time+=t;let s=1-Math.exp(-t*Np),n=!1;for(let[r,o]of i.entries){if(!o.visible||o.reduced)continue;let a=Pp(o.activity,i.time+jp(o.activity,o.phase)),l=o.pose;if(l.y+=(a.y-l.y)*s,l.r+=(a.r-l.r)*s,l.s+=(a.s-l.s)*s,l.w+=(a.w-l.w)*s,Il(o.activity)===0&&Vp(l)){as(r,o);continue}n=!0,o.moved=!0;let c=1-l.w*a.blink;r.style.transform=`translateY(${l.y.toFixed(2)}px) rotate(${l.r.toFixed(2)}deg) scale(${l.s.toFixed(4)}, ${(l.s*c).toFixed(4)})`}n&&(i.frame=requestAnimationFrame(r=>Rl(i,r)))}var Nn=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),Ll=Object.freeze(Nn.filter(i=>i!=="slate"));var sx=Object.freeze(["online","away","busy","offline"]),nx=Object.freeze(["src","name","initials","label","size","shape","tone","status","statusLabel","activity","activityLabel","animate","phase"]);function Fl(i){let e=String(i??"").trim().normalize("NFC").toLowerCase();if(!e)return"slate";let t=2166136261;for(let s=0;s<e.length;s+=1)t^=e.charCodeAt(s),t=Math.imul(t,16777619);return Ll[(t>>>0)%Ll.length]}var Pl=Object.freeze(["circle","squircle","hexagon","triangle","drop","pill","clover","dome","wedge","pentagon","trapezoid","cross","diamond","octagon"]),jl=Object.freeze(["round","oval","square"]),Ln=Object.freeze({sm:24,md:32,lg:40}),Hp=Object.freeze([.85,1,1.15]),Vl=Object.freeze({circle:{y:30,gap:11,shapes:[O("circle","body",{cx:32,cy:32,r:28})]},squircle:{y:29,gap:11,shapes:[O("rect","body",{x:5,y:5,width:54,height:54,rx:20})]},hexagon:{y:30,gap:10,shapes:[O("polygon","body",{points:"32,6 55,19 55,45 32,58 9,45 9,19","stroke-width":8,"stroke-linejoin":"round"})]},triangle:{y:40,gap:8,shapes:[O("polygon","body",{points:"32,9 57,53 7,53","stroke-width":9,"stroke-linejoin":"round"})]},drop:{y:32,gap:11,shapes:[O("path","body",{d:"M32 5H59V32A27 27 0 1 1 32 5Z"})]},pill:{y:30,gap:11,shapes:[O("rect","body",{x:4,y:15,width:56,height:34,rx:17,transform:"rotate(-20 32 32)"})]},clover:{y:30,gap:11,shapes:[O("circle","body",{cx:21,cy:21,r:15}),O("circle","body",{cx:43,cy:21,r:15}),O("circle","body",{cx:21,cy:43,r:15}),O("circle","body",{cx:43,cy:43,r:15}),O("rect","body",{x:16,y:16,width:32,height:32})]},dome:{y:36,gap:11,shapes:[O("path","body",{d:"M5 52V40A27 27 0 0 1 59 40V52Q59 56 55 56H9Q5 56 5 52Z"})]},wedge:{y:23,gap:9.5,shapes:[O("polygon","body",{points:"7,11 57,11 32,55","stroke-width":9,"stroke-linejoin":"round"})]},pentagon:{y:31,gap:10,shapes:[O("polygon","body",{points:"32,7 57,25 48,55 16,55 7,25","stroke-width":8,"stroke-linejoin":"round"})]},trapezoid:{y:31,gap:10,shapes:[O("polygon","body",{points:"17,11 47,11 58,53 6,53","stroke-width":8,"stroke-linejoin":"round"})]},cross:{y:31,gap:11,shapes:[O("polygon","body",{points:"22,7 42,7 42,21 57,21 57,43 42,43 42,57 22,57 22,43 7,43 7,21 22,21","stroke-width":6,"stroke-linejoin":"round"})]},diamond:{y:30,gap:9.5,shapes:[O("polygon","body",{points:"32,5 59,32 32,59 5,32","stroke-width":8,"stroke-linejoin":"round"})]},octagon:{y:30,gap:11,shapes:[O("polygon","body",{points:"22,5 42,5 59,22 59,42 42,59 22,59 5,42 5,22","stroke-width":6,"stroke-linejoin":"round"})]}});function Bl(i,e={}){let t=Gp(i),s=Nn.includes(e.tone)?e.tone:Fl(t),n=Pl.includes(e.body)?e.body:Rn(t,"body",Pl),r=jl.includes(e.eyes)?e.eyes:Rn(t,"eyes",jl),o=[0,1,2].includes(e.spacing)?e.spacing:Rn(t,"spacing",[0,1,2]);return{tone:s,body:n,eyes:r,spacing:o}}function ql(i,e=null,t=32){let s=e??"idle",n=t<=24,r=Vl[i.body]??Vl.circle,o=n?15:13,a=r.gap*(n?.95:Hp[i.spacing]??1);return[O("g","shape",{},r.shapes.map($l)),Up({xs:[32-a,32+a],y:r.y,w:o,h:i.eyes==="oval"?o*1.25:o,shape:i.eyes,pupils:t>=20,heavy:n},s)]}function Up(i,e){let{xs:t,y:s}=i,{w:n,h:r}=i,o=[];if(e==="blocked"){let h=i.heavy?4:3.2;for(let p of t)o.push(O("rect","sclera",{x:B(p-n*.6),y:B(s-h/2),width:B(n*1.2),height:h,rx:1.4}));return O("g","eyes",{},[O("g","look",{},o)])}if(e==="offline"){for(let h of t)o.push(O("path","line",{d:`M${B(h-n*.55)} ${B(s)}Q${B(h)} ${B(s+r*.45)} ${B(h+n*.55)} ${B(s)}`,"stroke-width":i.heavy?3:2.2}));return O("g","eyes",{},[O("g","look",{},o)])}let a=0,l=0,c=0,d=0;return e==="working"&&(r*=.62),e==="needs-you"&&(n*=1.2,r*=1.2),e==="thinking"&&(i.pupils?(c=n*.2,d=-r*.22):(a=2.5,l=-3)),e==="working"&&(i.pupils?d=r*.2:l=2),t.forEach((h,p)=>{let f=e==="thinking"&&!i.pupils&&p===1?.85:1,m=n*f,g=r*f,_=h+a,y=s+l,b=[Wp(i.shape,_,y,m,g)];if(i.pupils){let w=Math.min(m,g)*(e==="needs-you"?.36:.3),[v,A]=Yp(i.shape,m,g,w,c,d);b.push(O("g","gaze",{},[O("circle","pupil",{cx:B(_+v),cy:B(y+A),r:B(w)})]))}o.push(O("g","eye",{},b))}),O("g","eyes",{},[O("g","look",{},o)])}var Kp=.3;function Yp(i,e,t,s,n,r){let o=i==="oval"?e*.42:e/2,a=t/2,l=s+Kp,c=p=>{let f=n*p,m=r*p;if(i==="square")return Math.abs(f)+l<=o&&Math.abs(m)+l<=a;for(let g=0;g<32;g+=1){let _=g*Math.PI/16,y=f+l*Math.cos(_),b=m+l*Math.sin(_);if((y/o)**2+(b/a)**2>1)return!1}return!0};if(c(1))return[n,r];let d=0,h=1;for(let p=0;p<12;p+=1){let f=(d+h)/2;c(f)?d=f:h=f}return[n*d,r*d]}function Wp(i,e,t,s,n){return i==="square"?O("rect","sclera",{x:B(e-s/2),y:B(t-n/2),width:B(s),height:B(n),rx:B(Math.min(s,n)*.22)}):i==="oval"?O("ellipse","sclera",{cx:B(e),cy:B(t),rx:B(s*.42),ry:B(n/2)}):O("ellipse","sclera",{cx:B(e),cy:B(t),rx:B(s/2),ry:B(n/2)})}function O(i,e,t,s){return s?{tag:i,part:e,attrs:t,children:s}:{tag:i,part:e,attrs:t}}function $l(i){return O(i.tag,i.part,{...i.attrs},i.children?.map($l))}function B(i){return Math.round(i*100)/100}function Gp(i){return String(i??"").trim().normalize("NFC").toLowerCase()}function Rn(i,e,t){let s=`${i}\0${e}`,n=2166136261;for(let r=0;r<s.length;r+=1)n^=s.charCodeAt(r),n=Math.imul(n,16777619);return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),n^=n>>>16,t[(n>>>0)%t.length]}var Ul="http://www.w3.org/2000/svg",Hl=Object.freeze(["seed","name","tone","body","eyes","spacing","material","size","label","activity","activityLabel","indicator","animate","phase"]),Zp=5.2,Qp=28,Jp=Object.freeze([[0,"stop-lit"],[.3,"stop-base"],[.5,"stop-base"],[1,"stop-shade"]]),We=class i extends k{static cssName="agent-avatar";static defaults={seed:null,name:"",tone:null,body:null,eyes:null,spacing:null,material:"flat",size:"md",label:null,activity:null,activityLabel:null,indicator:!0,animate:!1,phase:null,msg:Cl};render(){this._createdRoot=this.el===null;let e=this.el??u("span");this.el=e,this._original=this._createdRoot?null:$(e),this._state={};for(let n of Hl)this._state[n]=this.options[n]??i.defaults[n];this._traits=null,this._paintId=`zx-agent-avatar-soft-${Xp()}`,this._destroyed=!1,this._presence=null;let t=document.createElementNS(Ul,"svg");t.setAttribute("class","zx-agent-avatar__face"),t.setAttribute("viewBox","0 0 64 64"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false"),this.refs.face=t;let s=u("span",{ref:"activity",class:"zx-agent-avatar__activity",ariaHidden:"true",hidden:!0});return e.replaceChildren(t,s),this._sync(),e}set(e={}){if(!e||typeof e!="object")return this;for(let t of Hl)Object.hasOwn(e,t)&&(this._state[t]=e[t]);return this._sync(),this}setActivity(e,t=null){return this._state.activity=e,this._state.activityLabel=t,this._sync(),this}getActivity(){return ss(this._state.activity)}getActivityWord(){return this._activityWord()}getTraits(){return{...this._traits??this._resolveTraits()}}destroy(){this._destroyed||(this._destroyed=!0,this._presence?.untrack(),this._presence=null,super.destroy(),this._createdRoot||H(this.el,this._original))}_resolveTraits(){let{seed:e,name:t,tone:s,body:n,eyes:r,spacing:o}=this._state,a=e==null||String(e).trim()===""?t:e;return Bl(a,{tone:s,body:n,eyes:r,spacing:o})}_px(){let e=this._state.size;return typeof e=="number"&&Number.isFinite(e)?Math.max(1,e):Ln[e]??Ln.md}_sync(){let e=this.el,{size:t}=this._state,s=this._resolveTraits();this._traits=s;let n=ss(this._state.activity);e.dataset.tone=s.tone,e.dataset.size=typeof t=="number"?"custom":["sm","md","lg"].includes(t)?t:"md",typeof t=="number"&&Number.isFinite(t)?e.style.setProperty("--zx-agent-avatar-size",`${Math.max(1,t)}px`):e.style.removeProperty("--zx-agent-avatar-size"),n?e.dataset.activity=n:delete e.dataset.activity;let r=this.refs.face,o=this._state.material==="soft"&&this._px()>=Qp&&n!=="offline";r.replaceChildren(...ql(s,n,this._px()).map(Fn)),o?(r.prepend(Fn({tag:"defs",part:null,attrs:{},children:[{tag:"linearGradient",part:null,attrs:{id:this._paintId,gradientUnits:"userSpaceOnUse",x1:0,y1:4,x2:0,y2:60},children:Jp.map(([d,h])=>({tag:"stop",part:h,attrs:{offset:d}}))}]})),e.dataset.material="soft",e.style.setProperty("--zx-agent-avatar-paint",`url("#${this._paintId}") var(--zx-agent-avatar-solid)`)):(e.dataset.material="flat",e.style.removeProperty("--zx-agent-avatar-paint"));let a=this.refs.activity,l=this._activityWord();a.hidden=!n||!this._state.indicator,l?a.setAttribute("title",l):a.removeAttribute("title");let c=this._state.label;c?(e.setAttribute("role","img"),e.setAttribute("aria-label",[String(c),l].filter(Boolean).join(", ")),e.removeAttribute("aria-hidden")):(e.removeAttribute("role"),e.removeAttribute("aria-label"),e.setAttribute("aria-hidden","true")),this._syncMotion(n)}_activityWord(){let e=ss(this._state.activity);return e?this._state.activityLabel?String(this._state.activityLabel):this.msg(Dn[e].key):null}_syncMotion(e){let t=this.el,s=!!this._state.animate&&e!==null,n=pt(this._state.phase)??Ml(this._seedKey());s?(t.dataset.animate="",t.style.setProperty("--zx-agent-avatar-delay",`${-(n*Zp).toFixed(2)}s`)):(delete t.dataset.animate,t.style.removeProperty("--zx-agent-avatar-delay")),s?this._presence?this._presence.set(e,{phase:n}):this._presence=Dl(t,e,{phase:n}):(this._presence?.untrack(),this._presence=null)}_seedKey(){let{seed:e,name:t}=this._state;return e==null||String(e).trim()===""?String(t??""):String(e)}};function Fn(i){let e=document.createElementNS(Ul,i.tag);i.part&&e.setAttribute("class",`zx-agent-avatar__${i.part}`);for(let[t,s]of Object.entries(i.attrs))e.setAttribute(t,String(s));return i.children&&e.append(...i.children.map(Fn)),e}function Xp(){let i=globalThis.crypto;return typeof i?.randomUUID=="function"?i.randomUUID():typeof i?.getRandomValues=="function"?Array.from(i.getRandomValues(new Uint32Array(4)),e=>e.toString(36)).join("-"):Array.from({length:4},()=>Math.random().toString(36).slice(2,10)).join("-")}var Kl=Object.freeze([Object.freeze(["getValue","setValue"]),Object.freeze(["get","set"]),Object.freeze(["getValues","setValues"]),Object.freeze(["isChecked","setChecked"])]),em=Object.freeze(["value","values","checked"]),Yl="input, select, textarea, button",tm="input, textarea";function ls(i){if(U(i))return i;let e=i;if(typeof e.toElement=="function")return e.toElement();if(U(e.el))return e.el;throw new TypeError("External field source must be an Element or a Component")}function Wl(i){return Zl(i,ls(i)).get()}function Pn(i){let e=ls(i),t=U(i)?null:i;if(t&&ke(t,"isDisabled",0))return!!t.isDisabled();if(t&&typeof t.disabled=="boolean")return t.disabled;if(mt(e,"disabled"))return!!e.disabled||e.hasAttribute("disabled");if(e.getAttribute("aria-disabled")==="true")return!0;let s=e.getAttribute("data-disabled");if(s!==null&&s!=="false")return!0;let n=[...e.querySelectorAll(Yl)];return n.length>0&&n.every(r=>r.disabled)}function jn(i){let e=ls(i),t=U(i)?null:i;for(let n of["readonly","readOnly"])if(t&&typeof t[n]=="boolean")return t[n];if(mt(e,"readOnly"))return!!e.readOnly||e.hasAttribute("readonly");if(e.getAttribute("aria-readonly")==="true")return!0;let s=e.getAttribute("data-readonly");return s!==null&&s!=="false"}function Gl(i,e=null){let t=ls(i),s=U(i)?null:i,n=t.parentNode,r=t.nextSibling,o=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(A=>[A,t.getAttribute(A)])),a=s===null,l=a&&mt(t,"value")?t.value:void 0,c=a&&Jl(t)?t.checked:void 0,d=Pn(i),h=jn(i),p=new Map,f=Zl(i,t),m=im(s,t,p),g=sm(s,t,p),_=d,y=h,b=!1,w=f.get();e&&s&&typeof s.addEventListener=="function"&&(e.listen(s,"change",()=>{b||(w=f.get(),e.emit("change",{value:w}))}),e.listen(t,"change",A=>{let S=f.get();nm(S,w)?A.stopImmediatePropagation():w=S}));let v={el:t,get:()=>f.get(),set:(A,S)=>{b=!0;try{f.set(A,S)}finally{b=!1}w=f.get()},focus:()=>{s&&ke(s,"focus",0)?s.focus():typeof t.focus=="function"&&t.focus()},setDisabled:A=>{_=!!A,m(_)},destroy:()=>{y!==h&&g&&g(h),_!==d&&m(d);for(let[A,S]of p)S.disabled!==void 0&&(A.disabled=S.disabled),S.readOnly!==void 0&&(A.readOnly=S.readOnly);p.clear();for(let[A,S]of o)S===null?t.removeAttribute(A):t.setAttribute(A,S);l!==void 0&&(t.value=l),c!==void 0&&(t.checked=c),n?n.insertBefore(t,r?.parentNode===n?r:null):t.remove()}};return g&&(v.setReadonly=A=>{y=!!A,g(y)}),v}function Zl(i,e){let t=U(i)?null:i;if(t){let s=Kl.find(([o])=>ke(t,o,0)),n=s?ke(t,s[1],2)?s[1]:Kl.map(([,o])=>o).find(o=>ke(t,o,1)):void 0;if(s)return{get:()=>t[s[0]](),set:(o,a={})=>{n&&t[n](o,{...a,silent:!!a.silent})}};let r=em.find(o=>o in t);if(r)return{get:()=>t[r],set:o=>{t[r]=o}}}return Jl(e)?{get:()=>!!e.checked,set:s=>{e.checked=!!s}}:mt(e,"value")?{get:()=>e.value,set:s=>{e.value=s??""}}:{get:()=>null,set:()=>{}}}function im(i,e,t){return i&&ke(i,"setDisabled",1)?s=>i.setDisabled(s):i&&ke(i,"enable",0)&&ke(i,"disable",0)?s=>s?i.disable():i.enable():i&&typeof i.disabled=="boolean"?s=>{i.disabled=s}:mt(e,"disabled")?s=>{e.disabled=s}:s=>{e.setAttribute("aria-disabled",String(s));for(let n of e.querySelectorAll(Yl))Ql(t,n,"disabled"),n.disabled=s||!!t.get(n)?.disabled}}function sm(i,e,t){if(i){for(let n of["setReadonly","setReadOnly"])if(ke(i,n,1))return r=>i[n](r);for(let n of["readonly","readOnly"])if(typeof i[n]=="boolean")return r=>{i[n]=r};return null}if(mt(e,"readOnly"))return n=>{e.readOnly=n};let s=[...e.querySelectorAll(tm)];return s.length?n=>{for(let r of s)Ql(t,r,"readOnly"),r.readOnly=n||!!t.get(r)?.readOnly}:null}function Ql(i,e,t){let s=i.get(e)??{};s[t]===void 0&&(s[t]=!!e[t]),i.set(e,s)}function ke(i,e,t){let s=i[e];return typeof s=="function"&&s.length<=t}function mt(i,e){return["INPUT","SELECT","TEXTAREA","BUTTON","FIELDSET","OUTPUT"].includes(i.tagName)&&e in i}function Jl(i){let e=String(i.type??"").toLowerCase();return i.tagName==="INPUT"&&(e==="checkbox"||e==="radio")}function nm(i,e){if(Object.is(i,e))return!0;if(i instanceof Date&&e instanceof Date)return i.getTime()===e.getTime();if(i&&e&&typeof i=="object"&&typeof e=="object")try{return JSON.stringify(i)===JSON.stringify(e)}catch{return!1}return!1}var Yt=class extends k{static cssName="fieldset";static defaults={title:"",columns:1,fields:{},idPrefix:null};render(){let e=this.el??u("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):z("zx-fieldset"),this._columnAttribute=e.getAttribute("data-columns");let t=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(e.dataset.columns=String(t),this.options.title){let n=u("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),e.append(n)}this._grid=u("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),e.append(this._grid);let s=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[n,r]of Object.entries(s))this.addField(n,r);return e}addField(e,t){let s=String(e);if(this._fields.has(s))throw new Error(`Field "${s}" already exists`);let n,r=!1;if(t instanceof E)n=t;else if(U(t)||t instanceof k){let o=t;n=new E(null,{id:this._controlId(s),name:s,type:"custom",label:s,value:Wl(o),disabled:Pn(o),readonly:jn(o),adapter:a=>Gl(o,a)}),r=!0}else{let o=t&&typeof t=="object"?t:{},a=o.id!=null&&String(o.id)!==""&&String(o.id)!==s;n=new E(null,{...o,id:a?String(o.id):this._controlId(s),name:o.name??s}),r=!0}return r?this._ownedFields.add(n):this._origins.set(n,{parent:n.el.parentNode,next:n.el.nextSibling}),this._fields.set(s,n),this._fieldIdAttributes.set(n,n.el.getAttribute("data-field-id")),n.el.dataset.fieldId=s,this._grid.append(n.el),n}getField(e){return this._fields.get(String(e))??null}hasField(e){return this._fields.has(String(e))}getFields(){return Object.fromEntries(this._fields)}getValues(){let e={};for(let[t,s]of this._fields)e[t]=s.getValue();return e}setValues(e,{silent:t=!1}={}){if(!e||typeof e!="object")return this;for(let[s,n]of Object.entries(e))this._fields.get(s)?.setValue(n,{silent:t});return this}getValue(e){return this._fields.get(String(e))?.getValue()??null}setValue(e,t){return this._fields.get(String(e))?.setValue(t),this}reset(){for(let e of this._fields.values())e.reset();return this}clear(){for(let e of[...this._fields.values()].reverse())this._releaseField(e);return this._fields.clear(),this}focus(e){return this._fields.get(String(e))?.focus(),this}setHighlights(e={},t="danger"){let s=0;for(let[n,r]of this._fields){let o=e?.[n];o?(r.setHighlight(String(o),t),s+=1):r.clearHighlight()}return s}clearHighlights(){for(let e of this._fields.values())e.clearHighlight();return this}_controlId(e){return`${this._idPrefix}-${e.trim().replace(/\s+/g,"-")}`}_releaseField(e){let t=this._fieldIdAttributes.get(e);if(t==null?e.el.removeAttribute("data-field-id"):e.el.setAttribute("data-field-id",t),this._fieldIdAttributes.delete(e),this._ownedFields.has(e)){e.destroy(),this._ownedFields.delete(e);return}let s=this._origins.get(e);s?.parent?s.parent.insertBefore(e.el,s.next?.parentNode===s.parent?s.next:null):e.el.remove(),this._origins.delete(e)}destroy(){this.clear();for(let e of this._ownedNodes??[])e.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};var rm=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),om=new Set(["hover","focus","both","manual"]),gt=class extends k{static cssName="tooltip";static defaults={content:"",placement:"top",offset:6,delay:400,hideDelay:80,maxWidth:260,trigger:"both",disabled:!1};#e;#t;#i=null;#s=0;#n=0;#r=!1;#o=!1;#c=!1;#u=!1;#a=!1;#h=null;#l=!1;#f=!1;constructor(e,t={}){let s=te(e);if(!s)throw new TypeError("Tooltip anchor could not be resolved");super(null,t),this.#e=s,ut(s,{dialog:!1})?.append(this.el),this.#t=this.options.content,this.#l=!!this.options.disabled,this.el.style.setProperty("--zx-tooltip-max-inline-size",lm(this.options.maxWidth));let n=om.has(this.options.trigger)?this.options.trigger:"both";if(n!=="manual"){this.#a=!0,(n==="hover"||n==="both")&&(this.listen(this.#e,"pointerenter",r=>{r.pointerType!=="touch"&&(this.#o=!0,this.#m(Number(this.options.delay)))}),this.listen(this.#e,"pointerleave",r=>{r.pointerType!=="touch"&&(this.#o=!1,this.#p(Number(this.options.hideDelay)))})),this.listen(this.el,"pointerenter",r=>{r.pointerType!=="touch"&&(this.#c=!0,this.#d())}),this.listen(this.el,"pointerleave",()=>{this.#c=!1,this.#p(Number(this.options.hideDelay))}),(n==="focus"||n==="both")&&(this.listen(this.#e,"focusin",()=>{this.#r||!cm(this.#e)||(this.#u=!0,this.#m(0))}),this.listen(this.#e,"focusout",()=>{this.#u=!1,this.#p(Number(this.options.hideDelay))})),this.listen(this.#e,"pointerdown",()=>{this.#r=!0,this.#d(),this.hide()});for(let r of["pointerup","pointercancel","pointerleave"])this.listen(this.#e,r,()=>{this.#r=!1})}}render(){let e=u("div",{id:z("zx-tooltip"),role:"tooltip",popover:"manual"});return e.dataset.state="closed",e}show(){if(this.#f||this.#l||this.isOpen())return this;this.#d();let e=Pt(this.#e);this.el.parentElement!==e&&e.append(this.el);let t=Xl(this.#t);if(t===null)return this;this.el.replaceChildren(t);let s=rm.has(this.options.placement)?this.options.placement:"top";return this.#i=ae(this.#e,this.el,{placement:s,offset:Number(this.options.offset),flip:!0}),/^(left|right)/.test(s)&&this.el.style.getPropertyValue("position-try-fallbacks")&&this.el.style.setProperty("position-try-fallbacks","flip-inline, top span-all, bottom span-all"),this.el.dataset.state="open",this.#e.setAttribute("aria-describedby",am(this.#e.getAttribute("aria-describedby"),this.el.id)),this.#h=ht({kind:"tooltip",root:this.el,owner:this,anchor:this.#e,inside:[this.#e],onEscape:this.#a?()=>{this.hide()}:void 0,onOutsidePointer:this.#a?()=>this.hide():void 0,onFocusOutside:this.#a?()=>{this.#u=!1,this.#p(Number(this.options.hideDelay))}:void 0,onParentClose:()=>this.hide()}),this.emit("open"),this}hide(){if(this.#d(),!this.isOpen())return this;this.#i?.destroy(),this.#i=null,this.#c=!1,this.el.dataset.state="closed",this.el.replaceChildren(),this.#g();let e=this.#h;return this.#h=null,e?.release(),this.emit("close"),this}toggle(){return this.isOpen()?this.hide():this.show()}isOpen(){return this.#i!==null}setContent(e){if(this.#t=e,!this.isOpen())return this;let t=Xl(e);return t===null?this.hide():(this.el.replaceChildren(t),this.#i?.update(),this)}enable(){return this.#l=!1,this}disable(){return this.#l=!0,this.hide()}isDisabled(){return this.#l}getAnchor(){return this.#e}destroy(){this.#f||(this.#f=!0,this.hide(),this.#g(),super.destroy())}#m(e){if(this.#d(),this.#f||this.#l||this.isOpen())return;let t=Number.isFinite(e)?Math.max(0,e):0;if(t===0){this.show();return}this.#s=setTimeout(()=>{this.#s=0,this.show()},t)}#p(e){if(this.#d(),this.#o||this.#c||this.#u||!this.isOpen())return;let t=Number.isFinite(e)?Math.max(0,e):0;if(t===0){this.hide();return}this.#n=setTimeout(()=>{this.#n=0,this.hide()},t)}#d(){this.#s!==0&&clearTimeout(this.#s),this.#n!==0&&clearTimeout(this.#n),this.#s=0,this.#n=0}#g(){let e=this.#e.getAttribute("aria-describedby");if(e===null)return;let t=e.split(/\s+/).filter(Boolean);if(!t.includes(this.el.id))return;let s=t.filter(n=>n!==this.el.id);s.length?this.#e.setAttribute("aria-describedby",s.join(" ")):this.#e.removeAttribute("aria-describedby")}};function Xl(i){let e=typeof i=="function"?i():i;if(e==null)return null;if(typeof e=="object"&&typeof e.nodeType=="number")return e;if(typeof e=="object"&&typeof e.toElement=="function")return e.toElement();let t=String(e);return t===""?null:document.createTextNode(t)}function am(i,e){let t=String(i??"").split(/\s+/).filter(Boolean);return t.includes(e)||t.push(e),t.join(" ")}function lm(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function cm(i){try{return i.matches(":focus-visible")}catch{return!0}}function ec(i){return ee(i,Intl.DateTimeFormat)}var ds=class extends k{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:null,label:null,closeLabel:null,resultsLabel:null,emptyText:null,loadingText:null,shortcut:"mod+k",hints:null,scope:null};constructor(e=null,t={}){super(e,t)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null,this._agentFaces=new Map,this._overlay=null;let e=this.el??u("dialog");this.el=e,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes,m=>[m.name,m.value]),children:Array.from(e.childNodes)},this._items=Wt(this.options.items),this._sources=rc(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._settled=!0,this._pages=[],this._restoreActiveId=null,this._announcePending=!1,this._announceToggle=!1,this._destroyed=!1,this._presentation=0,this._closingPresentations=[];let t=z("zx-launcher-results"),s=String(this.options.label??this._message("launcher.label","Launcher")),n=String(this.options.placeholder??this._message("launcher.placeholder","Search applications and records"));this._label=s,this._placeholder=n;let r=u("input",{ref:"input",class:"zx-launcher__input",type:"search",role:"combobox",autocomplete:"off",spellcheck:!1,ariaAutocomplete:"list",ariaControls:t,ariaExpanded:"false",ariaLabel:s,placeholder:n,value:this._query}),o=u("button",{ref:"scopeBack",class:"zx-icon-btn zx-launcher__scope-back",type:"button"},x("x",{size:T.dismiss})),a=u("span",{ref:"scope",class:"zx-launcher__scope",hidden:!0},u("span",{ref:"scopeLabel",class:"zx-launcher__scope-label"}),o),l=u("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel??this._message("launcher.close","Close launcher")},x("x",{size:T.dismiss})),c=u("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),d=u("div",{ref:"announce",class:"zx-launcher__announce",role:"status",ariaLive:"polite",ariaAtomic:"true"}),h=u("div",{ref:"results",class:"zx-launcher__results",id:t,role:"listbox",ariaLabel:this.options.resultsLabel??this._message("launcher.results","Launcher results")}),p=this.options.shortcut==="mod+k"?u("span",{class:"zx-launcher__shortcut",ariaHidden:"true"},Ae("Mod+K")):null,f=um(this.options.hints,{move:this._message("launcher.hintMove","Move"),open:this._message("launcher.hintOpen","Open"),back:this._message("launcher.hintBack","Back"),close:this._message("launcher.hintClose","Close")});return e.setAttribute("aria-label",s),e.replaceChildren(u("div",{class:"zx-launcher__surface"},u("div",{class:"zx-launcher__search",dataset:{shortcut:p?"true":"false"}},x("search"),a,r,p,l),c,h,f,d)),e.dataset.state="closed",this._createdRoot&&ut(this.options.scope,{dialog:!1})?.append(e),this.listen(r,"input",()=>{this._query=r.value,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(r,"keydown",m=>this._onKeydown(m)),this.listen(o,"click",()=>{this.back(),r.focus()}),this.listen(l,"click",()=>this.close()),this.listen(h,"click",m=>{let g=m.target?.closest?.("[data-launcher-index]");!g||!h.contains(g)||this._activate(Number(g.getAttribute("data-launcher-index")),m)}),this.listen(h,"pointermove",m=>{let g=m.target?.closest?.("[data-launcher-index]");if(!g||!h.contains(g))return;let _=Number(g.getAttribute("data-launcher-index"));!Number.isInteger(_)||this._results[_]?.disabled||_===this._active||(this._active=_,this._syncActive())}),this.listen(e,"cancel",m=>{m.preventDefault(),this.close()}),this.listen(e,"close",()=>{let m=this._closingPresentations.shift();m!==void 0&&m!==this._presentation||Vt(e)||(this._releaseOverlay(),e.dataset.state="closed",r.setAttribute("aria-expanded","false"),this._abortRequest(),this._pages.length&&!Vt(e)&&(this._unwind(),this._announcePending=!1,this._syncPage(),this._renderResults(),this._emitPage()),this.emit("close"))}),this.listen(document,"keydown",m=>this._onDocumentKeydown(m)),this._renderResults(),e}open(e={}){if(this._destroyed)return this;let t=e&&typeof e=="object"?e.page:void 0;if(this.isOpen()){let r=t==null?[]:this._pagePath(t);return r.length&&this._goTo(r),this}if(this.el.dataset.state==="open"&&!this._closingPresentations.includes(this._presentation)&&this._closingPresentations.push(this._presentation),this._createdRoot){let r=he(this.options.scope);this.el.parentElement!==r&&r.append(this.el)}let s=this._pages.map(r=>r.page),n=document.activeElement;return ol(this.el),this._presentation+=1,this._releaseOverlay(),this._overlay=ht({kind:"modal",root:this.el,owner:this,anchor:n}),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._goTo(t==null?[]:this._pagePath(t),{emit:!1}),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),tc(s,this._pages.map(r=>r.page))||this._emitPage(),this}back(){if(!this._pages.length)return this;let e=this._popPage();return this._syncPage(),this._announcePending=this.isOpen(),e?this._renderResults():this._refresh(!0),this._emitPage(),this}getPage(){return this._pages.at(-1)?.page??null}close(){return this.isOpen()&&(this._closingPresentations.push(this._presentation),zn(this.el)),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return Vt(this.el)}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(e){return this._query=String(e??""),this.refs.input.value=this._query,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(e){return this._items=Wt(e),this._renderResults(),this}setCurrent(e){let t=e==null?null:String(e);return this._items=this._items.map(s=>({...s,current:t!==null&&String(s.id)===t})),this._renderResults(),this}setSources(e){return this._sources=rc(e),this._pages.length?(this._pages[0].parent.sourceItems=null,this):(this._abortRequest(),this._sourceItems.clear(),this._refresh(),this)}_releaseOverlay(){let e=this._overlay;this._overlay=null,e?.release()}destroy(){if(this._destroyed)return;this._destroyed=!0;let e=this._original;this._abortRequest(),this.isOpen()&&zn(this.el),this._releaseOverlay();for(let{avatar:t}of this._agentFaces.values())t.destroy();if(this._agentFaces.clear(),super.destroy(),!this._createdRoot&&e){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,s]of e.attributes)this.el.setAttribute(t,s);this.el.replaceChildren(...e.children)}}_refresh(e=!1){this._abortRequest(),this._sourceItems.clear();let{sources:t}=this._level();if(this._settled=t.length===0,e&&t.length&&this._loadSources(),this._renderResults(),e||t.length===0)return;let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),s)}async _loadSources(){this._queryTimer=null;let e=this._query.trim(),t=this._pages?.at(-1)?.page??null,s=this._level().sources.filter(o=>cs(o.when,e)&&e.length>=Math.max(o._page?0:Number(this.options.minQuery)||0,Number(o.minQuery)||0));if(s.length===0){this._settled=!0;return}let n=new AbortController,r=++this._requestSequence;this._request=n,this._setBusy(!0),await Promise.all(s.map(async o=>{try{let a=await o.load(e,{signal:n.signal});if(n.signal.aborted||r!==this._requestSequence)return;this._sourceItems.set(o.id,Wt(a).map((l,c)=>({...l,_source:o._page?null:o.id,_sourceOrder:o.order==="source",group:l.group??o.label??"",itemOrder:l.itemOrder??(o.order==="source"?c:void 0)}))),this._renderResults()}catch(a){if(n.signal.aborted||r!==this._requestSequence)return;this.emit("error",{source:o,error:a,page:t})}})),!(n.signal.aborted||r!==this._requestSequence)&&(this._request=null,this._settled=!0,this._setBusy(!1))}_level(){return this._pages?.at(-1)??{items:this._items,sources:this._sources}}_openPage(e){this._pushPage(e),this._syncPage(),this._announcePending=this.isOpen(),this._refresh(!0),this._emitPage()}_goTo(e,{emit:t=!0}={}){let s=this._pages.map(n=>n.page);if(this._unwind(),e.length){this._abortRequest(),this._sourceItems.clear(),this._settled=!1;for(let n of e)this._pushPage(n)}this._syncPage(),this._announcePending=this.isOpen()&&e.length>0,this._refresh(e.length>0),t&&!tc(s,e)&&this._emitPage()}_unwind(){for(;this._pages.length;)this._popPage()}_pushPage(e){let t=this._active>=0?this._results[this._active]:null;this._pages.push({page:e,items:Array.isArray(e.items)?Wt(e.items):[],sources:typeof e.items=="function"?[pm(e)]:[],parent:{query:this._query,activeId:t?String(t.id):null,sourceItems:this._settled?new Map(this._sourceItems):null}}),this._setInputQuery("")}_popPage(){let e=this._pages.pop();if(!e)return!0;this._announcePending=!1,this._abortRequest();let{parent:t}=e;return this._setInputQuery(t.query),this._sourceItems=t.sourceItems?new Map(t.sourceItems):new Map,this._settled=t.sourceItems!==null,this._restoreActiveId=t.activeId,this._settled}_setInputQuery(e){this._query=e,this.refs.input.value=e,this._renderedQuery=null}_syncPage(){let e=this.getPage(),{input:t,scope:s,scopeLabel:n,scopeBack:r,backHint:o}=this.refs;if(s.hidden=e===null,o&&(o.hidden=e===null),this.el.toggleAttribute("data-page",e!==null),e===null){t.setAttribute("aria-label",this._label),t.setAttribute("placeholder",this._placeholder),n.textContent="";return}let a=this._pages.at(-2)?.page.label??this._label;n.textContent=e.label,r.setAttribute("aria-label",this._message("launcher.back","Back to %1",a)),t.setAttribute("aria-label",this._message("launcher.pageLabel","Search %1",e.label)),t.setAttribute("placeholder",e.placeholder!=null?String(e.placeholder):this._message("launcher.pagePlaceholder","Search"))}_emitPage(){let e=this._pages.map(t=>t.page);this.emit("page",{page:e.at(-1)??null,path:e})}_pagePath(e){if(e&&typeof e=="object"){let t=e;return!_t(t)||t.label==null?[]:[oc({...t,id:t.id??t.label})]}return dm(this._items,e)}_pageStatus(){let e=this.getPage()?.label??this._label,t=this._results.length;return t===0?this._message("launcher.pageEmpty","%1, no results",e):t===1?this._message("launcher.pageResult","%1, 1 result",e):this._message("launcher.pageResults","%1, %2 results",e,t)}_setBusy(e){this._busy=e,this.el.setAttribute("aria-busy",String(e)),this._renderStatus()}_abortRequest(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._request?.abort(),this._request=null,this._requestSequence+=1,this._busy&&this._setBusy(!1)}_renderResults(){let e=this._query,t=this._restoreActiveId??null;this._restoreActiveId=null;let s=t??(this._renderedQuery===e&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null),n=this._query.trim(),r=this._level(),o=r.items.filter(g=>cs(g.when,n)),a=sc(o,n,this.options.maxResults),l=r.sources.flatMap(g=>{let _=this._sourceItems.get(String(g.id))??[];return g.order==="source"?_.filter(y=>cs(y.when,n)):sc(_.filter(y=>cs(y.when,n)),n,this.options.maxResults)}),c=new Set,d=[...a.map(g=>({...g,_source:null})),...l].filter(g=>{let _=String(g.id);return c.has(_)?!1:(c.add(_),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),h=new Map;for(let g of d){let _=String(g.group??"");h.has(_)||h.set(_,[]),h.get(_).push(g)}this._results=[...h.values()].flat(),this._renderedQuery=e;let p=s===null?-1:this._results.findIndex(g=>!g.disabled&&String(g.id)===s);this._active=p>=0?p:this._results.findIndex(g=>!g.disabled);let f=[],m=0;for(let[g,_]of h){let y=_.map(b=>this._option(b,m++));g?f.push(u("div",{class:"zx-launcher__group",role:"group",ariaLabel:g,dataset:{layout:_.every(b=>b.kind==="application")?"grid":"list"}},u("div",{class:"zx-launcher__group-label",ariaHidden:"true"},g),y)):f.push(...y)}this.refs.results.replaceChildren(...f),this._syncActive(),this._renderStatus()}_option(e,t){let s=_t(e),n=s?null:Ve(e.href),r=n?"a":"button",o=[],a=this._agentFace(e),l=a?a.toElement():mm(e);l&&o.push(u("span",{class:"zx-launcher__icon",ariaHidden:"true"},l));let c=a?.getActivityWord()??null;o.push(u("span",{class:"zx-launcher__copy"},u("span",{class:"zx-launcher__label"},e.label,c?u("span",{class:"zx-launcher__word"},`, ${c}`):null),e.description?u("span",{class:"zx-launcher__description"},e.description):null)),e.badge!=null&&o.push(u("span",{class:"zx-launcher__badge"},String(e.badge))),e.hint!=null&&e.hint!==""&&o.push(u("span",{class:"zx-launcher__hint"},String(e.hint)));let d=fm(e),h=hm(e.shortcut);return h.length&&o.push(u("span",{class:"zx-launcher__keys",ariaHidden:d?"true":null},Ae(h,{size:"sm"}))),s&&o.push(u("span",{class:"zx-launcher__chevron",ariaHidden:"true"},x("chevron-right",{size:T.chevron}))),u(r,{class:"zx-launcher__option",type:r==="button"?"button":null,href:n,target:e.target??null,rel:r==="a"?"noopener":null,role:"option",id:z("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:e.disabled?"true":null,ariaCurrent:e.current?"page":null,ariaKeyShortcuts:d,dataset:{launcherIndex:t,pinned:e.pinned!==void 0&&e.pinned!==!1?"true":null,kind:ic(e.kind),page:s?"true":null}},o)}_agentFace(e){if(!e.agent)return null;let t=String(e.id),s=ic(e.kind)==="application"?"md":"sm",n=rs(e.agent,{size:s,label:null,animate:!1},{fallback:{name:String(e.label)},carry:ns});if(!n)return null;let r=JSON.stringify(n),o=this._agentFaces.get(t);return(!o||o.signature!==r)&&(o?.avatar.destroy(),o={signature:r,avatar:new We(null,n)},this._agentFaces.set(t,o)),o.avatar}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText??this._message("launcher.loading","Searching\u2026")):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText??this._message("launcher.empty","No results")):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent,this._announcePending&&!this._busy&&this._renderedQuery===this._query&&(this._announcePending=!1,this._announceToggle=!this._announceToggle,this.refs.announce.textContent=this._pageStatus()+(this._announceToggle?"\xA0":""))}_syncActive(){let e=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let s of e){let n=Number(s.getAttribute("data-launcher-index"))===this._active;s.setAttribute("aria-selected",String(n))}let t=e.find(s=>Number(s.getAttribute("data-launcher-index"))===this._active);t?this.refs.input.setAttribute("aria-activedescendant",t.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(e){if(e.key==="Escape"){e.preventDefault(),this.close();return}let t=!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey;if(e.key==="Backspace"&&t&&!e.repeat&&this._pages.length&&this._query===""){e.preventDefault(),this.back();return}if(e.key==="Enter"){if(this._active<0)return;e.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let s=this._results.map((r,o)=>r.disabled?-1:o).filter(r=>r>=0);if(/^Arrow(?:Left|Right|Up|Down)$/.test(e.key)){let r=s.length?this._spatialIndex(e.key,s):null;if(r!==null){e.preventDefault(),this._active=r,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(e.key==="ArrowLeft"||e.key==="ArrowRight"){t&&!e.repeat&&this._pageKey(e.key)&&e.preventDefault();return}}if(s.length===0)return;let n=s.indexOf(this._active);if(e.key==="Home"||e.key==="PageUp")n=0;else if(e.key==="End"||e.key==="PageDown")n=s.length-1;else if(e.key==="ArrowDown")n=(n+1+s.length)%s.length;else if(e.key==="ArrowUp")n=(n-1+s.length)%s.length;else return;e.preventDefault(),this._active=s[n],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_pageKey(e){if(e==="ArrowLeft")return!this._pages.length||this._query!==""?!1:(this.back(),!0);let t=this._active>=0?this._results[this._active]:null;if(!t||t.disabled||!_t(t)||t.kind==="application")return!1;let s=this.refs.input,n=s.value.length;return s.selectionStart!==n||s.selectionEnd!==n?!1:(this._openPage(t),!0)}_spatialIndex(e,t){let s=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(s instanceof HTMLElement)||(e==="ArrowLeft"||e==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>t.includes(Number(o.getAttribute("data-launcher-index")))&&(e!=="ArrowLeft"&&e!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=gm(n,s,e);return r?Number(r.getAttribute("data-launcher-index")):null}_activate(e,t){let s=this._results[e];if(!s||s.disabled){t.preventDefault();return}if(_t(s)){t.preventDefault(),this._openPage(s),this.refs.input.focus();return}if(this.emit("select",{item:s,value:s.value??s.id,source:s._source??null,query:this._query.trim(),page:this.getPage()}).defaultPrevented){t.preventDefault();return}this.close(),s.href||(t.preventDefault(),s.invoke?.())}_onDocumentKeydown(e){if(this.options.shortcut!=="mod+k"||e.isComposing||e.key.toLowerCase()!=="k"||Number(e.metaKey)+Number(e.ctrlKey)!==1||e.altKey||e.shiftKey)return;let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLElement&&t.isContentEditable)return;let s=rl(document)[0];s&&s!==this.el||(e.preventDefault(),this.open())}_message(e,t,...s){let n=this.msg(e,...s);return n===e?q(t,s):n}};function um(i,e){if(i===!1)return null;let t=i&&typeof i=="object"?i:{};return u("footer",{class:"zx-launcher__hints",ariaHidden:"true"},u("span",{},Ae(["\u2191\u2193\u2190\u2192"]),t.move??e.move),u("span",{},Ae("Enter"),t.open??e.open),u("span",{ref:"backHint",hidden:!0},Ae("Backspace"),t.back??e.back),u("span",{},Ae("Escape"),t.close??e.close))}function _t(i){let e=i?.items;return!!i&&typeof i=="object"&&(Array.isArray(e)||typeof e=="function")}function dm(i,e){if(e==null)return[];let t=String(e),s=new Set,n=(r,o)=>{if(!Array.isArray(r)||s.has(r))return null;s.add(r);for(let a of Wt(r)){if(!_t(a))continue;let l=[...o,a];if(String(a.id)===t)return l;let c=n(a.items,l);if(c)return c}return null};return n(i,[])??[]}function hm(i){let e=i&&typeof i=="object"&&!Array.isArray(i)?i.label:i;return(Array.isArray(e)?e:e==null?[]:[e]).filter(s=>s!=null&&String(s).trim()!=="").map(s=>String(s).trim())}function fm(i){let e=i.shortcut,t=i.keys??(e&&typeof e=="object"&&!Array.isArray(e)?e.keys:null);return typeof t=="string"&&t.trim()?t.trim():null}function pm(i){return{id:`page:${String(i.id)}`,load:i.items,order:i.order==="source"?"source":"rank",_page:!0}}function tc(i,e){return i.length===e.length&&i.every((t,s)=>t===e[s]||String(t.id)===String(e[s].id))}function mm(i){let e=i.icon;if(typeof e=="function"&&(e=e(i)),typeof e=="string")return x(e);if(e instanceof Node)return e.cloneNode(!0);if(e&&typeof e=="object"&&typeof e.toElement=="function"){let t=e.toElement();return t instanceof Node?t.cloneNode(!0):null}return null}function ic(i){return i==="application"||i==="record"?i:"action"}function cs(i,e){return i==="empty"?e==="":i==="query"?e!=="":!0}function gm(i,e,t){let s=e.getBoundingClientRect();if(s.width===0&&s.height===0)return null;let n=s.left+s.width/2,r=s.top+s.height/2,o=null,a=1/0;for(let l of i){if(l===e)continue;let c=l.getBoundingClientRect(),d=c.left+c.width/2-n,h=c.top+c.height/2-r,p=!1,f=1/0;t==="ArrowLeft"?(p=d<-2&&Math.abs(h)<Math.max(s.height,c.height)/2,f=Math.abs(d)+Math.abs(h)*4):t==="ArrowRight"?(p=d>2&&Math.abs(h)<Math.max(s.height,c.height)/2,f=Math.abs(d)+Math.abs(h)*4):t==="ArrowUp"?(p=h<-2,f=Math.abs(h)*10+Math.abs(d)):t==="ArrowDown"&&(p=h>2,f=Math.abs(h)*10+Math.abs(d)),p&&f<a&&(o=l,a=f)}return o}function sc(i,e,t=100){let s=bt(e).trim(),n=i.map((o,a)=>({item:o,order:a,score:_m(o,s)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let l=us(o.item.groupOrder),c=us(a.item.groupOrder);if(l!==c)return l-c;if(s===""){let d=nc(o.item.pinned,o.order),h=nc(a.item.pinned,a.order);if(d!==h)return d-h}return o.score-a.score||us(o.item.itemOrder)-us(a.item.itemOrder)||bm(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(t)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function _m(i,e){if(!e)return i.pinned?-1:0;let t=bt(i.label),s=bt(i.id),n=bt(Array.isArray(i.keywords)?i.keywords.join(" "):i.keywords??"");return t===e?0:t.startsWith(e)?10:t.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(e))?20:t.includes(e)||n.includes(e)?30:s.includes(e)?40:t.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(e)?50:1/0}function nc(i,e){return typeof i=="number"&&Number.isFinite(i)?i:i?e:Number.MAX_SAFE_INTEGER}function us(i){return typeof i=="number"&&Number.isFinite(i)?i:Number.MAX_SAFE_INTEGER}function bt(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function bm(i,e){let t=bt(i),s=bt(e);if(t<s)return-1;if(t>s)return 1;let n=String(i??"").normalize("NFC"),r=String(e??"").normalize("NFC");return n<r?-1:n>r?1:0}function Wt(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&e.label!=null).map(e=>oc(e)):[]}function oc(i){let e={...i,label:String(i.label)};if(i.href==null)return e;let t=Ve(i.href);return t!==null?e.href=t:(delete e.href,typeof e.invoke!="function"&&!_t(e)&&(e.disabled=!0)),e}function rc(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&typeof e.load=="function").map(e=>({...e,id:String(e.id)})):[]}var ym=["a[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe",'[contenteditable="true"]',"[tabindex]"].map(i=>`${i}:not([tabindex^="-"])`).join(","),yt=class extends k{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1,scope:null};#e;#t=null;#i=new Map;#s=null;#n=null;#r=!0;#o=!1;constructor(e,t={}){let s=te(e);if(!s)throw new TypeError("Dropdown anchor could not be resolved");super(null,t),this.#e=s,ut(this.options.scope??s,{dialog:!1})?.append(this.el),this.#l("aria-expanded"),this.#l("aria-controls"),this.#e.setAttribute("aria-expanded","false"),this.#e.setAttribute("aria-controls",this.el.id),this.setContent(this.options.content),this.options.openOn==="click"&&this.listen(this.#e,"click",()=>this.toggle()),this.listen(this.el,"click",()=>{this.options.closeOnSelect&&this.close()}),this.listen(this.#e,"keydown",n=>this.#a(n)),this.listen(this.el,"keydown",n=>this.#h(n))}render(){let e=u("div",{id:z("zx-dropdown"),popover:"manual"});return e.dataset.state="closed",e}open(){if(this.isOpen()||this.#o)return this;let e=this.#c();return this.el.parentElement!==e&&e.append(this.el),this.#t=ae(this.#e,this.el,{placement:this.options.placement,offset:Number(this.options.offset),matchWidth:!!this.options.matchWidth}),this.el.dataset.state="open",this.#s=ht({kind:"popup",root:this.el,owner:this,anchor:[this.#e,te(this.options.scope)],inside:[this.#e],onEscape:t=>this.#u(t),onOutsidePointer:()=>this.close(),onParentClose:()=>this.close()}),this.el.dataset.zxOverlayOrder=String(this.#s.order),this.#e.setAttribute("aria-expanded","true"),this.emit("open"),this}close(){if(!this.isOpen())return this;let e=this.el.contains(document.activeElement);this.#t?.destroy(),this.#t=null,this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder;let t=this.#s;return this.#s=null,this.#e.setAttribute("aria-expanded","false"),e&&this.#r&&this.#e instanceof HTMLElement&&this.#e.focus(),dt(this.el.parentElement)&&this.el.parentElement?.isConnected&&he(this.options.scope??this.#e).append(this.el),t?.release(),this.emit("close"),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#t!==null}setContent(e){return Xa(this.el,e),this.#t?.update(),this}getPanel(){return this.el}destroy(){if(!this.#o){this.#o=!0,this.close();for(let[e,t]of this.#i)xm(this.#e,e,t);super.destroy()}}_configure(e){return"onEscape"in e&&(this.#n=e.onEscape??null),"tabReach"in e&&(this.#r=!!e.tabReach),this}#c(){return dt(this.#e)??dt(te(this.options.scope))??Pt(this.options.scope??this.#e)}#u(e){if(this.#n){this.#n(e);return}let t=this.el.contains(document.activeElement);this.close(),t&&this.#e instanceof HTMLElement&&this.#e.focus()}#a(e){if(e.key!=="Tab"||e.shiftKey||e.defaultPrevented||!this.#r||!this.isOpen())return;let t=Vn(this.el)[0]??(this.el.hasAttribute("tabindex")?this.el:null);t instanceof HTMLElement&&(e.preventDefault(),t.focus())}#h(e){if(e.key!=="Tab"||e.defaultPrevented||!this.#r||!this.isOpen())return;let t=Vn(this.el),s=document.activeElement;if((s&&s!==this.el?t.filter(o=>!o.contains(s)&&(e.shiftKey?!!(s.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_PRECEDING):!!(s.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)&&!s.contains(o))):e.shiftKey?[]:t).length>0)return;if(e.shiftKey){if(!(this.#e instanceof HTMLElement))return;e.preventDefault(),this.#e.focus();return}let r=wm(this.#e,this.el);r&&(e.preventDefault(),r.focus())}#l(e){this.#i.set(e,this.#e.getAttribute(e))}};function Vn(i){return Array.from(i.querySelectorAll(ym)).filter(e=>vm(e))}function wm(i,e){let t=dt(i)??i.ownerDocument.body??i.ownerDocument.documentElement,s=Vn(t).filter(o=>!e.contains(o)),n=s.findIndex(o=>o===i||i.contains(o));if(n<0)return null;let r=n+1;for(;r<s.length&&i.contains(s[r]);)r+=1;return s[r]??null}function vm(i){let e=i;if(typeof e.focus!="function"||e.tabIndex<0||e.disabled||i.closest('[inert], [hidden], [aria-hidden="true"], fieldset[disabled]'))return!1;if(e instanceof HTMLInputElement&&e.type==="radio"&&e.name&&!e.checked){let t=e.form??e.getRootNode(),s=Array.from(t.querySelectorAll?.('input[type="radio"]')??[]).filter(n=>n.name===e.name&&(n.form??n.getRootNode())===t);if(s.some(n=>n.checked)||s[0]!==e)return!1}return typeof e.checkVisibility=="function"?e.checkVisibility({visibilityProperty:!0}):e.getClientRects().length>0}function xm(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}var qn=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),Bn=class extends k{static cssName="app-icon";static defaults={icon:null,color:null,tone:null,size:36,iconSize:"52%",label:null,badge:null,selected:!1,shape:"tile",glass:"subtle",class:[]};render(){this._createdRoot=this.el===null;let e=this.el??u("span");return this.el=e,this._snapshot=this._createdRoot?null:$(e),this._interactiveRoot=e.matches('a[href], button, input, select, textarea, [role="button"], [role="link"]'),this._state={...this.options},this._appliedClasses=[],this._sync(),e}set(e={}){return!e||typeof e!="object"?this:(Object.assign(this._state,e),this._sync(),this)}destroy(){let e=this.el,t=this._snapshot;super.destroy(),!this._createdRoot&&e&&H(e,t)}_sync(){let e=this._state;this.el.classList.remove(...this._appliedClasses),this._appliedClasses=[e.class].flat().flatMap(c=>String(c??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let t=ac(e.size,"36px"),s=ac(e.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",t),this.el.style.setProperty("--zx-app-icon-glyph-size",s),Ie(e.color)?this.el.style.setProperty("--zx-app-icon-color",String(e.color)):this.el.style.removeProperty("--zx-app-icon-color"),qn.includes(e.tone)?this.el.dataset.tone=e.tone:delete this.el.dataset.tone,this.el.dataset.glass=Am(e.glass),this.el.dataset.shape=km(e.shape),this.el.toggleAttribute("data-selected",!!e.selected);let n=e.label==null?"":String(e.label).trim();if(this._interactiveRoot){let c=lc(this._snapshot,"role"),d=lc(this._snapshot,"aria-label");c===null?this.el.removeAttribute("role"):this.el.setAttribute("role",c),n?this.el.setAttribute("aria-label",n):d===null?this.el.removeAttribute("aria-label"):this.el.setAttribute("aria-label",d),this.el.removeAttribute("aria-hidden")}else n?(this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",n),this.el.removeAttribute("aria-hidden")):(this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true"));let r=Sm(e.icon),o=e.badge==null||e.badge===""?null:u("span",{class:"zx-app-icon__badge",ariaHidden:"true"},String(e.badge)),l=[u("span",{class:"zx-app-icon__surface",ariaHidden:"true"},u("span",{class:"zx-app-icon__shine",ariaHidden:"true"}),u("span",{class:"zx-app-icon__glyph",ariaHidden:"true"},r))];o&&l.push(o),this.el.replaceChildren(...l)}};function hs(i={}){return new Bn(null,i).toElement()}function Sm(i){let e=typeof i=="function"?i():i;return typeof e=="string"?x(e,{size:"1em"}):e&&typeof e=="object"&&typeof e.nodeType=="number"?e:null}function ac(i,e){if(typeof i=="number"&&Number.isFinite(i))return`${Math.max(1,i)}px`;let t=String(i??"").trim();return t&&!/[;{}]/.test(t)?t:e}function Am(i){return i===!1||i==="none"?"none":i==="strong"?"strong":"subtle"}function km(i){return i==="circle"?"circle":"tile"}function lc(i,e){return i?.attributes.find(([t])=>t===e)?.[1]??null}var fs=class extends k{static cssName="app-rail";static partBlock="zx-app-rail";static defaults={items:[],active:null,orientation:"vertical",side:"left",label:"Applications",header:null,footer:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(e=null,t={}){super(e,t),this._rebuild()}render(){this._createdRoot=this.el===null;let e=this.el??u("nav");this.el=e,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes,o=>[o.name,o.value]),children:Array.from(e.childNodes)},this._items=Ge(this.options.items),this._active=this.options.active,this._flyouts=new Map,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._openTimers=new Map,this._closeTimers=new Map,this._pointerFocus=new WeakSet,this._silenceFlyoutEvents=!1,e.setAttribute("aria-label",String(this.options.label)),e.tagName!=="NAV"&&e.setAttribute("role","navigation"),e.dataset.orientation=this.options.orientation==="horizontal"?"horizontal":"vertical";let t=e.dataset.orientation==="horizontal"?["top","bottom"]:["left","right"];e.dataset.side=t.includes(this.options.side)?this.options.side:t[0];let s=this._partBlock(),n=u("div",{class:`${s}__header`}),r=u("div",{class:`${s}__footer`});return dc(n,this.options.header),dc(r,this.options.footer),n.hidden=!n.hasChildNodes(),r.hidden=!r.hasChildNodes(),e.replaceChildren(n,u("ul",{ref:"list",class:`${s}__list`}),r),this.listen(e,"keydown",o=>this._onRailKeydown(o)),e}setItems(e){return this._items=Ge(e),this._rebuild(),this}setActive(e){return this._active=e,this._syncActive(),this}getItems(){return this._items.map(e=>({...e,children:e.children?.map(t=>({...t}))}))}openFlyout(e,{focus:t=!1}={}){let s=this._resolveFlyout(e);if(!s)return this;let n=[s],r=s.parentKey===null?null:this._flyouts.get(s.parentKey)??null;for(;r;)n.unshift(r),r=r.parentKey===null?null:this._flyouts.get(r.parentKey)??null;if(n.some(o=>o.item.disabled))return this;this._cancelFlyoutTimers(s,!0);for(let[o,a]of this._flyouts)o!==s.key&&a.dropdown.isOpen()&&!this._isAncestor(a,s)&&this.closeFlyout(o);for(let o of n)this._tooltipById.get(String(o.item.id))?.hide(),o.dropdown.open();return t&&uc(s.panel)?.focus(),this}closeFlyout(e){let t=this._resolveFlyout(e);if(!t)return this;for(let s of[...this._flyouts.values()].reverse())s!==t&&this._isAncestor(t,s)&&(this._cancelTimers(s.key),s.dropdown.close());return this._cancelTimers(t.key),t.dropdown.close(),this}closeAllFlyouts(){for(let e of this._flyouts.values())e.parentKey===null&&this.closeFlyout(e.key);for(let e of[...this._flyouts.values()].reverse())this._cancelTimers(e.key),e.dropdown.isOpen()&&e.dropdown.close();return this}isFlyoutOpen(e){return this._resolveFlyout(e)?.dropdown.isOpen()??!1}focus(){return uc(this.refs.list)?.focus(),this}_containsNode(e){return!!(e&&(this.el.contains(e)||[...this._flyouts.values()].some(t=>t.panel.contains(e))))}destroy(){let e=this._original;if(this._clearArtifacts(),super.destroy(),!this._createdRoot&&e){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,s]of e.attributes)this.el.setAttribute(t,s);this.el.replaceChildren(...e.children)}}_rebuild(){this._clearArtifacts(),this.refs.list.replaceChildren(),this._interaction=new $n(this.el);let e=!1;for(let t of Hn(this._items)){if(t===hc){e&&this.refs.list.append(u("li",{class:`${this._partBlock()}__separator`,ariaHidden:"true"}));continue}e=!0;let s=Array.isArray(t.children)&&t.children.length>0&&this._flyoutsFor(t),n=this._renderControl(t,s),r=u("li",{class:`${this._partBlock()}__row`},n);if(this.refs.list.append(r),this._tooltipFor(t)){let o=new gt(n,{content:t.label,placement:Mm(this.el.dataset.side),delay:450});this._tooltips.push(o),this._tooltipById.set(String(t.id),o)}s?this._buildFlyout(t,n,String(t.id),null):this._interaction.listen(n,"click",o=>{if(!this._select(t,o).defaultPrevented)for(let l of this._flyouts.values())l.parentKey===null&&l.dropdown.isOpen()&&this.closeFlyout(l.key)})}this._afterRebuild(),this._syncActive()}_partBlock(){return this.constructor.partBlock}_renderControl(e,t){return cc(e,{className:"zx-app-rail__item",index:String(e.id),iconOnly:!0,disclosure:t,disclosureIcon:Cm(this.el.dataset.side),visual:ps(e,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:"root"})})}_flyoutsFor(e){return!0}_tooltipFor(e){return!0}_afterRebuild(){}_buildFlyout(e,t,s,n){let r=u("ul",{class:"zx-app-rail__flyout-list"});for(let h of Hn(e.children??[],!0)){if(h.section){r.append(u("li",{class:"zx-app-rail__flyout-section"},h.label));continue}let p=`${s}/${h.id}`,f=!!h.children?.length,m=cc(h,{className:"zx-app-rail__flyout-item",index:p,iconOnly:!1,disclosure:f,disclosureIcon:zm(this.el.dataset.side),visual:ps(h,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:p.split("/").length,location:"flyout"})});r.append(u("li",{},m)),f?this._buildFlyout(h,m,p,s):this._interaction.listen(m,"click",g=>{this._select(h,g).defaultPrevented||this._closeFlyoutChain(s)})}let o=u("div",{class:"zx-app-rail__flyout"},u("div",{class:"zx-app-rail__flyout-title"},e.label),r),a=new yt(t,{openOn:"manual",placement:n===null?Em(this.el.dataset.side):Tm(this.el.dataset.side),content:o,offset:6}),l=a.getPanel();a._configure({tabReach:!1,onEscape:()=>{let h=l.contains(document.activeElement);this.closeFlyout(s),h&&this._restoreFocus(t)}}),l.classList.add("zx-app-rail__popover"),l.dataset.side=this.el.dataset.side,l.setAttribute("role","region"),l.setAttribute("aria-label",this._message("appRail.subNavigation","%1 sub-navigation",e.label));let c={key:s,parentKey:n,item:e,trigger:t,panel:l,dropdown:a};this._flyouts.set(s,c);let d=n===null?this._tooltipById.get(String(e.id)):null;a.on("open",()=>{d?.disable(),this._silenceFlyoutEvents||this.emit("flyoutchange",{item:e,id:e.id,open:!0})}),a.on("close",()=>{d?.enable(),this._silenceFlyoutEvents||this.emit("flyoutchange",{item:e,id:e.id,open:!1})}),this._interaction.listen(t,"pointerdown",()=>{this._pointerFocus.add(t),queueMicrotask(()=>this._pointerFocus.delete(t))}),this._interaction.listen(t,"pointerenter",h=>{h.pointerType!=="touch"&&this._scheduleOpen(s)}),this._interaction.listen(t,"pointerleave",()=>this._scheduleClose(s)),this._interaction.listen(t,"focus",()=>{this._pointerFocus.has(t)||this.openFlyout(s)}),this._interaction.listen(t,"focusout",h=>{l.contains(h.relatedTarget)||this._scheduleClose(s)}),this._interaction.listen(t,"click",h=>{h.preventDefault(),h instanceof MouseEvent&&h.detail===0?this.openFlyout(s,{focus:!0}):this.openFlyout(s)}),this._interaction.listen(l,"pointerenter",()=>this._cancelFlyoutTimers(c,!0)),this._interaction.listen(l,"pointerleave",()=>this._scheduleFlyoutClose(c,!0)),this._interaction.listen(l,"focusin",()=>this._cancelFlyoutTimers(c,!0)),this._interaction.listen(l,"focusout",h=>{h.relatedTarget!==t&&!l.contains(h.relatedTarget)&&this._scheduleFlyoutClose(c,!0)}),this._interaction.listen(l,"keydown",h=>this._onFlyoutKeydown(h,c))}_select(e,t){if(e.disabled){t.preventDefault();let n=new Event("select",{cancelable:!0});return n.preventDefault(),n}let s=this.emit("select",{item:e,id:e.id,value:e.value??e.id,href:e.href??null,event:t});return s.defaultPrevented?t.preventDefault():e.href||(t.preventDefault(),e.invoke?.()),s}_onRailKeydown(e){let t=Im(this.refs.list),s=e.target?.closest?.("[data-app-nav-id]"),n=t.indexOf(s);if(n<0)return;let r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",l={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],c=s.getAttribute("data-app-nav-id");if(e.key===l&&this._flyouts.has(String(c))){e.preventDefault(),this.openFlyout(String(c),{focus:!0});return}let d;if(e.key==="Home")d=0;else if(e.key==="End")d=t.length-1;else if(e.key===o)d=(n-1+t.length)%t.length;else if(e.key===a)d=(n+1)%t.length;else return;e.preventDefault(),t[d]?.focus()}_onFlyoutKeydown(e,t){let s=fc(t.panel),n=e.target?.closest?.("a, button"),r=s.indexOf(n),o=[...this._flyouts.values()].find(d=>d.trigger===n),a=this.el.dataset.side==="right"?"ArrowLeft":"ArrowRight",l=a==="ArrowRight"?"ArrowLeft":"ArrowRight";if(o&&e.key===a){e.preventDefault(),e.stopPropagation(),this.openFlyout(o.key,{focus:!0});return}if((t.parentKey!==null||this.el.dataset.orientation==="vertical")&&e.key===l){e.preventDefault(),e.stopPropagation(),this.closeFlyout(t.key),this._restoreFocus(t.trigger);return}if(s.length===0)return;let c;if(e.key==="Home")c=0;else if(e.key==="End")c=s.length-1;else if(e.key==="ArrowDown")c=(r+1+s.length)%s.length;else if(e.key==="ArrowUp")c=(r-1+s.length)%s.length;else return;e.preventDefault(),s[c]?.focus()}_scheduleOpen(e){let t=String(e);this._cancelTimer(this._closeTimers,t),this._cancelTimer(this._openTimers,t);let s=Math.max(0,Number(this.options.openDelay)||0);this._openTimers.set(t,setTimeout(()=>{this._openTimers.delete(t),this.openFlyout(e)},s))}_scheduleClose(e){let t=String(e);this._cancelTimer(this._openTimers,t),this._cancelTimer(this._closeTimers,t);let s=Math.max(0,Number(this.options.closeDelay)||0);this._closeTimers.set(t,setTimeout(()=>{this._closeTimers.delete(t);let n=this._flyouts.get(t);n&&(this._branchInteracting(n)||this.closeFlyout(t))},s))}_scheduleFlyoutClose(e,t){let s=e;for(;s&&(this._scheduleClose(s.key),!(!t||s.parentKey===null));)s=this._flyouts.get(s.parentKey)??null}_resolveFlyout(e){let t=String(e);return this._flyouts.get(t)??[...this._flyouts.values()].find(s=>String(s.item.id)===t)??null}_closeFlyoutChain(e){let t=this._flyouts.get(e)??null;for(;t?.parentKey!==null;)t=this._flyouts.get(t.parentKey)??null;t&&this.closeFlyout(t.key)}_isAncestor(e,t){let s=t.parentKey;for(;s!==null;){if(s===e.key)return!0;s=this._flyouts.get(s)?.parentKey??null}return!1}_cancelFlyoutTimers(e,t){let s=e;for(;s&&(this._cancelTimers(s.key),!(!t||s.parentKey===null));)s=this._flyouts.get(s.parentKey)??null}_branchInteracting(e){return e.trigger.matches(":hover")||e.panel.matches(":hover")||e.trigger===document.activeElement||e.panel.contains(document.activeElement)?!0:[...this._flyouts.values()].some(t=>this._isAncestor(e,t)&&t.dropdown.isOpen()&&(t.trigger.matches(":hover")||t.panel.matches(":hover")||t.trigger===document.activeElement||t.panel.contains(document.activeElement)))}_restoreFocus(e){this._pointerFocus.add(e),e.focus(),queueMicrotask(()=>this._pointerFocus.delete(e))}_cancelTimers(e){this._cancelTimer(this._openTimers,e),this._cancelTimer(this._closeTimers,e)}_cancelTimer(e,t){let s=e.get(t);s!==void 0&&clearTimeout(s),e.delete(t)}_syncActive(){let e=this._active==null?null:String(this._active);for(let t of this.refs.list.querySelectorAll("[data-app-nav-id]")){let s=e!==null&&t.getAttribute("data-app-nav-value-id")===e,n=this._flyouts.get(String(t.getAttribute("data-app-nav-id"))),r=e!==null&&n?Un(n.item.children??[],e):!1;s?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current"),r?t.dataset.activeDescendant="true":delete t.dataset.activeDescendant}for(let t of this._flyouts.values()){e!==null&&Un(t.item.children??[],e)?t.trigger.dataset.activeDescendant="true":delete t.trigger.dataset.activeDescendant;for(let n of t.panel.querySelectorAll("[data-app-nav-value-id]"))e!==null&&n.getAttribute("data-app-nav-value-id")===e?n.setAttribute("aria-current","page"):n.removeAttribute("aria-current")}}_clearArtifacts(){for(let e of this._openTimers?this._openTimers.values():[])clearTimeout(e);for(let e of this._closeTimers?this._closeTimers.values():[])clearTimeout(e);this._openTimers?.clear?.(),this._closeTimers?.clear?.(),this._interaction?.destroy?.();for(let e of this._tooltips??[])e.destroy();this._silenceFlyoutEvents=!0;for(let e of this._flyouts?.values?.()??[])e.dropdown.destroy();this._silenceFlyoutEvents=!1,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._flyouts=new Map}_message(e,t,...s){let n=this.msg(e,...s);return n===e?q(t,s):n}},$n=class extends k{constructor(e){super(null),e.append(this.el)}render(){return u("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}},hc=Object.freeze({});function Hn(i,e=!1){return i.flatMap(t=>t.section?[e?t:hc,...Hn(t.children??[],e)]:[t])}function Ge(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.label!=null&&(e.id!=null||e.section===!0)).map((e,t)=>{let s={...e,id:e.id??`section:${t}:${e.label}`,label:String(e.label),children:Array.isArray(e.children)?Ge(e.children):[]};if(e.section===!0)return s.section=!0,delete s.href,s;if(e.href==null)return s;let n=Ve(e.href);return n!==null?s.href=n:(delete s.href,s.children.length===0&&typeof s.invoke!="function"&&(s.disabled=!0)),s}):[]}function ps(i,e,t){let s=typeof e=="function"?e(i,t):null,n=s==null?rs(i.agent||null,{size:"sm",label:null,animate:!1},{fallback:{name:i.label},carry:ns}):null;if(n)return new We(null,n).toElement();if(s==null&&(s=i.icon),typeof s=="function"&&(s=s(t,i)),typeof s=="string")return x(s);if(s instanceof Node)return s.cloneNode(!0);if(s&&typeof s=="object"&&typeof s.toElement=="function"){let r=s.toElement();return r instanceof Node?r.cloneNode(!0):null}return null}function ms(i){let e=i instanceof Element?k.from(i):null;return e instanceof We?e.getActivityWord():null}function Gt(i,e,t=!1){let s=ms(e),n=s?`${i.label}, ${s}`:i.label;return t&&i.badge!=null&&i.badge!==""?`${n} (${i.badge})`:n}function cc(i,{className:e,index:t,iconOnly:s,disclosure:n,disclosureIcon:r,visual:o}){let a=Ve(i.href),l=ms(o)!==null,c=a&&!n?"a":"button";return u(c,{class:e,type:c==="button"?"button":null,href:c==="a"?a:null,target:c==="a"?i.target??null:null,rel:c==="a"?"noopener":null,ariaLabel:s?Gt(i,o):l?Gt(i,o,!0):null,ariaDisabled:i.disabled?"true":null,dataset:{appNavId:t,appNavValueId:String(i.id)}},o?u("span",{class:`${e}-icon`,ariaHidden:"true"},o):null,u("span",{class:`${e}-label`},i.label),i.badge!=null?u("span",{class:`${e}-badge`},String(i.badge)):null,n?u("span",{class:`${e}-disclosure`,ariaHidden:"true"},x(r)):null)}function Cm(i){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[i]??"chevron-right"}function zm(i){return i==="right"?"chevron-left":"chevron-right"}function Em(i){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[i]??"right-start"}function Tm(i){return i==="right"?"left-start":"right-start"}function Mm(i){return{left:"right",right:"left",top:"bottom",bottom:"top"}[i]??"right"}function fc(i){return[...i.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function uc(i){return fc(i)[0]??null}function Im(i){return[...i.children].map(e=>e.querySelector("[data-app-nav-id]")).filter(Boolean)}function Un(i,e){return i.some(t=>String(t.id)===e||Un(t.children??[],e))}function dc(i,e){if(e!=null)if(typeof e=="string"||typeof e=="number")i.append(document.createTextNode(String(e)));else if(typeof e=="object"&&typeof e.toElement=="function"){let t=e.toElement();t&&i.append(t)}else typeof e=="object"&&typeof e.nodeType=="number"&&i.append(e)}var Dm=["tint","solid","plain"],Om=12,Nm=600,_s=class extends fs{static cssName="module-bar";static partBlock="zx-module-bar";static defaults={items:[],active:null,orientation:"vertical",side:"left",appearance:"tint",labels:"hidden",menus:"flyout",expanded:null,controls:null,allModules:"auto",header:null,footer:null,label:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(e=null,t={}){super(e,t)}render(){let e=super.render();return this._sections=new Map,this._items=Wn(this._items,this._sections),this._appearance=Dm.includes(this.options.appearance)?this.options.appearance:"tint",this._menus=this.options.menus==="none"?"none":"flyout",this._expandedId=this.options.expanded??null,this._labels=this.options.labels,this._promoted=null,this._catalogue=null,this._silenceCatalogue=!1,this._catalogueTooltip=null,this._observer=null,this._partition={visible:[],overflow:[]},this._rovingId=null,this._typeahead={text:"",at:0},e.setAttribute("aria-label",this._labelText()),e.dataset.appearance=this._appearance,e.dataset.menus=this._menus,e.dataset.allModules=["always","never"].includes(this.options.allModules)?this.options.allModules:"auto",e.dataset.labels=Kn(this.options.labels,e.dataset.orientation),e}setItems(e){let t=new Map,s=Wn(Ge(e),t);return this._sections=t,super.setItems(s)}getItems(){return super.getItems()}setActive(e){return super.setActive(e)}openFlyout(e,t={}){return super.openFlyout(e,t)}closeFlyout(e){return super.closeFlyout(e)}closeAllFlyouts(){return super.closeAllFlyouts()}isFlyoutOpen(e){return super.isFlyoutOpen(e)}setExpanded(e){return this._expandedId=e??null,this._syncExpanded(),this._layout(),this}setBadge(e,t){let s=Ce(this._items,e);if(!s)return this;t==null||t===""?delete s.badge:s.badge=t;let n=String(e);for(let o of this.refs.list.querySelectorAll(".zx-module-bar__item[data-app-nav-value-id]"))o.getAttribute("data-app-nav-value-id")===n&&this._applyTileBadge(o,s);for(let o of this._flyouts.values())for(let a of o.panel.querySelectorAll("[data-app-nav-value-id]"))a.getAttribute("data-app-nav-value-id")===n&&Yn(a,s,"zx-app-rail__flyout-item");let r=this._catalogueEntry(n);return r&&Yn(r,s,"zx-module-bar__entry"),this}setLayout(e={}){let t=e.orientation==="horizontal"||e.orientation==="vertical"?e.orientation:this.el.dataset.orientation,s=t==="horizontal"?["top","bottom"]:["left","right"],n=s.includes(e.side??this.el.dataset.side)?e.side??this.el.dataset.side:s[0];return t===this.el.dataset.orientation&&n===this.el.dataset.side?this:(this.el.dataset.orientation=t,this.el.dataset.side=n,this.el.dataset.labels=Kn(this._labels,t),this._rebuild(),this)}setLabels(e){this._labels=e;let t=Kn(e,this.el.dataset.orientation);if(t===this.el.dataset.labels)return this;let s=document.activeElement,n=s instanceof HTMLElement&&this.refs.list.contains(s)&&s.matches(".zx-module-bar__item")?gs(s):null;return this.el.dataset.labels=t,this._rebuild(),n!==null&&[...this.refs.list.querySelectorAll(".zx-module-bar__item")].find(r=>gs(r)===n)?.focus(),this}openAllModules(){return this._catalogue?.open(),this._focusCatalogue(),this}closeAllModules(){return this._catalogue?.close(),this}isAllModulesOpen(){return this._catalogue?.isOpen()??!1}focus(){return this._rovingStop()?.focus(),this}destroy(){super.destroy()}_containsNode(e){return super._containsNode(e)||!!(e&&this._catalogue?.getPanel().contains(e))}_clearArtifacts(){super._clearArtifacts(),this._observer?.disconnect(),this._observer=null,this._catalogueTooltip?.destroy(),this._catalogueTooltip=null,this._silenceCatalogue=!0,this._catalogue?.destroy(),this._silenceCatalogue=!1,this._catalogue=null}_flyoutsFor(e){return this._menus==="flyout"&&!e.disabled}_tooltipFor(){return this.el.dataset.labels==="hidden"}_renderControl(e){let t=!!e.children?.length,s=e.href&&!t?"a":"button",n=this.el.dataset.labels!=="hidden",r=u(s,{class:"zx-module-bar__item",type:s==="button"?"button":null,href:s==="a"?e.href:null,target:s==="a"?e.target??null:null,rel:s==="a"&&e.target?"noopener":null,ariaDisabled:e.disabled?"true":null,tabIndex:-1,dataset:{appNavId:String(e.id),appNavValueId:String(e.id)}},this._renderTile(e,"bar"),n?u("span",{class:"zx-module-bar__label"},e.label):null);return this._applyTileBadge(r,e),r}_afterRebuild(){let e=this.refs.list,t=_c(this._items),s=new Map;for(let r of[...e.children]){let o=r.querySelector("[data-app-nav-value-id]")?.getAttribute("data-app-nav-value-id");o!=null&&(r.dataset.moduleId=o,s.set(o,r))}let n=null;for(let r of t){let o=s.get(String(r.id));if(!o)continue;let a=this._sections.get(String(r.id))??null;a!==null&&a!==n&&e.append(u("li",{class:"zx-module-bar__heading",dataset:{section:a}},u("span",{class:"zx-module-bar__heading-label"},a))),n=a,e.append(o)}this._promoted!==null&&!Ce(this._items,this._promoted)&&(this._promoted=null),this._buildCatalogue(),this._interaction.listen(e,"focusin",r=>{let o=r.target.closest?.(".zx-module-bar__item");o instanceof HTMLElement&&this._setRovingStop(o)}),this._interaction.listen(e,"focusout",r=>{e.contains(r.relatedTarget)||(this._rovingId=null,this._syncRoving())}),typeof ResizeObserver=="function"&&(this._observer=new ResizeObserver(()=>this._layout()),this._observer.observe(e))}_syncActive(){super._syncActive();let e=this._active==null?null:String(this._active);for(let t of this._tiles()){let s=Ce(this._items,t.getAttribute("data-app-nav-value-id"));if(!s)continue;let n=gc(s,e);n?t.setAttribute("aria-current",n):t.removeAttribute("aria-current"),n==="true"?t.dataset.activeDescendant="true":delete t.dataset.activeDescendant}for(let t of this._catalogueEntries()){let s=Ce(this._items,t.dataset.moduleId),n=s?gc(s,e):null;n?t.setAttribute("aria-current",n):t.removeAttribute("aria-current")}this._syncExpanded(),this._layout()}_layout(){let e=this.refs.list;if(!e||!this._items)return;let t=[...e.querySelectorAll(":scope > [data-module-id]")],s=e.querySelector(":scope > [data-module-bar-more]"),n=this.el.dataset.allModules,r=[jm(this._items,this._active)?.id,this._expandedId,this._promoted],o=1/0;if(n!=="never"&&e.isConnected){for(let h of t)h.hidden=!1;s&&(s.hidden=!1),pc(e),o=Fm(e,this.el.dataset.orientation==="horizontal",t.length+1)}let a=Rm(this._items,o,r,n==="always"),l=new Set(a.visible.map(h=>String(h.id)));for(let h of t)h.hidden=!l.has(h.dataset.moduleId);pc(e),s&&(s.hidden=n==="never"||n==="auto"&&!a.more);let c={visible:a.visible.map(h=>h.id),overflow:a.overflow.map(h=>h.id)},d=c.visible.join("\0")!==this._partition.visible.join("\0")||c.overflow.join("\0")!==this._partition.overflow.join("\0");this._partition=c,this._syncRoving(),d&&e.isConnected&&this.emit("overflowchange",{...c})}_renderTile(e,t){let s=ps(e,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:t==="bar"?"module":"catalogue"})??u("span",{class:"zx-module-bar__initial"},e.label.trim().charAt(0).toUpperCase());if(s instanceof Element&&s.classList.contains("zx-agent-avatar"))return u("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{agent:""}},s);let{tone:n,color:r}=Lm(e),o=u("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{appearance:this._appearance,...n?{tone:n}:{},...r?{color:""}:{}}});return this._appearance==="solid"?o.append(hs({icon:s,color:r,tone:n??(r?null:"slate"),size:"var(--zx-module-bar-tile)",iconSize:"58%",glass:"subtle"})):(r&&o.style.setProperty("--zx-module-bar-color",r),o.append(s)),o}_applyTileBadge(e,t){e.querySelector(":scope > .zx-module-bar__badge")?.remove();let s=t.badge==null||t.badge===""?null:String(t.badge),n=Gt(t,e.querySelector(".zx-module-bar__tile > .zx-agent-avatar"));e.setAttribute("aria-label",s===null?n:this._message("moduleBar.itemBadge","%1 (%2)",n,s)),s!==null&&e.append(u("span",{class:"zx-module-bar__badge",ariaHidden:"true",dataset:{zxBadge:s.length>2&&this.el.dataset.labels!=="beside"?"dot":"count"}},s))}_buildCatalogue(){let e=this._message("moduleBar.more","All modules"),t=this.el.dataset.labels!=="hidden",s=u("button",{class:"zx-module-bar__item",type:"button",ariaLabel:e,tabIndex:-1,dataset:{moduleBarMore:""}},u("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{appearance:"plain"}},x("grid")),t?u("span",{class:"zx-module-bar__label"},e):null);this.refs.list.append(u("li",{class:"zx-module-bar__row",dataset:{moduleBarMore:""}},s)),t||(this._catalogueTooltip=new gt(s,{content:e,placement:{left:"right",right:"left",top:"bottom",bottom:"top"}[this.el.dataset.side]??"right",delay:450}));let n=this._items.length>Om?u("input",{class:"zx-module-bar__filter",type:"search",autocomplete:"off",placeholder:this._message("moduleBar.filter","Filter modules"),ariaLabel:this._message("moduleBar.filter","Filter modules")}):null,r=new Map;for(let p of this._items){let f=typeof p.group=="string"?p.group:this._sections.get(String(p.id))??"";r.has(f)||r.set(f,[]),r.get(f).push(p)}let o=[...r].map(([p,f])=>{let m=p?z("zx-module-bar-group"):null;return u("div",{class:"zx-module-bar__group"},p?u("div",{class:"zx-module-bar__group-label",id:m},p):null,u("ul",{class:"zx-module-bar__grid",ariaLabelledby:m},f.map(g=>u("li",{dataset:{moduleId:String(g.id)}},this._catalogueControl(g)))))}),a=u("p",{class:"zx-module-bar__empty",hidden:!0},this._message("moduleBar.empty","No modules")),l=u("div",{class:"zx-module-bar__catalogue"},n,...o,a),c={left:"right-start",right:"left-start",top:"bottom-end",bottom:"top-end"}[this.el.dataset.side]??"right-start",d=new yt(s,{content:l,placement:c,offset:6}),h=d.getPanel();h.classList.add("zx-module-bar__popover"),h.setAttribute("role","region"),h.setAttribute("aria-label",e),this._catalogue=d,d.on("open",()=>{this.closeAllFlyouts(),this._catalogueTooltip?.hide(),this.emit("allmodules",{open:!0})}),d.on("close",()=>{n instanceof HTMLInputElement&&n.value&&(n.value="",this._filterCatalogue("")),this._silenceCatalogue||this.emit("allmodules",{open:!1})}),this._interaction.listen(s,"click",()=>{d.isOpen()&&this._focusCatalogue()}),n&&this._interaction.listen(n,"input",()=>this._filterCatalogue(n.value)),this._interaction.listen(h,"click",p=>this._onCatalogueClick(p)),this._interaction.listen(h,"focusout",p=>{let f=p.relatedTarget;f&&!h.contains(f)&&f!==s&&d.close()}),this._interaction.listen(h,"keydown",p=>this._onCatalogueKeydown(p)),this._interaction.listen(h,"focusin",p=>{let f=p.target.closest?.(".zx-module-bar__entry");f instanceof HTMLElement&&this._syncCatalogueStop(f)}),this._syncCatalogueStop()}_syncCatalogueStop(e){let t=this._catalogueEntries(),s=t.filter(r=>!r.closest("li")?.hidden),n=(e&&s.includes(e)?e:null)??s.find(r=>r.tabIndex===0&&r.dataset.catalogueStop==="true")??s.find(r=>r.hasAttribute("aria-current"))??s[0];for(let r of t)r.tabIndex=r===n?0:-1,r===n?r.dataset.catalogueStop="true":delete r.dataset.catalogueStop}_catalogueControl(e){let t=!!e.children?.length,s=e.href&&!t?"a":"button",n=u(s,{class:"zx-module-bar__entry",type:s==="button"?"button":null,href:s==="a"?e.href:null,target:s==="a"?e.target??null:null,rel:s==="a"&&e.target?"noopener":null,title:typeof e.description=="string"?e.description:null,ariaDisabled:e.disabled?"true":null,dataset:{moduleId:String(e.id)}},this._renderTile(e,"catalogue"),u("span",{class:"zx-module-bar__entry-label"},e.label));return Yn(n,e,"zx-module-bar__entry"),n}_onCatalogueClick(e){let t=e.target.closest?.(".zx-module-bar__entry");if(!(t instanceof HTMLElement))return;let s=Ce(this._items,t.dataset.moduleId);if(!s||s.disabled){e.preventDefault();return}if(s.children?.length&&this._menus==="flyout"){e.preventDefault(),this._catalogue?.close(),this._promoted=s.id,this._layout();let o=e instanceof MouseEvent&&e.detail===0;this.openFlyout(s.id,{focus:o}),o||this._tiles().find(a=>a.getAttribute("data-app-nav-value-id")===String(s.id))?.focus();return}this._select(s,e);let n=this._catalogue?.getPanel();this._catalogue?.close();let r=document.activeElement;(!r||r===document.body||n?.contains(r))&&(this._tiles().find(a=>a.getAttribute("data-app-nav-value-id")===String(s.id)&&!a.closest("li")?.hidden)??this.refs.list.querySelector("[data-module-bar-more] .zx-module-bar__item"))?.focus()}_onCatalogueKeydown(e){let t=this._catalogue?.getPanel();if(!t||e.altKey||e.ctrlKey||e.metaKey)return;let s=t.querySelector(".zx-module-bar__filter"),n=this._catalogueEntries().filter(l=>!l.closest("li")?.hidden),r=e.target.closest?.(".zx-module-bar__entry");if(e.target===s){e.key==="ArrowDown"&&n[0]&&(e.preventDefault(),n[0].focus());return}if(!(r instanceof HTMLElement))return;let o=n.indexOf(r),a=null;if(e.key==="ArrowRight")a=n[Math.min(n.length-1,o+1)];else if(e.key==="ArrowLeft")a=n[Math.max(0,o-1)];else if(e.key==="Home")a=n[0];else if(e.key==="End")a=n.at(-1);else if(e.key==="ArrowDown"||e.key==="ArrowUp")a=Pm(n,r,e.key==="ArrowDown"?1:-1),!a&&e.key==="ArrowUp"&&s instanceof HTMLElement&&(a=s);else if(s instanceof HTMLElement&&e.key.length===1&&e.key!==" "){s.focus();return}else return;e.preventDefault(),a?.focus()}_filterCatalogue(e){let t=this._catalogue?.getPanel();if(!t)return;let s=e.trim().toLocaleLowerCase(),n=0;for(let o of t.querySelectorAll(".zx-module-bar__group")){let a=0;for(let l of o.querySelectorAll("li[data-module-id]")){let c=Ce(this._items,l.dataset.moduleId),d=`${c?.label??""} ${c?.description??""} ${c?.group??""}`.toLocaleLowerCase(),h=!s||d.includes(s);l.hidden=!h,h&&(a+=1)}o.hidden=a===0,n+=a}let r=t.querySelector(".zx-module-bar__empty");r instanceof HTMLElement&&(r.hidden=n>0),this._syncCatalogueStop()}_focusCatalogue(){let e=this._catalogue?.getPanel();if(!e||!this._catalogue?.isOpen())return;let s=e.querySelector(".zx-module-bar__filter")??this._catalogueEntries().find(n=>n.hasAttribute("aria-current"))??this._catalogueEntries()[0];s instanceof HTMLElement&&s.focus()}_onRailKeydown(e){let t=e.target.closest?.(".zx-module-bar__item");if(!(t instanceof HTMLElement)||!this.refs.list.contains(t)||e.altKey||e.ctrlKey||e.metaKey)return;let s=this._rovingControls(),n=s.indexOf(t),r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",l={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],c=t.getAttribute("data-app-nav-id");if(e.key===l&&c!==null&&this._flyouts.has(c)){e.preventDefault(),this.openFlyout(c,{focus:!0});return}let d=null;if(e.key==="Home")d=s[0];else if(e.key==="End")d=s.at(-1);else if(e.key===o)d=s[(n-1+s.length)%s.length];else if(e.key===a)d=s[(n+1)%s.length];else if(e.key.length===1&&e.key!==" ")d=this._typeaheadTarget(e.key,s,n);else return;d&&(e.preventDefault(),this._setRovingStop(d),d.focus())}_typeaheadTarget(e,t,s){let n=Date.now(),r=n-this._typeahead.at>Nm?e:this._typeahead.text+e;this._typeahead={text:r,at:n};let o=r.toLocaleLowerCase(),a=[...o].every(h=>h===o[0]),l=h=>(Ce(this._items,h.getAttribute("data-app-nav-value-id"))?.label??h.getAttribute("aria-label")??"").toLocaleLowerCase(),c=[...t.slice(s+1),...t.slice(0,s+1)],d=c.find(h=>l(h).startsWith(o))??(a?c.find(h=>l(h).startsWith(o[0])):null);return d||r.length===1?d??null:(this._typeahead={text:e,at:n},c.find(h=>l(h).startsWith(e.toLocaleLowerCase()))??null)}_tiles(){return[...this.refs.list.querySelectorAll(":scope > li > .zx-module-bar__item[data-app-nav-value-id]")]}_rovingControls(){return[...this.refs.list.querySelectorAll(":scope > li:not([hidden]) > .zx-module-bar__item")]}_rovingStop(){let e=this._rovingControls();if(this._rovingId!==null){let t=e.find(s=>gs(s)===this._rovingId);if(t)return t}return e.find(t=>t.hasAttribute("aria-current"))??e.find(t=>t.getAttribute("aria-expanded")==="true"&&t.hasAttribute("data-app-nav-value-id"))??e[0]??null}_setRovingStop(e){this._rovingId=gs(e),this._syncRoving()}_syncRoving(){let e=this._rovingStop();for(let t of this.refs.list.querySelectorAll(":scope > li > .zx-module-bar__item"))t.tabIndex=t===e?0:-1}_syncExpanded(){if(this._menus!=="none")return;let e=this._expandedId==null?null:String(this._expandedId);for(let t of this._tiles()){let s=t.getAttribute("data-app-nav-value-id"),n=Ce(this._items,s);(n?.children?.length||n?.header||n?.content||s===e)&&(t.setAttribute("aria-expanded",String(s===e)),this.options.controls&&t.setAttribute("aria-controls",String(this.options.controls)))}}_catalogueEntries(){let e=this._catalogue?.getPanel();return e?[...e.querySelectorAll(".zx-module-bar__entry")]:[]}_catalogueEntry(e){return this._catalogueEntries().find(t=>t.dataset.moduleId===e)??null}_labelText(){let e=this.options.label;return e==null||e===""?this._message("moduleBar.label","Modules"):String(e)}};function Rm(i,e=1/0,t=[],s=!1){let n=Array.isArray(i)?i.filter(m=>m&&m.id!=null):[],r=_c(n),a=n.some(mc)?r.filter(mc):r,l=Number.isFinite(e)?Math.max(1,Math.floor(e)):1/0,d=s||a.length<n.length||a.length>l?Math.max(0,l-1):l,h=a.slice(0,d),p=new Set([t].flat().filter(m=>m!=null).map(String));for(let m of p){let g=n.find(_=>String(_.id)===m);if(!(!g||h.includes(g))){if(h.length>=d){let _=h.findLastIndex(y=>!p.has(String(y.id)));_>=0&&h.splice(_,1)}h.push(g)}}h.sort((m,g)=>r.indexOf(m)-r.indexOf(g));let f=n.filter(m=>!h.includes(m));return{visible:h,overflow:f,more:f.length>0}}function Lm(i){let e=Ie(i?.color)?String(i.color).trim():null;return e?{tone:null,color:e}:{tone:qn.includes(i?.tone)?i.tone:null,color:null}}function Wn(i,e=new Map,t=null){return i.flatMap(s=>s.section?Wn(s.children??[],e,s.label):(t!==null&&e.set(String(s.id),t),[s]))}function pc(i){let e=null,t=!1,s=!0,n=()=>{e&&(e.hidden=!t)};for(let r of[...i.children]){if(r.classList.contains("zx-module-bar__heading")){n(),e=r,t=!1,s?r.dataset.leading="":delete r.dataset.leading;continue}r.hasAttribute("data-module-id")&&!r.hidden&&(t=!0,s=!1)}n()}function Kn(i,e){return e!=="vertical"?"hidden":i==="below"||i==="beside"?i:"hidden"}function mc(i){return i.pinned===!0||typeof i.pinned=="number"&&Number.isFinite(i.pinned)}function _c(i){let e=t=>typeof t.pinned=="number"&&Number.isFinite(t.pinned)?t.pinned:t.pinned===!0?Number.MAX_SAFE_INTEGER-1:Number.MAX_SAFE_INTEGER;return i.map((t,s)=>({item:t,index:s})).sort((t,s)=>e(t.item)-e(s.item)||t.index-s.index).map(({item:t})=>t)}function Fm(i,e,t){if(!(e?i.scrollWidth>i.clientWidth+1:i.scrollHeight>i.clientHeight+1))return 1/0;let n=[...i.querySelectorAll(":scope > li:not([hidden]):not(.zx-module-bar__heading)")];if(!n.length)return 1/0;let r=[...i.querySelectorAll(":scope > li.zx-module-bar__heading:not([hidden])")],o=getComputedStyle(i),a=Number.parseFloat(e?o.columnGap:o.rowGap)||0,l=e?(Number.parseFloat(o.paddingInlineStart)||0)+(Number.parseFloat(o.paddingInlineEnd)||0):(Number.parseFloat(o.paddingBlockStart)||0)+(Number.parseFloat(o.paddingBlockEnd)||0),c=Math.max(...n.map(p=>e?p.offsetWidth:p.offsetHeight)),d=r.reduce((p,f)=>p+a+(e?f.offsetWidth:f.offsetHeight)+(Number.parseFloat(e?getComputedStyle(f).marginInlineStart:getComputedStyle(f).marginBlockStart)||0)+(Number.parseFloat(e?getComputedStyle(f).marginInlineEnd:getComputedStyle(f).marginBlockEnd)||0),0),h=(e?i.clientWidth:i.clientHeight)-l-d;return c<=0||h<=0?t:Math.max(1,Math.floor((h+a)/(c+a)))}function Pm(i,e,t){let s=e.getBoundingClientRect(),n=s.left+s.width/2,r=null,o=1/0,a=1/0;for(let l of i){if(l===e)continue;let c=l.getBoundingClientRect(),d=t>0?c.top-s.bottom+1:s.top-c.bottom+1;if(d<0)continue;let h=Math.abs(c.left+c.width/2-n);(d<o-1||Math.abs(d-o)<=1&&h<a)&&(r=l,o=d,a=h)}return r}function gs(i){return i.getAttribute("data-app-nav-value-id")??"\0more"}function gc(i,e){return e===null?null:String(i.id)===e?"page":Gn(i.children??[],e)?"true":null}function Yn(i,e,t){let s=i.querySelector(":scope > .zx-module-bar__tile > .zx-agent-avatar, :scope > .zx-app-rail__flyout-item-icon > .zx-agent-avatar");ms(s)&&i.setAttribute("aria-label",Gt(e,s,!0));let n=i.querySelector(`:scope > .${t}-badge`),r=e.badge==null||e.badge===""?null:String(e.badge);if(r===null){n?.remove();return}n?n.textContent=r:i.querySelector(`:scope > .${t}-label`)?.after(u("span",{class:`${t}-badge`},r))}function jm(i,e){if(e==null||!Array.isArray(i))return null;let t=String(e);return i.find(s=>String(s.id)===t||Gn(s.children??[],t))??null}function Ce(i,e){if(e==null)return null;for(let t of i??[]){if(String(t.id)===String(e))return t;let s=Ce(t.children??[],e);if(s)return s}return null}function Gn(i,e){return i.some(t=>String(t.id)===e||Gn(t.children??[],e))}var Vm=new Set(["top-start","top","top-end","bottom-start","bottom","bottom-end"]),xc="top-end",Zn=2,Bm=.05,qm=8e3,Xn=class{#e;#t=[];#i=[];#s;constructor(e=5,t=()=>{}){if(!Number.isInteger(e)||e<1)throw new RangeError("Queue limit must be positive");if(typeof t!="function")throw new TypeError("Activation callback must be a function");this.#e=e,this.#s=t}enqueue(e){return this.#t.length<this.#e?(this.#t.push(e),this.#s(e),"active"):(this.#i.push(e),"pending")}remove(e){let t=this.#i.indexOf(e);if(t!==-1)return this.#i.splice(t,1),"pending";let s=this.#t.indexOf(e);if(s===-1)return null;if(this.#t.splice(s,1),this.#i.length>0){let n=this.#i.shift();this.#t.push(n),this.#s(n)}return"active"}isActive(e){return this.#t.includes(e)}clear(){let e={active:this.#t.slice(),pending:this.#i.slice()};return this.#t.length=0,this.#i.length=0,e}get activeCount(){return this.#t.length}get pendingCount(){return this.#i.length}},Re=class i extends k{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5,highlight:!1,stack:!1,expanded:!1};static#e=xc;static#t=!0;render(){let e=!this.el,t=this.el??u("div");return this._createdRoot=e,this._original=e?null:Jm(t),this._entries=new Set,this._floatingHost=null,this._placedIn=null,this._placement=null,this._overlay=null,this._unfollow=null,this._queue=new Xn(Gm(this.options.maxVisible),s=>{this._activate(s)}),this._shown=[],this._seq=0,this._stack=!!this.options.stack,this._hovered=!1,this._focusWithin=!1,this._pinned=!1,this._wasHeld=!1,this._stackReturn=null,this._pinnedAt=-1/0,this._pileFromEnd=null,this._reordering=!1,this._resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this._syncStack()):null,t.replaceChildren(),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),this._wasExpanded=this.isExpanded(),this._stack&&(t.setAttribute("data-stack",""),t.setAttribute("data-state",this._wasExpanded?"expanded":"collapsed")),this._listenStack(t),t}show(e,t={}){let s=Ym(t.action),n={kind:$m(t.kind??this.options.kind),timeout:Km(t.timeout??this.options.timeout,s!==null),closable:t.closable??!!this.options.closable,action:s,leading:Wm(t.leading),highlight:yc(t.highlight??this.options.highlight)},r=this._createEntry(e,n);return this._entries.add(r),this._queue.enqueue(r),{close:()=>this._close(r)}}static info(e,t={}){return this.show(e,{...t,kind:"info"})}static success(e,t={}){return this.show(e,{...t,kind:"success"})}static warning(e,t={}){return this.show(e,{...t,kind:"warning"})}static error(e,t={}){return this.show(e,{...t,kind:"error"})}static show(e,t={}){return i.#i(t.scope,t.placement).show(e,t)}static progress(e,t={}){return i.#i(t.scope,t.placement)._progress(e,t)}static setStack(e){i.#t=!!e;for(let t of Ue.entries())t.kind==="toast"&&t.owner instanceof i&&t.owner.setStack(i.#t);return i.#t}static getStack(){return i.#t}static setPlacement(e){return i.#e=bc(e),i.#e}static getPlacement(){return i.#e}static disposeRegion(e){if(e==null)return!1;let t=te(e);if(!t)return!1;let s=i.#s(he(t));for(let n of s)n._disposeFloating();return s.length>0}setStack(e){let t=!!e;if(t===this._stack)return this;this._stack=t;let s=this.el,n=this._wasExpanded;if(t)s.setAttribute("data-stack","");else{this._pinned=!1,this._hovered=!1,this._focusWithin=!1,this._wasExpanded=!1,this._pileFromEnd=null,s.removeAttribute("data-stack"),s.removeAttribute("data-state"),s.removeAttribute("data-overflow");for(let r of["--zx-message-stack-size","--zx-message-stack-hold"])s.style.removeProperty(r);for(let r of this._shown)Hm(r.node)}return this._order(),this._refreshStack(),!t&&n&&this.emit("collapse"),this}expand(){return this._stack?(this._pinned=!0,this._pinnedAt=wc(),this._refreshStack(),this):this}collapse(){return this._stack?(this._pinned=!1,this._hovered=!1,this._refreshStack(),this):this}isExpanded(){return this._stack&&!!(this.options.expanded||this._pinned||this._hovered||this._focusWithin)}destroy(){if(this._cleaned)return;this._cleaned=!0,this._resizeObserver?.disconnect(),this._resizeObserver=null,this._unfollow?.(),this._unfollow=null;let e=this._overlay;this._overlay=null,e?.release(),this._floatingHost=null,this._placedIn=null,this._placement=null;for(let t of this._entries)Jn(t),t.node.remove();this._queue.clear(),this._entries.clear(),this._shown.length=0,super.destroy(),!this._createdRoot&&this._original&&Xm(this.el,this._original)}_progress(e,t={}){let s={pct:0,text:String(e)},n=this._createEntry(s.text,{kind:"info",timeout:0,closable:!1,highlight:yc(t.highlight??this.options.highlight)},s);this._entries.add(n),this._queue.enqueue(n);let r=!1;return{update:(o,a)=>{r||n.closed||(s.pct=Zm(o),a!==void 0&&(s.text=String(a)),bs(n,s))},done:()=>{r||n.closed||(r=!0,s.pct=100,bs(n,s),n.timeout=600,n.remaining=600,this._queue.isActive(n)&&this._schedule(n))},fail:o=>{r||n.closed||(r=!0,o!==void 0&&(s.text=String(o)),n.kind="error",n.node.dataset.kind="error",n.node.setAttribute("role","alert"),n.iconHost.replaceChildren(x("error",{size:18})),bs(n,s),n.timeout=4e3,n.remaining=4e3,this._queue.isActive(n)&&this._schedule(n))}}}_createEntry(e,t,s=null){let n=u("span",{class:"zx-message__icon",ariaHidden:"true"},t.leading??x(t.kind,{size:18})),r=u("div",{class:"zx-message__content"});Ze(e)?r.append(e):r.append(document.createTextNode(String(e)));let o=u("div",{class:"zx-message__toast",role:t.kind==="error"?"alert":"status",dataset:{kind:t.kind,state:"queued"}},n,r),a={node:o,content:r,iconHost:n,kind:t.kind,timeout:t.timeout,remaining:t.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,hovered:!1,focused:!1,returnFocus:null,progressBar:null,progressFill:null,seq:0};if(t.leading&&(o.dataset.leading=""),t.highlight&&(o.dataset.highlight=t.highlight),s){o.dataset.progress="";let l=u("span",{class:"zx-message__progress-fill"}),c=u("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},l);r.append(c),a.progressBar=c,a.progressFill=l,bs(a,s)}if(t.action){let{label:l,kind:c,onclick:d}=t.action,h=ul({label:l,kind:c,size:"sm"});h.classList.add("zx-message__action"),o.append(h),this.listen(h,"click",p=>{if(!a.closed)try{d?.(p)}finally{this._close(a)}})}if(t.closable){let l=u("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:this._message("message.close","Close message"),title:this._message("message.closeTitle","Close")},x("x",{size:T.dismiss}));o.append(l),this.listen(l,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>{a.hovered=!0,this._pause(a)}),this.listen(o,"mouseleave",()=>{a.hovered=!1,this._resume(a)}),this.listen(o,"focusin",l=>{if(!a.focused){let c=l.relatedTarget;a.returnFocus=Ze(c)&&!o.contains(c)?c:null}a.focused=!0,this._pause(a)}),this.listen(o,"focusout",l=>{let c=l.relatedTarget;Ze(c)&&o.contains(c)||(a.focused=!1,this._resume(a))}),a}_activate(e){e.closed||(e.node.dataset.state="open",this._seq+=1,e.seq=this._seq,this._stack&&!this._fromEnd()?this.el.prepend(e.node):this.el.append(e.node),this._shown.push(e),this._resizeObserver?.observe(e.node),this._syncStack(),this._schedule(e))}_schedule(e){e.closed||e.remaining<=0||e.hovered||e.focused||this._held()||(e.startedAt=Date.now(),e.timer=setTimeout(()=>this._close(e),e.remaining))}_pause(e){e.closed||e.timer===null||(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(0,e.remaining-(Date.now()-e.startedAt)))}_resume(e){if(!(e.closed||e.timer!==null||e.hovered||e.focused||this._held())&&e.timeout!==0){if(e.remaining<=0){this._close(e);return}this._schedule(e)}}_close(e){if(e.closed)return;if(e.closed=!0,Jn(e),this._handOffFocus(e),!this._queue.isActive(e)){this._queue.remove(e),e.node.remove(),this._entries.delete(e),this._releaseIfEmpty();return}if(e.node.dataset.state="closing",this._syncStack(),!Qm()){this._finish(e);return}let t=s=>{s.target===e.node&&this._finish(e)};this.listen(e.node,"animationend",t,{once:!0}),e.exitTimer=setTimeout(()=>this._finish(e),260)}_finish(e){if(!this._entries.has(e))return;Jn(e),this._resizeObserver?.unobserve(e.node),e.node.remove(),this._entries.delete(e);let t=this._shown.indexOf(e);t!==-1&&this._shown.splice(t,1),this._queue.remove(e),this._shown.length===0&&(this._pinned=!1,this._hovered=!1);let s=this.el.ownerDocument?.activeElement;this._focusWithin&&!(s&&this.el.contains(s))&&(this._focusWithin=!1),this._refreshStack(),this._releaseIfEmpty()}_held(){return this._stack&&(this._pinned||this._hovered||this._focusWithin)}_fromEnd(){let e=this.el.ownerDocument?.defaultView;return!e||typeof e.getComputedStyle!="function"?!1:e.getComputedStyle(this.el).getPropertyValue("--zx-message-dir").trim()==="-1"}_order(e=this._fromEnd()){let t=this._shown.map(a=>a.node).filter(a=>a.parentNode===this.el);if(this._stack&&!e&&t.reverse(),Array.from(this.el.children).filter(a=>t.includes(a)).every((a,l)=>a===t[l]))return;let n=this.el.ownerDocument,r=n?.activeElement,o=r&&this.el.contains(r)?r:null;this._reordering=!0;try{for(let a of t)a.setAttribute("data-entered",""),this.el.append(a);o?.isConnected&&n?.activeElement!==o&&o.focus({preventScroll:!0})}finally{this._reordering=!1}}_handOffFocus(e){let t=e.node.ownerDocument?.activeElement;if(!this._stack||!t||!e.node.contains(t)){vc(e);return}let s=Array.from(this.el.children),n=this._shown.filter(p=>!p.closed&&p.node.parentNode===this.el).map(p=>p.node),r=s.indexOf(e.node),o=n.filter(p=>s.indexOf(p)>r).sort((p,f)=>s.indexOf(p)-s.indexOf(f))[0],a=n.filter(p=>s.indexOf(p)<r).sort((p,f)=>s.indexOf(f)-s.indexOf(p))[0],l=o??a,c=t.classList.contains("zx-message__close")?".zx-message__close":".zx-message__action",d=l?.querySelector(c)??l?.querySelector("button");if(d){d.focus({preventScroll:!0});return}let h=this._stackReturn;if(h?.isConnected&&typeof h.focus=="function"){this._stackReturn=null,h.focus({preventScroll:!0});return}vc(e)}_refreshStack(){let e=this._held();if(e!==this._wasHeld){this._wasHeld=e;for(let s of this._shown.slice())e?this._pause(s):this._resume(s)}if(this._syncStack(),!this._stack)return;let t=this.isExpanded();t!==this._wasExpanded&&(this._wasExpanded=t,this.emit(t?"expand":"collapse"))}_syncStack(){if(!this._stack||this._cleaned)return;let e=this.el,t=this._fromEnd();t!==this._pileFromEnd&&(this._pileFromEnd=t,this._order(t));let s=this.isExpanded();e.setAttribute("data-state",s?"expanded":"collapsed");let n=this._shown.filter(a=>!a.closed).reverse(),r=Sc(n.map(a=>a.node.offsetHeight),s);this._syncOverflow(s,r.size,t);let o=s?"--zx-message-gap":"--zx-message-peek";if(n.forEach((a,l)=>{let c=r.items[l],d=a.node.style;d.setProperty("--zx-message-y",Qn(c.y,o)),d.setProperty("--zx-message-scale",String(ys(c.scale))),d.setProperty("--zx-message-z",String(a.seq)),c.clip?d.setProperty("--zx-message-clip",`max(0px, ${Qn(c.clip,o)})`):d.removeProperty("--zx-message-clip"),a.node.setAttribute("data-depth",c.hidden?"hidden":String(c.depth))}),e.style.setProperty("--zx-message-stack-size",Qn(r.size,o)),s&&this._hovered){let a=Math.max(parseFloat(e.style.getPropertyValue("--zx-message-stack-hold"))||0,e.getBoundingClientRect().height);e.style.setProperty("--zx-message-stack-hold",`${ys(a)}px`)}else e.style.removeProperty("--zx-message-stack-hold")}_syncOverflow(e,t,s){let n=this.el,r=n.ownerDocument?.defaultView,o=!1;if(e&&this._floatingHost&&r&&typeof r.getComputedStyle=="function"){let a=parseFloat(r.getComputedStyle(n).rowGap)||0,l=n.getBoundingClientRect(),c=s?r.innerHeight-l.bottom:l.top;o=t.px+t.steps*a>r.innerHeight-2*Math.max(0,c)+.5}o!==n.hasAttribute("data-overflow")&&(n.toggleAttribute("data-overflow",o),o&&s&&(n.scrollTop=n.scrollHeight))}_listenStack(e){this.listen(e,"pointerenter",s=>{!this._stack||this._shown.length===0||s.pointerType!=="touch"&&(this._hovered=!0,this._refreshStack())}),this.listen(e,"pointerleave",s=>{!this._stack||s.pointerType==="touch"||(this._hovered=!1,this._refreshStack())}),this.listen(e,"pointerdown",s=>{!this._stack||this._pinned||this._shown.length===0||s.target?.closest?.("button, a[href], input, select, textarea, [tabindex]")||(this._pinned=!0,this._pinnedAt=wc(),this._refreshStack())});let t=e.ownerDocument;t&&this.listen(t,"click",s=>{if(!this._stack||e.contains(s.target))return;let n=s.timeStamp;setTimeout(()=>{this._cleaned||!this._pinned||this._pinnedAt>=n||(this._pinned=!1,this._refreshStack())},0)},{capture:!0}),this.listen(e,"focusin",s=>{if(!(!this._stack||this._reordering)){if(!this._focusWithin){let n=s.relatedTarget;this._stackReturn=Ze(n)&&!e.contains(n)?n:null}this._focusWithin=!0,this._refreshStack()}}),this.listen(e,"focusout",s=>{if(!this._stack||this._reordering)return;let n=s.relatedTarget;Ze(n)&&e.contains(n)||(this._focusWithin=!1,this._refreshStack())}),this.listen(e,"keydown",s=>{let n=s;if(n.key!=="Escape"||n.defaultPrevented||n.isComposing||!this._stack||this.options.expanded||!this.isExpanded())return;n.preventDefault(),this._pinned=!1,this._hovered=!1;let r=t?.activeElement;if(r&&e.contains(r)){let o=this._stackReturn;this._stackReturn=null,o?.isConnected&&typeof o.focus=="function"?o.focus({preventScroll:!0}):r.blur?.()}this._refreshStack()})}_releaseIfEmpty(){!this._floatingHost||this._entries.size>0||i.#n(this)}_rehome(){let e=this._floatingHost;if(!e)return;let t=Ue.topmostModal()??e;if(this.el.parentElement===t&&this._placedIn===t)return;t.append(this.el),this._placedIn=t;let s=this.el;typeof s.showPopover=="function"&&!s.matches(":popover-open")&&s.showPopover()}_disposeFloating(){let e=this.el;this.destroy(),e.remove()}_message(e,t){let s=this.msg(e);return s===e?t:s}static#i(e,t){let s=he(e??null);s.isConnected||(s=he(null));let n=bc(t,i.#e),r=i.#s(s).find(l=>l._placement===n)??null;if(r&&r.el.isConnected&&r.el.parentElement===r._placedIn)return r._rehome(),r;r?._disposeFloating();let o=u("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite",dataset:{placement:n}}),a=new i(o,{stack:i.#t});return a._floatingHost=s,a._placement=n,a._overlay=Ue.push({kind:"toast",root:o,owner:a}),a._unfollow=Ue.subscribe(()=>a._rehome()),a._rehome(),a}static#s(e){let t=[];for(let s of Ue.entries())s.kind==="toast"&&s.owner instanceof i&&s.owner._floatingHost===e&&t.push(s.owner);return t}static#n(e){e._disposeFloating()}};function $m(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function bc(i,e=xc){return Vm.has(i)?i:e}function yc(i){return i===!0||i==="border"?"border":i==="animated"?"animated":null}function Sc(i,e){let t=Array.from(i??[],a=>{let l=Number(a);return Number.isFinite(l)&&l>0?l:0}),s=t[0]??0,n=0,r=t.map((a,l)=>{if(e){let h={depth:l,y:{px:n,steps:l},scale:1,clip:null,hidden:!1};return n+=a,h}let c=Math.min(l,Zn),d=1-c*Bm;return{depth:c,y:{px:s-a,steps:c},scale:d,clip:c===0?null:{px:a,steps:-1/d},hidden:l>Zn}}),o={px:0,steps:0};return t.length>0&&(o=e?{px:n,steps:t.length-1}:{px:s,steps:Math.min(t.length-1,Zn)}),{items:r,size:o}}function Qn(i,e){return`calc(${ys(i.px)}px + ${ys(i.steps)} * var(${e}))`}function wc(){return typeof performance=="object"&&typeof performance.now=="function"?performance.now():Date.now()}function ys(i){return Math.round(i*100)/100}function Hm(i){for(let e of["--zx-message-y","--zx-message-scale","--zx-message-z","--zx-message-clip"])i.style.removeProperty(e);i.removeAttribute("data-depth")}function Um(i){let e=Number(i);return Number.isFinite(e)?Math.max(0,e):4e3}function Km(i,e=!1){let t=Um(i);return e&&t>0?Math.max(t,qm):t}function Ym(i){if(!i||typeof i!="object")return null;let e=i,t=e.label==null?"":String(e.label).trim();if(!t)return null;let s=["primary","danger","ghost"].includes(String(e.kind))?e.kind:"default";return{label:t,kind:s,onclick:typeof e.onclick=="function"?e.onclick:null}}function Wm(i){if(Ze(i))return i;if(i&&typeof i=="object"&&typeof i.toElement=="function"){let e=i.toElement();return Ze(e)?e:null}return null}function vc(i){let t=i.node.getRootNode?.()?.activeElement??globalThis.document?.activeElement;if(!t||!i.node.contains(t))return;let s=i.returnFocus;i.returnFocus=null,s?.isConnected&&typeof s.focus=="function"&&s.focus({preventScroll:!0})}function Gm(i){let e=Number(i);return Number.isInteger(e)&&e>0?e:5}function Ze(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Zm(i){let e=Number(i);return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function bs(i,e){i.content.firstChild.textContent=e.text,i.progressBar?.setAttribute("aria-valuenow",String(e.pct)),i.progressBar?.setAttribute("aria-label",e.text),i.progressFill&&(i.progressFill.style.inlineSize=`${e.pct}%`)}function Jn(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function Qm(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Jm(i){return{attributes:Array.from(i.attributes,e=>[e.name,e.value]),children:Array.from(i.childNodes)}}function Xm(i,e){for(let t of Array.from(i.attributes))i.removeAttribute(t.name);for(let[t,s]of e.attributes)i.setAttribute(t,s);i.replaceChildren(...e.children)}var vs=Object.freeze(["agenda","day","week","month","year"]),eg=864e5;function tr(i,e,t={}){let s=Qe(e,"Calendar date"),n=Mc(t.weekStart??1),r,o;if(i==="agenda")r=W(s),o=R(r,Ss(t.agendaDays??14,"agendaDays"));else if(i==="day")r=W(s),o=R(r,1);else if(i==="week")r=ws(s,n),o=R(r,7);else if(i==="month"){let a=new Date(s.getFullYear(),s.getMonth(),1),l=new Date(s.getFullYear(),s.getMonth()+1,0);r=ws(a,n),o=R(ws(l,n),7)}else if(i==="year")r=new Date(s.getFullYear(),0,1),o=new Date(s.getFullYear()+1,0,1);else throw new RangeError(`Unknown calendar view: ${i}`);return{start:r,end:o}}function ir(i,e,t,s={}){let n=Qe(e,"Calendar date"),r=Ee(t,"direction");if(i==="day")n.setDate(n.getDate()+r);else if(i==="agenda")n.setDate(n.getDate()+r*Ss(s.agendaDays??14,"agendaDays"));else if(i==="week")n.setDate(n.getDate()+r*7);else{if(i==="month")return er(n,r);if(i==="year")return er(n,r*12);throw new RangeError(`Unknown calendar view: ${i}`)}return n}function er(i,e){let t=Qe(i,"Calendar date"),s=t.getDate();return t.setDate(1),t.setMonth(t.getMonth()+Ee(e,"month amount")),t.setDate(Math.min(s,tg(t.getFullYear(),t.getMonth()))),t}function tg(i,e){return new Date(i,e+1,0).getDate()}function wt(i,e={}){if(!Array.isArray(i))throw new TypeError("Calendar events must be an array");let t={id:e.eventId??"id",title:e.eventTitle??"title",start:e.eventStart??"start",end:e.eventEnd??"end",allDay:e.eventAllDay??"allDay",color:e.eventColor??"color",location:e.eventLocation??"location",editable:e.eventEditable??"editable",durationEditable:e.eventDurationEditable??"durationEditable"},s=e.dateUnit==="seconds"?"seconds":"milliseconds",n=new Set;return i.map((r,o)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError(`Calendar event at index ${o} must be an object`);let a=ze(r,t.id);if(a==null||a==="")throw new TypeError(`Calendar event at index ${o} requires an id`);let l=String(a);if(n.has(l))throw new RangeError(`Duplicate Calendar event id: ${l}`);n.add(l);let c=kc(ze(r,t.start),s,`event ${l} start`),d=ze(r,t.end),h=d==null||d===""?new Date(c.getTime()):kc(d,s,`event ${l} end`);if(h<c)throw new RangeError(`Calendar event ${l} ends before it starts`);let p=String(ze(r,t.title)??"").trim()||(e.untitledTitle??V("calendar.untitled")),f=String(ze(r,t.location)??"").trim(),m=Cc(ze(r,t.editable)),g=Cc(ze(r,t.durationEditable));return{id:a,title:p,start:c,end:h,allDay:!!ze(r,t.allDay),color:sg(ze(r,t.color)),location:f,editable:m,durationEditable:g,data:r}})}function G(i){return{...i,start:new Date(i.start.getTime()),end:new Date(i.end.getTime())}}function sr(i,e,t={}){let s=Tc(t.minMinutes??0,"minMinutes"),n=Tc(t.maxMinutes??1440,"maxMinutes",!0),r=Ss(t.minimumMinutes??30,"minimumMinutes");if(n<=s)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=W(e),a=zc(o,s),l=zc(o,n),c=i.filter(f=>!be(f)&&nr(f,a,l)).map(f=>{let m=new Date(Math.max(f.start.getTime(),a.getTime())),g=new Date(Math.min(f.end.getTime(),l.getTime()));return g<=m&&(g=new Date(Math.min(l.getTime(),m.getTime()+r*6e4))),{event:f,start:m,end:g,startMinutes:Ec(o,m),endMinutes:Ec(o,g),column:0,columns:1}}).sort((f,m)=>f.start-m.start||m.end-f.end||String(f.event.id).localeCompare(String(m.event.id))),d=[],h=-1/0,p=()=>{if(!d.length)return;let f=[],m=1;for(let g of d){let _=f.findIndex(y=>y<=g.start.getTime());_===-1&&(_=f.length),f[_]=g.end.getTime(),g.column=_,m=Math.max(m,_+1)}for(let g of d)g.columns=m;d=[],h=-1/0};for(let f of c)d.length&&f.start.getTime()>=h&&p(),d.push(f),h=Math.max(h,f.end.getTime());return p(),c}function xs(i,e,t){let s=W(e),n=R(s,Ss(t,"days")),r=i.filter(a=>be(a)&&nr(a,s,n)).map(a=>{let l=W(a.start),c=ig(a);return{event:a,start:Math.max(0,se(s,l)),end:Math.min(t,se(s,c)),lane:0}}).filter(a=>a.end>a.start).sort((a,l)=>a.start-l.start||l.end-a.end||String(a.event.id).localeCompare(String(l.event.id))),o=[];for(let a of r){let l=o.findIndex(c=>c<=a.start);l===-1&&(l=o.length),a.lane=l,o[l]=a.end}return r}function Zt(i,e={}){let t=Ee(e.days??0,"days"),s=Ee(e.minutes??0,"minutes"),n=Ee(e.endDays??t,"endDays"),r=Ee(e.endMinutes??s,"endMinutes"),o=G(i);if(o.start=Ac(o.start,t,s),o.end=Ac(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function W(i){let e=Qe(i,"Calendar date");return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function R(i,e){let t=Qe(i,"Calendar date"),s=new Date(t.getTime());return s.setDate(s.getDate()+Ee(e,"day amount")),s}function ws(i,e=1){let t=W(i),s=Mc(e);return R(t,-((t.getDay()-s+7)%7))}function se(i,e){let t=W(i),s=W(e),n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate());return Math.round((r-n)/eg)}function K(i){let e=Qe(i,"Calendar date"),t=s=>String(s).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function be(i){if(i.allDay)return!0;if(i.end<=i.start)return!1;let e=new Date(i.end.getTime()-1);return K(i.start)!==K(e)}function Qt(i,e,t){return nr(i,e,t)}function Ac(i,e,t){let s=new Date(i.getTime());return s.setDate(s.getDate()+e),s.setMinutes(s.getMinutes()+t),s}function ig(i){if(i.end<=i.start)return R(W(i.start),1);let e=W(i.end);return i.end.getTime()===e.getTime()?e:R(e,1)}function nr(i,e,t){let s=i.end>i.start?i.end:new Date(i.start.getTime()+1);return i.start<t&&s>e}function ze(i,e){return typeof e=="function"?e(i):i[e]}function kc(i,e,t){let s;if(i instanceof Date)s=new Date(i.getTime());else if(typeof i=="number"||typeof i=="string"&&/^-?\d+(?:\.\d+)?$/.test(i.trim())){let n=Number(i);s=new Date(n*(e==="seconds"?1e3:1))}else s=new Date(i);return Qe(s,t)}function Cc(i){return i==null?null:!!i}function sg(i){let e=String(i??"").trim();return!e||e.length>100||/[;{}]|url\s*\(|image\s*\(/i.test(e)?null:/^#[\da-f]{3,8}$/i.test(e)||/^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\([^{};]+\)$/i.test(e)||/^var\(--[\w-]+\)$/i.test(e)||/^[a-z]+$/i.test(e)?e:null}function zc(i,e){let t=W(i);return t.setMinutes(e),t}function Ec(i,e){return se(i,e)*1440+e.getHours()*60+e.getMinutes()+e.getSeconds()/60+e.getMilliseconds()/6e4}function Qe(i,e){if(!(i instanceof Date)||Number.isNaN(i.getTime()))throw new TypeError(`${e} must be a valid Date`);return new Date(i.getTime())}function Mc(i){let e=Number(i);if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("weekStart must be from 0 through 6");return e}function Ee(i,e){let t=Number(i);if(!Number.isInteger(t))throw new TypeError(`${e} must be an integer`);return t}function Ss(i,e){let t=Ee(i,e);if(t<=0)throw new RangeError(`${e} must be greater than zero`);return t}function Tc(i,e,t=!1){let s=Ee(i,e),n=t?1440:1439;if(s<0||s>n)throw new RangeError(`${e} must be from 0 through ${n}`);return s}var As=".zx-calendar__month-day, .zx-calendar__year-day",Xt=class extends k{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:Array.from(vs),weekStart:1,weekNumbers:!0,workweek:!1,agendaDays:14,slotDuration:30,slotMinTime:0,slotMaxTime:1440,scrollTime:480,eventLimit:3,selectable:!1,editable:!1,eventStartEditable:null,eventDurationEditable:null,optimistic:!0,nowIndicator:!0,now:null,disabled:!1,eventId:"id",eventTitle:"title",eventStart:"start",eventEnd:"end",eventAllDay:"allDay",eventColor:"color",eventLocation:"location",eventEditable:"editable",dateUnit:"milliseconds"};render(){let e=!this.el,t=this.el??u("section");this.el||(this.el=t),this._createdRoot=e,this._snapshot=this._createdRoot?null:$(t),this._views=ng(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=Ic(this.options.date,this.options.dateUnit,this._now()),this._events=wt(this.options.events,this._normalizeOptions()),this._loading=!1,this._destroyed=!1,this._pointer=null,this._keyboardEdit=null,this._mutationVersions=new Map,this._mutationSerial=0,this._suppressClickId=null,this._suppressDateClick=!1,this._focusedSlot=null,this._focusedDate=null,this._selection=null,this._nowTimer=null;let s=u("div",{class:"zx-calendar__navigation"},this._toolbarButton("previous",this.msg("calendar.previous"),"chevron-left"),this._toolbarButton("today",this.msg("calendar.today")),this._toolbarButton("next",this.msg("calendar.next"),"chevron-right")),n=u("h2",{ref:"heading",class:"zx-calendar__heading",ariaLive:"polite"}),r=u("div",{ref:"views",class:"zx-calendar__views",role:"group",ariaLabel:this._message("calendar.viewSwitch","Calendar view")},this._views.map(h=>u("button",{type:"button",class:"zx-calendar__view-button",dataset:{calendarAction:"view",view:h},disabled:this.options.disabled},this.msg(`calendar.${h}`)))),o=u("div",{class:"zx-calendar__commands"},r,u("button",{type:"button",class:"zx-calendar__new",dataset:{calendarAction:"new"},disabled:this.options.disabled},x("plus"),u("span",{},this.msg("calendar.new")))),a=u("header",{class:"zx-calendar__toolbar"},s,n,o),l=u("div",{ref:"body",class:"zx-calendar__body"}),c=u("div",{ref:"loading",class:"zx-calendar__loading",role:"status",hidden:!0},this.msg("calendar.loading")),d=u("div",{ref:"status",class:"zx-calendar__status",role:"status",ariaLive:"polite",ariaAtomic:"true"});return t.replaceChildren(a,l,c,d),t.setAttribute("aria-label",this.msg("calendar.label")),t.dataset.view=this._view,t.dataset.state="ready",this.listen(t,"click",h=>this._onClick(h)),this.listen(t,"dblclick",h=>this._onDoubleClick(h)),this.listen(t,"keydown",h=>this._onKeydown(h)),this.listen(t,"pointerdown",h=>this._onPointerDown(h)),this.listen(t,"pointermove",h=>this._onPointerMove(h)),this.listen(t,"pointerup",h=>this._onPointerUp(h)),this.listen(t,"pointercancel",h=>this._cancelPointer(h)),this.listen(t,"dragstart",h=>h.preventDefault()),this._renderView({emitDates:!0,scroll:!0}),this.options.nowIndicator&&(this._nowTimer=setInterval(()=>this._refreshNowIndicator(),6e4)),t}getEvents(){return this._events.map(G)}setEvents(e,t={}){let s=wt(e,this._normalizeOptions());return this._events=s,this._mutationVersions.clear(),this._renderView({preserveFocus:!0}),t.silent||this.emit("eventschange",{events:this.getEvents()}),this}addEvent(e,t={}){if(typeof e=="string")return super.addEvent(e,t);let[s]=wt([e],this._normalizeOptions());if(this._eventById(s.id))throw new RangeError(`Duplicate Calendar event id: ${s.id}`);return this._events=[...this._events,s],this._renderView({preserveFocus:!0}),t.silent||this.emit("eventschange",{events:this.getEvents()}),this}updateEvent(e,t,s={}){let n=this._eventIndex(e);if(n<0)throw new RangeError(`Unknown Calendar event id: ${e}`);let r=this._events[n],o={id:r.id,title:t.title??r.title,start:t.start??r.start,end:t.end??r.end,allDay:t.allDay??r.allDay,color:Object.prototype.hasOwnProperty.call(t,"color")?t.color:r.color,location:t.location??r.location,editable:Object.prototype.hasOwnProperty.call(t,"editable")?t.editable:r.editable,durationEditable:Object.prototype.hasOwnProperty.call(t,"durationEditable")?t.durationEditable:r.durationEditable,data:t.data??r.data},[a]=wt([o],{dateUnit:this.options.dateUnit,untitledTitle:this.msg("calendar.untitled")});return a.data=o.data,this._events=this._events.map((l,c)=>c===n?a:l),this._mutationVersions.delete(String(e)),this._renderView({preserveFocus:!0}),s.silent||this.emit("eventschange",{events:this.getEvents()}),this}removeEvent(e,t={}){let s=String(e),n=this._events.filter(r=>String(r.id)!==s);return n.length===this._events.length?this:(this._events=n,this._mutationVersions.delete(s),this._renderView({preserveFocus:!0}),t.silent||this.emit("eventschange",{events:this.getEvents()}),this)}getDate(){return new Date(this._date.getTime())}setDate(e,t={}){return this._date=Ic(e,this.options.dateUnit,this._now()),this._renderView({emitDates:!t.silent,preserveFocus:!0,scroll:!0}),this}getView(){return this._view}setView(e,t={}){if(!this._views.includes(e))throw new RangeError(`Calendar view is not enabled: ${e}`);if(e===this._view)return this;let s=this._view;return this._view=e,this.el.dataset.view=e,this._renderView({emitDates:!0,preserveFocus:!0,scroll:!0}),t.silent||this.emit("viewchange",{view:e,oldView:s}),this}prev(){return this._page(-1)}next(){return this._page(1)}today(){return this.setDate(this._now())}setLoading(e=!0){return this._loading=!!e,this.el.dataset.state=this._loading?"loading":"ready",this.el.setAttribute("aria-busy",String(this._loading)),this.refs.loading.hidden=!this._loading,this}focusEvent(e){return this.el.querySelector(`[data-event-action][data-event-id="${or(String(e))}"]`)?.focus(),this}destroy(){this._destroyed||(this._destroyed=!0,this._nowTimer&&clearInterval(this._nowTimer),this._nowTimer=null,super.destroy(),this._createdRoot||H(this.el,this._snapshot))}_toolbarButton(e,t,s=null){return u("button",{type:"button",class:"zx-calendar__toolbar-button",dataset:{calendarAction:e},ariaLabel:s?t:null,disabled:this.options.disabled},s?x(s):t)}_normalizeOptions(){return{eventId:this.options.eventId,eventTitle:this.options.eventTitle,eventStart:this.options.eventStart,eventEnd:this.options.eventEnd,eventAllDay:this.options.eventAllDay,eventColor:this.options.eventColor,eventLocation:this.options.eventLocation,eventEditable:this.options.eventEditable,eventDurationEditable:cg(this.options.eventDurationEditable)?this.options.eventDurationEditable:void 0,untitledTitle:this.msg("calendar.untitled"),dateUnit:this.options.dateUnit}}_renderView(e={}){if(!this.refs?.body||this._destroyed)return;let t=e.preserveFocus?this._focusIdentity():null,s=tr(this._view,this._date,{weekStart:this.options.weekStart,agendaDays:this.options.agendaDays});this._range=s,this.refs.heading.textContent=this._rangeTitle(s);for(let r of this.refs.views.querySelectorAll("[data-view]"))r.setAttribute("aria-pressed",String(r.dataset.view===this._view));let n=this._view==="agenda"?this._renderAgenda(s):this._view==="day"||this._view==="week"?this._renderTimeGrid(s):this._view==="month"?this._renderMonth(s):this._renderYear(s);this.refs.body.replaceChildren(n),e.scroll&&this._scrollTimeGrid(),t&&this._restoreFocus(t),e.emitDates&&this.emit("dateschange",{view:this._view,start:new Date(s.start.getTime()),end:new Date(s.end.getTime())})}_renderAgenda(e){let t=u("div",{class:"zx-calendar__agenda",role:"grid",ariaLabel:this._rangeTitle(e)}),s=se(e.start,e.end);for(let n=0;n<s;n+=1){let r=R(e.start,n),o=R(r,1),a=this._events.filter(d=>Qt(d,r,o)?d.start>=r||n===0:!1).sort(ag),l=u("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:K(r)}},u("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:K(r),dateCell:"true"},ariaCurrent:Xe(r,this._now())?"date":null,disabled:this.options.disabled},this._format(r,{weekday:"long",day:"numeric",month:"long"}))),c=u("div",{class:"zx-calendar__agenda-events",role:"gridcell"});if(!a.length)c.append(u("p",{class:"zx-calendar__agenda-empty"},this.msg("calendar.noEvents")));else for(let d of a)c.append(this._eventElement(d,{variant:"agenda",day:r}));l.append(c),t.append(l)}return t}_renderTimeGrid(e){let t=Array.from({length:se(e.start,e.end)},(y,b)=>R(e.start,b)),s=this._view==="week"&&this.options.workweek?t.filter(y=>y.getDay()>0&&y.getDay()<6):t,n=Te(this.options.slotMinTime,0),r=Te(this.options.slotMaxTime,1440,!0),o=fe(this.options.slotDuration);if(r<=n)throw new RangeError("slotMaxTime must exceed slotMinTime");let a=Math.ceil((r-n)/o),l=u("div",{class:"zx-calendar__time-surface",style:{"--zx-calendar-day-count":String(s.length)}}),c=u("div",{class:"zx-calendar__time-header"},u("span",{class:"zx-calendar__time-corner",ariaHidden:"true"}),u("div",{class:"zx-calendar__day-headings",role:"row"},s.map(y=>u("button",{type:"button",class:"zx-calendar__day-heading",role:"columnheader",dataset:{calendarAction:"date",date:K(y),dateCell:"true"},ariaCurrent:Xe(y,this._now())?"date":null,disabled:this.options.disabled},u("span",{class:"zx-calendar__day-weekday"},this._format(y,{weekday:"short"})),u("span",{class:"zx-calendar__day-number"},this._format(y,{day:"numeric",month:"short"})))))),d=this._renderAllDayRail(s),h=u("div",{ref:"timeScroller",class:"zx-calendar__time-scroller"}),p=u("div",{class:"zx-calendar__time-axis",ariaHidden:"true"}),f=u("div",{class:"zx-calendar__time-grid",role:"grid",ariaLabel:this._rangeTitle(e),ariaRowcount:String(a),ariaColcount:String(s.length),style:{"--zx-calendar-slot-count":String(a)}}),m=u("div",{ref:"slots",class:"zx-calendar__slots"}),g=!0;for(let y=0;y<a;y+=1){let b=n+y*o;p.append(u("span",{class:"zx-calendar__time-label"},b%60===0?rr(b,this._locale()):""));for(let w=0;w<s.length;w+=1){let v=og(s[w],b),A=String(v.getTime()),S=g&&(!this._focusedSlot||this._focusedSlot===A);S&&(g=!1),m.append(u("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:S?0:-1,dataset:{calendarAction:"date",slot:A,dateTime:A,dayIndex:String(w),rowIndex:String(y),major:b%60===0?"true":null},ariaLabel:this._dateTimeLabel(v),disabled:this.options.disabled}))}}g&&m.firstElementChild&&(m.firstElementChild.tabIndex=0);let _=u("div",{class:"zx-calendar__timed-events",ariaHidden:"false"});return s.forEach((y,b)=>{let w=sr(this._events,y,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let v of w){let A=(v.startMinutes-n)/(r-n)*100,S=Math.max(o/(r-n)*100,(v.endMinutes-v.startMinutes)/(r-n)*100),M=100/s.length,L=M/v.columns,J=b*M+v.column*L,ue=this._eventElement(v.event,{variant:"timed",day:y,resizable:!0});ue.style.insetInlineStart=`${J}%`,ue.style.inlineSize=`${L}%`,ue.style.insetBlockStart=`${A}%`,ue.style.blockSize=`${S}%`,_.append(ue)}}),f.append(m,_,this._nowLine(s,n,r)),h.append(p,f),l.append(c,d,h),l}_renderAllDayRail(e){let t=u("div",{class:"zx-calendar__all-day"},u("span",{class:"zx-calendar__all-day-label"},this.msg("calendar.allDay"))),s=u("div",{class:"zx-calendar__all-day-grid",role:"row",style:{"--zx-calendar-day-count":String(e.length)}});for(let r of e)s.append(u("span",{class:"zx-calendar__all-day-cell",dataset:{date:K(r)},ariaHidden:"true"}));let n=xs(this._events,e[0],e.length);for(let r of n){let o=this._eventElement(r.event,{variant:"span",day:e[r.start]});o.style.gridColumn=`${r.start+1} / ${r.end+1}`,o.style.gridRow=String(r.lane+1),s.append(o)}return t.append(s),t}_renderMonth(e){let t=u("div",{class:"zx-calendar__month"}),s=u("div",{class:"zx-calendar__month-weekdays",role:"row"});this.options.weekNumbers&&s.append(u("span",{class:"zx-calendar__month-week-gutter",ariaHidden:"true"}));for(let r=0;r<7;r+=1){let o=R(e.start,r);s.append(u("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}t.append(s);let n=se(e.start,e.end)/7;for(let r=0;r<n;r+=1){let o=R(e.start,r*7),a=xs(this._events.map(g=>({...g,allDay:!0})),o,7),l=rg(this.options.eventLimit),c=a.filter(g=>g.lane<l),d=a.filter(g=>g.lane>=l),h=u("div",{class:"zx-calendar__month-week",role:"row",dataset:{weekStart:K(o)}});this.options.weekNumbers&&h.append(u("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:K(o)},ariaLabel:this.msg("calendar.weekNumber",Oc(o)),disabled:this.options.disabled},String(Oc(o))));let p=u("div",{class:"zx-calendar__month-days"});for(let g=0;g<7;g+=1){let _=R(o,g),y=this._events.filter(b=>Qt(b,_,R(_,1))).length;p.append(u("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",tabindex:-1,dataset:{calendarAction:"date",date:K(_),dateCell:"true",otherMonth:_.getMonth()===this._date.getMonth()?null:"true",eventCount:String(y)},ariaCurrent:Xe(_,this._now())?"date":null,ariaLabel:this._dayCountLabel(_,y),disabled:this.options.disabled},this._format(_,{day:"numeric"})))}let f=u("div",{class:"zx-calendar__month-events"});for(let g of c){let _=this._eventElement(g.event,{variant:"month",day:R(o,g.start)});_.style.gridColumn=`${g.start+1} / ${g.end+1}`,_.style.gridRow=String(g.lane+1),f.append(_)}let m=Array.from({length:7},(g,_)=>d.filter(y=>y.start<=_&&y.end>_).length);for(let g=0;g<m.length;g+=1){let _=m[g];if(!_)continue;let y=R(o,g);f.append(u("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:K(y),count:String(_)},style:{gridColumn:String(g+1),gridRow:String(l+1)},disabled:this.options.disabled},this.msg("calendar.more",_)))}h.append(p,f),t.append(h)}return t.setAttribute("role","grid"),t.setAttribute("aria-label",this._rangeTitle(e)),this._rovingDates(t),t}_renderYear(e){let t=e.start.getFullYear(),s=u("div",{class:"zx-calendar__year",ariaLabel:String(t)});for(let n=0;n<12;n+=1){let r=new Date(t,n,1),o=(r.getDay()-this.options.weekStart+7)%7,a=R(r,-o),l=u("h3",{class:"zx-calendar__year-heading",id:z("zx-calendar-month")},this._format(r,{month:"long"})),c=u("div",{class:"zx-calendar__year-row",role:"row"});for(let h=0;h<7;h+=1){let p=R(a,h);c.append(u("span",{class:"zx-calendar__year-weekday",role:"columnheader"},this._format(p,{weekday:"narrow"})))}let d=u("div",{class:"zx-calendar__year-grid",role:"grid",ariaLabelledby:l.id},c);for(let h=0;h<6;h+=1){let p=u("div",{class:"zx-calendar__year-row",role:"row"}),f=!1;for(let m=0;m<7;m+=1){let g=R(a,h*7+m);if(g.getMonth()!==n){p.append(u("span",{class:"zx-calendar__year-blank",role:"gridcell",ariaHidden:"true"}));continue}f=!0;let _=this._events.filter(y=>Qt(y,g,R(g,1))).length;p.append(u("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",tabindex:-1,dataset:{calendarAction:"date",date:K(g),dateCell:"true",activity:String(Math.min(3,_))},ariaCurrent:Xe(g,this._now())?"date":null,ariaLabel:this._dayCountLabel(g,_),disabled:this.options.disabled},String(g.getDate())))}f||p.setAttribute("aria-hidden","true"),d.append(p)}s.append(u("div",{class:"zx-calendar__year-month"},l,d))}return this._rovingDates(s),s}_rovingDates(e){let t=[...e.querySelectorAll(As)];if(!t.length)return;let s=r=>r?t.find(o=>o.dataset.date===r):void 0,n=s(this._focusedDate)??s(K(this._date))??s(K(this._now()))??t.find(r=>!r.dataset.otherMonth)??t[0];for(let r of t)r.tabIndex=r===n?0:-1}_moveDateStop(e){if(e.matches(As)){for(let t of this.el.querySelectorAll(`:is(${As})[tabindex="0"]`))t.tabIndex=-1;e.tabIndex=0,this._focusedDate=e.dataset.date??null}}_eventElement(e,t){let s=String(e.id),n=u("div",{class:"zx-calendar__event",dataset:{eventId:s,variant:t.variant,allDay:e.allDay?"true":null,draggable:this._canMove(e)?"true":null},style:e.color?{"--zx-calendar-event-color":e.color}:null}),r=u("button",{type:"button",class:"zx-calendar__event-action",dataset:{eventAction:"activate",eventId:s},ariaLabel:this._eventLabel(e),disabled:this.options.disabled}),o=typeof this.options.renderEvent=="function"?this.options.renderEvent(G(e)):null;if(o instanceof Node)r.append(o);else if(typeof o=="string")r.append(document.createTextNode(o));else{let a=u("span",{class:"zx-calendar__event-time"},this._eventTime(e,t.day)),l=u("span",{class:"zx-calendar__event-title"},e.title);r.append(a,l),e.location&&r.append(u("span",{class:"zx-calendar__event-location"},e.location))}return n.append(r),t.resizable&&this._canResize(e)&&n.append(u("button",{type:"button",class:"zx-calendar__event-resize",dataset:{eventAction:"resize",eventId:s},ariaLabel:this.msg("calendar.resize",e.title),disabled:this.options.disabled},u("span",{ariaHidden:"true"}))),n}_nowLine(e,t,s){let n=this._now(),r=e.findIndex(l=>Xe(l,n)),o=n.getHours()*60+n.getMinutes(),a=this.options.nowIndicator&&r>=0&&o>=t&&o<=s;return u("div",{ref:"nowLine",class:"zx-calendar__now",hidden:!a,ariaHidden:"true",style:a?{insetBlockStart:`${(o-t)/(s-t)*100}%`,"--zx-calendar-now-day":String(r)}:null},u("span",{class:"zx-calendar__now-time"},rr(o,this._locale())))}_onClick(e){let t=e.target?.closest?.("button");if(!t||!this.el.contains(t))return;let s=t.dataset.eventId;if(s!=null&&this._suppressClickId===s){this._suppressClickId=null,e.preventDefault();return}if(t.dataset.eventAction==="activate"){let r=this._eventById(s);r&&this.emit("eventclick",{event:G(r),jsEvent:e});return}if(t.dataset.eventAction==="resize")return;let n=t.dataset.calendarAction;if(n){if(n==="previous")this.prev();else if(n==="next")this.next();else if(n==="today")this.today();else if(n==="view")this.setView(t.dataset.view);else if(n==="new")this.emit("new",{date:this.getDate(),view:this._view,jsEvent:e});else if(n==="week"){let r=Le(t.dataset.date);r&&this.setDate(r).setView("week")}else if(n==="more"){let r=Le(t.dataset.date);if(!r)return;!this.emit("moreclick",{date:r,count:Number(t.dataset.count),jsEvent:e}).defaultPrevented&&this._views.includes("agenda")&&this.setDate(r).setView("agenda")}else if(n==="date"){if(this._suppressDateClick){this._suppressDateClick=!1,e.preventDefault();return}let r=this._dateFromTarget(t);if(!r)return;this._rememberFocusedDate(t),this.emit("dateclick",{date:r,allDay:!t.dataset.dateTime,view:this._view,jsEvent:e})}}}_onDoubleClick(e){let t=e.target?.closest?.('[data-event-action="activate"]');if(t){let a=this._eventById(t.dataset.eventId);a&&this.emit("eventdblclick",{event:G(a),jsEvent:e});return}let s=e.target?.closest?.('[data-calendar-action="date"]');if(!s)return;let n=this._dateFromTarget(s);if(!n)return;let r=!s.dataset.dateTime,o=r?R(n,1):Je(n,fe(this.options.slotDuration));this.emit("select",{start:n,end:o,allDay:r,view:this._view,jsEvent:e})}_onKeydown(e){let t=e.target?.closest?.("[data-event-action]");if(t){this._onEventKeydown(e,t);return}let s=e.target?.closest?.("[data-slot]");if(s){this._onSlotKeydown(e,s);return}let n=e.target?.closest?.("[data-date-cell]");n&&this._onDayKeydown(e,n)}_onEventKeydown(e,t){let s=this._eventById(t.dataset.eventId);if(!s)return;let n=t.dataset.eventAction==="resize";if(e.key==="Enter"&&!this._keyboardEdit&&!n){e.preventDefault(),this.emit("eventclick",{event:G(s),jsEvent:e});return}if(e.key===" "&&!this._keyboardEdit){if(n?!this._canResize(s):!this._canMove(s))return;e.preventDefault(),this._keyboardEdit={oldEvent:G(s),event:G(s),action:n?"resize":"move",control:t},t.setAttribute("aria-grabbed","true"),t.closest(".zx-calendar__event")?.setAttribute("data-state","grabbed"),this._announce(this.msg(n?"calendar.resizeStarted":"calendar.moveStarted",s.title));return}if(!this._keyboardEdit||String(this._keyboardEdit.event.id)!==String(s.id))return;if(e.key==="Escape"){e.preventDefault(),this._cancelKeyboardEdit();return}if(e.key===" "){e.preventDefault();let c=this._keyboardEdit;this._keyboardEdit=null,c.control.removeAttribute("aria-grabbed"),this._commitMutation(c.oldEvent,c.event,c.action,e);return}let r=0,o=0,a=!be(s)&&(this._view==="day"||this._view==="week");if(e.key==="ArrowLeft")r=-1;else if(e.key==="ArrowRight")r=1;else if(e.key==="ArrowUp")a?o=-fe(this.options.slotDuration):r=-7;else if(e.key==="ArrowDown")a?o=fe(this.options.slotDuration):r=7;else return;e.preventDefault();let l=this._keyboardEdit;if(l.action==="move")l.event=Zt(l.event,{days:r,minutes:o});else{let c=R(l.event.end,r);if(c.setMinutes(c.getMinutes()+o),c<=l.event.start)return;let d=Zt(l.event,{days:0,minutes:0,endDays:r,endMinutes:o});d.end>d.start&&(l.event=d)}l.control.closest(".zx-calendar__event")?.setAttribute("data-preview",this._eventTime(l.event,l.event.start)),this._announce(this.msg("calendar.editPreview",l.event.title,this._dateTimeLabel(l.event.start),this._dateTimeLabel(l.event.end)))}_onSlotKeydown(e,t){let s=Number(t.dataset.rowIndex),n=Number(t.dataset.dayIndex),r=t.closest('[role="grid"]'),o=Number(r?.getAttribute("aria-colcount"))||1,a=Number(r?.getAttribute("aria-rowcount"))||1,l=s,c=n;if(e.key==="ArrowLeft")c-=1;else if(e.key==="ArrowRight")c+=1;else if(e.key==="ArrowUp")l-=1;else if(e.key==="ArrowDown")l+=1;else if(e.key==="Home")c=0;else if(e.key==="End")c=o-1;else if(e.key==="PageUp"){e.preventDefault(),this.prev();return}else if(e.key==="PageDown"){e.preventDefault(),this.next();return}else if(e.key==="Enter"||e.key===" "){e.preventDefault();let h=this._dateFromTarget(t);h&&this.emit("dateclick",{date:h,allDay:!1,view:this._view,jsEvent:e});return}else return;e.preventDefault(),l=Math.max(0,Math.min(a-1,l)),c=Math.max(0,Math.min(o-1,c));let d=r?.querySelector(`[data-row-index="${l}"][data-day-index="${c}"]`);d&&(t.tabIndex=-1,d.tabIndex=0,this._focusedSlot=d.dataset.slot,d.focus())}_onDayKeydown(e,t){let s=Le(t.dataset.date);if(!s)return;let n=0;if(e.key==="ArrowLeft")n=-1;else if(e.key==="ArrowRight")n=1;else if(e.key==="ArrowUp")n=-7;else if(e.key==="ArrowDown")n=7;else if(e.key==="Home")n=-((s.getDay()-this.options.weekStart+7)%7);else if(e.key==="End")n=6-(s.getDay()-this.options.weekStart+7)%7;else if(e.key==="PageUp"){e.preventDefault(),this.prev();return}else if(e.key==="PageDown"){e.preventDefault(),this.next();return}else return;e.preventDefault();let r=R(s,n),o=K(r),a=()=>this.el.querySelector(`[data-date-cell][data-date="${o}"]`),l=a();l||(this._focusedDate=o,this.setDate(r),l=a()),l&&(this._moveDateStop(l),l.focus())}_onPointerDown(e){if(this.options.disabled||e.button!==0)return;let t=e.target?.closest?.("[data-event-action]");if(t){let r=this._eventById(t.dataset.eventId),o=t.dataset.eventAction==="resize"?"resize":"move";if(!r||(o==="move"?!this._canMove(r):!this._canResize(r)))return;e.preventDefault(),this._capturePointer(e.pointerId);let a=o==="move"?this._dragOffsetForEvent(r,e.clientX,e.clientY):null;this._pointer={type:"event",pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,oldEvent:G(r),event:G(r),action:o,control:t,timeOffsetMinutes:a?.minutes??0,dayOffset:a?.days??0,moved:!1};return}let s=e.target?.closest?.("[data-slot]");if(!s||!this.options.selectable)return;let n=this._dateFromTarget(s);n&&(e.preventDefault(),this._capturePointer(e.pointerId),this._pointer={type:"selection",pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,start:n,end:Je(n,fe(this.options.slotDuration)),control:s,moved:!1})}_onPointerMove(e){let t=this._pointer;if(!t||t.pointerId!==e.pointerId||!t.moved&&Math.hypot(e.clientX-t.startX,e.clientY-t.startY)<5)return;if(t.moved=!0,e.preventDefault(),t.type==="selection"){let r=this._timeAtPoint(e.clientX,e.clientY);if(!r)return;let o=fe(this.options.slotDuration);t.end=Je(r,o),this._previewSelection(t.start,t.end);return}let s=this._proposalAtPoint(t.oldEvent,t.action,e.clientX,e.clientY);if(!s)return;t.event=s;let n=t.control.closest(".zx-calendar__event");if(n){if(n.dataset.state="dragging",t.action==="resize"){n.style.transform="";let r=this._timedPreviewHeight(s);r&&(n.style.blockSize=r)}else n.style.transform=`translate(${e.clientX-t.startX}px, ${e.clientY-t.startY}px)`;n.dataset.preview=this._eventTime(s,s.start)}this._announce(this.msg("calendar.editPreview",s.title,this._dateTimeLabel(s.start),this._dateTimeLabel(s.end)))}_onPointerUp(e){let t=this._pointer;if(!(!t||t.pointerId!==e.pointerId)&&(this._pointer=null,this._releasePointerCapture(t.pointerId),this._clearSelectionPreview(),!!t.moved)){if(e.preventDefault(),t.type==="selection"){this._suppressDateClick=!0;let s=t.start<t.end?t.start:Je(t.end,-fe(this.options.slotDuration)),n=t.start<t.end?t.end:Je(t.start,fe(this.options.slotDuration));this.emit("select",{start:new Date(s),end:new Date(n),allDay:!1,view:this._view,jsEvent:e});return}this._suppressClickId=String(t.oldEvent.id),this._commitMutation(t.oldEvent,t.event,t.action,e)}}_cancelPointer(e){if(!this._pointer||this._pointer.pointerId!==e.pointerId)return;let t=this._pointer.control;this._releasePointerCapture(this._pointer.pointerId),this._pointer=null,this._clearSelectionPreview(),t.closest?.(".zx-calendar__event")?.removeAttribute("data-state"),this._renderView({preserveFocus:!0})}_proposalAtPoint(e,t,s,n){let r=t==="resize"&&!be(e),o=this._timeAtPoint(s,n,r?e.start:null);if(o&&!be(e)){if(t==="move"){let f=e.end.getTime()-e.start.getTime(),m=G(e);return m.start=Je(o,-Number(this._pointer?.timeOffsetMinutes??0)),m.end=new Date(m.start.getTime()+f),m}let p=G(e);return p.end=Je(o,fe(this.options.slotDuration)),p.end>p.start?p:null}let a=this._dayAtPoint(s,n);if(!a)return null;let l=R(a,-Number(this._pointer?.dayOffset??0)),c=se(W(e.start),l);if(t==="move")return Zt(e,{days:c,minutes:0});let d=G(e),h=R(a,1);return d.end=new Date(h.getTime()),d.end>d.start?d:null}_timeAtPoint(e,t,s=null){let n=this.refs.body.querySelector(".zx-calendar__slots");if(!n)return null;let r=n.getBoundingClientRect(),a=n.closest(".zx-calendar__time-scroller")?.getBoundingClientRect(),l=a?Math.max(r.left,a.left):r.left,c=a?Math.min(r.right,a.right):r.right,d=a?Math.max(r.top,a.top):r.top,h=a?Math.min(r.bottom,a.bottom):r.bottom;if(e<l||e>c||t<d||t>h||r.width<=0||r.height<=0)return null;let p=Number(n.closest('[role="grid"]')?.getAttribute("aria-colcount"))||1,f=Number(n.closest('[role="grid"]')?.getAttribute("aria-rowcount"))||1,m=s?this._timeGridDayIndex(s):-1,g=m>=0?m:Math.max(0,Math.min(p-1,Math.floor((e-r.left)/r.width*p))),_=Math.max(0,Math.min(f-1,Math.floor((t-r.top)/r.height*f))),y=n.querySelector(`[data-row-index="${_}"][data-day-index="${g}"]`);return y?this._dateFromTarget(y):null}_dayAtPoint(e,t){let s=this.refs.body.querySelector(".zx-calendar__all-day-grid");if(s){let r=s.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom){let o=s.querySelectorAll("[data-date]"),a=Math.max(0,Math.min(o.length-1,Math.floor((e-r.left)/r.width*o.length)));return Le(o[a]?.dataset.date)}}for(let r of this.refs.body.querySelectorAll(".zx-calendar__month-events")){let o=r.getBoundingClientRect();if(e<o.left||e>o.right||t<o.top||t>o.bottom||o.width<=0)continue;let a=Le(r.closest(".zx-calendar__month-week")?.dataset.weekStart);if(!a)continue;let l=Math.max(0,Math.min(6,Math.floor((e-o.left)/o.width*7)));return R(a,l)}for(let r of this.refs.body.querySelectorAll(".zx-calendar__agenda-day")){let o=r.getBoundingClientRect();if(!(e<o.left||e>o.right||t<o.top||t>o.bottom))return Le(r.dataset.date)}let n=typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[];for(let r of n){let o=r instanceof HTMLElement?r.closest("[data-date]"):null,a=o instanceof HTMLElement?o.dataset.date:null;if(a)return Le(a)}return null}_dragOffsetForEvent(e,t,s){if(!be(e)){let o=this._timeAtPoint(t,s);if(o){let a=fe(this.options.slotDuration),l=Math.max(0,Math.round((e.end.getTime()-e.start.getTime())/6e4)),c=Math.max(0,l-a),d=Math.round((o.getTime()-e.start.getTime())/6e4);return{minutes:Math.max(0,Math.min(c,d)),days:0}}}let n=this._dayAtPoint(t,s),r=n?se(W(e.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(e){let t=K(e);return[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")].findIndex(n=>n.dataset.date===t)}_timedPreviewHeight(e){if(!this.refs.body.querySelector(".zx-calendar__time-grid")||be(e))return null;let s=Te(this.options.slotMinTime,0),n=Te(this.options.slotMaxTime,1440,!0),r=fe(this.options.slotDuration),o=e.start.getHours()*60+e.start.getMinutes(),a=e.end.getHours()*60+e.end.getMinutes();return`${Math.max(r,Math.min(n,a)-Math.max(s,o))/(n-s)*100}%`}_capturePointer(e){try{this.el.setPointerCapture?.(e)}catch{}}_releasePointerCapture(e){this.el.hasPointerCapture?.(e)&&this.el.releasePointerCapture?.(e)}_previewSelection(e,t){let s=Math.min(e.getTime(),t.getTime()),n=Math.max(e.getTime(),t.getTime());for(let r of this.refs.body.querySelectorAll("[data-slot]")){let o=Number(r.dataset.dateTime);r.setAttribute("aria-selected",String(o>=s&&o<n))}}_clearSelectionPreview(){for(let e of this.refs.body.querySelectorAll("[data-slot][aria-selected]"))e.removeAttribute("aria-selected")}_cancelKeyboardEdit(){let e=this._keyboardEdit;e&&(e.control.removeAttribute("aria-grabbed"),e.control.closest(".zx-calendar__event")?.removeAttribute("data-state"),this._keyboardEdit=null,this._announce(this.msg("calendar.editCancelled")),this._renderView({preserveFocus:!0}))}_commitMutation(e,t,s,n){if(!(e.start.getTime()!==t.start.getTime()||e.end.getTime()!==t.end.getTime())){this._renderView({preserveFocus:!0});return}let o=String(e.id),a=++this._mutationSerial,l=!1;this.options.optimistic?(this._replaceNormalizedEvent(t),this._mutationVersions.set(o,a),this._renderView({preserveFocus:!0})):this._renderView({preserveFocus:!0});let c=()=>{if(l||!this.options.optimistic||this._mutationVersions.get(o)!==a)return!1;let p=this._eventById(o);return!p||p.start.getTime()!==t.start.getTime()||p.end.getTime()!==t.end.getTime()?!1:(l=!0,this._replaceNormalizedEvent(e),this._mutationVersions.delete(o),this._renderView({preserveFocus:!0}),this._announce(this.msg("calendar.editCancelled")),!0)},d={event:G(t),oldEvent:G(e),action:s,delta:lg(e,t),jsEvent:n,revert:c};this.emit("eventchange",d).defaultPrevented?c():this._announce(this.msg("calendar.editCommitted",t.title))}_replaceNormalizedEvent(e){let t=String(e.id);this._events=this._events.map(s=>String(s.id)===t?G(e):s)}_canMove(e){return this.options.disabled?!1:e.editable!=null?e.editable:this.options.eventStartEditable!=null?!!this.options.eventStartEditable:!!this.options.editable}_canResize(e){return this.options.disabled?!1:e.durationEditable!=null?e.durationEditable:typeof this.options.eventDurationEditable=="boolean"?this.options.eventDurationEditable:!!this.options.editable}_eventById(e){let t=this._eventIndex(e);return t<0?null:this._events[t]}_eventIndex(e){let t=String(e);return this._events.findIndex(s=>String(s.id)===t)}_page(e){return this.setDate(ir(this._view,this._date,e,{agendaDays:this.options.agendaDays}))}_rangeTitle(e){if(this._view==="day")return this._format(e.start,{weekday:"long",day:"numeric",month:"long",year:"numeric"});if(this._view==="month")return this._format(this._date,{month:"long",year:"numeric"});if(this._view==="year")return this._format(this._date,{year:"numeric"});let t=R(e.end,-1),s=new Intl.DateTimeFormat(this._locale(),{day:"numeric",month:"long",year:"numeric"});return typeof s.formatRange=="function"?s.formatRange(e.start,t):e.start.getFullYear()!==t.getFullYear()?`${this._format(e.start,{day:"numeric",month:"short",year:"numeric"})} \u2013 ${this._format(t,{day:"numeric",month:"short",year:"numeric"})}`:e.start.getMonth()!==t.getMonth()?`${this._format(e.start,{day:"numeric",month:"short"})} \u2013 ${this._format(t,{day:"numeric",month:"short",year:"numeric"})}`:`${this._format(e.start,{day:"numeric"})}\u2013${this._format(t,{day:"numeric",month:"long",year:"numeric"})}`}_eventTime(e,t){if(e.allDay)return this.msg("calendar.allDay");if(be(e))return Xe(e.start,t)?`${Jt(e.start,this._locale())} \u2192`:Xe(e.end,t)?`\u2192 ${Jt(e.end,this._locale())}`:this.msg("calendar.allDay");let s=ar(e.start,this._locale());return e.end<=e.start?s:`${s}\u2013${ar(e.end,this._locale())}`}_eventLabel(e){let t=e.location?`, ${e.location}`:"";return`${this.msg("calendar.eventLabel",e.title,Jt(e.start,this._locale()),Jt(e.end,this._locale()))}${t}`}_dateTimeLabel(e){return Jt(e,this._locale())}_locale(){return ec(this.options.locale)}_format(e,t){return new Intl.DateTimeFormat(this._locale(),t).format(e)}_now(){let e=typeof this.options.now=="function"?this.options.now():this.options.now,t=e??new Date;if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new TypeError("Calendar now must return a valid Date");return new Date(t.getTime())}_dateFromTarget(e){if(e.dataset.dateTime){let t=new Date(Number(e.dataset.dateTime));return Number.isNaN(t.getTime())?null:t}return Le(e.dataset.date)}_rememberFocusedDate(e){e.dataset.slot?this._focusedSlot=e.dataset.slot:this._moveDateStop(e)}_focusIdentity(){let e=document.activeElement;return!(e instanceof HTMLElement)||!this.el.contains(e)?null:{eventId:e.dataset.eventId,eventAction:e.dataset.eventAction,date:e.dataset.date,dateCell:e.dataset.dateCell,slot:e.dataset.slot,row:e.dataset.rowIndex,column:e.dataset.dayIndex}}_restoreFocus(e){let t=null;if(e.eventId&&(t=this.el.querySelector(`[data-event-id="${or(e.eventId)}"][data-event-action="${e.eventAction??"activate"}"]`)),!t&&e.slot){let s=[...this.el.querySelectorAll("[data-slot]:not(:disabled)")];if(t=s.find(n=>n.dataset.slot===e.slot)??null,!t){let n=Number(e.row)||0,r=Number(e.column)||0;t=s.sort((o,a)=>Math.abs(Number(o.dataset.rowIndex)-n)-Math.abs(Number(a.dataset.rowIndex)-n)||Math.abs(Number(o.dataset.dayIndex)-r)-Math.abs(Number(a.dataset.dayIndex)-r))[0]??null}if(t){for(let n of s)n.tabIndex=n===t?0:-1;this._focusedSlot=t.dataset.slot}}!t&&e.date&&(t=this.el.querySelector(`[data-date-cell][data-date="${or(e.date)}"]`)),!t&&e.dateCell&&(t=this.el.querySelector(`:is(${As})[tabindex="0"]`)),t&&this._moveDateStop(t),t?.focus?.()}_scrollTimeGrid(){let e=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!e)return;let t=Te(this.options.slotMinTime,0),s=Te(this.options.slotMaxTime,1440,!0),n=Te(this.options.scrollTime,480,!0),r=Math.max(0,Math.min(1,(n-t)/(s-t)));requestAnimationFrame(()=>{e.isConnected&&(e.scrollTop=Math.max(0,r*e.scrollHeight-e.clientHeight/4))})}_refreshNowIndicator(){if(this._destroyed||!this.options.nowIndicator||!["day","week"].includes(this._view))return;let e=this.refs.body.querySelector(".zx-calendar__now"),t=[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")];if(!e||!t.length)return;let s=this._now(),n=t.findIndex(c=>c.dataset.date===K(s)),r=Te(this.options.slotMinTime,0),o=Te(this.options.slotMaxTime,1440,!0),a=s.getHours()*60+s.getMinutes(),l=n>=0&&a>=r&&a<=o;e.hidden=!l,l&&(e.style.insetBlockStart=`${(a-r)/(o-r)*100}%`,e.style.setProperty("--zx-calendar-now-day",String(n)),e.querySelector(".zx-calendar__now-time").textContent=rr(a,this._locale()))}_announce(e){this.refs.status.textContent="",requestAnimationFrame(()=>{this._destroyed||(this.refs.status.textContent=e)})}_dayCountLabel(e,t){let s=this._format(e,{dateStyle:"full"});return t===1?this._message("calendar.dayEvent","%1, %2 event",s,t):this._message("calendar.dayEvents","%1, %2 events",s,t)}_message(e,t,...s){let n=this.msg(e,...s);return n===e?q(t,s):n}};function ng(i){if(!Array.isArray(i)||i.length===0)throw new TypeError("Calendar views must be a non-empty array");let e=[...new Set(i.map(String))];for(let t of e)if(!vs.includes(t))throw new RangeError(`Unknown Calendar view: ${t}`);return e}function Ic(i,e,t){if(i==null)return t;if(i instanceof Date){if(Number.isNaN(i.getTime()))throw new TypeError("Calendar date must be valid");return new Date(i.getTime())}let s=typeof i=="number"?i:typeof i=="string"&&/^-?\d+(?:\.\d+)?$/.test(i.trim())?Number(i):null,n=s==null?new Date(i):new Date(s*(e==="seconds"?1e3:1));if(Number.isNaN(n.getTime()))throw new TypeError("Calendar date must be valid");return n}function fe(i){let e=Number(i);if(!Number.isInteger(e)||e<=0||e>720||1440%e!==0)throw new RangeError("Calendar slotDuration must be a positive divisor of 1440");return e}function rg(i){let e=Number(i);if(!Number.isInteger(e)||e<1||e>20)throw new RangeError("Calendar eventLimit must be an integer from 1 through 20");return e}function Te(i,e,t=!1){let s=Number(i??e),n=t?1440:1439;if(!Number.isInteger(s)||s<0||s>n)throw new RangeError(`Calendar minute must be from 0 through ${n}`);return s}function og(i,e){let t=W(i);return t.setMinutes(e),t}function Je(i,e){let t=new Date(i.getTime());return t.setMinutes(t.getMinutes()+e),t}function Dc(i){return`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`}function Xe(i,e){return Dc(i)===Dc(e)}function Le(i){let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(i??""));if(!e)return null;let t=new Date(Number(e[1]),Number(e[2])-1,Number(e[3]));return K(t)===i?t:null}function ag(i,e){return i.start-e.start||e.end-i.end||i.title.localeCompare(e.title)}function rr(i,e){let t=new Date(2026,0,1);return t.setHours(Math.floor(i/60)%24,i%60,0,0),ar(t,e)}function ar(i,e){return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(i)}function Jt(i,e){return new Intl.DateTimeFormat(e,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(i)}function Oc(i){let e=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let s=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e-s)/864e5+1)/7)}function lg(i,e){let t=e.start.getTime()-i.start.getTime();return{milliseconds:t,days:se(W(i.start),W(e.start)),minutes:Math.round(t/6e4),endMilliseconds:e.end.getTime()-i.end.getTime()}}function or(i){return globalThis.CSS?.escape?CSS.escape(i):i.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function cg(i){return typeof i=="string"&&i!==""||typeof i=="function"}var ei=class extends k{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,idPrefix:null,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let e=this.el??u("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):z("zx-form"),this._novalidateAttribute=e.getAttribute("novalidate"),e.toggleAttribute("novalidate",!!this.options.novalidate),this._body=u("div",{class:"zx-form__body"}),this._actions=u("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),e.append(this._body,this._actions),this.listen(e,"submit",s=>{s.preventDefault(),this.submit()}),this.listen(e,"reset",s=>{s.preventDefault(),this.reset()}),this.listen(this._actions,"click",s=>this._handleAction(s));let t=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let s of t)this.addFieldset(s);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),e}addFieldset(e){let t=!(e instanceof Yt),s=t?new Yt(null,{...e??{},idPrefix:e?.idPrefix??this._idPrefix}):e;return this._fieldsets.includes(s)||(t?this._ownedFieldsets.add(s):this._origins.set(s,{parent:s.el.parentNode,next:s.el.nextSibling}),this._fieldsets.push(s),this._body.append(s.el),this.listen(s.el,"zx-change",n=>{let r=n.target,o=r instanceof Element?r.dataset.fieldId:null;o&&this.emit("change",{id:o,value:s.getValue(o)})})),s}setActions(e){return this._actionDescriptors=Array.isArray(e)?e.map(t=>({...t})):[],this._actions.replaceChildren(...this._actionDescriptors.map((t,s)=>{let n=String(t.label??t.id??this.msg("form.action"));return u("button",{class:"zx-btn",type:["submit","reset"].includes(t.type)?t.type:"button",disabled:!!t.disabled,title:t.title,ariaLabel:!n&&t.title?t.title:void 0,dataset:{actionIndex:s,kind:["primary","danger","ghost"].includes(t.kind)?t.kind:"default",size:t.size==="sm"?"sm":"md"}},t.icon?x(t.icon,{size:16}):null,n?u("span",{class:"zx-btn__label"},n):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(e=>e.getValues()))}setValues(e,{silent:t=!1}={}){for(let s of this._fieldsets)s.setValues(e,{silent:t});return this}getField(e){for(let t of this._fieldsets){let s=t.getField(e);if(s)return s}return null}setValue(e,t){return this.getField(e)?.setValue(t),this}getValue(e){return this.getField(e)?.getValue()??null}reset(){for(let e of this._fieldsets)e.reset().clearHighlights();return this}setHighlights(e,t="danger"){return this._fieldsets.reduce((s,n)=>s+n.setHighlights(e,t),0)}clearHighlights(){for(let e of this._fieldsets)e.clearHighlights();return this}submit(){let e={},t=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){if(ug(o)){o.clearHighlight();continue}let a=o.getValue(),l="";if(o.options.required&&lr(a))l=this.msg("form.required");else if(!lr(a)&&o.options.type==="int"){let c=Gs(a);c.valid?o.setValue(c.value,{silent:!0}):l=this.msg("form.int")}else if(!lr(a)&&o.options.type==="float"){let c=Zs(a);c.valid?o.setValue(c.value,{silent:!0}):l=this.msg("form.float")}l?(e[r]=l,o.setHighlight(l,"danger"),t??=o):o.clearHighlight()}return Object.keys(e).length?(this.emit("invalid",{errors:e}),t?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(e){let t=e.target instanceof Element?e.target.closest("[data-action-index]"):null;if(!t||!this._actions.contains(t))return;let s=this._actionDescriptors[Number(t.dataset.actionIndex)],n=s?.onClick??s?.onclick??s?.handler;typeof n=="function"&&n(e,this)}destroy(){for(let e of[...this._fieldsets??[]].reverse())if(this._ownedFieldsets.has(e))e.destroy();else{let t=this._origins.get(e);t?.parent?t.parent.insertBefore(e.el,t.next?.parentNode===t.parent?t.next:null):e.el.remove()}this._fieldsets=[];for(let e of this._ownedNodes??[])e.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function ug(i){return i.el.dataset.disabled==="true"||!!i.el.closest?.("fieldset:disabled")}function lr(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}function dg(){ja(),go(),bo(),na(),qo(),Xo(),Ka(),Ga(),ha(),la(),Ya(),ma(),ga(),$a(),Va()}dg();function ye(i,{onError:e,locale:t}={}){if(!i||typeof i!="object"||!i.api||typeof i.api!="object")throw new TypeError("connect() requires a ZeyOS client with an api namespace");if(e!=null&&typeof e!="function")throw new TypeError("onError must be a function");let s=t??hg(i);s&&Ls(String(s));let n=(o,a)=>e?e(o,a):Re.error(ur(o)),r=async(o,a,l)=>{let c=o;try{return c=fg(i,o,a),await i.api[c](l)}catch(d){try{n(d,{operation:c,resource:a})}catch{}throw d}};return{client:i,list:(o,a={})=>r("list",o,a),get:(o,a,l={})=>r("get",o,Nc(a)?a:{ID:a,...l}),create:(o,a)=>r("create",o,a),update:(o,a,l)=>r("update",o,l===void 0&&Nc(a)?a:{ID:a,body:l??{}}),reportError:n}}function hg(i){return i.locale??i.language??i.config?.locale??i.metadata?.locale??null}function fg(i,e,t){let s=String(t??"").trim();if(!s)throw new TypeError("ZeyOS resource must not be empty");let n=typeof i.schema?.operations=="function"?i.schema.operations(s):[];if(Array.isArray(n)&&n.length){let p=n.filter(f=>typeof f=="string"&&f.toLowerCase().startsWith(e)).sort((f,m)=>f.length-m.length);if(p.length)return p[0]}let r=Array.isArray(n)&&n.length?n:typeof i.schema?.operationIds=="function"?i.schema.operationIds():Object.keys(i.api);if(r.includes(s)&&s.toLowerCase().startsWith(e))return s;let o=Rc(s),a=Lc(o),l=r.filter(p=>{if(typeof p!="string"||!p.toLowerCase().startsWith(e))return!1;let f=Rc(p.slice(e.length));return f===o||f===a||Lc(f)===a});if(l.length)return l.sort((p,f)=>p.length-f.length)[0];let c=e==="list"?[`list${cr(s)}`]:[`${e}${cr(pg(s))}`,`${e}${cr(s)}`],d=new Set(Object.keys(i.api)),h=c.find(p=>d.has(p));if(h)return h;throw new RangeError(`No ${e} operation found for ZeyOS resource "${s}"`)}function Nc(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function ur(i){return i instanceof Error&&i.message||i&&typeof i=="object"&&typeof i.message=="string"?i.message:String(i??"ZeyOS request failed")}function Rc(i){return String(i).replace(/[^a-z\d]/gi,"").toLowerCase()}function Lc(i){return i.endsWith("ies")?`${i.slice(0,-3)}y`:i.endsWith("sses")?i.slice(0,-2):i.endsWith("s")&&!i.endsWith("ss")?i.slice(0,-1):i}function pg(i){let e=String(i);return/ies$/i.test(e)?`${e.slice(0,-3)}y`:/s$/i.test(e)&&!/ss$/i.test(e)?e.slice(0,-1):e}function cr(i){return String(i).split(/[^a-z\d]+/i).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}var et=Object.freeze({accounts:{label:"Accounts",icon:"zeyos-accounts",color:"#bc3885",fa:"building"},actionsteps:{label:"Action Steps",icon:"zeyos-actionsteps",color:"#f67f00",fa:"clock"},appointments:{label:"Appointments",icon:"zeyos-appointments",color:"#bd1e32",fa:"calendar-check"},billing:{label:"Billing",icon:"zeyos-billing",color:"#535494",fa:"file-invoice-dollar"},calendar:{label:"Calendar",icon:"zeyos-calendar",color:"#bd1e32",fa:"calendar-days"},campaigns:{label:"Campaigns",icon:"zeyos-campaigns",color:"#f16528",fa:"bullhorn"},collection:{label:"Collection",icon:"zeyos-collection",color:"#0d60ae",fa:"hand-holding-dollar"},contacts:{label:"Contacts",icon:"zeyos-contacts",color:"#8c6641",fa:"address-book"},contracts:{label:"Contracts",icon:"zeyos-contracts",color:"#823e89",fa:"file-contract"},coupons:{label:"Coupons",icon:"zeyos-coupons",color:"#10775c",fa:"ticket-simple"},devices:{label:"Devices",icon:"zeyos-devices",color:"#064e4f",fa:"desktop"},documents:{label:"Documents",icon:"zeyos-documents",color:"#808000",fa:"file"},dunning:{label:"Dunning",icon:"zeyos-dunning",color:"#0d60ae",fa:"file-invoice-dollar"},events:{label:"Events",icon:"zeyos-events",color:"#bd1e32",fa:"calendar-day"},inventory:{label:"Inventory",icon:"zeyos-inventory",color:"#064e4f",fa:"warehouse"},items:{label:"Items",icon:"zeyos-items",color:"#064e4f",fa:"box-open"},ledgers:{label:"Ledgers",icon:"zeyos-ledgers",color:"#4679c8",fa:"book-open"},line:{label:"Line Items",icon:"zeyos-line",color:"#064e4f",fa:"list-ul"},links:{label:"Links",icon:"zeyos-links",color:"#405e76",fa:"bookmark"},mailinglists:{label:"Mailing Lists",icon:"zeyos-mailinglists",color:"#0299ac",fa:"envelope-open-text"},messages:{label:"Messages",icon:"zeyos-messages",color:"#31a8e0",fa:"message"},"messages-unread":{label:"Unread Messages",icon:"zeyos-messages-unread",color:"#31a8e0",fa:"envelope"},notes:{label:"Notes",icon:"zeyos-notes",color:"#008853",fa:"note-sticky"},opportunities:{label:"Opportunities",icon:"zeyos-opportunities",color:"#7b67ae",fa:"handshake"},payments:{label:"Payments",icon:"zeyos-payments",color:"#4679c8",fa:"sack-dollar"},pricelists:{label:"Price Lists",icon:"zeyos-pricelists",color:"#10775c",fa:"clipboard-list"},procurement:{label:"Procurement",icon:"zeyos-procurement",color:"#006e9f",fa:"truck"},production:{label:"Production",icon:"zeyos-production",color:"#226375",fa:"industry"},projects:{label:"Projects",icon:"zeyos-projects",color:"#db532d",fa:"diagram-project"},stocktransactions:{label:"Stock Transactions",icon:"zeyos-stocktransactions",color:"#064e4f",fa:"arrow-right-arrow-left"},storages:{label:"Storages",icon:"zeyos-storages",color:"#064e4f",fa:"boxes-stacked"},tasks:{label:"Tasks",icon:"zeyos-tasks",color:"#e2b301",fa:"list-check"},text:{label:"Text Blocks",icon:"zeyos-text",color:"#064e4f",fa:"file-lines"},tickets:{label:"Tickets",icon:"zeyos-tickets",color:"#f04639",fa:"ticket"},"transactions-billing":{label:"Billing Transactions",icon:"zeyos-transactions-billing",color:"#535494",fa:"file-invoice"},"transactions-collection":{label:"Collection Transactions",icon:"zeyos-transactions-collection",color:"#0d60ae",fa:"money-bill-transfer"},"transactions-procurement":{label:"Procurement Transactions",icon:"zeyos-transactions-procurement",color:"#006e9f",fa:"cart-shopping"},"transactions-production":{label:"Production Transactions",icon:"zeyos-transactions-production",color:"#226375",fa:"gears"},zeyos:{label:"ZeyOS",icon:"zeyos",color:"#007a55",fa:"cloud"},default:{label:"Default",icon:"zeyos-default",color:"#21cc75",fa:"cube"},admin:{label:"Administration",icon:"zeyos-admin",color:"#4b5563",fa:"screwdriver-wrench"},applications:{label:"Applications",icon:"zeyos-applications",color:"#2563eb",fa:"window-maximize"},auth:{label:"Credentials",icon:"zeyos-auth",color:"#a16207",fa:"shield-halved"},categories:{label:"Categories",icon:"zeyos-categories",color:"#9a3412",fa:"folder-tree"},channels:{label:"Channels",icon:"zeyos-channels",color:"#0891b2",fa:"share-nodes"},control:{label:"Control Center",icon:"zeyos-control",color:"#0f766e",fa:"sliders"},davservers:{label:"DAV Servers",icon:"zeyos-davservers",color:"#475569",fa:"server"},dev:{label:"Development",icon:"zeyos-dev",color:"#1f2937",fa:"code"},error:{label:"Errors",icon:"zeyos-error",color:"#b91c1c",fa:"triangle-exclamation"},global:{label:"Global",icon:"zeyos-global",color:"#0369a1",fa:"globe"},groups:{label:"Groups",icon:"zeyos-groups",color:"#007a55",fa:"users"},logout:{label:"Logout",icon:"zeyos-logout",color:"#9f1239",fa:"right-from-bracket"},objects:{label:"Custom Objects",icon:"zeyos-objects",color:"#7e22ce",fa:"cubes"},participants:{label:"Participants",icon:"zeyos-participants",color:"#4338ca",fa:"user-group"},permissions:{label:"Permissions",icon:"zeyos-permissions",color:"#5b21b6",fa:"user-lock"},records:{label:"Records",icon:"zeyos-records",color:"#57534e",fa:"database"},resources:{label:"Resources",icon:"zeyos-resources",color:"#15803d",fa:"layer-group"},services:{label:"Services",icon:"zeyos-services",color:"#b45309",fa:"bell-concierge"},system:{label:"System",icon:"zeyos-system",color:"#374151",fa:"gear"},users:{label:"Users",icon:"zeyos-users",color:"#007a55",fa:"user"},weblets:{label:"Weblets",icon:"zeyos-weblets",color:"#4f46e5",fa:"window-restore"}}),Pc=Object.freeze({main:"zeyos",addresses:"contacts",clocking:"actionsteps",comments:"notes",couponcodes:"coupons",customers:"accounts",customfields:"objects",davids:"davservers",documentversions:"documents",enhancements:"applications",extdata:"objects",feedservers:"channels",files:"documents",filters:"records",forks:"applications",imports:"records",invoices:"transactions-billing",linecoupon:"line",logins:"auth",mailservers:"channels",notifications:"messages","participants-campaigns":"participants","participants-mailinglists":"participants",prices:"pricelists",pwd:"auth",purchaseorders:"transactions-procurement",sessions:"auth",settings:"system",suppliers:"accounts",tags:"categories",tokens:"auth",transactions:"transactions-billing",usergroups:"groups",usermgmt:"users",usersettings:"system",userfields:"objects",userfilters:"records"}),ti=Object.freeze({light:"#ffffff",dark:"#141414"}),ii=Object.create(null);function ks(i){let e=String(i??"").trim().toLowerCase().replaceAll(/[._\s]+/g,"-");if(!e)return"default";if(Object.hasOwn(ii,e)||Object.hasOwn(et,e))return e;let t=Pc[e];return t||"default"}function le(i){let e=ks(i);return ii[e]??et[e]??et.default}function mg(i){return le(i).color}function gg(i,{standard:e=!1}={}){let t=le(i);return e?t.fa:t.icon}function _g(){return[...new Set([...Object.keys(et),...Object.keys(ii)])].sort()}function bg(i){for(let[e,t]of Object.entries(i)){let s=String(e).trim().toLowerCase().replaceAll(/[._\s]+/g,"-"),n=typeof t=="string"?{color:t}:t,r=ii[s]??et[s]??et.default;ii[s]=Object.freeze({label:n.label??r.label,icon:n.icon??r.icon,color:n.color??r.color,fa:n.fa??r.fa})}}function yg(i){let e=dr(i);if(e===null)return ti.light;let t=Fc(e,dr(ti.light)??1),s=Fc(e,dr(ti.dark)??0);return t>=s?ti.light:ti.dark}function dr(i){let e=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(String(i).trim());if(!e)return null;let t=e[1].length===3?[...e[1]].map(o=>o+o).join(""):e[1],[s,n,r]=[0,2,4].map(o=>{let a=Number.parseInt(t.slice(o,o+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4});return .2126*s+.7152*n+.0722*r}function Fc(i,e){return(Math.max(i,e)+.05)/(Math.min(i,e)+.05)}var jc="https://kit.fontawesome.com/ae8320b210.js";function wg(i={}){return an({kit:jc,...i})}function Cs(i,e={}){let{standard:t=!1,...s}=e,n=le(i);return x(t?`fa:${n.fa}`:`kit:${n.icon}`,s)}function vt(i,e={}){let{size:t=24,iconSize:s="52%",label:n=null,title:r=!1,standard:o=!1,color:a=null,badge:l=null,selected:c=!1}=e,d=ks(i),h=le(i),p=Ie(a)?a:h.color,f=hs({icon:e.icon??Cs(i,{size:"1em",standard:o}),size:t,iconSize:s,color:p,label:n,badge:l,selected:c,shape:e.shape??"tile",glass:e.glass??"subtle",class:["zx-module-icon",e.class].flat().filter(Boolean)});return f.dataset.module=d,f.style.setProperty("--zx-module-color",p),f.style.setProperty("--zx-module-glyph","var(--zx-color-app-icon-glyph)"),f.style.setProperty("--zx-app-icon-glyph","var(--zx-color-app-icon-glyph)"),r&&(f.title=h.label),f}function hr(i,e={}){return vt(i,{shape:"circle",...e})}var vg=Object.freeze(["accounts","actionsteps","admin","auth","billing","calendar","campaigns","collection","contacts","contracts","control","coupons","dev","documents","inventory","mailinglists","main","messages","links","notes","objects","opportunities","payments","pricelists","procurement","production","projects","tasks","tickets"]);function Vc(i={},e={}){let{standardIcons:t=!1,items:s=[],sources:n=[],...r}=e,o=mr(i.labels),a={standardIcons:t,renderApplicationIcon:i.renderApplicationIcon,renderWebletIcon:i.renderWebletIcon},l=Bc(i,a),c=typeof i.loadRecent=="function"?[]:zs(i.recent??[],{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:t}),d=[];return typeof i.loadRecent=="function"&&d.push({id:"zeyos-recent",minQuery:0,when:"empty",order:"source",load:async(h,p)=>zs(await i.loadRecent(p),{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:t})}),typeof i.search=="function"&&d.push({id:"zeyos-records",minQuery:1,when:"query",order:"source",load:async(h,p)=>zs(await i.search(h,p),{query:h,labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:t})}),d.push(...n),{...r,items:[...l,...c,...s],sources:d,hints:e.hints??{move:o.move,open:o.open,close:o.close}}}function xg(i={},e={}){return new ds(null,Vc(i,e))}function Bc(i={},e={}){let t=mr(i.labels),s=Array.isArray(i.pinned)?i.pinned.map(String):[],n=new Set,r=[],o=(a,l=null,c=null)=>{let d=pr(a,l,c);if(!d||n.has(d.identifier)||d.type==="module"&&typeof i.canUseModule=="function"&&!i.canUseModule(d.module))return;n.add(d.identifier);let h=Es(d.raw,i.resolveApplication),p=s.indexOf(d.identifier),f=()=>(typeof e.renderApplicationIcon=="function"?e.renderApplicationIcon(d.raw,d):d.type==="weblet"&&typeof e.renderWebletIcon=="function"?e.renderWebletIcon(d.raw,d):null)??hr(d.module,{size:36,standard:!!e.standardIcons,color:d.color});r.push({id:d.identifier,label:d.label,keywords:[d.identifier,d.module],group:t.applications,groupOrder:0,kind:"application",icon:f,pinned:p>=0?p:void 0,current:d.identifier===i.activeIdentifier,disabled:!h.href&&typeof h.invoke!="function",...h,_zeyos:d})};for(let a of Array.isArray(i.menuApps)?i.menuApps:[])o(a);if(Array.isArray(i.modules))for(let a of i.modules)typeof a=="string"?o([a,le(a).label]):o(a,a?.id??a?.module,a?.label);else for(let[a,l]of Object.entries(i.modules??{}))o([a,l]);return r}function zs(i,e={}){let t=String(e.query??""),s=mr(e.labels),n=Ag(i,t),r=new Map;return n.flatMap(({raw:o,group:a},l)=>{let c=kg(o,a,t);if(!c)return[];let d=t===""?s.recent:c.group===""?s.results:s.entities[c.group]??c.group;r.has(d)||r.set(d,r.size+1);let h=Es(c.raw,e.resolveRecord);return[{id:`record:${c.entity}:${c.fork??""}:${c.ID}`,label:c.name,description:c.sec,keywords:[c.entity,c.ID,c.fork??""],group:d,groupOrder:r.get(d),itemOrder:l,kind:"record",when:t===""?"empty":"query",icon:()=>(typeof e.renderRecordIcon=="function"?e.renderRecordIcon(c.raw,c):null)??vt(c.entity,{size:28,standard:!!e.standardIcons}),disabled:!h.href&&typeof h.invoke!="function",...h,_zeyos:c}]})}function Sg(i={}){return i.weblet!=null&&i.weblet!==""?`weblet#${i.weblet}`:i.fork!=null&&i.fork!==""?`fork#${i.fork}`:String(i.module??"")}function pr(i,e,t){if(Array.isArray(i)){if(i.length<2)return null;if(i.length===2){let r=String(i[0]);return{raw:i,identifier:r,label:String(i[1]),module:r,type:"module",color:null}}if(i.length===4){let r=String(i[2]||"default");return{raw:i,identifier:`fork#${i[0]}`,label:String(i[1]),module:r,type:"fork",color:fr(i[3])}}return{raw:i,identifier:`weblet#${i[0]}`,label:String(i[1]),module:"weblets",type:"weblet",color:fr(i[8])}}if(!i||typeof i!="object")return null;let s=String(i.identifier??i.id??e??"");if(!s)return null;let n=s.startsWith("fork#")?"fork":s.startsWith("weblet#")?"weblet":"module";return{raw:i,identifier:s,label:String(i.label??t??le(s).label),module:String(i.module??(n==="module"?s:n==="fork"?"default":"weblets")),type:n,color:fr(i.color)}}function Ag(i,e){if(Array.isArray(i))return i.map(s=>({raw:s,group:s?.group??""}));if(!i||typeof i!="object")return[];let t=[];for(let[s,n]of Object.entries(i))if(Array.isArray(n))for(let r of n){if(!Array.isArray(r)){t.push({raw:r,group:s});continue}let o=s===""&&r.length>=5?{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:r[4],group:s}:{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:s,group:s};t.push({raw:o,group:s})}return t}function kg(i,e,t){return Array.isArray(i)?t===""&&i.length>=4?{raw:i,entity:String(i[0]),ID:i[1],fork:i[2]??null,name:String(i[3]),sec:String(i[4]??""),group:""}:null:!i||typeof i!="object"||i.ID==null||i.name==null?null:{raw:i,entity:String(i.entity??e??"records"),ID:i.ID,fork:i.fork??null,name:String(i.name),sec:String(i.sec??""),group:String(i.group??e??"")}}function Es(i,e){let t=i&&typeof i=="object"&&!Array.isArray(i)?i:{},s=typeof e=="function"?e(i):null,n=s&&typeof s=="object"?s:{};return Object.fromEntries(["href","target","invoke","value"].flatMap(r=>{let o=n[r]??t[r];return o===void 0?[]:[[r,o]]}))}function fr(i){let e=String(i??"").trim();if(!e)return null;let t=e.startsWith("#")?e:`#${e}`;return/^#[\da-f]{3}(?:[\da-f]{3})?$/i.test(t)?t:null}function mr(i){let e=i&&typeof i=="object"?i:{};return{applications:String(e.applications??V("zeyosLauncher.applications")),recent:String(e.recent??V("zeyosLauncher.recent")),results:String(e.results??V("zeyosLauncher.results")),entities:e.entities&&typeof e.entities=="object"?e.entities:{},move:String(e.move??V("zeyosLauncher.move")),open:String(e.open??V("zeyosLauncher.open")),close:String(e.close??V("zeyosLauncher.close"))}}function gr(i={},e={}){let t=Array.isArray(i.pinned)?i.pinned.map(String):null,s=i.menus&&typeof i.menus=="object"?i.menus:{},n=i.badges&&typeof i.badges=="object"?i.badges:{},r=i.groups&&typeof i.groups=="object"?i.groups:{},o={forks:V("zeyosModuleBar.forks"),weblets:V("zeyosModuleBar.weblets"),...i.labels??{}},a=new Set,l=[],c=(d,h=null,p=null)=>{let f=pr(d,h,p);if(!f||a.has(f.identifier)||f.type==="module"&&typeof i.canUseModule=="function"&&!i.canUseModule(f.module))return;a.add(f.identifier);let m=$c(s[f.identifier],n),g=m.length?{}:Es(f.raw,i.resolveApplication),_=t?t.indexOf(f.identifier):-1,y=r[f.identifier]??(f.type==="fork"?o.forks:f.type==="weblet"?o.weblets:void 0);l.push({id:f.identifier,label:f.label,icon:()=>(typeof i.renderApplicationIcon=="function"?i.renderApplicationIcon(f.raw,f):null)??Cs(f.module,{size:"1em",standard:!!e.standardIcons}),color:f.color??le(f.module).color,module:f.module,...y?{group:y}:{},...n[f.identifier]!=null?{badge:n[f.identifier]}:{},...t?{pinned:_>=0?_:!1}:{},...m.length?{children:m}:g})};for(let d of Array.isArray(i.menuApps)?i.menuApps:[])c(d);if(Array.isArray(i.modules))for(let d of i.modules)typeof d=="string"?c([d,le(d).label]):c(d,d?.id??d?.module,d?.label);else for(let[d,h]of Object.entries(i.modules??{}))c([d,h]);return Ge(l)}function qc(i={},e={}){let{standardIcons:t=!1,appearance:s="solid",...n}=e;return{...n,items:gr(i,{standardIcons:t}),active:i.active??i.activeIdentifier??null,appearance:s}}function Cg(i={},e={}){let{standardIcons:t=!1,appearance:s="solid",moduleBar:n={},...r}=e;return{label:"ZeyOS",...r,layout:"modules",items:gr(i,{standardIcons:t}),active:i.active??i.activeIdentifier??null,moduleBar:{appearance:s,...n}}}function zg(i,e={},t={}){return new _s(i,qc(e,t))}function $c(i,e){return Array.isArray(i)?i.flatMap(t=>{if(Array.isArray(t)){let[o,a,l]=t;return o==null||a==null?[]:[{id:o,label:String(a),...l!=null?{href:String(l)}:{},...e[String(o)]!=null?{badge:e[String(o)]}:{}}]}if(!t||typeof t!="object"||t.label==null)return[];let s=$c(t.children,e);if(t.section===!0)return s.length?[{...t.id!=null?{id:t.id}:{},section:!0,label:String(t.label),children:s}]:[];if(t.id==null)return[];let n=Object.fromEntries(["id","href","target","invoke","icon","value","disabled"].filter(o=>t[o]!==void 0).map(o=>[o,t[o]])),r=e[String(t.id)]??t.badge;return[{...n,label:String(t.label),...r!=null?{badge:r}:{},...s.length?{children:s}:{}}]}):[]}function si(i,e,t={}){let{fields:s,labelKey:n=Wc(i,e),valueKey:r="ID",searchFields:o=Gc(i,e),limit:a=50,filters:l={},value:c=null,...d}=t,h=ye(i),p=s??Yc(r,n,o);return{...d,valueKey:r,labelKey:n,value:c,filter:async f=>{let m=await h.list(e,Ct({search:f,filters:l,fields:p,searchFields:o,limit:a}));return _r(i,m).data}}}function Eg(i,e,t={}){let s=si(i,e,t),n=t.value??null,r=new Y(null,s);return r.ready=Kc(r,i,e,n),r}function Uc(i,e,t={}){let{fields:s,labelKey:n=Wc(i,e),valueKey:r="ID",searchFields:o=Gc(i,e),subtitleKey:a=null,moduleKey:l=()=>e,groupKey:c=null,none:d=!0,recent:h=[],create:p=!1,renderIcon:f=Ig,renderItem:m,renderValueAdornment:g,..._}=t,y=s??Yc(r,n,[...o,...[a,l,c].filter(v=>typeof v=="string")]),b=si(i,e,{..._,fields:y,labelKey:n,valueKey:r,searchFields:o,groupKey:c,clearable:d===!1?!!_.clearable:!0});b.recent=Array.isArray(h)?h:[];let w=(v,A=!1)=>{if(f===null)return null;let S=Ts(v,l)??e;return f(v,{resource:e,module:String(S),selected:A})};if(b.renderItem=m??(v=>{let A=w(v);return u("span",{class:"zx-select__entity"},A?u("span",{class:"zx-select__entity-icon",ariaHidden:"true"},A):null,u("span",{class:"zx-select__entity-copy"},u("span",{class:"zx-select__entity-label"},String(Ts(v,n)??"")),a&&Ts(v,a)!=null?u("span",{class:"zx-select__entity-subtitle"},String(Ts(v,a))):null))}),b.renderValueAdornment=g??(v=>w(v,!0)),d!==!1&&(b.noneLabel=typeof d=="string"?d:_.noneLabel??V("select.none"),b.renderNone=_.renderNone??(v=>u("span",{class:"zx-select__entity-none"},u("span",{class:"zx-select__entity-none-icon",ariaHidden:"true"}),u("span",{},v)))),p){let v=p===!0?{}:p,A=typeof v.oninvoke=="function"?v.oninvoke:null;b.actions=[...Array.isArray(b.actions)?b.actions:[],{id:v.id??"create",label:v.label??V("select.create"),group:v.group??V("select.createGroup"),icon:v.icon??"plus",invoke:S=>A?.({...S,resource:e})}]}return b}function Tg(i,e,t={}){let s=Uc(i,e,t),n=t.value??null,r=Y.entity(null,s);return r.ready=Kc(r,i,e,n),r}function _r(i,e){return typeof i?.normalizeListResult=="function"?Hc(i.normalizeListResult(e)):Hc(e)}function Hc(i){if(Array.isArray(i))return{data:i};if(!i||typeof i!="object")return{data:[]};let e=Array.isArray(i.data)?i.data:[],t=i.count==null||i.count===""?null:Number(i.count);return Number.isFinite(t)?{data:e,count:t}:{data:e}}function Kc(i,e,t,s){let n=(async()=>{if(s==null)return i;let r=i.value,o=!1,a=()=>{o=!0};i.on("change",a);try{let l=s&&typeof s=="object"?s:await ye(e).get(t,s),c=Mg(l);return o||!Object.is(i.value,r)||Y.from(i.el)!==i||(i.setItems([c]),i.set(c,{silent:!0})),i}finally{i.off("change",a)}})();return n.catch(()=>{}),n}function Mg(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let e=i.data;return e&&typeof e=="object"&&!Array.isArray(e)?e:i}throw new TypeError("ZeyOS get operation did not return a record")}function Ts(i,e){return typeof e=="function"?e(i):i&&typeof i=="object"&&typeof e=="string"?i[e]:null}function Ig(i,e){return vt(String(e.module??"default"),{size:20})}function Yc(i,e,t){let s=[i,e,...t].filter(n=>typeof n=="string"&&n);return s.length?[...new Set(s)]:void 0}function Wc(i,e){let t=Dg(i,e);for(let s of["name","lastname","customernum","transactionnum","number","title","ID"])if(t.includes(s))return s;return t[0]??"ID"}function Gc(i,e){let t=i?.schema?.describe?.(e)?.fields;return!t||typeof t!="object"||Array.isArray(t)?[]:Object.entries(t).flatMap(([s,n])=>{if(!n||typeof n!="object")return[];let r=String(n.type??"").toLowerCase();return n.indexed&&/text|character|varchar/.test(r)?[s]:[]})}function Dg(i,e){let t=i?.schema?.fields?.(e);if(Array.isArray(t))return t.map(String);if(t&&typeof t=="object")return Object.keys(t);let s=i?.schema?.describe?.(e)?.fields;return s&&typeof s=="object"?Object.keys(s):[]}function Og(i,e,t={}){let s=zt(i,e,t),n={},r=[],o=new Map;for(let a of s){let l=qs(a);(l.type==="date"||l.type==="datetime")&&o.set(String(a.id),l.type);let c=l.type==="zxselect"&&typeof l.props?.entity=="string"?l.props.entity:null;c&&(r.push({id:String(a.id),resource:c}),l.props={...si(i,c,{clearable:!l.required,placeholder:`Select ${String(l.label).toLowerCase()}`})}),n[String(a.id)]=l}return{fieldMeta:s,fields:n,entityFields:r,formOptions:{fieldsets:[{title:String(t.title??""),columns:jg(t.columns),fields:n}]},mapFromRecord:a=>Rg(a,s,o),mapToRecord:a=>Lg(a,s,o)}}function Ng(i,e,t={}){if(t.onSaved!=null&&typeof t.onSaved!="function")throw new TypeError("zeyosForm onSaved must be a function");let s=t.notify!==!1,n=Og(i,e,t),r=()=>t.scope??a.el,o=ye(i,{onError:_=>s?Re.error(ur(_),{scope:r()}):void 0}),a=new ei(null,n.formOptions),l=t.value?.ID??t.id??null,c=!1,d=null,h=0,p=async(_,y=++h,b=void 0)=>{if(!_||typeof _!="object"||Array.isArray(_))throw new TypeError("ZeyOS form value must be a record");let w=()=>!c&&y===h;return await Promise.all(n.entityFields.map(async({id:v,resource:A})=>{let S=_[v];if(S==null)return;let M=S&&typeof S=="object"?S:br(await o.get(A,S));if(!w())return;let L=Y.from(a.getField(v)?.getInput());L instanceof Y&&L.setItems([M])})),w()&&(b!==void 0&&(l=b),a.setValues(n.mapFromRecord(_),{silent:!0})),_},f=async _=>{if(_==null||_==="")throw new TypeError("zeyosForm.load() requires an id");let y=++h,b=br(await o.get(e,_));return c||y!==h||await p(b,y,b.ID??_),b},m=()=>{if(c)return Promise.reject(new Error("Cannot save a destroyed ZeyOS form"));if(d)return d;if(!a.submit())return Promise.resolve(null);let _=s?he(r()):null;return d=(async()=>{let y;try{y=n.mapToRecord(a.getValues()),delete y.ID}catch(v){throw o.reportError(v,{operation:"serialize",resource:e}),v}let b=l==null?await o.create(e,y):await o.update(e,{ID:l,...y}),w=br(b);if(l=w.ID??l,t.onSaved)try{await t.onSaved(w)}catch(v){throw o.reportError(v,{operation:"onSaved",resource:e}),v}return _&&Re.success(V("zeyosForm.saved",[Vg(w,e)]),{scope:_}),w})().finally(()=>{d=null}),d},g=Object.prototype.hasOwnProperty.call(t,"id")?f(t.id):t.value?p(t.value):Promise.resolve(null);return g.catch(()=>{}),{form:a,ready:g,load:f,save:m,getForm:()=>a,destroy(){c||(c=!0,a.destroy())}}}function Rg(i,e,t){let s={};for(let n of e){let r=String(n.id),o=i[r],a=t.get(r);!a||o==null||o===""?s[r]=o:a==="date"?s[r]=Bs(o,n.timeZone):s[r]=Me(o)}return s}function Lg(i,e,t){let s={};for(let n of e){let r=String(n.id),o=i[r],a=t.get(r);if(a)o==null||o===""?o=null:a==="date"?o=Pe(o,n.timeZone):o=ve(o);else if(Fg(n)&&Pg(n.type)&&o!==""&&o!=null){let l=Number(o);Number.isFinite(l)&&(o=l)}s[r]=o}return s}function Fg(i){return i.enums!=null||i.enum!=null}function Pg(i){return/^(?:smallint|integer|bigint|int|int2|int4|int8|numeric|decimal)$/i.test(String(i??""))}function jg(i){let e=Number(i??2);return[1,2,3].includes(e)?e:2}function br(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let e=i.data;return e&&typeof e=="object"&&!Array.isArray(e)?e:i}throw new TypeError("ZeyOS operation did not return a record")}function Vg(i,e){for(let t of["transactionnum","name","lastname","customernum","number","ID"])if(i[t]!=null&&i[t]!=="")return String(i[t]);return String(e)}var Bg=["variant","zebra","stickyHeader","responsive","growing","emptyText","rowClass","rowKind","rowKinds","columnVisibility","columnReorder","hiddenColumns","onrowdblclick","onsort","onselectionchange","ondatachange","onstackedchange","ongrow","oncolumnvisibilitychange","oncolumnorderchange"];function wr(i,e,t={}){let s=zt(i,e,{fields:t.fields,labels:t.labels,formats:t.formats,timeZone:t.timeZone}),n={},r=s.map(l=>{let c={...l},d=Hg(c);if(d){let f=Ug(i,d);c.labelField=`${c.id}_label`,n[c.labelField]=`${c.id}.${f}`}n[c.id]=c.id;let h=Kg(c),p=$s(h?{...c,format:"money"}:c);return h&&(p.render=f=>it(f?.[c.id],f?.currency,{locale:c.locale}),Yg(i,e,"currency")&&(n.currency="currency")),p}),o=t.rowId??"ID";typeof o=="string"&&!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=o);let a={};for(let l of Bg)t[l]!==void 0&&(a[l]=t[l]);return{fieldMeta:s,columns:r,projection:n,tableOptions:{...a,columns:r,data:[],rowId:o,sort:t.sort??null,sortMode:"server",selectable:t.selectable??!1,height:t.height??null,onrowclick:$g(t)}}}function qg(i,e,t={}){let s=wr(i,e,t),n=ye(i),r=new Ut(null,s.tableOptions),o;try{o=vr({client:i,facade:n,resource:e,projection:s.projection,target:r,pageSize:t.pageSize,sort:t.sort??null,filters:t.filters??{},search:t.search,label:"ZeyOS table"})}catch(l){throw r.destroy(),l}let a={table:r,load:o.load,setSearch:l=>o.load({search:l,page:0}),setFilters:l=>o.load({filters:l,page:0}),loadMore:o.loadMore,get count(){return o.count},get page(){return o.page},get pageSize(){return o.pageSize},get hasMore(){return o.hasMore},destroy:()=>{o.destroyed||(o.destroy(),r.destroy())}};return r.on("sort",l=>{if(o.destroyed)return;let c=l.detail?.id;o.setSort(c==null?null:{id:String(c),dir:l.detail.dir==="desc"?"desc":"asc"}),o.load({page:0}).catch(()=>{})}),a}function vr(i){let{client:e,facade:t,resource:s,projection:n,target:r,searchFields:o}=i,a=String(i.label??"ZeyOS binding"),l=Zc(i.pageSize,a),c=i.sort??null,d=yr(i.filters??{},a),h=String(i.search??""),p=0,f=null,m=!1,g=0,_=0,y=!1,b=!1,w=S=>Ct({fields:n,sort:c,filters:d,search:h,searchFields:o,limit:l,offset:S*l,count:!0}),v=(S={})=>{let M=S&&typeof S=="object"?S:{},L=J=>Object.prototype.hasOwnProperty.call(M,J);return{page:Gg(M.page??0,a),pageSize:L("pageSize")&&M.pageSize!==void 0?Zc(M.pageSize,a):l,filters:L("filters")?yr(M.filters??{},a):d,search:L("search")?String(M.search??""):h}},A=async(S={})=>{if(b)throw new Error(`${a} binding has been destroyed`);let M=v(S),L=M.page,J=M.pageSize;l=J,d=M.filters,h=M.search;let ue=L===0||S.replace===!0,I=w(L),F=++g;ue&&(_=F),y=!0,r.setLoading(!0);try{let j=_r(e,await t.list(s,I)),X=j.count??null,tt=X==null?j.data.length===J:L*J+j.data.length<X;return!b&&F===g&&(p=L,f=X,m=tt,ue?r.setData(j.data):r.addData(j.data)),{data:j.data,count:X,page:L,hasMore:tt,query:I}}catch(j){throw ue&&!b&&F===g&&(m=!1),j}finally{_===F&&(_=0),!b&&F===g&&(y=!1,r.setLoading(!1))}};return{load:A,check:v,loadMore:()=>m&&!_?A({page:p+1}):b?Promise.reject(new Error(`${a} binding has been destroyed`)):Promise.resolve({data:[],count:f,page:p,hasMore:!1,query:w(p)}),setSort:S=>{c=S??null},setQuery:(S={})=>{let M=Object.prototype.hasOwnProperty.call(S,"filters")?yr(S.filters??{},a):d;Object.prototype.hasOwnProperty.call(S,"search")&&(h=String(S.search??"")),d=M},reset:()=>{g+=1,_=0,p=0,f=null,m=!1,y&&!b&&r.setLoading(!1),y=!1},destroy:()=>{b||(b=!0,g+=1)},get destroyed(){return b},get count(){return f},get page(){return p},get pageSize(){return l},get hasMore(){return m},get sort(){return c},get filters(){return{...d}},get search(){return h}}}function $g(i){let e=typeof i.onrowclick=="function"?i.onrowclick:null,t=typeof i.onRowClick=="function"?i.onRowClick:null;if(!(!e&&!t))return s=>{e?.(s),t?.(s.detail.row,s)}}function Hg(i){for(let e of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"){let t=e.resource??e.target??e.table??e.entity;if(typeof t=="string"&&t)return t}}return null}function Ug(i,e){let t=i?.schema?.fields?.(e),s=Array.isArray(t)?t.map(String):Object.keys(t??{});for(let n of["name","lastname","customernum","transactionnum","number","title","ID"])if(s.includes(n))return n;return s[0]??"ID"}function Kg(i){let e=String(i.format??"").toLowerCase();return/money|currency|price/.test(e)||/(?:amount|price)$/.test(String(i.id).toLowerCase())}function Yg(i,e,t){let s=i?.schema?.fields?.(e);return Array.isArray(s)?s.includes(t):!!(s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,t))}var Wg=50;function Zc(i,e="ZeyOS table"){if(i==null)return Wg;let t=Number(i);if(!Number.isInteger(t)||t<1)throw new RangeError(`${e} page size must be a positive integer`);return t}function Gg(i,e="ZeyOS table"){let t=Number(i);if(!Number.isInteger(t)||t<0)throw new RangeError(`${e} page must be a non-negative integer`);return t}function yr(i,e="ZeyOS table"){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} filters must be an object`);return{...i}}function Xc(i,e={}){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ZeyOS appointment must be an object");let t=i.ID??i.id;if(t==null||t==="")throw new TypeError("ZeyOS appointment requires ID");let s=e?.timeZone,n=s==null||s===""?null:je(s),r=Me(i.datefrom),o=Me(i.dateto??i.datefrom);if(!(r instanceof Date)||!(o instanceof Date))throw new TypeError("ZeyOS appointment requires datefrom and dateto");let a=String(i.assoc_name??"").trim(),l=String(i.name??"").trim()||V("zeyosCalendar.untitled"),c=i.entity&&a?`${a}: ${l}`:l,d;if(n){let h=Jc(r,n),p=Jc(o,n);d=i.allDay!=null?!!i.allDay:!!(h&&p&&se(h,p)>=1),d&&h&&p&&(r=h,o=p)}else d=i.allDay!=null?!!i.allDay:Qc(r)&&Qc(o)&&se(r,o)>=1;return{id:String(i.occurrenceid??`${t}@${i.datefrom}`),title:c,start:r,end:o,allDay:d,color:Jg(i.color),location:String(i.location??"").trim(),editable:i.editable==null?null:!!i.editable,durationEditable:i.durationEditable==null?null:!!i.durationEditable,data:i}}function eu(i,e={}){if(!Array.isArray(i))throw new TypeError("ZeyOS appointments must be an array");return i.map(t=>Xc(t,e))}function Zg(i,e={}){if(!i||!(i.start instanceof Date)||!(i.end instanceof Date))throw new TypeError("Calendar event patch requires start and end Dates");let t=e?.timeZone,n=i.allDay===!0&&t!=null&&t!==""?{datefrom:Pe(i.start,t),dateto:Pe(i.end,t)}:{datefrom:ve(i.start),dateto:ve(i.end)};return i.data?.ID!=null?{ID:i.data.ID,...n}:n}function tu(i={}){let{appointments:e,timeZone:t,...s}=i;return{weekStart:1,optimistic:!0,...s,events:e==null?Array.isArray(s.events)?s.events:[]:eu(e,{timeZone:t})}}function Qg(i,e={}){return new Xt(i,tu(e))}function Jg(i){let e=String(i??"").trim();return e?/^[\da-f]{3,8}$/i.test(e)?`#${e}`:e:null}function Qc(i){return i.getHours()===0&&i.getMinutes()===0&&i.getSeconds()===0&&i.getMilliseconds()===0}function Jc(i,e){let{year:t,month:s,day:n}=e.dayOf(i.getTime());if(e.midnightOf(t,s,n)!==i.getTime())return null;let r=new Date(2e3,0,1);return r.setFullYear(t,s,n),r.setHours(0,0,0,0),r}var Xg=1,e_=new Set(["table","card","kanban"]),iu="1970-01-01T00:00:00.000Z",t_=new Set(["__proto__","constructor","prototype"]),i_=new Set(["cursor","data","offset","page","pagination","records","rows","selection","selectedRecords"]),St=class extends Error{constructor(e){super(`A saved view named "${e}" already exists`),this.name="SavedViewDuplicateNameError"}},Is=class extends Error{constructor(e,t){super(`Saved-view scope mismatch: expected ${At(e)}, received ${At(t)}`),this.name="SavedViewScopeMismatchError",this.expected={...e},this.actual={...t}}},Ds=class{constructor(e,t,s={}){if(!e||typeof e.load!="function"||typeof e.save!="function")throw new TypeError("SavedViewRegistry transport requires load() and save()");this.transport=e,this.scope=Os(t),this.options=o_(s),this._document=Sr(this.scope),this._loaded=!1,this._loading=null,this._loadSequence=0,this._mutation=Promise.resolve(),this._destroyed=!1}async ready(){return this.load()}async load(e={}){if(this._assertActive(),this._loaded&&!e.force)return this;if(this._loading&&!e.force)return await this._loading,this;let t=++this._loadSequence,s=Promise.resolve(this.transport.load({...this.scope})).then(n=>{if(this._assertActive(),t!==this._loadSequence)return;let r=xr(n,this.scope,this.options);this._document=r,this._loaded=!0});this._loading=s;try{await s}finally{this._loading===s&&(this._loading=null)}return this}async list(){return await this.ready(),this._document.views.map(xt)}async get(e){await this.ready();let t=Ms(this._document,e);return t?xt(t):null}async getDefault(){await this.ready();let e=this._document.views.find(t=>t.id===this._document.defaultId)??null;return e?xt(e):null}async save(e,t={}){return this._mutate(async s=>{let n=Cr(e?.name),r=Er(t.onDuplicate??this.options.duplicateNames),o=e?.id==null?null:zr(e.id),a=o?s.views.find(v=>v.id===o)??null:null,l=s.views.find(v=>ce(v.name)===ce(n))??null;if(a&&l&&a!==l&&r==="reject")throw new St(n);if(!a&&l&&r==="reject")throw new St(n);let c=a??(r==="replace"?l:null),d=r==="replace"&&a&&l!==a?l:null,h=this._now(),p=kr(e?.type??c?.type),f=Object.prototype.hasOwnProperty.call(e??{},"state")?lu(e.state):c?pe(c.state,"Saved view state"):null;if(!f)throw new TypeError("A new saved view requires state");let m=Object.prototype.hasOwnProperty.call(e??{},"filters")?cu(e.filters):c?pe(c.filters,"Saved view filters"):{},g=Object.prototype.hasOwnProperty.call(e??{},"search")?uu(e.search):c?.search??"",_=c?.createdAt??h,y=c?.id??o??this._createId(s,{name:n,type:p,createdAt:_}),b={id:y,name:n,type:p,state:f,filters:m,search:g,createdAt:_,updatedAt:h},w=s.views.filter(v=>v!==c&&v!==d&&v.id!==y);return w.push(b),s.views=Ar(w),d&&s.defaultId===d.id&&(s.defaultId=y),t.setDefault&&(s.defaultId=y),{changed:!0,result:b}})}async rename(e,t,s={}){return this._mutate(async n=>{let r=Ms(n,e);if(!r)return{changed:!1,result:null};let o=Cr(t);if(r.name===o)return{changed:!1,result:r};let a=n.views.find(c=>c!==r&&ce(c.name)===ce(o))??null,l=Er(s.onDuplicate??this.options.duplicateNames);if(a&&l==="reject")throw new St(o);return a&&(n.views=n.views.filter(c=>c!==a),n.defaultId===a.id&&(n.defaultId=r.id)),r.name=o,r.updatedAt=this._now(),n.views=Ar(n.views),{changed:!0,result:r}})}async remove(e){return this._mutate(async t=>{let s=Ms(t,e);return s?(t.views=t.views.filter(n=>n!==s),t.defaultId===s.id&&(t.defaultId=null),{changed:!0,removeDocument:t.views.length===0,result:!0}):{changed:!1,result:!1}})}async setDefault(e){return this._mutate(async t=>{if(e==null)return t.defaultId===null?{changed:!1,result:null}:(t.defaultId=null,{changed:!0,result:null});let s=Ms(t,e);return s?t.defaultId===s.id?{changed:!1,result:s}:(t.defaultId=s.id,{changed:!0,result:s}):{changed:!1,result:null}})}async capture(e,t,s={}){if(!e||typeof e.getViewState!="function")throw new TypeError("capture() requires a view with getViewState()");return this.save({...t,state:e.getViewState()},s)}async apply(e,t,s={}){let n=await this.get(e);if(!n)return{status:"missing",applied:!1,entry:null};if(s.type!=null){let r=kr(s.type);if(n.type!==r)return{status:"type-mismatch",applied:!1,entry:n,expectedType:n.type,currentType:r}}if(!t||typeof t.setViewState!="function")throw new TypeError("apply() requires a view with setViewState()");if(s.onQuery!=null&&typeof s.onQuery!="function")throw new TypeError("apply() onQuery must be a function");return t.setViewState(pe(n.state,"Saved view state")),s.onQuery&&await s.onQuery({filters:pe(n.filters,"Saved view filters"),search:n.search,entry:xt(n)}),{status:"applied",applied:!0,entry:n}}destroy(){this._destroyed=!0,this._loadSequence+=1,this._loading=null}_assertActive(){if(this._destroyed)throw new Error("SavedViewRegistry has been destroyed")}_now(){let e=this.options.clock(),t=e instanceof Date?e:new Date(e);if(!Number.isFinite(t.getTime()))throw new TypeError("Saved-view clock returned an invalid timestamp");return t.toISOString()}_createId(e,t){let s=this.options.idFactory?this.options.idFactory({scope:{...this.scope},...t}):`view-${du(`${At(this.scope)}\0${t.name}\0${t.type}\0${t.createdAt}`)}`,n=zr(s),r=new Set(e.views.map(a=>a.id));if(!r.has(n))return n;let o=2;for(;r.has(`${n}-${o}`);)o+=1;return`${n}-${o}`}_mutate(e){this._assertActive();let t=this._mutation.catch(()=>{}).then(async()=>{await this.ready();let s=su(this._document),n=await e(s);if(this._assertActive(),!n.changed)return nu(n.result);let r=xr(s,this.scope,this.options);return this._loadSequence+=1,n.removeDocument&&typeof this.transport.remove=="function"?(await this.transport.remove({...this.scope}),this._assertActive(),this._loadSequence+=1,this._document=Sr(this.scope)):(await this.transport.save({...this.scope},su(r)),this._assertActive(),this._loadSequence+=1,this._document=r),nu(n.result)});return this._mutation=t.then(()=>{},()=>{}),t}};function Ir(i,e,t={}){return new Ds(i,e,t)}function Os(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Saved-view scope must be an object");return{userId:Mr(i.userId,"userId"),workspaceId:a_(i.workspaceId),resource:Mr(i.resource,"resource")}}function xr(i,e,t={}){let s=Os(e);if(i==null)return Sr(s);let n=au(i,t.migrations);if(n.scope!=null){let p=Os(n.scope);if(At(p)!==At(s))throw new Is(s,p)}let o=(Array.isArray(n.views)?n.views:[]).map((p,f)=>n_(p,f,s)),a=r_(o),l=a.aliases,c=Ar(a.views),d=n.defaultId==null?null:String(n.defaultId),h=c.some(p=>p.id===d)?d:l.get(d)??null;return{version:1,scope:s,defaultId:c.some(p=>p.id===h)?h:null,views:c}}function au(i,e={}){let t=Array.isArray(i)?{version:0,savedViews:i}:pe(i,"Saved-view document"),s=ou(t.version);if(s>1)throw new RangeError(`Unsupported saved-view document version: ${s}`);for(;s<1;){let n=e?.[s]??(s===0?s_:null);if(typeof n!="function")throw new RangeError(`Missing saved-view migration from version ${s}`);t=pe(n(pe(t,"Saved-view document")),`Saved-view migration ${s}`);let r=ou(t.version);if(r<=s)throw new RangeError(`Saved-view migration ${s} did not advance the version`);s=r}return t}function s_(i){let t=(Array.isArray(i.savedViews)?i.savedViews:Array.isArray(i.entries)?i.entries:Array.isArray(i.views)?i.views:[]).map(s=>{let n=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return{id:n.id??null,name:n.name??n.label??"",type:n.type??n.presentation??n.view??"",state:n.state??n.viewState??{},filters:n.filters??n.filter??{},search:n.search??n.query??"",createdAt:n.createdAt??n.created??null,updatedAt:n.updatedAt??n.updated??null}});return{version:1,scope:i.scope??null,defaultId:i.defaultId??i.defaultView??i.default??null,views:t}}function n_(i,e,t){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`Saved view at index ${e} must be an object`);let s=i,n=Cr(s.name),r=kr(s.type),o=lu(s.state??{}),a=cu(s.filters??{}),l=uu(s.search),c=ru(s.createdAt),d=ru(s.updatedAt??c),h=d<c?c:d;return{id:s.id==null||String(s.id).trim()===""?`legacy-${du(`${At(t)}\0${n}\0${r}\0${e}`)}`:zr(s.id),name:n,type:r,state:o,filters:a,search:l,createdAt:c,updatedAt:h}}function r_(i){let e=[...i].sort((o,a)=>ni(a.updatedAt,o.updatedAt)||ni(o.id,a.id)),t=new Set,s=new Set,n=new Map,r=[];for(let o of e){let a=r.find(l=>l.id===o.id||ce(l.name)===ce(o.name));if(t.has(o.id)||s.has(ce(o.name))){a&&n.set(o.id,a.id);continue}t.add(o.id),s.add(ce(o.name)),r.push(o)}return{views:r,aliases:n}}function o_(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Saved-view registry options must be an object");if(i.clock!=null&&typeof i.clock!="function")throw new TypeError("Saved-view clock must be a function");if(i.idFactory!=null&&typeof i.idFactory!="function")throw new TypeError("Saved-view idFactory must be a function");return{...i,duplicateNames:Er(i.duplicateNames??"reject"),clock:i.clock??(()=>new Date)}}function Sr(i){return{version:1,scope:{...i},defaultId:null,views:[]}}function su(i){return{version:1,scope:{...i.scope},defaultId:i.defaultId,views:i.views.map(xt)}}function xt(i){return{...i,state:pe(i.state,"Saved view state"),filters:pe(i.filters,"Saved view filters")}}function nu(i){return l_(i)?xt(i):i}function Ms(i,e){if(typeof e!="string")return null;let t=e.trim();return t?i.views.find(s=>s.id===t)??i.views.find(s=>ce(s.name)===ce(t))??null:null}function Ar(i){return[...i].sort((e,t)=>ni(ce(e.name),ce(t.name))||ni(e.name,t.name)||ni(e.id,t.id))}function kr(i){if(typeof i!="string")throw new TypeError('Saved view type must be "table", "card", or "kanban"');let e=i.trim().toLowerCase();if(!e_.has(e))throw new TypeError('Saved view type must be "table", "card", or "kanban"');return e}function Cr(i){if(typeof i!="string")throw new TypeError("Saved view name must be a string");let e=i.normalize("NFKC").trim().replace(/\s+/g," ");if(!e)throw new TypeError("Saved view name cannot be empty");if(e.length>160)throw new RangeError("Saved view name cannot exceed 160 characters");return e}function ce(i){return i.normalize("NFKC").toLocaleLowerCase("en-US")}function zr(i){if(typeof i!="string")throw new TypeError("Saved view id must be a string");let e=i.normalize("NFKC").trim();if(!e)throw new TypeError("Saved view id cannot be empty");if(e.length>180)throw new RangeError("Saved view id cannot exceed 180 characters");return e}function Er(i){if(i!=="reject"&&i!=="replace")throw new TypeError('Duplicate saved-view policy must be "reject" or "replace"');return i}function lu(i){let e=pe(i,"Saved view state"),t=Number(e.version);if(!Number.isInteger(t)||t<1)throw new TypeError("Saved view state requires a positive integer version");e.version=t;for(let s of i_)if(Object.prototype.hasOwnProperty.call(e,s))throw new TypeError(`Saved view state cannot serialize ${s}`);return e}function cu(i){return pe(i??{},"Saved view filters")}function uu(i){if(i==null)return"";if(typeof i!="string")throw new TypeError("Saved view search must be a string");return i}function pe(i,e){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} must be a plain object`);return Tr(i,e,new WeakSet)}function Tr(i,e,t){if(i===null||typeof i=="string"||typeof i=="boolean")return i;if(typeof i=="number"){if(!Number.isFinite(i))throw new TypeError(`${e} cannot contain non-finite numbers`);return i}if(typeof i!="object")throw new TypeError(`${e} must be JSON-safe`);if(typeof i.nodeType=="number")throw new TypeError(`${e} cannot contain DOM nodes`);if(t.has(i))throw new TypeError(`${e} cannot contain cycles`);t.add(i);try{if(Array.isArray(i))return i.map(o=>Tr(o,e,t));let s=Object.getPrototypeOf(i);if(s!==Object.prototype&&s!==null)throw new TypeError(`${e} can contain only plain objects and arrays`);let n={},r=i;if(Object.getOwnPropertySymbols(i).length>0)throw new TypeError(`${e} cannot contain symbols`);for(let o of Object.keys(i).sort()){if(t_.has(o))throw new TypeError(`${e} cannot contain prototype-pollution keys`);let a=Object.getOwnPropertyDescriptor(r,o);if(!a||!Object.prototype.hasOwnProperty.call(a,"value"))throw new TypeError(`${e} cannot contain property accessors`);n[o]=Tr(a.value,e,t)}return n}finally{t.delete(i)}}function ru(i){if(i==null||i==="")return iu;let e=new Date(i);return Number.isFinite(e.getTime())?e.toISOString():iu}function ou(i){if(i==null)return 0;let e=Number(i);if(!Number.isInteger(e)||e<0)throw new TypeError("Saved-view document version must be a non-negative integer");return e}function Mr(i,e){if(typeof i!="string"&&typeof i!="number")throw new TypeError(`Saved-view scope ${e} must be a string or number`);let t=String(i).normalize("NFKC").trim();if(!t)throw new TypeError(`Saved-view scope ${e} cannot be empty`);return t}function a_(i){return i===null?null:Mr(i,"workspaceId")}function At(i){let e=i.workspaceId===null?"":`${i.workspaceId}`;return`${i.userId}\0${e}\0${i.resource}`}function ni(i,e){return i<e?-1:i>e?1:0}function l_(i){return!!(i&&typeof i=="object"&&"id"in i&&typeof i.id=="string")}function du(i){let e=2166136261;for(let t=0;t<i.length;t+=1)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return(e>>>0).toString(36)}var c_=["titleField","subtitleField","preview","previewAlt","link","actions","groupBy","groupOrder","columnBy","columns","swimlaneBy","swimlanes","moveMode","columnOrder","swimlaneOrder","collapsedColumns","collapsedSwimlanes","showCounts","showEmptyColumns","hiddenFields","fieldOrder","fieldControls","selectable","selection","emptyText"];function fu(i,e,t={}){let s=d_(i,e,t),n=wr(i,e,{fields:s,labels:t.labels,formats:t.formats,timeZone:t.timeZone,rowId:t.recordId??"ID",sort:t.sort??null}),r=t.fieldOverrides&&typeof t.fieldOverrides=="object"?t.fieldOverrides:{},o=Array.isArray(t.fields)?new Set(t.fields.map(String)):null,a=n.columns.map(d=>({...d,...o&&!o.has(d.id)?{visible:!1}:{},...r[d.id]??{},id:d.id})),l={...n.projection};for(let d of pu(t))Object.prototype.hasOwnProperty.call(l,d)||(l[d]=d);let c={...t.viewOptions??{}};for(let d of c_)Object.prototype.hasOwnProperty.call(t,d)&&(c[d]=t[d]);return Object.assign(c,{fields:a,data:[],recordId:t.recordId??"ID",sort:t.sort??null,sortMode:"server"}),typeof t.onRecordClick=="function"&&(c.onrecordclick=d=>t.onRecordClick(d.detail.record,d)),{fieldMeta:n.fieldMeta,fields:a,projection:l,viewOptions:c}}function u_(i,e,t,s={}){if(typeof t!="function")throw new TypeError("zeyosView() requires a view constructor");let n=fu(i,e,s),r=new t(s.target??null,n.viewOptions);for(let I of["setData","addData","setLoading","on","destroy"])if(typeof r?.[I]!="function"){try{r?.destroy?.()}catch{}throw new TypeError(`zeyosView() constructor must provide ${I}()`)}let o=ye(i),a;try{a=vr({client:i,facade:o,resource:e,projection:n.projection,target:r,pageSize:s.pageSize,sort:s.sort??null,filters:s.filters??{},search:s.search,searchFields:s.searchFields,label:"ZeyOS view"})}catch(I){throw r.destroy(),I}let l;try{l=p_(s.savedViews,t,e)}catch(I){throw r.destroy(),I}let c=l?.registry??null,d=l?.type??mu(t);if(c){for(let I of["getViewState","setViewState"])if(typeof r?.[I]!="function")throw l?.owned&&c.destroy?.(),r.destroy(),new TypeError(`zeyosView() saved views require ${I}()`)}let h=!1,p=a.load,f=!1,m=async(I,F={})=>{if(!c||!d)throw new Error("This ZeyOS view binding has no saved-view registry");if(h)throw new Error("ZeyOS view binding has been destroyed");let j=await c.apply(I,r,{type:d,onQuery:async({filters:X,search:tt})=>{h||a.setQuery({filters:f_(X),search:tt})}});return!j.applied||h||(a.setSort(__(r,j.entry)),a.reset(),F.load!==!1&&await p({page:0})),j},g=async(I={},F=()=>{})=>{if(!c)return null;try{await g_(c)}catch(j){if(!h&&(F(),s.savedViewFallback==="baseline"))try{o.reportError(j,{operation:"savedViews.read",resource:e})}catch{}throw j}if(h)throw new Error("ZeyOS view binding has been destroyed");try{let j=await c.getDefault();if(h)throw new Error("ZeyOS view binding has been destroyed");return j?await m(j.id,I):{status:"missing",applied:!1,entry:null}}catch(j){throw f=!0,j}},_=c?g({load:!1}):Promise.resolve(null),y=!c,b=null;_.then(()=>{y=!0},()=>{});let w=async(I={load:!1},F=!1)=>{if(h)throw new Error("ZeyOS view binding has been destroyed");if(y)return null;try{let X=await _;return y=!0,X}catch{}if(h)throw new Error("ZeyOS view binding has been destroyed");if(!b){let X={readFailed:!1,promise:null},tt=g(I,()=>{X.readFailed=!0}).then(yu=>(y=!0,yu));X.promise=tt.finally(()=>{b===X&&(b=null)}),b=X}let j=b;try{return await j.promise}catch(X){if(F&&s.savedViewFallback==="baseline"&&j.readFailed&&!f&&!h)return null;throw X}},v=async(I={})=>(a.check(I),await w({load:!1},!0),p(I)),A=I=>{if(h)throw new Error("ZeyOS view binding has been destroyed");if(c&&!y)throw new Error("Saved-view initialization has not succeeded");if(!d||typeof r.getViewState!="function")throw new Error("This view does not expose serializable saved-view state");let F=I&&typeof I=="object"?I:{};return{...F.id==null?{}:{id:String(F.id)},name:String(F.name??""),type:d,state:r.getViewState(),filters:a.filters,search:a.search}},S=async I=>{if(!c||!d)throw new Error("This ZeyOS view binding has no saved-view registry");if(await w({load:!1}),h)throw new Error("ZeyOS view binding has been destroyed");let F=A(I);return await c.capture(r,{...F.id==null?{}:{id:F.id},name:F.name,type:d,filters:F.filters,search:F.search},{onDuplicate:I?.onDuplicate,setDefault:!!I?.setDefault})},M=async(I,F={})=>(await w({load:!1}),m(I,F)),L=async(I={})=>y?g(I):w(I),J=I=>{if(h)return;let F=I.detail?.id;a.setSort(F==null?null:{id:String(F),dir:I.detail.dir==="desc"?"desc":"asc"}),v({page:0}).catch(()=>{})},ue={view:r,load:v,setSearch:I=>v({search:I,page:0}),setFilters:I=>v({filters:I,page:0}),loadMore:async()=>(await w({load:!1},!0),a.loadMore()),get count(){return a.count},get page(){return a.page},get pageSize(){return a.pageSize},get hasMore(){return a.hasMore},savedViews:c,ready:_,restoreDefault:L,captureView:A,saveView:S,applyView:M,destroy:()=>{h||(h=!0,a.destroy(),typeof r.off=="function"?r.off("sortchange",J):r.removeEventListener?.("sortchange",J),l?.owned&&c?.destroy?.(),r.destroy())}};return r.on("sortchange",J),ue}function d_(i,e,t){if(!Array.isArray(t.fields)&&!Array.isArray(t.exclude))return;let s=new Set(Array.isArray(t.exclude)?t.exclude.map(String):[]),n=Array.isArray(t.fields)?t.fields.map(String):h_(i,e);return[...new Set([...n,...pu(t)])].filter(r=>!s.has(r))}function h_(i,e){let t=i?.schema?.fields?.(e);return Array.isArray(t)?t.map(s=>typeof s=="string"?s:String(s?.id??s?.name??s?.field??"")).filter(Boolean):t&&typeof t=="object"?Object.keys(t):[]}function pu(i){let e=[];for(let t of["titleField","subtitleField","preview","groupBy","columnBy","swimlaneBy"]){let s=i[t];typeof s=="string"&&s.trim()&&e.push(s.trim())}return[...new Set(e)]}function f_(i){return i&&typeof i=="object"&&!Array.isArray(i)?{...i}:{}}function p_(i,e,t){if(i==null||i===!1)return null;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("savedViews must be a registry or transport/scope configuration");let s=i,n=s.controller??s.registry,r=hu(s)?s:hu(n)?n:null,o=m_(s.type??mu(e));if(!o)throw new TypeError("savedViews requires a table, card, or kanban presentation type");if(r)return{registry:r,type:o,owned:!1};if(!s.transport||!s.scope||typeof s.scope!="object")throw new TypeError("savedViews requires a controller or injected transport and scope");let a={...s.scope,resource:s.scope.resource??t};return{registry:Ir(s.transport,a,s.options??{}),type:o,owned:!0}}function hu(i){return!!(i&&typeof i=="object"&&typeof i.apply=="function"&&typeof i.capture=="function"&&typeof i.getDefault=="function")}function mu(i){let e=String(i.cssName??"").toLowerCase().replace(/-view$/,"");if(["table","card","kanban"].includes(e))return e;let t=String(i.name??"").toLowerCase().replace(/view$/,"");return["table","card","kanban"].includes(t)?t:null}function m_(i){let e=String(i??"").toLowerCase();return["table","card","kanban"].includes(e)?e:null}async function g_(i){typeof i.ready=="function"?await i.ready():typeof i.load=="function"&&await i.load()}function __(i,e){let t=typeof i.getSort=="function"?i.getSort():typeof i.getViewState=="function"?i.getViewState()?.sort:e?.state?.sort;return!t||typeof t!="object"||Array.isArray(t)||t.id==null?null:{id:String(t.id),dir:t.dir==="desc"?"desc":"asc"}}function b_(i){if(typeof i!="function")throw new TypeError("Legacy saved-view loader must be a function");return e=>new Promise((t,s)=>{i(e,t,(n,r,o)=>{let a=new Error(String(n??"ZeyOS saved-view request failed"));return Object.assign(a,{type:r,info:o}),s(a),!0})})}function y_(i,e={}){if(typeof i!="function")throw new TypeError("Saved-view request must be a function");let t=gu(e.recordName,"__zx_record_views_v1__","recordName"),s=gu(e.viewPrefix,"zx.record-views:","viewPrefix"),n=e.module==null?"":String(e.module),r=(o,a)=>{let l=w_(o);return{umi:n,page:a,fork:l.workspaceId,view:`${s}${l.resource}`}};return{async load(o){let a=await i(r(o,"fields")),l=v_(a,t);if(l==null||l==="")return null;if(typeof l=="string")try{let c=JSON.parse(l);return Ns(c)?c:null}catch{return null}return Ns(l)?_u(l):null},async save(o,a){if(!Ns(a))throw new TypeError("Saved-view document must be an object");let l=_u(a);return await i({...r(o,"fields_save"),name:t,data:JSON.stringify(l)}),l},async remove(o){await i({...r(o,"fields_remove"),name:t})}}}function w_(i){if(!Ns(i))throw new TypeError("Saved-view scope must be an object");if(i.userId==null||String(i.userId).trim()==="")throw new TypeError("Saved-view scope requires userId");let e=String(i.resource??"").trim();if(!e)throw new TypeError("Saved-view scope requires resource");let t=i.workspaceId==null||i.workspaceId===""?null:i.workspaceId;return{userId:String(i.userId),workspaceId:t,resource:e}}function v_(i,e){if(!Array.isArray(i)||!Array.isArray(i[0])||!Array.isArray(i[1]))return null;let t=i[0].findIndex(s=>String(s)===e);return t<0?null:i[1][t]}function gu(i,e,t){let s=i==null?e:String(i).trim();if(!s)throw new TypeError(`${t} must not be empty`);return s}function Ns(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function _u(i){bu(i,new Set);try{return JSON.parse(JSON.stringify(i))}catch{throw new TypeError("Saved-view document must be JSON-serializable")}}function bu(i,e){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"&&Number.isFinite(i))return;if(typeof i!="object")throw new TypeError("Saved-view document must be JSON-serializable");if(e.has(i))throw new TypeError("Saved-view document must be JSON-serializable");if(!Array.isArray(i)&&Object.getPrototypeOf(i)!==Object.prototype&&Object.getPrototypeOf(i)!==null)throw new TypeError("Saved-view document must be JSON-serializable");e.add(i);let t=Array.isArray(i)?i:Object.values(i);for(let s of t)bu(s,e);e.delete(i)}export{Xg as SAVED_VIEWS_VERSION,St as SavedViewDuplicateNameError,Ds as SavedViewRegistry,Is as SavedViewScopeMismatchError,jc as ZEYOS_ICON_KIT,vg as ZEYOS_LAUNCHER_APPLICATIONS,Ct as buildListQuery,Cg as buildZeyosAppSidebarConfig,tu as buildZeyosCalendarOptions,Uc as buildZeyosEntitySelectConfig,Vc as buildZeyosLauncherConfig,qc as buildZeyosModuleBarConfig,si as buildZeyosSelectConfig,fu as buildZeyosViewConfig,Pe as calendarDayToUnixSeconds,Zg as calendarEventToZeyosPatch,ye as connect,y_ as createLegacySavedViewTransport,Ir as createSavedViewRegistry,ku as dataFilterStateToFilters,ve as dateToUnixSeconds,$s as fieldToZxColumn,qs as fieldToZxField,b_ as legacySavedViewRequest,au as migrateSavedViewDocument,Pc as moduleAliases,vt as moduleChip,mg as moduleColor,yg as moduleGlyphColor,Cs as moduleIcon,gg as moduleIconName,le as moduleInfo,_g as moduleKeys,ks as normalizeModuleName,xr as normalizeSavedViewDocument,Os as normalizeSavedViewScope,Bc as normalizeZeyosLauncherApplications,zs as normalizeZeyosLauncherRecords,Q as registerFieldType,bg as registerModules,zt as resolveFields,Vr as tableSortToQuery,Bs as unixSecondsToCalendarDay,Me as unixSecondsToDate,wg as useZeyosIcons,Sg as zeyosActiveIdentifier,hr as zeyosAppIcon,Xc as zeyosAppointmentToEvent,eu as zeyosAppointmentsToEvents,Qg as zeyosCalendar,Tg as zeyosEntitySelect,Ng as zeyosForm,xg as zeyosLauncher,zg as zeyosModuleBar,gr as zeyosModuleItems,et as zeyosModules,Eg as zeyosSelect,qg as zeyosTable,u_ as zeyosView};
|
|
9
9
|
/*
|
|
10
10
|
* @license Lucide 1.53.0 (ISC), including icons derived from Feather (MIT) — notices below.
|
|
11
11
|
*
|