@vertesia/ui 1.4.0 → 1.5.0-dev.20260713.151751Z

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 (344) hide show
  1. package/lib/core/components/InputList.d.ts.map +1 -1
  2. package/lib/core/components/InputList.js +3 -2
  3. package/lib/core/components/InputList.js.map +1 -1
  4. package/lib/core/components/SelectList.d.ts.map +1 -1
  5. package/lib/core/components/SelectList.js +1 -1
  6. package/lib/core/components/SelectList.js.map +1 -1
  7. package/lib/core/components/TagsInput.d.ts.map +1 -1
  8. package/lib/core/components/TagsInput.js +36 -4
  9. package/lib/core/components/TagsInput.js.map +1 -1
  10. package/lib/core/components/popup/Popup.js +2 -1
  11. package/lib/core/components/popup/Popup.js.map +1 -1
  12. package/lib/core/components/popup/position.d.ts.map +1 -1
  13. package/lib/core/components/popup/position.js +3 -6
  14. package/lib/core/components/popup/position.js.map +1 -1
  15. package/lib/core/components/shadcn/badge.d.ts +2 -2
  16. package/lib/core/components/shadcn/badge.d.ts.map +1 -1
  17. package/lib/core/components/shadcn/badge.js +3 -0
  18. package/lib/core/components/shadcn/badge.js.map +1 -1
  19. package/lib/core/components/shadcn/breadcrumb.d.ts.map +1 -1
  20. package/lib/core/components/shadcn/breadcrumb.js +2 -2
  21. package/lib/core/components/shadcn/breadcrumb.js.map +1 -1
  22. package/lib/core/components/shadcn/filters/filterBar.d.ts.map +1 -1
  23. package/lib/core/components/shadcn/filters/filterBar.js +1 -3
  24. package/lib/core/components/shadcn/filters/filterBar.js.map +1 -1
  25. package/lib/core/components/shadcn/resizeable.d.ts +1 -1
  26. package/lib/core/components/shadcn/resizeable.d.ts.map +1 -1
  27. package/lib/core/components/shadcn/resizeable.js +12 -2
  28. package/lib/core/components/shadcn/resizeable.js.map +1 -1
  29. package/lib/core/components/shadcn/selectBox.d.ts +7 -1
  30. package/lib/core/components/shadcn/selectBox.d.ts.map +1 -1
  31. package/lib/core/components/shadcn/selectBox.js +29 -12
  32. package/lib/core/components/shadcn/selectBox.js.map +1 -1
  33. package/lib/core/components/table/index.d.ts.map +1 -1
  34. package/lib/core/components/table/index.js +1 -1
  35. package/lib/core/components/table/index.js.map +1 -1
  36. package/lib/core/hooks/useIntersectionObserver.d.ts.map +1 -1
  37. package/lib/core/hooks/useIntersectionObserver.js +3 -1
  38. package/lib/core/hooks/useIntersectionObserver.js.map +1 -1
  39. package/lib/features/agent/chat/AgentRightPanel.d.ts.map +1 -1
  40. package/lib/features/agent/chat/AgentRightPanel.js +3 -6
  41. package/lib/features/agent/chat/AgentRightPanel.js.map +1 -1
  42. package/lib/features/agent/chat/AnimatedThinkingDots.d.ts.map +1 -1
  43. package/lib/features/agent/chat/AnimatedThinkingDots.js +1 -1
  44. package/lib/features/agent/chat/AnimatedThinkingDots.js.map +1 -1
  45. package/lib/features/agent/chat/AskUserWidget.d.ts.map +1 -1
  46. package/lib/features/agent/chat/AskUserWidget.js +4 -3
  47. package/lib/features/agent/chat/AskUserWidget.js.map +1 -1
  48. package/lib/features/agent/chat/ModernAgentConversation.d.ts.map +1 -1
  49. package/lib/features/agent/chat/ModernAgentConversation.js +56 -11
  50. package/lib/features/agent/chat/ModernAgentConversation.js.map +1 -1
  51. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts +8 -1
  52. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts.map +1 -1
  53. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +40 -31
  54. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
  55. package/lib/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.js +3 -3
  56. package/lib/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.js.map +1 -1
  57. package/lib/features/agent/chat/ModernAgentOutput/MessageInput.d.ts.map +1 -1
  58. package/lib/features/agent/chat/ModernAgentOutput/MessageInput.js +5 -1
  59. package/lib/features/agent/chat/ModernAgentOutput/MessageInput.js.map +1 -1
  60. package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js +3 -7
  61. package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
  62. package/lib/features/agent/chat/ModernAgentOutput/PlanPanel.d.ts.map +1 -1
  63. package/lib/features/agent/chat/ModernAgentOutput/PlanPanel.js +5 -5
  64. package/lib/features/agent/chat/ModernAgentOutput/PlanPanel.js.map +1 -1
  65. package/lib/features/agent/chat/ModernAgentOutput/SlidingPlanPanel.d.ts.map +1 -1
  66. package/lib/features/agent/chat/ModernAgentOutput/SlidingPlanPanel.js +4 -4
  67. package/lib/features/agent/chat/ModernAgentOutput/SlidingPlanPanel.js.map +1 -1
  68. package/lib/features/agent/chat/ModernAgentOutput/ToolCallGroup.d.ts.map +1 -1
  69. package/lib/features/agent/chat/ModernAgentOutput/ToolCallGroup.js +3 -3
  70. package/lib/features/agent/chat/ModernAgentOutput/ToolCallGroup.js.map +1 -1
  71. package/lib/features/agent/chat/ModernAgentOutput/WorkstreamTabs.d.ts.map +1 -1
  72. package/lib/features/agent/chat/ModernAgentOutput/WorkstreamTabs.js +156 -8
  73. package/lib/features/agent/chat/ModernAgentOutput/WorkstreamTabs.js.map +1 -1
  74. package/lib/features/agent/chat/hooks/useFileProcessing.d.ts +1 -0
  75. package/lib/features/agent/chat/hooks/useFileProcessing.d.ts.map +1 -1
  76. package/lib/features/agent/chat/hooks/useFileProcessing.js +37 -3
  77. package/lib/features/agent/chat/hooks/useFileProcessing.js.map +1 -1
  78. package/lib/features/facets/AgentRunnerFacetsNav.d.ts.map +1 -1
  79. package/lib/features/facets/AgentRunnerFacetsNav.js +1 -1
  80. package/lib/features/facets/AgentRunnerFacetsNav.js.map +1 -1
  81. package/lib/features/facets/InteractionsFacetsNav.d.ts +10 -1
  82. package/lib/features/facets/InteractionsFacetsNav.d.ts.map +1 -1
  83. package/lib/features/facets/InteractionsFacetsNav.js +14 -5
  84. package/lib/features/facets/InteractionsFacetsNav.js.map +1 -1
  85. package/lib/features/facets/PromptsFacetsNav.d.ts.map +1 -1
  86. package/lib/features/facets/PromptsFacetsNav.js +12 -1
  87. package/lib/features/facets/PromptsFacetsNav.js.map +1 -1
  88. package/lib/features/facets/RunsFacetsNav.d.ts.map +1 -1
  89. package/lib/features/facets/RunsFacetsNav.js +1 -1
  90. package/lib/features/facets/RunsFacetsNav.js.map +1 -1
  91. package/lib/features/magic-pdf/AnnotatedImageSlider.d.ts.map +1 -1
  92. package/lib/features/magic-pdf/AnnotatedImageSlider.js +1 -3
  93. package/lib/features/magic-pdf/AnnotatedImageSlider.js.map +1 -1
  94. package/lib/features/magic-pdf/MagicPdfProvider.js +2 -3
  95. package/lib/features/magic-pdf/MagicPdfProvider.js.map +1 -1
  96. package/lib/features/store/objects/DocumentSearchResults.d.ts +6 -2
  97. package/lib/features/store/objects/DocumentSearchResults.d.ts.map +1 -1
  98. package/lib/features/store/objects/DocumentSearchResults.js +6 -6
  99. package/lib/features/store/objects/DocumentSearchResults.js.map +1 -1
  100. package/lib/features/store/objects/components/ContentOverview.js +1 -1
  101. package/lib/features/store/objects/components/ContentOverview.js.map +1 -1
  102. package/lib/features/store/objects/components/DocumentIcon.d.ts.map +1 -1
  103. package/lib/features/store/objects/components/DocumentIcon.js +1 -1
  104. package/lib/features/store/objects/components/DocumentIcon.js.map +1 -1
  105. package/lib/features/store/objects/components/DocumentInput.js.map +1 -1
  106. package/lib/features/store/objects/search/DocumentSearchContext.d.ts +4 -4
  107. package/lib/features/store/objects/search/DocumentSearchContext.d.ts.map +1 -1
  108. package/lib/features/store/objects/search/DocumentSearchContext.js +1 -1
  109. package/lib/features/store/objects/search/DocumentSearchContext.js.map +1 -1
  110. package/lib/features/store/objects/selection/ObjectsActionContext.d.ts.map +1 -1
  111. package/lib/features/store/objects/selection/ObjectsActionContext.js +2 -25
  112. package/lib/features/store/objects/selection/ObjectsActionContext.js.map +1 -1
  113. package/lib/features/store/objects/selection/ObjectsActionContextClass.d.ts +0 -2
  114. package/lib/features/store/objects/selection/ObjectsActionContextClass.d.ts.map +1 -1
  115. package/lib/features/store/objects/selection/ObjectsActionContextClass.js +1 -7
  116. package/lib/features/store/objects/selection/ObjectsActionContextClass.js.map +1 -1
  117. package/lib/features/store/objects/selection/ObjectsActionHooks.d.ts +0 -1
  118. package/lib/features/store/objects/selection/ObjectsActionHooks.d.ts.map +1 -1
  119. package/lib/features/store/objects/selection/ObjectsActionHooks.js +0 -10
  120. package/lib/features/store/objects/selection/ObjectsActionHooks.js.map +1 -1
  121. package/lib/features/store/objects/selection/SelectionActions.d.ts +4 -0
  122. package/lib/features/store/objects/selection/SelectionActions.d.ts.map +1 -1
  123. package/lib/features/store/objects/selection/SelectionActions.js +4 -18
  124. package/lib/features/store/objects/selection/SelectionActions.js.map +1 -1
  125. package/lib/features/store/objects/selection/actions/DeleteObjectsAction.d.ts.map +1 -1
  126. package/lib/features/store/objects/selection/actions/DeleteObjectsAction.js +16 -7
  127. package/lib/features/store/objects/selection/actions/DeleteObjectsAction.js.map +1 -1
  128. package/lib/features/store/objects/selection/actions/StartWorkflowButton.d.ts +7 -0
  129. package/lib/features/store/objects/selection/actions/StartWorkflowButton.d.ts.map +1 -0
  130. package/lib/features/store/objects/selection/actions/StartWorkflowButton.js +51 -0
  131. package/lib/features/store/objects/selection/actions/StartWorkflowButton.js.map +1 -0
  132. package/lib/features/store/objects/selection/actions/index.d.ts +0 -1
  133. package/lib/features/store/objects/selection/actions/index.d.ts.map +1 -1
  134. package/lib/features/store/objects/selection/actions/index.js +0 -1
  135. package/lib/features/store/objects/selection/actions/index.js.map +1 -1
  136. package/lib/features/store/types/ContentObjectTypesSearch.d.ts.map +1 -1
  137. package/lib/features/store/types/ContentObjectTypesSearch.js +55 -3
  138. package/lib/features/store/types/ContentObjectTypesSearch.js.map +1 -1
  139. package/lib/features/store/types/ContentObjectTypesTable.d.ts +5 -1
  140. package/lib/features/store/types/ContentObjectTypesTable.d.ts.map +1 -1
  141. package/lib/features/store/types/ContentObjectTypesTable.js +4 -2
  142. package/lib/features/store/types/ContentObjectTypesTable.js.map +1 -1
  143. package/lib/features/store/types/search/ObjectTypeSearchContext.js +1 -1
  144. package/lib/features/store/types/search/ObjectTypeSearchContext.js.map +1 -1
  145. package/lib/i18n/locales/ar.json +17 -0
  146. package/lib/i18n/locales/de.json +17 -0
  147. package/lib/i18n/locales/en.json +33 -0
  148. package/lib/i18n/locales/es.json +17 -0
  149. package/lib/i18n/locales/fr.json +17 -0
  150. package/lib/i18n/locales/it.json +17 -0
  151. package/lib/i18n/locales/ja.json +17 -0
  152. package/lib/i18n/locales/ko.json +17 -0
  153. package/lib/i18n/locales/pt.json +17 -0
  154. package/lib/i18n/locales/ru.json +17 -0
  155. package/lib/i18n/locales/tr.json +17 -0
  156. package/lib/i18n/locales/zh-TW.json +17 -0
  157. package/lib/i18n/locales/zh.json +17 -0
  158. package/lib/layout/Sidebar.d.ts +5 -1
  159. package/lib/layout/Sidebar.d.ts.map +1 -1
  160. package/lib/layout/Sidebar.js.map +1 -1
  161. package/lib/router/NestedRouterProvider.d.ts +1 -1
  162. package/lib/router/NestedRouterProvider.d.ts.map +1 -1
  163. package/lib/router/NestedRouterProvider.js +2 -2
  164. package/lib/router/NestedRouterProvider.js.map +1 -1
  165. package/lib/router/Redirect.d.ts +13 -0
  166. package/lib/router/Redirect.d.ts.map +1 -0
  167. package/lib/router/Redirect.js +20 -0
  168. package/lib/router/Redirect.js.map +1 -0
  169. package/lib/router/Router.d.ts.map +1 -1
  170. package/lib/router/Router.js +1 -2
  171. package/lib/router/Router.js.map +1 -1
  172. package/lib/router/index.d.ts +1 -0
  173. package/lib/router/index.d.ts.map +1 -1
  174. package/lib/router/index.js +1 -0
  175. package/lib/router/index.js.map +1 -1
  176. package/lib/session/DevSessionProvider.d.ts +8 -0
  177. package/lib/session/DevSessionProvider.d.ts.map +1 -0
  178. package/lib/session/DevSessionProvider.js +33 -0
  179. package/lib/session/DevSessionProvider.js.map +1 -0
  180. package/lib/session/UserSessionProvider.d.ts.map +1 -1
  181. package/lib/session/UserSessionProvider.js +16 -2
  182. package/lib/session/UserSessionProvider.js.map +1 -1
  183. package/lib/session/auth/composable.d.ts +10 -1
  184. package/lib/session/auth/composable.d.ts.map +1 -1
  185. package/lib/session/auth/composable.js +38 -2
  186. package/lib/session/auth/composable.js.map +1 -1
  187. package/lib/session/index.d.ts +1 -0
  188. package/lib/session/index.d.ts.map +1 -1
  189. package/lib/session/index.js +1 -0
  190. package/lib/session/index.js.map +1 -1
  191. package/lib/shell/VertesiaShell.d.ts +3 -1
  192. package/lib/shell/VertesiaShell.d.ts.map +1 -1
  193. package/lib/shell/VertesiaShell.js +5 -4
  194. package/lib/shell/VertesiaShell.js.map +1 -1
  195. package/lib/shell/login/SignInRestrictedEnvStep.d.ts +14 -0
  196. package/lib/shell/login/SignInRestrictedEnvStep.d.ts.map +1 -0
  197. package/lib/shell/login/SignInRestrictedEnvStep.js +50 -0
  198. package/lib/shell/login/SignInRestrictedEnvStep.js.map +1 -0
  199. package/lib/shell/login/SigninScreen.d.ts.map +1 -1
  200. package/lib/shell/login/SigninScreen.js +16 -3
  201. package/lib/shell/login/SigninScreen.js.map +1 -1
  202. package/lib/shell/login/productionUrl.d.ts +16 -0
  203. package/lib/shell/login/productionUrl.d.ts.map +1 -0
  204. package/lib/shell/login/productionUrl.js +19 -0
  205. package/lib/shell/login/productionUrl.js.map +1 -0
  206. package/lib/shell/login/signInUtils.d.ts.map +1 -1
  207. package/lib/shell/login/signInUtils.js +14 -1
  208. package/lib/shell/login/signInUtils.js.map +1 -1
  209. package/lib/vertesia-ui-core.js +95 -2
  210. package/lib/vertesia-ui-core.js.map +1 -1
  211. package/lib/vertesia-ui-env.js +2 -2
  212. package/lib/vertesia-ui-env.js.map +1 -1
  213. package/lib/vertesia-ui-features.js +454 -2
  214. package/lib/vertesia-ui-features.js.map +1 -1
  215. package/lib/vertesia-ui-i18n.js +41 -2
  216. package/lib/vertesia-ui-i18n.js.map +1 -1
  217. package/lib/vertesia-ui-layout.js +2 -2
  218. package/lib/vertesia-ui-layout.js.map +1 -1
  219. package/lib/vertesia-ui-router.js +2 -2
  220. package/lib/vertesia-ui-router.js.map +1 -1
  221. package/lib/vertesia-ui-session.js +2 -2
  222. package/lib/vertesia-ui-session.js.map +1 -1
  223. package/lib/vertesia-ui-shell.js +2 -2
  224. package/lib/vertesia-ui-shell.js.map +1 -1
  225. package/lib/vertesia-ui-widgets.js +9 -2
  226. package/lib/vertesia-ui-widgets.js.map +1 -1
  227. package/lib/widgets/json-view/JSONCode.d.ts.map +1 -1
  228. package/lib/widgets/json-view/JSONCode.js +1 -1
  229. package/lib/widgets/json-view/JSONCode.js.map +1 -1
  230. package/lib/widgets/json-view/JSONTable.d.ts.map +1 -1
  231. package/lib/widgets/json-view/JSONTable.js +1 -1
  232. package/lib/widgets/json-view/JSONTable.js.map +1 -1
  233. package/lib/widgets/markdown/ArtifactContentRenderer.d.ts.map +1 -1
  234. package/lib/widgets/markdown/ArtifactContentRenderer.js +1 -1
  235. package/lib/widgets/markdown/ArtifactContentRenderer.js.map +1 -1
  236. package/lib/widgets/markdown/CodeBlockPlaceholder.d.ts.map +1 -1
  237. package/lib/widgets/markdown/CodeBlockPlaceholder.js +1 -1
  238. package/lib/widgets/markdown/CodeBlockPlaceholder.js.map +1 -1
  239. package/lib/widgets/monacoEditor/foldingProviders.d.ts.map +1 -1
  240. package/lib/widgets/monacoEditor/foldingProviders.js +5 -10
  241. package/lib/widgets/monacoEditor/foldingProviders.js.map +1 -1
  242. package/lib/widgets/schema-editor/ManagedSchema.d.ts.map +1 -1
  243. package/lib/widgets/schema-editor/ManagedSchema.js +1 -2
  244. package/lib/widgets/schema-editor/ManagedSchema.js.map +1 -1
  245. package/lib/widgets/upload/UploadResultCategory.d.ts.map +1 -1
  246. package/lib/widgets/upload/UploadResultCategory.js +1 -1
  247. package/lib/widgets/upload/UploadResultCategory.js.map +1 -1
  248. package/lib/widgets/xml-viewer/components/TextElement/index.d.ts.map +1 -1
  249. package/lib/widgets/xml-viewer/components/TextElement/index.js +1 -1
  250. package/lib/widgets/xml-viewer/components/TextElement/index.js.map +1 -1
  251. package/package.json +38 -43
  252. package/src/core/components/InputList.tsx +5 -10
  253. package/src/core/components/SelectList.tsx +7 -2
  254. package/src/core/components/TagsInput.tsx +41 -4
  255. package/src/core/components/popup/Popup.tsx +3 -3
  256. package/src/core/components/popup/position.ts +3 -6
  257. package/src/core/components/shadcn/badge.tsx +3 -0
  258. package/src/core/components/shadcn/breadcrumb.tsx +2 -4
  259. package/src/core/components/shadcn/filters/filterBar.tsx +2 -3
  260. package/src/core/components/shadcn/resizeable.test.tsx +77 -0
  261. package/src/core/components/shadcn/resizeable.tsx +28 -2
  262. package/src/core/components/shadcn/selectBox.tsx +70 -36
  263. package/src/core/components/table/index.tsx +1 -2
  264. package/src/core/hooks/useIntersectionObserver.tsx +3 -1
  265. package/src/features/agent/chat/AgentRightPanel.tsx +5 -6
  266. package/src/features/agent/chat/AnimatedThinkingDots.tsx +1 -2
  267. package/src/features/agent/chat/AskUserWidget.test.tsx +49 -0
  268. package/src/features/agent/chat/AskUserWidget.tsx +32 -22
  269. package/src/features/agent/chat/ModernAgentConversation.test.tsx +198 -1
  270. package/src/features/agent/chat/ModernAgentConversation.tsx +62 -15
  271. package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +60 -34
  272. package/src/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.tsx +3 -3
  273. package/src/features/agent/chat/ModernAgentOutput/MessageInput.test.tsx +25 -0
  274. package/src/features/agent/chat/ModernAgentOutput/MessageInput.tsx +5 -1
  275. package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +30 -30
  276. package/src/features/agent/chat/ModernAgentOutput/PlanPanel.tsx +5 -6
  277. package/src/features/agent/chat/ModernAgentOutput/SlidingPlanPanel.tsx +4 -5
  278. package/src/features/agent/chat/ModernAgentOutput/ToolCallGroup.tsx +3 -5
  279. package/src/features/agent/chat/ModernAgentOutput/WorkstreamTabs.tsx +326 -42
  280. package/src/features/agent/chat/hooks/useFileProcessing.test.tsx +70 -0
  281. package/src/features/agent/chat/hooks/useFileProcessing.ts +37 -6
  282. package/src/features/facets/AgentRunnerFacetsNav.tsx +1 -2
  283. package/src/features/facets/InteractionsFacetsNav.tsx +30 -5
  284. package/src/features/facets/PromptsFacetsNav.tsx +13 -1
  285. package/src/features/facets/RunsFacetsNav.tsx +1 -2
  286. package/src/features/magic-pdf/AnnotatedImageSlider.tsx +1 -2
  287. package/src/features/magic-pdf/MagicPdfProvider.tsx +4 -4
  288. package/src/features/store/objects/DocumentSearchResults.tsx +11 -1
  289. package/src/features/store/objects/components/ContentOverview.tsx +1 -2
  290. package/src/features/store/objects/components/DocumentIcon.tsx +1 -2
  291. package/src/features/store/objects/components/DocumentInput.tsx +2 -2
  292. package/src/features/store/objects/search/DocumentSearchContext.test.ts +2 -2
  293. package/src/features/store/objects/search/DocumentSearchContext.ts +3 -3
  294. package/src/features/store/objects/selection/ObjectsActionContext.tsx +2 -27
  295. package/src/features/store/objects/selection/ObjectsActionContextClass.ts +1 -7
  296. package/src/features/store/objects/selection/ObjectsActionHooks.ts +0 -11
  297. package/src/features/store/objects/selection/SelectionActions.tsx +9 -34
  298. package/src/features/store/objects/selection/actions/DeleteObjectsAction.tsx +40 -7
  299. package/src/features/store/objects/selection/actions/StartWorkflowButton.tsx +104 -0
  300. package/src/features/store/objects/selection/actions/index.ts +0 -1
  301. package/src/features/store/types/ContentObjectTypesSearch.tsx +110 -1
  302. package/src/features/store/types/ContentObjectTypesTable.tsx +42 -3
  303. package/src/features/store/types/search/ObjectTypeSearchContext.tsx +1 -1
  304. package/src/i18n/locales/ar.json +17 -0
  305. package/src/i18n/locales/de.json +17 -0
  306. package/src/i18n/locales/en.json +33 -0
  307. package/src/i18n/locales/es.json +17 -0
  308. package/src/i18n/locales/fr.json +17 -0
  309. package/src/i18n/locales/it.json +17 -0
  310. package/src/i18n/locales/ja.json +17 -0
  311. package/src/i18n/locales/ko.json +17 -0
  312. package/src/i18n/locales/pt.json +17 -0
  313. package/src/i18n/locales/ru.json +17 -0
  314. package/src/i18n/locales/tr.json +17 -0
  315. package/src/i18n/locales/zh-TW.json +17 -0
  316. package/src/i18n/locales/zh.json +17 -0
  317. package/src/layout/Sidebar.tsx +6 -1
  318. package/src/router/NestedRouterProvider.tsx +2 -2
  319. package/src/router/Redirect.tsx +29 -0
  320. package/src/router/Router.tsx +1 -2
  321. package/src/router/index.ts +1 -0
  322. package/src/session/DevSessionProvider.tsx +46 -0
  323. package/src/session/UserSessionProvider.tsx +18 -2
  324. package/src/session/auth/composable.ts +41 -3
  325. package/src/session/index.ts +1 -0
  326. package/src/shell/VertesiaShell.tsx +27 -14
  327. package/src/shell/login/SignInRestrictedEnvStep.tsx +87 -0
  328. package/src/shell/login/SigninScreen.tsx +29 -16
  329. package/src/shell/login/productionUrl.test.ts +19 -0
  330. package/src/shell/login/productionUrl.ts +18 -0
  331. package/src/shell/login/signInUtils.ts +14 -1
  332. package/src/widgets/json-view/JSONCode.tsx +1 -2
  333. package/src/widgets/json-view/JSONTable.tsx +1 -2
  334. package/src/widgets/markdown/ArtifactContentRenderer.tsx +4 -7
  335. package/src/widgets/markdown/CodeBlockPlaceholder.tsx +1 -2
  336. package/src/widgets/monacoEditor/foldingProviders.ts +10 -15
  337. package/src/widgets/schema-editor/ManagedSchema.ts +1 -2
  338. package/src/widgets/upload/UploadResultCategory.tsx +2 -3
  339. package/src/widgets/xml-viewer/components/TextElement/index.tsx +1 -2
  340. package/lib/features/store/objects/selection/actions/StartWorkflowComponent.d.ts +0 -4
  341. package/lib/features/store/objects/selection/actions/StartWorkflowComponent.d.ts.map +0 -1
  342. package/lib/features/store/objects/selection/actions/StartWorkflowComponent.js +0 -77
  343. package/lib/features/store/objects/selection/actions/StartWorkflowComponent.js.map +0 -1
  344. package/src/features/store/objects/selection/actions/StartWorkflowComponent.tsx +0 -127
