@burdenoff/microfe-govcitizenhub 2026.730.2 → 2026.730.3

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.
@@ -3,27 +3,19 @@ import "../../context/index.js";
3
3
  import { PageLayout as t } from "../../components/PageLayout.js";
4
4
  import { formatNumber as n } from "../../utils/formatters.js";
5
5
  import { EmptyState as r } from "../../components/EmptyState.js";
6
- import { useGovAdminLevels as i, useGovCreateAdminLevel as ee, useGovDeleteAdminLevel as a, useGovSeedAdminLevels as te, useGovUpdateAdminLevel as o } from "../../hooks/useIntelligenceApi.js";
6
+ import { useGovAdminLevelPresets as i, useGovAdminLevels as a, useGovCreateAdminLevel as o, useGovDeleteAdminLevel as ee, useGovSeedAdminLevels as s, useGovUpdateAdminLevel as te } from "../../hooks/useIntelligenceApi.js";
7
7
  import "../../hooks/index.js";
8
- import { ErrorView as s } from "../../components/StateViews.js";
9
- import { SectionCard as c } from "../../components/SectionCard.js";
8
+ import { ErrorView as c } from "../../components/StateViews.js";
9
+ import { SectionCard as ne } from "../../components/SectionCard.js";
10
10
  import { describeError as l, notify as u } from "../../lib/toast.js";
11
- import { ConfirmDialog as d } from "../../components/ConfirmDialog.js";
12
- import { useMemo as f, useState as p } from "react";
13
- import { AlertTriangle as m, Building2 as ne, Globe2 as h, Info as re, Pencil as g, Plus as _, Sparkles as v, Trash2 as y, Vote as b } from "lucide-react";
11
+ import { ConfirmDialog as re } from "../../components/ConfirmDialog.js";
12
+ import { useMemo as d, useState as f } from "react";
13
+ import { AlertTriangle as ie, Building2 as p, Globe2 as m, Info as h, Pencil as g, Plus as _, Sparkles as v, Trash2 as y, Vote as b } from "lucide-react";
14
14
  import { jsx as x, jsxs as S } from "react/jsx-runtime";
15
- import { Button as C, GlassCard as w, Input as T, Label as E, ResponsiveDialog as D, ResponsiveDialogContent as O, ResponsiveDialogDescription as k, ResponsiveDialogFooter as A, ResponsiveDialogHeader as j, ResponsiveDialogTitle as M, Select as ie, SelectContent as ae, SelectItem as oe, SelectTrigger as se, SelectValue as ce, Skeleton as le, Switch as ue, Textarea as N } from "@burdenoff/fe-libs/ui";
15
+ import { Button as C, GlassCard as ae, Input as w, Label as T, ResponsiveDialog as E, ResponsiveDialogContent as D, ResponsiveDialogDescription as O, ResponsiveDialogFooter as k, ResponsiveDialogHeader as A, ResponsiveDialogTitle as j, Select as oe, SelectContent as se, SelectItem as ce, SelectTrigger as le, SelectValue as ue, Skeleton as de, Switch as fe, Textarea as M } from "@burdenoff/fe-libs/ui";
16
16
  //#region src/govcitizenhub/pages/intelligence/AdminLevelsPage.tsx
