@burdenoff/microfe-healthybowl 2026.918.1 → 2026.918.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,12 +1,13 @@
1
1
  import { Modal as e } from "../../components/Modal.js";
2
2
  import "../../components/index.js";
3
3
  import { readMutationErrorMessage as t, validateEidTagInput as n } from "./eidTagInput.js";
4
- import { useEffect as r, useState as i } from "react";
5
- import { useI18n as a } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
6
- import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
7
- import { Button as l, Input as u, Select as d, SelectContent as f, SelectItem as p, SelectTrigger as m, SelectValue as h, Textarea as g } from "@burdenoff/fe-libs/ui";
4
+ import { buildParentOptions as r } from "./parentOptions.js";
5
+ import { useEffect as i, useState as a } from "react";
6
+ import { useI18n as o } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
7
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
8
+ import { Button as u, Input as d, Select as f, SelectContent as p, SelectItem as m, SelectTrigger as h, SelectValue as g, Textarea as _ } from "@burdenoff/fe-libs/ui";
8
9
  //#region src/healthybowl/pages/livestock/AnimalDepthFormModal.tsx
9
- var _ = "__none__", v = {
10
+ var v = "__none__", y = {
10
11
  tooLong: {
11
12
  key: "healthybowl.livestock.depth.edit.eidTooLong",
12
13
  fallback: "The EID / RFID tag must be 100 characters or fewer."
@@ -19,158 +20,174 @@ var _ = "__none__", v = {
19
20
  key: "healthybowl.livestock.depth.edit.eidNoAlphanumeric",
20
21
  fallback: "The EID / RFID tag must contain at least one letter or digit."
21
22
  }
22
- }, y = "mb-1 block text-sm font-medium text-text-primary", b = "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", x = ({ open: x, onClose: S, animal: C, groups: w, animalOptions: T, onSubmit: E }) => {
23
- let { t: D } = a(), [O, k] = i(""), [A, j] = i(""), [M, N] = i(_), [P, F] = i(_), [I, L] = i(_), [R, z] = i(""), [B, V] = i(""), [H, U] = i(""), [W, G] = i(!1), [K, q] = i(null);
24
- r(() => {
25
- x && (q(null), k(C.eidTag ?? ""), j(C.bodyConditionScore === null ? "" : String(C.bodyConditionScore)), N(C.groupId ?? _), F(C.damId ?? _), L(C.sireId ?? _), z(C.grazingPaddock ?? ""), V(C.rotationDate ? C.rotationDate.slice(0, 10) : ""), U(C.grazingNotes ?? ""));
26
- }, [x, C]);
27
- let J = T.filter((e) => e.animalId !== C.animalId).sort((e, t) => Number(e.archived) - Number(t.archived)), Y = async () => {
28
- if (W) return;
29
- let e = A.trim() === "" ? null : Number(A);
23
+ }, b = "mb-1 block text-sm font-medium text-text-primary", x = "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", S = ({ open: S, onClose: C, animal: w, groups: T, animalOptions: ee, animalSearch: E, onAnimalSearchChange: D, animalOptionsTruncated: O, animalOptionsLoading: k, onSubmit: A }) => {
24
+ let { t: j } = o(), [M, N] = a(""), [P, F] = a(""), [I, L] = a(v), [R, z] = a(v), [B, V] = a(v), [H, U] = a(""), [W, G] = a(""), [K, q] = a(""), [J, Y] = a(!1), [X, Z] = a(null);
25
+ i(() => {
26
+ S && (Z(null), N(w.eidTag ?? ""), F(w.bodyConditionScore === null ? "" : String(w.bodyConditionScore)), L(w.groupId ?? v), z(w.damId ?? v), V(w.sireId ?? v), U(w.grazingPaddock ?? ""), G(w.rotationDate ? w.rotationDate.slice(0, 10) : ""), q(w.grazingNotes ?? ""));
27
+ }, [S, w]);
28
+ let Q = r(w, ee), te = async () => {
29
+ if (J) return;
30
+ let e = P.trim() === "" ? null : Number(P);
30
31
  if (e !== null && (Number.isNaN(e) || e < 0 || e > 5)) {
31
- q(D("healthybowl.livestock.depth.edit.bcsError", "Body condition score must be between 0 and 5."));
32
+ Z(j("healthybowl.livestock.depth.edit.bcsError", "Body condition score must be between 0 and 5."));
32
33
  return;
33
34
  }
34
- let r = n(O);
35
+ let r = n(M);
35
36
  if (!r.ok) {
36
- let e = v[r.reason];
37
- q(D(e.key, e.fallback));
37
+ let e = y[r.reason];
38
+ Z(j(e.key, e.fallback));
38
39
  return;
39
40
  }
40
- G(!0), q(null);
41
+ Y(!0), Z(null);
41
42
  try {
42
- await E({
43
- animalId: C.animalId,
43
+ await A({
44
+ animalId: w.animalId,
44
45
  eidTag: r.value,
45
46
  bodyConditionScore: e,
46
- groupId: M === _ ? null : M,
47
- damId: P === _ ? null : P,
48
- sireId: I === _ ? null : I,
49
- grazingPaddock: R.trim() || null,
50
- rotationDate: B || null,
51
- grazingNotes: H.trim() || null
52
- }), S();
47
+ groupId: I === v ? null : I,
48
+ damId: R === v ? null : R,
49
+ sireId: B === v ? null : B,
50
+ grazingPaddock: H.trim() || null,
51
+ rotationDate: W || null,
52
+ grazingNotes: K.trim() || null
53
+ }), C();
53
54
  } catch (e) {
54
- q(t(e, D("healthybowl.livestock.depth.edit.saveFailed", "Could not save the animal record.")));
55
+ Z(t(e, j("healthybowl.livestock.depth.edit.saveFailed", "Could not save the animal record.")));
55
56
  } finally {
56
- G(!1);
57
+ Y(!1);
57
58
  }
58
- }, X = (e, t, n) => /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
59
- className: y,
59
+ }, $ = (e, t, n) => /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
60
+ className: b,
60
61
  children: n
61
- }), /* @__PURE__ */ c(d, {
62
+ }), /* @__PURE__ */ l(f, {
62
63
  value: e,
63
64
  onValueChange: t,
64
- children: [/* @__PURE__ */ s(m, { children: /* @__PURE__ */ s(h, {}) }), /* @__PURE__ */ c(f, { children: [/* @__PURE__ */ s(p, {
65
- value: _,
66
- children: D("healthybowl.livestock.depth.edit.none", "None")
67
- }), J.map((e) => /* @__PURE__ */ s(p, {
68
- value: e.animalId,
69
- children: /* @__PURE__ */ c("span", {
70
- className: e.archived ? "text-text-secondary" : void 0,
71
- children: [
72
- e.tagNumber,
73
- " · ",
74
- e.name,
75
- e.archived ? ` · ${D("healthybowl.livestock.depth.edit.archivedOption", "archived")}` : ""
76
- ]
77
- })
78
- }, e.animalId))] })]
65
+ children: [/* @__PURE__ */ c(h, { children: /* @__PURE__ */ c(g, {}) }), /* @__PURE__ */ l(p, { children: [
66
+ /* @__PURE__ */ c("div", {
67
+ className: "p-2",
68
+ children: /* @__PURE__ */ c(d, {
69
+ value: E,
70
+ onChange: (e) => D(e.target.value),
71
+ onKeyDown: (e) => e.stopPropagation(),
72
+ placeholder: j("healthybowl.livestock.depth.edit.searchParents", "Search by tag or name…"),
73
+ "aria-label": j("healthybowl.livestock.depth.edit.searchParents", "Search by tag or name…")
74
+ })
75
+ }),
76
+ O ? /* @__PURE__ */ c("p", {
77
+ className: "px-3 pb-2 text-xs text-text-secondary",
78
+ children: j("healthybowl.livestock.depth.edit.parentsTruncated", "Showing part of the herd. Type to search for an animal that is not listed.")
79
+ }) : null,
80
+ !k && Q.length === 0 && E.trim() !== "" ? /* @__PURE__ */ c("p", {
81
+ className: "px-3 pb-2 text-xs text-text-secondary",
82
+ children: j("healthybowl.livestock.depth.edit.parentsNoMatch", "No animal matches that search.")
83
+ }) : null,
84
+ /* @__PURE__ */ c(m, {
85
+ value: v,
86
+ children: j("healthybowl.livestock.depth.edit.none", "None")
87
+ }),
88
+ Q.map((e) => /* @__PURE__ */ c(m, {
89
+ value: e.animalId,
90
+ children: /* @__PURE__ */ l("span", {
91
+ className: e.archived ? "text-text-secondary" : void 0,
92
+ children: [e.name ? `${e.tagNumber} · ${e.name}` : e.tagNumber, e.archived ? ` · ${j("healthybowl.livestock.depth.edit.archivedOption", "archived")}` : ""]
93
+ })
94
+ }, e.animalId))
95
+ ] })]
79
96
  })] });
80
- return /* @__PURE__ */ s(e, {
81
- open: x,
82
- onClose: S,
83
- title: D("healthybowl.livestock.depth.edit.title", "Edit animal record"),
84
- description: `${C.tagNumber} · ${C.name}`,
97
+ return /* @__PURE__ */ c(e, {
98
+ open: S,
99
+ onClose: C,
100
+ title: j("healthybowl.livestock.depth.edit.title", "Edit animal record"),
101
+ description: `${w.tagNumber} · ${w.name}`,
85
102
  size: "lg",
86
- footer: /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s(l, {
103
+ footer: /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(u, {
87
104
  variant: "outline",
88
- onClick: S,
89
- disabled: W,
90
- children: D("common.cancel", "Cancel")
91
- }), /* @__PURE__ */ s(l, {
92
- onClick: () => void Y(),
93
- disabled: W,
94
- children: D("healthybowl.livestock.depth.edit.save", "Save changes")
105
+ onClick: C,
106
+ disabled: J,
107
+ children: j("common.cancel", "Cancel")
108
+ }), /* @__PURE__ */ c(u, {
109
+ onClick: () => void te(),
110
+ disabled: J,
111
+ children: j("healthybowl.livestock.depth.edit.save", "Save changes")
95
112
  })] }),
96
- children: /* @__PURE__ */ c("div", {
113
+ children: /* @__PURE__ */ l("div", {
97
114
  className: "space-y-3",
98
115
  children: [
99
- K ? /* @__PURE__ */ s("div", {
116
+ X ? /* @__PURE__ */ c("div", {
100
117
  className: "rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text",
101
- children: K
118
+ children: X
102
119
  }) : null,
103
- /* @__PURE__ */ c("div", {
120
+ /* @__PURE__ */ l("div", {
104
121
  className: "grid grid-cols-2 gap-3",
105
- children: [/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
106
- className: y,
107
- children: D("healthybowl.livestock.depth.edit.eid", "EID / RFID tag")
108
- }), /* @__PURE__ */ s(u, {
109
- value: O,
110
- onChange: (e) => k(e.target.value),
122
+ children: [/* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
123
+ className: b,
124
+ children: j("healthybowl.livestock.depth.edit.eid", "EID / RFID tag")
125
+ }), /* @__PURE__ */ c(d, {
126
+ value: M,
127
+ onChange: (e) => N(e.target.value),
111
128
  placeholder: "982 000123456789"
112
- })] }), /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
113
- className: y,
114
- children: D("healthybowl.livestock.depth.edit.bcs", "Body condition (0–5)")
115
- }), /* @__PURE__ */ s(u, {
129
+ })] }), /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
130
+ className: b,
131
+ children: j("healthybowl.livestock.depth.edit.bcs", "Body condition (0–5)")
132
+ }), /* @__PURE__ */ c(d, {
116
133
  type: "number",
117
134
  min: "0",
118
135
  max: "5",
119
136
  step: "0.25",
120
- value: A,
121
- onChange: (e) => j(e.target.value)
137
+ value: P,
138
+ onChange: (e) => F(e.target.value)
122
139
  })] })]
123
140
  }),
124
- /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
125
- className: y,
126
- children: D("healthybowl.livestock.depth.edit.group", "Group")
127
- }), /* @__PURE__ */ c(d, {
128
- value: M,
129
- onValueChange: N,
130
- children: [/* @__PURE__ */ s(m, { children: /* @__PURE__ */ s(h, {}) }), /* @__PURE__ */ c(f, { children: [/* @__PURE__ */ s(p, {
131
- value: _,
132
- children: D("healthybowl.livestock.depth.edit.none", "None")
133
- }), w.map((e) => /* @__PURE__ */ s(p, {
141
+ /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
142
+ className: b,
143
+ children: j("healthybowl.livestock.depth.edit.group", "Group")
144
+ }), /* @__PURE__ */ l(f, {
145
+ value: I,
146
+ onValueChange: L,
147
+ children: [/* @__PURE__ */ c(h, { children: /* @__PURE__ */ c(g, {}) }), /* @__PURE__ */ l(p, { children: [/* @__PURE__ */ c(m, {
148
+ value: v,
149
+ children: j("healthybowl.livestock.depth.edit.none", "None")
150
+ }), T.map((e) => /* @__PURE__ */ c(m, {
134
151
  value: e.id,
135
152
  children: e.name
136
153
  }, e.id))] })]
137
154
  })] }),
138
- /* @__PURE__ */ c("div", {
155
+ /* @__PURE__ */ l("div", {
139
156
  className: "grid grid-cols-2 gap-3",
140
- children: [X(P, F, D("healthybowl.livestock.depth.edit.dam", "Genealogy — Dam")), X(I, L, D("healthybowl.livestock.depth.edit.sire", "Sire"))]
157
+ children: [$(R, z, j("healthybowl.livestock.depth.edit.dam", "Genealogy — Dam")), $(B, V, j("healthybowl.livestock.depth.edit.sire", "Sire"))]
141
158
  }),
142
- /* @__PURE__ */ c("div", {
159
+ /* @__PURE__ */ l("div", {
143
160
  className: "grid grid-cols-2 gap-3",
144
161
  children: [
145
- /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
146
- className: y,
147
- children: D("healthybowl.livestock.depth.edit.paddock", "Grazing paddock (legacy)")
148
- }), /* @__PURE__ */ s(u, {
149
- value: R,
150
- onChange: (e) => z(e.target.value),
162
+ /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
163
+ className: b,
164
+ children: j("healthybowl.livestock.depth.edit.paddock", "Grazing paddock (legacy)")
165
+ }), /* @__PURE__ */ c(d, {
166
+ value: H,
167
+ onChange: (e) => U(e.target.value),
151
168
  placeholder: "Paddock 4"
152
169
  })] }),
153
- /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
154
- className: y,
155
- children: D("healthybowl.livestock.depth.edit.rotation", "Rotates on (legacy)")
156
- }), /* @__PURE__ */ s("input", {
157
- type: "date",
170
+ /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
158
171
  className: b,
159
- value: B,
160
- onChange: (e) => V(e.target.value)
172
+ children: j("healthybowl.livestock.depth.edit.rotation", "Rotates on (legacy)")
173
+ }), /* @__PURE__ */ c("input", {
174
+ type: "date",
175
+ className: x,
176
+ value: W,
177
+ onChange: (e) => G(e.target.value)
161
178
  })] }),
162
- /* @__PURE__ */ s("p", {
179
+ /* @__PURE__ */ c("p", {
163
180
  className: "col-span-2 text-xs text-text-secondary",
164
- children: D("healthybowl.livestock.depth.edit.grazingLegacyHint", "These two carry a single paddock name and one date, with no time in or out, so saving them does not move an animal and does not change rest or stocking rate. Record the move on the Grazing page instead.")
181
+ children: j("healthybowl.livestock.depth.edit.grazingLegacyHint", "These two carry a single paddock name and one date, with no time in or out, so saving them does not move an animal and does not change rest or stocking rate. Record the move on the Grazing page instead.")
165
182
  })
166
183
  ]
167
184
  }),
