@declarion/react 0.65.1 → 0.66.1

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 (467) hide show
  1. package/dist-lib/api/access-expiry.js +32 -0
  2. package/dist-lib/api/agents.js +105 -0
  3. package/dist-lib/api/auth-redirect.js +30 -0
  4. package/dist-lib/api/auth.js +67 -0
  5. package/dist-lib/api/batch.js +34 -0
  6. package/dist-lib/api/client.js +241 -0
  7. package/dist-lib/api/data.js +122 -0
  8. package/dist-lib/api/entities.js +160 -0
  9. package/dist-lib/api/events.js +120 -0
  10. package/dist-lib/api/fileReferences.js +8 -0
  11. package/dist-lib/api/params.js +20 -0
  12. package/dist-lib/api/properties.js +25 -0
  13. package/dist-lib/api/request-bounds.js +28 -0
  14. package/dist-lib/api/schema.js +71 -0
  15. package/dist-lib/api/session-renewal.js +36 -0
  16. package/dist-lib/api/status.js +17 -0
  17. package/dist-lib/app.js +262 -0
  18. package/dist-lib/components/actions/ActionButton.js +116 -0
  19. package/dist-lib/{ActionDialog-C6EG-AmC.js → components/actions/ActionDialog.js} +63 -53
  20. package/dist-lib/{ActionResultDialog.impl-BATutW8J.js → components/actions/ActionResultDialog.impl.js} +53 -48
  21. package/dist-lib/components/actions/ActionResultDialog.js +12 -0
  22. package/dist-lib/components/actions/ActionRunner.js +274 -0
  23. package/dist-lib/components/actions/ObjectActionBar.js +127 -0
  24. package/dist-lib/components/actions/PropertyGridEditor.js +202 -0
  25. package/dist-lib/components/actions/ResponsiveActionBar.js +773 -0
  26. package/dist-lib/components/actions/RowActionsKebab.js +90 -0
  27. package/dist-lib/{AgentChatPanel.impl-D5y_qEex.js → components/agents/AgentChatPanel.impl.js} +314 -362
  28. package/dist-lib/components/agents/AgentChatPanel.js +12 -0
  29. package/dist-lib/components/agents/AgentConversationDrawer.js +59 -0
  30. package/dist-lib/components/agents/AgentElicitForm.js +152 -0
  31. package/dist-lib/components/agents/AgentOpenFollower.impl.js +7 -0
  32. package/dist-lib/components/agents/AgentOpenFollower.js +12 -0
  33. package/dist-lib/components/agents/AgentPicker.js +58 -0
  34. package/dist-lib/components/agents/transcript-runs.js +52 -0
  35. package/dist-lib/components/chrome/AssociationTabs.js +176 -0
  36. package/dist-lib/components/chrome/AuditMetaStrip.js +64 -0
  37. package/dist-lib/components/chrome/Breadcrumbs.js +67 -0
  38. package/dist-lib/components/chrome/HighlightsStrip.js +39 -0
  39. package/dist-lib/{PageHeader-DiwLe7CO.js → components/chrome/PageHeader.js} +19 -15
  40. package/dist-lib/{PageShell-BJz1MiTH.js → components/chrome/PageShell.js} +3 -3
  41. package/dist-lib/components/chrome/RecordHeader.js +119 -0
  42. package/dist-lib/{headerActionZone-bef-tZZ7.js → components/chrome/headerActionZone.js} +1 -1
  43. package/dist-lib/components/detail-layout/AssociatedBlock.js +1244 -0
  44. package/dist-lib/components/detail-layout/AssociatedToolbar.js +87 -0
  45. package/dist-lib/components/detail-layout/ChildrenBlock.js +80 -0
  46. package/dist-lib/components/detail-layout/ChildrenCards.js +156 -0
  47. package/dist-lib/components/detail-layout/ChildrenList.js +135 -0
  48. package/dist-lib/components/detail-layout/ChildrenTable.js +189 -0
  49. package/dist-lib/components/detail-layout/ChildrenTimeline.js +609 -0
  50. package/dist-lib/components/detail-layout/DetailAuditStrip.js +40 -0
  51. package/dist-lib/components/detail-layout/DetailHighlights.js +54 -0
  52. package/dist-lib/{DraggableChildrenTable-Dd5SeuF6.js → components/detail-layout/DraggableChildrenTable.js} +56 -53
  53. package/dist-lib/components/detail-layout/EditableChildrenTable.js +341 -0
  54. package/dist-lib/components/detail-layout/ErrorSummary.js +89 -0
  55. package/dist-lib/components/detail-layout/EvidenceBlock.js +66 -0
  56. package/dist-lib/{FieldRow-DedGIY9R.js → components/detail-layout/FieldRow.js} +8 -7
  57. package/dist-lib/components/detail-layout/FieldsBlock.js +74 -0
  58. package/dist-lib/components/detail-layout/LayoutColumn.js +16 -0
  59. package/dist-lib/components/detail-layout/LayoutRenderer.js +54 -0
  60. package/dist-lib/components/detail-layout/LayoutRow.js +83 -0
  61. package/dist-lib/components/detail-layout/LayoutTabs.js +195 -0
  62. package/dist-lib/components/detail-layout/PropertiesBlock.js +74 -0
  63. package/dist-lib/components/detail-layout/QuickAddForm.js +81 -0
  64. package/dist-lib/components/detail-layout/SectionBlock.js +48 -0
  65. package/dist-lib/components/detail-layout/StatusesBlock.js +18 -0
  66. package/dist-lib/components/detail-layout/TimelineComposer.js +205 -0
  67. package/dist-lib/components/detail-layout/blockMeta.js +27 -0
  68. package/dist-lib/components/detail-layout/useManualColumnResize.js +94 -0
  69. package/dist-lib/components/detail-layout/useQuickAdd.js +85 -0
  70. package/dist-lib/components/detail-layout/widgets/EntityScorecardWidget.js +295 -0
  71. package/dist-lib/components/detail-layout/widgets/JsonDiffWidget.js +107 -0
  72. package/dist-lib/components/detail-layout/widgets/MonacoJson.js +47 -0
  73. package/dist-lib/components/detail-layout/widgets/WidgetHost.js +36 -0
  74. package/dist-lib/components/detail-layout/widgets/builtins.js +10 -0
  75. package/dist-lib/components/detail-layout/widgets/canonicalizeJson.js +32 -0
  76. package/dist-lib/components/detail-layout/widgets/monacoBootstrap.js +16 -0
  77. package/dist-lib/components/detail-layout/widgets/registry.js +13 -0
  78. package/dist-lib/components/fields/BoolField.js +13 -0
  79. package/dist-lib/components/fields/EmailField.js +16 -0
  80. package/dist-lib/components/fields/EnumField.js +38 -0
  81. package/dist-lib/components/fields/FileReferenceField.js +60 -0
  82. package/dist-lib/components/fields/IntArrayField.js +83 -0
  83. package/dist-lib/components/fields/JsonField.js +51 -0
  84. package/dist-lib/components/fields/MultilangArrayField.js +56 -0
  85. package/dist-lib/components/fields/MultilangField.js +65 -0
  86. package/dist-lib/components/fields/MultilangTextField.js +65 -0
  87. package/dist-lib/components/fields/NumberField.js +64 -0
  88. package/dist-lib/components/fields/PasswordField.js +34 -0
  89. package/dist-lib/components/fields/PhoneField.js +84 -0
  90. package/dist-lib/components/fields/RefCombobox.js +112 -0
  91. package/dist-lib/components/fields/RefField.js +45 -0
  92. package/dist-lib/components/fields/RichTextField.js +225 -0
  93. package/dist-lib/components/fields/SecretField.js +34 -0
  94. package/dist-lib/components/fields/StringArrayField.js +165 -0
  95. package/dist-lib/components/fields/StringField.js +39 -0
  96. package/dist-lib/components/fields/StructureField.js +221 -0
  97. package/dist-lib/components/fields/TextField.js +76 -0
  98. package/dist-lib/components/fields/TimestampField.js +110 -0
  99. package/dist-lib/components/fields/UrlField.js +18 -0
  100. package/dist-lib/components/fields/cells/factories/badge.js +42 -0
  101. package/dist-lib/components/fields/cells/factories/boolPill.js +17 -0
  102. package/dist-lib/components/fields/cells/factories/code.js +11 -0
  103. package/dist-lib/components/fields/cells/factories/date.js +30 -0
  104. package/dist-lib/components/fields/cells/factories/email.js +26 -0
  105. package/dist-lib/components/fields/cells/factories/emptyCell.js +10 -0
  106. package/dist-lib/components/fields/cells/factories/fileReference.js +17 -0
  107. package/dist-lib/components/fields/cells/factories/host-icons.js +146 -0
  108. package/dist-lib/components/fields/cells/factories/json.js +61 -0
  109. package/dist-lib/components/fields/cells/factories/link.js +32 -0
  110. package/dist-lib/components/fields/cells/factories/markdown.js +31 -0
  111. package/dist-lib/components/fields/cells/factories/markdownPreview.js +81 -0
  112. package/dist-lib/components/fields/cells/factories/money.js +37 -0
  113. package/dist-lib/components/fields/cells/factories/multilangInline.js +35 -0
  114. package/dist-lib/components/fields/cells/factories/nextRun.js +46 -0
  115. package/dist-lib/components/fields/cells/factories/number.js +42 -0
  116. package/dist-lib/components/fields/cells/factories/passwordMask.js +23 -0
  117. package/dist-lib/components/fields/cells/factories/phone.js +35 -0
  118. package/dist-lib/components/fields/cells/factories/refLink.js +57 -0
  119. package/dist-lib/components/fields/cells/factories/richTextPreview.js +34 -0
  120. package/dist-lib/components/fields/cells/factories/statusPill.js +35 -0
  121. package/dist-lib/components/fields/cells/factories/tagList.js +44 -0
  122. package/dist-lib/components/fields/cells/factories/text.js +5 -0
  123. package/dist-lib/components/fields/cells/factories/timestamp.js +18 -0
  124. package/dist-lib/components/fields/cells/factories/url-helpers.js +49 -0
  125. package/dist-lib/components/fields/cells/factories/url.js +45 -0
  126. package/dist-lib/components/fields/cells/registry.js +58 -0
  127. package/dist-lib/components/fields/index.js +80 -0
  128. package/dist-lib/components/fields/langMap.js +6 -0
  129. package/dist-lib/components/fields/secretValue.js +7 -0
  130. package/dist-lib/components/file-widgets/CircleImage.js +11 -0
  131. package/dist-lib/components/file-widgets/DocumentCard.js +277 -0
  132. package/dist-lib/components/file-widgets/FileList.js +213 -0
  133. package/dist-lib/{Grid-XUHm5SDe.js → components/file-widgets/Grid.js} +45 -40
  134. package/dist-lib/components/file-widgets/GridLazy.js +15 -0
  135. package/dist-lib/components/file-widgets/ImageWidget.js +354 -0
  136. package/dist-lib/components/file-widgets/LabeledSlots.js +69 -0
  137. package/dist-lib/components/file-widgets/SquareImage.js +11 -0
  138. package/dist-lib/components/file-widgets/UnknownFileWidget.js +22 -0
  139. package/dist-lib/components/file-widgets/UploadFailureText.js +10 -0
  140. package/dist-lib/components/file-widgets/WideBanner.js +11 -0
  141. package/dist-lib/components/file-widgets/builtins.js +15 -0
  142. package/dist-lib/components/file-widgets/cropper.js +13 -0
  143. package/dist-lib/components/file-widgets/draft-scope.js +59 -0
  144. package/dist-lib/components/file-widgets/helpers.js +75 -0
  145. package/dist-lib/components/file-widgets/host.js +75 -0
  146. package/dist-lib/{payload-DioMoxMX.js → components/file-widgets/payload.js} +14 -14
  147. package/dist-lib/components/file-widgets/registry.js +13 -0
  148. package/dist-lib/components/file-widgets/upload.js +180 -0
  149. package/dist-lib/components/file-widgets/useEmbedFileSrc.js +45 -0
  150. package/dist-lib/components/file-widgets/value.js +12 -0
  151. package/dist-lib/components/filters/FilterChips.js +123 -0
  152. package/dist-lib/components/filters/FilterConditionValue.js +40 -0
  153. package/dist-lib/components/filters/FilterDrawer.js +670 -0
  154. package/dist-lib/components/filters/FilterOmittedNotice.js +14 -0
  155. package/dist-lib/components/filters/filter-op-label.js +8 -0
  156. package/dist-lib/{CommandPalette.impl-DRI5kxVY.js → components/layout/CommandPalette.impl.js} +62 -61
  157. package/dist-lib/components/layout/CommandPalette.js +12 -0
  158. package/dist-lib/{DirtyTabsCloseDialog.impl-FhAiOmEb.js → components/layout/DirtyTabsCloseDialog.impl.js} +16 -14
  159. package/dist-lib/components/layout/DirtyTabsCloseDialog.js +12 -0
  160. package/dist-lib/{ImpersonationBanner.impl--g0iYwcV.js → components/layout/ImpersonationBanner.impl.js} +4 -3
  161. package/dist-lib/components/layout/ImpersonationBanner.js +12 -0
  162. package/dist-lib/components/layout/ImpersonationFrame.js +29 -0
  163. package/dist-lib/{ImpersonationStartModal.impl-BFBN0YJe.js → components/layout/ImpersonationStartModal.impl.js} +9 -9
  164. package/dist-lib/components/layout/ImpersonationStartModal.js +12 -0
  165. package/dist-lib/components/layout/Layout.js +755 -0
  166. package/dist-lib/components/layout/Rail.js +149 -0
  167. package/dist-lib/components/layout/Sidebar.js +362 -0
  168. package/dist-lib/components/layout/TabStrip.js +321 -0
  169. package/dist-lib/components/layout/TenantChip.js +355 -0
  170. package/dist-lib/components/layout/TopBar.js +305 -0
  171. package/dist-lib/components/layout/tab-close.js +24 -0
  172. package/dist-lib/components/list/ColumnPicker.js +112 -0
  173. package/dist-lib/components/list/InlineEditCell.js +107 -0
  174. package/dist-lib/components/list/PeekFieldCell.js +143 -0
  175. package/dist-lib/components/list/QuickPeek.js +263 -0
  176. package/dist-lib/components/list/ViewSwitcher.js +156 -0
  177. package/dist-lib/components/list/peekDraftStore.js +14 -0
  178. package/dist-lib/{AdminCatalogPage.impl-B-7MLqa1.js → components/pages/AdminCatalogPage.impl.js} +53 -49
  179. package/dist-lib/components/pages/AdminCatalogPage.js +12 -0
  180. package/dist-lib/components/pages/DocumentsMenu.js +150 -0
  181. package/dist-lib/components/pages/ExportMenu.js +123 -0
  182. package/dist-lib/{NotFoundPage.impl-BoX11u-P.js → components/pages/NotFoundPage.impl.js} +6 -4
  183. package/dist-lib/components/pages/NotFoundPage.js +12 -0
  184. package/dist-lib/components/pages/RecordDocumentsPanel.js +230 -0
  185. package/dist-lib/components/pages/RecordNotesPanel.js +200 -0
  186. package/dist-lib/components/pages/RecordPanels.js +18 -0
  187. package/dist-lib/components/pages/SSOCallbackPage.impl.js +28 -0
  188. package/dist-lib/components/pages/SSOCallbackPage.js +12 -0
  189. package/dist-lib/components/pages/SmartDetailPage.impl.js +986 -0
  190. package/dist-lib/components/pages/SmartDetailPage.js +12 -0
  191. package/dist-lib/components/pages/SmartListPage.impl.js +708 -0
  192. package/dist-lib/components/pages/SmartListPage.js +12 -0
  193. package/dist-lib/components/pages/SmartRecordListPage.impl.js +818 -0
  194. package/dist-lib/components/pages/SmartRecordListPage.js +12 -0
  195. package/dist-lib/components/pages/auth/AuthShell.js +350 -0
  196. package/dist-lib/{Forgot.impl-6tL6SBlS.js → components/pages/auth/Forgot.impl.js} +13 -12
  197. package/dist-lib/components/pages/auth/Forgot.js +12 -0
  198. package/dist-lib/{Reset.impl-D0pjhS6d.js → components/pages/auth/Reset.impl.js} +17 -15
  199. package/dist-lib/components/pages/auth/Reset.js +12 -0
  200. package/dist-lib/components/pages/auth/SignIn.js +252 -0
  201. package/dist-lib/{SignUp.impl-CfEXrUeg.js → components/pages/auth/SignUp.impl.js} +31 -27
  202. package/dist-lib/components/pages/auth/SignUp.js +12 -0
  203. package/dist-lib/{TwoFA.impl-B2HtPduH.js → components/pages/auth/TwoFA.impl.js} +9 -8
  204. package/dist-lib/components/pages/auth/TwoFA.js +12 -0
  205. package/dist-lib/components/pages/auth/icons.js +56 -0
  206. package/dist-lib/components/pages/exportRequest.js +17 -0
  207. package/dist-lib/components/pages/list/DataCell.js +27 -0
  208. package/dist-lib/components/pages/list/DeleteViewDialog.js +22 -0
  209. package/dist-lib/{ListCardsBody-BEoYjSZ2.js → components/pages/list/ListCardRow.js} +47 -72
  210. package/dist-lib/components/pages/list/ListCardsBody.js +31 -0
  211. package/dist-lib/components/pages/list/ListFloatbar.js +130 -0
  212. package/dist-lib/components/pages/list/ListFooter.js +138 -0
  213. package/dist-lib/components/pages/list/ListHeader.js +120 -0
  214. package/dist-lib/components/pages/list/ListNoRows.js +72 -0
  215. package/dist-lib/components/pages/list/ListTable.js +191 -0
  216. package/dist-lib/components/pages/list/ListTableRow.js +37 -0
  217. package/dist-lib/components/pages/list/ListToolbar.js +261 -0
  218. package/dist-lib/components/pages/list/ListUrlBanner.js +45 -0
  219. package/dist-lib/components/pages/list/RowActionsCell.js +49 -0
  220. package/dist-lib/components/pages/list/RowContextMenu.js +55 -0
  221. package/dist-lib/components/pages/list/SaveViewDialog.js +111 -0
  222. package/dist-lib/{SortHeaderMenu-Co5PvhTA.js → components/pages/list/SortHeaderMenu.js} +18 -17
  223. package/dist-lib/{cardProjection-Cxlogzh8.js → components/pages/list/cardProjection.js} +3 -3
  224. package/dist-lib/components/pages/list/column-sizing.js +17 -0
  225. package/dist-lib/components/pages/list/columns.js +168 -0
  226. package/dist-lib/components/pages/list/filter-meta.js +84 -0
  227. package/dist-lib/components/pages/list/page-size.js +11 -0
  228. package/dist-lib/components/pages/list/sortable-header.js +18 -0
  229. package/dist-lib/components/pages/list/table-features.js +11 -0
  230. package/dist-lib/components/pages/list/use-filter-value-labels.js +115 -0
  231. package/dist-lib/components/pages/list/useActiveView.js +98 -0
  232. package/dist-lib/components/pages/list/useHeaderReorder.js +93 -0
  233. package/dist-lib/components/pages/list/useListColumnLayout.js +56 -0
  234. package/dist-lib/components/pages/list/useListFilterPresentation.js +34 -0
  235. package/dist-lib/components/pages/list/useListQuery.js +101 -0
  236. package/dist-lib/components/pages/list/useListRowInteraction.js +120 -0
  237. package/dist-lib/components/pages/list/useListSelection.js +53 -0
  238. package/dist-lib/components/pages/list/useListSort.js +44 -0
  239. package/dist-lib/components/pages/list/useListViews.js +148 -0
  240. package/dist-lib/components/pages/list/useRowMenu.js +106 -0
  241. package/dist-lib/components/pages/list/visible-filters.js +19 -0
  242. package/dist-lib/{Preferences.impl-Ct5xwZtT.js → components/pages/profile/Preferences.impl.js} +34 -31
  243. package/dist-lib/components/pages/profile/Preferences.js +12 -0
  244. package/dist-lib/components/pages/profile/Profile.impl.js +437 -0
  245. package/dist-lib/components/pages/profile/Profile.js +12 -0
  246. package/dist-lib/{TenantParamsPage.impl-BGpdmEZg.js → components/pages/tenant-params/TenantParamsPage.impl.js} +45 -40
  247. package/dist-lib/components/pages/tenant-params/TenantParamsPage.js +12 -0
  248. package/dist-lib/components/params/ParamsBlock.js +119 -0
  249. package/dist-lib/{param-editors-TYYU7HKK.js → components/params/param-editors.js} +32 -28
  250. package/dist-lib/components/primitives/Avatar.js +33 -0
  251. package/dist-lib/components/primitives/BoolToggle.js +35 -0
  252. package/dist-lib/components/primitives/BrandGlyph.js +38 -0
  253. package/dist-lib/components/primitives/BrandLogo.js +20 -0
  254. package/dist-lib/components/primitives/Btn.js +67 -0
  255. package/dist-lib/{Check-DAfMbQIw.js → components/primitives/Check.js} +2 -2
  256. package/dist-lib/components/primitives/Chip.js +44 -0
  257. package/dist-lib/components/primitives/ClassifiedFieldLocked.js +15 -0
  258. package/dist-lib/components/primitives/Dropdown.js +85 -0
  259. package/dist-lib/components/primitives/Fields.js +751 -0
  260. package/dist-lib/components/primitives/HoverCard.js +115 -0
  261. package/dist-lib/components/primitives/IconBtn.js +37 -0
  262. package/dist-lib/{Icons-lt-7lhYR.js → components/primitives/Icons.js} +1 -1
  263. package/dist-lib/{Kbd-CNttVu0z.js → components/primitives/Kbd.js} +2 -2
  264. package/dist-lib/components/primitives/MenuItem.js +57 -0
  265. package/dist-lib/{Pill-D-wsfRhx.js → components/primitives/Pill.js} +1 -1
  266. package/dist-lib/{RecordIdBadge-wbigZaFc.js → components/primitives/RecordIdBadge.js} +5 -5
  267. package/dist-lib/components/primitives/RowField.js +47 -0
  268. package/dist-lib/{SectionCard-BYHoHWJc.js → components/primitives/SectionCard.js} +10 -10
  269. package/dist-lib/components/primitives/Spinner.js +31 -0
  270. package/dist-lib/components/primitives/StatTile.js +108 -0
  271. package/dist-lib/components/primitives/Tooltip.js +115 -0
  272. package/dist-lib/{dataTableStyles-vwD1mVOP.js → components/primitives/dataTableStyles.js} +1 -1
  273. package/dist-lib/components/shared/BlankScreen.js +13 -0
  274. package/dist-lib/{ChangePasswordDialog.impl-5hDc0wpE.js → components/shared/ChangePasswordDialog.impl.js} +27 -22
  275. package/dist-lib/{ChangePasswordDialog-C_T_3pjl.js → components/shared/ChangePasswordDialog.js} +2 -2
  276. package/dist-lib/components/shared/ConfirmDialog.js +129 -0
  277. package/dist-lib/components/shared/ConnectionNotice.js +12 -0
  278. package/dist-lib/components/shared/CopyButton.js +25 -0
  279. package/dist-lib/components/shared/DynamicIcon.js +73 -0
  280. package/dist-lib/components/shared/EmptyState.js +56 -0
  281. package/dist-lib/components/shared/ErrorBoundary.js +96 -0
  282. package/dist-lib/components/shared/LoadingSkeleton.js +117 -0
  283. package/dist-lib/components/shared/LucideIcon.js +43 -0
  284. package/dist-lib/components/shared/Markdown.js +15 -0
  285. package/dist-lib/{MarkdownRenderer-sK2TRZS-.js → components/shared/MarkdownRenderer.js} +10 -9
  286. package/dist-lib/components/shared/RefreshControl.js +42 -0
  287. package/dist-lib/components/shared/StatusGroupsDisplay.js +123 -0
  288. package/dist-lib/components/shared/StatusStepper.js +70 -0
  289. package/dist-lib/components/shared/toast/DeclarionToast.js +308 -0
  290. package/dist-lib/components/shared/useOwnRefresh.js +19 -0
  291. package/dist-lib/declarion-react.css +1 -1
  292. package/dist-lib/embed/EmbedAuthBootstrap.js +71 -0
  293. package/dist-lib/embed/EmbedContext.js +38 -0
  294. package/dist-lib/embed/EmbedDirtyReporter.js +17 -0
  295. package/dist-lib/embed/EmbedHistoryTracker.js +17 -0
  296. package/dist-lib/embed/EmbedLocationReporter.js +26 -0
  297. package/dist-lib/embed/EmbedResizeReporter.js +25 -0
  298. package/dist-lib/embed/EmbedUnsavedGuard.js +23 -0
  299. package/dist-lib/embed/embed-dirty.js +21 -0
  300. package/dist-lib/embed/embed-history.js +17 -0
  301. package/dist-lib/embed/embed-nav-guard.js +13 -0
  302. package/dist-lib/embed/file-src.js +60 -0
  303. package/dist-lib/embed/handshake.js +37 -0
  304. package/dist-lib/embed/params.js +45 -0
  305. package/dist-lib/embed/protocol.js +26 -0
  306. package/dist-lib/embed/screen-location.js +44 -0
  307. package/dist-lib/embed/theme.js +11 -0
  308. package/dist-lib/embed/token.js +54 -0
  309. package/dist-lib/embed/useEmbedNavigate.js +65 -0
  310. package/dist-lib/embed/useGlobalLinkInterceptor.js +63 -0
  311. package/dist-lib/hooks/useActionData.js +58 -0
  312. package/dist-lib/hooks/useAgentConversation.js +311 -0
  313. package/dist-lib/hooks/useAggregate.js +18 -0
  314. package/dist-lib/hooks/useAllEntityData.js +53 -0
  315. package/dist-lib/hooks/useAssociatedData.js +37 -0
  316. package/dist-lib/hooks/useAuth.js +56 -0
  317. package/dist-lib/hooks/useBranding.js +18 -0
  318. package/dist-lib/hooks/useBrandingChrome.js +58 -0
  319. package/dist-lib/hooks/useChildrenData.js +33 -0
  320. package/dist-lib/hooks/useColumns.js +44 -0
  321. package/dist-lib/hooks/useConnectionNotice.js +35 -0
  322. package/dist-lib/{useCurrentLocation-Bq1T72AW.js → hooks/useCurrentLocation.js} +2 -2
  323. package/dist-lib/hooks/useCurrentScreen.js +20 -0
  324. package/dist-lib/hooks/useCursorEntityData.js +77 -0
  325. package/dist-lib/hooks/useDebounce.js +11 -0
  326. package/dist-lib/hooks/useEntity.js +8 -0
  327. package/dist-lib/hooks/useEntityData.js +64 -0
  328. package/dist-lib/hooks/useFileReferenceJSON.js +29 -0
  329. package/dist-lib/hooks/useFilters.js +28 -0
  330. package/dist-lib/hooks/useFollowAgentOpen.js +84 -0
  331. package/dist-lib/hooks/useImpersonation.js +40 -0
  332. package/dist-lib/hooks/useIntentPrefetch.js +43 -0
  333. package/dist-lib/hooks/useJsonSnapshot.js +8 -0
  334. package/dist-lib/hooks/useLanguage.js +21 -0
  335. package/dist-lib/hooks/useLiveObject.js +17 -0
  336. package/dist-lib/hooks/useLongPress.js +49 -0
  337. package/dist-lib/hooks/useMutations.js +70 -0
  338. package/dist-lib/{useObject-B45F96rC.js → hooks/useObject.js} +2 -2
  339. package/dist-lib/hooks/useObjectStatus.js +20 -0
  340. package/dist-lib/hooks/usePageState.js +18 -0
  341. package/dist-lib/hooks/usePageStateRuntime.js +46 -0
  342. package/dist-lib/hooks/usePageStateTtl.js +10 -0
  343. package/dist-lib/hooks/useParams.js +123 -0
  344. package/dist-lib/hooks/useProperties.js +32 -0
  345. package/dist-lib/hooks/useRealtimeThresholds.js +31 -0
  346. package/dist-lib/hooks/useRegisterScreenTab.js +28 -0
  347. package/dist-lib/hooks/useResponsiveMode.js +84 -0
  348. package/dist-lib/hooks/useSSE.js +307 -0
  349. package/dist-lib/hooks/useSchema.js +73 -0
  350. package/dist-lib/hooks/useScreen.js +8 -0
  351. package/dist-lib/hooks/useScreenBack.js +60 -0
  352. package/dist-lib/hooks/useScreenTab.js +11 -0
  353. package/dist-lib/hooks/useTabNavigate.js +82 -0
  354. package/dist-lib/hooks/useTabSearchMirror.js +19 -0
  355. package/dist-lib/{useTabTitle-KrzEo118.js → hooks/useTabTitle.js} +9 -7
  356. package/dist-lib/hooks/useText.js +15 -0
  357. package/dist-lib/hooks/useTimelineData.js +44 -0
  358. package/dist-lib/hooks/useUnsavedInput.js +18 -0
  359. package/dist-lib/hooks/useVersionWatcher.js +62 -0
  360. package/dist-lib/hooks/useViews.js +88 -0
  361. package/dist-lib/hooks/useWindowConversation.js +11 -0
  362. package/dist-lib/icons.js +5 -3
  363. package/dist-lib/index.d.ts +42 -20
  364. package/dist-lib/index.js +131 -3926
  365. package/dist-lib/lib/action-dispatch.js +7 -0
  366. package/dist-lib/lib/actions.js +279 -0
  367. package/dist-lib/lib/anchor.js +41 -0
  368. package/dist-lib/lib/brand-tokens.js +95 -0
  369. package/dist-lib/lib/branding.js +25 -0
  370. package/dist-lib/lib/canonical-url.js +17 -0
  371. package/dist-lib/lib/capabilityPrefetch.js +57 -0
  372. package/dist-lib/lib/child-config.js +111 -0
  373. package/dist-lib/lib/children-validation.js +52 -0
  374. package/dist-lib/lib/decimal-text.js +15 -0
  375. package/dist-lib/lib/display-value.js +19 -0
  376. package/dist-lib/lib/document-templates.js +6 -0
  377. package/dist-lib/lib/download.js +41 -0
  378. package/dist-lib/lib/evidence-verdict.js +23 -0
  379. package/dist-lib/lib/failure.js +9 -0
  380. package/dist-lib/lib/field-classification.js +58 -0
  381. package/dist-lib/lib/field-regions.js +13 -0
  382. package/dist-lib/lib/filter-evaluator.js +98 -0
  383. package/dist-lib/lib/filters.js +118 -0
  384. package/dist-lib/lib/format-count.js +24 -0
  385. package/dist-lib/lib/html-state.js +9 -0
  386. package/dist-lib/lib/language.js +52 -0
  387. package/dist-lib/lib/longPressGesture.js +34 -0
  388. package/dist-lib/lib/mass-edit.js +65 -0
  389. package/dist-lib/{page-inset-D_kkVwwN.js → lib/page-inset.js} +1 -1
  390. package/dist-lib/lib/phone.js +28 -0
  391. package/dist-lib/lib/query-retry.js +7 -0
  392. package/dist-lib/lib/quick-add.js +23 -0
  393. package/dist-lib/lib/realtime-query-keys.js +23 -0
  394. package/dist-lib/lib/realtime-reconcile.js +148 -0
  395. package/dist-lib/lib/realtime-resync.js +192 -0
  396. package/dist-lib/lib/record-documents-key.js +4 -0
  397. package/dist-lib/lib/ref-choices.js +6 -0
  398. package/dist-lib/lib/refetch-when-idle.js +25 -0
  399. package/dist-lib/lib/rich-text.js +46 -0
  400. package/dist-lib/lib/rowClickGesture.js +10 -0
  401. package/dist-lib/lib/safe-url.js +34 -0
  402. package/dist-lib/lib/schema-routing.js +51 -0
  403. package/dist-lib/{screen-back-BtbEp5sO.js → lib/screen-back.js} +2 -2
  404. package/dist-lib/lib/scroll-restoration.js +156 -0
  405. package/dist-lib/lib/size-value.js +22 -0
  406. package/dist-lib/lib/sort.js +59 -0
  407. package/dist-lib/lib/timestamp.js +97 -0
  408. package/dist-lib/lib/toast.js +78 -0
  409. package/dist-lib/lib/ui-actions.js +81 -0
  410. package/dist-lib/{utils-D_QDpB8_.js → lib/utils.js} +1 -1
  411. package/dist-lib/lib/variants.js +63 -0
  412. package/dist-lib/lib/versionTracker.js +102 -0
  413. package/dist-lib/lib/viewport-category.js +12 -0
  414. package/dist-lib/{window-election-CHIvIZwx.js → lib/window-election.js} +1 -1
  415. package/dist-lib/stores/auth.js +84 -0
  416. package/dist-lib/stores/icon-registry.js +24 -0
  417. package/dist-lib/stores/list-layout.js +178 -0
  418. package/dist-lib/{page-state-eA6J_KIR.js → stores/page-state.js} +1 -1
  419. package/dist-lib/stores/preferences.js +126 -0
  420. package/dist-lib/stores/realtime.js +115 -0
  421. package/dist-lib/stores/screen-registry.js +10 -0
  422. package/dist-lib/stores/tabs.js +220 -0
  423. package/dist-lib/test/seed-schema.js +8 -0
  424. package/dist-lib/testing.d.ts +1 -1
  425. package/dist-lib/testing.js +80 -76
  426. package/dist-lib/types/api.js +48 -0
  427. package/dist-lib/types/fieldType.js +4 -0
  428. package/dist-lib/types/ordmap.js +50 -0
  429. package/dist-lib/types/schema.js +173 -0
  430. package/dist-lib/{useResponsiveMode-DIR1bZfo.d.ts → useResponsiveMode-DmrpMbZX.d.ts} +44 -16
  431. package/package.json +13 -12
  432. package/dist-lib/ActionRunner-DdBFhqGe.js +0 -1440
  433. package/dist-lib/AgentOpenFollower.impl-BAs_wGEZ.js +0 -81
  434. package/dist-lib/AssociatedBlock-BOoPLOjw.js +0 -1515
  435. package/dist-lib/AuthShell-C8aVwHS7.js +0 -361
  436. package/dist-lib/BlankScreen-DVc7fh8C.js +0 -61
  437. package/dist-lib/CopyButton-DRIT_f0k.js +0 -119
  438. package/dist-lib/DynamicIcon-DuBSz6TZ.js +0 -133
  439. package/dist-lib/FilterChips-Cv1tlXyo.js +0 -1031
  440. package/dist-lib/LayoutRenderer-d-tXYPze.js +0 -3239
  441. package/dist-lib/MenuItem-CfkVXPvC.js +0 -140
  442. package/dist-lib/MonacoJson-BG3S3GHX.js +0 -60
  443. package/dist-lib/Profile.impl-Cypk27ah.js +0 -527
  444. package/dist-lib/PropertyGridEditor-XrP6TZ5s.js +0 -4378
  445. package/dist-lib/RecordHeader-BfQ0_4wq.js +0 -217
  446. package/dist-lib/RefreshControl-CRdWPoF5.js +0 -195
  447. package/dist-lib/SSOCallbackPage.impl-Cfi2pQ59.js +0 -31
  448. package/dist-lib/SmartDetailPage.impl-BiIX0n7K.js +0 -1609
  449. package/dist-lib/SmartListPage.impl-Cu83Gv_G.js +0 -2818
  450. package/dist-lib/SmartRecordListPage.impl-DR6lq7HA.js +0 -795
  451. package/dist-lib/format-count-lyB4CPen.js +0 -943
  452. package/dist-lib/peekDraftStore-CaimrOhW.js +0 -200
  453. package/dist-lib/registry-CGe5kCXN.js +0 -119
  454. package/dist-lib/use-filter-value-labels-D3YDgUzg.js +0 -413
  455. package/dist-lib/useAgentConversation-rru-7hnF.js +0 -612
  456. package/dist-lib/useBranding-zcxEic2k.js +0 -41
  457. package/dist-lib/useBrandingChrome-bxaR3G1R.js +0 -170
  458. package/dist-lib/useCurrentScreen-BZOHBGQZ.js +0 -2522
  459. package/dist-lib/useImpersonation-DBIRRR70.js +0 -35
  460. package/dist-lib/useOwnRefresh-DJjaje52.js +0 -435
  461. package/dist-lib/useParams-BFLJi4n3.js +0 -133
  462. package/dist-lib/useProperties-B7opZ-iy.js +0 -81
  463. package/dist-lib/useScreenBack-DENlz844.js +0 -71
  464. package/dist-lib/useTabNavigate-CUqOmcMj.js +0 -78
  465. package/dist-lib/value-BuQVYx52.js +0 -194
  466. package/dist-lib/variants-vUtfBbE6.js +0 -1961
  467. /package/dist-lib/{JsonEditor-Dz1PQHC8.js → components/fields/JsonEditor.js} +0 -0
