@salsita-ai/sdk 0.50.0-develop.9241bcf09e → 0.50.0-develop.927e2414eb

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 (527) hide show
  1. package/README.md +3 -3
  2. package/dist/admin/common/admin-interface.d.ts +11 -1
  3. package/dist/admin/common/admin-interface.js +1 -1
  4. package/dist/admin/ui/layout/UserProfile.d.ts +1 -1
  5. package/dist/admin/ui/layout/UserProfile.js +1 -1
  6. package/dist/admin/ui/maintenance/ImportPresets.js +1 -1
  7. package/dist/application/mount-application.js +1 -1
  8. package/dist/application/mount-configurator.js +1 -1
  9. package/dist/application/studio-embedding.d.ts +6 -0
  10. package/dist/application/studio-embedding.js +1 -0
  11. package/dist/application-spec/core/enhanced-json-schema.d.ts +5 -6
  12. package/dist/application-spec/core/enhanced-json-schema.js +1 -1
  13. package/dist/application-spec/core/markers/index.d.ts +1 -0
  14. package/dist/application-spec/core/markers/index.js +1 -1
  15. package/dist/application-spec/core/markers/set-in-studio-marker.d.ts +15 -0
  16. package/dist/application-spec/core/markers/set-in-studio-marker.js +1 -0
  17. package/dist/application-spec/errors/diagnostic-codes.d.ts +16 -0
  18. package/dist/application-spec/errors/diagnostic-codes.js +1 -1
  19. package/dist/application-spec/errors/diagnostic-messages.d.ts +16 -0
  20. package/dist/application-spec/errors/diagnostic-messages.js +1 -1
  21. package/dist/application-spec/generate-application/code/domain-runtime-files.d.ts +3 -3
  22. package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
  23. package/dist/application-spec/generate-application/code/standalone-app-files.d.ts +0 -12
  24. package/dist/application-spec/generate-application/code/standalone-app-files.js +1 -1
  25. package/dist/application-spec/generate-application/code/templates/admin-config.d.ts +5 -1
  26. package/dist/application-spec/generate-application/code/templates/admin-config.js +4 -4
  27. package/dist/application-spec/generate-application/code/templates/application-types.js +5 -5
  28. package/dist/application-spec/generate-application/code/templates/configurator-config.js +6 -6
  29. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.d.ts +1 -1
  30. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.js +19 -0
  31. package/dist/application-spec/generate-application/code/templates/domain-spec.js +12 -12
  32. package/dist/application-spec/generate-application/code/templates/frontend-config.js +7 -3
  33. package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.d.ts +3 -3
  34. package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +3 -3
  35. package/dist/application-spec/generate-application/code/templates/global-definition/generate-assistant-form-element-types.d.ts +10 -6
  36. package/dist/application-spec/generate-application/code/templates/global-definition/generate-assistant-form-element-types.js +7 -7
  37. package/dist/application-spec/generate-application/code/templates/global-definition/generate-phx-types.js +12 -12
  38. package/dist/application-spec/generate-application/code/templates/globals.js +21 -12
  39. package/dist/application-spec/generate-application/code/templates/index.d.ts +1 -1
  40. package/dist/application-spec/generate-application/code/templates/index.js +1 -1
  41. package/dist/application-spec/generate-application/code/templates/sign-in-page-options.d.ts +5 -0
  42. package/dist/application-spec/generate-application/code/templates/sign-in-page-options.js +1 -0
  43. package/dist/application-spec/generate-application/code/templates/skills/core/cli.d.ts +2 -1
  44. package/dist/application-spec/generate-application/code/templates/skills/core/cli.js +1 -1
  45. package/dist/application-spec/generate-application/code/templates/skills/core/sdk.js +2 -1
  46. package/dist/application-spec/generate-application/code/templates/skills/features/application-states/presets.js +1 -1
  47. package/dist/application-spec/generate-application/code/templates/skills/features/application-states/views-and-tools.js +1 -1
  48. package/dist/application-spec/generate-application/code/templates/skills/features/assistant/index.d.ts +3 -0
  49. package/dist/application-spec/generate-application/code/templates/skills/features/assistant/index.js +1 -0
  50. package/dist/application-spec/generate-application/code/templates/skills/features/{custom-layout/assistant.d.ts → assistant/panel.d.ts} +1 -1
  51. package/dist/application-spec/generate-application/code/templates/skills/features/assistant/panel.js +42 -0
  52. package/dist/application-spec/generate-application/code/templates/skills/features/assistant/reading-and-changing.d.ts +3 -0
  53. package/dist/application-spec/generate-application/code/templates/skills/features/assistant/reading-and-changing.js +55 -0
  54. package/dist/application-spec/generate-application/code/templates/skills/features/{webhooks/assistant-setup.d.ts → assistant/session-setup.d.ts} +1 -1
  55. package/dist/application-spec/generate-application/code/templates/skills/features/assistant/session-setup.js +16 -0
  56. package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/custom-layout.js +2 -2
  57. package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/sign-in.d.ts +3 -0
  58. package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/sign-in.js +19 -0
  59. package/dist/application-spec/generate-application/code/templates/skills/features/domain-model/actions.js +1 -1
  60. package/dist/application-spec/generate-application/code/templates/skills/features/embedding.d.ts +2 -0
  61. package/dist/application-spec/generate-application/code/templates/skills/features/embedding.js +1 -0
  62. package/dist/application-spec/generate-application/code/templates/skills/features/features.js +1 -1
  63. package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/authentication.d.ts +1 -1
  64. package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/authentication.js +32 -26
  65. package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/entry-and-environment.js +1 -3
  66. package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/publishing.js +1 -1
  67. package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/session-fields.d.ts +3 -0
  68. package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/session-fields.js +1 -0
  69. package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/webhooks.js +1 -1
  70. package/dist/application-spec/generate-application/code/templates/skills/guide.d.ts +1 -1
  71. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill-bundle.d.ts +1 -1
  72. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill-bundle.js +3 -3
  73. package/dist/application-spec/generate-application/code/templates/skills/processes/asset-conversion.js +3 -3
  74. package/dist/application-spec/generate-application/code/templates/skills/processes/assistant-configuration.d.ts +3 -0
  75. package/dist/application-spec/generate-application/code/templates/skills/processes/assistant-configuration.js +3 -0
  76. package/dist/application-spec/generate-application/code/templates/skills/processes/feedback/report.js +2 -2
  77. package/dist/application-spec/generate-application/code/templates/skills/processes/first-draft/handoff.js +1 -1
  78. package/dist/application-spec/generate-application/code/templates/skills/processes/index.d.ts +2 -1
  79. package/dist/application-spec/generate-application/code/templates/skills/processes/index.js +1 -1
  80. package/dist/application-spec/generate-application/code/templates/skills/processes/model-migration.js +1 -1
  81. package/dist/application-spec/generate-application/code/templates/skills/processes/review/appearance.js +1 -1
  82. package/dist/application-spec/generate-application/code/templates/skills/processes/review/code.js +1 -1
  83. package/dist/application-spec/generate-application/code/templates/skills/processes/scene-realism.d.ts +2 -0
  84. package/dist/application-spec/generate-application/code/templates/skills/processes/scene-realism.js +29 -0
  85. package/dist/application-spec/generate-application/code/templates/skills/sdk-channel.d.ts +17 -0
  86. package/dist/application-spec/generate-application/code/templates/skills/sdk-channel.js +1 -0
  87. package/dist/application-spec/generate-application/code/templates/skills/sdk-subpath-imports.js +1 -1
  88. package/dist/application-spec/generate-application/code/templates/webhook-builders.js +3 -2
  89. package/dist/application-spec/generate-application/code/templates/webhook-index.d.ts +1 -2
  90. package/dist/application-spec/generate-application/code/templates/webhook-index.js +3 -7
  91. package/dist/application-spec/generate-application/code/webhook-safe-files.d.ts +3 -1
  92. package/dist/application-spec/generate-application/code/webhook-safe-files.js +1 -1
  93. package/dist/application-spec/parse-application-files/access/access-handler-kinds.d.ts +18 -0
  94. package/dist/application-spec/parse-application-files/access/access-handler-kinds.js +1 -0
  95. package/dist/application-spec/parse-application-files/access/analyzed-file.d.ts +7 -0
  96. package/dist/application-spec/parse-application-files/access/analyzed-file.js +1 -0
  97. package/dist/application-spec/parse-application-files/access/check-access-handler-files.d.ts +20 -0
  98. package/dist/application-spec/parse-application-files/access/check-access-handler-files.js +1 -0
  99. package/dist/application-spec/parse-application-files/access/check-auth-hook-files.d.ts +17 -0
  100. package/dist/application-spec/parse-application-files/access/check-auth-hook-files.js +1 -0
  101. package/dist/application-spec/parse-application-files/access/index.d.ts +5 -0
  102. package/dist/application-spec/parse-application-files/access/index.js +1 -0
  103. package/dist/application-spec/parse-application-files/access/sign-in-control.d.ts +7 -0
  104. package/dist/application-spec/parse-application-files/access/sign-in-control.js +1 -0
  105. package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +2 -1
  106. package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
  107. package/dist/application-spec/parse-application-files/categorize/module-analysis.d.ts +30 -4
  108. package/dist/application-spec/parse-application-files/categorize/module-analysis.js +1 -1
  109. package/dist/application-spec/parse-application-files/categorize/webhook-safety.js +1 -1
  110. package/dist/application-spec/parse-application-files/merge/merged-app-metadata.d.ts +16 -1
  111. package/dist/application-spec/parse-application-files/merge/merged-app-metadata.js +1 -1
  112. package/dist/application-spec/parse-application-files/merge/merged-assistant.js +1 -1
  113. package/dist/application-spec/parse-application-files/merge/merged-spec.d.ts +7 -1
  114. package/dist/application-spec/parse-application-files/merge/merged-spec.js +1 -1
  115. package/dist/application-spec/parse-application-files/parse-application-files.js +1 -1
  116. package/dist/application-spec/parse-application-files/parse-common-admin-spec.js +1 -1
  117. package/dist/application-spec/parse-application-files/raw-spec/raw-actions.d.ts +3 -2
  118. package/dist/application-spec/parse-application-files/raw-spec/raw-actions.js +1 -1
  119. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +29 -6
  120. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
  121. package/dist/application-spec/parse-application-files/raw-spec/raw-components.js +1 -1
  122. package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.d.ts +11 -3
  123. package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
  124. package/dist/application-spec/parse-application-files/resolve/resolve-import-modules.js +1 -1
  125. package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.d.ts +6 -0
  126. package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.js +1 -1
  127. package/dist/application-spec/parse-application-files/spec/model/index.d.ts +2 -1
  128. package/dist/application-spec/parse-application-files/spec/model/index.js +1 -1
  129. package/dist/application-spec/parse-application-files/spec/model/session-data-schema.d.ts +5 -2
  130. package/dist/application-spec/parse-application-files/spec/model/session-data-schema.js +1 -1
  131. package/dist/application-spec/parse-application-files/spec/model/session-fields/index.d.ts +1 -0
  132. package/dist/application-spec/parse-application-files/spec/model/session-fields/index.js +1 -0
  133. package/dist/application-spec/parse-application-files/spec/model/session-fields/session-fields.d.ts +15 -0
  134. package/dist/application-spec/parse-application-files/spec/model/session-fields/session-fields.js +1 -0
  135. package/dist/application-spec/parse-application-files/spec/relations/relations.js +1 -1
  136. package/dist/application-spec/parse-application-files/spec/sections/actions.js +1 -1
  137. package/dist/application-spec/parse-application-files/spec/sections/app-metadata.js +1 -1
  138. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-form-elements.d.ts +14 -2
  139. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-form-elements.js +1 -1
  140. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +6 -9
  141. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  142. package/dist/application-spec/parse-application-files/spec/sections/assistant/index.d.ts +0 -1
  143. package/dist/client/authenticated-client.d.ts +5 -1
  144. package/dist/client/authenticated-client.js +1 -1
  145. package/dist/client/authorized-client.d.ts +3 -1
  146. package/dist/client/authorized-client.js +1 -1
  147. package/dist/client/base-client.d.ts +15 -1
  148. package/dist/client/base-client.js +1 -1
  149. package/dist/client/cli-client/cli-api-client.d.ts +17 -0
  150. package/dist/client/cli-client/cli-api-client.js +1 -0
  151. package/dist/client/cli-client/index.d.ts +2 -0
  152. package/dist/client/cli-client/index.js +1 -0
  153. package/dist/client/cli-client/unsupported-api-version-error.d.ts +11 -0
  154. package/dist/client/cli-client/unsupported-api-version-error.js +1 -0
  155. package/dist/client/contract.d.ts +39 -4
  156. package/dist/client/contract.js +1 -1
  157. package/dist/client/index.d.ts +3 -1
  158. package/dist/client/index.js +1 -1
  159. package/dist/client/phoenix-api.d.ts +7834 -2378
  160. package/dist/client/unauthenticated-client.d.ts +2 -1
  161. package/dist/client/unauthenticated-client.js +1 -1
  162. package/dist/client/version.d.ts +11 -0
  163. package/dist/client/version.js +1 -1
  164. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  165. package/dist/configurator/application-runtime/extensions/systems/action-system/action.d.ts +16 -4
  166. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +25 -10
  167. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  168. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +15 -5
  169. package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/index.d.ts +1 -0
  170. package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/index.js +1 -1
  171. package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/register-webmcp-tools.d.ts +7 -3
  172. package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/register-webmcp-tools.js +6 -2
  173. package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/share-link.d.ts +14 -0
  174. package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/share-link.js +2 -0
  175. package/dist/configurator/application-runtime/extensions/systems/camera-control-system/camera-control-system.d.ts +41 -35
  176. package/dist/configurator/application-runtime/extensions/systems/camera-control-system/camera-control-system.js +1 -1
  177. package/dist/configurator/application-runtime/extensions/systems/export-system/export-system.d.ts +4 -2
  178. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
  179. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +9 -3
  180. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  181. package/dist/configurator/application-runtime/extensions/systems/graphql-system/read-offered-navigation.d.ts +6 -3
  182. package/dist/configurator/application-runtime/extensions/systems/graphql-system/read-offered-navigation.js +1 -1
  183. package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/export-image-capture.d.ts +15 -4
  184. package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/export-image-capture.js +3 -3
  185. package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/image-rendering-system.d.ts +15 -7
  186. package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/image-rendering-system.js +1 -1
  187. package/dist/configurator/common/configurator-interface.d.ts +13 -1
  188. package/dist/configurator/common/configurator-interface.js +1 -1
  189. package/dist/configurator/scene/animations/Animations.js +1 -1
  190. package/dist/configurator/scene/cameras/CameraPadding.d.ts +5 -0
  191. package/dist/configurator/scene/cameras/CameraPadding.js +1 -1
  192. package/dist/configurator/scene/resources/use-phx-gltf.js +1 -1
  193. package/dist/configurator/scene/scene-entity/materials/LocalCreatedMaterial.js +1 -1
  194. package/dist/configurator/scene/scene-entity/materials/RemoteReplacedMaterial.d.ts +5 -0
  195. package/dist/configurator/scene/scene-entity/materials/RemoteReplacedMaterial.js +1 -1
  196. package/dist/configurator/scene/scene-entity/materials/use-dispose-replaced.d.ts +27 -0
  197. package/dist/configurator/scene/scene-entity/materials/use-dispose-replaced.js +1 -0
  198. package/dist/configurator/toolbar-actions/use-toolbar-actions.js +1 -1
  199. package/dist/configurator/ui/assistant/AssistantComposer.js +1 -1
  200. package/dist/configurator/ui/assistant/AssistantPanel.js +1 -1
  201. package/dist/configurator/ui/assistant/annotation/editor/AnnotationComment.d.ts +6 -5
  202. package/dist/configurator/ui/assistant/annotation/editor/AnnotationComment.js +1 -1
  203. package/dist/configurator/ui/assistant/annotation/editor/AnnotationEditor.d.ts +4 -3
  204. package/dist/configurator/ui/assistant/annotation/editor/AnnotationEditor.js +1 -1
  205. package/dist/configurator/ui/assistant/annotation/editor/annotation-pins.d.ts +5 -0
  206. package/dist/configurator/ui/assistant/annotation/editor/annotation-pins.js +1 -1
  207. package/dist/configurator/ui/assistant/disclaimer/AssistantDisclaimerDialog.d.ts +10 -0
  208. package/dist/configurator/ui/assistant/disclaimer/AssistantDisclaimerDialog.js +1 -0
  209. package/dist/configurator/ui/assistant/disclaimer/AssistantDisclaimerLine.d.ts +10 -0
  210. package/dist/configurator/ui/assistant/disclaimer/AssistantDisclaimerLine.js +1 -0
  211. package/dist/configurator/ui/assistant/disclaimer/index.d.ts +2 -0
  212. package/dist/configurator/ui/assistant/disclaimer/index.js +1 -0
  213. package/dist/configurator/ui/assistant/drawing/AssistantDrawing.d.ts +2 -3
  214. package/dist/configurator/ui/assistant/drawing/AssistantDrawing.js +1 -1
  215. package/dist/configurator/ui/assistant/drawing/index.d.ts +1 -1
  216. package/dist/configurator/ui/assistant/drawing/index.js +1 -1
  217. package/dist/configurator/ui/assistant/drawing/use-drawing-url.d.ts +6 -12
  218. package/dist/configurator/ui/assistant/drawing/use-drawing-url.js +1 -1
  219. package/dist/configurator/ui/assistant/form/registry/create-assistant-form-element.d.ts +11 -7
  220. package/dist/configurator/ui/assistant/form-elements/FormTile.js +1 -1
  221. package/dist/configurator/ui/assistant/image-view/ImageView.js +1 -1
  222. package/dist/configurator/ui/assistant/panel/AssistantPanelHeader.js +1 -1
  223. package/dist/configurator/ui/assistant/use-assistant-composer.d.ts +5 -0
  224. package/dist/configurator/ui/assistant/use-assistant-composer.js +2 -2
  225. package/dist/configurator/ui/configurator-layout/index.d.ts +1 -1
  226. package/dist/configurator/ui/configurator-layout/index.js +1 -1
  227. package/dist/configurator/ui/configurator-layout/slots/desktop-sidebar/DesktopSidebar.js +4 -4
  228. package/dist/configurator/ui/configurator-layout/slots/index.d.ts +2 -0
  229. package/dist/configurator/ui/configurator-layout/slots/index.js +1 -1
  230. package/dist/configurator/ui/configurator-layout/slots/view-controls/DesktopViewControls.js +1 -1
  231. package/dist/configurator/ui/configurator-layout/slots/view-controls/MobileViewControls.js +1 -1
  232. package/dist/configurator/ui/configurator-layout/slots/view-controls/NestedViewControls.d.ts +7 -0
  233. package/dist/configurator/ui/configurator-layout/slots/view-controls/NestedViewControls.js +1 -0
  234. package/dist/configurator/ui/configurator-layout/slots/view-controls/use-view-control-items.d.ts +6 -0
  235. package/dist/configurator/ui/configurator-layout/slots/view-controls/use-view-control-items.js +1 -0
  236. package/dist/configurator/ui/configurator-layout/universal/DesktopPreview.js +1 -1
  237. package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +3 -3
  238. package/dist/configurator/ui/configurator-layout/universal/MobilePreview.js +1 -1
  239. package/dist/configurator/ui/configurator-layout/universal/use-preview-description.d.ts +1 -0
  240. package/dist/configurator/ui/configurator-layout/universal/use-preview-description.js +1 -0
  241. package/dist/configurator/ui/index.d.ts +1 -1
  242. package/dist/configurator/ui/legacy/layout/common/ViewControls.js +1 -1
  243. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.js +1 -1
  244. package/dist/docs/index.json +117 -2
  245. package/dist/docs/layouts/nested-view-controls.mdx +223 -0
  246. package/dist/docs/layouts/preview/always.mdx +22 -0
  247. package/dist/docs/layouts/view-controls.mdx +2 -0
  248. package/dist/docs/other-features/domain-actions.mdx +53 -56
  249. package/dist/docs/phoenix/admin.mdx +5 -40
  250. package/dist/docs/phoenix/application-states.mdx +1 -1
  251. package/dist/docs/phoenix/assistant/actions.mdx +183 -0
  252. package/dist/docs/phoenix/assistant/changing-the-configuration.mdx +333 -0
  253. package/dist/docs/phoenix/assistant/instructions-and-ai-settings.mdx +221 -0
  254. package/dist/docs/phoenix/assistant/overview.mdx +137 -0
  255. package/dist/docs/phoenix/assistant/per-session-setup.mdx +166 -0
  256. package/dist/docs/phoenix/assistant/reading-the-configuration.mdx +349 -0
  257. package/dist/docs/phoenix/assistant/screenshots.mdx +135 -0
  258. package/dist/docs/phoenix/assistant/security-and-limits.mdx +151 -0
  259. package/dist/docs/phoenix/assistant/the-panel.mdx +298 -0
  260. package/dist/docs/phoenix/clerk-sign-in.mdx +9 -5
  261. package/dist/docs/phoenix/configurator-interface.mdx +18 -33
  262. package/dist/docs/phoenix/csp.mdx +3 -1
  263. package/dist/docs/phoenix/data-sources.mdx +26 -30
  264. package/dist/docs/phoenix/deployments.mdx +3 -3
  265. package/dist/docs/phoenix/finalization.mdx +0 -1
  266. package/dist/docs/phoenix/integration/authentication-external.mdx +17 -15
  267. package/dist/docs/phoenix/integration/authentication-internal.mdx +1 -1
  268. package/dist/docs/phoenix/integration/finalization-internal.mdx +1 -4
  269. package/dist/docs/phoenix/integration/integration-modes-external.mdx +2 -2
  270. package/dist/docs/phoenix/integration/integration-modes-internal.mdx +9 -0
  271. package/dist/docs/phoenix/layout-slots.mdx +1 -1
  272. package/dist/docs/phoenix/migrations.mdx +1 -1
  273. package/dist/docs/phoenix/phoenix-cli.mdx +90 -57
  274. package/dist/docs/phoenix/project-structure.mdx +30 -15
  275. package/dist/docs/phoenix/publishing.mdx +21 -28
  276. package/dist/docs/phoenix/sdk-builder-workflow.mdx +51 -34
  277. package/dist/docs/phoenix/sessions-and-access.mdx +171 -164
  278. package/dist/docs/phoenix/webhook-membership.mdx +4 -1
  279. package/dist/docs/phoenix/webhooks.mdx +93 -116
  280. package/dist/docs/ux-guidelines/interaction-modes.mdx +2 -2
  281. package/dist/domain/application/access/access-handlers.d.ts +19 -0
  282. package/dist/domain/application/access/access-handlers.js +1 -0
  283. package/dist/domain/application/access/anonymous-handler.d.ts +16 -0
  284. package/dist/domain/application/access/anonymous-handler.js +1 -0
  285. package/dist/domain/application/access/chunk-scopes-handler.d.ts +27 -0
  286. package/dist/domain/application/access/chunk-scopes-handler.js +1 -0
  287. package/dist/domain/application/access/code-handler.d.ts +16 -0
  288. package/dist/domain/application/access/code-handler.js +1 -0
  289. package/dist/domain/application/access/index.d.ts +7 -0
  290. package/dist/domain/application/access/index.js +1 -0
  291. package/dist/domain/application/access/refresh-handler.d.ts +16 -0
  292. package/dist/domain/application/access/refresh-handler.js +1 -0
  293. package/dist/domain/application/access/signed-in-handler.d.ts +44 -0
  294. package/dist/domain/application/access/signed-in-handler.js +1 -0
  295. package/dist/domain/application/access/visitor-handler.d.ts +23 -0
  296. package/dist/domain/application/access/visitor-handler.js +1 -0
  297. package/dist/domain/application/application-config.d.ts +36 -1
  298. package/dist/domain/application/assistant/assistant-exposure.d.ts +22 -0
  299. package/dist/domain/application/assistant/assistant-exposure.js +1 -0
  300. package/dist/domain/application/assistant/build-assistant-lenses.js +3 -3
  301. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -1
  302. package/dist/domain/application/assistant/generate-assistant-prompt.d.ts +6 -2
  303. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -1
  304. package/dist/domain/application/assistant/index.d.ts +1 -0
  305. package/dist/domain/application/assistant/index.js +1 -1
  306. package/dist/domain/application/assistant/session-setup/apply-assistant-setup.js +1 -1
  307. package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.d.ts +14 -2
  308. package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.js +1 -1
  309. package/dist/domain/application/assistant/session-setup/assistant-takes-images.d.ts +7 -0
  310. package/dist/domain/application/assistant/session-setup/assistant-takes-images.js +1 -0
  311. package/dist/domain/application/assistant/session-setup/index.d.ts +1 -0
  312. package/dist/domain/application/assistant/session-setup/index.js +1 -1
  313. package/dist/domain/application/assistant-mutations.js +1 -1
  314. package/dist/domain/application/assistant-recipe-groups.d.ts +4 -3
  315. package/dist/domain/application/assistant-recipe-groups.js +1 -1
  316. package/dist/domain/application/configurator-builder.d.ts +2 -0
  317. package/dist/domain/application/configurator-builder.js +1 -1
  318. package/dist/domain/application/index.d.ts +2 -1
  319. package/dist/domain/application/index.js +1 -1
  320. package/dist/domain/application/standard-properties.d.ts +1 -1
  321. package/dist/domain/application/standard-properties.js +1 -1
  322. package/dist/domain/available-system-components/available-system-components.js +1 -1
  323. package/dist/domain/core/component/system-component-filter.d.ts +1 -0
  324. package/dist/domain/core/component/system-component-filter.js +1 -1
  325. package/dist/domain/core/component/view-state-component.d.ts +4 -3
  326. package/dist/domain/core/component/view-state-component.js +1 -1
  327. package/dist/domain/core/domain-factory.d.ts +6 -0
  328. package/dist/domain/core/domain-factory.js +1 -1
  329. package/dist/domain/core/fit-session-data.d.ts +16 -0
  330. package/dist/domain/core/fit-session-data.js +1 -0
  331. package/dist/domain/domain-context/navigation-system/navigation-system.d.ts +2 -2
  332. package/dist/domain/domain-context/navigation-system/navigation-system.js +1 -1
  333. package/dist/domain/domain-context/transformers/when-builder.js +1 -1
  334. package/dist/domain/domain-runtime/domain-context/actions.d.ts +4 -0
  335. package/dist/domain/domain-runtime/domain-context/actions.js +1 -1
  336. package/dist/domain/domain-runtime/domain-context/domain-context.d.ts +8 -0
  337. package/dist/domain/domain-runtime/domain-context/domain-context.js +1 -1
  338. package/dist/domain/domain-runtime/domain-context/selectors.d.ts +1 -0
  339. package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
  340. package/dist/domain/domain-runtime/domain-context/types.d.ts +8 -4
  341. package/dist/domain/domain-runtime/domain-runtime.d.ts +8 -0
  342. package/dist/domain/extensions/export-images/agent-screenshot.d.ts +5 -4
  343. package/dist/domain/extensions/export-images/agent-screenshot.js +1 -1
  344. package/dist/domain/extensions/index.d.ts +0 -1
  345. package/dist/domain/extensions/index.js +1 -1
  346. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +4 -0
  347. package/dist/domain/spec/sections/actions.d.ts +3 -2
  348. package/dist/domain/spec/sections/app-metadata.d.ts +12 -0
  349. package/dist/domain/spec/sections/assistant/assistant-features.d.ts +13 -0
  350. package/dist/domain/spec/sections/assistant/assistant-features.js +1 -0
  351. package/dist/domain/spec/sections/assistant/assistant-manifest.d.ts +17 -6
  352. package/dist/domain/spec/sections/assistant/assistant-resolved-manifest.d.ts +28 -5
  353. package/dist/domain/spec/sections/assistant/index.d.ts +1 -0
  354. package/dist/domain/system-components/index.d.ts +1 -0
  355. package/dist/domain/system-components/index.js +1 -1
  356. package/dist/domain/system-components/navigation/index.d.ts +1 -0
  357. package/dist/domain/system-components/navigation/index.js +1 -0
  358. package/dist/domain/system-components/navigation/view-controls.d.ts +24 -0
  359. package/dist/domain/system-components/navigation/view-controls.js +1 -0
  360. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  361. package/dist/extras/clerk/index.d.ts +6 -0
  362. package/dist/extras/cognito/AccountAvatar.d.ts +7 -0
  363. package/dist/extras/cognito/AccountAvatar.js +1 -0
  364. package/dist/extras/cognito/AccountControl.d.ts +14 -0
  365. package/dist/extras/cognito/AccountControl.js +1 -0
  366. package/dist/extras/cognito/AdminSignInPage.d.ts +26 -0
  367. package/dist/extras/cognito/AdminSignInPage.js +1 -0
  368. package/dist/extras/cognito/CognitoSignInPage.d.ts +8 -2
  369. package/dist/extras/cognito/CognitoSignInPage.js +1 -1
  370. package/dist/extras/cognito/ConfiguratorSignInPage.d.ts +19 -0
  371. package/dist/extras/cognito/ConfiguratorSignInPage.js +1 -0
  372. package/dist/extras/cognito/SignInFailurePage.d.ts +11 -0
  373. package/dist/extras/cognito/SignInFailurePage.js +1 -0
  374. package/dist/extras/cognito/SignInGateLayout.d.ts +25 -0
  375. package/dist/extras/cognito/SignInGateLayout.js +1 -0
  376. package/dist/extras/cognito/SignInNotice.d.ts +9 -0
  377. package/dist/extras/cognito/SignInNotice.js +1 -0
  378. package/dist/extras/cognito/index.d.ts +4 -0
  379. package/dist/extras/cognito/index.js +1 -1
  380. package/dist/globals/index.d.ts +5 -0
  381. package/dist/i18n/locales/cs/messages.js +1 -1
  382. package/dist/i18n/locales/da/messages.js +1 -1
  383. package/dist/i18n/locales/de/messages.js +1 -1
  384. package/dist/i18n/locales/de-AT/messages.js +1 -1
  385. package/dist/i18n/locales/en/messages.js +1 -1
  386. package/dist/i18n/locales/en-AU/messages.js +1 -1
  387. package/dist/i18n/locales/en-GB/messages.js +1 -1
  388. package/dist/i18n/locales/es/messages.js +1 -1
  389. package/dist/i18n/locales/fr/messages.js +1 -1
  390. package/dist/i18n/locales/hu/messages.js +1 -1
  391. package/dist/i18n/locales/it/messages.js +1 -1
  392. package/dist/i18n/locales/nl/messages.js +1 -1
  393. package/dist/i18n/locales/pl/messages.js +1 -1
  394. package/dist/i18n/locales/pt/messages.js +1 -1
  395. package/dist/i18n/locales/ro/messages.js +1 -1
  396. package/dist/i18n/locales/sk/messages.js +1 -1
  397. package/dist/i18n/locales/tr/messages.js +1 -1
  398. package/dist/legacy/deployment-cli/commands/create-environment.js +1 -1
  399. package/dist/legacy/deployment-cli/commands/list-environments.js +1 -1
  400. package/dist/legacy/deployment-cli/commands/register-deployment.js +1 -1
  401. package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +12 -3
  402. package/dist/legacy/phoenix-cli/commands/prepare-deployment-command.js +1 -1
  403. package/dist/legacy/phoenix-cli/commands/prepare-local-environment-command.js +1 -1
  404. package/dist/legacy/phoenix-cli/services/prepare-development-environment.js +1 -1
  405. package/dist/legacy/phoenix-cli/services/webhook-service/transport.js +1 -1
  406. package/dist/phoenix/application-spec/index.d.ts +1 -1
  407. package/dist/phoenix/application-spec/index.js +1 -1
  408. package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +10 -3
  409. package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
  410. package/dist/phoenix/cli.js +1 -1
  411. package/dist/phoenix/commands/account/whoami.d.ts +8 -2
  412. package/dist/phoenix/commands/account/whoami.js +4 -3
  413. package/dist/phoenix/commands/cleanup-environment.js +1 -1
  414. package/dist/phoenix/commands/deploy.d.ts +7 -2
  415. package/dist/phoenix/commands/deploy.js +9 -3
  416. package/dist/phoenix/commands/deployment-build-envs-command.js +1 -1
  417. package/dist/phoenix/commands/deps/deps.js +2 -2
  418. package/dist/phoenix/commands/feedback.d.ts +2 -2
  419. package/dist/phoenix/commands/feedback.js +1 -1
  420. package/dist/phoenix/commands/finish-deployment-command.js +1 -1
  421. package/dist/phoenix/commands/init-starter-spec.js +3 -4
  422. package/dist/phoenix/commands/init.d.ts +2 -2
  423. package/dist/phoenix/commands/init.js +1 -1
  424. package/dist/phoenix/commands/login.d.ts +1 -1
  425. package/dist/phoenix/commands/login.js +2 -2
  426. package/dist/phoenix/commands/logout.js +1 -1
  427. package/dist/phoenix/commands/prepare-deployment-command.js +2 -2
  428. package/dist/phoenix/commands/prepare-local-environment-command.js +1 -1
  429. package/dist/phoenix/services/cli-credentials.d.ts +13 -2
  430. package/dist/phoenix/services/cli-credentials.js +2 -2
  431. package/dist/phoenix/services/cli-server/describe-saved-logins.d.ts +5 -0
  432. package/dist/phoenix/services/cli-server/describe-saved-logins.js +1 -0
  433. package/dist/phoenix/services/cli-server/index.d.ts +2 -0
  434. package/dist/phoenix/services/cli-server/index.js +1 -0
  435. package/dist/phoenix/services/cli-server/resolve-cli-server-url.d.ts +25 -0
  436. package/dist/phoenix/services/cli-server/resolve-cli-server-url.js +1 -0
  437. package/dist/phoenix/services/development-credential.js +1 -1
  438. package/dist/phoenix/services/frontend-config.d.ts +2 -0
  439. package/dist/phoenix/services/index.d.ts +4 -2
  440. package/dist/phoenix/services/index.js +1 -1
  441. package/dist/phoenix/services/phoenix-regions.d.ts +15 -5
  442. package/dist/phoenix/services/phoenix-regions.js +1 -1
  443. package/dist/phoenix/services/prepare-development-environment.js +2 -2
  444. package/dist/phoenix/services/session/phoenix-application.js +1 -1
  445. package/dist/phoenix/services/signed-in-development-environment.d.ts +15 -4
  446. package/dist/phoenix/services/signed-in-development-environment.js +1 -1
  447. package/dist/phoenix/services/spec-project/describe-workspace-projects.d.ts +11 -0
  448. package/dist/phoenix/services/spec-project/describe-workspace-projects.js +1 -0
  449. package/dist/phoenix/services/spec-project/index.d.ts +3 -0
  450. package/dist/phoenix/services/spec-project/index.js +1 -0
  451. package/dist/phoenix/services/spec-project/resolve-deploy-target.d.ts +47 -0
  452. package/dist/phoenix/services/spec-project/resolve-deploy-target.js +1 -0
  453. package/dist/phoenix/services/spec-project/resolve-target-project.d.ts +34 -0
  454. package/dist/phoenix/services/spec-project/resolve-target-project.js +2 -0
  455. package/dist/phoenix/services/spec-project/write-spec-project.d.ts +7 -0
  456. package/dist/phoenix/services/spec-project/write-spec-project.js +1 -0
  457. package/dist/phoenix/services/variant-file-session.js +1 -1
  458. package/dist/phoenix/services/vite-config.js +1 -1
  459. package/dist/phoenix/services/webhook-service/transport.js +1 -1
  460. package/dist/react-sdk/application-runtime/common-services/selectors.js +1 -1
  461. package/dist/react-sdk/application-runtime/domain-application-context/configuration-persist-system.d.ts +6 -0
  462. package/dist/react-sdk/application-runtime/domain-application-context/configuration-persist-system.js +1 -1
  463. package/dist/react-sdk/application-runtime/host-properties/selectors.d.ts +2 -2
  464. package/dist/react-sdk/application-runtime/integration/integration-mode.d.ts +30 -0
  465. package/dist/react-sdk/application-runtime/integration/integration-mode.js +1 -1
  466. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +20 -6
  467. package/dist/react-sdk/application-runtime/session/actions.d.ts +2 -1
  468. package/dist/react-sdk/application-runtime/session/actions.js +1 -1
  469. package/dist/react-sdk/application-runtime/session/initialize.js +1 -1
  470. package/dist/react-sdk/application-runtime/session/selectors.d.ts +2 -0
  471. package/dist/react-sdk/application-runtime/session/selectors.js +1 -1
  472. package/dist/react-sdk/application-runtime/session/session-service.d.ts +64 -2
  473. package/dist/react-sdk/application-runtime/session/session-service.js +1 -1
  474. package/dist/react-sdk/application-runtime/session/session-token.d.ts +8 -0
  475. package/dist/react-sdk/application-runtime/session/session-token.js +1 -1
  476. package/dist/react-sdk/application-runtime/session/types.d.ts +6 -1
  477. package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +1 -0
  478. package/dist/react-sdk/domain-context/index.d.ts +3 -2
  479. package/dist/react-sdk/domain-context/index.js +1 -1
  480. package/dist/react-sdk/domain-context/system-hooks/generate-share-link-hooks.d.ts +1 -5
  481. package/dist/react-sdk/domain-context/system-hooks/generate-share-link-hooks.js +1 -1
  482. package/dist/react-sdk/domain-context/system-hooks/generate-share-link.d.ts +25 -0
  483. package/dist/react-sdk/domain-context/system-hooks/generate-share-link.js +1 -0
  484. package/dist/react-sdk/domain-context/system-hooks/navigation-hooks.d.ts +5 -3
  485. package/dist/react-sdk/domain-context/system-hooks/navigation-hooks.js +1 -1
  486. package/dist/react-sdk/preset-selection/PresetSelectionProvider.js +1 -1
  487. package/dist/react-sdk/session/AccessDeniedAdminPage.d.ts +13 -0
  488. package/dist/react-sdk/session/AccessDeniedAdminPage.js +1 -0
  489. package/dist/react-sdk/session/AccessDeniedPage.d.ts +20 -0
  490. package/dist/react-sdk/session/AccessDeniedPage.js +1 -0
  491. package/dist/react-sdk/session/ConfiguratorUnavailablePage.d.ts +5 -0
  492. package/dist/react-sdk/session/ConfiguratorUnavailablePage.js +1 -0
  493. package/dist/react-sdk/session/SessionServiceProvider.d.ts +5 -0
  494. package/dist/react-sdk/session/SessionServiceProvider.js +1 -1
  495. package/dist/react-sdk/session/index.d.ts +3 -0
  496. package/dist/react-sdk/session/index.js +1 -1
  497. package/dist/react-sdk/session/server-sign-in-support.d.ts +16 -0
  498. package/dist/react-sdk/session/server-sign-in-support.js +1 -0
  499. package/dist/react-sdk/session/sign-in-address.d.ts +18 -0
  500. package/dist/react-sdk/session/sign-in-address.js +1 -0
  501. package/dist/react-sdk/session/studio-frame.d.ts +14 -0
  502. package/dist/react-sdk/session/studio-frame.js +1 -0
  503. package/dist/react-sdk/session/use-sign-in.d.ts +51 -0
  504. package/dist/react-sdk/session/use-sign-in.js +1 -0
  505. package/dist/ui-sdk/components/preview/Preview.d.ts +12 -4
  506. package/dist/ui-sdk/components/preview/Preview.js +2 -2
  507. package/dist/ui-sdk/components/snackbar/Snackbar.d.ts +3 -2
  508. package/dist/ui-sdk/components/snackbar/Snackbar.js +1 -1
  509. package/dist/ui-sdk/components/toolbar/desktop-toolbar/ToolbarPopper.d.ts +2 -0
  510. package/dist/ui-sdk/components/toolbar/desktop-toolbar/ToolbarPopper.js +1 -1
  511. package/dist/ui-sdk/components/view-controls/ViewControlsContext.d.ts +3 -1
  512. package/dist/ui-sdk/components/view-controls/ViewControlsItem.js +1 -1
  513. package/dist/ui-sdk/components/view-controls/ViewControlsRoot.d.ts +6 -1
  514. package/dist/ui-sdk/components/view-controls/ViewControlsRoot.js +1 -1
  515. package/dist/webhook/builders/auth-handler-builder.d.ts +21 -1
  516. package/dist/webhook/builders/auth-handler-builder.js +1 -1
  517. package/dist/webhook/builders/common.d.ts +9 -0
  518. package/dist/webhook/builders/webhook-builder.d.ts +18 -0
  519. package/dist/webhook/builders/webhook-builder.js +1 -1
  520. package/package.json +5 -4
  521. package/schema/domain-spec.json +224 -65
  522. package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/assistant.js +0 -43
  523. package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/assistant-setup.js +0 -32
  524. package/dist/application-spec/generate-application/code/templates/skills/processes/beta.d.ts +0 -14
  525. package/dist/application-spec/generate-application/code/templates/skills/processes/beta.js +0 -4
  526. package/dist/domain/extensions/view-controls.d.ts +0 -25
  527. package/dist/domain/extensions/view-controls.js +0 -1