168
- /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
169
- className: y,
170
- children: D("healthybowl.livestock.depth.edit.grazingNotes", "Grazing / rotation notes")
171
- }), /* @__PURE__ */ s(g, {
172
- value: H,
173
- onChange: (e) => U(e.target.value),
185
+ /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
186
+ className: b,
187
+ children: j("healthybowl.livestock.depth.edit.grazingNotes", "Grazing / rotation notes")
188
+ }), /* @__PURE__ */ c(_, {
189
+ value: K,
190
+ onChange: (e) => q(e.target.value),
174
191
  rows: 2
175
192
  })] })
176
193
  ]
@@ -178,6 +195,6 @@ var _ = "__none__", v = {
178
195
  });
179
196
  };
180
197
  //#endregion
181
- export { x as AnimalDepthFormModal };
198
+ export { S as AnimalDepthFormModal };
182
199
 
183
200
  //# sourceMappingURL=AnimalDepthFormModal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnimalDepthFormModal.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/AnimalDepthFormModal.tsx"],"sourcesContent":["/**\n * Edit an animal's deep record (BOFF-2890 · L-1): EID/RFID, body-condition score, group,\n * dam/sire genealogy, grazing/rotation. Dam & sire are picked from the workspace's own animals\n * (loose links). No fabricated data — every field maps to a real column.\n */\nimport { useEffect, useState } from 'react';\nimport {\n Button,\n Input,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Modal } from '../../components';\nimport type { AnimalDepthRecord, AnimalGroup } from '../../hooks/useHealthyBowlLivestockDepth';\nimport { type EidTagRejection, readMutationErrorMessage, validateEidTagInput } from './eidTagInput';\n\nexport interface AnimalOption {\n animalId: string;\n tagNumber: string;\n name: string;\n /** Has left the herd. Still pickable — a culled or sold parent is still the parent (BOFF-6011). */\n archived: boolean;\n}\n\ninterface AnimalDepthFormModalProps {\n open: boolean;\n onClose: () => void;\n animal: AnimalDepthRecord;\n groups: AnimalGroup[];\n animalOptions: AnimalOption[];\n onSubmit: (input: Record<string, unknown>) => Promise<void>;\n}\n\nconst NONE = '__none__';\n\n/**\n * Why the EID can be rejected, in the operator's words (BOFF-6050). Keyed by the reason\n * `validateEidTagInput` returns so the copy and the rule cannot drift apart.\n */\nconst EID_REJECTION_COPY: Record<EidTagRejection, { key: string; fallback: string }> = {\n tooLong: {\n key: 'healthybowl.livestock.depth.edit.eidTooLong',\n fallback: 'The EID / RFID tag must be 100 characters or fewer.',\n },\n charset: {\n key: 'healthybowl.livestock.depth.edit.eidCharset',\n fallback: 'The EID / RFID tag may contain only letters, digits, spaces, hyphens and underscores.',\n },\n noAlphanumeric: {\n key: 'healthybowl.livestock.depth.edit.eidNoAlphanumeric',\n fallback: 'The EID / RFID tag must contain at least one letter or digit.',\n },\n};\n\nconst fieldLabel = 'mb-1 block text-sm font-medium text-text-primary';\nconst dateInput =\n 'w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\n\nexport const AnimalDepthFormModal = ({\n open,\n onClose,\n animal,\n groups,\n animalOptions,\n onSubmit,\n}: AnimalDepthFormModalProps) => {\n const { t } = useI18n();\n const [eidTag, setEidTag] = useState('');\n const [bcs, setBcs] = useState('');\n const [groupId, setGroupId] = useState(NONE);\n const [damId, setDamId] = useState(NONE);\n const [sireId, setSireId] = useState(NONE);\n const [grazingPaddock, setGrazingPaddock] = useState('');\n const [rotationDate, setRotationDate] = useState('');\n const [grazingNotes, setGrazingNotes] = useState('');\n const [submitting, setSubmitting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (!open) return;\n setError(null);\n setEidTag(animal.eidTag ?? '');\n setBcs(animal.bodyConditionScore === null ? '' : String(animal.bodyConditionScore));\n setGroupId(animal.groupId ?? NONE);\n setDamId(animal.damId ?? NONE);\n setSireId(animal.sireId ?? NONE);\n setGrazingPaddock(animal.grazingPaddock ?? '');\n setRotationDate(animal.rotationDate ? animal.rotationDate.slice(0, 10) : '');\n setGrazingNotes(animal.grazingNotes ?? '');\n }, [open, animal]);\n\n // Archived animals stay pickable, but sort after every live one so the common case is not buried\n // under years of retired stock. `Array.prototype.sort` is stable, so the backend's tagNumber\n // ordering survives inside each half.\n const parents = animalOptions\n .filter((o) => o.animalId !== animal.animalId)\n .sort((x, y) => Number(x.archived) - Number(y.archived));\n\n const handleSubmit = async () => {\n if (submitting) return;\n const bcsNum = bcs.trim() === '' ? null : Number(bcs);\n if (bcsNum !== null && (Number.isNaN(bcsNum) || bcsNum < 0 || bcsNum > 5)) {\n setError(t('healthybowl.livestock.depth.edit.bcsError', 'Body condition score must be between 0 and 5.'));\n return;\n }\n // BOFF-6050: reject client-side what the server would reject, so an obviously-bad tag never\n // costs a round-trip. The server stays the authority — including on uniqueness, which only it\n // can decide.\n const eid = validateEidTagInput(eidTag);\n if (!eid.ok) {\n const copy = EID_REJECTION_COPY[eid.reason];\n setError(t(copy.key, copy.fallback));\n return;\n }\n setSubmitting(true);\n setError(null);\n try {\n await onSubmit({\n animalId: animal.animalId,\n eidTag: eid.value,\n bodyConditionScore: bcsNum,\n groupId: groupId === NONE ? null : groupId,\n damId: damId === NONE ? null : damId,\n sireId: sireId === NONE ? null : sireId,\n grazingPaddock: grazingPaddock.trim() || null,\n rotationDate: rotationDate || null,\n grazingNotes: grazingNotes.trim() || null,\n });\n onClose();\n } catch (err) {\n // The modal deliberately stays open — `onClose()` above is inside the try, after the await —\n // so the operator can correct a duplicate EID without retyping the whole record. The backend's\n // CONFLICT names the animal that already holds the tag; that text lives in\n // `extensions.userMessage`, not in `err.message`.\n setError(\n readMutationErrorMessage(\n err,\n t('healthybowl.livestock.depth.edit.saveFailed', 'Could not save the animal record.')\n )\n );\n } finally {\n setSubmitting(false);\n }\n };\n\n const parentSelect = (value: string, setValue: (v: string) => void, label: string) => (\n <div>\n <label className={fieldLabel}>{label}</label>\n <Select value={value} onValueChange={setValue}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value={NONE}>{t('healthybowl.livestock.depth.edit.none', 'None')}</SelectItem>\n {parents.map((o) => (\n <SelectItem key={o.animalId} value={o.animalId}>\n {/* The word carries the meaning; the muted colour is decoration only, because a state\n a user must act on may never be signalled by colour alone. */}\n <span className={o.archived ? 'text-text-secondary' : undefined}>\n {o.tagNumber} · {o.name}\n {o.archived ? ` · ${t('healthybowl.livestock.depth.edit.archivedOption', 'archived')}` : ''}\n </span>\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n );\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title={t('healthybowl.livestock.depth.edit.title', 'Edit animal record')}\n description={`${animal.tagNumber} · ${animal.name}`}\n size=\"lg\"\n footer={\n <>\n <Button variant=\"outline\" onClick={onClose} disabled={submitting}>\n {t('common.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handleSubmit()} disabled={submitting}>\n {t('healthybowl.livestock.depth.edit.save', 'Save changes')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-3\">\n {error ? (\n <div className=\"rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text\">\n {error}\n </div>\n ) : null}\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.eid', 'EID / RFID tag')}</label>\n <Input value={eidTag} onChange={(e) => setEidTag(e.target.value)} placeholder=\"982 000123456789\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.bcs', 'Body condition (0–5)')}</label>\n <Input type=\"number\" min=\"0\" max=\"5\" step=\"0.25\" value={bcs} onChange={(e) => setBcs(e.target.value)} />\n </div>\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.group', 'Group')}</label>\n <Select value={groupId} onValueChange={setGroupId}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value={NONE}>{t('healthybowl.livestock.depth.edit.none', 'None')}</SelectItem>\n {groups.map((g) => (\n <SelectItem key={g.id} value={g.id}>\n {g.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid grid-cols-2 gap-3\">\n {parentSelect(damId, setDamId, t('healthybowl.livestock.depth.edit.dam', 'Genealogy — Dam'))}\n {parentSelect(sireId, setSireId, t('healthybowl.livestock.depth.edit.sire', 'Sire'))}\n </div>\n {/* LEGACY (BOFF-2890). These two columns are not what the Grazing page reads and saving\n them does not move an animal — `rotationDate` is one scalar, so it has no time in, no\n time out and no history. Said here because the form is where the stale value gets\n written back. */}\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.paddock', 'Grazing paddock (legacy)')}\n </label>\n <Input value={grazingPaddock} onChange={(e) => setGrazingPaddock(e.target.value)} placeholder=\"Paddock 4\" />\n </div>\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.rotation', 'Rotates on (legacy)')}\n </label>\n <input\n type=\"date\"\n className={dateInput}\n value={rotationDate}\n onChange={(e) => setRotationDate(e.target.value)}\n />\n </div>\n <p className=\"col-span-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.depth.edit.grazingLegacyHint',\n 'These two carry a single paddock name and one date, with no time in or out, so saving them does not move an animal and does not change rest or stocking rate. Record the move on the Grazing page instead.'\n )}\n </p>\n </div>\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.grazingNotes', 'Grazing / rotation notes')}\n </label>\n <Textarea value={grazingNotes} onChange={(e) => setGrazingNotes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EAAE,OAAO,KAAK;KAAG,MAAM;IAAI,CAAA,CACxF,EAAA,CAAA;GACF;;CACA,CAAA;AAEX"}