@@ -1,2522 +0,0 @@
1
- import { t as e } from "./Icons-lt-7lhYR.js";
2
- import { Fragment as t, createContext as n, createElement as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
3
- import { useQuery as u } from "@tanstack/react-query";
4
- import { formatISO as d } from "date-fns";
5
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
6
- import { create as m } from "zustand";
7
- import { useLocation as ee, useNavigate as h } from "react-router";
8
- import { toast as g } from "sonner";
9
- //#region src/types/api.ts
10
- var _ = class extends Error {
11
- status;
12
- code;
13
- type;
14
- retryable;
15
- detail;
16
- index;
17
- raw;
18
- constructor(e, t, n) {
19
- super(t.title ?? ""), this.name = "ApiError", this.status = t.status ?? e, this.type = t.type ?? "", this.code = v(t.type), this.retryable = t.retryable ?? !1, this.detail = t.detail;
20
- let r = t.index;
21
- typeof r == "number" && (this.index = r), this.raw = n;
22
- }
23
- ext(e) {
24
- return this.raw?.[e];
25
- }
26
- };
27
- function v(e) {
28
- if (!e || e === "about:blank") return "";
29
- let t = e.lastIndexOf("/");
30
- return t >= 0 ? e.slice(t + 1) : e;
31
- }
32
- function y(e) {
33
- return typeof e == "object" && !!e && typeof e.type == "string";
34
- }
35
- var te = "cursor.semantics_mismatch", b = "cursor.language_changed";
36
- function ne(e) {
37
- return e instanceof _ && (e.code === "cursor.semantics_mismatch" || e.code === "cursor.language_changed" || e.code === "cursor.archive_invalid");
38
- }
39
- async function x(e) {
40
- let t;
41
- try {
42
- t = await e.json();
43
- } catch {}
44
- return {
45
- raw: t,
46
- body: y(t) ? t : {}
47
- };
48
- }
49
- //#endregion
50
- //#region src/api/auth-redirect.ts
51
- var S = "/", C = "/login", w = "/signup", T = "https://declarion.local";
52
- function re(e) {
53
- let t = e.split(/[?#]/, 1)[0];
54
- return t === C || t.startsWith(`${C}/`) || t === w || t.startsWith(`${w}/`);
55
- }
56
- function ie(e) {
57
- if (!e) return S;
58
- let t = e.toLowerCase();
59
- if (!e.startsWith("/") || e.startsWith("//") || e.includes("\\") || t.includes("%5c")) return S;
60
- try {
61
- let t = new URL(e, T);
62
- if (t.origin !== T) return S;
63
- let n = `${t.pathname}${t.search}${t.hash}`;
64
- return !n.startsWith("/") || n.startsWith("//") || n.includes("\\") ? S : n || S;
65
- } catch {
66
- return S;
67
- }
68
- }
69
- function ae(e) {
70
- let t = ie(e);
71
- return t === S || re(t) ? C : `${C}?next=${encodeURIComponent(t)}`;
72
- }
73
- function oe() {
74
- if (typeof window > "u") return C;
75
- let { pathname: e, search: t, hash: n } = window.location;
76
- return ae(`${e}${t}${n}`);
77
- }
78
- //#endregion
79
- //#region src/embed/protocol.ts
80
- var se = "declarion-embed", E = {
81
- ready: "ready",
82
- setToken: "set-token",
83
- tokenExpired: "token-expired",
84
- reloadRequired: "reload-required",
85
- resized: "resized",
86
- navigated: "navigated",
87
- navigationRequested: "navigation-requested",
88
- dirtyChanged: "dirty-changed",
89
- navigationFailed: "navigation-failed",
90
- navigate: "navigate",
91
- setTheme: "set-theme"
92
- };
93
- function D(e, t, n) {
94
- if (!e || typeof window > "u" || window.parent === window) return !1;
95
- let r = {
96
- source: se,
97
- protocol: 1,
98
- type: t,
99
- payload: n
100
- };
101
- return window.parent.postMessage(r, e), !0;
102
- }
103
- //#endregion
104
- //#region src/embed/token.ts
105
- var ce = 15e3, le = 5e3, O = {
106
- active: !1,
107
- parentOrigin: null,
108
- current: null,
109
- pending: null
110
- };
111
- function ue(e) {
112
- O.active = !0, O.parentOrigin = e;
113
- }
114
- function k() {
115
- return O.active;
116
- }
117
- function de() {
118
- return O.current?.token ?? null;
119
- }
120
- function fe() {
121
- return O.parentOrigin;
122
- }
123
- function pe() {
124
- return !O.current || Date.now() >= O.current.expiresAt - le;
125
- }
126
- function me(e) {
127
- if (!e.token || typeof e.token != "string") return;
128
- let t = Date.parse(e.expires_at);
129
- if (!Number.isNaN(t) && (O.current = {
130
- token: e.token,
131
- expiresAt: t
132
- }, O.pending)) {
133
- let t = O.pending;
134
- O.pending = null, clearTimeout(t.timer), t.resolve(e.token);
135
- }
136
- }
137
- function he() {
138
- O.current = null;
139
- }
140
- function ge() {
141
- if (!pe() && O.current) return Promise.resolve(O.current.token);
142
- if (O.pending) return O.pending.promise;
143
- let e, t, n = new Promise((n, r) => {
144
- e = n, t = r;
145
- }), r = setTimeout(() => {
146
- O.pending && O.pending.promise === n && (O.pending = null), t(/* @__PURE__ */ Error(`embed token wait timed out after ${ce}ms`));
147
- }, ce);
148
- return O.pending = {
149
- promise: n,
150
- resolve: e,
151
- reject: t,
152
- timer: r
153
- }, D(O.parentOrigin, E.tokenExpired, {}), n;
154
- }
155
- //#endregion
156
- //#region src/lib/versionTracker.ts
157
- var _e = "X-Declarion-Version", ve = "declarion-version";
158
- function ye() {
159
- if (typeof BroadcastChannel > "u") return null;
160
- try {
161
- return new BroadcastChannel(ve);
162
- } catch {
163
- return null;
164
- }
165
- }
166
- var A = {
167
- firstSeen: null,
168
- firstComponents: null,
169
- hasReportedDrift: !1,
170
- pendingReload: null,
171
- listeners: /* @__PURE__ */ new Set(),
172
- channel: null
173
- };
174
- function be() {
175
- A.channel || typeof BroadcastChannel > "u" || (A.channel = ye(), A.channel && A.channel.addEventListener("message", (e) => {
176
- let t = e.data;
177
- if (t && t.type === "drift" && t.delta && !A.hasReportedDrift) {
178
- A.hasReportedDrift = !0;
179
- for (let e of A.listeners) e(t.delta);
180
- }
181
- }));
182
- }
183
- function xe(e) {
184
- if (be(), !e) return;
185
- let t = e.get(_e);
186
- t && (A.firstSeen ? t !== A.firstSeen && (A.hasReportedDrift || Se().catch(() => {
187
- we({
188
- kind: "unknown",
189
- observed: t
190
- });
191
- })) : A.firstSeen = t);
192
- }
193
- async function Se() {
194
- be();
195
- let e;
196
- try {
197
- let t = {};
198
- A.firstSeen && (t["If-None-Match"] = `"${A.firstSeen}"`), e = await fetch("/api/version", {
199
- method: "GET",
200
- credentials: k() ? "omit" : "include",
201
- headers: t
202
- });
203
- } catch {
204
- throw Error("version probe network error");
205
- }
206
- if (e.status === 304) return;
207
- if (!e.ok) throw await x(e), Error(`version probe ${e.status}`);
208
- let t;
209
- try {
210
- t = await e.json();
211
- } catch {
212
- throw Error("version probe malformed body");
213
- }
214
- let n = t.fingerprint;
215
- if (typeof n != "string" || n === "") throw Error("version probe missing fingerprint");
216
- let r = typeof t.schema_fingerprint == "string" && typeof t.asset_fingerprint == "string" && typeof t.binary_fingerprint == "string" ? {
217
- schema: t.schema_fingerprint,
218
- asset: t.asset_fingerprint,
219
- binary: t.binary_fingerprint
220
- } : void 0;
221
- A.firstSeen ||= n, !A.firstComponents && r && n === A.firstSeen && (A.firstComponents = r), n !== A.firstSeen && we({
222
- kind: Ce(A.firstComponents, r),
223
- observed: n,
224
- components: r
225
- });
226
- }
227
- function Ce(e, t) {
228
- if (!e || !t) return "unknown";
229
- let n = e.schema !== t.schema, r = e.asset !== t.asset, i = e.binary !== t.binary;
230
- return n && !r && !i ? "schema-only" : r || i ? "asset-or-binary" : "unknown";
231
- }
232
- function we(e) {
233
- if (!A.hasReportedDrift) {
234
- A.hasReportedDrift = !0, e.kind !== "schema-only" && (A.pendingReload = e);
235
- for (let t of A.listeners) t(e);
236
- if (A.channel) try {
237
- A.channel.postMessage({
238
- type: "drift",
239
- delta: e
240
- });
241
- } catch {}
242
- k() && e.kind !== "schema-only" && D(fe(), E.reloadRequired, { reason: `version drift: ${e.kind}` });
243
- }
244
- }
245
- function Te() {
246
- return A.pendingReload;
247
- }
248
- function Ee(e) {
249
- return A.listeners.add(e), () => {
250
- A.listeners.delete(e);
251
- };
252
- }
253
- //#endregion
254
- //#region src/api/client.ts
255
- var De = (e) => JSON.stringify(e ?? {}), j = null, M = "declarion.auth.refresh.lock", N = "declarion.auth.refresh.result", Oe = "declarion.auth.refresh", ke = 3e4, Ae = 100, P = typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
256
- function je() {
257
- if (typeof window > "u") return !1;
258
- try {
259
- let e = window.localStorage, t = `${M}.probe`;
260
- return e.setItem(t, "1"), e.removeItem(t), !0;
261
- } catch {
262
- return !1;
263
- }
264
- }
265
- function Me() {
266
- return typeof navigator > "u" ? null : navigator.locks ?? null;
267
- }
268
- function Ne(e) {
269
- if (!e) return null;
270
- try {
271
- let t = JSON.parse(e);
272
- return typeof t.owner != "string" || typeof t.expires_at != "number" ? null : {
273
- owner: t.owner,
274
- expires_at: t.expires_at
275
- };
276
- } catch {
277
- return null;
278
- }
279
- }
280
- function Pe(e) {
281
- if (!e) return null;
282
- try {
283
- let t = JSON.parse(e);
284
- return typeof t.owner != "string" || typeof t.ok != "boolean" || typeof t.updated_at != "number" ? null : {
285
- owner: t.owner,
286
- ok: t.ok,
287
- status: typeof t.status == "number" ? t.status : void 0,
288
- updated_at: t.updated_at
289
- };
290
- } catch {
291
- return null;
292
- }
293
- }
294
- function Fe(e) {
295
- if (!je()) return null;
296
- let t = Pe(window.localStorage.getItem(N));
297
- return !t || t.updated_at < e ? null : t;
298
- }
299
- function Ie(e) {
300
- if (!e.ok) throw new F(e.status ?? 401);
301
- }
302
- function Le(e = Date.now()) {
303
- let t = Ne(window.localStorage.getItem(M));
304
- if (t && t.expires_at > e && t.owner !== P) return !1;
305
- let n = {
306
- owner: P,
307
- expires_at: e + ke
308
- };
309
- return window.localStorage.setItem(M, JSON.stringify(n)), Ne(window.localStorage.getItem(M))?.owner === P;
310
- }
311
- function Re() {
312
- Ne(window.localStorage.getItem(M))?.owner === P && window.localStorage.removeItem(M);
313
- }
314
- function ze(e) {
315
- let t = {
316
- owner: P,
317
- updated_at: Date.now(),
318
- ...e
319
- };
320
- window.localStorage.setItem(N, JSON.stringify(t));
321
- }
322
- async function Be(e) {
323
- return new Promise((t, n) => {
324
- let r = !1, i = null, a = (e) => {
325
- r || (r = !0, i && clearTimeout(i), window.removeEventListener("storage", c), t(e));
326
- }, o = (e) => {
327
- r || (r = !0, i && clearTimeout(i), window.removeEventListener("storage", c), n(new F(e)));
328
- }, s = () => {
329
- let t = Pe(window.localStorage.getItem(N));
330
- if (t && t.updated_at >= e) {
331
- t.ok ? a("complete") : o(t.status ?? 401);
332
- return;
333
- }
334
- let n = Ne(window.localStorage.getItem(M));
335
- n ? n.expires_at <= Date.now() ? a("expired") : i = setTimeout(s, Ae) : a("complete");
336
- }, c = (e) => {
337
- (e.key === M || e.key === N) && (i && clearTimeout(i), s());
338
- };
339
- window.addEventListener("storage", c), s();
340
- });
341
- }
342
- async function Ve(e) {
343
- let t = Me();
344
- return t ? (await t.request(Oe, { mode: "exclusive" }, async () => {
345
- let t = Fe(e);
346
- if (t) Ie(t);
347
- else try {
348
- await Je(), je() && ze({ ok: !0 });
349
- } catch (e) {
350
- throw e instanceof F && je() && ze({
351
- ok: !1,
352
- status: e.status
353
- }), e;
354
- }
355
- }), !0) : !1;
356
- }
357
- async function He() {
358
- let e = Date.now();
359
- if (!await Ve(e)) {
360
- if (!je()) await Je();
361
- else {
362
- if (Le(e)) try {
363
- await Je(), ze({ ok: !0 });
364
- return;
365
- } catch (e) {
366
- throw e instanceof F && ze({
367
- ok: !1,
368
- status: e.status
369
- }), e;
370
- } finally {
371
- Re();
372
- }
373
- await Be(e) === "expired" && await He();
374
- }
375
- }
376
- }
377
- var F = class extends Error {
378
- status;
379
- constructor(e) {
380
- super(`refresh failed terminally (${e})`), this.status = e, this.name = "RefreshDeadError";
381
- }
382
- }, I = null, L = null, Ue = 3e4, We = 5e3;
383
- function Ge() {
384
- Ye().catch((e) => {
385
- e instanceof F && B();
386
- });
387
- }
388
- function R(e) {
389
- if (z = null, I &&= (clearTimeout(I), null), L = null, !e || typeof window > "u") return;
390
- let t = Date.parse(e);
391
- if (Number.isNaN(t)) return;
392
- L = t;
393
- let n = Math.max(t - Date.now() - Ue, We);
394
- I = setTimeout(() => {
395
- I = null, Ge();
396
- }, n);
397
- }
398
- function Ke() {
399
- I &&= (clearTimeout(I), null), L = null;
400
- }
401
- typeof document < "u" && document.addEventListener("visibilitychange", () => {
402
- document.visibilityState === "visible" && L !== null && Date.now() >= L - Ue && Ge();
403
- });
404
- async function qe(e) {
405
- try {
406
- let t = await e.json();
407
- R(t?.result?.expires_at ?? t?.expires_at);
408
- } catch {}
409
- }
410
- async function Je() {
411
- let e = {
412
- method: "POST",
413
- credentials: "include",
414
- headers: { "Content-Type": "application/json" },
415
- body: De({})
416
- }, t = await fetch("/api/actions/auth.refresh", e);
417
- if (t.status === 429) {
418
- let n = parseInt(t.headers.get("Retry-After") || "1", 10);
419
- await new Promise((e) => setTimeout(e, n * 1e3));
420
- let r = await fetch("/api/actions/auth.refresh", e);
421
- if (!r.ok) throw await x(r), new F(r.status);
422
- await qe(r);
423
- } else {
424
- if (!t.ok) throw await x(t), new F(t.status);
425
- await qe(t);
426
- }
427
- }
428
- var z = null;
429
- async function Ye() {
430
- if (z !== null) throw new F(z);
431
- return j || (j = He().catch((e) => {
432
- throw e instanceof F && (z = e.status), e;
433
- }).finally(() => {
434
- j = null;
435
- }), j);
436
- }
437
- var B = () => {
438
- if (typeof window > "u") return;
439
- let { pathname: e } = window.location;
440
- e.startsWith("/login") || e.startsWith("/signup") || e === "/reset" || e === "/forgot" || e === "/2fa" || (window.location.href = oe());
441
- };
442
- function Xe(e) {
443
- let t = B;
444
- return B = e, t;
445
- }
446
- function Ze() {
447
- return B;
448
- }
449
- var Qe = ({ status: e, code: t, message: n }) => {
450
- console.error(`[API ${e}] ${t}: ${n}`);
451
- };
452
- function $e(e, t, n, r) {
453
- let i = new Headers(e);
454
- return !i.has("Content-Type") && t && i.set("Content-Type", "application/json"), n.setAccept && !i.has("Accept") && i.set("Accept", "*/*"), r && i.set("Authorization", `Bearer ${r}`), i;
455
- }
456
- var V = null, et = 0;
457
- function tt(e) {
458
- e || et++, V = e || null;
459
- }
460
- function nt() {
461
- return et;
462
- }
463
- function rt(e, t) {
464
- e === et && (V = t || null);
465
- }
466
- function it() {
467
- return V;
468
- }
469
- function at(e) {
470
- return !V || !e.startsWith("/api/") || /[?&]language=/.test(e) ? e : `${e}${e.includes("?") ? "&" : "?"}language=${encodeURIComponent(V)}`;
471
- }
472
- async function ot(e, t, n, r) {
473
- let i = at(e), a = k(), o = a ? "omit" : "include", s = $e(t.headers, !!t.body, n, a ? de() : null), c = await fetch(i, {
474
- ...t,
475
- headers: s,
476
- credentials: o
477
- });
478
- if (xe(c.headers), !c.ok) {
479
- let { raw: e, body: s } = await x(c), l = v(s.type), u = s.title ?? "";
480
- if (c.status === 401 && (l === "auth.token_refresh_needed" || l === "auth.unauthorized")) try {
481
- let e = null;
482
- a ? (he(), e = await ge()) : await Ye();
483
- let s = $e(t.headers, !!t.body, n, e), c = await fetch(i, {
484
- ...t,
485
- headers: s,
486
- credentials: o
487
- });
488
- if (!c.ok) {
489
- n.isSessionProbe || B();
490
- let e = await x(c);
491
- throw new _(c.status, e.body, e.raw);
492
- }
493
- return r(c);
494
- } catch (t) {
495
- throw t instanceof _ ? t : (n.isSessionProbe || B(), new _(401, s, e));
496
- }
497
- throw c.status === 401 && !n.isSessionProbe && B(), Qe({
498
- status: c.status,
499
- code: l,
500
- message: u
501
- }), new _(c.status, s, e);
502
- }
503
- return r(c);
504
- }
505
- function st(e) {
506
- return e.status === 204 ? Promise.resolve(void 0) : e.json();
507
- }
508
- async function H(e, t = {}) {
509
- return ot(e, t, {
510
- setAccept: !1,
511
- isSessionProbe: !1
512
- }, st);
513
- }
514
- async function ct(e) {
515
- return {
516
- blob: await e.blob(),
517
- filename: ut(e.headers),
518
- headers: e.headers
519
- };
520
- }
521
- async function lt(e, t = {}) {
522
- return ot(e, t, {
523
- setAccept: !0,
524
- isSessionProbe: !1
525
- }, ct);
526
- }
527
- function ut(e) {
528
- let t = e.get("Content-Disposition");
529
- if (!t) return "";
530
- let n = t.match(/filename\*\s*=\s*([^']*)'([^']*)'([^;]+)/i);
531
- if (n) try {
532
- return decodeURIComponent(n[3].trim());
533
- } catch {}
534
- let r = t.match(/filename\s*=\s*("([^"]+)"|([^;]+))/i);
535
- return r ? (r[2] ?? r[3] ?? "").trim() : "";
536
- }
537
- async function U(e, t = {}, { isSessionProbe: n = !1 } = {}) {
538
- return (await ot(`/api/actions/${encodeURIComponent(e)}`, {
539
- method: "POST",
540
- body: De(t)
541
- }, {
542
- setAccept: !1,
543
- isSessionProbe: n
544
- }, st)).result;
545
- }
546
- //#endregion
547
- //#region src/types/ordmap.ts
548
- var W = class e {
549
- #e;
550
- #t;
551
- constructor(e) {
552
- this.#e = e;
553
- let t = /* @__PURE__ */ new Map();
554
- for (let n = 0; n < e.length; n++) {
555
- let r = e[n].name;
556
- r !== void 0 && t.set(r, n);
557
- }
558
- this.#t = t;
559
- }
560
- static fromObject(t) {
561
- return e.#n(t);
562
- }
563
- static fromWire(t) {
564
- return e.#n(t);
565
- }
566
- static #n(t) {
567
- if (!t) return new e([]);
568
- let n = [];
569
- for (let [e, r] of Object.entries(t)) n.push({
570
- ...r,
571
- name: e
572
- });
573
- return new e(n);
574
- }
575
- get length() {
576
- return this.#e.length;
577
- }
578
- has(e) {
579
- return this.#t.has(e);
580
- }
581
- get(e) {
582
- let t = this.#t.get(e);
583
- return t === void 0 ? void 0 : this.#e[t];
584
- }
585
- items() {
586
- return this.#e;
587
- }
588
- names() {
589
- return this.#e.map((e) => e.name ?? "");
590
- }
591
- *[Symbol.iterator]() {
592
- for (let e of this.#e) yield [e.name ?? "", e];
593
- }
594
- };
595
- //#endregion
596
- //#region src/lib/display-value.ts
597
- function G(e) {
598
- if (e == null) return "";
599
- switch (typeof e) {
600
- case "string": return e;
601
- case "number":
602
- case "boolean":
603
- case "bigint":
604
- case "symbol": return String(e);
605
- case "object": try {
606
- return JSON.stringify(e);
607
- } catch {
608
- return "[unserializable]";
609
- }
610
- default: return "";
611
- }
612
- }
613
- //#endregion
614
- //#region src/lib/timestamp.ts
615
- function dt(e = /* @__PURE__ */ new Date()) {
616
- return d(e);
617
- }
618
- function ft(e, t, n) {
619
- let r = e.match(/([+-]\d{2}:\d{2})$/), i = e.endsWith("Z"), a = new Date(e);
620
- if (isNaN(a.getTime())) return e;
621
- if (r || i) {
622
- let e;
623
- if (i) e = "UTC";
624
- else if (r) {
625
- let t = r[1].charAt(0), n = parseInt(r[1].substring(1, 3), 10);
626
- parseInt(r[1].substring(4, 6), 10) === 0 && (e = n === 0 ? "UTC" : `Etc/GMT${t === "+" ? "-" : "+"}${n}`);
627
- }
628
- if (e) try {
629
- return new Intl.DateTimeFormat(n, {
630
- ...t,
631
- timeZone: e
632
- }).format(a);
633
- } catch {}
634
- if (r) {
635
- let e = r[1].charAt(0) === "+" ? 1 : -1, i = parseInt(r[1].substring(1, 3), 10), o = parseInt(r[1].substring(4, 6), 10), s = e * (i * 60 + o) * 60 * 1e3;
636
- return new Intl.DateTimeFormat(n, {
637
- ...t,
638
- timeZone: "UTC"
639
- }).format(new Date(a.getTime() + s));
640
- }
641
- }
642
- return new Intl.DateTimeFormat(n, t).format(a);
643
- }
644
- function pt(e) {
645
- return ft(e, {
646
- day: "2-digit",
647
- month: "2-digit",
648
- year: "numeric",
649
- hour: "2-digit",
650
- minute: "2-digit",
651
- hour12: !1
652
- }, "en-GB").replace(/\//g, "-").replace(",", "");
653
- }
654
- function mt(e, t, n = /* @__PURE__ */ new Date()) {
655
- if (t == null || t === "") return {
656
- text: "—",
657
- absolute: ""
658
- };
659
- let r = t instanceof Date ? t : new Date(String(t));
660
- if (isNaN(r.getTime())) {
661
- let e = String(t);
662
- return {
663
- text: e,
664
- absolute: e
665
- };
666
- }
667
- let i = pt(typeof t == "string" ? t : r.toISOString()), a = n.getTime() - r.getTime();
668
- return Math.abs(a) > 2592e6 ? {
669
- text: d(r, { representation: "date" }),
670
- absolute: i
671
- } : {
672
- text: _t(e, r, n),
673
- absolute: i
674
- };
675
- }
676
- var ht = [
677
- {
678
- unit: "second",
679
- ms: 1e3,
680
- limit: 60
681
- },
682
- {
683
- unit: "minute",
684
- ms: 6e4,
685
- limit: 60
686
- },
687
- {
688
- unit: "hour",
689
- ms: 36e5,
690
- limit: 24
691
- }
692
- ], gt = 864e5;
693
- function _t(e, t, n) {
694
- let r = t.getTime() - n.getTime(), i = new Intl.RelativeTimeFormat(e, { numeric: "always" }), a = (e) => r > 0 ? e : -e;
695
- for (let { unit: e, ms: t, limit: n } of ht) {
696
- let o = Math.round(Math.abs(r) / t);
697
- if (o < n) return i.format(a(o), e);
698
- }
699
- return i.format(a(Math.round(Math.abs(r) / gt)), "day");
700
- }
701
- var vt = "$display";
702
- function yt(e, t, n) {
703
- if (!t) return;
704
- let r = t[vt];
705
- if (typeof r == "string" && r !== "") return r;
706
- let i = n?.display?.display_field;
707
- if (!i) return;
708
- let a = t[i];
709
- if (a == null) return;
710
- let o = n?.fields?.get(i);
711
- if (o?.type === "timestamp" && typeof a == "string" && a !== "") return pt(a);
712
- let s = o?.values;
713
- if (s && (typeof a == "string" || typeof a == "number")) {
714
- let t = s.find((e) => e.code === String(a));
715
- if (t) {
716
- let n = e(t.name);
717
- if (n) return n;
718
- }
719
- }
720
- return typeof a == "object" && !Array.isArray(a) ? e(a) || void 0 : G(a);
721
- }
722
- function bt(e, t, n, r) {
723
- if (!n) return r;
724
- let i = t[n];
725
- return i == null ? r : typeof i == "object" && !Array.isArray(i) ? e(i) || r : G(i);
726
- }
727
- function xt(e) {
728
- let t = e.replace(/\/+$/, "").split("/").map((e) => e.startsWith(":") ? "[^/]+" : e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
729
- return RegExp("^" + t.join("/") + "$");
730
- }
731
- function St(e) {
732
- let t = (() => {
733
- try {
734
- return decodeURIComponent(e);
735
- } catch {
736
- return e;
737
- }
738
- })().split("-")[0];
739
- return t.length > 8 ? t.slice(0, 8) : t;
740
- }
741
- function Ct(e, t, n, r) {
742
- if (!n) return;
743
- let i = t.replace(/\/+$/, "") || "/", a;
744
- for (let t of Object.values(n)) {
745
- if (!t.route || !xt(t.route).test(i)) continue;
746
- let n = t.route.includes("/:"), o = e(t.display?.name);
747
- if (!o && !n && r && t.entity && (o = e(r[t.entity]?.display?.name_plural)), !o && n && r && t.entity) {
748
- let n = e(r[t.entity]?.display?.name);
749
- if (n) {
750
- let e = i.slice(i.lastIndexOf("/") + 1);
751
- o = e ? `${n} ${St(e)}` : n;
752
- }
753
- }
754
- if (!o) continue;
755
- let s = {
756
- title: o,
757
- icon: t.display?.icon,
758
- exact: !n
759
- };
760
- if (!n) return s;
761
- a ??= s;
762
- }
763
- return a;
764
- }
765
- function wt(e, t, n, r) {
766
- let i = e(t.display?.name);
767
- if (i) return i;
768
- if (t.type === "ref" && t.ref?.entity && r) {
769
- let n = r[t.ref.entity];
770
- if (n) {
771
- let t = e(n.display?.name);
772
- if (t) return t;
773
- }
774
- }
775
- return n;
776
- }
777
- function Tt(e) {
778
- if (e != null) return typeof e == "string" ? { entity: e } : e;
779
- }
780
- function Et(e, t) {
781
- let n = e ?? [];
782
- if (!t) return n;
783
- switch (t.mode ?? "append") {
784
- case "replace": return t.values ?? [];
785
- case "clear": return [];
786
- default: return [...n, ...t.values ?? []];
787
- }
788
- }
789
- function Dt(e) {
790
- let t = e.name, n = e.display ? {
791
- ...e.display,
792
- name: e.display.name ?? t
793
- } : { name: t };
794
- return {
795
- type: e.type,
796
- display: n,
797
- values: e.values,
798
- ref: e.ref,
799
- structure: e.structure
800
- };
801
- }
802
- function Ot(e, t) {
803
- return !e || e.readonly ? !1 : e.mutations?.[t] ?? !0;
804
- }
805
- function kt(e) {
806
- return !e?.disable_defaults?.includes("__new");
807
- }
808
- function K(e) {
809
- if (e.primary_key && e.primary_key.length > 0) return e.primary_key;
810
- for (let [t, n] of e.fields) if (n.primary) return [t];
811
- return ["id"];
812
- }
813
- function At(e, t) {
814
- let n = K(e), r = {};
815
- for (let e of n) r[e] = G(t[e]);
816
- return r;
817
- }
818
- function jt(e) {
819
- return e.length === 1 ? e[0] : JSON.stringify(e);
820
- }
821
- function Mt(e) {
822
- return jt(Object.values(e));
823
- }
824
- function Nt(e, t) {
825
- return jt(K(e).map((e) => t[e] ?? ""));
826
- }
827
- function Pt(e, t) {
828
- let n = K(e);
829
- if (n.length === 1) return { [n[0]]: t };
830
- }
831
- function Ft(e, t) {
832
- if (t <= 1) return [e];
833
- try {
834
- let n = JSON.parse(e);
835
- if (Array.isArray(n) && n.length === t && n.every((e) => typeof e == "string")) return n;
836
- } catch {
837
- return null;
838
- }
839
- return null;
840
- }
841
- function It(e, t, n) {
842
- if (e?.detail_screen === "none") return null;
843
- let r = e?.detail_screen ?? t?.detail_screen;
844
- return r ? n?.[r]?.route ?? null : null;
845
- }
846
- function Lt(e, t, n, r) {
847
- if (!t) return null;
848
- let i = It(e, n, r);
849
- return i ? i.replace(":id", encodeURIComponent(t)) : null;
850
- }
851
- function Rt(e, t, n, r) {
852
- return !t || K(t).some((e) => !r[e]) ? null : Lt(e, Nt(t, r), t, n);
853
- }
854
- function zt(e, t, n, r) {
855
- return t ? Rt(e, t, n, At(t, r)) : null;
856
- }
857
- function Bt(e) {
858
- return K(e).length > 1;
859
- }
860
- //#endregion
861
- //#region src/api/schema.ts
862
- function Vt(e) {
863
- return {
864
- ...e,
865
- params: e.params ? W.fromWire(e.params) : void 0
866
- };
867
- }
868
- function Ht(e) {
869
- return {
870
- ...e,
871
- resolved_params: e.resolved_params ? W.fromWire(e.resolved_params) : void 0
872
- };
873
- }
874
- function Ut(e) {
875
- let t = {};
876
- if (e.handlers) for (let [n, r] of Object.entries(e.handlers)) t[n] = Vt(r);
877
- let n = {};
878
- if (e.actions) for (let [t, r] of Object.entries(e.actions)) n[t] = Ht(r);
879
- return {
880
- ...e,
881
- fields: W.fromWire(e.fields),
882
- files: e.files ? W.fromWire(e.files) : void 0,
883
- variants: e.variants ? W.fromWire(e.variants) : void 0,
884
- handlers: e.handlers ? t : void 0,
885
- actions: e.actions ? n : void 0
886
- };
887
- }
888
- function Wt(e) {
889
- let t = {};
890
- if (e.entities) for (let [n, r] of Object.entries(e.entities)) t[n] = Ut(r);
891
- let n = {};
892
- if (e.structures) for (let [t, r] of Object.entries(e.structures)) n[t] = {
893
- ...r,
894
- fields: W.fromWire(r.fields)
895
- };
896
- let r = {};
897
- if (e.handlers) for (let [t, n] of Object.entries(e.handlers)) r[t] = Vt(n);
898
- let i = {};
899
- if (e.actions) for (let [t, n] of Object.entries(e.actions)) i[t] = Ht(n);
900
- let a = { ...e.screens };
901
- for (let [e, t] of Object.entries(a)) {
902
- let n = t;
903
- a[e] = {
904
- ...t,
905
- variants: n.variants ? W.fromWire(n.variants) : void 0
906
- };
907
- }
908
- return {
909
- ...e,
910
- entities: t,
911
- structures: n,
912
- handlers: r,
913
- actions: i,
914
- screens: a
915
- };
916
- }
917
- async function Gt() {
918
- let e = nt(), t = Wt(await H("/api/schema", { cache: "no-cache" }));
919
- return rt(e, t.language), t;
920
- }
921
- //#endregion
922
- //#region src/lib/html-state.ts
923
- function Kt(e) {
924
- typeof document < "u" && (document.documentElement.dataset.viewport = e);
925
- }
926
- function qt(e) {
927
- typeof document < "u" && (document.documentElement.dataset.embed = e ? "true" : "false");
928
- }
929
- //#endregion
930
- //#region src/embed/params.ts
931
- var Jt = "self", Yt = "embed", Xt = "parent_origin", Zt = "theme", Qt = [
932
- Yt,
933
- Xt,
934
- Zt,
935
- "nav"
936
- ];
937
- function $t(e) {
938
- if (!e) return null;
939
- let t;
940
- try {
941
- t = new URL(e);
942
- } catch {
943
- return null;
944
- }
945
- return t.origin === "null" ? null : e === t.origin ? t.origin : null;
946
- }
947
- function en(e) {
948
- return e === "light" || e === "dark" ? e : null;
949
- }
950
- function tn(e) {
951
- return e === "delegated" ? "delegated" : Jt;
952
- }
953
- function nn(e) {
954
- let t = typeof e == "string" ? new URLSearchParams(e) : e;
955
- return {
956
- enabled: t.get(Yt) === "1",
957
- parentOrigin: $t(t.get(Xt)),
958
- theme: en(t.get(Zt)),
959
- navigationMode: tn(t.get("nav"))
960
- };
961
- }
962
- function rn(e, t) {
963
- if (!t.enabled) return e;
964
- let n = /^[a-z][a-z0-9+.-]*:/i.test(e), r;
965
- try {
966
- r = new URL(e, "http://embed.invalid");
967
- } catch {
968
- return e;
969
- }
970
- let i = r.searchParams;
971
- return t.enabled && i.set(Yt, "1"), t.parentOrigin && i.set(Xt, t.parentOrigin), t.theme && i.set(Zt, t.theme), i.set("nav", t.navigationMode), n ? r.toString() : `${r.pathname}${r.search}${r.hash}`;
972
- }
973
- //#endregion
974
- //#region src/embed/EmbedContext.tsx
975
- var an = n({
976
- enabled: !1,
977
- parentOrigin: null,
978
- theme: null,
979
- navigationMode: "self",
980
- appendEmbedParams: (e) => e
981
- });
982
- function on(e) {
983
- return {
984
- enabled: e.enabled,
985
- parentOrigin: e.parentOrigin,
986
- theme: e.theme,
987
- navigationMode: e.navigationMode,
988
- appendEmbedParams: (t) => rn(t, e)
989
- };
990
- }
991
- function sn({ children: e, query: t }) {
992
- let n = s(() => on(nn(t ?? (typeof window < "u" ? window.location.search : ""))), [t]);
993
- return o(() => {
994
- qt(n.enabled);
995
- }, [n.enabled]), /* @__PURE__ */ f(an.Provider, {
996
- value: n,
997
- children: e
998
- });
999
- }
1000
- function q() {
1001
- return a(an);
1002
- }
1003
- //#endregion
1004
- //#region src/api/auth.ts
1005
- async function cn() {
1006
- return U("auth.check_setup");
1007
- }
1008
- async function ln(e, t, n = !0) {
1009
- let r = await U("auth.login", {
1010
- email: e,
1011
- password: t,
1012
- remember: n
1013
- });
1014
- return R(r.expires_at), r;
1015
- }
1016
- async function un(e, t, n) {
1017
- let r = await U("auth.signup", {
1018
- email: e,
1019
- password: t,
1020
- display_name: n
1021
- });
1022
- return R(r.expires_at), r;
1023
- }
1024
- async function dn() {
1025
- return U("auth.me");
1026
- }
1027
- async function fn() {
1028
- return U("auth.me", {}, { isSessionProbe: !0 });
1029
- }
1030
- async function pn() {
1031
- return (await U("auth.list_tenants")).tenants;
1032
- }
1033
- async function mn(e) {
1034
- let t = await U("auth.switch_tenant", { tenant_id: e });
1035
- return R(t.expires_at), t;
1036
- }
1037
- async function hn() {
1038
- await U("auth.logout");
1039
- }
1040
- async function gn(e) {
1041
- return (await U("sso_provider.list", e ? { tenant_code: e } : {})).providers;
1042
- }
1043
- function _n(e, t, n) {
1044
- let r = new URLSearchParams();
1045
- t && r.set("tenant", t), n && r.set("redirect", n);
1046
- let i = r.toString();
1047
- return `/api/auth/sso/authorize/${encodeURIComponent(e)}${i ? `?${i}` : ""}`;
1048
- }
1049
- async function vn(e, t, n) {
1050
- let r = {
1051
- target_user_id: e,
1052
- reason: t
1053
- };
1054
- return n != null && (r.duration_minutes = n), U("impersonation.start", r);
1055
- }
1056
- async function yn() {
1057
- return U("impersonation.stop");
1058
- }
1059
- async function bn(e) {
1060
- await U("impersonation.revoke", { session_id: e });
1061
- }
1062
- async function xn(e, t) {
1063
- await U("auth.change_password", {
1064
- current_password: e,
1065
- new_password: t
1066
- });
1067
- }
1068
- //#endregion
1069
- //#region src/stores/auth.ts
1070
- async function Sn(e, t) {
1071
- try {
1072
- let n = await t(), r = await pn().catch(() => []);
1073
- e({
1074
- user: n,
1075
- isAuthenticated: !0,
1076
- isLoading: !1,
1077
- activeTenant: n.tenant ?? null,
1078
- tenants: r
1079
- });
1080
- } catch {
1081
- e({
1082
- user: null,
1083
- isAuthenticated: !1,
1084
- isLoading: !1
1085
- });
1086
- }
1087
- }
1088
- var Cn = m((e) => ({
1089
- user: null,
1090
- isAuthenticated: !1,
1091
- isLoading: !0,
1092
- activeTenant: null,
1093
- tenants: [],
1094
- initialize: () => Sn(e, fn),
1095
- reloadSession: () => Sn(e, dn),
1096
- refreshMe: async () => {
1097
- try {
1098
- let t = await dn();
1099
- e({
1100
- user: t,
1101
- activeTenant: t.tenant ?? null
1102
- });
1103
- } catch {}
1104
- },
1105
- setUser: (t, n) => {
1106
- e({
1107
- user: t,
1108
- isAuthenticated: !0,
1109
- isLoading: !1,
1110
- activeTenant: n ?? null
1111
- });
1112
- },
1113
- setTenants: (t) => {
1114
- e({ tenants: t });
1115
- },
1116
- setActiveTenant: (t) => {
1117
- e({ activeTenant: t });
1118
- },
1119
- logout: async () => {
1120
- Ke();
1121
- try {
1122
- await hn();
1123
- } catch {}
1124
- e({
1125
- user: null,
1126
- isAuthenticated: !1,
1127
- activeTenant: null,
1128
- tenants: []
1129
- });
1130
- }
1131
- }));
1132
- Cn.subscribe((e, t) => {
1133
- e.isAuthenticated !== t.isAuthenticated && tt(null);
1134
- });
1135
- //#endregion
1136
- //#region src/hooks/useSchema.ts
1137
- function J() {
1138
- let e = Cn((e) => e.isAuthenticated), t = q().enabled;
1139
- return u({
1140
- queryKey: ["schema", e],
1141
- queryFn: Gt,
1142
- staleTime: Infinity,
1143
- enabled: e || !t
1144
- });
1145
- }
1146
- //#endregion
1147
- //#region src/lib/language.ts
1148
- var wn = "en", Tn = "ui_language";
1149
- function En(e, t, n) {
1150
- if (e) for (let r of [
1151
- t,
1152
- n,
1153
- "en"
1154
- ]) {
1155
- let t = e[r];
1156
- if (t) return [r, t];
1157
- }
1158
- }
1159
- function Dn(e, t, n) {
1160
- return En(e, t, n)?.[1];
1161
- }
1162
- function On(e, t, n) {
1163
- function r(r, i, a) {
1164
- if (typeof r != "string") return Dn(r, t, n) ?? "";
1165
- let o = Dn(e?.[r], t, n) ?? i ?? "";
1166
- return a ? o.replace(/\{(\w+)\}/g, (e, t) => Object.hasOwn(a, t) ? String(a[t]) : e) : o;
1167
- }
1168
- return Object.assign(r, {
1169
- language: t,
1170
- deploymentLanguage: n
1171
- });
1172
- }
1173
- function kn(e, t, n, r, i) {
1174
- let a = new Intl.PluralRules(e.language).select(n), o = {
1175
- ...i,
1176
- count: new Intl.NumberFormat(e.language).format(n)
1177
- };
1178
- return e(`${t}.${a}`, "", o) || e(`${t}.other`, a === "one" ? r.one : r.other, o);
1179
- }
1180
- function An(e, n) {
1181
- return e.split(/(\{[A-Za-z_][A-Za-z0-9_]*\})/).filter((e) => e !== "").map((e, i) => {
1182
- let a = /^\{(\w+)\}$/.exec(e)?.[1];
1183
- return r(t, { key: i }, a !== void 0 && Object.hasOwn(n, a) ? n[a] : e);
1184
- });
1185
- }
1186
- //#endregion
1187
- //#region src/hooks/useLanguage.ts
1188
- function jn() {
1189
- let { data: e } = J();
1190
- return e?.language || "en";
1191
- }
1192
- function Mn() {
1193
- let { data: e } = J();
1194
- return e?.deployment_language || "en";
1195
- }
1196
- async function Nn(e) {
1197
- let t = it();
1198
- tt(null), await e.refetchQueries({
1199
- queryKey: ["schema"],
1200
- type: "active"
1201
- }), it() !== t && await e.invalidateQueries({ predicate: (e) => e.queryKey[0] !== "schema" });
1202
- }
1203
- //#endregion
1204
- //#region src/hooks/useText.ts
1205
- function Pn(e = "messages") {
1206
- let { data: t } = J(), n = jn(), r = Mn(), i = e === "errors" ? t?.errors : t?.messages;
1207
- return s(() => On(i, n, r), [
1208
- i,
1209
- n,
1210
- r
1211
- ]);
1212
- }
1213
- //#endregion
1214
- //#region src/lib/viewport-category.ts
1215
- var Fn = {
1216
- phoneMax: 639,
1217
- tabletMax: 1023,
1218
- landscapePhoneMaxHeight: 520
1219
- };
1220
- function In(e, t = Fn) {
1221
- let { width: n, height: r, touch: i = !1 } = e;
1222
- return !Number.isFinite(n) || n <= 0 ? "desktop" : n <= t.phoneMax ? "phone" : n <= t.tabletMax ? i && Number.isFinite(r) && r > 0 && r <= t.landscapePhoneMaxHeight ? "phone" : "tablet" : "desktop";
1223
- }
1224
- //#endregion
1225
- //#region src/hooks/useResponsiveMode.tsx
1226
- var Y = {
1227
- width: 1280,
1228
- height: 720
1229
- }, Ln = n({
1230
- ...Y,
1231
- category: "desktop",
1232
- isPhone: !1,
1233
- isTablet: !1,
1234
- isDesktop: !0,
1235
- touch: !1
1236
- });
1237
- function Rn(e) {
1238
- return {
1239
- width: Number.isFinite(e.width) && e.width > 0 ? e.width : Y.width,
1240
- height: Number.isFinite(e.height) && e.height > 0 ? e.height : Y.height,
1241
- touch: e.touch ?? !1
1242
- };
1243
- }
1244
- function zn() {
1245
- if (typeof window > "u") return !1;
1246
- let e = window.matchMedia?.("(pointer: coarse)")?.matches ?? !1, t = window.navigator?.maxTouchPoints ?? 0;
1247
- return e || t > 0;
1248
- }
1249
- function Bn() {
1250
- if (typeof window > "u") return Y;
1251
- let e = window.visualViewport;
1252
- return Rn({
1253
- width: e?.width ?? window.innerWidth,
1254
- height: e?.height ?? window.innerHeight,
1255
- touch: zn()
1256
- });
1257
- }
1258
- function Vn(e, t, n) {
1259
- if (typeof document > "u") return;
1260
- let r = document.documentElement;
1261
- r.style.setProperty("--app-viewport-width", `${Math.round(e.width)}px`), r.style.setProperty("--app-viewport-height", `${Math.round(e.height)}px`), r.style.setProperty("--app-height", `${Math.round(e.height)}px`);
1262
- let i = t === "phone" || e.height <= n.landscapePhoneMaxHeight;
1263
- r.style.setProperty("--control-height", i ? "38px" : "30px"), r.style.setProperty("--control-line-height", i ? "36px" : "28px"), r.style.setProperty("--control-font-size", i ? "16px" : "12.5px");
1264
- }
1265
- function Hn({ children: e, breakpoints: t = Fn, viewportOverride: n, viewport: r = "auto" }) {
1266
- let [i, a] = l(() => Rn(n ?? Bn())), c = r === "auto" ? In(i, t) : r;
1267
- o(() => {
1268
- if (n) {
1269
- let e = Rn(n);
1270
- a(e), Vn(e, c, t);
1271
- return;
1272
- }
1273
- let e = () => {
1274
- let e = Bn();
1275
- a(e), Vn(e, c, t);
1276
- };
1277
- return e(), window.addEventListener("resize", e), window.addEventListener("orientationchange", e), window.visualViewport?.addEventListener("resize", e), window.visualViewport?.addEventListener("scroll", e), () => {
1278
- window.removeEventListener("resize", e), window.removeEventListener("orientationchange", e), window.visualViewport?.removeEventListener("resize", e), window.visualViewport?.removeEventListener("scroll", e);
1279
- };
1280
- }, [
1281
- n,
1282
- c,
1283
- t
1284
- ]), o(() => {
1285
- Kt(c);
1286
- }, [c]);
1287
- let u = s(() => ({
1288
- ...i,
1289
- category: c,
1290
- isPhone: c === "phone",
1291
- isTablet: c === "tablet",
1292
- isDesktop: c === "desktop",
1293
- touch: i.touch ?? !1
1294
- }), [c, i]);
1295
- return /* @__PURE__ */ f(Ln.Provider, {
1296
- value: u,
1297
- children: e
1298
- });
1299
- }
1300
- function Un() {
1301
- return a(Ln);
1302
- }
1303
- //#endregion
1304
- //#region src/api/data.ts
1305
- function Wn(e, t) {
1306
- let n = new URL(`/api/data/${e}`, window.location.origin);
1307
- if (t.page && n.searchParams.set("page", String(t.page)), t.per_page && n.searchParams.set("per_page", String(t.per_page)), t.sort && n.searchParams.set("sort", t.sort), t.search && n.searchParams.set("search", t.search), t.filters && t.filters.length > 0 && n.searchParams.set("filters", JSON.stringify(t.filters)), t.include_deleted && n.searchParams.set("include_deleted", "true"), t.expand) for (let e of t.expand) n.searchParams.append("expand", e);
1308
- return t.select && t.select.length > 0 && n.searchParams.set("select", t.select.join(",")), t.screen && n.searchParams.set("screen", t.screen), t.preview && n.searchParams.set("preview", "true"), t.count && n.searchParams.set("count", t.count), n.pathname + n.search;
1309
- }
1310
- async function Gn(e, t = {}, n = {}) {
1311
- if (ar) {
1312
- let n = ar(e, t);
1313
- if (n !== void 0) return n;
1314
- }
1315
- return H(Wn(e, t), { signal: n.signal });
1316
- }
1317
- async function Kn(e, t, n = {}) {
1318
- if (or) {
1319
- let n = or(e, t);
1320
- if (n !== void 0) return n;
1321
- }
1322
- let r = new URLSearchParams();
1323
- if (typeof t == "string") r.set("id", t);
1324
- else for (let [e, n] of Object.entries(t)) r.set(e, n);
1325
- return n.expand?.length && r.set("expand", n.expand.join(",")), H(`/api/data/${e}?${r.toString()}`);
1326
- }
1327
- async function qn(e, t) {
1328
- return { data: ((await X(`${e}.__create`, {
1329
- entity: e,
1330
- fields: t
1331
- })).result?.rows ?? [])[0] };
1332
- }
1333
- async function Jn(e, t, n) {
1334
- let r = typeof t == "string" ? t : Xn(t);
1335
- return { data: ((await X(`${e}.__update`, {
1336
- object_ids: [r],
1337
- entity: e,
1338
- fields: n
1339
- })).result?.rows ?? [])[0] };
1340
- }
1341
- async function Yn(e, t) {
1342
- let n = typeof t == "string" ? t : Xn(t);
1343
- await X(`${e}.__delete`, {
1344
- object_ids: [n],
1345
- entity: e
1346
- });
1347
- }
1348
- function Xn(e) {
1349
- let t = Object.values(e);
1350
- return t.length === 1 ? t[0] : t.join("");
1351
- }
1352
- async function Zn(e, t) {
1353
- let n = typeof t == "string" ? t : Xn(t);
1354
- await X(`${e}.__restore`, {
1355
- object_ids: [n],
1356
- entity: e
1357
- });
1358
- }
1359
- async function Qn(e, t) {
1360
- let n = await lt(`/api/data/${e}/export`, {
1361
- method: "POST",
1362
- body: JSON.stringify(t)
1363
- });
1364
- return {
1365
- blob: n.blob,
1366
- filename: n.filename
1367
- };
1368
- }
1369
- function $n(e) {
1370
- return !!e && ((e.failed_count ?? 0) > 0 || (e.timed_out_count ?? 0) > 0);
1371
- }
1372
- var er = class extends Error {
1373
- status;
1374
- response;
1375
- constructor(e, t) {
1376
- super(t.errors?.[0]?.error?.title ?? ""), this.name = "ActionBatchError", this.status = e, this.response = t;
1377
- }
1378
- };
1379
- function tr(e) {
1380
- if (!e || typeof e != "object") return !1;
1381
- let t = e;
1382
- return typeof t.status == "string" && Array.isArray(t.errors);
1383
- }
1384
- function nr(e, t) {
1385
- let n = { ...e ?? {} };
1386
- if ("object_ids" in n) throw Error("handler param \"object_ids\" collides with reserved key");
1387
- return t !== void 0 && (n.object_ids = t), n;
1388
- }
1389
- var rr = null;
1390
- function ir(e) {
1391
- let t = rr;
1392
- return rr = e, t;
1393
- }
1394
- var ar = null, or = null;
1395
- function sr(e) {
1396
- let t = ar;
1397
- return ar = e, t;
1398
- }
1399
- function cr(e) {
1400
- let t = or;
1401
- return or = e, t;
1402
- }
1403
- async function X(e, t) {
1404
- if (rr) return rr(e, t);
1405
- try {
1406
- return await H(`/api/actions/${e}`, {
1407
- method: "POST",
1408
- body: JSON.stringify(t)
1409
- });
1410
- } catch (e) {
1411
- throw e instanceof _ && tr(e.raw) ? new er(e.status, e.raw) : e;
1412
- }
1413
- }
1414
- async function lr(e, t) {
1415
- let n = new URLSearchParams();
1416
- return n.set("ids", t.join(",")), H(`/api/associations/${e}?${n.toString()}`);
1417
- }
1418
- //#endregion
1419
- //#region src/lib/safe-url.ts
1420
- var ur = [
1421
- "http:",
1422
- "https:",
1423
- "mailto:"
1424
- ], dr = /[\u0000-\u001f\u007f]/g;
1425
- function fr(e) {
1426
- if (!e) return;
1427
- let t = e.trim();
1428
- if (!t) return;
1429
- let n = t.replace(dr, "");
1430
- if (!n || n.startsWith("//")) return;
1431
- let r = n.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);
1432
- if (r) {
1433
- let e = r[1].toLowerCase() + ":";
1434
- if (!ur.includes(e)) return;
1435
- }
1436
- return n;
1437
- }
1438
- function pr(e) {
1439
- if (!e) return !1;
1440
- if (e.startsWith("//")) return !0;
1441
- let t = typeof window < "u" ? window.location.href : "http://localhost/", n;
1442
- try {
1443
- n = new URL(e, t);
1444
- } catch {
1445
- return !1;
1446
- }
1447
- if (n.protocol !== "http:" && n.protocol !== "https:") return !0;
1448
- let r = typeof window < "u" ? window.location.origin : "http://localhost";
1449
- return n.origin !== r;
1450
- }
1451
- //#endregion
1452
- //#region src/lib/download.ts
1453
- var mr = class extends Error {
1454
- code;
1455
- constructor(e, t) {
1456
- super(e), this.code = t, this.name = "DownloadError";
1457
- }
1458
- };
1459
- function hr(e) {
1460
- return e instanceof mr && e.code === "file.not_found";
1461
- }
1462
- async function gr(e, t, n) {
1463
- let r = fr(t);
1464
- if (!r) throw new mr(e("file.download_url_unsafe", "This download address is not allowed."));
1465
- let i = await fetch(at(r), { credentials: "same-origin" });
1466
- if (!i.ok) {
1467
- let t = await vr(i);
1468
- throw new mr(t.message || e("file.download_failed", "The file could not be downloaded."), t.code);
1469
- }
1470
- _r(await i.blob(), n);
1471
- }
1472
- function _r(e, t) {
1473
- let n = URL.createObjectURL(e), r = document.createElement("a");
1474
- r.href = n, t && (r.download = t), document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 0);
1475
- }
1476
- async function vr(e) {
1477
- try {
1478
- let t = JSON.parse(await e.text());
1479
- if (y(t)) return {
1480
- code: v(t.type),
1481
- message: t.title
1482
- };
1483
- } catch {
1484
- return {};
1485
- }
1486
- return {};
1487
- }
1488
- //#endregion
1489
- //#region src/lib/failure.ts
1490
- function yr(e, t) {
1491
- return t instanceof _ ? t.message || e(t.code, "") || e("platform.unavailable", "This service is temporarily unavailable.") : t instanceof er ? t.message || e("action.all_items_failed", "The action failed for every selected record.") : t instanceof mr ? t.message : e("platform.internal_error", "Something went wrong on our side.");
1492
- }
1493
- //#endregion
1494
- //#region src/embed/embed-dirty.ts
1495
- var br = m((e) => ({
1496
- isDirty: !1,
1497
- setDirty: (t) => e((e) => e.isDirty === t ? e : { isDirty: t })
1498
- }));
1499
- function xr(e, t) {
1500
- let n = br((e) => e.setDirty);
1501
- o(() => {
1502
- t && n(e);
1503
- }, [
1504
- t,
1505
- e,
1506
- n
1507
- ]), o(() => {
1508
- if (t) return () => n(!1);
1509
- }, [t, n]);
1510
- }
1511
- //#endregion
1512
- //#region src/embed/embed-nav-guard.ts
1513
- var Sr = m((e, t) => ({
1514
- pendingNavigation: null,
1515
- requestNavigation: (t) => e({ pendingNavigation: t }),
1516
- confirmNavigation: () => {
1517
- let n = t().pendingNavigation;
1518
- e({ pendingNavigation: null }), n?.();
1519
- },
1520
- cancelNavigation: () => e({ pendingNavigation: null })
1521
- }));
1522
- //#endregion
1523
- //#region src/embed/screen-location.ts
1524
- function Cr(e) {
1525
- let t = e.replace(/\/+$/, "").split("/").map((e) => e.startsWith(":") ? "[^/]+" : e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
1526
- return RegExp("^" + t.join("/") + "$");
1527
- }
1528
- function wr(e, t) {
1529
- let n = e.replace(/\/+$/, "") || "/";
1530
- if (!t) return {
1531
- matched: !1,
1532
- payload: { route: e }
1533
- };
1534
- let r, i, a, o;
1535
- for (let [e, s] of Object.entries(t)) if (s.route && Cr(s.route).test(n)) {
1536
- if (s.route.includes("/:")) a || (a = s, o = e);
1537
- else {
1538
- r = s, i = e;
1539
- break;
1540
- }
1541
- }
1542
- let s = r ?? a, c = r ? i : o;
1543
- if (!s || !c) return {
1544
- matched: !1,
1545
- payload: { route: e }
1546
- };
1547
- let l = {
1548
- route: s.route,
1549
- screenCode: c
1550
- };
1551
- if (s.entity && (l.entity = s.entity), s.route.includes("/:")) {
1552
- let e = n.slice(n.lastIndexOf("/") + 1);
1553
- e && (l.recordId = e);
1554
- }
1555
- return {
1556
- matched: !0,
1557
- screenCode: c,
1558
- screenType: s.type,
1559
- payload: l
1560
- };
1561
- }
1562
- function Tr(e, t) {
1563
- return wr(e, t).payload;
1564
- }
1565
- //#endregion
1566
- //#region src/embed/useEmbedNavigate.ts
1567
- function Er(e) {
1568
- let t = e.search(/[?#]/);
1569
- return t === -1 ? e : e.slice(0, t);
1570
- }
1571
- function Dr() {
1572
- let e = h(), t = ee(), n = q(), { data: r } = J();
1573
- return i((i, a) => {
1574
- if (!n.enabled) return e(i, a), !0;
1575
- let o = r?.screens, s = wr(Er(i), o), c = br.getState().isDirty && Er(i) !== t.pathname;
1576
- if (o && !s.matched) return D(n.parentOrigin, E.navigationFailed, {
1577
- route: Er(i),
1578
- reason: "unresolved"
1579
- }), !1;
1580
- if (n.navigationMode === "delegated") {
1581
- let e = () => {
1582
- D(n.parentOrigin, E.navigationRequested, s.payload);
1583
- };
1584
- return c ? (Sr.getState().requestNavigation(e), !1) : (e(), !1);
1585
- }
1586
- let l = () => {
1587
- e(n.appendEmbedParams(i), a);
1588
- };
1589
- return c ? (Sr.getState().requestNavigation(l), !1) : (l(), !0);
1590
- }, [
1591
- e,
1592
- t.pathname,
1593
- n,
1594
- r?.screens
1595
- ]);
1596
- }
1597
- function Or() {
1598
- let e = Dr();
1599
- return i((t, n) => {
1600
- e(t, n);
1601
- }, [e]);
1602
- }
1603
- function kr() {
1604
- let e = h();
1605
- return i(() => {
1606
- let t = () => {
1607
- e(-1);
1608
- };
1609
- br.getState().isDirty ? Sr.getState().requestNavigation(t) : t();
1610
- }, [e]);
1611
- }
1612
- function Ar() {
1613
- let e = q();
1614
- return i((t, n) => {
1615
- e.enabled && D(e.parentOrigin, E.navigationFailed, {
1616
- route: t,
1617
- reason: n
1618
- });
1619
- }, [e.enabled, e.parentOrigin]);
1620
- }
1621
- //#endregion
1622
- //#region src/components/shared/toast/DeclarionToast.tsx
1623
- var jr = {
1624
- success: {
1625
- tone: "success",
1626
- defaultTitle: (e) => e("toast.title.success", "Success")
1627
- },
1628
- error: {
1629
- tone: "danger",
1630
- defaultTitle: (e) => e("toast.title.error", "Error")
1631
- },
1632
- warning: {
1633
- tone: "warn",
1634
- defaultTitle: (e) => e("toast.title.warning", "Warning")
1635
- },
1636
- info: {
1637
- tone: "info",
1638
- defaultTitle: (e) => e("toast.title.info", "Heads up")
1639
- },
1640
- loading: {
1641
- tone: "info",
1642
- defaultTitle: (e) => e("toast.title.loading", "Working…")
1643
- }
1644
- }, Mr = 200;
1645
- function Nr({ type: t }) {
1646
- let n = { display: "flex" };
1647
- if (t === "loading") return /* @__PURE__ */ f("span", {
1648
- style: {
1649
- ...n,
1650
- animation: "dz-toast-spin 0.9s linear infinite"
1651
- },
1652
- children: /* @__PURE__ */ f(e.loader, { size: 11 })
1653
- });
1654
- let r = t === "success" ? e.check : t === "error" ? e.x : t === "warning" ? e.warning : e.info;
1655
- return /* @__PURE__ */ f("span", {
1656
- style: n,
1657
- children: /* @__PURE__ */ f(r, { size: 11 })
1658
- });
1659
- }
1660
- function Pr({ model: t, onClose: n }) {
1661
- let r = Pn(), a = jr[t.type] ?? jr.info, s = a.tone, [u, d] = l(!1), [m, ee] = l(!1), [h, g] = l(!1), [_, v] = l(!1), [y, te] = l(1), b = c(t.duration), ne = c(!1), x = !t.sticky && t.duration > 0, S = i(() => {
1662
- ne.current || (ne.current = !0, v(!0), window.setTimeout(n, Mr));
1663
- }, [n]);
1664
- o(() => {
1665
- b.current = t.duration, te(1);
1666
- }, [t.createdAt, t.duration]), o(() => {
1667
- if (!x || u || _) return;
1668
- let e = Date.now(), n = window.setTimeout(S, b.current), r = 0, i = () => {
1669
- let n = b.current - (Date.now() - e);
1670
- te(Math.max(0, n) / t.duration), n > 0 && (r = requestAnimationFrame(i));
1671
- };
1672
- return r = requestAnimationFrame(i), () => {
1673
- window.clearTimeout(n), cancelAnimationFrame(r), b.current = Math.max(0, b.current - (Date.now() - e));
1674
- };
1675
- }, [
1676
- x,
1677
- u,
1678
- _,
1679
- t.duration,
1680
- t.createdAt,
1681
- S
1682
- ]);
1683
- let C = i(() => {
1684
- let e = [
1685
- t.title,
1686
- t.message,
1687
- t.requestId ? `request_id: ${t.requestId}` : null,
1688
- t.details
1689
- ].filter(Boolean).join("\n");
1690
- navigator.clipboard?.writeText(e), ee(!0), window.setTimeout(() => ee(!1), 1500);
1691
- }, [
1692
- t.title,
1693
- t.message,
1694
- t.requestId,
1695
- t.details
1696
- ]), w = (e) => `var(--${s}${e})`, T = t.type === "error";
1697
- return /* @__PURE__ */ p("div", {
1698
- role: t.type === "error" ? "alert" : "status",
1699
- "aria-live": t.type === "error" ? "assertive" : "polite",
1700
- onMouseEnter: () => d(!0),
1701
- onMouseLeave: () => d(!1),
1702
- style: {
1703
- width: "100%",
1704
- background: "var(--surface)",
1705
- border: `1px solid ${w("-border")}`,
1706
- borderLeft: `3px solid ${w("")}`,
1707
- borderRadius: 8,
1708
- boxShadow: "var(--shadow-toast)",
1709
- overflow: "hidden",
1710
- position: "relative",
1711
- animation: _ ? `dz-toast-out ${Mr}ms ease-in forwards` : "dz-toast-in 0.24s cubic-bezier(0.16, 1, 0.3, 1)"
1712
- },
1713
- children: [/* @__PURE__ */ p("div", {
1714
- style: {
1715
- display: "flex",
1716
- padding: "10px 12px 11px 12px",
1717
- gap: 10
1718
- },
1719
- children: [
1720
- /* @__PURE__ */ f("div", {
1721
- style: {
1722
- width: 18,
1723
- height: 18,
1724
- marginTop: 1,
1725
- flexShrink: 0,
1726
- background: w("-soft"),
1727
- borderRadius: 99,
1728
- display: "flex",
1729
- alignItems: "center",
1730
- justifyContent: "center",
1731
- color: w("")
1732
- },
1733
- children: /* @__PURE__ */ f(Nr, { type: t.type })
1734
- }),
1735
- /* @__PURE__ */ p("div", {
1736
- style: {
1737
- flex: 1,
1738
- minWidth: 0
1739
- },
1740
- children: [
1741
- /* @__PURE__ */ p("div", {
1742
- style: {
1743
- display: "flex",
1744
- alignItems: "baseline",
1745
- gap: 6
1746
- },
1747
- children: [
1748
- /* @__PURE__ */ f("div", {
1749
- style: {
1750
- fontSize: 12.5,
1751
- fontWeight: 600,
1752
- color: "var(--text)",
1753
- letterSpacing: "-0.005em",
1754
- userSelect: "text"
1755
- },
1756
- children: t.title || a.defaultTitle(r)
1757
- }),
1758
- (t.count ?? 0) > 1 && /* @__PURE__ */ p("span", {
1759
- style: {
1760
- background: w("-soft"),
1761
- color: w(""),
1762
- fontSize: 10,
1763
- padding: "1px 6px",
1764
- borderRadius: 99,
1765
- fontWeight: 600,
1766
- flexShrink: 0
1767
- },
1768
- children: ["×", t.count]
1769
- }),
1770
- t.requestId && /* @__PURE__ */ f("span", {
1771
- className: "mono",
1772
- style: {
1773
- fontSize: 10,
1774
- color: "var(--text-4)",
1775
- marginLeft: "auto",
1776
- userSelect: "text"
1777
- },
1778
- children: t.requestId
1779
- })
1780
- ]
1781
- }),
1782
- t.message && /* @__PURE__ */ f("div", {
1783
- style: {
1784
- fontSize: 12,
1785
- color: "var(--text-2)",
1786
- marginTop: 3,
1787
- lineHeight: 1.5,
1788
- userSelect: "text",
1789
- cursor: "text",
1790
- wordBreak: "break-word"
1791
- },
1792
- children: t.message
1793
- }),
1794
- t.details && /* @__PURE__ */ p("div", {
1795
- style: { marginTop: 6 },
1796
- children: [/* @__PURE__ */ p("button", {
1797
- type: "button",
1798
- onClick: () => g((e) => !e),
1799
- style: {
1800
- background: "transparent",
1801
- border: 0,
1802
- padding: 0,
1803
- cursor: "pointer",
1804
- color: "var(--text-3)",
1805
- fontSize: 11,
1806
- fontWeight: 500,
1807
- display: "inline-flex",
1808
- alignItems: "center",
1809
- gap: 4
1810
- },
1811
- children: [/* @__PURE__ */ f(e.down, {
1812
- size: 10,
1813
- style: {
1814
- transform: h ? "rotate(180deg)" : "none",
1815
- transition: "transform .15s"
1816
- }
1817
- }), h ? r("toast.hide_details", "Hide details") : r("toast.show_details", "Show details")]
1818
- }), h && /* @__PURE__ */ f("pre", {
1819
- className: "mono",
1820
- style: {
1821
- margin: "6px 0 0 0",
1822
- padding: "8px 10px",
1823
- background: "var(--surface-2)",
1824
- border: "1px solid var(--border)",
1825
- borderRadius: 5,
1826
- fontSize: 11,
1827
- lineHeight: 1.5,
1828
- color: "var(--text-2)",
1829
- whiteSpace: "pre-wrap",
1830
- wordBreak: "break-word",
1831
- userSelect: "text",
1832
- maxHeight: 200,
1833
- overflow: "auto"
1834
- },
1835
- children: t.details
1836
- })]
1837
- }),
1838
- (t.action || T) && /* @__PURE__ */ p("div", {
1839
- style: {
1840
- display: "flex",
1841
- alignItems: "center",
1842
- gap: 6,
1843
- marginTop: 8
1844
- },
1845
- children: [t.action && /* @__PURE__ */ f("button", {
1846
- type: "button",
1847
- onClick: () => {
1848
- t.action?.onClick(), S();
1849
- },
1850
- style: {
1851
- background: w("-soft"),
1852
- color: w(""),
1853
- border: 0,
1854
- padding: "4px 10px",
1855
- borderRadius: 5,
1856
- fontSize: 11.5,
1857
- fontWeight: 600,
1858
- cursor: "pointer"
1859
- },
1860
- children: t.action.label
1861
- }), T && /* @__PURE__ */ p("button", {
1862
- type: "button",
1863
- onClick: C,
1864
- title: r("toast.copy_error_message", "Copy error message"),
1865
- "aria-label": r("toast.copy_error_message", "Copy error message"),
1866
- style: {
1867
- display: "inline-flex",
1868
- alignItems: "center",
1869
- gap: 4,
1870
- background: "transparent",
1871
- border: "1px solid var(--border)",
1872
- padding: "3px 7px",
1873
- borderRadius: 5,
1874
- fontSize: 11,
1875
- color: m ? "var(--success)" : "var(--text-3)",
1876
- cursor: "pointer",
1877
- fontWeight: 500
1878
- },
1879
- children: [f(m ? e.check : e.copy, { size: 11 }), m ? r("control.copied", "Copied") : r("control.copy", "Copy")]
1880
- })]
1881
- })
1882
- ]
1883
- }),
1884
- /* @__PURE__ */ f("button", {
1885
- type: "button",
1886
- onClick: S,
1887
- "aria-label": r("toast.dismiss", "Dismiss"),
1888
- style: {
1889
- width: 20,
1890
- height: 20,
1891
- padding: 0,
1892
- marginTop: -1,
1893
- flexShrink: 0,
1894
- background: "transparent",
1895
- border: 0,
1896
- borderRadius: 4,
1897
- cursor: "pointer",
1898
- color: "var(--text-4)",
1899
- display: "flex",
1900
- alignItems: "center",
1901
- justifyContent: "center"
1902
- },
1903
- children: /* @__PURE__ */ f(e.x, { size: 12 })
1904
- })
1905
- ]
1906
- }), x && /* @__PURE__ */ f("div", {
1907
- style: {
1908
- position: "absolute",
1909
- left: 0,
1910
- right: 0,
1911
- bottom: 0,
1912
- height: 2
1913
- },
1914
- children: /* @__PURE__ */ f("div", { style: {
1915
- height: "100%",
1916
- width: `${y * 100}%`,
1917
- background: w(""),
1918
- opacity: .55,
1919
- transition: u ? "none" : "width 0.1s linear"
1920
- } })
1921
- })]
1922
- });
1923
- }
1924
- //#endregion
1925
- //#region src/lib/toast.tsx
1926
- var Fr = {
1927
- success: 4e3,
1928
- info: 6e3,
1929
- warning: 8e3,
1930
- error: 0,
1931
- loading: 0
1932
- }, Z = /* @__PURE__ */ new Map(), Ir = /* @__PURE__ */ new Map(), Lr = 0, Rr = () => `dz-${++Lr}`;
1933
- function zr(e) {
1934
- g.custom(() => /* @__PURE__ */ f(Pr, {
1935
- model: e,
1936
- onClose: () => g.dismiss(e.id)
1937
- }), {
1938
- id: e.id,
1939
- duration: Infinity,
1940
- onDismiss: () => {
1941
- Z.delete(String(e.id)), e.group && Ir.get(e.group) === e.id && Ir.delete(e.group);
1942
- }
1943
- });
1944
- }
1945
- function Q(e, t, n, r = {}) {
1946
- if (r.group) {
1947
- let e = Ir.get(r.group);
1948
- if (e && Z.has(e)) {
1949
- let r = Z.get(e), i = {
1950
- ...r,
1951
- title: t,
1952
- message: n,
1953
- count: (r.count ?? 1) + 1,
1954
- createdAt: Date.now()
1955
- };
1956
- return Z.set(e, i), zr(i), e;
1957
- }
1958
- }
1959
- let i = r.id ?? Rr(), a = r.duration ?? Fr[e], o = {
1960
- id: i,
1961
- type: e,
1962
- title: t,
1963
- message: n,
1964
- duration: a,
1965
- sticky: r.sticky ?? a === 0,
1966
- action: r.action,
1967
- requestId: r.requestId,
1968
- details: r.details,
1969
- count: 1,
1970
- createdAt: Date.now(),
1971
- group: r.group
1972
- };
1973
- return Z.set(i, o), r.group && Ir.set(r.group, i), zr(o), i;
1974
- }
1975
- function Br(e, t) {
1976
- let n = Z.get(e);
1977
- if (!n) return;
1978
- let r = t.type ?? n.type, i = t.duration ?? (t.type ? Fr[r] : n.duration), a = {
1979
- ...n,
1980
- ...t,
1981
- type: r,
1982
- duration: i,
1983
- sticky: t.sticky ?? i === 0,
1984
- createdAt: Date.now()
1985
- };
1986
- Z.set(e, a), zr(a);
1987
- }
1988
- var Vr = {
1989
- success: (e, t, n) => Q("success", e, t, n),
1990
- info: (e, t, n) => Q("info", e, t, n),
1991
- warning: (e, t, n) => Q("warning", e, t, n),
1992
- error: (e, t, n) => Q("error", e, t, n),
1993
- loading: (e, t, n) => Q("loading", e, t, n),
1994
- update: Br,
1995
- dismiss: (e) => g.dismiss(e),
1996
- dismissAll: () => g.dismiss()
1997
- }, Hr = {
1998
- __create: "create",
1999
- __edit: "update",
2000
- __delete: "delete",
2001
- __restore: "restore"
2002
- }, Ur = "__peek", Wr = "__open", Gr = "__edit";
2003
- function Kr(e) {
2004
- return e === "__peek" || e === "__open";
2005
- }
2006
- function qr(e, t) {
2007
- if (!e) return "";
2008
- if (t) try {
2009
- return Nt(t, At(t, e));
2010
- } catch {}
2011
- let n = e.id;
2012
- return typeof n == "string" ? n : n == null ? "" : G(n);
2013
- }
2014
- function $(e, t) {
2015
- if (!e || e.length === 0) return !0;
2016
- for (let n of e) {
2017
- if (n.status && n.status.length > 0) {
2018
- let e = t.status;
2019
- if (typeof e != "string" || !n.status.includes(e)) return !1;
2020
- }
2021
- if (n.field && !Yr(n, t)) return !1;
2022
- }
2023
- return !0;
2024
- }
2025
- function Jr(e, t) {
2026
- return t.startsWith("$status.") ? !Array.isArray(e.$statuses) : t.startsWith("$property.") ? !Array.isArray(e.$properties) : !1;
2027
- }
2028
- function Yr(e, t) {
2029
- if (Jr(t, e.field)) return !1;
2030
- let n = Xr(t, e.field), r = e.op || "eq";
2031
- if (r === "in" || r === "not_in") {
2032
- let t = Array.isArray(e.value) ? e.value : [e.value], i = G(n), a = t.some((e) => G(e) === i);
2033
- return r === "in" ? a : !a;
2034
- }
2035
- return typeof e.value == "boolean" && r === "eq" ? Qr(n) === e.value : typeof n == "number" && typeof e.value == "number" ? $r(n, e.value, r) : $r(G(n), G(e.value), r);
2036
- }
2037
- function Xr(e, t) {
2038
- if (Object.prototype.hasOwnProperty.call(e, t)) return e[t];
2039
- if (t.startsWith("$status.")) {
2040
- let n = t.slice(8), r = e.$statuses;
2041
- return Array.isArray(r) ? r.find((e) => !e || typeof e != "object" ? !1 : e.group_code === n)?.status_code : void 0;
2042
- }
2043
- if (t.startsWith("$property.")) {
2044
- let n = t.slice(10), r = e.$properties;
2045
- return Array.isArray(r) ? r.find((e) => !e || typeof e != "object" ? !1 : e.property_code === n)?.value : void 0;
2046
- }
2047
- }
2048
- function Zr(e) {
2049
- let t = null, n = (n, r) => {
2050
- Object.prototype.hasOwnProperty.call(e, n) || (t === null && (t = { ...e }), t[n] = r);
2051
- }, r = e.$statuses;
2052
- if (Array.isArray(r)) for (let t of r) {
2053
- if (!t || typeof t != "object") continue;
2054
- let r = t.group_code;
2055
- typeof r == "string" && n(`$status.${r}`, Xr(e, `$status.${r}`));
2056
- }
2057
- let i = e.$properties;
2058
- if (Array.isArray(i)) for (let t of i) {
2059
- if (!t || typeof t != "object") continue;
2060
- let r = t.property_code;
2061
- typeof r == "string" && n(`$property.${r}`, Xr(e, `$property.${r}`));
2062
- }
2063
- return t ?? e;
2064
- }
2065
- function Qr(e) {
2066
- return e == null ? !1 : typeof e == "boolean" ? e : typeof e == "string" ? e !== "" : typeof e != "number" || e !== 0;
2067
- }
2068
- function $r(e, t, n) {
2069
- switch (n) {
2070
- case "eq": return e === t;
2071
- case "ne": return e !== t;
2072
- case "gt": return e > t;
2073
- case "gte":
2074
- case "ge": return e >= t;
2075
- case "lt": return e < t;
2076
- case "lte":
2077
- case "le": return e <= t;
2078
- default: return !1;
2079
- }
2080
- }
2081
- function ei(e, t) {
2082
- return e ? Object.entries(e).filter(([, e]) => e.visibility?.includes(t)).map(([e, t]) => ({
2083
- code: e,
2084
- action: t
2085
- })) : [];
2086
- }
2087
- function ti(e, t, n, r) {
2088
- return !e && !r ? [] : t === void 0 ? ei(e, n) : t.map((t) => {
2089
- let n = e?.[t] ?? r?.[t];
2090
- return n ? {
2091
- code: t,
2092
- action: n
2093
- } : null;
2094
- }).filter((e) => e !== null);
2095
- }
2096
- function ni(e, t) {
2097
- return e.filter(({ code: e }) => {
2098
- let n = Hr[e];
2099
- return !n || Ot(t, n);
2100
- });
2101
- }
2102
- function ri(e) {
2103
- return !!e?.confirmation && Object.keys(e.confirmation).length > 0;
2104
- }
2105
- function ii(e, t) {
2106
- return ri(t) ? e(t.confirmation) : t?.destructive ? e("action.confirm.destructive", "This action cannot be undone.") : null;
2107
- }
2108
- function ai(e) {
2109
- return ri(e) || !!e?.destructive;
2110
- }
2111
- function oi(e, t, n, r, i, a = !1) {
2112
- if (r && i) return i;
2113
- let o = e(t?.display?.description);
2114
- return o ? a || t?.display?.icon_only === !0 ? `${n}\n${o}` : o : n;
2115
- }
2116
- function si(e) {
2117
- return !!e.association;
2118
- }
2119
- function ci(e, t) {
2120
- if (e) {
2121
- for (let n of Object.values(e.screens)) if (n.entity === t && n.type === "list") {
2122
- let r = e.entities[t];
2123
- return {
2124
- route: n.route,
2125
- icon: n.display?.icon || r?.display?.icon || ""
2126
- };
2127
- }
2128
- }
2129
- }
2130
- function li(e, t, n, r, i, a, o) {
2131
- let s = [];
2132
- for (let c of t) {
2133
- let t = ui(e, c, n, r, i, a, o);
2134
- t !== null && s.push(t);
2135
- }
2136
- return s;
2137
- }
2138
- function ui(e, t, n, r, i, a, o) {
2139
- return t.kind === "group" ? di(e, t, n, r, i, a, o) : fi(e, t, n, r, i, a, o);
2140
- }
2141
- function di(e, t, n, r, i, a, o) {
2142
- let s = [];
2143
- for (let c of t.items) {
2144
- let t = ui(e, c, n, r, i, a, o);
2145
- t !== null && s.push(t);
2146
- }
2147
- return s.length === 0 ? null : {
2148
- ...t,
2149
- items: s
2150
- };
2151
- }
2152
- function fi(e, t, n, r, i, a, o) {
2153
- if (o && !t.code.startsWith("__") && !o.has(t.code)) return null;
2154
- let s = hi(t.code, n, r);
2155
- if (!s) return null;
2156
- if (a.length > 0) {
2157
- let n = pi(e, s, a);
2158
- return n.visible ? {
2159
- ...t,
2160
- enabled: n.enabled,
2161
- reason: n.reason
2162
- } : null;
2163
- }
2164
- if (!$(s.conditions, i) || !$(gi(s.visible_if), i)) return null;
2165
- let { enabled: c, reason: l } = mi(e, s, i);
2166
- return {
2167
- ...t,
2168
- enabled: c,
2169
- reason: l
2170
- };
2171
- }
2172
- function pi(e, t, n) {
2173
- let r = gi(t.visible_if), i = gi(t.enabled_if), a = t.conditions, o = 0, s = 0;
2174
- for (let e of n) {
2175
- let t = $(r, e) && $(a, e);
2176
- t && o++;
2177
- let n = $(i, e);
2178
- (!t || !n) && s++;
2179
- }
2180
- if (o === 0) return {
2181
- visible: !1,
2182
- enabled: !1,
2183
- reason: null
2184
- };
2185
- if (s === 0) return {
2186
- visible: !0,
2187
- enabled: !0,
2188
- reason: null
2189
- };
2190
- let c = {
2191
- failing: s,
2192
- total: n.length
2193
- }, l = e(t.enabled_if_reason);
2194
- return {
2195
- visible: !0,
2196
- enabled: !1,
2197
- reason: l ? e("action.bulk.reason_rows_fail", "{reason} ({failing} of {total} rows fail)", {
2198
- reason: l,
2199
- ...c
2200
- }) : e("action.bulk.rows_fail", "({failing} of {total} rows fail)", c)
2201
- };
2202
- }
2203
- function mi(e, t, n) {
2204
- let r = gi(t.enabled_if);
2205
- return !r || r.length === 0 || $(r, n) ? {
2206
- enabled: !0,
2207
- reason: null
2208
- } : {
2209
- enabled: !1,
2210
- reason: e(t.enabled_if_reason) || null
2211
- };
2212
- }
2213
- function hi(e, t, n) {
2214
- if (t && e in t) return t[e];
2215
- if (n && e in n) return n[e];
2216
- }
2217
- function gi(e) {
2218
- return e;
2219
- }
2220
- function _i(e, t, n, r, i) {
2221
- let a = [];
2222
- for (let o of e) {
2223
- if (o.kind === "group") {
2224
- let e = _i(o.items, t, n, r, i);
2225
- e.length > 0 && a.push({
2226
- ...o,
2227
- items: e
2228
- });
2229
- continue;
2230
- }
2231
- let e = hi(o.code, t, n);
2232
- e && e.visibility?.includes(r) && (i?.bulkRequired === void 0 || (i.bulkRequiredPredicate ? i.bulkRequiredPredicate(e) : !1) === i.bulkRequired) && (i?.excludeIf && i.excludeIf(e) || a.push(o));
2233
- }
2234
- return a;
2235
- }
2236
- function vi(e, t, n, r, i, a) {
2237
- let o = e ?? t;
2238
- return o ? _i(o, n, r, i, a) : Si(n, i);
2239
- }
2240
- function yi(e) {
2241
- return e.requires_selection === void 0 ? bi(e) : e.requires_selection;
2242
- }
2243
- function bi(e) {
2244
- return e.visibility?.includes("list_floatbar") ?? !1;
2245
- }
2246
- function xi(e, t, n, r, i) {
2247
- return e.map((e) => {
2248
- if (e.kind === "group") return {
2249
- ...e,
2250
- items: xi(e.items, t, n, r, i)
2251
- };
2252
- let a = hi(e.code, t, n);
2253
- return a && r(a) ? {
2254
- ...e,
2255
- enabled: !1,
2256
- reason: i
2257
- } : e;
2258
- });
2259
- }
2260
- function Si(e, t) {
2261
- return e ? Object.entries(e).filter(([, e]) => e.visibility?.includes(t)).sort(([e, t], [n, r]) => {
2262
- let i = t.position ?? 0, a = r.position ?? 0;
2263
- return i === a ? e < n ? -1 : +(e > n) : i - a;
2264
- }).map(([e]) => ({
2265
- kind: "action",
2266
- code: e,
2267
- enabled: !0,
2268
- reason: null
2269
- })) : [];
2270
- }
2271
- //#endregion
2272
- //#region src/api/events.ts
2273
- var Ci = new EventTarget(), wi = "agent-frame", Ti = "agent-message-changed";
2274
- function Ei(e) {
2275
- Ci.dispatchEvent(new CustomEvent(wi, { detail: e }));
2276
- }
2277
- var Di = class extends Error {
2278
- constructor() {
2279
- super("SSE auth expired"), this.name = "SSEAuthError";
2280
- }
2281
- }, Oi;
2282
- function ki() {
2283
- return Oi;
2284
- }
2285
- async function* Ai(e = {}) {
2286
- let t = new Headers();
2287
- e.lastEventID && t.set("Last-Event-ID", e.lastEventID), e.bearerToken && t.set("Authorization", `Bearer ${e.bearerToken}`);
2288
- let n = await fetch(at("/api/events"), {
2289
- credentials: e.credentials ?? "include",
2290
- signal: e.signal,
2291
- headers: t
2292
- });
2293
- if (!n.ok || !n.body) {
2294
- let { raw: e, body: t } = await x(n);
2295
- throw n.status === 401 ? new Di() : new _(n.status, t, e);
2296
- }
2297
- if (Oi === void 0) {
2298
- let e = Date.parse(n.headers.get("Date") ?? "");
2299
- Number.isNaN(e) || (Oi = e);
2300
- }
2301
- let r = n.body.getReader(), i = new TextDecoder(), a = "", o = "", s = "", c = "";
2302
- try {
2303
- for (;;) {
2304
- let { done: t, value: n } = await r.read();
2305
- if (t) break;
2306
- e.onActivity?.(), a += i.decode(n, { stream: !0 });
2307
- let l = a.split("\n");
2308
- a = l.pop() ?? "";
2309
- for (let e of l) if (e.startsWith("event: ")) o = e.slice(7);
2310
- else if (e.startsWith("id: ")) c = e.slice(4);
2311
- else if (e === "id:") c = "";
2312
- else if (e.startsWith("data: ")) s = e.slice(6);
2313
- else if (e === "" && o) {
2314
- try {
2315
- if (o === "session_refresh") yield { type: "session_refresh" };
2316
- else if (o === "checkpoint" && c) yield {
2317
- type: "checkpoint",
2318
- eventID: c
2319
- };
2320
- else if (o === "replay_complete") yield {
2321
- type: "replay_complete",
2322
- seq: (s ? JSON.parse(s) : {}).seq
2323
- };
2324
- else if (o === "snapshot_complete") {
2325
- let e = s ? JSON.parse(s) : {};
2326
- yield {
2327
- type: "snapshot_complete",
2328
- known: e.known === !0,
2329
- asOf: typeof e.as_of == "number" ? e.as_of : void 0
2330
- };
2331
- } else if (o === "realtime_streaming" && s) {
2332
- let e = JSON.parse(s);
2333
- Array.isArray(e.degraded) && e.degraded.every((e) => typeof e == "string") && (yield {
2334
- type: "realtime_streaming",
2335
- eventID: c || void 0,
2336
- degraded: e.degraded
2337
- });
2338
- } else if (o === "realtime_degraded" && s) {
2339
- let e = JSON.parse(s);
2340
- e.entity && (yield {
2341
- type: "realtime_degraded",
2342
- eventID: c || void 0,
2343
- entity: e.entity,
2344
- degradedSeq: e.degraded_seq
2345
- });
2346
- } else if (o === "cache_reset" && s) {
2347
- let e = JSON.parse(s);
2348
- yield {
2349
- type: "cache_reset",
2350
- eventID: c || void 0,
2351
- reason: e.reason || "replay_gap",
2352
- requestedSeq: e.requested_seq,
2353
- oldestSeq: e.oldest_seq,
2354
- resetSeq: e.reset_seq
2355
- };
2356
- } else if (o === "agent_stream" && s) {
2357
- let e = JSON.parse(s);
2358
- Ei({
2359
- convId: e.conversation_id,
2360
- kind: e.kind,
2361
- turnId: e.turn_id,
2362
- payload: e.payload
2363
- });
2364
- } else if (o === "entity_changed" && s) {
2365
- let e = JSON.parse(s);
2366
- (e.entity === "agent_message" || e.entity === "agent_turn" || e.entity === "agent_tool_invocation") && Ci.dispatchEvent(new CustomEvent(Ti, { detail: {
2367
- entity: e.entity,
2368
- rowId: e.ids[0],
2369
- action: e.action
2370
- } })), yield {
2371
- type: "entity_changed",
2372
- eventID: c || void 0,
2373
- entity: e.entity,
2374
- ids: e.ids,
2375
- objects: e.objects,
2376
- action: e.action,
2377
- reason: e.reason
2378
- };
2379
- }
2380
- } catch {}
2381
- o = "", s = "", c = "";
2382
- }
2383
- }
2384
- } finally {
2385
- r.releaseLock();
2386
- }
2387
- }
2388
- //#endregion
2389
- //#region src/lib/field-classification.ts
2390
- function ji(e, t) {
2391
- let n = e?.field_access?.[t];
2392
- return !n || n.read === "granted";
2393
- }
2394
- function Mi(e, t) {
2395
- let n = e?.field_access?.[t];
2396
- return !n || n.write === "granted";
2397
- }
2398
- function Ni(e, t) {
2399
- return e?.field_access?.[t]?.classification;
2400
- }
2401
- function Pi(e, t) {
2402
- return e?.field_access?.[t]?.required_permission;
2403
- }
2404
- function Fi(e, t, n) {
2405
- let r = Ni(t, n);
2406
- if (r) return e?.classifications?.[r];
2407
- }
2408
- function Ii(e, t, n) {
2409
- return !!Fi(e, t, n)?.sod_protected;
2410
- }
2411
- function Li(e, t) {
2412
- return e?.field_access?.[t];
2413
- }
2414
- function Ri(e, t) {
2415
- return ji(e, t.startsWith("$property.") ? t.slice(10) : t);
2416
- }
2417
- function zi(e, t) {
2418
- if (!t) return t;
2419
- let n = t.split(",").filter((t) => {
2420
- let n = t.split(":")[0]?.trim();
2421
- return !n || Ri(e, n);
2422
- });
2423
- return n.length > 0 ? n.join(",") : void 0;
2424
- }
2425
- function Bi(e, t) {
2426
- let n = [], r = !1;
2427
- for (let i of t) {
2428
- if (i.field !== void 0 && !Ri(e, i.field)) {
2429
- r = !0;
2430
- continue;
2431
- }
2432
- let t = i.or ? "or" : i.and ? "and" : void 0;
2433
- if (!t) {
2434
- n.push(i);
2435
- continue;
2436
- }
2437
- let a = i[t] ?? [], o = Bi(e, a);
2438
- o === a ? n.push(i) : (r = !0, o.length > 0 && n.push({
2439
- ...i,
2440
- [t]: o
2441
- }));
2442
- }
2443
- return r ? n : t;
2444
- }
2445
- //#endregion
2446
- //#region src/hooks/useEntity.ts
2447
- function Vi(e) {
2448
- let { data: t } = J();
2449
- if (t && e) return t.entities[e];
2450
- }
2451
- //#endregion
2452
- //#region src/hooks/useEntityData.ts
2453
- function Hi(e, t) {
2454
- return [
2455
- "entity-data",
2456
- e,
2457
- {
2458
- ...t,
2459
- count: "window"
2460
- }
2461
- ];
2462
- }
2463
- function Ui(e, t, n = !0) {
2464
- let r = Hi(e, t), i = r[2];
2465
- return u({
2466
- queryKey: r,
2467
- queryFn: ({ signal: t }) => Gn(e, i, { signal: t }),
2468
- enabled: !!e && n,
2469
- placeholderData: (t, n) => {
2470
- if (n?.queryKey?.[1] !== e) return;
2471
- let r = n?.queryKey?.[2];
2472
- return Wi(r, i) ? t : void 0;
2473
- }
2474
- });
2475
- }
2476
- function Wi(e, t) {
2477
- return e ? JSON.stringify(e.filters ?? null) === JSON.stringify(t.filters ?? null) && (e.search ?? "") === (t.search ?? "") && (e.screen ?? "") === (t.screen ?? "") && !!e.include_deleted == !!t.include_deleted : !1;
2478
- }
2479
- function Gi(e, t) {
2480
- return [
2481
- "entity-count",
2482
- e,
2483
- {
2484
- ...t,
2485
- count: "only",
2486
- page: void 0,
2487
- per_page: void 0,
2488
- sort: void 0,
2489
- select: void 0,
2490
- expand: void 0
2491
- }
2492
- ];
2493
- }
2494
- function Ki(e, t, n = !0) {
2495
- let r = Gi(e, t), i = r[2];
2496
- return u({
2497
- queryKey: r,
2498
- queryFn: ({ signal: t }) => Gn(e, i, { signal: t }),
2499
- enabled: !!e && n,
2500
- retry: 1,
2501
- staleTime: 3e4,
2502
- placeholderData: (t, n) => n?.queryKey?.[1] === e ? t : void 0
2503
- });
2504
- }
2505
- //#endregion
2506
- //#region src/hooks/useCurrentScreen.tsx
2507
- var qi = n(void 0);
2508
- function Ji({ code: e, children: t }) {
2509
- let { data: n } = J(), r = s(() => ({
2510
- code: e,
2511
- screen: n?.screens[e]
2512
- }), [e, n]);
2513
- return /* @__PURE__ */ f(qi.Provider, {
2514
- value: r,
2515
- children: t
2516
- });
2517
- }
2518
- function Yi() {
2519
- return a(qi);
2520
- }
2521
- //#endregion
2522
- export { gr as $, x as $n, Lt as $t, li as A, Ye as An, On as At, vi as B, k as Bn, bn as Bt, Gr as C, dt as Cn, In as Ct, ai as D, H as Dn, jn as Dt, ii as E, F as En, Mn as Et, ni as F, Ee as Fn, J as Ft, Ar as G, ae as Gn, ln as Gt, Zr as H, se as Hn, yn as Ht, ci as I, ge as In, Cn as It, Tr as J, b as Jn, mn as Jt, kr as K, ie as Kn, un as Kt, ti as L, he as Ln, xn as Lt, xi as M, Xe as Mn, En as Mt, $ as N, Se as Nn, kn as Nt, yi as O, lt as On, Tn as Ot, _i as P, Te as Pn, An as Pt, yr as Q, ne as Qn, vt as Qt, si as R, de as Rn, cn as Rt, Ai as S, mt as Sn, Fn as St, Ur as T, W as Tn, Nn as Tt, Vr as U, E as Un, gn as Ut, qr as V, me as Vn, vn as Vt, Or as W, D as Wn, pn as Wt, br as X, v as Xn, q as Xt, Sr as Y, te as Yn, sn as Yt, xr as Z, y as Zn, Qt as Zt, wi as _, bt as _n, cr as _t, Ki as a, At as an, nr as at, Ci as b, ft as bn, Hn as bt, Fi as c, K as cn, Xn as ct, Pi as d, jt as dn, Qn as dt, Rt as en, hr as et, ji as f, Ft as fn, Kn as ft, zi as g, It as gn, ir as gt, Bi as h, Dt as hn, Zn as ht, Hi as i, Ot as in, er as it, Si as j, Ze as jn, Dn as jt, oi as k, U as kn, wn as kt, Li as l, Bt as ln, $n as lt, Mi as m, Mt as mn, lr as mt, Yi as n, Et as nn, pr as nt, Ui as o, wt as on, qn as ot, Ii as p, Nt as pn, Gn as pt, Dr as q, _ as qn, _n as qt, Gi as r, kt as rn, fr as rt, Vi as s, yt as sn, Yn as st, Ji as t, zt as tn, _r as tt, Ni as u, Tt as un, X as ut, Ti as v, Ct as vn, sr as vt, Wr as w, G as wn, Pn as wt, ki as x, pt as xn, Un as xt, Di as y, Pt as yn, Jn as yt, Kr as z, ue as zn, dn as zt };