@burdenoff/microfe-govcitizenhub 2026.720.6 → 2026.730.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/dist/govcitizenhub/GovCitizenHubRoot.d.ts.map +1 -1
  2. package/dist/govcitizenhub/GovCitizenHubRoot.js +44 -36
  3. package/dist/govcitizenhub/GovCitizenHubRoot.js.map +1 -1
  4. package/dist/govcitizenhub/GovCitizenHubRoutes.d.ts.map +1 -1
  5. package/dist/govcitizenhub/GovCitizenHubRoutes.js +134 -6
  6. package/dist/govcitizenhub/GovCitizenHubRoutes.js.map +1 -1
  7. package/dist/govcitizenhub/components/DocumentUploadField.d.ts +17 -11
  8. package/dist/govcitizenhub/components/DocumentUploadField.d.ts.map +1 -1
  9. package/dist/govcitizenhub/components/DocumentUploadField.js +45 -42
  10. package/dist/govcitizenhub/components/DocumentUploadField.js.map +1 -1
  11. package/dist/govcitizenhub/components/GovCharts.js +127 -51
  12. package/dist/govcitizenhub/components/GovCharts.js.map +1 -1
  13. package/dist/govcitizenhub/hooks/index.d.ts +2 -0
  14. package/dist/govcitizenhub/hooks/index.d.ts.map +1 -1
  15. package/dist/govcitizenhub/hooks/index.js +2 -0
  16. package/dist/govcitizenhub/hooks/useGovApi.d.ts +23 -0
  17. package/dist/govcitizenhub/hooks/useGovApi.d.ts.map +1 -1
  18. package/dist/govcitizenhub/hooks/useGovApi.js +18 -7
  19. package/dist/govcitizenhub/hooks/useGovApi.js.map +1 -1
  20. package/dist/govcitizenhub/hooks/useGovCitizenHubAnalytics.d.ts +24 -0
  21. package/dist/govcitizenhub/hooks/useGovCitizenHubAnalytics.d.ts.map +1 -0
  22. package/dist/govcitizenhub/hooks/useGovCitizenHubAnalytics.js +40 -0
  23. package/dist/govcitizenhub/hooks/useGovCitizenHubAnalytics.js.map +1 -0
  24. package/dist/govcitizenhub/hooks/useIntelligenceApi.d.ts +214 -0
  25. package/dist/govcitizenhub/hooks/useIntelligenceApi.d.ts.map +1 -0
  26. package/dist/govcitizenhub/hooks/useIntelligenceApi.js +1140 -0
  27. package/dist/govcitizenhub/hooks/useIntelligenceApi.js.map +1 -0
  28. package/dist/govcitizenhub/index.d.ts +1 -0
  29. package/dist/govcitizenhub/index.d.ts.map +1 -1
  30. package/dist/govcitizenhub/index.js +18 -0
  31. package/dist/govcitizenhub/pages/agencies/AgenciesPage.js +7 -7
  32. package/dist/govcitizenhub/pages/agencies/AgencyFormDialog.js +6 -6
  33. package/dist/govcitizenhub/pages/applications/ApplicationDetailPage.d.ts.map +1 -1
  34. package/dist/govcitizenhub/pages/applications/ApplicationDetailPage.js +178 -172
  35. package/dist/govcitizenhub/pages/applications/ApplicationDetailPage.js.map +1 -1
  36. package/dist/govcitizenhub/pages/applications/ApplicationsPage.js +35 -35
  37. package/dist/govcitizenhub/pages/applications/ApplicationsPage.js.map +1 -1
  38. package/dist/govcitizenhub/pages/applications/NewApplicationPage.d.ts.map +1 -1
  39. package/dist/govcitizenhub/pages/applications/NewApplicationPage.js +151 -147
  40. package/dist/govcitizenhub/pages/applications/NewApplicationPage.js.map +1 -1
  41. package/dist/govcitizenhub/pages/documents/DocumentsPage.js +5 -5
  42. package/dist/govcitizenhub/pages/grievances/GrievanceDetailPage.js +30 -30
  43. package/dist/govcitizenhub/pages/grievances/GrievanceDetailPage.js.map +1 -1
  44. package/dist/govcitizenhub/pages/grievances/GrievancesPage.d.ts.map +1 -1
  45. package/dist/govcitizenhub/pages/grievances/GrievancesPage.js +176 -172
  46. package/dist/govcitizenhub/pages/grievances/GrievancesPage.js.map +1 -1
  47. package/dist/govcitizenhub/pages/intelligence/AdminLevelsPage.d.ts +4 -0
  48. package/dist/govcitizenhub/pages/intelligence/AdminLevelsPage.d.ts.map +1 -0
  49. package/dist/govcitizenhub/pages/intelligence/AdminLevelsPage.js +634 -0
  50. package/dist/govcitizenhub/pages/intelligence/AdminLevelsPage.js.map +1 -0
  51. package/dist/govcitizenhub/pages/intelligence/AssetFormDialog.d.ts +20 -0
  52. package/dist/govcitizenhub/pages/intelligence/AssetFormDialog.d.ts.map +1 -0
  53. package/dist/govcitizenhub/pages/intelligence/AssetFormDialog.js +537 -0
  54. package/dist/govcitizenhub/pages/intelligence/AssetFormDialog.js.map +1 -0
  55. package/dist/govcitizenhub/pages/intelligence/AssetImage.d.ts +11 -0
  56. package/dist/govcitizenhub/pages/intelligence/AssetImage.d.ts.map +1 -0
  57. package/dist/govcitizenhub/pages/intelligence/AssetImage.js +25 -0
  58. package/dist/govcitizenhub/pages/intelligence/AssetImage.js.map +1 -0
  59. package/dist/govcitizenhub/pages/intelligence/AssetMapPanel.d.ts +15 -0
  60. package/dist/govcitizenhub/pages/intelligence/AssetMapPanel.d.ts.map +1 -0
  61. package/dist/govcitizenhub/pages/intelligence/AssetMapPanel.js +203 -0
  62. package/dist/govcitizenhub/pages/intelligence/AssetMapPanel.js.map +1 -0
  63. package/dist/govcitizenhub/pages/intelligence/BenchmarkPage.d.ts +4 -0
  64. package/dist/govcitizenhub/pages/intelligence/BenchmarkPage.d.ts.map +1 -0
  65. package/dist/govcitizenhub/pages/intelligence/BenchmarkPage.js +497 -0
  66. package/dist/govcitizenhub/pages/intelligence/BenchmarkPage.js.map +1 -0
  67. package/dist/govcitizenhub/pages/intelligence/BudgetPage.d.ts +4 -0
  68. package/dist/govcitizenhub/pages/intelligence/BudgetPage.d.ts.map +1 -0
  69. package/dist/govcitizenhub/pages/intelligence/BudgetPage.js +1084 -0
  70. package/dist/govcitizenhub/pages/intelligence/BudgetPage.js.map +1 -0
  71. package/dist/govcitizenhub/pages/intelligence/ConsultationFormDialog.d.ts +13 -0
  72. package/dist/govcitizenhub/pages/intelligence/ConsultationFormDialog.d.ts.map +1 -0
  73. package/dist/govcitizenhub/pages/intelligence/ConsultationFormDialog.js +581 -0
  74. package/dist/govcitizenhub/pages/intelligence/ConsultationFormDialog.js.map +1 -0
  75. package/dist/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.d.ts +11 -0
  76. package/dist/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.d.ts.map +1 -0
  77. package/dist/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.js +429 -0
  78. package/dist/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.js.map +1 -0
  79. package/dist/govcitizenhub/pages/intelligence/ConsultationResultsPanel.d.ts +8 -0
  80. package/dist/govcitizenhub/pages/intelligence/ConsultationResultsPanel.d.ts.map +1 -0
  81. package/dist/govcitizenhub/pages/intelligence/ConsultationResultsPanel.js +235 -0
  82. package/dist/govcitizenhub/pages/intelligence/ConsultationResultsPanel.js.map +1 -0
  83. package/dist/govcitizenhub/pages/intelligence/ConsultationsPage.d.ts +4 -0
  84. package/dist/govcitizenhub/pages/intelligence/ConsultationsPage.d.ts.map +1 -0
  85. package/dist/govcitizenhub/pages/intelligence/ConsultationsPage.js +534 -0
  86. package/dist/govcitizenhub/pages/intelligence/ConsultationsPage.js.map +1 -0
  87. package/dist/govcitizenhub/pages/intelligence/CorrectionsPage.d.ts +4 -0
  88. package/dist/govcitizenhub/pages/intelligence/CorrectionsPage.d.ts.map +1 -0
  89. package/dist/govcitizenhub/pages/intelligence/CorrectionsPage.js +723 -0
  90. package/dist/govcitizenhub/pages/intelligence/CorrectionsPage.js.map +1 -0
  91. package/dist/govcitizenhub/pages/intelligence/ElectionsPage.d.ts +5 -0
  92. package/dist/govcitizenhub/pages/intelligence/ElectionsPage.d.ts.map +1 -0
  93. package/dist/govcitizenhub/pages/intelligence/ElectionsPage.js +1029 -0
  94. package/dist/govcitizenhub/pages/intelligence/ElectionsPage.js.map +1 -0
  95. package/dist/govcitizenhub/pages/intelligence/GovernancePage.d.ts +5 -0
  96. package/dist/govcitizenhub/pages/intelligence/GovernancePage.d.ts.map +1 -0
  97. package/dist/govcitizenhub/pages/intelligence/GovernancePage.js +1545 -0
  98. package/dist/govcitizenhub/pages/intelligence/GovernancePage.js.map +1 -0
  99. package/dist/govcitizenhub/pages/intelligence/IndicatorCatalogPage.d.ts +4 -0
  100. package/dist/govcitizenhub/pages/intelligence/IndicatorCatalogPage.d.ts.map +1 -0
  101. package/dist/govcitizenhub/pages/intelligence/IndicatorCatalogPage.js +960 -0
  102. package/dist/govcitizenhub/pages/intelligence/IndicatorCatalogPage.js.map +1 -0
  103. package/dist/govcitizenhub/pages/intelligence/IndicatorsPage.d.ts +13 -0
  104. package/dist/govcitizenhub/pages/intelligence/IndicatorsPage.d.ts.map +1 -0
  105. package/dist/govcitizenhub/pages/intelligence/IndicatorsPage.js +927 -0
  106. package/dist/govcitizenhub/pages/intelligence/IndicatorsPage.js.map +1 -0
  107. package/dist/govcitizenhub/pages/intelligence/JurisdictionDirectoryPage.d.ts +4 -0
  108. package/dist/govcitizenhub/pages/intelligence/JurisdictionDirectoryPage.d.ts.map +1 -0
  109. package/dist/govcitizenhub/pages/intelligence/JurisdictionDirectoryPage.js +620 -0
  110. package/dist/govcitizenhub/pages/intelligence/JurisdictionDirectoryPage.js.map +1 -0
  111. package/dist/govcitizenhub/pages/intelligence/JurisdictionLayout.d.ts +20 -0
  112. package/dist/govcitizenhub/pages/intelligence/JurisdictionLayout.d.ts.map +1 -0
  113. package/dist/govcitizenhub/pages/intelligence/JurisdictionLayout.js +183 -0
  114. package/dist/govcitizenhub/pages/intelligence/JurisdictionLayout.js.map +1 -0
  115. package/dist/govcitizenhub/pages/intelligence/JurisdictionProfilePage.d.ts +4 -0
  116. package/dist/govcitizenhub/pages/intelligence/JurisdictionProfilePage.d.ts.map +1 -0
  117. package/dist/govcitizenhub/pages/intelligence/JurisdictionProfilePage.js +629 -0
  118. package/dist/govcitizenhub/pages/intelligence/JurisdictionProfilePage.js.map +1 -0
  119. package/dist/govcitizenhub/pages/intelligence/OpenDataPage.d.ts +4 -0
  120. package/dist/govcitizenhub/pages/intelligence/OpenDataPage.d.ts.map +1 -0
  121. package/dist/govcitizenhub/pages/intelligence/OpenDataPage.js +1124 -0
  122. package/dist/govcitizenhub/pages/intelligence/OpenDataPage.js.map +1 -0
  123. package/dist/govcitizenhub/pages/intelligence/ProjectsPage.d.ts +4 -0
  124. package/dist/govcitizenhub/pages/intelligence/ProjectsPage.d.ts.map +1 -0
  125. package/dist/govcitizenhub/pages/intelligence/ProjectsPage.js +1518 -0
  126. package/dist/govcitizenhub/pages/intelligence/ProjectsPage.js.map +1 -0
  127. package/dist/govcitizenhub/pages/intelligence/PublicAssetsPage.d.ts +4 -0
  128. package/dist/govcitizenhub/pages/intelligence/PublicAssetsPage.d.ts.map +1 -0
  129. package/dist/govcitizenhub/pages/intelligence/PublicAssetsPage.js +577 -0
  130. package/dist/govcitizenhub/pages/intelligence/PublicAssetsPage.js.map +1 -0
  131. package/dist/govcitizenhub/pages/intelligence/ServicePerformancePage.d.ts +4 -0
  132. package/dist/govcitizenhub/pages/intelligence/ServicePerformancePage.d.ts.map +1 -0
  133. package/dist/govcitizenhub/pages/intelligence/ServicePerformancePage.js +534 -0
  134. package/dist/govcitizenhub/pages/intelligence/ServicePerformancePage.js.map +1 -0
  135. package/dist/govcitizenhub/pages/intelligence/TimelinePage.d.ts +5 -0
  136. package/dist/govcitizenhub/pages/intelligence/TimelinePage.d.ts.map +1 -0
  137. package/dist/govcitizenhub/pages/intelligence/TimelinePage.js +538 -0
  138. package/dist/govcitizenhub/pages/intelligence/TimelinePage.js.map +1 -0
  139. package/dist/govcitizenhub/pages/intelligence/consultationQuestions.d.ts +53 -0
  140. package/dist/govcitizenhub/pages/intelligence/consultationQuestions.d.ts.map +1 -0
  141. package/dist/govcitizenhub/pages/intelligence/consultationQuestions.js +138 -0
  142. package/dist/govcitizenhub/pages/intelligence/consultationQuestions.js.map +1 -0
  143. package/dist/govcitizenhub/pages/intelligence/index.d.ts +27 -0
  144. package/dist/govcitizenhub/pages/intelligence/index.d.ts.map +1 -0
  145. package/dist/govcitizenhub/pages/intelligence/index.js +17 -0
  146. package/dist/govcitizenhub/pages/payments/PaymentsPage.d.ts.map +1 -1
  147. package/dist/govcitizenhub/pages/payments/PaymentsPage.js +53 -49
  148. package/dist/govcitizenhub/pages/payments/PaymentsPage.js.map +1 -1
  149. package/dist/govcitizenhub/pages/permits/IssuePermitDialog.d.ts.map +1 -1
  150. package/dist/govcitizenhub/pages/permits/IssuePermitDialog.js +82 -76
  151. package/dist/govcitizenhub/pages/permits/IssuePermitDialog.js.map +1 -1
  152. package/dist/govcitizenhub/pages/permits/PermitsPage.d.ts.map +1 -1
  153. package/dist/govcitizenhub/pages/permits/PermitsPage.js +174 -120
  154. package/dist/govcitizenhub/pages/permits/PermitsPage.js.map +1 -1
  155. package/dist/govcitizenhub/pages/services/ServiceDetailPage.js +8 -8
  156. package/dist/govcitizenhub/pages/services/ServiceFormDialog.js +98 -98
  157. package/dist/govcitizenhub/pages/services/ServiceFormDialog.js.map +1 -1
  158. package/dist/govcitizenhub/types/index.d.ts +1 -0
  159. package/dist/govcitizenhub/types/index.d.ts.map +1 -1
  160. package/dist/govcitizenhub/types/intelligence.d.ts +1559 -0
  161. package/dist/govcitizenhub/types/intelligence.d.ts.map +1 -0
  162. package/dist/govcitizenhub/types/intelligence.js +125 -0
  163. package/dist/govcitizenhub/types/intelligence.js.map +1 -0
  164. package/dist/index.js +19 -2
  165. package/dist/node_modules/recharts/es6/chart/BarChart.js +24 -0
  166. package/dist/node_modules/recharts/es6/chart/BarChart.js.map +1 -0
  167. package/dist/utils/pageContext.d.ts +1 -0
  168. package/dist/utils/pageContext.d.ts.map +1 -1
  169. package/dist/utils/pageContext.js +44 -17
  170. package/dist/utils/pageContext.js.map +1 -1
  171. package/package.json +1 -1
