@burdenoff/microfe-healthybowl 2026.605.4 → 2026.605.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
|
|
2
|
+
import { useCallback as t, useState as n } from "react";
|
|
3
|
+
import { gql as r } from "@apollo/client";
|
|
4
|
+
import { useApolloClient as i } from "@apollo/client/react";
|
|
5
|
+
//#region src/healthybowl/hooks/useHealthyBowlExport.ts
|
|
6
|
+
var a = r`
|
|
7
|
+
mutation CreateHealthyBowlExportJob($context: ContextInput, $input: CreateExportJobInput!) {
|
|
8
|
+
createExportJob(context: $context, input: $input) {
|
|
9
|
+
id
|
|
10
|
+
status
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`, o = r`
|
|
14
|
+
query GetHealthyBowlExportJob($context: ContextInput, $id: ID!) {
|
|
15
|
+
getExportJob(context: $context, id: $id) {
|
|
16
|
+
id
|
|
17
|
+
status
|
|
18
|
+
downloadUrl
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`, s = 1500, c = 80;
|
|
22
|
+
function l() {
|
|
23
|
+
let r = i(), { workspaceId: l } = e(), [u, d] = n(!1);
|
|
24
|
+
return {
|
|
25
|
+
runExport: t(async (e) => {
|
|
26
|
+
d(!0);
|
|
27
|
+
try {
|
|
28
|
+
let t = { workspaceId: l }, n = await r.mutate({
|
|
29
|
+
mutation: a,
|
|
30
|
+
variables: {
|
|
31
|
+
context: t,
|
|
32
|
+
input: {
|
|
33
|
+
name: e.name,
|
|
34
|
+
entityTypes: e.entityTypes,
|
|
35
|
+
format: e.format,
|
|
36
|
+
dateRangeStart: e.dateRangeStart ?? null,
|
|
37
|
+
dateRangeEnd: e.dateRangeEnd ?? null
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (n.error) throw n.error;
|
|
42
|
+
let i = n.data?.createExportJob?.id;
|
|
43
|
+
if (!i) throw Error("The export job could not be created.");
|
|
44
|
+
for (let e = 0; e < c; e++) {
|
|
45
|
+
await new Promise((e) => setTimeout(e, s));
|
|
46
|
+
let e = (await r.query({
|
|
47
|
+
query: o,
|
|
48
|
+
variables: {
|
|
49
|
+
context: t,
|
|
50
|
+
id: i
|
|
51
|
+
},
|
|
52
|
+
fetchPolicy: "network-only"
|
|
53
|
+
})).data?.getExportJob;
|
|
54
|
+
if (e?.status === "COMPLETED") {
|
|
55
|
+
if (!e.downloadUrl) throw Error("Export finished but no download is available yet.");
|
|
56
|
+
window.location.href = e.downloadUrl;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (e && [
|
|
60
|
+
"FAILED",
|
|
61
|
+
"CANCELLED",
|
|
62
|
+
"EXPIRED"
|
|
63
|
+
].includes(e.status)) throw Error(`Export ${e.status.toLowerCase()}.`);
|
|
64
|
+
}
|
|
65
|
+
throw Error("Export timed out — try a narrower date range.");
|
|
66
|
+
} finally {
|
|
67
|
+
d(!1);
|
|
68
|
+
}
|
|
69
|
+
}, [r, l]),
|
|
70
|
+
exporting: u
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { l as useHealthyBowlExport };
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=useHealthyBowlExport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHealthyBowlExport.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlExport.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { useApolloClient } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n// Reuse-first: hand the work to the platform wspace-export-svc (Hive service\n// \"export\") instead of fabricating a client-side CSV. Flow mirrors the per-module\n// pattern in microfe-channel: createExportJob → poll getExportJob → download the\n// presigned ZIP. These ops aren't in the offline-pulled HB schema, so they're raw\n// gql documents (a later schema:pull + codegen can replace them with typed hooks).\nconst CREATE_EXPORT_JOB = gql`\n mutation CreateHealthyBowlExportJob($context: ContextInput, $input: CreateExportJobInput!) {\n createExportJob(context: $context, input: $input) {\n id\n status\n }\n }\n`;\n\nconst GET_EXPORT_JOB = gql`\n query GetHealthyBowlExportJob($context: ContextInput, $id: ID!) {\n getExportJob(context: $context, id: $id) {\n id\n status\n downloadUrl\n }\n }\n`;\n\n/** HealthyBowl entity types registered in wspace-export-svc's entity-config registry. */\nexport type HealthyBowlExportEntity = 'healthybowl_crops' | 'healthybowl_animals' | 'healthybowl_transactions';\n\ninterface RunExportArgs {\n name: string;\n entityTypes: HealthyBowlExportEntity[];\n format: 'CSV' | 'JSON';\n dateRangeStart?: string;\n dateRangeEnd?: string;\n}\n\ntype CreateJobData = { createExportJob: { id: string; status: string } };\ntype GetJobData = { getExportJob: { id: string; status: string; downloadUrl: string | null } | null };\n\nconst POLL_INTERVAL_MS = 1500;\nconst POLL_MAX_ATTEMPTS = 80; // ~2 minutes before giving up on the async job\n\nexport function useHealthyBowlExport() {\n const client = useApolloClient();\n const { workspaceId } = useHealthyBowl();\n const [exporting, setExporting] = useState(false);\n\n const runExport = useCallback(\n async (args: RunExportArgs): Promise<void> => {\n setExporting(true);\n try {\n const context = { workspaceId };\n const created = await client.mutate<CreateJobData>({\n mutation: CREATE_EXPORT_JOB,\n variables: {\n context,\n input: {\n name: args.name,\n entityTypes: args.entityTypes,\n format: args.format,\n dateRangeStart: args.dateRangeStart ?? null,\n dateRangeEnd: args.dateRangeEnd ?? null,\n },\n },\n });\n if (created.error) throw created.error;\n const jobId = created.data?.createExportJob?.id;\n if (!jobId) throw new Error('The export job could not be created.');\n\n // The export runs asynchronously (CREATED → QUEUED → RUNNING → COMPLETED,\n // packaged as a ZIP in Files/S3). Poll until it finishes, then download.\n for (let attempt = 0; attempt < POLL_MAX_ATTEMPTS; attempt++) {\n await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));\n const polled = await client.query<GetJobData>({\n query: GET_EXPORT_JOB,\n variables: { context, id: jobId },\n fetchPolicy: 'network-only',\n });\n const job = polled.data?.getExportJob;\n if (job?.status === 'COMPLETED') {\n if (!job.downloadUrl) throw new Error('Export finished but no download is available yet.');\n // Same-tab navigation — window.open is blocked by popup blockers after an\n // await loses the user-activation context.\n window.location.href = job.downloadUrl;\n return;\n }\n if (job && ['FAILED', 'CANCELLED', 'EXPIRED'].includes(job.status)) {\n throw new Error(`Export ${job.status.toLowerCase()}.`);\n }\n }\n throw new Error('Export timed out — try a narrower date range.');\n } finally {\n setExporting(false);\n }\n },\n [client, workspaceId]\n );\n\n return { runExport, exporting };\n}\n"],"mappings":";;;;;AAUA,IAAM,IAAoB,CAAG;;;;;;;GASvB,IAAiB,CAAG;;;;;;;;GAwBpB,IAAmB,MACnB,IAAoB;AAE1B,SAAgB,IAAuB;CACrC,IAAM,IAAS,GAAiB,EAC1B,EAAE,mBAAgB,GAAgB,EAClC,CAAC,GAAW,KAAgB,EAAS,GAAM;AAqDjD,QAAO;EAAE,WAnDS,EAChB,OAAO,MAAuC;AAC5C,KAAa,GAAK;AAClB,OAAI;IACF,IAAM,IAAU,EAAE,gBAAa,EACzB,IAAU,MAAM,EAAO,OAAsB;KACjD,UAAU;KACV,WAAW;MACT;MACA,OAAO;OACL,MAAM,EAAK;OACX,aAAa,EAAK;OAClB,QAAQ,EAAK;OACb,gBAAgB,EAAK,kBAAkB;OACvC,cAAc,EAAK,gBAAgB;OACpC;MACF;KACF,CAAC;AACF,QAAI,EAAQ,MAAO,OAAM,EAAQ;IACjC,IAAM,IAAQ,EAAQ,MAAM,iBAAiB;AAC7C,QAAI,CAAC,EAAO,OAAU,MAAM,uCAAuC;AAInE,SAAK,IAAI,IAAU,GAAG,IAAU,GAAmB,KAAW;AAC5D,WAAM,IAAI,SAAS,MAAY,WAAW,GAAS,EAAiB,CAAC;KAMrE,IAAM,KALS,MAAM,EAAO,MAAkB;MAC5C,OAAO;MACP,WAAW;OAAE;OAAS,IAAI;OAAO;MACjC,aAAa;MACd,CAAC,EACiB,MAAM;AACzB,SAAI,GAAK,WAAW,aAAa;AAC/B,UAAI,CAAC,EAAI,YAAa,OAAU,MAAM,oDAAoD;AAG1F,aAAO,SAAS,OAAO,EAAI;AAC3B;;AAEF,SAAI,KAAO;MAAC;MAAU;MAAa;MAAU,CAAC,SAAS,EAAI,OAAO,CAChE,OAAU,MAAM,UAAU,EAAI,OAAO,aAAa,CAAC,GAAG;;AAG1D,UAAU,MAAM,gDAAgD;aACxD;AACR,MAAa,GAAM;;KAGvB,CAAC,GAAQ,EAAY,CACtB;EAEmB;EAAW"}
|
|
@@ -1,130 +1,125 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { useHealthyBowl as e } from "../../context/HealthyBowlContext.js";
|
|
2
|
+
import { formatDate as t } from "../../utils/helpers.js";
|
|
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";
|
|
6
8
|
import "../../components/index.js";
|
|
7
|
-
import { useToast as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { useToast as s } from "../../hooks/useToast.js";
|
|
10
|
+
import { useHealthyBowlExport as c } from "../../hooks/useHealthyBowlExport.js";
|
|
11
|
+
import { useState as l } from "react";
|
|
12
|
+
import { Download as u, FileText as d } from "lucide-react";
|
|
13
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
14
|
+
import { gql as m } from "@apollo/client";
|
|
15
|
+
import { useQuery as h } from "@apollo/client/react";
|
|
11
16
|
//#region src/healthybowl/pages/analytics/ExportPage.tsx
|
|
12
|
-
var
|
|
13
|
-
"Crops",
|
|
14
|
-
"Livestock",
|
|
15
|
-
"Financial",
|
|
16
|
-
"Weather"
|
|
17
|
-
], m = [
|
|
18
|
-
"CSV",
|
|
19
|
-
"PDF",
|
|
20
|
-
"Excel"
|
|
21
|
-
], h = [
|
|
17
|
+
var g = [
|
|
22
18
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
type: "Crops",
|
|
26
|
-
format: "CSV",
|
|
27
|
-
date: "2025-03-14",
|
|
28
|
-
size: "2.4 MB",
|
|
29
|
-
status: "completed"
|
|
19
|
+
label: "Crops",
|
|
20
|
+
entityType: "healthybowl_crops"
|
|
30
21
|
},
|
|
31
22
|
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
type: "Financial",
|
|
35
|
-
format: "PDF",
|
|
36
|
-
date: "2025-03-12",
|
|
37
|
-
size: "1.1 MB",
|
|
38
|
-
status: "completed"
|
|
23
|
+
label: "Livestock",
|
|
24
|
+
entityType: "healthybowl_animals"
|
|
39
25
|
},
|
|
40
26
|
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
type: "Livestock",
|
|
44
|
-
format: "Excel",
|
|
45
|
-
date: "2025-03-10",
|
|
46
|
-
size: "3.8 MB",
|
|
47
|
-
status: "completed"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: "exp-4",
|
|
51
|
-
name: "Weather Data 2025",
|
|
52
|
-
type: "Weather",
|
|
53
|
-
format: "CSV",
|
|
54
|
-
date: "2025-03-08",
|
|
55
|
-
size: "0.5 MB",
|
|
56
|
-
status: "completed"
|
|
27
|
+
label: "Financial",
|
|
28
|
+
entityType: "healthybowl_transactions"
|
|
57
29
|
}
|
|
58
|
-
],
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
30
|
+
], _ = ["CSV", "JSON"], v = m`
|
|
31
|
+
query ListHealthyBowlExportJobs($context: ContextInput!) {
|
|
32
|
+
listExportJobs(context: $context) {
|
|
33
|
+
edges {
|
|
34
|
+
node {
|
|
35
|
+
id
|
|
36
|
+
name
|
|
37
|
+
status
|
|
38
|
+
format
|
|
39
|
+
entityTypes
|
|
40
|
+
createdAt
|
|
41
|
+
downloadUrl
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`, y = (e) => {
|
|
47
|
+
switch (e) {
|
|
48
|
+
case "COMPLETED": return "success";
|
|
49
|
+
case "FAILED":
|
|
50
|
+
case "CANCELLED":
|
|
51
|
+
case "EXPIRED": return "error";
|
|
52
|
+
case "RUNNING":
|
|
53
|
+
case "QUEUED":
|
|
54
|
+
case "CREATED": return "info";
|
|
55
|
+
default: return "default";
|
|
56
|
+
}
|
|
57
|
+
}, b = "h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring";
|
|
58
|
+
function x() {
|
|
59
|
+
let { workspaceId: m } = e(), { runExport: x, exporting: S } = c(), { toasts: C, toast: w, dismiss: T } = s(), [E, D] = l("Crops"), [O, k] = l("CSV"), [A, j] = l(""), [M, N] = l(""), { data: P, loading: F, refetch: I } = h(v, { variables: { context: { workspaceId: m } } }), L = (P?.listExportJobs?.edges?.map((e) => e.node) ?? []).filter((e) => (e.entityTypes ?? []).some((e) => e.startsWith("healthybowl_")));
|
|
60
|
+
return /* @__PURE__ */ p(n, {
|
|
66
61
|
title: "Export Data",
|
|
67
|
-
description: "Export your farm data
|
|
62
|
+
description: "Export your farm data via the workspace export service",
|
|
68
63
|
children: [
|
|
69
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ p("div", {
|
|
70
65
|
className: "rounded-lg border border-border bg-card p-6 shadow-sm",
|
|
71
66
|
children: [
|
|
72
|
-
/* @__PURE__ */
|
|
67
|
+
/* @__PURE__ */ f("h2", {
|
|
73
68
|
className: "text-lg font-medium text-foreground",
|
|
74
69
|
children: "New Export"
|
|
75
70
|
}),
|
|
76
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ p("div", {
|
|
77
72
|
className: "mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
|
|
78
73
|
children: [
|
|
79
|
-
/* @__PURE__ */
|
|
74
|
+
/* @__PURE__ */ p("div", {
|
|
80
75
|
className: "space-y-1.5",
|
|
81
|
-
children: [/* @__PURE__ */
|
|
76
|
+
children: [/* @__PURE__ */ f("label", {
|
|
82
77
|
className: "text-sm font-medium text-foreground",
|
|
83
78
|
children: "Data Type"
|
|
84
|
-
}), /* @__PURE__ */
|
|
85
|
-
value:
|
|
86
|
-
onChange: (e) =>
|
|
87
|
-
className:
|
|
88
|
-
children:
|
|
89
|
-
value: e,
|
|
90
|
-
children: e
|
|
91
|
-
}, e))
|
|
79
|
+
}), /* @__PURE__ */ f("select", {
|
|
80
|
+
value: E,
|
|
81
|
+
onChange: (e) => D(e.target.value),
|
|
82
|
+
className: b,
|
|
83
|
+
children: g.map((e) => /* @__PURE__ */ f("option", {
|
|
84
|
+
value: e.label,
|
|
85
|
+
children: e.label
|
|
86
|
+
}, e.label))
|
|
92
87
|
})]
|
|
93
88
|
}),
|
|
94
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ p("div", {
|
|
95
90
|
className: "space-y-1.5",
|
|
96
|
-
children: [/* @__PURE__ */
|
|
91
|
+
children: [/* @__PURE__ */ f("label", {
|
|
97
92
|
className: "text-sm font-medium text-foreground",
|
|
98
93
|
children: "From"
|
|
99
|
-
}), /* @__PURE__ */
|
|
94
|
+
}), /* @__PURE__ */ f("input", {
|
|
100
95
|
type: "date",
|
|
101
|
-
value:
|
|
102
|
-
onChange: (e) =>
|
|
103
|
-
className:
|
|
96
|
+
value: A,
|
|
97
|
+
onChange: (e) => j(e.target.value),
|
|
98
|
+
className: b
|
|
104
99
|
})]
|
|
105
100
|
}),
|
|
106
|
-
/* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ p("div", {
|
|
107
102
|
className: "space-y-1.5",
|
|
108
|
-
children: [/* @__PURE__ */
|
|
103
|
+
children: [/* @__PURE__ */ f("label", {
|
|
109
104
|
className: "text-sm font-medium text-foreground",
|
|
110
105
|
children: "To"
|
|
111
|
-
}), /* @__PURE__ */
|
|
106
|
+
}), /* @__PURE__ */ f("input", {
|
|
112
107
|
type: "date",
|
|
113
|
-
value:
|
|
114
|
-
onChange: (e) =>
|
|
115
|
-
className:
|
|
108
|
+
value: M,
|
|
109
|
+
onChange: (e) => N(e.target.value),
|
|
110
|
+
className: b
|
|
116
111
|
})]
|
|
117
112
|
}),
|
|
118
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ p("div", {
|
|
119
114
|
className: "space-y-1.5",
|
|
120
|
-
children: [/* @__PURE__ */
|
|
115
|
+
children: [/* @__PURE__ */ f("label", {
|
|
121
116
|
className: "text-sm font-medium text-foreground",
|
|
122
117
|
children: "Format"
|
|
123
|
-
}), /* @__PURE__ */
|
|
124
|
-
value:
|
|
125
|
-
onChange: (e) =>
|
|
126
|
-
className:
|
|
127
|
-
children:
|
|
118
|
+
}), /* @__PURE__ */ f("select", {
|
|
119
|
+
value: O,
|
|
120
|
+
onChange: (e) => k(e.target.value),
|
|
121
|
+
className: b,
|
|
122
|
+
children: _.map((e) => /* @__PURE__ */ f("option", {
|
|
128
123
|
value: e,
|
|
129
124
|
children: e
|
|
130
125
|
}, e))
|
|
@@ -132,37 +127,51 @@ function _() {
|
|
|
132
127
|
})
|
|
133
128
|
]
|
|
134
129
|
}),
|
|
135
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ p("div", {
|
|
136
131
|
className: "mt-5",
|
|
137
|
-
children: /* @__PURE__ */
|
|
138
|
-
onClick: () => {
|
|
139
|
-
let e =
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
132
|
+
children: [/* @__PURE__ */ p("button", {
|
|
133
|
+
onClick: async () => {
|
|
134
|
+
let e = g.find((e) => e.label === E);
|
|
135
|
+
if (e) try {
|
|
136
|
+
await x({
|
|
137
|
+
name: `${E} export${A || M ? ` (${A || "…"} → ${M || "…"})` : ""}`,
|
|
138
|
+
entityTypes: [e.entityType],
|
|
139
|
+
format: O,
|
|
140
|
+
dateRangeStart: A ? (/* @__PURE__ */ new Date(`${A}T00:00:00.000Z`)).toISOString() : void 0,
|
|
141
|
+
dateRangeEnd: M ? (/* @__PURE__ */ new Date(`${M}T23:59:59.999Z`)).toISOString() : void 0
|
|
142
|
+
}), w({
|
|
143
|
+
title: "Export ready",
|
|
144
|
+
description: "Your download should begin shortly.",
|
|
145
|
+
variant: "success"
|
|
146
|
+
}), I();
|
|
147
|
+
} catch (e) {
|
|
148
|
+
w({
|
|
149
|
+
title: "Export failed",
|
|
150
|
+
description: e instanceof Error ? e.message : "Something went wrong while exporting.",
|
|
151
|
+
variant: "error"
|
|
152
|
+
});
|
|
153
|
+
}
|
|
155
154
|
},
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
disabled: S,
|
|
156
|
+
className: "inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-60",
|
|
157
|
+
children: [/* @__PURE__ */ f(u, { className: "h-4 w-4" }), S ? "Exporting…" : "Export"]
|
|
158
|
+
}), /* @__PURE__ */ f("p", {
|
|
159
|
+
className: "mt-2 text-xs text-muted-foreground",
|
|
160
|
+
children: "Exports run in the background and download as a ZIP when ready."
|
|
161
|
+
})]
|
|
159
162
|
})
|
|
160
163
|
]
|
|
161
164
|
}),
|
|
162
|
-
/* @__PURE__ */
|
|
165
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h2", {
|
|
163
166
|
className: "mb-3 text-lg font-medium text-foreground",
|
|
164
167
|
children: "Recent Exports"
|
|
165
|
-
}), /* @__PURE__ */
|
|
168
|
+
}), F ? /* @__PURE__ */ f("div", {
|
|
169
|
+
className: "rounded-lg border border-border bg-card p-6 text-sm text-muted-foreground",
|
|
170
|
+
children: "Loading…"
|
|
171
|
+
}) : L.length === 0 ? /* @__PURE__ */ f(a, {
|
|
172
|
+
title: "No exports yet",
|
|
173
|
+
description: "Create an export above — it will appear here once it's ready."
|
|
174
|
+
}) : /* @__PURE__ */ f(r, {
|
|
166
175
|
columns: [
|
|
167
176
|
{
|
|
168
177
|
key: "name",
|
|
@@ -170,57 +179,62 @@ function _() {
|
|
|
170
179
|
},
|
|
171
180
|
{
|
|
172
181
|
key: "type",
|
|
173
|
-
header: "
|
|
174
|
-
render: (e) => /* @__PURE__ */
|
|
175
|
-
label: e.
|
|
182
|
+
header: "Data",
|
|
183
|
+
render: (e) => /* @__PURE__ */ f(i, {
|
|
184
|
+
label: e.entityTypes.map((e) => e.replace("healthybowl_", "")).join(", "),
|
|
176
185
|
variant: "info"
|
|
177
186
|
})
|
|
178
187
|
},
|
|
179
188
|
{
|
|
180
189
|
key: "format",
|
|
181
190
|
header: "Format",
|
|
182
|
-
render: (e) => /* @__PURE__ */
|
|
191
|
+
render: (e) => /* @__PURE__ */ p("span", {
|
|
183
192
|
className: "inline-flex items-center gap-1.5 text-foreground",
|
|
184
193
|
children: [
|
|
185
|
-
|
|
194
|
+
/* @__PURE__ */ f(d, { className: "h-4 w-4" }),
|
|
186
195
|
" ",
|
|
187
196
|
e.format
|
|
188
197
|
]
|
|
189
198
|
})
|
|
190
199
|
},
|
|
191
200
|
{
|
|
192
|
-
key: "
|
|
201
|
+
key: "createdAt",
|
|
193
202
|
header: "Date",
|
|
194
|
-
render: (
|
|
203
|
+
render: (e) => /* @__PURE__ */ f("span", {
|
|
195
204
|
className: "text-muted-foreground",
|
|
196
|
-
children: e
|
|
205
|
+
children: t(e.createdAt)
|
|
197
206
|
})
|
|
198
207
|
},
|
|
199
|
-
{
|
|
200
|
-
key: "size",
|
|
201
|
-
header: "Size"
|
|
202
|
-
},
|
|
203
208
|
{
|
|
204
209
|
key: "status",
|
|
205
210
|
header: "Status",
|
|
206
|
-
render: (e) => /* @__PURE__ */
|
|
207
|
-
label: e.status,
|
|
208
|
-
variant:
|
|
211
|
+
render: (e) => /* @__PURE__ */ f(i, {
|
|
212
|
+
label: e.status.toLowerCase(),
|
|
213
|
+
variant: y(e.status),
|
|
209
214
|
dot: !0
|
|
210
215
|
})
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
key: "downloadUrl",
|
|
219
|
+
header: "",
|
|
220
|
+
render: (e) => e.status === "COMPLETED" && e.downloadUrl ? /* @__PURE__ */ p("a", {
|
|
221
|
+
href: e.downloadUrl,
|
|
222
|
+
className: "inline-flex items-center gap-1 text-sm font-medium text-primary hover:underline",
|
|
223
|
+
children: [/* @__PURE__ */ f(u, { className: "h-4 w-4" }), " Download"]
|
|
224
|
+
}) : null
|
|
211
225
|
}
|
|
212
226
|
],
|
|
213
|
-
data:
|
|
227
|
+
data: L,
|
|
214
228
|
keyField: "id"
|
|
215
229
|
})] }),
|
|
216
|
-
/* @__PURE__ */
|
|
217
|
-
toasts:
|
|
218
|
-
onDismiss:
|
|
230
|
+
/* @__PURE__ */ f(o, {
|
|
231
|
+
toasts: C,
|
|
232
|
+
onDismiss: T
|
|
219
233
|
})
|
|
220
234
|
]
|
|
221
235
|
});
|
|
222
236
|
}
|
|
223
237
|
//#endregion
|
|
224
|
-
export {
|
|
238
|
+
export { x as ExportPage };
|
|
225
239
|
|
|
226
240
|
//# 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 { Download, FileSpreadsheet, FileText, File } from 'lucide-react';\nimport { PageLayout, DataTable, StatusBadge } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { formatDate } from '../../utils/helpers';\n\nconst dataTypes = ['Crops', 'Livestock', 'Financial', 'Weather'] as const;\nconst formats = ['CSV', 'PDF', 'Excel'] as const;\n\ninterface ExportRecord {\n id: string;\n name: string;\n type: string;\n format: string;\n date: string;\n size: string;\n status: string;\n}\n\nconst initialExports: ExportRecord[] = [\n {\n id: 'exp-1',\n name: 'Crop Data - March 2025',\n type: 'Crops',\n format: 'CSV',\n date: '2025-03-14',\n size: '2.4 MB',\n status: 'completed',\n },\n {\n id: 'exp-2',\n name: 'Financial Summary Q1',\n type: 'Financial',\n format: 'PDF',\n date: '2025-03-12',\n size: '1.1 MB',\n status: 'completed',\n },\n {\n id: 'exp-3',\n name: 'Livestock Records',\n type: 'Livestock',\n format: 'Excel',\n date: '2025-03-10',\n size: '3.8 MB',\n status: 'completed',\n },\n {\n id: 'exp-4',\n name: 'Weather Data 2025',\n type: 'Weather',\n format: 'CSV',\n date: '2025-03-08',\n size: '0.5 MB',\n status: 'completed',\n },\n];\n\nconst formatIcons: Record<string, React.ReactNode> = {\n CSV: <FileText className=\"h-4 w-4\" />,\n PDF: <File className=\"h-4 w-4\" />,\n Excel: <FileSpreadsheet className=\"h-4 w-4\" />,\n};\n\nexport function ExportPage() {\n const [dataType, setDataType] = useState<string>('Crops');\n const [format, setFormat] = useState<string>('CSV');\n const [dateFrom, setDateFrom] = useState('2025-01-01');\n const [dateTo, setDateTo] = useState('2025-03-15');\n const [recentExports, setRecentExports] = useState<ExportRecord[]>(initialExports);\n const { toasts, toast, dismiss } = useToast();\n\n const handleExport = () => {\n const csvContent = `Data Type,Format,From,To\\n${dataType},${format},${dateFrom},${dateTo}`;\n const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = `${dataType.toLowerCase()}-export-${dateFrom}-to-${dateTo}.${format.toLowerCase()}`;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(url);\n\n const newExport: ExportRecord = {\n id: `exp-${Date.now()}`,\n name: `${dataType} Data (${dateFrom} to ${dateTo})`,\n type: dataType,\n format,\n date: new Date().toISOString().split('T')[0],\n size: '1.0 MB',\n status: 'completed',\n };\n setRecentExports((prev) => [newExport, ...prev]);\n toast({ title: 'Export Complete', description: `${dataType} data exported as ${format}`, variant: 'success' });\n };\n\n const columns = [\n { key: 'name', header: 'Export Name' },\n {\n key: 'type',\n header: 'Type',\n render: (r: (typeof recentExports)[0]) => <StatusBadge label={r.type} variant=\"info\" />,\n },\n {\n key: 'format',\n header: 'Format',\n render: (r: (typeof recentExports)[0]) => (\n <span className=\"inline-flex items-center gap-1.5 text-foreground\">\n {formatIcons[r.format]} {r.format}\n </span>\n ),\n },\n {\n key: 'date',\n header: 'Date',\n render: (r: (typeof recentExports)[0]) => <span className=\"text-muted-foreground\">{formatDate(r.date)}</span>,\n },\n { key: 'size', header: 'Size' },\n {\n key: 'status',\n header: 'Status',\n render: (r: (typeof recentExports)[0]) => <StatusBadge label={r.status} variant=\"success\" dot />,\n },\n ];\n\n return (\n <PageLayout title=\"Export Data\" description=\"Export your farm data in various formats\">\n <div className=\"rounded-lg border border-border bg-card p-6 shadow-sm\">\n <h2 className=\"text-lg font-medium text-foreground\">New Export</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-foreground\">Data Type</label>\n <select\n value={dataType}\n onChange={(e) => setDataType(e.target.value)}\n className=\"h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring\"\n >\n {dataTypes.map((t) => (\n <option key={t} value={t}>\n {t}\n </option>\n ))}\n </select>\n </div>\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-foreground\">From</label>\n <input\n type=\"date\"\n value={dateFrom}\n onChange={(e) => setDateFrom(e.target.value)}\n className=\"h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring\"\n />\n </div>\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-foreground\">To</label>\n <input\n type=\"date\"\n value={dateTo}\n onChange={(e) => setDateTo(e.target.value)}\n className=\"h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring\"\n />\n </div>\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-foreground\">Format</label>\n <select\n value={format}\n onChange={(e) => setFormat(e.target.value)}\n className=\"h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring\"\n >\n {formats.map((f) => (\n <option key={f} value={f}>\n {f}\n </option>\n ))}\n </select>\n </div>\n </div>\n <div className=\"mt-5\">\n <button\n onClick={handleExport}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors\"\n >\n <Download className=\"h-4 w-4\" />\n Export\n </button>\n </div>\n </div>\n\n <div>\n <h2 className=\"mb-3 text-lg font-medium text-foreground\">Recent Exports</h2>\n <DataTable columns={columns} data={recentExports} keyField=\"id\" />\n </div>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;AAOA,IAAM,IAAY;CAAC;CAAS;CAAa;CAAa;CAAU,EAC1D,IAAU;CAAC;CAAO;CAAO;CAAQ,EAYjC,IAAiC;CACrC;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ;EACR,MAAM;EACN,MAAM;EACN,QAAQ;EACT;CACD;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ;EACR,MAAM;EACN,MAAM;EACN,QAAQ;EACT;CACD;EACE,IAAI;E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SAAE,OAAO;SAAmB,aAAa,GAAG,EAAS,oBAAoB;SAAU,SAAS;SAAW,CAAC;;OAuFtG,WAAU;iBAFZ,CAIE,kBAAC,GAAD,EAAU,WAAU,WAAY,CAAA,EAAA,SAEzB;;MACL,CAAA;KACF;;GAEN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,MAAD;IAAI,WAAU;cAA2C;IAAmB,CAAA,EAC5E,kBAAC,GAAD;IAAoB,SA9FV;KACd;MAAE,KAAK;MAAQ,QAAQ;MAAe;KACtC;MACE,KAAK;MACL,QAAQ;MACR,SAAS,MAAiC,kBAAC,GAAD;OAAa,OAAO,EAAE;OAAM,SAAQ;OAAS,CAAA;MACxF;KACD;MACE,KAAK;MACL,QAAQ;MACR,SAAS,MACP,kBAAC,QAAD;OAAM,WAAU;iBAAhB;QACG,EAAY,EAAE;QAAQ;QAAE,EAAE;QACtB;;MAEV;KACD;MACE,KAAK;MACL,QAAQ;MACR,SAAS,MAAiC,kBAAC,QAAD;OAAM,WAAU;iBAAyB,EAAW,EAAE,KAAK;OAAQ,CAAA;MAC9G;KACD;MAAE,KAAK;MAAQ,QAAQ;MAAQ;KAC/B;MACE,KAAK;MACL,QAAQ;MACR,SAAS,MAAiC,kBAAC,GAAD;OAAa,OAAO,EAAE;OAAQ,SAAQ;OAAU,KAAA;OAAM,CAAA;MACjG;KACF;IAmEkC,MAAM;IAAe,UAAS;IAAO,CAAA,CAC9D,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 { 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';\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.\nconst DATA_TYPES: { label: string; entityType: HealthyBowlExportEntity }[] = [\n { label: 'Crops', entityType: 'healthybowl_crops' },\n { label: 'Livestock', entityType: 'healthybowl_animals' },\n { label: 'Financial', entityType: 'healthybowl_transactions' },\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 bg-background px-3 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring';\n\nexport function ExportPage() {\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((t) => t.startsWith('healthybowl_'))\n );\n\n const handleExport = async () => {\n const selected = DATA_TYPES.find((d) => d.label === dataType);\n if (!selected) return;\n try {\n await runExport({\n name: `${dataType} export${dateFrom || dateTo ? ` (${dateFrom || '…'} → ${dateTo || '…'})` : ''}`,\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({ title: 'Export ready', description: 'Your download should begin shortly.', variant: 'success' });\n refetch();\n } catch (err) {\n toast({\n title: 'Export failed',\n description: err instanceof Error ? err.message : 'Something went wrong while exporting.',\n variant: 'error',\n });\n }\n };\n\n const columns = [\n { key: 'name', header: 'Export Name' },\n {\n key: 'type',\n header: 'Data',\n render: (r: ExportJobNode) => (\n <StatusBadge label={r.entityTypes.map((t) => t.replace('healthybowl_', '')).join(', ')} variant=\"info\" />\n ),\n },\n {\n key: 'format',\n header: 'Format',\n render: (r: ExportJobNode) => (\n <span className=\"inline-flex items-center gap-1.5 text-foreground\">\n <FileText className=\"h-4 w-4\" /> {r.format}\n </span>\n ),\n },\n {\n key: 'createdAt',\n header: 'Date',\n render: (r: ExportJobNode) => <span className=\"text-muted-foreground\">{formatDate(r.createdAt)}</span>,\n },\n {\n key: 'status',\n header: '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\" /> Download\n </a>\n ) : null,\n },\n ];\n\n return (\n <PageLayout title=\"Export Data\" description=\"Export your farm data via the workspace export service\">\n <div className=\"rounded-lg border border-border bg-card p-6 shadow-sm\">\n <h2 className=\"text-lg font-medium text-foreground\">New Export</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-foreground\">Data Type</label>\n <select value={dataType} onChange={(e) => setDataType(e.target.value)} className={selectClass}>\n {DATA_TYPES.map((t) => (\n <option key={t.label} value={t.label}>\n {t.label}\n </option>\n ))}\n </select>\n </div>\n <div className=\"space-y-1.5\">\n <label className=\"text-sm font-medium text-foreground\">From</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-foreground\">To</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-foreground\">Format</label>\n <select value={format} onChange={(e) => setFormat(e.target.value)} className={selectClass}>\n {FORMATS.map((f) => (\n <option key={f} value={f}>\n {f}\n </option>\n ))}\n </select>\n </div>\n </div>\n <div className=\"mt-5\">\n <button\n onClick={handleExport}\n disabled={exporting}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-60\"\n >\n <Download className=\"h-4 w-4\" />\n {exporting ? 'Exporting…' : 'Export'}\n </button>\n <p className=\"mt-2 text-xs text-muted-foreground\">\n Exports run in the background and download as a ZIP when ready.\n </p>\n </div>\n </div>\n\n <div>\n <h2 className=\"mb-3 text-lg font-medium text-foreground\">Recent Exports</h2>\n {loading ? (\n <div className=\"rounded-lg border border-border bg-card p-6 text-sm text-muted-foreground\">Loading…</div>\n ) : jobs.length === 0 ? (\n <EmptyState\n title=\"No exports yet\"\n description=\"Create an export above — it will appear here once it's ready.\"\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":";;;;;;;;;;;;;;;;AAcA,IAAM,IAAuE;CAC3E;EAAE,OAAO;EAAS,YAAY;EAAqB;CACnD;EAAE,OAAO;EAAa,YAAY;EAAuB;CACzD;EAAE,OAAO;EAAa,YAAY;EAA4B;CAC/D,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,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,gBAAa,EAAE,EACxC,CAAC,EAGI,KAAQ,GAAM,gBAAgB,OAAO,KAAK,MAAM,EAAE,KAAK,IAAI,EAAE,EAAE,QAAQ,OAC1E,EAAE,eAAe,EAAE,EAAE,MAAM,MAAM,EAAE,WAAW,eAAe,CAAC,CAChE;AAuED,QACE,kBAAC,GAAD;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