@rytass/bpm-core-react 0.4.1 → 0.5.0

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 (147) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/chunks/FormBuilderView-B_KGPjlp.cjs +3 -0
  3. package/dist/chunks/FormBuilderView-B_KGPjlp.cjs.map +1 -0
  4. package/dist/chunks/FormBuilderView-D8DrQOXD.js +1090 -0
  5. package/dist/chunks/FormBuilderView-D8DrQOXD.js.map +1 -0
  6. package/dist/chunks/{approval-instance-list-page-C5ZKPHdA.cjs → approval-instance-list-page-BMUKxzcz.cjs} +2 -2
  7. package/dist/chunks/{approval-instance-list-page-C5ZKPHdA.cjs.map → approval-instance-list-page-BMUKxzcz.cjs.map} +1 -1
  8. package/dist/chunks/{approval-instance-list-page-BF2r5D2-.js → approval-instance-list-page-YZcGGDD8.js} +2 -2
  9. package/dist/chunks/{approval-instance-list-page-BF2r5D2-.js.map → approval-instance-list-page-YZcGGDD8.js.map} +1 -1
  10. package/dist/chunks/compose-PMrmi-LE.js +451 -0
  11. package/dist/chunks/compose-PMrmi-LE.js.map +1 -0
  12. package/dist/chunks/compose-ziVbRYdo.cjs +2 -0
  13. package/dist/chunks/compose-ziVbRYdo.cjs.map +1 -0
  14. package/dist/chunks/{dashboard-page-Ib8srCMy.js → dashboard-page-DJ9vOPga.js} +2 -2
  15. package/dist/chunks/{dashboard-page-Ib8srCMy.js.map → dashboard-page-DJ9vOPga.js.map} +1 -1
  16. package/dist/chunks/{dashboard-page-CddG1MnK.cjs → dashboard-page-DwHQY6Ki.cjs} +2 -2
  17. package/dist/chunks/{dashboard-page-CddG1MnK.cjs.map → dashboard-page-DwHQY6Ki.cjs.map} +1 -1
  18. package/dist/chunks/designer-DCn6_v4b.cjs +65 -0
  19. package/dist/chunks/designer-DCn6_v4b.cjs.map +1 -0
  20. package/dist/chunks/designer-mOMxJ0Py.js +2576 -0
  21. package/dist/chunks/designer-mOMxJ0Py.js.map +1 -0
  22. package/dist/chunks/detail-Bml-vXHX.js +1622 -0
  23. package/dist/chunks/detail-Bml-vXHX.js.map +1 -0
  24. package/dist/chunks/detail-CWeCrmtC.cjs +2 -0
  25. package/dist/chunks/detail-CWeCrmtC.cjs.map +1 -0
  26. package/dist/chunks/{routes-config-dxahImVe.js → routes-config-RBYQtUd0.js} +2 -3
  27. package/dist/chunks/routes-config-RBYQtUd0.js.map +1 -0
  28. package/dist/chunks/routes-config-fDVHmvXi.cjs +2 -0
  29. package/dist/chunks/routes-config-fDVHmvXi.cjs.map +1 -0
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.js +268 -128
  33. package/dist/index.js.map +1 -1
  34. package/dist/lib/routes-config.d.ts +6 -4
  35. package/dist/next/index.cjs +1 -1
  36. package/dist/next/index.js +1 -1
  37. package/dist/next/workflow-chat-route.cjs +19 -0
  38. package/dist/next/workflow-chat-route.cjs.map +1 -0
  39. package/dist/next/workflow-chat-route.d.ts +17 -0
  40. package/dist/next/workflow-chat-route.js +31 -0
  41. package/dist/next/workflow-chat-route.js.map +1 -0
  42. package/dist/pages/instances/detail/index.cjs +1 -1
  43. package/dist/pages/instances/detail/index.js +1 -1
  44. package/dist/pages/templates/compose/index.cjs +2 -0
  45. package/dist/pages/templates/compose/index.cjs.map +1 -0
  46. package/dist/pages/templates/compose/index.d.ts +13 -0
  47. package/dist/pages/templates/compose/index.js +14 -0
  48. package/dist/pages/templates/compose/index.js.map +1 -0
  49. package/dist/pages/templates/designer/index.cjs +1 -1
  50. package/dist/pages/templates/designer/index.cjs.map +1 -1
  51. package/dist/pages/templates/designer/index.js +7 -2
  52. package/dist/pages/templates/designer/index.js.map +1 -1
  53. package/dist/pages/templates/index.cjs +1 -1
  54. package/dist/pages/templates/index.cjs.map +1 -1
  55. package/dist/pages/templates/index.js +3 -3
  56. package/dist/pages/templates/index.js.map +1 -1
  57. package/dist/views/cc/index.cjs +1 -1
  58. package/dist/views/cc/index.js +1 -1
  59. package/dist/views/dashboard/index.cjs +1 -1
  60. package/dist/views/dashboard/index.js +1 -1
  61. package/dist/views/forms/builder/FormBuilderView.d.ts +13 -4
  62. package/dist/views/forms/builder/index.cjs +1 -1
  63. package/dist/views/forms/builder/index.js +1 -1
  64. package/dist/views/forms/builder/json-code-editor.d.ts +1 -1
  65. package/dist/views/inbox/index.cjs +1 -1
  66. package/dist/views/inbox/index.js +1 -1
  67. package/dist/views/instances/detail/InstanceDetailView.d.ts +11 -1
  68. package/dist/views/instances/detail/index.cjs +1 -1
  69. package/dist/views/instances/detail/index.d.ts +5 -0
  70. package/dist/views/instances/detail/index.js +2 -2
  71. package/dist/views/instances/detail/sections/InstanceAttachmentsSection.d.ts +15 -0
  72. package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +33 -0
  73. package/dist/views/instances/detail/sections/InstanceHistorySection.d.ts +29 -0
  74. package/dist/views/instances/detail/sections/InstanceSignaturesSection.d.ts +14 -0
  75. package/dist/views/instances/detail/sections/InstanceTasksSection.d.ts +44 -0
  76. package/dist/views/instances/detail/sections/container-helpers.d.ts +8 -0
  77. package/dist/views/instances/detail/sections/shared.d.ts +103 -0
  78. package/dist/views/instances/new/index.cjs +1 -1
  79. package/dist/views/instances/new/index.js +1 -1
  80. package/dist/views/search/index.cjs +1 -1
  81. package/dist/views/search/index.js +1 -1
  82. package/dist/views/sent/index.cjs +1 -1
  83. package/dist/views/sent/index.js +1 -1
  84. package/dist/views/templates/TemplatesView.d.ts +5 -0
  85. package/dist/views/templates/compose/TemplateComposeWizardView.d.ts +8 -0
  86. package/dist/views/templates/compose/index.cjs +1 -0
  87. package/dist/views/templates/compose/index.d.ts +2 -0
  88. package/dist/views/templates/compose/index.js +2 -0
  89. package/dist/views/templates/compose/steps/ComposeFormStep.d.ts +15 -0
  90. package/dist/views/templates/compose/steps/ComposeReviewStep.d.ts +12 -0
  91. package/dist/views/templates/compose/steps/ComposeWorkflowStep.d.ts +11 -0
  92. package/dist/views/templates/compose/use-template-compose-wizard.d.ts +46 -0
  93. package/dist/views/templates/designer/TemplateDesignerView.d.ts +60 -2
  94. package/dist/views/templates/designer/chrome-workflow-chat.d.ts +12 -0
  95. package/dist/views/templates/designer/index.cjs +1 -51
  96. package/dist/views/templates/designer/index.js +2 -2272
  97. package/dist/views/templates/designer/use-workflow-chat.d.ts +21 -0
  98. package/dist/views/templates/designer/use-workflow-designer-controller.d.ts +41 -0
  99. package/dist/views/templates/designer/workflow-chat-drawer.d.ts +16 -0
  100. package/dist/views/templates/index.cjs +2 -1
  101. package/dist/views/templates/index.cjs.map +1 -0
  102. package/dist/views/templates/index.js +265 -4
  103. package/dist/views/templates/index.js.map +1 -0
  104. package/dist/views/templates/versions/index.cjs +1 -1
  105. package/dist/views/templates/versions/index.cjs.map +1 -1
  106. package/dist/views/templates/versions/index.js +38 -42
  107. package/dist/views/templates/versions/index.js.map +1 -1
  108. package/package.json +22 -19
  109. package/dist/chunks/builder-BLVnnpnP.js +0 -1300
  110. package/dist/chunks/builder-BLVnnpnP.js.map +0 -1
  111. package/dist/chunks/builder-DVE9zIKH.cjs +0 -3
  112. package/dist/chunks/builder-DVE9zIKH.cjs.map +0 -1
  113. package/dist/chunks/detail-Dcr5mM8g.cjs +0 -2
  114. package/dist/chunks/detail-Dcr5mM8g.cjs.map +0 -1
  115. package/dist/chunks/detail-u9DdLhDW.js +0 -1518
  116. package/dist/chunks/detail-u9DdLhDW.js.map +0 -1
  117. package/dist/chunks/form-name-modal-C3OEvkCV.js +0 -64
  118. package/dist/chunks/form-name-modal-C3OEvkCV.js.map +0 -1
  119. package/dist/chunks/form-name-modal-uZCHbtRH.cjs +0 -2
  120. package/dist/chunks/form-name-modal-uZCHbtRH.cjs.map +0 -1
  121. package/dist/chunks/routes-config-2aKbWq2H.cjs +0 -2
  122. package/dist/chunks/routes-config-2aKbWq2H.cjs.map +0 -1
  123. package/dist/chunks/routes-config-dxahImVe.js.map +0 -1
  124. package/dist/chunks/templates-D44FSB46.js +0 -380
  125. package/dist/chunks/templates-D44FSB46.js.map +0 -1
  126. package/dist/chunks/templates-w96t83N-.cjs +0 -2
  127. package/dist/chunks/templates-w96t83N-.cjs.map +0 -1
  128. package/dist/pages/forms/builder/index.cjs +0 -2
  129. package/dist/pages/forms/builder/index.cjs.map +0 -1
  130. package/dist/pages/forms/builder/index.d.ts +0 -21
  131. package/dist/pages/forms/builder/index.js +0 -15
  132. package/dist/pages/forms/builder/index.js.map +0 -1
  133. package/dist/pages/forms/index.cjs +0 -2
  134. package/dist/pages/forms/index.cjs.map +0 -1
  135. package/dist/pages/forms/index.d.ts +0 -17
  136. package/dist/pages/forms/index.js +0 -14
  137. package/dist/pages/forms/index.js.map +0 -1
  138. package/dist/views/forms/FormsView.d.ts +0 -2
  139. package/dist/views/forms/form-name-modal.d.ts +0 -12
  140. package/dist/views/forms/index.cjs +0 -2
  141. package/dist/views/forms/index.cjs.map +0 -1
  142. package/dist/views/forms/index.d.ts +0 -2
  143. package/dist/views/forms/index.js +0 -186
  144. package/dist/views/forms/index.js.map +0 -1
  145. package/dist/views/templates/designer/index.cjs.map +0 -1
  146. package/dist/views/templates/designer/index.js.map +0 -1
  147. package/dist/views/templates/template-name-modal.d.ts +0 -22
