base-screen 0.3.0 → 0.4.2

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 (424) hide show
  1. package/README.md +5 -2
  2. package/dist/_internal/contracts/diagnostics/material-error.d.ts +1 -1
  3. package/dist/_internal/contracts/diagnostics/material-error.js +1 -1
  4. package/dist/_internal/contracts/document/blueprint-graph.d.ts +3 -3
  5. package/dist/_internal/contracts/document/blueprint-graph.js +4 -4
  6. package/dist/_internal/contracts/document/component-states.d.ts +1 -1
  7. package/dist/_internal/contracts/document/component-states.js +1 -1
  8. package/dist/_internal/contracts/document/image-url.js +1 -1
  9. package/dist/_internal/contracts/document/json-schema.js +1 -1
  10. package/dist/_internal/contracts/document/limits.d.ts +5 -5
  11. package/dist/_internal/contracts/document/limits.js +5 -5
  12. package/dist/_internal/contracts/document/references.js +3 -3
  13. package/dist/_internal/contracts/document/schema.d.ts +9 -2
  14. package/dist/_internal/contracts/document/schema.js +4 -4
  15. package/dist/_internal/contracts/document/sub-canvas.d.ts +2 -2
  16. package/dist/_internal/contracts/document/sub-canvas.js +2 -2
  17. package/dist/_internal/contracts/document/theme.d.ts +2 -2
  18. package/dist/_internal/contracts/document/theme.js +2 -2
  19. package/dist/_internal/contracts/document/validate-blueprint.d.ts +1 -1
  20. package/dist/_internal/contracts/document/validate-blueprint.js +1 -1
  21. package/dist/_internal/contracts/document/validate-component.js +2 -2
  22. package/dist/_internal/contracts/document/validate-data-source.js +2 -2
  23. package/dist/_internal/contracts/document/validate-sub-canvas.d.ts +1 -1
  24. package/dist/_internal/contracts/document/validate-sub-canvas.js +1 -1
  25. package/dist/_internal/contracts/document/validate-value-ref.js +6 -1
  26. package/dist/_internal/contracts/index.d.ts +1 -1
  27. package/dist/_internal/contracts/migration/blueprint-graph-migration.d.ts +1 -1
  28. package/dist/_internal/contracts/migration/migrate-document.js +2 -2
  29. package/dist/_internal/contracts/push/delivery.d.ts +1 -1
  30. package/dist/_internal/contracts/push/delivery.js +1 -1
  31. package/dist/_internal/contracts/push/level-scale.d.ts +1 -1
  32. package/dist/_internal/contracts/push/level-scale.js +1 -1
  33. package/dist/_internal/contracts/screen-document.schema.json +15 -3
  34. package/dist/_internal/contracts/types/diagnostics.d.ts +1 -1
  35. package/dist/_internal/contracts/types/document.d.ts +21 -19
  36. package/dist/_internal/contracts/types/execution.d.ts +3 -3
  37. package/dist/_internal/contracts/types/host.d.ts +23 -5
  38. package/dist/_internal/contracts/types/host.js +1 -1
  39. package/dist/_internal/contracts/types/push.d.ts +3 -3
  40. package/dist/_internal/contracts/types/variable.d.ts +3 -3
  41. package/dist/_internal/contracts/variable/parse.js +5 -1
  42. package/dist/_internal/core/blueprint/runtime-compile.d.ts +1 -1
  43. package/dist/_internal/core/blueprint/runtime-compile.js +1 -1
  44. package/dist/_internal/core/blueprint/runtime-dispatch.js +1 -1
  45. package/dist/_internal/core/blueprint/runtime-simulate.d.ts +57 -0
  46. package/dist/_internal/core/blueprint/runtime-simulate.js +177 -0
  47. package/dist/_internal/core/blueprint/runtime-types.d.ts +4 -4
  48. package/dist/_internal/core/blueprint/runtime.d.ts +1 -0
  49. package/dist/_internal/core/blueprint/runtime.js +1 -0
  50. package/dist/_internal/core/commands/apply-collection-commands.d.ts +32 -0
  51. package/dist/_internal/core/commands/apply-collection-commands.js +174 -0
  52. package/dist/_internal/core/commands/apply-component-commands.d.ts +1 -1
  53. package/dist/_internal/core/commands/apply-component-commands.js +2 -2
  54. package/dist/_internal/core/commands/apply.js +15 -2
  55. package/dist/_internal/core/commands/parse-command.js +12 -0
  56. package/dist/_internal/core/commands/types.d.ts +33 -5
  57. package/dist/_internal/core/data/data-candidates.d.ts +38 -0
  58. package/dist/_internal/core/data/data-candidates.js +186 -0
  59. package/dist/_internal/core/data/data-source-dependents.d.ts +1 -1
  60. package/dist/_internal/core/data/data-source-dependents.js +1 -1
  61. package/dist/_internal/core/data/dataset-profile.d.ts +71 -0
  62. package/dist/_internal/core/data/dataset-profile.js +170 -0
  63. package/dist/_internal/core/data/host-dataset.d.ts +2 -2
  64. package/dist/_internal/core/data/host-dataset.js +2 -2
  65. package/dist/_internal/core/data/sample-values.d.ts +25 -0
  66. package/dist/_internal/core/data/sample-values.js +45 -0
  67. package/dist/_internal/core/data/value-ref.d.ts +2 -2
  68. package/dist/_internal/core/data/value-ref.js +1 -1
  69. package/dist/_internal/core/diff/screen-diff.js +6 -0
  70. package/dist/_internal/core/index.d.ts +7 -1
  71. package/dist/_internal/core/index.js +7 -1
  72. package/dist/_internal/core/state/state-preset.d.ts +32 -0
  73. package/dist/_internal/core/state/state-preset.js +37 -0
  74. package/dist/_internal/core/validation/layout-audit.d.ts +17 -0
  75. package/dist/_internal/core/validation/layout-audit.js +228 -0
  76. package/dist/_internal/core/validation/legibility.d.ts +9 -0
  77. package/dist/_internal/core/validation/legibility.js +33 -0
  78. package/dist/_internal/core/validation/validate-semantics.js +1 -1
  79. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-canvas-bridge.d.ts +1 -1
  80. package/dist/_internal/engine/browser/controllers/dataset/designer-data-source-authoring.d.ts +1 -1
  81. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-catalog-controller.d.ts +21 -0
  82. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-controller-context.d.ts +7 -2
  83. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-draft-controller.d.ts +7 -2
  84. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-effective-value.d.ts +1 -1
  85. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-surface-controller.d.ts +1 -1
  86. package/dist/_internal/engine/browser/controllers/dataset/designer-update-policy-authoring.d.ts +1 -1
  87. package/dist/_internal/engine/browser/controllers/designer-artboard-controller.d.ts +1 -1
  88. package/dist/_internal/engine/browser/controllers/designer-canvas-runtime-controller.d.ts +2 -2
  89. package/dist/_internal/engine/browser/controllers/designer-change-controller.d.ts +27 -0
  90. package/dist/_internal/engine/browser/controllers/designer-command-palette-controller.d.ts +1 -1
  91. package/dist/_internal/engine/browser/controllers/designer-intent-controller.d.ts +5 -0
  92. package/dist/_internal/engine/browser/controllers/designer-page-preview-controller.d.ts +1 -1
  93. package/dist/_internal/engine/browser/controllers/designer-popup-preview-controller.d.ts +1 -1
  94. package/dist/_internal/engine/browser/controllers/designer-reference-layer-controller.d.ts +1 -1
  95. package/dist/_internal/engine/browser/controllers/designer-text-edit-controller.d.ts +2 -2
  96. package/dist/_internal/engine/browser/controllers/designer-viewport-controller.d.ts +7 -1
  97. package/dist/_internal/engine/browser/controllers/gesture/designer-drag-gesture.d.ts +6 -1
  98. package/dist/_internal/engine/browser/controllers/gesture/designer-gesture-callbacks.d.ts +1 -1
  99. package/dist/_internal/engine/browser/controllers/panel/designer-component-states-controller.d.ts +1 -1
  100. package/dist/_internal/engine/browser/controllers/panel/designer-panel-controller-callbacks.d.ts +6 -6
  101. package/dist/_internal/engine/browser/controllers/panel/designer-panel-property-controller.d.ts +7 -0
  102. package/dist/_internal/engine/browser/controllers/variables/designer-variable-catalog-controller.d.ts +9 -1
  103. package/dist/_internal/engine/browser/controllers/variables/designer-variable-editor-controller.d.ts +6 -1
  104. package/dist/_internal/engine/browser/controllers/variables/designer-variables-controller.d.ts +16 -1
  105. package/dist/_internal/engine/browser/controllers/workbench/designer-workbench-controller.d.ts +2 -0
  106. package/dist/_internal/engine/browser/controllers/workbench/designer-workbench-tabs-controller.d.ts +2 -0
  107. package/dist/_internal/engine/browser/dom/blueprint/designer-blueprint-inspector-configuration.d.ts +1 -1
  108. package/dist/_internal/engine/browser/dom/change/designer-change-dom.d.ts +21 -5
  109. package/dist/_internal/engine/browser/dom/color/designer-color-palette-model.d.ts +3 -3
  110. package/dist/_internal/engine/browser/dom/color/designer-color-palette-types.d.ts +2 -2
  111. package/dist/_internal/engine/browser/dom/color/designer-color-theme-slots.d.ts +1 -1
  112. package/dist/_internal/engine/browser/dom/dataset/designer-data-group-dom.d.ts +1 -1
  113. package/dist/_internal/engine/browser/dom/dataset/designer-data-panel-notice.d.ts +1 -1
  114. package/dist/_internal/engine/browser/dom/dataset/designer-data-section-diff.d.ts +4 -6
  115. package/dist/_internal/engine/browser/dom/dataset/designer-data-state.d.ts +1 -1
  116. package/dist/_internal/engine/browser/dom/dataset/designer-dataset-authoring-dom.d.ts +1 -1
  117. package/dist/_internal/engine/browser/dom/dataset/designer-dataset-catalog-dom.d.ts +1 -1
  118. package/dist/_internal/engine/browser/dom/dataset/designer-dataset-sections.d.ts +1 -1
  119. package/dist/_internal/engine/browser/dom/dataset/designer-dataset-types.d.ts +11 -4
  120. package/dist/_internal/engine/browser/dom/descriptor/designer-descriptor-control-dom.d.ts +1 -1
  121. package/dist/_internal/engine/browser/dom/descriptor/designer-descriptor-model.d.ts +1 -1
  122. package/dist/_internal/engine/browser/dom/designer-field-primitives.d.ts +1 -1
  123. package/dist/_internal/engine/browser/dom/designer-icons.d.ts +2 -0
  124. package/dist/_internal/engine/browser/dom/designer-text-edit-dom.d.ts +2 -2
  125. package/dist/_internal/engine/browser/dom/designer-variable-inspector-dom.d.ts +7 -0
  126. package/dist/_internal/engine/browser/dom/designer-variables-dom.d.ts +5 -1
  127. package/dist/_internal/engine/browser/dom/designer-variables-editor-dom.d.ts +30 -1
  128. package/dist/_internal/engine/browser/dom/designer-variables-toolbar-dom.d.ts +4 -2
  129. package/dist/_internal/engine/browser/dom/intent/designer-intent-reference-picker-dom.d.ts +2 -0
  130. package/dist/_internal/engine/browser/dom/material-library/designer-material-library-dom.d.ts +1 -1
  131. package/dist/_internal/engine/browser/dom/menu/designer-menu-model.d.ts +3 -3
  132. package/dist/_internal/engine/browser/dom/menu/designer-plugin-command-menu.d.ts +5 -2
  133. package/dist/_internal/engine/browser/dom/panel/designer-canvas-transactions.d.ts +1 -1
  134. package/dist/_internal/engine/browser/dom/panel/designer-component-states-dom.d.ts +2 -2
  135. package/dist/_internal/engine/browser/dom/panel/designer-multi-selection-dom.d.ts +1 -1
  136. package/dist/_internal/engine/browser/dom/panel/designer-panel-primitives.d.ts +2 -2
  137. package/dist/_internal/engine/browser/dom/panel/designer-property-transactions.d.ts +1 -1
  138. package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-picker-dom.d.ts +1 -1
  139. package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-picker-mount.d.ts +1 -1
  140. package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-summary-dom.d.ts +1 -1
  141. package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-types.d.ts +6 -4
  142. package/dist/_internal/engine/browser/viewport/designer-canvas-aids-types.d.ts +3 -3
  143. package/dist/_internal/engine/browser/viewport/designer-canvas-aids.d.ts +5 -3
  144. package/dist/_internal/engine/browser/viewport/designer-canvas-measurements.d.ts +2 -14
  145. package/dist/_internal/engine/browser/viewport/designer-guide-overlay-nodes.d.ts +2 -0
  146. package/dist/_internal/engine/browser/viewport/designer-snap-tuning.d.ts +14 -0
  147. package/dist/_internal/engine/common/observability/designer-metrics.d.ts +1 -1
  148. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-capabilities.d.ts +1 -1
  149. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-graph.d.ts +5 -5
  150. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-model.d.ts +1 -1
  151. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-protocol-types.d.ts +2 -2
  152. package/dist/_internal/engine/common/operations/canvas/canvas-background-image.d.ts +1 -1
  153. package/dist/_internal/engine/common/operations/catalog/designer-catalog-refresh.d.ts +1 -1
  154. package/dist/_internal/engine/common/operations/change/designer-change-events.d.ts +2 -0
  155. package/dist/_internal/engine/common/operations/change/designer-change-proposal.d.ts +35 -2
  156. package/dist/_internal/engine/common/operations/designer-clipboard.d.ts +5 -1
  157. package/dist/_internal/engine/common/operations/designer-text-edit-operations.d.ts +1 -1
  158. package/dist/_internal/engine/common/operations/designer-variable-operations.d.ts +3 -3
  159. package/dist/_internal/engine/common/operations/display/designer-target-display.d.ts +2 -2
  160. package/dist/_internal/engine/common/operations/element/designer-element-operation-types.d.ts +1 -1
  161. package/dist/_internal/engine/common/operations/intent/designer-parameter-intent.d.ts +1 -1
  162. package/dist/_internal/engine/common/operations/material-component/material-component-fragment-extract.d.ts +2 -2
  163. package/dist/_internal/engine/common/operations/material-library/material-library-fragments.d.ts +1 -1
  164. package/dist/_internal/engine/common/operations/material-library/material-library-grouping.d.ts +1 -1
  165. package/dist/_internal/engine/common/operations/plugin/designer-plugin-commands.d.ts +2 -0
  166. package/dist/_internal/engine/common/operations/selection/designer-multi-selection-operations.d.ts +9 -9
  167. package/dist/_internal/engine/common/operations/style/designer-component-states.d.ts +12 -7
  168. package/dist/_internal/engine/common/operations/style/designer-material-appearance.d.ts +1 -1
  169. package/dist/_internal/engine/common/session/designer-artboard.d.ts +1 -1
  170. package/dist/_internal/engine/common/session/designer-session.d.ts +1 -1
  171. package/dist/_internal/engine/common/ui-text/designer-blueprint-ui-text.d.ts +3 -3
  172. package/dist/_internal/engine/common/ui-text/designer-ui-text.d.ts +127 -70
  173. package/dist/_internal/engine/{designer-blueprint-workbench-panel-CJ3iZo5v.js → designer-blueprint-workbench-panel-DVvKcSvJ.js} +269 -349
  174. package/dist/_internal/engine/{designer-dataset-controller-CrfOg2Ys.js → designer-dataset-controller-bSR5OB6n.js} +1512 -1348
  175. package/dist/_internal/engine/designer-element/api/designer-element-catalog.d.ts +2 -2
  176. package/dist/_internal/engine/designer-element/api/designer-element-change.d.ts +24 -0
  177. package/dist/_internal/engine/designer-element/api/designer-element-configuration-types.d.ts +4 -4
  178. package/dist/_internal/engine/designer-element/api/designer-element-fragment-save.d.ts +2 -2
  179. package/dist/_internal/engine/designer-element/api/designer-element-host-resource-selection.d.ts +1 -1
  180. package/dist/_internal/engine/designer-element/base-screen-designer-element.d.ts +21 -9
  181. package/dist/_internal/engine/designer-element/designer-element-public-api.d.ts +2 -1
  182. package/dist/_internal/engine/designer-element/runtime/designer-element-plugin-commands.d.ts +3 -3
  183. package/dist/_internal/engine/designer-element/runtime/designer-element-rendering.d.ts +3 -3
  184. package/dist/_internal/engine/designer-element/runtime/designer-element-runtime.d.ts +4 -1
  185. package/dist/_internal/engine/designer-element/runtime/designer-element-sample-data.d.ts +23 -0
  186. package/dist/_internal/engine/designer-element/runtime/designer-element-state.d.ts +7 -7
  187. package/dist/_internal/engine/{designer-field-primitives-KBZuWN_D.js → designer-field-primitives-C_StzrUa.js} +240 -180
  188. package/dist/_internal/engine/{designer-left-panel-groups-dom-N2OHOWjl.js → designer-left-panel-groups-dom-DBpI3Nc2.js} +19 -19
  189. package/dist/_internal/engine/{host-resource-selection-xo2mLCD4.js → host-resource-selection-BCRU23WQ.js} +446 -446
  190. package/dist/_internal/engine/index.js +5477 -4677
  191. package/dist/_internal/host-kit/index.d.ts +1 -0
  192. package/dist/_internal/host-kit/index.js +1 -0
  193. package/dist/_internal/host-kit/intent/index.d.ts +17 -0
  194. package/dist/_internal/host-kit/intent/index.js +14 -0
  195. package/dist/_internal/host-kit/intent/intent-behavior.d.ts +59 -0
  196. package/dist/_internal/host-kit/intent/intent-behavior.js +812 -0
  197. package/dist/_internal/host-kit/intent/intent-block.d.ts +66 -0
  198. package/dist/_internal/host-kit/intent/intent-block.js +438 -0
  199. package/dist/_internal/host-kit/intent/intent-catalog.d.ts +108 -0
  200. package/dist/_internal/host-kit/intent/intent-catalog.js +60 -0
  201. package/dist/_internal/host-kit/intent/intent-compile-types.d.ts +222 -0
  202. package/dist/_internal/host-kit/intent/intent-compile-types.js +10 -0
  203. package/dist/_internal/host-kit/intent/intent-compile.d.ts +35 -0
  204. package/dist/_internal/host-kit/intent/intent-compile.js +465 -0
  205. package/dist/_internal/host-kit/intent/intent-data-check.d.ts +50 -0
  206. package/dist/_internal/host-kit/intent/intent-data-check.js +163 -0
  207. package/dist/_internal/host-kit/intent/intent-data-context.d.ts +53 -0
  208. package/dist/_internal/host-kit/intent/intent-data-context.js +200 -0
  209. package/dist/_internal/host-kit/intent/intent-dataset.d.ts +52 -0
  210. package/dist/_internal/host-kit/intent/intent-dataset.js +125 -0
  211. package/dist/_internal/host-kit/intent/intent-format.d.ts +33 -0
  212. package/dist/_internal/host-kit/intent/intent-format.js +94 -0
  213. package/dist/_internal/host-kit/intent/intent-freeform.d.ts +48 -0
  214. package/dist/_internal/host-kit/intent/intent-freeform.js +412 -0
  215. package/dist/_internal/host-kit/intent/intent-kpi-bind.d.ts +29 -0
  216. package/dist/_internal/host-kit/intent/intent-kpi-bind.js +59 -0
  217. package/dist/_internal/host-kit/intent/intent-layout.d.ts +102 -0
  218. package/dist/_internal/host-kit/intent/intent-layout.js +264 -0
  219. package/dist/_internal/host-kit/intent/intent-parse.d.ts +41 -0
  220. package/dist/_internal/host-kit/intent/intent-parse.js +931 -0
  221. package/dist/_internal/host-kit/intent/intent-prepare.d.ts +55 -0
  222. package/dist/_internal/host-kit/intent/intent-prepare.js +156 -0
  223. package/dist/_internal/host-kit/intent/intent-session.d.ts +202 -0
  224. package/dist/_internal/host-kit/intent/intent-session.js +1001 -0
  225. package/dist/_internal/host-kit/intent/intent-stream.d.ts +28 -0
  226. package/dist/_internal/host-kit/intent/intent-stream.js +183 -0
  227. package/dist/_internal/host-kit/intent/intent-style.d.ts +37 -0
  228. package/dist/_internal/host-kit/intent/intent-style.js +77 -0
  229. package/dist/_internal/host-kit/intent/intent-types.d.ts +277 -0
  230. package/dist/_internal/host-kit/intent/intent-types.js +10 -0
  231. package/dist/_internal/host-kit/push-result.d.ts +1 -1
  232. package/dist/_internal/host-kit/push-result.js +1 -1
  233. package/dist/_internal/host-kit/sse-subscribe.d.ts +1 -1
  234. package/dist/_internal/host-kit/sse-subscribe.js +1 -1
  235. package/dist/_internal/host-kit/subscription-hub.d.ts +3 -3
  236. package/dist/_internal/host-kit/subscription-hub.js +1 -1
  237. package/dist/_internal/material/base-material.d.ts +3 -3
  238. package/dist/_internal/material/chart.js +34 -12
  239. package/dist/_internal/material/editor-descriptor.d.ts +3 -3
  240. package/dist/_internal/material/table.js +52 -21
  241. package/dist/_internal/plugin-core/contracts.d.ts +18 -16
  242. package/dist/_internal/plugin-core/contracts.js +1 -0
  243. package/dist/_internal/plugin-core/contribution-kind.d.ts +5 -5
  244. package/dist/_internal/plugin-core/contribution-kind.js +14 -6
  245. package/dist/_internal/plugin-core/editor/editor-descriptor-inference.d.ts +1 -1
  246. package/dist/_internal/plugin-core/editor/editor-descriptor-inference.js +2 -2
  247. package/dist/_internal/plugin-core/editor/editor-descriptor-items.d.ts +1 -1
  248. package/dist/_internal/plugin-core/editor/editor-descriptor-items.js +1 -1
  249. package/dist/_internal/plugin-core/editor/editor-descriptor-model.d.ts +2 -2
  250. package/dist/_internal/plugin-core/editor/editor-descriptor.js +1 -1
  251. package/dist/_internal/plugin-core/fragment/fragment.d.ts +4 -4
  252. package/dist/_internal/plugin-core/fragment/fragment.js +1 -1
  253. package/dist/_internal/plugin-core/material/material-manifest-fields.js +1 -1
  254. package/dist/_internal/plugin-core/material/material-manifest.js +1 -1
  255. package/dist/_internal/plugin-core/material/material-theme.d.ts +2 -2
  256. package/dist/_internal/plugin-core/material/material-theme.js +2 -2
  257. package/dist/_internal/plugin-manager/contribution-kind-plan.d.ts +5 -1
  258. package/dist/_internal/plugin-manager/contribution-kind-plan.js +20 -12
  259. package/dist/_internal/plugin-manager/manager.js +47 -30
  260. package/dist/_internal/plugin-manager/resolver.js +7 -13
  261. package/dist/_internal/plugin-manager/types.d.ts +2 -2
  262. package/dist/_internal/plugin-sdk/authoring-finding.d.ts +3 -3
  263. package/dist/_internal/plugin-sdk/fragment-audit.d.ts +6 -6
  264. package/dist/_internal/plugin-sdk/fragment-audit.js +8 -8
  265. package/dist/_internal/plugin-sdk/fragment-definition.d.ts +3 -3
  266. package/dist/_internal/plugin-sdk/fragment-definition.js +3 -3
  267. package/dist/_internal/plugin-sdk/index.d.ts +6 -0
  268. package/dist/_internal/plugin-sdk/index.js +6 -0
  269. package/dist/_internal/plugin-sdk/material-config-groups.d.ts +2 -2
  270. package/dist/_internal/plugin-sdk/material-definition.d.ts +5 -1
  271. package/dist/_internal/plugin-sdk/material-definition.js +3 -3
  272. package/dist/_internal/plugin-sdk/material-editor-audit.d.ts +9 -8
  273. package/dist/_internal/plugin-sdk/material-editor-audit.js +19 -11
  274. package/dist/_internal/plugin-sdk/material-isolated-csp.d.ts +38 -0
  275. package/dist/_internal/plugin-sdk/material-isolated-csp.js +67 -0
  276. package/dist/_internal/plugin-sdk/material-isolated-runtime.d.ts +22 -0
  277. package/dist/_internal/plugin-sdk/material-isolated-runtime.js +262 -0
  278. package/dist/_internal/plugin-sdk/material-isolated.d.ts +94 -0
  279. package/dist/_internal/plugin-sdk/material-isolated.js +1044 -0
  280. package/dist/_internal/plugin-sdk/material-package.d.ts +3 -3
  281. package/dist/_internal/plugin-sdk/material-package.js +7 -7
  282. package/dist/_internal/plugin-sdk/material-rendered-element.d.ts +22 -7
  283. package/dist/_internal/plugin-sdk/material-rendered-element.js +103 -10
  284. package/dist/_internal/plugin-sdk/material-spec-audit.d.ts +20 -10
  285. package/dist/_internal/plugin-sdk/material-spec-audit.js +108 -22
  286. package/dist/_internal/plugin-sdk/material-spec.d.ts +81 -16
  287. package/dist/_internal/plugin-sdk/material-spec.js +241 -42
  288. package/dist/_internal/plugin-sdk/material-style-keys.d.ts +6 -6
  289. package/dist/_internal/plugin-sdk/material-style-keys.js +7 -7
  290. package/dist/_internal/plugin-sdk/material-template-audit.d.ts +12 -0
  291. package/dist/_internal/plugin-sdk/material-template-audit.js +302 -0
  292. package/dist/_internal/plugin-sdk/material-template-expression.d.ts +98 -0
  293. package/dist/_internal/plugin-sdk/material-template-expression.js +549 -0
  294. package/dist/_internal/plugin-sdk/material-template-render.d.ts +32 -0
  295. package/dist/_internal/plugin-sdk/material-template-render.js +579 -0
  296. package/dist/_internal/plugin-sdk/material-template.d.ts +185 -0
  297. package/dist/_internal/plugin-sdk/material-template.js +879 -0
  298. package/dist/_internal/plugin-sdk/plugin-package.d.ts +2 -2
  299. package/dist/_internal/plugin-sdk/plugin-package.js +3 -3
  300. package/dist/_internal/plugin-sdk/plugin-registration.d.ts +2 -5
  301. package/dist/_internal/plugin-sdk/plugin-registration.js +3 -3
  302. package/dist/_internal/renderer/renderer/renderer-candidates.d.ts +1 -1
  303. package/dist/_internal/renderer/renderer/renderer-component-states.d.ts +1 -1
  304. package/dist/_internal/renderer/renderer/renderer-effective-style.d.ts +1 -1
  305. package/dist/_internal/renderer/renderer/renderer-material-dom.d.ts +1 -1
  306. package/dist/_internal/renderer/renderer/renderer-state.d.ts +2 -2
  307. package/dist/_internal/renderer/renderer/renderer-theme.d.ts +1 -1
  308. package/dist/_internal/renderer/renderer/renderer-types.d.ts +1 -1
  309. package/dist/_internal/renderer/renderer/renderer.d.ts +5 -5
  310. package/dist/_internal/renderer/resource/data-source-runtime.d.ts +3 -3
  311. package/dist/_internal/renderer/resource/push-window.d.ts +1 -1
  312. package/dist/_internal/renderer/resource/request-coordinator.d.ts +1 -1
  313. package/dist/_internal/renderer/resource/source-query-port.d.ts +3 -3
  314. package/dist/_internal/renderer/sub-canvas-layer.d.ts +2 -2
  315. package/dist/_internal/renderer/viewer/viewer-configuration.d.ts +1 -1
  316. package/dist/_internal/renderer/viewer/viewer.d.ts +3 -3
  317. package/dist/auto-register.js +10 -10
  318. package/dist/contracts.js +5 -5
  319. package/dist/contracts.js.map +1 -1
  320. package/dist/contrast-DRPezUIl.js +131 -0
  321. package/dist/contrast-DRPezUIl.js.map +1 -0
  322. package/dist/core.js +156 -136
  323. package/dist/core.js.map +1 -1
  324. package/dist/dataset-port-D993nOlT.js.map +1 -1
  325. package/dist/dataset-profile-Dk6xdtsM.js +261 -0
  326. package/dist/dataset-profile-Dk6xdtsM.js.map +1 -0
  327. package/dist/{designer-3Tb0EIDV.js → designer-DzBm8tXS.js} +2 -2
  328. package/dist/{designer-3Tb0EIDV.js.map → designer-DzBm8tXS.js.map} +1 -1
  329. package/dist/designer-auto-register.js +5 -5
  330. package/dist/{designer-blueprint-workbench-panel-CJ3iZo5v-BebifP4x.js → designer-blueprint-workbench-panel-DVvKcSvJ-CkRMBKZA.js} +452 -531
  331. package/dist/designer-blueprint-workbench-panel-DVvKcSvJ-CkRMBKZA.js.map +1 -0
  332. package/dist/{designer-dataset-controller-CrfOg2Ys-DhKUEJJe.js → designer-dataset-controller-bSR5OB6n-DfUP24S6.js} +1355 -1191
  333. package/dist/designer-dataset-controller-bSR5OB6n-DfUP24S6.js.map +1 -0
  334. package/dist/{designer-field-primitives-KBZuWN_D-B3h4jpYe.js → designer-field-primitives-C_StzrUa-QZpcn0yX.js} +241 -181
  335. package/dist/designer-field-primitives-C_StzrUa-QZpcn0yX.js.map +1 -0
  336. package/dist/{designer-left-panel-groups-dom-N2OHOWjl-D8CzGwbF.js → designer-left-panel-groups-dom-DBpI3Nc2-D8kYJLCg.js} +18 -18
  337. package/dist/{designer-left-panel-groups-dom-N2OHOWjl-D8CzGwbF.js.map → designer-left-panel-groups-dom-DBpI3Nc2-D8kYJLCg.js.map} +1 -1
  338. package/dist/designer.js +5 -5
  339. package/dist/{dist-6GRboBs-.js → dist-B2bW2Tru.js} +4 -4
  340. package/dist/{dist-6GRboBs-.js.map → dist-B2bW2Tru.js.map} +1 -1
  341. package/dist/{dist-BjLjFUy1.js → dist-YCmniYuO.js} +5636 -4838
  342. package/dist/dist-YCmniYuO.js.map +1 -0
  343. package/dist/engine.js +5 -5
  344. package/dist/{fragment-Y6YnW6wy.js → fragment-B-oP0Fru.js} +3 -3
  345. package/dist/fragment-B-oP0Fru.js.map +1 -0
  346. package/dist/host-kit.js +4388 -187
  347. package/dist/host-kit.js.map +1 -1
  348. package/dist/{host-resource-selection-xo2mLCD4-BR5XCcim.js → host-resource-selection-BCRU23WQ-Cedz0d14.js} +208 -208
  349. package/dist/host-resource-selection-BCRU23WQ-Cedz0d14.js.map +1 -0
  350. package/dist/image-url-D6mUcjY1.js.map +1 -1
  351. package/dist/index.js +10 -10
  352. package/dist/legibility-CS28ivEz.js +12 -0
  353. package/dist/legibility-CS28ivEz.js.map +1 -0
  354. package/dist/{level-scale-BzUjE31V.js → level-scale-CwHqFEVd.js} +2 -2
  355. package/dist/level-scale-CwHqFEVd.js.map +1 -0
  356. package/dist/{manager-Ch0RTu_i.js → manager-BcvdcZjM.js} +230 -210
  357. package/dist/manager-BcvdcZjM.js.map +1 -0
  358. package/dist/{material-UbSfiuZq.js → material-ReRzBIbb.js} +2 -2
  359. package/dist/{material-UbSfiuZq.js.map → material-ReRzBIbb.js.map} +1 -1
  360. package/dist/material-auto-register.js +1 -1
  361. package/dist/{material-definition-BeW34dJr.js → material-definition-BcjFM-B-.js} +9 -9
  362. package/dist/material-definition-BcjFM-B-.js.map +1 -0
  363. package/dist/material-manifest-B1XatGPx.js.map +1 -1
  364. package/dist/material-theme-C91eus78.js.map +1 -1
  365. package/dist/material.js +2 -2
  366. package/dist/{migrate-document-D3HhCVlZ.js → migrate-document-BM888PtC.js} +2 -2
  367. package/dist/migrate-document-BM888PtC.js.map +1 -0
  368. package/dist/{parse-B1OD1teS.js → parse-1U_-Qtn4.js} +4 -4
  369. package/dist/parse-1U_-Qtn4.js.map +1 -0
  370. package/dist/{parse-AOTE9WnD.js → parse-Ji7kE9ZT.js} +9 -4
  371. package/dist/parse-Ji7kE9ZT.js.map +1 -0
  372. package/dist/{parse-parts-BNrpdG5o.js → parse-parts-qzl4suzk.js} +2 -2
  373. package/dist/{parse-parts-BNrpdG5o.js.map → parse-parts-qzl4suzk.js.map} +1 -1
  374. package/dist/{plugin-DHgh9uHh.js → plugin-BH-4oNvT.js} +63 -55
  375. package/dist/plugin-BH-4oNvT.js.map +1 -0
  376. package/dist/plugin-core.js +2 -2
  377. package/dist/plugin-manager.js +1 -1
  378. package/dist/plugin-package-Cj-3iLv3.js +4369 -0
  379. package/dist/plugin-package-Cj-3iLv3.js.map +1 -0
  380. package/dist/{plugin-registration-rsmb4GvS.js → plugin-registration-C9_IxTxc.js} +9 -9
  381. package/dist/{plugin-registration-rsmb4GvS.js.map → plugin-registration-C9_IxTxc.js.map} +1 -1
  382. package/dist/plugin-sdk.js +6 -6
  383. package/dist/{plugins-DGRHgREK.js → plugins-CwATlfr0.js} +2 -2
  384. package/dist/{plugins-DGRHgREK.js.map → plugins-CwATlfr0.js.map} +1 -1
  385. package/dist/plugins.js +8 -8
  386. package/dist/renderer.js +1 -1
  387. package/dist/{runtime-dispatch-BfnRDtMe.js → runtime-dispatch-C0gyIrTv.js} +2 -2
  388. package/dist/runtime-dispatch-C0gyIrTv.js.map +1 -0
  389. package/dist/runtime-simulate-aSYO9yDX.js +147 -0
  390. package/dist/runtime-simulate-aSYO9yDX.js.map +1 -0
  391. package/dist/{src-Bm7u11mN-_0u6cMEw.js → src-Bm7u11mN-DFLnFQSk.js} +39 -39
  392. package/dist/{src-Bm7u11mN-_0u6cMEw.js.map → src-Bm7u11mN-DFLnFQSk.js.map} +1 -1
  393. package/dist/state-preset-DtpygJOH.js +22 -0
  394. package/dist/state-preset-DtpygJOH.js.map +1 -0
  395. package/dist/{text-BNksUr5J.js → text-DfKom8EG.js} +88 -35
  396. package/dist/text-DfKom8EG.js.map +1 -0
  397. package/dist/theme-CcBXf4Ay.js.map +1 -1
  398. package/dist/{value-ref-BG_MV9C-.js → value-ref-XkLuckGV.js} +2 -2
  399. package/dist/{value-ref-BG_MV9C-.js.map → value-ref-XkLuckGV.js.map} +1 -1
  400. package/dist/{viewer-CrJupI8I-D9dVcNw4.js → viewer-CrJupI8I-CeQS58mA.js} +5 -5
  401. package/dist/{viewer-CrJupI8I-D9dVcNw4.js.map → viewer-CrJupI8I-CeQS58mA.js.map} +1 -1
  402. package/dist/viewer-auto-register.js +2 -2
  403. package/dist/viewer.js +2 -2
  404. package/dist/{viewport-CiCKeAQH.js → viewport-BNIRWjiT.js} +354 -155
  405. package/dist/viewport-BNIRWjiT.js.map +1 -0
  406. package/package.json +12 -12
  407. package/dist/designer-blueprint-workbench-panel-CJ3iZo5v-BebifP4x.js.map +0 -1
  408. package/dist/designer-dataset-controller-CrfOg2Ys-DhKUEJJe.js.map +0 -1
  409. package/dist/designer-field-primitives-KBZuWN_D-B3h4jpYe.js.map +0 -1
  410. package/dist/dist-BjLjFUy1.js.map +0 -1
  411. package/dist/fragment-Y6YnW6wy.js.map +0 -1
  412. package/dist/host-resource-selection-xo2mLCD4-BR5XCcim.js.map +0 -1
  413. package/dist/level-scale-BzUjE31V.js.map +0 -1
  414. package/dist/manager-Ch0RTu_i.js.map +0 -1
  415. package/dist/material-definition-BeW34dJr.js.map +0 -1
  416. package/dist/migrate-document-D3HhCVlZ.js.map +0 -1
  417. package/dist/parse-AOTE9WnD.js.map +0 -1
  418. package/dist/parse-B1OD1teS.js.map +0 -1
  419. package/dist/plugin-DHgh9uHh.js.map +0 -1
  420. package/dist/plugin-package-Dr5ro6h6.js +0 -1221
  421. package/dist/plugin-package-Dr5ro6h6.js.map +0 -1
  422. package/dist/runtime-dispatch-BfnRDtMe.js.map +0 -1
  423. package/dist/text-BNksUr5J.js.map +0 -1
  424. package/dist/viewport-CiCKeAQH.js.map +0 -1
