@yuku123/z-cognition-component 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/dist-lib/BaseInput-DHrGPDB9.js +1096 -0
  2. package/dist-lib/ClockCircleOutlined-DP6fSLgk.js +12 -0
  3. package/dist-lib/Collapse-B77SsmFh.js +523 -0
  4. package/dist-lib/{ConceptsPage-BOeKdDKI.js → ConceptsPage-DOf_CJlz.js} +13 -16
  5. package/dist-lib/DeleteOutlined-BAZSAooQ.js +12 -0
  6. package/dist-lib/{DocsPage-BZOBFp3c.js → DocsPage-CiC7TU96.js} +4 -4
  7. package/dist-lib/EllipsisOutlined-Dr4orLLw.js +1109 -0
  8. package/dist-lib/EvidenceFormList-CrE2FzHk.js +90 -0
  9. package/dist-lib/{EyeOutlined-DGSrX-0M.js → EyeOutlined-CudyDdjH.js} +1 -1
  10. package/dist-lib/ImpactPage-CYiuqy0S.js +68 -0
  11. package/dist-lib/{LeftOutlined-Cgo6Izj-.js → LeftOutlined-CJasZIyX.js} +1 -1
  12. package/dist-lib/{OntologyDetailPage-B8DyU8WW.js → OntologyDetailPage-mgK_NQxP.js} +99 -93
  13. package/dist-lib/{OntologyInferPage-CvcjxpBB.js → OntologyInferPage-NUaoaQpN.js} +38 -40
  14. package/dist-lib/{OntologyListPage-Cb0XfpWE.js → OntologyListPage-C9wH01y0.js} +47 -49
  15. package/dist-lib/OntologyMaterializePage-D_fDqYHY.js +134 -0
  16. package/dist-lib/OntologyNodesPage-5kH7RHwE.js +2844 -0
  17. package/dist-lib/{OntologyValidatePage-abQVJwzV.js → OntologyValidatePage-DtkYK_l4.js} +49 -52
  18. package/dist-lib/Pagination-BJ8wnqAa.js +1112 -0
  19. package/dist-lib/PlusOutlined-BSTPGLOH.js +21 -0
  20. package/dist-lib/{ReloadOutlined-CS-e-TmN.js → ReloadOutlined-B26pDoyV.js} +19 -10
  21. package/dist-lib/{ResolvePage-rbQ-8nNZ.js → ResolvePage-Cz9HORZ3.js} +31 -33
  22. package/dist-lib/{RotateRightOutlined-q7zp2e47.js → RotateRightOutlined-DqyspFCO.js} +1 -1
  23. package/dist-lib/Skeleton-CxFsInYI.js +671 -0
  24. package/dist-lib/Table-Civ838nE.js +20514 -0
  25. package/dist-lib/{Table-CDagah-g.js → Table-J_7eBbi7.js} +414 -414
  26. package/dist-lib/TermDetailPage-BtkOpbPT.js +263 -0
  27. package/dist-lib/{TermsPage-CuufAyuL.js → TermsPage-BuzCMYov.js} +28 -31
  28. package/dist-lib/_commonjsHelpers-DaMA6jEr.js +8 -0
  29. package/dist-lib/accessAk-CA30m5eX.js +64 -0
  30. package/dist-lib/{agents-mAJW3cEN.js → agents-eZDKzePP.js} +41 -41
  31. package/dist-lib/{ai-BcYmZiRo.js → ai-CNSn3-sd.js} +32 -32
  32. package/dist-lib/{ai-chat-share-DO7GXjG4.js → ai-chat-share-Yrqt_J6a.js} +13 -14
  33. package/dist-lib/ak-manage-DklVFT5I.js +805 -0
  34. package/dist-lib/{approval-RPDUKg9-.js → approval-B-bCSmfi.js} +25 -26
  35. package/dist-lib/{approvals-CNjxJUpR.js → approvals-B0ggYiyD.js} +42 -43
  36. package/dist-lib/{assistant-FIQQziCn.js → assistant-Of0mgMsM.js} +33 -34
  37. package/dist-lib/{assistant-history-DsEGBJnq.js → assistant-history-DcyDhUzJ.js} +5 -5
  38. package/dist-lib/{assistant-summary-B-f3k55y.js → assistant-summary-CjLaTyFz.js} +1 -1
  39. package/dist-lib/{audit-NwnH1hm5.js → audit-wDNCfmOy.js} +1 -1
  40. package/dist-lib/{bios-CRwKtcit.js → bios-CIwO1AUK.js} +128 -130
  41. package/dist-lib/callSuper-CpMOVGin.js +7 -0
  42. package/dist-lib/callSuper-CwIeyYoc.js +7 -0
  43. package/dist-lib/category-9gqNseEa.js +76 -0
  44. package/dist-lib/causal-CzAYukj9.js +789 -0
  45. package/dist-lib/{changelog-DlL5u9o4.js → changelog-CQfIMS51.js} +2 -2
  46. package/dist-lib/changelog-sKJMQrlV.js +103 -0
  47. package/dist-lib/chat-panel-BPbqKckR.js +1543 -0
  48. package/dist-lib/chunk-6KYCQHYJ-DcgZQlO5.js +1627 -0
  49. package/dist-lib/code-space-D_ZE966E.js +1070 -0
  50. package/dist-lib/{colors-sdAcAcU3.js → colors-DpKdb8L-.js} +3 -3
  51. package/dist-lib/community-9_7ExHcm.js +70 -0
  52. package/dist-lib/community-CfWXxujB.js +217 -0
  53. package/dist-lib/community-material-page-Z_EZuBPl.js +747 -0
  54. package/dist-lib/connections-Bcqsp11M.js +1065 -0
  55. package/dist-lib/context-T27uno74.js +54 -0
  56. package/dist-lib/{createForOfIteratorHelper-DEx_aTey.js → createForOfIteratorHelper-CasBzL_Q.js} +1 -1
  57. package/dist-lib/{dayjs.min-BauDENhn.js → dayjs.min-DoEf5yCX.js} +1 -1
  58. package/dist-lib/detail-CV6xp_Jp.js +84 -0
  59. package/dist-lib/{detail-Cfb-zdr9.js → detail-DioaWKWj.js} +5847 -7224
  60. package/dist-lib/{detail-Dcfg3W8B.js → detail-EyLdjGpX.js} +71 -72
  61. package/dist-lib/development-CFcOIUKc.js +167 -0
  62. package/dist-lib/{docx-preview-B5nQuTwk.js → docx-preview-D4v2g8Yg.js} +1 -1
  63. package/dist-lib/{downloads-MkyxiHxi.js → downloads-DtV5hOQv.js} +3 -4
  64. package/dist-lib/{edit-DLGAM-Vo.js → edit-NtXUNj5N.js} +262 -266
  65. package/dist-lib/{editor-BtiheUpe.js → editor-KZhj-rwT.js} +25 -26
  66. package/dist-lib/editor-page-BaxK_OYm.js +1169 -0
  67. package/dist-lib/embed-mf8t3QXh.js +51841 -0
  68. package/dist-lib/embed.css +2 -2
  69. package/dist-lib/{evaluation-Dz9bUuhS.js → evaluation-CZTpC9v3.js} +14 -15
  70. package/dist-lib/execution-B6HmOA2_.js +159 -0
  71. package/dist-lib/focus-set-lt52maBX.js +38 -0
  72. package/dist-lib/{format-UGmYKemG.js → format-CWI99NCN.js} +1 -1
  73. package/dist-lib/graph-BllA9bmL.js +44 -0
  74. package/dist-lib/graph-DHV-rdiK.js +640 -0
  75. package/dist-lib/{index-o65vKUwa.js → index--AI-htgA.js} +44 -45
  76. package/dist-lib/index-2SysmGHo.js +1166 -0
  77. package/dist-lib/{index-CJSTTgTM.js → index-3J47mTL1.js} +10 -10
  78. package/dist-lib/index-4tbtbcAt.js +550 -0
  79. package/dist-lib/index-B12ZggsE.js +77 -0
  80. package/dist-lib/{index-D3GHtSlM.js → index-B5Roo82U.js} +49 -50
  81. package/dist-lib/{index-nQSVLWfW.js → index-B7SfTpox.js} +79 -81
  82. package/dist-lib/index-BEO8itgt.js +566 -0
  83. package/dist-lib/index-BPbOPT2j.js +413 -0
  84. package/dist-lib/index-BVgdmf6r.js +2487 -0
  85. package/dist-lib/index-Bd7AGv4a.js +34 -0
  86. package/dist-lib/index-BkJjYgKD.js +5012 -0
  87. package/dist-lib/{index-DBlG9uXV.js → index-BkTegt8T.js} +513 -590
  88. package/dist-lib/{index-BGB6NawZ.js → index-Bln3mJfp.js} +2 -2
  89. package/dist-lib/index-BoCtPJD4.js +915 -0
  90. package/dist-lib/{index-DMTPsTna.js → index-BqTsLClH.js} +3 -4
  91. package/dist-lib/index-Bs4MevzC.js +16075 -0
  92. package/dist-lib/index-BsoHetYT.js +236 -0
  93. package/dist-lib/{index-9aQ4BzIK.js → index-BvJ35WL3.js} +13 -14
  94. package/dist-lib/{index-BEjXaDfk.js → index-Bw4M9KLv.js} +84 -85
  95. package/dist-lib/index-C2CV4bte.js +242 -0
  96. package/dist-lib/{index-D_Qey9G8.js → index-CF0ucN_K.js} +12 -12
  97. package/dist-lib/{index-B57Fj7Y0.js → index-CLhLA2ig.js} +92 -94
  98. package/dist-lib/{index-Vu6sPBci.js → index-CSJA8wvL.js} +301 -296
  99. package/dist-lib/index-CSnvcFg-.js +543 -0
  100. package/dist-lib/{index-C3AMwzIi.js → index-CZipVp1G.js} +1 -1
  101. package/dist-lib/{index-ounfql2z.js → index-CdJ5ggvp.js} +26 -28
  102. package/dist-lib/index-CgwK2maq.js +1987 -0
  103. package/dist-lib/{index-Bc-Vin3j.js → index-CtqUgNxs.js} +53 -55
  104. package/dist-lib/index-CvxfA0ZK.js +215 -0
  105. package/dist-lib/{index-y7jVGGI0.js → index-CwyFMPcr.js} +16 -18
  106. package/dist-lib/index-D35Ry0PG.js +1162 -0
  107. package/dist-lib/{index-c2HokEFp.js → index-D6ns_Xmf.js} +10 -11
  108. package/dist-lib/{index-DsuUGhTA.js → index-DGbjbjBY.js} +46 -48
  109. package/dist-lib/index-DKAGVWMX.js +390 -0
  110. package/dist-lib/index-DQ16Zb7x.js +546 -0
  111. package/dist-lib/index-DRcTwC17.js +418 -0
  112. package/dist-lib/index-DU6bO95v.js +2075 -0
  113. package/dist-lib/index-DaMLYomP.js +853 -0
  114. package/dist-lib/index-Dd9pPAT3.js +2192 -0
  115. package/dist-lib/{index-DuI4K5e1.js → index-DgfIEgir.js} +29 -29
  116. package/dist-lib/{index-Cy9i4Kx7.js → index-DhSCFLtV.js} +113 -117
  117. package/dist-lib/index-DxzorPvG.js +13960 -0
  118. package/dist-lib/index-If4xc1-H.js +559 -0
  119. package/dist-lib/index-QZ9JPfVR.js +251 -0
  120. package/dist-lib/index-VeAMz0iC.js +1719 -0
  121. package/dist-lib/index-mUlorJxp.js +3279 -0
  122. package/dist-lib/{index-g16g7A4k.js → index-xQmDaKK3.js} +6 -6
  123. package/dist-lib/{index-BwVZgt5s.js → index-zXwXfn-X.js} +48 -50
  124. package/dist-lib/index.js +3 -4
  125. package/dist-lib/json-field-COcz5F2R.js +196 -0
  126. package/dist-lib/{jszip.min-DcEHhn-b.js → jszip.min-dcaDnWUw.js} +1 -1
  127. package/dist-lib/{kb-form-modal-BNoIhw6B.js → kb-form-modal-D9gnvXbE.js} +67 -67
  128. package/dist-lib/{kbTeam-EgcbWseM.js → kbTeam-CorrPJFr.js} +3 -3
  129. package/dist-lib/{knowledge-base-C023dnJ-.js → knowledge-base-DJkjMFHW.js} +103 -104
  130. package/dist-lib/{knowledge-hub-B4fGCn8m.js → knowledge-hub-DKiDlaZz.js} +54 -55
  131. package/dist-lib/login-56zv4aLO.js +36 -0
  132. package/dist-lib/{markdown-lite-EvJ9Fw7X.js → markdown-lite-p1tiuSZM.js} +198 -202
  133. package/dist-lib/material-DtPASeqq.js +204 -0
  134. package/dist-lib/material-draft-markdown-281d5_GN.js +443 -0
  135. package/dist-lib/material-original-preview-CPGjdmbe.js +214 -0
  136. package/dist-lib/{material-preview-docx-CH-09KeC.js → material-preview-docx-lp_xPipj.js} +1 -1
  137. package/dist-lib/{material-preview-pdf-CKAovvpc.js → material-preview-pdf-CTSo215V.js} +7 -7
  138. package/dist-lib/{material-preview-pptx-D8XGDF-u.js → material-preview-pptx-6Byitp0J.js} +1 -1
  139. package/dist-lib/material-workspace-model-QLsU5qUO.js +328 -0
  140. package/dist-lib/{member-BUg2QYlE.js → member-Cz-OIdj9.js} +1 -1
  141. package/dist-lib/memory-reorganization-DgJnWIrW.js +8 -0
  142. package/dist-lib/memory-spaces-D-orVNR7.js +2340 -0
  143. package/dist-lib/{message-GF-w8HuR.js → message-C9gfvpGg.js} +1 -1
  144. package/dist-lib/{message-Cwj8dO78.js → message-D6FhzB7J.js} +24 -25
  145. package/dist-lib/{messages-JID13L8-.js → messages-cctmEVcG.js} +15 -16
  146. package/dist-lib/meta-DT_O4zM9.js +708 -0
  147. package/dist-lib/{metrics-CT4eLzrq.js → metrics-BNeVcI8-.js} +2 -2
  148. package/dist-lib/mobile-D8kZjfQU.js +2413 -0
  149. package/dist-lib/{monitor-Bs9BfJOj.js → monitor-DTUyqumg.js} +4 -4
  150. package/dist-lib/{monitor-CmS65YSu.js → monitor-DexMYjzF.js} +8 -8
  151. package/dist-lib/{my-access-1Yj7UloI.js → my-access-DWBV6ohp.js} +120 -132
  152. package/dist-lib/{my-permissions-yQDHPLYI.js → my-permissions-B-gJZQYM.js} +22 -23
  153. package/dist-lib/navigation-DVlyWnpD.js +102 -0
  154. package/dist-lib/{new-BgkoBnZV.js → new-JmARyD88.js} +14 -15
  155. package/dist-lib/{ontology-BPrbXPor.js → ontology-B4rkO33J.js} +50 -52
  156. package/dist-lib/ontology-dataprep-BwD5TKs2.js +322 -0
  157. package/dist-lib/{ontology-domains-Cbqnm-po.js → ontology-domains-zxFrjn0v.js} +89 -92
  158. package/dist-lib/ontology-extract-BHOxruRO.js +3199 -0
  159. package/dist-lib/ontology-extract-iR_rXxFe.js +295 -0
  160. package/dist-lib/ontology-flow-CW0SzeK7.js +456 -0
  161. package/dist-lib/ontology-flow-Dv5iQ20f.js +154 -0
  162. package/dist-lib/ontology-modeling-B9wswveh.js +510 -0
  163. package/dist-lib/ontology-modeling-hakCluBi.js +15136 -0
  164. package/dist-lib/{ontology-scenarios-D3xy6IZL.js → ontology-scenarios-C2kp7Rs-.js} +1466 -1482
  165. package/dist-lib/ontology-scenarios-DKnfydG6.js +675 -0
  166. package/dist-lib/ontology-task-config-DmnWyCCB.js +122 -0
  167. package/dist-lib/ontology-terms-BoNB-5ar.js +66 -0
  168. package/dist-lib/ontology-terms-C-NhpcIZ.js +1195 -0
  169. package/dist-lib/pages-CticGC6S.js +512 -0
  170. package/dist-lib/pages.js +3 -3
  171. package/dist-lib/{permission-fTfxpEhV.js → permission-Dq1-AOQw.js} +41 -41
  172. package/dist-lib/pipeline-layout-CJlOMXJF.js +70 -0
  173. package/dist-lib/{pptx-preview.es-AUrdYKu3.js → pptx-preview.es-D4ODiBv2.js} +2 -2
  174. package/dist-lib/preset-Bp_mvsJm.js +56827 -0
  175. package/dist-lib/{preset-gh5SGoYT.js → preset-DCNSE--Y.js} +8 -8
  176. package/dist-lib/progress-CZxOOnIs.js +778 -0
  177. package/dist-lib/{quota-BlHnhkAT.js → quota-oICQRHFU.js} +4 -4
  178. package/dist-lib/row-By17TCiW.js +154 -0
  179. package/dist-lib/runs-DQTDpPaN.js +565 -0
  180. package/dist-lib/{save-blob-B-pzX8eT.js → save-blob-CwCZE1Dn.js} +2 -2
  181. package/dist-lib/{scenario-mapping-preview-DByQXh0y.js → scenario-mapping-preview-sJtjgmry.js} +46 -48
  182. package/dist-lib/scenario-simple-form-BvKSPFzw.js +989 -0
  183. package/dist-lib/{schedule-H4_9KnRj.js → schedule-CwkPPSuT.js} +8 -8
  184. package/dist-lib/script-gYJAFobb.js +2709 -0
  185. package/dist-lib/{settings-C3PI8KYa.js → settings-CJd5Jj4y.js} +133 -134
  186. package/dist-lib/{shared-DqeN-Wbb.js → shared-DG5-VCDM.js} +1 -1
  187. package/dist-lib/{shared-utils-DN3zT9P-.js → shared-utils-CFHws1DA.js} +2 -2
  188. package/dist-lib/{skills-eGlCExr0.js → skills-lxpJ5Lzx.js} +39 -40
  189. package/dist-lib/{source-selection-BCvClzc-.js → source-selection-DJnQQckl.js} +16 -16
  190. package/dist-lib/sources-C83LpCcV.js +279 -0
  191. package/dist-lib/style-B5THvtDY.js +191 -0
  192. package/dist-lib/{task-config-DEJVJ7zK.js → task-config-BNYoOb79.js} +4 -4
  193. package/dist-lib/{tech-C-4uM9bS.js → tech-LuZvKDo6.js} +3 -4
  194. package/dist-lib/templates-a-kbCamr.js +58 -0
  195. package/dist-lib/tenant-login-COB-5h_2.js +338 -0
  196. package/dist-lib/{tools-le6miafZ.js → tools-CrA6GrY6.js} +14 -14
  197. package/dist-lib/{use-domain-access-B3pDp3s5.js → use-domain-access-ehGJBGvU.js} +15 -15
  198. package/dist-lib/{use-g6-graph-WLX0PweO.js → use-g6-graph-DfRnsBS6.js} +1 -1
  199. package/dist-lib/{use-graph-layers-Dmp7uMHO.js → use-graph-layers-CrhEeHfD.js} +48 -50
  200. package/dist-lib/use-resizable-columns-BpMCRKif.js +59 -0
  201. package/dist-lib/useBreakpoint-Cul9y9Cu.js +87 -0
  202. package/dist-lib/{useForm-Byp1LopG.js → useForm-B-dwOwJ8.js} +11 -11
  203. package/dist-lib/{version-control-panel-WT1PobuV.js → version-control-panel-mWXkC-uB.js} +26 -27
  204. package/dist-lib/{version-management-DC0k1DRg.js → version-management-nPlG7wQO.js} +6 -7
  205. package/dist-lib/{welcome-VyWLrbth.js → welcome-Cqv1-rXT.js} +3 -4
  206. package/package.json +1 -1
  207. package/dist-lib/ApartmentOutlined-M6qSurnE.js +0 -12
  208. package/dist-lib/ArrowLeftOutlined-DowsrSUj.js +0 -12
  209. package/dist-lib/EvidenceFormList-DXqqSpPV.js +0 -91
  210. package/dist-lib/ImpactPage-DyhUR6fT.js +0 -71
  211. package/dist-lib/OntologyMaterializePage-B0f9TnJa.js +0 -136
  212. package/dist-lib/OntologyNodesPage-D4MWlm6q.js +0 -1268
  213. package/dist-lib/Pagination-Dxslodkq.js +0 -1344
  214. package/dist-lib/PlusOutlined-B_dXo_97.js +0 -12
  215. package/dist-lib/SearchOutlined-puH6bCY6.js +0 -979
  216. package/dist-lib/Skeleton-DXcERb5r.js +0 -557
  217. package/dist-lib/TagsOutlined-B4_qkn6-.js +0 -20
  218. package/dist-lib/TermDetailPage-CP0D6OvA.js +0 -242
  219. package/dist-lib/TextArea-DTpTS5HL.js +0 -1897
  220. package/dist-lib/ThunderboltOutlined-Bf54AaFE.js +0 -20
  221. package/dist-lib/callSuper-DZEfdkXG.js +0 -7
  222. package/dist-lib/changelog-Dj_Pv2nc.js +0 -69
  223. package/dist-lib/chunk-YDNE64FV-DGyyfCo0.js +0 -2004
  224. package/dist-lib/context-Buz0ggsK.js +0 -710
  225. package/dist-lib/context-DpmyNOn3.js +0 -21
  226. package/dist-lib/embed-DwLg9RDW.js +0 -31148
  227. package/dist-lib/focus-set-h0YtOUB2.js +0 -427
  228. package/dist-lib/index-CaXylbQR.js +0 -3419
  229. package/dist-lib/index-Cfu1W1H6.js +0 -535
  230. package/dist-lib/index-CrMcNEAZ.js +0 -9656
  231. package/dist-lib/index-CyKWCYMK.js +0 -218
  232. package/dist-lib/index-DBtGE89a.js +0 -168
  233. package/dist-lib/index-DjFPRXl5.js +0 -1484
  234. package/dist-lib/index-DvWHYX81.js +0 -450
  235. package/dist-lib/index-HieOUSwH.js +0 -340
  236. package/dist-lib/index-bOY1cBol.js +0 -4890
  237. package/dist-lib/meta-DPp5L3Uc.js +0 -540
  238. package/dist-lib/ontology-modeling-6k-m8fzr.js +0 -38946
  239. package/dist-lib/ontology-modeling-BT-EuDCs.js +0 -1039
  240. package/dist-lib/ontology-scenarios-DWYC2yxd.js +0 -660
  241. package/dist-lib/pages-CsexFuEz.js +0 -73
  242. package/dist-lib/row-B5MnGm9M.js +0 -156
  243. package/dist-lib/scenario-simple-form-Bw-6n9Kh.js +0 -2396
  244. package/dist-lib/useClosable-BY7FgWKy.js +0 -59
