@webority/ui-elements 0.183.0 → 0.184.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.
Files changed (73) hide show
  1. package/README.md +1 -1
  2. package/dist/{WuiSelect-DIW_WXH7.js → WuiSelect-B0CT2utp.js} +1 -1
  3. package/dist/{chips-paLEDoxn.js → chips-DxSWAJDI.js} +1 -1
  4. package/dist/drawerDiscard-CBUOklnA.js +1 -0
  5. package/dist/elements/select.js +1 -1
  6. package/dist/{loader-DUCcKxjq.js → loader-X2uBXCDm.js} +1 -1
  7. package/dist/{search-C46tnoPd.js → search-DLRWJomU.js} +1 -1
  8. package/dist/server.js +1 -1
  9. package/dist/ui-elements/calendar-views.global.js +1 -1
  10. package/dist/ui-elements/carousel.global.js +1 -1
  11. package/dist/ui-elements/code-block.global.js +1 -1
  12. package/dist/ui-elements/command-palette.global.js +1 -1
  13. package/dist/ui-elements/comment-thread.global.js +1 -1
  14. package/dist/ui-elements/consent-banner.global.js +1 -1
  15. package/dist/ui-elements/context-menu.global.js +1 -1
  16. package/dist/ui-elements/dashboard-grid.global.js +1 -1
  17. package/dist/ui-elements/data-table.global.js +1 -1
  18. package/dist/ui-elements/date-range.global.js +1 -1
  19. package/dist/ui-elements/date-time.global.js +1 -1
  20. package/dist/ui-elements/datepicker.global.js +1 -1
  21. package/dist/ui-elements/dock.global.js +1 -1
  22. package/dist/ui-elements/drawer.global.js +1 -1
  23. package/dist/ui-elements/dropdown.global.js +1 -1
  24. package/dist/ui-elements/entry-grid.global.js +1 -1
  25. package/dist/ui-elements/gantt.global.js +1 -1
  26. package/dist/ui-elements/glyphs.global.js +1 -1
  27. package/dist/ui-elements/hover-card.global.js +1 -1
  28. package/dist/ui-elements/image-crop.global.js +1 -1
  29. package/dist/ui-elements/inline-edit.global.js +1 -1
  30. package/dist/ui-elements/kanban.global.js +1 -1
  31. package/dist/ui-elements/lead-popup.global.js +1 -1
  32. package/dist/ui-elements/lightbox.global.js +1 -1
  33. package/dist/ui-elements/markdown.global.js +1 -1
  34. package/dist/ui-elements/mini-calendar.global.js +1 -1
  35. package/dist/ui-elements/navigation-menu.global.js +1 -1
  36. package/dist/ui-elements/notification-center.global.js +1 -1
  37. package/dist/ui-elements/offline-banner.global.js +1 -1
  38. package/dist/ui-elements/onboarding-checklist.global.js +1 -1
  39. package/dist/ui-elements/org-tree.global.js +1 -1
  40. package/dist/ui-elements/otp.global.js +1 -1
  41. package/dist/ui-elements/overflow.global.js +1 -1
  42. package/dist/ui-elements/phone.global.js +1 -1
  43. package/dist/ui-elements/popover.global.js +1 -1
  44. package/dist/ui-elements/rating.global.js +1 -1
  45. package/dist/ui-elements/record-pager.global.js +1 -1
  46. package/dist/ui-elements/relative-time.global.js +1 -1
  47. package/dist/ui-elements/saved-views.global.js +1 -1
  48. package/dist/ui-elements/select-chips.global.js +1 -1
  49. package/dist/ui-elements/select-recents.global.js +1 -1
  50. package/dist/ui-elements/select-search.global.js +1 -1
  51. package/dist/ui-elements/select-window.global.js +1 -1
  52. package/dist/ui-elements/server.global.js +1 -1
  53. package/dist/ui-elements/shell.global.js +1 -1
  54. package/dist/ui-elements/shortcuts.global.js +1 -1
  55. package/dist/ui-elements/show-more.global.js +1 -1
  56. package/dist/ui-elements/slider.global.js +1 -1
  57. package/dist/ui-elements/sortable.global.js +1 -1
  58. package/dist/ui-elements/status-icon.global.js +1 -1
  59. package/dist/ui-elements/table-export.global.js +1 -1
  60. package/dist/ui-elements/timepicker.global.js +1 -1
  61. package/dist/ui-elements/tour.global.js +1 -1
  62. package/dist/ui-elements/tree-picker.global.js +1 -1
  63. package/dist/ui-elements/tree.global.js +1 -1
  64. package/dist/ui-elements/truncate.global.js +1 -1
  65. package/dist/ui-elements/whats-new.global.js +1 -1
  66. package/dist/ui-elements/wizard.global.js +1 -1
  67. package/dist/ui-elements.global.js +1 -1
  68. package/dist/ui-elements.js +1 -1
  69. package/package.json +5 -5
  70. package/types/global/shared.d.ts +2 -0
  71. package/types/server/serverActions.d.ts +3 -0
  72. package/types/server/wuiUpload.d.ts +6 -4
  73. package/dist/drawerDiscard-D_LMpaFv.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./elementBase-Cxeyx0tU.js";import{n as ee}from"./filterPopover-DskHFNLi.js";import{t}from"./kanban-Dayig7ic.js";import{n}from"./statusIcons-Cd3GJcBR.js";import{t as r}from"./WuiCalendarViews-Dg9yRY1I.js";import{t as i}from"./WuiCarousel-B0yPDH5I.js";import{t as te}from"./WuiCodeBlock-BWYZ1S70.js";import{t as a}from"./WuiCommandPalette-CpmlKjzH.js";import{t as o}from"./WuiCommentThread-Cp7AVHvt.js";import{t as s}from"./WuiConsentBanner-nTua-kEd.js";import{t as c}from"./WuiContextMenu-oKlQvt3V.js";import{r as l}from"./WuiDashboardGrid-DFpX8Vx0.js";import{t as u}from"./WuiDataTable-CSgcwxU5.js";import{t as d}from"./WuiDatePicker-CRqjwyf2.js";import{t as f}from"./WuiDateRange-BBm_Q69p.js";import{t as p}from"./WuiDateTime-Vimu6grS.js";import{t as m}from"./WuiDock-2LGlbEFx.js";import{t as h}from"./WuiDrawer-BsY0fs_u.js";import{t as g}from"./WuiDropdown-6g074v1T.js";import{t as _}from"./WuiEntryGrid-Z69-1YBh.js";import{t as v}from"./WuiGantt-DvmVKJX2.js";import{t as y}from"./WuiHoverCard-DhJcIIM1.js";import{t as b}from"./WuiImageCrop-UakcSM2k.js";import{t as x}from"./WuiInlineEdit-JT83k3Nk.js";import{t as S}from"./WuiLeadPopup-DaYZ2zCJ.js";import{t as C}from"./WuiLightbox-DpHJAMO3.js";import{t as w}from"./WuiMarkdown-DRtGPxQX.js";import{r as T}from"./WuiMentionInput-DPCCSQRZ.js";import{t as E}from"./WuiMiniCalendar-BhUTIGwe.js";import{t as D}from"./WuiModal-DQbVJGUo.js";import{t as O}from"./WuiNavigationMenu-KdW7yuLn.js";import{t as k}from"./WuiNotificationCenter-D5bBM8Lp.js";import{t as A}from"./WuiOfflineBanner-DGTFCtyM.js";import{t as j}from"./WuiOnboardingChecklist-C-nllg2h.js";import{t as M}from"./WuiOrgTree-DWSk_LHd.js";import{t as N}from"./WuiOtp-Cc0formv.js";import{t as P}from"./WuiOverflow-fZKqdsr-.js";import{t as F}from"./WuiPhone-B5ZLabTY.js";import{t as I}from"./WuiPopover-BvWKRNQY.js";import{t as L}from"./WuiRating-DIQfif9x.js";import{t as R}from"./WuiRecordPager-BXoe4KfU.js";import{t as z}from"./WuiRelativeTime-CSg9vzfk.js";import{t as B}from"./WuiSavedViews-CH7IvwgZ.js";import{t as V}from"./WuiSelect-DIW_WXH7.js";import{t as H}from"./WuiShortcuts-CRCctX82.js";import{t as U}from"./WuiShowMore-BoYCrYYf.js";import{t as W}from"./WuiSlider-CK7_l_R5.js";import{t as G}from"./WuiSortable-x8Mg0tOv.js";import{t as K}from"./WuiTimePicker-BKFPf8Fn.js";import{t as q}from"./WuiTour-BgpMa8J5.js";import{t as J}from"./WuiTree-Db83Uztv.js";import{t as Y}from"./WuiTreePicker-DLddmEgG.js";import{t as X}from"./WuiTruncate-BB4i8wHE.js";import{n as Z,t as ne}from"./WuiWhatsNew-Dm4Yl68x.js";import{n as Q,t as $}from"./WuiWizardStep-BBkw94dD.js";import{c as re,f as ie,l as ae,m as oe,p as se,s as ce,u as le}from"./formatters-DTW53DjY.js";import{_ as ue,r as de}from"./themeTransition-C5nAlClG.js";import{t as fe}from"./drawerDiscard-D_LMpaFv.js";import{n as pe}from"./shortcutKeys-BMTWgV2g.js";function me(){ee(),e(`wui-select`,V),e(`wui-saved-views`,B),e(`wui-phone`,F),e(`wui-datepicker`,d),e(`wui-mini-calendar`,E),e(`wui-date-range`,f),e(`wui-date-time`,p),e(`wui-dock`,m),e(`wui-image-crop`,b),e(`wui-kanban`,t),e(`wui-dashboard-grid`,l),e(`wui-lead-popup`,S),e(`wui-inline-edit`,x),e(`wui-consent-banner`,s),e(`wui-slider`,W),e(`wui-sortable`,G),e(`wui-timepicker`,K),e(`wui-tour`,q),e(`wui-tree`,J),e(`wui-tree-picker`,Y),e(`wui-org-tree`,M),e(`wui-command-palette`,a),e(`wui-context-menu`,c),e(`wui-otp`,N),e(`wui-status-icon`,n),e(`wui-shortcuts`,H),e(`wui-record-pager`,R),e(`wui-carousel`,i),e(`wui-code-block`,te),e(`wui-markdown`,w),e(`wui-modal`,D),e(`wui-data-table`,u),e(`wui-drawer`,h),e(`wui-dropdown`,g),e(`wui-entry-grid`,_),e(`wui-gantt`,v),e(`wui-hover-card`,y),e(`wui-lightbox`,C),e(`wui-navigation-menu`,O),e(`wui-notification-center`,k),e(`wui-onboarding-checklist`,j),e(`wui-overflow`,P),e(`wui-popover`,I),e(`wui-rating`,L),e(`wui-relative-time`,z),e(`wui-show-more`,U),e(`wui-calendar-views`,r),e(`wui-truncate`,X),e(`wui-whats-new`,Z),e(`wui-offline-banner`,A),e(`wui-mention-input`,T),e(`wui-comment-thread`,o),e(`wui-wizard-step`,$),e(`wui-wizard`,Q)}me();export{fe as DISCARD_EVENT,ue as ROW_DROP_EVENT,pe as SHORTCUT_EVENT,de as THEME_CHANGE_EVENT,ne as WHATS_NEW_READ_EVENT,r as WuiCalendarViews,i as WuiCarousel,te as WuiCodeBlock,a as WuiCommandPalette,o as WuiCommentThread,s as WuiConsentBanner,c as WuiContextMenu,l as WuiDashboardGrid,u as WuiDataTable,d as WuiDatePicker,f as WuiDateRange,p as WuiDateTime,m as WuiDock,h as WuiDrawer,g as WuiDropdown,_ as WuiEntryGrid,v as WuiGantt,y as WuiHoverCard,b as WuiImageCrop,x as WuiInlineEdit,t as WuiKanban,S as WuiLeadPopup,C as WuiLightbox,w as WuiMarkdown,T as WuiMentionInput,E as WuiMiniCalendar,D as WuiModal,O as WuiNavigationMenu,k as WuiNotificationCenter,A as WuiOfflineBanner,j as WuiOnboardingChecklist,M as WuiOrgTree,N as WuiOtp,P as WuiOverflow,F as WuiPhone,I as WuiPopover,L as WuiRating,R as WuiRecordPager,z as WuiRelativeTime,B as WuiSavedViews,V as WuiSelect,H as WuiShortcuts,U as WuiShowMore,W as WuiSlider,G as WuiSortable,n as WuiStatusIcon,K as WuiTimePicker,q as WuiTour,J as WuiTree,Y as WuiTreePicker,X as WuiTruncate,Z as WuiWhatsNew,Q as WuiWizard,$ as WuiWizardStep,me as defineWeborityElements,ce as formatCompact,re as formatCurrency,ae as formatDate,le as formatDateTime,ie as formatNumber,se as formatPercent,oe as formatValue};
