@burdenoff/microfe-healthybowl 2026.919.2 → 2026.919.4

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 +1 @@
1
- {"version":3,"file":"AIAssistantPanel.js","names":[],"sources":["../../../src/components/assistant/AIAssistantPanel.tsx"],"sourcesContent":["/**\n * HealthyBowl's AI assistant.\n *\n * ★★ Everything below this file is now shared. The panel, the orchestrator, the\n * transport, the voice session, the composer and every component in them live in\n * `fe-libs/shared/assistant` and answer to any product that mounts them. What is\n * left here is the four things that are genuinely HealthyBowl's, and nothing\n * else:\n *\n * modes which use cases this product offers.\n * describeCurrentPage what to CALL the page the user is on.\n * gatherPageContext the same page, as structured context for the agent.\n * buildPrompt the system preamble — that this is an agronomy\n * assistant, what it may do, and in which language.\n * reportTokenUsage the charge, against HealthyBowl's OWN mutation.\n *\n * Plus `writeAccess`, which is a PROP rather than a fifth seam field: which\n * resource types prove \"this user can write here\" is a product answer, but the\n * product can simply compute it and hand it down. A capability a product can\n * work out for itself does not belong in an interface every product must\n * satisfy.\n *\n * ★ The provider wraps from OUTSIDE the shared panel rather than sitting inside\n * its tree: the panel calls `useAssistantProduct()` and `useAssistantTr()` in its\n * own body, so a provider nested in its JSX would be below the consumer and read\n * as null — which does not throw, it silently renders English with no modes.\n */\n\nimport type { FC } from 'react';\nimport {\n AIAssistantPanel as SharedAIAssistantPanel,\n type AIAssistantPanelProps as SharedProps,\n} from '@burdenoff/fe-libs/shared/assistant/ui/AIAssistantPanel';\nimport { AssistantProductProvider } from '@burdenoff/fe-libs/shared/assistant/product';\nimport { getActorId, getWorkspaceId } from '@burdenoff/fe-libs/shared/assistant/context';\nimport { ASSISTANT_MODES } from '@/types/assistant';\nimport { PRODUCT, reportAssistantAiTokenUsage } from '@/services/assistantApi';\nimport { useWorkspaceWriteAccess } from '@/hooks/useWorkspaceWriteAccess';\nimport { describeCurrentPage, gatherPageContext } from '@/utils/pageContext';\nimport { buildPromptForMode } from '@/utils/assistantPrompt';\n\n/**\n * Where this product's assistant files already live.\n *\n * ★★ These strings are LOAD-BEARING and must not be \"tidied\". They are the real\n * folders in the workspace file library holding every attachment and artifact\n * users have saved. Changing them does not fail — it starts a second folder\n * beside the first and orphans everything in the original.\n *\n * ★ Note the capitalisation: `/HealthyBowl/…`, while the product id is\n * `healthybowl`. That mismatch is exactly why fe-libs cannot derive this and why\n * it is supplied here. The shared default (`/<product>/AI Assistant/…`) is right\n * for a product starting fresh and would be a rename for this one.\n */\nconst STORAGE_FOLDERS = {\n attachments: '/HealthyBowl/AI Assistant/Attachments',\n artifacts: '/HealthyBowl/AI Assistant/Artifacts',\n} as const;\n\nexport type AIAssistantPanelProps = Omit<SharedProps, 'writeAccess'>;\n\nexport const AIAssistantPanel: FC<AIAssistantPanelProps> = (props) => {\n /**\n * ★ Advisory, never a gate — see `useWorkspaceWriteAccess`. Measured against\n * prod on 2026-09-02, workspace scopes have no roles provisioned at all, so\n * gating on this would delete Take-action from the product until an ops task\n * lands. It warns before the effort instead of after it, and self-corrects\n * with no code change the moment roles exist.\n */\n const writeAccess = useWorkspaceWriteAccess(getActorId(), getWorkspaceId() || null);\n\n return (\n <AssistantProductProvider\n product={PRODUCT}\n modes={ASSISTANT_MODES}\n describeCurrentPage={describeCurrentPage}\n gatherPageContext={gatherPageContext}\n buildPrompt={buildPromptForMode}\n reportTokenUsage={reportAssistantAiTokenUsage}\n storageFolders={STORAGE_FOLDERS}\n >\n <SharedAIAssistantPanel {...props} writeAccess={writeAccess} />\n </AssistantProductProvider>\n );\n};\n"],"mappings":";;;;;;;;;;AAsDA,IAAM,IAAkB;CACtB,aAAa;CACb,WAAW;AACb,GAIa,KAA+C,MAAU;CAQpE,IAAM,IAAc,EAAwB,EAAW,GAAG,EAAe,KAAK,IAAI;CAElF,OACE,kBAAC,GAAD;EACE,SAAS;EACT,OAAO;EACc;EACF;EACnB,aAAa;EACb,kBAAkB;EAClB,gBAAgB;YAEhB,kBAAC,GAAD;GAAwB,GAAI;GAAoB;EAAc,CAAA;CACtC,CAAA;AAE9B"}
1
+ {"version":3,"file":"AIAssistantPanel.js","names":[],"sources":["../../../src/components/assistant/AIAssistantPanel.tsx"],"sourcesContent":["/**\n * HealthyBowl's AI assistant.\n *\n * ★★ Everything below this file is now shared. The panel, the orchestrator, the\n * transport, the voice session, the composer and every component in them live in\n * `fe-libs/shared/assistant` and answer to any product that mounts them. What is\n * left here is the four things that are genuinely HealthyBowl's, and nothing\n * else:\n *\n * modes which use cases this product offers.\n * describeCurrentPage what to CALL the page the user is on.\n * gatherPageContext the same page, as structured context for the agent.\n * buildPrompt the system preamble — that this is an agronomy\n * assistant, what it may do, and in which language.\n * reportTokenUsage the charge, against HealthyBowl's OWN mutation.\n *\n * Plus `writeAccess`, which is a PROP rather than a fifth seam field: which\n * resource types prove \"this user can write here\" is a product answer, but the\n * product can simply compute it and hand it down. A capability a product can\n * work out for itself does not belong in an interface every product must\n * satisfy.\n *\n * ★ The provider wraps from OUTSIDE the shared panel rather than sitting inside\n * its tree: the panel calls `useAssistantProduct()` and `useAssistantTr()` in its\n * own body, so a provider nested in its JSX would be below the consumer and read\n * as null — which does not throw, it silently renders English with no modes.\n */\n\nimport type { FC } from 'react';\nimport {\n AIAssistantPanel as SharedAIAssistantPanel,\n type AIAssistantPanelProps as SharedProps,\n} from '@burdenoff/fe-libs/shared/assistant/ui/AIAssistantPanel';\nimport { AssistantProductProvider } from '@burdenoff/fe-libs/shared/assistant/product';\nimport { getActorId, getWorkspaceId } from '@burdenoff/fe-libs/shared/assistant/context';\nimport { ASSISTANT_MODES } from '@/types/assistant';\nimport { PRODUCT, reportAssistantAiTokenUsage } from '@/services/assistantApi';\nimport { useWorkspaceWriteAccess } from '@/hooks/useWorkspaceWriteAccess';\nimport { describeCurrentPage, gatherPageContext } from '@/utils/pageContext';\nimport { buildPromptForMode } from '@/utils/assistantPrompt';\n\n/**\n * Where this product's assistant files already live.\n *\n * ★★ These strings are LOAD-BEARING and must not be \"tidied\". They are the real\n * folders in the workspace file library holding every attachment and artifact\n * users have saved. Changing them does not fail — it starts a second folder\n * beside the first and orphans everything in the original.\n *\n * ★ Note the capitalisation: `/HealthyBowl/…`, while the product id is\n * `healthybowl`. That mismatch is exactly why fe-libs cannot derive this and why\n * it is supplied here. The shared default (`/<product>/AI Assistant/…`) is right\n * for a product starting fresh and would be a rename for this one.\n */\nconst STORAGE_FOLDERS = {\n attachments: '/HealthyBowl/AI Assistant/Attachments',\n artifacts: '/HealthyBowl/AI Assistant/Artifacts',\n} as const;\n\nexport type AIAssistantPanelProps = Omit<SharedProps, 'writeAccess'>;\n\nexport const AIAssistantPanel: FC<AIAssistantPanelProps> = (props) => {\n /**\n * ★ Advisory, never a gate — see `useWorkspaceWriteAccess`. The `@rbac` check\n * on each mutation is the authority; this only warns before the effort instead\n * of after it. A client-side permission read can be wrong, and a wrong GATE\n * would hide Take-action from a user who is allowed to use it. (The \"no roles\n * provisioned\" reading of 2026-09-02 was one uninitialised workspace, fixed on\n * 2026-09-07 — not the platform.)\n */\n const writeAccess = useWorkspaceWriteAccess(getActorId(), getWorkspaceId() || null);\n\n return (\n <AssistantProductProvider\n product={PRODUCT}\n modes={ASSISTANT_MODES}\n describeCurrentPage={describeCurrentPage}\n gatherPageContext={gatherPageContext}\n buildPrompt={buildPromptForMode}\n reportTokenUsage={reportAssistantAiTokenUsage}\n storageFolders={STORAGE_FOLDERS}\n >\n <SharedAIAssistantPanel {...props} writeAccess={writeAccess} />\n </AssistantProductProvider>\n );\n};\n"],"mappings":";;;;;;;;;;AAsDA,IAAM,IAAkB;CACtB,aAAa;CACb,WAAW;AACb,GAIa,KAA+C,MAAU;CASpE,IAAM,IAAc,EAAwB,EAAW,GAAG,EAAe,KAAK,IAAI;CAElF,OACE,kBAAC,GAAD;EACE,SAAS;EACT,OAAO;EACc;EACF;EACnB,aAAa;EACb,kBAAkB;EAClB,gBAAgB;YAEhB,kBAAC,GAAD;GAAwB,GAAI;GAAoB;EAAc,CAAA;CACtC,CAAA;AAE9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"assistantUsecases.js","names":[],"sources":["../../src/config/assistantUsecases.ts"],"sourcesContent":["/**\n * HealthyBowl AI Assistant usecases.\n *\n * `AssistantUsecaseId` is the full set of modes the transport/runtime\n * understands — it drives the image/resource switches in `services/assistantApi`.\n * `ASSISTANT_USECASE_CONFIG` is the set of modes the panel KNOWS about; the mode\n * selector further filters them at runtime by the user's role (see\n * `useAssistantApiAccess`) so a write-capable mode only appears for org admins.\n * - `general` — docs Q&A (proxy-token auth, available to everyone).\n * - `api-calls` — WRITE-CAPABLE: the agent executes GraphQL on the user's\n * behalf (app-client-credentials auth). Minting its per-sandbox OAuth app\n * requires a global Owner/Admin actor, so it is gated to admins, guarded by a\n * confirm-before-mutate dialog + a soft agent preamble, and master-flagged.\n * - `vibe-plugins` — a VibeControls-only concept HealthyBowl never exposes.\n */\n\n// Full set of runtime-understood modes. Keep in sync with the image/resource\n// switches in `services/assistantApi.ts`.\nexport type AssistantUsecaseId = 'general' | 'assistant' | 'api-calls' | 'vibe-plugins';\n\nexport interface AssistantUsecase {\n id: AssistantUsecaseId;\n label: string;\n description: string;\n suggestions: readonly string[];\n /** Only offered to a global Owner/Admin (minting the OAuth app needs admin). */\n requiresAdmin?: boolean;\n /** Executes mutations on live data → triggers the confirm-before-mutate guard. */\n writeCapable?: boolean;\n}\n\n/**\n * Master switch for the write-capable `api-calls` (\"Actions\") mode. Enabled on\n * ALL environments (alpha + production) as of 2026-06-30, by explicit product\n * decision. The mode remains gated by: (1) the admin check — only org\n * Owners/Admins ever see it (useAssistantApiAccess), (2) a one-time consent\n * dialog, and (3) a describe-and-confirm instruction prepended to the prompt.\n * The in-sandbox agent still auto-executes (no hard server-side confirm yet) —\n * that residual risk was accepted when enabling on prod.\n *\n * `typeof window` keeps it false during any non-browser evaluation; in the\n * browser it's always on (the admin gate is the real boundary).\n */\nexport const API_CALLS_MODE_ENABLED = typeof window !== 'undefined';\n\n// Default \"Ask\" for EVERY user: docs Q&A + READ-ONLY live data. Unlike\n// `api-calls` it authenticates with the user's OWN forwarded token (no\n// admin-gated OAuth-app mint), and the in-sandbox helper rejects mutations\n// (AI_ASSISTANT_READONLY) — so it needs no admin and answers questions like\n// \"list my livestock\" against real data. Writes live in `api-calls` below.\nconst ASSISTANT: AssistantUsecase = {\n id: 'assistant',\n label: 'Ask',\n description:\n 'Ask about HealthyBowl and your own farm data — crops, livestock, weather, finances. Reads your live records; use \"Take action\" to make changes.',\n suggestions: [\n 'List all my livestock',\n 'How many crops do I have?',\n 'Explain the livestock health tracker',\n 'What government schemes can I apply for?',\n ],\n};\n\nconst API_CALLS: AssistantUsecase = {\n id: 'api-calls',\n // Display label only — the mode ID stays 'api-calls' (see services/assistantApi).\n label: 'Take action',\n description:\n 'Let the assistant take actions for you — add crops, log harvests, update records. It describes what it will do and asks before changing anything.',\n suggestions: [\n 'Add a new crop',\n 'Log a harvest for one of my fields',\n 'List all my livestock',\n \"Update a crop's status\",\n ],\n requiresAdmin: true,\n writeCapable: true,\n};\n\n// Modes the panel knows about. The default \"Ask\" is now the read-only\n// `assistant` mode (docs + live data, available to everyone). `api-calls`\n// (\"Take action\", write) is added when enabled and further filtered to admins\n// at runtime by the mode selector. `general` (docs-only) is retained in the\n// type for back-compat with persisted conversations but no longer surfaced.\nexport const ASSISTANT_USECASE_CONFIG: readonly AssistantUsecase[] = API_CALLS_MODE_ENABLED\n ? [ASSISTANT, API_CALLS]\n : [ASSISTANT];\n"],"mappings":";AA2CA,IAAa,IAAyB,OAAO,SAAW,KAOlD,IAA8B;CAClC,IAAI;CACJ,OAAO;CACP,aACE;CACF,aAAa;EACX;EACA;EACA;EACA;CACF;AACF,GAuBa,IAAwD,IACjE,CAAC,GAAW;CArBd,IAAI;CAEJ,OAAO;CACP,aACE;CACF,aAAa;EACX;EACA;EACA;EACA;CACF;CACA,eAAe;CACf,cAAc;AASA,CAAS,IACrB,CAAC,CAAS"}
1
+ {"version":3,"file":"assistantUsecases.js","names":[],"sources":["../../src/config/assistantUsecases.ts"],"sourcesContent":["/**\n * HealthyBowl AI Assistant usecases.\n *\n * `AssistantUsecaseId` is the full set of modes the transport/runtime\n * understands — it drives the image/resource switches in `services/assistantApi`.\n * `ASSISTANT_USECASE_CONFIG` is the set of modes the panel KNOWS about; the mode\n * selector further filters them at runtime by the user's role (see\n * `useAssistantApiAccess`) so a write-capable mode only appears for org admins.\n * - `general` — docs Q&A (proxy-token auth, available to everyone).\n * - `api-calls` — WRITE-CAPABLE: the agent executes GraphQL on the user's\n * behalf (app-client-credentials auth). Minting its per-sandbox OAuth app\n * requires a global Owner/Admin actor, so it is gated to admins, guarded by a\n * confirm-before-mutate dialog + a soft agent preamble, and master-flagged.\n * - `vibe-plugins` — a VibeControls-only concept HealthyBowl never exposes.\n */\n\n// Full set of runtime-understood modes. Keep in sync with the image/resource\n// switches in `services/assistantApi.ts`.\nexport type AssistantUsecaseId = 'general' | 'assistant' | 'api-calls' | 'vibe-plugins';\n\nexport interface AssistantUsecase {\n id: AssistantUsecaseId;\n label: string;\n description: string;\n suggestions: readonly string[];\n /** Only offered to a global Owner/Admin (minting the OAuth app needs admin). */\n requiresAdmin?: boolean;\n /** Executes mutations on live data → triggers the confirm-before-mutate guard. */\n writeCapable?: boolean;\n}\n\n/**\n * Master switch for the write-capable `api-calls` (\"Actions\") mode. Enabled on\n * ALL environments (alpha + production) as of 2026-06-30, by explicit product\n * decision. The mode remains gated by: (1) the admin check — only org\n * Owners/Admins ever see it (useAssistantApiAccess), (2) a one-time consent\n * dialog, (3) the user's approval of each write — since 2026-09-07 the sandbox\n * refuses a mutation and holds it until the user presses Approve on the\n * pending-write card (ai-assistant #41/#42, fe-libs #194), and the model holds\n * no token that could send it — and (4) a describe-and-confirm instruction\n * prepended to the prompt, which is advisory. The approval is recorded inside\n * the sandbox, so it stops an accidental or misread write; it is not a wall\n * against a model set on getting round it.\n *\n * `typeof window` keeps it false during any non-browser evaluation; in the\n * browser it's always on (the admin gate is the real boundary).\n */\nexport const API_CALLS_MODE_ENABLED = typeof window !== 'undefined';\n\n// Default \"Ask\" for EVERY user: docs Q&A + READ-ONLY live data. Unlike\n// `api-calls` it authenticates with the user's OWN forwarded token (no\n// admin-gated OAuth-app mint), and the in-sandbox helper rejects mutations\n// (AI_ASSISTANT_READONLY) — so it needs no admin and answers questions like\n// \"list my livestock\" against real data. Writes live in `api-calls` below.\nconst ASSISTANT: AssistantUsecase = {\n id: 'assistant',\n label: 'Ask',\n description:\n 'Ask about HealthyBowl and your own farm data — crops, livestock, weather, finances. Reads your live records; use \"Take action\" to make changes.',\n suggestions: [\n 'List all my livestock',\n 'How many crops do I have?',\n 'Explain the livestock health tracker',\n 'What government schemes can I apply for?',\n ],\n};\n\nconst API_CALLS: AssistantUsecase = {\n id: 'api-calls',\n // Display label only — the mode ID stays 'api-calls' (see services/assistantApi).\n label: 'Take action',\n description:\n 'Let the assistant take actions for you — add crops, log harvests, update records. It describes what it will do and asks before changing anything.',\n suggestions: [\n 'Add a new crop',\n 'Log a harvest for one of my fields',\n 'List all my livestock',\n \"Update a crop's status\",\n ],\n requiresAdmin: true,\n writeCapable: true,\n};\n\n// Modes the panel knows about. The default \"Ask\" is now the read-only\n// `assistant` mode (docs + live data, available to everyone). `api-calls`\n// (\"Take action\", write) is added when enabled and further filtered to admins\n// at runtime by the mode selector. `general` (docs-only) is retained in the\n// type for back-compat with persisted conversations but no longer surfaced.\nexport const ASSISTANT_USECASE_CONFIG: readonly AssistantUsecase[] = API_CALLS_MODE_ENABLED\n ? [ASSISTANT, API_CALLS]\n : [ASSISTANT];\n"],"mappings":";AA+CA,IAAa,IAAyB,OAAO,SAAW,KAOlD,IAA8B;CAClC,IAAI;CACJ,OAAO;CACP,aACE;CACF,aAAa;EACX;EACA;EACA;EACA;CACF;AACF,GAuBa,IAAwD,IACjE,CAAC,GAAW;CArBd,IAAI;CAEJ,OAAO;CACP,aACE;CACF,aAAa;EACX;EACA;EACA;EACA;CACF;CACA,eAAe;CACf,cAAc;AASA,CAAS,IACrB,CAAC,CAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"GetHelpButton.js","names":[],"sources":["../../../src/healthybowl/components/GetHelpButton.tsx"],"sourcesContent":["import { HelpCircle } from 'lucide-react';\nimport { useOpenAssistantHelp } from '@/hooks/useOpenAssistantHelp';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface GetHelpButtonProps {\n /** The prompt auto-sent to the assistant (general mode) when clicked. */\n prompt: string;\n /** Optional label override. Defaults to \"Get Help\". */\n label?: string;\n /** `ghost` (default) is a subtle outlined button; `link` is text-only. */\n variant?: 'ghost' | 'link';\n /** Additional CSS class names. */\n className?: string;\n}\n\n/**\n * Shared \"Get Help\" button — a contextual help affordance that opens the AI\n * assistant and auto-asks about the current screen, so a user can get help\n * without leaving the page or typing. Rendered by `PageLayout` on every page\n * (prompt derived from the page title), and usable standalone next to \"Add X\"\n * empty states. Mirrors the VibeControls pattern; HB semantic tokens only.\n *\n * Clicking it: switches the assistant to `general` mode, opens the shell panel\n * (`hb:toggle-ai-assistant` { open: true }), and queues `prompt` — the\n * AssistantChatArea auto-sends it. See `useOpenAssistantHelp`.\n */\nexport function GetHelpButton({ prompt, label, variant = 'ghost', className = '' }: GetHelpButtonProps) {\n const tr = useTr();\n const resolvedLabel = label ?? tr('healthybowl.shared.getHelpButton.label', 'Get Help');\n const openHelp = useOpenAssistantHelp();\n\n const baseClass =\n variant === 'ghost'\n ? 'inline-flex items-center gap-1.5 px-3 py-1.5 text-sm border border-border-default text-text-secondary hover:text-text-primary hover:bg-bg-sunken rounded-md transition-colors'\n : 'inline-flex items-center gap-1.5 text-sm text-action-primary-bg hover:underline';\n\n return (\n <button\n type=\"button\"\n onClick={() => openHelp(prompt)}\n className={`${baseClass} ${className}`.trim()}\n title={tr('healthybowl.shared.getHelpButton.tooltip', 'Ask the assistant about this page')}\n data-testid=\"get-help-button\"\n >\n <HelpCircle className=\"size-4\" />\n {resolvedLabel}\n </button>\n );\n}\n"],"mappings":";;;;;AA0BA,SAAgB,EAAc,EAAE,WAAQ,UAAO,aAAU,SAAS,eAAY,MAA0B;CACtG,IAAM,IAAK,EAAM,GACX,IAAgB,KAAS,EAAG,0CAA0C,UAAU,GAChF,IAAW,EAAqB;CAOtC,OACE,kBAAC,UAAD;EACE,MAAK;EACL,eAAe,EAAS,CAAM;EAC9B,WAAW,GARb,MAAY,UACR,kLACA,kFAMsB,GAAG,IAAY,KAAK;EAC5C,OAAO,EAAG,4CAA4C,mCAAmC;EACzF,eAAY;YALd,CAOE,kBAAC,GAAD,EAAY,WAAU,SAAU,CAAA,GAC/B,CACK;;AAEZ"}
1
+ {"version":3,"file":"GetHelpButton.js","names":[],"sources":["../../../src/healthybowl/components/GetHelpButton.tsx"],"sourcesContent":["import { HelpCircle } from 'lucide-react';\nimport { useOpenAssistantHelp } from '@/hooks/useOpenAssistantHelp';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface GetHelpButtonProps {\n /** The prompt auto-sent to the assistant, in whatever mode it is already in, when clicked. */\n prompt: string;\n /** Optional label override. Defaults to \"Get Help\". */\n label?: string;\n /** `ghost` (default) is a subtle outlined button; `link` is text-only. */\n variant?: 'ghost' | 'link';\n /** Additional CSS class names. */\n className?: string;\n}\n\n/**\n * Shared \"Get Help\" button — a contextual help affordance that opens the AI\n * assistant and auto-asks about the current screen, so a user can get help\n * without leaving the page or typing. Rendered by `PageLayout` on every page\n * (prompt derived from the page title), and usable standalone next to \"Add X\"\n * empty states. Mirrors the VibeControls pattern; HB semantic tokens only.\n *\n * Clicking it opens the shell panel (`hb:toggle-ai-assistant` { open: true })\n * and queues `prompt`, which the AssistantChatArea auto-sends. It leaves the\n * MODE alone: forcing `general` — a documentation-only sandbox with no data\n * tools, absent from the mode selector — stranded users in a mode they could\n * neither see nor leave. See `useOpenAssistantHelp`.\n */\nexport function GetHelpButton({ prompt, label, variant = 'ghost', className = '' }: GetHelpButtonProps) {\n const tr = useTr();\n const resolvedLabel = label ?? tr('healthybowl.shared.getHelpButton.label', 'Get Help');\n const openHelp = useOpenAssistantHelp();\n\n const baseClass =\n variant === 'ghost'\n ? 'inline-flex items-center gap-1.5 px-3 py-1.5 text-sm border border-border-default text-text-secondary hover:text-text-primary hover:bg-bg-sunken rounded-md transition-colors'\n : 'inline-flex items-center gap-1.5 text-sm text-action-primary-bg hover:underline';\n\n return (\n <button\n type=\"button\"\n onClick={() => openHelp(prompt)}\n className={`${baseClass} ${className}`.trim()}\n title={tr('healthybowl.shared.getHelpButton.tooltip', 'Ask the assistant about this page')}\n data-testid=\"get-help-button\"\n >\n <HelpCircle className=\"size-4\" />\n {resolvedLabel}\n </button>\n );\n}\n"],"mappings":";;;;;AA4BA,SAAgB,EAAc,EAAE,WAAQ,UAAO,aAAU,SAAS,eAAY,MAA0B;CACtG,IAAM,IAAK,EAAM,GACX,IAAgB,KAAS,EAAG,0CAA0C,UAAU,GAChF,IAAW,EAAqB;CAOtC,OACE,kBAAC,UAAD;EACE,MAAK;EACL,eAAe,EAAS,CAAM;EAC9B,WAAW,GARb,MAAY,UACR,kLACA,kFAMsB,GAAG,IAAY,KAAK;EAC5C,OAAO,EAAG,4CAA4C,mCAAmC;EACzF,eAAY;YALd,CAOE,kBAAC,GAAD,EAAY,WAAU,SAAU,CAAA,GAC/B,CACK;;AAEZ"}
@@ -292,12 +292,7 @@ var Dt = a`
292
292
  notes
293
293
  fee
294
294
  status
295
- # NO payment fields. BOFF-6030 shipped this UI to main on 2026-09-02 (#328) without its
296
- # backend half: type Consultation in wspace-healthybowl-svc has no paymentStatus /
297
- # paymentProvider / paymentReference / paidAmount / paidAt, and PRs #248 and #249 are closed
298
- # unmerged. A validation error rejects the WHOLE query, so selecting them took six prod pages
299
- # down for 38 minutes on 2026-09-18 and forced the BOFF-7341 repin to be rolled back.
300
- # Restore them together with the backend fields, not before.
295
+ # No payment fields until BOFF-6030's backend lands — see the note above this document.
301
296
  createdAt
302
297
  }
303
298
  }
@@ -314,12 +309,7 @@ var Dt = a`
314
309
  notes
315
310
  fee
316
311
  status
317
- # NO payment fields. BOFF-6030 shipped this UI to main on 2026-09-02 (#328) without its
318
- # backend half: type Consultation in wspace-healthybowl-svc has no paymentStatus /
319
- # paymentProvider / paymentReference / paidAmount / paidAt, and PRs #248 and #249 are closed
320
- # unmerged. A validation error rejects the WHOLE query, so selecting them took six prod pages
321
- # down for 38 minutes on 2026-09-18 and forced the BOFF-7341 repin to be rolled back.
322
- # Restore them together with the backend fields, not before.
312
+ # No payment fields until BOFF-6030's backend lands — see the note above this document.
323
313
  createdAt
324
314
  }
325
315
  }
