@feedmepos/mf-inventory-portal 1.9.3-dev.0 → 1.10.0-dev.1

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.
Files changed (121) hide show
  1. package/dist/{App-CiOQuHhw.js → App-Dh-kak5M.js} +10 -10
  2. package/dist/{ApprovalView-C69CJTQj.js → ApprovalView-CQX3SsKB.js} +9 -9
  3. package/dist/{BindingsDialog-BI6xhJIE.js → BindingsDialog-gu29ZfJG.js} +2 -2
  4. package/dist/{BindingsPicker-CsofUw7f.js → BindingsPicker-D-OQFQKj.js} +2 -2
  5. package/dist/{BindingsTable-CGqaAZdg.js → BindingsTable-BoyC_OGE.js} +4 -4
  6. package/dist/{BulkReceiveRequestPage-C1m_p636.js → BulkReceiveRequestPage-CG1tJiPv.js} +19 -19
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-BAl8fTbk.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-hwA8FeAr.js} +1 -1
  8. package/dist/{ClosingDraftView-Ch2zpgwQ.js → ClosingDraftView-BzSFe5xy.js} +19 -19
  9. package/dist/{ClosingHistoryView-BwrEDI87.js → ClosingHistoryView-CL9wEpk4.js} +7 -7
  10. package/dist/{ClosingTemplateView-D8LeWon8.js → ClosingTemplateView-DU5pmH7f.js} +18 -18
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-DJ7DJJ7r.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-8Gs3fabn.js} +1 -1
  12. package/dist/{DefaultView-y3LsWxu2.js → DefaultView-QC__zfSG.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-B7TU851r.js → DeliveryOrderPrintPreview-Br1-XWrD.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-DaYXvUzy.js → EmailDialog.vue_vue_type_script_setup_true_lang-7O63bX20.js} +23 -23
  15. package/dist/{FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-BXVHbxri.js → FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-pwAMIprj.js} +1 -1
  16. package/dist/{FeatureCapabilityGate-BtSsonTW.js → FeatureCapabilityGate-BlJTbmsn.js} +2 -2
  17. package/dist/{FeaturePageGate.vue_vue_type_script_setup_true_lang-BxeC99Sg.js → FeaturePageGate.vue_vue_type_script_setup_true_lang-C-wsskNh.js} +1 -1
  18. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-DaScMVvk.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-DJBUQ-kR.js} +1 -1
  19. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DXoImNxb.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CE7AGfPC.js} +2 -2
  20. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-C96aUMR0.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BxPPEvtB.js} +2 -2
  21. package/dist/{FmMultiselectDialog-FNx_49Vd.js → FmMultiselectDialog-BJqR7vhA.js} +2 -2
  22. package/dist/{FmMultiselectDialog-B4-3K0fn.js → FmMultiselectDialog-C5FLM0Gh.js} +2 -2
  23. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BQ7zvVhF.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D5LL15Um.js} +5 -5
  24. package/dist/{ImportView-CWBDYeHh.js → ImportView-C2X3208X.js} +7 -7
  25. package/dist/{IngredientsView-C0X8c_0v.js → IngredientsView-CHWaXQlL.js} +15 -15
  26. package/dist/{IntegrationExplorerView-YWCS-Rr-.js → IntegrationExplorerView-t1J4l6Id.js} +6 -6
  27. package/dist/{IntegrationPlatformView-DUtta7MJ.js → IntegrationPlatformView-BYA6Tkst.js} +1606 -1590
  28. package/dist/{IntegrationView-C3GUvk9o.js → IntegrationView-CsJTx007.js} +15 -15
  29. package/dist/{InventoryBindingForm-Do329DkB.js → InventoryBindingForm-ho7g7G7Q.js} +1 -1
  30. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-B-6fV7fu.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-B_qROp0_.js} +4 -4
  31. package/dist/{InventoryBindingSummary-COB3W5cb.js → InventoryBindingSummary-fmA89SF4.js} +1 -1
  32. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CPwjN7Y4.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BwwlcRgG.js} +2 -2
  33. package/dist/ProductionRunDetailPage-BrJn9FLp.js +2335 -0
  34. package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-BWBXX4SU.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-DpnHaoe1.js} +6870 -6281
  35. package/dist/{ProductionRunPage-DkQjat-b.js → ProductionRunPage-H26MFgS2.js} +4 -4
  36. package/dist/{PublishView-B0tpsVGk.js → PublishView-CSrSkoWX.js} +5 -5
  37. package/dist/{PurchaseOrderPrintPreview-CEMExbly.js → PurchaseOrderPrintPreview-DoNXyUAq.js} +2 -2
  38. package/dist/{ReceiveRequestView-CsDnM11Q.js → ReceiveRequestView-Wb7YJX63.js} +14 -14
  39. package/dist/{RecipeView-BPD7Y9I0.js → RecipeView-KCQpJ7SS.js} +16 -16
  40. package/dist/{SettingsView-BYNYWMKW.js → SettingsView-DoG_F33c.js} +7 -7
  41. package/dist/{StockView-DXg1cc3t.js → StockView-B4HZXRN8.js} +21 -21
  42. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CBS2nasQ.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-ryrooMzm.js} +1 -1
  43. package/dist/{SupplierView-DbQF6Uyz.js → SupplierView-CtTB7Lpn.js} +13 -13
  44. package/dist/{SurchargeView-DbdHhrLf.js → SurchargeView-zgXKeGMc.js} +7 -7
  45. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-BvNSFmMe.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-JpxxNRit.js} +2 -2
  46. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-MejrG1jm.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BZ5blyev.js} +1 -1
  47. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-JS7yBums.js → TransferDetails.vue_vue_type_script_setup_true_lang-ByNBMoFV.js} +21 -21
  48. package/dist/{TransferTemplateView-B8on3zV0.js → TransferTemplateView-CO6FrzLy.js} +19 -19
  49. package/dist/{UnitCostHistoryView-i51A-5cK.js → UnitCostHistoryView-D7TbmKZD.js} +4 -4
  50. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-DXQvpWHC.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-DFXdIqSl.js} +4 -4
  51. package/dist/{UnitView-DsvJqbId.js → UnitView-BgqDqxfJ.js} +7 -7
  52. package/dist/{WarehouseView-CN_ahRSa.js → WarehouseView-BaieJUXC.js} +8 -8
  53. package/dist/{WastageTemplateView-DuCU_nBJ.js → WastageTemplateView-BYadevlz.js} +15 -15
  54. package/dist/api/netsuite.d.ts +8 -14
  55. package/dist/api/production-run-error.d.ts +26 -1
  56. package/dist/{app-6I8ZFr27.js → app-Dq9I3XI4.js} +9203 -9392
  57. package/dist/app.d.ts +328 -248
  58. package/dist/app.js +1 -1
  59. package/dist/{bulk-edit-simulation.helper-DDgaZf_R.js → bulk-edit-simulation.helper-LRxVzNpt.js} +2 -2
  60. package/dist/{closing-template-BSsPxnVF.js → closing-template-Dq0lVYML.js} +1 -1
  61. package/dist/{date2-GOP7g_bU.js → date2-C9a2hGF2.js} +1 -1
  62. package/dist/{dayjs.min-DEbDvLfu.js → dayjs.min-Boe04IJA.js} +1 -1
  63. package/dist/{decimal-I8CLMbAA.js → decimal-CapXS7w9.js} +2 -2
  64. package/dist/{defineDeepModel-CVn-T1iW.js → defineDeepModel-BCkw0D6y.js} +1 -1
  65. package/dist/{duplicate-template-CnIO7Xsj.js → duplicate-template-CDPD2O_k.js} +1 -1
  66. package/dist/{feature-zHW3ip-x.js → feature-CQUUcJxS.js} +21 -25
  67. package/dist/{format-time-from-id-DddiiGNz.js → format-time-from-id-BwhlcY5A.js} +1 -1
  68. package/dist/{format-unit-display-wDV9J26j.js → format-unit-display-D_DT29Nz.js} +12 -12
  69. package/dist/{id-to-date-D4JNCgjx.js → id-to-date-BhRK-01j.js} +1 -1
  70. package/dist/{import-export.helper-D7Uznl2F.js → import-export.helper-CixS7WaZ.js} +5 -5
  71. package/dist/{index-DqBH6CEX.js → index-CnZ9aT0W.js} +3 -3
  72. package/dist/{index-qe8J3LVW.js → index-DeOfF5Tt.js} +1 -1
  73. package/dist/{index-BP0BliuR.js → index-v4n0mtqr.js} +1 -1
  74. package/dist/{lz-string-nJvgtabI.js → lz-string-CIIInye8.js} +1 -1
  75. package/dist/{netsuite-CmBb3aml.js → netsuite-C54-843n.js} +2 -2
  76. package/dist/{netsuite-explorer-C_4qkkqX.js → netsuite-explorer-CgZteVAI.js} +1 -1
  77. package/dist/{predefined-templates-8sXIcivc.js → predefined-templates-C1I7RY5M.js} +1 -1
  78. package/dist/{publish-versions-DGvcQiOp.js → publish-versions-CZhfCqmR.js} +1 -1
  79. package/dist/{purchase-order-template-CdMWIXpQ.js → purchase-order-template-CQwJPOSt.js} +1 -1
  80. package/dist/{recalculationUtils-DXb7x3Xk.js → recalculationUtils-CV6n3RIc.js} +1 -1
  81. package/dist/{row-action.enum-BzbzZ5bN.js → row-action.enum-CfQIiMG1.js} +1 -1
  82. package/dist/{rules-BK5Dul4y.js → rules-BegeNAnD.js} +3 -3
  83. package/dist/{stock-C10cihjj.js → stock-BRjx4AbX.js} +1 -1
  84. package/dist/{stock-BknAZQ48.js → stock-DlDmFyoj.js} +2 -2
  85. package/dist/stores/inventory.d.ts +8 -10
  86. package/dist/stores/stock.d.ts +8 -10
  87. package/dist/style.css +1 -1
  88. package/dist/{supplier-5m-phEol.js → supplier-C-b_06_2.js} +2 -2
  89. package/dist/{surcharge-D7OCkL0j.js → surcharge-DZLtgZPI.js} +1 -1
  90. package/dist/tsconfig.app.tsbuildinfo +1 -1
  91. package/dist/{uom-rules-CyvlOZPO.js → uom-rules-9RjY5mdp.js} +1 -1
  92. package/dist/{use-ingredient-select-dialog-HhCypq52.js → use-ingredient-select-dialog-BCXNckRG.js} +2 -2
  93. package/dist/{use-inventory-binding-dialog-BMiNYNXV.js → use-inventory-binding-dialog-C2jghyFw.js} +2 -2
  94. package/dist/{use-template-enabled-locations-xqWZsGTv.js → use-template-enabled-locations-LVGn5xj5.js} +2 -2
  95. package/dist/{use-transfer-locations-yDC04RRt.js → use-transfer-locations-CuaqR9iW.js} +2 -2
  96. package/dist/{useHrmPermission-slYF_cER.js → useHrmPermission-C_aX175n.js} +1 -1
  97. package/dist/{useNavigationMenu-DI7vTxwl.js → useNavigationMenu-DMXSWSlw.js} +5 -5
  98. package/dist/{useSseClient-BWIU-WLd.js → useSseClient-BM0l1uNj.js} +1 -1
  99. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.vue.d.ts +16 -20
  100. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +32 -40
  101. package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupDetailSideSheet.vue.d.ts +16 -20
  102. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +48 -60
  103. package/dist/views/closing-draft/composables/use-closing-draft-import.d.ts +8 -10
  104. package/dist/views/production-run/features/output/use-production-run-record-output.d.ts +3 -1
  105. package/dist/views/production-run/features/planning/use-production-run-form.d.ts +19 -0
  106. package/dist/views/production-run/features/prepare/PrepareRunConfirmationDialog.vue.d.ts +2 -0
  107. package/dist/views/production-run/shared/model/production-run-plan-problem.d.ts +20 -0
  108. package/dist/views/production-run/shared/model/production-run-plan-problem.spec.d.ts +1 -0
  109. package/dist/views/production-run/shared/model/production-run-refusal.d.ts +23 -0
  110. package/dist/views/production-run/shared/model/use-production-run-actions.d.ts +2 -0
  111. package/dist/views/production-run/shared/model/use-production-run-ingredients.d.ts +24 -42
  112. package/dist/views/production-run/shared/ui/ProductionRunProjectionFeedback.vue.d.ts +13 -0
  113. package/dist/views/production-run/test-support/production-run.fixture.d.ts +4 -25
  114. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +8 -12
  115. package/dist/views/stock/components/dialog/AmendAdjustmentForm.vue.d.ts +0 -2
  116. package/dist/{vue-jN_8HeeE.js → vue-ZvgRmbwh.js} +2 -2
  117. package/dist/{vue-i18n-jmTuXNbR.js → vue-i18n-Q96C38GI.js} +169 -169
  118. package/dist/{xlsx.util-BPevMvrr.js → xlsx.util-568g2puT.js} +2 -2
  119. package/package.json +4 -4
  120. package/dist/ProductionRunDetailPage-DpyTf2_6.js +0 -2317
  121. package/dist/views/production-run/shared/ui/ProductionRunCostingUnavailable.vue.d.ts +0 -2