1
+ import{n as e}from"./elementBase-Cxeyx0tU.js";import{n as ee}from"./filterPopover-DskHFNLi.js";import{t}from"./kanban-Dayig7ic.js";import{n}from"./statusIcons-Cd3GJcBR.js";import{t as r}from"./WuiCalendarViews-Dg9yRY1I.js";import{t as i}from"./WuiCarousel-B0yPDH5I.js";import{t as te}from"./WuiCodeBlock-BWYZ1S70.js";import{t as a}from"./WuiCommandPalette-CpmlKjzH.js";import{t as o}from"./WuiCommentThread-Cp7AVHvt.js";import{t as s}from"./WuiConsentBanner-nTua-kEd.js";import{t as c}from"./WuiContextMenu-oKlQvt3V.js";import{r as l}from"./WuiDashboardGrid-DFpX8Vx0.js";import{t as u}from"./WuiDataTable-CSgcwxU5.js";import{t as d}from"./WuiDatePicker-CRqjwyf2.js";import{t as f}from"./WuiDateRange-BBm_Q69p.js";import{t as p}from"./WuiDateTime-Vimu6grS.js";import{t as m}from"./WuiDock-2LGlbEFx.js";import{t as h}from"./WuiDrawer-BsY0fs_u.js";import{t as g}from"./WuiDropdown-6g074v1T.js";import{t as _}from"./WuiEntryGrid-Z69-1YBh.js";import{t as v}from"./WuiGantt-DvmVKJX2.js";import{t as y}from"./WuiHoverCard-DhJcIIM1.js";import{t as b}from"./WuiImageCrop-UakcSM2k.js";import{t as x}from"./WuiInlineEdit-JT83k3Nk.js";import{t as S}from"./WuiLeadPopup-DaYZ2zCJ.js";import{t as C}from"./WuiLightbox-DpHJAMO3.js";import{t as w}from"./WuiMarkdown-DRtGPxQX.js";import{r as T}from"./WuiMentionInput-DPCCSQRZ.js";import{t as E}from"./WuiMiniCalendar-BhUTIGwe.js";import{t as D}from"./WuiModal-DQbVJGUo.js";import{t as O}from"./WuiNavigationMenu-KdW7yuLn.js";import{t as k}from"./WuiNotificationCenter-D5bBM8Lp.js";import{t as A}from"./WuiOfflineBanner-DGTFCtyM.js";import{t as j}from"./WuiOnboardingChecklist-C-nllg2h.js";import{t as M}from"./WuiOrgTree-DWSk_LHd.js";import{t as N}from"./WuiOtp-Cc0formv.js";import{t as P}from"./WuiOverflow-fZKqdsr-.js";import{t as F}from"./WuiPhone-B5ZLabTY.js";import{t as I}from"./WuiPopover-BvWKRNQY.js";import{t as L}from"./WuiRating-DIQfif9x.js";import{t as R}from"./WuiRecordPager-BXoe4KfU.js";import{t as z}from"./WuiRelativeTime-CSg9vzfk.js";import{t as B}from"./WuiSavedViews-CH7IvwgZ.js";import{t as V}from"./WuiSelect-B0CT2utp.js";import{t as H}from"./WuiShortcuts-CRCctX82.js";import{t as U}from"./WuiShowMore-BoYCrYYf.js";import{t as W}from"./WuiSlider-CK7_l_R5.js";import{t as G}from"./WuiSortable-x8Mg0tOv.js";import{t as K}from"./WuiTimePicker-BKFPf8Fn.js";import{t as q}from"./WuiTour-BgpMa8J5.js";import{t as J}from"./WuiTree-Db83Uztv.js";import{t as Y}from"./WuiTreePicker-DLddmEgG.js";import{t as X}from"./WuiTruncate-BB4i8wHE.js";import{n as Z,t as ne}from"./WuiWhatsNew-Dm4Yl68x.js";import{n as Q,t as $}from"./WuiWizardStep-BBkw94dD.js";import{c as re,f as ie,l as ae,m as oe,p as se,s as ce,u as le}from"./formatters-DTW53DjY.js";import{_ as ue,r as de}from"./themeTransition-C5nAlClG.js";import{t as fe}from"./drawerDiscard-CBUOklnA.js";import{n as pe}from"./shortcutKeys-BMTWgV2g.js";function me(){ee(),e(`wui-select`,V),e(`wui-saved-views`,B),e(`wui-phone`,F),e(`wui-datepicker`,d),e(`wui-mini-calendar`,E),e(`wui-date-range`,f),e(`wui-date-time`,p),e(`wui-dock`,m),e(`wui-image-crop`,b),e(`wui-kanban`,t),e(`wui-dashboard-grid`,l),e(`wui-lead-popup`,S),e(`wui-inline-edit`,x),e(`wui-consent-banner`,s),e(`wui-slider`,W),e(`wui-sortable`,G),e(`wui-timepicker`,K),e(`wui-tour`,q),e(`wui-tree`,J),e(`wui-tree-picker`,Y),e(`wui-org-tree`,M),e(`wui-command-palette`,a),e(`wui-context-menu`,c),e(`wui-otp`,N),e(`wui-status-icon`,n),e(`wui-shortcuts`,H),e(`wui-record-pager`,R),e(`wui-carousel`,i),e(`wui-code-block`,te),e(`wui-markdown`,w),e(`wui-modal`,D),e(`wui-data-table`,u),e(`wui-drawer`,h),e(`wui-dropdown`,g),e(`wui-entry-grid`,_),e(`wui-gantt`,v),e(`wui-hover-card`,y),e(`wui-lightbox`,C),e(`wui-navigation-menu`,O),e(`wui-notification-center`,k),e(`wui-onboarding-checklist`,j),e(`wui-overflow`,P),e(`wui-popover`,I),e(`wui-rating`,L),e(`wui-relative-time`,z),e(`wui-show-more`,U),e(`wui-calendar-views`,r),e(`wui-truncate`,X),e(`wui-whats-new`,Z),e(`wui-offline-banner`,A),e(`wui-mention-input`,T),e(`wui-comment-thread`,o),e(`wui-wizard-step`,$),e(`wui-wizard`,Q)}me();export{fe as DISCARD_EVENT,ue as ROW_DROP_EVENT,pe as SHORTCUT_EVENT,de as THEME_CHANGE_EVENT,ne as WHATS_NEW_READ_EVENT,r as WuiCalendarViews,i as WuiCarousel,te as WuiCodeBlock,a as WuiCommandPalette,o as WuiCommentThread,s as WuiConsentBanner,c as WuiContextMenu,l as WuiDashboardGrid,u as WuiDataTable,d as WuiDatePicker,f as WuiDateRange,p as WuiDateTime,m as WuiDock,h as WuiDrawer,g as WuiDropdown,_ as WuiEntryGrid,v as WuiGantt,y as WuiHoverCard,b as WuiImageCrop,x as WuiInlineEdit,t as WuiKanban,S as WuiLeadPopup,C as WuiLightbox,w as WuiMarkdown,T as WuiMentionInput,E as WuiMiniCalendar,D as WuiModal,O as WuiNavigationMenu,k as WuiNotificationCenter,A as WuiOfflineBanner,j as WuiOnboardingChecklist,M as WuiOrgTree,N as WuiOtp,P as WuiOverflow,F as WuiPhone,I as WuiPopover,L as WuiRating,R as WuiRecordPager,z as WuiRelativeTime,B as WuiSavedViews,V as WuiSelect,H as WuiShortcuts,U as WuiShowMore,W as WuiSlider,G as WuiSortable,n as WuiStatusIcon,K as WuiTimePicker,q as WuiTour,J as WuiTree,Y as WuiTreePicker,X as WuiTruncate,Z as WuiWhatsNew,Q as WuiWizard,$ as WuiWizardStep,me as defineWeborityElements,ce as formatCompact,re as formatCurrency,ae as formatDate,le as formatDateTime,ie as formatNumber,se as formatPercent,oe as formatValue};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/ui-elements",
3
- "version": "0.183.0",
3
+ "version": "0.184.0",
4
4
  "description": "Webority framework-agnostic UI custom elements (<wui-*>): the single implementation of the interactive components, styled by @webority/theme. Used natively in Razor and wrapped by @webority/ui-react.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -295,10 +295,10 @@
