bank20baht-ui 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
1
  import { nothing as h, html as l, svg as R } from "lit";
2
- import { property as n, customElement as f, state as v, query as It } from "lit/decorators.js";
3
- import { B as y, b as ce, h as T, a as X } from "./base-D1pT3J5T.js";
2
+ import { property as n, customElement as f, state as v, query as Bt } from "lit/decorators.js";
3
+ import { B as y, b as ce, h as j, a as X } from "./base-D1pT3J5T.js";
4
4
  import { t as u } from "./i18n-CWv5lrun.js";
5
- import { s as ye, m as qt, t as ws, j as Vt, p as xs, d as ie, a as ps, o as Re, v as ze, k as ge, q as we, c as _s, M as Ve, e as ks, h as Os, n as Ps } from "./display-CX-bz0Da.js";
5
+ import { k as Re, j as ae, u as ye, n as qt, o as ws, x as xs, p as _s, d as ie, a as ps, s as ze, v as Ve, l as ge, t as we, c as ks, M as Ke, e as Os, h as Ps, q as Cs } from "./display-Cm3Pmp9U.js";
6
6
  import { repeat as Fe } from "lit/directives/repeat.js";
7
- import { html as ae, unsafeStatic as ds } from "lit/static-html.js";
8
- import { r as j, e as Cs, i as us, d as pe, c as bs } from "./baht-toast-8qUXxEvh.js";
7
+ import { html as se, unsafeStatic as ds } from "lit/static-html.js";
8
+ import { r as T, e as Ds, i as us, d as pe, c as bs } from "./baht-toast-8qUXxEvh.js";
9
9
  import { live as Z } from "lit/directives/live.js";
10
10
  import { ifDefined as L } from "lit/directives/if-defined.js";
11
- import Ds from "flatpickr";
12
- var Ss = Object.defineProperty, Fs = Object.getOwnPropertyDescriptor, de = (t, e, a, i) => {
13
- for (var s = i > 1 ? void 0 : i ? Fs(e, a) : e, r = t.length - 1, o; r >= 0; r--)
14
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
15
- return i && s && Ss(e, a, s), s;
11
+ import Ss from "flatpickr";
12
+ var Fs = Object.defineProperty, Ms = Object.getOwnPropertyDescriptor, de = (t, e, s, i) => {
13
+ for (var a = i > 1 ? void 0 : i ? Ms(e, s) : e, r = t.length - 1, o; r >= 0; r--)
14
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
15
+ return i && a && Fs(e, s, a), a;
16
16
  };
17
- let Kt = class extends y {
17
+ let Vt = class extends y {
18
18
  constructor() {
19
19
  super(...arguments), this.tone = "neutral", this.label = "", this.dot = null;
20
20
  }
@@ -30,20 +30,20 @@ let Kt = class extends y {
30
30
  };
31
31
  de([
32
32
  n()
33
- ], Kt.prototype, "tone", 2);
33
+ ], Vt.prototype, "tone", 2);
34
34
  de([
35
35
  n()
36
- ], Kt.prototype, "label", 2);
36
+ ], Vt.prototype, "label", 2);
37
37
  de([
38
38
  n({ attribute: !1 })
39
- ], Kt.prototype, "dot", 2);
40
- Kt = de([
39
+ ], Vt.prototype, "dot", 2);
40
+ Vt = de([
41
41
  f("baht-badge")
42
- ], Kt);
43
- var Ms = Object.defineProperty, Bs = Object.getOwnPropertyDescriptor, Ee = (t, e, a, i) => {
44
- for (var s = i > 1 ? void 0 : i ? Bs(e, a) : e, r = t.length - 1, o; r >= 0; r--)
45
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
46
- return i && s && Ms(e, a, s), s;
42
+ ], Vt);
43
+ var Is = Object.defineProperty, Bs = Object.getOwnPropertyDescriptor, Ee = (t, e, s, i) => {
44
+ for (var a = i > 1 ? void 0 : i ? Bs(e, s) : e, r = t.length - 1, o; r >= 0; r--)
45
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
46
+ return i && a && Is(e, s, a), a;
47
47
  };
