@editora/ui-core 0.1.12 → 0.1.14

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 (141) hide show
  1. package/README.md +95 -5
  2. package/dist/alert-dialog.cjs.js +18 -18
  3. package/dist/alert-dialog.esm.js +130 -117
  4. package/dist/app-header.cjs.js +22 -2
  5. package/dist/app-header.esm.js +22 -2
  6. package/dist/badge.cjs.js +5 -5
  7. package/dist/badge.esm.js +9 -8
  8. package/dist/color-picker.cjs.js +4 -4
  9. package/dist/color-picker.esm.js +40 -31
  10. package/dist/combobox.cjs.js +21 -21
  11. package/dist/combobox.esm.js +79 -40
  12. package/dist/command-palette.cjs.js +1 -1
  13. package/dist/command-palette.esm.js +2 -2
  14. package/dist/components/date-time-utils.d.ts +2 -1
  15. package/dist/components/date-time-utils.d.ts.map +1 -1
  16. package/dist/components/ui-alert-dialog.d.ts +2 -0
  17. package/dist/components/ui-alert-dialog.d.ts.map +1 -1
  18. package/dist/components/ui-app-header.d.ts.map +1 -1
  19. package/dist/components/ui-badge.d.ts.map +1 -1
  20. package/dist/components/ui-color-picker.d.ts.map +1 -1
  21. package/dist/components/ui-combobox.d.ts +4 -1
  22. package/dist/components/ui-combobox.d.ts.map +1 -1
  23. package/dist/components/ui-context-menu.d.ts +6 -0
  24. package/dist/components/ui-context-menu.d.ts.map +1 -1
  25. package/dist/components/ui-date-picker.d.ts +3 -0
  26. package/dist/components/ui-date-picker.d.ts.map +1 -1
  27. package/dist/components/ui-date-range-picker.d.ts +3 -0
  28. package/dist/components/ui-date-range-picker.d.ts.map +1 -1
  29. package/dist/components/ui-date-range-time-picker.d.ts +3 -0
  30. package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
  31. package/dist/components/ui-date-time-picker.d.ts +3 -0
  32. package/dist/components/ui-date-time-picker.d.ts.map +1 -1
  33. package/dist/components/ui-dialog.d.ts +3 -0
  34. package/dist/components/ui-dialog.d.ts.map +1 -1
  35. package/dist/components/ui-drawer.d.ts +14 -0
  36. package/dist/components/ui-drawer.d.ts.map +1 -1
  37. package/dist/components/ui-floating-toolbar.d.ts +3 -0
  38. package/dist/components/ui-floating-toolbar.d.ts.map +1 -1
  39. package/dist/components/ui-gantt.d.ts +30 -1
  40. package/dist/components/ui-gantt.d.ts.map +1 -1
  41. package/dist/components/ui-hover-card.d.ts +3 -0
  42. package/dist/components/ui-hover-card.d.ts.map +1 -1
  43. package/dist/components/ui-menu.d.ts +1 -0
  44. package/dist/components/ui-menu.d.ts.map +1 -1
  45. package/dist/components/ui-menubar.d.ts +1 -0
  46. package/dist/components/ui-menubar.d.ts.map +1 -1
  47. package/dist/components/ui-positioner.d.ts.map +1 -1
  48. package/dist/components/ui-quick-actions.d.ts.map +1 -1
  49. package/dist/components/ui-radio.d.ts +47 -0
  50. package/dist/components/ui-radio.d.ts.map +1 -0
  51. package/dist/components/ui-select.d.ts +8 -0
  52. package/dist/components/ui-select.d.ts.map +1 -1
  53. package/dist/components/ui-selection-popup.d.ts.map +1 -1
  54. package/dist/components/ui-stepper.d.ts.map +1 -1
  55. package/dist/components/ui-time-picker.d.ts +3 -0
  56. package/dist/components/ui-time-picker.d.ts.map +1 -1
  57. package/dist/context-menu.cjs.js +12 -12
  58. package/dist/context-menu.esm.js +160 -133
  59. package/dist/date-field.cjs.js +1 -1
  60. package/dist/date-field.esm.js +3 -2
  61. package/dist/date-picker.cjs.js +13 -13
  62. package/dist/date-picker.esm.js +101 -67
  63. package/dist/date-range-picker.cjs.js +14 -14
  64. package/dist/date-range-picker.esm.js +99 -65
  65. package/dist/date-range-time-picker.cjs.js +13 -13
  66. package/dist/date-range-time-picker.esm.js +77 -45
  67. package/dist/date-time-picker.cjs.js +13 -13
  68. package/dist/date-time-picker.esm.js +133 -101
  69. package/dist/date-time-utils-66480de4.js +1 -0
  70. package/dist/date-time-utils-a2c7af25.mjs +307 -0
  71. package/dist/dialog.cjs.js +29 -20
  72. package/dist/dialog.esm.js +90 -70
  73. package/dist/drawer.cjs.js +16 -16
  74. package/dist/drawer.esm.js +216 -98
  75. package/dist/floating-toolbar.cjs.js +6 -16
  76. package/dist/floating-toolbar.esm.js +57 -40
  77. package/dist/gantt.cjs.js +656 -74
  78. package/dist/gantt.esm.js +1050 -100
  79. package/dist/hover-card.cjs.js +4 -4
  80. package/dist/hover-card.esm.js +62 -39
  81. package/dist/index.cjs.js +1 -1
  82. package/dist/index.d.ts +2 -0
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.esm.js +300 -286
  85. package/dist/menu.cjs.js +2 -2
  86. package/dist/menu.esm.js +118 -110
  87. package/dist/menubar.cjs.js +5 -5
  88. package/dist/menubar.esm.js +83 -78
  89. package/dist/{overlayManager-ece06517.js → overlayManager-0eda4e08.js} +1 -1
  90. package/dist/{overlayManager-86454af7.mjs → overlayManager-5bbd4dc3.mjs} +1 -1
  91. package/dist/popover.cjs.js +1 -1
  92. package/dist/popover.esm.js +2 -2
  93. package/dist/portal-c69756c0.js +1 -0
  94. package/dist/portal-fe73e5cc.mjs +123 -0
  95. package/dist/portal.d.ts +29 -3
  96. package/dist/portal.d.ts.map +1 -1
  97. package/dist/positioner-33529bb8.js +1 -0
  98. package/dist/positioner-e9770c66.mjs +582 -0
  99. package/dist/positioner.cjs.js +2 -2
  100. package/dist/positioner.esm.js +36 -26
  101. package/dist/primitives/positioner.d.ts +199 -1
  102. package/dist/primitives/positioner.d.ts.map +1 -1
  103. package/dist/quick-actions.cjs.js +10 -4
  104. package/dist/quick-actions.esm.js +27 -21
  105. package/dist/radio.cjs.js +259 -0
  106. package/dist/radio.esm.js +455 -0
  107. package/dist/{runtime-4ac0107b.mjs → runtime-161f68a2.mjs} +24 -23
  108. package/dist/runtime-3f13807b.js +1 -0
  109. package/dist/runtime.cjs.js +1 -1
  110. package/dist/runtime.d.ts +2 -0
  111. package/dist/runtime.d.ts.map +1 -1
  112. package/dist/runtime.esm.js +39 -24
  113. package/dist/scroll-lock-31da444f.mjs +56 -0
  114. package/dist/scroll-lock-d7b0df21.js +1 -0
  115. package/dist/scroll-lock.d.ts.map +1 -1
  116. package/dist/select.cjs.js +14 -15
  117. package/dist/select.esm.js +117 -97
  118. package/dist/selection-popup.cjs.js +4 -7
  119. package/dist/selection-popup.esm.js +8 -11
  120. package/dist/split-button.cjs.js +1 -1
  121. package/dist/split-button.esm.js +2 -2
  122. package/dist/standalone/radio.d.ts +2 -0
  123. package/dist/standalone/radio.d.ts.map +1 -0
  124. package/dist/stepper.cjs.js +19 -50
  125. package/dist/stepper.esm.js +17 -48
  126. package/dist/time-field.cjs.js +1 -1
  127. package/dist/time-field.esm.js +3 -2
  128. package/dist/time-picker.cjs.js +15 -15
  129. package/dist/time-picker.esm.js +100 -68
  130. package/dist/tooltip.cjs.js +1 -1
  131. package/dist/tooltip.esm.js +2 -1
  132. package/package.json +1 -1
  133. package/dist/date-time-utils-5cf58cd0.js +0 -1
  134. package/dist/date-time-utils-bdceb7af.mjs +0 -273
  135. package/dist/portal-1cf392ca.mjs +0 -114
  136. package/dist/portal-d8d7fbca.js +0 -1
  137. package/dist/positioner-accc6e5f.js +0 -1
  138. package/dist/positioner-fbd61bf1.mjs +0 -132
  139. package/dist/runtime-5f282bc8.js +0 -1
  140. package/dist/scroll-lock-48793569.js +0 -1
  141. package/dist/scroll-lock-9de6d328.mjs +0 -53