17
- var de = [{
18
- value: "generic",
19
- label: "Generic (unitary)",
20
- description: "A single descending chain from the national level down to the smallest local unit."
21
- }, {
22
- value: "federal",
23
- label: "Federal",
24
- description: "A federal chain whose middle tiers are themselves electoral."
25
- }], P = /^[A-Za-z]{2}$/, F = /^[A-Z0-9_]+$/;
26
- function I(e) {
17
+ var N = /^[A-Za-z]{2}$/, P = /^[A-Z0-9_]+$/;
18
+ function F(e) {
27
19
  try {
28
20
  let t = new Intl.DisplayNames(void 0, { type: "region" }).of(e);
29
21
  return t && t !== e ? `${t} (${e})` : e;
@@ -31,57 +23,57 @@ function I(e) {
31
23
  return e;
32
24
  }
33
25
  }
34
- function L() {
35
- let { navigateTo: ue } = e(), N = i(void 0, { limit: 200 }), F = f(() => {
26
+ function pe() {
27
+ let { navigateTo: fe } = e(), M = a(void 0, { limit: 200 }), P = d(() => {
36
28
  let e = /* @__PURE__ */ new Set();
37
- for (let t of N.data?.items ?? []) e.add(t.countryCode);
29
+ for (let t of M.data?.items ?? []) e.add(t.countryCode);
38
30
  return [...e].sort((e, t) => e.localeCompare(t));
39
- }, [N.data]), [L, R] = p(""), z = L || F[0] || "", B = i(z || void 0, { limit: 100 }), V = ee(), H = o(), pe = a(), U = te(), [me, W] = p(!1), [G, he] = p(""), [ge, K] = p(!1), [_e, ve] = p(de[0].value), [ye, q] = p(!1), [J, Y] = p(null), [X, Z] = p(null), [be, Q] = p(null), $ = f(() => [...B.data?.items ?? []].sort((e, t) => e.rank - t.rank), [B.data]), xe = $.length === 0 ? 0 : Math.max(...$.map((e) => e.rank)) + 1, Se = () => {
40
- let e = G.trim().toUpperCase();
41
- P.test(e) && (R(e), he(""), W(!1));
42
- }, Ce = async () => {
43
- if (z) try {
44
- let e = await U.mutateAsync({
45
- countryCode: z,
46
- preset: _e
31
+ }, [M.data]), [pe, I] = f(""), L = pe || P[0] || "", R = a(L || void 0, { limit: 100 }), z = o(), B = te(), he = ee(), V = s(), [ge, H] = f(!1), [U, _e] = f(""), [ve, W] = f(!1), [G, ye] = f(""), K = i(L), [be, q] = f(!1), [J, Y] = f(null), [X, Z] = f(null), [xe, Q] = f(null), $ = d(() => [...R.data?.items ?? []].sort((e, t) => e.rank - t.rank), [R.data]), Se = $.length === 0 ? 0 : Math.max(...$.map((e) => e.rank)) + 1, Ce = () => {
32
+ let e = U.trim().toUpperCase();
33
+ N.test(e) && (I(e), _e(""), H(!1));
34
+ }, we = async () => {
35
+ if (L) try {
36
+ let e = await V.mutateAsync({
37
+ countryCode: L,
38
+ preset: G || void 0
47
39
  });
48
- u.success("Hierarchy seeded", `${n(e.length)} tier${e.length === 1 ? "" : "s"} are now configured for ${I(z)}. Rename or re-rank them to match the real structure.`), K(!1);
40
+ u.success("Hierarchy seeded", `${n(e.length)} tier${e.length === 1 ? "" : "s"} are now configured for ${F(L)}. Rename or re-rank them to match the real structure.`), W(!1);
49
41
  } catch (e) {
50
42
  u.error("Could not seed the hierarchy", l(e));
51
43
  }
52
- }, we = async () => {
44
+ }, Te = async () => {
53
45
  if (X) {
54
46
  Q(null);
55
47
  try {
56
- await pe.mutateAsync(X.id), u.success("Tier removed", X.name), Z(null);
48
+ await he.mutateAsync(X.id), u.success("Tier removed", X.name), Z(null);
57
49
  } catch (e) {
58
50
  let t = l(e);
59
51
  Q(`${X.name}: ${t}`), u.error("The tier was not removed", t);
60
52
  }
61
53
  }
62
- }, Te = N.isLoading || B.isLoading, Ee = N.isError || B.isError;
54
+ }, Ee = M.isLoading || R.isLoading, De = M.isError || R.isError;
63
55
  return /* @__PURE__ */ S(t, {
64
56
  title: "Administrative hierarchy",
65
57
  description: "Define the administrative tiers each country is divided into. Jurisdiction profiles attach to these tiers.",
66
58
  breadcrumbs: [{
67
59
  label: "Community Intelligence",
68
- onClick: () => ue("intelligence")
60
+ onClick: () => fe("intelligence")
69
61
  }, { label: "Administrative hierarchy" }],
70
62
  actions: /* @__PURE__ */ S("div", {
71
63
  className: "flex flex-wrap items-center gap-2",
72
64
  children: [
73
65
  /* @__PURE__ */ S(C, {
74
66
  variant: "outline",
75
- onClick: () => W(!0),
76
- children: [/* @__PURE__ */ x(h, {
67
+ onClick: () => H(!0),
68
+ children: [/* @__PURE__ */ x(m, {
77
69
  className: "mr-1.5 h-4 w-4",
78
70
  "aria-hidden": "true"
79
71
  }), " Add country"]
80
72
  }),
81
73
  /* @__PURE__ */ S(C, {
82
74
  variant: "outline",
83
- onClick: () => K(!0),
84
- disabled: !z || U.isPending,
75
+ onClick: () => W(!0),
76
+ disabled: !L || V.isPending,
85
77
  children: [/* @__PURE__ */ x(v, {
86
78
  className: "mr-1.5 h-4 w-4",
87
79
  "aria-hidden": "true"
@@ -91,7 +83,7 @@ function L() {
91
83
  onClick: () => {
92
84
  Y(null), q(!0);
93
85
  },
94
- disabled: !z,
86
+ disabled: !L,
95
87
  children: [/* @__PURE__ */ x(_, {
96
88
  className: "mr-1.5 h-4 w-4",
97
89
  "aria-hidden": "true"
@@ -102,46 +94,46 @@ function L() {
102
94
  children: [
103
95
  /* @__PURE__ */ S("div", {
104
96
  className: "mb-4 flex items-start gap-2.5 rounded-card border border-border-seam bg-bg-sunken px-4 py-3",
105
- children: [/* @__PURE__ */ x(re, {
97
+ children: [/* @__PURE__ */ x(h, {
106
98
  className: "mt-0.5 size-4 shrink-0 text-text-muted",
107
99
  "aria-hidden": "true"
108
100
  }), /* @__PURE__ */ S("p", {
109
101
  className: "text-sm text-text-secondary",
110
102
  children: [
111
- "The hierarchy is configuration, not code — every country defines its own chain of tiers here, and nothing in the product assumes one country’s structure. The seed presets are a starting point to save typing; they are",
103
+ "The hierarchy is configuration, not code — every country defines its own chain of tiers here. Seeding uses",
112
104
  " ",
113
105
  /* @__PURE__ */ x("span", {
114
106
  className: "font-medium",
115
- children: "not official structures"
107
+ children: "the terminology that country actually uses"
116
108
  }),
117
- ". Rename, re-rank or delete any seeded tier to match how this country is actually organised."
109
+ ": States and Districts for India, Counties and Sub-counties for Kenya, Local Government Areas for Nigeria. They are still only a starting point — administrative structures get reorganised and are genuinely ambiguous at the margins, so rename, re-rank or delete any seeded tier to match how this country is organised today."
118
110
  ]
119
111
  })]
120
112
  }),
121
- /* @__PURE__ */ x(c, {
113
+ /* @__PURE__ */ x(ne, {
122
114
  title: "Country",
123
- icon: /* @__PURE__ */ x(h, {}),
115
+ icon: /* @__PURE__ */ x(m, {}),
124
116
  className: "mb-4 border-border-seam",
125
- children: F.length === 0 && !z ? /* @__PURE__ */ x("p", {
117
+ children: P.length === 0 && !L ? /* @__PURE__ */ x("p", {
126
118
  className: "text-sm text-text-secondary",
127
119
  children: "No country is configured yet. Add one with its ISO 3166-1 alpha-2 code, then seed or hand-build its tiers."
128
120
  }) : /* @__PURE__ */ S("div", {
129
121
  className: "flex flex-wrap items-end gap-3",
130
122
  children: [/* @__PURE__ */ S("div", {
131
123
  className: "grid min-w-56 gap-1.5",
132
- children: [/* @__PURE__ */ x(E, {
124
+ children: [/* @__PURE__ */ x(T, {
133
125
  htmlFor: "admin-country",
134
126
  children: "Configuring"
135
- }), /* @__PURE__ */ S(ie, {
136
- value: z,
137
- onValueChange: R,
138
- children: [/* @__PURE__ */ x(se, {
127
+ }), /* @__PURE__ */ S(oe, {
128
+ value: L,
129
+ onValueChange: I,
130
+ children: [/* @__PURE__ */ x(le, {
139
131
  id: "admin-country",
140
132
  "aria-label": "Select country",
141
- children: /* @__PURE__ */ x(ce, {})
142
- }), /* @__PURE__ */ x(ae, { children: (F.includes(z) ? F : [z, ...F]).map((e) => /* @__PURE__ */ x(oe, {
133
+ children: /* @__PURE__ */ x(ue, {})
134
+ }), /* @__PURE__ */ x(se, { children: (P.includes(L) ? P : [L, ...P]).map((e) => /* @__PURE__ */ x(ce, {
143
135
  value: e,
144
- children: I(e)
136
+ children: F(e)
145
137
  }, e)) })]
146
138
  })]
147
139
  }), /* @__PURE__ */ x("p", {
@@ -150,9 +142,9 @@ function L() {
150
142
  })]
151
143
  })
152
144
  }),
153
- be && /* @__PURE__ */ S("div", {
145
+ xe && /* @__PURE__ */ S("div", {
154
146
  className: "mb-4 flex items-start gap-2.5 rounded-card bg-status-error-bg-subtle px-4 py-3",
155
- children: [/* @__PURE__ */ x(m, {
147
+ children: [/* @__PURE__ */ x(ie, {
156
148
  className: "mt-0.5 size-4 shrink-0 text-status-error-text",
157
149
  "aria-hidden": "true"
158
150
  }), /* @__PURE__ */ S("div", {
@@ -164,7 +156,7 @@ function L() {
164
156
  }),
165
157
  /* @__PURE__ */ x("p", {
166
158
  className: "mt-0.5 text-sm text-status-error-text",
167
- children: be
159
+ children: xe
168
160
  }),
169
161
  /* @__PURE__ */ x("p", {
170
162
  className: "mt-1 text-xs text-status-error-text",
@@ -173,23 +165,23 @@ function L() {
173
165
  ]
174
166
  })]
175
167
  }),
176
- Te ? /* @__PURE__ */ x("div", {
168
+ Ee ? /* @__PURE__ */ x("div", {
177
169
  className: "space-y-3",
178
- children: Array.from({ length: 5 }, (e, t) => /* @__PURE__ */ x(le, { className: "h-14 w-full rounded-card" }, t))
179
- }) : Ee ? /* @__PURE__ */ x(s, {
170
+ children: Array.from({ length: 5 }, (e, t) => /* @__PURE__ */ x(de, { className: "h-14 w-full rounded-card" }, t))
171
+ }) : De ? /* @__PURE__ */ x(c, {
180
172
  message: "We couldn't load the administrative hierarchy.",
181
173
  onRetry: () => {
182
- N.refetch(), B.refetch();
174
+ M.refetch(), R.refetch();
183
175
  }
184
- }) : z ? $.length === 0 ? /* @__PURE__ */ x(r, {
176
+ }) : L ? $.length === 0 ? /* @__PURE__ */ x(r, {
185
177
  illustration: "empty-data",
186
- title: `No tiers configured for ${I(z)}`,
178
+ title: `No tiers configured for ${F(L)}`,
187
179
  description: "Seed a preset chain and edit it into shape, or add each tier by hand.",
188
180
  action: /* @__PURE__ */ S("div", {
189
181
  className: "flex flex-wrap justify-center gap-2",
190
182
  children: [/* @__PURE__ */ S(C, {
191
183
  variant: "outline",
192
- onClick: () => K(!0),
184
+ onClick: () => W(!0),
193
185
  children: [/* @__PURE__ */ x(v, {
194
186
  className: "mr-1.5 h-4 w-4",
195
187
  "aria-hidden": "true"
@@ -204,7 +196,7 @@ function L() {
204
196
  }), " New tier"]
205
197
  })]
206
198
  })
207
- }) : /* @__PURE__ */ x(w, {
199
+ }) : /* @__PURE__ */ x(ae, {
208
200
  treatment: "plain",
209
201
  className: "overflow-hidden border-border-seam p-0",
210
202
  children: /* @__PURE__ */ x("div", {
@@ -283,7 +275,7 @@ function L() {
283
275
  }), " Elects"]
284
276
  }) : /* @__PURE__ */ S("span", {
285
277
  className: "inline-flex items-center gap-1.5 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs font-medium text-text-secondary",
286
- children: [/* @__PURE__ */ x(ne, {
278
+ children: [/* @__PURE__ */ x(p, {
287
279
  className: "size-3.5",
288
280
  "aria-hidden": "true"
289
281
  }), " Administrative"]
@@ -315,7 +307,7 @@ function L() {
315
307
  onClick: () => {
316
308
  Q(null), Z(e);
317
309
  },
318
- disabled: pe.isPending,
310
+ disabled: he.isPending,
319
311
  children: /* @__PURE__ */ x(y, {
320
312
  className: "h-4 w-4",
321
313
  "aria-hidden": "true"
@@ -333,110 +325,126 @@ function L() {
333
325
  title: "No country configured yet",
334
326
  description: "Add a country by its ISO 3166-1 alpha-2 code to start defining its administrative tiers.",
335
327
  action: /* @__PURE__ */ S(C, {
336
- onClick: () => W(!0),
337
- children: [/* @__PURE__ */ x(h, {
328
+ onClick: () => H(!0),
329
+ children: [/* @__PURE__ */ x(m, {
338
330
  className: "mr-1.5 h-4 w-4",
339
331
  "aria-hidden": "true"
340
332
  }), " Add country"]
341
333
  })
342
334
  }),
343
- me && /* @__PURE__ */ x(D, {
335
+ ge && /* @__PURE__ */ x(E, {
344
336
  open: !0,
345
337
  onOpenChange: (e) => {
346
- e || W(!1);
338
+ e || H(!1);
347
339
  },
348
- children: /* @__PURE__ */ S(O, {
340
+ children: /* @__PURE__ */ S(D, {
349
341
  className: "sm:max-w-md",
350
342
  children: [
351
- /* @__PURE__ */ S(j, { children: [/* @__PURE__ */ x(M, { children: "Add a country" }), /* @__PURE__ */ x(k, { children: "Countries are identified by their ISO 3166-1 alpha-2 code. Nothing is created until you add or seed a tier for it." })] }),
343
+ /* @__PURE__ */ S(A, { children: [/* @__PURE__ */ x(j, { children: "Add a country" }), /* @__PURE__ */ x(O, { children: "Countries are identified by their ISO 3166-1 alpha-2 code. Nothing is created until you add or seed a tier for it." })] }),
352
344
  /* @__PURE__ */ S("div", {
353
345
  className: "grid gap-1.5 py-2",
354
346
  children: [
355
- /* @__PURE__ */ x(E, {
347
+ /* @__PURE__ */ x(T, {
356
348
  htmlFor: "admin-country-code",
357
349
  children: "Country code"
358
350
  }),
359
- /* @__PURE__ */ x(T, {
351
+ /* @__PURE__ */ x(w, {
360
352
  id: "admin-country-code",
361
- value: G,
353
+ value: U,
362
354
  maxLength: 2,
363
- onChange: (e) => he(e.target.value.toUpperCase()),
355
+ onChange: (e) => _e(e.target.value.toUpperCase()),
364
356
  placeholder: "Two letters, e.g. the code in the ISO 3166-1 list"
365
357
  }),
366
- G && !P.test(G.trim()) && /* @__PURE__ */ x("p", {
358
+ U && !N.test(U.trim()) && /* @__PURE__ */ x("p", {
367
359
  className: "text-xs text-status-error-text",
368
360
  children: "Enter exactly two letters — the ISO 3166-1 alpha-2 code."
369
361
  }),
370
- G && P.test(G.trim()) && /* @__PURE__ */ x("p", {
362
+ U && N.test(U.trim()) && /* @__PURE__ */ x("p", {
371
363
  className: "text-xs text-text-muted",
372
- children: I(G.trim().toUpperCase())
364
+ children: F(U.trim().toUpperCase())
373
365
  })
374
366
  ]
375
367
  }),
376
- /* @__PURE__ */ S(A, { children: [/* @__PURE__ */ x(C, {
368
+ /* @__PURE__ */ S(k, { children: [/* @__PURE__ */ x(C, {
377
369
  variant: "outline",
378
- onClick: () => W(!1),
370
+ onClick: () => H(!1),
379
371
  children: "Cancel"
380
372
  }), /* @__PURE__ */ x(C, {
381
- onClick: Se,
382
- disabled: !P.test(G.trim()),
373
+ onClick: Ce,
374
+ disabled: !N.test(U.trim()),
383
375
  children: "Configure this country"
384
376
  })] })
385
377
  ]
386
378
  })
387
379
  }),
388
- ge && /* @__PURE__ */ x(D, {
380
+ ve && /* @__PURE__ */ x(E, {
389
381
  open: !0,
390
382
  onOpenChange: (e) => {
391
- !e && !U.isPending && K(!1);
383
+ !e && !V.isPending && W(!1);
392
384
  },
393
- children: /* @__PURE__ */ S(O, {
385
+ children: /* @__PURE__ */ S(D, {
394
386
  className: "sm:max-w-lg",
395
387
  children: [
396
- /* @__PURE__ */ S(j, { children: [/* @__PURE__ */ S(M, { children: ["Seed a hierarchy for ", I(z)] }), /* @__PURE__ */ x(k, { children: "Presets are a starting point, not an official structure. Seeding is additive and idempotent — a tier whose code already exists is left alone, and every seeded tier stays renameable, re-rankable and deletable." })] }),
388
+ /* @__PURE__ */ S(A, { children: [/* @__PURE__ */ S(j, { children: ["Seed a hierarchy for ", F(L)] }), /* @__PURE__ */ x(O, { children: "The country’s own structure is offered first, using its own terminology. Seeding is additive and idempotent — a tier whose code already exists is left alone, and every seeded tier stays renameable, re-rankable and deletable." })] }),
397
389
  /* @__PURE__ */ x("div", {
398
390
  className: "grid gap-2 py-2",
399
- children: de.map((e) => {
400
- let t = _e === e.value;
391
+ children: K.isLoading ? /* @__PURE__ */ x("p", {
392
+ className: "px-1 py-3 text-sm text-text-secondary",
393
+ children: "Loading hierarchies…"
394
+ }) : (K.data ?? []).length === 0 ? /* @__PURE__ */ x("p", {
395
+ className: "px-1 py-3 text-sm text-text-secondary",
396
+ children: "No preset is available for this country. Add each tier by hand instead."
397
+ }) : (K.data ?? []).map((e) => {
398
+ let t = G === e.key || G === "" && e.isCountrySpecific;
401
399
  return /* @__PURE__ */ S("button", {
402
400
  type: "button",
403
- onClick: () => ve(e.value),
401
+ onClick: () => ye(e.key),
404
402
  "aria-pressed": t,
405
403
  className: t ? "rounded-xl border border-action-primary-bg bg-bg-sunken px-4 py-3 text-left transition-colors" : "rounded-xl border border-border-seam bg-bg-surface px-4 py-3 text-left transition-colors hover:bg-bg-sunken",
406
- children: [/* @__PURE__ */ x("p", {
407
- className: "text-sm font-medium text-text-primary",
408
- children: e.label
409
- }), /* @__PURE__ */ x("p", {
410
- className: "mt-0.5 text-xs text-text-secondary",
411
- children: e.description
412
- })]
413
- }, e.value);
404
+ children: [
405
+ /* @__PURE__ */ S("p", {
406
+ className: "flex items-center gap-2 text-sm font-medium text-text-primary",
407
+ children: [e.label, e.isCountrySpecific ? /* @__PURE__ */ x("span", {
408
+ className: "rounded-full bg-bg-sunken px-2 py-0.5 text-[11px] font-normal text-text-secondary",
409
+ children: "This country’s own structure"
410
+ }) : null]
411
+ }),
412
+ /* @__PURE__ */ x("p", {
413
+ className: "mt-0.5 text-xs text-text-secondary",
414
+ children: e.description
415
+ }),
416
+ /* @__PURE__ */ x("p", {
417
+ className: "mt-1.5 text-xs text-text-tertiary",
418
+ children: e.tiers.map((e) => e.name).join(" › ")
419
+ })
420
+ ]
421
+ }, e.key);
414
422
  })
415
423
  }),
416
- /* @__PURE__ */ S(A, { children: [/* @__PURE__ */ x(C, {
424
+ /* @__PURE__ */ S(k, { children: [/* @__PURE__ */ x(C, {
417
425
  variant: "outline",
418
- onClick: () => K(!1),
419
- disabled: U.isPending,
426
+ onClick: () => W(!1),
427
+ disabled: V.isPending,
420
428
  children: "Cancel"
421
429
  }), /* @__PURE__ */ x(C, {
422
430
  onClick: () => {
423
- Ce();
431
+ we();
424
432
  },
425
- disabled: U.isPending,
426
- children: U.isPending ? "Seeding…" : "Seed hierarchy"
433
+ disabled: V.isPending,
434
+ children: V.isPending ? "Seeding…" : "Seed hierarchy"
427
435
  })] })
428
436
  ]
429
437
  })
430
438
  }),
431
- ye && z && /* @__PURE__ */ x(fe, {
432
- countryCode: z,
439
+ be && L && /* @__PURE__ */ x(me, {
440
+ countryCode: L,
433
441
  level: J,
434
- defaultRank: xe,
435
- busy: V.isPending || H.isPending,
442
+ defaultRank: Se,
443
+ busy: z.isPending || B.isPending,
436
444
  onClose: () => q(!1),
437
445
  onSubmit: async (e) => {
438
446
  if (J) {
439
- let t = await H.mutateAsync({
447
+ let t = await B.mutateAsync({
440
448
  id: J.id,
441
449
  input: {
442
450
  rank: e.rank,
@@ -449,8 +457,8 @@ function L() {
449
457
  });
450
458
  u.success("Tier updated", t.name);
451
459
  } else {
452
- let t = await V.mutateAsync({
453
- countryCode: z,
460
+ let t = await z.mutateAsync({
461
+ countryCode: L,
454
462
  rank: e.rank,
455
463
  code: e.code,
456
464
  name: e.name,
@@ -462,8 +470,8 @@ function L() {
462
470
  }
463
471
  q(!1);
464
472
  }
465
- }, J?.id ?? `new-${z}`),
466
- X && /* @__PURE__ */ x(d, {
473
+ }, J?.id ?? `new-${L}`),
474
+ X && /* @__PURE__ */ x(re, {
467
475
  open: !0,
468
476
  onOpenChange: (e) => {
469
477
  e || Z(null);
@@ -472,40 +480,40 @@ function L() {
472
480
  description: X.jurisdictionCount > 0 ? `${n(X.jurisdictionCount)} jurisdiction${X.jurisdictionCount === 1 ? "" : "s"} still sit at this tier, so the platform will refuse the deletion. Move or remove them first.` : "No jurisdiction sits at this tier, so it can be removed.",
473
481
  confirmLabel: "Delete tier",
474
482
  destructive: !0,
475
- onConfirm: we
483
+ onConfirm: Te
476
484
  })
477
485
  ]
478
486
  });
479
487
  }
480
- var fe = ({ countryCode: e, level: t, defaultRank: n, busy: r, onClose: i, onSubmit: ee }) => {
481
- let [a, te] = p(String(t?.rank ?? n)), [o, s] = p(t?.code ?? ""), [c, u] = p(t?.name ?? ""), [d, f] = p(t?.pluralName ?? ""), [m, ne] = p(t?.description ?? ""), [h, re] = p(t?.isElectoral ?? !1), [g, _] = p(null), v = Number(a), y = Number.isInteger(v) && v >= 0, b = F.test(o.trim()), w = y && b && !!c.trim() && !!d.trim(), ie = async () => {
482
- if (w) {
483
- _(null);
488
+ var me = ({ countryCode: e, level: t, defaultRank: n, busy: r, onClose: i, onSubmit: a }) => {
489
+ let [o, ee] = f(String(t?.rank ?? n)), [s, te] = f(t?.code ?? ""), [c, ne] = f(t?.name ?? ""), [u, re] = f(t?.pluralName ?? ""), [d, ie] = f(t?.description ?? ""), [p, m] = f(t?.isElectoral ?? !1), [h, g] = f(null), _ = Number(o), v = Number.isInteger(_) && _ >= 0, y = P.test(s.trim()), b = v && y && !!c.trim() && !!u.trim(), ae = async () => {
490
+ if (b) {
491
+ g(null);
484
492
  try {
485
- await ee({
486
- rank: v,
487
- code: o.trim(),
493
+ await a({
494
+ rank: _,
495
+ code: s.trim(),
488
496
  name: c.trim(),
489
- pluralName: d.trim(),
490
- description: m.trim() || null,
491
- isElectoral: h
497
+ pluralName: u.trim(),
498
+ description: d.trim() || null,
499
+ isElectoral: p
492
500
  });
493
501
  } catch (e) {
494
- _(l(e));
502
+ g(l(e));
495
503
  }
496
504
  }
497
505
  };
498
- return /* @__PURE__ */ x(D, {
506
+ return /* @__PURE__ */ x(E, {
499
507
  open: !0,
500
508
  onOpenChange: (e) => {
501
509
  !e && !r && i();
502
510
  },
503
- children: /* @__PURE__ */ S(O, {
511
+ children: /* @__PURE__ */ S(D, {
504
512
  className: "sm:max-w-lg",
505
513
  children: [
506
- /* @__PURE__ */ S(j, { children: [/* @__PURE__ */ x(M, { children: t ? `Edit the “${t.name}” tier` : "New administrative tier" }), /* @__PURE__ */ S(k, { children: [
514
+ /* @__PURE__ */ S(A, { children: [/* @__PURE__ */ x(j, { children: t ? `Edit the “${t.name}” tier` : "New administrative tier" }), /* @__PURE__ */ S(O, { children: [
507
515
  "Tiers for ",
508
- I(e),
516
+ F(e),
509
517
  ". Rank 0 is the national level and each step down increases it by one."
510
518
  ] })] }),
511
519
  /* @__PURE__ */ S("div", {
@@ -514,19 +522,19 @@ var fe = ({ countryCode: e, level: t, defaultRank: n, busy: r, onClose: i, onSub
514
522
  /* @__PURE__ */ S("div", {
515
523
  className: "grid gap-1.5",
516
524
  children: [
517
- /* @__PURE__ */ x(E, {
525
+ /* @__PURE__ */ x(T, {
518
526
  htmlFor: "tier-rank",
519
527
  children: "Rank"
520
528
  }),
521
- /* @__PURE__ */ x(T, {
529
+ /* @__PURE__ */ x(w, {
522
530
  id: "tier-rank",
523
531
  type: "number",
524
532
  min: "0",
525
533
  step: "1",
526
- value: a,
527
- onChange: (e) => te(e.target.value)
534
+ value: o,
535
+ onChange: (e) => ee(e.target.value)
528
536
  }),
529
- !y && a.trim() !== "" && /* @__PURE__ */ x("p", {
537
+ !v && o.trim() !== "" && /* @__PURE__ */ x("p", {
530
538
  className: "text-xs text-status-error-text",
531
539
  children: "Rank must be a whole number, 0 or more."
532
540
  })
@@ -535,17 +543,17 @@ var fe = ({ countryCode: e, level: t, defaultRank: n, busy: r, onClose: i, onSub
535
543
  /* @__PURE__ */ S("div", {
536
544
  className: "grid gap-1.5",
537
545
  children: [
538
- /* @__PURE__ */ x(E, {
546
+ /* @__PURE__ */ x(T, {
539
547
  htmlFor: "tier-code",
540
548
  children: "Machine code"
541
549
  }),
542
- /* @__PURE__ */ x(T, {
550
+ /* @__PURE__ */ x(w, {
543
551
  id: "tier-code",
544
- value: o,
545
- onChange: (e) => s(e.target.value.toUpperCase()),
552
+ value: s,
553
+ onChange: (e) => te(e.target.value.toUpperCase()),
546
554
  placeholder: "UPPER_SNAKE_CASE"
547
555
  }),
548
- o.trim() !== "" && !b && /* @__PURE__ */ x("p", {
556
+ s.trim() !== "" && !y && /* @__PURE__ */ x("p", {
549
557
  className: "text-xs text-status-error-text",
550
558
  children: "Use uppercase letters, numbers and underscores only."
551
559
  })
@@ -553,37 +561,37 @@ var fe = ({ countryCode: e, level: t, defaultRank: n, busy: r, onClose: i, onSub
553
561
  }),
554
562
  /* @__PURE__ */ S("div", {
555
563
  className: "grid gap-1.5",
556
- children: [/* @__PURE__ */ x(E, {
564
+ children: [/* @__PURE__ */ x(T, {
557
565
  htmlFor: "tier-name",
558
566
  children: "Name (singular)"
559
- }), /* @__PURE__ */ x(T, {
567
+ }), /* @__PURE__ */ x(w, {
560
568
  id: "tier-name",
561
569
  value: c,
562
- onChange: (e) => u(e.target.value),
570
+ onChange: (e) => ne(e.target.value),
563
571
  placeholder: "What one unit at this tier is called"
564
572
  })]
565
573
  }),
566
574
  /* @__PURE__ */ S("div", {
567
575
  className: "grid gap-1.5",
568
- children: [/* @__PURE__ */ x(E, {
576
+ children: [/* @__PURE__ */ x(T, {
569
577
  htmlFor: "tier-plural",
570
578
  children: "Name (plural)"
571
- }), /* @__PURE__ */ x(T, {
579
+ }), /* @__PURE__ */ x(w, {
572
580
  id: "tier-plural",
573
- value: d,
574
- onChange: (e) => f(e.target.value),
581
+ value: u,
582
+ onChange: (e) => re(e.target.value),
575
583
  placeholder: "What several of them are called"
576
584
  })]
577
585
  }),
578
586
  /* @__PURE__ */ S("div", {
579
587
  className: "grid gap-1.5 sm:col-span-2",
580
- children: [/* @__PURE__ */ x(E, {
588
+ children: [/* @__PURE__ */ x(T, {
581
589
  htmlFor: "tier-description",
582
590
  children: "Description"
583
- }), /* @__PURE__ */ x(N, {
591
+ }), /* @__PURE__ */ x(M, {
584
592
  id: "tier-description",
585
- value: m,
586
- onChange: (e) => ne(e.target.value),
593
+ value: d,
594
+ onChange: (e) => ie(e.target.value),
587
595
  rows: 2,
588
596
  placeholder: "Optional note about what this tier is responsible for"
589
597
  })]
@@ -592,36 +600,36 @@ var fe = ({ countryCode: e, level: t, defaultRank: n, busy: r, onClose: i, onSub
592
600
  className: "flex items-center justify-between gap-3 rounded-lg border border-border-seam px-3 py-2.5 sm:col-span-2",
593
601
  children: [/* @__PURE__ */ S("div", {
594
602
  className: "min-w-0",
595
- children: [/* @__PURE__ */ x(E, {
603
+ children: [/* @__PURE__ */ x(T, {
596
604
  htmlFor: "tier-electoral",
597
605
  children: "Elects representatives"
598
606
  }), /* @__PURE__ */ x("p", {
599
607
  className: "mt-0.5 text-xs text-text-muted",
600
608
  children: "Turn on when units at this tier hold elections for their own office holders."
601
609
  })]
602
- }), /* @__PURE__ */ x(ue, {
610
+ }), /* @__PURE__ */ x(fe, {
603
611
  id: "tier-electoral",
604
- checked: h,
605
- onCheckedChange: re,
612
+ checked: p,
613
+ onCheckedChange: m,
606
614
  "aria-label": "Elects representatives"
607
615
  })]
608
616
  }),
609
- g && /* @__PURE__ */ x("p", {
617
+ h && /* @__PURE__ */ x("p", {
610
618
  className: "rounded-lg bg-status-error-bg-subtle px-3 py-2 text-sm text-status-error-text sm:col-span-2",
611
- children: g
619
+ children: h
612
620
  })
613
621
  ]
614
622
  }),
615
- /* @__PURE__ */ S(A, { children: [/* @__PURE__ */ x(C, {
623
+ /* @__PURE__ */ S(k, { children: [/* @__PURE__ */ x(C, {
616
624
  variant: "outline",
617
625
  onClick: i,
618
626
  disabled: r,
619
627
  children: "Cancel"
620
628
  }), /* @__PURE__ */ x(C, {
621
629
  onClick: () => {
622
- ie();
630
+ ae();
623
631
  },
624
- disabled: !w || r,
632
+ disabled: !b || r,
625
633
  children: r ? "Saving…" : t ? "Save changes" : "Add tier"
626
634
  })] })
627
635
  ]
@@ -629,6 +637,6 @@ var fe = ({ countryCode: e, level: t, defaultRank: n, busy: r, onClose: i, onSub
629
637
  });
630
638
  };
631
639
  //#endregion
632
- export { L as AdminLevelsPage };
640
+ export { pe as AdminLevelsPage };
633
641
 
634
642
  //# sourceMappingURL=AdminLevelsPage.js.map