@@ -0,0 +1,27 @@
1
+ interface Disposable {
2
+ dispose(): void;
3
+ }
4
+ /** How long the texture clones of an unmounted material stay alive before they are disposed. */
5
+ export declare const UNMOUNTED_DISPOSE_DELAY_MS = 10000;
6
+ /** How long a replaced or unmounted material stays alive before it is disposed. */
7
+ export declare const MATERIAL_KEEP_MS = 60000;
8
+ /**
9
+ * Disposes `resource` (a material, or the texture clones of one) once it has been replaced or its
10
+ * component has unmounted, late enough that what replaces it reuses its GPU state.
11
+ *
12
+ * Disposing a material releases its shader program, and a texture its GPU texture, once nothing
13
+ * else uses them; the next material with the same program then compiles it again, and the next
14
+ * texture of the same image uploads it again. Replaced materials often come back: an image export
15
+ * swaps scene objects to their export-state twins and back, a visitor tries finishes back and
16
+ * forth, and StrictMode remounts every component. So:
17
+ *
18
+ * - With `keepMs` (materials, cheap to keep), a replaced or unmounted resource stays alive for that
19
+ * long, and a material that returns meanwhile reuses its program.
20
+ * - Without it (texture clones, large), a replaced resource is disposed once its replacement has
21
+ * rendered a frame and holds the GPU texture, and an unmounted one after
22
+ * {@link UNMOUNTED_DISPOSE_DELAY_MS}.
23
+ *
24
+ * A remount of the same resources keeps them.
25
+ */
26
+ export declare const useDisposeReplaced: (resource: Disposable | readonly Disposable[], keepMs?: number) => void;
27
+ export {};
@@ -0,0 +1 @@
1
+ let e;import{useFrame as r}from"@react-three/fiber";import{useEffect as t,useRef as o}from"react";export const UNMOUNTED_DISPOSE_DELAY_MS=1e4;export const MATERIAL_KEEP_MS=6e4;let s=new Map,a=()=>{e=void 0;let r=Date.now();for(let[e,t]of s)t<=r&&(s.delete(e),e.dispose());s.size>0&&(e=setTimeout(a,Math.max(0,Math.min(...s.values())-r)))},c=(r,t)=>{let o=Date.now()+t,c=s.size>0?Math.min(...s.values()):1/0;r.forEach(e=>s.set(e,o)),(void 0===e||o<c)&&(clearTimeout(e),e=setTimeout(a,t))};export const useDisposeReplaced=(e,a)=>{let n=o([]),u=o(!1);t(()=>(u.current=!1,()=>{u.current=!0,n.current.forEach(e=>c(e.resources,1e4)),n.current=[]}),[]),t(()=>{let r=Array.isArray(e)?e:[e];return r.forEach(e=>s.delete(e)),()=>{void 0!==a?c(r,a):u.current?c(r,1e4):n.current.push({resources:r,framesSeen:0})}},[e,a]),r(()=>{0!==n.current.length&&(n.current=n.current.filter(e=>(e.framesSeen+=1,!!(e.framesSeen<2)||(e.resources.forEach(e=>e.dispose()),!1))))})};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useCallback as t,useEffect as n,useMemo as a,useRef as o}from"react";import{P as r,match as s}from"ts-pattern";import{FrontendAnalyticsFactory as l,PhoenixLayoutElementWithChildren as i,PhoenixLayoutElements as u,useAnalyticsService as d,useIsDev as m,useIsFullscreenActive as p,useLocaleSwitch as b,useResolveLocalizable as c,useSetFullscreen as g,useShareLinks as h,useStoreSelector as k,useUndoRedo as T}from"#package/react-sdk";import{useConfigurator as B}from"../application-runtime/index.js";import{useAssistantPanel as f}from"./use-assistant-panel.js";import{useMeasurements as w}from"./use-measurements.js";import{useToolbarHelp as A}from"./use-toolbar-help.js";let v={undo:{id:"sdk.toolbar.undoRedo.undo.label",message:"Undo"},redo:{id:"sdk.toolbar.undoRedo.redo.label",message:"Redo"},enterFullscreen:{id:"sdk.toolbar.fullscreen.enter.label",message:"Open fullscreen"},exitFullscreen:{id:"sdk.toolbar.fullscreen.exit.label",message:"Exit fullscreen"},resetCamera:{id:"sdk.toolbar.camera.reset.label",message:"Reset camera"},shareToolbarButton:{id:"sdk.toolbar.share.open.label",message:"Share"},shareMenuAction:{id:"sdk.layout.menu.hamburger.share.label",message:"Share configuration"},measurementsToolbarButton:{id:"sdk.measurements",message:"Change measure"},measurementsMenuAction:{id:"sdk.layout.menu.measurements.label",message:"Change measure"},languageToolbarButton:{id:"sdk.toolbar.language.title",message:"Switch language"},languageMenuAction:{id:"sdk.layout.hamburgerMenu.language.label",message:"Change Language"},helpToolbarButton:{id:"sdk.toolbar.help.label",message:"Help"},helpMenuAction:{id:"sdk.layout.menu.hamburger.help.label",message:"Show help"},assistant:{id:"sdk.assistant.toolbarButton.label",message:"Assistant"}},C=(e,t,n=!1)=>({key:e,icon:t?.icon,showTitle:t?.showTitle??n});export const useToolbarActions=(M="desktop")=>{let{layoutSystem:P,cameraControlSystem:x}=B(),S=k(e=>P.getToolbarState(e.state),[P])[M],y=d(),$=c(),F=m(),R=T(),j=p(),L=g(),E=h({enabled:!1}),G=w(),D=b(),I=f(),O=A(),U=t(()=>{y.push(l.FullScreenModeToggled()),L(!j)},[y,L,j]),H=t(()=>{x.resetCamera()},[x]),W=t(()=>{I.setOpen(!I.open)},[I]),q=o(new WeakMap),z=t((e,t)=>{let n=q.current.get(e);if(n)return n;let a=()=>t();return q.current.set(e,a),a},[]),J=a(()=>{let t=[],n=(n,a)=>s(n).returnType().with({kind:"undoToolbarButton"},e=>({...C(a,e.props),kind:"undo",label:$(v.undo),disabled:!R.canUndo,run:R.undo})).with({kind:"redoToolbarButton"},e=>({...C(a,e.props),kind:"redo",label:$(v.redo),disabled:!R.canRedo,run:R.redo})).with({kind:r.union("enterFullscreenToolbarButton","exitFullscreenToolbarButton")},e=>({...C(a,e.props),kind:"fullscreen",label:$(j?v.exitFullscreen:v.enterFullscreen),active:j,run:U})).with({kind:"resetCameraToolbarButton"},e=>({...C(a,e.props),kind:"resetCamera",label:$(v.resetCamera),run:H})).with({kind:r.union("shareToolbarButton","shareMenuAction")},e=>E.available?{...C(a,e.props),kind:"share",label:$(v[e.kind])}:null).with({kind:r.union("measurementsToolbarButton","measurementsMenuAction")},e=>{let t=e.props?.showIndicatorSwitch??G.hasIndicatorSwitch,n=G.units.length>1||t;return n?{...C(a,void 0),kind:"measurements",label:$(v[e.kind]),measurements:{...G,hasIndicatorSwitch:t,available:n},icons:e.props?.icons}:null}).with({kind:r.union("languageToolbarButton","languageMenuAction")},e=>D.available?{...C(a,void 0),kind:"language",label:$(v[e.kind]),language:D}:null).with({kind:r.union("helpToolbarButton","helpMenuAction")},t=>{let{children:n}=t,o=void 0!==n?z(t,()=>e(u,{elements:n})):O;return o?{...C(a,t.props),kind:"help",label:$(v[t.kind]),Content:o}:null}).with({kind:"assistantToolbarButton"},e=>I.available?{...C(a,e.props,!0),kind:"assistant",label:$(v.assistant),assistant:I,run:W}:null).with({kind:"customLayoutElement"},t=>({...C(a,void 0),kind:"custom",label:t.props.name,name:t.props.name,Element:z(t,()=>e(i,{kind:t.kind,elementProps:t.props,children:t.children}))})).with({kind:r.union("toolbarButtonGroup","adminConnectedResourcePage","adminDataTableActions","adminDataTablePage","adminPresetActions","adminPresetCategoryActions","adminPresetCategoryPage","adminPresetListPage","adminRecipeActions","adminRecipeCollectionPage","enterSummaryButton","footerPrice","mainFooterActions","nextStepButton","otherActions","previousStepButton","saveTemplateButton","stepLabel","stepProgress")},e=>(t.push(e.kind),null)).exhaustive(),a=(e,t)=>{if("toolbarButtonGroup"!==e.kind){let a=n(e,`${t}-0`);return a?[a]:[]}return(e.children??[]).flatMap((e,o)=>"toolbarButtonGroup"===e.kind?a(e,`${t}-${o}`):n(e,`${t}-${o}`)??[])},o=(S??[]).map((e,t)=>a(e,`${M}-${t}`)).filter(e=>e.length>0);return{groups:o,actions:o.flat(),unsupported:t}},[S,M,$,R,j,U,H,E.available,G,D,I,W,O,z]),K=J.unsupported.join(", ");return n(()=>{F&&K&&console.warn(`useToolbarActions('${M}') leaves out elements that are not toolbar entries: ${K}.`)},[F,M,K]),a(()=>({groups:J.groups,actions:J.actions}),[J])};
1
+ import{jsx as e}from"react/jsx-runtime";import{useCallback as t,useEffect as n,useMemo as a,useRef as o}from"react";import{P as r,match as s}from"ts-pattern";import{FrontendAnalyticsFactory as l,PhoenixLayoutElementWithChildren as i,PhoenixLayoutElements as u,useAnalyticsService as d,useIsDev as m,useIsFullscreenActive as p,useLocaleSwitch as b,useResolveLocalizable as c,useSetFullscreen as g,useShareLinks as h,useStoreSelector as k,useUndoRedo as T}from"#package/react-sdk";import{useConfigurator as B}from"../application-runtime/index.js";import{useAssistantPanel as f}from"./use-assistant-panel.js";import{useMeasurements as w}from"./use-measurements.js";import{useToolbarHelp as A}from"./use-toolbar-help.js";let v={undo:{id:"sdk.toolbar.undoRedo.undo.label",message:"Undo"},redo:{id:"sdk.toolbar.undoRedo.redo.label",message:"Redo"},enterFullscreen:{id:"sdk.toolbar.fullscreen.enter.label",message:"Open fullscreen"},exitFullscreen:{id:"sdk.toolbar.fullscreen.exit.label",message:"Exit fullscreen"},resetCamera:{id:"sdk.toolbar.camera.reset.label",message:"Reset camera"},shareToolbarButton:{id:"sdk.toolbar.share.open.label",message:"Share"},shareMenuAction:{id:"sdk.layout.menu.hamburger.share.label",message:"Share configuration"},measurementsToolbarButton:{id:"sdk.measurements",message:"Change measure"},measurementsMenuAction:{id:"sdk.layout.menu.measurements.label",message:"Change measure"},languageToolbarButton:{id:"sdk.toolbar.language.title",message:"Switch language"},languageMenuAction:{id:"sdk.layout.hamburgerMenu.language.label",message:"Change Language"},helpToolbarButton:{id:"sdk.toolbar.help.label",message:"Help"},helpMenuAction:{id:"sdk.layout.menu.hamburger.help.label",message:"Show help"},assistant:{id:"sdk.assistant.toolbarButton.label",message:"AI assistant"}},C=(e,t,n=!1)=>({key:e,icon:t?.icon,showTitle:t?.showTitle??n});export const useToolbarActions=(M="desktop")=>{let{layoutSystem:P,cameraControlSystem:x}=B(),S=k(e=>P.getToolbarState(e.state),[P])[M],y=d(),$=c(),F=m(),R=T(),j=p(),L=g(),E=h({enabled:!1}),G=w(),I=b(),D=f(),O=A(),U=t(()=>{y.push(l.FullScreenModeToggled()),L(!j)},[y,L,j]),H=t(()=>{x.resetCamera()},[x]),W=t(()=>{D.setOpen(!D.open)},[D]),q=o(new WeakMap),z=t((e,t)=>{let n=q.current.get(e);if(n)return n;let a=()=>t();return q.current.set(e,a),a},[]),J=a(()=>{let t=[],n=(n,a)=>s(n).returnType().with({kind:"undoToolbarButton"},e=>({...C(a,e.props),kind:"undo",label:$(v.undo),disabled:!R.canUndo,run:R.undo})).with({kind:"redoToolbarButton"},e=>({...C(a,e.props),kind:"redo",label:$(v.redo),disabled:!R.canRedo,run:R.redo})).with({kind:r.union("enterFullscreenToolbarButton","exitFullscreenToolbarButton")},e=>({...C(a,e.props),kind:"fullscreen",label:$(j?v.exitFullscreen:v.enterFullscreen),active:j,run:U})).with({kind:"resetCameraToolbarButton"},e=>({...C(a,e.props),kind:"resetCamera",label:$(v.resetCamera),run:H})).with({kind:r.union("shareToolbarButton","shareMenuAction")},e=>E.available?{...C(a,e.props),kind:"share",label:$(v[e.kind])}:null).with({kind:r.union("measurementsToolbarButton","measurementsMenuAction")},e=>{let t=e.props?.showIndicatorSwitch??G.hasIndicatorSwitch,n=G.units.length>1||t;return n?{...C(a,void 0),kind:"measurements",label:$(v[e.kind]),measurements:{...G,hasIndicatorSwitch:t,available:n},icons:e.props?.icons}:null}).with({kind:r.union("languageToolbarButton","languageMenuAction")},e=>I.available?{...C(a,void 0),kind:"language",label:$(v[e.kind]),language:I}:null).with({kind:r.union("helpToolbarButton","helpMenuAction")},t=>{let{children:n}=t,o=void 0!==n?z(t,()=>e(u,{elements:n})):O;return o?{...C(a,t.props),kind:"help",label:$(v[t.kind]),Content:o}:null}).with({kind:"assistantToolbarButton"},e=>D.available?{...C(a,e.props,!0),kind:"assistant",label:$(v.assistant),assistant:D,run:W}:null).with({kind:"customLayoutElement"},t=>({...C(a,void 0),kind:"custom",label:t.props.name,name:t.props.name,Element:z(t,()=>e(i,{kind:t.kind,elementProps:t.props,children:t.children}))})).with({kind:r.union("toolbarButtonGroup","adminConnectedResourcePage","adminDataTableActions","adminDataTablePage","adminPresetActions","adminPresetCategoryActions","adminPresetCategoryPage","adminPresetListPage","adminRecipeActions","adminRecipeCollectionPage","enterSummaryButton","footerPrice","mainFooterActions","nextStepButton","otherActions","previousStepButton","saveTemplateButton","stepLabel","stepProgress")},e=>(t.push(e.kind),null)).exhaustive(),a=(e,t)=>{if("toolbarButtonGroup"!==e.kind){let a=n(e,`${t}-0`);return a?[a]:[]}return(e.children??[]).flatMap((e,o)=>"toolbarButtonGroup"===e.kind?a(e,`${t}-${o}`):n(e,`${t}-${o}`)??[])},o=(S??[]).map((e,t)=>a(e,`${M}-${t}`)).filter(e=>e.length>0);return{groups:o,actions:o.flat(),unsupported:t}},[S,M,$,R,j,U,H,E.available,G,I,D,W,O,z]),K=J.unsupported.join(", ");return n(()=>{F&&K&&console.warn(`useToolbarActions('${M}') leaves out elements that are not toolbar entries: ${K}.`)},[F,M,K]),a(()=>({groups:J.groups,actions:J.actions}),[J])};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Trans as a}from"@lingui/react";import{IconButton as n,Tooltip as o,styled as i,useThemeProps as s}from"@mui/material";import{useCallback as r,useEffect as l,useRef as d,useState as c}from"react";import{useLocalizable as m}from"#package/react-sdk";import{PhxIcon as p,hoverStyles as u,useResponsive as h}from"#package/ui-sdk";import{AnnotationBadge as g}from"./annotation/index.js";import{AssistantComposerName as b,ComposerField as f,ComposerFrame as k,ComposerInput as v,ComposerPrimaryButton as y,ComposerToolButton as S}from"./composer/index.js";import{useAssistantComposer as B}from"./use-assistant-composer.js";import{RecordingBar as x}from"./voice/index.js";let z={id:"sdk.assistant.composer.placeholder",message:"Ask or tell me what to change…"},D={id:"sdk.assistant.composer.send.label",message:"Send"},w={id:"sdk.assistant.composer.stop.label",message:"Stop"},A={id:"sdk.assistant.composer.attach.label",message:"Attach images"},C={id:"sdk.assistant.composer.annotate.label",message:"Annotate with drawings and comments"},E={id:"sdk.assistant.composer.attachment.remove",message:"Remove image"},R={id:"sdk.assistant.composer.attachment.annotate",message:"Annotate image"},P={id:"sdk.assistant.composer.annotation.remove",message:"Remove annotation"},T={id:"sdk.assistant.composer.attachment.unreadable",message:"Unsupported image format."},j={id:"sdk.assistant.composer.record.label",message:"Record a voice message"},M={id:"sdk.assistant.composer.recording.send",message:"Send voice message"},F={id:"sdk.assistant.composer.record.blocked",message:"Microphone access is blocked. Allow it in your browser's site settings."},N={id:"sdk.assistant.composer.attachment.limit",message:"You can attach up to {max} images."},I=i("form",{name:b,slot:"root"})(({theme:{palette:e,spacing:t}})=>({borderBlockStart:`1px solid ${e.divider}`,display:"grid",gap:t(.75),paddingBlock:t(1.25),paddingInline:`var(--phx-sidebar-padding, ${t(2)})`})),K=i("div",{name:b,slot:"attachments"})(({theme:{spacing:e}})=>({display:"flex",flexWrap:"wrap",gap:e(1),gridColumn:"1 / -1",paddingBlockStart:e(.75)})),L=i("div")({cursor:"default",display:"flex",justifySelf:"start"}),$=i("div",{name:b,slot:"attachment"})(({theme:{palette:e,shape:t}})=>({blockSize:56,border:`1px solid ${e.divider}`,borderRadius:t.borderRadius,inlineSize:56,overflow:"hidden",position:"relative"})),O=i("img")({blockSize:"100%",display:"block",inlineSize:"100%",objectFit:"cover"}),U=i(n,{name:b,slot:"removeAttachment"})(({theme:{palette:e}})=>({background:e.background.paper,insetBlockStart:2,insetInlineEnd:2,padding:2,position:"absolute","&:hover":{background:e.background.paper}})),W=i(n,{name:b,slot:"annotateAttachment"})(({theme:{palette:e}})=>({background:e.background.paper,insetBlockEnd:2,insetInlineStart:2,padding:2,position:"absolute","&:hover":{background:e.background.paper}})),q=i(n,{name:b,slot:"stopButton"})(({theme:{palette:e}})=>({background:e.text.primary,borderRadius:8,color:e.background.paper,padding:4,"&:hover":{background:e.text.primary},...u({"&:hover":{background:e.text.secondary}})})),H=i("span")({background:"currentColor",blockSize:10,borderRadius:2,inlineSize:10,margin:5}),X=i("div",{name:b,slot:"hint"})(({theme:{palette:e,typography:t}})=>({...t.caption,color:e.text.secondary})),Y=i("div",{name:b,slot:"attachmentNotice"})(({theme:{palette:e,typography:t}})=>({...t.caption,color:e.error.main})),G=i("input")({display:"none"}),J=i(y,{name:b,slot:"micButton"})(({theme:{palette:e}})=>({'&[data-blocked="true"], &[data-blocked="true"]:hover':{background:e.action.disabledBackground,color:e.text.secondary}}));export const AssistantComposer=n=>{let{slots:i={},slotProps:u={}}=s({props:n,name:b}),{draft:Q,setDraft:V,attachments:Z,addFiles:_,annotate:ee,annotateAttachment:et,removeAttachment:ea,notice:en,maxAttachments:eo,isBusy:ei,isPreparing:es,isLocked:er,isReplying:el,canSend:ed,send:ec,stop:em,inputFocusHandlers:ep,canRecord:eu,recording:eh,startRecording:eg,sendRecording:eb,cancelRecording:ef}=B(),[ek,ev]=c(!1),ey=d(null),eS=d(null),{isDesktop:eB}=h(),ex=m(z),ez=m(D),eD=m(w),ew=m(A),eA=m(C),eC=m(R),eE=m(E),eR=m(P),eP=m(T),eT=m({...N,values:{max:eo}}),ej=m(j),eM=m(M),eF=m(F),eN="recording"===eh.status||"recorded"===eh.status,eI=eu&&!Q.trim()&&0===Z.length,eK=eu&&"refused"===eh.status,eL=r(async()=>{ed&&!eB&&ey.current?.blur(),await ec()},[ed,eB,ec]),e$=r(e=>{e.preventDefault(),eN?eb():eL()},[eN,eL,eb]);l(()=>{eB&&ey.current?.focus()},[]);let eO=d(null),eU=d(null),eW=d(eN);l(()=>{var e;let t,a=(e=eO.current,(t=e?.getRootNode())instanceof ShadowRoot?t.activeElement??(document.activeElement===document.body?null:document.activeElement):document.activeElement===document.body?null:document.activeElement),n=null===a||(eO.current?.contains(a)??!1);n&&eN&&!eU.current?.contains(a)?eU.current?.focus():n&&!eN&&eW.current&&eB&&ey.current?.focus(),eW.current=eN},[eN,ei,eB]);let eq=u.root?.onKeyDown,eH=r(e=>{if(eq?.(e),!e.defaultPrevented&&eN&&!e.nativeEvent.isComposing){if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),ei||ef();return}"Enter"===e.key&&!(e.target instanceof HTMLButtonElement)&&(e.preventDefault(),e.repeat||ei||es||eb())}},[ef,eN,ei,es,eq,eb]),eX=r(e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),eL())},[eL]),eY=r(e=>{e.target===e.currentTarget&&(e.preventDefault(),ey.current?.focus())},[]),eG=r(e=>{let t=[...e.target.files??[]];e.target.value="",_(t)},[_]),eJ=r(e=>{let t=[...e.clipboardData.files].filter(e=>e.type.startsWith("image/"));0!==t.length&&(e.preventDefault(),_(t))},[_]),eQ=r(e=>{!er&&e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",ev(!0))},[er]),eV=r(e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||ev(!1)},[]),eZ=r(e=>{er||0===e.dataTransfer.files.length||(e.preventDefault(),ev(!1),_([...e.dataTransfer.files]))},[_,er]),e_=i.root??I,e1=i.inputFrame??k,e0=i.attachments??K,e2=i.attachment??$,e5=i.removeAttachment??U,e6=i.annotateAttachment??W,e7=i.input??v,e4=i.toolButton??S,e8=i.sendButton??y,e3=i.micButton??J,e9=i.stopButton??q,te=i.hint??X,tt=i.attachmentNotice??Y;return t(e_,{...u.root,ref:eO,onSubmit:e$,onKeyDown:eH,onDragOver:eQ,onDragLeave:eV,onDrop:eZ,children:[t(e1,{...u.inputFrame,"data-dragging":ek,onMouseDown:eY,children:[Z.length>0&&e(e0,{...u.attachments,children:Z.map(a=>t(e2,{...u.attachment,children:[e(O,{src:a.previewUrl,alt:""}),a.isAnnotation?e(g,{count:a.pinCount}):e(e6,{size:"small","aria-label":eC,...u.annotateAttachment,disabled:ei||er,onClick:()=>void et(a.id),children:e(p,{name:"PencilSimpleLine",sx:{fontSize:12}})}),e(e5,{size:"small","aria-label":a.isAnnotation?eR:eE,...u.removeAttachment,disabled:ei,onClick:()=>ea(a.id),children:e(p,{name:"X",sx:{fontSize:12}})})]},a.id))}),eN?e(x,{ref:eU,slot:i.recordingBar,slotProps:u.recordingBar,isRecording:"recording"===eh.status,elapsedMs:eh.elapsedMs,level:eh.level,disabled:ei,onDiscard:ef}):e(f,{children:e(e7,{multiline:!0,maxRows:6,placeholder:ex,...u.input,inputProps:{...u.input?.inputProps,"aria-label":ex},value:Q,readOnly:ei,disabled:er,inputRef:ey,onChange:e=>V(e.target.value),onKeyDown:eX,onPaste:eJ,onFocus:ep.onFocus,onBlur:ep.onBlur})}),t(L,{children:[e(o,{title:ew,placement:"top",children:e("span",{children:e(e4,{size:"small","aria-label":ew,...u.toolButton,disabled:ei||er,onClick:()=>eS.current?.click(),children:e(p,{name:"Paperclip",fontSize:"small"})})})}),e(o,{title:eA,placement:"top",children:e("span",{children:e(e4,{size:"small","aria-label":eA,...u.toolButton,disabled:ei||er,onClick:()=>void ee(),children:e(p,{name:"PencilSimpleLine",fontSize:"small"})})})})]}),e(G,{ref:eS,type:"file",accept:"image/*",multiple:!0,onChange:eG}),el?e(o,{title:eD,placement:"top",children:e(e9,{size:"small","aria-label":eD,...u.stopButton,onClick:em,children:e(H,{})})}):eN?e(o,{title:eM,placement:"top",children:e("span",{children:e(e8,{size:"small","aria-label":eM,...u.sendButton,type:"submit",disabled:ei||es,children:e(p,{name:"PaperPlaneRightBold",fontSize:"small"})})})}):eI?e(o,{title:ej,placement:"top",children:e("span",{children:e(e3,{size:"small","aria-label":ej,...u.micButton,"data-blocked":eK,disabled:ei||"requesting"===eh.status,onClick:()=>void eg(),children:e(p,{name:eK?"MicrophoneSlash":"Microphone",fontSize:"small"})})})}):e(o,{title:ez,placement:"top",children:e("span",{children:e(e8,{size:"small","aria-label":ez,...u.sendButton,type:"submit",disabled:!ed,children:e(p,{name:"PaperPlaneRightBold",fontSize:"small"})})})})]}),en?e(tt,{role:"status",...u.attachmentNotice,children:"limit"===en?eT:eP}):eK&&eI?e(tt,{role:"status",...u.attachmentNotice,children:eF}):e(te,{...u.hint,children:e(a,{id:"sdk.assistant.composer.disclaimer",message:"AI can be wrong. Check the result."})})]})};
1
+ import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import{IconButton as n,Tooltip as o,styled as i,useThemeProps as r}from"@mui/material";import{useCallback as s,useEffect as l,useRef as d,useState as c}from"react";import{useLocalizable as m}from"#package/react-sdk";import{PhxIcon as p,hoverStyles as u,useResponsive as h}from"#package/ui-sdk";import{AnnotationBadge as g}from"./annotation/index.js";import{AssistantComposerName as b,ComposerField as f,ComposerFrame as k,ComposerInput as v,ComposerPrimaryButton as y,ComposerToolButton as S}from"./composer/index.js";import{AssistantDisclaimerDialog as B,AssistantDisclaimerLine as x}from"./disclaimer/index.js";import{useAssistantComposer as z}from"./use-assistant-composer.js";import{RecordingBar as D}from"./voice/index.js";let w={id:"sdk.assistant.composer.placeholder",message:"Ask or tell me what to change…"},C={id:"sdk.assistant.composer.send.label",message:"Send"},A={id:"sdk.assistant.composer.stop.label",message:"Stop"},E={id:"sdk.assistant.composer.attach.label",message:"Attach images"},R={id:"sdk.assistant.composer.annotate.label",message:"Annotate with drawings and comments"},P={id:"sdk.assistant.composer.attachment.remove",message:"Remove image"},j={id:"sdk.assistant.composer.attachment.annotate",message:"Annotate image"},T={id:"sdk.assistant.composer.annotation.remove",message:"Remove annotation"},M={id:"sdk.assistant.composer.attachment.unreadable",message:"Unsupported image format."},F={id:"sdk.assistant.composer.record.label",message:"Record a voice message"},N={id:"sdk.assistant.composer.recording.send",message:"Send voice message"},L={id:"sdk.assistant.composer.record.blocked",message:"Microphone access is blocked. Allow it in your browser's site settings."},K={id:"sdk.assistant.composer.attachment.limit",message:"You can attach up to {max} images."},I=i("form",{name:b,slot:"root"})(({theme:{palette:e,spacing:t}})=>({borderBlockStart:`1px solid ${e.divider}`,display:"grid",gap:t(.75),paddingBlock:t(1.25),paddingInline:`var(--phx-sidebar-padding, ${t(2)})`})),O=i("div",{name:b,slot:"attachments"})(({theme:{spacing:e}})=>({display:"flex",flexWrap:"wrap",gap:e(1),gridColumn:"1 / -1",paddingBlockStart:e(.75)})),$=i("div")({cursor:"default",display:"flex",justifySelf:"start"}),U=i("div",{name:b,slot:"attachment"})(({theme:{palette:e,shape:t}})=>({blockSize:56,border:`1px solid ${e.divider}`,borderRadius:t.borderRadius,inlineSize:56,overflow:"hidden",position:"relative"})),W=i("img")({blockSize:"100%",display:"block",inlineSize:"100%",objectFit:"cover"}),q=i(n,{name:b,slot:"removeAttachment"})(({theme:{palette:e}})=>({background:e.background.paper,insetBlockStart:2,insetInlineEnd:2,padding:2,position:"absolute","&:hover":{background:e.background.paper}})),H=i(n,{name:b,slot:"annotateAttachment"})(({theme:{palette:e}})=>({background:e.background.paper,insetBlockEnd:2,insetInlineStart:2,padding:2,position:"absolute","&:hover":{background:e.background.paper}})),X=i(n,{name:b,slot:"stopButton"})(({theme:{palette:e}})=>({background:e.text.primary,borderRadius:8,color:e.background.paper,padding:4,"&:hover":{background:e.text.primary},...u({"&:hover":{background:e.text.secondary}})})),Y=i("span")({background:"currentColor",blockSize:10,borderRadius:2,inlineSize:10,margin:5}),G=i("div",{name:b,slot:"hint"})(({theme:{palette:e,typography:t}})=>({...t.caption,color:e.text.secondary})),J=i("div",{name:b,slot:"attachmentNotice"})(({theme:{palette:e,typography:t}})=>({...t.caption,color:e.error.main})),Q=i("input")({display:"none"}),V=i(y,{name:b,slot:"micButton"})(({theme:{palette:e}})=>({'&[data-blocked="true"], &[data-blocked="true"]:hover':{background:e.action.disabledBackground,color:e.text.secondary}}));export const AssistantComposer=n=>{let{slots:i={},slotProps:u={}}=r({props:n,name:b}),{draft:Z,setDraft:_,attachments:ee,addFiles:et,annotate:ea,annotateAttachment:en,removeAttachment:eo,notice:ei,maxAttachments:er,isBusy:es,isPreparing:el,isLocked:ed,isReplying:ec,canSend:em,send:ep,stop:eu,inputFocusHandlers:eh,canAttach:eg,canAnnotate:eb,canRecord:ef,recording:ek,startRecording:ev,sendRecording:ey,cancelRecording:eS}=z(),[eB,ex]=c(!1),ez=d(null),eD=d(null),{isDesktop:ew}=h(),eC=m(w),eA=m(C),eE=m(A),eR=m(E),eP=m(R),ej=m(j),eT=m(P),eM=m(T),eF=m(M),eN=m({...K,values:{max:er}}),eL=m(F),eK=m(N),eI=m(L),eO="recording"===ek.status||"recorded"===ek.status,e$=ef&&!Z.trim()&&0===ee.length,eU=ef&&"refused"===ek.status,eW=s(async()=>{em&&!ew&&ez.current?.blur(),await ep()},[em,ew,ep]),eq=s(e=>{e.preventDefault(),eO?ey():eW()},[eO,eW,ey]);l(()=>{ew&&ez.current?.focus()},[]);let eH=d(null),eX=d(null),eY=d(eO);l(()=>{var e;let t,a=(e=eH.current,(t=e?.getRootNode())instanceof ShadowRoot?t.activeElement??(document.activeElement===document.body?null:document.activeElement):document.activeElement===document.body?null:document.activeElement),n=null===a||(eH.current?.contains(a)??!1);n&&eO&&!eX.current?.contains(a)?eX.current?.focus():n&&!eO&&eY.current&&ew&&ez.current?.focus(),eY.current=eO},[eO,es,ew]);let eG=u.root?.onKeyDown,eJ=s(e=>{if(eG?.(e),!e.defaultPrevented&&eO&&!e.nativeEvent.isComposing){if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),es||eS();return}"Enter"===e.key&&!(e.target instanceof HTMLButtonElement)&&(e.preventDefault(),e.repeat||es||el||ey())}},[eS,eO,es,el,eG,ey]),eQ=s(e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),eW())},[eW]),[eV,eZ]=c(!1),e_=s(()=>eZ(!0),[]),e1=s(()=>eZ(!1),[]),e0=s(e=>{e.target===e.currentTarget&&(e.preventDefault(),ez.current?.focus())},[]),e2=s(e=>{let t=[...e.target.files??[]];e.target.value="",et(t)},[et]),e5=s(e=>{let t=[...e.clipboardData.files].filter(e=>e.type.startsWith("image/"));eg&&0!==t.length&&(e.preventDefault(),et(t))},[et,eg]),e6=s(e=>{eg&&!ed&&e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",ex(!0))},[eg,ed]),e7=s(e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||ex(!1)},[]),e4=s(e=>{eg&&!ed&&0!==e.dataTransfer.files.length&&(e.preventDefault(),ex(!1),et([...e.dataTransfer.files]))},[et,eg,ed]),e8=i.root??I,e3=i.inputFrame??k,e9=i.attachments??O,te=i.attachment??U,tt=i.removeAttachment??q,ta=i.annotateAttachment??H,tn=i.input??v,to=i.toolButton??S,ti=i.sendButton??y,tr=i.micButton??V,ts=i.stopButton??X,tl=i.hint??G,td=i.attachmentNotice??J;return t(a,{children:[t(e8,{...u.root,ref:eH,onSubmit:eq,onKeyDown:eJ,onDragOver:e6,onDragLeave:e7,onDrop:e4,children:[t(e3,{...u.inputFrame,"data-dragging":eB,onMouseDown:e0,children:[ee.length>0&&e(e9,{...u.attachments,children:ee.map(a=>t(te,{...u.attachment,children:[e(W,{src:a.previewUrl,alt:""}),a.isAnnotation?e(g,{count:a.pinCount}):eg&&eb&&e(ta,{size:"small","aria-label":ej,...u.annotateAttachment,disabled:es||ed,onClick:()=>void en(a.id),children:e(p,{name:"PencilSimpleLine",sx:{fontSize:12}})}),e(tt,{size:"small","aria-label":a.isAnnotation?eM:eT,...u.removeAttachment,disabled:es,onClick:()=>eo(a.id),children:e(p,{name:"X",sx:{fontSize:12}})})]},a.id))}),eO?e(D,{ref:eX,slot:i.recordingBar,slotProps:u.recordingBar,isRecording:"recording"===ek.status,elapsedMs:ek.elapsedMs,level:ek.level,disabled:es,onDiscard:eS}):e(f,{children:e(tn,{multiline:!0,maxRows:6,placeholder:eC,...u.input,inputProps:{...u.input?.inputProps,"aria-label":eC},value:Z,readOnly:es,disabled:ed,inputRef:ez,onChange:e=>_(e.target.value),onKeyDown:eQ,onPaste:e5,onFocus:eh.onFocus,onBlur:eh.onBlur})}),t($,{children:[eg&&e(o,{title:eR,placement:"top",children:e("span",{children:e(to,{size:"small","aria-label":eR,...u.toolButton,disabled:es||ed,onClick:()=>eD.current?.click(),children:e(p,{name:"Paperclip",fontSize:"small"})})})}),eb&&e(o,{title:eP,placement:"top",children:e("span",{children:e(to,{size:"small","aria-label":eP,...u.toolButton,disabled:es||ed,onClick:()=>void ea(),children:e(p,{name:"PencilSimpleLine",fontSize:"small"})})})})]}),eg&&e(Q,{ref:eD,type:"file",accept:"image/*",multiple:!0,onChange:e2}),ec?e(o,{title:eE,placement:"top",children:e(ts,{size:"small","aria-label":eE,...u.stopButton,onClick:eu,children:e(Y,{})})}):eO?e(o,{title:eK,placement:"top",children:e("span",{children:e(ti,{size:"small","aria-label":eK,...u.sendButton,type:"submit",disabled:es||el,children:e(p,{name:"PaperPlaneRightBold",fontSize:"small"})})})}):e$?e(o,{title:eL,placement:"top",children:e("span",{children:e(tr,{size:"small","aria-label":eL,...u.micButton,"data-blocked":eU,disabled:es||"requesting"===ek.status,onClick:()=>void ev(),children:e(p,{name:eU?"MicrophoneSlash":"Microphone",fontSize:"small"})})})}):e(o,{title:eA,placement:"top",children:e("span",{children:e(ti,{size:"small","aria-label":eA,...u.sendButton,type:"submit",disabled:!em,children:e(p,{name:"PaperPlaneRightBold",fontSize:"small"})})})})]}),ei?e(td,{role:"status",...u.attachmentNotice,children:"limit"===ei?eN:eF}):eU&&e$?e(td,{role:"status",...u.attachmentNotice,children:eI}):e(tl,{...u.hint,children:e(x,{onLearnMore:e_})})]}),e(B,{isOpen:eV,onClose:e1})]})};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as e}from"react/jsx-runtime";import{styled as s,useThemeProps as r}from"@mui/material";import{useLocalizable as a}from"#package/react-sdk";import{AssistantComposer as o}from"./AssistantComposer.js";import{AssistantThread as n}from"./AssistantThread.js";import{AssistantPanelHeader as i}from"./panel/index.js";import{useIsAssistantPanelOpen as m}from"./use-is-assistant-panel-open.js";let l="PhxAssistantPanel",p={id:"sdk.assistant.panel.title",message:"Assistant"};export const ASSISTANT_PANEL_SLOT="slot[assistant]";let d=s("section",{name:l,slot:"root"})(({theme:{palette:t}})=>({background:`var(--phx-sidebar-background, ${t.background.paper})`,border:"var(--phx-sidebar-border, 0)",borderRadius:"inherit",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:"min-content minmax(0, 1fr) min-content",inset:0,overflow:"hidden",position:"absolute",zIndex:1})),u=t=>{t.target instanceof Element&&t.target.closest('button, [role="button"]')&&t.preventDefault()};export const AssistantPanel=s=>{let{slots:c={},slotProps:b={}}=r({props:s,name:l}),f=m(),x=a(p);if(!f)return null;let g=c.root??d,h=c.header??i,A=c.thread??n,j=c.composer??o;return e(g,{"aria-label":x,...b.root,"data-sidebar":"slot[assistant]",onMouseDown:u,children:[t(h,{}),t(A,{}),t(j,{})]})};
1
+ import{jsx as t,jsxs as e}from"react/jsx-runtime";import{styled as s,useThemeProps as r}from"@mui/material";import{useLocalizable as a}from"#package/react-sdk";import{AssistantComposer as o}from"./AssistantComposer.js";import{AssistantThread as n}from"./AssistantThread.js";import{AssistantPanelHeader as i}from"./panel/index.js";import{useIsAssistantPanelOpen as m}from"./use-is-assistant-panel-open.js";let l="PhxAssistantPanel",p={id:"sdk.assistant.panel.title",message:"AI assistant"};export const ASSISTANT_PANEL_SLOT="slot[assistant]";let d=s("section",{name:l,slot:"root"})(({theme:{palette:t}})=>({background:`var(--phx-sidebar-background, ${t.background.paper})`,border:"var(--phx-sidebar-border, 0)",borderRadius:"inherit",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:"min-content minmax(0, 1fr) min-content",inset:0,overflow:"hidden",position:"absolute",zIndex:1})),u=t=>{t.target instanceof Element&&t.target.closest('button, [role="button"]')&&t.preventDefault()};export const AssistantPanel=s=>{let{slots:c={},slotProps:b={}}=r({props:s,name:l}),f=m(),x=a(p);if(!f)return null;let g=c.root??d,h=c.header??i,A=c.thread??n,j=c.composer??o;return e(g,{"aria-label":x,...b.root,"data-sidebar":"slot[assistant]",onMouseDown:u,children:[t(h,{}),t(A,{}),t(j,{})]})};
@@ -36,14 +36,15 @@ export interface ThemeableAssistantAnnotationCommentProps {
36
36
  interface AnnotationCommentProps {
37
37
  /** Where its pin is on the view. */
38
38
  readonly point: AnnotationPoint;
39
- /** The comment as saved so far; what is typed is the pin's only once it is saved. */
40
- readonly comment: string;
39
+ /** What is typed in the comment, which the editor keeps: Done saves it, closing the comment otherwise drops it. */
40
+ readonly draft: string;
41
+ readonly onDraftChange: (draft: string) => void;
41
42
  readonly onDelete: () => void;
42
- readonly onSave: (comment: string) => void;
43
+ readonly onSave: () => void;
43
44
  }
44
45
  /**
45
46
  * The comment of a pin, open for editing by the pin: it takes the focus as it opens. Enter saves it and
46
- * Shift+Enter adds a line, as in the composer. What is typed stays here until it is saved.
47
+ * Shift+Enter adds a line, as in the composer.
47
48
  */
48
- export declare const AnnotationComment: ({ point, comment, onDelete, onSave }: AnnotationCommentProps) => import("react/jsx-runtime").JSX.Element;
49
+ export declare const AnnotationComment: ({ point, draft, onDraftChange, onDelete, onSave }: AnnotationCommentProps) => import("react/jsx-runtime").JSX.Element;
49
50
  export {};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Tooltip as n,styled as o,useThemeProps as a}from"@mui/material";import{useCallback as i,useRef as s,useState as r}from"react";import{useLocalizable as l}from"#package/react-sdk";import{PhxIcon as m}from"#package/ui-sdk";import{ComposerField as c,ComposerFrame as p,ComposerInput as d,ComposerPrimaryButton as u,ComposerToolButton as h}from"../../composer/index.js";let g="PhxAssistantAnnotationComment",f={id:"sdk.assistant.annotation.comment.placeholder",message:"Add a comment…"},k={id:"sdk.assistant.annotation.comment.delete",message:"Delete"},x={id:"sdk.assistant.annotation.comment.save",message:"Save"},v=o(p,{name:g,slot:"root"})(({theme:{palette:e,shadows:t}})=>({background:e.background.paper,boxShadow:t[6],inlineSize:"min(280px, 80cqw)",position:"absolute",zIndex:1})),C=o("div")(({theme:{spacing:e}})=>({cursor:"default",display:"flex",gap:e(.5),gridColumn:2})),b={};export const AnnotationComment=({point:o,comment:p,onDelete:S,onSave:w})=>{let[y,z]=r(p),D=s(null),P=l(f),j=l(k),A=l(x),{slots:E={},slotProps:$={}}=a({props:b,name:g}),I=i(e=>{e.stopPropagation(),e.target===e.currentTarget&&(e.preventDefault(),D.current?.focus())},[]),B=i(e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),w(y))},[y,w]);return t(E.root??v,{...$.root,style:{...$.root?.style,...(({x:e,y:t})=>({...e<.5?{insetInlineStart:`${100*e}%`}:{insetInlineEnd:`${(1-e)*100}%`},...t<.5?{insetBlockStart:`calc(${100*t}% + 18px)`}:{insetBlockEnd:`calc(${(1-t)*100}% + 18px)`}}))(o)},onPointerDown:e=>e.stopPropagation(),onMouseDown:I,children:[e(c,{children:e(d,{autoFocus:!0,multiline:!0,maxRows:4,placeholder:P,value:y,inputRef:D,inputProps:{"aria-label":P},onChange:e=>z(e.target.value),onKeyDown:B})}),t(C,{children:[e(n,{title:j,placement:"top",children:e(h,{size:"small","aria-label":j,onClick:S,children:e(m,{name:"Trash",fontSize:"small"})})}),e(n,{title:A,placement:"top",children:e(u,{size:"small","aria-label":A,onClick:()=>w(y),children:e(m,{name:"Check",fontSize:"small"})})})]})]})};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Tooltip as n,styled as o,useThemeProps as a}from"@mui/material";import{useCallback as i,useRef as s}from"react";import{useLocalizable as r}from"#package/react-sdk";import{PhxIcon as l}from"#package/ui-sdk";import{ComposerField as m,ComposerFrame as c,ComposerInput as p,ComposerPrimaryButton as d,ComposerToolButton as u}from"../../composer/index.js";let h="PhxAssistantAnnotationComment",g={id:"sdk.assistant.annotation.comment.placeholder",message:"Add a comment…"},f={id:"sdk.assistant.annotation.comment.delete",message:"Delete"},k={id:"sdk.assistant.annotation.comment.save",message:"Save"},x=o(c,{name:h,slot:"root"})(({theme:{palette:e,shadows:t}})=>({background:e.background.paper,boxShadow:t[6],inlineSize:"min(280px, 80cqw)",position:"absolute",zIndex:1})),v=o("div")(({theme:{spacing:e}})=>({cursor:"default",display:"flex",gap:e(.5),gridColumn:2})),C={};export const AnnotationComment=({point:o,draft:c,onDraftChange:b,onDelete:S,onSave:w})=>{let y=s(null),z=r(g),D=r(f),P=r(k),{slots:j={},slotProps:A={}}=a({props:C,name:h}),E=i(e=>{e.stopPropagation(),e.target===e.currentTarget&&(e.preventDefault(),y.current?.focus())},[]),$=i(e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),w())},[w]);return t(j.root??x,{...A.root,style:{...A.root?.style,...(({x:e,y:t})=>({...e<.5?{insetInlineStart:`${100*e}%`}:{insetInlineEnd:`${(1-e)*100}%`},...t<.5?{insetBlockStart:`calc(${100*t}% + 18px)`}:{insetBlockEnd:`calc(${(1-t)*100}% + 18px)`}}))(o)},onPointerDown:e=>e.stopPropagation(),onMouseDown:E,children:[e(m,{children:e(p,{autoFocus:!0,multiline:!0,maxRows:4,placeholder:z,value:c,inputRef:y,inputProps:{"aria-label":z},onChange:e=>b(e.target.value),onKeyDown:$})}),t(v,{children:[e(n,{title:D,placement:"top",children:e(u,{size:"small","aria-label":D,onClick:S,children:e(l,{name:"Trash",fontSize:"small"})})}),e(n,{title:P,placement:"top",children:e(d,{size:"small","aria-label":P,onClick:w,children:e(l,{name:"Check",fontSize:"small"})})})]})]})};