@@ -0,0 +1,307 @@
1
+ import { p as T, c as b, s as N, e as v, a as F } from "./calendar-2c11b824.mjs";
2
+ import { a as L } from "./scroll-lock-31da444f.mjs";
3
+ import { c as U } from "./positioner-e9770c66.mjs";
4
+ const C = /* @__PURE__ */ new Map(), I = 24;
5
+ function D(t, e, n) {
6
+ return Math.max(e, Math.min(n, t));
7
+ }
8
+ function u(t) {
9
+ return String(t).padStart(2, "0");
10
+ }
11
+ function $(t) {
12
+ if (!/^-?\d+$/.test(t))
13
+ return null;
14
+ const e = Number(t);
15
+ return Number.isFinite(e) ? Math.trunc(e) : null;
16
+ }
17
+ function O(t) {
18
+ return t.replace(/[.\-]/g, "/").replace(/\s+/g, " ").trim();
19
+ }
20
+ function P(t) {
21
+ const e = [];
22
+ for (let n = 0; n < 12; n += 1)
23
+ e.push(
24
+ new Intl.DateTimeFormat(t, {
25
+ month: "short",
26
+ timeZone: "UTC"
27
+ }).format(new Date(Date.UTC(2024, n, 1)))
28
+ );
29
+ return e;
30
+ }
31
+ function A(t) {
32
+ const e = [];
33
+ for (let n = 0; n < 12; n += 1)
34
+ e.push(
35
+ new Intl.DateTimeFormat(t, {
36
+ month: "long",
37
+ timeZone: "UTC"
38
+ }).format(new Date(Date.UTC(2024, n, 1)))
39
+ );
40
+ return e;
41
+ }
42
+ function B(t, e = !1) {
43
+ if (t == null)
44
+ return e;
45
+ const n = t.trim().toLowerCase();
46
+ return n ? n !== "false" && n !== "0" && n !== "off" && n !== "no" : !0;
47
+ }
48
+ function H(t, e) {
49
+ const n = typeof t.composedPath == "function" ? t.composedPath() : [];
50
+ for (const o of e)
51
+ if (o && n.includes(o))
52
+ return !0;
53
+ const r = t.target;
54
+ if (!(r instanceof Node))
55
+ return !1;
56
+ for (const o of e)
57
+ if (o instanceof Node && o.contains(r))
58
+ return !0;
59
+ return !1;
60
+ }
61
+ function q(t) {
62
+ const e = (t || "").trim();
63
+ return e || (typeof navigator < "u" && navigator.language ? navigator.language : "en-US");
64
+ }
65
+ function m(t) {
66
+ if (!t)
67
+ return null;
68
+ const e = T(t);
69
+ return e ? `${e.y}-${u(e.m)}-${u(e.d)}` : null;
70
+ }
71
+ function y(t) {
72
+ if (!t)
73
+ return null;
74
+ const e = /^(\d{4}-\d{2}-\d{2})[T ](\d{1,2}:\d{2}(?::\d{2})?)$/.exec(t.trim());
75
+ if (!e)
76
+ return null;
77
+ const n = m(e[1]);
78
+ if (!n)
79
+ return null;
80
+ const r = h(e[2], !0);
81
+ if (!r)
82
+ return null;
83
+ const o = e[2].split(":").length === 3;
84
+ return { date: n, time: w(r, o) };
85
+ }
86
+ function E(t, e) {
87
+ if (!t || !e)
88
+ return null;
89
+ const n = m(t), r = h(e, !0);
90
+ return !n || !r ? null : `${n}T${w(r, e.split(":").length >= 3)}`;
91
+ }
92
+ function Z(t) {
93
+ if (!t)
94
+ return null;
95
+ const e = m(t);
96
+ if (e)
97
+ return e;
98
+ const n = y(t);
99
+ return (n == null ? void 0 : n.date) || null;
100
+ }
101
+ function _(t) {
102
+ if (!t)
103
+ return null;
104
+ const e = y(t);
105
+ if (e)
106
+ return e;
107
+ const n = m(t);
108
+ return n ? { date: n, time: "00:00" } : null;
109
+ }
110
+ function z(t, e, n) {
111
+ const r = T(t);
112
+ if (!r)
113
+ return t;
114
+ const o = `${e}::${JSON.stringify(n || {})}`;
115
+ let s = C.get(o);
116
+ return s || (s = new Intl.DateTimeFormat(e, {
117
+ year: "numeric",
118
+ month: "short",
119
+ day: "2-digit",
120
+ timeZone: "UTC",
121
+ ...n || {}
122
+ }), C.set(o, s)), s.format(new Date(Date.UTC(r.y, r.m - 1, r.d)));
123
+ }
124
+ function W(t, e, n, r) {
125
+ if (!t)
126
+ return "";
127
+ if (n === "iso")
128
+ return t;
129
+ if (n === "custom" && r) {
130
+ const o = T(t);
131
+ if (!o)
132
+ return t;
133
+ const s = P(e), i = A(e);
134
+ return r.replace(/YYYY/g, String(o.y)).replace(/MMM/g, s[o.m - 1] || "").replace(/MMMM/g, i[o.m - 1] || "").replace(/MM/g, u(o.m)).replace(/DD/g, u(o.d));
135
+ }
136
+ return z(t, e);
137
+ }
138
+ function j(t, e) {
139
+ const n = m(t.trim());
140
+ if (n)
141
+ return n;
142
+ const r = O(t);
143
+ if (!r)
144
+ return null;
145
+ const o = m(r);
146
+ if (o)
147
+ return o;
148
+ const s = r.split("/").map((M) => M.trim()).filter(Boolean);
149
+ if (s.length !== 3)
150
+ return null;
151
+ const i = $(s[0]), a = $(s[1]), d = $(s[2]);
152
+ if (i == null || a == null || d == null)
153
+ return null;
154
+ let f = d;
155
+ f < 100 && (f += f >= 70 ? 1900 : 2e3);
156
+ const l = e.toLowerCase().startsWith("en-us"), c = l ? i : a, p = l ? a : i;
157
+ if (f < 1e3 || c < 1 || c > 12 || p < 1 || p > 31)
158
+ return null;
159
+ const g = `${f}-${u(c)}-${u(p)}`;
160
+ return m(g);
161
+ }
162
+ function h(t, e) {
163
+ const n = t.trim().toLowerCase();
164
+ if (!n)
165
+ return null;
166
+ const r = /^(\d{1,2})(?::|\.|h)?(\d{1,2})?(?::|\.|m)?(\d{1,2})?\s*(am|pm)?$/.exec(n);
167
+ if (!r)
168
+ return null;
169
+ let o = Number(r[1]);
170
+ const s = Number(r[2] ?? "0"), i = Number(r[3] ?? "0");
171
+ if (!Number.isFinite(o) || !Number.isFinite(s) || !Number.isFinite(i) || s < 0 || s > 59 || i < 0 || i > 59 || !e && i !== 0)
172
+ return null;
173
+ const a = r[4];
174
+ if (a) {
175
+ if (o < 1 || o > 12)
176
+ return null;
177
+ a === "pm" && o < 12 && (o += 12), a === "am" && o === 12 && (o = 0);
178
+ }
179
+ return o < 0 || o > 23 ? null : { hours: o, minutes: s, seconds: i };
180
+ }
181
+ function w(t, e = !1) {
182
+ if (!t)
183
+ return "";
184
+ const n = u(D(t.hours, 0, 23)), r = u(D(t.minutes, 0, 59));
185
+ if (!e)
186
+ return `${n}:${r}`;
187
+ const o = u(D(t.seconds, 0, 59));
188
+ return `${n}:${r}:${o}`;
189
+ }
190
+ function G(t, e) {
191
+ const n = h(t, !0);
192
+ if (!n)
193
+ return t;
194
+ const r = /* @__PURE__ */ new Date();
195
+ return r.setHours(n.hours, n.minutes, n.seconds, 0), new Intl.DateTimeFormat(e, {
196
+ hour: "numeric",
197
+ minute: "2-digit",
198
+ second: t.split(":").length > 2 ? "2-digit" : void 0,
199
+ hour12: !0
200
+ }).format(r);
201
+ }
202
+ function S(t, e) {
203
+ const n = h(t, !0), r = h(e, !0);
204
+ if (!n || !r)
205
+ return t.localeCompare(e);
206
+ const o = n.hours * 3600 + n.minutes * 60 + n.seconds, s = r.hours * 3600 + r.minutes * 60 + r.seconds;
207
+ return o - s;
208
+ }
209
+ function J(t, e, n) {
210
+ const r = h(t, !0);
211
+ if (!r)
212
+ return t;
213
+ let o = w(r, t.split(":").length >= 3);
214
+ return e && S(o, e) < 0 && (o = e), n && S(o, n) > 0 && (o = n), o;
215
+ }
216
+ function K(t, e, n) {
217
+ let r = t;
218
+ return e && b(r, e) < 0 && (r = e), n && b(r, n) > 0 && (r = n), r;
219
+ }
220
+ function V(t, e) {
221
+ const n = y(t), r = y(e);
222
+ if (!n || !r)
223
+ return t.localeCompare(e);
224
+ const o = b(n.date, r.date);
225
+ return o !== 0 ? o : S(n.time, r.time);
226
+ }
227
+ function Q(t) {
228
+ const e = T(t);
229
+ if (!e)
230
+ return { start: t, end: t };
231
+ const n = N(e.y, e.m), r = v(e.y, e.m);
232
+ return {
233
+ start: `${n.y}-${u(n.m)}-${u(n.d)}`,
234
+ end: `${r.y}-${u(r.m)}-${u(r.d)}`
235
+ };
236
+ }
237
+ function R(t, e) {
238
+ const n = D(e, 1, 366);
239
+ return {
240
+ start: F(t, -(n - 1)),
241
+ end: t
242
+ };
243
+ }
244
+ function X(t, e, n = 8, r = 8, o = null) {
245
+ const i = (typeof window < "u" ? window.innerHeight : 800) - t.bottom - r - n, a = t.top - r - n, d = i >= e.height, f = a >= e.height, l = o === "top" ? "top" : "bottom";
246
+ let c;
247
+ if (d && !f)
248
+ c = "bottom";
249
+ else if (f && !d)
250
+ c = "top";
251
+ else if (f && d)
252
+ c = l;
253
+ else {
254
+ const g = l === "bottom" ? i : a, M = l === "bottom" ? a : i;
255
+ g > 0 && M <= g + I ? c = l : c = i >= a ? "bottom" : "top";
256
+ }
257
+ const p = U(t, e, {
258
+ placement: `${c}-start`,
259
+ strategy: "fixed",
260
+ offset: r,
261
+ shift: !1,
262
+ flip: !1,
263
+ boundaryPadding: n
264
+ });
265
+ return { top: Math.round(p.y), left: Math.round(p.x), placement: c };
266
+ }
267
+ function tt(t) {
268
+ let e = 0;
269
+ return { run: () => {
270
+ e || (e = requestAnimationFrame(() => {
271
+ e = 0, t();
272
+ }));
273
+ }, cancel: () => {
274
+ e && (cancelAnimationFrame(e), e = 0);
275
+ } };
276
+ }
277
+ function et(t) {
278
+ return (t || "popover") === "inline" || typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(max-width: 639px)").matches;
279
+ }
280
+ function nt() {
281
+ return L();
282
+ }
283
+ export {
284
+ K as a,
285
+ q as b,
286
+ X as c,
287
+ j as d,
288
+ H as e,
289
+ W as f,
290
+ R as g,
291
+ Q as h,
292
+ B as i,
293
+ E as j,
294
+ y as k,
295
+ nt as l,
296
+ V as m,
297
+ m as n,
298
+ _ as o,
299
+ Z as p,
300
+ h as q,
301
+ tt as r,
302
+ et as s,
303
+ G as t,
304
+ w as u,
305
+ J as v,
306
+ S as w
307
+ };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=require("./ElementBase-1b301e7f.js"),w=require("./scroll-lock-48793569.js"),B=require("./dismissable-layer-193e3bed.js"),z=require("./focus-scope-2b12b4e7.js"),M=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const z=require("./ElementBase-1b301e7f.js"),F=require("./scroll-lock-d7b0df21.js"),M=require("./dismissable-layer-193e3bed.js"),R=require("./focus-scope-2b12b4e7.js"),P=`
2
2
  :host {
3
3
  position: fixed;
4
4
  inset: 0;
@@ -8,6 +8,7 @@
8
8
  isolation: isolate;
9
9
  color-scheme: light dark;
10
10
  --ui-dialog-backdrop: color-mix(in srgb, #020617 58%, transparent);
11
+ --ui-dialog-backdrop-filter: none;
11
12
  --ui-dialog-bg: linear-gradient(
12
13
  180deg,
13
14
  color-mix(in srgb, var(--ui-color-surface, #ffffff) 98%, transparent) 0%,
@@ -65,11 +66,16 @@
65
66
  box-sizing: border-box;
66
67
  pointer-events: auto;
67
68
  background: var(--ui-dialog-backdrop);
68
- backdrop-filter: saturate(1.05) blur(4px);
69
+ -webkit-backdrop-filter: var(--ui-dialog-backdrop-filter);
70
+ backdrop-filter: var(--ui-dialog-backdrop-filter);
69
71
  opacity: 0;
70
72
  transition: opacity var(--ui-dialog-duration) var(--ui-dialog-easing);
71
73
  }
72
74
 
75
+ .overlay[hidden] {
76
+ display: none;
77
+ }
78
+
73
79
  .overlay[data-open='true'] {
74
80
  opacity: 1;
75
81
  }
@@ -87,17 +93,19 @@
87
93
  color: var(--ui-dialog-color);
88
94
  box-shadow: var(--ui-dialog-shadow);
89
95
  padding: var(--ui-dialog-padding-y) var(--ui-dialog-padding-x);
90
- transform: translateY(12px) scale(0.985);
96
+ transform: translate3d(0, 12px, 0) scale(0.985);
91
97
  opacity: 0;
92
98
  transition:
93
99
  transform var(--ui-dialog-duration) var(--ui-dialog-easing),
94
100
  opacity var(--ui-dialog-duration) var(--ui-dialog-easing),
95
101
  border-color var(--ui-dialog-duration) var(--ui-dialog-easing),
96
102
  box-shadow var(--ui-dialog-duration) var(--ui-dialog-easing);
103
+ will-change: transform, opacity;
104
+ backface-visibility: hidden;
97
105
  }
98
106
 
99
107
  .overlay[data-open='true'] .panel {
100
- transform: translateY(0) scale(1);
108
+ transform: translate3d(0, 0, 0) scale(1);
101
109
  opacity: 1;
102
110
  }
103
111
 
@@ -364,43 +372,44 @@
364
372
  box-shadow: none;
365
373
  }
366
374
  }
367
- `,R='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function b(u,t){if(u==null)return t;const i=u.trim().toLowerCase();return i!=="false"&&i!=="0"&&i!=="off"}function a(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function S(){return typeof window<"u"&&typeof document<"u"}const E=class n extends I.ElementBase{constructor(){super(),this._isActive=!1,this._uid=Math.random().toString(36).slice(2,10),this._dialogId=this._uid,this._lastFocused=null,this._terminalEmitted=!1,this._closeMeta=null,this._runtimeError="",this._config={},this._dismissableLayer=null,this._focusScope=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onSubmit=this._onSubmit.bind(this)}static get observedAttributes(){return["open","headless","title","description","closable","dismissible","close-on-overlay","close-on-backdrop","close-on-esc","lock-while-loading","size","state","role","initial-focus","submit-text","cancel-text","loading-text","error-message","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.addEventListener("submit",this._onSubmit),this._syncFromAttributes(),this._syncOpenState()}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("submit",this._onSubmit),this._isActive&&!this._terminalEmitted&&this.close("dismiss","unmount"),this._destroyRuntimeControllers(),this._deactivate(),super.disconnectedCallback()}attributeChangedCallback(t,i,e){if(i!==e){if(t==="open"){this._syncOpenState();return}t==="state"&&e!=="error"&&(this._runtimeError=""),this._syncFromAttributes(),this.isConnected&&this.requestRender()}}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.close("dismiss","programmatic")}get dismissible(){return b(this.getAttribute("dismissible")??this.getAttribute("closable"),!0)}set dismissible(t){this.setAttribute("dismissible",String(t)),this.setAttribute("closable",String(t))}get closeOnOverlay(){return b(this.getAttribute("close-on-overlay")??this.getAttribute("close-on-backdrop"),!0)}set closeOnOverlay(t){this.setAttribute("close-on-overlay",String(t)),this.setAttribute("close-on-backdrop",String(t))}get closeOnEsc(){return b(this.getAttribute("close-on-esc"),!0)}set closeOnEsc(t){this.setAttribute("close-on-esc",String(t))}get lockWhileLoading(){return b(this.getAttribute("lock-while-loading"),!0)}set lockWhileLoading(t){this.setAttribute("lock-while-loading",String(t))}get state(){const t=this.getAttribute("state");return t==="loading"||t==="error"||t==="success"?t:"idle"}set state(t){if(t==="idle"){this.removeAttribute("state");return}this.setAttribute("state",t)}get dialogId(){return this._dialogId}set dialogId(t){this._dialogId=t||this._uid,this.requestRender()}get config(){return this._config}set config(t){this._config=t||{},this._config.id&&(this._dialogId=this._config.id),this._config.dismissible!=null&&(this.dismissible=!!this._config.dismissible),this._config.closeOnOverlay!=null&&(this.closeOnOverlay=!!this._config.closeOnOverlay),this._config.closeOnEsc!=null&&(this.closeOnEsc=!!this._config.closeOnEsc),this._config.lockWhileLoading!=null&&(this.lockWhileLoading=!!this._config.lockWhileLoading),this._config.size&&this.setAttribute("size",this._config.size),this._config.role&&this.setAttribute("role",this._config.role),this._config.initialFocus&&this.setAttribute("initial-focus",this._config.initialFocus),this._config.ariaLabel&&this.setAttribute("aria-label",this._config.ariaLabel),this._config.ariaLabelledby&&this.setAttribute("aria-labelledby",this._config.ariaLabelledby),this._config.ariaDescribedby&&this.setAttribute("aria-describedby",this._config.ariaDescribedby),this._config.errorMessage&&(this._runtimeError=this._config.errorMessage),this.requestRender()}openDialog(){this.setAttribute("open","")}closeDialog(t="programmatic"){if(!this.hasAttribute("open"))return;const i=new CustomEvent("request-close",{detail:{reason:t},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i);const e=new CustomEvent("ui-request-close",{detail:{id:this.dialogId||this._uid,reason:t},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(e),!(i.defaultPrevented||e.defaultPrevented)){if(t==="submit"){this.close("submit");return}if(t==="cancel"){this.close("cancel");return}if(t==="overlay"){this.close("dismiss","overlay");return}if(t==="escape"){this.close("dismiss","esc");return}if(t==="button"){this.close("dismiss","close-icon");return}this.close("dismiss","programmatic")}}close(t="dismiss",i,e){this._terminalEmitted||(this._closeMeta={action:t,source:i,reason:e},this.hasAttribute("open")&&this.removeAttribute("open"),this._syncOpenState())}setError(t){this._runtimeError=t,this.state=t?"error":"idle",this.requestRender()}clearError(){this._runtimeError="",this.state==="error"&&(this.state="idle"),this.requestRender()}_syncFromAttributes(){!this.hasAttribute("dismissible")&&this.hasAttribute("closable")&&this.setAttribute("dismissible",this.getAttribute("closable")||"true"),!this.hasAttribute("closable")&&this.hasAttribute("dismissible")&&this.setAttribute("closable",this.getAttribute("dismissible")||"true"),!this.hasAttribute("close-on-overlay")&&this.hasAttribute("close-on-backdrop")&&this.setAttribute("close-on-overlay",this.getAttribute("close-on-backdrop")||"true"),!this.hasAttribute("close-on-backdrop")&&this.hasAttribute("close-on-overlay")&&this.setAttribute("close-on-backdrop",this.getAttribute("close-on-overlay")||"true"),this.hasAttribute("role")||this.setAttribute("role","dialog")}_syncOpenState(){const t=this.hasAttribute("open");if(t&&!this._isActive){this._activate();return}!t&&this._isActive&&this._deactivate()}_activate(){this._isActive=!0,this._terminalEmitted=!1,this._closeMeta=null,n._openStack.includes(this)||n._openStack.push(this),this._lastFocused=document.activeElement||null,w.acquireBodyScrollLock();const t=this.dialogId||this._uid;this._dispatchWithLegacy("ui-open","open",{id:t}),this.dispatchEvent(new CustomEvent("show",{bubbles:!0,composed:!0})),this.requestRender()}_deactivate(){if(!this._isActive)return;this._isActive=!1,this._destroyRuntimeControllers();const t=n._openStack.lastIndexOf(this);if(t>=0&&n._openStack.splice(t,1),w.releaseBodyScrollLock(),!this._terminalEmitted){const e=this._closeMeta||{action:"dismiss",source:"abort"},s=this.dialogId||this._uid;e.action==="cancel"?this._dispatchWithLegacy("ui-cancel","cancel",{id:s}):this._dispatchWithLegacy("ui-dismiss","dismiss",{id:s,source:e.source||"abort",reason:e.reason}),this._dispatchWithLegacy("ui-close","close",{id:s,action:e.action,source:e.source,reason:e.reason}),this.dispatchEvent(new CustomEvent("hide",{bubbles:!0,composed:!0})),this._terminalEmitted=!0,this._closeMeta=null}const i=this._lastFocused;this._lastFocused=null,i&&this._canRestoreFocus(i)&&setTimeout(()=>{try{this._canRestoreFocus(i)&&i.focus()}catch{}},0),this.requestRender()}_dispatchWithLegacy(t,i,e,s=!1){const o=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0,cancelable:s});this.dispatchEvent(o);const r=new CustomEvent(i,{detail:e,bubbles:!0,composed:!0,cancelable:s});return this.dispatchEvent(r),o}_isTopMost(){if(!this._isActive)return!1;const t=n._openStack;return t.length>0&&t[t.length-1]===this}_queryPanel(){return this.root.querySelector(".panel")}_canRestoreFocus(t){if(!t||!t.isConnected||t.disabled||t.getAttribute("aria-hidden")==="true")return!1;if(!S())return!0;const i=window.getComputedStyle(t);return i.display!=="none"&&i.visibility!=="hidden"}_collectFocusable(t){return Array.from(t.querySelectorAll(R)).filter(i=>{if(i.disabled||i.getAttribute("aria-hidden")==="true")return!1;const s=S()?window.getComputedStyle(i):null;return!(s&&(s.display==="none"||s.visibility==="hidden"))})}_focusInitial(){if(!this.open)return;const t=this._queryPanel();if(!t)return;const i=this.getAttribute("initial-focus")||this._config.initialFocus||"";if(i){const r=t.querySelector(i);if(r&&typeof r.focus=="function"){r.focus();return}}const e=this._collectFocusable(t),o=e.find(r=>r.hasAttribute("autofocus"))||e[0]||t;!o.hasAttribute("tabindex")&&o===t&&o.setAttribute("tabindex","-1");try{o.focus()}catch{}}_onFocusIn(t){!this.open||this._isTopMost()}_handleTab(t){t.key}_destroyRuntimeControllers(){var t,i;(t=this._dismissableLayer)==null||t.destroy(),this._dismissableLayer=null,(i=this._focusScope)==null||i.destroy(),this._focusScope=null}_syncRuntimeControllers(){if(this._destroyRuntimeControllers(),!this.open||!this._isTopMost())return;const t=this._queryPanel();t&&(this._dismissableLayer=B.createDismissableLayer({node:t,closeOnEscape:this.closeOnEsc,closeOnPointerOutside:this.closeOnOverlay,closeOnFocusOutside:!1,onBeforeDismiss:(i,e)=>this._isInteractionLocked()?!1:i==="escape-key"?(this.closeDialog("escape"),!1):(i==="outside-pointer"&&this.closeDialog("overlay"),!1)}),this._focusScope=z.createFocusScope({node:t,trapped:!0,loop:!0,restoreFocus:!1,autoFocus:"first",initialFocus:()=>{const i=this.getAttribute("initial-focus")||this._config.initialFocus||"";return i?t.querySelector(i):null}}))}_collectFormData(t){const i=this._queryPanel(),e=t||this.querySelector("form")||(i==null?void 0:i.querySelector("form"))||null;if(!(e instanceof HTMLFormElement)||typeof FormData>"u")return;const s=new FormData(e),o={};for(const[r,h]of s.entries()){const l=String(h);if(o[r]==null){o[r]=l;continue}const c=o[r];Array.isArray(c)?c.push(l):o[r]=[c,l]}return Object.keys(o).length?o:void 0}_resolveSubmitForm(t){var s;if(t){const o=t.closest("form");if(o instanceof HTMLFormElement&&this.contains(o))return o}const i=this.querySelector("form");if(i instanceof HTMLFormElement)return i;const e=(s=this._queryPanel())==null?void 0:s.querySelector("form");return e instanceof HTMLFormElement?e:null}_isInteractionLocked(){return this.state==="loading"&&this.lockWhileLoading}_requestDismiss(t,i){if(!this._isInteractionLocked()){if(t==="overlay"){this.closeDialog("overlay");return}if(t==="esc"){this.closeDialog("escape");return}if(t==="close-icon"){this.closeDialog("button");return}this.close("dismiss",t,i)}}_handleSubmit(t){if(this._isInteractionLocked())return;const i=t??this._resolveSubmitForm();if(i&&typeof i.reportValidity=="function"&&!i.reportValidity())return;const e={id:this.dialogId||this._uid,formData:this._collectFormData(i)};this._dispatchWithLegacy("ui-submit","submit",e,!0).defaultPrevented||this.closeDialog("submit")}_handleCancel(){this._isInteractionLocked()||this.closeDialog("cancel")}_onClick(t){if(!this.open||!this._isTopMost())return;const i=t.target;if(i){if(!i.closest(".panel")&&i.closest(".overlay")&&this.closeOnOverlay){this._requestDismiss("overlay");return}if(i.closest(".close")){this._requestDismiss("close-icon");return}if(i.closest(".btn-submit")){this._handleSubmit();return}i.closest(".btn-cancel")&&this._handleCancel()}}_onSubmit(t){if(!this.open||!this._isTopMost())return;const i=t.target;i&&i!==this&&this.contains(i)&&(t.preventDefault(),t.stopPropagation(),this._handleSubmit(i))}_onKeyDown(t){if(!(!this.open||!this._isTopMost())&&t.key==="Escape"){if(!this.closeOnEsc)return;t.preventDefault(),t.stopPropagation(),this._requestDismiss("esc");return}}render(){if(!this.open){this._destroyRuntimeControllers(),this.setContent("");return}const t=this._config.title??this.getAttribute("title")??"",i=this._config.description??this.getAttribute("description")??"",e=this._config.submitText??this.getAttribute("submit-text")??"Submit",s=this._config.cancelText??this.getAttribute("cancel-text")??"Cancel",o=this._config.loadingText??this.getAttribute("loading-text")??"Working...",r=t.trim(),h=i.trim(),l=!!this.querySelector('[slot="title"]'),c=!!this.querySelector('[slot="description"]'),p=!!(r||l),f=!!(h||c),L=!!this.querySelector('[slot="content"]'),F=!!this.querySelector('[slot="footer"]'),D=this._config.showCancel??!0,q=this._config.showClose??this.dismissible,m=this._runtimeError||this._config.errorMessage||this.getAttribute("error-message")||"",g=this.state==="loading",_=`ui-dialog-title-${this._uid}`,y=`ui-dialog-description-${this._uid}`,x=`ui-dialog-error-${this._uid}`,O=this.getAttribute("aria-label")||"",$=this.getAttribute("aria-labelledby")||"",A=this.getAttribute("aria-describedby")||"",v=$||(p?_:""),k=O||(v?"":"Dialog"),d=[];A?d.push(A):(f&&d.push(y),m&&d.push(x));const T=p||f?`
375
+ `,W='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function g(n,t){if(n==null)return t;const i=n.trim().toLowerCase();return i!=="false"&&i!=="0"&&i!=="off"}function a(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function S(){return typeof window<"u"&&typeof document<"u"}function C(n){return typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>n()):window.setTimeout(n,16)}function p(n){if(n){if(typeof cancelAnimationFrame=="function"){cancelAnimationFrame(n);return}window.clearTimeout(n)}}const E=class l extends z.ElementBase{constructor(){super(),this._isActive=!1,this._uid=Math.random().toString(36).slice(2,10),this._dialogId=this._uid,this._lastFocused=null,this._terminalEmitted=!1,this._closeMeta=null,this._runtimeError="",this._config={},this._dismissableLayer=null,this._focusScope=null,this._disconnectCleanupFrame=0,this._restoreFocusFrame=0,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onSubmit=this._onSubmit.bind(this)}static get observedAttributes(){return["open","headless","title","description","closable","dismissible","close-on-overlay","close-on-backdrop","close-on-esc","lock-while-loading","size","state","role","initial-focus","submit-text","cancel-text","loading-text","error-message","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this._disconnectCleanupFrame&&(p(this._disconnectCleanupFrame),this._disconnectCleanupFrame=0),super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.addEventListener("submit",this._onSubmit),this._syncFromAttributes(),this._syncOpenState()}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("submit",this._onSubmit),this._disconnectCleanupFrame&&p(this._disconnectCleanupFrame),this._restoreFocusFrame&&(p(this._restoreFocusFrame),this._restoreFocusFrame=0),this._disconnectCleanupFrame=C(()=>{this._disconnectCleanupFrame=0,!this.isConnected&&(this._isActive&&!this._terminalEmitted?this.close("dismiss","unmount"):(this._destroyRuntimeControllers(),this._deactivate()),super.disconnectedCallback())})}attributeChangedCallback(t,i,e){if(i!==e){if(t==="open"){this._syncOpenState();return}t==="state"&&e!=="error"&&(this._runtimeError=""),this._syncFromAttributes(),this.isConnected&&this.requestRender()}}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.close("dismiss","programmatic")}get dismissible(){return g(this.getAttribute("dismissible")??this.getAttribute("closable"),!0)}set dismissible(t){this.setAttribute("dismissible",String(t)),this.setAttribute("closable",String(t))}get closeOnOverlay(){return g(this.getAttribute("close-on-overlay")??this.getAttribute("close-on-backdrop"),!0)}set closeOnOverlay(t){this.setAttribute("close-on-overlay",String(t)),this.setAttribute("close-on-backdrop",String(t))}get closeOnEsc(){return g(this.getAttribute("close-on-esc"),!0)}set closeOnEsc(t){this.setAttribute("close-on-esc",String(t))}get lockWhileLoading(){return g(this.getAttribute("lock-while-loading"),!0)}set lockWhileLoading(t){this.setAttribute("lock-while-loading",String(t))}get state(){const t=this.getAttribute("state");return t==="loading"||t==="error"||t==="success"?t:"idle"}set state(t){if(t==="idle"){this.removeAttribute("state");return}this.setAttribute("state",t)}get dialogId(){return this._dialogId}set dialogId(t){this._dialogId=t||this._uid,this.requestRender()}get config(){return this._config}set config(t){this._config=t||{},this._config.id&&(this._dialogId=this._config.id),this._config.dismissible!=null&&(this.dismissible=!!this._config.dismissible),this._config.closeOnOverlay!=null&&(this.closeOnOverlay=!!this._config.closeOnOverlay),this._config.closeOnEsc!=null&&(this.closeOnEsc=!!this._config.closeOnEsc),this._config.lockWhileLoading!=null&&(this.lockWhileLoading=!!this._config.lockWhileLoading),this._config.size&&this.setAttribute("size",this._config.size),this._config.role&&this.setAttribute("role",this._config.role),this._config.initialFocus&&this.setAttribute("initial-focus",this._config.initialFocus),this._config.ariaLabel&&this.setAttribute("aria-label",this._config.ariaLabel),this._config.ariaLabelledby&&this.setAttribute("aria-labelledby",this._config.ariaLabelledby),this._config.ariaDescribedby&&this.setAttribute("aria-describedby",this._config.ariaDescribedby),this._config.errorMessage&&(this._runtimeError=this._config.errorMessage),this.requestRender()}openDialog(){this.setAttribute("open","")}closeDialog(t="programmatic"){if(!this.hasAttribute("open"))return;const i=new CustomEvent("request-close",{detail:{reason:t},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i);const e=new CustomEvent("ui-request-close",{detail:{id:this.dialogId||this._uid,reason:t},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(e),!(i.defaultPrevented||e.defaultPrevented)){if(t==="submit"){this.close("submit");return}if(t==="cancel"){this.close("cancel");return}if(t==="overlay"){this.close("dismiss","overlay");return}if(t==="escape"){this.close("dismiss","esc");return}if(t==="button"){this.close("dismiss","close-icon");return}this.close("dismiss","programmatic")}}close(t="dismiss",i,e){this._terminalEmitted||(this._closeMeta={action:t,source:i,reason:e},this.hasAttribute("open")&&this.removeAttribute("open"),this._syncOpenState())}setError(t){this._runtimeError=t,this.state=t?"error":"idle",this.requestRender()}clearError(){this._runtimeError="",this.state==="error"&&(this.state="idle"),this.requestRender()}_syncFromAttributes(){!this.hasAttribute("dismissible")&&this.hasAttribute("closable")&&this.setAttribute("dismissible",this.getAttribute("closable")||"true"),!this.hasAttribute("closable")&&this.hasAttribute("dismissible")&&this.setAttribute("closable",this.getAttribute("dismissible")||"true"),!this.hasAttribute("close-on-overlay")&&this.hasAttribute("close-on-backdrop")&&this.setAttribute("close-on-overlay",this.getAttribute("close-on-backdrop")||"true"),!this.hasAttribute("close-on-backdrop")&&this.hasAttribute("close-on-overlay")&&this.setAttribute("close-on-backdrop",this.getAttribute("close-on-overlay")||"true"),this.hasAttribute("role")||this.setAttribute("role","dialog")}_syncOpenState(){const t=this.hasAttribute("open");t&&!this._isActive?this._activate():!t&&this._isActive&&this._deactivate(),this._syncOpenUi()}_activate(){this._isActive=!0,this._terminalEmitted=!1,this._closeMeta=null,l._openStack.includes(this)||l._openStack.push(this),this._lastFocused=document.activeElement||null,F.acquireBodyScrollLock();const t=this.dialogId||this._uid;this._dispatchWithLegacy("ui-open","open",{id:t}),this.dispatchEvent(new CustomEvent("show",{bubbles:!0,composed:!0})),this._syncOpenUi(),this._syncRuntimeControllers()}_deactivate(){if(!this._isActive)return;this._isActive=!1,this._destroyRuntimeControllers();const t=l._openStack.lastIndexOf(this);if(t>=0&&l._openStack.splice(t,1),F.releaseBodyScrollLock(),!this._terminalEmitted){const e=this._closeMeta||{action:"dismiss",source:"abort"},s=this.dialogId||this._uid;e.action==="cancel"?this._dispatchWithLegacy("ui-cancel","cancel",{id:s}):this._dispatchWithLegacy("ui-dismiss","dismiss",{id:s,source:e.source||"abort",reason:e.reason}),this._dispatchWithLegacy("ui-close","close",{id:s,action:e.action,source:e.source,reason:e.reason}),this.dispatchEvent(new CustomEvent("hide",{bubbles:!0,composed:!0})),this._terminalEmitted=!0,this._closeMeta=null}const i=this._lastFocused;this._lastFocused=null,i&&this._canRestoreFocus(i)&&(this._restoreFocusFrame&&p(this._restoreFocusFrame),this._restoreFocusFrame=C(()=>{this._restoreFocusFrame=0;try{this._canRestoreFocus(i)&&i.focus()}catch{}})),this._syncOpenUi()}_dispatchWithLegacy(t,i,e,s=!1){const o=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0,cancelable:s});this.dispatchEvent(o);const r=new CustomEvent(i,{detail:e,bubbles:!0,composed:!0,cancelable:s});return this.dispatchEvent(r),o}_isTopMost(){if(!this._isActive)return!1;const t=l._openStack;return t.length>0&&t[t.length-1]===this}_queryPanel(){return this.root.querySelector(".panel")}_canRestoreFocus(t){if(!t||!t.isConnected||t.disabled||t.getAttribute("aria-hidden")==="true")return!1;if(!S())return!0;const i=window.getComputedStyle(t);return i.display!=="none"&&i.visibility!=="hidden"}_collectFocusable(t){return Array.from(t.querySelectorAll(W)).filter(i=>{if(i.disabled||i.getAttribute("aria-hidden")==="true")return!1;const s=S()?window.getComputedStyle(i):null;return!(s&&(s.display==="none"||s.visibility==="hidden"))})}_focusInitial(){if(!this.open)return;const t=this._queryPanel();if(!t)return;const i=this.getAttribute("initial-focus")||this._config.initialFocus||"";if(i){const r=t.querySelector(i);if(r&&typeof r.focus=="function"){r.focus();return}}const e=this._collectFocusable(t),o=e.find(r=>r.hasAttribute("autofocus"))||e[0]||t;!o.hasAttribute("tabindex")&&o===t&&o.setAttribute("tabindex","-1");try{o.focus()}catch{}}_onFocusIn(t){!this.open||this._isTopMost()}_handleTab(t){t.key}_destroyRuntimeControllers(){var t,i;(t=this._dismissableLayer)==null||t.destroy(),this._dismissableLayer=null,(i=this._focusScope)==null||i.destroy(),this._focusScope=null}_syncOpenUi(){const t=this.root.querySelector(".overlay"),i=this._queryPanel(),e=this.open;!t||!i||(t.hidden=!e,t.setAttribute("data-open",String(e)),t.setAttribute("aria-hidden",e?"false":"true"),i.setAttribute("aria-hidden",e?"false":"true"))}_syncRuntimeControllers(){if(this._destroyRuntimeControllers(),!this.open||!this._isTopMost())return;const t=this._queryPanel();t&&(this._dismissableLayer=M.createDismissableLayer({node:t,closeOnEscape:this.closeOnEsc,closeOnPointerOutside:this.closeOnOverlay,closeOnFocusOutside:!1,onBeforeDismiss:(i,e)=>this._isInteractionLocked()?!1:i==="escape-key"?(this.closeDialog("escape"),!1):(i==="outside-pointer"&&this.closeDialog("overlay"),!1)}),this._focusScope=R.createFocusScope({node:t,trapped:!0,loop:!0,restoreFocus:!1,autoFocus:"first",initialFocus:()=>{const i=this.getAttribute("initial-focus")||this._config.initialFocus||"";return i?t.querySelector(i):null}}))}_collectFormData(t){const i=this._queryPanel(),e=t||this.querySelector("form")||(i==null?void 0:i.querySelector("form"))||null;if(!(e instanceof HTMLFormElement)||typeof FormData>"u")return;const s=new FormData(e),o={};for(const[r,h]of s.entries()){const c=String(h);if(o[r]==null){o[r]=c;continue}const d=o[r];Array.isArray(d)?d.push(c):o[r]=[d,c]}return Object.keys(o).length?o:void 0}_resolveSubmitForm(t){var s;if(t){const o=t.closest("form");if(o instanceof HTMLFormElement&&this.contains(o))return o}const i=this.querySelector("form");if(i instanceof HTMLFormElement)return i;const e=(s=this._queryPanel())==null?void 0:s.querySelector("form");return e instanceof HTMLFormElement?e:null}_isInteractionLocked(){return this.state==="loading"&&this.lockWhileLoading}_requestDismiss(t,i){if(!this._isInteractionLocked()){if(t==="overlay"){this.closeDialog("overlay");return}if(t==="esc"){this.closeDialog("escape");return}if(t==="close-icon"){this.closeDialog("button");return}this.close("dismiss",t,i)}}_handleSubmit(t){if(this._isInteractionLocked())return;const i=t??this._resolveSubmitForm();if(i&&typeof i.reportValidity=="function"&&!i.reportValidity())return;const e={id:this.dialogId||this._uid,formData:this._collectFormData(i)};this._dispatchWithLegacy("ui-submit","submit",e,!0).defaultPrevented||this.closeDialog("submit")}_handleCancel(){this._isInteractionLocked()||this.closeDialog("cancel")}_onClick(t){if(!this.open||!this._isTopMost())return;const i=t.target;if(i){if(!i.closest(".panel")&&i.closest(".overlay")&&this.closeOnOverlay){this._requestDismiss("overlay");return}if(i.closest(".close")){this._requestDismiss("close-icon");return}if(i.closest(".btn-submit")){this._handleSubmit();return}i.closest(".btn-cancel")&&this._handleCancel()}}_onSubmit(t){if(!this.open||!this._isTopMost())return;const i=t.target;i&&i!==this&&this.contains(i)&&(t.preventDefault(),t.stopPropagation(),this._handleSubmit(i))}_onKeyDown(t){if(!(!this.open||!this._isTopMost())&&t.key==="Escape"){if(!this.closeOnEsc)return;t.preventDefault(),t.stopPropagation(),this._requestDismiss("esc");return}}render(){const t=this._config.title??this.getAttribute("title")??"",i=this._config.description??this.getAttribute("description")??"",e=this._config.submitText??this.getAttribute("submit-text")??"Submit",s=this._config.cancelText??this.getAttribute("cancel-text")??"Cancel",o=this._config.loadingText??this.getAttribute("loading-text")??"Working...",r=t.trim(),h=i.trim(),c=!!this.querySelector('[slot="title"]'),d=!!this.querySelector('[slot="description"]'),f=!!(r||c),m=!!(h||d),O=!!this.querySelector('[slot="content"]'),D=!!this.querySelector('[slot="footer"]'),q=this._config.showCancel??!0,$=this._config.showClose??this.dismissible,v=this._runtimeError||this._config.errorMessage||this.getAttribute("error-message")||"",b=this.state==="loading",y=`ui-dialog-title-${this._uid}`,x=`ui-dialog-description-${this._uid}`,A=`ui-dialog-error-${this._uid}`,T=this.getAttribute("aria-label")||"",I=this.getAttribute("aria-labelledby")||"",k=this.getAttribute("aria-describedby")||"",_=I||(f?y:""),w=T||(_?"":"Dialog"),u=[];k?u.push(k):(m&&u.push(x),v&&u.push(A));const B=f||m?`
368
376
  <header class="header" part="header">
369
- ${p?`<h2 id="${_}" class="title" part="title"><slot name="title">${a(r)}</slot></h2>`:""}
370
- ${f?`<p id="${y}" class="description" part="description"><slot name="description">${a(h)}</slot></p>`:""}
377
+ ${f?`<h2 id="${y}" class="title" part="title"><slot name="title">${a(r)}</slot></h2>`:""}
378
+ ${m?`<p id="${x}" class="description" part="description"><slot name="description">${a(h)}</slot></p>`:""}
371
379
  </header>
372
380
  `:"";this._destroyRuntimeControllers(),this.setContent(`
373
- ${this.hasAttribute("headless")?"":`<style>${M}</style>`}
374
- <div class="overlay" part="overlay" data-open="${String(this.open)}">
381
+ ${this.hasAttribute("headless")?"":`<style>${P}</style>`}
382
+ <div class="overlay" part="overlay" data-open="${String(this.open)}" ${this.open?"":"hidden"} aria-hidden="${this.open?"false":"true"}">
375
383
  <section
376
384
  class="panel"
377
385
  part="panel"
378
386
  role="${a(this.getAttribute("role")||"dialog")}"
379
387
  aria-modal="true"
380
- ${k?`aria-label="${a(k)}"`:""}
381
- ${v?`aria-labelledby="${a(v)}"`:""}
382
- ${d.length?`aria-describedby="${a(d.join(" "))}"`:""}
388
+ ${w?`aria-label="${a(w)}"`:""}
389
+ ${_?`aria-labelledby="${a(_)}"`:""}
390
+ ${u.length?`aria-describedby="${a(u.join(" "))}"`:""}
391
+ aria-hidden="${this.open?"false":"true"}"
383
392
  tabindex="-1"
384
393
  >
385
- ${q?`<button class="close" part="close" aria-label="Close dialog" type="button" ${g?"disabled":""}>
394
+ ${$?`<button class="close" part="close" aria-label="Close dialog" type="button" ${b?"disabled":""}>
386
395
  <svg class="close-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true">
387
396
  <path d="M3.5 3.5L12.5 12.5"></path>
388
397
  <path d="M12.5 3.5L3.5 12.5"></path>
389
398
  </svg>
390
399
  </button>`:""}
391
- ${T}
400
+ ${B}
392
401
  <div class="body" part="body">
393
- ${L?'<slot name="content"></slot>':"<slot></slot>"}
402
+ ${O?'<slot name="content"></slot>':"<slot></slot>"}
394
403
  </div>
395
404
 
396
- <div class="error" id="${x}" part="error" aria-live="polite" data-empty="${String(!m)}">${a(m)}</div>
405
+ <div class="error" id="${A}" part="error" aria-live="polite" data-empty="${String(!v)}">${a(v)}</div>
397
406
 
398
407
  <footer class="footer" part="footer">
399
- ${g?`<span class="loading" part="loading"><span class="spinner" aria-hidden="true"></span><span>${a(o)}</span></span>`:'<span aria-hidden="true"></span>'}
408
+ ${b?`<span class="loading" part="loading"><span class="spinner" aria-hidden="true"></span><span>${a(o)}</span></span>`:'<span aria-hidden="true"></span>'}
400
409
 
401
- ${F?'<slot name="footer"></slot>':`${D?`<button class="btn btn-cancel" part="cancel" type="button" ${g?"disabled":""}>${a(s)}</button>`:""}
402
- <button class="btn btn-submit" part="submit" type="button" ${g?"disabled":""}>${a(e)}</button>`}
410
+ ${D?'<slot name="footer"></slot>':`${q?`<button class="btn btn-cancel" part="cancel" type="button" ${b?"disabled":""}>${a(s)}</button>`:""}
411
+ <button class="btn btn-submit" part="submit" type="button" ${b?"disabled":""}>${a(e)}</button>`}
403
412
  </footer>
404
413
  </section>
405
414
  </div>
406
- `),this._syncRuntimeControllers()}};E._openStack=[];let C=E;typeof customElements<"u"&&!customElements.get("ui-dialog")&&customElements.define("ui-dialog",C);exports.UIDialog=C;
415
+ `),this._syncOpenUi(),this.open?this._syncRuntimeControllers():this._destroyRuntimeControllers()}};E._openStack=[];let L=E;typeof customElements<"u"&&!customElements.get("ui-dialog")&&customElements.define("ui-dialog",L);exports.UIDialog=L;