@open-mercato/core 0.8.1-develop.7296.1.2111d779db → 0.9.0

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 (2352) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/AGENTS.md +4 -5
  3. package/dist/generated/entities/availability_policy/index.js +41 -0
  4. package/dist/generated/entities/availability_policy/index.js.map +7 -0
  5. package/dist/generated/entities/communication_channel/index.js +3 -1
  6. package/dist/generated/entities/communication_channel/index.js.map +2 -2
  7. package/dist/generated/entities/customer_email_conversation_share/index.js +21 -0
  8. package/dist/generated/entities/customer_email_conversation_share/index.js.map +7 -0
  9. package/dist/generated/entities/customer_group/index.js +33 -0
  10. package/dist/generated/entities/customer_group/index.js.map +7 -0
  11. package/dist/generated/entities/customer_group_membership/index.js +29 -0
  12. package/dist/generated/entities/customer_group_membership/index.js.map +7 -0
  13. package/dist/generated/entities/customer_group_terms/index.js +33 -0
  14. package/dist/generated/entities/customer_group_terms/index.js.map +7 -0
  15. package/dist/generated/entities/customer_interaction/index.js +2 -0
  16. package/dist/generated/entities/customer_interaction/index.js.map +2 -2
  17. package/dist/generated/entities/form/index.js +35 -0
  18. package/dist/generated/entities/form/index.js.map +7 -0
  19. package/dist/generated/entities/form_access_audit/index.js +21 -0
  20. package/dist/generated/entities/form_access_audit/index.js.map +7 -0
  21. package/dist/generated/entities/form_attachment/index.js +29 -0
  22. package/dist/generated/entities/form_attachment/index.js.map +7 -0
  23. package/dist/generated/entities/form_consent_record/index.js +37 -0
  24. package/dist/generated/entities/form_consent_record/index.js.map +7 -0
  25. package/dist/generated/entities/form_distribution/index.js +47 -0
  26. package/dist/generated/entities/form_distribution/index.js.map +7 -0
  27. package/dist/generated/entities/form_invitation/index.js +49 -0
  28. package/dist/generated/entities/form_invitation/index.js.map +7 -0
  29. package/dist/generated/entities/form_submission/index.js +39 -0
  30. package/dist/generated/entities/form_submission/index.js.map +7 -0
  31. package/dist/generated/entities/form_submission_actor/index.js +23 -0
  32. package/dist/generated/entities/form_submission_actor/index.js.map +7 -0
  33. package/dist/generated/entities/form_submission_revision/index.js +29 -0
  34. package/dist/generated/entities/form_submission_revision/index.js.map +7 -0
  35. package/dist/generated/entities/form_version/index.js +37 -0
  36. package/dist/generated/entities/form_version/index.js.map +7 -0
  37. package/dist/generated/entities/forms_encryption_key/index.js +15 -0
  38. package/dist/generated/entities/forms_encryption_key/index.js.map +7 -0
  39. package/dist/generated/entities.ids.generated.js +27 -2
  40. package/dist/generated/entities.ids.generated.js.map +2 -2
  41. package/dist/generated/entity-fields-registry.js +269 -0
  42. package/dist/generated/entity-fields-registry.js.map +2 -2
  43. package/dist/helpers/integration/communicationChannelsFixtures.js +16 -0
  44. package/dist/helpers/integration/communicationChannelsFixtures.js.map +2 -2
  45. package/dist/helpers/integration/customerGroupsFixtures.js +88 -0
  46. package/dist/helpers/integration/customerGroupsFixtures.js.map +7 -0
  47. package/dist/helpers/integration/formsFixtures.js +448 -0
  48. package/dist/helpers/integration/formsFixtures.js.map +7 -0
  49. package/dist/modules/api_docs/api/get/version.js +19 -7
  50. package/dist/modules/api_docs/api/get/version.js.map +2 -2
  51. package/dist/modules/api_keys/api/keys/route.js +74 -169
  52. package/dist/modules/api_keys/api/keys/route.js.map +2 -2
  53. package/dist/modules/api_keys/backend/api-keys/create/page.js +1 -1
  54. package/dist/modules/api_keys/backend/api-keys/create/page.js.map +2 -2
  55. package/dist/modules/api_keys/commands/keys.js +140 -0
  56. package/dist/modules/api_keys/commands/keys.js.map +7 -0
  57. package/dist/modules/api_keys/services/apiKeyService.js +72 -43
  58. package/dist/modules/api_keys/services/apiKeyService.js.map +2 -2
  59. package/dist/modules/attachments/api/file/[id]/route.js +9 -2
  60. package/dist/modules/attachments/api/file/[id]/route.js.map +2 -2
  61. package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js +6 -2
  62. package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js.map +2 -2
  63. package/dist/modules/attachments/api/route.js +10 -4
  64. package/dist/modules/attachments/api/route.js.map +2 -2
  65. package/dist/modules/attachments/components/AttachmentLibrary.js +16 -6
  66. package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
  67. package/dist/modules/attachments/lib/access.js +1 -3
  68. package/dist/modules/attachments/lib/access.js.map +2 -2
  69. package/dist/modules/attachments/lib/requestScope.js +13 -4
  70. package/dist/modules/attachments/lib/requestScope.js.map +2 -2
  71. package/dist/modules/audit_logs/api/audit-logs/actions/export/route.js +6 -1
  72. package/dist/modules/audit_logs/api/audit-logs/actions/export/route.js.map +2 -2
  73. package/dist/modules/audit_logs/api/audit-logs/actions/redo/route.js +36 -6
  74. package/dist/modules/audit_logs/api/audit-logs/actions/redo/route.js.map +3 -3
  75. package/dist/modules/audit_logs/api/audit-logs/actions/route.js +6 -1
  76. package/dist/modules/audit_logs/api/audit-logs/actions/route.js.map +2 -2
  77. package/dist/modules/audit_logs/api/audit-logs/actions/undo/route.js +34 -4
  78. package/dist/modules/audit_logs/api/audit-logs/actions/undo/route.js.map +2 -2
  79. package/dist/modules/audit_logs/data/validators.js +1 -0
  80. package/dist/modules/audit_logs/data/validators.js.map +2 -2
  81. package/dist/modules/audit_logs/lib/actorSubject.js +65 -0
  82. package/dist/modules/audit_logs/lib/actorSubject.js.map +7 -0
  83. package/dist/modules/audit_logs/lib/replayAuthorization.js +41 -0
  84. package/dist/modules/audit_logs/lib/replayAuthorization.js.map +7 -0
  85. package/dist/modules/audit_logs/services/actionLogService.js +162 -39
  86. package/dist/modules/audit_logs/services/actionLogService.js.map +3 -3
  87. package/dist/modules/auth/api/features.js +1 -1
  88. package/dist/modules/auth/api/features.js.map +2 -2
  89. package/dist/modules/auth/cli.js +29 -17
  90. package/dist/modules/auth/cli.js.map +2 -2
  91. package/dist/modules/auth/commands/acl.js +25 -36
  92. package/dist/modules/auth/commands/acl.js.map +2 -2
  93. package/dist/modules/auth/commands/interceptors.js +22 -0
  94. package/dist/modules/auth/commands/interceptors.js.map +7 -0
  95. package/dist/modules/auth/commands/roles.js +421 -147
  96. package/dist/modules/auth/commands/roles.js.map +2 -2
  97. package/dist/modules/auth/commands/users.js +543 -69
  98. package/dist/modules/auth/commands/users.js.map +2 -2
  99. package/dist/modules/auth/lib/authorizationStateLocks.js +249 -0
  100. package/dist/modules/auth/lib/authorizationStateLocks.js.map +7 -0
  101. package/dist/modules/auth/lib/commandReplay.js +144 -0
  102. package/dist/modules/auth/lib/commandReplay.js.map +7 -0
  103. package/dist/modules/auth/lib/executionPrincipal.js +32 -25
  104. package/dist/modules/auth/lib/executionPrincipal.js.map +2 -2
  105. package/dist/modules/auth/lib/grantChecks.js +7 -2
  106. package/dist/modules/auth/lib/grantChecks.js.map +2 -2
  107. package/dist/modules/auth/lib/setup-app.js +85 -49
  108. package/dist/modules/auth/lib/setup-app.js.map +2 -2
  109. package/dist/modules/auth/lib/tokenHash.js +13 -1
  110. package/dist/modules/auth/lib/tokenHash.js.map +2 -2
  111. package/dist/modules/auth/services/rbacService.js +386 -5
  112. package/dist/modules/auth/services/rbacService.js.map +3 -3
  113. package/dist/modules/availability/acl.js +16 -0
  114. package/dist/modules/availability/acl.js.map +7 -0
  115. package/dist/modules/availability/api/check/route.js +115 -0
  116. package/dist/modules/availability/api/check/route.js.map +7 -0
  117. package/dist/modules/availability/api/openapi.js +27 -0
  118. package/dist/modules/availability/api/openapi.js.map +7 -0
  119. package/dist/modules/availability/api/policies/resolve-preview/route.js +72 -0
  120. package/dist/modules/availability/api/policies/resolve-preview/route.js.map +7 -0
  121. package/dist/modules/availability/api/policies/route.js +203 -0
  122. package/dist/modules/availability/api/policies/route.js.map +7 -0
  123. package/dist/modules/availability/backend/availability/check/page.js +186 -0
  124. package/dist/modules/availability/backend/availability/check/page.js.map +7 -0
  125. package/dist/modules/availability/backend/availability/check/page.meta.js +16 -0
  126. package/dist/modules/availability/backend/availability/check/page.meta.js.map +7 -0
  127. package/dist/modules/availability/backend/availability/policies/ResolutionPreviewPanel.js +83 -0
  128. package/dist/modules/availability/backend/availability/policies/ResolutionPreviewPanel.js.map +7 -0
  129. package/dist/modules/availability/backend/availability/policies/ScopeFields.js +53 -0
  130. package/dist/modules/availability/backend/availability/policies/ScopeFields.js.map +7 -0
  131. package/dist/modules/availability/backend/availability/policies/StockManagedField.js +32 -0
  132. package/dist/modules/availability/backend/availability/policies/StockManagedField.js.map +7 -0
  133. package/dist/modules/availability/backend/availability/policies/[id]/page.js +168 -0
  134. package/dist/modules/availability/backend/availability/policies/[id]/page.js.map +7 -0
  135. package/dist/modules/availability/backend/availability/policies/[id]/page.meta.js +12 -0
  136. package/dist/modules/availability/backend/availability/policies/[id]/page.meta.js.map +7 -0
  137. package/dist/modules/availability/backend/availability/policies/create/page.js +122 -0
  138. package/dist/modules/availability/backend/availability/policies/create/page.js.map +7 -0
  139. package/dist/modules/availability/backend/availability/policies/create/page.meta.js +12 -0
  140. package/dist/modules/availability/backend/availability/policies/create/page.meta.js.map +7 -0
  141. package/dist/modules/availability/backend/availability/policies/formGroups.js +77 -0
  142. package/dist/modules/availability/backend/availability/policies/formGroups.js.map +7 -0
  143. package/dist/modules/availability/backend/availability/policies/page.js +207 -0
  144. package/dist/modules/availability/backend/availability/policies/page.js.map +7 -0
  145. package/dist/modules/availability/backend/availability/policies/page.meta.js +16 -0
  146. package/dist/modules/availability/backend/availability/policies/page.meta.js.map +7 -0
  147. package/dist/modules/availability/backend/availability/policies/policyPayload.js +28 -0
  148. package/dist/modules/availability/backend/availability/policies/policyPayload.js.map +7 -0
  149. package/dist/modules/availability/commands/policies.js +364 -0
  150. package/dist/modules/availability/commands/policies.js.map +7 -0
  151. package/dist/modules/availability/commands/scope.js +19 -0
  152. package/dist/modules/availability/commands/scope.js.map +7 -0
  153. package/dist/modules/availability/data/entities.js +94 -0
  154. package/dist/modules/availability/data/entities.js.map +7 -0
  155. package/dist/modules/availability/data/validators.js +59 -0
  156. package/dist/modules/availability/data/validators.js.map +7 -0
  157. package/dist/modules/availability/di.js +50 -0
  158. package/dist/modules/availability/di.js.map +7 -0
  159. package/dist/modules/availability/events.js +18 -0
  160. package/dist/modules/availability/events.js.map +7 -0
  161. package/dist/modules/availability/index.js +15 -0
  162. package/dist/modules/availability/index.js.map +7 -0
  163. package/dist/modules/availability/lib/catalogTarget.js +42 -0
  164. package/dist/modules/availability/lib/catalogTarget.js.map +7 -0
  165. package/dist/modules/availability/lib/organizationScope.js +33 -0
  166. package/dist/modules/availability/lib/organizationScope.js.map +7 -0
  167. package/dist/modules/availability/lib/policyResolution.js +150 -0
  168. package/dist/modules/availability/lib/policyResolution.js.map +7 -0
  169. package/dist/modules/availability/lib/tryResolve.js +11 -0
  170. package/dist/modules/availability/lib/tryResolve.js.map +7 -0
  171. package/dist/modules/availability/migrations/Migration20260922095844_availability.js +16 -0
  172. package/dist/modules/availability/migrations/Migration20260922095844_availability.js.map +7 -0
  173. package/dist/modules/availability/migrations/Migration20260930120000_availability.js +20 -0
  174. package/dist/modules/availability/migrations/Migration20260930120000_availability.js.map +7 -0
  175. package/dist/modules/availability/setup.js +12 -0
  176. package/dist/modules/availability/setup.js.map +7 -0
  177. package/dist/modules/catalog/api/categories/bulk-create/route.js +124 -0
  178. package/dist/modules/catalog/api/categories/bulk-create/route.js.map +7 -0
  179. package/dist/modules/catalog/api/categories/route.js +56 -8
  180. package/dist/modules/catalog/api/categories/route.js.map +2 -2
  181. package/dist/modules/catalog/api/products/bulk-create/route.js +124 -0
  182. package/dist/modules/catalog/api/products/bulk-create/route.js.map +7 -0
  183. package/dist/modules/catalog/api/products/route.js +55 -31
  184. package/dist/modules/catalog/api/products/route.js.map +3 -3
  185. package/dist/modules/catalog/backend/catalog/products/[id]/page.js +3 -6
  186. package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
  187. package/dist/modules/catalog/backend/catalog/products/create/page.js +12 -4
  188. package/dist/modules/catalog/backend/catalog/products/create/page.js.map +2 -2
  189. package/dist/modules/catalog/commands/categories.js +1 -0
  190. package/dist/modules/catalog/commands/categories.js.map +2 -2
  191. package/dist/modules/catalog/commands/products.js +5 -2
  192. package/dist/modules/catalog/commands/products.js.map +2 -2
  193. package/dist/modules/catalog/components/PriceKindSettings.js +5 -19
  194. package/dist/modules/catalog/components/PriceKindSettings.js.map +2 -2
  195. package/dist/modules/catalog/components/prices/PriceScopeSelectors.js +2 -2
  196. package/dist/modules/catalog/components/prices/PriceScopeSelectors.js.map +2 -2
  197. package/dist/modules/catalog/components/products/ProductUomSection.js +26 -29
  198. package/dist/modules/catalog/components/products/ProductUomSection.js.map +2 -2
  199. package/dist/modules/catalog/components/products/productForm.js +3 -2
  200. package/dist/modules/catalog/components/products/productForm.js.map +2 -2
  201. package/dist/modules/catalog/data/validators.js +15 -0
  202. package/dist/modules/catalog/data/validators.js.map +2 -2
  203. package/dist/modules/catalog/di.js +3 -2
  204. package/dist/modules/catalog/di.js.map +2 -2
  205. package/dist/modules/catalog/events.js +9 -3
  206. package/dist/modules/catalog/events.js.map +2 -2
  207. package/dist/modules/catalog/lib/bulkCreateCategories.js +237 -0
  208. package/dist/modules/catalog/lib/bulkCreateCategories.js.map +7 -0
  209. package/dist/modules/catalog/lib/bulkCreateCheckpoint.js +82 -0
  210. package/dist/modules/catalog/lib/bulkCreateCheckpoint.js.map +7 -0
  211. package/dist/modules/catalog/lib/bulkCreateMutationGuards.js +39 -0
  212. package/dist/modules/catalog/lib/bulkCreateMutationGuards.js.map +7 -0
  213. package/dist/modules/catalog/lib/bulkCreateProducts.js +241 -0
  214. package/dist/modules/catalog/lib/bulkCreateProducts.js.map +7 -0
  215. package/dist/modules/catalog/lib/bulkDelete.js +10 -11
  216. package/dist/modules/catalog/lib/bulkDelete.js.map +2 -2
  217. package/dist/modules/catalog/lib/catalogQueue.js +14 -0
  218. package/dist/modules/catalog/lib/catalogQueue.js.map +7 -0
  219. package/dist/modules/catalog/lib/currencyOptions.js +25 -0
  220. package/dist/modules/catalog/lib/currencyOptions.js.map +7 -0
  221. package/dist/modules/catalog/lib/productSearch.js +8 -0
  222. package/dist/modules/catalog/lib/productSearch.js.map +7 -0
  223. package/dist/modules/catalog/lib/seeds.js +2 -42
  224. package/dist/modules/catalog/lib/seeds.js.map +2 -2
  225. package/dist/modules/catalog/lib/unitLabels.js +53 -0
  226. package/dist/modules/catalog/lib/unitLabels.js.map +7 -0
  227. package/dist/modules/catalog/migrations/Migration20260914120000.js +29 -0
  228. package/dist/modules/catalog/migrations/Migration20260914120000.js.map +7 -0
  229. package/dist/modules/catalog/migrations/Migration20260914120100.js +28 -0
  230. package/dist/modules/catalog/migrations/Migration20260914120100.js.map +7 -0
  231. package/dist/modules/catalog/workers/catalog-category-bulk-create.js +40 -0
  232. package/dist/modules/catalog/workers/catalog-category-bulk-create.js.map +7 -0
  233. package/dist/modules/catalog/workers/catalog-product-bulk-create.js +40 -0
  234. package/dist/modules/catalog/workers/catalog-product-bulk-create.js.map +7 -0
  235. package/dist/modules/communication_channels/acl.js +8 -0
  236. package/dist/modules/communication_channels/acl.js.map +2 -2
  237. package/dist/modules/communication_channels/api/get/me/channels/route.js +4 -0
  238. package/dist/modules/communication_channels/api/get/me/channels/route.js.map +2 -2
  239. package/dist/modules/communication_channels/api/get/oauth/[provider]/callback/route.js +22 -0
  240. package/dist/modules/communication_channels/api/get/oauth/[provider]/callback/route.js.map +2 -2
  241. package/dist/modules/communication_channels/api/post/channels/[id]/import-history/route.js +4 -4
  242. package/dist/modules/communication_channels/api/post/channels/[id]/import-history/route.js.map +2 -2
  243. package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js +2 -1
  244. package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js.map +2 -2
  245. package/dist/modules/communication_channels/api/post/test-seed/route.js +90 -20
  246. package/dist/modules/communication_channels/api/post/test-seed/route.js.map +3 -3
  247. package/dist/modules/communication_channels/api/put/channels/[id]/visibility/route.js +137 -0
  248. package/dist/modules/communication_channels/api/put/channels/[id]/visibility/route.js.map +7 -0
  249. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js +175 -107
  250. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js.map +2 -2
  251. package/dist/modules/communication_channels/commands/ingest-inbound-message.js +2 -1
  252. package/dist/modules/communication_channels/commands/ingest-inbound-message.js.map +2 -2
  253. package/dist/modules/communication_channels/commands/set-channel-visibility.js +88 -0
  254. package/dist/modules/communication_channels/commands/set-channel-visibility.js.map +7 -0
  255. package/dist/modules/communication_channels/data/enrichers.js +18 -9
  256. package/dist/modules/communication_channels/data/enrichers.js.map +2 -2
  257. package/dist/modules/communication_channels/data/entities.js +4 -0
  258. package/dist/modules/communication_channels/data/entities.js.map +2 -2
  259. package/dist/modules/communication_channels/di.js +9 -1
  260. package/dist/modules/communication_channels/di.js.map +2 -2
  261. package/dist/modules/communication_channels/events.js +7 -0
  262. package/dist/modules/communication_channels/events.js.map +2 -2
  263. package/dist/modules/communication_channels/index.js +1 -1
  264. package/dist/modules/communication_channels/index.js.map +1 -1
  265. package/dist/modules/communication_channels/lib/access-control.js +2 -1
  266. package/dist/modules/communication_channels/lib/access-control.js.map +2 -2
  267. package/dist/modules/communication_channels/lib/channel-thread-access.js +60 -0
  268. package/dist/modules/communication_channels/lib/channel-thread-access.js.map +7 -0
  269. package/dist/modules/communication_channels/lib/credential-refresh.js +11 -2
  270. package/dist/modules/communication_channels/lib/credential-refresh.js.map +2 -2
  271. package/dist/modules/communication_channels/lib/inbound-message-origin.js +18 -0
  272. package/dist/modules/communication_channels/lib/inbound-message-origin.js.map +7 -0
  273. package/dist/modules/communication_channels/lib/oauth-state.js +37 -0
  274. package/dist/modules/communication_channels/lib/oauth-state.js.map +2 -2
  275. package/dist/modules/communication_channels/lib/outbound-delivery-intent.js +12 -0
  276. package/dist/modules/communication_channels/lib/outbound-delivery-intent.js.map +7 -0
  277. package/dist/modules/communication_channels/lib/send-as-user.js +1 -1
  278. package/dist/modules/communication_channels/lib/send-as-user.js.map +2 -2
  279. package/dist/modules/communication_channels/migrations/Migration20260825141000_communication_channels.js +14 -0
  280. package/dist/modules/communication_channels/migrations/Migration20260825141000_communication_channels.js.map +7 -0
  281. package/dist/modules/communication_channels/setup.js +6 -2
  282. package/dist/modules/communication_channels/setup.js.map +2 -2
  283. package/dist/modules/communication_channels/subscribers/outbound-bridge.js +8 -2
  284. package/dist/modules/communication_channels/subscribers/outbound-bridge.js.map +2 -2
  285. package/dist/modules/communication_channels/workers/gmail-history-sync.js +1 -1
  286. package/dist/modules/communication_channels/workers/gmail-history-sync.js.map +2 -2
  287. package/dist/modules/communication_channels/workers/poll-channel.js +1 -1
  288. package/dist/modules/communication_channels/workers/poll-channel.js.map +2 -2
  289. package/dist/modules/communication_channels/workers/reaction-processor.js +2 -2
  290. package/dist/modules/communication_channels/workers/reaction-processor.js.map +2 -2
  291. package/dist/modules/configs/api/upgrade-actions/route.js +2 -1
  292. package/dist/modules/configs/api/upgrade-actions/route.js.map +2 -2
  293. package/dist/modules/configs/cli.js +2 -2
  294. package/dist/modules/configs/cli.js.map +2 -2
  295. package/dist/modules/configs/lib/upgrade-actions.js +28 -6
  296. package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
  297. package/dist/modules/configs/services/upgradeActionsService.js +44 -30
  298. package/dist/modules/configs/services/upgradeActionsService.js.map +2 -2
  299. package/dist/modules/currencies/api/currencies/route.js +11 -5
  300. package/dist/modules/currencies/api/currencies/route.js.map +2 -2
  301. package/dist/modules/currencies/api/exchange-rates/route.js +11 -5
  302. package/dist/modules/currencies/api/exchange-rates/route.js.map +2 -2
  303. package/dist/modules/customer_accounts/api/admin/users/[id]/sessions/[sessionId].js +78 -0
  304. package/dist/modules/customer_accounts/api/admin/users/[id]/sessions/[sessionId].js.map +7 -0
  305. package/dist/modules/customer_groups/acl.js +14 -0
  306. package/dist/modules/customer_groups/acl.js.map +7 -0
  307. package/dist/modules/customer_groups/api/customer-groups/[id]/terms/route.js +266 -0
  308. package/dist/modules/customer_groups/api/customer-groups/[id]/terms/route.js.map +7 -0
  309. package/dist/modules/customer_groups/api/customer-groups/crud.js +473 -0
  310. package/dist/modules/customer_groups/api/customer-groups/crud.js.map +7 -0
  311. package/dist/modules/customer_groups/api/customer-groups/explain-terms/route.js +143 -0
  312. package/dist/modules/customer_groups/api/customer-groups/explain-terms/route.js.map +7 -0
  313. package/dist/modules/customer_groups/api/customer-groups/memberships/crud.js +383 -0
  314. package/dist/modules/customer_groups/api/customer-groups/memberships/crud.js.map +7 -0
  315. package/dist/modules/customer_groups/api/customer-groups/memberships/route.js +66 -0
  316. package/dist/modules/customer_groups/api/customer-groups/memberships/route.js.map +7 -0
  317. package/dist/modules/customer_groups/api/customer-groups/price-kinds/route.js +90 -0
  318. package/dist/modules/customer_groups/api/customer-groups/price-kinds/route.js.map +7 -0
  319. package/dist/modules/customer_groups/api/customer-groups/reconcile/adopt/route.js +133 -0
  320. package/dist/modules/customer_groups/api/customer-groups/reconcile/adopt/route.js.map +7 -0
  321. package/dist/modules/customer_groups/api/customer-groups/reconcile/route.js +80 -0
  322. package/dist/modules/customer_groups/api/customer-groups/reconcile/route.js.map +7 -0
  323. package/dist/modules/customer_groups/api/customer-groups/reorder/route.js +127 -0
  324. package/dist/modules/customer_groups/api/customer-groups/reorder/route.js.map +7 -0
  325. package/dist/modules/customer_groups/api/customer-groups/route.js +62 -0
  326. package/dist/modules/customer_groups/api/customer-groups/route.js.map +7 -0
  327. package/dist/modules/customer_groups/api/openapi.js +27 -0
  328. package/dist/modules/customer_groups/api/openapi.js.map +7 -0
  329. package/dist/modules/customer_groups/backend/customer-groups/[id]/edit/page.js +328 -0
  330. package/dist/modules/customer_groups/backend/customer-groups/[id]/edit/page.js.map +7 -0
  331. package/dist/modules/customer_groups/backend/customer-groups/[id]/edit/page.meta.js +16 -0
  332. package/dist/modules/customer_groups/backend/customer-groups/[id]/edit/page.meta.js.map +7 -0
  333. package/dist/modules/customer_groups/backend/customer-groups/create/page.js +249 -0
  334. package/dist/modules/customer_groups/backend/customer-groups/create/page.js.map +7 -0
  335. package/dist/modules/customer_groups/backend/customer-groups/create/page.meta.js +27 -0
  336. package/dist/modules/customer_groups/backend/customer-groups/create/page.meta.js.map +7 -0
  337. package/dist/modules/customer_groups/backend/customer-groups/orphans/page.js +139 -0
  338. package/dist/modules/customer_groups/backend/customer-groups/orphans/page.js.map +7 -0
  339. package/dist/modules/customer_groups/backend/customer-groups/orphans/page.meta.js +16 -0
  340. package/dist/modules/customer_groups/backend/customer-groups/orphans/page.meta.js.map +7 -0
  341. package/dist/modules/customer_groups/backend/customer-groups/page.js +368 -0
  342. package/dist/modules/customer_groups/backend/customer-groups/page.js.map +7 -0
  343. package/dist/modules/customer_groups/backend/customer-groups/page.meta.js +15 -0
  344. package/dist/modules/customer_groups/backend/customer-groups/page.meta.js.map +7 -0
  345. package/dist/modules/customer_groups/cli.js +72 -0
  346. package/dist/modules/customer_groups/cli.js.map +7 -0
  347. package/dist/modules/customer_groups/commands/reorderGroups.js +96 -0
  348. package/dist/modules/customer_groups/commands/reorderGroups.js.map +7 -0
  349. package/dist/modules/customer_groups/components/CustomerGroupDefaultField.js +41 -0
  350. package/dist/modules/customer_groups/components/CustomerGroupDefaultField.js.map +7 -0
  351. package/dist/modules/customer_groups/components/CustomerGroupParentField.js +156 -0
  352. package/dist/modules/customer_groups/components/CustomerGroupParentField.js.map +7 -0
  353. package/dist/modules/customer_groups/components/CustomerGroupTermsPriceKindField.js +94 -0
  354. package/dist/modules/customer_groups/components/CustomerGroupTermsPriceKindField.js.map +7 -0
  355. package/dist/modules/customer_groups/components/CustomerGroupTermsSection.js +199 -0
  356. package/dist/modules/customer_groups/components/CustomerGroupTermsSection.js.map +7 -0
  357. package/dist/modules/customer_groups/components/GroupPickerField.js +116 -0
  358. package/dist/modules/customer_groups/components/GroupPickerField.js.map +7 -0
  359. package/dist/modules/customer_groups/components/OrphanBanner.js +75 -0
  360. package/dist/modules/customer_groups/components/OrphanBanner.js.map +7 -0
  361. package/dist/modules/customer_groups/components/customerGroupTree.js +57 -0
  362. package/dist/modules/customer_groups/components/customerGroupTree.js.map +7 -0
  363. package/dist/modules/customer_groups/data/entities.js +226 -0
  364. package/dist/modules/customer_groups/data/entities.js.map +7 -0
  365. package/dist/modules/customer_groups/data/validators.js +153 -0
  366. package/dist/modules/customer_groups/data/validators.js.map +7 -0
  367. package/dist/modules/customer_groups/di.js +20 -0
  368. package/dist/modules/customer_groups/di.js.map +7 -0
  369. package/dist/modules/customer_groups/events.js +22 -0
  370. package/dist/modules/customer_groups/events.js.map +7 -0
  371. package/dist/modules/customer_groups/index.js +15 -0
  372. package/dist/modules/customer_groups/index.js.map +7 -0
  373. package/dist/modules/customer_groups/lib/createConflictRecheck.js +29 -0
  374. package/dist/modules/customer_groups/lib/createConflictRecheck.js.map +7 -0
  375. package/dist/modules/customer_groups/lib/customerScope.js +81 -0
  376. package/dist/modules/customer_groups/lib/customerScope.js.map +7 -0
  377. package/dist/modules/customer_groups/lib/groupEvents.js +31 -0
  378. package/dist/modules/customer_groups/lib/groupEvents.js.map +7 -0
  379. package/dist/modules/customer_groups/lib/priceKindScope.js +50 -0
  380. package/dist/modules/customer_groups/lib/priceKindScope.js.map +7 -0
  381. package/dist/modules/customer_groups/lib/reconcile.js +161 -0
  382. package/dist/modules/customer_groups/lib/reconcile.js.map +7 -0
  383. package/dist/modules/customer_groups/migrations/Migration20260922095316_customer_groups.js +27 -0
  384. package/dist/modules/customer_groups/migrations/Migration20260922095316_customer_groups.js.map +7 -0
  385. package/dist/modules/customer_groups/migrations/Migration20260922103033_customer_groups.js +19 -0
  386. package/dist/modules/customer_groups/migrations/Migration20260922103033_customer_groups.js.map +7 -0
  387. package/dist/modules/customer_groups/migrations/Migration20260922105444_customer_groups.js +19 -0
  388. package/dist/modules/customer_groups/migrations/Migration20260922105444_customer_groups.js.map +7 -0
  389. package/dist/modules/customer_groups/migrations/Migration20260923193330_customer_groups.js +19 -0
  390. package/dist/modules/customer_groups/migrations/Migration20260923193330_customer_groups.js.map +7 -0
  391. package/dist/modules/customer_groups/migrations/Migration20260929083000_customer_groups.js +20 -0
  392. package/dist/modules/customer_groups/migrations/Migration20260929083000_customer_groups.js.map +7 -0
  393. package/dist/modules/customer_groups/services/customerGroupsService.js +190 -0
  394. package/dist/modules/customer_groups/services/customerGroupsService.js.map +7 -0
  395. package/dist/modules/customer_groups/setup.js +13 -0
  396. package/dist/modules/customer_groups/setup.js.map +7 -0
  397. package/dist/modules/customer_groups/widgets/injection/group-picker-field/widget.js +31 -0
  398. package/dist/modules/customer_groups/widgets/injection/group-picker-field/widget.js.map +7 -0
  399. package/dist/modules/customer_groups/widgets/injection/person-groups-explain-terms.js +166 -0
  400. package/dist/modules/customer_groups/widgets/injection/person-groups-explain-terms.js.map +7 -0
  401. package/dist/modules/customer_groups/widgets/injection/person-groups-tab/widget.js +17 -0
  402. package/dist/modules/customer_groups/widgets/injection/person-groups-tab/widget.js.map +7 -0
  403. package/dist/modules/customer_groups/widgets/injection/person-groups-tab.js +457 -0
  404. package/dist/modules/customer_groups/widgets/injection/person-groups-tab.js.map +7 -0
  405. package/dist/modules/customer_groups/widgets/injection-table.js +33 -0
  406. package/dist/modules/customer_groups/widgets/injection-table.js.map +7 -0
  407. package/dist/modules/customers/acl.js +13 -0
  408. package/dist/modules/customers/acl.js.map +2 -2
  409. package/dist/modules/customers/api/activities/route.js +9 -1
  410. package/dist/modules/customers/api/activities/route.js.map +2 -2
  411. package/dist/modules/customers/api/companies/[id]/people/route.js +2 -1
  412. package/dist/modules/customers/api/companies/[id]/people/route.js.map +2 -2
  413. package/dist/modules/customers/api/companies/[id]/route.js +19 -7
  414. package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
  415. package/dist/modules/customers/api/deals/[id]/companies/route.js +2 -1
  416. package/dist/modules/customers/api/deals/[id]/companies/route.js.map +2 -2
  417. package/dist/modules/customers/api/deals/[id]/people/route.js +2 -1
  418. package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
  419. package/dist/modules/customers/api/deals/map/route.js +7 -2
  420. package/dist/modules/customers/api/deals/map/route.js.map +2 -2
  421. package/dist/modules/customers/api/dictionaries/context.js +2 -1
  422. package/dist/modules/customers/api/dictionaries/context.js.map +2 -2
  423. package/dist/modules/customers/api/entity-roles-factory.js +3 -2
  424. package/dist/modules/customers/api/entity-roles-factory.js.map +2 -2
  425. package/dist/modules/customers/api/interactions/[id]/visibility/route.js +2 -1
  426. package/dist/modules/customers/api/interactions/[id]/visibility/route.js.map +2 -2
  427. package/dist/modules/customers/api/interactions/cancel/route.js +2 -1
  428. package/dist/modules/customers/api/interactions/cancel/route.js.map +2 -2
  429. package/dist/modules/customers/api/interactions/complete/route.js +2 -1
  430. package/dist/modules/customers/api/interactions/complete/route.js.map +2 -2
  431. package/dist/modules/customers/api/interactions/conflicts/route.js +10 -6
  432. package/dist/modules/customers/api/interactions/conflicts/route.js.map +2 -2
  433. package/dist/modules/customers/api/interactions/counts/route.js +24 -4
  434. package/dist/modules/customers/api/interactions/counts/route.js.map +2 -2
  435. package/dist/modules/customers/api/interactions/route.js +31 -8
  436. package/dist/modules/customers/api/interactions/route.js.map +2 -2
  437. package/dist/modules/customers/api/labels/assign/route.js +2 -1
  438. package/dist/modules/customers/api/labels/assign/route.js.map +2 -2
  439. package/dist/modules/customers/api/labels/route.js +3 -2
  440. package/dist/modules/customers/api/labels/route.js.map +2 -2
  441. package/dist/modules/customers/api/labels/unassign/route.js +2 -1
  442. package/dist/modules/customers/api/labels/unassign/route.js.map +2 -2
  443. package/dist/modules/customers/api/people/[id]/companies/context.js +7 -2
  444. package/dist/modules/customers/api/people/[id]/companies/context.js.map +2 -2
  445. package/dist/modules/customers/api/people/[id]/email-share/route.js +218 -0
  446. package/dist/modules/customers/api/people/[id]/email-share/route.js.map +7 -0
  447. package/dist/modules/customers/api/people/[id]/email-threads/route.js +11 -2
  448. package/dist/modules/customers/api/people/[id]/email-threads/route.js.map +2 -2
  449. package/dist/modules/customers/api/people/[id]/emails/route.js +2 -1
  450. package/dist/modules/customers/api/people/[id]/emails/route.js.map +2 -2
  451. package/dist/modules/customers/api/people/[id]/route.js +20 -19
  452. package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
  453. package/dist/modules/customers/api/people/check-phone/route.js +2 -1
  454. package/dist/modules/customers/api/people/check-phone/route.js.map +2 -2
  455. package/dist/modules/customers/api/pipeline-stages/reorder/route.js +3 -2
  456. package/dist/modules/customers/api/pipeline-stages/reorder/route.js.map +2 -2
  457. package/dist/modules/customers/api/pipeline-stages/route.js +3 -3
  458. package/dist/modules/customers/api/pipeline-stages/route.js.map +2 -2
  459. package/dist/modules/customers/api/pipelines/route.js +3 -3
  460. package/dist/modules/customers/api/pipelines/route.js.map +2 -2
  461. package/dist/modules/customers/api/settings/address-format/route.js +2 -1
  462. package/dist/modules/customers/api/settings/address-format/route.js.map +2 -2
  463. package/dist/modules/customers/api/settings/dictionary-sort-modes/route.js +2 -1
  464. package/dist/modules/customers/api/settings/dictionary-sort-modes/route.js.map +2 -2
  465. package/dist/modules/customers/api/settings/stuck-threshold/route.js +2 -1
  466. package/dist/modules/customers/api/settings/stuck-threshold/route.js.map +2 -2
  467. package/dist/modules/customers/api/tags/assign/route.js +2 -1
  468. package/dist/modules/customers/api/tags/assign/route.js.map +2 -2
  469. package/dist/modules/customers/api/tags/unassign/route.js +2 -1
  470. package/dist/modules/customers/api/tags/unassign/route.js.map +2 -2
  471. package/dist/modules/customers/backend/customers/companies/[id]/page.js +4 -2
  472. package/dist/modules/customers/backend/customers/companies/[id]/page.js.map +2 -2
  473. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.js +6 -2
  474. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.js.map +2 -2
  475. package/dist/modules/customers/backend/customers/deals/[id]/page.js +6 -1
  476. package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +2 -2
  477. package/dist/modules/customers/backend/customers/deals/components/ReassignOwnerDialog.js +93 -0
  478. package/dist/modules/customers/backend/customers/deals/components/ReassignOwnerDialog.js.map +7 -0
  479. package/dist/modules/customers/backend/customers/deals/page.js +111 -1
  480. package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
  481. package/dist/modules/customers/backend/customers/people/[id]/page.js +4 -2
  482. package/dist/modules/customers/backend/customers/people/[id]/page.js.map +2 -2
  483. package/dist/modules/customers/commands/addresses.js +83 -15
  484. package/dist/modules/customers/commands/addresses.js.map +2 -2
  485. package/dist/modules/customers/commands/companies.js +24 -5
  486. package/dist/modules/customers/commands/companies.js.map +2 -2
  487. package/dist/modules/customers/commands/emailConversationShares.js +177 -0
  488. package/dist/modules/customers/commands/emailConversationShares.js.map +7 -0
  489. package/dist/modules/customers/commands/index.js +1 -0
  490. package/dist/modules/customers/commands/index.js.map +2 -2
  491. package/dist/modules/customers/commands/interactions.js +48 -23
  492. package/dist/modules/customers/commands/interactions.js.map +3 -3
  493. package/dist/modules/customers/commands/people.js +3 -2
  494. package/dist/modules/customers/commands/people.js.map +2 -2
  495. package/dist/modules/customers/commands/shared.js +4 -0
  496. package/dist/modules/customers/commands/shared.js.map +2 -2
  497. package/dist/modules/customers/components/calendar/types.js.map +1 -1
  498. package/dist/modules/customers/components/detail/CompanyPeopleSection.js +3 -11
  499. package/dist/modules/customers/components/detail/CompanyPeopleSection.js.map +2 -2
  500. package/dist/modules/customers/components/detail/DealForm.js +66 -2
  501. package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
  502. package/dist/modules/customers/components/detail/DealOwnerSelect.js +96 -0
  503. package/dist/modules/customers/components/detail/DealOwnerSelect.js.map +7 -0
  504. package/dist/modules/customers/components/detail/DealsSection.js +8 -14
  505. package/dist/modules/customers/components/detail/DealsSection.js.map +2 -2
  506. package/dist/modules/customers/components/detail/PersonEmailShareControl.js +190 -0
  507. package/dist/modules/customers/components/detail/PersonEmailShareControl.js.map +7 -0
  508. package/dist/modules/customers/components/detail/PersonEmailThreadsTab.js +17 -0
  509. package/dist/modules/customers/components/detail/PersonEmailThreadsTab.js.map +2 -2
  510. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js +5 -2
  511. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js.map +2 -2
  512. package/dist/modules/customers/components/detail/create/CreateDealForm.js +19 -0
  513. package/dist/modules/customers/components/detail/create/CreateDealForm.js.map +2 -2
  514. package/dist/modules/customers/components/detail/create/DealDetailsFields.js +11 -0
  515. package/dist/modules/customers/components/detail/create/DealDetailsFields.js.map +2 -2
  516. package/dist/modules/customers/components/detail/create/DealSectionCard.js +2 -2
  517. package/dist/modules/customers/components/detail/create/DealSectionCard.js.map +2 -2
  518. package/dist/modules/customers/components/detail/create/dealFormTypes.js +1 -0
  519. package/dist/modules/customers/components/detail/create/dealFormTypes.js.map +2 -2
  520. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js +1 -1
  521. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js.map +2 -2
  522. package/dist/modules/customers/components/formConfig.js +2 -0
  523. package/dist/modules/customers/components/formConfig.js.map +2 -2
  524. package/dist/modules/customers/components/linking/LinkEntityDialog.js +8 -0
  525. package/dist/modules/customers/components/linking/LinkEntityDialog.js.map +2 -2
  526. package/dist/modules/customers/data/enrichers.js +40 -2
  527. package/dist/modules/customers/data/enrichers.js.map +2 -2
  528. package/dist/modules/customers/data/entities.js +56 -0
  529. package/dist/modules/customers/data/entities.js.map +2 -2
  530. package/dist/modules/customers/data/validators.js +11 -0
  531. package/dist/modules/customers/data/validators.js.map +2 -2
  532. package/dist/modules/customers/events.js +6 -1
  533. package/dist/modules/customers/events.js.map +2 -2
  534. package/dist/modules/customers/lib/assignableStaff.js +14 -0
  535. package/dist/modules/customers/lib/assignableStaff.js.map +2 -2
  536. package/dist/modules/customers/lib/calendar/editorPayload.js +17 -13
  537. package/dist/modules/customers/lib/calendar/editorPayload.js.map +2 -2
  538. package/dist/modules/customers/lib/calendar/mapItem.js +1 -0
  539. package/dist/modules/customers/lib/calendar/mapItem.js.map +2 -2
  540. package/dist/modules/customers/lib/conversationShares.js +126 -0
  541. package/dist/modules/customers/lib/conversationShares.js.map +7 -0
  542. package/dist/modules/customers/lib/dealsOrganizationScope.js +5 -3
  543. package/dist/modules/customers/lib/dealsOrganizationScope.js.map +2 -2
  544. package/dist/modules/customers/lib/interactionRequestContext.js +2 -1
  545. package/dist/modules/customers/lib/interactionRequestContext.js.map +2 -2
  546. package/dist/modules/customers/lib/link-channel-message-handler.js +19 -9
  547. package/dist/modules/customers/lib/link-channel-message-handler.js.map +2 -2
  548. package/dist/modules/customers/lib/personDetailCacheTags.js +32 -0
  549. package/dist/modules/customers/lib/personDetailCacheTags.js.map +7 -0
  550. package/dist/modules/customers/lib/personEmailThreads.js +26 -5
  551. package/dist/modules/customers/lib/personEmailThreads.js.map +2 -2
  552. package/dist/modules/customers/lib/reassignDealOwner.js +25 -0
  553. package/dist/modules/customers/lib/reassignDealOwner.js.map +7 -0
  554. package/dist/modules/customers/lib/userNames.js +26 -0
  555. package/dist/modules/customers/lib/userNames.js.map +7 -0
  556. package/dist/modules/customers/lib/visibilityFilter.js +70 -2
  557. package/dist/modules/customers/lib/visibilityFilter.js.map +2 -2
  558. package/dist/modules/customers/migrations/Migration20260825120000_customers.js +18 -0
  559. package/dist/modules/customers/migrations/Migration20260825120000_customers.js.map +7 -0
  560. package/dist/modules/customers/migrations/Migration20260825140000_customers.js +27 -0
  561. package/dist/modules/customers/migrations/Migration20260825140000_customers.js.map +7 -0
  562. package/dist/modules/customers/setup.js +1 -0
  563. package/dist/modules/customers/setup.js.map +2 -2
  564. package/dist/modules/customers/subscribers/channel-visibility-changed.js +16 -0
  565. package/dist/modules/customers/subscribers/channel-visibility-changed.js.map +7 -0
  566. package/dist/modules/dashboards/api/widgets/data/batch/route.js +3 -8
  567. package/dist/modules/dashboards/api/widgets/data/batch/route.js.map +2 -2
  568. package/dist/modules/dashboards/api/widgets/data/route.js +10 -15
  569. package/dist/modules/dashboards/api/widgets/data/route.js.map +2 -2
  570. package/dist/modules/dashboards/lib/aggregations.js +1 -1
  571. package/dist/modules/dashboards/lib/aggregations.js.map +2 -2
  572. package/dist/modules/dashboards/lib/widgetScope.js +2 -7
  573. package/dist/modules/dashboards/lib/widgetScope.js.map +2 -2
  574. package/dist/modules/data_sync/api/runs/[id]/cancel.js +4 -1
  575. package/dist/modules/data_sync/api/runs/[id]/cancel.js.map +2 -2
  576. package/dist/modules/data_sync/backend/data-sync/page.js +497 -329
  577. package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
  578. package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js +248 -113
  579. package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js.map +3 -3
  580. package/dist/modules/data_sync/components/useDataSyncRunAccess.js +17 -0
  581. package/dist/modules/data_sync/components/useDataSyncRunAccess.js.map +7 -0
  582. package/dist/modules/data_sync/lib/resume-point.js +21 -0
  583. package/dist/modules/data_sync/lib/resume-point.js.map +7 -0
  584. package/dist/modules/data_sync/lib/start-run.js +52 -2
  585. package/dist/modules/data_sync/lib/start-run.js.map +2 -2
  586. package/dist/modules/data_sync/lib/sync-run-service.js +22 -33
  587. package/dist/modules/data_sync/lib/sync-run-service.js.map +3 -3
  588. package/dist/modules/devices/api/[id]/route.js +3 -2
  589. package/dist/modules/devices/api/[id]/route.js.map +2 -2
  590. package/dist/modules/devices/api/admin/devices/route.js +2 -1
  591. package/dist/modules/devices/api/admin/devices/route.js.map +2 -2
  592. package/dist/modules/devices/api/route.js +2 -1
  593. package/dist/modules/devices/api/route.js.map +2 -2
  594. package/dist/modules/dictionaries/api/[dictionaryId]/route.js.map +2 -2
  595. package/dist/modules/dictionaries/api/context.js +2 -1
  596. package/dist/modules/dictionaries/api/context.js.map +2 -2
  597. package/dist/modules/dictionaries/api/route.js +4 -0
  598. package/dist/modules/dictionaries/api/route.js.map +2 -2
  599. package/dist/modules/dictionaries/components/DictionariesManager.js +101 -89
  600. package/dist/modules/dictionaries/components/DictionariesManager.js.map +2 -2
  601. package/dist/modules/dictionaries/data/validators.js +3 -1
  602. package/dist/modules/dictionaries/data/validators.js.map +2 -2
  603. package/dist/modules/directory/api/organization-branding/route.js +10 -1
  604. package/dist/modules/directory/api/organization-branding/route.js.map +2 -2
  605. package/dist/modules/directory/api/organizations/route.js +1 -1
  606. package/dist/modules/directory/api/organizations/route.js.map +1 -1
  607. package/dist/modules/directory/backend/directory/branding/page.js +17 -4
  608. package/dist/modules/directory/backend/directory/branding/page.js.map +3 -3
  609. package/dist/modules/directory/commands/organizations.js +136 -74
  610. package/dist/modules/directory/commands/organizations.js.map +2 -2
  611. package/dist/modules/directory/lib/hierarchy.js +19 -1
  612. package/dist/modules/directory/lib/hierarchy.js.map +2 -2
  613. package/dist/modules/directory/utils/organizationScope.js +66 -12
  614. package/dist/modules/directory/utils/organizationScope.js.map +2 -2
  615. package/dist/modules/directory/utils/organizationScopeFilter.js +7 -4
  616. package/dist/modules/directory/utils/organizationScopeFilter.js.map +2 -2
  617. package/dist/modules/directory/utils/organizationScopeGuard.js +6 -2
  618. package/dist/modules/directory/utils/organizationScopeGuard.js.map +2 -2
  619. package/dist/modules/entities/api/encryption.js +68 -25
  620. package/dist/modules/entities/api/encryption.js.map +2 -2
  621. package/dist/modules/entities/api/records.js +9 -8
  622. package/dist/modules/entities/api/records.js.map +2 -2
  623. package/dist/modules/entities/cli.js +33 -22
  624. package/dist/modules/entities/cli.js.map +2 -2
  625. package/dist/modules/entities/data/entities.js +8 -0
  626. package/dist/modules/entities/data/entities.js.map +2 -2
  627. package/dist/modules/entities/lib/definition-scope.js +3 -1
  628. package/dist/modules/entities/lib/definition-scope.js.map +2 -2
  629. package/dist/modules/entities/lib/encryption-maps.js +117 -0
  630. package/dist/modules/entities/lib/encryption-maps.js.map +7 -0
  631. package/dist/modules/entities/lib/helpers.js +30 -6
  632. package/dist/modules/entities/lib/helpers.js.map +2 -2
  633. package/dist/modules/entities/migrations/Migration20260910120000.js +17 -0
  634. package/dist/modules/entities/migrations/Migration20260910120000.js.map +7 -0
  635. package/dist/modules/entities/migrations/Migration20261004120000_encryption_map_scope_uniqueness.js +130 -0
  636. package/dist/modules/entities/migrations/Migration20261004120000_encryption_map_scope_uniqueness.js.map +7 -0
  637. package/dist/modules/eudr/api/dashboard/widgets/compliance-overview/route.js +2 -1
  638. package/dist/modules/eudr/api/dashboard/widgets/compliance-overview/route.js.map +2 -2
  639. package/dist/modules/eudr/api/plots/import/route.js +2 -1
  640. package/dist/modules/eudr/api/plots/import/route.js.map +2 -2
  641. package/dist/modules/eudr/api/product-mappings/suggestions/apply/route.js +2 -1
  642. package/dist/modules/eudr/api/product-mappings/suggestions/apply/route.js.map +2 -2
  643. package/dist/modules/eudr/api/product-mappings/suggestions/route.js +2 -1
  644. package/dist/modules/eudr/api/product-mappings/suggestions/route.js.map +2 -2
  645. package/dist/modules/eudr/api/reports/annual/route.js +2 -1
  646. package/dist/modules/eudr/api/reports/annual/route.js.map +2 -2
  647. package/dist/modules/eudr/api/statements/[id]/export/route.js +2 -1
  648. package/dist/modules/eudr/api/statements/[id]/export/route.js.map +2 -2
  649. package/dist/modules/eudr/api/statements/[id]/readiness/route.js +2 -1
  650. package/dist/modules/eudr/api/statements/[id]/readiness/route.js.map +2 -2
  651. package/dist/modules/eudr/api/suppliers/compliance/route.js +2 -1
  652. package/dist/modules/eudr/api/suppliers/compliance/route.js.map +2 -2
  653. package/dist/modules/feature_toggles/commands/global.js +13 -13
  654. package/dist/modules/feature_toggles/commands/global.js.map +2 -2
  655. package/dist/modules/feature_toggles/lib/feature-flag-check.js +8 -2
  656. package/dist/modules/feature_toggles/lib/feature-flag-check.js.map +2 -2
  657. package/dist/modules/forms/acl.js +14 -0
  658. package/dist/modules/forms/acl.js.map +7 -0
  659. package/dist/modules/forms/api/[id]/analytics/route.js +113 -0
  660. package/dist/modules/forms/api/[id]/analytics/route.js.map +7 -0
  661. package/dist/modules/forms/api/[id]/distributions/route.js +176 -0
  662. package/dist/modules/forms/api/[id]/distributions/route.js.map +7 -0
  663. package/dist/modules/forms/api/[id]/route.js +225 -0
  664. package/dist/modules/forms/api/[id]/route.js.map +7 -0
  665. package/dist/modules/forms/api/[id]/run/context/route.js +115 -0
  666. package/dist/modules/forms/api/[id]/run/context/route.js.map +7 -0
  667. package/dist/modules/forms/api/[id]/run/submissions/route.js +109 -0
  668. package/dist/modules/forms/api/[id]/run/submissions/route.js.map +7 -0
  669. package/dist/modules/forms/api/[id]/submissions/route.js +83 -0
  670. package/dist/modules/forms/api/[id]/submissions/route.js.map +7 -0
  671. package/dist/modules/forms/api/[id]/theme-logo/route.js +117 -0
  672. package/dist/modules/forms/api/[id]/theme-logo/route.js.map +7 -0
  673. package/dist/modules/forms/api/[id]/versions/[versionId]/diff/route.js +125 -0
  674. package/dist/modules/forms/api/[id]/versions/[versionId]/diff/route.js.map +7 -0
  675. package/dist/modules/forms/api/[id]/versions/[versionId]/publish/route.js +99 -0
  676. package/dist/modules/forms/api/[id]/versions/[versionId]/publish/route.js.map +7 -0
  677. package/dist/modules/forms/api/[id]/versions/[versionId]/route.js +176 -0
  678. package/dist/modules/forms/api/[id]/versions/[versionId]/route.js.map +7 -0
  679. package/dist/modules/forms/api/[id]/versions/fork/route.js +92 -0
  680. package/dist/modules/forms/api/[id]/versions/fork/route.js.map +7 -0
  681. package/dist/modules/forms/api/attachment-helpers.js +111 -0
  682. package/dist/modules/forms/api/attachment-helpers.js.map +7 -0
  683. package/dist/modules/forms/api/by-key/[key]/active/route.js +140 -0
  684. package/dist/modules/forms/api/by-key/[key]/active/route.js.map +7 -0
  685. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/route.js +84 -0
  686. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/route.js.map +7 -0
  687. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/send/route.js +88 -0
  688. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/send/route.js.map +7 -0
  689. package/dist/modules/forms/api/distributions/[distributionId]/invitations/route.js +183 -0
  690. package/dist/modules/forms/api/distributions/[distributionId]/invitations/route.js.map +7 -0
  691. package/dist/modules/forms/api/distributions/[distributionId]/route.js +191 -0
  692. package/dist/modules/forms/api/distributions/[distributionId]/route.js.map +7 -0
  693. package/dist/modules/forms/api/form-submissions/[id]/attachments/route.js +91 -0
  694. package/dist/modules/forms/api/form-submissions/[id]/attachments/route.js.map +7 -0
  695. package/dist/modules/forms/api/form-submissions/[id]/resume-token/route.js +110 -0
  696. package/dist/modules/forms/api/form-submissions/[id]/resume-token/route.js.map +7 -0
  697. package/dist/modules/forms/api/form-submissions/[id]/route.js +146 -0
  698. package/dist/modules/forms/api/form-submissions/[id]/route.js.map +7 -0
  699. package/dist/modules/forms/api/form-submissions/[id]/submit/route.js +74 -0
  700. package/dist/modules/forms/api/form-submissions/[id]/submit/route.js.map +7 -0
  701. package/dist/modules/forms/api/form-submissions/by-subject/[subject_type]/[subject_id]/route.js +76 -0
  702. package/dist/modules/forms/api/form-submissions/by-subject/[subject_type]/[subject_id]/route.js.map +7 -0
  703. package/dist/modules/forms/api/form-submissions/route.js +113 -0
  704. package/dist/modules/forms/api/form-submissions/route.js.map +7 -0
  705. package/dist/modules/forms/api/helpers.js +124 -0
  706. package/dist/modules/forms/api/helpers.js.map +7 -0
  707. package/dist/modules/forms/api/public/distributions/[slug]/embed-policy/route.js +47 -0
  708. package/dist/modules/forms/api/public/distributions/[slug]/embed-policy/route.js.map +7 -0
  709. package/dist/modules/forms/api/public/distributions/[slug]/route.js +81 -0
  710. package/dist/modules/forms/api/public/distributions/[slug]/route.js.map +7 -0
  711. package/dist/modules/forms/api/public/embed-loader/route.js +116 -0
  712. package/dist/modules/forms/api/public/embed-loader/route.js.map +7 -0
  713. package/dist/modules/forms/api/public/invitations/[token]/route.js +87 -0
  714. package/dist/modules/forms/api/public/invitations/[token]/route.js.map +7 -0
  715. package/dist/modules/forms/api/public/rate-limit.js +54 -0
  716. package/dist/modules/forms/api/public/rate-limit.js.map +7 -0
  717. package/dist/modules/forms/api/public/start/route.js +142 -0
  718. package/dist/modules/forms/api/public/start/route.js.map +7 -0
  719. package/dist/modules/forms/api/public/submissions/[id]/attachments/[attachmentId]/route.js +67 -0
  720. package/dist/modules/forms/api/public/submissions/[id]/attachments/[attachmentId]/route.js.map +7 -0
  721. package/dist/modules/forms/api/public/submissions/[id]/attachments/route.js +85 -0
  722. package/dist/modules/forms/api/public/submissions/[id]/attachments/route.js.map +7 -0
  723. package/dist/modules/forms/api/public/submissions/[id]/pdf/route.js +72 -0
  724. package/dist/modules/forms/api/public/submissions/[id]/pdf/route.js.map +7 -0
  725. package/dist/modules/forms/api/public/submissions/[id]/route.js +154 -0
  726. package/dist/modules/forms/api/public/submissions/[id]/route.js.map +7 -0
  727. package/dist/modules/forms/api/public/submissions/[id]/submit/route.js +127 -0
  728. package/dist/modules/forms/api/public/submissions/[id]/submit/route.js.map +7 -0
  729. package/dist/modules/forms/api/route.js +216 -0
  730. package/dist/modules/forms/api/route.js.map +7 -0
  731. package/dist/modules/forms/api/runtime-helpers.js +149 -0
  732. package/dist/modules/forms/api/runtime-helpers.js.map +7 -0
  733. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/consents/route.js +137 -0
  734. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/consents/route.js.map +7 -0
  735. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/export/route.js +101 -0
  736. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/export/route.js.map +7 -0
  737. package/dist/modules/forms/api/submissions/[submissionId]/access-audit/route.js +76 -0
  738. package/dist/modules/forms/api/submissions/[submissionId]/access-audit/route.js.map +7 -0
  739. package/dist/modules/forms/api/submissions/[submissionId]/actors/[actorId]/route.js +56 -0
  740. package/dist/modules/forms/api/submissions/[submissionId]/actors/[actorId]/route.js.map +7 -0
  741. package/dist/modules/forms/api/submissions/[submissionId]/actors/route.js +76 -0
  742. package/dist/modules/forms/api/submissions/[submissionId]/actors/route.js.map +7 -0
  743. package/dist/modules/forms/api/submissions/[submissionId]/anonymize/route.js +107 -0
  744. package/dist/modules/forms/api/submissions/[submissionId]/anonymize/route.js.map +7 -0
  745. package/dist/modules/forms/api/submissions/[submissionId]/attachments/[attachmentId]/route.js +73 -0
  746. package/dist/modules/forms/api/submissions/[submissionId]/attachments/[attachmentId]/route.js.map +7 -0
  747. package/dist/modules/forms/api/submissions/[submissionId]/export/route.js +90 -0
  748. package/dist/modules/forms/api/submissions/[submissionId]/export/route.js.map +7 -0
  749. package/dist/modules/forms/api/submissions/[submissionId]/pdf/route.js +91 -0
  750. package/dist/modules/forms/api/submissions/[submissionId]/pdf/route.js.map +7 -0
  751. package/dist/modules/forms/api/submissions/[submissionId]/reopen/route.js +55 -0
  752. package/dist/modules/forms/api/submissions/[submissionId]/reopen/route.js.map +7 -0
  753. package/dist/modules/forms/api/submissions/[submissionId]/revisions/route.js +61 -0
  754. package/dist/modules/forms/api/submissions/[submissionId]/revisions/route.js.map +7 -0
  755. package/dist/modules/forms/api/submissions/[submissionId]/route.js +75 -0
  756. package/dist/modules/forms/api/submissions/[submissionId]/route.js.map +7 -0
  757. package/dist/modules/forms/backend/forms/[id]/FormStudio.js +2811 -0
  758. package/dist/modules/forms/backend/forms/[id]/FormStudio.js.map +7 -0
  759. package/dist/modules/forms/backend/forms/[id]/analytics/page.js +214 -0
  760. package/dist/modules/forms/backend/forms/[id]/analytics/page.js.map +7 -0
  761. package/dist/modules/forms/backend/forms/[id]/analytics/page.meta.js +19 -0
  762. package/dist/modules/forms/backend/forms/[id]/analytics/page.meta.js.map +7 -0
  763. package/dist/modules/forms/backend/forms/[id]/distributions/page.js +12 -0
  764. package/dist/modules/forms/backend/forms/[id]/distributions/page.js.map +7 -0
  765. package/dist/modules/forms/backend/forms/[id]/distributions/page.meta.js +19 -0
  766. package/dist/modules/forms/backend/forms/[id]/distributions/page.meta.js.map +7 -0
  767. package/dist/modules/forms/backend/forms/[id]/history/page.js +152 -0
  768. package/dist/modules/forms/backend/forms/[id]/history/page.js.map +7 -0
  769. package/dist/modules/forms/backend/forms/[id]/history/page.meta.js +15 -0
  770. package/dist/modules/forms/backend/forms/[id]/history/page.meta.js.map +7 -0
  771. package/dist/modules/forms/backend/forms/[id]/page.js +13 -0
  772. package/dist/modules/forms/backend/forms/[id]/page.js.map +7 -0
  773. package/dist/modules/forms/backend/forms/[id]/page.meta.js +15 -0
  774. package/dist/modules/forms/backend/forms/[id]/page.meta.js.map +7 -0
  775. package/dist/modules/forms/backend/forms/[id]/studio/YesNoRow.js +51 -0
  776. package/dist/modules/forms/backend/forms/[id]/studio/YesNoRow.js.map +7 -0
  777. package/dist/modules/forms/backend/forms/[id]/studio/autosave-guard.js +21 -0
  778. package/dist/modules/forms/backend/forms/[id]/studio/autosave-guard.js.map +7 -0
  779. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DragOverlayCard.js +18 -0
  780. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DragOverlayCard.js.map +7 -0
  781. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DropIndicator.js +41 -0
  782. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DropIndicator.js.map +7 -0
  783. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FieldRow.js +277 -0
  784. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FieldRow.js.map +7 -0
  785. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FormCanvas.js +196 -0
  786. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FormCanvas.js.map +7 -0
  787. package/dist/modules/forms/backend/forms/[id]/studio/canvas/GridSlot.js +151 -0
  788. package/dist/modules/forms/backend/forms/[id]/studio/canvas/GridSlot.js.map +7 -0
  789. package/dist/modules/forms/backend/forms/[id]/studio/canvas/SectionContainer.js +340 -0
  790. package/dist/modules/forms/backend/forms/[id]/studio/canvas/SectionContainer.js.map +7 -0
  791. package/dist/modules/forms/backend/forms/[id]/studio/canvas/grid-collision.js +24 -0
  792. package/dist/modules/forms/backend/forms/[id]/studio/canvas/grid-collision.js.map +7 -0
  793. package/dist/modules/forms/backend/forms/[id]/studio/canvas/keyboard-coordinates.js +91 -0
  794. package/dist/modules/forms/backend/forms/[id]/studio/canvas/keyboard-coordinates.js.map +7 -0
  795. package/dist/modules/forms/backend/forms/[id]/studio/canvas/overlay-size.js +11 -0
  796. package/dist/modules/forms/backend/forms/[id]/studio/canvas/overlay-size.js.map +7 -0
  797. package/dist/modules/forms/backend/forms/[id]/studio/canvas/resize-math.js +27 -0
  798. package/dist/modules/forms/backend/forms/[id]/studio/canvas/resize-math.js.map +7 -0
  799. package/dist/modules/forms/backend/forms/[id]/studio/canvas/row-layout.js +80 -0
  800. package/dist/modules/forms/backend/forms/[id]/studio/canvas/row-layout.js.map +7 -0
  801. package/dist/modules/forms/backend/forms/[id]/studio/logic/ConditionBuilder.js +210 -0
  802. package/dist/modules/forms/backend/forms/[id]/studio/logic/ConditionBuilder.js.map +7 -0
  803. package/dist/modules/forms/backend/forms/[id]/studio/logic/HiddenFieldsPanel.js +91 -0
  804. package/dist/modules/forms/backend/forms/[id]/studio/logic/HiddenFieldsPanel.js.map +7 -0
  805. package/dist/modules/forms/backend/forms/[id]/studio/logic/JumpsEditor.js +201 -0
  806. package/dist/modules/forms/backend/forms/[id]/studio/logic/JumpsEditor.js.map +7 -0
  807. package/dist/modules/forms/backend/forms/[id]/studio/logic/RecallTokenPicker.js +66 -0
  808. package/dist/modules/forms/backend/forms/[id]/studio/logic/RecallTokenPicker.js.map +7 -0
  809. package/dist/modules/forms/backend/forms/[id]/studio/logic/VariablesPanel.js +223 -0
  810. package/dist/modules/forms/backend/forms/[id]/studio/logic/VariablesPanel.js.map +7 -0
  811. package/dist/modules/forms/backend/forms/[id]/studio/logic/condition-model.js +151 -0
  812. package/dist/modules/forms/backend/forms/[id]/studio/logic/condition-model.js.map +7 -0
  813. package/dist/modules/forms/backend/forms/[id]/studio/lucide-icons.js +88 -0
  814. package/dist/modules/forms/backend/forms/[id]/studio/lucide-icons.js.map +7 -0
  815. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormAppearancePanel.js +493 -0
  816. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormAppearancePanel.js.map +7 -0
  817. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormPalettePanel.js +44 -0
  818. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormPalettePanel.js.map +7 -0
  819. package/dist/modules/forms/backend/forms/[id]/studio/palette/InputParametersTab.js +350 -0
  820. package/dist/modules/forms/backend/forms/[id]/studio/palette/InputParametersTab.js.map +7 -0
  821. package/dist/modules/forms/backend/forms/[id]/studio/palette/PaletteCard.js +40 -0
  822. package/dist/modules/forms/backend/forms/[id]/studio/palette/PaletteCard.js.map +7 -0
  823. package/dist/modules/forms/backend/forms/[id]/studio/palette/RolesEditor.js +202 -0
  824. package/dist/modules/forms/backend/forms/[id]/studio/palette/RolesEditor.js.map +7 -0
  825. package/dist/modules/forms/backend/forms/[id]/studio/palette/entries.js +66 -0
  826. package/dist/modules/forms/backend/forms/[id]/studio/palette/entries.js.map +7 -0
  827. package/dist/modules/forms/backend/forms/[id]/studio/preview/PreviewSurface.js +1200 -0
  828. package/dist/modules/forms/backend/forms/[id]/studio/preview/PreviewSurface.js.map +7 -0
  829. package/dist/modules/forms/backend/forms/[id]/studio/preview/ViewportFrame.js +34 -0
  830. package/dist/modules/forms/backend/forms/[id]/studio/preview/ViewportFrame.js.map +7 -0
  831. package/dist/modules/forms/backend/forms/[id]/studio/recall.js +76 -0
  832. package/dist/modules/forms/backend/forms/[id]/studio/recall.js.map +7 -0
  833. package/dist/modules/forms/backend/forms/[id]/studio/schema-helpers.js +1693 -0
  834. package/dist/modules/forms/backend/forms/[id]/studio/schema-helpers.js.map +7 -0
  835. package/dist/modules/forms/backend/forms/[id]/studio/style/BackgroundControl.js +127 -0
  836. package/dist/modules/forms/backend/forms/[id]/studio/style/BackgroundControl.js.map +7 -0
  837. package/dist/modules/forms/backend/forms/[id]/studio/style/ColorControl.js +181 -0
  838. package/dist/modules/forms/backend/forms/[id]/studio/style/ColorControl.js.map +7 -0
  839. package/dist/modules/forms/backend/forms/[id]/studio/style/contrast.js +75 -0
  840. package/dist/modules/forms/backend/forms/[id]/studio/style/contrast.js.map +7 -0
  841. package/dist/modules/forms/backend/forms/[id]/studio/style/presets.js +91 -0
  842. package/dist/modules/forms/backend/forms/[id]/studio/style/presets.js.map +7 -0
  843. package/dist/modules/forms/backend/forms/[id]/studio/type-label.js +11 -0
  844. package/dist/modules/forms/backend/forms/[id]/studio/type-label.js.map +7 -0
  845. package/dist/modules/forms/backend/forms/[id]/studio/types.js +1 -0
  846. package/dist/modules/forms/backend/forms/[id]/studio/types.js.map +7 -0
  847. package/dist/modules/forms/backend/forms/[id]/studio/undo-controller.js +43 -0
  848. package/dist/modules/forms/backend/forms/[id]/studio/undo-controller.js.map +7 -0
  849. package/dist/modules/forms/backend/forms/[id]/studio/validation/FileConstraintsEditor.js +74 -0
  850. package/dist/modules/forms/backend/forms/[id]/studio/validation/FileConstraintsEditor.js.map +7 -0
  851. package/dist/modules/forms/backend/forms/[id]/studio/validation/GroupConfigEditor.js +134 -0
  852. package/dist/modules/forms/backend/forms/[id]/studio/validation/GroupConfigEditor.js.map +7 -0
  853. package/dist/modules/forms/backend/forms/[id]/studio/validation/LengthRangeEditor.js +61 -0
  854. package/dist/modules/forms/backend/forms/[id]/studio/validation/LengthRangeEditor.js.map +7 -0
  855. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixColumnsEditor.js +149 -0
  856. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixColumnsEditor.js.map +7 -0
  857. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixRowsEditor.js +168 -0
  858. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixRowsEditor.js.map +7 -0
  859. package/dist/modules/forms/backend/forms/[id]/studio/validation/MessageOverridesEditor.js +64 -0
  860. package/dist/modules/forms/backend/forms/[id]/studio/validation/MessageOverridesEditor.js.map +7 -0
  861. package/dist/modules/forms/backend/forms/[id]/studio/validation/NpsAnchorsEditor.js +52 -0
  862. package/dist/modules/forms/backend/forms/[id]/studio/validation/NpsAnchorsEditor.js.map +7 -0
  863. package/dist/modules/forms/backend/forms/[id]/studio/validation/NumberRangeEditor.js +59 -0
  864. package/dist/modules/forms/backend/forms/[id]/studio/validation/NumberRangeEditor.js.map +7 -0
  865. package/dist/modules/forms/backend/forms/[id]/studio/validation/OpinionIconSelect.js +31 -0
  866. package/dist/modules/forms/backend/forms/[id]/studio/validation/OpinionIconSelect.js.map +7 -0
  867. package/dist/modules/forms/backend/forms/[id]/studio/validation/PatternEditor.js +105 -0
  868. package/dist/modules/forms/backend/forms/[id]/studio/validation/PatternEditor.js.map +7 -0
  869. package/dist/modules/forms/backend/forms/[id]/studio/validation/RankingExhaustiveSwitch.js +15 -0
  870. package/dist/modules/forms/backend/forms/[id]/studio/validation/RankingExhaustiveSwitch.js.map +7 -0
  871. package/dist/modules/forms/backend/forms/[id]/studio/validation/SignatureConfigEditor.js +75 -0
  872. package/dist/modules/forms/backend/forms/[id]/studio/validation/SignatureConfigEditor.js.map +7 -0
  873. package/dist/modules/forms/backend/forms/[id]/studio/validation/ValidationPanel.js +293 -0
  874. package/dist/modules/forms/backend/forms/[id]/studio/validation/ValidationPanel.js.map +7 -0
  875. package/dist/modules/forms/backend/forms/[id]/submissions/components/RowBadges.js +42 -0
  876. package/dist/modules/forms/backend/forms/[id]/submissions/components/RowBadges.js.map +7 -0
  877. package/dist/modules/forms/backend/forms/[id]/submissions/components/SubmissionDrawer.js +473 -0
  878. package/dist/modules/forms/backend/forms/[id]/submissions/components/SubmissionDrawer.js.map +7 -0
  879. package/dist/modules/forms/backend/forms/[id]/submissions/components/formSummary.js +9 -0
  880. package/dist/modules/forms/backend/forms/[id]/submissions/components/formSummary.js.map +7 -0
  881. package/dist/modules/forms/backend/forms/[id]/submissions/page.js +205 -0
  882. package/dist/modules/forms/backend/forms/[id]/submissions/page.js.map +7 -0
  883. package/dist/modules/forms/backend/forms/[id]/submissions/page.meta.js +12 -0
  884. package/dist/modules/forms/backend/forms/[id]/submissions/page.meta.js.map +7 -0
  885. package/dist/modules/forms/backend/forms/create/page.js +101 -0
  886. package/dist/modules/forms/backend/forms/create/page.js.map +7 -0
  887. package/dist/modules/forms/backend/forms/create/page.meta.js +15 -0
  888. package/dist/modules/forms/backend/forms/create/page.meta.js.map +7 -0
  889. package/dist/modules/forms/backend/forms/page.js +227 -0
  890. package/dist/modules/forms/backend/forms/page.js.map +7 -0
  891. package/dist/modules/forms/backend/forms/page.meta.js +33 -0
  892. package/dist/modules/forms/backend/forms/page.meta.js.map +7 -0
  893. package/dist/modules/forms/commands/distribution.js +421 -0
  894. package/dist/modules/forms/commands/distribution.js.map +7 -0
  895. package/dist/modules/forms/commands/form-version.js +645 -0
  896. package/dist/modules/forms/commands/form-version.js.map +7 -0
  897. package/dist/modules/forms/commands/form.js +411 -0
  898. package/dist/modules/forms/commands/form.js.map +7 -0
  899. package/dist/modules/forms/commands/index.js +11 -0
  900. package/dist/modules/forms/commands/index.js.map +7 -0
  901. package/dist/modules/forms/commands/invitation.js +333 -0
  902. package/dist/modules/forms/commands/invitation.js.map +7 -0
  903. package/dist/modules/forms/commands/shared.js +151 -0
  904. package/dist/modules/forms/commands/shared.js.map +7 -0
  905. package/dist/modules/forms/commands/submission.js +139 -0
  906. package/dist/modules/forms/commands/submission.js.map +7 -0
  907. package/dist/modules/forms/data/entities.js +654 -0
  908. package/dist/modules/forms/data/entities.js.map +7 -0
  909. package/dist/modules/forms/data/validators.js +254 -0
  910. package/dist/modules/forms/data/validators.js.map +7 -0
  911. package/dist/modules/forms/di.js +199 -0
  912. package/dist/modules/forms/di.js.map +7 -0
  913. package/dist/modules/forms/encryption.js +15 -0
  914. package/dist/modules/forms/encryption.js.map +7 -0
  915. package/dist/modules/forms/events-payloads.js +81 -0
  916. package/dist/modules/forms/events-payloads.js.map +7 -0
  917. package/dist/modules/forms/events.js +33 -0
  918. package/dist/modules/forms/events.js.map +7 -0
  919. package/dist/modules/forms/extension-points.js +36 -0
  920. package/dist/modules/forms/extension-points.js.map +7 -0
  921. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.js +33 -0
  922. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.js.map +7 -0
  923. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.meta.js +11 -0
  924. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.meta.js.map +7 -0
  925. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.js +41 -0
  926. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.js.map +7 -0
  927. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.meta.js +11 -0
  928. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.meta.js.map +7 -0
  929. package/dist/modules/forms/frontend/embed/[slug]/page.js +105 -0
  930. package/dist/modules/forms/frontend/embed/[slug]/page.js.map +7 -0
  931. package/dist/modules/forms/frontend/embed/[slug]/page.meta.js +11 -0
  932. package/dist/modules/forms/frontend/embed/[slug]/page.meta.js.map +7 -0
  933. package/dist/modules/forms/frontend/f/[slug]/page.js +12 -0
  934. package/dist/modules/forms/frontend/f/[slug]/page.js.map +7 -0
  935. package/dist/modules/forms/frontend/f/[slug]/page.meta.js +11 -0
  936. package/dist/modules/forms/frontend/f/[slug]/page.meta.js.map +7 -0
  937. package/dist/modules/forms/frontend/forms/[id]/run/page.js +62 -0
  938. package/dist/modules/forms/frontend/forms/[id]/run/page.js.map +7 -0
  939. package/dist/modules/forms/frontend/forms/[id]/run/page.meta.js +11 -0
  940. package/dist/modules/forms/frontend/forms/[id]/run/page.meta.js.map +7 -0
  941. package/dist/modules/forms/frontend/i/[token]/page.js +12 -0
  942. package/dist/modules/forms/frontend/i/[token]/page.js.map +7 -0
  943. package/dist/modules/forms/frontend/i/[token]/page.meta.js +11 -0
  944. package/dist/modules/forms/frontend/i/[token]/page.meta.js.map +7 -0
  945. package/dist/modules/forms/index.js +20 -0
  946. package/dist/modules/forms/index.js.map +7 -0
  947. package/dist/modules/forms/lib/embed-frame-policy.js +68 -0
  948. package/dist/modules/forms/lib/embed-frame-policy.js.map +7 -0
  949. package/dist/modules/forms/lib/form-definition-slicing.js +38 -0
  950. package/dist/modules/forms/lib/form-definition-slicing.js.map +7 -0
  951. package/dist/modules/forms/lib/log-redaction.js +38 -0
  952. package/dist/modules/forms/lib/log-redaction.js.map +7 -0
  953. package/dist/modules/forms/lib/navigable-url.js +24 -0
  954. package/dist/modules/forms/lib/navigable-url.js.map +7 -0
  955. package/dist/modules/forms/lib/retention.js +20 -0
  956. package/dist/modules/forms/lib/retention.js.map +7 -0
  957. package/dist/modules/forms/lib/runtime-principal.js +59 -0
  958. package/dist/modules/forms/lib/runtime-principal.js.map +7 -0
  959. package/dist/modules/forms/migrations/Migration20260508135459_forms.js +17 -0
  960. package/dist/modules/forms/migrations/Migration20260508135459_forms.js.map +7 -0
  961. package/dist/modules/forms/migrations/Migration20260508140932_forms.js +23 -0
  962. package/dist/modules/forms/migrations/Migration20260508140932_forms.js.map +7 -0
  963. package/dist/modules/forms/migrations/Migration20260508155737_forms.js +15 -0
  964. package/dist/modules/forms/migrations/Migration20260508155737_forms.js.map +7 -0
  965. package/dist/modules/forms/migrations/Migration20260520120000_forms.js +23 -0
  966. package/dist/modules/forms/migrations/Migration20260520120000_forms.js.map +7 -0
  967. package/dist/modules/forms/migrations/Migration20260521090000_forms.js +13 -0
  968. package/dist/modules/forms/migrations/Migration20260521090000_forms.js.map +7 -0
  969. package/dist/modules/forms/migrations/Migration20260521120000_forms.js +17 -0
  970. package/dist/modules/forms/migrations/Migration20260521120000_forms.js.map +7 -0
  971. package/dist/modules/forms/runner/FormRunner.js +786 -0
  972. package/dist/modules/forms/runner/FormRunner.js.map +7 -0
  973. package/dist/modules/forms/runner/MatrixField.js +150 -0
  974. package/dist/modules/forms/runner/MatrixField.js.map +7 -0
  975. package/dist/modules/forms/runner/RankingField.js +131 -0
  976. package/dist/modules/forms/runner/RankingField.js.map +7 -0
  977. package/dist/modules/forms/runner/ScaleField.js +78 -0
  978. package/dist/modules/forms/runner/ScaleField.js.map +7 -0
  979. package/dist/modules/forms/runner/SignatureField.js +132 -0
  980. package/dist/modules/forms/runner/SignatureField.js.map +7 -0
  981. package/dist/modules/forms/runner/tamper-check.js +85 -0
  982. package/dist/modules/forms/runner/tamper-check.js.map +7 -0
  983. package/dist/modules/forms/schema/address-countries.js +43 -0
  984. package/dist/modules/forms/schema/address-countries.js.map +7 -0
  985. package/dist/modules/forms/schema/field-type-patterns.js +15 -0
  986. package/dist/modules/forms/schema/field-type-patterns.js.map +7 -0
  987. package/dist/modules/forms/schema/field-type-registry-advanced.js +32 -0
  988. package/dist/modules/forms/schema/field-type-registry-advanced.js.map +7 -0
  989. package/dist/modules/forms/schema/field-type-registry.js +625 -0
  990. package/dist/modules/forms/schema/field-type-registry.js.map +7 -0
  991. package/dist/modules/forms/schema/file-field.js +64 -0
  992. package/dist/modules/forms/schema/file-field.js.map +7 -0
  993. package/dist/modules/forms/schema/group-field.js +143 -0
  994. package/dist/modules/forms/schema/group-field.js.map +7 -0
  995. package/dist/modules/forms/schema/jsonlogic-grammar.js +66 -0
  996. package/dist/modules/forms/schema/jsonlogic-grammar.js.map +7 -0
  997. package/dist/modules/forms/schema/jsonschema-extensions.js +739 -0
  998. package/dist/modules/forms/schema/jsonschema-extensions.js.map +7 -0
  999. package/dist/modules/forms/schema/layout-catalog.js +38 -0
  1000. package/dist/modules/forms/schema/layout-catalog.js.map +7 -0
  1001. package/dist/modules/forms/schema/signature-field.js +67 -0
  1002. package/dist/modules/forms/schema/signature-field.js.map +7 -0
  1003. package/dist/modules/forms/schema/style-extensions.js +77 -0
  1004. package/dist/modules/forms/schema/style-extensions.js.map +7 -0
  1005. package/dist/modules/forms/schema/style-validators.js +181 -0
  1006. package/dist/modules/forms/schema/style-validators.js.map +7 -0
  1007. package/dist/modules/forms/services/access-audit-logger.js +179 -0
  1008. package/dist/modules/forms/services/access-audit-logger.js.map +7 -0
  1009. package/dist/modules/forms/services/analytics-service.js +306 -0
  1010. package/dist/modules/forms/services/analytics-service.js.map +7 -0
  1011. package/dist/modules/forms/services/anonymize-service.js +123 -0
  1012. package/dist/modules/forms/services/anonymize-service.js.map +7 -0
  1013. package/dist/modules/forms/services/attachment-service.js +123 -0
  1014. package/dist/modules/forms/services/attachment-service.js.map +7 -0
  1015. package/dist/modules/forms/services/captcha-verifier.js +76 -0
  1016. package/dist/modules/forms/services/captcha-verifier.js.map +7 -0
  1017. package/dist/modules/forms/services/consent-record-service.js +96 -0
  1018. package/dist/modules/forms/services/consent-record-service.js.map +7 -0
  1019. package/dist/modules/forms/services/distribution-service.js +366 -0
  1020. package/dist/modules/forms/services/distribution-service.js.map +7 -0
  1021. package/dist/modules/forms/services/distribution-token.js +93 -0
  1022. package/dist/modules/forms/services/distribution-token.js.map +7 -0
  1023. package/dist/modules/forms/services/encryption-service.js +328 -0
  1024. package/dist/modules/forms/services/encryption-service.js.map +7 -0
  1025. package/dist/modules/forms/services/export-service.js +210 -0
  1026. package/dist/modules/forms/services/export-service.js.map +7 -0
  1027. package/dist/modules/forms/services/field-validation-service.js +168 -0
  1028. package/dist/modules/forms/services/field-validation-service.js.map +7 -0
  1029. package/dist/modules/forms/services/form-logic-evaluator.js +517 -0
  1030. package/dist/modules/forms/services/form-logic-evaluator.js.map +7 -0
  1031. package/dist/modules/forms/services/form-version-compiler.js +518 -0
  1032. package/dist/modules/forms/services/form-version-compiler.js.map +7 -0
  1033. package/dist/modules/forms/services/form-version-differ.js +89 -0
  1034. package/dist/modules/forms/services/form-version-differ.js.map +7 -0
  1035. package/dist/modules/forms/services/jsonlogic-evaluator.js +171 -0
  1036. package/dist/modules/forms/services/jsonlogic-evaluator.js.map +7 -0
  1037. package/dist/modules/forms/services/pdf-snapshot-service.js +526 -0
  1038. package/dist/modules/forms/services/pdf-snapshot-service.js.map +7 -0
  1039. package/dist/modules/forms/services/prefill-resolver.js +53 -0
  1040. package/dist/modules/forms/services/prefill-resolver.js.map +7 -0
  1041. package/dist/modules/forms/services/role-policy-service.js +55 -0
  1042. package/dist/modules/forms/services/role-policy-service.js.map +7 -0
  1043. package/dist/modules/forms/services/style-compiler.js +234 -0
  1044. package/dist/modules/forms/services/style-compiler.js.map +7 -0
  1045. package/dist/modules/forms/services/submission-service.js +858 -0
  1046. package/dist/modules/forms/services/submission-service.js.map +7 -0
  1047. package/dist/modules/forms/services/upload-scanner.js +9 -0
  1048. package/dist/modules/forms/services/upload-scanner.js.map +7 -0
  1049. package/dist/modules/forms/services/upload-validation.js +54 -0
  1050. package/dist/modules/forms/services/upload-validation.js.map +7 -0
  1051. package/dist/modules/forms/services/visibility-resolver.js +30 -0
  1052. package/dist/modules/forms/services/visibility-resolver.js.map +7 -0
  1053. package/dist/modules/forms/setup.js +18 -0
  1054. package/dist/modules/forms/setup.js.map +7 -0
  1055. package/dist/modules/forms/subscribers/forms-consent-projector.js +58 -0
  1056. package/dist/modules/forms/subscribers/forms-consent-projector.js.map +7 -0
  1057. package/dist/modules/forms/subscribers/forms-pdf-snapshot.js +68 -0
  1058. package/dist/modules/forms/subscribers/forms-pdf-snapshot.js.map +7 -0
  1059. package/dist/modules/forms/subscribers/forms-webhook-bridge-anonymized.js +29 -0
  1060. package/dist/modules/forms/subscribers/forms-webhook-bridge-anonymized.js.map +7 -0
  1061. package/dist/modules/forms/subscribers/forms-webhook-bridge.js +35 -0
  1062. package/dist/modules/forms/subscribers/forms-webhook-bridge.js.map +7 -0
  1063. package/dist/modules/forms/subscribers/invitation-email.js +100 -0
  1064. package/dist/modules/forms/subscribers/invitation-email.js.map +7 -0
  1065. package/dist/modules/forms/translations.js +10 -0
  1066. package/dist/modules/forms/translations.js.map +7 -0
  1067. package/dist/modules/forms/ui/admin/forms/[id]/distributions/CreateDistributionDialog.js +376 -0
  1068. package/dist/modules/forms/ui/admin/forms/[id]/distributions/CreateDistributionDialog.js.map +7 -0
  1069. package/dist/modules/forms/ui/admin/forms/[id]/distributions/DistributionsPanel.js +313 -0
  1070. package/dist/modules/forms/ui/admin/forms/[id]/distributions/DistributionsPanel.js.map +7 -0
  1071. package/dist/modules/forms/ui/admin/forms/[id]/distributions/EmbedSettingsDialog.js +263 -0
  1072. package/dist/modules/forms/ui/admin/forms/[id]/distributions/EmbedSettingsDialog.js.map +7 -0
  1073. package/dist/modules/forms/ui/admin/forms/[id]/distributions/RecipientsTable.js +373 -0
  1074. package/dist/modules/forms/ui/admin/forms/[id]/distributions/RecipientsTable.js.map +7 -0
  1075. package/dist/modules/forms/ui/public/EmbeddedForm.js +166 -0
  1076. package/dist/modules/forms/ui/public/EmbeddedForm.js.map +7 -0
  1077. package/dist/modules/forms/ui/public/FormRunner.js +359 -0
  1078. package/dist/modules/forms/ui/public/FormRunner.js.map +7 -0
  1079. package/dist/modules/forms/ui/public/FormTrigger.js +45 -0
  1080. package/dist/modules/forms/ui/public/FormTrigger.js.map +7 -0
  1081. package/dist/modules/forms/ui/public/PublicFormRunnerPage.js +14 -0
  1082. package/dist/modules/forms/ui/public/PublicFormRunnerPage.js.map +7 -0
  1083. package/dist/modules/forms/ui/public/components/CompletionScreen.js +55 -0
  1084. package/dist/modules/forms/ui/public/components/CompletionScreen.js.map +7 -0
  1085. package/dist/modules/forms/ui/public/components/LocaleSwitch.js +28 -0
  1086. package/dist/modules/forms/ui/public/components/LocaleSwitch.js.map +7 -0
  1087. package/dist/modules/forms/ui/public/components/ResumeGate.js +52 -0
  1088. package/dist/modules/forms/ui/public/components/ResumeGate.js.map +7 -0
  1089. package/dist/modules/forms/ui/public/components/ReviewStep.js +90 -0
  1090. package/dist/modules/forms/ui/public/components/ReviewStep.js.map +7 -0
  1091. package/dist/modules/forms/ui/public/components/SaveIndicator.js +65 -0
  1092. package/dist/modules/forms/ui/public/components/SaveIndicator.js.map +7 -0
  1093. package/dist/modules/forms/ui/public/components/SectionStepper.js +52 -0
  1094. package/dist/modules/forms/ui/public/components/SectionStepper.js.map +7 -0
  1095. package/dist/modules/forms/ui/public/index.js +38 -0
  1096. package/dist/modules/forms/ui/public/index.js.map +7 -0
  1097. package/dist/modules/forms/ui/public/renderers/index.js +737 -0
  1098. package/dist/modules/forms/ui/public/renderers/index.js.map +7 -0
  1099. package/dist/modules/forms/ui/public/state/logic-derivation.js +42 -0
  1100. package/dist/modules/forms/ui/public/state/logic-derivation.js.map +7 -0
  1101. package/dist/modules/forms/ui/public/state/runtime-client.js +306 -0
  1102. package/dist/modules/forms/ui/public/state/runtime-client.js.map +7 -0
  1103. package/dist/modules/forms/ui/public/state/useAutosave.js +64 -0
  1104. package/dist/modules/forms/ui/public/state/useAutosave.js.map +7 -0
  1105. package/dist/modules/forms/ui/public/state/useFormRunner.js +394 -0
  1106. package/dist/modules/forms/ui/public/state/useFormRunner.js.map +7 -0
  1107. package/dist/modules/forms/ui/public/style/LogoHeader.js +33 -0
  1108. package/dist/modules/forms/ui/public/style/LogoHeader.js.map +7 -0
  1109. package/dist/modules/forms/ui/public/style/applyStyle.js +12 -0
  1110. package/dist/modules/forms/ui/public/style/applyStyle.js.map +7 -0
  1111. package/dist/modules/forms/ui/public/types.js +18 -0
  1112. package/dist/modules/forms/ui/public/types.js.map +7 -0
  1113. package/dist/modules/forms/widgets/injection/access-audit-panel/widget.js +100 -0
  1114. package/dist/modules/forms/widgets/injection/access-audit-panel/widget.js.map +7 -0
  1115. package/dist/modules/forms/widgets/injection/anonymize-button/widget.js +148 -0
  1116. package/dist/modules/forms/widgets/injection/anonymize-button/widget.js.map +7 -0
  1117. package/dist/modules/forms/widgets/injection/audit-format.js +33 -0
  1118. package/dist/modules/forms/widgets/injection/audit-format.js.map +7 -0
  1119. package/dist/modules/forms/widgets/injection/context.js +5 -0
  1120. package/dist/modules/forms/widgets/injection/context.js.map +7 -0
  1121. package/dist/modules/forms/widgets/injection/embedded-form/widget.js +52 -0
  1122. package/dist/modules/forms/widgets/injection/embedded-form/widget.js.map +7 -0
  1123. package/dist/modules/forms/widgets/injection/pdf-download-button/widget.js +83 -0
  1124. package/dist/modules/forms/widgets/injection/pdf-download-button/widget.js.map +7 -0
  1125. package/dist/modules/forms/widgets/injection/self-audit-footer/widget.js +38 -0
  1126. package/dist/modules/forms/widgets/injection/self-audit-footer/widget.js.map +7 -0
  1127. package/dist/modules/forms/widgets/injection-table.js +32 -0
  1128. package/dist/modules/forms/widgets/injection-table.js.map +7 -0
  1129. package/dist/modules/forms/workers/pdf-snapshot.js +60 -0
  1130. package/dist/modules/forms/workers/pdf-snapshot.js.map +7 -0
  1131. package/dist/modules/forms/workers/retention-purge.js +112 -0
  1132. package/dist/modules/forms/workers/retention-purge.js.map +7 -0
  1133. package/dist/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.js +7 -1
  1134. package/dist/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.js.map +2 -2
  1135. package/dist/modules/inbox_ops/data/validators.js +2 -2
  1136. package/dist/modules/inbox_ops/data/validators.js.map +2 -2
  1137. package/dist/modules/inbox_ops/lib/llmProvider.js +5 -1
  1138. package/dist/modules/inbox_ops/lib/llmProvider.js.map +2 -2
  1139. package/dist/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.js +2 -2
  1140. package/dist/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.js.map +2 -2
  1141. package/dist/modules/integrations/di.js +3 -1
  1142. package/dist/modules/integrations/di.js.map +2 -2
  1143. package/dist/modules/integrations/lib/credentials-service.js +29 -36
  1144. package/dist/modules/integrations/lib/credentials-service.js.map +2 -2
  1145. package/dist/modules/messages/api/[id]/attachments/route.js +7 -3
  1146. package/dist/modules/messages/api/[id]/attachments/route.js.map +2 -2
  1147. package/dist/modules/messages/api/[id]/forward-preview/route.js +4 -3
  1148. package/dist/modules/messages/api/[id]/forward-preview/route.js.map +2 -2
  1149. package/dist/modules/messages/api/[id]/route.js +29 -3
  1150. package/dist/modules/messages/api/[id]/route.js.map +2 -2
  1151. package/dist/modules/messages/api/route.js +91 -2
  1152. package/dist/modules/messages/api/route.js.map +2 -2
  1153. package/dist/modules/messages/commands/messages.js +40 -6
  1154. package/dist/modules/messages/commands/messages.js.map +2 -2
  1155. package/dist/modules/messages/components/ComposeMessagePageClient.js +24 -1
  1156. package/dist/modules/messages/components/ComposeMessagePageClient.js.map +2 -2
  1157. package/dist/modules/messages/data/validators.js +11 -1
  1158. package/dist/modules/messages/data/validators.js.map +2 -2
  1159. package/dist/modules/messages/lib/channelThreadAccess.js +30 -0
  1160. package/dist/modules/messages/lib/channelThreadAccess.js.map +7 -0
  1161. package/dist/modules/messages/lib/composeSenderDelegation.js +87 -0
  1162. package/dist/modules/messages/lib/composeSenderDelegation.js.map +7 -0
  1163. package/dist/modules/messages/lib/composeSenderOptions.js +24 -0
  1164. package/dist/modules/messages/lib/composeSenderOptions.js.map +7 -0
  1165. package/dist/modules/messages/lib/email-sender.js +1 -11
  1166. package/dist/modules/messages/lib/email-sender.js.map +2 -2
  1167. package/dist/modules/messages/lib/forwarding.js +4 -4
  1168. package/dist/modules/messages/lib/forwarding.js.map +2 -2
  1169. package/dist/modules/messages/lib/markdownEmailBody.js +15 -0
  1170. package/dist/modules/messages/lib/markdownEmailBody.js.map +7 -0
  1171. package/dist/modules/messages/lib/messageSourceEntityTypes.js +7 -0
  1172. package/dist/modules/messages/lib/messageSourceEntityTypes.js.map +7 -0
  1173. package/dist/modules/messages/lib/routeHelpers.js +43 -0
  1174. package/dist/modules/messages/lib/routeHelpers.js.map +2 -2
  1175. package/dist/modules/messages/subscribers/message-notification.js +30 -1
  1176. package/dist/modules/messages/subscribers/message-notification.js.map +2 -2
  1177. package/dist/modules/notifications/api/[id]/action/route.js +2 -1
  1178. package/dist/modules/notifications/api/[id]/action/route.js.map +2 -2
  1179. package/dist/modules/notifications/api/openapi.js +2 -1
  1180. package/dist/modules/notifications/api/openapi.js.map +2 -2
  1181. package/dist/modules/notifications/frontend/NotificationSettingsPageClient.js +47 -28
  1182. package/dist/modules/notifications/frontend/NotificationSettingsPageClient.js.map +2 -2
  1183. package/dist/modules/notifications/lib/deliveryConfig.js +27 -2
  1184. package/dist/modules/notifications/lib/deliveryConfig.js.map +2 -2
  1185. package/dist/modules/notifications/lib/notificationMapper.js +3 -1
  1186. package/dist/modules/notifications/lib/notificationMapper.js.map +2 -2
  1187. package/dist/modules/notifications/lib/safeHref.js +4 -0
  1188. package/dist/modules/notifications/lib/safeHref.js.map +2 -2
  1189. package/dist/modules/planner/api/availability-date-specific.js +2 -1
  1190. package/dist/modules/planner/api/availability-date-specific.js.map +2 -2
  1191. package/dist/modules/planner/api/availability-weekly.js +2 -1
  1192. package/dist/modules/planner/api/availability-weekly.js.map +2 -2
  1193. package/dist/modules/progress/api/active/route.js +14 -2
  1194. package/dist/modules/progress/api/active/route.js.map +2 -2
  1195. package/dist/modules/progress/api/jobs/[id]/route.js +38 -22
  1196. package/dist/modules/progress/api/jobs/[id]/route.js.map +2 -2
  1197. package/dist/modules/progress/api/jobs/route.js +20 -6
  1198. package/dist/modules/progress/api/jobs/route.js.map +2 -2
  1199. package/dist/modules/progress/api/requestScope.js +32 -0
  1200. package/dist/modules/progress/api/requestScope.js.map +7 -0
  1201. package/dist/modules/progress/lib/organizationScope.js +10 -0
  1202. package/dist/modules/progress/lib/organizationScope.js.map +7 -0
  1203. package/dist/modules/progress/lib/progressService.js.map +2 -2
  1204. package/dist/modules/progress/lib/progressServiceImpl.js +48 -15
  1205. package/dist/modules/progress/lib/progressServiceImpl.js.map +2 -2
  1206. package/dist/modules/push_notifications/api/custom-send/route.js +4 -1
  1207. package/dist/modules/push_notifications/api/custom-send/route.js.map +2 -2
  1208. package/dist/modules/query_index/api/status.js +5 -3
  1209. package/dist/modules/query_index/api/status.js.map +2 -2
  1210. package/dist/modules/query_index/di.js +2 -1
  1211. package/dist/modules/query_index/di.js.map +2 -2
  1212. package/dist/modules/query_index/lib/engine.js +2 -1
  1213. package/dist/modules/query_index/lib/engine.js.map +2 -2
  1214. package/dist/modules/query_index/lib/request-encryption.js +16 -0
  1215. package/dist/modules/query_index/lib/request-encryption.js.map +7 -0
  1216. package/dist/modules/query_index/lib/search-tokens.js +31 -1
  1217. package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
  1218. package/dist/modules/resources/api/resources/tags/assign/route.js +2 -1
  1219. package/dist/modules/resources/api/resources/tags/assign/route.js.map +2 -2
  1220. package/dist/modules/resources/api/resources/tags/unassign/route.js +2 -1
  1221. package/dist/modules/resources/api/resources/tags/unassign/route.js.map +2 -2
  1222. package/dist/modules/resources/commands/activities.js +2 -2
  1223. package/dist/modules/resources/commands/activities.js.map +2 -2
  1224. package/dist/modules/sales/api/document-history/route.js +5 -1
  1225. package/dist/modules/sales/api/document-history/route.js.map +2 -2
  1226. package/dist/modules/sales/api/document-numbers/route.js +2 -1
  1227. package/dist/modules/sales/api/document-numbers/route.js.map +2 -2
  1228. package/dist/modules/sales/api/quotes/convert/route.js +2 -1
  1229. package/dist/modules/sales/api/quotes/convert/route.js.map +2 -2
  1230. package/dist/modules/sales/api/quotes/send/route.js +2 -1
  1231. package/dist/modules/sales/api/quotes/send/route.js.map +2 -2
  1232. package/dist/modules/sales/api/settings/document-numbers/route.js +7 -1
  1233. package/dist/modules/sales/api/settings/document-numbers/route.js.map +2 -2
  1234. package/dist/modules/sales/api/settings/order-editing/route.js +7 -1
  1235. package/dist/modules/sales/api/settings/order-editing/route.js.map +2 -2
  1236. package/dist/modules/sales/commands/documents.js +354 -138
  1237. package/dist/modules/sales/commands/documents.js.map +3 -3
  1238. package/dist/modules/sales/commands/payments.js +2 -1
  1239. package/dist/modules/sales/commands/payments.js.map +2 -2
  1240. package/dist/modules/sales/commands/settings.js +25 -5
  1241. package/dist/modules/sales/commands/settings.js.map +2 -2
  1242. package/dist/modules/sales/commands/shipments.js +2 -1
  1243. package/dist/modules/sales/commands/shipments.js.map +2 -2
  1244. package/dist/modules/sales/components/DocumentNumberSettings.js +32 -21
  1245. package/dist/modules/sales/components/DocumentNumberSettings.js.map +2 -2
  1246. package/dist/modules/sales/components/documents/ItemsSection.js +49 -11
  1247. package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
  1248. package/dist/modules/sales/lib/lineSnapshots.js +19 -0
  1249. package/dist/modules/sales/lib/lineSnapshots.js.map +2 -2
  1250. package/dist/modules/sales/setup.js +4 -4
  1251. package/dist/modules/sales/setup.js.map +2 -2
  1252. package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js +2 -2
  1253. package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js.map +2 -2
  1254. package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js +2 -2
  1255. package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js.map +2 -2
  1256. package/dist/modules/staff/api/leave-requests/accept/route.js +2 -1
  1257. package/dist/modules/staff/api/leave-requests/accept/route.js.map +2 -2
  1258. package/dist/modules/staff/api/leave-requests/reject/route.js +2 -1
  1259. package/dist/modules/staff/api/leave-requests/reject/route.js.map +2 -2
  1260. package/dist/modules/staff/api/leave-requests.js +2 -1
  1261. package/dist/modules/staff/api/leave-requests.js.map +2 -2
  1262. package/dist/modules/staff/api/team-members/self/route.js +2 -1
  1263. package/dist/modules/staff/api/team-members/self/route.js.map +2 -2
  1264. package/dist/modules/staff/api/team-members/tags/assign/route.js +2 -1
  1265. package/dist/modules/staff/api/team-members/tags/assign/route.js.map +2 -2
  1266. package/dist/modules/staff/api/team-members/tags/unassign/route.js +2 -1
  1267. package/dist/modules/staff/api/team-members/tags/unassign/route.js.map +2 -2
  1268. package/dist/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.js +12 -11
  1269. package/dist/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.js.map +2 -2
  1270. package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js +2 -1
  1271. package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js.map +2 -2
  1272. package/dist/modules/staff/api/timesheets/my-projects/route.js +2 -1
  1273. package/dist/modules/staff/api/timesheets/my-projects/route.js.map +2 -2
  1274. package/dist/modules/staff/api/timesheets/my-work/route.js +2 -1
  1275. package/dist/modules/staff/api/timesheets/my-work/route.js.map +2 -2
  1276. package/dist/modules/staff/api/timesheets/projects/kpis/route.js +2 -1
  1277. package/dist/modules/staff/api/timesheets/projects/kpis/route.js.map +2 -2
  1278. package/dist/modules/staff/api/timesheets/reports/[id]/close/route.js +2 -1
  1279. package/dist/modules/staff/api/timesheets/reports/[id]/close/route.js.map +2 -2
  1280. package/dist/modules/staff/api/timesheets/reports/[id]/export/route.js +3 -2
  1281. package/dist/modules/staff/api/timesheets/reports/[id]/export/route.js.map +2 -2
  1282. package/dist/modules/staff/api/timesheets/reports/[id]/sheet/route.js +3 -2
  1283. package/dist/modules/staff/api/timesheets/reports/[id]/sheet/route.js.map +2 -2
  1284. package/dist/modules/staff/api/timesheets/reports/[id]/unlock/route.js +3 -2
  1285. package/dist/modules/staff/api/timesheets/reports/[id]/unlock/route.js.map +2 -2
  1286. package/dist/modules/staff/api/timesheets/reports/preview/route.js +2 -1
  1287. package/dist/modules/staff/api/timesheets/reports/preview/route.js.map +2 -2
  1288. package/dist/modules/staff/api/timesheets/reports/shared.js +2 -1
  1289. package/dist/modules/staff/api/timesheets/reports/shared.js.map +2 -2
  1290. package/dist/modules/staff/api/timesheets/settings/reapply-rounding/route.js +2 -1
  1291. package/dist/modules/staff/api/timesheets/settings/reapply-rounding/route.js.map +2 -2
  1292. package/dist/modules/staff/api/timesheets/tags/entry-assignments/route.js +2 -1
  1293. package/dist/modules/staff/api/timesheets/tags/entry-assignments/route.js.map +2 -2
  1294. package/dist/modules/staff/api/timesheets/tags/task-assignments/route.js +2 -1
  1295. package/dist/modules/staff/api/timesheets/tags/task-assignments/route.js.map +2 -2
  1296. package/dist/modules/staff/api/timesheets/tasks/[id]/comments/route.js +2 -1
  1297. package/dist/modules/staff/api/timesheets/tasks/[id]/comments/route.js.map +2 -2
  1298. package/dist/modules/staff/api/timesheets/tasks/[id]/status/route.js +2 -1
  1299. package/dist/modules/staff/api/timesheets/tasks/[id]/status/route.js.map +2 -2
  1300. package/dist/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.js +3 -2
  1301. package/dist/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.js.map +2 -2
  1302. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js +2 -1
  1303. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js.map +2 -2
  1304. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js +2 -1
  1305. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js.map +2 -2
  1306. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js +2 -1
  1307. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js.map +2 -2
  1308. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js +2 -1
  1309. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js.map +2 -2
  1310. package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js +2 -1
  1311. package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js.map +2 -2
  1312. package/dist/modules/staff/api/timesheets/time-entries/copy-day/route.js +3 -2
  1313. package/dist/modules/staff/api/timesheets/time-entries/copy-day/route.js.map +2 -2
  1314. package/dist/modules/staff/api/timesheets/time-entries/overlaps/route.js +2 -1
  1315. package/dist/modules/staff/api/timesheets/time-entries/overlaps/route.js.map +2 -2
  1316. package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js +3 -2
  1317. package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js.map +2 -2
  1318. package/dist/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.js +3 -2
  1319. package/dist/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.js.map +2 -2
  1320. package/dist/modules/staff/api/timesheets/time-projects/route.js +2 -1
  1321. package/dist/modules/staff/api/timesheets/time-projects/route.js.map +2 -2
  1322. package/dist/modules/staff/commands/activities.js +2 -2
  1323. package/dist/modules/staff/commands/activities.js.map +2 -2
  1324. package/dist/modules/staff/commands/timesheets-entries.js.map +2 -2
  1325. package/dist/modules/staff/commands/timesheets-reports.js +55 -14
  1326. package/dist/modules/staff/commands/timesheets-reports.js.map +2 -2
  1327. package/dist/modules/staff/lib/timesheets-reports/buildReportSheet.js +2 -1
  1328. package/dist/modules/staff/lib/timesheets-reports/buildReportSheet.js.map +2 -2
  1329. package/dist/modules/staff/lib/timesheets-reports/loadReportData.js +32 -3
  1330. package/dist/modules/staff/lib/timesheets-reports/loadReportData.js.map +2 -2
  1331. package/dist/modules/staff/lib/timesheets-reports/reportPeriod.js +16 -0
  1332. package/dist/modules/staff/lib/timesheets-reports/reportPeriod.js.map +7 -0
  1333. package/dist/modules/staff/lib/timesheets-ui/CalendarPicker.js +15 -10
  1334. package/dist/modules/staff/lib/timesheets-ui/CalendarPicker.js.map +2 -2
  1335. package/dist/modules/sync_excel/api/import/route.js +35 -12
  1336. package/dist/modules/sync_excel/api/import/route.js.map +2 -2
  1337. package/dist/modules/sync_excel/api/upload/route.js +29 -4
  1338. package/dist/modules/sync_excel/api/upload/route.js.map +2 -2
  1339. package/dist/modules/translations/api/context.js +2 -1
  1340. package/dist/modules/translations/api/context.js.map +2 -2
  1341. package/dist/modules/warranty_claims/api/ai/assess/route.js +2 -1
  1342. package/dist/modules/warranty_claims/api/ai/assess/route.js.map +2 -2
  1343. package/dist/modules/warranty_claims/api/ai/draft-reply/route.js +2 -1
  1344. package/dist/modules/warranty_claims/api/ai/draft-reply/route.js.map +2 -2
  1345. package/dist/modules/warranty_claims/api/ai/suggest/route.js +2 -1
  1346. package/dist/modules/warranty_claims/api/ai/suggest/route.js.map +2 -2
  1347. package/dist/modules/warranty_claims/api/assign/route.js +2 -1
  1348. package/dist/modules/warranty_claims/api/assign/route.js.map +2 -2
  1349. package/dist/modules/warranty_claims/api/credit-memo/route.js +2 -1
  1350. package/dist/modules/warranty_claims/api/credit-memo/route.js.map +2 -2
  1351. package/dist/modules/warranty_claims/api/entitlement/route.js +2 -1
  1352. package/dist/modules/warranty_claims/api/entitlement/route.js.map +2 -2
  1353. package/dist/modules/warranty_claims/api/events/route.js +2 -1
  1354. package/dist/modules/warranty_claims/api/events/route.js.map +2 -2
  1355. package/dist/modules/warranty_claims/api/external/claims/route.js +2 -1
  1356. package/dist/modules/warranty_claims/api/external/claims/route.js.map +2 -2
  1357. package/dist/modules/warranty_claims/api/receiving/route.js +2 -1
  1358. package/dist/modules/warranty_claims/api/receiving/route.js.map +2 -2
  1359. package/dist/modules/warranty_claims/api/replacement-order/route.js +2 -1
  1360. package/dist/modules/warranty_claims/api/replacement-order/route.js.map +2 -2
  1361. package/dist/modules/warranty_claims/api/return-label/route.js +2 -1
  1362. package/dist/modules/warranty_claims/api/return-label/route.js.map +2 -2
  1363. package/dist/modules/warranty_claims/api/risk/route.js +2 -1
  1364. package/dist/modules/warranty_claims/api/risk/route.js.map +2 -2
  1365. package/dist/modules/warranty_claims/api/sales-return/route.js +2 -1
  1366. package/dist/modules/warranty_claims/api/sales-return/route.js.map +2 -2
  1367. package/dist/modules/warranty_claims/api/settings-general/route.js +2 -1
  1368. package/dist/modules/warranty_claims/api/settings-general/route.js.map +2 -2
  1369. package/dist/modules/warranty_claims/api/stats/route.js +9 -5
  1370. package/dist/modules/warranty_claims/api/stats/route.js.map +2 -2
  1371. package/dist/modules/warranty_claims/api/submit/route.js +2 -1
  1372. package/dist/modules/warranty_claims/api/submit/route.js.map +2 -2
  1373. package/dist/modules/warranty_claims/api/transition/route.js +2 -1
  1374. package/dist/modules/warranty_claims/api/transition/route.js.map +2 -2
  1375. package/dist/modules/warranty_claims/api/vendor-recovery/route.js +2 -1
  1376. package/dist/modules/warranty_claims/api/vendor-recovery/route.js.map +2 -2
  1377. package/dist/modules/warranty_claims/api/vendor-recovery-suggestions/route.js +2 -1
  1378. package/dist/modules/warranty_claims/api/vendor-recovery-suggestions/route.js.map +2 -2
  1379. package/dist/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.js +1 -1
  1380. package/dist/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.js.map +2 -2
  1381. package/dist/modules/wms/api/dashboard/operational/route.js +2 -1
  1382. package/dist/modules/wms/api/dashboard/operational/route.js.map +2 -2
  1383. package/dist/modules/wms/api/inventory/cycle-count/route.js +1 -0
  1384. package/dist/modules/wms/api/inventory/cycle-count/route.js.map +2 -2
  1385. package/dist/modules/wms/api/inventory/helpers.js +2 -1
  1386. package/dist/modules/wms/api/inventory/helpers.js.map +2 -2
  1387. package/dist/modules/wms/api/inventory/import/helpers.js +2 -1
  1388. package/dist/modules/wms/api/inventory/import/helpers.js.map +2 -2
  1389. package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js +2 -1
  1390. package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js.map +2 -2
  1391. package/dist/modules/wms/commands/inventory-actions.js +39 -1
  1392. package/dist/modules/wms/commands/inventory-actions.js.map +2 -2
  1393. package/dist/modules/wms/components/backend/CycleCountWizardDialog.js +14 -1
  1394. package/dist/modules/wms/components/backend/CycleCountWizardDialog.js.map +2 -2
  1395. package/dist/modules/wms/di.js +5 -0
  1396. package/dist/modules/wms/di.js.map +2 -2
  1397. package/dist/modules/wms/lib/availabilityCache.js +86 -0
  1398. package/dist/modules/wms/lib/availabilityCache.js.map +7 -0
  1399. package/dist/modules/wms/lib/availabilityCalculation.js +212 -0
  1400. package/dist/modules/wms/lib/availabilityCalculation.js.map +7 -0
  1401. package/dist/modules/wms/lib/availabilityProvider.js +24 -0
  1402. package/dist/modules/wms/lib/availabilityProvider.js.map +7 -0
  1403. package/dist/modules/wms/lib/loadOperationalDashboard.js +42 -5
  1404. package/dist/modules/wms/lib/loadOperationalDashboard.js.map +2 -2
  1405. package/dist/modules/wms/lib/lowStockBalanceFilter.js +23 -10
  1406. package/dist/modules/wms/lib/lowStockBalanceFilter.js.map +2 -2
  1407. package/dist/modules/wms/lib/sqlInClause.js +9 -0
  1408. package/dist/modules/wms/lib/sqlInClause.js.map +7 -0
  1409. package/dist/modules/wms/lib/tryResolve.js +11 -0
  1410. package/dist/modules/wms/lib/tryResolve.js.map +7 -0
  1411. package/dist/modules/wms/subscribers/invalidate-availability-cache-policy.js +14 -0
  1412. package/dist/modules/wms/subscribers/invalidate-availability-cache-policy.js.map +7 -0
  1413. package/dist/modules/wms/subscribers/invalidate-availability-cache-profile.js +14 -0
  1414. package/dist/modules/wms/subscribers/invalidate-availability-cache-profile.js.map +7 -0
  1415. package/dist/modules/wms/subscribers/invalidate-availability-cache.js +16 -0
  1416. package/dist/modules/wms/subscribers/invalidate-availability-cache.js.map +7 -0
  1417. package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js +2 -2
  1418. package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js.map +2 -2
  1419. package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js +4 -3
  1420. package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js.map +2 -2
  1421. package/dist/modules/workflows/api/commands/route.js +4 -1
  1422. package/dist/modules/workflows/api/commands/route.js.map +2 -2
  1423. package/dist/modules/workflows/api/definitions/[id]/callers/route.js +4 -1
  1424. package/dist/modules/workflows/api/definitions/[id]/callers/route.js.map +2 -2
  1425. package/dist/modules/workflows/api/definitions/[id]/context-schema/route.js +4 -2
  1426. package/dist/modules/workflows/api/definitions/[id]/context-schema/route.js.map +2 -2
  1427. package/dist/modules/workflows/api/definitions/[id]/customize/route.js +4 -1
  1428. package/dist/modules/workflows/api/definitions/[id]/customize/route.js.map +2 -2
  1429. package/dist/modules/workflows/api/definitions/[id]/draft/route.js +6 -1
  1430. package/dist/modules/workflows/api/definitions/[id]/draft/route.js.map +2 -2
  1431. package/dist/modules/workflows/api/definitions/[id]/publish/route.js +6 -1
  1432. package/dist/modules/workflows/api/definitions/[id]/publish/route.js.map +2 -2
  1433. package/dist/modules/workflows/api/definitions/[id]/reset-to-code/route.js +4 -1
  1434. package/dist/modules/workflows/api/definitions/[id]/reset-to-code/route.js.map +2 -2
  1435. package/dist/modules/workflows/api/definitions/[id]/route.js +5 -3
  1436. package/dist/modules/workflows/api/definitions/[id]/route.js.map +2 -2
  1437. package/dist/modules/workflows/api/definitions/[id]/test-step/route.js +4 -2
  1438. package/dist/modules/workflows/api/definitions/[id]/test-step/route.js.map +2 -2
  1439. package/dist/modules/workflows/api/definitions/generate/route.js +4 -1
  1440. package/dist/modules/workflows/api/definitions/generate/route.js.map +2 -2
  1441. package/dist/modules/workflows/api/definitions/route.js +4 -2
  1442. package/dist/modules/workflows/api/definitions/route.js.map +2 -2
  1443. package/dist/modules/workflows/api/endpoints/route.js +4 -1
  1444. package/dist/modules/workflows/api/endpoints/route.js.map +2 -2
  1445. package/dist/modules/workflows/api/functions/route.js +4 -1
  1446. package/dist/modules/workflows/api/functions/route.js.map +2 -2
  1447. package/dist/modules/workflows/api/grantable-features/route.js +2 -1
  1448. package/dist/modules/workflows/api/grantable-features/route.js.map +2 -2
  1449. package/dist/modules/workflows/api/instances/[id]/advance/route.js +4 -1
  1450. package/dist/modules/workflows/api/instances/[id]/advance/route.js.map +2 -2
  1451. package/dist/modules/workflows/api/instances/[id]/cancel/route.js +4 -1
  1452. package/dist/modules/workflows/api/instances/[id]/cancel/route.js.map +2 -2
  1453. package/dist/modules/workflows/api/instances/[id]/context/route.js +2 -1
  1454. package/dist/modules/workflows/api/instances/[id]/context/route.js.map +2 -2
  1455. package/dist/modules/workflows/api/instances/[id]/rerun-step/route.js +4 -1
  1456. package/dist/modules/workflows/api/instances/[id]/rerun-step/route.js.map +2 -2
  1457. package/dist/modules/workflows/api/instances/[id]/retry/route.js +4 -1
  1458. package/dist/modules/workflows/api/instances/[id]/retry/route.js.map +2 -2
  1459. package/dist/modules/workflows/api/instances/[id]/signal/route.js +4 -1
  1460. package/dist/modules/workflows/api/instances/[id]/signal/route.js.map +2 -2
  1461. package/dist/modules/workflows/api/instances/[id]/step-through/route.js +4 -2
  1462. package/dist/modules/workflows/api/instances/[id]/step-through/route.js.map +2 -2
  1463. package/dist/modules/workflows/api/instances/route.js +4 -2
  1464. package/dist/modules/workflows/api/instances/route.js.map +2 -2
  1465. package/dist/modules/workflows/api/instances/validate-start/route.js +4 -1
  1466. package/dist/modules/workflows/api/instances/validate-start/route.js.map +2 -2
  1467. package/dist/modules/workflows/api/rule-usage/route.js +4 -1
  1468. package/dist/modules/workflows/api/rule-usage/route.js.map +2 -2
  1469. package/dist/modules/workflows/api/signals/route.js +4 -1
  1470. package/dist/modules/workflows/api/signals/route.js.map +2 -2
  1471. package/dist/modules/workflows/api/tasks/[id]/claim/route.js +4 -1
  1472. package/dist/modules/workflows/api/tasks/[id]/claim/route.js.map +2 -2
  1473. package/dist/modules/workflows/api/tasks/[id]/complete/route.js +4 -1
  1474. package/dist/modules/workflows/api/tasks/[id]/complete/route.js.map +2 -2
  1475. package/dist/modules/workflows/api/tasks/[id]/reassign/route.js +2 -1
  1476. package/dist/modules/workflows/api/tasks/[id]/reassign/route.js.map +2 -2
  1477. package/dist/modules/workflows/api/tasks/[id]/unclaim/route.js +4 -1
  1478. package/dist/modules/workflows/api/tasks/[id]/unclaim/route.js.map +2 -2
  1479. package/dist/modules/workflows/api/templates/route.js +4 -1
  1480. package/dist/modules/workflows/api/templates/route.js.map +2 -2
  1481. package/dist/modules/workflows/api/work-inbox/next/route.js +4 -1
  1482. package/dist/modules/workflows/api/work-inbox/next/route.js.map +2 -2
  1483. package/dist/modules/workflows/lib/activity-executor.js +87 -20
  1484. package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
  1485. package/dist/modules/workflows/lib/activity-types.js +4 -4
  1486. package/dist/modules/workflows/lib/activity-types.js.map +2 -2
  1487. package/dist/modules/workflows/lib/activity-worker-handler.js +16 -11
  1488. package/dist/modules/workflows/lib/activity-worker-handler.js.map +2 -2
  1489. package/dist/modules/workflows/lib/event-trigger-service.js +8 -1
  1490. package/dist/modules/workflows/lib/event-trigger-service.js.map +2 -2
  1491. package/dist/modules/workflows/lib/step-handler.js +4 -4
  1492. package/dist/modules/workflows/lib/step-handler.js.map +2 -2
  1493. package/dist/test-utils/transactionalEntityManagerDouble.js +37 -0
  1494. package/dist/test-utils/transactionalEntityManagerDouble.js.map +7 -0
  1495. package/generated/entities/availability_policy/index.ts +19 -0
  1496. package/generated/entities/communication_channel/index.ts +1 -0
  1497. package/generated/entities/customer_email_conversation_share/index.ts +9 -0
  1498. package/generated/entities/customer_group/index.ts +15 -0
  1499. package/generated/entities/customer_group_membership/index.ts +13 -0
  1500. package/generated/entities/customer_group_terms/index.ts +15 -0
  1501. package/generated/entities/customer_interaction/index.ts +1 -0
  1502. package/generated/entities/form/index.ts +16 -0
  1503. package/generated/entities/form_access_audit/index.ts +9 -0
  1504. package/generated/entities/form_attachment/index.ts +13 -0
  1505. package/generated/entities/form_consent_record/index.ts +17 -0
  1506. package/generated/entities/form_distribution/index.ts +22 -0
  1507. package/generated/entities/form_invitation/index.ts +23 -0
  1508. package/generated/entities/form_submission/index.ts +18 -0
  1509. package/generated/entities/form_submission_actor/index.ts +10 -0
  1510. package/generated/entities/form_submission_revision/index.ts +13 -0
  1511. package/generated/entities/form_version/index.ts +17 -0
  1512. package/generated/entities/forms_encryption_key/index.ts +6 -0
  1513. package/generated/entities.ids.generated.ts +27 -2
  1514. package/generated/entity-fields-registry.ts +269 -0
  1515. package/package.json +19 -9
  1516. package/src/helpers/integration/communicationChannelsFixtures.ts +43 -0
  1517. package/src/helpers/integration/customerGroupsFixtures.ts +171 -0
  1518. package/src/helpers/integration/formsFixtures.ts +757 -0
  1519. package/src/modules/api_docs/api/get/version.ts +28 -11
  1520. package/src/modules/api_keys/api/keys/route.ts +89 -199
  1521. package/src/modules/api_keys/backend/api-keys/create/page.tsx +2 -2
  1522. package/src/modules/api_keys/commands/keys.ts +172 -0
  1523. package/src/modules/api_keys/i18n/de.json +1 -0
  1524. package/src/modules/api_keys/i18n/en.json +1 -0
  1525. package/src/modules/api_keys/i18n/es.json +1 -0
  1526. package/src/modules/api_keys/i18n/ko.json +1 -0
  1527. package/src/modules/api_keys/i18n/pl.json +1 -0
  1528. package/src/modules/api_keys/services/apiKeyService.ts +82 -49
  1529. package/src/modules/attachments/api/file/[id]/route.ts +9 -4
  1530. package/src/modules/attachments/api/image/[id]/[[...slug]]/route.ts +6 -4
  1531. package/src/modules/attachments/api/route.ts +10 -4
  1532. package/src/modules/attachments/components/AttachmentLibrary.tsx +16 -5
  1533. package/src/modules/attachments/lib/access.ts +1 -3
  1534. package/src/modules/attachments/lib/requestScope.ts +35 -3
  1535. package/src/modules/audit_logs/api/audit-logs/actions/export/route.ts +6 -1
  1536. package/src/modules/audit_logs/api/audit-logs/actions/redo/route.ts +41 -6
  1537. package/src/modules/audit_logs/api/audit-logs/actions/route.ts +6 -1
  1538. package/src/modules/audit_logs/api/audit-logs/actions/undo/route.ts +39 -4
  1539. package/src/modules/audit_logs/data/validators.ts +1 -0
  1540. package/src/modules/audit_logs/lib/actorSubject.ts +82 -0
  1541. package/src/modules/audit_logs/lib/replayAuthorization.ts +61 -0
  1542. package/src/modules/audit_logs/services/actionLogService.ts +191 -47
  1543. package/src/modules/auth/api/features.ts +1 -1
  1544. package/src/modules/auth/cli.ts +31 -17
  1545. package/src/modules/auth/commands/acl.ts +26 -36
  1546. package/src/modules/auth/commands/interceptors.ts +23 -0
  1547. package/src/modules/auth/commands/roles.ts +475 -148
  1548. package/src/modules/auth/commands/users.ts +693 -81
  1549. package/src/modules/auth/i18n/de.json +22 -0
  1550. package/src/modules/auth/i18n/en.json +22 -0
  1551. package/src/modules/auth/i18n/es.json +22 -0
  1552. package/src/modules/auth/i18n/ko.json +22 -0
  1553. package/src/modules/auth/i18n/pl.json +22 -0
  1554. package/src/modules/auth/lib/authorizationStateLocks.ts +340 -0
  1555. package/src/modules/auth/lib/commandReplay.ts +194 -0
  1556. package/src/modules/auth/lib/executionPrincipal.ts +36 -28
  1557. package/src/modules/auth/lib/grantChecks.ts +10 -2
  1558. package/src/modules/auth/lib/setup-app.ts +97 -50
  1559. package/src/modules/auth/lib/tokenHash.ts +16 -1
  1560. package/src/modules/auth/services/rbacService.ts +578 -6
  1561. package/src/modules/availability/acl.ts +12 -0
  1562. package/src/modules/availability/api/check/route.ts +136 -0
  1563. package/src/modules/availability/api/openapi.ts +28 -0
  1564. package/src/modules/availability/api/policies/resolve-preview/route.ts +83 -0
  1565. package/src/modules/availability/api/policies/route.ts +243 -0
  1566. package/src/modules/availability/backend/availability/check/page.meta.ts +12 -0
  1567. package/src/modules/availability/backend/availability/check/page.tsx +226 -0
  1568. package/src/modules/availability/backend/availability/policies/ResolutionPreviewPanel.tsx +112 -0
  1569. package/src/modules/availability/backend/availability/policies/ScopeFields.tsx +55 -0
  1570. package/src/modules/availability/backend/availability/policies/StockManagedField.tsx +37 -0
  1571. package/src/modules/availability/backend/availability/policies/[id]/page.meta.ts +8 -0
  1572. package/src/modules/availability/backend/availability/policies/[id]/page.tsx +202 -0
  1573. package/src/modules/availability/backend/availability/policies/create/page.meta.ts +8 -0
  1574. package/src/modules/availability/backend/availability/policies/create/page.tsx +134 -0
  1575. package/src/modules/availability/backend/availability/policies/formGroups.ts +83 -0
  1576. package/src/modules/availability/backend/availability/policies/page.meta.ts +12 -0
  1577. package/src/modules/availability/backend/availability/policies/page.tsx +232 -0
  1578. package/src/modules/availability/backend/availability/policies/policyPayload.ts +29 -0
  1579. package/src/modules/availability/commands/policies.ts +430 -0
  1580. package/src/modules/availability/commands/scope.ts +26 -0
  1581. package/src/modules/availability/data/entities.ts +93 -0
  1582. package/src/modules/availability/data/validators.ts +87 -0
  1583. package/src/modules/availability/di.ts +68 -0
  1584. package/src/modules/availability/events.ts +17 -0
  1585. package/src/modules/availability/i18n/de.json +93 -0
  1586. package/src/modules/availability/i18n/en.json +93 -0
  1587. package/src/modules/availability/i18n/es.json +93 -0
  1588. package/src/modules/availability/i18n/ko.json +93 -0
  1589. package/src/modules/availability/i18n/pl.json +93 -0
  1590. package/src/modules/availability/index.ts +13 -0
  1591. package/src/modules/availability/lib/catalogTarget.ts +72 -0
  1592. package/src/modules/availability/lib/organizationScope.ts +55 -0
  1593. package/src/modules/availability/lib/policyResolution.ts +289 -0
  1594. package/src/modules/availability/lib/tryResolve.ts +8 -0
  1595. package/src/modules/availability/migrations/.snapshot-open-mercato.json +375 -0
  1596. package/src/modules/availability/migrations/Migration20260922095844_availability.ts +13 -0
  1597. package/src/modules/availability/migrations/Migration20260930120000_availability.ts +22 -0
  1598. package/src/modules/availability/setup.ts +10 -0
  1599. package/src/modules/catalog/api/categories/bulk-create/route.ts +133 -0
  1600. package/src/modules/catalog/api/categories/route.ts +70 -8
  1601. package/src/modules/catalog/api/products/bulk-create/route.ts +133 -0
  1602. package/src/modules/catalog/api/products/route.ts +55 -24
  1603. package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +9 -16
  1604. package/src/modules/catalog/backend/catalog/products/create/page.tsx +16 -10
  1605. package/src/modules/catalog/commands/categories.ts +1 -0
  1606. package/src/modules/catalog/commands/products.ts +11 -7
  1607. package/src/modules/catalog/components/PriceKindSettings.tsx +6 -20
  1608. package/src/modules/catalog/components/prices/PriceScopeSelectors.tsx +2 -2
  1609. package/src/modules/catalog/components/products/ProductUomSection.tsx +26 -37
  1610. package/src/modules/catalog/components/products/productForm.ts +6 -4
  1611. package/src/modules/catalog/data/validators.ts +22 -0
  1612. package/src/modules/catalog/di.ts +2 -1
  1613. package/src/modules/catalog/events.ts +9 -3
  1614. package/src/modules/catalog/i18n/de.json +40 -0
  1615. package/src/modules/catalog/i18n/en.json +40 -0
  1616. package/src/modules/catalog/i18n/es.json +40 -0
  1617. package/src/modules/catalog/i18n/ko.json +40 -0
  1618. package/src/modules/catalog/i18n/pl.json +40 -0
  1619. package/src/modules/catalog/lib/bulkCreateCategories.ts +349 -0
  1620. package/src/modules/catalog/lib/bulkCreateCheckpoint.ts +176 -0
  1621. package/src/modules/catalog/lib/bulkCreateMutationGuards.ts +62 -0
  1622. package/src/modules/catalog/lib/bulkCreateProducts.ts +340 -0
  1623. package/src/modules/catalog/lib/bulkDelete.ts +10 -14
  1624. package/src/modules/catalog/lib/catalogQueue.ts +14 -0
  1625. package/src/modules/catalog/lib/currencyOptions.ts +28 -0
  1626. package/src/modules/catalog/lib/productSearch.ts +16 -0
  1627. package/src/modules/catalog/lib/seeds.ts +2 -43
  1628. package/src/modules/catalog/lib/unitLabels.ts +52 -0
  1629. package/src/modules/catalog/migrations/Migration20260914120000.ts +51 -0
  1630. package/src/modules/catalog/migrations/Migration20260914120100.ts +50 -0
  1631. package/src/modules/catalog/workers/catalog-category-bulk-create.ts +48 -0
  1632. package/src/modules/catalog/workers/catalog-product-bulk-create.ts +48 -0
  1633. package/src/modules/communication_channels/acl.ts +8 -0
  1634. package/src/modules/communication_channels/api/get/me/channels/route.ts +4 -0
  1635. package/src/modules/communication_channels/api/get/oauth/[provider]/callback/route.ts +23 -0
  1636. package/src/modules/communication_channels/api/post/channels/[id]/import-history/route.ts +3 -4
  1637. package/src/modules/communication_channels/api/post/channels/[id]/test-send/route.ts +9 -1
  1638. package/src/modules/communication_channels/api/post/test-seed/route.ts +109 -24
  1639. package/src/modules/communication_channels/api/put/channels/[id]/visibility/route.ts +165 -0
  1640. package/src/modules/communication_channels/backend/profile/communication-channels/page.tsx +247 -129
  1641. package/src/modules/communication_channels/commands/ingest-inbound-message.ts +2 -1
  1642. package/src/modules/communication_channels/commands/set-channel-visibility.ts +138 -0
  1643. package/src/modules/communication_channels/data/enrichers.ts +42 -19
  1644. package/src/modules/communication_channels/data/entities.ts +21 -0
  1645. package/src/modules/communication_channels/di.ts +9 -0
  1646. package/src/modules/communication_channels/events.ts +7 -0
  1647. package/src/modules/communication_channels/i18n/de.json +13 -3
  1648. package/src/modules/communication_channels/i18n/en.json +13 -3
  1649. package/src/modules/communication_channels/i18n/es.json +13 -3
  1650. package/src/modules/communication_channels/i18n/ko.json +13 -3
  1651. package/src/modules/communication_channels/i18n/pl.json +13 -3
  1652. package/src/modules/communication_channels/index.ts +1 -1
  1653. package/src/modules/communication_channels/lib/access-control.ts +4 -1
  1654. package/src/modules/communication_channels/lib/adapter.ts +16 -6
  1655. package/src/modules/communication_channels/lib/channel-thread-access.ts +133 -0
  1656. package/src/modules/communication_channels/lib/credential-refresh.ts +27 -5
  1657. package/src/modules/communication_channels/lib/inbound-message-origin.ts +62 -0
  1658. package/src/modules/communication_channels/lib/oauth-state.ts +96 -1
  1659. package/src/modules/communication_channels/lib/outbound-delivery-intent.ts +57 -0
  1660. package/src/modules/communication_channels/lib/send-as-user.ts +2 -2
  1661. package/src/modules/communication_channels/migrations/.snapshot-open-mercato.json +18 -1
  1662. package/src/modules/communication_channels/migrations/Migration20260825141000_communication_channels.ts +22 -0
  1663. package/src/modules/communication_channels/setup.ts +4 -0
  1664. package/src/modules/communication_channels/subscribers/outbound-bridge.ts +34 -9
  1665. package/src/modules/communication_channels/workers/gmail-history-sync.ts +1 -1
  1666. package/src/modules/communication_channels/workers/poll-channel.ts +1 -1
  1667. package/src/modules/communication_channels/workers/reaction-processor.ts +2 -2
  1668. package/src/modules/configs/api/upgrade-actions/route.ts +2 -1
  1669. package/src/modules/configs/cli.ts +2 -2
  1670. package/src/modules/configs/i18n/de.json +2 -0
  1671. package/src/modules/configs/i18n/en.json +2 -0
  1672. package/src/modules/configs/i18n/es.json +2 -0
  1673. package/src/modules/configs/i18n/ko.json +2 -0
  1674. package/src/modules/configs/i18n/pl.json +2 -0
  1675. package/src/modules/configs/lib/upgrade-actions.ts +29 -6
  1676. package/src/modules/configs/services/upgradeActionsService.ts +45 -30
  1677. package/src/modules/currencies/api/currencies/route.ts +11 -5
  1678. package/src/modules/currencies/api/exchange-rates/route.ts +11 -5
  1679. package/src/modules/customer_accounts/AGENTS.md +1 -0
  1680. package/src/modules/customer_accounts/api/admin/users/[id]/sessions/[sessionId].ts +89 -0
  1681. package/src/modules/customer_groups/acl.ts +10 -0
  1682. package/src/modules/customer_groups/api/customer-groups/[id]/terms/route.ts +355 -0
  1683. package/src/modules/customer_groups/api/customer-groups/crud.ts +627 -0
  1684. package/src/modules/customer_groups/api/customer-groups/explain-terms/route.ts +195 -0
  1685. package/src/modules/customer_groups/api/customer-groups/memberships/crud.ts +525 -0
  1686. package/src/modules/customer_groups/api/customer-groups/memberships/route.ts +65 -0
  1687. package/src/modules/customer_groups/api/customer-groups/price-kinds/route.ts +99 -0
  1688. package/src/modules/customer_groups/api/customer-groups/reconcile/adopt/route.ts +150 -0
  1689. package/src/modules/customer_groups/api/customer-groups/reconcile/route.ts +90 -0
  1690. package/src/modules/customer_groups/api/customer-groups/reorder/route.ts +147 -0
  1691. package/src/modules/customer_groups/api/customer-groups/route.ts +65 -0
  1692. package/src/modules/customer_groups/api/openapi.ts +28 -0
  1693. package/src/modules/customer_groups/backend/customer-groups/[id]/edit/page.meta.ts +12 -0
  1694. package/src/modules/customer_groups/backend/customer-groups/[id]/edit/page.tsx +392 -0
  1695. package/src/modules/customer_groups/backend/customer-groups/create/page.meta.ts +25 -0
  1696. package/src/modules/customer_groups/backend/customer-groups/create/page.tsx +279 -0
  1697. package/src/modules/customer_groups/backend/customer-groups/orphans/page.meta.ts +12 -0
  1698. package/src/modules/customer_groups/backend/customer-groups/orphans/page.tsx +216 -0
  1699. package/src/modules/customer_groups/backend/customer-groups/page.meta.ts +11 -0
  1700. package/src/modules/customer_groups/backend/customer-groups/page.tsx +484 -0
  1701. package/src/modules/customer_groups/cli.ts +87 -0
  1702. package/src/modules/customer_groups/commands/reorderGroups.ts +163 -0
  1703. package/src/modules/customer_groups/components/CustomerGroupDefaultField.tsx +55 -0
  1704. package/src/modules/customer_groups/components/CustomerGroupParentField.tsx +194 -0
  1705. package/src/modules/customer_groups/components/CustomerGroupTermsPriceKindField.tsx +112 -0
  1706. package/src/modules/customer_groups/components/CustomerGroupTermsSection.tsx +277 -0
  1707. package/src/modules/customer_groups/components/GroupPickerField.tsx +142 -0
  1708. package/src/modules/customer_groups/components/OrphanBanner.tsx +92 -0
  1709. package/src/modules/customer_groups/components/customerGroupTree.ts +84 -0
  1710. package/src/modules/customer_groups/data/entities.ts +244 -0
  1711. package/src/modules/customer_groups/data/validators.ts +232 -0
  1712. package/src/modules/customer_groups/di.ts +25 -0
  1713. package/src/modules/customer_groups/events.ts +22 -0
  1714. package/src/modules/customer_groups/i18n/de.json +199 -0
  1715. package/src/modules/customer_groups/i18n/en.json +199 -0
  1716. package/src/modules/customer_groups/i18n/es.json +199 -0
  1717. package/src/modules/customer_groups/i18n/ko.json +199 -0
  1718. package/src/modules/customer_groups/i18n/pl.json +199 -0
  1719. package/src/modules/customer_groups/index.ts +13 -0
  1720. package/src/modules/customer_groups/lib/createConflictRecheck.ts +39 -0
  1721. package/src/modules/customer_groups/lib/customerScope.ts +145 -0
  1722. package/src/modules/customer_groups/lib/groupEvents.ts +50 -0
  1723. package/src/modules/customer_groups/lib/priceKindScope.ts +65 -0
  1724. package/src/modules/customer_groups/lib/reconcile.ts +299 -0
  1725. package/src/modules/customer_groups/migrations/.snapshot-open-mercato.json +905 -0
  1726. package/src/modules/customer_groups/migrations/Migration20260922095316_customer_groups.ts +26 -0
  1727. package/src/modules/customer_groups/migrations/Migration20260922103033_customer_groups.ts +22 -0
  1728. package/src/modules/customer_groups/migrations/Migration20260922105444_customer_groups.ts +17 -0
  1729. package/src/modules/customer_groups/migrations/Migration20260923193330_customer_groups.ts +20 -0
  1730. package/src/modules/customer_groups/migrations/Migration20260929083000_customer_groups.ts +21 -0
  1731. package/src/modules/customer_groups/services/customerGroupsService.ts +358 -0
  1732. package/src/modules/customer_groups/setup.ts +11 -0
  1733. package/src/modules/customer_groups/widgets/injection/group-picker-field/widget.ts +41 -0
  1734. package/src/modules/customer_groups/widgets/injection/person-groups-explain-terms.tsx +227 -0
  1735. package/src/modules/customer_groups/widgets/injection/person-groups-tab/widget.ts +21 -0
  1736. package/src/modules/customer_groups/widgets/injection/person-groups-tab.tsx +573 -0
  1737. package/src/modules/customer_groups/widgets/injection-table.ts +35 -0
  1738. package/src/modules/customers/acl.ts +13 -0
  1739. package/src/modules/customers/api/activities/route.ts +10 -0
  1740. package/src/modules/customers/api/companies/[id]/people/route.ts +2 -1
  1741. package/src/modules/customers/api/companies/[id]/route.ts +20 -6
  1742. package/src/modules/customers/api/deals/[id]/companies/route.ts +2 -1
  1743. package/src/modules/customers/api/deals/[id]/people/route.ts +2 -1
  1744. package/src/modules/customers/api/deals/map/route.ts +11 -10
  1745. package/src/modules/customers/api/dictionaries/context.ts +2 -1
  1746. package/src/modules/customers/api/entity-roles-factory.ts +3 -2
  1747. package/src/modules/customers/api/interactions/[id]/visibility/route.ts +2 -1
  1748. package/src/modules/customers/api/interactions/cancel/route.ts +2 -1
  1749. package/src/modules/customers/api/interactions/complete/route.ts +2 -1
  1750. package/src/modules/customers/api/interactions/conflicts/route.ts +10 -10
  1751. package/src/modules/customers/api/interactions/counts/route.ts +25 -7
  1752. package/src/modules/customers/api/interactions/route.ts +34 -10
  1753. package/src/modules/customers/api/labels/assign/route.ts +2 -1
  1754. package/src/modules/customers/api/labels/route.ts +3 -2
  1755. package/src/modules/customers/api/labels/unassign/route.ts +2 -1
  1756. package/src/modules/customers/api/people/[id]/companies/context.ts +11 -2
  1757. package/src/modules/customers/api/people/[id]/email-share/route.ts +276 -0
  1758. package/src/modules/customers/api/people/[id]/email-threads/route.ts +14 -1
  1759. package/src/modules/customers/api/people/[id]/emails/route.ts +2 -1
  1760. package/src/modules/customers/api/people/[id]/route.ts +31 -22
  1761. package/src/modules/customers/api/people/check-phone/route.ts +2 -1
  1762. package/src/modules/customers/api/pipeline-stages/reorder/route.ts +3 -2
  1763. package/src/modules/customers/api/pipeline-stages/route.ts +3 -3
  1764. package/src/modules/customers/api/pipelines/route.ts +3 -3
  1765. package/src/modules/customers/api/settings/address-format/route.ts +2 -1
  1766. package/src/modules/customers/api/settings/dictionary-sort-modes/route.ts +2 -1
  1767. package/src/modules/customers/api/settings/stuck-threshold/route.ts +2 -1
  1768. package/src/modules/customers/api/tags/assign/route.ts +2 -1
  1769. package/src/modules/customers/api/tags/unassign/route.ts +2 -1
  1770. package/src/modules/customers/backend/customers/companies/[id]/page.tsx +4 -2
  1771. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.ts +10 -6
  1772. package/src/modules/customers/backend/customers/deals/[id]/page.tsx +6 -1
  1773. package/src/modules/customers/backend/customers/deals/components/ReassignOwnerDialog.tsx +115 -0
  1774. package/src/modules/customers/backend/customers/deals/page.tsx +121 -1
  1775. package/src/modules/customers/backend/customers/people/[id]/page.tsx +4 -2
  1776. package/src/modules/customers/commands/addresses.ts +117 -15
  1777. package/src/modules/customers/commands/companies.ts +26 -5
  1778. package/src/modules/customers/commands/emailConversationShares.ts +261 -0
  1779. package/src/modules/customers/commands/index.ts +1 -0
  1780. package/src/modules/customers/commands/interactions.ts +61 -21
  1781. package/src/modules/customers/commands/people.ts +3 -2
  1782. package/src/modules/customers/commands/shared.ts +4 -0
  1783. package/src/modules/customers/components/calendar/types.ts +1 -1
  1784. package/src/modules/customers/components/detail/CompanyPeopleSection.tsx +3 -11
  1785. package/src/modules/customers/components/detail/DealForm.tsx +111 -2
  1786. package/src/modules/customers/components/detail/DealOwnerSelect.tsx +161 -0
  1787. package/src/modules/customers/components/detail/DealsSection.tsx +8 -14
  1788. package/src/modules/customers/components/detail/PersonEmailShareControl.tsx +273 -0
  1789. package/src/modules/customers/components/detail/PersonEmailThreadsTab.tsx +26 -0
  1790. package/src/modules/customers/components/detail/ScheduleActivityDialog.tsx +10 -2
  1791. package/src/modules/customers/components/detail/create/CreateDealForm.tsx +30 -0
  1792. package/src/modules/customers/components/detail/create/DealDetailsFields.tsx +12 -0
  1793. package/src/modules/customers/components/detail/create/DealSectionCard.tsx +7 -2
  1794. package/src/modules/customers/components/detail/create/dealFormTypes.ts +3 -0
  1795. package/src/modules/customers/components/detail/schedule/useScheduleFormState.ts +16 -4
  1796. package/src/modules/customers/components/formConfig.tsx +3 -0
  1797. package/src/modules/customers/components/linking/LinkEntityDialog.tsx +8 -0
  1798. package/src/modules/customers/data/enrichers.ts +64 -5
  1799. package/src/modules/customers/data/entities.ts +105 -1
  1800. package/src/modules/customers/data/validators.ts +22 -0
  1801. package/src/modules/customers/events.ts +5 -0
  1802. package/src/modules/customers/i18n/de.json +28 -5
  1803. package/src/modules/customers/i18n/en.json +23 -0
  1804. package/src/modules/customers/i18n/es.json +23 -0
  1805. package/src/modules/customers/i18n/ko.json +23 -0
  1806. package/src/modules/customers/i18n/pl.json +23 -0
  1807. package/src/modules/customers/lib/assignableStaff.ts +17 -0
  1808. package/src/modules/customers/lib/calendar/editorPayload.ts +20 -13
  1809. package/src/modules/customers/lib/calendar/mapItem.ts +1 -0
  1810. package/src/modules/customers/lib/conversationShares.ts +250 -0
  1811. package/src/modules/customers/lib/dealsOrganizationScope.ts +5 -3
  1812. package/src/modules/customers/lib/interactionRequestContext.ts +2 -1
  1813. package/src/modules/customers/lib/link-channel-message-handler.ts +27 -4
  1814. package/src/modules/customers/lib/personDetailCacheTags.ts +68 -0
  1815. package/src/modules/customers/lib/personEmailThreads.ts +61 -6
  1816. package/src/modules/customers/lib/reassignDealOwner.ts +51 -0
  1817. package/src/modules/customers/lib/userNames.ts +39 -0
  1818. package/src/modules/customers/lib/visibilityFilter.ts +170 -3
  1819. package/src/modules/customers/migrations/.snapshot-open-mercato.json +240 -0
  1820. package/src/modules/customers/migrations/Migration20260825120000_customers.ts +19 -0
  1821. package/src/modules/customers/migrations/Migration20260825140000_customers.ts +41 -0
  1822. package/src/modules/customers/setup.ts +1 -0
  1823. package/src/modules/customers/subscribers/channel-visibility-changed.ts +50 -0
  1824. package/src/modules/dashboards/api/widgets/data/batch/route.ts +3 -8
  1825. package/src/modules/dashboards/api/widgets/data/route.ts +12 -18
  1826. package/src/modules/dashboards/lib/aggregations.ts +1 -1
  1827. package/src/modules/dashboards/lib/widgetScope.ts +2 -7
  1828. package/src/modules/data_sync/AGENTS.md +35 -1
  1829. package/src/modules/data_sync/api/runs/[id]/cancel.ts +5 -1
  1830. package/src/modules/data_sync/backend/data-sync/page.tsx +292 -19
  1831. package/src/modules/data_sync/backend/data-sync/runs/[id]/page.tsx +205 -21
  1832. package/src/modules/data_sync/components/useDataSyncRunAccess.ts +27 -0
  1833. package/src/modules/data_sync/i18n/de.json +24 -0
  1834. package/src/modules/data_sync/i18n/en.json +24 -0
  1835. package/src/modules/data_sync/i18n/es.json +24 -0
  1836. package/src/modules/data_sync/i18n/ko.json +24 -0
  1837. package/src/modules/data_sync/i18n/pl.json +24 -0
  1838. package/src/modules/data_sync/lib/adapter.ts +37 -0
  1839. package/src/modules/data_sync/lib/resume-point.ts +63 -0
  1840. package/src/modules/data_sync/lib/start-run.ts +61 -2
  1841. package/src/modules/data_sync/lib/sync-run-service.ts +27 -34
  1842. package/src/modules/devices/api/[id]/route.ts +3 -2
  1843. package/src/modules/devices/api/admin/devices/route.ts +2 -1
  1844. package/src/modules/devices/api/route.ts +2 -1
  1845. package/src/modules/dictionaries/api/[dictionaryId]/route.ts +3 -5
  1846. package/src/modules/dictionaries/api/context.ts +2 -1
  1847. package/src/modules/dictionaries/api/route.ts +4 -0
  1848. package/src/modules/dictionaries/components/DictionariesManager.tsx +12 -4
  1849. package/src/modules/dictionaries/data/validators.ts +9 -1
  1850. package/src/modules/dictionaries/i18n/de.json +3 -3
  1851. package/src/modules/dictionaries/i18n/en.json +3 -3
  1852. package/src/modules/dictionaries/i18n/es.json +3 -3
  1853. package/src/modules/dictionaries/i18n/ko.json +3 -3
  1854. package/src/modules/dictionaries/i18n/pl.json +3 -3
  1855. package/src/modules/directory/api/organization-branding/route.ts +10 -1
  1856. package/src/modules/directory/api/organizations/route.ts +1 -1
  1857. package/src/modules/directory/backend/directory/branding/page.tsx +24 -2
  1858. package/src/modules/directory/commands/organizations.ts +173 -80
  1859. package/src/modules/directory/i18n/de.json +1 -0
  1860. package/src/modules/directory/i18n/en.json +1 -0
  1861. package/src/modules/directory/i18n/es.json +1 -0
  1862. package/src/modules/directory/i18n/ko.json +1 -0
  1863. package/src/modules/directory/i18n/pl.json +1 -0
  1864. package/src/modules/directory/lib/hierarchy.ts +22 -1
  1865. package/src/modules/directory/utils/organizationScope.ts +102 -15
  1866. package/src/modules/directory/utils/organizationScopeFilter.ts +6 -3
  1867. package/src/modules/directory/utils/organizationScopeGuard.ts +9 -5
  1868. package/src/modules/entities/api/encryption.ts +73 -27
  1869. package/src/modules/entities/api/records.ts +9 -8
  1870. package/src/modules/entities/cli.ts +46 -24
  1871. package/src/modules/entities/data/entities.ts +15 -0
  1872. package/src/modules/entities/lib/definition-scope.ts +5 -1
  1873. package/src/modules/entities/lib/encryption-maps.ts +164 -0
  1874. package/src/modules/entities/lib/helpers.ts +95 -8
  1875. package/src/modules/entities/migrations/.snapshot-open-mercato.json +21 -0
  1876. package/src/modules/entities/migrations/.snapshot-openmercato.json +12 -0
  1877. package/src/modules/entities/migrations/Migration20260910120000.ts +42 -0
  1878. package/src/modules/entities/migrations/Migration20261004120000_encryption_map_scope_uniqueness.ts +130 -0
  1879. package/src/modules/eudr/api/dashboard/widgets/compliance-overview/route.ts +2 -1
  1880. package/src/modules/eudr/api/plots/import/route.ts +2 -1
  1881. package/src/modules/eudr/api/product-mappings/suggestions/apply/route.ts +2 -1
  1882. package/src/modules/eudr/api/product-mappings/suggestions/route.ts +2 -1
  1883. package/src/modules/eudr/api/reports/annual/route.ts +2 -1
  1884. package/src/modules/eudr/api/statements/[id]/export/route.ts +2 -1
  1885. package/src/modules/eudr/api/statements/[id]/readiness/route.ts +2 -1
  1886. package/src/modules/eudr/api/suppliers/compliance/route.ts +2 -1
  1887. package/src/modules/eudr/i18n/de.json +1 -0
  1888. package/src/modules/eudr/i18n/en.json +1 -0
  1889. package/src/modules/eudr/i18n/es.json +1 -0
  1890. package/src/modules/eudr/i18n/ko.json +1 -0
  1891. package/src/modules/eudr/i18n/pl.json +1 -0
  1892. package/src/modules/feature_toggles/commands/global.ts +18 -15
  1893. package/src/modules/feature_toggles/lib/feature-flag-check.ts +8 -3
  1894. package/src/modules/forms/acl.ts +10 -0
  1895. package/src/modules/forms/api/[id]/analytics/route.ts +137 -0
  1896. package/src/modules/forms/api/[id]/distributions/route.ts +192 -0
  1897. package/src/modules/forms/api/[id]/route.ts +245 -0
  1898. package/src/modules/forms/api/[id]/run/context/route.ts +142 -0
  1899. package/src/modules/forms/api/[id]/run/submissions/route.ts +147 -0
  1900. package/src/modules/forms/api/[id]/submissions/route.ts +100 -0
  1901. package/src/modules/forms/api/[id]/theme-logo/route.ts +147 -0
  1902. package/src/modules/forms/api/[id]/versions/[versionId]/diff/route.ts +137 -0
  1903. package/src/modules/forms/api/[id]/versions/[versionId]/publish/route.ts +108 -0
  1904. package/src/modules/forms/api/[id]/versions/[versionId]/route.ts +200 -0
  1905. package/src/modules/forms/api/[id]/versions/fork/route.ts +98 -0
  1906. package/src/modules/forms/api/attachment-helpers.ts +160 -0
  1907. package/src/modules/forms/api/by-key/[key]/active/route.ts +165 -0
  1908. package/src/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/route.ts +92 -0
  1909. package/src/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/send/route.ts +96 -0
  1910. package/src/modules/forms/api/distributions/[distributionId]/invitations/route.ts +207 -0
  1911. package/src/modules/forms/api/distributions/[distributionId]/route.ts +213 -0
  1912. package/src/modules/forms/api/form-submissions/[id]/attachments/route.ts +114 -0
  1913. package/src/modules/forms/api/form-submissions/[id]/resume-token/route.ts +140 -0
  1914. package/src/modules/forms/api/form-submissions/[id]/route.ts +176 -0
  1915. package/src/modules/forms/api/form-submissions/[id]/submit/route.ts +91 -0
  1916. package/src/modules/forms/api/form-submissions/by-subject/[subject_type]/[subject_id]/route.ts +93 -0
  1917. package/src/modules/forms/api/form-submissions/route.ts +133 -0
  1918. package/src/modules/forms/api/helpers.ts +175 -0
  1919. package/src/modules/forms/api/public/distributions/[slug]/embed-policy/route.ts +74 -0
  1920. package/src/modules/forms/api/public/distributions/[slug]/route.ts +101 -0
  1921. package/src/modules/forms/api/public/embed-loader/route.ts +136 -0
  1922. package/src/modules/forms/api/public/invitations/[token]/route.ts +107 -0
  1923. package/src/modules/forms/api/public/rate-limit.ts +69 -0
  1924. package/src/modules/forms/api/public/start/route.ts +195 -0
  1925. package/src/modules/forms/api/public/submissions/[id]/attachments/[attachmentId]/route.ts +86 -0
  1926. package/src/modules/forms/api/public/submissions/[id]/attachments/route.ts +108 -0
  1927. package/src/modules/forms/api/public/submissions/[id]/pdf/route.ts +96 -0
  1928. package/src/modules/forms/api/public/submissions/[id]/route.ts +189 -0
  1929. package/src/modules/forms/api/public/submissions/[id]/submit/route.ts +159 -0
  1930. package/src/modules/forms/api/route.ts +240 -0
  1931. package/src/modules/forms/api/runtime-helpers.ts +208 -0
  1932. package/src/modules/forms/api/subjects/[subjectType]/[subjectId]/consents/route.ts +178 -0
  1933. package/src/modules/forms/api/subjects/[subjectType]/[subjectId]/export/route.ts +135 -0
  1934. package/src/modules/forms/api/submissions/[submissionId]/access-audit/route.ts +100 -0
  1935. package/src/modules/forms/api/submissions/[submissionId]/actors/[actorId]/route.ts +70 -0
  1936. package/src/modules/forms/api/submissions/[submissionId]/actors/route.ts +92 -0
  1937. package/src/modules/forms/api/submissions/[submissionId]/anonymize/route.ts +134 -0
  1938. package/src/modules/forms/api/submissions/[submissionId]/attachments/[attachmentId]/route.ts +90 -0
  1939. package/src/modules/forms/api/submissions/[submissionId]/export/route.ts +111 -0
  1940. package/src/modules/forms/api/submissions/[submissionId]/pdf/route.ts +118 -0
  1941. package/src/modules/forms/api/submissions/[submissionId]/reopen/route.ts +69 -0
  1942. package/src/modules/forms/api/submissions/[submissionId]/revisions/route.ts +75 -0
  1943. package/src/modules/forms/api/submissions/[submissionId]/route.ts +90 -0
  1944. package/src/modules/forms/backend/forms/[id]/FormStudio.tsx +3269 -0
  1945. package/src/modules/forms/backend/forms/[id]/analytics/page.meta.ts +15 -0
  1946. package/src/modules/forms/backend/forms/[id]/analytics/page.tsx +289 -0
  1947. package/src/modules/forms/backend/forms/[id]/distributions/page.meta.ts +15 -0
  1948. package/src/modules/forms/backend/forms/[id]/distributions/page.tsx +16 -0
  1949. package/src/modules/forms/backend/forms/[id]/history/page.meta.ts +11 -0
  1950. package/src/modules/forms/backend/forms/[id]/history/page.tsx +229 -0
  1951. package/src/modules/forms/backend/forms/[id]/page.meta.ts +11 -0
  1952. package/src/modules/forms/backend/forms/[id]/page.tsx +17 -0
  1953. package/src/modules/forms/backend/forms/[id]/studio/YesNoRow.tsx +65 -0
  1954. package/src/modules/forms/backend/forms/[id]/studio/autosave-guard.ts +25 -0
  1955. package/src/modules/forms/backend/forms/[id]/studio/canvas/DragOverlayCard.tsx +24 -0
  1956. package/src/modules/forms/backend/forms/[id]/studio/canvas/DropIndicator.tsx +36 -0
  1957. package/src/modules/forms/backend/forms/[id]/studio/canvas/FieldRow.tsx +308 -0
  1958. package/src/modules/forms/backend/forms/[id]/studio/canvas/FormCanvas.tsx +265 -0
  1959. package/src/modules/forms/backend/forms/[id]/studio/canvas/GridSlot.tsx +176 -0
  1960. package/src/modules/forms/backend/forms/[id]/studio/canvas/SectionContainer.tsx +473 -0
  1961. package/src/modules/forms/backend/forms/[id]/studio/canvas/grid-collision.ts +25 -0
  1962. package/src/modules/forms/backend/forms/[id]/studio/canvas/keyboard-coordinates.ts +128 -0
  1963. package/src/modules/forms/backend/forms/[id]/studio/canvas/overlay-size.ts +15 -0
  1964. package/src/modules/forms/backend/forms/[id]/studio/canvas/resize-math.ts +36 -0
  1965. package/src/modules/forms/backend/forms/[id]/studio/canvas/row-layout.ts +110 -0
  1966. package/src/modules/forms/backend/forms/[id]/studio/logic/ConditionBuilder.tsx +264 -0
  1967. package/src/modules/forms/backend/forms/[id]/studio/logic/HiddenFieldsPanel.tsx +121 -0
  1968. package/src/modules/forms/backend/forms/[id]/studio/logic/JumpsEditor.tsx +237 -0
  1969. package/src/modules/forms/backend/forms/[id]/studio/logic/RecallTokenPicker.tsx +87 -0
  1970. package/src/modules/forms/backend/forms/[id]/studio/logic/VariablesPanel.tsx +260 -0
  1971. package/src/modules/forms/backend/forms/[id]/studio/logic/condition-model.ts +207 -0
  1972. package/src/modules/forms/backend/forms/[id]/studio/lucide-icons.ts +87 -0
  1973. package/src/modules/forms/backend/forms/[id]/studio/palette/FormAppearancePanel.tsx +561 -0
  1974. package/src/modules/forms/backend/forms/[id]/studio/palette/FormPalettePanel.tsx +52 -0
  1975. package/src/modules/forms/backend/forms/[id]/studio/palette/InputParametersTab.tsx +378 -0
  1976. package/src/modules/forms/backend/forms/[id]/studio/palette/PaletteCard.tsx +40 -0
  1977. package/src/modules/forms/backend/forms/[id]/studio/palette/RolesEditor.tsx +225 -0
  1978. package/src/modules/forms/backend/forms/[id]/studio/palette/entries.ts +102 -0
  1979. package/src/modules/forms/backend/forms/[id]/studio/preview/PreviewSurface.tsx +1459 -0
  1980. package/src/modules/forms/backend/forms/[id]/studio/preview/ViewportFrame.tsx +49 -0
  1981. package/src/modules/forms/backend/forms/[id]/studio/recall.ts +0 -0
  1982. package/src/modules/forms/backend/forms/[id]/studio/schema-helpers.ts +2525 -0
  1983. package/src/modules/forms/backend/forms/[id]/studio/style/BackgroundControl.tsx +137 -0
  1984. package/src/modules/forms/backend/forms/[id]/studio/style/ColorControl.tsx +257 -0
  1985. package/src/modules/forms/backend/forms/[id]/studio/style/contrast.ts +114 -0
  1986. package/src/modules/forms/backend/forms/[id]/studio/style/presets.ts +104 -0
  1987. package/src/modules/forms/backend/forms/[id]/studio/type-label.ts +13 -0
  1988. package/src/modules/forms/backend/forms/[id]/studio/types.ts +31 -0
  1989. package/src/modules/forms/backend/forms/[id]/studio/undo-controller.ts +52 -0
  1990. package/src/modules/forms/backend/forms/[id]/studio/validation/FileConstraintsEditor.tsx +89 -0
  1991. package/src/modules/forms/backend/forms/[id]/studio/validation/GroupConfigEditor.tsx +167 -0
  1992. package/src/modules/forms/backend/forms/[id]/studio/validation/LengthRangeEditor.tsx +67 -0
  1993. package/src/modules/forms/backend/forms/[id]/studio/validation/MatrixColumnsEditor.tsx +166 -0
  1994. package/src/modules/forms/backend/forms/[id]/studio/validation/MatrixRowsEditor.tsx +184 -0
  1995. package/src/modules/forms/backend/forms/[id]/studio/validation/MessageOverridesEditor.tsx +83 -0
  1996. package/src/modules/forms/backend/forms/[id]/studio/validation/NpsAnchorsEditor.tsx +60 -0
  1997. package/src/modules/forms/backend/forms/[id]/studio/validation/NumberRangeEditor.tsx +65 -0
  1998. package/src/modules/forms/backend/forms/[id]/studio/validation/OpinionIconSelect.tsx +46 -0
  1999. package/src/modules/forms/backend/forms/[id]/studio/validation/PatternEditor.tsx +122 -0
  2000. package/src/modules/forms/backend/forms/[id]/studio/validation/RankingExhaustiveSwitch.tsx +28 -0
  2001. package/src/modules/forms/backend/forms/[id]/studio/validation/SignatureConfigEditor.tsx +84 -0
  2002. package/src/modules/forms/backend/forms/[id]/studio/validation/ValidationPanel.tsx +369 -0
  2003. package/src/modules/forms/backend/forms/[id]/submissions/components/RowBadges.ts +56 -0
  2004. package/src/modules/forms/backend/forms/[id]/submissions/components/SubmissionDrawer.tsx +605 -0
  2005. package/src/modules/forms/backend/forms/[id]/submissions/components/formSummary.ts +19 -0
  2006. package/src/modules/forms/backend/forms/[id]/submissions/page.meta.ts +10 -0
  2007. package/src/modules/forms/backend/forms/[id]/submissions/page.tsx +252 -0
  2008. package/src/modules/forms/backend/forms/create/page.meta.ts +11 -0
  2009. package/src/modules/forms/backend/forms/create/page.tsx +113 -0
  2010. package/src/modules/forms/backend/forms/page.meta.ts +31 -0
  2011. package/src/modules/forms/backend/forms/page.tsx +269 -0
  2012. package/src/modules/forms/commands/distribution.ts +506 -0
  2013. package/src/modules/forms/commands/form-version.ts +811 -0
  2014. package/src/modules/forms/commands/form.ts +477 -0
  2015. package/src/modules/forms/commands/index.ts +18 -0
  2016. package/src/modules/forms/commands/invitation.ts +428 -0
  2017. package/src/modules/forms/commands/shared.ts +261 -0
  2018. package/src/modules/forms/commands/submission.ts +216 -0
  2019. package/src/modules/forms/data/entities.ts +686 -0
  2020. package/src/modules/forms/data/validators.ts +483 -0
  2021. package/src/modules/forms/di.ts +246 -0
  2022. package/src/modules/forms/encryption.ts +31 -0
  2023. package/src/modules/forms/events-payloads.ts +103 -0
  2024. package/src/modules/forms/events.ts +50 -0
  2025. package/src/modules/forms/extension-points.ts +41 -0
  2026. package/src/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.meta.ts +9 -0
  2027. package/src/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.tsx +45 -0
  2028. package/src/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.meta.ts +9 -0
  2029. package/src/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.tsx +56 -0
  2030. package/src/modules/forms/frontend/embed/[slug]/page.meta.ts +42 -0
  2031. package/src/modules/forms/frontend/embed/[slug]/page.tsx +171 -0
  2032. package/src/modules/forms/frontend/f/[slug]/page.meta.ts +9 -0
  2033. package/src/modules/forms/frontend/f/[slug]/page.tsx +10 -0
  2034. package/src/modules/forms/frontend/forms/[id]/run/page.meta.ts +17 -0
  2035. package/src/modules/forms/frontend/forms/[id]/run/page.tsx +83 -0
  2036. package/src/modules/forms/frontend/i/[token]/page.meta.ts +9 -0
  2037. package/src/modules/forms/frontend/i/[token]/page.tsx +10 -0
  2038. package/src/modules/forms/i18n/de.json +821 -0
  2039. package/src/modules/forms/i18n/en.json +821 -0
  2040. package/src/modules/forms/i18n/es.json +821 -0
  2041. package/src/modules/forms/i18n/ko.json +821 -0
  2042. package/src/modules/forms/i18n/pl.json +821 -0
  2043. package/src/modules/forms/index.ts +18 -0
  2044. package/src/modules/forms/lib/embed-frame-policy.ts +144 -0
  2045. package/src/modules/forms/lib/form-definition-slicing.ts +54 -0
  2046. package/src/modules/forms/lib/log-redaction.ts +91 -0
  2047. package/src/modules/forms/lib/navigable-url.ts +57 -0
  2048. package/src/modules/forms/lib/retention.ts +73 -0
  2049. package/src/modules/forms/lib/runtime-principal.ts +101 -0
  2050. package/src/modules/forms/migrations/.snapshot-open-mercato.json +3185 -0
  2051. package/src/modules/forms/migrations/Migration20260508135459_forms.ts +17 -0
  2052. package/src/modules/forms/migrations/Migration20260508140932_forms.ts +26 -0
  2053. package/src/modules/forms/migrations/Migration20260508155737_forms.ts +15 -0
  2054. package/src/modules/forms/migrations/Migration20260520120000_forms.ts +26 -0
  2055. package/src/modules/forms/migrations/Migration20260521090000_forms.ts +15 -0
  2056. package/src/modules/forms/migrations/Migration20260521120000_forms.ts +21 -0
  2057. package/src/modules/forms/runner/FormRunner.tsx +924 -0
  2058. package/src/modules/forms/runner/MatrixField.tsx +210 -0
  2059. package/src/modules/forms/runner/RankingField.tsx +207 -0
  2060. package/src/modules/forms/runner/ScaleField.tsx +102 -0
  2061. package/src/modules/forms/runner/SignatureField.tsx +158 -0
  2062. package/src/modules/forms/runner/tamper-check.ts +131 -0
  2063. package/src/modules/forms/schema/address-countries.ts +60 -0
  2064. package/src/modules/forms/schema/field-type-patterns.ts +21 -0
  2065. package/src/modules/forms/schema/field-type-registry-advanced.ts +58 -0
  2066. package/src/modules/forms/schema/field-type-registry.ts +819 -0
  2067. package/src/modules/forms/schema/file-field.ts +102 -0
  2068. package/src/modules/forms/schema/group-field.ts +235 -0
  2069. package/src/modules/forms/schema/jsonlogic-grammar.ts +95 -0
  2070. package/src/modules/forms/schema/jsonschema-extensions.ts +1060 -0
  2071. package/src/modules/forms/schema/layout-catalog.ts +68 -0
  2072. package/src/modules/forms/schema/signature-field.ts +120 -0
  2073. package/src/modules/forms/schema/style-extensions.ts +194 -0
  2074. package/src/modules/forms/schema/style-validators.ts +252 -0
  2075. package/src/modules/forms/services/access-audit-logger.ts +275 -0
  2076. package/src/modules/forms/services/analytics-service.ts +498 -0
  2077. package/src/modules/forms/services/anonymize-service.ts +177 -0
  2078. package/src/modules/forms/services/attachment-service.ts +223 -0
  2079. package/src/modules/forms/services/captcha-verifier.ts +156 -0
  2080. package/src/modules/forms/services/consent-record-service.ts +162 -0
  2081. package/src/modules/forms/services/distribution-service.ts +509 -0
  2082. package/src/modules/forms/services/distribution-token.ts +153 -0
  2083. package/src/modules/forms/services/encryption-service.ts +500 -0
  2084. package/src/modules/forms/services/export-service.ts +360 -0
  2085. package/src/modules/forms/services/field-validation-service.ts +300 -0
  2086. package/src/modules/forms/services/form-logic-evaluator.ts +718 -0
  2087. package/src/modules/forms/services/form-version-compiler.ts +829 -0
  2088. package/src/modules/forms/services/form-version-differ.ts +143 -0
  2089. package/src/modules/forms/services/jsonlogic-evaluator.ts +228 -0
  2090. package/src/modules/forms/services/pdf-snapshot-service.ts +782 -0
  2091. package/src/modules/forms/services/prefill-resolver.ts +125 -0
  2092. package/src/modules/forms/services/role-policy-service.ts +90 -0
  2093. package/src/modules/forms/services/style-compiler.ts +378 -0
  2094. package/src/modules/forms/services/submission-service.ts +1259 -0
  2095. package/src/modules/forms/services/upload-scanner.ts +36 -0
  2096. package/src/modules/forms/services/upload-validation.ts +94 -0
  2097. package/src/modules/forms/services/visibility-resolver.ts +63 -0
  2098. package/src/modules/forms/setup.ts +16 -0
  2099. package/src/modules/forms/subscribers/forms-consent-projector.ts +100 -0
  2100. package/src/modules/forms/subscribers/forms-pdf-snapshot.ts +112 -0
  2101. package/src/modules/forms/subscribers/forms-webhook-bridge-anonymized.ts +36 -0
  2102. package/src/modules/forms/subscribers/forms-webhook-bridge.ts +56 -0
  2103. package/src/modules/forms/subscribers/invitation-email.ts +180 -0
  2104. package/src/modules/forms/translations.ts +14 -0
  2105. package/src/modules/forms/ui/admin/forms/[id]/distributions/CreateDistributionDialog.tsx +401 -0
  2106. package/src/modules/forms/ui/admin/forms/[id]/distributions/DistributionsPanel.tsx +381 -0
  2107. package/src/modules/forms/ui/admin/forms/[id]/distributions/EmbedSettingsDialog.tsx +332 -0
  2108. package/src/modules/forms/ui/admin/forms/[id]/distributions/RecipientsTable.tsx +460 -0
  2109. package/src/modules/forms/ui/public/EmbeddedForm.tsx +248 -0
  2110. package/src/modules/forms/ui/public/FormRunner.tsx +491 -0
  2111. package/src/modules/forms/ui/public/FormTrigger.tsx +80 -0
  2112. package/src/modules/forms/ui/public/PublicFormRunnerPage.tsx +34 -0
  2113. package/src/modules/forms/ui/public/components/CompletionScreen.tsx +97 -0
  2114. package/src/modules/forms/ui/public/components/LocaleSwitch.tsx +42 -0
  2115. package/src/modules/forms/ui/public/components/ResumeGate.tsx +61 -0
  2116. package/src/modules/forms/ui/public/components/ReviewStep.tsx +153 -0
  2117. package/src/modules/forms/ui/public/components/SaveIndicator.tsx +69 -0
  2118. package/src/modules/forms/ui/public/components/SectionStepper.tsx +60 -0
  2119. package/src/modules/forms/ui/public/index.ts +48 -0
  2120. package/src/modules/forms/ui/public/renderers/index.tsx +889 -0
  2121. package/src/modules/forms/ui/public/state/logic-derivation.ts +91 -0
  2122. package/src/modules/forms/ui/public/state/runtime-client.ts +495 -0
  2123. package/src/modules/forms/ui/public/state/useAutosave.ts +97 -0
  2124. package/src/modules/forms/ui/public/state/useFormRunner.ts +547 -0
  2125. package/src/modules/forms/ui/public/style/LogoHeader.tsx +43 -0
  2126. package/src/modules/forms/ui/public/style/applyStyle.ts +26 -0
  2127. package/src/modules/forms/ui/public/types.ts +228 -0
  2128. package/src/modules/forms/widgets/injection/access-audit-panel/widget.tsx +144 -0
  2129. package/src/modules/forms/widgets/injection/anonymize-button/widget.tsx +177 -0
  2130. package/src/modules/forms/widgets/injection/audit-format.ts +60 -0
  2131. package/src/modules/forms/widgets/injection/context.ts +24 -0
  2132. package/src/modules/forms/widgets/injection/embedded-form/widget.tsx +102 -0
  2133. package/src/modules/forms/widgets/injection/pdf-download-button/widget.tsx +111 -0
  2134. package/src/modules/forms/widgets/injection/self-audit-footer/widget.tsx +56 -0
  2135. package/src/modules/forms/widgets/injection-table.ts +54 -0
  2136. package/src/modules/forms/workers/pdf-snapshot.ts +110 -0
  2137. package/src/modules/forms/workers/retention-purge.ts +169 -0
  2138. package/src/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.ts +7 -1
  2139. package/src/modules/inbox_ops/data/validators.ts +2 -1
  2140. package/src/modules/inbox_ops/lib/llmProvider.ts +11 -0
  2141. package/src/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.tsx +2 -2
  2142. package/src/modules/integrations/di.ts +5 -1
  2143. package/src/modules/integrations/lib/credentials-service.ts +45 -36
  2144. package/src/modules/messages/api/[id]/attachments/route.ts +12 -3
  2145. package/src/modules/messages/api/[id]/forward-preview/route.ts +9 -3
  2146. package/src/modules/messages/api/[id]/route.ts +83 -4
  2147. package/src/modules/messages/api/route.ts +123 -2
  2148. package/src/modules/messages/commands/messages.ts +81 -7
  2149. package/src/modules/messages/components/ComposeMessagePageClient.tsx +29 -1
  2150. package/src/modules/messages/data/validators.ts +10 -0
  2151. package/src/modules/messages/i18n/de.json +8 -0
  2152. package/src/modules/messages/i18n/en.json +8 -0
  2153. package/src/modules/messages/i18n/es.json +8 -0
  2154. package/src/modules/messages/i18n/ko.json +8 -0
  2155. package/src/modules/messages/i18n/pl.json +8 -0
  2156. package/src/modules/messages/lib/channelThreadAccess.ts +101 -0
  2157. package/src/modules/messages/lib/composeSenderDelegation.ts +182 -0
  2158. package/src/modules/messages/lib/composeSenderOptions.ts +56 -0
  2159. package/src/modules/messages/lib/email-sender.ts +1 -17
  2160. package/src/modules/messages/lib/forwarding.ts +17 -2
  2161. package/src/modules/messages/lib/markdownEmailBody.ts +25 -0
  2162. package/src/modules/messages/lib/messageSourceEntityTypes.ts +12 -0
  2163. package/src/modules/messages/lib/routeHelpers.ts +92 -0
  2164. package/src/modules/messages/subscribers/message-notification.ts +47 -1
  2165. package/src/modules/notifications/AGENTS.md +1 -1
  2166. package/src/modules/notifications/api/[id]/action/route.ts +2 -1
  2167. package/src/modules/notifications/api/openapi.ts +1 -0
  2168. package/src/modules/notifications/frontend/NotificationSettingsPageClient.tsx +77 -48
  2169. package/src/modules/notifications/i18n/de.json +1 -0
  2170. package/src/modules/notifications/i18n/en.json +1 -0
  2171. package/src/modules/notifications/i18n/es.json +1 -0
  2172. package/src/modules/notifications/i18n/ko.json +1 -0
  2173. package/src/modules/notifications/i18n/pl.json +1 -0
  2174. package/src/modules/notifications/lib/deliveryConfig.ts +31 -2
  2175. package/src/modules/notifications/lib/notificationMapper.ts +2 -0
  2176. package/src/modules/notifications/lib/safeHref.ts +7 -0
  2177. package/src/modules/planner/api/availability-date-specific.ts +2 -1
  2178. package/src/modules/planner/api/availability-weekly.ts +2 -1
  2179. package/src/modules/progress/AGENTS.md +2 -0
  2180. package/src/modules/progress/api/active/route.ts +14 -2
  2181. package/src/modules/progress/api/jobs/[id]/route.ts +44 -27
  2182. package/src/modules/progress/api/jobs/route.ts +22 -8
  2183. package/src/modules/progress/api/requestScope.ts +43 -0
  2184. package/src/modules/progress/lib/organizationScope.ts +17 -0
  2185. package/src/modules/progress/lib/progressService.ts +3 -2
  2186. package/src/modules/progress/lib/progressServiceImpl.ts +63 -14
  2187. package/src/modules/push_notifications/api/custom-send/route.ts +4 -1
  2188. package/src/modules/push_notifications/i18n/de.json +1 -0
  2189. package/src/modules/push_notifications/i18n/en.json +1 -0
  2190. package/src/modules/push_notifications/i18n/es.json +1 -0
  2191. package/src/modules/push_notifications/i18n/ko.json +1 -0
  2192. package/src/modules/push_notifications/i18n/pl.json +1 -0
  2193. package/src/modules/query_index/api/status.ts +4 -9
  2194. package/src/modules/query_index/di.ts +2 -1
  2195. package/src/modules/query_index/lib/engine.ts +2 -0
  2196. package/src/modules/query_index/lib/request-encryption.ts +31 -0
  2197. package/src/modules/query_index/lib/search-tokens.ts +42 -1
  2198. package/src/modules/resources/api/resources/tags/assign/route.ts +2 -1
  2199. package/src/modules/resources/api/resources/tags/unassign/route.ts +2 -1
  2200. package/src/modules/resources/commands/activities.ts +2 -2
  2201. package/src/modules/sales/api/document-history/route.ts +5 -1
  2202. package/src/modules/sales/api/document-numbers/route.ts +2 -1
  2203. package/src/modules/sales/api/quotes/convert/route.ts +2 -1
  2204. package/src/modules/sales/api/quotes/send/route.ts +2 -1
  2205. package/src/modules/sales/api/settings/document-numbers/route.ts +7 -1
  2206. package/src/modules/sales/api/settings/order-editing/route.ts +7 -1
  2207. package/src/modules/sales/commands/documents.ts +451 -131
  2208. package/src/modules/sales/commands/payments.ts +2 -1
  2209. package/src/modules/sales/commands/settings.ts +34 -6
  2210. package/src/modules/sales/commands/shipments.ts +2 -1
  2211. package/src/modules/sales/components/DocumentNumberSettings.tsx +41 -28
  2212. package/src/modules/sales/components/documents/ItemsSection.tsx +58 -13
  2213. package/src/modules/sales/i18n/de.json +2 -0
  2214. package/src/modules/sales/i18n/en.json +2 -0
  2215. package/src/modules/sales/i18n/es.json +2 -0
  2216. package/src/modules/sales/i18n/ko.json +2 -0
  2217. package/src/modules/sales/i18n/pl.json +2 -0
  2218. package/src/modules/sales/lib/lineSnapshots.ts +36 -0
  2219. package/src/modules/sales/setup.ts +4 -4
  2220. package/src/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.tsx +2 -2
  2221. package/src/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.tsx +2 -2
  2222. package/src/modules/staff/api/leave-requests/accept/route.ts +2 -1
  2223. package/src/modules/staff/api/leave-requests/reject/route.ts +2 -1
  2224. package/src/modules/staff/api/leave-requests.ts +2 -1
  2225. package/src/modules/staff/api/team-members/self/route.ts +2 -1
  2226. package/src/modules/staff/api/team-members/tags/assign/route.ts +2 -1
  2227. package/src/modules/staff/api/team-members/tags/unassign/route.ts +2 -1
  2228. package/src/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.ts +16 -16
  2229. package/src/modules/staff/api/timesheets/my-projects/[projectId]/route.ts +2 -1
  2230. package/src/modules/staff/api/timesheets/my-projects/route.ts +2 -1
  2231. package/src/modules/staff/api/timesheets/my-work/route.ts +2 -1
  2232. package/src/modules/staff/api/timesheets/projects/kpis/route.ts +2 -1
  2233. package/src/modules/staff/api/timesheets/reports/[id]/close/route.ts +2 -1
  2234. package/src/modules/staff/api/timesheets/reports/[id]/export/route.ts +3 -2
  2235. package/src/modules/staff/api/timesheets/reports/[id]/sheet/route.ts +3 -2
  2236. package/src/modules/staff/api/timesheets/reports/[id]/unlock/route.ts +3 -2
  2237. package/src/modules/staff/api/timesheets/reports/preview/route.ts +2 -1
  2238. package/src/modules/staff/api/timesheets/reports/shared.ts +2 -1
  2239. package/src/modules/staff/api/timesheets/settings/reapply-rounding/route.ts +2 -1
  2240. package/src/modules/staff/api/timesheets/tags/entry-assignments/route.ts +2 -1
  2241. package/src/modules/staff/api/timesheets/tags/task-assignments/route.ts +2 -1
  2242. package/src/modules/staff/api/timesheets/tasks/[id]/comments/route.ts +2 -1
  2243. package/src/modules/staff/api/timesheets/tasks/[id]/status/route.ts +2 -1
  2244. package/src/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.ts +3 -2
  2245. package/src/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.ts +2 -1
  2246. package/src/modules/staff/api/timesheets/time-entries/[id]/segments/route.ts +2 -1
  2247. package/src/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.ts +2 -1
  2248. package/src/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.ts +2 -1
  2249. package/src/modules/staff/api/timesheets/time-entries/bulk/route.ts +2 -1
  2250. package/src/modules/staff/api/timesheets/time-entries/copy-day/route.ts +3 -2
  2251. package/src/modules/staff/api/timesheets/time-entries/overlaps/route.ts +2 -1
  2252. package/src/modules/staff/api/timesheets/time-entries/start-timer/route.ts +3 -2
  2253. package/src/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.ts +3 -2
  2254. package/src/modules/staff/api/timesheets/time-projects/route.ts +2 -1
  2255. package/src/modules/staff/commands/activities.ts +2 -2
  2256. package/src/modules/staff/commands/timesheets-entries.ts +3 -2
  2257. package/src/modules/staff/commands/timesheets-reports.ts +88 -15
  2258. package/src/modules/staff/lib/timesheets-reports/buildReportSheet.ts +1 -0
  2259. package/src/modules/staff/lib/timesheets-reports/loadReportData.ts +69 -8
  2260. package/src/modules/staff/lib/timesheets-reports/reportPeriod.ts +18 -0
  2261. package/src/modules/staff/lib/timesheets-ui/CalendarPicker.tsx +21 -10
  2262. package/src/modules/sync_excel/api/import/route.ts +40 -12
  2263. package/src/modules/sync_excel/api/upload/route.ts +34 -4
  2264. package/src/modules/translations/api/context.ts +2 -1
  2265. package/src/modules/warranty_claims/api/ai/assess/route.ts +2 -1
  2266. package/src/modules/warranty_claims/api/ai/draft-reply/route.ts +2 -1
  2267. package/src/modules/warranty_claims/api/ai/suggest/route.ts +2 -1
  2268. package/src/modules/warranty_claims/api/assign/route.ts +2 -1
  2269. package/src/modules/warranty_claims/api/credit-memo/route.ts +2 -1
  2270. package/src/modules/warranty_claims/api/entitlement/route.ts +2 -1
  2271. package/src/modules/warranty_claims/api/events/route.ts +2 -1
  2272. package/src/modules/warranty_claims/api/external/claims/route.ts +2 -1
  2273. package/src/modules/warranty_claims/api/receiving/route.ts +2 -1
  2274. package/src/modules/warranty_claims/api/replacement-order/route.ts +2 -1
  2275. package/src/modules/warranty_claims/api/return-label/route.ts +2 -1
  2276. package/src/modules/warranty_claims/api/risk/route.ts +2 -1
  2277. package/src/modules/warranty_claims/api/sales-return/route.ts +2 -1
  2278. package/src/modules/warranty_claims/api/settings-general/route.ts +2 -1
  2279. package/src/modules/warranty_claims/api/stats/route.ts +11 -11
  2280. package/src/modules/warranty_claims/api/submit/route.ts +2 -1
  2281. package/src/modules/warranty_claims/api/transition/route.ts +2 -1
  2282. package/src/modules/warranty_claims/api/vendor-recovery/route.ts +2 -1
  2283. package/src/modules/warranty_claims/api/vendor-recovery-suggestions/route.ts +2 -1
  2284. package/src/modules/warranty_claims/i18n/de.json +1 -0
  2285. package/src/modules/warranty_claims/i18n/en.json +1 -0
  2286. package/src/modules/warranty_claims/i18n/es.json +1 -0
  2287. package/src/modules/warranty_claims/i18n/ko.json +1 -0
  2288. package/src/modules/warranty_claims/i18n/pl.json +1 -0
  2289. package/src/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.tsx +1 -1
  2290. package/src/modules/wms/api/dashboard/operational/route.ts +2 -1
  2291. package/src/modules/wms/api/inventory/cycle-count/route.ts +1 -0
  2292. package/src/modules/wms/api/inventory/helpers.ts +2 -1
  2293. package/src/modules/wms/api/inventory/import/helpers.ts +2 -1
  2294. package/src/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.ts +2 -1
  2295. package/src/modules/wms/commands/inventory-actions.ts +45 -1
  2296. package/src/modules/wms/components/backend/CycleCountWizardDialog.tsx +14 -1
  2297. package/src/modules/wms/di.ts +6 -0
  2298. package/src/modules/wms/i18n/de.json +2 -0
  2299. package/src/modules/wms/i18n/en.json +2 -0
  2300. package/src/modules/wms/i18n/es.json +2 -0
  2301. package/src/modules/wms/i18n/ko.json +2 -0
  2302. package/src/modules/wms/i18n/pl.json +2 -0
  2303. package/src/modules/wms/lib/availabilityCache.ts +137 -0
  2304. package/src/modules/wms/lib/availabilityCalculation.ts +351 -0
  2305. package/src/modules/wms/lib/availabilityProvider.ts +47 -0
  2306. package/src/modules/wms/lib/loadOperationalDashboard.ts +51 -3
  2307. package/src/modules/wms/lib/lowStockBalanceFilter.ts +23 -10
  2308. package/src/modules/wms/lib/sqlInClause.ts +21 -0
  2309. package/src/modules/wms/lib/tryResolve.ts +8 -0
  2310. package/src/modules/wms/subscribers/invalidate-availability-cache-policy.ts +18 -0
  2311. package/src/modules/wms/subscribers/invalidate-availability-cache-profile.ts +18 -0
  2312. package/src/modules/wms/subscribers/invalidate-availability-cache.ts +30 -0
  2313. package/src/modules/wms/widgets/notifications/WmsLowStockRenderer.tsx +2 -2
  2314. package/src/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.tsx +4 -3
  2315. package/src/modules/workflows/AGENTS.md +7 -5
  2316. package/src/modules/workflows/api/commands/route.ts +4 -1
  2317. package/src/modules/workflows/api/definitions/[id]/callers/route.ts +4 -1
  2318. package/src/modules/workflows/api/definitions/[id]/context-schema/route.ts +4 -2
  2319. package/src/modules/workflows/api/definitions/[id]/customize/route.ts +4 -1
  2320. package/src/modules/workflows/api/definitions/[id]/draft/route.ts +6 -1
  2321. package/src/modules/workflows/api/definitions/[id]/publish/route.ts +10 -1
  2322. package/src/modules/workflows/api/definitions/[id]/reset-to-code/route.ts +4 -1
  2323. package/src/modules/workflows/api/definitions/[id]/route.ts +5 -3
  2324. package/src/modules/workflows/api/definitions/[id]/test-step/route.ts +4 -2
  2325. package/src/modules/workflows/api/definitions/generate/route.ts +4 -1
  2326. package/src/modules/workflows/api/definitions/route.ts +4 -2
  2327. package/src/modules/workflows/api/endpoints/route.ts +4 -1
  2328. package/src/modules/workflows/api/functions/route.ts +4 -1
  2329. package/src/modules/workflows/api/grantable-features/route.ts +2 -1
  2330. package/src/modules/workflows/api/instances/[id]/advance/route.ts +4 -1
  2331. package/src/modules/workflows/api/instances/[id]/cancel/route.ts +4 -1
  2332. package/src/modules/workflows/api/instances/[id]/context/route.ts +2 -1
  2333. package/src/modules/workflows/api/instances/[id]/rerun-step/route.ts +4 -1
  2334. package/src/modules/workflows/api/instances/[id]/retry/route.ts +4 -1
  2335. package/src/modules/workflows/api/instances/[id]/signal/route.ts +4 -1
  2336. package/src/modules/workflows/api/instances/[id]/step-through/route.ts +4 -2
  2337. package/src/modules/workflows/api/instances/route.ts +4 -2
  2338. package/src/modules/workflows/api/instances/validate-start/route.ts +4 -1
  2339. package/src/modules/workflows/api/rule-usage/route.ts +4 -1
  2340. package/src/modules/workflows/api/signals/route.ts +4 -1
  2341. package/src/modules/workflows/api/tasks/[id]/claim/route.ts +4 -1
  2342. package/src/modules/workflows/api/tasks/[id]/complete/route.ts +4 -1
  2343. package/src/modules/workflows/api/tasks/[id]/reassign/route.ts +2 -1
  2344. package/src/modules/workflows/api/tasks/[id]/unclaim/route.ts +4 -1
  2345. package/src/modules/workflows/api/templates/route.ts +4 -1
  2346. package/src/modules/workflows/api/work-inbox/next/route.ts +4 -1
  2347. package/src/modules/workflows/lib/activity-executor.ts +125 -28
  2348. package/src/modules/workflows/lib/activity-types.ts +8 -4
  2349. package/src/modules/workflows/lib/activity-worker-handler.ts +16 -12
  2350. package/src/modules/workflows/lib/event-trigger-service.ts +18 -2
  2351. package/src/modules/workflows/lib/step-handler.ts +13 -8
  2352. package/src/test-utils/transactionalEntityManagerDouble.ts +51 -0
@@ -0,0 +1,2811 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import Link from "next/link";
5
+ import { useRouter } from "next/navigation";
6
+ import {
7
+ DndContext,
8
+ DragOverlay,
9
+ KeyboardSensor,
10
+ PointerSensor,
11
+ useSensor,
12
+ useSensors
13
+ } from "@dnd-kit/core";
14
+ import { gridKeyboardCoordinates } from "./studio/canvas/keyboard-coordinates.js";
15
+ import { Button } from "@open-mercato/ui/primitives/button";
16
+ import { IconButton } from "@open-mercato/ui/primitives/icon-button";
17
+ import { Input } from "@open-mercato/ui/primitives/input";
18
+ import { Textarea } from "@open-mercato/ui/primitives/textarea";
19
+ import { Tag } from "@open-mercato/ui/primitives/tag";
20
+ import { Alert } from "@open-mercato/ui/primitives/alert";
21
+ import {
22
+ Dialog,
23
+ DialogContent,
24
+ DialogFooter,
25
+ DialogHeader,
26
+ DialogTitle
27
+ } from "@open-mercato/ui/primitives/dialog";
28
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@open-mercato/ui/primitives/select";
29
+ import { Checkbox } from "@open-mercato/ui/primitives/checkbox";
30
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@open-mercato/ui/primitives/tabs";
31
+ import { LoadingMessage, ErrorMessage, RecordNotFoundState } from "@open-mercato/ui/backend/detail";
32
+ import { apiCall, withScopedApiRequestHeaders } from "@open-mercato/ui/backend/utils/apiCall";
33
+ import { buildOptimisticLockHeader } from "@open-mercato/ui/backend/utils/optimisticLock";
34
+ import { surfaceRecordConflict } from "@open-mercato/ui/backend/conflicts";
35
+ import { flash } from "@open-mercato/ui/backend/FlashMessages";
36
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
37
+ import { createLogger } from "@open-mercato/shared/lib/logger";
38
+ import { useConfirmDialog } from "@open-mercato/ui/backend/confirm-dialog";
39
+ import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
40
+ import { Label } from "@open-mercato/ui/primitives/label";
41
+ import { FormPalettePanel } from "./studio/palette/FormPalettePanel.js";
42
+ import { FormAppearancePanel } from "./studio/palette/FormAppearancePanel.js";
43
+ import { PALETTE_DRAGGABLE_PREFIX } from "./studio/palette/PaletteCard.js";
44
+ import { buildPaletteEntries, resolvePaletteId } from "./studio/palette/entries.js";
45
+ import { ArrowDown, ArrowUp, Globe, Plus, resolveLucideIcon, Trash2, Undo2, Redo2 } from "./studio/lucide-icons.js";
46
+ import { resolveTypeLabel } from "./studio/type-label.js";
47
+ import { DragOverlayCard } from "./studio/canvas/DragOverlayCard.js";
48
+ import { FormCanvas } from "./studio/canvas/FormCanvas.js";
49
+ import { FIELD_DRAGGABLE_PREFIX } from "./studio/canvas/FieldRow.js";
50
+ import { SECTION_DROP_PREFIX, parseSectionDropId } from "./studio/canvas/GridSlot.js";
51
+ import { gridAwareCollision } from "./studio/canvas/grid-collision.js";
52
+ import { computeOverlayWidthPx } from "./studio/canvas/overlay-size.js";
53
+ import { computeRowLayout, dropHintToLinearIndex, readSpan } from "./studio/canvas/row-layout.js";
54
+ import { SECTION_DRAGGABLE_PREFIX } from "./studio/canvas/SectionContainer.js";
55
+ import {
56
+ addFieldFromPalette,
57
+ addLayoutFromPalette,
58
+ addRoleToSchema,
59
+ adoptUngroupedAsSection,
60
+ deleteField,
61
+ disableGuestSubmissions,
62
+ enableGuestSubmissions,
63
+ isGuestSubmissionEnabled,
64
+ removeRoleFromSchema,
65
+ renameRoleInSchema,
66
+ deleteSection,
67
+ findSectionOwning,
68
+ indexOfFieldInSection,
69
+ isCompatibleFieldSwap,
70
+ moveField,
71
+ moveSection,
72
+ setFieldAlign,
73
+ setFieldGridSpan,
74
+ setFieldHideMobile,
75
+ setFieldStyle,
76
+ setFieldVisibilityIf,
77
+ setHiddenFields,
78
+ setJumps,
79
+ setRedirectUrl,
80
+ setSectionVisibilityIf,
81
+ setVariables,
82
+ setFormLabelPosition,
83
+ setFormStyle,
84
+ setFormTheme,
85
+ setPageMode,
86
+ setSectionColumns,
87
+ setSectionDivider,
88
+ setSectionGap,
89
+ setSectionHideTitle,
90
+ setSectionKind,
91
+ setSectionStyle,
92
+ setSectionTitle,
93
+ setShowProgress,
94
+ swapFieldType,
95
+ SWAP_FAMILIES,
96
+ validateSchemaExtensions,
97
+ groupNodeAddSubField,
98
+ groupNodeRemoveSubField,
99
+ groupNodeUpdateSubField
100
+ } from "./studio/schema-helpers.js";
101
+ import { defaultFieldTypeRegistry } from "../../../schema/field-type-registry.js";
102
+ import { createAutosaveGuard } from "./studio/autosave-guard.js";
103
+ import { ValidationPanel } from "./studio/validation/ValidationPanel.js";
104
+ import {
105
+ partitionPages,
106
+ resolveFormLabelPosition,
107
+ resolveFormStyle,
108
+ resolveFormTheme,
109
+ resolvePageMode,
110
+ resolveSectionViews,
111
+ resolveShowProgress
112
+ } from "../../../services/form-version-compiler.js";
113
+ import { ColorControl } from "./studio/style/ColorControl.js";
114
+ import { BackgroundControl } from "./studio/style/BackgroundControl.js";
115
+ import { YesNoRow } from "./studio/YesNoRow.js";
116
+ import { createUndoController } from "./studio/undo-controller.js";
117
+ import { PreviewSurface } from "./studio/preview/PreviewSurface.js";
118
+ import { ConditionBuilder, buildFieldSourceOptions } from "./studio/logic/ConditionBuilder.js";
119
+ import { JumpsEditor } from "./studio/logic/JumpsEditor.js";
120
+ import { ViewportFrame } from "./studio/preview/ViewportFrame.js";
121
+ const logger = createLogger("forms").child({ component: "FormStudio" });
122
+ const DEFAULT_SECTION_KEY = "default_section";
123
+ const ROLE_IDENTIFIER_PATTERN = /^[a-z][a-z0-9_-]*$/;
124
+ function isValidRoleIdentifier(value) {
125
+ return value.length >= 2 && value.length <= 64 && ROLE_IDENTIFIER_PATTERN.test(value);
126
+ }
127
+ const DEFAULT_SCHEMA = {
128
+ type: "object",
129
+ "x-om-roles": ["admin"],
130
+ "x-om-default-actor-role": "admin",
131
+ "x-om-sections": [
132
+ { key: DEFAULT_SECTION_KEY, kind: "section", title: { en: "" }, fieldKeys: [] }
133
+ ],
134
+ properties: {},
135
+ required: []
136
+ };
137
+ function ensureDefaultSection(schema) {
138
+ const sections = schema["x-om-sections"] ?? [];
139
+ if (sections.length > 0) return schema;
140
+ const next = {
141
+ ...schema,
142
+ "x-om-sections": [
143
+ { key: DEFAULT_SECTION_KEY, kind: "section", title: { en: "" }, fieldKeys: [] }
144
+ ]
145
+ };
146
+ return next;
147
+ }
148
+ function describeFieldForAnnouncement(schema, fieldKey) {
149
+ const node = schema.properties[fieldKey];
150
+ if (!node) return fieldKey;
151
+ return node["x-om-label"]?.en ?? fieldKey;
152
+ }
153
+ function describeSectionForAnnouncement(schema, sectionKey) {
154
+ const section = (schema["x-om-sections"] ?? []).find((entry) => entry.key === sectionKey);
155
+ if (!section) return sectionKey;
156
+ return section.title?.en?.length ? section.title.en : sectionKey;
157
+ }
158
+ function buildAnnouncements(t, schemaRef) {
159
+ const labelOf = (rawId) => {
160
+ if (rawId.startsWith(FIELD_DRAGGABLE_PREFIX)) {
161
+ const fieldKey = rawId.slice(FIELD_DRAGGABLE_PREFIX.length);
162
+ return describeFieldForAnnouncement(schemaRef.current, fieldKey);
163
+ }
164
+ if (rawId.startsWith(PALETTE_DRAGGABLE_PREFIX)) {
165
+ return rawId.slice(PALETTE_DRAGGABLE_PREFIX.length);
166
+ }
167
+ return rawId;
168
+ };
169
+ const describeGridTarget = (rawId) => {
170
+ if (!rawId.startsWith(SECTION_DROP_PREFIX)) return null;
171
+ const parsed = parseSectionDropId(rawId);
172
+ if (!parsed || parsed.kind === "legacy") return null;
173
+ const sectionName = describeSectionForAnnouncement(schemaRef.current, parsed.sectionKey);
174
+ if (parsed.kind === "cell") {
175
+ return t("forms.studio.dnd.announce.movedToCell", {
176
+ item: "",
177
+ section: sectionName,
178
+ row: String(parsed.rowIndex + 1),
179
+ column: String(parsed.columnIndex + 1)
180
+ });
181
+ }
182
+ if (parsed.kind === "col-gap") {
183
+ return t("forms.studio.dnd.announce.movedToCell", {
184
+ item: "",
185
+ section: sectionName,
186
+ row: String(parsed.rowIndex + 1),
187
+ column: String(parsed.columnIndex + 1)
188
+ });
189
+ }
190
+ return t("forms.studio.dnd.announce.movedToRowGap", {
191
+ item: "",
192
+ section: sectionName,
193
+ previous: String(parsed.rowIndex),
194
+ next: String(parsed.rowIndex + 1)
195
+ });
196
+ };
197
+ const targetOf = (rawId) => {
198
+ if (!rawId) return "";
199
+ if (rawId.startsWith(SECTION_DROP_PREFIX)) {
200
+ const grid = describeGridTarget(rawId);
201
+ if (grid) return grid;
202
+ const sectionKey = rawId.slice(SECTION_DROP_PREFIX.length);
203
+ return describeSectionForAnnouncement(schemaRef.current, sectionKey);
204
+ }
205
+ if (rawId.startsWith(FIELD_DRAGGABLE_PREFIX)) {
206
+ const fieldKey = rawId.slice(FIELD_DRAGGABLE_PREFIX.length);
207
+ return describeFieldForAnnouncement(schemaRef.current, fieldKey);
208
+ }
209
+ return String(rawId);
210
+ };
211
+ return {
212
+ onDragStart({ active }) {
213
+ return t("forms.studio.dnd.announce.pickedUp", { item: labelOf(String(active.id)) });
214
+ },
215
+ onDragOver({ active, over }) {
216
+ return t("forms.studio.dnd.announce.movedOver", {
217
+ item: labelOf(String(active.id)),
218
+ target: targetOf(over ? String(over.id) : null)
219
+ });
220
+ },
221
+ onDragEnd({ active, over }) {
222
+ return t("forms.studio.dnd.announce.droppedAt", {
223
+ item: labelOf(String(active.id)),
224
+ target: targetOf(over ? String(over.id) : null)
225
+ });
226
+ },
227
+ onDragCancel({ active }) {
228
+ return t("forms.studio.dnd.announce.cancelled", { item: labelOf(String(active.id)) });
229
+ }
230
+ };
231
+ }
232
+ function stableJsonStringify(value) {
233
+ return JSON.stringify(value, null, 2);
234
+ }
235
+ function deepClone(value) {
236
+ return JSON.parse(JSON.stringify(value));
237
+ }
238
+ function autosaveDebounce(fn, ms) {
239
+ let timer = null;
240
+ return (...args) => {
241
+ if (timer) clearTimeout(timer);
242
+ timer = setTimeout(() => fn(...args), ms);
243
+ };
244
+ }
245
+ function FormStudio({ formId }) {
246
+ const t = useT();
247
+ const { runMutation } = useGuardedMutation({ contextId: "forms.form.studio" });
248
+ const router = useRouter();
249
+ const [form, setForm] = React.useState(null);
250
+ const [draftVersionId, setDraftVersionId] = React.useState(null);
251
+ const [version, setVersion] = React.useState(null);
252
+ const [schema, setSchema] = React.useState(DEFAULT_SCHEMA);
253
+ const [selection, setSelection] = React.useState(null);
254
+ const [previewRole, setPreviewRole] = React.useState("admin");
255
+ const [autosaveState, setAutosaveState] = React.useState("idle");
256
+ const [isLoading, setIsLoading] = React.useState(true);
257
+ const [loadError, setLoadError] = React.useState(null);
258
+ const [showPublishDialog, setShowPublishDialog] = React.useState(false);
259
+ const [topTab, setTopTab] = React.useState("builder");
260
+ const [activeDragId, setActiveDragId] = React.useState(null);
261
+ const [activeDropTarget, setActiveDropTarget] = React.useState(null);
262
+ const [fieldResizeState, setFieldResizeState] = React.useState(null);
263
+ const [resizeAnnouncement, setResizeAnnouncement] = React.useState("");
264
+ const [focusSectionTitleKey, setFocusSectionTitleKey] = React.useState(null);
265
+ const [activeLocale, setActiveLocale] = React.useState("en");
266
+ const [previewViewport, setPreviewViewport] = React.useState("desktop");
267
+ const [previewStyleTarget, setPreviewStyleTarget] = React.useState("form");
268
+ const dirtyFlagRef = React.useRef(false);
269
+ const schemaRef = React.useRef(DEFAULT_SCHEMA);
270
+ const selectionRef = React.useRef(null);
271
+ const formUpdatedAtRef = React.useRef(null);
272
+ const versionUpdatedAtRef = React.useRef(null);
273
+ const gridRefs = React.useRef(/* @__PURE__ */ new Map());
274
+ const { confirm, ConfirmDialogElement } = useConfirmDialog();
275
+ const selectedFieldKey = selection?.kind === "field" ? selection.key : null;
276
+ const undoController = React.useMemo(() => createUndoController({ capacity: 50 }), []);
277
+ const [undoNonce, setUndoNonce] = React.useState(0);
278
+ React.useEffect(() => {
279
+ schemaRef.current = schema;
280
+ }, [schema]);
281
+ React.useEffect(() => {
282
+ selectionRef.current = selection;
283
+ }, [selection]);
284
+ React.useEffect(() => {
285
+ formUpdatedAtRef.current = form?.updatedAt ?? null;
286
+ }, [form?.updatedAt]);
287
+ React.useEffect(() => {
288
+ versionUpdatedAtRef.current = version?.updatedAt ?? null;
289
+ }, [version?.updatedAt]);
290
+ const reload = React.useCallback(async () => {
291
+ setIsLoading(true);
292
+ setLoadError(null);
293
+ const formCall = await apiCall(`/api/forms/${encodeURIComponent(formId)}`);
294
+ if (!formCall.ok || !formCall.result) {
295
+ setLoadError(formCall.status === 404 ? "forms.errors.form_not_found" : "forms.errors.internal");
296
+ setIsLoading(false);
297
+ return;
298
+ }
299
+ const detail = formCall.result;
300
+ setForm(detail);
301
+ setActiveLocale(
302
+ (current) => detail.supportedLocales.includes(current) ? current : detail.defaultLocale
303
+ );
304
+ let draft = detail.versions.find((entry) => entry.status === "draft") ?? null;
305
+ if (!draft) {
306
+ const forkCall = await runMutation({
307
+ operation: () => apiCall(
308
+ `/api/forms/${encodeURIComponent(formId)}/versions/fork`,
309
+ { method: "POST", body: JSON.stringify({}) }
310
+ ),
311
+ context: { formId },
312
+ mutationPayload: { formId }
313
+ });
314
+ if (forkCall.ok && forkCall.result?.versionId) {
315
+ const refresh = await apiCall(`/api/forms/${encodeURIComponent(formId)}`);
316
+ if (refresh.ok && refresh.result) {
317
+ setForm(refresh.result);
318
+ draft = refresh.result.versions.find((entry) => entry.id === forkCall.result?.versionId) ?? null;
319
+ }
320
+ }
321
+ }
322
+ if (draft) {
323
+ setDraftVersionId(draft.id);
324
+ const versionCall = await apiCall(
325
+ `/api/forms/${encodeURIComponent(formId)}/versions/${encodeURIComponent(draft.id)}`
326
+ );
327
+ if (versionCall.ok && versionCall.result) {
328
+ setVersion(versionCall.result);
329
+ const loaded = versionCall.result.schema;
330
+ setSchema(ensureDefaultSection(loaded && loaded.properties ? loaded : DEFAULT_SCHEMA));
331
+ dirtyFlagRef.current = false;
332
+ undoController.clear();
333
+ }
334
+ } else {
335
+ setVersion(null);
336
+ setSchema(DEFAULT_SCHEMA);
337
+ dirtyFlagRef.current = false;
338
+ undoController.clear();
339
+ }
340
+ setIsLoading(false);
341
+ }, [formId, runMutation, undoController]);
342
+ React.useEffect(() => {
343
+ void reload();
344
+ }, [reload]);
345
+ const persistDraftRaw = React.useCallback(async (next) => {
346
+ if (!draftVersionId) return;
347
+ setAutosaveState("saving");
348
+ const call = await runMutation({
349
+ operation: () => withScopedApiRequestHeaders(
350
+ buildOptimisticLockHeader(versionUpdatedAtRef.current),
351
+ () => apiCall(
352
+ `/api/forms/${encodeURIComponent(formId)}/versions/${encodeURIComponent(draftVersionId)}`,
353
+ {
354
+ method: "PATCH",
355
+ body: JSON.stringify({ schema: next })
356
+ }
357
+ )
358
+ ),
359
+ context: { formId, versionId: draftVersionId },
360
+ mutationPayload: { formId, versionId: draftVersionId }
361
+ });
362
+ if (!call.ok) {
363
+ setAutosaveState("error");
364
+ if (surfaceRecordConflict({ status: call.status, body: call.result }, t)) return;
365
+ const errPayload = call.result;
366
+ flash(t(errPayload?.error ?? "forms.studio.autosave.error"), "error");
367
+ return;
368
+ }
369
+ const updatedAt = call.result?.updatedAt;
370
+ if (updatedAt) {
371
+ versionUpdatedAtRef.current = updatedAt;
372
+ setVersion((current) => current ? { ...current, updatedAt } : current);
373
+ }
374
+ setAutosaveState("idle");
375
+ dirtyFlagRef.current = false;
376
+ const refreshed = await apiCall(
377
+ `/api/forms/${encodeURIComponent(formId)}/versions/${encodeURIComponent(draftVersionId)}`
378
+ );
379
+ if (refreshed.ok && refreshed.result) setVersion(refreshed.result);
380
+ }, [draftVersionId, formId, runMutation, t]);
381
+ const autosaveGuard = React.useMemo(
382
+ () => createAutosaveGuard({
383
+ patch: persistDraftRaw,
384
+ onInvalid: () => {
385
+ setAutosaveState("error");
386
+ flash(t("forms.studio.autosave.invalidSchema"), "error");
387
+ }
388
+ }),
389
+ [persistDraftRaw, t]
390
+ );
391
+ const persistDraft = React.useMemo(
392
+ () => autosaveDebounce((next) => {
393
+ void autosaveGuard.run(next);
394
+ }, 2e3),
395
+ [autosaveGuard]
396
+ );
397
+ const updateSchema = React.useCallback((updater) => {
398
+ setSchema((current) => {
399
+ const next = updater(current);
400
+ dirtyFlagRef.current = true;
401
+ persistDraft(next);
402
+ return next;
403
+ });
404
+ }, [persistDraft]);
405
+ const updateSchemaStructural = React.useCallback(
406
+ (updater) => {
407
+ undoController.push({
408
+ schema: schemaRef.current,
409
+ selection: selectionRef.current
410
+ });
411
+ setSchema((current) => {
412
+ const next = updater(current);
413
+ dirtyFlagRef.current = true;
414
+ persistDraft(next);
415
+ return next;
416
+ });
417
+ },
418
+ [persistDraft, undoController]
419
+ );
420
+ const selectField = React.useCallback((fieldKey) => {
421
+ setSelection({ kind: "field", key: fieldKey });
422
+ }, []);
423
+ const selectSection = React.useCallback((sectionKey) => {
424
+ setSelection({ kind: "section", key: sectionKey });
425
+ }, []);
426
+ const clearSelection = React.useCallback(() => {
427
+ setSelection(null);
428
+ }, []);
429
+ const handleDeleteField = React.useCallback((fieldKey) => {
430
+ updateSchemaStructural((current) => {
431
+ return deleteField({ schema: current, fieldKey });
432
+ });
433
+ clearSelection();
434
+ flash(t("forms.studio.fields.deletedFlash"), "info");
435
+ }, [updateSchemaStructural, clearSelection, t]);
436
+ const handleDeleteSection = React.useCallback(async (sectionKey) => {
437
+ const sections = schemaRef.current["x-om-sections"] ?? [];
438
+ const target = sections.find((entry) => entry.key === sectionKey);
439
+ if (!target) return;
440
+ const fieldCount = target.fieldKeys.length;
441
+ if (fieldCount > 0) {
442
+ const ok = await confirm({
443
+ title: t("forms.studio.canvas.section.delete.confirm.title"),
444
+ text: t("forms.studio.canvas.section.delete.confirm.body", {
445
+ name: target.title?.en?.length ? target.title.en : t("forms.studio.canvas.section.title.placeholder"),
446
+ count: String(fieldCount)
447
+ }),
448
+ confirmText: t("forms.studio.canvas.section.delete.confirm.submit"),
449
+ variant: "destructive"
450
+ });
451
+ if (!ok) return;
452
+ }
453
+ updateSchemaStructural((current) => deleteSection({ schema: current, sectionKey }));
454
+ clearSelection();
455
+ }, [confirm, t, updateSchemaStructural, clearSelection]);
456
+ const handleSectionTitleCommit = React.useCallback((sectionKey, title) => {
457
+ updateSchema(
458
+ (current) => setSectionTitle({ schema: current, sectionKey, locale: activeLocale, title })
459
+ );
460
+ }, [updateSchema, activeLocale]);
461
+ const handleSectionColumnsChange = React.useCallback(
462
+ (sectionKey, columns) => {
463
+ updateSchemaStructural((current) => setSectionColumns({ schema: current, sectionKey, columns }));
464
+ },
465
+ [updateSchemaStructural]
466
+ );
467
+ const handleSectionGapChange = React.useCallback(
468
+ (sectionKey, gap) => {
469
+ updateSchemaStructural((current) => setSectionGap({ schema: current, sectionKey, gap }));
470
+ },
471
+ [updateSchemaStructural]
472
+ );
473
+ const handleSectionDividerChange = React.useCallback(
474
+ (sectionKey, divider) => {
475
+ updateSchemaStructural((current) => setSectionDivider({ schema: current, sectionKey, divider }));
476
+ },
477
+ [updateSchemaStructural]
478
+ );
479
+ const handleSectionKindChange = React.useCallback(
480
+ (sectionKey, kind) => {
481
+ updateSchemaStructural((current) => setSectionKind({ schema: current, sectionKey, kind }));
482
+ },
483
+ [updateSchemaStructural]
484
+ );
485
+ const handleSectionHideTitleChange = React.useCallback(
486
+ (sectionKey, hideTitle) => {
487
+ updateSchemaStructural((current) => setSectionHideTitle({ schema: current, sectionKey, hideTitle }));
488
+ },
489
+ [updateSchemaStructural]
490
+ );
491
+ const handleSectionStyleChange = React.useCallback(
492
+ (sectionKey, style) => {
493
+ updateSchema((current) => setSectionStyle(current, sectionKey, style));
494
+ },
495
+ [updateSchema]
496
+ );
497
+ const handleAdoptUngrouped = React.useCallback(() => {
498
+ let newSectionKey = null;
499
+ updateSchemaStructural((current) => {
500
+ const result = adoptUngroupedAsSection({ schema: current });
501
+ newSectionKey = result.sectionKey;
502
+ return result.schema;
503
+ });
504
+ if (newSectionKey) {
505
+ const created = newSectionKey;
506
+ setSelection({ kind: "section", key: created });
507
+ setFocusSectionTitleKey(created);
508
+ flash(
509
+ t("forms.studio.canvas.ungrouped.adopt.toast", {
510
+ name: t("forms.studio.canvas.section.title.placeholder")
511
+ }),
512
+ "success"
513
+ );
514
+ }
515
+ }, [updateSchemaStructural, t]);
516
+ const handleFieldGridSpan = React.useCallback(
517
+ (fieldKey, span) => {
518
+ updateSchemaStructural((current) => setFieldGridSpan({ schema: current, fieldKey, span }));
519
+ },
520
+ [updateSchemaStructural]
521
+ );
522
+ const handleFieldResizeStart = React.useCallback(
523
+ (input) => {
524
+ setFieldResizeState({
525
+ fieldKey: input.fieldKey,
526
+ sectionKey: input.sectionKey,
527
+ startSpan: input.startSpan,
528
+ previewSpan: input.startSpan
529
+ });
530
+ setResizeAnnouncement(
531
+ t("forms.studio.canvas.field.resizeStart", {
532
+ item: describeFieldForAnnouncement(schemaRef.current, input.fieldKey)
533
+ })
534
+ );
535
+ },
536
+ [t]
537
+ );
538
+ const handleFieldResizePreview = React.useCallback(
539
+ (input) => {
540
+ setFieldResizeState((current) => {
541
+ if (!current || current.fieldKey !== input.fieldKey) return current;
542
+ if (current.previewSpan === input.previewSpan) return current;
543
+ return { ...current, previewSpan: input.previewSpan };
544
+ });
545
+ },
546
+ []
547
+ );
548
+ const handleFieldResizeCommit = React.useCallback(
549
+ (input) => {
550
+ setFieldResizeState((current) => {
551
+ if (current && current.fieldKey === input.fieldKey) {
552
+ if (input.finalSpan !== current.startSpan) {
553
+ handleFieldGridSpan(input.fieldKey, input.finalSpan);
554
+ }
555
+ }
556
+ return null;
557
+ });
558
+ setResizeAnnouncement(
559
+ t("forms.studio.canvas.field.resizeCommit", {
560
+ item: describeFieldForAnnouncement(schemaRef.current, input.fieldKey),
561
+ span: String(input.finalSpan)
562
+ })
563
+ );
564
+ },
565
+ [handleFieldGridSpan, t]
566
+ );
567
+ const handleFieldAlign = React.useCallback(
568
+ (fieldKey, align) => {
569
+ updateSchema((current) => setFieldAlign({ schema: current, fieldKey, align }));
570
+ },
571
+ [updateSchema]
572
+ );
573
+ const handleFieldHideMobile = React.useCallback(
574
+ (fieldKey, value) => {
575
+ updateSchema((current) => setFieldHideMobile({ schema: current, fieldKey, value }));
576
+ },
577
+ [updateSchema]
578
+ );
579
+ const handleFieldStyleChange = React.useCallback(
580
+ (fieldKey, style) => {
581
+ updateSchema((current) => setFieldStyle(current, fieldKey, style));
582
+ },
583
+ [updateSchema]
584
+ );
585
+ const handleFieldVisibilityChange = React.useCallback(
586
+ (fieldKey, predicate) => {
587
+ updateSchema((current) => setFieldVisibilityIf({ schema: current, fieldKey, predicate }));
588
+ },
589
+ [updateSchema]
590
+ );
591
+ const handleSectionVisibilityChange = React.useCallback(
592
+ (sectionKey, predicate) => {
593
+ updateSchema((current) => setSectionVisibilityIf({ schema: current, sectionKey, predicate }));
594
+ },
595
+ [updateSchema]
596
+ );
597
+ const handleHiddenFieldsChange = React.useCallback(
598
+ (entries) => {
599
+ updateSchema((current) => setHiddenFields({ schema: current, entries }));
600
+ },
601
+ [updateSchema]
602
+ );
603
+ const handleVariablesChange = React.useCallback(
604
+ (entries) => {
605
+ updateSchema((current) => setVariables({ schema: current, entries }));
606
+ },
607
+ [updateSchema]
608
+ );
609
+ const handleRedirectUrlChange = React.useCallback(
610
+ (sectionKey, url) => {
611
+ updateSchema((current) => setRedirectUrl({ schema: current, sectionKey, url }));
612
+ },
613
+ [updateSchema]
614
+ );
615
+ const handleJumpsChange = React.useCallback(
616
+ (rules) => {
617
+ updateSchema((current) => setJumps({ schema: current, rules }));
618
+ },
619
+ [updateSchema]
620
+ );
621
+ const handleFieldTypeSwap = React.useCallback(
622
+ (fieldKey, targetType) => {
623
+ try {
624
+ updateSchemaStructural(
625
+ (current) => swapFieldType({ schema: current, fieldKey, targetType })
626
+ );
627
+ } catch (error) {
628
+ flash(t("forms.studio.autosave.invalidSchema"), "error");
629
+ logger.warn("field-type swap failed", { err: error });
630
+ }
631
+ },
632
+ [t, updateSchemaStructural]
633
+ );
634
+ const handleDensityChange = React.useCallback(
635
+ (next) => {
636
+ updateSchema((current) => setFormStyle({ schema: current, style: next }));
637
+ },
638
+ [updateSchema]
639
+ );
640
+ const handleLabelPositionChange = React.useCallback(
641
+ (next) => {
642
+ updateSchema((current) => setFormLabelPosition({ schema: current, position: next }));
643
+ },
644
+ [updateSchema]
645
+ );
646
+ const handlePageModeChange = React.useCallback(
647
+ (next) => {
648
+ updateSchema((current) => setPageMode({ schema: current, mode: next }));
649
+ },
650
+ [updateSchema]
651
+ );
652
+ const handleShowProgressChange = React.useCallback(
653
+ (next) => {
654
+ updateSchema((current) => setShowProgress({ schema: current, value: next }));
655
+ },
656
+ [updateSchema]
657
+ );
658
+ const handleThemeChange = React.useCallback(
659
+ (next) => {
660
+ updateSchema((current) => setFormTheme(current, next));
661
+ },
662
+ [updateSchema]
663
+ );
664
+ const handleUndo = React.useCallback(() => {
665
+ const previous = undoController.undo({
666
+ schema: schemaRef.current,
667
+ selection: selectionRef.current
668
+ });
669
+ if (!previous) return;
670
+ setSchema(previous.schema);
671
+ setSelection(previous.selection ?? null);
672
+ dirtyFlagRef.current = true;
673
+ persistDraft(previous.schema);
674
+ setUndoNonce((current) => current + 1);
675
+ flash(t("forms.studio.undo.toast.undone"), "success");
676
+ }, [persistDraft, t, undoController]);
677
+ const handleRedo = React.useCallback(() => {
678
+ const next = undoController.redo({
679
+ schema: schemaRef.current,
680
+ selection: selectionRef.current
681
+ });
682
+ if (!next) return;
683
+ setSchema(next.schema);
684
+ setSelection(next.selection ?? null);
685
+ dirtyFlagRef.current = true;
686
+ persistDraft(next.schema);
687
+ setUndoNonce((current) => current + 1);
688
+ flash(t("forms.studio.undo.toast.redone"), "success");
689
+ }, [persistDraft, t, undoController]);
690
+ React.useEffect(() => {
691
+ function handleKeyDown(event) {
692
+ if (!(event.metaKey || event.ctrlKey)) return;
693
+ const target = event.target;
694
+ if (target) {
695
+ const tagName = target.tagName?.toLowerCase();
696
+ if (tagName === "input" || tagName === "textarea" || target.isContentEditable) return;
697
+ }
698
+ const isRedoCombo = event.key === "z" && event.shiftKey || event.key === "y";
699
+ const isUndoCombo = event.key === "z" && !event.shiftKey;
700
+ if (isRedoCombo) {
701
+ event.preventDefault();
702
+ handleRedo();
703
+ } else if (isUndoCombo) {
704
+ event.preventDefault();
705
+ handleUndo();
706
+ }
707
+ }
708
+ window.addEventListener("keydown", handleKeyDown);
709
+ return () => window.removeEventListener("keydown", handleKeyDown);
710
+ }, [handleUndo, handleRedo]);
711
+ const handleFieldUpdate = React.useCallback((fieldKey, updater) => {
712
+ updateSchema((current) => {
713
+ const next = deepClone(current);
714
+ const node = next.properties[fieldKey];
715
+ if (!node) return current;
716
+ next.properties[fieldKey] = updater(node);
717
+ return next;
718
+ });
719
+ }, [updateSchema]);
720
+ const handleRequiredToggle = React.useCallback((fieldKey, required) => {
721
+ updateSchema((current) => {
722
+ const next = deepClone(current);
723
+ const requiredList = new Set(next.required ?? []);
724
+ if (required) requiredList.add(fieldKey);
725
+ else requiredList.delete(fieldKey);
726
+ next.required = Array.from(requiredList);
727
+ return next;
728
+ });
729
+ }, [updateSchema]);
730
+ const handleDefaultActorRoleChange = React.useCallback((nextRole) => {
731
+ updateSchema((current) => {
732
+ const next = deepClone(current);
733
+ next["x-om-default-actor-role"] = nextRole;
734
+ const declared = new Set(next["x-om-roles"] ?? []);
735
+ declared.add(nextRole);
736
+ declared.add("admin");
737
+ next["x-om-roles"] = Array.from(declared);
738
+ return next;
739
+ });
740
+ }, [updateSchema]);
741
+ const handleAddRole = React.useCallback((role) => {
742
+ if (!isValidRoleIdentifier(role) || role === "admin") return;
743
+ updateSchema((current) => addRoleToSchema(current, role));
744
+ }, [updateSchema]);
745
+ const handleRenameRole = React.useCallback((oldRole, newRole) => {
746
+ if (oldRole === "admin" || newRole === "admin") return;
747
+ if (!isValidRoleIdentifier(newRole)) return;
748
+ updateSchema((current) => renameRoleInSchema(current, oldRole, newRole));
749
+ }, [updateSchema]);
750
+ const handleRemoveRole = React.useCallback((role) => {
751
+ if (role === "admin") return;
752
+ updateSchema((current) => removeRoleFromSchema(current, role));
753
+ }, [updateSchema]);
754
+ const handleToggleGuest = React.useCallback((enabled) => {
755
+ updateSchema(
756
+ (current) => enabled ? enableGuestSubmissions(current) : disableGuestSubmissions(current)
757
+ );
758
+ }, [updateSchema]);
759
+ const sensors = useSensors(
760
+ useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),
761
+ useSensor(KeyboardSensor, { coordinateGetter: gridKeyboardCoordinates })
762
+ );
763
+ const announcements = React.useMemo(() => buildAnnouncements(t, schemaRef), [t]);
764
+ const paletteEntries = React.useMemo(() => buildPaletteEntries(), []);
765
+ const paletteEntryById = React.useMemo(() => {
766
+ const map = /* @__PURE__ */ new Map();
767
+ for (const entry of [...paletteEntries.input, ...paletteEntries.survey, ...paletteEntries.layout]) {
768
+ map.set(entry.id, { displayNameKey: entry.displayNameKey, iconName: entry.iconName });
769
+ }
770
+ return map;
771
+ }, [paletteEntries]);
772
+ const handleDragStart = React.useCallback((event) => {
773
+ setActiveDragId(String(event.active.id));
774
+ setActiveDropTarget(null);
775
+ }, []);
776
+ const resolveDropPosition = React.useCallback((event) => {
777
+ const activeTop = event.active.rect.current.translated?.top ?? event.active.rect.current.initial?.top ?? null;
778
+ const activeHeight = event.active.rect.current.translated?.height ?? event.active.rect.current.initial?.height ?? 0;
779
+ const overTop = event.over?.rect.top ?? null;
780
+ const overHeight = event.over?.rect.height ?? 0;
781
+ if (activeTop === null || overTop === null) return "before";
782
+ return activeTop + activeHeight / 2 > overTop + overHeight / 2 ? "after" : "before";
783
+ }, []);
784
+ const handleDragOver = React.useCallback((event) => {
785
+ const overId = event.over ? String(event.over.id) : null;
786
+ if (!overId) {
787
+ setActiveDropTarget(null);
788
+ return;
789
+ }
790
+ if (overId.startsWith(FIELD_DRAGGABLE_PREFIX) || overId.startsWith(SECTION_DRAGGABLE_PREFIX)) {
791
+ setActiveDropTarget({ kind: "sortable", id: overId, position: resolveDropPosition(event) });
792
+ return;
793
+ }
794
+ if (overId.startsWith(SECTION_DROP_PREFIX)) {
795
+ const parsed = parseSectionDropId(overId);
796
+ if (!parsed || parsed.kind === "legacy") {
797
+ setActiveDropTarget(null);
798
+ return;
799
+ }
800
+ if (parsed.kind === "cell") {
801
+ setActiveDropTarget({
802
+ kind: "cell",
803
+ sectionKey: parsed.sectionKey,
804
+ rowIndex: parsed.rowIndex,
805
+ columnIndex: parsed.columnIndex,
806
+ dropId: overId
807
+ });
808
+ return;
809
+ }
810
+ if (parsed.kind === "col-gap") {
811
+ setActiveDropTarget({
812
+ kind: "col-gap",
813
+ sectionKey: parsed.sectionKey,
814
+ rowIndex: parsed.rowIndex,
815
+ columnIndex: parsed.columnIndex,
816
+ dropId: overId
817
+ });
818
+ return;
819
+ }
820
+ setActiveDropTarget({
821
+ kind: "row-gap",
822
+ sectionKey: parsed.sectionKey,
823
+ rowIndex: parsed.rowIndex,
824
+ dropId: overId
825
+ });
826
+ return;
827
+ }
828
+ setActiveDropTarget(null);
829
+ }, [resolveDropPosition]);
830
+ const handleDragEnd = React.useCallback((event) => {
831
+ setActiveDragId(null);
832
+ setActiveDropTarget(null);
833
+ const { active, over } = event;
834
+ if (!over) return;
835
+ const activeId = String(active.id);
836
+ const overId = String(over.id);
837
+ const handleDrop = (next) => {
838
+ try {
839
+ validateSchemaExtensions(next.schema);
840
+ } catch (error) {
841
+ flash(t("forms.studio.autosave.invalidSchema"), "error");
842
+ logger.warn("drop validation failed", { err: error });
843
+ return;
844
+ }
845
+ undoController.push({
846
+ schema: schemaRef.current,
847
+ selection: selectionRef.current
848
+ });
849
+ setSchema(next.schema);
850
+ dirtyFlagRef.current = true;
851
+ persistDraft(next.schema);
852
+ if (next.selection !== void 0) setSelection(next.selection);
853
+ };
854
+ const resolveTargetSection = () => {
855
+ if (overId.startsWith(SECTION_DROP_PREFIX)) {
856
+ const parsed = parseSectionDropId(overId);
857
+ if (!parsed) {
858
+ return { sectionKey: overId.slice(SECTION_DROP_PREFIX.length) };
859
+ }
860
+ if (parsed.kind === "legacy") {
861
+ return { sectionKey: parsed.sectionKey };
862
+ }
863
+ const sections = schemaRef.current["x-om-sections"] ?? [];
864
+ const section = sections.find((entry) => entry.key === parsed.sectionKey);
865
+ if (!section) return { sectionKey: parsed.sectionKey };
866
+ const view = resolveSectionViews(schemaRef.current).find(
867
+ (entry) => entry.key === parsed.sectionKey
868
+ );
869
+ const columns = view?.columns ?? 1;
870
+ const fieldKeys = section.fieldKeys.filter((key) => schemaRef.current.properties[key]);
871
+ if (fieldKeys.length === 0) {
872
+ return { sectionKey: parsed.sectionKey, index: 0 };
873
+ }
874
+ const spans = {};
875
+ for (const key of fieldKeys) {
876
+ spans[key] = readSpan(schemaRef.current.properties[key]?.["x-om-grid-span"]);
877
+ }
878
+ const layout = computeRowLayout({ fieldKeys, spans, columns });
879
+ if (parsed.kind === "cell" || parsed.kind === "col-gap") {
880
+ const index2 = dropHintToLinearIndex({
881
+ layout,
882
+ rowIndex: parsed.rowIndex,
883
+ columnIndex: parsed.columnIndex
884
+ });
885
+ return { sectionKey: parsed.sectionKey, index: index2 };
886
+ }
887
+ let index = 0;
888
+ for (let r = 0; r < parsed.rowIndex && r < layout.rows.length; r += 1) {
889
+ index += layout.rows[r].cells.filter((cell) => cell.kind === "field").length;
890
+ }
891
+ return { sectionKey: parsed.sectionKey, index };
892
+ }
893
+ if (overId.startsWith(FIELD_DRAGGABLE_PREFIX)) {
894
+ const overFieldKey = overId.slice(FIELD_DRAGGABLE_PREFIX.length);
895
+ const owning = findSectionOwning(schemaRef.current, overFieldKey);
896
+ if (!owning) return null;
897
+ const overIndex = indexOfFieldInSection(schemaRef.current, owning.key, overFieldKey);
898
+ if (overIndex < 0) return { sectionKey: owning.key };
899
+ const position = resolveDropPosition(event);
900
+ return { sectionKey: owning.key, index: overIndex + (position === "after" ? 1 : 0) };
901
+ }
902
+ return null;
903
+ };
904
+ if (activeId.startsWith(PALETTE_DRAGGABLE_PREFIX)) {
905
+ const rawId = activeId.slice(PALETTE_DRAGGABLE_PREFIX.length);
906
+ const resolved = resolvePaletteId(rawId);
907
+ if (resolved.kind === "input" || resolved.kind === "layout-field") {
908
+ const target = resolveTargetSection();
909
+ if (!target) return;
910
+ const targetSection = (schemaRef.current["x-om-sections"] ?? []).find(
911
+ (entry) => entry.key === target.sectionKey
912
+ );
913
+ if (targetSection?.kind === "ending" && resolved.typeKey !== "info_block") {
914
+ flash(t("forms.studio.canvas.ending.dropRejected"), "error");
915
+ return;
916
+ }
917
+ try {
918
+ const result = addFieldFromPalette({
919
+ schema: schemaRef.current,
920
+ typeKey: resolved.typeKey,
921
+ target
922
+ });
923
+ handleDrop({
924
+ schema: result.schema,
925
+ selection: { kind: "field", key: result.fieldKey }
926
+ });
927
+ } catch (error) {
928
+ flash(t("forms.studio.autosave.invalidSchema"), "error");
929
+ logger.warn("palette drop failed", { err: error });
930
+ }
931
+ return;
932
+ }
933
+ if (resolved.kind === "layout-primitive") {
934
+ let insertionIndex;
935
+ const sections = schemaRef.current["x-om-sections"] ?? [];
936
+ if (overId.startsWith(SECTION_DRAGGABLE_PREFIX)) {
937
+ const overSectionKey = overId.slice(SECTION_DRAGGABLE_PREFIX.length);
938
+ const candidate = sections.findIndex((entry) => entry.key === overSectionKey);
939
+ if (candidate >= 0) {
940
+ insertionIndex = candidate + (resolveDropPosition(event) === "after" ? 1 : 0);
941
+ }
942
+ }
943
+ try {
944
+ const result = addLayoutFromPalette({
945
+ schema: schemaRef.current,
946
+ kind: resolved.layoutKind,
947
+ target: { index: insertionIndex }
948
+ });
949
+ handleDrop({
950
+ schema: result.schema,
951
+ selection: { kind: "section", key: result.sectionKey }
952
+ });
953
+ setFocusSectionTitleKey(result.sectionKey);
954
+ } catch (error) {
955
+ flash(t("forms.studio.autosave.invalidSchema"), "error");
956
+ logger.warn("layout drop failed", { err: error });
957
+ }
958
+ return;
959
+ }
960
+ return;
961
+ }
962
+ if (activeId.startsWith(SECTION_DRAGGABLE_PREFIX)) {
963
+ const sectionKey = activeId.slice(SECTION_DRAGGABLE_PREFIX.length);
964
+ let beforeKey = null;
965
+ if (overId.startsWith(SECTION_DRAGGABLE_PREFIX)) {
966
+ const overKey = overId.slice(SECTION_DRAGGABLE_PREFIX.length);
967
+ if (overKey !== sectionKey) {
968
+ if (resolveDropPosition(event) === "after") {
969
+ const sections = schemaRef.current["x-om-sections"] ?? [];
970
+ const overIndex = sections.findIndex((entry) => entry.key === overKey);
971
+ beforeKey = sections[overIndex + 1]?.key ?? null;
972
+ } else {
973
+ beforeKey = overKey;
974
+ }
975
+ }
976
+ }
977
+ try {
978
+ const nextSchema = moveSection({ schema: schemaRef.current, sectionKey, beforeKey });
979
+ handleDrop({ schema: nextSchema });
980
+ } catch (error) {
981
+ flash(t("forms.studio.autosave.invalidSchema"), "error");
982
+ logger.warn("section reorder failed", { err: error });
983
+ }
984
+ return;
985
+ }
986
+ if (activeId.startsWith(FIELD_DRAGGABLE_PREFIX)) {
987
+ const fieldKey = activeId.slice(FIELD_DRAGGABLE_PREFIX.length);
988
+ const target = resolveTargetSection();
989
+ if (!target) return;
990
+ const owning = findSectionOwning(schemaRef.current, fieldKey);
991
+ if (owning && owning.key === target.sectionKey && typeof target.index === "number") {
992
+ const currentIndex = indexOfFieldInSection(schemaRef.current, owning.key, fieldKey);
993
+ if (currentIndex >= 0 && currentIndex < target.index) {
994
+ target.index -= 1;
995
+ }
996
+ }
997
+ try {
998
+ const nextSchema = moveField({
999
+ schema: schemaRef.current,
1000
+ fieldKey,
1001
+ target
1002
+ });
1003
+ handleDrop({ schema: nextSchema });
1004
+ } catch (error) {
1005
+ flash(t("forms.studio.autosave.invalidSchema"), "error");
1006
+ logger.warn("reorder failed", { err: error });
1007
+ }
1008
+ }
1009
+ }, [persistDraft, resolveDropPosition, t, undoController]);
1010
+ const handleDragCancel = React.useCallback(() => {
1011
+ setActiveDragId(null);
1012
+ setActiveDropTarget(null);
1013
+ }, []);
1014
+ const handleMoveField = React.useCallback((fieldKey, direction) => {
1015
+ const owning = findSectionOwning(schemaRef.current, fieldKey);
1016
+ if (!owning) return;
1017
+ const currentIndex = indexOfFieldInSection(schemaRef.current, owning.key, fieldKey);
1018
+ const nextIndex = direction === "up" ? currentIndex - 1 : currentIndex + 1;
1019
+ if (currentIndex < 0 || nextIndex < 0 || nextIndex >= owning.fieldKeys.length) return;
1020
+ updateSchemaStructural((current) => moveField({
1021
+ schema: current,
1022
+ fieldKey,
1023
+ target: { sectionKey: owning.key, index: nextIndex }
1024
+ }));
1025
+ }, [updateSchemaStructural]);
1026
+ const handleMoveSection = React.useCallback((sectionKey, direction) => {
1027
+ const sections = schemaRef.current["x-om-sections"] ?? [];
1028
+ const currentIndex = sections.findIndex((entry) => entry.key === sectionKey);
1029
+ const nextIndex = direction === "up" ? currentIndex - 1 : currentIndex + 1;
1030
+ if (currentIndex < 0 || nextIndex < 0 || nextIndex >= sections.length) return;
1031
+ const beforeKey = direction === "up" ? sections[nextIndex]?.key ?? null : sections[nextIndex + 1]?.key ?? null;
1032
+ updateSchemaStructural((current) => moveSection({ schema: current, sectionKey, beforeKey }));
1033
+ }, [updateSchemaStructural]);
1034
+ const dragOverlayContent = React.useMemo(() => {
1035
+ if (!activeDragId) return null;
1036
+ const resolveHoveredSectionKey = () => {
1037
+ if (!activeDropTarget) return null;
1038
+ if (activeDropTarget.kind === "sortable") {
1039
+ if (activeDropTarget.id.startsWith(FIELD_DRAGGABLE_PREFIX)) {
1040
+ const overFieldKey = activeDropTarget.id.slice(FIELD_DRAGGABLE_PREFIX.length);
1041
+ const owning = findSectionOwning(schemaRef.current, overFieldKey);
1042
+ return owning ? owning.key : null;
1043
+ }
1044
+ if (activeDropTarget.id.startsWith(SECTION_DRAGGABLE_PREFIX)) {
1045
+ return activeDropTarget.id.slice(SECTION_DRAGGABLE_PREFIX.length);
1046
+ }
1047
+ return null;
1048
+ }
1049
+ return activeDropTarget.sectionKey;
1050
+ };
1051
+ const resolveTargetGeometry = (spanIntent) => {
1052
+ const sectionKey = resolveHoveredSectionKey();
1053
+ if (!sectionKey) return null;
1054
+ const node = gridRefs.current.get(sectionKey);
1055
+ if (!node) return null;
1056
+ const rect = node.getBoundingClientRect();
1057
+ if (!rect || rect.width <= 0) return null;
1058
+ const view = resolveSectionViews(schemaRef.current).find(
1059
+ (entry) => entry.key === sectionKey
1060
+ );
1061
+ if (!view) return null;
1062
+ const widthPx = computeOverlayWidthPx({
1063
+ sectionWidthPx: rect.width,
1064
+ columns: view.columns,
1065
+ span: spanIntent,
1066
+ gap: view.gap
1067
+ });
1068
+ if (!Number.isFinite(widthPx) || widthPx <= 0) return null;
1069
+ return { widthPx };
1070
+ };
1071
+ if (activeDragId.startsWith(PALETTE_DRAGGABLE_PREFIX)) {
1072
+ const rawId = activeDragId.slice(PALETTE_DRAGGABLE_PREFIX.length);
1073
+ const meta = paletteEntryById.get(rawId);
1074
+ if (!meta) return null;
1075
+ const resolved = resolvePaletteId(rawId);
1076
+ const isSectionPrimitive = resolved.kind === "layout-primitive";
1077
+ const geometry = isSectionPrimitive ? null : resolveTargetGeometry(1);
1078
+ return /* @__PURE__ */ jsx(
1079
+ DragOverlayCard,
1080
+ {
1081
+ Icon: resolveLucideIcon(meta.iconName),
1082
+ label: t(meta.displayNameKey),
1083
+ widthPx: geometry?.widthPx
1084
+ }
1085
+ );
1086
+ }
1087
+ if (activeDragId.startsWith(SECTION_DRAGGABLE_PREFIX)) {
1088
+ return null;
1089
+ }
1090
+ if (activeDragId.startsWith(FIELD_DRAGGABLE_PREFIX)) {
1091
+ const fieldKey = activeDragId.slice(FIELD_DRAGGABLE_PREFIX.length);
1092
+ const node = schemaRef.current.properties[fieldKey];
1093
+ if (!node) return null;
1094
+ const omType = String(node["x-om-type"] ?? "text");
1095
+ const Icon = resolveLucideIcon(
1096
+ paletteEntryById.get(omType)?.iconName ?? paletteEntryById.get(`layout:field:${omType}`)?.iconName
1097
+ );
1098
+ const label = node["x-om-label"]?.en ?? fieldKey;
1099
+ const persistedSpan = readSpan(node["x-om-grid-span"]) ?? 1;
1100
+ const geometry = resolveTargetGeometry(persistedSpan);
1101
+ return /* @__PURE__ */ jsx(DragOverlayCard, { Icon, label, widthPx: geometry?.widthPx });
1102
+ }
1103
+ return null;
1104
+ }, [activeDragId, activeDropTarget, paletteEntryById, t]);
1105
+ const persistFormPatch = React.useMemo(
1106
+ () => autosaveDebounce(async (payload) => {
1107
+ const call = await runMutation({
1108
+ operation: () => withScopedApiRequestHeaders(
1109
+ buildOptimisticLockHeader(formUpdatedAtRef.current),
1110
+ () => apiCall(`/api/forms/${encodeURIComponent(formId)}`, {
1111
+ method: "PATCH",
1112
+ body: JSON.stringify(payload)
1113
+ })
1114
+ ),
1115
+ context: { formId },
1116
+ mutationPayload: { formId, ...payload }
1117
+ });
1118
+ if (!call.ok) {
1119
+ if (surfaceRecordConflict({ status: call.status, body: call.result }, t)) return;
1120
+ const errPayload = call.result;
1121
+ flash(t(errPayload?.error ?? "forms.studio.autosave.error"), "error");
1122
+ return;
1123
+ }
1124
+ const updatedAt = call.result?.updatedAt;
1125
+ if (updatedAt) {
1126
+ formUpdatedAtRef.current = updatedAt;
1127
+ setForm((current) => current ? { ...current, updatedAt } : current);
1128
+ }
1129
+ }, 1e3),
1130
+ [formId, runMutation, t]
1131
+ );
1132
+ const handleNameChange = React.useCallback((nextName) => {
1133
+ setForm((current) => current ? { ...current, name: nextName } : current);
1134
+ persistFormPatch({ name: nextName });
1135
+ }, [persistFormPatch]);
1136
+ const handleDescriptionChange = React.useCallback((nextDescription) => {
1137
+ setForm((current) => current ? { ...current, description: nextDescription } : current);
1138
+ persistFormPatch({ description: nextDescription.length > 0 ? nextDescription : null });
1139
+ }, [persistFormPatch]);
1140
+ const persistLocalePatch = React.useCallback(
1141
+ async (payload) => {
1142
+ setForm(
1143
+ (current) => current ? { ...current, supportedLocales: payload.supportedLocales, defaultLocale: payload.defaultLocale } : current
1144
+ );
1145
+ setActiveLocale(
1146
+ (current) => payload.supportedLocales.includes(current) ? current : payload.defaultLocale
1147
+ );
1148
+ const call = await runMutation({
1149
+ operation: () => withScopedApiRequestHeaders(
1150
+ buildOptimisticLockHeader(formUpdatedAtRef.current),
1151
+ () => apiCall(`/api/forms/${encodeURIComponent(formId)}`, {
1152
+ method: "PATCH",
1153
+ body: JSON.stringify(payload)
1154
+ })
1155
+ ),
1156
+ context: { formId },
1157
+ mutationPayload: { formId, ...payload }
1158
+ });
1159
+ if (!call.ok) {
1160
+ if (surfaceRecordConflict({ status: call.status, body: call.result }, t)) {
1161
+ await reload();
1162
+ return;
1163
+ }
1164
+ const errPayload = call.result;
1165
+ flash(t(errPayload?.error ?? "forms.studio.autosave.error"), "error");
1166
+ await reload();
1167
+ return;
1168
+ }
1169
+ const updatedAt = call.result?.updatedAt;
1170
+ if (updatedAt) {
1171
+ formUpdatedAtRef.current = updatedAt;
1172
+ setForm((current) => current ? { ...current, updatedAt } : current);
1173
+ }
1174
+ },
1175
+ [formId, reload, runMutation, t]
1176
+ );
1177
+ const handleAddLocale = React.useCallback(
1178
+ (locale) => {
1179
+ const trimmed = locale.trim();
1180
+ if (!trimmed) return;
1181
+ setForm((current) => {
1182
+ if (!current || current.supportedLocales.includes(trimmed)) return current;
1183
+ const nextSupported = [...current.supportedLocales, trimmed];
1184
+ void persistLocalePatch({ supportedLocales: nextSupported, defaultLocale: current.defaultLocale });
1185
+ return current;
1186
+ });
1187
+ },
1188
+ [persistLocalePatch]
1189
+ );
1190
+ const handleRemoveLocale = React.useCallback(
1191
+ (locale) => {
1192
+ setForm((current) => {
1193
+ if (!current) return current;
1194
+ if (locale === current.defaultLocale) return current;
1195
+ if (current.supportedLocales.length <= 1) return current;
1196
+ const nextSupported = current.supportedLocales.filter((entry) => entry !== locale);
1197
+ void persistLocalePatch({ supportedLocales: nextSupported, defaultLocale: current.defaultLocale });
1198
+ return current;
1199
+ });
1200
+ },
1201
+ [persistLocalePatch]
1202
+ );
1203
+ const handleDefaultLocaleChange = React.useCallback(
1204
+ (locale) => {
1205
+ setForm((current) => {
1206
+ if (!current || locale === current.defaultLocale) return current;
1207
+ if (!current.supportedLocales.includes(locale)) return current;
1208
+ void persistLocalePatch({ supportedLocales: current.supportedLocales, defaultLocale: locale });
1209
+ return current;
1210
+ });
1211
+ },
1212
+ [persistLocalePatch]
1213
+ );
1214
+ const declaredRoles = React.useMemo(
1215
+ () => (schema["x-om-roles"] ?? []).filter((entry) => typeof entry === "string"),
1216
+ [schema]
1217
+ );
1218
+ const guestEnabled = React.useMemo(() => isGuestSubmissionEnabled(schema), [schema]);
1219
+ const previewRoles = React.useMemo(() => {
1220
+ const all = /* @__PURE__ */ new Set(["admin"]);
1221
+ declaredRoles.forEach((entry) => all.add(entry));
1222
+ return Array.from(all);
1223
+ }, [declaredRoles]);
1224
+ const selectedField = selectedFieldKey ? schema.properties[selectedFieldKey] : null;
1225
+ const selectedSectionNode = selection?.kind === "section" ? (schema["x-om-sections"] ?? []).find((entry) => entry.key === selection.key) ?? null : null;
1226
+ const sectionsForDerivation = resolveSectionViews(schema);
1227
+ const derivedPages = partitionPages(sectionsForDerivation);
1228
+ const density = resolveFormStyle(schema);
1229
+ const persistedLabelPosition = resolveFormLabelPosition(schema);
1230
+ const pageMode = resolvePageMode(schema);
1231
+ const persistedShowProgress = resolveShowProgress(schema);
1232
+ const persistedTheme = resolveFormTheme(schema);
1233
+ const canUndo = undoController.canUndo();
1234
+ const canRedo = undoController.canRedo();
1235
+ void undoNonce;
1236
+ const persistedHiddenFields = React.useMemo(() => {
1237
+ const raw = schema["x-om-hidden-fields"];
1238
+ if (!Array.isArray(raw)) return [];
1239
+ return raw.filter((entry) => !!entry && typeof entry === "object").map((entry) => ({
1240
+ name: String(entry.name ?? ""),
1241
+ defaultValue: typeof entry.defaultValue === "string" ? entry.defaultValue : void 0
1242
+ })).filter((entry) => entry.name.length > 0);
1243
+ }, [schema]);
1244
+ const persistedJumps = React.useMemo(() => {
1245
+ const raw = schema["x-om-jumps"];
1246
+ if (!Array.isArray(raw)) return [];
1247
+ const result = [];
1248
+ for (const entry of raw) {
1249
+ if (!entry || typeof entry !== "object") continue;
1250
+ const candidate = entry;
1251
+ if (!candidate.from || typeof candidate.from !== "object") continue;
1252
+ if (!Array.isArray(candidate.rules)) continue;
1253
+ result.push({
1254
+ from: candidate.from,
1255
+ rules: candidate.rules,
1256
+ otherwise: candidate.otherwise
1257
+ });
1258
+ }
1259
+ return result;
1260
+ }, [schema]);
1261
+ const persistedVariables = React.useMemo(() => {
1262
+ const raw = schema["x-om-variables"];
1263
+ if (!Array.isArray(raw)) return [];
1264
+ const result = [];
1265
+ for (const entry of raw) {
1266
+ if (!entry || typeof entry !== "object") continue;
1267
+ const candidate = entry;
1268
+ const type = candidate.type;
1269
+ if (type !== "number" && type !== "boolean" && type !== "string") continue;
1270
+ const name = String(candidate.name ?? "");
1271
+ if (name.length === 0) continue;
1272
+ const next = { name, type, formula: candidate.formula };
1273
+ if (candidate.default !== void 0) {
1274
+ next.default = candidate.default;
1275
+ }
1276
+ result.push(next);
1277
+ }
1278
+ return result;
1279
+ }, [schema]);
1280
+ if (isLoading) {
1281
+ return /* @__PURE__ */ jsx(LoadingMessage, { label: t("forms.studio.title") });
1282
+ }
1283
+ if (loadError === "forms.errors.form_not_found") {
1284
+ return /* @__PURE__ */ jsx(
1285
+ RecordNotFoundState,
1286
+ {
1287
+ label: t(loadError),
1288
+ backHref: "/backend/forms",
1289
+ backLabel: t("forms.list.title")
1290
+ }
1291
+ );
1292
+ }
1293
+ if (loadError || !form) {
1294
+ return /* @__PURE__ */ jsx(
1295
+ ErrorMessage,
1296
+ {
1297
+ label: t(loadError ?? "forms.errors.internal"),
1298
+ action: /* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", children: /* @__PURE__ */ jsx(Link, { href: "/backend/forms", children: t("forms.list.title") }) })
1299
+ }
1300
+ );
1301
+ }
1302
+ const paletteParameters = {
1303
+ formId,
1304
+ formKey: form.key,
1305
+ name: form.name,
1306
+ description: form.description ?? "",
1307
+ supportedLocales: form.supportedLocales,
1308
+ defaultLocale: form.defaultLocale,
1309
+ defaultActorRole: schema["x-om-default-actor-role"] ?? "admin",
1310
+ declaredRoles,
1311
+ guestEnabled,
1312
+ density,
1313
+ labelPosition: persistedLabelPosition,
1314
+ pageMode,
1315
+ showProgress: persistedShowProgress,
1316
+ pagesCount: derivedPages.length,
1317
+ hiddenFields: persistedHiddenFields,
1318
+ variables: persistedVariables,
1319
+ schema,
1320
+ onNameChange: handleNameChange,
1321
+ onDescriptionChange: handleDescriptionChange,
1322
+ onToggleGuest: handleToggleGuest,
1323
+ onAddRole: handleAddRole,
1324
+ onRenameRole: handleRenameRole,
1325
+ onRemoveRole: handleRemoveRole,
1326
+ onDefaultActorRoleChange: handleDefaultActorRoleChange,
1327
+ onDensityChange: handleDensityChange,
1328
+ onLabelPositionChange: handleLabelPositionChange,
1329
+ onPageModeChange: handlePageModeChange,
1330
+ onShowProgressChange: handleShowProgressChange,
1331
+ onHiddenFieldsChange: handleHiddenFieldsChange,
1332
+ onVariablesChange: handleVariablesChange,
1333
+ onAddLocale: handleAddLocale,
1334
+ onRemoveLocale: handleRemoveLocale,
1335
+ onDefaultLocaleChange: handleDefaultLocaleChange
1336
+ };
1337
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1338
+ /* @__PURE__ */ jsx(
1339
+ "div",
1340
+ {
1341
+ role: "status",
1342
+ "aria-live": "polite",
1343
+ "aria-atomic": "true",
1344
+ className: "sr-only",
1345
+ children: resizeAnnouncement
1346
+ }
1347
+ ),
1348
+ /* @__PURE__ */ jsxs("header", { className: "mb-4 flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between", children: [
1349
+ /* @__PURE__ */ jsxs("div", { children: [
1350
+ /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-foreground", children: form.name }),
1351
+ /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
1352
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: form.key }),
1353
+ /* @__PURE__ */ jsx("span", { className: "mx-2", children: "\u2014" }),
1354
+ /* @__PURE__ */ jsxs("span", { children: [
1355
+ t("forms.studio.schemaHashLabel"),
1356
+ ": ",
1357
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: (version?.schemaHash ?? "").slice(0, 12) || "\u2014" })
1358
+ ] })
1359
+ ] })
1360
+ ] }),
1361
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1362
+ form.supportedLocales.length > 1 ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
1363
+ /* @__PURE__ */ jsx(Globe, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }),
1364
+ /* @__PURE__ */ jsxs(Select, { value: activeLocale, onValueChange: setActiveLocale, children: [
1365
+ /* @__PURE__ */ jsx(
1366
+ SelectTrigger,
1367
+ {
1368
+ className: "h-8 w-24",
1369
+ "aria-label": t("forms.studio.locale_switcher.label"),
1370
+ children: /* @__PURE__ */ jsx(SelectValue, {})
1371
+ }
1372
+ ),
1373
+ /* @__PURE__ */ jsx(SelectContent, { children: form.supportedLocales.map((locale) => /* @__PURE__ */ jsx(SelectItem, { value: locale, children: locale }, locale)) })
1374
+ ] })
1375
+ ] }) : null,
1376
+ /* @__PURE__ */ jsx(Tag, { variant: version?.status === "published" ? "success" : "warning", dot: true, children: t(version?.status === "published" ? "forms.studio.statusPublished" : version?.status === "archived" ? "forms.studio.statusArchived" : "forms.studio.statusDraft") }),
1377
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: autosaveState === "saving" ? t("forms.studio.autosave.saving") : autosaveState === "error" ? t("forms.studio.autosave.error") : t("forms.studio.autosave.idle") }),
1378
+ /* @__PURE__ */ jsx(
1379
+ IconButton,
1380
+ {
1381
+ type: "button",
1382
+ variant: "ghost",
1383
+ size: "sm",
1384
+ onClick: handleUndo,
1385
+ disabled: !canUndo,
1386
+ "aria-label": t("forms.studio.undo.button.undo"),
1387
+ title: t("forms.studio.undo.button.undo"),
1388
+ children: /* @__PURE__ */ jsx(Undo2, { className: "size-4", "aria-hidden": "true" })
1389
+ }
1390
+ ),
1391
+ /* @__PURE__ */ jsx(
1392
+ IconButton,
1393
+ {
1394
+ type: "button",
1395
+ variant: "ghost",
1396
+ size: "sm",
1397
+ onClick: handleRedo,
1398
+ disabled: !canRedo,
1399
+ "aria-label": t("forms.studio.undo.button.redo"),
1400
+ title: t("forms.studio.undo.button.redo"),
1401
+ children: /* @__PURE__ */ jsx(Redo2, { className: "size-4", "aria-hidden": "true" })
1402
+ }
1403
+ ),
1404
+ /* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", children: /* @__PURE__ */ jsx(Link, { href: `/backend/forms/${encodeURIComponent(formId)}/history`, children: t("forms.studio.actions.history") }) }),
1405
+ /* @__PURE__ */ jsx(Button, { onClick: () => setShowPublishDialog(true), disabled: !draftVersionId, children: t("forms.studio.actions.publish") })
1406
+ ] })
1407
+ ] }),
1408
+ /* @__PURE__ */ jsxs(Tabs, { value: topTab, onValueChange: (next) => setTopTab(next), children: [
1409
+ /* @__PURE__ */ jsxs(TabsList, { children: [
1410
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "builder", children: t("forms.studio.tabs.top.builder") }),
1411
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "preview", children: t("forms.studio.tabs.top.preview") })
1412
+ ] }),
1413
+ /* @__PURE__ */ jsx(TabsContent, { value: "builder", children: /* @__PURE__ */ jsxs(
1414
+ DndContext,
1415
+ {
1416
+ sensors,
1417
+ collisionDetection: gridAwareCollision,
1418
+ onDragStart: handleDragStart,
1419
+ onDragOver: handleDragOver,
1420
+ onDragEnd: handleDragEnd,
1421
+ onDragCancel: handleDragCancel,
1422
+ accessibility: {
1423
+ announcements,
1424
+ screenReaderInstructions: {
1425
+ draggable: t("forms.studio.dnd.instructions.draggable")
1426
+ }
1427
+ },
1428
+ children: [
1429
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-[280px_1fr_320px]", children: [
1430
+ /* @__PURE__ */ jsx(FormPalettePanel, { parameters: paletteParameters }),
1431
+ /* @__PURE__ */ jsxs("section", { className: "rounded-lg border border-border bg-card p-4", children: [
1432
+ /* @__PURE__ */ jsx("h2", { className: "mb-3 text-sm font-semibold uppercase tracking-wide text-muted-foreground", children: t("forms.studio.panes.tree") }),
1433
+ /* @__PURE__ */ jsx(
1434
+ FormCanvas,
1435
+ {
1436
+ schema,
1437
+ selectedKey: selection,
1438
+ onSelectField: selectField,
1439
+ onSelectSection: selectSection,
1440
+ onDeleteField: handleDeleteField,
1441
+ onDeleteSection: (key) => {
1442
+ void handleDeleteSection(key);
1443
+ },
1444
+ onMoveField: handleMoveField,
1445
+ onMoveSection: handleMoveSection,
1446
+ onAdoptUngrouped: handleAdoptUngrouped,
1447
+ onSectionTitleCommit: handleSectionTitleCommit,
1448
+ focusSectionTitleKey,
1449
+ onSectionTitleFocusConsumed: () => setFocusSectionTitleKey(null),
1450
+ activeLocale,
1451
+ activeDropTarget,
1452
+ resizeState: fieldResizeState,
1453
+ onFieldResizeStart: handleFieldResizeStart,
1454
+ onFieldResizePreview: handleFieldResizePreview,
1455
+ onFieldResizeCommit: handleFieldResizeCommit,
1456
+ gridRefs,
1457
+ t
1458
+ }
1459
+ )
1460
+ ] }),
1461
+ /* @__PURE__ */ jsxs("aside", { className: "rounded-lg border border-border bg-card p-4", children: [
1462
+ /* @__PURE__ */ jsx("h2", { className: "mb-3 text-sm font-semibold uppercase tracking-wide text-muted-foreground", children: t("forms.studio.panes.properties") }),
1463
+ selection?.kind === "section" ? /* @__PURE__ */ jsx(
1464
+ SectionPropertiesPanel,
1465
+ {
1466
+ schema,
1467
+ sectionKey: selection.key,
1468
+ activeLocale,
1469
+ jumps: persistedJumps,
1470
+ onColumnsChange: handleSectionColumnsChange,
1471
+ onGapChange: handleSectionGapChange,
1472
+ onDividerChange: handleSectionDividerChange,
1473
+ onKindChange: handleSectionKindChange,
1474
+ onHideTitleChange: handleSectionHideTitleChange,
1475
+ onStyleChange: handleSectionStyleChange,
1476
+ onVisibilityChange: handleSectionVisibilityChange,
1477
+ onRedirectUrlChange: handleRedirectUrlChange,
1478
+ onJumpsChange: handleJumpsChange,
1479
+ t
1480
+ }
1481
+ ) : !selectedField || !selectedFieldKey ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1482
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("forms.studio.empty") }),
1483
+ /* @__PURE__ */ jsx(
1484
+ FormAppearancePanel,
1485
+ {
1486
+ formId,
1487
+ theme: persistedTheme,
1488
+ onThemeChange: handleThemeChange
1489
+ }
1490
+ )
1491
+ ] }) : /* @__PURE__ */ jsx(
1492
+ FieldPropertiesPanel,
1493
+ {
1494
+ schema,
1495
+ fieldKey: selectedFieldKey,
1496
+ node: selectedField,
1497
+ declaredRoles,
1498
+ required: (schema.required ?? []).includes(selectedFieldKey),
1499
+ activeLocale,
1500
+ onUpdate: (updater) => handleFieldUpdate(selectedFieldKey, updater),
1501
+ onRequiredChange: (value) => handleRequiredToggle(selectedFieldKey, value),
1502
+ onDelete: () => handleDeleteField(selectedFieldKey),
1503
+ onGridSpanChange: handleFieldGridSpan,
1504
+ onAlignChange: handleFieldAlign,
1505
+ onHideMobileChange: handleFieldHideMobile,
1506
+ onStyleChange: handleFieldStyleChange,
1507
+ onTypeSwap: handleFieldTypeSwap,
1508
+ onVisibilityChange: handleFieldVisibilityChange,
1509
+ t
1510
+ }
1511
+ ),
1512
+ /* @__PURE__ */ jsxs("details", { className: "mt-4", children: [
1513
+ /* @__PURE__ */ jsx("summary", { className: "cursor-pointer text-xs font-medium uppercase text-muted-foreground", children: t("forms.studio.compiledJson") }),
1514
+ /* @__PURE__ */ jsx("pre", { className: "mt-2 max-h-72 overflow-auto rounded-md border border-border bg-muted/30 p-2 text-xs", children: selectedField ? stableJsonStringify(selectedField) : selectedSectionNode ? stableJsonStringify(selectedSectionNode) : "{}" })
1515
+ ] })
1516
+ ] })
1517
+ ] }),
1518
+ /* @__PURE__ */ jsx(DragOverlay, { children: dragOverlayContent })
1519
+ ]
1520
+ }
1521
+ ) }),
1522
+ /* @__PURE__ */ jsx(TabsContent, { value: "preview", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-[1fr_320px]", children: [
1523
+ /* @__PURE__ */ jsxs("section", { className: "rounded-lg border border-border bg-card p-4", children: [
1524
+ /* @__PURE__ */ jsxs("div", { className: "mb-4 flex items-center justify-between", children: [
1525
+ /* @__PURE__ */ jsx("h2", { className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground", children: t("forms.studio.panes.preview") }),
1526
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs", children: [
1527
+ /* @__PURE__ */ jsx("span", { children: t("forms.studio.previewAs") }),
1528
+ /* @__PURE__ */ jsxs(Select, { value: previewRole, onValueChange: setPreviewRole, children: [
1529
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-32", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
1530
+ /* @__PURE__ */ jsx(SelectContent, { children: previewRoles.map((role) => /* @__PURE__ */ jsx(SelectItem, { value: role, children: role }, role)) })
1531
+ ] })
1532
+ ] })
1533
+ ] }),
1534
+ /* @__PURE__ */ jsx(
1535
+ ViewportFrame,
1536
+ {
1537
+ viewport: previewViewport,
1538
+ onViewportChange: setPreviewViewport,
1539
+ t,
1540
+ children: /* @__PURE__ */ jsx(
1541
+ PreviewSurface,
1542
+ {
1543
+ schema,
1544
+ viewport: previewViewport,
1545
+ previewRole,
1546
+ t
1547
+ }
1548
+ )
1549
+ }
1550
+ )
1551
+ ] }),
1552
+ /* @__PURE__ */ jsx("aside", { className: "space-y-3 rounded-lg border border-border bg-card p-4", children: (() => {
1553
+ const sectionNodes = schema["x-om-sections"] ?? [];
1554
+ const fieldOptions = buildFieldSourceOptions(schema, activeLocale, t).filter((entry) => entry.namespace === "field");
1555
+ const sectionKey = previewStyleTarget.startsWith("section:") ? previewStyleTarget.slice("section:".length) : null;
1556
+ const fieldKey = previewStyleTarget.startsWith("field:") ? previewStyleTarget.slice("field:".length) : null;
1557
+ const activeSection = sectionKey ? sectionNodes.find((s) => s.key === sectionKey) ?? null : null;
1558
+ const activeFieldNode = fieldKey ? schema.properties[fieldKey] ?? null : null;
1559
+ const effectiveTarget = activeSection ? previewStyleTarget : activeFieldNode ? previewStyleTarget : "form";
1560
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1561
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
1562
+ /* @__PURE__ */ jsx("label", { htmlFor: "forms-studio-preview-style-target", className: "block text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: t("forms.studio.style.target.label", "Style") }),
1563
+ /* @__PURE__ */ jsxs(Select, { value: effectiveTarget, onValueChange: setPreviewStyleTarget, children: [
1564
+ /* @__PURE__ */ jsx(SelectTrigger, { id: "forms-studio-preview-style-target", className: "h-8", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
1565
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
1566
+ /* @__PURE__ */ jsx(SelectItem, { value: "form", children: t("forms.studio.style.target.form", "Whole form") }),
1567
+ sectionNodes.map((section) => /* @__PURE__ */ jsxs(SelectItem, { value: `section:${section.key}`, children: [
1568
+ t("forms.studio.style.target.section", "Section"),
1569
+ ": ",
1570
+ section.title?.[activeLocale] ?? section.title?.en ?? section.key
1571
+ ] }, `section:${section.key}`)),
1572
+ fieldOptions.map((option) => /* @__PURE__ */ jsxs(SelectItem, { value: `field:${option.value}`, children: [
1573
+ t("forms.studio.style.target.field", "Field"),
1574
+ ": ",
1575
+ option.label
1576
+ ] }, `field:${option.value}`))
1577
+ ] })
1578
+ ] })
1579
+ ] }),
1580
+ activeSection ? /* @__PURE__ */ jsx(
1581
+ SectionAppearanceTabContent,
1582
+ {
1583
+ style: activeSection.style,
1584
+ onStyleChange: (next) => handleSectionStyleChange(activeSection.key, next),
1585
+ t
1586
+ }
1587
+ ) : activeFieldNode && fieldKey ? /* @__PURE__ */ jsx(
1588
+ FieldAppearanceTabContent,
1589
+ {
1590
+ style: activeFieldNode["x-om-style"],
1591
+ onStyleChange: (next) => handleFieldStyleChange(fieldKey, next),
1592
+ formSurface: persistedTheme?.surface ?? "surface",
1593
+ t
1594
+ }
1595
+ ) : /* @__PURE__ */ jsx(FormAppearancePanel, { formId, theme: persistedTheme, onThemeChange: handleThemeChange })
1596
+ ] });
1597
+ })() })
1598
+ ] }) })
1599
+ ] }),
1600
+ showPublishDialog && draftVersionId && /* @__PURE__ */ jsx(
1601
+ PublishDialog,
1602
+ {
1603
+ formId,
1604
+ versionId: draftVersionId,
1605
+ updatedAt: version?.updatedAt ?? null,
1606
+ onClose: () => setShowPublishDialog(false),
1607
+ onPublished: () => {
1608
+ setShowPublishDialog(false);
1609
+ flash(t("forms.studio.actions.publish"), "success");
1610
+ router.push(`/backend/forms/${encodeURIComponent(formId)}/history`);
1611
+ },
1612
+ t
1613
+ }
1614
+ ),
1615
+ ConfirmDialogElement
1616
+ ] });
1617
+ }
1618
+ function SectionPropertiesPanel(props) {
1619
+ const { schema, sectionKey, activeLocale, jumps, onVisibilityChange, onJumpsChange, onStyleChange, t } = props;
1620
+ const [tab, setTab] = React.useState("style");
1621
+ const sections = schema["x-om-sections"] ?? [];
1622
+ const section = sections.find((entry) => entry.key === sectionKey);
1623
+ if (!section) {
1624
+ return /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("forms.studio.empty") });
1625
+ }
1626
+ const isEnding = section.kind === "ending";
1627
+ const isPage = section.kind === "page";
1628
+ const sourceOptions = buildFieldSourceOptions(schema, activeLocale, t);
1629
+ return /* @__PURE__ */ jsxs(Tabs, { value: tab, onValueChange: (next) => setTab(next), children: [
1630
+ /* @__PURE__ */ jsxs(TabsList, { className: "w-full justify-stretch", children: [
1631
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "style", className: "flex-1", children: t("forms.studio.style.tabs.style") }),
1632
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "appearance", className: "flex-1", children: t("forms.studio.style.tabs.appearance", "Appearance") }),
1633
+ !isEnding ? /* @__PURE__ */ jsx(TabsTrigger, { value: "logic", className: "flex-1", children: t("forms.studio.logic.tab.label") }) : null
1634
+ ] }),
1635
+ /* @__PURE__ */ jsx(TabsContent, { value: "style", children: /* @__PURE__ */ jsx(SectionStyleTabContent, { ...props, section }) }),
1636
+ /* @__PURE__ */ jsx(TabsContent, { value: "appearance", children: /* @__PURE__ */ jsx(
1637
+ SectionAppearanceTabContent,
1638
+ {
1639
+ style: section.style,
1640
+ onStyleChange: (next) => onStyleChange(sectionKey, next),
1641
+ t
1642
+ }
1643
+ ) }),
1644
+ !isEnding ? /* @__PURE__ */ jsxs(TabsContent, { value: "logic", className: "space-y-4", children: [
1645
+ /* @__PURE__ */ jsx(
1646
+ ConditionBuilder,
1647
+ {
1648
+ predicate: section["x-om-visibility-if"] ?? null,
1649
+ sources: sourceOptions,
1650
+ onChange: (next) => onVisibilityChange(sectionKey, next)
1651
+ }
1652
+ ),
1653
+ isPage ? /* @__PURE__ */ jsx(
1654
+ JumpsEditor,
1655
+ {
1656
+ schema,
1657
+ pageKey: sectionKey,
1658
+ sources: sourceOptions,
1659
+ rules: jumps,
1660
+ onChange: onJumpsChange
1661
+ }
1662
+ ) : null
1663
+ ] }) : null
1664
+ ] });
1665
+ }
1666
+ function SectionStyleTabContent({
1667
+ schema,
1668
+ sectionKey,
1669
+ section,
1670
+ onColumnsChange,
1671
+ onGapChange,
1672
+ onDividerChange,
1673
+ onKindChange,
1674
+ onHideTitleChange,
1675
+ onRedirectUrlChange,
1676
+ t
1677
+ }) {
1678
+ void schema;
1679
+ const columns = section.columns ?? 1;
1680
+ const gap = section.gap ?? "md";
1681
+ const divider = section.divider === true;
1682
+ const kind = section.kind ?? "section";
1683
+ const hideTitle = section.hideTitle === true;
1684
+ const isEnding = kind === "ending";
1685
+ const redirectUrl = typeof section["x-om-redirect-url"] === "string" ? section["x-om-redirect-url"] : "";
1686
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1687
+ isEnding ? /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
1688
+ /* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.style.section.redirect.label") }),
1689
+ /* @__PURE__ */ jsx(
1690
+ Input,
1691
+ {
1692
+ type: "url",
1693
+ placeholder: "https://example.com/thanks",
1694
+ value: redirectUrl,
1695
+ onChange: (event) => onRedirectUrlChange(sectionKey, event.target.value)
1696
+ }
1697
+ ),
1698
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("forms.studio.style.section.redirect.helper") })
1699
+ ] }) : null,
1700
+ !isEnding ? /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
1701
+ /* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.style.section.kind.label") }),
1702
+ /* @__PURE__ */ jsxs(
1703
+ Select,
1704
+ {
1705
+ value: kind,
1706
+ onValueChange: (next) => onKindChange(sectionKey, next),
1707
+ children: [
1708
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
1709
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
1710
+ /* @__PURE__ */ jsx(SelectItem, { value: "section", children: t("forms.studio.style.section.kind.section") }),
1711
+ /* @__PURE__ */ jsx(SelectItem, { value: "page", children: t("forms.studio.style.section.kind.page") })
1712
+ ] })
1713
+ ]
1714
+ }
1715
+ ),
1716
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("forms.studio.style.section.kind.helper") })
1717
+ ] }) : null,
1718
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
1719
+ /* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.style.section.columns.label") }),
1720
+ /* @__PURE__ */ jsxs(
1721
+ Select,
1722
+ {
1723
+ value: String(columns),
1724
+ onValueChange: (next) => onColumnsChange(sectionKey, Number(next)),
1725
+ children: [
1726
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
1727
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
1728
+ /* @__PURE__ */ jsx(SelectItem, { value: "1", children: "1" }),
1729
+ /* @__PURE__ */ jsx(SelectItem, { value: "2", children: "2" }),
1730
+ /* @__PURE__ */ jsx(SelectItem, { value: "3", children: "3" }),
1731
+ /* @__PURE__ */ jsx(SelectItem, { value: "4", children: "4" })
1732
+ ] })
1733
+ ]
1734
+ }
1735
+ )
1736
+ ] }),
1737
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
1738
+ /* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.style.section.gap.label") }),
1739
+ /* @__PURE__ */ jsxs(
1740
+ Select,
1741
+ {
1742
+ value: gap,
1743
+ onValueChange: (next) => onGapChange(sectionKey, next),
1744
+ children: [
1745
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
1746
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
1747
+ /* @__PURE__ */ jsx(SelectItem, { value: "sm", children: t("forms.studio.style.section.gap.sm") }),
1748
+ /* @__PURE__ */ jsx(SelectItem, { value: "md", children: t("forms.studio.style.section.gap.md") }),
1749
+ /* @__PURE__ */ jsx(SelectItem, { value: "lg", children: t("forms.studio.style.section.gap.lg") })
1750
+ ] })
1751
+ ]
1752
+ }
1753
+ )
1754
+ ] }),
1755
+ /* @__PURE__ */ jsx(
1756
+ YesNoRow,
1757
+ {
1758
+ label: t("forms.studio.style.section.divider.label"),
1759
+ value: divider,
1760
+ onChange: (next) => onDividerChange(sectionKey, next)
1761
+ }
1762
+ ),
1763
+ /* @__PURE__ */ jsx(
1764
+ YesNoRow,
1765
+ {
1766
+ label: t("forms.studio.style.section.hideTitle.label"),
1767
+ value: hideTitle,
1768
+ onChange: (next) => onHideTitleChange(sectionKey, next)
1769
+ }
1770
+ )
1771
+ ] });
1772
+ }
1773
+ const SECTION_STYLE_NONE = "__none__";
1774
+ const SECTION_PADDING_OPTIONS = [
1775
+ { value: "none", fallback: "None" },
1776
+ { value: "xs", fallback: "XS" },
1777
+ { value: "sm", fallback: "Small" },
1778
+ { value: "md", fallback: "Medium" },
1779
+ { value: "lg", fallback: "Large" },
1780
+ { value: "xl", fallback: "XL" }
1781
+ ];
1782
+ const SECTION_BORDER_OPTIONS = [
1783
+ { value: "none", fallback: "None" },
1784
+ { value: "subtle", fallback: "Subtle" },
1785
+ { value: "strong", fallback: "Strong" }
1786
+ ];
1787
+ const SECTION_RADIUS_OPTIONS = [
1788
+ { value: "none", fallback: "None" },
1789
+ { value: "sm", fallback: "Small" },
1790
+ { value: "md", fallback: "Medium" },
1791
+ { value: "lg", fallback: "Large" },
1792
+ { value: "full", fallback: "Full" }
1793
+ ];
1794
+ const TEXT_ALIGN_OPTIONS = [
1795
+ { value: "start", fallback: "Start" },
1796
+ { value: "center", fallback: "Center" },
1797
+ { value: "end", fallback: "End" }
1798
+ ];
1799
+ const FIELD_LABEL_WEIGHT_OPTIONS = [
1800
+ { value: "normal", fallback: "Normal" },
1801
+ { value: "medium", fallback: "Medium" },
1802
+ { value: "semibold", fallback: "Semibold" },
1803
+ { value: "bold", fallback: "Bold" }
1804
+ ];
1805
+ function AppearanceEnumSelect({
1806
+ id,
1807
+ label,
1808
+ current,
1809
+ options,
1810
+ labelKeyPrefix,
1811
+ onPick,
1812
+ t
1813
+ }) {
1814
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
1815
+ /* @__PURE__ */ jsx("label", { htmlFor: id, className: "block text-xs font-medium text-foreground", children: label }),
1816
+ /* @__PURE__ */ jsxs(
1817
+ Select,
1818
+ {
1819
+ value: current ?? SECTION_STYLE_NONE,
1820
+ onValueChange: (next) => onPick(next === SECTION_STYLE_NONE ? void 0 : next),
1821
+ children: [
1822
+ /* @__PURE__ */ jsx(SelectTrigger, { id, className: "h-8", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
1823
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
1824
+ /* @__PURE__ */ jsx(SelectItem, { value: SECTION_STYLE_NONE, children: t("forms.studio.style.inherit", "Default") }),
1825
+ options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: t(`${labelKeyPrefix}.${option.value}`, option.fallback) }, option.value))
1826
+ ] })
1827
+ ]
1828
+ }
1829
+ )
1830
+ ] });
1831
+ }
1832
+ function SectionAppearanceTabContent({ style, onStyleChange, t }) {
1833
+ const patch = React.useCallback(
1834
+ (next) => {
1835
+ const merged = { ...style ?? {}, ...next };
1836
+ for (const key of Object.keys(merged)) {
1837
+ if (merged[key] === void 0) delete merged[key];
1838
+ }
1839
+ onStyleChange(Object.keys(merged).length === 0 ? void 0 : merged);
1840
+ },
1841
+ [style, onStyleChange]
1842
+ );
1843
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1844
+ /* @__PURE__ */ jsx(
1845
+ BackgroundControl,
1846
+ {
1847
+ label: t("forms.studio.style.section.background", "Background"),
1848
+ value: style?.background,
1849
+ onChange: (next) => patch({ background: next })
1850
+ }
1851
+ ),
1852
+ /* @__PURE__ */ jsx(
1853
+ ColorControl,
1854
+ {
1855
+ label: t("forms.studio.style.section.foreground", "Text"),
1856
+ value: style?.foreground,
1857
+ onChange: (next) => patch({ foreground: next }),
1858
+ contrastAgainst: style?.background?.kind === "color" ? style.background.color : void 0
1859
+ }
1860
+ ),
1861
+ /* @__PURE__ */ jsx(
1862
+ AppearanceEnumSelect,
1863
+ {
1864
+ id: "forms-studio-section-padding",
1865
+ label: t("forms.studio.style.section.padding", "Padding"),
1866
+ current: style?.padding,
1867
+ options: SECTION_PADDING_OPTIONS,
1868
+ labelKeyPrefix: "forms.studio.style.padding",
1869
+ onPick: (next) => patch({ padding: next }),
1870
+ t
1871
+ }
1872
+ ),
1873
+ /* @__PURE__ */ jsx(
1874
+ AppearanceEnumSelect,
1875
+ {
1876
+ id: "forms-studio-section-border",
1877
+ label: t("forms.studio.style.section.border", "Border"),
1878
+ current: style?.border,
1879
+ options: SECTION_BORDER_OPTIONS,
1880
+ labelKeyPrefix: "forms.studio.style.border",
1881
+ onPick: (next) => patch({ border: next }),
1882
+ t
1883
+ }
1884
+ ),
1885
+ /* @__PURE__ */ jsx(
1886
+ AppearanceEnumSelect,
1887
+ {
1888
+ id: "forms-studio-section-radius",
1889
+ label: t("forms.studio.style.section.radius", "Corner radius"),
1890
+ current: style?.radius,
1891
+ options: SECTION_RADIUS_OPTIONS,
1892
+ labelKeyPrefix: "forms.studio.style.radius",
1893
+ onPick: (next) => patch({ radius: next }),
1894
+ t
1895
+ }
1896
+ ),
1897
+ /* @__PURE__ */ jsx(
1898
+ YesNoRow,
1899
+ {
1900
+ label: t("forms.studio.style.section.card", "Card"),
1901
+ value: style?.card === true,
1902
+ onChange: (next) => patch({ card: next ? true : void 0 })
1903
+ }
1904
+ ),
1905
+ /* @__PURE__ */ jsx(
1906
+ AppearanceEnumSelect,
1907
+ {
1908
+ id: "forms-studio-section-align",
1909
+ label: t("forms.studio.style.section.align", "Alignment"),
1910
+ current: style?.align,
1911
+ options: TEXT_ALIGN_OPTIONS,
1912
+ labelKeyPrefix: "forms.studio.style.align",
1913
+ onPick: (next) => patch({ align: next }),
1914
+ t
1915
+ }
1916
+ )
1917
+ ] });
1918
+ }
1919
+ function FieldAppearanceTabContent({ style, onStyleChange, formSurface, t }) {
1920
+ const patch = React.useCallback(
1921
+ (next) => {
1922
+ const merged = { ...style ?? {}, ...next };
1923
+ for (const key of Object.keys(merged)) {
1924
+ if (merged[key] === void 0) delete merged[key];
1925
+ }
1926
+ onStyleChange(Object.keys(merged).length === 0 ? void 0 : merged);
1927
+ },
1928
+ [style, onStyleChange]
1929
+ );
1930
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1931
+ /* @__PURE__ */ jsx(
1932
+ AppearanceEnumSelect,
1933
+ {
1934
+ id: "forms-studio-field-label-weight",
1935
+ label: t("forms.studio.style.field.labelWeight", "Label weight"),
1936
+ current: style?.labelWeight,
1937
+ options: FIELD_LABEL_WEIGHT_OPTIONS,
1938
+ labelKeyPrefix: "forms.studio.style.weight",
1939
+ onPick: (next) => patch({ labelWeight: next }),
1940
+ t
1941
+ }
1942
+ ),
1943
+ /* @__PURE__ */ jsx(
1944
+ ColorControl,
1945
+ {
1946
+ label: t("forms.studio.style.field.labelColor", "Label color"),
1947
+ value: style?.labelColor,
1948
+ onChange: (next) => patch({ labelColor: next }),
1949
+ contrastAgainst: formSurface
1950
+ }
1951
+ ),
1952
+ /* @__PURE__ */ jsx(
1953
+ ColorControl,
1954
+ {
1955
+ label: t("forms.studio.style.field.textColor", "Text color"),
1956
+ value: style?.textColor,
1957
+ onChange: (next) => patch({ textColor: next }),
1958
+ contrastAgainst: formSurface
1959
+ }
1960
+ ),
1961
+ /* @__PURE__ */ jsx(
1962
+ ColorControl,
1963
+ {
1964
+ label: t("forms.studio.style.field.accent", "Accent"),
1965
+ value: style?.accent,
1966
+ onChange: (next) => patch({ accent: next })
1967
+ }
1968
+ ),
1969
+ /* @__PURE__ */ jsx(
1970
+ AppearanceEnumSelect,
1971
+ {
1972
+ id: "forms-studio-field-align",
1973
+ label: t("forms.studio.style.field.appearanceAlign", "Alignment"),
1974
+ current: style?.align,
1975
+ options: TEXT_ALIGN_OPTIONS,
1976
+ labelKeyPrefix: "forms.studio.style.align",
1977
+ onPick: (next) => patch({ align: next }),
1978
+ t
1979
+ }
1980
+ )
1981
+ ] });
1982
+ }
1983
+ function findOwningSection(schema, fieldKey) {
1984
+ const sections = schema["x-om-sections"] ?? [];
1985
+ for (const section of sections) {
1986
+ if (section.fieldKeys.includes(fieldKey)) return section;
1987
+ }
1988
+ return null;
1989
+ }
1990
+ function FieldPropertiesPanel({
1991
+ schema,
1992
+ fieldKey,
1993
+ node,
1994
+ declaredRoles,
1995
+ required,
1996
+ activeLocale,
1997
+ onUpdate,
1998
+ onRequiredChange,
1999
+ onDelete,
2000
+ onGridSpanChange,
2001
+ onAlignChange,
2002
+ onHideMobileChange,
2003
+ onStyleChange,
2004
+ onTypeSwap,
2005
+ onVisibilityChange,
2006
+ t
2007
+ }) {
2008
+ const [tab, setTab] = React.useState("field");
2009
+ const sourceOptions = React.useMemo(
2010
+ () => buildFieldSourceOptions(schema, activeLocale, t).filter((entry) => entry.value !== fieldKey),
2011
+ [schema, activeLocale, t, fieldKey]
2012
+ );
2013
+ const visibilityPredicate = node["x-om-visibility-if"] ?? null;
2014
+ const owningSection = findOwningSection(schema, fieldKey);
2015
+ const sectionColumns = owningSection?.columns ?? 1;
2016
+ const omType = String(node["x-om-type"] ?? "text");
2017
+ const isInfoBlock = omType === "info_block";
2018
+ const persistedSpanRaw = node["x-om-grid-span"];
2019
+ const persistedSpan = persistedSpanRaw === 2 || persistedSpanRaw === 3 || persistedSpanRaw === 4 ? persistedSpanRaw : 1;
2020
+ const align = node["x-om-align"] === "center" || node["x-om-align"] === "end" ? node["x-om-align"] : "start";
2021
+ const hideMobile = node["x-om-hide-mobile"] === true;
2022
+ const widthOptions = React.useMemo(() => {
2023
+ const max = sectionColumns;
2024
+ const options = [];
2025
+ for (let i = 1; i <= max; i += 1) options.push(i);
2026
+ return options;
2027
+ }, [sectionColumns]);
2028
+ const showWidth = !isInfoBlock && sectionColumns > 1;
2029
+ const swapFamily = SWAP_FAMILIES[omType];
2030
+ const swapTargets = swapFamily ? Array.from(swapFamily) : null;
2031
+ return /* @__PURE__ */ jsxs(Tabs, { value: tab, onValueChange: (next) => setTab(next), children: [
2032
+ /* @__PURE__ */ jsxs(TabsList, { className: "w-full justify-stretch", children: [
2033
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "field", className: "flex-1", children: t("forms.studio.style.tabs.field") }),
2034
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "style", className: "flex-1", children: t("forms.studio.style.tabs.style") }),
2035
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "appearance", className: "flex-1", children: t("forms.studio.style.tabs.appearance", "Appearance") }),
2036
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "logic", className: "flex-1", children: t("forms.studio.logic.tab.label") })
2037
+ ] }),
2038
+ /* @__PURE__ */ jsx(TabsContent, { value: "field", children: /* @__PURE__ */ jsx(
2039
+ FieldTabContent,
2040
+ {
2041
+ fieldKey,
2042
+ node,
2043
+ declaredRoles,
2044
+ required,
2045
+ activeLocale,
2046
+ onUpdate,
2047
+ onRequiredChange,
2048
+ onDelete,
2049
+ onTypeSwap,
2050
+ omType,
2051
+ swapTargets,
2052
+ t
2053
+ }
2054
+ ) }),
2055
+ /* @__PURE__ */ jsx(TabsContent, { value: "style", children: /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
2056
+ showWidth ? /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
2057
+ /* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.style.field.width.label") }),
2058
+ /* @__PURE__ */ jsxs(
2059
+ Select,
2060
+ {
2061
+ value: String(Math.min(persistedSpan, sectionColumns)),
2062
+ onValueChange: (next) => onGridSpanChange(fieldKey, Number(next)),
2063
+ children: [
2064
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2065
+ /* @__PURE__ */ jsx(SelectContent, { children: widthOptions.map((value) => /* @__PURE__ */ jsx(SelectItem, { value: String(value), children: value }, value)) })
2066
+ ]
2067
+ }
2068
+ )
2069
+ ] }) : null,
2070
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
2071
+ /* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.style.field.align.label") }),
2072
+ /* @__PURE__ */ jsxs(
2073
+ Select,
2074
+ {
2075
+ value: align,
2076
+ onValueChange: (next) => onAlignChange(fieldKey, next),
2077
+ children: [
2078
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2079
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
2080
+ /* @__PURE__ */ jsx(SelectItem, { value: "start", children: t("forms.studio.style.field.align.start") }),
2081
+ /* @__PURE__ */ jsx(SelectItem, { value: "center", children: t("forms.studio.style.field.align.center") }),
2082
+ /* @__PURE__ */ jsx(SelectItem, { value: "end", children: t("forms.studio.style.field.align.end") })
2083
+ ] })
2084
+ ]
2085
+ }
2086
+ )
2087
+ ] }),
2088
+ /* @__PURE__ */ jsx(
2089
+ YesNoRow,
2090
+ {
2091
+ label: t("forms.studio.style.field.hideMobile.label"),
2092
+ value: hideMobile,
2093
+ onChange: (next) => onHideMobileChange(fieldKey, next)
2094
+ }
2095
+ )
2096
+ ] }) }),
2097
+ /* @__PURE__ */ jsx(TabsContent, { value: "appearance", children: /* @__PURE__ */ jsx(
2098
+ FieldAppearanceTabContent,
2099
+ {
2100
+ style: node["x-om-style"],
2101
+ onStyleChange: (next) => onStyleChange(fieldKey, next),
2102
+ formSurface: resolveFormTheme(schema)?.surface ?? "surface",
2103
+ t
2104
+ }
2105
+ ) }),
2106
+ /* @__PURE__ */ jsx(TabsContent, { value: "logic", children: /* @__PURE__ */ jsx(
2107
+ ConditionBuilder,
2108
+ {
2109
+ predicate: visibilityPredicate,
2110
+ sources: sourceOptions,
2111
+ onChange: (next) => onVisibilityChange(fieldKey, next)
2112
+ }
2113
+ ) })
2114
+ ] });
2115
+ }
2116
+ function RoleCheckboxList({
2117
+ legend,
2118
+ selected,
2119
+ options,
2120
+ onToggle
2121
+ }) {
2122
+ return /* @__PURE__ */ jsxs("div", { children: [
2123
+ /* @__PURE__ */ jsx("span", { className: "block text-xs font-medium text-muted-foreground", children: legend }),
2124
+ /* @__PURE__ */ jsx("div", { className: "mt-1 space-y-1", children: options.map((role) => /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
2125
+ /* @__PURE__ */ jsx(
2126
+ Checkbox,
2127
+ {
2128
+ checked: selected.includes(role),
2129
+ onCheckedChange: (value) => onToggle(role, Boolean(value))
2130
+ }
2131
+ ),
2132
+ role
2133
+ ] }, role)) })
2134
+ ] });
2135
+ }
2136
+ function FieldTabContent({
2137
+ fieldKey,
2138
+ node,
2139
+ declaredRoles,
2140
+ required,
2141
+ activeLocale,
2142
+ onUpdate,
2143
+ onRequiredChange,
2144
+ onDelete,
2145
+ onTypeSwap,
2146
+ omType,
2147
+ swapTargets,
2148
+ t
2149
+ }) {
2150
+ const label = node["x-om-label"]?.[activeLocale] ?? "";
2151
+ const help = node["x-om-help"]?.[activeLocale] ?? "";
2152
+ const editableBy = node["x-om-editable-by"] ?? ["admin"];
2153
+ const visibleTo = node["x-om-visible-to"] ?? [];
2154
+ const sensitive = node["x-om-sensitive"] === true;
2155
+ const roleOptions = React.useMemo(() => {
2156
+ const set = /* @__PURE__ */ new Set(["admin"]);
2157
+ for (const role of declaredRoles) set.add(role);
2158
+ return Array.from(set);
2159
+ }, [declaredRoles]);
2160
+ const toggleRole = React.useCallback(
2161
+ (keyword, fallback, role, checked) => {
2162
+ onUpdate((current) => {
2163
+ const next = new Set(current[keyword] ?? fallback);
2164
+ if (checked) next.add(role);
2165
+ else next.delete(role);
2166
+ return { ...current, [keyword]: Array.from(next) };
2167
+ });
2168
+ },
2169
+ [onUpdate]
2170
+ );
2171
+ const handlePatternChange = React.useCallback(
2172
+ (next) => {
2173
+ onUpdate((current) => {
2174
+ const updated = { ...current };
2175
+ if (next === null || next.length === 0) {
2176
+ delete updated["x-om-pattern"];
2177
+ } else {
2178
+ updated["x-om-pattern"] = next;
2179
+ }
2180
+ return updated;
2181
+ });
2182
+ },
2183
+ [onUpdate]
2184
+ );
2185
+ const handleLengthRangeChange = React.useCallback(
2186
+ (patch) => {
2187
+ onUpdate((current) => {
2188
+ const updated = { ...current };
2189
+ if (patch.min !== void 0) {
2190
+ if (patch.min === null) delete updated["x-om-min-length"];
2191
+ else updated["x-om-min-length"] = patch.min;
2192
+ }
2193
+ if (patch.max !== void 0) {
2194
+ if (patch.max === null) delete updated["x-om-max-length"];
2195
+ else updated["x-om-max-length"] = patch.max;
2196
+ }
2197
+ return updated;
2198
+ });
2199
+ },
2200
+ [onUpdate]
2201
+ );
2202
+ const handleNumberRangeChange = React.useCallback(
2203
+ (patch) => {
2204
+ onUpdate((current) => {
2205
+ const updated = { ...current };
2206
+ if (patch.min !== void 0) {
2207
+ if (patch.min === null) delete updated["x-om-min"];
2208
+ else updated["x-om-min"] = patch.min;
2209
+ }
2210
+ if (patch.max !== void 0) {
2211
+ if (patch.max === null) delete updated["x-om-max"];
2212
+ else updated["x-om-max"] = patch.max;
2213
+ }
2214
+ return updated;
2215
+ });
2216
+ },
2217
+ [onUpdate]
2218
+ );
2219
+ const handleMessageChange = React.useCallback(
2220
+ (patch) => {
2221
+ onUpdate((current) => {
2222
+ const updated = { ...current };
2223
+ const existing = current["x-om-validation-messages"];
2224
+ const cloned = existing && typeof existing === "object" && !Array.isArray(existing) ? Object.fromEntries(
2225
+ Object.entries(existing).map(([loc, inner2]) => [
2226
+ loc,
2227
+ inner2 && typeof inner2 === "object" && !Array.isArray(inner2) ? { ...inner2 } : {}
2228
+ ])
2229
+ ) : {};
2230
+ const inner = cloned[activeLocale] ? { ...cloned[activeLocale] } : {};
2231
+ const trimmed = typeof patch.message === "string" ? patch.message : "";
2232
+ if (!trimmed) {
2233
+ delete inner[patch.rule];
2234
+ } else {
2235
+ inner[patch.rule] = trimmed;
2236
+ }
2237
+ if (Object.keys(inner).length === 0) {
2238
+ delete cloned[activeLocale];
2239
+ } else {
2240
+ cloned[activeLocale] = inner;
2241
+ }
2242
+ if (Object.keys(cloned).length === 0) {
2243
+ delete updated["x-om-validation-messages"];
2244
+ } else {
2245
+ updated["x-om-validation-messages"] = cloned;
2246
+ }
2247
+ return updated;
2248
+ });
2249
+ },
2250
+ [onUpdate, activeLocale]
2251
+ );
2252
+ const handleRankingExhaustiveChange = React.useCallback(
2253
+ (next) => {
2254
+ onUpdate((current) => {
2255
+ const updated = { ...current };
2256
+ if (next === false) {
2257
+ delete updated["x-om-ranking-exhaustive"];
2258
+ } else {
2259
+ updated["x-om-ranking-exhaustive"] = true;
2260
+ }
2261
+ return updated;
2262
+ });
2263
+ },
2264
+ [onUpdate]
2265
+ );
2266
+ const handleOpinionIconChange = React.useCallback(
2267
+ (next) => {
2268
+ onUpdate((current) => {
2269
+ const updated = { ...current };
2270
+ if (next === "dot") {
2271
+ delete updated["x-om-opinion-icon"];
2272
+ } else {
2273
+ updated["x-om-opinion-icon"] = next;
2274
+ }
2275
+ return updated;
2276
+ });
2277
+ },
2278
+ [onUpdate]
2279
+ );
2280
+ const handleNpsAnchorChange = React.useCallback(
2281
+ (patch) => {
2282
+ onUpdate((current) => {
2283
+ const updated = { ...current };
2284
+ const existing = current["x-om-nps-anchors"];
2285
+ const sourceLow = existing && typeof existing === "object" && !Array.isArray(existing) && existing.low && typeof existing.low === "object" ? { ...existing.low } : {};
2286
+ const sourceHigh = existing && typeof existing === "object" && !Array.isArray(existing) && existing.high && typeof existing.high === "object" ? { ...existing.high } : {};
2287
+ const map = {
2288
+ low: sourceLow,
2289
+ high: sourceHigh
2290
+ };
2291
+ const target = map[patch.anchor];
2292
+ const trimmed = typeof patch.label === "string" ? patch.label : "";
2293
+ if (!trimmed) {
2294
+ delete target[activeLocale];
2295
+ } else {
2296
+ target[activeLocale] = trimmed;
2297
+ }
2298
+ const hasLow = Object.keys(map.low).length > 0;
2299
+ const hasHigh = Object.keys(map.high).length > 0;
2300
+ if (!hasLow && !hasHigh) {
2301
+ delete updated["x-om-nps-anchors"];
2302
+ } else {
2303
+ updated["x-om-nps-anchors"] = { low: map.low, high: map.high };
2304
+ }
2305
+ return updated;
2306
+ });
2307
+ },
2308
+ [onUpdate, activeLocale]
2309
+ );
2310
+ const handleMatrixRowsChange = React.useCallback(
2311
+ (next) => {
2312
+ onUpdate((current) => {
2313
+ const updated = { ...current };
2314
+ if (!next || next.length === 0) {
2315
+ delete updated["x-om-matrix-rows"];
2316
+ } else {
2317
+ updated["x-om-matrix-rows"] = next.map((row) => {
2318
+ const result = { key: row.key, label: row.label };
2319
+ if (row.multiple === true) result.multiple = true;
2320
+ if (row.required === true) result.required = true;
2321
+ return result;
2322
+ });
2323
+ }
2324
+ return updated;
2325
+ });
2326
+ },
2327
+ [onUpdate]
2328
+ );
2329
+ const handleMatrixColumnsChange = React.useCallback(
2330
+ (next) => {
2331
+ onUpdate((current) => {
2332
+ const updated = { ...current };
2333
+ if (!next || next.length === 0) {
2334
+ delete updated["x-om-matrix-columns"];
2335
+ } else {
2336
+ updated["x-om-matrix-columns"] = next.map((column) => ({
2337
+ value: column.value,
2338
+ label: column.label
2339
+ }));
2340
+ }
2341
+ return updated;
2342
+ });
2343
+ },
2344
+ [onUpdate]
2345
+ );
2346
+ const handleFileAcceptChange = React.useCallback(
2347
+ (next) => {
2348
+ onUpdate((current) => {
2349
+ const updated = { ...current };
2350
+ if (!next || next.length === 0) {
2351
+ delete updated["x-om-accept"];
2352
+ } else {
2353
+ updated["x-om-accept"] = next;
2354
+ }
2355
+ return updated;
2356
+ });
2357
+ },
2358
+ [onUpdate]
2359
+ );
2360
+ const handleFileMaxSizeChange = React.useCallback(
2361
+ (next) => {
2362
+ onUpdate((current) => {
2363
+ const updated = { ...current };
2364
+ if (next === null) {
2365
+ delete updated["x-om-max-size-bytes"];
2366
+ } else {
2367
+ updated["x-om-max-size-bytes"] = next;
2368
+ }
2369
+ return updated;
2370
+ });
2371
+ },
2372
+ [onUpdate]
2373
+ );
2374
+ const handleFileMultipleChange = React.useCallback(
2375
+ (next) => {
2376
+ onUpdate((current) => {
2377
+ const updated = { ...current };
2378
+ if (next) {
2379
+ updated["x-om-multiple"] = true;
2380
+ } else {
2381
+ delete updated["x-om-multiple"];
2382
+ }
2383
+ return updated;
2384
+ });
2385
+ },
2386
+ [onUpdate]
2387
+ );
2388
+ const handleSignatureClauseChange = React.useCallback(
2389
+ (next) => {
2390
+ onUpdate((current) => {
2391
+ const updated = { ...current };
2392
+ const clause = { ...updated["x-om-consent-clause"] ?? {} };
2393
+ if (next === null) {
2394
+ delete clause[activeLocale];
2395
+ } else {
2396
+ clause[activeLocale] = next;
2397
+ }
2398
+ if (Object.keys(clause).length === 0) {
2399
+ delete updated["x-om-consent-clause"];
2400
+ } else {
2401
+ updated["x-om-consent-clause"] = clause;
2402
+ }
2403
+ return updated;
2404
+ });
2405
+ },
2406
+ [onUpdate, activeLocale]
2407
+ );
2408
+ const handleSignatureModesChange = React.useCallback(
2409
+ (next) => {
2410
+ onUpdate((current) => {
2411
+ const updated = { ...current };
2412
+ if (next.length === 0 || next.includes("drawn") && next.includes("typed")) {
2413
+ delete updated["x-om-signature-modes"];
2414
+ } else {
2415
+ updated["x-om-signature-modes"] = next;
2416
+ }
2417
+ return updated;
2418
+ });
2419
+ },
2420
+ [onUpdate]
2421
+ );
2422
+ const handleOptionsChange = React.useCallback(
2423
+ (next) => {
2424
+ onUpdate((current) => {
2425
+ const updated = { ...current };
2426
+ updated["x-om-options"] = next.map((option) => ({
2427
+ value: option.value,
2428
+ label: option.label
2429
+ }));
2430
+ return updated;
2431
+ });
2432
+ },
2433
+ [onUpdate]
2434
+ );
2435
+ const handleGroupAddSubField = React.useCallback(() => {
2436
+ onUpdate((current) => groupNodeAddSubField(current, { [activeLocale]: "New sub-field" }));
2437
+ }, [onUpdate, activeLocale]);
2438
+ const handleGroupRemoveSubField = React.useCallback(
2439
+ (subFieldKey) => {
2440
+ onUpdate((current) => groupNodeRemoveSubField(current, subFieldKey));
2441
+ },
2442
+ [onUpdate]
2443
+ );
2444
+ const handleGroupUpdateSubField = React.useCallback(
2445
+ (subFieldKey, patch) => {
2446
+ onUpdate((current) => {
2447
+ const nodePatch = {};
2448
+ if (patch.label !== void 0) {
2449
+ const existingLabel = current.items?.properties?.[subFieldKey]?.["x-om-label"] ?? {};
2450
+ nodePatch.label = { ...existingLabel, [activeLocale]: patch.label };
2451
+ }
2452
+ if (patch.type !== void 0) nodePatch.type = patch.type;
2453
+ if (patch.required !== void 0) nodePatch.required = patch.required;
2454
+ return groupNodeUpdateSubField(current, subFieldKey, nodePatch);
2455
+ });
2456
+ },
2457
+ [onUpdate, activeLocale]
2458
+ );
2459
+ const handleGroupMinItemsChange = React.useCallback(
2460
+ (next) => {
2461
+ onUpdate((current) => {
2462
+ const updated = { ...current };
2463
+ if (next === null) delete updated["x-om-min-items"];
2464
+ else updated["x-om-min-items"] = next;
2465
+ return updated;
2466
+ });
2467
+ },
2468
+ [onUpdate]
2469
+ );
2470
+ const handleGroupMaxItemsChange = React.useCallback(
2471
+ (next) => {
2472
+ onUpdate((current) => {
2473
+ const updated = { ...current };
2474
+ if (next === null || next < 1) delete updated["x-om-max-items"];
2475
+ else updated["x-om-max-items"] = next;
2476
+ return updated;
2477
+ });
2478
+ },
2479
+ [onUpdate]
2480
+ );
2481
+ const groupTypeOptions = React.useMemo(
2482
+ () => defaultFieldTypeRegistry.keys().filter((key) => key !== "group" && key !== "info_block").map((key) => ({ value: key, label: resolveTypeLabel(key, t) })),
2483
+ [t]
2484
+ );
2485
+ const showOptionsEditor = omType === "select_one" || omType === "select_many" || omType === "ranking";
2486
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
2487
+ /* @__PURE__ */ jsxs("div", { children: [
2488
+ /* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.field.type.label") }),
2489
+ swapTargets && swapTargets.length > 1 ? /* @__PURE__ */ jsxs(
2490
+ Select,
2491
+ {
2492
+ value: omType,
2493
+ onValueChange: (next) => {
2494
+ if (next !== omType && isCompatibleFieldSwap(omType, next)) {
2495
+ onTypeSwap(fieldKey, next);
2496
+ }
2497
+ },
2498
+ children: [
2499
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2500
+ /* @__PURE__ */ jsx(SelectContent, { children: swapTargets.map((value) => /* @__PURE__ */ jsx(SelectItem, { value, children: resolveTypeLabel(value, t) }, value)) })
2501
+ ]
2502
+ }
2503
+ ) : /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: resolveTypeLabel(omType, t) }),
2504
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("forms.studio.field.type.swapHint") })
2505
+ ] }),
2506
+ /* @__PURE__ */ jsxs("div", { children: [
2507
+ /* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.fields.label") }),
2508
+ /* @__PURE__ */ jsx(
2509
+ Input,
2510
+ {
2511
+ value: label,
2512
+ onChange: (event) => onUpdate((current) => ({
2513
+ ...current,
2514
+ "x-om-label": { ...current["x-om-label"] ?? {}, [activeLocale]: event.target.value }
2515
+ }))
2516
+ }
2517
+ )
2518
+ ] }),
2519
+ /* @__PURE__ */ jsxs("div", { children: [
2520
+ /* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.fields.help") }),
2521
+ /* @__PURE__ */ jsx(
2522
+ Textarea,
2523
+ {
2524
+ rows: 2,
2525
+ value: help,
2526
+ onChange: (event) => onUpdate((current) => ({
2527
+ ...current,
2528
+ "x-om-help": { ...current["x-om-help"] ?? {}, [activeLocale]: event.target.value }
2529
+ }))
2530
+ }
2531
+ )
2532
+ ] }),
2533
+ /* @__PURE__ */ jsx(
2534
+ RoleCheckboxList,
2535
+ {
2536
+ legend: t("forms.studio.fields.editableBy"),
2537
+ selected: editableBy,
2538
+ options: roleOptions,
2539
+ onToggle: (role, checked) => toggleRole("x-om-editable-by", ["admin"], role, checked)
2540
+ }
2541
+ ),
2542
+ /* @__PURE__ */ jsx(
2543
+ RoleCheckboxList,
2544
+ {
2545
+ legend: t("forms.studio.fields.visibleTo"),
2546
+ selected: visibleTo,
2547
+ options: roleOptions,
2548
+ onToggle: (role, checked) => toggleRole("x-om-visible-to", [], role, checked)
2549
+ }
2550
+ ),
2551
+ /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
2552
+ /* @__PURE__ */ jsx(Checkbox, { checked: required, onCheckedChange: (value) => onRequiredChange(Boolean(value)) }),
2553
+ t("forms.studio.fields.required")
2554
+ ] }),
2555
+ /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
2556
+ /* @__PURE__ */ jsx(
2557
+ Checkbox,
2558
+ {
2559
+ checked: sensitive,
2560
+ onCheckedChange: (value) => onUpdate((current) => ({ ...current, "x-om-sensitive": Boolean(value) }))
2561
+ }
2562
+ ),
2563
+ t("forms.studio.fields.sensitive")
2564
+ ] }),
2565
+ /* @__PURE__ */ jsx(
2566
+ ValidationPanel,
2567
+ {
2568
+ fieldKey,
2569
+ fieldType: omType,
2570
+ node,
2571
+ locale: activeLocale,
2572
+ onPatternChange: handlePatternChange,
2573
+ onLengthRangeChange: handleLengthRangeChange,
2574
+ onNumberRangeChange: handleNumberRangeChange,
2575
+ onMessageChange: handleMessageChange,
2576
+ onOpinionIconChange: handleOpinionIconChange,
2577
+ onNpsAnchorChange: handleNpsAnchorChange,
2578
+ onRankingExhaustiveChange: handleRankingExhaustiveChange,
2579
+ onMatrixRowsChange: handleMatrixRowsChange,
2580
+ onMatrixColumnsChange: handleMatrixColumnsChange,
2581
+ onFileAcceptChange: handleFileAcceptChange,
2582
+ onFileMaxSizeChange: handleFileMaxSizeChange,
2583
+ onFileMultipleChange: handleFileMultipleChange,
2584
+ onSignatureClauseChange: handleSignatureClauseChange,
2585
+ onSignatureModesChange: handleSignatureModesChange,
2586
+ groupTypeOptions,
2587
+ onGroupAddSubField: handleGroupAddSubField,
2588
+ onGroupRemoveSubField: handleGroupRemoveSubField,
2589
+ onGroupUpdateSubField: handleGroupUpdateSubField,
2590
+ onGroupMinItemsChange: handleGroupMinItemsChange,
2591
+ onGroupMaxItemsChange: handleGroupMaxItemsChange
2592
+ }
2593
+ ),
2594
+ showOptionsEditor ? /* @__PURE__ */ jsx(
2595
+ OptionsEditor,
2596
+ {
2597
+ options: readFieldOptions(node),
2598
+ activeLocale,
2599
+ onChange: handleOptionsChange,
2600
+ t
2601
+ }
2602
+ ) : null,
2603
+ /* @__PURE__ */ jsxs(Button, { type: "button", variant: "destructive-outline", onClick: onDelete, children: [
2604
+ /* @__PURE__ */ jsx(Trash2, { className: "size-4", "aria-hidden": "true" }),
2605
+ t("forms.studio.fields.deleteButton")
2606
+ ] })
2607
+ ] });
2608
+ }
2609
+ function readFieldOptions(node) {
2610
+ const raw = node["x-om-options"];
2611
+ if (!Array.isArray(raw)) return [];
2612
+ return raw.filter(
2613
+ (entry) => Boolean(entry) && typeof entry === "object" && typeof entry.value === "string"
2614
+ ).map((entry) => ({
2615
+ value: entry.value,
2616
+ label: entry.label && typeof entry.label === "object" && !Array.isArray(entry.label) ? { ...entry.label } : { en: entry.value }
2617
+ }));
2618
+ }
2619
+ function slugOptionValue(label, fallback) {
2620
+ const slug = label.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
2621
+ return slug || fallback;
2622
+ }
2623
+ function nextOptionValue(options) {
2624
+ const used = new Set(options.map((option) => option.value));
2625
+ let index = options.length + 1;
2626
+ let candidate = `option_${index}`;
2627
+ while (used.has(candidate)) {
2628
+ index += 1;
2629
+ candidate = `option_${index}`;
2630
+ }
2631
+ return candidate;
2632
+ }
2633
+ function moveArrayItem(items, from, to) {
2634
+ const next = [...items];
2635
+ const [item] = next.splice(from, 1);
2636
+ if (!item) return items;
2637
+ next.splice(to, 0, item);
2638
+ return next;
2639
+ }
2640
+ function OptionsEditor({
2641
+ options,
2642
+ activeLocale,
2643
+ onChange,
2644
+ t
2645
+ }) {
2646
+ const addOption = React.useCallback(() => {
2647
+ const value = nextOptionValue(options);
2648
+ onChange([...options, { value, label: { [activeLocale]: t("forms.studio.field.options.defaultLabel", { n: String(options.length + 1) }) } }]);
2649
+ }, [onChange, options, t, activeLocale]);
2650
+ const updateOption = React.useCallback((index, patch) => {
2651
+ onChange(options.map((option, optionIndex) => {
2652
+ if (optionIndex !== index) return option;
2653
+ return {
2654
+ ...option,
2655
+ ...patch,
2656
+ label: patch.label ?? option.label
2657
+ };
2658
+ }));
2659
+ }, [onChange, options]);
2660
+ return /* @__PURE__ */ jsxs("section", { className: "space-y-2 rounded-md border border-border bg-muted/20 p-3", children: [
2661
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
2662
+ /* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold uppercase text-muted-foreground", children: t("forms.studio.field.options.heading") }),
2663
+ /* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: addOption, children: [
2664
+ /* @__PURE__ */ jsx(Plus, { className: "size-4", "aria-hidden": "true" }),
2665
+ t("forms.studio.field.options.add")
2666
+ ] })
2667
+ ] }),
2668
+ options.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("forms.studio.field.options.empty") }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: options.map((option, index) => {
2669
+ const label = option.label[activeLocale] ?? "";
2670
+ return /* @__PURE__ */ jsx("div", { className: "rounded-md border border-border bg-background p-2", children: /* @__PURE__ */ jsxs("div", { className: "grid gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]", children: [
2671
+ /* @__PURE__ */ jsxs("label", { className: "space-y-1", children: [
2672
+ /* @__PURE__ */ jsx("span", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.field.options.label") }),
2673
+ /* @__PURE__ */ jsx(
2674
+ Input,
2675
+ {
2676
+ value: label,
2677
+ onChange: (event) => {
2678
+ const nextLabel = event.target.value;
2679
+ const currentValue = option.value;
2680
+ const generatedValue = slugOptionValue(nextLabel, currentValue || `option_${index + 1}`);
2681
+ updateOption(index, {
2682
+ value: currentValue.startsWith("option_") ? generatedValue : currentValue,
2683
+ label: { ...option.label, [activeLocale]: nextLabel }
2684
+ });
2685
+ }
2686
+ }
2687
+ )
2688
+ ] }),
2689
+ /* @__PURE__ */ jsxs("label", { className: "space-y-1", children: [
2690
+ /* @__PURE__ */ jsx("span", { className: "block text-xs font-medium text-muted-foreground", children: t("forms.studio.field.options.value") }),
2691
+ /* @__PURE__ */ jsx(
2692
+ Input,
2693
+ {
2694
+ value: option.value,
2695
+ onChange: (event) => updateOption(index, {
2696
+ value: slugOptionValue(event.target.value, `option_${index + 1}`)
2697
+ })
2698
+ }
2699
+ )
2700
+ ] }),
2701
+ /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-1", children: [
2702
+ /* @__PURE__ */ jsx(
2703
+ IconButton,
2704
+ {
2705
+ type: "button",
2706
+ variant: "ghost",
2707
+ size: "sm",
2708
+ disabled: index === 0,
2709
+ "aria-label": t("forms.studio.field.options.moveUp"),
2710
+ onClick: () => onChange(moveArrayItem(options, index, index - 1)),
2711
+ children: /* @__PURE__ */ jsx(ArrowUp, { className: "size-4", "aria-hidden": "true" })
2712
+ }
2713
+ ),
2714
+ /* @__PURE__ */ jsx(
2715
+ IconButton,
2716
+ {
2717
+ type: "button",
2718
+ variant: "ghost",
2719
+ size: "sm",
2720
+ disabled: index >= options.length - 1,
2721
+ "aria-label": t("forms.studio.field.options.moveDown"),
2722
+ onClick: () => onChange(moveArrayItem(options, index, index + 1)),
2723
+ children: /* @__PURE__ */ jsx(ArrowDown, { className: "size-4", "aria-hidden": "true" })
2724
+ }
2725
+ ),
2726
+ /* @__PURE__ */ jsx(
2727
+ IconButton,
2728
+ {
2729
+ type: "button",
2730
+ variant: "ghost",
2731
+ size: "sm",
2732
+ "aria-label": t("forms.studio.field.options.delete"),
2733
+ onClick: () => onChange(options.filter((_, optionIndex) => optionIndex !== index)),
2734
+ children: /* @__PURE__ */ jsx(Trash2, { className: "size-4", "aria-hidden": "true" })
2735
+ }
2736
+ )
2737
+ ] })
2738
+ ] }) }, `${option.value}:${index}`);
2739
+ }) })
2740
+ ] });
2741
+ }
2742
+ function PublishDialog({ formId, versionId, updatedAt, onClose, onPublished, t }) {
2743
+ const [changelog, setChangelog] = React.useState("");
2744
+ const [busy, setBusy] = React.useState(false);
2745
+ const { runMutation } = useGuardedMutation({ contextId: "forms.form.publish" });
2746
+ const submit = React.useCallback(async () => {
2747
+ if (busy) return;
2748
+ setBusy(true);
2749
+ const call = await runMutation({
2750
+ operation: () => withScopedApiRequestHeaders(
2751
+ buildOptimisticLockHeader(updatedAt),
2752
+ () => apiCall(
2753
+ `/api/forms/${encodeURIComponent(formId)}/versions/${encodeURIComponent(versionId)}/publish`,
2754
+ {
2755
+ method: "POST",
2756
+ body: JSON.stringify({ changelog: changelog.trim() || null })
2757
+ }
2758
+ )
2759
+ ),
2760
+ context: { formId, versionId },
2761
+ mutationPayload: { formId, versionId }
2762
+ });
2763
+ setBusy(false);
2764
+ if (!call.ok) {
2765
+ if (surfaceRecordConflict({ status: call.status, body: call.result }, t)) return;
2766
+ const errPayload = call.result;
2767
+ flash(t(errPayload?.error ?? "forms.errors.internal"), "error");
2768
+ return;
2769
+ }
2770
+ onPublished();
2771
+ }, [busy, changelog, formId, onPublished, runMutation, t, updatedAt, versionId]);
2772
+ return /* @__PURE__ */ jsx(Dialog, { open: true, onOpenChange: (open) => {
2773
+ if (!open) onClose();
2774
+ }, children: /* @__PURE__ */ jsxs(
2775
+ DialogContent,
2776
+ {
2777
+ onKeyDown: (event) => {
2778
+ if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
2779
+ event.preventDefault();
2780
+ void submit();
2781
+ }
2782
+ },
2783
+ children: [
2784
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("forms.version.publish.title") }) }),
2785
+ /* @__PURE__ */ jsx(Alert, { status: "warning", style: "light", children: t("forms.version.publish.reassurance") }),
2786
+ /* @__PURE__ */ jsxs("div", { children: [
2787
+ /* @__PURE__ */ jsx(Label, { htmlFor: "forms-publish-changelog", className: "mb-1 block text-sm font-medium", children: t("forms.version.publish.changelog") }),
2788
+ /* @__PURE__ */ jsx(
2789
+ Textarea,
2790
+ {
2791
+ id: "forms-publish-changelog",
2792
+ rows: 4,
2793
+ value: changelog,
2794
+ placeholder: t("forms.version.publish.changelogPlaceholder"),
2795
+ onChange: (event) => setChangelog(event.target.value)
2796
+ }
2797
+ )
2798
+ ] }),
2799
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("forms.version.publish.blastRadius") }),
2800
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
2801
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: onClose, disabled: busy, children: t("forms.version.publish.actions.cancel") }),
2802
+ /* @__PURE__ */ jsx(Button, { type: "button", onClick: () => void submit(), disabled: busy, children: t("forms.version.publish.actions.confirm") })
2803
+ ] })
2804
+ ]
2805
+ }
2806
+ ) });
2807
+ }
2808
+ export {
2809
+ FormStudio
2810
+ };
2811
+ //# sourceMappingURL=FormStudio.js.map