@@ -0,0 +1,2335 @@
1
+ import { defineComponent as Q, computed as _, ref as j, resolveComponent as te, createElementBlock as v, openBlock as r, Fragment as W, createElementVNode as o, createBlock as B, createCommentVNode as R, createVNode as q, withCtx as ne, createTextVNode as ie, toDisplayString as p, unref as e, renderList as oe, Teleport as Ce, normalizeClass as z, watch as se, renderSlot as ve, createSlots as et, nextTick as Ie, toValue as fe, onBeforeUnmount as tt } from "vue";
2
+ import { useRouter as Se } from "vue-router";
3
+ import { _ as re, a as nt } from "./FeaturePageGate.vue_vue_type_script_setup_true_lang-C-wsskNh.js";
4
+ import { u as Ae, n as ot } from "./app-Dq9I3XI4.js";
5
+ import { useBreakpoints as at, useDialog as rt, useSnackbar as st } from "@feedmepos/ui-library";
6
+ import { useI18n as Y } from "@feedmepos/mf-common";
7
+ import { c as pe, b as it, _ as lt, h as Pe, m as ut, n as Ee, o as De, r as Me, s as dt, q as Ve, t as Ue, v as He, N as le, f as F, w as ze, x as We, y as ct, z as ge, A as pt, B as mt, C as vt, D as Ge, E as bt, a as yt, F as Ne, G as ft, H as gt, I as ht, u as Ke, J as _t, K as we, L as kt, M as $t, O as xt, i as wt, p as It, j as be, Q as Le, d as Rt, e as St, R as At, S as Pt, T as Lt, U as qt, V as Tt, g as Bt, l as Ct, W as Nt } from "./ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-DpnHaoe1.js";
8
+ import { p as Ot } from "./production-run-list-DR1WsaBR.js";
9
+ import { _ as me } from "./_plugin-vue_export-helper-CHgC5LLL.js";
10
+ import { g as Oe } from "./rules-BegeNAnD.js";
11
+ const jt = { class: "flex flex-col gap-12" }, Ft = {
12
+ "data-testid": "production-run-header-layout",
13
+ class: "relative flex flex-col items-stretch gap-16 lg:flex-row lg:items-start"
14
+ }, Et = {
15
+ "data-testid": "production-run-header-copy",
16
+ class: "grow min-w-0 flex flex-col gap-4"
17
+ }, Dt = { class: "fm-typo-en-title-lg-600 break-words text-fm-color-typo-primary" }, Mt = {
18
+ "data-testid": "production-run-caption",
19
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
20
+ }, Vt = { class: "mt-4 flex items-center" }, Ut = {
21
+ "data-testid": "production-run-header-actions",
22
+ class: "flex shrink-0 flex-wrap items-center justify-start gap-8 lg:justify-end"
23
+ }, Ht = { key: 0 }, zt = {
24
+ key: 0,
25
+ "data-testid": "production-run-header-overflow"
26
+ }, Wt = ["data-testid"], Gt = {
27
+ key: 2,
28
+ "data-testid": "production-run-header-secondary-print"
29
+ }, Kt = { class: "fixed bottom-64 right-16 z-40" }, je = "__print_prepare_sheet__", Qt = /* @__PURE__ */ Q({
30
+ __name: "ProductionRunHeader",
31
+ props: {
32
+ run: {},
33
+ locationName: {},
34
+ primaryAction: {},
35
+ secondaryActions: {},
36
+ dangerActions: {},
37
+ canPrintPrepareSheet: { type: Boolean },
38
+ backTo: {},
39
+ backLabel: {},
40
+ statusDescription: {},
41
+ targetReached: { type: Boolean },
42
+ busy: { type: Boolean }
43
+ },
44
+ emits: ["action", "print-prepare-sheet"],
45
+ setup(P, { emit: c }) {
46
+ const t = P, k = c, { t: l } = Y(), { breakpoints: u } = at(), x = _(() => u.value.xs), f = _(() => u.value.sm || u.value.md), $ = j(!1), w = _(
47
+ () => Ot(t.run, l("inventory.production.run.list.untitled"))
48
+ ), a = _(() => {
49
+ const b = t.run.activityLogs, S = b.length ? b[b.length - 1] : null, y = (S == null ? void 0 : S.performedAt) ?? t.run.createdAt, N = S && S.action !== "create" ? l("inventory.production.run.list.columns.updated") : l("inventory.production.run.detail.created"), E = [`# ${t.run.runNo}`, t.locationName].filter(Boolean);
50
+ return y && E.push(`${N} ${pe(y)}`), E.join(" · ");
51
+ }), I = (b) => b === "complete" && Pe(t.run) ? l("inventory.production.run.detail.pendingStock.resume") : b === "complete" && t.targetReached ? l("inventory.production.run.detail.action.recordAdditionalOutput") : l(`inventory.production.run.detail.action.${b}`, ut[b]), s = _(() => t.dangerActions.length > 0), i = _(
52
+ () => t.dangerActions.map((b) => ({
53
+ id: b,
54
+ label: I(b),
55
+ destructive: !0,
56
+ disabled: t.busy
57
+ }))
58
+ ), m = _(() => [
59
+ ...t.secondaryActions.map((b) => ({
60
+ id: b,
61
+ label: I(b),
62
+ disabled: t.busy
63
+ })),
64
+ ...t.canPrintPrepareSheet ? [
65
+ {
66
+ id: je,
67
+ label: l("inventory.production.run.detail.printPrepareSheet"),
68
+ disabled: t.busy
69
+ }
70
+ ] : [],
71
+ ...i.value
72
+ ]), n = _(
73
+ () => m.value.map(
74
+ (b) => ({
75
+ label: b.label,
76
+ value: b.id,
77
+ disabled: b.disabled
78
+ })
79
+ )
80
+ ), d = _(() => {
81
+ const b = s.value ? [{ key: "overflow", kind: "overflow" }] : [], S = t.secondaryActions.map((E) => ({
82
+ key: `secondary-${E}`,
83
+ kind: "lifecycle",
84
+ action: E,
85
+ variant: "secondary"
86
+ })), y = t.canPrintPrepareSheet ? [{ key: "print", kind: "print" }] : [], N = t.primaryAction ? [
87
+ {
88
+ key: `primary-${t.primaryAction}`,
89
+ kind: "lifecycle",
90
+ action: t.primaryAction,
91
+ variant: "primary"
92
+ }
93
+ ] : [];
94
+ return f.value ? [...N, ...S, ...y, ...b] : [...b, ...S, ...y, ...N];
95
+ });
96
+ function g(b) {
97
+ k("action", b);
98
+ }
99
+ function T(b) {
100
+ if (!t.busy) {
101
+ if ($.value = !1, b === je) {
102
+ k("print-prepare-sheet");
103
+ return;
104
+ }
105
+ g(b);
106
+ }
107
+ }
108
+ const C = _(() => l(`inventory.production.run.list.status.${t.run.status}`)), V = _(
109
+ () => l("inventory.production.run.detail.statusHelp", { status: C.value })
110
+ );
111
+ return (b, S) => {
112
+ const y = te("FmIcon"), N = te("RouterLink"), E = te("FmButton"), U = te("FmCollapsibleTabs"), Z = te("FmBottomSheet");
113
+ return r(), v(W, null, [
114
+ o("header", jt, [
115
+ q(N, {
116
+ to: b.backTo,
117
+ "data-testid": "production-run-back",
118
+ class: "-ml-12 inline-flex h-32 w-fit items-center gap-4 rounded-md px-12 fm-typo-en-body-sm-600 leading-[18px] text-fm-color-typo-secondary hover:bg-fm-color-opacity-sm hover:text-fm-color-typo-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-fm-color-primary print:hidden"
119
+ }, {
120
+ default: ne(() => [
121
+ q(y, {
122
+ name: "arrow_back",
123
+ size: "sm",
124
+ "aria-hidden": "true"
125
+ }),
126
+ ie(" " + p(b.backLabel ?? e(l)("inventory.production.run.detail.back")), 1)
127
+ ]),
128
+ _: 1
129
+ }, 8, ["to"]),
130
+ o("div", Ft, [
131
+ o("div", Et, [
132
+ o("h1", Dt, p(w.value), 1),
133
+ o("p", Mt, p(a.value), 1),
134
+ o("div", Vt, [
135
+ q(it, {
136
+ status: b.run.status,
137
+ tooltip: b.statusDescription,
138
+ "accessible-label": V.value,
139
+ "help-icon": ""
140
+ }, null, 8, ["status", "tooltip", "accessible-label"])
141
+ ])
142
+ ]),
143
+ o("div", Ut, [
144
+ x.value && m.value.length ? (r(), v("div", Ht, [
145
+ q(E, {
146
+ type: "button",
147
+ variant: "tertiary",
148
+ "prepend-icon": "more_vert",
149
+ "aria-label": e(l)("inventory.production.run.detail.moreActions"),
150
+ disabled: b.busy,
151
+ "data-testid": "production-run-detail-mobile-more",
152
+ onClick: S[0] || (S[0] = (O) => $.value = !0)
153
+ }, null, 8, ["aria-label", "disabled"])
154
+ ])) : R("", !0),
155
+ (r(!0), v(W, null, oe(x.value ? [] : d.value, (O) => (r(), v(W, {
156
+ key: O.key
157
+ }, [
158
+ O.kind === "overflow" ? (r(), v("div", zt, [
159
+ q(lt, {
160
+ items: i.value,
161
+ placement: "bottom-end",
162
+ "accessible-label": e(l)("inventory.production.run.detail.moreActions"),
163
+ disabled: b.busy,
164
+ onSelect: g
165
+ }, null, 8, ["items", "accessible-label", "disabled"])
166
+ ])) : O.kind === "lifecycle" ? (r(), v("div", {
167
+ key: 1,
168
+ "data-testid": `production-run-header-${O.variant}-${O.action}`
169
+ }, [
170
+ q(E, {
171
+ variant: O.variant,
172
+ label: I(O.action),
173
+ disabled: b.busy,
174
+ loading: O.variant === "primary" && b.busy,
175
+ onClick: (X) => k("action", O.action)
176
+ }, null, 8, ["variant", "label", "disabled", "loading", "onClick"])
177
+ ], 8, Wt)) : (r(), v("div", Gt, [
178
+ q(E, {
179
+ variant: "secondary",
180
+ icon: "print",
181
+ label: e(l)("inventory.production.run.detail.printPrepareSheet"),
182
+ disabled: b.busy,
183
+ onClick: S[1] || (S[1] = (X) => k("print-prepare-sheet"))
184
+ }, null, 8, ["label", "disabled"])
185
+ ]))
186
+ ], 64))), 128))
187
+ ])
188
+ ])
189
+ ]),
190
+ x.value && b.primaryAction ? (r(), B(Ce, {
191
+ key: 0,
192
+ to: "body"
193
+ }, [
194
+ o("div", Kt, [
195
+ q(E, {
196
+ "data-testid": "production-run-detail-mobile-primary",
197
+ variant: "fab",
198
+ label: I(b.primaryAction),
199
+ "prepend-icon": b.primaryAction === "complete" ? "add" : void 0,
200
+ loading: b.busy,
201
+ onClick: S[2] || (S[2] = (O) => k("action", b.primaryAction))
202
+ }, null, 8, ["label", "prepend-icon", "loading"])
203
+ ])
204
+ ])) : R("", !0),
205
+ x.value && m.value.length ? (r(), B(Ce, {
206
+ key: 1,
207
+ to: "body"
208
+ }, [
209
+ q(Z, {
210
+ modelValue: $.value,
211
+ "onUpdate:modelValue": S[3] || (S[3] = (O) => $.value = O),
212
+ "dismiss-away": "",
213
+ "no-header": ""
214
+ }, {
215
+ default: ne(() => [
216
+ q(U, {
217
+ class: "pb-8",
218
+ items: n.value,
219
+ "data-testid": "production-run-detail-mobile-menu",
220
+ "onUpdate:modelValue": T
221
+ }, null, 8, ["items"])
222
+ ]),
223
+ _: 1
224
+ }, 8, ["modelValue"])
225
+ ])) : R("", !0)
226
+ ], 64);
227
+ };
228
+ }
229
+ }), Zt = /* @__PURE__ */ me(Qt, [["__scopeId", "data-v-9715608c"]]), Jt = ["aria-labelledby"], Yt = { class: "flex min-h-56 items-center px-16 py-12" }, Xt = ["id"], en = ["aria-label"], tn = { key: 0 }, nn = { class: "border-y border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100" }, on = { class: "production-run-table-header h-40 border-b border-fm-color-neutral-gray-200 fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, an = { class: "text-left px-16 py-8 font-inherit" }, rn = {
230
+ key: 0,
231
+ class: "text-right px-16 py-8 font-inherit"
232
+ }, sn = { class: "px-16 py-12 align-top fm-typo-en-body-md-400 text-fm-color-typo-primary" }, ln = { class: "block fm-typo-en-body-md-600" }, un = {
233
+ key: 0,
234
+ class: "px-16 py-12 text-right fm-typo-en-body-md-400 text-fm-color-typo-secondary tabular-nums"
235
+ }, dn = { key: 0 }, cn = {
236
+ key: 1,
237
+ class: "text-fm-color-typo-disabled"
238
+ }, pn = { key: 0 }, mn = {
239
+ key: 1,
240
+ class: "text-fm-color-typo-success"
241
+ }, vn = { key: 0 }, bn = ["colspan"], yn = { class: "production-run-items-bindings-sticky bg-fm-color-surface-primary px-16 pb-12 pt-4" }, fn = {
242
+ key: 0,
243
+ "data-testid": "unattributed-issued-ingredients",
244
+ class: "border-t border-fm-color-border-default bg-fm-color-surface-secondary px-16 py-12"
245
+ }, gn = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-warning" }, hn = { class: "mt-2 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _n = /* @__PURE__ */ Q({
246
+ __name: "ProductionRunItemsTable",
247
+ props: {
248
+ run: {},
249
+ names: {},
250
+ ingredientContributions: { default: () => ({}) },
251
+ unattributedIngredients: { default: () => [] },
252
+ unissuedSkuIds: { default: () => [] },
253
+ titleKey: { default: "inventory.production.run.detail.items.title" },
254
+ presentation: { default: "review" }
255
+ },
256
+ setup(P) {
257
+ const c = P, { t } = Y(), k = j(/* @__PURE__ */ new Set()), l = _(() => c.presentation === "preparing"), u = _(
258
+ () => {
259
+ var n;
260
+ return /* @__PURE__ */ new Set([
261
+ ...((n = c.run.plan.requirements) == null ? void 0 : n.skippedSkuIds) ?? [],
262
+ ...c.run.preparation.issuances.flatMap((d) => d.skippedSkuIds ?? [])
263
+ ]);
264
+ }
265
+ ), x = _(() => new Set(c.unissuedSkuIds));
266
+ function f(n) {
267
+ return l.value ? u.value.has(n) ? !0 : !c.run.plan.requirements && c.unattributedIngredients.length === 0 && x.value.has(n) : !1;
268
+ }
269
+ function $(n) {
270
+ return c.ingredientContributions[n] ?? [];
271
+ }
272
+ function w(n, d) {
273
+ return d > 0 ? n.issued / d : n.issued;
274
+ }
275
+ function a(n) {
276
+ return `production-run-output-ingredients-${n}`;
277
+ }
278
+ function I(n) {
279
+ const d = new Set(k.value);
280
+ d.has(n) ? d.delete(n) : d.add(n), k.value = d;
281
+ }
282
+ function s(n) {
283
+ return $(n.skuId).map((d) => ({
284
+ id: d.skuId,
285
+ name: d.name,
286
+ amount: w(d, n.committed),
287
+ unit: d.unit ?? ""
288
+ }));
289
+ }
290
+ function i(n) {
291
+ return `production-run-committed-description-${n.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
292
+ }
293
+ const m = _(() => {
294
+ var V;
295
+ const n = Ee(c.run), d = De(c.run), g = Me(c.run), T = {}, C = /* @__PURE__ */ new Set();
296
+ for (const b of c.run.plan.items) {
297
+ const S = (V = c.run.preparation.issuances.flatMap((N) => N.items).find((N) => N.sku._id === b.skuId)) == null ? void 0 : V.sku.unit, y = S ? dt(b.measurement, S) : null;
298
+ if (!y) {
299
+ C.add(b.skuId), T[b.skuId] = null;
300
+ continue;
301
+ }
302
+ C.has(b.skuId) || (T[b.skuId] = (T[b.skuId] ?? 0) + Ve(b.requestedAmount, y));
303
+ }
304
+ return Object.keys(n).map((b) => {
305
+ var S, y;
306
+ return {
307
+ skuId: b,
308
+ name: ((S = c.names[b]) == null ? void 0 : S.name) ?? b,
309
+ unit: ((y = c.names[b]) == null ? void 0 : y.unit) ?? null,
310
+ requested: T[b] ?? null,
311
+ committed: n[b] ?? 0,
312
+ produced: d[b] ?? 0,
313
+ remaining: g[b] ?? 0
314
+ };
315
+ });
316
+ });
317
+ return (n, d) => (r(), v("section", {
318
+ class: "border border-fm-color-neutral-gray-200 fm-corner-radius-md overflow-hidden bg-fm-color-surface-primary",
319
+ "aria-labelledby": l.value ? "items-to-produce-title" : void 0
320
+ }, [
321
+ o("header", Yt, [
322
+ o("h2", {
323
+ id: l.value ? "items-to-produce-title" : void 0,
324
+ class: "fm-typo-en-body-lg-600"
325
+ }, [
326
+ ie(p(e(t)(n.titleKey)), 1),
327
+ l.value ? (r(), v(W, { key: 0 }, [
328
+ ie(" (" + p(m.value.length) + ")", 1)
329
+ ], 64)) : R("", !0)
330
+ ], 8, Xt)
331
+ ]),
332
+ o("div", {
333
+ "data-testid": "production-run-items-scroll",
334
+ class: "production-run-items-scroll overflow-x-auto",
335
+ role: "region",
336
+ tabindex: "0",
337
+ "aria-label": e(t)(n.titleKey)
338
+ }, [
339
+ o("table", {
340
+ class: z(["w-full min-w-[44rem]", { "table-fixed": l.value }])
341
+ }, [
342
+ l.value ? (r(), v("colgroup", tn, d[0] || (d[0] = [
343
+ o("col", null, null, -1),
344
+ o("col", { class: "w-36" }, null, -1),
345
+ o("col", { class: "w-36" }, null, -1),
346
+ o("col", { class: "w-36" }, null, -1)
347
+ ]))) : R("", !0),
348
+ o("thead", nn, [
349
+ o("tr", on, [
350
+ o("th", an, p(e(t)("inventory.production.run.detail.items.item")), 1),
351
+ l.value ? R("", !0) : (r(), v("th", rn, p(e(t)("inventory.production.run.detail.items.requested")), 1)),
352
+ o("th", {
353
+ class: z([l.value ? "text-center" : "text-right", "px-16 py-8 font-inherit"])
354
+ }, p(e(t)(
355
+ l.value ? "inventory.production.run.detail.preparing.toProduce" : "inventory.production.run.detail.items.committed"
356
+ )), 3),
357
+ o("th", {
358
+ class: z([l.value ? "text-center" : "text-right", "px-16 py-8 font-inherit"])
359
+ }, p(e(t)(
360
+ l.value ? "inventory.production.run.detail.preparing.recorded" : "inventory.production.run.detail.items.produced"
361
+ )), 3),
362
+ o("th", {
363
+ class: z([l.value ? "text-center" : "text-right", "px-16 py-8 font-inherit"])
364
+ }, p(e(t)(
365
+ l.value ? "inventory.production.run.detail.preparing.remaining" : "inventory.production.run.detail.items.left"
366
+ )), 3)
367
+ ])
368
+ ]),
369
+ (r(!0), v(W, null, oe(m.value, (g) => (r(), v("tbody", {
370
+ key: g.skuId,
371
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
372
+ }, [
373
+ o("tr", {
374
+ class: z({ "production-run-preparing-row": l.value })
375
+ }, [
376
+ o("td", sn, [
377
+ o("span", ln, p(g.name), 1),
378
+ $(g.skuId).length ? (r(), B(Ue, {
379
+ key: 0,
380
+ class: "mt-[2px]",
381
+ count: $(g.skuId).length,
382
+ controls: a(g.skuId),
383
+ expanded: k.value.has(g.skuId),
384
+ testid: `output-ingredient-disclosure-${g.skuId}`,
385
+ onToggle: (T) => I(g.skuId)
386
+ }, null, 8, ["count", "controls", "expanded", "testid", "onToggle"])) : f(g.skuId) ? (r(), B(He, {
387
+ key: 1,
388
+ "item-name": g.name
389
+ }, null, 8, ["item-name"])) : R("", !0)
390
+ ]),
391
+ l.value ? R("", !0) : (r(), v("td", un, p(g.requested === null ? e(le) : e(F)(g.requested, g.unit)), 1)),
392
+ o("td", {
393
+ class: z(["px-16 py-12 fm-typo-en-body-md-400 tabular-nums", [
394
+ l.value ? "text-center" : "text-right",
395
+ g.requested !== null && g.committed !== g.requested ? "text-fm-color-typo-warning fm-typo-en-body-md-600" : "text-fm-color-typo-primary"
396
+ ]])
397
+ }, [
398
+ o("span", {
399
+ class: z(["inline-flex items-center gap-2", l.value ? "justify-center" : "justify-end"])
400
+ }, [
401
+ o("span", null, p(e(F)(g.committed, g.unit)), 1),
402
+ !l.value && g.requested !== null && g.committed !== g.requested ? (r(), B(ze, {
403
+ key: 0,
404
+ "description-id": i(g.skuId),
405
+ "trigger-label": e(t)("inventory.production.run.detail.items.committedHelpLabel"),
406
+ description: e(t)("inventory.production.run.detail.items.committedHelp", {
407
+ requested: e(F)(g.requested, g.unit)
408
+ }),
409
+ testid: `committed-quantity-help-${g.skuId}`,
410
+ compact: ""
411
+ }, null, 8, ["description-id", "trigger-label", "description", "testid"])) : R("", !0)
412
+ ], 2)
413
+ ], 2),
414
+ o("td", {
415
+ class: z(["px-16 py-12 fm-typo-en-body-md-400 tabular-nums", l.value ? "text-center" : "text-right"])
416
+ }, [
417
+ l.value || g.produced > 0 ? (r(), v("span", dn, p(e(F)(g.produced, g.unit)), 1)) : (r(), v("span", cn, p(e(le)), 1))
418
+ ], 2),
419
+ o("td", {
420
+ class: z([
421
+ "px-16 py-12 tabular-nums",
422
+ l.value ? "text-center fm-typo-en-body-md-600" : "text-right fm-typo-en-body-md-400"
423
+ ])
424
+ }, [
425
+ l.value || g.remaining > 0 ? (r(), v("span", pn, p(e(F)(g.remaining, g.unit)), 1)) : (r(), v("span", mn, p(e(t)("inventory.production.run.detail.items.done")), 1))
426
+ ], 2)
427
+ ], 2),
428
+ k.value.has(g.skuId) ? (r(), v("tr", vn, [
429
+ o("td", {
430
+ colspan: l.value ? 4 : 5,
431
+ class: "production-run-items-bindings-cell"
432
+ }, [
433
+ o("div", yn, [
434
+ q(We, {
435
+ id: a(g.skuId),
436
+ testid: "production-run-output-ingredient-list",
437
+ count: $(g.skuId).length,
438
+ unit: g.unit ?? "",
439
+ lines: s(g),
440
+ "item-name": g.name
441
+ }, null, 8, ["id", "count", "unit", "lines", "item-name"])
442
+ ])
443
+ ], 8, bn)
444
+ ])) : R("", !0)
445
+ ]))), 128))
446
+ ], 2)
447
+ ], 8, en),
448
+ n.unattributedIngredients.length ? (r(), v("div", fn, [
449
+ o("p", gn, p(e(t)("inventory.production.run.detail.items.unattributedTitle")), 1),
450
+ o("p", hn, p(e(t)("inventory.production.run.detail.items.unattributedMessage")), 1)
451
+ ])) : R("", !0)
452
+ ], 8, Jt));
453
+ }
454
+ }), Qe = /* @__PURE__ */ me(_n, [["__scopeId", "data-v-b5fad4a9"]]), kn = {
455
+ "data-testid": "closed-production-result",
456
+ class: "min-w-0 overflow-hidden border border-fm-color-neutral-gray-200 fm-corner-radius-md bg-fm-color-surface-primary",
457
+ "aria-labelledby": "production-run-result-title"
458
+ }, $n = { class: "flex h-56 items-center justify-between gap-16 border-b border-fm-color-neutral-gray-200 px-16 py-12" }, xn = {
459
+ id: "production-run-result-title",
460
+ class: "fm-typo-en-body-lg-600"
461
+ }, wn = {
462
+ "data-testid": "closed-targets-reached",
463
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
464
+ }, In = ["aria-label"], Rn = ["aria-label"], Sn = { class: "bg-fm-color-neutral-gray-100" }, An = { class: "h-40 border-b border-fm-color-neutral-gray-200 fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, Pn = { class: "whitespace-nowrap px-16 py-8 text-left font-inherit" }, Ln = { class: "whitespace-nowrap px-8 py-8 text-center font-inherit" }, qn = { class: "whitespace-nowrap px-8 py-8 text-center font-inherit" }, Tn = { class: "min-w-0 px-16 py-12" }, Bn = ["title"], Cn = {
465
+ "data-testid": "closed-item-yield",
466
+ class: "whitespace-nowrap px-8 py-12 text-center tabular-nums"
467
+ }, Nn = { class: "block fm-typo-en-body-md-400" }, On = {
468
+ "data-testid": "closed-item-variance",
469
+ class: "whitespace-nowrap px-8 py-12 text-center tabular-nums"
470
+ }, ee = "inventory.production.run.detail.result", jn = /* @__PURE__ */ Q({
471
+ __name: "ProductionRunResultTable",
472
+ props: {
473
+ run: {},
474
+ names: {}
475
+ },
476
+ setup(P) {
477
+ const c = P, { t } = Y(), k = _(() => {
478
+ const $ = Ee(c.run), w = De(c.run);
479
+ return Object.keys($).map((a) => {
480
+ var n, d, g;
481
+ const I = $[a] ?? 0, s = w[a] ?? 0, i = s - I, m = I > 0 ? Math.round(s / I * 1e8) / 1e6 : null;
482
+ return {
483
+ skuId: a,
484
+ name: ((n = c.names[a]) == null ? void 0 : n.name) ?? a,
485
+ unit: ((d = c.names[a]) == null ? void 0 : d.unit) ?? null,
486
+ precision: ((g = c.names[a]) == null ? void 0 : g.precision) ?? null,
487
+ target: I,
488
+ produced: s,
489
+ variance: i,
490
+ rate: m,
491
+ reached: s >= I
492
+ };
493
+ });
494
+ }), l = _(() => k.value.filter(($) => $.reached).length);
495
+ function u($) {
496
+ return $ === null ? "—" : `${F($)}%`;
497
+ }
498
+ function x($, w, a) {
499
+ if ($ === 0) return F(0, w, { precision: a });
500
+ const I = F(Math.abs($), w, { precision: a });
501
+ return $ > 0 ? `+${I}` : `−${I}`;
502
+ }
503
+ function f($, w) {
504
+ if ($ === 0) return t(`${ee}.atTarget`);
505
+ if (w <= 0) return $ > 0 ? t(`${ee}.aboveTarget`) : t(`${ee}.belowTarget`);
506
+ const a = F(Math.abs($ / w) * 100);
507
+ return t(`${ee}.${$ > 0 ? "above" : "below"}`, { percent: a });
508
+ }
509
+ return ($, w) => (r(), v("section", kn, [
510
+ o("header", $n, [
511
+ o("h2", xn, p(e(t)(`${ee}.title`)), 1),
512
+ o("span", wn, p(e(t)(`${ee}.targetsReached`, { reached: l.value, total: k.value.length })), 1)
513
+ ]),
514
+ o("div", {
515
+ class: "overflow-x-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-fm-color-border-focused",
516
+ role: "region",
517
+ "aria-label": e(t)(`${ee}.ledger`),
518
+ tabindex: "0"
519
+ }, [
520
+ o("table", {
521
+ "aria-label": e(t)(`${ee}.title`),
522
+ class: "min-w-[24rem] w-full table-fixed"
523
+ }, [
524
+ w[0] || (w[0] = o("colgroup", null, [
525
+ o("col"),
526
+ o("col", { class: "w-96" }),
527
+ o("col", { class: "w-112" })
528
+ ], -1)),
529
+ o("thead", Sn, [
530
+ o("tr", An, [
531
+ o("th", Pn, p(e(t)(`${ee}.item`)), 1),
532
+ o("th", Ln, p(e(t)(`${ee}.yield`)), 1),
533
+ o("th", qn, p(e(t)(`${ee}.variance`)), 1)
534
+ ])
535
+ ]),
536
+ o("tbody", null, [
537
+ (r(!0), v(W, null, oe(k.value, (a) => (r(), v("tr", {
538
+ key: a.skuId,
539
+ class: "border-b border-fm-color-neutral-gray-200 fm-typo-en-body-md-400 last:border-b-0"
540
+ }, [
541
+ o("td", Tn, [
542
+ o("strong", {
543
+ class: "block break-words fm-typo-en-body-md-600",
544
+ title: a.name
545
+ }, p(a.name), 9, Bn)
546
+ ]),
547
+ o("td", Cn, [
548
+ o("span", Nn, p(e(F)(a.produced, a.unit, { precision: a.precision })), 1),
549
+ o("span", {
550
+ "data-testid": "closed-item-rate",
551
+ class: z([
552
+ "block fm-typo-en-body-sm-400",
553
+ a.rate !== null && a.rate !== 100 ? "text-fm-color-typo-warning" : "text-fm-color-typo-secondary"
554
+ ])
555
+ }, p(u(a.rate)), 3)
556
+ ]),
557
+ o("td", On, [
558
+ o("strong", {
559
+ class: z(["block fm-typo-en-body-md-600", a.variance === 0 ? "" : "text-fm-color-typo-warning"])
560
+ }, p(x(a.variance, a.unit, a.precision)), 3),
561
+ o("span", {
562
+ class: z([
563
+ "block fm-typo-en-body-sm-400",
564
+ a.variance === 0 ? "text-fm-color-typo-secondary" : "text-fm-color-typo-warning"
565
+ ])
566
+ }, p(f(a.variance, a.target)), 3)
567
+ ])
568
+ ]))), 128))
569
+ ])
570
+ ], 8, Rn)
571
+ ], 8, In)
572
+ ]));
573
+ }
574
+ }), Fn = ["id", "aria-label"], En = { class: "flex min-w-[680px] flex-col gap-8" }, Dn = {
575
+ "data-testid": "batch-wastage-headings",
576
+ role: "row",
577
+ class: "production-run-batch-wastage-headings grid min-h-40 grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1.2fr)] items-center gap-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 px-12 py-8 fm-typo-en-body-sm-600 text-fm-color-typo-secondary"
578
+ }, Mn = { role: "columnheader" }, Vn = {
579
+ role: "columnheader",
580
+ class: "text-center"
581
+ }, Un = { role: "columnheader" }, Hn = { role: "columnheader" }, zn = {
582
+ role: "rowgroup",
583
+ class: "flex flex-col gap-8"
584
+ }, Wn = {
585
+ role: "cell",
586
+ class: "min-w-0"
587
+ }, Gn = ["title"], Kn = {
588
+ role: "cell",
589
+ class: "min-w-0"
590
+ }, Qn = {
591
+ "data-testid": "batch-wastage-quantity",
592
+ class: "production-run-batch-wastage-quantity block whitespace-nowrap text-center tabular-nums"
593
+ }, Zn = {
594
+ role: "cell",
595
+ class: "min-w-0"
596
+ }, Jn = {
597
+ "data-testid": "batch-wastage-reason",
598
+ class: "break-words text-fm-color-typo-primary"
599
+ }, Yn = {
600
+ role: "cell",
601
+ class: "min-w-0"
602
+ }, Xn = {
603
+ "data-testid": "batch-wastage-remark",
604
+ class: "whitespace-pre-wrap break-words text-fm-color-typo-primary"
605
+ }, he = /* @__PURE__ */ Q({
606
+ __name: "ProductionRunBatchWastageDetails",
607
+ props: {
608
+ id: {},
609
+ label: {},
610
+ lines: {},
611
+ names: {}
612
+ },
613
+ setup(P) {
614
+ const { t: c } = Y();
615
+ function t(k) {
616
+ const l = ct(k);
617
+ return l ? c(l) : le;
618
+ }
619
+ return (k, l) => (r(), v("div", {
620
+ id: k.id,
621
+ tabindex: "0",
622
+ role: "table",
623
+ "aria-label": k.label,
624
+ class: "overflow-x-auto overscroll-x-contain pb-12"
625
+ }, [
626
+ o("div", En, [
627
+ o("div", Dn, [
628
+ o("span", Mn, p(e(c)("inventory.production.run.detail.batch.ingredient")), 1),
629
+ o("span", Vn, p(e(c)("inventory.production.run.detail.batch.quantityLost")), 1),
630
+ o("span", Un, p(e(c)("inventory.production.run.detail.batch.reason")), 1),
631
+ o("span", Hn, p(e(c)("inventory.production.run.detail.batch.remark")), 1)
632
+ ]),
633
+ o("div", zn, [
634
+ (r(!0), v(W, null, oe(k.lines, (u, x) => {
635
+ var f, $, w, a, I;
636
+ return r(), v("div", {
637
+ key: `${u.skuId}-${x}`,
638
+ "data-testid": "batch-wastage-line",
639
+ role: "row",
640
+ class: "production-run-batch-wastage-row grid grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1.2fr)] items-start gap-12 fm-corner-radius-md bg-fm-color-surface-secondary p-12 fm-typo-en-body-sm-400"
641
+ }, [
642
+ o("div", Wn, [
643
+ o("span", {
644
+ "data-testid": "batch-wastage-ingredient",
645
+ class: "production-run-batch-wastage-ingredient block truncate",
646
+ title: ((f = k.names[u.skuId]) == null ? void 0 : f.name) ?? u.skuId
647
+ }, p((($ = k.names[u.skuId]) == null ? void 0 : $.name) ?? u.skuId), 9, Gn)
648
+ ]),
649
+ o("div", Kn, [
650
+ o("span", Qn, p(e(F)(
651
+ e(Ve)(u.amount, u.measurement),
652
+ ((w = k.names[u.skuId]) == null ? void 0 : w.unit) ?? null,
653
+ { precision: ((a = k.names[u.skuId]) == null ? void 0 : a.precision) ?? null }
654
+ )), 1)
655
+ ]),
656
+ o("div", Zn, [
657
+ o("span", Jn, p(t(u.reason)), 1)
658
+ ]),
659
+ o("div", Yn, [
660
+ o("span", Xn, p(((I = u.remark) == null ? void 0 : I.trim()) || e(le)), 1)
661
+ ])
662
+ ]);
663
+ }), 128))
664
+ ])
665
+ ])
666
+ ], 8, Fn));
667
+ }
668
+ }), eo = {
669
+ key: 0,
670
+ "data-testid": "batch-stock-pending",
671
+ role: "status",
672
+ class: "border-b border-fm-color-border-default bg-fm-color-surface-secondary px-16 py-8 fm-typo-en-body-sm-600 text-fm-color-typo-warning"
673
+ }, to = {
674
+ key: 1,
675
+ class: "flex items-start justify-between gap-12 px-16 pt-12"
676
+ }, no = { class: "min-w-0" }, oo = {
677
+ "data-testid": "batch-title",
678
+ class: "fm-typo-en-body-md-600"
679
+ }, ao = ["title"], ro = {
680
+ key: 2,
681
+ class: "flex items-center gap-8 flex-wrap px-16 py-12 border-b border-fm-color-border-default"
682
+ }, so = { class: "fm-typo-en-body-md-600" }, io = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, lo = {
683
+ key: 0,
684
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary bg-fm-color-surface-secondary px-8 py-2 fm-corner-radius-sm"
685
+ }, uo = ["aria-label"], co = { class: "p-12 max-w-[320px] fm-typo-en-body-sm-400 text-fm-color-typo-primary" }, po = {
686
+ key: 3,
687
+ class: "overflow-x-auto px-16 pb-12"
688
+ }, mo = {
689
+ key: 0,
690
+ "data-testid": "batch-note",
691
+ class: "mt-12 whitespace-pre-wrap break-words fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
692
+ }, vo = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, bo = ["aria-label"], yo = { class: "border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100" }, fo = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, go = { class: "px-12 py-8 text-left font-semibold" }, ho = { class: "px-12 py-8 text-center font-semibold" }, _o = { class: "px-12 py-8 align-top" }, ko = ["data-testid", "title"], $o = ["data-testid"], xo = { key: 0 }, wo = {
693
+ colspan: "2",
694
+ class: "px-16"
695
+ }, Io = { key: 0 }, Ro = {
696
+ colspan: "2",
697
+ class: "border-t border-fm-color-neutral-gray-200 px-16 py-8 text-center"
698
+ }, So = {
699
+ key: 4,
700
+ class: "flex flex-col px-16"
701
+ }, Ao = { class: "flex items-start justify-between gap-12 py-12" }, Po = { class: "min-w-0 flex-1" }, Lo = ["data-testid", "title"], qo = { class: "fm-typo-en-body-md-400 tabular-nums shrink-0" }, To = {
702
+ key: 0,
703
+ class: "border-t border-fm-color-border-default py-8 text-center"
704
+ }, Bo = {
705
+ key: 5,
706
+ "data-testid": "batch-note",
707
+ class: "px-16 py-10 border-t border-fm-color-border-default fm-typo-en-body-sm-400 text-fm-color-typo-secondary whitespace-pre-wrap break-words"
708
+ }, Co = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, No = {
709
+ key: 6,
710
+ class: "flex items-center justify-between gap-12 px-16 py-8 border-t border-fm-color-border-default fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
711
+ }, Oo = { key: 0 }, Re = /* @__PURE__ */ Q({
712
+ __name: "ProductionRunBatchCard",
713
+ props: {
714
+ batch: {},
715
+ names: {},
716
+ summary: {},
717
+ total: {},
718
+ presentation: { default: "overview" }
719
+ },
720
+ setup(P) {
721
+ const c = P, { t } = Y(), k = _(() => c.presentation === "output"), l = _(() => {
722
+ var n;
723
+ return ((n = c.batch.remark) == null ? void 0 : n.trim()) ?? "";
724
+ }), u = j(/* @__PURE__ */ new Set()), x = _(() => {
725
+ var V;
726
+ const n = /* @__PURE__ */ new Map(), d = new Set(c.batch.items.map((b) => b.skuId)), g = c.batch.items.length === 1 ? (V = c.batch.items[0]) == null ? void 0 : V.skuId : void 0;
727
+ for (const b of c.batch.wastages) {
728
+ const y = b.itemSkuId ?? g, N = y && d.has(y) ? y : "unattributed";
729
+ n.set(N, [...n.get(N) ?? [], b]);
730
+ }
731
+ const T = c.batch.items.flatMap((b) => {
732
+ const S = n.get(b.skuId);
733
+ return S != null && S.length ? [{ key: b.skuId, lines: S }] : [];
734
+ }), C = n.get("unattributed");
735
+ return C != null && C.length ? [...T, { key: "unattributed", lines: C }] : T;
736
+ });
737
+ se(
738
+ () => c.batch.id,
739
+ () => {
740
+ u.value = /* @__PURE__ */ new Set();
741
+ }
742
+ );
743
+ function f(n) {
744
+ return x.value.find((d) => d.key === n);
745
+ }
746
+ function $(n) {
747
+ return `batch-${c.batch.id}-wastage-${n}`;
748
+ }
749
+ function w(n) {
750
+ var d;
751
+ return t("inventory.production.run.detail.batch.wastage", {
752
+ count: ((d = f(n)) == null ? void 0 : d.lines.length) ?? 0
753
+ });
754
+ }
755
+ function a(n) {
756
+ var d;
757
+ return `${w(n)}: ${((d = c.names[n]) == null ? void 0 : d.name) ?? n}`;
758
+ }
759
+ function I(n) {
760
+ return u.value.has(n);
761
+ }
762
+ function s(n) {
763
+ const d = new Set(u.value);
764
+ d.has(n) ? d.delete(n) : d.add(n), u.value = d;
765
+ }
766
+ const i = _(() => {
767
+ var g;
768
+ if (!c.summary) return null;
769
+ const n = (g = c.batch.items[0]) == null ? void 0 : g.skuId, d = n ? c.names[n] : void 0;
770
+ return {
771
+ ...c.summary,
772
+ unit: (d == null ? void 0 : d.unit) ?? null,
773
+ precision: (d == null ? void 0 : d.precision) ?? null,
774
+ percent: c.summary.committed > 0 ? Math.round(c.summary.cumulative / c.summary.committed * 100) : null
775
+ };
776
+ }), m = _(
777
+ () => c.batch.isBackdated ? t("inventory.production.run.detail.batch.hintBackdated", {
778
+ name: c.batch.recordedBy,
779
+ at: pe(c.batch.recordedAt)
780
+ }) : t("inventory.production.run.detail.batch.hint", {
781
+ name: c.batch.recordedBy,
782
+ at: pe(c.batch.recordedAt)
783
+ })
784
+ );
785
+ return (n, d) => {
786
+ var C, V, b, S;
787
+ const g = te("FmIcon"), T = te("FmPopover");
788
+ return r(), v("article", {
789
+ class: z([
790
+ "border fm-corner-radius-md overflow-hidden bg-fm-color-surface-primary",
791
+ k.value ? "border-fm-color-neutral-gray-200" : "border-fm-color-border-default"
792
+ ])
793
+ }, [
794
+ n.batch.stockApplicationStatus === "PENDING" ? (r(), v("p", eo, p(e(t)("inventory.production.run.detail.pendingStock.title")), 1)) : R("", !0),
795
+ k.value ? (r(), v("header", to, [
796
+ o("div", no, [
797
+ o("h2", oo, [
798
+ ve(n.$slots, "title", {}, () => [
799
+ ie(p(e(t)("inventory.production.run.detail.batch.shortTitle", { index: n.batch.index })), 1)
800
+ ])
801
+ ]),
802
+ o("p", {
803
+ "data-testid": "batch-provenance",
804
+ class: "mt-1 fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
805
+ title: n.batch.isBackdated ? m.value : void 0
806
+ }, p(e(t)("inventory.production.run.detail.batch.provenance", {
807
+ at: e(pe)(n.batch.producedAt),
808
+ name: n.batch.recordedBy
809
+ })), 9, ao)
810
+ ]),
811
+ ve(n.$slots, "nav")
812
+ ])) : (r(), v("header", ro, [
813
+ o("span", so, p(e(t)("inventory.production.run.detail.batch.title", { index: n.batch.index, total: n.total })), 1),
814
+ o("span", io, p(e(pe)(n.batch.producedAt)), 1),
815
+ n.batch.isBackdated ? (r(), v("span", lo, p(e(t)("inventory.production.run.detail.batch.entered", {
816
+ at: e(pe)(n.batch.recordedAt)
817
+ })), 1)) : R("", !0),
818
+ q(T, { placement: "bottom-start" }, {
819
+ "popover-button": ne(() => [
820
+ o("button", {
821
+ type: "button",
822
+ class: "flex text-fm-color-typo-disabled hover:text-fm-color-typo-primary",
823
+ "aria-label": e(t)("inventory.production.run.detail.moreDetail")
824
+ }, [
825
+ q(g, {
826
+ name: "info",
827
+ size: "sm",
828
+ outline: ""
829
+ })
830
+ ], 8, uo)
831
+ ]),
832
+ default: ne(() => [
833
+ o("p", co, p(m.value), 1)
834
+ ]),
835
+ _: 1
836
+ }),
837
+ d[2] || (d[2] = o("span", { class: "grow" }, null, -1)),
838
+ ve(n.$slots, "nav")
839
+ ])),
840
+ k.value ? (r(), v("div", po, [
841
+ l.value ? (r(), v("p", mo, [
842
+ o("span", vo, p(e(t)("inventory.production.run.detail.batch.batchNote")), 1),
843
+ ie(" " + p(l.value), 1)
844
+ ])) : R("", !0),
845
+ o("table", {
846
+ class: "mt-12 w-full table-fixed",
847
+ "aria-label": e(t)("inventory.production.run.detail.batch.outputTableLabel", { index: n.batch.index })
848
+ }, [
849
+ d[3] || (d[3] = o("colgroup", null, [
850
+ o("col"),
851
+ o("col", { class: "w-[144px]" })
852
+ ], -1)),
853
+ o("thead", yo, [
854
+ o("tr", fo, [
855
+ o("th", go, p(e(t)("inventory.production.run.detail.items.item")), 1),
856
+ o("th", ho, p(e(t)("inventory.production.run.detail.batch.yield")), 1)
857
+ ])
858
+ ]),
859
+ (r(!0), v(W, null, oe(n.batch.items, (y) => {
860
+ var N, E, U, Z, O, X;
861
+ return r(), v("tbody", {
862
+ key: y.skuId,
863
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
864
+ }, [
865
+ o("tr", null, [
866
+ o("td", _o, [
867
+ o("span", {
868
+ "data-testid": `batch-output-name-${y.skuId}`,
869
+ class: "block truncate fm-typo-en-body-md-400",
870
+ title: ((N = n.names[y.skuId]) == null ? void 0 : N.name) ?? y.skuId
871
+ }, p(((E = n.names[y.skuId]) == null ? void 0 : E.name) ?? y.skuId), 9, ko),
872
+ f(y.skuId) ? (r(), B(ge, {
873
+ key: 0,
874
+ "data-testid": `batch-wastage-toggle-${y.skuId}`,
875
+ class: "mt-2",
876
+ expanded: I(y.skuId),
877
+ controls: $(y.skuId),
878
+ label: w(y.skuId),
879
+ "aria-label": a(y.skuId),
880
+ onToggle: (ue) => s(y.skuId)
881
+ }, null, 8, ["data-testid", "expanded", "controls", "label", "aria-label", "onToggle"])) : R("", !0)
882
+ ]),
883
+ o("td", {
884
+ "data-testid": `batch-output-yield-${y.skuId}`,
885
+ class: "whitespace-nowrap px-12 py-8 text-center align-top fm-typo-en-body-md-400 tabular-nums"
886
+ }, [
887
+ o("span", null, p(e(F)(y.amount, ((U = n.names[y.skuId]) == null ? void 0 : U.unit) ?? null, {
888
+ precision: ((Z = n.names[y.skuId]) == null ? void 0 : Z.precision) ?? null
889
+ })), 1)
890
+ ], 8, $o)
891
+ ]),
892
+ f(y.skuId) && I(y.skuId) ? (r(), v("tr", xo, [
893
+ o("td", wo, [
894
+ q(he, {
895
+ id: $(y.skuId),
896
+ label: e(t)("inventory.production.run.detail.batch.wastageFor", {
897
+ name: ((O = n.names[y.skuId]) == null ? void 0 : O.name) ?? y.skuId
898
+ }),
899
+ lines: ((X = f(y.skuId)) == null ? void 0 : X.lines) ?? [],
900
+ names: n.names
901
+ }, null, 8, ["id", "label", "lines", "names"])
902
+ ])
903
+ ])) : R("", !0)
904
+ ]);
905
+ }), 128)),
906
+ f("unattributed") ? (r(), v("tbody", Io, [
907
+ o("tr", null, [
908
+ o("td", Ro, [
909
+ q(ge, {
910
+ "data-testid": "batch-wastage-toggle-unattributed",
911
+ expanded: I("unattributed"),
912
+ controls: $("unattributed"),
913
+ label: e(t)("inventory.production.run.detail.batch.unattributedWastage", {
914
+ count: ((C = f("unattributed")) == null ? void 0 : C.lines.length) ?? 0
915
+ }),
916
+ onToggle: d[0] || (d[0] = (y) => s("unattributed"))
917
+ }, null, 8, ["expanded", "controls", "label"]),
918
+ I("unattributed") ? (r(), B(he, {
919
+ key: 0,
920
+ id: $("unattributed"),
921
+ label: e(t)("inventory.production.run.detail.batch.unattributedWastageLabel"),
922
+ lines: ((V = f("unattributed")) == null ? void 0 : V.lines) ?? [],
923
+ names: n.names,
924
+ class: "mt-8 text-left"
925
+ }, null, 8, ["id", "label", "lines", "names"])) : R("", !0)
926
+ ])
927
+ ])
928
+ ])) : R("", !0)
929
+ ], 8, bo)
930
+ ])) : (r(), v("div", So, [
931
+ (r(!0), v(W, null, oe(n.batch.items, (y) => {
932
+ var N, E, U, Z, O, X;
933
+ return r(), v("div", {
934
+ key: y.skuId,
935
+ class: "border-b border-fm-color-border-default last:border-b-0"
936
+ }, [
937
+ o("div", Ao, [
938
+ o("div", Po, [
939
+ o("span", {
940
+ "data-testid": `batch-output-name-${y.skuId}`,
941
+ class: "block break-words fm-typo-en-body-md-600 sm:truncate",
942
+ title: ((N = n.names[y.skuId]) == null ? void 0 : N.name) ?? y.skuId
943
+ }, p(((E = n.names[y.skuId]) == null ? void 0 : E.name) ?? y.skuId), 9, Lo),
944
+ f(y.skuId) ? (r(), B(ge, {
945
+ key: 0,
946
+ "data-testid": `batch-wastage-toggle-${y.skuId}`,
947
+ class: "mt-2",
948
+ expanded: I(y.skuId),
949
+ controls: $(y.skuId),
950
+ label: w(y.skuId),
951
+ "aria-label": a(y.skuId),
952
+ onToggle: (ue) => s(y.skuId)
953
+ }, null, 8, ["data-testid", "expanded", "controls", "label", "aria-label", "onToggle"])) : R("", !0)
954
+ ]),
955
+ o("span", qo, p(e(F)(y.amount, ((U = n.names[y.skuId]) == null ? void 0 : U.unit) ?? null, {
956
+ precision: ((Z = n.names[y.skuId]) == null ? void 0 : Z.precision) ?? null
957
+ })), 1)
958
+ ]),
959
+ f(y.skuId) && I(y.skuId) ? (r(), B(he, {
960
+ key: 0,
961
+ id: $(y.skuId),
962
+ label: e(t)("inventory.production.run.detail.batch.wastageFor", {
963
+ name: ((O = n.names[y.skuId]) == null ? void 0 : O.name) ?? y.skuId
964
+ }),
965
+ lines: ((X = f(y.skuId)) == null ? void 0 : X.lines) ?? [],
966
+ names: n.names
967
+ }, null, 8, ["id", "label", "lines", "names"])) : R("", !0)
968
+ ]);
969
+ }), 128)),
970
+ f("unattributed") ? (r(), v("div", To, [
971
+ q(ge, {
972
+ "data-testid": "batch-wastage-toggle-unattributed",
973
+ expanded: I("unattributed"),
974
+ controls: $("unattributed"),
975
+ label: e(t)("inventory.production.run.detail.batch.unattributedWastage", {
976
+ count: ((b = f("unattributed")) == null ? void 0 : b.lines.length) ?? 0
977
+ }),
978
+ onToggle: d[1] || (d[1] = (y) => s("unattributed"))
979
+ }, null, 8, ["expanded", "controls", "label"]),
980
+ I("unattributed") ? (r(), B(he, {
981
+ key: 0,
982
+ id: $("unattributed"),
983
+ label: e(t)("inventory.production.run.detail.batch.unattributedWastageLabel"),
984
+ lines: ((S = f("unattributed")) == null ? void 0 : S.lines) ?? [],
985
+ names: n.names,
986
+ class: "mt-8 text-left"
987
+ }, null, 8, ["id", "label", "lines", "names"])) : R("", !0)
988
+ ])) : R("", !0)
989
+ ])),
990
+ l.value && !k.value ? (r(), v("p", Bo, [
991
+ o("span", Co, p(e(t)("inventory.production.run.detail.batch.batchNote")), 1),
992
+ ie(" " + p(l.value), 1)
993
+ ])) : R("", !0),
994
+ i.value && !k.value ? (r(), v("footer", No, [
995
+ o("span", null, p(e(t)("inventory.production.run.detail.batch.ofCommitted", {
996
+ amount: e(F)(i.value.amount, i.value.unit, {
997
+ precision: i.value.precision
998
+ }),
999
+ committed: e(F)(i.value.committed, i.value.unit, {
1000
+ precision: i.value.precision
1001
+ })
1002
+ })), 1),
1003
+ i.value.percent !== null ? (r(), v("span", Oo, p(e(t)("inventory.production.run.detail.batch.cumulative", { percent: i.value.percent })), 1)) : R("", !0)
1004
+ ])) : R("", !0)
1005
+ ], 2);
1006
+ };
1007
+ }
1008
+ }), jo = { class: "flex flex-col gap-16" }, Fo = {
1009
+ key: 2,
1010
+ "data-testid": "production-run-last-output",
1011
+ class: "flex min-w-0 flex-col gap-8",
1012
+ "aria-labelledby": "production-run-last-output-title"
1013
+ }, Eo = { class: "flex items-center justify-between gap-12" }, Do = {
1014
+ id: "production-run-last-output-title",
1015
+ class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary"
1016
+ }, Mo = {
1017
+ key: 3,
1018
+ class: "production-run-review-layout grid grid-cols-1 gap-16 items-start"
1019
+ }, Vo = { class: "flex flex-col gap-16 min-w-0" }, Uo = { class: "flex items-center justify-between fm-typo-en-body-sm-500 uppercase tracking-wider text-fm-color-typo-secondary" }, Ho = { class: "flex items-center gap-4" }, zo = /* @__PURE__ */ Q({
1020
+ __name: "ProductionRunOverviewTab",
1021
+ props: {
1022
+ run: {},
1023
+ names: {},
1024
+ batches: {},
1025
+ committed: {},
1026
+ unit: {},
1027
+ hasIssuance: { type: Boolean },
1028
+ operational: { type: Boolean, default: !1 }
1029
+ },
1030
+ emits: ["view-all"],
1031
+ setup(P, { emit: c }) {
1032
+ const t = P, k = c, { t: l } = Y(), u = j(null), x = _(() => {
1033
+ if (!t.batches.length) return null;
1034
+ const s = t.batches.length - 1, i = u.value === null || u.value >= t.batches.length ? s : u.value;
1035
+ return { batch: t.batches[i], i };
1036
+ }), f = _(() => {
1037
+ const s = t.batches.length - 1;
1038
+ return s >= 0 ? { batch: t.batches[s], i: s } : null;
1039
+ }), $ = _(() => {
1040
+ const s = new Set(
1041
+ t.run.preparation.issuances.flatMap((i) => i.items.map((m) => m.sku._id))
1042
+ );
1043
+ return s.size === 1 ? [...s][0] : null;
1044
+ });
1045
+ function w(s) {
1046
+ const i = t.committed;
1047
+ if (!s || $.value === null || i === null) return null;
1048
+ const m = $.value;
1049
+ if (t.batches.some((g) => g.items.some((T) => T.skuId !== m))) return null;
1050
+ const n = s.batch.items.reduce((g, T) => g + T.amount, 0), d = t.batches.slice(0, s.i + 1).reduce(
1051
+ (g, T) => g + T.items.reduce((C, V) => C + V.amount, 0),
1052
+ 0
1053
+ );
1054
+ return { amount: n, cumulative: d, committed: i };
1055
+ }
1056
+ const a = _(() => w(x.value)), I = _(() => t.run.status === "CLOSED");
1057
+ return (s, i) => {
1058
+ const m = te("FmButton");
1059
+ return r(), v("div", jo, [
1060
+ s.operational ? ve(s.$slots, "operational", { key: 0 }, void 0, !0) : ve(s.$slots, "planner", { key: 1 }, void 0, !0),
1061
+ s.operational && s.run.status === "PREPARING" && f.value ? (r(), v("section", Fo, [
1062
+ o("header", Eo, [
1063
+ o("h2", Do, p(e(l)("inventory.production.run.detail.output.lastOutput")), 1),
1064
+ q(m, {
1065
+ variant: "secondary",
1066
+ label: e(l)("inventory.production.run.detail.output.viewAllOutput"),
1067
+ onClick: i[0] || (i[0] = (n) => k("view-all"))
1068
+ }, null, 8, ["label"])
1069
+ ]),
1070
+ q(Re, {
1071
+ batch: f.value.batch,
1072
+ names: s.names,
1073
+ summary: null,
1074
+ total: s.batches.length,
1075
+ presentation: "output"
1076
+ }, {
1077
+ title: ne(() => [
1078
+ ie(p(e(l)("inventory.production.run.detail.batch.title", {
1079
+ index: f.value.batch.index,
1080
+ total: s.batches.length
1081
+ })), 1)
1082
+ ]),
1083
+ _: 1
1084
+ }, 8, ["batch", "names", "total"])
1085
+ ])) : R("", !0),
1086
+ !s.operational && s.hasIssuance ? (r(), v("div", Mo, [
1087
+ o("div", Vo, [
1088
+ I.value ? (r(), B(jn, {
1089
+ key: 0,
1090
+ run: s.run,
1091
+ names: s.names
1092
+ }, null, 8, ["run", "names"])) : (r(), v(W, { key: 1 }, [
1093
+ q(Qe, {
1094
+ run: s.run,
1095
+ names: s.names
1096
+ }, null, 8, ["run", "names"]),
1097
+ x.value ? (r(), v(W, { key: 0 }, [
1098
+ o("div", Uo, [
1099
+ o("span", null, p(e(l)("inventory.production.run.detail.output.recorded")), 1),
1100
+ o("span", null, p(e(l)("inventory.production.run.detail.output.count", { count: s.batches.length })), 1)
1101
+ ]),
1102
+ q(Re, {
1103
+ batch: x.value.batch,
1104
+ names: s.names,
1105
+ summary: a.value,
1106
+ total: s.batches.length
1107
+ }, et({ _: 2 }, [
1108
+ s.batches.length > 1 ? {
1109
+ name: "nav",
1110
+ fn: ne(() => [
1111
+ o("div", Ho, [
1112
+ q(m, {
1113
+ variant: "tertiary",
1114
+ icon: "chevron_left",
1115
+ disabled: x.value.i === 0,
1116
+ "aria-label": e(l)("inventory.production.run.detail.output.previous"),
1117
+ onClick: i[1] || (i[1] = (n) => u.value = x.value.i - 1)
1118
+ }, null, 8, ["disabled", "aria-label"]),
1119
+ q(m, {
1120
+ variant: "tertiary",
1121
+ icon: "chevron_right",
1122
+ disabled: x.value.i === s.batches.length - 1,
1123
+ "aria-label": e(l)("inventory.production.run.detail.output.next"),
1124
+ onClick: i[2] || (i[2] = (n) => u.value = x.value.i + 1)
1125
+ }, null, 8, ["disabled", "aria-label"]),
1126
+ q(m, {
1127
+ variant: "tertiary",
1128
+ label: e(l)("inventory.production.run.detail.output.viewAll"),
1129
+ onClick: i[3] || (i[3] = (n) => k("view-all"))
1130
+ }, null, 8, ["label"])
1131
+ ])
1132
+ ]),
1133
+ key: "0"
1134
+ } : void 0
1135
+ ]), 1032, ["batch", "names", "summary", "total"])
1136
+ ], 64)) : R("", !0)
1137
+ ], 64))
1138
+ ])
1139
+ ])) : R("", !0)
1140
+ ]);
1141
+ };
1142
+ }
1143
+ }), Wo = /* @__PURE__ */ me(zo, [["__scopeId", "data-v-8bc34f94"]]), Go = { class: "flex flex-col gap-16" }, Ko = {
1144
+ key: 0,
1145
+ class: "border border-dashed border-fm-color-border-default fm-corner-radius-md px-16 py-24 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1146
+ }, Qo = /* @__PURE__ */ Q({
1147
+ __name: "ProductionRunOutputTab",
1148
+ props: {
1149
+ batches: {},
1150
+ names: {}
1151
+ },
1152
+ setup(P) {
1153
+ const { t: c } = Y();
1154
+ return (t, k) => (r(), v("div", Go, [
1155
+ t.batches.length ? (r(!0), v(W, { key: 1 }, oe(t.batches, (l) => (r(), B(Re, {
1156
+ key: l.id,
1157
+ batch: l,
1158
+ names: t.names,
1159
+ summary: null,
1160
+ total: t.batches.length,
1161
+ presentation: "output"
1162
+ }, null, 8, ["batch", "names", "total"]))), 128)) : (r(), v("p", Ko, p(e(c)("inventory.production.run.detail.output.empty")), 1))
1163
+ ]));
1164
+ }
1165
+ }), Zo = ["aria-label"], Jo = {
1166
+ key: 0,
1167
+ role: "status",
1168
+ class: "border border-dashed border-fm-color-border-default px-16 py-24 fm-corner-radius-md fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1169
+ }, Yo = {
1170
+ key: 1,
1171
+ class: "border border-dashed border-fm-color-border-default px-16 py-24 fm-corner-radius-md fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1172
+ }, Xo = {
1173
+ key: 2,
1174
+ class: "border border-dashed border-fm-color-border-default px-16 py-24 fm-corner-radius-md fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1175
+ }, ea = {
1176
+ key: 3,
1177
+ "data-testid": "ingredient-issue-card",
1178
+ class: "overflow-hidden border border-fm-color-neutral-gray-200 bg-fm-color-surface-primary fm-corner-radius-md"
1179
+ }, ta = ["aria-label"], na = ["aria-label"], oa = { class: "ingredient-ledger__head bg-fm-color-neutral-gray-100" }, aa = { class: "h-40 fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, ra = { class: "px-16 py-8 text-left" }, sa = { class: "whitespace-nowrap px-8 py-8 text-center" }, ia = { class: "whitespace-nowrap px-8 py-8 text-center" }, la = ["data-testid"], ua = { class: "ingredient-ledger__ingredient col-span-1 min-w-0 px-16 py-8 align-top" }, da = ["data-testid"], ca = ["title"], pa = ["data-testid"], ma = ["data-testid"], va = ["data-testid"], ba = {
1180
+ key: 0,
1181
+ class: "ingredient-ledger__contributors-row"
1182
+ }, ya = {
1183
+ colspan: "3",
1184
+ class: "px-0 pb-0 pt-0"
1185
+ }, fa = {
1186
+ "data-testid": "issued-ingredient-contributors-width",
1187
+ class: "max-w-full"
1188
+ }, ga = {
1189
+ "data-testid": "issued-ingredient-contributors-content",
1190
+ class: "ingredient-ledger__contributors-content w-3/5"
1191
+ }, K = "inventory.production.run.detail.ingredients", ha = /* @__PURE__ */ Q({
1192
+ __name: "ProductionRunIngredientsTab",
1193
+ props: {
1194
+ runId: {},
1195
+ loading: { type: Boolean },
1196
+ snapshotAvailable: { type: Boolean },
1197
+ lines: {},
1198
+ ingredientContributions: {},
1199
+ outputNames: {},
1200
+ unattributedIngredients: {}
1201
+ },
1202
+ setup(P) {
1203
+ const c = P, { t } = Y(), k = j(/* @__PURE__ */ new Set()), l = _(() => {
1204
+ var i, m, n;
1205
+ const s = {};
1206
+ for (const [d, g] of Object.entries(c.ingredientContributions ?? {}))
1207
+ for (const T of g)
1208
+ (s[i = T.skuId] ?? (s[i] = [])).push({
1209
+ outputSkuId: d,
1210
+ outputName: ((n = (m = c.outputNames) == null ? void 0 : m[d]) == null ? void 0 : n.name) ?? d,
1211
+ issued: T.issued,
1212
+ unit: T.unit
1213
+ });
1214
+ return s;
1215
+ }), u = _(
1216
+ () => new Set(
1217
+ Object.entries(l.value).filter(([, s]) => s.length > 0).map(([s]) => s)
1218
+ )
1219
+ );
1220
+ se(
1221
+ () => c.runId,
1222
+ () => k.value = /* @__PURE__ */ new Set()
1223
+ ), se(
1224
+ () => [...u.value].sort().join("|"),
1225
+ () => {
1226
+ k.value = new Set(
1227
+ [...k.value].filter((s) => u.value.has(s))
1228
+ );
1229
+ }
1230
+ );
1231
+ function x(s) {
1232
+ return l.value[s] ?? [];
1233
+ }
1234
+ function f(s) {
1235
+ return `production-run-ingredient-contributors-${c.runId}-${s}`;
1236
+ }
1237
+ function $(s) {
1238
+ const i = new Set(k.value);
1239
+ i.has(s) ? i.delete(s) : i.add(s), k.value = i;
1240
+ }
1241
+ function w(s) {
1242
+ const i = x(s).length;
1243
+ return t(i === 1 ? `${K}.acrossItem` : `${K}.acrossItems`, { count: i });
1244
+ }
1245
+ function a(s) {
1246
+ return x(s).map((i) => ({
1247
+ key: i.outputSkuId,
1248
+ label: i.outputName,
1249
+ value: F(i.issued, i.unit)
1250
+ }));
1251
+ }
1252
+ function I(s) {
1253
+ if (s.stockBefore === null || s.stockAfter === null) return le;
1254
+ const i = F(s.stockBefore, s.unit);
1255
+ if (s.stockAfter >= 0) return `${i} → ${F(s.stockAfter, s.unit)}`;
1256
+ const m = t("inventory.production.run.form.commits.shortBy", {
1257
+ amount: `−${F(Math.abs(s.stockAfter), s.unit)}`
1258
+ });
1259
+ return `${i} → ${m}`;
1260
+ }
1261
+ return (s, i) => {
1262
+ var m;
1263
+ return r(), v("section", {
1264
+ class: "flex flex-col gap-16",
1265
+ "aria-label": e(t)(`${K}.title`)
1266
+ }, [
1267
+ s.loading ? (r(), v("p", Jo, p(e(t)(`${K}.loading`)), 1)) : s.snapshotAvailable ? s.lines.length ? (r(), v("div", ea, [
1268
+ o("div", {
1269
+ "data-testid": "ingredient-ledger-scroll",
1270
+ class: "overflow-x-auto overscroll-x-contain",
1271
+ role: "region",
1272
+ tabindex: "0",
1273
+ "aria-label": e(t)(`${K}.tableLabel`)
1274
+ }, [
1275
+ o("table", {
1276
+ class: "ingredient-ledger w-full min-w-[44rem]",
1277
+ "aria-label": e(t)(`${K}.tableLabel`)
1278
+ }, [
1279
+ i[0] || (i[0] = o("colgroup", { class: "ingredient-ledger__columns" }, [
1280
+ o("col"),
1281
+ o("col", { class: "w-36" }),
1282
+ o("col", { class: "w-36" })
1283
+ ], -1)),
1284
+ o("thead", oa, [
1285
+ o("tr", aa, [
1286
+ o("th", ra, p(e(t)(`${K}.ingredient`)), 1),
1287
+ o("th", sa, p(e(t)(`${K}.requestedQty`)), 1),
1288
+ o("th", ia, p(e(t)(`${K}.committedQty`)), 1)
1289
+ ])
1290
+ ]),
1291
+ (r(!0), v(W, null, oe(s.lines, (n) => (r(), v("tbody", {
1292
+ key: n.skuId,
1293
+ class: "ingredient-ledger__body"
1294
+ }, [
1295
+ o("tr", {
1296
+ "data-testid": `ingredient-row-${n.skuId}`,
1297
+ class: "ingredient-ledger__row border-t border-fm-color-neutral-gray-200"
1298
+ }, [
1299
+ o("td", ua, [
1300
+ o("div", {
1301
+ "data-testid": `issued-ingredient-identity-${n.skuId}`,
1302
+ class: "flex min-w-0 flex-col items-start gap-0"
1303
+ }, [
1304
+ o("strong", {
1305
+ class: "ingredient-ledger__identity-name block max-w-full truncate fm-typo-en-body-md-600",
1306
+ title: n.name
1307
+ }, p(n.name), 9, ca),
1308
+ n.stockAfter !== null && n.stockAfter < 0 ? (r(), B(pt, {
1309
+ key: 0,
1310
+ class: "ingredient-ledger__identity-stock",
1311
+ testid: `ingredient-stock-${n.skuId}`,
1312
+ "help-testid": `ingredient-stock-help-${n.skuId}`,
1313
+ type: "hint",
1314
+ "icon-placement": "trailing",
1315
+ variant: "danger",
1316
+ size: "sm",
1317
+ text: `${e(t)(`${K}.stock`)} ${I(n)}`,
1318
+ "accessible-label": e(t)("inventory.production.run.detail.ingredients.negativeStockHelp"),
1319
+ tooltip: e(t)("inventory.production.run.detail.ingredients.negativeStockHelp")
1320
+ }, null, 8, ["testid", "help-testid", "text", "accessible-label", "tooltip"])) : (r(), v("p", {
1321
+ key: 1,
1322
+ "data-testid": `ingredient-stock-${n.skuId}`,
1323
+ class: "ingredient-ledger__identity-stock fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1324
+ }, p(e(t)(`${K}.stock`)) + " " + p(I(n)), 9, pa)),
1325
+ u.value.has(n.skuId) ? (r(), B(mt, {
1326
+ key: 2,
1327
+ class: "ingredient-ledger__disclosure mt-[2px] w-fit",
1328
+ testid: `ingredient-contributor-disclosure-${n.skuId}`,
1329
+ controls: f(n.skuId),
1330
+ expanded: k.value.has(n.skuId),
1331
+ label: w(n.skuId),
1332
+ onToggle: (d) => $(n.skuId)
1333
+ }, null, 8, ["testid", "controls", "expanded", "label", "onToggle"])) : R("", !0)
1334
+ ], 8, da)
1335
+ ]),
1336
+ o("td", {
1337
+ "data-testid": `ingredient-requested-${n.skuId}`,
1338
+ class: z([
1339
+ "ingredient-ledger__value ingredient-ledger__requested px-8 py-8 text-center align-middle fm-typo-en-body-md-400 tabular-nums",
1340
+ n.requested === null ? "text-fm-color-typo-secondary" : "text-fm-color-typo-primary"
1341
+ ])
1342
+ }, p(n.requested === null ? e(le) : e(F)(n.requested, n.unit)), 11, ma),
1343
+ o("td", {
1344
+ "data-testid": `ingredient-committed-${n.skuId}`,
1345
+ class: "ingredient-ledger__value ingredient-ledger__committed px-8 py-8 text-center align-middle fm-typo-en-body-md-400 text-fm-color-typo-primary tabular-nums"
1346
+ }, p(e(F)(n.issued, n.unit)), 9, va)
1347
+ ], 8, la),
1348
+ u.value.has(n.skuId) && k.value.has(n.skuId) ? (r(), v("tr", ba, [
1349
+ o("td", ya, [
1350
+ o("div", fa, [
1351
+ o("div", ga, [
1352
+ q(vt, {
1353
+ id: f(n.skuId),
1354
+ role: "list",
1355
+ "aria-label": e(t)(`${K}.contributorsFor`, { name: n.name }),
1356
+ entries: a(n.skuId),
1357
+ class: "ml-[22px] mr-[8px]"
1358
+ }, null, 8, ["id", "aria-label", "entries"])
1359
+ ])
1360
+ ])
1361
+ ])
1362
+ ])) : R("", !0)
1363
+ ]))), 128))
1364
+ ], 8, na)
1365
+ ], 8, ta)
1366
+ ])) : (r(), v("p", Xo, p(e(t)(`${K}.noBindings`)), 1)) : (r(), v("p", Yo, p(e(t)(`${K}.snapshotUnavailable`)), 1)),
1367
+ (m = s.unattributedIngredients) != null && m.length ? (r(), B(re, {
1368
+ key: 4,
1369
+ "data-testid": "unattributed-issued-ingredients",
1370
+ tone: "warn",
1371
+ title: e(t)("inventory.production.run.detail.items.unattributedTitle"),
1372
+ message: e(t)("inventory.production.run.detail.items.unattributedMessage")
1373
+ }, null, 8, ["title", "message"])) : R("", !0)
1374
+ ], 8, Zo);
1375
+ };
1376
+ }
1377
+ }), _a = /* @__PURE__ */ me(ha, [["__scopeId", "data-v-2a6f6173"]]), ka = { "aria-labelledby": "activity-title" }, $a = { class: "flex items-center gap-8" }, xa = {
1378
+ id: "activity-title",
1379
+ class: "text-[18px] font-semibold leading-[28px]"
1380
+ }, wa = {
1381
+ key: 0,
1382
+ class: "mt-[20px] space-y-16"
1383
+ }, Ia = {
1384
+ class: "mt-[2px] grid size-24 place-items-center rounded-full bg-fm-color-system-success-100 text-fm-color-system-success-400",
1385
+ "aria-hidden": "true"
1386
+ }, Ra = { class: "min-w-0" }, Sa = {
1387
+ "data-testid": "activity-title",
1388
+ class: "text-[14px] font-medium leading-[18px] text-fm-color-typo-primary"
1389
+ }, Aa = {
1390
+ key: 0,
1391
+ "data-testid": "activity-description",
1392
+ class: "mt-4 text-[14px] font-normal leading-[20px] text-fm-color-typo-secondary"
1393
+ }, Pa = {
1394
+ "data-testid": "activity-meta",
1395
+ class: "mt-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1396
+ }, La = {
1397
+ key: 1,
1398
+ class: "mt-[20px] fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1399
+ }, qa = /* @__PURE__ */ Q({
1400
+ __name: "ProductionRunActivityTab",
1401
+ props: {
1402
+ run: {}
1403
+ },
1404
+ setup(P) {
1405
+ const c = P, { t } = Y(), k = _(
1406
+ () => [...c.run.activityLogs].reverse().map((l, u) => {
1407
+ var x;
1408
+ return {
1409
+ key: `${l.action}-${l.performedAt}-${u}`,
1410
+ label: l.action === "close" && Ge(c.run) === "below-target" ? t("inventory.production.run.list.activity.closeBelowTarget") : t(`inventory.production.run.list.activity.${l.action}`),
1411
+ description: l.remark,
1412
+ meta: [pe(l.performedAt), (x = l.performedBy) == null ? void 0 : x.name].filter(Boolean).join(" · ")
1413
+ };
1414
+ })
1415
+ );
1416
+ return (l, u) => {
1417
+ const x = te("FmIcon");
1418
+ return r(), v("section", ka, [
1419
+ o("header", $a, [
1420
+ q(x, {
1421
+ name: "history",
1422
+ size: "sm",
1423
+ "aria-hidden": "true",
1424
+ class: "production-run-activity-history"
1425
+ }),
1426
+ o("h2", xa, p(e(t)("inventory.production.run.detail.tab.activity")), 1)
1427
+ ]),
1428
+ k.value.length ? (r(), v("ol", wa, [
1429
+ (r(!0), v(W, null, oe(k.value, (f) => (r(), v("li", {
1430
+ key: f.key,
1431
+ class: "grid grid-cols-[24px_1fr] gap-12"
1432
+ }, [
1433
+ o("span", Ia, [
1434
+ q(x, {
1435
+ name: "check_circle",
1436
+ size: "sm",
1437
+ class: "production-run-activity-check"
1438
+ })
1439
+ ]),
1440
+ o("div", Ra, [
1441
+ o("div", Sa, p(f.label), 1),
1442
+ f.description ? (r(), v("p", Aa, p(f.description), 1)) : R("", !0),
1443
+ o("p", Pa, p(f.meta), 1)
1444
+ ])
1445
+ ]))), 128))
1446
+ ])) : (r(), v("p", La, p(e(t)("inventory.production.run.list.activity.none")), 1))
1447
+ ]);
1448
+ };
1449
+ }
1450
+ }), Ta = /* @__PURE__ */ me(qa, [["__scopeId", "data-v-ea0bca54"]]), Ba = { class: "production-run-requested-layout grid grid-cols-1 items-start gap-16" }, Ca = {
1451
+ "data-testid": "production-run-requested-left",
1452
+ class: "flex min-w-0 flex-col gap-16"
1453
+ }, Na = {
1454
+ "data-stage-card": "items",
1455
+ class: "overflow-hidden border border-fm-color-neutral-gray-200 bg-fm-color-surface-primary fm-corner-radius-md"
1456
+ }, Oa = { class: "flex min-h-[60px] items-center border-b border-fm-color-neutral-gray-200 px-16 py-12" }, ja = { class: "inline-flex items-center gap-4 fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Fa = { "data-output-count": "" }, Ea = { class: "grid grid-cols-[minmax(0,1fr)_auto] gap-x-12 px-16 py-12" }, Da = { class: "fm-typo-en-body-md-600 truncate text-fm-color-typo-primary" }, Ma = {
1457
+ "data-requested-quantity": "",
1458
+ class: "fm-typo-en-body-md-600 justify-self-end text-right tabular-nums text-fm-color-typo-primary"
1459
+ }, Va = {
1460
+ key: 0,
1461
+ "data-output-stock": "",
1462
+ "data-output-stock-transition": "",
1463
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1464
+ }, Ua = /* @__PURE__ */ Q({
1465
+ __name: "ProductionRunRequestedOverview",
1466
+ props: {
1467
+ run: {},
1468
+ items: {},
1469
+ ingredients: {},
1470
+ refreshable: { type: Boolean, default: !1 },
1471
+ refreshing: { type: Boolean, default: !1 },
1472
+ showStockProjection: { type: Boolean, default: !0 }
1473
+ },
1474
+ emits: ["refresh"],
1475
+ setup(P, { emit: c }) {
1476
+ const t = P, k = c, { t: l } = Y(), u = _(() => new Map(t.items.map((i) => [i.skuId, i]))), x = _(() => {
1477
+ var i;
1478
+ return new Set(((i = t.run.plan.requirements) == null ? void 0 : i.skippedSkuIds) ?? []);
1479
+ }), f = _(() => bt(t.run.plan)), $ = j(/* @__PURE__ */ new Set());
1480
+ se(
1481
+ () => t.run._id,
1482
+ () => $.value = /* @__PURE__ */ new Set()
1483
+ );
1484
+ function w(i) {
1485
+ return `requested-item-ingredients-${t.run._id}-${i}`.replace(/[^a-zA-Z0-9_-]/g, "-");
1486
+ }
1487
+ function a(i) {
1488
+ const m = new Set($.value);
1489
+ m.has(i) ? m.delete(i) : m.add(i), $.value = m;
1490
+ }
1491
+ const I = _(
1492
+ () => [...x.value].map((i) => {
1493
+ var m;
1494
+ return ((m = u.value.get(i)) == null ? void 0 : m.name) ?? i;
1495
+ })
1496
+ ), s = _(
1497
+ () => t.run.plan.items.map((i) => {
1498
+ const m = u.value.get(i.skuId), n = yt(i.measurement) ? i.measurement : null;
1499
+ return {
1500
+ skuId: i.skuId,
1501
+ name: (m == null ? void 0 : m.name) ?? i.skuId,
1502
+ stock: (m == null ? void 0 : m.onHand) != null && n && m.sku && m.baseQuantity != null && m.baseUnit ? `${l("inventory.production.run.form.items.columns.inStock")} ${F(
1503
+ m.onHand,
1504
+ null,
1505
+ {
1506
+ precision: Ne(m.sku)
1507
+ }
1508
+ )} → ${F(m.onHand + m.baseQuantity, m.baseUnit, {
1509
+ precision: Ne(m.sku)
1510
+ })}` : le,
1511
+ // Read-only history renders its own structurally valid frozen snapshot.
1512
+ // Catalogue compatibility is checked only before a new write.
1513
+ requested: n ? F(i.requestedAmount, n.abbrev, {
1514
+ precision: i.requestedAmount.precision
1515
+ }) : le,
1516
+ ingredientBreakdown: f.value.get(i.skuId) ?? null,
1517
+ hasNoBindings: x.value.has(i.skuId)
1518
+ };
1519
+ })
1520
+ );
1521
+ return (i, m) => {
1522
+ var n;
1523
+ return r(), v("div", Ba, [
1524
+ o("div", Ca, [
1525
+ q(ft, {
1526
+ instructions: i.run.instructions
1527
+ }, null, 8, ["instructions"]),
1528
+ q(gt, {
1529
+ "data-stage-card": "ingredients",
1530
+ mode: "requested",
1531
+ rows: i.ingredients,
1532
+ "no-items": !((n = i.run.plan.requirements) != null && n.ingredients.length),
1533
+ "unbound-names": I.value,
1534
+ refreshable: i.refreshable && i.showStockProjection,
1535
+ refreshing: i.refreshing,
1536
+ "show-stock-projection": i.showStockProjection,
1537
+ onRefresh: m[0] || (m[0] = (d) => k("refresh"))
1538
+ }, null, 8, ["rows", "no-items", "unbound-names", "refreshable", "refreshing", "show-stock-projection"])
1539
+ ]),
1540
+ o("section", Na, [
1541
+ o("header", Oa, [
1542
+ o("h2", ja, [
1543
+ ie(p(e(l)("inventory.production.run.form.items.title")) + " ", 1),
1544
+ o("span", Fa, "(" + p(s.value.length) + ")", 1),
1545
+ q(ze, {
1546
+ "description-id": "requested-quantity-help",
1547
+ testid: "requested-quantity-help-trigger",
1548
+ "trigger-label": e(l)("inventory.production.run.detail.requested.quantityHelpLabel"),
1549
+ description: e(l)("inventory.production.run.detail.requested.quantityHelp")
1550
+ }, null, 8, ["trigger-label", "description"])
1551
+ ])
1552
+ ]),
1553
+ (r(!0), v(W, null, oe(s.value, (d) => {
1554
+ var g, T;
1555
+ return r(), v("div", {
1556
+ key: d.skuId,
1557
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
1558
+ }, [
1559
+ o("div", Ea, [
1560
+ o("span", Da, p(d.name), 1),
1561
+ o("span", Ma, p(d.requested), 1),
1562
+ i.showStockProjection ? (r(), v("span", Va, p(d.stock), 1)) : R("", !0),
1563
+ o("span", {
1564
+ "data-requested-label": "",
1565
+ class: z(["fm-typo-en-body-sm-400 text-right text-fm-color-typo-secondary", i.showStockProjection ? "" : "col-start-2"])
1566
+ }, p(e(l)("inventory.production.run.detail.items.requested")), 3),
1567
+ d.hasNoBindings ? (r(), B(He, {
1568
+ key: 1,
1569
+ class: "col-span-2 mt-4",
1570
+ "item-name": d.name
1571
+ }, null, 8, ["item-name"])) : (g = d.ingredientBreakdown) != null && g.lines.length ? (r(), B(Ue, {
1572
+ key: 2,
1573
+ class: "col-span-2 mt-4",
1574
+ testid: "requested-item-ingredients-toggle",
1575
+ count: d.ingredientBreakdown.lines.length,
1576
+ controls: w(d.skuId),
1577
+ expanded: $.value.has(d.skuId),
1578
+ onToggle: (C) => a(d.skuId)
1579
+ }, null, 8, ["count", "controls", "expanded", "onToggle"])) : R("", !0)
1580
+ ]),
1581
+ $.value.has(d.skuId) && ((T = d.ingredientBreakdown) != null && T.lines.length) ? (r(), B(We, {
1582
+ key: 0,
1583
+ id: w(d.skuId),
1584
+ testid: "requested-item-ingredients-list",
1585
+ class: "px-16 pb-12",
1586
+ count: d.ingredientBreakdown.lines.length,
1587
+ unit: d.ingredientBreakdown.basisUnit,
1588
+ lines: d.ingredientBreakdown.lines,
1589
+ "item-name": d.name
1590
+ }, null, 8, ["id", "count", "unit", "lines", "item-name"])) : R("", !0)
1591
+ ]);
1592
+ }), 128))
1593
+ ])
1594
+ ]);
1595
+ };
1596
+ }
1597
+ }), Ha = /* @__PURE__ */ me(Ua, [["__scopeId", "data-v-ff35cbd5"]]), za = ["aria-label"], Wa = { class: "flex min-w-max items-center gap-8" }, Ga = ["id", "aria-selected", "aria-controls", "tabindex", "onClick", "onKeydown"], Ka = /* @__PURE__ */ Q({
1598
+ __name: "ProductionRunDetailTabs",
1599
+ props: {
1600
+ items: {},
1601
+ modelValue: {},
1602
+ ariaLabel: {}
1603
+ },
1604
+ emits: ["update:modelValue"],
1605
+ setup(P, { emit: c }) {
1606
+ const t = P, k = c, l = j([]);
1607
+ function u(f, $ = !1) {
1608
+ const w = t.items[f];
1609
+ w && (k("update:modelValue", w.value), $ && Ie(() => {
1610
+ var a;
1611
+ return (a = l.value[f]) == null ? void 0 : a.focus();
1612
+ }));
1613
+ }
1614
+ function x(f, $) {
1615
+ let w = null;
1616
+ f.key === "ArrowRight" && (w = ($ + 1) % t.items.length), f.key === "ArrowLeft" && (w = ($ - 1 + t.items.length) % t.items.length), f.key === "Home" && (w = 0), f.key === "End" && (w = t.items.length - 1), w !== null && (f.preventDefault(), u(w, !0));
1617
+ }
1618
+ return se(
1619
+ () => t.modelValue,
1620
+ async (f) => {
1621
+ var w, a;
1622
+ await Ie();
1623
+ const $ = t.items.findIndex((I) => I.value === f);
1624
+ (a = (w = l.value[$]) == null ? void 0 : w.scrollIntoView) == null || a.call(w, { block: "nearest", inline: "nearest" });
1625
+ },
1626
+ { immediate: !0 }
1627
+ ), (f, $) => (r(), v("nav", {
1628
+ role: "tablist",
1629
+ "aria-label": f.ariaLabel,
1630
+ class: "overflow-x-auto print:hidden"
1631
+ }, [
1632
+ o("div", Wa, [
1633
+ (r(!0), v(W, null, oe(f.items, (w, a) => (r(), v("button", {
1634
+ id: w.id,
1635
+ key: w.value,
1636
+ ref_for: !0,
1637
+ ref: (I) => l.value[a] = I,
1638
+ type: "button",
1639
+ role: "tab",
1640
+ "aria-selected": f.modelValue === w.value,
1641
+ "aria-controls": w.controls,
1642
+ tabindex: f.modelValue === w.value ? 0 : -1,
1643
+ class: z(["flex h-40 shrink-0 items-center gap-[6px] border-b-2 px-12 text-[14px] leading-[18px] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-fm-color-border-focused", [
1644
+ f.modelValue === w.value ? "border-fm-color-primary font-semibold text-fm-color-primary" : "border-transparent font-normal text-fm-color-typo-secondary hover:text-fm-color-typo-primary"
1645
+ ]]),
1646
+ onClick: (I) => u(a),
1647
+ onKeydown: (I) => x(I, a)
1648
+ }, [
1649
+ o("span", null, p(w.label), 1)
1650
+ ], 42, Ga))), 128))
1651
+ ])
1652
+ ], 8, za));
1653
+ }
1654
+ }), Qa = {
1655
+ key: 0,
1656
+ "data-testid": "production-run-close-remark"
1657
+ }, Za = /* @__PURE__ */ Q({
1658
+ __name: "ProductionRunTerminalNotice",
1659
+ props: {
1660
+ run: {}
1661
+ },
1662
+ setup(P) {
1663
+ const c = P, { t } = Y(), k = _(() => ht(c.run)), l = _(
1664
+ () => {
1665
+ var u, x;
1666
+ return ((x = (u = [...c.run.activityLogs].reverse().find((f) => f.action === "close")) == null ? void 0 : u.remark) == null ? void 0 : x.trim()) || null;
1667
+ }
1668
+ );
1669
+ return (u, x) => k.value === "above-target" ? (r(), B(re, {
1670
+ key: 0,
1671
+ "data-testid": "closed-run-notice",
1672
+ role: "note",
1673
+ tone: "warn",
1674
+ title: e(t)("inventory.production.run.detail.banner.closedAbove.title")
1675
+ }, null, 8, ["title"])) : k.value === "below-target" ? (r(), B(re, {
1676
+ key: 1,
1677
+ "data-testid": "closed-run-notice",
1678
+ role: "note",
1679
+ tone: "warn",
1680
+ title: e(t)("inventory.production.run.detail.banner.closed.title")
1681
+ }, {
1682
+ default: ne(() => [
1683
+ l.value ? (r(), v("p", Qa, p(l.value), 1)) : R("", !0)
1684
+ ]),
1685
+ _: 1
1686
+ }, 8, ["title"])) : u.run.status === "CANCEL" ? (r(), B(re, {
1687
+ key: 2,
1688
+ "data-testid": "cancelled-run-notice",
1689
+ role: "note",
1690
+ tone: "critical",
1691
+ title: e(t)("inventory.production.run.detail.banner.cancelled.title"),
1692
+ message: u.run.cancelReason || void 0
1693
+ }, null, 8, ["title", "message"])) : R("", !0);
1694
+ }
1695
+ }), Fe = {
1696
+ failed: 4,
1697
+ unavailable: 3,
1698
+ unknown: 2,
1699
+ dispatched: 1
1700
+ };
1701
+ function Ja(P) {
1702
+ switch (P.stockRecalculationDispatch) {
1703
+ case "failed":
1704
+ return "failed";
1705
+ case "dispatched":
1706
+ return "dispatched";
1707
+ case "unavailable":
1708
+ return "unavailable";
1709
+ case "not-required":
1710
+ return null;
1711
+ default:
1712
+ return P.stockRecalculationRequired ? "unknown" : null;
1713
+ }
1714
+ }
1715
+ function Ya(P, { leaveOnLocationChange: c = !0 } = {}) {
1716
+ const t = Ke(), k = Ae(), l = Se(), u = j(null), x = j("waitingForLocation"), f = j(null), $ = j("overview"), w = j(null), a = _(() => w.value !== null);
1717
+ let I = null, s = 0, i = null;
1718
+ async function m() {
1719
+ const A = ++s;
1720
+ i = null;
1721
+ const D = k._currentLocation;
1722
+ if (!D) {
1723
+ x.value = "waitingForLocation";
1724
+ return;
1725
+ }
1726
+ if (I && I !== D.dbName) {
1727
+ u.value = null, c ? (I = null, await l.replace(Le())) : x.value = "loading";
1728
+ return;
1729
+ }
1730
+ const J = fe(P);
1731
+ if (!J) {
1732
+ x.value = "error";
1733
+ return;
1734
+ }
1735
+ x.value = "loading", f.value = null, i = { dbName: D.dbName, id: J };
1736
+ try {
1737
+ const ae = await t.read(J);
1738
+ if (A !== s) return;
1739
+ i = null, u.value = ae, I = D.dbName, x.value = "ready";
1740
+ } catch (ae) {
1741
+ if (A !== s) return;
1742
+ i = null;
1743
+ const ce = be(ae);
1744
+ x.value = ce.kind === "notFound" ? "notInLocation" : "error", f.value = ce.message, u.value = null;
1745
+ }
1746
+ }
1747
+ async function n() {
1748
+ const A = fe(P);
1749
+ if (!A || !k._currentLocation) return;
1750
+ const D = ++s;
1751
+ i = null;
1752
+ try {
1753
+ const J = await t.read(A);
1754
+ if (D !== s) return;
1755
+ u.value = J, x.value = "ready";
1756
+ } catch (J) {
1757
+ if (D !== s) return;
1758
+ const ae = be(J);
1759
+ x.value = ae.kind === "notFound" ? "notInLocation" : "error", f.value = ae.message;
1760
+ }
1761
+ }
1762
+ async function d() {
1763
+ var D;
1764
+ const A = (D = k._currentLocation) == null ? void 0 : D.dbName;
1765
+ A && A === I && x.value !== "waitingForLocation" || A && x.value === "loading" && (i == null ? void 0 : i.dbName) === A && i.id === fe(P) || await m();
1766
+ }
1767
+ k.watchLocation(d), se(
1768
+ () => fe(P),
1769
+ (A, D) => {
1770
+ !A || A === D || (u.value = null, $.value = "overview", w.value = null, m());
1771
+ }
1772
+ );
1773
+ function g(A) {
1774
+ if (!("run" in A)) {
1775
+ u.value = A;
1776
+ return;
1777
+ }
1778
+ u.value = A.run;
1779
+ const D = Ja(A);
1780
+ if (!D) return;
1781
+ const J = w.value;
1782
+ (!J || Fe[D] > Fe[J]) && (w.value = D);
1783
+ }
1784
+ const T = _(() => {
1785
+ var A;
1786
+ return ((A = k._currentLocation) == null ? void 0 : A.name) ?? "";
1787
+ }), C = _(() => {
1788
+ var A;
1789
+ return (((A = u.value) == null ? void 0 : A.preparation.issuances.length) ?? 0) > 0;
1790
+ }), V = _(
1791
+ () => u.value ? _t(u.value) : []
1792
+ ), b = _(() => C.value ? V.value.length > 0 || !!u.value && we(u.value) ? ["overview", "output", "ingredients", "activity"] : ["overview", "ingredients", "activity"] : ["overview", "activity"]), S = _(() => !!u.value && !kt(u.value)), y = _(() => u.value && S.value ? $t(u.value) : null), N = _(() => u.value && S.value ? xt(u.value) : null), E = _(
1793
+ () => u.value && S.value ? Object.values(Me(u.value)).reduce((A, D) => A + D, 0) : null
1794
+ ), U = _(() => y.value === null || N.value === null ? null : y.value > 0 && N.value > 0 ? N.value / y.value * 100 : u.value && we(u.value) ? 0 : null), Z = _(() => !!u.value && wt(u.value)), O = _(
1795
+ () => Z.value && !!u.value && !we(u.value) && !Pe(u.value)
1796
+ ), X = _(() => u.value ? Ge(u.value) : null), ue = _(() => u.value ? It(u.value) : []), _e = _(() => ue.value.map((A) => A.action));
1797
+ function de(A) {
1798
+ return _e.value.includes(A);
1799
+ }
1800
+ const ye = _(() => {
1801
+ if (O.value && de("close")) return "close";
1802
+ for (const A of ["complete", "prepare", "request"])
1803
+ if (de(A)) return A;
1804
+ return null;
1805
+ }), ke = _(
1806
+ () => ["complete", "close", "update"].filter(
1807
+ (A) => de(A) && A !== ye.value
1808
+ )
1809
+ ), $e = _(
1810
+ () => ["cancel"].filter((A) => de(A))
1811
+ );
1812
+ return {
1813
+ run: u,
1814
+ phase: x,
1815
+ errorMessage: f,
1816
+ activeTab: $,
1817
+ tabs: b,
1818
+ locationName: T,
1819
+ stockRecalculation: w,
1820
+ stockRecalculationRequired: a,
1821
+ /** The one way to take a stock-moving write's answer onto the page. */
1822
+ adoptWriteResult: g,
1823
+ hasIssuance: C,
1824
+ batches: V,
1825
+ committed: y,
1826
+ produced: N,
1827
+ remaining: E,
1828
+ attainmentPercent: U,
1829
+ atTarget: Z,
1830
+ targetReachedOpen: O,
1831
+ outcome: X,
1832
+ summable: S,
1833
+ legalActions: ue,
1834
+ /** Legality asked as a question, so callers never re-derive the table. */
1835
+ can: de,
1836
+ primaryAction: ye,
1837
+ secondaryActions: ke,
1838
+ dangerActions: $e,
1839
+ load: m,
1840
+ reload: n
1841
+ };
1842
+ }
1843
+ function Xa(P) {
1844
+ const c = j([]), t = j(null), k = j(!1), l = j(!1), u = j(null);
1845
+ let x = 0;
1846
+ const f = _(() => ({
1847
+ loading: k.value,
1848
+ loaded: l.value,
1849
+ hasMore: t.value !== null,
1850
+ error: u.value
1851
+ }));
1852
+ function $() {
1853
+ x++, c.value = [], t.value = null, k.value = !1, l.value = !1, u.value = null;
1854
+ }
1855
+ async function w(s) {
1856
+ const i = x, m = P.runId(), n = P.locationId(), d = () => i === x && P.runId() === m && P.locationId() === n;
1857
+ k.value = !0, u.value = null;
1858
+ try {
1859
+ const g = await P.list(s);
1860
+ if (!d()) return;
1861
+ if (s && g.nextCursor === s)
1862
+ throw new Error(
1863
+ "The next page could not be advanced. Reopen the editor to refresh history."
1864
+ );
1865
+ const T = new Set(c.value.map((C) => C._id));
1866
+ c.value = [...c.value, ...g.items.filter((C) => !T.has(C._id))], t.value = g.nextCursor, l.value = !0;
1867
+ } catch (g) {
1868
+ d() && (u.value = be(g).message);
1869
+ } finally {
1870
+ d() && (k.value = !1);
1871
+ }
1872
+ }
1873
+ async function a() {
1874
+ $(), await w();
1875
+ }
1876
+ async function I() {
1877
+ if (!k.value) {
1878
+ if (!l.value) return await a();
1879
+ t.value !== null && await w(t.value);
1880
+ }
1881
+ }
1882
+ return { sources: c, state: f, load: a, loadMore: I, invalidate: $ };
1883
+ }
1884
+ const er = { class: "flex flex-col w-full h-full bg-fm-color-surface-primary overflow-y-auto" }, tr = {
1885
+ key: 0,
1886
+ class: "flex flex-col gap-16 p-24"
1887
+ }, nr = {
1888
+ key: 1,
1889
+ class: "flex flex-col gap-16 p-24 max-w-[640px]"
1890
+ }, or = {
1891
+ key: 2,
1892
+ class: "flex flex-col gap-16 p-24 max-w-[640px]"
1893
+ }, ar = {
1894
+ key: 1,
1895
+ class: "flex justify-center py-32"
1896
+ }, rr = /* @__PURE__ */ Q({
1897
+ __name: "ProductionRunDetailView",
1898
+ props: {
1899
+ id: {}
1900
+ },
1901
+ setup(P) {
1902
+ const c = P, { t } = Y(), k = Se(), l = rt(), u = ot(), x = st(), f = Ke(), $ = Ae(), w = _(() => Le());
1903
+ Rt();
1904
+ const a = Ya(() => c.id, { leaveOnLocationChange: !1 }), I = St(() => a.run.value), s = Xa({
1905
+ list: (h) => f.list(h ? { cursor: h } : {}),
1906
+ runId: () => c.id,
1907
+ locationId: () => $.currentLocationId
1908
+ }), i = s.sources, m = At(), n = j(!1), d = _(
1909
+ () => a.run.value ? m.requestedIngredientRows(a.run.value) : []
1910
+ );
1911
+ async function g() {
1912
+ if (!a.run.value) return;
1913
+ const h = c.id;
1914
+ if (a.run.value.status === "CANCEL") {
1915
+ n.value = !0, await m.loadCatalogue();
1916
+ return;
1917
+ }
1918
+ !await m.load({ livePlan: a.run.value.status === "DRAFT" }) || h !== c.id || !a.run.value || (m.seedFrom(a.run.value), n.value = !0);
1919
+ }
1920
+ const T = _(() => {
1921
+ const h = a.run.value, L = h == null ? void 0 : h.status;
1922
+ return L === "DRAFT" ? "draft" : L === "REQUESTING" ? "requested" : L === "PREPARING" ? "preparing" : L === "CANCEL" ? h != null && h.plan.requirements ? "requested" : "draft" : "review";
1923
+ }), C = _(() => {
1924
+ var h;
1925
+ return ((h = a.run.value) == null ? void 0 : h.status) !== "CANCEL";
1926
+ }), V = _(() => {
1927
+ const h = a.run.value;
1928
+ return h && h.status === "CANCEL" ? m.historicalItems(h) : void 0;
1929
+ });
1930
+ se(
1931
+ () => [a.phase.value, a.hasIssuance.value],
1932
+ async ([h, L]) => {
1933
+ h !== "ready" || L || n.value || !a.run.value || await g();
1934
+ },
1935
+ { immediate: !0 }
1936
+ );
1937
+ const b = j(null);
1938
+ let S = null;
1939
+ const y = j("review"), N = j(!1), E = j(null);
1940
+ let U = 0;
1941
+ tt(() => {
1942
+ U++;
1943
+ }), se(
1944
+ () => c.id,
1945
+ () => {
1946
+ s.invalidate(), n.value = !1, ae.value = !1, b.value = null, U++, N.value = !1;
1947
+ }
1948
+ );
1949
+ const Z = _(() => a.run.value ? Pt(a.run.value) : null), O = _(() => {
1950
+ var L, H;
1951
+ const h = {};
1952
+ for (const G of ((L = a.run.value) == null ? void 0 : L.preparation.issuances) ?? [])
1953
+ for (const M of G.items)
1954
+ h[M.sku._id] = {
1955
+ name: M.sku.name,
1956
+ unit: ((H = M.sku.unit) == null ? void 0 : H.abbrev) ?? null,
1957
+ precision: M.sku.unit ? Oe(M.sku.unit) : null
1958
+ };
1959
+ for (const G of I.ingredientLines.value)
1960
+ h[G.skuId] || (h[G.skuId] = {
1961
+ name: G.name,
1962
+ unit: G.unit,
1963
+ precision: G.unitRef ? Oe(G.unitRef) : null
1964
+ });
1965
+ return h;
1966
+ }), X = _(
1967
+ () => a.tabs.value.map((h) => ({
1968
+ label: t(`inventory.production.run.detail.tab.${h}`),
1969
+ value: h,
1970
+ id: `production-run-tab-${h}`,
1971
+ controls: `production-run-panel-${h}`
1972
+ }))
1973
+ ), ue = _(
1974
+ () => !!a.run.value && Pe(a.run.value)
1975
+ ), _e = _(
1976
+ () => !!a.run.value && Lt(a.run.value)
1977
+ ), de = _(() => {
1978
+ const h = a.run.value;
1979
+ if (!h) return "";
1980
+ if (ue.value) return t("inventory.production.run.detail.pendingStock.message");
1981
+ let L;
1982
+ switch (h.status) {
1983
+ case "REQUESTING":
1984
+ L = "requested";
1985
+ break;
1986
+ case "PREPARING":
1987
+ L = h.batches.length > 0 ? "issuedWithOutput" : "issued";
1988
+ break;
1989
+ case "CLOSED":
1990
+ L = "closed";
1991
+ break;
1992
+ case "CANCEL":
1993
+ L = "cancelled";
1994
+ break;
1995
+ default:
1996
+ L = "draft";
1997
+ }
1998
+ return t(`inventory.production.run.detail.next.${L}`);
1999
+ }), ye = _(
2000
+ () => I.ingredientLines.value.map((h) => ({
2001
+ skuId: h.skuId,
2002
+ name: h.name,
2003
+ unit: h.unit,
2004
+ unitRef: h.unitRef,
2005
+ outputSkuIds: h.outputSkuIds
2006
+ }))
2007
+ );
2008
+ function ke(h) {
2009
+ var L;
2010
+ if (a.can(h)) {
2011
+ if (h === "update") {
2012
+ b.value = "update", s.load();
2013
+ return;
2014
+ }
2015
+ if (h === "request") {
2016
+ const H = (L = a.run.value) == null ? void 0 : L._id, G = $.currentLocationDBName, M = U;
2017
+ l.open(Ct(t)).onPrimary(() => {
2018
+ var Be;
2019
+ M !== U || H !== ((Be = a.run.value) == null ? void 0 : Be._id) || G !== $.currentLocationDBName || A();
2020
+ });
2021
+ return;
2022
+ }
2023
+ h === "prepare" && (y.value = "review"), S = document.activeElement instanceof HTMLElement ? document.activeElement : null, b.value = h;
2024
+ }
2025
+ }
2026
+ function $e() {
2027
+ a.can("prepare") && (y.value = "print", S = document.activeElement instanceof HTMLElement ? document.activeElement : null, b.value = "prepare");
2028
+ }
2029
+ async function A() {
2030
+ if (!a.can("request")) return;
2031
+ const h = a.run.value;
2032
+ if (!h) return;
2033
+ const L = ++U;
2034
+ N.value = !0;
2035
+ try {
2036
+ const H = await f.request(h._id);
2037
+ if (L !== U) return;
2038
+ a.run.value = H, x == null || x.open({ title: t("inventory.production.run.detail.toast.requested"), type: "success" });
2039
+ } catch (H) {
2040
+ if (L !== U) return;
2041
+ const G = be(H), M = Nt(t, G, m.catalogueName);
2042
+ x == null || x.open({
2043
+ title: (M == null ? void 0 : M.title) ?? t("inventory.production.run.list.error.action", {
2044
+ action: t("inventory.production.run.list.rowActions.request")
2045
+ }),
2046
+ message: (M == null ? void 0 : M.message) ?? G.message,
2047
+ type: "error"
2048
+ });
2049
+ } finally {
2050
+ L === U && (N.value = !1);
2051
+ }
2052
+ }
2053
+ function D(h) {
2054
+ a.adoptWriteResult(h), u.success(t("inventory.production.run.detail.toast.issued"));
2055
+ }
2056
+ function J(h) {
2057
+ a.adoptWriteResult(h), I.refresh(), u.success(t("inventory.production.run.detail.toast.recorded")), ae.value = a.can("close") && a.atTarget.value;
2058
+ }
2059
+ const ae = j(!1), ce = _(() => {
2060
+ const h = a.stockRecalculation.value;
2061
+ return h ? {
2062
+ tone: h === "dispatched" ? "info" : "warn",
2063
+ key: `inventory.production.run.detail.recalculation.${h}`
2064
+ } : null;
2065
+ }), Ze = _(() => {
2066
+ const h = a.locationName.value;
2067
+ return h ? t("inventory.production.run.detail.notInLocation.title", { location: h }) : t("inventory.production.run.detail.notInLocation.titleUnknown");
2068
+ });
2069
+ function Je(h) {
2070
+ b.value = null, s.invalidate(), xe(h), n.value && m.seedFrom(h), I.refresh();
2071
+ }
2072
+ function qe() {
2073
+ a.reload(), I.refresh();
2074
+ }
2075
+ se(
2076
+ () => a.activeTab.value,
2077
+ (h, L) => {
2078
+ h === "ingredients" && L !== "ingredients" && qe();
2079
+ }
2080
+ );
2081
+ async function Te() {
2082
+ try {
2083
+ await m.refreshStock();
2084
+ } catch (h) {
2085
+ u.error(be(h).message);
2086
+ }
2087
+ }
2088
+ async function Ye(h) {
2089
+ var L;
2090
+ if (h === null) {
2091
+ const H = S;
2092
+ S = null, b.value = null, s.invalidate(), await Ie(), H != null && H.isConnected ? H.focus() : (L = E.value) == null || L.focus();
2093
+ }
2094
+ }
2095
+ function xe(h) {
2096
+ a.run.value = h;
2097
+ }
2098
+ function Xe() {
2099
+ k.push(w.value);
2100
+ }
2101
+ return (h, L) => {
2102
+ const H = te("FmButton"), G = te("FmCircularProgress");
2103
+ return r(), v("div", er, [
2104
+ e(a).phase.value === "waitingForLocation" || e(a).phase.value === "loading" ? (r(), v("div", tr, L[3] || (L[3] = [
2105
+ o("div", { class: "h-24 w-1/3 rounded bg-fm-color-neutral-gray-100 animate-pulse" }, null, -1),
2106
+ o("div", { class: "h-16 w-1/2 rounded bg-fm-color-neutral-gray-100 animate-pulse" }, null, -1),
2107
+ o("div", { class: "h-[240px] rounded bg-fm-color-neutral-gray-100 animate-pulse" }, null, -1)
2108
+ ]))) : e(a).phase.value === "notInLocation" ? (r(), v("div", nr, [
2109
+ q(re, {
2110
+ tone: "warn",
2111
+ title: Ze.value,
2112
+ message: e(t)("inventory.production.run.detail.notInLocation.message")
2113
+ }, {
2114
+ actions: ne(() => [
2115
+ q(H, {
2116
+ variant: "secondary",
2117
+ label: e(t)("inventory.production.run.detail.notInLocation.action"),
2118
+ onClick: Xe
2119
+ }, null, 8, ["label"])
2120
+ ]),
2121
+ _: 1
2122
+ }, 8, ["title", "message"])
2123
+ ])) : e(a).phase.value === "error" ? (r(), v("div", or, [
2124
+ q(re, {
2125
+ role: "alert",
2126
+ tone: "critical",
2127
+ title: e(t)("inventory.production.run.detail.error.title"),
2128
+ message: e(a).errorMessage.value ?? void 0
2129
+ }, {
2130
+ actions: ne(() => [
2131
+ q(H, {
2132
+ variant: "secondary",
2133
+ label: e(t)("inventory.production.run.detail.error.retry"),
2134
+ onClick: L[0] || (L[0] = (M) => e(a).load())
2135
+ }, null, 8, ["label"])
2136
+ ]),
2137
+ _: 1
2138
+ }, 8, ["title", "message"])
2139
+ ])) : e(a).run.value ? (r(), v("div", {
2140
+ key: 3,
2141
+ ref_key: "detailContent",
2142
+ ref: E,
2143
+ tabindex: "-1",
2144
+ "data-testid": "production-run-detail-content",
2145
+ class: "production-run-detail-content mx-auto flex w-full max-w-[1228px] flex-col gap-16"
2146
+ }, [
2147
+ q(Zt, {
2148
+ run: e(a).run.value,
2149
+ "location-name": e(a).locationName.value,
2150
+ "back-to": w.value,
2151
+ "primary-action": e(a).primaryAction.value,
2152
+ "secondary-actions": e(a).secondaryActions.value,
2153
+ "danger-actions": e(a).dangerActions.value,
2154
+ "can-print-prepare-sheet": e(a).primaryAction.value === "prepare",
2155
+ "status-description": de.value,
2156
+ "target-reached": e(a).targetReachedOpen.value,
2157
+ busy: N.value,
2158
+ onAction: ke,
2159
+ onPrintPrepareSheet: $e
2160
+ }, null, 8, ["run", "location-name", "back-to", "primary-action", "secondary-actions", "danger-actions", "can-print-prepare-sheet", "status-description", "target-reached", "busy"]),
2161
+ ue.value ? (r(), B(re, {
2162
+ key: 0,
2163
+ "data-testid": "production-run-pending-stock",
2164
+ role: "status",
2165
+ tone: "warn",
2166
+ title: e(t)("inventory.production.run.detail.pendingStock.title"),
2167
+ message: e(t)("inventory.production.run.detail.pendingStock.message")
2168
+ }, null, 8, ["title", "message"])) : R("", !0),
2169
+ _e.value ? (r(), B(re, {
2170
+ key: 1,
2171
+ "data-testid": "production-run-pending-preparation",
2172
+ role: "status",
2173
+ tone: "warn",
2174
+ title: e(t)("inventory.production.run.detail.pendingPreparation.title"),
2175
+ message: e(t)("inventory.production.run.detail.pendingPreparation.message")
2176
+ }, null, 8, ["title", "message"])) : R("", !0),
2177
+ ce.value ? (r(), B(re, {
2178
+ key: 2,
2179
+ tone: ce.value.tone,
2180
+ title: e(t)(`${ce.value.key}.title`),
2181
+ message: e(t)(`${ce.value.key}.message`)
2182
+ }, null, 8, ["tone", "title", "message"])) : R("", !0),
2183
+ ae.value && e(a).targetReachedOpen.value ? (r(), B(re, {
2184
+ key: 3,
2185
+ "data-testid": "target-reached-notice",
2186
+ tone: "info",
2187
+ title: e(t)("inventory.production.run.detail.targetOffer.title"),
2188
+ message: e(t)("inventory.production.run.detail.targetOffer.message")
2189
+ }, null, 8, ["title", "message"])) : R("", !0),
2190
+ q(Za, {
2191
+ run: e(a).run.value
2192
+ }, null, 8, ["run"]),
2193
+ q(Ka, {
2194
+ modelValue: e(a).activeTab.value,
2195
+ "onUpdate:modelValue": L[1] || (L[1] = (M) => e(a).activeTab.value = M),
2196
+ class: "mb-4",
2197
+ items: X.value,
2198
+ ariaLabel: e(t)("inventory.production.run.detail.tabsLabel")
2199
+ }, null, 8, ["modelValue", "items", "ariaLabel"]),
2200
+ e(a).activeTab.value === "overview" ? (r(), B(Wo, {
2201
+ key: 4,
2202
+ id: "production-run-panel-overview",
2203
+ role: "tabpanel",
2204
+ "aria-labelledby": "production-run-tab-overview",
2205
+ run: e(a).run.value,
2206
+ names: O.value,
2207
+ batches: e(a).batches.value,
2208
+ committed: e(a).committed.value,
2209
+ unit: Z.value,
2210
+ "has-issuance": e(a).hasIssuance.value,
2211
+ operational: T.value !== "review",
2212
+ onViewAll: L[2] || (L[2] = (M) => e(a).activeTab.value = "output")
2213
+ }, {
2214
+ operational: ne(() => [
2215
+ C.value && T.value !== "preparing" && (e(m).loadFailure.value || e(m).projectionFailed.value) ? (r(), B(qt, {
2216
+ key: 0,
2217
+ "load-failure": e(m).loadFailure.value,
2218
+ "projection-failed": e(m).projectionFailed.value,
2219
+ "projection-problem": e(m).projectionProblem.value,
2220
+ "name-of": e(m).catalogueName,
2221
+ onRetryLoad: g,
2222
+ onRetryProjection: e(m).retryProjection
2223
+ }, null, 8, ["load-failure", "projection-failed", "projection-problem", "name-of", "onRetryProjection"])) : C.value && T.value !== "preparing" && e(m).loading.value ? (r(), v("div", ar, [
2224
+ q(G, { size: "lg" })
2225
+ ])) : T.value === "draft" && n.value ? (r(), B(Tt, {
2226
+ key: 2,
2227
+ items: e(m).items.value,
2228
+ "historical-items": V.value,
2229
+ commits: e(m).commits.value,
2230
+ instructions: e(a).run.value.instructions,
2231
+ editable: !1,
2232
+ refreshable: C.value,
2233
+ refreshing: e(m).refreshingStock.value,
2234
+ "show-stock-projection": C.value,
2235
+ onRefresh: Te
2236
+ }, null, 8, ["items", "historical-items", "commits", "instructions", "refreshable", "refreshing", "show-stock-projection"])) : T.value === "requested" && n.value ? (r(), B(Ha, {
2237
+ key: 3,
2238
+ run: e(a).run.value,
2239
+ items: V.value ?? e(m).items.value,
2240
+ ingredients: d.value,
2241
+ refreshable: C.value,
2242
+ refreshing: e(m).refreshingStock.value,
2243
+ "show-stock-projection": C.value,
2244
+ onRefresh: Te
2245
+ }, null, 8, ["run", "items", "ingredients", "refreshable", "refreshing", "show-stock-projection"])) : T.value === "preparing" ? (r(), B(Qe, {
2246
+ key: 4,
2247
+ run: e(a).run.value,
2248
+ names: O.value,
2249
+ "ingredient-contributions": e(I).ingredientContributions.value,
2250
+ "unattributed-ingredients": e(I).unattributedIngredientLines.value,
2251
+ "unissued-sku-ids": e(I).unissuedOutputs.value.map((M) => M.skuId),
2252
+ "title-key": "inventory.production.run.form.items.title",
2253
+ presentation: "preparing"
2254
+ }, null, 8, ["run", "names", "ingredient-contributions", "unattributed-ingredients", "unissued-sku-ids"])) : R("", !0)
2255
+ ]),
2256
+ _: 1
2257
+ }, 8, ["run", "names", "batches", "committed", "unit", "has-issuance", "operational"])) : e(a).activeTab.value === "output" ? (r(), B(Qo, {
2258
+ key: 5,
2259
+ id: "production-run-panel-output",
2260
+ role: "tabpanel",
2261
+ "aria-labelledby": "production-run-tab-output",
2262
+ batches: e(a).batches.value,
2263
+ names: O.value
2264
+ }, null, 8, ["batches", "names"])) : e(a).activeTab.value === "ingredients" ? (r(), B(_a, {
2265
+ key: 6,
2266
+ id: "production-run-panel-ingredients",
2267
+ role: "tabpanel",
2268
+ "aria-labelledby": "production-run-tab-ingredients",
2269
+ "run-id": e(a).run.value._id,
2270
+ loading: e(I).loading.value,
2271
+ "snapshot-available": e(I).adjustment.value !== null,
2272
+ lines: e(I).ingredientLines.value,
2273
+ "ingredient-contributions": e(I).ingredientContributions.value,
2274
+ "output-names": O.value,
2275
+ "unattributed-ingredients": e(I).unattributedIngredientLines.value
2276
+ }, null, 8, ["run-id", "loading", "snapshot-available", "lines", "ingredient-contributions", "output-names", "unattributed-ingredients"])) : (r(), B(Ta, {
2277
+ key: 7,
2278
+ id: "production-run-panel-activity",
2279
+ role: "tabpanel",
2280
+ "aria-labelledby": "production-run-tab-activity",
2281
+ run: e(a).run.value
2282
+ }, null, 8, ["run"])),
2283
+ q(Bt, {
2284
+ action: b.value,
2285
+ run: e(a).run.value,
2286
+ "location-name": e(a).locationName.value,
2287
+ "duplicate-sources": e(i),
2288
+ "duplicate-source-state": e(s).state.value,
2289
+ onLoadMoreDuplicateSources: e(s).loadMore,
2290
+ "prepare-initial-view": y.value,
2291
+ "at-target": e(a).atTarget.value,
2292
+ ingredients: ye.value,
2293
+ "onUpdate:action": Ye,
2294
+ onEdited: Je,
2295
+ onIssued: D,
2296
+ onRecorded: J,
2297
+ onClosed: xe,
2298
+ onCancelled: xe,
2299
+ onReload: qe
2300
+ }, null, 8, ["action", "run", "location-name", "duplicate-sources", "duplicate-source-state", "onLoadMoreDuplicateSources", "prepare-initial-view", "at-target", "ingredients"])
2301
+ ], 512)) : R("", !0)
2302
+ ]);
2303
+ };
2304
+ }
2305
+ }), sr = /* @__PURE__ */ me(rr, [["__scopeId", "data-v-e5fd70a2"]]), fr = /* @__PURE__ */ Q({
2306
+ __name: "ProductionRunDetailPage",
2307
+ props: {
2308
+ id: {}
2309
+ },
2310
+ setup(P) {
2311
+ var x;
2312
+ const c = P, t = Se(), k = Ae(), l = j(!1);
2313
+ let u = (x = k._currentLocation) == null ? void 0 : x.dbName;
2314
+ return se(
2315
+ () => {
2316
+ var f;
2317
+ return (f = k._currentLocation) == null ? void 0 : f.dbName;
2318
+ },
2319
+ (f) => {
2320
+ !f || l.value || (u && f !== u && (l.value = !0, t.replace(Le())), u = f);
2321
+ }
2322
+ ), (f, $) => (r(), B(nt, { "feature-key": "production-runs" }, {
2323
+ default: ne(() => [
2324
+ l.value ? R("", !0) : (r(), B(sr, {
2325
+ key: 0,
2326
+ id: c.id
2327
+ }, null, 8, ["id"]))
2328
+ ]),
2329
+ _: 1
2330
+ }));
2331
+ }
2332
+ });
2333
+ export {
2334
+ fr as default
2335
+ };