@@ -10,9 +10,10 @@ interface AnnotationEditorProps {
10
10
  * red strokes; Comment places a numbered pin where the user clicks and opens its comment, and opens
11
11
  * the comment of a pin clicked again, with Delete. Hovering or tapping a pin shows its comment.
12
12
  *
13
- * Done drops the pins without a comment and flattens the strokes and the pin badges onto the view; it
14
- * does nothing while there is nothing on it. Cancel, or Escape, ends it with nothing. Either way it
15
- * fades out first. An editor that goes away before it ended ends as cancelled.
13
+ * Done saves what is typed in an open comment, as Save would, drops the pins without a comment and flattens
14
+ * the strokes and the pin badges onto the view; it does nothing while there is nothing on it. Cancel, or
15
+ * Escape, ends it with nothing. Either way it fades out first. While a comment is open, Escape and a click
16
+ * beside it close it and drop what was typed in it. An editor that goes away before it ended ends as cancelled.
16
17
  */
17
18
  export declare const AnnotationEditor: ({ view, finish }: AnnotationEditorProps) => import("react/jsx-runtime").JSX.Element;
18
19
  export {};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Trans as t}from"@lingui/react";import{Button as r,ToggleButton as i,ToggleButtonGroup as o}from"@mui/material";import{useCallback as a,useEffect as l,useLayoutEffect as s,useRef as m,useState as c}from"react";import{useLocalizable as u}from"#package/react-sdk";import{PhxIcon as d}from"#package/ui-sdk";import{useOnUnmount as p}from"../../use-on-unmount.js";import{AnnotationPin as h}from"../AnnotationPin.js";import{ANNOTATION_FADE_DURATION as g,ANNOTATION_STROKE_WIDTH as f,AnnotationPicture as w,AnnotationStage as v,AnnotationSurface as k,annotationSurfaceSize as x,useAnnotationSlots as C}from"../annotation-layout.js";import{prefersReducedMotion as j}from"../prefers-reduced-motion.js";import{AnnotationComment as P}from"./AnnotationComment.js";import{drawAnnotationStrokes as b}from"./annotation-drawing.js";import{annotationPointIn as y,closeAnnotationPin as I,createAnnotationPin as E,deleteAnnotationPin as T,keptAnnotationPins as A,replaceAnnotationPin as D}from"./annotation-pins.js";import{flattenAnnotation as M}from"./flatten-annotation.js";let z={id:"sdk.assistant.annotation.label",message:"Annotate the view"},R=(e,n)=>y(n.getBoundingClientRect(),e.clientX,e.clientY);export const AnnotationEditor=({view:y,finish:S})=>{let[F,L]=c("marker"),{Root:O,Toolbar:W,slotProps:q}=C(),[B,H]=c([]),[U,X]=c([]),[Y,G]=c(null),[J,K]=c(!1),N=m(null),Q=m(null),V=m(null),Z=m(null),$=m(!1),_=m(S);_.current=S;let ee=u(z),en=B.length>0||A(U).length>0;p(()=>_.current(null)),s(()=>{Q.current?.getContext("2d")?.drawImage(y,0,0)},[y]);let et=a(()=>{let e,n,t,r=V.current,i=r?.getContext("2d");if(!r||!i)return;let{width:o,height:a,ratio:l}=(e=globalThis.devicePixelRatio||1,n=Math.round(r.clientWidth*e),t=Math.round(r.clientHeight*e),(r.width!==n||r.height!==t)&&(r.width=n,r.height=t),{width:n,height:t,ratio:e}),s=Z.current;i.clearRect(0,0,o,a),b(i,s?[...B,s.points]:B,{width:o,height:a},f*l)},[B]),er=m(null),ei=a(()=>{null!==er.current&&(cancelAnimationFrame(er.current),er.current=null)},[]),eo=a(()=>{er.current??=requestAnimationFrame(()=>{er.current=null,et()})},[et]);l(()=>ei,[ei]),s(()=>{ei(),et();let e=N.current;if(!e)return;let n=new ResizeObserver(()=>{ei(),et()});return n.observe(e),()=>n.disconnect()},[ei,et]);let ea=a(async e=>{if($.current)return;$.current=!0,K(!0);let[n]=await Promise.all([e(),new Promise(e=>setTimeout(e,j()?0:g))]);_.current(n)},[]),el=a(()=>void ea(async()=>null),[ea]),es=a(()=>{let e=N.current;if(!en||!e)return;let n=A(U),t=y.width/e.clientWidth;ea(async()=>{try{return{blob:await M({view:y,strokes:B,pins:n,scale:t}),pins:n}}catch{return null}})},[en,ea,U,B,y]),em=a(()=>{Y&&X(e=>I(e,Y)),G(null)},[Y]),ec=a(e=>{if(Y){let n={...Y,comment:e.trim()};X(e=>I(D(e,Y,n),n))}G(null)},[Y]),eu=a(()=>{Y&&X(e=>T(e,Y)),G(null)},[Y]),ed=a(e=>{e!==Y&&(em(),G(e))},[em,Y]);l(()=>{let e=e=>{"Escape"!==e.key||e.isComposing||(Y?em():el())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[em,Y,el]);let ep=a(e=>{if(Z.current||!e.isPrimary)return;let n=R(e,e.currentTarget);if("comment"===F){if(Y)em();else{let e=E(n);X(n=>[...n,e]),G(e)}return}e.currentTarget.setPointerCapture(e.pointerId),Z.current={pointerId:e.pointerId,points:[n]}},[em,Y,F]),eh=a(e=>{let n=Z.current;n?.pointerId===e.pointerId&&(n.points.push(R(e,e.currentTarget)),eo())},[eo]),eg=a(e=>{let n=Z.current;n?.pointerId===e.pointerId&&(Z.current=null,H(e=>[...e,n.points]))},[]);return n(O,{...q.root,role:"dialog","aria-modal":"true","aria-label":ee,"data-leaving":J,children:[e(v,{children:n(k,{ref:N,sx:{...x(y.width,y.height),cursor:"comment"===F?"copy":"crosshair"},onPointerDown:ep,onMouseDown:e=>"comment"===F&&e.preventDefault(),onPointerMove:eh,onPointerUp:eg,onPointerCancel:eg,children:[e(w,{ref:Q,width:y.width,height:y.height}),e(w,{ref:V}),U.map((n,t)=>e(h,{pin:n,index:t,variant:"badge",isEdited:n===Y,onClick:"comment"===F?()=>ed(n):void 0},t)),Y&&e(P,{point:Y,comment:Y.comment,onDelete:eu,onSave:ec},U.indexOf(Y))]})}),n(W,{...q.toolbar,children:[n(o,{exclusive:!0,size:"small",value:F,onChange:(e,n)=>{n&&(L(n),em())},children:[n(i,{value:"marker",autoFocus:!0,children:[e(d,{name:"PencilSimpleLine",fontSize:"small",sx:{marginInlineEnd:.5}}),e(t,{id:"sdk.assistant.annotation.marker",message:"Marker"})]}),n(i,{value:"comment",children:[e(d,{name:"ChatCircleText",fontSize:"small",sx:{marginInlineEnd:.5}}),e(t,{id:"sdk.assistant.annotation.comment",message:"Comment"})]})]}),e(r,{variant:"text",onClick:el,children:e(t,{id:"sdk.assistant.annotation.cancel",message:"Cancel"})}),e(r,{variant:"contained",disabled:!en,onClick:es,children:e(t,{id:"sdk.assistant.annotation.done",message:"Done"})})]})]})};
1
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Trans as t}from"@lingui/react";import{Button as r,ToggleButton as i,ToggleButtonGroup as o}from"@mui/material";import{useCallback as a,useEffect as l,useLayoutEffect as s,useRef as m,useState as c}from"react";import{useLocalizable as u}from"#package/react-sdk";import{PhxIcon as d}from"#package/ui-sdk";import{useOnUnmount as p}from"../../use-on-unmount.js";import{AnnotationPin as h}from"../AnnotationPin.js";import{ANNOTATION_FADE_DURATION as g,ANNOTATION_STROKE_WIDTH as f,AnnotationPicture as w,AnnotationStage as v,AnnotationSurface as k,annotationSurfaceSize as C,useAnnotationSlots as x}from"../annotation-layout.js";import{prefersReducedMotion as j}from"../prefers-reduced-motion.js";import{AnnotationComment as P}from"./AnnotationComment.js";import{drawAnnotationStrokes as b}from"./annotation-drawing.js";import{annotationPointIn as y,closeAnnotationPin as I,createAnnotationPin as E,deleteAnnotationPin as T,draftedAnnotationPins as A,keptAnnotationPins as D,replaceAnnotationPin as M}from"./annotation-pins.js";import{flattenAnnotation as z}from"./flatten-annotation.js";let R={id:"sdk.assistant.annotation.label",message:"Annotate the view"},S=(e,n)=>y(n.getBoundingClientRect(),e.clientX,e.clientY);export const AnnotationEditor=({view:y,finish:F})=>{let[L,O]=c("marker"),{Root:W,Toolbar:q,slotProps:B}=x(),[H,U]=c([]),[X,Y]=c([]),[G,J]=c(null),[K,N]=c(""),[Q,V]=c(!1),Z=m(null),$=m(null),_=m(null),ee=m(null),en=m(!1),et=m(F);et.current=F;let er=u(R),ei=D(A(X,G,K)),eo=H.length>0||ei.length>0;p(()=>et.current(null)),s(()=>{$.current?.getContext("2d")?.drawImage(y,0,0)},[y]);let ea=a(()=>{let e,n,t,r=_.current,i=r?.getContext("2d");if(!r||!i)return;let{width:o,height:a,ratio:l}=(e=globalThis.devicePixelRatio||1,n=Math.round(r.clientWidth*e),t=Math.round(r.clientHeight*e),(r.width!==n||r.height!==t)&&(r.width=n,r.height=t),{width:n,height:t,ratio:e}),s=ee.current;i.clearRect(0,0,o,a),b(i,s?[...H,s.points]:H,{width:o,height:a},f*l)},[H]),el=m(null),es=a(()=>{null!==el.current&&(cancelAnimationFrame(el.current),el.current=null)},[]),em=a(()=>{el.current??=requestAnimationFrame(()=>{el.current=null,ea()})},[ea]);l(()=>es,[es]),s(()=>{es(),ea();let e=Z.current;if(!e)return;let n=new ResizeObserver(()=>{es(),ea()});return n.observe(e),()=>n.disconnect()},[es,ea]);let ec=a(async e=>{if(en.current)return;en.current=!0,V(!0);let[n]=await Promise.all([e(),new Promise(e=>setTimeout(e,j()?0:g))]);et.current(n)},[]),eu=a(()=>void ec(async()=>null),[ec]),ed=a(()=>{let e=Z.current;if(!eo||!e)return;let n=y.width/e.clientWidth;ec(async()=>{try{return{blob:await z({view:y,strokes:H,pins:ei,scale:n}),pins:ei}}catch{return null}})},[ei,eo,ec,H,y]),ep=a(e=>{J(e),N(e.comment)},[]),eh=a(()=>{G&&Y(e=>I(e,G)),J(null)},[G]),eg=a(()=>{if(G){let e={...G,comment:K.trim()};Y(n=>I(M(n,G,e),e))}J(null)},[K,G]),ef=a(()=>{G&&Y(e=>T(e,G)),J(null)},[G]),ew=a(e=>{e!==G&&(eh(),ep(e))},[eh,ep,G]);l(()=>{let e=e=>{"Escape"!==e.key||e.isComposing||(G?eh():eu())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eh,G,eu]);let ev=a(e=>{if(ee.current||!e.isPrimary)return;let n=S(e,e.currentTarget);if("comment"===L){if(G)eh();else{let e=E(n);Y(n=>[...n,e]),ep(e)}return}e.currentTarget.setPointerCapture(e.pointerId),ee.current={pointerId:e.pointerId,points:[n]}},[eh,ep,G,L]),ek=a(e=>{let n=ee.current;n?.pointerId===e.pointerId&&(n.points.push(S(e,e.currentTarget)),em())},[em]),eC=a(e=>{let n=ee.current;n?.pointerId===e.pointerId&&(ee.current=null,U(e=>[...e,n.points]))},[]);return n(W,{...B.root,role:"dialog","aria-modal":"true","aria-label":er,"data-leaving":Q,children:[e(v,{children:n(k,{ref:Z,sx:{...C(y.width,y.height),cursor:"comment"===L?"copy":"crosshair"},onPointerDown:ev,onMouseDown:e=>"comment"===L&&e.preventDefault(),onPointerMove:ek,onPointerUp:eC,onPointerCancel:eC,children:[e(w,{ref:$,width:y.width,height:y.height}),e(w,{ref:_}),X.map((n,t)=>e(h,{pin:n,index:t,variant:"badge",isEdited:n===G,onClick:"comment"===L?()=>ew(n):void 0},t)),G&&e(P,{point:G,draft:K,onDraftChange:N,onDelete:ef,onSave:eg},X.indexOf(G))]})}),n(q,{...B.toolbar,children:[n(o,{exclusive:!0,size:"small",value:L,onChange:(e,n)=>{n&&(O(n),eh())},children:[n(i,{value:"marker",autoFocus:!0,children:[e(d,{name:"PencilSimpleLine",fontSize:"small",sx:{marginInlineEnd:.5}}),e(t,{id:"sdk.assistant.annotation.marker",message:"Marker"})]}),n(i,{value:"comment",children:[e(d,{name:"ChatCircleText",fontSize:"small",sx:{marginInlineEnd:.5}}),e(t,{id:"sdk.assistant.annotation.comment",message:"Comment"})]})]}),e(r,{variant:"text",onClick:eu,children:e(t,{id:"sdk.assistant.annotation.cancel",message:"Cancel"})}),e(r,{variant:"contained",disabled:!eo,onClick:ed,children:e(t,{id:"sdk.assistant.annotation.done",message:"Done"})})]})]})};
@@ -11,6 +11,11 @@ export declare const replaceAnnotationPin: (pins: AnnotationPins, pin: Assistant
11
11
  export declare const deleteAnnotationPin: (pins: AnnotationPins, pin: AssistantAnnotationPin) => AnnotationPins;
12
12
  /** The pins once the comment of `pin` closes: no pin is left without a comment, so a pin with none goes. */
13
13
  export declare const closeAnnotationPin: (pins: AnnotationPins, pin: AssistantAnnotationPin) => AnnotationPins;
14
+ /**
15
+ * The pins with the open comment of `pin` saved as `draft`, the text typed in it: Done keeps what is typed in an open
16
+ * comment, as Save would. With no open comment, the pins as they are.
17
+ */
18
+ export declare const draftedAnnotationPins: (pins: AnnotationPins, pin: AssistantAnnotationPin | null, draft: string) => AnnotationPins;
14
19
  /** The pins an annotation keeps once it is done: those with a comment, renumbered, their comments trimmed. */
15
20
  export declare const keptAnnotationPins: (pins: AnnotationPins) => AnnotationPins;
16
21
  /** Where a point of the page is on a box, as fractions of it, kept within it. */
@@ -1 +1 @@
1
- export const createAnnotationPin=({x:t,y:n})=>({x:t,y:n,comment:""});export const replaceAnnotationPin=(t,n,o)=>t.map(t=>t===n?o:t);export const deleteAnnotationPin=(t,n)=>t.filter(t=>t!==n);export const closeAnnotationPin=(t,n)=>n.comment.trim()?t:deleteAnnotationPin(t,n);export const keptAnnotationPins=t=>t.flatMap(t=>{let n=t.comment.trim();return n?[{...t,comment:n}]:[]});let t=t=>Math.min(1,Math.max(0,t));export const annotationPointIn=(n,o,e)=>({x:t((o-n.left)/n.width),y:t((e-n.top)/n.height)});
1
+ export const createAnnotationPin=({x:t,y:n})=>({x:t,y:n,comment:""});export const replaceAnnotationPin=(t,n,o)=>t.map(t=>t===n?o:t);export const deleteAnnotationPin=(t,n)=>t.filter(t=>t!==n);export const closeAnnotationPin=(t,n)=>n.comment.trim()?t:deleteAnnotationPin(t,n);export const draftedAnnotationPins=(t,n,o)=>n?replaceAnnotationPin(t,n,{...n,comment:o}):t;export const keptAnnotationPins=t=>t.flatMap(t=>{let n=t.comment.trim();return n?[{...t,comment:n}]:[]});let t=t=>Math.min(1,Math.max(0,t));export const annotationPointIn=(n,o,e)=>({x:t((o-n.left)/n.width),y:t((e-n.top)/n.height)});
@@ -0,0 +1,10 @@
1
+ export interface AssistantDisclaimerDialogProps {
2
+ readonly isOpen: boolean;
3
+ readonly onClose: () => void;
4
+ }
5
+ /**
6
+ * The full disclaimer of the assistant panel, opened from the line under the composer. The body is one message
7
+ * written in Markdown, so a project rewrites it, links and lists included, in its own catalogs. Full screen on a
8
+ * phone, like the legacy chat's disclaimer.
9
+ */
10
+ export declare const AssistantDisclaimerDialog: ({ isOpen, onClose }: AssistantDisclaimerDialogProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Button as i,DialogActions as s,DialogContent as a,DialogTitle as n,IconButton as o,styled as r}from"@mui/material";import l from"react-markdown";import{useLocalizable as d}from"#package/react-sdk";import{Dialog as c,PhxIcon as m,useResponsive as h}from"#package/ui-sdk";let u={id:"sdk.assistant.disclaimer.title",message:"About this AI assistant"},p={id:"sdk.assistant.disclaimer.close",message:"Close"},g={id:"sdk.assistant.disclaimer.body",message:"This assistant is an automated AI system. It answers from the information it has about the products on this website and can change your design when you ask it to.\n\n**Accuracy.** Answers can be incomplete, out of date or wrong. Check important details such as dimensions, compatibility and price before you rely on them, and contact the seller if you are unsure.\n\n**Your responsibility.** You decide what to do with the assistant's answers. Neither the owner of this website nor the provider of the assistant technology is liable for actions, losses or damages resulting from its use.\n\nBy using the assistant, you accept this disclaimer. If you do not agree with any part of it, please do not use the assistant."},f=r(n)(({theme:{spacing:e}})=>({paddingInlineEnd:e(7)})),y=r(o)(({theme:{spacing:e}})=>({insetBlockStart:e(1.5),insetInlineEnd:e(1.5),position:"absolute"})),k=r(s)(({theme:{spacing:e}})=>({padding:e(1,3,2)})),b=r(a)(({theme:{palette:e,spacing:t,typography:i}})=>({...i.body2,color:e.text.primary,"& > :first-child":{marginBlockStart:0},"& > :last-child":{marginBlockEnd:0},"& p, & ul, & ol":{marginBlock:t(1.5)},"& ul, & ol":{paddingInlineStart:t(3)},"& a":{color:e.primary.main}})),w={a:({node:t,...i})=>e("a",{...i,target:"_blank",rel:"noopener noreferrer"})};export const AssistantDisclaimerDialog=({isOpen:s,onClose:a})=>{let{isMobile:n}=h(),o=d(u),r=d(p),x=d(g);return t(c.Root,{isOpen:s,onClose:a,fullScreen:n,sx:n?void 0:{maxWidth:"40rem",width:"90%"},children:[e(y,{"aria-label":r,onClick:a,children:e(m,{name:"X"})}),e(f,{children:o}),e(b,{children:e(l,{components:w,children:x})}),e(k,{children:e(i,{variant:"contained",onClick:a,children:r})})]})};
@@ -0,0 +1,10 @@
1
+ export interface AssistantDisclaimerLineProps {
2
+ /** Opens the dialog with the full disclaimer. */
3
+ readonly onLearnMore: () => void;
4
+ }
5
+ /**
6
+ * The line under the composer that tells the shopper they are chatting with an AI, as the EU AI Act Art. 50(1)
7
+ * requires, with a link to the full disclaimer. The link is part of the one message, so a translation can place it
8
+ * anywhere in the sentence.
9
+ */
10
+ export declare const AssistantDisclaimerLine: ({ onLearnMore }: AssistantDisclaimerLineProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ import{jsx as t}from"react/jsx-runtime";import{Trans as i}from"@lingui/react";import{Link as n}from"@mui/material";export const AssistantDisclaimerLine=({onLearnMore:a})=>t(i,{id:"sdk.assistant.disclaimer.line",components:{0:t(n,{component:"button",type:"button",variant:"inherit",color:"inherit",onClick:a})},message:"You're chatting with an AI. It can make mistakes. <0>Learn more</0>"});
@@ -0,0 +1,2 @@
1
+ export { AssistantDisclaimerDialog } from './AssistantDisclaimerDialog.js';
2
+ export { AssistantDisclaimerLine } from './AssistantDisclaimerLine.js';
@@ -0,0 +1 @@
1
+ export{AssistantDisclaimerDialog}from"./AssistantDisclaimerDialog.js";export{AssistantDisclaimerLine}from"./AssistantDisclaimerLine.js";
@@ -22,8 +22,7 @@ export interface ThemeableAssistantDrawingProps {
22
22
  *
23
23
  * - `root` — The frame around the drawing, its placeholder or its note (`div`).
24
24
  * - `button` — The button over the whole picture that opens it larger (`ButtonBase`).
25
- * - `image` — The picture (`img`). A custom image must keep calling the `onLoad` it is given: it revokes the blob URL
26
- * of the picture once the picture has loaded, and the URL leaks without it.
25
+ * - `image` — The picture (`img`).
27
26
  * - `note` — The placeholder while the model writes the drawing, or the note that it could not be shown (`div`).
28
27
  */
29
28
  readonly slots?: Partial<Record<'root' | 'button' | 'image' | 'note', ElementType>>;
@@ -52,7 +51,7 @@ export interface AssistantDrawingProps {
52
51
  /**
53
52
  * A drawing the model wrote in a reply, framed and as wide as the thread allows; a click opens it
54
53
  * larger beside the panel. It is shown as an image, so nothing in it runs or loads, and its source
55
- * never reaches the page; a source that is not a drawing the panel can show leaves a note. While the
54
+ * is never rendered as markup; a source that is not a drawing the panel can show leaves a note. While the
56
55
  * model writes it, a placeholder stands in.
57
56
  */
58
57
  export declare const AssistantDrawing: import("react").MemoExoticComponent<({ source, status }: AssistantDrawingProps) => import("react/jsx-runtime").JSX.Element>;
@@ -1 +1 @@
1
- import{jsx as i}from"react/jsx-runtime";import{Trans as e}from"@lingui/react";import{ButtonBase as o,styled as r,useThemeProps as t}from"@mui/material";import{memo as n,useCallback as a,useMemo as s,useState as l}from"react";import{useLocalizable as d}from"#package/react-sdk";import{useConfigurator as m}from"../../../application-runtime/index.js";import{parseDrawing as g}from"./parse-drawing.js";import{revokeDrawingUrlOnLoad as c,useDrawingUrl as u}from"./use-drawing-url.js";let p="PhxAssistantDrawing",b=r("div",{name:p,slot:"root"})(({theme:{palette:i,shape:e,spacing:o}})=>({border:`1px solid ${i.divider}`,borderRadius:e.borderRadius,boxSizing:"border-box",marginBlock:o(1),maxInlineSize:"100%",padding:o(1)})),w={id:"sdk.assistant.drawing.open.label",message:"Open the drawing"},h=r(o,{name:p,slot:"button"})(({theme:{palette:i}})=>({cursor:"zoom-in",display:"block",inlineSize:"100%","&:focus-visible":{outline:`2px solid ${i.primary.main}`,outlineOffset:2}})),k=r("img",{name:p,slot:"image"})({blockSize:"auto",display:"block",inlineSize:"100%"}),f=r("div",{name:p,slot:"note"})(({theme:{palette:i,spacing:e,typography:o}})=>({...o.caption,color:i.text.secondary,paddingBlock:e(1),paddingInline:e(.5)})),x={},v=()=>{let{slots:i={},slotProps:e={}}=t({props:x,name:p});return{Root:i.root??b,Button:i.button??h,Image:i.image??k,NoteSlot:i.note??f,slotProps:e}},z=()=>{let{Root:o,NoteSlot:r,slotProps:t}=v();return i(o,{...t.root,children:i(r,{...t.note,role:"alert",children:i(e,{id:"sdk.assistant.drawing.failure",message:"This drawing could not be shown"})})})},S=({source:e,title:o})=>{let{assistantSystem:r}=m(),t=u(e),[n,s]=l(),g=d(w),{Root:p,Button:b,Image:h,slotProps:k}=v(),f=a(()=>{r.viewImage({kind:"svg",source:e,title:o})},[r,e,o]),x=a(()=>{s(t)},[t]);return void 0!==t&&t===n?i(z,{}):i(p,{...k.root,children:i(b,{...k.button,"aria-label":void 0===o?g:void 0,onClick:f,children:void 0!==t&&i(h,{...k.image,src:t,alt:o??"",onLoad:c,onError:x})})})},j=({source:e})=>{let o=s(()=>g(e),[e]);return o.ok?i(S,{source:e,title:o.title}):i(z,{})},y=()=>{let{Root:o,NoteSlot:r,slotProps:t}=v();return i(o,{...t.root,children:i(r,{...t.note,role:"status",children:i(e,{id:"sdk.assistant.drawing.writing",message:"Drawing…"})})})};export const AssistantDrawing=n(({source:e,status:o})=>"writing"===o?i(y,{}):i(j,{source:e}));
1
+ import{jsx as i}from"react/jsx-runtime";import{Trans as e}from"@lingui/react";import{ButtonBase as r,styled as t,useThemeProps as o}from"@mui/material";import{memo as n,useCallback as a,useMemo as s,useState as l}from"react";import{useLocalizable as d}from"#package/react-sdk";import{useConfigurator as m}from"../../../application-runtime/index.js";import{parseDrawing as g}from"./parse-drawing.js";import{useDrawingUrl as c}from"./use-drawing-url.js";let u="PhxAssistantDrawing",p=t("div",{name:u,slot:"root"})(({theme:{palette:i,shape:e,spacing:r}})=>({border:`1px solid ${i.divider}`,borderRadius:e.borderRadius,boxSizing:"border-box",marginBlock:r(1),maxInlineSize:"100%",padding:r(1)})),b={id:"sdk.assistant.drawing.open.label",message:"Open the drawing"},w=t(r,{name:u,slot:"button"})(({theme:{palette:i}})=>({cursor:"zoom-in",display:"block",inlineSize:"100%","&:focus-visible":{outline:`2px solid ${i.primary.main}`,outlineOffset:2}})),h=t("img",{name:u,slot:"image"})({blockSize:"auto",display:"block",inlineSize:"100%"}),k=t("div",{name:u,slot:"note"})(({theme:{palette:i,spacing:e,typography:r}})=>({...r.caption,color:i.text.secondary,paddingBlock:e(1),paddingInline:e(.5)})),f={},x=()=>{let{slots:i={},slotProps:e={}}=o({props:f,name:u});return{Root:i.root??p,Button:i.button??w,Image:i.image??h,NoteSlot:i.note??k,slotProps:e}},v=()=>{let{Root:r,NoteSlot:t,slotProps:o}=x();return i(r,{...o.root,children:i(t,{...o.note,role:"alert",children:i(e,{id:"sdk.assistant.drawing.failure",message:"This drawing could not be shown"})})})},z=({source:e,title:r})=>{let{assistantSystem:t}=m(),o=c(e),[n,s]=l(),g=d(b),{Root:u,Button:p,Image:w,slotProps:h}=x(),k=a(()=>{t.viewImage({kind:"svg",source:e,title:r})},[t,e,r]),f=a(()=>{s(o)},[o]);return o===n?i(v,{}):i(u,{...h.root,children:i(p,{...h.button,"aria-label":void 0===r?g:void 0,onClick:k,children:i(w,{...h.image,src:o,alt:r??"",onError:f})})})},S=({source:e})=>{let r=s(()=>g(e),[e]);return r.ok?i(z,{source:e,title:r.title}):i(v,{})},j=()=>{let{Root:r,NoteSlot:t,slotProps:o}=x();return i(r,{...o.root,children:i(t,{...o.note,role:"status",children:i(e,{id:"sdk.assistant.drawing.writing",message:"Drawing…"})})})};export const AssistantDrawing=n(({source:e,status:r})=>"writing"===r?i(j,{}):i(S,{source:e}));
@@ -1,2 +1,2 @@
1
1
  export { AssistantDrawing, type ThemeableAssistantDrawingProps } from './AssistantDrawing.js';
2
- export { revokeDrawingUrlOnLoad, useDrawingUrl } from './use-drawing-url.js';
2
+ export { useDrawingUrl } from './use-drawing-url.js';
@@ -1 +1 @@
1
- export{AssistantDrawing}from"./AssistantDrawing.js";export{revokeDrawingUrlOnLoad,useDrawingUrl}from"./use-drawing-url.js";
1
+ export{AssistantDrawing}from"./AssistantDrawing.js";export{useDrawingUrl}from"./use-drawing-url.js";
@@ -1,14 +1,8 @@
1
- import { type SyntheticEvent } from 'react';
2
1
  /**
3
- * A `blob:` URL of type `image/svg+xml` for the source of a drawing, for an `<img>`, which runs no
4
- * script of it, loads nothing it points at and keeps its styles to itself. The source never becomes
5
- * part of the page. The `<img>` revokes it once loaded, with {@link revokeDrawingUrlOnLoad}; it is
6
- * also revoked when the source changes or the component unmounts. Nothing is returned until it is made.
2
+ * A `data:` URL of type `image/svg+xml` for the source of a drawing, for an `<img>`, which runs no
3
+ * script of it, loads nothing it points at and keeps its styles to itself. The source is never
4
+ * rendered as markup of the page. A `data:` URL has an opaque origin, so a drawing the user opens
5
+ * in a new tab never runs as a document of the host page's origin; unlike a revoked `blob:` URL,
6
+ * it stays valid, so the browser's own image menu can save it.
7
7
  */
8
- export declare const useDrawingUrl: (source: string) => string | undefined;
9
- /**
10
- * The `onLoad` of a drawing's `<img>`: revokes its URL once the picture is decoded, which stays
11
- * painted. A live `blob:` URL has the host page's origin, so "Open image in new tab" would load the
12
- * SVG as a document of that origin, where a script the model wrote would run.
13
- */
14
- export declare const revokeDrawingUrlOnLoad: (event: SyntheticEvent<HTMLImageElement>) => void;
8
+ export declare const useDrawingUrl: (source: string) => string;
@@ -1 +1 @@
1
- import{useEffect as e,useState as r}from"react";export const useDrawingUrl=t=>{let[o,c]=r();return e(()=>{let e=URL.createObjectURL(new Blob([t],{type:"image/svg+xml"}));return c({source:t,url:e}),()=>{URL.revokeObjectURL(e)}},[t]),o?.source===t?o.url:void 0};export const revokeDrawingUrlOnLoad=e=>{URL.revokeObjectURL(e.currentTarget.src)};
1
+ import{useMemo as e}from"react";export const useDrawingUrl=o=>e(()=>`data:image/svg+xml,${encodeURIComponent(o)}`,[o]);
@@ -2,28 +2,32 @@ import type { ReactNode } from 'react';
2
2
  import { type AssistantFormElementRegistration, type AssistantFormRole } from '#package/domain';
3
3
  import type { FormContainerProps, FormInputProps, FormOptionProps } from '../../form-elements/index.js';
4
4
  /**
5
- * What a project's generated types say of one of its assistant form elements: its role and the
6
- * attributes its component gets, typed from its declaration under `assistant.formElements`.
5
+ * What a project's generated types say of one of its assistant form elements: its role, the
6
+ * attributes its component gets and, for an input that declares it, the state it holds, typed from
7
+ * its declaration under `assistant.formElements`.
7
8
  */
8
9
  export interface AssistantFormElementType {
9
10
  readonly role: AssistantFormRole;
10
11
  readonly attributes: object;
12
+ readonly state?: unknown;
11
13
  }
12
14
  /**
13
15
  * The props of the component of a project's form element, by its role: a container's, an option's
14
- * or an input's, with the element's typed attributes. An input's `STATE` is its own and is inferred
15
- * from the component.
16
+ * or an input's, with the element's typed attributes. An input's `state` and the first argument of
17
+ * its `onChange` have the type its declared `state` gives, or `unknown` when it declares none.
16
18
  */
17
- export type AssistantFormElementRoleProps<TYPE extends AssistantFormElementType, STATE = unknown> = TYPE extends {
19
+ export type AssistantFormElementRoleProps<TYPE extends AssistantFormElementType> = TYPE extends {
18
20
  readonly role: 'option';
19
21
  } ? FormOptionProps<TYPE['attributes']> : TYPE extends {
20
22
  readonly role: 'input';
21
- } ? FormInputProps<STATE, TYPE['attributes']> : FormContainerProps<TYPE['attributes']>;
23
+ } ? FormInputProps<TYPE extends {
24
+ readonly state: infer STATE;
25
+ } ? STATE : unknown, TYPE['attributes']> : FormContainerProps<TYPE['attributes']>;
22
26
  /**
23
27
  * Registers the component of one of the project's assistant form elements, under the name its YAML
24
28
  * declares it by in `assistant.formElements`. The name picks the props the component gets.
25
29
  */
26
- export type CreateAssistantFormElement<TYPES extends object> = <NAME extends keyof TYPES & string, STATE = unknown>(name: NAME, component: (props: TYPES[NAME] extends AssistantFormElementType ? AssistantFormElementRoleProps<TYPES[NAME], STATE> : never) => ReactNode) => AssistantFormElementRegistration;
30
+ export type CreateAssistantFormElement<TYPES extends object> = <NAME extends keyof TYPES & string>(name: NAME, component: (props: TYPES[NAME] extends AssistantFormElementType ? AssistantFormElementRoleProps<TYPES[NAME]> : never) => ReactNode) => AssistantFormElementRegistration;
27
31
  /**
28
32
  * `createAssistantFormElement` typed by a project's form elements, for the generated code to put
29
33
  * on `phx.frontend`.
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Tooltip as t,styled as a,useThemeProps as i}from"@mui/material";import{useCallback as r,useState as n}from"react";import{useResourceUrl as l}from"#package/react-sdk";import{PhxIcon as d}from"#package/ui-sdk";let s="PhxAssistantFormTile",c=a("button",{name:s,slot:"root"})(({theme:{palette:e,shape:o,spacing:t}})=>({border:`1px solid ${e.divider}`,borderRadius:o.borderRadius,cursor:"pointer",font:"inherit",margin:0,position:"relative","&:focus-visible":{outline:`2px solid ${e.primary.main}`,outlineOffset:1},"&:disabled":{cursor:"default"},'&[data-look="picture"], &[data-look="text"]':{background:e.background.paper,color:e.text.primary,display:"grid",gridTemplateRows:"subgrid",padding:t(.75),rowGap:0,textAlign:"start","&:hover:not(:disabled)":{background:e.action.hover},"&:disabled":{color:e.text.disabled},'&[aria-pressed="true"]':{borderColor:e.primary.main,boxShadow:`inset 0 0 0 1px ${e.primary.main}`}},'&[data-look="picture"]':{gridRow:"span 3"},'&[data-look="text"]':{gridRow:"span 2"},'&[data-look="swatch"]':{background:e.action.hover,blockSize:36,flex:"none",inlineSize:36,overflow:"hidden",padding:0,"&:focus-visible":{outlineOffset:3},"&:disabled":{opacity:e.action.disabledOpacity},'&[aria-pressed="true"]':{boxShadow:`0 0 0 2px ${e.background.paper}, 0 0 0 4px ${e.primary.main}`}}})),p=a("img",{name:s,slot:"image"})(({theme:{shape:e,spacing:o}})=>({display:"block",inlineSize:"100%",'[data-look="picture"] > &':{aspectRatio:"4 / 3",borderRadius:e.borderRadius,gridRow:1,marginBlockEnd:o(.75),objectFit:"contain"},'[data-look="swatch"] > &':{blockSize:"100%",objectFit:"cover"}})),m=a("span",{name:s,slot:"label"})(({theme:{typography:e}})=>({...e.body2,fontWeight:e.fontWeightMedium})),u=a("span",{name:s,slot:"description"})(({theme:{palette:e,spacing:o,typography:t}})=>({...t.caption,color:e.text.secondary,marginBlockStart:o(.25)})),b=a("span",{name:s,slot:"check"})(({theme:{palette:e,spacing:o}})=>({alignItems:"center",background:e.primary.main,borderRadius:"50%",color:e.primary.contrastText,display:"flex",fontSize:14,justifyContent:"center",padding:2,position:"absolute",'[data-look="picture"] > &, [data-look="text"] > &':{insetBlockStart:o(.5),insetInlineEnd:o(.5)},'[data-look="swatch"] > &':{inset:"50% auto auto 50%",transform:"translate(-50%, -50%)"}})),k=a("span")({display:"inline-flex"}),h={};export const FormTile=({attributes:a,disabled:g,selected:x,onSelect:f})=>{let{look:y,name:w,description:v,imageUrl:R,color:S}=a,{getResourceUrl:$}=l(),z=null==R||"text"===y?void 0:$(R),[j,C]=n(),{slots:F={},slotProps:T={}}=i({props:h,name:s}),B=r(()=>{C(z)},[z]),E=F.root??c,O=F.image??p,A=F.label??m,I=F.description??u,W=F.check??b,G="swatch"===y,M=null==v?w:`${w}, ${v}`,P=o(E,{...T.root,type:"button","data-look":y,"aria-label":G?M:void 0,disabled:g,"aria-pressed":x,onClick:()=>f(w),style:G&&null!=S?{...T.root?.style,background:S}:T.root?.style,children:[null!=z&&z!==j&&e(O,{loading:"lazy",...T.image,src:z,alt:"",onError:B}),!G&&e(A,{...T.label,children:w}),!G&&null!=v&&e(I,{...T.description,children:v}),x&&e(W,{"aria-hidden":!0,...T.check,children:e(d,{name:"Check",fontSize:"inherit"})})]});return G?e(t,{title:null==v?w:`${w} \xb7 ${v}`,placement:"top",describeChild:!0,children:e(k,{children:P})}):P};
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Tooltip as t,styled as a,useThemeProps as i}from"@mui/material";import{useCallback as r,useState as n}from"react";import{useResourceUrl as l}from"#package/react-sdk";import{PhxIcon as d}from"#package/ui-sdk";let s="PhxAssistantFormTile",c=a("button",{name:s,slot:"root"})(({theme:{palette:e,shape:o,spacing:t}})=>({border:`1px solid ${e.divider}`,borderRadius:o.borderRadius,cursor:"pointer",font:"inherit",margin:0,position:"relative","&:focus-visible":{outline:`2px solid ${e.primary.main}`,outlineOffset:1},"&:disabled":{cursor:"default"},'&[data-look="picture"], &[data-look="text"]':{background:e.background.paper,color:e.text.primary,display:"grid",gridTemplateRows:"subgrid",padding:t(.75),rowGap:0,textAlign:"start","&:hover:not(:disabled)":{background:e.action.hover},"&:disabled":{color:e.text.disabled},'&[aria-pressed="true"]':{borderColor:e.primary.main,boxShadow:`inset 0 0 0 1px ${e.primary.main}`}},'&[data-look="picture"]':{gridRow:"span 3"},'&[data-look="text"]':{gridRow:"span 2"},'&[data-look="swatch"]':{background:e.action.hover,blockSize:36,flex:"none",inlineSize:36,overflow:"hidden",padding:0,"&:focus-visible":{outlineOffset:3},"&:disabled":{opacity:e.action.disabledOpacity},'&[aria-pressed="true"]':{boxShadow:`0 0 0 2px ${e.background.paper}, 0 0 0 4px ${e.primary.main}`}}})),p=a("img",{name:s,slot:"image"})(({theme:{shape:e,spacing:o}})=>({display:"block",inlineSize:"100%",'[data-look="picture"] > &':{aspectRatio:"4 / 3",borderRadius:e.borderRadius,gridRow:1,marginBlockEnd:o(.75),objectFit:"contain"},'[data-look="swatch"] > &':{blockSize:"100%",objectFit:"cover"}})),m=a("span",{name:s,slot:"label"})(({theme:{typography:e}})=>({...e.body2,fontWeight:e.fontWeightMedium,'[data-look="picture"] > &':{gridRow:2}})),u=a("span",{name:s,slot:"description"})(({theme:{palette:e,spacing:o,typography:t}})=>({...t.caption,color:e.text.secondary,marginBlockStart:o(.25),'[data-look="picture"] > &':{gridRow:3}})),b=a("span",{name:s,slot:"check"})(({theme:{palette:e,spacing:o}})=>({alignItems:"center",background:e.primary.main,borderRadius:"50%",color:e.primary.contrastText,display:"flex",fontSize:14,justifyContent:"center",padding:2,position:"absolute",'[data-look="picture"] > &, [data-look="text"] > &':{insetBlockStart:o(.5),insetInlineEnd:o(.5)},'[data-look="swatch"] > &':{inset:"50% auto auto 50%",transform:"translate(-50%, -50%)"}})),k=a("span")({display:"inline-flex"}),g={};export const FormTile=({attributes:a,disabled:h,selected:x,onSelect:f})=>{let{look:y,name:w,description:R,imageUrl:v,color:S}=a,{getResourceUrl:$}=l(),z=null==v||"text"===y?void 0:$(v),[j,C]=n(),{slots:F={},slotProps:T={}}=i({props:g,name:s}),B=r(()=>{C(z)},[z]),E=F.root??c,O=F.image??p,A=F.label??m,I=F.description??u,W=F.check??b,G="swatch"===y,M=null==R?w:`${w}, ${R}`,P=o(E,{...T.root,type:"button","data-look":y,"aria-label":G?M:void 0,disabled:h,"aria-pressed":x,onClick:()=>f(w),style:G&&null!=S?{...T.root?.style,background:S}:T.root?.style,children:[null!=z&&z!==j&&e(O,{loading:"lazy",...T.image,src:z,alt:"",onError:B}),!G&&e(A,{...T.label,children:w}),!G&&null!=R&&e(I,{...T.description,children:R}),x&&e(W,{"aria-hidden":!0,...T.check,children:e(d,{name:"Check",fontSize:"inherit"})})]});return G?e(t,{title:null==R?w:`${w} \xb7 ${R}`,placement:"top",describeChild:!0,children:e(k,{children:P})}):P};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Trans as i}from"@lingui/react";import{Button as a,Tooltip as n,keyframes as o,styled as s,useTheme as l,useThemeProps as r}from"@mui/material";import{useEffect as m,useMemo as d,useState as c}from"react";import{useEagerObservableSelector as u,useEagerObservableValue as g,useLocalizable as p,useResponsiveState as h}from"#package/react-sdk";import{MAX_COMPOSER_ATTACHMENTS as v,useConfigurator as w}from"../../../application-runtime/index.js";import{revokeDrawingUrlOnLoad as b,useDrawingUrl as f}from"../drawing/index.js";import{useOnUnmount as x}from"../use-on-unmount.js";import{useImageBlob as k}from"./use-image-blob.js";let y="PhxAssistantImageView";export const MIN_IMAGE_VIEW_SIZE=240;let I={id:"sdk.assistant.image.view.drawing",message:"Drawing"},$={id:"sdk.assistant.image.view.image",message:"Image"},j={id:"sdk.assistant.composer.attachment.limit",message:"You can attach up to {max} images."},S=o({from:{opacity:0}}),B=s("div")(({theme:{zIndex:e}})=>({inset:0,pointerEvents:"none",position:"absolute",zIndex:e.modal+1})),E=s("div",{name:y,slot:"root"})(({theme:{palette:e,shadows:t,shape:i,spacing:a}})=>({animation:`${S} 200ms ease`,background:e.background.paper,borderRadius:i.borderRadius,boxShadow:t[8],display:"flex",flexDirection:"column",gap:a(1),margin:a(2),padding:a(1.5),pointerEvents:"auto",position:"absolute","@media (prefers-reduced-motion: reduce)":{animation:"none"}})),z=s("div",{name:y,slot:"header"})(({theme:{spacing:e}})=>({alignItems:"center",display:"flex",gap:e(1),justifyContent:"space-between"})),V=s("h2",{name:y,slot:"title"})(({theme:{typography:e}})=>({...e.subtitle2,margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),C=s("div",{name:y,slot:"actions"})(({theme:{spacing:e}})=>({display:"flex",flexShrink:0,gap:e(.5),marginInlineStart:"auto"})),L=s(a,{name:y,slot:"annotateButton"})({}),R=s(a,{name:y,slot:"closeButton"})({}),A=s("img",{name:y,slot:"image"})({blockSize:"100%",display:"block",flex:1,inlineSize:"100%",minBlockSize:0,objectFit:"contain"}),O={},_=({view:a,close:o,label:s,src:d,onLoad:b,image:f})=>{var k;let{title:I}=a,{assistantSystem:$}=w(),{canvasPadding:S,sceneSafeArea:_}=h(),[D,F]=c(null),[M,P]=c(),G=p(s),{slots:N={},slotProps:T={}}=r({props:O,name:y}),W=p({...j,values:{max:v}}),Y=g($.hasFreeAttachmentSlot$),Z=null!==g($.annotationOverlay$),q=u($.chat$,e=>e.isLocked,[]),H=Y&&!Z&&!q&&null!=f,{palette:J}=l();x(()=>{$.imageView$.value===a&&o()}),m(()=>{if(null===D)return;let e=new ResizeObserver(([e])=>{void 0!==e&&P({width:e.contentRect.width,height:e.contentRect.height})});return e.observe(D),()=>e.disconnect()},[D]),m(()=>{let e=e=>{"Escape"!==e.key||e.isComposing||e.defaultPrevented||null!==$.annotationOverlay$.value||o()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[$,o]);let K=N.root??E,Q=N.header??z,U=N.title??V,X=N.actions??C,ee=N.annotateButton??L,et=N.closeButton??R,ei=N.image??A;return e(B,{ref:F,children:t(K,{...T.root,role:"dialog","aria-label":I??G,style:{...T.root?.style,inset:(k=_??S,void 0!==M&&M.width-k.left-k.right>=240&&M.height-k.top-k.bottom>=240?`${k.top}px ${k.right}px ${k.bottom}px ${k.left}px`:0)},children:[t(Q,{...T.header,children:[void 0!==I&&e(U,{...T.title,children:I}),t(X,{...T.actions,children:[null!==f&&e(n,{title:Y?"":W,children:e("span",{children:e(ee,{size:"small",...T.annotateButton,disabled:!H,onClick:()=>{null!=f&&(o(),$.annotate({type:"image",image:f,background:J.background.default}))},children:e(i,{id:"sdk.assistant.image.view.annotate",message:"Annotate"})})})}),e(et,{size:"small",...T.closeButton,onClick:o,children:e(i,{id:"sdk.assistant.image.view.close",message:"Close"})})]})]}),void 0!==d&&e(ei,{...T.image,src:d,alt:I??"",onLoad:b})]})})},D=({view:t,close:i})=>{let{source:a}=t;return e(_,{view:t,close:i,label:I,src:f(a),onLoad:b,image:d(()=>new Blob([a],{type:"image/svg+xml"}),[a])})},F=({view:t,close:i})=>e(_,{view:t,close:i,label:$,src:t.url,image:k(t.url)});export const ImageView=()=>{let{assistantSystem:t}=w(),i=g(t.imageView$),a=t.closeImageView;return null===i?null:"svg"===i.kind?e(D,{view:i,close:a}):e(F,{view:i,close:a})};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Trans as i}from"@lingui/react";import{Button as a,Tooltip as n,keyframes as o,styled as s,useTheme as l,useThemeProps as r}from"@mui/material";import{useEffect as m,useMemo as d,useState as c}from"react";import{useApplicationRuntimeSelector as u,useEagerObservableSelector as g,useEagerObservableValue as p,useLocalizable as h,useResponsiveState as v}from"#package/react-sdk";import{MAX_COMPOSER_ATTACHMENTS as w,useConfigurator as f}from"../../../application-runtime/index.js";import{useDrawingUrl as b}from"../drawing/index.js";import{useOnUnmount as x}from"../use-on-unmount.js";import{useImageBlob as k}from"./use-image-blob.js";let y="PhxAssistantImageView";export const MIN_IMAGE_VIEW_SIZE=240;let I={id:"sdk.assistant.image.view.drawing",message:"Drawing"},$={id:"sdk.assistant.image.view.image",message:"Image"},S={id:"sdk.assistant.composer.attachment.limit",message:"You can attach up to {max} images."},j=o({from:{opacity:0}}),B=s("div")(({theme:{zIndex:e}})=>({inset:0,pointerEvents:"none",position:"absolute",zIndex:e.modal+1})),E=s("div",{name:y,slot:"root"})(({theme:{palette:e,shadows:t,shape:i,spacing:a}})=>({animation:`${j} 200ms ease`,background:e.background.paper,borderRadius:i.borderRadius,boxShadow:t[8],display:"flex",flexDirection:"column",gap:a(1),margin:a(2),padding:a(1.5),pointerEvents:"auto",position:"absolute","@media (prefers-reduced-motion: reduce)":{animation:"none"}})),z=s("div",{name:y,slot:"header"})(({theme:{spacing:e}})=>({alignItems:"center",display:"flex",gap:e(1),justifyContent:"space-between"})),V=s("h2",{name:y,slot:"title"})(({theme:{typography:e}})=>({...e.subtitle2,margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),C=s("div",{name:y,slot:"actions"})(({theme:{spacing:e}})=>({display:"flex",flexShrink:0,gap:e(.5),marginInlineStart:"auto"})),R=s(a,{name:y,slot:"annotateButton"})({}),A=s(a,{name:y,slot:"closeButton"})({}),O=s("img",{name:y,slot:"image"})({blockSize:"100%",display:"block",flex:1,inlineSize:"100%",minBlockSize:0,objectFit:"contain"}),L={},M=({view:a,close:o,label:s,src:d,image:b})=>{var k;let{title:I}=a,{assistantSystem:$}=f(),{canvasPadding:j,sceneSafeArea:M}=v(),[_,D]=c(null),[F,P]=c(),G=h(s),{slots:N={},slotProps:T={}}=r({props:L,name:y}),W=h({...S,values:{max:w}}),Y=p($.hasFreeAttachmentSlot$),Z=null!==p($.annotationOverlay$),q=g($.chat$,e=>e.isLocked,[]),H=u(()=>$.getSessionManifest()?.features.annotations===!0),J=H&&Y&&!Z&&!q&&null!=b,{palette:K}=l();x(()=>{$.imageView$.value===a&&o()}),m(()=>{if(null===_)return;let e=new ResizeObserver(([e])=>{void 0!==e&&P({width:e.contentRect.width,height:e.contentRect.height})});return e.observe(_),()=>e.disconnect()},[_]),m(()=>{let e=e=>{"Escape"!==e.key||e.isComposing||e.defaultPrevented||null!==$.annotationOverlay$.value||o()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[$,o]);let Q=N.root??E,U=N.header??z,X=N.title??V,ee=N.actions??C,et=N.annotateButton??R,ei=N.closeButton??A,ea=N.image??O;return e(B,{ref:D,children:t(Q,{...T.root,role:"dialog","aria-label":I??G,style:{...T.root?.style,inset:(k=M??j,void 0!==F&&F.width-k.left-k.right>=240&&F.height-k.top-k.bottom>=240?`${k.top}px ${k.right}px ${k.bottom}px ${k.left}px`:0)},children:[t(U,{...T.header,children:[void 0!==I&&e(X,{...T.title,children:I}),t(ee,{...T.actions,children:[null!==b&&H&&e(n,{title:Y?"":W,children:e("span",{children:e(et,{size:"small",...T.annotateButton,disabled:!J,onClick:()=>{null!=b&&(o(),$.annotate({type:"image",image:b,background:K.background.default}))},children:e(i,{id:"sdk.assistant.image.view.annotate",message:"Annotate"})})})}),e(ei,{size:"small",...T.closeButton,onClick:o,children:e(i,{id:"sdk.assistant.image.view.close",message:"Close"})})]})]}),e(ea,{...T.image,src:d,alt:I??""})]})})},_=({view:t,close:i})=>{let{source:a}=t;return e(M,{view:t,close:i,label:I,src:b(a),image:d(()=>new Blob([a],{type:"image/svg+xml"}),[a])})},D=({view:t,close:i})=>e(M,{view:t,close:i,label:$,src:t.url,image:k(t.url)});export const ImageView=()=>{let{assistantSystem:t}=f(),i=p(t.imageView$),a=t.closeImageView;return null===i?null:"svg"===i.kind?e(_,{view:i,close:a}):e(D,{view:i,close:a})};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{IconButton as a,Tooltip as s,Typography as n,styled as i,useThemeProps as l}from"@mui/material";import{useCallback as o}from"react";import{useEagerObservableValue as r,useLocalizable as m}from"#package/react-sdk";import{PhxIcon as p}from"#package/ui-sdk";import{useConfigurator as d}from"../../../application-runtime/index.js";let u="PhxAssistantPanelHeader",c={id:"sdk.assistant.panel.title",message:"Assistant"},k={id:"sdk.assistant.panel.close.label",message:"Close assistant"},h={id:"sdk.assistant.panel.mute.label",message:"Mute spoken replies"},g={id:"sdk.assistant.panel.unmute.label",message:"Unmute spoken replies"},B={Root:i("header",{name:u,slot:"root"})(({theme:{palette:e,spacing:t}})=>({alignItems:"center",borderBlockEnd:`1px solid ${e.divider}`,display:"flex",gap:t(1),justifyContent:"space-between",paddingBlock:t(1),paddingInline:`var(--phx-sidebar-padding, ${t(2)}) ${t(1)}`})),Title:i(n,{name:u,slot:"title"})({fontWeight:600,marginInlineEnd:"auto"}),MuteButton:i(a,{name:u,slot:"muteButton"})({}),CloseButton:i(a,{name:u,slot:"closeButton"})({})};export const AssistantPanelHeader=a=>{let{slots:n={},slotProps:i={}}=l({props:a,name:u}),{assistantSystem:b}=d(),f=m(c),x=m(k),{isVoiceEnabled:C}=r(b.chat$),j=r(b.muted$),$=m(j?g:h),M=o(()=>{b.setOpen(!1)},[b]),v=o(()=>{b.setMuted(!j)},[b,j]),A=n.root??B.Root,H=n.title??B.Title,I=n.muteButton??B.MuteButton,P=n.closeButton??B.CloseButton;return t(A,{...i.root,children:[e(H,{variant:"subtitle1",component:"h2",...i.title,children:f}),C&&e(s,{title:$,placement:"top",children:e(I,{size:"small","aria-label":$,...i.muteButton,onClick:v,children:e(p,{name:j?"SpeakerSlash":"SpeakerHigh"})})}),e(s,{title:x,placement:"top",children:e(P,{size:"small","aria-label":x,...i.closeButton,onClick:M,children:e(p,{name:"X"})})})]})};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{IconButton as a,Tooltip as s,Typography as n,styled as i,useThemeProps as l}from"@mui/material";import{useCallback as o}from"react";import{useEagerObservableValue as r,useLocalizable as m}from"#package/react-sdk";import{PhxIcon as p}from"#package/ui-sdk";import{useConfigurator as d}from"../../../application-runtime/index.js";let u="PhxAssistantPanelHeader",c={id:"sdk.assistant.panel.title",message:"AI assistant"},k={id:"sdk.assistant.panel.close.label",message:"Close assistant"},h={id:"sdk.assistant.panel.mute.label",message:"Mute spoken replies"},g={id:"sdk.assistant.panel.unmute.label",message:"Unmute spoken replies"},B={Root:i("header",{name:u,slot:"root"})(({theme:{palette:e,spacing:t}})=>({alignItems:"center",borderBlockEnd:`1px solid ${e.divider}`,display:"flex",gap:t(1),justifyContent:"space-between",paddingBlock:t(1),paddingInline:`var(--phx-sidebar-padding, ${t(2)}) ${t(1)}`})),Title:i(n,{name:u,slot:"title"})({fontWeight:600,marginInlineEnd:"auto"}),MuteButton:i(a,{name:u,slot:"muteButton"})({}),CloseButton:i(a,{name:u,slot:"closeButton"})({})};export const AssistantPanelHeader=a=>{let{slots:n={},slotProps:i={}}=l({props:a,name:u}),{assistantSystem:b}=d(),f=m(c),x=m(k),{isVoiceEnabled:C}=r(b.chat$),j=r(b.muted$),$=m(j?g:h),I=o(()=>{b.setOpen(!1)},[b]),M=o(()=>{b.setMuted(!j)},[b,j]),v=n.root??B.Root,A=n.title??B.Title,H=n.muteButton??B.MuteButton,P=n.closeButton??B.CloseButton;return t(v,{...i.root,children:[e(A,{variant:"subtitle1",component:"h2",...i.title,children:f}),C&&e(s,{title:$,placement:"top",children:e(H,{size:"small","aria-label":$,...i.muteButton,onClick:M,children:e(p,{name:j?"SpeakerSlash":"SpeakerHigh"})})}),e(s,{title:x,placement:"top",children:e(P,{size:"small","aria-label":x,...i.closeButton,onClick:I,children:e(p,{name:"X"})})})]})};
@@ -36,6 +36,9 @@ export type AssistantComposerNotice = 'unreadable' | 'limit';
36
36
  * - `canSend` and `send()`: whether the message can be sent, and sending it. The message is cleared once the chat
37
37
  * takes it, and comes back, after what was written meanwhile, when the chat gives it back.
38
38
  * - `inputFocusHandlers`: `onFocus` and `onBlur` for the message input, so a phone layout makes room for it.
39
+ * - `canAttach` and `canAnnotate`: whether the session's `assistant.features` let the user attach images and
40
+ * annotate; `addFiles`, `annotate()` and `annotateAttachment(id)` do nothing without them. Annotating an attached
41
+ * image needs both.
39
42
  * - `canRecord`: whether the user may speak the message: the session has voice messages on, the browser can record,
40
43
  * and the assistant takes messages here. A composer shows a mic in place of Send while the text is empty and nothing
41
44
  * is attached then.
@@ -68,6 +71,8 @@ export interface UseAssistantComposerResult {
68
71
  readonly onFocus: () => void;
69
72
  readonly onBlur: () => void;
70
73
  };
74
+ readonly canAttach: boolean;
75
+ readonly canAnnotate: boolean;
71
76
  readonly canRecord: boolean;
72
77
  readonly recording: AssistantRecording;
73
78
  readonly startRecording: () => Promise<void>;
@@ -1,2 +1,2 @@
1
- import{useTheme as t}from"@mui/material";import{useCallback as e,useEffect as n,useMemo as r,useReducer as a,useRef as i,useState as o}from"react";import{skip as c}from"rxjs/operators";import{useEagerObservableSelector as s,useEagerObservableValue as l}from"#package/react-sdk";import{MAX_COMPOSER_ATTACHMENTS as m,useConfigurator as u}from"../../application-runtime/index.js";import{prepareImage as p}from"./attachments/index.js";import{useVoiceRecording as h}from"./voice/index.js";export const useAssistantComposer=()=>{let{assistantSystem:d}=u(),[f,y]=o(""),v=l(d.composerAttachments$),[b,g]=o(0),[k,A]=o(),[w,L]=o(!1),R=i(new Map),[U,j]=a(t=>t+1,0),x=i(v);x.current=v,n(()=>{let t=R.current;for(let[e,n]of t)v.some(t=>t.id===e)||(URL.revokeObjectURL(n),t.delete(e))},[v]),n(()=>{let t=R.current;return 0===t.size&&x.current.length>0&&j(),()=>{for(let e of t.values())URL.revokeObjectURL(e);t.clear()}},[]);let $=i(!1),P=e(t=>{$.current=!0;try{return t()}finally{$.current=!1}},[]);n(()=>{let t=d.composerAttachments$.pipe(c(1)).subscribe(()=>{$.current||A(void 0)});return()=>t.unsubscribe()},[d]);let{isReplying:F,isResuming:S,isLocked:C,isVoiceEnabled:E}=s(d.chat$,t=>({isReplying:t.isLoading,isResuming:t.isResuming,isLocked:t.isLocked,isVoiceEnabled:t.isVoiceEnabled}),[]),I=f.trim(),O=S||w,V=!F&&!O&&!C&&0===b&&(I.length>0||v.length>0),z=e(async t=>{if(0===t.length)return;let e=[];for(let n of t){let t=d.reserveAttachmentSlot();if(!t)break;e.push(t)}let n=t.slice(0,e.length);A(n.length<t.length?"limit":void 0),0!==n.length&&(g(t=>t+n.length),await Promise.all(n.map(async(t,n)=>{let r;try{r=await p(t)}catch{A("unreadable")}finally{g(t=>t-1)}if(e[n]?.()&&r){let t=r;P(()=>d.attach(t))}})))},[d,P]),B=e(async()=>{d.hasFreeAttachmentSlot$.value?(A(void 0),await d.annotate({type:"view"})):A("limit")},[d]),{palette:M}=t(),q=M.background.default,D=e(async t=>{A(void 0),await d.annotate({type:"attachment",attachmentId:t,background:q})},[d,q]),G=e(t=>{d.removeAttachment(t),A(void 0)},[d]),H=i(!0);n(()=>(H.current=!0,()=>{H.current=!1}),[]);let J=e(t=>{P(()=>t.forEach(({id:t})=>d.removeAttachment(t))),A(void 0),L(!1)},[d,P]),K=e(t=>{A(P(()=>d.restoreAttachments(t))?void 0:"limit")},[d,P]),N=e(async()=>{if(V){L(!0);try{await d.send(I,v,{onSent:()=>{y(""),J(v)},onUnsent:()=>{y(t=>t.trim()?`${t}
2
- ${f}`:f),K(v)}})}finally{L(!1)}}},[d,v,V,I,f,K,J]),Q=i(async()=>{}),T=h({onLimitReached:()=>void Q.current()}),{recording:W,finish:X,clear:Y,restore:Z}=T,{start:_,cancel:tt}=T,te=E&&"unavailable"!==W.status&&!C,tn=e(async()=>{if(!te||F||O)return;d.unlockPlayback();let t=await X();if(t&&!(b>0)){L(!0);try{await d.send("",v,{audio:t,onSent:()=>{Y(),J(v)},onUnsent:()=>{K(v),H.current&&Z(t)}})}finally{L(!1)}}},[d,v,te,Y,X,O,F,b,K,Z,J]);Q.current=tn;let tr=e(async()=>{!te||F||O||(d.stopPlayback(),d.unlockPlayback(),await _())},[d,te,O,F,_]),ta=e(()=>{d.stop()},[d]),ti=r(()=>({onFocus:()=>d.setInputFocused(!0),onBlur:()=>d.setInputFocused(!1)}),[d]);return{draft:f,setDraft:y,attachments:r(()=>v.map(t=>{let{id:e}=t,n=R.current.get(e);return void 0===n&&(n=URL.createObjectURL(t.blob),R.current.set(e,n)),"annotation"===t.type?{id:e,previewUrl:n,isAnnotation:!0,pinCount:t.pins.length}:{id:e,previewUrl:n,isAnnotation:!1,pinCount:0}}),[v,U]),addFiles:z,annotate:B,annotateAttachment:D,removeAttachment:G,isPreparing:b>0,notice:k,maxAttachments:m,isBusy:O,isLocked:C,isReplying:F,canSend:V,send:N,stop:ta,inputFocusHandlers:ti,canRecord:te,recording:W,startRecording:tr,sendRecording:tn,cancelRecording:tt}};
1
+ import{useTheme as t}from"@mui/material";import{useCallback as e,useEffect as n,useMemo as a,useReducer as r,useRef as i,useState as o}from"react";import{skip as s}from"rxjs/operators";import{useApplicationRuntimeSelector as c,useEagerObservableSelector as l,useEagerObservableValue as u}from"#package/react-sdk";import{MAX_COMPOSER_ATTACHMENTS as m,useConfigurator as p}from"../../application-runtime/index.js";import{prepareImage as f}from"./attachments/index.js";import{useVoiceRecording as d}from"./voice/index.js";export const useAssistantComposer=()=>{let{assistantSystem:h}=p(),[y,g]=o(""),v=u(h.composerAttachments$),[b,k]=o(0),[A,w]=o(),[L,R]=o(!1),U=i(new Map),[j,x]=r(t=>t+1,0),S=i(v);S.current=v,n(()=>{let t=U.current;for(let[e,n]of t)v.some(t=>t.id===e)||(URL.revokeObjectURL(n),t.delete(e))},[v]),n(()=>{let t=U.current;return 0===t.size&&S.current.length>0&&x(),()=>{for(let e of t.values())URL.revokeObjectURL(e);t.clear()}},[]);let $=i(!1),P=e(t=>{$.current=!0;try{return t()}finally{$.current=!1}},[]);n(()=>{let t=h.composerAttachments$.pipe(s(1)).subscribe(()=>{$.current||w(void 0)});return()=>t.unsubscribe()},[h]);let{isReplying:F,isResuming:C,isLocked:E,isVoiceEnabled:I}=l(h.chat$,t=>({isReplying:t.isLoading,isResuming:t.isResuming,isLocked:t.isLocked,isVoiceEnabled:t.isVoiceEnabled}),[]),M=y.trim(),O=C||L,V=!F&&!O&&!E&&0===b&&(M.length>0||v.length>0),z=c(()=>h.getSessionManifest()?.features.images===!0),B=c(()=>h.getSessionManifest()?.features.annotations===!0),q=e(async t=>{if(!z||0===t.length)return;let e=[];for(let n of t){let t=h.reserveAttachmentSlot();if(!t)break;e.push(t)}let n=t.slice(0,e.length);w(n.length<t.length?"limit":void 0),0!==n.length&&(k(t=>t+n.length),await Promise.all(n.map(async(t,n)=>{let a;try{a=await f(t)}catch{w("unreadable")}finally{k(t=>t-1)}if(e[n]?.()&&a){let t=a;P(()=>h.attach(t))}})))},[h,z,P]),D=e(async()=>{if(B){if(!h.hasFreeAttachmentSlot$.value)return void w("limit");w(void 0),await h.annotate({type:"view"})}},[h,B]),{palette:G}=t(),H=G.background.default,J=e(async t=>{z&&B&&(w(void 0),await h.annotate({type:"attachment",attachmentId:t,background:H}))},[h,H,B,z]),K=e(t=>{h.removeAttachment(t),w(void 0)},[h]),N=i(!0);n(()=>(N.current=!0,()=>{N.current=!1}),[]);let Q=e(t=>{P(()=>t.forEach(({id:t})=>h.removeAttachment(t))),w(void 0),R(!1)},[h,P]),T=e(t=>{w(P(()=>h.restoreAttachments(t))?void 0:"limit")},[h,P]),W=e(async()=>{if(V){R(!0);try{await h.send(M,v,{onSent:()=>{g(""),Q(v)},onUnsent:()=>{g(t=>t.trim()?`${t}
2
+ ${y}`:y),T(v)}})}finally{R(!1)}}},[h,v,V,M,y,T,Q]),X=i(async()=>{}),Y=d({onLimitReached:()=>void X.current()}),{recording:Z,finish:_,clear:tt,restore:te}=Y,{start:tn,cancel:ta}=Y,tr=I&&"unavailable"!==Z.status&&!E,ti=e(async()=>{if(!tr||F||O)return;h.unlockPlayback();let t=await _();if(t&&!(b>0)){R(!0);try{await h.send("",v,{audio:t,onSent:()=>{tt(),Q(v)},onUnsent:()=>{T(v),N.current&&te(t)}})}finally{R(!1)}}},[h,v,tr,tt,_,O,F,b,T,te,Q]);X.current=ti;let to=e(async()=>{!tr||F||O||(h.stopPlayback(),h.unlockPlayback(),await tn())},[h,tr,O,F,tn]),ts=e(()=>{h.stop()},[h]),tc=a(()=>({onFocus:()=>h.setInputFocused(!0),onBlur:()=>h.setInputFocused(!1)}),[h]);return{draft:y,setDraft:g,attachments:a(()=>v.map(t=>{let{id:e}=t,n=U.current.get(e);return void 0===n&&(n=URL.createObjectURL(t.blob),U.current.set(e,n)),"annotation"===t.type?{id:e,previewUrl:n,isAnnotation:!0,pinCount:t.pins.length}:{id:e,previewUrl:n,isAnnotation:!1,pinCount:0}}),[v,j]),addFiles:q,annotate:D,annotateAttachment:J,removeAttachment:K,isPreparing:b>0,notice:A,maxAttachments:m,isBusy:O,isLocked:E,isReplying:F,canSend:V,send:W,stop:ts,inputFocusHandlers:tc,canAttach:z,canAnnotate:B,canRecord:tr,recording:Z,startRecording:to,sendRecording:ti,cancelRecording:ta}};
@@ -1,2 +1,2 @@
1
- export * from './slots/index.js';
1
+ export { LayoutSlots } from './slots/index.js';
2
2
  export * from './universal/index.js';
@@ -1 +1 @@
1
- export*from"./slots/index.js";export*from"./universal/index.js";
1
+ export{LayoutSlots}from"./slots/index.js";export*from"./universal/index.js";