@nocobase/portal-template-default 1.0.9 → 1.0.11

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 (338) hide show
  1. package/.env.example +5 -0
  2. package/.github/workflows/publish.yml +106 -0
  3. package/.gitignore +33 -0
  4. package/AGENTS.md +19 -0
  5. package/README.MD +61 -180
  6. package/dist/assets/{LineDraw-C0m1GONT.js → LineDraw-iG-ADes-.js} +1 -1
  7. package/dist/assets/{SymbolDraw-CCospe5G.js → SymbolDraw-DXoSw1tM.js} +1 -1
  8. package/dist/assets/VisualMapping-C_ee4Eht.js +1 -0
  9. package/dist/assets/auth-method-demo-DaOCuvsq.js +1 -0
  10. package/dist/assets/auto-login-provider-5Uxza9Ms.js +2 -0
  11. package/dist/assets/auto-login-provider-DyaPGK2D.js +1 -0
  12. package/dist/assets/auto-redirect-provider-CfwRvYOI.js +1 -0
  13. package/dist/assets/auto-redirect-provider-Cr3jmYts.js +1 -0
  14. package/dist/assets/auto-redirect-provider-QkJQRBbG.js +1 -0
  15. package/dist/assets/calendar-DjDRfD5t.js +1 -0
  16. package/dist/assets/card-DuQBOS6A.js +1 -0
  17. package/dist/assets/cas-sign-in-button-CyqG1QME.js +1 -0
  18. package/dist/assets/components-D-ptYjX_.js +20 -0
  19. package/dist/assets/configuration-gate-C08mkkiX.js +1 -0
  20. package/dist/assets/{createClipPathFromCoordSys-uEftn1Mq.js → createClipPathFromCoordSys-wj34-b1B.js} +1 -1
  21. package/dist/assets/createSeriesDataSimply-D0A6SAVQ.js +1 -0
  22. package/dist/assets/customGraphicKeyframeAnimation-DWrhrHL_.js +3 -0
  23. package/dist/assets/demo-BYWHeKUe.js +1 -0
  24. package/dist/assets/demo-CPWoNtx8.js +1 -0
  25. package/dist/assets/demo-CyvJk5zV.js +1 -0
  26. package/dist/assets/demo-D4OiKplc.js +1 -0
  27. package/dist/assets/demo-DBueJg0m.js +1 -0
  28. package/dist/assets/demo-DkIhyiRK.js +1 -0
  29. package/dist/assets/demo-tpTjO0sC.js +1 -0
  30. package/dist/assets/dingtalk-sign-in-button-DSWsSruv.js +1 -0
  31. package/dist/assets/echarts-preview-DxHNfq1C.js +1 -0
  32. package/dist/assets/{echarts-runtime-CEgJbv68.js → echarts-runtime-D8kXn6ME.js} +3 -3
  33. package/dist/assets/{echarts-runtime-advanced-Buhm2BHz.js → echarts-runtime-advanced-QY8v95qK.js} +1 -1
  34. package/dist/assets/{echarts-runtime-common-DLAdBAIa.js → echarts-runtime-common-D-yqAK-r.js} +1 -1
  35. package/dist/assets/{echarts-runtime-components-ypnyLkYx.js → echarts-runtime-components-P4-i8jPU.js} +1 -1
  36. package/dist/assets/{echarts-runtime-hierarchy-ClStquCF.js → echarts-runtime-hierarchy-ByQZ-DbP.js} +1 -1
  37. package/dist/assets/floating-BFVEyPEp.js +15 -0
  38. package/dist/assets/index-BgCbGDMc.js +43 -0
  39. package/dist/assets/index-Btk35Nx-.js +23 -0
  40. package/dist/assets/index-CwNxd66J.js +1 -0
  41. package/dist/assets/index-MB-jfQld.js +686 -0
  42. package/dist/assets/index-NH3aqqQz.css +1 -0
  43. package/dist/assets/index-gFtCXH3o.js +58 -0
  44. package/dist/assets/index-um5hdKdZ.js +23 -0
  45. package/dist/assets/{labelHelper-C137W5gU.js → labelHelper-DQqRy3a_.js} +1 -1
  46. package/dist/assets/ldap-sign-in-form--6Gt3yGq.js +1 -0
  47. package/dist/assets/oidc-sign-in-button-CQdRcR_p.js +1 -0
  48. package/dist/assets/{page-context-Cxx11gzg.js → page-context-CnQ4GYM7.js} +10 -10
  49. package/dist/assets/prompt-card-B2RS4nt2.js +1 -0
  50. package/dist/assets/prompt-output-DZHRM2ft.js +1 -0
  51. package/dist/assets/saml-sign-in-button-BHL5a0JV.js +1 -0
  52. package/dist/assets/{sectorHelper-Fqgz3uEk.js → sectorHelper-DN_Vv6OL.js} +1 -1
  53. package/dist/assets/shortcut-C5x5LQWU.js +47 -0
  54. package/dist/assets/sms-sign-in-form-DTX9GV2I.js +1 -0
  55. package/dist/assets/{static.browser-CfQQzERe.js → static.browser-jI1psK0d.js} +8 -8
  56. package/dist/assets/{switch-DrxImI8F.js → switch-CRL8PmRI.js} +1 -1
  57. package/dist/assets/{tool-cards-BGfsY8JF.js → tool-cards-DFttLAfo.js} +6 -7
  58. package/dist/assets/use-authenticator-sign-in-CRGjzXju.js +1 -0
  59. package/dist/assets/use-dingtalk-sign-in-8WYzJ2jf.js +1 -0
  60. package/dist/assets/use-wecom-sign-in-C9j8wfCD.js +1 -0
  61. package/dist/assets/wecom-sign-in-button-mIS1zGSU.js +1 -0
  62. package/dist/index.html +2 -2
  63. package/dist/index.raw.html +5 -2
  64. package/package.json +3 -5
  65. package/scripts/build-html.mjs +12 -0
  66. package/src/App.css +2 -0
  67. package/src/App.tsx +35 -186
  68. package/src/app/development.tsx +154 -0
  69. package/src/app/extension.ts +5 -0
  70. package/src/app/extensions.tsx +18 -4
  71. package/src/app/routes.tsx +65 -0
  72. package/src/components/access-control/acl-bootstrap.tsx +11 -3
  73. package/src/components/access-control/acl-gate.tsx +7 -6
  74. package/src/components/access-control/can-access.tsx +17 -0
  75. package/src/components/access-control/navigate-to-accessible-resource.tsx +8 -3
  76. package/src/components/app-shell/sidebar.tsx +21 -5
  77. package/src/components/auth/auto-redirect-provider.tsx +2 -1
  78. package/src/extensions/nocobase-acl/README.md +74 -0
  79. package/{registry → src/extensions}/nocobase-acl/components/acl-boundary.tsx +22 -25
  80. package/{registry → src/extensions}/nocobase-acl/components/role-switcher.tsx +26 -23
  81. package/src/extensions/nocobase-acl/demo/acl-preview-provider.tsx +81 -0
  82. package/{registry → src/extensions}/nocobase-acl/demo/boundary-api.tsx +58 -0
  83. package/{registry → src/extensions}/nocobase-acl/demo/index.tsx +243 -105
  84. package/{registry → src/extensions}/nocobase-acl/demo/prompt-generator.tsx +3 -1
  85. package/src/extensions/nocobase-acl/extension.tsx +73 -0
  86. package/{registry → src/extensions}/nocobase-ai/README.md +21 -5
  87. package/{registry → src/extensions}/nocobase-ai/components/chat/chat-composer.tsx +3 -1
  88. package/{registry → src/extensions}/nocobase-ai/components/chat/chat-messages.tsx +38 -3
  89. package/{registry → src/extensions}/nocobase-ai/components/chat/tool-call-card.tsx +1 -9
  90. package/{registry → src/extensions}/nocobase-ai/components/index.ts +5 -0
  91. package/src/extensions/nocobase-ai/components/surfaces/chat-dialog.tsx +17 -0
  92. package/src/extensions/nocobase-ai/components/surfaces/chat-side-panel.tsx +35 -0
  93. package/src/extensions/nocobase-ai/components/surfaces/chat-surface.tsx +108 -0
  94. package/{registry → src/extensions}/nocobase-ai/components/triggers/ai-chat-floating-trigger.tsx +2 -2
  95. package/{registry → src/extensions}/nocobase-ai/demo/configuration-gate.tsx +4 -1
  96. package/{registry → src/extensions}/nocobase-ai/demo/container-showcase.tsx +2 -2
  97. package/{registry → src/extensions}/nocobase-ai/demo/floating.tsx +45 -15
  98. package/{registry → src/extensions}/nocobase-ai/demo/index.tsx +116 -74
  99. package/{registry → src/extensions}/nocobase-ai/demo/prompt-generator.tsx +3 -3
  100. package/{registry → src/extensions}/nocobase-ai/demo/tool-cards.tsx +2 -3
  101. package/src/extensions/nocobase-ai/extension.tsx +160 -0
  102. package/{registry → src/extensions}/nocobase-ai/global-ai-chat.tsx +12 -28
  103. package/{registry → src/extensions}/nocobase-ai/providers/ai-provider.tsx +14 -1
  104. package/{registry → src/extensions}/nocobase-ai/providers/chat-context.tsx +1 -0
  105. package/{registry → src/extensions}/nocobase-ai/providers/chat-provider.tsx +29 -8
  106. package/{registry → src/extensions}/nocobase-ai/providers/use-chat-attachments.ts +6 -1
  107. package/{registry → src/extensions}/nocobase-ai/providers/use-chat-work-context.ts +4 -1
  108. package/{registry → src/extensions}/nocobase-route-surfaces/README.md +2 -1
  109. package/{registry → src/extensions}/nocobase-route-surfaces/demo/index.tsx +33 -7
  110. package/{registry → src/extensions}/nocobase-route-surfaces/demo/scenarios.ts +20 -14
  111. package/{registry → src/extensions}/nocobase-route-surfaces/extension.tsx +55 -52
  112. package/src/{pages/users → extensions/nocobase-users-example}/create.tsx +4 -4
  113. package/src/{pages/users → extensions/nocobase-users-example}/edit.tsx +5 -9
  114. package/src/extensions/nocobase-users-example/extension.tsx +109 -0
  115. package/src/{pages/users → extensions/nocobase-users-example}/form-context.ts +11 -9
  116. package/src/extensions/nocobase-users-example/layout.tsx +16 -0
  117. package/src/{pages/users → extensions/nocobase-users-example}/list.tsx +1 -1
  118. package/src/extensions/nocobase-users-example/locales/en-US.ts +77 -0
  119. package/src/extensions/nocobase-users-example/locales/index.ts +8 -0
  120. package/src/extensions/nocobase-users-example/locales/zh-CN.ts +73 -0
  121. package/src/extensions/nocobase-users-example/optional-ai.ts +67 -0
  122. package/src/{pages/users → extensions/nocobase-users-example}/role-detail.tsx +4 -15
  123. package/src/{pages/users → extensions/nocobase-users-example}/routes.ts +1 -4
  124. package/src/extensions/nocobase-users-example/show.tsx +266 -0
  125. package/src/lib/nocobase/acl/context.ts +32 -0
  126. package/src/lib/nocobase/acl/evaluator.ts +186 -0
  127. package/src/lib/nocobase/acl/hooks.ts +40 -0
  128. package/src/lib/nocobase/acl/index.ts +4 -1
  129. package/src/lib/nocobase/acl/menu.ts +6 -6
  130. package/src/lib/nocobase/acl/record-permissions.ts +37 -7
  131. package/src/lib/nocobase/acl/store-provider.tsx +14 -0
  132. package/src/lib/nocobase/acl/store.ts +92 -86
  133. package/src/lib/nocobase/acl/types.ts +52 -32
  134. package/src/lib/nocobase/auth-session.ts +128 -0
  135. package/src/lib/nocobase/client.ts +48 -50
  136. package/src/locales/en-US.ts +0 -78
  137. package/src/locales/index.ts +2 -7
  138. package/src/locales/zh-CN.ts +0 -74
  139. package/src/providers/access-control.ts +43 -8
  140. package/src/providers/auth-callback.ts +1 -0
  141. package/src/providers/auth.ts +24 -26
  142. package/src/providers/constants.ts +0 -4
  143. package/src/providers/data.ts +14 -26
  144. package/src/providers/runtime-config.ts +40 -0
  145. package/src/vite-env.d.ts +9 -0
  146. package/tests/auth-session-regression.mjs +101 -0
  147. package/tsconfig.json +2 -1
  148. package/vite.config.ts +9 -1
  149. package/dist/assets/VisualMapping-Cbv1v7Cd.js +0 -1
  150. package/dist/assets/ai-employee-shortcut-B253WWow.js +0 -1
  151. package/dist/assets/calendar-B3dXXyIv.js +0 -1
  152. package/dist/assets/chat-inline-xpQ9iq4p.js +0 -1
  153. package/dist/assets/chat-side-panel-layout-BVWsp5rr.js +0 -1
  154. package/dist/assets/components-ChhJaNRc.js +0 -20
  155. package/dist/assets/configuration-gate-Dwdq_lxf.js +0 -1
  156. package/dist/assets/createSeriesDataSimply-CI7l7Ufv.js +0 -1
  157. package/dist/assets/customGraphicKeyframeAnimation-DE3jSfMd.js +0 -3
  158. package/dist/assets/echarts-preview-C-cNUtJF.js +0 -1
  159. package/dist/assets/floating-BarTmn-b.js +0 -13
  160. package/dist/assets/index-BJIcYTdc.js +0 -53
  161. package/dist/assets/index-C6xNKxpg.js +0 -656
  162. package/dist/assets/index-D4JQi1TM.js +0 -54
  163. package/dist/assets/index-YA7-AUO8.css +0 -1
  164. package/dist/assets/index-g8zWVpP9.js +0 -23
  165. package/dist/assets/prompt-card-BsYMW_rq.js +0 -1
  166. package/dist/assets/shortcut-xtghDP63.js +0 -47
  167. package/registry/nocobase-acl/README.md +0 -19
  168. package/registry/nocobase-acl/extension.tsx +0 -71
  169. package/registry/nocobase-acl/tests/acl-regression.mjs +0 -314
  170. package/registry/nocobase-ai/components/surfaces/chat-dialog.tsx +0 -31
  171. package/registry/nocobase-ai/components/surfaces/chat-side-panel.tsx +0 -74
  172. package/registry/nocobase-ai/extension.tsx +0 -158
  173. package/registry/nocobase-ai/tests/business-report-regression.mjs +0 -70
  174. package/registry/nocobase-ai/tests/form-filler-regression.mjs +0 -129
  175. package/registry/nocobase-ai/tests/frontend-tool-regression.mjs +0 -128
  176. package/registry/nocobase-ai/tests/page-context-regression.mjs +0 -48
  177. package/registry/nocobase-ai/tests/stream-regression.mjs +0 -207
  178. package/registry/nocobase-auth-cas/README.md +0 -6
  179. package/registry/nocobase-auth-cas/cas-sign-in-button.tsx +0 -41
  180. package/registry/nocobase-auth-cas/demo.tsx +0 -20
  181. package/registry/nocobase-auth-cas/extension.tsx +0 -46
  182. package/registry/nocobase-auth-cas/index.ts +0 -1
  183. package/registry/nocobase-auth-cas/use-cas-sign-in.ts +0 -29
  184. package/registry/nocobase-auth-dingtalk/README.md +0 -7
  185. package/registry/nocobase-auth-dingtalk/auto-login-provider.tsx +0 -154
  186. package/registry/nocobase-auth-dingtalk/demo.tsx +0 -23
  187. package/registry/nocobase-auth-dingtalk/dingtalk-sign-in-button.tsx +0 -45
  188. package/registry/nocobase-auth-dingtalk/extension.tsx +0 -55
  189. package/registry/nocobase-auth-dingtalk/index.ts +0 -4
  190. package/registry/nocobase-auth-dingtalk/use-dingtalk-sign-in.ts +0 -64
  191. package/registry/nocobase-auth-ldap/README.md +0 -6
  192. package/registry/nocobase-auth-ldap/demo.tsx +0 -21
  193. package/registry/nocobase-auth-ldap/extension.tsx +0 -46
  194. package/registry/nocobase-auth-ldap/index.ts +0 -1
  195. package/registry/nocobase-auth-ldap/ldap-sign-in-form.tsx +0 -69
  196. package/registry/nocobase-auth-ldap/use-ldap-sign-in.ts +0 -5
  197. package/registry/nocobase-auth-oidc/README.md +0 -11
  198. package/registry/nocobase-auth-oidc/auto-redirect-provider.tsx +0 -13
  199. package/registry/nocobase-auth-oidc/demo.tsx +0 -20
  200. package/registry/nocobase-auth-oidc/extension.tsx +0 -51
  201. package/registry/nocobase-auth-oidc/index.ts +0 -1
  202. package/registry/nocobase-auth-oidc/oidc-sign-in-button.tsx +0 -44
  203. package/registry/nocobase-auth-oidc/use-oidc-sign-in.ts +0 -58
  204. package/registry/nocobase-auth-saml/README.md +0 -6
  205. package/registry/nocobase-auth-saml/auto-redirect-provider.tsx +0 -13
  206. package/registry/nocobase-auth-saml/demo.tsx +0 -20
  207. package/registry/nocobase-auth-saml/extension.tsx +0 -51
  208. package/registry/nocobase-auth-saml/index.ts +0 -1
  209. package/registry/nocobase-auth-saml/saml-sign-in-button.tsx +0 -43
  210. package/registry/nocobase-auth-saml/use-saml-sign-in.ts +0 -51
  211. package/registry/nocobase-auth-sms/README.md +0 -7
  212. package/registry/nocobase-auth-sms/demo.tsx +0 -25
  213. package/registry/nocobase-auth-sms/extension.tsx +0 -46
  214. package/registry/nocobase-auth-sms/index.ts +0 -1
  215. package/registry/nocobase-auth-sms/sms-sign-in-form.tsx +0 -107
  216. package/registry/nocobase-auth-sms/use-sms-sign-in.ts +0 -88
  217. package/registry/nocobase-auth-wecom/README.md +0 -6
  218. package/registry/nocobase-auth-wecom/auto-login-provider.tsx +0 -21
  219. package/registry/nocobase-auth-wecom/demo.tsx +0 -23
  220. package/registry/nocobase-auth-wecom/extension.tsx +0 -49
  221. package/registry/nocobase-auth-wecom/index.ts +0 -1
  222. package/registry/nocobase-auth-wecom/use-wecom-sign-in.ts +0 -62
  223. package/registry/nocobase-auth-wecom/wecom-sign-in-button.tsx +0 -70
  224. package/registry/nocobase-i18n/README.md +0 -44
  225. package/registry/nocobase-i18n/components/index.ts +0 -1
  226. package/registry/nocobase-i18n/components/language-switcher.tsx +0 -138
  227. package/registry/nocobase-i18n/demo/index.tsx +0 -209
  228. package/registry/nocobase-i18n/demo/prompt-generator.tsx +0 -132
  229. package/registry/nocobase-i18n/extension.tsx +0 -45
  230. package/registry/nocobase-i18n/index.ts +0 -7
  231. package/registry/nocobase-i18n/locales/en-US.ts +0 -39
  232. package/registry/nocobase-i18n/locales/index.ts +0 -8
  233. package/registry/nocobase-i18n/locales/zh-CN.ts +0 -35
  234. package/registry/nocobase-i18n/provider.tsx +0 -44
  235. package/registry/nocobase-i18n/server-resources.ts +0 -166
  236. package/registry/nocobase-i18n/tests/i18n-regression.mjs +0 -51
  237. package/registry.config.json +0 -302
  238. package/scripts/registry.mjs +0 -164
  239. package/src/components/access-control/resource-access-guard.tsx +0 -21
  240. package/src/components/access-control/use-acl-runtime.ts +0 -28
  241. package/src/lib/nocobase/acl/action.ts +0 -147
  242. package/src/pages/users/layout.tsx +0 -15
  243. package/src/pages/users/show.tsx +0 -278
  244. /package/{registry → src/extensions}/nocobase-acl/components/index.ts +0 -0
  245. /package/{registry → src/extensions}/nocobase-acl/components/role-options.ts +0 -0
  246. /package/{registry → src/extensions}/nocobase-acl/demo/components.tsx +0 -0
  247. /package/{registry → src/extensions}/nocobase-acl/demo/lazy-route.tsx +0 -0
  248. /package/{registry → src/extensions}/nocobase-acl/demo/role-switcher-prompt-generator.tsx +0 -0
  249. /package/{registry → src/extensions}/nocobase-acl/demo/scenario-section.tsx +0 -0
  250. /package/{registry → src/extensions}/nocobase-acl/index.ts +0 -0
  251. /package/{registry → src/extensions}/nocobase-ai/adapters/react-hook-form.ts +0 -0
  252. /package/{registry → src/extensions}/nocobase-ai/assets/nocobase-ai-chat.svg +0 -0
  253. /package/{registry → src/extensions}/nocobase-ai/components/ai-root-provider.tsx +0 -0
  254. /package/{registry → src/extensions}/nocobase-ai/components/chat/ai-employee-avatar.tsx +0 -0
  255. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-attachment.tsx +0 -0
  256. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-compact.tsx +0 -0
  257. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-empty-state.tsx +0 -0
  258. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-header.tsx +0 -0
  259. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-history-dialog.tsx +0 -0
  260. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-message.tsx +0 -0
  261. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-window.tsx +0 -0
  262. /package/{registry → src/extensions}/nocobase-ai/components/chat/conversation-list.tsx +0 -0
  263. /package/{registry → src/extensions}/nocobase-ai/components/chat/markdown-message.tsx +0 -0
  264. /package/{registry → src/extensions}/nocobase-ai/components/chat/model-select-options.tsx +0 -0
  265. /package/{registry → src/extensions}/nocobase-ai/components/chat/reasoning-panel.tsx +0 -0
  266. /package/{registry → src/extensions}/nocobase-ai/components/chat/sub-agent-conversation.tsx +0 -0
  267. /package/{registry → src/extensions}/nocobase-ai/components/chat/user-prompt-editor.tsx +0 -0
  268. /package/{registry → src/extensions}/nocobase-ai/components/chat/work-context-chip.tsx +0 -0
  269. /package/{registry → src/extensions}/nocobase-ai/components/page-elements/ai-form.tsx +0 -0
  270. /package/{registry → src/extensions}/nocobase-ai/components/page-elements/page-element-provider.tsx +0 -0
  271. /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-inline.tsx +0 -0
  272. /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-page.tsx +0 -0
  273. /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-side-panel-layout.tsx +0 -0
  274. /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-surface-actions.tsx +0 -0
  275. /package/{registry → src/extensions}/nocobase-ai/components/tools/builtin-tool-renderers.tsx +0 -0
  276. /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-dialog.tsx +0 -0
  277. /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-renderer.tsx +0 -0
  278. /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-utils.tsx +0 -0
  279. /package/{registry → src/extensions}/nocobase-ai/components/tools/chart-renderer.tsx +0 -0
  280. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-preview.tsx +0 -0
  281. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-advanced.ts +0 -0
  282. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-common.ts +0 -0
  283. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-components.ts +0 -0
  284. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-hierarchy.ts +0 -0
  285. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime.ts +0 -0
  286. /package/{registry → src/extensions}/nocobase-ai/components/tools/sub-agent-renderer.tsx +0 -0
  287. /package/{registry → src/extensions}/nocobase-ai/components/tools/suggestions-renderer.tsx +0 -0
  288. /package/{registry → src/extensions}/nocobase-ai/components/tools/tool-renderer-provider.tsx +0 -0
  289. /package/{registry → src/extensions}/nocobase-ai/components/tools/tool-renderer-utils.ts +0 -0
  290. /package/{registry → src/extensions}/nocobase-ai/components/tools/workflow-renderer.tsx +0 -0
  291. /package/{registry → src/extensions}/nocobase-ai/components/triggers/ai-employee-shortcut.tsx +0 -0
  292. /package/{registry → src/extensions}/nocobase-ai/demo/interaction-showcase.tsx +0 -0
  293. /package/{registry → src/extensions}/nocobase-ai/demo/page-context-prompt-generator.tsx +0 -0
  294. /package/{registry → src/extensions}/nocobase-ai/demo/page-context.tsx +0 -0
  295. /package/{registry → src/extensions}/nocobase-ai/demo/page-element-showcase.tsx +0 -0
  296. /package/{registry → src/extensions}/nocobase-ai/demo/prompt-card.tsx +0 -0
  297. /package/{registry → src/extensions}/nocobase-ai/demo/shortcut.tsx +0 -0
  298. /package/{registry → src/extensions}/nocobase-ai/index.ts +0 -0
  299. /package/{registry → src/extensions}/nocobase-ai/providers/avatars.ts +0 -0
  300. /package/{registry → src/extensions}/nocobase-ai/providers/chat-controller.ts +0 -0
  301. /package/{registry → src/extensions}/nocobase-ai/providers/chat-message-utils.ts +0 -0
  302. /package/{registry → src/extensions}/nocobase-ai/providers/chat-reducer.ts +0 -0
  303. /package/{registry → src/extensions}/nocobase-ai/providers/chat-task-utils.ts +0 -0
  304. /package/{registry → src/extensions}/nocobase-ai/providers/chat-transport.ts +0 -0
  305. /package/{registry → src/extensions}/nocobase-ai/providers/form-registry.tsx +0 -0
  306. /package/{registry → src/extensions}/nocobase-ai/providers/frontend-tool-registry.tsx +0 -0
  307. /package/{registry → src/extensions}/nocobase-ai/providers/index.ts +0 -0
  308. /package/{registry → src/extensions}/nocobase-ai/providers/model.ts +0 -0
  309. /package/{registry → src/extensions}/nocobase-ai/providers/page-context.tsx +0 -0
  310. /package/{registry → src/extensions}/nocobase-ai/providers/stream-coalescer.ts +0 -0
  311. /package/{registry → src/extensions}/nocobase-ai/providers/stream-event-utils.ts +0 -0
  312. /package/{registry → src/extensions}/nocobase-ai/providers/stream-parser.ts +0 -0
  313. /package/{registry → src/extensions}/nocobase-ai/providers/sub-agent-stream.ts +0 -0
  314. /package/{registry → src/extensions}/nocobase-ai/providers/types.ts +0 -0
  315. /package/{registry → src/extensions}/nocobase-ai/providers/ui-message-stream.ts +0 -0
  316. /package/{registry → src/extensions}/nocobase-ai/providers/use-automatic-tool-approval.ts +0 -0
  317. /package/{registry → src/extensions}/nocobase-ai/providers/use-chat-message-actions.ts +0 -0
  318. /package/{registry → src/extensions}/nocobase-ai/providers/use-chat-runtime.ts +0 -0
  319. /package/{registry → src/extensions}/nocobase-ai/providers/use-conversation-catalog.ts +0 -0
  320. /package/{registry → src/extensions}/nocobase-ai/providers/use-conversation-history.ts +0 -0
  321. /package/{registry → src/extensions}/nocobase-ai/services/index.ts +0 -0
  322. /package/{registry → src/extensions}/nocobase-ai/services/nocobase-ai-service.ts +0 -0
  323. /package/{registry → src/extensions}/nocobase-ai/services/types.ts +0 -0
  324. /package/{registry → src/extensions}/nocobase-route-surfaces/demo/lazy-route.tsx +0 -0
  325. /package/{registry → src/extensions}/nocobase-route-surfaces/demo/prompt-generator.tsx +0 -0
  326. /package/{registry → src/extensions}/nocobase-route-surfaces/index.ts +0 -0
  327. /package/{registry → src/extensions}/nocobase-route-surfaces/route-dialog.tsx +0 -0
  328. /package/{registry → src/extensions}/nocobase-route-surfaces/route-drawer.tsx +0 -0
  329. /package/{registry → src/extensions}/nocobase-route-surfaces/route-page.tsx +0 -0
  330. /package/{registry → src/extensions}/nocobase-route-surfaces/route-surface-context.ts +0 -0
  331. /package/{registry → src/extensions}/nocobase-route-surfaces/use-refine-unsaved-changes.tsx +0 -0
  332. /package/{registry → src/extensions}/nocobase-route-surfaces/use-route-surface-close.ts +0 -0
  333. /package/{registry → src/extensions}/nocobase-route-surfaces/use-route-surface-state.ts +0 -0
  334. /package/src/{pages/users → extensions/nocobase-users-example}/form-fields.tsx +0 -0
  335. /package/src/{pages/users → extensions/nocobase-users-example}/index.ts +0 -0
  336. /package/src/{pages/users → extensions/nocobase-users-example}/role-badges.tsx +0 -0
  337. /package/src/{pages/users → extensions/nocobase-users-example}/role-utils.ts +0 -0
  338. /package/src/{pages/users → extensions/nocobase-users-example}/types.ts +0 -0
@@ -0,0 +1,58 @@
1
+ import{t as U,v as T,j as e,A as G,b as A,w as X,l as Y,m as Z,n as B,o as w,p as ee,q as v,x as se,C as te,k as D,I as k,T as re,B as W,y as ie,z as c,U as q,D as u,P as ne,E as ae,F as oe,G as le}from"./index-MB-jfQld.js";import{C as m,a as h,b as p,c as P,d as x}from"./card-DuQBOS6A.js";import{P as de}from"./prompt-output-DZHRM2ft.js";/**
2
+ * @license lucide-react v0.487.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ce=[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]],L=U("layout-panel-top",ce);/**
7
+ * @license lucide-react v0.487.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const me=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],V=U("lock-keyhole",me);/**
12
+ * @license lucide-react v0.487.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ue=[["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}]],he=U("user-round-cog",ue),O=s=>({resource:s.resource,action:s.action,id:s.id,field:s.field,dataSourceKey:s.dataSourceKey});function pe({children:s,anyOf:t,allOf:r,roles:i,fallback:a=e.jsx(G,{})}){const n=T(),o=!(t!=null&&t.length)||t.some(g=>n(O(g))),f=!(r!=null&&r.length)||r.every(g=>n(O(g)));return n({roles:i})&&o&&f?s:a}function z({children:s,resource:t,action:r,id:i,dataSourceKey:a,fallback:n="hidden"}){return T()({resource:t,action:r,id:i,dataSourceKey:a})?s:n==="hidden"?null:n==="forbidden"?e.jsx(G,{className:"min-h-40"}):n}function C({children:s,resource:t,action:r,field:i,dataSourceKey:a,fallback:n=null}){return T()({resource:t,action:r,field:i,dataSourceKey:a})?s:n}function d({children:s,roles:t,permissions:r={},recordPermissions:i=[]}){const a=A.useMemo(()=>{const n=Array.from(new Set(Object.keys(r).map(l=>l.slice(0,l.lastIndexOf(":"))))),o={status:"ready",permissions:{currentRole:t.length>1?"__union__":t[0],roles:t,roleMode:t.length>1?"allow-use-union":"default",resources:n,actions:r,actionAlias:{list:"list",get:"get",create:"create",update:"update",destroy:"destroy"},snippets:[]}},f=new Map(i.map(l=>[`${l.dataSourceKey??"main"}:${l.resource}:${l.action}:${l.id}`,l.allowed]));return{getState:()=>o,subscribe:()=>()=>{},load:async()=>o,retry:async()=>o,clear:()=>{},recordPermissions:{getState:()=>f,subscribe:()=>()=>{},getPermission:({dataSourceKey:l="main",resource:g,action:J,id:Q})=>f.get(`${l}:${g}:${J}:${Q}`)}}},[r,i,t]);return e.jsx(X,{store:a,children:s})}const xe=[["roles","RoleConstraint","undefined","Checks the current effective roles with anyOf, allOf, and noneOf."],["resource / action","string","undefined","Checks a NocoBase resource action. When roles are also present, both checks must pass."],["id / field","BaseKey / string","undefined","Optionally narrows the decision to one record or field."],["fallback","ReactNode","null","Renders when the access request is denied."]],fe=[["anyOf","AclPermission[]","undefined","Allows the page when any listed permission is available."],["allOf","AclPermission[]","undefined","Requires every listed permission before rendering the page."],["roles","RoleConstraint","undefined","Requires the current effective roles to match anyOf, allOf, and noneOf constraints."],["fallback","ReactNode","AccessDenied","Replaces the complete page when its permission test fails."],["children","ReactNode","required","The protected page content."]],ge=[["resource","string","required","NocoBase collection or ACL resource name."],["action","string","required","Resource action such as list, show, create, edit, or delete."],["id","BaseKey","undefined","Optional record ID for record-scoped permission checks."],["dataSourceKey","string","undefined","Selects a non-main NocoBase data source."],["fallback",'"hidden" | "forbidden" | ReactNode','"hidden"',"Hides the region or replaces it with a local denied state."],["children","ReactNode","required","The protected page region."]],je=[["resource","string","required","NocoBase collection containing the field."],["action","string","required","The action whose field whitelist should be checked."],["field","string","required","Exact NocoBase field name."],["dataSourceKey","string","undefined","Selects a non-main NocoBase data source."],["fallback","ReactNode","null","Optional read-only replacement for a denied field."],["children","ReactNode","required","The protected field or field group."]],be=[["AclStoreProvider","{ store, children }","required","Connects React ACL hooks and components to the application aclStore. The Starter mounts it at the application root."],["useGetRoles","() => QueryResult<string[]>","-","Returns the current effective ACL role names, including all participating roles in union mode."]];function ye(){return e.jsxs("section",{className:"space-y-5 border-t pt-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Permission boundaries"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Components behind the patterns"}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Use the smallest boundary that matches the intended user experience: complete page, independent region, or individual field."})]}),e.jsxs("div",{className:"space-y-7",children:[e.jsx(j,{title:"CanAccess",description:"The Starter access boundary for role-only, resource-only, or combined permission checks.",rows:xe}),e.jsx(j,{title:"AclPage",description:"Protects a complete route or business page. This corresponds to the Page permission pattern above.",rows:fe}),e.jsx(j,{title:"AclRegion",description:"Protects one independent area inside a larger page. This corresponds to the Region permission pattern.",rows:ge}),e.jsx(j,{title:"AclField",description:"Protects one field or field group. This corresponds to the Field permission pattern.",rows:je}),e.jsx(j,{title:"ACL context APIs",description:"Read the active role context from the application ACL store. Demo previews use an isolated in-memory store with the same evaluator.",rows:be})]})]})}function j({title:s,description:t,rows:r}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:s}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t})]}),e.jsx(m,{className:"gap-0 overflow-hidden py-0",children:e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(B,{children:[e.jsx(w,{children:"Prop"}),e.jsx(w,{children:"Type"}),e.jsx(w,{children:"Default"}),e.jsx(w,{children:"Description"})]})}),e.jsx(ee,{children:r.map(([i,a,n,o])=>e.jsxs(B,{children:[e.jsx(v,{className:"font-mono text-xs font-medium",children:i}),e.jsx(v,{className:"font-mono text-xs text-muted-foreground",children:a}),e.jsx(v,{className:"font-mono text-xs text-muted-foreground",children:n}),e.jsx(v,{className:"min-w-72 whitespace-normal text-muted-foreground",children:o})]},i))})]})})]})}function we({config:s}){const[t,r]=A.useState(s.defaultScene),[i,a]=A.useState(s.defaultTarget),n=A.useMemo(()=>`Build a complete NocoBase ACL scene in the NocoBase Admin Starter.
17
+
18
+ Business scene
19
+ - Page or feature: ${t}
20
+ - Permission target: ${i}
21
+ - Use realistic fixed sample content so the permission behavior is visible immediately.
22
+ - Build the complete page section and user flow, not an isolated ACL snippet.
23
+
24
+ ACL scenario
25
+ ${s.requirements}
26
+
27
+ Implementation contract
28
+ - Use the Starter's built-in NocoBase accessControlProvider and ACL store.
29
+ - NocoBase roles:check is the source of truth. Do not create a second permission store. Use configured role names only when the requirement explicitly includes a role constraint.
30
+ - Import the Starter CanAccess from @/components/access-control/can-access. Use it with AclPage, AclRegion, and AclField for permission presentation. Do not copy their checks into local booleans or role comparisons.
31
+ - Use useGetRoles only when UI needs to display or pass through the current effective ACL roles; it is not a replacement permission evaluator.
32
+ - Keep backend ACL enforcement in place; frontend checks only control presentation and navigation.
33
+ - Import reusable components from the installed local entry point at @/extensions/nocobase-acl when page composition is needed.
34
+ - Resource actions use the application names list, show, create, edit, and delete. Let the Starter map them to NocoBase list/get/create/update/destroy.
35
+ - Preserve dataSourceKey when the collection belongs to a non-main data source.
36
+ - Show an understandable forbidden or hidden state where appropriate.
37
+ - Deliver complete React component code, resource metadata, route integration, and the visible sample UI.`,[s.requirements,t,i]);return e.jsxs("details",{className:"group rounded-xl border bg-muted/15",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium marker:hidden",children:[e.jsx(se,{className:"size-4 text-primary"}),"Prompt generator",e.jsx("span",{className:"ml-auto text-xs font-normal text-muted-foreground",children:s.title}),e.jsx(te,{className:"size-4 text-muted-foreground transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"grid items-start gap-5 border-t p-4 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(m,{className:"gap-0 py-0",children:[e.jsxs(h,{className:"border-b py-4",children:[e.jsx(p,{className:"text-base",children:"Scenario settings"}),e.jsx(P,{children:s.description})]}),e.jsxs(x,{className:"space-y-5 py-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:`${s.title}-scene`,children:"Business scene"}),e.jsx(k,{id:`${s.title}-scene`,value:t,onChange:o=>r(o.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:`${s.title}-target`,children:"Permission target"}),e.jsx(re,{id:`${s.title}-target`,value:i,onChange:o=>a(o.target.value),className:"min-h-24"})]})]})]}),e.jsx(de,{description:"Updates as you change the business scene and permission target.",prompt:n})]})]})}function b({eyebrow:s,title:t,description:r,children:i,prompt:a}){return e.jsxs("section",{className:"space-y-5 border-t pt-8",children:[e.jsxs("div",{children:[e.jsx(W,{variant:"outline",children:s}),e.jsx("h2",{className:"mt-3 text-2xl font-semibold tracking-[-0.025em]",children:t}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-muted-foreground",children:r})]}),i,e.jsx(we,{config:a})]})}const R=[{id:1,name:"Alex Johnson",username:"alex",email:"alex@example.com",phone:"+1 202 555 0148",role:"Administrator"},{id:2,name:"Jamie Chen",username:"jamie",email:"jamie@example.com",phone:"+1 202 555 0186",role:"Member"},{id:3,name:"Morgan Lee",username:"morgan",email:"morgan@example.com",phone:"+1 202 555 0162",role:"Member"}],$={anyOf:["admin"]},ve={"users:list":{},"departments:list":{}},Ne={"users:list":{}},Ae={"users:get":{},"users:create":{},"users:update":{},"users:destroy":{}},ke={"users:get":{},"users:update":{},"users:destroy":{}},Pe=R.flatMap(s=>[{resource:"users",action:"update",id:s.id,allowed:!1},{resource:"users",action:"destroy",id:s.id,allowed:!1}]),Re={"users:update":{fields:["nickname","email","phone"]}},Ce={"users:update":{fields:["nickname"]}};function qe(){return e.jsxs("div",{className:"space-y-10 pb-12",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-[-0.025em] sm:text-3xl",children:"Permission patterns"}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:"Compare the authorized and restricted outcomes of navigation, pages, regions, record actions, and form fields using the same fixed data."})]}),e.jsx(b,{eyebrow:"Navigation permission",title:"Role-restricted routes disappear from navigation",description:"A route outside the current effective role is removed from the sidebar and its direct URL is guarded. Other accessible navigation remains unchanged.",prompt:{title:"Resource navigation",description:"Generate application resources, sidebar behavior, and guarded routes backed by NocoBase collections.",defaultScene:"User and role administration",defaultTarget:"Allow administrators to open Users, but remove it from navigation and block its direct URL for other roles.",requirements:`- Put role constraints on the route resource through meta.acl.roles using anyOf, allOf, or noneOf.
38
+ - Use meta.acl.type = "authenticated" when the route itself is role-controlled and its inner regions perform collection checks.
39
+ - Let the Starter filter inaccessible sidebar items and choose the first accessible default route.
40
+ - Wrap list, create, show, and edit routes with the Starter CanAccess and provide an AccessDenied fallback.
41
+ - Mark non-collection utility pages as authenticated, snippet, route, or acl: false instead of treating them as collections.
42
+ - If a parent route is denied but an accessible child remains, navigation must continue to the child route.`},children:e.jsx(y,{allowedTitle:"Users permission granted",deniedTitle:"Users permission denied",allowed:e.jsx(d,{roles:["admin"],children:e.jsx(E,{})}),denied:e.jsx(d,{roles:["member"],children:e.jsx(E,{})})})}),e.jsx(b,{eyebrow:"Page permission",title:"A complete page is either available or replaced",description:"Page-level permission is useful when the whole route has one business purpose. Denial produces an understandable destination instead of a blank screen.",prompt:{title:"Page permission",description:"Generate a complete page whose availability depends on NocoBase permissions.",defaultScene:"User directory and account administration page",defaultTarget:"Allow administrators and user managers to render the complete page.",requirements:`- Wrap the complete business page with AclPage.
43
+ - Use the AclPage roles prop with anyOf, allOf, or noneOf for page-level role access.
44
+ - Keep anyOf and allOf for resource permissions when the page also needs collection access.
45
+ - Provide a useful page-level fallback instead of rendering an empty screen.
46
+ - Keep each inner data region independently protected when the page combines multiple collections.`},children:e.jsx(y,{allowedTitle:"Page allowed",deniedTitle:"Page denied",allowed:e.jsx(d,{roles:["user-manager"],children:e.jsx(F,{})}),denied:e.jsx(d,{roles:["member"],children:e.jsx(F,{})})})}),e.jsx(b,{eyebrow:"Region permission",title:"Only the protected region changes",description:"On a page with multiple resources, denying Departments hides only that panel and must not affect the Users table.",prompt:{title:"Region permission",description:"Generate a multi-resource page where each region follows its own collection ACL.",defaultScene:"Organization management dashboard",defaultTarget:"Keep Users visible while hiding the denied Departments panel.",requirements:`- Keep the outer page visible when its page-level permission is satisfied.
47
+ - Wrap every collection-backed panel in its own AclRegion.
48
+ - Enable each data query only when the corresponding list permission is allowed.
49
+ - Use fallback="hidden" so denied regions do not reveal unavailable resources or placeholders.
50
+ - Never use permission for one collection to hide unrelated tables or controls.`},children:e.jsx(y,{allowedTitle:"Both regions allowed",deniedTitle:"Departments resource hidden",allowed:e.jsx(d,{roles:["member"],permissions:ve,children:e.jsx(I,{})}),denied:e.jsx(d,{roles:["member"],permissions:Ne,children:e.jsx(I,{})})})}),e.jsx(b,{eyebrow:"Action and record permission",title:"Only unavailable actions are removed",description:"Collection permission controls global actions such as Create. Record ACL metadata controls Edit and Delete for each individual row.",prompt:{title:"Action permission",description:"Generate a data table whose toolbar and row actions respond to collection and record scopes.",defaultScene:"User administration table",defaultTarget:"Allow all actions for one user record and show a view-only row when update and delete are denied.",requirements:`- Use the Starter dataProvider so X-With-ACL-Meta captures NocoBase allowedActions from list, get, and getMany responses.
51
+ - Use the built-in Create, Show, Edit, and Delete buttons; do not manually compare user IDs or role names.
52
+ - Collection-level denial hides the action everywhere.
53
+ - Record-level allowedActions must hide or disable only the affected row action.
54
+ - Keep 403 responses authenticated and let NocoBase perform the final action validation.`},children:e.jsx(y,{allowedTitle:"Create and row actions allowed",deniedTitle:"Create, Update, and Delete denied",allowed:e.jsx(d,{roles:["admin"],permissions:Ae,children:e.jsx(K,{})}),denied:e.jsx(d,{roles:["viewer"],permissions:ke,recordPermissions:Pe,children:e.jsx(K,{})})})}),e.jsx(b,{eyebrow:"Field permission",title:"A form can mix editable, read-only, and hidden fields",description:"Field ACL does not have to hide the complete form. Only protected inputs change, while permitted fields remain usable.",prompt:{title:"Field permission",description:"Generate a form or detail page whose individual fields follow NocoBase field ACL.",defaultScene:"User profile edit form",defaultTarget:"Allow nickname editing, make email read-only, and hide phone when those fields are denied.",requirements:`- Wrap each protected field or field group with AclField.
55
+ - Pass the collection resource, application action, and exact field name.
56
+ - Choose whether a denied field is hidden, replaced by read-only output, or shown with a custom fallback.
57
+ - Do not infer field access from the overall edit permission.
58
+ - Submit only values the current UI is allowed to edit; NocoBase still performs final field validation.`},children:e.jsx(y,{allowedTitle:"All fields editable",deniedTitle:"Email read-only and phone hidden",allowed:e.jsx(d,{roles:["admin"],permissions:Re,children:e.jsx(M,{})}),denied:e.jsx(d,{roles:["member"],permissions:Ce,children:e.jsx(M,{})})})}),e.jsx(ye,{})]})}function y({allowedTitle:s,deniedTitle:t,allowed:r,denied:i}){return e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-2",children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-emerald-700 dark:text-emerald-400",children:[e.jsx(ie,{className:"size-4"}),s]}),r]}),e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-amber-700 dark:text-amber-400",children:[e.jsx(V,{className:"size-4"}),t]}),i]})]})}function E(){return e.jsxs("div",{className:"grid min-h-48 grid-cols-[150px_minmax(0,1fr)] overflow-hidden rounded-xl border bg-background",children:[e.jsxs("aside",{className:"border-r bg-muted/35 p-3",children:[e.jsx("div",{className:"mb-3 text-xs font-semibold text-muted-foreground",children:"Workspace"}),e.jsx(S,{icon:e.jsx(L,{}),label:"Dashboard"}),e.jsx(c,{roles:$,children:e.jsx(S,{icon:e.jsx(q,{}),label:"Users",active:!0})}),e.jsx(S,{icon:e.jsx(he,{}),label:"Roles"})]}),e.jsx("div",{className:"flex items-center justify-center p-5 text-center",children:e.jsx(c,{roles:$,fallback:e.jsxs("div",{children:[e.jsx(L,{className:"mx-auto size-7 text-muted-foreground"}),e.jsx("div",{className:"mt-2 font-medium",children:"Dashboard"}),e.jsx("div",{className:"mt-1 max-w-48 text-xs text-muted-foreground",children:"Users is absent from navigation and its direct route is guarded."})]}),children:e.jsxs("div",{children:[e.jsx(q,{className:"mx-auto size-7 text-primary"}),e.jsx("div",{className:"mt-2 font-medium",children:"Users"}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Route is available"})]})})})]})}function S({icon:s,label:t,active:r=!1}){return e.jsxs("div",{className:`mb-1 flex items-center gap-2 rounded-md px-2 py-2 text-xs ${r?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:[e.jsx("span",{className:"[&_svg]:size-3.5",children:s}),t]})}function F(){return e.jsx(pe,{roles:{anyOf:["admin","user-manager"]},fallback:e.jsx(Ue,{}),children:e.jsx(Se,{})})}function Se(){return e.jsxs(m,{children:[e.jsxs(h,{children:[e.jsx(p,{children:"User directory"}),e.jsx(P,{children:"3 users"})]}),e.jsx(x,{children:e.jsx(H,{})})]})}function Ue(){return e.jsx("div",{className:"flex min-h-64 items-center justify-center rounded-xl border border-dashed bg-background p-6 text-center",children:e.jsxs("div",{children:[e.jsx(V,{className:"mx-auto size-8 text-muted-foreground"}),e.jsx("div",{className:"mt-3 font-medium",children:"You cannot open this page"}),e.jsx("p",{className:"mx-auto mt-1 max-w-xs text-sm text-muted-foreground",children:"Ask an administrator for access to the user directory or return to an available page."}),e.jsx(u,{className:"mt-4",variant:"outline",size:"sm",children:"Return to dashboard"})]})})}function I(){return e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border bg-background p-3 md:flex-row",children:[e.jsx(z,{resource:"users",action:"list",children:e.jsxs(m,{size:"sm",className:"min-w-0 flex-1",children:[e.jsx(h,{children:e.jsx(p,{children:"Users"})}),e.jsx(x,{children:e.jsx(H,{limit:2})})]})}),e.jsx(z,{resource:"departments",action:"list",children:e.jsxs(m,{size:"sm",className:"md:w-56",children:[e.jsx(h,{children:e.jsx(p,{children:"Departments"})}),e.jsxs(x,{className:"space-y-2",children:[e.jsx(_,{title:"Engineering",name:"engineering"}),e.jsx(_,{title:"Operations",name:"operations"})]})]})})]})}function K(){return e.jsxs(m,{children:[e.jsxs(h,{className:"flex-row items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(p,{children:"Users"}),e.jsx(P,{children:"Record actions"})]}),e.jsx(c,{resource:"users",action:"create",children:e.jsxs(u,{size:"sm",children:[e.jsx(ne,{})," New user"]})})]}),e.jsx(x,{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[420px] text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-3 font-medium",children:"User"}),e.jsx("th",{className:"pb-3 font-medium",children:"Role"}),e.jsx("th",{className:"pb-3 text-right font-medium",children:"Actions"})]})}),e.jsx("tbody",{children:R.slice(0,2).map(s=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-3 font-medium",children:s.name}),e.jsx("td",{className:"py-3 text-muted-foreground",children:s.role}),e.jsx("td",{className:"py-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(c,{resource:"users",action:"show",id:s.id,children:e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":"View user",children:e.jsx(ae,{})})}),e.jsx(c,{resource:"users",action:"edit",id:s.id,children:e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":"Edit user",children:e.jsx(oe,{})})}),e.jsx(c,{resource:"users",action:"delete",id:s.id,children:e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":"Delete user",children:e.jsx(le,{})})})]})})]},s.id))})]})})]})}function M(){const s=R[1];return e.jsxs(m,{children:[e.jsxs(h,{children:[e.jsx(p,{children:"Edit profile"}),e.jsx(P,{children:s.name})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsx(C,{resource:"users",action:"edit",field:"nickname",children:e.jsx(N,{label:"Nickname",children:e.jsx(k,{defaultValue:s.name})})}),e.jsx(C,{resource:"users",action:"edit",field:"email",fallback:e.jsx(N,{label:"Email",children:e.jsxs("div",{className:"rounded-md border bg-muted/45 px-3 py-2 text-sm text-muted-foreground",children:[s.email,e.jsx(W,{className:"ml-2",variant:"outline",children:"Read only"})]})}),children:e.jsx(N,{label:"Email",children:e.jsx(k,{defaultValue:s.email})})}),e.jsx(C,{resource:"users",action:"edit",field:"phone",children:e.jsx(N,{label:"Phone",children:e.jsx(k,{defaultValue:s.phone})})}),e.jsx(c,{resource:"users",action:"edit",children:e.jsx(u,{size:"sm",children:"Save changes"})})]})]})}function N({label:s,children:t}){return e.jsxs("label",{className:"block space-y-2",children:[e.jsx("span",{className:"text-xs font-medium",children:s}),t]})}function H({limit:s=3}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[360px] text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-3 font-medium",children:"User"}),e.jsx("th",{className:"pb-3 font-medium",children:"Email"})]})}),e.jsx("tbody",{children:R.slice(0,s).map(t=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsxs("td",{className:"py-3",children:[e.jsx("div",{className:"font-medium",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.username})]}),e.jsx("td",{className:"py-3 text-muted-foreground",children:t.email})]},t.id))})]})})}function _({title:s,name:t}){return e.jsxs("div",{className:"rounded-lg border px-3 py-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s}),e.jsx("div",{className:"mt-0.5 font-mono text-xs text-muted-foreground",children:t})]})}export{qe as AclPatternsPage};
@@ -0,0 +1,23 @@
1
+ import{t as N,bc as j,b as l,j as e,x as f,C as v,k as g,I as w,T as L,bd as C,be as S,B as x,bf as h,bg as k,bh as R,a$ as P}from"./index-MB-jfQld.js";import{C as c,a as d,b as m,c as p,d as u}from"./card-DuQBOS6A.js";import{P as z}from"./prompt-output-DZHRM2ft.js";/**
2
+ * @license lucide-react v0.487.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const B=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],I=N("database",B);function T(){const s=j(),[n,a]=l.useState("A customer support workspace"),[t,i]=l.useState("English and Simplified Chinese"),y=l.useMemo(()=>`Build a complete multilingual scene in the NocoBase Admin Starter.
7
+
8
+ Application scene
9
+ - Product or page: ${n}
10
+ - Supported languages: ${t}
11
+ - Translate the complete visible user flow, including empty, loading, validation, and error states.
12
+
13
+ Implementation contract
14
+ - Use the Starter's @/providers/i18n runtime and the application's translation and locale hooks.
15
+ - Put application-owned React messages in src/locales and register the app namespace through registerTranslationResources from @/lib/i18n.
16
+ - Keep each Registry component's messages in its own namespace and register them with registerLocaleResources().
17
+ - Do not place application messages inside src/extensions/nocobase-i18n/locales because installed Registry files may be refreshed independently.
18
+ - Use the reusable LanguageSwitcher when the page needs an explicit language control; the signed-in user menu already includes one.
19
+ - Reuse the Starter's shared system settings instead of requesting systemSettings:get again.
20
+ - Keep Starter and Registry UI resources local. Use app:getLang only for registered dynamic server namespaces such as lm-collections when the NocoBase i18n Registry is installed.
21
+ - Let the shared NocoBase client send the selected locale through X-Locale.
22
+ - Preserve compatibility when server metadata contains exact {{t("...")}} expressions.
23
+ - Provide complete React components, locale resource files, route/resource integration, and realistic visible content.`,[t,n]);return e.jsxs("details",{open:!0,className:"group rounded-xl border bg-muted/15",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium marker:hidden",children:[e.jsx(f,{className:"size-4 text-primary"}),s("demo.prompt.title",{ns:"nocobase-i18n"},"Prompt generator"),e.jsx(v,{className:"ml-auto size-4 text-muted-foreground transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"grid items-start gap-5 border-t p-4 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(c,{className:"gap-0 py-0",children:[e.jsxs(d,{className:"border-b py-4",children:[e.jsx(m,{className:"text-base",children:s("demo.prompt.settings",{ns:"nocobase-i18n"},"Scene settings")}),e.jsx(p,{children:s("demo.prompt.description",{ns:"nocobase-i18n"},"Describe a complete multilingual application scene and generate an implementation prompt.")})]}),e.jsxs(u,{className:"space-y-5 py-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"i18n-prompt-scene",children:s("demo.prompt.scene",{ns:"nocobase-i18n"},"Application scene")}),e.jsx(w,{id:"i18n-prompt-scene",value:n,onChange:r=>a(r.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"i18n-prompt-languages",children:s("demo.prompt.languages",{ns:"nocobase-i18n"},"Languages")}),e.jsx(L,{id:"i18n-prompt-languages",value:t,onChange:r=>i(r.target.value),className:"min-h-24"})]})]})]}),e.jsx(z,{title:s("demo.prompt.output",{ns:"nocobase-i18n"},"Generated prompt"),description:s("demo.prompt.outputDescription",{ns:"nocobase-i18n"},"Updates as you change the scene and language requirements."),prompt:y,copyLabel:s("demo.prompt.copy",{ns:"nocobase-i18n"},"Copy prompt"),copiedLabel:s("demo.prompt.copied",{ns:"nocobase-i18n"},"Copied"),copyErrorLabel:s("demo.prompt.copyError",{ns:"nocobase-i18n"},"Clipboard access failed. Select the prompt and copy it manually.")})]})]})}function E(){const s=j(),a=C()(),i=S().length>1;return e.jsxs("div",{className:"space-y-10 pb-12",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{variant:"secondary",children:"i18n"}),e.jsx(x,{variant:"outline",children:a})]}),e.jsx("h1",{className:"text-2xl font-semibold tracking-[-0.025em] sm:text-3xl",children:s("demo.title",{ns:"nocobase-i18n"},"Internationalization")}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:s("demo.description",{ns:"nocobase-i18n"},"Optional NocoBase server translations and language controls built on the Starter's internationalization runtime.")})]}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-3",children:[e.jsxs(c,{children:[e.jsxs(d,{children:[e.jsxs(m,{className:"flex items-center gap-2",children:[e.jsx(h,{className:"size-4"}),s("demo.switcher.title",{ns:"nocobase-i18n"},"Language switcher")]}),e.jsx(p,{children:s("demo.switcher.description",{ns:"nocobase-i18n"},"The same reusable component is also integrated into the signed-in user menu.")})]}),e.jsx(u,{children:i?e.jsx(k,{className:"max-w-sm"}):e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/30 p-4",children:[e.jsx(h,{className:"mt-0.5 size-5 shrink-0 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("demo.switcher.unavailable.title",{ns:"nocobase-i18n"},"Only one language is enabled")}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:s("demo.switcher.unavailable.description",{ns:"nocobase-i18n"},"Enable another language in NocoBase system settings to display the switcher.")})]})]})})]}),e.jsx(b,{icon:e.jsx(R,{className:"size-4"}),title:s("demo.frontend.title",{ns:"nocobase-i18n"},"Application UI translations"),description:s("demo.frontend.description",{ns:"nocobase-i18n"},"The Starter provides the runtime while application and Registry components keep their messages in local resource files."),children:e.jsxs("div",{className:"divide-y rounded-lg border",children:[e.jsx(o,{label:s("language.current",{ns:"nocobase-i18n"},"Current language"),value:a}),e.jsx(o,{label:s("demo.frontend.actions",{ns:"nocobase-i18n"},"Common actions"),value:`${s("buttons.apply","Apply")} · ${s("buttons.clear","Clear")}`})]})}),e.jsx(b,{icon:e.jsx(I,{className:"size-4"}),title:s("demo.server.title",{ns:"nocobase-i18n"},"NocoBase metadata translations"),description:s("demo.server.description",{ns:"nocobase-i18n"},"Collection and field labels are loaded from dynamic server namespaces such as lm-collections."),children:e.jsxs("div",{className:"divide-y rounded-lg border",children:[e.jsx(o,{label:"Users",value:s("Users",{ns:"lm-collections"},"Users")}),e.jsx(o,{label:"Nickname",value:s("Nickname",{ns:"lm-collections"},"Nickname")}),e.jsx(o,{label:"X-Locale",value:P.getLocale()??a,code:!0})]})})]}),e.jsx("section",{className:"border-t pt-8",children:e.jsx(T,{})})]})}function o({code:s,label:n,value:a}){return e.jsxs("div",{className:"flex items-center justify-between gap-4 px-3 py-2.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:n}),s?e.jsx("code",{className:"rounded bg-muted px-2 py-1 text-xs",children:a}):e.jsx("span",{className:"text-sm font-medium",children:a})]})}function b({children:s,description:n,icon:a,title:t}){return e.jsxs(c,{children:[e.jsxs(d,{children:[e.jsxs(m,{className:"flex items-center gap-2",children:[a,t]}),e.jsx(p,{children:n})]}),e.jsx(u,{className:"text-sm",children:s})]})}export{E as I18nDemoPage};
@@ -1 +1 @@
1
- import{dD as t,H as u}from"./echarts-runtime-CEgJbv68.js";function o(r,l){var e=r.mapDimensionsAll("defaultedLabel"),a=e.length;if(a===1){var n=t(r,l,e[0]);return n!=null?n+"":null}else if(a){for(var s=[],f=0;f<e.length;f++)s.push(t(r,l,e[f]));return s.join(" ")}}function v(r,l){var e=r.mapDimensionsAll("defaultedLabel");if(!u(l))return l+"";for(var a=[],n=0;n<e.length;n++){var s=r.getDimensionIndex(e[n]);s>=0&&a.push(l[s])}return a.join(" ")}export{o as a,v as g};
1
+ import{ar as t,H as u}from"./echarts-runtime-D8kXn6ME.js";function o(r,l){var e=r.mapDimensionsAll("defaultedLabel"),a=e.length;if(a===1){var n=t(r,l,e[0]);return n!=null?n+"":null}else if(a){for(var s=[],f=0;f<e.length;f++)s.push(t(r,l,e[f]));return s.join(" ")}}function v(r,l){var e=r.mapDimensionsAll("defaultedLabel");if(!u(l))return l+"";for(var a=[],n=0;n<e.length;n++){var s=r.getDimensionIndex(e[n]);s>=0&&a.push(l[s])}return a.join(" ")}export{o as a,v as g};
@@ -0,0 +1 @@
1
+ import{b as i,j as s,k as l,I as x,b6 as g,D as f}from"./index-MB-jfQld.js";import{u as j}from"./use-authenticator-sign-in-CRGjzXju.js";function w(e){return j(e)}function b({authenticator:e,onSignIn:t}){var o;const[n,c]=i.useState(""),[r,d]=i.useState(""),{signIn:p,isPending:u}=w(e.name),m=((o=e.options)==null?void 0:o.autoSignup)===!0;return s.jsxs("form",{className:"space-y-5",onSubmit:a=>{if(a.preventDefault(),t){t({account:n,password:r});return}p({account:n,password:r})},children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(l,{htmlFor:`${e.name}-ldap-account`,children:"Account"}),s.jsx(x,{id:`${e.name}-ldap-account`,value:n,onChange:a=>c(a.target.value),autoComplete:"username",required:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(l,{htmlFor:`${e.name}-ldap-password`,children:"Password"}),s.jsx(g,{id:`${e.name}-ldap-password`,value:r,onChange:a=>d(a.target.value),autoComplete:"current-password",required:!0})]}),s.jsx(f,{type:"submit",className:"w-full",disabled:!t&&u,children:!t&&u?"Signing in…":"Sign in"}),m&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"An account will be created automatically after the first successful LDAP sign-in."})]})}export{b as default};
@@ -0,0 +1 @@
1
+ import{aZ as g,b as o,a_ as m,a$ as d,j as t,aT as f,aV as h,aW as x,D as b,b0 as v,r as p}from"./index-MB-jfQld.js";function w(r){const[e]=g(),[i,a]=o.useState(!1),[n,l]=o.useState(),u=o.useMemo(()=>{if(e.get("authenticator")!==r.name)return;const s=e.get("error");return s?new Error(s):void 0},[r.name,e]);return{signIn:o.useCallback(async()=>{l(void 0),a(!0);try{const s=m(e.get("to")||e.get("redirect")||"/"),c=await d.action("oidc","getAuthUrl",{method:"POST",authenticator:r.name,includeRole:!1,withAclMeta:!1,body:{redirect:s}});if(!c)throw new Error("NocoBase did not return an OIDC authorization URL.");window.location.replace(d.resolveUrl(c))}catch(s){l(s instanceof Error?s:new Error("Unable to start OIDC sign-in.")),a(!1)}},[r.name,e]),isPending:i,error:n??u}}function E({authenticator:r,onSignIn:e}){const{signIn:i,isPending:a,error:n}=w(r);return t.jsxs("div",{className:"space-y-3",children:[n&&t.jsxs(f,{variant:"destructive",children:[t.jsx(h,{children:"OIDC sign-in failed"}),t.jsx(x,{children:n.message})]}),t.jsxs(b,{type:"button",variant:"outline",className:"w-full",disabled:!e&&a,onClick:e??i,children:[t.jsx(v,{}),!e&&a?"Redirecting…":p(r.title||r.authTypeTitle||"OIDC")]})]})}export{E as default};
@@ -1,4 +1,4 @@
1
- import{aZ as F,r as t,j as e,w as j,x as A,y as T,A as P,D as i,I as y,T as U,m as k,n as N,o as C,p as S,v as l,ae as R,a3 as ce,ag as de,ah as me,af as he,a_ as M,l as b,a9 as $,ak as _,a$ as J,b3 as ue,b4 as xe,B as pe,b5 as ge,b6 as je}from"./index-C6xNKxpg.js";import{C as B}from"./chat-inline-xpQ9iq4p.js";import{A as D}from"./ai-employee-shortcut-B253WWow.js";import{A as fe}from"./configuration-gate-Dwdq_lxf.js";import{S as ve}from"./switch-DrxImI8F.js";import{P as ye}from"./prompt-card-BsYMW_rq.js";const be=n=>!["nathan","dara"].includes(n.toLowerCase());function we(){var Z,X;const{employees:n}=F(),r=n.filter(a=>be(a.username)),[o,d]=t.useState(((Z=r[0])==null?void 0:Z.username)??((X=n[0])==null?void 0:X.username)??""),[x,c]=t.useState("Customer renewal workspace"),[p,g]=t.useState("Show a customer renewal detail with account health, contract value, renewal date, owner, recent activity, and a working AI conversation beside it."),[m,f]=t.useState("Review renewal risk"),[s,I]=t.useState("Review this customer renewal, identify risks, and recommend the next action."),[h,v]=t.useState(!1),[w,K]=t.useState("shortcut"),[u,z]=t.useState("renewal-detail"),[q,ee]=t.useState("Customer renewal detail"),[V,te]=t.useState("context"),[H,se]=t.useState("update_renewal_plan"),[W,ae]=t.useState("Update the renewal risk level and the visible follow-up note on the page."),[O,ne]=t.useState("ASK"),re=t.useMemo(()=>{var Y;const a=((Y=n.find(le=>le.username===o))==null?void 0:Y.nickname)??o,Q=`{ type: "page-element", id: "${u}", title: "${q}" }`,G=w==="manual"?!1:h,oe={shortcut:`Place an AIEmployeeShortcut in the page header, visually separated from the registered business element. Target the embedded chat controller and configure this task on its tasks prop:
1
+ import{aI as E,b as t,j as e,k as i,I as y,T as U,d as k,e as N,f as C,g as S,i as l,Y as F,$ as ce,a0 as de,a1 as me,_ as ue,aJ as M,B as b,K as $,N as B,a4 as D,aL as _,aK as J,aP as he,aQ as xe,D as pe,aR as ge}from"./index-MB-jfQld.js";import{C as j,a as A,b as T,d as P}from"./card-DuQBOS6A.js";import{A as je}from"./configuration-gate-C08mkkiX.js";import{S as fe}from"./switch-CRL8PmRI.js";import{P as ve}from"./prompt-card-B2RS4nt2.js";import"./prompt-output-DZHRM2ft.js";function ye(n,r){for(const[o,c]of Object.entries(r)){const u=o;n.setValue(u,c,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}}const be=n=>!["nathan","dara"].includes(n.toLowerCase());function we(){var Y,X;const{employees:n}=E(),r=n.filter(a=>be(a.username)),[o,c]=t.useState(((Y=r[0])==null?void 0:Y.username)??((X=n[0])==null?void 0:X.username)??""),[u,d]=t.useState("Customer renewal workspace"),[p,g]=t.useState("Show a customer renewal detail with account health, contract value, renewal date, owner, recent activity, and a working AI conversation beside it."),[m,f]=t.useState("Review renewal risk"),[s,I]=t.useState("Review this customer renewal, identify risks, and recommend the next action."),[h,v]=t.useState(!1),[w,K]=t.useState("shortcut"),[x,z]=t.useState("renewal-detail"),[V,ee]=t.useState("Customer renewal detail"),[q,te]=t.useState("context"),[H,se]=t.useState("update_renewal_plan"),[O,ae]=t.useState("Update the renewal risk level and the visible follow-up note on the page."),[W,ne]=t.useState("ASK"),re=t.useMemo(()=>{var Z;const a=((Z=n.find(le=>le.username===o))==null?void 0:Z.nickname)??o,Q=`{ type: "page-element", id: "${x}", title: "${V}" }`,G=w==="manual"?!1:h,oe={shortcut:`Place an AIEmployeeShortcut in the page header, visually separated from the registered business element. Target the embedded chat controller and configure this task on its tasks prop:
2
2
  - Title: ${m}
3
3
  - User message: ${s}
4
4
  - Auto send: ${G}
@@ -18,19 +18,19 @@ The task should disappear after a conversation starts and must resolve the lates
18
18
 
19
19
  Configure the Shortcut task without message.workContext so it inherits the surrounding context. Keep the registered element and task visibly within the same scoped scene.`,manual:`Do not pre-attach workContext to a Shortcut or preset task. Add a "Pick page element" composer action using useAIPageElementPicker. When the user selects an element, call addWorkContext(item) and focusComposer().
20
20
 
21
- Show "${s}" as a suggested prompt near the chat, but keep it in the composer for review. The user must pick context manually before sending, so this scene must not auto-send.`}[w],ie={context:"Build the primary work area as a polished, read-only business detail view based on the scene brief. Include at least five realistic fields, a status indicator, and a short recent-activity section. Register the complete detail region with useAIPageElementHandle and return its current serializable values from getContext. Reuse handle.ref on the visible element and handle.context wherever the scene needs a context reference.","form-filler":`Build the primary work area with two connected parts: realistic source material and an editable business form derived from the scene brief. Use React Hook Form and register the form with useAIForm using id "${u}", meaningful field definitions, getValues, and setValues.
21
+ Show "${s}" as a suggested prompt near the chat, but keep it in the composer for review. The user must pick context manually before sending, so this scene must not auto-send.`}[w],ie={context:"Build the primary work area as a polished, read-only business detail view based on the scene brief. Include at least five realistic fields, a status indicator, and a short recent-activity section. Register the complete detail region with useAIPageElementHandle and return its current serializable values from getContext. Reuse handle.ref on the visible element and handle.context wherever the scene needs a context reference.","form-filler":`Build the primary work area with two connected parts: realistic source material and an editable business form derived from the scene brief. Use React Hook Form and register the form with useAIForm using id "${x}", meaningful field definitions, getValues, and setValues.
22
22
 
23
23
  Use the fixed built-in formFiller Tool. Do not register Form filler as a custom frontend Tool and do not add formFiller manually to task.skillSettings: the Registry activates it automatically when a registered form context is sent. The Tool may fill declared editable values only and must never submit or save the form. Include a visible reset action and import applyReactHookFormValues from the optional adapters/react-hook-form Registry item for setValues.`,"custom-tool":`Register a custom frontend Tool on the useAIPageElement descriptor:
24
24
  - Name: ${H}
25
- - Business action: ${W}
26
- - Permission: ${O}
25
+ - Business action: ${O}
26
+ - Permission: ${W}
27
27
  - Provide a concise description, JSON inputSchema, and execute(args).
28
28
 
29
29
  Build visible state in the business work area that clearly changes when this Tool succeeds, including before/after values or a status/note update. Keep it separate from the fixed formFiller Tool. The execute function must update only the current React page state and return a serializable result. NocoBase runtime handles ASK / ALLOW execution behavior.
30
- `}[V];return`Build a complete, self-contained NocoBase AI page-context scene.
30
+ `}[q];return`Build a complete, self-contained NocoBase AI page-context scene.
31
31
 
32
32
  Scene
33
- - Title: ${x}
33
+ - Title: ${u}
34
34
  - Business brief: ${p}
35
35
  - Create a dedicated demo page or scene component rather than adding an isolated integration snippet to an unspecified page.
36
36
  - Use realistic fixed sample data so the scene works immediately without additional backend setup.
@@ -44,8 +44,8 @@ AI employee and task
44
44
  - Auto send: ${G}
45
45
 
46
46
  Business context
47
- - Context id: ${u}
48
- - Context title: ${q}
47
+ - Context id: ${x}
48
+ - Context title: ${V}
49
49
  - Register a visible, meaningful business element with this stable id.
50
50
  - Resolve its content at task or message send time so the AI always receives the latest displayed values.
51
51
  - Prefer useAIPageElementHandle so the registered ref and context reference cannot drift apart.
@@ -68,6 +68,6 @@ Implementation requirements
68
68
  - Manual Pick affects only the current composed message.
69
69
  - Preserve NocoBase streaming, conversation history, Tool approval, and resume behavior.
70
70
  - Use shadcn/Base UI components and the existing Registry components.
71
- - Deliver the complete component code, including sample state, context registration, task configuration, chat layout, and all visible business UI.`},[h,V,u,q,o,n,w,p,x,s,m,W,H,O]);return e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-[390px_minmax(0,1fr)]",children:[e.jsxs(j,{className:"gap-0 py-0",children:[e.jsx(A,{className:"border-b py-4",children:e.jsx(T,{children:"Scene settings"})}),e.jsxs(P,{className:"space-y-5 py-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-scene-title",children:"Scene title"}),e.jsx(y,{id:"context-generator-scene-title",value:x,onChange:a=>c(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-scene-brief",children:"Business scene"}),e.jsx(U,{id:"context-generator-scene-brief",value:p,onChange:a=>g(a.target.value),className:"min-h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"AI employee"}),e.jsxs(k,{value:o,onValueChange:a=>a&&d(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsx(S,{children:(r.length?r:n).map(a=>e.jsx(l,{value:a.username,children:a.nickname},a.username))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-task-title",children:"Task title"}),e.jsx(y,{id:"context-generator-task-title",value:m,onChange:a=>f(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-task-message",children:"Task message"}),e.jsx(U,{id:"context-generator-task-message",value:s,onChange:a=>I(a.target.value),className:"min-h-24"})]}),e.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-lg border px-3 py-2.5",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Auto send"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Otherwise fill the composer for review."})]}),e.jsx(ve,{checked:w==="manual"?!1:h,disabled:w==="manual",onCheckedChange:v})]}),w==="manual"?e.jsx("p",{className:"-mt-3 text-xs leading-5 text-muted-foreground",children:"Manual Pick keeps the message in the composer so context can be selected before sending."}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Context integration"}),e.jsxs(k,{value:w,onValueChange:a=>a&&K(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"shortcut",children:"Shortcut task"}),e.jsx(l,{value:"preset",children:"Conversation preset task"}),e.jsx(l,{value:"scope",children:"Scope inheritance"}),e.jsx(l,{value:"manual",children:"Manual Pick"})]})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-id",children:"Context id"}),e.jsx(y,{id:"context-generator-id",value:u,onChange:a=>z(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-title",children:"Context title"}),e.jsx(y,{id:"context-generator-title",value:q,onChange:a=>ee(a.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Page capability"}),e.jsxs(k,{value:V,onValueChange:a=>a&&te(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"context",children:"Context only"}),e.jsx(l,{value:"form-filler",children:"Built-in Form filler"}),e.jsx(l,{value:"custom-tool",children:"Custom frontend Tool"})]})]})]}),V==="custom-tool"?e.jsxs("div",{className:"space-y-4 rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-tool-name",children:"Tool name"}),e.jsx(y,{id:"context-generator-tool-name",value:H,onChange:a=>se(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-tool-action",children:"Business action"}),e.jsx(U,{id:"context-generator-tool-action",value:W,onChange:a=>ae(a.target.value),className:"min-h-20"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Permission"}),e.jsxs(k,{value:O,onValueChange:a=>a&&ne(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"ASK",children:"ASK"}),e.jsx(l,{value:"ALLOW",children:"ALLOW"})]})]})]})]}):null]})]}),e.jsx(ye,{title:"Complete page context scene prompt",description:"Copy this prompt to generate the business page, AI interaction, context binding, and working conversation as one complete scene.",prompt:re})]})}function ke(){return e.jsx(R,{id:"page-element-demo",children:e.jsx(Ne,{})})}function Ne(){const[n,r]=t.useState("Northwind Studio"),[o,d]=t.useState("ops@northwind.test"),[x,c]=t.useState("high"),[p,g]=t.useState(!1),{id:m,addWorkContext:f,focusComposer:s}=ce(),{registeredCount:I,startPicking:h}=de(),v=t.useMemo(()=>[{key:"pick-page-element",label:"Pick page element",icon:e.jsx(me,{}),disabled:I===0,onClick:()=>h({chatId:m,onSelect:u=>{f(u),s()}})},{key:"web-search",label:"Web search",icon:e.jsx(he,{}),active:p,onClick:()=>g(u=>!u)}],[f,m,s,I,h,p]),w=M({id:"customer-intake-form",title:"Customer intake form",kind:"form",getContext:()=>({form:"customer-intake",values:{customerName:n,contactEmail:o,priority:x}})}),K=M({id:"customer-health-summary",title:"Customer health summary",kind:"record-detail",getContext:()=>({resource:"customers",record:{name:n,plan:"Enterprise",healthScore:86,openRequests:3,renewalDate:"2026-09-30"}})});return e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] lg:grid-cols-[minmax(0,1fr)_390px]",children:[e.jsxs("div",{className:"space-y-4 bg-muted/15 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Customer workspace"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"The form and detail card are registered page elements."})]}),e.jsx(b,{variant:"outline",children:"2 selectable elements"})]}),e.jsxs(j,{ref:w,className:"transition-shadow",children:[e.jsxs(A,{children:[e.jsx(T,{children:"Customer intake form"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Update a value, then pick this form to capture its current state."})]}),e.jsxs(P,{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(i,{htmlFor:"page-context-customer-name",children:"Customer name"}),e.jsx(y,{id:"page-context-customer-name",value:n,onChange:u=>r(u.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"page-context-contact-email",children:"Contact email"}),e.jsx(y,{id:"page-context-contact-email",value:o,onChange:u=>d(u.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Priority"}),e.jsxs(k,{value:x,onValueChange:u=>u&&c(u),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"normal",children:"Normal"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]}),e.jsxs(j,{ref:K,className:"transition-shadow",children:[e.jsx(A,{children:e.jsx(T,{children:"Customer health summary"})}),e.jsx(P,{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[["Plan","Enterprise"],["Health score","86 / 100"],["Open requests","3"],["Renewal","Sep 30, 2026"]].map(([u,z])=>e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:u}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:z})]},u))})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card lg:border-l lg:border-t-0",children:e.jsx(B,{className:"h-[560px] rounded-none border-0",children:e.jsx($,{composerActions:v,showConversationToggle:!1,enableAttachments:!0,attachmentActionIndex:1,disclaimer:!1})})})]})})}const L=n=>!["nathan","dara"].includes(n.username.toLowerCase());function Le(){return e.jsx(fe,{children:e.jsx(Ce,{})})}function Ce(){return e.jsxs("div",{className:"space-y-12 pb-12",children:[e.jsx("section",{className:"flex flex-wrap items-start justify-between gap-5 border-b pb-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"secondary",children:"AI Components"}),e.jsx(b,{variant:"outline",children:"Conversation context"})]}),e.jsx("h1",{className:"mt-4 text-3xl font-semibold tracking-[-0.035em]",children:"Page context and frontend tools"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Connect AI employees to live React page state. Start with manual context selection, configure task context, then expose fixed or custom frontend capabilities that can safely update the page."})]})}),e.jsx(E,{eyebrow:"Manual context",title:"Pick page context while composing a message",description:"The user can pick any registered page element from the composer. Its current content is added to this message without changing task configuration.",children:e.jsx(ke,{})}),e.jsx(E,{eyebrow:"Task context · Shortcut",title:"Reference page context from a Shortcut task",description:"The Shortcut task stores a page-element reference in message.workContext and reads its latest content when the user starts the task.",children:e.jsx(Te,{})}),e.jsx(E,{eyebrow:"Task context · Conversation preset",title:"Reference page context from a conversation preset task",description:"The AIChatProvider employeeTasks configuration uses the same message.workContext reference, but exposes the task in the conversation empty state instead of through a Shortcut.",children:e.jsx(Pe,{})}),e.jsx(E,{eyebrow:"Task context · Scope inheritance",title:"Inherit the surrounding page context",description:"A Shortcut or AIChatProvider inside AIPageContextScope inherits that context. A task-level message.workContext still takes precedence when configured.",children:e.jsx(Ie,{})}),e.jsx(E,{eyebrow:"Built-in frontend tool",title:"Fill a registered React form with Form filler",description:"Form filler is registered once by AIProvider. The form exposes its identifier, field schema, live values, and setter through useAIForm; it is not part of the custom frontend Tool catalog.",children:e.jsx(Se,{})}),e.jsx(E,{eyebrow:"Custom frontend tool",title:"Expose a page-specific action to the AI employee",description:"A registered page element can advertise custom Tools through the NocoBase loadFrontendTool and executeFrontendTool protocol. The example uses ASK permission and updates only the local quote preview.",children:e.jsx(Ae,{})}),e.jsx(E,{eyebrow:"Prompt generator",title:"Generate a complete page context scene",description:"Describe the business scene, select the AI employee and task, then generate the full page surface, context binding, conversation layout, and optional frontend capability together.",children:e.jsx(we,{})})]})}function Se(){const{employees:n}=F(),r=n.find(s=>s.username==="form_assistant")??n.find(s=>s.username.toLowerCase()==="dex")??n.filter(L)[0],o=_(),[d,x]=t.useState("Acme Logistics is evaluating the enterprise plan. The main contact is Jordan Lee at jordan.lee@acme.test. This is a high-priority opportunity."),c=ue({defaultValues:{company:"",contactName:"",email:"",priority:"normal"}}),p=t.useMemo(()=>[{name:"company",title:"Company",type:"string",required:!0},{name:"contactName",title:"Contact name",type:"string",required:!0},{name:"email",title:"Email",type:"email"},{name:"priority",title:"Priority",type:"string",enum:["low","normal","high"]}],[]),g=xe({id:"lead-intake-form",title:"Lead intake form",fields:p,getValues:c.getValues,setValues:s=>je(c,s)}),m=t.useMemo(()=>({type:"page-element",id:"lead-intake-form",title:"Lead intake form",kind:"form"}),[]),f=t.useMemo(()=>({title:"Fill lead form",message:{user:`Extract the lead details from the following text and fill the current form. Do not submit it.
71
+ - Deliver the complete component code, including sample state, context registration, task configuration, chat layout, and all visible business UI.`},[h,q,x,V,o,n,w,p,u,s,m,O,H,W]);return e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(j,{className:"gap-0 py-0",children:[e.jsx(A,{className:"border-b py-4",children:e.jsx(T,{children:"Scene settings"})}),e.jsxs(P,{className:"space-y-5 py-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-scene-title",children:"Scene title"}),e.jsx(y,{id:"context-generator-scene-title",value:u,onChange:a=>d(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-scene-brief",children:"Business scene"}),e.jsx(U,{id:"context-generator-scene-brief",value:p,onChange:a=>g(a.target.value),className:"min-h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"AI employee"}),e.jsxs(k,{value:o,onValueChange:a=>a&&c(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsx(S,{children:(r.length?r:n).map(a=>e.jsx(l,{value:a.username,children:a.nickname},a.username))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-task-title",children:"Task title"}),e.jsx(y,{id:"context-generator-task-title",value:m,onChange:a=>f(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-task-message",children:"Task message"}),e.jsx(U,{id:"context-generator-task-message",value:s,onChange:a=>I(a.target.value),className:"min-h-24"})]}),e.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-lg border px-3 py-2.5",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Auto send"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Otherwise fill the composer for review."})]}),e.jsx(fe,{checked:w==="manual"?!1:h,disabled:w==="manual",onCheckedChange:v})]}),w==="manual"?e.jsx("p",{className:"-mt-3 text-xs leading-5 text-muted-foreground",children:"Manual Pick keeps the message in the composer so context can be selected before sending."}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Context integration"}),e.jsxs(k,{value:w,onValueChange:a=>a&&K(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"shortcut",children:"Shortcut task"}),e.jsx(l,{value:"preset",children:"Conversation preset task"}),e.jsx(l,{value:"scope",children:"Scope inheritance"}),e.jsx(l,{value:"manual",children:"Manual Pick"})]})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-id",children:"Context id"}),e.jsx(y,{id:"context-generator-id",value:x,onChange:a=>z(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-title",children:"Context title"}),e.jsx(y,{id:"context-generator-title",value:V,onChange:a=>ee(a.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Page capability"}),e.jsxs(k,{value:q,onValueChange:a=>a&&te(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"context",children:"Context only"}),e.jsx(l,{value:"form-filler",children:"Built-in Form filler"}),e.jsx(l,{value:"custom-tool",children:"Custom frontend Tool"})]})]})]}),q==="custom-tool"?e.jsxs("div",{className:"space-y-4 rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-tool-name",children:"Tool name"}),e.jsx(y,{id:"context-generator-tool-name",value:H,onChange:a=>se(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-tool-action",children:"Business action"}),e.jsx(U,{id:"context-generator-tool-action",value:O,onChange:a=>ae(a.target.value),className:"min-h-20"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Permission"}),e.jsxs(k,{value:W,onValueChange:a=>a&&ne(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"ASK",children:"ASK"}),e.jsx(l,{value:"ALLOW",children:"ALLOW"})]})]})]})]}):null]})]}),e.jsx(ve,{title:"Complete page context scene prompt",description:"Copy this prompt to generate the business page, AI interaction, context binding, and working conversation as one complete scene.",prompt:re})]})}function ke(){return e.jsx(F,{id:"page-element-demo",children:e.jsx(Ne,{})})}function Ne(){const[n,r]=t.useState("Northwind Studio"),[o,c]=t.useState("ops@northwind.test"),[u,d]=t.useState("high"),[p,g]=t.useState(!1),{id:m,addWorkContext:f,focusComposer:s}=ce(),{registeredCount:I,startPicking:h}=de(),v=t.useMemo(()=>[{key:"pick-page-element",label:"Pick page element",icon:e.jsx(me,{}),disabled:I===0,onClick:()=>h({chatId:m,onSelect:x=>{f(x),s()}})},{key:"web-search",label:"Web search",icon:e.jsx(ue,{}),active:p,onClick:()=>g(x=>!x)}],[f,m,s,I,h,p]),w=M({id:"customer-intake-form",title:"Customer intake form",kind:"form",getContext:()=>({form:"customer-intake",values:{customerName:n,contactEmail:o,priority:u}})}),K=M({id:"customer-health-summary",title:"Customer health summary",kind:"record-detail",getContext:()=>({resource:"customers",record:{name:n,plan:"Enterprise",healthScore:86,openRequests:3,renewalDate:"2026-09-30"}})});return e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] lg:grid-cols-[minmax(0,1fr)_390px]",children:[e.jsxs("div",{className:"space-y-4 bg-muted/15 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Customer workspace"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"The form and detail card are registered page elements."})]}),e.jsx(b,{variant:"outline",children:"2 selectable elements"})]}),e.jsxs(j,{ref:w,className:"transition-shadow",children:[e.jsxs(A,{children:[e.jsx(T,{children:"Customer intake form"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Update a value, then pick this form to capture its current state."})]}),e.jsxs(P,{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(i,{htmlFor:"page-context-customer-name",children:"Customer name"}),e.jsx(y,{id:"page-context-customer-name",value:n,onChange:x=>r(x.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"page-context-contact-email",children:"Contact email"}),e.jsx(y,{id:"page-context-contact-email",value:o,onChange:x=>c(x.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Priority"}),e.jsxs(k,{value:u,onValueChange:x=>x&&d(x),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"normal",children:"Normal"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]}),e.jsxs(j,{ref:K,className:"transition-shadow",children:[e.jsx(A,{children:e.jsx(T,{children:"Customer health summary"})}),e.jsx(P,{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[["Plan","Enterprise"],["Health score","86 / 100"],["Open requests","3"],["Renewal","Sep 30, 2026"]].map(([x,z])=>e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:x}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:z})]},x))})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card lg:border-l lg:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{composerActions:v,showConversationToggle:!1,enableAttachments:!0,attachmentActionIndex:1,disclaimer:!1})})})]})})}const L=n=>!["nathan","dara"].includes(n.username.toLowerCase());function Le(){return e.jsx(je,{children:e.jsx(Ce,{})})}function Ce(){return e.jsxs("div",{className:"space-y-12 pb-12",children:[e.jsx("section",{className:"flex flex-wrap items-start justify-between gap-5 border-b pb-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"secondary",children:"AI Components"}),e.jsx(b,{variant:"outline",children:"Conversation context"})]}),e.jsx("h1",{className:"mt-4 text-3xl font-semibold tracking-[-0.035em]",children:"Page context and frontend tools"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Connect AI employees to live React page state. Start with manual context selection, configure task context, then expose fixed or custom frontend capabilities that can safely update the page."})]})}),e.jsx(R,{eyebrow:"Manual context",title:"Pick page context while composing a message",description:"The user can pick any registered page element from the composer. Its current content is added to this message without changing task configuration.",children:e.jsx(ke,{})}),e.jsx(R,{eyebrow:"Task context · Shortcut",title:"Reference page context from a Shortcut task",description:"The Shortcut task stores a page-element reference in message.workContext and reads its latest content when the user starts the task.",children:e.jsx(Te,{})}),e.jsx(R,{eyebrow:"Task context · Conversation preset",title:"Reference page context from a conversation preset task",description:"The AIChatProvider employeeTasks configuration uses the same message.workContext reference, but exposes the task in the conversation empty state instead of through a Shortcut.",children:e.jsx(Pe,{})}),e.jsx(R,{eyebrow:"Task context · Scope inheritance",title:"Inherit the surrounding page context",description:"A Shortcut or AIChatProvider inside AIPageContextScope inherits that context. A task-level message.workContext still takes precedence when configured.",children:e.jsx(Ie,{})}),e.jsx(R,{eyebrow:"Built-in frontend tool",title:"Fill a registered React form with Form filler",description:"Form filler is registered once by AIProvider. The form exposes its identifier, field schema, live values, and setter through useAIForm; it is not part of the custom frontend Tool catalog.",children:e.jsx(Se,{})}),e.jsx(R,{eyebrow:"Custom frontend tool",title:"Expose a page-specific action to the AI employee",description:"A registered page element can advertise custom Tools through the NocoBase loadFrontendTool and executeFrontendTool protocol. The example uses ASK permission and updates only the local quote preview.",children:e.jsx(Ae,{})}),e.jsx(R,{eyebrow:"Prompt generator",title:"Generate a complete page context scene",description:"Describe the business scene, select the AI employee and task, then generate the full page surface, context binding, conversation layout, and optional frontend capability together.",children:e.jsx(we,{})})]})}function Se(){const{employees:n}=E(),r=n.find(s=>s.username==="form_assistant")??n.find(s=>s.username.toLowerCase()==="dex")??n.filter(L)[0],o=D(),[c,u]=t.useState("Acme Logistics is evaluating the enterprise plan. The main contact is Jordan Lee at jordan.lee@acme.test. This is a high-priority opportunity."),d=he({defaultValues:{company:"",contactName:"",email:"",priority:"normal"}}),p=t.useMemo(()=>[{name:"company",title:"Company",type:"string",required:!0},{name:"contactName",title:"Contact name",type:"string",required:!0},{name:"email",title:"Email",type:"email"},{name:"priority",title:"Priority",type:"string",enum:["low","normal","high"]}],[]),g=xe({id:"lead-intake-form",title:"Lead intake form",fields:p,getValues:d.getValues,setValues:s=>ye(d,s)}),m=t.useMemo(()=>({type:"page-element",id:"lead-intake-form",title:"Lead intake form",kind:"form"}),[]),f=t.useMemo(()=>({title:"Fill lead form",message:{user:`Extract the lead details from the following text and fill the current form. Do not submit it.
72
72
 
73
- ${d}`},autoSend:!0}),[d]);return e.jsx(J,{context:m,children:e.jsx(R,{id:"form-filler-context-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[610px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsxs("div",{className:"space-y-5 bg-muted/15 p-4 sm:p-5",children:[e.jsxs(j,{children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Source content"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Edit this text, then ask the AI employee to fill the registered form below."})]}),e.jsx(D,{aiEmployee:r.username,target:o,tasks:[f],label:`Ask ${r.nickname}`,size:34})]})}),e.jsx(P,{children:e.jsx(U,{value:d,onChange:s=>x(s.target.value),className:"min-h-28"})})]}),e.jsxs("form",{ref:g,className:"rounded-xl border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 border-b p-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Lead intake form"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Form filler changes visible values only. It never submits the form."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"secondary",children:"useAIForm"}),e.jsx(pe,{type:"button",variant:"outline",size:"sm",onClick:()=>c.reset({company:"",contactName:"",email:"",priority:"normal"}),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-4 p-5 sm:grid-cols-2",children:[e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-company",children:"Company"}),e.jsx(y,{id:"form-filler-company",...c.register("company")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-contact",children:"Contact name"}),e.jsx(y,{id:"form-filler-contact",...c.register("contactName")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-email",children:"Email"}),e.jsx(y,{id:"form-filler-email",type:"email",...c.register("email")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{children:"Priority"}),e.jsxs(k,{value:c.watch("priority"),onValueChange:s=>s&&c.setValue("priority",s,{shouldDirty:!0,shouldTouch:!0}),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"normal",children:"Normal"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx(B,{className:"h-[610px] rounded-none border-0",children:e.jsx($,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function Ae(){const{employees:n}=F(),r=n.filter(L)[0],o=_(),[d,x]=t.useState(0),[c,p]=t.useState("Not reviewed"),g=24e3,m=g*(1-d/100),f=t.useMemo(()=>[{name:"update_quote_discount",title:"Update quote discount",description:"Update the discount percentage and review note shown on the current quote. This changes the page preview only and does not save the quote.",permission:"ASK",inputSchema:{type:"object",properties:{discountPercent:{type:"number",minimum:0,maximum:30,description:"Discount percentage applied to the quote."},note:{type:"string",description:"Short explanation shown in the review note."}},required:["discountPercent","note"],additionalProperties:!1},execute:h=>{const v=h&&typeof h=="object"&&!Array.isArray(h)?h:{};return typeof v.discountPercent!="number"||v.discountPercent<0||v.discountPercent>30||typeof v.note!="string"?{status:"error",content:"Provide a discount from 0 to 30 and a review note."}:(x(v.discountPercent),p(v.note),{status:"success",content:`Updated the quote preview to a ${v.discountPercent}% discount.`})}}],[]),s=ge({id:"quote-review-card",title:"Quote review",kind:"record-detail",tools:f,getContext:()=>({resource:"quotes",record:{quoteNumber:"QT-2026-1048",customer:"Northwind Studio",baseAmount:g,discountPercent:d,total:m,approvalNote:c}})}),I=t.useMemo(()=>({title:"Apply review discount",message:{user:"Update the current quote preview to use a 12% discount and set the review note to 'Approved for the renewal discussion'."},autoSend:!0}),[]);return e.jsx(J,{context:s.context,children:e.jsx(R,{id:"custom-frontend-tool-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:s.ref,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Quote review"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"QT-2026-1048 · Northwind Studio"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"outline",children:"Custom Tool"}),e.jsx(b,{variant:"secondary",children:"ASK"})]})]})}),e.jsxs(P,{className:"space-y-5",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:[["Base amount",`$${g.toLocaleString()}`],["Discount",`${d}%`],["Preview total",`$${m.toLocaleString()}`]].map(([h,v])=>e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:h}),e.jsx("div",{className:"mt-1 font-medium",children:v})]},h))}),e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Review note"}),e.jsx("div",{className:"mt-1 text-sm",children:c})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t pt-4",children:[e.jsx("p",{className:"max-w-lg text-xs leading-5 text-muted-foreground",children:"The page element registers update_quote_discount. Its full input schema is loaded only when the AI chooses this Tool. Approval is controlled by the ASK permission."}),e.jsx(D,{aiEmployee:r.username,target:o,tasks:[I],label:`Ask ${r.nickname}`,size:34})]})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx(B,{className:"h-[560px] rounded-none border-0",children:e.jsx($,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function Te(){const{employees:n}=F(),r=n.filter(L)[0],o=_(),[d,x]=t.useState("Payment callback reached the order service twelve minutes late."),[c,p]=t.useState("high"),g=t.useMemo(()=>({type:"page-element",id:"selected-support-case",title:"Selected support case"}),[]),m=M({id:"selected-support-case",title:"Selected support case",kind:"editable-record",getContext:()=>({resource:"supportTickets",values:{summary:d,severity:c}})}),f=t.useMemo(()=>({title:"Analyze selected case",message:{user:"Analyze the selected support case.",workContext:[g]},autoSend:!1}),[g]);return e.jsx(R,{id:"shortcut-task-context-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsxs("div",{className:"bg-muted/15 p-4 sm:p-5",children:[e.jsxs(j,{ref:m,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Selected support case"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Change a value before running either task."})]}),e.jsx(b,{variant:"secondary",children:"Task context"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"selected-context-summary",children:"Summary"}),e.jsx(y,{id:"selected-context-summary",value:d,onChange:s=>x(s.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Severity"}),e.jsxs(k,{value:c,onValueChange:s=>s&&p(s),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"medium",children:"Medium"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]}),e.jsxs(j,{className:"mt-5 border-dashed bg-background/80",children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Task shortcut area"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"This button is outside the selected page element. Its task explicitly references “Selected support case”."})]}),e.jsx(b,{variant:"outline",children:"Explicit reference"})]})}),e.jsx(P,{children:e.jsx(D,{aiEmployee:r.username,target:o,tasks:[f],label:"Analyze selected case",size:34})})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx(B,{className:"h-[560px] rounded-none border-0",children:e.jsx($,{showConversationToggle:!1,disclaimer:!1})})})]})})})}function Pe(){const{employees:n}=F(),r=n.filter(L)[0],[o,d]=t.useState("Enterprise workspace expansion"),[x,c]=t.useState("likely"),p=t.useMemo(()=>({type:"page-element",id:"selected-opportunity",title:"Selected opportunity"}),[]),g=M({id:"selected-opportunity",title:"Selected opportunity",kind:"record-detail",getContext:()=>({resource:"opportunities",record:{name:o,forecast:x}})}),m=t.useMemo(()=>({title:"Prepare opportunity brief",message:{user:"Prepare a brief for the selected opportunity.",workContext:[p]},autoSend:!1}),[p]),f=t.useMemo(()=>({[r.username]:[m]}),[r.username,m]);return e.jsx(R,{id:"preset-task-context-demo",defaultEmployee:r.username,employeeTasks:f,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:g,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Selected opportunity"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Change a value, then select the preset task in the chat."})]}),e.jsx(b,{variant:"secondary",children:"Preset task context"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"preset-context-opportunity",children:"Opportunity"}),e.jsx(y,{id:"preset-context-opportunity",value:o,onChange:s=>d(s.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Forecast"}),e.jsxs(k,{value:x,onValueChange:s=>s&&c(s),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"pipeline",children:"Pipeline"}),e.jsx(l,{value:"likely",children:"Likely"}),e.jsx(l,{value:"committed",children:"Committed"})]})]})]}),e.jsx("div",{className:"rounded-lg border bg-background p-3 text-xs leading-5 text-muted-foreground",children:"No Shortcut is used here. “Prepare opportunity brief” comes from AIChatProvider.employeeTasks and appears in the conversation empty state."})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx(B,{className:"h-[560px] rounded-none border-0",children:e.jsx($,{showConversationToggle:!1,disclaimer:!1})})})]})})})}function Ie(){const{employees:n}=F(),r=n.filter(L)[0],o=_(),[d,x]=t.useState("Northwind Finance"),[c,p]=t.useState("negotiation"),g=t.useMemo(()=>({type:"page-element",id:"inherited-renewal-context",title:"Current account renewal"}),[]),m=M({id:"inherited-renewal-context",title:"Current account renewal",kind:"record-detail",getContext:()=>({resource:"accounts",record:{accountName:d,stage:c}})}),f=t.useMemo(()=>({title:"Review current renewal",message:{user:"Review the current account renewal."},autoSend:!1}),[]),s=t.useMemo(()=>({title:"Recommend next renewal action",message:{user:"Recommend the next renewal action."},autoSend:!1}),[]),I=t.useMemo(()=>({[r.username]:[s]}),[r.username,s]);return e.jsx(J,{context:g,children:e.jsx(R,{id:"inherited-context-demo",controller:o,defaultEmployee:r.username,employeeTasks:I,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:m,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Current account renewal"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Shortcut and conversation are inside this context scope."})]}),e.jsx(b,{variant:"outline",children:"Inherited"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"inherited-account-name",children:"Account"}),e.jsx(y,{id:"inherited-account-name",value:d,onChange:h=>x(h.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Renewal stage"}),e.jsxs(k,{value:c,onValueChange:h=>h&&p(h),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"discovery",children:"Discovery"}),e.jsx(l,{value:"negotiation",children:"Negotiation"}),e.jsx(l,{value:"committed",children:"Committed"})]})]})]}),e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Shortcut task without message.workContext"}),e.jsx(D,{aiEmployee:r.username,target:o,tasks:[f],label:"Review current renewal",size:34})]}),e.jsx("div",{className:"rounded-lg border bg-background p-3 text-xs leading-5 text-muted-foreground",children:"The preset task “Recommend next renewal action” also has no task context, so it inherits this scope."})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx(B,{className:"h-[560px] rounded-none border-0",children:e.jsx($,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function E({eyebrow:n,title:r,description:o,children:d}){return e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:n}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:r}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:o})]}),d]})}export{Le as PageContextPage};
73
+ ${c}`},autoSend:!0}),[c]);return e.jsx(J,{context:m,children:e.jsx(F,{id:"form-filler-context-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[610px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsxs("div",{className:"space-y-5 bg-muted/15 p-4 sm:p-5",children:[e.jsxs(j,{children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Source content"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Edit this text, then ask the AI employee to fill the registered form below."})]}),e.jsx(_,{aiEmployee:r.username,target:o,tasks:[f],label:`Ask ${r.nickname}`,size:34})]})}),e.jsx(P,{children:e.jsx(U,{value:c,onChange:s=>u(s.target.value),className:"min-h-28"})})]}),e.jsxs("form",{ref:g,className:"rounded-xl border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 border-b p-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Lead intake form"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Form filler changes visible values only. It never submits the form."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"secondary",children:"useAIForm"}),e.jsx(pe,{type:"button",variant:"outline",size:"sm",onClick:()=>d.reset({company:"",contactName:"",email:"",priority:"normal"}),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-4 p-5 sm:grid-cols-2",children:[e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-company",children:"Company"}),e.jsx(y,{id:"form-filler-company",...d.register("company")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-contact",children:"Contact name"}),e.jsx(y,{id:"form-filler-contact",...d.register("contactName")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-email",children:"Email"}),e.jsx(y,{id:"form-filler-email",type:"email",...d.register("email")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{children:"Priority"}),e.jsxs(k,{value:d.watch("priority"),onValueChange:s=>s&&d.setValue("priority",s,{shouldDirty:!0,shouldTouch:!0}),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"normal",children:"Normal"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[610px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function Ae(){const{employees:n}=E(),r=n.filter(L)[0],o=D(),[c,u]=t.useState(0),[d,p]=t.useState("Not reviewed"),g=24e3,m=g*(1-c/100),f=t.useMemo(()=>[{name:"update_quote_discount",title:"Update quote discount",description:"Update the discount percentage and review note shown on the current quote. This changes the page preview only and does not save the quote.",permission:"ASK",inputSchema:{type:"object",properties:{discountPercent:{type:"number",minimum:0,maximum:30,description:"Discount percentage applied to the quote."},note:{type:"string",description:"Short explanation shown in the review note."}},required:["discountPercent","note"],additionalProperties:!1},execute:h=>{const v=h&&typeof h=="object"&&!Array.isArray(h)?h:{};return typeof v.discountPercent!="number"||v.discountPercent<0||v.discountPercent>30||typeof v.note!="string"?{status:"error",content:"Provide a discount from 0 to 30 and a review note."}:(u(v.discountPercent),p(v.note),{status:"success",content:`Updated the quote preview to a ${v.discountPercent}% discount.`})}}],[]),s=ge({id:"quote-review-card",title:"Quote review",kind:"record-detail",tools:f,getContext:()=>({resource:"quotes",record:{quoteNumber:"QT-2026-1048",customer:"Northwind Studio",baseAmount:g,discountPercent:c,total:m,approvalNote:d}})}),I=t.useMemo(()=>({title:"Apply review discount",message:{user:"Update the current quote preview to use a 12% discount and set the review note to 'Approved for the renewal discussion'."},autoSend:!0}),[]);return e.jsx(J,{context:s.context,children:e.jsx(F,{id:"custom-frontend-tool-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:s.ref,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Quote review"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"QT-2026-1048 · Northwind Studio"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"outline",children:"Custom Tool"}),e.jsx(b,{variant:"secondary",children:"ASK"})]})]})}),e.jsxs(P,{className:"space-y-5",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:[["Base amount",`$${g.toLocaleString()}`],["Discount",`${c}%`],["Preview total",`$${m.toLocaleString()}`]].map(([h,v])=>e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:h}),e.jsx("div",{className:"mt-1 font-medium",children:v})]},h))}),e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Review note"}),e.jsx("div",{className:"mt-1 text-sm",children:d})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t pt-4",children:[e.jsx("p",{className:"max-w-lg text-xs leading-5 text-muted-foreground",children:"The page element registers update_quote_discount. Its full input schema is loaded only when the AI chooses this Tool. Approval is controlled by the ASK permission."}),e.jsx(_,{aiEmployee:r.username,target:o,tasks:[I],label:`Ask ${r.nickname}`,size:34})]})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function Te(){const{employees:n}=E(),r=n.filter(L)[0],o=D(),[c,u]=t.useState("Payment callback reached the order service twelve minutes late."),[d,p]=t.useState("high"),g=t.useMemo(()=>({type:"page-element",id:"selected-support-case",title:"Selected support case"}),[]),m=M({id:"selected-support-case",title:"Selected support case",kind:"editable-record",getContext:()=>({resource:"supportTickets",values:{summary:c,severity:d}})}),f=t.useMemo(()=>({title:"Analyze selected case",message:{user:"Analyze the selected support case.",workContext:[g]},autoSend:!1}),[g]);return e.jsx(F,{id:"shortcut-task-context-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsxs("div",{className:"bg-muted/15 p-4 sm:p-5",children:[e.jsxs(j,{ref:m,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Selected support case"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Change a value before running either task."})]}),e.jsx(b,{variant:"secondary",children:"Task context"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"selected-context-summary",children:"Summary"}),e.jsx(y,{id:"selected-context-summary",value:c,onChange:s=>u(s.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Severity"}),e.jsxs(k,{value:d,onValueChange:s=>s&&p(s),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"medium",children:"Medium"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]}),e.jsxs(j,{className:"mt-5 border-dashed bg-background/80",children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Task shortcut area"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"This button is outside the selected page element. Its task explicitly references “Selected support case”."})]}),e.jsx(b,{variant:"outline",children:"Explicit reference"})]})}),e.jsx(P,{children:e.jsx(_,{aiEmployee:r.username,target:o,tasks:[f],label:"Analyze selected case",size:34})})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})}function Pe(){const{employees:n}=E(),r=n.filter(L)[0],[o,c]=t.useState("Enterprise workspace expansion"),[u,d]=t.useState("likely"),p=t.useMemo(()=>({type:"page-element",id:"selected-opportunity",title:"Selected opportunity"}),[]),g=M({id:"selected-opportunity",title:"Selected opportunity",kind:"record-detail",getContext:()=>({resource:"opportunities",record:{name:o,forecast:u}})}),m=t.useMemo(()=>({title:"Prepare opportunity brief",message:{user:"Prepare a brief for the selected opportunity.",workContext:[p]},autoSend:!1}),[p]),f=t.useMemo(()=>({[r.username]:[m]}),[r.username,m]);return e.jsx(F,{id:"preset-task-context-demo",defaultEmployee:r.username,employeeTasks:f,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:g,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Selected opportunity"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Change a value, then select the preset task in the chat."})]}),e.jsx(b,{variant:"secondary",children:"Preset task context"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"preset-context-opportunity",children:"Opportunity"}),e.jsx(y,{id:"preset-context-opportunity",value:o,onChange:s=>c(s.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Forecast"}),e.jsxs(k,{value:u,onValueChange:s=>s&&d(s),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"pipeline",children:"Pipeline"}),e.jsx(l,{value:"likely",children:"Likely"}),e.jsx(l,{value:"committed",children:"Committed"})]})]})]}),e.jsx("div",{className:"rounded-lg border bg-background p-3 text-xs leading-5 text-muted-foreground",children:"No Shortcut is used here. “Prepare opportunity brief” comes from AIChatProvider.employeeTasks and appears in the conversation empty state."})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})}function Ie(){const{employees:n}=E(),r=n.filter(L)[0],o=D(),[c,u]=t.useState("Northwind Finance"),[d,p]=t.useState("negotiation"),g=t.useMemo(()=>({type:"page-element",id:"inherited-renewal-context",title:"Current account renewal"}),[]),m=M({id:"inherited-renewal-context",title:"Current account renewal",kind:"record-detail",getContext:()=>({resource:"accounts",record:{accountName:c,stage:d}})}),f=t.useMemo(()=>({title:"Review current renewal",message:{user:"Review the current account renewal."},autoSend:!1}),[]),s=t.useMemo(()=>({title:"Recommend next renewal action",message:{user:"Recommend the next renewal action."},autoSend:!1}),[]),I=t.useMemo(()=>({[r.username]:[s]}),[r.username,s]);return e.jsx(J,{context:g,children:e.jsx(F,{id:"inherited-context-demo",controller:o,defaultEmployee:r.username,employeeTasks:I,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:m,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Current account renewal"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Shortcut and conversation are inside this context scope."})]}),e.jsx(b,{variant:"outline",children:"Inherited"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"inherited-account-name",children:"Account"}),e.jsx(y,{id:"inherited-account-name",value:c,onChange:h=>u(h.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Renewal stage"}),e.jsxs(k,{value:d,onValueChange:h=>h&&p(h),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"discovery",children:"Discovery"}),e.jsx(l,{value:"negotiation",children:"Negotiation"}),e.jsx(l,{value:"committed",children:"Committed"})]})]})]}),e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Shortcut task without message.workContext"}),e.jsx(_,{aiEmployee:r.username,target:o,tasks:[f],label:"Review current renewal",size:34})]}),e.jsx("div",{className:"rounded-lg border bg-background p-3 text-xs leading-5 text-muted-foreground",children:"The preset task “Recommend next renewal action” also has no task context, so it inherits this scope."})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function R({eyebrow:n,title:r,description:o,children:c}){return e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:n}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:r}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:o})]}),c]})}export{Le as PageContextPage};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-MB-jfQld.js";import{P as p}from"./prompt-output-DZHRM2ft.js";function x({title:r,description:t,prompt:m}){return o.jsx(p,{title:r,description:t,prompt:m,promptClassName:"max-h-[620px]"})}export{x as P};
@@ -0,0 +1 @@
1
+ import{b as o,j as e,D as f,y as h,bx as y,c as i}from"./index-MB-jfQld.js";import{C as j}from"./card-DuQBOS6A.js";function C({className:c,copiedLabel:n="Copied",copyErrorLabel:p="Clipboard access failed. Select the prompt and copy it manually.",copyLabel:d="Copy prompt",description:l,prompt:t,promptClassName:x,title:m="Generated prompt"}){const[s,a]=o.useState(!1),[u,r]=o.useState(!1);return e.jsxs(j,{className:i("min-w-0 gap-0 overflow-hidden py-0",c),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium",children:m}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l})]}),e.jsxs(f,{type:"button",size:"sm",className:"shrink-0",onClick:async()=>{try{await navigator.clipboard.writeText(t),r(!1),a(!0),window.setTimeout(()=>a(!1),1500)}catch{r(!0)}},children:[s?e.jsx(h,{}):e.jsx(y,{}),s?n:d]})]}),u?e.jsx("p",{className:"border-b px-4 py-2 text-xs text-destructive",children:p}):null,e.jsx("pre",{className:i("max-h-[560px] overflow-auto whitespace-pre-wrap bg-muted/25 p-5 font-mono text-xs leading-5 text-muted-foreground",x),children:t})]})}export{C as P};
@@ -0,0 +1 @@
1
+ import{aZ as m,b as o,a_ as g,a$ as d,j as a,aT as f,aV as h,aW as x,D as b,b0 as v,r as S}from"./index-MB-jfQld.js";function p(r){const[e]=m(),[i,t]=o.useState(!1),[n,l]=o.useState(),u=o.useMemo(()=>{if(e.get("authenticator")!==r.name)return;const s=e.get("error");return s?new Error(s):void 0},[r.name,e]);return{signIn:o.useCallback(async()=>{l(void 0),t(!0);try{const s=g(e.get("to")||e.get("redirect")||"/"),c=await d.action("saml","getAuthUrl",{method:"POST",authenticator:r.name,includeRole:!1,withAclMeta:!1,body:{redirect:s}});if(!c)throw new Error("NocoBase did not return a SAML authorization URL.");window.location.replace(d.resolveUrl(c))}catch(s){l(s instanceof Error?s:new Error("Unable to start SAML sign-in.")),t(!1)}},[r.name,e]),isPending:i,error:n??u}}function j({authenticator:r,onSignIn:e}){const{signIn:i,isPending:t,error:n}=p(r);return a.jsxs("div",{className:"space-y-3",children:[n&&a.jsxs(f,{variant:"destructive",children:[a.jsx(h,{children:"SAML sign-in failed"}),a.jsx(x,{children:n.message})]}),a.jsxs(b,{type:"button",variant:"outline",className:"w-full",disabled:!e&&t,onClick:e??i,children:[a.jsx(v,{}),!e&&t?"Redirecting…":S(r.title||r.authTypeTitle||"SAML")]})]})}export{j as default};
@@ -1 +1 @@
1
- import{_ as m,P as A,H as y,m as I,bA as R}from"./echarts-runtime-CEgJbv68.js";var b=(function(){function u(){this.cx=0,this.cy=0,this.r0=0,this.r=0,this.startAngle=0,this.endAngle=Math.PI*2,this.clockwise=!0}return u})(),w=(function(u){m(s,u);function s(a){var r=u.call(this,a)||this;return r.type="sausage",r}return s.prototype.getDefaultShape=function(){return new b},s.prototype.buildPath=function(a,r){var e=r.cx,i=r.cy,o=Math.max(r.r0||0,0),h=Math.max(r.r,0),d=(h-o)*.5,v=o+d,t=r.startAngle,n=r.endAngle,c=r.clockwise,l=Math.PI*2,M=c?n-t<l:t-n<l;M||(t=n-(c?l:-l));var f=Math.cos(t),g=Math.sin(t),P=Math.cos(n),S=Math.sin(n);M?(a.moveTo(f*o+e,g*o+i),a.arc(f*v+e,g*v+i,d,-Math.PI+t,t,!c)):a.moveTo(f*h+e,g*h+i),a.arc(e,i,h,t,n,!c),a.arc(P*v+e,S*v+i,d,n-Math.PI*2,n-Math.PI,!c),o!==0&&a.arc(e,i,o,n,t,c)},s})(A);function k(u,s,a){var r=u.get("borderRadius");if(r==null)return a?{cornerRadius:0}:null;y(r)||(r=[r,r,r,r]);var e=Math.abs(s.r||0-s.r0||0);return{cornerRadius:I(r,function(i){return R(i,e)})}}export{w as S,k as g};
1
+ import{_ as m,P as y,H as A,m as I,aq as R}from"./echarts-runtime-D8kXn6ME.js";var p=(function(){function u(){this.cx=0,this.cy=0,this.r0=0,this.r=0,this.startAngle=0,this.endAngle=Math.PI*2,this.clockwise=!0}return u})(),b=(function(u){m(s,u);function s(a){var r=u.call(this,a)||this;return r.type="sausage",r}return s.prototype.getDefaultShape=function(){return new p},s.prototype.buildPath=function(a,r){var e=r.cx,i=r.cy,o=Math.max(r.r0||0,0),h=Math.max(r.r,0),d=(h-o)*.5,v=o+d,t=r.startAngle,n=r.endAngle,c=r.clockwise,l=Math.PI*2,M=c?n-t<l:t-n<l;M||(t=n-(c?l:-l));var f=Math.cos(t),g=Math.sin(t),P=Math.cos(n),S=Math.sin(n);M?(a.moveTo(f*o+e,g*o+i),a.arc(f*v+e,g*v+i,d,-Math.PI+t,t,!c)):a.moveTo(f*h+e,g*h+i),a.arc(e,i,h,t,n,!c),a.arc(P*v+e,S*v+i,d,n-Math.PI*2,n-Math.PI,!c),o!==0&&a.arc(e,i,o,n,t,c)},s})(y);function k(u,s,a){var r=u.get("borderRadius");if(r==null)return a?{cornerRadius:0}:null;A(r)||(r=[r,r,r,r]);var e=Math.abs(s.r||0-s.r0||0);return{cornerRadius:I(r,function(i){return R(i,e)})}}export{b as S,k as g};
@@ -0,0 +1,47 @@
1
+ import{b as n,a7 as ge,a8 as St,a9 as tt,aa as st,ab as se,j as e,ac as It,ad as at,ae as Pt,af as At,ag as nt,ah as xe,ai as Mt,aj as Tt,ak as rt,al as ot,am as fe,an as Et,ao as Rt,ap as $t,c as le,C as Bt,aq as Ut,ar as it,as as Dt,at as Vt,au as Wt,av as Ft,aw as Fe,ax as zt,ay as Ot,az as Kt,aA as Lt,aB as ze,aC as qt,aD as Gt,aE as Ht,aF as _t,aG as Jt,aH as Xt,y as Yt,aI as lt,a4 as Qt,aJ as Zt,B as Se,aK as es,aL as Pe,Y as Oe,K as Ke,N as Le,a0 as ts,aM as Ie,d as Q,e as Z,f as ee,g as te,i as W,I as qe,D as pe,P as ss,G as as,h as ns,aN as rs,T as Ge,a1 as os,aO as is}from"./index-MB-jfQld.js";import{C as he,a as Ae,b as Me,d as Te}from"./card-DuQBOS6A.js";import{u as ls,S as He}from"./switch-CRL8PmRI.js";import{P as ds}from"./prompt-card-B2RS4nt2.js";import{A as cs}from"./configuration-gate-C08mkkiX.js";import"./prompt-output-DZHRM2ft.js";const us=n.createContext({disabled:!1});function ms(){return n.useContext(us)}const ps=n.createContext(void 0);function hs(s=!0){const a=n.useContext(ps);if(a===void 0&&!s)throw new Error(ge(3));return a}const dt=n.createContext(void 0);function ct(){const s=n.useContext(dt);if(s===void 0)throw new Error(ge(10));return s}const xs={value:()=>null},fs=n.forwardRef(function(a,l){const{render:x,className:P,disabled:m=!1,hiddenUntilFound:h,keepMounted:d,loopFocus:v,onValueChange:f,multiple:M=!1,orientation:k="vertical",value:T,defaultValue:j,style:S,...y}=a,E=St(),I=n.useMemo(()=>{if(T===void 0)return j??[]},[T,j]),C=n.useRef([]),[c,w]=tt({controlled:T,default:I,name:"Accordion",state:"value"}),V=st(($,K,g)=>{if(M)if(K){const N=c.slice();if(N.push($),f==null||f(N,g),g.isCanceled)return;w(N)}else{const N=c.filter(q=>q!==$);if(f==null||f(N,g),g.isCanceled)return;w(N)}else{const N=c[0]===$?[]:[$];if(f==null||f(N,g),g.isCanceled)return;w(N)}}),b=n.useMemo(()=>({value:c,disabled:m,orientation:k}),[c,m,k]),R=n.useMemo(()=>({disabled:m,handleValueChange:V,hiddenUntilFound:h??!1,keepMounted:d??!1,state:b,value:c}),[m,V,h,d,b,c]),p=se("div",a,{state:b,ref:l,props:[{dir:E},y],stateAttributesMapping:xs});return e.jsx(dt.Provider,{value:R,children:e.jsx(It,{elementsRef:C,children:p})})}),ut=n.createContext(void 0);function Ee(){const s=n.useContext(ut);if(s===void 0)throw new Error(ge(9));return s}let gs=(function(s){return s.index="data-index",s.disabled="data-disabled",s.open="data-open",s})({});const Re={...Pt,index:s=>Number.isInteger(s)?{[gs.index]:String(s)}:null,...at,value:()=>null},bs=n.forwardRef(function(a,l){const{className:x,disabled:P=!1,onOpenChange:m,render:h,value:d,style:v,...f}=a,{ref:M,index:k}=At(),T=nt(l,M),{disabled:j,handleValueChange:S,state:y,value:E}=ct(),I=xe(),C=d??I,c=P||j,w=n.useMemo(()=>{if(!E)return!1;for(let B=0;B<E.length;B+=1)if(E[B]===C)return!0;return!1},[E,C]),V=st((B,F)=>{m==null||m(B,F),!F.isCanceled&&S(C,B,F)}),b=Mt({open:w,onOpenChange:V,disabled:c}),R=n.useMemo(()=>({open:b.open,disabled:b.disabled,transitionStatus:b.transitionStatus}),[b.open,b.disabled,b.transitionStatus]),p=n.useMemo(()=>({...b,onOpenChange:V,state:R}),[b,R,V]),$=n.useMemo(()=>({...y,hidden:!w&&!b.mounted,index:k,disabled:c,open:w}),[b.mounted,c,k,w,y]),K=xe(),[g,N]=n.useState(),q=n.useMemo(()=>({open:w,state:$,setTriggerId:N,triggerId:g??K}),[K,w,$,N,g]),G=se("div",a,{state:$,ref:T,props:f,stateAttributesMapping:Re});return e.jsx(Tt.Provider,{value:p,children:e.jsx(ut.Provider,{value:q,children:G})})}),ks=n.forwardRef(function(a,l){const{render:x,className:P,style:m,...h}=a,{state:d}=Ee();return se("h3",a,{state:d,ref:l,props:h,stateAttributesMapping:Re})}),vs=n.forwardRef(function(a,l){const{disabled:x,className:P,id:m,render:h,nativeButton:d=!0,style:v,...f}=a,{panelId:M,open:k,handleTrigger:T,disabled:j}=rt(),S=x||j,{getButtonProps:y,buttonRef:E}=ot({disabled:S,focusableWhenDisabled:!0,native:d}),{state:I,setTriggerId:C,triggerId:c}=Ee();return fe(()=>(m&&C(m),()=>{C(void 0)}),[m,C]),se("button",a,{state:I,ref:[l,E],props:[{"aria-controls":k?M:void 0,"aria-expanded":k,id:c,onClick:T},f,y],stateAttributesMapping:Et})});let _e=(function(s){return s.accordionPanelHeight="--accordion-panel-height",s.accordionPanelWidth="--accordion-panel-width",s})({});const js=n.forwardRef(function(a,l){const{className:x,hiddenUntilFound:P,keepMounted:m,id:h,render:d,style:v,...f}=a,{hiddenUntilFound:M,keepMounted:k}=ct(),{mounted:T,onOpenChange:j,open:S,panelId:y,setMounted:E,setOpen:I,setPanelIdState:C,transitionStatus:c}=rt(),w=P??M,V=m??k;fe(()=>{if(h)return C(h),()=>{C(void 0)}},[h,C]);const{height:b,props:R,ref:p,shouldPreventOpenAnimation:$,shouldRender:K,transitionStatus:g,width:N}=Rt({externalRef:l,hiddenUntilFound:w,id:h??y,keepMounted:V,mounted:T,onOpenChange:j,open:S,setMounted:E,setOpen:I,transitionStatus:c}),{state:q,triggerId:G}=Ee(),B={...q,transitionStatus:g},F=$t(v,B),ae=se("div",{...a,style:void 0},{state:B,ref:p,props:[R,{"aria-labelledby":G,role:"region",style:{[_e.accordionPanelHeight]:b===void 0?"auto":`${b}px`,[_e.accordionPanelWidth]:N===void 0?"auto":`${N}px`}},f,F?{style:F}:void 0,$?{style:{animationName:"none"}}:void 0],stateAttributesMapping:Re});return K?ae:null});function ys({className:s,...a}){return e.jsx(fs,{"data-slot":"accordion",className:le("flex w-full flex-col",s),...a})}function ws({className:s,...a}){return e.jsx(bs,{"data-slot":"accordion-item",className:le("not-last:border-b",s),...a})}function Cs({className:s,children:a,...l}){return e.jsx(ks,{className:"flex",children:e.jsxs(vs,{"data-slot":"accordion-trigger",className:le("group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",s),...l,children:[a,e.jsx(Bt,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden"}),e.jsx(Ut,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline"})]})})}function Ns({className:s,children:a,...l}){return e.jsx(js,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up",...l,children:e.jsx("div",{className:le("h-(--accordion-panel-height) pt-0 pb-2.5 data-ending-style:h-0 data-starting-style:h-0 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",s),children:a})})}function Ss(s){if(!s)return null;for(const a of s.elements){const l=a.tagName;if(l==="BUTTON"||l==="INPUT"){const x=a;if(x.type==="submit")return x}}return null}let Je=(function(s){return s.checked="data-checked",s.unchecked="data-unchecked",s.indeterminate="data-indeterminate",s.disabled="data-disabled",s.readonly="data-readonly",s.required="data-required",s.valid="data-valid",s.invalid="data-invalid",s.touched="data-touched",s.dirty="data-dirty",s.filled="data-filled",s.focused="data-focused",s})({});function mt(s){return n.useMemo(()=>({checked(a){return s.indeterminate?{}:a?{[Je.checked]:""}:{[Je.unchecked]:""}},...it}),[s.indeterminate])}const pt=n.createContext(void 0);function Is(){const s=n.useContext(pt);if(s===void 0)throw new Error(ge(14));return s}const Ps="data-parent",As=n.forwardRef(function(a,l){const{checked:x,className:P,defaultChecked:m=!1,"aria-labelledby":h,disabled:d=!1,form:v,id:f,indeterminate:M=!1,inputRef:k,name:T,onCheckedChange:j,parent:S=!1,readOnly:y=!1,render:E,required:I=!1,uncheckedValue:C,value:c,nativeButton:w=!1,style:V,...b}=a,{clearErrors:R}=Dt(),{disabled:p,name:$,setDirty:K,setFilled:g,setFocused:N,setTouched:q,state:G,validationMode:B,validityData:F,validation:ae}=Vt(),de=ms(),{labelId:ce,controlId:t,registerControlId:o,getDescriptionProps:r}=Wt(),i=hs(),z=i==null?void 0:i.parent,H=z&&i.allValues,A=p||de.disabled||(i==null?void 0:i.disabled)||d,ne=$??T,U=c??ne,$e=xe(),xt=xe();let _=t;H?_=S?xt:`${z.id}-${U}`:f&&(_=f);let be={};H&&(S?be=i.parent.getParentProps():U&&(be=i.parent.getChildProps(U)));const{checked:Be=x,indeterminate:ft=M,onCheckedChange:ke,...gt}=be,re=i==null?void 0:i.value,Ue=i==null?void 0:i.setValue,De=i==null?void 0:i.defaultValue,ve=n.useRef(null),ue=Ft(()=>Symbol("checkbox-control")),je=n.useRef(!1),{getButtonProps:bt,buttonRef:kt}=ot({disabled:A,native:w}),oe=(i==null?void 0:i.validation)??ae,[O,vt]=tt({controlled:U&&re&&!S?re.includes(U):Be,default:U&&De&&!S?De.includes(U):m,name:"Checkbox",state:"checked"}),ye=H?!!Be:O,ie=H&&ft||M;fe(()=>{o!==Fe&&(je.current=!0,o(ue.current,_))},[_,o,ue]),n.useEffect(()=>{const u=ue.current;return()=>{!je.current||o===Fe||(je.current=!1,o(u,void 0))}},[o,ue]),zt(ve,$e,O,void 0,!i&&!A,T);const J=n.useRef(null),jt=nt(k,J,oe.inputRef,oe.registerInput),yt=ls(h,ce,J,!w,_??void 0);fe(()=>{J.current&&(J.current.indeterminate=ie,O&&g(!0))},[O,ie,g]),Ot(O,()=>{i||(R(ne),g(O),K(O!==F.initialValue),oe.change(O))});const wt=Kt({checked:O,disabled:A,form:v,name:S?void 0:ne,id:w?void 0:_??void 0,required:I,ref:jt,style:ne?qt:Gt,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(u){if(u.nativeEvent.defaultPrevented)return;if(y){u.preventDefault();return}const L=u.currentTarget.checked,X=Ht(_t,u.nativeEvent);if(j==null||j(L,X),!X.isCanceled&&(ke==null||ke(L,X),!X.isCanceled&&(vt(L),U&&re&&Ue&&!S&&!H))){const Y=L?[...re,U]:re.filter(me=>me!==U);Ue(Y,X)}},onFocus(){var u;(u=ve.current)==null||u.focus()}},c!==void 0?{value:(i?O&&c:c)||""}:Lt,r,u=>oe.getValidationProps(A,u));n.useEffect(()=>{if(!z||!U)return;const u=z.disabledStatesRef.current;return u.set(U,A),()=>{u.delete(U)}},[z,A,U]);const we=n.useMemo(()=>({...G,checked:ye,disabled:A,readOnly:y,required:I,indeterminate:ie}),[G,ye,A,y,I,ie]),Ct=mt(we),Nt=se("span",a,{state:we,ref:[kt,ve,l,i==null?void 0:i.registerControlRef],props:[{id:w?_??void 0:$e,role:"checkbox","aria-checked":ie?"mixed":ye,"aria-readonly":y||void 0,"aria-required":I||void 0,"aria-labelledby":yt,[Ps]:S?"":void 0,onFocus(){A||N(!0)},onBlur(){const u=J.current;u&&(q(!0),N(!1),B==="onBlur"&&oe.commit(i?re:u.checked))},onKeyDown(u){var Ve;if(u.key!=="Enter"||(u.preventBaseUIHandler(),u.defaultPrevented))return;const L=((Ve=J.current)==null?void 0:Ve.form)??null,X=u.currentTarget,Y=u.nativeEvent,me=u.preventDefault,Ce=Y.preventDefault;let Ne=!1;u.preventDefault=()=>{Ne=!0,me.call(u)},Y.preventDefault=()=>{Ne=!0,Ce.call(Y)},Ce.call(Y),ze(X).queueMicrotask(()=>{var We;u.preventDefault=me,Y.preventDefault=Ce,Ne||(We=Ss(L))==null||We.click()})},onClick(u){if(y||A)return;u.preventDefault();const L=J.current;L&&L.dispatchEvent(new(ze(L)).PointerEvent("click",{bubbles:!0,shiftKey:u.shiftKey,ctrlKey:u.ctrlKey,altKey:u.altKey,metaKey:u.metaKey}))}},b,gt,bt,r,u=>oe.getValidationProps(A,u)],stateAttributesMapping:Ct});return e.jsxs(pt.Provider,{value:we,children:[Nt,!O&&!i&&ne&&!S&&C!==void 0&&e.jsx("input",{type:"hidden",form:v,name:ne,value:C,disabled:A}),e.jsx("input",{...wt,suppressHydrationWarning:!0})]})}),Ms=n.forwardRef(function(a,l){const{render:x,className:P,style:m,keepMounted:h=!1,...d}=a,v=Is(),f=v.checked||v.indeterminate,{mounted:M,transitionStatus:k,setMounted:T}=Jt(f),j=n.useRef(null),S={...v,transitionStatus:k};Xt({open:f,ref:j,onComplete(){f||T(!1)}});const E={...mt(v),...at,...it},I=h||M,C=se("span",a,{ref:[l,j],state:S,stateAttributesMapping:E,props:d});return I?C:null});function Ts({className:s,...a}){return e.jsx(As,{"data-slot":"checkbox",className:le("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",s),...a,children:e.jsx(Ms,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:e.jsx(Yt,{})})})}const Xe={title:"Analyze this ticket",message:{system:"Review the current ticket, identify operational risk, and suggest the next action.",user:"Analyze the current ticket and recommend the next action."},autoSend:!0,model:{llmService:"openai",model:"gpt-5"},webSearch:!0,skillSettings:{skills:["ticket-analysis"],tools:["inspect-record"]}},Ye={title:"Draft a customer reply",message:{user:"Draft a concise customer reply for the current ticket."},autoSend:!1,skillSettings:{skills:["response-drafting"],tools:["inspect-record"]}},Qe={title:"Review operational risk",message:{system:"Review the current queue, identify operational risk, and prioritize the next actions.",user:"Review the current ticket queue and identify operational risk."},autoSend:!1,skillSettings:{skills:["ticket-analysis"],tools:["inspect-record"]}},D={id:"TK-1042",title:"Payment callback delayed",status:"Open",requester:"Northwind Finance",createdAt:"July 22, 2026 · 09:42",description:"Payment succeeded, but the callback reached the order service twelve minutes late. The customer needs an impact assessment and a response before the next settlement window."},Es=[D,{id:"TK-1041",title:"Unable to update profile"},{id:"TK-1038",title:"Invoice export formatting"}],ht=s=>!["nathan","dara"].includes(s.username.toLowerCase());function Ks(){return e.jsx(cs,{children:e.jsx(Rs,{})})}function Rs(){const{employees:s}=lt(),a=Qt(),l=s.filter(ht),x=l.find(v=>v.username.toLowerCase()==="atlas")??l[0],P=l.find(v=>v.username!==x.username)??x,m=l.find(v=>v.username.toLowerCase()==="atlas")??l.find(v=>v.username!==x.username)??x,h=Zt({id:"support-ticket-detail",title:`${D.id} · ${D.title}`,kind:"record-detail",getContext:()=>({resource:"supportTickets",record:D})}),d=n.useMemo(()=>({[x.username]:[Xe,Ye],...P.username!==x.username?{[P.username]:[Qe]}:{}}),[x.username,P.username]);return e.jsxs("div",{className:"space-y-12 pb-12",children:[e.jsx("section",{className:"flex flex-wrap items-start justify-between gap-5 border-b pb-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{variant:"secondary",children:"AI Components"}),e.jsx(Se,{variant:"outline",children:"Employee capability"})]}),e.jsx("h1",{className:"mt-4 text-3xl font-semibold tracking-[-0.035em]",children:"Employee tasks"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Bind reusable tasks to AI employees. Tasks can appear directly inside a chat when the employee is selected, or be triggered from contextual buttons elsewhere in the application."})]})}),e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Scenario 1 · Multiple tasks"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Trigger employee tasks from a business record"}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:"The Shortcut component can still sit in a detail header and provide the current record as work context. Opening it shows the configured analysis and reply tasks below the employee greeting."})]}),e.jsx(es,{context:{type:"page-element",id:"support-ticket-detail",title:`${D.id} · ${D.title}`},children:e.jsxs(he,{ref:h,className:"gap-0 overflow-hidden py-0",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b p-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:D.id}),e.jsx(Se,{variant:"outline",children:D.status})]}),e.jsx("h3",{className:"mt-2 text-lg font-semibold tracking-tight",children:D.title})]}),e.jsx(Pe,{aiEmployee:x.username,tasks:[Xe,Ye],label:`Ask ${x.nickname}`,size:34})]}),e.jsxs("div",{className:"grid gap-5 p-5 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Requester"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:D.requester})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Created"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:D.createdAt})]})]}),e.jsxs("div",{className:"border-t p-5",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6",children:D.description})]})]})})]}),e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Scenario 2 · Explicit target"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Send a shortcut task to a designated embedded chat"}),e.jsxs("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:["The shortcut receives the embedded chat Controller directly. Its Provider explicitly configures ",m.nickname," and an employee task set. It does not need a global target ID and cannot accidentally trigger another conversation on the same page."]})]}),e.jsx(Oe,{id:"shortcut-embedded-chat",controller:a,defaultEmployee:m.username,children:e.jsxs("div",{className:"grid items-stretch gap-5 xl:grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs(he,{children:[e.jsx(Ae,{children:e.jsx(Me,{className:"text-base",children:"Risk review workspace"})}),e.jsxs(Te,{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:"The embedded chat starts without preset tasks. Clicking the Shortcut injects “Review operational risk” into this specific conversation, where the user can choose it before the request is placed in the composer."}),e.jsx(Pe,{aiEmployee:m.username,target:a,tasks:[Qe],auto:!1,context:[{type:"table",title:"Open ticket queue",content:Es}],label:`Ask ${m.nickname}`,size:36})]})]}),e.jsx(Ke,{className:"h-[560px] min-h-0",children:e.jsx(Le,{})})]})})]}),e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Scenario 3 · Chat-bound tasks"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Show tasks when the selected employee changes"}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:"This conversation window binds task lists directly to business AI employees. Starting a new conversation or switching employees in the composer immediately replaces the empty-state tasks. Employees without a binding keep the normal greeting-only state."})]}),e.jsxs("div",{className:"grid items-stretch gap-5 xl:grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs(he,{children:[e.jsx(Ae,{children:e.jsx(Me,{className:"text-base",children:"Employee task bindings"})}),e.jsxs(Te,{className:"space-y-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/25 p-3 font-mono text-xs leading-5",children:[e.jsx("div",{children:x.username}),e.jsx("div",{className:"pl-4",children:"Analyze this ticket"}),e.jsx("div",{className:"pl-4",children:"Draft a customer reply"}),P.username!==x.username?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2",children:P.username}),e.jsx("div",{className:"pl-4",children:"Review operational risk"})]}):null]}),e.jsx("p",{children:"Switch employees from the bottom of the chat to preview each configured task list."}),e.jsxs("p",{children:["The same ",e.jsx("code",{children:"employeeTasks"})," parameter works in page, embedded, side-panel, dialog, and mobile containers."]})]})]}),e.jsx(Oe,{id:"employee-task-scenario-chat",defaultEmployee:x.username,employeeTasks:d,children:e.jsx(Ke,{className:"h-[620px] min-h-0",children:e.jsx(Le,{})})})]})]}),e.jsx(Us,{embeddedController:a})]})}const $s=[{value:"ticket-analysis",label:"Ticket analysis"},{value:"response-drafting",label:"Response drafting"},{value:"workflow-design",label:"Workflow design"}],Bs=[{value:"inspect-record",label:"Inspect record"},{value:"search-records",label:"Search records"},{value:"update-record",label:"Update record"}],Ze=[{id:"analyze-ticket",employee:"",title:"Analyze this ticket",background:"Identify operational risk and recommend the next action.",userMessage:"Analyze the current ticket and recommend the next action.",autoSend:!0,workContext:[{type:"page-element",id:"support-ticket-detail",title:`${D.id} · ${D.title}`}],model:"gpt-5",webSearch:!0,skillsMode:"custom",skills:["ticket-analysis"],toolsMode:"custom",tools:["inspect-record"]},{id:"draft-reply",employee:"",title:"Draft a customer reply",background:"Write a concise and helpful response using the ticket context.",userMessage:"Draft a customer reply for the current ticket.",autoSend:!1,workContext:[],model:"default",webSearch:!1,skillsMode:"custom",skills:["response-drafting"],toolsMode:"preset",tools:[]}];function Us({embeddedController:s}){var B,F,ae,de,ce;const{employees:a,models:l}=lt(),{registeredCount:x,startPicking:P}=ts(),m=a.filter(ht),h=m.find(t=>t.username.toLowerCase()==="atlas")??m[0],[d,v]=n.useState("shortcut"),[f,M]=n.useState("the ticket detail header actions"),[k,T]=n.useState(h.username),[j,S]=n.useState(h.username),[y,E]=n.useState("global-side-panel"),[I,C]=n.useState("embedded"),[c,w]=n.useState(()=>Ze.map(t=>({...t,employee:h.username}))),[V,b]=n.useState(Ze[0].id),R=d==="chat-tasks"?c.filter(t=>t.employee===j):c,p=R.find(t=>t.id===V)??R[0],$=n.useMemo(()=>c.map(t=>{const o=Ie(l,t.model),r=t.skillsMode==="custom"||t.toolsMode==="custom";return{title:t.title,message:{system:t.background||void 0,user:t.userMessage||void 0,workContext:t.workContext.length?t.workContext:void 0},autoSend:t.autoSend,model:o?{llmService:o.llmService,model:o.value}:void 0,webSearch:t.webSearch,skillSettings:r?{skills:t.skillsMode==="custom"?t.skills:void 0,tools:t.toolsMode==="custom"?t.tools:void 0}:void 0}}),[l,c]),K=n.useMemo(()=>{const t=(r,i)=>{var H;const z=r.model==="default"?"Use the AI employee default":((H=l.find(A=>A.value===r.model))==null?void 0:H.label)??r.model;return`${i+1}. ${r.title}
2
+ - Background: ${r.background||"None"}
3
+ - Default user message: ${r.userMessage||"None"}
4
+ - Send automatically: ${r.autoSend}
5
+ - Work context: ${r.workContext.map(A=>A.title??A.id).join(", ")||"Inherit the surrounding context"}
6
+ - Model: ${z}
7
+ - Web search: ${r.webSearch}
8
+ - Skills: ${r.skillsMode==="preset"?"Use the AI employee defaults":r.skills.join(", ")||"Disabled"}
9
+ - Tools: ${r.toolsMode==="preset"?"Use the AI employee defaults":r.tools.join(", ")||"Disabled"}`},o=d==="chat-tasks"?Array.from(new Set(c.map(r=>r.employee))).map(r=>{const i=c.filter(z=>z.employee===r);return`AI employee: ${r}
10
+ ${i.map(t).join(`
11
+ `)}`}).join(`
12
+
13
+ `):c.map(t).join(`
14
+ `);if(d==="chat-tasks"){const r={page:"a dedicated page",embedded:"an embedded block in the page","side-panel":"a push side panel",dialog:"a dialog"}[I];return`Add an AI conversation window to ${f} using ${r}.
15
+
16
+ Employee task bindings:
17
+ ${o}
18
+
19
+ Implementation requirements:
20
+ - Render AIChatWindow in the selected container and wrap it with AIChatProvider.
21
+ - Configure AIChatProvider with employeeTasks grouped by AI employee username.
22
+ - When the user starts a new conversation or switches AI employees, show the matching tasks below that employee’s greeting.
23
+ - Employees without configured tasks must keep the greeting-only empty state.
24
+ - Selecting a task must respect autoSend: either send immediately or fill the composer for review.
25
+ - Resolve task message.workContext when the task starts so selected page elements use their latest values.
26
+ - When a task has no message.workContext, inherit the context surrounding the Shortcut or AIChatProvider.
27
+ - Preserve every task’s background prompt, model override, Web search setting, Skills, Tools, and work context.
28
+ - Keep the employeeTasks capability independent of the container so the same configuration works in page, embedded, side-panel, dialog, and mobile layouts.
29
+ - Use the existing AIProvider/AIChatProvider runtime with shadcn/Base UI components.`}return`Add an AI employee shortcut to ${f}.
30
+
31
+ Shortcut configuration:
32
+ - AI employee: ${k}
33
+ - Target conversation: ${y==="global-side-panel"?"the default global push side panel":"the embedded chat rendered in this page section"}
34
+ - Include the current record or form values as work context.
35
+
36
+ Tasks:
37
+ ${o}
38
+
39
+ Implementation requirements:
40
+ - Use AIEmployeeShortcut and pass all configured tasks through its tasks prop.
41
+ - When multiple tasks are provided, open a new conversation and show the tasks below the AI employee greeting.
42
+ - Selecting a task must respect that task's autoSend setting: either send immediately or fill the composer for review.
43
+ - Resolve task message.workContext when the task starts so selected page elements use their latest values.
44
+ - When a task has no message.workContext, inherit the context surrounding the Shortcut or AIChatProvider.
45
+ - Preserve each task's background prompt, work context, model override, Web search setting, Skills, and Tools.
46
+ - ${y==="global-side-panel"?"Use the global AI chat controller; do not pass a target prop.":"Create a dedicated controller with useAIChatController(), bind it to the embedded AIChatProvider, and pass it through the shortcut target prop."}
47
+ - Use the existing AIProvider and AIChatProvider runtime with shadcn/Base UI components.`},[I,k,d,f,l,y,c]),g=t=>{p&&w(o=>o.map(r=>r.id===p.id?{...r,...t}:r))},N=()=>{const t=`task-${crypto.randomUUID()}`;w(o=>[...o,{id:t,employee:d==="chat-tasks"?j:k,title:`Task ${o.length+1}`,background:"",userMessage:"",autoSend:!1,workContext:[],model:"default",webSearch:!1,skillsMode:"preset",skills:[],toolsMode:"preset",tools:[]}]),b(t)},q=t=>{if(c.length===1)return;const o=c.filter(r=>r.id!==t);if(w(o),V===t){const r=d==="chat-tasks"?o.find(i=>i.employee===j):o[0];b((r==null?void 0:r.id)??"")}},G=(t,o,r)=>{if(!p)return;const i=p[t];g({[t]:r?[...i,o]:i.filter(z=>z!==o)})};return e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Employee tasks prompt"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Generate an integration prompt"}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Choose whether tasks are exposed through a contextual Shortcut or directly by the selected employee in a chat. Both modes share the same task, model, Web search, Skills, and Tools configuration."})]}),e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(he,{className:"gap-0 py-0",children:[e.jsx(Ae,{className:"py-4",children:e.jsx(Me,{className:"text-base",children:"Employee task configuration"})}),e.jsxs(Te,{className:"space-y-4 pb-4",children:[e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Integration"}),e.jsxs(Q,{value:d,onValueChange:t=>{if(!t)return;const o=t;v(o),M(o==="shortcut"?"the ticket detail header actions":"the ticket detail page");const r=o==="chat-tasks"?c.find(i=>i.employee===j):c[0];b((r==null?void 0:r.id)??"")},children:[e.jsx(Z,{className:"w-full",children:e.jsx(ee,{children:d==="shortcut"?"Contextual Shortcut":"Tasks inside a chat"})}),e.jsxs(te,{children:[e.jsx(W,{value:"shortcut",children:"Contextual Shortcut"}),e.jsx(W,{value:"chat-tasks",children:"Tasks inside a chat"})]})]})]}),d==="chat-tasks"?e.jsxs("label",{className:"block space-y-2 border-t pt-4 text-xs font-medium",children:[e.jsx("span",{children:"AI employee"}),e.jsxs(Q,{value:j,onValueChange:t=>{var o;t&&(S(t),b(((o=c.find(r=>r.employee===t))==null?void 0:o.id)??""))},children:[e.jsx(Z,{className:"w-full",children:e.jsx(ee,{children:((B=m.find(t=>t.username===j))==null?void 0:B.nickname)??j})}),e.jsx(te,{children:m.map(t=>e.jsx(W,{value:t.username,children:t.nickname},t.username))})]}),e.jsx("span",{className:"block font-normal leading-5 text-muted-foreground",children:"Select an employee first, then configure the tasks shown in that employee’s new-conversation state."})]}):null,e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[d==="shortcut"?e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"AI employee"}),e.jsxs(Q,{value:k,onValueChange:t=>t&&T(t),children:[e.jsx(Z,{className:"w-full",children:e.jsx(ee,{children:((F=m.find(t=>t.username===k))==null?void 0:F.nickname)??k})}),e.jsx(te,{children:m.map(t=>e.jsx(W,{value:t.username,children:t.nickname},t.username))})]})]}):null,e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Placement"}),e.jsx(qe,{value:f,onChange:t=>M(t.target.value)})]}),d==="chat-tasks"?e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Chat container"}),e.jsxs(Q,{value:I,onValueChange:t=>t&&C(t),children:[e.jsx(Z,{className:"w-full",children:e.jsx(ee,{children:{page:"Page",embedded:"Embedded block","side-panel":"Side panel",dialog:"Dialog"}[I]})}),e.jsxs(te,{children:[e.jsx(W,{value:"page",children:"Page"}),e.jsx(W,{value:"embedded",children:"Embedded block"}),e.jsx(W,{value:"side-panel",children:"Side panel"}),e.jsx(W,{value:"dialog",children:"Dialog"})]})]})]}):null]}),d==="shortcut"?e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Target conversation"}),e.jsxs(Q,{value:y,onValueChange:t=>t&&E(t),children:[e.jsx(Z,{className:"w-full",children:e.jsx(ee,{children:y==="global-side-panel"?"Global side panel":"Embedded chat"})}),e.jsxs(te,{children:[e.jsx(W,{value:"global-side-panel",children:"Global side panel"}),e.jsx(W,{value:"embedded",children:"Embedded chat"})]})]})]}):null,e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Tasks"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[R.length," configured task",R.length===1?"":"s",d==="chat-tasks"?" for this employee":""]})]}),e.jsxs(pe,{variant:"outline",size:"sm",onClick:N,children:[e.jsx(ss,{})," Add task"]})]}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:R.map((t,o)=>e.jsxs("div",{className:t.id===(p==null?void 0:p.id)?"flex items-center gap-2 rounded-lg border border-foreground/25 bg-muted/60 p-1":"flex items-center gap-2 rounded-lg border p-1",children:[e.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-1.5 text-left",onClick:()=>b(t.id),children:[e.jsxs("span",{className:"block truncate text-xs font-medium",children:[o+1,". ",t.title]}),e.jsxs("span",{className:"block text-[10px] text-muted-foreground",children:[t.autoSend?"Auto send":"Fill composer",t.workContext.length?" · Task context":"",t.webSearch?" · Web search":""]})]}),e.jsx(pe,{variant:"ghost",size:"icon-xs",disabled:c.length===1,"aria-label":`Remove ${t.title}`,onClick:()=>q(t.id),children:e.jsx(as,{})})]},t.id))})]}),p?e.jsxs("div",{className:"space-y-3 border-t pt-4",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Title"}),e.jsx(qe,{value:p.title,onChange:t=>g({title:t.target.value})})]}),e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Model"}),e.jsxs(Q,{value:p.model,onValueChange:t=>t&&g({model:t}),children:[e.jsx(Z,{className:"w-full",children:e.jsx(ee,{className:"min-w-0 overflow-hidden",children:e.jsx("span",{className:"block min-w-0 truncate",title:p.model==="default"?"Use employee default":((ae=Ie(l,p.model))==null?void 0:ae.label)??p.model,children:p.model==="default"?"Use employee default":((de=Ie(l,p.model))==null?void 0:de.label)??p.model})})}),e.jsxs(te,{children:[e.jsx(W,{value:"default",children:"Use employee default"}),e.jsx(ns,{}),e.jsx(rs,{models:l})]})]})]})]}),e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Default user message"}),e.jsx(Ge,{className:"min-h-16",value:p.userMessage,onChange:t=>g({userMessage:t.target.value})})]}),e.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-lg border px-3 py-2.5 text-sm",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"Auto send"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Otherwise the message is placed in the composer."})]}),e.jsx(He,{size:"sm",checked:p.autoSend,onCheckedChange:t=>g({autoSend:t})})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Work context"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Select a page context for this task. Without one, the task inherits its surrounding context."})]}),e.jsxs(pe,{variant:"outline",size:"sm",disabled:x===0,onClick:()=>P({onSelect:t=>g({workContext:[{type:t.type,id:t.id,title:t.title,kind:t.kind}]})}),children:[e.jsx(os,{})," Pick context"]})]}),p.workContext.map((t,o)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-xs",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.title??t.id??t.type}),e.jsx(pe,{variant:"ghost",size:"icon-xs","aria-label":"Remove task context",onClick:()=>g({workContext:[]}),children:e.jsx(is,{})})]},`${t.type}:${t.id??o}`))]}),e.jsx(ys,{children:e.jsxs(ws,{value:"advanced-task-settings",className:"rounded-lg border px-3",children:[e.jsx(Cs,{className:"no-underline hover:no-underline",children:e.jsxs("span",{children:[e.jsx("span",{className:"block",children:"Advanced task settings"}),e.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:"Background, Web search, Skills, and Tools"})]})}),e.jsxs(Ns,{className:"space-y-4 pt-1",children:[e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Background"}),e.jsx(Ge,{className:"min-h-16",value:p.background,onChange:t=>g({background:t.target.value})})]}),e.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-lg border px-3 py-2.5 text-sm",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"Web search"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Subject to the selected LLM service capability."})]}),e.jsx(He,{size:"sm",checked:p.webSearch,onCheckedChange:t=>g({webSearch:t})})]}),e.jsx(et,{title:"Skills",mode:p.skillsMode,values:p.skills,options:$s,onModeChange:t=>g({skillsMode:t}),onToggle:(t,o)=>G("skills",t,o)}),e.jsx(et,{title:"Tools",mode:p.toolsMode,values:p.tools,options:Bs,onModeChange:t=>g({toolsMode:t}),onToggle:(t,o)=>G("tools",t,o)})]})]})})]}):null,e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t pt-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:d==="shortcut"?"Live shortcut preview":"Chat-bound task configuration"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:d==="shortcut"?"Multiple tasks appear in the chat empty state after opening.":"Use the third scenario above to preview employee switching."})]}),d==="shortcut"?e.jsx(Pe,{aiEmployee:k,tasks:$,target:y==="embedded"?s:void 0,label:`Ask ${((ce=m.find(t=>t.username===k))==null?void 0:ce.nickname)??k}`,size:34}):null]})]})]}),e.jsx(ds,{title:d==="shortcut"?"Add an AI employee task shortcut":"Add employee tasks to a chat",description:d==="shortcut"?"The prompt includes every task, capability override, and target conversation.":"The prompt groups configured tasks by business AI employee and selected chat container.",prompt:K})]})]})}function et({title:s,mode:a,values:l,options:x,onModeChange:P,onToggle:m}){return e.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:s}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Preset inherits the AI employee configuration."})]}),e.jsxs(Q,{value:a,onValueChange:h=>h&&P(h),children:[e.jsx(Z,{size:"sm",className:"w-28",children:e.jsx(ee,{children:a==="preset"?"Preset":"Custom"})}),e.jsxs(te,{children:[e.jsx(W,{value:"preset",children:"Preset"}),e.jsx(W,{value:"custom",children:"Custom"})]})]})]}),a==="custom"?e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:x.map(h=>e.jsxs("label",{className:"flex items-center gap-2 rounded-md bg-muted/40 px-2.5 py-2 text-xs",children:[e.jsx(Ts,{checked:l.includes(h.value),onCheckedChange:d=>m(h.value,d)}),e.jsx("span",{children:h.label})]},h.value))}):null]})}export{Ks as ShortcutPage};
@@ -0,0 +1 @@
1
+ import{b as a,a$ as y,j as e,aT as j,aV as b,aW as A,k as S,I as v,D as w}from"./index-MB-jfQld.js";import{u as C}from"./use-authenticator-sign-in-CRGjzXju.js";function E(n){var x;const s=C(n.name),[l,r]=a.useState(!1),[g,d]=a.useState(),[c,t]=a.useState(),[f,m]=a.useState(Date.now()),i=typeof((x=n.options)==null?void 0:x.verifier)=="string"?n.options.verifier:"";a.useEffect(()=>{if(!c||c<=Date.now())return;const u=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(u)},[c]);const h=a.useMemo(()=>c?Math.max(0,Math.ceil((c-f)/1e3)):0,[c,f]);return{sendCode:a.useCallback(async u=>{if(!u)throw new Error("Enter a phone number first.");if(!i)throw new Error("The SMS verifier is not configured.");if(!(h>0)){d(void 0),r(!0);try{const o=await y.action("smsOTP","publicCreate",{method:"POST",authenticator:null,includeRole:!1,withAclMeta:!1,body:{action:"auth:signIn",verifier:i,uuid:u}}),p=o!=null&&o.expiresAt?Date.parse(o.expiresAt):Date.now()+6e4;m(Date.now()),t(p)}catch(o){const p=o instanceof Error?o:new Error("Unable to send the verification code.");throw d(p),p}finally{r(!1)}}},[h,i]),signIn:(u,o)=>s.signIn({uuid:u,code:o}),isSendingCode:l,isSigningIn:s.isPending,retryAfter:h,error:g??s.error}}function N({authenticator:n,onSendCode:s,onSignIn:l}){var m;const[r,g]=a.useState(""),[d,c]=a.useState(""),t=E(n),f=((m=n.options)==null?void 0:m.autoSignup)===!0;return e.jsxs("form",{className:"space-y-5",onSubmit:i=>{if(i.preventDefault(),l){l({phone:r,code:d});return}t.signIn(r,d)},children:[t.error&&e.jsxs(j,{variant:"destructive",children:[e.jsx(b,{children:"SMS sign-in failed"}),e.jsx(A,{children:t.error.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:`${n.name}-phone`,children:"Phone"}),e.jsx(v,{id:`${n.name}-phone`,type:"tel",value:r,onChange:i=>g(i.target.value),autoComplete:"tel",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:`${n.name}-code`,children:"Verification code"}),e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-2",children:[e.jsx(v,{id:`${n.name}-code`,inputMode:"numeric",value:d,onChange:i=>c(i.target.value),autoComplete:"one-time-code",required:!0}),e.jsx(w,{type:"button",variant:"outline",disabled:!s&&(t.isSendingCode||t.retryAfter>0)||!r,onClick:()=>{if(s){s(r);return}t.sendCode(r).catch(()=>{})},children:!s&&t.isSendingCode?"Sending…":!s&&t.retryAfter>0?`Retry in ${t.retryAfter}s`:"Send code"})]})]}),e.jsx(w,{type:"submit",className:"w-full",disabled:!l&&t.isSigningIn,children:!l&&t.isSigningIn?"Signing in…":"Sign in"}),f&&e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"An account will be created automatically if this phone number is new."})]})}export{N as default};