@burdenoff/microfe-healthybowl 2026.712.1 → 2026.713.2

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,22 +1,23 @@
1
1
  import { useHealthyBowl as e } from "../../context/HealthyBowlContext.js";
2
2
  import { formatDate as t } from "../../utils/helpers.js";
3
3
  import { PageLayout as n } from "../../components/PageLayout.js";
4
- import { DataTable as r } from "../../components/DataTable.js";
5
- import { StatusBadge as i } from "../../components/StatusBadge.js";
6
- import { EmptyState as a } from "../../components/EmptyState.js";
7
- import { ToastContainer as o } from "../../components/Toast.js";
8
- import { useToast as s } from "../../hooks/useToast.js";
4
+ import { DataTable as ee } from "../../components/DataTable.js";
5
+ import { StatusBadge as r } from "../../components/StatusBadge.js";
6
+ import { EmptyState as i } from "../../components/EmptyState.js";
7
+ import { ToastContainer as a } from "../../components/Toast.js";
8
+ import { useToast as o } from "../../hooks/useToast.js";
9
9
  import "../../components/index.js";
10
- import { useHealthyBowlExport as c } from "../../hooks/useHealthyBowlExport.js";
11
- import { useState as l } from "react";
12
- import { useI18n as u } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
13
- import { Download as d, FileText as f } from "lucide-react";
14
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
15
- import { Button as h, EmphasisPanel as g, Select as _, SelectContent as v, SelectItem as y, SelectTrigger as b, SelectValue as x } from "@burdenoff/fe-libs/ui";
16
- import { gql as S } from "@apollo/client";
17
- import { useQuery as C } from "@apollo/client/react";
10
+ import { useHealthyBowlExport as s } from "../../hooks/useHealthyBowlExport.js";
11
+ import { useState as c } from "react";
12
+ import { useI18n as l } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
13
+ import { Download as u, FileText as d } from "lucide-react";
14
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
15
+ import { AlertDialog as m, AlertDialogAction as h, AlertDialogCancel as g, AlertDialogContent as _, AlertDialogDescription as v, AlertDialogFooter as y, AlertDialogHeader as b, AlertDialogTitle as x, Button as S, EmphasisPanel as C, Select as w, SelectContent as T, SelectItem as E, SelectTrigger as D, SelectValue as O } from "@burdenoff/fe-libs/ui";
16
+ import { isQuotaExhaustedError as k } from "@burdenoff/fe-libs/shared/utils";
17
+ import { gql as A } from "@apollo/client";
18
+ import { useQuery as j } from "@apollo/client/react";
18
19
  //#region src/healthybowl/pages/analytics/ExportPage.tsx