1
+ {"version":3,"file":"AnimalDepthFormModal.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/AnimalDepthFormModal.tsx"],"sourcesContent":["/**\n * Edit an animal's deep record (BOFF-2890 · L-1): EID/RFID, body-condition score, group,\n * dam/sire genealogy, grazing/rotation. Dam & sire are picked from the workspace's own animals\n * (loose links). No fabricated data — every field maps to a real column.\n */\nimport { useEffect, useState } from 'react';\nimport {\n Button,\n Input,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Modal } from '../../components';\nimport type { AnimalDepthRecord, AnimalGroup } from '../../hooks/useHealthyBowlLivestockDepth';\nimport { type EidTagRejection, readMutationErrorMessage, validateEidTagInput } from './eidTagInput';\nimport { type AnimalOption, buildParentOptions } from './parentOptions';\n\nexport type { AnimalOption };\n\ninterface AnimalDepthFormModalProps {\n open: boolean;\n onClose: () => void;\n animal: AnimalDepthRecord;\n groups: AnimalGroup[];\n /** A SERVER-FILTERED slice of the herd, not the whole herd — see `animalOptionsTruncated`. */\n animalOptions: AnimalOption[];\n animalSearch: string;\n onAnimalSearchChange: (value: string) => void;\n /** True when the herd read hit its row cap, so the list on screen is not everything. */\n animalOptionsTruncated: boolean;\n animalOptionsLoading: boolean;\n onSubmit: (input: Record<string, unknown>) => Promise<void>;\n}\n\nconst NONE = '__none__';\n\n/**\n * Why the EID can be rejected, in the operator's words (BOFF-6050). Keyed by the reason\n * `validateEidTagInput` returns so the copy and the rule cannot drift apart.\n */\nconst EID_REJECTION_COPY: Record<EidTagRejection, { key: string; fallback: string }> = {\n tooLong: {\n key: 'healthybowl.livestock.depth.edit.eidTooLong',\n fallback: 'The EID / RFID tag must be 100 characters or fewer.',\n },\n charset: {\n key: 'healthybowl.livestock.depth.edit.eidCharset',\n fallback: 'The EID / RFID tag may contain only letters, digits, spaces, hyphens and underscores.',\n },\n noAlphanumeric: {\n key: 'healthybowl.livestock.depth.edit.eidNoAlphanumeric',\n fallback: 'The EID / RFID tag must contain at least one letter or digit.',\n },\n};\n\nconst fieldLabel = 'mb-1 block text-sm font-medium text-text-primary';\nconst dateInput =\n 'w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\n\nexport const AnimalDepthFormModal = ({\n open,\n onClose,\n animal,\n groups,\n animalOptions,\n animalSearch,\n onAnimalSearchChange,\n animalOptionsTruncated,\n animalOptionsLoading,\n onSubmit,\n}: AnimalDepthFormModalProps) => {\n const { t } = useI18n();\n const [eidTag, setEidTag] = useState('');\n const [bcs, setBcs] = useState('');\n const [groupId, setGroupId] = useState(NONE);\n const [damId, setDamId] = useState(NONE);\n const [sireId, setSireId] = useState(NONE);\n const [grazingPaddock, setGrazingPaddock] = useState('');\n const [rotationDate, setRotationDate] = useState('');\n const [grazingNotes, setGrazingNotes] = useState('');\n const [submitting, setSubmitting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (!open) return;\n setError(null);\n setEidTag(animal.eidTag ?? '');\n setBcs(animal.bodyConditionScore === null ? '' : String(animal.bodyConditionScore));\n setGroupId(animal.groupId ?? NONE);\n setDamId(animal.damId ?? NONE);\n setSireId(animal.sireId ?? NONE);\n setGrazingPaddock(animal.grazingPaddock ?? '');\n setRotationDate(animal.rotationDate ? animal.rotationDate.slice(0, 10) : '');\n setGrazingNotes(animal.grazingNotes ?? '');\n }, [open, animal]);\n\n // Merge + de-dup + sort live in `parentOptions.ts` so the rule that keeps a recorded parent\n // offered is unit-tested rather than buried in a render body.\n const parents = buildParentOptions(animal, animalOptions);\n\n const handleSubmit = async () => {\n if (submitting) return;\n const bcsNum = bcs.trim() === '' ? null : Number(bcs);\n if (bcsNum !== null && (Number.isNaN(bcsNum) || bcsNum < 0 || bcsNum > 5)) {\n setError(t('healthybowl.livestock.depth.edit.bcsError', 'Body condition score must be between 0 and 5.'));\n return;\n }\n // BOFF-6050: reject client-side what the server would reject, so an obviously-bad tag never\n // costs a round-trip. The server stays the authority — including on uniqueness, which only it\n // can decide.\n const eid = validateEidTagInput(eidTag);\n if (!eid.ok) {\n const copy = EID_REJECTION_COPY[eid.reason];\n setError(t(copy.key, copy.fallback));\n return;\n }\n setSubmitting(true);\n setError(null);\n try {\n await onSubmit({\n animalId: animal.animalId,\n eidTag: eid.value,\n bodyConditionScore: bcsNum,\n groupId: groupId === NONE ? null : groupId,\n damId: damId === NONE ? null : damId,\n sireId: sireId === NONE ? null : sireId,\n grazingPaddock: grazingPaddock.trim() || null,\n rotationDate: rotationDate || null,\n grazingNotes: grazingNotes.trim() || null,\n });\n onClose();\n } catch (err) {\n // The modal deliberately stays open — `onClose()` above is inside the try, after the await —\n // so the operator can correct a duplicate EID without retyping the whole record. The backend's\n // CONFLICT names the animal that already holds the tag; that text lives in\n // `extensions.userMessage`, not in `err.message`.\n setError(\n readMutationErrorMessage(\n err,\n t('healthybowl.livestock.depth.edit.saveFailed', 'Could not save the animal record.')\n )\n );\n } finally {\n setSubmitting(false);\n }\n };\n\n const parentSelect = (value: string, setValue: (v: string) => void, label: string) => (\n <div>\n <label className={fieldLabel}>{label}</label>\n <Select value={value} onValueChange={setValue}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {/* The search reaches the WHOLE herd, not just what is rendered — Radix's built-in\n typeahead only matches items already in the DOM, which is precisely why a capped list\n could not be searched past. Stop-propagation keeps the Select's own key handling from\n swallowing what is typed here. */}\n <div className=\"p-2\">\n <Input\n value={animalSearch}\n onChange={(e) => onAnimalSearchChange(e.target.value)}\n onKeyDown={(e) => e.stopPropagation()}\n placeholder={t('healthybowl.livestock.depth.edit.searchParents', 'Search by tag or name…')}\n aria-label={t('healthybowl.livestock.depth.edit.searchParents', 'Search by tag or name…')}\n />\n </div>\n {animalOptionsTruncated ? (\n <p className=\"px-3 pb-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.depth.edit.parentsTruncated',\n 'Showing part of the herd. Type to search for an animal that is not listed.'\n )}\n </p>\n ) : null}\n {!animalOptionsLoading && parents.length === 0 && animalSearch.trim() !== '' ? (\n <p className=\"px-3 pb-2 text-xs text-text-secondary\">\n {t('healthybowl.livestock.depth.edit.parentsNoMatch', 'No animal matches that search.')}\n </p>\n ) : null}\n <SelectItem value={NONE}>{t('healthybowl.livestock.depth.edit.none', 'None')}</SelectItem>\n {parents.map((o) => (\n <SelectItem key={o.animalId} value={o.animalId}>\n {/* The word carries the meaning; the muted colour is decoration only, because a state\n a user must act on may never be signalled by colour alone. */}\n <span className={o.archived ? 'text-text-secondary' : undefined}>\n {o.name ? `${o.tagNumber} · ${o.name}` : o.tagNumber}\n {o.archived ? ` · ${t('healthybowl.livestock.depth.edit.archivedOption', 'archived')}` : ''}\n </span>\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n );\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title={t('healthybowl.livestock.depth.edit.title', 'Edit animal record')}\n description={`${animal.tagNumber} · ${animal.name}`}\n size=\"lg\"\n footer={\n <>\n <Button variant=\"outline\" onClick={onClose} disabled={submitting}>\n {t('common.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handleSubmit()} disabled={submitting}>\n {t('healthybowl.livestock.depth.edit.save', 'Save changes')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-3\">\n {error ? (\n <div className=\"rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text\">\n {error}\n </div>\n ) : null}\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.eid', 'EID / RFID tag')}</label>\n <Input value={eidTag} onChange={(e) => setEidTag(e.target.value)} placeholder=\"982 000123456789\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.bcs', 'Body condition (0–5)')}</label>\n <Input type=\"number\" min=\"0\" max=\"5\" step=\"0.25\" value={bcs} onChange={(e) => setBcs(e.target.value)} />\n </div>\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.group', 'Group')}</label>\n <Select value={groupId} onValueChange={setGroupId}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value={NONE}>{t('healthybowl.livestock.depth.edit.none', 'None')}</SelectItem>\n {groups.map((g) => (\n <SelectItem key={g.id} value={g.id}>\n {g.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid grid-cols-2 gap-3\">\n {parentSelect(damId, setDamId, t('healthybowl.livestock.depth.edit.dam', 'Genealogy — Dam'))}\n {parentSelect(sireId, setSireId, t('healthybowl.livestock.depth.edit.sire', 'Sire'))}\n </div>\n {/* LEGACY (BOFF-2890). These two columns are not what the Grazing page reads and saving\n them does not move an animal — `rotationDate` is one scalar, so it has no time in, no\n time out and no history. Said here because the form is where the stale value gets\n written back. */}\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.paddock', 'Grazing paddock (legacy)')}\n </label>\n <Input value={grazingPaddock} onChange={(e) => setGrazingPaddock(e.target.value)} placeholder=\"Paddock 4\" />\n </div>\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.rotation', 'Rotates on (legacy)')}\n </label>\n <input\n type=\"date\"\n className={dateInput}\n value={rotationDate}\n onChange={(e) => setRotationDate(e.target.value)}\n />\n </div>\n <p className=\"col-span-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.depth.edit.grazingLegacyHint',\n 'These two carry a single paddock name and one date, with no time in or out, so saving them does not move an animal and does not change rest or stocking rate. Record the move on the Grazing page instead.'\n )}\n </p>\n </div>\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.grazingNotes', 'Grazing / rotation notes')}\n </label>\n <Textarea value={grazingNotes} onChange={(e) => setGrazingNotes(e.target.value)} rows={2} />\n </div>\n </div>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;;;AAuCA,IAAM,IAAO,YAMP,IAAiF;CACrF,SAAS;EACP,KAAK;EACL,UAAU;CACZ;CACA,SAAS;EACP,KAAK;EACL,UAAU;CACZ;CACA,gBAAgB;EACd,KAAK;EACL,UAAU;CACZ;AACF,GAEM,IAAa,oDACb,IACJ,wKAEW,KAAwB,EACnC,SACA,YACA,WACA,WACA,mBACA,iBACA,yBACA,2BACA,yBACA,kBAC+B;CAC/B,IAAM,EAAE,SAAM,EAAQ,GAChB,CAAC,GAAQ,KAAa,EAAS,EAAE,GACjC,CAAC,GAAK,KAAU,EAAS,EAAE,GAC3B,CAAC,GAAS,KAAc,EAAS,CAAI,GACrC,CAAC,GAAO,KAAY,EAAS,CAAI,GACjC,CAAC,GAAQ,KAAa,EAAS,CAAI,GACnC,CAAC,GAAgB,KAAqB,EAAS,EAAE,GACjD,CAAC,GAAc,KAAmB,EAAS,EAAE,GAC7C,CAAC,GAAc,KAAmB,EAAS,EAAE,GAC7C,CAAC,GAAY,KAAiB,EAAS,EAAK,GAC5C,CAAC,GAAO,KAAY,EAAwB,IAAI;CAEtD,QAAgB;EACT,MACL,EAAS,IAAI,GACb,EAAU,EAAO,UAAU,EAAE,GAC7B,EAAO,EAAO,uBAAuB,OAAO,KAAK,OAAO,EAAO,kBAAkB,CAAC,GAClF,EAAW,EAAO,WAAW,CAAI,GACjC,EAAS,EAAO,SAAS,CAAI,GAC7B,EAAU,EAAO,UAAU,CAAI,GAC/B,EAAkB,EAAO,kBAAkB,EAAE,GAC7C,EAAgB,EAAO,eAAe,EAAO,aAAa,MAAM,GAAG,EAAE,IAAI,EAAE,GAC3E,EAAgB,EAAO,gBAAgB,EAAE;CAC3C,GAAG,CAAC,GAAM,CAAM,CAAC;C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OAAG,aAAY;MAAa,CAAA,CACxG,EAAA,CAAA;MACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;OAAO,WAAW;iBACf,EAAE,6CAA6C,qBAAqB;MAChE,CAAA,GACP,kBAAC,SAAD;OACE,MAAK;OACL,WAAW;OACX,OAAO;OACP,WAAW,MAAM,EAAgB,EAAE,OAAO,KAAK;MAChD,CAAA,CACE,EAAA,CAAA;MACL,kBAAC,KAAD;OAAG,WAAU;iBACV,EACC,sDACA,4MACF;MACC,CAAA;KACA;;IACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;KAAO,WAAW;eACf,EAAE,iDAAiD,0BAA0B;IACzE,CAAA,GACP,kBAAC,GAAD;KAAU,OAAO;KAAc,WAAW,MAAM,EAAgB,EAAE,OAAO,KAAK;KAAG,MAAM;IAAI,CAAA,CACxF,EAAA,CAAA;GACF;;CACA,CAAA;AAEX"}
@@ -2,323 +2,333 @@ import { PageLayout as e } from "../../components/PageLayout.js";
2
2
  import { useBasePath as t } from "../../hooks/useBasePath.js";
3
3
  import { StatusBadge as n } from "../../components/StatusBadge.js";
4
4
  import { ErrorState as r } from "../../components/ErrorState.js";
5
- import { useConfirm as i } from "../../components/ConfirmDialog.js";
6
- import { Breadcrumbs as a } from "../../components/Breadcrumbs.js";
7
- import { PageLoader as ee } from "../../components/PageLoader.js";
8
- import { useToast as te } from "../../hooks/useToast.js";
5
+ import { useConfirm as ee } from "../../components/ConfirmDialog.js";
6
+ import { Breadcrumbs as i } from "../../components/Breadcrumbs.js";
7
+ import { PageLoader as a } from "../../components/PageLoader.js";
8
+ import { useToast as o } from "../../hooks/useToast.js";
9
9
  import "../../components/index.js";
10
- import { useHealthyBowlLivestockDepth as o } from "../../hooks/useHealthyBowlLivestockDepth.js";
11
- import { useHealthyBowlGrazingEvents as s } from "../../hooks/useHealthyBowlGrazing.js";
12
- import { AnimalDepthFormModal as c } from "./AnimalDepthFormModal.js";
13
- import { formatAdg as l, formatBcs as u, formatShortDate as d, formatWeight as f, withdrawalBadgeVariant as p } from "./depthLabels.js";
14
- import { RecordWeightModal as m } from "./RecordWeightModal.js";
15
- import { PedigreeTree as h } from "./PedigreeTree.js";
16
- import { useMemo as g, useState as _ } from "react";
17
- import { useI18n as v } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
18
- import { AlertTriangle as y, ArrowLeft as b, GitBranch as x, Pencil as S, Scale as C, TrendingUp as ne } from "lucide-react";
19
- import { useNavigate as re, useParams as ie } from "react-router";
20
- import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
21
- import { Button as D } from "@burdenoff/fe-libs/ui";
10
+ import { useHealthyBowlLivestockDepth as s } from "../../hooks/useHealthyBowlLivestockDepth.js";
11
+ import { useHealthyBowlGrazingEvents as c } from "../../hooks/useHealthyBowlGrazing.js";
12
+ import { AnimalDepthFormModal as l } from "./AnimalDepthFormModal.js";
13
+ import { formatAdg as u, formatBcs as d, formatShortDate as f, formatWeight as p, withdrawalBadgeVariant as m } from "./depthLabels.js";
14
+ import { RecordWeightModal as te } from "./RecordWeightModal.js";
15
+ import { PedigreeTree as ne } from "./PedigreeTree.js";
16
+ import { useEffect as re, useMemo as h, useState as g } from "react";
17
+ import { useI18n as _ } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
18
+ import { AlertTriangle as v, ArrowLeft as y, GitBranch as b, Pencil as x, Scale as S, TrendingUp as C } from "lucide-react";
19
+ import { useNavigate as w, useParams as T } from "react-router";
20
+ import { Fragment as ie, jsx as E, jsxs as D } from "react/jsx-runtime";
21
+ import { Button as O } from "@burdenoff/fe-libs/ui";
22
22
  //#region src/healthybowl/pages/livestock/AnimalDepthPage.tsx