295
295
  "@tiptap/starter-kit": "3.31.4",
296
296
  "@types/node": "25.6.0",
297
297
  "@vitest/coverage-v8": "5.1.0",
298
- "@webority/biome-config": "0.183.0",
299
- "@webority/markdown-core": "0.183.0",
300
- "@webority/theme": "0.183.0",
301
- "@webority/web-core": "0.183.0",
298
+ "@webority/biome-config": "0.184.0",
299
+ "@webority/markdown-core": "0.184.0",
300
+ "@webority/theme": "0.184.0",
301
+ "@webority/web-core": "0.184.0",
302
302
  "echarts": "6.1.0",
303
303
  "jsdom": "30.1.1",
304
304
  "libphonenumber-js": "^1.13.9",
@@ -38,6 +38,7 @@ import * as toastAction from "../server/toastAction.ts";
38
38
  import * as toastHeader from "../server/toastHeader.ts";
39
39
  import * as wuiHost from "../server/wuiHost.ts";
40
40
  import * as wuiHttp from "../server/wuiHttp.ts";
41
+ import * as wuiUpload from "../server/wuiUpload.ts";
41
42
  import * as shortcutKeys from "../shortcutKeys.ts";
42
43
  import * as stepperHeader from "../stepperHeader.ts";
43
44
  import * as svgNodes from "../svgNodes.ts";
@@ -115,6 +116,7 @@ export interface SharedModules {
115
116
  readonly tooltips: typeof tooltips;
116
117
  readonly wuiHost: typeof wuiHost;
117
118
  readonly wuiHttp: typeof wuiHttp;
119
+ readonly wuiUpload: typeof wuiUpload;
118
120
  readonly WuiSelect: typeof WuiSelect;
119
121
  readonly zone: typeof zone;
120
122
  }
@@ -22,10 +22,13 @@ export interface PostActionOptions {
22
22
  refresh?: boolean;
23
23
  toast?: boolean;
24
24
  timeoutMs?: number;
25
+ /** Called as the request body uploads; when given, the post goes through XMLHttpRequest, because fetch cannot report upload progress. Needs a FormData body and the POST method. totalBytes is 0 when the browser cannot size the body. */
26
+ onUploadProgress?: ((loadedBytes: number, totalBytes: number) => void) | undefined;
25
27
  }
26
28
  /**
27
29
  * Posts to url with the antiforgery token and settles it. Resolves with the answer's JSON, its HTML fragment or null;
28
30
  * rejects with a WuiPostError on any refusal or failure. The answer's refresh applies unless refresh is false.
31
+ * With onUploadProgress it sends through XMLHttpRequest and reports upload progress; the answer is settled the same way.
29
32
  */
30
33
  export declare function postAction(url: string, options?: PostActionOptions): Promise<unknown>;
31
34
  /** Wire the delegated confirm and post listeners once per document. */
@@ -1,11 +1,13 @@
1
1
  import { type WuiResult } from "./wuiHttp.ts";
2
2
  export interface WuiUploadOptions {
3
3
  /** Called from the upload progress events; totalBytes is 0 when the browser cannot size the body. */
4
- onProgress?: (loadedBytes: number, totalBytes: number) => void;
5
- signal?: AbortSignal;
4
+ onProgress?: ((loadedBytes: number, totalBytes: number) => void) | undefined;
5
+ signal?: AbortSignal | undefined;
6
6
  /** Milliseconds from sending to the answer. Undefined means no limit: a large part can take minutes. */
7
- timeoutMs?: number;
8
- headers?: Record<string, string>;
7
+ timeoutMs?: number | undefined;
8
+ headers?: Record<string, string> | undefined;
9
+ /** Replaces the session-expiry navigation (tests, or a host that wants to show a "signed out" notice first). */
10
+ navigate?: ((url: string) => void) | undefined;
9
11
  }
10
12
  /**
11
13
  * POST `body` to `url` and settle as a classified result, like wuiFetch; never rejects for an HTTP or network
@@ -1 +0,0 @@
1
- import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{i as n,n as r,r as i,t as a}from"./dom-DMQu--xV.js";import{t as o}from"./loader-DUCcKxjq.js";import{r as s}from"./textStore-DBplASiZ.js";import{t as c}from"./drawer.g-B-zYKBfQ.js";import{i as l,n as u,r as d,t as f}from"./toast.g-CJ8c0BNZ.js";import{N as p}from"./dataTable-C0q14bkP.js";import{n as ee,t as m}from"./devWarn-DXdRWZs3.js";import{t as h}from"./httpFailure.g-DjZzGxPj.js";import{_ as g,a as te,b as ne,c as re,d as ie,f as ae,i as oe,l as se,o as ce,r as le,s as ue,t as de,u as fe,x as _,y as pe}from"./refreshAfter-DhYgWXmQ.js";import{t as me}from"./hasOwn-CJsplJ62.js";import{t as he}from"./svgNodes-CyPS2oFH.js";import{t as ge}from"./serverHtml-BC6tAyAl.js";import{h as _e,l as ve,m as v,p as ye}from"./wuiHttp-8CYWEbRz.js";var y=class extends Error{code;status;html;body;kind;constructor(e,t){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`WuiPostError`,this.code=t.code,this.status=t.status,this.html=t.html,this.body=t.body,this.kind=t.kind}},be=/* @__PURE__ */ new Set(/* @__PURE__ */ `bad request.unauthorized.payment required.forbidden.not found.method not allowed.not acceptable.proxy authentication required.request timeout.conflict.gone.length required.precondition failed.payload too large.uri too long.unsupported media type.range not satisfiable.expectation failed.misdirected request.unprocessable content.unprocessable entity.locked.failed dependency.too early.upgrade required.precondition required.too many requests.request header fields too large.unavailable for legal reasons`.split(`.`)),xe=e=>typeof e!=`object`||!e?{message:void 0,detail:void 0,title:void 0}:{message:`message`in e?e.message:void 0,detail:`detail`in e?e.detail:void 0,title:`title`in e?e.title:void 0};async function Se(e){return e.html===``?e.response===null?``:e.response.text():e.html}function Ce(e,t){let n=e=>typeof e==`string`?e.trim():``,r=xe(e),i=n(r.message);if(i)return i;let a=n(r.detail);if(a)return a;let o=n(r.title);if(!o)return null;let s=o.toLowerCase();return be.has(s)||s===t.trim().toLowerCase()?null:o}var we=`wui-remote-modal`,Te=`wui-remote-drawer`,Ee=Object.freeze({sm:360,md:480,lg:640,xl:720}),De=`wui-modal-fullscreen`,Oe=`wui-modal-wide`,b=Object.freeze({sm:380,md:440,lg:640,xl:880,wide:1080}),x=()=>s(`modal`,u),ke=e=>ye(e?.getAttribute(`data-wui-timeout`)??null)??3e4,Ae=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,je=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,Me=`[aria-invalid="true"], .is-invalid, .input-validation-error`,Ne=`invalid`,Pe=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,Fe=`[data-wui-modal-content]`,Ie=`[data-wui-pane-close], [data-wui-dismiss]`,Le=()=>i(`button`,{type:`button`,class:`wui-modal-close`,"data-wui-dismiss":!0,"aria-label":x().closeLabel},he({width:18,height:18,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},[[`path`,{d:`M18 6 6 18M6 6l12 12`}]])),S=/* @__PURE__ */ new WeakMap,Re=/* @__PURE__ */ new WeakSet;function C(e,t){if(e==null)throw TypeError(`The remote modal needs ${t}, and the page does not have it.`);return e}var w=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},T=(e,t,n)=>C(w(e,t),n),ze=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),E=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),Be=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,D=(e,t)=>{let n=e instanceof Element?e.closest(t):null;return n instanceof HTMLElement?n:null},Ve=e=>me(b,e),He=e=>me(Ee,e);function Ue(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(Ve(e))return e===`wide`?{px:b.wide,wide:!0}:{px:b[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported modal size "${String(e)}". Use sm, md, lg, xl, wide, fullscreen or a px number.`)}var We=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};if(e.classList.contains(`wui-modal-wide`))return{px:b.wide,wide:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:b.md}},O=(e,t)=>{e.classList.toggle(De,!!t.fullscreen),e.classList.toggle(Oe,!t.fullscreen&&!!t.wide),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},Ge=[`center`,`top`];function Ke(e){if(e==null||e===``)return null;if(He(e))return{px:Ee[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported drawer size "${String(e)}". Use sm, md, lg, xl or a px number.`)}var qe=e=>e.container===`drawer`,k=e=>e.container===`pane`,Je=e=>e.container!==`modal`,Ye=(e,t)=>qe(e)?Ke(t):Ue(t),Xe=e=>{let t=typeof e==`string`?document.querySelector(e):e,n=t instanceof HTMLElement?t:null;return n?.matches(`[data-wui-pane-host]`)?n:null},Ze=e=>k(e)?e.shell:T(e.shell,`.modal-dialog`,`a dialog frame`);function Qe(e=`modal`){let t=e===`drawer`,n=t?Te:we,r=document.getElementById(n);if(r)return r;let a=document.createElement(`wui-modal`);a.id=n,a.setAttribute(`data-wui`,`AppModal`);let o=document.createElement(`dialog`);return o.className=t?`modal wui-modal-shell wui-remote-drawer`:`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${t?Ee.md:b.md}px`),o.replaceChildren(i(`div`,{class:t?`modal-dialog wui-remote-drawer-dialog`:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal`}))),a.append(o),document.body.appendChild(a),a}var $e=e=>i(`div`,{class:`wui-modal-header`},i(`div`,{class:`wui-modal-heading`},i(`div`,{class:`wui-modal-headtext`},i(`div`,{class:`wui-modal-title`},e))),Le()),et=e=>i(`div`,{class:`modal-content wui-modal`,"aria-busy":`true`},$e(e),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-loading`,role:`status`},i(`span`,{class:`visually-hidden`},x().loadingLabel),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton wui-modal-skeleton--short`})))),tt=(n,r)=>{let a={forbidden:x().forbiddenMessage,networkCheck:s(`httpFailure`,h).networkCheckText,client:x().clientMessage,server:x().serverMessage,network:x().networkMessage,timeout:x().timeoutMessage};return i(`div`,{class:`modal-content wui-modal`,"data-wui-modal-error":r},$e(n),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-state`,role:`alert`},i(`p`,{class:`wui-modal-state-title`},x().errorTitle),i(`p`,{class:`wui-modal-state-text`},a[r]||x().serverMessage),i(`div`,{class:`wui-modal-state-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":!0,"data-wui":t},x().closeLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-wui-modal-retry":!0,"data-wui":t},x().retryLabel)))))},A=e=>w(e.shell,`.modal-content`),nt=e=>r(e.cloneNode(!0),HTMLElement,`a card copy is not an element`);function rt(e){e&&e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}))}function j(e,t){let n=A(e),r=n?at(n):/* @__PURE__ */ new Map;rt(n),n?n.replaceWith(t):Ze(e).appendChild(t),ot(t,r),g().refresh()}var it=`input[type="file"][name]`;function at(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(it)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function ot(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(it)){if(!(n instanceof HTMLInputElement))continue;let e=t.get(n.name);if(!e)continue;let r=new DataTransfer;for(let t of e)r.items.add(t);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}var st=e=>k(e)?!e.shell.hidden:e.host.hasAttribute(`open`);function ct(e,t,n=!1){let r=t?w(e,Me):null,i=r?r.matches(Ae)?r:w(r,Ae)||r:null;if(!i&&n)i=w(e,`[data-autofocus]`)||w(e,je)||w(e,`.wui-modal-close`);else if(!i){let t=ze(e,Ae);i=w(e,`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function lt(e,t){let n=w(e.shell,`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),Ze(e).appendChild(n)),n.textContent=``,n.textContent=t}var ut=e=>{let t=w(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},dt=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function M(e,t,n,r){let i={...r,container:e.container};dt(t,`wui:modal:${n}`,i),qe(e)&&dt(t,`wui:drawer:${n}`,i),k(e)&&dt(t,`wui:pane:${n}`,i)}var ft=e=>e.matches(`[data-wui-pane-host]`)?`pane`:T(e,`dialog`,`a dialog`).classList.contains(`wui-remote-drawer`)?`drawer`:`modal`,pt=e=>C(e.host.closest(`wui-modal`),`a wui-modal host`);function mt(e){let t=S.get(e);if(t)return t;let n=ft(e),r=n===`pane`?e:T(e,`dialog`,`a dialog`),a=A({shell:r}),o={host:e,shell:r,container:n,queue:ve(),defaultSize:We(r),defaultLabel:r.getAttribute(`aria-label`),placeholder:a?nt(a):i(`div`,{class:`modal-content wui-modal`}),remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null};return S.set(e,o),e.addEventListener(`submit`,e=>Ft(o,e)),e.addEventListener(`click`,e=>{D(e.target,`[data-wui-modal-retry]`)&&o.session&&(e.preventDefault(),P(o,o.session))}),k(o)&&e.addEventListener(`click`,t=>{let n=D(t.target,Ie);n&&e.contains(n)&&o.session&&N(o,o.session,`dismissed`,null)}),e.addEventListener(`wui-modal-close`,t=>{t.target===e&&t instanceof CustomEvent&&jt(t.detail,`reason`)===`escape`&&e.querySelector(`form[data-wui-submitting]`)&&t.preventDefault()}),e.addEventListener(`wui-modal-closed`,t=>{t.target===e&&bt(o)}),e.addEventListener(`wui-modal-opened`,t=>{if(t.target!==e)return;let n=A(o);o.session&&n?.matches(Fe)&&!n.contains(document.activeElement)&&ct(n,!1,Je(o))}),o.remoteUrl&&e.addEventListener(`wui-modal-open`,t=>{t.target===e&&xt(o,t)}),o}function ht(e,t,n){let r=null;e.session&&(r=e.session.pendingRefresh,e.session.pendingRefresh=null,e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let i=()=>void 0,a=new Promise(e=>{i=e}),o={url:t,method:(n.method||`GET`).toUpperCase(),body:n.body,options:n,trigger:n.trigger||null,explicitSize:null,closing:null,resolveClosed:i,handle:{el:e.shell,closed:a,close:()=>N(e,o,`dismissed`,null),reload:()=>P(e,o)},pendingRefresh:r};return e.session=o,o}function N(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},k(e)?_t(e,t):gt(e))}function gt(e){let t=pt(e);t.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:`dismiss`}}))&&t.hide()}function _t(e,t){let n=e.shell,{status:r,detail:i}=C(t.closing,`the closing state`),a=n.contains(document.activeElement);e.queue.abort(),e.session=null,rt(A(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),M(e,n,`closed`,{status:r,url:t.url}),vt(t),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function vt(e){let t=e.pendingRefresh;e.pendingRefresh=null,t&&de(t).catch(m)}function yt(e,t){for(let n=e;n!==null;n=n.parentElement){let e=n instanceof HTMLElement?S.get(n):void 0;if(e?.session){let n=ue(t);return e.session.pendingRefresh=te(e.session.pendingRefresh,{...t,message:n?t.message:null,action:n?t.action:null}),!0}}return!1}ae(yt);function bt(e){let t=e.session;if(e.queue.abort(),e.session=null,ut(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),M(e,e.shell,`closed`,{status:n.status,url:t.url}),vt(t);let r=document.activeElement;t.trigger?.isConnected&&(!r||r===document.body||e.shell.contains(r))&&t.trigger.focus?.()}e.cache||(j(e,nt(e.placeholder)),e.loadedUrl=null,O(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function xt(e,t){let n=jt(t instanceof CustomEvent?t.detail:null,`trigger`),r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=ht(e,i,{trigger:r});a.explicitSize=St(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&O(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&j(e,nt(e.placeholder)),P(e,a,{keepPlaceholder:!0}))}function St(e,t){try{return Ye(e,t)}catch(e){return m(e),null}}async function P(e,t,{keepPlaceholder:n=!1}={}){n||j(e,et(t.options.title||Ct(e)));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate,timeoutMs:ke(t.trigger)});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if(r.kind===`ok`&&Dt(e,t,r.html,!1))return e.loadedUrl=t.url,M(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return j(e,tt(t.options.title||Ct(e),i)),st(e)&&ct(C(A(e),`a card`),!1,Je(e)),M(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var Ct=e=>A(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,wt=`/_content/Webority.Ui.Razor/js/`,Tt=e=>new URL(e,window.location.href).pathname.includes(wt);function Et(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function Dt(e,t,n,r){let i=ge(n),a=!1;for(let e of i.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Tt(t)?Et(t):a=!0}a&&ee(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let o=w(i,Fe);if(!o)return m(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(j(e,o),r||ut(e),!k(e)){O(e.shell,t.explicitSize||St(e,o.getAttribute(`data-wui-size`))||e.defaultSize);let n=o.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return st(e)&&ct(o,r,Je(e)),!0}var Ot=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function kt(e,t,n){let r=[...e.elements].filter(e=>e.matches(Ot));if(n){e.setAttribute(`data-wui-submitting`,``);let n=t&&r.includes(t)?t:r[0];for(let e of r)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;n&&(n.classList.add(`is-loading`),n.setAttribute(`aria-busy`,`true`),n.tagName===`BUTTON`&&n.prepend(i(`span`,{class:`spinner-border spinner-border-sm me-2`,"aria-hidden":`true`,"data-wui-submit-spinner":!0})))}else{e.removeAttribute(`data-wui-submitting`);for(let e of r)e.disabled=e.hasAttribute(`data-wui-was-disabled`),e.removeAttribute(`data-wui-was-disabled`),e.classList.remove(`is-loading`),e.removeAttribute(`aria-busy`),e.querySelector(`[data-wui-submit-spinner]`)?.remove()}}function At(e){for(let t of e.querySelectorAll(Pe))t.remove();for(let t of e.querySelectorAll(Me))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var jt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function Mt(e){if(e.status<400||e.status>499||!e.response?.headers.get(`content-type`)?.toLowerCase().includes(`json`))return null;let t;try{t=JSON.parse(await Se(e))}catch{return null}return Ce(t,e.response.statusText)}function Nt(e,t,n,r){let i={forbidden:x().forbiddenMessage,networkCheck:s(`httpFailure`,h).networkCheckText,client:x().clientMessage,server:x().serverMessage,network:x().networkMessage,timeout:x().timeoutMessage},a=t.closest(`.wui-modal-body`)||t;a.querySelector(`[data-wui-modal-submit-error]`)?.remove(),At(a);let o=document.createElement(`div`);o.className=`alert alert-danger wui-modal-submit-error`,o.setAttribute(`role`,`alert`),o.setAttribute(`data-wui-modal-submit-error`,``),o.textContent=`${x().submitFailedMessage} ${r||i[n]||x().serverMessage}`,a.prepend(o),lt(e,o.textContent)}var Pt=(e,t)=>{let n=new URL(e,window.location.href);for(let[e,r]of t)typeof r==`string`&&n.searchParams.append(e,r);return n.origin===window.location.origin?n.pathname+n.search:n.href};async function Ft(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(Fe)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=`submitter`in t&&(t.submitter instanceof HTMLButtonElement||t.submitter instanceof HTMLInputElement)?t.submitter:null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;kt(n,i,!0);let l;try{l=await e.queue.run(c?Pt(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate,timeoutMs:ke(r.trigger)})}catch(t){m(t),e.session===r&&n.isConnected&&(kt(n,i,!1),Nt(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&kt(n,i,!1),l.kind===`ok`&&l.result===`success`){It(e,r,l);return}if(l.kind===`aborted`||l.kind===`stale`||l.kind===`session`)return;if(l.kind===`ok`&&l.html){let t=l.result===Ne;if(Dt(e,r,l.html,t)){if(t){let t=C(A(e),`a card`).querySelector(Pe)?.textContent?.replace(/\s+/g,` `).trim();lt(e,t||x().invalidMessage)}return}}let u=l.kind===`ok`||l.kind===`validation`?`server`:l.kind,d=await Mt(l);e.session===r&&Nt(e,n,u,d)}function It(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!ne(a))throw TypeError(`Unknown toast variant "${a}". Use ${pe.join(`, `)}.`);let o={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container},s=i||oe(t.trigger)?null:ce(n),c=!(n.next&&!i)&&!n.keepOpen,l=s!==null&&c&&ue(s);i&&!t.options.navigate?_(r,a):r&&!l&&g().toast(r,{variant:a}),M(e,t.trigger?.isConnected?t.trigger:document,`success`,o),t.options.onSuccess?.(o,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i),s&&(t.pendingRefresh=te(t.pendingRefresh,{...s,action:null,message:l?s.message:null}));let u=n.next;u&&!i?(t.url=u,t.method=`GET`,t.body=void 0,P(e,t)):n.keepOpen?n.html&&n.data===null&&Dt(e,t,n.html,!1):N(e,t,`success`,o)}function Lt(e){let t=D(e.target,`[data-wui-modal], [data-wui-drawer], [data-wui-pane]`);t&&(t.matches(`a[href]`)&&(e.ctrlKey||e.metaKey||e.shiftKey||e.button!==0)||(e.preventDefault(),t.hasAttribute(`data-wui-pane`)?Wt(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{Be(e)||m(e)}):t.hasAttribute(`data-wui-modal`)?Bt(t.getAttribute(`data-wui-modal`)??``,{size:t.getAttribute(`data-wui-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{Be(e)||m(e)}):Ht(t.getAttribute(`data-wui-drawer`)??``,{size:t.getAttribute(`data-wui-drawer-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{Be(e)||m(e)})))}function Rt(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=D(e.target,Ut);if(!t)return;let n=S.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`wui-modal[open]`)&&(t.querySelector(`form[data-wui-submitting]`)||(e.preventDefault(),N(n,n.session,`dismissed`,null)))}function zt(e=document){let t=e instanceof Document?e:C(e.ownerDocument,`an owner document`);Re.has(t)||(Re.add(t),t.addEventListener(`click`,Lt),t.addEventListener(`keydown`,Rt));let n=ze(e,`wui-modal[data-wui-remote-url]`);e instanceof HTMLElement&&e.matches(`wui-modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)mt(e)}function Bt(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=t.container===`drawer`,r=n?Ke(t.size):Ue(t.size),i=t.placement||`center`;if(!Ge.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(E());let a=Qe(n?`drawer`:`modal`);zt(document);let o=mt(a),s=st(o),c=ht(o,e,t);c.explicitSize=r,O(o.shell,r||o.defaultSize),n||T(o.shell,`.modal-dialog`,`a dialog frame`).classList.toggle(`modal-dialog-centered`,i===`center`),t.title&&o.shell.setAttribute(`aria-label`,t.title),s||(a.toggleAttribute(`static`,t.staticBackdrop!==!1),a.toggleAttribute(`no-escape`,t.closeOnEscape===!1));let l=s?Promise.resolve():new Promise(e=>a.addEventListener(`wui-modal-opened`,()=>e(),{once:!0})),u=P(o,c);return s||pt(o).show(),Vt(o,c,t,l,u,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function Vt(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),N(e,t,`dismissed`,{aborted:!0})),i(E())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw E();if(e===`session`)throw Error(`${a}(${t.url}): the session expired; the browser is signing in again.`);return t.handle});return Promise.race([s,o])}function Ht(e,t={}){return Bt(e,{...t,container:`drawer`,placement:void 0})}var Ut=`[data-wui-pane-host]`;function Wt(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=Xe(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(E());zt(document);let r=mt(n),i=ht(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=P(r,i);return Vt(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function Gt(e){let t=Xe(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=S.get(t);n?.session&&N(n,n.session,`dismissed`,null)}var Kt=8e3,qt=()=>s(`toast`,f);function Jt(e){if(!ne(e))throw RangeError(`Unknown toast variant "${e}".`);return e}function F(e,t=`success`){e?.message&&Yt(e.message,t,e.toastAction)}function Yt(e,t,n=null){n?g().toast(e,{variant:Jt(t),duration:Kt,action:{label:n.label,onClick:e=>void Xt(n,e)}}):g().toast(e,{variant:Jt(t)})}async function Xt(e,t=null){let n=await v(e.url,{method:e.method});n.kind!==`session`&&n.kind!==`aborted`&&(n.ok?(ie(n)||F(n,n.toastVariant||`success`),await re(n,{origin:t})):g().toast(n.message||qt().failedText,{variant:`danger`}))}var I=`wuiConfirm`,Zt=Object.freeze([`danger`]),Qt=Object.freeze([`warning`,`info`,`delete`]),L=()=>s(`confirmDialog`,d),$t=/* @__PURE__ */ new WeakSet,en=/* @__PURE__ */ new WeakSet,R=null,z=null,B=!1,V=(e,t)=>{e&&g().toast(e,{variant:t})};function tn(){let r=document.getElementById(I);if(r)return n(r.closest(`wui-modal`),`#${I} must be a wui-modal.`);let a=document.createElement(`wui-modal`);a.id=I;let o=document.createElement(`dialog`);return o.className=`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${b.md}px`),o.replaceChildren(i(`div`,{class:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal wui-confirm`},i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-confirm-content`},i(`span`,{class:`wui-confirm-icon`},i(`wui-status-icon`,{tone:`info`,size:120})),i(`h3`,{class:`wui-confirm-title`,tabindex:-1,"data-autofocus":``}),i(`p`,{class:`wui-confirm-msg`}))),i(`div`,{class:`wui-modal-footer`},i(`div`,{class:`wui-confirm-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":``,"data-wui":t},L().cancelLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-app-confirm":``,"data-wui":t})))))),a.append(o),document.body.appendChild(a),a}function nn(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!Zt.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);rn({title:e.getAttribute(`data-wui-confirm-title`),message:e.getAttribute(`data-wui-confirm`),label:e.getAttribute(`data-wui-confirm-label`),danger:n===`danger`,cancel:void 0,icon:void 0},t)}function rn({title:e,message:t,label:r,danger:i,cancel:a,icon:o},s){let c=tn(),l=c.querySelector(`.wui-confirm-title`),u=c.querySelector(`[data-app-confirm]`);if(!l||!u)throw Error(`#${I} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${I}"> without confirm-href, or leave the dialog to the library.`);let d=c.querySelector(`.wui-confirm-msg`);d||(d=document.createElement(`p`),d.className=`wui-confirm-msg`,l.after(d));let f=e||L().confirmTitle;l.textContent=f,d.textContent=t,u.textContent=r||L().confirmLabel,u.classList.toggle(`btn-danger`,i),u.classList.toggle(`btn-primary`,!i),c.querySelector(`wui-status-icon`)?.setAttribute(`tone`,o??(i?`delete`:`info`));let p=c.querySelector(`[data-wui-dismiss]`);p&&(p.textContent=a||L().cancelLabel),n(c.querySelector(`dialog`),`#${I} has no <dialog>.`).setAttribute(`aria-label`,f),z=s,B=!1,c.show()}var an=(e,t)=>{R=e;try{t()}finally{R=null}},H=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},on=e=>{if(typeof e!=`object`||!e)throw TypeError(`confirmAction: options must be an object with a message.`);let t=`message`in e?e.message:void 0;if(typeof t!=`string`)throw TypeError(`confirmAction: message must be text.`);return{title:H(e,`title`),message:t,label:H(e,`label`),tone:H(e,`tone`),cancel:H(e,`cancel`),icon:H(e,`icon`)}};function sn(e,t,n){let{title:r,message:i,label:a,tone:o,cancel:s,icon:c}=on(t);if(o!=null&&!Zt.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);if(c!=null&&!Qt.includes(c))throw TypeError(`confirmAction: icon "${c}" is not supported. Use warning, info or delete, or leave it off.`);kn(e.ownerDocument),rn({title:r,message:i,label:a,danger:o===`danger`,cancel:s,icon:c},()=>an(e,n))}var cn=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,ln=e=>{r(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function un(e){let t=a(e.target,`[data-wui-confirm]:not(form)`);t&&t!==R&&!cn(t)&&(e.preventDefault(),e.stopImmediatePropagation(),nn(t,()=>an(t,()=>ln(t))))}function dn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===R||e.submitter&&e.submitter===R||t.querySelector(`input[data-app-repeater-hidden]`))return;e.preventDefault(),e.stopImmediatePropagation();let n=e.submitter instanceof HTMLButtonElement||e.submitter instanceof HTMLInputElement?e.submitter:null,r=n?.form===t?n:void 0;nn(t,()=>an(t,()=>t.requestSubmit(r)))}function fn(e){let t=a(e.target,`#${I} [data-app-confirm]`);t&&!t.hasAttribute(`disabled`)&&z&&(B=!0,n(t.closest(`wui-modal`),`#${I} is missing around its confirm button.`).hide())}function pn(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=B?z:null;z=null,B=!1,t?.()}var U=e=>e===`forbidden`?L().forbiddenMessage:e===`networkCheck`?s(`httpFailure`,h).networkCheckText:e===`network`?L().networkMessage:e===`timeout`?L().timeoutMessage:L().failedMessage,mn=(e,t)=>{`disabled`in e&&(e.disabled=t)},hn=e=>{mn(e,!1),e.removeAttribute(`aria-busy`)};async function gn(e){let t=e.getAttribute(`data-wui-post`);if(!t)throw Error(`A data-wui-post button needs the URL the action posts to.`);return _n(t,e)}async function _n(e,t,n){mn(t,!0),t.setAttribute(`aria-busy`,`true`);let r=ye(t.getAttribute(`data-wui-timeout`))??3e4,i=await v(e,{method:`POST`,body:n,timeoutMs:r});if(i.kind===`session`||i.kind===`aborted`)return;let a=i.toastVariant||`success`;if(i.ok&&i.redirect)_(i.message,a,i.toastAction),window.location.assign(i.redirect);else if(i.ok){let e=oe(t);if(!e&&ie(i)){await re(i,{origin:t})===`held`&&hn(t);return}hn(t),F(i,a),e||await re(i,{origin:t})}else hn(t),V(i.message||U(i.kind),`danger`)}var vn=e=>typeof e!=`object`||!e||!(`code`in e)?null:typeof e.code==`string`?e.code:null,yn=e=>(e.response?.headers.get(`Content-Type`)??``).toLowerCase().includes(`json`)?e.data:e.html===``?null:e.html;async function bn(e,t={}){if(t.body!==void 0&&t.json!==void 0)throw TypeError(`postAction takes a body or a json value, not both.`);let n=t.method??`POST`;if(!_e.includes(n))throw TypeError(`postAction method must be POST, PUT, PATCH or DELETE.`);let r=t.timeoutMs??3e4;if(!Number.isInteger(r)||r<0)throw TypeError(`postAction timeoutMs must be a whole number of milliseconds, 0 for no limit.`);let i={},a;t.json===void 0?t.body instanceof FormData||t.body instanceof URLSearchParams?a=t.body:t.body!==void 0&&(a=new URLSearchParams(t.body)):(i[`Content-Type`]=`application/json`,a=JSON.stringify(t.json));let o;try{o=await v(e,{method:n,body:a,headers:i,timeoutMs:r})}catch(e){throw m(e),e}if(o.kind===`session`||o.kind===`aborted`)throw new y(U(o.kind),{code:null,status:o.status,html:null,body:null,kind:o.kind});let s=t.toast!==!1,c=t.refresh!==!1,l=o.toastVariant||`success`;if(o.ok){if(o.redirect)_(s?o.message:null,l,s?o.toastAction:null),window.location.assign(o.redirect);else{let e=ce(o);s&&!(c&&ie(o))&&F(o,l),e!==null&&c&&await de({...e,message:s?e.message:null,action:s?e.action:null})}return yn(o)}let u;try{u=await Se(o)}catch(e){m(e);let t=o.message||U(o.kind);throw V(t,`danger`),new y(t,{code:null,status:o.status,html:null,body:null,kind:o.kind,cause:e})}let d=(o.response?.headers.get(`Content-Type`)??``).toLowerCase(),f=null;if(d.includes(`json`))try{f=JSON.parse(u)}catch{f=null}let p=Ce(f,o.response?.statusText??``)||o.message||U(o.kind),ee=d.includes(`text/html`)?u:null;throw(o.kind!==`validation`||ee===null)&&V(p,`danger`),new y(p,{code:vn(f),status:o.status,html:ee,body:f,kind:o.kind})}function xn(e,t){mn(e,!1),e.removeAttribute(`aria-busy`),m(t),V(L().failedMessage,`danger`)}function Sn(e){let t=a(e.target,`[data-wui-post]`);t&&(e.preventDefault(),cn(t)||t.getAttribute(`aria-busy`)===`true`||gn(t).catch(e=>xn(t,e)))}function Cn(e){let t=a(e.target,`form[data-wui-post-form]`);if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let r=n(e.submitter||t.querySelector(`button:not(.repeater-add):not(.repeater-remove)`),`A data-wui-post-form needs a submit button to report its result on.`);if(r.getAttribute(`aria-busy`)===`true`)return;let i=new URL(n(t.getAttribute(`action`),`A data-wui-post-form needs an action attribute to post to.`),document.baseURI).href;_n(i,r,new FormData(t)).catch(e=>xn(r,e)),t.closest(`wui-dropdown`)?.hide()}var W=(e,t)=>{e.disabled=!1,e.removeAttribute(`aria-busy`),t&&p(t,null)};async function wn(e,t){let n=e.dataset.url;if(!n)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);e.disabled=!0,e.setAttribute(`aria-busy`,`true`),t&&p(t,`saving`);let r=ye(e.getAttribute(`data-wui-timeout`))??3e4,i=await v(n,{method:(e.dataset.method||`post`).toUpperCase(),timeoutMs:r});if(i.kind===`session`)return;if(i.kind===`aborted`){W(e,t);return}let a=i.toastVariant||`success`;if(i.ok&&i.redirect){_(i.message,a,i.toastAction),window.location.assign(i.redirect);return}if(i.ok){let n=ce(i);if(oe(e)||n===null||se(n)){W(e,t),F(i,a);return}if(le({...n,reload:`page`},e)){W(e,t);return}_(i.message,a,i.toastAction),fe();return}let o=i.message||U(i.kind);e.disabled=!1,e.removeAttribute(`aria-busy`),t&&p(t,`error`,o),V(o,`danger`)}var Tn=/* @__PURE__ */ new WeakSet;function En(e){let t=a(e.target,`[data-wui-row-action]`);if(!t||t.closest(`[data-wui-server]`))return;if(!(t instanceof HTMLButtonElement)){if(Tn.has(t))return;Tn.add(t),m(/* @__PURE__ */ Error(`A [data-wui-row-action] element must be a button with data-url, so its click does nothing: ${t.getAttribute(`data-wui-row-action`)??``}`));return}if(e.preventDefault(),t.disabled||t.getAttribute(`aria-busy`)===`true`)return;let n=t.closest(`tr`);wn(t,n).catch(e=>{W(t,n),m(e),V(L().failedMessage,`danger`)})}var Dn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function On(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=Dn(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function kn(e){en.has(e)||(en.add(e),e.addEventListener(`click`,fn),e.addEventListener(`wui-modal-closed`,pn))}function An(e=document){let t=e instanceof Element?e.ownerDocument:e;$t.has(t)||($t.add(t),t.addEventListener(`click`,un,!0),t.addEventListener(`submit`,dn,!0),kn(t),t.addEventListener(`click`,Sn),t.addEventListener(`click`,En),t.addEventListener(`submit`,Cn),t.addEventListener(`change`,On))}var G=()=>s(`unsavedChanges`,l),K=`form[data-wui-unsaved]`,jn=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,Mn=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,Nn=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),Pn=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),Fn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,In=e=>Fn(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,Ln=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,Rn=e=>typeof e==`object`&&!!e,zn=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function Bn(e){let t=JSON.parse(e);if(!zn(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var q=/* @__PURE__ */ new WeakMap,Vn=/* @__PURE__ */ new WeakSet,Hn=e=>`${e.name}:${e.size}:${e.lastModified}`,J=e=>[...e.querySelectorAll(K)].filter(e=>e instanceof HTMLFormElement);function Y(e){let t=[];for(let n of e.elements)Ln(n)&&!In(n)&&(Fn(n)&&Nn.has(n.type)||(n instanceof HTMLInputElement&&(n.type===`checkbox`||n.type===`radio`)?t.push([n.name,n.value,n.checked]):n instanceof HTMLInputElement&&n.type===`file`?t.push([n.name,[...n.files||[]].map(Hn)]):n instanceof HTMLSelectElement&&n.type===`select-multiple`?t.push([n.name,[...n.selectedOptions].map(e=>e.value)]):n instanceof HTMLFieldSetElement||n instanceof HTMLObjectElement?t.push([n.name,null]):t.push([n.name,`value`in n?n.value:null])));return JSON.stringify(t)}function X(e){return Y(e)}function Un(e,t){let n=/* @__PURE__ */ new Map,r=Bn(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=Bn(Y(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function Wn(e){for(let t of e.elements)if(Fn(t)&&t.name&&!In(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!Pn.has(t.type)){if(t.value.trim()!==``)return!0}else if(t instanceof HTMLInputElement&&t.type===`file`&&(t.files?.length??0)>0)return!0}return!1}var Gn=e=>({saved:e.querySelector(jn)&&Wn(e)?null:Y(e),engaged:!1,discarded:!1});function Kn(e){let t=q.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Y(e)!==t.saved}var qn=(e,t)=>J(e).filter(e=>e!==t&&Kn(e));function Jn(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||G().message;sn(e,{title:G().title,message:r,label:G().leaveLabel,cancel:G().keepLabel,icon:`warning`,tone:`danger`},()=>{for(let e of t){let t=q.get(e);t&&(t.discarded=!0)}n()})}function Yn(e){if(e.matches(Mn))return!1;let t=e.getAttribute(`target`);if(t&&t.toLowerCase()!==`_self`)return!1;let n=e.getAttribute(`href`);if(n===null)return!1;let r=new URL(n,window.location.href);if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=window.location;return!(r.hash&&r.origin===i.origin&&r.pathname===i.pathname&&r.search===i.search)}function Xn(e,t){if((t?.getAttribute(`formmethod`)||e.getAttribute(`method`)||`get`).toLowerCase()===`dialog`)return!1;let n=t?.getAttribute(`formtarget`)||e.getAttribute(`target`);return!n||n.toLowerCase()===`_self`}function Zn(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target,n=a(t,`a[href]`);if(!(n instanceof HTMLAnchorElement)||!Yn(n))return;let r=qn(n.ownerDocument,null);r.length&&(e.preventDefault(),Jn(n,r,()=>n.click()))}function Qn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!Xn(t,e.submitter))return;let n=qn(t.ownerDocument,t);if(n.length){e.preventDefault();let r=e.submitter,i=(r instanceof HTMLButtonElement||r instanceof HTMLInputElement)&&r.form===t?r:void 0;Jn(t,n,()=>t.requestSubmit(i));return}let r=q.get(t);r&&(r.saved=Y(t),r.discarded=!1)}function $n(e){qn(document,null).length&&e.preventDefault()}function er(e){let t=e.target,n=a(t,K);return n instanceof HTMLFormElement?n:null}function tr(e){let t=er(e);if(!t)return;let n=q.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Y(t)),n.engaged=!0)}function nr(e){let t=er(e),n=t&&q.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function rr(e){for(let t of J(e)){let e=q.get(t);e?.saved&&(e.saved=Un(t,e.saved))}}function ir(e){let t=Rn(e)?e.handle:void 0;return Rn(t)?t.el:void 0}function ar(e){if(!(e instanceof CustomEvent))return;let t=ir(e.detail);if(t instanceof Element)for(let e of J(t))sr(e)}function or(e=document){let t=e instanceof Document?e:e.ownerDocument;if(!Vn.has(t)){Vn.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,tr,!0);for(let e of[`input`,`change`])t.addEventListener(e,nr,!0);t.addEventListener(`click`,Zn),t.addEventListener(`submit`,Qn),t.addEventListener(`wui:modal:success`,ar),t.addEventListener(o,()=>rr(t)),n(t.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,$n)}let r=J(e);e instanceof HTMLFormElement&&e.matches(K)&&r.unshift(e);for(let e of r)q.has(e)||q.set(e,Gn(e))}function sr(e){if(!(e instanceof HTMLFormElement)||!e.matches(K))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);q.set(e,{saved:Y(e),engaged:!1,discarded:!1})}var cr=()=>s(`drawer`,c),lr=`wui:drawer:discard`,Z=`wui-drawer[confirm-discard]`,ur=`wui-modal`,dr=`data-wui-no-discard`,fr=`.wui-drawer-discard`,pr=`input, select, textarea`,mr=e=>typeof e==`object`&&!!e||typeof e==`function`;function hr(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function gr(e,t){return a(e,t)}var _r=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,Q=/* @__PURE__ */ new WeakMap,vr=/* @__PURE__ */ new WeakSet,yr=/* @__PURE__ */ new WeakSet;function br(n,r,i,a,o){let s=n.createElement(`button`);return s.type=`button`,s.className=e(r,i,`sm`),s.dataset.wui=t,s.setAttribute(a,``),s.textContent=o,s}function xr(e,t){let n=e.createElement(`div`);n.className=`wui-drawer-discard`,n.setAttribute(`role`,`alert`);let r=e.createElement(`span`);return r.className=`wui-drawer-discard-text`,r.textContent=t,n.append(r,br(e,`danger`,`solid`,`data-wui-discard-confirm`,cr().discardLabel),br(e,`primary`,`soft`,`data-wui-discard-keep`,cr().keepLabel)),n}function Sr(e){if(!(e instanceof Element))return null;let t=e.closest(Z);if(t)return t;let n=e.closest(ur);return n&&$(n).length?n:null}function Cr(e){return e.closest(Z)??e.closest(ur)}function wr(e,t){return t.hasAttribute(dr)||e.hasAttribute(dr)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function $(e){return e.matches(Z)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>wr(t,e))}function Tr(e){let t=Q.get(e);return t!=null&&X(e)!==t}function Er(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,n(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(t),yr.add(t),t}function Dr(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-modal-footer`,(e.querySelector(`.wui-modal-body`)?.parentElement??e.querySelector(`.modal-content`)??e).append(t),yr.add(t),t}function Or(e){let t=e.querySelector(`[data-wui-discard-confirm]`);if(!(t instanceof HTMLElement))throw Error(`The discard prompt has no confirm button.`);t.focus()}function kr(e,t,n){let r=e.querySelector(fr);if(r){Or(r);return}let i=xr(e.ownerDocument,t),a;if(e.matches(Z))a=e.querySelector(`.wui-drawer-footer`)??Er(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??Dr(e),a.prepend(i);else{if(!n)throw Error(`A discard prompt needs the form that is dirty.`);a=n.querySelector(`.modal-footer`)??e.querySelector(`.wui-modal-footer`)??Dr(e),a.prepend(i)}a.classList.add(`wui-drawer-discarding`),Or(i)}function Ar(e){let t=e.parentElement;if(e.remove(),!t)throw Error(`The discard prompt has no footer.`);t.classList.remove(`wui-drawer-discarding`),yr.has(t)&&t.remove()}function jr(e){for(let t of $(e))for(let e of t.querySelectorAll(pr))if(_r(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function Mr(e){let t=Sr(e.target);if(t)for(let e of $(t))Q.get(e)??Q.set(e,X(e))}function Nr(e){for(let t of hr(e).querySelectorAll(`form`)){let e=Q.get(t);e!=null&&Q.set(t,Un(t,e))}}function Pr(e){let t=e.target;t instanceof HTMLFormElement&&Sr(t)&&Q.set(t,X(t))}function Fr(e){if(!mr(e))return;let t=`handle`in e?e.handle:void 0;if(mr(t))return`el`in t?t.el:void 0}function Ir(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=Fr(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))Q.delete(e)}function Lr(e){let t=e.target;t instanceof Element&&t.matches(Z)&&[...$(t)].some(Tr)&&(e.preventDefault(),kr(t,t.getAttribute(`confirm-discard`),null))}function Rr(e){let t=e.target;if(!(t instanceof Element)||!t.matches(ur))return;let n=[...$(t)].find(Tr);n&&(e.preventDefault(),kr(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??cr().confirmDiscard,n))}function zr(e){let t=n(e.closest(fr),`The discard button is outside its prompt.`),r=Cr(t);if(Ar(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of $(r))Q.set(e,X(e));r.dispatchEvent(new CustomEvent(lr,{bubbles:!0})),r.matches(Z)?n(r.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():n(r.closest(`wui-modal`),`The discarded dialog is not a wui-modal.`).hide()}function Br(e){let t=n(e.closest(fr),`The keep button is outside its prompt.`),r=Cr(t);if(Ar(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);jr(r)}function Vr(e){let t=gr(e.target,`[data-wui-discard-confirm]`);if(t){zr(t);return}let n=gr(e.target,`[data-wui-discard-keep]`);n&&Br(n)}function Hr(e=document){let t=e instanceof Document?e:e.ownerDocument;vr.has(t)||(vr.add(t),t.addEventListener(`focusin`,Mr),t.addEventListener(`pointerdown`,Mr),t.addEventListener(`submit`,Pr),t.addEventListener(o,Nr),t.addEventListener(`wui:modal:success`,Ir),t.addEventListener(`wui:modal:loaded`,Ir),t.addEventListener(`wui-drawer-close`,Lr,!0),t.addEventListener(`wui-modal-close`,Rr),t.addEventListener(`click`,Vr))}export{zt as _,or as a,Wt as b,Zt as c,bn as d,Kt as f,Gt as g,Yt as h,X as i,sn as l,F as m,xr as n,sr as o,Xt as p,Hr as r,I as s,lr as t,An as u,Ht as v,y as x,Bt as y};