@@ -0,0 +1,1543 @@
1
+ import { jsxs as m, jsx as c, Fragment as lt } from "react/jsx-runtime";
2
+ import { A as ue, R as ae, I as B, V as Mt } from "./embed-mf8t3QXh.js";
3
+ import { M as de } from "./markdown-lite-p1tiuSZM.js";
4
+ import { O as zt, i as At, a as he, s as pe, B as Lt, c as fe, b as me, A as ge, p as Ne } from "./ontology-modeling-B9wswveh.js";
5
+ import { useState as w, useRef as T, useEffect as D, useCallback as R, useMemo as ve } from "react";
6
+ function Yt(t) {
7
+ return typeof t == "object" && t !== null && !Array.isArray(t) ? t : null;
8
+ }
9
+ function H(t) {
10
+ return typeof t == "string" ? t.trim() : "";
11
+ }
12
+ function ft(t) {
13
+ return Array.isArray(t) ? t.map(Yt).filter((e) => e !== null) : [];
14
+ }
15
+ function Qt(t) {
16
+ const e = t.filter((n) => !!n);
17
+ return e.length ? e.join(" · ") : void 0;
18
+ }
19
+ const Wt = { ADD: "新增", UPDATE: "修改", RETIRE: "退役" }, ye = { UPSERT: "写入", DELETE: "删除" }, qt = (t, e) => e[t] ?? "变更";
20
+ function ke(t) {
21
+ const e = H(t.tagName);
22
+ if (!e)
23
+ return null;
24
+ const n = ft(t.properties).length;
25
+ return {
26
+ kind: "structure",
27
+ label: `${qt(H(t.op), Wt)}对象类型 ${e}`,
28
+ detail: Qt([
29
+ H(t.displayName),
30
+ n ? `${n} 个属性` : void 0
31
+ ])
32
+ };
33
+ }
34
+ function be(t) {
35
+ const e = H(t.edgeName);
36
+ if (!e)
37
+ return null;
38
+ const n = ft(t.endpoints)[0], r = n ? H(n.srcTag) : "", o = n ? H(n.dstTag) : "", i = ft(t.properties).length;
39
+ return {
40
+ kind: "structure",
41
+ label: `${qt(H(t.op), Wt)}关系类型 ${e}`,
42
+ detail: Qt([
43
+ H(t.displayName),
44
+ r && o ? `${r} → ${o}` : void 0,
45
+ i ? `${i} 个属性` : void 0
46
+ ])
47
+ };
48
+ }
49
+ function jt(t, e, n) {
50
+ const r = /* @__PURE__ */ new Map();
51
+ return t.forEach((o) => {
52
+ const i = H(o[e]);
53
+ if (!i)
54
+ return;
55
+ const l = H(o.op), u = `${l}|${i}`, h = r.get(u);
56
+ if (h) {
57
+ h.count += 1;
58
+ return;
59
+ }
60
+ r.set(u, { label: `${qt(l, ye)}${n} · ${i}`, count: 1 });
61
+ }), [...r.values()].map(({ label: o, count: i }) => ({
62
+ kind: "instance",
63
+ label: o,
64
+ detail: `${i} 条`
65
+ }));
66
+ }
67
+ function Xt(t) {
68
+ let e = t;
69
+ if (typeof t == "string") {
70
+ if (!t.trim())
71
+ return null;
72
+ try {
73
+ e = JSON.parse(t);
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
78
+ const n = Yt(e);
79
+ if (!n)
80
+ return null;
81
+ const r = ft(n.tags), o = ft(n.edges), i = ft(n.nodes), l = ft(n.relations);
82
+ if (!r.length && !o.length && !i.length && !l.length)
83
+ return null;
84
+ const u = [...r.map(ke), ...o.map(be)].filter(
85
+ (f) => f !== null
86
+ ), h = [
87
+ ...u,
88
+ ...jt(i, "tagName", "实例"),
89
+ ...jt(l, "edgeName", "关系")
90
+ ];
91
+ return h.length ? {
92
+ structureCount: u.length,
93
+ instanceCount: i.filter((f) => H(f.tagName)).length + l.filter((f) => H(f.edgeName)).length,
94
+ items: h
95
+ } : null;
96
+ }
97
+ const Kt = 9e4, Ct = "c2f_question";
98
+ function Vt(t) {
99
+ let e = ut(t);
100
+ !e && typeof t == "string" && t.trim() && (e = Tt(t));
101
+ const n = e ? ut(e.request) : null;
102
+ return {
103
+ question: e ? O(e.question) : "",
104
+ requestKeys: n ? Object.keys(n) : []
105
+ };
106
+ }
107
+ function ut(t) {
108
+ return typeof t != "object" || t === null || Array.isArray(t) ? null : t;
109
+ }
110
+ function O(t) {
111
+ return typeof t == "string" ? t : typeof t == "number" || typeof t == "boolean" ? String(t) : "";
112
+ }
113
+ function Tt(t) {
114
+ try {
115
+ return ut(JSON.parse(t));
116
+ } catch {
117
+ return null;
118
+ }
119
+ }
120
+ function bt(t) {
121
+ if (typeof t == "string") {
122
+ const r = Tt(t);
123
+ return r ? bt(r) : void 0;
124
+ }
125
+ if (Array.isArray(t)) {
126
+ for (const r of t) {
127
+ const o = bt(r);
128
+ if (o)
129
+ return o;
130
+ }
131
+ return;
132
+ }
133
+ const e = ut(t);
134
+ if (!e)
135
+ return;
136
+ const n = O(e.proposalCode);
137
+ if (n)
138
+ return n;
139
+ for (const r of Object.values(e)) {
140
+ const o = bt(r);
141
+ if (o)
142
+ return o;
143
+ }
144
+ }
145
+ function it(t, e) {
146
+ if (typeof t == "string") {
147
+ const r = Tt(t);
148
+ return r ? it(r, e) : void 0;
149
+ }
150
+ if (Array.isArray(t)) {
151
+ for (const r of t) {
152
+ const o = it(r, e);
153
+ if (o !== void 0)
154
+ return o;
155
+ }
156
+ return;
157
+ }
158
+ const n = ut(t);
159
+ if (n) {
160
+ if (n[e] !== void 0)
161
+ return n[e];
162
+ for (const r of Object.values(n)) {
163
+ const o = it(r, e);
164
+ if (o !== void 0)
165
+ return o;
166
+ }
167
+ }
168
+ }
169
+ function Ht(t) {
170
+ if (typeof t == "number")
171
+ return Number.isFinite(t) ? t : void 0;
172
+ if (typeof t == "string" && t.trim()) {
173
+ const e = Number(t);
174
+ return Number.isFinite(e) ? e : void 0;
175
+ }
176
+ }
177
+ const Ce = /token|secret|password|authorization|cookie|session|api[-_]?key|access[-_]?key/i;
178
+ function _t(t) {
179
+ if (Array.isArray(t))
180
+ return t.map((r) => _t(r));
181
+ const e = ut(t);
182
+ if (!e)
183
+ return t;
184
+ const n = {};
185
+ for (const [r, o] of Object.entries(e))
186
+ n[r] = Ce.test(r) ? "***" : _t(o);
187
+ return n;
188
+ }
189
+ function Zt(t) {
190
+ if (typeof t != "string")
191
+ return O(t);
192
+ const e = Tt(t);
193
+ if (!e)
194
+ return t;
195
+ const n = _t(e);
196
+ return JSON.stringify(n) === JSON.stringify(e) ? t : JSON.stringify(n, null, 2);
197
+ }
198
+ function Ee(t) {
199
+ const e = t.result ?? t.content ?? t;
200
+ try {
201
+ const n = JSON.stringify(e, null, 2);
202
+ return n.length > 2e3 ? `${n.slice(0, 2e3)}
203
+ …(已截断)` : n;
204
+ } catch {
205
+ return O(e);
206
+ }
207
+ }
208
+ function Te(t) {
209
+ return t.length > 2e3 ? `${t.slice(0, 2e3)}
210
+ …(已截断)` : t;
211
+ }
212
+ const $e = /```ontology-patch\s*([\s\S]*?)```/g, Ie = "```ontology-patch", xe = 2400;
213
+ function Oe(t) {
214
+ const e = [];
215
+ let n = t;
216
+ for (const o of t.matchAll($e)) {
217
+ try {
218
+ e.push(JSON.parse(o[1].trim()));
219
+ } catch {
220
+ e.push(null);
221
+ }
222
+ n = n.replace(o[0], "");
223
+ }
224
+ const r = n.indexOf(Ie);
225
+ return r >= 0 && (n = n.slice(0, r)), { patches: e, rest: n.trim() };
226
+ }
227
+ function Se(t, e) {
228
+ if (!e)
229
+ return t;
230
+ if (!t || t.includes(e) || e.startsWith(t))
231
+ return t.includes(e) ? t : e;
232
+ const n = Math.min(t.length, e.length);
233
+ for (let r = n; r > 0; r -= 1)
234
+ if (t.endsWith(e.slice(0, r)))
235
+ return t + e.slice(r);
236
+ return t + e;
237
+ }
238
+ function Ae(t) {
239
+ const e = ut(t);
240
+ if (!e)
241
+ return null;
242
+ const n = {};
243
+ typeof e.title == "string" && e.title.trim() && (n.title = e.title.trim()), (e.proposalType === 1 || e.proposalType === 2 || e.proposalType === 3) && (n.proposalType = e.proposalType);
244
+ let r = 0;
245
+ const o = e.tags;
246
+ if (o !== void 0) {
247
+ if (!Array.isArray(o))
248
+ return null;
249
+ n.tags = o, r += o.length;
250
+ }
251
+ const i = e.edges;
252
+ if (i !== void 0) {
253
+ if (!Array.isArray(i))
254
+ return null;
255
+ n.edges = i, r += i.length;
256
+ }
257
+ const l = e.nodes;
258
+ if (l !== void 0) {
259
+ if (!Array.isArray(l))
260
+ return null;
261
+ n.nodes = l, r += l.length;
262
+ }
263
+ const u = e.relations;
264
+ if (u !== void 0) {
265
+ if (!Array.isArray(u))
266
+ return null;
267
+ n.relations = u, r += u.length;
268
+ }
269
+ return r ? n : null;
270
+ }
271
+ function Re(t) {
272
+ var r, o, i, l;
273
+ const e = /* @__PURE__ */ new Set(), n = (u) => {
274
+ typeof u == "string" && u && e.add(u);
275
+ };
276
+ return (r = t.tags) == null || r.forEach((u) => n(u == null ? void 0 : u.tagName)), (o = t.edges) == null || o.forEach((u) => n(u == null ? void 0 : u.edgeName)), (i = t.nodes) == null || i.forEach((u) => n(u == null ? void 0 : u.tagName)), (l = t.relations) == null || l.forEach((u) => n(u == null ? void 0 : u.edgeName)), Array.from(e);
277
+ }
278
+ function we(t) {
279
+ const e = t.slice(0, 5).map((n) => `${n.rowRef ? `${n.rowRef} ` : ""}${n.message}`).join(";");
280
+ return t.length > 5 ? `${e} 等 ${t.length} 项` : e;
281
+ }
282
+ function Me(t) {
283
+ return t instanceof ae && Number(t.code) === ge;
284
+ }
285
+ function _e(t, e) {
286
+ const n = `history-${e}`, r = [];
287
+ t.userText && r.push({
288
+ id: `${n}-user`,
289
+ turnId: n,
290
+ role: "user",
291
+ content: t.userText,
292
+ status: "done"
293
+ }), (t.toolCalls || []).forEach((i, l) => {
294
+ if (i.toolName === Ct) {
295
+ const u = Vt(i.arguments), h = !!i.result && !i.isError;
296
+ r.push({
297
+ id: `${n}-question-${l}`,
298
+ turnId: n,
299
+ role: "tool",
300
+ kind: "question",
301
+ content: u.question || "智能体需要补充信息",
302
+ requestKeys: u.requestKeys,
303
+ answered: h,
304
+ expired: !!i.result && !h,
305
+ status: "done"
306
+ });
307
+ return;
308
+ }
309
+ r.push({
310
+ id: `${n}-tool-${l}`,
311
+ turnId: n,
312
+ role: "tool",
313
+ kind: "tool_call",
314
+ content: Zt(i.arguments) || "",
315
+ toolName: i.toolName,
316
+ isError: i.isError || void 0,
317
+ result: i.result ? Te(i.result) : void 0,
318
+ status: "done"
319
+ });
320
+ });
321
+ const o = t.proposal;
322
+ if (o) {
323
+ const i = (t.toolCalls || []).map((l) => Xt(l.arguments)).find((l) => l !== null);
324
+ r.push({
325
+ id: `${n}-proposal`,
326
+ turnId: n,
327
+ role: "tool",
328
+ kind: "proposal",
329
+ content: "",
330
+ proposalCode: o.code,
331
+ proposalTitle: o.title,
332
+ proposalStatus: o.status,
333
+ proposalOrderCode: o.orderCode,
334
+ proposalBreakdown: i,
335
+ status: "done"
336
+ });
337
+ }
338
+ return t.assistantText && r.push({
339
+ id: `${n}-assistant`,
340
+ turnId: n,
341
+ role: "assistant",
342
+ content: t.assistantText,
343
+ status: "done"
344
+ }), r;
345
+ }
346
+ function sn(t, e, n, r) {
347
+ const { message: o } = ue.useApp(), [i, l] = w([]), [u, h] = w(!1), [f, p] = w(!1), [A, g] = w(/* @__PURE__ */ new Set()), b = T(null), M = T(!1), x = T(""), G = T(null), [at, P] = w(""), [I, rt] = w(""), [$t, J] = w("ready"), X = T(0), z = T(null), V = T(0), Z = T(""), tt = T(0), dt = T(!1), ht = T(0), et = T(Promise.resolve()), F = T(0), q = T(0), U = T(/* @__PURE__ */ new Map()), ot = T(() => {
348
+ }), mt = T(/* @__PURE__ */ new Map()), d = T(null), j = T(e);
349
+ D(() => {
350
+ j.current = e;
351
+ }, [e]);
352
+ const nt = T(n);
353
+ D(() => {
354
+ nt.current = n;
355
+ }, [n]);
356
+ const K = T(r);
357
+ D(() => {
358
+ K.current = r;
359
+ }, [r]);
360
+ const vt = (r == null ? void 0 : r.agentCode) ?? zt, [re, oe] = w(vt), pt = T(vt), Y = R((a) => {
361
+ !a || a === pt.current || (pt.current = a, oe(a));
362
+ }, []);
363
+ D(() => {
364
+ Y(r == null ? void 0 : r.agentCode);
365
+ }, [r == null ? void 0 : r.agentCode, Y]);
366
+ const yt = R(() => {
367
+ U.current.forEach((a) => window.clearTimeout(a)), U.current.clear(), g(/* @__PURE__ */ new Set());
368
+ }, []);
369
+ D(
370
+ () => () => {
371
+ var N, s;
372
+ const a = x.current;
373
+ (N = b.current) == null || N.abort(), a && !((s = K.current) != null && s.serverManaged) && At(
374
+ pt.current,
375
+ a
376
+ ), U.current.forEach((v) => window.clearTimeout(v)), U.current.clear();
377
+ },
378
+ []
379
+ );
380
+ const _ = R(
381
+ (a, N) => {
382
+ l((s) => s.map((v) => v.id === a ? N(v) : v));
383
+ },
384
+ []
385
+ ), Q = R(() => {
386
+ const a = z.current;
387
+ a && (z.current = null, _(a.id, (N) => N.status === "streaming" ? { ...N, status: "done" } : N));
388
+ }, [_]), gt = R((a, N) => {
389
+ l((s) => [
390
+ ...s,
391
+ {
392
+ id: `${a}-notice-${X.current++}`,
393
+ turnId: a,
394
+ role: "tool",
395
+ kind: "notice",
396
+ content: N,
397
+ isError: !0,
398
+ status: "done",
399
+ at: Date.now()
400
+ }
401
+ ]);
402
+ }, []), se = R((a) => {
403
+ l((N) => {
404
+ let s = !1;
405
+ const v = N.map((y) => y.kind === "proposal" && y.proposalSubmitted !== !0 && y.proposalTitle === void 0 && y.proposalStatus === void 0 && !y.proposalDraftCanceled && (!a || !y.proposalCode || y.proposalCode === a) ? (s = !0, { ...y, proposalDraftCanceled: !0 }) : y);
406
+ return s ? [
407
+ ...v,
408
+ {
409
+ id: `draft-canceled-${X.current++}`,
410
+ role: "tool",
411
+ kind: "notice",
412
+ content: "切换域时已丢弃未提交变更,之前的草稿已取消。",
413
+ status: "done",
414
+ at: Date.now()
415
+ }
416
+ ] : N;
417
+ });
418
+ }, []), Dt = R((a) => {
419
+ a.length && (g((N) => {
420
+ const s = new Set(N);
421
+ return a.forEach((v) => s.add(v)), s;
422
+ }), a.forEach((N) => {
423
+ const s = U.current.get(N);
424
+ s !== void 0 && window.clearTimeout(s);
425
+ const v = window.setTimeout(() => {
426
+ U.current.delete(N), g((y) => {
427
+ if (!y.has(N))
428
+ return y;
429
+ const E = new Set(y);
430
+ return E.delete(N), E;
431
+ });
432
+ }, xe);
433
+ U.current.set(N, v);
434
+ }));
435
+ }, []), Bt = R(
436
+ async (a, N, s) => {
437
+ var v, y;
438
+ for (const E of N) {
439
+ if (s !== q.current)
440
+ return;
441
+ const k = Ae(E);
442
+ if (!k) {
443
+ gt(
444
+ a,
445
+ "有一条 ontology-patch 不是可用补丁(JSON 非法或缺少 tags/edges/nodes/relations),已跳过,未写入草稿。"
446
+ );
447
+ continue;
448
+ }
449
+ const $ = x.current;
450
+ if (!$) {
451
+ gt(a, "补丁未落库:会话尚未建立,请重试。");
452
+ continue;
453
+ }
454
+ try {
455
+ const C = await he(
456
+ { ...k, conversationId: $ },
457
+ { silent: !0, rethrow: !0 }
458
+ );
459
+ if (s !== q.current)
460
+ return;
461
+ if (!C) {
462
+ gt(a, "补丁未落库:服务未返回结果,请重试。");
463
+ continue;
464
+ }
465
+ if ((v = C.issues) != null && v.length) {
466
+ gt(
467
+ a,
468
+ `补丁未落草稿:${C.issues.length} 项未通过校验(${we(C.issues)}),请修正后重新发送。`
469
+ );
470
+ continue;
471
+ }
472
+ F.current += 1, Dt(Re(k)), (y = j.current) == null || y.call(j, C.proposalCode);
473
+ } catch (C) {
474
+ if (s !== q.current)
475
+ return;
476
+ gt(
477
+ a,
478
+ `补丁未落库:${C instanceof Error ? C.message : "请求失败"}`
479
+ );
480
+ }
481
+ }
482
+ },
483
+ [gt, Dt]
484
+ ), It = R(
485
+ (a, N) => {
486
+ const { patches: s, rest: v } = Oe(N), y = v.replace(/^\s+/, "");
487
+ tt.current = y.length, _(a, (C) => ({
488
+ ...C,
489
+ content: y,
490
+ at: C.at ?? (y ? Date.now() : void 0)
491
+ }));
492
+ const E = ht.current;
493
+ if (s.length <= E)
494
+ return;
495
+ ht.current = s.length;
496
+ const k = s.slice(E), $ = q.current;
497
+ et.current = et.current.then(
498
+ () => Bt(a, k, $)
499
+ );
500
+ },
501
+ [_, Bt]
502
+ ), Pt = R((a, N) => {
503
+ var v, y, E;
504
+ const s = ut(N.data);
505
+ switch (N.type) {
506
+ case "meta":
507
+ case "conversationMeta": {
508
+ const k = s != null && s.conversationId ? O(s.conversationId) : "";
509
+ k && (x.current = k, P(k), J("ready")), s != null && s.conversationName && rt(O(s.conversationName)), s != null && s.agentCode && Y(O(s.agentCode)), s && ((y = (v = K.current) == null ? void 0 : v.onMeta) == null || y.call(v, s));
510
+ return;
511
+ }
512
+ case "thought": {
513
+ const k = O(s == null ? void 0 : s.text);
514
+ if (!k)
515
+ return;
516
+ const $ = z.current;
517
+ if (!$ || $.answerId !== a) {
518
+ const C = `${a}-thought-${X.current++}`, S = tt.current;
519
+ z.current = { id: C, answerId: a }, l((st) => [
520
+ ...st,
521
+ {
522
+ id: C,
523
+ turnId: a,
524
+ role: "tool",
525
+ kind: "thought",
526
+ content: k,
527
+ status: "streaming",
528
+ at: Date.now(),
529
+ textAt: S
530
+ }
531
+ ]);
532
+ } else
533
+ _($.id, (C) => ({ ...C, content: C.content + k }));
534
+ return;
535
+ }
536
+ case "token": {
537
+ const k = O(s == null ? void 0 : s.text);
538
+ if (!k || !k.trim() && !Z.current)
539
+ return;
540
+ Q(), Z.current += k, It(a, Z.current);
541
+ return;
542
+ }
543
+ case "tool_call": {
544
+ Q();
545
+ const k = O(s == null ? void 0 : s.name) || O(s == null ? void 0 : s.toolName) || "工具调用", $ = O(s == null ? void 0 : s.id) || void 0;
546
+ if (k === Ct) {
547
+ ot.current();
548
+ const S = Vt(s == null ? void 0 : s.arguments), st = tt.current;
549
+ l((W) => [
550
+ ...W,
551
+ {
552
+ id: `${a}-question-${X.current++}`,
553
+ turnId: a,
554
+ role: "tool",
555
+ kind: "question",
556
+ content: S.question || "智能体需要补充信息",
557
+ requestKeys: S.requestKeys,
558
+ toolName: k,
559
+ toolCallId: $,
560
+ status: "done",
561
+ at: Date.now(),
562
+ textAt: st
563
+ }
564
+ ]), _(a, (W) => W.status === "streaming" ? { ...W, status: "done" } : W);
565
+ return;
566
+ }
567
+ $ && mt.current.set($, s == null ? void 0 : s.arguments), d.current = s == null ? void 0 : s.arguments;
568
+ const C = tt.current;
569
+ l((S) => [
570
+ ...S,
571
+ {
572
+ id: `${a}-call-${X.current++}`,
573
+ turnId: a,
574
+ role: "tool",
575
+ kind: "tool_call",
576
+ content: Zt(s == null ? void 0 : s.arguments) || "",
577
+ toolName: k,
578
+ toolCallId: $,
579
+ status: "done",
580
+ at: Date.now(),
581
+ textAt: C
582
+ }
583
+ ]);
584
+ return;
585
+ }
586
+ case "tool_result": {
587
+ Q();
588
+ const k = O(s == null ? void 0 : s.name) || O(s == null ? void 0 : s.toolName) || "工具结果";
589
+ if (k === Ct)
590
+ return;
591
+ const $ = O(s == null ? void 0 : s.id) || void 0, C = (s == null ? void 0 : s.error) === !0 ? void 0 : bt(s), S = O(it(s, "orderNo")) || O(it(s, "orderCode")) || void 0, st = it(s, "submitted") === !0, W = !!S || st, kt = Ht(it(s, "rowCount")) ?? Ht(it(s, "itemCount")), L = C ? Xt(
592
+ $ ? mt.current.get($) : d.current
593
+ ) : null, Nt = tt.current;
594
+ l((ct) => [
595
+ ...ct,
596
+ {
597
+ id: `${a}-result-${X.current++}`,
598
+ turnId: a,
599
+ role: "tool",
600
+ kind: C ? "proposal" : "tool_result",
601
+ content: Ee(s || {}),
602
+ toolName: k,
603
+ toolCallId: $,
604
+ proposalCode: C,
605
+ proposalSubmitted: W,
606
+ proposalRowCount: kt,
607
+ proposalBreakdown: L ?? void 0,
608
+ proposalOrderCode: S,
609
+ isError: (s == null ? void 0 : s.error) === !0 || void 0,
610
+ status: "done",
611
+ at: Date.now(),
612
+ textAt: Nt
613
+ }
614
+ ]), C && (F.current += 1, (E = j.current) == null || E.call(j, C));
615
+ return;
616
+ }
617
+ case "done": {
618
+ Q(), dt.current = !0;
619
+ const k = Se(Z.current, O(s == null ? void 0 : s.content));
620
+ Z.current = k, It(a, k), _(a, ($) => ({ ...$, status: "done" }));
621
+ return;
622
+ }
623
+ case "error": {
624
+ Q(), _(a, (k) => ({
625
+ ...k,
626
+ status: "error",
627
+ error: O(s == null ? void 0 : s.message) || "对话失败"
628
+ }));
629
+ return;
630
+ }
631
+ default:
632
+ return;
633
+ }
634
+ }, [_, Q, It, Y]), xt = R(
635
+ (a, N, s) => {
636
+ var st, W, kt;
637
+ const v = a.trim();
638
+ if (!v || b.current || !t)
639
+ return;
640
+ const y = Date.now() + X.current++, E = `assistant-${y}`, k = q.current + 1;
641
+ q.current = k, Z.current = "", tt.current = 0, ht.current = 0, dt.current = !1, et.current = Promise.resolve(), F.current = 0, yt(), l((L) => [
642
+ ...L,
643
+ { id: `user-${y}`, turnId: E, role: "user", content: v, status: "done" },
644
+ { id: E, turnId: E, role: "assistant", content: "", status: "streaming" }
645
+ ]), z.current = null, h(!0), M.current = !1;
646
+ let $ = () => {
647
+ };
648
+ const C = pe(
649
+ {
650
+ agentCode: pt.current,
651
+ conversationId: x.current || void 0,
652
+ ontologyCode: t,
653
+ bizType: ((st = K.current) == null ? void 0 : st.bizType) ?? Lt,
654
+ userInput: v,
655
+ context: N && Object.keys(N).length ? N : void 0,
656
+ datasetRefs: (W = s == null ? void 0 : s.datasetRefs) != null && W.length ? s.datasetRefs : void 0,
657
+ sourceRefs: (kt = s == null ? void 0 : s.sourceRefs) != null && kt.length ? s.sourceRefs : void 0
658
+ },
659
+ {
660
+ onEvent: (L) => {
661
+ $(), Pt(E, L);
662
+ },
663
+ onError: (L) => {
664
+ Q(), _(E, (Nt) => ({ ...Nt, status: "error", error: L }));
665
+ }
666
+ }
667
+ );
668
+ b.current = C;
669
+ let S;
670
+ ot.current = () => {
671
+ S !== void 0 && (window.clearTimeout(S), S = void 0);
672
+ }, $ = () => {
673
+ S !== void 0 && window.clearTimeout(S), S = window.setTimeout(() => {
674
+ b.current === C && (M.current = !0, C.abort(), b.current = null, Q(), h(!1), _(
675
+ E,
676
+ (L) => L.status === "streaming" ? {
677
+ ...L,
678
+ status: "error",
679
+ error: `模型服务 ${Kt / 1e3} 秒没有返回内容,已停止等待,请重试或换一种问法`
680
+ } : L
681
+ ));
682
+ }, Kt);
683
+ }, $(), C.done.finally(() => {
684
+ if (k === q.current) {
685
+ if (S !== void 0 && window.clearTimeout(S), b.current === C && (b.current = null), Q(), h(!1), M.current) {
686
+ M.current = !1;
687
+ return;
688
+ }
689
+ et.current.then(() => {
690
+ var Nt;
691
+ if (k !== q.current)
692
+ return;
693
+ const L = dt.current;
694
+ _(E, (ct) => ct.status !== "streaming" ? ct : L ? ct.content || F.current ? { ...ct, status: "done" } : { ...ct, status: "error", error: "连接已结束但没有收到模型回复,请重试" } : { ...ct, status: "error", error: "连接中断,本轮回复可能不完整,请重试" }), F.current || (Nt = nt.current) == null || Nt.call(nt);
695
+ });
696
+ }
697
+ });
698
+ },
699
+ [t, Pt, _, Q, yt]
700
+ ), ce = R(
701
+ (a, N, s) => {
702
+ const v = N.trim();
703
+ v && (_(a, (y) => ({ ...y, answered: !0 })), b.current && (M.current = !0, b.current.abort(), b.current = null, z.current = null, l(
704
+ (y) => y.map((E) => E.status === "streaming" ? { ...E, status: "stopped" } : E)
705
+ ), h(!1)), xt(v, s));
706
+ },
707
+ [xt, _]
708
+ ), ie = R(() => {
709
+ var a, N, s, v;
710
+ if (M.current = !0, (a = b.current) == null || a.abort(), b.current = null, ot.current(), z.current = null, l(
711
+ (y) => y.map((E) => E.status === "streaming" ? { ...E, status: "stopped" } : E)
712
+ ), h(!1), (N = K.current) != null && N.serverManaged) {
713
+ (v = (s = K.current).onServerCancel) == null || v.call(s);
714
+ return;
715
+ }
716
+ x.current && At(
717
+ pt.current,
718
+ x.current
719
+ );
720
+ }, []), Ot = R(() => {
721
+ var a, N, s;
722
+ M.current = !0, (a = b.current) == null || a.abort(), b.current = null, ot.current(), x.current && !((N = K.current) != null && N.serverManaged) && At(
723
+ pt.current,
724
+ x.current
725
+ ), V.current += 1, q.current += 1, Z.current = "", tt.current = 0, ht.current = 0, dt.current = !1, mt.current.clear(), d.current = null, et.current = Promise.resolve(), F.current = 0, yt(), z.current = null, x.current = "", P(""), rt(""), J("ready"), l([]), h(!1), p(!1), Y(((s = K.current) == null ? void 0 : s.agentCode) ?? zt);
726
+ }, [yt, Y]), St = R(async () => {
727
+ if (x.current)
728
+ return x.current;
729
+ if (G.current)
730
+ return G.current;
731
+ const a = q.current;
732
+ J("creating");
733
+ const N = (async () => {
734
+ var v;
735
+ let s;
736
+ try {
737
+ s = await fe({
738
+ agentCode: pt.current,
739
+ ontologyCode: t,
740
+ bizType: ((v = K.current) == null ? void 0 : v.bizType) ?? Lt
741
+ });
742
+ } catch {
743
+ return J("failed"), null;
744
+ }
745
+ return s != null && s.conversationId ? a !== q.current ? (J("ready"), null) : (x.current = s.conversationId, P(s.conversationId), rt(s.conversationName || ""), J("ready"), Y(s.agentCode), s.conversationId) : (J("failed"), null);
746
+ })();
747
+ G.current = N;
748
+ try {
749
+ return await N;
750
+ } finally {
751
+ G.current === N && (G.current = null);
752
+ }
753
+ }, [t, Y]), le = R(
754
+ (a, N, s) => {
755
+ Ot(), Y(s), x.current = a, P(a), rt(N || "");
756
+ const v = ++V.current;
757
+ p(!0), me(a).then((y) => {
758
+ v === V.current && l((y.rounds || []).flatMap(_e));
759
+ }).catch((y) => {
760
+ if (v === V.current) {
761
+ if (!Me(y)) {
762
+ o.warning("历史加载失败");
763
+ return;
764
+ }
765
+ x.current = "", P(""), rt(""), J("ready"), St().then((E) => {
766
+ o.info(
767
+ E ? "该会话已失效,已为你开启新会话" : "该会话已失效,新会话创建失败,请点状态点重试"
768
+ );
769
+ });
770
+ }
771
+ }).finally(() => {
772
+ v === V.current && p(!1);
773
+ });
774
+ },
775
+ [Ot, o, St, Y]
776
+ );
777
+ return {
778
+ messages: i,
779
+ streaming: u,
780
+ historyLoading: f,
781
+ agentNames: A,
782
+ send: xt,
783
+ answerQuestion: ce,
784
+ stop: ie,
785
+ reset: Ot,
786
+ resume: le,
787
+ startSession: St,
788
+ cancelDraft: se,
789
+ conversationId: at,
790
+ conversationName: I,
791
+ sessionStatus: $t,
792
+ agentCode: re
793
+ };
794
+ }
795
+ function Gt(t) {
796
+ return t.kind === "question" || t.kind === "tool_result" && t.toolName === Ct;
797
+ }
798
+ function qe(t) {
799
+ const e = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
800
+ return t.forEach((o, i) => {
801
+ Gt(o) || o.kind === "tool_result" && o.toolCallId && !r.has(o.toolCallId) && r.set(o.toolCallId, i);
802
+ }), t.forEach((o, i) => {
803
+ if (!(n.has(i) || Gt(o))) {
804
+ if (o.kind === "thought") {
805
+ e.push({
806
+ kind: "thought",
807
+ id: o.id,
808
+ content: o.content,
809
+ status: o.status,
810
+ at: o.at
811
+ });
812
+ return;
813
+ }
814
+ if (o.kind === "tool_call") {
815
+ let l = o.toolCallId ? r.get(o.toolCallId) ?? -1 : -1;
816
+ l >= 0 && n.has(l) && (l = -1);
817
+ for (let h = i + 1; l < 0 && h < t.length; h += 1) {
818
+ if (n.has(h))
819
+ continue;
820
+ const f = t[h];
821
+ if (f.kind === "tool_call")
822
+ break;
823
+ if (f.kind === "tool_result" && (!o.toolName || !f.toolName || f.toolName === o.toolName)) {
824
+ l = h;
825
+ break;
826
+ }
827
+ }
828
+ const u = l >= 0 ? t[l] : void 0;
829
+ l >= 0 && n.add(l), e.push({
830
+ kind: "tool",
831
+ id: o.id,
832
+ toolName: o.toolName,
833
+ args: o.content,
834
+ result: (u == null ? void 0 : u.content) ?? o.result,
835
+ isError: (u == null ? void 0 : u.isError) ?? o.isError,
836
+ at: o.at,
837
+ endedAt: u == null ? void 0 : u.at
838
+ });
839
+ return;
840
+ }
841
+ o.kind === "tool_result" && e.push({
842
+ kind: "tool",
843
+ id: o.id,
844
+ toolName: o.toolName,
845
+ args: "",
846
+ result: o.content,
847
+ isError: o.isError,
848
+ at: o.at,
849
+ endedAt: o.at
850
+ });
851
+ }
852
+ }), e;
853
+ }
854
+ function Et(t, e = 72) {
855
+ const r = (t.split(/\r?\n/).map((o) => o.trim()).find((o) => o.length > 0) ?? "").replace(/\s+/g, " ");
856
+ return r.length > e ? `${r.slice(0, e - 1)}…` : r;
857
+ }
858
+ function De(t) {
859
+ const e = t.trim();
860
+ if (!e)
861
+ return "";
862
+ try {
863
+ return Et(JSON.stringify(JSON.parse(e)));
864
+ } catch {
865
+ return Et(e);
866
+ }
867
+ }
868
+ const Be = 30, Pe = 24, ze = 10;
869
+ function te(t, e) {
870
+ const [n, r] = w(e ? 0 : t.length), o = T(t), i = n < t.length;
871
+ return D(() => {
872
+ o.current = t;
873
+ }, [t]), D(() => {
874
+ if (!e && !i)
875
+ return;
876
+ const l = window.setInterval(() => {
877
+ r((u) => {
878
+ const h = o.current;
879
+ if (u >= h.length)
880
+ return u;
881
+ const f = Math.min(
882
+ ze,
883
+ Math.max(1, Math.ceil((h.length - u) / Pe))
884
+ );
885
+ return Math.min(h.length, u + f);
886
+ });
887
+ }, Be);
888
+ return () => window.clearInterval(l);
889
+ }, [e, i]), n >= t.length ? t : t.slice(0, n);
890
+ }
891
+ function ee() {
892
+ return /* @__PURE__ */ m("div", { className: "om-msg-typing", "aria-live": "polite", children: [
893
+ /* @__PURE__ */ c("span", { children: "正在思考" }),
894
+ /* @__PURE__ */ m("span", { className: "om-thinking-dots", "aria-hidden": "true", children: [
895
+ /* @__PURE__ */ c("i", {}),
896
+ /* @__PURE__ */ c("i", {}),
897
+ /* @__PURE__ */ c("i", {})
898
+ ] })
899
+ ] });
900
+ }
901
+ const Jt = /^\s*(?:\d+\s*[.、))]|[((]\d+[))]|[-*•])\s+(.+)$/;
902
+ function Le(t) {
903
+ const e = (t || "").split(`
904
+ `);
905
+ let n = e.length;
906
+ for (; n > 0; ) {
907
+ if (!e[n - 1].trim()) {
908
+ n -= 1;
909
+ continue;
910
+ }
911
+ if (!Jt.test(e[n - 1]))
912
+ break;
913
+ n -= 1;
914
+ }
915
+ const r = e.slice(n).map((o) => {
916
+ var i;
917
+ return (i = Jt.exec(o)) == null ? void 0 : i[1].replace(/\*\*/g, "").trim();
918
+ }).filter((o) => !!o);
919
+ return r.length < 2 ? { prompt: t, options: [] } : { prompt: e.slice(0, n).join(`
920
+ `).trim(), options: r };
921
+ }
922
+ function je({
923
+ message: t,
924
+ answerable: e,
925
+ onAnswer: n
926
+ }) {
927
+ var f;
928
+ const [r, o] = w(""), i = T(null);
929
+ D(() => {
930
+ const p = i.current;
931
+ p && (p.style.height = "auto", p.style.height = `${Math.max(32, Math.min(p.scrollHeight, 120))}px`);
932
+ }, [r]);
933
+ const l = () => {
934
+ const p = r.trim();
935
+ !p || !n || (n(t.id, p), o(""));
936
+ }, u = (p) => {
937
+ n == null || n(t.id, p);
938
+ }, h = e ? Le(t.content) : null;
939
+ return /* @__PURE__ */ m("div", { className: `om-question${t.answered ? " answered" : ""}`, children: [
940
+ /* @__PURE__ */ m("div", { className: "om-question-head", children: [
941
+ /* @__PURE__ */ c(B, { name: "message-square", size: 13 }),
942
+ /* @__PURE__ */ c("b", { children: "智能体提问" }),
943
+ !t.answered && ((f = t.requestKeys) != null && f.length) ? /* @__PURE__ */ m("span", { className: "om-question-keys", children: [
944
+ "需要补充:",
945
+ t.requestKeys.join("、")
946
+ ] }) : null
947
+ ] }),
948
+ h != null && h.options.length ? /* @__PURE__ */ m(lt, { children: [
949
+ h.prompt ? /* @__PURE__ */ c("div", { className: "om-question-text", children: h.prompt }) : null,
950
+ /* @__PURE__ */ c("div", { className: "om-question-options", children: h.options.map((p) => /* @__PURE__ */ c(
951
+ "button",
952
+ {
953
+ type: "button",
954
+ className: "om-question-option",
955
+ onClick: () => u(p),
956
+ children: p
957
+ },
958
+ p
959
+ )) }),
960
+ /* @__PURE__ */ m("div", { className: "om-question-other", children: [
961
+ /* @__PURE__ */ c("span", { children: "其他" }),
962
+ /* @__PURE__ */ c(
963
+ "input",
964
+ {
965
+ className: "input om-question-other-input",
966
+ placeholder: "输入其他回答(Enter 发送)",
967
+ value: r,
968
+ onChange: (p) => o(p.target.value),
969
+ onKeyDown: (p) => {
970
+ p.key === "Enter" && !Mt(p) && (p.preventDefault(), l());
971
+ }
972
+ }
973
+ )
974
+ ] })
975
+ ] }) : /* @__PURE__ */ m(lt, { children: [
976
+ /* @__PURE__ */ c("div", { className: "om-question-text", children: t.content }),
977
+ t.answered ? /* @__PURE__ */ c("div", { className: "om-question-answer", children: "已回答" }) : e ? /* @__PURE__ */ c(
978
+ "textarea",
979
+ {
980
+ ref: i,
981
+ className: "input om-question-input",
982
+ rows: 1,
983
+ placeholder: "输入你的回答(Enter 发送)",
984
+ value: r,
985
+ onChange: (p) => o(p.target.value),
986
+ onKeyDown: (p) => {
987
+ p.key === "Enter" && !p.shiftKey && !Mt(p) && (p.preventDefault(), l());
988
+ }
989
+ }
990
+ ) : /* @__PURE__ */ c("div", { className: "om-question-stale", children: "该提问已过期,请以最新一轮为准" })
991
+ ] })
992
+ ] });
993
+ }
994
+ function ne({
995
+ message: t,
996
+ text: e,
997
+ animate: n
998
+ }) {
999
+ const r = te(e ?? t.content, n && t.status === "streaming");
1000
+ return /* @__PURE__ */ c("div", { className: "om-msg-text om-msg-md", children: /* @__PURE__ */ c(de, { content: r }) });
1001
+ }
1002
+ function Ke(t) {
1003
+ const e = t.proposalBreakdown;
1004
+ if (e) {
1005
+ const n = [];
1006
+ if (e.structureCount && n.push(`结构 ${e.structureCount} 项`), e.instanceCount && n.push(`实例 ${e.instanceCount} 条`), n.length)
1007
+ return n.join(" · ");
1008
+ }
1009
+ return t.proposalRowCount ? `${t.proposalRowCount} 项变更` : "";
1010
+ }
1011
+ function Ft({ breakdown: t }) {
1012
+ return /* @__PURE__ */ m("details", { className: "om-proposal-changes", children: [
1013
+ /* @__PURE__ */ m("summary", { children: [
1014
+ /* @__PURE__ */ c(B, { name: "chevron-down", size: 11, className: "om-proposal-caret" }),
1015
+ /* @__PURE__ */ c("span", { children: "查看本次变更明细" }),
1016
+ /* @__PURE__ */ m("span", { className: "om-proposal-changes-count", children: [
1017
+ t.items.length,
1018
+ " 项"
1019
+ ] })
1020
+ ] }),
1021
+ /* @__PURE__ */ c("ul", { children: t.items.map((e) => /* @__PURE__ */ m("li", { children: [
1022
+ /* @__PURE__ */ c("span", { className: `om-proposal-kind ${e.kind}`, children: e.kind === "structure" ? "结构" : "实例" }),
1023
+ /* @__PURE__ */ c("span", { className: "om-proposal-change-label", children: e.label }),
1024
+ e.detail ? /* @__PURE__ */ c("span", { className: "om-proposal-change-detail", children: e.detail }) : null
1025
+ ] }, `${e.kind}:${e.label}`)) })
1026
+ ] });
1027
+ }
1028
+ function Ut({
1029
+ message: t,
1030
+ animate: e = !1,
1031
+ onViewProposal: n,
1032
+ onViewDraft: r
1033
+ }) {
1034
+ if (t.kind === "notice")
1035
+ return /* @__PURE__ */ c("div", { className: "om-msg-notice", children: t.content });
1036
+ if (t.kind === "proposal") {
1037
+ const o = t.proposalTitle !== void 0 || t.proposalStatus !== void 0, i = t.proposalBreakdown, l = Ke(t);
1038
+ if (!o) {
1039
+ if (t.proposalDraftCanceled)
1040
+ return /* @__PURE__ */ m("div", { className: "om-msg-proposal is-canceled", children: [
1041
+ /* @__PURE__ */ m("div", { className: "om-proposal-head", children: [
1042
+ /* @__PURE__ */ c(B, { name: "x-circle", size: 14 }),
1043
+ /* @__PURE__ */ c("b", { children: "草稿已取消" })
1044
+ ] }),
1045
+ /* @__PURE__ */ c("div", { className: "om-proposal-note", children: "切换域时已丢弃未提交变更,这份草稿不再可用。" })
1046
+ ] });
1047
+ const p = t.proposalSubmitted === !0, A = t.proposalCode, g = p ? A && n ? /* @__PURE__ */ c(
1048
+ "button",
1049
+ {
1050
+ type: "button",
1051
+ className: "btn sm",
1052
+ onClick: () => n(A),
1053
+ children: "查看提案"
1054
+ }
1055
+ ) : null : r ? /* @__PURE__ */ c("button", { type: "button", className: "btn sm", onClick: r, children: "查看草稿" }) : null;
1056
+ return /* @__PURE__ */ m("div", { className: "om-msg-proposal", children: [
1057
+ /* @__PURE__ */ m("div", { className: "om-proposal-head", children: [
1058
+ /* @__PURE__ */ c(B, { name: p ? "check-circle" : "sparkles", size: 14 }),
1059
+ /* @__PURE__ */ c("b", { children: p ? "已提交提案" : "已加入草稿" }),
1060
+ l ? /* @__PURE__ */ c("span", { className: p ? "tag sm" : "tag green sm", children: l }) : null
1061
+ ] }),
1062
+ i ? /* @__PURE__ */ c(Ft, { breakdown: i }) : null,
1063
+ /* @__PURE__ */ m("div", { className: "om-proposal-note", children: [
1064
+ /* @__PURE__ */ c("b", { children: "提案" }),
1065
+ "是这次改动整理成的一张待审清单,审批通过后才会真正写进图谱。",
1066
+ p ? null : "现在还在草稿区,可在右栏勾选提交,或直接说「提交」由我提交为提案。"
1067
+ ] }),
1068
+ /* @__PURE__ */ m("div", { className: "om-proposal-meta", children: [
1069
+ "提案编码 ",
1070
+ /* @__PURE__ */ c("code", { className: "mono", children: t.proposalCode }),
1071
+ t.proposalOrderCode ? /* @__PURE__ */ m(lt, { children: [
1072
+ ",工单编码 ",
1073
+ /* @__PURE__ */ c("code", { className: "mono", children: t.proposalOrderCode })
1074
+ ] }) : null
1075
+ ] }),
1076
+ g ? /* @__PURE__ */ c("div", { className: "om-proposal-actions", children: g }) : null
1077
+ ] });
1078
+ }
1079
+ const u = t.proposalStatus ? Ne(t.proposalStatus) : "待提交", h = t.proposalStatus === 3 ? "red" : t.proposalStatus === 2 ? "blue" : "green", f = t.proposalCode;
1080
+ return /* @__PURE__ */ m("div", { className: "om-msg-proposal", children: [
1081
+ /* @__PURE__ */ m("div", { className: "om-proposal-head", children: [
1082
+ /* @__PURE__ */ c(B, { name: "file-text", size: 14 }),
1083
+ /* @__PURE__ */ c("b", { children: `提案:${t.proposalTitle || "未命名提案"}` }),
1084
+ /* @__PURE__ */ c("span", { className: `tag ${h} sm`, children: u }),
1085
+ l ? /* @__PURE__ */ c("span", { className: "om-proposal-count", children: l }) : null
1086
+ ] }),
1087
+ i ? /* @__PURE__ */ c(Ft, { breakdown: i }) : null,
1088
+ /* @__PURE__ */ m("div", { className: "om-proposal-note", children: [
1089
+ /* @__PURE__ */ c("b", { children: "提案" }),
1090
+ "是这次改动整理成的一张待审清单,审批通过后才会真正写进图谱。"
1091
+ ] }),
1092
+ /* @__PURE__ */ m("div", { className: "om-proposal-meta", children: [
1093
+ "提案编码 ",
1094
+ /* @__PURE__ */ c("code", { className: "mono", children: t.proposalCode }),
1095
+ t.proposalOrderCode ? /* @__PURE__ */ m(lt, { children: [
1096
+ ",工单编码 ",
1097
+ /* @__PURE__ */ c("code", { className: "mono", children: t.proposalOrderCode })
1098
+ ] }) : null
1099
+ ] }),
1100
+ f && n ? /* @__PURE__ */ c("div", { className: "om-proposal-actions", children: /* @__PURE__ */ c(
1101
+ "button",
1102
+ {
1103
+ type: "button",
1104
+ className: "btn sm",
1105
+ onClick: () => n(f),
1106
+ children: "查看提案"
1107
+ }
1108
+ ) }) : null
1109
+ ] });
1110
+ }
1111
+ return t.status === "error" ? /* @__PURE__ */ c("div", { className: "om-msg-error", children: t.error || "对话失败" }) : !t.content && t.status === "streaming" ? /* @__PURE__ */ c(ee, {}) : t.role === "assistant" ? /* @__PURE__ */ c(ne, { message: t, animate: e }) : /* @__PURE__ */ c("div", { className: "om-msg-text", children: t.content });
1112
+ }
1113
+ function He({
1114
+ message: t,
1115
+ live: e = !1,
1116
+ answerableQuestionId: n,
1117
+ userName: r,
1118
+ assistantName: o,
1119
+ onViewProposal: i,
1120
+ onViewDraft: l,
1121
+ onAnswer: u
1122
+ }) {
1123
+ if (t.role === "tool")
1124
+ return /* @__PURE__ */ c("div", { className: "om-msg tool", children: t.kind === "question" ? /* @__PURE__ */ c(
1125
+ je,
1126
+ {
1127
+ message: t,
1128
+ answerable: t.id === n,
1129
+ onAnswer: u
1130
+ }
1131
+ ) : /* @__PURE__ */ c(
1132
+ Ut,
1133
+ {
1134
+ message: t,
1135
+ onViewProposal: i,
1136
+ onViewDraft: l
1137
+ }
1138
+ ) });
1139
+ const h = t.role === "user", f = (h ? (r == null ? void 0 : r.trim()) || "我" : o == null ? void 0 : o.trim()) ?? "";
1140
+ return /* @__PURE__ */ m("div", { className: `om-msg ${h ? "user" : "assistant"}`, children: [
1141
+ /* @__PURE__ */ m("div", { className: "om-msg-head", children: [
1142
+ /* @__PURE__ */ c("div", { className: "om-msg-avatar", children: /* @__PURE__ */ c(B, { name: h ? "user" : "brain", size: 14 }) }),
1143
+ f ? /* @__PURE__ */ c("span", { className: "om-msg-sender", children: f }) : null
1144
+ ] }),
1145
+ /* @__PURE__ */ c("div", { className: "om-msg-main", children: /* @__PURE__ */ c(
1146
+ Ut,
1147
+ {
1148
+ message: t,
1149
+ animate: e,
1150
+ onViewProposal: i,
1151
+ onViewDraft: l
1152
+ }
1153
+ ) })
1154
+ ] });
1155
+ }
1156
+ function Ge(t) {
1157
+ return t < 1e3 ? `${t}ms` : `${(t / 1e3).toFixed(1)}s`;
1158
+ }
1159
+ function Je(t) {
1160
+ return `${Math.max(1, Math.round(t / 1e3))}s`;
1161
+ }
1162
+ function Fe({ startAt: t }) {
1163
+ const [e, n] = w(t);
1164
+ return D(() => {
1165
+ const r = window.setInterval(() => n(Date.now()), 1e3);
1166
+ return () => window.clearInterval(r);
1167
+ }, []), /* @__PURE__ */ c(lt, { children: Je(Math.max(0, e - t)) });
1168
+ }
1169
+ function Rt(t, e, n) {
1170
+ return {
1171
+ kind: "text",
1172
+ key: `${t.id}-text-${e}`,
1173
+ text: t.content.slice(e, n)
1174
+ };
1175
+ }
1176
+ function wt(t, e) {
1177
+ if (!e.length)
1178
+ return t != null && t.content ? [Rt(t, 0, t.content.length)] : [];
1179
+ if (!t || e.some((f) => f.textAt === void 0)) {
1180
+ const f = [{ kind: "process", key: `proc-${e[0].id}`, steps: e }];
1181
+ return t != null && t.content && f.push(Rt(t, 0, t.content.length)), f;
1182
+ }
1183
+ const r = t.content, o = [];
1184
+ let i = [], l = 0;
1185
+ const u = () => {
1186
+ i.length && (o.push({ kind: "process", key: `proc-${i[0].id}`, steps: i }), i = []);
1187
+ }, h = (f) => {
1188
+ f > l && (o.push(Rt(t, l, f)), l = f);
1189
+ };
1190
+ for (const f of e) {
1191
+ const p = Math.min(Math.max(f.textAt ?? 0, l), r.length);
1192
+ i.length && p !== l && u(), h(p), i.push(f);
1193
+ }
1194
+ return u(), h(r.length), o;
1195
+ }
1196
+ function Ue(t) {
1197
+ const e = [], n = /* @__PURE__ */ new Map();
1198
+ for (const r of t) {
1199
+ const o = r.proposalCode;
1200
+ if (!o) {
1201
+ e.push(r);
1202
+ continue;
1203
+ }
1204
+ const i = n.get(o);
1205
+ if (i === void 0) {
1206
+ n.set(o, e.length), e.push(r);
1207
+ continue;
1208
+ }
1209
+ r.proposalSubmitted === !0 && e[i].proposalSubmitted !== !0 && (e[i] = {
1210
+ ...e[i],
1211
+ proposalSubmitted: !0,
1212
+ proposalOrderCode: r.proposalOrderCode ?? e[i].proposalOrderCode
1213
+ });
1214
+ }
1215
+ return e;
1216
+ }
1217
+ function Ye(t) {
1218
+ for (let e = t.length - 1; e >= 0; e -= 1) {
1219
+ const n = t[e];
1220
+ if (n.role === "user")
1221
+ return;
1222
+ if (n.kind === "question")
1223
+ return n.answered || n.expired ? void 0 : n.id;
1224
+ }
1225
+ }
1226
+ function Qe(t) {
1227
+ var r;
1228
+ const e = [];
1229
+ let n = 0;
1230
+ for (; n < t.length; ) {
1231
+ const o = t[n];
1232
+ if (o.role === "user") {
1233
+ e.push({ kind: "message", message: o }), n += 1;
1234
+ continue;
1235
+ }
1236
+ const i = o.turnId, l = [];
1237
+ for (; n < t.length && t[n].role !== "user" && (i === void 0 || t[n].turnId === void 0 || t[n].turnId === i); )
1238
+ l.push(t[n]), n += 1;
1239
+ const u = l.filter((g) => g.role === "assistant"), h = l.filter((g) => g.kind === "notice"), f = l.filter((g) => g.kind === "proposal"), p = l.filter((g) => g.kind === "question"), A = l.filter(
1240
+ (g) => g.role === "tool" && g.kind !== "proposal" && g.kind !== "notice" && g.kind !== "question"
1241
+ );
1242
+ if (u.length > 1) {
1243
+ let g = [];
1244
+ l.forEach((b) => {
1245
+ if (b.role === "tool" && b.kind !== "proposal" && b.kind !== "notice" && b.kind !== "question") {
1246
+ g.push(b);
1247
+ return;
1248
+ }
1249
+ b.role === "assistant" && (e.push({
1250
+ kind: "turn",
1251
+ key: `turn-${b.id}`,
1252
+ turnId: b.turnId,
1253
+ answer: b,
1254
+ blocks: wt(b, g)
1255
+ }), g = []);
1256
+ }), g.length && e.push({
1257
+ kind: "turn",
1258
+ key: `turn-${g[0].id}`,
1259
+ turnId: g[0].turnId,
1260
+ blocks: wt(void 0, g)
1261
+ });
1262
+ } else if (u.length || A.length) {
1263
+ const g = u[0];
1264
+ (!!!(g && !g.content && g.status === "done") || A.length) && e.push({
1265
+ kind: "turn",
1266
+ key: `turn-${(g ?? A[0]).id}`,
1267
+ turnId: (g == null ? void 0 : g.turnId) ?? ((r = A[0]) == null ? void 0 : r.turnId) ?? i,
1268
+ answer: g,
1269
+ blocks: wt(g, A)
1270
+ });
1271
+ }
1272
+ p.forEach((g) => e.push({ kind: "message", message: g })), h.forEach((g) => e.push({ kind: "message", message: g })), Ue(f).forEach(
1273
+ (g) => e.push({ kind: "message", message: g })
1274
+ );
1275
+ }
1276
+ return e;
1277
+ }
1278
+ function We({
1279
+ entry: t,
1280
+ live: e
1281
+ }) {
1282
+ const [n, r] = w(!1), o = t.kind === "tool" && t.isError === !0, i = t.kind === "thought" && e && t.status === "streaming", l = t.kind === "tool" && e && !t.result && !o, u = i || l, h = t.kind === "thought" ? "思考" : t.toolName || "工具调用", f = i ? "思考中" : o ? "执行失败" : l ? "运行中" : t.kind === "thought" ? "已完成" : "已运行", p = t.kind === "thought" ? Et(t.content) : De(t.args) || Et(t.result ?? "");
1283
+ return /* @__PURE__ */ m("div", { className: `om-proc-item${o ? " failed" : ""}`, children: [
1284
+ /* @__PURE__ */ m(
1285
+ "button",
1286
+ {
1287
+ type: "button",
1288
+ className: "om-proc-row",
1289
+ "aria-expanded": n,
1290
+ onClick: () => r((A) => !A),
1291
+ children: [
1292
+ /* @__PURE__ */ c("span", { className: "om-proc-icon", children: u ? /* @__PURE__ */ c("span", { className: "om-proc-spin" }) : /* @__PURE__ */ c(B, { name: o ? "alert-circle" : "check-circle", size: 12 }) }),
1293
+ /* @__PURE__ */ c("span", { className: "om-proc-kind", children: h }),
1294
+ /* @__PURE__ */ c("span", { className: `om-proc-status${o ? " failed" : ""}`, children: f }),
1295
+ p ? /* @__PURE__ */ c("span", { className: "om-proc-summary", title: p, children: p }) : null,
1296
+ /* @__PURE__ */ c(B, { name: "chevron-down", size: 11, className: `om-proc-caret${n ? " open" : ""}` })
1297
+ ]
1298
+ }
1299
+ ),
1300
+ n ? /* @__PURE__ */ c("div", { className: "om-proc-detail", children: t.kind === "thought" ? /* @__PURE__ */ c("div", { className: "om-proc-thought-full", children: t.content || "暂无思考内容" }) : /* @__PURE__ */ m(lt, { children: [
1301
+ /* @__PURE__ */ c("div", { className: "om-tool-sub", children: "入参" }),
1302
+ /* @__PURE__ */ c("pre", { className: "om-tool-json", children: t.args || "—" }),
1303
+ /* @__PURE__ */ c("div", { className: "om-tool-sub", children: "返回" }),
1304
+ /* @__PURE__ */ c("pre", { className: "om-tool-json", children: t.result ?? (l ? "等待返回…" : "—") })
1305
+ ] }) }) : null
1306
+ ] });
1307
+ }
1308
+ function Xe({ content: t }) {
1309
+ const e = te(t, !0), n = T(null);
1310
+ return D(() => {
1311
+ const r = n.current;
1312
+ r && (r.scrollTop = r.scrollHeight);
1313
+ }, [e]), /* @__PURE__ */ m("div", { className: "om-thought-live", "aria-live": "polite", children: [
1314
+ /* @__PURE__ */ m("div", { className: "om-thought-head", children: [
1315
+ /* @__PURE__ */ c("span", { className: "om-proc-spin" }),
1316
+ /* @__PURE__ */ c("span", { children: "思考中" })
1317
+ ] }),
1318
+ /* @__PURE__ */ c("div", { className: "om-thought-body", ref: n, children: e || "正在思考…" })
1319
+ ] });
1320
+ }
1321
+ function Ve({ steps: t, live: e }) {
1322
+ var P;
1323
+ const n = ve(() => qe(t), [t]), r = n[n.length - 1], o = e && (r == null ? void 0 : r.kind) === "thought" && r.status === "streaming" ? r : void 0, i = o ? n.slice(0, -1) : n, l = e, u = i.some((I) => I.kind === "tool" && I.isError === !0), h = u || l, [f, p] = w(h), [A, g] = w(h);
1324
+ h !== A && (g(h), p(h));
1325
+ const b = i.filter((I) => I.kind === "tool").length, M = (P = i[0]) == null ? void 0 : P.at, x = (I) => I.kind === "tool" ? I.endedAt ?? I.at ?? 0 : I.at ?? 0, G = Math.max(0, ...i.map(x)) || void 0, at = !l && M && G && G > M ? Ge(G - M) : "";
1326
+ return /* @__PURE__ */ m(lt, { children: [
1327
+ i.length ? /* @__PURE__ */ m(
1328
+ "details",
1329
+ {
1330
+ className: "om-process",
1331
+ open: f,
1332
+ onToggle: (I) => p(I.currentTarget.open),
1333
+ children: [
1334
+ /* @__PURE__ */ m("summary", { className: "om-process-head", children: [
1335
+ /* @__PURE__ */ c(B, { name: u ? "alert-circle" : l ? "sparkles" : "check-circle", size: 12 }),
1336
+ /* @__PURE__ */ m("span", { children: [
1337
+ l ? "正在执行中" : `已完成 ${i.length} 个步骤`,
1338
+ b ? ` · ${b} 次工具` : "",
1339
+ l ? M ? /* @__PURE__ */ m(lt, { children: [
1340
+ " · ",
1341
+ /* @__PURE__ */ c(Fe, { startAt: M })
1342
+ ] }) : "" : at ? ` · ${at}` : ""
1343
+ ] }),
1344
+ /* @__PURE__ */ c(B, { name: "chevron-down", size: 11, className: "om-process-caret" })
1345
+ ] }),
1346
+ /* @__PURE__ */ c("div", { className: "om-process-body", children: i.map((I) => /* @__PURE__ */ c(We, { entry: I, live: e }, I.id)) })
1347
+ ]
1348
+ }
1349
+ ) : null,
1350
+ o ? /* @__PURE__ */ c(Xe, { content: o.content }, o.id) : null
1351
+ ] });
1352
+ }
1353
+ function Ze({
1354
+ blocks: t,
1355
+ answer: e,
1356
+ live: n,
1357
+ assistantName: r
1358
+ }) {
1359
+ const o = (r == null ? void 0 : r.trim()) ?? "";
1360
+ return /* @__PURE__ */ m("div", { className: "om-msg assistant om-turn", children: [
1361
+ /* @__PURE__ */ m("div", { className: "om-msg-head", children: [
1362
+ /* @__PURE__ */ c("div", { className: "om-msg-avatar", children: /* @__PURE__ */ c(B, { name: "brain", size: 14 }) }),
1363
+ o ? /* @__PURE__ */ c("span", { className: "om-msg-sender", children: o }) : null
1364
+ ] }),
1365
+ /* @__PURE__ */ m("div", { className: "om-msg-main", children: [
1366
+ t.map((i, l) => {
1367
+ const u = n && l === t.length - 1;
1368
+ return i.kind === "process" ? /* @__PURE__ */ c(Ve, { steps: i.steps, live: u }, i.key) : e ? /* @__PURE__ */ c(
1369
+ ne,
1370
+ {
1371
+ message: e,
1372
+ text: i.text,
1373
+ animate: u
1374
+ },
1375
+ i.key
1376
+ ) : null;
1377
+ }),
1378
+ !t.length && n ? /* @__PURE__ */ c(ee, {}) : null,
1379
+ (e == null ? void 0 : e.status) === "error" ? /* @__PURE__ */ c("div", { className: "om-msg-error", children: e.error || "对话失败" }) : null
1380
+ ] })
1381
+ ] });
1382
+ }
1383
+ function cn({
1384
+ messages: t,
1385
+ streaming: e,
1386
+ historyLoading: n = !1,
1387
+ onSend: r,
1388
+ onStop: o,
1389
+ userName: i,
1390
+ assistantName: l,
1391
+ welcomeTitle: u = "和智能助手开始对话",
1392
+ welcomeText: h = "可以说「先看看当前有哪些对象类型」,或直接描述要新增的结构与实例。",
1393
+ prefill: f,
1394
+ onPrefillConsumed: p,
1395
+ onViewProposal: A,
1396
+ onViewDraft: g,
1397
+ onAnswer: b,
1398
+ headerExtra: M,
1399
+ headerSlot: x,
1400
+ footerSlot: G,
1401
+ leadingSlot: at,
1402
+ quickActions: P,
1403
+ onQuickAction: I,
1404
+ scopeHint: rt,
1405
+ placeholder: $t = "描述要建模的对象类型、关系或实例(Enter 发送,Shift+Enter 换行)",
1406
+ compact: J = !1,
1407
+ readOnly: X = !1
1408
+ }) {
1409
+ const [z, V] = w(f ?? ""), [Z, tt] = w(f);
1410
+ f !== Z && (tt(f), f !== void 0 && V(f));
1411
+ const dt = T(null), ht = T(null), et = T(null), F = e || n, q = Qe(t), U = Ye(t);
1412
+ let ot;
1413
+ if (e) {
1414
+ for (let d = t.length - 1; d >= 0; d -= 1)
1415
+ if (t[d].turnId !== void 0) {
1416
+ ot = t[d].turnId;
1417
+ break;
1418
+ }
1419
+ }
1420
+ D(() => {
1421
+ var d;
1422
+ e || (d = dt.current) == null || d.scrollIntoView({ behavior: "smooth", block: "end" });
1423
+ }, [t, e]), D(() => {
1424
+ const d = ht.current;
1425
+ if (!d || !e)
1426
+ return;
1427
+ const j = () => {
1428
+ d.scrollTop = d.scrollHeight;
1429
+ };
1430
+ j();
1431
+ const nt = new MutationObserver(j);
1432
+ return nt.observe(d, { childList: !0, subtree: !0, characterData: !0 }), () => nt.disconnect();
1433
+ }, [e]), D(() => {
1434
+ var d;
1435
+ f !== void 0 && ((d = et.current) == null || d.focus(), p == null || p());
1436
+ }, [f, p]), D(() => {
1437
+ const d = et.current;
1438
+ d && (d.style.height = "auto", d.style.height = `${Math.max(34, Math.min(d.scrollHeight, 110))}px`);
1439
+ }, [z]);
1440
+ const mt = () => {
1441
+ const d = z.trim();
1442
+ !d || F || (r == null || r(d), V(""));
1443
+ };
1444
+ return /* @__PURE__ */ m("div", { className: "om-chat-panel", children: [
1445
+ J ? null : x || /* @__PURE__ */ m("div", { className: "om-chat-head", children: [
1446
+ /* @__PURE__ */ c("b", { children: "智能助手" }),
1447
+ M
1448
+ ] }),
1449
+ /* @__PURE__ */ m("div", { className: "om-chat-body", ref: ht, children: [
1450
+ n ? /* @__PURE__ */ c("div", { className: "om-chat-loading", children: "正在加载历史对话…" }) : t.length ? null : /* @__PURE__ */ m("div", { className: "om-chat-welcome", children: [
1451
+ /* @__PURE__ */ c(B, { name: "brain", size: 22 }),
1452
+ /* @__PURE__ */ c("b", { children: u }),
1453
+ /* @__PURE__ */ c("p", { children: h })
1454
+ ] }),
1455
+ q.map((d, j) => {
1456
+ const nt = d.kind === "message" ? d.message.turnId ?? d.message.id : d.turnId ?? d.key, K = ot !== void 0 ? nt === ot : j === q.length - 1;
1457
+ if (d.kind === "message")
1458
+ return /* @__PURE__ */ c(
1459
+ He,
1460
+ {
1461
+ message: d.message,
1462
+ live: K,
1463
+ answerableQuestionId: U,
1464
+ userName: i,
1465
+ assistantName: l,
1466
+ onViewProposal: A,
1467
+ onViewDraft: g,
1468
+ onAnswer: b
1469
+ },
1470
+ d.message.id
1471
+ );
1472
+ const vt = K && (!d.answer || d.answer.status === "streaming");
1473
+ return /* @__PURE__ */ c(
1474
+ Ze,
1475
+ {
1476
+ blocks: d.blocks,
1477
+ answer: d.answer,
1478
+ live: vt,
1479
+ assistantName: l
1480
+ },
1481
+ d.key
1482
+ );
1483
+ }),
1484
+ /* @__PURE__ */ c("div", { ref: dt })
1485
+ ] }),
1486
+ X ? null : /* @__PURE__ */ m("div", { className: "om-chat-input", children: [
1487
+ G,
1488
+ rt ? /* @__PURE__ */ c("div", { className: "om-chat-scope", children: rt }) : null,
1489
+ /* @__PURE__ */ m("div", { className: "om-chat-input-row", children: [
1490
+ at ? /* @__PURE__ */ c("div", { className: "om-chat-leading", children: at }) : null,
1491
+ /* @__PURE__ */ c(
1492
+ "textarea",
1493
+ {
1494
+ ref: et,
1495
+ className: "input om-chat-textarea",
1496
+ rows: 1,
1497
+ placeholder: U ? "请先回答上方提问(或停止本轮)" : $t,
1498
+ value: z,
1499
+ disabled: F,
1500
+ onChange: (d) => V(d.target.value),
1501
+ onKeyDown: (d) => {
1502
+ d.key === "Enter" && !d.shiftKey && !Mt(d) && (d.preventDefault(), mt());
1503
+ }
1504
+ }
1505
+ ),
1506
+ e ? /* @__PURE__ */ m("button", { className: "btn", type: "button", onClick: o, children: [
1507
+ /* @__PURE__ */ c(B, { name: "stop", size: 13 }),
1508
+ "停止"
1509
+ ] }) : /* @__PURE__ */ m(
1510
+ "button",
1511
+ {
1512
+ className: "btn primary",
1513
+ type: "button",
1514
+ disabled: !z.trim(),
1515
+ onClick: mt,
1516
+ children: [
1517
+ /* @__PURE__ */ c(B, { name: "send", size: 13 }),
1518
+ "发送"
1519
+ ]
1520
+ }
1521
+ )
1522
+ ] }),
1523
+ P != null && P.length ? /* @__PURE__ */ c("div", { className: "om-quick-row", children: P.map((d) => /* @__PURE__ */ m(
1524
+ "button",
1525
+ {
1526
+ type: "button",
1527
+ className: `om-quick-chip${d.done ? " done" : ""}`,
1528
+ disabled: F || d.done,
1529
+ onClick: () => I == null ? void 0 : I(d.key),
1530
+ children: [
1531
+ d.done ? "✓ " : "",
1532
+ d.label
1533
+ ]
1534
+ },
1535
+ d.key
1536
+ )) }) : null
1537
+ ] })
1538
+ ] });
1539
+ }
1540
+ export {
1541
+ cn as C,
1542
+ sn as u
1543
+ };