package/dist/host-kit.js CHANGED
@@ -1,17 +1,23 @@
1
1
  import { t as e } from "./parse-B5b0hjql.js";
2
2
  import { i as t, n, r } from "./definition-DlTP-401.js";
3
- import { r as i } from "./parse-AOTE9WnD.js";
4
- import { t as a } from "./migrate-document-D3HhCVlZ.js";
3
+ import { At as i, r as a } from "./parse-Ji7kE9ZT.js";
4
+ import { d as o } from "./theme-CcBXf4Ay.js";
5
+ import { t as s } from "./migrate-document-BM888PtC.js";
6
+ import { n as c } from "./runtime-simulate-aSYO9yDX.js";
7
+ import { o as l, r as u } from "./dataset-profile-Dk6xdtsM.js";
8
+ import { t as d } from "./state-preset-DtpygJOH.js";
9
+ import { o as f } from "./contrast-DRPezUIl.js";
10
+ import { n as p } from "./legibility-CS28ivEz.js";
5
11
  //#region ../host-kit/dist/http.js
6
- var o = {
12
+ var m = {
7
13
  code: "NETWORK",
8
14
  message: "网络请求失败,请确认后端服务已启动。",
9
15
  status: 0
10
16
  };
11
- function s(e) {
17
+ function h(e) {
12
18
  let t = e.fetch ?? fetch, n = e.baseUrl.replace(/\/+$/, "");
13
19
  return { async request(e, r = {}) {
14
- let { method: i = "GET", body: a, signal: s } = r;
20
+ let { method: i = "GET", body: a, signal: o } = r;
15
21
  try {
16
22
  let r = await t(`${n}${e}`, {
17
23
  method: i,
@@ -20,14 +26,14 @@ function s(e) {
20
26
  ...a === void 0 ? {} : { "Content-Type": "application/json" }
21
27
  },
22
28
  ...a === void 0 ? {} : { body: JSON.stringify(a) },
23
- ...s === void 0 ? {} : { signal: s }
24
- }), o = await r.json().catch(() => null);
29
+ ...o === void 0 ? {} : { signal: o }
30
+ }), s = await r.json().catch(() => null);
25
31
  return r.ok ? {
26
32
  ok: !0,
27
- data: o
33
+ data: s
28
34
  } : {
29
35
  ok: !1,
30
- error: c(o, r.status)
36
+ error: g(s, r.status)
31
37
  };
32
38
  } catch (e) {
33
39
  return e instanceof DOMException && e.name === "AbortError" ? {
@@ -39,12 +45,12 @@ function s(e) {
39
45
  }
40
46
  } : {
41
47
  ok: !1,
42
- error: o
48
+ error: m
43
49
  };
44
50
  }
45
51
  } };
46
52
  }