23
- var O = ({ label: e, value: t }) => /* @__PURE__ */ E("div", {
23
+ var k = 300, A = ({ label: e, value: t }) => /* @__PURE__ */ D("div", {
24
24
  className: "flex items-center justify-between gap-4 border-b border-border-subtle py-3 last:border-0",
25
- children: [/* @__PURE__ */ T("span", {
25
+ children: [/* @__PURE__ */ E("span", {
26
26
  className: "text-sm text-text-secondary",
27
27
  children: e
28
- }), /* @__PURE__ */ T("span", {
28
+ }), /* @__PURE__ */ E("span", {
29
29
  className: "text-end text-sm font-medium text-text-primary",
30
30
  children: t
31
31
  })]
32
- }), k = ({ role: e, tag: t, archived: n }) => {
33
- let { t: r } = v();
34
- return t ? /* @__PURE__ */ E("span", { children: [`${e} ${t}`, n ? /* @__PURE__ */ T("span", {
32
+ }), j = ({ role: e, tag: t, archived: n }) => {
33
+ let { t: r } = _();
34
+ return t ? /* @__PURE__ */ D("span", { children: [`${e} ${t}`, n ? /* @__PURE__ */ E("span", {
35
35
  className: "ms-1 font-normal text-text-secondary",
36
36
  children: r("healthybowl.livestock.depth.detail.archivedSuffix", "(archived)")
37
- }) : null] }) : /* @__PURE__ */ T("span", { children: `${e} —` });
38
- }, A = () => {
39
- let { t: A } = v(), j = re(), { buildPath: M } = t(), { toast: N } = te(), P = i(), { animalId: F } = ie(), { animalDepth: I, herd: L, groups: R, pedigree: z, loading: B, errors: V, refetchAnimal: H, updateAnimalDepth: U, recordWeight: W, deleteWeight: G } = o({
40
- animalId: F ?? null,
41
- herd: !0,
37
+ }) : null] }) : /* @__PURE__ */ E("span", { children: `${e} —` });
38
+ }, M = () => {
39
+ let { t: M } = _(), N = w(), { buildPath: P } = t(), { toast: F } = o(), I = ee(), { animalId: L } = T(), [R, z] = g(!1), [B, V] = g(""), [ae, H] = g("");
40
+ re(() => {
41
+ let e = globalThis.setTimeout(() => H(B), k);
42
+ return () => globalThis.clearTimeout(e);
43
+ }, [B]);
44
+ let { animalDepth: U, herd: W, groups: G, pedigree: K, loading: q, errors: J, refetchAnimal: oe, updateAnimalDepth: se, recordWeight: ce, deleteWeight: le } = s({
45
+ animalId: L ?? null,
46
+ herd: R,
47
+ herdSearch: ae.trim() || null,
42
48
  herdIncludeArchived: !0,
43
49
  groups: !0,
44
50
  pedigree: !0
45
- }), { latest: K, loading: q, error: J } = s({
46
- animalId: F ?? null,
51
+ }), { latest: Y, loading: X, error: Z } = c({
52
+ animalId: L ?? null,
47
53
  limit: 5
48
- }), [Y, X] = _(!1), [ae, Z] = _(!1), oe = g(() => (L?.rows ?? []).map((e) => ({
54
+ }), [ue, Q] = g(!1), de = h(() => (W?.rows ?? []).map((e) => ({
49
55
  animalId: e.animalId,
50
56
  tagNumber: e.tagNumber,
51
57
  name: e.name,
52
58
  archived: e.archived ?? !1
53
- })), [L]);
54
- if (B.animal && !I) return /* @__PURE__ */ T(ee, {});
55
- if (V.animal && !I || !I) return /* @__PURE__ */ T(e, {
56
- title: A("healthybowl.livestock.depth.detail.title", "Animal Record"),
57
- children: /* @__PURE__ */ T(r, {
58
- description: V.animal?.message ?? A("healthybowl.livestock.depth.detail.notFound", "Animal not found."),
59
- onRetry: () => void H()
59
+ })), [W]);
60
+ if (q.animal && !U) return /* @__PURE__ */ E(a, {});
61
+ if (J.animal && !U || !U) return /* @__PURE__ */ E(e, {
62
+ title: M("healthybowl.livestock.depth.detail.title", "Animal Record"),
63
+ children: /* @__PURE__ */ E(r, {
64
+ description: J.animal?.message ?? M("healthybowl.livestock.depth.detail.notFound", "Animal not found."),
65
+ onRetry: () => void oe()
60
66
  })
61
67
  });
62
- let Q = I, $ = Q.name.slice(0, 2).toUpperCase(), se = async (e) => {
63
- await U(e), N({
64
- title: A("healthybowl.livestock.depth.toast.updated", "Record updated"),
65
- description: Q.name,
68
+ let $ = U, fe = $.name.slice(0, 2).toUpperCase(), pe = async (e) => {
69
+ await se(e), F({
70
+ title: M("healthybowl.livestock.depth.toast.updated", "Record updated"),
71
+ description: $.name,
66
72
  variant: "success"
67
73
  });
68
- }, ce = async (e) => {
69
- await W({
74
+ }, me = async (e) => {
75
+ await ce({
70
76
  ...e,
71
- animalId: Q.animalId
72
- }), N({
73
- title: A("healthybowl.livestock.depth.toast.weightSaved", "Weight recorded"),
77
+ animalId: $.animalId
78
+ }), F({
79
+ title: M("healthybowl.livestock.depth.toast.weightSaved", "Weight recorded"),
74
80
  description: `${String(e.weightKg)} kg`,
75
81
  variant: "success"
76
82
  });
77
- }, le = async (e) => {
78
- if (await P({
79
- title: A("healthybowl.livestock.depth.confirm.delWeightTitle", "Delete weight?"),
80
- message: A("healthybowl.livestock.depth.confirm.delWeight", "Remove this weight measurement?")
83
+ }, he = async (e) => {
84
+ if (await I({
85
+ title: M("healthybowl.livestock.depth.confirm.delWeightTitle", "Delete weight?"),
86
+ message: M("healthybowl.livestock.depth.confirm.delWeight", "Remove this weight measurement?")
81
87
  })) try {
82
- await G(e), N({
83
- title: A("healthybowl.livestock.depth.toast.weightDeleted", "Weight removed"),
88
+ await le(e), F({
89
+ title: M("healthybowl.livestock.depth.toast.weightDeleted", "Weight removed"),
84
90
  variant: "success"
85
91
  });
86
92
  } catch (e) {
87
- N({
88
- title: A("healthybowl.livestock.depth.toast.error", "Something went wrong"),
93
+ F({
94
+ title: M("healthybowl.livestock.depth.toast.error", "Something went wrong"),
89
95
  description: e instanceof Error ? e.message : String(e),
90
96
  variant: "error"
91
97
  });
92
98
  }
93
99
  };
94
- return /* @__PURE__ */ E(e, {
95
- title: Q.name,
96
- description: `${Q.type} · ${Q.tagNumber}`,
97
- actions: /* @__PURE__ */ E("div", {
100
+ return /* @__PURE__ */ D(e, {
101
+ title: $.name,
102
+ description: `${$.type} · ${$.tagNumber}`,
103
+ actions: /* @__PURE__ */ D("div", {
98
104
  className: "flex items-center gap-2",
99
- children: [/* @__PURE__ */ E(D, {
105
+ children: [/* @__PURE__ */ D(O, {
100
106
  variant: "outline",
101
- onClick: () => Z(!0),
102
- children: [/* @__PURE__ */ T(C, { className: "h-4 w-4" }), A("healthybowl.livestock.depth.detail.logWeight", "Record weight")]
103
- }), /* @__PURE__ */ E(D, {
104
- onClick: () => X(!0),
105
- children: [/* @__PURE__ */ T(S, { className: "h-4 w-4" }), A("healthybowl.livestock.depth.detail.edit", "Edit")]
107
+ onClick: () => Q(!0),
108
+ children: [/* @__PURE__ */ E(S, { className: "h-4 w-4" }), M("healthybowl.livestock.depth.detail.logWeight", "Record weight")]
109
+ }), /* @__PURE__ */ D(O, {
110
+ onClick: () => z(!0),
111
+ children: [/* @__PURE__ */ E(x, { className: "h-4 w-4" }), M("healthybowl.livestock.depth.detail.edit", "Edit")]
106
112
  })]
107
113
  }),
108
114
  children: [
109
- /* @__PURE__ */ T(a, { items: [{
110
- label: A("healthybowl.livestock.depth.title", "Livestock Records"),
111
- href: M("livestock/records")
112
- }, { label: Q.name }] }),
113
- /* @__PURE__ */ T("div", {
115
+ /* @__PURE__ */ E(i, { items: [{
116
+ label: M("healthybowl.livestock.depth.title", "Livestock Records"),
117
+ href: P("livestock/records")
118
+ }, { label: $.name }] }),
119
+ /* @__PURE__ */ E("div", {
114
120
  className: "mt-2",
115
- children: /* @__PURE__ */ E(D, {
121
+ children: /* @__PURE__ */ D(O, {
116
122
  variant: "ghost",
117
123
  size: "sm",
118
- onClick: () => j(M("livestock/records")),
119
- children: [/* @__PURE__ */ T(b, { className: "h-4 w-4" }), A("common.back", "Back")]
124
+ onClick: () => N(P("livestock/records")),
125
+ children: [/* @__PURE__ */ E(y, { className: "h-4 w-4" }), M("common.back", "Back")]
120
126
  })
121
127
  }),
122
- Q.withdrawal.blocked ? /* @__PURE__ */ E("div", {
128
+ $.withdrawal.blocked ? /* @__PURE__ */ D("div", {
123
129
  role: "alert",
124
130
  className: "mt-3 flex items-center gap-3 rounded-lg border border-status-error-border bg-status-error-bg px-4 py-3 text-status-error-text",
125
- children: [/* @__PURE__ */ T(y, { className: "h-5 w-5 shrink-0" }), /* @__PURE__ */ T("span", {
131
+ children: [/* @__PURE__ */ E(v, { className: "h-5 w-5 shrink-0" }), /* @__PURE__ */ E("span", {
126
132
  className: "text-sm font-semibold",
127
- children: A("healthybowl.livestock.depth.detail.withdrawalBanner", "In medication withdrawal — Withdrawal ends {{date}} · do not sell milk or meat", { date: d(Q.withdrawal.endDate) })
133
+ children: M("healthybowl.livestock.depth.detail.withdrawalBanner", "In medication withdrawal — Withdrawal ends {{date}} · do not sell milk or meat", { date: f($.withdrawal.endDate) })
128
134
  })]
129
135
  }) : null,
130
- /* @__PURE__ */ E("div", {
136
+ /* @__PURE__ */ D("div", {
131
137
  className: "mt-4 grid grid-cols-1 gap-4 lg:grid-cols-3",
132
138
  children: [
133
- /* @__PURE__ */ E("div", {
139
+ /* @__PURE__ */ D("div", {
134
140
  className: "rounded-xl border border-border-subtle bg-bg-surface p-5 lg:col-span-2",
135
141
  children: [
136
- /* @__PURE__ */ E("div", {
142
+ /* @__PURE__ */ D("div", {
137
143
  className: "mb-2 flex items-center gap-3",
138
144
  children: [
139
- /* @__PURE__ */ T("div", {
145
+ /* @__PURE__ */ E("div", {
140
146
  className: "flex h-14 w-14 items-center justify-center rounded-full bg-accent-teal/10 text-lg font-semibold text-accent-teal",
141
- children: $
147
+ children: fe
142
148
  }),
143
- /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("div", {
149
+ /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("div", {
144
150
  className: "text-lg font-semibold text-text-primary",
145
- children: Q.name
146
- }), /* @__PURE__ */ E("div", {
151
+ children: $.name
152
+ }), /* @__PURE__ */ D("div", {
147
153
  className: "text-sm text-text-secondary",
148
154
  children: [
149
- Q.type,
155
+ $.type,
150
156
  " #",
151
- Q.tagNumber
157
+ $.tagNumber
152
158
  ]
153
159
  })] }),
154
- /* @__PURE__ */ T("div", {
160
+ /* @__PURE__ */ E("div", {
155
161
  className: "ms-auto",
156
- children: /* @__PURE__ */ T(n, {
157
- variant: p(Q.withdrawal.status),
158
- label: Q.withdrawal.blocked ? A("healthybowl.livestock.depth.detail.inWithdrawal", "In withdrawal") : A("healthybowl.livestock.depth.detail.clear", "Clear to sell"),
162
+ children: /* @__PURE__ */ E(n, {
163
+ variant: m($.withdrawal.status),
164
+ label: $.withdrawal.blocked ? M("healthybowl.livestock.depth.detail.inWithdrawal", "In withdrawal") : M("healthybowl.livestock.depth.detail.clear", "Clear to sell"),
159
165
  dot: !0
160
166
  })
161
167
  })
162
168
  ]
163
169
  }),
164
- /* @__PURE__ */ T(O, {
165
- label: A("healthybowl.livestock.depth.detail.eid", "EID / RFID Tag"),
166
- value: Q.eidTag ?? "—"
170
+ /* @__PURE__ */ E(A, {
171
+ label: M("healthybowl.livestock.depth.detail.eid", "EID / RFID Tag"),
172
+ value: $.eidTag ?? "—"
167
173
  }),
168
- /* @__PURE__ */ T(O, {
169
- label: A("healthybowl.livestock.depth.detail.bcs", "Body Condition Score"),
170
- value: u(Q.bodyConditionScore)
174
+ /* @__PURE__ */ E(A, {
175
+ label: M("healthybowl.livestock.depth.detail.bcs", "Body Condition Score"),
176
+ value: d($.bodyConditionScore)
171
177
  }),
172
- /* @__PURE__ */ T(O, {
173
- label: A("healthybowl.livestock.depth.detail.group", "Group"),
174
- value: Q.groupName ?? "—"
178
+ /* @__PURE__ */ E(A, {
179
+ label: M("healthybowl.livestock.depth.detail.group", "Group"),
180
+ value: $.groupName ?? "—"
175
181
  }),
176
- /* @__PURE__ */ T(O, {
177
- label: A("healthybowl.livestock.depth.detail.grazingNow", "Grazing — where this animal is"),
178
- value: /* @__PURE__ */ E("span", {
182
+ /* @__PURE__ */ E(A, {
183
+ label: M("healthybowl.livestock.depth.detail.grazingNow", "Grazing — where this animal is"),
184
+ value: /* @__PURE__ */ D("span", {
179
185
  className: "inline-flex flex-col items-end gap-0.5",
180
- children: [J ? /* @__PURE__ */ T("span", {
186
+ children: [Z ? /* @__PURE__ */ E("span", {
181
187
  className: "text-status-error-text",
182
- children: A("healthybowl.livestock.depth.detail.grazingFailed", "The grazing log could not be read — {{message}}", { message: J.message })
183
- }) : q && !K ? /* @__PURE__ */ T("span", {
188
+ children: M("healthybowl.livestock.depth.detail.grazingFailed", "The grazing log could not be read — {{message}}", { message: Z.message })
189
+ }) : X && !Y ? /* @__PURE__ */ E("span", {
184
190
  className: "font-normal text-text-secondary",
185
- children: A("healthybowl.livestock.depth.detail.grazingLoading", "Reading the grazing log…")
186
- }) : K ? /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ T("span", { children: K.paddockName }), /* @__PURE__ */ T("span", {
191
+ children: M("healthybowl.livestock.depth.detail.grazingLoading", "Reading the grazing log…")
192
+ }) : Y ? /* @__PURE__ */ D(ie, { children: [/* @__PURE__ */ E("span", { children: Y.paddockName }), /* @__PURE__ */ E("span", {
187
193
  className: "text-xs font-normal text-text-secondary",
188
- children: K.active ? A("healthybowl.livestock.depth.detail.grazingIn", "In since {{date}}", { date: d(K.enteredAt) }) : A("healthybowl.livestock.depth.detail.grazingOut", "Left {{date}} — no paddock since", { date: d(K.exitedAt) })
189
- })] }) : /* @__PURE__ */ T("span", {
194
+ children: Y.active ? M("healthybowl.livestock.depth.detail.grazingIn", "In since {{date}}", { date: f(Y.enteredAt) }) : M("healthybowl.livestock.depth.detail.grazingOut", "Left {{date}} — no paddock since", { date: f(Y.exitedAt) })
195
+ })] }) : /* @__PURE__ */ E("span", {
190
196
  className: "font-normal text-text-secondary",
191
- children: A("healthybowl.livestock.depth.detail.grazingNone", "No move recorded in the grazing log yet.")
192
- }), /* @__PURE__ */ T("button", {
197
+ children: M("healthybowl.livestock.depth.detail.grazingNone", "No move recorded in the grazing log yet.")
198
+ }), /* @__PURE__ */ E("button", {
193
199
  type: "button",
194
200
  className: "text-xs font-normal text-text-secondary underline hover:text-text-primary",
195
- onClick: () => j(M("livestock/grazing")),
196
- children: A("healthybowl.livestock.depth.detail.grazingLink", "Open grazing — moves, rest and stocking rate")
201
+ onClick: () => N(P("livestock/grazing")),
202
+ children: M("healthybowl.livestock.depth.detail.grazingLink", "Open grazing — moves, rest and stocking rate")
197
203
  })]
198
204
  })
199
205
  }),
200
- Q.grazingPaddock ? /* @__PURE__ */ T(O, {
201
- label: A("healthybowl.livestock.depth.detail.grazing", "Grazing / Rotation (legacy)"),
202
- value: /* @__PURE__ */ E("span", {
206
+ $.grazingPaddock ? /* @__PURE__ */ E(A, {
207
+ label: M("healthybowl.livestock.depth.detail.grazing", "Grazing / Rotation (legacy)"),
208
+ value: /* @__PURE__ */ D("span", {
203
209
  className: "inline-flex flex-col items-end gap-0.5",
204
- children: [/* @__PURE__ */ T("span", {
205
- className: K ? "font-normal text-text-secondary line-through" : void 0,
206
- children: `${Q.grazingPaddock}${Q.rotationDate ? ` (rotates ${d(Q.rotationDate)})` : ""}`
207
- }), /* @__PURE__ */ T("span", {
210
+ children: [/* @__PURE__ */ E("span", {
211
+ className: Y ? "font-normal text-text-secondary line-through" : void 0,
212
+ children: `${$.grazingPaddock}${$.rotationDate ? ` (rotates ${f($.rotationDate)})` : ""}`
213
+ }), /* @__PURE__ */ E("span", {
208
214
  className: "max-w-[320px] text-xs font-normal text-text-secondary",
209
- children: K ? A("healthybowl.livestock.depth.detail.grazingSuperseded", "Recorded before the grazing log and never updated since — the row above is where this animal is now.") : J || q ? A("healthybowl.livestock.depth.detail.grazingUnchecked", "A single free-text paddock and one rotation date, with no time in or out. Whether the grazing log has superseded it could not be checked.") : A("healthybowl.livestock.depth.detail.grazingOnlyRecord", "A single free-text paddock and one rotation date, with no time in or out. Record a move on the Grazing page and this animal joins the history.")
215
+ children: Y ? M("healthybowl.livestock.depth.detail.grazingSuperseded", "Recorded before the grazing log and never updated since — the row above is where this animal is now.") : Z || X ? M("healthybowl.livestock.depth.detail.grazingUnchecked", "A single free-text paddock and one rotation date, with no time in or out. Whether the grazing log has superseded it could not be checked.") : M("healthybowl.livestock.depth.detail.grazingOnlyRecord", "A single free-text paddock and one rotation date, with no time in or out. Record a move on the Grazing page and this animal joins the history.")
210
216
  })]
211
217
  })
212
218
  }) : null,
213
- /* @__PURE__ */ T(O, {
214
- label: A("healthybowl.livestock.depth.detail.genealogy", "Genealogy — Dam · Sire"),
215
- value: /* @__PURE__ */ E("span", {
219
+ /* @__PURE__ */ E(A, {
220
+ label: M("healthybowl.livestock.depth.detail.genealogy", "Genealogy — Dam · Sire"),
221
+ value: /* @__PURE__ */ D("span", {
216
222
  className: "inline-flex flex-wrap items-center justify-end gap-x-1",
217
223
  children: [
218
- /* @__PURE__ */ T(k, {
219
- role: A("healthybowl.livestock.depth.detail.dam", "Dam"),
220
- tag: Q.damTag,
221
- archived: Q.damArchived
224
+ /* @__PURE__ */ E(j, {
225
+ role: M("healthybowl.livestock.depth.detail.dam", "Dam"),
226
+ tag: $.damTag,
227
+ archived: $.damArchived
222
228
  }),
223
- /* @__PURE__ */ T("span", {
229
+ /* @__PURE__ */ E("span", {
224
230
  className: "text-text-secondary",
225
231
  children: "·"
226
232
  }),
227
- /* @__PURE__ */ T(k, {
228
- role: A("healthybowl.livestock.depth.detail.sire", "Sire"),
229
- tag: Q.sireTag,
230
- archived: Q.sireArchived
233
+ /* @__PURE__ */ E(j, {
234
+ role: M("healthybowl.livestock.depth.detail.sire", "Sire"),
235
+ tag: $.sireTag,
236
+ archived: $.sireArchived
231
237
  })
232
238
  ]
233
239
  })
234
240
  }),
235
- /* @__PURE__ */ T(O, {
236
- label: A("healthybowl.livestock.depth.detail.adg", "Average Daily Gain (ADG)"),
237
- value: /* @__PURE__ */ E("span", {
241
+ /* @__PURE__ */ E(A, {
242
+ label: M("healthybowl.livestock.depth.detail.adg", "Average Daily Gain (ADG)"),
243
+ value: /* @__PURE__ */ D("span", {
238
244
  className: "inline-flex items-center gap-1",
239
- children: [Q.adgKgPerDay === null ? null : /* @__PURE__ */ T(ne, { className: "h-4 w-4 text-accent-teal" }), l(Q.adgKgPerDay)]
245
+ children: [$.adgKgPerDay === null ? null : /* @__PURE__ */ E(C, { className: "h-4 w-4 text-accent-teal" }), u($.adgKgPerDay)]
240
246
  })
241
247
  }),
242
- /* @__PURE__ */ T(O, {
243
- label: A("healthybowl.livestock.depth.detail.latestWeight", "Latest Weight"),
244
- value: f(Q.latestWeightKg, Q.latestWeightAt)
248
+ /* @__PURE__ */ E(A, {
249
+ label: M("healthybowl.livestock.depth.detail.latestWeight", "Latest Weight"),
250
+ value: p($.latestWeightKg, $.latestWeightAt)
245
251
  }),
246
- Q.grazingNotes ? /* @__PURE__ */ T(O, {
247
- label: A("healthybowl.livestock.depth.detail.notes", "Grazing notes"),
248
- value: Q.grazingNotes
252
+ $.grazingNotes ? /* @__PURE__ */ E(A, {
253
+ label: M("healthybowl.livestock.depth.detail.notes", "Grazing notes"),
254
+ value: $.grazingNotes
249
255
  }) : null
250
256
  ]
251
257
  }),
252
- /* @__PURE__ */ E("div", {
258
+ /* @__PURE__ */ D("div", {
253
259
  className: "rounded-xl border border-border-subtle bg-bg-surface p-5",
254
- children: [/* @__PURE__ */ E("div", {
260
+ children: [/* @__PURE__ */ D("div", {
255
261
  className: "mb-3 flex items-center justify-between",
256
- children: [/* @__PURE__ */ T("h3", {
262
+ children: [/* @__PURE__ */ E("h3", {
257
263
  className: "text-sm font-semibold text-text-primary",
258
- children: A("healthybowl.livestock.depth.detail.weightHistory", "Weight history")
259
- }), /* @__PURE__ */ E(D, {
264
+ children: M("healthybowl.livestock.depth.detail.weightHistory", "Weight history")
265
+ }), /* @__PURE__ */ D(O, {
260
266
  variant: "outline",
261
267
  size: "sm",
262
- onClick: () => Z(!0),
263
- children: [/* @__PURE__ */ T(C, { className: "h-3.5 w-3.5" }), A("healthybowl.livestock.depth.detail.add", "Add")]
268
+ onClick: () => Q(!0),
269
+ children: [/* @__PURE__ */ E(S, { className: "h-3.5 w-3.5" }), M("healthybowl.livestock.depth.detail.add", "Add")]
264
270
  })]
265
- }), Q.weightHistory.length === 0 ? /* @__PURE__ */ T("p", {
271
+ }), $.weightHistory.length === 0 ? /* @__PURE__ */ E("p", {
266
272
  className: "text-sm text-text-secondary",
267
- children: A("healthybowl.livestock.depth.detail.noWeights", "No weights logged yet — record two or more to compute ADG.")
268
- }) : /* @__PURE__ */ T("ul", {
273
+ children: M("healthybowl.livestock.depth.detail.noWeights", "No weights logged yet — record two or more to compute ADG.")
274
+ }) : /* @__PURE__ */ E("ul", {
269
275
  className: "space-y-2",
270
- children: Q.weightHistory.map((e) => /* @__PURE__ */ E("li", {
276
+ children: $.weightHistory.map((e) => /* @__PURE__ */ D("li", {
271
277
  className: "flex items-center justify-between rounded-md bg-bg-sunken px-3 py-2 text-sm",
272
278
  children: [
273
- /* @__PURE__ */ E("span", {
279
+ /* @__PURE__ */ D("span", {
274
280
  className: "tabular-nums text-text-primary",
275
281
  children: [e.weightKg, " kg"]
276
282
  }),
277
- /* @__PURE__ */ T("span", {
283
+ /* @__PURE__ */ E("span", {
278
284
  className: "text-text-secondary",
279
- children: d(e.measuredAt)
285
+ children: f(e.measuredAt)
280
286
  }),
281
- /* @__PURE__ */ T("button", {
287
+ /* @__PURE__ */ E("button", {
282
288
  type: "button",
283
- onClick: () => void le(e.id),
289
+ onClick: () => void he(e.id),
284
290
  className: "text-xs text-text-secondary hover:text-status-error-text",
285
- children: A("common.remove", "Remove")
291
+ children: M("common.remove", "Remove")
286
292
  })
287
293
  ]
288
294
  }, e.id))
289
295
  })]
290
296
  }),
291
- /* @__PURE__ */ E("div", {
297
+ /* @__PURE__ */ D("div", {
292
298
  className: "rounded-xl border border-border-subtle bg-bg-surface p-5 lg:col-span-3",
293
- children: [/* @__PURE__ */ E("h3", {
299
+ children: [/* @__PURE__ */ D("h3", {
294
300
  className: "mb-3 flex items-center gap-2 text-sm font-semibold text-text-primary",
295
- children: [/* @__PURE__ */ T(x, { className: "h-4 w-4 text-text-secondary" }), A("healthybowl.livestock.depth.detail.pedigree", "Pedigree")]
296
- }), /* @__PURE__ */ T(h, {
297
- pedigree: z,
298
- loading: B.pedigree,
299
- error: V.pedigree
301
+ children: [/* @__PURE__ */ E(b, { className: "h-4 w-4 text-text-secondary" }), M("healthybowl.livestock.depth.detail.pedigree", "Pedigree")]
302
+ }), /* @__PURE__ */ E(ne, {
303
+ pedigree: K,
304
+ loading: q.pedigree,
305
+ error: J.pedigree
300
306
  })]
301
307
  })
302
308
  ]
303
309
  }),
304
- /* @__PURE__ */ T(c, {
305
- open: Y,
306
- onClose: () => X(!1),
307
- animal: Q,
308
- groups: R,
309
- animalOptions: oe,
310
- onSubmit: se
310
+ /* @__PURE__ */ E(l, {
311
+ open: R,
312
+ onClose: () => z(!1),
313
+ animal: $,
314
+ groups: G,
315
+ animalOptions: de,
316
+ animalSearch: B,
317
+ onAnimalSearchChange: V,
318
+ animalOptionsTruncated: W?.truncated ?? !1,
319
+ animalOptionsLoading: q.herd,
320
+ onSubmit: pe
311
321
  }),
312
- /* @__PURE__ */ T(m, {
313
- open: ae,
314
- onClose: () => Z(!1),
315
- animalName: Q.name,
316
- onSubmit: ce
322
+ /* @__PURE__ */ E(te, {
323
+ open: ue,
324
+ onClose: () => Q(!1),
325
+ animalName: $.name,
326
+ onSubmit: me
317
327
  })
318
328
  ]
319
329
  });
320
330
  };
321
331
  //#endregion
322
- export { A as AnimalDepthPage };
332
+ export { M as AnimalDepthPage };
323
333
 
324
334
  //# sourceMappingURL=AnimalDepthPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnimalDepthPage.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/AnimalDepthPage.tsx"],"sourcesContent":["/**\n * Single-animal deep record (BOFF-2890 · L-1).\n * EID/RFID, body-condition score, group, grazing/rotation, dam/sire genealogy, ADG, latest\n * weight and weight history, plus the medication-withdrawal compliance badge (reused from\n * BOFF-2885). Edit the record or log a new weight in place. No fabricated data.\n */\nimport { useMemo, useState } from 'react';\nimport { useNavigate, useParams } from 'react-router';\nimport { AlertTriangle, ArrowLeft, GitBranch, Pencil, Scale, TrendingUp } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PageLayout, StatusBadge, ErrorState, PageLoader, Breadcrumbs, useConfirm } from '../../components';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { useHealthyBowlLivestockDepth } from '../../hooks/useHealthyBowlLivestockDepth';\nimport { useHealthyBowlGrazingEvents } from '../../hooks/useHealthyBowlGrazing';\nimport { AnimalDepthFormModal, type AnimalOption } from './AnimalDepthFormModal';\nimport { RecordWeightModal } from './RecordWeightModal';\nimport { PedigreeTree } from './PedigreeTree';\nimport { formatAdg, formatBcs, formatShortDate, formatWeight, withdrawalBadgeVariant } from './depthLabels';\n\nconst DetailRow = ({ label, value }: { label: string; value: React.ReactNode }) => (\n <div className=\"flex items-center justify-between gap-4 border-b border-border-subtle py-3 last:border-0\">\n <span className=\"text-sm text-text-secondary\">{label}</span>\n <span className=\"text-end text-sm font-medium text-text-primary\">{value}</span>\n </div>\n);\n\n/**\n * One parent on the genealogy row (BOFF-6195).\n *\n * Deliberately NOT a link. `healthyBowlAnimalDepth` filters `deletedAt: null`, so navigating to an\n * archived parent dead-ends on NOT_FOUND — a link that reliably breaks is worse than plain text.\n *\n * The \"(archived)\" marker is driven by the API's `damArchived`/`sireArchived`, never inferred from\n * whether the tag happens to be missing from the live herd list: that read is capped, so an absence\n * there is not evidence the animal left the herd.\n */\nconst ParentTag = ({ role, tag, archived }: { role: string; tag: string | null; archived: boolean }) => {\n const { t } = useI18n();\n if (!tag) return <span>{`${role} —`}</span>;\n return (\n <span>\n {`${role} ${tag}`}\n {archived ? (\n <span className=\"ms-1 font-normal text-text-secondary\">\n {t('healthybowl.livestock.depth.detail.archivedSuffix', '(archived)')}\n </span>\n ) : null}\n </span>\n );\n};\n\nexport const AnimalDepthPage = () => {\n const { t } = useI18n();\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { toast } = useToast();\n const confirm = useConfirm();\n const { animalId } = useParams<{ animalId: string }>();\n\n const {\n animalDepth,\n herd,\n groups,\n pedigree,\n loading,\n errors,\n refetchAnimal,\n updateAnimalDepth,\n recordWeight,\n deleteWeight,\n } = useHealthyBowlLivestockDepth({\n animalId: animalId ?? null,\n herd: true,\n // The Dam/Sire picker must be able to offer a culled or sold parent — the backend has\n // accepted that link since BOFF-6011, and this page is the only place it can be recorded\n // (BOFF-6195). Archived rows are additive to `rows` only; the compliance summary and the\n // group counts stay live-only server-side.\n herdIncludeArchived: true,\n groups: true,\n // The one-hop Dam/Sire row answers \"who are the parents\"; the pedigree answers \"where does\n // this animal come from, and what has it produced\" (BOFF-6097).\n pedigree: true,\n });\n\n /**\n * Where this animal actually is (BOFF-5970).\n *\n * `recordHealthyBowlGrazingMove` writes a grazing EVENT and never touches the animal's legacy\n * `grazingPaddock` / `rotationDate` columns, so after any move recorded on the Grazing page those\n * two are a frozen snapshot of a previous model — and rendering them as a plain current fact made\n * this page and the Grazing page give two different answers to the same question. The event is\n * the live answer whenever one exists; the legacy pair is annotated in the VALUE, not only in its\n * label, because the label is not what a farmer reads off the row.\n */\n const {\n latest: latestGrazing,\n loading: grazingLoading,\n error: grazingError,\n } = useHealthyBowlGrazingEvents({ animalId: animalId ?? null, limit: 5 });\n\n const [editOpen, setEditOpen] = useState(false);\n const [weightOpen, setWeightOpen] = useState(false);\n\n const animalOptions = useMemo<AnimalOption[]>(\n () =>\n (herd?.rows ?? []).map((r) => ({\n animalId: r.animalId,\n tagNumber: r.tagNumber,\n name: r.name,\n // `archived` is only selected by the archived-aware herd document, which this page opts\n // into above. Defaulting to false keeps the option type honest for any future caller that\n // does not.\n archived: r.archived ?? false,\n })),\n [herd]\n );\n\n if (loading.animal && !animalDepth) {\n return <PageLoader />;\n }\n if ((errors.animal && !animalDepth) || !animalDepth) {\n return (\n <PageLayout title={t('healthybowl.livestock.depth.detail.title', 'Animal Record')}>\n <ErrorState\n description={errors.animal?.message ?? t('healthybowl.livestock.depth.detail.notFound', 'Animal not found.')}\n onRetry={() => void refetchAnimal()}\n />\n </PageLayout>\n );\n }\n\n const a = animalDepth;\n const initials = a.name.slice(0, 2).toUpperCase();\n\n const handleEdit = async (input: Record<string, unknown>) => {\n await updateAnimalDepth(input);\n toast({\n title: t('healthybowl.livestock.depth.toast.updated', 'Record updated'),\n description: a.name,\n variant: 'success',\n });\n };\n\n const handleWeight = async (input: Record<string, unknown>) => {\n await recordWeight({ ...input, animalId: a.animalId });\n toast({\n title: t('healthybowl.livestock.depth.toast.weightSaved', 'Weight recorded'),\n description: `${String(input.weightKg)} kg`,\n variant: 'success',\n });\n };\n\n const handleDeleteWeight = async (id: string) => {\n if (\n !(await confirm({\n title: t('healthybowl.livestock.depth.confirm.delWeightTitle', 'Delete weight?'),\n message: t('healthybowl.livestock.depth.confirm.delWeight', 'Remove this weight measurement?'),\n }))\n ) {\n return;\n }\n try {\n await deleteWeight(id);\n toast({ title: t('healthybowl.livestock.depth.toast.weightDeleted', 'Weight removed'), variant: 'success' });\n } catch (err) {\n toast({\n title: t('healthybowl.livestock.depth.toast.error', 'Something went wrong'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n }\n };\n\n return (\n <PageLayout\n title={a.name}\n description={`${a.type} · ${a.tagNumber}`}\n actions={\n <div className=\"flex items-center gap-2\">\n <Button variant=\"outline\" onClick={() => setWeightOpen(true)}>\n <Scale className=\"h-4 w-4\" />\n {t('healthybowl.livestock.depth.detail.logWeight', 'Record weight')}\n </Button>\n <Button onClick={() => setEditOpen(true)}>\n <Pencil className=\"h-4 w-4\" />\n {t('healthybowl.livestock.depth.detail.edit', 'Edit')}\n </Button>\n </div>\n }\n >\n <Breadcrumbs\n items={[\n { label: t('healthybowl.livestock.depth.title', 'Livestock Records'), href: buildPath('livestock/records') },\n { label: a.name },\n ]}\n />\n\n <div className=\"mt-2\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => navigate(buildPath('livestock/records'))}>\n <ArrowLeft className=\"h-4 w-4\" />\n {t('common.back', 'Back')}\n </Button>\n </div>\n\n {a.withdrawal.blocked ? (\n <div\n role=\"alert\"\n className=\"mt-3 flex items-center gap-3 rounded-lg border border-status-error-border bg-status-error-bg px-4 py-3 text-status-error-text\"\n >\n <AlertTriangle className=\"h-5 w-5 shrink-0\" />\n <span className=\"text-sm font-semibold\">\n {t(\n 'healthybowl.livestock.depth.detail.withdrawalBanner',\n 'In medication withdrawal — Withdrawal ends {{date}} · do not sell milk or meat',\n {\n date: formatShortDate(a.withdrawal.endDate),\n }\n )}\n </span>\n </div>\n ) : null}\n\n <div className=\"mt-4 grid grid-cols-1 gap-4 lg:grid-cols-3\">\n <div className=\"rounded-xl border border-border-subtle bg-bg-surface p-5 lg:col-span-2\">\n <div className=\"mb-2 flex items-center gap-3\">\n <div className=\"flex h-14 w-14 items-center justify-center rounded-full bg-accent-teal/10 text-lg font-semibold text-accent-teal\">\n {initials}\n </div>\n <div>\n <div className=\"text-lg font-semibold text-text-primary\">{a.name}</div>\n <div className=\"text-sm text-text-secondary\">\n {a.type} #{a.tagNumber}\n </div>\n </div>\n <div className=\"ms-auto\">\n <StatusBadge\n variant={withdrawalBadgeVariant(a.withdrawal.status)}\n label={\n a.withdrawal.blocked\n ? t('healthybowl.livestock.depth.detail.inWithdrawal', 'In withdrawal')\n : t('healthybowl.livestock.depth.detail.clear', 'Clear to sell')\n }\n dot\n />\n </div>\n </div>\n\n <DetailRow label={t('healthybowl.livestock.depth.detail.eid', 'EID / RFID Tag')} value={a.eidTag ?? '—'} />\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.bcs', 'Body Condition Score')}\n value={formatBcs(a.bodyConditionScore)}\n />\n <DetailRow label={t('healthybowl.livestock.depth.detail.group', 'Group')} value={a.groupName ?? '—'} />\n {/* The live answer, from the grazing event model (BOFF-5970). Error before empty: \"no\n move recorded\" is a claim about this animal and must not stand in for a failed read. */}\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.grazingNow', 'Grazing — where this animal is')}\n value={\n <span className=\"inline-flex flex-col items-end gap-0.5\">\n {grazingError ? (\n <span className=\"text-status-error-text\">\n {t(\n 'healthybowl.livestock.depth.detail.grazingFailed',\n 'The grazing log could not be read — {{message}}',\n { message: grazingError.message }\n )}\n </span>\n ) : grazingLoading && !latestGrazing ? (\n <span className=\"font-normal text-text-secondary\">\n {t('healthybowl.livestock.depth.detail.grazingLoading', 'Reading the grazing log…')}\n </span>\n ) : latestGrazing ? (\n <>\n <span>{latestGrazing.paddockName}</span>\n <span className=\"text-xs font-normal text-text-secondary\">\n {latestGrazing.active\n ? t('healthybowl.livestock.depth.detail.grazingIn', 'In since {{date}}', {\n date: formatShortDate(latestGrazing.enteredAt),\n })\n : t('healthybowl.livestock.depth.detail.grazingOut', 'Left {{date}} — no paddock since', {\n date: formatShortDate(latestGrazing.exitedAt),\n })}\n </span>\n </>\n ) : (\n <span className=\"font-normal text-text-secondary\">\n {t('healthybowl.livestock.depth.detail.grazingNone', 'No move recorded in the grazing log yet.')}\n </span>\n )}\n <button\n type=\"button\"\n className=\"text-xs font-normal text-text-secondary underline hover:text-text-primary\"\n onClick={() => navigate(buildPath('livestock/grazing'))}\n >\n {t('healthybowl.livestock.depth.detail.grazingLink', 'Open grazing — moves, rest and stocking rate')}\n </button>\n </span>\n }\n />\n {/* LEGACY grazing fields (BOFF-2890). `rotationDate` is a single scalar, so writing the\n next rotation overwrote the previous one — no duration, rest period or stocking rate\n could ever be derived from it. BOFF-5970 replaced this with a grazing EVENT, and moves\n recorded there never write back here, so once an event exists this pair is a frozen\n snapshot. The VALUE says so, not just the label: the label is not what gets read off\n the row. Shown at all only when there is something in it. */}\n {a.grazingPaddock ? (\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.grazing', 'Grazing / Rotation (legacy)')}\n value={\n <span className=\"inline-flex flex-col items-end gap-0.5\">\n <span className={latestGrazing ? 'font-normal text-text-secondary line-through' : undefined}>\n {`${a.grazingPaddock}${a.rotationDate ? ` (rotates ${formatShortDate(a.rotationDate)})` : ''}`}\n </span>\n <span className=\"max-w-[320px] text-xs font-normal text-text-secondary\">\n {latestGrazing\n ? t(\n 'healthybowl.livestock.depth.detail.grazingSuperseded',\n 'Recorded before the grazing log and never updated since — the row above is where this animal is now.'\n )\n : grazingError || grazingLoading\n ? t(\n 'healthybowl.livestock.depth.detail.grazingUnchecked',\n 'A single free-text paddock and one rotation date, with no time in or out. Whether the grazing log has superseded it could not be checked.'\n )\n : t(\n 'healthybowl.livestock.depth.detail.grazingOnlyRecord',\n 'A single free-text paddock and one rotation date, with no time in or out. Record a move on the Grazing page and this animal joins the history.'\n )}\n </span>\n </span>\n }\n />\n ) : null}\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.genealogy', 'Genealogy — Dam · Sire')}\n value={\n <span className=\"inline-flex flex-wrap items-center justify-end gap-x-1\">\n <ParentTag\n role={t('healthybowl.livestock.depth.detail.dam', 'Dam')}\n tag={a.damTag}\n archived={a.damArchived}\n />\n <span className=\"text-text-secondary\">·</span>\n <ParentTag\n role={t('healthybowl.livestock.depth.detail.sire', 'Sire')}\n tag={a.sireTag}\n archived={a.sireArchived}\n />\n </span>\n }\n />\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.adg', 'Average Daily Gain (ADG)')}\n value={\n <span className=\"inline-flex items-center gap-1\">\n {a.adgKgPerDay !== null ? <TrendingUp className=\"h-4 w-4 text-accent-teal\" /> : null}\n {formatAdg(a.adgKgPerDay)}\n </span>\n }\n />\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.latestWeight', 'Latest Weight')}\n value={formatWeight(a.latestWeightKg, a.latestWeightAt)}\n />\n {a.grazingNotes ? (\n <DetailRow label={t('healthybowl.livestock.depth.detail.notes', 'Grazing notes')} value={a.grazingNotes} />\n ) : null}\n </div>\n\n <div className=\"rounded-xl border border-border-subtle bg-bg-surface p-5\">\n <div className=\"mb-3 flex items-center justify-between\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.livestock.depth.detail.weightHistory', 'Weight history')}\n </h3>\n <Button variant=\"outline\" size=\"sm\" onClick={() => setWeightOpen(true)}>\n <Scale className=\"h-3.5 w-3.5\" />\n {t('healthybowl.livestock.depth.detail.add', 'Add')}\n </Button>\n </div>\n {a.weightHistory.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'healthybowl.livestock.depth.detail.noWeights',\n 'No weights logged yet — record two or more to compute ADG.'\n )}\n </p>\n ) : (\n <ul className=\"space-y-2\">\n {a.weightHistory.map((w) => (\n <li key={w.id} className=\"flex items-center justify-between rounded-md bg-bg-sunken px-3 py-2 text-sm\">\n <span className=\"tabular-nums text-text-primary\">{w.weightKg} kg</span>\n <span className=\"text-text-secondary\">{formatShortDate(w.measuredAt)}</span>\n <button\n type=\"button\"\n onClick={() => void handleDeleteWeight(w.id)}\n className=\"text-xs text-text-secondary hover:text-status-error-text\"\n >\n {t('common.remove', 'Remove')}\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n <div className=\"rounded-xl border border-border-subtle bg-bg-surface p-5 lg:col-span-3\">\n <h3 className=\"mb-3 flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <GitBranch className=\"h-4 w-4 text-text-secondary\" />\n {t('healthybowl.livestock.depth.detail.pedigree', 'Pedigree')}\n </h3>\n <PedigreeTree pedigree={pedigree} loading={loading.pedigree} error={errors.pedigree} />\n </div>\n </div>\n\n <AnimalDepthFormModal\n open={editOpen}\n onClose={() => setEditOpen(false)}\n animal={a}\n groups={groups}\n animalOptions={animalOptions}\n onSubmit={handleEdit}\n />\n <RecordWeightModal\n open={weightOpen}\n onClose={() => setWeightOpen(false)}\n animalName={a.name}\n onSubmit={handleWeight}\n />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAM,KAAa,EAAE,UAAO,eAC1B,kBAAC,OAAD;CAAK,WAAU;WAAf,CACE,kBAAC,QAAD;EAAM,WAAU;YAA+B;CAAY,CAAA,GAC3D,kBAAC,QAAD;EAAM,WAAU;YAAkD;CAAY,CAAA,CAC3E;IAaD,KAAa,EAAE,SAAM,QAAK,kBAAwE;CACtG,IAAM,EAAE,SAAM,EAAQ;CAEtB,OADK,IAEH,kBAAC,QAAD,EAAA,UAAA,CACG,GAAG,EAAK,GAAG,KACX,IACC,kBAAC,QAAD;EAAM,WAAU;YACb,EAAE,qDAAqD,YAAY;CAChE,CAAA,IACJ,IACA,EAAA,CAAA,IATS,kBAAC,Q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AE,UAAS,KAAS;;SACtE,kBAAC,QAAD;UAAM,WAAU;oBAAuB,EAAgB,EAAE,UAAU;SAAQ,CAAA;SAC3E,kBAAC,UAAD;UACE,MAAK;UACL,eAAe,KAAK,GAAmB,EAAE,EAAE;UAC3C,WAAU;oBAET,EAAE,iBAAiB,QAAQ;SACtB,CAAA;QACN;UAVK,EAAE,EAUP,CACL;MACC,CAAA,CAEH;;KAEL,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,MAAD;OAAI,WAAU;iBAAd,CACE,kBAAC,GAAD,EAAW,WAAU,8BAA+B,CAAA,GACnD,EAAE,+CAA+C,UAAU,CAC1D;UACJ,kBAAC,GAAD;OAAwB;OAAU,SAAS,EAAQ;OAAU,OAAO,EAAO;MAAW,CAAA,CACnF;;IACF;;GAEL,kBAAC,GAAD;IACE,MAAM;IACN,eAAe,EAAY,EAAK;IAChC,QAAQ;IACA;IACO;IACf,UAAU;GACX,CAAA;GACD,kBAAC,GAAD;IACE,MAAM;IACN,eAAe,EAAc,EAAK;IAClC,YAAY,EAAE;IACd,UAAU;GACX,CAAA;EACS;;AAEhB"}
1
+ {"version":3,"file":"AnimalDepthPage.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/AnimalDepthPage.tsx"],"sourcesContent":["/**\n * Single-animal deep record (BOFF-2890 · L-1).\n * EID/RFID, body-condition score, group, grazing/rotation, dam/sire genealogy, ADG, latest\n * weight and weight history, plus the medication-withdrawal compliance badge (reused from\n * BOFF-2885). Edit the record or log a new weight in place. No fabricated data.\n */\nimport { useEffect, useMemo, useState } from 'react';\nimport { useNavigate, useParams } from 'react-router';\nimport { AlertTriangle, ArrowLeft, GitBranch, Pencil, Scale, TrendingUp } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PageLayout, StatusBadge, ErrorState, PageLoader, Breadcrumbs, useConfirm } from '../../components';\n\n/** Matches GrazingPage: a keystroke must not fire the herd-depth read, which is an expensive one. */\nconst ANIMAL_SEARCH_DEBOUNCE_MS = 300;\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { useHealthyBowlLivestockDepth } from '../../hooks/useHealthyBowlLivestockDepth';\nimport { useHealthyBowlGrazingEvents } from '../../hooks/useHealthyBowlGrazing';\nimport { AnimalDepthFormModal, type AnimalOption } from './AnimalDepthFormModal';\nimport { RecordWeightModal } from './RecordWeightModal';\nimport { PedigreeTree } from './PedigreeTree';\nimport { formatAdg, formatBcs, formatShortDate, formatWeight, withdrawalBadgeVariant } from './depthLabels';\n\nconst DetailRow = ({ label, value }: { label: string; value: React.ReactNode }) => (\n <div className=\"flex items-center justify-between gap-4 border-b border-border-subtle py-3 last:border-0\">\n <span className=\"text-sm text-text-secondary\">{label}</span>\n <span className=\"text-end text-sm font-medium text-text-primary\">{value}</span>\n </div>\n);\n\n/**\n * One parent on the genealogy row (BOFF-6195).\n *\n * Deliberately NOT a link. `healthyBowlAnimalDepth` filters `deletedAt: null`, so navigating to an\n * archived parent dead-ends on NOT_FOUND — a link that reliably breaks is worse than plain text.\n *\n * The \"(archived)\" marker is driven by the API's `damArchived`/`sireArchived`, never inferred from\n * whether the tag happens to be missing from the live herd list: that read is capped, so an absence\n * there is not evidence the animal left the herd.\n */\nconst ParentTag = ({ role, tag, archived }: { role: string; tag: string | null; archived: boolean }) => {\n const { t } = useI18n();\n if (!tag) return <span>{`${role} —`}</span>;\n return (\n <span>\n {`${role} ${tag}`}\n {archived ? (\n <span className=\"ms-1 font-normal text-text-secondary\">\n {t('healthybowl.livestock.depth.detail.archivedSuffix', '(archived)')}\n </span>\n ) : null}\n </span>\n );\n};\n\nexport const AnimalDepthPage = () => {\n const { t } = useI18n();\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { toast } = useToast();\n const confirm = useConfirm();\n const { animalId } = useParams<{ animalId: string }>();\n\n const [editOpen, setEditOpen] = useState(false);\n const [animalSearch, setAnimalSearch] = useState('');\n const [debouncedAnimalSearch, setDebouncedAnimalSearch] = useState('');\n useEffect(() => {\n const id = globalThis.setTimeout(() => setDebouncedAnimalSearch(animalSearch), ANIMAL_SEARCH_DEBOUNCE_MS);\n return () => globalThis.clearTimeout(id);\n }, [animalSearch]);\n\n const {\n animalDepth,\n herd,\n groups,\n pedigree,\n loading,\n errors,\n refetchAnimal,\n updateAnimalDepth,\n recordWeight,\n deleteWeight,\n } = useHealthyBowlLivestockDepth({\n animalId: animalId ?? null,\n // ★ Fetched only while the edit modal is open, and filtered SERVER-side.\n //\n // `healthyBowlHerdDepth` is capped at 2,000 rows ordered by tagNumber, so on a larger herd the\n // picker simply never saw the rest — and, worse, asserted they did not exist. Radix's typeahead\n // only matches items already rendered, so there was no way to reach past the cap from the UI.\n // The backend has taken `search` in the Prisma WHERE since BOFF-6012; this page was never\n // migrated. GrazingPage hit exactly this and fixed it the same way.\n //\n // Gating on `editOpen` matters as much as the search: this read also pulls up to 20,000 weight\n // records and 20,000 medication rows, which is far heavier than a picker warrants on page load.\n herd: editOpen,\n herdSearch: debouncedAnimalSearch.trim() || null,\n // The Dam/Sire picker must be able to offer a culled or sold parent — the backend has\n // accepted that link since BOFF-6011, and this page is the only place it can be recorded\n // (BOFF-6195). Archived rows are additive to `rows` only; the compliance summary and the\n // group counts stay live-only server-side.\n herdIncludeArchived: true,\n groups: true,\n // The one-hop Dam/Sire row answers \"who are the parents\"; the pedigree answers \"where does\n // this animal come from, and what has it produced\" (BOFF-6097).\n pedigree: true,\n });\n\n /**\n * Where this animal actually is (BOFF-5970).\n *\n * `recordHealthyBowlGrazingMove` writes a grazing EVENT and never touches the animal's legacy\n * `grazingPaddock` / `rotationDate` columns, so after any move recorded on the Grazing page those\n * two are a frozen snapshot of a previous model — and rendering them as a plain current fact made\n * this page and the Grazing page give two different answers to the same question. The event is\n * the live answer whenever one exists; the legacy pair is annotated in the VALUE, not only in its\n * label, because the label is not what a farmer reads off the row.\n */\n const {\n latest: latestGrazing,\n loading: grazingLoading,\n error: grazingError,\n } = useHealthyBowlGrazingEvents({ animalId: animalId ?? null, limit: 5 });\n\n const [weightOpen, setWeightOpen] = useState(false);\n\n const animalOptions = useMemo<AnimalOption[]>(\n () =>\n (herd?.rows ?? []).map((r) => ({\n animalId: r.animalId,\n tagNumber: r.tagNumber,\n name: r.name,\n // `archived` is only selected by the archived-aware herd document, which this page opts\n // into above. Defaulting to false keeps the option type honest for any future caller that\n // does not.\n archived: r.archived ?? false,\n })),\n [herd]\n );\n\n if (loading.animal && !animalDepth) {\n return <PageLoader />;\n }\n if ((errors.animal && !animalDepth) || !animalDepth) {\n return (\n <PageLayout title={t('healthybowl.livestock.depth.detail.title', 'Animal Record')}>\n <ErrorState\n description={errors.animal?.message ?? t('healthybowl.livestock.depth.detail.notFound', 'Animal not found.')}\n onRetry={() => void refetchAnimal()}\n />\n </PageLayout>\n );\n }\n\n const a = animalDepth;\n const initials = a.name.slice(0, 2).toUpperCase();\n\n const handleEdit = async (input: Record<string, unknown>) => {\n await updateAnimalDepth(input);\n toast({\n title: t('healthybowl.livestock.depth.toast.updated', 'Record updated'),\n description: a.name,\n variant: 'success',\n });\n };\n\n const handleWeight = async (input: Record<string, unknown>) => {\n await recordWeight({ ...input, animalId: a.animalId });\n toast({\n title: t('healthybowl.livestock.depth.toast.weightSaved', 'Weight recorded'),\n description: `${String(input.weightKg)} kg`,\n variant: 'success',\n });\n };\n\n const handleDeleteWeight = async (id: string) => {\n if (\n !(await confirm({\n title: t('healthybowl.livestock.depth.confirm.delWeightTitle', 'Delete weight?'),\n message: t('healthybowl.livestock.depth.confirm.delWeight', 'Remove this weight measurement?'),\n }))\n ) {\n return;\n }\n try {\n await deleteWeight(id);\n toast({ title: t('healthybowl.livestock.depth.toast.weightDeleted', 'Weight removed'), variant: 'success' });\n } catch (err) {\n toast({\n title: t('healthybowl.livestock.depth.toast.error', 'Something went wrong'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n }\n };\n\n return (\n <PageLayout\n title={a.name}\n description={`${a.type} · ${a.tagNumber}`}\n actions={\n <div className=\"flex items-center gap-2\">\n <Button variant=\"outline\" onClick={() => setWeightOpen(true)}>\n <Scale className=\"h-4 w-4\" />\n {t('healthybowl.livestock.depth.detail.logWeight', 'Record weight')}\n </Button>\n <Button onClick={() => setEditOpen(true)}>\n <Pencil className=\"h-4 w-4\" />\n {t('healthybowl.livestock.depth.detail.edit', 'Edit')}\n </Button>\n </div>\n }\n >\n <Breadcrumbs\n items={[\n { label: t('healthybowl.livestock.depth.title', 'Livestock Records'), href: buildPath('livestock/records') },\n { label: a.name },\n ]}\n />\n\n <div className=\"mt-2\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => navigate(buildPath('livestock/records'))}>\n <ArrowLeft className=\"h-4 w-4\" />\n {t('common.back', 'Back')}\n </Button>\n </div>\n\n {a.withdrawal.blocked ? (\n <div\n role=\"alert\"\n className=\"mt-3 flex items-center gap-3 rounded-lg border border-status-error-border bg-status-error-bg px-4 py-3 text-status-error-text\"\n >\n <AlertTriangle className=\"h-5 w-5 shrink-0\" />\n <span className=\"text-sm font-semibold\">\n {t(\n 'healthybowl.livestock.depth.detail.withdrawalBanner',\n 'In medication withdrawal — Withdrawal ends {{date}} · do not sell milk or meat',\n {\n date: formatShortDate(a.withdrawal.endDate),\n }\n )}\n </span>\n </div>\n ) : null}\n\n <div className=\"mt-4 grid grid-cols-1 gap-4 lg:grid-cols-3\">\n <div className=\"rounded-xl border border-border-subtle bg-bg-surface p-5 lg:col-span-2\">\n <div className=\"mb-2 flex items-center gap-3\">\n <div className=\"flex h-14 w-14 items-center justify-center rounded-full bg-accent-teal/10 text-lg font-semibold text-accent-teal\">\n {initials}\n </div>\n <div>\n <div className=\"text-lg font-semibold text-text-primary\">{a.name}</div>\n <div className=\"text-sm text-text-secondary\">\n {a.type} #{a.tagNumber}\n </div>\n </div>\n <div className=\"ms-auto\">\n <StatusBadge\n variant={withdrawalBadgeVariant(a.withdrawal.status)}\n label={\n a.withdrawal.blocked\n ? t('healthybowl.livestock.depth.detail.inWithdrawal', 'In withdrawal')\n : t('healthybowl.livestock.depth.detail.clear', 'Clear to sell')\n }\n dot\n />\n </div>\n </div>\n\n <DetailRow label={t('healthybowl.livestock.depth.detail.eid', 'EID / RFID Tag')} value={a.eidTag ?? '—'} />\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.bcs', 'Body Condition Score')}\n value={formatBcs(a.bodyConditionScore)}\n />\n <DetailRow label={t('healthybowl.livestock.depth.detail.group', 'Group')} value={a.groupName ?? '—'} />\n {/* The live answer, from the grazing event model (BOFF-5970). Error before empty: \"no\n move recorded\" is a claim about this animal and must not stand in for a failed read. */}\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.grazingNow', 'Grazing — where this animal is')}\n value={\n <span className=\"inline-flex flex-col items-end gap-0.5\">\n {grazingError ? (\n <span className=\"text-status-error-text\">\n {t(\n 'healthybowl.livestock.depth.detail.grazingFailed',\n 'The grazing log could not be read — {{message}}',\n { message: grazingError.message }\n )}\n </span>\n ) : grazingLoading && !latestGrazing ? (\n <span className=\"font-normal text-text-secondary\">\n {t('healthybowl.livestock.depth.detail.grazingLoading', 'Reading the grazing log…')}\n </span>\n ) : latestGrazing ? (\n <>\n <span>{latestGrazing.paddockName}</span>\n <span className=\"text-xs font-normal text-text-secondary\">\n {latestGrazing.active\n ? t('healthybowl.livestock.depth.detail.grazingIn', 'In since {{date}}', {\n date: formatShortDate(latestGrazing.enteredAt),\n })\n : t('healthybowl.livestock.depth.detail.grazingOut', 'Left {{date}} — no paddock since', {\n date: formatShortDate(latestGrazing.exitedAt),\n })}\n </span>\n </>\n ) : (\n <span className=\"font-normal text-text-secondary\">\n {t('healthybowl.livestock.depth.detail.grazingNone', 'No move recorded in the grazing log yet.')}\n </span>\n )}\n <button\n type=\"button\"\n className=\"text-xs font-normal text-text-secondary underline hover:text-text-primary\"\n onClick={() => navigate(buildPath('livestock/grazing'))}\n >\n {t('healthybowl.livestock.depth.detail.grazingLink', 'Open grazing — moves, rest and stocking rate')}\n </button>\n </span>\n }\n />\n {/* LEGACY grazing fields (BOFF-2890). `rotationDate` is a single scalar, so writing the\n next rotation overwrote the previous one — no duration, rest period or stocking rate\n could ever be derived from it. BOFF-5970 replaced this with a grazing EVENT, and moves\n recorded there never write back here, so once an event exists this pair is a frozen\n snapshot. The VALUE says so, not just the label: the label is not what gets read off\n the row. Shown at all only when there is something in it. */}\n {a.grazingPaddock ? (\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.grazing', 'Grazing / Rotation (legacy)')}\n value={\n <span className=\"inline-flex flex-col items-end gap-0.5\">\n <span className={latestGrazing ? 'font-normal text-text-secondary line-through' : undefined}>\n {`${a.grazingPaddock}${a.rotationDate ? ` (rotates ${formatShortDate(a.rotationDate)})` : ''}`}\n </span>\n <span className=\"max-w-[320px] text-xs font-normal text-text-secondary\">\n {latestGrazing\n ? t(\n 'healthybowl.livestock.depth.detail.grazingSuperseded',\n 'Recorded before the grazing log and never updated since — the row above is where this animal is now.'\n )\n : grazingError || grazingLoading\n ? t(\n 'healthybowl.livestock.depth.detail.grazingUnchecked',\n 'A single free-text paddock and one rotation date, with no time in or out. Whether the grazing log has superseded it could not be checked.'\n )\n : t(\n 'healthybowl.livestock.depth.detail.grazingOnlyRecord',\n 'A single free-text paddock and one rotation date, with no time in or out. Record a move on the Grazing page and this animal joins the history.'\n )}\n </span>\n </span>\n }\n />\n ) : null}\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.genealogy', 'Genealogy — Dam · Sire')}\n value={\n <span className=\"inline-flex flex-wrap items-center justify-end gap-x-1\">\n <ParentTag\n role={t('healthybowl.livestock.depth.detail.dam', 'Dam')}\n tag={a.damTag}\n archived={a.damArchived}\n />\n <span className=\"text-text-secondary\">·</span>\n <ParentTag\n role={t('healthybowl.livestock.depth.detail.sire', 'Sire')}\n tag={a.sireTag}\n archived={a.sireArchived}\n />\n </span>\n }\n />\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.adg', 'Average Daily Gain (ADG)')}\n value={\n <span className=\"inline-flex items-center gap-1\">\n {a.adgKgPerDay !== null ? <TrendingUp className=\"h-4 w-4 text-accent-teal\" /> : null}\n {formatAdg(a.adgKgPerDay)}\n </span>\n }\n />\n <DetailRow\n label={t('healthybowl.livestock.depth.detail.latestWeight', 'Latest Weight')}\n value={formatWeight(a.latestWeightKg, a.latestWeightAt)}\n />\n {a.grazingNotes ? (\n <DetailRow label={t('healthybowl.livestock.depth.detail.notes', 'Grazing notes')} value={a.grazingNotes} />\n ) : null}\n </div>\n\n <div className=\"rounded-xl border border-border-subtle bg-bg-surface p-5\">\n <div className=\"mb-3 flex items-center justify-between\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.livestock.depth.detail.weightHistory', 'Weight history')}\n </h3>\n <Button variant=\"outline\" size=\"sm\" onClick={() => setWeightOpen(true)}>\n <Scale className=\"h-3.5 w-3.5\" />\n {t('healthybowl.livestock.depth.detail.add', 'Add')}\n </Button>\n </div>\n {a.weightHistory.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'healthybowl.livestock.depth.detail.noWeights',\n 'No weights logged yet — record two or more to compute ADG.'\n )}\n </p>\n ) : (\n <ul className=\"space-y-2\">\n {a.weightHistory.map((w) => (\n <li key={w.id} className=\"flex items-center justify-between rounded-md bg-bg-sunken px-3 py-2 text-sm\">\n <span className=\"tabular-nums text-text-primary\">{w.weightKg} kg</span>\n <span className=\"text-text-secondary\">{formatShortDate(w.measuredAt)}</span>\n <button\n type=\"button\"\n onClick={() => void handleDeleteWeight(w.id)}\n className=\"text-xs text-text-secondary hover:text-status-error-text\"\n >\n {t('common.remove', 'Remove')}\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n <div className=\"rounded-xl border border-border-subtle bg-bg-surface p-5 lg:col-span-3\">\n <h3 className=\"mb-3 flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <GitBranch className=\"h-4 w-4 text-text-secondary\" />\n {t('healthybowl.livestock.depth.detail.pedigree', 'Pedigree')}\n </h3>\n <PedigreeTree pedigree={pedigree} loading={loading.pedigree} error={errors.pedigree} />\n </div>\n </div>\n\n <AnimalDepthFormModal\n open={editOpen}\n onClose={() => setEditOpen(false)}\n animal={a}\n groups={groups}\n animalOptions={animalOptions}\n animalSearch={animalSearch}\n onAnimalSearchChange={setAnimalSearch}\n // The picker now shows a server-filtered slice, so it must say when there is more behind it.\n animalOptionsTruncated={herd?.truncated ?? false}\n animalOptionsLoading={loading.herd}\n onSubmit={handleEdit}\n />\n <RecordWeightModal\n open={weightOpen}\n onClose={() => setWeightOpen(false)}\n animalName={a.name}\n onSubmit={handleWeight}\n />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAcA,IAAM,IAA4B,KAU5B,KAAa,EAAE,UAAO,eAC1B,kBAAC,OAAD;CAAK,WAAU;WAAf,CACE,kBAAC,QAAD;EAAM,WAAU;YAA+B;CAAY,CAAA,GAC3D,kBAAC,QAAD;EAAM,WAAU;YAAkD;CAAY,CAAA,CAC3E;IAaD,KAAa,EAAE,SAAM,QAAK,kBAAwE;CACtG,IAAM,EAAE,SAAM,EAAQ;CAEtB,OADK,IAEH,kBAAC,QAAD,EAAA,UAAA,CACG,GAAG,EAAK,GAAG,KACX,IACC,kBAAC,QAAD;EAAM,WAAU;YACb,EAAE,qDAAqD,YAAY;CAChE,CAAA,IACJ,IACA,EAAA,CAAA,IATS,kBAAC,QAAD,EAAA,UAAO,GAAG,EAAK,IAAU,CAAA;AAW5C,GAEa,UAAwB;CACnC,IAAM,EAAE,SAAM,EAAQ,GAChB,IAAW,EAAY,GACvB,EAAE,iBAAc,EAAY,GAC5B,EAAE,aAAU,EAAS,GACrB,IAAU,GAAW,GACrB,EAAE,gBAAa,EAAgC,GAE/C,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,CAAC,GAAc,KAAmB,EAAS,EAAE,GAC7C,C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,WAAU;oBAAuB,EAAgB,EAAE,UAAU;SAAQ,CAAA;SAC3E,kBAAC,UAAD;UACE,MAAK;UACL,eAAe,KAAK,GAAmB,EAAE,EAAE;UAC3C,WAAU;oBAET,EAAE,iBAAiB,QAAQ;SACtB,CAAA;QACN;UAVK,EAAE,EAUP,CACL;MACC,CAAA,CAEH;;KAEL,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,MAAD;OAAI,WAAU;iBAAd,CACE,kBAAC,GAAD,EAAW,WAAU,8BAA+B,CAAA,GACnD,EAAE,+CAA+C,UAAU,CAC1D;UACJ,kBAAC,IAAD;OAAwB;OAAU,SAAS,EAAQ;OAAU,OAAO,EAAO;MAAW,CAAA,CACnF;;IACF;;GAEL,kBAAC,GAAD;IACE,MAAM;IACN,eAAe,EAAY,EAAK;IAChC,QAAQ;IACA;IACO;IACD;IACd,sBAAsB;IAEtB,wBAAwB,GAAM,aAAa;IAC3C,sBAAsB,EAAQ;IAC9B,UAAU;GACX,CAAA;GACD,kBAAC,IAAD;IACE,MAAM;IACN,eAAe,EAAc,EAAK;IAClC,YAAY,EAAE;IACd,UAAU;GACX,CAAA;EACS;;AAEhB"}
@@ -0,0 +1,23 @@
1
+ //#region src/healthybowl/pages/livestock/parentOptions.ts
2
+ function e(e) {
3
+ return [e.damId && e.damTag ? {
4
+ animalId: e.damId,
5
+ tagNumber: e.damTag,
6
+ name: "",
7
+ archived: e.damArchived
8
+ } : null, e.sireId && e.sireTag ? {
9
+ animalId: e.sireId,
10
+ tagNumber: e.sireTag,
11
+ name: "",
12
+ archived: e.sireArchived
13
+ } : null].filter((e) => e !== null);
14
+ }
15
+ function t(t, n) {
16
+ let r = /* @__PURE__ */ new Map();
17
+ for (let i of [...n, ...e(t)]) i.animalId !== t.animalId && (r.has(i.animalId) || r.set(i.animalId, i));
18
+ return [...r.values()].sort((e, t) => Number(e.archived) - Number(t.archived));
19
+ }
20
+ //#endregion
21
+ export { t as buildParentOptions };
22
+
23
+ //# sourceMappingURL=parentOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parentOptions.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/parentOptions.ts"],"sourcesContent":["/**\n * Which animals the Dam/Sire picker may offer (BOFF-7162).\n *\n * The herd list feeding this picker is capped at 2,000 rows server-side and, since this ticket, is\n * also SEARCH-FILTERED server-side. Both facts break the naive \"just render what came back\":\n *\n * - the parent recorded years ago is usually absent from the current search results, and\n * - a Select whose `value` matches no item renders its trigger EMPTY, which tells a farmer no\n * parent is recorded when one is.\n *\n * So the recorded dam and sire are always merged in, synthesised from the animal's own record\n * (`damTag`/`damArchived`, `sireTag`/`sireArchived`) — no extra query needed. The stored id does\n * survive a save regardless, because it is held in form state rather than read back off this list;\n * this is a display correctness fix, not a data-loss one.\n */\nimport type { AnimalDepthRecord } from '../../hooks/useHealthyBowlLivestockDepth';\n\nexport interface AnimalOption {\n animalId: string;\n tagNumber: string;\n name: string;\n /** Has left the herd. Still pickable — a culled or sold parent is still the parent (BOFF-6011). */\n archived: boolean;\n}\n\n/** The dam and sire already on the record, as pickable options. */\nexport function recordedParentOptions(animal: AnimalDepthRecord): AnimalOption[] {\n return [\n animal.damId && animal.damTag\n ? { animalId: animal.damId, tagNumber: animal.damTag, name: '', archived: animal.damArchived }\n : null,\n animal.sireId && animal.sireTag\n ? { animalId: animal.sireId, tagNumber: animal.sireTag, name: '', archived: animal.sireArchived }\n : null,\n ].filter((option): option is AnimalOption => option !== null);\n}\n\n/**\n * The picker's option list: the recorded parents first (so they always exist), then the server's\n * slice, de-duplicated by id, with the animal itself removed and archived stock sorted last.\n *\n * The server's rows come FIRST and win a collision: a synthesised option carries only a tag number,\n * while the server row also carries the animal's name. The synthesised entry is a FALLBACK — it\n * exists to guarantee the recorded parent is offered at all, not to replace a better row when the\n * search happens to return one. `Array.prototype.sort` is stable, so the backend's tagNumber\n * ordering survives within each half.\n */\nexport function buildParentOptions(animal: AnimalDepthRecord, fromServer: AnimalOption[]): AnimalOption[] {\n const byId = new Map<string, AnimalOption>();\n for (const option of [...fromServer, ...recordedParentOptions(animal)]) {\n // An animal is never its own parent, whatever the server returned.\n if (option.animalId === animal.animalId) continue;\n if (!byId.has(option.animalId)) byId.set(option.animalId, option);\n }\n return [...byId.values()].sort((x, y) => Number(x.archived) - Number(y.archived));\n}\n"],"mappings":";AA0BA,SAAgB,EAAsB,GAA2C;CAC/E,OAAO,CACL,EAAO,SAAS,EAAO,SACnB;EAAE,UAAU,EAAO;EAAO,WAAW,EAAO;EAAQ,MAAM;EAAI,UAAU,EAAO;CAAY,IAC3F,MACJ,EAAO,UAAU,EAAO,UACpB;EAAE,UAAU,EAAO;EAAQ,WAAW,EAAO;EAAS,MAAM;EAAI,UAAU,EAAO;CAAa,IAC9F,IACN,EAAE,QAAQ,MAAmC,MAAW,IAAI;AAC9D;AAYA,SAAgB,EAAmB,GAA2B,GAA4C;CACxG,IAAM,oBAAO,IAAI,IAA0B;CAC3C,KAAK,IAAM,KAAU,CAAC,GAAG,GAAY,GAAG,EAAsB,CAAM,CAAC,GAE/D,EAAO,aAAa,EAAO,aAC1B,EAAK,IAAI,EAAO,QAAQ,KAAG,EAAK,IAAI,EAAO,UAAU,CAAM;CAElE,OAAO,CAAC,GAAG,EAAK,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,QAAQ,CAAC;AAClF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.918.1",
3
+ "version": "2026.918.2",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [