@burdenoff/microfe-assethandler 2026.826.16 → 2026.826.17
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.
|
@@ -67,6 +67,10 @@ export interface GenerateResult {
|
|
|
67
67
|
/** The four values the backend accepts for a PLAN. */
|
|
68
68
|
export declare const PLAN_TYPES: readonly ["PREVENTIVE", "CORRECTIVE", "PREDICTIVE", "INSPECTION"];
|
|
69
69
|
export declare const PLAN_PRIORITIES: readonly ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
|
|
70
|
+
export declare const MAINTENANCE_PLAN_FEEDBACK: {
|
|
71
|
+
readonly created: "Preview due work, then explicitly raise maintenance records.";
|
|
72
|
+
readonly deleted: "Previously generated service records have been kept.";
|
|
73
|
+
};
|
|
70
74
|
export declare function useMaintenancePlans(options?: {
|
|
71
75
|
includeInactive?: boolean;
|
|
72
76
|
withinDays?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMaintenancePlans.d.ts","sourceRoot":"","sources":["../../../src/assethandler/hooks/useMaintenancePlans.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAY,MAAM,sBAAsB,CAAC;AAG7D;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,uBAAuB,gCAqBnC,CAAC;AAwEF,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gBAAgB,EAAE,MAAM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AY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,CAAC;CAC/F;AAED,sDAAsD;AACtD,eAAO,MAAM,UAAU,mEAAoE,CAAC;AAC5F,eAAO,MAAM,eAAe,gDAAiD,CAAC;AAC9E,eAAO,MAAM,yBAAyB;;;CAG5B,CAAC;AAIX,wBAAgB,mBAAmB,CACjC,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO;;;;;;;;;;;;;;;;uCAkC/B,cAAc;;;;;EAyBhD"}
|
|
@@ -91,46 +91,49 @@ var i = t`
|
|
|
91
91
|
"HIGH",
|
|
92
92
|
"MEDIUM",
|
|
93
93
|
"LOW"
|
|
94
|
-
], p =
|
|
95
|
-
|
|
94
|
+
], p = {
|
|
95
|
+
created: "Preview due work, then explicitly raise maintenance records.",
|
|
96
|
+
deleted: "Previously generated service records have been kept."
|
|
97
|
+
}, m = ["AssetHandlerMaintenancePlans", "AssetHandlerDueMaintenancePlans"];
|
|
98
|
+
function h(t = {}) {
|
|
96
99
|
let { includeInactive: i = !1, withinDays: d = 0 } = t, f = r(a, {
|
|
97
100
|
variables: { includeInactive: i },
|
|
98
101
|
fetchPolicy: "cache-and-network"
|
|
99
|
-
}),
|
|
102
|
+
}), h = r(o, {
|
|
100
103
|
variables: { withinDays: d },
|
|
101
104
|
fetchPolicy: "cache-and-network"
|
|
102
|
-
}), [
|
|
103
|
-
refetchQueries:
|
|
104
|
-
onCompleted: () => e.success("Plan created",
|
|
105
|
+
}), [g, _] = n(s, {
|
|
106
|
+
refetchQueries: m,
|
|
107
|
+
onCompleted: () => e.success("Plan created", p.created),
|
|
105
108
|
onError: (t) => e.error("Could not create the plan", t.message)
|
|
106
|
-
}), [
|
|
107
|
-
refetchQueries:
|
|
109
|
+
}), [v, y] = n(c, {
|
|
110
|
+
refetchQueries: m,
|
|
108
111
|
onCompleted: () => e.success("Plan updated"),
|
|
109
112
|
onError: (t) => e.error("Could not update the plan", t.message)
|
|
110
|
-
}), [
|
|
111
|
-
refetchQueries:
|
|
112
|
-
onCompleted: () => e.success("Plan deleted",
|
|
113
|
+
}), [b, x] = n(l, {
|
|
114
|
+
refetchQueries: m,
|
|
115
|
+
onCompleted: () => e.success("Plan deleted", p.deleted),
|
|
113
116
|
onError: (t) => e.error("Could not delete the plan", t.message)
|
|
114
|
-
}), [
|
|
115
|
-
refetchQueries: [...
|
|
117
|
+
}), [S, C] = n(u, {
|
|
118
|
+
refetchQueries: [...m, "AssetHandlerBootstrap"],
|
|
116
119
|
onError: (t) => e.error("Could not raise the work", t.message)
|
|
117
120
|
});
|
|
118
121
|
return {
|
|
119
122
|
plans: f.data?.maintenancePlans ?? [],
|
|
120
|
-
duePlans:
|
|
121
|
-
loading: f.loading ||
|
|
122
|
-
error: f.error ??
|
|
123
|
+
duePlans: h.data?.dueMaintenancePlans ?? [],
|
|
124
|
+
loading: f.loading || h.loading,
|
|
125
|
+
error: f.error ?? h.error ?? null,
|
|
123
126
|
refetch: () => {
|
|
124
|
-
f.refetch(),
|
|
127
|
+
f.refetch(), h.refetch();
|
|
125
128
|
},
|
|
126
|
-
createPlan:
|
|
127
|
-
updatePlan:
|
|
128
|
-
deletePlan:
|
|
129
|
-
generateRecords:
|
|
130
|
-
busy:
|
|
129
|
+
createPlan: g,
|
|
130
|
+
updatePlan: v,
|
|
131
|
+
deletePlan: b,
|
|
132
|
+
generateRecords: S,
|
|
133
|
+
busy: _.loading || y.loading || x.loading || C.loading
|
|
131
134
|
};
|
|
132
135
|
}
|
|
133
136
|
//#endregion
|
|
134
|
-
export { f as PLAN_PRIORITIES, d as PLAN_TYPES,
|
|
137
|
+
export { f as PLAN_PRIORITIES, d as PLAN_TYPES, h as useMaintenancePlans };
|
|
135
138
|
|
|
136
139
|
//# sourceMappingURL=useMaintenancePlans.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMaintenancePlans.js","names":[],"sources":["../../../src/assethandler/hooks/useMaintenancePlans.ts"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { notify } from '../utils/toast';\n\n/**\n * Recurring preventive-maintenance plans (BOFF-6031).\n *\n * These operations post-date the MFE's bootstrap query, so they are hand-written\n * `gql` documents rather than additions to it: the bootstrap is one large query\n * every page pays for, and plans are only needed on the plans surface.\n *\n * ── What the backend guarantees, and what this must therefore not do ─────────\n *\n * `nextDueAt` / `nextDueMeter` are DERIVED server-side on every read — they are\n * not stored. So this layer never caches a due date or recomputes one locally;\n * it re-reads after anything that could move it.\n *\n * `currentMeter`, `nextDueMeter`, `daysUntilDue` and `meterUntilDue` are all\n * genuinely nullable and null means \"not applicable\", never zero. An asset that\n * nobody meters has no meter reading; rendering that as 0 would claim a machine\n * sitting at zero hours.\n */\n\nexport const MAINTENANCE_PLAN_FIELDS = gql`\n fragment MaintenancePlanFields on MaintenancePlan {\n id\n assetId\n title\n description\n type\n priority\n isActive\n intervalDays\n intervalMeter\n lastServiceAt\n lastServiceMeter\n startAt\n startMeter\n leadTimeDays\n estimatedCost\n checklistTemplate\n createdAt\n updatedAt\n }\n`;\n\nconst MAINTENANCE_PLANS_QUERY = gql`\n ${MAINTENANCE_PLAN_FIELDS}\n query AssetHandlerMaintenancePlans($assetId: ID, $includeInactive: Boolean) {\n maintenancePlans(assetId: $assetId, includeInactive: $includeInactive) {\n ...MaintenancePlanFields\n }\n }\n`;\n\nconst DUE_MAINTENANCE_PLANS_QUERY = gql`\n ${MAINTENANCE_PLAN_FIELDS}\n query AssetHandlerDueMaintenancePlans($assetId: ID, $withinDays: Int) {\n dueMaintenancePlans(assetId: $assetId, withinDays: $withinDays) {\n plan {\n ...MaintenancePlanFields\n }\n nextDueAt\n nextDueMeter\n currentMeter\n meterUnit\n isDue\n isOverdue\n daysUntilDue\n meterUntilDue\n dueReason\n }\n }\n`;\n\nconst CREATE_MAINTENANCE_PLAN = gql`\n ${MAINTENANCE_PLAN_FIELDS}\n mutation AssetHandlerCreateMaintenancePlan($input: CreateMaintenancePlanInput!) {\n createMaintenancePlan(input: $input) {\n ...MaintenancePlanFields\n }\n }\n`;\n\nconst UPDATE_MAINTENANCE_PLAN = gql`\n ${MAINTENANCE_PLAN_FIELDS}\n mutation AssetHandlerUpdateMaintenancePlan($id: ID!, $input: UpdateMaintenancePlanInput!) {\n updateMaintenancePlan(id: $id, input: $input) {\n ...MaintenancePlanFields\n }\n }\n`;\n\nconst DELETE_MAINTENANCE_PLAN = gql`\n mutation AssetHandlerDeleteMaintenancePlan($id: ID!) {\n deleteMaintenancePlan(id: $id)\n }\n`;\n\nconst GENERATE_DUE_RECORDS = gql`\n mutation AssetHandlerGenerateDueMaintenanceRecords($input: GenerateMaintenanceRecordsInput) {\n generateDueMaintenanceRecords(input: $input) {\n dryRun\n generated\n skipped\n notes\n records {\n id\n title\n scheduledAt\n dueMeter\n }\n }\n }\n`;\n\nexport interface MaintenancePlan {\n id: string;\n assetId: string;\n title: string;\n description: string | null;\n type: string;\n priority: string;\n isActive: boolean;\n intervalDays: number | null;\n intervalMeter: number | null;\n lastServiceAt: string | null;\n lastServiceMeter: number | null;\n startAt: string | null;\n startMeter: number | null;\n leadTimeDays: number | null;\n estimatedCost: number | null;\n checklistTemplate: Record<string, unknown>[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface DueMaintenancePlan {\n plan: MaintenancePlan;\n nextDueAt: string | null;\n nextDueMeter: number | null;\n currentMeter: number | null;\n /** What that reading counts in. Null when the asset carries no unit. */\n meterUnit: string | null;\n isDue: boolean;\n isOverdue: boolean;\n daysUntilDue: number | null;\n meterUntilDue: number | null;\n dueReason: string | null;\n}\n\nexport interface GenerateResult {\n dryRun: boolean;\n generated: number;\n skipped: number;\n notes: string[];\n records: { id: string; title: string; scheduledAt: string | null; dueMeter: number | null }[];\n}\n\n/** The four values the backend accepts for a PLAN. */\nexport const PLAN_TYPES = ['PREVENTIVE', 'CORRECTIVE', 'PREDICTIVE', 'INSPECTION'] as const;\nexport const PLAN_PRIORITIES = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'] as const;\n\nconst REFETCH = ['AssetHandlerMaintenancePlans', 'AssetHandlerDueMaintenancePlans'];\n\nexport function useMaintenancePlans(\n options: { includeInactive?: boolean; withinDays?: number } = {}\n) {\n const { includeInactive = false, withinDays = 0 } = options;\n\n const plansQuery = useQuery<{ maintenancePlans: MaintenancePlan[] }>(MAINTENANCE_PLANS_QUERY, {\n variables: { includeInactive },\n fetchPolicy: 'cache-and-network',\n });\n\n const dueQuery = useQuery<{ dueMaintenancePlans: DueMaintenancePlan[] }>(\n DUE_MAINTENANCE_PLANS_QUERY,\n { variables: { withinDays }, fetchPolicy: 'cache-and-network' }\n );\n\n const [createPlan, createState] = useMutation(CREATE_MAINTENANCE_PLAN, {\n refetchQueries: REFETCH,\n onCompleted: () => notify.success('Plan created',
|
|
1
|
+
{"version":3,"file":"useMaintenancePlans.js","names":[],"sources":["../../../src/assethandler/hooks/useMaintenancePlans.ts"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { notify } from '../utils/toast';\n\n/**\n * Recurring preventive-maintenance plans (BOFF-6031).\n *\n * These operations post-date the MFE's bootstrap query, so they are hand-written\n * `gql` documents rather than additions to it: the bootstrap is one large query\n * every page pays for, and plans are only needed on the plans surface.\n *\n * ── What the backend guarantees, and what this must therefore not do ─────────\n *\n * `nextDueAt` / `nextDueMeter` are DERIVED server-side on every read — they are\n * not stored. So this layer never caches a due date or recomputes one locally;\n * it re-reads after anything that could move it.\n *\n * `currentMeter`, `nextDueMeter`, `daysUntilDue` and `meterUntilDue` are all\n * genuinely nullable and null means \"not applicable\", never zero. An asset that\n * nobody meters has no meter reading; rendering that as 0 would claim a machine\n * sitting at zero hours.\n */\n\nexport const MAINTENANCE_PLAN_FIELDS = gql`\n fragment MaintenancePlanFields on MaintenancePlan {\n id\n assetId\n title\n description\n type\n priority\n isActive\n intervalDays\n intervalMeter\n lastServiceAt\n lastServiceMeter\n startAt\n startMeter\n leadTimeDays\n estimatedCost\n checklistTemplate\n createdAt\n updatedAt\n }\n`;\n\nconst MAINTENANCE_PLANS_QUERY = gql`\n ${MAINTENANCE_PLAN_FIELDS}\n query AssetHandlerMaintenancePlans($assetId: ID, $includeInactive: Boolean) {\n maintenancePlans(assetId: $assetId, includeInactive: $includeInactive) {\n ...MaintenancePlanFields\n }\n }\n`;\n\nconst DUE_MAINTENANCE_PLANS_QUERY = gql`\n ${MAINTENANCE_PLAN_FIELDS}\n query AssetHandlerDueMaintenancePlans($assetId: ID, $withinDays: Int) {\n dueMaintenancePlans(assetId: $assetId, withinDays: $withinDays) {\n plan {\n ...MaintenancePlanFields\n }\n nextDueAt\n nextDueMeter\n currentMeter\n meterUnit\n isDue\n isOverdue\n daysUntilDue\n meterUntilDue\n dueReason\n }\n }\n`;\n\nconst CREATE_MAINTENANCE_PLAN = gql`\n ${MAINTENANCE_PLAN_FIELDS}\n mutation AssetHandlerCreateMaintenancePlan($input: CreateMaintenancePlanInput!) {\n createMaintenancePlan(input: $input) {\n ...MaintenancePlanFields\n }\n }\n`;\n\nconst UPDATE_MAINTENANCE_PLAN = gql`\n ${MAINTENANCE_PLAN_FIELDS}\n mutation AssetHandlerUpdateMaintenancePlan($id: ID!, $input: UpdateMaintenancePlanInput!) {\n updateMaintenancePlan(id: $id, input: $input) {\n ...MaintenancePlanFields\n }\n }\n`;\n\nconst DELETE_MAINTENANCE_PLAN = gql`\n mutation AssetHandlerDeleteMaintenancePlan($id: ID!) {\n deleteMaintenancePlan(id: $id)\n }\n`;\n\nconst GENERATE_DUE_RECORDS = gql`\n mutation AssetHandlerGenerateDueMaintenanceRecords($input: GenerateMaintenanceRecordsInput) {\n generateDueMaintenanceRecords(input: $input) {\n dryRun\n generated\n skipped\n notes\n records {\n id\n title\n scheduledAt\n dueMeter\n }\n }\n }\n`;\n\nexport interface MaintenancePlan {\n id: string;\n assetId: string;\n title: string;\n description: string | null;\n type: string;\n priority: string;\n isActive: boolean;\n intervalDays: number | null;\n intervalMeter: number | null;\n lastServiceAt: string | null;\n lastServiceMeter: number | null;\n startAt: string | null;\n startMeter: number | null;\n leadTimeDays: number | null;\n estimatedCost: number | null;\n checklistTemplate: Record<string, unknown>[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface DueMaintenancePlan {\n plan: MaintenancePlan;\n nextDueAt: string | null;\n nextDueMeter: number | null;\n currentMeter: number | null;\n /** What that reading counts in. Null when the asset carries no unit. */\n meterUnit: string | null;\n isDue: boolean;\n isOverdue: boolean;\n daysUntilDue: number | null;\n meterUntilDue: number | null;\n dueReason: string | null;\n}\n\nexport interface GenerateResult {\n dryRun: boolean;\n generated: number;\n skipped: number;\n notes: string[];\n records: { id: string; title: string; scheduledAt: string | null; dueMeter: number | null }[];\n}\n\n/** The four values the backend accepts for a PLAN. */\nexport const PLAN_TYPES = ['PREVENTIVE', 'CORRECTIVE', 'PREDICTIVE', 'INSPECTION'] as const;\nexport const PLAN_PRIORITIES = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'] as const;\nexport const MAINTENANCE_PLAN_FEEDBACK = {\n created: 'Preview due work, then explicitly raise maintenance records.',\n deleted: 'Previously generated service records have been kept.',\n} as const;\n\nconst REFETCH = ['AssetHandlerMaintenancePlans', 'AssetHandlerDueMaintenancePlans'];\n\nexport function useMaintenancePlans(\n options: { includeInactive?: boolean; withinDays?: number } = {}\n) {\n const { includeInactive = false, withinDays = 0 } = options;\n\n const plansQuery = useQuery<{ maintenancePlans: MaintenancePlan[] }>(MAINTENANCE_PLANS_QUERY, {\n variables: { includeInactive },\n fetchPolicy: 'cache-and-network',\n });\n\n const dueQuery = useQuery<{ dueMaintenancePlans: DueMaintenancePlan[] }>(\n DUE_MAINTENANCE_PLANS_QUERY,\n { variables: { withinDays }, fetchPolicy: 'cache-and-network' }\n );\n\n const [createPlan, createState] = useMutation(CREATE_MAINTENANCE_PLAN, {\n refetchQueries: REFETCH,\n onCompleted: () => notify.success('Plan created', MAINTENANCE_PLAN_FEEDBACK.created),\n onError: (error) => notify.error('Could not create the plan', error.message),\n });\n\n const [updatePlan, updateState] = useMutation(UPDATE_MAINTENANCE_PLAN, {\n refetchQueries: REFETCH,\n onCompleted: () => notify.success('Plan updated'),\n onError: (error) => notify.error('Could not update the plan', error.message),\n });\n\n const [deletePlan, deleteState] = useMutation(DELETE_MAINTENANCE_PLAN, {\n refetchQueries: REFETCH,\n // Deleting a plan does not delete service history that a user explicitly generated.\n onCompleted: () => notify.success('Plan deleted', MAINTENANCE_PLAN_FEEDBACK.deleted),\n onError: (error) => notify.error('Could not delete the plan', error.message),\n });\n\n const [generateRecords, generateState] = useMutation<{\n generateDueMaintenanceRecords: GenerateResult;\n }>(GENERATE_DUE_RECORDS, {\n // Generated records are MaintenanceRecords, which the bootstrap owns — so\n // the scheduler and calendar pages must be refreshed too, or the new work\n // is invisible everywhere except here.\n refetchQueries: [...REFETCH, 'AssetHandlerBootstrap'],\n onError: (error) => notify.error('Could not raise the work', error.message),\n });\n\n return {\n plans: plansQuery.data?.maintenancePlans ?? [],\n duePlans: dueQuery.data?.dueMaintenancePlans ?? [],\n loading: plansQuery.loading || dueQuery.loading,\n error: plansQuery.error ?? dueQuery.error ?? null,\n refetch: () => {\n void plansQuery.refetch();\n void dueQuery.refetch();\n },\n createPlan,\n updatePlan,\n deletePlan,\n generateRecords,\n busy:\n createState.loading || updateState.loading || deleteState.loading || generateState.loading,\n };\n}\n"],"mappings":";;;;AAuBA,IAAa,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;;GAuBpC,IAA0B,CAAG;IAC/B,EAAwB;;;;;;GAQtB,IAA8B,CAAG;IACnC,EAAwB;;;;;;;;;;;;;;;;;GAmBtB,IAA0B,CAAG;IAC/B,EAAwB;;;;;;GAQtB,IAA0B,CAAG;IAC/B,EAAwB;;;;;;GAQtB,IAA0B,CAAG;;;;GAM7B,IAAuB,CAAG;;;;;;;;;;;;;;;GA6DnB,IAAa;CAAC;CAAc;CAAc;CAAc;AAAY,GACpE,IAAkB;CAAC;CAAY;CAAQ;CAAU;AAAK,GACtD,IAA4B;CACvC,SAAS;CACT,SAAS;AACX,GAEM,IAAU,CAAC,gCAAgC,iCAAiC;AAElF,SAAgB,EACd,IAA8D,CAAC,GAC/D;CACA,IAAM,EAAE,qBAAkB,IAAO,gBAAa,MAAM,GAE9C,IAAa,EAAkD,GAAyB;EAC5F,WAAW,EAAE,mBAAgB;EAC7B,aAAa;CACf,CAAC,GAEK,IAAW,EACf,GACA;EAAE,WAAW,EAAE,cAAW;EAAG,aAAa;CAAoB,CAChE,GAEM,CAAC,GAAY,KAAe,EAAY,GAAyB;EACrE,gBAAgB;EAChB,mBAAmB,EAAO,QAAQ,gBAAgB,EAA0B,OAAO;EACnF,UAAU,MAAU,EAAO,MAAM,6BAA6B,EAAM,OAAO;CAC7E,CAAC,GAEK,CAAC,GAAY,KAAe,EAAY,GAAyB;EACrE,gBAAgB;EAChB,mBAAmB,EAAO,QAAQ,cAAc;EAChD,UAAU,MAAU,EAAO,MAAM,6BAA6B,EAAM,OAAO;CAC7E,CAAC,GAEK,CAAC,GAAY,KAAe,EAAY,GAAyB;EACrE,gBAAgB;EAEhB,mBAAmB,EAAO,QAAQ,gBAAgB,EAA0B,OAAO;EACnF,UAA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