47
- function c(e, t) {
53
+ function g(e, t) {
48
54
  if (typeof e == "object" && e) {
49
55
  let n = e;
50
56
  if (typeof n.error == "string" && typeof n.message == "string") return {
@@ -59,182 +65,4377 @@ function c(e, t) {
59
65
  status: t
60
66
  };
61
67
  }
62
- function l(e) {
68
+ function _(e) {
63
69
  let t = new URLSearchParams();
64
70
  for (let [n, r] of Object.entries(e)) r !== void 0 && r !== "" && t.set(n, String(r));
65
71
  let n = t.toString();
66
72
  return n === "" ? "" : `?${n}`;
67
73
  }
68
- function u(e) {
74
+ function v(e) {
69
75
  if (e === void 0) return;
70
76
  let t = new AbortController();
71
77
  return e.aborted ? (t.abort(), t.signal) : (e.addEventListener("abort", () => t.abort(), { once: !0 }), t.signal);
72
78
  }
73
79
  //#endregion
74
80
  //#region ../host-kit/dist/operation.js
75
- async function d(e, t, n, r) {
81
+ async function y(e, t, n, r) {
76
82
  try {
77
- let i = u(n);
83
+ let i = v(n);
78
84
  if (i === void 0) throw Error("缺少取消信号。");
79
85
  return await e.execute(t, i, r);
80
86
  } catch (e) {
81
87
  return {
82
- ok: !1,
83
- error: {
84
- code: n.aborted || typeof e == "object" && e && "name" in e && e.name === "AbortError" ? "ABORTED" : "NETWORK",
85
- message: "宿主业务请求失败。"
86
- }
88
+ ok: !1,
89
+ error: {
90
+ code: n.aborted || typeof e == "object" && e && "name" in e && e.name === "AbortError" ? "ABORTED" : "NETWORK",
91
+ message: "宿主业务请求失败。"
92
+ }
93
+ };
94
+ }
95
+ }
96
+ function b(e, t, n, r) {
97
+ if (e !== void 0) try {
98
+ let i = { ...t };
99
+ Reflect.deleteProperty(i, "signal");
100
+ let a = e({
101
+ request: structuredClone(i),
102
+ result: structuredClone(n),
103
+ ...r === void 0 ? {} : { error: structuredClone(r) }
104
+ });
105
+ Promise.resolve(a).catch(() => {});
106
+ } catch {}
107
+ }
108
+ function x(e, t, n, r = (e) => e) {
109
+ return {
110
+ async execute(r, i) {
111
+ let a;
112
+ try {
113
+ a = t?.request?.(r) ?? n(r);
114
+ } catch {
115
+ return {
116
+ ok: !1,
117
+ error: {
118
+ code: "HOST_KIT_MAPPING",
119
+ message: "宿主请求映射失败。"
120
+ }
121
+ };
122
+ }
123
+ return i.aborted ? {
124
+ ok: !1,
125
+ error: {
126
+ code: "ABORTED",
127
+ message: "请求已取消。"
128
+ }
129
+ } : e.request(a.path, {
130
+ ...a,
131
+ signal: i
132
+ });
133
+ },
134
+ response: (e, n) => t?.response ? t.response(e, n) : r(e)
135
+ };
136
+ }
137
+ //#endregion
138
+ //#region ../host-kit/dist/dataset-port.js
139
+ var S = 6e4;
140
+ function C(i) {
141
+ let a;
142
+ async function o(e, t, n, r, i, a) {
143
+ if (n.aborted) return O();
144
+ let o = await y(e, t, n, a);
145
+ if (n.aborted || !o.ok && o.error.code === "ABORTED") return O();
146
+ let s;
147
+ if (!o.ok) s = D(E(o.error), o.error.message);
148
+ else try {
149
+ let n = r(e.response ? e.response(o.data, t) : o.data);
150
+ s = n.ok ? n : D("HOST_DATASET_INVALID", "数据集响应格式无效。");
151
+ } catch {
152
+ s = D("HOST_DATASET_INVALID", "数据集响应格式无效。");
153
+ }
154
+ return n.aborted ? O() : (b(i, t, s, o.ok ? void 0 : o.error), s);
155
+ }
156
+ let s = i.groups;
157
+ return {
158
+ queryScope: "dataset",
159
+ ...s === void 0 ? {} : { async groups(e) {
160
+ if (e.signal.aborted) return O();
161
+ let n = a;
162
+ if (n !== void 0 && Date.now() - n.at < S) return {
163
+ ok: !0,
164
+ value: n.value,
165
+ diagnostics: []
166
+ };
167
+ let r = await o(s, e, e.signal, t);
168
+ return r.ok && (a = {
169
+ at: Date.now(),
170
+ value: r.value
171
+ }), r;
172
+ } },
173
+ list: (e) => o(i.list, e, e.signal, r, i.onListResult),
174
+ describe: (e) => o(i.describe, e, e.signal, n, i.onDescribeResult),
175
+ query: (t, n) => o(i.query, t, n.signal, e, i.onQueryResult, n.context)
176
+ };
177
+ }
178
+ function w(e) {
179
+ let t = h(e);
180
+ return C({
181
+ groups: x(t, e.mapping?.groups, () => ({ path: `/datasets${_({ limit: 1 })}` }), (e) => {
182
+ if (!(typeof e != "object" || !e || Array.isArray(e))) return "groups" in e ? e.groups : [];
183
+ }),
184
+ list: x(t, e.mapping?.list, (e) => ({ path: `/datasets${_({
185
+ query: e.query,
186
+ limit: e.limit,
187
+ groupId: e.groupId,
188
+ cursor: e.cursor
189
+ })}` }), (e) => {
190
+ if (!(typeof e != "object" || !e || !("items" in e))) return {
191
+ items: e.items,
192
+ ..."nextCursor" in e ? { nextCursor: e.nextCursor } : {}
193
+ };
194
+ }),
195
+ describe: x(t, e.mapping?.describe, (e) => ({ path: `/datasets/${encodeURIComponent(e.datasetId)}` })),
196
+ query: x(t, e.mapping?.query, (e) => ({ path: `/datasets/${encodeURIComponent(e.datasetId)}/query${_(T(e.params))}` }))
197
+ });
198
+ }
199
+ function T(e) {
200
+ let t = {};
201
+ for (let [n, r] of Object.entries(e)) (typeof r == "string" || typeof r == "number" || typeof r == "boolean") && (t[n] = r);
202
+ return t;
203
+ }
204
+ function E(e) {
205
+ return e.code === "HOST_KIT_MAPPING" ? "HOST_DATASET_INVALID" : e.code === "UNKNOWN_DATASET" || e.status === 404 ? "HOST_DATASET_UNAVAILABLE" : e.status === 400 || e.status === 422 ? "HOST_DATASET_PARAMETER_INVALID" : "HOST_DATASET_UNAVAILABLE";
206
+ }
207
+ function D(e, t) {
208
+ return {
209
+ ok: !1,
210
+ diagnostics: [{
211
+ severity: "error",
212
+ code: e,
213
+ path: [],
214
+ message: t
215
+ }]
216
+ };
217
+ }
218
+ function O() {
219
+ return {
220
+ ok: !1,
221
+ diagnostics: []
222
+ };
223
+ }
224
+ //#endregion
225
+ //#region ../host-kit/dist/intent/intent-behavior.js
226
+ var k = /* @__PURE__ */ new Set([
227
+ "AGENT_INTERACTION_SOURCE_UNKNOWN",
228
+ "AGENT_INTERACTION_TARGET_UNKNOWN",
229
+ "AGENT_INTERACTION_EVENT_UNKNOWN",
230
+ "AGENT_INTERACTION_FIELD_UNKNOWN",
231
+ "AGENT_INTERACTION_TARGET_INVALID",
232
+ "AGENT_INTERACTION_NO_EFFECT",
233
+ "AGENT_STATE_FIELD_TYPE",
234
+ "AGENT_INTERACTION_STATE_UNKNOWN"
235
+ ]);
236
+ function A(e) {
237
+ let t = [], n = (e) => ({
238
+ kind: "block",
239
+ origin: e.origin,
240
+ ...e.ident === void 0 ? {} : { ident: e.ident },
241
+ ...e.key === void 0 ? {} : { key: e.key },
242
+ title: e.title,
243
+ block: e
244
+ });
245
+ for (let r of e.regions) if (r.kind === "band") for (let e of r.items) t.push({
246
+ kind: "kpi",
247
+ origin: e.origin,
248
+ ...e.ident === void 0 ? {} : { ident: e.ident },
249
+ ...e.key === void 0 ? {} : { key: e.key },
250
+ title: e.label,
251
+ kpi: e
252
+ });
253
+ else r.kind === "grid" ? t.push(...r.blocks.map(n)) : t.push(...r.main.map(n), ...r.rail.map(n));
254
+ return t;
255
+ }
256
+ function j(e, t) {
257
+ let n = e.find((e) => e.key === t) ?? e.find((e) => (e.ident ?? e.origin) === t);
258
+ if (n !== void 0) return n;
259
+ let r = e.filter((e) => e.title.trim() === t.trim());
260
+ return r.length === 1 ? r[0] : void 0;
261
+ }
262
+ function M(e, t) {
263
+ let n = [], r = e.interactions ?? [];
264
+ if (r.length === 0 || t === void 0) return {
265
+ intent: e,
266
+ warnings: n
267
+ };
268
+ let i = A(e), a = /* @__PURE__ */ new Map();
269
+ for (let e of r) {
270
+ if (e.kind !== "filter") continue;
271
+ let r = j(i, e.from);
272
+ if (r === void 0) continue;
273
+ let o = P(r, e.field, t);
274
+ for (let r of e.to) {
275
+ let s = j(i, r), c = s === void 0 ? void 0 : N(s);
276
+ if (s === void 0 || c === void 0) continue;
277
+ let l = t.datasets.find((e) => e.datasetId === c.datasetId)?.parameters?.find((t) => t.name === e.param);
278
+ if (l === void 0 || !l.required || l.defaultValue !== void 0 || c.params !== void 0 && Object.hasOwn(c.params, e.param)) continue;
279
+ let u = (o ?? []).find((e) => l.allowedValues === void 0 || l.allowedValues.includes(e));
280
+ u !== void 0 && (a.set(s.origin, {
281
+ ...a.get(s.origin) ?? {},
282
+ [e.param]: u
283
+ }), n.push({
284
+ severity: "warning",
285
+ code: "INTENT_FILTER_INITIAL_FROM_SOURCE",
286
+ path: e.origin,
287
+ message: `Parameter ${e.param} of ${s.title} starts from the first value of the source (${String(u)}).`,
288
+ detail: {
289
+ param: e.param,
290
+ value: String(u),
291
+ target: s.title
292
+ }
293
+ }));
294
+ }
295
+ }
296
+ if (a.size === 0) return {
297
+ intent: e,
298
+ warnings: n
299
+ };
300
+ let o = (e) => {
301
+ let t = a.get(e.origin);
302
+ return t === void 0 || e.bind === void 0 ? e : {
303
+ ...e,
304
+ bind: {
305
+ ...e.bind,
306
+ params: {
307
+ ...e.bind.params ?? {},
308
+ ...t
309
+ }
310
+ }
311
+ };
312
+ }, s = (e) => {
313
+ let t = a.get(e.origin);
314
+ return t === void 0 || e.bind.kind !== "dataset" ? e : {
315
+ ...e,
316
+ bind: {
317
+ ...e.bind,
318
+ params: {
319
+ ...e.bind.params ?? {},
320
+ ...t
321
+ }
322
+ }
323
+ };
324
+ };
325
+ return {
326
+ intent: {
327
+ ...e,
328
+ regions: e.regions.map((e) => e.kind === "band" ? {
329
+ ...e,
330
+ items: e.items.map(o)
331
+ } : e.kind === "grid" ? {
332
+ ...e,
333
+ blocks: e.blocks.map(s)
334
+ } : {
335
+ ...e,
336
+ main: e.main.map(s),
337
+ rail: e.rail.map(s)
338
+ })
339
+ },
340
+ warnings: n
341
+ };
342
+ }
343
+ function N(e) {
344
+ if (e.kpi?.bind !== void 0) return e.kpi.bind;
345
+ if (e.block?.bind.kind === "dataset") return e.block.bind;
346
+ }
347
+ function P(e, t, n) {
348
+ if (t === void 0) return;
349
+ let r = e.block?.bind;
350
+ if (r?.kind === "table") return [...new Set(r.table.rows.map((e) => e[t]).filter(F))];
351
+ let i = N(e);
352
+ if (i !== void 0) return n?.datasets.find((e) => e.datasetId === i.datasetId)?.values?.[t];
353
+ }
354
+ function F(e) {
355
+ return typeof e == "string" || typeof e == "number" || typeof e == "boolean";
356
+ }
357
+ function ee(e) {
358
+ let t = {
359
+ variables: [],
360
+ blueprint: {
361
+ nodes: [],
362
+ edges: []
363
+ },
364
+ behaviors: []
365
+ }, n = A(e.intent), r = new te(e, t);
366
+ for (let t of e.intent.interactions ?? []) t.kind === "filter" ? r.filter(t, n) : t.kind === "show" && r.show(t, n);
367
+ for (let e of n) e.kpi?.states !== void 0 && r.states(e, e.kpi);
368
+ for (let t of e.intent.interactions ?? []) t.kind === "state" && r.setState(t, n);
369
+ return t;
370
+ }
371
+ var te = class {
372
+ input;
373
+ output;
374
+ #e = 0;
375
+ #t = 0;
376
+ #n = 0;
377
+ #r = /* @__PURE__ */ new Set();
378
+ #i = /* @__PURE__ */ new Map();
379
+ constructor(e, t) {
380
+ this.input = e, this.output = t;
381
+ }
382
+ warn(e, t, n, r) {
383
+ this.input.warnings.push({
384
+ severity: "warning",
385
+ code: e,
386
+ path: t,
387
+ message: n,
388
+ ...r === void 0 ? {} : { detail: r }
389
+ });
390
+ }
391
+ componentsOf(e) {
392
+ return this.input.components.filter((t) => this.input.sources[t.id] === e.origin);
393
+ }
394
+ mainOf(e) {
395
+ let t = this.componentsOf(e);
396
+ if (e.kpi !== void 0) return t.find((e) => e.name === "指标值");
397
+ let n = e.block?.type;
398
+ return t.filter((e) => e.type === n).at(-1);
399
+ }
400
+ rootOf(e) {
401
+ return this.componentsOf(e).find((e) => e.parentId === null) ?? this.mainOf(e);
402
+ }
403
+ nameOf(e) {
404
+ return e.title.trim() === "" ? e.block?.type ?? e.origin : e.title;
405
+ }
406
+ missing(e) {
407
+ let t = this.input.capabilities;
408
+ if (t !== void 0) return e.find((e) => !t.includes(e));
409
+ }
410
+ componentNode(e) {
411
+ let t = `agent:c:${e}`;
412
+ return this.#r.has(t) || (this.#r.add(t), this.output.blueprint.nodes.push({
413
+ kind: "component",
414
+ id: t,
415
+ componentId: e
416
+ })), t;
417
+ }
418
+ edge(e) {
419
+ this.#t += 1, this.output.blueprint.edges.push({
420
+ kind: "flow",
421
+ id: `agent-edge-${this.#t}`,
422
+ ...e
423
+ });
424
+ }
425
+ sourceEvent(e, t) {
426
+ let n = j(t, e.from), r = n === void 0 ? void 0 : this.mainOf(n);
427
+ if (n === void 0 || r === void 0) {
428
+ this.warn("AGENT_INTERACTION_SOURCE_UNKNOWN", e.origin, `No compiled block is addressed by "${e.from}".`);
429
+ return;
430
+ }
431
+ let i = this.input.catalog.materials.find((e) => e.type === r.type), a = i?.events?.find((t) => t.name === e.event);
432
+ if (a === void 0) {
433
+ let t = (i?.events ?? []).map((e) => e.name).join(", ");
434
+ this.warn("AGENT_INTERACTION_EVENT_UNKNOWN", e.origin, `${r.type} has no event ${e.event}${t === "" ? " (it declares no events)" : ` (events: ${t})`}.`, { events: t });
435
+ return;
436
+ }
437
+ return {
438
+ item: n,
439
+ component: r,
440
+ event: a
441
+ };
442
+ }
443
+ filter(e, t) {
444
+ let n = this.sourceEvent(e, t);
445
+ if (n === void 0) return;
446
+ let r = [
447
+ i.materialEvent,
448
+ i.eventPayload,
449
+ i.setVariable
450
+ ];
451
+ e.reset === !0 && r.push(i.condition, i.variable);
452
+ let a = this.missing(r);
453
+ if (a !== void 0) {
454
+ this.warn("AGENT_INTERACTION_CAPABILITY_MISSING", e.origin, `The host has not granted ${a}; the interaction was not compiled.`, { capability: a });
455
+ return;
456
+ }
457
+ let o = this.payloadPath(e, n);
458
+ if (o === void 0) return;
459
+ let s = o[0] === "row" ? o[1] : o[0] === "x" ? ae(n.component) : o[0] === "value" ? ie(n.component) : void 0, c = P(n.item, s, this.input.references), l = [];
460
+ for (let n of e.to) {
461
+ let r = this.filterTarget(e, n, t);
462
+ r !== void 0 && l.push(r);
463
+ }
464
+ if (l.length === 0) return;
465
+ let u = `agent-var-${this.#e + 1}`, d = `agent:v:${u}`, f = `agent:c:${n.component.id}`, p = {
466
+ kind: "event-payload",
467
+ path: o
468
+ }, m = l.filter((t) => {
469
+ let r = this.simulateFilter({
470
+ interaction: e,
471
+ sourceComponentId: n.component.id,
472
+ sourceNode: f,
473
+ variableId: u,
474
+ variableNode: d,
475
+ edgeValue: p,
476
+ path: o,
477
+ values: c,
478
+ target: t
479
+ });
480
+ return r === "changes" || r === "unknown" || (this.warn("AGENT_INTERACTION_NO_EFFECT", e.origin, r === "not-allowed" ? `None of the source values is an allowed value of ${e.param} (${(t.parameter.allowedValues ?? []).join(", ")}).` : r === "failed" ? "Simulating the interaction failed; it was not compiled." : `Every source value equals the current ${e.param} (${String(t.initial)}); clicking would change nothing.`, {
481
+ target: this.nameOf(t.item),
482
+ param: e.param,
483
+ reason: r
484
+ }), !1);
485
+ });
486
+ if (m.length === 0) return;
487
+ this.#e += 1;
488
+ let h = m[0], g = this.nameOf(n.item), _ = m.map((e) => this.nameOf(e.item));
489
+ this.output.variables.push({
490
+ id: u,
491
+ name: oe(`${e.param}_${this.#e}`),
492
+ description: se(this.input.language === "en" ? `Set by clicking ${g}; filters ${_.join(", ")}` : `点「${g}」设置,筛选${_.map((e) => `「${e}」`).join("")}`, 120),
493
+ type: "static",
494
+ initialValue: h.initial
495
+ });
496
+ for (let t of m) {
497
+ let n = this.input.dataSources.find((e) => e.id === t.dataSourceId);
498
+ n !== void 0 && (n.params = {
499
+ ...n.params,
500
+ [e.param]: {
501
+ kind: "variable",
502
+ variableId: u
503
+ }
504
+ }, this.input.components.filter((e) => e.dataValue?.dataSourceId === t.dataSourceId && this.input.sources[e.id] !== void 0 && !m.some((t) => t.item.origin === this.input.sources[e.id])).length > 0 && this.warn("INTENT_FILTER_SHARED_SOURCE", e.origin, `Other blocks read the same data source as ${this.nameOf(t.item)} and are filtered too.`, { target: this.nameOf(t.item) }));
505
+ }
506
+ this.#r.add(d), this.output.blueprint.nodes.push({
507
+ kind: "variable",
508
+ id: d,
509
+ variableId: u
510
+ });
511
+ let v = {
512
+ node: this.componentNode(n.component.id),
513
+ port: `event:${e.event}`
514
+ };
515
+ if (e.reset === !0) {
516
+ this.#n += 1;
517
+ let e = `agent:k:${this.#n}`;
518
+ this.#r.add(e), this.output.blueprint.nodes.push({
519
+ kind: "condition",
520
+ id: e,
521
+ name: this.input.language === "en" ? "Same item again?" : "再点同一项?",
522
+ condition: {
523
+ left: p,
524
+ operator: "eq",
525
+ right: {
526
+ kind: "variable",
527
+ variableId: u
528
+ }
529
+ }
530
+ }), this.edge({
531
+ from: v,
532
+ to: {
533
+ node: e,
534
+ port: "judge"
535
+ }
536
+ }), this.edge({
537
+ from: {
538
+ node: e,
539
+ port: "yes"
540
+ },
541
+ to: {
542
+ node: d,
543
+ port: "set"
544
+ },
545
+ value: {
546
+ kind: "literal",
547
+ value: h.initial
548
+ }
549
+ }), this.edge({
550
+ from: {
551
+ node: e,
552
+ port: "no"
553
+ },
554
+ to: {
555
+ node: d,
556
+ port: "set"
557
+ },
558
+ value: p
559
+ });
560
+ } else this.edge({
561
+ from: v,
562
+ to: {
563
+ node: d,
564
+ port: "set"
565
+ },
566
+ value: p
567
+ });
568
+ let y = e.reset === !0 ? this.input.language === "en" ? " (click again to reset)" : "(再点恢复)" : "";
569
+ this.output.behaviors.push({
570
+ kind: "filter",
571
+ origin: e.origin,
572
+ from: g,
573
+ to: _,
574
+ detail: this.input.language === "en" ? `${n.event.label ?? e.event} → filter by ${e.param}${y}` : `${n.event.label ?? e.event} → 按 ${e.param} 筛选${y}`
575
+ });
576
+ }
577
+ payloadPath(e, t) {
578
+ let n = t.event.payload, r = e.field;
579
+ if (n.row === "object") {
580
+ if (r === void 0) {
581
+ this.warn("AGENT_INTERACTION_FIELD_UNKNOWN", e.origin, `${e.event} carries a whole row; name the row field to filter by ("field").`);
582
+ return;
583
+ }
584
+ let n = ne(t.component);
585
+ if (n !== void 0 && !n.includes(r)) {
586
+ this.warn("AGENT_INTERACTION_FIELD_UNKNOWN", e.origin, `The source row has no field ${r} (fields: ${n.join(", ")}).`, { fields: n.join(", ") });
587
+ return;
588
+ }
589
+ return ["row", r];
590
+ }
591
+ if (r !== void 0 && n[r] !== void 0) return [r];
592
+ if (n.value !== void 0) return ["value"];
593
+ if (n.x !== void 0) return ["x"];
594
+ this.warn("AGENT_INTERACTION_EVENT_UNKNOWN", e.origin, `${e.event} carries no value that can drive a filter.`);
595
+ }
596
+ filterTarget(e, t, n) {
597
+ let r = j(n, t), i = r === void 0 ? void 0 : this.mainOf(r);
598
+ if (r === void 0 || i === void 0) {
599
+ this.warn("AGENT_INTERACTION_TARGET_UNKNOWN", e.origin, `No compiled block is addressed by "${t}".`);
600
+ return;
601
+ }
602
+ let a = i.dataValue, o = a?.kind === "data-source-field" && typeof a.dataSourceId == "string" ? a.dataSourceId : void 0, s = this.input.dataSources.find((e) => e.id === o), c = s?.source, l = c?.kind === "dataset" ? this.input.references?.datasets.find((e) => e.datasetId === c.datasetId) : void 0, u = l?.parameters?.find((t) => t.name === e.param);
603
+ if (o === void 0 || l === void 0 || u === void 0) {
604
+ this.warn("AGENT_INTERACTION_TARGET_INVALID", e.origin, `${this.nameOf(r)} does not read a dataset with parameter ${e.param}; filters only work through dataset parameters.`, {
605
+ target: this.nameOf(r),
606
+ param: e.param
607
+ });
608
+ return;
609
+ }
610
+ let d = s?.params?.[e.param], f = F(d?.value) ? d.value : u.defaultValue;
611
+ if (f === void 0) {
612
+ this.warn("AGENT_INTERACTION_TARGET_INVALID", e.origin, `Parameter ${e.param} of ${this.nameOf(r)} has no starting value.`, {
613
+ target: this.nameOf(r),
614
+ param: e.param
615
+ });
616
+ return;
617
+ }
618
+ return {
619
+ item: r,
620
+ dataSourceId: o,
621
+ initial: f,
622
+ parameter: u
623
+ };
624
+ }
625
+ simulateFilter(e) {
626
+ let { interaction: t, target: n, values: r } = e;
627
+ if (r === void 0 || r.length === 0) return "unknown";
628
+ let i = this.input.dataSources.find((e) => e.id === n.dataSourceId);
629
+ if (i === void 0) return "failed";
630
+ let a = {
631
+ canvas: {
632
+ width: 1920,
633
+ height: 1080,
634
+ backgroundColor: "#000000"
635
+ },
636
+ components: this.input.components,
637
+ variables: [{
638
+ id: e.variableId,
639
+ name: "probe",
640
+ type: "static",
641
+ initialValue: n.initial
642
+ }],
643
+ dataSources: [{
644
+ ...i,
645
+ params: {
646
+ ...i.params,
647
+ [t.param]: {
648
+ kind: "variable",
649
+ variableId: e.variableId
650
+ }
651
+ }
652
+ }],
653
+ blueprint: {
654
+ nodes: [{
655
+ kind: "component",
656
+ id: e.sourceNode,
657
+ componentId: e.sourceComponentId
658
+ }, {
659
+ kind: "variable",
660
+ id: e.variableNode,
661
+ variableId: e.variableId
662
+ }],
663
+ edges: [{
664
+ kind: "flow",
665
+ id: "agent-probe",
666
+ from: {
667
+ node: e.sourceNode,
668
+ port: `event:${t.event}`
669
+ },
670
+ to: {
671
+ node: e.variableNode,
672
+ port: "set"
673
+ },
674
+ value: e.edgeValue
675
+ }]
676
+ }
677
+ }, o = n.parameter.allowedValues, s = !1, l = !1;
678
+ for (let [i, u] of r.slice(0, 24).entries()) {
679
+ let r = c(a, {
680
+ componentId: e.sourceComponentId,
681
+ name: t.event,
682
+ payload: re(e.path, u, i)
683
+ });
684
+ if (!r.ok || r.value.failure !== void 0) return "failed";
685
+ let d = r.value.dataSourceChanges[n.dataSourceId]?.[t.param];
686
+ if (d === void 0) continue;
687
+ s = !0;
688
+ let f = d.after;
689
+ F(f) && (o === void 0 || o.includes(f)) && (l = !0);
690
+ }
691
+ return l ? "changes" : s ? "not-allowed" : "same";
692
+ }
693
+ show(e, t) {
694
+ let n = this.sourceEvent(e, t);
695
+ if (n === void 0) return;
696
+ let r = this.missing([i.materialEvent, i.componentVisibility]);
697
+ if (r !== void 0) {
698
+ this.warn("AGENT_INTERACTION_CAPABILITY_MISSING", e.origin, `The host has not granted ${r}; the interaction was not compiled.`, { capability: r });
699
+ return;
700
+ }
701
+ let a = [];
702
+ for (let r of e.to) {
703
+ let i = j(t, r), o = i === void 0 ? void 0 : this.rootOf(i);
704
+ if (i === void 0 || o === void 0) {
705
+ this.warn("AGENT_INTERACTION_TARGET_UNKNOWN", e.origin, `No compiled block is addressed by "${r}".`);
706
+ continue;
707
+ }
708
+ if (i.origin === n.item.origin && e.mode !== "hide") {
709
+ this.warn("AGENT_INTERACTION_NO_EFFECT", e.origin, "A block cannot show or toggle itself.", {
710
+ target: this.nameOf(i),
711
+ reason: "self"
712
+ });
713
+ continue;
714
+ }
715
+ e.mode === "show" && (o.status = {
716
+ ...o.status,
717
+ hidden: !0
718
+ }), this.edge({
719
+ from: {
720
+ node: this.componentNode(n.component.id),
721
+ port: `event:${e.event}`
722
+ },
723
+ to: {
724
+ node: this.componentNode(o.id),
725
+ port: e.mode
726
+ }
727
+ }), a.push(i);
728
+ }
729
+ if (a.length === 0) return;
730
+ let o = this.input.language === "en" ? {
731
+ show: "show",
732
+ hide: "hide",
733
+ toggle: "toggle"
734
+ }[e.mode] : {
735
+ show: "显示",
736
+ hide: "隐藏",
737
+ toggle: "切换显隐"
738
+ }[e.mode];
739
+ this.output.behaviors.push({
740
+ kind: "show",
741
+ origin: e.origin,
742
+ from: this.nameOf(n.item),
743
+ to: a.map((e) => this.nameOf(e)),
744
+ detail: `${n.event.label ?? e.event} → ${o}`
745
+ });
746
+ }
747
+ states(e, t) {
748
+ let n = t.states;
749
+ if (n === void 0) return;
750
+ let r = this.mainOf(e), i = r?.dataValue;
751
+ if (t.bind === void 0 || r === void 0 || i?.kind !== "data-source-field" || typeof i.dataSourceId != "string") {
752
+ this.warn("AGENT_STATE_NEEDS_DATA", e.origin, "Threshold states only apply to a KPI bound to a dataset field; a sample value is not real data.");
753
+ return;
754
+ }
755
+ let a = this.input.references?.datasets.find((e) => e.datasetId === t.bind?.datasetId), s = t.bind.field, c = n.rules, l;
756
+ if (n.source === "level-scale") {
757
+ let t = a?.levelScales?.find((e) => e.path.length === 1 && e.path[0] === s);
758
+ if (t === void 0 || t.levels.length === 0) {
759
+ this.warn("AGENT_STATE_LEVEL_SCALE_UNAVAILABLE", e.origin, `The host declares no level scale for field ${s}; level states were not generated.`, {
760
+ target: e.title,
761
+ field: s
762
+ });
763
+ return;
764
+ }
765
+ l = t.levels.slice(0, 8).map((e) => e.value), c = t.levels.slice(0, 8).map((e) => ({
766
+ op: "eq",
767
+ value: typeof e.value == "boolean" ? String(e.value) : e.value,
768
+ tone: e.tone,
769
+ label: e.label
770
+ }));
771
+ } else {
772
+ let t = a?.columns.find((e) => e.id === s);
773
+ if (c.some((e) => e.op !== "eq" && e.op !== "neq") && t !== void 0 && t.type !== "number") {
774
+ this.warn("AGENT_STATE_FIELD_TYPE", e.origin, `Field ${s} is ${t.type}; compare it with eq / neq, not a numeric threshold.`);
775
+ return;
776
+ }
777
+ }
778
+ let u = this.input.catalog.materials.find((e) => e.type === r.type), f = u !== void 0 && "color" in u.defaults.style, p = (e) => {
779
+ let t = u?.statePreset === void 0 ? {} : d(u.statePreset, e);
780
+ return Object.keys(t).length > 0 ? t : f ? { color: o(e) } : {};
781
+ }, m = c.map((e, t) => ({
782
+ id: `agent-state-${t + 1}`,
783
+ name: e.label ?? ce(e.tone, this.input.language),
784
+ style: p(e.tone)
785
+ }));
786
+ this.#i.set(r.id, m.map((e, t) => ({
787
+ id: e.id,
788
+ name: e.name,
789
+ tone: c[t].tone
790
+ }))), r.states = {
791
+ items: m,
792
+ judge: {
793
+ input: {
794
+ kind: "data-source-field",
795
+ dataSourceId: i.dataSourceId,
796
+ path: [
797
+ "rows",
798
+ "0",
799
+ s
800
+ ]
801
+ },
802
+ cases: c.map((e, t) => ({
803
+ operator: e.op,
804
+ value: l?.[t] ?? e.value,
805
+ stateId: `agent-state-${t + 1}`
806
+ }))
807
+ }
808
+ }, n.suggested === !0 && n.source !== "level-scale" && this.warn("INTENT_STATE_SUGGESTED", e.origin, `The thresholds of ${e.title} were suggested by the model; check them before adopting.`, { target: e.title });
809
+ let h = c.map((e) => ue(e, this.input.language)).join(";");
810
+ this.output.behaviors.push({
811
+ kind: "state",
812
+ origin: e.origin,
813
+ from: e.title,
814
+ to: [e.title],
815
+ detail: n.source === "level-scale" ? `${this.input.language === "en" ? "by host level scale: " : "按宿主分级表:"}${h}` : h,
816
+ ...n.suggested === !0 && n.source !== "level-scale" ? { suggested: !0 } : {}
817
+ });
818
+ }
819
+ setState(e, t) {
820
+ let n = this.sourceEvent(e, t);
821
+ if (n === void 0) return;
822
+ let r = this.missing([i.materialEvent, i.componentState]);
823
+ if (r !== void 0) {
824
+ this.warn("AGENT_INTERACTION_CAPABILITY_MISSING", e.origin, `The host has not granted ${r}; the interaction was not compiled.`, { capability: r });
825
+ return;
826
+ }
827
+ let a = e.state.toLowerCase() === "reset", o = [], s = "";
828
+ for (let r of e.to) {
829
+ let i = j(t, r), c = i === void 0 ? void 0 : this.mainOf(i);
830
+ if (i === void 0 || c === void 0) {
831
+ this.warn("AGENT_INTERACTION_TARGET_UNKNOWN", e.origin, `No compiled block is addressed by "${r}".`);
832
+ continue;
833
+ }
834
+ let l = this.#i.get(c.id);
835
+ if (l === void 0 || l.length === 0) {
836
+ this.warn("AGENT_INTERACTION_TARGET_INVALID", e.origin, `${this.nameOf(i)} declares no states; give the KPI "states" first, then set one of them.`, {
837
+ target: this.nameOf(i),
838
+ reason: "no-states"
839
+ });
840
+ continue;
841
+ }
842
+ if (a) {
843
+ this.edge({
844
+ from: {
845
+ node: this.componentNode(n.component.id),
846
+ port: `event:${e.event}`
847
+ },
848
+ to: {
849
+ node: this.componentNode(c.id),
850
+ port: "reset-state"
851
+ }
852
+ }), o.push(i);
853
+ continue;
854
+ }
855
+ let u = e.state.trim(), d = l.find((e) => e.name === u) ?? l.find((e) => e.tone === u || ce(e.tone, this.input.language) === u);
856
+ if (d === void 0) {
857
+ let t = l.map((e) => e.name).join(", ");
858
+ this.warn("AGENT_INTERACTION_STATE_UNKNOWN", e.origin, `${this.nameOf(i)} has no state "${u}" (states: ${t}).`, {
859
+ target: this.nameOf(i),
860
+ states: t
861
+ });
862
+ continue;
863
+ }
864
+ s = d.name, this.edge({
865
+ from: {
866
+ node: this.componentNode(n.component.id),
867
+ port: `event:${e.event}`
868
+ },
869
+ to: {
870
+ node: this.componentNode(c.id),
871
+ port: "set-state"
872
+ },
873
+ stateId: d.id
874
+ }), o.push(i);
875
+ }
876
+ if (o.length === 0) return;
877
+ let c = this.input.language === "en", l = a ? c ? "reset the state of" : "恢复按判定显示" : c ? `set to "${s}":` : `设为「${s}」`;
878
+ this.output.behaviors.push({
879
+ kind: "set-state",
880
+ origin: e.origin,
881
+ from: this.nameOf(n.item),
882
+ to: o.map((e) => this.nameOf(e)),
883
+ detail: `${n.event.label ?? e.event} → ${l}`
884
+ });
885
+ }
886
+ };
887
+ function ne(e) {
888
+ let t = e.dataBinding?.fields;
889
+ if (t !== void 0) return Object.values(t).flatMap((e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : []);
890
+ let n = e.dataValue;
891
+ if (n?.kind === "inline" && Array.isArray(n.value?.fields)) return n.value.fields.map((e) => e.id).filter((e) => typeof e == "string");
892
+ }
893
+ function re(e, t, n) {
894
+ return e[0] === "row" && e[1] !== void 0 ? {
895
+ rowIndex: n,
896
+ row: { [e[1]]: t }
897
+ } : e[0] === void 0 ? {} : {
898
+ [e[0]]: t,
899
+ index: n
900
+ };
901
+ }
902
+ function ie(e) {
903
+ let t = e.dataBinding?.fields, n = t === void 0 ? void 0 : Object.values(t)[0];
904
+ return Array.isArray(n) && typeof n.at(-1) == "string" ? n.at(-1) : void 0;
905
+ }
906
+ function ae(e) {
907
+ let t = e.dataBinding?.fields;
908
+ if (t === void 0) return;
909
+ let n = t.dimension ?? Object.values(t)[0];
910
+ return Array.isArray(n) && typeof n[0] == "string" ? n[0] : void 0;
911
+ }
912
+ function oe(e) {
913
+ let t = e.replace(/[^A-Za-z0-9_]/g, "_").replace(/^[^A-Za-z_]+/, "");
914
+ return t === "" ? "agent_filter" : t.slice(0, 64);
915
+ }
916
+ function se(e, t) {
917
+ return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
918
+ }
919
+ function ce(e, t) {
920
+ return t === "en" ? {
921
+ success: "Normal",
922
+ warning: "Warning",
923
+ danger: "Alert",
924
+ info: "Notice"
925
+ }[e] : {
926
+ success: "正常",
927
+ warning: "预警",
928
+ danger: "告警",
929
+ info: "提示"
930
+ }[e];
931
+ }
932
+ var le = {
933
+ gt: ">",
934
+ gte: "≥",
935
+ lt: "<",
936
+ lte: "≤",
937
+ eq: "=",
938
+ neq: "≠"
939
+ };
940
+ function ue(e, t) {
941
+ return `${le[e.op]} ${String(e.value)} ${e.label ?? ce(e.tone, t)}`;
942
+ }
943
+ //#endregion
944
+ //#region ../host-kit/dist/intent/intent-dataset.js
945
+ function de(e, t = {}) {
946
+ let n = e.parameters ?? [], r = Object.keys(t).filter((e) => {
947
+ let r = n.find((t) => t.name === e);
948
+ return r === void 0 || !fe(r, t[e]);
949
+ });
950
+ if (r.length > 0) return {
951
+ ok: !1,
952
+ missing: [],
953
+ invalid: r
954
+ };
955
+ let i = {}, a = [];
956
+ for (let e of n) {
957
+ let n = Object.hasOwn(t, e.name) ? t[e.name] : e.defaultValue;
958
+ n === void 0 ? e.required && a.push(e) : i[e.name] = {
959
+ kind: "inline",
960
+ value: n
961
+ };
962
+ }
963
+ return a.length > 0 ? {
964
+ ok: !1,
965
+ missing: a,
966
+ invalid: []
967
+ } : {
968
+ ok: !0,
969
+ params: i
970
+ };
971
+ }
972
+ function fe(e, t) {
973
+ let n = e.valueType;
974
+ return n === "number" && typeof t != "number" || n === "boolean" && typeof t != "boolean" || (n === "string" || n === "date") && typeof t != "string" ? !1 : e.allowedValues === void 0 || e.allowedValues.includes(t);
975
+ }
976
+ function pe(e, t, n) {
977
+ let r = new Map(t.columns.map((e) => [e.id, e])), i = {};
978
+ for (let [a, o] of Object.entries(n)) {
979
+ let n = e.roles.find((e) => e.id === a);
980
+ if (n === void 0) return {
981
+ ok: !1,
982
+ code: "AGENT_BINDING_FIELD_UNKNOWN",
983
+ message: `${e.type} has no binding role ${a}.`
984
+ };
985
+ for (let i of o) {
986
+ let o = r.get(i);
987
+ if (o === void 0) return {
988
+ ok: !1,
989
+ code: "AGENT_BINDING_FIELD_UNKNOWN",
990
+ message: `Dataset ${t.datasetId} has no field ${i}.`
991
+ };
992
+ if (n.valueTypes !== void 0 && !n.valueTypes.includes(o.type)) return {
993
+ ok: !1,
994
+ code: "AGENT_BINDING_TYPE_MISMATCH",
995
+ message: `Field ${i} (${o.type}) does not fit role ${a} of ${e.type}.`
996
+ };
997
+ }
998
+ if (o.length < n.min || o.length > n.max) return {
999
+ ok: !1,
1000
+ code: "AGENT_BINDING_TYPE_MISMATCH",
1001
+ message: `Role ${a} of ${e.type} takes ${n.min}–${n.max} fields.`
1002
+ };
1003
+ i[a] = [...o];
1004
+ }
1005
+ let a = e.roles.find((e) => e.min > 0 && i[e.id] === void 0);
1006
+ return a === void 0 ? {
1007
+ ok: !0,
1008
+ fields: i
1009
+ } : {
1010
+ ok: !1,
1011
+ code: "AGENT_BINDING_FIELD_UNKNOWN",
1012
+ message: `Role ${a.id} of ${e.type} needs at least ${a.min} field(s).`
1013
+ };
1014
+ }
1015
+ function me(e, t, n) {
1016
+ let r = JSON.stringify(n);
1017
+ for (let n of e.dataSources) {
1018
+ let e = n.source;
1019
+ if (e?.kind === "dataset" && e.datasetId === t.datasetId && JSON.stringify(n.params) === r && typeof n.id == "string") return n.id;
1020
+ }
1021
+ let i = `agent-ds-${e.dataSources.length + 1}`;
1022
+ return e.dataSources.push({
1023
+ id: i,
1024
+ name: t.name,
1025
+ source: {
1026
+ kind: "dataset",
1027
+ datasetId: t.datasetId
1028
+ },
1029
+ params: n
1030
+ }), i;
1031
+ }
1032
+ function he(e, t) {
1033
+ let n = t[0];
1034
+ return {
1035
+ datasetId: e.datasetId,
1036
+ dataset: e.name,
1037
+ params: t.map((e) => e.name).join(", "),
1038
+ allowed: (n?.allowedValues ?? []).map((e) => String(e)).join(" / ")
1039
+ };
1040
+ }
1041
+ //#endregion
1042
+ //#region ../host-kit/dist/intent/intent-block.js
1043
+ function ge(e, t, n, r) {
1044
+ let i = n.catalog.materials.find((t) => t.type === e.type);
1045
+ if (i === void 0) {
1046
+ r.sink.warnings.push(I("AGENT_MATERIAL_UNKNOWN", e, `The catalog has no material ${e.type}.`));
1047
+ return;
1048
+ }
1049
+ let a = _e(i, e, n, r);
1050
+ if (a === null) return;
1051
+ let o = n.textMaterial !== void 0 && i.type === n.textMaterial.type, s = (e.bind.kind === "text" ? e.bind.text : "").trim(), c = o && s !== "" && e.title.trim() === s, l = e.title.trim() !== "" && !c, u = l && (e.note ?? "").trim() !== "", d = l ? u ? 64 : 36 : 0;
1052
+ e.substituteFor !== void 0 && r.sink.warnings.push({
1053
+ severity: "warning",
1054
+ code: "INTENT_BLOCK_SUBSTITUTED",
1055
+ path: e.origin,
1056
+ message: `The model used "${i.name}" in place of "${e.substituteFor}", which the catalog does not offer.`,
1057
+ detail: {
1058
+ wanted: e.substituteFor,
1059
+ used: i.name
1060
+ }
1061
+ }), n.beginShell(e.title.trim() === "" ? i.name : e.title, t), l && (n.pushText("块标题", e.title, {
1062
+ x: t.x,
1063
+ y: t.y,
1064
+ width: t.width,
1065
+ height: 28
1066
+ }, {
1067
+ fontSize: 21,
1068
+ fontWeight: "700"
1069
+ }), u && n.pushText("块说明", e.note ?? "", {
1070
+ x: t.x,
1071
+ y: t.y + 30,
1072
+ width: t.width,
1073
+ height: 24
1074
+ }, {
1075
+ fontSize: 16,
1076
+ color: n.palette.muted
1077
+ }));
1078
+ let f = {
1079
+ x: t.x,
1080
+ y: t.y + d,
1081
+ width: t.width,
1082
+ height: t.height - d
1083
+ }, p = e.title.trim() === "" ? i.name : e.title, m = Ee(f), h = {
1084
+ ...a.style ?? {},
1085
+ ...Ce(i, e.style),
1086
+ ...Te(i, e, m.height)
1087
+ };
1088
+ n.push(i, p, m, {
1089
+ props: xe(i, e.props),
1090
+ ...a,
1091
+ ...Object.keys(h).length === 0 ? {} : { style: h }
1092
+ }), n.endShell();
1093
+ }
1094
+ function _e(e, t, n, r) {
1095
+ let { sink: i } = r;
1096
+ if (e.data === "tabular") {
1097
+ if (t.bind.kind === "dataset") {
1098
+ let { datasetId: r } = t.bind, a = n.references?.datasets.find((e) => e.datasetId === r);
1099
+ if (a !== void 0) {
1100
+ let n = de(a, t.bind.params);
1101
+ if (!n.ok && n.invalid.length > 0) return i.warnings.push(I("AGENT_DATASET_PARAM_INVALID", t, `Parameter(s) ${n.invalid.join(", ")} of dataset ${r} are not declared or not allowed.`)), null;
1102
+ if (!n.ok) return i.warnings.push({
1103
+ ...I("AGENT_DATASET_PARAM_REQUIRED", t, `Dataset ${r} requires parameter(s) ${n.missing.map((e) => e.name).join(", ")} without a default; the block is skipped.`),
1104
+ detail: he(a, n.missing)
1105
+ }), null;
1106
+ let o = t.bind.fields === void 0 ? void 0 : pe(e, a, t.bind.fields);
1107
+ if (o !== void 0 && !o.ok) return i.warnings.push(I(o.code, t, o.message)), null;
1108
+ let s = me(i, a, n.params);
1109
+ if (o !== void 0) return {
1110
+ dataValue: {
1111
+ kind: "data-source-field",
1112
+ dataSourceId: s,
1113
+ path: []
1114
+ },
1115
+ dataBinding: { fields: o.fields }
1116
+ };
1117
+ let c = ve(e, { columns: a.columns.map((e) => ({
1118
+ id: e.id,
1119
+ label: e.id,
1120
+ type: e.type === "number" ? "number" : "string"
1121
+ })) });
1122
+ return {
1123
+ dataValue: {
1124
+ kind: "data-source-field",
1125
+ dataSourceId: s,
1126
+ path: []
1127
+ },
1128
+ ...c === null ? {} : { dataBinding: { fields: c } }
1129
+ };
1130
+ }
1131
+ i.warnings.push(I("AGENT_DATASET_UNKNOWN", t, `Dataset ${r} is not part of this round's references; the block is skipped.`));
1132
+ }
1133
+ let r = t.bind.kind === "table" ? t.bind.table : void 0;
1134
+ if (r === void 0) return i.warnings.push(I("AGENT_BLOCK_DATA_MISSING", t, `${e.type} is a data material but no table was given.`)), null;
1135
+ let a = ve(e, r);
1136
+ return a === null ? (i.warnings.push(I("AGENT_BLOCK_BINDING_UNSATISFIED", t, `The binding roles of ${e.type} cannot be satisfied by these ${r.columns.length} columns; the block degraded to an empty one.`)), {}) : {
1137
+ dataValue: {
1138
+ kind: "inline",
1139
+ value: be(r),
1140
+ sample: !0
1141
+ },
1142
+ dataBinding: { fields: a }
1143
+ };
1144
+ }
1145
+ if (e.data === "scalar") {
1146
+ if (t.bind.kind === "asset") {
1147
+ let { assetId: a } = t.bind, o = n.catalog.assets.find((e) => e.id === a);
1148
+ if (o === void 0) return i.warnings.push(I("AGENT_ASSET_UNKNOWN", t, `Asset ${a} is not in the host asset list.`)), null;
1149
+ let s = `agent-ds-${i.dataSources.length + 1}`;
1150
+ return i.dataSources.push({
1151
+ id: s,
1152
+ name: o.name,
1153
+ source: {
1154
+ kind: "host-resource",
1155
+ resourceType: "host_image",
1156
+ resourceId: o.id
1157
+ },
1158
+ params: {}
1159
+ }), r.onAsset(), {
1160
+ ...typeof e.defaults.style.objectFit == "string" ? { style: { objectFit: "cover" } } : {},
1161
+ dataValue: {
1162
+ kind: "data-source-field",
1163
+ dataSourceId: s,
1164
+ path: []
1165
+ }
1166
+ };
1167
+ }
1168
+ if (e.asset) return i.warnings.push(I("AGENT_BLOCK_ASSET_REQUIRED", t, `${e.type} needs an assetId but only text was given; the block is skipped.`)), null;
1169
+ let a = t.bind.kind === "text" ? t.bind.text : "";
1170
+ return a === "" ? (i.warnings.push(I("AGENT_BLOCK_DATA_MISSING", t, `${e.type} is a value material but no text was given.`)), null) : {
1171
+ ...n.textMaterial !== void 0 && e.type === n.textMaterial.type ? { style: we(e, {
1172
+ fontSize: 18,
1173
+ color: n.palette.text,
1174
+ lineSpacing: a.includes("\n") ? 8 : 0
1175
+ }) } : {},
1176
+ dataValue: {
1177
+ kind: "inline",
1178
+ value: a
1179
+ }
1180
+ };
1181
+ }
1182
+ return {};
1183
+ }
1184
+ function I(e, t, n) {
1185
+ return {
1186
+ severity: "warning",
1187
+ code: e,
1188
+ path: t.origin,
1189
+ message: n
1190
+ };
1191
+ }
1192
+ function ve(e, t) {
1193
+ if (e.roles.length === 0) return null;
1194
+ if (e.roles.every((e) => e.valueTypes !== void 0)) return ye(e, t);
1195
+ let n = t.columns.map((e) => e.id), r = t.columns.filter((e) => e.type === "number").map((e) => e.id), i = t.columns.filter((e) => e.type !== "number").map((e) => e.id), a = {};
1196
+ for (let t of e.roles) {
1197
+ let e = t.id.toLowerCase(), o;
1198
+ o = e === "columns" ? n : e === "dimension" ? i.length > 0 ? i : n : r.length > 0 ? r : n;
1199
+ let s = o.slice(0, t.max);
1200
+ if (s.length < t.min) return null;
1201
+ a[t.id] = s;
1202
+ }
1203
+ return a;
1204
+ }
1205
+ function ye(e, t) {
1206
+ let n = (e, t) => e.includes(t) || t === "string" && e.includes("date"), r = /* @__PURE__ */ new Set(), i = {};
1207
+ for (let a of e.roles) {
1208
+ let e = a.valueTypes ?? [], o = t.columns.filter((t) => n(e, t.type)), s;
1209
+ if (e.length === 1 && e[0] === "number") s = o.filter((e) => !r.has(e.id)).map((e) => e.id);
1210
+ else if (a.max === 1 && n(e, "string")) {
1211
+ let e = o.find((e) => e.type !== "number" && !r.has(e.id)) ?? o.find((e) => !r.has(e.id));
1212
+ s = e === void 0 ? [] : [e.id], e !== void 0 && r.add(e.id);
1213
+ } else s = o.map((e) => e.id);
1214
+ let c = s.slice(0, a.max);
1215
+ if (c.length < a.min) return null;
1216
+ i[a.id] = c;
1217
+ }
1218
+ return i;
1219
+ }
1220
+ function be(e) {
1221
+ return {
1222
+ fields: e.columns.map((e) => ({
1223
+ id: e.id,
1224
+ label: e.label,
1225
+ valueType: e.type,
1226
+ nullable: !1
1227
+ })),
1228
+ rows: e.rows.map((t) => {
1229
+ let n = {};
1230
+ for (let r of e.columns) n[r.id] = t[r.id] ?? null;
1231
+ return n;
1232
+ })
1233
+ };
1234
+ }
1235
+ function xe(e, t) {
1236
+ if (t === void 0) return {};
1237
+ let n = {};
1238
+ for (let [r, i] of Object.entries(t)) {
1239
+ let t = e.props[r];
1240
+ if (t !== void 0) {
1241
+ if (t.kind === "enum") {
1242
+ typeof i == "string" && t.values?.includes(i) === !0 && (n[r] = i);
1243
+ continue;
1244
+ }
1245
+ if (t.kind === "number") {
1246
+ if (typeof i == "number" && Number.isFinite(i)) {
1247
+ let e = t.min ?? -Infinity, a = t.max ?? Infinity;
1248
+ n[r] = Math.min(a, Math.max(e, i));
1249
+ }
1250
+ continue;
1251
+ }
1252
+ if (t.kind === "boolean") {
1253
+ typeof i == "boolean" && (n[r] = i);
1254
+ continue;
1255
+ }
1256
+ typeof i == "string" && (n[r] = i.slice(0, 160));
1257
+ }
1258
+ }
1259
+ return n;
1260
+ }
1261
+ var Se = [
1262
+ "fontSize",
1263
+ "fontWeight",
1264
+ "color",
1265
+ "fill",
1266
+ "backgroundColor",
1267
+ "align",
1268
+ "textAlign",
1269
+ "lineSpacing"
1270
+ ];
1271
+ function Ce(e, t) {
1272
+ if (t === void 0) return {};
1273
+ let n = e.defaults.style, r = p(1920), i = {};
1274
+ for (let e of Se) {
1275
+ let a = t[e];
1276
+ if (!(a === void 0 || !(e in n))) {
1277
+ if (e === "fontSize") {
1278
+ typeof a == "number" && Number.isFinite(a) && (i.fontSize = Math.max(r, Math.round(a)));
1279
+ continue;
1280
+ }
1281
+ if (e === "fontWeight") {
1282
+ if (typeof n.fontWeight == "number") {
1283
+ let e = typeof a == "number" ? a : Number(a);
1284
+ typeof a != "boolean" && Number.isFinite(e) && (i.fontWeight = e);
1285
+ continue;
1286
+ }
1287
+ let e = typeof a == "number" ? a : Number(a);
1288
+ typeof a != "boolean" && Number.isFinite(e) ? i.fontWeight = e >= 600 ? "700" : "400" : a === "bold" || a === "bolder" ? i.fontWeight = "700" : (a === "normal" || a === "lighter") && (i.fontWeight = "400");
1289
+ continue;
1290
+ }
1291
+ if (e === "lineSpacing") {
1292
+ typeof a == "number" && Number.isFinite(a) && (i.lineSpacing = a);
1293
+ continue;
1294
+ }
1295
+ if (e === "align" || e === "textAlign") {
1296
+ (a === "left" || a === "center" || a === "right") && (i[e] = a);
1297
+ continue;
1298
+ }
1299
+ (e === "color" || e === "fill" || e === "backgroundColor") && typeof a == "string" && f(a) !== void 0 && (i[e] = a);
1300
+ }
1301
+ }
1302
+ return i;
1303
+ }
1304
+ function we(e, t) {
1305
+ let n = e.defaults.style, r = {};
1306
+ return t.fontSize !== void 0 && "fontSize" in n && (r.fontSize = t.fontSize), t.fontWeight !== void 0 && "fontWeight" in n && (r.fontWeight = t.fontWeight), t.color !== void 0 && "color" in n && (r.color = t.color), t.lineSpacing !== void 0 && "lineSpacing" in n && (r.lineSpacing = t.lineSpacing), r;
1307
+ }
1308
+ function Te(e, t, n) {
1309
+ if (!("rowHeight" in e.defaults.style)) return {};
1310
+ let r = t.bind.kind === "table" ? t.bind.table.rows.length : 0;
1311
+ if (r === 0) return {};
1312
+ let i = e.defaults.style.rowHeight, a = typeof i == "number" && i > 0 ? i : 32, o = Math.floor((n - 4) / (r + 1));
1313
+ return { rowHeight: Math.min(a, Math.max(20, o)) };
1314
+ }
1315
+ function Ee(e) {
1316
+ return {
1317
+ x: e.x + 16,
1318
+ y: e.y + 16,
1319
+ width: Math.max(1, e.width - 32),
1320
+ height: Math.max(1, e.height - 32)
1321
+ };
1322
+ }
1323
+ //#endregion
1324
+ //#region ../host-kit/dist/intent/intent-catalog.js
1325
+ function De(e) {
1326
+ return e.materials.find((e) => e.data === "scalar" && typeof e.defaults.style.fontSize == "number");
1327
+ }
1328
+ var Oe = /(?:^|[-.])(?:ellipse|oval|circle|triangle|polygon|star|arrow|line|rule|connector|divider)(?:$|[-.])/i, ke = /(?:^|[-.])(?:rectangle|rect|card|panel|surface|box|frame|tile)(?:$|[-.])/i, Ae = /(椭圆|圆形|圆|三角|多边形|星形|箭头|线条|连线|分隔线)/, je = /(矩形|方形|底板|卡片|面板|背景|容器|框架|色块)/;
1329
+ function Me(e) {
1330
+ let t, n = -1;
1331
+ for (let r of e.materials) {
1332
+ if (r.data !== "none" || r.children === !0 || typeof r.defaults.style.fill != "string" || Oe.test(r.type) || Ae.test(r.name)) continue;
1333
+ let e = 0;
1334
+ /(?:^|[-.])rect(?:angle)?(?:$|[-.])/i.test(r.type) && (e += 4), ke.test(r.type) && (e += 2), r.name.includes("矩形") && (e += 3), je.test(r.name) && (e += 1), "borderRadius" in r.defaults.style && (e += 1), e > n && (t = r, n = e);
1335
+ }
1336
+ return t;
1337
+ }
1338
+ function Ne(e) {
1339
+ return e.materials.find((e) => e.children === !0 && e.data === "none");
1340
+ }
1341
+ //#endregion
1342
+ //#region ../host-kit/dist/intent/intent-format.js
1343
+ var Pe = "—", Fe = /^(?:[万亿千]|[KMBk](?![a-z]))/;
1344
+ function Ie(...e) {
1345
+ return /[⺀-鿿豈-﫿＀-￯]/.test(e.join("")) ? "zh" : "en";
1346
+ }
1347
+ function Le(e, t = "zh") {
1348
+ if (e.value === null) return Pe;
1349
+ let n = e.unit ?? "", r = Math.abs(e.value), [i, a] = n === "%" || Fe.test(n) ? [e.value, ""] : t === "en" ? r >= 1e9 ? [e.value / 1e9, "B"] : r >= 1e6 ? [e.value / 1e6, "M"] : [e.value, ""] : r >= 1e8 ? [e.value / 1e8, "亿"] : r >= 1e4 ? [e.value / 1e4, "万"] : [e.value, ""], o = e.precision ?? (a === "" ? Number.isInteger(i) ? 0 : Math.min(2, Ve(i)) : 1), s = Ue(i.toFixed(o));
1350
+ if (n === "%") return `${s}%`;
1351
+ if (t === "en") return n === "" ? `${s}${a}` : `${s}${a} ${n}`;
1352
+ let c = `${a}${n}`;
1353
+ return c === "" ? s : `${s} ${c}`;
1354
+ }
1355
+ function Re(e, t = "zh") {
1356
+ let n = e.delta;
1357
+ if (n === void 0) return "";
1358
+ let r = ze(n) ? "" : n.value > 0 ? "+" : "-", i = Math.abs(n.value);
1359
+ return n.unit === "percent" ? `${r}${He(i.toFixed(1))}%` : n.unit === "point" ? `${r}${He(i.toFixed(1))}${t === "en" ? " pp" : " 个百分点"}` : `${r}${Le({
1360
+ value: i,
1361
+ ...e.unit === void 0 ? {} : { unit: e.unit }
1362
+ }, t)}`;
1363
+ }
1364
+ function ze(e) {
1365
+ return e.value === 0 || e.unit !== "absolute" && Number(Math.abs(e.value).toFixed(1)) === 0;
1366
+ }
1367
+ function Be(e, t) {
1368
+ return e.direction === "neutral" || ze(e) ? t.muted : e.direction === "up-good" == e.value > 0 ? "theme:success" : "theme:danger";
1369
+ }
1370
+ function Ve(e) {
1371
+ let t = String(e), n = t.indexOf(".");
1372
+ return n < 0 ? 0 : t.length - n - 1;
1373
+ }
1374
+ function He(e) {
1375
+ return e.includes(".") ? e.replace(/\.?0+$/, "") : e;
1376
+ }
1377
+ function Ue(e) {
1378
+ let [t, n] = e.split("."), r = (t ?? "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
1379
+ return n === void 0 ? r : `${r}.${n}`;
1380
+ }
1381
+ //#endregion
1382
+ //#region ../host-kit/dist/intent/intent-kpi-bind.js
1383
+ function We(e, t, n) {
1384
+ let r = e.bind;
1385
+ if (r === void 0) return !1;
1386
+ let i = (t, r, i) => (n.sink.warnings.push({
1387
+ severity: "warning",
1388
+ code: t,
1389
+ path: e.origin,
1390
+ message: r,
1391
+ ...i === void 0 ? {} : { detail: i }
1392
+ }), !1), a = n.references?.datasets.find((e) => e.datasetId === r.datasetId);
1393
+ if (a === void 0) return i("AGENT_DATASET_UNKNOWN", `Dataset ${r.datasetId} is not part of this round's references; the KPI shows a placeholder.`);
1394
+ let o = a.columns.find((e) => e.id === r.field);
1395
+ if (o === void 0) return i("AGENT_BINDING_FIELD_UNKNOWN", `Dataset ${a.datasetId} has no field ${r.field}.`);
1396
+ if (a.rows !== void 0 && (a.rows.sampled > 1 || (a.rows.total ?? 0) > 1)) return i("AGENT_KPI_MULTI_ROW", `Dataset ${a.datasetId} returns more than one row; a KPI card only shows the first row. Use a chart or table block instead.`);
1397
+ let s = n.textMaterial, c = s?.roles[0];
1398
+ if (s === void 0 || c === void 0 || c.valueTypes !== void 0 && !c.valueTypes.includes(o.type)) return i("AGENT_KPI_BIND_UNSUPPORTED", "The catalog has no text material that can read a dataset field.");
1399
+ let l = de(a, r.params);
1400
+ if (!l.ok && l.invalid.length > 0) return i("AGENT_DATASET_PARAM_INVALID", `Parameter(s) ${l.invalid.join(", ")} of dataset ${a.datasetId} are not declared or not allowed.`);
1401
+ if (!l.ok) return i("AGENT_DATASET_PARAM_REQUIRED", `Dataset ${a.datasetId} requires parameter(s) ${l.missing.map((e) => e.name).join(", ")} without a default; the KPI shows a placeholder.`, he(a, l.missing));
1402
+ let u = me(n.sink, a, l.params), d = e.unit ?? o.unit ?? "", f = d === "" ? e.label : n.language === "en" ? `${e.label} (${d})` : `${e.label}(${d})`;
1403
+ return n.pushText("指标名", f, t.label, {
1404
+ fontSize: 18,
1405
+ color: n.palette.muted
1406
+ }), n.push(s, "指标值", t.value, {
1407
+ style: we(s, {
1408
+ fontSize: 42,
1409
+ fontWeight: "700",
1410
+ color: n.palette.text
1411
+ }),
1412
+ dataValue: {
1413
+ kind: "data-source-field",
1414
+ dataSourceId: u,
1415
+ path: []
1416
+ },
1417
+ dataBinding: { fields: { [c.id]: [r.field] } }
1418
+ }), !0;
1419
+ }
1420
+ //#endregion
1421
+ //#region ../host-kit/dist/intent/intent-layout.js
1422
+ var Ge = 1920, Ke = 1080, qe = 1026, Je = 1.35, Ye = 1792, Xe = 430;
1423
+ function Ze(e) {
1424
+ let t = [], n = 24 * Math.max(0, e.length - 1), r = e.map(Qe);
1425
+ for (let [e, n] of r.entries()) if (n.kind === "band") {
1426
+ let r = rt(n.count);
1427
+ n.count > 0 && r < 240 && t.push({
1428
+ regionIndex: e,
1429
+ reason: "width",
1430
+ requiredPx: 240 * n.count + 24 * (n.count - 1),
1431
+ availablePx: Ye
1432
+ });
1433
+ }
1434
+ let i = r.reduce((e, t) => e + (t.kind === "band" ? t.height : 0), 0), a = r.flatMap((e, t) => e.kind === "band" ? [] : [{
1435
+ plan: e,
1436
+ index: t
1437
+ }]), o = 838 - n - i, s = a.reduce((e, t) => e + t.plan.minHeight, 0);
1438
+ if (a.length > 0 && s > o) {
1439
+ let e = a.reduce((e, t) => t.plan.minHeight > e.plan.minHeight ? t : e);
1440
+ t.push({
1441
+ regionIndex: e.index,
1442
+ reason: "height",
1443
+ requiredPx: s,
1444
+ availablePx: o
1445
+ });
1446
+ }
1447
+ if (t.length > 0) return {
1448
+ ok: !1,
1449
+ issues: t
1450
+ };
1451
+ let c = /* @__PURE__ */ new Map();
1452
+ if (a.length > 0) {
1453
+ let e = a.reduce((e, t) => e + t.plan.weight, 0) || 1, t = a.map((t) => Math.max(t.plan.minHeight, Math.floor(o * t.plan.weight / e))), n = t.reduce((e, t) => e + t, 0) - o;
1454
+ for (; n > 0;) {
1455
+ let e = 0;
1456
+ t.forEach((n, r) => {
1457
+ n > (t[e] ?? 0) && (e = r);
1458
+ });
1459
+ let r = (t[e] ?? 0) - (a[e]?.plan.minHeight ?? 0);
1460
+ if (r <= 0) break;
1461
+ let i = Math.min(r, n);
1462
+ t[e] = (t[e] ?? 0) - i, n -= i;
1463
+ }
1464
+ a.forEach((e, n) => c.set(e.index, t[n] ?? e.plan.minHeight));
1465
+ }
1466
+ let l = [], u = 172;
1467
+ for (let [e, t] of r.entries()) {
1468
+ let n = t.kind === "band" ? t.height : c.get(e) ?? t.minHeight;
1469
+ l.push(tt(t, u, n)), u += n + 24;
1470
+ }
1471
+ return {
1472
+ ok: !0,
1473
+ regions: l
1474
+ };
1475
+ }
1476
+ function Qe(e) {
1477
+ if (e.kind === "band") return {
1478
+ kind: "band",
1479
+ count: e.count,
1480
+ height: 148
1481
+ };
1482
+ if (e.kind === "grid") {
1483
+ let t = at(e.slots.map((e, t) => ({
1484
+ ...e,
1485
+ index: t
1486
+ })));
1487
+ return {
1488
+ kind: "grid",
1489
+ rows: t,
1490
+ weight: t.reduce((e, t) => e + $e(t), 0),
1491
+ minHeight: et(t.length)
1492
+ };
1493
+ }
1494
+ let t = (e) => e.reduce((e, t) => e + (t.data ? Je : 1), 0);
1495
+ return {
1496
+ kind: "split",
1497
+ region: e,
1498
+ weight: Math.max(t(e.main), t(e.rail)),
1499
+ minHeight: et(Math.max(e.main.length, e.rail.length))
1500
+ };
1501
+ }
1502
+ function $e(e) {
1503
+ return e.some((e) => e.data) ? Je : 1;
1504
+ }
1505
+ function et(e) {
1506
+ return e === 0 ? 0 : 120 * e + 24 * (e - 1);
1507
+ }
1508
+ function tt(e, t, n) {
1509
+ if (e.kind === "band") {
1510
+ let r = rt(e.count), i = [];
1511
+ for (let a = 0; a < e.count; a += 1) i.push({
1512
+ x: 64 + a * (r + 24),
1513
+ y: t,
1514
+ width: r,
1515
+ height: n
1516
+ });
1517
+ return {
1518
+ kind: "band",
1519
+ boxes: i
1520
+ };
1521
+ }
1522
+ if (e.kind === "grid") {
1523
+ let r = st(e.rows, n - 24 * (e.rows.length - 1)), i = Array(e.rows.reduce((e, t) => e + t.length, 0)), a = t;
1524
+ return e.rows.forEach((e, t) => {
1525
+ let n = ot(e), o = r[t] ?? 120, s = 0;
1526
+ e.forEach((e, t) => {
1527
+ let r = n[t] ?? 1;
1528
+ i[e.index] = {
1529
+ x: 64 + s * 454,
1530
+ y: a,
1531
+ width: Xe * r + 24 * (r - 1),
1532
+ height: o
1533
+ }, s += r;
1534
+ }), a += o + 24;
1535
+ }), {
1536
+ kind: "grid",
1537
+ boxes: i
1538
+ };
1539
+ }
1540
+ let { region: r } = e, i = r.ratio === "even" ? 884 : Xe, a = r.ratio === "even" ? i : 1768 - i, o = r.railSide === "left" ? 64 + i + 24 : 64, s = r.railSide === "left" ? 64 : 64 + a + 24;
1541
+ return {
1542
+ kind: "split",
1543
+ main: nt(r.main, o, t, a, n),
1544
+ rail: nt(r.rail, s, t, i, n)
1545
+ };
1546
+ }
1547
+ function nt(e, t, n, r, i) {
1548
+ let a = e.map((e, t) => [{
1549
+ data: e.data,
1550
+ index: t
1551
+ }]), o = st(a, i - 24 * (a.length - 1)), s = [], c = n;
1552
+ for (let [e, n] of o.entries()) s[e] = {
1553
+ x: t,
1554
+ y: c,
1555
+ width: r,
1556
+ height: n
1557
+ }, c += n + 24;
1558
+ return s;
1559
+ }
1560
+ function rt(e) {
1561
+ return e <= 0 ? 0 : Math.floor((Ye - 24 * (e - 1)) / e);
1562
+ }
1563
+ function it(e) {
1564
+ return Number.isFinite(e) ? Math.min(4, Math.max(1, Math.round(e))) : 1;
1565
+ }
1566
+ function at(e) {
1567
+ let t = [], n = [], r = 0;
1568
+ for (let i of e) {
1569
+ let e = it(i.span);
1570
+ r + e > 4 && n.length > 0 && (t.push(n), n = [], r = 0), n.push(i), r += e;
1571
+ }
1572
+ return n.length > 0 && t.push(n), t;
1573
+ }
1574
+ function ot(e) {
1575
+ let t = e.map((e) => it(e.span)), n = 4 - t.reduce((e, t) => e + t, 0);
1576
+ if (n <= 0 || t.length === 0) return t;
1577
+ let r = t.map((e, t) => ({
1578
+ span: e,
1579
+ index: t
1580
+ })).sort((e, t) => t.span - e.span || e.index - t.index).map((e) => e.index), i = 0;
1581
+ for (; n > 0;) {
1582
+ let e = r[i % r.length];
1583
+ t[e] = (t[e] ?? 1) + 1, --n, i += 1;
1584
+ }
1585
+ return t;
1586
+ }
1587
+ function st(e, t) {
1588
+ if (e.length === 0) return [];
1589
+ let n = Math.max(120, Math.min(200, Math.floor(t / e.length))), r = e.map($e), i = r.reduce((e, t) => e + t, 0) || 1, a = r.map((e) => Math.max(n, Math.floor(t * e / i))), o = a.reduce((e, t) => e + t, 0) - t;
1590
+ for (; o > 0;) {
1591
+ let e = 0;
1592
+ a.forEach((t, n) => {
1593
+ t > (a[e] ?? 0) && (e = n);
1594
+ });
1595
+ let t = (a[e] ?? 0) - n;
1596
+ if (t <= 0) break;
1597
+ let r = Math.min(t, o);
1598
+ a[e] = (a[e] ?? 0) - r, o -= r;
1599
+ }
1600
+ return a;
1601
+ }
1602
+ //#endregion
1603
+ //#region ../host-kit/dist/intent/intent-style.js
1604
+ var ct = [
1605
+ "deep-tech",
1606
+ "light-biz",
1607
+ "warm-care",
1608
+ "ink-finance"
1609
+ ], lt = {
1610
+ "deep-tech": {
1611
+ id: "deep-tech",
1612
+ label: "深色科技(深蓝底、冷色强调,适合监控、实时、指挥类)",
1613
+ palette: {
1614
+ canvas: "#0b1020",
1615
+ card: "#141b24",
1616
+ text: "#e9eef5",
1617
+ muted: "#c6d3e4",
1618
+ accent: "#4fcb6f",
1619
+ footer: "#8a97a8"
1620
+ }
1621
+ },
1622
+ "light-biz": {
1623
+ id: "light-biz",
1624
+ label: "浅色商务(浅灰底、白卡片、蓝色强调,适合经营分析、财务、报表类)",
1625
+ palette: {
1626
+ canvas: "#f4f6fa",
1627
+ card: "#ffffff",
1628
+ text: "#0f172a",
1629
+ muted: "#4a5a70",
1630
+ accent: "#1a63c4",
1631
+ footer: "#5b6b82"
1632
+ }
1633
+ },
1634
+ "warm-care": {
1635
+ id: "warm-care",
1636
+ label: "暖色人文(深棕底、暖色强调,适合医疗、民生、服务类)",
1637
+ palette: {
1638
+ canvas: "#1f1a17",
1639
+ card: "#2a221e",
1640
+ text: "#f6efe8",
1641
+ muted: "#d9c7b5",
1642
+ accent: "#f0a04b",
1643
+ footer: "#b3a291"
1644
+ }
1645
+ },
1646
+ "ink-finance": {
1647
+ id: "ink-finance",
1648
+ label: "墨黑金(黑底、金色强调,适合高管看板、汇总、战略类)",
1649
+ palette: {
1650
+ canvas: "#0e1116",
1651
+ card: "#171c24",
1652
+ text: "#eef1f5",
1653
+ muted: "#b8c2d1",
1654
+ accent: "#e8b84a",
1655
+ footer: "#8f9aab"
1656
+ }
1657
+ }
1658
+ }, ut = "deep-tech";
1659
+ function dt(e) {
1660
+ if (typeof e == "string") {
1661
+ let t = ct.find((t) => t === e.trim());
1662
+ if (t !== void 0) return lt[t];
1663
+ }
1664
+ return lt[ut];
1665
+ }
1666
+ //#endregion
1667
+ //#region ../host-kit/dist/intent/intent-compile.js
1668
+ var ft = 5, pt = 20;
1669
+ function mt(e) {
1670
+ let { catalog: t, references: n, stream: r } = e, i = r === void 0 ? M(e.intent, n) : void 0, a = i?.intent ?? e.intent, o = dt(a.style).palette, s = Ie(a.title, a.subtitle), c = {
1671
+ diagnostics: [],
1672
+ warnings: [...i?.warnings ?? []],
1673
+ dataSources: []
1674
+ }, l = r === void 0 ? vt(a) : yt(r), u = Ze(l.map((e) => e.layout));
1675
+ if (!u.ok) return {
1676
+ ok: !1,
1677
+ diagnostics: u.issues.map((e) => xt(e, l))
1678
+ };
1679
+ let d = [], f = {}, p = "", m = "", h = (e, t = e) => {
1680
+ p = e, m = t;
1681
+ }, g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Map(), v = 0, y = De(t), b = Me(t), x = Ne(t), S = null, C = !1, w = (e, t, n, r = {}) => {
1682
+ let i = r.pending === !0, a = kt(p), o = i ? a.pendingOffset : _.get(p) ?? 0;
1683
+ i || _.set(p, o + 1);
1684
+ let s = i ? `agent-${a.key}-pending` : `agent-${a.key}-${o}`;
1685
+ return f[s] = m, d.push({
1686
+ id: s,
1687
+ type: e.type,
1688
+ name: t,
1689
+ parentId: r.parentId === void 0 ? S : r.parentId,
1690
+ position: {
1691
+ x: Math.round(n.x),
1692
+ y: Math.round(n.y)
1693
+ },
1694
+ size: {
1695
+ width: Math.max(1, Math.round(n.width)),
1696
+ height: Math.max(1, Math.round(n.height))
1697
+ },
1698
+ rotation: 0,
1699
+ zIndex: a.layer + o,
1700
+ status: {
1701
+ locked: !1,
1702
+ hidden: !1
1703
+ },
1704
+ props: {
1705
+ ...e.defaults.props,
1706
+ ...r.props
1707
+ },
1708
+ style: Et({
1709
+ ...e.defaults.style,
1710
+ ...r.style
1711
+ }),
1712
+ dataSource: null,
1713
+ dataValue: r.dataValue ?? null,
1714
+ ...r.dataBinding === void 0 ? {} : { dataBinding: r.dataBinding }
1715
+ }), g.add(e.type), s;
1716
+ }, T = (e, t) => {
1717
+ if (x === void 0) {
1718
+ C = !0;
1719
+ return;
1720
+ }
1721
+ S = w(x, e, t, { parentId: null });
1722
+ }, E = () => {
1723
+ S = null;
1724
+ }, D = (e, t, n, r = {}, i = !1) => {
1725
+ y !== void 0 && t !== "" && w(y, e, n, {
1726
+ style: we(y, {
1727
+ color: o.text,
1728
+ ...r
1729
+ }),
1730
+ dataValue: i ? {
1731
+ kind: "inline",
1732
+ value: t,
1733
+ sample: !0
1734
+ } : {
1735
+ kind: "inline",
1736
+ value: t
1737
+ }
1738
+ });
1739
+ }, O = (e, t, n, r = !1) => {
1740
+ b !== void 0 && w(b, e, t, {
1741
+ style: {
1742
+ fill: o.card,
1743
+ ...n ?? {}
1744
+ },
1745
+ ...r ? { pending: !0 } : {}
1746
+ });
1747
+ };
1748
+ h("title"), D("标题", a.title, {
1749
+ x: 64,
1750
+ y: 44,
1751
+ width: 1200,
1752
+ height: 62
1753
+ }, {
1754
+ fontSize: 46,
1755
+ fontWeight: "700"
1756
+ }), h("subtitle"), D("副标题", a.subtitle, {
1757
+ x: 64,
1758
+ y: 112,
1759
+ width: 1400,
1760
+ height: 30
1761
+ }, {
1762
+ fontSize: 20,
1763
+ color: o.muted
1764
+ });
1765
+ let k = Ct(o.card), A = {
1766
+ catalog: t,
1767
+ textMaterial: y,
1768
+ push: w,
1769
+ pushText: D,
1770
+ references: n,
1771
+ palette: o,
1772
+ beginShell: T,
1773
+ endShell: E
1774
+ }, j = {
1775
+ sink: c,
1776
+ onAsset: () => v += 1
1777
+ }, N = (e, t) => {
1778
+ h(e.path, e.block?.origin ?? e.path), e.block === void 0 ? O("占位", t, k, !0) : ge(e.block, t, A, j);
1779
+ };
1780
+ for (let [t, r] of l.entries()) {
1781
+ let i = u.regions[t];
1782
+ r.kind === "band" && i.kind === "band" ? r.kpis.forEach((t, r) => {
1783
+ let a = i.boxes[r];
1784
+ if (h(t.path, t.kpi?.origin ?? t.path), T("指标卡", a), O(x === void 0 ? "指标卡" : "底板", a, k), t.kpi !== void 0) {
1785
+ let r = t.kpi, i = a.x + pt, l = a.width - 40;
1786
+ r.bind !== void 0 && We(r, {
1787
+ label: {
1788
+ x: i,
1789
+ y: a.y + 18,
1790
+ width: l,
1791
+ height: 26
1792
+ },
1793
+ value: {
1794
+ x: i,
1795
+ y: a.y + 50,
1796
+ width: l,
1797
+ height: 54
1798
+ }
1799
+ }, {
1800
+ textMaterial: y,
1801
+ references: n,
1802
+ sink: c,
1803
+ palette: o,
1804
+ language: s,
1805
+ push: w,
1806
+ pushText: D
1807
+ }) || St(r, a, o, e.mode, s, D);
1808
+ }
1809
+ E();
1810
+ }) : r.kind === "grid" && i.kind === "grid" ? r.blocks.forEach((e, t) => N(e, i.boxes[t])) : r.kind === "split" && i.kind === "split" && (r.main.forEach((e, t) => N(e, i.main[t])), r.rail.forEach((e, t) => N(e, i.rail[t])));
1811
+ }
1812
+ let P = e.mode === "llm" ? s === "en" ? "model output" : "模型输出" : e.mode === "deterministic" ? s === "en" ? "deterministic fallback · model not called" : "确定性兜底 · 未调用模型" : "";
1813
+ if (h(""), D("页脚", s === "en" ? `Generated by the sample agent${P === "" ? "" : ` · ${P}`} · component catalog from the host designer (${t.materials.length} materials)` : `生成自示例智能体${P === "" ? "" : ` · ${P}`} · 组件目录来自宿主设计器(${t.materials.length} 种可用物料)`, {
1814
+ x: 64,
1815
+ y: qe,
1816
+ width: 1600,
1817
+ height: 26
1818
+ }, {
1819
+ fontSize: Tt,
1820
+ color: o.footer
1821
+ }), C && c.warnings.push({
1822
+ severity: "warning",
1823
+ code: "INTENT_SHELL_UNAVAILABLE",
1824
+ path: "",
1825
+ message: "The catalog has no material that can hold child components, so cards and blocks were laid out flat instead of as movable groups."
1826
+ }), c.diagnostics.length > 0) return {
1827
+ ok: !1,
1828
+ diagnostics: c.diagnostics
1829
+ };
1830
+ let F = r === void 0 ? ee({
1831
+ intent: a,
1832
+ catalog: t,
1833
+ references: n,
1834
+ capabilities: e.capabilities,
1835
+ language: s,
1836
+ components: d,
1837
+ dataSources: c.dataSources,
1838
+ sources: f,
1839
+ warnings: c.warnings
1840
+ }) : void 0;
1841
+ return d.length === 0 ? {
1842
+ ok: !1,
1843
+ diagnostics: [{
1844
+ severity: "error",
1845
+ code: "AGENT_CATALOG_UNUSABLE",
1846
+ path: "catalog",
1847
+ message: "The catalog has no basic material to lay out with (text / surface / asset)."
1848
+ }]
1849
+ } : {
1850
+ ok: !0,
1851
+ value: {
1852
+ imageCount: v,
1853
+ materials: [...g],
1854
+ warnings: c.warnings,
1855
+ sources: f,
1856
+ behaviors: F?.behaviors ?? [],
1857
+ document: {
1858
+ canvas: {
1859
+ width: Ge,
1860
+ height: Ke,
1861
+ backgroundColor: o.canvas
1862
+ },
1863
+ components: d,
1864
+ variables: F?.variables ?? [],
1865
+ ...c.dataSources.length === 0 ? {} : { dataSources: c.dataSources },
1866
+ blueprint: F?.blueprint ?? {
1867
+ nodes: [],
1868
+ edges: []
1869
+ }
1870
+ }
1871
+ }
1872
+ };
1873
+ }
1874
+ function ht(e, t) {
1875
+ return e.origin === "kpis" || e.origin === "blocks" ? e.origin : `regions[${t}]`;
1876
+ }
1877
+ function gt(e, t, n) {
1878
+ return e === "kpis" || e === "blocks" ? `${e}[${n}]` : `${e}.${t}[${n}]`;
1879
+ }
1880
+ var _t = (e) => e.bind.kind === "table" || e.bind.kind === "dataset";
1881
+ function vt(e) {
1882
+ return e.regions.map((e, t) => {
1883
+ let n = ht(e, t), r = (e, t) => e.map((e, r) => ({
1884
+ path: e.ident ?? gt(n, t, r),
1885
+ block: e
1886
+ }));
1887
+ if (e.kind === "band") {
1888
+ let t = n === "kpis" ? e.items.slice(0, ft) : e.items;
1889
+ return {
1890
+ kind: "band",
1891
+ path: n,
1892
+ origin: e.origin,
1893
+ layout: {
1894
+ kind: "band",
1895
+ count: t.length
1896
+ },
1897
+ kpis: t.map((e, t) => ({
1898
+ path: e.ident ?? gt(n, "items", t),
1899
+ kpi: e
1900
+ }))
1901
+ };
1902
+ }
1903
+ return e.kind === "grid" ? {
1904
+ kind: "grid",
1905
+ path: n,
1906
+ origin: e.origin,
1907
+ layout: {
1908
+ kind: "grid",
1909
+ slots: e.blocks.map((e) => ({
1910
+ span: e.span,
1911
+ data: _t(e)
1912
+ }))
1913
+ },
1914
+ blocks: r(e.blocks, "blocks")
1915
+ } : {
1916
+ kind: "split",
1917
+ path: n,
1918
+ origin: e.origin,
1919
+ layout: {
1920
+ kind: "split",
1921
+ ratio: e.ratio,
1922
+ railSide: e.railSide,
1923
+ main: e.main.map((e) => ({ data: _t(e) })),
1924
+ rail: e.rail.map((e) => ({ data: _t(e) }))
1925
+ },
1926
+ main: r(e.main, "main"),
1927
+ rail: r(e.rail, "rail")
1928
+ };
1929
+ });
1930
+ }
1931
+ function yt(e) {
1932
+ let { skeleton: t } = e;
1933
+ return t.regions.map((n, r) => {
1934
+ let i = bt(t, n, r), a = (t, n) => Array.from({ length: t }, (t, r) => {
1935
+ let a = gt(i, n, r);
1936
+ return {
1937
+ path: a,
1938
+ block: e.blocks[a]
1939
+ };
1940
+ });
1941
+ if (n.kind === "band") {
1942
+ let r = t.flat === !0 ? Math.min(n.count, ft) : n.count;
1943
+ return {
1944
+ kind: "band",
1945
+ path: i,
1946
+ origin: i,
1947
+ layout: {
1948
+ kind: "band",
1949
+ count: r
1950
+ },
1951
+ kpis: Array.from({ length: r }, (t, n) => {
1952
+ let r = gt(i, "items", n);
1953
+ return {
1954
+ path: r,
1955
+ kpi: e.kpis[r]
1956
+ };
1957
+ })
1958
+ };
1959
+ }
1960
+ return n.kind === "grid" ? {
1961
+ kind: "grid",
1962
+ path: i,
1963
+ origin: i,
1964
+ layout: {
1965
+ kind: "grid",
1966
+ slots: n.slots
1967
+ },
1968
+ blocks: a(n.slots.length, "blocks")
1969
+ } : {
1970
+ kind: "split",
1971
+ path: i,
1972
+ origin: i,
1973
+ layout: n,
1974
+ main: a(n.main.length, "main"),
1975
+ rail: a(n.rail.length, "rail")
1976
+ };
1977
+ });
1978
+ }
1979
+ function bt(e, t, n) {
1980
+ return e.flat === !0 ? t.kind === "band" ? "kpis" : "blocks" : `regions[${n}]`;
1981
+ }
1982
+ function xt(e, t) {
1983
+ return {
1984
+ severity: "error",
1985
+ code: "LAYOUT_CAPACITY_EXCEEDED",
1986
+ path: t[e.regionIndex]?.origin ?? "",
1987
+ message: e.reason === "width" ? `The band needs ${e.requiredPx}px to keep every card at least 240px wide, but only ${e.availablePx}px is available; use fewer cards.` : `The regions need ${e.requiredPx}px of height but only ${e.availablePx}px is available (short by ${e.requiredPx - e.availablePx}px); use fewer blocks.`
1988
+ };
1989
+ }
1990
+ function St(e, t, n, r, i, a) {
1991
+ let o = t.width - 40, s = t.x + pt;
1992
+ a("指标名", e.label, {
1993
+ x: s,
1994
+ y: t.y + 18,
1995
+ width: o,
1996
+ height: 26
1997
+ }, {
1998
+ fontSize: 18,
1999
+ color: n.muted
2000
+ }), a("指标值", Le(e, i), {
2001
+ x: s,
2002
+ y: t.y + 50,
2003
+ width: o,
2004
+ height: 54
2005
+ }, {
2006
+ fontSize: 42,
2007
+ fontWeight: "700",
2008
+ color: n.text
2009
+ }, r === "llm" && e.value !== null), e.delta !== void 0 && a("同比", Re(e, i), {
2010
+ x: s,
2011
+ y: t.y + 108,
2012
+ width: o,
2013
+ height: 24
2014
+ }, {
2015
+ fontSize: 16,
2016
+ color: Be(e.delta, n)
2017
+ });
2018
+ }
2019
+ function Ct(e) {
2020
+ let t = e === void 0 ? null : wt(e);
2021
+ if (t === null) return {};
2022
+ let n = Math.max(...t), r = Math.min(...t);
2023
+ if (n === 0) return {};
2024
+ let i = (n + r) / 510;
2025
+ return (n - r) / (n + r === 0 ? 1 : 255 - Math.abs(n + r - 255)) < .45 || i > .6 ? {} : { opacity: .3 };
2026
+ }
2027
+ function wt(e) {
2028
+ let t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
2029
+ if (t === null) return null;
2030
+ let n = t[1], r = n.length === 3 ? [...n].map((e) => e + e).join("") : n;
2031
+ return [
2032
+ Number.parseInt(r.slice(0, 2), 16),
2033
+ Number.parseInt(r.slice(2, 4), 16),
2034
+ Number.parseInt(r.slice(4, 6), 16)
2035
+ ];
2036
+ }
2037
+ var Tt = p(Ge);
2038
+ function Et(e) {
2039
+ let t = e.fontSize;
2040
+ return typeof t == "number" && t < Tt ? {
2041
+ ...e,
2042
+ fontSize: Tt
2043
+ } : e;
2044
+ }
2045
+ var Dt = {
2046
+ items: "k",
2047
+ blocks: "b",
2048
+ main: "m",
2049
+ rail: "s"
2050
+ }, Ot = {
2051
+ items: 0,
2052
+ blocks: 0,
2053
+ main: 0,
2054
+ rail: 64
2055
+ };
2056
+ function kt(e) {
2057
+ if (e === "title") return {
2058
+ key: "title",
2059
+ layer: 1,
2060
+ pendingOffset: 19
2061
+ };
2062
+ if (e === "subtitle") return {
2063
+ key: "subtitle",
2064
+ layer: 2,
2065
+ pendingOffset: 19
2066
+ };
2067
+ if (e === "") return {
2068
+ key: "footer",
2069
+ layer: 1e3,
2070
+ pendingOffset: 19
2071
+ };
2072
+ let t = /^(kpis|blocks)\[(\d+)\]$/.exec(e);
2073
+ if (t !== null) {
2074
+ let e = Number(t[2]);
2075
+ return t[1] === "kpis" ? {
2076
+ key: `kpi-${e}`,
2077
+ layer: 10 + e * 10,
2078
+ pendingOffset: 19
2079
+ } : {
2080
+ key: `block-${e}`,
2081
+ layer: 100 + e * 20,
2082
+ pendingOffset: 19
2083
+ };
2084
+ }
2085
+ let n = /^regions\[(\d+)\]\.(items|blocks|main|rail)\[(\d+)\]$/.exec(e);
2086
+ if (n !== null) {
2087
+ let e = n[2], t = Number(n[1]), r = Number(n[3]);
2088
+ return {
2089
+ key: `r${t}-${Dt[e]}${r}`,
2090
+ layer: 100 + t * 140 + Ot[e] + r * 8,
2091
+ pendingOffset: 7
2092
+ };
2093
+ }
2094
+ return {
2095
+ key: e,
2096
+ layer: 1e3,
2097
+ pendingOffset: 19
2098
+ };
2099
+ }
2100
+ //#endregion
2101
+ //#region ../host-kit/dist/intent/intent-compile-types.js
2102
+ function At(e, t) {
2103
+ let n = [];
2104
+ return e > 0 && n.push({
2105
+ kind: "band",
2106
+ count: e
2107
+ }), t.length > 0 && n.push({
2108
+ kind: "grid",
2109
+ slots: t
2110
+ }), {
2111
+ regions: n,
2112
+ flat: !0
2113
+ };
2114
+ }
2115
+ //#endregion
2116
+ //#region ../host-kit/dist/intent/intent-data-context.js
2117
+ function jt(e, t) {
2118
+ let n = Object.keys(t).sort().map((e) => [e, t[e]]);
2119
+ return JSON.stringify([e, n]);
2120
+ }
2121
+ var Mt = 4, Nt = [
2122
+ "string",
2123
+ "number",
2124
+ "boolean",
2125
+ "date"
2126
+ ];
2127
+ async function Pt(e) {
2128
+ let t = [], n = [...new Set(e.datasetIds)];
2129
+ n.length > 4 && t.push({
2130
+ severity: "warning",
2131
+ code: "AGENT_DATASETS_TRIMMED",
2132
+ path: "",
2133
+ message: "Only the first 4 referenced datasets are profiled."
2134
+ });
2135
+ let r = n.slice(0, 4).map(() => []), i = await Promise.all(n.slice(0, 4).map((t, n) => Ft(t, n, e, r[n] ?? [])));
2136
+ for (let e of r) t.push(...e);
2137
+ let a = i.filter((e) => e !== void 0), o = a.map((e) => e.profile), s = l(o, Lt(e.catalog), { maxPerDataset: e.maxCandidatesPerDataset ?? 12 }), c = /* @__PURE__ */ new Map();
2138
+ for (let e of a) e.sample !== void 0 && c.set(e.sample.key, e.sample.value);
2139
+ return {
2140
+ profiles: o,
2141
+ samples: c,
2142
+ candidates: s.map((e) => ({
2143
+ id: e.id,
2144
+ fact: e.fact,
2145
+ datasetId: e.datasetId,
2146
+ type: e.type,
2147
+ fields: e.fields
2148
+ })),
2149
+ references: a.map((e) => Bt(e.definition, e.profile, e.sample?.value)),
2150
+ warnings: t
2151
+ };
2152
+ }
2153
+ async function Ft(e, t, n, r) {
2154
+ let i = new AbortController(), a = () => i.abort();
2155
+ n.signal.aborted ? a() : n.signal.addEventListener("abort", a, { once: !0 });
2156
+ let o = setTimeout(a, n.timeoutMs ?? 3e3);
2157
+ try {
2158
+ let a = await n.port.describe({
2159
+ datasetId: e,
2160
+ signal: i.signal
2161
+ });
2162
+ if (!a.ok) {
2163
+ r.push(It("AGENT_DATASET_UNKNOWN", e, "describe failed"));
2164
+ return;
2165
+ }
2166
+ let o = a.value, s = {}, c = !1;
2167
+ for (let e of o.parameters) if (e.defaultValue !== void 0) s[e.name] = e.defaultValue;
2168
+ else if (e.required) {
2169
+ let t = e.allowedValues?.[0];
2170
+ t === void 0 ? c = !0 : s[e.name] = t;
2171
+ }
2172
+ if (c) return {
2173
+ definition: o,
2174
+ profile: u(o)
2175
+ };
2176
+ let l;
2177
+ try {
2178
+ let r = await n.port.query({
2179
+ datasetId: e,
2180
+ dataSourceId: `agent-profile-${t + 1}`,
2181
+ params: s
2182
+ }, { signal: i.signal });
2183
+ r.ok && (l = r.value);
2184
+ } catch {
2185
+ l = void 0;
2186
+ }
2187
+ return l === void 0 && r.push(It("AGENT_DATASET_SAMPLE_UNAVAILABLE", e, "sample query failed")), {
2188
+ definition: o,
2189
+ profile: u(o, l),
2190
+ ...l === void 0 ? {} : { sample: {
2191
+ key: jt(e, s),
2192
+ value: l
2193
+ } }
2194
+ };
2195
+ } catch {
2196
+ r.push(It("AGENT_DATASET_UNKNOWN", e, "describe failed"));
2197
+ return;
2198
+ } finally {
2199
+ clearTimeout(o);
2200
+ }
2201
+ }
2202
+ function It(e, t, n) {
2203
+ return {
2204
+ severity: "warning",
2205
+ code: e,
2206
+ path: "",
2207
+ message: `Dataset ${t}: ${n}.`,
2208
+ detail: { datasetId: t }
2209
+ };
2210
+ }
2211
+ function Lt(e) {
2212
+ return e.materials.filter((e) => e.children !== !0 && e.roles.length > 0 && (e.data === "tabular" || e.data === "scalar")).map((e) => ({
2213
+ type: e.type,
2214
+ name: e.name,
2215
+ roles: e.roles.map((e) => ({
2216
+ id: e.id,
2217
+ minFields: e.min,
2218
+ maxFields: e.max,
2219
+ valueTypes: [...e.valueTypes ?? Nt]
2220
+ }))
2221
+ }));
2222
+ }
2223
+ var Rt = 24;
2224
+ function zt(e) {
2225
+ if (e === void 0 || e.rows.length === 0) return;
2226
+ let t = {};
2227
+ for (let n of e.fields) {
2228
+ let r = /* @__PURE__ */ new Set();
2229
+ for (let t of e.rows) {
2230
+ let e = t[n.id];
2231
+ if ((typeof e == "string" || typeof e == "number" || typeof e == "boolean") && (r.add(e), r.size >= Rt)) break;
2232
+ }
2233
+ r.size > 0 && (t[n.id] = [...r]);
2234
+ }
2235
+ return t;
2236
+ }
2237
+ function Bt(e, t, n) {
2238
+ let r = zt(n);
2239
+ return {
2240
+ datasetId: e.datasetId,
2241
+ name: e.name,
2242
+ columns: e.fields.map((e) => ({
2243
+ id: e.id,
2244
+ type: e.valueType,
2245
+ label: e.label,
2246
+ ...e.unit === void 0 ? {} : { unit: e.unit }
2247
+ })),
2248
+ parameters: e.parameters.map((e) => ({
2249
+ name: e.name,
2250
+ required: e.required,
2251
+ valueType: e.valueType,
2252
+ ...e.defaultValue === void 0 ? {} : { defaultValue: e.defaultValue },
2253
+ ...e.allowedValues === void 0 ? {} : { allowedValues: [...e.allowedValues] }
2254
+ })),
2255
+ ...r === void 0 ? {} : { values: r },
2256
+ ...t.sampled ? { rows: {
2257
+ sampled: t.rows.sampled,
2258
+ ...t.rows.total === void 0 ? {} : { total: t.rows.total }
2259
+ } } : {}
2260
+ };
2261
+ }
2262
+ function Vt(e) {
2263
+ return e.profiles.map((t) => ({
2264
+ datasetId: t.datasetId,
2265
+ profile: t,
2266
+ candidates: e.candidates.filter((e) => e.datasetId === t.datasetId)
2267
+ }));
2268
+ }
2269
+ //#endregion
2270
+ //#region ../host-kit/dist/intent/intent-data-check.js
2271
+ var Ht = /^(?:kpis\[\d+\]|regions\[\d+\]\.items\[\d+\])$/;
2272
+ async function Ut(e) {
2273
+ let t = Kt(e.document.dataSources ?? [], Gt(e.document.variables ?? [])), n = /* @__PURE__ */ new Set();
2274
+ for (let t of e.document.components) {
2275
+ let e = qt(t.dataValue);
2276
+ e !== void 0 && n.add(e);
2277
+ }
2278
+ let r = t.filter((e) => n.has(e.id));
2279
+ if (r.length === 0) return {
2280
+ issues: [],
2281
+ verified: [],
2282
+ unverified: [],
2283
+ empty: []
2284
+ };
2285
+ let i = /* @__PURE__ */ new Map(), a = [], o = [], s = [], c = await Promise.all(r.map(async (t, n) => ({
2286
+ instance: t,
2287
+ result: await Wt(t, n, e)
2288
+ })));
2289
+ for (let { instance: e, result: t } of c) t === void 0 ? o.push(e.name) : (i.set(e.id, t), a.push(e.name), t.rows.length === 0 && s.push(e.name));
2290
+ let l = [], u = /* @__PURE__ */ new Set(), d = (e, t) => {
2291
+ let n = `${e}@${t}`;
2292
+ u.has(n) || (u.add(n), l.push({
2293
+ code: e,
2294
+ path: t
2295
+ }));
2296
+ };
2297
+ for (let t of e.document.components) {
2298
+ let n = qt(t.dataValue), r = n === void 0 ? void 0 : i.get(n);
2299
+ if (r === void 0) continue;
2300
+ let a = e.sources[t.id] ?? "", o = Jt(t.dataBinding);
2301
+ if (r.rows.length === 0) continue;
2302
+ let s = new Set(r.fields.map((e) => e.id));
2303
+ if (o.some((e) => !s.has(e))) {
2304
+ d("DATA_FIELD_ABSENT", a);
2305
+ continue;
2306
+ }
2307
+ o.some((e) => r.rows.every((t) => Yt(t[e]))) && d("DATA_FIELD_ALL_NULL", a), Ht.test(a) && r.rows.length > 1 && d("AGENT_KPI_MULTI_ROW", a);
2308
+ }
2309
+ return {
2310
+ issues: l,
2311
+ verified: a,
2312
+ unverified: o,
2313
+ empty: s
2314
+ };
2315
+ }
2316
+ async function Wt(e, t, n) {
2317
+ let r = n.context?.samples.get(jt(e.datasetId, e.params));
2318
+ if (r !== void 0) return r;
2319
+ let i = new AbortController(), a = () => i.abort();
2320
+ if (n.signal.aborted) return;
2321
+ n.signal.addEventListener("abort", a, { once: !0 });
2322
+ let o = setTimeout(a, n.timeoutMs ?? 3e3);
2323
+ try {
2324
+ let r = await n.port.query({
2325
+ datasetId: e.datasetId,
2326
+ dataSourceId: `agent-check-${t + 1}`,
2327
+ params: { ...e.params }
2328
+ }, { signal: i.signal });
2329
+ return r.ok && !i.signal.aborted ? r.value : void 0;
2330
+ } catch {
2331
+ return;
2332
+ } finally {
2333
+ clearTimeout(o);
2334
+ }
2335
+ }
2336
+ function Gt(e) {
2337
+ let t = /* @__PURE__ */ new Map();
2338
+ for (let n of e) {
2339
+ let e = L(n);
2340
+ e !== null && typeof e.id == "string" && e.type === "static" && t.set(e.id, e.initialValue);
2341
+ }
2342
+ return t;
2343
+ }
2344
+ function Kt(e, t) {
2345
+ let n = [];
2346
+ for (let r of e) {
2347
+ let e = L(r), i = L(e?.source);
2348
+ if (e === null || i === null || i.kind !== "dataset" || typeof e.id != "string" || typeof i.datasetId != "string") continue;
2349
+ let a = {}, o = !0;
2350
+ for (let [n, r] of Object.entries(L(e.params) ?? {})) {
2351
+ let e = L(r), i = e?.kind === "inline" ? e.value : e?.kind === "variable" && typeof e.variableId == "string" ? t.get(e.variableId) : void 0;
2352
+ typeof i == "string" || typeof i == "number" || typeof i == "boolean" ? a[n] = i : o = !1;
2353
+ }
2354
+ o && n.push({
2355
+ id: e.id,
2356
+ name: typeof e.name == "string" && e.name !== "" ? e.name : i.datasetId,
2357
+ datasetId: i.datasetId,
2358
+ params: a
2359
+ });
2360
+ }
2361
+ return n;
2362
+ }
2363
+ function qt(e) {
2364
+ let t = L(e);
2365
+ return t?.kind === "data-source-field" && typeof t.dataSourceId == "string" ? t.dataSourceId : void 0;
2366
+ }
2367
+ function Jt(e) {
2368
+ let t = L(L(e)?.fields);
2369
+ return t === null ? [] : Object.values(t).flatMap((e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : []);
2370
+ }
2371
+ function Yt(e) {
2372
+ return e == null || e === "";
2373
+ }
2374
+ function L(e) {
2375
+ return typeof e == "object" && e && !Array.isArray(e) ? e : null;
2376
+ }
2377
+ //#endregion
2378
+ //#region ../host-kit/dist/intent/intent-parse.js
2379
+ var Xt = 20, Zt = 40, Qt = 12, $t = 6, en = 24, tn = 32, nn = 160, rn = 40, an = 4, on = 8, sn = 24, cn = 12, ln = 8, un = 80, dn = 5, fn = 8, pn = 6, mn = 8, hn = /[⺀-鿿豈-﫿＀-￯]/;
2380
+ function R(e, t) {
2381
+ return e.slice(0, hn.test(e) ? t : t * 2);
2382
+ }
2383
+ var gn = /* @__PURE__ */ new Set([
2384
+ "percent",
2385
+ "point",
2386
+ "absolute"
2387
+ ]), _n = /* @__PURE__ */ new Set([
2388
+ "up-good",
2389
+ "down-good",
2390
+ "neutral"
2391
+ ]), vn = /* @__PURE__ */ new Set(["wide-narrow", "even"]), yn = /* @__PURE__ */ new Set(["left", "right"]), bn = [
2392
+ "pages",
2393
+ "facts",
2394
+ "variables",
2395
+ "states"
2396
+ ];
2397
+ function xn(e, t) {
2398
+ let n = [], r = er(e);
2399
+ if (r === void 0) return nr(n, "AGENT_SPEC_INVALID", "", "Intent output must be a JSON object.");
2400
+ if (Object.prototype.hasOwnProperty.call(r, "panels")) return nr(n, "AGENT_SPEC_INVALID", "", "The legacy \"panels\" shape is not accepted.");
2401
+ let i = tr(r.title, Xt), a = tr(r.subtitle, Zt);
2402
+ if (i === "" || a === "") return nr(n, "AGENT_SPEC_INVALID", "", "Intent needs a non-empty title and subtitle.");
2403
+ for (let e of bn) Object.prototype.hasOwnProperty.call(r, e) && n.push({
2404
+ severity: "warning",
2405
+ code: "INTENT_PART_NOT_SUPPORTED",
2406
+ path: e,
2407
+ message: `The "${e}" part is reserved and is not compiled yet; it was ignored.`
2408
+ });
2409
+ let o = Object.prototype.hasOwnProperty.call(r, "regions"), s = "kpis" in r || "blocks" in r;
2410
+ if (o && s) return nr(n, "AGENT_SPEC_INVALID", "", "Use either \"regions\" or the flat \"kpis\" + \"blocks\" shape, not both.");
2411
+ let c = o ? Cn(r.regions, t.catalog, n, t.placeholders === !0) : Sn(r, t.catalog, n, t.placeholders === !0);
2412
+ if (c === void 0) return {
2413
+ intent: void 0,
2414
+ diagnostics: n
2415
+ };
2416
+ let l = typeof r.style == "string" ? r.style.trim() : void 0, u = Xn(r.interactions, n);
2417
+ Zn(r.gaps, n);
2418
+ let d = {
2419
+ title: i,
2420
+ subtitle: a,
2421
+ ...l === void 0 ? {} : { style: l },
2422
+ regions: c,
2423
+ ...u === void 0 ? {} : { interactions: u }
2424
+ };
2425
+ return c.some(kn) || n.push({
2426
+ severity: "error",
2427
+ code: "AGENT_BLOCKS_ALL_INVALID",
2428
+ path: "",
2429
+ message: "At least one usable block is required."
2430
+ }), {
2431
+ intent: d,
2432
+ diagnostics: n
2433
+ };
2434
+ }
2435
+ function Sn(e, t, n, r) {
2436
+ if (!Array.isArray(e.kpis) || !Array.isArray(e.blocks)) {
2437
+ rr(n, "AGENT_SPEC_INVALID", "Intent needs \"kpis\" and \"blocks\" arrays.");
2438
+ return;
2439
+ }
2440
+ let i = [];
2441
+ for (let [t, a] of e.kpis.slice(0, dn).entries()) {
2442
+ let e = z(a, `kpis[${t}]`, { placeholders: r });
2443
+ n.push(...e.diagnostics), e.value !== void 0 && i.push(e.value);
2444
+ }
2445
+ if (i.length < 1) {
2446
+ rr(n, "AGENT_SPEC_INVALID", "Intent needs at least one usable KPI.");
2447
+ return;
2448
+ }
2449
+ let a = [];
2450
+ for (let [r, i] of e.blocks.slice(0, fn).entries()) {
2451
+ let e = B(i, t, `blocks[${r}]`, { grid: !0 });
2452
+ n.push(...e.diagnostics), e.value !== void 0 && a.push(e.value);
2453
+ }
2454
+ let o = [{
2455
+ kind: "band",
2456
+ items: i,
2457
+ origin: "kpis"
2458
+ }];
2459
+ return a.length > 0 && o.push({
2460
+ kind: "grid",
2461
+ blocks: a,
2462
+ origin: "blocks"
2463
+ }), o;
2464
+ }
2465
+ function Cn(e, t, n, r) {
2466
+ if (!Array.isArray(e) || e.length === 0) {
2467
+ rr(n, "AGENT_SPEC_INVALID", "Intent needs a non-empty \"regions\" array.");
2468
+ return;
2469
+ }
2470
+ let i = [];
2471
+ for (let [a, o] of e.slice(0, pn).entries()) {
2472
+ let e = wn(o, t, `regions[${a}]`, n, r);
2473
+ e !== void 0 && i.push(e);
2474
+ }
2475
+ if (e.length > pn && n.push({
2476
+ severity: "warning",
2477
+ code: "INTENT_ITEMS_TRIMMED",
2478
+ path: "regions",
2479
+ message: `Only the first ${pn} regions are kept.`
2480
+ }), i.length === 0) {
2481
+ rr(n, "AGENT_SPEC_INVALID", "No usable region is left.");
2482
+ return;
2483
+ }
2484
+ return i;
2485
+ }
2486
+ function wn(e, t, n, r, i) {
2487
+ let a = V(e), o = a?.kind;
2488
+ if (a === null || o !== "band" && o !== "grid" && o !== "split") {
2489
+ r.push(On(n, "A region must be an object with kind \"band\", \"grid\" or \"split\"."));
2490
+ return;
2491
+ }
2492
+ if (o === "band") {
2493
+ let e = En(a.items, n, "items", r);
2494
+ if (e === void 0) return;
2495
+ let t = [];
2496
+ for (let [a, o] of e.entries()) {
2497
+ let e = z(o, `${n}.items[${a}]`, { placeholders: i });
2498
+ r.push(...e.diagnostics), e.value !== void 0 && t.push(e.value);
2499
+ }
2500
+ return t.length === 0 ? void 0 : {
2501
+ kind: "band",
2502
+ items: t,
2503
+ origin: n
2504
+ };
2505
+ }
2506
+ if (o === "grid") {
2507
+ let e = Tn(a.blocks, t, n, "blocks", !0, r);
2508
+ return e === void 0 || e.length === 0 ? void 0 : {
2509
+ kind: "grid",
2510
+ blocks: e,
2511
+ origin: n
2512
+ };
2513
+ }
2514
+ let s = Dn(a.ratio, vn, "wide-narrow", `${n}.ratio`, r), c = Dn(a.railSide, yn, "right", `${n}.railSide`, r), l = Tn(a.main, t, n, "main", !1, r), u = Tn(a.rail, t, n, "rail", !1, r);
2515
+ if (l !== void 0 && u !== void 0 && l.length !== 0 && u.length !== 0) return {
2516
+ kind: "split",
2517
+ ratio: s,
2518
+ railSide: c,
2519
+ main: l,
2520
+ rail: u,
2521
+ origin: n
2522
+ };
2523
+ }
2524
+ function Tn(e, t, n, r, i, a) {
2525
+ let o = En(e, n, r, a);
2526
+ if (o === void 0) return;
2527
+ let s = [];
2528
+ for (let [e, c] of o.entries()) {
2529
+ let o = B(c, t, `${n}.${r}[${e}]`, { grid: i });
2530
+ a.push(...o.diagnostics), o.value !== void 0 && s.push(o.value);
2531
+ }
2532
+ return s;
2533
+ }
2534
+ function En(e, t, n, r) {
2535
+ if (!Array.isArray(e) || e.length === 0) {
2536
+ r.push(On(t, `"${n}" must be a non-empty array.`));
2537
+ return;
2538
+ }
2539
+ return e.length > mn && r.push({
2540
+ severity: "warning",
2541
+ code: "INTENT_ITEMS_TRIMMED",
2542
+ path: `${t}.${n}`,
2543
+ message: `Only the first ${mn} items are kept.`
2544
+ }), e.slice(0, mn);
2545
+ }
2546
+ function Dn(e, t, n, r, i) {
2547
+ return e === void 0 ? n : typeof e == "string" && t.has(e) ? e : (i.push({
2548
+ severity: "warning",
2549
+ code: "INTENT_REGION_VALUE_DEFAULTED",
2550
+ path: r,
2551
+ message: `Unknown value; "${n}" was used instead.`
2552
+ }), n);
2553
+ }
2554
+ function On(e, t) {
2555
+ return {
2556
+ severity: "error",
2557
+ code: "INTENT_REGION_INVALID",
2558
+ path: e,
2559
+ message: t
2560
+ };
2561
+ }
2562
+ function kn(e) {
2563
+ return e.kind === "grid" ? e.blocks.length > 0 : e.kind === "split" ? e.main.length > 0 || e.rail.length > 0 : !1;
2564
+ }
2565
+ function z(e, t, n = {}) {
2566
+ let r = An(e, t, n);
2567
+ if (r.value === void 0) return r;
2568
+ let i = V(e) ?? {}, a = [...r.diagnostics], o = Jn(i.key, t, a), s = Yn(i.states, t, a);
2569
+ return {
2570
+ value: {
2571
+ ...r.value,
2572
+ ...o === void 0 ? {} : { key: o },
2573
+ ...s === void 0 ? {} : { states: s }
2574
+ },
2575
+ diagnostics: a
2576
+ };
2577
+ }
2578
+ function An(e, t, n) {
2579
+ let r = [], i = V(e), a = typeof i?.label == "string" ? i.label.trim() : "";
2580
+ if (i !== null && i.bind !== void 0) return jn(i, a, t);
2581
+ let o = i?.value, s = o === null && n.placeholders === !0;
2582
+ if (i === null || a === "" || !s && (typeof o != "number" || !Number.isFinite(o))) return r.push({
2583
+ severity: "error",
2584
+ code: "AGENT_KPI_INVALID",
2585
+ path: t,
2586
+ message: "A KPI needs a non-empty label and a finite numeric value."
2587
+ }), {
2588
+ value: void 0,
2589
+ diagnostics: r
2590
+ };
2591
+ let c = typeof i.unit == "string" ? i.unit.trim().slice(0, $t) : "", l = typeof i.precision == "number" && Number.isInteger(i.precision) ? Math.min(3, Math.max(0, i.precision)) : void 0, u = Pn(i.delta);
2592
+ return i.delta !== void 0 && u === void 0 && r.push({
2593
+ severity: "error",
2594
+ code: "AGENT_KPI_DELTA_DROPPED",
2595
+ path: t,
2596
+ message: "The delta needs a finite value, a unit and a direction; only the value was kept."
2597
+ }), {
2598
+ value: {
2599
+ label: R(a, Qt),
2600
+ value: s ? null : o,
2601
+ ...c === "" ? {} : { unit: c },
2602
+ ...l === void 0 ? {} : { precision: l },
2603
+ ...u === void 0 ? {} : { delta: u },
2604
+ origin: t
2605
+ },
2606
+ diagnostics: r
2607
+ };
2608
+ }
2609
+ function jn(e, t, n) {
2610
+ let r = [], i = (e, t) => (r.push({
2611
+ severity: "error",
2612
+ code: e,
2613
+ path: n,
2614
+ message: t
2615
+ }), {
2616
+ value: void 0,
2617
+ diagnostics: r
2618
+ }), a = V(e.bind), o = typeof a?.datasetId == "string" ? a.datasetId.trim() : "", s = typeof a?.field == "string" ? a.field.trim() : "";
2619
+ if (t === "" || a === null || o === "" || s === "") return i("AGENT_KPI_INVALID", "A bound KPI needs a label, bind.datasetId and bind.field.");
2620
+ if (e.value !== void 0 && e.value !== null || e.delta !== void 0) return i("AGENT_BIND_CONFLICT", "A KPI bound to a dataset field must not also give a literal value or delta.");
2621
+ let c = Nn(a.params);
2622
+ if (c === null) return i("AGENT_BIND_INVALID", "bind.params must map parameter names to scalar values.");
2623
+ e.precision !== void 0 && r.push({
2624
+ severity: "warning",
2625
+ code: "AGENT_KPI_PRECISION_IGNORED",
2626
+ path: n,
2627
+ message: "precision has no effect on a KPI bound to a dataset field."
2628
+ });
2629
+ let l = typeof e.unit == "string" ? e.unit.trim().slice(0, $t) : "";
2630
+ return {
2631
+ value: {
2632
+ label: R(t, Qt),
2633
+ value: null,
2634
+ ...l === "" ? {} : { unit: l },
2635
+ bind: {
2636
+ datasetId: o,
2637
+ field: s,
2638
+ ...c === void 0 ? {} : { params: c }
2639
+ },
2640
+ origin: n
2641
+ },
2642
+ diagnostics: r
2643
+ };
2644
+ }
2645
+ function Mn(e) {
2646
+ if (e === void 0) return;
2647
+ let t = V(e);
2648
+ if (t === null) return null;
2649
+ let n = {};
2650
+ for (let [e, r] of Object.entries(t)) {
2651
+ let t = typeof r == "string" ? [r] : r;
2652
+ if (!Array.isArray(t) || t.length === 0) return null;
2653
+ let i = t.map((e) => typeof e == "string" ? e.trim() : "");
2654
+ if (i.some((e) => e === "")) return null;
2655
+ n[e] = i;
2656
+ }
2657
+ return Object.keys(n).length === 0 ? void 0 : n;
2658
+ }
2659
+ function Nn(e) {
2660
+ if (e === void 0) return;
2661
+ let t = V(e);
2662
+ if (t === null) return null;
2663
+ let n = {};
2664
+ for (let [e, r] of Object.entries(t)) if (typeof r == "string" || typeof r == "boolean" || typeof r == "number" && Number.isFinite(r)) n[e] = r;
2665
+ else return null;
2666
+ return Object.keys(n).length === 0 ? void 0 : n;
2667
+ }
2668
+ function Pn(e) {
2669
+ let t = V(e);
2670
+ if (!(t === null || typeof t.value != "number" || !Number.isFinite(t.value) || typeof t.unit != "string" || !gn.has(t.unit) || typeof t.direction != "string" || !_n.has(t.direction))) return {
2671
+ value: t.value,
2672
+ unit: t.unit,
2673
+ direction: t.direction
2674
+ };
2675
+ }
2676
+ function B(e, t, n, r) {
2677
+ let i = [], a = (e, t) => (i.push({
2678
+ severity: "error",
2679
+ code: e,
2680
+ path: n,
2681
+ message: t
2682
+ }), {
2683
+ value: void 0,
2684
+ diagnostics: i
2685
+ }), o = (e, t, r = n) => {
2686
+ i.push({
2687
+ severity: "warning",
2688
+ code: e,
2689
+ path: r,
2690
+ message: t
2691
+ });
2692
+ }, s = V(e);
2693
+ if (s === null) return a("AGENT_BLOCK_INVALID", "A block must be an object.");
2694
+ let c = typeof s.candidate == "string" ? s.candidate.trim() : "", l = c === "" ? void 0 : t.candidates?.find((e) => e.id === c);
2695
+ if (c !== "" && l === void 0) return a("AGENT_CANDIDATE_UNKNOWN", `Candidate ${c} is not in this round's list.`);
2696
+ if (l?.fact === "value") return a("AGENT_CANDIDATE_KPI_ONLY", `Candidate ${c} is a single value; use it as a KPI bind, not as a block.`);
2697
+ let u = l === void 0 ? typeof s.type == "string" ? s.type.trim() : "" : l.type, d = t.materials.find((e) => e.type === u);
2698
+ if (u === "" || d === void 0 || d.children === !0) return a("AGENT_BLOCK_TYPE_UNKNOWN", "The block type is not in the catalog.");
2699
+ let f = typeof s.title == "string" ? s.title.trim() : "";
2700
+ R(f, en).length < f.length && (f = R(f, en), o("AGENT_BLOCK_TEXT_TRIMMED", "The block title was trimmed."));
2701
+ let p = typeof s.note == "string" ? s.note.trim() : "";
2702
+ R(p, tn).length < p.length && (p = R(p, tn), o("AGENT_BLOCK_TEXT_TRIMMED", "The block note was trimmed."));
2703
+ let m = 1;
2704
+ if (r.grid) {
2705
+ let e = typeof s.span == "number" ? Math.round(s.span) : 1;
2706
+ m = Math.min(4, Math.max(1, Number.isFinite(e) ? e : 1)), m !== e && o("AGENT_BLOCK_SPAN_CLAMPED", "The block span was clamped to 1–4.");
2707
+ }
2708
+ let h = l === void 0 ? void 0 : Nn(s.params);
2709
+ if (h === null) return a("AGENT_BIND_INVALID", "params must map parameter names to scalar values.");
2710
+ let g = l === void 0 ? Fn(s, d, t, n, i) : {
2711
+ kind: "dataset",
2712
+ datasetId: l.datasetId,
2713
+ fields: l.fields,
2714
+ ...h === void 0 ? {} : { params: h }
2715
+ };
2716
+ if (g === void 0) return {
2717
+ value: void 0,
2718
+ diagnostics: i
2719
+ };
2720
+ let _ = In(s.props, d, n, i), v = Jn(s.key, n, i), y = typeof s.substituteFor == "string" ? s.substituteFor.trim().slice(0, rn) : "";
2721
+ return {
2722
+ value: {
2723
+ type: u,
2724
+ title: f,
2725
+ span: m,
2726
+ bind: g,
2727
+ ...p === "" ? {} : { note: p },
2728
+ ..._ === void 0 ? {} : { props: _ },
2729
+ ...y === "" ? {} : { substituteFor: y },
2730
+ ...l === void 0 ? {} : { candidate: l.id },
2731
+ ...v === void 0 ? {} : { key: v },
2732
+ origin: n
2733
+ },
2734
+ diagnostics: i
2735
+ };
2736
+ }
2737
+ function Fn(e, t, n, r, i) {
2738
+ let a = (e, t) => {
2739
+ i.push({
2740
+ severity: "error",
2741
+ code: e,
2742
+ path: r,
2743
+ message: t
2744
+ });
2745
+ };
2746
+ if (t.data === "tabular") {
2747
+ let t = typeof e.datasetId == "string" ? e.datasetId.trim() : "";
2748
+ if (t !== "") {
2749
+ if (e.table !== void 0) return a("AGENT_BIND_CONFLICT", "A data block must give either datasetId or table, not both.");
2750
+ let n = Mn(e.fields), r = Nn(e.params);
2751
+ return n === null || r === null ? a("AGENT_BIND_INVALID", "fields must map role ids to field ids and params must map names to scalar values.") : {
2752
+ kind: "dataset",
2753
+ datasetId: t,
2754
+ ...n === void 0 ? {} : { fields: n },
2755
+ ...r === void 0 ? {} : { params: r }
2756
+ };
2757
+ }
2758
+ let n = Ln(e.table, r, i);
2759
+ return n === null ? a("AGENT_BLOCK_DATA_MISSING", "A data block needs a table or a dataset reference.") : {
2760
+ kind: "table",
2761
+ table: n
2762
+ };
2763
+ }
2764
+ if (t.data === "scalar") {
2765
+ let o = typeof e.assetId == "string" ? e.assetId.trim() : "";
2766
+ if (o !== "") return !t.asset || !n.assets.some((e) => e.id === o) ? a("AGENT_ASSET_UNKNOWN", "The asset is not in the authorized asset list.") : {
2767
+ kind: "asset",
2768
+ assetId: o
2769
+ };
2770
+ let s = typeof e.text == "string" ? e.text.trim() : "";
2771
+ return s === "" ? a("AGENT_BLOCK_DATA_MISSING", "A text block needs text.") : (R(s, nn).length < s.length && (s = R(s, nn), i.push({
2772
+ severity: "warning",
2773
+ code: "AGENT_BLOCK_TEXT_TRIMMED",
2774
+ path: r,
2775
+ message: "The block text was trimmed."
2776
+ })), {
2777
+ kind: "text",
2778
+ text: s
2779
+ });
2780
+ }
2781
+ return { kind: "none" };
2782
+ }
2783
+ function In(e, t, n, r) {
2784
+ if (e === void 0) return;
2785
+ let i = () => {
2786
+ r.push({
2787
+ severity: "warning",
2788
+ code: "AGENT_BLOCK_PROPS_DROPPED",
2789
+ path: n,
2790
+ message: "A prop that is not declared by the material was ignored."
2791
+ });
2792
+ }, a = V(e);
2793
+ if (a === null) {
2794
+ i();
2795
+ return;
2796
+ }
2797
+ let o = Object.keys(a);
2798
+ o.length > ln && i();
2799
+ let s = {};
2800
+ for (let e of o.slice(0, ln)) {
2801
+ let n = t.props[e], r = a[e];
2802
+ if (n === void 0) {
2803
+ i();
2804
+ continue;
2805
+ }
2806
+ if (n.kind === "number") {
2807
+ typeof r == "number" && Number.isFinite(r) ? s[e] = r : i();
2808
+ continue;
2809
+ }
2810
+ if (n.kind === "boolean") {
2811
+ typeof r == "boolean" ? s[e] = r : i();
2812
+ continue;
2813
+ }
2814
+ if (typeof r != "string") {
2815
+ i();
2816
+ continue;
2817
+ }
2818
+ if (n.kind === "enum" && n.values?.includes(r) !== !0) {
2819
+ i();
2820
+ continue;
2821
+ }
2822
+ s[e] = r.slice(0, un);
2823
+ }
2824
+ return Object.keys(s).length === 0 ? void 0 : s;
2825
+ }
2826
+ function Ln(e, t, n) {
2827
+ let r = (e, r) => {
2828
+ n.push({
2829
+ severity: "warning",
2830
+ code: e,
2831
+ path: t,
2832
+ message: r
2833
+ });
2834
+ }, i = V(e);
2835
+ if (i === null || !Array.isArray(i.columns) || !Array.isArray(i.rows) || i.columns.length < 1 || i.rows.length < 1) return null;
2836
+ i.columns.length > an && r("AGENT_BLOCK_COLUMNS_TRIMMED", `A table keeps at most ${an} columns.`);
2837
+ let a = [];
2838
+ for (let e of i.columns.slice(0, an)) {
2839
+ let t = V(e);
2840
+ if (t === null) return null;
2841
+ let n = typeof t.id == "string" ? t.id.trim() : "", i = typeof t.label == "string" ? t.label.trim() : "", o = t.type;
2842
+ if (!/^[a-zA-Z][a-zA-Z0-9_]{0,15}$/.test(n) || i === "" || o !== "string" && o !== "number" && o !== "boolean" || a.some((e) => e.id === n)) return null;
2843
+ let s = i;
2844
+ s.length > cn && (s = s.slice(0, cn), r("AGENT_BLOCK_TEXT_TRIMMED", "A column label was trimmed.")), a.push({
2845
+ id: n,
2846
+ label: s,
2847
+ type: o
2848
+ });
2849
+ }
2850
+ i.rows.length > on && r("AGENT_BLOCK_ROWS_TRIMMED", `A table keeps at most ${on} rows.`);
2851
+ let o = /* @__PURE__ */ new Set(), s = [];
2852
+ for (let e of i.rows.slice(0, on)) {
2853
+ let t = V(e);
2854
+ if (t === null) {
2855
+ r("AGENT_BLOCK_INVALID", "A table row was not an object and was skipped.");
2856
+ continue;
2857
+ }
2858
+ let n = {};
2859
+ for (let e of a) {
2860
+ let r = t[e.id];
2861
+ e.type === "number" && typeof r == "number" && Number.isFinite(r) || e.type === "boolean" && typeof r == "boolean" ? n[e.id] = r : (e.type !== "string" && o.add(e.id), n[e.id] = r == null ? "" : String(r).slice(0, sn));
2862
+ }
2863
+ s.push(n);
2864
+ }
2865
+ return s.length === 0 ? null : (o.size > 0 && r("AGENT_BLOCK_COLUMN_COERCED", "A column value did not match its declared type."), {
2866
+ columns: a.map((e) => o.has(e.id) ? {
2867
+ ...e,
2868
+ type: "string"
2869
+ } : e),
2870
+ rows: s
2871
+ });
2872
+ }
2873
+ var Rn = /^[a-z][a-z0-9-]{0,31}$/, zn = 8, Bn = 4, Vn = 4, Hn = 8, Un = /* @__PURE__ */ new Set([
2874
+ "gt",
2875
+ "gte",
2876
+ "lt",
2877
+ "lte",
2878
+ "eq",
2879
+ "neq"
2880
+ ]), Wn = /* @__PURE__ */ new Set([
2881
+ "success",
2882
+ "warning",
2883
+ "danger",
2884
+ "info"
2885
+ ]), Gn = /* @__PURE__ */ new Set([
2886
+ "show",
2887
+ "hide",
2888
+ "toggle"
2889
+ ]), Kn = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/, qn = /^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$/;
2890
+ function Jn(e, t, n) {
2891
+ if (e === void 0) return;
2892
+ let r = typeof e == "string" ? e.trim() : "";
2893
+ if (Rn.test(r)) return r;
2894
+ n.push({
2895
+ severity: "warning",
2896
+ code: "INTENT_KEY_INVALID",
2897
+ path: t,
2898
+ message: "A key must start with a lowercase letter and use letters, digits or hyphens (≤ 32)."
2899
+ });
2900
+ }
2901
+ function Yn(e, t, n) {
2902
+ if (e === void 0) return;
2903
+ let r = V(e);
2904
+ if (r?.source === "level-scale") return {
2905
+ rules: [],
2906
+ source: "level-scale"
2907
+ };
2908
+ let i = Array.isArray(e) ? e : Array.isArray(r?.rules) ? r.rules : void 0, a = (e) => {
2909
+ n.push({
2910
+ severity: "error",
2911
+ code: "INTENT_STATE_INVALID",
2912
+ path: t,
2913
+ message: e
2914
+ });
2915
+ };
2916
+ if (i === void 0) return a("states must be a list of { op, value, tone } rules.");
2917
+ let o = [];
2918
+ for (let e of i.slice(0, Vn)) {
2919
+ let t = V(e), n = typeof t?.op == "string" ? t.op : "", r = typeof t?.tone == "string" ? t.tone : "", i = t?.value;
2920
+ if (!(Un.has(n) && Wn.has(r) && (typeof i == "number" && Number.isFinite(i) || typeof i == "string" && i.trim() !== "" && (n === "eq" || n === "neq")))) {
2921
+ a("Each state rule needs op (gt/gte/lt/lte/eq/neq), a value and a tone.");
2922
+ continue;
2923
+ }
2924
+ let s = typeof t?.label == "string" ? R(t.label.trim(), Hn) : "";
2925
+ o.push({
2926
+ op: n,
2927
+ value: typeof i == "string" ? i.trim() : i,
2928
+ tone: r,
2929
+ ...s === "" ? {} : { label: s }
2930
+ });
2931
+ }
2932
+ if (i.length > Vn && n.push({
2933
+ severity: "warning",
2934
+ code: "INTENT_ITEMS_TRIMMED",
2935
+ path: t,
2936
+ message: `Only the first ${Vn} state rules are kept.`
2937
+ }), o.length !== 0) return {
2938
+ rules: o,
2939
+ ...r?.suggested === !0 ? { suggested: !0 } : {}
2940
+ };
2941
+ }
2942
+ function Xn(e, t) {
2943
+ if (e === void 0) return;
2944
+ if (!Array.isArray(e)) {
2945
+ t.push({
2946
+ severity: "error",
2947
+ code: "INTENT_INTERACTION_INVALID",
2948
+ path: "interactions",
2949
+ message: "interactions must be an array."
2950
+ });
2951
+ return;
2952
+ }
2953
+ let n = [];
2954
+ for (let [r, i] of e.slice(0, zn).entries()) {
2955
+ let e = `interactions[${r}]`, a = $n(i, e);
2956
+ typeof a == "string" ? t.push({
2957
+ severity: "error",
2958
+ code: "INTENT_INTERACTION_INVALID",
2959
+ path: e,
2960
+ message: a
2961
+ }) : n.push(a);
2962
+ }
2963
+ return e.length > zn && t.push({
2964
+ severity: "warning",
2965
+ code: "INTENT_ITEMS_TRIMMED",
2966
+ path: "interactions",
2967
+ message: `Only the first ${zn} interactions are kept.`
2968
+ }), n.length === 0 ? void 0 : n;
2969
+ }
2970
+ function Zn(e, t) {
2971
+ if (Array.isArray(e)) for (let [n, r] of e.slice(0, 3).entries()) {
2972
+ let e = typeof r == "string" ? R(r.trim(), 40) : "";
2973
+ e !== "" && t.push({
2974
+ severity: "warning",
2975
+ code: "INTENT_BEHAVIOR_GAP",
2976
+ path: `gaps[${n}]`,
2977
+ message: `The model reported a request it could not fulfil: ${e}`,
2978
+ detail: { text: e }
2979
+ });
2980
+ }
2981
+ }
2982
+ function Qn(e, t = 0) {
2983
+ let n = [];
2984
+ for (let [r, i] of e.entries()) {
2985
+ let e = $n(i, `interactions[${t + r}]`);
2986
+ typeof e != "string" && n.push(e);
2987
+ }
2988
+ return n;
2989
+ }
2990
+ function $n(e, t) {
2991
+ let n = V(e);
2992
+ if (n === null) return "An interaction must be an object.";
2993
+ let r = typeof n.from == "string" ? n.from.trim() : "", i = typeof n.event == "string" ? n.event.trim() : "", a = (Array.isArray(n.to) ? n.to : [n.to]).filter((e) => typeof e == "string").map((e) => e.trim()).filter((e) => e !== "");
2994
+ if (r === "" || a.length === 0) return "An interaction needs \"from\" and \"to\" (block keys or titles).";
2995
+ if (!Kn.test(i)) return "An interaction needs the event name of the source block.";
2996
+ let o = [...new Set(a)].slice(0, Bn);
2997
+ if (n.kind === "filter") {
2998
+ let e = typeof n.param == "string" ? n.param.trim() : "";
2999
+ if (!qn.test(e)) return "A filter needs the target query parameter \"param\".";
3000
+ let a = typeof n.field == "string" ? n.field.trim() : "";
3001
+ return a !== "" && !qn.test(a) ? "The filter field is not a field id." : {
3002
+ kind: "filter",
3003
+ from: r,
3004
+ event: i,
3005
+ to: o,
3006
+ param: e,
3007
+ ...a === "" ? {} : { field: a },
3008
+ ...n.reset === !0 ? { reset: !0 } : {},
3009
+ origin: t
3010
+ };
3011
+ }
3012
+ if (n.kind === "show") return {
3013
+ kind: "show",
3014
+ from: r,
3015
+ event: i,
3016
+ to: o,
3017
+ mode: typeof n.mode == "string" && Gn.has(n.mode) ? n.mode : "toggle",
3018
+ origin: t
3019
+ };
3020
+ if (n.kind === "state") {
3021
+ let e = typeof n.state == "string" ? R(n.state.trim(), 16) : "";
3022
+ return e === "" ? "A state interaction needs \"state\": a state name or tone of the target, or \"reset\"." : {
3023
+ kind: "state",
3024
+ from: r,
3025
+ event: i,
3026
+ to: o,
3027
+ state: e,
3028
+ origin: t
3029
+ };
3030
+ }
3031
+ return "Interaction kind must be \"filter\", \"show\" or \"state\".";
3032
+ }
3033
+ function er(e) {
3034
+ let t = e;
3035
+ if (typeof e == "string") {
3036
+ let n = e.trim().replace(/^```(?:json)?/i, "").replace(/```$/, "").trim();
3037
+ try {
3038
+ t = JSON.parse(n);
3039
+ } catch {
3040
+ return;
3041
+ }
3042
+ }
3043
+ return V(t) ?? void 0;
3044
+ }
3045
+ function tr(e, t) {
3046
+ return typeof e == "string" ? R(e.trim(), t) : "";
3047
+ }
3048
+ function V(e) {
3049
+ return typeof e == "object" && e && !Array.isArray(e) ? e : null;
3050
+ }
3051
+ function nr(e, t, n, r) {
3052
+ return e.push({
3053
+ severity: "error",
3054
+ code: t,
3055
+ path: n,
3056
+ message: r
3057
+ }), {
3058
+ intent: void 0,
3059
+ diagnostics: e
3060
+ };
3061
+ }
3062
+ function rr(e, t, n) {
3063
+ e.push({
3064
+ severity: "error",
3065
+ code: t,
3066
+ path: "",
3067
+ message: n
3068
+ });
3069
+ }
3070
+ //#endregion
3071
+ //#region ../host-kit/dist/intent/intent-freeform.js
3072
+ var ir = 1920, ar = 1080, or = 40, sr = 8, cr = 16, lr = p(ir);
3073
+ function ur(e, t) {
3074
+ let n = er(e);
3075
+ if (n === void 0 || !Array.isArray(n.items)) return {
3076
+ matched: !1,
3077
+ intent: void 0,
3078
+ diagnostics: []
3079
+ };
3080
+ let r = [], i = br(yr(n.title), 20) || "参考图大屏", a = br(yr(n.subtitle), 40) || "按参考图还原", o = xr(n.canvas) ? n.canvas : {}, s = typeof o.backgroundColor == "string" ? o.backgroundColor.trim() : void 0, c = n.items;
3081
+ c.length > or && r.push({
3082
+ severity: "warning",
3083
+ code: "INTENT_ITEMS_TRIMMED",
3084
+ path: "items",
3085
+ message: `Only the first ${or} items are kept.`
3086
+ });
3087
+ let l = [];
3088
+ for (let [e, n] of c.slice(0, or).entries()) {
3089
+ let i = `items[${e}]`;
3090
+ if (!xr(n)) {
3091
+ r.push({
3092
+ severity: "error",
3093
+ code: "AGENT_BLOCK_INVALID",
3094
+ path: i,
3095
+ message: "An item must be an object."
3096
+ });
3097
+ continue;
3098
+ }
3099
+ let a = pr(n, i, r);
3100
+ if (a === void 0) continue;
3101
+ let o = B({
3102
+ ...n,
3103
+ span: 1
3104
+ }, t.catalog, i, { grid: !1 });
3105
+ if (r.push(...o.diagnostics), o.value === void 0) continue;
3106
+ let s = mr(n.style);
3107
+ l.push({
3108
+ type: o.value.type,
3109
+ ...a,
3110
+ bind: o.value.bind,
3111
+ ...o.value.props === void 0 ? {} : { props: o.value.props },
3112
+ ...o.value.title === "" ? {} : { title: o.value.title },
3113
+ ...o.value.note === void 0 ? {} : { note: o.value.note },
3114
+ ...o.value.substituteFor === void 0 ? {} : { substituteFor: o.value.substituteFor },
3115
+ ...s === void 0 ? {} : { style: s },
3116
+ origin: i
3117
+ });
3118
+ }
3119
+ return l.length === 0 ? (r.push({
3120
+ severity: "error",
3121
+ code: "AGENT_BLOCKS_ALL_INVALID",
3122
+ path: "",
3123
+ message: "At least one usable item is required."
3124
+ }), {
3125
+ matched: !0,
3126
+ intent: void 0,
3127
+ diagnostics: r
3128
+ }) : {
3129
+ matched: !0,
3130
+ intent: {
3131
+ kind: "freeform",
3132
+ title: i,
3133
+ subtitle: a,
3134
+ canvas: { ...s === void 0 ? {} : { backgroundColor: s } },
3135
+ items: l
3136
+ },
3137
+ diagnostics: r
3138
+ };
3139
+ }
3140
+ function dr(e) {
3141
+ let t, n = /* @__PURE__ */ new Map();
3142
+ return {
3143
+ skeleton(e) {
3144
+ t = e;
3145
+ },
3146
+ item(e, r) {
3147
+ if (t === void 0) return !1;
3148
+ let i = /^items\[(\d+)\]$/.exec(e);
3149
+ return i !== null && (n.set(Number(i[1]), r), !0);
3150
+ },
3151
+ frame() {
3152
+ if (t === void 0 || n.size === 0) return;
3153
+ let r = [...n.entries()].sort(([e], [t]) => e - t).map(([, e]) => e), i = ur({
3154
+ title: t.title,
3155
+ subtitle: t.subtitle,
3156
+ ...t.canvas === void 0 ? {} : { canvas: t.canvas },
3157
+ items: r
3158
+ }, { catalog: e.catalog });
3159
+ if (i.intent === void 0) return;
3160
+ let a = fr({
3161
+ intent: i.intent,
3162
+ catalog: e.catalog,
3163
+ ...e.references === void 0 ? {} : { references: e.references }
3164
+ });
3165
+ return a.ok ? a.value.document : void 0;
3166
+ }
3167
+ };
3168
+ }
3169
+ function fr(e) {
3170
+ let { intent: t, catalog: n, references: r } = e, i = dt(void 0).palette, a = {
3171
+ diagnostics: [],
3172
+ warnings: [],
3173
+ dataSources: []
3174
+ }, o = [], s = {}, c = /* @__PURE__ */ new Set(), l = De(n), u = Me(n), d = Ne(n), p = 0, m = null, h = 0, g = 0, _ = 0, v = (e, n, r, a = {}) => {
3175
+ let d = `agent-free-${h}-${_}`;
3176
+ return _ += 1, s[d] = t.items[h]?.origin ?? "", o.push({
3177
+ id: d,
3178
+ type: e.type,
3179
+ name: n,
3180
+ parentId: a.parentId === void 0 ? m : a.parentId,
3181
+ position: {
3182
+ x: Math.round(r.x),
3183
+ y: Math.round(r.y)
3184
+ },
3185
+ size: {
3186
+ width: Math.max(1, Math.round(r.width)),
3187
+ height: Math.max(1, Math.round(r.height))
3188
+ },
3189
+ rotation: 0,
3190
+ zIndex: g + _,
3191
+ status: {
3192
+ locked: !1,
3193
+ hidden: !1
3194
+ },
3195
+ props: {
3196
+ ...e.defaults.props,
3197
+ ...a.props
3198
+ },
3199
+ style: gr({
3200
+ ...e.defaults.style,
3201
+ ...hr(e, l, u, i, a.style)
3202
+ }),
3203
+ dataSource: null,
3204
+ dataValue: a.dataValue ?? null,
3205
+ ...a.dataBinding === void 0 ? {} : { dataBinding: a.dataBinding }
3206
+ }), c.add(e.type), d;
3207
+ }, y = {
3208
+ catalog: n,
3209
+ textMaterial: l,
3210
+ references: r,
3211
+ palette: i,
3212
+ push: v,
3213
+ pushText: (e, t, n, r = {}) => {
3214
+ l !== void 0 && t !== "" && v(l, e, n, {
3215
+ style: we(l, {
3216
+ color: i.text,
3217
+ ...r
3218
+ }),
3219
+ dataValue: {
3220
+ kind: "inline",
3221
+ value: t
3222
+ }
3223
+ });
3224
+ },
3225
+ beginShell: (e, t) => {
3226
+ d !== void 0 && (m = v(d, e, t, { parentId: null }));
3227
+ },
3228
+ endShell: () => {
3229
+ m = null;
3230
+ }
3231
+ }, b = {
3232
+ sink: a,
3233
+ onAsset: () => p += 1
3234
+ };
3235
+ for (let [e, r] of t.items.entries()) {
3236
+ h = e, g = (r.z ?? e) * 10, _ = 0;
3237
+ let t = n.materials.find((e) => e.type === r.type);
3238
+ if (t !== void 0) {
3239
+ if (r.bind.kind === "text") {
3240
+ v(t, r.title?.trim() || t.name, _r(r), {
3241
+ style: Ce(t, r.style),
3242
+ props: xe(t, r.props),
3243
+ dataValue: {
3244
+ kind: "inline",
3245
+ value: r.bind.text
3246
+ }
3247
+ });
3248
+ continue;
3249
+ }
3250
+ if (r.bind.kind === "none" && t.data === "none") {
3251
+ v(t, r.title?.trim() || t.name, _r(r), {
3252
+ style: Ce(t, r.style),
3253
+ props: xe(t, r.props)
3254
+ });
3255
+ continue;
3256
+ }
3257
+ ge({
3258
+ type: r.type,
3259
+ title: r.title ?? "",
3260
+ span: 1,
3261
+ bind: r.bind,
3262
+ ...r.note === void 0 ? {} : { note: r.note },
3263
+ ...r.props === void 0 ? {} : { props: r.props },
3264
+ ...r.substituteFor === void 0 ? {} : { substituteFor: r.substituteFor },
3265
+ ...r.style === void 0 ? {} : { style: r.style },
3266
+ origin: r.origin
3267
+ }, vr(r), y, b);
3268
+ }
3269
+ }
3270
+ let x = t.canvas.backgroundColor, S = x !== void 0 && f(x) !== void 0 ? x : i.canvas;
3271
+ return x !== void 0 && f(x) === void 0 && a.warnings.push({
3272
+ severity: "warning",
3273
+ code: "INTENT_CANVAS_COLOR_INVALID",
3274
+ path: "canvas.backgroundColor",
3275
+ message: `"${x}" is not a CSS color; the style palette background was used instead.`
3276
+ }), o.length === 0 ? {
3277
+ ok: !1,
3278
+ diagnostics: [{
3279
+ severity: "error",
3280
+ code: "AGENT_CATALOG_UNUSABLE",
3281
+ path: "",
3282
+ message: "No item could be compiled into a component."
3283
+ }]
3284
+ } : {
3285
+ ok: !0,
3286
+ value: {
3287
+ imageCount: p,
3288
+ materials: [...c],
3289
+ warnings: a.warnings,
3290
+ sources: s,
3291
+ behaviors: [],
3292
+ document: {
3293
+ canvas: {
3294
+ width: ir,
3295
+ height: ar,
3296
+ backgroundColor: S
3297
+ },
3298
+ components: o,
3299
+ variables: [],
3300
+ ...a.dataSources.length === 0 ? {} : { dataSources: a.dataSources },
3301
+ blueprint: {
3302
+ nodes: [],
3303
+ edges: []
3304
+ }
3305
+ }
3306
+ }
3307
+ };
3308
+ }
3309
+ function pr(e, t, n) {
3310
+ let r = H(e.x), i = H(e.y), a = H(e.w ?? e.width), o = H(e.h ?? e.height);
3311
+ if (r === void 0 || i === void 0 || a === void 0 || o === void 0) {
3312
+ n.push({
3313
+ severity: "error",
3314
+ code: "AGENT_ITEM_GEOMETRY_INVALID",
3315
+ path: t,
3316
+ message: "An item needs numeric x, y, w and h in pixels."
3317
+ });
3318
+ return;
3319
+ }
3320
+ let s = U(Math.round(r), 0, 1912), c = U(Math.round(i), 0, 1072), l = U(Math.round(a), sr, ir - s), u = U(Math.round(o), sr, ar - c);
3321
+ (s !== Math.round(r) || c !== Math.round(i)) && n.push({
3322
+ severity: "warning",
3323
+ code: "INTENT_ITEM_CLAMPED",
3324
+ path: t,
3325
+ message: "The item position was clamped into the canvas."
3326
+ }), (l !== Math.round(a) || u !== Math.round(o)) && n.push({
3327
+ severity: "warning",
3328
+ code: "INTENT_ITEM_CLAMPED",
3329
+ path: t,
3330
+ message: "The item size was clamped to stay inside the canvas."
3331
+ });
3332
+ let d = H(e.z);
3333
+ return {
3334
+ x: s,
3335
+ y: c,
3336
+ width: l,
3337
+ height: u,
3338
+ ...d === void 0 ? {} : { z: U(Math.round(d), 0, 9999) }
3339
+ };
3340
+ }
3341
+ function mr(e) {
3342
+ let t = xr(e) ? e : void 0;
3343
+ if (t === void 0) return;
3344
+ let n = {}, r = H(t.fontSize);
3345
+ r !== void 0 && (n.fontSize = r), (typeof t.fontWeight == "string" || typeof t.fontWeight == "number") && (n.fontWeight = t.fontWeight);
3346
+ for (let e of [
3347
+ "color",
3348
+ "fill",
3349
+ "backgroundColor",
3350
+ "align",
3351
+ "textAlign"
3352
+ ]) {
3353
+ let r = t[e];
3354
+ typeof r == "string" && r.trim() !== "" && (n[e] = r.trim());
3355
+ }
3356
+ let i = H(t.lineSpacing);
3357
+ return i !== void 0 && (n.lineSpacing = i), Object.keys(n).length === 0 ? void 0 : n;
3358
+ }
3359
+ function hr(e, t, n, r, i) {
3360
+ let a = { ...i };
3361
+ return e.type === t?.type && a.color === void 0 && "color" in e.defaults.style && (a.color = r.text), e.type === n?.type && a.fill === void 0 && "fill" in e.defaults.style && (a.fill = r.card), a;
3362
+ }
3363
+ function gr(e) {
3364
+ let t = e.fontSize;
3365
+ return typeof t == "number" && t < lr ? {
3366
+ ...e,
3367
+ fontSize: lr
3368
+ } : e;
3369
+ }
3370
+ function _r(e) {
3371
+ return {
3372
+ x: e.x,
3373
+ y: e.y,
3374
+ width: e.width,
3375
+ height: e.height
3376
+ };
3377
+ }
3378
+ function vr(e) {
3379
+ let t = Math.max(0, e.x - cr), n = Math.max(0, e.y - cr), r = Math.min(ir, e.x + e.width + cr), i = Math.min(ar, e.y + e.height + cr);
3380
+ return {
3381
+ x: t,
3382
+ y: n,
3383
+ width: Math.max(sr, r - t),
3384
+ height: Math.max(sr, i - n)
3385
+ };
3386
+ }
3387
+ function yr(e) {
3388
+ return typeof e == "string" ? e.trim() : "";
3389
+ }
3390
+ function br(e, t) {
3391
+ return e.slice(0, t);
3392
+ }
3393
+ function H(e) {
3394
+ return typeof e == "number" && Number.isFinite(e) ? e : void 0;
3395
+ }
3396
+ function U(e, t, n) {
3397
+ return Math.min(n, Math.max(t, e));
3398
+ }
3399
+ function xr(e) {
3400
+ return typeof e == "object" && !!e && !Array.isArray(e);
3401
+ }
3402
+ //#endregion
3403
+ //#region ../host-kit/dist/intent/intent-prepare.js
3404
+ var Sr = /^(?:kpis\[\d+\]|blocks\[\d+\]|items\[\d+\]|interactions\[\d+\]|regions\[\d+\]\.(?:items|blocks|main|rail)\[\d+\])$/, Cr = /* @__PURE__ */ new Set([
3405
+ "AGENT_BLOCK_BINDING_UNSATISFIED",
3406
+ "AGENT_BINDING_FIELD_UNKNOWN",
3407
+ "AGENT_BINDING_TYPE_MISMATCH",
3408
+ "AGENT_DATASET_PARAM_INVALID",
3409
+ "AGENT_KPI_MULTI_ROW"
3410
+ ]);
3411
+ function wr(e) {
3412
+ let t = ur(e.output, { catalog: e.catalog });
3413
+ if (t.matched) return Tr(e, t);
3414
+ let n = xn(e.output, {
3415
+ catalog: e.catalog,
3416
+ placeholders: e.mode === "deterministic"
3417
+ }), r = n.diagnostics.filter((e) => e.severity === "warning"), i = n.diagnostics.filter((e) => e.severity === "error").map((e) => ({
3418
+ code: e.code,
3419
+ path: e.path
3420
+ }));
3421
+ if (n.intent === void 0) return {
3422
+ intent: void 0,
3423
+ compiled: void 0,
3424
+ issues: W(i),
3425
+ warnings: r,
3426
+ deliverable: !1
3427
+ };
3428
+ let a = mt({
3429
+ intent: n.intent,
3430
+ catalog: e.catalog,
3431
+ mode: e.mode,
3432
+ ...e.references === void 0 ? {} : { references: e.references },
3433
+ ...e.capabilities === void 0 ? {} : { capabilities: e.capabilities }
3434
+ });
3435
+ if (!a.ok) {
3436
+ for (let e of a.diagnostics) i.push({
3437
+ code: e.code,
3438
+ path: e.path
3439
+ });
3440
+ return {
3441
+ intent: n.intent,
3442
+ compiled: void 0,
3443
+ issues: W(i),
3444
+ warnings: r,
3445
+ deliverable: !1
3446
+ };
3447
+ }
3448
+ for (let e of a.value.warnings) r.push(e), (Cr.has(e.code) || k.has(e.code)) && i.push({
3449
+ code: e.code,
3450
+ path: e.path
3451
+ });
3452
+ let o = W(i);
3453
+ return {
3454
+ intent: n.intent,
3455
+ compiled: a.value,
3456
+ issues: o,
3457
+ warnings: r,
3458
+ deliverable: o.every((e) => Sr.test(e.path))
3459
+ };
3460
+ }
3461
+ function Tr(e, t) {
3462
+ let n = t.diagnostics.filter((e) => e.severity === "warning"), r = t.diagnostics.filter((e) => e.severity === "error").map((e) => ({
3463
+ code: e.code,
3464
+ path: e.path
3465
+ }));
3466
+ if (t.intent === void 0) return {
3467
+ intent: void 0,
3468
+ compiled: void 0,
3469
+ issues: W(r),
3470
+ warnings: n,
3471
+ deliverable: !1
3472
+ };
3473
+ let i = t.intent, a = fr({
3474
+ intent: t.intent,
3475
+ catalog: e.catalog,
3476
+ ...e.references === void 0 ? {} : { references: e.references },
3477
+ ...e.mode === void 0 ? {} : { mode: e.mode }
3478
+ });
3479
+ if (!a.ok) {
3480
+ for (let e of a.diagnostics) r.push({
3481
+ code: e.code,
3482
+ path: e.path
3483
+ });
3484
+ return {
3485
+ intent: void 0,
3486
+ freeform: i,
3487
+ compiled: void 0,
3488
+ issues: W(r),
3489
+ warnings: n,
3490
+ deliverable: !1
87
3491
  };
88
3492
  }
3493
+ n.push(...a.value.warnings);
3494
+ let o = W(r);
3495
+ return {
3496
+ intent: void 0,
3497
+ freeform: i,
3498
+ compiled: a.value,
3499
+ issues: o,
3500
+ warnings: n,
3501
+ deliverable: o.every((e) => Sr.test(e.path))
3502
+ };
89
3503
  }
90
- function f(e, t, n, r) {
91
- if (e !== void 0) try {
92
- let i = { ...t };
93
- Reflect.deleteProperty(i, "signal");
94
- let a = e({
95
- request: structuredClone(i),
96
- result: structuredClone(n),
97
- ...r === void 0 ? {} : { error: structuredClone(r) }
3504
+ function Er(e) {
3505
+ return e.map((e) => `${e.code}@${e.path}`).sort().join("|");
3506
+ }
3507
+ function Dr(e, t, n) {
3508
+ let r = [];
3509
+ for (let i of e) {
3510
+ if (i.severity !== "error" || i.code.startsWith("CHANGE_")) continue;
3511
+ let [e, a] = i.path, o = e === "components" && typeof a == "number" ? t[a] : void 0;
3512
+ r.push({
3513
+ code: i.code,
3514
+ path: o === void 0 ? "" : n[o] ?? ""
98
3515
  });
99
- Promise.resolve(a).catch(() => {});
100
- } catch {}
3516
+ }
3517
+ return W(r);
3518
+ }
3519
+ function W(e) {
3520
+ let t = /* @__PURE__ */ new Set(), n = [];
3521
+ for (let r of e) {
3522
+ let e = `${r.code}@${r.path}`;
3523
+ if (!t.has(e) && (t.add(e), n.push(r), n.length >= 100)) break;
3524
+ }
3525
+ return n;
101
3526
  }
102
- function p(e, t, n, r = (e) => e) {
3527
+ //#endregion
3528
+ //#region ../host-kit/dist/intent/intent-session.js
3529
+ function Or(e) {
103
3530
  return {
104
- async execute(r, i) {
105
- let a;
106
- try {
107
- a = t?.request?.(r) ?? n(r);
108
- } catch {
109
- return {
110
- ok: !1,
111
- error: {
112
- code: "HOST_KIT_MAPPING",
113
- message: "宿主请求映射失败。"
114
- }
115
- };
3531
+ intent: Ur(e.intent),
3532
+ compiled: e.compiled,
3533
+ catalog: e.catalog,
3534
+ references: e.references,
3535
+ mode: e.mode
3536
+ };
3537
+ }
3538
+ function kr(e, t) {
3539
+ let n = e.compiled.document.canvas;
3540
+ return n.width === t.canvas.width && n.height === t.canvas.height;
3541
+ }
3542
+ function Ar(e, t, n) {
3543
+ let r = Mr(e.intent, t, e.catalog);
3544
+ if (!r.ok) return r;
3545
+ let i = mt({
3546
+ intent: r.intent,
3547
+ catalog: e.catalog,
3548
+ mode: e.mode,
3549
+ ...e.references === void 0 ? {} : { references: e.references }
3550
+ });
3551
+ if (!i.ok) return {
3552
+ ok: !1,
3553
+ diagnostics: i.diagnostics
3554
+ };
3555
+ let a = e.compiled.document, o = i.value.document, s = new Map(n.components.map((e) => [e.id, e])), c = new Map(a.components.map((e) => [e.id, e])), l = new Map(o.components.map((e) => [e.id, e])), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
3556
+ for (let [e, t] of c) {
3557
+ let n = s.get(e);
3558
+ n === void 0 ? d.add(e) : ri(t, n) || u.add(e);
3559
+ }
3560
+ let f = [...c.keys()].filter((e) => !l.has(e)), p = o.components.filter((e) => !c.has(e.id)), m = o.components.filter((e) => {
3561
+ let t = c.get(e.id);
3562
+ return t !== void 0 && !ri(t, e);
3563
+ }), h = /* @__PURE__ */ new Set(), g = [], _ = f.filter((e) => !d.has(e) && !u.has(e));
3564
+ for (let e of f) u.has(e) && h.add(e);
3565
+ let v = m.filter((e) => !d.has(e.id) && !u.has(e.id) && c.get(e.id)?.type !== e.type), y = new Set(v.map((e) => e.id)), b = /* @__PURE__ */ new Map(), x = new Map((a.dataSources ?? []).map((e) => [String(e.id), e])), S = new Map((o.dataSources ?? []).map((e) => [String(e.id), e]));
3566
+ for (let e of m) {
3567
+ let t = X(c.get(e.id)?.dataValue), n = X(e.dataValue), r = X(s.get(e.id)?.dataValue);
3568
+ t !== void 0 && n !== void 0 && r !== void 0 && t !== n && (b.has(n) || si(x.get(t), S.get(n)) && b.set(n, r));
3569
+ }
3570
+ let C = m.filter((e) => {
3571
+ if (d.has(e.id) || u.has(e.id) || y.has(e.id)) return !1;
3572
+ let t = e.dataValue;
3573
+ return typeof t?.dataSourceId == "string" && !b.has(t.dataSourceId) && JSON.stringify(c.get(e.id)?.dataValue ?? null) !== JSON.stringify(t);
3574
+ }), w = oi(o, [
3575
+ ...p,
3576
+ ...v,
3577
+ ...C
3578
+ ], n.dataSources ?? [], b), T = ti(a, o, n, s), E = [], D = [], O = (e) => {
3579
+ for (let t of e) D.push(g.length), g.push(t);
3580
+ }, k = (e) => {
3581
+ E.push(g.length), g.push(e);
3582
+ };
3583
+ O(T.detach), w.fresh.length > 0 && k({
3584
+ type: "add-data-sources",
3585
+ dataSources: w.fresh
3586
+ }), O(T.attach);
3587
+ let A = n.components.reduce((e, t) => Math.max(e, t.zIndex ?? 0), 0);
3588
+ for (let e of m) {
3589
+ if (d.has(e.id)) continue;
3590
+ if (u.has(e.id)) {
3591
+ h.add(e.id);
3592
+ continue;
3593
+ }
3594
+ if (y.has(e.id)) continue;
3595
+ let t = ai(w.applyPrevious(c.get(e.id)), w.apply(e));
3596
+ Object.keys(t).length !== 0 && k({
3597
+ type: "update-components",
3598
+ componentIds: [e.id],
3599
+ patch: t
3600
+ });
3601
+ }
3602
+ let j = [..._, ...y];
3603
+ j.length > 0 && k({
3604
+ type: "remove-components",
3605
+ componentIds: j
3606
+ });
3607
+ for (let e of v) k({
3608
+ type: "add-component",
3609
+ component: w.apply({
3610
+ ...e,
3611
+ zIndex: s.get(e.id)?.zIndex ?? e.zIndex + A
3612
+ })
3613
+ });
3614
+ for (let e of p) k({
3615
+ type: "add-component",
3616
+ component: w.apply({
3617
+ ...e,
3618
+ zIndex: e.zIndex + A
3619
+ })
3620
+ });
3621
+ O(T.wire);
3622
+ let M = Ie(r.intent.title, r.intent.subtitle), N = jr(e.compiled.behaviors, i.value.behaviors, M), P = E.length > 0 && D.length > 0 ? [{
3623
+ label: M === "en" ? "Layout and content" : "版面与内容",
3624
+ commandIndexes: E
3625
+ }, {
3626
+ label: M === "en" ? "Interactions" : "联动",
3627
+ commandIndexes: D,
3628
+ ...N.length === 0 ? {} : { notes: N }
3629
+ }] : void 0;
3630
+ return {
3631
+ ok: !0,
3632
+ session: {
3633
+ ...e,
3634
+ intent: r.intent,
3635
+ compiled: i.value
3636
+ },
3637
+ commands: g,
3638
+ keptForUser: [...h],
3639
+ summary: {
3640
+ changed: m.filter((e) => !u.has(e.id) && !d.has(e.id)).length,
3641
+ added: p.length,
3642
+ removed: _.length
3643
+ },
3644
+ warnings: i.value.warnings,
3645
+ ...P === void 0 ? {} : { groups: P }
3646
+ };
3647
+ }
3648
+ function jr(e, t, n) {
3649
+ let r = (e) => n === "en" ? `${e.from}: ${e.detail} ${e.to.join(", ")}` : `点「${e.from}」${e.detail}「${e.to.join("」「")}」`, i = (e) => JSON.stringify([
3650
+ e.kind,
3651
+ e.from,
3652
+ e.to,
3653
+ e.detail
3654
+ ]), a = (e) => e.filter((e) => e.kind !== "state"), o = new Set(a(e).map(i)), s = new Set(a(t).map(i));
3655
+ return [...a(t).filter((e) => !o.has(i(e))).map((e) => `${n === "en" ? "Add" : "新增"}:${r(e)}`), ...a(e).filter((e) => !s.has(i(e))).map((e) => `${n === "en" ? "Remove" : "去掉"}:${r(e)}`)];
3656
+ }
3657
+ function Mr(e, t, n) {
3658
+ let r = Ur(e);
3659
+ for (let [e, i] of t.entries()) {
3660
+ let t = `ops[${e}]`, a = qr(i);
3661
+ if (a === void 0) return q(t, "INTENT_OP_INVALID", "Unknown or malformed operation.");
3662
+ let o = Nr(r, a, n, t);
3663
+ if (!o.ok) return o;
3664
+ r = o.intent;
3665
+ }
3666
+ return r.regions.some(Vr) ? {
3667
+ ok: !0,
3668
+ intent: r
3669
+ } : q("ops", "INTENT_OP_INVALID", "An edit may not leave the screen without any block.");
3670
+ }
3671
+ function Nr(e, t, n, r) {
3672
+ if (t.op === "add") return Fr(e, t, n, r);
3673
+ if (t.op === "link") return Jr(e, t, r);
3674
+ if (t.op === "unlink") return Yr(e, t, r);
3675
+ if (t.target === "title" || t.target === "subtitle") {
3676
+ if (t.op !== "change") return q(r, "INTENT_OP_INVALID", "The title and subtitle can only be changed.");
3677
+ let n = typeof t.set.text == "string" ? t.set.text.trim() : "";
3678
+ return n === "" ? q(r, "INTENT_OP_INVALID", "A title change needs non-empty text.") : {
3679
+ ok: !0,
3680
+ intent: {
3681
+ ...e,
3682
+ [t.target]: R(n, t.target === "title" ? 20 : 40)
116
3683
  }
117
- return i.aborted ? {
118
- ok: !1,
119
- error: {
120
- code: "ABORTED",
121
- message: "请求已取消。"
3684
+ };
3685
+ }
3686
+ let i = Rr(e, t.target);
3687
+ if (i === void 0) return q(r, "INTENT_OP_TARGET_UNKNOWN", `No item is addressed by "${t.target}".`);
3688
+ if (t.op === "delete") return {
3689
+ ok: !0,
3690
+ intent: Xr(Br(e, i), i)
3691
+ };
3692
+ if (t.op === "rebind") return Pr(e, i, t, n, r);
3693
+ if (t.op === "change") {
3694
+ if (i.kpi !== void 0 && (Array.isArray(t.set.rules) || "suggested" in t.set)) {
3695
+ let { rules: e, suggested: n, states: r, ...i } = t.set, a = Array.isArray(r) ? { rules: r } : typeof r == "object" && r ? r : Array.isArray(e) ? { rules: e } : void 0;
3696
+ a !== void 0 && (t = {
3697
+ ...t,
3698
+ set: {
3699
+ ...i,
3700
+ states: n === !0 ? {
3701
+ ...a,
3702
+ suggested: !0
3703
+ } : a
122
3704
  }
123
- } : e.request(a.path, {
124
- ...a,
125
- signal: i
126
3705
  });
127
- },
128
- response: (e, n) => t?.response ? t.response(e, n) : r(e)
3706
+ }
3707
+ let e = i.kpi === void 0 ? Lr : Ir, n = Object.keys(t.set).filter((t) => !e.has(t));
3708
+ if (n.length > 0) return q(r, "INTENT_OP_INVALID", `Unknown field(s) ${n.join(", ")}; a ${i.kpi === void 0 ? "block" : "KPI"} change may set ${[...e].join(" / ")}.`);
3709
+ }
3710
+ if (i.kpi !== void 0) {
3711
+ if (t.op !== "change") return q(r, "INTENT_OP_INVALID", "A KPI can only be changed or deleted.");
3712
+ let n = z({
3713
+ ...Gr(i.kpi),
3714
+ ...t.set
3715
+ }, i.kpi.origin, { placeholders: i.kpi.value === null });
3716
+ return n.value === void 0 ? q(r, "INTENT_OP_FAILED", "The changed KPI is not usable.") : {
3717
+ ok: !0,
3718
+ intent: zr(e, i, {
3719
+ ...n.value,
3720
+ ident: i.kpi.ident ?? i.kpi.origin
3721
+ })
3722
+ };
3723
+ }
3724
+ let a = i.block, o = B(t.op === "swap" ? {
3725
+ ...Wr(Kr(a)),
3726
+ type: t.type,
3727
+ props: t.props
3728
+ } : {
3729
+ ...Kr(a),
3730
+ ...t.set
3731
+ }, n, a.origin, { grid: i.grid }), s = o.diagnostics.filter((e) => e.severity === "error");
3732
+ return o.value === void 0 || s.length > 0 ? q(r, "INTENT_OP_FAILED", `The edited block is not usable (${s[0]?.code ?? "unknown"}).`) : {
3733
+ ok: !0,
3734
+ intent: zr(e, i, {
3735
+ ...o.value,
3736
+ span: a.span,
3737
+ ident: a.ident ?? a.origin
3738
+ })
129
3739
  };
130
3740
  }
131
- //#endregion
132
- //#region ../host-kit/dist/dataset-port.js
133
- var m = 6e4;
134
- function h(i) {
135
- let a;
136
- async function o(e, t, n, r, i, a) {
137
- if (n.aborted) return b();
138
- let o = await d(e, t, n, a);
139
- if (n.aborted || !o.ok && o.error.code === "ABORTED") return b();
140
- let s;
141
- if (!o.ok) s = y(v(o.error), o.error.message);
142
- else try {
143
- let n = r(e.response ? e.response(o.data, t) : o.data);
144
- s = n.ok ? n : y("HOST_DATASET_INVALID", "数据集响应格式无效。");
145
- } catch {
146
- s = y("HOST_DATASET_INVALID", "数据集响应格式无效。");
3741
+ function Pr(e, t, n, r, i) {
3742
+ if (t.kpi !== void 0) {
3743
+ let r = z({
3744
+ label: t.kpi.label,
3745
+ ...t.kpi.unit === void 0 ? {} : { unit: t.kpi.unit },
3746
+ ...t.kpi.key === void 0 ? {} : { key: t.kpi.key },
3747
+ ...t.kpi.states === void 0 ? {} : { states: t.kpi.states },
3748
+ bind: n.bind
3749
+ }, t.kpi.origin);
3750
+ return r.value === void 0 ? q(i, "INTENT_OP_FAILED", "The rebound KPI is not usable.") : {
3751
+ ok: !0,
3752
+ intent: zr(e, t, {
3753
+ ...r.value,
3754
+ ident: G(t.kpi)
3755
+ })
3756
+ };
3757
+ }
3758
+ let a = t.block, { table: o, datasetId: s, fields: c, params: l, text: u, assetId: d, ...f } = Kr(a), p = typeof n.bind.candidate == "string" ? n.bind.candidate : void 0, m = B(p === void 0 ? {
3759
+ ...f,
3760
+ ...typeof n.bind.type == "string" ? { type: n.bind.type } : {},
3761
+ datasetId: n.bind.datasetId,
3762
+ ...n.bind.fields === void 0 ? {} : { fields: n.bind.fields },
3763
+ ...n.bind.params === void 0 ? {} : { params: n.bind.params }
3764
+ } : {
3765
+ ...f,
3766
+ candidate: p,
3767
+ ...K(n.bind.params) ? { params: n.bind.params } : {}
3768
+ }, r, a.origin, { grid: t.grid }), h = m.diagnostics.filter((e) => e.severity === "error");
3769
+ return m.value === void 0 || h.length > 0 ? q(i, "INTENT_OP_FAILED", `The rebound block is not usable (${h[0]?.code ?? "unknown"}).`) : {
3770
+ ok: !0,
3771
+ intent: zr(e, t, {
3772
+ ...m.value,
3773
+ span: a.span,
3774
+ ident: G(a)
3775
+ })
3776
+ };
3777
+ }
3778
+ function Fr(e, t, n, r) {
3779
+ let i = e.regions.findIndex((e) => e.origin === t.region), a = e.regions[i];
3780
+ if (a === void 0 || a.kind === "band") return q(r, "INTENT_OP_TARGET_UNKNOWN", `"${t.region}" is not a region that holds blocks.`);
3781
+ let o = a.kind === "grid" ? "blocks" : t.part === "rail" ? "rail" : "main", s = Hr((a.kind === "grid" ? a.blocks : a[o === "rail" ? "rail" : "main"]).map((e) => e.ident ?? e.origin)), c = `${a.origin === "blocks" ? "blocks" : `${a.origin}.${o}`}[${s}]`, l = B(t.block, n, c, { grid: a.kind === "grid" }), u = l.diagnostics.filter((e) => e.severity === "error");
3782
+ if (l.value === void 0 || u.length > 0) return q(r, "INTENT_OP_FAILED", `The new block is not usable (${u[0]?.code ?? "unknown"}).`);
3783
+ let d = {
3784
+ ...l.value,
3785
+ ident: c
3786
+ }, f = e.regions.map((e, t) => t === i ? e.kind === "grid" ? {
3787
+ ...e,
3788
+ blocks: [...e.blocks, d]
3789
+ } : e.kind === "split" ? o === "rail" ? {
3790
+ ...e,
3791
+ rail: [...e.rail, d]
3792
+ } : {
3793
+ ...e,
3794
+ main: [...e.main, d]
3795
+ } : e : e);
3796
+ return {
3797
+ ok: !0,
3798
+ intent: {
3799
+ ...e,
3800
+ regions: f
3801
+ }
3802
+ };
3803
+ }
3804
+ var Ir = /* @__PURE__ */ new Set([
3805
+ "label",
3806
+ "value",
3807
+ "unit",
3808
+ "precision",
3809
+ "delta",
3810
+ "states",
3811
+ "key"
3812
+ ]), Lr = /* @__PURE__ */ new Set([
3813
+ "title",
3814
+ "note",
3815
+ "text",
3816
+ "table",
3817
+ "props",
3818
+ "substituteFor",
3819
+ "key"
3820
+ ]), G = (e) => e.ident ?? e.origin;
3821
+ function Rr(e, t) {
3822
+ for (let [n, r] of e.regions.entries()) {
3823
+ if (r.kind === "band") {
3824
+ let e = r.items.findIndex((e) => G(e) === t), i = r.items[e];
3825
+ if (i !== void 0) return {
3826
+ regionIndex: n,
3827
+ part: "items",
3828
+ itemIndex: e,
3829
+ grid: !1,
3830
+ kpi: i
3831
+ };
3832
+ continue;
3833
+ }
3834
+ let e = r.kind === "grid" ? ["blocks"] : ["main", "rail"];
3835
+ for (let i of e) {
3836
+ let e = r.kind === "grid" ? r.blocks : r[i], a = e.findIndex((e) => G(e) === t), o = e[a];
3837
+ if (o !== void 0) return {
3838
+ regionIndex: n,
3839
+ part: i,
3840
+ itemIndex: a,
3841
+ grid: r.kind === "grid",
3842
+ block: o
3843
+ };
147
3844
  }
148
- return n.aborted ? b() : (f(i, t, s, o.ok ? void 0 : o.error), s);
149
3845
  }
150
- let s = i.groups;
3846
+ }
3847
+ function zr(e, t, n) {
151
3848
  return {
152
- queryScope: "dataset",
153
- ...s === void 0 ? {} : { async groups(e) {
154
- if (e.signal.aborted) return b();
155
- let n = a;
156
- if (n !== void 0 && Date.now() - n.at < m) return {
157
- ok: !0,
158
- value: n.value,
159
- diagnostics: []
3849
+ ...e,
3850
+ regions: e.regions.map((e, r) => {
3851
+ if (r !== t.regionIndex) return e;
3852
+ let i = (e) => e.map((e, r) => r === t.itemIndex ? n : e);
3853
+ return e.kind === "band" ? {
3854
+ ...e,
3855
+ items: i(e.items)
3856
+ } : e.kind === "grid" ? {
3857
+ ...e,
3858
+ blocks: i(e.blocks)
3859
+ } : t.part === "rail" ? {
3860
+ ...e,
3861
+ rail: i(e.rail)
3862
+ } : {
3863
+ ...e,
3864
+ main: i(e.main)
160
3865
  };
161
- let r = await o(s, e, e.signal, t);
162
- return r.ok && (a = {
163
- at: Date.now(),
164
- value: r.value
165
- }), r;
166
- } },
167
- list: (e) => o(i.list, e, e.signal, r, i.onListResult),
168
- describe: (e) => o(i.describe, e, e.signal, n, i.onDescribeResult),
169
- query: (t, n) => o(i.query, t, n.signal, e, i.onQueryResult, n.context)
3866
+ })
170
3867
  };
171
3868
  }
172
- function g(e) {
173
- let t = s(e);
174
- return h({
175
- groups: p(t, e.mapping?.groups, () => ({ path: `/datasets${l({ limit: 1 })}` }), (e) => {
176
- if (!(typeof e != "object" || !e || Array.isArray(e))) return "groups" in e ? e.groups : [];
177
- }),
178
- list: p(t, e.mapping?.list, (e) => ({ path: `/datasets${l({
179
- query: e.query,
180
- limit: e.limit,
181
- groupId: e.groupId,
182
- cursor: e.cursor
183
- })}` }), (e) => {
184
- if (!(typeof e != "object" || !e || !("items" in e))) return {
185
- items: e.items,
186
- ..."nextCursor" in e ? { nextCursor: e.nextCursor } : {}
3869
+ function Br(e, t) {
3870
+ let n = [];
3871
+ for (let [r, i] of e.regions.entries()) {
3872
+ if (r !== t.regionIndex) {
3873
+ n.push(i);
3874
+ continue;
3875
+ }
3876
+ let e = (e) => e.filter((e, n) => n !== t.itemIndex);
3877
+ if (i.kind === "band") {
3878
+ let t = e(i.items);
3879
+ t.length > 0 && n.push({
3880
+ ...i,
3881
+ items: t
3882
+ });
3883
+ } else if (i.kind === "grid") {
3884
+ let t = e(i.blocks);
3885
+ t.length > 0 && n.push({
3886
+ ...i,
3887
+ blocks: t
3888
+ });
3889
+ } else {
3890
+ let r = t.part === "main" ? e(i.main) : i.main, a = t.part === "rail" ? e(i.rail) : i.rail;
3891
+ if (r.length > 0 && a.length > 0) n.push({
3892
+ ...i,
3893
+ main: r,
3894
+ rail: a
3895
+ });
3896
+ else {
3897
+ let e = [...r, ...a];
3898
+ e.length > 0 && n.push({
3899
+ kind: "grid",
3900
+ origin: i.origin,
3901
+ blocks: e.map((e) => ({
3902
+ ...e,
3903
+ span: 4
3904
+ }))
3905
+ });
3906
+ }
3907
+ }
3908
+ }
3909
+ return {
3910
+ ...e,
3911
+ regions: n
3912
+ };
3913
+ }
3914
+ function Vr(e) {
3915
+ return e.kind === "grid" ? e.blocks.length > 0 : e.kind === "split" ? e.main.length > 0 || e.rail.length > 0 : !1;
3916
+ }
3917
+ function Hr(e) {
3918
+ let t = -1;
3919
+ for (let n of e) {
3920
+ let e = /\[(\d+)\]$/.exec(n);
3921
+ e !== null && (t = Math.max(t, Number(e[1])));
3922
+ }
3923
+ return t + 1;
3924
+ }
3925
+ function Ur(e) {
3926
+ return {
3927
+ ...e,
3928
+ regions: e.regions.map((e) => {
3929
+ let t = (e) => ({
3930
+ ...e,
3931
+ ident: e.ident ?? e.origin
3932
+ });
3933
+ return e.kind === "band" ? {
3934
+ ...e,
3935
+ items: e.items.map(t)
3936
+ } : e.kind === "grid" ? {
3937
+ ...e,
3938
+ blocks: e.blocks.map(t)
3939
+ } : {
3940
+ ...e,
3941
+ main: e.main.map(t),
3942
+ rail: e.rail.map(t)
187
3943
  };
188
- }),
189
- describe: p(t, e.mapping?.describe, (e) => ({ path: `/datasets/${encodeURIComponent(e.datasetId)}` })),
190
- query: p(t, e.mapping?.query, (e) => ({ path: `/datasets/${encodeURIComponent(e.datasetId)}/query${l(_(e.params))}` }))
191
- });
3944
+ })
3945
+ };
192
3946
  }
193
- function _(e) {
194
- let t = {};
195
- for (let [n, r] of Object.entries(e)) (typeof r == "string" || typeof r == "number" || typeof r == "boolean") && (t[n] = r);
196
- return t;
3947
+ function Wr(e) {
3948
+ let { fields: t, ...n } = e;
3949
+ return n;
197
3950
  }
198
- function v(e) {
199
- return e.code === "HOST_KIT_MAPPING" ? "HOST_DATASET_INVALID" : e.code === "UNKNOWN_DATASET" || e.status === 404 ? "HOST_DATASET_UNAVAILABLE" : e.status === 400 || e.status === 422 ? "HOST_DATASET_PARAMETER_INVALID" : "HOST_DATASET_UNAVAILABLE";
3951
+ function Gr(e) {
3952
+ let t = {
3953
+ ...e.key === void 0 ? {} : { key: e.key },
3954
+ ...e.states === void 0 ? {} : { states: e.states }
3955
+ };
3956
+ return e.bind === void 0 ? {
3957
+ label: e.label,
3958
+ value: e.value,
3959
+ ...e.unit === void 0 ? {} : { unit: e.unit },
3960
+ ...e.precision === void 0 ? {} : { precision: e.precision },
3961
+ ...e.delta === void 0 ? {} : { delta: e.delta },
3962
+ ...t
3963
+ } : {
3964
+ label: e.label,
3965
+ ...e.unit === void 0 ? {} : { unit: e.unit },
3966
+ bind: e.bind,
3967
+ ...t
3968
+ };
3969
+ }
3970
+ function Kr(e) {
3971
+ return {
3972
+ type: e.type,
3973
+ title: e.title,
3974
+ span: e.span,
3975
+ ...e.note === void 0 ? {} : { note: e.note },
3976
+ ...e.props === void 0 ? {} : { props: e.props },
3977
+ ...e.substituteFor === void 0 ? {} : { substituteFor: e.substituteFor },
3978
+ ...e.key === void 0 ? {} : { key: e.key },
3979
+ ...e.bind.kind === "table" ? { table: e.bind.table } : {},
3980
+ ...e.bind.kind === "dataset" ? {
3981
+ datasetId: e.bind.datasetId,
3982
+ ...e.bind.fields === void 0 ? {} : { fields: e.bind.fields },
3983
+ ...e.bind.params === void 0 ? {} : { params: e.bind.params }
3984
+ } : {},
3985
+ ...e.bind.kind === "text" ? { text: e.bind.text } : {},
3986
+ ...e.bind.kind === "asset" ? { assetId: e.bind.assetId } : {}
3987
+ };
3988
+ }
3989
+ function qr(e) {
3990
+ if (typeof e != "object" || !e || Array.isArray(e)) return;
3991
+ let t = e, n = typeof t.target == "string" ? t.target : void 0;
3992
+ switch (t.op) {
3993
+ case "change": return n !== void 0 && K(t.set) ? {
3994
+ op: "change",
3995
+ target: n,
3996
+ set: t.set
3997
+ } : void 0;
3998
+ case "swap": return n !== void 0 && typeof t.type == "string" ? {
3999
+ op: "swap",
4000
+ target: n,
4001
+ type: t.type,
4002
+ ...K(t.props) ? { props: t.props } : {}
4003
+ } : void 0;
4004
+ case "delete": return n === void 0 ? void 0 : {
4005
+ op: "delete",
4006
+ target: n
4007
+ };
4008
+ case "add": return typeof t.region == "string" && t.block !== void 0 ? {
4009
+ op: "add",
4010
+ region: t.region,
4011
+ ...t.part === "main" || t.part === "rail" ? { part: t.part } : {},
4012
+ block: t.block
4013
+ } : void 0;
4014
+ case "rebind": return n !== void 0 && K(t.bind) ? {
4015
+ op: "rebind",
4016
+ target: n,
4017
+ bind: t.bind
4018
+ } : void 0;
4019
+ case "link": return K(t.interaction) ? {
4020
+ op: "link",
4021
+ interaction: t.interaction
4022
+ } : void 0;
4023
+ case "unlink": return n === void 0 ? void 0 : {
4024
+ op: "unlink",
4025
+ target: n
4026
+ };
4027
+ default: return;
4028
+ }
200
4029
  }
201
- function y(e, t) {
4030
+ function K(e) {
4031
+ return typeof e == "object" && !!e && !Array.isArray(e);
4032
+ }
4033
+ function q(e, t, n) {
202
4034
  return {
203
4035
  ok: !1,
204
4036
  diagnostics: [{
205
4037
  severity: "error",
206
- code: e,
207
- path: [],
208
- message: t
4038
+ code: t,
4039
+ path: e,
4040
+ message: n
209
4041
  }]
210
4042
  };
211
4043
  }
212
- function b() {
4044
+ function Jr(e, t, n) {
4045
+ let r = e.interactions ?? [], i = Qn([t.interaction], r.length)[0];
4046
+ return i === void 0 ? q(n, "INTENT_OP_INVALID", "The interaction is not usable.") : {
4047
+ ok: !0,
4048
+ intent: {
4049
+ ...e,
4050
+ interactions: [...r, i]
4051
+ }
4052
+ };
4053
+ }
4054
+ function Yr(e, t, n) {
4055
+ let r = e.interactions ?? [], i = r.filter((e) => e.origin !== t.target);
4056
+ return i.length === r.length ? q(n, "INTENT_OP_TARGET_UNKNOWN", `No interaction is addressed by "${t.target}".`) : {
4057
+ ok: !0,
4058
+ intent: Zr(e, i)
4059
+ };
4060
+ }
4061
+ function Xr(e, t) {
4062
+ let n = t.kpi ?? t.block;
4063
+ if (e.interactions === void 0 || n === void 0) return e;
4064
+ let r = t.kpi === void 0 ? t.block?.title ?? "" : t.kpi.label, i = (e) => e === n.key || r !== "" && e === r, a = [];
4065
+ for (let t of e.interactions) {
4066
+ if (i(t.from)) continue;
4067
+ let e = t.to.filter((e) => !i(e));
4068
+ e.length !== 0 && a.push({
4069
+ ...t,
4070
+ to: e
4071
+ });
4072
+ }
4073
+ return Zr(e, a);
4074
+ }
4075
+ function Zr(e, t) {
4076
+ let { interactions: n, ...r } = e;
4077
+ return t.length === 0 ? r : {
4078
+ ...r,
4079
+ interactions: t
4080
+ };
4081
+ }
4082
+ var Qr = (e) => typeof e == "string" && e.startsWith("agent:"), $r = (e) => typeof e == "string" && e.startsWith("agent-edge-"), ei = (e) => typeof e == "string" && e.startsWith("agent-var-"), J = (e) => K(e) && e.kind === "variable" && typeof e.variableId == "string";
4083
+ function ti(e, t, n, r) {
4084
+ let i = K(n.blueprint) ? n.blueprint : {}, a = (Array.isArray(i.nodes) ? i.nodes : []).filter(K), o = (Array.isArray(i.edges) ? i.edges : []).filter(K), s = (n.variables ?? []).filter(K).filter((e) => ei(e.id)), c = (e, t) => e.some((e) => e.id === t.id && Y(e) === Y(t)), l = a.filter((e) => Qr(e.id)), u = o.filter((e) => $r(e.id)), d = t.blueprint.nodes.filter(K), f = t.blueprint.edges.filter(K), p = l.filter((e) => !c(d, e)).map((e) => String(e.id)), m = new Set(p), h = u.filter((e) => !c(f, e) && !m.has(String(e.from?.node)) && !m.has(String(e.to?.node))).map((e) => String(e.id)), g = u.filter((e) => c(f, e) && !m.has(String(e.from?.node)) && !m.has(String(e.to?.node))), _ = l.filter((e) => !m.has(String(e.id))), v = d.filter((e) => !c(_, e)), y = f.filter((e) => !c(g, e)), b = s.filter((e) => !c(t.variables, e)), x = new Set(b.map((e) => String(e.id))), S = s.filter((e) => !x.has(String(e.id))), C = t.variables.filter((e) => !c(S, e)), w = /* @__PURE__ */ new Map(), T = new Map((t.dataSources ?? []).map((e) => [String(e.id), e]));
4085
+ for (let e of t.components) {
4086
+ let t = e.dataValue?.dataSourceId, n = r.get(e.id)?.dataValue?.dataSourceId, i = typeof t == "string" ? T.get(t) : void 0;
4087
+ if (i === void 0 || typeof n != "string") continue;
4088
+ let a = K(i.params) ? i.params : {};
4089
+ w.set(n, {
4090
+ ...w.get(n) ?? {},
4091
+ ...a
4092
+ });
4093
+ }
4094
+ let E = [], D = [];
4095
+ for (let e of n.dataSources ?? []) {
4096
+ let t = String(e.id), n = K(e.params) ? e.params : {}, r = w.get(t) ?? {}, i = {}, a = {};
4097
+ for (let [e, t] of Object.entries(n)) {
4098
+ if (!J(t) || !ei(t.variableId)) continue;
4099
+ let n = r[e];
4100
+ J(n) && n.variableId === t.variableId && !x.has(t.variableId) || (i[e] = {
4101
+ kind: "inline",
4102
+ value: s.find((e) => e.id === t.variableId)?.initialValue ?? null
4103
+ }, (J(n) || n !== void 0 && Y(n) !== Y(i[e])) && (a[e] = n));
4104
+ }
4105
+ for (let [e, t] of Object.entries(r)) !J(t) || !ei(t.variableId) || a[e] === void 0 && i[e] === void 0 && Y(n[e]) !== Y(t) && (a[e] = t);
4106
+ Object.keys(i).length > 0 && E.push({
4107
+ type: "update-data-source-params",
4108
+ dataSourceId: t,
4109
+ params: i
4110
+ }), Object.keys(a).length > 0 && D.push({
4111
+ type: "update-data-source-params",
4112
+ dataSourceId: t,
4113
+ params: a
4114
+ });
4115
+ }
4116
+ let O = [];
4117
+ return p.length + h.length > 0 && O.push({
4118
+ type: "remove-blueprint-elements",
4119
+ nodeIds: p,
4120
+ edgeIds: h
4121
+ }), O.push(...E), b.length > 0 && O.push({
4122
+ type: "remove-variables",
4123
+ variableIds: b.map((e) => String(e.id))
4124
+ }), C.length > 0 && O.push({
4125
+ type: "add-variables",
4126
+ variables: C
4127
+ }), {
4128
+ detach: O,
4129
+ attach: D,
4130
+ wire: v.length + y.length > 0 ? [{
4131
+ type: "add-blueprint-elements",
4132
+ nodes: v,
4133
+ edges: y
4134
+ }] : []
4135
+ };
4136
+ }
4137
+ var ni = [
4138
+ "type",
4139
+ "name",
4140
+ "parentId",
4141
+ "position",
4142
+ "size",
4143
+ "rotation",
4144
+ "props",
4145
+ "style",
4146
+ "dataValue",
4147
+ "dataBinding",
4148
+ "states",
4149
+ "status"
4150
+ ];
4151
+ function ri(e, t) {
4152
+ let n = e, r = t;
4153
+ return ni.every((e) => Y(n[e]) === Y(r[e]));
4154
+ }
4155
+ function Y(e) {
4156
+ return JSON.stringify(ii(e ?? null));
4157
+ }
4158
+ function ii(e) {
4159
+ return Array.isArray(e) ? e.map(ii) : typeof e != "object" || !e ? e : Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => [e, ii(t)]));
4160
+ }
4161
+ function ai(e, t) {
4162
+ let n = e, r = t, i = {};
4163
+ for (let e of ni) e !== "type" && Y(n[e]) !== Y(r[e]) && (i[e] = r[e]);
4164
+ return i;
4165
+ }
4166
+ function oi(e, t, n, r = /* @__PURE__ */ new Map()) {
4167
+ let i = /* @__PURE__ */ new Set();
4168
+ for (let e of t) {
4169
+ let t = e.dataValue;
4170
+ typeof t?.dataSourceId == "string" && i.add(t.dataSourceId);
4171
+ }
4172
+ let a = (e) => (t) => {
4173
+ let n = t.dataValue, r = typeof n?.dataSourceId == "string" ? e.get(n.dataSourceId) : void 0;
4174
+ return r === void 0 || n === null ? t : {
4175
+ ...t,
4176
+ dataValue: {
4177
+ ...n,
4178
+ dataSourceId: r
4179
+ }
4180
+ };
4181
+ }, o = /* @__PURE__ */ new Map(), s = (t) => {
4182
+ let n = X(t.dataValue), i = X(e.components.find((e) => e.id === t.id)?.dataValue), s = i === void 0 ? void 0 : r.get(i);
4183
+ return n === void 0 || s === void 0 ? t : (o.set(n, s), a(o)(t));
4184
+ };
4185
+ if (i.size === 0) return {
4186
+ fresh: [],
4187
+ apply: a(r),
4188
+ applyPrevious: s
4189
+ };
4190
+ let c = new Set(n.map((e) => String(e.id))), l = new Map(r), u = [];
4191
+ for (let t of e.dataSources ?? []) {
4192
+ let e = String(t.id);
4193
+ if (!i.has(e) || l.has(e)) continue;
4194
+ let r = n.find((e) => JSON.stringify({
4195
+ ...e,
4196
+ id: ""
4197
+ }) === JSON.stringify({
4198
+ ...t,
4199
+ id: ""
4200
+ }));
4201
+ if (r !== void 0) {
4202
+ l.set(e, String(r.id));
4203
+ continue;
4204
+ }
4205
+ let a = e;
4206
+ for (let t = 2; c.has(a); t += 1) a = `${e}-e${t}`;
4207
+ c.add(a), l.set(e, a), u.push({
4208
+ ...t,
4209
+ id: a
4210
+ });
4211
+ }
4212
+ return {
4213
+ fresh: u,
4214
+ apply: a(l),
4215
+ applyPrevious: s
4216
+ };
4217
+ }
4218
+ function X(e) {
4219
+ return K(e) && e.kind === "data-source-field" && typeof e.dataSourceId == "string" ? e.dataSourceId : void 0;
4220
+ }
4221
+ function si(e, t) {
4222
+ if (e === void 0 || t === void 0) return !1;
4223
+ let n = K(e.params) ? e.params : {}, r = K(t.params) ? t.params : {}, i = (e) => J(e) && ei(e.variableId), a = new Set([...Object.keys(n), ...Object.keys(r)].filter((e) => i(n[e]) || i(r[e]))), o = (e) => Object.fromEntries(Object.entries(e).filter(([e]) => !a.has(e)));
4224
+ return Y({
4225
+ source: e.source,
4226
+ name: e.name,
4227
+ params: o(n)
4228
+ }) === Y({
4229
+ source: t.source,
4230
+ name: t.name,
4231
+ params: o(r)
4232
+ });
4233
+ }
4234
+ function ci(e, t) {
4235
+ let n = new Map(t.components.map((e) => [e.id, e])), r;
4236
+ for (let i of e) {
4237
+ if (!kr(i, t)) continue;
4238
+ let e = i.compiled.document.components, a = 0, o = 0;
4239
+ for (let t of e) {
4240
+ let e = n.get(t.id);
4241
+ e !== void 0 && (a += 1, ri(t, e) && (o += 1));
4242
+ }
4243
+ if (a < 3 || a < e.length / 2) continue;
4244
+ let s = e.length - a, c = t.components.filter((t) => !e.some((e) => e.id === t.id)).length, l = o - s - c;
4245
+ (r === void 0 || l > r.score) && (r = {
4246
+ session: i,
4247
+ score: l
4248
+ });
4249
+ }
4250
+ return r?.session;
4251
+ }
4252
+ function li(e) {
4253
+ let { intent: t } = e, n = Ie(t.title, t.subtitle), r = (e, t) => ({
4254
+ target: G(e),
4255
+ kind: "block",
4256
+ part: t,
4257
+ type: e.type,
4258
+ title: e.title === "" ? e.type : e.title,
4259
+ ...e.key === void 0 ? {} : { key: e.key }
4260
+ }), i = (t.interactions ?? []).map((e) => ({
4261
+ target: e.origin,
4262
+ kind: e.kind,
4263
+ from: e.from,
4264
+ to: e.to,
4265
+ event: e.event,
4266
+ ...e.kind === "filter" ? {
4267
+ param: e.param,
4268
+ ...e.field === void 0 ? {} : { field: e.field },
4269
+ ...e.reset === !0 ? { reset: !0 } : {}
4270
+ } : e.kind === "show" ? { mode: e.mode } : { state: e.state }
4271
+ }));
213
4272
  return {
214
- ok: !1,
215
- diagnostics: []
4273
+ title: t.title,
4274
+ subtitle: t.subtitle,
4275
+ ...i.length === 0 ? {} : { interactions: i },
4276
+ regions: t.regions.map((e) => e.kind === "band" ? {
4277
+ path: e.origin,
4278
+ kind: "band",
4279
+ items: e.items.map((e) => ({
4280
+ target: G(e),
4281
+ kind: "kpi",
4282
+ part: "items",
4283
+ title: e.label,
4284
+ value: Le(e, n),
4285
+ ...e.key === void 0 ? {} : { key: e.key },
4286
+ ...e.states === void 0 || e.states.rules.length === 0 ? {} : { states: e.states.rules.map((e) => e.label ?? `${e.tone}`) }
4287
+ }))
4288
+ } : e.kind === "grid" ? {
4289
+ path: e.origin,
4290
+ kind: "grid",
4291
+ items: e.blocks.map((e) => r(e, "blocks"))
4292
+ } : {
4293
+ path: e.origin,
4294
+ kind: "split",
4295
+ items: [...e.main.map((e) => r(e, "main")), ...e.rail.map((e) => r(e, "rail"))]
4296
+ })
4297
+ };
4298
+ }
4299
+ //#endregion
4300
+ //#region ../host-kit/dist/intent/intent-stream.js
4301
+ var ui = 6, di = 8, fi = 5, pi = 8, mi = /* @__PURE__ */ new Set(["wide-narrow", "even"]), hi = /* @__PURE__ */ new Set(["left", "right"]);
4302
+ function gi(e, t) {
4303
+ let n = bi(e);
4304
+ if (n === null) return;
4305
+ if (Array.isArray(n.regions)) {
4306
+ if (n.regions.length < 1 || n.regions.length > ui) return;
4307
+ let e = [];
4308
+ for (let r of n.regions) {
4309
+ let n = _i(r, t);
4310
+ if (n === void 0) return;
4311
+ e.push(n);
4312
+ }
4313
+ return { regions: e };
4314
+ }
4315
+ let r = n.kpis;
4316
+ if (typeof r != "number" || !Number.isInteger(r) || r < 1 || r > fi) return;
4317
+ let i = vi(n.blocks, t, pi);
4318
+ return i === void 0 ? void 0 : At(r, i);
4319
+ }
4320
+ function _i(e, t) {
4321
+ let n = bi(e);
4322
+ if (n !== null) {
4323
+ if (n.kind === "band") {
4324
+ let e = n.count;
4325
+ return typeof e != "number" || !Number.isInteger(e) || e < 1 || e > di ? void 0 : {
4326
+ kind: "band",
4327
+ count: e
4328
+ };
4329
+ }
4330
+ if (n.kind === "grid") {
4331
+ let e = vi(n.blocks ?? n.slots, t, di);
4332
+ return e === void 0 ? void 0 : {
4333
+ kind: "grid",
4334
+ slots: e
4335
+ };
4336
+ }
4337
+ if (n.kind === "split") {
4338
+ let e = n.ratio === void 0 ? "wide-narrow" : n.ratio, r = n.railSide === void 0 ? "right" : n.railSide;
4339
+ if (typeof e != "string" || !mi.has(e) || typeof r != "string" || !hi.has(r)) return;
4340
+ let i = vi(n.main, t, di), a = vi(n.rail, t, di);
4341
+ return i === void 0 || a === void 0 ? void 0 : {
4342
+ kind: "split",
4343
+ ratio: e,
4344
+ railSide: r,
4345
+ main: i.map((e) => ({ data: e.data })),
4346
+ rail: a.map((e) => ({ data: e.data }))
4347
+ };
4348
+ }
4349
+ }
4350
+ }
4351
+ function vi(e, t, n) {
4352
+ if (!Array.isArray(e) || e.length < 1 || e.length > n) return;
4353
+ let r = [];
4354
+ for (let n of e) {
4355
+ let e = bi(n), i = typeof e?.type == "string" ? e.type.trim() : "", a = t.materials.find((e) => e.type === i);
4356
+ if (e === null || a === void 0 || a.children === !0) return;
4357
+ let o = e.span === void 0 ? 1 : e.span;
4358
+ if (typeof o != "number" || !Number.isFinite(o)) return;
4359
+ r.push({
4360
+ span: Math.min(4, Math.max(1, Math.round(o))),
4361
+ data: a.data === "tabular"
4362
+ });
4363
+ }
4364
+ return r;
4365
+ }
4366
+ function yi(e) {
4367
+ let t, n, r = {}, i = {}, a = {
4368
+ kpis: /* @__PURE__ */ new Set(),
4369
+ blocks: /* @__PURE__ */ new Set()
4370
+ }, o = /* @__PURE__ */ new Set(), s = (e) => {
4371
+ for (let [t, n] of e.regions.entries()) {
4372
+ let r = e.flat === !0 ? n.kind === "band" ? "kpis" : "blocks" : `regions[${t}]`, i = (t, n) => e.flat === !0 ? `${r}[${n}]` : `${r}.${t}[${n}]`;
4373
+ if (n.kind === "band") for (let e = 0; e < n.count; e += 1) a.kpis.add(i("items", e));
4374
+ else if (n.kind === "grid") for (let e = 0; e < n.slots.length; e += 1) a.blocks.add(i("blocks", e)), o.add(i("blocks", e));
4375
+ else {
4376
+ for (let e = 0; e < n.main.length; e += 1) a.blocks.add(i("main", e));
4377
+ for (let e = 0; e < n.rail.length; e += 1) a.blocks.add(i("rail", e));
4378
+ }
4379
+ }
4380
+ };
4381
+ return {
4382
+ skeleton(r) {
4383
+ if (t !== void 0) return !1;
4384
+ let i = gi(r.layout, e);
4385
+ return i === void 0 || r.title.trim() === "" || r.subtitle.trim() === "" ? !1 : (t = r, n = i, s(i), !0);
4386
+ },
4387
+ item(t, s) {
4388
+ if (n === void 0) return !1;
4389
+ if (a.kpis.has(t)) {
4390
+ let e = z(s, t);
4391
+ return e.value === void 0 || t in r ? !1 : (r[t] = e.value, !0);
4392
+ }
4393
+ if (a.blocks.has(t)) {
4394
+ let n = B(s, e, t, { grid: o.has(t) });
4395
+ return n.value === void 0 || t in i ? !1 : (i[t] = n.value, !0);
4396
+ }
4397
+ return !1;
4398
+ },
4399
+ frame() {
4400
+ if (t !== void 0 && n !== void 0) return {
4401
+ intent: {
4402
+ title: R(t.title.trim(), 20),
4403
+ subtitle: R(t.subtitle.trim(), 40),
4404
+ ...t.style === void 0 || t.style === "" ? {} : { style: t.style },
4405
+ regions: []
4406
+ },
4407
+ stream: {
4408
+ skeleton: n,
4409
+ kpis: { ...r },
4410
+ blocks: { ...i }
4411
+ }
4412
+ };
4413
+ }
216
4414
  };
217
4415
  }
4416
+ function bi(e) {
4417
+ return typeof e == "object" && e && !Array.isArray(e) ? e : null;
4418
+ }
218
4419
  //#endregion
219
4420
  //#region ../host-kit/dist/project-adapter.js
220
- function x(e) {
221
- let t = e.migrate ?? a;
222
- async function n(e, n, r, a) {
223
- if (n.signal.aborted) return w();
224
- let o = await d(e, n, n.signal);
225
- if (n.signal.aborted || !o.ok && o.error.code === "ABORTED") return w();
4421
+ function xi(e) {
4422
+ let t = e.migrate ?? s;
4423
+ async function n(e, n, r, i) {
4424
+ if (n.signal.aborted) return Z();
4425
+ let o = await y(e, n, n.signal);
4426
+ if (n.signal.aborted || !o.ok && o.error.code === "ABORTED") return Z();
226
4427
  let s;
227
- if (!o.ok) s = T(r && (o.error.code === "REVISION_CONFLICT" || o.error.status === 409) ? "PROJECT_CONFLICT" : "PROJECT_UNAVAILABLE", r ? ["revision"] : [], o.error.message);
4428
+ if (!o.ok) s = wi(r && (o.error.code === "REVISION_CONFLICT" || o.error.status === 409) ? "PROJECT_CONFLICT" : "PROJECT_UNAVAILABLE", r ? ["revision"] : [], o.error.message);
228
4429
  else try {
229
- let a = e.response ? e.response(o.data, n) : o.data;
230
- if (n.signal.aborted) return w();
231
- if (r) s = i(a);
232
- else if (typeof a != "object" || !a || !("document" in a)) s = T("PROJECT_UNAVAILABLE", [], "项目信封格式无效。");
4430
+ let i = e.response ? e.response(o.data, n) : o.data;
4431
+ if (n.signal.aborted) return Z();
4432
+ if (r) s = a(i);
4433
+ else if (typeof i != "object" || !i || !("document" in i)) s = wi("PROJECT_UNAVAILABLE", [], "项目信封格式无效。");
233
4434
  else {
234
- let e = t(a.document);
235
- if (n.signal.aborted) return w();
236
- s = e.ok ? i({
237
- ...a,
4435
+ let e = t(i.document);
4436
+ if (n.signal.aborted) return Z();
4437
+ s = e.ok ? a({
4438
+ ...i,
238
4439
  document: e.document
239
4440
  }) : {
240
4441
  ok: !1,
@@ -242,9 +4443,9 @@ function x(e) {
242
4443
  };
243
4444
  }
244
4445
  } catch {
245
- s = T("PROJECT_UNAVAILABLE", [], "项目信封格式无效。");
4446
+ s = wi("PROJECT_UNAVAILABLE", [], "项目信封格式无效。");
246
4447
  }
247
- return n.signal.aborted ? w() : (f(a, n, s, o.ok ? void 0 : o.error), s);
4448
+ return n.signal.aborted ? Z() : (b(i, n, s, o.ok ? void 0 : o.error), s);
248
4449
  }
249
4450
  return {
250
4451
  capabilities: { publish: !1 },
@@ -252,22 +4453,22 @@ function x(e) {
252
4453
  save: (t) => n(e.save, t, !0, e.onSaveResult)
253
4454
  };
254
4455
  }
255
- function S(e) {
256
- let t = s(e);
257
- return x({
4456
+ function Si(e) {
4457
+ let t = h(e);
4458
+ return xi({
258
4459
  ...e.migrate === void 0 ? {} : { migrate: e.migrate },
259
- load: p(t, e.mapping?.load, (e) => ({ path: `/screens/${encodeURIComponent(e.projectId)}` }), C),
260
- save: p(t, e.mapping?.save, (e) => ({
4460
+ load: x(t, e.mapping?.load, (e) => ({ path: `/screens/${encodeURIComponent(e.projectId)}` }), Ci),
4461
+ save: x(t, e.mapping?.save, (e) => ({
261
4462
  path: `/screens/${encodeURIComponent(e.projectId)}`,
262
4463
  method: "PUT",
263
4464
  body: {
264
4465
  document: e.document,
265
4466
  revision: Number(e.revision)
266
4467
  }
267
- }), C)
4468
+ }), Ci)
268
4469
  });
269
4470
  }
270
- function C(e) {
4471
+ function Ci(e) {
271
4472
  if (typeof e != "object" || !e || !("screen" in e)) return;
272
4473
  let t = e.screen;
273
4474
  if (!(typeof t != "object" || !t || !("id" in t) || !("name" in t) || !("revision" in t) || !("document" in t) || typeof t.revision != "number" || !Number.isSafeInteger(t.revision) || t.revision < 0)) return {
@@ -279,13 +4480,13 @@ function C(e) {
279
4480
  metadata: {}
280
4481
  };
281
4482
  }
282
- function w() {
4483
+ function Z() {
283
4484
  return {
284
4485
  ok: !1,
285
4486
  diagnostics: []
286
4487
  };
287
4488
  }
288
- function T(e, t, n) {
4489
+ function wi(e, t, n) {
289
4490
  return {
290
4491
  ok: !1,
291
4492
  diagnostics: [{
@@ -298,14 +4499,14 @@ function T(e, t, n) {
298
4499
  }
299
4500
  //#endregion
300
4501
  //#region ../host-kit/dist/push-result.js
301
- function E() {
4502
+ function Q() {
302
4503
  return {
303
4504
  ok: !0,
304
4505
  value: null,
305
4506
  diagnostics: []
306
4507
  };
307
4508
  }
308
- function D(e, t) {
4509
+ function $(e, t) {
309
4510
  return {
310
4511
  ok: !1,
311
4512
  diagnostics: [{
@@ -318,15 +4519,15 @@ function D(e, t) {
318
4519
  }
319
4520
  //#endregion
320
4521
  //#region ../host-kit/dist/sse-subscribe.js
321
- var O = /* @__PURE__ */ new Set([
4522
+ var Ti = /* @__PURE__ */ new Set([
322
4523
  "snapshot",
323
4524
  "append",
324
4525
  "invalidate",
325
4526
  "status",
326
4527
  "heartbeat"
327
- ]), k = [...O], A = 2, j = 1e3, M = /^(.+):(\d+)$/;
328
- function N(e) {
329
- let t = Math.max(0, e.suspendAfterMs ?? 3e4), n = e.cursorFromEventId ?? !0, r = e.events ?? k;
4528
+ ]), Ei = [...Ti], Di = 2, Oi = 1e3, ki = /^(.+):(\d+)$/;
4529
+ function Ai(e) {
4530
+ let t = Math.max(0, e.suspendAfterMs ?? 3e4), n = e.cursorFromEventId ?? !0, r = e.events ?? Ei;
330
4531
  return (i, a, o) => {
331
4532
  let s;
332
4533
  try {
@@ -334,10 +4535,10 @@ function N(e) {
334
4535
  } catch {
335
4536
  s = void 0;
336
4537
  }
337
- if (s === void 0) return D("HOST_RESOURCE_ACCESS_DENIED", "Subscription is not allowed for this request.");
4538
+ if (s === void 0) return $("HOST_RESOURCE_ACCESS_DENIED", "Subscription is not allowed for this request.");
338
4539
  let c = e.EventSource ?? globalThis.EventSource;
339
- if (c === void 0) return D("HOST_RESOURCE_UNAVAILABLE", "EventSource is not available.");
340
- if (o.signal.aborted) return E();
4540
+ if (c === void 0) return $("HOST_RESOURCE_UNAVAILABLE", "EventSource is not available.");
4541
+ if (o.signal.aborted) return Q();
341
4542
  let l = !1, u = !1, d = [], f, p, m, h, g = (e) => {
342
4543
  if (!l) try {
343
4544
  a.push(e);
@@ -377,7 +4578,7 @@ function N(e) {
377
4578
  g(e);
378
4579
  return;
379
4580
  }
380
- d.push(e), d.length > j && d.shift();
4581
+ d.push(e), d.length > Oi && d.shift();
381
4582
  }, S = () => {
382
4583
  let t = e.fetchSnapshot;
383
4584
  if (t === void 0) return;
@@ -403,28 +4604,28 @@ function N(e) {
403
4604
  if (l) return;
404
4605
  let a = typeof r.lastEventId == "string" ? r.lastEventId : "", o = {
405
4606
  event: t,
406
- data: P(r.data),
4607
+ data: ji(r.data),
407
4608
  lastEventId: a
408
4609
  }, s;
409
4610
  try {
410
- s = (e.mapEvent ?? F)(o, i);
4611
+ s = (e.mapEvent ?? Mi)(o, i);
411
4612
  } catch {
412
4613
  s = void 0;
413
4614
  }
414
4615
  if (s === void 0) return;
415
4616
  let c = Array.isArray(s) ? s : [s];
416
- for (let e of c) x(n ? I(e, a) : e);
4617
+ for (let e of c) x(n ? Ni(e, a) : e);
417
4618
  };
418
4619
  try {
419
4620
  h = new c(s, e.withCredentials === void 0 ? void 0 : { withCredentials: e.withCredentials });
420
4621
  } catch {
421
- return D("HOST_RESOURCE_UNAVAILABLE", "Subscription stream could not be opened.");
4622
+ return $("HOST_RESOURCE_UNAVAILABLE", "Subscription stream could not be opened.");
422
4623
  }
423
4624
  h.addEventListener("open", () => {
424
4625
  l || (p !== void 0 && clearTimeout(p), p = void 0, _("open"), S());
425
4626
  }), h.addEventListener("error", () => {
426
4627
  if (!l) {
427
- if (h.readyState === A) {
4628
+ if (h.readyState === Di) {
428
4629
  y("Subscription stream was closed by the server.");
429
4630
  return;
430
4631
  }
@@ -434,10 +4635,10 @@ function N(e) {
434
4635
  }
435
4636
  });
436
4637
  for (let e of /* @__PURE__ */ new Set(["message", ...r])) h.addEventListener(e, (t) => C(e, t));
437
- return o.signal.addEventListener("abort", v, { once: !0 }), E();
4638
+ return o.signal.addEventListener("abort", v, { once: !0 }), Q();
438
4639
  };
439
4640
  }
440
- function P(e) {
4641
+ function ji(e) {
441
4642
  if (typeof e != "string") return e;
442
4643
  try {
443
4644
  return JSON.parse(e);
@@ -445,18 +4646,18 @@ function P(e) {
445
4646
  return e;
446
4647
  }
447
4648
  }
448
- function F(e) {
4649
+ function Mi(e) {
449
4650
  let t = e.data;
450
4651
  if (typeof t != "object" || !t || Array.isArray(t)) return e.event === "heartbeat" ? { type: "heartbeat" } : e.event === "invalidate" ? { type: "invalidate" } : void 0;
451
4652
  let n = t, r = typeof n.type == "string" ? n.type : e.event;
452
- if (O.has(r)) return {
4653
+ if (Ti.has(r)) return {
453
4654
  ...n,
454
4655
  type: r
455
4656
  };
456
4657
  }
457
- function I(e, t) {
4658
+ function Ni(e, t) {
458
4659
  if (e.type !== "snapshot" && e.type !== "append" || e.cursor !== void 0) return e;
459
- let n = M.exec(t);
4660
+ let n = ki.exec(t);
460
4661
  if (n === null) return e;
461
4662
  let r = Number(n[2]);
462
4663
  return Number.isSafeInteger(r) ? {
@@ -469,14 +4670,14 @@ function I(e, t) {
469
4670
  }
470
4671
  //#endregion
471
4672
  //#region ../host-kit/dist/subscription-hub.js
472
- var L = 2e3, R = 1e3;
473
- function z(e) {
474
- let t = Math.max(0, e.lingerMs ?? L), n = Math.max(1, Math.floor(e.replayRows ?? R)), r = /* @__PURE__ */ new Map(), i = (e) => {
4673
+ var Pi = 2e3, Fi = 1e3;
4674
+ function Ii(e) {
4675
+ let t = Math.max(0, e.lingerMs ?? Pi), n = Math.max(1, Math.floor(e.replayRows ?? Fi)), r = /* @__PURE__ */ new Map(), i = (e) => {
475
4676
  e.closed || (e.closed = !0, e.lingerTimer !== void 0 && clearTimeout(e.lingerTimer), e.lingerTimer = void 0, e.listeners.clear(), r.get(e.key) === e && r.delete(e.key), e.controller.abort());
476
4677
  }, a = (e, t) => {
477
4678
  if (!(e.closed || typeof t != "object" || !t)) {
478
- B(e, t, n);
479
- for (let n of [...e.listeners]) U(n.sink, t);
4679
+ Li(e, t, n);
4680
+ for (let n of [...e.listeners]) Bi(n.sink, t);
480
4681
  t.type === "status" && t.status === "failed" && i(e);
481
4682
  }
482
4683
  }, o = (e, n) => {
@@ -492,15 +4693,15 @@ function z(e) {
492
4693
  };
493
4694
  return {
494
4695
  subscribe: (t, n, s) => {
495
- if (s.signal.aborted) return E();
4696
+ if (s.signal.aborted) return Q();
496
4697
  let c;
497
4698
  try {
498
4699
  c = e.keyOf(t);
499
4700
  } catch {
500
- return D("HOST_RESOURCE_INVALID", "Subscription key could not be derived.");
4701
+ return $("HOST_RESOURCE_INVALID", "Subscription key could not be derived.");
501
4702
  }
502
4703
  let l = { sink: n }, u = r.get(c);
503
- if (u !== void 0 && !u.closed) u.lingerTimer !== void 0 && clearTimeout(u.lingerTimer), u.lingerTimer = void 0, u.listeners.add(l), V(u, n);
4704
+ if (u !== void 0 && !u.closed) u.lingerTimer !== void 0 && clearTimeout(u.lingerTimer), u.lingerTimer = void 0, u.listeners.add(l), Ri(u, n);
504
4705
  else {
505
4706
  let n = {
506
4707
  key: c,
@@ -520,15 +4721,15 @@ function z(e) {
520
4721
  signal: n.controller.signal
521
4722
  });
522
4723
  } catch {
523
- o = D("HOST_RESOURCE_UNAVAILABLE", "Upstream subscription could not be opened.");
4724
+ o = $("HOST_RESOURCE_UNAVAILABLE", "Upstream subscription could not be opened.");
524
4725
  }
525
4726
  if (!o.ok) return i(n), o;
526
- if (n.closed) return E();
4727
+ if (n.closed) return Q();
527
4728
  }
528
4729
  return s.signal.addEventListener("abort", () => {
529
4730
  let e = r.get(c);
530
4731
  e !== void 0 && e.listeners.has(l) && o(e, l);
531
- }, { once: !0 }), E();
4732
+ }, { once: !0 }), Q();
532
4733
  },
533
4734
  channelCount: () => r.size,
534
4735
  dispose: () => {
@@ -536,7 +4737,7 @@ function z(e) {
536
4737
  }
537
4738
  };
538
4739
  }
539
- function B(e, t, n) {
4740
+ function Li(e, t, n) {
540
4741
  switch (t.type) {
541
4742
  case "snapshot":
542
4743
  e.snapshot = {
@@ -547,7 +4748,7 @@ function B(e, t, n) {
547
4748
  case "append": {
548
4749
  let r = e.snapshot;
549
4750
  if (r === void 0 || !Array.isArray(t.rows)) return;
550
- let i = H(r.value);
4751
+ let i = zi(r.value);
551
4752
  if (i === void 0) return;
552
4753
  let a = [...i, ...t.rows], o = a.length > n ? a.slice(a.length - n) : a;
553
4754
  e.snapshot = {
@@ -568,29 +4769,29 @@ function B(e, t, n) {
568
4769
  default: return;
569
4770
  }
570
4771
  }
571
- function V(e, t) {
572
- e.status !== void 0 && U(t, {
4772
+ function Ri(e, t) {
4773
+ e.status !== void 0 && Bi(t, {
573
4774
  type: "status",
574
4775
  status: e.status
575
4776
  });
576
4777
  let n = e.snapshot;
577
- n !== void 0 && (U(t, {
4778
+ n !== void 0 && (Bi(t, {
578
4779
  type: "snapshot",
579
4780
  value: n.value,
580
4781
  ...n.cursor === void 0 ? {} : { cursor: n.cursor }
581
- }), e.invalidated && U(t, { type: "invalidate" }));
4782
+ }), e.invalidated && Bi(t, { type: "invalidate" }));
582
4783
  }
583
- function H(e) {
4784
+ function zi(e) {
584
4785
  if (typeof e != "object" || !e || Array.isArray(e)) return;
585
4786
  let t = e.rows;
586
4787
  return Array.isArray(t) ? t : void 0;
587
4788
  }
588
- function U(e, t) {
4789
+ function Bi(e, t) {
589
4790
  try {
590
4791
  e.push(t);
591
4792
  } catch {}
592
4793
  }
593
4794
  //#endregion
594
- export { h as createHostDatasetPort, s as createHostKitHttp, x as createHostProjectAdapter, S as createHttpProjectAdapter, g as createRestDatasetPort, N as createSseSubscribe, z as createSubscriptionHub, u as toAbortSignal, l as toHostKitSearch };
4795
+ export { k as BEHAVIOR_REPAIRABLE, ut as DEFAULT_INTENT_STYLE, Mt as INTENT_MAX_REFERENCED_DATASETS, lt as INTENT_STYLE_PRESETS, ct as INTENT_STYLE_PRESET_IDS, Mr as applyIntentOps, fr as compileFreeformIntent, ee as compileIntentBehaviors, mt as compileScreenIntent, dr as createFreeformStreamAssembler, C as createHostDatasetPort, h as createHostKitHttp, xi as createHostProjectAdapter, Si as createHttpProjectAdapter, Or as createIntentSession, yi as createIntentStreamAssembler, w as createRestDatasetPort, Ai as createSseSubscribe, Ii as createSubscriptionHub, li as describeSession, Ie as detectIntentLanguage, Ar as editIntent, At as flatSkeleton, Re as formatKpiDelta, Le as formatKpiValue, jt as intentDatasetQueryKey, kr as isSessionUsable, Dr as mapDocumentIssues, ur as parseFreeformIntent, B as parseIntentBlock, z as parseIntentKpi, gi as parseIntentSkeleton, xn as parseScreenIntent, Qn as parseScreenIntentInteractions, ci as pickSession, wr as prepareIntent, Pt as prepareIntentDataContext, Er as repairKey, dt as resolveIntentStyle, M as seedFilterTargets, Ze as solveLayout, Vt as summarizeIntentDataContext, v as toAbortSignal, _ as toHostKitSearch, Ut as validateIntentData };
595
4796
 
596
4797
  //# sourceMappingURL=host-kit.js.map