@@ -1,2 +1,9 @@
1
- import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{Styles as n,FormItem as a,Button as i,DotBadge as s,useTheme as o,Table as l,VTooltip as c,SelectBox as d,Modal as u,ModalTitle as h,ModalBody as m,ModalFooter as p,useFlag as f,useClickOutside as g,useToast as y,errorMessage as v}from"@vertesia/ui/core";import b,{clsx as x}from"clsx";import{Plus as w,Trash2 as N,Loader2 as k,Check as C,Copy as S,Download as A,Minimize2 as j,Maximize2 as O,X as $,Code as I,FileText as P,Table as R,Link as L,Image as F,MessageSquare as T,GitBranch as E,BarChart3 as D,Info as V,AlignLeft as z,SquarePen as M,ChevronDown as q,ChevronRight as _,UploadIcon as U,CheckCircleIcon as W,AlertCircleIcon as J,XCircleIcon as H}from"lucide-react";import B,{createContext as K,useContext as G,useState as Z,useRef as X,useMemo as Y,useEffect as Q,useCallback as ee,memo as te,useId as re}from"react";import ne from"ajv";import ae from"ajv-formats";import{useUITranslation as ie}from"@vertesia/ui/i18n";import{Editor as se}from"@monaco-editor/react";import oe from"debounce";import{FusionFragmentProvider as le,FusionFragmentHandler as ce}from"@vertesia/fusion-ux";import de from"dompurify";import*as ue from"@radix-ui/react-dialog";import{useUserSession as he}from"@vertesia/ui/session";import me from"papaparse";import{VegaEmbed as pe}from"react-vega";import{twMerge as fe}from"tailwind-merge";import ge from"mermaid";import ye,{defaultUrlTransform as ve}from"react-markdown";import be from"rehype-katex";import{remarkDefinitionList as xe,defListHastHandlers as we}from"remark-definition-list";import Ne from"remark-directive";import ke from"remark-gfm";import Ce from"remark-github-blockquote-alert";import Se from"remark-math";import Ae from"remark-supersub";import{visit as je,SKIP as Oe}from"unist-util-visit";import{XMLParser as $e}from"fast-xml-parser";import{SyntaxValidator as Ie}from"fast-xml-validator";import{isNil as Pe,omit as Re}from"lodash-es";const Le=K(void 0),Fe=Le.Provider;function Te(){const e=G(Le);if(!e)throw new Error("useFieldSet must be used within a Form or FieldSet element");return e}class Ee{object;components;disabled;constructor(e,t={},r=!1){this.object=e,this.components=t,this.disabled=r}}const De=K(void 0);function Ve(){const e=G(De);if(!e)throw new Error("useForm must be used within a Form element");return e}const ze=De.Provider,Me=B.forwardRef(({object:t,type:r="text",onChange:a,...i},s)=>{const[o,l]=Z(null!=t.value?String(t.value):""),[c,d]=Z(t.schema.isBoolean&&!0===t.value);i.className?i.className=b(n.INPUT,i.className):i.className=n.INPUT;const u=e=>{i.disabled||(l(e.target.value),t.schema.isBoolean?(t.value=e.target.checked,d(t.value)):t.value=e.target.value,a?.(e))};return"textarea"===r?e("textarea",{ref:s,...i,value:o,onChange:u}):e("input","checkbox"===r?{ref:s,...i,type:"checkbox",checked:c,onChange:u,className:"form-check-input"}:{ref:s,...i,type:r,value:o,onChange:u})});function qe({object:t,components:r,onSubmit:n,children:a,onChange:i,disabled:s}){return t.observer=i,e(ze,{value:new Ee(t,r||{},s??!1),children:e("form",{className:"w-full",onSubmit:e=>{e.stopPropagation(),e.preventDefault(),n?.(t.value)},children:a})})}function _e(){const t=Ve();return e("div",{className:"flex flex-col gap-4 w-full",children:t.object.properties.map(We)})}function Ue({children:r,...n}){return t(qe,{...n,children:[e(_e,{}),r]})}function We(t){return t.isList?e(Ke,{object:t},t.name):t.isObject?e(Be,{object:t},t.name):e(He,{object:t},t.name)}function Je(t,r){return t.isList?e(Ke,{object:t}):t.isObject?e(Be,{object:t}):e(He,{object:t,editor:r})}function He({object:t,editor:r,inline:n=!1}){r||(r=t.schema.editor);const{components:i,disabled:s}=Ve(),o=r&&i[r]||Me,l=t.getInputType();"checkbox"===l&&(n=!0);const c=e=>{s||(t.schema.isBoolean?t.value=e.target instanceof HTMLInputElement&&e.target.checked:t.schema.isNumber?t.value=parseFloat(e.target.value):t.value=e.target.value)};return t.isListItem?e(o,{object:t,type:l,onChange:c,disabled:s}):e(a,{label:t.title,required:t.schema.isRequired,description:t.schema.description,className:b("flex",n?"flex-row items-center":"flex-col"),children:e(o,{object:t,type:l,onChange:c,disabled:s})})}function Be({object:r}){return t("div",{className:"flex flex-col gap-4 my-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 dark:border-s-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.properties.map(We)]})}function Ke({object:r}){const{disabled:n}=Ve(),a=X((r.value??[]).length),[s,o]=Z(()=>(r.value??[]).map((e,t)=>t));return t("div",{className:"flex flex-col gap-4 my-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 darK:border-s-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.items.map((t,a)=>{const i=s[a];return e(Ge,{object:t,list:r,onDelete:()=>(e=>{n||(r.remove(e),o(t=>t.filter((t,r)=>r!==e)))})(a),disabled:n},i)}),e("div",{children:t(i,{variant:"outline",onClick:()=>{n||(r.add(),o(e=>[...e,a.current++]))},disabled:n,children:[e(w,{className:"size-6"})," Add"]})})]})}function Ge({list:r,object:n,onDelete:a,disabled:s}){const o="string"==typeof r.schema.arraySchema.editor?r.schema.arraySchema.editor:void 0;return t("div",{className:"flex gap-2 w-full",children:[e("div",{className:"flex-1",children:Je(n,o)}),e(i,{variant:"ghost",onClick:a,disabled:s,alt:"Delete",children:e(N,{className:"size-4 text-destructive"})})]})}function Ze({label:t,required:r,children:n}){return e(a,{label:t,required:r,children:n})}function Xe({children:t}){return e("p",{className:"mt-2 text-sm text-gray-500",children:t})}function Ye({children:t}){return e("p",{className:"mt-2 text-sm text-red-600",children:t})}class Qe{schema;properties={};_validator;constructor(e){this.schema=e||{type:"object",properties:{}},this.load()}get validator(){if(!this._validator){const e=new ne({allErrors:!0,strict:!1});ae(e),this._validator=e.compile(this.schema)}return this._validator}load(){if(this.schema.properties){const e=this.schema.properties;Object.keys(e).forEach(t=>{this.loadProperty(t,e[t])})}}hasProperties(){return Object.keys(this.properties).length>0}get title(){const e=this.schema.title;if("string"==typeof e)return e;const t=this.schema.name;return"string"==typeof t?t:void 0}get description(){return this.schema.description}loadProperty(e,t){let r;return r="array"===t.type?new tt(this,e,t):new et(this,e,t),this.properties[e]=r,r}get type(){return this.schema.type}validate(e){return this.validator(e)?null:this.validator.errors||[]}addProperty(e,t,r=!1){"object"!==this.schema.type&&(this.schema.type="object"),this.schema.properties||(this.schema.properties={});const n="string"==typeof t?"object"===(a=t)?{type:"object",properties:{}}:"array"===a?{type:"array",items:{}}:{type:a}:t;var a;const i=this.loadProperty(e,n);return this.schema.properties[i.name]=i.schema,r&&(i.isRequired=!0),i}removeProperty(e){this.schema.properties&&(delete this.schema.properties[e],Array.isArray(this.schema.required)&&(this.schema.required=this.schema.required.filter(t=>t!==e))),delete this.properties[e]}getProperty(e){return this.properties[e]}get editor(){return"string"==typeof this.schema.editor?this.schema.editor:void 0}}class et extends Qe{parent;name;constructor(e,t,r){if(super(r),this.parent=e,this.name=t,"array"===r.type)throw new Error("Array property must be instantiated using ArrayPropertySchema");"object"!==r.type||r.properties||(r.properties={})}get isMulti(){return!1}get isReadOnly(){return!!this.schema.readOnly}set isReadOnly(e){this.schema.readOnly=e}get defaultValue(){return this.schema.default}set defaultValue(e){this.schema.default=e}get enum(){return this.schema.enum}set enum(e){this.schema.enum=e}get isRequired(){const e=this.parent.schema.required;return!!e&&e.includes(this.name)}set isRequired(e){let t=Array.isArray(this.parent.schema.required)?this.parent.schema.required:[];t=e?t.concat(this.name):t.filter(e=>e!==this.name),this.parent.schema.required=t}get type(){return this.schema.type}set type(e){this.schema.type!==e&&(this.schema.type=e,"object"!==e&&(this.properties={},this.schema.properties=void 0))}remove(){this.parent.removeProperty(this.name)}get isBoolean(){return"boolean"===this.type}get isString(){return"string"===this.type}get isNumber(){return"number"===this.type||"integer"===this.type}get isObject(){return"object"===this.type}}class tt extends et{arraySchema;constructor(e,t,r){super(e,t,function(e){if("array"!==e.type)throw new Error("Expecting an array schema");if(e.items){if(Array.isArray(e.items))throw new Error("Tuple arrays are not supported")}else e.items={};return e.items}(r)),this.arraySchema=r}get isMulti(){return!0}}function rt(e){return(e=e.replace(/_/g," ").replace(/([a-z0-9])&([A-Z])/g,"$1 $2"))[0].toUpperCase()+e.slice(1)}function nt(e,t){if(t.editor)return t.editor;if(t.schema.format)return t.schema.format;switch(t.type){case"number":case"integer":return"number";case"boolean":return"checkbox";default:return"text"}}class at{parent;schema;name;observer;constructor(e,t,r){this.parent=e,this.schema=t,this.name=r}get isRoot(){return!this.parent}get root(){return this.parent?this.parent.root:this}get path(){return this.parent?this.parent.path.concat(this.name):[]}get isScalar(){return!1}get isListItem(){return!1}get isObject(){return!1}get isList(){return!1}get title(){return this.schema.title||rt(this.name)}onChange(e){this.observer&&!1===this.observer(this)||this.parent?.onChange(e)}}class it extends at{get isObject(){return!0}getProperty(e){const t=this.schema.properties[e];return t.isMulti?new ct(this,t,this.getOrInitArrayProperty(e)):t.isObject?new ot(this,t,t.name,this.getOrInitObjectProperty(e)):new lt(this,t)}getOrInitObjectProperty(e){let t=this.value[e];return t||(this.value[e]=t={}),t}getOrInitArrayProperty(e){let t=this.value[e];return t||(this.value[e]=t=[]),t}setPropertyValue(e,t){return this.value[e]!==t&&(this.value[e]=t,!0)}getPropertyValue(e){return this.value[e]}get properties(){const e=[];for(const t of Object.values(this.schema.properties))t.isMulti?e.push(new ct(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new ot(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new lt(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}}class st extends it{value;constructor(e,t={}){super(null,e instanceof Qe?e:new Qe(e),"#root"),this.value=t}}class ot extends it{value;constructor(e,t,r,n){super(e,t,r),this.value=n}}class lt extends at{constructor(e,t){super(e,t,t.name),void 0===e.value[this.name]&&void 0!==t.defaultValue&&(e.value[this.name]=t.defaultValue)}get isScalar(){return!0}set value(e){this.parent.setPropertyValue(this.name,e)&&this.onChange(this)}get value(){return this.parent.getPropertyValue(this.name)}getInputType(){return nt(this.name,this.schema)}}class ct extends at{value;items=[];constructor(e,t,r){super(e,t,t.name),this.value=r;for(const e of this.value)this.add()}get isList(){return!0}newItem(e){return this.schema.isObject?new dt(this,e):new ut(this,e)}add(){const e=this.newItem(this.items.length);return this.items.push(e),e}remove(e){const t=this.value;if(e>=0&&e<this.items.length){this.items.splice(e,1);for(let e=0,t=this.items.length;e<t;e++){const t=this.items[e];t.index=e,t.name=String(e)}}Array.isArray(t)&&e>=0&&e<t.length&&(t.splice(e,1),this.onChange(this))}[Symbol.iterator](){return this.items[Symbol.iterator]()}item(e){if(e<0||e>=this.value.length)return;const t=this.value[e];return this.schema.isObject?new ot(this,this.schema,String(e),t):new ut(this,e)}trim(){for(;void 0===this.items[this.items.length-1];)this.items.pop()}}class dt extends it{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&(e.value[t]={}),this.key=`${this.name}@${Date.now()}`}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}}class ut extends at{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&void 0!==e.schema.defaultValue&&(e.value[t]=e.schema.defaultValue),this.key=`${this.name}@${Date.now()}`}get isScalar(){return!0}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}getInputType(){return nt(this.name,this.schema)}}function ht({data:r,className:n}){const a=Y(()=>{try{return JSON.stringify(r,null,2)}catch(e){return console.error("Failed to stringify JSON:",e),"{}"}},[r]),i=Y(()=>a.split("\n"),[a]);return e("pre",{className:`h-full overflow-auto rounded-md border bg-background p-3 font-mono text-xs leading-5 text-foreground ${n||""}`,children:e("code",{children:i.map((e,r)=>t("span",{children:[ft(e),r<i.length-1?"\n":null]},r))})})}const mt=/("(?:\\.|[^"\\])*"?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,pt=/^\s*:/;function ft(t){mt.lastIndex=0;const r=[];let n=0,a=mt.exec(t);for(;null!==a;){a.index>n&&r.push(t.slice(n,a.index));const[i,s,o,l]=a,c=void 0!==s&&pt.test(t.slice(a.index+i.length))?"text-info":s?"text-success":o?"text-primary":l?"text-attention":void 0;r.push(e("span",{className:c,children:i},`${a.index}-${i}`)),n=a.index+i.length,a=mt.exec(t)}return n<t.length&&r.push(t.slice(n)),r.length?r:t}function gt({value:t}){return Array.isArray(t)?e("div",{className:"flex flex-col gap-4 px-2 h-full overflow-auto",children:e(xt,{value:t})}):e("div","object"!=typeof t||null==t?{className:"flex flex-col gap-4 px-2 h-full overflow-auto",children:e(bt,{name:"value",value:t})}:{className:"flex flex-col gap-4 px-2 h-full overflow-auto",children:Object.entries(t).map(([t,r])=>e(bt,{name:t,value:r},t))})}function yt({name:t}){return e("div",{className:"text-md font-semibold",children:rt(t)})}function vt({children:t,className:r}){return e("div",{className:b("flex flex-col gap-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 dark:border-s-slate-600",r),children:t})}function bt({name:r,value:n}){const a=kt(n);switch(a.type){case Nt.Inline:return t("div",{className:"w-full flex gap-2",children:[e(yt,{name:`${r}:`}),e("p",{children:a.value})]});case Nt.Paragraph:return t("div",{children:[e(yt,{name:r}),e("p",{children:a.value})]});case Nt.Prose:return t("div",{className:"prose dark:prose-invert",children:[e(yt,{name:r}),e("div",{className:"vprose dark:prose-invert",children:a.value})]});case Nt.Array:return e(xt,{name:r,value:n});case Nt.Object:return t("div",{children:[e(yt,{name:r}),e(vt,{className:"mt-2",children:Object.entries(n).map(([t,r])=>e(bt,{name:t,value:r},t))})]})}}function xt({name:r,value:n}){const a=n.join(" ").length,i=a/n.length,o="string"==typeof n[0]&&(a<80||a<400&&i<32),l=n.length>9,c=n.map((e,t)=>({item:e,index:t,key:`${t}-${JSON.stringify(e)}`}));return t("div",o?{className:"flex gap-2 flex-wrap",children:[r&&e(yt,{name:`${r}:`}),c.map(({item:t,key:r})=>e(s,{children:String(t)},r))]}:{children:[r&&e(yt,{name:r}),e("div",{className:"flex flex-col gap-2",children:c.map(({item:t,index:r,key:n})=>e(wt,{index:r,value:t,useBullet:l},n))})]})}function wt({index:r,value:n,useBullet:a}){const i=a?e("span",{className:"text-xl",children:"•"}):t("span",{children:[r+1,"."]}),s=kt(n);let o;switch(s.type){case Nt.Object:o=e(vt,{children:Object.entries(n).map(([t,r])=>e(bt,{name:t,value:r},t))});break;case Nt.Array:o=e(xt,{value:n});break;case Nt.Prose:o=e("div",{className:"prose dark:prose-invert",children:s.value});break;default:o=e("div",{children:s.value})}return t("div",{className:"flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pe-2 ps-4",children:[e("div",{className:"font-semibold text-gray-600 dark:text-gray-400",children:i}),e("div",{children:o})]})}var Nt;function kt(e){if(null==e)return{value:"-",type:Nt.Inline};if(Array.isArray(e))return{value:e,type:Nt.Array};if("string"==typeof e){const t=e.length;let r,n=e;return t<80?r=Nt.Inline:t>400?r=Nt.Prose:(r=Nt.Paragraph,n=e.replace(/(?:\n\n)+/g,"\n\n")),{type:r,value:n}}return"number"==typeof e||"boolean"==typeof e?{value:String(e),type:Nt.Inline}:{value:e,type:Nt.Object}}function Ct({value:t,viewCode:r=!1}){const{t:n}=ie();return t?e("div",{className:"relative w-full h-full flex flex-col",children:r||!St(t)?e(ht,{data:t}):e("div",{className:"flex-1 min-h-0 overflow-auto",children:e(gt,{value:t})})}):e("pre",{className:"whitespace-pre-wrap",children:n("misc.noData")})}function St(e){return null==e||("string"==typeof e||"number"==typeof e||"boolean"==typeof e||(Array.isArray(e)?e.every(St):"object"==typeof e&&Object.values(e).every(St)))}!function(e){e[e.Inline=0]="Inline",e[e.Paragraph=1]="Paragraph",e[e.Prose=2]="Prose",e[e.Array=3]="Array",e[e.Object=4]="Object"}(Nt||(Nt={}));const At=new Set;class jt{VgetValue;VsetValue;constructor(e,t){this.VgetValue=e,this.VsetValue=t}getValue(){return this.VgetValue()}setValue(e){this.VsetValue(e||"")}}function Ot({onChange:t,value:r,className:n,editorRef:a,language:i="javascript",path:s,debounceTimeout:l=0,options:c={},beforeMount:d,onMount:u,defaultValue:h,useCustomFolding:m=!1}){const[p,f]=Z(r||h||""),g=X(null),y=X(null),{theme:v}=o(),x="system"===v?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":v,w=r||h||"",N=X(()=>p),k=X(e=>{f(e),g.current&&g.current.setValue(e)});Q(()=>{N.current=()=>p},[p]),Q(()=>(a&&(a.current=new jt(()=>N.current(),e=>k.current(e))),()=>{a&&(a.current=void 0)}),[a]);const C=Y(()=>{if(t)return l>0?oe(e=>t(e),l):t},[t,l]),S=ee(async(e,t)=>{const r=e.getModel();if(!r)return;const n=/```[\s\S]*?```/g;for(const a of r.getValue().matchAll(n)){const n=r.getPositionAt(a.index).lineNumber,i=r.getPositionAt(a.index+a[0].length).lineNumber;e.setSelection(new t.Selection(n,1,i,1)),await(e.getAction("editor.createFoldingRangeFromSelection")?.run())}},[]),A=ee(e=>{const t=e||"";if(f(t),C){const e={docChanged:!0,state:{doc:{toString:()=>t,length:t.length}}};C(e)}},[C]),j=ee((e,t)=>{g.current=e,y.current=t,m&&function(e){At.has("markdown")||(At.add("markdown"),e.languages.registerFoldingRangeProvider("markdown",{provideFoldingRanges(e){const t=[],r=e.getLinesContent(),n=/^(#{1,6})\s/,a=[];for(let e=0;e<r.length;e++){const i=e+1,s=n.exec(r[e]);if(s){const e=s[1].length;for(;a.length>0&&a[a.length-1].level>=e;){const e=a.pop();i-1>e.line&&t.push({start:e.line,end:i-1})}a.push({level:e,line:i})}}const i=r.length;for(;a.length>0;){const e=a.pop();i>e.line&&t.push({start:e.line,end:i})}return t}}));for(const t of["javascript","typescript"])At.has(t)||(At.add(t),e.languages.registerFoldingRangeProvider(t,{provideFoldingRanges(e){const t=e.getLinesContent(),r=/^(#{1,6})\s/,n=[],a=[],i=[],s=[];let o=!1,l=!1,c="";for(let e=0;e<t.length;e++){const d=e+1,u=t[e],h=o;for(let e=0;e<u.length;e++){const t=u[e];if("\\"!==t)if(l)t===c&&(l=!1);else if(o)"`"===t&&(o=!1);else if("`"!==t)if('"'!==t&&"'"!==t){if("{"===t&&i.push(d),"}"===t&&i.length>0){const t=i.pop(),r=u.slice(e+1).trimStart().length>0?d-1:d;r>t&&n.push({start:t,end:r})}}else l=!0,c=t;else o=!0;else e++}if(h){const e=r.exec(u);if(e){const t=e[1].length;for(;s.length>0&&s[s.length-1].level>=t;){const e=s.pop();d-1>e.line&&a.push({start:e.line,end:d-1})}s.push({level:t,line:d})}if(!o)for(;s.length>0;){const e=s.pop();d>e.line&&a.push({start:e.line,end:d})}}}return[...n,...a]}}))}(t),k.current=t=>{f(t),e.setValue(t)},t.editor.defineTheme("errorLineTheme",{base:"dark"===x?"vs-dark":"vs",inherit:!0,rules:[],colors:{"editorError.background":"#ffebee","editorError.border":"#f44336"}}),t.editor.setTheme("errorLineTheme"),m&&setTimeout(()=>S(e,t),300),u?.(e,t)},[u,x,m,S]);Q(()=>{f(e=>w===e?e:(g.current&&g.current.setValue(w),w))},[w]),Q(()=>{if(!(w&&m&&g.current&&y.current))return;const e=g.current,t=y.current,r=setTimeout(()=>S(e,t),300);return()=>clearTimeout(r)},[w,m,S]);const O={fontSize:14,fontFamily:"monospace",minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"on",folding:!0,lineDecorationsWidth:10,lineNumbersMinChars:3,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2,insertSpaces:!0,fixedOverflowWidgets:!0,glyphMargin:!0,renderValidationDecorations:"on",renderLineHighlight:"line",hover:{enabled:!0,delay:100},quickSuggestions:{other:!0,comments:!0,strings:!0},...c};return e("div",{className:b(n,"w-full h-full!"),children:e(se,{className:"h-full w-full",height:"100%",theme:"dark"===x?"vs-dark":"light",language:i,path:s,value:p,onChange:A,onMount:j,beforeMount:d,options:O,defaultValue:h||""})})}function $t({value:r,onChange:n,onValidChange:a,readonly:i=!1,height:s="200px",placeholder:l,className:c}){const{theme:d}=o(),u=X(void 0),[h,m]=Z(null),p=Y(()=>{if(null==r)return l??"{}";try{return JSON.stringify(r,null,2)}catch{return"{}"}},[r,l]),f=ee(()=>{if(!u.current||i)return;const e=u.current.getValue();try{const t=JSON.parse(e);m(null),a?.(t)}catch{m("Invalid JSON")}},[i,a]);return t("div",{className:c,children:[e("div",{className:"border rounded overflow-hidden",style:{height:s},children:e(Ot,{defaultValue:p,editorRef:u,language:"json",theme:"dark"===d?"vs-dark":"vs",onChange:f,options:i?{readOnly:!0,domReadOnly:!0}:void 0})}),h&&e("p",{className:"text-xs text-destructive mt-1",children:h})]})}function It(e){if(!e.current)return null;try{return JSON.parse(e.current.getValue())}catch{return null}}function Pt({title:r,viewCode:n,setViewCode:a}){return t("div",{className:"flex items-center gap-1 bg-muted mb-2 p-1 rounded",children:[e(i,{variant:n?"ghost":"primary",size:"sm",alt:"Preview properties",onClick:()=>a(!1),children:r}),e(i,{variant:n?"primary":"ghost",size:"sm",alt:"View in JSON format",onClick:()=>a(!0),children:"JSON"})]})}function Rt(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/^./,e=>e.toUpperCase())}function Lt(n){if(null==n)return"Failed to query";if("string"==typeof n)return n;if(Array.isArray(n)){if(0===n.length)return"None";return n.some(e=>e&&"object"==typeof e)?e(r,{children:n.map((r,n)=>t("div",{className:"flex gap-1",children:[t("span",{className:"text-xs align-top pe-2 font-medium",children:[n+1,":"]}),e("span",{className:"text-xs",children:Lt(r)})]},n))}):n.map(e=>String(e)).join(", ")}return"object"==typeof n?e(r,{children:Object.entries(n).map(([r,n])=>t("div",{className:"flex gap-1",children:[t("span",{className:"text-xs align-top pe-2 font-medium",children:[Rt(r),":"]}),e("span",{className:"text-xs",children:Lt(n)})]},r))}):String(n)}function Ft({data:r,className:n}){const a=r?Object.entries(r):[];return e("table",{className:n||"mb-2 text-xs bg-muted rounded-sm w-full",children:e("tbody",{children:a.map(([r,n])=>t("tr",{className:"align-top hover:bg-background border-y",children:[e("td",{className:"align-top pe-4 p-2",children:Rt(r)}),e("td",{className:"p-2",children:Lt(n)})]},r))})})}function Tt(...e){return fe(x(e))}const Et=K(null);function Dt(){return G(Et)}function Vt(e){return e.startsWith("agents/")||e.startsWith("documents/")}function zt(e,t,r="inline"){return`artifact:${e}:${t}:${r}`}function Mt(e){return`file:${e}`}function qt({error:r,chartTitle:n}){return e("div",{className:"flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4",children:t("div",{className:"text-center",children:[t("p",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:["Cannot render ",n||"Vega-Lite"," chart"]}),e("p",{className:"text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate",children:r})]})})}function _t({isOpen:r,onClose:n,title:a,description:s,children:o}){const{t:l}=ie();return e(ue.Root,{open:r,onOpenChange:e=>!e&&n(),children:t(ue.Portal,{children:[e(ue.Overlay,{className:"fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),t(ue.Content,{className:"fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2",onEscapeKeyDown:n,children:[e(ue.Close,{asChild:!0,children:e(i,{variant:"unstyled",onClick:n,className:"absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm","aria-label":l("agent.closeFullscreen"),children:e($,{className:"w-5 h-5 text-gray-600 dark:text-gray-300"})})}),e("div",{className:"flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150",children:o}),e("div",{className:"flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl",children:t("div",{className:"flex flex-col",children:[e(ue.Title,{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:a||l("agent.dashboard")}),s&&e(ue.Description,{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5",children:s})]})})]})]})})}const Ut={categorical:["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],blues:["#dbeafe","#93c5fd","#3b82f6","#1d4ed8","#1e3a8a"],purples:["#f3e8ff","#c4b5fd","#8b5cf6","#6d28d9","#4c1d95"],diverging:["#ef4444","#fca5a5","#fef3c7","#86efac","#22c55e"]};function Wt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Jt(e){return Wt(e)}function Ht(e,t){if(!e?.encoding)return!1;for(const r of t)for(const t of Object.values(e.encoding))if(t.field===r)return!0;if(Array.isArray(e.layer))for(const r of e.layer)if(Ht(r,t))return!0;return!1}function Bt(e,t){if(!e)return!1;const r=e=>{if(!e)return!1;const r=e.color?.field;return!!r&&t.includes(r)};if(r(e.encoding))return!0;if(Array.isArray(e.layer))for(const t of e.layer)if(r(t.encoding))return!0;return!1}function Kt(e,t=[]){const r=[];if(!e||"object"!=typeof e)return r;if(e.data&&"object"==typeof e.data){const n=e.data.url;"string"==typeof n&&n.startsWith("artifact:")&&r.push({path:[...t,"data"],artifactPath:n.replace(/^artifact:/,"").trim()})}const n=["layer","vconcat","hconcat","concat","spec","repeat","facet"];for(const a of n)if(a in e){const n=e[a];Array.isArray(n)?n.forEach((e,n)=>{Jt(e)&&r.push(...Kt(e,[...t,a,String(n)]))}):Jt(n)&&r.push(...Kt(n,[...t,a]))}return r}const Gt=te(function({spec:n,artifactRunId:a}){const{t:s}=ie(),{title:o,description:l,options:c}=n,d=n.spec,[u,h]=Z(!1),[m,p]=Z(!1),[f,g]=Z(null),[y,v]=Z(!1),b=X(null),x=X(null),w=X(null),{client:N}=he(),$=Dt(),I=X(N);I.current=N;const P=X($);P.current=$;const[R,L]=Z(null),[F,T]=Z(!1),[E,D]=Z(null),V=c?.mode||"chart",z="dashboard"===V,M=c?.enableFullscreen??z,q=c?.height||function(e,t){if("chart"===t)return 280;let r=1;if(e.vconcat)r=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){const t=e.columns||2,n=Array.isArray(e.concat)?e.concat.length:1;r=Math.ceil(n/t)}else e.facet&&(r=2);return Math.max(500,280*r+40)}(d,V);Q(()=>{const e=Kt(d);if(0===e.length)return L(d),T(!1),void D(null);a?console.info("[VegaLiteChart] resolving artifacts with runId:",a,e.map(e=>e.artifactPath)):console.warn("[VegaLiteChart] artifact references found but artifactRunId is missing!",{references:e.map(e=>e.artifactPath),artifactRunId:a});let t=!1;T(!0),D(null);return(async()=>{const r=new Map,n=I.current,i=P.current;for(const s of e)try{const e=s.path.join(".");let t;if(a&&!Vt(s.artifactPath)){const e=zt(a,s.artifactPath,"inline");if(i)t=await i.getOrFetch(e,async()=>(await n.files.getArtifactDownloadUrl(a,s.artifactPath,"inline")).url);else{t=(await n.files.getArtifactDownloadUrl(a,s.artifactPath,"inline")).url}}else{const e=Mt(s.artifactPath);if(i)t=await i.getOrFetch(e,async()=>(await n.files.getDownloadUrl(s.artifactPath)).url);else{t=(await n.files.getDownloadUrl(s.artifactPath)).url}}const o=await fetch(t);if(!o.ok)throw new Error(`Failed to fetch artifact data: ${o.statusText}`);let l;if(s.artifactPath.toLowerCase().endsWith(".csv")){const e=await o.text();l=me.parse(e,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{const e=await o.json();l=Array.isArray(e)?e:[e]}r.set(e,l)}catch(e){return console.error(`Failed to resolve artifact: ${s.artifactPath}`,e),void(t||D(`Failed to load data from artifact: ${s.artifactPath}`))}if(!t){const e=function(e,t){const r=JSON.parse(JSON.stringify(e));for(const[e,n]of t){const t=e.split(".");let a=r;for(let e=0;e<t.length-1;e++){const r=a[t[e]];if(!Wt(r))break;a=r}const i=a[t[t.length-1]];Wt(i)&&(delete i.url,i.values=n)}return r}(d,r);L(e),T(!1)}})(),()=>{t=!0}},[d,a]);const[_,U]=Z(!1),W=X(!1);Q(()=>{const e=()=>{const e=document.documentElement.classList.contains("dark");e!==W.current&&(W.current=e,U(e))};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const[J,H]=Z(0),B=X(0);Q(()=>{if(!w.current)return;let e;const t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{const e=t[0]?.contentRect.width;e&&e!==B.current&&(B.current=e,H(e))},100)});t.observe(w.current);const r=w.current.clientWidth;return B.current=r,H(r),()=>{clearTimeout(e),t.disconnect()}},[]);const K=Y(()=>Kt(d).length>0,[d]),G=Y(()=>{if(K&&!R)return null;let e=R||d;return e?(c?.parameterValues&&(e=function(e,t){if(!t||0===Object.keys(t).length)return e;const r=JSON.parse(JSON.stringify(e)),n=e=>{for(const r of e)r.name&&r.name in t&&(r.value=t[r.name])};Array.isArray(r.params)&&n(r.params);const a=e=>{if(Array.isArray(e))for(const t of e)if(Array.isArray(t.params)&&n(t.params),t.vconcat&&a(t.vconcat),t.hconcat&&a(t.hconcat),t.concat&&a(t.concat),Array.isArray(t.layer))for(const e of t.layer)Array.isArray(e.params)&&n(e.params)};if(r.vconcat&&a(r.vconcat),r.hconcat&&a(r.hconcat),r.concat&&a(r.concat),Array.isArray(r.layer))for(const e of r.layer)e&&Array.isArray(e.params)&&n(e.params);return r}(e,c.parameterValues)),function(e){const t=JSON.parse(JSON.stringify(e)),r=["vconcat","hconcat","concat"];if(!r.some(e=>Array.isArray(t[e])))return t;const n=[];if(Array.isArray(t.params))for(const e of t.params)e&&"object"==typeof e&&e.name&&e.select&&n.push({name:e.name,param:e});if(0===n.length)return t;for(const{name:e,param:a}of n){const n=a.select?.fields||[],i="legend"===a.select?.bind;let s=null;for(const e of r)if(Array.isArray(t[e])){s=t[e];break}if(!s||0===s.length)continue;let o=0;for(let e=0;e<s.length;e++){const t=s[e];if(Ht(t,n)||i&&Bt(t,n)){o=e;break}}const l=s[o];l.params||(l.params=[]),l.params.push(a);const c=t.params??[];t.params=c.filter(t=>t.name!==e)}return Array.isArray(t.params)&&0===t.params.length&&delete t.params,t}(e)):null},[R,d,K,c?.parameterValues]),te=ee((e,t)=>{if(!e||"object"!=typeof e)return e;if(e.hconcat&&Array.isArray(e.hconcat)){const r=e.hconcat.length,n=(e.spacing??10)*(r-1),a=Math.floor((t-n)/r);return{...e,hconcat:e.hconcat.map(e=>te(e,a))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>te(e,t))};if(e.concat&&Array.isArray(e.concat)){const r=e.columns??e.concat.length,n=(e.spacing??10)*(r-1),a=Math.floor((t-n)/r);return{...e,concat:e.concat.map(e=>te(e,a))}}const r=e.width;return"container"===r||"number"==typeof r&&r>t?{...e,width:t}:e},[]),re=ee((e,t=!1)=>{if(!G)return null;const r=function(e){const t={background:"transparent",view:{stroke:"transparent"},range:{category:Ut.categorical,diverging:Ut.diverging,heatmap:Ut.purples,ramp:Ut.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:"round"},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:"#a1a1aa",titleColor:"#e4e4e7",gridColor:"#3f3f46",domainColor:"#52525b",tickColor:"#52525b",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:"#a1a1aa",titleColor:"#e4e4e7",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:"#fafafa",font:"Inter, system-ui, sans-serif",fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:"#71717a",titleColor:"#3f3f46",gridColor:"#e4e4e7",domainColor:"#d4d4d8",tickColor:"#d4d4d8",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:"#71717a",titleColor:"#3f3f46",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:"#18181b",font:"Inter, system-ui, sans-serif",fontSize:14,fontWeight:600}}}(_),n=t?"undefined"!=typeof window?Math.min(window.innerWidth-80,1400):1200:J>0?J-24:500,a="vconcat"in G||"hconcat"in G||"concat"in G,i=a?{type:"pad",contains:"padding"}:{type:"fit",contains:"padding"};let s=G;a&&n&&(s=te(G,n));const l=s.width,c=a?void 0:"container"===l?n:l??n,{width:d,...u}=s;return{$schema:"https://vega.github.io/schema/vega-lite/v6.json",...!a&&c?{width:c}:{},height:t?void 0:e,autosize:i,...a?s:u,...o&&!G.title?{title:o}:{},config:{...r,...G.config}}},[G,o,_,J,te]),ne=ee(async()=>{const e=y?x.current:b.current;if(e&&!m)try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),p(!0),setTimeout(()=>p(!1),2e3))},"image/png")}catch(e){console.error("Failed to copy chart:",e)}},[m,y]),ae=ee(async()=>{const e=y?x.current:b.current;if(e&&!u){h(!0);try{const t=await e.toImageURL("png",2),r=document.createElement("a");r.download=`${o||"chart"}.png`,r.href=t,r.click()}catch(e){console.error("Failed to export chart:",e)}finally{h(!1)}}},[o,u,y]),se=ee(e=>{b.current=e,g(null)},[]),oe=ee(e=>{x.current=e},[]),le=ee(e=>{console.error("Vega-Lite rendering error:",e),g(e instanceof Error?e.message:"Unknown error")},[]),ce=ee(()=>{v(e=>!e)},[]);Q(()=>{g(null)},[d]);const de=({className:r})=>t("div",{className:Tt("flex items-center gap-2",r),children:[t(i,{variant:"unstyled",onClick:ne,disabled:m,className:"text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1",title:s("agent.copyToClipboard"),children:[e(m?C:S,{className:"w-3 h-3"}),s(m?"agent.copied":"agent.copy")]}),t(i,{variant:"unstyled",onClick:ae,disabled:u,className:"text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1",title:s("agent.exportAsPng"),children:[e(A,{className:"w-3 h-3"}),s(u?"agent.exporting":"agent.export")]}),M&&t(i,{variant:"unstyled",onClick:ce,className:"text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1",title:s(y?"agent.exitFullscreen":"agent.fullscreen"),children:[e(y?j:O,{className:"w-3 h-3"}),s(y?"agent.exit":"agent.fullscreen")]})]});if(F||K&&!R)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||"Chart"})}),e("div",{className:"flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded",style:{width:"100%",height:q},children:t("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e(k,{className:"w-5 h-5 animate-spin"}),e("span",{className:"text-sm",children:"Loading data from artifacts..."})]})})]})});if(E)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||"Chart"})}),e("div",{style:{width:"100%",height:q},children:e(qt,{error:E,chartTitle:o})})]})});if(f)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||"Chart"})}),e("div",{style:{width:"100%",height:q},children:e(qt,{error:f,chartTitle:o})})]})});const ue=re(q),fe=re(0,!0);return ue?("undefined"!=typeof window&&localStorage.getItem("DEBUG_VEGA_RENDERS")&&console.log("VegaLite rendering with spec:",{title:o,hasData:!!ue.data?.values,dataLength:ue.data?.values?.length}),t(r,{children:[e("div",{className:Tt("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",z&&"border-2"),children:t("div",{className:"flex flex-col gap-2 p-3",children:[t("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-2",children:[e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||(z?"Dashboard":"Chart")}),z&&e("span",{className:"text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300",children:"Interactive"})]}),e(de,{})]}),l&&e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:l}),e("div",{ref:w,className:"bg-white dark:bg-gray-900 rounded overflow-hidden",style:{width:"100%",height:q,minWidth:0},children:e(pe,{spec:ue,onEmbed:e=>se(e.view),onError:le,options:{renderer:c?.renderer||"canvas",actions:!1}})})]})}),t(_t,{isOpen:y,onClose:()=>v(!1),title:o||(z?"Dashboard":"Chart"),description:l,children:[e("div",{className:"w-full h-full min-h-[calc(100vh-200px)]",children:fe&&e(pe,{spec:fe,onEmbed:e=>oe(e.view),onError:le,options:{renderer:c?.renderer||"canvas",actions:!1}})}),e("div",{className:"absolute bottom-6 end-6",children:e(de,{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700"})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId),Zt=B.createContext({});function Xt({children:t,artifactRunId:r,onProposalSelect:n,onProposalSubmit:a,MarkdownRenderer:i}){const s=Y(()=>({artifactRunId:r,onProposalSelect:n,onProposalSubmit:a,MarkdownRenderer:i}),[r,n,a,i]);return e(Zt.Provider,{value:s,children:t})}function Yt(){return B.useContext(Zt)}const Qt={chart:{icon:D,label:"chart",defaultHeight:200},mermaid:{icon:E,label:"diagram",defaultHeight:150},proposal:{icon:T,label:"options",defaultHeight:100},code:{icon:I,label:"code",defaultHeight:80},image:{icon:F,label:"image",defaultHeight:150},link:{icon:L,label:"link",defaultHeight:24},expand:{icon:A,label:"content",defaultHeight:100},table:{icon:R,label:"table",defaultHeight:150},markdown:{icon:P,label:"content",defaultHeight:100},"fusion-fragment":{icon:I,label:"fragment",defaultHeight:150}};function er({type:r,error:n,onRetry:a,message:s,height:o}){const l=Qt[r],c=o??l.defaultHeight,d="link"===r;if(n)return t("div",{className:"flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive "+(d?"inline-flex px-2 py-1 text-sm":"p-4"),style:d?void 0:{minHeight:c},children:[t("span",{className:"text-destructive",children:["Failed to load ",l.label]}),a&&e(i,{variant:"unstyled",onClick:a,className:"ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive",children:"Retry"})]});const u=l.icon;return d?t("span",{className:"inline-flex items-center gap-1 text-muted animate-pulse",children:[e(u,{className:"h-3 w-3"}),e("span",{children:s||`Loading ${l.label}...`})]}):t("div",{className:"flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse",style:{minHeight:c},children:[e(u,{className:"h-8 w-8 text-muted"}),e("span",{className:"text-sm text-muted",children:s||`Loading ${l.label}...`}),e("div",{className:"flex gap-1",children:[...Array(3)].map((t,r)=>e("div",{className:"h-2 w-2 rounded-full bg-muted animate-bounce",style:{animationDelay:150*r+"ms"}},r))})]})}class tr extends B.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){const{type:r,fallbackCode:n}=this.props;return t("div",{className:"space-y-2",children:[e(er,{type:r,error:this.state.error?.message||"Rendering failed",onRetry:this.handleRetry}),n&&t("details",{className:"text-sm",children:[e("summary",{className:"cursor-pointer text-muted hover:text-foreground",children:"Show raw content"}),e("pre",{className:"mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs",children:e("code",{children:n})})]})]})}return this.props.children}}function rr(e){if("object"!=typeof e||null===e)return null;const t=e;return"vega-lite"===t.library&&"spec"in t&&"object"==typeof t.spec&&null!==t.spec?t:"string"==typeof t.$schema&&t.$schema.includes("vega")?{library:"vega-lite",spec:t}:null}function nr({content:r}){const{headers:n,rows:a}=Y(()=>{if(!Array.isArray(r)||0===r.length)return{headers:[],rows:[]};const e=r[0];if("object"!=typeof e||null===e)return{headers:[],rows:[]};const t=Object.keys(e),n=r.map(e=>t.map(t=>{const r=e[t];return null==r?"":"object"==typeof r?JSON.stringify(r):String(r)}));return{headers:t,rows:n}},[r]);return 0===n.length?e(er,{type:"table",error:"No table data found"}):t("div",{className:"overflow-x-auto",children:[t("table",{className:"min-w-full text-sm border-collapse",children:[e("thead",{children:e("tr",{className:"border-b",children:n.map((t,r)=>e("th",{className:"px-3 py-2 text-start font-medium text-muted",children:t},r))})}),e("tbody",{children:a.slice(0,100).map((t,r)=>e("tr",{className:"border-b border-muted/20",children:t.map((t,r)=>e("td",{className:"px-3 py-2",children:t},r))},r))})]}),a.length>100&&t("div",{className:"text-sm text-muted py-2",children:["Showing 100 of ",a.length," rows"]})]})}function ar({content:t,path:r}){const n=r.split(".").pop()?.toLowerCase()||"",a="string"==typeof t?t:JSON.stringify(t,null,2);return e("pre",{className:"overflow-x-auto p-3 bg-muted/10 rounded text-sm",children:e("code",{className:`language-${n}`,children:a})})}function ir(e){return de.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:["use"],FORBID_TAGS:["foreignObject"]})}function sr(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let r=t;if(!/viewBox/i.test(r)){const e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(r),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(r);e&&t&&(r+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return r=r.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,"").replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,""),/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):r+=' style="width:100%;height:auto;display:block;max-width:100%;"',/preserveAspectRatio=/i.test(r)||(r+=' preserveAspectRatio="xMidYMid meet"'),`<svg${r}>`})}function or({content:t}){const r=Y(()=>{const e="string"==typeof t?t.trim():"";return e?sr(ir(e)):null},[t]);return r?e("div",{style:{margin:"16px 0",width:"100%",overflowX:"auto"},dangerouslySetInnerHTML:{__html:r}}):e(er,{type:"expand",error:"Empty mockup"})}function lr({content:t,path:r}){const n="string"==typeof t?t:"",a=r.split("/").pop()||"Artifact image";return e("img",{src:n,alt:a,className:"max-w-full h-auto rounded",loading:"lazy"})}function cr({content:t,renderType:r,path:n,runId:a,contentType:i}){const{MarkdownRenderer:s}=Yt(),o=Y(()=>"auto"!==r?r:function(e,t,r){const n=t.split(".").pop()?.toLowerCase();if("svg"===n)return"mockup";if(["png","jpg","jpeg","gif","webp"].includes(n||""))return"image";if("md"===n)return"markdown";if("csv"===n)return"table";if("json"===r&&"object"==typeof e&&null!==e){const t=e;if("string"==typeof t.$schema&&t.$schema.includes("vega"))return"vega-lite";if("vega-lite"===t.library&&"spec"in t)return"vega-lite";if("template"in t&&"data"in t)return"fusion-fragment";if(Array.isArray(e)&&e.length>0&&"object"==typeof e[0])return"table"}return"code"}(t,n,i),[t,n,i,r]);switch(o){case"chart":{const r=rr(t);return r?e(tr,{type:"chart",fallbackCode:JSON.stringify(t,null,2),children:e(Gt,{spec:r,artifactRunId:a})}):e(er,{type:"chart",error:"Only Vega-Lite charts are supported. Recharts rendering has been retired."})}case"vega-lite":{const r=rr(t);return r?e(tr,{type:"chart",fallbackCode:JSON.stringify(t,null,2),children:e(Gt,{spec:r,artifactRunId:a})}):e(er,{type:"chart",error:"Invalid Vega-Lite specification"})}case"fusion-fragment":{const r=t;return console.log("[ArtifactContentRenderer] fusion-fragment:",{hasTemplate:!!r.template,hasData:!!r.data,runId:a,hasVegaLiteChart:!!Gt}),r.template&&r.data?e(tr,{type:"fusion-fragment",fallbackCode:JSON.stringify(t,null,2),children:e(le,{data:r.data,ChartComponent:Gt,artifactRunId:a,children:e(ce,{code:JSON.stringify(r.template),data:r.data})})}):e(tr,{type:"fusion-fragment",fallbackCode:JSON.stringify(t,null,2),children:e(ce,{code:JSON.stringify(t)})})}case"table":return e(tr,{type:"table",fallbackCode:JSON.stringify(t,null,2),children:e(nr,{content:t})});case"markdown":{const r="string"==typeof t?t:String(t);return e(tr,{type:"markdown",fallbackCode:r,children:s?e(s,{artifactRunId:a,children:r}):e("pre",{className:"overflow-x-auto p-3 bg-muted/10 rounded text-sm",children:e("code",{children:r})})})}case"mockup":return e(tr,{type:"expand",fallbackCode:"string"==typeof t?t:n,children:e(or,{content:t})});case"image":return e(tr,{type:"image",fallbackCode:n,children:e(lr,{content:t,path:n})});default:return e(ar,{content:t,path:n})}}class dr{components={};registerComponent(e,t){this.components[e]=t}getComponent(e){return this.components[e]}}const ur=K(null);function hr({components:t,children:r}){const n=Y(()=>{const e=new dr;for(const[r,n]of Object.entries(t))e.registerComponent(r,n);return e},[t]);return e(ur.Provider,{value:n,children:r})}function mr(){return G(ur)}function pr(e){const t=G(ur);if(t)return t.getComponent(e)}const fr='Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';function gr({code:t,className:r}){const n=X(null),[a,i]=Z(null),[s,o]=Z(null),l=re().replace(/:/g,"_");return Q(()=>{let e=!1;return(async()=>{if(!t.trim())return i(null),void o(null);try{o(null);const r=`mermaid-${l}-${Date.now()}`,n=function(e){const t=e.trim();let r="",n=!1,a=!1;for(let e=0;e<t.length;e++){const i=t[e],s=e>0?t[e-1]:"";if('"'!==i||a||"\\"===s)if("'"!==i||n||"\\"===s){if((n||a)&&"\\"===i){let n=e;for(;"\\"===t[n];)n++;if("n"===t[n]){r+="<br/>",e=n;continue}}r+=i}else a=!a,r+=i;else n=!n,r+=i}return r}(t),{svg:a}=await ge.render(r,n),s=function(e){return e.replace(/<svg([^<>]*)>/i,(e,t)=>{let r=t.replace(/\swidth="[^"]*"/i,"").replace(/\sheight="[^"]*"/i,"");return/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):r+=' style="width:100%;height:auto;display:block;max-width:100%;"',/preserveAspectRatio=/i.test(r)||(r+=' preserveAspectRatio="xMidYMid meet"'),`<svg${r}>`})}(a);e||i(s)}catch(t){if(!e){const e=t instanceof Error?t.message:"Failed to render mermaid diagram";o(e),i(null)}}})(),()=>{e=!0}},[t,l]),s?null:e("div",a?{ref:n,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${r||""}`,dangerouslySetInnerHTML:{__html:a}}:{className:`my-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg animate-pulse ${r||""}`,children:e("div",{className:"h-32 bg-gray-200 dark:bg-gray-700 rounded"})})}function yr({runId:e,path:t,parseJson:r=!0}){const{client:n}=he(),a=Dt(),i=X(n);i.current=n;const s=X(a);s.current=a;const[o,l]=Z({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),c=ee(async()=>{if(!e)return void l({data:void 0,rawContent:void 0,isLoading:!1,error:"No run ID provided",contentType:void 0});if(!t)return void l({data:void 0,rawContent:void 0,isLoading:!1,error:"No artifact path provided",contentType:void 0});l(e=>({...e,isLoading:!0,error:void 0}));const n=i.current,a=s.current,o=function(e){const t=e.split(".").pop()?.toLowerCase();switch(t){case"json":return"json";case"md":case"txt":case"csv":case"yaml":case"yml":default:return"text";case"png":case"jpg":case"jpeg":case"gif":case"webp":case"pdf":return"binary"}}(t);try{const i=zt(e,t,"inline");let s;if(a)s=await a.getOrFetch(i,async()=>(await n.files.getArtifactDownloadUrl(e,t,"inline")).url);else{s=(await n.files.getArtifactDownloadUrl(e,t,"inline")).url}const c=await fetch(s);if(!c.ok)throw new Error(`Failed to fetch artifact: ${c.status} ${c.statusText}`);if("binary"===o)return void l({data:s,rawContent:void 0,isLoading:!1,error:void 0,contentType:o});const d=await c.text();let u;if(r&&"json"===o)try{u=JSON.parse(d)}catch{u=d}else u=d;l({data:u,rawContent:d,isLoading:!1,error:void 0,contentType:o})}catch(e){const r=e instanceof Error?e.message:"Failed to fetch artifact";console.error("Failed to fetch artifact content:",t,e),l({data:void 0,rawContent:void 0,isLoading:!1,error:r,contentType:o})}},[e,t,r]);Q(()=>{c()},[c]);const d=ee(()=>{l({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),c()},[c]);return{data:o.data,rawContent:o.rawContent,isLoading:o.isLoading,error:o.error,contentType:o.contentType,retry:d}}function vr(e){const t=e.trim();if(t.length<2)return!0;if(!t.startsWith("{"))return!1;try{return JSON.parse(t),!1}catch(e){const r=["unexpected end","unterminated string","expected","unexpected token"],n=(e instanceof Error?e.message:"").toLowerCase();if(r.some(e=>n.includes(e))){let e=0,r=0,n=!1,a=!1;for(const i of t)a?a=!1:"\\"!==i?'"'!==i?n||("{"===i?e++:"}"===i?e--:"["===i?r++:"]"===i&&r--):n=!n:a=!0;return e>0||r>0||n}return!1}}function br(e){try{let t=e.trim();const r=t.indexOf("{"),n=t.lastIndexOf("}");return-1!==r&&n>r&&(t=t.slice(r,n+1)),JSON.parse(t)}catch{return null}}function xr({code:t}){const{artifactRunId:r}=Yt();r||console.warn("[VegaLiteCodeBlockHandler] artifactRunId is missing from CodeBlockContext");const n=Y(()=>vr(t),[t]),a=Y(()=>{if(n)return null;const e=br(t);return e?{library:"vega-lite",spec:e}:null},[t,n]);return n?e(er,{type:"chart",message:"Loading chart..."}):a?e(tr,{type:"chart",fallbackCode:t,children:e(Gt,{spec:a,artifactRunId:r})}):e(er,{type:"chart",error:"Invalid Vega-Lite specification"})}function wr({code:t}){const{artifactRunId:r}=Yt();r||console.warn("[ChartCodeBlockHandler] artifactRunId is missing from CodeBlockContext");const n=Y(()=>vr(t),[t]),a=Y(()=>{if(n)return null;const e=br(t);if(!e)return null;const r=function(e){const t="string"==typeof e.$schema&&e.$schema.includes("vega"),r="vega-lite"===e.library&&"spec"in e;return t||r?"vega-lite":null}(e);return r?"vega-lite"===e.library&&"spec"in e&&"object"==typeof e.spec?e:{library:"vega-lite",spec:e}:null},[t,n]);return n?e(er,{type:"chart",message:"Loading chart..."}):a?e(tr,{type:"chart",fallbackCode:t,children:e(Gt,{spec:a,artifactRunId:r})}):e(er,{type:"chart",error:"Invalid Vega-Lite chart specification"})}function Nr({code:t}){const r=t.trim();return r?e(tr,{type:"mermaid",fallbackCode:t,children:e(gr,{code:r})}):e(er,{type:"mermaid",error:"Empty diagram"})}function kr({code:t}){const r=Y(()=>{const e=t.trim();return e?sr(ir(e)):null},[t]);return r?e(tr,{type:"code",fallbackCode:t,children:e("div",{style:{margin:"16px 0",width:"100%",overflowX:"auto"},dangerouslySetInnerHTML:{__html:r}})}):e(er,{type:"code",error:"Empty mockup"})}function Cr({code:t,language:r}){const{artifactRunId:n}=Yt(),a=t.trim(),i=Y(()=>{if(!r?.includes(":"))return"auto";const e=r.split(":")[1];return["chart","vega-lite","table","markdown","fusion-fragment","mockup","code","image","auto"].includes(e)?e:"auto"},[r]),{data:s,isLoading:o,error:l,contentType:c}=yr({runId:n,path:a});return n?o?e(er,{type:"expand",message:`Loading ${a}...`}):l?e(er,{type:"expand",error:`Failed to load artifact: ${l}`}):void 0===s?e(er,{type:"expand",error:"No content found in artifact"}):e(cr,{content:s,renderType:i,path:a,runId:n,contentType:c}):e(er,{type:"expand",error:"No artifact run ID available"})}function Sr(e){return e?.startsWith("expand")??!1}function Ar(){return{chart:wr,"vega-lite":xr,vegalite:xr,mermaid:Nr,mockup:kr,svg:kr}}function jr(e){return e.trim().replace(/^\/+/,"")}function Or(e){return e.startsWith("artifact:")?{scheme:"artifact",path:e.slice(9).trim()}:e.startsWith("image:")?{scheme:"image",path:e.slice(6).trim()}:e.startsWith("store:")?{scheme:"store",path:jr(e.slice(6))}:e.startsWith("document:")?{scheme:"document",path:jr(e.slice(9))}:e.startsWith("collection:")?{scheme:"collection",path:jr(e.slice(11))}:{scheme:"standard",path:e}}function $r(e,t){switch(e){case"store":case"document":return t?`/store/objects/${t}`:null;case"collection":return t?`/store/collections/${t}`:null;default:return null}}function Ir({rawUrl:e,artifactRunId:t,disposition:r="inline"}){const{client:n}=he(),a=Dt(),i=X(n);i.current=n;const s=X(a);s.current=a;const{scheme:o,path:l}=Or(e),c=$r(o,l),[d,u]=Z(()=>{if(c)return{url:c,isLoading:!1,error:void 0};if("standard"===o)return{url:e,isLoading:!1,error:void 0};if(a&&("artifact"===o||"image"===o)){let e;e="artifact"===o&&t&&!Vt(l)?zt(t,l,r):Mt(l);const n=a.getUrl(e);if(n)return{url:n,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),h=ee(async()=>{if(c||"standard"===o)return;if("artifact"!==o&&"image"!==o)return void u({url:void 0,isLoading:!1,error:`Unknown scheme: ${o}`});u(e=>({...e,isLoading:!0,error:void 0}));const e=i.current,n=s.current;try{let a;if("artifact"===o)if(t&&!Vt(l)){const i=zt(t,l,r);if(n)a=await n.getOrFetch(i,async()=>(await e.files.getArtifactDownloadUrl(t,l,r)).url);else{a=(await e.files.getArtifactDownloadUrl(t,l,r)).url}}else{const t=Mt(l);if(n)a=await n.getOrFetch(t,async()=>(await e.files.getDownloadUrl(l)).url);else{a=(await e.files.getDownloadUrl(l)).url}}else{const t=Mt(l);if(n)a=await n.getOrFetch(t,async()=>(await e.files.getDownloadUrl(l)).url);else{a=(await e.files.getDownloadUrl(l)).url}}u({url:a,isLoading:!1,error:void 0})}catch(e){const t=e instanceof Error?e.message:"Failed to resolve URL";console.error("Failed to resolve URL:",l,e),u({url:void 0,isLoading:!1,error:t})}},[o,l,t,r,c]);Q(()=>{if(d.url&&!d.error)return;let e=!1;return e||(async()=>{await h()})(),()=>{e=!0}},[h,d.url,d.error]);const m=ee(()=>{u({url:void 0,isLoading:!0,error:void 0}),h()},[h]);return{url:d.url,isLoading:d.isLoading,error:d.error,scheme:o,retry:m}}function Pr({src:r,alt:n,caption:a,className:i,artifactRunId:s}){const o=r||"",{scheme:l}=Or(o);return"standard"===l?t("figure",{className:"my-4",children:[e("img",{src:r,alt:n,className:i}),e("figcaption",{className:"mt-2 text-sm text-muted text-center italic",children:a})]}):e(Rr,{rawSrc:o,alt:n,caption:a,artifactRunId:s,className:i})}function Rr({rawSrc:r,alt:n,caption:a,artifactRunId:i,className:s}){const{url:o,isLoading:l,error:c,retry:d}=Ir({rawUrl:r,artifactRunId:i,disposition:"inline"});return l?e(er,{type:"image",message:n?`Loading ${n}...`:void 0}):c?e(er,{type:"image",error:c,onRetry:d}):o?t("figure",{className:"my-4",children:[e("img",{src:o,alt:n,className:s}),e("figcaption",{className:"mt-2 text-sm text-muted text-center italic",children:a})]}):null}function Lr({node:t,src:r,alt:n,className:a,artifactRunId:i,ExistingImg:s,...o}){const l=r||"",{scheme:c}=Or(l);return"standard"===c?"function"==typeof s?e(s,{node:t,src:r,alt:n,...o}):e("img",{src:r,alt:n,className:a,...o}):e(Fr,{rawSrc:l,alt:n,artifactRunId:i,className:a,rest:o})}function Fr({rawSrc:t,alt:r,artifactRunId:n,className:a,rest:i}){const{url:s,isLoading:o,error:l,retry:c}=Ir({rawUrl:t,artifactRunId:n,disposition:"inline"});return o?e(er,{type:"image",message:r?`Loading ${r}...`:void 0}):l?e(er,{type:"image",error:l,onRetry:c}):s?e("img",{src:s,alt:r,className:a,...i}):null}function Tr({node:t,href:r,children:n,className:a,artifactRunId:i,ExistingLink:s,...o}){const l=r||"",{scheme:c,path:d}=Or(l),u=$r(c,d);return u?"function"==typeof s?e(s,{node:t,href:u,...o,children:n}):e("a",{href:u,...o,className:a,target:"_blank",rel:"noopener noreferrer",children:n}):"standard"===c?"function"==typeof s?e(s,{node:t,href:r,...o,children:n}):e("a",{href:r,...o,className:a,target:"_blank",rel:"noopener noreferrer",children:n}):e(Er,{rawHref:l,artifactRunId:i,className:a,rest:o,children:n})}function Er({rawHref:t,artifactRunId:r,className:n,children:a,rest:i}){const{url:s,isLoading:o,error:l,retry:c}=Ir({rawUrl:t,artifactRunId:r,disposition:"attachment"});return o?e("span",{className:"inline-flex items-center gap-1 text-muted",children:e(er,{type:"link"})}):l?e("span",{className:"inline-flex items-center gap-1",children:e(er,{type:"link",error:l,onRetry:c})}):e("a",{href:s||"#",...i,className:n,target:"_blank",rel:"noopener noreferrer",children:a})}ge.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:fr,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:fr}});const Dr=["artifact:","image:","store:","document://","collection:"],Vr=/(!?\[[^[\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:)[^)[\n]+)(\))/g,zr=/`[^`\n]*`/g,Mr=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,qr=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function _r(e){return Dr.some(t=>e.startsWith(t))}function Ur(e){return e.replace(Vr,(e,t,r,n)=>`${t}${function(e){const t=e.trim();if(t.startsWith("<")){const r=t.indexOf(">");if(r>0&&_r(t.slice(1,r).trim()))return e}const r=t.match(qr),n=r?.index??-1,a=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):"";return _r(a)?`<${a}>${i}`:e}(r)}${n}`)}function Wr(e){let t="",r=0;for(const n of e.matchAll(zr))t+=Ur(e.slice(r,n.index)),t+=n[0],r=n.index+n[0].length;return t+=Ur(e.slice(r)),t}const Jr=/^([ \t]*):::([^\n]*?):::[ \t]*$/gm,Hr=/^\w+/;const Br=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,Kr=/`[^`\n]*`/g,Gr=/\\\$/g,Zr=/\\[^\s]/,Xr=/[{}]/,Yr=/[_^][\w{]/,Qr=/^[a-zA-Z]$/,en=/^[a-zA-Z]\s*=/,tn=/^\s/,rn=/\s$/,nn=/[+*/-]$/,an=/\^[+-]$/;function sn(e){return Zr.test(e)||Xr.test(e)||Yr.test(e)||Qr.test(e)||en.test(e)}function on(e){return!!tn.test(e)||(!!rn.test(e)||!(!nn.test(e)||an.test(e)))}function ln(e,t,r){const n=e.slice(t+1,r);return 0===n.length||n.includes("\n")?null:n}function cn(e){const t=function(e){const t=[];for(let r=0;r<e.length;r++)"$"===e[r]&&(r>0&&"\\"===e[r-1]||(r+1<e.length&&"$"===e[r+1]?r++:r>0&&"$"===e[r-1]&&(r<2||"\\"!==e[r-2])||t.push(r)));return t}(e);if(t.length<2)return e;const r=new Set,n=new Set,a=new Array(t.length-1);for(let r=0;r<t.length-1;r++)a[r]=ln(e,t[r],t[r+1]);const i=[];for(let e=0;e<t.length-1;e++){if(r.has(e))continue;const n=a[e];null!==n&&sn(n)&&(r.add(e),r.add(e+1),i.push([t[e],t[e+1]]))}let s=0;for(;s<t.length;){if(r.has(s)){s++;continue}let e=s+1;for(;e<t.length&&r.has(e);)e++;if(e>=t.length)break;if(e>s+1){n.add(t[s]),s++;continue}const i=a[s];null!==i?(on(i)&&(n.add(t[s]),n.add(t[e])),r.add(s),r.add(e),s=e+1):s++}for(let e=0;e<t.length;e++)r.has(e)||e+1<t.length&&r.has(e+1)&&n.add(t[e]);if(0===n.size&&0===i.length)return e;const o=[];let l=0;const c=Array.from(n).sort((e,t)=>e-t);let d=0,u=0;for(;d<c.length||u<i.length;){const t=d<c.length?c[d]:1/0;if(t<(u<i.length?i[u][0]:1/0))t>l&&o.push(e.slice(l,t)),o.push("\\$"),l=t+1,d++;else{const[t,r]=i[u];t>l&&o.push(e.slice(l,t));const n=e.slice(t,r+1);for(o.push(n.replace(Gr,"\\text{\\textdollar}")),l=r+1;d<c.length&&c[d]<=r;)d++;u++}}return l<e.length&&o.push(e.slice(l)),o.join("")}function dn(e){const t=[];let r=0;for(const n of e.matchAll(Kr))t.push(cn(e.slice(r,n.index))),t.push(n[0]),r=n.index+n[0].length;return t.push(cn(e.slice(r))),t.join("")}const un={note:"md-callout-info",tip:"md-callout-info",warning:"md-callout-attention",important:"md-callout-attention",caution:"md-callout-destructive"},hn={note:"Note",tip:"Tip",warning:"Warning",important:"Important",caution:"Caution"};function mn(){return e=>{je(e,e=>{if("containerDirective"!==e.type&&"leafDirective"!==e.type&&"textDirective"!==e.type)return;const t=e;t.data||(t.data={});const r=t.data,n=t.attributes||{},a=t.name;if("pagebreak"===a)return r.hName="hr",void(r.hProperties={className:"md-pagebreak"});if("columns"===a)return r.hName="div",void(r.hProperties={className:"md-columns"});if("column"===a){r.hName="div";const e={className:"md-column"};return n.width&&(e.style=`flex-basis:${n.width};flex-grow:0;flex-shrink:0`),void(r.hProperties=e)}if(a in un){r.hName="div",r.hProperties={className:`md-callout ${un[a]}`,"data-callout-type":a};const e=hn[a];if(e&&t.children){const r={type:"paragraph",data:{hName:"p",hProperties:{className:"md-callout-title"}},children:[{type:"text",value:e}]};t.children.unshift(r)}return}r.hName="div",r.hProperties={className:`md-${a}`,...Object.fromEntries(Object.entries(n).filter(([e])=>"class"!==e))},n.class&&(r.hProperties.className+=` ${n.class}`)})}}const pn=["artifact:","image:","store:","document:","document://","collection:"];function fn(e){return pn.some(t=>e.startsWith(t))?e:ve(e)}function gn(){return e=>{je(e,"html",(e,t,r)=>{const n=e,a=r;if("string"==typeof n.value&&/<!--[\s\S]*?-->/.test(n.value)&&a?.children&&"number"==typeof t)return a.children.splice(t,1),[Oe,t]})}}const yn=Ar();function vn({children:t,components:r,remarkPlugins:n=[],removeComments:a=!0,artifactRunId:i,className:s,codeClassName:o,inlineCodeClassName:l,linkClassName:c,imageClassName:d,onProposalSelect:u,onProposalSubmit:h}){const m=mr(),p=B.useMemo(()=>{return e=function(e){if(!e||!Dr.some(t=>e.includes(t)))return e;let t="",r=0;for(const n of e.matchAll(Mr))t+=Wr(e.slice(r,n.index)),t+=n[0],r=n.index+n[0].length;return t+=Wr(e.slice(r)),t}(function(e){if(!e?.includes("$"))return e;const t=[];let r=0;for(const n of e.matchAll(Br))t.push(dn(e.slice(r,n.index))),t.push(n[0]),r=n.index+n[0].length;return t.push(dn(e.slice(r))),t.join("")}(t)),e?.includes(":::")?e.replace(Jr,(e,t,r)=>{const n=r.trim(),a=Hr.exec(n);if(!a)return e;const i=a[0],s=n.slice(i.length).trim();return s?`${t}:::${i}\n${t}${s}\n${t}:::`:`${t}::${i}`}):e;var e},[t]),f=B.useMemo(()=>{const e=[ke,Ne,mn,Ce,xe,Ae,Se,...n];return a&&e.push(gn),e},[n,a]),g=B.useMemo(()=>[be],[]),y=B.useMemo(()=>({handlers:{...we}}),[]),v=B.useMemo(()=>{const t=r||{},n=t.code,a=t.a,s=t.img;return{...t,code:({node:t,className:r,children:a,...i})=>{const s=/language-([\w-]+)/.exec(r||""),c=!s,d=s?s[1]:"";if(!c&&d){if(m){const t=m.getComponent(d);if(t){const r=String(a||"").trim();return e(t,{code:r,language:d})}}if(Sr(d)){const t=String(a||"").trim();return e(Cr,{code:t,language:d})}const t=yn[d];if(t){const r=String(a||"").trim();return e(t,{code:r,language:d})}}if("function"==typeof n)return e(n,{node:t,className:r,...i,children:a});return e("code",{...i,className:c?`px-1.5 py-0.5 rounded ${l||""}`:` ${o||""}`,children:a})},a:t=>{const{node:r,href:n,children:s,...o}=t;return e(Tr,{node:r,href:n,className:c,artifactRunId:i,ExistingLink:"function"==typeof a?a:void 0,...o,children:s})},img:t=>{const{node:r,src:n,alt:a,title:o,...l}=t;return o?e(Pr,{src:n,alt:a,caption:o,className:d,artifactRunId:i}):e(Lr,{node:r,src:n,alt:a,className:d,artifactRunId:i,ExistingImg:"function"==typeof s?s:void 0,...l})}}},[r,i,m,o,l,c,d]),b=e(Xt,{artifactRunId:i,onProposalSelect:u,onProposalSubmit:h,MarkdownRenderer:vn,children:e(ye,{remarkPlugins:f,rehypePlugins:g,remarkRehypeOptions:y,components:v,urlTransform:fn,children:p})});return e("div",s?{className:`md-content ${s}`,children:b}:{className:"md-content",children:b})}function bn({percent:t}){return e("div",{className:"w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700",children:e("div",{className:"bg-blue-600 h-2.5 rounded-full",style:{width:`${t}%`}})})}function xn({className:r,properties:n}){return e(l,{className:r,children:e("tbody",{children:n.map(r=>t("tr",{children:[t("td",{className:"w-1/3 font-semibold gap-2",children:[e("span",{children:r.name}),r.description&&e(c,{description:r.description,placement:"top",children:e(V,{className:"size-3 ms-2 text-muted-foreground"})})]}),e("td",{className:"w-2/3",children:r.value??"undefined"})]},r.name))})})}function wn({content:t,...r}){const n=X(null);return Q(()=>{if(!n.current)return;const e=(new DOMParser).parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)return console.warn("SvgIcon: No <svg> element found in provided string"),void(n.current.innerHTML="");Object.entries(r).forEach(([t,r])=>{if(null==r)return;const n="className"===t?"class":t;e.setAttribute(n,String(r))}),n.current.innerHTML="",n.current.appendChild(e)}),e("span",{ref:n})}function Nn(t){return r=>e(wn,{content:t,...r})}function kn(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}var Cn;!function(e){e.string="string",e.number="number",e.integer="integer",e.boolean="boolean",e.object="object",e.any="any",e.text="text",e.media="media",e.document="document"}(Cn||(Cn={}));const Sn=function(){const e=Object.values(Cn),t=[...e];for(const r of e)t.push(`${r}[]`);return e.sort(),t}();function An({value:r,onChange:n,onCancel:a,onSave:s}){const{t:o}=ie(),[l,c]=Z(!1);if(!r)return null;return t("div",{className:"flex items-center",children:[e("div",{className:"flex-1",children:e(jn,{value:r.name,onChange:e=>{n({...r,name:e})},onCancel:a,onSave:s})}),e("div",{className:"px-1 font-semibold",children:":"}),e("div",{className:"flex-1",children:e(On,{value:r.type,onChange:e=>{n({...r,type:e})},onCancel:a,onSave:s})}),t("div",{children:[e(i,{variant:"ghost",size:"xs",onClick:()=>c(!0),title:o("widgets.schema.editDescription"),children:e(z,{className:"size-4"})}),e($n,{value:r.description,isOpen:l,onClose:e=>{void 0!==e&&"string"==typeof e&&n({...r,description:e},!0),c(!1)}})]})]})}function jn({value:t,onChange:r,onCancel:a,onSave:i}){const s=X(null);Q(()=>{s.current?.focus()},[]);return e("input",{onKeyUp:e=>{switch(e.key){case"Enter":i?.();break;case"Escape":a?.()}},ref:s,value:t,onChange:e=>{r(e.target.value)},className:n.INPUT_UNSTYLED,style:{fontSize:"inherit",width:"",display:"inline"}})}function On({value:t,onChange:r,onCancel:a,onSave:i}){return e(d,{className:n.INPUT_UNSTYLED,options:Sn,value:t||"",onBlur:()=>{i?.()},onChange:r,onKeyDown:(e,t)=>{t||("Enter"===e.key?i?.():"Escape"===e.key&&a?.())},popupClass:"schema-type-suggest-popup z-90"})}function $n({value:r,isOpen:n,onClose:a}){const{t:i}=ie();return t(u,{isOpen:n,onClose:a,children:[e(h,{children:i("widgets.schema.editDescription")}),e(In,{value:r,onSave:a})]})}function In({value:n,onSave:a}){const{t:s}=ie(),o=X(null),[l,c]=Z(n||"");return Q(()=>{o.current?.focus()},[]),t(r,{children:[e(m,{className:"h-max",children:e("textarea",{ref:o,className:"dark:bg-gray-800 w-full h-full dark:text-white",value:l,onChange:e=>c(e.target.value)})}),e(p,{children:e(i,{onClick:()=>a(l),children:s("store.saveChanges")})})]})}function Pn({value:r}){return r?t("div",{className:"w-full flex items-baseline",children:[e("div",{children:r.name||""}),e("div",{className:"ms-2 text-sm text-muted",children:r.type||""})]}):null}function Rn(e,t){const r="any"===t.name?void 0:t.isNullable?[t.name,"null"]:t.name;if(t.isArray)if(e.type="array",e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:r,properties:t.isObject?{}:void 0};else{const n=e.items;n.type=r,t.isObject&&!n.properties&&(n.properties={})}else e.type=r,e.items=void 0,t.isObject?e.properties||(e.properties={}):e.properties=void 0}function Ln(e){let t,r=!1,n=!1;const a=e.type;if(Array.isArray(a))for(const e of a)"null"===e?r=!0:t||(t=e);else t=a;t||(t="any"),"array"===t&&(n=!0,t=function(e){if(!e)return"any";let t;t=Array.isArray(e)?Fn(e[0].type):Fn(e.type);"array"!==t&&"null"!==t||(t="any");return t}(e.items));let i=t;switch(e.editor){case"textarea":i="text";break;case"media":i="media";break;case"document":i="document"}return{isNullable:r,isArray:n,isObject:"object"===t,name:i}}function Fn(e){return e?Array.isArray(e)?e.find(e=>"null"!==e)||"any":e:"any"}let Tn=0;class En{source;onChange=()=>{};schema;root;constructor(e,t){this.schema=e?"string"==typeof e?JSON.parse(e):e:{title:t,type:"object",properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new Dn("",this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||0===this.root.children.length}get children(){return this.root.children}reload(){return this.root=new Dn("",this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){this.schema=e||{title:this.schema.title,type:"object",properties:{}},this.reload()}clone(){const e=new En(this.schema);return e.source=this.source,this.onChange&&e.withChangeListener(this.onChange),e}}class Dn{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,r,n){if(this.schema=t,this.loader=r,this.parent=n,this.name=e,this.type=Ln(t),this.parent){const t=this.parent._getPropertiesSchema().required;this.isRequired=!(!t||!Array.isArray(t))&&t.includes(e)}}get title(){return"string"==typeof this.schema.title?this.schema.title:void 0}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){const e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?"":"?"}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?"[]":""}${this.type.isNullable?"?":""}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[];const e=this.schema.items?.properties;this.schema.items&&e?this._loadChildren(e,this.children):this.schema.properties&&this._loadChildren(this.schema.properties,this.children)}_loadChildren(e,t){for(const r of Object.keys(e)){const n=e[r],a=new Dn(r,n,this.loader,this);t.push(a),a.isParent&&a.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){const t=this._getPropertiesSchema().properties||{};let r;do{r=e+ ++Tn}while(t[r]);return r}addChild(e,t,r=!1){if(!this.type.isObject)throw new Error("Cannot add child to a non object node");this.children||(this.children=[]);const n=function(e,t,r,n=!1){if("object"!==e.type)throw new Error("Cannot add property to a non-object schema");e.properties||(e.properties={});const a={};return Rn(a,r),e.properties[t]=a,n&&(Array.isArray(e.required)?function(e,t){e.includes(t)||e.push(t)}(e.required,t):e.required=[t]),a}(this._getPropertiesSchema(),e,t,r),a=new Dn(e,n,this.loader,this);return this.children.push(a),a}remove(){if(this.parent?.type.isObject){return function(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter(e=>e!==t)))}(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter(e=>e.name!==this.name)),!0}return!1}update(e){let t=!1;null!=e.name&&this.name!==e.name&&(this.parent&&function(e,t,r){if(e.properties){const n=e.properties,a={};for(const e of Object.keys(n)){const i=n[e];e===t?a[r]=i:a[e]=i}e.properties=a}e.required&&(e.required=e.required.map(e=>e===t?r:e))}(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),null!=e.isRequired&&this.isRequired!==e.isRequired&&(this.parent&&function(e,t,r){if(Array.isArray(e.required)){const n=e.required.indexOf(t);r?n<0&&e.required.push(t):n>-1&&e.required.splice(n,1)}else r&&(e.required=[t])}(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let r=e.type?.name;"any"===r&&(r=void 0);const n=r!==this.schema.type;return e.type&&(Rn(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||(this.children=[]):this.children=void 0,t=!0),this.schema.editor&&null===e.editor?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):n&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let r=e.trim(),n=!0;r.endsWith("?")&&(r=r.substring(0,r.length-1).trim(),n=!1);const a=function(e){let t=!1,r=!1;(e=e.trim()).endsWith("?")&&(r=!0,e=e.substring(0,e.length-1).trim()),e.endsWith("[]")&&(t=!0,e=e.substring(0,e.length-2).trim());const n=Cn[e];if(!n)throw new Error(`Unknown type "${e}"`);return{name:n,isArray:t,isNullable:r,isObject:n===Cn.object}}(t);let i;return"text"===a.name?(a.name=Cn.string,i="textarea"):"media"===a.name?(a.name=Cn.any,i="media"):"document"===a.name?(a.name=Cn.any,i="document"):i=null,{name:r,type:a,isRequired:n,editor:i}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){const t=(e=e.trim()).indexOf(":");if(t<0)throw new Error("Expecting a name and a type separated by a colon");const r=e.substring(0,t),n=e.substring(t+1);return this.updateFromNameAndTypeSignature(r,n)}}function Vn(e){const[t,r]=Z(new En(e||{type:"object",properties:{}}).withChangeListener(e=>{r(e.clone())}));return t}const zn="block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4",Mn=`${zn} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,qn=`${zn} shadow-xs ring-1 ring-inset ring-ring`;function _n({value:r,onChange:n,onDelete:a,outlineOnHover:i=!1,editOnClick:s=!0,placeholder:o,viewer:l,editor:c,skipClickOutside:d,isEditing:u=!1,readonly:h=!1,onValidate:m}){const{on:p,off:g,isOn:y}=f(u),[v,b]=Z();return t("div",{className:"",children:[y&&!h?e(Wn,{value:r,onSave:e=>{if(m){const t=m(e);if(t)return void b(t);b(void 0)}n(e)&&g()},onCancel:g,editor:c,skipClickOutside:e=>!!d&&d(e)}):e(Un,{value:r,onEdit:p,viewer:l,placeholder:o,outlineOnHover:i,editOnClick:s,onDelete:a,readonly:h}),v&&e("div",{className:"text-red-500 text-sm",children:v})]})}function Un({viewer:r,value:n,onEdit:a,editOnClick:s,outlineOnHover:o,placeholder:l,onDelete:c,readonly:d}){const u="invisible group-hover:visible";return t("div",{role:s?"button":void 0,tabIndex:0,onKeyUp:e=>{"Enter"===e.key&&a()},onClick:()=>{s&&a()},className:b("flex justify-start items-center group",o?Mn:zn,{"cursor-pointer":s}),children:[e(r,{value:n,placeholder:l}),t("div",{className:"ms-auto flex gap-2",children:[!d&&c&&e(i,{variant:"ghost",size:"sm",className:u,onClick:c,children:e(N,{className:"size-4"})}),d?null:e(i,{variant:"ghost",size:"sm",className:u,onClick:a,children:e(M,{className:"size-4"})})]})]})}function Wn({editor:t,value:r,onSave:n,onCancel:a,skipClickOutside:i}){const[s,o]=Z(r),l=X(r),[c,d]=Z(null),u=()=>{n(l.current)},h=g(u,i);return e("div",{ref:h,children:e("div",{className:qn,children:e("div",{className:"w-full",onClick:e=>e.stopPropagation(),children:e(t,{value:s,onChange:(e,t=!1)=>{o(e),l.current=e,t&&(c&&clearTimeout(c),d(setTimeout(()=>{n(e)},500)))},onSave:u,onCancel:a})})})})}function Jn(e){const t=e.target;return!!t.closest?.(".schema-type-suggest-popup")}function Hn({schema:r,readonly:n=!1}){return t("ul",{className:"",children:[r.children.map(e=>Bn(e,n)),n?null:e(Yn,{parent:r.root})]})}function Bn(t,r){return t.isParent?e(Gn,{property:t,readonly:r},t.name):e(Kn,{node:t,readonly:r},t.name)}function Kn({node:t,readonly:r}){return e("li",{children:e(Xn,{property:t,readonly:r})})}function Gn({property:r,readonly:n}){const[a,s]=Z(!0),o=a?q:_;return t("li",{children:[t("div",{className:"flex items-center w-full",children:[e(i,{variant:"ghost",size:"icon",onClick:()=>s(!a),"aria-label":a?`Collapse ${r.name}`:`Expand ${r.name}`,"aria-expanded":a,children:e(o,{className:"size-4 cn-rtl-flip"})}),e("div",{className:"flex-1",children:e(Xn,{property:r,readonly:n})})]}),a&&t("ul",{className:"ms-4 border-s border-gray-400 border-dashed",children:[(r.children||[]).map(e=>Bn(e,n)),n?null:e(Yn,{parent:r})]})]})}function Zn(e){return e?/^[a-zA-Z0-9_]+[?]?$/.test(e)?void 0:"Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)":"Name is required"}function Xn({property:t,readonly:r}){const{t:n}=ie(),a=y(),i=t.resetIsNew(),s=kn(t);return e(_n,{value:s,onChange:e=>{try{e.description&&"string"!=typeof e.description&&(e.description=void 0);const r=t.getUpdateFromNameAndTypeSignature(e.name,e.type);t.update({...r,description:e.description})&&t.reloadTree()}catch(e){return a({status:"error",title:n("widgets.schema.invalidPropertyDeclaration"),description:v(e),duration:9e3}),!1}return!0},onDelete:()=>{t.remove(),t.reloadTree()},editor:An,viewer:Pn,outlineOnHover:!0,isEditing:i,skipClickOutside:Jn,readonly:r,onValidate:e=>Zn(e.name)})}function Yn({parent:r}){return t(i,{variant:"ghost",onClick:()=>{const e=r.findAvailableChildName("new_property_");r.addChild(e,{isObject:!1,isArray:!1,isNullable:!1,name:Cn.string},!0).isNew=!0,r.reloadTree()},children:[e(w,{className:"size-4"}),"Add property"]})}function Qn({onDrop:r,message:n,buttonLabel:a,allowFolders:s=!0,className:o=""}){const{t:l}=ie(),c=a??l("upload.uploadFiles"),[d,u]=Z(!1),h=X(null),m=e=>{if(e&&e.length>0){const t=Array.from(e);if(t.some(e=>e.webkitRelativePath?.includes("/"))){const e=new Set(t.map(e=>e.webkitRelativePath.split("/")[0]).filter(Boolean)).size,n=t.length,a=l("upload.preparingFolder",{count:e,folderCount:e,fileCount:n}),i={count:t.length,message:a};r(t,i)}else{const e={count:t.length,message:l("upload.preparingFiles",{count:t.length})};r(t,e)}}};return t("div",{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${d?"border-color-primary bg-color-primary/10":"border-dashed border-color-border"} ${o}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.types.includes("Files")&&u(!0)},onDragLeave:e=>{e.preventDefault(),h.current&&!h.current.contains(e.relatedTarget)&&u(!1)},onDrop:async e=>{if(e.preventDefault(),u(!1),e.dataTransfer.items&&e.dataTransfer.items.length>0){const t=Array.from(e.dataTransfer.items),n=[],a=new Set,i=async e=>{if(function(e){return e.isFile}(e)){const t=await new Promise(t=>{e.file(r=>{Object.defineProperty(r,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(r)})});!t.name.startsWith(".")&&t.size>0&&n.push(t);const r=e.fullPath.substring(1).split("/").slice(0,-1).join("/");r&&a.add(r)}else if(function(e){return e.isDirectory}(e)){const t=e.createReader(),r=await new Promise(e=>{t.readEntries(t=>{e(t)})});await Promise.all(r.map(i));const n=e.fullPath.substring(1);n&&a.add(n)}};try{if(await Promise.all(t.map(e=>{const t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?i(t):Promise.resolve()})),n.length>0){const e=new Set(Array.from(a).map(e=>e.split("/")[0]).filter(Boolean)).size,t=n.length;let i="";i=e>0?l("upload.preparingFolder",{count:e,folderCount:e,fileCount:t}):l("upload.preparingFiles",{count:t}),r(n,{count:n.length,message:i})}}catch(t){console.error("Error processing dropped files:",t);const n=Array.from(e.dataTransfer.files);n.length>0&&r(n)}}else if(e.dataTransfer.files&&e.dataTransfer.files.length>0){const t=Array.from(e.dataTransfer.files);r(t)}},children:[e(U,{className:"h-12 w-12 mb-3 transition-colors "+(d?"text-primary":"text-muted/50")}),e("p",{className:"text-muted",children:n}),t("div",{className:"flex gap-2 justify-center mt-2",children:[e(i,{onClick:()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="*",e?.click(),e.onchange=()=>{m(e.files)}},children:c}),s&&e(i,{onClick:()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="*",e.webkitdirectory=!0,e?.click(),e.onchange=()=>{m(e.files)}},children:l("upload.selectFolder")})]})]})}function ea({title:r,count:n,icon:a=e(W,{className:"h-4 w-4 text-green-500"}),items:i}){const{t:s}=ie(),[o,l]=Z(!1),c=re();return t("div",{className:"border border-color-border rounded-md overflow-hidden",children:[t("button",{type:"button","aria-expanded":o,"aria-controls":c,className:"w-full flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer text-start bg-transparent border-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:()=>l(!o),children:[t("span",{className:"flex items-center",children:[e("span",{className:"me-2",children:a}),e("span",{className:"font-medium",children:r}),e("span",{className:"ms-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs",children:n})]}),e("span",{className:"text-muted","aria-hidden":"true",children:e("svg",{className:"h-5 w-5 transition-transform "+(o?"transform rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),o&&e("div",{id:c,className:"p-3 border-t border-color-border max-h-48 overflow-y-auto",children:i.length>0?e("ul",{className:"space-y-1",children:i.map((t,r)=>e("li",{className:"text-sm py-1 px-2 rounded hover:bg-color-muted/10",children:t},r))}):e("div",{className:"text-sm text-muted py-2",children:s("upload.noItems")})})]})}function ta({files:r,className:n="",location:a,collection:i}){const{t:s}=ie(),o=r.filter(e=>"success"===e.status),l=r.filter(e=>"updated"===e.status),c=r.filter(e=>"skipped"===e.status),d=r.filter(e=>"failed"===e.status),u=o.length,h=l.length,m=c.length,p=d.length,f=r.length;return t("div",{className:`flex flex-col py-2 ${n}`,children:[t("div",{className:"flex items-center mb-4",children:[e("div",{className:"size-8 me-4 rounded-full bg-success/10 flex items-center justify-center",children:e(W,{className:"size-4 text-success"})}),e("div",{children:t("p",{className:"text-muted",children:[s("upload.filesProcessed",{count:f}),i?s("upload.inCollection",{collection:i}):"",a?s("upload.inFolder",{location:a}):""]})})]}),t("div",{className:"space-y-3 mt-2",children:[u>0&&e(ea,{title:s("upload.successfullyUploaded"),count:u,icon:e(W,{className:"h-4 w-4 text-green-500"}),items:o.map(e=>e.name)}),h>0&&e(ea,{title:s("upload.successfullyUpdated"),count:h,icon:e(W,{className:"h-4 w-4 text-blue-500"}),items:l.map(e=>e.name)}),m>0&&e(ea,{title:s("upload.skippedAlreadyExisted"),count:m,icon:e(J,{className:"h-4 w-4 text-amber-500"}),items:c.map(e=>e.name)}),p>0&&e(ea,{title:s("upload.failedToUpload"),count:p,icon:e(H,{className:"h-4 w-4 text-red-500"}),items:d.map(e=>e.name)})]})]})}const ra="#text",na="#comment",aa="#cdata",ia="DECLARATION_TAG",sa={tagColor:"#d43900",textColor:"#333",attributeKeyColor:"#2a7ab0",attributeValueColor:"#008000",separatorColor:"#333",commentColor:"#aaa",cdataColor:"#1d781d",fontFamily:"monospace"},oa={attributeKeyColor:"#FFD700",attributeValueColor:"#FF4500",tagColor:"#87CEFA",textColor:"#00FF00",separatorColor:"#FFD700",commentColor:"#BEBEBE",cdataColor:"#33CC66",fontFamily:"monospace"},la=K({theme:sa,collapsible:!1,indentSize:2}),ca=()=>G(la),da=new $e({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",allowBooleanAttributes:!0,commentPropName:na,cdataPropName:aa,parseTagValue:!1});function ua(r){const{indentation:n,children:a,isInline:i}=r,{theme:s}=ca();return t("div",{style:{color:s.cdataColor},children:[e("span",{children:`${n}<![CDATA[`}),a,e("span",{children:`${i?"":n}]]>`})]})}function ha(t){const{collapsible:r,theme:n}=ca(),{collapsed:a}=t;return r?e("span",{style:{position:"relative"},children:e("span",{style:{position:"absolute",right:"0",border:0,padding:0,background:"none"},children:e(ma,{fill:n.separatorColor,style:{transform:`rotate(${a?0:90}deg)`,transition:"transform 0.2s"}})})}):null}function ma({...t}){return e("svg",{width:"16px",height:"16px",viewBox:"0 0 24 24","aria-hidden":"true",...t,children:e("path",{d:"M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z"})})}function pa(e){const{collapsible:t,initialCollapsedDepth:r}=ca(),[n,a]=Z(()=>!(Pe(r)||!t)&&e>=r);return Q(()=>{a(!(Pe(r)||!t)&&e>=r)},[r,e,t]),{collapsed:n,buttonProps:t?{onClick:()=>a(e=>!e),role:"button",style:{cursor:"pointer"}}:{}}}function fa(r){const{indentation:n,children:a,isInline:i,level:s}=r,{theme:o}=ca(),{collapsed:l,buttonProps:c}=pa(s);return t("div",{style:{color:o.commentColor},children:[t("span",{...c,children:[e("span",{children:n}),e(ha,{collapsed:l}),e("span",{children:"\x3c!-- "})]}),!l&&a,l&&"...",e("span",{children:`${i||l?" ":n}--\x3e`})]})}function ga(r){const{attributes:n}=r,{theme:a}=ca();return n?e("span",{children:Object.entries(n).map(([r,n])=>t("span",{children:[e("span",{style:{color:a.attributeKeyColor},children:` ${r}`}),e("span",{style:{color:a.separatorColor},children:"="}),e("span",{style:{color:a.attributeValueColor},children:`"${n}"`})]},`attribute-${r}`))}):null}function ya(r){const{indentation:n,tagKey:a,attributes:i}=r,{theme:s}=ca();return t("div",{children:[e("span",{style:{color:s.separatorColor},children:`${n}<?`}),e("span",{style:{color:s.tagColor},children:`${a.slice(1)}`}),e(ga,{attributes:i}),e("span",{style:{color:s.separatorColor},children:"?>"})]})}function va(e){return"string"==typeof e&&e.includes("\n")}function ba(e){const t=e[":@"],r=Re(e,":@"),[[n,a]]=Object.entries(r),i=function(e){switch(e){case ra:case aa:case na:return e;default:return e.startsWith("?")?ia:"TAG"}}(n);return{attributes:t,tagKey:n,subElements:a,type:i}}function xa(e){return!!e&&Object.keys(e).length>0}function wa(n){const{indentation:a,tagKey:i,attributes:s,children:o,isInline:l,hasChildren:c,level:d}=n,{collapsed:u,buttonProps:h}=pa(d),{theme:m}=ca();return t("div",{children:[t("span",{...h,children:[e("span",{children:a}),e(ha,{collapsed:u}),e("span",{style:{color:m.separatorColor},children:"<"}),e("span",{style:{color:m.tagColor},children:`${i}`}),!u&&e(ga,{attributes:s}),u&&xa(s)&&" ...",e("span",{style:{color:m.separatorColor},children:c?">":" />"})]}),c&&t(r,{children:[!u&&o,u&&"...",e("span",{style:{color:m.separatorColor},children:`${l||u?"":a}</`}),e("span",{style:{color:m.tagColor},children:`${i}`}),e("span",{style:{color:m.separatorColor},children:">"})]})]})}function Na(t){const{hasSiblings:r,text:n,indentation:a,isText:i}=t,{theme:s}=ca(),o=i?{color:s.textColor}:void 0;return va(n)||r?e("div",{style:o,children:n.split("\n").filter(e=>!!e.trim()).map((t,r)=>e("div",{children:`${a}${t.trim()}`},`${r}`))}):e("span",{style:o,children:n})}function ka(t){const{elements:n,level:a=0,isText:i=!0}=t,{indentSize:s}=ca();return Array.isArray(n)&&0!==n.length?e(r,{children:n.map((t,r)=>{const{tagKey:o,attributes:l,subElements:c,type:d}=ba(t),u=n.length>1,h=function(e,t){return new Array(t*e+1).join(" ")}(s,a),m=`${a}-${r}`,p=function(e){return"string"!=typeof e&&1===e.length&&ra in e[0]&&!va(e[0][ra])}(c);switch(d){case ra:return e(Na,{text:c,indentation:h,hasSiblings:u,isText:i},m);case na:return e(fa,{isInline:p,indentation:h,level:a,children:e(ka,{elements:c,level:a+1,isText:!1})},m);case aa:return e(ua,{indentation:h,isInline:p,children:e(ka,{elements:c,level:a+1,isText:!1})},m);case ia:return e(ya,{indentation:h,tagKey:o,attributes:l},m);default:return e(wa,{indentation:h,tagKey:o,attributes:l,isInline:p,hasChildren:c.length>0,level:a,children:e(ka,{elements:c,level:a+1})},m)}})}):null}function Ca(){return e("div",{children:"Invalid XML!"})}function Sa(t){const{theme:r,xml:n,collapsible:a=!1,indentSize:i=2,invalidXml:s,initalCollapsedDepth:o,initialCollapsedDepth:l}=t,[c,d]=Z(()=>document.documentElement.classList.contains("dark"));Q(()=>{const e=document.documentElement,t=new MutationObserver(()=>{d(e.classList.contains("dark"))});return t.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const u=Y(()=>({...c?oa:sa,...r}),[c,r]),{json:h,valid:m}=function(e){return Y(()=>{try{const t=Ie.validate(e);if(!0!==t)throw new Error(t.err.msg||"Invalid XML!");const r=da.parse(e);if("string"==typeof e&&e.trim().length>0&&0===r.length)throw new Error("Invalid XML!");return{json:r,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}},[e])}(n),p=Y(()=>({theme:u,collapsible:a,indentSize:i,initialCollapsedDepth:l??o}),[u,a,i,o,l]);return m?e(la.Provider,{value:p,children:e("div",{className:"rxv-container",style:{whiteSpace:"pre-wrap",fontFamily:u.fontFamily,overflowWrap:"break-word"},children:e(ka,{elements:h})})}):s||e(Ca,{})}export{tt as ArrayPropertySchema,cr as ArtifactContentRenderer,wr as ChartCodeBlockHandler,tr as CodeBlockErrorBoundary,Xt as CodeBlockHandlerProvider,er as CodeBlockPlaceholder,hr as CodeBlockRendererProvider,Qn as DropZone,Cr as ExpandCodeBlockHandler,Fe as FieldSetContextProvider,qe as Form,Ee as FormContext,ze as FormContextProvider,Ye as FormError,Xe as FormHelper,Ze as FormLabel,Ue as GeneratedForm,Me as Input,ht as JSONCode,Ct as JSONDisplay,$t as JSONEditor,Pt as JSONSwitcher,Ft as JSONTable,gt as JSONView,dt as ManageObjectEntry,ct as ManagedListProperty,st as ManagedObject,it as ManagedObjectBase,ot as ManagedObjectProperty,lt as ManagedProperty,ut as ManagedScalarEntry,En as ManagedSchema,Pr as MarkdownFigure,Lr as MarkdownImage,Tr as MarkdownLink,vn as MarkdownRenderer,Nr as MermaidCodeBlockHandler,gr as MermaidDiagram,Ot as MonacoEditor,at as Node,bn as Progress,xn as PropertiesView,An as PropertyEditor,jn as PropertyNameEditor,et as PropertySchema,Pn as PropertyViewer,He as ScalarField,Qe as Schema,Hn as SchemaEditor,Dn as SchemaNode,wn as SvgIcon,ea as UploadResultCategory,ta as UploadSummary,jt as VEditorApi,Sa as XMLViewer,rt as computeTitleFromName,Ar as createDefaultCodeBlockHandlers,Nn as createSvgIcon,kn as getEditableSchemaProperty,It as getJSONEditorValue,Sr as isExpandLanguage,vr as isIncompleteJson,$r as mapSchemeToRoute,Or as parseUrlScheme,ft as renderJsonLine,yr as useArtifactContent,pr as useCodeBlockComponent,Yt as useCodeBlockContext,mr as useCodeBlockRendererRegistry,Te as useFieldSet,Ve as useForm,Ir as useResolvedUrl,Vn as useSchema,Zn as validatePropertyName};
2
- //# sourceMappingURL=vertesia-ui-widgets.js.map
1
+ import{Fragment as e,jsx as t,jsxs as n}from"react/jsx-runtime";import{Button as r,DotBadge as i,FormItem as a,Modal as o,ModalBody as s,ModalFooter as c,ModalTitle as l,SelectBox as u,Styles as d,Table as f,VTooltip as p,errorMessage as m,useClickOutside as h,useFlag as g,useTheme as _,useToast as v}from"@vertesia/ui/core";import y,{clsx as b}from"clsx";import{AlertCircleIcon as x,AlignLeft as S,BarChart3 as C,Check as ee,CheckCircleIcon as w,ChevronDown as te,ChevronRight as T,Code as E,Copy as ne,Download as re,FileText as ie,GitBranch as ae,Image as oe,Info as se,Link as ce,Loader2 as le,Maximize2 as ue,MessageSquare as D,Minimize2 as de,Plus as fe,SquarePen as O,Table as pe,Trash2 as me,UploadIcon as he,X as ge,XCircleIcon as _e}from"lucide-react";import k,{createContext as A,memo as j,useCallback as M,useContext as N,useEffect as P,useId as ve,useMemo as F,useRef as I,useState as L}from"react";import ye from"ajv";import be from"ajv-formats";import{useUITranslation as R}from"@vertesia/ui/i18n";import{Editor as xe}from"@monaco-editor/react";import Se from"debounce";import{FusionFragmentHandler as Ce,FusionFragmentProvider as we}from"@vertesia/fusion-ux";import Te from"dompurify";import*as z from"@radix-ui/react-dialog";import{useUserSession as Ee}from"@vertesia/ui/session";import De from"papaparse";import{VegaEmbed as Oe}from"react-vega";import{twMerge as ke}from"tailwind-merge";import Ae from"mermaid";import je,{defaultUrlTransform as Me}from"react-markdown";import Ne from"rehype-katex";import{defListHastHandlers as Pe,remarkDefinitionList as Fe}from"remark-definition-list";import Ie from"remark-directive";import Le from"remark-gfm";import Re from"remark-github-blockquote-alert";import ze from"remark-math";import Be from"remark-supersub";import{SKIP as Ve,visit as He}from"unist-util-visit";import{XMLParser as Ue}from"fast-xml-parser";import{SyntaxValidator as We}from"fast-xml-validator";import{isNil as Ge,omit as Ke}from"lodash-es";const qe=A(void 0),Je=qe.Provider;function Ye(){let e=N(qe);if(!e)throw Error(`useFieldSet must be used within a Form or FieldSet element`);return e}var Xe=class{object;components;disabled;constructor(e,t={},n=!1){this.object=e,this.components=t,this.disabled=n}};const Ze=A(void 0);function B(){let e=N(Ze);if(!e)throw Error(`useForm must be used within a Form element`);return e}const Qe=Ze.Provider,$e=k.forwardRef(({object:e,type:n=`text`,onChange:r,...i},a)=>{let[o,s]=L(e.value==null?``:String(e.value)),[c,l]=L(e.schema.isBoolean&&e.value===!0);i.className?i.className=y(d.INPUT,i.className):i.className=d.INPUT;let u=t=>{i.disabled||(s(t.target.value),e.schema.isBoolean?(e.value=t.target.checked,l(e.value)):e.value=t.target.value,r?.(t))};return n===`textarea`?t(`textarea`,{ref:a,...i,value:o,onChange:u}):n===`checkbox`?t(`input`,{ref:a,...i,type:`checkbox`,checked:c,onChange:u,className:`form-check-input`}):t(`input`,{ref:a,...i,type:n,value:o,onChange:u})});function et({object:e,components:n,onSubmit:r,children:i,onChange:a,disabled:o}){return e.observer=a,t(Qe,{value:new Xe(e,n||{},o??!1),children:t(`form`,{className:`w-full`,onSubmit:t=>{t.stopPropagation(),t.preventDefault(),r?.(e.value)},children:i})})}function tt(){return t(`div`,{className:`flex flex-col gap-4 w-full`,children:B().object.properties.map(rt)})}function nt({children:e,...r}){return n(et,{...r,children:[t(tt,{}),e]})}function rt(e){return e.isList?t(st,{object:e},e.name):e.isObject?t(ot,{object:e},e.name):t(at,{object:e},e.name)}function it(e,n){return e.isList?t(st,{object:e}):e.isObject?t(ot,{object:e}):t(at,{object:e,editor:n})}function at({object:e,editor:n,inline:r=!1}){n||=e.schema.editor;let{components:i,disabled:o}=B(),s=n&&i[n]||$e,c=e.getInputType();c===`checkbox`&&(r=!0);let l=t=>{o||(e.schema.isBoolean?e.value=t.target instanceof HTMLInputElement?t.target.checked:!1:e.schema.isNumber?e.value=parseFloat(t.target.value):e.value=t.target.value)};return e.isListItem?t(s,{object:e,type:c,onChange:l,disabled:o}):t(a,{label:e.title,required:e.schema.isRequired,description:e.schema.description,className:y(`flex`,r?`flex-row items-center`:`flex-col`),children:t(s,{object:e,type:c,onChange:l,disabled:o})})}function ot({object:e}){return n(`div`,{className:`flex flex-col gap-4 my-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 dark:border-s-slate-600`,children:[!e.isListItem&&t(`div`,{className:`text-gray-900 dark:text-gray-200 font-semibold`,children:e.title}),e.properties.map(rt)]})}function st({object:e}){let{disabled:i}=B(),a=I((e.value??[]).length),[o,s]=L(()=>(e.value??[]).map((e,t)=>t)),c=()=>{i||(e.add(),s(e=>[...e,a.current++]))},l=t=>{i||(e.remove(t),s(e=>e.filter((e,n)=>n!==t)))};return n(`div`,{className:`flex flex-col gap-4 my-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 darK:border-s-slate-600`,children:[!e.isListItem&&t(`div`,{className:`text-gray-900 dark:text-gray-200 font-semibold`,children:e.title}),e.items.map((n,r)=>{let a=o[r];return t(ct,{object:n,list:e,onDelete:()=>l(r),disabled:i},a)}),t(`div`,{children:n(r,{variant:`outline`,onClick:c,disabled:i,children:[t(fe,{className:`size-6`}),` Add`]})})]})}function ct({list:e,object:i,onDelete:a,disabled:o}){return n(`div`,{className:`flex gap-2 w-full`,children:[t(`div`,{className:`flex-1`,children:it(i,typeof e.schema.arraySchema.editor==`string`?e.schema.arraySchema.editor:void 0)}),t(r,{variant:`ghost`,onClick:a,disabled:o,alt:`Delete`,children:t(me,{className:`size-4 text-destructive`})})]})}function lt({label:e,required:n,children:r}){return t(a,{label:e,required:n,children:r})}function ut({children:e}){return t(`p`,{className:`mt-2 text-sm text-gray-500`,children:e})}function dt({children:e}){return t(`p`,{className:`mt-2 text-sm text-red-600`,children:e})}function ft(e){return e===`object`?{type:`object`,properties:{}}:e===`array`?{type:`array`,items:{}}:{type:e}}var V=class{schema;properties={};_validator;constructor(e){this.schema=e||{type:`object`,properties:{}},this.load()}get validator(){if(!this._validator){let e=new ye({allErrors:!0,strict:!1});be(e),this._validator=e.compile(this.schema)}return this._validator}load(){if(this.schema.properties){let e=this.schema.properties;Object.keys(e).forEach(t=>{this.loadProperty(t,e[t])})}}hasProperties(){return Object.keys(this.properties).length>0}get title(){let e=this.schema.title;if(typeof e==`string`)return e;let t=this.schema.name;return typeof t==`string`?t:void 0}get description(){return this.schema.description}loadProperty(e,t){let n;return n=t.type===`array`?new ht(this,e,t):new pt(this,e,t),this.properties[e]=n,n}get type(){return this.schema.type}validate(e){return this.validator(e)?null:this.validator.errors||[]}addProperty(e,t,n=!1){this.schema.type!==`object`&&(this.schema.type=`object`),this.schema.properties||(this.schema.properties={});let r=typeof t==`string`?ft(t):t,i=this.loadProperty(e,r);return this.schema.properties[i.name]=i.schema,n&&(i.isRequired=!0),i}removeProperty(e){this.schema.properties&&(delete this.schema.properties[e],Array.isArray(this.schema.required)&&(this.schema.required=this.schema.required.filter(t=>t!==e))),delete this.properties[e]}getProperty(e){return this.properties[e]}get editor(){return typeof this.schema.editor==`string`?this.schema.editor:void 0}},pt=class extends V{parent;name;constructor(e,t,n){if(super(n),this.parent=e,this.name=t,n.type===`array`)throw Error(`Array property must be instantiated using ArrayPropertySchema`);n.type===`object`&&!n.properties&&(n.properties={})}get isMulti(){return!1}get isReadOnly(){return!!this.schema.readOnly}set isReadOnly(e){this.schema.readOnly=e}get defaultValue(){return this.schema.default}set defaultValue(e){this.schema.default=e}get enum(){return this.schema.enum}set enum(e){this.schema.enum=e}get isRequired(){let e=this.parent.schema.required;return e?e.includes(this.name):!1}set isRequired(e){let t=Array.isArray(this.parent.schema.required)?this.parent.schema.required:[];t=e?t.concat(this.name):t.filter(e=>e!==this.name),this.parent.schema.required=t}get type(){return this.schema.type}set type(e){this.schema.type!==e&&(this.schema.type=e,e!==`object`&&(this.properties={},this.schema.properties=void 0))}remove(){this.parent.removeProperty(this.name)}get isBoolean(){return this.type===`boolean`}get isString(){return this.type===`string`}get isNumber(){return this.type===`number`||this.type===`integer`}get isObject(){return this.type===`object`}};function mt(e){if(e.type!==`array`)throw Error(`Expecting an array schema`);if(!e.items)e.items={};else if(Array.isArray(e.items))throw Error(`Tuple arrays are not supported`);return e.items}var ht=class extends pt{arraySchema;constructor(e,t,n){super(e,t,mt(n)),this.arraySchema=n}get isMulti(){return!0}};function gt(e){return e=e.replace(/_/g,` `).replace(/([a-z0-9])&([A-Z])/g,`$1 $2`),e[0].toUpperCase()+e.slice(1)}function _t(e,t){if(t.editor)return t.editor;if(t.schema.format)return t.schema.format;switch(t.type){case`number`:case`integer`:return`number`;case`boolean`:return`checkbox`;case`string`:return`text`;default:return`text`}}var H=class{parent;schema;name;observer;constructor(e,t,n){this.parent=e,this.schema=t,this.name=n}get isRoot(){return!this.parent}get root(){return this.parent?this.parent.root:this}get path(){return this.parent?this.parent.path.concat(this.name):[]}get isScalar(){return!1}get isListItem(){return!1}get isObject(){return!1}get isList(){return!1}get title(){return this.schema.title||gt(this.name)}onChange(e){this.observer&&this.observer(this)===!1||this.parent?.onChange(e)}},U=class extends H{get isObject(){return!0}getProperty(e){let t=this.schema.properties[e];return t.isMulti?new xt(this,t,this.getOrInitArrayProperty(e)):t.isObject?new yt(this,t,t.name,this.getOrInitObjectProperty(e)):new bt(this,t)}getOrInitObjectProperty(e){let t=this.value[e];return t||(this.value[e]=t={}),t}getOrInitArrayProperty(e){let t=this.value[e];return t||(this.value[e]=t=[]),t}setPropertyValue(e,t){return this.value[e]===t?!1:(this.value[e]=t,!0)}getPropertyValue(e){return this.value[e]}get properties(){let e=[];for(let t of Object.values(this.schema.properties))t.isMulti?e.push(new xt(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new yt(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new bt(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}},vt=class extends U{value;constructor(e,t={}){super(null,e instanceof V?e:new V(e),`#root`),this.value=t}},yt=class extends U{value;constructor(e,t,n,r){super(e,t,n),this.value=r}},bt=class extends H{constructor(e,t){super(e,t,t.name),e.value[this.name]===void 0&&t.defaultValue!==void 0&&(e.value[this.name]=t.defaultValue)}get isScalar(){return!0}set value(e){this.parent.setPropertyValue(this.name,e)&&this.onChange(this)}get value(){return this.parent.getPropertyValue(this.name)}getInputType(){return _t(this.name,this.schema)}},xt=class extends H{value;items=[];constructor(e,t,n){super(e,t,t.name),this.value=n;for(let e of this.value)this.add()}get isList(){return!0}newItem(e){return this.schema.isObject?new St(this,e):new Ct(this,e)}add(){let e=this.newItem(this.items.length);return this.items.push(e),e}remove(e){let t=this.value;if(e>=0&&e<this.items.length){this.items.splice(e,1);for(let e=0,t=this.items.length;e<t;e++){let t=this.items[e];t.index=e,t.name=String(e)}}Array.isArray(t)&&e>=0&&e<t.length&&(t.splice(e,1),this.onChange(this))}[Symbol.iterator](){return this.items[Symbol.iterator]()}item(e){if(e<0||e>=this.value.length)return;let t=this.value[e];return this.schema.isObject?new yt(this,this.schema,String(e),t):new Ct(this,e)}trim(){for(;this.items[this.items.length-1]===void 0;)this.items.pop()}},St=class extends U{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,e.value[t]===void 0&&(e.value[t]={}),this.key=`${this.name}@${Date.now()}`}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}},Ct=class extends H{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,e.value[t]===void 0&&e.schema.defaultValue!==void 0&&(e.value[t]=e.schema.defaultValue),this.key=`${this.name}@${Date.now()}`}get isScalar(){return!0}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}getInputType(){return _t(this.name,this.schema)}};function wt({data:e,className:r}){let i=F(()=>{try{return JSON.stringify(e,null,2)}catch(e){return console.error(`Failed to stringify JSON:`,e),`{}`}},[e]),a=F(()=>i.split(`
2
+ `),[i]);return t(`pre`,{className:`h-full overflow-auto rounded-md border bg-background p-3 font-mono text-xs leading-5 text-foreground ${r||``}`,children:t(`code`,{children:a.map((e,t)=>n(`span`,{children:[Dt(e),t<a.length-1?`
3
+ `:null]},`line-${t}`))})})}const Tt=/("(?:\\.|[^"\\])*"?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,Et=/^\s*:/;function Dt(e){Tt.lastIndex=0;let n=[],r=0,i=Tt.exec(e);for(;i!==null;){i.index>r&&n.push(e.slice(r,i.index));let[a,o,s,c]=i,l=o!==void 0&&Et.test(e.slice(i.index+a.length))?`text-info`:o?`text-success`:s?`text-primary`:c?`text-attention`:void 0;n.push(t(`span`,{className:l,children:a},`${i.index}-${a}`)),r=i.index+a.length,i=Tt.exec(e)}return r<e.length&&n.push(e.slice(r)),n.length?n:e}function Ot({value:e}){return Array.isArray(e)?t(`div`,{className:`flex flex-col gap-4 px-2 h-full overflow-auto`,children:t(jt,{value:e})}):typeof e!=`object`||!e?t(`div`,{className:`flex flex-col gap-4 px-2 h-full overflow-auto`,children:t(At,{name:`value`,value:e})}):t(`div`,{className:`flex flex-col gap-4 px-2 h-full overflow-auto`,children:Object.entries(e).map(([e,n])=>t(At,{name:e,value:n},e))})}function W({name:e}){return t(`div`,{className:`text-md font-semibold`,children:gt(e)})}function kt({children:e,className:n}){return t(`div`,{className:y(`flex flex-col gap-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 dark:border-s-slate-600`,n),children:e})}function At({name:e,value:r}){let i=Nt(r);switch(i.type){case G.Inline:return n(`div`,{className:`w-full flex gap-2`,children:[t(W,{name:`${e}:`}),t(`p`,{children:i.value})]});case G.Paragraph:return n(`div`,{children:[t(W,{name:e}),t(`p`,{children:i.value})]});case G.Prose:return n(`div`,{className:`prose dark:prose-invert`,children:[t(W,{name:e}),t(`div`,{className:`vprose dark:prose-invert`,children:i.value})]});case G.Array:return t(jt,{name:e,value:r});case G.Object:return n(`div`,{children:[t(W,{name:e}),t(kt,{className:`mt-2`,children:Object.entries(r).map(([e,n])=>t(At,{name:e,value:n},e))})]})}}function jt({name:e,value:r}){let a=r.join(` `).length,o=a/r.length,s=typeof r[0]==`string`&&(a<80||a<400&&o<32),c=r.length>9,l=r.map((e,t)=>({item:e,index:t,key:`${t}-${JSON.stringify(e)}`}));return s?n(`div`,{className:`flex gap-2 flex-wrap`,children:[e&&t(W,{name:`${e}:`}),l.map(({item:e,key:n})=>t(i,{children:String(e)},n))]}):n(`div`,{children:[e&&t(W,{name:e}),t(`div`,{className:`flex flex-col gap-2`,children:l.map(({item:e,index:n,key:r})=>t(Mt,{index:n,value:e,useBullet:c},r))})]})}function Mt({index:e,value:r,useBullet:i}){let a=i?t(`span`,{className:`text-xl`,children:`•`}):n(`span`,{children:[e+1,`.`]}),o=Nt(r),s;switch(o.type){case G.Object:s=t(kt,{children:Object.entries(r).map(([e,n])=>t(At,{name:e,value:n},e))});break;case G.Array:s=t(jt,{value:r});break;case G.Prose:s=t(`div`,{className:`prose dark:prose-invert`,children:o.value});break;default:s=t(`div`,{children:o.value});break}return n(`div`,{className:`flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pe-2 ps-4`,children:[t(`div`,{className:`font-semibold text-gray-600 dark:text-gray-400`,children:a}),t(`div`,{children:s})]})}var G;(function(e){e[e.Inline=0]=`Inline`,e[e.Paragraph=1]=`Paragraph`,e[e.Prose=2]=`Prose`,e[e.Array=3]=`Array`,e[e.Object=4]=`Object`})(G||={});function Nt(e){if(e==null)return{value:`-`,type:G.Inline};if(Array.isArray(e))return{value:e,type:G.Array};if(typeof e==`string`){let t=e.length,n,r=e;return t<80?n=G.Inline:t>400?n=G.Prose:(n=G.Paragraph,r=e.replace(/(?:\n\n)+/g,`
4
+
5
+ `)),{type:n,value:r}}else if(typeof e==`number`||typeof e==`boolean`)return{value:String(e),type:G.Inline};else return{value:e,type:G.Object}}function Pt({value:e,viewCode:n=!1}){let{t:r}=R();return e?t(`div`,{className:`relative w-full h-full flex flex-col`,children:n||!Ft(e)?t(wt,{data:e}):t(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:t(Ot,{value:e})})}):t(`pre`,{className:`whitespace-pre-wrap`,children:r(`misc.noData`)})}function Ft(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?!0:Array.isArray(e)?e.every(Ft):typeof e==`object`?Object.values(e).every(Ft):!1}const It=new Set;function Lt(e){It.has(`markdown`)||(It.add(`markdown`),e.languages.registerFoldingRangeProvider(`markdown`,{provideFoldingRanges(e){let t=[],n=e.getLinesContent(),r=/^(#{1,6})\s/,i=[];for(let e=0;e<n.length;e++){let a=e+1,o=r.exec(n[e]);if(o){let e=o[1].length;for(;i.length>0&&i[i.length-1].level>=e;){let e=i.pop();e&&a-1>e.line&&t.push({start:e.line,end:a-1})}i.push({level:e,line:a})}}let a=n.length;for(;i.length>0;){let e=i.pop();e&&a>e.line&&t.push({start:e.line,end:a})}return t}}));for(let t of[`javascript`,`typescript`])It.has(t)||(It.add(t),e.languages.registerFoldingRangeProvider(t,{provideFoldingRanges(e){let t=e.getLinesContent(),n=/^(#{1,6})\s/,r=[],i=[],a=[],o=[],s=!1,c=!1,l=``;for(let e=0;e<t.length;e++){let u=e+1,d=t[e],f=s;for(let e=0;e<d.length;e++){let t=d[e];if(t===`\\`){e++;continue}if(c){t===l&&(c=!1);continue}if(s){t==="`"&&(s=!1);continue}if(t==="`"){s=!0;continue}if(t===`"`||t===`'`){c=!0,l=t;continue}if(t===`{`&&a.push(u),t===`}`&&a.length>0){let t=a.pop(),n=d.slice(e+1).trimStart().length>0?u-1:u;t!==void 0&&n>t&&r.push({start:t,end:n})}}if(f){let e=n.exec(d);if(e){let t=e[1].length;for(;o.length>0&&o[o.length-1].level>=t;){let e=o.pop();e&&u-1>e.line&&i.push({start:e.line,end:u-1})}o.push({level:t,line:u})}if(!s)for(;o.length>0;){let e=o.pop();e&&u>e.line&&i.push({start:e.line,end:u})}}}return[...r,...i]}}))}var Rt=class{VgetValue;VsetValue;constructor(e,t){this.VgetValue=e,this.VsetValue=t}getValue(){return this.VgetValue()}setValue(e){this.VsetValue(e||``)}};function zt({onChange:e,value:n,className:r,editorRef:i,language:a=`javascript`,path:o,debounceTimeout:s=0,options:c={},beforeMount:l,onMount:u,defaultValue:d,useCustomFolding:f=!1}){let[p,m]=L(n||d||``),h=I(null),g=I(null),{theme:v}=_(),b=v===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:v,x=n||d||``,S=I(()=>p),C=I(e=>{m(e),h.current&&h.current.setValue(e)});P(()=>{S.current=()=>p},[p]),P(()=>(i&&(i.current=new Rt(()=>S.current(),e=>C.current(e))),()=>{i&&(i.current=void 0)}),[i]);let ee=F(()=>{if(e)return s>0?Se(t=>e(t),s):e},[e,s]),w=M(async(e,t)=>{let n=e.getModel();if(n)for(let r of n.getValue().matchAll(/```[\s\S]*?```/g)){let i=n.getPositionAt(r.index).lineNumber,a=n.getPositionAt(r.index+r[0].length).lineNumber;e.setSelection(new t.Selection(i,1,a,1)),await e.getAction(`editor.createFoldingRangeFromSelection`)?.run()}},[]),te=M(e=>{let t=e||``;m(t),ee&&ee({docChanged:!0,state:{doc:{toString:()=>t,length:t.length}}})},[ee]),T=M((e,t)=>{h.current=e,g.current=t,f&&Lt(t),C.current=t=>{m(t),e.setValue(t)},t.editor.defineTheme(`errorLineTheme`,{base:b===`dark`?`vs-dark`:`vs`,inherit:!0,rules:[],colors:{"editorError.background":`#ffebee`,"editorError.border":`#f44336`}}),t.editor.setTheme(`errorLineTheme`),f&&setTimeout(()=>w(e,t),300),u?.(e,t)},[u,b,f,w]);P(()=>{m(e=>x===e?e:(h.current&&h.current.setValue(x),x))},[x]),P(()=>{if(!x||!f||!h.current||!g.current)return;let e=h.current,t=g.current,n=setTimeout(()=>w(e,t),300);return()=>clearTimeout(n)},[x,f,w]);let E={fontSize:14,fontFamily:`monospace`,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,lineNumbers:`on`,folding:!0,lineDecorationsWidth:10,lineNumbersMinChars:3,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2,insertSpaces:!0,fixedOverflowWidgets:!0,glyphMargin:!0,renderValidationDecorations:`on`,renderLineHighlight:`line`,hover:{enabled:!0,delay:100},quickSuggestions:{other:!0,comments:!0,strings:!0},...c};return t(`div`,{className:y(r,`w-full h-full!`),children:t(xe,{className:`h-full w-full`,height:`100%`,theme:b===`dark`?`vs-dark`:`light`,language:a,path:o,value:p,onChange:te,onMount:T,beforeMount:l,options:E,defaultValue:d||``})})}function Bt({value:e,onChange:r,onValidChange:i,readonly:a=!1,height:o=`200px`,placeholder:s,className:c}){let{theme:l}=_(),u=I(void 0),[d,f]=L(null),p=F(()=>{if(e==null)return s??`{}`;try{return JSON.stringify(e,null,2)}catch{return`{}`}},[e,s]),m=M(()=>{if(!u.current||a)return;let e=u.current.getValue();try{let t=JSON.parse(e);f(null),i?.(t)}catch{f(`Invalid JSON`)}},[a,i]);return n(`div`,{className:c,children:[t(`div`,{className:`border rounded overflow-hidden`,style:{height:o},children:t(zt,{defaultValue:p,editorRef:u,language:`json`,theme:l===`dark`?`vs-dark`:`vs`,onChange:m,options:a?{readOnly:!0,domReadOnly:!0}:void 0})}),d&&t(`p`,{className:`text-xs text-destructive mt-1`,children:d})]})}function Vt(e){if(!e.current)return null;try{return JSON.parse(e.current.getValue())}catch{return null}}function Ht({title:e,viewCode:i,setViewCode:a}){return n(`div`,{className:`flex items-center gap-1 bg-muted mb-2 p-1 rounded`,children:[t(r,{variant:i?`ghost`:`primary`,size:`sm`,alt:`Preview properties`,onClick:()=>a(!1),children:e}),t(r,{variant:i?`primary`:`ghost`,size:`sm`,alt:`View in JSON format`,onClick:()=>a(!0),children:`JSON`})]})}function Ut(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim().replace(/^./,e=>e.toUpperCase())}function Wt(r){return r==null?`Failed to query`:typeof r==`string`?r:Array.isArray(r)?r.length===0?`None`:r.some(e=>e&&typeof e==`object`)?t(e,{children:r.map((e,r)=>n(`div`,{className:`flex gap-1`,children:[n(`span`,{className:`text-xs align-top pe-2 font-medium`,children:[r+1,`:`]}),t(`span`,{className:`text-xs`,children:Wt(e)})]},`item-${r}`))}):r.map(e=>String(e)).join(`, `):typeof r==`object`?t(e,{children:Object.entries(r).map(([e,r])=>n(`div`,{className:`flex gap-1`,children:[n(`span`,{className:`text-xs align-top pe-2 font-medium`,children:[Ut(e),`:`]}),t(`span`,{className:`text-xs`,children:Wt(r)})]},e))}):String(r)}function Gt({data:e,className:r}){let i=e?Object.entries(e):[];return t(`table`,{className:r||`mb-2 text-xs bg-muted rounded-sm w-full`,children:t(`tbody`,{children:i.map(([e,r])=>n(`tr`,{className:`align-top hover:bg-background border-y`,children:[t(`td`,{className:`align-top pe-4 p-2`,children:Ut(e)}),t(`td`,{className:`p-2`,children:Wt(r)})]},e))})})}function Kt(...e){return ke(b(e))}const qt=A(null);function Jt(){return N(qt)}function Yt(e){return e.startsWith(`agents/`)||e.startsWith(`documents/`)}function Xt(e,t,n=`inline`){return`artifact:${e}:${t}:${n}`}function Zt(e){return`file:${e}`}function Qt({error:e,chartTitle:r}){return t(`div`,{className:`flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4`,children:n(`div`,{className:`text-center`,children:[n(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:[`Cannot render `,r||`Vega-Lite`,` chart`]}),t(`p`,{className:`text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate`,children:e})]})})}function $t({isOpen:e,onClose:i,title:a,description:o,children:s}){let{t:c}=R();return t(z.Root,{open:e,onOpenChange:e=>!e&&i(),children:n(z.Portal,{children:[t(z.Overlay,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),n(z.Content,{className:`fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2`,onEscapeKeyDown:i,children:[t(z.Close,{asChild:!0,children:t(r,{variant:`unstyled`,onClick:i,className:`absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm`,"aria-label":c(`agent.closeFullscreen`),children:t(ge,{className:`w-5 h-5 text-gray-600 dark:text-gray-300`})})}),t(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150`,children:s}),t(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl`,children:n(`div`,{className:`flex flex-col`,children:[t(z.Title,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:a||c(`agent.dashboard`)}),o&&t(z.Description,{className:`text-sm text-gray-500 dark:text-gray-400 mt-0.5`,children:o})]})})]})]})})}function en(e,t){if(t===`chart`)return 280;let n=1;if(e.vconcat)n=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){let t=e.columns||2,r=Array.isArray(e.concat)?e.concat.length:1;n=Math.ceil(r/t)}else e.facet&&(n=2);return Math.max(500,n*280+40)}const tn={categorical:[`#6366f1`,`#8b5cf6`,`#ec4899`,`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#14b8a6`,`#06b6d4`,`#3b82f6`],blues:[`#dbeafe`,`#93c5fd`,`#3b82f6`,`#1d4ed8`,`#1e3a8a`],purples:[`#f3e8ff`,`#c4b5fd`,`#8b5cf6`,`#6d28d9`,`#4c1d95`],greens:[`#dcfce7`,`#86efac`,`#22c55e`,`#15803d`,`#14532d`],diverging:[`#ef4444`,`#fca5a5`,`#fef3c7`,`#86efac`,`#22c55e`]};function nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rn(e){return nn(e)}function an(e){let t=JSON.parse(JSON.stringify(e)),n=[`vconcat`,`hconcat`,`concat`];if(!n.some(e=>Array.isArray(t[e])))return t;let r=[];if(Array.isArray(t.params))for(let e of t.params)e&&typeof e==`object`&&e.name&&e.select&&r.push({name:e.name,param:e});if(r.length===0)return t;for(let{name:e,param:i}of r){let r=i.select?.fields||[],a=i.select?.bind===`legend`,o=null;for(let e of n)if(Array.isArray(t[e])){o=t[e];break}if(!o||o.length===0)continue;let s=0;for(let e=0;e<o.length;e++){let t=o[e];if(sn(t,r)||a&&cn(t,r)){s=e;break}}let c=o[s];c.params||=[],c.params.push(i),t.params=(t.params??[]).filter(t=>t.name!==e)}return Array.isArray(t.params)&&t.params.length===0&&delete t.params,t}function on(e,t){if(!t||Object.keys(t).length===0)return e;let n=JSON.parse(JSON.stringify(e)),r=e=>{for(let n of e)n.name&&n.name in t&&(n.value=t[n.name])};Array.isArray(n.params)&&r(n.params);let i=e=>{if(Array.isArray(e)){for(let t of e)if(Array.isArray(t.params)&&r(t.params),t.vconcat&&i(t.vconcat),t.hconcat&&i(t.hconcat),t.concat&&i(t.concat),Array.isArray(t.layer))for(let e of t.layer)Array.isArray(e.params)&&r(e.params)}};if(n.vconcat&&i(n.vconcat),n.hconcat&&i(n.hconcat),n.concat&&i(n.concat),Array.isArray(n.layer))for(let e of n.layer)e&&Array.isArray(e.params)&&r(e.params);return n}function sn(e,t){if(!e?.encoding)return!1;for(let n of t)for(let t of Object.values(e.encoding))if(t.field===n)return!0;if(Array.isArray(e.layer)){for(let n of e.layer)if(sn(n,t))return!0}return!1}function cn(e,t){if(!e)return!1;let n=e=>{if(!e)return!1;let n=e.color?.field;return!!n&&t.includes(n)};if(n(e.encoding))return!0;if(Array.isArray(e.layer)){for(let t of e.layer)if(n(t.encoding))return!0}return!1}function ln(e,t=[]){let n=[];if(!e||typeof e!=`object`)return n;if(e.data&&typeof e.data==`object`){let r=e.data.url;typeof r==`string`&&r.startsWith(`artifact:`)&&n.push({path:[...t,`data`],artifactPath:r.replace(/^artifact:/,``).trim()})}for(let r of[`layer`,`vconcat`,`hconcat`,`concat`,`spec`,`repeat`,`facet`])if(r in e){let i=e[r];Array.isArray(i)?i.forEach((e,i)=>{rn(e)&&n.push(...ln(e,[...t,r,String(i)]))}):rn(i)&&n.push(...ln(i,[...t,r]))}return n}function un(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of t){let t=e.split(`.`),i=n;for(let e=0;e<t.length-1;e++){let n=i[t[e]];if(!nn(n))break;i=n}let a=t[t.length-1],o=i[a];nn(o)&&(delete o.url,o.values=r)}return n}function dn(e){let t={background:`transparent`,view:{stroke:`transparent`},range:{category:tn.categorical,diverging:tn.diverging,heatmap:tn.purples,ramp:tn.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:`round`},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,gridColor:`#3f3f46`,domainColor:`#52525b`,tickColor:`#52525b`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#fafafa`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:`#71717a`,titleColor:`#3f3f46`,gridColor:`#e4e4e7`,domainColor:`#d4d4d8`,tickColor:`#d4d4d8`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#71717a`,titleColor:`#3f3f46`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#18181b`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}}const K=j(function({spec:i,artifactRunId:a}){let{t:o}=R(),{title:s,description:c,options:l}=i,u=i.spec,[d,f]=L(!1),[p,m]=L(!1),[h,g]=L(null),[_,v]=L(!1),y=I(null),b=I(null),x=I(null),{client:S}=Ee(),C=Jt(),w=I(S);w.current=S;let te=I(C);te.current=C;let[T,E]=L(null),[ie,ae]=L(!1),[oe,se]=L(null),ce=l?.mode||`chart`,D=ce===`dashboard`,fe=l?.enableFullscreen??D,O=l?.height||en(u,ce);P(()=>{let e=ln(u);if(e.length===0){E(u),ae(!1),se(null);return}a?console.info(`[VegaLiteChart] resolving artifacts with runId:`,a,e.map(e=>e.artifactPath)):console.warn(`[VegaLiteChart] artifact references found but artifactRunId is missing!`,{references:e.map(e=>e.artifactPath),artifactRunId:a});let t=!1;return ae(!0),se(null),(async()=>{let n=new Map,r=w.current,i=te.current;for(let o of e)try{let e=o.path.join(`.`),t;if(a&&!Yt(o.artifactPath)){let e=Xt(a,o.artifactPath,`inline`);t=i?await i.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(a,o.artifactPath,`inline`)).url):(await r.files.getArtifactDownloadUrl(a,o.artifactPath,`inline`)).url}else{let e=Zt(o.artifactPath);t=i?await i.getOrFetch(e,async()=>(await r.files.getDownloadUrl(o.artifactPath)).url):(await r.files.getDownloadUrl(o.artifactPath)).url}let s=await fetch(t);if(!s.ok)throw Error(`Failed to fetch artifact data: ${s.statusText}`);let c=o.artifactPath.toLowerCase().endsWith(`.csv`),l;if(c){let e=await s.text();l=De.parse(e,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{let e=await s.json();l=Array.isArray(e)?e:[e]}n.set(e,l)}catch(e){console.error(`Failed to resolve artifact: ${o.artifactPath}`,e),t||se(`Failed to load data from artifact: ${o.artifactPath}`);return}t||(E(un(u,n)),ae(!1))})(),()=>{t=!0}},[u,a]);let[pe,me]=L(!1),he=I(!1);P(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`);e!==he.current&&(he.current=e,me(e))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let[ge,_e]=L(0),k=I(0);P(()=>{if(!x.current)return;let e,t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{let e=t[0]?.contentRect.width;e&&e!==k.current&&(k.current=e,_e(e))},100)});t.observe(x.current);let n=x.current.clientWidth;return k.current=n,_e(n),()=>{clearTimeout(e),t.disconnect()}},[]);let A=F(()=>ln(u).length>0,[u]),j=F(()=>{if(A&&!T)return null;let e=T||u;return e?(l?.parameterValues&&(e=on(e,l.parameterValues)),an(e)):null},[T,u,A,l?.parameterValues]),N=M((e,t)=>{if(!e||typeof e!=`object`)return e;if(e.hconcat&&Array.isArray(e.hconcat)){let n=e.hconcat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,hconcat:e.hconcat.map(e=>N(e,i))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>N(e,t))};if(e.concat&&Array.isArray(e.concat)){let n=e.columns??e.concat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,concat:e.concat.map(e=>N(e,i))}}let n=e.width;return n===`container`||typeof n==`number`&&n>t?{...e,width:t}:e},[]),ve=M((e,t=!1)=>{if(!j)return null;let n=dn(pe),r=t?typeof window<`u`?Math.min(window.innerWidth-80,1400):1200:ge>0?ge-24:500,i=`vconcat`in j||`hconcat`in j||`concat`in j,a=i?{type:`pad`,contains:`padding`}:{type:`fit`,contains:`padding`},o=j;i&&r&&(o=N(j,r));let c=o.width,l=i?void 0:c===`container`?r:c??r,{width:u,...d}=o;return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,...!i&&l?{width:l}:{},height:t?void 0:e,autosize:a,...i?o:d,...s&&!j.title?{title:s}:{},config:{...n,...j.config}}},[j,s,pe,ge,N]),ye=M(async()=>{let e=_?b.current:y.current;if(!(!e||p))try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),m(!0),setTimeout(()=>m(!1),2e3))},`image/png`)}catch(e){console.error(`Failed to copy chart:`,e)}},[p,_]),be=M(async()=>{let e=_?b.current:y.current;if(!(!e||d)){f(!0);try{let t=await e.toImageURL(`png`,2),n=document.createElement(`a`);n.download=`${s||`chart`}.png`,n.href=t,n.click()}catch(e){console.error(`Failed to export chart:`,e)}finally{f(!1)}}},[s,d,_]),xe=M(e=>{y.current=e,g(null)},[]),Se=M(e=>{b.current=e},[]),Ce=M(e=>{console.error(`Vega-Lite rendering error:`,e),g(e instanceof Error?e.message:`Unknown error`)},[]),we=M(()=>{v(e=>!e)},[]);P(()=>{g(null)},[u]);let Te=({className:e})=>n(`div`,{className:Kt(`flex items-center gap-2`,e),children:[n(r,{variant:`unstyled`,onClick:ye,disabled:p,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1`,title:o(`agent.copyToClipboard`),children:[t(p?ee:ne,{className:`w-3 h-3`}),o(p?`agent.copied`:`agent.copy`)]}),n(r,{variant:`unstyled`,onClick:be,disabled:d,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1`,title:o(`agent.exportAsPng`),children:[t(re,{className:`w-3 h-3`}),o(d?`agent.exporting`:`agent.export`)]}),fe&&n(r,{variant:`unstyled`,onClick:we,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1`,title:o(_?`agent.exitFullscreen`:`agent.fullscreen`),children:[t(_?de:ue,{className:`w-3 h-3`}),o(_?`agent.exit`:`agent.fullscreen`)]})]});if(ie||A&&!T)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{className:`flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded`,style:{width:`100%`,height:O},children:n(`div`,{className:`flex items-center gap-2 text-gray-500 dark:text-gray-400`,children:[t(le,{className:`w-5 h-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading data from artifacts...`})]})})]})});if(oe)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:O},children:t(Qt,{error:oe,chartTitle:s})})]})});if(h)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:O},children:t(Qt,{error:h,chartTitle:s})})]})});let z=ve(O),ke=ve(0,!0);return z?(typeof window<`u`&&localStorage.getItem(`DEBUG_VEGA_RENDERS`)&&console.log(`VegaLite rendering with spec:`,{title:s,hasData:!!z.data?.values,dataLength:z.data?.values?.length}),n(e,{children:[t(`div`,{className:Kt(`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,D&&`border-2`),children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||(D?`Dashboard`:`Chart`)}),D&&t(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300`,children:`Interactive`})]}),t(Te,{})]}),c&&t(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c}),t(`div`,{ref:x,className:`bg-white dark:bg-gray-900 rounded overflow-hidden`,style:{width:`100%`,height:O,minWidth:0},children:t(Oe,{spec:z,onEmbed:e=>xe(e.view),onError:Ce,options:{renderer:l?.renderer||`canvas`,actions:!1}})})]})}),n($t,{isOpen:_,onClose:()=>v(!1),title:s||(D?`Dashboard`:`Chart`),description:c,children:[t(`div`,{className:`w-full h-full min-h-[calc(100vh-200px)]`,children:ke&&t(Oe,{spec:ke,onEmbed:e=>Se(e.view),onError:Ce,options:{renderer:l?.renderer||`canvas`,actions:!1}})}),t(`div`,{className:`absolute bottom-6 end-6`,children:t(Te,{className:`bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700`})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId),fn=k.createContext({});function pn({children:e,artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}){let o=F(()=>({artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}),[n,r,i,a]);return t(fn.Provider,{value:o,children:e})}function q(){return k.useContext(fn)}const mn={chart:{icon:C,label:`chart`,defaultHeight:200},mermaid:{icon:ae,label:`diagram`,defaultHeight:150},proposal:{icon:D,label:`options`,defaultHeight:100},code:{icon:E,label:`code`,defaultHeight:80},image:{icon:oe,label:`image`,defaultHeight:150},link:{icon:ce,label:`link`,defaultHeight:24},expand:{icon:re,label:`content`,defaultHeight:100},table:{icon:pe,label:`table`,defaultHeight:150},markdown:{icon:ie,label:`content`,defaultHeight:100},"fusion-fragment":{icon:E,label:`fragment`,defaultHeight:150}};function J({type:e,error:i,onRetry:a,message:o,height:s}){let c=mn[e],l=s??c.defaultHeight,u=e===`link`;if(i)return n(`div`,{className:`flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive ${u?`inline-flex px-2 py-1 text-sm`:`p-4`}`,style:u?void 0:{minHeight:l},children:[n(`span`,{className:`text-destructive`,children:[`Failed to load `,c.label]}),a&&t(r,{variant:`unstyled`,onClick:a,className:`ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive`,children:`Retry`})]});let d=c.icon;return u?n(`span`,{className:`inline-flex items-center gap-1 text-muted animate-pulse`,children:[t(d,{className:`h-3 w-3`}),t(`span`,{children:o||`Loading ${c.label}...`})]}):n(`div`,{className:`flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse`,style:{minHeight:l},children:[t(d,{className:`h-8 w-8 text-muted`}),t(`span`,{className:`text-sm text-muted`,children:o||`Loading ${c.label}...`}),t(`div`,{className:`flex gap-1`,children:[...[,,,]].map((e,n)=>t(`div`,{className:`h-2 w-2 rounded-full bg-muted animate-bounce`,style:{animationDelay:`${n*150}ms`}},`dot-${n}`))})]})}var Y=class extends k.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){let{type:e,fallbackCode:r}=this.props;return n(`div`,{className:`space-y-2`,children:[t(J,{type:e,error:this.state.error?.message||`Rendering failed`,onRetry:this.handleRetry}),r&&n(`details`,{className:`text-sm`,children:[t(`summary`,{className:`cursor-pointer text-muted hover:text-foreground`,children:`Show raw content`}),t(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs`,children:t(`code`,{children:r})})]})]})}return this.props.children}};function hn(e,t,n){let r=t.split(`.`).pop()?.toLowerCase();if(r===`svg`)return`mockup`;if([`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(r||``))return`image`;if(r===`md`)return`markdown`;if(r===`csv`)return`table`;if(n===`json`&&typeof e==`object`&&e){let t=e;if(typeof t.$schema==`string`&&t.$schema.includes(`vega`)||t.library===`vega-lite`&&`spec`in t)return`vega-lite`;if(`template`in t&&`data`in t)return`fusion-fragment`;if(Array.isArray(e)&&e.length>0&&typeof e[0]==`object`)return`table`}return`code`}function gn(e){if(typeof e!=`object`||!e)return null;let t=e;return t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`&&t.spec!==null?t:typeof t.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}function _n({content:e}){let{headers:r,rows:i}=F(()=>{if(!Array.isArray(e)||e.length===0)return{headers:[],rows:[]};let t=e[0];if(typeof t!=`object`||!t)return{headers:[],rows:[]};let n=Object.keys(t);return{headers:n,rows:e.map(e=>n.map(t=>{let n=e[t];return n==null?``:typeof n==`object`?JSON.stringify(n):String(n)}))}},[e]);return r.length===0?t(J,{type:`table`,error:`No table data found`}):n(`div`,{className:`overflow-x-auto`,children:[n(`table`,{className:`min-w-full text-sm border-collapse`,children:[t(`thead`,{children:t(`tr`,{className:`border-b`,children:r.map(e=>t(`th`,{className:`px-3 py-2 text-start font-medium text-muted`,children:e},e))})}),t(`tbody`,{children:i.slice(0,100).map((e,n)=>t(`tr`,{className:`border-b border-muted/20`,children:e.map((e,n)=>t(`td`,{className:`px-3 py-2`,children:e},`cell-${n}`))},`row-${n}`))})]}),i.length>100&&n(`div`,{className:`text-sm text-muted py-2`,children:[`Showing 100 of `,i.length,` rows`]})]})}function vn({content:e,path:n}){let r=n.split(`.`).pop()?.toLowerCase()||``,i=typeof e==`string`?e:JSON.stringify(e,null,2);return t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{className:`language-${r}`,children:i})})}function yn(e){return Te.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`use`],FORBID_TAGS:[`foreignObject`]})}function bn(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let n=t;if(!/viewBox/i.test(n)){let e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n);e&&t&&(n+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return n=n.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``).replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``),/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}function xn({content:e}){let n=F(()=>{let t=typeof e==`string`?e.trim():``;return t?bn(yn(t)):null},[e]);return n?t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}}):t(J,{type:`expand`,error:`Empty mockup`})}function Sn({content:e,path:n}){return t(`img`,{src:typeof e==`string`?e:``,alt:n.split(`/`).pop()||`Artifact image`,className:`max-w-full h-auto rounded`,loading:`lazy`})}function Cn({content:e,renderType:n,path:r,runId:i,contentType:a}){let{MarkdownRenderer:o}=q();switch(F(()=>n===`auto`?hn(e,r,a):n,[e,r,a,n])){case`chart`:{let n=gn(e);return n?t(Y,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(K,{spec:n,artifactRunId:i})}):t(J,{type:`chart`,error:`Only Vega-Lite charts are supported. Recharts rendering has been retired.`})}case`vega-lite`:{let n=gn(e);return n?t(Y,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(K,{spec:n,artifactRunId:i})}):t(J,{type:`chart`,error:`Invalid Vega-Lite specification`})}case`fusion-fragment`:{let n=e;return console.log(`[ArtifactContentRenderer] fusion-fragment:`,{hasTemplate:!!n.template,hasData:!!n.data,runId:i,hasVegaLiteChart:!!K}),n.template&&n.data?t(Y,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(we,{data:n.data,ChartComponent:K,artifactRunId:i,children:t(Ce,{code:JSON.stringify(n.template),data:n.data})})}):t(Y,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(Ce,{code:JSON.stringify(e)})})}case`table`:return t(Y,{type:`table`,fallbackCode:JSON.stringify(e,null,2),children:t(_n,{content:e})});case`markdown`:{let n=typeof e==`string`?e:String(e);return t(Y,{type:`markdown`,fallbackCode:n,children:o?t(o,{artifactRunId:i,children:n}):t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{children:n})})})}case`mockup`:return t(Y,{type:`expand`,fallbackCode:typeof e==`string`?e:r,children:t(xn,{content:e})});case`image`:return t(Y,{type:`image`,fallbackCode:r,children:t(Sn,{content:e,path:r})});default:return t(vn,{content:e,path:r})}}var wn=class{components={};registerComponent(e,t){this.components[e]=t}getComponent(e){return this.components[e]}};const Tn=A(null);function En({components:e,children:n}){let r=F(()=>{let t=new wn;for(let[n,r]of Object.entries(e))t.registerComponent(n,r);return t},[e]);return t(Tn.Provider,{value:r,children:n})}function Dn(){return N(Tn)}function On(e){let t=N(Tn);if(t)return t.getComponent(e)}const kn=`Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function An(e){let t=e.trim(),n=``,r=!1,i=!1;for(let e=0;e<t.length;e++){let a=t[e],o=e>0?t[e-1]:``;if(a===`"`&&!i&&o!==`\\`){r=!r,n+=a;continue}if(a===`'`&&!r&&o!==`\\`){i=!i,n+=a;continue}if((r||i)&&a===`\\`){let r=e;for(;t[r]===`\\`;)r++;if(t[r]===`n`){n+=`<br/>`,e=r;continue}}n+=a}return n}function jn(e){return e.replace(/<svg([^<>]*)>/i,(e,t)=>{let n=t.replace(/\swidth="[^"]*"/i,``).replace(/\sheight="[^"]*"/i,``);return/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}Ae.initialize({startOnLoad:!1,theme:`default`,securityLevel:`loose`,fontFamily:kn,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:kn}});function Mn({code:e,className:n}){let r=I(null),[i,a]=L(null),[o,s]=L(null),c=ve().replace(/:/g,`_`);return P(()=>{let t=!1;return(async()=>{if(!e.trim()){a(null),s(null);return}try{s(null);let n=`mermaid-${c}-${Date.now()}`,r=An(e),{svg:i}=await Ae.render(n,r),o=jn(i);t||a(o)}catch(e){t||(s(e instanceof Error?e.message:`Failed to render mermaid diagram`),a(null))}})(),()=>{t=!0}},[e,c]),o?null:i?t(`div`,{ref:r,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${n||``}`,dangerouslySetInnerHTML:{__html:i}}):t(`div`,{className:`my-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg animate-pulse ${n||``}`,children:t(`div`,{className:`h-32 bg-gray-200 dark:bg-gray-700 rounded`})})}function Nn(e){switch(e.split(`.`).pop()?.toLowerCase()){case`json`:return`json`;case`md`:case`txt`:case`csv`:case`yaml`:case`yml`:return`text`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`webp`:case`pdf`:return`binary`;default:return`text`}}function Pn({runId:e,path:t,parseJson:n=!0}){let{client:r}=Ee(),i=Jt(),a=I(r);a.current=r;let o=I(i);o.current=i;let[s,c]=L({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l=M(async()=>{if(!e){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No run ID provided`,contentType:void 0});return}if(!t){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No artifact path provided`,contentType:void 0});return}c(e=>({...e,isLoading:!0,error:void 0}));let r=a.current,i=o.current,s=Nn(t);try{let a=Xt(e,t,`inline`),o;o=i?await i.getOrFetch(a,async()=>(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url):(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url;let l=await fetch(o);if(!l.ok)throw Error(`Failed to fetch artifact: ${l.status} ${l.statusText}`);if(s===`binary`){c({data:o,rawContent:void 0,isLoading:!1,error:void 0,contentType:s});return}let u=await l.text(),d;if(n&&s===`json`)try{d=JSON.parse(u)}catch{d=u}else d=u;c({data:d,rawContent:u,isLoading:!1,error:void 0,contentType:s})}catch(e){let n=e instanceof Error?e.message:`Failed to fetch artifact`;console.error(`Failed to fetch artifact content:`,t,e),c({data:void 0,rawContent:void 0,isLoading:!1,error:n,contentType:s})}},[e,t,n]);P(()=>{l()},[l]);let u=M(()=>{c({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l()},[l]);return{data:s.data,rawContent:s.rawContent,isLoading:s.isLoading,error:s.error,contentType:s.contentType,retry:u}}function Fn(e){let t=e.trim();if(t.length<2)return!0;if(!t.startsWith(`{`))return!1;try{return JSON.parse(t),!1}catch(e){let n=e instanceof Error?e.message:``,r=[`unexpected end`,`unterminated string`,`expected`,`unexpected token`],i=n.toLowerCase();if(r.some(e=>i.includes(e))){let e=0,n=0,r=!1,i=!1;for(let a of t){if(i){i=!1;continue}if(a===`\\`){i=!0;continue}if(a===`"`){r=!r;continue}r||(a===`{`?e++:a===`}`?e--:a===`[`?n++:a===`]`&&n--)}return e>0||n>0||r}return!1}}function In(e){try{let t=e.trim(),n=t.indexOf(`{`),r=t.lastIndexOf(`}`);return n!==-1&&r>n&&(t=t.slice(n,r+1)),JSON.parse(t)}catch{return null}}function Ln(e){let t=typeof e.$schema==`string`&&e.$schema.includes(`vega`),n=e.library===`vega-lite`&&`spec`in e;return t||n?`vega-lite`:null}function Rn({code:e}){let{artifactRunId:n}=q();n||console.warn(`[VegaLiteCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=F(()=>Fn(e),[e]),i=F(()=>{if(r)return null;let t=In(e);return t?{library:`vega-lite`,spec:t}:null},[e,r]);return r?t(J,{type:`chart`,message:`Loading chart...`}):i?t(Y,{type:`chart`,fallbackCode:e,children:t(K,{spec:i,artifactRunId:n})}):t(J,{type:`chart`,error:`Invalid Vega-Lite specification`})}function zn({code:e}){let{artifactRunId:n}=q();n||console.warn(`[ChartCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=F(()=>Fn(e),[e]),i=F(()=>{if(r)return null;let t=In(e);return!t||!Ln(t)?null:t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`?t:{library:`vega-lite`,spec:t}},[e,r]);return r?t(J,{type:`chart`,message:`Loading chart...`}):i?t(Y,{type:`chart`,fallbackCode:e,children:t(K,{spec:i,artifactRunId:n})}):t(J,{type:`chart`,error:`Invalid Vega-Lite chart specification`})}function Bn({code:e}){let n=e.trim();return n?t(Y,{type:`mermaid`,fallbackCode:e,children:t(Mn,{code:n})}):t(J,{type:`mermaid`,error:`Empty diagram`})}function Vn({code:e}){let n=F(()=>{let t=e.trim();return t?bn(yn(t)):null},[e]);return n?t(Y,{type:`code`,fallbackCode:e,children:t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}})}):t(J,{type:`code`,error:`Empty mockup`})}function Hn({code:e,language:n}){let{artifactRunId:r}=q(),i=e.trim(),a=F(()=>{if(!n?.includes(`:`))return`auto`;let e=n.split(`:`)[1];return[`chart`,`vega-lite`,`table`,`markdown`,`fusion-fragment`,`mockup`,`code`,`image`,`auto`].includes(e)?e:`auto`},[n]),{data:o,isLoading:s,error:c,contentType:l}=Pn({runId:r,path:i});return r?s?t(J,{type:`expand`,message:`Loading ${i}...`}):c?t(J,{type:`expand`,error:`Failed to load artifact: ${c}`}):o===void 0?t(J,{type:`expand`,error:`No content found in artifact`}):t(Cn,{content:o,renderType:a,path:i,runId:r,contentType:l}):t(J,{type:`expand`,error:`No artifact run ID available`})}function Un(e){return e?.startsWith(`expand`)??!1}function Wn(){return{chart:zn,"vega-lite":Rn,vegalite:Rn,mermaid:Bn,mockup:Vn,svg:Vn}}function Gn(e){return e.trim().replace(/^\/+/,``)}function X(e){return e.startsWith(`artifact:`)?{scheme:`artifact`,path:e.slice(9).trim()}:e.startsWith(`image:`)?{scheme:`image`,path:e.slice(6).trim()}:e.startsWith(`store:`)?{scheme:`store`,path:Gn(e.slice(6))}:e.startsWith(`document:`)?{scheme:`document`,path:Gn(e.slice(9))}:e.startsWith(`collection:`)?{scheme:`collection`,path:Gn(e.slice(11))}:{scheme:`standard`,path:e}}function Kn(e,t){switch(e){case`store`:return t?`/store/objects/${t}`:null;case`document`:return t?`/store/objects/${t}`:null;case`collection`:return t?`/store/collections/${t}`:null;default:return null}}function qn({rawUrl:e,artifactRunId:t,disposition:n=`inline`}){let{client:r}=Ee(),i=Jt(),a=I(r);a.current=r;let o=I(i);o.current=i;let{scheme:s,path:c}=X(e),l=Kn(s,c),[u,d]=L(()=>{if(l)return{url:l,isLoading:!1,error:void 0};if(s===`standard`)return{url:e,isLoading:!1,error:void 0};if(i&&(s===`artifact`||s===`image`)){let e;e=s===`artifact`&&t&&!Yt(c)?Xt(t,c,n):Zt(c);let r=i.getUrl(e);if(r)return{url:r,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),f=M(async()=>{if(l||s===`standard`)return;if(s!==`artifact`&&s!==`image`){d({url:void 0,isLoading:!1,error:`Unknown scheme: ${s}`});return}d(e=>({...e,isLoading:!0,error:void 0}));let e=a.current,r=o.current;try{let i;if(s===`artifact`)if(t&&!Yt(c)){let a=Xt(t,c,n);i=r?await r.getOrFetch(a,async()=>(await e.files.getArtifactDownloadUrl(t,c,n)).url):(await e.files.getArtifactDownloadUrl(t,c,n)).url}else{let t=Zt(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}else{let t=Zt(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}d({url:i,isLoading:!1,error:void 0})}catch(e){let t=e instanceof Error?e.message:`Failed to resolve URL`;console.error(`Failed to resolve URL:`,c,e),d({url:void 0,isLoading:!1,error:t})}},[s,c,t,n,l]);P(()=>{if(u.url&&!u.error)return;let e=!1;return e||(async()=>{await f()})(),()=>{e=!0}},[f,u.url,u.error]);let p=M(()=>{d({url:void 0,isLoading:!0,error:void 0}),f()},[f]);return{url:u.url,isLoading:u.isLoading,error:u.error,scheme:s,retry:p}}function Jn({src:e,alt:r,caption:i,className:a,artifactRunId:o}){let s=e||``,{scheme:c}=X(s);return c===`standard`?n(`figure`,{className:`my-4`,children:[t(`img`,{src:e,alt:r,className:a}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):t(Yn,{rawSrc:s,alt:r,caption:i,artifactRunId:o,className:a})}function Yn({rawSrc:e,alt:r,caption:i,artifactRunId:a,className:o}){let{url:s,isLoading:c,error:l,retry:u}=qn({rawUrl:e,artifactRunId:a,disposition:`inline`});return c?t(J,{type:`image`,message:r?`Loading ${r}...`:void 0}):l?t(J,{type:`image`,error:l,onRetry:u}):s?n(`figure`,{className:`my-4`,children:[t(`img`,{src:s,alt:r,className:o}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):null}function Xn({node:e,src:n,alt:r,className:i,artifactRunId:a,ExistingImg:o,...s}){let c=n||``,{scheme:l}=X(c);return l===`standard`?typeof o==`function`?t(o,{node:e,src:n,alt:r,...s}):t(`img`,{src:n,alt:r,className:i,...s}):t(Zn,{rawSrc:c,alt:r,artifactRunId:a,className:i,rest:s})}function Zn({rawSrc:e,alt:n,artifactRunId:r,className:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=qn({rawUrl:e,artifactRunId:r,disposition:`inline`});return s?t(J,{type:`image`,message:n?`Loading ${n}...`:void 0}):c?t(J,{type:`image`,error:c,onRetry:l}):o?t(`img`,{src:o,alt:n,className:i,...a}):null}function Qn({node:e,href:n,children:r,className:i,artifactRunId:a,ExistingLink:o,...s}){let c=n||``,{scheme:l,path:u}=X(c),d=Kn(l,u);return d?typeof o==`function`?t(o,{node:e,href:d,...s,children:r}):t(`a`,{href:d,...s,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):l===`standard`?typeof o==`function`?t(o,{node:e,href:n,...s,children:r}):t(`a`,{href:n,...s,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):t($n,{rawHref:c,artifactRunId:a,className:i,rest:s,children:r})}function $n({rawHref:e,artifactRunId:n,className:r,children:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=qn({rawUrl:e,artifactRunId:n,disposition:`attachment`});return s?t(`span`,{className:`inline-flex items-center gap-1 text-muted`,children:t(J,{type:`link`})}):c?t(`span`,{className:`inline-flex items-center gap-1`,children:t(J,{type:`link`,error:c,onRetry:l})}):t(`a`,{href:o||`#`,...a,className:r,target:`_blank`,rel:`noopener noreferrer`,children:i})}const er=[`artifact:`,`image:`,`store:`,`document://`,`collection:`],tr=/(!?\[[^[\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:)[^)[\n]+)(\))/g,nr=/`[^`\n]*`/g,rr=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,ir=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function ar(e){return er.some(t=>e.startsWith(t))}function or(e){let t=e.trim();if(t.startsWith(`<`)){let n=t.indexOf(`>`);if(n>0&&ar(t.slice(1,n).trim()))return e}let n=t.match(ir)?.index??-1,r=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):``;return ar(r)?`<${r}>${i}`:e}function sr(e){return e.replace(tr,(e,t,n,r)=>`${t}${or(n)}${r}`)}function cr(e){let t=``,n=0;for(let r of e.matchAll(nr))t+=sr(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=sr(e.slice(n)),t}function lr(e){if(!e||!er.some(t=>e.includes(t)))return e;let t=``,n=0;for(let r of e.matchAll(rr))t+=cr(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=cr(e.slice(n)),t}const ur=/^([ \t]*):::([^\n]*?):::[ \t]*$/gm,dr=/^\w+/;function fr(e){return e?.includes(`:::`)?e.replace(ur,(e,t,n)=>{let r=n.trim(),i=dr.exec(r);if(!i)return e;let a=i[0],o=r.slice(a.length).trim();return o?`${t}:::${a}\n${t}${o}\n${t}:::`:`${t}::${a}`}):e}const pr=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,mr=/`[^`\n]*`/g,hr=/\\\$/g,gr=/\\[^\s]/,_r=/[{}]/,vr=/[_^][\w{]/,yr=/^[a-zA-Z]$/,br=/^[a-zA-Z]\s*=/,xr=/^\s/,Sr=/\s$/,Cr=/[+*/-]$/,wr=/\^[+-]$/;function Tr(e){return gr.test(e)||_r.test(e)||vr.test(e)||yr.test(e)||br.test(e)}function Er(e){return!!(xr.test(e)||Sr.test(e)||Cr.test(e)&&!wr.test(e))}function Dr(e){let t=[];for(let n=0;n<e.length;n++)if(e[n]===`$`&&!(n>0&&e[n-1]===`\\`)){if(n+1<e.length&&e[n+1]===`$`){n++;continue}n>0&&e[n-1]===`$`&&(n<2||e[n-2]!==`\\`)||t.push(n)}return t}function Or(e,t,n){let r=e.slice(t+1,n);return r.length===0||r.includes(`
6
+ `)?null:r}function kr(e){let t=Dr(e);if(t.length<2)return e;let n=new Set,r=new Set,i=Array(t.length-1);for(let n=0;n<t.length-1;n++)i[n]=Or(e,t[n],t[n+1]);let a=[];for(let e=0;e<t.length-1;e++){if(n.has(e))continue;let r=i[e];r!==null&&Tr(r)&&(n.add(e),n.add(e+1),a.push([t[e],t[e+1]]))}let o=0;for(;o<t.length;){if(n.has(o)){o++;continue}let e=o+1;for(;e<t.length&&n.has(e);)e++;if(e>=t.length)break;if(e>o+1){r.add(t[o]),o++;continue}let a=i[o];if(a===null){o++;continue}Er(a)&&(r.add(t[o]),r.add(t[e])),n.add(o),n.add(e),o=e+1}for(let e=0;e<t.length;e++)n.has(e)||e+1<t.length&&n.has(e+1)&&r.add(t[e]);if(r.size===0&&a.length===0)return e;let s=[],c=0,l=Array.from(r).sort((e,t)=>e-t),u=0,d=0;for(;u<l.length||d<a.length;){let t=u<l.length?l[u]:1/0;if(t<(d<a.length?a[d][0]:1/0))t>c&&s.push(e.slice(c,t)),s.push(`\\$`),c=t+1,u++;else{let[t,n]=a[d];t>c&&s.push(e.slice(c,t));let r=e.slice(t,n+1);for(s.push(r.replace(hr,`\\text{\\textdollar}`)),c=n+1;u<l.length&&l[u]<=n;)u++;d++}}return c<e.length&&s.push(e.slice(c)),s.join(``)}function Ar(e){let t=[],n=0;for(let r of e.matchAll(mr))t.push(kr(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(kr(e.slice(n))),t.join(``)}function jr(e){if(!e?.includes(`$`))return e;let t=[],n=0;for(let r of e.matchAll(pr))t.push(Ar(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(Ar(e.slice(n))),t.join(``)}const Mr={note:`md-callout-info`,tip:`md-callout-info`,warning:`md-callout-attention`,important:`md-callout-attention`,caution:`md-callout-destructive`},Nr={note:`Note`,tip:`Tip`,warning:`Warning`,important:`Important`,caution:`Caution`};function Pr(){return e=>{He(e,e=>{if(e.type!==`containerDirective`&&e.type!==`leafDirective`&&e.type!==`textDirective`)return;let t=e;t.data||={};let n=t.data,r=t.attributes||{},i=t.name;if(i===`pagebreak`){n.hName=`hr`,n.hProperties={className:`md-pagebreak`};return}if(i===`columns`){n.hName=`div`,n.hProperties={className:`md-columns`};return}if(i===`column`){n.hName=`div`;let e={className:`md-column`};r.width&&(e.style=`flex-basis:${r.width};flex-grow:0;flex-shrink:0`),n.hProperties=e;return}if(i in Mr){n.hName=`div`,n.hProperties={className:`md-callout ${Mr[i]}`,"data-callout-type":i};let e=Nr[i];if(e&&t.children){let n={type:`paragraph`,data:{hName:`p`,hProperties:{className:`md-callout-title`}},children:[{type:`text`,value:e}]};t.children.unshift(n)}return}n.hName=`div`,n.hProperties={className:`md-${i}`,...Object.fromEntries(Object.entries(r).filter(([e])=>e!==`class`))},r.class&&(n.hProperties.className+=` ${r.class}`)})}}const Fr=[`artifact:`,`image:`,`store:`,`document:`,`document://`,`collection:`];function Ir(e){return Fr.some(t=>e.startsWith(t))?e:Me(e)}function Lr(){return e=>{He(e,`html`,(e,t,n)=>{let r=e,i=n;if(typeof r.value==`string`&&/<!--[\s\S]*?-->/.test(r.value)&&i?.children&&typeof t==`number`)return i.children.splice(t,1),[Ve,t]})}}const Rr=Wn();function zr({children:e,components:n,remarkPlugins:r=[],removeComments:i=!0,artifactRunId:a,className:o,codeClassName:s,inlineCodeClassName:c,linkClassName:l,imageClassName:u,onProposalSelect:d,onProposalSubmit:f}){let p=Dn(),m=k.useMemo(()=>fr(lr(jr(e))),[e]),h=t(pn,{artifactRunId:a,onProposalSelect:d,onProposalSubmit:f,MarkdownRenderer:zr,children:t(je,{remarkPlugins:k.useMemo(()=>{let e=[Le,Ie,Pr,Re,Fe,Be,ze,...r];return i&&e.push(Lr),e},[r,i]),rehypePlugins:k.useMemo(()=>[Ne],[]),remarkRehypeOptions:k.useMemo(()=>({handlers:{...Pe}}),[]),components:k.useMemo(()=>{let e=n||{},r=e.code,i=e.a,o=e.img,d=({node:e,className:n,children:i,...a})=>{let o=/language-([\w-]+)/.exec(n||``),l=!o,u=o?o[1]:``;if(!l&&u){if(p){let e=p.getComponent(u);if(e)return t(e,{code:String(i||``).trim(),language:u})}if(Un(u))return t(Hn,{code:String(i||``).trim(),language:u});let e=Rr[u];if(e)return t(e,{code:String(i||``).trim(),language:u})}return typeof r==`function`?t(r,{node:e,className:n,...a,children:i}):t(`code`,{...a,className:l?`px-1.5 py-0.5 rounded ${c||``}`:` ${s||``}`,children:i})},f=e=>{let{node:n,href:r,children:o,...s}=e;return t(Qn,{node:n,href:r,className:l,artifactRunId:a,ExistingLink:typeof i==`function`?i:void 0,...s,children:o})},m=e=>{let{node:n,src:r,alt:i,title:s,...c}=e;return s?t(Jn,{src:r,alt:i,caption:s,className:u,artifactRunId:a}):t(Xn,{node:n,src:r,alt:i,className:u,artifactRunId:a,ExistingImg:typeof o==`function`?o:void 0,...c})};return{...e,code:d,a:f,img:m}},[n,a,p,s,c,l,u]),urlTransform:Ir,children:m})});return o?t(`div`,{className:`md-content ${o}`,children:h}):t(`div`,{className:`md-content`,children:h})}function Br({percent:e}){return t(`div`,{className:`w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700`,children:t(`div`,{className:`bg-blue-600 h-2.5 rounded-full`,style:{width:`${e}%`}})})}function Vr({className:e,properties:r}){return t(f,{className:e,children:t(`tbody`,{children:r.map(e=>n(`tr`,{children:[n(`td`,{className:`w-1/3 font-semibold gap-2`,children:[t(`span`,{children:e.name}),e.description&&t(p,{description:e.description,placement:`top`,children:t(se,{className:`size-3 ms-2 text-muted-foreground`})})]}),t(`td`,{className:`w-2/3`,children:e.value??`undefined`})]},e.name))})})}function Hr({content:e,...n}){let r=I(null);return P(()=>{if(!r.current)return;let t=new DOMParser().parseFromString(e,`image/svg+xml`).querySelector(`svg`);if(!t){console.warn(`SvgIcon: No <svg> element found in provided string`),r.current.innerHTML=``;return}Object.entries(n).forEach(([e,n])=>{if(n==null)return;let r=e===`className`?`class`:e;t.setAttribute(r,String(n))}),r.current.innerHTML=``,r.current.appendChild(t)}),t(`span`,{ref:r})}function Ur(e){return n=>t(Hr,{content:e,...n})}function Wr(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}var Z;(function(e){e.string=`string`,e.number=`number`,e.integer=`integer`,e.boolean=`boolean`,e.object=`object`,e.any=`any`,e.text=`text`,e.media=`media`,e.document=`document`})(Z||={});function Gr(e){e=e.trim();let t=!1,n=!1;e.endsWith(`?`)&&(n=!0,e=e.substring(0,e.length-1).trim()),e.endsWith(`[]`)&&(t=!0,e=e.substring(0,e.length-2).trim());let r=Z[e];if(!r)throw Error(`Unknown type "${e}"`);return{name:r,isArray:t,isNullable:n,isObject:r===Z.object}}function Kr(){let e=Object.values(Z),t=[...e];for(let n of e)t.push(`${n}[]`);return e.sort(),t}const qr=Kr();function Jr({value:e,onChange:i,onCancel:a,onSave:o}){let{t:s}=R(),[c,l]=L(!1);return e?n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`flex-1`,children:t(Yr,{value:e.name,onChange:t=>{i({...e,name:t})},onCancel:a,onSave:o})}),t(`div`,{className:`px-1 font-semibold`,children:`:`}),t(`div`,{className:`flex-1`,children:t(Xr,{value:e.type,onChange:t=>{i({...e,type:t})},onCancel:a,onSave:o})}),n(`div`,{children:[t(r,{variant:`ghost`,size:`xs`,onClick:()=>l(!0),title:s(`widgets.schema.editDescription`),children:t(S,{className:`size-4`})}),t(Zr,{value:e.description,isOpen:c,onClose:t=>{t!==void 0&&typeof t==`string`&&i({...e,description:t},!0),l(!1)}})]})]}):null}function Yr({value:e,onChange:n,onCancel:r,onSave:i}){let a=I(null);return P(()=>{a.current?.focus()},[]),t(`input`,{onKeyUp:e=>{switch(e.key){case`Enter`:i?.();break;case`Escape`:r?.();break}},ref:a,value:e,onChange:e=>{n(e.target.value)},className:d.INPUT_UNSTYLED,style:{fontSize:`inherit`,width:``,display:`inline`}})}function Xr({value:e,onChange:n,onCancel:r,onSave:i}){return t(u,{className:d.INPUT_UNSTYLED,options:qr,value:e||``,onBlur:()=>{i?.()},onChange:n,onKeyDown:(e,t)=>{t||(e.key===`Enter`?i?.():e.key===`Escape`&&r?.())},popupClass:`schema-type-suggest-popup z-90`})}function Zr({value:e,isOpen:r,onClose:i}){let{t:a}=R();return n(o,{isOpen:r,onClose:i,children:[t(l,{children:a(`widgets.schema.editDescription`)}),t(Qr,{value:e,onSave:i})]})}function Qr({value:i,onSave:a}){let{t:o}=R(),l=I(null),[u,d]=L(i||``);return P(()=>{l.current?.focus()},[]),n(e,{children:[t(s,{className:`h-max`,children:t(`textarea`,{ref:l,className:`dark:bg-gray-800 w-full h-full dark:text-white`,value:u,onChange:e=>d(e.target.value)})}),t(c,{children:t(r,{onClick:()=>a(u),children:o(`store.saveChanges`)})})]})}function $r({value:e}){return e?n(`div`,{className:`w-full flex items-baseline`,children:[t(`div`,{children:e.name||``}),t(`div`,{className:`ms-2 text-sm text-muted`,children:e.type||``})]}):null}function ei(e,t,n){if(e.properties){let r=e.properties,i={};for(let e of Object.keys(r)){let a=r[e];e===t?i[n]=a:i[e]=a}e.properties=i}e.required&&=e.required.map(e=>e===t?n:e)}function ti(e,t,n){if(Array.isArray(e.required)){let r=e.required.indexOf(t);n?r<0&&e.required.push(t):r>-1&&e.required.splice(r,1)}else n&&(e.required=[t])}function ni(e,t){let n=t.name===`any`?void 0:t.isNullable?[t.name,`null`]:t.name;if(t.isArray)if(e.type=`array`,e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:n,properties:t.isObject?{}:void 0};else{let r=e.items;r.type=n,t.isObject&&!r.properties&&(r.properties={})}else e.type=n,e.items=void 0,t.isObject?e.properties||={}:e.properties=void 0}function ri(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter(e=>e!==t)))}function ii(e,t,n,r=!1){if(e.type!==`object`)throw Error(`Cannot add property to a non-object schema`);e.properties||={};let i={};return ni(i,n),e.properties[t]=i,r&&(Array.isArray(e.required)?ci(e.required,t):e.required=[t]),i}function ai(e){let t=!1,n=!1,r,i=e.type;if(Array.isArray(i))for(let e of i)e===`null`?t=!0:r||=e;else r=i;r||=`any`,r===`array`&&(n=!0,r=oi(e.items));let a=r;switch(e.editor){case`textarea`:a=`text`;break;case`media`:a=`media`;break;case`document`:a=`document`;break}return{isNullable:t,isArray:n,isObject:r===`object`,name:a}}function oi(e){if(!e)return`any`;let t;return t=si(Array.isArray(e)?e[0].type:e.type),(t===`array`||t===`null`)&&(t=`any`),t}function si(e){return e?Array.isArray(e)?e.find(e=>e!==`null`)||`any`:e:`any`}function ci(e,t){e.includes(t)||e.push(t)}let li=0;var ui=class e{source;onChange=()=>{};schema;root;constructor(e,t){e?typeof e==`string`?this.schema=JSON.parse(e):this.schema=e:this.schema={title:t,type:`object`,properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new di(``,this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||this.root.children.length===0}get children(){return this.root.children??[]}reload(){return this.root=new di(``,this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){e?this.schema=e:this.schema={title:this.schema.title,type:`object`,properties:{}},this.reload()}clone(){let t=new e(this.schema);return t.source=this.source,this.onChange&&t.withChangeListener(this.onChange),t}},di=class e{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,n,r){if(this.schema=t,this.loader=n,this.parent=r,this.name=e,this.type=ai(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=t&&Array.isArray(t)?t.includes(e):!1}}get title(){return typeof this.schema.title==`string`?this.schema.title:void 0}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){let e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?``:`?`}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?`[]`:``}${this.type.isNullable?`?`:``}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[];let e=this.schema.items?.properties;this.schema.items&&e?this._loadChildren(e,this.children):this.schema.properties&&this._loadChildren(this.schema.properties,this.children)}_loadChildren(t,n){for(let r of Object.keys(t)){let i=t[r],a=new e(r,i,this.loader,this);n.push(a),a.isParent&&a.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){let t=this._getPropertiesSchema().properties||{},n;do n=e+ ++li;while(t[n]);return n}addChild(t,n,r=!1){if(!this.type.isObject)throw Error(`Cannot add child to a non object node`);this.children||=[];let i=new e(t,ii(this._getPropertiesSchema(),t,n,r),this.loader,this);return this.children.push(i),i}remove(){return this.parent?.type.isObject?(ri(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter(e=>e.name!==this.name)),!0):!1}update(e){let t=!1;e.name!=null&&this.name!==e.name&&(this.parent&&ei(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),e.isRequired!=null&&this.isRequired!==e.isRequired&&(this.parent&&ti(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let n=e.type?.name;n===`any`&&(n=void 0);let r=n!==this.schema.type;return e.type&&(ni(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||=[]:this.children=void 0,t=!0),this.schema.editor&&e.editor===null?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):r&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let n=e.trim(),r=!0;n.endsWith(`?`)&&(n=n.substring(0,n.length-1).trim(),r=!1);let i=Gr(t),a;return i.name===`text`?(i.name=Z.string,a=`textarea`):i.name===`media`?(i.name=Z.any,a=`media`):i.name===`document`?(i.name=Z.any,a=`document`):a=null,{name:n,type:i,isRequired:r,editor:a}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){e=e.trim();let t=e.indexOf(`:`);if(t<0)throw Error(`Expecting a name and a type separated by a colon`);let n=e.substring(0,t),r=e.substring(t+1);return this.updateFromNameAndTypeSignature(n,r)}};function fi(e){let[t,n]=L(new ui(e||{type:`object`,properties:{}}).withChangeListener(e=>{n(e.clone())}));return t}const pi=`block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4`,mi=`${pi} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,hi=`${pi} shadow-xs ring-1 ring-inset ring-ring`;function gi({value:e,onChange:r,onDelete:i,outlineOnHover:a=!1,editOnClick:o=!0,placeholder:s,viewer:c,editor:l,skipClickOutside:u,isEditing:d=!1,readonly:f=!1,onValidate:p}){let{on:m,off:h,isOn:_}=g(d),[v,y]=L();return n(`div`,{className:``,children:[_&&!f?t(vi,{value:e,onSave:e=>{if(p){let t=p(e);if(t){y(t);return}else y(void 0)}r(e)&&h()},onCancel:h,editor:l,skipClickOutside:e=>u?u(e):!1}):t(_i,{value:e,onEdit:m,viewer:c,placeholder:s,outlineOnHover:a,editOnClick:o,onDelete:i,readonly:f}),v&&t(`div`,{className:`text-red-500 text-sm`,children:v})]})}function _i({viewer:e,value:i,onEdit:a,editOnClick:o,outlineOnHover:s,placeholder:c,onDelete:l,readonly:u}){let d=()=>{o&&a()},f=e=>{e.key===`Enter`&&a()},p=`invisible group-hover:visible`;return n(`div`,{role:o?`button`:void 0,tabIndex:0,onKeyUp:f,onClick:d,className:y(`flex justify-start items-center group`,s?mi:pi,{"cursor-pointer":o}),children:[t(e,{value:i,placeholder:c}),n(`div`,{className:`ms-auto flex gap-2`,children:[!u&&l&&t(r,{variant:`ghost`,size:`sm`,className:p,onClick:l,children:t(me,{className:`size-4`})}),u?null:t(r,{variant:`ghost`,size:`sm`,className:p,onClick:a,children:t(O,{className:`size-4`})})]})]})}function vi({editor:e,value:n,onSave:r,onCancel:i,skipClickOutside:a}){let[o,s]=L(n),c=I(n),[l,u]=L(null),d=()=>{r(c.current)};return t(`div`,{ref:h(d,a),children:t(`div`,{className:hi,children:t(`div`,{className:`w-full`,onClick:e=>e.stopPropagation(),children:t(e,{value:o,onChange:(e,t=!1)=>{s(e),c.current=e,t&&(l&&clearTimeout(l),u(setTimeout(()=>{r(e)},500)))},onSave:d,onCancel:i})})})})}function yi(e){return!!e.target.closest?.(`.schema-type-suggest-popup`)}function bi({schema:e,readonly:r=!1}){return n(`ul`,{className:``,children:[e.children.map(e=>xi(e,r)),r?null:t(Ei,{parent:e.root})]})}function xi(e,n){return e.isParent?t(Ci,{property:e,readonly:n},e.name):t(Si,{node:e,readonly:n},e.name)}function Si({node:e,readonly:n}){return t(`li`,{children:t(Ti,{property:e,readonly:n})})}function Ci({property:e,readonly:i}){let[a,o]=L(!0),s=a?te:T;return n(`li`,{children:[n(`div`,{className:`flex items-center w-full`,children:[t(r,{variant:`ghost`,size:`icon`,onClick:()=>o(!a),"aria-label":a?`Collapse ${e.name}`:`Expand ${e.name}`,"aria-expanded":a,children:t(s,{className:`size-4 cn-rtl-flip`})}),t(`div`,{className:`flex-1`,children:t(Ti,{property:e,readonly:i})})]}),a&&n(`ul`,{className:`ms-4 border-s border-gray-400 border-dashed`,children:[(e.children||[]).map(e=>xi(e,i)),i?null:t(Ei,{parent:e})]})]})}function wi(e){if(!e)return`Name is required`;if(!/^[a-zA-Z0-9_]+[?]?$/.test(e))return`Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)`}function Ti({property:e,readonly:n}){let{t:r}=R(),i=v(),a=t=>{try{t.description&&typeof t.description!=`string`&&(t.description=void 0);let n=e.getUpdateFromNameAndTypeSignature(t.name,t.type);e.update({...n,description:t.description})&&e.reloadTree()}catch(e){return i({status:`error`,title:r(`widgets.schema.invalidPropertyDeclaration`),description:m(e),duration:9e3}),!1}return!0},o=e.resetIsNew();return t(gi,{value:Wr(e),onChange:a,onDelete:()=>{e.remove(),e.reloadTree()},editor:Jr,viewer:$r,outlineOnHover:!0,isEditing:o,skipClickOutside:yi,readonly:n,onValidate:e=>wi(e.name)})}function Ei({parent:e}){return n(r,{variant:`ghost`,onClick:()=>{let t=e.findAvailableChildName(`new_property_`),n=e.addChild(t,{isObject:!1,isArray:!1,isNullable:!1,name:Z.string},!0);n.isNew=!0,e.reloadTree()},children:[t(fe,{className:`size-4`}),`Add property`]})}function Di(e){return e.isFile}function Oi(e){return e.isDirectory}function ki({onDrop:e,message:i,buttonLabel:a,allowFolders:o=!0,className:s=``}){let{t:c}=R(),l=a??c(`upload.uploadFiles`),[u,d]=L(!1),f=I(null),p=e=>{e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&d(!0)},m=e=>{e.preventDefault(),f.current&&!f.current.contains(e.relatedTarget)&&d(!1)},h=async t=>{if(t.preventDefault(),d(!1),t.dataTransfer.items&&t.dataTransfer.items.length>0){let n=Array.from(t.dataTransfer.items),r=[],i=new Set,a=async e=>{if(Di(e)){let t=await new Promise(t=>{e.file(n=>{Object.defineProperty(n,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(n)})});!t.name.startsWith(`.`)&&t.size>0&&r.push(t);let n=e.fullPath.substring(1).split(`/`).slice(0,-1).join(`/`);n&&i.add(n)}else if(Oi(e)){let t=e.createReader(),n=await new Promise(e=>{t.readEntries(t=>{e(t)})});await Promise.all(n.map(a));let r=e.fullPath.substring(1);r&&i.add(r)}};try{if(await Promise.all(n.map(e=>{let t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?a(t):Promise.resolve()})),r.length>0){let t=new Set(Array.from(i).map(e=>e.split(`/`)[0]).filter(Boolean)).size,n=r.length,a=``;a=t>0?c(`upload.preparingFolder`,{count:t,folderCount:t,fileCount:n}):c(`upload.preparingFiles`,{count:n}),e(r,{count:r.length,message:a})}}catch(n){console.error(`Error processing dropped files:`,n);let r=Array.from(t.dataTransfer.files);r.length>0&&e(r)}}else t.dataTransfer.files&&t.dataTransfer.files.length>0&&e(Array.from(t.dataTransfer.files))},g=t=>{if(t&&t.length>0){let n=Array.from(t);if(n.some(e=>e.webkitRelativePath?.includes(`/`))){let t=new Set(n.map(e=>e.webkitRelativePath.split(`/`)[0]).filter(Boolean)).size,r=n.length,i=c(`upload.preparingFolder`,{count:t,folderCount:t,fileCount:r});e(n,{count:n.length,message:i})}else e(n,{count:n.length,message:c(`upload.preparingFiles`,{count:n.length})})}};return n(`div`,{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${u?`border-color-primary bg-color-primary/10`:`border-dashed border-color-border`} ${s}`,onDragOver:p,onDragLeave:m,onDrop:h,children:[t(he,{className:`h-12 w-12 mb-3 transition-colors ${u?`text-primary`:`text-muted/50`}`}),t(`p`,{className:`text-muted`,children:i}),n(`div`,{className:`flex gap-2 justify-center mt-2`,children:[t(r,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`*`,e?.click(),e.onchange=()=>{g(e.files)}},children:l}),o&&t(r,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`*`,e.webkitdirectory=!0,e?.click(),e.onchange=()=>{g(e.files)}},children:c(`upload.selectFolder`)})]})]})}function Q({title:e,count:r,icon:i=t(w,{className:`h-4 w-4 text-green-500`}),items:a}){let{t:o}=R(),[s,c]=L(!1),l=ve();return n(`div`,{className:`border border-color-border rounded-md overflow-hidden`,children:[n(`button`,{type:`button`,"aria-expanded":s,"aria-controls":l,className:`w-full flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer text-start bg-transparent border-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,onClick:()=>c(!s),children:[n(`span`,{className:`flex items-center`,children:[t(`span`,{className:`me-2`,children:i}),t(`span`,{className:`font-medium`,children:e}),t(`span`,{className:`ms-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs`,children:r})]}),t(`span`,{className:`text-muted`,"aria-hidden":`true`,children:t(`svg`,{className:`h-5 w-5 transition-transform ${s?`transform rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})})]}),s&&t(`div`,{id:l,className:`p-3 border-t border-color-border max-h-48 overflow-y-auto`,children:a.length>0?t(`ul`,{className:`space-y-1`,children:a.map(e=>t(`li`,{className:`text-sm py-1 px-2 rounded hover:bg-color-muted/10`,children:e},e))}):t(`div`,{className:`text-sm text-muted py-2`,children:o(`upload.noItems`)})})]})}function Ai({files:e,className:r=``,location:i,collection:a}){let{t:o}=R(),s=e.filter(e=>e.status===`success`),c=e.filter(e=>e.status===`updated`),l=e.filter(e=>e.status===`skipped`),u=e.filter(e=>e.status===`failed`),d=s.length,f=c.length,p=l.length,m=u.length,h=e.length;return n(`div`,{className:`flex flex-col py-2 ${r}`,children:[n(`div`,{className:`flex items-center mb-4`,children:[t(`div`,{className:`size-8 me-4 rounded-full bg-success/10 flex items-center justify-center`,children:t(w,{className:`size-4 text-success`})}),t(`div`,{children:n(`p`,{className:`text-muted`,children:[o(`upload.filesProcessed`,{count:h}),a?o(`upload.inCollection`,{collection:a}):``,i?o(`upload.inFolder`,{location:i}):``]})})]}),n(`div`,{className:`space-y-3 mt-2`,children:[d>0&&t(Q,{title:o(`upload.successfullyUploaded`),count:d,icon:t(w,{className:`h-4 w-4 text-green-500`}),items:s.map(e=>e.name)}),f>0&&t(Q,{title:o(`upload.successfullyUpdated`),count:f,icon:t(w,{className:`h-4 w-4 text-blue-500`}),items:c.map(e=>e.name)}),p>0&&t(Q,{title:o(`upload.skippedAlreadyExisted`),count:p,icon:t(x,{className:`h-4 w-4 text-amber-500`}),items:l.map(e=>e.name)}),m>0&&t(Q,{title:o(`upload.failedToUpload`),count:m,icon:t(_e,{className:`h-4 w-4 text-red-500`}),items:u.map(e=>e.name)})]})]})}const ji=`#text`,Mi=`#comment`,Ni=`#cdata`,Pi=`DECLARATION_TAG`,Fi={tagColor:`#d43900`,textColor:`#333`,attributeKeyColor:`#2a7ab0`,attributeValueColor:`#008000`,separatorColor:`#333`,commentColor:`#aaa`,cdataColor:`#1d781d`,fontFamily:`monospace`},Ii={attributeKeyColor:`#FFD700`,attributeValueColor:`#FF4500`,tagColor:`#87CEFA`,textColor:`#00FF00`,separatorColor:`#FFD700`,commentColor:`#BEBEBE`,cdataColor:`#33CC66`,fontFamily:`monospace`},Li=A({theme:Fi,collapsible:!1,indentSize:2}),$=()=>N(Li),Ri=new Ue({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:``,allowBooleanAttributes:!0,commentPropName:Mi,cdataPropName:Ni,parseTagValue:!1});function zi(e){return F(()=>{try{let t=We.validate(e);if(t!==!0)throw Error(t.err.msg||`Invalid XML!`);let n=Ri.parse(e);if(typeof e==`string`&&e.trim().length>0&&n.length===0)throw Error(`Invalid XML!`);return{json:n,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}},[e])}function Bi(e){let{indentation:r,children:i,isInline:a}=e,{theme:o}=$();return n(`div`,{style:{color:o.cdataColor},children:[t(`span`,{children:`${r}<![CDATA[`}),i,t(`span`,{children:`${a?``:r}]]>`})]})}function Vi(e){let{collapsible:n,theme:r}=$(),{collapsed:i}=e;return n?t(`span`,{style:{position:`relative`},children:t(`span`,{style:{position:`absolute`,right:`0`,border:0,padding:0,background:`none`},children:t(Hi,{fill:r.separatorColor,style:{transform:`rotate(${i?0:90}deg)`,transition:`transform 0.2s`}})})}):null}function Hi({...e}){return t(`svg`,{width:`16px`,height:`16px`,viewBox:`0 0 24 24`,"aria-hidden":`true`,...e,children:t(`path`,{d:`M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z`})})}function Ui(e){let{collapsible:t,initialCollapsedDepth:n}=$(),[r,i]=L(()=>Ge(n)||!t?!1:e>=n);return P(()=>{i(Ge(n)||!t?!1:e>=n)},[n,e,t]),{collapsed:r,buttonProps:t?{onClick:()=>i(e=>!e),role:`button`,style:{cursor:`pointer`}}:{}}}function Wi(e){let{indentation:r,children:i,isInline:a,level:o}=e,{theme:s}=$(),{collapsed:c,buttonProps:l}=Ui(o);return n(`div`,{style:{color:s.commentColor},children:[n(`span`,{...l,children:[t(`span`,{children:r}),t(Vi,{collapsed:c}),t(`span`,{children:`<!-- `})]}),!c&&i,c&&`...`,t(`span`,{children:`${a||c?` `:r}-->`})]})}function Gi(e){let{attributes:r}=e,{theme:i}=$();return r?t(`span`,{children:Object.entries(r).map(([e,r])=>n(`span`,{children:[t(`span`,{style:{color:i.attributeKeyColor},children:` ${e}`}),t(`span`,{style:{color:i.separatorColor},children:`=`}),t(`span`,{style:{color:i.attributeValueColor},children:`"${r}"`})]},`attribute-${e}`))}):null}function Ki(e){let{indentation:r,tagKey:i,attributes:a}=e,{theme:o}=$();return n(`div`,{children:[t(`span`,{style:{color:o.separatorColor},children:`${r}<?`}),t(`span`,{style:{color:o.tagColor},children:`${i.slice(1)}`}),t(Gi,{attributes:a}),t(`span`,{style:{color:o.separatorColor},children:`?>`})]})}function qi(e,t){return Array(t*e+1).join(` `)}function Ji(e){return typeof e==`string`&&e.includes(`
7
+ `)}function Yi(e){return typeof e==`string`?!1:e.length===1&&`#text`in e[0]&&!Ji(e[0][`#text`])}function Xi(e){switch(e){case ji:case Ni:case Mi:return e;default:return e.startsWith(`?`)?Pi:`TAG`}}function Zi(e){let t=e[`:@`],n=Ke(e,`:@`),[[r,i]]=Object.entries(n);return{attributes:t,tagKey:r,subElements:i,type:Xi(r)}}function Qi(e){return e?Object.keys(e).length>0:!1}function $i(r){let{indentation:i,tagKey:a,attributes:o,children:s,isInline:c,hasChildren:l,level:u}=r,{collapsed:d,buttonProps:f}=Ui(u),{theme:p}=$();return n(`div`,{children:[n(`span`,{...f,children:[t(`span`,{children:i}),t(Vi,{collapsed:d}),t(`span`,{style:{color:p.separatorColor},children:`<`}),t(`span`,{style:{color:p.tagColor},children:`${a}`}),!d&&t(Gi,{attributes:o}),d&&Qi(o)&&` ...`,t(`span`,{style:{color:p.separatorColor},children:l?`>`:` />`})]}),l&&n(e,{children:[!d&&s,d&&`...`,t(`span`,{style:{color:p.separatorColor},children:`${c||d?``:i}</`}),t(`span`,{style:{color:p.tagColor},children:`${a}`}),t(`span`,{style:{color:p.separatorColor},children:`>`})]})]})}function ea(e){let{hasSiblings:n,text:r,indentation:i,isText:a}=e,{theme:o}=$(),s=a?{color:o.textColor}:void 0;return Ji(r)||n?t(`div`,{style:s,children:r.split(`
8
+ `).filter(e=>!!e.trim()).map((e,n)=>t(`div`,{children:`${i}${e.trim()}`},`line-${n}`))}):t(`span`,{style:s,children:r})}function ta(n){let{elements:r,level:i=0,isText:a=!0}=n,{indentSize:o}=$();return!Array.isArray(r)||r.length===0?null:t(e,{children:r.map((e,n)=>{let{tagKey:s,attributes:c,subElements:l,type:u}=Zi(e),d=r.length>1,f=qi(o,i),p=`${i}-${n}`,m=Yi(l);switch(u){case ji:return t(ea,{text:l,indentation:f,hasSiblings:d,isText:a},p);case Mi:return t(Wi,{isInline:m,indentation:f,level:i,children:t(ta,{elements:l,level:i+1,isText:!1})},p);case Ni:return t(Bi,{indentation:f,isInline:m,children:t(ta,{elements:l,level:i+1,isText:!1})},p);case Pi:return t(Ki,{indentation:f,tagKey:s,attributes:c},p);default:return t($i,{indentation:f,tagKey:s,attributes:c,isInline:m,hasChildren:l.length>0,level:i,children:t(ta,{elements:l,level:i+1})},p)}})})}function na(){return t(`div`,{children:`Invalid XML!`})}function ra(e){let{theme:n,xml:r,collapsible:i=!1,indentSize:a=2,invalidXml:o,initalCollapsedDepth:s,initialCollapsedDepth:c}=e,[l,u]=L(()=>document.documentElement.classList.contains(`dark`));P(()=>{let e=document.documentElement,t=new MutationObserver(()=>{u(e.classList.contains(`dark`))});return t.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let d=F(()=>({...l?Ii:Fi,...n}),[l,n]),{json:f,valid:p}=zi(r),m=F(()=>({theme:d,collapsible:i,indentSize:a,initialCollapsedDepth:c??s}),[d,i,a,s,c]);return p?t(Li.Provider,{value:m,children:t(`div`,{className:`rxv-container`,style:{whiteSpace:`pre-wrap`,fontFamily:d.fontFamily,overflowWrap:`break-word`},children:t(ta,{elements:f})})}):o||t(na,{})}export{ht as ArrayPropertySchema,Cn as ArtifactContentRenderer,zn as ChartCodeBlockHandler,Y as CodeBlockErrorBoundary,pn as CodeBlockHandlerProvider,J as CodeBlockPlaceholder,En as CodeBlockRendererProvider,ki as DropZone,Hn as ExpandCodeBlockHandler,Je as FieldSetContextProvider,et as Form,Xe as FormContext,Qe as FormContextProvider,dt as FormError,ut as FormHelper,lt as FormLabel,nt as GeneratedForm,$e as Input,wt as JSONCode,Pt as JSONDisplay,Bt as JSONEditor,Ht as JSONSwitcher,Gt as JSONTable,Ot as JSONView,St as ManageObjectEntry,xt as ManagedListProperty,vt as ManagedObject,U as ManagedObjectBase,yt as ManagedObjectProperty,bt as ManagedProperty,Ct as ManagedScalarEntry,ui as ManagedSchema,Jn as MarkdownFigure,Xn as MarkdownImage,Qn as MarkdownLink,zr as MarkdownRenderer,Bn as MermaidCodeBlockHandler,Mn as MermaidDiagram,zt as MonacoEditor,H as Node,Br as Progress,Vr as PropertiesView,Jr as PropertyEditor,Yr as PropertyNameEditor,pt as PropertySchema,$r as PropertyViewer,at as ScalarField,V as Schema,bi as SchemaEditor,di as SchemaNode,Hr as SvgIcon,Q as UploadResultCategory,Ai as UploadSummary,Rt as VEditorApi,ra as XMLViewer,gt as computeTitleFromName,Wn as createDefaultCodeBlockHandlers,Ur as createSvgIcon,Wr as getEditableSchemaProperty,Vt as getJSONEditorValue,Un as isExpandLanguage,Fn as isIncompleteJson,Kn as mapSchemeToRoute,X as parseUrlScheme,Dt as renderJsonLine,Pn as useArtifactContent,On as useCodeBlockComponent,q as useCodeBlockContext,Dn as useCodeBlockRendererRegistry,Ye as useFieldSet,B as useForm,qn as useResolvedUrl,fi as useSchema,wi as validatePropertyName};
9
+ //# sourceMappingURL=vertesia-ui-widgets.js.map