19
- var w = [
20
+ var M = [
20
21
  {
21
22
  value: "Crops",
22
23
  labelKey: "healthybowl.analytics.export.dataTypes.crops",
@@ -35,7 +36,7 @@ var w = [
35
36
  labelEn: "Financial",
36
37
  entityType: "healthybowl_transactions"
37
38
  }
38
- ], T = ["CSV", "JSON"], E = S`
39
+ ], N = ["CSV", "JSON"], P = A`
39
40
  query ListHealthyBowlExportJobs($context: ContextInput!) {
40
41
  listExportJobs(context: $context) {
41
42
  edges {
@@ -51,7 +52,7 @@ var w = [
51
52
  }
52
53
  }
53
54
  }
54
- `, D = (e) => {
55
+ `, F = (e) => {
55
56
  switch (e) {
56
57
  case "COMPLETED": return "success";
57
58
  case "FAILED":
@@ -62,55 +63,59 @@ var w = [
62
63
  case "CREATED": return "info";
63
64
  default: return "default";
64
65
  }
65
- }, O = "h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]";
66
- function k() {
67
- let { t: S } = u(), { workspaceId: k } = e(), { runExport: A, exporting: j } = c(), { toasts: M, toast: N, dismiss: P } = s(), [F, I] = l("Crops"), [L, R] = l("CSV"), [z, B] = l(""), [V, H] = l(""), { data: U, loading: W, refetch: G } = C(E, { variables: { context: { workspaceId: k } } }), K = (U?.listExportJobs?.edges?.map((e) => e.node) ?? []).filter((e) => (e.entityTypes ?? []).some((e) => e.startsWith("healthybowl_"))), q = async () => {
68
- let e = w.find((e) => e.value === F);
66
+ }, I = "h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]";
67
+ function L() {
68
+ let { t: A } = l(), { workspaceId: L } = e(), { runExport: R, exporting: z } = s(), { toasts: te, toast: B, dismiss: V } = o(), [H, U] = c("Crops"), [W, G] = c("CSV"), [K, q] = c(""), [J, Y] = c(""), [X, Z] = c(!1), { data: Q, loading: ne, refetch: re } = j(P, { variables: { context: { workspaceId: L } } }), $ = (Q?.listExportJobs?.edges?.map((e) => e.node) ?? []).filter((e) => (e.entityTypes ?? []).some((e) => e.startsWith("healthybowl_"))), ie = async () => {
69
+ let e = M.find((e) => e.value === H);
69
70
  if (!e) return;
70
- let t = S(e.labelKey, e.labelEn);
71
+ let t = A(e.labelKey, e.labelEn);
71
72
  try {
72
- await A({
73
- name: z || V ? S("healthybowl.analytics.export.jobName.withRange", "{{dataType}} export ({{from}} → {{to}})", {
73
+ await R({
74
+ name: K || J ? A("healthybowl.analytics.export.jobName.withRange", "{{dataType}} export ({{from}} → {{to}})", {
74
75
  dataType: t,
75
- from: z || "…",
76
- to: V || "…"
77
- }) : S("healthybowl.analytics.export.jobName.default", "{{dataType}} export", { dataType: t }),
76
+ from: K || "…",
77
+ to: J || "…"
78
+ }) : A("healthybowl.analytics.export.jobName.default", "{{dataType}} export", { dataType: t }),
78
79
  entityTypes: [e.entityType],
79
- format: L,
80
- dateRangeStart: z ? (/* @__PURE__ */ new Date(`${z}T00:00:00.000Z`)).toISOString() : void 0,
81
- dateRangeEnd: V ? (/* @__PURE__ */ new Date(`${V}T23:59:59.999Z`)).toISOString() : void 0
82
- }), N({
83
- title: S("healthybowl.analytics.export.toast.ready.title", "Export ready"),
84
- description: S("healthybowl.analytics.export.toast.ready.description", "Your download should begin shortly."),
80
+ format: W,
81
+ dateRangeStart: K ? (/* @__PURE__ */ new Date(`${K}T00:00:00.000Z`)).toISOString() : void 0,
82
+ dateRangeEnd: J ? (/* @__PURE__ */ new Date(`${J}T23:59:59.999Z`)).toISOString() : void 0
83
+ }), B({
84
+ title: A("healthybowl.analytics.export.toast.ready.title", "Export ready"),
85
+ description: A("healthybowl.analytics.export.toast.ready.description", "Your download should begin shortly."),
85
86
  variant: "success"
86
- }), G();
87
+ }), re();
87
88
  } catch (e) {
88
- N({
89
- title: S("healthybowl.analytics.export.toast.failed.title", "Export failed"),
90
- description: e instanceof Error ? e.message : S("healthybowl.analytics.export.toast.failed.description", "Something went wrong while exporting."),
89
+ if (k(e)) {
90
+ Z(!0);
91
+ return;
92
+ }
93
+ B({
94
+ title: A("healthybowl.analytics.export.toast.failed.title", "Export failed"),
95
+ description: e instanceof Error ? e.message : A("healthybowl.analytics.export.toast.failed.description", "Something went wrong while exporting."),
91
96
  variant: "error"
92
97
  });
93
98
  }
94
- }, J = [
99
+ }, ae = [
95
100
  {
96
101
  key: "name",
97
- header: S("healthybowl.analytics.export.table.headers.name", "Export Name")
102
+ header: A("healthybowl.analytics.export.table.headers.name", "Export Name")
98
103
  },
99
104
  {
100
105
  key: "type",
101
- header: S("healthybowl.analytics.export.table.headers.data", "Data"),
102
- render: (e) => /* @__PURE__ */ p(i, {
106
+ header: A("healthybowl.analytics.export.table.headers.data", "Data"),
107
+ render: (e) => /* @__PURE__ */ f(r, {
103
108
  label: e.entityTypes.map((e) => e.replace("healthybowl_", "")).join(", "),
104
109
  variant: "info"
105
110
  })
106
111
  },
107
112
  {
108
113
  key: "format",
109
- header: S("healthybowl.analytics.export.table.headers.format", "Format"),
110
- render: (e) => /* @__PURE__ */ m("span", {
114
+ header: A("healthybowl.analytics.export.table.headers.format", "Format"),
115
+ render: (e) => /* @__PURE__ */ p("span", {
111
116
  className: "inline-flex items-center gap-1.5 text-text-primary",
112
117
  children: [
113
- /* @__PURE__ */ p(f, { className: "h-4 w-4" }),
118
+ /* @__PURE__ */ f(d, { className: "h-4 w-4" }),
114
119
  " ",
115
120
  e.format
116
121
  ]
@@ -118,103 +123,103 @@ function k() {
118
123
  },
119
124
  {
120
125
  key: "createdAt",
121
- header: S("healthybowl.analytics.export.table.headers.date", "Date"),
122
- render: (e) => /* @__PURE__ */ p("span", {
126
+ header: A("healthybowl.analytics.export.table.headers.date", "Date"),
127
+ render: (e) => /* @__PURE__ */ f("span", {
123
128
  className: "text-text-secondary",
124
129
  children: t(e.createdAt)
125
130
  })
126
131
  },
127
132
  {
128
133
  key: "status",
129
- header: S("healthybowl.analytics.export.table.headers.status", "Status"),
130
- render: (e) => /* @__PURE__ */ p(i, {
134
+ header: A("healthybowl.analytics.export.table.headers.status", "Status"),
135
+ render: (e) => /* @__PURE__ */ f(r, {
131
136
  label: e.status.toLowerCase(),
132
- variant: D(e.status),
137
+ variant: F(e.status),
133
138
  dot: !0
134
139
  })
135
140
  },
136
141
  {
137
142
  key: "downloadUrl",
138
143
  header: "",
139
- render: (e) => e.status === "COMPLETED" && e.downloadUrl ? /* @__PURE__ */ m("a", {
144
+ render: (e) => e.status === "COMPLETED" && e.downloadUrl ? /* @__PURE__ */ p("a", {
140
145
  href: e.downloadUrl,
141
146
  className: "inline-flex items-center gap-1 text-sm font-medium text-primary hover:underline",
142
147
  children: [
143
- /* @__PURE__ */ p(d, { className: "h-4 w-4" }),
148
+ /* @__PURE__ */ f(u, { className: "h-4 w-4" }),
144
149
  " ",
145
- S("healthybowl.common.download", "Download")
150
+ A("healthybowl.common.download", "Download")
146
151
  ]
147
152
  }) : null
148
153
  }
149
154
  ];
150
- return /* @__PURE__ */ m(n, {
151
- title: S("healthybowl.analytics.export.title", "Export Data"),
152
- description: S("healthybowl.analytics.export.description", "Export your farm data via the workspace export service"),
155
+ return /* @__PURE__ */ p(n, {
156
+ title: A("healthybowl.analytics.export.title", "Export Data"),
157
+ description: A("healthybowl.analytics.export.description", "Export your farm data via the workspace export service"),
153
158
  purpose: "Pull your farm records out of HealthyBowl as downloadable files — useful for sharing with an accountant or advisor, backing up your data, or doing your own analysis in a spreadsheet.",
154
159
  children: [
155
- /* @__PURE__ */ m(g, {
160
+ /* @__PURE__ */ p(C, {
156
161
  className: "p-6",
157
162
  children: [
158
- /* @__PURE__ */ p("h2", {
163
+ /* @__PURE__ */ f("h2", {
159
164
  className: "text-lg font-medium text-text-primary",
160
- children: S("healthybowl.analytics.export.newExport.heading", "New Export")
165
+ children: A("healthybowl.analytics.export.newExport.heading", "New Export")
161
166
  }),
162
- /* @__PURE__ */ m("div", {
167
+ /* @__PURE__ */ p("div", {
163
168
  className: "mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
164
169
  children: [
165
- /* @__PURE__ */ m("div", {
170
+ /* @__PURE__ */ p("div", {
166
171
  className: "space-y-1.5",
167
- children: [/* @__PURE__ */ p("label", {
172
+ children: [/* @__PURE__ */ f("label", {
168
173
  className: "text-sm font-medium text-text-primary",
169
- children: S("healthybowl.analytics.export.form.dataType.label", "Data Type")
170
- }), /* @__PURE__ */ m(_, {
171
- value: F,
172
- onValueChange: I,
173
- children: [/* @__PURE__ */ p(b, {
174
+ children: A("healthybowl.analytics.export.form.dataType.label", "Data Type")
175
+ }), /* @__PURE__ */ p(w, {
176
+ value: H,
177
+ onValueChange: U,
178
+ children: [/* @__PURE__ */ f(D, {
174
179
  className: "h-9 w-full",
175
- children: /* @__PURE__ */ p(x, {})
176
- }), /* @__PURE__ */ p(v, { children: w.map((e) => /* @__PURE__ */ p(y, {
180
+ children: /* @__PURE__ */ f(O, {})
181
+ }), /* @__PURE__ */ f(T, { children: M.map((e) => /* @__PURE__ */ f(E, {
177
182
  value: e.value,
178
- children: S(e.labelKey, e.labelEn)
183
+ children: A(e.labelKey, e.labelEn)
179
184
  }, e.value)) })]
180
185
  })]
181
186
  }),
182
- /* @__PURE__ */ m("div", {
187
+ /* @__PURE__ */ p("div", {
183
188
  className: "space-y-1.5",
184
- children: [/* @__PURE__ */ p("label", {
189
+ children: [/* @__PURE__ */ f("label", {
185
190
  className: "text-sm font-medium text-text-primary",
186
- children: S("healthybowl.analytics.export.form.from.label", "From")
187
- }), /* @__PURE__ */ p("input", {
191
+ children: A("healthybowl.analytics.export.form.from.label", "From")
192
+ }), /* @__PURE__ */ f("input", {
188
193
  type: "date",
189
- value: z,
190
- onChange: (e) => B(e.target.value),
191
- className: O
194
+ value: K,
195
+ onChange: (e) => q(e.target.value),
196
+ className: I
192
197
  })]
193
198
  }),
194
- /* @__PURE__ */ m("div", {
199
+ /* @__PURE__ */ p("div", {
195
200
  className: "space-y-1.5",
196
- children: [/* @__PURE__ */ p("label", {
201
+ children: [/* @__PURE__ */ f("label", {
197
202
  className: "text-sm font-medium text-text-primary",
198
- children: S("healthybowl.analytics.export.form.to.label", "To")
199
- }), /* @__PURE__ */ p("input", {
203
+ children: A("healthybowl.analytics.export.form.to.label", "To")
204
+ }), /* @__PURE__ */ f("input", {
200
205
  type: "date",
201
- value: V,
202
- onChange: (e) => H(e.target.value),
203
- className: O
206
+ value: J,
207
+ onChange: (e) => Y(e.target.value),
208
+ className: I
204
209
  })]
205
210
  }),
206
- /* @__PURE__ */ m("div", {
211
+ /* @__PURE__ */ p("div", {
207
212
  className: "space-y-1.5",
208
- children: [/* @__PURE__ */ p("label", {
213
+ children: [/* @__PURE__ */ f("label", {
209
214
  className: "text-sm font-medium text-text-primary",
210
- children: S("healthybowl.analytics.export.form.format.label", "Format")
211
- }), /* @__PURE__ */ m(_, {
212
- value: L,
213
- onValueChange: R,
214
- children: [/* @__PURE__ */ p(b, {
215
+ children: A("healthybowl.analytics.export.form.format.label", "Format")
216
+ }), /* @__PURE__ */ p(w, {
217
+ value: W,
218
+ onValueChange: G,
219
+ children: [/* @__PURE__ */ f(D, {
215
220
  className: "h-9 w-full",
216
- children: /* @__PURE__ */ p(x, {})
217
- }), /* @__PURE__ */ p(v, { children: T.map((e) => /* @__PURE__ */ p(y, {
221
+ children: /* @__PURE__ */ f(O, {})
222
+ }), /* @__PURE__ */ f(T, { children: N.map((e) => /* @__PURE__ */ f(E, {
218
223
  value: e,
219
224
  children: e
220
225
  }, e)) })]
@@ -222,41 +227,49 @@ function k() {
222
227
  })
223
228
  ]
224
229
  }),
225
- /* @__PURE__ */ m("div", {
230
+ /* @__PURE__ */ p("div", {
226
231
  className: "mt-5",
227
- children: [/* @__PURE__ */ m(h, {
228
- onClick: q,
229
- disabled: j,
230
- children: [/* @__PURE__ */ p(d, { className: "h-4 w-4" }), j ? S("healthybowl.analytics.export.actions.exporting", "Exporting…") : S("healthybowl.analytics.export.actions.export", "Export")]
231
- }), /* @__PURE__ */ p("p", {
232
+ children: [/* @__PURE__ */ p(S, {
233
+ onClick: ie,
234
+ disabled: z,
235
+ children: [/* @__PURE__ */ f(u, { className: "h-4 w-4" }), z ? A("healthybowl.analytics.export.actions.exporting", "Exporting…") : A("healthybowl.analytics.export.actions.export", "Export")]
236
+ }), /* @__PURE__ */ f("p", {
232
237
  className: "mt-2 text-xs text-text-secondary",
233
- children: S("healthybowl.analytics.export.newExport.hint", "Exports run in the background and download as a ZIP when ready.")
238
+ children: A("healthybowl.analytics.export.newExport.hint", "Exports run in the background and download as a ZIP when ready.")
234
239
  })]
235
240
  })
236
241
  ]
237
242
  }),
238
- /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("h2", {
243
+ /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h2", {
239
244
  className: "mb-3 text-lg font-medium text-text-primary",
240
- children: S("healthybowl.analytics.export.recent.heading", "Recent Exports")
241
- }), W ? /* @__PURE__ */ p("div", {
245
+ children: A("healthybowl.analytics.export.recent.heading", "Recent Exports")
246
+ }), ne ? /* @__PURE__ */ f("div", {
242
247
  className: "rounded-lg border border-border-subtle bg-bg-surface p-6 text-sm text-text-secondary",
243
- children: S("healthybowl.common.loading", "Loading…")
244
- }) : K.length === 0 ? /* @__PURE__ */ p(a, {
245
- title: S("healthybowl.analytics.export.emptyState.title", "No exports yet"),
246
- description: S("healthybowl.analytics.export.emptyState.description", "Create an export above — it will appear here once it's ready.")
247
- }) : /* @__PURE__ */ p(r, {
248
- columns: J,
249
- data: K,
248
+ children: A("healthybowl.common.loading", "Loading…")
249
+ }) : $.length === 0 ? /* @__PURE__ */ f(i, {
250
+ title: A("healthybowl.analytics.export.emptyState.title", "No exports yet"),
251
+ description: A("healthybowl.analytics.export.emptyState.description", "Create an export above — it will appear here once it's ready.")
252
+ }) : /* @__PURE__ */ f(ee, {
253
+ columns: ae,
254
+ data: $,
250
255
  keyField: "id"
251
256
  })] }),
252
- /* @__PURE__ */ p(o, {
253
- toasts: M,
254
- onDismiss: P
257
+ /* @__PURE__ */ f(a, {
258
+ toasts: te,
259
+ onDismiss: V
260
+ }),
261
+ /* @__PURE__ */ f(m, {
262
+ open: X,
263
+ onOpenChange: Z,
264
+ children: /* @__PURE__ */ p(_, { children: [/* @__PURE__ */ p(b, { children: [/* @__PURE__ */ f(x, { children: A("healthybowl.analytics.export.quota.title", "Export Limit Reached") }), /* @__PURE__ */ f(v, { children: A("healthybowl.analytics.export.quota.description", "You have reached your export limit for this month.") })] }), /* @__PURE__ */ p(y, { children: [/* @__PURE__ */ f(g, { children: A("healthybowl.common.dismiss", "Dismiss") }), /* @__PURE__ */ f(h, {
265
+ onClick: () => window.location.assign("/billing"),
266
+ children: A("healthybowl.common.viewBilling", "View Billing")
267
+ })] })] })
255
268
  })
256
269
  ]
257
270
  });
258
271
  }
259
272
  //#endregion
260
- export { k as ExportPage };
273
+ export { L as ExportPage };
261
274
 
262
275
  //# sourceMappingURL=ExportPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExportPage.js","names":[],"sources":["../../../../src/healthybowl/pages/analytics/ExportPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport { Download, FileText } from 'lucide-react';\nimport { PageLayout, DataTable, StatusBadge, EmptyState } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { useHealthyBowl } from '../../context/HealthyBowlContext';\nimport { useHealthyBowlExport, type HealthyBowlExportEntity } from '../../hooks/useHealthyBowlExport';\nimport { formatDate } from '../../utils/helpers';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Button,\n EmphasisPanel,\n Select,\n SelectTrigger,\n SelectValue,\n SelectContent,\n SelectItem,\n} from '@burdenoff/fe-libs/ui';\n\n// Only the data types + formats wspace-export-svc actually supports for HealthyBowl\n// (entity-configs: healthybowl_crops/animals/transactions; ExportFormat: CSV|JSON).\n// Weather/PDF/Excel were offered by the old fake UI but aren't backed — dropped.\n// `value` is the stable logic identifier (compared/submitted); `labelKey` is the\n// display key resolved via t() inside the component.\nconst DATA_TYPES: { value: string; labelKey: string; labelEn: string; entityType: HealthyBowlExportEntity }[] = [\n {\n value: 'Crops',\n labelKey: 'healthybowl.analytics.export.dataTypes.crops',\n labelEn: 'Crops',\n entityType: 'healthybowl_crops',\n },\n {\n value: 'Livestock',\n labelKey: 'healthybowl.analytics.export.dataTypes.livestock',\n labelEn: 'Livestock',\n entityType: 'healthybowl_animals',\n },\n {\n value: 'Financial',\n labelKey: 'healthybowl.analytics.export.dataTypes.financial',\n labelEn: 'Financial',\n entityType: 'healthybowl_transactions',\n },\n];\nconst FORMATS = ['CSV', 'JSON'] as const;\n\nconst LIST_EXPORT_JOBS = gql`\n query ListHealthyBowlExportJobs($context: ContextInput!) {\n listExportJobs(context: $context) {\n edges {\n node {\n id\n name\n status\n format\n entityTypes\n createdAt\n downloadUrl\n }\n }\n }\n }\n`;\n\ninterface ExportJobNode {\n id: string;\n name: string;\n status: string;\n format: string;\n entityTypes: string[];\n createdAt: string;\n downloadUrl: string | null;\n}\ntype ListData = { listExportJobs: { edges: { node: ExportJobNode }[] } };\n\nconst statusVariant = (s: string) => {\n switch (s) {\n case 'COMPLETED':\n return 'success' as const;\n case 'FAILED':\n case 'CANCELLED':\n case 'EXPIRED':\n return 'error' as const;\n case 'RUNNING':\n case 'QUEUED':\n case 'CREATED':\n return 'info' as const;\n default:\n return 'default' as const;\n }\n};\n\nconst selectClass =\n 'h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\n\nexport function ExportPage() {\n const { t } = useI18n();\n const { workspaceId } = useHealthyBowl();\n const { runExport, exporting } = useHealthyBowlExport();\n const { toasts, toast, dismiss } = useToast();\n const [dataType, setDataType] = useState<string>('Crops');\n const [format, setFormat] = useState<string>('CSV');\n const [dateFrom, setDateFrom] = useState('');\n const [dateTo, setDateTo] = useState('');\n\n const { data, loading, refetch } = useQuery<ListData>(LIST_EXPORT_JOBS, {\n variables: { context: { workspaceId } },\n });\n // Only show this workspace's HealthyBowl export jobs (listExportJobs returns\n // jobs from every module in the workspace).\n const jobs = (data?.listExportJobs?.edges?.map((e) => e.node) ?? []).filter((j) =>\n (j.entityTypes ?? []).some((et) => et.startsWith('healthybowl_'))\n );\n\n const handleExport = async () => {\n const selected = DATA_TYPES.find((d) => d.value === dataType);\n if (!selected) return;\n const dataTypeLabel = t(selected.labelKey, selected.labelEn);\n try {\n await runExport({\n name:\n dateFrom || dateTo\n ? t('healthybowl.analytics.export.jobName.withRange', '{{dataType}} export ({{from}} → {{to}})', {\n dataType: dataTypeLabel,\n from: dateFrom || '…',\n to: dateTo || '…',\n })\n : t('healthybowl.analytics.export.jobName.default', '{{dataType}} export', {\n dataType: dataTypeLabel,\n }),\n entityTypes: [selected.entityType],\n format: format as 'CSV' | 'JSON',\n dateRangeStart: dateFrom ? new Date(`${dateFrom}T00:00:00.000Z`).toISOString() : undefined,\n // End of the selected day (inclusive) — a bare date parses to UTC\n // midnight, which would exclude records created on the end date itself.\n dateRangeEnd: dateTo ? new Date(`${dateTo}T23:59:59.999Z`).toISOString() : undefined,\n });\n toast({\n title: t('healthybowl.analytics.export.toast.ready.title', 'Export ready'),\n description: t('healthybowl.analytics.export.toast.ready.description', 'Your download should begin shortly.'),\n variant: 'success',\n });\n refetch();\n } catch (err) {\n toast({\n title: t('healthybowl.analytics.export.toast.failed.title', 'Export failed'),\n description:\n err instanceof Error\n ? err.message\n : t('healthybowl.analytics.export.toast.failed.description', 'Something went wrong while exporting.'),\n variant: 'error',\n });\n }\n };\n\n const columns = [\n { key: 'name', header: t('healthybowl.analytics.export.table.headers.name', 'Export Name') },\n {\n key: 'type',\n header: t('healthybowl.analytics.export.table.headers.data', 'Data'),\n render: (r: ExportJobNode) => (\n <StatusBadge label={r.entityTypes.map((e) => e.replace('healthybowl_', '')).join(', ')} variant=\"info\" />\n ),\n },\n {\n key: 'format',\n header: t('healthybowl.analytics.export.table.headers.format', 'Format'),\n render: (r: ExportJobNode) => (\n <span className=\"inline-flex items-center gap-1.5 text-text-primary\">\n <FileText className=\"h-4 w-4\" /> {r.format}\n </span>\n ),\n },\n {\n key: 'createdAt',\n header: t('healthybowl.analytics.export.table.headers.date', 'Date'),\n render: (r: ExportJobNode) => <span className=\"text-text-secondary\">{formatDate(r.createdAt)}</span>,\n },\n {\n key: 'status',\n header: t('healthybowl.analytics.export.table.headers.status', 'Status'),\n render: (r: ExportJobNode) => (\n <StatusBadge label={r.status.toLowerCase()} variant={statusVariant(r.status)} dot />\n ),\n },\n {\n key: 'downloadUrl',\n header: '',\n render: (r: ExportJobNode) =>\n r.status === 'COMPLETED' && r.downloadUrl ? (\n <a\n href={r.downloadUrl}\n className=\"inline-flex items-center gap-1 text-sm font-medium text-primary hover:underline\"\n >\n <Download className=\"h-4 w-4\" /> {t('healthybowl.common.download', 'Download')}\n </a>\n ) : null,\n },\n ];\n\n return (\n <PageLayout\n title={t('healthybowl.analytics.export.title', 'Export Data')}\n description={t(\n 'healthybowl.analytics.export.description',\n 'Export your farm data via the workspace export service'\n )}\n purpose=\"Pull your farm records out of HealthyBowl as downloadable files — useful for sharing with an accountant or advisor, backing up your data, or doing your own analysis in a spreadsheet.\"\n >\n <EmphasisPanel className=\"p-6\">\n <h2 className=\"text-lg font-medium text-text-primary\">\n {t('healthybowl.analytics.export.newExport.heading', 'New Export')}\n </h2>\n <div className=\"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.analytics.export.form.dataType.label', 'Data Type')}\n </label>\n <Select value={dataType} onValueChange={setDataType}>\n <SelectTrigger className=\"h-9 w-full\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {DATA_TYPES.map((dt) => (\n <SelectItem key={dt.value} value={dt.value}>\n {t(dt.labelKey, dt.labelEn)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.analytics.export.form.from.label', 'From')}\n </label>\n <input type=\"date\" value={dateFrom} onChange={(e) => setDateFrom(e.target.value)} className={selectClass} />\n </div>\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.analytics.export.form.to.label', 'To')}\n </label>\n <input type=\"date\" value={dateTo} onChange={(e) => setDateTo(e.target.value)} className={selectClass} />\n </div>\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.analytics.export.form.format.label', 'Format')}\n </label>\n <Select value={format} onValueChange={setFormat}>\n <SelectTrigger className=\"h-9 w-full\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {FORMATS.map((f) => (\n <SelectItem key={f} value={f}>\n {f}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n <div className=\"mt-5\">\n <Button onClick={handleExport} disabled={exporting}>\n <Download className=\"h-4 w-4\" />\n {exporting\n ? t('healthybowl.analytics.export.actions.exporting', 'Exporting…')\n : t('healthybowl.analytics.export.actions.export', 'Export')}\n </Button>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.analytics.export.newExport.hint',\n 'Exports run in the background and download as a ZIP when ready.'\n )}\n </p>\n </div>\n </EmphasisPanel>\n\n <div>\n <h2 className=\"mb-3 text-lg font-medium text-text-primary\">\n {t('healthybowl.analytics.export.recent.heading', 'Recent Exports')}\n </h2>\n {loading ? (\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6 text-sm text-text-secondary\">\n {t('healthybowl.common.loading', 'Loading…')}\n </div>\n ) : jobs.length === 0 ? (\n <EmptyState\n title={t('healthybowl.analytics.export.emptyState.title', 'No exports yet')}\n description={t(\n 'healthybowl.analytics.export.emptyState.description',\n \"Create an export above — it will appear here once it's ready.\"\n )}\n />\n ) : (\n <DataTable columns={columns} data={jobs} keyField=\"id\" />\n )}\n </div>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAM,IAA0G;CAC9G;EACE,OAAO;EACP,UAAU;EACV,SAAS;EACT,YAAY;EACb;CACD;EACE,OAAO;EACP,UAAU;EACV,SAAS;EACT,YAAY;EACb;CACD;EACE,OAAO;EACP,UAAU;EACV,SAAS;EACT,YAAY;EACb;CACF,EACK,IAAU,CAAC,OAAO,OAAO,EAEzB,IAAmB,CAAG;;;;;;;;;;;;;;;;GA6BtB,KAAiB,MAAc;AACnC,SAAQ,GAAR;EACE,KAAK,YACH,QAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK,UACH,QAAO;EACT,QACE,QAAO;;GAIP,IACJ;AAEF,SAAgB,IAAa;CAC3B,IAAM,EAAE,SAAM,GAAS,EACjB,EAAE,mBAAgB,GAAgB,EAClC,EAAE,cAAW,iBAAc,GAAsB,EACjD,EAAE,WAAQ,UAAO,eAAY,GAAU,EACvC,CAAC,GAAU,KAAe,EAAiB,QAAQ,EACnD,CAAC,GAAQ,KAAa,EAAiB,MAAM,EAC7C,CAAC,GAAU,KAAe,EAAS,GAAG,EACtC,CAAC,GAAQ,KAAa,EAAS,GAAG,EAElC,EAAE,SAAM,YAAS,eAAY,EAAmB,GAAkB,EACtE,WAAW,EAAE,SAAS,EAAE,g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AAA,CACE,kBAAC,MAAD;IAAI,WAAU;cACX,EAAE,+CAA+C,iBAAiB;IAChE,CAAA,EACJ,IACC,kBAAC,OAAD;IAAK,WAAU;cACZ,EAAE,8BAA8B,WAAW;IACxC,CAAA,GACJ,EAAK,WAAW,IAClB,kBAAC,GAAD;IACE,OAAO,EAAE,iDAAiD,iBAAiB;IAC3E,aAAa,EACX,uDACA,gEACD;IACD,CAAA,GAEF,kBAAC,GAAD;IAAoB;IAAS,MAAM;IAAM,UAAS;IAAO,CAAA,CAEvD,EAAA,CAAA;GAEN,kBAAC,GAAD;IAAwB;IAAQ,WAAW;IAAW,CAAA;GAC3C"}
1
+ {"version":3,"file":"ExportPage.js","names":[],"sources":["../../../../src/healthybowl/pages/analytics/ExportPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport { isQuotaExhaustedError } from '@burdenoff/fe-libs/shared/utils';\nimport { Download, FileText } from 'lucide-react';\nimport { PageLayout, DataTable, StatusBadge, EmptyState } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { useHealthyBowl } from '../../context/HealthyBowlContext';\nimport { useHealthyBowlExport, type HealthyBowlExportEntity } from '../../hooks/useHealthyBowlExport';\nimport { formatDate } from '../../utils/helpers';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n Button,\n EmphasisPanel,\n Select,\n SelectTrigger,\n SelectValue,\n SelectContent,\n SelectItem,\n} from '@burdenoff/fe-libs/ui';\n\n// Only the data types + formats wspace-export-svc actually supports for HealthyBowl\n// (entity-configs: healthybowl_crops/animals/transactions; ExportFormat: CSV|JSON).\n// Weather/PDF/Excel were offered by the old fake UI but aren't backed — dropped.\n// `value` is the stable logic identifier (compared/submitted); `labelKey` is the\n// display key resolved via t() inside the component.\nconst DATA_TYPES: { value: string; labelKey: string; labelEn: string; entityType: HealthyBowlExportEntity }[] = [\n {\n value: 'Crops',\n labelKey: 'healthybowl.analytics.export.dataTypes.crops',\n labelEn: 'Crops',\n entityType: 'healthybowl_crops',\n },\n {\n value: 'Livestock',\n labelKey: 'healthybowl.analytics.export.dataTypes.livestock',\n labelEn: 'Livestock',\n entityType: 'healthybowl_animals',\n },\n {\n value: 'Financial',\n labelKey: 'healthybowl.analytics.export.dataTypes.financial',\n labelEn: 'Financial',\n entityType: 'healthybowl_transactions',\n },\n];\nconst FORMATS = ['CSV', 'JSON'] as const;\n\nconst LIST_EXPORT_JOBS = gql`\n query ListHealthyBowlExportJobs($context: ContextInput!) {\n listExportJobs(context: $context) {\n edges {\n node {\n id\n name\n status\n format\n entityTypes\n createdAt\n downloadUrl\n }\n }\n }\n }\n`;\n\ninterface ExportJobNode {\n id: string;\n name: string;\n status: string;\n format: string;\n entityTypes: string[];\n createdAt: string;\n downloadUrl: string | null;\n}\ntype ListData = { listExportJobs: { edges: { node: ExportJobNode }[] } };\n\nconst statusVariant = (s: string) => {\n switch (s) {\n case 'COMPLETED':\n return 'success' as const;\n case 'FAILED':\n case 'CANCELLED':\n case 'EXPIRED':\n return 'error' as const;\n case 'RUNNING':\n case 'QUEUED':\n case 'CREATED':\n return 'info' as const;\n default:\n return 'default' as const;\n }\n};\n\nconst selectClass =\n 'h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\n\nexport function ExportPage() {\n const { t } = useI18n();\n const { workspaceId } = useHealthyBowl();\n const { runExport, exporting } = useHealthyBowlExport();\n const { toasts, toast, dismiss } = useToast();\n const [dataType, setDataType] = useState<string>('Crops');\n const [format, setFormat] = useState<string>('CSV');\n const [dateFrom, setDateFrom] = useState('');\n const [dateTo, setDateTo] = useState('');\n const [showQuotaDialog, setShowQuotaDialog] = useState(false);\n\n const { data, loading, refetch } = useQuery<ListData>(LIST_EXPORT_JOBS, {\n variables: { context: { workspaceId } },\n });\n // Only show this workspace's HealthyBowl export jobs (listExportJobs returns\n // jobs from every module in the workspace).\n const jobs = (data?.listExportJobs?.edges?.map((e) => e.node) ?? []).filter((j) =>\n (j.entityTypes ?? []).some((et) => et.startsWith('healthybowl_'))\n );\n\n const handleExport = async () => {\n const selected = DATA_TYPES.find((d) => d.value === dataType);\n if (!selected) return;\n const dataTypeLabel = t(selected.labelKey, selected.labelEn);\n try {\n await runExport({\n name:\n dateFrom || dateTo\n ? t('healthybowl.analytics.export.jobName.withRange', '{{dataType}} export ({{from}} → {{to}})', {\n dataType: dataTypeLabel,\n from: dateFrom || '…',\n to: dateTo || '…',\n })\n : t('healthybowl.analytics.export.jobName.default', '{{dataType}} export', {\n dataType: dataTypeLabel,\n }),\n entityTypes: [selected.entityType],\n format: format as 'CSV' | 'JSON',\n dateRangeStart: dateFrom ? new Date(`${dateFrom}T00:00:00.000Z`).toISOString() : undefined,\n // End of the selected day (inclusive) — a bare date parses to UTC\n // midnight, which would exclude records created on the end date itself.\n dateRangeEnd: dateTo ? new Date(`${dateTo}T23:59:59.999Z`).toISOString() : undefined,\n });\n toast({\n title: t('healthybowl.analytics.export.toast.ready.title', 'Export ready'),\n description: t('healthybowl.analytics.export.toast.ready.description', 'Your download should begin shortly.'),\n variant: 'success',\n });\n refetch();\n } catch (err) {\n if (isQuotaExhaustedError(err)) {\n setShowQuotaDialog(true);\n return;\n }\n toast({\n title: t('healthybowl.analytics.export.toast.failed.title', 'Export failed'),\n description:\n err instanceof Error\n ? err.message\n : t('healthybowl.analytics.export.toast.failed.description', 'Something went wrong while exporting.'),\n variant: 'error',\n });\n }\n };\n\n const columns = [\n { key: 'name', header: t('healthybowl.analytics.export.table.headers.name', 'Export Name') },\n {\n key: 'type',\n header: t('healthybowl.analytics.export.table.headers.data', 'Data'),\n render: (r: ExportJobNode) => (\n <StatusBadge label={r.entityTypes.map((e) => e.replace('healthybowl_', '')).join(', ')} variant=\"info\" />\n ),\n },\n {\n key: 'format',\n header: t('healthybowl.analytics.export.table.headers.format', 'Format'),\n render: (r: ExportJobNode) => (\n <span className=\"inline-flex items-center gap-1.5 text-text-primary\">\n <FileText className=\"h-4 w-4\" /> {r.format}\n </span>\n ),\n },\n {\n key: 'createdAt',\n header: t('healthybowl.analytics.export.table.headers.date', 'Date'),\n render: (r: ExportJobNode) => <span className=\"text-text-secondary\">{formatDate(r.createdAt)}</span>,\n },\n {\n key: 'status',\n header: t('healthybowl.analytics.export.table.headers.status', 'Status'),\n render: (r: ExportJobNode) => (\n <StatusBadge label={r.status.toLowerCase()} variant={statusVariant(r.status)} dot />\n ),\n },\n {\n key: 'downloadUrl',\n header: '',\n render: (r: ExportJobNode) =>\n r.status === 'COMPLETED' && r.downloadUrl ? (\n <a\n href={r.downloadUrl}\n className=\"inline-flex items-center gap-1 text-sm font-medium text-primary hover:underline\"\n >\n <Download className=\"h-4 w-4\" /> {t('healthybowl.common.download', 'Download')}\n </a>\n ) : null,\n },\n ];\n\n return (\n <PageLayout\n title={t('healthybowl.analytics.export.title', 'Export Data')}\n description={t(\n 'healthybowl.analytics.export.description',\n 'Export your farm data via the workspace export service'\n )}\n purpose=\"Pull your farm records out of HealthyBowl as downloadable files — useful for sharing with an accountant or advisor, backing up your data, or doing your own analysis in a spreadsheet.\"\n >\n <EmphasisPanel className=\"p-6\">\n <h2 className=\"text-lg font-medium text-text-primary\">\n {t('healthybowl.analytics.export.newExport.heading', 'New Export')}\n </h2>\n <div className=\"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.analytics.export.form.dataType.label', 'Data Type')}\n </label>\n <Select value={dataType} onValueChange={setDataType}>\n <SelectTrigger className=\"h-9 w-full\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {DATA_TYPES.map((dt) => (\n <SelectItem key={dt.value} value={dt.value}>\n {t(dt.labelKey, dt.labelEn)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.analytics.export.form.from.label', 'From')}\n </label>\n <input type=\"date\" value={dateFrom} onChange={(e) => setDateFrom(e.target.value)} className={selectClass} />\n </div>\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.analytics.export.form.to.label', 'To')}\n </label>\n <input type=\"date\" value={dateTo} onChange={(e) => setDateTo(e.target.value)} className={selectClass} />\n </div>\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.analytics.export.form.format.label', 'Format')}\n </label>\n <Select value={format} onValueChange={setFormat}>\n <SelectTrigger className=\"h-9 w-full\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {FORMATS.map((f) => (\n <SelectItem key={f} value={f}>\n {f}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n <div className=\"mt-5\">\n <Button onClick={handleExport} disabled={exporting}>\n <Download className=\"h-4 w-4\" />\n {exporting\n ? t('healthybowl.analytics.export.actions.exporting', 'Exporting…')\n : t('healthybowl.analytics.export.actions.export', 'Export')}\n </Button>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.analytics.export.newExport.hint',\n 'Exports run in the background and download as a ZIP when ready.'\n )}\n </p>\n </div>\n </EmphasisPanel>\n\n <div>\n <h2 className=\"mb-3 text-lg font-medium text-text-primary\">\n {t('healthybowl.analytics.export.recent.heading', 'Recent Exports')}\n </h2>\n {loading ? (\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6 text-sm text-text-secondary\">\n {t('healthybowl.common.loading', 'Loading…')}\n </div>\n ) : jobs.length === 0 ? (\n <EmptyState\n title={t('healthybowl.analytics.export.emptyState.title', 'No exports yet')}\n description={t(\n 'healthybowl.analytics.export.emptyState.description',\n \"Create an export above — it will appear here once it's ready.\"\n )}\n />\n ) : (\n <DataTable columns={columns} data={jobs} keyField=\"id\" />\n )}\n </div>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n\n <AlertDialog open={showQuotaDialog} onOpenChange={setShowQuotaDialog}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>\n {t('healthybowl.analytics.export.quota.title', 'Export Limit Reached')}\n </AlertDialogTitle>\n <AlertDialogDescription>\n {t('healthybowl.analytics.export.quota.description', 'You have reached your export limit for this month.')}\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>{t('healthybowl.common.dismiss', 'Dismiss')}</AlertDialogCancel>\n <AlertDialogAction onClick={() => window.location.assign('/billing')}>\n {t('healthybowl.common.viewBilling', 'View Billing')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,IAAM,IAA0G;CAC9G;EACE,OAAO;EACP,UAAU;EACV,SAAS;EACT,YAAY;EACb;CACD;EACE,OAAO;EACP,UAAU;EACV,SAAS;EACT,YAAY;EACb;CACD;EACE,OAAO;EACP,UAAU;EACV,SAAS;EACT,YAAY;EACb;CACF,EACK,IAAU,CAAC,OAAO,OAAO,EAEzB,IAAmB,CAAG;;;;;;;;;;;;;;;;GA6BtB,KAAiB,MAAc;AACnC,SAAQ,GAAR;EACE,KAAK,YACH,QAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK,UACH,QAAO;EACT,QACE,QAAO;;GAIP,IACJ;AAEF,SAAgB,IAAa;CAC3B,IAAM,EAAE,SAAM,GAAS,EACjB,EAAE,mBAAgB,GAAgB,EAClC,EAAE,cAAW,iBAAc,GAAsB,EACjD,EAAE,YAAQ,UAAO,eAAY,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