@@ -336,12 +326,7 @@ var Dt = a`
336
326
  notes
337
327
  fee
338
328
  status
339
- # NO payment fields. BOFF-6030 shipped this UI to main on 2026-09-02 (#328) without its
340
- # backend half: type Consultation in wspace-healthybowl-svc has no paymentStatus /
341
- # paymentProvider / paymentReference / paidAmount / paidAt, and PRs #248 and #249 are closed
342
- # unmerged. A validation error rejects the WHOLE query, so selecting them took six prod pages
343
- # down for 38 minutes on 2026-09-18 and forced the BOFF-7341 repin to be rolled back.
344
- # Restore them together with the backend fields, not before.
329
+ # No payment fields until BOFF-6030's backend lands — see the note above this document.
345
330
  createdAt
346
331
  }
347
332
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useHealthyBowlData.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlData.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport {\n useGetHealthyBowlAnalyticsDataQuery,\n useGetHealthyBowlComplianceDataQuery,\n useGetHealthyBowlDashboardDataQuery,\n useGetHealthyBowlFinancialDataQuery,\n useGetHealthyBowlTransactionReceiptUrlLazyQuery,\n useGetHealthyBowlGovernmentDataQuery,\n useGetHealthyBowlLivestockDataQuery,\n useGetHealthyBowlMarketplaceDataQuery,\n useGetHealthyBowlNetworkDataQuery,\n useGetHealthyBowlPestDataQuery,\n useGetHealthyBowlProductionDataQuery,\n useGetHealthyBowlProductsDataQuery,\n useGetHealthyBowlSoilDataQuery,\n useGetHealthyBowlTraceabilityDataQuery,\n useMarkHealthyBowlAlertReadMutation,\n useMarkHealthyBowlGovernmentNotificationReadMutation,\n useCreateHealthyBowlCropMutation,\n useUpdateHealthyBowlCropMutation,\n useDeleteHealthyBowlCropMutation,\n useCreateHealthyBowlAnimalMutation,\n useUpdateHealthyBowlAnimalMutation,\n useDeleteHealthyBowlAnimalMutation,\n useCreateHealthyBowlFarmMutation,\n useUpdateHealthyBowlFarmMutation,\n useCreateHealthyBowlFieldMutation,\n useUpdateHealthyBowlFieldMutation,\n useDeleteHealthyBowlFieldMutation,\n useCreateHealthyBowlMarketplaceProductMutation,\n useUpdateHealthyBowlMarketplaceProductMutation,\n useDeleteHealthyBowlMarketplaceProductMutation,\n useCreateHealthyBowlTransactionMutation,\n useUpdateHealthyBowlTransactionMutation,\n useDeleteHealthyBowlTransactionMutation,\n useCreateHealthyBowlPlantingPlanMutation,\n useCreateHealthyBowlHarvestRecordMutation,\n useCreateHealthyBowlHealthRecordMutation,\n useCreateHealthyBowlFeedRecordMutation,\n useCreateHealthyBowlVaccinationMutation,\n useCreateHealthyBowlBreedingRecordMutation,\n useCreateHealthyBowlProductionRecordMutation,\n useCreateHealthyBowlSoilTestMutation,\n useUpdateHealthyBowlSoilTestMutation,\n useDeleteHealthyBowlSoilTestMutation,\n useCreateHealthyBowlPestIssueMutation,\n useDeleteHealthyBowlPestIssueMutation,\n useCreateHealthyBowlTreatmentMutation,\n useUpdateHealthyBowlTreatmentMutation,\n useDeleteHealthyBowlTreatmentMutation,\n useDeleteHealthyBowlBudgetMutation,\n useDeleteHealthyBowlInvoiceMutation,\n useDeleteHealthyBowlAuditMutation,\n useCreateHealthyBowlRecipeMutation,\n useUpdateHealthyBowlRecipeMutation,\n useDeleteHealthyBowlRecipeMutation,\n useCreateHealthyBowlBudgetMutation,\n useCreateHealthyBowlInvoiceMutation,\n useCreateHealthyBowlAuditMutation,\n useCreateHealthyBowlTraceBatchMutation,\n useUpdateHealthyBowlTraceBatchMutation,\n useRecallHealthyBowlTraceBatchMutation,\n useDeleteHealthyBowlTraceBatchMutation,\n useUpdateHealthyBowlCertificationMutation,\n useDeleteHealthyBowlCertificationMutation,\n useUpdateHealthyBowlComplianceDocumentMutation,\n useDeleteHealthyBowlComplianceDocumentMutation,\n useUpdateHealthyBowlFarmEventMutation,\n useDeleteHealthyBowlFarmEventMutation,\n useCreateHealthyBowlCommunityPostMutation,\n useCreateHealthyBowlExpertMutation,\n useUpdateHealthyBowlExpertMutation,\n useDeleteHealthyBowlExpertMutation,\n useCreateHealthyBowlMentorMutation,\n useUpdateHealthyBowlMentorMutation,\n useDeleteHealthyBowlMentorMutation,\n useCreateHealthyBowlGovernmentSchemeMutation,\n useUpdateHealthyBowlGovernmentSchemeMutation,\n useDeleteHealthyBowlGovernmentSchemeMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateFarmInput,\n UpdateFarmInput,\n CreateCropInput,\n UpdateCropInput,\n CreateAnimalInput,\n UpdateAnimalInput,\n CreateHealthyBowlFieldInput,\n UpdateHealthyBowlFieldInput,\n GrowLocationType as GqlGrowLocationType,\n CreateMarketplaceProductInput,\n UpdateMarketplaceProductInput,\n CreateHealthyBowlTransactionInput,\n UpdateHealthyBowlTransactionInput,\n CreatePlantingPlanInput,\n CreateHarvestRecordInput,\n CreateHealthRecordInput,\n CreateFeedRecordInput,\n CreateVaccinationInput,\n CreateBreedingRecordInput,\n CreateProductionRecordInput,\n CreateSoilTestInput,\n UpdateSoilTestInput,\n CreatePestIssueInput,\n CreateTreatmentInput,\n UpdateTreatmentInput,\n CreateRecipeInput,\n UpdateRecipeInput,\n CreateBudgetInput,\n CreateInvoiceInput,\n CreateAuditInput,\n CreateTraceBatchInput,\n UpdateTraceBatchInput,\n UpdateCertificationInput,\n UpdateComplianceDocumentInput,\n UpdateFarmEventInput,\n CreateCommunityPostInput,\n CreateExpertInput,\n UpdateExpertInput,\n CreateMentorInput,\n UpdateMentorInput,\n CreateGovernmentSchemeInput,\n UpdateGovernmentSchemeInput,\n} from '../../generated/wspace-types';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport { HEALTHYBOWL_FALLBACK_WORKSPACE_ID, useHealthyBowl } from '../context/HealthyBowlContext';\nimport { emitCropCreated, emitCropUpdated, emitFarmCreated, emitHarvestRecorded } from '../events/rybbit';\nimport type {\n Alert,\n AnalyticsKPI,\n AnalyticsReport,\n Animal,\n Audit,\n BreedingRecord,\n Budget,\n Certification,\n CommunityPost,\n ComplianceDocument,\n Consultation,\n ConsultantType,\n ConsultationMode,\n ConsultationStatus,\n Crop,\n DashboardStats,\n Expert,\n Farm,\n FarmEvent,\n FeedRecord,\n Field,\n GovernmentScheme,\n HarvestRecord,\n HealthRecord,\n Invoice,\n MarketplaceProduct,\n Mentor,\n Order,\n PestIssue,\n PlantingPlan,\n ProductionBatch,\n ProductionRecord,\n Product,\n Recipe,\n SchemeApplication,\n SoilTest,\n TraceBatch,\n TrainingProgram,\n Transaction,\n Treatment,\n Vaccination,\n WeatherData,\n} from '../types';\nimport type { GrowLocationType } from '../utils/growLocationType';\n\n// A field's grow-location type is re-declared as the plain string union the UI\n// works in (`utils/growLocationType`) rather than codegen's `GrowLocationType`,\n// which is a TypeScript string *enum* and so refuses a raw string literal even\n// though the values are identical. Swapping it here means one cast at the\n// mutation boundary instead of one at every call site.\nexport type CreateFieldInput = Omit<CreateHealthyBowlFieldInput, 'context' | 'type'> & {\n type?: GrowLocationType | null;\n};\nexport type UpdateFieldInput = Omit<UpdateHealthyBowlFieldInput, 'context' | 'type'> & {\n type?: GrowLocationType | null;\n};\n\n// --- Record update/delete (wired via raw gql documents: these mutations are not\n// yet in the pulled microfe schema, so codegen hooks don't exist for them offline.\n// A later `schema:pull` + `codegen` can replace these with generated hooks.) ---\ntype HBContext = { workspaceId: string };\ntype HealthyBowlCropsDataQueryResult = {\n getHealthyBowlCropsData: {\n crops: Crop[];\n fields: Field[];\n plantingPlans: PlantingPlan[];\n harvests: HarvestRecord[];\n updatedAt: string;\n };\n};\ntype HealthyBowlWeatherDataQueryResult = {\n getHealthyBowlWeatherData: {\n weather: WeatherData;\n dailyHistory: WeatherHistoryRecord[];\n monthlySummaries: WeatherMonthlySummary[];\n updatedAt: string;\n };\n};\n\nconst GET_HEALTHYBOWL_CROPS_DATA_DOC = gql`\n query GetHealthyBowlCropsDataWithBoundaryAndPlanIds($context: ContextInput!) {\n getHealthyBowlCropsData(context: $context) {\n crops {\n id\n name\n variety\n category\n season\n plantingDate\n expectedHarvestDate\n status\n growthStage\n healthStatus\n yieldEstimate\n yieldUnit\n yieldEstimateSource\n yieldEstimateAt\n healthScore\n healthScoreSource\n healthScoreAt\n organicCertified\n daysToHarvest\n progress\n field\n fieldName\n imageIds\n entityTags {\n id\n key\n label\n color\n vocabularyKey\n }\n }\n fields {\n id\n name\n area\n unit\n soilType\n irrigationType\n organicCertified\n status\n type\n crops\n location\n boundary\n imageIds\n growGeometry\n }\n plantingPlans {\n id\n cropId\n fieldId\n season\n startDate\n endDate\n status\n priority\n fieldName\n cropName\n expectedYield\n seedRequired\n weatherRisk\n fertilizers\n plantsNeeded\n seedGrams\n seedlingsToRaise\n }\n harvests {\n id\n cropName\n fieldName\n quantity\n unit\n qualityGrade\n status\n harvestDate\n pricePerUnit\n storageLocation\n # BOFF-6095 — set once the harvest has been banked into inventory. Drives whether the\n # harvest page offers \"Add to inventory\" or reports that it is already stock.\n productId\n # BOFF-6056 — the plan this harvest counts towards. Selected so the edit modal can show\n # the current link rather than defaulting the select to \"not linked\".\n plantingPlanId\n }\n updatedAt\n }\n }\n`;\n\nconst GET_HEALTHYBOWL_WEATHER_DATA_DOC = gql`\n query GetHealthyBowlWeatherDataWithCoordinates($context: ContextInput!) {\n getHealthyBowlWeatherData(context: $context) {\n weather {\n location\n latitude\n longitude\n current {\n temperature\n feelsLike\n humidity\n condition\n icon\n windSpeed\n windDirection\n pressure\n uvIndex\n visibility\n }\n forecast {\n date\n high\n low\n condition\n icon\n humidity\n precipitation\n windSpeed\n }\n alerts {\n id\n title\n type\n severity\n description\n startTime\n endTime\n affectedAreas\n }\n }\n dailyHistory {\n id\n date\n condition\n tempMax\n tempMin\n tempAvg\n humidity\n rainfall\n windSpeed\n pressure\n uvIndex\n sunrise\n sunset\n }\n monthlySummaries {\n id\n month\n year\n avgTemp\n avgHumidity\n totalRainfall\n rainyDays\n sunnyDays\n extremeEvents\n }\n updatedAt\n }\n }\n`;\ntype CreateSchemeApplicationInput = {\n schemeId: string;\n schemeName?: string;\n status?: 'draft' | 'submitted';\n amount?: number;\n notes?: string;\n};\ntype UpdateHealthRecordInput = {\n id: string;\n animalId?: string;\n type?: string;\n date?: string;\n diagnosis?: string;\n treatment?: string;\n veterinarian?: string;\n cost?: number;\n status?: string;\n};\ntype UpdateFeedRecordInput = {\n id: string;\n animalId?: string;\n feedType?: string;\n quantity?: number;\n unit?: string;\n cost?: number;\n date?: string;\n notes?: string;\n};\ntype UpdateVaccinationInput = {\n id: string;\n animalId?: string;\n vaccineName?: string;\n date?: string;\n nextDue?: string;\n administeredBy?: string;\n status?: string;\n};\ntype UpdateBreedingRecordInput = {\n id: string;\n animalId?: string;\n mateId?: string;\n matingType?: string;\n matingDate?: string;\n /** The PREDICTED delivery date. */\n expectedDueDate?: string;\n /** The OBSERVED delivery date — send when moving a record to DELIVERED (BOFF-6034). */\n deliveredOn?: string;\n offspringBorn?: number | null;\n /** Must not exceed offspringBorn; the server rejects an inverted pair. */\n offspringLive?: number | null;\n status?: string;\n notes?: string;\n};\ntype UpdateProductionRecordInput = {\n id: string;\n animalId?: string;\n type?: string;\n quantity?: number;\n unit?: string;\n quality?: string;\n date?: string;\n notes?: string;\n};\ntype UpdatePlantingPlanInput = {\n id: string;\n cropId?: string;\n fieldId?: string;\n season?: string;\n startDate?: string;\n endDate?: string;\n expectedYield?: number;\n seedRequired?: number;\n fertilizers?: string[];\n priority?: string;\n weatherRisk?: string;\n status?: string;\n};\ntype UpdateHarvestRecordInput = {\n id: string;\n cropId?: string;\n fieldId?: string;\n quantity?: number;\n unit?: string;\n quality?: string;\n harvestDate?: string;\n pricePerUnit?: number;\n storageLocation?: string;\n status?: string;\n};\ntype CreateHealthyBowlProductInput = {\n name: string;\n sku: string;\n category: string;\n price: number;\n unit: string;\n stock: number;\n minStock?: number;\n status?: string;\n organicCertified?: boolean;\n shelfLife: number;\n batchNumber?: string;\n /** GS1 AI (01) GTIN (BOFF-5729). Empty string clears it server-side. */\n gs1Gtin?: string;\n};\ntype UpdateHealthyBowlProductInput = {\n id: string;\n name?: string;\n sku?: string;\n category?: string;\n price?: number;\n unit?: string;\n stock?: number;\n minStock?: number;\n status?: string;\n organicCertified?: boolean;\n shelfLife?: number;\n batchNumber?: string;\n /** GS1 AI (01) GTIN (BOFF-5729). Empty string CLEARS it — see readGtinInput server-side. */\n gs1Gtin?: string;\n};\n/**\n * A finished-goods stock adjustment (BOFF-6371).\n *\n * Send the delta, never an absolute stock figure: the server applies it atomically and\n * re-derives `status`, so two operators adjusting at once no longer overwrite each other.\n * An OUT larger than the stock on hand is REJECTED, not clamped — clamping would leave\n * the ledger unable to reconcile with the stock column.\n */\ntype AdjustHealthyBowlProductStockInput = {\n productId: string;\n /** IN | OUT */\n direction: 'IN' | 'OUT';\n /** Positive whole number — `Product.stock` is an integer column. */\n quantity: number;\n unit?: string;\n /** HARVEST | RECEIPT | SALE | TRANSFER | ADJUSTMENT | SPOILAGE | OTHER. Defaults to ADJUSTMENT. */\n reason?: string;\n orderId?: string;\n reference?: string;\n occurredAt?: string;\n /** Why the stock moved, in the operator's own words. This is what the ledger is for. */\n notes?: string;\n};\ntype CreateFarmEventInput = {\n title: string;\n type: string;\n date: string;\n location: string;\n description: string;\n organizer: string;\n capacity?: number;\n mode: string;\n fee?: number;\n};\ntype CreateMarketplaceOrderInput = {\n buyerId: string;\n items: Array<{\n // Omitted by callers: the server derives a stable line-item id from the order + productId.\n // (Sending the Zustand cart-entry id would leak a local, ephemeral identifier.)\n id?: string;\n productId: string;\n productName: string;\n quantity: number;\n price: number;\n unit: string;\n seller: string;\n }>;\n subtotal?: number;\n tax?: number;\n shipping?: number;\n total: number;\n // BOFF-6090: a promo CODE, never a discount amount — the server validates it against\n // global-store and computes discountAmount itself; a client-supplied number is never trusted.\n promoCode?: string;\n deliveryDate?: string;\n};\ntype UpdateMarketplaceOrderInput = {\n id: string;\n // Lifecycle: pending | confirmed | shipped | delivered | cancelled (validated server-side).\n status?: string;\n // Payment: pending | paid | refunded (validated server-side).\n paymentStatus?: string;\n deliveryDate?: string;\n};\ntype CreateComplianceDocumentInput = {\n title: string;\n type: string;\n status?: string;\n fileUrl?: string;\n fileId?: string;\n fileName?: string;\n certificationId?: string;\n};\ntype CreateCertificationInput = {\n name: string;\n standard: string;\n certifyingBody: string;\n issuedDate: string;\n expiryDate: string;\n status?: string;\n scope?: string[];\n};\ntype CreateProductionBatchInput = {\n batchNumber: string;\n productId?: string;\n recipeId?: string;\n status?: string;\n quantity: number;\n unit: string;\n startDate: string;\n completionDate?: string;\n qualityScore?: number;\n cost?: number;\n};\ntype CreateConsultationInput = {\n consultantType: ConsultantType;\n consultantId: string;\n consultantName: string;\n topic: string;\n requestedDate: string;\n mode: ConsultationMode;\n notes?: string;\n fee?: number;\n /**\n * BOFF-6081 — link the booking back to an AI plant scan (the INCONCLUSIVE\n * hand-off). The scan's context is stamped with the created consultation id.\n */\n plantScanId?: string;\n};\ntype UpdatePestIssueInput = {\n id: string;\n pestName?: string;\n type?: string;\n cropAffected?: string;\n severity?: string;\n status?: PestIssue['status'];\n detectedDate?: string;\n treatment?: string;\n};\n\nconst UPDATE_PEST_ISSUE_DOC = gql`\n mutation UpdateHealthyBowlPestIssue($input: UpdatePestIssueInput!) {\n updateHealthyBowlPestIssue(input: $input) {\n id\n }\n }\n`;\ntype UpdateAuditInput = {\n id: string;\n title?: string;\n type?: 'internal' | 'external' | 'certification';\n auditor?: string;\n scheduledDate?: string;\n completedDate?: string;\n status?: 'scheduled' | 'in_progress' | 'completed' | 'failed';\n findings?: number;\n criticalFindings?: number;\n score?: number;\n};\n\nconst UPDATE_AUDIT_DOC = gql`\n mutation UpdateHealthyBowlAudit($input: UpdateAuditInput!) {\n updateHealthyBowlAudit(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_HEALTH_RECORD_DOC = gql`\n mutation UpdateHealthyBowlHealthRecord($input: UpdateHealthRecordInput!) {\n updateHealthyBowlHealthRecord(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_FEED_RECORD_DOC = gql`\n mutation UpdateHealthyBowlFeedRecord($input: UpdateFeedRecordInput!) {\n updateHealthyBowlFeedRecord(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_VACCINATION_DOC = gql`\n mutation UpdateHealthyBowlVaccination($input: UpdateVaccinationInput!) {\n updateHealthyBowlVaccination(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_BREEDING_RECORD_DOC = gql`\n mutation UpdateHealthyBowlBreedingRecord($input: UpdateBreedingRecordInput!) {\n updateHealthyBowlBreedingRecord(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_PRODUCTION_RECORD_DOC = gql`\n mutation UpdateHealthyBowlProductionRecord($input: UpdateProductionRecordInput!) {\n updateHealthyBowlProductionRecord(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_PLANTING_PLAN_DOC = gql`\n mutation UpdateHealthyBowlPlantingPlan($input: UpdatePlantingPlanInput!) {\n updateHealthyBowlPlantingPlan(input: $input) {\n id\n cropId\n fieldId\n }\n }\n`;\nconst DELETE_PLANTING_PLAN_DOC = gql`\n mutation DeleteHealthyBowlPlantingPlan($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlPlantingPlan(id: $id, context: $context)\n }\n`;\nconst UPDATE_HARVEST_RECORD_DOC = gql`\n mutation UpdateHealthyBowlHarvestRecord($input: UpdateHarvestRecordInput!) {\n updateHealthyBowlHarvestRecord(input: $input) {\n id\n }\n }\n`;\nconst DELETE_HARVEST_RECORD_DOC = gql`\n mutation DeleteHealthyBowlHarvestRecord($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlHarvestRecord(id: $id, context: $context)\n }\n`;\nconst DELETE_VACCINATION_DOC = gql`\n mutation DeleteHealthyBowlVaccination($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlVaccination(id: $id, context: $context)\n }\n`;\nconst DELETE_HEALTH_RECORD_DOC = gql`\n mutation DeleteHealthyBowlHealthRecord($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlHealthRecord(id: $id, context: $context)\n }\n`;\nconst DELETE_FEED_RECORD_DOC = gql`\n mutation DeleteHealthyBowlFeedRecord($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlFeedRecord(id: $id, context: $context)\n }\n`;\nconst DELETE_BREEDING_RECORD_DOC = gql`\n mutation DeleteHealthyBowlBreedingRecord($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlBreedingRecord(id: $id, context: $context)\n }\n`;\nconst DELETE_PRODUCTION_RECORD_DOC = gql`\n mutation DeleteHealthyBowlProductionRecord($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlProductionRecord(id: $id, context: $context)\n }\n`;\nconst CREATE_PRODUCT_DOC = gql`\n mutation CreateHealthyBowlProduct($input: CreateHealthyBowlProductInput!) {\n createHealthyBowlProduct(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_PRODUCT_DOC = gql`\n mutation UpdateHealthyBowlProduct($input: UpdateHealthyBowlProductInput!) {\n updateHealthyBowlProduct(input: $input) {\n id\n }\n }\n`;\nconst DELETE_PRODUCT_DOC = gql`\n mutation DeleteHealthyBowlProduct($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlProduct(id: $id, context: $context)\n }\n`;\nconst ADJUST_PRODUCT_STOCK_DOC = gql`\n mutation AdjustHealthyBowlProductStock($input: AdjustHealthyBowlProductStockInput!) {\n adjustHealthyBowlProductStock(input: $input) {\n id\n productId\n direction\n quantity\n unit\n reason\n notes\n occurredAt\n }\n }\n`;\nconst CREATE_CONSULTATION_DOC = gql`\n mutation CreateHealthyBowlConsultation($input: CreateConsultationInput!) {\n createHealthyBowlConsultation(input: $input) {\n id\n consultantType\n consultantId\n consultantName\n topic\n requestedDate\n mode\n notes\n fee\n status\n # NO payment fields. BOFF-6030 shipped this UI to main on 2026-09-02 (#328) without its\n # backend half: type Consultation in wspace-healthybowl-svc has no paymentStatus /\n # paymentProvider / paymentReference / paidAmount / paidAt, and PRs #248 and #249 are closed\n # unmerged. A validation error rejects the WHOLE query, so selecting them took six prod pages\n # down for 38 minutes on 2026-09-18 and forced the BOFF-7341 repin to be rolled back.\n # Restore them together with the backend fields, not before.\n createdAt\n }\n }\n`;\nconst GET_CONSULTATIONS_DOC = gql`\n query GetHealthyBowlConsultations($context: ContextInput!) {\n getHealthyBowlConsultations(context: $context) {\n id\n consultantType\n consultantId\n consultantName\n topic\n requestedDate\n mode\n notes\n fee\n status\n # NO payment fields. BOFF-6030 shipped this UI to main on 2026-09-02 (#328) without its\n # backend half: type Consultation in wspace-healthybowl-svc has no paymentStatus /\n # paymentProvider / paymentReference / paidAmount / paidAt, and PRs #248 and #249 are closed\n # unmerged. A validation error rejects the WHOLE query, so selecting them took six prod pages\n # down for 38 minutes on 2026-09-18 and forced the BOFF-7341 repin to be rolled back.\n # Restore them together with the backend fields, not before.\n createdAt\n }\n }\n`;\n\ntype UpdateConsultationStatusInput = {\n id: string;\n status: ConsultationStatus;\n};\n\nconst UPDATE_CONSULTATION_STATUS_DOC = gql`\n mutation UpdateHealthyBowlConsultationStatus($input: UpdateHealthyBowlConsultationStatusInput!) {\n updateHealthyBowlConsultationStatus(input: $input) {\n id\n consultantType\n consultantId\n consultantName\n topic\n requestedDate\n mode\n notes\n fee\n status\n # NO payment fields. BOFF-6030 shipped this UI to main on 2026-09-02 (#328) without its\n # backend half: type Consultation in wspace-healthybowl-svc has no paymentStatus /\n # paymentProvider / paymentReference / paidAmount / paidAt, and PRs #248 and #249 are closed\n # unmerged. A validation error rejects the WHOLE query, so selecting them took six prod pages\n # down for 38 minutes on 2026-09-18 and forced the BOFF-7341 repin to be rolled back.\n # Restore them together with the backend fields, not before.\n createdAt\n }\n }\n`;\n\nconst CREATE_FARM_EVENT_DOC = gql`\n mutation CreateHealthyBowlFarmEvent($input: CreateFarmEventInput!) {\n createHealthyBowlFarmEvent(input: $input) {\n id\n title\n date\n }\n }\n`;\nconst CREATE_ORDER_DOC = gql`\n mutation CreateHealthyBowlOrder($input: CreateMarketplaceOrderInput!) {\n createHealthyBowlOrder(input: $input) {\n id\n orderNumber\n status\n paymentStatus\n total\n # BOFF-6090: the server-computed discount actually applied (0 when no code was used).\n discountAmount\n }\n }\n`;\nconst UPDATE_ORDER_DOC = gql`\n mutation UpdateHealthyBowlOrder($input: UpdateMarketplaceOrderInput!) {\n updateHealthyBowlOrder(input: $input) {\n id\n orderNumber\n status\n paymentStatus\n deliveryDate\n total\n }\n }\n`;\nconst CREATE_COMPLIANCE_DOCUMENT_DOC = gql`\n mutation CreateHealthyBowlComplianceDocument($input: CreateComplianceDocumentInput!) {\n createHealthyBowlComplianceDocument(input: $input) {\n id\n name\n status\n }\n }\n`;\nconst CREATE_CERTIFICATION_DOC = gql`\n mutation CreateHealthyBowlCertification($input: CreateCertificationInput!) {\n createHealthyBowlCertification(input: $input) {\n id\n name\n status\n }\n }\n`;\nconst CREATE_PRODUCTION_BATCH_DOC = gql`\n mutation CreateHealthyBowlProductionBatch($input: CreateProductionBatchInput!) {\n createHealthyBowlProductionBatch(input: $input) {\n id\n batchNumber\n status\n }\n }\n`;\n\nconst UPDATE_BUDGET_DOC = gql`\n mutation UpdateHealthyBowlBudget($input: UpdateBudgetInput!) {\n updateHealthyBowlBudget(input: $input) {\n id\n name\n category\n period\n allocated\n spent\n remaining\n status\n }\n }\n`;\n\nconst UPDATE_INVOICE_DOC = gql`\n mutation UpdateHealthyBowlInvoice($input: UpdateInvoiceInput!) {\n updateHealthyBowlInvoice(input: $input) {\n id\n invoiceNumber\n customer\n status\n subtotal\n tax\n total\n }\n }\n`;\n\ntype UpdateBudgetFields = {\n id: string;\n name?: string;\n category?: string;\n period?: string;\n allocated?: number;\n spent?: number;\n status?: string;\n};\n\ntype UpdateInvoiceFields = {\n id: string;\n customer?: string;\n amount?: number;\n dueDate?: string;\n tax?: number;\n status?: string;\n};\n\ntype RevenueChartPoint = { month: string; revenue: number; expenses: number };\ntype CropDistributionPoint = { name: string; value: number; color: string };\ntype YieldTrendPoint = { month: string; tomatoes: number; peppers: number; lettuce: number; basil: number };\ntype GovernmentMessage = {\n id: string;\n from: string;\n department: string;\n subject: string;\n preview: string;\n body: string;\n date: string;\n unread: boolean;\n};\ntype GovernmentAnnouncement = {\n id: string;\n title: string;\n date: string;\n category: string;\n content: string;\n};\ntype GovernmentNotification = {\n id: string;\n title: string;\n description: string;\n date: string;\n type: 'scheme_update' | 'status_change' | 'deadline' | 'new_scheme';\n read: boolean;\n};\ntype GovernmentActivityItem = {\n id: string;\n type: 'submitted' | 'status_change' | 'new_scheme' | 'disbursement' | 'deadline';\n title: string;\n description: string;\n date: string;\n};\ntype BenefitsChartPoint = { month: string; amount: number };\ntype EventAgendaItem = { time: string; session: string };\ntype WeatherHistoryRecord = {\n id: string;\n date: string;\n tempMax: number;\n tempMin: number;\n tempAvg: number;\n humidity: number;\n rainfall: number;\n windSpeed: number;\n condition: 'sunny' | 'cloudy' | 'rainy' | 'stormy';\n sunrise: string;\n sunset: string;\n uvIndex: number;\n pressure: number;\n};\ntype WeatherMonthlySummary = {\n id: string;\n month: string;\n year: number;\n avgTemp: number;\n totalRainfall: number;\n rainyDays: number;\n sunnyDays: number;\n avgHumidity: number;\n extremeEvents: number;\n};\ntype FarmInsight = {\n id: string;\n title: string;\n description: string;\n confidence: number;\n category: string;\n action: string;\n};\ntype SoilSensorReading = {\n fieldId: string;\n fieldName: string;\n moisture: number;\n temperature: number;\n moistureThreshold: number;\n tempThreshold: number;\n lastUpdated: string;\n};\n\n/**\n * Arguments for `createHarvestRecord`.\n *\n * The four I-8 linkage fields (`addToInventory`, `productCategory`, `plantingPlanId`, `bedId`) were\n * once re-declared here, because the local `CreateHarvestRecordInput` lagged the deployed schema and\n * did not carry them (BOFF-6095). It did not lag — codegen had simply never run successfully on the\n * machine, and could not: `node_modules` had escaped into a parent store holding a second copy of\n * `graphql`. With that fixed the generated input carries all four, so the hand-widening for them is\n * gone (BOFF-6209).\n *\n * `clientMutationId` (BOFF-6094) is re-declared here for the same reason those four once were: it is\n * a real, gateway-accepted field on `createHealthyBowlHarvestRecord` as of this change, but the local\n * generated `CreateHarvestRecordInput` won't carry it until the next `schema:pull`. Drop this\n * intersection once that runs and the generated type includes it natively.\n *\n * The alias is kept because three call sites use it.\n */\n/**\n * Update args widened past the generated input (BOFF-6056).\n *\n * `plantingPlanId` is newer than the committed `graphql/wspace.graphql` snapshot codegen validates\n * against, so the generated `UpdateHarvestRecordInput` does not carry it yet. Same escape hatch as\n * `HarvestRecordCreateArgs` below; drop the widening once the snapshot is re-pulled post-merge.\n */\nexport type HarvestRecordUpdateArgs = UpdateHarvestRecordInput & {\n /**\n * Attach a banked harvest to the plan it came from, so plan-vs-actual counts it.\n *\n * Three states, and the type has to permit all three: absent leaves an existing link alone,\n * `null` detaches it, an id attaches it. Typing this `string | undefined` would make the detach\n * unrepresentable and the UI's \"Not linked to a plan\" option a no-op.\n */\n plantingPlanId?: string | null;\n};\n\nexport type HarvestRecordCreateArgs = Omit<CreateHarvestRecordInput, 'context'> & {\n /**\n * Client-generated idempotency key (BOFF-6094). A retried/duplicate submit of the\n * same key — a double-click, a dropped-response retry — returns the original\n * harvest instead of recording (and banking) it a second time. Mint one per\n * harvest-recording attempt with `crypto.randomUUID()`.\n */\n clientMutationId?: string;\n};\n\nexport interface HealthyBowlDataBundle {\n alerts: Alert[];\n analyticsKPIs: AnalyticsKPI[];\n crops: Crop[];\n dashboardStats: DashboardStats;\n dailyHistory: WeatherHistoryRecord[];\n fields: Field[];\n farm: Farm;\n harvests: HarvestRecord[];\n invoices: Invoice[];\n monthlySummaries: WeatherMonthlySummary[];\n plantingPlans: PlantingPlan[];\n productionBatches: ProductionBatch[];\n products: Product[];\n revenueChartData: RevenueChartPoint[];\n recipes: Recipe[];\n sensorReadings: SoilSensorReading[];\n soilTests: SoilTest[];\n traceBatches: TraceBatch[];\n transactions: Transaction[];\n weatherData: WeatherData;\n budgets: Budget[];\n governmentSchemes: GovernmentScheme[];\n messages: GovernmentMessage[];\n marketplaceProducts: MarketplaceProduct[];\n notifications: GovernmentNotification[];\n orders: Order[];\n benefitsChart: BenefitsChartPoint[];\n activity: GovernmentActivityItem[];\n announcements: GovernmentAnnouncement[];\n animals: Animal[];\n breedingRecords: BreedingRecord[];\n feedRecords: FeedRecord[];\n healthRecords: HealthRecord[];\n productionRecords: ProductionRecord[];\n /**\n * Records still held in the workspace whose animal has left the herd. Every\n * livestock list is scoped to animals still present (BOFF-6009), so removing an\n * animal silently drops its rows from every total; this is the number that lets\n * the UI say so instead of leaving the farmer to guess.\n */\n recordsForRemovedAnimals: number;\n schemeApplications: SchemeApplication[];\n trainingPrograms: TrainingProgram[];\n vaccinations: Vaccination[];\n analyticsReports: AnalyticsReport[];\n cropDistributionData: CropDistributionPoint[];\n yieldTrendData: YieldTrendPoint[];\n insights: FarmInsight[];\n audits: Audit[];\n certifications: Certification[];\n complianceDocuments: ComplianceDocument[];\n communityPosts: CommunityPost[];\n events: FarmEvent[];\n experts: Expert[];\n mentors: Mentor[];\n agenda: EventAgendaItem[];\n consultations: Consultation[];\n pestIssues: PestIssue[];\n treatments: Treatment[];\n loading: boolean;\n error: Error | null;\n // Per-domain query errors, so a page can show an honest error state for ITS data instead of\n // masking a failed query as an empty state. (The aggregate `error` above is any-slice-failed.)\n errors: {\n government: Error | null;\n weather: Error | null;\n analytics: Error | null;\n network: Error | null;\n soil: Error | null;\n dashboard: Error | null;\n crops: Error | null;\n livestock: Error | null;\n financial: Error | null;\n marketplace: Error | null;\n production: Error | null;\n products: Error | null;\n traceability: Error | null;\n compliance: Error | null;\n pest: Error | null;\n };\n // Per-domain loading flags, so a page gates its loader on ITS OWN slice\n // instead of the aggregate `loading` above (which ORs every query and would\n // over-eagerly spinner a page while an unrelated slice is still fetching).\n loadings: {\n government: boolean;\n weather: boolean;\n analytics: boolean;\n network: boolean;\n soil: boolean;\n dashboard: boolean;\n crops: boolean;\n livestock: boolean;\n financial: boolean;\n marketplace: boolean;\n production: boolean;\n products: boolean;\n traceability: boolean;\n compliance: boolean;\n pest: boolean;\n };\n refetch: () => Promise<unknown>;\n /** Refresh just the trace-batch list (after a publish/unpublish) without refetching everything. */\n refetchTraceabilityData: () => Promise<unknown>;\n markAlertRead: (alertId: string, read?: boolean) => Promise<boolean>;\n /**\n * BOFF-6112 — persist government-notification read-state.\n *\n * Bulk by design: \"mark all read\" is the common action, and one call per notification leaves a\n * half-applied state visible if the network drops mid-way.\n */\n markGovernmentNotificationRead: (notificationIds: string[], read?: boolean) => Promise<number>;\n // CRUD mutations\n createCrop: (input: Omit<CreateCropInput, 'context'>) => Promise<unknown>;\n updateCrop: (input: Omit<UpdateCropInput, 'context'>) => Promise<unknown>;\n deleteCrop: (id: string) => Promise<boolean>;\n createAnimal: (input: Omit<CreateAnimalInput, 'context'>) => Promise<unknown>;\n updateAnimal: (input: Omit<UpdateAnimalInput, 'context'>) => Promise<unknown>;\n deleteAnimal: (id: string) => Promise<boolean>;\n createFarm: (input: Omit<CreateFarmInput, 'context'>) => Promise<unknown>;\n updateFarm: (input: Omit<UpdateFarmInput, 'context'>) => Promise<unknown>;\n createField: (input: CreateFieldInput) => Promise<unknown>;\n updateField: (input: UpdateFieldInput) => Promise<unknown>;\n deleteField: (id: string) => Promise<boolean>;\n createMarketplaceProduct: (input: Omit<CreateMarketplaceProductInput, 'context'>) => Promise<unknown>;\n updateMarketplaceProduct: (input: Omit<UpdateMarketplaceProductInput, 'context'>) => Promise<unknown>;\n deleteMarketplaceProduct: (id: string) => Promise<boolean>;\n createTransaction: (input: Omit<CreateHealthyBowlTransactionInput, 'context'>) => Promise<unknown>;\n updateTransaction: (input: Omit<UpdateHealthyBowlTransactionInput, 'context'>) => Promise<unknown>;\n deleteTransaction: (id: string) => Promise<boolean>;\n /** Resolve a fresh, short-lived Files-authorized URL for a persisted transaction receipt. */\n getTransactionReceiptUrl: (transactionId: string) => Promise<string>;\n createPlantingPlan: (input: Omit<CreatePlantingPlanInput, 'context'>) => Promise<unknown>;\n createHarvestRecord: (input: HarvestRecordCreateArgs) => Promise<unknown>;\n createHealthRecord: (input: Omit<CreateHealthRecordInput, 'context'>) => Promise<unknown>;\n createFeedRecord: (input: Omit<CreateFeedRecordInput, 'context'>) => Promise<unknown>;\n createVaccination: (input: Omit<CreateVaccinationInput, 'context'>) => Promise<unknown>;\n createBreedingRecord: (input: Omit<CreateBreedingRecordInput, 'context'>) => Promise<unknown>;\n createProductionRecord: (input: Omit<CreateProductionRecordInput, 'context'>) => Promise<unknown>;\n updateHealthRecord: (input: UpdateHealthRecordInput) => Promise<unknown>;\n updateFeedRecord: (input: UpdateFeedRecordInput) => Promise<unknown>;\n updateVaccination: (input: UpdateVaccinationInput) => Promise<unknown>;\n updateBreedingRecord: (input: UpdateBreedingRecordInput) => Promise<unknown>;\n updateProductionRecord: (input: UpdateProductionRecordInput) => Promise<unknown>;\n updatePlantingPlan: (input: UpdatePlantingPlanInput) => Promise<unknown>;\n deletePlantingPlan: (id: string) => Promise<boolean>;\n updateHarvestRecord: (input: HarvestRecordUpdateArgs) => Promise<unknown>;\n deleteHarvestRecord: (id: string) => Promise<boolean>;\n deleteVaccination: (id: string) => Promise<boolean>;\n deleteHealthRecord: (id: string) => Promise<boolean>;\n deleteFeedRecord: (id: string) => Promise<boolean>;\n deleteBreedingRecord: (id: string) => Promise<boolean>;\n deleteProductionRecord: (id: string) => Promise<boolean>;\n createProduct: (input: CreateHealthyBowlProductInput) => Promise<unknown>;\n updateProduct: (input: UpdateHealthyBowlProductInput) => Promise<unknown>;\n /** Apply a stock delta through the movement ledger (BOFF-6371) — never write `stock` directly. */\n adjustProductStock: (input: AdjustHealthyBowlProductStockInput) => Promise<unknown>;\n deleteProduct: (id: string) => Promise<boolean>;\n createFarmEvent: (input: CreateFarmEventInput) => Promise<unknown>;\n updateFarmEvent: (input: Omit<UpdateFarmEventInput, 'context'>) => Promise<unknown>;\n deleteFarmEvent: (id: string) => Promise<boolean>;\n createOrder: (input: CreateMarketplaceOrderInput) => Promise<unknown>;\n updateOrder: (input: UpdateMarketplaceOrderInput) => Promise<unknown>;\n createComplianceDocument: (input: CreateComplianceDocumentInput) => Promise<unknown>;\n updateComplianceDocument: (input: Omit<UpdateComplianceDocumentInput, 'context'>) => Promise<unknown>;\n deleteComplianceDocument: (id: string) => Promise<boolean>;\n createCertification: (input: CreateCertificationInput) => Promise<unknown>;\n updateCertification: (input: Omit<UpdateCertificationInput, 'context'>) => Promise<unknown>;\n deleteCertification: (id: string) => Promise<boolean>;\n createProductionBatch: (input: CreateProductionBatchInput) => Promise<unknown>;\n createSoilTest: (input: Omit<CreateSoilTestInput, 'context'>) => Promise<unknown>;\n createPestIssue: (input: Omit<CreatePestIssueInput, 'context'>) => Promise<unknown>;\n updatePestIssue: (input: UpdatePestIssueInput) => Promise<unknown>;\n createTreatment: (input: Omit<CreateTreatmentInput, 'context'>) => Promise<unknown>;\n createRecipe: (input: Omit<CreateRecipeInput, 'context'>) => Promise<unknown>;\n updateRecipe: (input: Omit<UpdateRecipeInput, 'context'>) => Promise<unknown>;\n deleteRecipe: (id: string) => Promise<boolean>;\n createBudget: (input: Omit<CreateBudgetInput, 'context'>) => Promise<unknown>;\n createInvoice: (input: Omit<CreateInvoiceInput, 'context'>) => Promise<unknown>;\n updateBudget: (input: UpdateBudgetFields) => Promise<unknown>;\n updateInvoice: (input: UpdateInvoiceFields) => Promise<unknown>;\n createAudit: (input: Omit<CreateAuditInput, 'context'>) => Promise<unknown>;\n updateAudit: (input: UpdateAuditInput) => Promise<unknown>;\n updateSoilTest: (input: Omit<UpdateSoilTestInput, 'context'>) => Promise<unknown>;\n deleteSoilTest: (id: string) => Promise<boolean>;\n updateTreatment: (input: Omit<UpdateTreatmentInput, 'context'>) => Promise<unknown>;\n deleteTreatment: (id: string) => Promise<boolean>;\n deletePestIssue: (id: string) => Promise<boolean>;\n deleteBudget: (id: string) => Promise<boolean>;\n deleteInvoice: (id: string) => Promise<boolean>;\n deleteAudit: (id: string) => Promise<boolean>;\n createTraceBatch: (input: Omit<CreateTraceBatchInput, 'context'>) => Promise<unknown>;\n updateTraceBatch: (input: Omit<UpdateTraceBatchInput, 'context'>) => Promise<unknown>;\n /** Recall a batch (BOFF-6044): sets RECALLED, unpublishes, and notifies the owner. */\n recallTraceBatch: (id: string, reason?: string) => Promise<unknown>;\n deleteTraceBatch: (id: string) => Promise<boolean>;\n createCommunityPost: (input: Omit<CreateCommunityPostInput, 'context'>) => Promise<unknown>;\n createConsultation: (input: CreateConsultationInput) => Promise<unknown>;\n updateConsultationStatus: (input: UpdateConsultationStatusInput) => Promise<unknown>;\n createExpert: (input: Omit<CreateExpertInput, 'context'>) => Promise<unknown>;\n updateExpert: (input: Omit<UpdateExpertInput, 'context'>) => Promise<unknown>;\n deleteExpert: (id: string) => Promise<boolean>;\n createMentor: (input: Omit<CreateMentorInput, 'context'>) => Promise<unknown>;\n updateMentor: (input: Omit<UpdateMentorInput, 'context'>) => Promise<unknown>;\n deleteMentor: (id: string) => Promise<boolean>;\n createGovernmentScheme: (input: Omit<CreateGovernmentSchemeInput, 'context'>) => Promise<unknown>;\n updateGovernmentScheme: (input: Omit<UpdateGovernmentSchemeInput, 'context'>) => Promise<unknown>;\n deleteGovernmentScheme: (id: string) => Promise<boolean>;\n}\n\nconst EMPTY_DASHBOARD_STATS: DashboardStats = {\n totalRevenue: 0,\n totalExpenses: 0,\n netProfit: 0,\n activeCrops: 0,\n totalFields: 0,\n totalAnimals: 0,\n harvestDue: 0,\n pendingOrders: 0,\n weatherAlerts: 0,\n organicScore: 0,\n};\n\nconst EMPTY_FARM: Farm = {\n id: '',\n name: '',\n location: '',\n totalArea: 0,\n areaUnit: 'acres',\n organicCertified: false,\n owner: '',\n imageIds: [],\n};\n\nconst EMPTY_WEATHER: WeatherData = {\n location: '',\n current: {\n temperature: 0,\n humidity: 0,\n windSpeed: 0,\n windDirection: '',\n condition: '',\n icon: '',\n feelsLike: 0,\n uvIndex: 0,\n visibility: 0,\n pressure: 0,\n },\n forecast: [],\n alerts: [],\n};\n\nfunction readQueryArray<T>(value: unknown, fallback: T[]): T[] {\n return Array.isArray(value) ? (value as T[]) : fallback;\n}\n\nfunction readQueryValue<T>(value: unknown, fallback: T): T {\n return value === undefined || value === null ? fallback : (value as T);\n}\n\nexport function useHealthyBowlData(): HealthyBowlDataBundle {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || HEALTHYBOWL_FALLBACK_WORKSPACE_ID;\n\n const {\n data: governmentData,\n loading: governmentLoading,\n error: governmentError,\n refetch: refetchGovernmentData,\n } = useGetHealthyBowlGovernmentDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n // Fetch the full curated scheme catalog so the discovery page can filter and\n // sort client-side (the backend caps unbounded reads at 200 by default).\n limit: 1000,\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: analyticsData,\n loading: analyticsLoading,\n error: analyticsError,\n refetch: refetchAnalyticsData,\n } = useGetHealthyBowlAnalyticsDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: weatherData,\n loading: weatherLoading,\n error: weatherError,\n refetch: refetchWeatherData,\n } = useQuery<HealthyBowlWeatherDataQueryResult, { context: HBContext }>(GET_HEALTHYBOWL_WEATHER_DATA_DOC, {\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: networkData,\n loading: networkLoading,\n error: networkError,\n refetch: refetchNetworkData,\n } = useGetHealthyBowlNetworkDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n // Consultations query is not yet in the pulled microfe schema (no codegen hook\n // offline), so it is wired via a raw gql document. A later `schema:pull` +\n // `codegen` can replace this with a generated hook.\n // errorPolicy:'all' keeps this resilient: until the consultation subgraph (svc #38)\n // is composed into the gateway, a missing-field error degrades to an empty list\n // instead of throwing and breaking every page that mounts this shared hook. It is\n // deliberately NOT folded into the combined `error` below — consultations are an\n // additive, optional feature, not a hard dependency of the dashboard.\n const { data: consultationsData, refetch: refetchConsultations } = useQuery<\n { getHealthyBowlConsultations: Consultation[] },\n { context: HBContext }\n >(GET_CONSULTATIONS_DOC, {\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n errorPolicy: 'all',\n });\n\n const {\n data: soilData,\n loading: soilLoading,\n error: soilError,\n refetch: refetchSoilData,\n } = useGetHealthyBowlSoilDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: dashboardData,\n loading: dashboardLoading,\n error: dashboardError,\n refetch: refetchDashboardData,\n } = useGetHealthyBowlDashboardDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: cropsData,\n loading: cropsLoading,\n error: cropsError,\n refetch: refetchCropsData,\n } = useQuery<HealthyBowlCropsDataQueryResult, { context: HBContext }>(GET_HEALTHYBOWL_CROPS_DATA_DOC, {\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: livestockData,\n loading: livestockLoading,\n error: livestockError,\n refetch: refetchLivestockData,\n } = useGetHealthyBowlLivestockDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: financialData,\n loading: financialLoading,\n error: financialError,\n refetch: refetchFinancialData,\n } = useGetHealthyBowlFinancialDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n const [getTransactionReceiptUrlQuery] = useGetHealthyBowlTransactionReceiptUrlLazyQuery({\n // The response is a short-lived bearer URL. Always hit Files authorization and never retain the\n // URL in Apollo's normalized cache after the caller has opened it.\n fetchPolicy: 'no-cache',\n });\n\n const {\n data: marketplaceData,\n loading: marketplaceLoading,\n error: marketplaceError,\n refetch: refetchMarketplaceData,\n } = useGetHealthyBowlMarketplaceDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: productionData,\n loading: productionLoading,\n error: productionError,\n refetch: refetchProductionData,\n } = useGetHealthyBowlProductionDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: productsData,\n loading: productsLoading,\n error: productsError,\n refetch: refetchProductsData,\n } = useGetHealthyBowlProductsDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: traceabilityData,\n loading: traceabilityLoading,\n error: traceabilityError,\n refetch: refetchTraceabilityData,\n } = useGetHealthyBowlTraceabilityDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: complianceData,\n loading: complianceLoading,\n error: complianceError,\n refetch: refetchComplianceData,\n } = useGetHealthyBowlComplianceDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: pestData,\n loading: pestLoading,\n error: pestError,\n refetch: refetchPestData,\n } = useGetHealthyBowlPestDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const [markAlertReadMutation] = useMarkHealthyBowlAlertReadMutation();\n const [markGovernmentNotificationReadMutation] = useMarkHealthyBowlGovernmentNotificationReadMutation();\n const [createCropMutation] = useCreateHealthyBowlCropMutation();\n const [updateCropMutation] = useUpdateHealthyBowlCropMutation();\n const [deleteCropMutation] = useDeleteHealthyBowlCropMutation();\n const [createAnimalMutation] = useCreateHealthyBowlAnimalMutation();\n const [updateAnimalMutation] = useUpdateHealthyBowlAnimalMutation();\n const [deleteAnimalMutation] = useDeleteHealthyBowlAnimalMutation();\n const [createFarmMutation] = useCreateHealthyBowlFarmMutation();\n const [updateFarmMutation] = useUpdateHealthyBowlFarmMutation();\n const [createFieldMutation] = useCreateHealthyBowlFieldMutation();\n const [updateFieldMutation] = useUpdateHealthyBowlFieldMutation();\n const [deleteFieldMutation] = useDeleteHealthyBowlFieldMutation();\n const [createMarketplaceProductMutation] = useCreateHealthyBowlMarketplaceProductMutation();\n const [updateMarketplaceProductMutation] = useUpdateHealthyBowlMarketplaceProductMutation();\n const [deleteMarketplaceProductMutation] = useDeleteHealthyBowlMarketplaceProductMutation();\n const [createTransactionMutation] = useCreateHealthyBowlTransactionMutation();\n const [updateTransactionMutation] = useUpdateHealthyBowlTransactionMutation();\n const [deleteTransactionMutation] = useDeleteHealthyBowlTransactionMutation();\n const [createPlantingPlanMutation] = useCreateHealthyBowlPlantingPlanMutation();\n const [createHarvestRecordMutation] = useCreateHealthyBowlHarvestRecordMutation();\n const [createHealthRecordMutation] = useCreateHealthyBowlHealthRecordMutation();\n const [createFeedRecordMutation] = useCreateHealthyBowlFeedRecordMutation();\n const [createVaccinationMutation] = useCreateHealthyBowlVaccinationMutation();\n const [createBreedingRecordMutation] = useCreateHealthyBowlBreedingRecordMutation();\n const [createProductionRecordMutation] = useCreateHealthyBowlProductionRecordMutation();\n const [updatePestIssueMutation] = useMutation<\n { updateHealthyBowlPestIssue: { id: string } },\n { input: UpdatePestIssueInput & { context: HBContext } }\n >(UPDATE_PEST_ISSUE_DOC);\n const [updateAuditMutation] = useMutation<\n { updateHealthyBowlAudit: { id: string } },\n { input: UpdateAuditInput & { context: HBContext } }\n >(UPDATE_AUDIT_DOC);\n const [updateHealthRecordMutation] = useMutation<\n { updateHealthyBowlHealthRecord: { id: string } },\n { input: UpdateHealthRecordInput & { context: HBContext } }\n >(UPDATE_HEALTH_RECORD_DOC);\n const [updateFeedRecordMutation] = useMutation<\n { updateHealthyBowlFeedRecord: { id: string } },\n { input: UpdateFeedRecordInput & { context: HBContext } }\n >(UPDATE_FEED_RECORD_DOC);\n const [updateVaccinationMutation] = useMutation<\n { updateHealthyBowlVaccination: { id: string } },\n { input: UpdateVaccinationInput & { context: HBContext } }\n >(UPDATE_VACCINATION_DOC);\n const [updateBreedingRecordMutation] = useMutation<\n { updateHealthyBowlBreedingRecord: { id: string } },\n { input: UpdateBreedingRecordInput & { context: HBContext } }\n >(UPDATE_BREEDING_RECORD_DOC);\n const [updateProductionRecordMutation] = useMutation<\n { updateHealthyBowlProductionRecord: { id: string } },\n { input: UpdateProductionRecordInput & { context: HBContext } }\n >(UPDATE_PRODUCTION_RECORD_DOC);\n const [updatePlantingPlanMutation] = useMutation<\n { updateHealthyBowlPlantingPlan: { id: string } },\n { input: UpdatePlantingPlanInput & { context: HBContext } }\n >(UPDATE_PLANTING_PLAN_DOC);\n const [deletePlantingPlanMutation] = useMutation<\n { deleteHealthyBowlPlantingPlan: boolean },\n { id: string; context: HBContext }\n >(DELETE_PLANTING_PLAN_DOC);\n const [updateHarvestRecordMutation] = useMutation<\n { updateHealthyBowlHarvestRecord: { id: string } },\n { input: UpdateHarvestRecordInput & { context: HBContext } }\n >(UPDATE_HARVEST_RECORD_DOC);\n const [deleteHarvestRecordMutation] = useMutation<\n { deleteHealthyBowlHarvestRecord: boolean },\n { id: string; context: HBContext }\n >(DELETE_HARVEST_RECORD_DOC);\n const [deleteVaccinationMutation] = useMutation<\n { deleteHealthyBowlVaccination: boolean },\n { id: string; context: HBContext }\n >(DELETE_VACCINATION_DOC);\n const [deleteHealthRecordMutation] = useMutation<\n { deleteHealthyBowlHealthRecord: boolean },\n { id: string; context: HBContext }\n >(DELETE_HEALTH_RECORD_DOC);\n const [deleteFeedRecordMutation] = useMutation<\n { deleteHealthyBowlFeedRecord: boolean },\n { id: string; context: HBContext }\n >(DELETE_FEED_RECORD_DOC);\n const [deleteBreedingRecordMutation] = useMutation<\n { deleteHealthyBowlBreedingRecord: boolean },\n { id: string; context: HBContext }\n >(DELETE_BREEDING_RECORD_DOC);\n const [deleteProductionRecordMutation] = useMutation<\n { deleteHealthyBowlProductionRecord: boolean },\n { id: string; context: HBContext }\n >(DELETE_PRODUCTION_RECORD_DOC);\n const [createProductMutation] = useMutation<\n { createHealthyBowlProduct: { id: string } },\n { input: CreateHealthyBowlProductInput & { context: HBContext } }\n >(CREATE_PRODUCT_DOC);\n const [updateProductMutation] = useMutation<\n { updateHealthyBowlProduct: { id: string } },\n { input: UpdateHealthyBowlProductInput & { context: HBContext } }\n >(UPDATE_PRODUCT_DOC);\n const [deleteProductMutation] = useMutation<\n { deleteHealthyBowlProduct: boolean },\n { id: string; context: HBContext }\n >(DELETE_PRODUCT_DOC);\n const [adjustProductStockMutation] = useMutation<\n { adjustHealthyBowlProductStock: { id: string } },\n { input: AdjustHealthyBowlProductStockInput & { context: HBContext } }\n >(ADJUST_PRODUCT_STOCK_DOC);\n const [createFarmEventMutation] = useMutation<\n { createHealthyBowlFarmEvent: { id: string } },\n { input: CreateFarmEventInput & { context: HBContext } }\n >(CREATE_FARM_EVENT_DOC);\n const [createOrderMutation] = useMutation<\n { createHealthyBowlOrder: { id: string } },\n { input: CreateMarketplaceOrderInput & { context: HBContext } }\n >(CREATE_ORDER_DOC);\n const [updateOrderMutation] = useMutation<\n { updateHealthyBowlOrder: { id: string } },\n { input: UpdateMarketplaceOrderInput & { context: HBContext } }\n >(UPDATE_ORDER_DOC);\n const [createComplianceDocumentMutation] = useMutation<\n { createHealthyBowlComplianceDocument: { id: string } },\n { input: CreateComplianceDocumentInput & { context: HBContext } }\n >(CREATE_COMPLIANCE_DOCUMENT_DOC);\n const [createCertificationMutation] = useMutation<\n { createHealthyBowlCertification: { id: string } },\n { input: CreateCertificationInput & { context: HBContext } }\n >(CREATE_CERTIFICATION_DOC);\n const [createProductionBatchMutation] = useMutation<\n { createHealthyBowlProductionBatch: { id: string } },\n { input: CreateProductionBatchInput & { context: HBContext } }\n >(CREATE_PRODUCTION_BATCH_DOC);\n const [createConsultationMutation] = useMutation<\n { createHealthyBowlConsultation: Consultation },\n { input: CreateConsultationInput & { context: HBContext } }\n >(CREATE_CONSULTATION_DOC);\n const [updateConsultationStatusMutation] = useMutation<\n { updateHealthyBowlConsultationStatus: Consultation },\n { input: UpdateConsultationStatusInput & { context: HBContext } }\n >(UPDATE_CONSULTATION_STATUS_DOC);\n const [createSoilTestMutation] = useCreateHealthyBowlSoilTestMutation();\n const [updateSoilTestMutation] = useUpdateHealthyBowlSoilTestMutation();\n const [deleteSoilTestMutation] = useDeleteHealthyBowlSoilTestMutation();\n const [createPestIssueMutation] = useCreateHealthyBowlPestIssueMutation();\n const [deletePestIssueMutation] = useDeleteHealthyBowlPestIssueMutation();\n const [createTreatmentMutation] = useCreateHealthyBowlTreatmentMutation();\n const [updateTreatmentMutation] = useUpdateHealthyBowlTreatmentMutation();\n const [deleteTreatmentMutation] = useDeleteHealthyBowlTreatmentMutation();\n const [deleteBudgetMutation] = useDeleteHealthyBowlBudgetMutation();\n const [deleteInvoiceMutation] = useDeleteHealthyBowlInvoiceMutation();\n const [deleteAuditMutation] = useDeleteHealthyBowlAuditMutation();\n const [createRecipeMutation] = useCreateHealthyBowlRecipeMutation();\n const [updateRecipeMutation] = useUpdateHealthyBowlRecipeMutation();\n const [deleteRecipeMutation] = useDeleteHealthyBowlRecipeMutation();\n const [createBudgetMutation] = useCreateHealthyBowlBudgetMutation();\n const [createInvoiceMutation] = useCreateHealthyBowlInvoiceMutation();\n const [updateBudgetMutation] = useMutation<\n { updateHealthyBowlBudget: { id: string } },\n { input: UpdateBudgetFields & { context: HBContext } }\n >(UPDATE_BUDGET_DOC);\n const [updateInvoiceMutation] = useMutation<\n { updateHealthyBowlInvoice: { id: string } },\n { input: UpdateInvoiceFields & { context: HBContext } }\n >(UPDATE_INVOICE_DOC);\n const [createAuditMutation] = useCreateHealthyBowlAuditMutation();\n const [createTraceBatchMutation] = useCreateHealthyBowlTraceBatchMutation();\n const [updateTraceBatchMutation] = useUpdateHealthyBowlTraceBatchMutation();\n const [recallTraceBatchMutation] = useRecallHealthyBowlTraceBatchMutation();\n const [deleteTraceBatchMutation] = useDeleteHealthyBowlTraceBatchMutation();\n const [updateCertificationMutation] = useUpdateHealthyBowlCertificationMutation();\n const [deleteCertificationMutation] = useDeleteHealthyBowlCertificationMutation();\n const [updateComplianceDocumentMutation] = useUpdateHealthyBowlComplianceDocumentMutation();\n const [deleteComplianceDocumentMutation] = useDeleteHealthyBowlComplianceDocumentMutation();\n const [updateFarmEventMutation] = useUpdateHealthyBowlFarmEventMutation();\n const [deleteFarmEventMutation] = useDeleteHealthyBowlFarmEventMutation();\n const [createCommunityPostMutation] = useCreateHealthyBowlCommunityPostMutation();\n const [createExpertMutation] = useCreateHealthyBowlExpertMutation();\n const [updateExpertMutation] = useUpdateHealthyBowlExpertMutation();\n const [deleteExpertMutation] = useDeleteHealthyBowlExpertMutation();\n const [createMentorMutation] = useCreateHealthyBowlMentorMutation();\n const [updateMentorMutation] = useUpdateHealthyBowlMentorMutation();\n const [deleteMentorMutation] = useDeleteHealthyBowlMentorMutation();\n const [createGovernmentSchemeMutation] = useCreateHealthyBowlGovernmentSchemeMutation();\n const [updateGovernmentSchemeMutation] = useUpdateHealthyBowlGovernmentSchemeMutation();\n const [deleteGovernmentSchemeMutation] = useDeleteHealthyBowlGovernmentSchemeMutation();\n\n const refetch = useCallback(\n () =>\n Promise.all([\n refetchGovernmentData(),\n refetchWeatherData(),\n refetchAnalyticsData(),\n refetchNetworkData(),\n refetchSoilData(),\n refetchDashboardData(),\n refetchCropsData(),\n refetchLivestockData(),\n refetchFinancialData(),\n refetchMarketplaceData(),\n refetchProductionData(),\n refetchProductsData(),\n refetchTraceabilityData(),\n refetchComplianceData(),\n refetchPestData(),\n refetchConsultations(),\n ]),\n [\n refetchGovernmentData,\n refetchWeatherData,\n refetchAnalyticsData,\n refetchNetworkData,\n refetchSoilData,\n refetchDashboardData,\n refetchCropsData,\n refetchLivestockData,\n refetchFinancialData,\n refetchMarketplaceData,\n refetchProductionData,\n refetchProductsData,\n refetchTraceabilityData,\n refetchComplianceData,\n refetchPestData,\n refetchConsultations,\n ]\n );\n\n const markAlertRead = useCallback(\n async (alertId: string, read = true): Promise<boolean> => {\n const response = await markAlertReadMutation({\n variables: {\n input: {\n alertId,\n read,\n context: { workspaceId: effectiveWorkspaceId },\n },\n },\n });\n\n await refetch();\n return Boolean(response.data?.markHealthyBowlAlertRead?.success);\n },\n [effectiveWorkspaceId, markAlertReadMutation, refetch]\n );\n\n // ── CRUD mutation wrappers ─────────────────────────────────────────────\n const eventBus = useEventBus();\n const ctx = useMemo(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const createCrop = useCallback(\n async (input: Omit<CreateCropInput, 'context'>) => {\n const res = await createCropMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n const crop = res.data?.createHealthyBowlCrop;\n emitCropCreated(eventBus, crop, ctx.workspaceId);\n return crop;\n },\n [createCropMutation, ctx, refetchCropsData, eventBus]\n );\n const updateCrop = useCallback(\n async (input: Omit<UpdateCropInput, 'context'>) => {\n const res = await updateCropMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n const crop = res.data?.updateHealthyBowlCrop;\n emitCropUpdated(eventBus, crop, ctx.workspaceId);\n return crop;\n },\n [updateCropMutation, ctx, refetchCropsData, eventBus]\n );\n const deleteCrop = useCallback(\n async (id: string) => {\n const res = await deleteCropMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return true;\n },\n [deleteCropMutation, ctx, refetchCropsData]\n );\n\n const createAnimal = useCallback(\n async (input: Omit<CreateAnimalInput, 'context'>) => {\n const res = await createAnimalMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlAnimal;\n },\n [createAnimalMutation, ctx, refetchLivestockData]\n );\n const updateAnimal = useCallback(\n async (input: Omit<UpdateAnimalInput, 'context'>) => {\n const res = await updateAnimalMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlAnimal;\n },\n [updateAnimalMutation, ctx, refetchLivestockData]\n );\n const deleteAnimal = useCallback(\n async (id: string) => {\n const res = await deleteAnimalMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return true;\n },\n [deleteAnimalMutation, ctx, refetchLivestockData]\n );\n\n const createFarm = useCallback(\n async (input: Omit<CreateFarmInput, 'context'>) => {\n const res = await createFarmMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchDashboardData();\n const farm = res.data?.createHealthyBowlFarm;\n emitFarmCreated(eventBus, farm, ctx.workspaceId);\n return farm;\n },\n [createFarmMutation, ctx, refetchDashboardData, eventBus]\n );\n\n const updateFarm = useCallback(\n async (input: Omit<UpdateFarmInput, 'context'>) => {\n const res = await updateFarmMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchDashboardData();\n return res.data?.updateHealthyBowlFarm;\n },\n [updateFarmMutation, ctx, refetchDashboardData]\n );\n\n const createField = useCallback(\n async (input: CreateFieldInput) => {\n const res = await createFieldMutation({\n variables: { input: { ...input, type: input.type as GqlGrowLocationType | null | undefined, context: ctx } },\n });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.createHealthyBowlField;\n },\n [createFieldMutation, ctx, refetchCropsData]\n );\n const updateField = useCallback(\n async (input: UpdateFieldInput) => {\n const res = await updateFieldMutation({\n variables: { input: { ...input, type: input.type as GqlGrowLocationType | null | undefined, context: ctx } },\n });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.updateHealthyBowlField;\n },\n [updateFieldMutation, ctx, refetchCropsData]\n );\n const deleteField = useCallback(\n async (id: string) => {\n const res = await deleteFieldMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return true;\n },\n [deleteFieldMutation, ctx, refetchCropsData]\n );\n\n const createMarketplaceProduct = useCallback(\n async (input: Omit<CreateMarketplaceProductInput, 'context'>) => {\n const res = await createMarketplaceProductMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchMarketplaceData();\n return res.data?.createHealthyBowlMarketplaceProduct;\n },\n [createMarketplaceProductMutation, ctx, refetchMarketplaceData]\n );\n const updateMarketplaceProduct = useCallback(\n async (input: Omit<UpdateMarketplaceProductInput, 'context'>) => {\n const res = await updateMarketplaceProductMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchMarketplaceData();\n return res.data?.updateHealthyBowlMarketplaceProduct;\n },\n [updateMarketplaceProductMutation, ctx, refetchMarketplaceData]\n );\n const deleteMarketplaceProduct = useCallback(\n async (id: string) => {\n const res = await deleteMarketplaceProductMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchMarketplaceData();\n return true;\n },\n [deleteMarketplaceProductMutation, ctx, refetchMarketplaceData]\n );\n\n const createTransaction = useCallback(\n async (input: Omit<CreateHealthyBowlTransactionInput, 'context'>) => {\n const res = await createTransactionMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.createHealthyBowlTransaction;\n },\n [createTransactionMutation, ctx, refetchFinancialData]\n );\n const updateTransaction = useCallback(\n async (input: Omit<UpdateHealthyBowlTransactionInput, 'context'>) => {\n const res = await updateTransactionMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.updateHealthyBowlTransaction;\n },\n [updateTransactionMutation, ctx, refetchFinancialData]\n );\n const deleteTransaction = useCallback(\n async (id: string) => {\n const res = await deleteTransactionMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return true;\n },\n [deleteTransactionMutation, ctx, refetchFinancialData]\n );\n const getTransactionReceiptUrl = useCallback(\n async (transactionId: string): Promise<string> => {\n const res = await getTransactionReceiptUrlQuery({\n variables: { context: ctx, transactionId },\n });\n if (res.error) throw res.error;\n const url = res.data?.getHealthyBowlTransactionReceiptUrl;\n if (!url) throw new Error('Receipt is unavailable in this workspace.');\n return url;\n },\n [ctx, getTransactionReceiptUrlQuery]\n );\n\n // ── New CRUD mutations (16 entities) ──────────────────────────────────\n const createPlantingPlan = useCallback(\n async (input: Omit<CreatePlantingPlanInput, 'context'>) => {\n const res = await createPlantingPlanMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.createHealthyBowlPlantingPlan;\n },\n [createPlantingPlanMutation, ctx, refetchCropsData]\n );\n const createHarvestRecord = useCallback(\n async (input: HarvestRecordCreateArgs) => {\n const res = await createHarvestRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n const harvest = res.data?.createHealthyBowlHarvestRecord;\n emitHarvestRecorded(eventBus, harvest, ctx.workspaceId);\n return harvest;\n },\n [createHarvestRecordMutation, ctx, refetchCropsData, eventBus]\n );\n const createHealthRecord = useCallback(\n async (input: Omit<CreateHealthRecordInput, 'context'>) => {\n const res = await createHealthRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlHealthRecord;\n },\n [createHealthRecordMutation, ctx, refetchLivestockData]\n );\n const createFeedRecord = useCallback(\n async (input: Omit<CreateFeedRecordInput, 'context'>) => {\n const res = await createFeedRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlFeedRecord;\n },\n [createFeedRecordMutation, ctx, refetchLivestockData]\n );\n const createVaccination = useCallback(\n async (input: Omit<CreateVaccinationInput, 'context'>) => {\n const res = await createVaccinationMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlVaccination;\n },\n [createVaccinationMutation, ctx, refetchLivestockData]\n );\n const createBreedingRecord = useCallback(\n async (input: Omit<CreateBreedingRecordInput, 'context'>) => {\n const res = await createBreedingRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlBreedingRecord;\n },\n [createBreedingRecordMutation, ctx, refetchLivestockData]\n );\n const createProductionRecord = useCallback(\n async (input: Omit<CreateProductionRecordInput, 'context'>) => {\n const res = await createProductionRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlProductionRecord;\n },\n [createProductionRecordMutation, ctx, refetchLivestockData]\n );\n const updateHealthRecord = useCallback(\n async (input: UpdateHealthRecordInput) => {\n const res = await updateHealthRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlHealthRecord;\n },\n [updateHealthRecordMutation, ctx, refetchLivestockData]\n );\n const updateFeedRecord = useCallback(\n async (input: UpdateFeedRecordInput) => {\n const res = await updateFeedRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlFeedRecord;\n },\n [updateFeedRecordMutation, ctx, refetchLivestockData]\n );\n const updateVaccination = useCallback(\n async (input: UpdateVaccinationInput) => {\n const res = await updateVaccinationMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlVaccination;\n },\n [updateVaccinationMutation, ctx, refetchLivestockData]\n );\n const updateBreedingRecord = useCallback(\n async (input: UpdateBreedingRecordInput) => {\n const res = await updateBreedingRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlBreedingRecord;\n },\n [updateBreedingRecordMutation, ctx, refetchLivestockData]\n );\n const updateProductionRecord = useCallback(\n async (input: UpdateProductionRecordInput) => {\n const res = await updateProductionRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlProductionRecord;\n },\n [updateProductionRecordMutation, ctx, refetchLivestockData]\n );\n const updatePlantingPlan = useCallback(\n async (input: UpdatePlantingPlanInput) => {\n const res = await updatePlantingPlanMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.updateHealthyBowlPlantingPlan;\n },\n [updatePlantingPlanMutation, ctx, refetchCropsData]\n );\n const deletePlantingPlan = useCallback(\n async (id: string) => {\n const res = await deletePlantingPlanMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.deleteHealthyBowlPlantingPlan ?? false;\n },\n [deletePlantingPlanMutation, ctx, refetchCropsData]\n );\n const updateHarvestRecord = useCallback(\n async (input: HarvestRecordUpdateArgs) => {\n const res = await updateHarvestRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.updateHealthyBowlHarvestRecord;\n },\n [updateHarvestRecordMutation, ctx, refetchCropsData]\n );\n const deleteHarvestRecord = useCallback(\n async (id: string) => {\n const res = await deleteHarvestRecordMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.deleteHealthyBowlHarvestRecord ?? false;\n },\n [deleteHarvestRecordMutation, ctx, refetchCropsData]\n );\n const deleteVaccination = useCallback(\n async (id: string) => {\n const res = await deleteVaccinationMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.deleteHealthyBowlVaccination ?? false;\n },\n [deleteVaccinationMutation, ctx, refetchLivestockData]\n );\n const deleteHealthRecord = useCallback(\n async (id: string) => {\n const res = await deleteHealthRecordMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.deleteHealthyBowlHealthRecord ?? false;\n },\n [deleteHealthRecordMutation, ctx, refetchLivestockData]\n );\n const deleteFeedRecord = useCallback(\n async (id: string) => {\n const res = await deleteFeedRecordMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.deleteHealthyBowlFeedRecord ?? false;\n },\n [deleteFeedRecordMutation, ctx, refetchLivestockData]\n );\n const deleteBreedingRecord = useCallback(\n async (id: string) => {\n const res = await deleteBreedingRecordMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.deleteHealthyBowlBreedingRecord ?? false;\n },\n [deleteBreedingRecordMutation, ctx, refetchLivestockData]\n );\n const deleteProductionRecord = useCallback(\n async (id: string) => {\n const res = await deleteProductionRecordMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.deleteHealthyBowlProductionRecord ?? false;\n },\n [deleteProductionRecordMutation, ctx, refetchLivestockData]\n );\n const createProduct = useCallback(\n async (input: CreateHealthyBowlProductInput) => {\n const res = await createProductMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchProductsData();\n return res.data?.createHealthyBowlProduct;\n },\n [createProductMutation, ctx, refetchProductsData]\n );\n const updateProduct = useCallback(\n async (input: UpdateHealthyBowlProductInput) => {\n const res = await updateProductMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchProductsData();\n return res.data?.updateHealthyBowlProduct;\n },\n [updateProductMutation, ctx, refetchProductsData]\n );\n const adjustProductStock = useCallback(\n async (input: AdjustHealthyBowlProductStockInput) => {\n const res = await adjustProductStockMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchProductsData();\n return res.data?.adjustHealthyBowlProductStock;\n },\n [adjustProductStockMutation, ctx, refetchProductsData]\n );\n const deleteProduct = useCallback(\n async (id: string) => {\n const res = await deleteProductMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchProductsData();\n return res.data?.deleteHealthyBowlProduct ?? false;\n },\n [deleteProductMutation, ctx, refetchProductsData]\n );\n const createFarmEvent = useCallback(\n async (input: CreateFarmEventInput) => {\n const res = await createFarmEventMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n // A post-create refresh blip must not surface as a create failure (the record WAS created).\n try {\n await refetchNetworkData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.createHealthyBowlFarmEvent;\n },\n [createFarmEventMutation, ctx, refetchNetworkData]\n );\n const updateFarmEvent = useCallback(\n async (input: Omit<UpdateFarmEventInput, 'context'>) => {\n const res = await updateFarmEventMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.updateHealthyBowlFarmEvent;\n },\n [updateFarmEventMutation, ctx, refetchNetworkData]\n );\n const deleteFarmEvent = useCallback(\n async (id: string) => {\n const res = await deleteFarmEventMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return true;\n },\n [deleteFarmEventMutation, ctx, refetchNetworkData]\n );\n const createOrder = useCallback(\n async (input: CreateMarketplaceOrderInput) => {\n const res = await createOrderMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n try {\n await refetchMarketplaceData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.createHealthyBowlOrder;\n },\n [createOrderMutation, ctx, refetchMarketplaceData]\n );\n const updateOrder = useCallback(\n async (input: UpdateMarketplaceOrderInput) => {\n const res = await updateOrderMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n try {\n await refetchMarketplaceData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.updateHealthyBowlOrder;\n },\n [updateOrderMutation, ctx, refetchMarketplaceData]\n );\n const createComplianceDocument = useCallback(\n async (input: CreateComplianceDocumentInput) => {\n const res = await createComplianceDocumentMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n try {\n await refetchComplianceData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.createHealthyBowlComplianceDocument;\n },\n [createComplianceDocumentMutation, ctx, refetchComplianceData]\n );\n const createCertification = useCallback(\n async (input: CreateCertificationInput) => {\n const res = await createCertificationMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n try {\n await refetchComplianceData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.createHealthyBowlCertification;\n },\n [createCertificationMutation, ctx, refetchComplianceData]\n );\n const updateCertification = useCallback(\n async (input: Omit<UpdateCertificationInput, 'context'>) => {\n const res = await updateCertificationMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return res.data?.updateHealthyBowlCertification;\n },\n [updateCertificationMutation, ctx, refetchComplianceData]\n );\n const deleteCertification = useCallback(\n async (id: string) => {\n const res = await deleteCertificationMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return true;\n },\n [deleteCertificationMutation, ctx, refetchComplianceData]\n );\n const updateComplianceDocument = useCallback(\n async (input: Omit<UpdateComplianceDocumentInput, 'context'>) => {\n const res = await updateComplianceDocumentMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return res.data?.updateHealthyBowlComplianceDocument;\n },\n [updateComplianceDocumentMutation, ctx, refetchComplianceData]\n );\n const deleteComplianceDocument = useCallback(\n async (id: string) => {\n const res = await deleteComplianceDocumentMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return true;\n },\n [deleteComplianceDocumentMutation, ctx, refetchComplianceData]\n );\n const createProductionBatch = useCallback(\n async (input: CreateProductionBatchInput) => {\n const res = await createProductionBatchMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n try {\n await refetchProductionData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.createHealthyBowlProductionBatch;\n },\n [createProductionBatchMutation, ctx, refetchProductionData]\n );\n const createSoilTest = useCallback(\n async (input: Omit<CreateSoilTestInput, 'context'>) => {\n const res = await createSoilTestMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchSoilData();\n return res.data?.createHealthyBowlSoilTest;\n },\n [createSoilTestMutation, ctx, refetchSoilData]\n );\n const createPestIssue = useCallback(\n async (input: Omit<CreatePestIssueInput, 'context'>) => {\n const res = await createPestIssueMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchPestData();\n return res.data?.createHealthyBowlPestIssue;\n },\n [createPestIssueMutation, ctx, refetchPestData]\n );\n const updatePestIssue = useCallback(\n async (input: UpdatePestIssueInput) => {\n const res = await updatePestIssueMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchPestData();\n return res.data?.updateHealthyBowlPestIssue;\n },\n [updatePestIssueMutation, ctx, refetchPestData]\n );\n const createTreatment = useCallback(\n async (input: Omit<CreateTreatmentInput, 'context'>) => {\n const res = await createTreatmentMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchPestData();\n return res.data?.createHealthyBowlTreatment;\n },\n [createTreatmentMutation, ctx, refetchPestData]\n );\n const createRecipe = useCallback(\n async (input: Omit<CreateRecipeInput, 'context'>) => {\n const res = await createRecipeMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchProductionData();\n return res.data?.createHealthyBowlRecipe;\n },\n [createRecipeMutation, ctx, refetchProductionData]\n );\n const updateRecipe = useCallback(\n async (input: Omit<UpdateRecipeInput, 'context'>) => {\n const res = await updateRecipeMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchProductionData();\n return res.data?.updateHealthyBowlRecipe;\n },\n [updateRecipeMutation, ctx, refetchProductionData]\n );\n const deleteRecipe = useCallback(\n async (id: string) => {\n const res = await deleteRecipeMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchProductionData();\n return true;\n },\n [deleteRecipeMutation, ctx, refetchProductionData]\n );\n const createBudget = useCallback(\n async (input: Omit<CreateBudgetInput, 'context'>) => {\n const res = await createBudgetMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.createHealthyBowlBudget;\n },\n [createBudgetMutation, ctx, refetchFinancialData]\n );\n const createInvoice = useCallback(\n async (input: Omit<CreateInvoiceInput, 'context'>) => {\n const res = await createInvoiceMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.createHealthyBowlInvoice;\n },\n [createInvoiceMutation, ctx, refetchFinancialData]\n );\n const updateBudget = useCallback(\n async (input: UpdateBudgetFields) => {\n const res = await updateBudgetMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.updateHealthyBowlBudget;\n },\n [updateBudgetMutation, ctx, refetchFinancialData]\n );\n const updateInvoice = useCallback(\n async (input: UpdateInvoiceFields) => {\n const res = await updateInvoiceMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.updateHealthyBowlInvoice;\n },\n [updateInvoiceMutation, ctx, refetchFinancialData]\n );\n const createAudit = useCallback(\n async (input: Omit<CreateAuditInput, 'context'>) => {\n const res = await createAuditMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return res.data?.createHealthyBowlAudit;\n },\n [createAuditMutation, ctx, refetchComplianceData]\n );\n const updateAudit = useCallback(\n async (input: UpdateAuditInput) => {\n const res = await updateAuditMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return res.data?.updateHealthyBowlAudit;\n },\n [updateAuditMutation, ctx, refetchComplianceData]\n );\n const updateSoilTest = useCallback(\n async (input: Omit<UpdateSoilTestInput, 'context'>) => {\n const res = await updateSoilTestMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchSoilData();\n return res.data?.updateHealthyBowlSoilTest;\n },\n [updateSoilTestMutation, ctx, refetchSoilData]\n );\n const deleteSoilTest = useCallback(\n async (id: string) => {\n const res = await deleteSoilTestMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchSoilData();\n return true;\n },\n [deleteSoilTestMutation, ctx, refetchSoilData]\n );\n const updateTreatment = useCallback(\n async (input: Omit<UpdateTreatmentInput, 'context'>) => {\n const res = await updateTreatmentMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchPestData();\n return res.data?.updateHealthyBowlTreatment;\n },\n [updateTreatmentMutation, ctx, refetchPestData]\n );\n const deleteTreatment = useCallback(\n async (id: string) => {\n const res = await deleteTreatmentMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchPestData();\n return true;\n },\n [deleteTreatmentMutation, ctx, refetchPestData]\n );\n const deletePestIssue = useCallback(\n async (id: string) => {\n const res = await deletePestIssueMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchPestData();\n return true;\n },\n [deletePestIssueMutation, ctx, refetchPestData]\n );\n const deleteBudget = useCallback(\n async (id: string) => {\n const res = await deleteBudgetMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return true;\n },\n [deleteBudgetMutation, ctx, refetchFinancialData]\n );\n const deleteInvoice = useCallback(\n async (id: string) => {\n const res = await deleteInvoiceMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return true;\n },\n [deleteInvoiceMutation, ctx, refetchFinancialData]\n );\n const deleteAudit = useCallback(\n async (id: string) => {\n const res = await deleteAuditMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return true;\n },\n [deleteAuditMutation, ctx, refetchComplianceData]\n );\n const createTraceBatch = useCallback(\n async (input: Omit<CreateTraceBatchInput, 'context'>) => {\n const res = await createTraceBatchMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchTraceabilityData();\n return res.data?.createHealthyBowlTraceBatch;\n },\n [createTraceBatchMutation, ctx, refetchTraceabilityData]\n );\n const updateTraceBatch = useCallback(\n async (input: Omit<UpdateTraceBatchInput, 'context'>) => {\n const res = await updateTraceBatchMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchTraceabilityData();\n return res.data?.updateHealthyBowlTraceBatch;\n },\n [updateTraceBatchMutation, ctx, refetchTraceabilityData]\n );\n const recallTraceBatch = useCallback(\n async (id: string, reason?: string) => {\n const res = await recallTraceBatchMutation({\n variables: { id, reason: reason?.trim() ? reason.trim() : null, context: ctx },\n });\n if (res.error) throw res.error;\n await refetchTraceabilityData();\n return res.data?.recallHealthyBowlTraceBatch;\n },\n [recallTraceBatchMutation, ctx, refetchTraceabilityData]\n );\n const deleteTraceBatch = useCallback(\n async (id: string) => {\n const res = await deleteTraceBatchMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchTraceabilityData();\n return true;\n },\n [deleteTraceBatchMutation, ctx, refetchTraceabilityData]\n );\n const createCommunityPost = useCallback(\n async (input: Omit<CreateCommunityPostInput, 'context'>) => {\n const res = await createCommunityPostMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.createHealthyBowlCommunityPost;\n },\n [createCommunityPostMutation, ctx, refetchNetworkData]\n );\n const createConsultation = useCallback(\n async (input: CreateConsultationInput) => {\n const res = await createConsultationMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchConsultations();\n return res.data?.createHealthyBowlConsultation;\n },\n [createConsultationMutation, ctx, refetchConsultations]\n );\n const updateConsultationStatus = useCallback(\n async (input: UpdateConsultationStatusInput) => {\n const res = await updateConsultationStatusMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchConsultations();\n return res.data?.updateHealthyBowlConsultationStatus;\n },\n [updateConsultationStatusMutation, ctx, refetchConsultations]\n );\n const createExpert = useCallback(\n async (input: Omit<CreateExpertInput, 'context'>) => {\n const res = await createExpertMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.createHealthyBowlExpert;\n },\n [createExpertMutation, ctx, refetchNetworkData]\n );\n const updateExpert = useCallback(\n async (input: Omit<UpdateExpertInput, 'context'>) => {\n const res = await updateExpertMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.updateHealthyBowlExpert;\n },\n [updateExpertMutation, ctx, refetchNetworkData]\n );\n const deleteExpert = useCallback(\n async (id: string) => {\n const res = await deleteExpertMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return true;\n },\n [deleteExpertMutation, ctx, refetchNetworkData]\n );\n const createMentor = useCallback(\n async (input: Omit<CreateMentorInput, 'context'>) => {\n const res = await createMentorMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.createHealthyBowlMentor;\n },\n [createMentorMutation, ctx, refetchNetworkData]\n );\n const updateMentor = useCallback(\n async (input: Omit<UpdateMentorInput, 'context'>) => {\n const res = await updateMentorMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.updateHealthyBowlMentor;\n },\n [updateMentorMutation, ctx, refetchNetworkData]\n );\n const deleteMentor = useCallback(\n async (id: string) => {\n const res = await deleteMentorMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return true;\n },\n [deleteMentorMutation, ctx, refetchNetworkData]\n );\n const createGovernmentScheme = useCallback(\n async (input: Omit<CreateGovernmentSchemeInput, 'context'>) => {\n const res = await createGovernmentSchemeMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchGovernmentData();\n return res.data?.createHealthyBowlGovernmentScheme;\n },\n [createGovernmentSchemeMutation, ctx, refetchGovernmentData]\n );\n /**\n * BOFF-6112 — mark government notifications read/unread and persist it.\n *\n * Refetches ONLY the government slice, not the 16-query `refetch()` that `markAlertRead` uses —\n * clicking a notification should not re-run every dashboard query on the page.\n */\n const markGovernmentNotificationRead = useCallback(\n async (notificationIds: string[], read: boolean = true) => {\n if (notificationIds.length === 0) return 0;\n const res = await markGovernmentNotificationReadMutation({\n variables: { input: { notificationIds, read, context: ctx } },\n });\n if (res.error) throw res.error;\n await refetchGovernmentData();\n return res.data?.markHealthyBowlGovernmentNotificationRead?.updatedCount ?? 0;\n },\n [markGovernmentNotificationReadMutation, ctx, refetchGovernmentData]\n );\n\n const updateGovernmentScheme = useCallback(\n async (input: Omit<UpdateGovernmentSchemeInput, 'context'>) => {\n const res = await updateGovernmentSchemeMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchGovernmentData();\n return res.data?.updateHealthyBowlGovernmentScheme;\n },\n [updateGovernmentSchemeMutation, ctx, refetchGovernmentData]\n );\n const deleteGovernmentScheme = useCallback(\n async (id: string) => {\n const res = await deleteGovernmentSchemeMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchGovernmentData();\n return res.data?.deleteHealthyBowlGovernmentScheme ?? false;\n },\n [deleteGovernmentSchemeMutation, ctx, refetchGovernmentData]\n );\n\n const governmentPayload = governmentData?.getHealthyBowlGovernmentData;\n const analyticsPayload = analyticsData?.getHealthyBowlAnalyticsData;\n const weatherPayload = weatherData?.getHealthyBowlWeatherData;\n const networkPayload = networkData?.getHealthyBowlNetworkData;\n const soilPayload = soilData?.getHealthyBowlSoilData;\n const dashboardPayload = dashboardData?.getHealthyBowlDashboardData;\n const cropsPayload = cropsData?.getHealthyBowlCropsData;\n const livestockPayload = livestockData?.getHealthyBowlLivestockData;\n const financialPayload = financialData?.getHealthyBowlFinancialData;\n const marketplacePayload = marketplaceData?.getHealthyBowlMarketplaceData;\n const productionPayload = productionData?.getHealthyBowlProductionData;\n const productsPayload = productsData?.getHealthyBowlProductsData;\n const traceabilityPayload = traceabilityData?.getHealthyBowlTraceabilityData;\n const compliancePayload = complianceData?.getHealthyBowlComplianceData;\n const pestPayload = pestData?.getHealthyBowlPestData;\n const loading =\n governmentLoading ||\n weatherLoading ||\n analyticsLoading ||\n networkLoading ||\n soilLoading ||\n dashboardLoading ||\n cropsLoading ||\n livestockLoading ||\n financialLoading ||\n marketplaceLoading ||\n productionLoading ||\n productsLoading ||\n traceabilityLoading ||\n complianceLoading ||\n pestLoading;\n const error =\n governmentError ??\n weatherError ??\n analyticsError ??\n networkError ??\n soilError ??\n dashboardError ??\n cropsError ??\n livestockError ??\n financialError ??\n marketplaceError ??\n productionError ??\n productsError ??\n traceabilityError ??\n complianceError ??\n pestError;\n\n // Per-domain error, surfaced ONLY on a cold failure (no cached payload yet).\n // With cache-and-network, Apollo sets `error` even while cached data persists\n // during a background revalidation — gating on `!{domain}Payload` means a\n // transient refetch failure never replaces already-visible data with an error\n // screen; the page keeps showing the cached data instead.\n const errors = useMemo(\n () => ({\n government: governmentError && !governmentPayload ? governmentError : null,\n weather: weatherError && !weatherPayload ? weatherError : null,\n analytics: analyticsError && !analyticsPayload ? analyticsError : null,\n network: networkError && !networkPayload ? networkError : null,\n soil: soilError && !soilPayload ? soilError : null,\n dashboard: dashboardError && !dashboardPayload ? dashboardError : null,\n crops: cropsError && !cropsPayload ? cropsError : null,\n livestock: livestockError && !livestockPayload ? livestockError : null,\n financial: financialError && !financialPayload ? financialError : null,\n marketplace: marketplaceError && !marketplacePayload ? marketplaceError : null,\n production: productionError && !productionPayload ? productionError : null,\n products: productsError && !productsPayload ? productsError : null,\n traceability: traceabilityError && !traceabilityPayload ? traceabilityError : null,\n compliance: complianceError && !compliancePayload ? complianceError : null,\n pest: pestError && !pestPayload ? pestError : null,\n }),\n [\n governmentError,\n weatherError,\n analyticsError,\n networkError,\n soilError,\n dashboardError,\n cropsError,\n livestockError,\n financialError,\n marketplaceError,\n productionError,\n productsError,\n traceabilityError,\n complianceError,\n pestError,\n governmentPayload,\n weatherPayload,\n analyticsPayload,\n networkPayload,\n soilPayload,\n dashboardPayload,\n cropsPayload,\n livestockPayload,\n financialPayload,\n marketplacePayload,\n productionPayload,\n productsPayload,\n traceabilityPayload,\n compliancePayload,\n pestPayload,\n ]\n );\n\n // Per-domain \"is this slice doing its FIRST load\" — true only while a query is\n // loading AND has no cached payload yet. This deliberately excludes the\n // cache-and-network BACKGROUND revalidation (payload already present), so a\n // page never replaces already-visible data with a spinner on a revisit/refetch\n // — it only shows the loader on the cold initial load.\n const loadings = useMemo(\n () => ({\n government: governmentLoading && !governmentPayload,\n weather: weatherLoading && !weatherPayload,\n analytics: analyticsLoading && !analyticsPayload,\n network: networkLoading && !networkPayload,\n soil: soilLoading && !soilPayload,\n dashboard: dashboardLoading && !dashboardPayload,\n crops: cropsLoading && !cropsPayload,\n livestock: livestockLoading && !livestockPayload,\n financial: financialLoading && !financialPayload,\n marketplace: marketplaceLoading && !marketplacePayload,\n production: productionLoading && !productionPayload,\n products: productsLoading && !productsPayload,\n traceability: traceabilityLoading && !traceabilityPayload,\n compliance: complianceLoading && !compliancePayload,\n pest: pestLoading && !pestPayload,\n }),\n [\n governmentLoading,\n weatherLoading,\n analyticsLoading,\n networkLoading,\n soilLoading,\n dashboardLoading,\n cropsLoading,\n livestockLoading,\n financialLoading,\n marketplaceLoading,\n productionLoading,\n productsLoading,\n traceabilityLoading,\n complianceLoading,\n pestLoading,\n governmentPayload,\n weatherPayload,\n analyticsPayload,\n networkPayload,\n soilPayload,\n dashboardPayload,\n cropsPayload,\n livestockPayload,\n financialPayload,\n marketplacePayload,\n productionPayload,\n productsPayload,\n traceabilityPayload,\n compliancePayload,\n pestPayload,\n ]\n );\n\n return useMemo(\n () => ({\n alerts: readQueryArray<Alert>(dashboardPayload?.alerts, []),\n analyticsKPIs: readQueryArray<AnalyticsKPI>(analyticsPayload?.kpis, []),\n crops: readQueryArray<Crop>(cropsPayload?.crops, []),\n dashboardStats: readQueryValue<DashboardStats>(dashboardPayload?.dashboardStats, EMPTY_DASHBOARD_STATS),\n dailyHistory: readQueryArray<WeatherHistoryRecord>(weatherPayload?.dailyHistory, []),\n fields: readQueryArray<Field>(cropsPayload?.fields, []),\n farm: readQueryValue<Farm>(dashboardPayload?.farm, EMPTY_FARM),\n governmentSchemes: readQueryArray<GovernmentScheme>(governmentPayload?.schemes, []),\n harvests: readQueryArray<HarvestRecord>(cropsPayload?.harvests, []),\n invoices: readQueryArray<Invoice>(financialPayload?.invoices, []),\n marketplaceProducts: readQueryArray<MarketplaceProduct>(marketplacePayload?.marketplaceProducts, []),\n messages: readQueryArray<GovernmentMessage>(governmentPayload?.messages, []),\n monthlySummaries: readQueryArray<WeatherMonthlySummary>(weatherPayload?.monthlySummaries, []),\n notifications: readQueryArray<GovernmentNotification>(governmentPayload?.notifications, []),\n orders: readQueryArray<Order>(marketplacePayload?.orders, []),\n plantingPlans: readQueryArray<PlantingPlan>(cropsPayload?.plantingPlans, []),\n productionBatches: readQueryArray<ProductionBatch>(productionPayload?.productionBatches, []),\n products: readQueryArray<Product>(productsPayload?.products, []),\n revenueChartData: readQueryArray<RevenueChartPoint>(analyticsPayload?.revenueChart, []),\n recipes: readQueryArray<Recipe>(productionPayload?.recipes, []),\n benefitsChart: readQueryArray<BenefitsChartPoint>(governmentPayload?.benefitsChart, []),\n activity: readQueryArray<GovernmentActivityItem>(governmentPayload?.activity, []),\n announcements: readQueryArray<GovernmentAnnouncement>(governmentPayload?.announcements, []),\n animals: readQueryArray<Animal>(livestockPayload?.animals, []),\n breedingRecords: readQueryArray<BreedingRecord>(livestockPayload?.breedingRecords, []),\n feedRecords: readQueryArray<FeedRecord>(livestockPayload?.feedRecords, []),\n healthRecords: readQueryArray<HealthRecord>(livestockPayload?.healthRecords, []),\n productionRecords: readQueryArray<ProductionRecord>(livestockPayload?.productionRecords, []),\n recordsForRemovedAnimals: readQueryValue<number>(livestockPayload?.recordsForRemovedAnimals, 0),\n schemeApplications: readQueryArray<SchemeApplication>(governmentPayload?.applications, []),\n sensorReadings: readQueryArray<SoilSensorReading>(soilPayload?.sensorReadings, []),\n soilTests: readQueryArray<SoilTest>(soilPayload?.soilTests, []),\n traceBatches: readQueryArray<TraceBatch>(traceabilityPayload?.traceBatches, []),\n trainingPrograms: readQueryArray<TrainingProgram>(governmentPayload?.trainingPrograms, []),\n transactions: readQueryArray<Transaction>(financialPayload?.transactions, []),\n vaccinations: readQueryArray<Vaccination>(livestockPayload?.vaccinations, []),\n weatherData: readQueryValue<WeatherData>(weatherPayload?.weather, EMPTY_WEATHER),\n budgets: readQueryArray<Budget>(financialPayload?.budgets, []),\n analyticsReports: readQueryArray<AnalyticsReport>(analyticsPayload?.reports, []),\n cropDistributionData: readQueryArray<CropDistributionPoint>(analyticsPayload?.cropDistribution, []),\n yieldTrendData: readQueryArray<YieldTrendPoint>(analyticsPayload?.yieldTrend, []),\n insights: readQueryArray<FarmInsight>(analyticsPayload?.insights, []),\n audits: readQueryArray<Audit>(compliancePayload?.audits, []),\n certifications: readQueryArray<Certification>(compliancePayload?.certifications, []),\n complianceDocuments: readQueryArray<ComplianceDocument>(compliancePayload?.complianceDocuments, []),\n communityPosts: readQueryArray<CommunityPost>(networkPayload?.communityPosts, []),\n events: readQueryArray<FarmEvent>(networkPayload?.events, []),\n experts: readQueryArray<Expert>(networkPayload?.experts, []),\n mentors: readQueryArray<Mentor>(networkPayload?.mentors, []),\n agenda: readQueryArray<EventAgendaItem>(networkPayload?.agenda, []),\n consultations: readQueryArray<Consultation>(consultationsData?.getHealthyBowlConsultations, []),\n pestIssues: readQueryArray<PestIssue>(pestPayload?.pestIssues, []),\n treatments: readQueryArray<Treatment>(pestPayload?.treatments, []),\n loading,\n error: error ? new Error(error.message) : null,\n errors,\n loadings,\n refetch,\n // Exposed so the trace-portal page can refresh just the batch list after a publish /\n // unpublish, instead of refetching every slice of the dashboard bundle.\n refetchTraceabilityData,\n markAlertRead,\n markGovernmentNotificationRead,\n createCrop,\n updateCrop,\n deleteCrop,\n createAnimal,\n updateAnimal,\n deleteAnimal,\n createFarm,\n updateFarm,\n createField,\n updateField,\n deleteField,\n createMarketplaceProduct,\n updateMarketplaceProduct,\n deleteMarketplaceProduct,\n createTransaction,\n updateTransaction,\n deleteTransaction,\n getTransactionReceiptUrl,\n createPlantingPlan,\n createHarvestRecord,\n createHealthRecord,\n createFeedRecord,\n createVaccination,\n createBreedingRecord,\n createProductionRecord,\n createSoilTest,\n createPestIssue,\n updatePestIssue,\n createTreatment,\n createRecipe,\n updateRecipe,\n deleteRecipe,\n createBudget,\n createInvoice,\n updateBudget,\n updateInvoice,\n createAudit,\n updateAudit,\n updateSoilTest,\n deleteSoilTest,\n updateTreatment,\n deleteTreatment,\n deletePestIssue,\n deleteBudget,\n deleteInvoice,\n deleteAudit,\n createTraceBatch,\n updateTraceBatch,\n recallTraceBatch,\n deleteTraceBatch,\n createCommunityPost,\n updateHealthRecord,\n updateFeedRecord,\n updateVaccination,\n updateBreedingRecord,\n updateProductionRecord,\n updatePlantingPlan,\n deletePlantingPlan,\n updateHarvestRecord,\n deleteHarvestRecord,\n deleteVaccination,\n deleteHealthRecord,\n deleteFeedRecord,\n deleteBreedingRecord,\n deleteProductionRecord,\n createProduct,\n updateProduct,\n adjustProductStock,\n deleteProduct,\n createFarmEvent,\n updateFarmEvent,\n deleteFarmEvent,\n createOrder,\n updateOrder,\n createComplianceDocument,\n updateComplianceDocument,\n deleteComplianceDocument,\n createCertification,\n updateCertification,\n deleteCertification,\n createProductionBatch,\n createConsultation,\n updateConsultationStatus,\n createExpert,\n updateExpert,\n deleteExpert,\n createMentor,\n updateMentor,\n deleteMentor,\n createGovernmentScheme,\n updateGovernmentScheme,\n deleteGovernmentScheme,\n }),\n [\n governmentPayload,\n weatherPayload,\n analyticsPayload,\n networkPayload,\n soilPayload,\n dashboardPayload,\n cropsPayload,\n livestockPayload,\n financialPayload,\n marketplacePayload,\n productionPayload,\n productsPayload,\n traceabilityPayload,\n compliancePayload,\n pestPayload,\n loading,\n error,\n errors,\n loadings,\n refetch,\n refetchTraceabilityData,\n markAlertRead,\n markGovernmentNotificationRead,\n createCrop,\n updateCrop,\n deleteCrop,\n createAnimal,\n updateAnimal,\n deleteAnimal,\n createFarm,\n updateFarm,\n createField,\n updateField,\n deleteField,\n createMarketplaceProduct,\n updateMarketplaceProduct,\n deleteMarketplaceProduct,\n createTransaction,\n updateTransaction,\n deleteTransaction,\n getTransactionReceiptUrl,\n createPlantingPlan,\n createHarvestRecord,\n createHealthRecord,\n createFeedRecord,\n createVaccination,\n createBreedingRecord,\n createProductionRecord,\n createSoilTest,\n createPestIssue,\n updatePestIssue,\n createTreatment,\n createRecipe,\n updateRecipe,\n deleteRecipe,\n createBudget,\n createInvoice,\n updateBudget,\n updateInvoice,\n createAudit,\n updateAudit,\n updateSoilTest,\n deleteSoilTest,\n updateTreatment,\n deleteTreatment,\n deletePestIssue,\n deleteBudget,\n deleteInvoice,\n deleteAudit,\n createTraceBatch,\n updateTraceBatch,\n recallTraceBatch,\n deleteTraceBatch,\n createCommunityPost,\n updateHealthRecord,\n updateFeedRecord,\n updateVaccination,\n updateBreedingRecord,\n updateProductionRecord,\n updatePlantingPlan,\n deletePlantingPlan,\n updateHarvestRecord,\n deleteHarvestRecord,\n deleteVaccination,\n deleteHealthRecord,\n deleteFeedRecord,\n deleteBreedingRecord,\n deleteProductionRecord,\n createProduct,\n updateProduct,\n adjustProductStock,\n deleteProduct,\n createFarmEvent,\n updateFarmEvent,\n deleteFarmEvent,\n createOrder,\n updateOrder,\n createComplianceDocument,\n updateComplianceDocument,\n deleteComplianceDocument,\n createCertification,\n updateCertification,\n deleteCertification,\n createProductionBatch,\n consultationsData,\n createConsultation,\n updateConsultationStatus,\n createExpert,\n updateExpert,\n deleteExpert,\n createMentor,\n updateMentor,\n deleteMentor,\n createGovernmentScheme,\n updateGovernmentScheme,\n deleteGovernmentScheme,\n ]\n );\n}\n"],"mappings":";;;;;;;;AAiNA,IAAM,KAAiC,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FpC,KAAmC,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsTtC,KAAwB,CAAG;;;;;;GAoB3B,KAAmB,CAAG;;;;;;GAOtB,KAA2B,CAAG;;;;;;GAO9B,KAAyB,CAAG;;;;;;GAO5B,KAAyB,CAAG;;;;;;GAO5B,KAA6B,CAAG;;;;;;GAOhC,KAA+B,CAAG;;;;;;GAOlC,KAA2B,CAAG;;;;;;;;GAS9B,KAA2B,CAAG;;;;GAK9B,KAA4B,CAAG;;;;;;GAO/B,KAA4B,CAAG;;;;GAK/B,KAAyB,CAAG;;;;GAK5B,KAA2B,CAAG;;;;GAK9B,KAAyB,CAAG;;;;GAK5B,KAA6B,CAAG;;;;GAKhC,KAA+B,CAAG;;;;GAKlC,KAAqB,CAAG;;;;;;GAOxB,KAAqB,CAAG;;;;;;GAOxB,KAAqB,CAAG;;;;GAKxB,KAA2B,CAAG;;;;;;;;;;;;;GAc9B,KAA0B,CAAG;;;;;;;;;;;;;;;;;;;;;;GAuB7B,KAAwB,CAAG;;;;;;;;;;;;;;;;;;;;;;GA6B3B,KAAiC,CAAG;;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;EAC9F,YAAY,EAA0B,GAAa,YAAY,CAAC,CAAC;EACjE,YAAY,EAA0B,GAAa,YAAY,CAAC,CAAC;EACjE;EACA,OAAO,KAAY,MAAM,GAAM,OAAO,IAAI;EAC1C;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;AACF"}
1
+ {"version":3,"file":"useHealthyBowlData.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlData.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport {\n useGetHealthyBowlAnalyticsDataQuery,\n useGetHealthyBowlComplianceDataQuery,\n useGetHealthyBowlDashboardDataQuery,\n useGetHealthyBowlFinancialDataQuery,\n useGetHealthyBowlTransactionReceiptUrlLazyQuery,\n useGetHealthyBowlGovernmentDataQuery,\n useGetHealthyBowlLivestockDataQuery,\n useGetHealthyBowlMarketplaceDataQuery,\n useGetHealthyBowlNetworkDataQuery,\n useGetHealthyBowlPestDataQuery,\n useGetHealthyBowlProductionDataQuery,\n useGetHealthyBowlProductsDataQuery,\n useGetHealthyBowlSoilDataQuery,\n useGetHealthyBowlTraceabilityDataQuery,\n useMarkHealthyBowlAlertReadMutation,\n useMarkHealthyBowlGovernmentNotificationReadMutation,\n useCreateHealthyBowlCropMutation,\n useUpdateHealthyBowlCropMutation,\n useDeleteHealthyBowlCropMutation,\n useCreateHealthyBowlAnimalMutation,\n useUpdateHealthyBowlAnimalMutation,\n useDeleteHealthyBowlAnimalMutation,\n useCreateHealthyBowlFarmMutation,\n useUpdateHealthyBowlFarmMutation,\n useCreateHealthyBowlFieldMutation,\n useUpdateHealthyBowlFieldMutation,\n useDeleteHealthyBowlFieldMutation,\n useCreateHealthyBowlMarketplaceProductMutation,\n useUpdateHealthyBowlMarketplaceProductMutation,\n useDeleteHealthyBowlMarketplaceProductMutation,\n useCreateHealthyBowlTransactionMutation,\n useUpdateHealthyBowlTransactionMutation,\n useDeleteHealthyBowlTransactionMutation,\n useCreateHealthyBowlPlantingPlanMutation,\n useCreateHealthyBowlHarvestRecordMutation,\n useCreateHealthyBowlHealthRecordMutation,\n useCreateHealthyBowlFeedRecordMutation,\n useCreateHealthyBowlVaccinationMutation,\n useCreateHealthyBowlBreedingRecordMutation,\n useCreateHealthyBowlProductionRecordMutation,\n useCreateHealthyBowlSoilTestMutation,\n useUpdateHealthyBowlSoilTestMutation,\n useDeleteHealthyBowlSoilTestMutation,\n useCreateHealthyBowlPestIssueMutation,\n useDeleteHealthyBowlPestIssueMutation,\n useCreateHealthyBowlTreatmentMutation,\n useUpdateHealthyBowlTreatmentMutation,\n useDeleteHealthyBowlTreatmentMutation,\n useDeleteHealthyBowlBudgetMutation,\n useDeleteHealthyBowlInvoiceMutation,\n useDeleteHealthyBowlAuditMutation,\n useCreateHealthyBowlRecipeMutation,\n useUpdateHealthyBowlRecipeMutation,\n useDeleteHealthyBowlRecipeMutation,\n useCreateHealthyBowlBudgetMutation,\n useCreateHealthyBowlInvoiceMutation,\n useCreateHealthyBowlAuditMutation,\n useCreateHealthyBowlTraceBatchMutation,\n useUpdateHealthyBowlTraceBatchMutation,\n useRecallHealthyBowlTraceBatchMutation,\n useDeleteHealthyBowlTraceBatchMutation,\n useUpdateHealthyBowlCertificationMutation,\n useDeleteHealthyBowlCertificationMutation,\n useUpdateHealthyBowlComplianceDocumentMutation,\n useDeleteHealthyBowlComplianceDocumentMutation,\n useUpdateHealthyBowlFarmEventMutation,\n useDeleteHealthyBowlFarmEventMutation,\n useCreateHealthyBowlCommunityPostMutation,\n useCreateHealthyBowlExpertMutation,\n useUpdateHealthyBowlExpertMutation,\n useDeleteHealthyBowlExpertMutation,\n useCreateHealthyBowlMentorMutation,\n useUpdateHealthyBowlMentorMutation,\n useDeleteHealthyBowlMentorMutation,\n useCreateHealthyBowlGovernmentSchemeMutation,\n useUpdateHealthyBowlGovernmentSchemeMutation,\n useDeleteHealthyBowlGovernmentSchemeMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateFarmInput,\n UpdateFarmInput,\n CreateCropInput,\n UpdateCropInput,\n CreateAnimalInput,\n UpdateAnimalInput,\n CreateHealthyBowlFieldInput,\n UpdateHealthyBowlFieldInput,\n GrowLocationType as GqlGrowLocationType,\n CreateMarketplaceProductInput,\n UpdateMarketplaceProductInput,\n CreateHealthyBowlTransactionInput,\n UpdateHealthyBowlTransactionInput,\n CreatePlantingPlanInput,\n CreateHarvestRecordInput,\n CreateHealthRecordInput,\n CreateFeedRecordInput,\n CreateVaccinationInput,\n CreateBreedingRecordInput,\n CreateProductionRecordInput,\n CreateSoilTestInput,\n UpdateSoilTestInput,\n CreatePestIssueInput,\n CreateTreatmentInput,\n UpdateTreatmentInput,\n CreateRecipeInput,\n UpdateRecipeInput,\n CreateBudgetInput,\n CreateInvoiceInput,\n CreateAuditInput,\n CreateTraceBatchInput,\n UpdateTraceBatchInput,\n UpdateCertificationInput,\n UpdateComplianceDocumentInput,\n UpdateFarmEventInput,\n CreateCommunityPostInput,\n CreateExpertInput,\n UpdateExpertInput,\n CreateMentorInput,\n UpdateMentorInput,\n CreateGovernmentSchemeInput,\n UpdateGovernmentSchemeInput,\n} from '../../generated/wspace-types';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport { HEALTHYBOWL_FALLBACK_WORKSPACE_ID, useHealthyBowl } from '../context/HealthyBowlContext';\nimport { emitCropCreated, emitCropUpdated, emitFarmCreated, emitHarvestRecorded } from '../events/rybbit';\nimport type {\n Alert,\n AnalyticsKPI,\n AnalyticsReport,\n Animal,\n Audit,\n BreedingRecord,\n Budget,\n Certification,\n CommunityPost,\n ComplianceDocument,\n Consultation,\n ConsultantType,\n ConsultationMode,\n ConsultationStatus,\n Crop,\n DashboardStats,\n Expert,\n Farm,\n FarmEvent,\n FeedRecord,\n Field,\n GovernmentScheme,\n HarvestRecord,\n HealthRecord,\n Invoice,\n MarketplaceProduct,\n Mentor,\n Order,\n PestIssue,\n PlantingPlan,\n ProductionBatch,\n ProductionRecord,\n Product,\n Recipe,\n SchemeApplication,\n SoilTest,\n TraceBatch,\n TrainingProgram,\n Transaction,\n Treatment,\n Vaccination,\n WeatherData,\n} from '../types';\nimport type { GrowLocationType } from '../utils/growLocationType';\n\n// A field's grow-location type is re-declared as the plain string union the UI\n// works in (`utils/growLocationType`) rather than codegen's `GrowLocationType`,\n// which is a TypeScript string *enum* and so refuses a raw string literal even\n// though the values are identical. Swapping it here means one cast at the\n// mutation boundary instead of one at every call site.\nexport type CreateFieldInput = Omit<CreateHealthyBowlFieldInput, 'context' | 'type'> & {\n type?: GrowLocationType | null;\n};\nexport type UpdateFieldInput = Omit<UpdateHealthyBowlFieldInput, 'context' | 'type'> & {\n type?: GrowLocationType | null;\n};\n\n// --- Record update/delete (wired via raw gql documents: these mutations are not\n// yet in the pulled microfe schema, so codegen hooks don't exist for them offline.\n// A later `schema:pull` + `codegen` can replace these with generated hooks.) ---\ntype HBContext = { workspaceId: string };\ntype HealthyBowlCropsDataQueryResult = {\n getHealthyBowlCropsData: {\n crops: Crop[];\n fields: Field[];\n plantingPlans: PlantingPlan[];\n harvests: HarvestRecord[];\n updatedAt: string;\n };\n};\ntype HealthyBowlWeatherDataQueryResult = {\n getHealthyBowlWeatherData: {\n weather: WeatherData;\n dailyHistory: WeatherHistoryRecord[];\n monthlySummaries: WeatherMonthlySummary[];\n updatedAt: string;\n };\n};\n\nconst GET_HEALTHYBOWL_CROPS_DATA_DOC = gql`\n query GetHealthyBowlCropsDataWithBoundaryAndPlanIds($context: ContextInput!) {\n getHealthyBowlCropsData(context: $context) {\n crops {\n id\n name\n variety\n category\n season\n plantingDate\n expectedHarvestDate\n status\n growthStage\n healthStatus\n yieldEstimate\n yieldUnit\n yieldEstimateSource\n yieldEstimateAt\n healthScore\n healthScoreSource\n healthScoreAt\n organicCertified\n daysToHarvest\n progress\n field\n fieldName\n imageIds\n entityTags {\n id\n key\n label\n color\n vocabularyKey\n }\n }\n fields {\n id\n name\n area\n unit\n soilType\n irrigationType\n organicCertified\n status\n type\n crops\n location\n boundary\n imageIds\n growGeometry\n }\n plantingPlans {\n id\n cropId\n fieldId\n season\n startDate\n endDate\n status\n priority\n fieldName\n cropName\n expectedYield\n seedRequired\n weatherRisk\n fertilizers\n plantsNeeded\n seedGrams\n seedlingsToRaise\n }\n harvests {\n id\n cropName\n fieldName\n quantity\n unit\n qualityGrade\n status\n harvestDate\n pricePerUnit\n storageLocation\n # BOFF-6095 — set once the harvest has been banked into inventory. Drives whether the\n # harvest page offers \"Add to inventory\" or reports that it is already stock.\n productId\n # BOFF-6056 — the plan this harvest counts towards. Selected so the edit modal can show\n # the current link rather than defaulting the select to \"not linked\".\n plantingPlanId\n }\n updatedAt\n }\n }\n`;\n\nconst GET_HEALTHYBOWL_WEATHER_DATA_DOC = gql`\n query GetHealthyBowlWeatherDataWithCoordinates($context: ContextInput!) {\n getHealthyBowlWeatherData(context: $context) {\n weather {\n location\n latitude\n longitude\n current {\n temperature\n feelsLike\n humidity\n condition\n icon\n windSpeed\n windDirection\n pressure\n uvIndex\n visibility\n }\n forecast {\n date\n high\n low\n condition\n icon\n humidity\n precipitation\n windSpeed\n }\n alerts {\n id\n title\n type\n severity\n description\n startTime\n endTime\n affectedAreas\n }\n }\n dailyHistory {\n id\n date\n condition\n tempMax\n tempMin\n tempAvg\n humidity\n rainfall\n windSpeed\n pressure\n uvIndex\n sunrise\n sunset\n }\n monthlySummaries {\n id\n month\n year\n avgTemp\n avgHumidity\n totalRainfall\n rainyDays\n sunnyDays\n extremeEvents\n }\n updatedAt\n }\n }\n`;\ntype CreateSchemeApplicationInput = {\n schemeId: string;\n schemeName?: string;\n status?: 'draft' | 'submitted';\n amount?: number;\n notes?: string;\n};\ntype UpdateHealthRecordInput = {\n id: string;\n animalId?: string;\n type?: string;\n date?: string;\n diagnosis?: string;\n treatment?: string;\n veterinarian?: string;\n cost?: number;\n status?: string;\n};\ntype UpdateFeedRecordInput = {\n id: string;\n animalId?: string;\n feedType?: string;\n quantity?: number;\n unit?: string;\n cost?: number;\n date?: string;\n notes?: string;\n};\ntype UpdateVaccinationInput = {\n id: string;\n animalId?: string;\n vaccineName?: string;\n date?: string;\n nextDue?: string;\n administeredBy?: string;\n status?: string;\n};\ntype UpdateBreedingRecordInput = {\n id: string;\n animalId?: string;\n mateId?: string;\n matingType?: string;\n matingDate?: string;\n /** The PREDICTED delivery date. */\n expectedDueDate?: string;\n /** The OBSERVED delivery date — send when moving a record to DELIVERED (BOFF-6034). */\n deliveredOn?: string;\n offspringBorn?: number | null;\n /** Must not exceed offspringBorn; the server rejects an inverted pair. */\n offspringLive?: number | null;\n status?: string;\n notes?: string;\n};\ntype UpdateProductionRecordInput = {\n id: string;\n animalId?: string;\n type?: string;\n quantity?: number;\n unit?: string;\n quality?: string;\n date?: string;\n notes?: string;\n};\ntype UpdatePlantingPlanInput = {\n id: string;\n cropId?: string;\n fieldId?: string;\n season?: string;\n startDate?: string;\n endDate?: string;\n expectedYield?: number;\n seedRequired?: number;\n fertilizers?: string[];\n priority?: string;\n weatherRisk?: string;\n status?: string;\n};\ntype UpdateHarvestRecordInput = {\n id: string;\n cropId?: string;\n fieldId?: string;\n quantity?: number;\n unit?: string;\n quality?: string;\n harvestDate?: string;\n pricePerUnit?: number;\n storageLocation?: string;\n status?: string;\n};\ntype CreateHealthyBowlProductInput = {\n name: string;\n sku: string;\n category: string;\n price: number;\n unit: string;\n stock: number;\n minStock?: number;\n status?: string;\n organicCertified?: boolean;\n shelfLife: number;\n batchNumber?: string;\n /** GS1 AI (01) GTIN (BOFF-5729). Empty string clears it server-side. */\n gs1Gtin?: string;\n};\ntype UpdateHealthyBowlProductInput = {\n id: string;\n name?: string;\n sku?: string;\n category?: string;\n price?: number;\n unit?: string;\n stock?: number;\n minStock?: number;\n status?: string;\n organicCertified?: boolean;\n shelfLife?: number;\n batchNumber?: string;\n /** GS1 AI (01) GTIN (BOFF-5729). Empty string CLEARS it — see readGtinInput server-side. */\n gs1Gtin?: string;\n};\n/**\n * A finished-goods stock adjustment (BOFF-6371).\n *\n * Send the delta, never an absolute stock figure: the server applies it atomically and\n * re-derives `status`, so two operators adjusting at once no longer overwrite each other.\n * An OUT larger than the stock on hand is REJECTED, not clamped — clamping would leave\n * the ledger unable to reconcile with the stock column.\n */\ntype AdjustHealthyBowlProductStockInput = {\n productId: string;\n /** IN | OUT */\n direction: 'IN' | 'OUT';\n /** Positive whole number — `Product.stock` is an integer column. */\n quantity: number;\n unit?: string;\n /** HARVEST | RECEIPT | SALE | TRANSFER | ADJUSTMENT | SPOILAGE | OTHER. Defaults to ADJUSTMENT. */\n reason?: string;\n orderId?: string;\n reference?: string;\n occurredAt?: string;\n /** Why the stock moved, in the operator's own words. This is what the ledger is for. */\n notes?: string;\n};\ntype CreateFarmEventInput = {\n title: string;\n type: string;\n date: string;\n location: string;\n description: string;\n organizer: string;\n capacity?: number;\n mode: string;\n fee?: number;\n};\ntype CreateMarketplaceOrderInput = {\n buyerId: string;\n items: Array<{\n // Omitted by callers: the server derives a stable line-item id from the order + productId.\n // (Sending the Zustand cart-entry id would leak a local, ephemeral identifier.)\n id?: string;\n productId: string;\n productName: string;\n quantity: number;\n price: number;\n unit: string;\n seller: string;\n }>;\n subtotal?: number;\n tax?: number;\n shipping?: number;\n total: number;\n // BOFF-6090: a promo CODE, never a discount amount — the server validates it against\n // global-store and computes discountAmount itself; a client-supplied number is never trusted.\n promoCode?: string;\n deliveryDate?: string;\n};\ntype UpdateMarketplaceOrderInput = {\n id: string;\n // Lifecycle: pending | confirmed | shipped | delivered | cancelled (validated server-side).\n status?: string;\n // Payment: pending | paid | refunded (validated server-side).\n paymentStatus?: string;\n deliveryDate?: string;\n};\ntype CreateComplianceDocumentInput = {\n title: string;\n type: string;\n status?: string;\n fileUrl?: string;\n fileId?: string;\n fileName?: string;\n certificationId?: string;\n};\ntype CreateCertificationInput = {\n name: string;\n standard: string;\n certifyingBody: string;\n issuedDate: string;\n expiryDate: string;\n status?: string;\n scope?: string[];\n};\ntype CreateProductionBatchInput = {\n batchNumber: string;\n productId?: string;\n recipeId?: string;\n status?: string;\n quantity: number;\n unit: string;\n startDate: string;\n completionDate?: string;\n qualityScore?: number;\n cost?: number;\n};\ntype CreateConsultationInput = {\n consultantType: ConsultantType;\n consultantId: string;\n consultantName: string;\n topic: string;\n requestedDate: string;\n mode: ConsultationMode;\n notes?: string;\n fee?: number;\n /**\n * BOFF-6081 — link the booking back to an AI plant scan (the INCONCLUSIVE\n * hand-off). The scan's context is stamped with the created consultation id.\n */\n plantScanId?: string;\n};\ntype UpdatePestIssueInput = {\n id: string;\n pestName?: string;\n type?: string;\n cropAffected?: string;\n severity?: string;\n status?: PestIssue['status'];\n detectedDate?: string;\n treatment?: string;\n};\n\nconst UPDATE_PEST_ISSUE_DOC = gql`\n mutation UpdateHealthyBowlPestIssue($input: UpdatePestIssueInput!) {\n updateHealthyBowlPestIssue(input: $input) {\n id\n }\n }\n`;\ntype UpdateAuditInput = {\n id: string;\n title?: string;\n type?: 'internal' | 'external' | 'certification';\n auditor?: string;\n scheduledDate?: string;\n completedDate?: string;\n status?: 'scheduled' | 'in_progress' | 'completed' | 'failed';\n findings?: number;\n criticalFindings?: number;\n score?: number;\n};\n\nconst UPDATE_AUDIT_DOC = gql`\n mutation UpdateHealthyBowlAudit($input: UpdateAuditInput!) {\n updateHealthyBowlAudit(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_HEALTH_RECORD_DOC = gql`\n mutation UpdateHealthyBowlHealthRecord($input: UpdateHealthRecordInput!) {\n updateHealthyBowlHealthRecord(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_FEED_RECORD_DOC = gql`\n mutation UpdateHealthyBowlFeedRecord($input: UpdateFeedRecordInput!) {\n updateHealthyBowlFeedRecord(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_VACCINATION_DOC = gql`\n mutation UpdateHealthyBowlVaccination($input: UpdateVaccinationInput!) {\n updateHealthyBowlVaccination(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_BREEDING_RECORD_DOC = gql`\n mutation UpdateHealthyBowlBreedingRecord($input: UpdateBreedingRecordInput!) {\n updateHealthyBowlBreedingRecord(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_PRODUCTION_RECORD_DOC = gql`\n mutation UpdateHealthyBowlProductionRecord($input: UpdateProductionRecordInput!) {\n updateHealthyBowlProductionRecord(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_PLANTING_PLAN_DOC = gql`\n mutation UpdateHealthyBowlPlantingPlan($input: UpdatePlantingPlanInput!) {\n updateHealthyBowlPlantingPlan(input: $input) {\n id\n cropId\n fieldId\n }\n }\n`;\nconst DELETE_PLANTING_PLAN_DOC = gql`\n mutation DeleteHealthyBowlPlantingPlan($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlPlantingPlan(id: $id, context: $context)\n }\n`;\nconst UPDATE_HARVEST_RECORD_DOC = gql`\n mutation UpdateHealthyBowlHarvestRecord($input: UpdateHarvestRecordInput!) {\n updateHealthyBowlHarvestRecord(input: $input) {\n id\n }\n }\n`;\nconst DELETE_HARVEST_RECORD_DOC = gql`\n mutation DeleteHealthyBowlHarvestRecord($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlHarvestRecord(id: $id, context: $context)\n }\n`;\nconst DELETE_VACCINATION_DOC = gql`\n mutation DeleteHealthyBowlVaccination($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlVaccination(id: $id, context: $context)\n }\n`;\nconst DELETE_HEALTH_RECORD_DOC = gql`\n mutation DeleteHealthyBowlHealthRecord($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlHealthRecord(id: $id, context: $context)\n }\n`;\nconst DELETE_FEED_RECORD_DOC = gql`\n mutation DeleteHealthyBowlFeedRecord($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlFeedRecord(id: $id, context: $context)\n }\n`;\nconst DELETE_BREEDING_RECORD_DOC = gql`\n mutation DeleteHealthyBowlBreedingRecord($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlBreedingRecord(id: $id, context: $context)\n }\n`;\nconst DELETE_PRODUCTION_RECORD_DOC = gql`\n mutation DeleteHealthyBowlProductionRecord($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlProductionRecord(id: $id, context: $context)\n }\n`;\nconst CREATE_PRODUCT_DOC = gql`\n mutation CreateHealthyBowlProduct($input: CreateHealthyBowlProductInput!) {\n createHealthyBowlProduct(input: $input) {\n id\n }\n }\n`;\nconst UPDATE_PRODUCT_DOC = gql`\n mutation UpdateHealthyBowlProduct($input: UpdateHealthyBowlProductInput!) {\n updateHealthyBowlProduct(input: $input) {\n id\n }\n }\n`;\nconst DELETE_PRODUCT_DOC = gql`\n mutation DeleteHealthyBowlProduct($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlProduct(id: $id, context: $context)\n }\n`;\nconst ADJUST_PRODUCT_STOCK_DOC = gql`\n mutation AdjustHealthyBowlProductStock($input: AdjustHealthyBowlProductStockInput!) {\n adjustHealthyBowlProductStock(input: $input) {\n id\n productId\n direction\n quantity\n unit\n reason\n notes\n occurredAt\n }\n }\n`;\n/**\n * ★ NO PAYMENT FIELDS, and this is not an oversight.\n *\n * BOFF-6030's consultation-payment UI landed on main on 2026-09-02 (#328) without its backend half.\n * `type Consultation` in wspace-healthybowl-svc has no paymentStatus / paymentProvider /\n * paymentReference / paidAmount / paidAt, and PRs #248 and #249 are closed unmerged. A GraphQL\n * validation error rejects the WHOLE document, so selecting them took six prod pages down for 38\n * minutes on 2026-09-18 and forced the BOFF-7341 repin to be rolled back. Restore them together with\n * the backend fields, never before, and run scripts/schema-preflight.md first.\n *\n * ★★ The reasoning lives HERE rather than as a `#` comment inside the document. A GraphQL comment is\n * part of the document STRING: the bundler preserves it and it is transmitted to the gateway on\n * every single request. The first version of this note was six lines of incident history riding\n * along on every consultation fetch. TypeScript comments are stripped at build; GraphQL ones are not.\n */\nconst CREATE_CONSULTATION_DOC = gql`\n mutation CreateHealthyBowlConsultation($input: CreateConsultationInput!) {\n createHealthyBowlConsultation(input: $input) {\n id\n consultantType\n consultantId\n consultantName\n topic\n requestedDate\n mode\n notes\n fee\n status\n # No payment fields until BOFF-6030's backend lands — see the note above this document.\n createdAt\n }\n }\n`;\n/**\n * ★ NO PAYMENT FIELDS, and this is not an oversight.\n *\n * BOFF-6030's consultation-payment UI landed on main on 2026-09-02 (#328) without its backend half.\n * `type Consultation` in wspace-healthybowl-svc has no paymentStatus / paymentProvider /\n * paymentReference / paidAmount / paidAt, and PRs #248 and #249 are closed unmerged. A GraphQL\n * validation error rejects the WHOLE document, so selecting them took six prod pages down for 38\n * minutes on 2026-09-18 and forced the BOFF-7341 repin to be rolled back. Restore them together with\n * the backend fields, never before, and run scripts/schema-preflight.md first.\n *\n * ★★ The reasoning lives HERE rather than as a `#` comment inside the document. A GraphQL comment is\n * part of the document STRING: the bundler preserves it and it is transmitted to the gateway on\n * every single request. The first version of this note was six lines of incident history riding\n * along on every consultation fetch. TypeScript comments are stripped at build; GraphQL ones are not.\n */\nconst GET_CONSULTATIONS_DOC = gql`\n query GetHealthyBowlConsultations($context: ContextInput!) {\n getHealthyBowlConsultations(context: $context) {\n id\n consultantType\n consultantId\n consultantName\n topic\n requestedDate\n mode\n notes\n fee\n status\n # No payment fields until BOFF-6030's backend lands — see the note above this document.\n createdAt\n }\n }\n`;\n\ntype UpdateConsultationStatusInput = {\n id: string;\n status: ConsultationStatus;\n};\n\n/**\n * ★ NO PAYMENT FIELDS, and this is not an oversight.\n *\n * BOFF-6030's consultation-payment UI landed on main on 2026-09-02 (#328) without its backend half.\n * `type Consultation` in wspace-healthybowl-svc has no paymentStatus / paymentProvider /\n * paymentReference / paidAmount / paidAt, and PRs #248 and #249 are closed unmerged. A GraphQL\n * validation error rejects the WHOLE document, so selecting them took six prod pages down for 38\n * minutes on 2026-09-18 and forced the BOFF-7341 repin to be rolled back. Restore them together with\n * the backend fields, never before, and run scripts/schema-preflight.md first.\n *\n * ★★ The reasoning lives HERE rather than as a `#` comment inside the document. A GraphQL comment is\n * part of the document STRING: the bundler preserves it and it is transmitted to the gateway on\n * every single request. The first version of this note was six lines of incident history riding\n * along on every consultation fetch. TypeScript comments are stripped at build; GraphQL ones are not.\n */\nconst UPDATE_CONSULTATION_STATUS_DOC = gql`\n mutation UpdateHealthyBowlConsultationStatus($input: UpdateHealthyBowlConsultationStatusInput!) {\n updateHealthyBowlConsultationStatus(input: $input) {\n id\n consultantType\n consultantId\n consultantName\n topic\n requestedDate\n mode\n notes\n fee\n status\n # No payment fields until BOFF-6030's backend lands — see the note above this document.\n createdAt\n }\n }\n`;\n\nconst CREATE_FARM_EVENT_DOC = gql`\n mutation CreateHealthyBowlFarmEvent($input: CreateFarmEventInput!) {\n createHealthyBowlFarmEvent(input: $input) {\n id\n title\n date\n }\n }\n`;\nconst CREATE_ORDER_DOC = gql`\n mutation CreateHealthyBowlOrder($input: CreateMarketplaceOrderInput!) {\n createHealthyBowlOrder(input: $input) {\n id\n orderNumber\n status\n paymentStatus\n total\n # BOFF-6090: the server-computed discount actually applied (0 when no code was used).\n discountAmount\n }\n }\n`;\nconst UPDATE_ORDER_DOC = gql`\n mutation UpdateHealthyBowlOrder($input: UpdateMarketplaceOrderInput!) {\n updateHealthyBowlOrder(input: $input) {\n id\n orderNumber\n status\n paymentStatus\n deliveryDate\n total\n }\n }\n`;\nconst CREATE_COMPLIANCE_DOCUMENT_DOC = gql`\n mutation CreateHealthyBowlComplianceDocument($input: CreateComplianceDocumentInput!) {\n createHealthyBowlComplianceDocument(input: $input) {\n id\n name\n status\n }\n }\n`;\nconst CREATE_CERTIFICATION_DOC = gql`\n mutation CreateHealthyBowlCertification($input: CreateCertificationInput!) {\n createHealthyBowlCertification(input: $input) {\n id\n name\n status\n }\n }\n`;\nconst CREATE_PRODUCTION_BATCH_DOC = gql`\n mutation CreateHealthyBowlProductionBatch($input: CreateProductionBatchInput!) {\n createHealthyBowlProductionBatch(input: $input) {\n id\n batchNumber\n status\n }\n }\n`;\n\nconst UPDATE_BUDGET_DOC = gql`\n mutation UpdateHealthyBowlBudget($input: UpdateBudgetInput!) {\n updateHealthyBowlBudget(input: $input) {\n id\n name\n category\n period\n allocated\n spent\n remaining\n status\n }\n }\n`;\n\nconst UPDATE_INVOICE_DOC = gql`\n mutation UpdateHealthyBowlInvoice($input: UpdateInvoiceInput!) {\n updateHealthyBowlInvoice(input: $input) {\n id\n invoiceNumber\n customer\n status\n subtotal\n tax\n total\n }\n }\n`;\n\ntype UpdateBudgetFields = {\n id: string;\n name?: string;\n category?: string;\n period?: string;\n allocated?: number;\n spent?: number;\n status?: string;\n};\n\ntype UpdateInvoiceFields = {\n id: string;\n customer?: string;\n amount?: number;\n dueDate?: string;\n tax?: number;\n status?: string;\n};\n\ntype RevenueChartPoint = { month: string; revenue: number; expenses: number };\ntype CropDistributionPoint = { name: string; value: number; color: string };\ntype YieldTrendPoint = { month: string; tomatoes: number; peppers: number; lettuce: number; basil: number };\ntype GovernmentMessage = {\n id: string;\n from: string;\n department: string;\n subject: string;\n preview: string;\n body: string;\n date: string;\n unread: boolean;\n};\ntype GovernmentAnnouncement = {\n id: string;\n title: string;\n date: string;\n category: string;\n content: string;\n};\ntype GovernmentNotification = {\n id: string;\n title: string;\n description: string;\n date: string;\n type: 'scheme_update' | 'status_change' | 'deadline' | 'new_scheme';\n read: boolean;\n};\ntype GovernmentActivityItem = {\n id: string;\n type: 'submitted' | 'status_change' | 'new_scheme' | 'disbursement' | 'deadline';\n title: string;\n description: string;\n date: string;\n};\ntype BenefitsChartPoint = { month: string; amount: number };\ntype EventAgendaItem = { time: string; session: string };\ntype WeatherHistoryRecord = {\n id: string;\n date: string;\n tempMax: number;\n tempMin: number;\n tempAvg: number;\n humidity: number;\n rainfall: number;\n windSpeed: number;\n condition: 'sunny' | 'cloudy' | 'rainy' | 'stormy';\n sunrise: string;\n sunset: string;\n uvIndex: number;\n pressure: number;\n};\ntype WeatherMonthlySummary = {\n id: string;\n month: string;\n year: number;\n avgTemp: number;\n totalRainfall: number;\n rainyDays: number;\n sunnyDays: number;\n avgHumidity: number;\n extremeEvents: number;\n};\ntype FarmInsight = {\n id: string;\n title: string;\n description: string;\n confidence: number;\n category: string;\n action: string;\n};\ntype SoilSensorReading = {\n fieldId: string;\n fieldName: string;\n moisture: number;\n temperature: number;\n moistureThreshold: number;\n tempThreshold: number;\n lastUpdated: string;\n};\n\n/**\n * Arguments for `createHarvestRecord`.\n *\n * The four I-8 linkage fields (`addToInventory`, `productCategory`, `plantingPlanId`, `bedId`) were\n * once re-declared here, because the local `CreateHarvestRecordInput` lagged the deployed schema and\n * did not carry them (BOFF-6095). It did not lag — codegen had simply never run successfully on the\n * machine, and could not: `node_modules` had escaped into a parent store holding a second copy of\n * `graphql`. With that fixed the generated input carries all four, so the hand-widening for them is\n * gone (BOFF-6209).\n *\n * `clientMutationId` (BOFF-6094) is re-declared here for the same reason those four once were: it is\n * a real, gateway-accepted field on `createHealthyBowlHarvestRecord` as of this change, but the local\n * generated `CreateHarvestRecordInput` won't carry it until the next `schema:pull`. Drop this\n * intersection once that runs and the generated type includes it natively.\n *\n * The alias is kept because three call sites use it.\n */\n/**\n * Update args widened past the generated input (BOFF-6056).\n *\n * `plantingPlanId` is newer than the committed `graphql/wspace.graphql` snapshot codegen validates\n * against, so the generated `UpdateHarvestRecordInput` does not carry it yet. Same escape hatch as\n * `HarvestRecordCreateArgs` below; drop the widening once the snapshot is re-pulled post-merge.\n */\nexport type HarvestRecordUpdateArgs = UpdateHarvestRecordInput & {\n /**\n * Attach a banked harvest to the plan it came from, so plan-vs-actual counts it.\n *\n * Three states, and the type has to permit all three: absent leaves an existing link alone,\n * `null` detaches it, an id attaches it. Typing this `string | undefined` would make the detach\n * unrepresentable and the UI's \"Not linked to a plan\" option a no-op.\n */\n plantingPlanId?: string | null;\n};\n\nexport type HarvestRecordCreateArgs = Omit<CreateHarvestRecordInput, 'context'> & {\n /**\n * Client-generated idempotency key (BOFF-6094). A retried/duplicate submit of the\n * same key — a double-click, a dropped-response retry — returns the original\n * harvest instead of recording (and banking) it a second time. Mint one per\n * harvest-recording attempt with `crypto.randomUUID()`.\n */\n clientMutationId?: string;\n};\n\nexport interface HealthyBowlDataBundle {\n alerts: Alert[];\n analyticsKPIs: AnalyticsKPI[];\n crops: Crop[];\n dashboardStats: DashboardStats;\n dailyHistory: WeatherHistoryRecord[];\n fields: Field[];\n farm: Farm;\n harvests: HarvestRecord[];\n invoices: Invoice[];\n monthlySummaries: WeatherMonthlySummary[];\n plantingPlans: PlantingPlan[];\n productionBatches: ProductionBatch[];\n products: Product[];\n revenueChartData: RevenueChartPoint[];\n recipes: Recipe[];\n sensorReadings: SoilSensorReading[];\n soilTests: SoilTest[];\n traceBatches: TraceBatch[];\n transactions: Transaction[];\n weatherData: WeatherData;\n budgets: Budget[];\n governmentSchemes: GovernmentScheme[];\n messages: GovernmentMessage[];\n marketplaceProducts: MarketplaceProduct[];\n notifications: GovernmentNotification[];\n orders: Order[];\n benefitsChart: BenefitsChartPoint[];\n activity: GovernmentActivityItem[];\n announcements: GovernmentAnnouncement[];\n animals: Animal[];\n breedingRecords: BreedingRecord[];\n feedRecords: FeedRecord[];\n healthRecords: HealthRecord[];\n productionRecords: ProductionRecord[];\n /**\n * Records still held in the workspace whose animal has left the herd. Every\n * livestock list is scoped to animals still present (BOFF-6009), so removing an\n * animal silently drops its rows from every total; this is the number that lets\n * the UI say so instead of leaving the farmer to guess.\n */\n recordsForRemovedAnimals: number;\n schemeApplications: SchemeApplication[];\n trainingPrograms: TrainingProgram[];\n vaccinations: Vaccination[];\n analyticsReports: AnalyticsReport[];\n cropDistributionData: CropDistributionPoint[];\n yieldTrendData: YieldTrendPoint[];\n insights: FarmInsight[];\n audits: Audit[];\n certifications: Certification[];\n complianceDocuments: ComplianceDocument[];\n communityPosts: CommunityPost[];\n events: FarmEvent[];\n experts: Expert[];\n mentors: Mentor[];\n agenda: EventAgendaItem[];\n consultations: Consultation[];\n pestIssues: PestIssue[];\n treatments: Treatment[];\n loading: boolean;\n error: Error | null;\n // Per-domain query errors, so a page can show an honest error state for ITS data instead of\n // masking a failed query as an empty state. (The aggregate `error` above is any-slice-failed.)\n errors: {\n government: Error | null;\n weather: Error | null;\n analytics: Error | null;\n network: Error | null;\n soil: Error | null;\n dashboard: Error | null;\n crops: Error | null;\n livestock: Error | null;\n financial: Error | null;\n marketplace: Error | null;\n production: Error | null;\n products: Error | null;\n traceability: Error | null;\n compliance: Error | null;\n pest: Error | null;\n };\n // Per-domain loading flags, so a page gates its loader on ITS OWN slice\n // instead of the aggregate `loading` above (which ORs every query and would\n // over-eagerly spinner a page while an unrelated slice is still fetching).\n loadings: {\n government: boolean;\n weather: boolean;\n analytics: boolean;\n network: boolean;\n soil: boolean;\n dashboard: boolean;\n crops: boolean;\n livestock: boolean;\n financial: boolean;\n marketplace: boolean;\n production: boolean;\n products: boolean;\n traceability: boolean;\n compliance: boolean;\n pest: boolean;\n };\n refetch: () => Promise<unknown>;\n /** Refresh just the trace-batch list (after a publish/unpublish) without refetching everything. */\n refetchTraceabilityData: () => Promise<unknown>;\n markAlertRead: (alertId: string, read?: boolean) => Promise<boolean>;\n /**\n * BOFF-6112 — persist government-notification read-state.\n *\n * Bulk by design: \"mark all read\" is the common action, and one call per notification leaves a\n * half-applied state visible if the network drops mid-way.\n */\n markGovernmentNotificationRead: (notificationIds: string[], read?: boolean) => Promise<number>;\n // CRUD mutations\n createCrop: (input: Omit<CreateCropInput, 'context'>) => Promise<unknown>;\n updateCrop: (input: Omit<UpdateCropInput, 'context'>) => Promise<unknown>;\n deleteCrop: (id: string) => Promise<boolean>;\n createAnimal: (input: Omit<CreateAnimalInput, 'context'>) => Promise<unknown>;\n updateAnimal: (input: Omit<UpdateAnimalInput, 'context'>) => Promise<unknown>;\n deleteAnimal: (id: string) => Promise<boolean>;\n createFarm: (input: Omit<CreateFarmInput, 'context'>) => Promise<unknown>;\n updateFarm: (input: Omit<UpdateFarmInput, 'context'>) => Promise<unknown>;\n createField: (input: CreateFieldInput) => Promise<unknown>;\n updateField: (input: UpdateFieldInput) => Promise<unknown>;\n deleteField: (id: string) => Promise<boolean>;\n createMarketplaceProduct: (input: Omit<CreateMarketplaceProductInput, 'context'>) => Promise<unknown>;\n updateMarketplaceProduct: (input: Omit<UpdateMarketplaceProductInput, 'context'>) => Promise<unknown>;\n deleteMarketplaceProduct: (id: string) => Promise<boolean>;\n createTransaction: (input: Omit<CreateHealthyBowlTransactionInput, 'context'>) => Promise<unknown>;\n updateTransaction: (input: Omit<UpdateHealthyBowlTransactionInput, 'context'>) => Promise<unknown>;\n deleteTransaction: (id: string) => Promise<boolean>;\n /** Resolve a fresh, short-lived Files-authorized URL for a persisted transaction receipt. */\n getTransactionReceiptUrl: (transactionId: string) => Promise<string>;\n createPlantingPlan: (input: Omit<CreatePlantingPlanInput, 'context'>) => Promise<unknown>;\n createHarvestRecord: (input: HarvestRecordCreateArgs) => Promise<unknown>;\n createHealthRecord: (input: Omit<CreateHealthRecordInput, 'context'>) => Promise<unknown>;\n createFeedRecord: (input: Omit<CreateFeedRecordInput, 'context'>) => Promise<unknown>;\n createVaccination: (input: Omit<CreateVaccinationInput, 'context'>) => Promise<unknown>;\n createBreedingRecord: (input: Omit<CreateBreedingRecordInput, 'context'>) => Promise<unknown>;\n createProductionRecord: (input: Omit<CreateProductionRecordInput, 'context'>) => Promise<unknown>;\n updateHealthRecord: (input: UpdateHealthRecordInput) => Promise<unknown>;\n updateFeedRecord: (input: UpdateFeedRecordInput) => Promise<unknown>;\n updateVaccination: (input: UpdateVaccinationInput) => Promise<unknown>;\n updateBreedingRecord: (input: UpdateBreedingRecordInput) => Promise<unknown>;\n updateProductionRecord: (input: UpdateProductionRecordInput) => Promise<unknown>;\n updatePlantingPlan: (input: UpdatePlantingPlanInput) => Promise<unknown>;\n deletePlantingPlan: (id: string) => Promise<boolean>;\n updateHarvestRecord: (input: HarvestRecordUpdateArgs) => Promise<unknown>;\n deleteHarvestRecord: (id: string) => Promise<boolean>;\n deleteVaccination: (id: string) => Promise<boolean>;\n deleteHealthRecord: (id: string) => Promise<boolean>;\n deleteFeedRecord: (id: string) => Promise<boolean>;\n deleteBreedingRecord: (id: string) => Promise<boolean>;\n deleteProductionRecord: (id: string) => Promise<boolean>;\n createProduct: (input: CreateHealthyBowlProductInput) => Promise<unknown>;\n updateProduct: (input: UpdateHealthyBowlProductInput) => Promise<unknown>;\n /** Apply a stock delta through the movement ledger (BOFF-6371) — never write `stock` directly. */\n adjustProductStock: (input: AdjustHealthyBowlProductStockInput) => Promise<unknown>;\n deleteProduct: (id: string) => Promise<boolean>;\n createFarmEvent: (input: CreateFarmEventInput) => Promise<unknown>;\n updateFarmEvent: (input: Omit<UpdateFarmEventInput, 'context'>) => Promise<unknown>;\n deleteFarmEvent: (id: string) => Promise<boolean>;\n createOrder: (input: CreateMarketplaceOrderInput) => Promise<unknown>;\n updateOrder: (input: UpdateMarketplaceOrderInput) => Promise<unknown>;\n createComplianceDocument: (input: CreateComplianceDocumentInput) => Promise<unknown>;\n updateComplianceDocument: (input: Omit<UpdateComplianceDocumentInput, 'context'>) => Promise<unknown>;\n deleteComplianceDocument: (id: string) => Promise<boolean>;\n createCertification: (input: CreateCertificationInput) => Promise<unknown>;\n updateCertification: (input: Omit<UpdateCertificationInput, 'context'>) => Promise<unknown>;\n deleteCertification: (id: string) => Promise<boolean>;\n createProductionBatch: (input: CreateProductionBatchInput) => Promise<unknown>;\n createSoilTest: (input: Omit<CreateSoilTestInput, 'context'>) => Promise<unknown>;\n createPestIssue: (input: Omit<CreatePestIssueInput, 'context'>) => Promise<unknown>;\n updatePestIssue: (input: UpdatePestIssueInput) => Promise<unknown>;\n createTreatment: (input: Omit<CreateTreatmentInput, 'context'>) => Promise<unknown>;\n createRecipe: (input: Omit<CreateRecipeInput, 'context'>) => Promise<unknown>;\n updateRecipe: (input: Omit<UpdateRecipeInput, 'context'>) => Promise<unknown>;\n deleteRecipe: (id: string) => Promise<boolean>;\n createBudget: (input: Omit<CreateBudgetInput, 'context'>) => Promise<unknown>;\n createInvoice: (input: Omit<CreateInvoiceInput, 'context'>) => Promise<unknown>;\n updateBudget: (input: UpdateBudgetFields) => Promise<unknown>;\n updateInvoice: (input: UpdateInvoiceFields) => Promise<unknown>;\n createAudit: (input: Omit<CreateAuditInput, 'context'>) => Promise<unknown>;\n updateAudit: (input: UpdateAuditInput) => Promise<unknown>;\n updateSoilTest: (input: Omit<UpdateSoilTestInput, 'context'>) => Promise<unknown>;\n deleteSoilTest: (id: string) => Promise<boolean>;\n updateTreatment: (input: Omit<UpdateTreatmentInput, 'context'>) => Promise<unknown>;\n deleteTreatment: (id: string) => Promise<boolean>;\n deletePestIssue: (id: string) => Promise<boolean>;\n deleteBudget: (id: string) => Promise<boolean>;\n deleteInvoice: (id: string) => Promise<boolean>;\n deleteAudit: (id: string) => Promise<boolean>;\n createTraceBatch: (input: Omit<CreateTraceBatchInput, 'context'>) => Promise<unknown>;\n updateTraceBatch: (input: Omit<UpdateTraceBatchInput, 'context'>) => Promise<unknown>;\n /** Recall a batch (BOFF-6044): sets RECALLED, unpublishes, and notifies the owner. */\n recallTraceBatch: (id: string, reason?: string) => Promise<unknown>;\n deleteTraceBatch: (id: string) => Promise<boolean>;\n createCommunityPost: (input: Omit<CreateCommunityPostInput, 'context'>) => Promise<unknown>;\n createConsultation: (input: CreateConsultationInput) => Promise<unknown>;\n updateConsultationStatus: (input: UpdateConsultationStatusInput) => Promise<unknown>;\n createExpert: (input: Omit<CreateExpertInput, 'context'>) => Promise<unknown>;\n updateExpert: (input: Omit<UpdateExpertInput, 'context'>) => Promise<unknown>;\n deleteExpert: (id: string) => Promise<boolean>;\n createMentor: (input: Omit<CreateMentorInput, 'context'>) => Promise<unknown>;\n updateMentor: (input: Omit<UpdateMentorInput, 'context'>) => Promise<unknown>;\n deleteMentor: (id: string) => Promise<boolean>;\n createGovernmentScheme: (input: Omit<CreateGovernmentSchemeInput, 'context'>) => Promise<unknown>;\n updateGovernmentScheme: (input: Omit<UpdateGovernmentSchemeInput, 'context'>) => Promise<unknown>;\n deleteGovernmentScheme: (id: string) => Promise<boolean>;\n}\n\nconst EMPTY_DASHBOARD_STATS: DashboardStats = {\n totalRevenue: 0,\n totalExpenses: 0,\n netProfit: 0,\n activeCrops: 0,\n totalFields: 0,\n totalAnimals: 0,\n harvestDue: 0,\n pendingOrders: 0,\n weatherAlerts: 0,\n organicScore: 0,\n};\n\nconst EMPTY_FARM: Farm = {\n id: '',\n name: '',\n location: '',\n totalArea: 0,\n areaUnit: 'acres',\n organicCertified: false,\n owner: '',\n imageIds: [],\n};\n\nconst EMPTY_WEATHER: WeatherData = {\n location: '',\n current: {\n temperature: 0,\n humidity: 0,\n windSpeed: 0,\n windDirection: '',\n condition: '',\n icon: '',\n feelsLike: 0,\n uvIndex: 0,\n visibility: 0,\n pressure: 0,\n },\n forecast: [],\n alerts: [],\n};\n\nfunction readQueryArray<T>(value: unknown, fallback: T[]): T[] {\n return Array.isArray(value) ? (value as T[]) : fallback;\n}\n\nfunction readQueryValue<T>(value: unknown, fallback: T): T {\n return value === undefined || value === null ? fallback : (value as T);\n}\n\nexport function useHealthyBowlData(): HealthyBowlDataBundle {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || HEALTHYBOWL_FALLBACK_WORKSPACE_ID;\n\n const {\n data: governmentData,\n loading: governmentLoading,\n error: governmentError,\n refetch: refetchGovernmentData,\n } = useGetHealthyBowlGovernmentDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n // Fetch the full curated scheme catalog so the discovery page can filter and\n // sort client-side (the backend caps unbounded reads at 200 by default).\n limit: 1000,\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: analyticsData,\n loading: analyticsLoading,\n error: analyticsError,\n refetch: refetchAnalyticsData,\n } = useGetHealthyBowlAnalyticsDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: weatherData,\n loading: weatherLoading,\n error: weatherError,\n refetch: refetchWeatherData,\n } = useQuery<HealthyBowlWeatherDataQueryResult, { context: HBContext }>(GET_HEALTHYBOWL_WEATHER_DATA_DOC, {\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: networkData,\n loading: networkLoading,\n error: networkError,\n refetch: refetchNetworkData,\n } = useGetHealthyBowlNetworkDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n // Consultations query is not yet in the pulled microfe schema (no codegen hook\n // offline), so it is wired via a raw gql document. A later `schema:pull` +\n // `codegen` can replace this with a generated hook.\n // errorPolicy:'all' keeps this resilient: until the consultation subgraph (svc #38)\n // is composed into the gateway, a missing-field error degrades to an empty list\n // instead of throwing and breaking every page that mounts this shared hook. It is\n // deliberately NOT folded into the combined `error` below — consultations are an\n // additive, optional feature, not a hard dependency of the dashboard.\n const { data: consultationsData, refetch: refetchConsultations } = useQuery<\n { getHealthyBowlConsultations: Consultation[] },\n { context: HBContext }\n >(GET_CONSULTATIONS_DOC, {\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n errorPolicy: 'all',\n });\n\n const {\n data: soilData,\n loading: soilLoading,\n error: soilError,\n refetch: refetchSoilData,\n } = useGetHealthyBowlSoilDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: dashboardData,\n loading: dashboardLoading,\n error: dashboardError,\n refetch: refetchDashboardData,\n } = useGetHealthyBowlDashboardDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: cropsData,\n loading: cropsLoading,\n error: cropsError,\n refetch: refetchCropsData,\n } = useQuery<HealthyBowlCropsDataQueryResult, { context: HBContext }>(GET_HEALTHYBOWL_CROPS_DATA_DOC, {\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: livestockData,\n loading: livestockLoading,\n error: livestockError,\n refetch: refetchLivestockData,\n } = useGetHealthyBowlLivestockDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: financialData,\n loading: financialLoading,\n error: financialError,\n refetch: refetchFinancialData,\n } = useGetHealthyBowlFinancialDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n const [getTransactionReceiptUrlQuery] = useGetHealthyBowlTransactionReceiptUrlLazyQuery({\n // The response is a short-lived bearer URL. Always hit Files authorization and never retain the\n // URL in Apollo's normalized cache after the caller has opened it.\n fetchPolicy: 'no-cache',\n });\n\n const {\n data: marketplaceData,\n loading: marketplaceLoading,\n error: marketplaceError,\n refetch: refetchMarketplaceData,\n } = useGetHealthyBowlMarketplaceDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: productionData,\n loading: productionLoading,\n error: productionError,\n refetch: refetchProductionData,\n } = useGetHealthyBowlProductionDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: productsData,\n loading: productsLoading,\n error: productsError,\n refetch: refetchProductsData,\n } = useGetHealthyBowlProductsDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: traceabilityData,\n loading: traceabilityLoading,\n error: traceabilityError,\n refetch: refetchTraceabilityData,\n } = useGetHealthyBowlTraceabilityDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: complianceData,\n loading: complianceLoading,\n error: complianceError,\n refetch: refetchComplianceData,\n } = useGetHealthyBowlComplianceDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const {\n data: pestData,\n loading: pestLoading,\n error: pestError,\n refetch: refetchPestData,\n } = useGetHealthyBowlPestDataQuery({\n variables: {\n context: { workspaceId: effectiveWorkspaceId },\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const [markAlertReadMutation] = useMarkHealthyBowlAlertReadMutation();\n const [markGovernmentNotificationReadMutation] = useMarkHealthyBowlGovernmentNotificationReadMutation();\n const [createCropMutation] = useCreateHealthyBowlCropMutation();\n const [updateCropMutation] = useUpdateHealthyBowlCropMutation();\n const [deleteCropMutation] = useDeleteHealthyBowlCropMutation();\n const [createAnimalMutation] = useCreateHealthyBowlAnimalMutation();\n const [updateAnimalMutation] = useUpdateHealthyBowlAnimalMutation();\n const [deleteAnimalMutation] = useDeleteHealthyBowlAnimalMutation();\n const [createFarmMutation] = useCreateHealthyBowlFarmMutation();\n const [updateFarmMutation] = useUpdateHealthyBowlFarmMutation();\n const [createFieldMutation] = useCreateHealthyBowlFieldMutation();\n const [updateFieldMutation] = useUpdateHealthyBowlFieldMutation();\n const [deleteFieldMutation] = useDeleteHealthyBowlFieldMutation();\n const [createMarketplaceProductMutation] = useCreateHealthyBowlMarketplaceProductMutation();\n const [updateMarketplaceProductMutation] = useUpdateHealthyBowlMarketplaceProductMutation();\n const [deleteMarketplaceProductMutation] = useDeleteHealthyBowlMarketplaceProductMutation();\n const [createTransactionMutation] = useCreateHealthyBowlTransactionMutation();\n const [updateTransactionMutation] = useUpdateHealthyBowlTransactionMutation();\n const [deleteTransactionMutation] = useDeleteHealthyBowlTransactionMutation();\n const [createPlantingPlanMutation] = useCreateHealthyBowlPlantingPlanMutation();\n const [createHarvestRecordMutation] = useCreateHealthyBowlHarvestRecordMutation();\n const [createHealthRecordMutation] = useCreateHealthyBowlHealthRecordMutation();\n const [createFeedRecordMutation] = useCreateHealthyBowlFeedRecordMutation();\n const [createVaccinationMutation] = useCreateHealthyBowlVaccinationMutation();\n const [createBreedingRecordMutation] = useCreateHealthyBowlBreedingRecordMutation();\n const [createProductionRecordMutation] = useCreateHealthyBowlProductionRecordMutation();\n const [updatePestIssueMutation] = useMutation<\n { updateHealthyBowlPestIssue: { id: string } },\n { input: UpdatePestIssueInput & { context: HBContext } }\n >(UPDATE_PEST_ISSUE_DOC);\n const [updateAuditMutation] = useMutation<\n { updateHealthyBowlAudit: { id: string } },\n { input: UpdateAuditInput & { context: HBContext } }\n >(UPDATE_AUDIT_DOC);\n const [updateHealthRecordMutation] = useMutation<\n { updateHealthyBowlHealthRecord: { id: string } },\n { input: UpdateHealthRecordInput & { context: HBContext } }\n >(UPDATE_HEALTH_RECORD_DOC);\n const [updateFeedRecordMutation] = useMutation<\n { updateHealthyBowlFeedRecord: { id: string } },\n { input: UpdateFeedRecordInput & { context: HBContext } }\n >(UPDATE_FEED_RECORD_DOC);\n const [updateVaccinationMutation] = useMutation<\n { updateHealthyBowlVaccination: { id: string } },\n { input: UpdateVaccinationInput & { context: HBContext } }\n >(UPDATE_VACCINATION_DOC);\n const [updateBreedingRecordMutation] = useMutation<\n { updateHealthyBowlBreedingRecord: { id: string } },\n { input: UpdateBreedingRecordInput & { context: HBContext } }\n >(UPDATE_BREEDING_RECORD_DOC);\n const [updateProductionRecordMutation] = useMutation<\n { updateHealthyBowlProductionRecord: { id: string } },\n { input: UpdateProductionRecordInput & { context: HBContext } }\n >(UPDATE_PRODUCTION_RECORD_DOC);\n const [updatePlantingPlanMutation] = useMutation<\n { updateHealthyBowlPlantingPlan: { id: string } },\n { input: UpdatePlantingPlanInput & { context: HBContext } }\n >(UPDATE_PLANTING_PLAN_DOC);\n const [deletePlantingPlanMutation] = useMutation<\n { deleteHealthyBowlPlantingPlan: boolean },\n { id: string; context: HBContext }\n >(DELETE_PLANTING_PLAN_DOC);\n const [updateHarvestRecordMutation] = useMutation<\n { updateHealthyBowlHarvestRecord: { id: string } },\n { input: UpdateHarvestRecordInput & { context: HBContext } }\n >(UPDATE_HARVEST_RECORD_DOC);\n const [deleteHarvestRecordMutation] = useMutation<\n { deleteHealthyBowlHarvestRecord: boolean },\n { id: string; context: HBContext }\n >(DELETE_HARVEST_RECORD_DOC);\n const [deleteVaccinationMutation] = useMutation<\n { deleteHealthyBowlVaccination: boolean },\n { id: string; context: HBContext }\n >(DELETE_VACCINATION_DOC);\n const [deleteHealthRecordMutation] = useMutation<\n { deleteHealthyBowlHealthRecord: boolean },\n { id: string; context: HBContext }\n >(DELETE_HEALTH_RECORD_DOC);\n const [deleteFeedRecordMutation] = useMutation<\n { deleteHealthyBowlFeedRecord: boolean },\n { id: string; context: HBContext }\n >(DELETE_FEED_RECORD_DOC);\n const [deleteBreedingRecordMutation] = useMutation<\n { deleteHealthyBowlBreedingRecord: boolean },\n { id: string; context: HBContext }\n >(DELETE_BREEDING_RECORD_DOC);\n const [deleteProductionRecordMutation] = useMutation<\n { deleteHealthyBowlProductionRecord: boolean },\n { id: string; context: HBContext }\n >(DELETE_PRODUCTION_RECORD_DOC);\n const [createProductMutation] = useMutation<\n { createHealthyBowlProduct: { id: string } },\n { input: CreateHealthyBowlProductInput & { context: HBContext } }\n >(CREATE_PRODUCT_DOC);\n const [updateProductMutation] = useMutation<\n { updateHealthyBowlProduct: { id: string } },\n { input: UpdateHealthyBowlProductInput & { context: HBContext } }\n >(UPDATE_PRODUCT_DOC);\n const [deleteProductMutation] = useMutation<\n { deleteHealthyBowlProduct: boolean },\n { id: string; context: HBContext }\n >(DELETE_PRODUCT_DOC);\n const [adjustProductStockMutation] = useMutation<\n { adjustHealthyBowlProductStock: { id: string } },\n { input: AdjustHealthyBowlProductStockInput & { context: HBContext } }\n >(ADJUST_PRODUCT_STOCK_DOC);\n const [createFarmEventMutation] = useMutation<\n { createHealthyBowlFarmEvent: { id: string } },\n { input: CreateFarmEventInput & { context: HBContext } }\n >(CREATE_FARM_EVENT_DOC);\n const [createOrderMutation] = useMutation<\n { createHealthyBowlOrder: { id: string } },\n { input: CreateMarketplaceOrderInput & { context: HBContext } }\n >(CREATE_ORDER_DOC);\n const [updateOrderMutation] = useMutation<\n { updateHealthyBowlOrder: { id: string } },\n { input: UpdateMarketplaceOrderInput & { context: HBContext } }\n >(UPDATE_ORDER_DOC);\n const [createComplianceDocumentMutation] = useMutation<\n { createHealthyBowlComplianceDocument: { id: string } },\n { input: CreateComplianceDocumentInput & { context: HBContext } }\n >(CREATE_COMPLIANCE_DOCUMENT_DOC);\n const [createCertificationMutation] = useMutation<\n { createHealthyBowlCertification: { id: string } },\n { input: CreateCertificationInput & { context: HBContext } }\n >(CREATE_CERTIFICATION_DOC);\n const [createProductionBatchMutation] = useMutation<\n { createHealthyBowlProductionBatch: { id: string } },\n { input: CreateProductionBatchInput & { context: HBContext } }\n >(CREATE_PRODUCTION_BATCH_DOC);\n const [createConsultationMutation] = useMutation<\n { createHealthyBowlConsultation: Consultation },\n { input: CreateConsultationInput & { context: HBContext } }\n >(CREATE_CONSULTATION_DOC);\n const [updateConsultationStatusMutation] = useMutation<\n { updateHealthyBowlConsultationStatus: Consultation },\n { input: UpdateConsultationStatusInput & { context: HBContext } }\n >(UPDATE_CONSULTATION_STATUS_DOC);\n const [createSoilTestMutation] = useCreateHealthyBowlSoilTestMutation();\n const [updateSoilTestMutation] = useUpdateHealthyBowlSoilTestMutation();\n const [deleteSoilTestMutation] = useDeleteHealthyBowlSoilTestMutation();\n const [createPestIssueMutation] = useCreateHealthyBowlPestIssueMutation();\n const [deletePestIssueMutation] = useDeleteHealthyBowlPestIssueMutation();\n const [createTreatmentMutation] = useCreateHealthyBowlTreatmentMutation();\n const [updateTreatmentMutation] = useUpdateHealthyBowlTreatmentMutation();\n const [deleteTreatmentMutation] = useDeleteHealthyBowlTreatmentMutation();\n const [deleteBudgetMutation] = useDeleteHealthyBowlBudgetMutation();\n const [deleteInvoiceMutation] = useDeleteHealthyBowlInvoiceMutation();\n const [deleteAuditMutation] = useDeleteHealthyBowlAuditMutation();\n const [createRecipeMutation] = useCreateHealthyBowlRecipeMutation();\n const [updateRecipeMutation] = useUpdateHealthyBowlRecipeMutation();\n const [deleteRecipeMutation] = useDeleteHealthyBowlRecipeMutation();\n const [createBudgetMutation] = useCreateHealthyBowlBudgetMutation();\n const [createInvoiceMutation] = useCreateHealthyBowlInvoiceMutation();\n const [updateBudgetMutation] = useMutation<\n { updateHealthyBowlBudget: { id: string } },\n { input: UpdateBudgetFields & { context: HBContext } }\n >(UPDATE_BUDGET_DOC);\n const [updateInvoiceMutation] = useMutation<\n { updateHealthyBowlInvoice: { id: string } },\n { input: UpdateInvoiceFields & { context: HBContext } }\n >(UPDATE_INVOICE_DOC);\n const [createAuditMutation] = useCreateHealthyBowlAuditMutation();\n const [createTraceBatchMutation] = useCreateHealthyBowlTraceBatchMutation();\n const [updateTraceBatchMutation] = useUpdateHealthyBowlTraceBatchMutation();\n const [recallTraceBatchMutation] = useRecallHealthyBowlTraceBatchMutation();\n const [deleteTraceBatchMutation] = useDeleteHealthyBowlTraceBatchMutation();\n const [updateCertificationMutation] = useUpdateHealthyBowlCertificationMutation();\n const [deleteCertificationMutation] = useDeleteHealthyBowlCertificationMutation();\n const [updateComplianceDocumentMutation] = useUpdateHealthyBowlComplianceDocumentMutation();\n const [deleteComplianceDocumentMutation] = useDeleteHealthyBowlComplianceDocumentMutation();\n const [updateFarmEventMutation] = useUpdateHealthyBowlFarmEventMutation();\n const [deleteFarmEventMutation] = useDeleteHealthyBowlFarmEventMutation();\n const [createCommunityPostMutation] = useCreateHealthyBowlCommunityPostMutation();\n const [createExpertMutation] = useCreateHealthyBowlExpertMutation();\n const [updateExpertMutation] = useUpdateHealthyBowlExpertMutation();\n const [deleteExpertMutation] = useDeleteHealthyBowlExpertMutation();\n const [createMentorMutation] = useCreateHealthyBowlMentorMutation();\n const [updateMentorMutation] = useUpdateHealthyBowlMentorMutation();\n const [deleteMentorMutation] = useDeleteHealthyBowlMentorMutation();\n const [createGovernmentSchemeMutation] = useCreateHealthyBowlGovernmentSchemeMutation();\n const [updateGovernmentSchemeMutation] = useUpdateHealthyBowlGovernmentSchemeMutation();\n const [deleteGovernmentSchemeMutation] = useDeleteHealthyBowlGovernmentSchemeMutation();\n\n const refetch = useCallback(\n () =>\n Promise.all([\n refetchGovernmentData(),\n refetchWeatherData(),\n refetchAnalyticsData(),\n refetchNetworkData(),\n refetchSoilData(),\n refetchDashboardData(),\n refetchCropsData(),\n refetchLivestockData(),\n refetchFinancialData(),\n refetchMarketplaceData(),\n refetchProductionData(),\n refetchProductsData(),\n refetchTraceabilityData(),\n refetchComplianceData(),\n refetchPestData(),\n refetchConsultations(),\n ]),\n [\n refetchGovernmentData,\n refetchWeatherData,\n refetchAnalyticsData,\n refetchNetworkData,\n refetchSoilData,\n refetchDashboardData,\n refetchCropsData,\n refetchLivestockData,\n refetchFinancialData,\n refetchMarketplaceData,\n refetchProductionData,\n refetchProductsData,\n refetchTraceabilityData,\n refetchComplianceData,\n refetchPestData,\n refetchConsultations,\n ]\n );\n\n const markAlertRead = useCallback(\n async (alertId: string, read = true): Promise<boolean> => {\n const response = await markAlertReadMutation({\n variables: {\n input: {\n alertId,\n read,\n context: { workspaceId: effectiveWorkspaceId },\n },\n },\n });\n\n await refetch();\n return Boolean(response.data?.markHealthyBowlAlertRead?.success);\n },\n [effectiveWorkspaceId, markAlertReadMutation, refetch]\n );\n\n // ── CRUD mutation wrappers ─────────────────────────────────────────────\n const eventBus = useEventBus();\n const ctx = useMemo(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const createCrop = useCallback(\n async (input: Omit<CreateCropInput, 'context'>) => {\n const res = await createCropMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n const crop = res.data?.createHealthyBowlCrop;\n emitCropCreated(eventBus, crop, ctx.workspaceId);\n return crop;\n },\n [createCropMutation, ctx, refetchCropsData, eventBus]\n );\n const updateCrop = useCallback(\n async (input: Omit<UpdateCropInput, 'context'>) => {\n const res = await updateCropMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n const crop = res.data?.updateHealthyBowlCrop;\n emitCropUpdated(eventBus, crop, ctx.workspaceId);\n return crop;\n },\n [updateCropMutation, ctx, refetchCropsData, eventBus]\n );\n const deleteCrop = useCallback(\n async (id: string) => {\n const res = await deleteCropMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return true;\n },\n [deleteCropMutation, ctx, refetchCropsData]\n );\n\n const createAnimal = useCallback(\n async (input: Omit<CreateAnimalInput, 'context'>) => {\n const res = await createAnimalMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlAnimal;\n },\n [createAnimalMutation, ctx, refetchLivestockData]\n );\n const updateAnimal = useCallback(\n async (input: Omit<UpdateAnimalInput, 'context'>) => {\n const res = await updateAnimalMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlAnimal;\n },\n [updateAnimalMutation, ctx, refetchLivestockData]\n );\n const deleteAnimal = useCallback(\n async (id: string) => {\n const res = await deleteAnimalMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return true;\n },\n [deleteAnimalMutation, ctx, refetchLivestockData]\n );\n\n const createFarm = useCallback(\n async (input: Omit<CreateFarmInput, 'context'>) => {\n const res = await createFarmMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchDashboardData();\n const farm = res.data?.createHealthyBowlFarm;\n emitFarmCreated(eventBus, farm, ctx.workspaceId);\n return farm;\n },\n [createFarmMutation, ctx, refetchDashboardData, eventBus]\n );\n\n const updateFarm = useCallback(\n async (input: Omit<UpdateFarmInput, 'context'>) => {\n const res = await updateFarmMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchDashboardData();\n return res.data?.updateHealthyBowlFarm;\n },\n [updateFarmMutation, ctx, refetchDashboardData]\n );\n\n const createField = useCallback(\n async (input: CreateFieldInput) => {\n const res = await createFieldMutation({\n variables: { input: { ...input, type: input.type as GqlGrowLocationType | null | undefined, context: ctx } },\n });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.createHealthyBowlField;\n },\n [createFieldMutation, ctx, refetchCropsData]\n );\n const updateField = useCallback(\n async (input: UpdateFieldInput) => {\n const res = await updateFieldMutation({\n variables: { input: { ...input, type: input.type as GqlGrowLocationType | null | undefined, context: ctx } },\n });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.updateHealthyBowlField;\n },\n [updateFieldMutation, ctx, refetchCropsData]\n );\n const deleteField = useCallback(\n async (id: string) => {\n const res = await deleteFieldMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return true;\n },\n [deleteFieldMutation, ctx, refetchCropsData]\n );\n\n const createMarketplaceProduct = useCallback(\n async (input: Omit<CreateMarketplaceProductInput, 'context'>) => {\n const res = await createMarketplaceProductMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchMarketplaceData();\n return res.data?.createHealthyBowlMarketplaceProduct;\n },\n [createMarketplaceProductMutation, ctx, refetchMarketplaceData]\n );\n const updateMarketplaceProduct = useCallback(\n async (input: Omit<UpdateMarketplaceProductInput, 'context'>) => {\n const res = await updateMarketplaceProductMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchMarketplaceData();\n return res.data?.updateHealthyBowlMarketplaceProduct;\n },\n [updateMarketplaceProductMutation, ctx, refetchMarketplaceData]\n );\n const deleteMarketplaceProduct = useCallback(\n async (id: string) => {\n const res = await deleteMarketplaceProductMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchMarketplaceData();\n return true;\n },\n [deleteMarketplaceProductMutation, ctx, refetchMarketplaceData]\n );\n\n const createTransaction = useCallback(\n async (input: Omit<CreateHealthyBowlTransactionInput, 'context'>) => {\n const res = await createTransactionMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.createHealthyBowlTransaction;\n },\n [createTransactionMutation, ctx, refetchFinancialData]\n );\n const updateTransaction = useCallback(\n async (input: Omit<UpdateHealthyBowlTransactionInput, 'context'>) => {\n const res = await updateTransactionMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.updateHealthyBowlTransaction;\n },\n [updateTransactionMutation, ctx, refetchFinancialData]\n );\n const deleteTransaction = useCallback(\n async (id: string) => {\n const res = await deleteTransactionMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return true;\n },\n [deleteTransactionMutation, ctx, refetchFinancialData]\n );\n const getTransactionReceiptUrl = useCallback(\n async (transactionId: string): Promise<string> => {\n const res = await getTransactionReceiptUrlQuery({\n variables: { context: ctx, transactionId },\n });\n if (res.error) throw res.error;\n const url = res.data?.getHealthyBowlTransactionReceiptUrl;\n if (!url) throw new Error('Receipt is unavailable in this workspace.');\n return url;\n },\n [ctx, getTransactionReceiptUrlQuery]\n );\n\n // ── New CRUD mutations (16 entities) ──────────────────────────────────\n const createPlantingPlan = useCallback(\n async (input: Omit<CreatePlantingPlanInput, 'context'>) => {\n const res = await createPlantingPlanMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.createHealthyBowlPlantingPlan;\n },\n [createPlantingPlanMutation, ctx, refetchCropsData]\n );\n const createHarvestRecord = useCallback(\n async (input: HarvestRecordCreateArgs) => {\n const res = await createHarvestRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n const harvest = res.data?.createHealthyBowlHarvestRecord;\n emitHarvestRecorded(eventBus, harvest, ctx.workspaceId);\n return harvest;\n },\n [createHarvestRecordMutation, ctx, refetchCropsData, eventBus]\n );\n const createHealthRecord = useCallback(\n async (input: Omit<CreateHealthRecordInput, 'context'>) => {\n const res = await createHealthRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlHealthRecord;\n },\n [createHealthRecordMutation, ctx, refetchLivestockData]\n );\n const createFeedRecord = useCallback(\n async (input: Omit<CreateFeedRecordInput, 'context'>) => {\n const res = await createFeedRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlFeedRecord;\n },\n [createFeedRecordMutation, ctx, refetchLivestockData]\n );\n const createVaccination = useCallback(\n async (input: Omit<CreateVaccinationInput, 'context'>) => {\n const res = await createVaccinationMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlVaccination;\n },\n [createVaccinationMutation, ctx, refetchLivestockData]\n );\n const createBreedingRecord = useCallback(\n async (input: Omit<CreateBreedingRecordInput, 'context'>) => {\n const res = await createBreedingRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlBreedingRecord;\n },\n [createBreedingRecordMutation, ctx, refetchLivestockData]\n );\n const createProductionRecord = useCallback(\n async (input: Omit<CreateProductionRecordInput, 'context'>) => {\n const res = await createProductionRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.createHealthyBowlProductionRecord;\n },\n [createProductionRecordMutation, ctx, refetchLivestockData]\n );\n const updateHealthRecord = useCallback(\n async (input: UpdateHealthRecordInput) => {\n const res = await updateHealthRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlHealthRecord;\n },\n [updateHealthRecordMutation, ctx, refetchLivestockData]\n );\n const updateFeedRecord = useCallback(\n async (input: UpdateFeedRecordInput) => {\n const res = await updateFeedRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlFeedRecord;\n },\n [updateFeedRecordMutation, ctx, refetchLivestockData]\n );\n const updateVaccination = useCallback(\n async (input: UpdateVaccinationInput) => {\n const res = await updateVaccinationMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlVaccination;\n },\n [updateVaccinationMutation, ctx, refetchLivestockData]\n );\n const updateBreedingRecord = useCallback(\n async (input: UpdateBreedingRecordInput) => {\n const res = await updateBreedingRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlBreedingRecord;\n },\n [updateBreedingRecordMutation, ctx, refetchLivestockData]\n );\n const updateProductionRecord = useCallback(\n async (input: UpdateProductionRecordInput) => {\n const res = await updateProductionRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.updateHealthyBowlProductionRecord;\n },\n [updateProductionRecordMutation, ctx, refetchLivestockData]\n );\n const updatePlantingPlan = useCallback(\n async (input: UpdatePlantingPlanInput) => {\n const res = await updatePlantingPlanMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.updateHealthyBowlPlantingPlan;\n },\n [updatePlantingPlanMutation, ctx, refetchCropsData]\n );\n const deletePlantingPlan = useCallback(\n async (id: string) => {\n const res = await deletePlantingPlanMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.deleteHealthyBowlPlantingPlan ?? false;\n },\n [deletePlantingPlanMutation, ctx, refetchCropsData]\n );\n const updateHarvestRecord = useCallback(\n async (input: HarvestRecordUpdateArgs) => {\n const res = await updateHarvestRecordMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.updateHealthyBowlHarvestRecord;\n },\n [updateHarvestRecordMutation, ctx, refetchCropsData]\n );\n const deleteHarvestRecord = useCallback(\n async (id: string) => {\n const res = await deleteHarvestRecordMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchCropsData();\n return res.data?.deleteHealthyBowlHarvestRecord ?? false;\n },\n [deleteHarvestRecordMutation, ctx, refetchCropsData]\n );\n const deleteVaccination = useCallback(\n async (id: string) => {\n const res = await deleteVaccinationMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.deleteHealthyBowlVaccination ?? false;\n },\n [deleteVaccinationMutation, ctx, refetchLivestockData]\n );\n const deleteHealthRecord = useCallback(\n async (id: string) => {\n const res = await deleteHealthRecordMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.deleteHealthyBowlHealthRecord ?? false;\n },\n [deleteHealthRecordMutation, ctx, refetchLivestockData]\n );\n const deleteFeedRecord = useCallback(\n async (id: string) => {\n const res = await deleteFeedRecordMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.deleteHealthyBowlFeedRecord ?? false;\n },\n [deleteFeedRecordMutation, ctx, refetchLivestockData]\n );\n const deleteBreedingRecord = useCallback(\n async (id: string) => {\n const res = await deleteBreedingRecordMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.deleteHealthyBowlBreedingRecord ?? false;\n },\n [deleteBreedingRecordMutation, ctx, refetchLivestockData]\n );\n const deleteProductionRecord = useCallback(\n async (id: string) => {\n const res = await deleteProductionRecordMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchLivestockData();\n return res.data?.deleteHealthyBowlProductionRecord ?? false;\n },\n [deleteProductionRecordMutation, ctx, refetchLivestockData]\n );\n const createProduct = useCallback(\n async (input: CreateHealthyBowlProductInput) => {\n const res = await createProductMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchProductsData();\n return res.data?.createHealthyBowlProduct;\n },\n [createProductMutation, ctx, refetchProductsData]\n );\n const updateProduct = useCallback(\n async (input: UpdateHealthyBowlProductInput) => {\n const res = await updateProductMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchProductsData();\n return res.data?.updateHealthyBowlProduct;\n },\n [updateProductMutation, ctx, refetchProductsData]\n );\n const adjustProductStock = useCallback(\n async (input: AdjustHealthyBowlProductStockInput) => {\n const res = await adjustProductStockMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchProductsData();\n return res.data?.adjustHealthyBowlProductStock;\n },\n [adjustProductStockMutation, ctx, refetchProductsData]\n );\n const deleteProduct = useCallback(\n async (id: string) => {\n const res = await deleteProductMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await refetchProductsData();\n return res.data?.deleteHealthyBowlProduct ?? false;\n },\n [deleteProductMutation, ctx, refetchProductsData]\n );\n const createFarmEvent = useCallback(\n async (input: CreateFarmEventInput) => {\n const res = await createFarmEventMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n // A post-create refresh blip must not surface as a create failure (the record WAS created).\n try {\n await refetchNetworkData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.createHealthyBowlFarmEvent;\n },\n [createFarmEventMutation, ctx, refetchNetworkData]\n );\n const updateFarmEvent = useCallback(\n async (input: Omit<UpdateFarmEventInput, 'context'>) => {\n const res = await updateFarmEventMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.updateHealthyBowlFarmEvent;\n },\n [updateFarmEventMutation, ctx, refetchNetworkData]\n );\n const deleteFarmEvent = useCallback(\n async (id: string) => {\n const res = await deleteFarmEventMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return true;\n },\n [deleteFarmEventMutation, ctx, refetchNetworkData]\n );\n const createOrder = useCallback(\n async (input: CreateMarketplaceOrderInput) => {\n const res = await createOrderMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n try {\n await refetchMarketplaceData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.createHealthyBowlOrder;\n },\n [createOrderMutation, ctx, refetchMarketplaceData]\n );\n const updateOrder = useCallback(\n async (input: UpdateMarketplaceOrderInput) => {\n const res = await updateOrderMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n try {\n await refetchMarketplaceData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.updateHealthyBowlOrder;\n },\n [updateOrderMutation, ctx, refetchMarketplaceData]\n );\n const createComplianceDocument = useCallback(\n async (input: CreateComplianceDocumentInput) => {\n const res = await createComplianceDocumentMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n try {\n await refetchComplianceData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.createHealthyBowlComplianceDocument;\n },\n [createComplianceDocumentMutation, ctx, refetchComplianceData]\n );\n const createCertification = useCallback(\n async (input: CreateCertificationInput) => {\n const res = await createCertificationMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n try {\n await refetchComplianceData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.createHealthyBowlCertification;\n },\n [createCertificationMutation, ctx, refetchComplianceData]\n );\n const updateCertification = useCallback(\n async (input: Omit<UpdateCertificationInput, 'context'>) => {\n const res = await updateCertificationMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return res.data?.updateHealthyBowlCertification;\n },\n [updateCertificationMutation, ctx, refetchComplianceData]\n );\n const deleteCertification = useCallback(\n async (id: string) => {\n const res = await deleteCertificationMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return true;\n },\n [deleteCertificationMutation, ctx, refetchComplianceData]\n );\n const updateComplianceDocument = useCallback(\n async (input: Omit<UpdateComplianceDocumentInput, 'context'>) => {\n const res = await updateComplianceDocumentMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return res.data?.updateHealthyBowlComplianceDocument;\n },\n [updateComplianceDocumentMutation, ctx, refetchComplianceData]\n );\n const deleteComplianceDocument = useCallback(\n async (id: string) => {\n const res = await deleteComplianceDocumentMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return true;\n },\n [deleteComplianceDocumentMutation, ctx, refetchComplianceData]\n );\n const createProductionBatch = useCallback(\n async (input: CreateProductionBatchInput) => {\n const res = await createProductionBatchMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n try {\n await refetchProductionData();\n } catch {\n /* non-fatal: the next refetch/load reconciles the list */\n }\n return res.data?.createHealthyBowlProductionBatch;\n },\n [createProductionBatchMutation, ctx, refetchProductionData]\n );\n const createSoilTest = useCallback(\n async (input: Omit<CreateSoilTestInput, 'context'>) => {\n const res = await createSoilTestMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchSoilData();\n return res.data?.createHealthyBowlSoilTest;\n },\n [createSoilTestMutation, ctx, refetchSoilData]\n );\n const createPestIssue = useCallback(\n async (input: Omit<CreatePestIssueInput, 'context'>) => {\n const res = await createPestIssueMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchPestData();\n return res.data?.createHealthyBowlPestIssue;\n },\n [createPestIssueMutation, ctx, refetchPestData]\n );\n const updatePestIssue = useCallback(\n async (input: UpdatePestIssueInput) => {\n const res = await updatePestIssueMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchPestData();\n return res.data?.updateHealthyBowlPestIssue;\n },\n [updatePestIssueMutation, ctx, refetchPestData]\n );\n const createTreatment = useCallback(\n async (input: Omit<CreateTreatmentInput, 'context'>) => {\n const res = await createTreatmentMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchPestData();\n return res.data?.createHealthyBowlTreatment;\n },\n [createTreatmentMutation, ctx, refetchPestData]\n );\n const createRecipe = useCallback(\n async (input: Omit<CreateRecipeInput, 'context'>) => {\n const res = await createRecipeMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchProductionData();\n return res.data?.createHealthyBowlRecipe;\n },\n [createRecipeMutation, ctx, refetchProductionData]\n );\n const updateRecipe = useCallback(\n async (input: Omit<UpdateRecipeInput, 'context'>) => {\n const res = await updateRecipeMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchProductionData();\n return res.data?.updateHealthyBowlRecipe;\n },\n [updateRecipeMutation, ctx, refetchProductionData]\n );\n const deleteRecipe = useCallback(\n async (id: string) => {\n const res = await deleteRecipeMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchProductionData();\n return true;\n },\n [deleteRecipeMutation, ctx, refetchProductionData]\n );\n const createBudget = useCallback(\n async (input: Omit<CreateBudgetInput, 'context'>) => {\n const res = await createBudgetMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.createHealthyBowlBudget;\n },\n [createBudgetMutation, ctx, refetchFinancialData]\n );\n const createInvoice = useCallback(\n async (input: Omit<CreateInvoiceInput, 'context'>) => {\n const res = await createInvoiceMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.createHealthyBowlInvoice;\n },\n [createInvoiceMutation, ctx, refetchFinancialData]\n );\n const updateBudget = useCallback(\n async (input: UpdateBudgetFields) => {\n const res = await updateBudgetMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.updateHealthyBowlBudget;\n },\n [updateBudgetMutation, ctx, refetchFinancialData]\n );\n const updateInvoice = useCallback(\n async (input: UpdateInvoiceFields) => {\n const res = await updateInvoiceMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return res.data?.updateHealthyBowlInvoice;\n },\n [updateInvoiceMutation, ctx, refetchFinancialData]\n );\n const createAudit = useCallback(\n async (input: Omit<CreateAuditInput, 'context'>) => {\n const res = await createAuditMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return res.data?.createHealthyBowlAudit;\n },\n [createAuditMutation, ctx, refetchComplianceData]\n );\n const updateAudit = useCallback(\n async (input: UpdateAuditInput) => {\n const res = await updateAuditMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return res.data?.updateHealthyBowlAudit;\n },\n [updateAuditMutation, ctx, refetchComplianceData]\n );\n const updateSoilTest = useCallback(\n async (input: Omit<UpdateSoilTestInput, 'context'>) => {\n const res = await updateSoilTestMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchSoilData();\n return res.data?.updateHealthyBowlSoilTest;\n },\n [updateSoilTestMutation, ctx, refetchSoilData]\n );\n const deleteSoilTest = useCallback(\n async (id: string) => {\n const res = await deleteSoilTestMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchSoilData();\n return true;\n },\n [deleteSoilTestMutation, ctx, refetchSoilData]\n );\n const updateTreatment = useCallback(\n async (input: Omit<UpdateTreatmentInput, 'context'>) => {\n const res = await updateTreatmentMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchPestData();\n return res.data?.updateHealthyBowlTreatment;\n },\n [updateTreatmentMutation, ctx, refetchPestData]\n );\n const deleteTreatment = useCallback(\n async (id: string) => {\n const res = await deleteTreatmentMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchPestData();\n return true;\n },\n [deleteTreatmentMutation, ctx, refetchPestData]\n );\n const deletePestIssue = useCallback(\n async (id: string) => {\n const res = await deletePestIssueMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchPestData();\n return true;\n },\n [deletePestIssueMutation, ctx, refetchPestData]\n );\n const deleteBudget = useCallback(\n async (id: string) => {\n const res = await deleteBudgetMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return true;\n },\n [deleteBudgetMutation, ctx, refetchFinancialData]\n );\n const deleteInvoice = useCallback(\n async (id: string) => {\n const res = await deleteInvoiceMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchFinancialData();\n return true;\n },\n [deleteInvoiceMutation, ctx, refetchFinancialData]\n );\n const deleteAudit = useCallback(\n async (id: string) => {\n const res = await deleteAuditMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchComplianceData();\n return true;\n },\n [deleteAuditMutation, ctx, refetchComplianceData]\n );\n const createTraceBatch = useCallback(\n async (input: Omit<CreateTraceBatchInput, 'context'>) => {\n const res = await createTraceBatchMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchTraceabilityData();\n return res.data?.createHealthyBowlTraceBatch;\n },\n [createTraceBatchMutation, ctx, refetchTraceabilityData]\n );\n const updateTraceBatch = useCallback(\n async (input: Omit<UpdateTraceBatchInput, 'context'>) => {\n const res = await updateTraceBatchMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchTraceabilityData();\n return res.data?.updateHealthyBowlTraceBatch;\n },\n [updateTraceBatchMutation, ctx, refetchTraceabilityData]\n );\n const recallTraceBatch = useCallback(\n async (id: string, reason?: string) => {\n const res = await recallTraceBatchMutation({\n variables: { id, reason: reason?.trim() ? reason.trim() : null, context: ctx },\n });\n if (res.error) throw res.error;\n await refetchTraceabilityData();\n return res.data?.recallHealthyBowlTraceBatch;\n },\n [recallTraceBatchMutation, ctx, refetchTraceabilityData]\n );\n const deleteTraceBatch = useCallback(\n async (id: string) => {\n const res = await deleteTraceBatchMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchTraceabilityData();\n return true;\n },\n [deleteTraceBatchMutation, ctx, refetchTraceabilityData]\n );\n const createCommunityPost = useCallback(\n async (input: Omit<CreateCommunityPostInput, 'context'>) => {\n const res = await createCommunityPostMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.createHealthyBowlCommunityPost;\n },\n [createCommunityPostMutation, ctx, refetchNetworkData]\n );\n const createConsultation = useCallback(\n async (input: CreateConsultationInput) => {\n const res = await createConsultationMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchConsultations();\n return res.data?.createHealthyBowlConsultation;\n },\n [createConsultationMutation, ctx, refetchConsultations]\n );\n const updateConsultationStatus = useCallback(\n async (input: UpdateConsultationStatusInput) => {\n const res = await updateConsultationStatusMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchConsultations();\n return res.data?.updateHealthyBowlConsultationStatus;\n },\n [updateConsultationStatusMutation, ctx, refetchConsultations]\n );\n const createExpert = useCallback(\n async (input: Omit<CreateExpertInput, 'context'>) => {\n const res = await createExpertMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.createHealthyBowlExpert;\n },\n [createExpertMutation, ctx, refetchNetworkData]\n );\n const updateExpert = useCallback(\n async (input: Omit<UpdateExpertInput, 'context'>) => {\n const res = await updateExpertMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.updateHealthyBowlExpert;\n },\n [updateExpertMutation, ctx, refetchNetworkData]\n );\n const deleteExpert = useCallback(\n async (id: string) => {\n const res = await deleteExpertMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return true;\n },\n [deleteExpertMutation, ctx, refetchNetworkData]\n );\n const createMentor = useCallback(\n async (input: Omit<CreateMentorInput, 'context'>) => {\n const res = await createMentorMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.createHealthyBowlMentor;\n },\n [createMentorMutation, ctx, refetchNetworkData]\n );\n const updateMentor = useCallback(\n async (input: Omit<UpdateMentorInput, 'context'>) => {\n const res = await updateMentorMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return res.data?.updateHealthyBowlMentor;\n },\n [updateMentorMutation, ctx, refetchNetworkData]\n );\n const deleteMentor = useCallback(\n async (id: string) => {\n const res = await deleteMentorMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchNetworkData();\n return true;\n },\n [deleteMentorMutation, ctx, refetchNetworkData]\n );\n const createGovernmentScheme = useCallback(\n async (input: Omit<CreateGovernmentSchemeInput, 'context'>) => {\n const res = await createGovernmentSchemeMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchGovernmentData();\n return res.data?.createHealthyBowlGovernmentScheme;\n },\n [createGovernmentSchemeMutation, ctx, refetchGovernmentData]\n );\n /**\n * BOFF-6112 — mark government notifications read/unread and persist it.\n *\n * Refetches ONLY the government slice, not the 16-query `refetch()` that `markAlertRead` uses —\n * clicking a notification should not re-run every dashboard query on the page.\n */\n const markGovernmentNotificationRead = useCallback(\n async (notificationIds: string[], read: boolean = true) => {\n if (notificationIds.length === 0) return 0;\n const res = await markGovernmentNotificationReadMutation({\n variables: { input: { notificationIds, read, context: ctx } },\n });\n if (res.error) throw res.error;\n await refetchGovernmentData();\n return res.data?.markHealthyBowlGovernmentNotificationRead?.updatedCount ?? 0;\n },\n [markGovernmentNotificationReadMutation, ctx, refetchGovernmentData]\n );\n\n const updateGovernmentScheme = useCallback(\n async (input: Omit<UpdateGovernmentSchemeInput, 'context'>) => {\n const res = await updateGovernmentSchemeMutation({ variables: { input: { ...input, context: ctx } } });\n if (res.error) throw res.error;\n await refetchGovernmentData();\n return res.data?.updateHealthyBowlGovernmentScheme;\n },\n [updateGovernmentSchemeMutation, ctx, refetchGovernmentData]\n );\n const deleteGovernmentScheme = useCallback(\n async (id: string) => {\n const res = await deleteGovernmentSchemeMutation({ variables: { context: ctx, id } });\n if (res.error) throw res.error;\n await refetchGovernmentData();\n return res.data?.deleteHealthyBowlGovernmentScheme ?? false;\n },\n [deleteGovernmentSchemeMutation, ctx, refetchGovernmentData]\n );\n\n const governmentPayload = governmentData?.getHealthyBowlGovernmentData;\n const analyticsPayload = analyticsData?.getHealthyBowlAnalyticsData;\n const weatherPayload = weatherData?.getHealthyBowlWeatherData;\n const networkPayload = networkData?.getHealthyBowlNetworkData;\n const soilPayload = soilData?.getHealthyBowlSoilData;\n const dashboardPayload = dashboardData?.getHealthyBowlDashboardData;\n const cropsPayload = cropsData?.getHealthyBowlCropsData;\n const livestockPayload = livestockData?.getHealthyBowlLivestockData;\n const financialPayload = financialData?.getHealthyBowlFinancialData;\n const marketplacePayload = marketplaceData?.getHealthyBowlMarketplaceData;\n const productionPayload = productionData?.getHealthyBowlProductionData;\n const productsPayload = productsData?.getHealthyBowlProductsData;\n const traceabilityPayload = traceabilityData?.getHealthyBowlTraceabilityData;\n const compliancePayload = complianceData?.getHealthyBowlComplianceData;\n const pestPayload = pestData?.getHealthyBowlPestData;\n const loading =\n governmentLoading ||\n weatherLoading ||\n analyticsLoading ||\n networkLoading ||\n soilLoading ||\n dashboardLoading ||\n cropsLoading ||\n livestockLoading ||\n financialLoading ||\n marketplaceLoading ||\n productionLoading ||\n productsLoading ||\n traceabilityLoading ||\n complianceLoading ||\n pestLoading;\n const error =\n governmentError ??\n weatherError ??\n analyticsError ??\n networkError ??\n soilError ??\n dashboardError ??\n cropsError ??\n livestockError ??\n financialError ??\n marketplaceError ??\n productionError ??\n productsError ??\n traceabilityError ??\n complianceError ??\n pestError;\n\n // Per-domain error, surfaced ONLY on a cold failure (no cached payload yet).\n // With cache-and-network, Apollo sets `error` even while cached data persists\n // during a background revalidation — gating on `!{domain}Payload` means a\n // transient refetch failure never replaces already-visible data with an error\n // screen; the page keeps showing the cached data instead.\n const errors = useMemo(\n () => ({\n government: governmentError && !governmentPayload ? governmentError : null,\n weather: weatherError && !weatherPayload ? weatherError : null,\n analytics: analyticsError && !analyticsPayload ? analyticsError : null,\n network: networkError && !networkPayload ? networkError : null,\n soil: soilError && !soilPayload ? soilError : null,\n dashboard: dashboardError && !dashboardPayload ? dashboardError : null,\n crops: cropsError && !cropsPayload ? cropsError : null,\n livestock: livestockError && !livestockPayload ? livestockError : null,\n financial: financialError && !financialPayload ? financialError : null,\n marketplace: marketplaceError && !marketplacePayload ? marketplaceError : null,\n production: productionError && !productionPayload ? productionError : null,\n products: productsError && !productsPayload ? productsError : null,\n traceability: traceabilityError && !traceabilityPayload ? traceabilityError : null,\n compliance: complianceError && !compliancePayload ? complianceError : null,\n pest: pestError && !pestPayload ? pestError : null,\n }),\n [\n governmentError,\n weatherError,\n analyticsError,\n networkError,\n soilError,\n dashboardError,\n cropsError,\n livestockError,\n financialError,\n marketplaceError,\n productionError,\n productsError,\n traceabilityError,\n complianceError,\n pestError,\n governmentPayload,\n weatherPayload,\n analyticsPayload,\n networkPayload,\n soilPayload,\n dashboardPayload,\n cropsPayload,\n livestockPayload,\n financialPayload,\n marketplacePayload,\n productionPayload,\n productsPayload,\n traceabilityPayload,\n compliancePayload,\n pestPayload,\n ]\n );\n\n // Per-domain \"is this slice doing its FIRST load\" — true only while a query is\n // loading AND has no cached payload yet. This deliberately excludes the\n // cache-and-network BACKGROUND revalidation (payload already present), so a\n // page never replaces already-visible data with a spinner on a revisit/refetch\n // — it only shows the loader on the cold initial load.\n const loadings = useMemo(\n () => ({\n government: governmentLoading && !governmentPayload,\n weather: weatherLoading && !weatherPayload,\n analytics: analyticsLoading && !analyticsPayload,\n network: networkLoading && !networkPayload,\n soil: soilLoading && !soilPayload,\n dashboard: dashboardLoading && !dashboardPayload,\n crops: cropsLoading && !cropsPayload,\n livestock: livestockLoading && !livestockPayload,\n financial: financialLoading && !financialPayload,\n marketplace: marketplaceLoading && !marketplacePayload,\n production: productionLoading && !productionPayload,\n products: productsLoading && !productsPayload,\n traceability: traceabilityLoading && !traceabilityPayload,\n compliance: complianceLoading && !compliancePayload,\n pest: pestLoading && !pestPayload,\n }),\n [\n governmentLoading,\n weatherLoading,\n analyticsLoading,\n networkLoading,\n soilLoading,\n dashboardLoading,\n cropsLoading,\n livestockLoading,\n financialLoading,\n marketplaceLoading,\n productionLoading,\n productsLoading,\n traceabilityLoading,\n complianceLoading,\n pestLoading,\n governmentPayload,\n weatherPayload,\n analyticsPayload,\n networkPayload,\n soilPayload,\n dashboardPayload,\n cropsPayload,\n livestockPayload,\n financialPayload,\n marketplacePayload,\n productionPayload,\n productsPayload,\n traceabilityPayload,\n compliancePayload,\n pestPayload,\n ]\n );\n\n return useMemo(\n () => ({\n alerts: readQueryArray<Alert>(dashboardPayload?.alerts, []),\n analyticsKPIs: readQueryArray<AnalyticsKPI>(analyticsPayload?.kpis, []),\n crops: readQueryArray<Crop>(cropsPayload?.crops, []),\n dashboardStats: readQueryValue<DashboardStats>(dashboardPayload?.dashboardStats, EMPTY_DASHBOARD_STATS),\n dailyHistory: readQueryArray<WeatherHistoryRecord>(weatherPayload?.dailyHistory, []),\n fields: readQueryArray<Field>(cropsPayload?.fields, []),\n farm: readQueryValue<Farm>(dashboardPayload?.farm, EMPTY_FARM),\n governmentSchemes: readQueryArray<GovernmentScheme>(governmentPayload?.schemes, []),\n harvests: readQueryArray<HarvestRecord>(cropsPayload?.harvests, []),\n invoices: readQueryArray<Invoice>(financialPayload?.invoices, []),\n marketplaceProducts: readQueryArray<MarketplaceProduct>(marketplacePayload?.marketplaceProducts, []),\n messages: readQueryArray<GovernmentMessage>(governmentPayload?.messages, []),\n monthlySummaries: readQueryArray<WeatherMonthlySummary>(weatherPayload?.monthlySummaries, []),\n notifications: readQueryArray<GovernmentNotification>(governmentPayload?.notifications, []),\n orders: readQueryArray<Order>(marketplacePayload?.orders, []),\n plantingPlans: readQueryArray<PlantingPlan>(cropsPayload?.plantingPlans, []),\n productionBatches: readQueryArray<ProductionBatch>(productionPayload?.productionBatches, []),\n products: readQueryArray<Product>(productsPayload?.products, []),\n revenueChartData: readQueryArray<RevenueChartPoint>(analyticsPayload?.revenueChart, []),\n recipes: readQueryArray<Recipe>(productionPayload?.recipes, []),\n benefitsChart: readQueryArray<BenefitsChartPoint>(governmentPayload?.benefitsChart, []),\n activity: readQueryArray<GovernmentActivityItem>(governmentPayload?.activity, []),\n announcements: readQueryArray<GovernmentAnnouncement>(governmentPayload?.announcements, []),\n animals: readQueryArray<Animal>(livestockPayload?.animals, []),\n breedingRecords: readQueryArray<BreedingRecord>(livestockPayload?.breedingRecords, []),\n feedRecords: readQueryArray<FeedRecord>(livestockPayload?.feedRecords, []),\n healthRecords: readQueryArray<HealthRecord>(livestockPayload?.healthRecords, []),\n productionRecords: readQueryArray<ProductionRecord>(livestockPayload?.productionRecords, []),\n recordsForRemovedAnimals: readQueryValue<number>(livestockPayload?.recordsForRemovedAnimals, 0),\n schemeApplications: readQueryArray<SchemeApplication>(governmentPayload?.applications, []),\n sensorReadings: readQueryArray<SoilSensorReading>(soilPayload?.sensorReadings, []),\n soilTests: readQueryArray<SoilTest>(soilPayload?.soilTests, []),\n traceBatches: readQueryArray<TraceBatch>(traceabilityPayload?.traceBatches, []),\n trainingPrograms: readQueryArray<TrainingProgram>(governmentPayload?.trainingPrograms, []),\n transactions: readQueryArray<Transaction>(financialPayload?.transactions, []),\n vaccinations: readQueryArray<Vaccination>(livestockPayload?.vaccinations, []),\n weatherData: readQueryValue<WeatherData>(weatherPayload?.weather, EMPTY_WEATHER),\n budgets: readQueryArray<Budget>(financialPayload?.budgets, []),\n analyticsReports: readQueryArray<AnalyticsReport>(analyticsPayload?.reports, []),\n cropDistributionData: readQueryArray<CropDistributionPoint>(analyticsPayload?.cropDistribution, []),\n yieldTrendData: readQueryArray<YieldTrendPoint>(analyticsPayload?.yieldTrend, []),\n insights: readQueryArray<FarmInsight>(analyticsPayload?.insights, []),\n audits: readQueryArray<Audit>(compliancePayload?.audits, []),\n certifications: readQueryArray<Certification>(compliancePayload?.certifications, []),\n complianceDocuments: readQueryArray<ComplianceDocument>(compliancePayload?.complianceDocuments, []),\n communityPosts: readQueryArray<CommunityPost>(networkPayload?.communityPosts, []),\n events: readQueryArray<FarmEvent>(networkPayload?.events, []),\n experts: readQueryArray<Expert>(networkPayload?.experts, []),\n mentors: readQueryArray<Mentor>(networkPayload?.mentors, []),\n agenda: readQueryArray<EventAgendaItem>(networkPayload?.agenda, []),\n consultations: readQueryArray<Consultation>(consultationsData?.getHealthyBowlConsultations, []),\n pestIssues: readQueryArray<PestIssue>(pestPayload?.pestIssues, []),\n treatments: readQueryArray<Treatment>(pestPayload?.treatments, []),\n loading,\n error: error ? new Error(error.message) : null,\n errors,\n loadings,\n refetch,\n // Exposed so the trace-portal page can refresh just the batch list after a publish /\n // unpublish, instead of refetching every slice of the dashboard bundle.\n refetchTraceabilityData,\n markAlertRead,\n markGovernmentNotificationRead,\n createCrop,\n updateCrop,\n deleteCrop,\n createAnimal,\n updateAnimal,\n deleteAnimal,\n createFarm,\n updateFarm,\n createField,\n updateField,\n deleteField,\n createMarketplaceProduct,\n updateMarketplaceProduct,\n deleteMarketplaceProduct,\n createTransaction,\n updateTransaction,\n deleteTransaction,\n getTransactionReceiptUrl,\n createPlantingPlan,\n createHarvestRecord,\n createHealthRecord,\n createFeedRecord,\n createVaccination,\n createBreedingRecord,\n createProductionRecord,\n createSoilTest,\n createPestIssue,\n updatePestIssue,\n createTreatment,\n createRecipe,\n updateRecipe,\n deleteRecipe,\n createBudget,\n createInvoice,\n updateBudget,\n updateInvoice,\n createAudit,\n updateAudit,\n updateSoilTest,\n deleteSoilTest,\n updateTreatment,\n deleteTreatment,\n deletePestIssue,\n deleteBudget,\n deleteInvoice,\n deleteAudit,\n createTraceBatch,\n updateTraceBatch,\n recallTraceBatch,\n deleteTraceBatch,\n createCommunityPost,\n updateHealthRecord,\n updateFeedRecord,\n updateVaccination,\n updateBreedingRecord,\n updateProductionRecord,\n updatePlantingPlan,\n deletePlantingPlan,\n updateHarvestRecord,\n deleteHarvestRecord,\n deleteVaccination,\n deleteHealthRecord,\n deleteFeedRecord,\n deleteBreedingRecord,\n deleteProductionRecord,\n createProduct,\n updateProduct,\n adjustProductStock,\n deleteProduct,\n createFarmEvent,\n updateFarmEvent,\n deleteFarmEvent,\n createOrder,\n updateOrder,\n createComplianceDocument,\n updateComplianceDocument,\n deleteComplianceDocument,\n createCertification,\n updateCertification,\n deleteCertification,\n createProductionBatch,\n createConsultation,\n updateConsultationStatus,\n createExpert,\n updateExpert,\n deleteExpert,\n createMentor,\n updateMentor,\n deleteMentor,\n createGovernmentScheme,\n updateGovernmentScheme,\n deleteGovernmentScheme,\n }),\n [\n governmentPayload,\n weatherPayload,\n analyticsPayload,\n networkPayload,\n soilPayload,\n dashboardPayload,\n cropsPayload,\n livestockPayload,\n financialPayload,\n marketplacePayload,\n productionPayload,\n productsPayload,\n traceabilityPayload,\n compliancePayload,\n pestPayload,\n loading,\n error,\n errors,\n loadings,\n refetch,\n refetchTraceabilityData,\n markAlertRead,\n markGovernmentNotificationRead,\n createCrop,\n updateCrop,\n deleteCrop,\n createAnimal,\n updateAnimal,\n deleteAnimal,\n createFarm,\n updateFarm,\n createField,\n updateField,\n deleteField,\n createMarketplaceProduct,\n updateMarketplaceProduct,\n deleteMarketplaceProduct,\n createTransaction,\n updateTransaction,\n deleteTransaction,\n getTransactionReceiptUrl,\n createPlantingPlan,\n createHarvestRecord,\n createHealthRecord,\n createFeedRecord,\n createVaccination,\n createBreedingRecord,\n createProductionRecord,\n createSoilTest,\n createPestIssue,\n updatePestIssue,\n createTreatment,\n createRecipe,\n updateRecipe,\n deleteRecipe,\n createBudget,\n createInvoice,\n updateBudget,\n updateInvoice,\n createAudit,\n updateAudit,\n updateSoilTest,\n deleteSoilTest,\n updateTreatment,\n deleteTreatment,\n deletePestIssue,\n deleteBudget,\n deleteInvoice,\n deleteAudit,\n createTraceBatch,\n updateTraceBatch,\n recallTraceBatch,\n deleteTraceBatch,\n createCommunityPost,\n updateHealthRecord,\n updateFeedRecord,\n updateVaccination,\n updateBreedingRecord,\n updateProductionRecord,\n updatePlantingPlan,\n deletePlantingPlan,\n updateHarvestRecord,\n deleteHarvestRecord,\n deleteVaccination,\n deleteHealthRecord,\n deleteFeedRecord,\n deleteBreedingRecord,\n deleteProductionRecord,\n createProduct,\n updateProduct,\n adjustProductStock,\n deleteProduct,\n createFarmEvent,\n updateFarmEvent,\n deleteFarmEvent,\n createOrder,\n updateOrder,\n createComplianceDocument,\n updateComplianceDocument,\n deleteComplianceDocument,\n createCertification,\n updateCertification,\n deleteCertification,\n createProductionBatch,\n consultationsData,\n createConsultation,\n updateConsultationStatus,\n createExpert,\n updateExpert,\n deleteExpert,\n createMentor,\n updateMentor,\n deleteMentor,\n createGovernmentScheme,\n updateGovernmentScheme,\n deleteGovernmentScheme,\n ]\n );\n}\n"],"mappings":";;;;;;;;AAiNA,IAAM,KAAiC,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FpC,KAAmC,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsTtC,KAAwB,CAAG;;;;;;GAoB3B,KAAmB,CAAG;;;;;;GAOtB,KAA2B,CAAG;;;;;;GAO9B,KAAyB,CAAG;;;;;;GAO5B,KAAyB,CAAG;;;;;;GAO5B,KAA6B,CAAG;;;;;;GAOhC,KAA+B,CAAG;;;;;;GAOlC,KAA2B,CAAG;;;;;;;;GAS9B,KAA2B,CAAG;;;;GAK9B,KAA4B,CAAG;;;;;;GAO/B,KAA4B,CAAG;;;;GAK/B,KAAyB,CAAG;;;;GAK5B,KAA2B,CAAG;;;;GAK9B,KAAyB,CAAG;;;;GAK5B,KAA6B,CAAG;;;;GAKhC,KAA+B,CAAG;;;;GAKlC,KAAqB,CAAG;;;;;;GAOxB,KAAqB,CAAG;;;;;;GAOxB,KAAqB,CAAG;;;;GAKxB,KAA2B,CAAG;;;;;;;;;;;;;GA6B9B,KAA0B,CAAG;;;;;;;;;;;;;;;;;GAiC7B,KAAwB,CAAG;;;;;;;;;;;;;;;;;GAuC3B,KAAiC,CAAG;;;;;;;;;;;;;;;;;GAmBpC,KA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AAC,CAAC;EACjE,YAAY,EAA0B,GAAa,YAAY,CAAC,CAAC;EACjE;EACA,OAAO,KAAY,MAAM,GAAM,OAAO,IAAI;EAC1C;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;AACF"}
@@ -34,20 +34,7 @@ var o = r`
34
34
  healthyBowlIncomingOrders(context: $context, status: $status, limit: $limit) {
35
35
  id
36
36
  orderNumber
37
- # NO buyerId. It is not a field on Order in the composed supergraph -- not on any subgraph
38
- # and not on backend main, where the only buyerId is a member of the input type
39
- # CreateMarketplaceOrderInput. Selecting it made the WHOLE query fail validation, so the
40
- # "Incoming from other farms" tab rendered "Something went wrong" and loaded nothing.
41
- #
42
- # This was SHIPPED, not a staging problem: verified live 2026-09-19 against prod, which runs
43
- # microfe-healthybowl 2026.905.4. Clicking that tab produced exactly one error --
44
- # GRAPHQL_VALIDATION_FAILED, Cannot query field "buyerId" on type "Order", operationName
45
- # HbIncomingOrders. So it was never a repin regression; the stale pin was carrying it.
46
- #
47
- # Nothing consumed it. The field appeared once in this file -- in this selection -- and is
48
- # absent from the SharedMarketOrder interface. The buyer linkage described elsewhere
49
- # ("Order.buyerId = Contact.id") is a DATABASE column the GraphQL Order type does not expose.
50
- # If a buyer is ever needed here, it has to be added to the schema first.
37
+ # No buyerId — not a field on Order. See the note above this document.
51
38
  total
52
39
  status
53
40
  paymentStatus
@@ -1 +1 @@
1
- {"version":3,"file":"useSharedMarket.js","names":[],"sources":["../../../src/healthybowl/hooks/useSharedMarket.ts"],"sourcesContent":["/**\n * Shared cross-farm marketplace (roadmap #6, acceptance D-1).\n *\n * `MarketplaceProduct` is workspace-scoped, so a buyer normally only ever sees their own farm's\n * listings. A farm OPTS IN per listing (`setHealthyBowlListingShared`) and the shared read then\n * returns listings from EVERY farm that has opted in — a narrowed projection\n * (`SharedMarketListing`) that carries the selling farm's identity, which is the entire point of a\n * cross-farm view.\n *\n * The offline codegen doesn't type these operations (they post-date the checked-in SDL), so —\n * mirroring the raw-gql pattern used for Auctions (`useAuctions`) and Irrigation (`useIrrigation`)\n * — they are hand-written `gql` documents executed directly against the live gateway. Every op\n * carries the workspace `context`.\n * @module healthybowl\n */\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A listing some farm has published to the shared cross-farm market. */\nexport interface SharedMarketListing {\n id: string;\n name: string;\n category: string;\n price: number;\n unit: string;\n stock: number;\n organicCertified: boolean;\n image?: string | null;\n description: string;\n /** The selling farm — what makes a cross-farm view legible. */\n seller?: string | null;\n sellerRating?: number | null;\n location?: string | null;\n rating: number;\n}\n\n/** Server-side filters for the shared-market read. */\nexport interface SharedMarketFilters {\n /** Exact category match; pass null/undefined (or 'All') for every category. */\n category?: string | null;\n /** Free-text match on name / description / seller. */\n search?: string | null;\n limit?: number | null;\n}\n\nconst SHARED_LISTING_FIELDS = `\n id\n name\n category\n price\n unit\n stock\n organicCertified\n image\n description\n seller\n sellerRating\n location\n rating\n`;\n\nconst SHARED_LISTINGS_QUERY = gql`\n query HealthyBowlSharedMarketListings($context: ContextInput!, $category: String, $search: String, $limit: Int) {\n healthyBowlSharedMarketListings(context: $context, category: $category, search: $search, limit: $limit) {\n ${SHARED_LISTING_FIELDS}\n }\n }\n`;\n\nconst SET_LISTING_SHARED = gql`\n mutation SetHealthyBowlListingShared($id: ID!, $shared: Boolean!, $context: ContextInput!) {\n setHealthyBowlListingShared(id: $id, shared: $shared, context: $context) {\n id\n name\n }\n }\n`;\n\ninterface SharedListingsQueryData {\n healthyBowlSharedMarketListings: SharedMarketListing[];\n}\n\ninterface SetListingSharedData {\n setHealthyBowlListingShared: { id: string; name: string };\n}\n\n/**\n * Loads the shared cross-farm listings. Filters are passed to the server (not applied client-side)\n * so the buyer searches every farm's catalogue, not just the page they happen to have loaded.\n *\n * `sharedListingIds` is the set of listing ids currently visible in the shared market. The\n * fixed-price tab uses it to show whether one of the farm's OWN listings is published — the\n * `MarketplaceProduct` type deliberately exposes no `sharedMarket` field, so this is the only\n * server-truth available. Caveat: the shared read excludes out-of-stock listings, so a published\n * listing with zero stock reads as unpublished until it is restocked; a toggle performed in-session\n * overrides that (see `MarketplacePage`).\n */\n/**\n * BOFF-6205 — place a shared-market order, fanning out into ONE ORDER PER SELLING FARM.\n *\n * A shared-market cart can mix produce from several farms. The server resolves each line to the farm\n * that published it and creates one order per farm, so each seller gets its own order, its own total\n * and its own fulfilment — a single row could not represent that.\n */\nconst CREATE_SHARED_ORDERS = gql`\n mutation HbCreateSharedMarketOrders($input: CreateMarketplaceOrderInput!) {\n createHealthyBowlSharedMarketOrders(input: $input) {\n id\n orderNumber\n total\n # BOFF-6090: the server-computed discount actually applied, so the confirmation the buyer\n # sees after placing the order reflects what was really charged, not a client guess.\n discountAmount\n status\n sellerWorkspaceId\n }\n }\n`;\n\n/** BOFF-6205 — orders placed AGAINST this farm by a buyer in another workspace. */\nconst INCOMING_ORDERS = gql`\n query HbIncomingOrders($context: ContextInput!, $status: String, $limit: Int) {\n healthyBowlIncomingOrders(context: $context, status: $status, limit: $limit) {\n id\n orderNumber\n # NO buyerId. It is not a field on Order in the composed supergraph -- not on any subgraph\n # and not on backend main, where the only buyerId is a member of the input type\n # CreateMarketplaceOrderInput. Selecting it made the WHOLE query fail validation, so the\n # \"Incoming from other farms\" tab rendered \"Something went wrong\" and loaded nothing.\n #\n # This was SHIPPED, not a staging problem: verified live 2026-09-19 against prod, which runs\n # microfe-healthybowl 2026.905.4. Clicking that tab produced exactly one error --\n # GRAPHQL_VALIDATION_FAILED, Cannot query field \"buyerId\" on type \"Order\", operationName\n # HbIncomingOrders. So it was never a repin regression; the stale pin was carrying it.\n #\n # Nothing consumed it. The field appeared once in this file -- in this selection -- and is\n # absent from the SharedMarketOrder interface. The buyer linkage described elsewhere\n # (\"Order.buyerId = Contact.id\") is a DATABASE column the GraphQL Order type does not expose.\n # If a buyer is ever needed here, it has to be added to the schema first.\n total\n status\n paymentStatus\n date\n sellerWorkspaceId\n items {\n productName\n quantity\n price\n unit\n }\n }\n }\n`;\n\nexport interface SharedMarketOrder {\n id: string;\n orderNumber: string;\n total: number;\n /** BOFF-6090: the server-computed discount actually applied to this order; 0 when none was. */\n discountAmount: number;\n status: string;\n sellerWorkspaceId: string | null;\n}\n\n/** Place a cross-farm order. Returns one order per selling farm. */\nexport function useCreateSharedMarketOrders() {\n const { workspaceId } = useHealthyBowl();\n const [mutate, { loading }] = useMutation(CREATE_SHARED_ORDERS);\n\n const placeSharedOrders = useCallback(\n async (input: Record<string, unknown>): Promise<SharedMarketOrder[]> => {\n const res = await mutate({ variables: { input: { ...input, context: { workspaceId } } } });\n if (res.error) throw res.error;\n return (\n (res.data as { createHealthyBowlSharedMarketOrders: SharedMarketOrder[] } | undefined)\n ?.createHealthyBowlSharedMarketOrders ?? []\n );\n },\n [mutate, workspaceId]\n );\n\n return { placeSharedOrders, placing: loading };\n}\n\n/**\n * Orders other farms have placed against this one.\n *\n * ★ Deliberately does NOT fall back to a placeholder workspace id the way the read-only hooks do.\n * `healthyBowlIncomingOrders` filters on `sellerWorkspaceId = <caller>`, so querying with a\n * placeholder returns an empty list that is indistinguishable from \"nobody has ordered from you\" —\n * the UI would state, as fact, that a farm has no orders when we simply do not know which farm it\n * is. Instead the query is skipped and `workspaceReady` is false, so the caller can say so.\n */\nexport function useIncomingOrders(options: { status?: string | null; skip?: boolean } = {}) {\n const { workspaceId } = useHealthyBowl();\n const workspaceReady = Boolean(workspaceId);\n const { data, loading, error, refetch } = useQuery(INCOMING_ORDERS, {\n variables: { context: { workspaceId }, status: options.status ?? null, limit: 50 },\n fetchPolicy: 'cache-and-network',\n skip: options.skip === true || !workspaceReady,\n });\n return {\n incomingOrders:\n (data as { healthyBowlIncomingOrders?: Record<string, unknown>[] } | undefined)?.healthyBowlIncomingOrders ?? [],\n loading,\n error,\n refetch,\n workspaceReady,\n };\n}\n\nexport function useSharedMarketListings(filters: SharedMarketFilters = {}) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const category = filters.category && filters.category !== 'All' ? filters.category : null;\n const search = filters.search?.trim() ? filters.search.trim() : null;\n const limit = filters.limit ?? null;\n\n const { data, loading, error, refetch } = useQuery<SharedListingsQueryData>(SHARED_LISTINGS_QUERY, {\n variables: { context, category, search, limit },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const listings = useMemo(() => data?.healthyBowlSharedMarketListings ?? [], [data]);\n const sharedListingIds = useMemo(() => new Set(listings.map((l) => l.id)), [listings]);\n\n return { listings, sharedListingIds, loading, error, refetch };\n}\n\n/**\n * A live auction another farm has published to the shared cross-farm market (BOFF-6206).\n *\n * A narrow projection: it carries what a cross-farm bidder needs — the product, the selling farm, the\n * close time and the CURRENT high bid. It never exposes the reserve price or rival bidder identities.\n */\nexport interface SharedMarketAuction {\n id: string;\n productName: string;\n unit: string;\n /** The selling farm — what makes a cross-farm view legible. */\n seller?: string | null;\n /** Auction close time as an ISO-8601 string. */\n endTime: string;\n startingPrice: number;\n bidIncrement: number;\n /** The current high bid, or startingPrice when nobody has bid yet. Never the reserve. */\n currentBid: number;\n bidCount: number;\n status: string;\n}\n\nconst SHARED_AUCTIONS_QUERY = gql`\n query HealthyBowlSharedMarketAuctions($context: ContextInput!, $limit: Int) {\n healthyBowlSharedMarketAuctions(context: $context, limit: $limit) {\n id\n productName\n unit\n seller\n endTime\n startingPrice\n bidIncrement\n currentBid\n bidCount\n status\n }\n }\n`;\n\nconst PLACE_SHARED_BID = gql`\n mutation HealthyBowlPlaceSharedBid($auctionId: ID!, $amount: Float!, $context: ContextInput!) {\n placeHealthyBowlBid(auctionId: $auctionId, amount: $amount, context: $context) {\n id\n auctionId\n bidderId\n amount\n createdAt\n }\n }\n`;\n\ninterface SharedAuctionsQueryData {\n healthyBowlSharedMarketAuctions: SharedMarketAuction[];\n}\n\n/** The minimum acceptable next bid: startingPrice with no bids, else the current high + increment. */\nexport function minNextBid(\n auction: Pick<SharedMarketAuction, 'currentBid' | 'bidIncrement' | 'bidCount' | 'startingPrice'>\n): number {\n return auction.bidCount > 0 ? auction.currentBid + auction.bidIncrement : auction.startingPrice;\n}\n\n/**\n * Live auctions on shared listings from EVERY farm (BOFF-6206), plus cross-farm bid placement.\n *\n * The read is cross-workspace by design (`healthyBowlSharedMarketAuctions` runs unscoped server-side).\n * `placeBid` reuses the ordinary `placeHealthyBowlBid` mutation carrying the caller's own workspace\n * `context`; the server pins the seller's workspace, so a Farm B bid becomes the new high bid inside\n * Farm A's own auction. On success the shared list is refetched so the Current Bid updates in place.\n */\nexport function useSharedMarketAuctions(options: { limit?: number | null } = {}) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<SharedAuctionsQueryData>(SHARED_AUCTIONS_QUERY, {\n variables: { context, limit: options.limit ?? null },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [placeBidMutation, { loading: placing }] = useMutation(PLACE_SHARED_BID);\n\n const auctions = useMemo(() => data?.healthyBowlSharedMarketAuctions ?? [], [data]);\n\n const placeBid = useCallback(\n async (auctionId: string, amount: number) => {\n // This Apollo Client version's mutate resolves to a MutateResult whose GraphQL/network failure\n // is `error` (singular ApolloError) — not `errors`. Capture it so the caller's toast reports the\n // real rejection (e.g. \"Bid too low\"). Mirrors the shipped useCreateSharedMarketOrders.\n let bidError: unknown = null;\n try {\n // Build the context inline from workspaceId (its only ingredient) so the callback's deps are\n // honest and no eslint-disable is needed — the outer `context` object is a new ref each render.\n const res = await placeBidMutation({ variables: { auctionId, amount, context: { workspaceId } } });\n if (res.error) bidError = res.error;\n } catch (err) {\n bidError = err;\n }\n // Refresh either way — a rejection usually means a rival just raised the high bid, so the buyer\n // must see the new current bid, not fly blind. But this refresh is BEST-EFFORT: a refetch failure\n // must never turn a bid that actually landed into an apparent failure (nor swallow a real reject).\n await refetch().catch(() => undefined);\n if (bidError) throw bidError;\n },\n [placeBidMutation, refetch, workspaceId]\n );\n\n return { auctions, loading, error, refetch, placeBid, placing };\n}\n\n/**\n * Publish / unpublish one of the farm's OWN listings to the shared cross-farm market.\n * Workspace-scoped server-side: a farm can only ever change the flag on its own listings.\n */\nexport function useSetListingShared() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const [mutate, { loading }] = useMutation<SetListingSharedData>(SET_LISTING_SHARED);\n\n const setListingShared = useCallback(\n async (id: string, shared: boolean) => {\n const res = await mutate({ variables: { id, shared, context } });\n return res.data?.setHealthyBowlListingShared;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [mutate, workspaceId]\n );\n\n return { setListingShared, saving: loading };\n}\n"],"mappings":";;;;;AA+DA,IAAM,IAAwB,CAAG;;;QAGzB,qJAAsB;;;GAKxB,IAAqB,CAAG;;;;;;;GAmCxB,IAAuB,CAAG;;;;;;;;;;;;;GAgB1B,IAAkB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6C3B,SAAgB,IAA8B;CAC5C,IAAM,EAAE,mBAAgB,EAAe,GACjC,CAAC,GAAQ,EAAE,gBAAa,EAAY,CAAoB;CAc9D,OAAO;EAAE,mBAZiB,EACxB,OAAO,MAAiE;GACtE,IAAM,IAAM,MAAM,EAAO,EAAE,WAAW,EAAE,OAAO;IAAE,GAAG;IAAO,SAAS,EAAE,eAAY;GAAE,EAAE,EAAE,CAAC;GACzF,IAAI,EAAI,OAAO,MAAM,EAAI;GACzB,OACG,EAAI,MACD,uCAAuC,CAAC;EAEhD,GACA,CAAC,GAAQ,CAAW,CAGb;EAAmB,SAAS;CAAQ;AAC/C;AAWA,SAAgB,EAAkB,IAAsD,CAAC,GAAG;CAC1F,IAAM,EAAE,mBAAgB,EAAe,GACjC,IAAiB,EAAQ,GACzB,EAAE,SAAM,YAAS,UAAO,eAAY,EAAS,GAAiB;EAClE,WAAW;GAAE,SAAS,EAAE,eAAY;GAAG,QAAQ,EAAQ,UAAU;GAAM,OAAO;EAAG;EACjF,aAAa;EACb,MAAM,EAAQ,SAAS,MAAQ,CAAC;CAClC,CAAC;CACD,OAAO;EACL,gBACG,GAAgF,6BAA6B,CAAC;EACjH;EACA;EACA;EACA;CACF;AACF;AAEA,SAAgB,EAAwB,IAA+B,CAAC,GAAG;CACzE,I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W;KAAQ,SAAS,EAAE,eAAY;IAAE,EAAE,CAAC;IACjG,AAAI,EAAI,UAAO,IAAW,EAAI;GAChC,SAAS,GAAK;IACZ,IAAW;GACb;GAKA,IADA,MAAM,EAAQ,EAAE,YAAY,KAAA,CAAS,GACjC,GAAU,MAAM;EACtB,GACA;GAAC;GAAkB;GAAS;EAAW,CAGG;EAAU;CAAQ;AAChE;AAMA,SAAgB,IAAsB;CACpC,IAAM,EAAE,mBAAgB,EAAe,GACjC,IAAU,EAAE,eAAY,GACxB,CAAC,GAAQ,EAAE,gBAAa,EAAkC,CAAkB;CAWlF,OAAO;EAAE,kBATgB,EACvB,OAAO,GAAY,OAEV,MADW,EAAO,EAAE,WAAW;GAAE;GAAI;GAAQ;EAAQ,EAAE,CAAC,GACpD,MAAM,6BAGnB,CAAC,GAAQ,CAAW,CAGb;EAAkB,QAAQ;CAAQ;AAC7C"}
1
+ {"version":3,"file":"useSharedMarket.js","names":[],"sources":["../../../src/healthybowl/hooks/useSharedMarket.ts"],"sourcesContent":["/**\n * Shared cross-farm marketplace (roadmap #6, acceptance D-1).\n *\n * `MarketplaceProduct` is workspace-scoped, so a buyer normally only ever sees their own farm's\n * listings. A farm OPTS IN per listing (`setHealthyBowlListingShared`) and the shared read then\n * returns listings from EVERY farm that has opted in — a narrowed projection\n * (`SharedMarketListing`) that carries the selling farm's identity, which is the entire point of a\n * cross-farm view.\n *\n * The offline codegen doesn't type these operations (they post-date the checked-in SDL), so —\n * mirroring the raw-gql pattern used for Auctions (`useAuctions`) and Irrigation (`useIrrigation`)\n * — they are hand-written `gql` documents executed directly against the live gateway. Every op\n * carries the workspace `context`.\n * @module healthybowl\n */\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A listing some farm has published to the shared cross-farm market. */\nexport interface SharedMarketListing {\n id: string;\n name: string;\n category: string;\n price: number;\n unit: string;\n stock: number;\n organicCertified: boolean;\n image?: string | null;\n description: string;\n /** The selling farm — what makes a cross-farm view legible. */\n seller?: string | null;\n sellerRating?: number | null;\n location?: string | null;\n rating: number;\n}\n\n/** Server-side filters for the shared-market read. */\nexport interface SharedMarketFilters {\n /** Exact category match; pass null/undefined (or 'All') for every category. */\n category?: string | null;\n /** Free-text match on name / description / seller. */\n search?: string | null;\n limit?: number | null;\n}\n\nconst SHARED_LISTING_FIELDS = `\n id\n name\n category\n price\n unit\n stock\n organicCertified\n image\n description\n seller\n sellerRating\n location\n rating\n`;\n\nconst SHARED_LISTINGS_QUERY = gql`\n query HealthyBowlSharedMarketListings($context: ContextInput!, $category: String, $search: String, $limit: Int) {\n healthyBowlSharedMarketListings(context: $context, category: $category, search: $search, limit: $limit) {\n ${SHARED_LISTING_FIELDS}\n }\n }\n`;\n\nconst SET_LISTING_SHARED = gql`\n mutation SetHealthyBowlListingShared($id: ID!, $shared: Boolean!, $context: ContextInput!) {\n setHealthyBowlListingShared(id: $id, shared: $shared, context: $context) {\n id\n name\n }\n }\n`;\n\ninterface SharedListingsQueryData {\n healthyBowlSharedMarketListings: SharedMarketListing[];\n}\n\ninterface SetListingSharedData {\n setHealthyBowlListingShared: { id: string; name: string };\n}\n\n/**\n * Loads the shared cross-farm listings. Filters are passed to the server (not applied client-side)\n * so the buyer searches every farm's catalogue, not just the page they happen to have loaded.\n *\n * `sharedListingIds` is the set of listing ids currently visible in the shared market. The\n * fixed-price tab uses it to show whether one of the farm's OWN listings is published — the\n * `MarketplaceProduct` type deliberately exposes no `sharedMarket` field, so this is the only\n * server-truth available. Caveat: the shared read excludes out-of-stock listings, so a published\n * listing with zero stock reads as unpublished until it is restocked; a toggle performed in-session\n * overrides that (see `MarketplacePage`).\n */\n/**\n * BOFF-6205 — place a shared-market order, fanning out into ONE ORDER PER SELLING FARM.\n *\n * A shared-market cart can mix produce from several farms. The server resolves each line to the farm\n * that published it and creates one order per farm, so each seller gets its own order, its own total\n * and its own fulfilment — a single row could not represent that.\n */\nconst CREATE_SHARED_ORDERS = gql`\n mutation HbCreateSharedMarketOrders($input: CreateMarketplaceOrderInput!) {\n createHealthyBowlSharedMarketOrders(input: $input) {\n id\n orderNumber\n total\n # BOFF-6090: the server-computed discount actually applied, so the confirmation the buyer\n # sees after placing the order reflects what was really charged, not a client guess.\n discountAmount\n status\n sellerWorkspaceId\n }\n }\n`;\n\n/** BOFF-6205 — orders placed AGAINST this farm by a buyer in another workspace. */\n/**\n * ★ NO `buyerId` ON `Order`, and it was a LIVE PRODUCTION DEFECT.\n *\n * That field exists on no subgraph and not on backend main, where the only `buyerId` belongs to the\n * input type `CreateMarketplaceOrderInput`. A validation error rejects the whole query, so the\n * \"Incoming from other farms\" tab rendered \"Something went wrong\" and loaded nothing.\n *\n * Verified live 2026-09-19 against prod, which runs microfe-healthybowl 2026.905.4: the shipped dist\n * carried the same selection, and clicking that tab produced exactly one error —\n * GRAPHQL_VALIDATION_FAILED, Cannot query field \"buyerId\" on type \"Order\", operationName\n * HbIncomingOrders. So the stale pin was shipping this, not hiding it (BOFF-7454).\n *\n * Nothing consumed the field: one occurrence in the repo, absent from `SharedMarketOrder`. The buyer\n * linkage described elsewhere (\"Order.buyerId = Contact.id\") is a database column the GraphQL `Order`\n * type does not expose; exposing it is schema work, not a selection.\n *\n * ★★ Kept out of the document itself: a GraphQL `#` comment is part of the document string, so the\n * bundler ships it and it is sent to the gateway on every request.\n */\nconst INCOMING_ORDERS = gql`\n query HbIncomingOrders($context: ContextInput!, $status: String, $limit: Int) {\n healthyBowlIncomingOrders(context: $context, status: $status, limit: $limit) {\n id\n orderNumber\n # No buyerId — not a field on Order. See the note above this document.\n total\n status\n paymentStatus\n date\n sellerWorkspaceId\n items {\n productName\n quantity\n price\n unit\n }\n }\n }\n`;\n\nexport interface SharedMarketOrder {\n id: string;\n orderNumber: string;\n total: number;\n /** BOFF-6090: the server-computed discount actually applied to this order; 0 when none was. */\n discountAmount: number;\n status: string;\n sellerWorkspaceId: string | null;\n}\n\n/** Place a cross-farm order. Returns one order per selling farm. */\nexport function useCreateSharedMarketOrders() {\n const { workspaceId } = useHealthyBowl();\n const [mutate, { loading }] = useMutation(CREATE_SHARED_ORDERS);\n\n const placeSharedOrders = useCallback(\n async (input: Record<string, unknown>): Promise<SharedMarketOrder[]> => {\n const res = await mutate({ variables: { input: { ...input, context: { workspaceId } } } });\n if (res.error) throw res.error;\n return (\n (res.data as { createHealthyBowlSharedMarketOrders: SharedMarketOrder[] } | undefined)\n ?.createHealthyBowlSharedMarketOrders ?? []\n );\n },\n [mutate, workspaceId]\n );\n\n return { placeSharedOrders, placing: loading };\n}\n\n/**\n * Orders other farms have placed against this one.\n *\n * ★ Deliberately does NOT fall back to a placeholder workspace id the way the read-only hooks do.\n * `healthyBowlIncomingOrders` filters on `sellerWorkspaceId = <caller>`, so querying with a\n * placeholder returns an empty list that is indistinguishable from \"nobody has ordered from you\" —\n * the UI would state, as fact, that a farm has no orders when we simply do not know which farm it\n * is. Instead the query is skipped and `workspaceReady` is false, so the caller can say so.\n */\nexport function useIncomingOrders(options: { status?: string | null; skip?: boolean } = {}) {\n const { workspaceId } = useHealthyBowl();\n const workspaceReady = Boolean(workspaceId);\n const { data, loading, error, refetch } = useQuery(INCOMING_ORDERS, {\n variables: { context: { workspaceId }, status: options.status ?? null, limit: 50 },\n fetchPolicy: 'cache-and-network',\n skip: options.skip === true || !workspaceReady,\n });\n return {\n incomingOrders:\n (data as { healthyBowlIncomingOrders?: Record<string, unknown>[] } | undefined)?.healthyBowlIncomingOrders ?? [],\n loading,\n error,\n refetch,\n workspaceReady,\n };\n}\n\nexport function useSharedMarketListings(filters: SharedMarketFilters = {}) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const category = filters.category && filters.category !== 'All' ? filters.category : null;\n const search = filters.search?.trim() ? filters.search.trim() : null;\n const limit = filters.limit ?? null;\n\n const { data, loading, error, refetch } = useQuery<SharedListingsQueryData>(SHARED_LISTINGS_QUERY, {\n variables: { context, category, search, limit },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const listings = useMemo(() => data?.healthyBowlSharedMarketListings ?? [], [data]);\n const sharedListingIds = useMemo(() => new Set(listings.map((l) => l.id)), [listings]);\n\n return { listings, sharedListingIds, loading, error, refetch };\n}\n\n/**\n * A live auction another farm has published to the shared cross-farm market (BOFF-6206).\n *\n * A narrow projection: it carries what a cross-farm bidder needs — the product, the selling farm, the\n * close time and the CURRENT high bid. It never exposes the reserve price or rival bidder identities.\n */\nexport interface SharedMarketAuction {\n id: string;\n productName: string;\n unit: string;\n /** The selling farm — what makes a cross-farm view legible. */\n seller?: string | null;\n /** Auction close time as an ISO-8601 string. */\n endTime: string;\n startingPrice: number;\n bidIncrement: number;\n /** The current high bid, or startingPrice when nobody has bid yet. Never the reserve. */\n currentBid: number;\n bidCount: number;\n status: string;\n}\n\nconst SHARED_AUCTIONS_QUERY = gql`\n query HealthyBowlSharedMarketAuctions($context: ContextInput!, $limit: Int) {\n healthyBowlSharedMarketAuctions(context: $context, limit: $limit) {\n id\n productName\n unit\n seller\n endTime\n startingPrice\n bidIncrement\n currentBid\n bidCount\n status\n }\n }\n`;\n\nconst PLACE_SHARED_BID = gql`\n mutation HealthyBowlPlaceSharedBid($auctionId: ID!, $amount: Float!, $context: ContextInput!) {\n placeHealthyBowlBid(auctionId: $auctionId, amount: $amount, context: $context) {\n id\n auctionId\n bidderId\n amount\n createdAt\n }\n }\n`;\n\ninterface SharedAuctionsQueryData {\n healthyBowlSharedMarketAuctions: SharedMarketAuction[];\n}\n\n/** The minimum acceptable next bid: startingPrice with no bids, else the current high + increment. */\nexport function minNextBid(\n auction: Pick<SharedMarketAuction, 'currentBid' | 'bidIncrement' | 'bidCount' | 'startingPrice'>\n): number {\n return auction.bidCount > 0 ? auction.currentBid + auction.bidIncrement : auction.startingPrice;\n}\n\n/**\n * Live auctions on shared listings from EVERY farm (BOFF-6206), plus cross-farm bid placement.\n *\n * The read is cross-workspace by design (`healthyBowlSharedMarketAuctions` runs unscoped server-side).\n * `placeBid` reuses the ordinary `placeHealthyBowlBid` mutation carrying the caller's own workspace\n * `context`; the server pins the seller's workspace, so a Farm B bid becomes the new high bid inside\n * Farm A's own auction. On success the shared list is refetched so the Current Bid updates in place.\n */\nexport function useSharedMarketAuctions(options: { limit?: number | null } = {}) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<SharedAuctionsQueryData>(SHARED_AUCTIONS_QUERY, {\n variables: { context, limit: options.limit ?? null },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [placeBidMutation, { loading: placing }] = useMutation(PLACE_SHARED_BID);\n\n const auctions = useMemo(() => data?.healthyBowlSharedMarketAuctions ?? [], [data]);\n\n const placeBid = useCallback(\n async (auctionId: string, amount: number) => {\n // This Apollo Client version's mutate resolves to a MutateResult whose GraphQL/network failure\n // is `error` (singular ApolloError) — not `errors`. Capture it so the caller's toast reports the\n // real rejection (e.g. \"Bid too low\"). Mirrors the shipped useCreateSharedMarketOrders.\n let bidError: unknown = null;\n try {\n // Build the context inline from workspaceId (its only ingredient) so the callback's deps are\n // honest and no eslint-disable is needed — the outer `context` object is a new ref each render.\n const res = await placeBidMutation({ variables: { auctionId, amount, context: { workspaceId } } });\n if (res.error) bidError = res.error;\n } catch (err) {\n bidError = err;\n }\n // Refresh either way — a rejection usually means a rival just raised the high bid, so the buyer\n // must see the new current bid, not fly blind. But this refresh is BEST-EFFORT: a refetch failure\n // must never turn a bid that actually landed into an apparent failure (nor swallow a real reject).\n await refetch().catch(() => undefined);\n if (bidError) throw bidError;\n },\n [placeBidMutation, refetch, workspaceId]\n );\n\n return { auctions, loading, error, refetch, placeBid, placing };\n}\n\n/**\n * Publish / unpublish one of the farm's OWN listings to the shared cross-farm market.\n * Workspace-scoped server-side: a farm can only ever change the flag on its own listings.\n */\nexport function useSetListingShared() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const [mutate, { loading }] = useMutation<SetListingSharedData>(SET_LISTING_SHARED);\n\n const setListingShared = useCallback(\n async (id: string, shared: boolean) => {\n const res = await mutate({ variables: { id, shared, context } });\n return res.data?.setHealthyBowlListingShared;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [mutate, workspaceId]\n );\n\n return { setListingShared, saving: loading };\n}\n"],"mappings":";;;;;AA+DA,IAAM,IAAwB,CAAG;;;QAGzB,qJAAsB;;;GAKxB,IAAqB,CAAG;;;;;;;GAmCxB,IAAuB,CAAG;;;;;;;;;;;;;GAmC1B,IAAkB,CAAG;;;;;;;;;;;;;;;;;;;;AAgC3B,SAAgB,IAA8B;CAC5C,IAAM,EAAE,mBAAgB,EAAe,GACjC,CAAC,GAAQ,EAAE,gBAAa,EAAY,CAAoB;CAc9D,OAAO;EAAE,mBAZiB,EACxB,OAAO,MAAiE;GACtE,IAAM,IAAM,MAAM,EAAO,EAAE,WAAW,EAAE,OAAO;IAAE,GAAG;IAAO,SAAS,EAAE,eAAY;GAAE,EAAE,EAAE,CAAC;GACzF,IAAI,EAAI,OAAO,MAAM,EAAI;GACzB,OACG,EAAI,MACD,uCAAuC,CAAC;EAEhD,GACA,CAAC,GAAQ,CAAW,CAGb;EAAmB,SAAS;CAAQ;AAC/C;AAWA,SAAgB,EAAkB,IAAsD,CAAC,GAAG;CAC1F,IAAM,EAAE,mBAAgB,EAAe,GACjC,IAAiB,EAAQ,GACzB,EAAE,SAAM,YAAS,UAAO,eAAY,EAAS,GAAiB;EAClE,WAAW;GAAE,SAAS,EAAE,eAAY;GAAG,QAAQ,EAAQ,UAAU;GAAM,OAAO;EAAG;EACjF,aAAa;EACb,MAAM,EAAQ,SAAS,MAAQ,CAAC;CAClC,CAAC;CACD,OAAO;EACL,gBACG,GAAgF,6BAA6B,CAAC;EACjH;EACA;EACA;EACA;CACF;AACF;AAEA,SAAgB,EAAwB,IAA+B,CA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,WAAW;KAAE;KAAW;KAAQ,SAAS,EAAE,eAAY;IAAE,EAAE,CAAC;IACjG,AAAI,EAAI,UAAO,IAAW,EAAI;GAChC,SAAS,GAAK;IACZ,IAAW;GACb;GAKA,IADA,MAAM,EAAQ,EAAE,YAAY,KAAA,CAAS,GACjC,GAAU,MAAM;EACtB,GACA;GAAC;GAAkB;GAAS;EAAW,CAGG;EAAU;CAAQ;AAChE;AAMA,SAAgB,IAAsB;CACpC,IAAM,EAAE,mBAAgB,EAAe,GACjC,IAAU,EAAE,eAAY,GACxB,CAAC,GAAQ,EAAE,gBAAa,EAAkC,CAAkB;CAWlF,OAAO;EAAE,kBATgB,EACvB,OAAO,GAAY,OAEV,MADW,EAAO,EAAE,WAAW;GAAE;GAAI;GAAQ;EAAQ,EAAE,CAAC,GACpD,MAAM,6BAGnB,CAAC,GAAQ,CAAW,CAGb;EAAkB,QAAQ;CAAQ;AAC7C"}
@@ -6,4 +6,3 @@ import "./HealthyBowlRoot.js";
6
6
  import "./public/PublicTracePage.js";
7
7
  import "./public/PublicSeedLotPage.js";
8
8
  import "./store/healthybowlStore.js";
9
- import "./hooks/useOpenAssistantHelp.js";
@@ -1 +1 @@
1
- {"version":3,"file":"assistantPrompt.js","names":[],"sources":["../../src/utils/assistantPrompt.ts"],"sourcesContent":["/**\n * Soft confirm-before-mutate guardrail for the assistant's api-calls (write)\n * mode. The in-sandbox agent executes mutations autonomously — there is no hard\n * server-side confirmation — so we prepend a describe-and-confirm instruction to\n * the user's TURN (not the session system prompt, which would clobber the\n * agent's api-calls behaviour). This is ADVISORY; the dependable guard is the\n * host-side consent dialog + the admin gate. Only the agent receives the\n * prepended text — the user-facing message bubble keeps the raw content.\n */\n\nimport type { AssistantMode } from '@/types/assistant';\n\n/**\n * Marks where our instructions stop and the user's words begin. Exactly one may\n * exist in a prompt, and it must be last — see `buildPromptForMode`.\n */\nexport const USER_REQUEST_DELIMITER = '--- User request ---';\n\nexport const API_CALLS_CONFIRM_PREAMBLE = [\n \"You are in api-calls mode for HealthyBowl and can run GraphQL queries and mutations on the user's behalf.\",\n 'Before performing ANY write (create, update, delete — any mutation):',\n '1. State exactly what you are about to change (entity, fields, and values).',\n '2. Ask the user to confirm, and WAIT for an explicit \"yes\"/\"confirm\" before executing it.',\n 'Read-only queries may run without confirmation. Confirm each write separately; never batch mutations behind a single confirmation.',\n '',\n USER_REQUEST_DELIMITER,\n].join('\\n');\n\n/**\n * Ask for the reply in the user's language (BOFF-7107).\n *\n * Nothing else does. The sandbox system prompt carries no language instruction,\n * the grounding documentation is entirely in English, and the persona insists on\n * grounding in it — so every force in the session pushes the answer towards\n * English regardless of what the user wrote. The model's tendency to mirror the\n * input is the only thing resisting that, and it is being outvoted.\n *\n * Three deliberate choices:\n *\n * - **The user's own language wins over the UI language.** The chrome being in\n * English says nothing about the person typing Tamil into it; treating the\n * locale as an instruction rather than a default would be the actual bug.\n * - **Translate the docs, do not switch to their language.** This is the clause\n * that matters. Without it a grounded answer drifts back to English mid-reply\n * simply because the source material is English.\n * - **Prepended per TURN, not sent as `system`.** The transport's `system` field\n * REPLACES the whole mode prompt, which would silently delete the docs and\n * api-calls instructions along with it.\n */\n/**\n * The instruction lines only — deliberately WITHOUT the delimiter.\n *\n * The delimiter marks where our instructions stop and the user's words begin, so\n * exactly one may exist and it must be last. Emitting it here too put a second\n * one mid-prompt, which left the api-calls safety instructions sitting *after* a\n * \"User request\" marker — i.e. presented to the model as though the user had\n * written them. `buildPromptForMode` owns placing it, once.\n */\n/**\n * Told to the model when the turn was SPOKEN rather than typed.\n *\n * Speech recognition does not fail uniformly — it fails on specific words, and\n * the ones it fails on here are predictable: English technical terms, product\n * and crop names, and numbers spoken inside an Indic sentence. A recogniser set\n * to `ta-IN` has no good model for \"urea\", \"pH\" or \"NPK\", so a Tamil sentence\n * comes back mostly right with a few words wrong. That is exactly the report:\n * \"some word some times\".\n *\n * The model is far better placed to repair that than the recogniser is, because\n * it has the farming context — but only if it is TOLD the text was dictated.\n * Otherwise it answers the garbled word literally, which is what makes the\n * assistant look like it misunderstood.\n *\n * ★ The refusal to guess is the important half. Charitable interpretation is\n * right for a mangled verb and dangerous for a mangled QUANTITY: this is\n * agriculture, and a dose or a unit that the recogniser mis-heard must be asked\n * about, not inferred. One extra question costs a few seconds; a wrong dose\n * costs a crop.\n */\nconst DICTATION_PREAMBLE = [\n 'This message was DICTATED using speech recognition, so some words may be mis-heard.',\n 'Errors cluster on English technical terms, product and crop names, and numbers spoken inside a sentence in another language.',\n 'Read the message for INTENT rather than literally: where a word is clearly a recognition error, infer what was meant from the agricultural context instead of answering the garbled word.',\n 'But do NOT guess when a mis-heard word would change what is being asked — a crop, a chemical, a quantity or a unit. Ask one short clarifying question instead. A wrong dose is far worse than an extra question.',\n].join('\\n');\n\n/**\n * Told to the model when its answer will be SPOKEN ALOUD, not read.\n *\n * The assistant was never told this, so it replied the way it replies in chat:\n * documentation-style markdown with `##` headings, `**bold**` and long\n * enumerated sections. In the chat panel that renders correctly. In the voice\n * panel it is read aloud AND shown as a caption, where the syntax is literal\n * and the length is unusable — the operator screenshotted a live session whose\n * caption was a wall of \"### **Budget Planning Features:**\".\n *\n * ★ This is the fix at SOURCE. Stripping markdown at render time is a\n * necessary backstop, but it cannot shorten a 500-word answer that was never\n * meant to be listened to. A spoken reply has to be short because the listener\n * cannot skim it.\n */\nconst VOICE_REPLY_PREAMBLE = [\n 'Your answer will be SPOKEN ALOUD and shown as a live caption, not read as a document.',\n 'Write plain conversational sentences. Use NO markdown whatsoever: no #, ##, ###, no **bold**, no bullet or numbered lists, no tables, no code fences.',\n 'Keep it SHORT — normally one to four sentences. The listener cannot skim, so a long answer is worse than an incomplete one.',\n 'If the full answer is genuinely long, give the useful part first and offer to go deeper, rather than listing every option.',\n 'Speak numbers, units and quantities the way a person says them.',\n].join('\\n');\n\nexport function buildLanguagePreamble(languageName: string, isExplicitChoice = false): string {\n return [\n `Answer in ${languageName}.`,\n // The mirror clause is right for a DEFAULT and wrong for a CHOICE.\n //\n // Derived from the interface language it is only a guess, and the language\n // the user actually wrote in is better evidence. But once they have picked a\n // language deliberately, \"what they wrote in wins\" silently overrides them —\n // and it does so hardest for people who TYPE, since a typed English question\n // would come back in English no matter what they selected. That makes the\n // preference inert for exactly the users who cannot dictate.\n isExplicitChoice\n ? `The user has chosen ${languageName} deliberately: answer in it even when their message is written in another language.`\n : 'If the user writes in a different language, answer in THAT language instead — what they wrote in always wins.',\n 'Your documentation and tool output are in English: translate what you quote from them rather than switching language.',\n ].join('\\n');\n}\n\n/**\n * `languageName` is the human name of the user's language (\"Tamil\"), not a code:\n * a code invites the model to answer *about* the tag instead of *in* it.\n * Omitted (or empty) leaves the prompt untouched, so a caller without locale\n * context behaves exactly as before.\n *\n * Order is load-bearing: instructions, then the delimiter, then the user's text.\n * The language preamble goes FIRST so the api-calls preamble keeps its own\n * delimiter adjacent to the content it introduces.\n */\nexport function buildPromptForMode(\n mode: AssistantMode,\n content: string,\n languageName?: string,\n isExplicitChoice = false,\n dictated = false\n): string {\n // Dictation goes AFTER the language lines and before the delimiter: it is an\n // instruction about the user's text, so it belongs with the instructions, not\n // inside them. Defaults to false, so every typed turn is byte-identical to\n // before — the composer's own dictation is excluded deliberately, because the\n // user can read and edit that text before sending it.\n const preamble = [\n languageName ? buildLanguagePreamble(languageName, isExplicitChoice) : '',\n dictated ? DICTATION_PREAMBLE : '',\n // A dictated turn is a SPOKEN conversation, so the reply is spoken too.\n dictated ? VOICE_REPLY_PREAMBLE : '',\n ]\n .filter(Boolean)\n .join('\\n\\n');\n const language = preamble ? `${preamble}\\n\\n` : '';\n if (mode === 'api-calls') return `${language}${API_CALLS_CONFIRM_PREAMBLE}\\n${content}`;\n return language ? `${language}${USER_REQUEST_DELIMITER}\\n${content}` : content;\n}\n"],"mappings":";AAgBA,IAAa,IAAyB,wBAEzB,IAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI,GAqDL,IAAqB;CACzB;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI,GAiBL,IAAuB;CAC3B;CACA;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI;AAEX,SAAgB,EAAsB,GAAsB,IAAmB,IAAe;CAC5F,OAAO;EACL,aAAa,EAAa;EAS1B,IACI,uBAAuB,EAAa,uFACpC;EACJ;CACF,EAAE,KAAK,IAAI;AACb;AAYA,SAAgB,EACd,GACA,GACA,GACA,IAAmB,IACnB,IAAW,IACH;CAMR,IAAM,IAAW;EACf,IAAe,EAAsB,GAAc,CAAgB,IAAI;EACvE,IAAW,IAAqB;EAEhC,IAAW,IAAuB;CACpC,EACG,OAAO,OAAO,EACd,KAAK,MAAM,GACR,IAAW,IAAW,GAAG,EAAS,QAAQ;CAEhD,OADI,MAAS,cAAoB,GAAG,IAAW,EAA2B,IAAI,MACvE,IAAW,GAAG,IAAW,EAAuB,IAAI,MAAY;AACzE"}
1
+ {"version":3,"file":"assistantPrompt.js","names":[],"sources":["../../src/utils/assistantPrompt.ts"],"sourcesContent":["/**\n * Soft confirm-before-mutate guardrail for the assistant's api-calls (write)\n * mode: a describe-and-confirm instruction prepended to the user's TURN (not the\n * session system prompt, which would clobber the agent's api-calls behaviour).\n * This is ADVISORY — the model is asked, not made. What holds a write is the\n * sandbox: since 2026-09-07 it refuses the mutation and keeps it pending until\n * the user presses Approve on the pending-write card, behind the admin gate and\n * the consent dialog. This text shapes what the model says before that card\n * appears. Only the agent receives the prepended text — the user-facing message\n * bubble keeps the raw content.\n */\n\nimport type { AssistantMode } from '@/types/assistant';\n\n/**\n * Marks where our instructions stop and the user's words begin. Exactly one may\n * exist in a prompt, and it must be last — see `buildPromptForMode`.\n */\nexport const USER_REQUEST_DELIMITER = '--- User request ---';\n\nexport const API_CALLS_CONFIRM_PREAMBLE = [\n \"You are in api-calls mode for HealthyBowl and can run GraphQL queries and mutations on the user's behalf.\",\n 'Before performing ANY write (create, update, delete — any mutation):',\n '1. State exactly what you are about to change (entity, fields, and values).',\n '2. Ask the user to confirm, and WAIT for an explicit \"yes\"/\"confirm\" before executing it.',\n 'Read-only queries may run without confirmation. Confirm each write separately; never batch mutations behind a single confirmation.',\n '',\n USER_REQUEST_DELIMITER,\n].join('\\n');\n\n/**\n * Ask for the reply in the user's language (BOFF-7107).\n *\n * Nothing else does. The sandbox system prompt carries no language instruction,\n * the grounding documentation is entirely in English, and the persona insists on\n * grounding in it — so every force in the session pushes the answer towards\n * English regardless of what the user wrote. The model's tendency to mirror the\n * input is the only thing resisting that, and it is being outvoted.\n *\n * Three deliberate choices:\n *\n * - **The user's own language wins over the UI language.** The chrome being in\n * English says nothing about the person typing Tamil into it; treating the\n * locale as an instruction rather than a default would be the actual bug.\n * - **Translate the docs, do not switch to their language.** This is the clause\n * that matters. Without it a grounded answer drifts back to English mid-reply\n * simply because the source material is English.\n * - **Prepended per TURN, not sent as `system`.** The transport's `system` field\n * REPLACES the whole mode prompt, which would silently delete the docs and\n * api-calls instructions along with it.\n */\n/**\n * The instruction lines only — deliberately WITHOUT the delimiter.\n *\n * The delimiter marks where our instructions stop and the user's words begin, so\n * exactly one may exist and it must be last. Emitting it here too put a second\n * one mid-prompt, which left the api-calls safety instructions sitting *after* a\n * \"User request\" marker — i.e. presented to the model as though the user had\n * written them. `buildPromptForMode` owns placing it, once.\n */\n/**\n * Told to the model when the turn was SPOKEN rather than typed.\n *\n * Speech recognition does not fail uniformly — it fails on specific words, and\n * the ones it fails on here are predictable: English technical terms, product\n * and crop names, and numbers spoken inside an Indic sentence. A recogniser set\n * to `ta-IN` has no good model for \"urea\", \"pH\" or \"NPK\", so a Tamil sentence\n * comes back mostly right with a few words wrong. That is exactly the report:\n * \"some word some times\".\n *\n * The model is far better placed to repair that than the recogniser is, because\n * it has the farming context — but only if it is TOLD the text was dictated.\n * Otherwise it answers the garbled word literally, which is what makes the\n * assistant look like it misunderstood.\n *\n * ★ The refusal to guess is the important half. Charitable interpretation is\n * right for a mangled verb and dangerous for a mangled QUANTITY: this is\n * agriculture, and a dose or a unit that the recogniser mis-heard must be asked\n * about, not inferred. One extra question costs a few seconds; a wrong dose\n * costs a crop.\n */\nconst DICTATION_PREAMBLE = [\n 'This message was DICTATED using speech recognition, so some words may be mis-heard.',\n 'Errors cluster on English technical terms, product and crop names, and numbers spoken inside a sentence in another language.',\n 'Read the message for INTENT rather than literally: where a word is clearly a recognition error, infer what was meant from the agricultural context instead of answering the garbled word.',\n 'But do NOT guess when a mis-heard word would change what is being asked — a crop, a chemical, a quantity or a unit. Ask one short clarifying question instead. A wrong dose is far worse than an extra question.',\n].join('\\n');\n\n/**\n * Told to the model when its answer will be SPOKEN ALOUD, not read.\n *\n * The assistant was never told this, so it replied the way it replies in chat:\n * documentation-style markdown with `##` headings, `**bold**` and long\n * enumerated sections. In the chat panel that renders correctly. In the voice\n * panel it is read aloud AND shown as a caption, where the syntax is literal\n * and the length is unusable — the operator screenshotted a live session whose\n * caption was a wall of \"### **Budget Planning Features:**\".\n *\n * ★ This is the fix at SOURCE. Stripping markdown at render time is a\n * necessary backstop, but it cannot shorten a 500-word answer that was never\n * meant to be listened to. A spoken reply has to be short because the listener\n * cannot skim it.\n */\nconst VOICE_REPLY_PREAMBLE = [\n 'Your answer will be SPOKEN ALOUD and shown as a live caption, not read as a document.',\n 'Write plain conversational sentences. Use NO markdown whatsoever: no #, ##, ###, no **bold**, no bullet or numbered lists, no tables, no code fences.',\n 'Keep it SHORT — normally one to four sentences. The listener cannot skim, so a long answer is worse than an incomplete one.',\n 'If the full answer is genuinely long, give the useful part first and offer to go deeper, rather than listing every option.',\n 'Speak numbers, units and quantities the way a person says them.',\n].join('\\n');\n\nexport function buildLanguagePreamble(languageName: string, isExplicitChoice = false): string {\n return [\n `Answer in ${languageName}.`,\n // The mirror clause is right for a DEFAULT and wrong for a CHOICE.\n //\n // Derived from the interface language it is only a guess, and the language\n // the user actually wrote in is better evidence. But once they have picked a\n // language deliberately, \"what they wrote in wins\" silently overrides them —\n // and it does so hardest for people who TYPE, since a typed English question\n // would come back in English no matter what they selected. That makes the\n // preference inert for exactly the users who cannot dictate.\n isExplicitChoice\n ? `The user has chosen ${languageName} deliberately: answer in it even when their message is written in another language.`\n : 'If the user writes in a different language, answer in THAT language instead — what they wrote in always wins.',\n 'Your documentation and tool output are in English: translate what you quote from them rather than switching language.',\n ].join('\\n');\n}\n\n/**\n * `languageName` is the human name of the user's language (\"Tamil\"), not a code:\n * a code invites the model to answer *about* the tag instead of *in* it.\n * Omitted (or empty) leaves the prompt untouched, so a caller without locale\n * context behaves exactly as before.\n *\n * Order is load-bearing: instructions, then the delimiter, then the user's text.\n * The language preamble goes FIRST so the api-calls preamble keeps its own\n * delimiter adjacent to the content it introduces.\n */\nexport function buildPromptForMode(\n mode: AssistantMode,\n content: string,\n languageName?: string,\n isExplicitChoice = false,\n dictated = false\n): string {\n // Dictation goes AFTER the language lines and before the delimiter: it is an\n // instruction about the user's text, so it belongs with the instructions, not\n // inside them. Defaults to false, so every typed turn is byte-identical to\n // before — the composer's own dictation is excluded deliberately, because the\n // user can read and edit that text before sending it.\n const preamble = [\n languageName ? buildLanguagePreamble(languageName, isExplicitChoice) : '',\n dictated ? DICTATION_PREAMBLE : '',\n // A dictated turn is a SPOKEN conversation, so the reply is spoken too.\n dictated ? VOICE_REPLY_PREAMBLE : '',\n ]\n .filter(Boolean)\n .join('\\n\\n');\n const language = preamble ? `${preamble}\\n\\n` : '';\n if (mode === 'api-calls') return `${language}${API_CALLS_CONFIRM_PREAMBLE}\\n${content}`;\n return language ? `${language}${USER_REQUEST_DELIMITER}\\n${content}` : content;\n}\n"],"mappings":";AAkBA,IAAa,IAAyB,wBAEzB,IAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI,GAqDL,IAAqB;CACzB;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI,GAiBL,IAAuB;CAC3B;CACA;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI;AAEX,SAAgB,EAAsB,GAAsB,IAAmB,IAAe;CAC5F,OAAO;EACL,aAAa,EAAa;EAS1B,IACI,uBAAuB,EAAa,uFACpC;EACJ;CACF,EAAE,KAAK,IAAI;AACb;AAYA,SAAgB,EACd,GACA,GACA,GACA,IAAmB,IACnB,IAAW,IACH;CAMR,IAAM,IAAW;EACf,IAAe,EAAsB,GAAc,CAAgB,IAAI;EACvE,IAAW,IAAqB;EAEhC,IAAW,IAAuB;CACpC,EACG,OAAO,OAAO,EACd,KAAK,MAAM,GACR,IAAW,IAAW,GAAG,EAAS,QAAQ;CAEhD,OADI,MAAS,cAAoB,GAAG,IAAW,EAA2B,IAAI,MACvE,IAAW,GAAG,IAAW,EAAuB,IAAI,MAAY;AACzE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.919.2",
3
+ "version": "2026.919.4",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@apollo/client": "^4.0.11",
51
- "@burdenoff/fe-libs": "2026.905.2",
51
+ "@burdenoff/fe-libs": "2026.917.2",
52
52
  "@burdenoff/planmagnet-fe-sdk": "2026.831.1",
53
53
  "@tanstack/react-query": "^5.90.16",
54
54
  "clsx": "^2.1.1",
@@ -1 +0,0 @@
1
- import "react";