48
48
  let re = class extends y {
49
49
  constructor() {
@@ -66,10 +66,10 @@ Ee([
66
66
  re = Ee([
67
67
  f("baht-code")
68
68
  ], re);
69
- var Is = Object.defineProperty, js = Object.getOwnPropertyDescriptor, gt = (t, e, a, i) => {
70
- for (var s = i > 1 ? void 0 : i ? js(e, a) : e, r = t.length - 1, o; r >= 0; r--)
71
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
72
- return i && s && Is(e, a, s), s;
69
+ var Ts = Object.defineProperty, js = Object.getOwnPropertyDescriptor, gt = (t, e, s, i) => {
70
+ for (var a = i > 1 ? void 0 : i ? js(e, s) : e, r = t.length - 1, o; r >= 0; r--)
71
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
72
+ return i && a && Ts(e, s, a), a;
73
73
  };
74
74
  let ht = class extends y {
75
75
  constructor() {
@@ -84,12 +84,12 @@ let ht = class extends y {
84
84
  }
85
85
  /** Visible page numbers with `null` marking an ellipsis gap. */
86
86
  get pageItems() {
87
- const { page: t, totalPages: e, siblings: a } = this, i = /* @__PURE__ */ new Set([1, e]);
88
- for (let c = t - a; c <= t + a; c++)
87
+ const { page: t, totalPages: e, siblings: s } = this, i = /* @__PURE__ */ new Set([1, e]);
88
+ for (let c = t - s; c <= t + s; c++)
89
89
  c >= 1 && c <= e && i.add(c);
90
- const s = [...i].sort((c, m) => c - m), r = [];
90
+ const a = [...i].sort((c, m) => c - m), r = [];
91
91
  let o = 0;
92
- for (const c of s)
92
+ for (const c of a)
93
93
  o && c - o === 2 ? r.push(o + 1) : o && c - o > 2 && r.push(null), r.push(c), o = c;
94
94
  return r;
95
95
  }
@@ -103,12 +103,12 @@ let ht = class extends y {
103
103
  return l`<nav class="baht-pagination" aria-label="Pagination">
104
104
  <button type="button" aria-label="Previous page" ?disabled=${t} @click=${() => this.go(this.page - 1)}><span aria-hidden="true">«</span></button>
105
105
  ${this.variant === "compact" ? l`<span class="baht-pagination-label">Page ${this.page} of ${this.totalPages}</span>` : this.pageItems.map(
106
- (a) => a === null ? l`<span class="baht-pagination-ellipsis" aria-hidden="true">…</span>` : l`<button
106
+ (s) => s === null ? l`<span class="baht-pagination-ellipsis" aria-hidden="true">…</span>` : l`<button
107
107
  type="button"
108
- aria-current=${a === this.page ? "page" : h}
109
- aria-label="Page ${a}"
110
- @click=${() => this.go(a)}
111
- >${a}</button>`
108
+ aria-current=${s === this.page ? "page" : h}
109
+ aria-label="Page ${s}"
110
+ @click=${() => this.go(s)}
111
+ >${s}</button>`
112
112
  )}
113
113
  <button type="button" aria-label="Next page" ?disabled=${e} @click=${() => this.go(this.page + 1)}><span aria-hidden="true">»</span></button>
114
114
  </nav>`;
@@ -135,12 +135,12 @@ gt([
135
135
  ht = gt([
136
136
  f("baht-pagination")
137
137
  ], ht);
138
- var Ts = Object.defineProperty, As = Object.getOwnPropertyDescriptor, O = (t, e, a, i) => {
139
- for (var s = i > 1 ? void 0 : i ? As(e, a) : e, r = t.length - 1, o; r >= 0; r--)
140
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
141
- return i && s && Ts(e, a, s), s;
138
+ var As = Object.defineProperty, Es = Object.getOwnPropertyDescriptor, O = (t, e, s, i) => {
139
+ for (var a = i > 1 ? void 0 : i ? Es(e, s) : e, r = t.length - 1, o; r >= 0; r--)
140
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
141
+ return i && a && As(e, s, a), a;
142
142
  };
143
- const Es = " › ", xe = (t) => t !== null && typeof t == "object" && !Array.isArray(t) && !(t instanceof Date), se = (t) => t.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
143
+ const Ls = " › ", xe = (t) => t !== null && typeof t == "object" && !Array.isArray(t) && !(t instanceof Date), ee = (t) => t.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
144
144
  let x = class extends y {
145
145
  constructor() {
146
146
  super(...arguments), this.items = [], this.columns = {}, this.loading = !1, this.error = !1, this.errorMessage = "Couldn't load data. Try again.", this.emptyMessage = "No records yet.", this.showIndex = !0, this.indexOffset = 0, this.skeletonRows = 10, this.rowKey = "", this.clickable = !0, this.renderers = {}, this.visibleColumns = [], this.columnPicker = !0, this.selectable = !1, this.selected = [], this.sortable = !1, this.sort = null, this.rowActions = !1, this.page = 1, this.totalPages = 1, this.cursorMode = !1, this.hasNext = !1, this.hasPrev = !1, this.pickerOpen = !1, this.pickedColumns = null, this.draftColumns = [], this.pickAvail = [], this.pickSel = [], this.expanded = [], this.pickerPreviousFocus = null, this.onPickerKeydown = (t) => {
@@ -162,11 +162,11 @@ let x = class extends y {
162
162
  trapPickerFocus(t) {
163
163
  const e = this.pickerFocusables();
164
164
  if (e.length === 0) return;
165
- const a = e[0], i = e[e.length - 1], s = document.activeElement, r = this.querySelector(".baht-table-picker-modal");
166
- r != null && r.contains(s) ? t.shiftKey && s === a ? (i.focus(), t.preventDefault()) : !t.shiftKey && s === i && (a.focus(), t.preventDefault()) : (a.focus(), t.preventDefault());
165
+ const s = e[0], i = e[e.length - 1], a = document.activeElement, r = this.querySelector(".baht-table-picker-modal");
166
+ r != null && r.contains(a) ? t.shiftKey && a === s ? (i.focus(), t.preventDefault()) : !t.shiftKey && a === i && (s.focus(), t.preventDefault()) : (s.focus(), t.preventDefault());
167
167
  }
168
168
  disconnectedCallback() {
169
- super.disconnectedCallback(), T() && document.removeEventListener("keydown", this.onPickerKeydown);
169
+ super.disconnectedCallback(), j() && document.removeEventListener("keydown", this.onPickerKeydown);
170
170
  }
171
171
  willUpdate(t) {
172
172
  t.has("visibleColumns") && !t.has("columns") && (this.pickedColumns = null);
@@ -178,23 +178,23 @@ let x = class extends y {
178
178
  const t = this.items[0];
179
179
  if (!t) return {};
180
180
  const e = {};
181
- for (const [a, i] of Object.entries(t))
182
- e[a] = xe(i) ? {
183
- label: se(a),
184
- fields: Object.fromEntries(Object.keys(i).map((s) => [s, se(s)]))
185
- } : se(a);
181
+ for (const [s, i] of Object.entries(t))
182
+ e[s] = xe(i) ? {
183
+ label: ee(s),
184
+ fields: Object.fromEntries(Object.keys(i).map((a) => [a, ee(a)]))
185
+ } : ee(s);
186
186
  return e;
187
187
  }
188
188
  /** Walk a dotted key through the spec; undefined when no such column exists. */
189
189
  specAt(t) {
190
- let e = this.spec, a;
190
+ let e = this.spec, s;
191
191
  for (const i of t.split(".")) {
192
- const s = e == null ? void 0 : e[i];
193
- if (s === void 0) return;
194
- const r = typeof s == "string" ? { label: s } : s;
195
- a = r, e = r.fields;
192
+ const a = e == null ? void 0 : e[i];
193
+ if (a === void 0) return;
194
+ const r = typeof a == "string" ? { label: a } : a;
195
+ s = r, e = r.fields;
196
196
  }
197
- return a;
197
+ return s;
198
198
  }
199
199
  isReference(t) {
200
200
  var e;
@@ -202,11 +202,11 @@ let x = class extends y {
202
202
  }
203
203
  childrenOf(t) {
204
204
  var e;
205
- return Object.keys(((e = this.specAt(t)) == null ? void 0 : e.fields) ?? {}).map((a) => `${t}.${a}`);
205
+ return Object.keys(((e = this.specAt(t)) == null ? void 0 : e.fields) ?? {}).map((s) => `${t}.${s}`);
206
206
  }
207
207
  /** Every pickable key, reference fields included (`requester`, `requester.name`, ...). */
208
208
  allPaths(t = "") {
209
- return (t ? this.childrenOf(t) : this.allColumnKeys).flatMap((a) => this.isReference(a) ? [a, ...this.allPaths(a)] : [a]);
209
+ return (t ? this.childrenOf(t) : this.allColumnKeys).flatMap((s) => this.isReference(s) ? [s, ...this.allPaths(s)] : [s]);
210
210
  }
211
211
  get allColumnKeys() {
212
212
  return Object.keys(this.spec);
@@ -217,29 +217,29 @@ let x = class extends y {
217
217
  /** "Requested by › Department" for a dotted key; the plain label otherwise. */
218
218
  labelFor(t) {
219
219
  const e = [];
220
- let a = this.spec;
220
+ let s = this.spec;
221
221
  for (const i of t.split(".")) {
222
- const s = a == null ? void 0 : a[i];
223
- if (s === void 0) {
224
- e.push(se(i)), a = void 0;
222
+ const a = s == null ? void 0 : s[i];
223
+ if (a === void 0) {
224
+ e.push(ee(i)), s = void 0;
225
225
  continue;
226
226
  }
227
- e.push(typeof s == "string" ? s : s.label), a = typeof s == "string" ? void 0 : s.fields;
227
+ e.push(typeof a == "string" ? a : a.label), s = typeof a == "string" ? void 0 : a.fields;
228
228
  }
229
- return e.join(Es);
229
+ return e.join(Ls);
230
230
  }
231
231
  /** The row's value at a dotted key (`requester.department`). */
232
232
  static valueAt(t, e) {
233
- let a = t;
233
+ let s = t;
234
234
  for (const i of e.split(".")) {
235
- if (!xe(a)) return;
236
- a = a[i];
235
+ if (!xe(s)) return;
236
+ s = s[i];
237
237
  }
238
- return a;
238
+ return s;
239
239
  }
240
240
  // ---- picker -----------------------------------------------------------
241
241
  openPicker() {
242
- this.draftColumns = this.columnKeys.slice(), this.pickAvail = [], this.pickSel = [], this.pickerOpen = !0, this.pickerPreviousFocus = document.activeElement, T() && document.addEventListener("keydown", this.onPickerKeydown), this.updateComplete.then(() => {
242
+ this.draftColumns = this.columnKeys.slice(), this.pickAvail = [], this.pickSel = [], this.pickerOpen = !0, this.pickerPreviousFocus = document.activeElement, j() && document.addEventListener("keydown", this.onPickerKeydown), this.updateComplete.then(() => {
243
243
  var t;
244
244
  this.pickerOpen && ((t = this.pickerFocusables()[0]) == null || t.focus());
245
245
  });
@@ -247,7 +247,7 @@ let x = class extends y {
247
247
  closePicker() {
248
248
  var e;
249
249
  if (!this.pickerOpen) return;
250
- this.pickerOpen = !1, T() && document.removeEventListener("keydown", this.onPickerKeydown);
250
+ this.pickerOpen = !1, j() && document.removeEventListener("keydown", this.onPickerKeydown);
251
251
  const t = this.pickerPreviousFocus;
252
252
  this.pickerPreviousFocus = null, t != null && t.isConnected && ((e = t.focus) == null || e.call(t));
253
253
  }
@@ -270,10 +270,10 @@ let x = class extends y {
270
270
  this.draftColumns = this.draftColumns.filter((t) => !this.pickSel.includes(t)), this.pickSel = [];
271
271
  }
272
272
  moveSelected(t) {
273
- const e = [...this.draftColumns], a = this.pickSel.map((i) => e.indexOf(i)).filter((i) => i >= 0).sort((i, s) => t === -1 ? i - s : s - i);
274
- for (const i of a) {
275
- const s = i + t;
276
- s < 0 || s >= e.length || ([e[i], e[s]] = [e[s], e[i]]);
273
+ const e = [...this.draftColumns], s = this.pickSel.map((i) => e.indexOf(i)).filter((i) => i >= 0).sort((i, a) => t === -1 ? i - a : a - i);
274
+ for (const i of s) {
275
+ const a = i + t;
276
+ a < 0 || a >= e.length || ([e[i], e[a]] = [e[a], e[i]]);
277
277
  }
278
278
  this.draftColumns = e;
279
279
  }
@@ -300,11 +300,11 @@ let x = class extends y {
300
300
  return this.selected.includes(this.keyOf(t, e));
301
301
  }
302
302
  emitSelection(t) {
303
- const e = this.items.filter((a, i) => t.includes(this.keyOf(a, i)));
303
+ const e = this.items.filter((s, i) => t.includes(this.keyOf(s, i)));
304
304
  this.emit("baht-selection-change", { selected: t, rows: e });
305
305
  }
306
306
  toggleRow(t, e) {
307
- const a = this.keyOf(t, e), i = this.isSelected(t, e) ? this.selected.filter((s) => s !== a) : [...this.selected, a];
307
+ const s = this.keyOf(t, e), i = this.isSelected(t, e) ? this.selected.filter((a) => a !== s) : [...this.selected, s];
308
308
  this.emitSelection(i);
309
309
  }
310
310
  get pageKeys() {
@@ -332,8 +332,8 @@ let x = class extends y {
332
332
  return this.sortable || ((e = this.specAt(t)) == null ? void 0 : e.sortable) === !0;
333
333
  }
334
334
  requestSort(t) {
335
- var a;
336
- const e = ((a = this.sort) == null ? void 0 : a.key) === t && this.sort.direction === "asc" ? "desc" : "asc";
335
+ var s;
336
+ const e = ((s = this.sort) == null ? void 0 : s.key) === t && this.sort.direction === "asc" ? "desc" : "asc";
337
337
  this.emit("baht-sort-change", { key: t, direction: e });
338
338
  }
339
339
  /** Alignment class for a column (explicit `align` beats `numeric`). */
@@ -342,11 +342,11 @@ let x = class extends y {
342
342
  return e != null && e.align ? ` baht-table-align-${e.align}` : e != null && e.numeric ? " baht-table-numeric" : "";
343
343
  }
344
344
  cell(t, e) {
345
- const a = this.renderers[e], i = x.valueAt(t, e);
346
- if (a) return a(i, t);
345
+ const s = this.renderers[e], i = x.valueAt(t, e);
346
+ if (s) return s(i, t);
347
347
  if (xe(i)) {
348
- const s = i.name ?? i.label ?? i.title ?? i.id;
349
- return s == null ? "" : String(s);
348
+ const a = i.name ?? i.label ?? i.title ?? i.id;
349
+ return a == null ? "" : String(a);
350
350
  }
351
351
  return i == null ? "" : String(i);
352
352
  }
@@ -354,36 +354,36 @@ let x = class extends y {
354
354
  const e = t.length + (this.showIndex ? 1 : 0) + (this.selectable ? 1 : 0) + (this.rowActions ? 1 : 0);
355
355
  return this.loading ? l`${Array.from(
356
356
  { length: this.skeletonRows },
357
- (a, i) => l`<tr class="baht-table-row">
357
+ (s, i) => l`<tr class="baht-table-row">
358
358
  ${this.selectable ? l`<td class="baht-table-select"></td>` : h}
359
359
  ${this.showIndex ? l`<td class="baht-table-index">${this.indexOffset + i + 1}</td>` : h}
360
360
  ${t.map(() => l`<td><span class="baht-skeleton" style="height:16px;"></span></td>`)}
361
361
  ${this.rowActions ? l`<td class="baht-table-actions"></td>` : h}
362
362
  </tr>`
363
- )}` : this.error ? l`<tr><td colspan=${e}><div class="baht-table-state baht-table-state--error" role="alert">${this.errorMessage}</div></td></tr>` : this.items.length === 0 ? l`<tr><td colspan=${e}><div class="baht-table-state">${this.emptyMessage}</div></td></tr>` : l`${this.items.map((a, i) => {
364
- const s = this.selectable && this.isSelected(a, i);
363
+ )}` : this.error ? l`<tr><td colspan=${e}><div class="baht-table-state baht-table-state--error" role="alert">${this.errorMessage}</div></td></tr>` : this.items.length === 0 ? l`<tr><td colspan=${e}><div class="baht-table-state">${this.emptyMessage}</div></td></tr>` : l`${this.items.map((s, i) => {
364
+ const a = this.selectable && this.isSelected(s, i);
365
365
  return l`<tr
366
- class="baht-table-row${s ? " baht-table-row--selected" : ""}"
367
- aria-selected=${this.selectable ? s ? "true" : "false" : h}
366
+ class="baht-table-row${a ? " baht-table-row--selected" : ""}"
367
+ aria-selected=${this.selectable ? a ? "true" : "false" : h}
368
368
  tabindex=${this.clickable ? "0" : h}
369
- @click=${() => this.emitRow(a, i)}
369
+ @click=${() => this.emitRow(s, i)}
370
370
  @keydown=${(r) => {
371
- r.key !== "Enter" && r.key !== " " || r.target === r.currentTarget && (r.preventDefault(), this.emitRow(a, i));
371
+ r.key !== "Enter" && r.key !== " " || r.target === r.currentTarget && (r.preventDefault(), this.emitRow(s, i));
372
372
  }}
373
373
  >
374
374
  ${this.selectable ? l`<td class="baht-table-select">
375
375
  <input
376
376
  type="checkbox"
377
377
  aria-label=${u("selectRow", { n: this.indexOffset + i + 1 })}
378
- .checked=${s}
378
+ .checked=${a}
379
379
  @click=${(r) => {
380
- r.stopPropagation(), this.toggleRow(a, i);
380
+ r.stopPropagation(), this.toggleRow(s, i);
381
381
  }}
382
382
  />
383
383
  </td>` : h}
384
384
  ${this.showIndex ? l`<td class="baht-table-index">${this.indexOffset + i + 1}</td>` : h}
385
385
  ${t.map(
386
- (r) => l`<td data-col=${r} class="baht-table-cell${this.alignClass(r)}">${this.cell(a, r)}</td>`
386
+ (r) => l`<td data-col=${r} class="baht-table-cell${this.alignClass(r)}">${this.cell(s, r)}</td>`
387
387
  )}
388
388
  ${this.rowActions ? l`<td class="baht-table-actions">
389
389
  <button
@@ -391,27 +391,27 @@ let x = class extends y {
391
391
  class="baht-table-actions-btn baht-button baht-button--ghost baht-button--icon baht-button--sm"
392
392
  aria-label=${u("rowActions")}
393
393
  @click=${(r) => {
394
- r.stopPropagation(), this.emit("baht-row-actions", { row: a, index: i, id: this.idOf(a) });
394
+ r.stopPropagation(), this.emit("baht-row-actions", { row: s, index: i, id: this.idOf(s) });
395
395
  }}
396
- >${j("more")}</button>
396
+ >${T("more")}</button>
397
397
  </td>` : h}
398
398
  </tr>`;
399
399
  })}`;
400
400
  }
401
401
  renderHeaderCell(t) {
402
402
  var o;
403
- const e = this.labelFor(t), a = ((o = this.sort) == null ? void 0 : o.key) === t ? this.sort.direction : null, i = a === "asc" ? "ascending" : a === "desc" ? "descending" : h, s = `baht-table-cell${this.alignClass(t)}`;
403
+ const e = this.labelFor(t), s = ((o = this.sort) == null ? void 0 : o.key) === t ? this.sort.direction : null, i = s === "asc" ? "ascending" : s === "desc" ? "descending" : h, a = `baht-table-cell${this.alignClass(t)}`;
404
404
  if (!this.isSortable(t))
405
- return l`<th scope="col" data-col=${t} class=${s}>${e}</th>`;
406
- const r = a === "asc" ? "chevron-up" : a === "desc" ? "chevron-down" : "sort";
407
- return l`<th scope="col" data-col=${t} class=${s} aria-sort=${i}>
405
+ return l`<th scope="col" data-col=${t} class=${a}>${e}</th>`;
406
+ const r = s === "asc" ? "chevron-up" : s === "desc" ? "chevron-down" : "sort";
407
+ return l`<th scope="col" data-col=${t} class=${a} aria-sort=${i}>
408
408
  <button
409
409
  type="button"
410
- class="baht-table-sort${a ? " baht-table-sort--active" : ""}"
410
+ class="baht-table-sort${s ? " baht-table-sort--active" : ""}"
411
411
  aria-label=${u("sortBy", { label: e })}
412
412
  @click=${() => this.requestSort(t)}
413
413
  >
414
- <span>${e}</span>${j(r)}
414
+ <span>${e}</span>${T(r)}
415
415
  </button>
416
416
  </th>`;
417
417
  }
@@ -437,7 +437,7 @@ let x = class extends y {
437
437
  aria-haspopup="dialog"
438
438
  aria-expanded=${this.pickerOpen ? "true" : "false"}
439
439
  @click=${() => this.openPicker()}
440
- >${j("columns")}</button>`;
440
+ >${T("columns")}</button>`;
441
441
  }
442
442
  /**
443
443
  * One row of the Available tree. A reference column gets an expander that
@@ -445,16 +445,16 @@ let x = class extends y {
445
445
  * list works from the keyboard without the native multi-select.
446
446
  */
447
447
  renderAvailRow(t, e) {
448
- const a = this.specAt(t), i = (a == null ? void 0 : a.fields) !== void 0, s = this.expanded.includes(t), r = this.draftColumns.includes(t);
448
+ const s = this.specAt(t), i = (s == null ? void 0 : s.fields) !== void 0, a = this.expanded.includes(t), r = this.draftColumns.includes(t);
449
449
  return l`<li class="baht-table-picker-node" style="--baht-picker-depth:${e}">
450
450
  <div class="baht-table-picker-row">
451
451
  ${i ? l`<button
452
452
  type="button"
453
453
  class="baht-table-picker-expand"
454
- aria-label=${s ? `Collapse ${a == null ? void 0 : a.label}` : `Expand ${a == null ? void 0 : a.label}`}
455
- aria-expanded=${s ? "true" : "false"}
454
+ aria-label=${a ? `Collapse ${s == null ? void 0 : s.label}` : `Expand ${s == null ? void 0 : s.label}`}
455
+ aria-expanded=${a ? "true" : "false"}
456
456
  @click=${() => this.toggleExpanded(t)}
457
- >${j(s ? "chevron-down" : "chevron-right")}</button>` : l`<span class="baht-table-picker-expand baht-table-picker-expand--leaf"></span>`}
457
+ >${T(a ? "chevron-down" : "chevron-right")}</button>` : l`<span class="baht-table-picker-expand baht-table-picker-expand--leaf"></span>`}
458
458
  <button
459
459
  type="button"
460
460
  class="baht-table-picker-option"
@@ -462,15 +462,15 @@ let x = class extends y {
462
462
  ?disabled=${r}
463
463
  aria-pressed=${this.pickAvail.includes(t) ? "true" : "false"}
464
464
  @click=${() => this.toggleAvail(t)}
465
- >${e === 0 ? this.labelFor(t) : (a == null ? void 0 : a.label) ?? t}</button>
465
+ >${e === 0 ? this.labelFor(t) : (s == null ? void 0 : s.label) ?? t}</button>
466
466
  </div>
467
- ${i && s ? l`<ul class="baht-table-picker-tree">
467
+ ${i && a ? l`<ul class="baht-table-picker-tree">
468
468
  ${this.childrenOf(t).map((o) => this.renderAvailRow(o, e + 1))}
469
469
  </ul>` : h}
470
470
  </li>`;
471
471
  }
472
472
  renderColumnModal() {
473
- const t = this.allColumnKeys, e = this.allPaths().filter((i) => !this.draftColumns.includes(i)).length, a = (i) => (s) => i(x.selectedValues(s));
473
+ const t = this.allColumnKeys, e = this.allPaths().filter((i) => !this.draftColumns.includes(i)).length, s = (i) => (a) => i(x.selectedValues(a));
474
474
  return l`<div
475
475
  class="baht-table-picker-scrim"
476
476
  @click=${(i) => i.target === i.currentTarget && this.closePicker()}
@@ -495,7 +495,7 @@ let x = class extends y {
495
495
  </div>
496
496
  <div>
497
497
  <div class="baht-table-picker-collabel">Selected (${this.draftColumns.length})</div>
498
- <select multiple size="10" class="baht-table-picker-select" aria-label="Selected columns" @change=${a((i) => this.pickSel = i)}>
498
+ <select multiple size="10" class="baht-table-picker-select" aria-label="Selected columns" @change=${s((i) => this.pickSel = i)}>
499
499
  ${this.draftColumns.map(
500
500
  (i) => l`<option value=${i} ?selected=${this.pickSel.includes(i)}>${this.labelFor(i)}</option>`
501
501
  )}
@@ -654,10 +654,10 @@ O([
654
654
  x = O([
655
655
  f("baht-table")
656
656
  ], x);
657
- var Ls = Object.defineProperty, Ns = Object.getOwnPropertyDescriptor, ut = (t, e, a, i) => {
658
- for (var s = i > 1 ? void 0 : i ? Ns(e, a) : e, r = t.length - 1, o; r >= 0; r--)
659
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
660
- return i && s && Ls(e, a, s), s;
657
+ var Ns = Object.defineProperty, qs = Object.getOwnPropertyDescriptor, ut = (t, e, s, i) => {
658
+ for (var a = i > 1 ? void 0 : i ? qs(e, s) : e, r = t.length - 1, o; r >= 0; r--)
659
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
660
+ return i && a && Ns(e, s, a), a;
661
661
  };
662
662
  let ot = class extends y {
663
663
  constructor() {
@@ -681,8 +681,8 @@ let ot = class extends y {
681
681
  role="listitem"
682
682
  tabindex=${this.clickable ? "0" : h}
683
683
  @click=${() => this.emitItem(t, e)}
684
- @keydown=${(a) => {
685
- a.key !== "Enter" && a.key !== " " || (a.preventDefault(), this.emitItem(t, e));
684
+ @keydown=${(s) => {
685
+ s.key !== "Enter" && s.key !== " " || (s.preventDefault(), this.emitItem(t, e));
686
686
  }}
687
687
  >
688
688
  <div class="baht-list-main">
@@ -723,10 +723,10 @@ ut([
723
723
  ot = ut([
724
724
  f("baht-list")
725
725
  ], ot);
726
- var qs = Object.defineProperty, Rs = Object.getOwnPropertyDescriptor, Jt = (t, e, a, i) => {
727
- for (var s = i > 1 ? void 0 : i ? Rs(e, a) : e, r = t.length - 1, o; r >= 0; r--)
728
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
729
- return i && s && qs(e, a, s), s;
726
+ var Rs = Object.defineProperty, zs = Object.getOwnPropertyDescriptor, Wt = (t, e, s, i) => {
727
+ for (var a = i > 1 ? void 0 : i ? zs(e, s) : e, r = t.length - 1, o; r >= 0; r--)
728
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
729
+ return i && a && Rs(e, s, a), a;
730
730
  };
731
731
  let Ot = class extends y {
732
732
  constructor() {
@@ -767,25 +767,25 @@ let Ot = class extends y {
767
767
  </span>`;
768
768
  }
769
769
  };
770
- Jt([
770
+ Wt([
771
771
  n()
772
772
  ], Ot.prototype, "text", 2);
773
- Jt([
773
+ Wt([
774
774
  n()
775
775
  ], Ot.prototype, "position", 2);
776
- Jt([
777
- It(".baht-tooltip-anchor")
776
+ Wt([
777
+ Bt(".baht-tooltip-anchor")
778
778
  ], Ot.prototype, "anchorEl", 2);
779
- Jt([
779
+ Wt([
780
780
  v()
781
781
  ], Ot.prototype, "dismissed", 2);
782
- Ot = Jt([
782
+ Ot = Wt([
783
783
  f("baht-tooltip")
784
784
  ], Ot);
785
- var zs = Object.defineProperty, Vs = Object.getOwnPropertyDescriptor, jt = (t, e, a, i) => {
786
- for (var s = i > 1 ? void 0 : i ? Vs(e, a) : e, r = t.length - 1, o; r >= 0; r--)
787
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
788
- return i && s && zs(e, a, s), s;
785
+ var Vs = Object.defineProperty, Ks = Object.getOwnPropertyDescriptor, Tt = (t, e, s, i) => {
786
+ for (var a = i > 1 ? void 0 : i ? Ks(e, s) : e, r = t.length - 1, o; r >= 0; r--)
787
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
788
+ return i && a && Vs(e, s, a), a;
789
789
  };
790
790
  let mt = class extends y {
791
791
  constructor() {
@@ -798,12 +798,12 @@ let mt = class extends y {
798
798
  this.emit("baht-dismiss");
799
799
  const t = this.generation, e = () => {
800
800
  t === this.generation && (this.dismissed = !0);
801
- }, a = this.querySelector(".baht-alert");
802
- if (!a) {
801
+ }, s = this.querySelector(".baht-alert");
802
+ if (!s) {
803
803
  e();
804
804
  return;
805
805
  }
806
- a.classList.add("baht-alert--leaving"), Cs(a, e);
806
+ s.classList.add("baht-alert--leaving"), Ds(s, e);
807
807
  }
808
808
  render() {
809
809
  return this.dismissed ? h : l`<div class="baht-alert baht-alert--${this.tone}" role="alert">
@@ -815,28 +815,28 @@ let mt = class extends y {
815
815
  </div>`;
816
816
  }
817
817
  };
818
- jt([
818
+ Tt([
819
819
  n()
820
820
  ], mt.prototype, "tone", 2);
821
- jt([
821
+ Tt([
822
822
  n()
823
823
  ], mt.prototype, "heading", 2);
824
- jt([
824
+ Tt([
825
825
  n()
826
826
  ], mt.prototype, "message", 2);
827
- jt([
827
+ Tt([
828
828
  n({ type: Boolean })
829
829
  ], mt.prototype, "dismissible", 2);
830
- jt([
830
+ Tt([
831
831
  v()
832
832
  ], mt.prototype, "dismissed", 2);
833
- mt = jt([
833
+ mt = Tt([
834
834
  f("baht-alert")
835
835
  ], mt);
836
- var Ks = Object.defineProperty, Us = Object.getOwnPropertyDescriptor, Tt = (t, e, a, i) => {
837
- for (var s = i > 1 ? void 0 : i ? Us(e, a) : e, r = t.length - 1, o; r >= 0; r--)
838
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
839
- return i && s && Ks(e, a, s), s;
836
+ var Us = Object.defineProperty, Hs = Object.getOwnPropertyDescriptor, jt = (t, e, s, i) => {
837
+ for (var a = i > 1 ? void 0 : i ? Hs(e, s) : e, r = t.length - 1, o; r >= 0; r--)
838
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
839
+ return i && a && Us(e, s, a), a;
840
840
  };
841
841
  let vt = class extends y {
842
842
  constructor() {
@@ -852,13 +852,13 @@ let vt = class extends y {
852
852
  onKeydown(t, e) {
853
853
  var i;
854
854
  if (this.readonly) return;
855
- let a;
856
- if (t.key === "ArrowRight" || t.key === "ArrowUp") a = Math.min(e + 1, this.max);
857
- else if (t.key === "ArrowLeft" || t.key === "ArrowDown") a = Math.max(e - 1, 1);
858
- else if (t.key === "Home") a = 1;
859
- else if (t.key === "End") a = this.max;
855
+ let s;
856
+ if (t.key === "ArrowRight" || t.key === "ArrowUp") s = Math.min(e + 1, this.max);
857
+ else if (t.key === "ArrowLeft" || t.key === "ArrowDown") s = Math.max(e - 1, 1);
858
+ else if (t.key === "Home") s = 1;
859
+ else if (t.key === "End") s = this.max;
860
860
  else return;
861
- t.preventDefault(), this.emitValue(a), (i = this.querySelectorAll("button")[a - 1]) == null || i.focus();
861
+ t.preventDefault(), this.emitValue(s), (i = this.querySelectorAll("button")[s - 1]) == null || i.focus();
862
862
  }
863
863
  setHover(t) {
864
864
  this.readonly || (this.hover = t);
@@ -871,15 +871,15 @@ let vt = class extends y {
871
871
  aria-label=${this.label}
872
872
  @mouseleave=${() => this.setHover(0)}
873
873
  >
874
- ${Array.from({ length: this.max }, (e, a) => {
875
- const i = a + 1, s = this.value || 1;
874
+ ${Array.from({ length: this.max }, (e, s) => {
875
+ const i = s + 1, a = this.value || 1;
876
876
  return l`<button
877
877
  type="button"
878
878
  class=${i <= t ? "baht-rating--on" : ""}
879
879
  role="radio"
880
880
  aria-checked=${i === this.value}
881
881
  aria-label="${i} of ${this.max}"
882
- tabindex=${i === s ? "0" : "-1"}
882
+ tabindex=${i === a ? "0" : "-1"}
883
883
  ?disabled=${this.readonly}
884
884
  @mouseenter=${() => this.setHover(i)}
885
885
  @click=${() => this.pick(i)}
@@ -889,28 +889,28 @@ let vt = class extends y {
889
889
  </div>`;
890
890
  }
891
891
  };
892
- Tt([
892
+ jt([
893
893
  n({ type: Number })
894
894
  ], vt.prototype, "value", 2);
895
- Tt([
895
+ jt([
896
896
  n({ type: Number })
897
897
  ], vt.prototype, "max", 2);
898
- Tt([
898
+ jt([
899
899
  n({ type: Boolean })
900
900
  ], vt.prototype, "readonly", 2);
901
- Tt([
901
+ jt([
902
902
  n()
903
903
  ], vt.prototype, "label", 2);
904
- Tt([
904
+ jt([
905
905
  v()
906
906
  ], vt.prototype, "hover", 2);
907
- vt = Tt([
907
+ vt = jt([
908
908
  f("baht-rating")
909
909
  ], vt);
910
- var Hs = Object.defineProperty, Gs = Object.getOwnPropertyDescriptor, bt = (t, e, a, i) => {
911
- for (var s = i > 1 ? void 0 : i ? Gs(e, a) : e, r = t.length - 1, o; r >= 0; r--)
912
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
913
- return i && s && Hs(e, a, s), s;
910
+ var Gs = Object.defineProperty, Ws = Object.getOwnPropertyDescriptor, bt = (t, e, s, i) => {
911
+ for (var a = i > 1 ? void 0 : i ? Ws(e, s) : e, r = t.length - 1, o; r >= 0; r--)
912
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
913
+ return i && a && Gs(e, s, a), a;
914
914
  };
915
915
  let lt = class extends y {
916
916
  constructor() {
@@ -967,10 +967,10 @@ bt([
967
967
  lt = bt([
968
968
  f("baht-range")
969
969
  ], lt);
970
- var Ws = Object.defineProperty, Js = Object.getOwnPropertyDescriptor, At = (t, e, a, i) => {
971
- for (var s = i > 1 ? void 0 : i ? Js(e, a) : e, r = t.length - 1, o; r >= 0; r--)
972
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
973
- return i && s && Ws(e, a, s), s;
970
+ var Js = Object.defineProperty, Xs = Object.getOwnPropertyDescriptor, At = (t, e, s, i) => {
971
+ for (var a = i > 1 ? void 0 : i ? Xs(e, s) : e, r = t.length - 1, o; r >= 0; r--)
972
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
973
+ return i && a && Js(e, s, a), a;
974
974
  };
975
975
  let $t = class extends y {
976
976
  constructor() {
@@ -985,46 +985,46 @@ let $t = class extends y {
985
985
  willUpdate(t) {
986
986
  super.willUpdate(t);
987
987
  const e = t.has("value") && this.value !== this._lastValue;
988
- !this.hasUpdated || e ? (this._chars = Array.from({ length: this.length }, (a, i) => this.value[i] ?? ""), this._lastValue = this.value, this._wasFull = this._chars.length > 0 && this._chars.every((a) => a !== "")) : this._chars.length !== this.length && (this._chars = Array.from({ length: this.length }, (a, i) => this._chars[i] ?? ""));
988
+ !this.hasUpdated || e ? (this._chars = Array.from({ length: this.length }, (s, i) => this.value[i] ?? ""), this._lastValue = this.value, this._wasFull = this._chars.length > 0 && this._chars.every((s) => s !== "")) : this._chars.length !== this.length && (this._chars = Array.from({ length: this.length }, (s, i) => this._chars[i] ?? ""));
989
989
  }
990
990
  /** Writes `text` into `_chars` starting at `start`. Returns the index just
991
991
  * past the last box written (may equal `this.length`). */
992
992
  fill(t, e) {
993
- let a = t;
993
+ let s = t;
994
994
  for (const i of e) {
995
- if (a >= this.length) break;
996
- this._chars[a] = i, a += 1;
995
+ if (s >= this.length) break;
996
+ this._chars[s] = i, s += 1;
997
997
  }
998
- return a;
998
+ return s;
999
999
  }
1000
1000
  commit() {
1001
1001
  const t = this._chars.join("").slice(0, this.length);
1002
1002
  this.value = t, this._lastValue = t, this.requestUpdate(), this.emit("baht-change", { value: this.value });
1003
- const e = this._chars.length > 0 && this._chars.every((a) => a !== "");
1003
+ const e = this._chars.length > 0 && this._chars.every((s) => s !== "");
1004
1004
  e && !this._wasFull && this.emit("baht-otp-complete", { value: this.value }), this._wasFull = e;
1005
1005
  }
1006
1006
  onInput(t, e) {
1007
1007
  var r, o;
1008
- const a = e.target, i = this.clean(a.value);
1008
+ const s = e.target, i = this.clean(s.value);
1009
1009
  if (i.length > 1) {
1010
1010
  const c = this.fill(t, i);
1011
- a.value = this._chars[t] ?? "", this.commit(), (r = this.inputs()[Math.min(c, this.length - 1)]) == null || r.focus();
1011
+ s.value = this._chars[t] ?? "", this.commit(), (r = this.inputs()[Math.min(c, this.length - 1)]) == null || r.focus();
1012
1012
  return;
1013
1013
  }
1014
- const s = i.slice(-1);
1015
- a.value = s, this._chars[t] = s, this.commit(), s && t < this.length - 1 && ((o = this.inputs()[t + 1]) == null || o.focus());
1014
+ const a = i.slice(-1);
1015
+ s.value = a, this._chars[t] = a, this.commit(), a && t < this.length - 1 && ((o = this.inputs()[t + 1]) == null || o.focus());
1016
1016
  }
1017
1017
  onKeydown(t, e) {
1018
- var a;
1019
- e.key === "Backspace" && !this._chars[t] && t > 0 && (this._chars[t - 1] = "", this.commit(), (a = this.inputs()[t - 1]) == null || a.focus(), e.preventDefault());
1018
+ var s;
1019
+ e.key === "Backspace" && !this._chars[t] && t > 0 && (this._chars[t - 1] = "", this.commit(), (s = this.inputs()[t - 1]) == null || s.focus(), e.preventDefault());
1020
1020
  }
1021
1021
  onPaste(t) {
1022
- var i, s;
1022
+ var i, a;
1023
1023
  t.preventDefault();
1024
1024
  const e = this.clean(((i = t.clipboardData) == null ? void 0 : i.getData("text")) ?? "").slice(0, this.length);
1025
1025
  if (!e) return;
1026
- const a = this.fill(0, e);
1027
- this.commit(), (s = this.inputs()[Math.min(a, this.length - 1)]) == null || s.focus();
1026
+ const s = this.fill(0, e);
1027
+ this.commit(), (a = this.inputs()[Math.min(s, this.length - 1)]) == null || a.focus();
1028
1028
  }
1029
1029
  render() {
1030
1030
  return l`<div class="baht-otp" role="group" aria-label=${this.label} @paste=${(t) => this.onPaste(t)}>
@@ -1037,8 +1037,8 @@ let $t = class extends y {
1037
1037
  aria-label=${u("otpCharacter", { i: e + 1, n: this.length })}
1038
1038
  .value=${t}
1039
1039
  ?disabled=${this.disabled}
1040
- @input=${(a) => this.onInput(e, a)}
1041
- @keydown=${(a) => this.onKeydown(e, a)}
1040
+ @input=${(s) => this.onInput(e, s)}
1041
+ @keydown=${(s) => this.onKeydown(e, s)}
1042
1042
  />`
1043
1043
  )}
1044
1044
  </div>`;
@@ -1062,10 +1062,10 @@ At([
1062
1062
  $t = At([
1063
1063
  f("baht-otp")
1064
1064
  ], $t);
1065
- var Xs = Object.defineProperty, Ys = Object.getOwnPropertyDescriptor, Et = (t, e, a, i) => {
1066
- for (var s = i > 1 ? void 0 : i ? Ys(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1067
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1068
- return i && s && Xs(e, a, s), s;
1065
+ var Ys = Object.defineProperty, Zs = Object.getOwnPropertyDescriptor, Et = (t, e, s, i) => {
1066
+ for (var a = i > 1 ? void 0 : i ? Zs(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1067
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1068
+ return i && a && Ys(e, s, a), a;
1069
1069
  };
1070
1070
  let yt = class extends y {
1071
1071
  constructor() {
@@ -1073,8 +1073,8 @@ let yt = class extends y {
1073
1073
  }
1074
1074
  toggle(t) {
1075
1075
  const e = this.selected.includes(t);
1076
- let a;
1077
- this.multiple ? (a = e ? this.selected.filter((s) => s !== t) : [...this.selected, t], a = this.options.map((s) => s.key).filter((s) => a.includes(s))) : a = e ? [] : [t], this.emit("baht-change", { selected: a });
1076
+ let s;
1077
+ this.multiple ? (s = e ? this.selected.filter((a) => a !== t) : [...this.selected, t], s = this.options.map((a) => a.key).filter((a) => s.includes(a))) : s = e ? [] : [t], this.emit("baht-change", { selected: s });
1078
1078
  }
1079
1079
  render() {
1080
1080
  return l`<div class="baht-filter" role="group" aria-label=${this.label}>
@@ -1107,12 +1107,12 @@ Et([
1107
1107
  yt = Et([
1108
1108
  f("baht-filter")
1109
1109
  ], yt);
1110
- var Zs = Object.defineProperty, Qs = Object.getOwnPropertyDescriptor, ue = (t, e, a, i) => {
1111
- for (var s = i > 1 ? void 0 : i ? Qs(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1112
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1113
- return i && s && Zs(e, a, s), s;
1110
+ var Qs = Object.defineProperty, ta = Object.getOwnPropertyDescriptor, ue = (t, e, s, i) => {
1111
+ for (var a = i > 1 ? void 0 : i ? ta(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1112
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1113
+ return i && a && Qs(e, s, a), a;
1114
1114
  };
1115
- let Ut = class extends y {
1115
+ let Kt = class extends y {
1116
1116
  constructor() {
1117
1117
  super(...arguments), this.variant = "rect", this.width = "100%", this.height = "";
1118
1118
  }
@@ -1127,30 +1127,30 @@ let Ut = class extends y {
1127
1127
  };
1128
1128
  ue([
1129
1129
  n()
1130
- ], Ut.prototype, "variant", 2);
1130
+ ], Kt.prototype, "variant", 2);
1131
1131
  ue([
1132
1132
  n()
1133
- ], Ut.prototype, "width", 2);
1133
+ ], Kt.prototype, "width", 2);
1134
1134
  ue([
1135
1135
  n()
1136
- ], Ut.prototype, "height", 2);
1137
- Ut = ue([
1136
+ ], Kt.prototype, "height", 2);
1137
+ Kt = ue([
1138
1138
  f("baht-skeleton")
1139
- ], Ut);
1140
- var ta = Object.defineProperty, ea = Object.getOwnPropertyDescriptor, Xt = (t, e, a, i) => {
1141
- for (var s = i > 1 ? void 0 : i ? ea(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1142
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1143
- return i && s && ta(e, a, s), s;
1139
+ ], Kt);
1140
+ var ea = Object.defineProperty, sa = Object.getOwnPropertyDescriptor, Jt = (t, e, s, i) => {
1141
+ for (var a = i > 1 ? void 0 : i ? sa(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1142
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1143
+ return i && a && ea(e, s, a), a;
1144
1144
  };
1145
1145
  let Pt = class extends y {
1146
1146
  constructor() {
1147
1147
  super(...arguments), this.value = null, this.tone = "primary", this.showLabel = !1, this.label = "Progress";
1148
1148
  }
1149
1149
  render() {
1150
- const t = this.value == null || Number.isNaN(this.value), e = t ? 0 : Math.min(100, Math.max(0, this.value)), a = this.tone === "primary" ? "" : ` baht-progress--${this.tone}`;
1150
+ const t = this.value == null || Number.isNaN(this.value), e = t ? 0 : Math.min(100, Math.max(0, this.value)), s = this.tone === "primary" ? "" : ` baht-progress--${this.tone}`;
1151
1151
  return l`<div>
1152
1152
  <div
1153
- class="baht-progress${a}${t ? " baht-progress--indeterminate" : ""}"
1153
+ class="baht-progress${s}${t ? " baht-progress--indeterminate" : ""}"
1154
1154
  role="progressbar"
1155
1155
  aria-label=${this.label}
1156
1156
  aria-valuemin="0"
@@ -1163,25 +1163,25 @@ let Pt = class extends y {
1163
1163
  </div>`;
1164
1164
  }
1165
1165
  };
1166
- Xt([
1166
+ Jt([
1167
1167
  n({ type: Number })
1168
1168
  ], Pt.prototype, "value", 2);
1169
- Xt([
1169
+ Jt([
1170
1170
  n()
1171
1171
  ], Pt.prototype, "tone", 2);
1172
- Xt([
1172
+ Jt([
1173
1173
  n({ type: Boolean, attribute: "show-label" })
1174
1174
  ], Pt.prototype, "showLabel", 2);
1175
- Xt([
1175
+ Jt([
1176
1176
  n()
1177
1177
  ], Pt.prototype, "label", 2);
1178
- Pt = Xt([
1178
+ Pt = Jt([
1179
1179
  f("baht-progress")
1180
1180
  ], Pt);
1181
- var sa = Object.defineProperty, aa = Object.getOwnPropertyDescriptor, Le = (t, e, a, i) => {
1182
- for (var s = i > 1 ? void 0 : i ? aa(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1183
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1184
- return i && s && sa(e, a, s), s;
1181
+ var aa = Object.defineProperty, ia = Object.getOwnPropertyDescriptor, Le = (t, e, s, i) => {
1182
+ for (var a = i > 1 ? void 0 : i ? ia(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1183
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1184
+ return i && a && aa(e, s, a), a;
1185
1185
  };
1186
1186
  let oe = class extends y {
1187
1187
  constructor() {
@@ -1201,10 +1201,10 @@ Le([
1201
1201
  oe = Le([
1202
1202
  f("baht-spinner")
1203
1203
  ], oe);
1204
- var ia = Object.defineProperty, ra = Object.getOwnPropertyDescriptor, Yt = (t, e, a, i) => {
1205
- for (var s = i > 1 ? void 0 : i ? ra(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1206
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1207
- return i && s && ia(e, a, s), s;
1204
+ var ra = Object.defineProperty, oa = Object.getOwnPropertyDescriptor, Xt = (t, e, s, i) => {
1205
+ for (var a = i > 1 ? void 0 : i ? oa(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1206
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1207
+ return i && a && ra(e, s, a), a;
1208
1208
  };
1209
1209
  let Ct = class extends y {
1210
1210
  constructor() {
@@ -1221,25 +1221,25 @@ let Ct = class extends y {
1221
1221
  </div>`;
1222
1222
  }
1223
1223
  };
1224
- Yt([
1224
+ Xt([
1225
1225
  n()
1226
1226
  ], Ct.prototype, "heading", 2);
1227
- Yt([
1227
+ Xt([
1228
1228
  n()
1229
1229
  ], Ct.prototype, "subtitle", 2);
1230
- Yt([
1230
+ Xt([
1231
1231
  n({ type: Boolean })
1232
1232
  ], Ct.prototype, "hero", 2);
1233
- Yt([
1234
- It(".baht-card-body")
1233
+ Xt([
1234
+ Bt(".baht-card-body")
1235
1235
  ], Ct.prototype, "bodyEl", 2);
1236
- Ct = Yt([
1236
+ Ct = Xt([
1237
1237
  f("baht-card")
1238
1238
  ], Ct);
1239
- var oa = Object.defineProperty, la = Object.getOwnPropertyDescriptor, Zt = (t, e, a, i) => {
1240
- for (var s = i > 1 ? void 0 : i ? la(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1241
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1242
- return i && s && oa(e, a, s), s;
1239
+ var la = Object.defineProperty, na = Object.getOwnPropertyDescriptor, Yt = (t, e, s, i) => {
1240
+ for (var a = i > 1 ? void 0 : i ? na(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1241
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1242
+ return i && a && la(e, s, a), a;
1243
1243
  };
1244
1244
  let Dt = class extends y {
1245
1245
  constructor() {
@@ -1256,25 +1256,25 @@ let Dt = class extends y {
1256
1256
  </fieldset>`;
1257
1257
  }
1258
1258
  };
1259
- Zt([
1259
+ Yt([
1260
1260
  n()
1261
1261
  ], Dt.prototype, "legend", 2);
1262
- Zt([
1262
+ Yt([
1263
1263
  n()
1264
1264
  ], Dt.prototype, "help", 2);
1265
- Zt([
1265
+ Yt([
1266
1266
  n({ type: Boolean })
1267
1267
  ], Dt.prototype, "disabled", 2);
1268
- Zt([
1269
- It(".baht-fieldset-body")
1268
+ Yt([
1269
+ Bt(".baht-fieldset-body")
1270
1270
  ], Dt.prototype, "bodyEl", 2);
1271
- Dt = Zt([
1271
+ Dt = Yt([
1272
1272
  f("baht-fieldset")
1273
1273
  ], Dt);
1274
- var na = Object.defineProperty, ha = Object.getOwnPropertyDescriptor, fs = (t, e, a, i) => {
1275
- for (var s = i > 1 ? void 0 : i ? ha(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1276
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1277
- return i && s && na(e, a, s), s;
1274
+ var ha = Object.defineProperty, ca = Object.getOwnPropertyDescriptor, fs = (t, e, s, i) => {
1275
+ for (var a = i > 1 ? void 0 : i ? ca(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1276
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1277
+ return i && a && ha(e, s, a), a;
1278
1278
  };
1279
1279
  let Me = class extends y {
1280
1280
  constructor() {
@@ -1306,10 +1306,10 @@ fs([
1306
1306
  Me = fs([
1307
1307
  f("baht-timeline")
1308
1308
  ], Me);
1309
- var ca = Object.defineProperty, pa = Object.getOwnPropertyDescriptor, be = (t, e, a, i) => {
1310
- for (var s = i > 1 ? void 0 : i ? pa(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1311
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1312
- return i && s && ca(e, a, s), s;
1309
+ var pa = Object.defineProperty, da = Object.getOwnPropertyDescriptor, be = (t, e, s, i) => {
1310
+ for (var a = i > 1 ? void 0 : i ? da(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1311
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1312
+ return i && a && pa(e, s, a), a;
1313
1313
  };
1314
1314
  let St = class extends y {
1315
1315
  constructor() {
@@ -1321,30 +1321,30 @@ let St = class extends y {
1321
1321
  willUpdate(t) {
1322
1322
  if (t.has("items")) {
1323
1323
  const e = St.fingerprint(this.items);
1324
- e !== this.itemsFingerprint && (this.itemsFingerprint = e, this.openSet = new Set(this.items.flatMap((a, i) => a.open ? [i] : [])));
1324
+ e !== this.itemsFingerprint && (this.itemsFingerprint = e, this.openSet = new Set(this.items.flatMap((s, i) => s.open ? [i] : [])));
1325
1325
  }
1326
1326
  }
1327
1327
  toggle(t) {
1328
- const e = !this.openSet.has(t), a = this.multiple ? new Set(this.openSet) : /* @__PURE__ */ new Set();
1329
- e ? a.add(t) : a.delete(t), this.openSet = a, this.emit("baht-toggle", { index: t, open: e });
1328
+ const e = !this.openSet.has(t), s = this.multiple ? new Set(this.openSet) : /* @__PURE__ */ new Set();
1329
+ e ? s.add(t) : s.delete(t), this.openSet = s, this.emit("baht-toggle", { index: t, open: e });
1330
1330
  }
1331
1331
  render() {
1332
1332
  return l`<div class="baht-accordion">
1333
1333
  ${this.items.map((t, e) => {
1334
- const a = this.openSet.has(e), i = `baht-acc-${this.uid}-t-${e}`, s = `baht-acc-${this.uid}-p-${e}`;
1335
- return l`<div class="baht-accordion-item${a ? " baht-accordion-item--open" : ""}">
1334
+ const s = this.openSet.has(e), i = `baht-acc-${this.uid}-t-${e}`, a = `baht-acc-${this.uid}-p-${e}`;
1335
+ return l`<div class="baht-accordion-item${s ? " baht-accordion-item--open" : ""}">
1336
1336
  <button
1337
1337
  type="button"
1338
1338
  class="baht-accordion-trigger"
1339
1339
  id=${i}
1340
- aria-expanded=${a}
1341
- aria-controls=${a ? s : h}
1340
+ aria-expanded=${s}
1341
+ aria-controls=${s ? a : h}
1342
1342
  @click=${() => this.toggle(e)}
1343
1343
  >
1344
1344
  <span>${t.title}</span>
1345
- <span class="baht-accordion-chevron" aria-hidden="true">${j("chevron-down")}</span>
1345
+ <span class="baht-accordion-chevron" aria-hidden="true">${T("chevron-down")}</span>
1346
1346
  </button>
1347
- ${a ? l`<div class="baht-accordion-content" id=${s} role="region" aria-labelledby=${i}>${t.content}</div>` : h}
1347
+ ${s ? l`<div class="baht-accordion-content" id=${a} role="region" aria-labelledby=${i}>${t.content}</div>` : h}
1348
1348
  </div>`;
1349
1349
  })}
1350
1350
  </div>`;
@@ -1362,10 +1362,10 @@ be([
1362
1362
  St = be([
1363
1363
  f("baht-accordion")
1364
1364
  ], St);
1365
- var da = Object.defineProperty, ua = Object.getOwnPropertyDescriptor, Qt = (t, e, a, i) => {
1366
- for (var s = i > 1 ? void 0 : i ? ua(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1367
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1368
- return i && s && da(e, a, s), s;
1365
+ var ua = Object.defineProperty, ba = Object.getOwnPropertyDescriptor, Zt = (t, e, s, i) => {
1366
+ for (var a = i > 1 ? void 0 : i ? ba(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1367
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1368
+ return i && a && ua(e, s, a), a;
1369
1369
  };
1370
1370
  let Ft = class extends y {
1371
1371
  constructor() {
@@ -1380,25 +1380,25 @@ let Ft = class extends y {
1380
1380
  >${this.label}${this.external ? l` <span class="baht-link-external" aria-hidden="true">↗</span><span class="baht-visually-hidden"> (${this.externalHint})</span>` : h}</a>`;
1381
1381
  }
1382
1382
  };
1383
- Qt([
1383
+ Zt([
1384
1384
  n()
1385
1385
  ], Ft.prototype, "href", 2);
1386
- Qt([
1386
+ Zt([
1387
1387
  n()
1388
1388
  ], Ft.prototype, "label", 2);
1389
- Qt([
1389
+ Zt([
1390
1390
  n({ type: Boolean })
1391
1391
  ], Ft.prototype, "external", 2);
1392
- Qt([
1392
+ Zt([
1393
1393
  n({ attribute: "external-hint" })
1394
1394
  ], Ft.prototype, "externalHint", 2);
1395
- Ft = Qt([
1395
+ Ft = Zt([
1396
1396
  f("baht-link")
1397
1397
  ], Ft);
1398
- var ba = Object.defineProperty, fa = Object.getOwnPropertyDescriptor, Ne = (t, e, a, i) => {
1399
- for (var s = i > 1 ? void 0 : i ? fa(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1400
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1401
- return i && s && ba(e, a, s), s;
1398
+ var fa = Object.defineProperty, ma = Object.getOwnPropertyDescriptor, Ne = (t, e, s, i) => {
1399
+ for (var a = i > 1 ? void 0 : i ? ma(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1400
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1401
+ return i && a && fa(e, s, a), a;
1402
1402
  };
1403
1403
  let le = class extends y {
1404
1404
  constructor() {
@@ -1410,13 +1410,13 @@ let le = class extends y {
1410
1410
  render() {
1411
1411
  const t = this.items.length - 1;
1412
1412
  return l`<nav class="baht-breadcrumbs" aria-label="Breadcrumb">
1413
- ${this.items.map((e, a) => {
1414
- const i = a < t ? l`<span class="baht-breadcrumbs-sep" aria-hidden="true">${this.separator}</span>` : h;
1415
- return a === t ? l`<span class="baht-breadcrumbs-current" aria-current="page">${e.label}</span>${i}` : e.href ? l`<a class="baht-link" href=${e.href}>${e.label}</a>${i}` : l`<a
1413
+ ${this.items.map((e, s) => {
1414
+ const i = s < t ? l`<span class="baht-breadcrumbs-sep" aria-hidden="true">${this.separator}</span>` : h;
1415
+ return s === t ? l`<span class="baht-breadcrumbs-current" aria-current="page">${e.label}</span>${i}` : e.href ? l`<a class="baht-link" href=${e.href}>${e.label}</a>${i}` : l`<a
1416
1416
  class="baht-link"
1417
1417
  href="#"
1418
- @click=${(s) => {
1419
- s.preventDefault(), this.navigate(e, a);
1418
+ @click=${(a) => {
1419
+ a.preventDefault(), this.navigate(e, s);
1420
1420
  }}
1421
1421
  >${e.label}</a>${i}`;
1422
1422
  })}
@@ -1432,12 +1432,12 @@ Ne([
1432
1432
  le = Ne([
1433
1433
  f("baht-breadcrumbs")
1434
1434
  ], le);
1435
- var ma = Object.getOwnPropertyDescriptor, va = (t, e, a, i) => {
1436
- for (var s = i > 1 ? void 0 : i ? ma(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1437
- (o = t[r]) && (s = o(s) || s);
1438
- return s;
1435
+ var va = Object.getOwnPropertyDescriptor, $a = (t, e, s, i) => {
1436
+ for (var a = i > 1 ? void 0 : i ? va(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1437
+ (o = t[r]) && (a = o(a) || a);
1438
+ return a;
1439
1439
  };
1440
- let Ke = class extends X {
1440
+ let Ue = class extends X {
1441
1441
  renderControl() {
1442
1442
  return l`<input
1443
1443
  class="baht-control baht-control--text"
@@ -1456,15 +1456,15 @@ let Ke = class extends X {
1456
1456
  />`;
1457
1457
  }
1458
1458
  };
1459
- Ke = va([
1459
+ Ue = $a([
1460
1460
  f("baht-input")
1461
- ], Ke);
1462
- var $a = Object.getOwnPropertyDescriptor, ya = (t, e, a, i) => {
1463
- for (var s = i > 1 ? void 0 : i ? $a(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1464
- (o = t[r]) && (s = o(s) || s);
1465
- return s;
1461
+ ], Ue);
1462
+ var ya = Object.getOwnPropertyDescriptor, ga = (t, e, s, i) => {
1463
+ for (var a = i > 1 ? void 0 : i ? ya(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1464
+ (o = t[r]) && (a = o(a) || a);
1465
+ return a;
1466
1466
  };
1467
- let Ue = class extends X {
1467
+ let He = class extends X {
1468
1468
  renderControl() {
1469
1469
  return l`<textarea
1470
1470
  class="baht-control baht-control--textarea"
@@ -1483,15 +1483,15 @@ let Ue = class extends X {
1483
1483
  ></textarea>`;
1484
1484
  }
1485
1485
  };
1486
- Ue = ya([
1486
+ He = ga([
1487
1487
  f("baht-textarea")
1488
- ], Ue);
1489
- var ga = Object.getOwnPropertyDescriptor, wa = (t, e, a, i) => {
1490
- for (var s = i > 1 ? void 0 : i ? ga(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1491
- (o = t[r]) && (s = o(s) || s);
1492
- return s;
1488
+ ], He);
1489
+ var wa = Object.getOwnPropertyDescriptor, xa = (t, e, s, i) => {
1490
+ for (var a = i > 1 ? void 0 : i ? wa(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1491
+ (o = t[r]) && (a = o(a) || a);
1492
+ return a;
1493
1493
  };
1494
- let He = class extends X {
1494
+ let Ge = class extends X {
1495
1495
  renderControl() {
1496
1496
  return l`<input
1497
1497
  class="baht-control baht-control--number"
@@ -1514,31 +1514,31 @@ let He = class extends X {
1514
1514
  />`;
1515
1515
  }
1516
1516
  };
1517
- He = wa([
1517
+ Ge = xa([
1518
1518
  f("baht-number")
1519
- ], He);
1520
- var xa = Object.defineProperty, _a = Object.getOwnPropertyDescriptor, ms = (t, e, a, i) => {
1521
- for (var s = i > 1 ? void 0 : i ? _a(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1522
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1523
- return i && s && xa(e, a, s), s;
1519
+ ], Ge);
1520
+ var _a = Object.defineProperty, ka = Object.getOwnPropertyDescriptor, ms = (t, e, s, i) => {
1521
+ for (var a = i > 1 ? void 0 : i ? ka(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1522
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1523
+ return i && a && _a(e, s, a), a;
1524
1524
  };
1525
- function Ge(t) {
1525
+ function We(t) {
1526
1526
  const e = t.replace(/,/g, "").trim();
1527
1527
  if (e === "" || e === "-") return null;
1528
- const a = Number(e);
1529
- return Number.isNaN(a) ? null : a;
1528
+ const s = Number(e);
1529
+ return Number.isNaN(s) ? null : s;
1530
1530
  }
1531
- function ka(t) {
1531
+ function Oa(t) {
1532
1532
  return t.toLocaleString("en-US", { maximumFractionDigits: 2 });
1533
1533
  }
1534
- let Be = class extends X {
1534
+ let Ie = class extends X {
1535
1535
  constructor() {
1536
1536
  super(...arguments), this.focused = !1;
1537
1537
  }
1538
1538
  displayFor(t) {
1539
1539
  if (t == null || t === "") return "";
1540
- const e = typeof t == "number" ? t : Ge(String(t));
1541
- return e == null ? String(t) : this.focused ? String(e) : ka(e);
1540
+ const e = typeof t == "number" ? t : We(String(t));
1541
+ return e == null ? String(t) : this.focused ? String(e) : Oa(e);
1542
1542
  }
1543
1543
  renderControl() {
1544
1544
  return l`<input
@@ -1562,23 +1562,23 @@ let Be = class extends X {
1562
1562
  }}
1563
1563
  @input=${(t) => {
1564
1564
  const e = t.target.value;
1565
- this.emitTyped(e === "" ? null : Ge(e));
1565
+ this.emitTyped(e === "" ? null : We(e));
1566
1566
  }}
1567
1567
  />`;
1568
1568
  }
1569
1569
  };
1570
1570
  ms([
1571
1571
  v()
1572
- ], Be.prototype, "focused", 2);
1573
- Be = ms([
1572
+ ], Ie.prototype, "focused", 2);
1573
+ Ie = ms([
1574
1574
  f("baht-currency")
1575
- ], Be);
1576
- var Oa = Object.defineProperty, Pa = Object.getOwnPropertyDescriptor, qe = (t, e, a, i) => {
1577
- for (var s = i > 1 ? void 0 : i ? Pa(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1578
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
1579
- return i && s && Oa(e, a, s), s;
1575
+ ], Ie);
1576
+ var Pa = Object.defineProperty, Ca = Object.getOwnPropertyDescriptor, qe = (t, e, s, i) => {
1577
+ for (var a = i > 1 ? void 0 : i ? Ca(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1578
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
1579
+ return i && a && Pa(e, s, a), a;
1580
1580
  };
1581
- const Ca = 500;
1581
+ const Da = 500;
1582
1582
  let ne = class extends X {
1583
1583
  constructor() {
1584
1584
  super(...arguments), this.open = !1, this.active = 0, this.typeBuffer = "", this.onDocMousedown = (t) => {
@@ -1586,7 +1586,7 @@ let ne = class extends X {
1586
1586
  };
1587
1587
  }
1588
1588
  disconnectedCallback() {
1589
- super.disconnectedCallback(), clearTimeout(this.typeTimer), T() && document.removeEventListener("mousedown", this.onDocMousedown);
1589
+ super.disconnectedCallback(), clearTimeout(this.typeTimer), j() && document.removeEventListener("mousedown", this.onDocMousedown);
1590
1590
  }
1591
1591
  get listId() {
1592
1592
  return `${this.controlId}-list`;
@@ -1621,10 +1621,10 @@ let ne = class extends X {
1621
1621
  (e = t == null ? void 0 : t.scrollIntoView) == null || e.call(t, { block: "nearest" });
1622
1622
  }
1623
1623
  openList() {
1624
- !this.interactive || this.open || (this.active = this.selectedIndex, this.open = !0, T() && document.addEventListener("mousedown", this.onDocMousedown));
1624
+ !this.interactive || this.open || (this.active = this.selectedIndex, this.open = !0, j() && document.addEventListener("mousedown", this.onDocMousedown));
1625
1625
  }
1626
1626
  close() {
1627
- this.open && (this.open = !1, T() && document.removeEventListener("mousedown", this.onDocMousedown));
1627
+ this.open && (this.open = !1, j() && document.removeEventListener("mousedown", this.onDocMousedown));
1628
1628
  }
1629
1629
  toggle() {
1630
1630
  this.open ? this.close() : this.openList();
@@ -1642,12 +1642,12 @@ let ne = class extends X {
1642
1642
  }
1643
1643
  /** Type-to-select: first option (after the highlighted one) starting with the buffer. */
1644
1644
  typeahead(t) {
1645
- clearTimeout(this.typeTimer), this.typeBuffer += t.toLowerCase(), this.typeTimer = setTimeout(() => this.typeBuffer = "", Ca);
1646
- const e = this.rows, a = this.typeBuffer.length === 1 ? this.active + 1 : this.active;
1645
+ clearTimeout(this.typeTimer), this.typeBuffer += t.toLowerCase(), this.typeTimer = setTimeout(() => this.typeBuffer = "", Da);
1646
+ const e = this.rows, s = this.typeBuffer.length === 1 ? this.active + 1 : this.active;
1647
1647
  for (let i = 0; i < e.length; i++) {
1648
- const s = (a + i) % e.length;
1649
- if (s !== 0 && e[s].label.toLowerCase().startsWith(this.typeBuffer)) {
1650
- this.open ? this.active = s : this.commit(s);
1648
+ const a = (s + i) % e.length;
1649
+ if (a !== 0 && e[a].label.toLowerCase().startsWith(this.typeBuffer)) {
1650
+ this.open ? this.active = a : this.commit(a);
1651
1651
  return;
1652
1652
  }
1653
1653
  }
@@ -1687,11 +1687,11 @@ let ne = class extends X {
1687
1687
  }
1688
1688
  }
1689
1689
  renderControl() {
1690
- const t = this.rows, e = this.selectedIndex, a = e === 0;
1690
+ const t = this.rows, e = this.selectedIndex, s = e === 0;
1691
1691
  return l`<div class="baht-select${this.open ? " baht-select--open" : ""}">
1692
1692
  <button
1693
1693
  type="button"
1694
- class="baht-control baht-control--select baht-select-trigger${a ? " baht-select-trigger--placeholder" : ""}"
1694
+ class="baht-control baht-control--select baht-select-trigger${s ? " baht-select-trigger--placeholder" : ""}"
1695
1695
  id=${this.controlId}
1696
1696
  role="combobox"
1697
1697
  aria-haspopup="listbox"
@@ -1708,7 +1708,7 @@ let ne = class extends X {
1708
1708
  @keydown=${(i) => this.onKeydown(i)}
1709
1709
  >
1710
1710
  <span class="baht-select-value">${t[e].label}</span>
1711
- <span class="baht-select-chevron" aria-hidden="true">${j("chevron-down")}</span>
1711
+ <span class="baht-select-chevron" aria-hidden="true">${T("chevron-down")}</span>
1712
1712
  </button>
1713
1713
  <div
1714
1714
  class="baht-listbox baht-select-list"
@@ -1719,15 +1719,15 @@ let ne = class extends X {
1719
1719
  >
1720
1720
  ${t.map(
1721
1721
  // eslint-disable-next-line lit-a11y/click-events-have-key-events -- keyboard lives on the combobox (aria-activedescendant pattern); options are never focused
1722
- (i, s) => l`<div
1723
- class="baht-listbox-option${s === this.active ? " baht-listbox-option--active" : ""}${s === 0 ? " baht-listbox-option--placeholder" : ""}"
1724
- id=${this.optionId(s)}
1722
+ (i, a) => l`<div
1723
+ class="baht-listbox-option${a === this.active ? " baht-listbox-option--active" : ""}${a === 0 ? " baht-listbox-option--placeholder" : ""}"
1724
+ id=${this.optionId(a)}
1725
1725
  role="option"
1726
- aria-selected=${s === e ? "true" : "false"}
1726
+ aria-selected=${a === e ? "true" : "false"}
1727
1727
  data-key=${i.key}
1728
1728
  @mousedown=${(r) => r.preventDefault()}
1729
- @mousemove=${() => this.highlight(s)}
1730
- @click=${() => this.commit(s)}
1729
+ @mousemove=${() => this.highlight(a)}
1730
+ @click=${() => this.commit(a)}
1731
1731
  >
1732
1732
  ${i.label}
1733
1733
  </div>`
@@ -1745,18 +1745,18 @@ qe([
1745
1745
  ne = qe([
1746
1746
  f("baht-select")
1747
1747
  ], ne);
1748
- var Da = Object.getOwnPropertyDescriptor, Sa = (t, e, a, i) => {
1749
- for (var s = i > 1 ? void 0 : i ? Da(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1750
- (o = t[r]) && (s = o(s) || s);
1751
- return s;
1748
+ var Sa = Object.getOwnPropertyDescriptor, Fa = (t, e, s, i) => {
1749
+ for (var a = i > 1 ? void 0 : i ? Sa(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1750
+ (o = t[r]) && (a = o(a) || a);
1751
+ return a;
1752
1752
  };
1753
- let We = class extends X {
1753
+ let Je = class extends X {
1754
1754
  get selected() {
1755
1755
  return Array.isArray(this.value) ? this.value : [];
1756
1756
  }
1757
1757
  toggle(t, e) {
1758
- const a = e ? [...this.selected, t] : this.selected.filter((s) => s !== t), i = (this.field.options ?? []).map((s) => s.key);
1759
- this.emitInput(i.filter((s) => a.includes(s)));
1758
+ const s = e ? [...this.selected, t] : this.selected.filter((a) => a !== t), i = (this.field.options ?? []).map((a) => a.key);
1759
+ this.emitInput(i.filter((a) => s.includes(a)));
1760
1760
  }
1761
1761
  renderControl() {
1762
1762
  return l`<div
@@ -1780,15 +1780,15 @@ let We = class extends X {
1780
1780
  </div>`;
1781
1781
  }
1782
1782
  };
1783
- We = Sa([
1783
+ Je = Fa([
1784
1784
  f("baht-multiselect")
1785
- ], We);
1786
- var Fa = Object.getOwnPropertyDescriptor, Ma = (t, e, a, i) => {
1787
- for (var s = i > 1 ? void 0 : i ? Fa(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1788
- (o = t[r]) && (s = o(s) || s);
1789
- return s;
1785
+ ], Je);
1786
+ var Ma = Object.getOwnPropertyDescriptor, Ia = (t, e, s, i) => {
1787
+ for (var a = i > 1 ? void 0 : i ? Ma(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1788
+ (o = t[r]) && (a = o(a) || a);
1789
+ return a;
1790
1790
  };
1791
- let Je = class extends X {
1791
+ let Xe = class extends X {
1792
1792
  /** Label sits beside the box, so suppress the block label. */
1793
1793
  renderLabel() {
1794
1794
  return h;
@@ -1811,15 +1811,15 @@ let Je = class extends X {
1811
1811
  </label>`;
1812
1812
  }
1813
1813
  };
1814
- Je = Ma([
1814
+ Xe = Ia([
1815
1815
  f("baht-checkbox")
1816
- ], Je);
1817
- var Ba = Object.getOwnPropertyDescriptor, Ia = (t, e, a, i) => {
1818
- for (var s = i > 1 ? void 0 : i ? Ba(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1819
- (o = t[r]) && (s = o(s) || s);
1820
- return s;
1816
+ ], Xe);
1817
+ var Ba = Object.getOwnPropertyDescriptor, Ta = (t, e, s, i) => {
1818
+ for (var a = i > 1 ? void 0 : i ? Ba(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1819
+ (o = t[r]) && (a = o(a) || a);
1820
+ return a;
1821
1821
  };
1822
- let Xe = class extends X {
1822
+ let Ye = class extends X {
1823
1823
  renderOption(t) {
1824
1824
  return l`<label class="baht-option">
1825
1825
  <input
@@ -1844,7 +1844,7 @@ let Xe = class extends X {
1844
1844
  ?disabled=${this.disabled || this.readonly}
1845
1845
  @change=${() => this.emitInput(t.key)}
1846
1846
  />
1847
- ${t.icon && us(t.icon) ? l`<span class="baht-option-card-icon">${j(t.icon)}</span>` : h}
1847
+ ${t.icon && us(t.icon) ? l`<span class="baht-option-card-icon">${T(t.icon)}</span>` : h}
1848
1848
  <span class="baht-option-card-title">${t.label}</span>
1849
1849
  </span>
1850
1850
  ${t.description ? l`<span class="baht-option-card-desc">${t.description}</span>` : h}
@@ -1866,15 +1866,15 @@ let Xe = class extends X {
1866
1866
  </div>`;
1867
1867
  }
1868
1868
  };
1869
- Xe = Ia([
1869
+ Ye = Ta([
1870
1870
  f("baht-radio")
1871
- ], Xe);
1872
- var ja = Object.getOwnPropertyDescriptor, Ta = (t, e, a, i) => {
1873
- for (var s = i > 1 ? void 0 : i ? ja(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1874
- (o = t[r]) && (s = o(s) || s);
1875
- return s;
1871
+ ], Ye);
1872
+ var ja = Object.getOwnPropertyDescriptor, Aa = (t, e, s, i) => {
1873
+ for (var a = i > 1 ? void 0 : i ? ja(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1874
+ (o = t[r]) && (a = o(a) || a);
1875
+ return a;
1876
1876
  };
1877
- let Ye = class extends X {
1877
+ let Ze = class extends X {
1878
1878
  renderLabel() {
1879
1879
  return h;
1880
1880
  }
@@ -1899,15 +1899,15 @@ let Ye = class extends X {
1899
1899
  </label>`;
1900
1900
  }
1901
1901
  };
1902
- Ye = Ta([
1902
+ Ze = Aa([
1903
1903
  f("baht-toggle")
1904
- ], Ye);
1905
- var Aa = Object.getOwnPropertyDescriptor, Ea = (t, e, a, i) => {
1906
- for (var s = i > 1 ? void 0 : i ? Aa(e, a) : e, r = t.length - 1, o; r >= 0; r--)
1907
- (o = t[r]) && (s = o(s) || s);
1908
- return s;
1904
+ ], Ze);
1905
+ var Ea = Object.getOwnPropertyDescriptor, La = (t, e, s, i) => {
1906
+ for (var a = i > 1 ? void 0 : i ? Ea(e, s) : e, r = t.length - 1, o; r >= 0; r--)
1907
+ (o = t[r]) && (a = o(a) || a);
1908
+ return a;
1909
1909
  };
1910
- let Ze = class extends X {
1910
+ let Qe = class extends X {
1911
1911
  constructor() {
1912
1912
  super(...arguments), this.lastEmitted = null;
1913
1913
  }
@@ -1925,7 +1925,7 @@ let Ze = class extends X {
1925
1925
  aria-invalid=${this.invalid}
1926
1926
  aria-describedby=${this.describedBy}
1927
1927
  />
1928
- <span class="baht-datepicker-field-icon" aria-hidden="true">${j("calendar")}</span>
1928
+ <span class="baht-datepicker-field-icon" aria-hidden="true">${T("calendar")}</span>
1929
1929
  </span>`;
1930
1930
  }
1931
1931
  connectedCallback() {
@@ -1941,7 +1941,7 @@ let Ze = class extends X {
1941
1941
  return;
1942
1942
  }
1943
1943
  if (!this.fp || this.fp.input !== e || t.has("field") || t.has("disabled") || t.has("readonly")) {
1944
- this.teardown(), this.fp = Ds(e, this.options());
1944
+ this.teardown(), this.fp = Ss(e, this.options());
1945
1945
  return;
1946
1946
  }
1947
1947
  t.has("value") && (this.lastEmitted = null, this.syncValue());
@@ -1954,30 +1954,37 @@ let Ze = class extends X {
1954
1954
  syncValue() {
1955
1955
  if (!this.fp) return;
1956
1956
  const t = this.datesOf(this.value);
1957
- ts(this.fp.selectedDates, t) || (t.length === 0 ? this.fp.clear(!1) : this.fp.setDate(t, !1));
1957
+ this.sameInstants(this.fp.selectedDates, t) || (t.length === 0 ? this.fp.clear(!1) : this.fp.setDate(t, !1));
1958
+ }
1959
+ /** Value-equality for the picker's own selection (minute-precise with `enable_time`). */
1960
+ sameInstants(t, e) {
1961
+ if (t.length !== e.length) return !1;
1962
+ const s = this.field.enable_time ? Re : ae;
1963
+ return t.every((i, a) => s(i) === s(e[a]));
1958
1964
  }
1959
1965
  options() {
1960
- const t = this.field, e = ye(t), a = qt(t.min), i = qt(t.max);
1966
+ const t = this.field, e = ye(t), s = qt(t.min), i = qt(t.max);
1961
1967
  return {
1962
1968
  static: !0,
1963
1969
  disableMobile: !0,
1964
1970
  // our calendar everywhere — never the OS date wheel
1965
1971
  mode: e,
1966
- dateFormat: t.date_format ?? "Y-m-d",
1972
+ dateFormat: t.date_format ?? (t.enable_time ? "Y-m-d H:i" : "Y-m-d"),
1973
+ ...t.enable_time ? { enableTime: !0, time_24hr: t.time_24hr ?? !1 } : {},
1967
1974
  allowInput: !0,
1968
1975
  clickOpens: !this.disabled && !this.readonly,
1969
1976
  defaultDate: this.datesOf(this.value),
1970
- ...a ? { minDate: a } : {},
1977
+ ...s ? { minDate: s } : {},
1971
1978
  ...i ? { maxDate: i } : {},
1972
1979
  disable: es(t),
1973
- onReady: (s, r, o) => this.mountFooter(o),
1980
+ onReady: (a, r, o) => this.mountFooter(o),
1974
1981
  onOpen: () => this.refreshFooter(),
1975
- onChange: (s) => {
1976
- this.refreshFooter(), !(e === "range" && s.length === 1) && this.emitIfChanged(s);
1982
+ onChange: (a) => {
1983
+ this.refreshFooter(), !(e === "range" && a.length === 1) && this.emitIfChanged(a);
1977
1984
  },
1978
- onClose: (s) => {
1985
+ onClose: (a) => {
1979
1986
  var r, o;
1980
- e === "range" && s.length === 1 && ((r = this.fp) == null || r.clear(!1)), this.emitIfChanged(((o = this.fp) == null ? void 0 : o.selectedDates) ?? []);
1987
+ e === "range" && a.length === 1 && ((r = this.fp) == null || r.clear(!1)), this.emitIfChanged(((o = this.fp) == null ? void 0 : o.selectedDates) ?? []);
1981
1988
  }
1982
1989
  };
1983
1990
  }
@@ -1985,13 +1992,13 @@ let Ze = class extends X {
1985
1992
  mountFooter(t) {
1986
1993
  const e = document.createElement("div");
1987
1994
  e.className = "baht-datepicker-footer";
1988
- const a = document.createElement("button");
1989
- a.type = "button", a.className = "baht-button baht-button--sm baht-datepicker-today", a.textContent = u("today"), a.addEventListener("click", () => this.pickToday());
1995
+ const s = document.createElement("button");
1996
+ s.type = "button", s.className = "baht-button baht-button--sm baht-datepicker-today", s.textContent = u("today"), s.addEventListener("click", () => this.pickToday());
1990
1997
  const i = document.createElement("button");
1991
1998
  i.type = "button", i.className = "baht-button baht-button--danger baht-button--sm baht-datepicker-clear", i.textContent = u("clear"), i.addEventListener("click", () => {
1992
- var s, r;
1993
- (s = this.fp) == null || s.clear(), (r = this.fp) == null || r.close();
1994
- }), e.append(a, i), t.calendarContainer.appendChild(e), this.todayBtn = a, this.clearBtn = i, this.refreshFooter(t);
1999
+ var a, r;
2000
+ (a = this.fp) == null || a.clear(), (r = this.fp) == null || r.close();
2001
+ }), e.append(s, i), t.calendarContainer.appendChild(e), this.todayBtn = s, this.clearBtn = i, this.refreshFooter(t);
1995
2002
  }
1996
2003
  /** Today greys out when the rules exclude it; Clear when there is nothing to clear.
1997
2004
  * `fp` is passed explicitly from onReady — it fires inside the flatpickr()
@@ -2000,16 +2007,16 @@ let Ze = class extends X {
2000
2007
  t && (this.todayBtn && (this.todayBtn.disabled = !this.todayAllowed()), this.clearBtn && (this.clearBtn.disabled = t.selectedDates.length === 0));
2001
2008
  }
2002
2009
  todayAllowed() {
2003
- const t = kt(/* @__PURE__ */ new Date()), e = qt(this.field.min), a = qt(this.field.max);
2004
- if (e && t < kt(e) || a && t > kt(a)) return !1;
2010
+ const t = kt(/* @__PURE__ */ new Date()), e = qt(this.field.min), s = qt(this.field.max);
2011
+ if (e && t < kt(e) || s && t > kt(s)) return !1;
2005
2012
  for (const i of es(this.field) ?? [])
2006
2013
  if (i instanceof Date) {
2007
- if (Qe(i, t)) return !1;
2014
+ if (ts(i, t)) return !1;
2008
2015
  } else if (typeof i == "function") {
2009
2016
  if (i(t)) return !1;
2010
2017
  } else if (typeof i == "object" && "from" in i) {
2011
- const s = kt(new Date(i.from)), r = kt(new Date(i.to));
2012
- if (t >= s && t <= r) return !1;
2018
+ const a = kt(new Date(i.from)), r = kt(new Date(i.to));
2019
+ if (t >= a && t <= r) return !1;
2013
2020
  }
2014
2021
  return !0;
2015
2022
  }
@@ -2022,7 +2029,7 @@ let Ze = class extends X {
2022
2029
  t.setDate([e, e], !0);
2023
2030
  break;
2024
2031
  case "multiple": {
2025
- t.selectedDates.some((i) => Qe(i, e)) || t.setDate([...t.selectedDates, e], !0);
2032
+ t.selectedDates.some((i) => ts(i, e)) || t.setDate([...t.selectedDates, e], !0);
2026
2033
  break;
2027
2034
  }
2028
2035
  default:
@@ -2032,50 +2039,48 @@ let Ze = class extends X {
2032
2039
  }
2033
2040
  emitIfChanged(t) {
2034
2041
  const e = this.lastEmitted ?? this.datesOf(this.value);
2035
- ts(t, e) || (this.lastEmitted = [...t], this.emitInput(this.toValue(t)));
2042
+ this.sameInstants(t, e) || (this.lastEmitted = [...t], this.emitInput(this.toValue(t)));
2036
2043
  }
2037
2044
  /** Host value (any mode) -> the Date list flatpickr works with. */
2038
2045
  datesOf(t) {
2039
- return ws(t).map(qt).filter((e) => e !== null);
2046
+ const e = this.field.enable_time ? ws : qt;
2047
+ return xs(t).map(e).filter((s) => s !== null);
2040
2048
  }
2041
2049
  /** flatpickr's selection -> the value shape of the field's mode. */
2042
2050
  toValue(t) {
2043
- const e = t.map(Vt);
2051
+ const e = this.field.enable_time ? Re : ae, s = t.map(e);
2044
2052
  switch (ye(this.field)) {
2045
2053
  case "range":
2046
- return e.length === 2 ? [e[0], e[1]] : null;
2054
+ return s.length === 2 ? [s[0], s[1]] : null;
2047
2055
  case "multiple":
2048
- return e;
2056
+ return s;
2049
2057
  default:
2050
- return e[0] ?? null;
2058
+ return s[0] ?? null;
2051
2059
  }
2052
2060
  }
2053
2061
  };
2054
- Ze = Ea([
2062
+ Qe = La([
2055
2063
  f("baht-datepicker")
2056
- ], Ze);
2064
+ ], Qe);
2057
2065
  function kt(t) {
2058
2066
  return new Date(t.getFullYear(), t.getMonth(), t.getDate());
2059
2067
  }
2060
- function Qe(t, e) {
2061
- return Vt(t) === Vt(e);
2062
- }
2063
2068
  function ts(t, e) {
2064
- return t.length !== e.length ? !1 : t.every((a, i) => Vt(a) === Vt(e[i]));
2069
+ return ae(t) === ae(e);
2065
2070
  }
2066
2071
  function es(t) {
2067
2072
  const e = [];
2068
2073
  for (const i of t.disabled_dates ?? []) {
2069
- const s = xs(i);
2070
- s && e.push(s[0].getTime() === s[1].getTime() ? s[0] : { from: s[0], to: s[1] });
2074
+ const a = _s(i);
2075
+ a && e.push(a[0].getTime() === a[1].getTime() ? a[0] : { from: a[0], to: a[1] });
2071
2076
  }
2072
- const a = t.disabled_weekdays;
2073
- return a != null && a.length && e.push((i) => a.includes(i.getDay())), e;
2077
+ const s = t.disabled_weekdays;
2078
+ return s != null && s.length && e.push((i) => s.includes(i.getDay())), e;
2074
2079
  }
2075
- var La = Object.defineProperty, Na = Object.getOwnPropertyDescriptor, te = (t, e, a, i) => {
2076
- for (var s = i > 1 ? void 0 : i ? Na(e, a) : e, r = t.length - 1, o; r >= 0; r--)
2077
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
2078
- return i && s && La(e, a, s), s;
2080
+ var Na = Object.defineProperty, qa = Object.getOwnPropertyDescriptor, Qt = (t, e, s, i) => {
2081
+ for (var a = i > 1 ? void 0 : i ? qa(e, s) : e, r = t.length - 1, o; r >= 0; r--)
2082
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
2083
+ return i && a && Na(e, s, a), a;
2079
2084
  };
2080
2085
  function ss(t) {
2081
2086
  return t !== null && typeof t == "object" && typeof t.url == "string";
@@ -2097,9 +2102,9 @@ let Mt = class extends X {
2097
2102
  if (!this.uploader) return;
2098
2103
  this.uploadError = null, this.uploadingCount += t.length;
2099
2104
  const e = this.field.multiple ? [...this.refs] : [];
2100
- for (const a of t)
2105
+ for (const s of t)
2101
2106
  try {
2102
- e.push(await this.uploader(a));
2107
+ e.push(await this.uploader(s));
2103
2108
  } catch {
2104
2109
  this.uploadError = u("uploadFailed");
2105
2110
  } finally {
@@ -2112,8 +2117,8 @@ let Mt = class extends X {
2112
2117
  this.take(Array.from(e.files ?? []), e);
2113
2118
  }
2114
2119
  take(t, e) {
2115
- const a = this.field.max_size, i = a ? t.filter((r) => r.size <= a) : t, s = a ? t.filter((r) => r.size > a) : [];
2116
- if (this.rejectedNames = s.map((r) => r.name), this.uploader) {
2120
+ const s = this.field.max_size, i = s ? t.filter((r) => r.size <= s) : t, a = s ? t.filter((r) => r.size > s) : [];
2121
+ if (this.rejectedNames = a.map((r) => r.name), this.uploader) {
2117
2122
  e && (e.value = ""), this.uploadAll(i);
2118
2123
  return;
2119
2124
  }
@@ -2129,20 +2134,20 @@ let Mt = class extends X {
2129
2134
  ), this.field.max_size && t.push(u("uploadMaxSize", { size: _e(this.field.max_size) })), t.join(" · ");
2130
2135
  }
2131
2136
  renderControl() {
2132
- const t = this.disabled || this.readonly || this.uploadingCount > 0, e = this.hintText(), a = [
2137
+ const t = this.disabled || this.readonly || this.uploadingCount > 0, e = this.hintText(), s = [
2133
2138
  "baht-dropzone",
2134
2139
  t ? "baht-dropzone--disabled" : "",
2135
2140
  this.invalid === "true" ? "baht-dropzone--invalid" : ""
2136
2141
  ].filter(Boolean).join(" ");
2137
2142
  return l`<div
2138
- class=${a}
2143
+ class=${s}
2139
2144
  @dragover=${(i) => {
2140
2145
  t || (i.preventDefault(), i.currentTarget.classList.add("baht-dropzone--over"));
2141
2146
  }}
2142
2147
  @dragleave=${(i) => i.currentTarget.classList.remove("baht-dropzone--over")}
2143
2148
  @drop=${(i) => {
2144
- var s;
2145
- i.preventDefault(), i.currentTarget.classList.remove("baht-dropzone--over"), t || this.take(Array.from(((s = i.dataTransfer) == null ? void 0 : s.files) ?? []));
2149
+ var a;
2150
+ i.preventDefault(), i.currentTarget.classList.remove("baht-dropzone--over"), t || this.take(Array.from(((a = i.dataTransfer) == null ? void 0 : a.files) ?? []));
2146
2151
  }}
2147
2152
  >
2148
2153
  <input
@@ -2188,57 +2193,57 @@ let Mt = class extends X {
2188
2193
  class="baht-file-remove"
2189
2194
  aria-label=${u("removeFile")}
2190
2195
  title=${u("removeFile")}
2191
- @click=${() => this.emitRefs(this.refs.filter((s) => s !== i))}
2196
+ @click=${() => this.emitRefs(this.refs.filter((a) => a !== i))}
2192
2197
  >
2193
- ${j("close")}
2198
+ ${T("close")}
2194
2199
  </button>`}
2195
2200
  </span>`
2196
2201
  )}`;
2197
2202
  }
2198
2203
  };
2199
- te([
2204
+ Qt([
2200
2205
  n({ attribute: !1 })
2201
2206
  ], Mt.prototype, "uploader", 2);
2202
- te([
2207
+ Qt([
2203
2208
  v()
2204
2209
  ], Mt.prototype, "uploadingCount", 2);
2205
- te([
2210
+ Qt([
2206
2211
  v()
2207
2212
  ], Mt.prototype, "uploadError", 2);
2208
- te([
2213
+ Qt([
2209
2214
  v()
2210
2215
  ], Mt.prototype, "rejectedNames", 2);
2211
- Mt = te([
2216
+ Mt = Qt([
2212
2217
  f("baht-file")
2213
2218
  ], Mt);
2214
- var qa = Object.defineProperty, Ra = Object.getOwnPropertyDescriptor, B = (t, e, a, i) => {
2215
- for (var s = i > 1 ? void 0 : i ? Ra(e, a) : e, r = t.length - 1, o; r >= 0; r--)
2216
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
2217
- return i && s && qa(e, a, s), s;
2219
+ var Ra = Object.defineProperty, za = Object.getOwnPropertyDescriptor, I = (t, e, s, i) => {
2220
+ for (var a = i > 1 ? void 0 : i ? za(e, s) : e, r = t.length - 1, o; r >= 0; r--)
2221
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
2222
+ return i && a && Ra(e, s, a), a;
2218
2223
  };
2219
- function za(t, e) {
2220
- return e.split(".").reduce((a, i) => {
2221
- if (a !== null && typeof a == "object") return a[i];
2224
+ function Va(t, e) {
2225
+ return e.split(".").reduce((s, i) => {
2226
+ if (s !== null && typeof s == "object") return s[i];
2222
2227
  }, t);
2223
2228
  }
2224
- function Va(t, e) {
2225
- const a = t.trim();
2226
- if (!a) return null;
2229
+ function Ka(t, e) {
2230
+ const s = t.trim();
2231
+ if (!s) return null;
2227
2232
  try {
2228
- const i = JSON.parse(a);
2233
+ const i = JSON.parse(s);
2229
2234
  if (typeof i == "string") return i;
2230
- const s = e ? za(i, e) : i;
2231
- return typeof s == "string" && s ? s : null;
2235
+ const a = e ? Va(i, e) : i;
2236
+ return typeof a == "string" && a ? a : null;
2232
2237
  } catch {
2233
- return /^(https?:\/\/|\/|data:|blob:)/.test(a) ? a : null;
2238
+ return /^(https?:\/\/|\/|data:|blob:)/.test(s) ? s : null;
2234
2239
  }
2235
2240
  }
2236
- function Ka(t) {
2237
- const a = (t.split(/[?#]/)[0] ?? t).split("/").filter(Boolean).pop() ?? t;
2241
+ function Ua(t) {
2242
+ const s = (t.split(/[?#]/)[0] ?? t).split("/").filter(Boolean).pop() ?? t;
2238
2243
  try {
2239
- return decodeURIComponent(a);
2244
+ return decodeURIComponent(s);
2240
2245
  } catch {
2241
- return a;
2246
+ return s;
2242
2247
  }
2243
2248
  }
2244
2249
  function ke(t) {
@@ -2255,7 +2260,7 @@ let S = class extends y {
2255
2260
  return `baht-upload-${this.uid}`;
2256
2261
  }
2257
2262
  fileFor(t) {
2258
- return this.known.get(t) ?? { name: Ka(t), size: 0, url: t };
2263
+ return this.known.get(t) ?? { name: Ua(t), size: 0, url: t };
2259
2264
  }
2260
2265
  /** Empty the value (does not delete anything on the server). */
2261
2266
  clear() {
@@ -2265,15 +2270,15 @@ let S = class extends y {
2265
2270
  const e = this.multiple ? t : t[0] ?? null;
2266
2271
  this.value = e, this.emit("baht-change", {
2267
2272
  value: e,
2268
- files: t.map((a) => this.fileFor(a))
2273
+ files: t.map((s) => this.fileFor(s))
2269
2274
  });
2270
2275
  }
2271
2276
  accept_(t) {
2272
2277
  if (this.disabled || t.length === 0) return;
2273
- const e = this.maxSize, a = e ? t.filter((s) => s.size <= e) : t;
2274
- this.rejectedNames = e ? t.filter((s) => s.size > e).map((s) => s.name) : [];
2275
- const i = this.multiple ? a : a.slice(0, 1);
2276
- for (const s of i) this.start(s);
2278
+ const e = this.maxSize, s = e ? t.filter((a) => a.size <= e) : t;
2279
+ this.rejectedNames = e ? t.filter((a) => a.size > e).map((a) => a.name) : [];
2280
+ const i = this.multiple ? s : s.slice(0, 1);
2281
+ for (const a of i) this.start(a);
2277
2282
  }
2278
2283
  onPick(t) {
2279
2284
  const e = t.target;
@@ -2294,36 +2299,36 @@ let S = class extends y {
2294
2299
  this.pending = this.multiple ? [...this.pending, e] : [e], this.emit("baht-upload-start", { file: t }), this.send(e);
2295
2300
  }
2296
2301
  patch(t, e) {
2297
- this.pending = this.pending.map((a) => a.id === t ? { ...a, ...e } : a);
2302
+ this.pending = this.pending.map((s) => s.id === t ? { ...s, ...e } : s);
2298
2303
  }
2299
2304
  send(t) {
2300
2305
  const e = new XMLHttpRequest();
2301
2306
  e.open(this.method || "POST", this.url);
2302
- for (const [i, s] of Object.entries(this.headers ?? {})) e.setRequestHeader(i, s);
2307
+ for (const [i, a] of Object.entries(this.headers ?? {})) e.setRequestHeader(i, a);
2303
2308
  e.withCredentials = this.withCredentials, e.upload.onprogress = (i) => {
2304
- const s = i.total > 0 ? Math.round(i.loaded / i.total * 100) : 0;
2305
- this.patch(t.id, { percent: s }), this.emit("baht-upload-progress", {
2309
+ const a = i.total > 0 ? Math.round(i.loaded / i.total * 100) : 0;
2310
+ this.patch(t.id, { percent: a }), this.emit("baht-upload-progress", {
2306
2311
  file: t.file,
2307
2312
  loaded: i.loaded,
2308
2313
  total: i.total,
2309
- percent: s
2314
+ percent: a
2310
2315
  });
2311
2316
  }, e.onload = () => {
2312
- const i = e.status >= 200 && e.status < 300, s = i ? Va(e.responseText, this.responseKey) : null;
2313
- if (!i || !s) return this.failed(t, i ? 0 : e.status);
2314
- this.known.set(s, {
2317
+ const i = e.status >= 200 && e.status < 300, a = i ? Ka(e.responseText, this.responseKey) : null;
2318
+ if (!i || !a) return this.failed(t, i ? 0 : e.status);
2319
+ this.known.set(a, {
2315
2320
  name: t.file.name,
2316
2321
  size: t.file.size,
2317
2322
  type: t.file.type || void 0,
2318
- url: s
2319
- }), this.pending = this.pending.filter((r) => r.id !== t.id), this.emitValue(this.multiple ? [...this.urls, s] : [s]);
2323
+ url: a
2324
+ }), this.pending = this.pending.filter((r) => r.id !== t.id), this.emitValue(this.multiple ? [...this.urls, a] : [a]);
2320
2325
  }, e.onerror = () => this.failed(t, 0);
2321
- const a = new FormData();
2322
- a.append(this.fieldName || "file", t.file, t.file.name), e.send(a);
2326
+ const s = new FormData();
2327
+ s.append(this.fieldName || "file", t.file, t.file.name), e.send(s);
2323
2328
  }
2324
2329
  failed(t, e) {
2325
- const a = u("uploadFailed");
2326
- this.patch(t.id, { error: a, percent: 0 }), this.emit("baht-upload-error", { file: t.file, status: e, message: a });
2330
+ const s = u("uploadFailed");
2331
+ this.patch(t.id, { error: s, percent: 0 }), this.emit("baht-upload-error", { file: t.file, status: e, message: s });
2327
2332
  }
2328
2333
  retry(t) {
2329
2334
  this.patch(t.id, { error: null, percent: 0 }), this.send({ ...t, error: null, percent: 0 });
@@ -2338,7 +2343,7 @@ let S = class extends y {
2338
2343
  ), this.maxSize && t.push(u("uploadMaxSize", { size: ke(this.maxSize) })), t.join(" · ");
2339
2344
  }
2340
2345
  render() {
2341
- const t = this.pending.some((c) => !c.error), e = !!this.error, a = this.hint || this.defaultHint(), i = a ? `${this.inputId}-hint` : void 0, s = this.error ? `${this.inputId}-error` : void 0, r = [i, s].filter(Boolean).join(" ") || void 0, o = [
2346
+ const t = this.pending.some((c) => !c.error), e = !!this.error, s = this.hint || this.defaultHint(), i = s ? `${this.inputId}-hint` : void 0, a = this.error ? `${this.inputId}-error` : void 0, r = [i, a].filter(Boolean).join(" ") || void 0, o = [
2342
2347
  "baht-dropzone",
2343
2348
  this.dragging ? "baht-dropzone--over" : "",
2344
2349
  this.disabled ? "baht-dropzone--disabled" : "",
@@ -2373,7 +2378,7 @@ let S = class extends y {
2373
2378
  >
2374
2379
  <span class="baht-dropzone-or">${u("orDropHere")}</span>
2375
2380
  </span>
2376
- ${a ? l`<span class="baht-dropzone-hint" id=${L(i)}>${a}</span>` : h}
2381
+ ${s ? l`<span class="baht-dropzone-hint" id=${L(i)}>${s}</span>` : h}
2377
2382
  </div>
2378
2383
 
2379
2384
  ${this.pending.length > 0 || this.urls.length > 0 ? l`<ul class="baht-upload-list" aria-live="polite" aria-busy=${t ? "true" : "false"}>
@@ -2383,13 +2388,13 @@ let S = class extends y {
2383
2388
  ${this.rejectedNames.length > 0 ? l`<p class="baht-error" role="alert">
2384
2389
  ${u("fileRejectedTooLarge", { names: this.rejectedNames.join(", ") })}
2385
2390
  </p>` : h}
2386
- ${this.error ? l`<p class="baht-error" id=${L(s)} role="alert">${this.error}</p>` : h}
2391
+ ${this.error ? l`<p class="baht-error" id=${L(a)} role="alert">${this.error}</p>` : h}
2387
2392
  </div>`;
2388
2393
  }
2389
2394
  renderStored(t) {
2390
2395
  const e = this.fileFor(t);
2391
2396
  return l`<li class="baht-file-chip baht-file-chip--done">
2392
- <span class="baht-file-chip-icon" aria-hidden="true">${j("check")}</span>
2397
+ <span class="baht-file-chip-icon" aria-hidden="true">${T("check")}</span>
2393
2398
  <a class="baht-file-name" href=${t} target="_blank" rel="noreferrer"
2394
2399
  >${e.name}<span class="baht-visually-hidden"> (${u("opensInNewTab")})</span></a
2395
2400
  >
@@ -2399,9 +2404,9 @@ let S = class extends y {
2399
2404
  class="baht-file-remove"
2400
2405
  aria-label=${u("removeFile")}
2401
2406
  title=${u("removeFile")}
2402
- @click=${() => this.emitValue(this.urls.filter((a) => a !== t))}
2407
+ @click=${() => this.emitValue(this.urls.filter((s) => s !== t))}
2403
2408
  >
2404
- ${j("close")}
2409
+ ${T("close")}
2405
2410
  </button>`}
2406
2411
  </li>`;
2407
2412
  }
@@ -2420,7 +2425,7 @@ let S = class extends y {
2420
2425
  title=${u("removeFile")}
2421
2426
  @click=${() => this.dismiss(t)}
2422
2427
  >
2423
- ${j("close")}
2428
+ ${T("close")}
2424
2429
  </button>` : l`<span
2425
2430
  class="baht-upload-bar"
2426
2431
  role="progressbar"
@@ -2433,69 +2438,69 @@ let S = class extends y {
2433
2438
  </li>`;
2434
2439
  }
2435
2440
  };
2436
- B([
2441
+ I([
2437
2442
  n()
2438
2443
  ], S.prototype, "url", 2);
2439
- B([
2444
+ I([
2440
2445
  n()
2441
2446
  ], S.prototype, "method", 2);
2442
- B([
2447
+ I([
2443
2448
  n({ attribute: "field-name" })
2444
2449
  ], S.prototype, "fieldName", 2);
2445
- B([
2450
+ I([
2446
2451
  n({ attribute: "response-key" })
2447
2452
  ], S.prototype, "responseKey", 2);
2448
- B([
2453
+ I([
2449
2454
  n({ attribute: !1 })
2450
2455
  ], S.prototype, "headers", 2);
2451
- B([
2456
+ I([
2452
2457
  n({ type: Boolean, attribute: "with-credentials" })
2453
2458
  ], S.prototype, "withCredentials", 2);
2454
- B([
2459
+ I([
2455
2460
  n({ attribute: !1 })
2456
2461
  ], S.prototype, "value", 2);
2457
- B([
2462
+ I([
2458
2463
  n()
2459
2464
  ], S.prototype, "label", 2);
2460
- B([
2465
+ I([
2461
2466
  n()
2462
2467
  ], S.prototype, "hint", 2);
2463
- B([
2468
+ I([
2464
2469
  n()
2465
2470
  ], S.prototype, "accept", 2);
2466
- B([
2471
+ I([
2467
2472
  n({ type: Boolean })
2468
2473
  ], S.prototype, "multiple", 2);
2469
- B([
2474
+ I([
2470
2475
  n({ type: Number, attribute: "max-size" })
2471
2476
  ], S.prototype, "maxSize", 2);
2472
- B([
2477
+ I([
2473
2478
  n({ type: Boolean })
2474
2479
  ], S.prototype, "disabled", 2);
2475
- B([
2480
+ I([
2476
2481
  n({ type: Boolean })
2477
2482
  ], S.prototype, "required", 2);
2478
- B([
2483
+ I([
2479
2484
  n()
2480
2485
  ], S.prototype, "error", 2);
2481
- B([
2486
+ I([
2482
2487
  v()
2483
2488
  ], S.prototype, "pending", 2);
2484
- B([
2489
+ I([
2485
2490
  v()
2486
2491
  ], S.prototype, "rejectedNames", 2);
2487
- B([
2492
+ I([
2488
2493
  v()
2489
2494
  ], S.prototype, "dragging", 2);
2490
- S = B([
2495
+ S = I([
2491
2496
  f("baht-upload")
2492
2497
  ], S);
2493
- var Ua = Object.defineProperty, Ha = Object.getOwnPropertyDescriptor, vs = (t, e, a, i) => {
2494
- for (var s = i > 1 ? void 0 : i ? Ha(e, a) : e, r = t.length - 1, o; r >= 0; r--)
2495
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
2496
- return i && s && Ua(e, a, s), s;
2498
+ var Ha = Object.defineProperty, Ga = Object.getOwnPropertyDescriptor, vs = (t, e, s, i) => {
2499
+ for (var a = i > 1 ? void 0 : i ? Ga(e, s) : e, r = t.length - 1, o; r >= 0; r--)
2500
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
2501
+ return i && a && Ha(e, s, a), a;
2497
2502
  };
2498
- let Ie = class extends y {
2503
+ let Be = class extends y {
2499
2504
  render() {
2500
2505
  if (!this.field) return h;
2501
2506
  const t = this.field.variant ?? "body";
@@ -2504,16 +2509,16 @@ let Ie = class extends y {
2504
2509
  };
2505
2510
  vs([
2506
2511
  n({ attribute: !1 })
2507
- ], Ie.prototype, "field", 2);
2508
- Ie = vs([
2512
+ ], Be.prototype, "field", 2);
2513
+ Be = vs([
2509
2514
  f("baht-text")
2510
- ], Ie);
2511
- var Ga = Object.defineProperty, Wa = Object.getOwnPropertyDescriptor, $s = (t, e, a, i) => {
2512
- for (var s = i > 1 ? void 0 : i ? Wa(e, a) : e, r = t.length - 1, o; r >= 0; r--)
2513
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
2514
- return i && s && Ga(e, a, s), s;
2515
+ ], Be);
2516
+ var Wa = Object.defineProperty, Ja = Object.getOwnPropertyDescriptor, $s = (t, e, s, i) => {
2517
+ for (var a = i > 1 ? void 0 : i ? Ja(e, s) : e, r = t.length - 1, o; r >= 0; r--)
2518
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
2519
+ return i && a && Wa(e, s, a), a;
2515
2520
  };
2516
- let je = class extends y {
2521
+ let Te = class extends y {
2517
2522
  render() {
2518
2523
  return this.field ? l`<div class="baht-section">
2519
2524
  <span class="baht-section-label">${this.field.text ?? this.field.label ?? ""}</span>
@@ -2522,16 +2527,16 @@ let je = class extends y {
2522
2527
  };
2523
2528
  $s([
2524
2529
  n({ attribute: !1 })
2525
- ], je.prototype, "field", 2);
2526
- je = $s([
2530
+ ], Te.prototype, "field", 2);
2531
+ Te = $s([
2527
2532
  f("baht-section")
2528
- ], je);
2529
- var Ja = Object.defineProperty, Xa = Object.getOwnPropertyDescriptor, fe = (t, e, a, i) => {
2530
- for (var s = i > 1 ? void 0 : i ? Xa(e, a) : e, r = t.length - 1, o; r >= 0; r--)
2531
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
2532
- return i && s && Ja(e, a, s), s;
2533
+ ], Te);
2534
+ var Xa = Object.defineProperty, Ya = Object.getOwnPropertyDescriptor, fe = (t, e, s, i) => {
2535
+ for (var a = i > 1 ? void 0 : i ? Ya(e, s) : e, r = t.length - 1, o; r >= 0; r--)
2536
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
2537
+ return i && a && Xa(e, s, a), a;
2533
2538
  };
2534
- let Ht = class extends y {
2539
+ let Ut = class extends y {
2535
2540
  constructor() {
2536
2541
  super(...arguments), this.total = 0, this.label = "", this.color = "";
2537
2542
  }
@@ -2547,35 +2552,35 @@ let Ht = class extends y {
2547
2552
  };
2548
2553
  fe([
2549
2554
  n({ type: Number })
2550
- ], Ht.prototype, "total", 2);
2555
+ ], Ut.prototype, "total", 2);
2551
2556
  fe([
2552
2557
  n()
2553
- ], Ht.prototype, "label", 2);
2558
+ ], Ut.prototype, "label", 2);
2554
2559
  fe([
2555
2560
  n()
2556
- ], Ht.prototype, "color", 2);
2557
- Ht = fe([
2561
+ ], Ut.prototype, "color", 2);
2562
+ Ut = fe([
2558
2563
  f("baht-stat-chart")
2559
- ], Ht);
2560
- var Ya = Object.defineProperty, Lt = (t, e, a, i) => {
2561
- for (var s = void 0, r = t.length - 1, o; r >= 0; r--)
2562
- (o = t[r]) && (s = o(e, a, s) || s);
2563
- return s && Ya(e, a, s), s;
2564
+ ], Ut);
2565
+ var Za = Object.defineProperty, Lt = (t, e, s, i) => {
2566
+ for (var a = void 0, r = t.length - 1, o; r >= 0; r--)
2567
+ (o = t[r]) && (a = o(e, s, a) || a);
2568
+ return a && Za(e, s, a), a;
2564
2569
  };
2565
- const Za = 10;
2570
+ const Qa = 10;
2566
2571
  function ft(t, e) {
2567
- return e && t === 0 ? e : `var(--baht-chart-${t % Za + 1})`;
2572
+ return e && t === 0 ? e : `var(--baht-chart-${t % Qa + 1})`;
2568
2573
  }
2569
2574
  function as(t, e = 5) {
2570
2575
  return `var(--baht-chart-seq-${Math.min(e - 1, Math.max(0, t)) + 1})`;
2571
2576
  }
2572
- function zt(t, e = "number", a = "THB") {
2577
+ function zt(t, e = "number", s = "THB") {
2573
2578
  if (!Number.isFinite(t)) return "—";
2574
2579
  switch (e) {
2575
2580
  case "currency":
2576
2581
  return new Intl.NumberFormat("en-US", {
2577
2582
  style: "currency",
2578
- currency: a || "THB",
2583
+ currency: s || "THB",
2579
2584
  currencyDisplay: "narrowSymbol",
2580
2585
  maximumFractionDigits: 0
2581
2586
  }).format(t).replace(/THB\s?/, "฿");
@@ -2593,35 +2598,35 @@ function zt(t, e = "number", a = "THB") {
2593
2598
  return new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format(t);
2594
2599
  }
2595
2600
  }
2596
- function Te(t, e = 4) {
2601
+ function je(t, e = 4) {
2597
2602
  if (!Number.isFinite(t) || t <= 0) return [0, 1];
2598
- const a = t / (Math.max(1, e) + 1), i = 10 ** Math.floor(Math.log10(a)), s = [1, 2, 2.5, 5, 10].map((c) => c * i).find((c) => c >= a - 1e-9) ?? 10 * i, r = Math.ceil(t / s) * s, o = [];
2599
- for (let c = 0; c <= r + s / 1e3; c += s) o.push(Number(c.toFixed(10)));
2603
+ const s = t / (Math.max(1, e) + 1), i = 10 ** Math.floor(Math.log10(s)), a = [1, 2, 2.5, 5, 10].map((c) => c * i).find((c) => c >= s - 1e-9) ?? 10 * i, r = Math.ceil(t / a) * a, o = [];
2604
+ for (let c = 0; c <= r + a / 1e3; c += a) o.push(Number(c.toFixed(10)));
2600
2605
  return o;
2601
2606
  }
2602
2607
  function he(t, e) {
2603
- const [a, i] = t, [s, r] = e, o = i - a;
2604
- return !Number.isFinite(o) || o === 0 ? () => s : (c) => s + (c - a) / o * (r - s);
2608
+ const [s, i] = t, [a, r] = e, o = i - s;
2609
+ return !Number.isFinite(o) || o === 0 ? () => a : (c) => a + (c - s) / o * (r - a);
2605
2610
  }
2606
- function Qa(t, e, a = "Other") {
2611
+ function ti(t, e, s = "Other") {
2607
2612
  if (t.length <= e) return t;
2608
- const i = t.slice(0, e - 1), s = t.slice(e - 1).reduce((r, o) => r + o.count, 0);
2609
- return [...i, { label: a, count: s }];
2613
+ const i = t.slice(0, e - 1), a = t.slice(e - 1).reduce((r, o) => r + o.count, 0);
2614
+ return [...i, { label: s, count: a }];
2610
2615
  }
2611
- function me(t, e, a, i = "View as table") {
2616
+ function me(t, e, s, i = "View as table") {
2612
2617
  return l`<details class="baht-chart-table">
2613
2618
  <summary>${i}</summary>
2614
2619
  <table>
2615
2620
  <caption>${t}</caption>
2616
2621
  <thead>
2617
2622
  <tr>
2618
- ${e.map((s) => l`<th scope="col">${s}</th>`)}
2623
+ ${e.map((a) => l`<th scope="col">${a}</th>`)}
2619
2624
  </tr>
2620
2625
  </thead>
2621
2626
  <tbody>
2622
- ${a.map(
2623
- (s) => l`<tr>
2624
- ${s.map(
2627
+ ${s.map(
2628
+ (a) => l`<tr>
2629
+ ${a.map(
2625
2630
  (r, o) => o === 0 ? l`<th scope="row">${r}</th>` : l`<td class="baht-chart-num">${r}</td>`
2626
2631
  )}
2627
2632
  </tr>`
@@ -2658,14 +2663,14 @@ class at extends y {
2658
2663
  * Content is assigned with `textContent`: category and series names are
2659
2664
  * untrusted data (interaction.md).
2660
2665
  */
2661
- showTip(e, a) {
2666
+ showTip(e, s) {
2662
2667
  var $;
2663
2668
  const i = this.tipEl;
2664
2669
  if (!i) return;
2665
- i.textContent = a, i.hidden = !1;
2666
- const s = this.querySelector(".baht-chart");
2667
- if (!s || typeof s.getBoundingClientRect != "function") return;
2668
- const r = s.getBoundingClientRect(), o = e;
2670
+ i.textContent = s, i.hidden = !1;
2671
+ const a = this.querySelector(".baht-chart");
2672
+ if (!a || typeof a.getBoundingClientRect != "function") return;
2673
+ const r = a.getBoundingClientRect(), o = e;
2669
2674
  let c, m;
2670
2675
  if (typeof o.clientX == "number" && (o.clientX !== 0 || o.clientY !== 0))
2671
2676
  c = o.clientX - r.left, m = o.clientY - r.top;
@@ -2685,12 +2690,12 @@ class at extends y {
2685
2690
  return l`<div class="baht-chart-empty">${this.emptyMessage}</div>`;
2686
2691
  }
2687
2692
  /** Legend rows — only ever rendered for 2+ series (marks-and-anatomy.md). */
2688
- renderLegend(e, a = "rect") {
2693
+ renderLegend(e, s = "rect") {
2689
2694
  return e.length < 2 ? h : l`<div class="baht-chart-legend">
2690
2695
  ${e.map(
2691
2696
  (i) => l`<div class="baht-chart-legend-row">
2692
2697
  <span
2693
- class="baht-chart-swatch${a === "line" ? " baht-chart-swatch--line" : ""}"
2698
+ class="baht-chart-swatch${s === "line" ? " baht-chart-swatch--line" : ""}"
2694
2699
  style="background:${i.color}"
2695
2700
  aria-hidden="true"
2696
2701
  ></span>
@@ -2718,12 +2723,12 @@ Lt([
2718
2723
  n()
2719
2724
  ], at.prototype, "currency");
2720
2725
  Lt([
2721
- It(".baht-chart-tooltip")
2726
+ Bt(".baht-chart-tooltip")
2722
2727
  ], at.prototype, "tipEl");
2723
- var ti = Object.defineProperty, ei = Object.getOwnPropertyDescriptor, wt = (t, e, a, i) => {
2724
- for (var s = i > 1 ? void 0 : i ? ei(e, a) : e, r = t.length - 1, o; r >= 0; r--)
2725
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
2726
- return i && s && ti(e, a, s), s;
2728
+ var ei = Object.defineProperty, si = Object.getOwnPropertyDescriptor, wt = (t, e, s, i) => {
2729
+ for (var a = i > 1 ? void 0 : i ? si(e, s) : e, r = t.length - 1, o; r >= 0; r--)
2730
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
2731
+ return i && a && ei(e, s, a), a;
2727
2732
  };
2728
2733
  let ct = class extends y {
2729
2734
  constructor() {
@@ -2732,12 +2737,12 @@ let ct = class extends y {
2732
2737
  render() {
2733
2738
  const t = (this.values ?? []).filter((g) => Number.isFinite(g));
2734
2739
  if (t.length < 2) return h;
2735
- const e = Math.max(16, this.width), a = Math.max(8, this.height), i = 3, s = Math.min(...t), r = Math.max(...t), o = he([0, t.length - 1], [i, e - i]), c = he([s, r === s ? s + 1 : r], [a - i, i]), m = t.map((g, b) => `${o(b).toFixed(2)},${c(g).toFixed(2)}`).join(" "), $ = o(t.length - 1), _ = c(t[t.length - 1]), p = this.color || "var(--baht-chart-muted)", C = this.label || `Trend of ${t.length} points`;
2740
+ const e = Math.max(16, this.width), s = Math.max(8, this.height), i = 3, a = Math.min(...t), r = Math.max(...t), o = he([0, t.length - 1], [i, e - i]), c = he([a, r === a ? a + 1 : r], [s - i, i]), m = t.map((g, b) => `${o(b).toFixed(2)},${c(g).toFixed(2)}`).join(" "), $ = o(t.length - 1), _ = c(t[t.length - 1]), p = this.color || "var(--baht-chart-muted)", C = this.label || `Trend of ${t.length} points`;
2736
2741
  return l`<svg
2737
2742
  class="baht-sparkline"
2738
2743
  width=${e}
2739
- height=${a}
2740
- viewBox="0 0 ${e} ${a}"
2744
+ height=${s}
2745
+ viewBox="0 0 ${e} ${s}"
2741
2746
  role="img"
2742
2747
  aria-label=${C}
2743
2748
  >
@@ -2768,10 +2773,10 @@ wt([
2768
2773
  ct = wt([
2769
2774
  f("baht-sparkline")
2770
2775
  ], ct);
2771
- var si = Object.defineProperty, ai = Object.getOwnPropertyDescriptor, Y = (t, e, a, i) => {
2772
- for (var s = i > 1 ? void 0 : i ? ai(e, a) : e, r = t.length - 1, o; r >= 0; r--)
2773
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
2774
- return i && s && si(e, a, s), s;
2776
+ var ai = Object.defineProperty, ii = Object.getOwnPropertyDescriptor, Y = (t, e, s, i) => {
2777
+ for (var a = i > 1 ? void 0 : i ? ii(e, s) : e, r = t.length - 1, o; r >= 0; r--)
2778
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
2779
+ return i && a && ai(e, s, a), a;
2775
2780
  };
2776
2781
  let W = class extends y {
2777
2782
  constructor() {
@@ -2791,17 +2796,17 @@ let W = class extends y {
2791
2796
  return this.deltaKind === "pct" ? `${zt(e / 100, "percent")}` : zt(e, this.format, this.currency);
2792
2797
  }
2793
2798
  render() {
2794
- const t = this.delta != null && Number.isFinite(this.delta), e = this.tone, a = (this.delta ?? 0) > 0 ? "up" : (this.delta ?? 0) < 0 ? "down" : "flat";
2799
+ const t = this.delta != null && Number.isFinite(this.delta), e = this.tone, s = (this.delta ?? 0) > 0 ? "up" : (this.delta ?? 0) < 0 ? "down" : "flat";
2795
2800
  return l`<div class="baht-stat${this.size === "hero" ? " baht-stat--hero" : ""}">
2796
2801
  ${this.label ? l`<div class="baht-stat-label-row">
2797
- ${this.icon && us(this.icon) ? l`<span class="baht-stat-icon">${j(this.icon)}</span>` : h}
2802
+ ${this.icon && us(this.icon) ? l`<span class="baht-stat-icon">${T(this.icon)}</span>` : h}
2798
2803
  <span class="baht-stat-label">${this.label}</span>
2799
2804
  </div>` : h}
2800
2805
  <div class="baht-stat-value">${zt(this.value, this.format, this.currency)}</div>
2801
2806
  ${t ? l`<div class="baht-stat-delta baht-stat-delta--${e}">
2802
2807
  <span class="baht-stat-arrow" aria-hidden="true">${this.arrow}</span>
2803
2808
  <span class="baht-stat-delta-value">${this.deltaText}</span>
2804
- <span class="baht-visually-hidden">${a}</span>
2809
+ <span class="baht-visually-hidden">${s}</span>
2805
2810
  ${this.deltaLabel ? l`<span class="baht-stat-delta-label">${this.deltaLabel}</span>` : h}
2806
2811
  </div>` : h}
2807
2812
  ${!t && this.deltaLabel ? l`<div class="baht-stat-caption">${this.deltaLabel}</div>` : h}
@@ -2849,10 +2854,10 @@ Y([
2849
2854
  W = Y([
2850
2855
  f("baht-stat")
2851
2856
  ], W);
2852
- var ii = Object.defineProperty, ri = Object.getOwnPropertyDescriptor, Nt = (t, e, a, i) => {
2853
- for (var s = i > 1 ? void 0 : i ? ri(e, a) : e, r = t.length - 1, o; r >= 0; r--)
2854
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
2855
- return i && s && ii(e, a, s), s;
2857
+ var ri = Object.defineProperty, oi = Object.getOwnPropertyDescriptor, Nt = (t, e, s, i) => {
2858
+ for (var a = i > 1 ? void 0 : i ? oi(e, s) : e, r = t.length - 1, o; r >= 0; r--)
2859
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
2860
+ return i && a && ri(e, s, a), a;
2856
2861
  };
2857
2862
  const is = 6;
2858
2863
  let Q = class extends at {
@@ -2863,10 +2868,10 @@ let Q = class extends at {
2863
2868
  const t = this.hold(this.groups ?? []);
2864
2869
  if (t.length === 0)
2865
2870
  return l`<div class=${this.rootClass("baht-donut-chart")}>${this.renderEmpty()}</div>`;
2866
- const e = Qa(t, is, this.otherLabel), a = e.reduce((p, C) => p + C.count, 0) || 1, i = this.total ?? t.reduce((p, C) => p + C.count, 0), s = Q.R, r = 2 * Math.PI * s, o = e.length > 1 ? Q.GAP : 0, c = t.length > is;
2871
+ const e = ti(t, is, this.otherLabel), s = e.reduce((p, C) => p + C.count, 0) || 1, i = this.total ?? t.reduce((p, C) => p + C.count, 0), a = Q.R, r = 2 * Math.PI * a, o = e.length > 1 ? Q.GAP : 0, c = t.length > is;
2867
2872
  let m = 0;
2868
2873
  const $ = e.map((p, C) => {
2869
- const g = p.count / a, b = Math.max(0, g * r - o), w = {
2874
+ const g = p.count / s, b = Math.max(0, g * r - o), w = {
2870
2875
  ...p,
2871
2876
  frac: g,
2872
2877
  dash: `${b} ${r - b}`,
@@ -2880,7 +2885,7 @@ let Q = class extends at {
2880
2885
  <svg width="160" height="160" viewBox="0 0 160 160" role="img" aria-label=${_}>
2881
2886
  <g transform="translate(80,80) rotate(-90)">
2882
2887
  ${$.map(
2883
- (p) => R`<circle r=${s} cx="0" cy="0" fill="none" stroke=${p.color}
2888
+ (p) => R`<circle r=${a} cx="0" cy="0" fill="none" stroke=${p.color}
2884
2889
  stroke-width="22" stroke-dasharray=${p.dash} stroke-dashoffset=${p.offset}/>`
2885
2890
  )}
2886
2891
  </g>
@@ -2929,36 +2934,36 @@ Nt([
2929
2934
  Q = Nt([
2930
2935
  f("baht-donut-chart")
2931
2936
  ], Q);
2932
- var oi = Object.defineProperty, li = Object.getOwnPropertyDescriptor, G = (t, e, a, i) => {
2933
- for (var s = i > 1 ? void 0 : i ? li(e, a) : e, r = t.length - 1, o; r >= 0; r--)
2934
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
2935
- return i && s && oi(e, a, s), s;
2937
+ var li = Object.defineProperty, ni = Object.getOwnPropertyDescriptor, G = (t, e, s, i) => {
2938
+ for (var a = i > 1 ? void 0 : i ? ni(e, s) : e, r = t.length - 1, o; r >= 0; r--)
2939
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
2940
+ return i && a && li(e, s, a), a;
2936
2941
  };
2937
- const rs = 24, os = 2, ni = 56, hi = 26;
2942
+ const rs = 24, os = 2, hi = 56, ci = 26;
2938
2943
  let K = class extends at {
2939
2944
  constructor() {
2940
2945
  super(...arguments), this.groups = [], this.series = [], this.categories = [], this.orientation = "horizontal", this.stacked = !1, this.compare = [], this.compareLabel = "Previous period", this.markers = [], this.labelValues = "ends", this.emphasis = null, this.color = "", this.label = "", this.band = 0;
2941
2946
  }
2942
2947
  connectedCallback() {
2943
- super.connectedCallback(), !(!T() || typeof ResizeObserver > "u") && (this.resizeObserver = new ResizeObserver(() => this.measure()), this.resizeObserver.observe(this));
2948
+ super.connectedCallback(), !(!j() || typeof ResizeObserver > "u") && (this.resizeObserver = new ResizeObserver(() => this.measure()), this.resizeObserver.observe(this));
2944
2949
  }
2945
2950
  disconnectedCallback() {
2946
2951
  var t;
2947
2952
  (t = this.resizeObserver) == null || t.disconnect(), this.resizeObserver = void 0, super.disconnectedCallback();
2948
2953
  }
2949
2954
  firstUpdated() {
2950
- T() && queueMicrotask(() => this.measure());
2955
+ j() && queueMicrotask(() => this.measure());
2951
2956
  }
2952
2957
  /** Host width → px per category. Never runs on the server (`hasDom` guard). */
2953
2958
  measure() {
2954
2959
  var r;
2955
- if (!T() || !this.isConnected || this.orientation !== "vertical") return;
2960
+ if (!j() || !this.isConnected || this.orientation !== "vertical") return;
2956
2961
  const t = this.columnCount;
2957
2962
  if (t === 0) return;
2958
2963
  const e = ((r = this.getBoundingClientRect) == null ? void 0 : r.call(this).width) ?? 0;
2959
2964
  if (!e) return;
2960
- const i = (Math.max(0, e - ni) - os * (t - 1)) / t, s = i > 0 ? Math.floor(i * 100) / 100 : 0;
2961
- Math.abs(s - this.band) > 0.01 && (this.band = s);
2965
+ const i = (Math.max(0, e - hi) - os * (t - 1)) / t, a = i > 0 ? Math.floor(i * 100) / 100 : 0;
2966
+ Math.abs(a - this.band) > 0.01 && (this.band = a);
2962
2967
  }
2963
2968
  get columnCount() {
2964
2969
  const t = this.model.series;
@@ -2971,40 +2976,40 @@ let K = class extends at {
2971
2976
  return { series: this.series, categories: this.categories ?? [], legacy: !1 };
2972
2977
  const t = this.groups ?? [];
2973
2978
  return {
2974
- series: t.length ? [{ name: this.label || "Value", values: t.map((a) => a.count) }] : [],
2975
- categories: t.map((a) => a.label),
2979
+ series: t.length ? [{ name: this.label || "Value", values: t.map((s) => s.count) }] : [],
2980
+ categories: t.map((s) => s.label),
2976
2981
  legacy: !0
2977
2982
  };
2978
2983
  }
2979
- colorFor(t, e, a) {
2984
+ colorFor(t, e, s) {
2980
2985
  const i = this.model.series[t];
2981
- return this.emphasis != null && !(a ? t === this.emphasis : e === this.emphasis) ? "var(--baht-chart-muted)" : ft(a ? t : 0, this.color || (i == null ? void 0 : i.color) || void 0);
2986
+ return this.emphasis != null && !(s ? t === this.emphasis : e === this.emphasis) ? "var(--baht-chart-muted)" : ft(s ? t : 0, this.color || (i == null ? void 0 : i.color) || void 0);
2982
2987
  }
2983
2988
  render() {
2984
2989
  const t = this.hold(this.model);
2985
2990
  return t.series.length === 0 ? l`<div class=${this.rootClass("baht-bar-chart")}>${this.renderEmpty()}</div>` : this.orientation === "vertical" ? this.renderVertical(t) : this.renderHorizontal(t);
2986
2991
  }
2987
2992
  /** Largest value a bar can reach: the raw max for `groups`, a clean tick otherwise. */
2988
- domainMax(t, e, a) {
2989
- const i = Math.max(...t.map((c) => c.values.length)), s = Array.from(
2993
+ domainMax(t, e, s) {
2994
+ const i = Math.max(...t.map((c) => c.values.length)), a = Array.from(
2990
2995
  { length: i },
2991
2996
  (c, m) => e ? t.reduce(($, _) => $ + (_.values[m] ?? 0), 0) : Math.max(...t.map(($) => $.values[m] ?? 0))
2992
2997
  ), r = Math.max(
2993
2998
  1,
2994
- ...s,
2999
+ ...a,
2995
3000
  ...this.compare ?? [],
2996
3001
  ...(this.markers ?? []).map((c) => c.value)
2997
3002
  );
2998
- if (a) return r;
2999
- const o = Te(r, 4);
3003
+ if (s) return r;
3004
+ const o = je(r, 4);
3000
3005
  return o[o.length - 1] ?? r;
3001
3006
  }
3002
- tableTwin(t, e, a) {
3007
+ tableTwin(t, e, s) {
3003
3008
  var r;
3004
3009
  if (!this.showTable) return h;
3005
3010
  const i = ["Category", ...t.map((o) => o.name || "Value")];
3006
3011
  (r = this.compare) != null && r.length && i.push(this.compareLabel);
3007
- const s = Array.from({ length: a }, (o, c) => {
3012
+ const a = Array.from({ length: s }, (o, c) => {
3008
3013
  var $;
3009
3014
  const m = [
3010
3015
  e[c] || "(empty)",
@@ -3013,12 +3018,12 @@ let K = class extends at {
3013
3018
  return ($ = this.compare) != null && $.length && m.push(this.fmt(this.compare[c] ?? 0)), m;
3014
3019
  });
3015
3020
  for (const o of this.markers ?? [])
3016
- s.push([
3021
+ a.push([
3017
3022
  `${o.label ?? "Target"}${o.category ? ` (${o.category})` : ""}`,
3018
3023
  this.fmt(o.value),
3019
3024
  ...Array.from({ length: i.length - 2 }, () => "—")
3020
3025
  ]);
3021
- return me(this.label || "Bar chart data", i, s);
3026
+ return me(this.label || "Bar chart data", i, a);
3022
3027
  }
3023
3028
  /** Markers with no `category` span the chart; the rest ride their own row. */
3024
3029
  markersFor(t) {
@@ -3042,9 +3047,9 @@ let K = class extends at {
3042
3047
  */
3043
3048
  markerOverlay(t, e) {
3044
3049
  return this.markersFor(e).map(
3045
- (a) => l`<span
3050
+ (s) => l`<span
3046
3051
  class="baht-bar-chart-marker"
3047
- style=${`left:${Math.min(100, a.value / t * 100).toFixed(2)}%`}
3052
+ style=${`left:${Math.min(100, s.value / t * 100).toFixed(2)}%`}
3048
3053
  aria-hidden="true"
3049
3054
  ></span>`
3050
3055
  );
@@ -3056,12 +3061,12 @@ let K = class extends at {
3056
3061
  * each other, a row's own markers only with that row's.
3057
3062
  */
3058
3063
  place(t, e) {
3059
- const a = [], i = [...t].sort((s, r) => s.value - r.value);
3060
- for (const s of i) {
3061
- const r = Math.min(100, Math.max(0, s.value / e * 100)), o = a[a.length - 1];
3062
- o && r - o.pct < 12 || a.push({ m: s, pct: r });
3064
+ const s = [], i = [...t].sort((a, r) => a.value - r.value);
3065
+ for (const a of i) {
3066
+ const r = Math.min(100, Math.max(0, a.value / e * 100)), o = s[s.length - 1];
3067
+ o && r - o.pct < 12 || s.push({ m: a, pct: r });
3063
3068
  }
3064
- return a;
3069
+ return s;
3065
3070
  }
3066
3071
  /** Chart-wide marker labels — the strip above the rows / the end of the line. */
3067
3072
  placedMarkers(t) {
@@ -3070,26 +3075,26 @@ let K = class extends at {
3070
3075
  /** A row's own marker labels, drawn beside their line inside that row. */
3071
3076
  rowMarkerLabels(t, e) {
3072
3077
  return this.place(this.categoryMarkers(t), e).map(
3073
- ({ m: a, pct: i }) => l`<span
3078
+ ({ m: s, pct: i }) => l`<span
3074
3079
  class="baht-bar-chart-marker-label baht-bar-chart-marker-label--row"
3075
3080
  style=${`left:${i.toFixed(2)}%;transform:translateX(${i > 70 ? "calc(-100% - 4px)" : "4px"})`}
3076
- >${this.markerText(a)}</span
3081
+ >${this.markerText(s)}</span
3077
3082
  >`
3078
3083
  );
3079
3084
  }
3080
3085
  /** Legend rows: one per series, plus the muted `compare` key when it is set. */
3081
3086
  legendEntries(t) {
3082
- const e = t.map((a, i) => ({
3083
- label: a.name || "Value",
3084
- color: ft(i, a.color)
3087
+ const e = t.map((s, i) => ({
3088
+ label: s.name || "Value",
3089
+ color: ft(i, s.color)
3085
3090
  }));
3086
3091
  return (this.compare ?? []).length > 0 && e.push({ label: this.compareLabel, color: "var(--baht-chart-muted)" }), e;
3087
3092
  }
3088
3093
  renderHorizontal(t) {
3089
- const { series: e, categories: a, legacy: i } = t, s = e.length > 1, r = Math.max(...e.map((C) => C.values.length)), o = this.domainMax(e, this.stacked, i), c = (this.compare ?? []).length > 0, m = (this.stacked ? 1 : e.length) + (c ? 1 : 0), $ = Math.min(rs, Math.max(6, Math.floor(48 / m))), _ = Array.from({ length: r }, (C, g) => {
3090
- const b = a[g] || "(empty)", w = e.reduce((D, E) => D + (E.values[g] ?? 0), 0), P = `${b}: ${e.map((D) => `${D.name ? `${D.name} ` : ""}${this.fmt(D.values[g] ?? 0)}`).join(", ")}${c ? `, previous ${this.fmt(this.compare[g] ?? 0)}` : ""}`, H = e.map((D, E) => ({
3094
+ const { series: e, categories: s, legacy: i } = t, a = e.length > 1, r = Math.max(...e.map((C) => C.values.length)), o = this.domainMax(e, this.stacked, i), c = (this.compare ?? []).length > 0, m = (this.stacked ? 1 : e.length) + (c ? 1 : 0), $ = Math.min(rs, Math.max(6, Math.floor(48 / m))), _ = Array.from({ length: r }, (C, g) => {
3095
+ const b = s[g] || "(empty)", w = e.reduce((D, E) => D + (E.values[g] ?? 0), 0), P = `${b}: ${e.map((D) => `${D.name ? `${D.name} ` : ""}${this.fmt(D.values[g] ?? 0)}`).join(", ")}${c ? `, previous ${this.fmt(this.compare[g] ?? 0)}` : ""}`, H = e.map((D, E) => ({
3091
3096
  value: D.values[g] ?? 0,
3092
- color: this.colorFor(E, g, s),
3097
+ color: this.colorFor(E, g, a),
3093
3098
  name: D.name
3094
3099
  }));
3095
3100
  return l`<div class="baht-bar-chart-row">
@@ -3148,13 +3153,13 @@ let K = class extends at {
3148
3153
  ${_}
3149
3154
  ${this.renderTooltip()}
3150
3155
  ${this.renderLegend(this.legendEntries(e))}
3151
- ${this.tableTwin(e, a, r)}
3156
+ ${this.tableTwin(e, s, r)}
3152
3157
  </div>`;
3153
3158
  }
3154
3159
  renderVertical(t) {
3155
- const { series: e, categories: a, legacy: i } = t, s = e.length > 1, r = Math.max(...e.map((w) => w.values.length)), o = this.domainMax(e, this.stacked, i), c = Te(o, 4), m = (this.compare ?? []).length > 0, $ = (this.stacked ? 1 : e.length) + (m ? 1 : 0), _ = this.band > 0 ? (this.band - os) / $ : 48 / $, p = Math.min(rs, Math.max(2, Math.floor(_))), C = this.band > 0 ? Math.max(1, Math.ceil(hi / Math.max(1, this.band))) : Math.max(1, Math.ceil(r / 12)), g = (this.markers ?? []).map(
3160
+ const { series: e, categories: s, legacy: i } = t, a = e.length > 1, r = Math.max(...e.map((w) => w.values.length)), o = this.domainMax(e, this.stacked, i), c = je(o, 4), m = (this.compare ?? []).length > 0, $ = (this.stacked ? 1 : e.length) + (m ? 1 : 0), _ = this.band > 0 ? (this.band - os) / $ : 48 / $, p = Math.min(rs, Math.max(2, Math.floor(_))), C = this.band > 0 ? Math.max(1, Math.ceil(ci / Math.max(1, this.band))) : Math.max(1, Math.ceil(r / 12)), g = (this.markers ?? []).map(
3156
3161
  (w) => `${this.markerText(w)}${w.category ? ` on ${w.category}` : ""}`
3157
- ), b = this.label || `Column chart, ${r} categories. ${a.map((w, P) => `${w} ${this.fmt(e[0].values[P] ?? 0)}`).join(", ")}${g.length ? `. Reference lines: ${g.join(", ")}` : ""}`;
3162
+ ), b = this.label || `Column chart, ${r} categories. ${s.map((w, P) => `${w} ${this.fmt(e[0].values[P] ?? 0)}`).join(", ")}${g.length ? `. Reference lines: ${g.join(", ")}` : ""}`;
3158
3163
  return l`<div class=${this.rootClass("baht-bar-chart baht-bar-chart--vertical")}>
3159
3164
  <div class="baht-bar-chart-plot" role="img" aria-label=${b}>
3160
3165
  <div class="baht-bar-chart-yaxis" aria-hidden="true">
@@ -3178,7 +3183,7 @@ let K = class extends at {
3178
3183
  ${[...c].reverse().map(() => l`<span class="baht-chart-grid-rule" aria-hidden="true"></span>`)}
3179
3184
  <div class="baht-bar-chart-columns">
3180
3185
  ${Array.from({ length: r }, (w, P) => {
3181
- const H = a[P] || "(empty)", D = `${H}: ${e.map((E) => `${E.name ? `${E.name} ` : ""}${this.fmt(E.values[P] ?? 0)}`).join(", ")}`;
3186
+ const H = s[P] || "(empty)", D = `${H}: ${e.map((E) => `${E.name ? `${E.name} ` : ""}${this.fmt(E.values[P] ?? 0)}`).join(", ")}`;
3182
3187
  return l`<div
3183
3188
  class="baht-bar-chart-column"
3184
3189
  style=${this.band > 0 ? `flex:0 0 auto;width:${this.band}px` : h}
@@ -3205,7 +3210,7 @@ let K = class extends at {
3205
3210
  ${e.map(
3206
3211
  (E, d) => l`<div
3207
3212
  class="baht-bar-chart-col"
3208
- style=${`height:${Math.max(1, (E.values[P] ?? 0) / o * 100)}%;width:${p}px;background:${this.colorFor(d, P, s)}`}
3213
+ style=${`height:${Math.max(1, (E.values[P] ?? 0) / o * 100)}%;width:${p}px;background:${this.colorFor(d, P, a)}`}
3209
3214
  ></div>`
3210
3215
  )}
3211
3216
  ${m ? l`<div
@@ -3221,7 +3226,7 @@ let K = class extends at {
3221
3226
  </div>
3222
3227
  ${this.renderTooltip()}
3223
3228
  ${this.renderLegend(this.legendEntries(e))}
3224
- ${this.tableTwin(e, a, r)}
3229
+ ${this.tableTwin(e, s, r)}
3225
3230
  </div>`;
3226
3231
  }
3227
3232
  };
@@ -3267,10 +3272,10 @@ G([
3267
3272
  K = G([
3268
3273
  f("baht-bar-chart")
3269
3274
  ], K);
3270
- var ci = Object.defineProperty, pi = Object.getOwnPropertyDescriptor, nt = (t, e, a, i) => {
3271
- for (var s = i > 1 ? void 0 : i ? pi(e, a) : e, r = t.length - 1, o; r >= 0; r--)
3272
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
3273
- return i && s && ci(e, a, s), s;
3275
+ var pi = Object.defineProperty, di = Object.getOwnPropertyDescriptor, nt = (t, e, s, i) => {
3276
+ for (var a = i > 1 ? void 0 : i ? di(e, s) : e, r = t.length - 1, o; r >= 0; r--)
3277
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
3278
+ return i && a && pi(e, s, a), a;
3274
3279
  };
3275
3280
  const ls = 640, Oe = 260, M = { top: 14, right: 72, bottom: 30, left: 60 };
3276
3281
  let st = class extends at {
@@ -3287,10 +3292,10 @@ let st = class extends at {
3287
3292
  return d && ((k = d.values) == null ? void 0 : k.length);
3288
3293
  }),
3289
3294
  categories: this.categories ?? []
3290
- }), { series: e, categories: a } = t;
3295
+ }), { series: e, categories: s } = t;
3291
3296
  if (e.length === 0)
3292
3297
  return l`<div class=${this.rootClass("baht-line-chart")}>${this.renderEmpty()}</div>`;
3293
- const i = Math.max(...e.map((d) => d.values.length)), s = e.flatMap((d) => d.values).filter((d) => Number.isFinite(d)), r = Math.max(0, ...s, ...(this.markers ?? []).map((d) => d.value)), o = Te(r, 4), c = o[o.length - 1] ?? 1, { w: m, h: $ } = this.plot, _ = he([0, Math.max(1, i - 1)], [M.left, M.left + m]), p = he([0, c], [M.top + $, M.top]), C = Math.max(0, i - 1 - Math.max(0, this.forecast)), g = (d, k, et) => d.slice(k, et + 1).map((it, rt) => `${rt === 0 ? "M" : "L"}${_(k + rt).toFixed(2)},${p(it).toFixed(2)}`).join(" "), b = e.map((d, k) => ({
3298
+ const i = Math.max(...e.map((d) => d.values.length)), a = e.flatMap((d) => d.values).filter((d) => Number.isFinite(d)), r = Math.max(0, ...a, ...(this.markers ?? []).map((d) => d.value)), o = je(r, 4), c = o[o.length - 1] ?? 1, { w: m, h: $ } = this.plot, _ = he([0, Math.max(1, i - 1)], [M.left, M.left + m]), p = he([0, c], [M.top + $, M.top]), C = Math.max(0, i - 1 - Math.max(0, this.forecast)), g = (d, k, et) => d.slice(k, et + 1).map((it, rt) => `${rt === 0 ? "M" : "L"}${_(k + rt).toFixed(2)},${p(it).toFixed(2)}`).join(" "), b = e.map((d, k) => ({
3294
3299
  i: k,
3295
3300
  name: d.name,
3296
3301
  value: d.values[d.values.length - 1] ?? 0,
@@ -3342,11 +3347,11 @@ let st = class extends at {
3342
3347
  <text class="baht-chart-end-label" x=${_(i - 1) + 10} y=${(d.yPos + 4).toFixed(2)}
3343
3348
  text-anchor="start">${this.fmt(d.value)}</text>`
3344
3349
  ) : h}
3345
- ${a.map(
3350
+ ${s.map(
3346
3351
  (d, k) => k % D === 0 ? R`<text class="baht-chart-tick" x=${_(k).toFixed(2)} y=${Oe - 10} text-anchor="middle">${d}</text>` : h
3347
3352
  )}
3348
3353
  ${Array.from({ length: i }, (d, k) => {
3349
- const et = m / Math.max(1, i - 1), it = `${a[k] ?? `Point ${k + 1}`}: ${e.map((rt) => `${rt.name} ${this.fmt(rt.values[k] ?? 0)}`).join(", ")}`;
3354
+ const et = m / Math.max(1, i - 1), it = `${s[k] ?? `Point ${k + 1}`}: ${e.map((rt) => `${rt.name} ${this.fmt(rt.values[k] ?? 0)}`).join(", ")}`;
3350
3355
  return R`<rect class="baht-chart-hit" x=${(_(k) - et / 2).toFixed(2)} y=${M.top}
3351
3356
  width=${Math.max(24, et).toFixed(2)} height=${$} tabindex="0" role="button"
3352
3357
  aria-label=${it}
@@ -3367,14 +3372,14 @@ let st = class extends at {
3367
3372
  this.label || "Line chart data",
3368
3373
  ["Point", ...e.map((d) => d.name)],
3369
3374
  Array.from({ length: i }, (d, k) => [
3370
- a[k] ?? `Point ${k + 1}`,
3375
+ s[k] ?? `Point ${k + 1}`,
3371
3376
  ...e.map((et) => this.fmt(et.values[k] ?? 0))
3372
3377
  ])
3373
3378
  ) : h}
3374
3379
  </div>`;
3375
3380
  }
3376
- onHover(t, e, a) {
3377
- this.crosshairAt = e, this.requestUpdate(), this.showTip(t, a);
3381
+ onHover(t, e, s) {
3382
+ this.crosshairAt = e, this.requestUpdate(), this.showTip(t, s);
3378
3383
  }
3379
3384
  onLeave() {
3380
3385
  this.crosshairAt = null, this.requestUpdate(), this.hideTip();
@@ -3407,12 +3412,12 @@ nt([
3407
3412
  st = nt([
3408
3413
  f("baht-line-chart")
3409
3414
  ], st);
3410
- var di = Object.defineProperty, ui = Object.getOwnPropertyDescriptor, xt = (t, e, a, i) => {
3411
- for (var s = i > 1 ? void 0 : i ? ui(e, a) : e, r = t.length - 1, o; r >= 0; r--)
3412
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
3413
- return i && s && di(e, a, s), s;
3415
+ var ui = Object.defineProperty, bi = Object.getOwnPropertyDescriptor, xt = (t, e, s, i) => {
3416
+ for (var a = i > 1 ? void 0 : i ? bi(e, s) : e, r = t.length - 1, o; r >= 0; r--)
3417
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
3418
+ return i && a && ui(e, s, a), a;
3414
3419
  };
3415
- const Pe = 22, Rt = 24, ns = 34, Ce = 18, bi = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
3420
+ const Pe = 22, Rt = 24, ns = 34, Ce = 18, fi = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
3416
3421
  function De(t) {
3417
3422
  const e = /^(\d{4})-(\d{2})-(\d{2})/.exec(t ?? "");
3418
3423
  return e ? new Date(Date.UTC(+e[1], +e[2] - 1, +e[3])) : null;
@@ -3425,18 +3430,18 @@ let pt = class extends at {
3425
3430
  super(...arguments), this.values = [], this.from = "", this.to = "", this.lessLabel = "Less", this.moreLabel = "More", this.label = "";
3426
3431
  }
3427
3432
  get range() {
3428
- const t = (this.values ?? []).map((i) => De(i.date)).filter((i) => !!i), e = De(this.from) ?? (t.length ? new Date(Math.min(...t.map((i) => +i))) : null), a = De(this.to) ?? (t.length ? new Date(Math.max(...t.map((i) => +i))) : null);
3429
- return !e || !a || +a < +e ? null : { start: e, end: a };
3433
+ const t = (this.values ?? []).map((i) => De(i.date)).filter((i) => !!i), e = De(this.from) ?? (t.length ? new Date(Math.min(...t.map((i) => +i))) : null), s = De(this.to) ?? (t.length ? new Date(Math.max(...t.map((i) => +i))) : null);
3434
+ return !e || !s || +s < +e ? null : { start: e, end: s };
3430
3435
  }
3431
3436
  render() {
3432
3437
  const t = this.hold({ values: this.values ?? [], range: this.range }), e = t.range;
3433
3438
  if (!e || t.values.length === 0)
3434
3439
  return l`<div class=${this.rootClass("baht-heatmap")}>${this.renderEmpty()}</div>`;
3435
- const a = new Map(t.values.map((b) => [b.date.slice(0, 10), b.value])), i = [], s = new Date(e.start), r = (e.start.getUTCDay() + 6) % 7;
3440
+ const s = new Map(t.values.map((b) => [b.date.slice(0, 10), b.value])), i = [], a = new Date(e.start), r = (e.start.getUTCDay() + 6) % 7;
3436
3441
  let o = 0;
3437
- for (; +s <= +e.end; ) {
3438
- const b = Se(s), w = (s.getUTCDay() + 6) % 7, P = Math.floor((r + o) / 7);
3439
- i.push({ iso: b, value: a.has(b) ? a.get(b) : null, col: P, row: w }), s.setUTCDate(s.getUTCDate() + 1), o += 1;
3442
+ for (; +a <= +e.end; ) {
3443
+ const b = Se(a), w = (a.getUTCDay() + 6) % 7, P = Math.floor((r + o) / 7);
3444
+ i.push({ iso: b, value: s.has(b) ? s.get(b) : null, col: P, row: w }), a.setUTCDate(a.getUTCDate() + 1), o += 1;
3440
3445
  }
3441
3446
  const c = Math.max(1, ...i.map((b) => b.col + 1)), m = ns + c * Rt, $ = Ce + 7 * Rt + 4, _ = Math.max(1, ...i.map((b) => b.value ?? 0)), p = (b) => Math.min(4, Math.max(0, Math.ceil(b / _ * 5) - 1)), C = i.reduce((b, w) => b + (w.value ?? 0), 0), g = this.label || `Calendar heatmap, ${i.length} days from ${Se(e.start)} to ${Se(e.end)}, total ${this.fmt(C)}`;
3442
3447
  return l`<div class=${this.rootClass("baht-heatmap")}>
@@ -3449,7 +3454,7 @@ let pt = class extends at {
3449
3454
  role="img"
3450
3455
  aria-label=${g}
3451
3456
  >
3452
- ${bi.map(
3457
+ ${fi.map(
3453
3458
  (b, w) => w % 2 === 0 ? R`<text class="baht-chart-tick" x="0" y=${Ce + w * Rt + Pe / 2 + 4}>${b}</text>` : h
3454
3459
  )}
3455
3460
  ${i.map((b) => {
@@ -3503,10 +3508,10 @@ xt([
3503
3508
  pt = xt([
3504
3509
  f("baht-heatmap")
3505
3510
  ], pt);
3506
- var fi = Object.defineProperty, mi = Object.getOwnPropertyDescriptor, tt = (t, e, a, i) => {
3507
- for (var s = i > 1 ? void 0 : i ? mi(e, a) : e, r = t.length - 1, o; r >= 0; r--)
3508
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
3509
- return i && s && fi(e, a, s), s;
3511
+ var mi = Object.defineProperty, vi = Object.getOwnPropertyDescriptor, tt = (t, e, s, i) => {
3512
+ for (var a = i > 1 ? void 0 : i ? vi(e, s) : e, r = t.length - 1, o; r >= 0; r--)
3513
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
3514
+ return i && a && mi(e, s, a), a;
3510
3515
  };
3511
3516
  let J = class extends y {
3512
3517
  constructor() {
@@ -3523,8 +3528,8 @@ let J = class extends y {
3523
3528
  * `warning` stays inclusive (`>=`).
3524
3529
  */
3525
3530
  get severity() {
3526
- const { warning: t, danger: e } = this.thresholds ?? { warning: 0.8, danger: 1 }, a = this.fraction;
3527
- return a > e ? "danger" : a >= t ? "warning" : "ok";
3531
+ const { warning: t, danger: e } = this.thresholds ?? { warning: 0.8, danger: 1 }, s = this.fraction;
3532
+ return s > e ? "danger" : s >= t ? "warning" : "ok";
3528
3533
  }
3529
3534
  get statusText() {
3530
3535
  const { danger: t } = this.thresholds ?? { danger: 1 }, e = this.severity;
@@ -3532,11 +3537,11 @@ let J = class extends y {
3532
3537
  }
3533
3538
  render() {
3534
3539
  var c;
3535
- const t = this.severity, e = Math.min(100, this.fraction * 100), a = (m) => zt(m, this.format, this.currency), i = this.expected != null && Number.isFinite(this.expected) && this.max ? Math.min(100, Math.max(0, this.expected / this.max * 100)) : null, s = `${a(this.value)} of ${a(this.max)}`, r = t === "warning" && this.fraction >= (((c = this.thresholds) == null ? void 0 : c.danger) ?? 1), o = t === "danger" ? "!" : r ? "=" : t === "warning" ? "△" : "";
3540
+ const t = this.severity, e = Math.min(100, this.fraction * 100), s = (m) => zt(m, this.format, this.currency), i = this.expected != null && Number.isFinite(this.expected) && this.max ? Math.min(100, Math.max(0, this.expected / this.max * 100)) : null, a = `${s(this.value)} of ${s(this.max)}`, r = t === "warning" && this.fraction >= (((c = this.thresholds) == null ? void 0 : c.danger) ?? 1), o = t === "danger" ? "!" : r ? "=" : t === "warning" ? "△" : "";
3536
3541
  return l`<div class="baht-meter baht-meter--${t}">
3537
3542
  <div class="baht-meter-head">
3538
3543
  ${this.label ? l`<span class="baht-meter-label">${this.label}</span>` : h}
3539
- <span class="baht-meter-value">${s}</span>
3544
+ <span class="baht-meter-value">${a}</span>
3540
3545
  ${this.statusText ? l`<span class="baht-meter-status"
3541
3546
  ><span class="baht-meter-icon" aria-hidden="true">${o}</span
3542
3547
  >${this.statusText}</span
@@ -3549,7 +3554,7 @@ let J = class extends y {
3549
3554
  aria-valuemin="0"
3550
3555
  aria-valuemax=${this.max}
3551
3556
  aria-valuenow=${this.value}
3552
- aria-valuetext=${`${s}${this.statusText ? `, ${this.statusText}` : ""}`}
3557
+ aria-valuetext=${`${a}${this.statusText ? `, ${this.statusText}` : ""}`}
3553
3558
  >
3554
3559
  <div class="baht-meter-fill" style=${`width:${e.toFixed(2)}%`}></div>
3555
3560
  ${i != null ? l`<span
@@ -3558,7 +3563,7 @@ let J = class extends y {
3558
3563
  aria-hidden="true"
3559
3564
  ></span>` : h}
3560
3565
  </div>
3561
- ${i != null ? l`<div class="baht-meter-pace">Expected by now ${a(this.expected)}</div>` : h}
3566
+ ${i != null ? l`<div class="baht-meter-pace">Expected by now ${s(this.expected)}</div>` : h}
3562
3567
  </div>`;
3563
3568
  }
3564
3569
  };
@@ -3595,12 +3600,12 @@ tt([
3595
3600
  J = tt([
3596
3601
  f("baht-meter")
3597
3602
  ], J);
3598
- var vi = Object.defineProperty, $i = Object.getOwnPropertyDescriptor, ve = (t, e, a, i) => {
3599
- for (var s = i > 1 ? void 0 : i ? $i(e, a) : e, r = t.length - 1, o; r >= 0; r--)
3600
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
3601
- return i && s && vi(e, a, s), s;
3603
+ var $i = Object.defineProperty, yi = Object.getOwnPropertyDescriptor, ve = (t, e, s, i) => {
3604
+ for (var a = i > 1 ? void 0 : i ? yi(e, s) : e, r = t.length - 1, o; r >= 0; r--)
3605
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
3606
+ return i && a && $i(e, s, a), a;
3602
3607
  };
3603
- let Gt = class extends y {
3608
+ let Ht = class extends y {
3604
3609
  constructor() {
3605
3610
  super(...arguments), this.icon = "empty-box", this.message = "Nothing to display", this.hint = "";
3606
3611
  }
@@ -3614,22 +3619,22 @@ let Gt = class extends y {
3614
3619
  };
3615
3620
  ve([
3616
3621
  n()
3617
- ], Gt.prototype, "icon", 2);
3622
+ ], Ht.prototype, "icon", 2);
3618
3623
  ve([
3619
3624
  n()
3620
- ], Gt.prototype, "message", 2);
3625
+ ], Ht.prototype, "message", 2);
3621
3626
  ve([
3622
3627
  n()
3623
- ], Gt.prototype, "hint", 2);
3624
- Gt = ve([
3628
+ ], Ht.prototype, "hint", 2);
3629
+ Ht = ve([
3625
3630
  f("baht-empty-state")
3626
- ], Gt);
3627
- var yi = Object.defineProperty, gi = Object.getOwnPropertyDescriptor, ee = (t, e, a, i) => {
3628
- for (var s = i > 1 ? void 0 : i ? gi(e, a) : e, r = t.length - 1, o; r >= 0; r--)
3629
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
3630
- return i && s && yi(e, a, s), s;
3631
+ ], Ht);
3632
+ var gi = Object.defineProperty, wi = Object.getOwnPropertyDescriptor, te = (t, e, s, i) => {
3633
+ for (var a = i > 1 ? void 0 : i ? wi(e, s) : e, r = t.length - 1, o; r >= 0; r--)
3634
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
3635
+ return i && a && gi(e, s, a), a;
3631
3636
  };
3632
- let Bt = class extends y {
3637
+ let It = class extends y {
3633
3638
  constructor() {
3634
3639
  super(...arguments), this.icon = "error", this.heading = "Something went wrong", this.message = "", this.retryLabel = "";
3635
3640
  }
@@ -3645,25 +3650,25 @@ let Bt = class extends y {
3645
3650
  </div>`;
3646
3651
  }
3647
3652
  };
3648
- ee([
3653
+ te([
3649
3654
  n()
3650
- ], Bt.prototype, "icon", 2);
3651
- ee([
3655
+ ], It.prototype, "icon", 2);
3656
+ te([
3652
3657
  n()
3653
- ], Bt.prototype, "heading", 2);
3654
- ee([
3658
+ ], It.prototype, "heading", 2);
3659
+ te([
3655
3660
  n()
3656
- ], Bt.prototype, "message", 2);
3657
- ee([
3661
+ ], It.prototype, "message", 2);
3662
+ te([
3658
3663
  n({ attribute: "retry-label" })
3659
- ], Bt.prototype, "retryLabel", 2);
3660
- Bt = ee([
3664
+ ], It.prototype, "retryLabel", 2);
3665
+ It = te([
3661
3666
  f("baht-error-state")
3662
- ], Bt);
3663
- var wi = Object.defineProperty, xi = Object.getOwnPropertyDescriptor, _t = (t, e, a, i) => {
3664
- for (var s = i > 1 ? void 0 : i ? xi(e, a) : e, r = t.length - 1, o; r >= 0; r--)
3665
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
3666
- return i && s && wi(e, a, s), s;
3667
+ ], It);
3668
+ var xi = Object.defineProperty, _i = Object.getOwnPropertyDescriptor, _t = (t, e, s, i) => {
3669
+ for (var a = i > 1 ? void 0 : i ? _i(e, s) : e, r = t.length - 1, o; r >= 0; r--)
3670
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
3671
+ return i && a && xi(e, s, a), a;
3667
3672
  };
3668
3673
  let dt = class extends y {
3669
3674
  constructor() {
@@ -3675,8 +3680,8 @@ let dt = class extends y {
3675
3680
  e !== this.syncedJson && (this.syncedJson = e, this.rows = this.toRows(this.value));
3676
3681
  }
3677
3682
  toRows(t) {
3678
- const e = Object.entries(t ?? {}).map(([a, i]) => ({
3679
- k: a,
3683
+ const e = Object.entries(t ?? {}).map(([s, i]) => ({
3684
+ k: s,
3680
3685
  v: typeof i == "string" ? i : JSON.stringify(i)
3681
3686
  }));
3682
3687
  return e.length > 0 ? e : [{ k: "", v: "" }];
@@ -3684,11 +3689,11 @@ let dt = class extends y {
3684
3689
  commit(t) {
3685
3690
  this.rows = t.length > 0 ? t : [{ k: "", v: "" }];
3686
3691
  const e = {};
3687
- for (const a of t) a.k.trim() && (e[a.k.trim()] = a.v);
3692
+ for (const s of t) s.k.trim() && (e[s.k.trim()] = s.v);
3688
3693
  this.syncedJson = JSON.stringify(e), this.emit("baht-change", { value: e });
3689
3694
  }
3690
3695
  edit(t, e) {
3691
- this.commit(this.rows.map((a, i) => i === t ? { ...a, ...e } : a));
3696
+ this.commit(this.rows.map((s, i) => i === t ? { ...s, ...e } : s));
3692
3697
  }
3693
3698
  addRow() {
3694
3699
  this.rows = [...this.rows, { k: "", v: "" }];
@@ -3703,7 +3708,7 @@ let dt = class extends y {
3703
3708
  aria-label="${this.keyPlaceholder} ${e + 1}"
3704
3709
  .value=${t.k}
3705
3710
  ?disabled=${this.disabled}
3706
- @input=${(a) => this.edit(e, { k: a.target.value })}
3711
+ @input=${(s) => this.edit(e, { k: s.target.value })}
3707
3712
  />
3708
3713
  <span class="baht-keyvalue-eq" aria-hidden="true">=</span>
3709
3714
  <input
@@ -3712,15 +3717,15 @@ let dt = class extends y {
3712
3717
  aria-label="${this.valuePlaceholder} ${e + 1}"
3713
3718
  .value=${t.v}
3714
3719
  ?disabled=${this.disabled}
3715
- @input=${(a) => this.edit(e, { v: a.target.value })}
3720
+ @input=${(s) => this.edit(e, { v: s.target.value })}
3716
3721
  />
3717
3722
  <button
3718
3723
  type="button"
3719
3724
  class="baht-keyvalue-remove"
3720
3725
  aria-label="Remove row ${e + 1}"
3721
3726
  ?disabled=${this.disabled}
3722
- @click=${() => this.commit(this.rows.filter((a, i) => i !== e))}
3723
- >${j("close")}</button>
3727
+ @click=${() => this.commit(this.rows.filter((s, i) => i !== e))}
3728
+ >${T("close")}</button>
3724
3729
  </div>`
3725
3730
  )}
3726
3731
  <button
@@ -3728,7 +3733,7 @@ let dt = class extends y {
3728
3733
  class="baht-keyvalue-add"
3729
3734
  ?disabled=${this.disabled}
3730
3735
  @click=${this.addRow}
3731
- >${j("plus")}${this.add_label}</button>
3736
+ >${T("plus")}${this.add_label}</button>
3732
3737
  </div>`;
3733
3738
  }
3734
3739
  };
@@ -3753,10 +3758,10 @@ _t([
3753
3758
  dt = _t([
3754
3759
  f("baht-keyvalue-editor")
3755
3760
  ], dt);
3756
- var _i = Object.defineProperty, ki = Object.getOwnPropertyDescriptor, q = (t, e, a, i) => {
3757
- for (var s = i > 1 ? void 0 : i ? ki(e, a) : e, r = t.length - 1, o; r >= 0; r--)
3758
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
3759
- return i && s && _i(e, a, s), s;
3761
+ var ki = Object.defineProperty, Oi = Object.getOwnPropertyDescriptor, q = (t, e, s, i) => {
3762
+ for (var a = i > 1 ? void 0 : i ? Oi(e, s) : e, r = t.length - 1, o; r >= 0; r--)
3763
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
3764
+ return i && a && ki(e, s, a), a;
3760
3765
  };
3761
3766
  let A = class extends y {
3762
3767
  constructor() {
@@ -3768,16 +3773,16 @@ let A = class extends y {
3768
3773
  return `baht-refpicker-list-${this.uid}`;
3769
3774
  }
3770
3775
  disconnectedCallback() {
3771
- super.disconnectedCallback(), clearTimeout(this.timer), T() && document.removeEventListener("mousedown", this.onDocMousedown);
3776
+ super.disconnectedCallback(), clearTimeout(this.timer), j() && document.removeEventListener("mousedown", this.onDocMousedown);
3772
3777
  }
3773
3778
  openLookup() {
3774
- this.disabled || this.open || (this.open = !0, this.term = "", this.activeIndex = -1, T() && document.addEventListener("mousedown", this.onDocMousedown), this.search(""), this.updateComplete.then(() => {
3779
+ this.disabled || this.open || (this.open = !0, this.term = "", this.activeIndex = -1, j() && document.addEventListener("mousedown", this.onDocMousedown), this.search(""), this.updateComplete.then(() => {
3775
3780
  var t;
3776
3781
  return (t = this.inputEl) == null ? void 0 : t.focus();
3777
3782
  }));
3778
3783
  }
3779
3784
  close() {
3780
- this.open && (this.open = !1, this.loading = !1, clearTimeout(this.timer), T() && document.removeEventListener("mousedown", this.onDocMousedown));
3785
+ this.open && (this.open = !1, this.loading = !1, clearTimeout(this.timer), j() && document.removeEventListener("mousedown", this.onDocMousedown));
3781
3786
  }
3782
3787
  search(t) {
3783
3788
  clearTimeout(this.timer), this.timer = setTimeout(async () => {
@@ -3785,8 +3790,8 @@ let A = class extends y {
3785
3790
  const e = ++this.fetchSeq;
3786
3791
  this.loading = !0;
3787
3792
  try {
3788
- const a = await this.fetcher(t);
3789
- e === this.fetchSeq && (this.options = a);
3793
+ const s = await this.fetcher(t);
3794
+ e === this.fetchSeq && (this.options = s);
3790
3795
  } catch {
3791
3796
  e === this.fetchSeq && (this.options = []);
3792
3797
  } finally {
@@ -3810,8 +3815,8 @@ let A = class extends y {
3810
3815
  if (this.open)
3811
3816
  if (t.key === "ArrowDown" || t.key === "ArrowUp") {
3812
3817
  t.preventDefault();
3813
- const e = t.key === "ArrowDown" ? 1 : -1, a = this.options.length;
3814
- a > 0 && (this.activeIndex = (this.activeIndex + e + a) % a);
3818
+ const e = t.key === "ArrowDown" ? 1 : -1, s = this.options.length;
3819
+ s > 0 && (this.activeIndex = (this.activeIndex + e + s) % s);
3815
3820
  } else if (t.key === "Enter") {
3816
3821
  t.preventDefault();
3817
3822
  const e = this.options[this.activeIndex];
@@ -3846,7 +3851,7 @@ let A = class extends y {
3846
3851
  aria-label="Clear"
3847
3852
  @mousedown=${(e) => e.preventDefault()}
3848
3853
  @click=${() => this.clear()}
3849
- >${j("close")}</button>` : h}
3854
+ >${T("close")}</button>` : h}
3850
3855
  </div>
3851
3856
  <button
3852
3857
  type="button"
@@ -3855,13 +3860,13 @@ let A = class extends y {
3855
3860
  title=${this.lookupLabel}
3856
3861
  ?disabled=${this.disabled}
3857
3862
  @click=${() => this.open ? this.close() : this.openLookup()}
3858
- >${j("search")}</button>
3863
+ >${T("search")}</button>
3859
3864
  ${this.value && this.href ? l`<a
3860
3865
  class="baht-refpicker-open"
3861
3866
  href=${this.href}
3862
3867
  aria-label="Open record"
3863
3868
  title="Open record"
3864
- >${j("external")}</a>` : h}
3869
+ >${T("external")}</a>` : h}
3865
3870
  <div
3866
3871
  class="baht-refpicker-list"
3867
3872
  id=${this.listboxId}
@@ -3871,10 +3876,10 @@ let A = class extends y {
3871
3876
  ?hidden=${!this.open}
3872
3877
  >
3873
3878
  ${this.loading ? l`<div class="baht-refpicker-note" role="option" aria-disabled="true" aria-selected="false">Searching…</div>` : this.options.length === 0 ? l`<div class="baht-refpicker-note" role="option" aria-disabled="true" aria-selected="false">No matches</div>` : this.options.map(
3874
- (e, a) => l`<button
3879
+ (e, s) => l`<button
3875
3880
  type="button"
3876
- class="baht-refpicker-option${a === this.activeIndex ? " baht-refpicker-option--active" : ""}"
3877
- id="${this.listboxId}-${a}"
3881
+ class="baht-refpicker-option${s === this.activeIndex ? " baht-refpicker-option--active" : ""}"
3882
+ id="${this.listboxId}-${s}"
3878
3883
  role="option"
3879
3884
  aria-selected=${e.key === this.value ? "true" : "false"}
3880
3885
  @mousedown=${(i) => i.preventDefault()}
@@ -3934,15 +3939,15 @@ q([
3934
3939
  v()
3935
3940
  ], A.prototype, "activeIndex", 2);
3936
3941
  q([
3937
- It("input")
3942
+ Bt("input")
3938
3943
  ], A.prototype, "inputEl", 2);
3939
3944
  A = q([
3940
3945
  f("baht-reference-picker")
3941
3946
  ], A);
3942
- var Oi = Object.defineProperty, Pi = Object.getOwnPropertyDescriptor, I = (t, e, a, i) => {
3943
- for (var s = i > 1 ? void 0 : i ? Pi(e, a) : e, r = t.length - 1, o; r >= 0; r--)
3944
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
3945
- return i && s && Oi(e, a, s), s;
3947
+ var Pi = Object.defineProperty, Ci = Object.getOwnPropertyDescriptor, B = (t, e, s, i) => {
3948
+ for (var a = i > 1 ? void 0 : i ? Ci(e, s) : e, r = t.length - 1, o; r >= 0; r--)
3949
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
3950
+ return i && a && Pi(e, s, a), a;
3946
3951
  };
3947
3952
  let F = class extends y {
3948
3953
  constructor() {
@@ -3960,7 +3965,7 @@ let F = class extends y {
3960
3965
  return `${this.listboxId}-${t}`;
3961
3966
  }
3962
3967
  disconnectedCallback() {
3963
- super.disconnectedCallback(), clearTimeout(this.timer), T() && document.removeEventListener("mousedown", this.onDocMousedown);
3968
+ super.disconnectedCallback(), clearTimeout(this.timer), j() && document.removeEventListener("mousedown", this.onDocMousedown);
3964
3969
  }
3965
3970
  willUpdate(t) {
3966
3971
  super.willUpdate(t), t.has("value") && this.timer === void 0 && (this.term = this.value);
@@ -3973,15 +3978,15 @@ let F = class extends y {
3973
3978
  }
3974
3979
  // ---- suggestions -----------------------------------------------------
3975
3980
  filterStatic(t) {
3976
- var s;
3981
+ var a;
3977
3982
  const e = t.trim().toLowerCase();
3978
3983
  if (!e) return this.options.slice(0, this.maxItems);
3979
- const a = [], i = [];
3984
+ const s = [], i = [];
3980
3985
  for (const r of this.options) {
3981
3986
  const o = r.label.toLowerCase();
3982
- o.startsWith(e) ? a.push(r) : (o.includes(e) || (s = r.sub) != null && s.toLowerCase().includes(e)) && i.push(r);
3987
+ o.startsWith(e) ? s.push(r) : (o.includes(e) || (a = r.sub) != null && a.toLowerCase().includes(e)) && i.push(r);
3983
3988
  }
3984
- return [...a, ...i].slice(0, this.maxItems);
3989
+ return [...s, ...i].slice(0, this.maxItems);
3985
3990
  }
3986
3991
  async suggest(t) {
3987
3992
  if (t.length < this.minChars) {
@@ -3995,8 +4000,8 @@ let F = class extends y {
3995
4000
  const e = ++this.fetchSeq;
3996
4001
  this.loading = !0, this.open = !0, this.listen();
3997
4002
  try {
3998
- const a = await this.fetcher(t);
3999
- e === this.fetchSeq && (this.results = a.slice(0, this.maxItems));
4003
+ const s = await this.fetcher(t);
4004
+ e === this.fetchSeq && (this.results = s.slice(0, this.maxItems));
4000
4005
  } catch {
4001
4006
  e === this.fetchSeq && (this.results = []);
4002
4007
  } finally {
@@ -4007,10 +4012,10 @@ let F = class extends y {
4007
4012
  this.activeIndex !== t && (this.activeIndex = t);
4008
4013
  }
4009
4014
  listen() {
4010
- T() && document.addEventListener("mousedown", this.onDocMousedown);
4015
+ j() && document.addEventListener("mousedown", this.onDocMousedown);
4011
4016
  }
4012
4017
  close() {
4013
- T() && document.removeEventListener("mousedown", this.onDocMousedown), this.open && (this.open = !1, this.activeIndex = -1);
4018
+ j() && document.removeEventListener("mousedown", this.onDocMousedown), this.open && (this.open = !1, this.activeIndex = -1);
4014
4019
  }
4015
4020
  // ---- events ------------------------------------------------------------
4016
4021
  emitChange(t, e) {
@@ -4054,8 +4059,8 @@ let F = class extends y {
4054
4059
  t.preventDefault(), this.open && e > 0 && (this.activeIndex = (this.activeIndex - 1 + e) % e);
4055
4060
  break;
4056
4061
  case "Enter": {
4057
- const a = this.open ? this.results[this.activeIndex] : void 0;
4058
- a ? (t.preventDefault(), this.pick(a)) : (this.flush(), this.close());
4062
+ const s = this.open ? this.results[this.activeIndex] : void 0;
4063
+ s ? (t.preventDefault(), this.pick(s)) : (this.flush(), this.close());
4059
4064
  break;
4060
4065
  }
4061
4066
  case "Escape":
@@ -4084,8 +4089,8 @@ let F = class extends y {
4084
4089
  placeholder=${this.placeholder || h}
4085
4090
  .value=${Z(this.term)}
4086
4091
  ?disabled=${this.disabled}
4087
- @input=${(a) => this.onInput(a)}
4088
- @keydown=${(a) => this.onKeydown(a)}
4092
+ @input=${(s) => this.onInput(s)}
4093
+ @keydown=${(s) => this.onKeydown(s)}
4089
4094
  @blur=${() => this.onBlur()}
4090
4095
  />
4091
4096
  <div
@@ -4098,82 +4103,82 @@ let F = class extends y {
4098
4103
  >
4099
4104
  ${this.loading ? l`<div class="baht-listbox-note" role="option" aria-disabled="true" aria-selected="false">Searching…</div>` : e ? l`<div class="baht-listbox-note" role="option" aria-disabled="true" aria-selected="false">No matches</div>` : this.results.map(
4100
4105
  // eslint-disable-next-line lit-a11y/click-events-have-key-events -- keyboard lives on the combobox input (aria-activedescendant pattern)
4101
- (a, i) => l`<div
4106
+ (s, i) => l`<div
4102
4107
  class="baht-listbox-option${i === this.activeIndex ? " baht-listbox-option--active" : ""}"
4103
4108
  id=${this.optionId(i)}
4104
4109
  role="option"
4105
4110
  aria-selected=${i === this.activeIndex ? "true" : "false"}
4106
- data-key=${a.key}
4107
- @mousedown=${(s) => s.preventDefault()}
4111
+ data-key=${s.key}
4112
+ @mousedown=${(a) => a.preventDefault()}
4108
4113
  @mousemove=${() => this.highlight(i)}
4109
4114
  @click=${() => {
4110
- var s;
4111
- this.pick(a), (s = this.inputEl) == null || s.focus();
4115
+ var a;
4116
+ this.pick(s), (a = this.inputEl) == null || a.focus();
4112
4117
  }}
4113
4118
  >
4114
- <span class="baht-listbox-option-label">${a.label}</span>
4115
- ${a.sub ? l`<span class="baht-listbox-option-sub">${a.sub}</span>` : h}
4119
+ <span class="baht-listbox-option-label">${s.label}</span>
4120
+ ${s.sub ? l`<span class="baht-listbox-option-sub">${s.sub}</span>` : h}
4116
4121
  </div>`
4117
4122
  )}
4118
4123
  </div>
4119
4124
  </div>`;
4120
4125
  }
4121
4126
  };
4122
- I([
4127
+ B([
4123
4128
  n()
4124
4129
  ], F.prototype, "label", 2);
4125
- I([
4130
+ B([
4126
4131
  n()
4127
4132
  ], F.prototype, "value", 2);
4128
- I([
4133
+ B([
4129
4134
  n()
4130
4135
  ], F.prototype, "placeholder", 2);
4131
- I([
4136
+ B([
4132
4137
  n({ type: Boolean })
4133
4138
  ], F.prototype, "disabled", 2);
4134
- I([
4139
+ B([
4135
4140
  n({ type: Boolean })
4136
4141
  ], F.prototype, "invalid", 2);
4137
- I([
4142
+ B([
4138
4143
  n({ attribute: !1 })
4139
4144
  ], F.prototype, "options", 2);
4140
- I([
4145
+ B([
4141
4146
  n({ attribute: !1 })
4142
4147
  ], F.prototype, "fetcher", 2);
4143
- I([
4148
+ B([
4144
4149
  n({ type: Number })
4145
4150
  ], F.prototype, "debounce", 2);
4146
- I([
4151
+ B([
4147
4152
  n({ type: Number, attribute: "min-chars" })
4148
4153
  ], F.prototype, "minChars", 2);
4149
- I([
4154
+ B([
4150
4155
  n({ type: Number, attribute: "max-items" })
4151
4156
  ], F.prototype, "maxItems", 2);
4152
- I([
4157
+ B([
4153
4158
  n({ attribute: "free-text", converter: (t) => t !== "false" })
4154
4159
  ], F.prototype, "freeText", 2);
4155
- I([
4160
+ B([
4156
4161
  n()
4157
4162
  ], F.prototype, "autocomplete", 2);
4158
- I([
4163
+ B([
4159
4164
  v()
4160
4165
  ], F.prototype, "term", 2);
4161
- I([
4166
+ B([
4162
4167
  v()
4163
4168
  ], F.prototype, "open", 2);
4164
- I([
4169
+ B([
4165
4170
  v()
4166
4171
  ], F.prototype, "results", 2);
4167
- I([
4172
+ B([
4168
4173
  v()
4169
4174
  ], F.prototype, "loading", 2);
4170
- I([
4175
+ B([
4171
4176
  v()
4172
4177
  ], F.prototype, "activeIndex", 2);
4173
- I([
4174
- It("input")
4178
+ B([
4179
+ Bt("input")
4175
4180
  ], F.prototype, "inputEl", 2);
4176
- F = I([
4181
+ F = B([
4177
4182
  f("baht-typeahead")
4178
4183
  ], F);
4179
4184
  const ys = {
@@ -4194,18 +4199,18 @@ const ys = {
4194
4199
  section: "baht-section",
4195
4200
  repeater: "baht-repeater"
4196
4201
  };
4197
- var Ci = Object.defineProperty, Di = Object.getOwnPropertyDescriptor, gs = (t, e, a, i) => {
4198
- for (var s = i > 1 ? void 0 : i ? Di(e, a) : e, r = t.length - 1, o; r >= 0; r--)
4199
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
4200
- return i && s && Ci(e, a, s), s;
4202
+ var Di = Object.defineProperty, Si = Object.getOwnPropertyDescriptor, gs = (t, e, s, i) => {
4203
+ for (var a = i > 1 ? void 0 : i ? Si(e, s) : e, r = t.length - 1, o; r >= 0; r--)
4204
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
4205
+ return i && a && Di(e, s, a), a;
4201
4206
  };
4202
- const Si = {
4207
+ const Fi = {
4203
4208
  "1/4": "baht-field--w-1-4",
4204
4209
  "1/2": "baht-field--w-1-2",
4205
4210
  "3/4": "baht-field--w-3-4",
4206
4211
  full: "baht-field--w-full"
4207
4212
  }, hs = /* @__PURE__ */ new Map();
4208
- function Fi(t) {
4213
+ function Mi(t) {
4209
4214
  let e = hs.get(t);
4210
4215
  return e || (e = ds(t), hs.set(t, e)), e;
4211
4216
  }
@@ -4222,9 +4227,9 @@ let Ae = class extends X {
4222
4227
  get subFields() {
4223
4228
  return [...this.field.fields ?? []].sort((t, e) => t.order - e.order).filter((t) => t.type !== "repeater");
4224
4229
  }
4225
- patchRow(t, e, a) {
4230
+ patchRow(t, e, s) {
4226
4231
  const i = [...this.rows];
4227
- i[t] = { ...i[t], [e]: a }, this.emitInput(i);
4232
+ i[t] = { ...i[t], [e]: s }, this.emitInput(i);
4228
4233
  }
4229
4234
  addRow() {
4230
4235
  const t = {};
@@ -4233,49 +4238,49 @@ let Ae = class extends X {
4233
4238
  this.emitInput([...this.rows, t]);
4234
4239
  }
4235
4240
  removeRow(t) {
4236
- this.emitInput(this.rows.filter((e, a) => a !== t));
4241
+ this.emitInput(this.rows.filter((e, s) => s !== t));
4237
4242
  }
4238
4243
  /** Pending keystrokes in any row land in the array before the host reads it. */
4239
4244
  flushTyped() {
4240
4245
  var t;
4241
- if (!T()) return super.flushTyped();
4246
+ if (!j()) return super.flushTyped();
4242
4247
  for (const e of this.querySelectorAll(".baht-repeater-row > .baht-field > *"))
4243
4248
  (t = e.flushTyped) == null || t.call(e);
4244
4249
  super.flushTyped();
4245
4250
  }
4246
4251
  errorFor(t, e) {
4247
4252
  var i;
4248
- const a = `${this.field.key}[${t}].${e}`;
4249
- return ((i = this.rowErrors.find((s) => s.key === a)) == null ? void 0 : i.message) ?? null;
4253
+ const s = `${this.field.key}[${t}].${e}`;
4254
+ return ((i = this.rowErrors.find((a) => a.key === s)) == null ? void 0 : i.message) ?? null;
4250
4255
  }
4251
4256
  /**
4252
4257
  * Sub-controls render declaratively (one static-tag template per primitive, rows
4253
4258
  * keyed by index) so Lit reuses the same node across re-renders — typing keeps
4254
4259
  * focus, same as <baht-form> — and the whole thing renders on the server.
4255
4260
  */
4256
- renderSub(t, e, a) {
4257
- const i = ys[a.type];
4261
+ renderSub(t, e, s) {
4262
+ const i = ys[s.type];
4258
4263
  if (!i) return h;
4259
- const s = Fi(i), r = Si[a.width ?? "full"] ?? "baht-field--w-full", o = (c) => {
4264
+ const a = Mi(i), r = Fi[s.width ?? "full"] ?? "baht-field--w-full", o = (c) => {
4260
4265
  c.stopPropagation();
4261
4266
  const { value: m } = c.detail;
4262
- this.patchRow(e, a.key, m);
4267
+ this.patchRow(e, s.key, m);
4263
4268
  };
4264
- return l`<div class="baht-field ${r}" data-key=${a.key} data-type=${a.type}>
4265
- ${ae`<${s}
4266
- .field=${a}
4267
- .value=${Object.hasOwn(t, a.key) ? t[a.key] : ie(a)}
4269
+ return l`<div class="baht-field ${r}" data-key=${s.key} data-type=${s.type}>
4270
+ ${se`<${a}
4271
+ .field=${s}
4272
+ .value=${Object.hasOwn(t, s.key) ? t[s.key] : ie(s)}
4268
4273
  .disabled=${this.disabled}
4269
4274
  .readonly=${this.readonly}
4270
- .required=${!!a.required}
4271
- .error=${this.errorFor(e, a.key)}
4275
+ .required=${!!s.required}
4276
+ .error=${this.errorFor(e, s.key)}
4272
4277
  .debounce=${this.debounce}
4273
4278
  @baht-input=${o}
4274
- ></${s}>`}
4279
+ ></${a}>`}
4275
4280
  </div>`;
4276
4281
  }
4277
4282
  renderControl() {
4278
- const t = this.rows, e = !this.disabled && !this.readonly, a = this.field.max_rows !== void 0 && t.length >= this.field.max_rows;
4283
+ const t = this.rows, e = !this.disabled && !this.readonly, s = this.field.max_rows !== void 0 && t.length >= this.field.max_rows;
4279
4284
  return l`<div
4280
4285
  class="baht-repeater"
4281
4286
  id=${this.controlId}
@@ -4285,24 +4290,24 @@ let Ae = class extends X {
4285
4290
  >
4286
4291
  ${Fe(
4287
4292
  t,
4288
- (i, s) => s,
4289
- (i, s) => l`<div
4293
+ (i, a) => a,
4294
+ (i, a) => l`<div
4290
4295
  class="baht-repeater-row"
4291
- data-row=${s}
4296
+ data-row=${a}
4292
4297
  role="group"
4293
- aria-label=${u("row", { n: s + 1 })}
4298
+ aria-label=${u("row", { n: a + 1 })}
4294
4299
  >
4295
4300
  ${Fe(
4296
4301
  this.subFields,
4297
4302
  (r) => r.key,
4298
- (r) => this.renderSub(i, s, r)
4303
+ (r) => this.renderSub(i, a, r)
4299
4304
  )}
4300
4305
  ${e ? l`<button
4301
4306
  type="button"
4302
4307
  class="baht-repeater-remove"
4303
- aria-label=${u("removeRowN", { n: s + 1 })}
4304
- title=${u("removeRowN", { n: s + 1 })}
4305
- @click=${() => this.removeRow(s)}
4308
+ aria-label=${u("removeRowN", { n: a + 1 })}
4309
+ title=${u("removeRowN", { n: a + 1 })}
4310
+ @click=${() => this.removeRow(a)}
4306
4311
  >
4307
4312
  ✕
4308
4313
  </button>` : h}
@@ -4311,7 +4316,7 @@ let Ae = class extends X {
4311
4316
  ${this.readonly ? h : l`<button
4312
4317
  type="button"
4313
4318
  class="baht-repeater-add"
4314
- ?disabled=${this.disabled || a}
4319
+ ?disabled=${this.disabled || s}
4315
4320
  @click=${() => this.addRow()}
4316
4321
  >
4317
4322
  + ${this.field.add_label ?? u("addRow")}
@@ -4325,12 +4330,12 @@ gs([
4325
4330
  Ae = gs([
4326
4331
  f("baht-repeater")
4327
4332
  ], Ae);
4328
- var Mi = Object.defineProperty, Bi = Object.getOwnPropertyDescriptor, $e = (t, e, a, i) => {
4329
- for (var s = i > 1 ? void 0 : i ? Bi(e, a) : e, r = t.length - 1, o; r >= 0; r--)
4330
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
4331
- return i && s && Mi(e, a, s), s;
4333
+ var Ii = Object.defineProperty, Bi = Object.getOwnPropertyDescriptor, $e = (t, e, s, i) => {
4334
+ for (var a = i > 1 ? void 0 : i ? Bi(e, s) : e, r = t.length - 1, o; r >= 0; r--)
4335
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
4336
+ return i && a && Ii(e, s, a), a;
4332
4337
  };
4333
- let Wt = class extends y {
4338
+ let Gt = class extends y {
4334
4339
  constructor() {
4335
4340
  super(...arguments), this.steps = [], this.current = 0, this.variant = "default";
4336
4341
  }
@@ -4340,13 +4345,13 @@ let Wt = class extends y {
4340
4345
  class="baht-steps ${t ? "baht-steps--sidebar" : ""}"
4341
4346
  aria-label=${u("step", { current: this.current + 1, total: this.steps.length })}
4342
4347
  >
4343
- ${this.steps.map((e, a) => {
4344
- const i = a < this.current ? "done" : a === this.current ? "current" : "todo";
4348
+ ${this.steps.map((e, s) => {
4349
+ const i = s < this.current ? "done" : s === this.current ? "current" : "todo";
4345
4350
  return l`<li
4346
4351
  class="baht-step baht-step--${i} ${t ? "baht-step--sidebar" : ""}"
4347
4352
  aria-current=${i === "current" ? "step" : "false"}
4348
4353
  >
4349
- ${t ? h : l`<span class="baht-step-marker" aria-hidden="true">${i === "done" ? "✓" : a + 1}</span>`}
4354
+ ${t ? h : l`<span class="baht-step-marker" aria-hidden="true">${i === "done" ? "✓" : s + 1}</span>`}
4350
4355
  <span class="baht-step-label">${e}</span>
4351
4356
  ${i === "done" ? l`<span class="baht-visually-hidden"> (${u("stepDone")})</span>` : i === "current" ? l`<span class="baht-visually-hidden"> (${u("stepCurrent")})</span>` : h}
4352
4357
  </li>`;
@@ -4356,28 +4361,28 @@ let Wt = class extends y {
4356
4361
  };
4357
4362
  $e([
4358
4363
  n({ attribute: !1 })
4359
- ], Wt.prototype, "steps", 2);
4364
+ ], Gt.prototype, "steps", 2);
4360
4365
  $e([
4361
4366
  n({ type: Number })
4362
- ], Wt.prototype, "current", 2);
4367
+ ], Gt.prototype, "current", 2);
4363
4368
  $e([
4364
4369
  n()
4365
- ], Wt.prototype, "variant", 2);
4366
- Wt = $e([
4370
+ ], Gt.prototype, "variant", 2);
4371
+ Gt = $e([
4367
4372
  f("baht-steps")
4368
- ], Wt);
4369
- var Ii = Object.defineProperty, ji = Object.getOwnPropertyDescriptor, U = (t, e, a, i) => {
4370
- for (var s = i > 1 ? void 0 : i ? ji(e, a) : e, r = t.length - 1, o; r >= 0; r--)
4371
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
4372
- return i && s && Ii(e, a, s), s;
4373
+ ], Gt);
4374
+ var Ti = Object.defineProperty, ji = Object.getOwnPropertyDescriptor, U = (t, e, s, i) => {
4375
+ for (var a = i > 1 ? void 0 : i ? ji(e, s) : e, r = t.length - 1, o; r >= 0; r--)
4376
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
4377
+ return i && a && Ti(e, s, a), a;
4373
4378
  };
4374
- const Ti = {
4379
+ const Ai = {
4375
4380
  "1/4": "baht-field--w-1-4",
4376
4381
  "1/2": "baht-field--w-1-2",
4377
4382
  "3/4": "baht-field--w-3-4",
4378
4383
  full: "baht-field--w-full"
4379
4384
  }, cs = /* @__PURE__ */ new Map();
4380
- function Ai(t) {
4385
+ function Ei(t) {
4381
4386
  let e = cs.get(t);
4382
4387
  return e || (e = ds(t), cs.set(t, e)), e;
4383
4388
  }
@@ -4401,16 +4406,16 @@ let z = class extends y {
4401
4406
  * dropped by epoch).
4402
4407
  */
4403
4408
  syncDynamicOptions() {
4404
- var e, a;
4409
+ var e, s;
4405
4410
  const t = this.getData();
4406
4411
  for (const i of ((e = this.effectiveForm) == null ? void 0 : e.fields) ?? []) {
4407
4412
  if (!i.options_from) continue;
4408
- const s = JSON.stringify((i.options_deps ?? []).map((m) => t[m] ?? null));
4409
- if (this.optionsSnapshots.get(i.key) === s) continue;
4410
- this.optionsSnapshots.set(i.key, s);
4413
+ const a = JSON.stringify((i.options_deps ?? []).map((m) => t[m] ?? null));
4414
+ if (this.optionsSnapshots.get(i.key) === a) continue;
4415
+ this.optionsSnapshots.set(i.key, a);
4411
4416
  const r = (this.optionsEpoch.get(i.key) ?? 0) + 1;
4412
4417
  this.optionsEpoch.set(i.key, r);
4413
- const o = (a = this.registry.options) == null ? void 0 : a[i.options_from];
4418
+ const o = (s = this.registry.options) == null ? void 0 : s[i.options_from];
4414
4419
  if (!o) {
4415
4420
  console.warn(`[bahtui] unknown options fetcher "${i.options_from}" — skipped`), this.dynamicOptions.set(i.key, []);
4416
4421
  continue;
@@ -4429,18 +4434,18 @@ let z = class extends y {
4429
4434
  * (province -> district -> subdistrict).
4430
4435
  */
4431
4436
  clearDependents(t) {
4432
- var i, s;
4433
- const e = [t], a = /* @__PURE__ */ new Set();
4437
+ var i, a;
4438
+ const e = [t], s = /* @__PURE__ */ new Set();
4434
4439
  for (; e.length > 0; ) {
4435
4440
  const r = e.shift();
4436
4441
  for (const o of ((i = this.effectiveForm) == null ? void 0 : i.fields) ?? [])
4437
- !((s = o.options_deps) != null && s.includes(r)) || a.has(o.key) || (a.add(o.key), this.edits = { ...this.edits, [o.key]: ie(o) }, e.push(o.key));
4442
+ !((a = o.options_deps) != null && a.includes(r)) || s.has(o.key) || (s.add(o.key), this.edits = { ...this.edits, [o.key]: ie(o) }, e.push(o.key));
4438
4443
  }
4439
4444
  }
4440
4445
  get sortedFields() {
4441
4446
  if (!this.form) return [];
4442
- const t = Re(this.effectiveForm, this.view);
4443
- return t || (this.view !== void 0 && !this.warnedViews.has(this.view) && (this.warnedViews.add(this.view), console.warn(`[bahtui] unknown view "${this.view}" — showing the full form`)), Re(this.effectiveForm) ?? []);
4447
+ const t = ze(this.effectiveForm, this.view);
4448
+ return t || (this.view !== void 0 && !this.warnedViews.has(this.view) && (this.warnedViews.add(this.view), console.warn(`[bahtui] unknown view "${this.view}" — showing the full form`)), ze(this.effectiveForm) ?? []);
4444
4449
  }
4445
4450
  stateFor(t) {
4446
4451
  const e = this.fieldStates[t.key] ?? {
@@ -4449,8 +4454,8 @@ let z = class extends y {
4449
4454
  readonly: !!t.readonly,
4450
4455
  required: !!t.required,
4451
4456
  computed: !1
4452
- }, a = this.scriptStates[t.key];
4453
- return a ? { ...e, ...a } : e;
4457
+ }, s = this.scriptStates[t.key];
4458
+ return s ? { ...e, ...s } : e;
4454
4459
  }
4455
4460
  valueFor(t) {
4456
4461
  return Object.hasOwn(this.edits, t.key) ? this.edits[t.key] : Object.hasOwn(this.value, t.key) ? this.value[t.key] : ie(t);
@@ -4459,7 +4464,7 @@ let z = class extends y {
4459
4464
  /** Debounced keystrokes still in a control land in `edits` before anyone reads them. */
4460
4465
  flushTyped() {
4461
4466
  var t;
4462
- if (T())
4467
+ if (j())
4463
4468
  for (const e of this.querySelectorAll(":scope > .baht-form > .baht-field > *"))
4464
4469
  (t = e.flushTyped) == null || t.call(e);
4465
4470
  }
@@ -4467,8 +4472,8 @@ let z = class extends y {
4467
4472
  var e;
4468
4473
  this.flushTyped();
4469
4474
  const t = {};
4470
- for (const a of ((e = this.effectiveForm) == null ? void 0 : e.fields) ?? [])
4471
- a.type === "label" || a.type === "section" || (t[a.key] = this.valueFor(a));
4475
+ for (const s of ((e = this.effectiveForm) == null ? void 0 : e.fields) ?? [])
4476
+ s.type === "label" || s.type === "section" || (t[s.key] = this.valueFor(s));
4472
4477
  return t;
4473
4478
  }
4474
4479
  /**
@@ -4479,18 +4484,18 @@ let z = class extends y {
4479
4484
  setValue(t) {
4480
4485
  const e = this.getData();
4481
4486
  this.edits = { ...this.edits, ...t }, this.requestUpdate();
4482
- for (const a of Object.keys(t))
4483
- this.runChangeScripts(a, e[a], t[a], !1);
4487
+ for (const s of Object.keys(t))
4488
+ this.runChangeScripts(s, e[s], t[s], !1);
4484
4489
  }
4485
4490
  /** Declarative + registry validators over the visible fields (no scripts). */
4486
4491
  runValidators() {
4487
4492
  const t = [], e = this.getData();
4488
- for (const a of this.sortedFields) {
4489
- if (a.type === "label" || a.type === "section") continue;
4490
- const i = this.stateFor(a);
4493
+ for (const s of this.sortedFields) {
4494
+ if (s.type === "label" || s.type === "section") continue;
4495
+ const i = this.stateFor(s);
4491
4496
  if (!i.visible) continue;
4492
- const s = i.required === !!a.required ? a : { ...a, required: i.required };
4493
- t.push(...ze(s, this.valueFor(a), this.registry, e));
4497
+ const a = i.required === !!s.required ? s : { ...s, required: i.required };
4498
+ t.push(...Ve(a, this.valueFor(s), this.registry, e));
4494
4499
  }
4495
4500
  return t;
4496
4501
  }
@@ -4509,14 +4514,14 @@ let z = class extends y {
4509
4514
  g: this.g(e),
4510
4515
  on: "submit",
4511
4516
  detail: { isLoading: !1, data: this.getData() }
4512
- }), s = this.formMessages.filter((r) => r.type === "error").map((r) => ({ key: "$", message: r.message }));
4513
- !i && s.length === 0 && s.push({ key: "$", message: u("scriptBlocked") }), t.push(...s);
4517
+ }), a = this.formMessages.filter((r) => r.type === "error").map((r) => ({ key: "$", message: r.message }));
4518
+ !i && a.length === 0 && a.push({ key: "$", message: u("scriptBlocked") }), t.push(...a);
4514
4519
  }
4515
4520
  this.errors = t;
4516
- const a = { valid: t.length === 0, errors: t };
4521
+ const s = { valid: t.length === 0, errors: t };
4517
4522
  return this.dispatchEvent(
4518
- new CustomEvent("baht-validity", { detail: a, bubbles: !0, composed: !0 })
4519
- ), a;
4523
+ new CustomEvent("baht-validity", { detail: s, bubbles: !0, composed: !0 })
4524
+ ), s;
4520
4525
  }
4521
4526
  reset() {
4522
4527
  this.edits = {}, this.value = {}, this.errors = [], this.scriptStates = {}, this.fieldMessages = {}, this.formMessages = [], this.requestUpdate();
@@ -4524,13 +4529,13 @@ let z = class extends y {
4524
4529
  // ---- client scripts (spec 01 §14) ----
4525
4530
  /** The `g` (g_form) for the current form — built lazily over this component's state. */
4526
4531
  g(t) {
4527
- return this.scriptContext && this.scriptContextForm === t ? this.scriptContext : (this.scriptContextForm = t, this.scriptContext = _s(t, {
4532
+ return this.scriptContext && this.scriptContextForm === t ? this.scriptContext : (this.scriptContextForm = t, this.scriptContext = ks(t, {
4528
4533
  getData: () => this.getData(),
4529
- setValue: (e, a) => this.applyScriptValue(e, a),
4530
- setState: (e, a) => {
4534
+ setValue: (e, s) => this.applyScriptValue(e, s),
4535
+ setState: (e, s) => {
4531
4536
  this.scriptStates = {
4532
4537
  ...this.scriptStates,
4533
- [e]: { ...this.scriptStates[e], ...a }
4538
+ [e]: { ...this.scriptStates[e], ...s }
4534
4539
  };
4535
4540
  },
4536
4541
  resetState: (e) => {
@@ -4538,12 +4543,12 @@ let z = class extends y {
4538
4543
  this.scriptStates = {};
4539
4544
  return;
4540
4545
  }
4541
- const a = { ...this.scriptStates };
4542
- delete a[e], this.scriptStates = a;
4546
+ const s = { ...this.scriptStates };
4547
+ delete s[e], this.scriptStates = s;
4543
4548
  },
4544
- setFieldMessage: (e, a) => {
4549
+ setFieldMessage: (e, s) => {
4545
4550
  const i = { ...this.fieldMessages };
4546
- a ? i[e] = a : delete i[e], this.fieldMessages = i;
4551
+ s ? i[e] = s : delete i[e], this.fieldMessages = i;
4547
4552
  },
4548
4553
  addFormMessage: (e) => {
4549
4554
  this.formMessages = [...this.formMessages, e];
@@ -4555,33 +4560,33 @@ let z = class extends y {
4555
4560
  }
4556
4561
  /** A script wrote a value: same path as a user edit (emit + cascade), minus the formatter. */
4557
4562
  applyScriptValue(t, e) {
4558
- const a = this.getData()[t];
4563
+ const s = this.getData()[t];
4559
4564
  this.edits = { ...this.edits, [t]: e }, this.clearDependents(t), this.syncDynamicOptions(), this.dispatchEvent(
4560
4565
  new CustomEvent("baht-change", {
4561
4566
  detail: { form_name: this.form.form_name, key: t, value: e, data: this.getData() },
4562
4567
  bubbles: !0,
4563
4568
  composed: !0
4564
4569
  })
4565
- ), this.runChangeScripts(t, a, e, !1);
4570
+ ), this.runChangeScripts(t, s, e, !1);
4566
4571
  }
4567
- runChangeScripts(t, e, a, i) {
4568
- const s = this.effectiveForm;
4569
- if (!(!s || !ge(s, "change", t))) {
4570
- if (this.scriptDepth >= Ve) {
4572
+ runChangeScripts(t, e, s, i) {
4573
+ const a = this.effectiveForm;
4574
+ if (!(!a || !ge(a, "change", t))) {
4575
+ if (this.scriptDepth >= Ke) {
4571
4576
  console.warn(
4572
- `[bahtui] script cascade on "${s.form_name}.${t}" exceeded ${Ve} levels — stopped (setValue ping-pong between change scripts?)`
4577
+ `[bahtui] script cascade on "${a.form_name}.${t}" exceeded ${Ke} levels — stopped (setValue ping-pong between change scripts?)`
4573
4578
  );
4574
4579
  return;
4575
4580
  }
4576
4581
  this.scriptDepth++;
4577
4582
  try {
4578
4583
  we({
4579
- form: s,
4584
+ form: a,
4580
4585
  registry: this.registry,
4581
- g: this.g(s),
4586
+ g: this.g(a),
4582
4587
  on: "change",
4583
4588
  key: t,
4584
- detail: { oldValue: e, newValue: a, isLoading: i, data: this.getData() }
4589
+ detail: { oldValue: e, newValue: s, isLoading: i, data: this.getData() }
4585
4590
  });
4586
4591
  } finally {
4587
4592
  this.scriptDepth--;
@@ -4594,9 +4599,9 @@ let z = class extends y {
4594
4599
  * workflow reuses this element across steps, so each step loads.
4595
4600
  */
4596
4601
  runLoadScripts() {
4597
- var a;
4602
+ var s;
4598
4603
  const t = this.effectiveForm;
4599
- if (!((a = t == null ? void 0 : t.scripts) != null && a.length)) return;
4604
+ if (!((s = t == null ? void 0 : t.scripts) != null && s.length)) return;
4600
4605
  const e = this.getData();
4601
4606
  for (const i of t.fields)
4602
4607
  i.type === "label" || i.type === "section" || this.runChangeScripts(i.key, void 0, e[i.key], !0);
@@ -4609,92 +4614,92 @@ let z = class extends y {
4609
4614
  });
4610
4615
  }
4611
4616
  updated(t) {
4612
- super.updated(t), T() && this.form && this.loadedForm !== this.form && (this.loadedForm = this.form, this.runLoadScripts());
4617
+ super.updated(t), j() && this.form && this.loadedForm !== this.form && (this.loadedForm = this.form, this.runLoadScripts());
4613
4618
  }
4614
4619
  // ---- internal ----
4615
4620
  onFieldInput(t, e) {
4616
4621
  var r;
4617
4622
  e.stopPropagation();
4618
- let { value: a } = e.detail;
4623
+ let { value: s } = e.detail;
4619
4624
  const i = t.formatter ? (r = this.registry.formatters) == null ? void 0 : r[t.formatter] : void 0;
4620
- t.formatter && !i && console.warn(`[bahtui] unknown formatter "${t.formatter}" — skipped`), i && (a = i(a));
4621
- const s = this.valueFor(t);
4622
- this.edits = { ...this.edits, [t.key]: a }, this.clearDependents(t.key), this.syncDynamicOptions(), (this.options.validateOn ?? "change") === "change" && this.errors.length > 0 && (this.errors = this.runValidators()), this.dispatchEvent(
4625
+ t.formatter && !i && console.warn(`[bahtui] unknown formatter "${t.formatter}" — skipped`), i && (s = i(s));
4626
+ const a = this.valueFor(t);
4627
+ this.edits = { ...this.edits, [t.key]: s }, this.clearDependents(t.key), this.syncDynamicOptions(), (this.options.validateOn ?? "change") === "change" && this.errors.length > 0 && (this.errors = this.runValidators()), this.dispatchEvent(
4623
4628
  new CustomEvent("baht-change", {
4624
- detail: { form_name: this.form.form_name, key: t.key, value: a, data: this.getData() },
4629
+ detail: { form_name: this.form.form_name, key: t.key, value: s, data: this.getData() },
4625
4630
  bubbles: !0,
4626
4631
  composed: !0
4627
4632
  })
4628
- ), this.runChangeScripts(t.key, s, a, !1);
4633
+ ), this.runChangeScripts(t.key, a, s, !1);
4629
4634
  }
4630
4635
  /** Validate a single field against current form data (siblings included). */
4631
4636
  validateOneField(t) {
4632
4637
  const e = this.stateFor(t);
4633
4638
  if (!e.visible) return [];
4634
- const a = this.getData(), i = e.required === !!t.required ? t : { ...t, required: e.required };
4635
- return ze(i, this.valueFor(t), this.registry, a);
4639
+ const s = this.getData(), i = e.required === !!t.required ? t : { ...t, required: e.required };
4640
+ return Ve(i, this.valueFor(t), this.registry, s);
4636
4641
  }
4637
4642
  /** `validateOn: 'blur'` — validate just the field the user left, same as
4638
4643
  * how errors are shown elsewhere (merged into `this.errors`, painted by
4639
4644
  * `renderField`/`.baht-error`). No-op for 'change'/'submit' modes. */
4640
4645
  onFieldBlur(t) {
4641
4646
  if ((this.options.validateOn ?? "change") !== "blur") return;
4642
- const e = this.validateOneField(t), a = this.errors.filter((i) => i.key !== t.key);
4643
- this.errors = [...a, ...e];
4647
+ const e = this.validateOneField(t), s = this.errors.filter((i) => i.key !== t.key);
4648
+ this.errors = [...s, ...e];
4644
4649
  }
4645
4650
  renderField(t) {
4646
4651
  var b, w;
4647
4652
  const e = ys[t.type];
4648
4653
  if (!e)
4649
4654
  return console.warn(`[bahtui] unknown field type "${t.type}" — skipped`), h;
4650
- const a = this.stateFor(t), i = Ti[t.width ?? "full"] ?? "baht-field--w-full", s = ((b = this.errors.find((P) => P.key === t.key)) == null ? void 0 : b.message) ?? null;
4655
+ const s = this.stateFor(t), i = Ai[t.width ?? "full"] ?? "baht-field--w-full", a = ((b = this.errors.find((P) => P.key === t.key)) == null ? void 0 : b.message) ?? null;
4651
4656
  if (this.readonly && t.type !== "label" && t.type !== "section")
4652
- return this.renderReadonlyField(t, i, a.visible);
4653
- const r = t.options_from ? { ...t, options: this.dynamicOptions.get(t.key) ?? t.options ?? [] } : t, o = this.valueFor(t), c = !a.enabled, m = this.readonly || a.readonly, $ = this.options.inputDebounce, _ = (P) => this.onControlInput(t.key, P), p = Ai(e);
4657
+ return this.renderReadonlyField(t, i, s.visible);
4658
+ const r = t.options_from ? { ...t, options: this.dynamicOptions.get(t.key) ?? t.options ?? [] } : t, o = this.valueFor(t), c = !s.enabled, m = this.readonly || s.readonly, $ = this.options.inputDebounce, _ = (P) => this.onControlInput(t.key, P), p = Ei(e);
4654
4659
  let C;
4655
4660
  if (t.type === "repeater") {
4656
4661
  const P = this.errors.filter((H) => H.key.startsWith(`${t.key}[`));
4657
- C = ae`<${p}
4662
+ C = se`<${p}
4658
4663
  .field=${r}
4659
4664
  .value=${o}
4660
4665
  .disabled=${c}
4661
4666
  .readonly=${m}
4662
- .required=${a.required}
4667
+ .required=${s.required}
4663
4668
  .showOptional=${this.showOptional}
4664
- .error=${s}
4669
+ .error=${a}
4665
4670
  .debounce=${$}
4666
4671
  .rowErrors=${P}
4667
4672
  @baht-input=${_}
4668
4673
  ></${p}>`;
4669
4674
  } else if (t.type === "file") {
4670
4675
  let P;
4671
- t.uploader && (P = (w = this.registry.uploaders) == null ? void 0 : w[t.uploader], P || console.warn(`[bahtui] unknown uploader "${t.uploader}" — capture only`)), C = ae`<${p}
4676
+ t.uploader && (P = (w = this.registry.uploaders) == null ? void 0 : w[t.uploader], P || console.warn(`[bahtui] unknown uploader "${t.uploader}" — capture only`)), C = se`<${p}
4672
4677
  .field=${r}
4673
4678
  .value=${o}
4674
4679
  .disabled=${c}
4675
4680
  .readonly=${m}
4676
- .required=${a.required}
4681
+ .required=${s.required}
4677
4682
  .showOptional=${this.showOptional}
4678
- .error=${s}
4683
+ .error=${a}
4679
4684
  .debounce=${$}
4680
4685
  .uploader=${P}
4681
4686
  @baht-input=${_}
4682
4687
  ></${p}>`;
4683
4688
  } else
4684
- C = ae`<${p}
4689
+ C = se`<${p}
4685
4690
  .field=${r}
4686
4691
  .value=${o}
4687
4692
  .disabled=${c}
4688
4693
  .readonly=${m}
4689
- .required=${a.required}
4694
+ .required=${s.required}
4690
4695
  .showOptional=${this.showOptional}
4691
- .error=${s}
4696
+ .error=${a}
4692
4697
  .debounce=${$}
4693
4698
  @baht-input=${_}
4694
4699
  ></${p}>`;
4695
4700
  const g = this.fieldMessages[t.key];
4696
4701
  return l`<div
4697
- class="baht-field ${i} ${a.visible ? "" : "baht-field--hidden"}"
4702
+ class="baht-field ${i} ${s.visible ? "" : "baht-field--hidden"}"
4698
4703
  data-key=${t.key}
4699
4704
  data-type=${t.type}
4700
4705
  data-testid="${this.form.form_id}.${t.key}"
@@ -4715,14 +4720,14 @@ let z = class extends y {
4715
4720
  */
4716
4721
  onControlInput(t, e) {
4717
4722
  var i;
4718
- const a = (i = this.effectiveForm) == null ? void 0 : i.fields.find((s) => s.key === t);
4719
- a && this.onFieldInput(a, e);
4723
+ const s = (i = this.effectiveForm) == null ? void 0 : i.fields.find((a) => a.key === t);
4724
+ s && this.onFieldInput(s, e);
4720
4725
  }
4721
- renderReadonlyField(t, e, a) {
4722
- const i = t.options_from ? this.dynamicOptions.get(t.key) ?? t.options ?? [] : t.options, s = ks(t, this.valueFor(t), i), r = s.kind === "empty" ? l`<span class="baht-readonly-value baht-readonly-value--empty">${u("emptyValue")}</span>` : s.kind === "text" ? l`<span class="baht-readonly-value">${s.text}</span>` : s.kind === "chips" ? l`<span class="baht-readonly-value baht-readonly-chips"
4723
- >${s.items.map((o) => l`<span class="baht-readonly-chip">${o}</span>`)}</span
4726
+ renderReadonlyField(t, e, s) {
4727
+ const i = t.options_from ? this.dynamicOptions.get(t.key) ?? t.options ?? [] : t.options, a = Os(t, this.valueFor(t), i), r = a.kind === "empty" ? l`<span class="baht-readonly-value baht-readonly-value--empty">${u("emptyValue")}</span>` : a.kind === "text" ? l`<span class="baht-readonly-value">${a.text}</span>` : a.kind === "chips" ? l`<span class="baht-readonly-value baht-readonly-chips"
4728
+ >${a.items.map((o) => l`<span class="baht-readonly-chip">${o}</span>`)}</span
4724
4729
  >` : l`<div class="baht-readonly-rows">
4725
- ${s.rows.map(
4730
+ ${a.rows.map(
4726
4731
  (o) => l`<div class="baht-readonly-row">
4727
4732
  ${o.map(
4728
4733
  (c) => l`<span class="baht-readonly-cell"
@@ -4734,7 +4739,7 @@ let z = class extends y {
4734
4739
  )}
4735
4740
  </div>`;
4736
4741
  return l`<div
4737
- class="baht-field ${e} baht-field--readonly ${a ? "" : "baht-field--hidden"}"
4742
+ class="baht-field ${e} baht-field--readonly ${s ? "" : "baht-field--hidden"}"
4738
4743
  data-key=${t.key}
4739
4744
  data-type=${t.type}
4740
4745
  data-testid="${this.form.form_id}.${t.key}"
@@ -4808,10 +4813,10 @@ U([
4808
4813
  z = U([
4809
4814
  f("baht-form")
4810
4815
  ], z);
4811
- var Ei = Object.defineProperty, Li = Object.getOwnPropertyDescriptor, V = (t, e, a, i) => {
4812
- for (var s = i > 1 ? void 0 : i ? Li(e, a) : e, r = t.length - 1, o; r >= 0; r--)
4813
- (o = t[r]) && (s = (i ? o(e, a, s) : o(s)) || s);
4814
- return i && s && Ei(e, a, s), s;
4816
+ var Li = Object.defineProperty, Ni = Object.getOwnPropertyDescriptor, V = (t, e, s, i) => {
4817
+ for (var a = i > 1 ? void 0 : i ? Ni(e, s) : e, r = t.length - 1, o; r >= 0; r--)
4818
+ (o = t[r]) && (a = (i ? o(e, s, a) : o(a)) || a);
4819
+ return i && a && Li(e, s, a), a;
4815
4820
  };
4816
4821
  let N = class extends y {
4817
4822
  constructor() {
@@ -4828,19 +4833,19 @@ let N = class extends y {
4828
4833
  }), this.flagCache.out) : this.workflow;
4829
4834
  }
4830
4835
  willUpdate(t) {
4831
- var e, a;
4832
- t.has("workflow") || t.has("value") ? (this.data = structuredClone(this.value ?? {}), this.reevaluate(), this.history = [], this.current = ((e = this.visibleForms[0]) == null ? void 0 : e.form_name) ?? null, this.approvalError = null) : t.has("flags") && (this.reevaluate(), this.current && !this.visibleForms.some((i) => i.form_name === this.current) && (this.current = ((a = this.visibleForms[0]) == null ? void 0 : a.form_name) ?? null));
4836
+ var e, s;
4837
+ t.has("workflow") || t.has("value") ? (this.data = structuredClone(this.value ?? {}), this.reevaluate(), this.history = [], this.current = ((e = this.visibleForms[0]) == null ? void 0 : e.form_name) ?? null, this.approvalError = null) : t.has("flags") && (this.reevaluate(), this.current && !this.visibleForms.some((i) => i.form_name === this.current) && (this.current = ((s = this.visibleForms[0]) == null ? void 0 : s.form_name) ?? null));
4833
4838
  }
4834
4839
  reevaluate() {
4835
- this.derived = Os(this.effectiveWorkflow, this.data), this.data = this.derived.data;
4840
+ this.derived = Ps(this.effectiveWorkflow, this.data), this.data = this.derived.data;
4836
4841
  }
4837
4842
  /** Forms in ascending order whose derived visibility is true. */
4838
4843
  get visibleForms() {
4839
4844
  var e;
4840
- const t = [...((e = this.effectiveWorkflow) == null ? void 0 : e.forms) ?? []].sort((a, i) => a.order - i.order);
4841
- return this.derived ? t.filter((a) => {
4845
+ const t = [...((e = this.effectiveWorkflow) == null ? void 0 : e.forms) ?? []].sort((s, i) => s.order - i.order);
4846
+ return this.derived ? t.filter((s) => {
4842
4847
  var i;
4843
- return ((i = this.derived.forms[a.form_name]) == null ? void 0 : i.visible) !== !1;
4848
+ return ((i = this.derived.forms[s.form_name]) == null ? void 0 : i.visible) !== !1;
4844
4849
  }) : t;
4845
4850
  }
4846
4851
  get currentForm() {
@@ -4852,9 +4857,9 @@ let N = class extends y {
4852
4857
  if (!this.current) return "end";
4853
4858
  const t = this.effectiveWorkflow;
4854
4859
  if (t.transitions && t.transitions.length > 0)
4855
- return Ps(t, this.current, this.data);
4856
- const e = this.visibleForms, a = e.findIndex((s) => s.form_name === this.current);
4857
- return ((i = e[a + 1]) == null ? void 0 : i.form_name) ?? "end";
4860
+ return Cs(t, this.current, this.data);
4861
+ const e = this.visibleForms, s = e.findIndex((a) => a.form_name === this.current);
4862
+ return ((i = e[s + 1]) == null ? void 0 : i.form_name) ?? "end";
4858
4863
  }
4859
4864
  get isLast() {
4860
4865
  return this.current !== null && this.navTarget === "end";
@@ -4862,9 +4867,9 @@ let N = class extends y {
4862
4867
  fieldStatesFor(t) {
4863
4868
  const e = {};
4864
4869
  if (!this.derived) return e;
4865
- const a = `${t}.`;
4866
- for (const [i, s] of Object.entries(this.derived.fields))
4867
- i.startsWith(a) && (e[i.slice(a.length)] = s);
4870
+ const s = `${t}.`;
4871
+ for (const [i, a] of Object.entries(this.derived.fields))
4872
+ i.startsWith(s) && (e[i.slice(s.length)] = a);
4868
4873
  return e;
4869
4874
  }
4870
4875
  get formEl() {
@@ -4881,8 +4886,8 @@ let N = class extends y {
4881
4886
  * that re-feeding the `value` prop causes.
4882
4887
  */
4883
4888
  setValue(t, e) {
4884
- var a;
4885
- this.data = { ...this.data, [t]: { ...this.data[t], ...e } }, this.reevaluate(), this.current && !this.visibleForms.some((i) => i.form_name === this.current) && (this.current = ((a = this.visibleForms[0]) == null ? void 0 : a.form_name) ?? null), this.emit("baht-data-change", { data: this.getData() });
4889
+ var s;
4890
+ this.data = { ...this.data, [t]: { ...this.data[t], ...e } }, this.reevaluate(), this.current && !this.visibleForms.some((i) => i.form_name === this.current) && (this.current = ((s = this.visibleForms[0]) == null ? void 0 : s.form_name) ?? null), this.emit("baht-data-change", { data: this.getData() });
4886
4891
  }
4887
4892
  next() {
4888
4893
  const t = this.currentForm;
@@ -4896,20 +4901,20 @@ let N = class extends y {
4896
4901
  }
4897
4902
  /** Advance past the current form: submit+complete at 'end', else step to navTarget. */
4898
4903
  advance(t = {}) {
4899
- const e = { ...t, data: this.getData() }, a = this.navTarget;
4900
- if (a === "end") {
4904
+ const e = { ...t, data: this.getData() }, s = this.navTarget;
4905
+ if (s === "end") {
4901
4906
  this.emit("baht-submit", e), this.emit("baht-complete", { data: this.getData(), status: "completed" });
4902
4907
  return;
4903
4908
  }
4904
- const i = this.visibleForms.find((s) => s.form_name === a);
4909
+ const i = this.visibleForms.find((a) => a.form_name === s);
4905
4910
  if (!i || i.form_name === this.current) {
4906
- const s = i ? "self-transition" : "target-hidden";
4911
+ const a = i ? "self-transition" : "target-hidden";
4907
4912
  console.warn(
4908
- `[bahtui] cannot advance from "${this.current}": target "${a}" is ` + (i ? "the current form (self-transition)" : "not visible")
4913
+ `[bahtui] cannot advance from "${this.current}": target "${s}" is ` + (i ? "the current form (self-transition)" : "not visible")
4909
4914
  ), this.emit("baht-nav-blocked", {
4910
4915
  form_name: this.current,
4911
- target: a,
4912
- reason: s,
4916
+ target: s,
4917
+ reason: a,
4913
4918
  data: this.getData()
4914
4919
  });
4915
4920
  return;
@@ -4932,8 +4937,8 @@ let N = class extends y {
4932
4937
  var m;
4933
4938
  const e = this.currentForm;
4934
4939
  if (!e || e.kind !== "approval") return;
4935
- const a = e.approval ?? {}, i = String(((m = this.data[e.form_name]) == null ? void 0 : m.comment) ?? ""), s = a.comment ?? "optional";
4936
- if ((s === "required" || s === "requireOnReject" && t === "rejected") && i.trim() === "") {
4940
+ const s = e.approval ?? {}, i = String(((m = this.data[e.form_name]) == null ? void 0 : m.comment) ?? ""), a = s.comment ?? "optional";
4941
+ if ((a === "required" || a === "requireOnReject" && t === "rejected") && i.trim() === "") {
4937
4942
  this.approvalError = u("commentRequired");
4938
4943
  return;
4939
4944
  }
@@ -4947,23 +4952,23 @@ let N = class extends y {
4947
4952
  return;
4948
4953
  }
4949
4954
  this.emit("baht-reject", o);
4950
- const c = a.on_reject ?? { action: "end" };
4955
+ const c = s.on_reject ?? { action: "end" };
4951
4956
  c.action === "goto" && this.visibleForms.some(($) => $.form_name === c.form) ? this.gotoForm(c.form) : this.emit("baht-complete", { data: this.getData(), status: "rejected" });
4952
4957
  }
4953
4958
  /** Jump back to a visible form, truncating the history to that point. */
4954
4959
  gotoForm(t) {
4955
4960
  const e = this.history.indexOf(t);
4956
4961
  this.history = e >= 0 ? this.history.slice(0, e) : [], this.current = t;
4957
- const a = this.effectiveWorkflow.forms.find((i) => i.form_name === t);
4958
- this.emit("baht-step-change", { form_name: t, order: (a == null ? void 0 : a.order) ?? 0, direction: "back" });
4962
+ const s = this.effectiveWorkflow.forms.find((i) => i.form_name === t);
4963
+ this.emit("baht-step-change", { form_name: t, order: (s == null ? void 0 : s.order) ?? 0, direction: "back" });
4959
4964
  }
4960
4965
  back() {
4961
4966
  let t = this.history.pop();
4962
- for (; t !== void 0 && !this.visibleForms.some((a) => a.form_name === t); )
4967
+ for (; t !== void 0 && !this.visibleForms.some((s) => s.form_name === t); )
4963
4968
  t = this.history.pop();
4964
4969
  if (!t) return;
4965
4970
  this.current = t, this.approvalError = null;
4966
- const e = this.effectiveWorkflow.forms.find((a) => a.form_name === t);
4971
+ const e = this.effectiveWorkflow.forms.find((s) => s.form_name === t);
4967
4972
  this.emit("baht-step-change", { form_name: t, order: (e == null ? void 0 : e.order) ?? 0, direction: "back" });
4968
4973
  }
4969
4974
  gotoStart() {
@@ -4972,10 +4977,10 @@ let N = class extends y {
4972
4977
  }
4973
4978
  // ---- internal ----
4974
4979
  onFormChange(t) {
4975
- var s;
4980
+ var a;
4976
4981
  t.stopPropagation();
4977
- const { form_name: e, key: a, value: i } = t.detail;
4978
- this.data = { ...this.data, [e]: { ...this.data[e], [a]: i } }, this.reevaluate(), this.current && !this.visibleForms.some((r) => r.form_name === this.current) && (this.current = ((s = this.visibleForms[0]) == null ? void 0 : s.form_name) ?? null), this.emit("baht-data-change", { data: this.getData() });
4982
+ const { form_name: e, key: s, value: i } = t.detail;
4983
+ this.data = { ...this.data, [e]: { ...this.data[e], [s]: i } }, this.reevaluate(), this.current && !this.visibleForms.some((r) => r.form_name === this.current) && (this.current = ((a = this.visibleForms[0]) == null ? void 0 : a.form_name) ?? null), this.emit("baht-data-change", { data: this.getData() });
4979
4984
  }
4980
4985
  onCommentInput(t, e) {
4981
4986
  this.data = { ...this.data, [t]: { ...this.data[t], comment: e } }, this.reevaluate(), e.trim() !== "" && (this.approvalError = null), this.emit("baht-data-change", { data: this.getData() });
@@ -4984,17 +4989,17 @@ let N = class extends y {
4984
4989
  /** Forms the approval step summarizes: configured list, else every earlier plain form. */
4985
4990
  summary_forms(t) {
4986
4991
  var i;
4987
- const e = (i = t.approval) == null ? void 0 : i.summary_forms, a = this.visibleForms.filter(
4988
- (s) => s.form_name !== t.form_name && s.kind !== "approval"
4992
+ const e = (i = t.approval) == null ? void 0 : i.summary_forms, s = this.visibleForms.filter(
4993
+ (a) => a.form_name !== t.form_name && a.kind !== "approval"
4989
4994
  );
4990
- return e ? a.filter((s) => e.includes(s.form_name)) : a.filter((s) => s.order < t.order);
4995
+ return e ? s.filter((a) => e.includes(a.form_name)) : s.filter((a) => a.order < t.order);
4991
4996
  }
4992
4997
  renderApproval(t) {
4993
- var i, s;
4994
- const e = ((i = t.approval) == null ? void 0 : i.comment) ?? "optional", a = this.summary_forms(t);
4998
+ var i, a;
4999
+ const e = ((i = t.approval) == null ? void 0 : i.comment) ?? "optional", s = this.summary_forms(t);
4995
5000
  return l`<div class="baht-approval">
4996
5001
  <div class="baht-approval-summary">
4997
- ${a.length === 0 ? l`<p class="baht-approval-empty">${u("nothingToReview")}</p>` : a.map(
5002
+ ${s.length === 0 ? l`<p class="baht-approval-empty">${u("nothingToReview")}</p>` : s.map(
4998
5003
  (r) => l`<section class="baht-approval-group">
4999
5004
  <h4 class="baht-approval-group-title">${r.form_name}</h4>
5000
5005
  <baht-form
@@ -5014,7 +5019,7 @@ let N = class extends y {
5014
5019
  rows="3"
5015
5020
  aria-required=${e === "required" ? "true" : h}
5016
5021
  aria-invalid=${this.approvalError ? "true" : h}
5017
- .value=${String(((s = this.data[t.form_name]) == null ? void 0 : s.comment) ?? "")}
5022
+ .value=${String(((a = this.data[t.form_name]) == null ? void 0 : a.comment) ?? "")}
5018
5023
  @input=${(r) => this.onCommentInput(t.form_name, r.target.value)}
5019
5024
  ></textarea>
5020
5025
  </label>` : h}
@@ -5022,20 +5027,20 @@ let N = class extends y {
5022
5027
  </div>`;
5023
5028
  }
5024
5029
  render() {
5025
- var s, r;
5030
+ var a, r;
5026
5031
  const t = this.currentForm;
5027
5032
  if (!t) return l`<div class="baht-workflow"></div>`;
5028
- const e = t.kind === "approval", a = this.visibleForms, i = a.findIndex((o) => o.form_name === t.form_name);
5033
+ const e = t.kind === "approval", s = this.visibleForms, i = s.findIndex((o) => o.form_name === t.form_name);
5029
5034
  return l`<div
5030
5035
  class="baht-workflow"
5031
5036
  data-step=${t.form_name}
5032
5037
  data-testid="${this.workflow.workflow_id}.${t.form_name}"
5033
5038
  >
5034
5039
  <div class="baht-visually-hidden" role="status">
5035
- ${u("step", { current: i + 1, total: a.length })}
5040
+ ${u("step", { current: i + 1, total: s.length })}
5036
5041
  </div>
5037
5042
  ${this.showSteps ? l`<baht-steps
5038
- .steps=${a.map((o) => o.form_name)}
5043
+ .steps=${s.map((o) => o.form_name)}
5039
5044
  .current=${i}
5040
5045
  .variant=${this.stepsVariant}
5041
5046
  ></baht-steps>` : h}
@@ -5060,7 +5065,7 @@ let N = class extends y {
5060
5065
  data-testid="${this.workflow.workflow_id}.reject"
5061
5066
  @click=${() => this.decide("rejected")}
5062
5067
  >
5063
- ${((s = t.approval) == null ? void 0 : s.reject_label) ?? u("reject")}
5068
+ ${((a = t.approval) == null ? void 0 : a.reject_label) ?? u("reject")}
5064
5069
  </button>
5065
5070
  <button
5066
5071
  type="button"
@@ -5133,24 +5138,24 @@ export {
5133
5138
  St as B,
5134
5139
  ht as C,
5135
5140
  Pt as D,
5136
- Xe as E,
5141
+ Ye as E,
5137
5142
  lt as F,
5138
5143
  vt as G,
5139
5144
  A as H,
5140
5145
  Ae as I,
5141
- je as J,
5146
+ Te as J,
5142
5147
  ne as K,
5143
- Ut as L,
5148
+ Kt as L,
5144
5149
  ct as M,
5145
5150
  oe as N,
5146
5151
  W as O,
5147
- Ht as P,
5148
- Wt as Q,
5152
+ Ut as P,
5153
+ Gt as Q,
5149
5154
  x as R,
5150
- Ie as S,
5151
- Ue as T,
5155
+ Be as S,
5156
+ He as T,
5152
5157
  Me as U,
5153
- Ye as V,
5158
+ Ze as V,
5154
5159
  Ot as W,
5155
5160
  F as X,
5156
5161
  S as Y,
@@ -5158,34 +5163,34 @@ export {
5158
5163
  ys as _,
5159
5164
  mt as a,
5160
5165
  as as a0,
5161
- Qa as a1,
5166
+ ti as a1,
5162
5167
  zt as a2,
5163
5168
  he as a3,
5164
- Te as a4,
5169
+ je as a4,
5165
5170
  me as a5,
5166
- Kt as b,
5171
+ Vt as b,
5167
5172
  K as c,
5168
5173
  le as d,
5169
5174
  Ct as e,
5170
5175
  at as f,
5171
- Je as g,
5176
+ Xe as g,
5172
5177
  re as h,
5173
- Be as i,
5174
- Ze as j,
5178
+ Ie as i,
5179
+ Qe as j,
5175
5180
  Q as k,
5176
- Gt as l,
5177
- Bt as m,
5181
+ Ht as l,
5182
+ It as m,
5178
5183
  Dt as n,
5179
5184
  Mt as o,
5180
5185
  yt as p,
5181
5186
  z as q,
5182
5187
  pt as r,
5183
- Ke as s,
5188
+ Ue as s,
5184
5189
  dt as t,
5185
5190
  st as u,
5186
5191
  Ft as v,
5187
5192
  ot as w,
5188
5193
  J as x,
5189
- We as y,
5190
- He as z
5194
+ Je as y,
5195
+ Ge as z
5191
5196
  };