@@ -0,0 +1,634 @@
1
+ import { useGovCitizenHub as e } from "../../context/GovCitizenHubContext.js";
2
+ import "../../context/index.js";
3
+ import { PageLayout as t } from "../../components/PageLayout.js";
4
+ import { formatNumber as n } from "../../utils/formatters.js";
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";
7
+ import "../../hooks/index.js";
8
+ import { ErrorView as s } from "../../components/StateViews.js";
9
+ import { SectionCard as c } from "../../components/SectionCard.js";
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";
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";
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) {
27
+ try {
28
+ let t = new Intl.DisplayNames(void 0, { type: "region" }).of(e);
29
+ return t && t !== e ? `${t} (${e})` : e;
30
+ } catch {
31
+ return e;
32
+ }
33
+ }
34
+ function L() {
35
+ let { navigateTo: ue } = e(), N = i(void 0, { limit: 200 }), F = f(() => {
36
+ let e = /* @__PURE__ */ new Set();
37
+ for (let t of N.data?.items ?? []) e.add(t.countryCode);
38
+ 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
47
+ });
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);
49
+ } catch (e) {
50
+ u.error("Could not seed the hierarchy", l(e));
51
+ }
52
+ }, we = async () => {
53
+ if (X) {
54
+ Q(null);
55
+ try {
56
+ await pe.mutateAsync(X.id), u.success("Tier removed", X.name), Z(null);
57
+ } catch (e) {
58
+ let t = l(e);
59
+ Q(`${X.name}: ${t}`), u.error("The tier was not removed", t);
60
+ }
61
+ }
62
+ }, Te = N.isLoading || B.isLoading, Ee = N.isError || B.isError;
63
+ return /* @__PURE__ */ S(t, {
64
+ title: "Administrative hierarchy",
65
+ description: "Define the administrative tiers each country is divided into. Jurisdiction profiles attach to these tiers.",
66
+ breadcrumbs: [{
67
+ label: "Community Intelligence",
68
+ onClick: () => ue("intelligence")
69
+ }, { label: "Administrative hierarchy" }],
70
+ actions: /* @__PURE__ */ S("div", {
71
+ className: "flex flex-wrap items-center gap-2",
72
+ children: [
73
+ /* @__PURE__ */ S(C, {
74
+ variant: "outline",
75
+ onClick: () => W(!0),
76
+ children: [/* @__PURE__ */ x(h, {
77
+ className: "mr-1.5 h-4 w-4",
78
+ "aria-hidden": "true"
79
+ }), " Add country"]
80
+ }),
81
+ /* @__PURE__ */ S(C, {
82
+ variant: "outline",
83
+ onClick: () => K(!0),
84
+ disabled: !z || U.isPending,
85
+ children: [/* @__PURE__ */ x(v, {
86
+ className: "mr-1.5 h-4 w-4",
87
+ "aria-hidden": "true"
88
+ }), " Seed hierarchy"]
89
+ }),
90
+ /* @__PURE__ */ S(C, {
91
+ onClick: () => {
92
+ Y(null), q(!0);
93
+ },
94
+ disabled: !z,
95
+ children: [/* @__PURE__ */ x(_, {
96
+ className: "mr-1.5 h-4 w-4",
97
+ "aria-hidden": "true"
98
+ }), " New tier"]
99
+ })
100
+ ]
101
+ }),
102
+ children: [
103
+ /* @__PURE__ */ S("div", {
104
+ 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, {
106
+ className: "mt-0.5 size-4 shrink-0 text-text-muted",
107
+ "aria-hidden": "true"
108
+ }), /* @__PURE__ */ S("p", {
109
+ className: "text-sm text-text-secondary",
110
+ 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",
112
+ " ",
113
+ /* @__PURE__ */ x("span", {
114
+ className: "font-medium",
115
+ children: "not official structures"
116
+ }),
117
+ ". Rename, re-rank or delete any seeded tier to match how this country is actually organised."
118
+ ]
119
+ })]
120
+ }),
121
+ /* @__PURE__ */ x(c, {
122
+ title: "Country",
123
+ icon: /* @__PURE__ */ x(h, {}),
124
+ className: "mb-4 border-border-seam",
125
+ children: F.length === 0 && !z ? /* @__PURE__ */ x("p", {
126
+ className: "text-sm text-text-secondary",
127
+ children: "No country is configured yet. Add one with its ISO 3166-1 alpha-2 code, then seed or hand-build its tiers."
128
+ }) : /* @__PURE__ */ S("div", {
129
+ className: "flex flex-wrap items-end gap-3",
130
+ children: [/* @__PURE__ */ S("div", {
131
+ className: "grid min-w-56 gap-1.5",
132
+ children: [/* @__PURE__ */ x(E, {
133
+ htmlFor: "admin-country",
134
+ children: "Configuring"
135
+ }), /* @__PURE__ */ S(ie, {
136
+ value: z,
137
+ onValueChange: R,
138
+ children: [/* @__PURE__ */ x(se, {
139
+ id: "admin-country",
140
+ "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, {
143
+ value: e,
144
+ children: I(e)
145
+ }, e)) })]
146
+ })]
147
+ }), /* @__PURE__ */ x("p", {
148
+ className: "text-sm text-text-muted",
149
+ children: $.length === 0 ? "No tiers configured for this country yet." : `${n($.length)} tier${$.length === 1 ? "" : "s"} configured, deepest rank ${$[$.length - 1].rank}.`
150
+ })]
151
+ })
152
+ }),
153
+ be && /* @__PURE__ */ S("div", {
154
+ 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, {
156
+ className: "mt-0.5 size-4 shrink-0 text-status-error-text",
157
+ "aria-hidden": "true"
158
+ }), /* @__PURE__ */ S("div", {
159
+ className: "min-w-0",
160
+ children: [
161
+ /* @__PURE__ */ x("p", {
162
+ className: "text-sm font-medium text-status-error-text",
163
+ children: "This tier was kept"
164
+ }),
165
+ /* @__PURE__ */ x("p", {
166
+ className: "mt-0.5 text-sm text-status-error-text",
167
+ children: be
168
+ }),
169
+ /* @__PURE__ */ x("p", {
170
+ className: "mt-1 text-xs text-status-error-text",
171
+ children: "Move the jurisdictions at this tier to another one (or remove them) and try again."
172
+ })
173
+ ]
174
+ })]
175
+ }),
176
+ Te ? /* @__PURE__ */ x("div", {
177
+ 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, {
180
+ message: "We couldn't load the administrative hierarchy.",
181
+ onRetry: () => {
182
+ N.refetch(), B.refetch();
183
+ }
184
+ }) : z ? $.length === 0 ? /* @__PURE__ */ x(r, {
185
+ illustration: "empty-data",
186
+ title: `No tiers configured for ${I(z)}`,
187
+ description: "Seed a preset chain and edit it into shape, or add each tier by hand.",
188
+ action: /* @__PURE__ */ S("div", {
189
+ className: "flex flex-wrap justify-center gap-2",
190
+ children: [/* @__PURE__ */ S(C, {
191
+ variant: "outline",
192
+ onClick: () => K(!0),
193
+ children: [/* @__PURE__ */ x(v, {
194
+ className: "mr-1.5 h-4 w-4",
195
+ "aria-hidden": "true"
196
+ }), " Seed hierarchy"]
197
+ }), /* @__PURE__ */ S(C, {
198
+ onClick: () => {
199
+ Y(null), q(!0);
200
+ },
201
+ children: [/* @__PURE__ */ x(_, {
202
+ className: "mr-1.5 h-4 w-4",
203
+ "aria-hidden": "true"
204
+ }), " New tier"]
205
+ })]
206
+ })
207
+ }) : /* @__PURE__ */ x(w, {
208
+ treatment: "plain",
209
+ className: "overflow-hidden border-border-seam p-0",
210
+ children: /* @__PURE__ */ x("div", {
211
+ className: "overflow-x-auto",
212
+ children: /* @__PURE__ */ S("table", {
213
+ className: "w-full text-left text-sm",
214
+ children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", {
215
+ className: "border-b border-border-seam text-xs uppercase tracking-wide text-text-muted",
216
+ children: [
217
+ /* @__PURE__ */ x("th", {
218
+ className: "px-4 py-3 font-medium",
219
+ children: "Rank"
220
+ }),
221
+ /* @__PURE__ */ x("th", {
222
+ className: "px-4 py-3 font-medium",
223
+ children: "Code"
224
+ }),
225
+ /* @__PURE__ */ x("th", {
226
+ className: "px-4 py-3 font-medium",
227
+ children: "Name"
228
+ }),
229
+ /* @__PURE__ */ x("th", {
230
+ className: "px-4 py-3 font-medium",
231
+ children: "Plural"
232
+ }),
233
+ /* @__PURE__ */ x("th", {
234
+ className: "px-4 py-3 font-medium",
235
+ children: "Electoral"
236
+ }),
237
+ /* @__PURE__ */ x("th", {
238
+ className: "px-4 py-3 text-right font-medium",
239
+ children: "Jurisdictions"
240
+ }),
241
+ /* @__PURE__ */ x("th", {
242
+ className: "px-4 py-3 text-right font-medium",
243
+ children: "Actions"
244
+ })
245
+ ]
246
+ }) }), /* @__PURE__ */ x("tbody", {
247
+ className: "divide-y divide-border-subtle",
248
+ children: $.map((e) => /* @__PURE__ */ S("tr", {
249
+ className: "transition-colors hover:bg-bg-sunken",
250
+ children: [
251
+ /* @__PURE__ */ x("td", {
252
+ className: "whitespace-nowrap px-4 py-3 align-top",
253
+ children: /* @__PURE__ */ x("span", {
254
+ className: "inline-flex size-7 items-center justify-center rounded-lg bg-bg-sunken text-xs font-semibold text-text-secondary tabular-nums",
255
+ children: e.rank
256
+ })
257
+ }),
258
+ /* @__PURE__ */ x("td", {
259
+ className: "whitespace-nowrap px-4 py-3 align-top font-mono text-xs text-text-secondary",
260
+ children: e.code
261
+ }),
262
+ /* @__PURE__ */ S("td", {
263
+ className: "px-4 py-3 align-top",
264
+ children: [/* @__PURE__ */ x("p", {
265
+ className: "font-medium text-text-primary",
266
+ children: e.name
267
+ }), e.description && /* @__PURE__ */ x("p", {
268
+ className: "mt-0.5 max-w-md text-xs text-text-muted",
269
+ children: e.description
270
+ })]
271
+ }),
272
+ /* @__PURE__ */ x("td", {
273
+ className: "whitespace-nowrap px-4 py-3 align-top text-text-secondary",
274
+ children: e.pluralName
275
+ }),
276
+ /* @__PURE__ */ x("td", {
277
+ className: "whitespace-nowrap px-4 py-3 align-top",
278
+ children: e.isElectoral ? /* @__PURE__ */ S("span", {
279
+ className: "inline-flex items-center gap-1.5 rounded-full bg-status-success-bg-subtle px-2.5 py-0.5 text-xs font-medium text-status-success-text",
280
+ children: [/* @__PURE__ */ x(b, {
281
+ className: "size-3.5",
282
+ "aria-hidden": "true"
283
+ }), " Elects"]
284
+ }) : /* @__PURE__ */ S("span", {
285
+ 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, {
287
+ className: "size-3.5",
288
+ "aria-hidden": "true"
289
+ }), " Administrative"]
290
+ })
291
+ }),
292
+ /* @__PURE__ */ x("td", {
293
+ className: "whitespace-nowrap px-4 py-3 text-right align-top text-text-secondary tabular-nums",
294
+ children: n(e.jurisdictionCount)
295
+ }),
296
+ /* @__PURE__ */ x("td", {
297
+ className: "whitespace-nowrap px-4 py-3 align-top",
298
+ children: /* @__PURE__ */ S("div", {
299
+ className: "flex justify-end gap-1.5",
300
+ children: [/* @__PURE__ */ x(C, {
301
+ variant: "outline",
302
+ size: "sm",
303
+ "aria-label": `Edit ${e.name}`,
304
+ onClick: () => {
305
+ Y(e), q(!0);
306
+ },
307
+ children: /* @__PURE__ */ x(g, {
308
+ className: "h-4 w-4",
309
+ "aria-hidden": "true"
310
+ })
311
+ }), /* @__PURE__ */ x(C, {
312
+ variant: "outline",
313
+ size: "sm",
314
+ "aria-label": `Delete ${e.name}`,
315
+ onClick: () => {
316
+ Q(null), Z(e);
317
+ },
318
+ disabled: pe.isPending,
319
+ children: /* @__PURE__ */ x(y, {
320
+ className: "h-4 w-4",
321
+ "aria-hidden": "true"
322
+ })
323
+ })]
324
+ })
325
+ })
326
+ ]
327
+ }, e.id))
328
+ })]
329
+ })
330
+ })
331
+ }) : /* @__PURE__ */ x(r, {
332
+ illustration: "empty-data",
333
+ title: "No country configured yet",
334
+ description: "Add a country by its ISO 3166-1 alpha-2 code to start defining its administrative tiers.",
335
+ action: /* @__PURE__ */ S(C, {
336
+ onClick: () => W(!0),
337
+ children: [/* @__PURE__ */ x(h, {
338
+ className: "mr-1.5 h-4 w-4",
339
+ "aria-hidden": "true"
340
+ }), " Add country"]
341
+ })
342
+ }),
343
+ me && /* @__PURE__ */ x(D, {
344
+ open: !0,
345
+ onOpenChange: (e) => {
346
+ e || W(!1);
347
+ },
348
+ children: /* @__PURE__ */ S(O, {
349
+ className: "sm:max-w-md",
350
+ 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." })] }),
352
+ /* @__PURE__ */ S("div", {
353
+ className: "grid gap-1.5 py-2",
354
+ children: [
355
+ /* @__PURE__ */ x(E, {
356
+ htmlFor: "admin-country-code",
357
+ children: "Country code"
358
+ }),
359
+ /* @__PURE__ */ x(T, {
360
+ id: "admin-country-code",
361
+ value: G,
362
+ maxLength: 2,
363
+ onChange: (e) => he(e.target.value.toUpperCase()),
364
+ placeholder: "Two letters, e.g. the code in the ISO 3166-1 list"
365
+ }),
366
+ G && !P.test(G.trim()) && /* @__PURE__ */ x("p", {
367
+ className: "text-xs text-status-error-text",
368
+ children: "Enter exactly two letters — the ISO 3166-1 alpha-2 code."
369
+ }),
370
+ G && P.test(G.trim()) && /* @__PURE__ */ x("p", {
371
+ className: "text-xs text-text-muted",
372
+ children: I(G.trim().toUpperCase())
373
+ })
374
+ ]
375
+ }),
376
+ /* @__PURE__ */ S(A, { children: [/* @__PURE__ */ x(C, {
377
+ variant: "outline",
378
+ onClick: () => W(!1),
379
+ children: "Cancel"
380
+ }), /* @__PURE__ */ x(C, {
381
+ onClick: Se,
382
+ disabled: !P.test(G.trim()),
383
+ children: "Configure this country"
384
+ })] })
385
+ ]
386
+ })
387
+ }),
388
+ ge && /* @__PURE__ */ x(D, {
389
+ open: !0,
390
+ onOpenChange: (e) => {
391
+ !e && !U.isPending && K(!1);
392
+ },
393
+ children: /* @__PURE__ */ S(O, {
394
+ className: "sm:max-w-lg",
395
+ 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." })] }),
397
+ /* @__PURE__ */ x("div", {
398
+ className: "grid gap-2 py-2",
399
+ children: de.map((e) => {
400
+ let t = _e === e.value;
401
+ return /* @__PURE__ */ S("button", {
402
+ type: "button",
403
+ onClick: () => ve(e.value),
404
+ "aria-pressed": t,
405
+ 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);
414
+ })
415
+ }),
416
+ /* @__PURE__ */ S(A, { children: [/* @__PURE__ */ x(C, {
417
+ variant: "outline",
418
+ onClick: () => K(!1),
419
+ disabled: U.isPending,
420
+ children: "Cancel"
421
+ }), /* @__PURE__ */ x(C, {
422
+ onClick: () => {
423
+ Ce();
424
+ },
425
+ disabled: U.isPending,
426
+ children: U.isPending ? "Seeding…" : "Seed hierarchy"
427
+ })] })
428
+ ]
429
+ })
430
+ }),
431
+ ye && z && /* @__PURE__ */ x(fe, {
432
+ countryCode: z,
433
+ level: J,
434
+ defaultRank: xe,
435
+ busy: V.isPending || H.isPending,
436
+ onClose: () => q(!1),
437
+ onSubmit: async (e) => {
438
+ if (J) {
439
+ let t = await H.mutateAsync({
440
+ id: J.id,
441
+ input: {
442
+ rank: e.rank,
443
+ code: e.code,
444
+ name: e.name,
445
+ pluralName: e.pluralName,
446
+ description: e.description,
447
+ isElectoral: e.isElectoral
448
+ }
449
+ });
450
+ u.success("Tier updated", t.name);
451
+ } else {
452
+ let t = await V.mutateAsync({
453
+ countryCode: z,
454
+ rank: e.rank,
455
+ code: e.code,
456
+ name: e.name,
457
+ pluralName: e.pluralName,
458
+ description: e.description,
459
+ isElectoral: e.isElectoral
460
+ });
461
+ u.success("Tier added", t.name);
462
+ }
463
+ q(!1);
464
+ }
465
+ }, J?.id ?? `new-${z}`),
466
+ X && /* @__PURE__ */ x(d, {
467
+ open: !0,
468
+ onOpenChange: (e) => {
469
+ e || Z(null);
470
+ },
471
+ title: `Delete the “${X.name}” tier?`,
472
+ 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
+ confirmLabel: "Delete tier",
474
+ destructive: !0,
475
+ onConfirm: we
476
+ })
477
+ ]
478
+ });
479
+ }
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);
484
+ try {
485
+ await ee({
486
+ rank: v,
487
+ code: o.trim(),
488
+ name: c.trim(),
489
+ pluralName: d.trim(),
490
+ description: m.trim() || null,
491
+ isElectoral: h
492
+ });
493
+ } catch (e) {
494
+ _(l(e));
495
+ }
496
+ }
497
+ };
498
+ return /* @__PURE__ */ x(D, {
499
+ open: !0,
500
+ onOpenChange: (e) => {
501
+ !e && !r && i();
502
+ },
503
+ children: /* @__PURE__ */ S(O, {
504
+ className: "sm:max-w-lg",
505
+ children: [
506
+ /* @__PURE__ */ S(j, { children: [/* @__PURE__ */ x(M, { children: t ? `Edit the “${t.name}” tier` : "New administrative tier" }), /* @__PURE__ */ S(k, { children: [
507
+ "Tiers for ",
508
+ I(e),
509
+ ". Rank 0 is the national level and each step down increases it by one."
510
+ ] })] }),
511
+ /* @__PURE__ */ S("div", {
512
+ className: "grid gap-4 py-2 sm:grid-cols-2",
513
+ children: [
514
+ /* @__PURE__ */ S("div", {
515
+ className: "grid gap-1.5",
516
+ children: [
517
+ /* @__PURE__ */ x(E, {
518
+ htmlFor: "tier-rank",
519
+ children: "Rank"
520
+ }),
521
+ /* @__PURE__ */ x(T, {
522
+ id: "tier-rank",
523
+ type: "number",
524
+ min: "0",
525
+ step: "1",
526
+ value: a,
527
+ onChange: (e) => te(e.target.value)
528
+ }),
529
+ !y && a.trim() !== "" && /* @__PURE__ */ x("p", {
530
+ className: "text-xs text-status-error-text",
531
+ children: "Rank must be a whole number, 0 or more."
532
+ })
533
+ ]
534
+ }),
535
+ /* @__PURE__ */ S("div", {
536
+ className: "grid gap-1.5",
537
+ children: [
538
+ /* @__PURE__ */ x(E, {
539
+ htmlFor: "tier-code",
540
+ children: "Machine code"
541
+ }),
542
+ /* @__PURE__ */ x(T, {
543
+ id: "tier-code",
544
+ value: o,
545
+ onChange: (e) => s(e.target.value.toUpperCase()),
546
+ placeholder: "UPPER_SNAKE_CASE"
547
+ }),
548
+ o.trim() !== "" && !b && /* @__PURE__ */ x("p", {
549
+ className: "text-xs text-status-error-text",
550
+ children: "Use uppercase letters, numbers and underscores only."
551
+ })
552
+ ]
553
+ }),
554
+ /* @__PURE__ */ S("div", {
555
+ className: "grid gap-1.5",
556
+ children: [/* @__PURE__ */ x(E, {
557
+ htmlFor: "tier-name",
558
+ children: "Name (singular)"
559
+ }), /* @__PURE__ */ x(T, {
560
+ id: "tier-name",
561
+ value: c,
562
+ onChange: (e) => u(e.target.value),
563
+ placeholder: "What one unit at this tier is called"
564
+ })]
565
+ }),
566
+ /* @__PURE__ */ S("div", {
567
+ className: "grid gap-1.5",
568
+ children: [/* @__PURE__ */ x(E, {
569
+ htmlFor: "tier-plural",
570
+ children: "Name (plural)"
571
+ }), /* @__PURE__ */ x(T, {
572
+ id: "tier-plural",
573
+ value: d,
574
+ onChange: (e) => f(e.target.value),
575
+ placeholder: "What several of them are called"
576
+ })]
577
+ }),
578
+ /* @__PURE__ */ S("div", {
579
+ className: "grid gap-1.5 sm:col-span-2",
580
+ children: [/* @__PURE__ */ x(E, {
581
+ htmlFor: "tier-description",
582
+ children: "Description"
583
+ }), /* @__PURE__ */ x(N, {
584
+ id: "tier-description",
585
+ value: m,
586
+ onChange: (e) => ne(e.target.value),
587
+ rows: 2,
588
+ placeholder: "Optional note about what this tier is responsible for"
589
+ })]
590
+ }),
591
+ /* @__PURE__ */ S("div", {
592
+ className: "flex items-center justify-between gap-3 rounded-lg border border-border-seam px-3 py-2.5 sm:col-span-2",
593
+ children: [/* @__PURE__ */ S("div", {
594
+ className: "min-w-0",
595
+ children: [/* @__PURE__ */ x(E, {
596
+ htmlFor: "tier-electoral",
597
+ children: "Elects representatives"
598
+ }), /* @__PURE__ */ x("p", {
599
+ className: "mt-0.5 text-xs text-text-muted",
600
+ children: "Turn on when units at this tier hold elections for their own office holders."
601
+ })]
602
+ }), /* @__PURE__ */ x(ue, {
603
+ id: "tier-electoral",
604
+ checked: h,
605
+ onCheckedChange: re,
606
+ "aria-label": "Elects representatives"
607
+ })]
608
+ }),
609
+ g && /* @__PURE__ */ x("p", {
610
+ 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
612
+ })
613
+ ]
614
+ }),
615
+ /* @__PURE__ */ S(A, { children: [/* @__PURE__ */ x(C, {
616
+ variant: "outline",
617
+ onClick: i,
618
+ disabled: r,
619
+ children: "Cancel"
620
+ }), /* @__PURE__ */ x(C, {
621
+ onClick: () => {
622
+ ie();
623
+ },
624
+ disabled: !w || r,
625
+ children: r ? "Saving…" : t ? "Save changes" : "Add tier"
626
+ })] })
627
+ ]
628
+ })
629
+ });
630
+ };
631
+ //#endregion
632
+ export { L as AdminLevelsPage };
633
+
634
+ //# sourceMappingURL=AdminLevelsPage.js.map