@objectstack/console 10.3.0 → 11.1.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.
- package/dist/assets/{AdapterProvider-BNg96rLB.js → AdapterProvider-BTAMdG2T.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-DX6zBTm5.js → AiPendingActionsPage-BtiQFQw8.js} +1 -1
- package/dist/assets/ApiConsolePage-CQJbzAsw.js +1 -0
- package/dist/assets/{AppDocsIndex-CFievvEN.js → AppDocsIndex-CbHC6KGX.js} +1 -1
- package/dist/assets/AppManagementPage-DOoQrTPO.js +1 -0
- package/dist/assets/ApprovalsInboxPage-D6eWYxCu.js +1 -0
- package/dist/assets/AuditLogPage-F85cQBBY.js +1 -0
- package/dist/assets/{ComponentNavView-BlIradDc.js → ComponentNavView-g9qw3mhW.js} +1 -1
- package/dist/assets/ConsoleFloatingChatbot-Cy-Ny_TS.js +1 -0
- package/dist/assets/DashboardView-mIWO-jW_.js +1 -0
- package/dist/assets/DashboardWidgetInspector-DOnyBhGN.js +1 -0
- package/dist/assets/{DeveloperHubPage-CQ2_nCOl.js → DeveloperHubPage-Ci0wA8GZ.js} +1 -1
- package/dist/assets/ExpressionProvider-NqLS0ljf.js +1 -0
- package/dist/assets/FlowRunsPage-CNz2_VFK.js +1 -0
- package/dist/assets/{IntegrationsPage-Ch5OmIKz.js → IntegrationsPage-CAZ3nsKJ.js} +2 -2
- package/dist/assets/{InterfaceListPage-B5-dEiYQ.js → InterfaceListPage-D1BbH0Iy.js} +1 -1
- package/dist/assets/{ManagedByBadge-DdytxDlp.js → ManagedByBadge-6DwSVsdr.js} +1 -1
- package/dist/assets/{MarketplaceAccessDenied-BRaR8_1a.js → MarketplaceAccessDenied-Cyx7lSjy.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-BtW9YVL_.js → MarketplaceInstalledPage-C41H1YlB.js} +1 -1
- package/dist/assets/MarketplacePackagePage-Bihb2q1b.js +4 -0
- package/dist/assets/MarketplacePage-C2B6TMNM.js +1 -0
- package/dist/assets/MetadataInspector-COEBMw6y.js +1 -0
- package/dist/assets/{MetadataProvider-QdHbK1P5.js → MetadataProvider-D234gTjV.js} +1 -1
- package/dist/assets/PageView-DuiaqvzN.js +1 -0
- package/dist/assets/ProfilePage-B1oCou0F.js +1 -0
- package/dist/assets/{PublicFormsPage-Dc2X36T6.js → PublicFormsPage-C2prdsH6.js} +1 -1
- package/dist/assets/RecordDetailView-B-AuOKPI.js +9 -0
- package/dist/assets/{RecordFormPage-Hs6Ml27g.js → RecordFormPage-CpKMoOCj.js} +1 -1
- package/dist/assets/ReportDefaultInspector-DxP-Ac7I.js +11 -0
- package/dist/assets/{ReportView-BM3Ai6gG.js → ReportView-Cw9Ompki.js} +1 -1
- package/dist/assets/{SearchResultsPage-CmNe7LEF.js → SearchResultsPage-CZ038ncU.js} +1 -1
- package/dist/assets/{SettingsHub-E8tuZ4eC.js → SettingsHub-BXe-fVlJ.js} +1 -1
- package/dist/assets/{SettingsView-Zy-v0lBl.js → SettingsView-DxPgTnlF.js} +1 -1
- package/dist/assets/{SystemHubPage-BAzCcy5f.js → SystemHubPage-CJq_1ITt.js} +1 -1
- package/dist/assets/{data-adapter-dGnCpoPP.js → data-adapter-02g96tfY.js} +1 -1
- package/dist/assets/exceljs.min-HZhgX9lC.js +28 -0
- package/dist/assets/framework-h98DIM1k.js +35 -0
- package/dist/assets/{highlighted-body-OFNGDK62-DQgrzYjA.js → highlighted-body-OFNGDK62-DO9p_wSr.js} +1 -1
- package/dist/assets/index-BQhiWf8_.js +2 -0
- package/dist/assets/index-WhD62Q-7.css +2 -0
- package/dist/assets/infrastructure-B1z73d-r.js +3 -0
- package/dist/assets/{marketplaceApi-BEwXWaVr.js → marketplaceApi-B_Gmytip.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-DEmtnxCC.js +1 -0
- package/dist/assets/metadata-admin-DStYGsRM.js +22 -0
- package/dist/assets/plugin-calendar-BYmYEyQk.js +1 -0
- package/dist/assets/plugin-charts-BDFf0TCn.js +7 -0
- package/dist/assets/plugin-chatbot-CnuZn8AC.js +120 -0
- package/dist/assets/plugin-dashboard-CuwYQhsg.js +6 -0
- package/dist/assets/plugin-form-CH8ruD9E.js +1 -0
- package/dist/assets/plugin-gantt-BB8ZeREv.js +93 -0
- package/dist/assets/plugin-grid-D414NLNP.js +6 -0
- package/dist/assets/plugin-kanban-BRFJEEAA.js +1 -0
- package/dist/assets/plugin-map-rEWoyyKa.js +1 -0
- package/dist/assets/{plugin-markdown-4BcL1bu0.js → plugin-markdown-BgV76qm3.js} +1 -1
- package/dist/assets/plugin-report-C-YPOtvZ.js +59 -0
- package/dist/assets/{plugin-timeline-C2lZtCO1.js → plugin-timeline-CC91-fmI.js} +1 -1
- package/dist/assets/plugin-tree-D2QWz1x1.js +1 -0
- package/dist/assets/plugin-view-C6iEzx93.js +1 -0
- package/dist/assets/plugins-views-CcoNygsH.js +4 -0
- package/dist/assets/recordFormNavigation-CXt3jCB4.js +1 -0
- package/dist/assets/{skeletons-B4Te484-.js → skeletons-BQ5aRDUn.js} +1 -1
- package/dist/assets/{src-Bw-Pk_Bz.js → src-C4OnKiir.js} +1 -1
- package/dist/assets/src-CKHT6scJ.js +2 -0
- package/dist/assets/types-BUZu4QOP.js +1 -0
- package/dist/assets/ui-components-C9egdVxV.js +42 -0
- package/dist/assets/ui-layout-BwokMuBv.js +1 -0
- package/dist/assets/useActionModal-ChUaxcEW.js +1 -0
- package/dist/assets/{useOpenRecordList-D2EZK86D.js → useOpenRecordList-BkSEs2q6.js} +1 -1
- package/dist/assets/{useReconcileOnError-CGxw9vPi.js → useReconcileOnError-FPUCNTHc.js} +1 -1
- package/dist/assets/utils-6HhVlFkm.js +1 -0
- package/dist/assets/vendor-objectstack-BTQLr7T3.js +96 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/LICENSE.apache +0 -202
- package/dist/assets/ApiConsolePage-BV6fdN_d.js +0 -1
- package/dist/assets/AppManagementPage-BwMda0Jw.js +0 -1
- package/dist/assets/ApprovalsInboxPage-CLB_n_w1.js +0 -1
- package/dist/assets/AuditLogPage-B5jAkCIM.js +0 -1
- package/dist/assets/ConsoleFloatingChatbot-Bn99Z39a.js +0 -1
- package/dist/assets/DashboardView-BQ1jDkNk.js +0 -1
- package/dist/assets/DashboardWidgetInspector-BR98NQH8.js +0 -1
- package/dist/assets/ExpressionProvider-Tm4jr_3p.js +0 -1
- package/dist/assets/FlowRunsPage-B179CDQR.js +0 -1
- package/dist/assets/MarketplacePackagePage-CHWrggYQ.js +0 -4
- package/dist/assets/MarketplacePage-D9egwY6W.js +0 -1
- package/dist/assets/MetadataInspector-Cx8ePTT_.js +0 -1
- package/dist/assets/PageView-Cz5sZQ5t.js +0 -1
- package/dist/assets/ProfilePage-COEmwLJ3.js +0 -1
- package/dist/assets/RecordDetailView-BgaxhKDF.js +0 -9
- package/dist/assets/ReportDefaultInspector-CoX9gMMh.js +0 -7
- package/dist/assets/framework-D5XqsLzE.js +0 -35
- package/dist/assets/index-DOshzaoZ.css +0 -2
- package/dist/assets/index-DnQZFTk9.js +0 -2
- package/dist/assets/infrastructure-HR_Bc4bJ.js +0 -3
- package/dist/assets/mermaid-GHXKKRXX-BhYOzfYs.js +0 -1
- package/dist/assets/metadata-admin-B-J5LjrF.js +0 -21
- package/dist/assets/plugin-calendar-BRaVMiNC.js +0 -1
- package/dist/assets/plugin-charts-lC1nlc8y.js +0 -7
- package/dist/assets/plugin-chatbot-DiZuqXNz.js +0 -120
- package/dist/assets/plugin-dashboard-Bru0NpLD.js +0 -6
- package/dist/assets/plugin-form-CnIr9O51.js +0 -1
- package/dist/assets/plugin-gantt-DjNJ3XF1.js +0 -93
- package/dist/assets/plugin-grid-CLR5UBO-.js +0 -6
- package/dist/assets/plugin-kanban-C_oukMvw.js +0 -1
- package/dist/assets/plugin-map-7UTNE-o1.js +0 -1
- package/dist/assets/plugin-report-DnFF3lpC.js +0 -59
- package/dist/assets/plugin-tree-Ch_JGKmm.js +0 -1
- package/dist/assets/plugin-view-XyXvMY2E.js +0 -1
- package/dist/assets/plugins-views-Ck67hsjt.js +0 -4
- package/dist/assets/src-DzwWvy9u.js +0 -2
- package/dist/assets/types-aLjHZGFr.js +0 -1
- package/dist/assets/ui-components-DiLX53DV.js +0 -42
- package/dist/assets/ui-layout-s7dWTKAK.js +0 -1
- package/dist/assets/useActionModal-DjfU9Nzh.js +0 -1
- package/dist/assets/utils-29quoGQV.js +0 -1
- package/dist/assets/vendor-objectstack-C1teU2a6.js +0 -96
package/dist/index.html
CHANGED
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
<script>
|
|
19
19
|
window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
|
|
20
20
|
</script>
|
|
21
|
-
<script type="module" crossorigin src="./assets/index-
|
|
21
|
+
<script type="module" crossorigin src="./assets/index-BQhiWf8_.js"></script>
|
|
22
22
|
<link rel="stylesheet" crossorigin href="./assets/ui-components-BL3SEdAz.css">
|
|
23
23
|
<link rel="stylesheet" crossorigin href="./assets/plugin-dashboard-DnNKJB60.css">
|
|
24
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
25
|
-
<link rel="modulepreload" href="./assets/framework-
|
|
26
|
-
<link rel="modulepreload" href="./assets/ui-components-
|
|
24
|
+
<link rel="stylesheet" crossorigin href="./assets/index-WhD62Q-7.css">
|
|
25
|
+
<link rel="modulepreload" href="./assets/framework-h98DIM1k.js" />
|
|
26
|
+
<link rel="modulepreload" href="./assets/ui-components-C9egdVxV.js" />
|
|
27
27
|
<link rel="modulepreload" href="./assets/vendor-radix-90T7eS-d.js" />
|
|
28
28
|
<link rel="modulepreload" href="./assets/vendor-react-ClIa1CJA.js" />
|
|
29
29
|
</head>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/console",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "Prebuilt Console SPA pinned to this @objectstack/framework release. Source of truth: @object-ui/console (https://github.com/objectstack-ai/objectui).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/objectstack-ai/framework/tree/main/packages/console",
|
package/LICENSE.apache
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute
|
|
108
|
-
must include a readable copy of the attribution notices
|
|
109
|
-
contained within such NOTICE file, excluding those notices
|
|
110
|
-
that do not pertain to any part of the Derivative Works,
|
|
111
|
-
in at least one of the following places: within a NOTICE
|
|
112
|
-
text file distributed as part of the Derivative Works; within
|
|
113
|
-
the Source form or documentation, if provided along with
|
|
114
|
-
the Derivative Works; or, within a display generated by the
|
|
115
|
-
Derivative Works, if and wherever such third-party notices
|
|
116
|
-
normally appear. The contents of the NOTICE file are for
|
|
117
|
-
informational purposes only and do not modify the License.
|
|
118
|
-
You may add Your own attribution notices within Derivative
|
|
119
|
-
Works that You distribute, alongside or as an addendum to
|
|
120
|
-
the NOTICE text from the Work, provided that such additional
|
|
121
|
-
attribution notices cannot be construed as modifying the
|
|
122
|
-
License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
-
|
|
181
|
-
To apply the Apache License to your work, attach the following
|
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
-
replaced with your own identifying information. (Don't include
|
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format. We also recommend that a
|
|
186
|
-
file or class name and description of purpose be included on the
|
|
187
|
-
same "printed page" as the copyright notice for easier
|
|
188
|
-
identification within third-party archives.
|
|
189
|
-
|
|
190
|
-
Copyright 2026 ObjectStack
|
|
191
|
-
|
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
you may not use this file except in compliance with the License.
|
|
194
|
-
You may obtain a copy of the License at
|
|
195
|
-
|
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
|
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
-
See the License for the specific language governing permissions and
|
|
202
|
-
limitations under the License.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{k as r}from"./framework-D5XqsLzE.js";import{As as i,Ci as a,Cr as o,Gn as s,Hr as c,Ii as l,Ki as u,Kn as d,Ms as f,Ns as p,Pa as m,Wi as h,Wn as g,cs as _,er as v,es as ee,uo as y}from"./ui-components-DiLX53DV.js";import"./src-DzwWvy9u.js";var b=e(t(),1),x=[`plugin`,`plugins`,`kind`,`package`];function S(e){return[{method:`POST`,path:`${e}/sign-in/email`,desc:`Sign in (email)`,group:`Auth`,bodyTemplate:{email:`user@example.com`,password:``}},{method:`POST`,path:`${e}/sign-up/email`,desc:`Sign up (email)`,group:`Auth`,bodyTemplate:{email:``,password:``,name:``}},{method:`POST`,path:`${e}/sign-out`,desc:`Sign out`,group:`Auth`},{method:`GET`,path:`${e}/get-session`,desc:`Get session`,group:`Auth`}]}var C={ai:{group:`AI`,defaultRoute:`/api/v1/ai`,endpoints:[{method:`POST`,path:`/chat`,desc:`Chat completion`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/chat/stream`,desc:`Streaming chat (SSE)`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/complete`,desc:`Text completion`,bodyTemplate:{prompt:``}},{method:`GET`,path:`/models`,desc:`List available models`},{method:`POST`,path:`/nlq`,desc:`Natural language query`,bodyTemplate:{query:``}},{method:`POST`,path:`/suggest`,desc:`AI-powered suggestions`,bodyTemplate:{object:``,field:``,context:{}}},{method:`POST`,path:`/insights`,desc:`AI-generated insights`,bodyTemplate:{object:``,recordIds:[]}},{method:`POST`,path:`/conversations`,desc:`Create conversation`,bodyTemplate:{}},{method:`GET`,path:`/conversations`,desc:`List conversations`},{method:`POST`,path:`/conversations/:id/messages`,desc:`Add message to conversation`,bodyTemplate:{role:`user`,content:``}},{method:`DELETE`,path:`/conversations/:id`,desc:`Delete conversation`}]},workflow:{group:`Workflow`,defaultRoute:`/api/v1/workflow`,endpoints:[{method:`GET`,path:`/:object/config`,desc:`Get workflow configuration`},{method:`GET`,path:`/:object/:recordId/state`,desc:`Get workflow state`},{method:`POST`,path:`/:object/:recordId/transition`,desc:`Execute workflow transition`,bodyTemplate:{targetState:``}},{method:`POST`,path:`/:object/:recordId/approve`,desc:`Approve workflow step`,bodyTemplate:{comment:``}},{method:`POST`,path:`/:object/:recordId/reject`,desc:`Reject workflow step`,bodyTemplate:{comment:``}}]},realtime:{group:`Realtime`,defaultRoute:`/api/v1/realtime`,endpoints:[{method:`POST`,path:`/connect`,desc:`Establish realtime connection`,bodyTemplate:{transport:`websocket`}},{method:`POST`,path:`/disconnect`,desc:`Close realtime connection`,bodyTemplate:{connectionId:``}},{method:`POST`,path:`/subscribe`,desc:`Subscribe to channel`,bodyTemplate:{channel:``}},{method:`POST`,path:`/unsubscribe`,desc:`Unsubscribe from channel`,bodyTemplate:{channel:``}},{method:`PUT`,path:`/presence/:channel`,desc:`Set presence state`,bodyTemplate:{status:`online`}},{method:`GET`,path:`/presence/:channel`,desc:`Get channel presence`}]},notification:{group:`Notifications`,defaultRoute:`/api/v1/notifications`,endpoints:[{method:`GET`,path:``,desc:`List notifications`},{method:`POST`,path:`/devices`,desc:`Register device for push`,bodyTemplate:{token:``,platform:`web`}},{method:`DELETE`,path:`/devices/:deviceId`,desc:`Unregister device`},{method:`GET`,path:`/preferences`,desc:`Get notification preferences`},{method:`PATCH`,path:`/preferences`,desc:`Update notification preferences`,bodyTemplate:{email:!0,push:!0}},{method:`POST`,path:`/read`,desc:`Mark notifications as read`,bodyTemplate:{ids:[]}},{method:`POST`,path:`/read/all`,desc:`Mark all as read`}]},analytics:{group:`Analytics`,defaultRoute:`/api/v1/analytics`,endpoints:[{method:`POST`,path:`/query`,desc:`Execute analytics query`,bodyTemplate:{measures:[],dimensions:[]}},{method:`GET`,path:`/meta`,desc:`Get analytics metadata`}]},automation:{group:`Automation`,defaultRoute:`/api/v1/automation`,endpoints:[{method:`POST`,path:`/trigger`,desc:`Trigger automation`,bodyTemplate:{name:``,params:{}}}]},i18n:{group:`i18n`,defaultRoute:`/api/v1/i18n`,endpoints:[{method:`GET`,path:`/locales`,desc:`Get available locales`},{method:`GET`,path:`/translations/:locale`,desc:`Get translations for locale`},{method:`GET`,path:`/labels/:object/:locale`,desc:`Get translated field labels`}]},ui:{group:`UI`,defaultRoute:`/api/v1/ui`,endpoints:[{method:`GET`,path:`/views`,desc:`List views`},{method:`GET`,path:`/views/:id`,desc:`Get view by ID`},{method:`POST`,path:`/views`,desc:`Create view`,bodyTemplate:{name:``,object:``,type:`list`}},{method:`PATCH`,path:`/views/:id`,desc:`Update view`,bodyTemplate:{name:``}},{method:`DELETE`,path:`/views/:id`,desc:`Delete view`}]},feed:{group:`Feed`,defaultRoute:`/api/v1/feed`,endpoints:[{method:`GET`,path:`/:object/:recordId`,desc:`Get feed items`},{method:`POST`,path:`/:object/:recordId`,desc:`Post feed item`,bodyTemplate:{body:``}}]},storage:{group:`Storage`,defaultRoute:`/api/v1/storage`,endpoints:[{method:`POST`,path:`/upload`,desc:`Upload file (multipart/form-data)`},{method:`GET`,path:`/:fileId`,desc:`Download file`},{method:`DELETE`,path:`/:fileId`,desc:`Delete file`}]}};function w(e,t){let n=C[e];return n?n.endpoints.map(e=>({method:e.method,path:`${t}${e.path}`,desc:e.desc,group:n.group,...e.bodyTemplate?{bodyTemplate:e.bodyTemplate}:{}})):[]}function te(){let e=r(),[t,n]=(0,b.useState)([]),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(null),u=(0,b.useCallback)(async()=>{s(!0),l(null);let t=`/api/v1`,r=`${t}/discovery`,i=[{method:`GET`,path:r,desc:`API Discovery`,group:`System`},{method:`GET`,path:`${t}/meta/types`,desc:`List metadata types`,group:`Metadata`},{method:`GET`,path:`${t}/packages`,desc:`List packages`,group:`System`},{method:`GET`,path:`/api/v1/health`,desc:`Health check`,group:`System`}];try{let o=`/api/v1/auth`,s={},c={};try{let e=await fetch(r);if(e.ok){let t=await e.json(),n=t?.data??t;c=n?.routes??{},s=n?.services??{},c.auth&&(o=c.auth)}}catch{}let l=[];for(let[e,t]of Object.entries(C)){let n=s[e],r=n?.enabled??!1,i=n?.handlerReady??(n?.status===`available`||n?.status===`degraded`),a=n?.route??c[e]??t.defaultRoute;r&&i&&l.push(...w(e,a))}let u=e?.getClient?.(),d=[];try{let e=await u?.meta?.getTypes?.();e&&Array.isArray(e.types)?d=e.types:Array.isArray(e)&&(d=e)}catch{}let f=[];try{let e=d.includes(`object`)?`object`:null;if(e&&u?.meta?.getItems){let t=await u.meta.getItems(e),n=[];Array.isArray(t)?n=t:t&&Array.isArray(t.items)?n=t.items:t&&Array.isArray(t.value)&&(n=t.value),f=n.map(e=>e.name||e.id).filter(Boolean)}}catch{}let p=f.flatMap(e=>{let n=e.startsWith(`sys_`)?`Data: system tables`:`Data: ${e}`;return[{method:`GET`,path:`${t}/data/${e}`,desc:`List ${e}`,group:n},{method:`POST`,path:`${t}/data/${e}`,desc:`Create ${e}`,group:n,bodyTemplate:{name:`example`}},{method:`GET`,path:`${t}/data/${e}/:id`,desc:`Get ${e} by ID`,group:n},{method:`PATCH`,path:`${t}/data/${e}/:id`,desc:`Update ${e}`,group:n,bodyTemplate:{name:`updated`}},{method:`DELETE`,path:`${t}/data/${e}/:id`,desc:`Delete ${e}`,group:n}]}),m=d.filter(e=>!x.includes(e)).map(e=>({method:`GET`,path:`${t}/meta/${e}`,desc:`List ${e} metadata`,group:`Metadata`})),h=f.map(e=>({method:`GET`,path:`${t}/meta/object/${e}`,desc:`${e} schema`,group:`Metadata`})),g=[...i,...S(o),...l,...m,...h,...p],_=new Map;for(let e of g){let t=_.get(e.group)||[];t.push(e),_.set(e.group,t)}let v=[`System`,`Auth`,`AI`,`Workflow`,`Realtime`,`Notifications`,`Analytics`,`Automation`,`i18n`,`UI`,`Feed`,`Storage`,`Metadata`];n(Array.from(_.entries()).sort(([e],[t])=>{let n=v.indexOf(e),r=v.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?e.localeCompare(t):1:-1}).map(([e,t])=>({key:e,label:e,endpoints:t}))),a(g)}catch(e){l(e.message||`Failed to discover APIs`)}finally{s(!1)}},[e]);return(0,b.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var T=n(),E={GET:`text-emerald-600 bg-emerald-50 border-emerald-200 dark:text-emerald-400 dark:bg-emerald-950/50`,POST:`text-blue-600 bg-blue-50 border-blue-200 dark:text-blue-400 dark:bg-blue-950/50`,PATCH:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,PUT:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,DELETE:`text-red-600 bg-red-50 border-red-200 dark:text-red-400 dark:bg-red-950/50`},ne={2:`text-emerald-600 dark:text-emerald-400`,3:`text-blue-600 dark:text-blue-400`,4:`text-amber-600 dark:text-amber-400`,5:`text-red-600 dark:text-red-400`},re=[{key:`$top`,placeholder:`10`,hint:`limit`},{key:`$skip`,placeholder:`0`,hint:`offset`},{key:`$sort`,placeholder:`name`,hint:`sort field`},{key:`$select`,placeholder:`name,email`,hint:`fields`},{key:`$count`,placeholder:`true`,hint:`total count`},{key:`$filter`,placeholder:`status eq 'active'`,hint:`OData filter`}],D=1;function O(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:x}=te(),[S,C]=(0,b.useState)(``),[w,O]=(0,b.useState)(new Set),[k,A]=(0,b.useState)(null),[ie,j]=(0,b.useState)(``),[ae,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)([]),[L,R]=(0,b.useState)(!1),[z,B]=(0,b.useState)(null),[V,H]=(0,b.useState)([]),[U,oe]=(0,b.useState)(null),[W,G]=(0,b.useState)(!1),K=(0,b.useMemo)(()=>{if(!S)return t;let e=S.toLowerCase();return t.map(t=>({...t,endpoints:t.endpoints.filter(t=>t.desc.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)||t.method.toLowerCase().includes(e))})).filter(e=>e.endpoints.length>0)},[t,S]),se=(0,b.useCallback)(e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,b.useCallback)(e=>{A(e),j(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ie||k?.method||`GET`,J=ae||k?.path||``,Y=(0,b.useMemo)(()=>{let e=F.filter(e=>e.enabled&&e.key.trim());return e.length===0?J:`${J}?${e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`)}`},[J,F]),X=(0,b.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:D++,key:e,value:t,enabled:!0}])},[]),le=(0,b.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,b.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,b.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,b.useCallback)(async()=>{if(L||!Y)return;let t=`${e?.baseUrl??``}${Y}`;R(!0);let n=performance.now();try{let e={method:q,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(q)&&N.trim()&&(e.body=N);let r=await fetch(t,e),i=Math.round(performance.now()-n),a;if((r.headers.get(`content-type`)??``).includes(`json`)){let e=await r.json();a=JSON.stringify(e,null,2)}else a=await r.text();B({status:r.status,body:a,duration:i}),H(e=>[{id:Date.now(),method:q,url:Y,body:N||void 0,status:r.status,duration:i,response:a,timestamp:new Date},...e].slice(0,50))}catch(e){let t=Math.round(performance.now()-n);B({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{R(!1)}},[e,Y,q,N,L]),de=(0,b.useCallback)(e=>{j(e.method);let[t,n]=e.url.split(`?`);if(M(t),P(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:D++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),A(null)},[]),fe=(0,b.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>ne[String(e)[0]]??`text-muted-foreground`;return(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,T.jsx)(`button`,{onClick:x,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,T.jsx)(l,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(a,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,T.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`Search endpoints...`,className:`w-full rounded-md border bg-background pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(m,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,T.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(y,{className:`h-6 w-6 opacity-30 mb-2`}),(0,T.jsx)(`span`,{children:S?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=w.has(e.key)||!!S;return(0,T.jsxs)(g,{open:t,onOpenChange:()=>se(e.key),children:[(0,T.jsx)(d,{asChild:!0,children:(0,T.jsxs)(`button`,{className:`w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors`,children:[(0,T.jsx)(i,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,T.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,T.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,T.jsx)(s,{children:(0,T.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,T.jsxs)(`button`,{onClick:()=>ce(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${k===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,T.jsx)(v,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,T.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,T.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(h,{className:`h-3 w-3`}),`Add`]})]}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:re.map(e=>(0,T.jsx)(`button`,{onClick:()=>X(e.key,``),className:`text-[10px] px-1.5 py-0.5 rounded border bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors font-mono`,title:e.hint,children:e.key},e.key))}),F.length>0&&(0,T.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,T.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Z(e.id,`key`,t.target.value),placeholder:`key`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,T.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>Z(e.id,`value`,t.target.value),placeholder:`value`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,T.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,T.jsx)(o,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`select`,{value:q,onChange:e=>j(e.target.value),className:`rounded-md border bg-background px-2 py-1.5 font-mono text-xs font-semibold focus:outline-none focus:ring-1 focus:ring-ring ${E[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,T.jsx)(`option`,{value:e,children:e},e))}),(0,T.jsx)(`input`,{type:`text`,value:J,onChange:e=>M(e.target.value),className:`flex-1 rounded-md border bg-background px-3 py-1.5 font-mono text-sm focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`/api/v1/...`,onKeyDown:e=>{e.key===`Enter`&&Q()}}),(0,T.jsxs)(`button`,{onClick:Q,disabled:L||!Y,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:[L?(0,T.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,T.jsx)(u,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,T.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,T.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),rows:5,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-ring resize-y`,placeholder:`{ "key": "value" }`})]}),L&&(0,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(m,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,T.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,T.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,T.jsx)(_,{className:`h-3 w-3`}),z.duration,`ms`]})]}),(0,T.jsxs)(`button`,{onClick:fe,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[W?(0,T.jsx)(p,{className:`h-3 w-3`}):(0,T.jsx)(ee,{className:`h-3 w-3`}),W?`Copied`:`Copy`]})]}),(0,T.jsx)(`pre`,{className:`flex-1 overflow-auto p-3 text-xs font-mono bg-muted/10 whitespace-pre-wrap break-all`,children:z.body})]}),!z&&!L&&(0,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,T.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,T.jsx)(y,{className:`h-10 w-10 mx-auto opacity-20`}),(0,T.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,T.jsx)(`strong`,{children:`Send`})]}),(0,T.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),V.length>0&&(0,T.jsxs)(`div`,{className:`border-t`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,T.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,V.length,`)`]}),(0,T.jsxs)(`button`,{onClick:()=>H([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(c,{className:`h-3 w-3`}),`Clear`]})]}),(0,T.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:V.map(e=>(0,T.jsxs)(`div`,{className:`rounded border`,children:[(0,T.jsxs)(`button`,{onClick:()=>oe(U===e.id?null:e.id),className:`w-full flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 transition-colors`,children:[U===e.id?(0,T.jsx)(f,{className:`h-3 w-3 shrink-0`}):(0,T.jsx)(i,{className:`h-3 w-3 shrink-0`}),(0,T.jsx)(v,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,T.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,T.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,T.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:`Replay request`,children:(0,T.jsx)(u,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,T.jsx)(`pre`,{className:`px-3 py-2 text-xs font-mono bg-muted/10 border-t overflow-auto max-h-40 whitespace-pre-wrap break-all`,children:e.response})]},e.id))})]})]})]})]})}export{O as ApiConsolePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{A as a}from"./framework-D5XqsLzE.js";import{Bo as o,Ci as s,Hr as c,Jn as l,Ua as u,Ur as d,Wi as f,Wr as p,Yn as m,Zi as h,er as g,gr as _,nn as v,qn as y,ri as b}from"./ui-components-DiLX53DV.js";import{r as x}from"./vendor-ui-utils-C92Fl7BT.js";import"./src-DzwWvy9u.js";var S=e(t(),1);function C(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}var w=r();function T(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,{apps:T,refresh:E}=a(),[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(new Set),[j,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(!1),F=(T||[]).filter(e=>{if(!D)return!0;let t=D.toLowerCase();return(e.name||``).toLowerCase().includes(t)||(e.label||``).toLowerCase().includes(t)||(e.description||``).toLowerCase().includes(t)}),I=(0,S.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),L=(0,S.useCallback)(()=>{k.size===F.length?A(new Set):A(new Set(F.map(e=>e.name)))},[k.size,F]),R=(0,S.useCallback)(async e=>{P(!0);try{let t=e.active===!1;x.success(`${e.label||e.name} ${t?`enabled`:`disabled`}`),await E()}catch{x.error(`Failed to toggle app status`)}finally{P(!1)}},[E]),z=(0,S.useCallback)(async e=>{P(!0);try{x.success(`${e.label||e.name} set as default`),await E()}catch{x.error(`Failed to set default app`)}finally{P(!1)}},[E]),B=(0,S.useCallback)(async e=>{if(j!==e.name){M(e.name);return}P(!0);try{x.success(`${e.label||e.name} deleted`),M(null),await E()}catch{x.error(`Failed to delete app`)}finally{P(!1)}},[j,E]),V=(0,S.useCallback)(async e=>{P(!0);try{x.success(`${k.size} apps ${e?`enabled`:`disabled`}`),A(new Set),await E()}catch{x.error(`Bulk operation failed`)}finally{P(!1)}},[k,E]);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Applications`}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage all configured applications`})]}),(0,w.jsxs)(_,{onClick:()=>e(`${r}/create-app`),"data-testid":`create-app-btn`,children:[(0,w.jsx)(f,{className:`h-4 w-4 mr-2`}),`New App`]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,w.jsx)(`label`,{htmlFor:`app-search`,className:`sr-only`,children:`Search apps`}),(0,w.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,w.jsx)(v,{id:`app-search`,placeholder:`Search apps...`,value:D,onChange:e=>O(e.target.value),className:`pl-8`,"data-testid":`app-search-input`})]}),k.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(g,{variant:`secondary`,children:[k.size,` selected`]}),(0,w.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>V(!0),disabled:N,children:`Enable`}),(0,w.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>V(!1),disabled:N,children:`Disable`})]})]}),F.length>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,w.jsx)(y,{id:`select-all-apps`,checked:k.size===F.length&&F.length>0,onCheckedChange:()=>L()}),(0,w.jsxs)(`label`,{htmlFor:`select-all-apps`,className:`cursor-pointer`,children:[`Select all (`,F.length,`)`]})]}),F.length===0?(0,w.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground`,"data-testid":`no-apps-message`,children:[(0,w.jsx)(u,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{children:`No apps found.`})]}):(0,w.jsx)(`div`,{className:`grid gap-3`,children:F.map(t=>{let n=t.active!==!1,i=t.isDefault===!0,a=j===t.name;return(0,w.jsx)(l,{className:n?``:`opacity-60`,"data-testid":`app-card-${t.name}`,children:(0,w.jsxs)(m,{className:`flex items-center gap-3 py-3 px-4`,children:[(0,w.jsx)(y,{id:`select-app-${t.name}`,checked:k.has(t.name),onCheckedChange:()=>I(t.name),"aria-label":`Select ${t.label||t.name}`,className:`shrink-0`}),(0,w.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,w.jsx)(u,{className:`h-4 w-4`})}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`font-medium truncate`,children:C(t.label)||t.name}),i&&(0,w.jsx)(g,{variant:`default`,className:`text-xs`,children:`Default`}),(0,w.jsx)(g,{variant:n?`secondary`:`outline`,className:`text-xs`,children:n?`Active`:`Inactive`})]}),t.description&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:C(t.description)})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,w.jsx)(_,{variant:`ghost`,size:`icon`,title:`Open app`,"aria-label":`Open ${t.label||t.name}`,onClick:()=>e(`/apps/${t._packageId??t.name}`),children:(0,w.jsx)(o,{className:`h-4 w-4`})}),(0,w.jsx)(_,{variant:`ghost`,size:`icon`,title:`Edit app`,"aria-label":`Edit ${t.label||t.name}`,onClick:()=>e(`${r}/edit-app/${t.name}`),children:(0,w.jsx)(h,{className:`h-4 w-4`})}),(0,w.jsx)(_,{variant:`ghost`,size:`icon`,title:n?`Disable app`:`Enable app`,"aria-label":n?`Disable ${t.label||t.name}`:`Enable ${t.label||t.name}`,onClick:()=>R(t),disabled:N,children:n?(0,w.jsx)(d,{className:`h-4 w-4`}):(0,w.jsx)(p,{className:`h-4 w-4`})}),(0,w.jsx)(_,{variant:`ghost`,size:`icon`,title:`Set as default`,"aria-label":`Set ${t.label||t.name} as default`,onClick:()=>z(t),disabled:N||i,children:(0,w.jsx)(b,{className:`h-4 w-4 ${i?`fill-current text-yellow-500`:``}`})}),(0,w.jsx)(_,{variant:`ghost`,size:`icon`,title:a?`Click again to confirm delete`:`Delete app`,"aria-label":a?`Confirm delete ${t.label||t.name}`:`Delete ${t.label||t.name}`,onClick:()=>B(t),disabled:N,className:a?`text-destructive`:``,children:(0,w.jsx)(c,{className:`h-4 w-4`})})]})]})},t.name)})})]})}export{T as AppManagementPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,r,t as i}from"./vendor-react-ClIa1CJA.js";import{d as a,f as ee}from"./infrastructure-HR_Bc4bJ.js";import{i as te}from"./framework-D5XqsLzE.js";import{As as ne,Bo as re,Bt as ie,Ci as ae,Cr as oe,Ft as se,H as ce,Ht as o,Ii as le,It as ue,Jn as de,Lr as fe,Lt as pe,Mr as me,Mt as s,Ns as he,Pt as ge,R as _e,Rt as ve,Si as ye,Ut as be,Vt as xe,Wt as Se,Yn as Ce,Zo as we,ar as Te,at as Ee,cr as c,cs as De,ct as l,dc as Oe,dr as u,dt as ke,er as Ae,es as je,fr as d,gr as f,gs as Me,hr as Ne,ir as Pe,it as Fe,js as Ie,li as Le,lr as p,lt as m,mr as h,nc as Re,nn as ze,nt as Be,on as Ve,ot as He,pr as g,ps as Ue,qn as We,rt as Ge,sr as _,st as Ke,tt as qe,ur as v,ut as Je,vc as y,ws as Ye,xs as Xe,z as Ze,zt as Qe}from"./ui-components-DiLX53DV.js";import{r as b}from"./vendor-ui-utils-C92Fl7BT.js";var x=e(t(),1),$e=`${``.replace(/\/$/,``)}/api/v1`;async function S(e,t){let n=await fetch(`${$e}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.code??`HTTP_${n.status}`,t=r?.message??r?.error??n.statusText,i=Error(`${e}: ${t}`);throw i.code=e,i.status=n.status,i.details=r,i}return r}var C={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return S(`/approvals/processes${n?`?${n}`:``}`)},listRequests(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.object&&t.set(`object`,e.object),e.recordId&&t.set(`recordId`,e.recordId);let n=Array.isArray(e.approverId)?e.approverId.filter(Boolean).join(`,`):e.approverId;n&&t.set(`approverId`,n),e.submitterId&&t.set(`submitterId`,e.submitterId),e.q?.trim()&&t.set(`q`,e.q.trim()),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let r=t.toString();return S(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await S(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return S(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/approve`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async reject(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/reject`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async recall(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/remind`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,notified:n.notified}},async requestInfo(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/revise`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,autoRejected:n.autoRejected===!0}},async resubmit(e,t={}){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/resubmit`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,resumed:n.resumed===!0}},async comment(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return S(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function et(e){if(!e)return[];let t=new Set;e.id&&t.add(e.id),e.email&&t.add(e.email);let n=[...e.roles||[],...typeof e.role==`string`?e.role.split(`,`):[]];for(let e of n){let n=String(e).trim();n&&t.add(`role:${n}`)}return Array.from(t)}var w=i(),tt=50,nt={pending:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400`,approved:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400`,rejected:`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`,recalled:`border-border bg-muted text-muted-foreground`,returned:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400`};function rt(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function T(e){return e?e.includes(`@`)?e:e.startsWith(`role:`)?`Role: ${e.slice(5)}`:e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e:`—`}function E(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function it(e){return e.process_label||E(e.process_name)}function at(e){return e.step_label?e.step_label:e.current_step?E(e.current_step):null}function ot(e){return e.submitter_name||T(e.submitter_id)}function st(e,t){return t.pending_approver_names?.[e]||T(e)}function ct(e){return e.object_label||e.object_name}function D(e){return e.submitted_at||e.created_at||void 0}function O(e){let t=D(e);if(!t)return null;let n=Date.parse(t);return Number.isNaN(n)?null:(Date.now()-n)/36e5}function lt(e){if(e.status!==`pending`)return`text-muted-foreground`;let t=O(e);return t==null?`text-muted-foreground`:t>72?`text-red-600 dark:text-red-400 font-medium`:t>24?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function ut(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}var k=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function A(e){return e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function j(e,t){if(typeof t==`boolean`)return t?`✓`:`—`;if(typeof t==`number`){if(t>0xe8d4a51000&&/(_at$|_date$|^date_|_time$)/.test(e))try{return new Date(t).toLocaleDateString()}catch{}return t.toLocaleString()}let n=String(t);if(/^\d{4}-\d{2}-\d{2}T\d{2}/.test(n))try{return new Date(n).toLocaleString()}catch{}return n}var dt=/^[A-Za-z0-9_-]{15,}$/;function ft(e,t,n=6){if(!e||typeof e!=`object`||Array.isArray(e))return[];let r=[];for(let[i,a]of Object.entries(e)){if(k.has(i)||a==null||typeof a==`object`||String(a).trim()===``)continue;let e=t?.[i];if(!(!e&&typeof a==`string`&&dt.test(a.trim())&&!/^\d+$/.test(a.trim()))&&(r.push([A(i),e??j(i,a)]),r.length>=n))break}return r}function pt(){let{t:e,language:t}=te(),{user:i}=ee(),$e=a(),{appName:S}=n(),E=(0,x.useMemo)(()=>et(i),[i]),O=(0,x.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),k=(0,x.useCallback)(e=>{if(!e)return`—`;let n=Date.parse(e);if(Number.isNaN(n))return e;let r=Math.round((Date.now()-n)/1e3);if(r<45)return O(`justNow`,`just now`);let i=Math.round(r/60);if(i<60)return O(`minutesAgo`,`{{count}}m ago`,{count:i});let a=Math.round(i/60);if(a<24)return O(`hoursAgo`,`{{count}}h ago`,{count:a});let ee=Math.round(a/24);if(ee<30)return O(`daysAgo`,`{{count}}d ago`,{count:ee});try{return new Date(e).toLocaleDateString(t)}catch{return e}},[O,t]),A=(0,x.useCallback)(e=>{switch(e){case`pending`:return O(`statusPending`,`Pending`);case`approved`:return O(`statusApproved`,`Approved`);case`rejected`:return O(`statusRejected`,`Rejected`);case`recalled`:return O(`statusRecalled`,`Recalled`);case`returned`:return O(`statusReturned`,`Returned for revision`);default:return e}},[O]),j=(0,x.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?O(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?O(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?O(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?O(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?O(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[O]);function dt({status:e}){return(0,w.jsx)(Ae,{variant:`outline`,className:y(`font-medium`,nt[e]??``),children:A(e)})}let pt=(0,x.useCallback)(e=>`/apps/${S||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[S]),[M,mt]=(0,x.useState)(`pending`),[N,ht]=(0,x.useState)([]),[gt,_t]=(0,x.useState)(!1),[vt,yt]=(0,x.useState)(!1),[bt,xt]=(0,x.useState)(null),[St,Ct]=(0,x.useState)(null),[wt,Tt]=(0,x.useState)(0),[P,Et]=(0,x.useState)(null),[F,Dt]=(0,x.useState)(null),[Ot,kt]=(0,x.useState)([]),[At,jt]=(0,x.useState)(!1),[I,L]=(0,x.useState)(``),[R,Mt]=(0,x.useState)(``),[z,Nt]=(0,x.useState)(null),[B,Pt]=(0,x.useState)(``),[Ft,It]=(0,x.useState)(``),[Lt,Rt]=(0,x.useState)(`all`),[zt,Bt]=(0,x.useState)(`all`),[V,Vt]=(0,x.useState)(`all`),[H,Ht]=(0,x.useState)(new Set),[Ut,Wt]=(0,x.useState)(!1),[U,Gt]=(0,x.useState)(null),[Kt,qt]=(0,x.useState)(null),[Jt,Yt]=(0,x.useState)(!1),[Xt,Zt]=(0,x.useState)(``),[Qt,$t]=(0,x.useState)(!1),[en,tn]=(0,x.useState)(``),[nn,rn]=(0,x.useState)(!1),[an,on]=(0,x.useState)(``),[sn,cn]=(0,x.useState)(!1),[ln,un]=(0,x.useState)(``),[W,G]=(0,x.useState)(!1),[dn,fn]=(0,x.useState)([]),[pn,mn]=(0,x.useState)(-1);(0,x.useEffect)(()=>{if(M===`pending`)return;let e=window.setTimeout(()=>It(B),350);return()=>window.clearTimeout(e)},[B,M]);let K=(0,x.useCallback)(async()=>{_t(!0),Ct(null);try{let e=[];if(M===`pending`)e=E.length?(await C.listRequests({status:`pending`,approverId:E})).data:[],Tt(e.length),xt(null);else{let t={q:Ft||void 0,status:V===`all`?void 0:V,limit:tt,offset:0};if(M===`submitted`){let n=i?.id;if(n){let r=await C.listRequests({submitterId:n,...t});e=r.data,xt(r.total??r.data.length)}else e=[],xt(0)}else{let n=await C.listRequests(t);e=n.data,xt(n.total??n.data.length)}E.length&&C.listRequests({status:`pending`,approverId:E}).then(e=>Tt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(D(t)||``).localeCompare(D(e)||``)),ht(e)}catch(e){Ct(e?.message||String(e)),ht([])}finally{_t(!1)}},[M,E,i?.id,Ft,V]);(0,x.useEffect)(()=>{K()},[K]);let hn=(0,x.useCallback)(async()=>{if(!(M===`pending`||vt)){yt(!0);try{let e=await C.listRequests({submitterId:M===`submitted`?i?.id??void 0:void 0,q:Ft||void 0,status:V===`all`?void 0:V,limit:tt,offset:N.length});ht(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&xt(e.total)}catch(e){b.error(j(e,O(`loadFailed`,`Failed to load request`)))}finally{yt(!1)}}},[M,vt,i?.id,Ft,V,N.length,j,O]),q=(0,x.useCallback)(async e=>{Et(e),jt(!0),L(``),Mt(``);try{let[t,n]=await Promise.all([C.getRequest(e),C.listActions(e)]);Dt(t.data),kt(n.data)}catch(e){b.error(j(e,O(`loadFailed`,`Failed to load request`))),Dt(null),kt([])}finally{jt(!1)}},[j,O]),gn=()=>{Et(null),Dt(null),kt([]),L(``),Mt(``)},J=(0,x.useCallback)(e=>{if(R.trim())return R.trim();if(!e)return i?.id||``;let t=new Set(e.pending_approvers||[]);for(let e of E)if(t.has(e))return e;return i?.id||``},[R,E,i?.id]),Y=(0,x.useCallback)(()=>{E.length&&C.listRequests({status:`pending`,approverId:E}).then(e=>Tt(e.data.length)).catch(()=>{})},[E]),_n=(0,x.useCallback)(async e=>{if(!F)return;let t=e===`recall`&&i?.id||J(F);if(!t){b.error(O(`noActor`,`Cannot determine the acting identity`));return}Nt(e);try{let n={actor_id:t,comment:I.trim()||void 0},r=await(e===`approve`?C.approve:e===`reject`?C.reject:C.recall)(F.id,n);if(b.success(e===`approve`?r.finalized?O(`approvedFinal`,`Approved`):O(`approvedWaiting`,`Approved — waiting on the remaining approvers`):e===`reject`?O(`rejectedToast`,`Rejected`):O(`recalledToast`,`Request recalled`)),L(``),e!==`recall`&&M===`pending`){let e=Rn.current,t=e.findIndex(e=>e.id===F.id),n=e[t+1]??e[t-1];K(),n&&n.id!==F.id?q(n.id):gn();return}let[i,a]=await Promise.all([C.getRequest(F.id),C.listActions(F.id)]);Dt(i.data),kt(a.data),K()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{Nt(null)}},[F,J,I,K,i?.id,j,O,M,q]),X=(0,x.useCallback)(async e=>{let[t,n]=await Promise.all([C.getRequest(e),C.listActions(e)]);Dt(t.data),kt(n.data),K()},[K]),vn=(0,x.useCallback)(async()=>{if(!(!F||!Xt.trim())){G(!0);try{await C.reassign(F.id,{actor_id:J(F),to:Xt.trim(),comment:I.trim()||void 0}),b.success(O(`reassignSuccess`,`Handed to {{to}}`,{to:Xt.trim()})),Yt(!1),Zt(``),L(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,Xt,I,J,X,Y,j,O]),yn=(0,x.useCallback)(async()=>{if(F){G(!0);try{let e=await C.remind(F.id,{actor_id:i?.id});b.success(O(`remindSuccess`,`Reminder sent to {{count}} approver(s)`,{count:e.notified})),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,i?.id,X,j,O]),bn=(0,x.useCallback)(async()=>{if(!(!F||!en.trim())){G(!0);try{await C.requestInfo(F.id,{actor_id:J(F),comment:en.trim()}),b.success(O(`requestInfoSent`,`Sent back to the requester for more information`)),$t(!1),tn(``),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,en,J,X,j,O]),xn=(0,x.useCallback)(async()=>{if(F){G(!0);try{let e=await C.sendBack(F.id,{actor_id:J(F),comment:an.trim()||void 0});b.success(e.autoRejected?O(`sendBackAutoRejected`,`Revision limit reached — the request was auto-rejected`):O(`sendBackSuccess`,`Sent back for revision — the requester can now edit and resubmit`)),rn(!1),on(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,an,J,X,Y,j,O]),Sn=(0,x.useCallback)(async()=>{if(F){cn(!0);try{await C.resubmit(F.id,{actor_id:i?.id,comment:I.trim()||void 0}),b.success(O(`resubmitSuccess`,`Resubmitted — a new approval round has opened`)),L(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{cn(!1)}}},[F,I,i?.id,X,Y,j,O]),Cn=(0,x.useCallback)(async()=>{if(!(!F||!ln.trim())){G(!0);try{await C.comment(F.id,{actor_id:i?.id,comment:ln.trim()}),un(``),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,ln,i?.id,X,j,O]),wn=(0,x.useCallback)(async()=>{if(!dn.length)try{let e=``.replace(/\/$/,``);fn(((await(await fetch(`${e}/api/v1/data/sys_user?limit=100`,{credentials:`include`})).json()).records||[]).filter(e=>e.email&&e.name&&e.id!==i?.id).map(e=>({name:String(e.name),email:String(e.email)})))}catch{}},[dn.length,i?.id]),Tn=(0,x.useMemo)(()=>{if(!F||F.status!==`pending`)return!1;let e=new Set(F.pending_approvers||[]);return E.some(t=>e.has(t))||R.trim().length>0},[F,E,R]),En=(0,x.useMemo)(()=>!F||F.status!==`pending`?!1:F.submitter_id===i?.id||R.trim().length>0,[F,i?.id,R]),Dn=(0,x.useMemo)(()=>!F||F.status!==`returned`?!1:F.submitter_id===i?.id||R.trim().length>0,[F,i?.id,R]),On=(0,x.useMemo)(()=>{let e=new Set;for(let t of N)e.add(it(t));return Array.from(e).sort()},[N]),kn=(0,x.useMemo)(()=>{let e=new Set;for(let t of N)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[N]),Z=(0,x.useMemo)(()=>{let e=B.trim().toLowerCase();return N.filter(t=>Lt!==`all`&&it(t)!==Lt||zt!==`all`&&t.object_name!==zt||V!==`all`&&t.status!==V?!1:M!==`pending`||!e?!0:[t.process_name,t.process_label,t.step_label,t.object_name,t.record_id,t.record_title,t.submitter_id,t.submitter_name,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e))},[N,B,Lt,zt,V,M]),An=(0,x.useMemo)(()=>P?Z.findIndex(e=>e.id===P):-1,[Z,P]);(0,x.useEffect)(()=>{if(H.size===0)return;let e=new Set(Z.map(e=>e.id)),t=!1,n=new Set;for(let r of H)e.has(r)?n.add(r):t=!0;t&&Ht(n)},[Z,H]),(0,x.useEffect)(()=>{pn>=Z.length&&mn(Z.length-1)},[Z.length,pn]);let Q=(0,x.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(E);return(e.pending_approvers||[]).some(e=>t.has(e))},[E]),$=(0,x.useMemo)(()=>Z.filter(e=>H.has(e.id)&&Q(e)),[Z,H,Q]),jn=Z.filter(e=>e.status===`pending`),Mn=jn.length>0&&jn.every(e=>H.has(e.id)),Nn=(0,x.useCallback)(()=>{Ht(e=>{if(Mn)return new Set;let t=new Set(e);for(let e of jn)t.add(e.id);return t})},[Mn,jn]),Pn=(0,x.useCallback)(e=>{Ht(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Fn=(0,x.useCallback)(async e=>{let t=$;if(t.length===0)return;Wt(!0);let n=0,r=[];for(let a of t){let t=new Set(a.pending_approvers||[]),ee=E.find(e=>t.has(e))||i?.id||``;try{await(e===`approve`?C.approve:C.reject)(a.id,{actor_id:ee}),n++}catch{r.push(a.record_title||T(a.record_id))}}if(Wt(!1),Ht(new Set),r.length===0)b.success(e===`approve`?O(`bulkApproved`,`Approved {{count}} requests`,{count:n}):O(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);b.error(O(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),Y()},[$,E,i?.id,K,Y,O]),In=(0,x.useCallback)(async e=>{if(!Q(e)||Kt)return;let t=new Set(e.pending_approvers||[]),n=E.find(e=>t.has(e))||i?.id||``;qt(e.id);try{let t=await C.approve(e.id,{actor_id:n});b.success(t.finalized?O(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||T(e.record_id)}):O(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{qt(null)}},[Q,Kt,E,i?.id,K,Y,j,O]),Ln=(0,x.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=E.find(e=>t.has(e))||i?.id||``;qt(e.id),Gt(null);try{await C.reject(e.id,{actor_id:n}),b.success(O(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||T(e.record_id)})),K(),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{qt(null)}},[U,E,i?.id,K,Y,j,O]),Rn=(0,x.useRef)(Z);Rn.current=Z;let zn=(0,x.useRef)(pn);zn.current=pn,(0,x.useEffect)(()=>{let e=e=>{if(P||U)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Rn.current;if(!r.length)return;let i=zn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),mn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),mn(Math.max(i-1,0))):e.key===`Enter`&&i>=0&&r[i]?(e.preventDefault(),q(r[i].id)):(e.key===`x`||e.key===` `)&&i>=0&&r[i]&&M===`pending`?(e.preventDefault(),Pn(r[i].id)):e.key===`a`&&i>=0&&r[i]?(e.preventDefault(),In(r[i])):e.key===`r`&&i>=0&&r[i]&&Q(r[i])&&(e.preventDefault(),Gt(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P,U,M,q,Pn,In,Q]),(0,x.useEffect)(()=>{if(!P)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Rn.current,i=r.findIndex(e=>e.id===P);if(i<0)return;let a=e.key===`ArrowLeft`?r[i-1]:r[i+1];a&&(e.preventDefault(),q(a.id))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P,q]);let Bn=!!B||Lt!==`all`||zt!==`all`||V!==`all`,Vn=e=>{mt(e),Vt(`all`),Rt(`all`),Bt(`all`),Pt(``),mn(-1)};function Hn({r:e}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`font-medium truncate`,children:it(e)}),(0,w.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[at(e)||`—`,(e.round??1)>1&&(0,w.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:O(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function Un({r:e}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(r,{to:pt(e),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-sm hover:underline truncate max-w-full`,title:e.record_id,children:[(0,w.jsx)(`span`,{className:`truncate`,children:e.record_title||T(e.record_id)}),(0,w.jsx)(re,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:ct(e)})]})}function Wn({r:e}){if(!Q(e))return null;let t=Kt===e.id;return(0,w.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),children:[(0,w.jsx)(f,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-emerald-700 hover:text-emerald-800 hover:bg-emerald-50 dark:text-emerald-400`,disabled:t,onClick:()=>void In(e),"aria-label":O(`approve`,`Approve`),children:(0,w.jsx)(Xe,{className:`h-4 w-4`})}),(0,w.jsx)(f,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400`,disabled:t,onClick:()=>Gt(e),"aria-label":O(`reject`,`Reject`),children:(0,w.jsx)(Ue,{className:`h-4 w-4`})})]})}return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,w.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,w.jsx)(Le,{className:`h-6 w-6`}),O(`title`,`Approvals Inbox`)]}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:O(`subtitle`,`Review and act on approval requests.`)})]}),(0,w.jsxs)(f,{variant:`outline`,size:`sm`,onClick:K,disabled:gt,className:`self-start sm:self-auto`,children:[(0,w.jsx)(le,{className:`h-4 w-4 mr-2 ${gt?`animate-spin`:``}`}),O(`refresh`,`Refresh`)]})]}),St&&(0,w.jsxs)(Pe,{variant:`destructive`,children:[(0,w.jsx)(Ye,{className:`h-4 w-4`}),(0,w.jsx)(Te,{children:St})]}),(0,w.jsxs)(Be,{value:M,onValueChange:Vn,children:[(0,w.jsxs)(Fe,{children:[(0,w.jsxs)(Ee,{value:`pending`,children:[O(`tabMyPending`,`My Pending`),wt>0&&(0,w.jsx)(Ae,{variant:`secondary`,className:`ml-2`,children:wt})]}),(0,w.jsx)(Ee,{value:`submitted`,children:O(`tabSubmitted`,`Submitted by me`)}),(0,w.jsx)(Ee,{value:`all`,children:O(`tabAll`,`All`)})]}),(0,w.jsxs)(Ge,{value:M,className:`mt-4 space-y-3`,children:[!gt&&(N.length>0||M!==`pending`&&(Ft||V!==`all`))&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,w.jsx)(ae,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,w.jsx)(ze,{value:B,onChange:e=>Pt(e.target.value),placeholder:O(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),B&&(0,w.jsx)(`button`,{type:`button`,onClick:()=>Pt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":O(`clearSearch`,`Clear search`),children:(0,w.jsx)(oe,{className:`h-3.5 w-3.5`})})]}),M!==`pending`&&(0,w.jsxs)(ie,{value:V,onValueChange:Vt,children:[(0,w.jsx)(be,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,w.jsx)(Se,{placeholder:O(`statusFilter`,`Status`)})}),(0,w.jsxs)(xe,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allStatuses`,`All statuses`)}),(0,w.jsx)(o,{value:`pending`,children:A(`pending`)}),(0,w.jsx)(o,{value:`approved`,children:A(`approved`)}),(0,w.jsx)(o,{value:`rejected`,children:A(`rejected`)}),(0,w.jsx)(o,{value:`recalled`,children:A(`recalled`)}),(0,w.jsx)(o,{value:`returned`,children:A(`returned`)})]})]}),On.length>1&&(0,w.jsxs)(ie,{value:Lt,onValueChange:Rt,children:[(0,w.jsx)(be,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,w.jsx)(Se,{placeholder:O(`processFilter`,`Process`)})}),(0,w.jsxs)(xe,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allProcesses`,`All processes`)}),On.map(e=>(0,w.jsx)(o,{value:e,children:e},e))]})]}),kn.length>1&&(0,w.jsxs)(ie,{value:zt,onValueChange:Bt,children:[(0,w.jsx)(be,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,w.jsx)(Se,{placeholder:O(`objectFilter`,`Object`)})}),(0,w.jsxs)(xe,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allObjects`,`All objects`)}),kn.map(e=>(0,w.jsx)(o,{value:e,children:e},e))]})]}),Bn&&(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`filterCount`,`{{shown}} of {{total}}`,{shown:Z.length,total:N.length})})]}),M===`pending`&&H.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,w.jsxs)(`span`,{children:[(0,w.jsx)(`strong`,{children:H.size}),` `,O(`selected`,`selected`),$.length!==H.size&&(0,w.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:O(`actionableCount`,`({{count}} actionable)`,{count:$.length})})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,disabled:Ut||$.length===0,children:[(0,w.jsx)(Xe,{className:`h-3.5 w-3.5 mr-1`}),O(`approveN`,`Approve {{count}}`,{count:$.length||``})]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:$.length})}),(0,w.jsx)(u,{children:O(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>Fn(`approve`),children:O(`approveN`,`Approve {{count}}`,{count:$.length})})]})]})]}),(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:Ut||$.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,w.jsx)(Ue,{className:`h-3.5 w-3.5 mr-1`}),O(`rejectN`,`Reject {{count}}`,{count:$.length||``})]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:$.length})}),(0,w.jsx)(u,{children:O(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>Fn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`rejectN`,`Reject {{count}}`,{count:$.length})})]})]})]}),(0,w.jsx)(f,{size:`sm`,variant:`ghost`,onClick:()=>Ht(new Set),disabled:Ut,children:O(`clear`,`Clear`)})]})]}),gt?(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(s,{className:`h-10 w-full`}),(0,w.jsx)(s,{className:`h-10 w-full`}),(0,w.jsx)(s,{className:`h-10 w-full`})]}):N.length===0?(0,w.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,w.jsxs)(_e,{children:[(0,w.jsx)(ce,{children:O(`emptyTitle`,`No requests`)}),(0,w.jsx)(Ze,{children:M===`pending`?O(`emptyPending`,`You're all caught up — nothing is waiting on you.`):O(`emptyOther`,`Nothing here yet.`)}),M===`pending`&&(0,w.jsx)(f,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Vn(`all`),children:O(`emptyViewAll`,`Browse all requests`)})]})}):Z.length===0?(0,w.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:O(`noMatches`,`No matches for current filters.`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(de,{className:`hidden md:block`,children:(0,w.jsx)(Ce,{className:`p-0`,children:(0,w.jsxs)(He,{children:[(0,w.jsx)(Je,{children:(0,w.jsxs)(ke,{children:[M===`pending`&&(0,w.jsx)(m,{className:`w-10`,children:(0,w.jsx)(We,{checked:Mn,onCheckedChange:Nn,"aria-label":O(`selectAll`,`Select all`),disabled:jn.length===0})}),(0,w.jsx)(m,{children:O(`colRequest`,`Request`)}),(0,w.jsx)(m,{children:O(`colRecord`,`Record`)}),(0,w.jsx)(m,{children:O(`colRequester`,`Requester`)}),(0,w.jsx)(m,{children:O(`colStatus`,`Status`)}),(0,w.jsx)(m,{children:O(`colWaiting`,`Submitted`)}),(0,w.jsx)(m,{className:`w-20`,"aria-label":O(`colActions`,`Actions`)})]})}),(0,w.jsx)(Ke,{children:Z.map((e,t)=>(0,w.jsxs)(ke,{className:y(`group cursor-pointer hover:bg-accent/50`,pn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{mn(t),q(e.id)},children:[M===`pending`&&(0,w.jsx)(l,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,w.jsx)(We,{checked:H.has(e.id),onCheckedChange:()=>Pn(e.id),disabled:e.status!==`pending`,"aria-label":O(`selectRow`,`Select request`)})}),(0,w.jsx)(l,{children:(0,w.jsx)(Hn,{r:e})}),(0,w.jsx)(l,{children:(0,w.jsx)(Un,{r:e})}),(0,w.jsx)(l,{children:(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,w.jsx)(me,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,w.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:ot(e)})]})}),(0,w.jsx)(l,{children:(0,w.jsx)(dt,{status:e.status})}),(0,w.jsxs)(l,{className:y(`text-xs whitespace-nowrap`,lt(e)),title:rt(D(e)),children:[(0,w.jsx)(De,{className:`h-3 w-3 inline mr-1`}),k(D(e)),e.status===`pending`&&e.sla_due_at&&(0,w.jsx)(`div`,{className:y(`mt-0.5 text-[10px] font-medium`,Date.parse(e.sla_due_at)<Date.now()?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:Date.parse(e.sla_due_at)<Date.now()?O(`slaOverdue`,`SLA overdue {{dur}}`,{dur:ut(Date.now()-Date.parse(e.sla_due_at))}):O(`slaRemaining`,`SLA {{dur}} left`,{dur:ut(Date.parse(e.sla_due_at)-Date.now())})})]}),(0,w.jsx)(l,{className:`w-20`,children:(0,w.jsx)(Wn,{r:e})})]},e.id))})]})})}),(0,w.jsx)(`div`,{className:`md:hidden space-y-2`,children:Z.map(e=>(0,w.jsx)(de,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,w.jsxs)(Ce,{className:`p-3 space-y-1.5`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,w.jsx)(`div`,{className:`font-medium text-sm truncate`,children:it(e)}),(0,w.jsx)(dt,{status:e.status})]}),(0,w.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||T(e.record_id),(0,w.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:ct(e)})]}),(0,w.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,w.jsx)(me,{className:`h-3 w-3`}),ot(e)]}),(0,w.jsxs)(`span`,{className:y(`inline-flex items-center gap-1 whitespace-nowrap`,lt(e)),children:[(0,w.jsx)(De,{className:`h-3 w-3`}),k(D(e))]})]}),Q(e)&&(0,w.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(f,{size:`sm`,className:`h-7 flex-1`,disabled:Kt===e.id,onClick:()=>void In(e),children:[(0,w.jsx)(Xe,{className:`h-3.5 w-3.5 mr-1`}),O(`approve`,`Approve`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:Kt===e.id,onClick:()=>Gt(e),children:[(0,w.jsx)(Ue,{className:`h-3.5 w-3.5 mr-1`}),O(`reject`,`Reject`)]})]})]})},e.id))}),M!==`pending`&&bt!=null&&(0,w.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:N.length,total:bt})}),N.length<bt&&(0,w.jsx)(f,{size:`sm`,variant:`outline`,disabled:vt,onClick:()=>void hn(),children:vt?O(`loadingMore`,`Loading…`):O(`loadMore`,`Load more`)})]}),(0,w.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:O(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,w.jsx)(_,{open:Jt,onOpenChange:e=>{e||(Yt(!1),Zt(``))},children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`reassignTitle`,`Hand this approval to someone else?`)}),(0,w.jsx)(u,{children:O(`reassignBody`,`Your approver slot moves to the person you pick — they are notified and can act immediately.`)})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Ve,{htmlFor:`reassign-to`,className:`text-xs`,children:O(`reassignTo`,`New approver`)}),(0,w.jsx)(ze,{id:`reassign-to`,list:`reassign-user-options`,value:Xt,onChange:e=>Zt(e.target.value),placeholder:O(`reassignToPlaceholder`,`Pick a user or type an email / role:<name>`),className:`mt-1`}),(0,w.jsx)(`datalist`,{id:`reassign-user-options`,children:dn.map(e=>(0,w.jsx)(`option`,{value:e.email,children:e.name},e.email))})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{disabled:!Xt.trim()||W,onClick:()=>void vn(),children:O(`reassignBtn`,`Reassign`)})]})]})}),(0,w.jsx)(_,{open:Qt,onOpenChange:e=>{e||($t(!1),tn(``))},children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`requestInfoTitle`,`Ask the requester for more information?`)}),(0,w.jsx)(u,{children:O(`requestInfoBody`,`The request stays pending; the requester is notified and can reply on the thread.`)})]}),(0,w.jsx)(qe,{value:en,onChange:e=>tn(e.target.value),rows:3,placeholder:O(`requestInfoPlaceholder`,`What do you need from the requester?`)}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{disabled:!en.trim()||W,onClick:()=>void bn(),children:O(`requestInfoBtn`,`Request info`)})]})]})}),(0,w.jsx)(_,{open:nn,onOpenChange:e=>{e||(rn(!1),on(``))},children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`sendBackTitle`,`Send this request back for revision?`)}),(0,w.jsx)(u,{children:O(`sendBackBody`,`This round ends and the record unlocks so the requester can fix the data. When they resubmit, a fresh approval round opens for all approvers.`)})]}),(0,w.jsx)(qe,{value:an,onChange:e=>on(e.target.value),rows:3,placeholder:O(`sendBackPlaceholder`,`What needs to be fixed before this can be approved?`)}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{disabled:W,onClick:()=>void xn(),children:O(`sendBackBtn`,`Send back`)})]})]})}),(0,w.jsx)(_,{open:!!U,onOpenChange:e=>!e&&Gt(null),children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`rejectOneTitle`,`Reject "{{title}}"?`,{title:U?U.record_title||T(U.record_id):``})}),(0,w.jsx)(u,{children:O(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>void Ln(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`reject`,`Reject`)})]})]})}),(0,w.jsx)(ge,{open:!!P,onOpenChange:e=>!e&&gn(),children:(0,w.jsxs)(se,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,w.jsxs)(pe,{children:[(0,w.jsx)(ve,{children:F?it(F):O(`drawerTitle`,`Approval Request`)}),(0,w.jsx)(ue,{children:F?at(F)||ct(F):``})]}),F&&An>=0&&Z.length>1&&(0,w.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,w.jsxs)(f,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An<=0,onClick:()=>{let e=Z[An-1];e&&q(e.id)},children:[(0,w.jsx)(Ie,{className:`h-4 w-4 mr-0.5`}),O(`prevRequest`,`Previous`)]}),(0,w.jsx)(`span`,{children:O(`positionOf`,`{{index}} of {{total}}`,{index:An+1,total:Z.length})}),(0,w.jsxs)(f,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An>=Z.length-1,onClick:()=>{let e=Z[An+1];e&&q(e.id)},children:[O(`nextRequest`,`Next`),(0,w.jsx)(ne,{className:`h-4 w-4 ml-0.5`})]})]}),At?(0,w.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,w.jsx)(s,{className:`h-6 w-3/4`}),(0,w.jsx)(s,{className:`h-6 w-1/2`}),(0,w.jsx)(s,{className:`h-20 w-full`})]}):F?(0,w.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(dt,{status:F.status}),(F.round??1)>1&&(0,w.jsx)(Ae,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:O(`roundChip`,`Round {{n}}`,{n:F.round})}),(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:rt(D(F)),children:[(0,w.jsx)(De,{className:`h-3 w-3`}),O(`submittedAgo`,`Submitted {{when}}`,{when:k(D(F))})]}),F.completed_at&&(0,w.jsxs)(`span`,{children:[`· `,O(`completedAt`,`Completed {{when}}`,{when:k(F.completed_at)})]}),F.status===`pending`&&F.sla_due_at&&(0,w.jsx)(Ae,{variant:`outline`,className:y(`text-[10px]`,Date.parse(F.sla_due_at)<Date.now()?`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`:`border-border text-muted-foreground`),children:Date.parse(F.sla_due_at)<Date.now()?O(`slaOverdue`,`SLA overdue {{dur}}`,{dur:ut(Date.now()-Date.parse(F.sla_due_at))}):O(`slaRemaining`,`SLA {{dur}} left`,{dur:ut(Date.parse(F.sla_due_at)-Date.now())})})]}),(0,w.jsx)(de,{children:(0,w.jsxs)(Ce,{className:`p-4 space-y-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(r,{to:pt(F),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,w.jsx)(`span`,{className:`truncate`,children:F.record_title||T(F.record_id)}),(0,w.jsx)(re,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:ct(F)})]}),(0,w.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,w.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,w.jsx)(me,{className:`h-3 w-3`}),(0,w.jsx)(`span`,{title:F.submitter_id||``,children:ot(F)})]})})]}),ft(F.payload,F.payload_display).length>0&&(0,w.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-sm border-t pt-3`,children:ft(F.payload,F.payload_display).map(([e,t])=>(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,w.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),F.status===`pending`&&(F.pending_approvers||[]).length>0&&(0,w.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,w.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:O(`waitingOn`,`Waiting on`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(F.pending_approvers||[]).map((e,t)=>(0,w.jsx)(Ae,{variant:`outline`,className:`text-[11px]`,title:e,children:st(e,F)},t))})]})]})}),(F.flow_steps?.length??0)>1&&(0,w.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":O(`stepProgress`,`Approval steps`),children:F.flow_steps.map((e,t)=>(0,w.jsxs)(x.Fragment,{children:[t>0&&(0,w.jsx)(`div`,{className:y(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,w.jsx)(`span`,{className:y(`flex items-center justify-center h-5 w-5 rounded-full text-[10px] font-semibold`,e.state===`done`&&`bg-emerald-500 text-white`,e.state===`current`&&`bg-amber-500 text-white ring-2 ring-amber-200 dark:ring-amber-500/30`,e.state===`upcoming`&&`bg-muted text-muted-foreground border`),children:e.state===`done`?(0,w.jsx)(he,{className:`h-3 w-3`}):t+1}),(0,w.jsx)(`span`,{className:y(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:O(`history`,`Activity`)}),Ot.length===0?(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O(`noActions`,`No actions yet.`)}):(0,w.jsx)(`ol`,{className:`relative space-y-3 pl-5 before:absolute before:left-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border`,children:Ot.map(e=>{let t=e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:e.action===`reassign`?`bg-indigo-500`:e.action===`remind`||e.action===`request_info`?`bg-amber-500`:e.action===`comment`?`bg-slate-400`:e.action===`escalate`?`bg-red-500`:e.action===`revise`?`bg-violet-500`:e.action===`resubmit`?`bg-blue-500`:`bg-muted-foreground`,n=e.actor_id===`system:sla`?O(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===F.submitter_id?ot(F):T(e.actor_id)),r=e.action===`submit`?O(`actSubmit`,`Submitted`):e.action===`approve`?O(`actApprove`,`Approved`):e.action===`reject`?O(`actReject`,`Rejected`):e.action===`recall`?O(`actRecall`,`Recalled`):e.action===`reassign`?O(`actReassign`,`Reassigned`):e.action===`remind`?O(`actRemind`,`Reminder sent`):e.action===`request_info`?O(`actRequestInfo`,`Requested more info`):e.action===`comment`?O(`actComment`,`Commented`):e.action===`escalate`?O(`actEscalate`,`SLA escalated`):e.action===`revise`?O(`actRevise`,`Sent back for revision`):e.action===`resubmit`?O(`actResubmit`,`Resubmitted`):e.action;return(0,w.jsxs)(`li`,{className:`relative text-xs`,children:[(0,w.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,w.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,w.jsx)(`span`,{className:`font-medium`,children:r}),(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,w.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,w.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:rt(e.created_at),children:k(e.created_at)})]}),e.comment&&(0,w.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]})]},e.id)})}),F.status===`pending`&&(Tn||En)&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,w.jsx)(ze,{value:ln,onChange:e=>un(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ln.trim()&&(e.preventDefault(),Cn())},placeholder:O(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,w.jsx)(f,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!ln.trim()||W,onClick:()=>void Cn(),children:(0,w.jsx)(ye,{className:`h-3.5 w-3.5`})})]})]}),F.payload!=null&&(0,w.jsxs)(`details`,{className:`group`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:O(`rawData`,`Raw data (JSON)`)}),(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(`div`,{className:`flex justify-end`,children:(0,w.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(F.payload,null,2)),b.success(O(`copied`,`Copied`))}catch{b.error(O(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,w.jsx)(je,{className:`h-3 w-3`}),O(`copy`,`Copy`)]})}),(0,w.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(F.payload,null,2)})]})]}),F.status===`pending`&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Qe,{}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[$e&&(0,w.jsxs)(`details`,{className:`group`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:O(`overrideActor`,`Act as another identity (admin)`)}),(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(Ve,{htmlFor:`actor-override`,className:`text-xs`,children:O(`actor`,`Actor`)}),(0,w.jsx)(`input`,{id:`actor-override`,type:`text`,value:R,onChange:e=>Mt(e.target.value),placeholder:`${O(`auto`,`Auto`)}: ${J(F)||`—`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,w.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:O(`overrideHint`,`e.g. role:sales_manager. Leave blank to use the auto-detected identity.`)})]})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Ve,{htmlFor:`comment`,className:`text-xs`,children:O(`comment`,`Comment (optional)`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[O(`quickPhrase1`,`Approved — meets requirements.`),O(`quickPhrase2`,`Approved with conditions — please monitor execution.`),O(`quickPhrase3`,`Please add supporting material and resubmit.`)].map(e=>(0,w.jsx)(`button`,{type:`button`,onClick:()=>L(e),className:`text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:e},e))}),(0,w.jsx)(qe,{id:`comment`,value:I,onChange:e=>L(e.target.value),rows:2,className:`mt-1`})]}),(0,w.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,w.jsxs)(f,{size:`sm`,onClick:()=>_n(`approve`),disabled:!Tn||z!==null,children:[(0,w.jsx)(Xe,{className:`h-4 w-4 mr-1`}),z===`approve`?O(`approving`,`Approving…`):O(`approve`,`Approve`)]}),(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:!Tn||z!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,w.jsx)(Ue,{className:`h-4 w-4 mr-1`}),z===`reject`?O(`rejecting`,`Rejecting…`):O(`reject`,`Reject`)]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`rejectTitle`,`Reject this request?`)}),(0,w.jsx)(u,{children:O(`rejectBody`,`This marks the request as rejected and notifies the submitter.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>_n(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`reject`,`Reject`)})]})]})]}),Tn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,className:`border-violet-300 text-violet-700 hover:bg-violet-50 dark:text-violet-400`,onClick:()=>rn(!0),children:[(0,w.jsx)(we,{className:`h-4 w-4 mr-1`}),O(`sendBackBtn`,`Send back`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,className:`border-amber-300 text-amber-700 hover:bg-amber-50 dark:text-amber-400`,onClick:()=>$t(!0),children:[(0,w.jsx)(Me,{className:`h-4 w-4 mr-1`}),O(`requestInfoBtn`,`Request info`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,onClick:()=>{wn(),Yt(!0)},children:[(0,w.jsx)(Oe,{className:`h-4 w-4 mr-1`}),O(`reassignBtn`,`Reassign`)]})]}),En&&(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:W,onClick:()=>void yn(),children:[(0,w.jsx)(Re,{className:`h-4 w-4 mr-1`}),O(`remindBtn`,`Send reminder`)]}),En&&(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null,children:[(0,w.jsx)(fe,{className:`h-4 w-4 mr-1`}),z===`recall`?O(`recalling`,`Recalling…`):O(`recall`,`Recall`)]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`recallTitle`,`Recall this request?`)}),(0,w.jsx)(u,{children:O(`recallBody`,`This withdraws your request. Approvers can no longer act on it, and the record is unlocked.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>_n(`recall`),children:O(`recall`,`Recall`)})]})]})]})]}),!Tn&&(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:En?O(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):O(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(F.pending_approvers||[]).map(e=>st(e,F)).join(`, `)||`—`})})]})]}),Dn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Qe,{}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Ve,{htmlFor:`resubmit-comment`,className:`text-xs`,children:O(`comment`,`Comment (optional)`)}),(0,w.jsx)(qe,{id:`resubmit-comment`,value:I,onChange:e=>L(e.target.value),rows:2,className:`mt-1`,placeholder:O(`resubmitPlaceholder`,`What did you change?`)})]}),(0,w.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,w.jsx)(f,{asChild:!0,size:`sm`,variant:`outline`,children:(0,w.jsxs)(r,{to:pt(F),children:[(0,w.jsx)(re,{className:`h-4 w-4 mr-1`}),O(`editRecordBtn`,`Edit record`)]})}),(0,w.jsxs)(f,{size:`sm`,disabled:sn,onClick:()=>void Sn(),children:[(0,w.jsx)(le,{className:y(`h-4 w-4 mr-1`,sn&&`animate-spin`)}),sn?O(`resubmitting`,`Resubmitting…`):O(`resubmitBtn`,`Resubmit`)]}),(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:sn,children:[(0,w.jsx)(fe,{className:`h-4 w-4 mr-1`}),O(`recall`,`Recall`)]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`abandonTitle`,`Abandon this revision?`)}),(0,w.jsx)(u,{children:O(`abandonBody`,`This withdraws the request instead of resubmitting it. The approval ends here.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>_n(`recall`),children:O(`recall`,`Recall`)})]})]})]})]})]})]})]}):null]})})]})}export{pt as ApprovalsInboxPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{Bt as r,Ci as i,Cr as a,Ft as ee,H as te,Ht as o,Ii as ne,It as re,Jn as s,Lt as c,Mt as l,Pt as u,R as ie,Rt as ae,Ut as oe,Vt as d,Wt as f,Yn as p,ar as m,ct as h,dt as g,er as _,gr as v,ir as se,lt as y,nn as b,on as x,ot as ce,st as le,ut as ue,wi as S,ws as C,z as w,zt as T}from"./ui-components-DiLX53DV.js";var E=e(t(),1),D=n(),de=`${``.replace(/\/$/,``)}/api/v1`,fe=[`create`,`update`,`delete`,`restore`,`login`,`logout`,`permission_change`,`config_change`,`export`,`import`],O={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`},k=50;function A(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function j(e,t=24){return e?e.length>t?`${e.slice(0,t-1)}…`:e:`—`}function M(e){if(!e)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function N(){let[e,t]=(0,E.useState)([]),[n,N]=(0,E.useState)(!1),[P,F]=(0,E.useState)(null),[I,L]=(0,E.useState)(`all`),[R,z]=(0,E.useState)(``),[B,V]=(0,E.useState)(``),[H,U]=(0,E.useState)(``),[W,G]=(0,E.useState)(``),[K,q]=(0,E.useState)(0),[J,Y]=(0,E.useState)(!1),[X,Z]=(0,E.useState)(null),Q=(0,E.useCallback)(async()=>{N(!0),F(null);try{let e={};I&&I!==`all`&&(e.action=I),R.trim()&&(e.object_name=R.trim()),B.trim()&&(e.user_id=B.trim()),H&&(e.created_at={...e.created_at||{},$gte:H}),W&&(e.created_at={...e.created_at||{},$lte:`${W}T23:59:59`});let n=new URLSearchParams;Object.keys(e).length>0&&n.set(`$filter`,JSON.stringify(e)),n.set(`$orderby`,`created_at desc`),n.set(`$top`,`51`),n.set(`$skip`,String(K*k));let r=await fetch(`${de}/data/sys_audit_log?${n.toString()}`,{credentials:`include`});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`HTTP ${r.status}: ${e.slice(0,200)||r.statusText}`)}let i=await r.json(),a=Array.isArray(i)?i:Array.isArray(i?.records)?i.records:Array.isArray(i?.data)?i.data:[];Y(a.length>k),t(a.slice(0,k))}catch(e){console.warn(`[AuditLogPage] load failed:`,e),F(e?.message||`Failed to load audit log`),t([]),Y(!1)}finally{N(!1)}},[I,R,B,H,W,K]);(0,E.useEffect)(()=>{Q()},[Q]);let pe=(0,E.useCallback)(()=>{L(`all`),z(``),V(``),U(``),G(``),q(0)},[]),$=(0,E.useMemo)(()=>{let e=0;return I!==`all`&&(e+=1),R.trim()&&(e+=1),B.trim()&&(e+=1),H&&(e+=1),W&&(e+=1),e},[I,R,B,H,W]);return(0,D.jsxs)(`div`,{className:`p-6 space-y-4 max-w-screen-2xl mx-auto`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(S,{className:`h-6 w-6 text-muted-foreground`}),(0,D.jsxs)(`div`,{className:`flex-1`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Audit Log`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Read-only system activity and record changes. Newest first.`})]}),(0,D.jsxs)(v,{variant:`outline`,size:`sm`,onClick:Q,disabled:n,children:[(0,D.jsx)(ne,{className:`h-4 w-4 mr-1 ${n?`animate-spin`:``}`}),`Refresh`]})]}),(0,D.jsx)(s,{children:(0,D.jsxs)(p,{className:`p-4 grid grid-cols-1 md:grid-cols-5 gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(x,{className:`text-xs`,children:`Action`}),(0,D.jsxs)(r,{value:I,onValueChange:e=>{L(e),q(0)},children:[(0,D.jsx)(oe,{className:`h-9`,children:(0,D.jsx)(f,{})}),(0,D.jsxs)(d,{children:[(0,D.jsx)(o,{value:`all`,children:`All actions`}),fe.map(e=>(0,D.jsx)(o,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(x,{className:`text-xs`,children:`Object`}),(0,D.jsx)(b,{placeholder:`e.g. account`,value:R,onChange:e=>{z(e.target.value),q(0)},className:`h-9`})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(x,{className:`text-xs`,children:`Actor (user id)`}),(0,D.jsx)(b,{placeholder:`user id`,value:B,onChange:e=>{V(e.target.value),q(0)},className:`h-9`})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(x,{className:`text-xs`,children:`From`}),(0,D.jsx)(b,{type:`date`,value:H,onChange:e=>{U(e.target.value),q(0)},className:`h-9`})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(x,{className:`text-xs`,children:`To`}),(0,D.jsx)(b,{type:`date`,value:W,onChange:e=>{G(e.target.value),q(0)},className:`h-9`})]}),$>0&&(0,D.jsx)(`div`,{className:`md:col-span-5 flex justify-end`,children:(0,D.jsxs)(v,{variant:`ghost`,size:`sm`,onClick:pe,children:[(0,D.jsx)(a,{className:`h-4 w-4 mr-1`}),`Clear filters (`,$,`)`]})})]})}),P&&(0,D.jsxs)(se,{variant:`destructive`,children:[(0,D.jsx)(C,{className:`h-4 w-4`}),(0,D.jsx)(m,{children:P})]}),(0,D.jsx)(s,{children:(0,D.jsx)(p,{className:`p-0`,children:n&&e.length===0?(0,D.jsx)(`div`,{className:`p-6 space-y-2`,children:Array.from({length:6}).map((e,t)=>(0,D.jsx)(l,{className:`h-9 w-full`},t))}):e.length===0?(0,D.jsx)(`div`,{className:`p-12`,children:(0,D.jsxs)(ie,{children:[(0,D.jsx)(i,{className:`h-8 w-8 text-muted-foreground mb-3`}),(0,D.jsx)(te,{children:`No audit entries`}),(0,D.jsx)(w,{children:$>0?`Try clearing filters or widening the date range.`:`Events will appear here once tracked objects are modified.`})]})}):(0,D.jsxs)(ce,{children:[(0,D.jsx)(ue,{children:(0,D.jsxs)(g,{children:[(0,D.jsx)(y,{className:`w-[180px]`,children:`Timestamp`}),(0,D.jsx)(y,{className:`w-[130px]`,children:`Action`}),(0,D.jsx)(y,{children:`Object`}),(0,D.jsx)(y,{children:`Record`}),(0,D.jsx)(y,{children:`Actor`}),(0,D.jsx)(y,{className:`w-[130px]`,children:`IP`})]})}),(0,D.jsx)(le,{children:e.map(e=>{let t=O[e.action||``]||`outline`;return(0,D.jsxs)(g,{className:`cursor-pointer`,onClick:()=>Z(e),children:[(0,D.jsx)(h,{className:`font-mono text-xs`,children:A(e.created_at)}),(0,D.jsx)(h,{children:(0,D.jsx)(_,{variant:t,children:e.action||`—`})}),(0,D.jsx)(h,{children:e.object_name||`—`}),(0,D.jsx)(h,{className:`font-mono text-xs`,children:j(e.record_id,18)}),(0,D.jsx)(h,{className:`font-mono text-xs`,children:j(e.user_id,18)}),(0,D.jsx)(h,{className:`font-mono text-xs`,children:e.ip_address||`—`})]},e.id)})})]})})}),(e.length>0||K>0)&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-sm text-muted-foreground`,children:[(0,D.jsxs)(`span`,{children:[`Page `,K+1,J?``:` · end`]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(v,{variant:`outline`,size:`sm`,disabled:K===0||n,onClick:()=>q(e=>Math.max(0,e-1)),children:`Previous`}),(0,D.jsx)(v,{variant:`outline`,size:`sm`,disabled:!J||n,onClick:()=>q(e=>e+1),children:`Next`})]})]}),(0,D.jsx)(u,{open:!!X,onOpenChange:e=>!e&&Z(null),children:(0,D.jsxs)(ee,{side:`right`,className:`sm:max-w-2xl w-full overflow-y-auto`,children:[(0,D.jsxs)(c,{children:[(0,D.jsxs)(ae,{className:`flex items-center gap-2`,children:[(0,D.jsx)(_,{variant:X&&O[X.action||``]||`outline`,children:X?.action||`—`}),X?.object_name||`Audit Event`]}),(0,D.jsx)(re,{children:X?.id?(0,D.jsx)(`span`,{className:`font-mono text-xs`,children:X.id}):null})]}),X&&(0,D.jsxs)(`div`,{className:`mt-6 space-y-5`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Timestamp`}),(0,D.jsx)(`div`,{className:`font-mono`,children:A(X.created_at)})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`IP Address`}),(0,D.jsx)(`div`,{className:`font-mono`,children:X.ip_address||`—`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Actor (user_id)`}),(0,D.jsx)(`div`,{className:`font-mono break-all`,children:X.user_id||`—`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Tenant`}),(0,D.jsx)(`div`,{className:`font-mono break-all`,children:X.tenant_id||`—`})]}),(0,D.jsxs)(`div`,{className:`col-span-2`,children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Target record`}),(0,D.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[X.object_name||`—`,` / `,X.record_id||`—`]})]}),X.user_agent&&(0,D.jsxs)(`div`,{className:`col-span-2`,children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`User Agent`}),(0,D.jsx)(`div`,{className:`font-mono text-xs break-all`,children:X.user_agent})]})]}),(X.old_value||X.new_value)&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(T,{}),(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(`div`,{className:`text-sm font-medium`,children:`Change payload`}),X.old_value&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Before`}),(0,D.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.old_value)})]}),X.new_value&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`After`}),(0,D.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.new_value)})]})]})]}),X.metadata&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(T,{}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,D.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-48 overflow-auto`,children:M(X.metadata)})]})]})]})]})})]})}export{N as AuditLogPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{i as a}from"./framework-D5XqsLzE.js";import{Bt as o,Ht as s,Ut as c,Vt as l,Wt as u,gr as d,oi as f,w as p,yi as m}from"./ui-components-DiLX53DV.js";import{r as h}from"./vendor-ui-utils-C92Fl7BT.js";import{i as g,s as _,t as v}from"./assistantBus-BMrg1uLy.js";import{c as y,l as b,n as ee,o as te,t as ne}from"./useReconcileOnError-CGxw9vPi.js";import{S as x,a as re,d as S,h as C,m as w,p as T,r as E,t as D,u as O,v as ie}from"./plugin-chatbot-DiZuqXNz.js";import{b as k,n as ae}from"./marketplaceApi-BEwXWaVr.js";var A=e(t(),1);function j(e){return e.some(e=>w(e.name))&&e.some(e=>C(e.name))}function M({agents:e,showAgentPickerProp:t,envOptIn:n=!1,aiStudioEnabled:r=!0}){return t===void 0?n?!0:r&&j(e):t}var N=r(),P={ask:{zh:`智能助手`,en:`Assistant`},build:{zh:`构建助手`,en:`Build assistant`}};function F(e,t,n){let r=t?P[T(t)]:void 0;return r?e?r.zh:r.en:n}function oe(e,t,n,r,i){let a=(e??``).toLowerCase().startsWith(`zh`),o=F(a,n,r),s=i.slice(0,2).map(e=>e.label||e.name);if(a){let e=[s[0]?`查询最近创建的${s[0]}`:`帮我查询最近的数据`,s[0]?`统计${s[0]}的总数量`:`统计各对象的记录数量`,s[1]?`${s[1]}有哪些字段?`:`当前应用里有哪些数据对象?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`你好,我是${o}`,emptyDescription:`随时帮你查询和分析「${t}」中的数据。试试下面的问题,或直接输入你的需求。`,clear:`清空对话`,sendHint:`发送`,agentActivity:`执行过程`,toolCompleted:`已完成`,toolRunning:`运行中`,toolAwaitingApproval:`等待确认`,toolFailed:`失败`,connectionWaiting:`正在等待服务器响应…`,connectionStalledLabel:`仍在处理中…`,connectionOfflineLabel:`网络已断开,正在重连…`,toolDetailsHidden:`已隐藏工具参数和原始结果,仅保留过程摘要。`,copy:`复制`,copied:`已复制`,regenerate:`重新生成`,model:`模型`,submit:`发送`,uploadFiles:`上传文件`,stopResponse:`停止生成`,trace:`调试 trace`,viewTrace:`查看调试 trace`},placeholder:`向${o}提问…`,loadingPlaceholder:`正在加载助手…`,title:`${t} 智能助手`,newChat:`开启新对话`,share:`分享对话`,reviewDraft:e=>`查看 ${e} 项变更`,publishDrafts:`发布`,published:`已发布`,nextSteps:`下一步`,planTitle:`方案预览`,planQuestions:`搭建前请确认`,planAssumptions:`假设`,planApproveHint:`回复以确认或调整该方案。`,planApprove:`开始搭建`,planAdjust:`调整方案`,planBuilt:`已搭建`,planApproveMessage:`就按这个方案搭建吧。`,planApproveDefaultsMessage:`就按你的合理假设直接搭建,未决问题用默认即可。`,planAnswer:(e,t)=>`关于「${e}」,我选择「${t}」。`,publishOk:`已发布,对象已生效。`,publishFailed:`发布失败`,seedWarn:`已发布,但部分示例数据未能载入。`,openBuiltApp:`打开应用`,suggestions:e}}let c=[s[0]?`Show the latest ${s[0]}`:`Show my most recent records`,s[0]?`How many ${s[0]} are there?`:`Count records by status`,s[1]?`What fields does ${s[1]} have?`:`What data can I work with here?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`Hi, I'm ${o}`,emptyDescription:`I can help you query and analyze your ${t} data. Try a prompt below, or just type your question.`,clear:`Clear`,sendHint:`to send`,agentActivity:`Agent activity`,toolCompleted:`Completed`,toolRunning:`Running`,toolAwaitingApproval:`Awaiting approval`,toolFailed:`Failed`,connectionWaiting:`Waiting for server…`,connectionStalledLabel:`Still working…`,connectionOfflineLabel:`Connection lost — reconnecting…`,toolDetailsHidden:`Tool inputs and raw results are hidden in this view.`,copy:`Copy`,copied:`Copied`,regenerate:`Regenerate`,model:`Model`,submit:`Submit`,uploadFiles:`Upload files`,stopResponse:`Stop response`,trace:`trace`,viewTrace:`View trace`},placeholder:`Ask ${o}...`,loadingPlaceholder:`Loading assistant...`,title:`${t} Assistant`,newChat:`New chat`,share:`Share conversation`,reviewDraft:e=>`Review ${e} change${e===1?``:`s`}`,publishDrafts:`Publish`,published:`Published`,nextSteps:`What's next`,planTitle:`Proposed plan`,planQuestions:`Confirm before building`,planAssumptions:`Assumptions`,planApproveHint:`Reply to approve or adjust this plan.`,planApprove:`Build it`,planAdjust:`Adjust`,planBuilt:`Built`,planApproveMessage:`Looks good — build it as proposed.`,planApproveDefaultsMessage:`Build it with your best assumptions; use sensible defaults for the open questions.`,planAnswer:(e,t)=>`For "${e}", go with: ${t}.`,publishOk:`Published — objects are now live.`,publishFailed:`Publish failed`,seedWarn:`Published, but some sample data failed to load.`,openBuiltApp:`Open app`,suggestions:c}}var I=`/api/v1/ai`;function L(e){if(e)return e.replace(/\/$/,``);let t={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},n=t.VITE_AI_BASE_URL;return n?n.replace(/\/$/,``):`${(t.VITE_SERVER_URL??``).replace(/\/$/,``)}${I}`}function se(e,t){if(!e||e.type!==`object`)return null;let n=e.label||e.name||`this object`;return(t??``).toLowerCase().startsWith(`zh`)?[`为「${n}」补充字段`,`为「${n}」建议校验规则`,`添加一个状态选项字段`]:[`Add fields to ${n}`,`Suggest validations for ${n}`,`Add a status picklist field`]}var R=new Set([`view`,`record`,`page`,`dashboard`,`design`,`report`,`metadata`]);function z(e){try{return decodeURIComponent(e)}catch{return e}}function ce(e,t){let n=e.split(`/`).filter(Boolean),r=n.indexOf(`apps`);if(r===-1||n.length<r+3)return{};let i=z(n[r+2]);if(R.has(i)||!t.some(e=>e.name===i))return{};let a=n[r+3]?z(n[r+3]):void 0,o=a&&a!==`new`?a:void 0;return{objectName:i,...o?{recordId:o}:{}}}function B({appLabel:e,appName:t,objects:r,agents:y,agentsLoading:S,activeAgent:C,onAgentChange:w,showAgentPicker:T,chatApi:O,apiBase:j,defaultOpen:M=!1,conversationId:P,initialMessages:F}){let{language:I}=a(),L=i(),R=n(),z=A.useMemo(()=>ce(R.pathname,r),[R.pathname,r]),{editor:B}=_(),V=A.useMemo(()=>!F||F.length===0?[]:x(F),[F]),H=A.useMemo(()=>y.find(e=>e.name===C)?.label??C??e,[y,C,e]),U=A.useMemo(()=>oe(I,e,C,H,r),[I,e,C,H,r]),W=A.useMemo(()=>se(B,I),[B,I]),{errorSuppressed:le,handleChatError:ue,setMessagesRef:de,resetSuppression:G}=ne({chatApi:O,conversationId:P}),{messages:K,isLoading:q,error:fe,sendMessage:J,stop:pe,reload:Y,clear:X,setMessages:Z}=ie({api:O,conversationId:P,onError:ue,body:{context:{activeApp:e,appName:t,objects:r.map(e=>({name:e.name,label:e.label})),agentName:C,autoPublishAiBuilds:k().features.autoPublishAiBuilds,...z.objectName?{objectName:z.objectName}:{},...z.recordId?{recordId:z.recordId}:{},...B?{editing:B}:{}}},initialMessages:V,autoResponse:!O,autoResponseText:r.length>0?`I can help you work with ${r.map(e=>e.label||e.name).join(`, `)}. What would you like to do?`:`Thanks for your message! I'm here to help you navigate and manage your data.`,autoResponseDelay:600});A.useEffect(()=>{de.current=Z},[Z]),A.useEffect(()=>{b(P,te(K))},[P,K]);let Q=D({messages:K,apiBase:j,continueConversation:e=>{G(),J(e)}}),me=T&&y.length>1?(0,N.jsxs)(o,{value:C,onValueChange:w,disabled:S,children:[(0,N.jsx)(c,{className:`h-7 w-[180px] text-xs`,"data-testid":`floating-chatbot-agent-picker`,children:(0,N.jsx)(u,{placeholder:`Choose agent...`})}),(0,N.jsx)(l,{align:`end`,children:y.map(e=>(0,N.jsxs)(s,{value:e.name,className:`text-xs`,children:[(0,N.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,N.jsx)(`span`,{className:`block text-muted-foreground text-[10px] truncate max-w-[220px]`,children:e.description}):null]},e.name))})]}):null,[he,$]=A.useState(!1),ge=A.useMemo(()=>j.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[j]),_e=(0,N.jsxs)(N.Fragment,{children:[K.length>0?(0,N.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":U.newChat,title:U.newChat,"data-testid":`floating-chatbot-new`,onClick:X,children:(0,N.jsx)(f,{className:`h-4 w-4`})}):null,P?(0,N.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":U.share,title:U.share,"data-testid":`floating-chatbot-share`,onClick:()=>$(!0),children:(0,N.jsx)(m,{className:`h-4 w-4`})}):null]});return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(E,{onUpgrade:()=>window.open(ae(),`_blank`,`noopener,noreferrer`),floatingConfig:{position:`bottom-right`,defaultOpen:M,panelWidth:420,panelHeight:560,title:U.title,triggerSize:56},headerExtra:me,headerActions:_e,messages:K,labels:U.labels,showAvatars:!0,hideClearBar:!0,assistantAvatarFallback:U.agentLabel,suggestions:K.length===0?W??U.suggestions:void 0,placeholder:C?U.placeholder:S?U.loadingPlaceholder:U.placeholder,onSendMessage:e=>{G(),J(e)},onClear:X,onStop:q?pe:void 0,onReload:Y,isLoading:q,error:le?void 0:fe,enableMarkdown:!0,onToolApprove:Q.decide,toolDecisions:Q.decisions,toolApproveLabel:`Approve & run`,toolDenyLabel:`Reject`,toolDenyReason:`Operator rejected from chat`,onReviewDraft:e=>{e[0]&&g(e[0])},toolReviewLabel:U.reviewDraft,onOpenBuiltApp:e=>L(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:U.openBuiltApp,onPreviewDraftApp:(e,t)=>L(t?.materialized?`/apps/${encodeURIComponent(e)}`:`/apps/${encodeURIComponent(e)}?preview=draft`),onDraftArtifacts:e=>{for(let t of e)v(t)},fetchPendingDraftCount:ee,onPublishDrafts:async e=>{try{let t=await fetch(`/api/v1/packages/${encodeURIComponent(e)}/publish-drafts`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error?.message||`HTTP ${t.status}`);let r=n?.data?.failedCount??n?.failedCount??0;if(r)throw Error(String(r));let i=n?.data?.seedApplied??n?.seedApplied;i&&i.success===!1?h.warning(U.seedWarn,{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):h.success(U.publishOk);let a=(n?.data?.published??n?.published??[]).find(e=>e?.type===`app`&&e?.name);return a?.name&&L(`/apps/${encodeURIComponent(a.name)}`),{ok:!0,health:re(n)}}catch(e){return h.error(U.publishFailed,{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:U.publishDrafts,nextStepsLabel:U.nextSteps,planTitleLabel:U.planTitle,planQuestionsLabel:U.planQuestions,planAssumptionsLabel:U.planAssumptions,planApproveHintLabel:U.planApproveHint,planApproveLabel:U.planApprove,planAdjustLabel:U.planAdjust,planBuiltLabel:U.planBuilt,planApproveMessage:U.planApproveMessage,planApproveDefaultsMessage:U.planApproveDefaultsMessage,planAnswerMessage:U.planAnswer,publishedLabel:U.published,autoPublishDrafts:k().features.autoPublishAiBuilds}),P&&(0,N.jsx)(p,{open:he,onOpenChange:$,objectName:`ai_conversations`,recordId:P,recordLabel:`this conversation`,apiBase:ge})]})}function V({appLabel:e,appName:t,objects:n,apiBase:r,defaultAgent:i,showAgentPicker:a,defaultOpen:o=!1,userId:s}){let c=A.useMemo(()=>L(r),[r]),l={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},u=l.VITE_AI_DEFAULT_AGENT,{agents:d,isLoading:f,error:p}=S({apiBase:c}),m=M({agents:d,showAgentPickerProp:a,envOptIn:l.VITE_AI_SHOW_AGENT_PICKER===`true`,aiStudioEnabled:k().features.aiStudio!==!1}),[h,g]=A.useState(void 0);A.useEffect(()=>{if(!h&&d.length>0){let e=O(d,i??u);e&&g(e)}},[d,h,i,u]);let _=h?`${c}/agents/${encodeURIComponent(h)}/chat`:void 0,{conversationId:v,initialMessages:b}=y({userId:h?s:void 0,scope:h,apiBase:c});return(0,N.jsx)(B,{appLabel:e,appName:t,objects:n,agents:d,agentsLoading:f,agentsError:p,activeAgent:h,onAgentChange:g,showAgentPicker:m,chatApi:_,apiBase:c,defaultOpen:o,conversationId:v,initialMessages:b},`${_??`local`}:${v??`pending`}`)}export{V as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i}from"./vendor-react-ClIa1CJA.js";import{f as a}from"./infrastructure-HR_Bc4bJ.js";import{A as o,f as s,i as c,k as l}from"./framework-D5XqsLzE.js";import{$r as u,Bn as d,Bs as f,Cr as p,Ga as m,H as h,Hn as g,Hr as _,Is as v,R as y,Rn as b,Ua as x,Un as S,Vn as C,Vs as w,Wi as T,Zi as E,fc as D,gr as O,wc as ee,z as k,zn as te,zr as A}from"./ui-components-DiLX53DV.js";import{r as j}from"./vendor-ui-utils-C92Fl7BT.js";import"./AdapterProvider-BNg96rLB.js";import{n as ne}from"./plugin-form-CnIr9O51.js";import"./MetadataProvider-QdHbK1P5.js";import{r as re}from"./ExpressionProvider-Tm4jr_3p.js";import{Z as ie,v as M}from"./ReportDefaultInspector-CoX9gMMh.js";import{n as N}from"./utils-29quoGQV.js";import{n as ae,r as oe,t as se}from"./MetadataInspector-Cx8ePTT_.js";import{n as P,t as F}from"./DashboardWidgetInspector-BR98NQH8.js";import{i as ce,n as I,t as le}from"./useOpenRecordList-D2EZK86D.js";import{n as ue}from"./skeletons-B4Te484-.js";import{n as de}from"./plugin-dashboard-Bru0NpLD.js";var L=e(n(),1),R=i();function fe({open:e,onClose:t,schema:n,selectedWidgetId:r,onSelectWidget:i,onSave:a,onChange:o,onRemoveWidget:s,name:l,metadataClient:u,onAfterChange:d}){let{t:f}=c(),m=(0,L.useMemo)(()=>M(),[]),[h,g]=(0,L.useState)(!1),[v,y]=(0,L.useState)(0),b=(0,L.useCallback)(e=>{g(!0),o({...n??{},...e})},[n,o]),x=(0,L.useCallback)(e=>{o(e),g(!1)},[o]),S=(0,L.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),C=Array.isArray(n?.widgets)?n.widgets:[],w=r?C.find(e=>e?.id===r):null;if(!e)return null;let T=typeof n?.name==`string`?n.name:``,E=w?f(`widget.editor.title`,{defaultValue:`Edit widget`}):f(`dashboard.editor.title`,{defaultValue:`Edit dashboard`});return(0,R.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`dashboard-config-panel`,role:`complementary`,"aria-label":E,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[w&&(0,R.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>i(null),className:`h-7 w-7 p-0`,"aria-label":f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),title:f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),"data-testid":`dashboard-config-back`,children:(0,R.jsx)(D,{className:`h-4 w-4`})}),(0,R.jsx)(`div`,{className:`text-sm font-medium truncate`,children:E})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&s&&(0,R.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>s(r),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"aria-label":f(`widget.editor.delete`,{defaultValue:`Delete widget`}),title:f(`widget.editor.delete`,{defaultValue:`Delete widget`}),"data-testid":`widget-delete-button`,children:(0,R.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(O,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":f(`common.close`,{defaultValue:`Close`}),"data-testid":`dashboard-config-close`,children:(0,R.jsx)(p,{className:`h-4 w-4`})})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:w?(0,R.jsx)(F,{type:`dashboard`,name:T,draft:n??{},selection:{kind:`widget`,id:r},onPatch:b,onClearSelection:()=>i(null),onSelectionChange:S,readOnly:!1,locale:m}):(0,R.jsx)(P,{type:`dashboard`,name:T,draft:n??{},onPatch:b,onSelectionChange:S,readOnly:!1,locale:m})}),(0,R.jsxs)(`div`,{"data-testid":`dashboard-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,R.jsx)(I,{type:`dashboard`,name:l||T||void 0,metadataClient:u,dirty:h,onResume:x,savedSignal:v,onAfterChange:d}),(0,R.jsx)(O,{size:`sm`,onClick:()=>{a(n??{}),g(!1),y(e=>e+1)},"data-testid":`dashboard-config-save`,children:f(`common.save`,{defaultValue:`Save`})})]})]})}var z=t({DashboardView:()=>U}),B=[{type:`metric`,label:`KPI Metric`,Icon:A},{type:`bar`,label:`Bar Chart`,Icon:w},{type:`line`,label:`Line Chart`,Icon:f},{type:`pie`,label:`Pie Chart`,Icon:v},{type:`table`,label:`Table`,Icon:u},{type:`pivot`,label:`Pivot`,Icon:x}],V=0;function H(){return V+=1,`widget_${Date.now()}_${V}`}function pe(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:H()})}}function me(e){let t=B.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function U({dataSource:e}){let t=le(),{dashboardName:n}=r(),{showDebug:i}=ae(),u=l(),f=ie(),{t:p}=c(),{dashboardLabel:_,dashboardDescription:v}=ee(),{user:x}=a(),w=x?.role===`admin`,[D,A]=(0,L.useState)(!0),[M,P]=(0,L.useState)(!1),[F,I]=(0,L.useState)(null),[z,V]=(0,L.useState)(null),U=(0,L.useCallback)(e=>{V(t=>(t&&t.resolve(e),null))},[]),he=(0,L.useCallback)(e=>new Promise(t=>{let n;if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);if(t){let e=t[1];n={objectName:t[2],mode:e===`edit`||e===`update`?`edit`:`create`}}else n={objectName:e,mode:`create`}}else n=e;V({schema:n,resolve:t})}),[]),ge=(0,L.useMemo)(()=>({export_dashboard_pdf:async()=>{j.info(p(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return j.error(p(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(j.info(p(`dashboardActions.forecastSoon`)),{success:!0})}),[p]);(0,L.useEffect)(()=>{A(!0),J(null),P(!1),I(null),queueMicrotask(()=>A(!1))},[n]);let{dashboards:_e,objects:W,refresh:G}=o(),{app:ve}=re(),K=oe(_e,n,ve?._packageId),[q,J]=(0,L.useState)(null);(0,L.useEffect)(()=>{M||J(null)},[K]);let Y=(0,L.useCallback)(async e=>{try{f&&await ce(`dashboard`,n,e,{metadataClient:f}),G().catch(()=>{})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[DashboardView] Auto-save failed:`,e),j.error(`Failed to save dashboard: ${t}`)}},[f,n,G]),ye=(0,L.useCallback)(()=>{J(pe(K)),P(!0)},[K]),be=(0,L.useCallback)(()=>{P(!1),I(null)},[]),X=(0,L.useCallback)(e=>{if(!q)return;let t=H(),n={id:t,title:me(e),type:e,layout:{x:0,y:q.widgets?.length??0,w:q.columns??2,h:1}},r={...q,widgets:[...q.widgets||[],n]};J(r),Y(r),I(t)},[q,Y]),xe=(0,L.useCallback)(e=>{if(!q)return;let t={...q,widgets:q.widgets.filter(t=>t.id!==e)};J(t),Y(t),F===e&&I(null)},[q,F,Y]),Se=(0,L.useCallback)(e=>{let t=q||K;if(!t)return;let n={...t,widgets:e};J(n),Y(n)},[q,K,Y]),Ce=(q||K)??null,Z=(0,L.useMemo)(()=>new Set((W||[]).map(e=>e?.name).filter(Boolean)),[W]),Q=q||K,$=(0,L.useMemo)(()=>{if(!Q||Z.size===0)return Q;let e=Q.widgets;if(!Array.isArray(e)||e.length===0)return Q;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return t?Z.has(t):!0});return t.length===e.length?Q:{...Q,widgets:t}},[Q,Z]);return D?(0,R.jsx)(ue,{}):K?(0,R.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=N(($||K).title,p),t=N(K.label,p),n=_({name:K.name,label:t});return(0,R.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||K.name})})(),(()=>{let e=($||K).description??K.description,t=v({name:K.name,description:N(e,p)});return t?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]}),(0,R.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[M&&(0,R.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:B.map(({type:e,label:t,Icon:n})=>(0,R.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>X(e),className:`inline-flex items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,title:`Add ${t}`,"aria-label":`Add ${t} widget`,children:[(0,R.jsx)(T,{className:`h-3 w-3`}),(0,R.jsx)(n,{className:`h-3 w-3`})]},e))}),w&&(0,R.jsxs)(`button`,{type:`button`,onClick:ye,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`dashboard-edit-button`,children:[(0,R.jsx)(E,{className:`h-3.5 w-3.5`}),p(`common.edit`,{defaultValue:`Edit`})]})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,R.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,R.jsx)(s,{value:{openRecordList:t},children:(0,R.jsx)(de,{schema:$,dataSource:e,designMode:M,selectedWidgetId:F,onWidgetClick:I,onWidgetsReorder:Se,modalHandler:he,scriptHandlers:ge,hideHeaderText:!0})})}),(0,R.jsx)(fe,{open:M&&w,onClose:be,schema:Ce,selectedWidgetId:F,onSelectWidget:I,onSave:Y,onChange:J,onRemoveWidget:xe,name:n,metadataClient:f,onAfterChange:()=>G().catch(()=>{})}),(0,R.jsx)(se,{open:i,sections:[{title:`Dashboard Configuration`,data:$}]})]}),z&&z.schema?.objectName?(0,R.jsx)(ne,{schema:{type:`object-form`,formType:`modal`,objectName:z.schema.objectName,mode:z.schema.mode||`create`,recordId:z.schema.recordId,title:z.schema.title,description:z.schema.description,fields:z.schema.fields,open:!0,onOpenChange:e=>{e||U({success:!1})},onSuccess:e=>{U({success:!0,reload:!0,data:e})},onCancel:()=>{U({success:!1})},showSubmit:!0,showCancel:!0},dataSource:u}):z?(0,R.jsx)(b,{open:!0,onOpenChange:e=>{e||U({success:!1})},children:(0,R.jsxs)(te,{children:[(0,R.jsxs)(g,{children:[(0,R.jsx)(S,{children:z.schema?.title||p(`actionDialog.defaultActionTitle`)}),z.schema?.description&&(0,R.jsx)(d,{children:z.schema.description})]}),(0,R.jsxs)(C,{children:[(0,R.jsx)(O,{variant:`outline`,onClick:()=>U({success:!1}),children:p(`actionDialog.cancel`)}),(0,R.jsx)(O,{onClick:()=>U({success:!0}),children:p(`actionDialog.ok`)})]})]})}):null]}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(y,{children:[(0,R.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,R.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(h,{children:p(`empty.dashboardNotFound`)}),(0,R.jsx)(k,{children:p(`empty.dashboardNotFoundDescription`,{name:n})})]})})}export{z as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{R as r,l as i,m as a}from"./vendor-objectstack-C1teU2a6.js";import{$r as o,$t as s,An as c,Bs as l,Bt as u,Ci as d,Cr as f,Es as p,Fa as m,Fn as h,Fs as g,Go as _,Hs as v,Ht as y,In as b,Is as x,Jo as S,Mn as ee,Nn as C,Ns as w,Pn as te,Rs as T,Ut as E,Vr as D,Vt as O,Wi as k,Wt as A,_c as j,ao as M,co as ne,en as re,er as ie,gr as N,is as ae,nn as P,on as F,tn as oe,vc as I,zs as se}from"./ui-components-DiLX53DV.js";import{G as ce,J as le,K as ue,U as de,V as fe,W as L,Z as R,_ as pe,a as me,g as he,i as ge,j as _e,p as ve,q as ye,r as be,t as xe,y as z}from"./ReportDefaultInspector-CoX9gMMh.js";var B=e(t(),1),V=n();function Se(e,t){if(!t)return!0;let n=t.toLowerCase();return e.value.toLowerCase().includes(n)||e.label.toLowerCase().includes(n)||(e.group?.toLowerCase().includes(n)??!1)}function H({label:e,value:t,onCommit:n,options:r,placeholder:i=`Select…`,searchPlaceholder:a=`Search or type…`,emptyText:o=`No match — keep typing to use a custom value.`,disabled:l,loading:u,allowCustom:d=!0,mono:f,className:m}){let[g,_]=B.useState(!1),[v,y]=B.useState(``),x=r.find(e=>e.value===t),S=x?x.label:t||(u?`Loading…`:i),T=B.useMemo(()=>r.filter(e=>Se(e,v)),[r,v]),E=B.useMemo(()=>{let e=[],t=new Map;for(let n of T){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[T]),D=v.trim(),O=d&&!!D&&!r.some(e=>e.value===D),k=e=>{n(e),_(!1),y(``)},A=(0,V.jsxs)(s,{open:g,onOpenChange:e=>{_(e),e||y(``)},children:[(0,V.jsx)(oe,{asChild:!0,children:(0,V.jsxs)(N,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":g,disabled:l,className:I(`h-8 w-full justify-between px-2 text-sm font-normal`,m),children:[(0,V.jsx)(`span`,{className:I(`truncate`,f&&`font-mono`,!x&&!t&&`text-muted-foreground`),children:S}),(0,V.jsx)(p,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,V.jsx)(re,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,V.jsxs)(c,{shouldFilter:!1,children:[(0,V.jsx)(te,{value:v,onValueChange:y,placeholder:a}),(0,V.jsxs)(b,{children:[!O&&T.length===0&&(0,V.jsx)(ee,{children:o}),O&&(0,V.jsx)(C,{children:(0,V.jsx)(h,{value:`__custom__${D}`,onSelect:()=>k(D),children:(0,V.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,V.jsxs)(`span`,{className:`font-mono`,children:[`“`,D,`”`]})]})})}),E.map((e,n)=>(0,V.jsx)(C,{heading:e.heading||void 0,children:e.items.map(e=>(0,V.jsxs)(h,{value:e.value,onSelect:()=>k(e.value),children:[(0,V.jsx)(w,{className:I(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,V.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,V.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,V.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(F,{className:`text-xs text-muted-foreground`,children:e}),A]}):A}var Ce=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function U(e,t){if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`&&t)return t}return t}function we(e){let t=e.reference??e.reference_to??e.referenceTo??e.reference_to_object;if(typeof t==`string`&&t)return t;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0];if(t&&typeof t==`object`){let e=t.object;if(typeof e==`string`&&e)return e}}function Te(e){switch(e){case`lookup`:case`master_detail`:case`masterDetail`:case`master-detail`:return`lookup`;case`date`:case`datetime`:case`time`:return`date`;case`number`:case`currency`:case`percent`:case`int`:case`integer`:case`float`:case`double`:case`autonumber`:return`number`;case`boolean`:case`toggle`:return`boolean`;default:return`string`}}function W(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=U(e.label,t),r=_e(e.fields).entries.map(e=>({name:e.name,label:U(e.def.label,e.name),type:typeof e.def.type==`string`?e.def.type:void 0,def:e.def}));return{label:n,fields:r,relationships:r.filter(e=>e.type&&Ce.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:we(e.def)}))}}function Ee(e,t,n){let r=e.fields.map(t=>({value:t.name,label:t.label,type:t.type,group:e.label}));for(let i of t){let t=e.relationships.find(e=>e.name===i),a=t?.referenceTo?n[t.referenceTo]:void 0;if(!a)continue;let o=`${t.label} → ${a.label}`;for(let e of a.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:o})}return r}function G(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>G(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&G(e,t))}function K(){let e=R(),[t,n]=B.useState({options:[],loading:!0});return B.useEffect(()=>{let t=!1;return n(e=>({...e,loading:!0})),e.list(`object`).then(e=>{t||n({options:(Array.isArray(e)?e:[]).map(e=>({name:typeof e.name==`string`?e.name:``,label:U(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label)),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function De(e,t){let n=R(),r=t.join(`\0`),[i,a]=B.useState({relationships:[],fieldOptions:[],loading:!!e});return B.useEffect(()=>{if(!e){a({relationships:[],fieldOptions:[],loading:!1});return}let t=!1;return a(e=>({...e,loading:!0})),(async()=>{try{let i=await n.get(`object`,e);if(t)return;let o=W(i,e),s=new Set;for(let e of r?r.split(`\0`):[]){let t=o.relationships.find(t=>t.name===e);t?.referenceTo&&s.add(t.referenceTo)}let c=await Promise.all([...s].map(async e=>{try{return[e,W(await n.get(`object`,e),e)]}catch{return[e,W(null,e)]}}));if(t)return;let l=Object.fromEntries(c),u=r?r.split(`\0`):[];a({relationships:o.relationships,fieldOptions:Ee(o,u,l),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Oe(e){let t=R(),[n,r]=B.useState({reports:0,dashboards:0,loading:!!e});return B.useEffect(()=>{if(!e){r({reports:0,dashboards:0,loading:!1});return}let n=!1;return r(e=>({...e,loading:!0})),(async()=>{let[i,a]=await Promise.all([t.list(`report`).catch(()=>[]),t.list(`dashboard`).catch(()=>[])]);n||r({reports:(Array.isArray(i)?i:[]).filter(t=>G(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>G(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var q={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:M},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:se},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:T},line:{id:`line`,label:`Line chart`,category:`chart`,icon:l},area:{id:`area`,label:`Area chart`,category:`chart`,icon:v},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:x},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:_},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:g},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:D},table:{id:`table`,label:`Data table`,category:`data`,icon:o},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:S},list:{id:`list`,label:`Record list`,category:`data`,icon:m},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:ae}},ke={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},J=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(q).filter(t=>t.category===e)})),Y=j;function X({onAdd:e,label:t=`Add widget`}){let[n,r]=B.useState(!1),[i,a]=B.useState(``),o=B.useRef(null),s=B.useRef(null);B.useEffect(()=>{if(!n){a(``);return}let e=e=>{o.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>s.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let c=B.useMemo(()=>{let e=i.trim().toLowerCase();return e?J.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):J},[i]);return(0,V.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:()=>r(e=>!e),children:[(0,V.jsx)(k,{className:`h-3 w-3`}),t]}),n&&(0,V.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,V.jsx)(d,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,V.jsx)(`input`,{ref:s,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search widgets…`,className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,V.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,V.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:ke[t.category]}),t.types.map(t=>(0,V.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,V.jsx)(q[t.id]?.icon??Y,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,V.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var Ae={io:`input`,unrepresentable:`any`},je=new Set([`widgets`,`label`,`description`,`name`]),Z,Me=!1;function Ne(){if(Z||Me)return Z;try{Z=r(i,Ae)}catch(e){Me=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Pe(){if(Q)return Q;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!je.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Q=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return Q}}var Fe=new Set([`name`,`label`,`description`,`widgets`]);function Ie({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=B.useCallback(e=>z(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=B.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),u=e=>{let n=le(`widget`,l.map(e=>e?.id).filter(Boolean)),r=q[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:ce(l,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},d=e=>{t({widgets:ye(l,e,null)})},p=(e,n)=>{e!==n&&t({widgets:ue(l,e,n)})},m=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[h,g]=B.useState(null),[_,v]=B.useState(null),{schema:y,form:b}=B.useMemo(()=>me({bundledSchema:Ne(),bundledForm:Pe(),serverSchema:a,excludeFields:Fe,sectionTitle:z(`engine.inspector.moreFields`,r)}),[a,r]);return(0,V.jsxs)(de,{kindLabel:o(`engine.inspector.dashboard.kind`),title:String(s||e.name||o(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,V.jsx)(L,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,V.jsx)(L,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,V.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(F,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,V.jsx)(ie,{variant:`outline`,className:`text-[10px]`,children:l.length})]}),l.length===0?(0,V.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.widgetsEmpty`)}):(0,V.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let r=q[e?.type]?.icon??Y;return(0,V.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{h!=null&&h!==t&&p(h,t),g(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&h!==null&&h!==t?` border-primary`:``),children:[!n&&(0,V.jsx)(ne,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,V.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>m(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,V.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>d(t),title:o(`engine.inspector.dashboard.removeWidget`),"aria-label":o(`engine.inspector.dashboard.removeWidget`),children:(0,V.jsx)(f,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,V.jsx)(X,{onAdd:u,label:o(`engine.inspector.add.widget`)})]}),(0,V.jsx)(`div`,{className:`border-t pt-3`,children:y?(0,V.jsx)(ve,{schema:y,form:b,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,V.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Le=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],Re=[`count`,`sum`,`avg`,`min`,`max`],ze=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Be(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function Ve({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let s=Array.isArray(e.widgets)?e.widgets:[],c=t.kind===`widget`?t.id:void 0,l=c?Be(e,c):null,d=l?.widget??{},p=typeof d.dataset==`string`?d.dataset:``,m=typeof d.object==`string`?d.object:``,h=Array.isArray(d.dimensions)?d.dimensions.filter(e=>typeof e==`string`):[],g=Array.isArray(d.values)?d.values.filter(e=>typeof e==`string`):[],_=be(),v=ge(p||void 0,_),{options:b,loading:x}=K(),{fields:S}=he(m||void 0),ee=B.useMemo(()=>{let e=_.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return p&&!e.some(e=>e.value===p)&&e.push({value:p,label:p}),e},[_.datasets,p]),C=B.useMemo(()=>b.map(e=>({value:e.name,label:e.label})),[b]),w=B.useMemo(()=>S.map(e=>({value:e.name,label:e.label,hint:e.type})),[S]),te=B.useMemo(()=>v.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[v.measures]),T=B.useMemo(()=>v.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[v.dimensions]);if(t.kind!==`widget`)return(0,V.jsx)(He,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!l)return(0,V.jsx)(He,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:D,index:k}=l;function j(e){let t=[...s];t[k]={...t[k],...e},n({widgets:t})}function M(e){n({widgets:ue(s,k,e)}),D.id&&i?.({kind:`widget`,id:D.id,label:D.title??void 0})}return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:z(`engine.inspector.widget.kind`,o)}),(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:D.title||t.label||`Widget ${k+1}`})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,V.jsx)(fe,{index:k,total:s.length,onMove:M,upLabel:z(`engine.inspector.reorder.up`,o),downLabel:z(`engine.inspector.reorder.down`,o),disabled:a}),(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:z(`engine.inspector.widget.close`,o),"aria-label":z(`engine.inspector.widget.close`,o),children:(0,V.jsx)(f,{className:`h-3.5 w-3.5`})})]})]}),(0,V.jsx)($,{id:`widget-title`,label:z(`engine.inspector.widget.title`,o),children:(0,V.jsx)(P,{id:`widget-title`,value:D.title??``,onChange:e=>j({title:e.target.value}),disabled:a})}),(0,V.jsx)($,{id:`widget-type`,label:z(`engine.inspector.widget.type`,o),children:(0,V.jsxs)(u,{value:D.type??`metric`,onValueChange:e=>j({type:e}),disabled:a,children:[(0,V.jsx)(E,{id:`widget-type`,children:(0,V.jsx)(A,{})}),(0,V.jsx)(O,{children:Le.map(e=>(0,V.jsx)(y,{value:e.value,children:e.label},e.value))})]})}),(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,V.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:z(`engine.inspector.widget.datasetSection`,o)}),(0,V.jsxs)($,{id:`widget-dataset`,label:z(`engine.inspector.widget.dataset`,o),children:[(0,V.jsx)(H,{value:p,onCommit:e=>j({dataset:e||void 0}),options:ee,loading:_.loading,placeholder:z(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:z(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,V.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:z(`engine.inspector.widget.datasetHint`,o)})]}),p&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xe,{label:z(`engine.inspector.widget.dimensions`,o),emptyText:z(`engine.inspector.widget.dimensionsHint`,o),names:h,options:T,loading:v.loading,error:v.error,readOnly:a,onCommit:e=>j({dimensions:e})}),(0,V.jsx)(xe,{label:z(`engine.inspector.widget.values`,o),emptyText:z(`engine.inspector.widget.valuesHint`,o),names:g,options:te,loading:v.loading,error:v.error,readOnly:a,onCommit:e=>j({values:e})})]})]}),(0,V.jsx)($,{id:`widget-object`,label:z(`engine.inspector.widget.object`,o),children:(0,V.jsx)(H,{value:D.object??``,onCommit:e=>j({object:e||void 0}),options:C,loading:x,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-value-field`,label:z(`engine.inspector.widget.valueField`,o),children:(0,V.jsx)(H,{value:D.valueField??``,onCommit:e=>j({valueField:e||void 0}),options:w,placeholder:D.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-category-field`,label:z(`engine.inspector.widget.categoryField`,o),children:(0,V.jsx)(H,{value:D.categoryField??``,onCommit:e=>j({categoryField:e||void 0}),options:w,placeholder:D.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-aggregate`,label:z(`engine.inspector.widget.aggregate`,o),children:(0,V.jsxs)(u,{value:D.aggregate??`count`,onValueChange:e=>j({aggregate:e}),disabled:a,children:[(0,V.jsx)(E,{id:`widget-aggregate`,children:(0,V.jsx)(A,{})}),(0,V.jsx)(O,{children:Re.map(e=>(0,V.jsx)(y,{value:e,children:e},e))})]})}),(0,V.jsx)($,{id:`widget-color`,label:z(`engine.inspector.widget.color`,o),children:(0,V.jsx)(pe,{value:D.colorVariant??`default`,onChange:e=>j({colorVariant:e}),disabled:a,options:ze.map(e=>({value:e}))})}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsx)($,{id:`widget-w`,label:z(`engine.inspector.widget.width`,o),children:(0,V.jsx)(P,{id:`widget-w`,type:`number`,min:1,value:D.layout?.w??1,onChange:e=>j({layout:{...D.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,V.jsx)($,{id:`widget-h`,label:z(`engine.inspector.widget.height`,o),children:(0,V.jsx)(P,{id:`widget-h`,type:`number`,min:1,value:D.layout?.h??1,onChange:e=>j({layout:{...D.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,V.jsx)(`div`,{className:`pt-2 border-t`,children:(0,V.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(k,1),n({widgets:t}),r()},children:z(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(F,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function He({message:e,onClose:t,locale:n}){return(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,V.jsx)(`p`,{children:e}),(0,V.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:z(`engine.inspector.widget.close`,n)})]})}export{Te as a,K as c,q as i,H as l,Ie as n,De as o,X as r,Oe as s,Ve as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{W as r,yt as i}from"./framework-D5XqsLzE.js";var a=e(t(),1),o=n(),s=(0,a.createContext)(null);function c({children:e,user:t={},app:n={},data:c={},features:l={}}){let u=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l,evaluator:new i({user:t,app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}};return{...e,evaluator:new i(e)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{k as r}from"./framework-D5XqsLzE.js";import{Ft as i,Gt as a,Ii as o,It as s,Jn as c,Ki as l,Lt as u,Mt as d,Pa as f,Pt as p,Qn as m,Rt as h,Tr as g,Xn as _,Yn as v,Zn as y,cs as b,ct as x,dt as S,er as C,ft as w,gr as T,lt as E,nn as D,on as O,ot as k,ps as A,st as j,tt as M,ut as N,ws as P,xs as F}from"./ui-components-DiLX53DV.js";import"./src-DzwWvy9u.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:F,cls:`text-emerald-600 border-emerald-300`},completed:{icon:F,cls:`text-emerald-600 border-emerald-300`},failed:{icon:A,cls:`text-red-600 border-red-300`},error:{icon:A,cls:`text-red-600 border-red-300`},running:{icon:f,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:b,cls:`text-amber-600 border-amber-300`},skipped:{icon:P,cls:`text-muted-foreground`}}[e]??{icon:P,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(C,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,a]=(0,I.useState)(!0),[s,l]=(0,I.useState)(null),[u,f]=(0,I.useState)(``),[p,h]=(0,I.useState)(0),b=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),a(!1);return}a(!0),l(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!u&&r.length>0&&f(r[0].name)}catch(e){l(e?.message??String(e))}finally{a(!1)}},[e,u]);(0,I.useEffect)(()=>{b()},[b]);let x=(0,I.useMemo)(()=>t.find(e=>e.name===u)??null,[t,u]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(g,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(c,{children:[(0,L.jsx)(y,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(m,{className:`text-base`,children:`Flow`}),(0,L.jsx)(_,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(T,{variant:`outline`,size:`sm`,onClick:b,disabled:i,children:[(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(v,{children:[i&&(0,L.jsx)(d,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!i&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!s&&t.length>0&&(0,L.jsx)(`select`,{value:u,onChange:e=>f(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),x&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:x.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:x.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,a]=(0,I.useState)({}),[o,s]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[p,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{a({}),d(null),h(null)},[t?.name]);let g=(e,t)=>a(n=>({...n,[e]:t}));return(0,L.jsxs)(c,{children:[(0,L.jsxs)(y,{className:`pb-3`,children:[(0,L.jsx)(m,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(_,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(v,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(O,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(C,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(w,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>g(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(M,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(D,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(T,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}s(!0),h(null),d(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}d(await e.automation.execute(t.name,{params:a})),n?.()}catch(e){h(e?.message??String(e))}finally{s(!1)}},disabled:o,size:`sm`,children:[o?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2`}),o?`Running…`:`Run Flow`]})}),(u||p)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[p||u?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(F,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof u?.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono`,children:[u.durationMs,` ms`]})]}),p&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:p}),u&&(0,L.jsx)(V,{data:u})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,l]=(0,I.useState)([]),[g,b]=(0,I.useState)(!0),[w,D]=(0,I.useState)(null),[O,A]=(0,I.useState)(null),[M,P]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){D(`automation.listRuns is not available on this client`),b(!1);return}b(!0),D(null);try{let n=await e.automation.listRuns(t,{limit:20});l(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){D(e?.message??String(e))}finally{b(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{A(n),P(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);P(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(c,{children:[(0,L.jsx)(y,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(m,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(_,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(T,{variant:`outline`,size:`sm`,onClick:W,disabled:g,children:[g?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(v,{children:[g&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(d,{className:`h-8 w-full`}),(0,L.jsx)(d,{className:`h-8 w-full`}),(0,L.jsx)(d,{className:`h-8 w-full`})]}),!g&&w&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:w}),!g&&!w&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!g&&!w&&r.length>0&&(0,L.jsxs)(k,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(S,{children:[(0,L.jsx)(E,{children:`Run`}),(0,L.jsx)(E,{children:`Status`}),(0,L.jsx)(E,{children:`Started`}),(0,L.jsx)(E,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(S,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(x,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(x,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(x,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(x,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(p,{open:!!O,onOpenChange:e=>{e||(A(null),P(null))},children:(0,L.jsxs)(i,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(u,{className:`p-4 border-b`,children:[(0,L.jsxs)(h,{className:`font-mono text-sm break-all`,children:[`Run `,O]}),(0,L.jsx)(s,{children:M&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:M.status}),typeof M.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono`,children:[M.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(M.startedAt)})]})})]}),(0,L.jsxs)(a,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(d,{className:`h-16 w-full`}),(0,L.jsx)(d,{className:`h-16 w-full`}),(0,L.jsx)(d,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&M&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(M.steps)&&M.steps.length>0?M.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(C,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:M})]})})]})]})})]})}export{H as FlowRunsPage};
|