@@ -0,0 +1,1622 @@
1
+ "use client";
2
+ import { n as e } from "./auth-provider-B5oPmvk2.js";
3
+ import { t } from "./format-date-time-CB-LxzqT.js";
4
+ import { t as n } from "./bpm-form-field-Cao0rMol.js";
5
+ import { t as r } from "./FormRendererView-DrHsuSVo.js";
6
+ import { Fragment as i, forwardRef as a, useCallback as o, useEffect as s, useImperativeHandle as c, useMemo as l, useRef as u, useState as d } from "react";
7
+ import { AutoComplete as f, Button as p, Modal as m, PageHeader as h, Section as g, SectionGroup as ee, Select as te, Stepper as _, Table as ne, Textarea as re, Tooltip as v, Typography as y } from "@mezzanine-ui/react";
8
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
9
+ import { cancelApprovalInstance as C, decideTask as w, listAttachments as ie, listTaskDecisions as T, readApprovalInstance as ae, readAttachmentDownloadUrl as oe, readAttachmentPreviewUrl as se, readInstanceSignatures as ce, resolveMemberProfiles as le, resubmitApprovalInstance as ue, searchMembers as de, uploadAttachment as fe } from "@rytass/bpm-core-client/workflow";
10
+ import pe from "@mezzanine-ui/react/ContentHeader";
11
+ import { CheckedIcon as me, ChevronLeftIcon as E, ChevronRightIcon as he, DangerousOutlineIcon as ge, DownloadIcon as D, FileSearchIcon as _e, RefreshCcwIcon as ve, ShareIcon as ye, UserIcon as be, ZoomInIcon as xe, ZoomOutIcon as Se } from "@mezzanine-ui/icons";
12
+ import { focusFormRendererField as O, validateFormRendererValues as k } from "@rytass/bpm-core-client/form";
13
+ import { Background as A, Controls as Ce, Handle as j, Position as M, ReactFlow as we } from "@xyflow/react";
14
+ import * as N from "dagre";
15
+ import { Document as Te, Page as P } from "react-pdf";
16
+ import { stepClasses as F } from "@mezzanine-ui/core/stepper";
17
+ import '../detail.css';var I = {
18
+ root: "bpm_root_ehm7w",
19
+ toolbar: "bpm_toolbar_R-tis",
20
+ pageControls: "bpm_pageControls_jM-rC",
21
+ zoomControls: "bpm_zoomControls_7RAbJ",
22
+ counter: "bpm_counter_ILUsD",
23
+ viewport: "bpm_viewport_DQXms",
24
+ page: "bpm_page_Cv5Rg",
25
+ state: "bpm_state_bpgp3"
26
+ }, L = 760, Ee = 920, R = 320, De = 32, z = .75, Oe = 1.75, ke = .25;
27
+ function Ae({ filename: e, fileUrl: t, onDownload: n }) {
28
+ let r = u(null), [i, a] = d(null), [c, f] = d(1), [m, h] = d(1), [g, ee] = d(L);
29
+ s(() => {
30
+ let e = r.current;
31
+ if (!e || typeof ResizeObserver > "u") return;
32
+ let t = new ResizeObserver((e) => {
33
+ let t = e[0]?.contentRect.width;
34
+ t && ee(t);
35
+ });
36
+ return t.observe(e), () => t.disconnect();
37
+ }, []), s(() => {
38
+ a(null), f(1), h(1);
39
+ }, [t]);
40
+ let te = l(() => {
41
+ let e = Math.max(R, g - De);
42
+ return Math.round(Math.min(Ee, e) * m);
43
+ }, [m, g]), _ = o((e) => {
44
+ a(e.numPages), f(1);
45
+ }, []), ne = c > 1, re = i !== null && c < i, v = m > z, b = m < Oe, C = i === null ? `第 ${c} 頁` : `第 ${c} / ${i} 頁`, w = `${Math.round(m * 100)}%`;
46
+ return /* @__PURE__ */ S("section", {
47
+ "aria-label": `${e} PDF 預覽`,
48
+ className: I.root,
49
+ children: [/* @__PURE__ */ S("div", {
50
+ className: I.toolbar,
51
+ children: [
52
+ /* @__PURE__ */ S("div", {
53
+ className: I.pageControls,
54
+ "aria-label": "頁面切換",
55
+ children: [
56
+ /* @__PURE__ */ x(p, {
57
+ "aria-label": "上一頁",
58
+ disabled: !ne,
59
+ icon: E,
60
+ onClick: () => {
61
+ f((e) => Math.max(1, e - 1));
62
+ },
63
+ size: "minor",
64
+ variant: "base-secondary"
65
+ }),
66
+ /* @__PURE__ */ x(y, {
67
+ className: I.counter,
68
+ component: "span",
69
+ variant: "body",
70
+ children: C
71
+ }),
72
+ /* @__PURE__ */ x(p, {
73
+ "aria-label": "下一頁",
74
+ disabled: !re,
75
+ icon: he,
76
+ onClick: () => {
77
+ f((e) => i === null ? e : Math.min(i, e + 1));
78
+ },
79
+ size: "minor",
80
+ variant: "base-secondary"
81
+ })
82
+ ]
83
+ }),
84
+ /* @__PURE__ */ S("div", {
85
+ className: I.zoomControls,
86
+ "aria-label": "縮放",
87
+ children: [
88
+ /* @__PURE__ */ x(p, {
89
+ "aria-label": "縮小",
90
+ disabled: !v,
91
+ icon: Se,
92
+ onClick: () => {
93
+ h((e) => Math.max(z, e - ke));
94
+ },
95
+ size: "minor",
96
+ variant: "base-secondary"
97
+ }),
98
+ /* @__PURE__ */ x(y, {
99
+ className: I.counter,
100
+ component: "span",
101
+ variant: "body",
102
+ children: w
103
+ }),
104
+ /* @__PURE__ */ x(p, {
105
+ "aria-label": "放大",
106
+ disabled: !b,
107
+ icon: xe,
108
+ onClick: () => {
109
+ h((e) => Math.min(Oe, e + ke));
110
+ },
111
+ size: "minor",
112
+ variant: "base-secondary"
113
+ })
114
+ ]
115
+ }),
116
+ n ? /* @__PURE__ */ x(p, {
117
+ icon: D,
118
+ iconType: "leading",
119
+ onClick: n,
120
+ size: "minor",
121
+ variant: "base-primary",
122
+ children: "下載"
123
+ }) : null
124
+ ]
125
+ }), /* @__PURE__ */ x("div", {
126
+ className: I.viewport,
127
+ ref: r,
128
+ children: /* @__PURE__ */ x(Te, {
129
+ error: /* @__PURE__ */ x(B, { message: "PDF 無法載入。" }),
130
+ file: t,
131
+ loading: /* @__PURE__ */ x(B, { message: "正在載入 PDF..." }),
132
+ noData: /* @__PURE__ */ x(B, { message: "沒有可預覽的 PDF。" }),
133
+ onLoadSuccess: _,
134
+ children: /* @__PURE__ */ x(P, {
135
+ className: I.page,
136
+ loading: /* @__PURE__ */ x(B, { message: "正在載入頁面..." }),
137
+ pageNumber: c,
138
+ renderAnnotationLayer: !0,
139
+ renderTextLayer: !0,
140
+ width: te
141
+ })
142
+ })
143
+ })]
144
+ });
145
+ }
146
+ function B({ message: e }) {
147
+ return /* @__PURE__ */ x("div", {
148
+ className: I.state,
149
+ children: /* @__PURE__ */ x(y, {
150
+ color: "text-neutral",
151
+ variant: "body",
152
+ children: e
153
+ })
154
+ });
155
+ }
156
+ //#endregion
157
+ //#region src/views/instances/detail/sections/shared.ts
158
+ function je(e) {
159
+ let t = V(e, "from"), n = V(e, "to"), r = V(e, "reason");
160
+ return !t || !n || !r ? null : {
161
+ from: t,
162
+ reason: r,
163
+ ruleId: V(e, "ruleId"),
164
+ to: n
165
+ };
166
+ }
167
+ function Me(e) {
168
+ try {
169
+ let t = JSON.parse(e);
170
+ return Array.isArray(t) ? t.map((e) => Fe(e) ? je(e) : null).filter((e) => e !== null) : [];
171
+ } catch {
172
+ return [];
173
+ }
174
+ }
175
+ function V(e, t) {
176
+ let n = e[t];
177
+ return typeof n == "string" ? n : null;
178
+ }
179
+ function Ne(e, t) {
180
+ let n = e[t];
181
+ return Array.isArray(n) ? n.filter((e) => typeof e == "string") : [];
182
+ }
183
+ function Pe(e, t) {
184
+ let n = e[t];
185
+ return typeof n == "number" ? n : null;
186
+ }
187
+ function H(e) {
188
+ return typeof e == "string" && e.trim().length > 0;
189
+ }
190
+ function Fe(e) {
191
+ return typeof e == "object" && !!e;
192
+ }
193
+ function U(e) {
194
+ return e.status === "PENDING" || e.status === "IN_PROGRESS";
195
+ }
196
+ function W(e) {
197
+ return e instanceof Error ? e.message : "發生未知錯誤";
198
+ }
199
+ function Ie(e) {
200
+ return !Number.isFinite(e) || e <= 0 ? "-" : e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
201
+ }
202
+ function G(e) {
203
+ return e.length > 16 ? `${e.slice(0, 12)}...` : e;
204
+ }
205
+ function Le(e) {
206
+ return e === "APPROVED" ? "已同意" : e === "CANCELLED" ? "已取消" : e === "DRAFT" ? "草稿" : e === "EXPIRED" ? "已逾期" : e === "REJECTED" ? "已拒絕" : e === "RETURNED" ? "已退回" : e === "RUNNING" ? "進行中" : e;
207
+ }
208
+ function Re(e) {
209
+ return e === "PENDING" ? "待處理" : e === "IN_PROGRESS" ? "處理中" : e === "COMPLETED" ? "已完成" : e === "CANCELLED" ? "已取消" : e === "TRANSFERRED" ? "已轉派" : e;
210
+ }
211
+ function ze(e) {
212
+ return e === "APPROVED" ? "同意" : e === "REJECTED" ? "拒絕" : e === "RETURNED" ? "退回" : e === "TRANSFERRED" ? "轉派" : e;
213
+ }
214
+ function K(e) {
215
+ return e === "startEvent" ? "開始" : e === "endEvent" ? "完成" : e === "userTask" ? "簽核節點" : e === "serviceTask" ? "知會節點" : e === "exclusiveGateway" ? "條件分流" : "平行處理";
216
+ }
217
+ function q(e, t) {
218
+ return t?.nodes.find((t) => t.id === e)?.data.label ?? e;
219
+ }
220
+ function J(e, t) {
221
+ if (!e) return "-";
222
+ let n = t.get(e);
223
+ return n ? `${n.name}(${n.email})` : e;
224
+ }
225
+ function Be(e, t = /* @__PURE__ */ new Map()) {
226
+ let n = Me(e.delegationChainJson);
227
+ if (!e.assigneeMemberId) return e.candidateMemberIds.length ? `候選 ${e.candidateMemberIds.map((e) => J(e, t)).join("、")}` : "未指定";
228
+ let r = J(e.assigneeMemberId, t), i = J(e.originalAssigneeMemberId, t);
229
+ return n.length === 0 || e.originalAssigneeMemberId === e.assigneeMemberId ? r : `${r}(原:${i})`;
230
+ }
231
+ function Ve(e, t) {
232
+ return t ? e.assigneeMemberId === t || e.candidateMemberIds.includes(t) : !1;
233
+ }
234
+ function He(e, t) {
235
+ if (t.type !== "userTask" || !t.data.returnBehavior.allowReturn) return [];
236
+ if (t.data.returnBehavior.allowedTargets === "ANY") return e.nodes.filter((e) => e.id !== t.id).map((e) => ({
237
+ id: e.id,
238
+ name: `${e.data.label}(${K(e.type)})`
239
+ }));
240
+ let n = t.data.returnBehavior.allowedTargets === "INITIATOR" ? e.nodes.find((e) => e.type === "startEvent")?.id : e.edges.find((e) => e.target === t.id)?.source, r = e.nodes.find((e) => e.id === n);
241
+ return r ? [{
242
+ id: r.id,
243
+ name: `${r.data.label}(${K(r.type)})`
244
+ }] : [];
245
+ }
246
+ function Ue(e) {
247
+ return {
248
+ email: e.email,
249
+ id: e.memberId,
250
+ name: `${e.name} · ${e.email}`
251
+ };
252
+ }
253
+ function We(e) {
254
+ if (!Fe(e)) return null;
255
+ let t = e.email, n = e.id, r = e.name;
256
+ return typeof n == "string" && typeof r == "string" ? {
257
+ email: typeof t == "string" ? t : null,
258
+ id: n,
259
+ name: r
260
+ } : null;
261
+ }
262
+ function Ge(e, t) {
263
+ let n = e.trim().toLocaleLowerCase();
264
+ if (!n) return null;
265
+ let r = t.filter((e) => [
266
+ e.id,
267
+ e.name,
268
+ e.email ?? ""
269
+ ].some((e) => e.toLocaleLowerCase().includes(n)));
270
+ return r.length === 1 ? r[0] ?? null : null;
271
+ }
272
+ function Y(e) {
273
+ return H(e) ? {
274
+ text: e,
275
+ type: "text"
276
+ } : null;
277
+ }
278
+ function X(e) {
279
+ return H(e) ? {
280
+ text: e,
281
+ type: "dangerText"
282
+ } : null;
283
+ }
284
+ function Ke(e, t, n, r) {
285
+ let i = t ? n.get(t) : null;
286
+ return {
287
+ email: i?.email ?? null,
288
+ label: i?.name ?? r,
289
+ memberId: t,
290
+ prefix: e,
291
+ type: "member"
292
+ };
293
+ }
294
+ function Z(e) {
295
+ return !!e;
296
+ }
297
+ function qe(e) {
298
+ let t = e.findIndex((e) => e.id.startsWith("pending-task-") || e.id.startsWith("future-node-"));
299
+ return t === -1 ? e.length : t;
300
+ }
301
+ function Q(e) {
302
+ return e.eventType === "INSTANCE_STARTED" || e.eventType === "TASK_DECIDED" || e.eventType === "SLA_TRIGGERED";
303
+ }
304
+ function Je(e) {
305
+ return e === "APPROVED" ? "已同意" : e === "REJECTED" ? "已拒絕" : e === "RETURNED" ? "已退回" : e === "TRANSFERRED" ? "已轉派" : "簽核已決議";
306
+ }
307
+ function Ye(e, t) {
308
+ return e === "INSTANCE_STARTED" ? "案件已發起" : e === "TOKEN_CREATED" ? "流程路徑已建立" : e === "ENGINE_PROCESS_REQUESTED" ? "流程引擎已處理" : e === "TOKEN_ADVANCED" ? "流程已前進" : e === "TASK_CREATED" ? "待簽任務已建立" : e === "TASK_DECIDED" ? Je(V(t, "action")) : e === "SLA_TRIGGERED" ? "時限提醒已觸發" : e;
309
+ }
310
+ function Xe(e) {
311
+ try {
312
+ let t = JSON.parse(e.payloadJson);
313
+ return Fe(t) ? t : {};
314
+ } catch {
315
+ return {};
316
+ }
317
+ }
318
+ function Ze(e, t) {
319
+ return e.eventType === "SLA_TRIGGERED" || V(t, "action") === "REJECTED" || V(t, "instanceState") === "REJECTED";
320
+ }
321
+ function Qe(e) {
322
+ return t(e);
323
+ }
324
+ function $e(e, t, n, r) {
325
+ if (e.eventType === "TASK_CREATED") {
326
+ let e = V(t, "assigneeMemberId"), n = V(t, "originalAssigneeMemberId");
327
+ if (!e) {
328
+ let e = Ne(t, "candidateMemberIds");
329
+ return e.length ? `候選簽核人:${e.map((e) => J(e, r)).join("、")}` : null;
330
+ }
331
+ let i = J(e, r), a = J(n, r);
332
+ return n && n !== e ? `待簽人:${i}(原簽核人:${a})` : `待簽人:${i}`;
333
+ }
334
+ if (e.eventType === "TASK_DECIDED") {
335
+ let e = V(t, "action"), n = V(t, "comment"), i = e ? `決議:${ze(e)}` : null, a = V(t, "transferToMemberId");
336
+ return e === "REJECTED" && n ? [i, `拒絕原因:${n}`].filter(H).join(" · ") : e === "TRANSFERRED" ? [i, `轉派給:${J(a, r)}`].filter(H).join(" · ") : i;
337
+ }
338
+ if (e.eventType === "TOKEN_ADVANCED") {
339
+ let e = V(t, "action");
340
+ if (e) return `流程結果:${ze(e)}`;
341
+ let r = Pe(t, "arrivedCount"), i = Pe(t, "requiredCount");
342
+ if (r !== null && i !== null) return `等待匯合:${r}/${i}`;
343
+ let a = V(t, "fromNodeId"), o = V(t, "toNodeId");
344
+ if (a && o) return `由 ${q(a, n)} 前進至 ${q(o, n)}`;
345
+ }
346
+ if (e.eventType === "ENGINE_PROCESS_REQUESTED") {
347
+ let e = V(t, "state");
348
+ return e ? `案件狀態:${Le(e)}` : null;
349
+ }
350
+ return null;
351
+ }
352
+ function $(e, t, n, r, i, a, o) {
353
+ if (e.eventType !== "TASK_DECIDED") return [Y($e(e, t, n, o))].filter(Z);
354
+ let s = e.taskId ? r.get(e.taskId) : null, c = V(t, "action") ?? s?.action ?? null, l = V(t, "comment") ?? s?.comment ?? null, u = V(t, "transferToMemberId") ?? s?.transferToMemberId ?? null, d = V(t, "signatureId") ?? s?.signatureId ?? null, f = d ? i.get(d) : null;
355
+ return [
356
+ Y(c ? `決議:${ze(c)}` : null),
357
+ c === "REJECTED" ? X(`拒絕原因:${l ?? "-"}`) : null,
358
+ c === "RETURNED" ? Y(`退回說明:${l ?? "-"}`) : null,
359
+ c === "TRANSFERRED" ? Y(`轉派給:${J(u, o)}`) : null,
360
+ c === "TRANSFERRED" ? Y(`轉派說明:${l ?? "-"}`) : null,
361
+ f ? Y(a?.valid ? `簽章:已驗證(${G(f.signedPayloadHash)})` : `簽章:待檢查(${G(f.signedPayloadHash)})`) : null
362
+ ].filter(Z);
363
+ }
364
+ function et(e, t, n, r, i) {
365
+ if (e.type === "startEvent" || i.has(e.id)) return !1;
366
+ if (r === "REJECTED") return !0;
367
+ let a = lt(e, t, n, r);
368
+ return a.tone === "neutral" || a.tone === "waiting";
369
+ }
370
+ function tt(e, t, n, r, i) {
371
+ if (r !== "RUNNING" && r !== "REJECTED") return [];
372
+ let a = e.nodes.filter((e) => et(e, t, n, r, i)), o = nt(e, a, t, n, i), s = new Map(e.nodes.map((e, t) => [e.id, t]));
373
+ return a.filter((e) => o.has(e.id)).sort((e, t) => {
374
+ let n = o.get(e.id) ?? 0, r = o.get(t.id) ?? 0;
375
+ return n === r ? e.position.x === t.position.x ? e.position.y === t.position.y ? (s.get(e.id) ?? 0) - (s.get(t.id) ?? 0) : e.position.y - t.position.y : e.position.x - t.position.x : n - r;
376
+ });
377
+ }
378
+ function nt(e, t, n, r, i) {
379
+ let a = new Set(t.map((e) => e.id)), o = e.edges.reduce((e, t) => {
380
+ let n = [...e.get(t.source) ?? [], t.target];
381
+ return new Map(e).set(t.source, n);
382
+ }, /* @__PURE__ */ new Map());
383
+ return rt(e, n, r, i).reduce((e, t) => ot(e, it(t, o, a)), /* @__PURE__ */ new Map());
384
+ }
385
+ function rt(e, t, n, r) {
386
+ let i = n.filter((e) => e.status === "ACTIVE" || e.status === "WAITING").map((e) => e.currentNodeId), a = t.filter(U).map((e) => e.nodeId), o = e.nodes.filter((e) => r.has(e.id)).map((e) => e.id), s = [...new Set([
387
+ ...i,
388
+ ...a,
389
+ ...o
390
+ ])], c = e.nodes.filter((e) => e.type === "startEvent").map((e) => e.id);
391
+ return s.length > 0 ? s : c;
392
+ }
393
+ function it(e, t, n) {
394
+ return at([{
395
+ distance: 0,
396
+ nodeId: e
397
+ }], t, n);
398
+ }
399
+ function at(e, t, n, r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map()) {
400
+ let [a, ...o] = e;
401
+ if (!a) return i;
402
+ if (r.has(a.nodeId)) return at(o, t, n, r, i);
403
+ let s = new Set(r).add(a.nodeId), c = n.has(a.nodeId) ? new Map(i).set(a.nodeId, Math.min(i.get(a.nodeId) ?? a.distance, a.distance)) : i;
404
+ return at([...o, ...(t.get(a.nodeId) ?? []).map((e) => ({
405
+ distance: a.distance + 1,
406
+ nodeId: e
407
+ }))], t, n, s, c);
408
+ }
409
+ function ot(e, t) {
410
+ return [...t.entries()].reduce((e, [t, n]) => new Map(e).set(t, Math.min(e.get(t) ?? n, n)), e);
411
+ }
412
+ function st(e) {
413
+ return e.type === "userTask" ? `未來簽核:${e.data.label}` : e.type === "serviceTask" ? `未來知會:${e.data.label}` : e.type === "exclusiveGateway" ? `未來分流:${e.data.label}` : e.type === "parallelGateway" ? `未來匯合:${e.data.label}` : e.type === "endEvent" ? `流程完成:${e.data.label}` : `未來節點:${e.data.label}`;
414
+ }
415
+ function ct(e, t, n, r, i, a, o, s, c) {
416
+ let l = e.filter(Q).map((e) => {
417
+ let t = Xe(e), n = e.nodeId ? q(e.nodeId, r) : null;
418
+ return {
419
+ descriptionParts: [
420
+ Y(n ? `節點:${n}` : "節點:全流程"),
421
+ Ke("操作者", e.actorMemberId, a, "系統"),
422
+ Y(`時間:${Qe(e.createdAt)}`),
423
+ ...$(e, t, r, o, s, c, a)
424
+ ].filter(Z),
425
+ error: Ze(e, t),
426
+ id: e.id,
427
+ title: Ye(e.eventType, t)
428
+ };
429
+ }), u = t.filter(U).map((e) => ({
430
+ descriptionParts: [
431
+ Y(`節點:${q(e.nodeId, r)}`),
432
+ Ke("處理者", e.assigneeMemberId, a, "未指定"),
433
+ Y(`建立時間:${Qe(e.createdAt)}`)
434
+ ].filter(Z),
435
+ error: !1,
436
+ id: `pending-task-${e.id}`,
437
+ title: e.status === "IN_PROGRESS" ? "簽核處理中" : "等待簽核處理"
438
+ })), d = new Set([...e.filter(Q).map((e) => e.nodeId), ...t.map((e) => e.nodeId)].filter(H)), f = r ? tt(r, t, n, i, d).map((e) => ({
439
+ descriptionParts: [Y(`${K(e.type)} · 尚未抵達`)].filter(Z),
440
+ error: !1,
441
+ forcePending: !0,
442
+ id: `future-node-${e.id}`,
443
+ title: st(e)
444
+ })) : [];
445
+ return [
446
+ ...l,
447
+ ...u,
448
+ ...f
449
+ ];
450
+ }
451
+ function lt(e, t, n, r) {
452
+ let i = t.filter((t) => t.nodeId === e.id), a = i.find((e) => e.status === "PENDING" || e.status === "IN_PROGRESS"), o = i.find((e) => e.status === "CANCELLED"), s = i.find((e) => e.status === "COMPLETED"), c = n.filter((t) => t.currentNodeId === e.id), l = c.find((e) => e.status === "ACTIVE"), u = c.find((e) => e.status === "WAITING");
453
+ return a ? {
454
+ secondaryLabel: `處理者 ${Be(a)}`,
455
+ statusLabel: "待處理",
456
+ tone: "current"
457
+ } : o ? {
458
+ secondaryLabel: `已取消 ${Be(o)}`,
459
+ statusLabel: "已取消",
460
+ tone: "cancelled"
461
+ } : s ? {
462
+ secondaryLabel: `已完成 ${Be(s)}`,
463
+ statusLabel: "已完成",
464
+ tone: "completed"
465
+ } : l ? {
466
+ secondaryLabel: `token ${l.id}`,
467
+ statusLabel: "執行中",
468
+ tone: "current"
469
+ } : u ? {
470
+ secondaryLabel: `token ${u.id}`,
471
+ statusLabel: "等待前置",
472
+ tone: "waiting"
473
+ } : e.type === "startEvent" ? {
474
+ secondaryLabel: "流程已發起",
475
+ statusLabel: "已發起",
476
+ tone: "completed"
477
+ } : e.type === "endEvent" && r !== "RUNNING" ? {
478
+ secondaryLabel: r,
479
+ statusLabel: r === "REJECTED" ? "已拒絕" : "已完成",
480
+ tone: r === "REJECTED" ? "cancelled" : "completed"
481
+ } : {
482
+ secondaryLabel: K(e.type),
483
+ statusLabel: "未抵達",
484
+ tone: "neutral"
485
+ };
486
+ }
487
+ //#endregion
488
+ //#region src/views/instances/detail/sections/container-helpers.ts
489
+ async function ut({ activityLogs: e, tasks: t }) {
490
+ let n = [...new Set([
491
+ ...e.map((e) => e.actorMemberId),
492
+ ...t.map((e) => e.assigneeMemberId),
493
+ ...t.map((e) => e.originalAssigneeMemberId),
494
+ ...t.flatMap((e) => e.candidateMemberIds),
495
+ ...t.flatMap((e) => Me(e.delegationChainJson).flatMap((e) => [e.from, e.to]))
496
+ ].filter(H))];
497
+ try {
498
+ return await le(n);
499
+ } catch {
500
+ return [];
501
+ }
502
+ }
503
+ async function dt(e) {
504
+ return (await Promise.all(e.map((e) => T(e.id)))).flat();
505
+ }
506
+ function ft(e) {
507
+ return e.reduce((e, t) => {
508
+ let n = e.get(t.taskId), r = !n || new Date(t.decidedAt).getTime() > new Date(n.decidedAt).getTime() ? t : n;
509
+ return new Map(e).set(t.taskId, r);
510
+ }, /* @__PURE__ */ new Map());
511
+ }
512
+ //#endregion
513
+ //#region src/views/instances/detail/sections/InstanceFormSection.tsx
514
+ var pt = {
515
+ display: "grid",
516
+ gap: 16
517
+ }, mt = {
518
+ display: "flex",
519
+ flexWrap: "wrap",
520
+ gap: 8
521
+ };
522
+ function ht({ canResubmitInstance: e, deciding: t, error: n, instance: i, loading: a, onResubmitFormChange: o, onResubmitInstance: s, onUploadAttachment: c, resubmitFormData: l, resubmitFormErrors: u }) {
523
+ return /* @__PURE__ */ S("div", {
524
+ style: pt,
525
+ children: [
526
+ n ? /* @__PURE__ */ x(y, {
527
+ color: "text-error",
528
+ variant: "body",
529
+ children: n
530
+ }) : null,
531
+ a ? /* @__PURE__ */ x(y, {
532
+ color: "text-neutral",
533
+ variant: "body",
534
+ children: "載入中..."
535
+ }) : null,
536
+ i?.formDefinitionSnapshot.schema && i.formDefinitionSnapshot.uiSchema ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(r, {
537
+ errors: u,
538
+ onChange: (e) => {
539
+ o(e);
540
+ },
541
+ onUploadAttachment: e ? c : void 0,
542
+ readonly: !e,
543
+ schema: i.formDefinitionSnapshot.schema,
544
+ uiSchema: i.formDefinitionSnapshot.uiSchema,
545
+ value: e ? l : i.formData
546
+ }), e ? /* @__PURE__ */ x("div", {
547
+ style: mt,
548
+ children: /* @__PURE__ */ x(p, {
549
+ disabled: t,
550
+ icon: ve,
551
+ iconType: "leading",
552
+ onClick: s,
553
+ variant: "base-primary",
554
+ children: "重新送出"
555
+ })
556
+ }) : null] }) : /* @__PURE__ */ x(y, {
557
+ color: "text-neutral",
558
+ variant: "body",
559
+ children: "此案件沒有可顯示的表單快照。"
560
+ })
561
+ ]
562
+ });
563
+ }
564
+ //#endregion
565
+ //#region src/views/instances/detail/sections/InstanceAttachmentsSection.tsx
566
+ var gt = {
567
+ display: "grid",
568
+ gap: 16
569
+ };
570
+ function _t({ attachments: e, onDownload: n, onPreview: r }) {
571
+ let i = l(() => e.map((e) => ({
572
+ attachment: e,
573
+ createdAt: e.createdAt,
574
+ filename: e.filename,
575
+ id: e.id,
576
+ key: e.id,
577
+ mimeType: e.mimeType,
578
+ sizeLabel: Ie(Number(e.sizeBytes))
579
+ })), [e]), a = l(() => [
580
+ {
581
+ dataIndex: "filename",
582
+ key: "filename",
583
+ title: "檔名",
584
+ width: 260
585
+ },
586
+ {
587
+ dataIndex: "mimeType",
588
+ key: "mimeType",
589
+ title: "類型",
590
+ width: 180
591
+ },
592
+ {
593
+ dataIndex: "sizeLabel",
594
+ key: "sizeLabel",
595
+ title: "大小",
596
+ width: 120
597
+ },
598
+ {
599
+ key: "createdAt",
600
+ render: (e) => /* @__PURE__ */ x(y, {
601
+ component: "span",
602
+ variant: "body",
603
+ children: t(e.createdAt)
604
+ }),
605
+ title: "上傳時間",
606
+ width: 220
607
+ }
608
+ ], []), o = l(() => ({
609
+ render: (e) => [...e.mimeType === "application/pdf" ? [{
610
+ icon: _e,
611
+ iconType: "leading",
612
+ name: "預覽",
613
+ onClick: () => {
614
+ r(e.attachment);
615
+ }
616
+ }] : [], {
617
+ icon: D,
618
+ iconType: "leading",
619
+ name: "下載",
620
+ onClick: () => {
621
+ n(e.attachment);
622
+ }
623
+ }],
624
+ variant: "base-secondary",
625
+ width: 160
626
+ }), [n, r]);
627
+ return /* @__PURE__ */ S("div", {
628
+ style: gt,
629
+ children: [/* @__PURE__ */ x(y, {
630
+ component: "h2",
631
+ variant: "h3",
632
+ children: "附件"
633
+ }), i.length > 0 ? /* @__PURE__ */ x(ne, {
634
+ actions: o,
635
+ columns: a,
636
+ dataSource: i,
637
+ fullWidth: !0
638
+ }) : /* @__PURE__ */ x(y, {
639
+ color: "text-neutral",
640
+ variant: "body",
641
+ children: "此案件沒有附件。"
642
+ })]
643
+ });
644
+ }
645
+ //#endregion
646
+ //#region src/views/instances/detail/sections/InstanceTasksSection.tsx
647
+ var vt = {
648
+ display: "grid",
649
+ gap: 12,
650
+ width: "100%"
651
+ }, yt = {
652
+ minWidth: "100%",
653
+ width: "100%"
654
+ }, bt = {
655
+ display: "grid",
656
+ gap: 12,
657
+ width: "100%"
658
+ };
659
+ function xt(e) {
660
+ e && (e.style.width = "100%");
661
+ }
662
+ var St = a(function({ currentMemberId: e, instance: r, memberProfilesById: i, onChanged: a, tasks: o }, s) {
663
+ let [u, p] = d(!1), [h, g] = d(null), [ee, _] = d(""), [v, C] = d(null), [ie, T] = d(!1), [ae, oe] = d(""), [se, ce] = d(!1), [le, ue] = d(null), [fe, pe] = d(""), [me, E] = d(null), [he, ge] = d(!1), [D, _e] = d([]), [ve, ye] = d(!1), be = ee.trim(), xe = ae.trim(), Se = fe.trim(), O = l(() => o.find((t) => Ve(t, e) && (t.status === "PENDING" || t.status === "IN_PROGRESS")) ?? null, [e, o]), k = l(() => O && r ? r.workflowSnapshot.nodes.find((e) => e.id === O.nodeId) ?? null : null, [O, r]), A = l(() => k && r ? He(r.workflowSnapshot, k) : [], [k, r]), Ce = k?.type === "userTask" && k.data.returnBehavior.allowReturn, j = A.find((e) => e.id === le) ?? A[0] ?? null, M = l(() => o.map((e) => ({
664
+ ...e,
665
+ assigneeLabel: Be(e, i),
666
+ key: e.id,
667
+ nodeLabel: q(e.nodeId, r?.workflowSnapshot ?? null),
668
+ statusLabel: Re(e.status)
669
+ })), [
670
+ r,
671
+ i,
672
+ o
673
+ ]), we = l(() => [
674
+ {
675
+ dataIndex: "nodeLabel",
676
+ key: "nodeLabel",
677
+ title: "節點",
678
+ width: 180
679
+ },
680
+ {
681
+ key: "assigneeMemberId",
682
+ title: "處理者",
683
+ render: (e) => /* @__PURE__ */ x(y, {
684
+ component: "span",
685
+ variant: "body",
686
+ children: e.assigneeLabel
687
+ }),
688
+ width: 180
689
+ },
690
+ {
691
+ dataIndex: "statusLabel",
692
+ key: "statusLabel",
693
+ title: "狀態",
694
+ width: 120
695
+ },
696
+ {
697
+ key: "createdAt",
698
+ render: (e) => /* @__PURE__ */ x(y, {
699
+ component: "span",
700
+ variant: "body",
701
+ children: t(e.createdAt)
702
+ }),
703
+ title: "建立時間",
704
+ width: 220
705
+ }
706
+ ], []);
707
+ async function N({ action: t, comment: n, returnToNodeId: r = null, transferToMemberId: i = null }) {
708
+ if (!(!e || !O)) {
709
+ p(!0), g(null);
710
+ try {
711
+ await w({
712
+ action: t,
713
+ comment: n,
714
+ decidedByMemberId: e,
715
+ returnToNodeId: r,
716
+ taskId: O.id,
717
+ transferToMemberId: i
718
+ }), T(!1), ce(!1), ye(!1), _(""), oe(""), pe(""), E(null), ue(null), C(null), await a();
719
+ } catch (e) {
720
+ g(W(e));
721
+ } finally {
722
+ p(!1);
723
+ }
724
+ }
725
+ }
726
+ function Te() {
727
+ _(""), C(null), T(!0);
728
+ }
729
+ function P() {
730
+ u || (T(!1), _(""), C(null));
731
+ }
732
+ function F() {
733
+ oe(""), ue(A[0]?.id ?? null), ce(!0);
734
+ }
735
+ function I() {
736
+ u || (ce(!1), oe(""), ue(null));
737
+ }
738
+ function L() {
739
+ pe(""), E(null), ye(!0), R("");
740
+ }
741
+ function Ee() {
742
+ u || (ye(!1), pe(""), E(null));
743
+ }
744
+ async function R(t) {
745
+ ge(!0);
746
+ try {
747
+ _e((await de(t)).filter((t) => t.memberId !== e).map(Ue));
748
+ } catch (e) {
749
+ g(W(e));
750
+ } finally {
751
+ ge(!1);
752
+ }
753
+ }
754
+ async function De() {
755
+ if (!be) {
756
+ C("請輸入拒絕原因");
757
+ return;
758
+ }
759
+ await N({
760
+ action: "REJECTED",
761
+ comment: be
762
+ });
763
+ }
764
+ async function z() {
765
+ if (!me) {
766
+ g("請選擇轉派對象");
767
+ return;
768
+ }
769
+ await N({
770
+ action: "TRANSFERRED",
771
+ comment: Se || null,
772
+ transferToMemberId: me.id
773
+ });
774
+ }
775
+ async function Oe() {
776
+ await N({
777
+ action: "RETURNED",
778
+ comment: xe || null,
779
+ returnToNodeId: j?.id ?? null
780
+ });
781
+ }
782
+ return c(s, () => ({
783
+ canReturnCurrentTask: Ce,
784
+ deciding: u,
785
+ handleApprove: () => {
786
+ N({
787
+ action: "APPROVED",
788
+ comment: null
789
+ });
790
+ },
791
+ hasCurrentTask: O !== null,
792
+ openRejectModal: Te,
793
+ openReturnModal: F,
794
+ openTransferModal: L
795
+ }), [
796
+ Ce,
797
+ O,
798
+ u
799
+ ]), /* @__PURE__ */ S(b, { children: [
800
+ /* @__PURE__ */ x(y, {
801
+ component: "h2",
802
+ variant: "h3",
803
+ children: "任務"
804
+ }),
805
+ h ? /* @__PURE__ */ x(y, {
806
+ color: "text-error",
807
+ variant: "body",
808
+ children: h
809
+ }) : null,
810
+ /* @__PURE__ */ x(ne, {
811
+ columns: we,
812
+ dataSource: M,
813
+ fullWidth: !0
814
+ }),
815
+ /* @__PURE__ */ x(m, {
816
+ cancelText: "取消",
817
+ confirmButtonProps: {
818
+ disabled: !be,
819
+ variant: "destructive-primary"
820
+ },
821
+ confirmText: "送出拒絕",
822
+ loading: u,
823
+ modalStatusType: "error",
824
+ modalType: "standard",
825
+ onCancel: P,
826
+ onClose: P,
827
+ onConfirm: () => void De(),
828
+ open: ie,
829
+ showModalFooter: !0,
830
+ showModalHeader: !0,
831
+ size: "regular",
832
+ supportingText: "拒絕案件時必須留下原因,供發起人與後續追蹤查看。",
833
+ title: "拒絕原因",
834
+ children: /* @__PURE__ */ S("div", {
835
+ style: vt,
836
+ children: [/* @__PURE__ */ x(n, {
837
+ label: "拒絕原因",
838
+ name: "rejectReason",
839
+ required: !0,
840
+ children: /* @__PURE__ */ x(re, {
841
+ autoFocus: !0,
842
+ onChange: (e) => {
843
+ _(e.target.value), C(null);
844
+ },
845
+ placeholder: "請說明拒絕原因",
846
+ ref: xt,
847
+ resize: "vertical",
848
+ rows: 4,
849
+ style: yt,
850
+ type: v ? "error" : "default",
851
+ value: ee
852
+ })
853
+ }), v ? /* @__PURE__ */ x(y, {
854
+ color: "text-error",
855
+ variant: "body",
856
+ children: v
857
+ }) : null]
858
+ })
859
+ }),
860
+ /* @__PURE__ */ x(m, {
861
+ cancelText: "取消",
862
+ confirmButtonProps: { disabled: !me },
863
+ confirmText: "送出轉派",
864
+ loading: u,
865
+ modalType: "standard",
866
+ onCancel: Ee,
867
+ onClose: Ee,
868
+ onConfirm: () => void z(),
869
+ open: ve,
870
+ showModalFooter: !0,
871
+ showModalHeader: !0,
872
+ size: "regular",
873
+ supportingText: "轉派後,原任務會保留轉派紀錄,新的待簽任務會指派給指定成員。",
874
+ title: "轉派簽核",
875
+ children: /* @__PURE__ */ S("div", {
876
+ style: bt,
877
+ children: [/* @__PURE__ */ x(n, {
878
+ label: "轉派對象",
879
+ name: "transferToMemberId",
880
+ required: !0,
881
+ children: /* @__PURE__ */ x(f, {
882
+ asyncData: !0,
883
+ disabledOptionsFilter: !0,
884
+ emptyText: "沒有符合的成員",
885
+ inputProps: {
886
+ autoCapitalize: "none",
887
+ autoCorrect: "off",
888
+ name: "transfer-member-search",
889
+ spellCheck: !1
890
+ },
891
+ loading: he,
892
+ loadingText: "搜尋成員中...",
893
+ mode: "single",
894
+ onChange: (e) => E(We(e)),
895
+ onSearch: R,
896
+ onSearchTextChange: (e) => E(Ge(e, D)),
897
+ onVisibilityChange: (e) => {
898
+ e && R("");
899
+ },
900
+ options: [...D],
901
+ placeholder: "搜尋姓名或信箱",
902
+ searchDebounceTime: 300,
903
+ value: me
904
+ })
905
+ }), /* @__PURE__ */ x(n, {
906
+ label: "轉派說明",
907
+ name: "transferComment",
908
+ children: /* @__PURE__ */ x(re, {
909
+ onChange: (e) => pe(e.target.value),
910
+ placeholder: "可補充轉派原因",
911
+ ref: xt,
912
+ resize: "vertical",
913
+ rows: 4,
914
+ style: yt,
915
+ value: fe
916
+ })
917
+ })]
918
+ })
919
+ }),
920
+ /* @__PURE__ */ x(m, {
921
+ cancelText: "取消",
922
+ confirmButtonProps: { disabled: !j },
923
+ confirmText: "送出退回",
924
+ loading: u,
925
+ modalType: "standard",
926
+ onCancel: I,
927
+ onClose: I,
928
+ onConfirm: () => void Oe(),
929
+ open: se,
930
+ showModalFooter: !0,
931
+ showModalHeader: !0,
932
+ size: "regular",
933
+ supportingText: "退回後,流程會回到指定節點並等待重新處理。",
934
+ title: "退回簽核",
935
+ children: /* @__PURE__ */ S("div", {
936
+ style: bt,
937
+ children: [/* @__PURE__ */ x(n, {
938
+ label: "退回節點",
939
+ name: "returnTargetNodeId",
940
+ required: !0,
941
+ children: /* @__PURE__ */ x(te, {
942
+ clearable: !1,
943
+ fullWidth: !0,
944
+ onChange: (e) => ue(e?.id ?? null),
945
+ options: [...A],
946
+ placeholder: "選擇退回節點",
947
+ value: j
948
+ })
949
+ }), /* @__PURE__ */ x(n, {
950
+ label: "退回說明",
951
+ name: "returnComment",
952
+ children: /* @__PURE__ */ x(re, {
953
+ onChange: (e) => oe(e.target.value),
954
+ placeholder: "可補充需要修改的內容",
955
+ ref: xt,
956
+ resize: "vertical",
957
+ rows: 4,
958
+ style: yt,
959
+ value: ae
960
+ })
961
+ })]
962
+ })
963
+ })
964
+ ] });
965
+ }), Ct = {
966
+ display: "grid",
967
+ gap: 16
968
+ };
969
+ function wt({ signatureVerification: e, signatures: n }) {
970
+ let r = l(() => n.map((e) => ({
971
+ algorithm: e.algorithm,
972
+ hashLabel: G(e.signedPayloadHash),
973
+ key: e.id,
974
+ keyVersion: e.keyVersion,
975
+ signedAtLabel: t(e.signedAt),
976
+ signerMemberId: e.signerMemberId
977
+ })), [n]), i = l(() => [
978
+ {
979
+ dataIndex: "signerMemberId",
980
+ key: "signerMemberId",
981
+ title: "簽章者",
982
+ width: 160
983
+ },
984
+ {
985
+ dataIndex: "algorithm",
986
+ key: "algorithm",
987
+ title: "演算法",
988
+ width: 150
989
+ },
990
+ {
991
+ dataIndex: "keyVersion",
992
+ key: "keyVersion",
993
+ title: "Key 版本",
994
+ width: 100
995
+ },
996
+ {
997
+ dataIndex: "hashLabel",
998
+ key: "hashLabel",
999
+ title: "Payload Hash",
1000
+ width: 180
1001
+ },
1002
+ {
1003
+ dataIndex: "signedAtLabel",
1004
+ key: "signedAtLabel",
1005
+ title: "簽章時間",
1006
+ width: 220
1007
+ }
1008
+ ], []);
1009
+ return /* @__PURE__ */ S("div", {
1010
+ style: Ct,
1011
+ children: [
1012
+ /* @__PURE__ */ x(y, {
1013
+ component: "h2",
1014
+ variant: "h3",
1015
+ children: "簽章"
1016
+ }),
1017
+ /* @__PURE__ */ x(y, {
1018
+ color: e?.valid ? "text-success" : "text-error",
1019
+ variant: "body",
1020
+ children: e ? e.valid ? `簽章鏈已驗證,共 ${e.checkedCount} 筆。` : `簽章鏈驗證失敗:${e.errors.join("、")}` : "尚無簽章紀錄。"
1021
+ }),
1022
+ r.length > 0 ? /* @__PURE__ */ x(ne, {
1023
+ columns: i,
1024
+ dataSource: r,
1025
+ fullWidth: !0
1026
+ }) : null
1027
+ ]
1028
+ });
1029
+ }
1030
+ //#endregion
1031
+ //#region src/views/instances/detail/sections/InstanceHistorySection.tsx
1032
+ var Tt = {
1033
+ display: "grid",
1034
+ gap: 16
1035
+ }, Et = {
1036
+ cursor: "help",
1037
+ textDecoration: "underline dotted",
1038
+ textUnderlineOffset: 3
1039
+ }, Dt = { color: "var(--mzn-color-text-error)" };
1040
+ function Ot(...e) {
1041
+ return e.filter((e) => H(e ?? null)).join(" ");
1042
+ }
1043
+ var kt = a(function({ className: e, descriptionParts: t, error: n, forcePending: r = !1, index: a = 0, orientation: o, status: s = "pending", title: c, type: l = "number", ...u }, d) {
1044
+ let f = r ? "pending" : s;
1045
+ return /* @__PURE__ */ S("div", {
1046
+ ...u,
1047
+ className: Ot(F.host, l === "dot" ? F.dot : null, n && f !== "processing" ? F.error : null, o === "horizontal" ? F.horizontal : null, l === "number" ? F.number : null, f === "pending" ? F.pending : null, f === "processing" ? F.processing : null, n && f === "processing" ? F.processingError : null, !n && f === "succeeded" ? F.succeeded : null, o === "vertical" ? F.vertical : null, e),
1048
+ ref: d,
1049
+ children: [l === "dot" ? /* @__PURE__ */ x("span", { className: Ot(F.statusIndicator, F.statusIndicatorDot) }) : /* @__PURE__ */ x("span", {
1050
+ className: F.statusIndicator,
1051
+ children: a + 1
1052
+ }), /* @__PURE__ */ S("div", {
1053
+ className: F.textContainer,
1054
+ children: [/* @__PURE__ */ S(y, {
1055
+ className: F.title,
1056
+ variant: "label-primary-highlight",
1057
+ children: [c, /* @__PURE__ */ x("span", { className: F.titleConnectLine })]
1058
+ }), t.length > 0 ? /* @__PURE__ */ x(y, {
1059
+ className: F.description,
1060
+ variant: "caption",
1061
+ children: t.map((e, t) => /* @__PURE__ */ S(i, { children: [t > 0 ? " · " : null, At(e)] }, `${e.type}-${t}`))
1062
+ }) : null]
1063
+ })]
1064
+ });
1065
+ });
1066
+ function At(e) {
1067
+ return e.type === "text" ? e.text : e.type === "dangerText" ? /* @__PURE__ */ x("span", {
1068
+ style: Dt,
1069
+ children: e.text
1070
+ }) : e.email ? /* @__PURE__ */ S(b, { children: [
1071
+ e.prefix,
1072
+ ":",
1073
+ /* @__PURE__ */ x(v, {
1074
+ title: e.email,
1075
+ children: ({ onMouseEnter: t, onMouseLeave: n, ref: r }) => /* @__PURE__ */ x("span", {
1076
+ "data-testid": e.memberId ? `member-tooltip-${e.memberId}` : void 0,
1077
+ onMouseEnter: t,
1078
+ onMouseLeave: n,
1079
+ ref: r,
1080
+ style: Et,
1081
+ children: e.label
1082
+ })
1083
+ })
1084
+ ] }) : `${e.prefix}:${e.label}`;
1085
+ }
1086
+ function jt({ activityLogs: e, instanceState: t, memberProfilesById: n, signatureVerification: r, signaturesById: i, taskDecisionsByTaskId: a, tasks: o, workflowSnapshot: s, workflowTokens: c }) {
1087
+ let l = ct(e, o, c, s, t, n, a, i, r), u = qe(l), d = l.map((e) => ({
1088
+ ...e,
1089
+ descriptionParts: e.descriptionParts.filter(Z)
1090
+ }));
1091
+ return /* @__PURE__ */ S("div", {
1092
+ style: Tt,
1093
+ children: [/* @__PURE__ */ x(y, {
1094
+ component: "h2",
1095
+ variant: "h3",
1096
+ children: "歷程"
1097
+ }), d.length > 0 ? /* @__PURE__ */ x(_, {
1098
+ currentStep: u,
1099
+ orientation: "vertical",
1100
+ type: "dot",
1101
+ children: d.map((e) => /* @__PURE__ */ x(kt, {
1102
+ descriptionParts: e.descriptionParts,
1103
+ error: e.error,
1104
+ forcePending: e.forcePending,
1105
+ title: e.title
1106
+ }, e.id))
1107
+ }) : /* @__PURE__ */ x(y, {
1108
+ color: "text-neutral",
1109
+ variant: "body",
1110
+ children: "尚無歷程紀錄。"
1111
+ })]
1112
+ });
1113
+ }
1114
+ //#endregion
1115
+ //#region src/views/instances/detail/InstanceDetailView.tsx
1116
+ var Mt = 184, Nt = 96, Pt = {
1117
+ display: "grid",
1118
+ gap: 16
1119
+ }, Ft = {
1120
+ background: "#f8fafc",
1121
+ border: "1px solid #e2e8f0",
1122
+ borderRadius: 8,
1123
+ height: "min(64vh, 620px)",
1124
+ minHeight: 440,
1125
+ overflow: "hidden",
1126
+ width: "min(80vw, 1040px)"
1127
+ }, It = {
1128
+ background: "#ffffff",
1129
+ border: "1px solid #cbd5e1",
1130
+ borderRadius: 8,
1131
+ boxShadow: "0 8px 18px rgba(15, 23, 42, 0.08)",
1132
+ display: "grid",
1133
+ gap: 6,
1134
+ minHeight: 82,
1135
+ padding: 12,
1136
+ width: 184
1137
+ }, Lt = {
1138
+ borderRadius: 999,
1139
+ fontSize: 12,
1140
+ fontWeight: 600,
1141
+ justifySelf: "start",
1142
+ lineHeight: "18px",
1143
+ padding: "0 8px"
1144
+ }, Rt = {
1145
+ color: "#64748b",
1146
+ fontSize: 12,
1147
+ overflow: "hidden",
1148
+ textOverflow: "ellipsis",
1149
+ whiteSpace: "nowrap"
1150
+ }, zt = { opacity: 0 }, Bt = {
1151
+ display: "flex",
1152
+ flexWrap: "wrap",
1153
+ gap: 8
1154
+ }, Vt = {
1155
+ alignItems: "center",
1156
+ background: "#ffffff",
1157
+ border: "1px solid #cbd5e1",
1158
+ borderRadius: 8,
1159
+ color: "#334155",
1160
+ display: "inline-flex",
1161
+ fontSize: 12,
1162
+ fontWeight: 600,
1163
+ gap: 6,
1164
+ lineHeight: "20px",
1165
+ padding: "4px 8px"
1166
+ }, Ht = {
1167
+ display: "grid",
1168
+ gap: 16
1169
+ }, Ut = { workflowRuntime: $t };
1170
+ function Wt({ instanceId: r, showAttachments: i = !0, showForm: a = !0, showHistory: o = !0, showSignatures: c = !0, showTasks: f = !0 }) {
1171
+ let { member: te } = e(), _ = te?.memberId ?? null, [ne, v] = d([]), [w, T] = d(null), [le, de] = d([]), [E, he] = d([]), [D, _e] = d([]), [xe, Se] = d(null), [j, M] = d([]), [N, Te] = d([]), [P, F] = d([]), [I, L] = d(null), [Ee, R] = d(!0), [De, z] = d(!1), [Oe, ke] = d(!1), [B, je] = d(""), [Me, V] = d(!1), [Ne, Pe] = d({}), [H, Fe] = d({}), [U, Ie] = d(null), [G, Re] = d(null), ze = B.trim(), K = u(null);
1172
+ s(() => {
1173
+ Q();
1174
+ }, [_, r]), s(() => {
1175
+ Fe(w?.formData ?? {});
1176
+ }, [w]);
1177
+ let q = l(() => j.find((e) => Ve(e, _) && (e.status === "PENDING" || e.status === "IN_PROGRESS")) ?? null, [_, j]), J = l(() => q && w ? w.workflowSnapshot.nodes.find((e) => e.id === q.nodeId) ?? null : null, [q, w]), Be = J?.type === "userTask" && J.data.returnBehavior.allowReturn, He = !!(w && w.initiatorMemberId === _ && (w.state === "RUNNING" || w.state === "RETURNED")), Ue = !!(w && w.initiatorMemberId === _ && w.state === "RETURNED"), We = l(() => new Map(P.map((e) => [e.memberId, e])), [P]), Ge = l(() => ft(le), [le]), Y = l(() => new Map(D.map((e) => [e.id, e])), [D]), X = l(() => w ? Yt(w.workflowSnapshot) : null, [w]), Ke = l(() => w && X ? Jt(X, j, N, w.state) : [], [
1178
+ w,
1179
+ X,
1180
+ j,
1181
+ N
1182
+ ]), Z = l(() => X ? Xt(X) : [], [X]), qe = l(() => w ? Kt(w.workflowSnapshot) : [], [w]);
1183
+ async function Q() {
1184
+ R(!0), L(null);
1185
+ try {
1186
+ let e = await ae(r);
1187
+ v(e.activityLogs), T(e.instance), M(e.tasks), Te(e.workflowTokens);
1188
+ let [t, n, i, a] = await Promise.all([
1189
+ dt(e.tasks),
1190
+ ut(e),
1191
+ ie(e.instance.id),
1192
+ ce(e.instance.id)
1193
+ ]);
1194
+ de(t), F(n), he(i), _e(a.signatures), Se(a.verification);
1195
+ } catch (e) {
1196
+ L(W(e));
1197
+ } finally {
1198
+ R(!1);
1199
+ }
1200
+ }
1201
+ async function Je(e, t) {
1202
+ if (!_) throw Error("尚未登入,無法上傳附件");
1203
+ return { id: (await fe({
1204
+ file: t,
1205
+ formFieldPath: `form.${e.fieldKey}`
1206
+ })).id };
1207
+ }
1208
+ async function Ye(e) {
1209
+ if (!_) return;
1210
+ let t = await oe({ id: e.id });
1211
+ window.open(t, "_blank", "noopener,noreferrer");
1212
+ }
1213
+ async function Xe(e) {
1214
+ if (!_) return;
1215
+ let t = await se({ id: e.id });
1216
+ Ie(e), Re(t);
1217
+ }
1218
+ async function Ze() {
1219
+ if (!(!_ || !w || !He)) {
1220
+ if (z(!0), L(null), Pe({}), w.formDefinitionSnapshot.schema && w.formDefinitionSnapshot.uiSchema) {
1221
+ let e = k({
1222
+ schema: w.formDefinitionSnapshot.schema,
1223
+ uiSchema: w.formDefinitionSnapshot.uiSchema,
1224
+ values: H
1225
+ });
1226
+ if (!e.valid) {
1227
+ Pe(e.errors), L("請先補齊必填欄位。"), e.firstInvalidFieldKey && O(e.firstInvalidFieldKey), z(!1);
1228
+ return;
1229
+ }
1230
+ }
1231
+ try {
1232
+ await C({
1233
+ cancelledByMemberId: _,
1234
+ comment: ze || null,
1235
+ instanceId: w.id
1236
+ }), je(""), V(!1), await Q();
1237
+ } catch (e) {
1238
+ L(W(e));
1239
+ } finally {
1240
+ z(!1);
1241
+ }
1242
+ }
1243
+ }
1244
+ async function Qe() {
1245
+ if (!(!_ || !w || !Ue)) {
1246
+ z(!0), L(null);
1247
+ try {
1248
+ await ue({
1249
+ formData: H,
1250
+ initiatorMemberId: _,
1251
+ instanceId: w.id,
1252
+ title: w.title
1253
+ }), await Q();
1254
+ } catch (e) {
1255
+ L(W(e));
1256
+ } finally {
1257
+ z(!1);
1258
+ }
1259
+ }
1260
+ }
1261
+ let $e = K.current?.deciding ?? !1, $ = De || $e;
1262
+ return /* @__PURE__ */ S(b, { children: [
1263
+ /* @__PURE__ */ x(h, { children: /* @__PURE__ */ S(pe, {
1264
+ description: w ? `${Le(w.state)} · ${t(w.startedAt)}` : "載入案件內容。",
1265
+ title: w?.title ?? "簽核案件",
1266
+ children: [
1267
+ w ? /* @__PURE__ */ x(p, {
1268
+ "aria-label": "查看流程圖",
1269
+ icon: ye,
1270
+ iconType: "icon-only",
1271
+ onClick: () => ke(!0),
1272
+ title: "查看流程圖",
1273
+ variant: "base-secondary",
1274
+ children: "流程圖"
1275
+ }) : null,
1276
+ He ? /* @__PURE__ */ x(p, {
1277
+ disabled: $,
1278
+ icon: ge,
1279
+ iconType: "leading",
1280
+ onClick: () => V(!0),
1281
+ variant: "destructive-secondary",
1282
+ children: "取消案件"
1283
+ }) : null,
1284
+ q ? /* @__PURE__ */ S(b, { children: [
1285
+ Be ? /* @__PURE__ */ x(p, {
1286
+ disabled: $,
1287
+ icon: ve,
1288
+ iconType: "leading",
1289
+ onClick: () => K.current?.openReturnModal(),
1290
+ variant: "base-secondary",
1291
+ children: "退回"
1292
+ }) : null,
1293
+ /* @__PURE__ */ x(p, {
1294
+ disabled: $,
1295
+ icon: be,
1296
+ iconType: "leading",
1297
+ onClick: () => K.current?.openTransferModal(),
1298
+ variant: "base-secondary",
1299
+ children: "轉派"
1300
+ }),
1301
+ /* @__PURE__ */ x(p, {
1302
+ disabled: $,
1303
+ icon: ge,
1304
+ iconType: "leading",
1305
+ onClick: () => K.current?.openRejectModal(),
1306
+ variant: "destructive-secondary",
1307
+ children: "拒絕"
1308
+ }),
1309
+ /* @__PURE__ */ x(p, {
1310
+ disabled: $,
1311
+ icon: me,
1312
+ iconType: "leading",
1313
+ onClick: () => K.current?.handleApprove(),
1314
+ variant: "base-primary",
1315
+ children: "同意"
1316
+ })
1317
+ ] }) : null
1318
+ ]
1319
+ }) }),
1320
+ /* @__PURE__ */ S(ee, { children: [
1321
+ a ? /* @__PURE__ */ x(g, { children: /* @__PURE__ */ x(ht, {
1322
+ canResubmitInstance: Ue,
1323
+ deciding: De,
1324
+ error: I,
1325
+ instance: w,
1326
+ loading: Ee,
1327
+ onResubmitFormChange: (e) => {
1328
+ Fe(e), Pe({});
1329
+ },
1330
+ onResubmitInstance: () => void Qe(),
1331
+ onUploadAttachment: Je,
1332
+ resubmitFormData: H,
1333
+ resubmitFormErrors: Ne
1334
+ }) }) : null,
1335
+ i ? /* @__PURE__ */ x(g, { children: /* @__PURE__ */ x(_t, {
1336
+ attachments: E,
1337
+ onDownload: (e) => {
1338
+ Ye(e);
1339
+ },
1340
+ onPreview: (e) => {
1341
+ Xe(e);
1342
+ }
1343
+ }) }) : null,
1344
+ f ? /* @__PURE__ */ x(g, { children: /* @__PURE__ */ x(St, {
1345
+ currentMemberId: _,
1346
+ instance: w,
1347
+ memberProfilesById: We,
1348
+ onChanged: Q,
1349
+ ref: K,
1350
+ tasks: j
1351
+ }) }) : null,
1352
+ c ? /* @__PURE__ */ x(g, { children: /* @__PURE__ */ x(wt, {
1353
+ signatureVerification: xe,
1354
+ signatures: D
1355
+ }) }) : null,
1356
+ o ? /* @__PURE__ */ x(g, { children: /* @__PURE__ */ x(jt, {
1357
+ activityLogs: ne,
1358
+ instanceState: w?.state ?? "RUNNING",
1359
+ memberProfilesById: We,
1360
+ signatureVerification: xe,
1361
+ signaturesById: Y,
1362
+ taskDecisionsByTaskId: Ge,
1363
+ tasks: j,
1364
+ workflowSnapshot: w?.workflowSnapshot ?? null,
1365
+ workflowTokens: N
1366
+ }) }) : null
1367
+ ] }),
1368
+ w ? /* @__PURE__ */ x(m, {
1369
+ modalType: "standard",
1370
+ onClose: () => ke(!1),
1371
+ open: Oe,
1372
+ showModalHeader: !0,
1373
+ size: "wide",
1374
+ supportingText: `${Le(w.state)} · ${t(w.startedAt)}`,
1375
+ title: "流程圖",
1376
+ children: /* @__PURE__ */ S("div", {
1377
+ style: Pt,
1378
+ children: [/* @__PURE__ */ x("div", {
1379
+ style: Ft,
1380
+ children: /* @__PURE__ */ S(we, {
1381
+ edges: Z,
1382
+ fitView: !0,
1383
+ fitViewOptions: { padding: .18 },
1384
+ maxZoom: 1.2,
1385
+ minZoom: .2,
1386
+ nodes: Ke,
1387
+ nodesDraggable: !1,
1388
+ nodesFocusable: !1,
1389
+ nodeTypes: Ut,
1390
+ panOnDrag: !0,
1391
+ proOptions: { hideAttribution: !0 },
1392
+ children: [/* @__PURE__ */ x(A, {}), /* @__PURE__ */ x(Ce, { showInteractive: !1 })]
1393
+ })
1394
+ }), qe.length > 0 ? /* @__PURE__ */ x("div", {
1395
+ style: Bt,
1396
+ children: qe.map((e) => /* @__PURE__ */ x("span", {
1397
+ style: Vt,
1398
+ children: e
1399
+ }, e))
1400
+ }) : null]
1401
+ })
1402
+ }) : null,
1403
+ /* @__PURE__ */ x(m, {
1404
+ modalType: "standard",
1405
+ onClose: () => {
1406
+ Ie(null), Re(null);
1407
+ },
1408
+ open: !!(U && G),
1409
+ showModalHeader: !0,
1410
+ size: "wide",
1411
+ supportingText: U?.filename ?? void 0,
1412
+ title: "PDF 預覽",
1413
+ children: G ? /* @__PURE__ */ x(Ae, {
1414
+ filename: U?.filename ?? "PDF 預覽",
1415
+ fileUrl: G,
1416
+ onDownload: U ? () => void Ye(U) : void 0
1417
+ }) : null
1418
+ }),
1419
+ /* @__PURE__ */ x(m, {
1420
+ cancelText: "保留案件",
1421
+ confirmButtonProps: { variant: "destructive-primary" },
1422
+ confirmText: "確認取消",
1423
+ loading: De,
1424
+ modalStatusType: "error",
1425
+ modalType: "standard",
1426
+ onCancel: () => V(!1),
1427
+ onClose: () => V(!1),
1428
+ onConfirm: () => void Ze(),
1429
+ open: Me,
1430
+ showModalFooter: !0,
1431
+ showModalHeader: !0,
1432
+ supportingText: "取消後會關閉目前待簽任務與候選簽核人。",
1433
+ title: "取消案件",
1434
+ children: /* @__PURE__ */ S("div", {
1435
+ style: Ht,
1436
+ children: [/* @__PURE__ */ S(y, {
1437
+ variant: "body",
1438
+ children: [
1439
+ "確定要取消「",
1440
+ w?.title ?? "",
1441
+ "」嗎?"
1442
+ ]
1443
+ }), /* @__PURE__ */ x(n, {
1444
+ label: "取消原因",
1445
+ name: "cancelComment",
1446
+ children: /* @__PURE__ */ x(re, {
1447
+ onChange: (e) => je(e.target.value),
1448
+ placeholder: "可填寫取消原因",
1449
+ resize: "vertical",
1450
+ rows: 3,
1451
+ value: B
1452
+ })
1453
+ })]
1454
+ })
1455
+ })
1456
+ ] });
1457
+ }
1458
+ function Gt(e) {
1459
+ return e.data.label ? e.data.label : e.data.isDefault ? "其他情況" : e.data.condition ?? "";
1460
+ }
1461
+ function Kt(e) {
1462
+ return e.edges.map(Gt).filter((e) => e.trim().length > 0);
1463
+ }
1464
+ function qt(e) {
1465
+ return e === "startEvent" ? "開始" : e === "endEvent" ? "完成" : e === "userTask" ? "簽核節點" : e === "serviceTask" ? "知會節點" : e === "exclusiveGateway" ? "條件分流" : "平行處理";
1466
+ }
1467
+ function Jt(e, t, n, r) {
1468
+ return e.nodes.map((e) => {
1469
+ let i = lt(e, t, n, r);
1470
+ return {
1471
+ data: {
1472
+ kindLabel: qt(e.type),
1473
+ label: e.data.label,
1474
+ secondaryLabel: i.secondaryLabel,
1475
+ statusLabel: i.statusLabel,
1476
+ tone: i.tone
1477
+ },
1478
+ id: e.id,
1479
+ position: e.position,
1480
+ sourcePosition: M.Right,
1481
+ targetPosition: M.Left,
1482
+ type: "workflowRuntime"
1483
+ };
1484
+ });
1485
+ }
1486
+ function Yt(e) {
1487
+ let t = new N.graphlib.Graph();
1488
+ return t.setDefaultEdgeLabel(() => ({})), t.setGraph({
1489
+ nodesep: 56,
1490
+ rankdir: "LR",
1491
+ ranksep: 120
1492
+ }), e.nodes.forEach((e) => {
1493
+ t.setNode(e.id, {
1494
+ height: Nt,
1495
+ width: Mt
1496
+ });
1497
+ }), e.edges.forEach((e) => {
1498
+ t.setEdge(e.source, e.target);
1499
+ }), N.layout(t), {
1500
+ ...e,
1501
+ nodes: e.nodes.map((e) => {
1502
+ let n = t.node(e.id);
1503
+ return n ? {
1504
+ ...e,
1505
+ position: {
1506
+ x: n.x - Mt / 2,
1507
+ y: n.y - Nt / 2
1508
+ }
1509
+ } : e;
1510
+ })
1511
+ };
1512
+ }
1513
+ function Xt(e) {
1514
+ return e.edges.map((e) => {
1515
+ let t = Gt(e);
1516
+ return {
1517
+ animated: !1,
1518
+ id: e.id,
1519
+ label: t,
1520
+ labelBgBorderRadius: 6,
1521
+ labelBgPadding: [8, 4],
1522
+ labelBgStyle: {
1523
+ fill: e.data.isDefault ? "#f8fafc" : "#eff6ff",
1524
+ stroke: e.data.isDefault ? "#64748b" : "#2563eb",
1525
+ strokeWidth: 1
1526
+ },
1527
+ labelShowBg: !!t,
1528
+ labelStyle: {
1529
+ fill: e.data.isDefault ? "#475569" : "#2563eb",
1530
+ fontSize: 12,
1531
+ fontWeight: 600
1532
+ },
1533
+ source: e.source,
1534
+ style: {
1535
+ stroke: "#475569",
1536
+ strokeWidth: 1.5
1537
+ },
1538
+ target: e.target,
1539
+ type: e.type ?? "smoothstep"
1540
+ };
1541
+ });
1542
+ }
1543
+ function Zt(e) {
1544
+ return e === "current" ? {
1545
+ ...It,
1546
+ border: "1px solid var(--mzn-color-primary, #0057ff)",
1547
+ boxShadow: "0 0 0 3px rgba(0, 87, 255, 0.14)"
1548
+ } : e === "completed" ? {
1549
+ ...It,
1550
+ border: "1px solid #16a34a"
1551
+ } : e === "cancelled" ? {
1552
+ ...It,
1553
+ border: "1px solid #dc2626",
1554
+ opacity: .72
1555
+ } : e === "waiting" ? {
1556
+ ...It,
1557
+ border: "1px dashed #64748b"
1558
+ } : It;
1559
+ }
1560
+ function Qt(e) {
1561
+ let t = Lt;
1562
+ return e === "current" ? {
1563
+ ...t,
1564
+ background: "#eff6ff",
1565
+ color: "#2563eb"
1566
+ } : e === "completed" ? {
1567
+ ...t,
1568
+ background: "#f0fdf4",
1569
+ color: "#15803d"
1570
+ } : e === "cancelled" ? {
1571
+ ...t,
1572
+ background: "#fef2f2",
1573
+ color: "#dc2626"
1574
+ } : e === "waiting" ? {
1575
+ ...t,
1576
+ background: "#f8fafc",
1577
+ color: "#475569"
1578
+ } : {
1579
+ ...t,
1580
+ background: "#f1f5f9",
1581
+ color: "#64748b"
1582
+ };
1583
+ }
1584
+ function $t({ data: e }) {
1585
+ return /* @__PURE__ */ S("div", {
1586
+ style: Zt(e.tone),
1587
+ children: [
1588
+ /* @__PURE__ */ x(j, {
1589
+ isConnectable: !1,
1590
+ position: M.Left,
1591
+ style: zt,
1592
+ type: "target"
1593
+ }),
1594
+ /* @__PURE__ */ x(y, {
1595
+ component: "span",
1596
+ ellipsis: !0,
1597
+ title: e.label,
1598
+ variant: "label-primary",
1599
+ children: e.label
1600
+ }),
1601
+ /* @__PURE__ */ x("span", {
1602
+ style: Qt(e.tone),
1603
+ children: e.statusLabel
1604
+ }),
1605
+ /* @__PURE__ */ x("span", {
1606
+ title: e.secondaryLabel,
1607
+ style: Rt,
1608
+ children: e.secondaryLabel || e.kindLabel
1609
+ }),
1610
+ /* @__PURE__ */ x(j, {
1611
+ isConnectable: !1,
1612
+ position: M.Right,
1613
+ style: zt,
1614
+ type: "source"
1615
+ })
1616
+ ]
1617
+ });
1618
+ }
1619
+ //#endregion
1620
+ export { _t as a, St as i, jt as n, ht as o, wt as r, Wt as t };
1621
+
1622
+ //# sourceMappingURL=detail-Bml-vXHX.js.map