@protobase/ui 0.122.0 → 0.122.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 (248) hide show
  1. package/dist/account/alias-check-panel.d.ts +13 -0
  2. package/dist/account/alias-check-panel.js +40 -0
  3. package/dist/account/alias-check-run.d.ts +37 -0
  4. package/dist/account/alias-check-run.js +24 -0
  5. package/dist/account/alias-check.d.ts +15 -0
  6. package/dist/account/alias-check.js +16 -0
  7. package/dist/account/blocks/personal-mail-block.js +3 -1
  8. package/dist/account/mail-sender-dialog.d.ts +4 -1
  9. package/dist/account/mail-sender-dialog.js +10 -2
  10. package/dist/account/mail-senders-section.d.ts +8 -3
  11. package/dist/account/mail-senders-section.js +25 -6
  12. package/dist/account/messages.d.ts +2 -2
  13. package/dist/account/use-alias-check.d.ts +12 -0
  14. package/dist/account/use-alias-check.js +54 -0
  15. package/dist/activity-chart/messages.d.ts +2 -2
  16. package/dist/app/charts/messages.d.ts +2 -2
  17. package/dist/app/confirm-sign-in-messages.d.ts +2 -2
  18. package/dist/app/conversation/messages.d.ts +2 -2
  19. package/dist/app/conversation-page/messages.d.ts +2 -2
  20. package/dist/app/create/messages.d.ts +2 -2
  21. package/dist/app/custom-section.d.ts +1 -1
  22. package/dist/app/delete/messages.d.ts +2 -2
  23. package/dist/app/displays/list-cards.d.ts +1 -1
  24. package/dist/app/displays/messages.d.ts +2 -2
  25. package/dist/app/embedded-list/messages.d.ts +2 -2
  26. package/dist/app/export/messages.d.ts +2 -2
  27. package/dist/app/field-messages.d.ts +2 -2
  28. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  29. package/dist/app/field-types/widget-part.d.ts +1 -1
  30. package/dist/app/field-types/workflow/definition.d.ts +1 -1
  31. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  32. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  33. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  34. package/dist/app/field-types/workflow-status/messages.d.ts +2 -2
  35. package/dist/app/file-viewers/messages.d.ts +2 -2
  36. package/dist/app/focus/messages.d.ts +2 -2
  37. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  38. package/dist/app/gallery/messages.d.ts +2 -2
  39. package/dist/app/hand-order/messages.d.ts +2 -2
  40. package/dist/app/history/messages.d.ts +2 -2
  41. package/dist/app/import/messages.d.ts +2 -2
  42. package/dist/app/list-messages.d.ts +2 -2
  43. package/dist/app/messages.d.ts +2 -2
  44. package/dist/app/pages/custom-boundary.d.ts +1 -1
  45. package/dist/app/pages/custom-chosen.d.ts +1 -1
  46. package/dist/app/pages/messages.d.ts +2 -2
  47. package/dist/app/record-chart/messages.d.ts +2 -2
  48. package/dist/app/record-messages.d.ts +2 -2
  49. package/dist/app/record-mode/shown-layout.d.ts +1 -1
  50. package/dist/app/record-row/messages.d.ts +2 -2
  51. package/dist/app/related-cards/messages.d.ts +2 -2
  52. package/dist/app/runtime/messages.d.ts +2 -2
  53. package/dist/app/saved/saved-list.d.ts +1 -1
  54. package/dist/app/search/messages.d.ts +2 -2
  55. package/dist/app/searches/messages.d.ts +2 -2
  56. package/dist/app-shell/messages.d.ts +2 -2
  57. package/dist/assistant-dock/messages.d.ts +2 -2
  58. package/dist/auth/messages.d.ts +2 -2
  59. package/dist/chat/messages.d.ts +2 -2
  60. package/dist/compact-table/messages.d.ts +2 -2
  61. package/dist/data-grid/column-spec.d.ts +1 -1
  62. package/dist/data-grid/messages.d.ts +2 -2
  63. package/dist/filter-panel/messages.d.ts +2 -2
  64. package/dist/inline-child-table/messages.d.ts +2 -2
  65. package/dist/invitations/messages.d.ts +2 -2
  66. package/dist/locale/en.js +7 -0
  67. package/dist/locale/en.json.d.ts +7 -0
  68. package/dist/locale/messages.d.ts +14 -0
  69. package/dist/locale/nl.js +7 -0
  70. package/dist/locale/texts-gate.d.ts +1 -1
  71. package/dist/mailbox/messages.d.ts +2 -2
  72. package/dist/mentions/messages.d.ts +2 -2
  73. package/dist/mocks/customers.d.ts +1 -1
  74. package/dist/mocks/invoices.d.ts +1 -1
  75. package/dist/mocks/orders.d.ts +3 -3
  76. package/dist/notifications/bell/messages.d.ts +2 -2
  77. package/dist/organizations/messages.d.ts +2 -2
  78. package/dist/package.js +1 -1
  79. package/dist/plugins/before-sign-in.d.ts +1 -1
  80. package/dist/plugins/messages.d.ts +2 -2
  81. package/dist/primitives/messages.d.ts +2 -2
  82. package/dist/record-view/messages.d.ts +2 -2
  83. package/dist/shell/assets/{account-page-Dw3W4H6l.js → account-page-BESKgoYT.js} +2 -2
  84. package/dist/shell/assets/{app-B4Vl9AEn.js → app-DANB5cb3.js} +5 -5
  85. package/dist/shell/assets/{assistant-shell-DyBHCHuy.js → assistant-shell-DUxCRpci.js} +2 -2
  86. package/dist/shell/assets/{board-display-BlJwyapl.js → board-display-Blx6nTDs.js} +2 -2
  87. package/dist/shell/assets/{calendar-display-C2vvdk6I.js → calendar-display-SPyIwDLG.js} +2 -2
  88. package/dist/shell/assets/{call-rings-DKHVIKwh.js → call-rings-BGJkCQwP.js} +2 -2
  89. package/dist/shell/assets/{calls-CDleoS9h.js → calls-BRoDIvWu.js} +2 -2
  90. package/dist/shell/assets/{circle-alert-DYA4c4B7.js → circle-alert-BZyGgZSj.js} +2 -2
  91. package/dist/shell/assets/{composed-page-BtPlNGV4.js → composed-page-By2d8F85.js} +2 -2
  92. package/dist/shell/assets/{composer-section-zJurnYKu.js → composer-section-BiCIOqwU.js} +2 -2
  93. package/dist/shell/assets/{connect-route-oTxVxU6f.js → connect-route-BZsnJGaF.js} +2 -2
  94. package/dist/shell/assets/{copy-field-D_iD-sgT.js → copy-field-DpbjVuK4.js} +2 -2
  95. package/dist/shell/assets/{create-route-z6BVZwk3.js → create-route-DglCC2Tk.js} +2 -2
  96. package/dist/shell/assets/{custom-step-container-field-vl09jwo_.js → custom-step-container-field-DJbluU0F.js} +2 -2
  97. package/dist/shell/assets/{embedded-list-B0wJoqm3.js → embedded-list-CepLmiOu.js} +3 -3
  98. package/dist/shell/assets/en-Cn7SAD9K.js +2 -0
  99. package/dist/shell/assets/{export-dialog-DN8mwLKi.js → export-dialog-B9fvLoT2.js} +2 -2
  100. package/dist/shell/assets/export-worker-C4HtUYaa.js +15 -0
  101. package/dist/shell/assets/{first-organization-page-CN5x-0QP.js → first-organization-page-CSIsJmoQ.js} +2 -2
  102. package/dist/shell/assets/{graph-view-w7lrzAmt.js → graph-view-IPDrZVmC.js} +2 -2
  103. package/dist/shell/assets/{group-donut-g3nDENBg.js → group-donut-DRT539D9.js} +2 -2
  104. package/dist/shell/assets/{guest-call-page-_-o8LpKg.js → guest-call-page-IxjqrW0F.js} +3 -3
  105. package/dist/shell/assets/{html-viewer-Bfjrowsp.js → html-viewer-C-FI9kDC.js} +2 -2
  106. package/dist/shell/assets/{import-dialog-DeGzN4TA.js → import-dialog-DDaXN05w.js} +2 -2
  107. package/dist/shell/assets/{import-table-dialog-BcSfnTNF.js → import-table-dialog-CHWoi7_S.js} +2 -2
  108. package/dist/shell/assets/{index-Bu8r1CM4.js → index-tI-2Oomu.js} +1 -1
  109. package/dist/shell/assets/{invitations-page-CVkFsOgL.js → invitations-page-BE0tj3Aw.js} +2 -2
  110. package/dist/shell/assets/{layout-grid-Cmzqqy11.js → layout-grid-7R6t_Nlh.js} +2 -2
  111. package/dist/shell/assets/{legend-item-dXfws39r.js → legend-item-C-DA-JTo.js} +2 -2
  112. package/dist/shell/assets/{list-page-C7H5G772.js → list-page-Dj-oZ99M.js} +4 -4
  113. package/dist/shell/assets/{maplibre-C1Y1UO5-.js → maplibre-D0uTAdwG.js} +2 -2
  114. package/dist/shell/assets/{markdown-content-Be_Vsipv.js → markdown-content-BpKVfSRq.js} +2 -2
  115. package/dist/shell/assets/{members-page-vnYWXsnN.js → members-page-Ced4meCg.js} +2 -2
  116. package/dist/shell/assets/{message-content-BgtfnCSo.js → message-content-DSZOlZUY.js} +2 -2
  117. package/dist/shell/assets/{messages-BJNycdpS.js → messages-CEK97JXa.js} +2 -2
  118. package/dist/shell/assets/nl-BU1R957e.js +2 -0
  119. package/dist/shell/assets/{organization-page-Cbb97Ebt.js → organization-page-Dp_D2xbC.js} +2 -2
  120. package/dist/shell/assets/{organizations-page-Cq7fzpZa.js → organizations-page-CtrgjIWL.js} +2 -2
  121. package/dist/shell/assets/parse-worker-zWUgfCm6.js +35 -0
  122. package/dist/shell/assets/{pending-invitation-row-xX2VAQLM.js → pending-invitation-row-Bs60Zx0i.js} +2 -2
  123. package/dist/shell/assets/{period-chart-CgHgMZ2l.js → period-chart-CIgxhMTn.js} +2 -2
  124. package/dist/shell/assets/{person-row-CjXGB6eY.js → person-row-BH3iAvuG.js} +2 -2
  125. package/dist/shell/assets/{public-form-page-DROsvcsL.js → public-form-page-NPPZ_rgo.js} +2 -2
  126. package/dist/shell/assets/{record-lines-D-pcqwS2.js → record-lines-hY9wRXCf.js} +2 -2
  127. package/dist/shell/assets/{record-map-COL77PxJ.js → record-map-Dzt7xpK8.js} +2 -2
  128. package/dist/shell/assets/{record-opens-AboxTqcw.js → record-opens-DN1LnH9j.js} +2 -2
  129. package/dist/shell/assets/{record-page-Ctj-uKq1.js → record-page-CSsNYC0Q.js} +3 -3
  130. package/dist/shell/assets/{record-preview--cdSUcRq.js → record-preview-B1WiPOw4.js} +2 -2
  131. package/dist/shell/assets/{records-map-C5es9EjJ.js → records-map-BLcMBygH.js} +2 -2
  132. package/dist/shell/assets/{render-node-BbfwkxfK.js → render-node-DyvozeRy.js} +3 -3
  133. package/dist/shell/assets/{reorder-button-ClD-Ptqm.js → reorder-button-NNfcfua7.js} +2 -2
  134. package/dist/shell/assets/{run-trace-view-BlfDwdyz.js → run-trace-view-BoBj-5R0.js} +2 -2
  135. package/dist/shell/assets/{runner-install-field-E1dq6epi.js → runner-install-field-BdfsPY9H.js} +2 -2
  136. package/dist/shell/assets/{runtime-update-Dwwvn6ea.js → runtime-update-CRO1fS5O.js} +2 -2
  137. package/dist/shell/assets/{shared-protobase-ui-9v4EmiO7.js → shared-protobase-ui-BbJCcQ0y.js} +1 -1
  138. package/dist/shell/assets/{sheet-source-C2r0xsKl.js → sheet-source-DSJ73Heh.js} +3 -3
  139. package/dist/shell/assets/{sign-in-policy-page-D9_X1fyz.js → sign-in-policy-page-RaxuDREW.js} +2 -2
  140. package/dist/shell/assets/{start-block-queries-CSHzGGu1.js → start-block-queries-DTa6akPc.js} +2 -2
  141. package/dist/shell/assets/{step-catalog-DFsFCluU.js → step-catalog-UHxllpni.js} +2 -2
  142. package/dist/shell/assets/{step-panel-DmMSxA8x.js → step-panel-BkpaCVJd.js} +2 -2
  143. package/dist/shell/assets/{timeline-display-Br58uLQ8.js → timeline-display-CFIOdA59.js} +2 -2
  144. package/dist/shell/assets/{trash-DzKZquG9.js → trash-IV6Ox5bV.js} +2 -2
  145. package/dist/shell/assets/{update-set-DwG0XGif.js → update-set-BTHuLrBr.js} +2 -2
  146. package/dist/shell/assets/{use-calendar-move-DusjGuvd.js → use-calendar-move-CaU_5smA.js} +2 -2
  147. package/dist/shell/assets/{use-display-rows-llOhHJvA.js → use-display-rows-C_H7lxLW.js} +2 -2
  148. package/dist/shell/assets/{use-my-invitations-tnMnjktl.js → use-my-invitations-DSp8OwP9.js} +2 -2
  149. package/dist/shell/assets/{use-paged-search-BWcRlArY.js → use-paged-search-DOcO0Rbz.js} +2 -2
  150. package/dist/shell/assets/{use-run-trace-B2K4dLw0.js → use-run-trace-BsH3vq5k.js} +2 -2
  151. package/dist/shell/assets/{use-workflow-page-ted3LYxk.js → use-workflow-page-DDl2MUPY.js} +2 -2
  152. package/dist/shell/assets/{use-workflow-types-f_gVwLT2.js → use-workflow-types-nJ6UhHeL.js} +2 -2
  153. package/dist/shell/assets/{workflow-canvas-T1QChoXq.js → workflow-canvas-xG0FmrJj.js} +2 -2
  154. package/dist/shell/assets/{workflow-field-D0Yp-t1X.js → workflow-field-fuI75chK.js} +3 -3
  155. package/dist/shell/assets/{workflow-graph-editor-CJmYosOs.js → workflow-graph-editor-DCCcZ5AP.js} +2 -2
  156. package/dist/shell/assets/{workflow-run-field-CaJfI9Xi.js → workflow-run-field-BxIU66mn.js} +3 -3
  157. package/dist/shell/assets/{workflow-status-field-DlZvZQNx.js → workflow-status-field-Bnk5IHI5.js} +2 -2
  158. package/dist/shell/assets/{workflow-workbench-BcZEcj70.js → workflow-workbench-7EvpXFq6.js} +2 -2
  159. package/dist/shell/index.html +3 -3
  160. package/dist/shell/protobase.shell.json +2 -2
  161. package/dist/shell/protobase.sw.js +2 -2
  162. package/dist/shell-source-maps/assets/{account-page-Dw3W4H6l.js.map → account-page-BESKgoYT.js.map} +1 -1
  163. package/dist/shell-source-maps/assets/app-DANB5cb3.js.map +1 -0
  164. package/dist/shell-source-maps/assets/{assistant-shell-DyBHCHuy.js.map → assistant-shell-DUxCRpci.js.map} +1 -1
  165. package/dist/shell-source-maps/assets/{board-display-BlJwyapl.js.map → board-display-Blx6nTDs.js.map} +1 -1
  166. package/dist/shell-source-maps/assets/{calendar-display-C2vvdk6I.js.map → calendar-display-SPyIwDLG.js.map} +1 -1
  167. package/dist/shell-source-maps/assets/{call-rings-DKHVIKwh.js.map → call-rings-BGJkCQwP.js.map} +1 -1
  168. package/dist/shell-source-maps/assets/{calls-CDleoS9h.js.map → calls-BRoDIvWu.js.map} +1 -1
  169. package/dist/shell-source-maps/assets/{circle-alert-DYA4c4B7.js.map → circle-alert-BZyGgZSj.js.map} +1 -1
  170. package/dist/shell-source-maps/assets/{composed-page-BtPlNGV4.js.map → composed-page-By2d8F85.js.map} +1 -1
  171. package/dist/shell-source-maps/assets/{composer-section-zJurnYKu.js.map → composer-section-BiCIOqwU.js.map} +1 -1
  172. package/dist/shell-source-maps/assets/{connect-route-oTxVxU6f.js.map → connect-route-BZsnJGaF.js.map} +1 -1
  173. package/dist/shell-source-maps/assets/{copy-field-D_iD-sgT.js.map → copy-field-DpbjVuK4.js.map} +1 -1
  174. package/dist/shell-source-maps/assets/{create-route-z6BVZwk3.js.map → create-route-DglCC2Tk.js.map} +1 -1
  175. package/dist/shell-source-maps/assets/{custom-step-container-field-vl09jwo_.js.map → custom-step-container-field-DJbluU0F.js.map} +1 -1
  176. package/dist/shell-source-maps/assets/{embedded-list-B0wJoqm3.js.map → embedded-list-CepLmiOu.js.map} +1 -1
  177. package/dist/shell-source-maps/assets/en-Cn7SAD9K.js.map +1 -0
  178. package/dist/shell-source-maps/assets/{export-dialog-DN8mwLKi.js.map → export-dialog-B9fvLoT2.js.map} +1 -1
  179. package/dist/shell-source-maps/assets/export-worker-C4HtUYaa.js.map +1 -0
  180. package/dist/shell-source-maps/assets/{first-organization-page-CN5x-0QP.js.map → first-organization-page-CSIsJmoQ.js.map} +1 -1
  181. package/dist/shell-source-maps/assets/{graph-view-w7lrzAmt.js.map → graph-view-IPDrZVmC.js.map} +1 -1
  182. package/dist/shell-source-maps/assets/{group-donut-g3nDENBg.js.map → group-donut-DRT539D9.js.map} +1 -1
  183. package/dist/shell-source-maps/assets/{guest-call-page-_-o8LpKg.js.map → guest-call-page-IxjqrW0F.js.map} +1 -1
  184. package/dist/shell-source-maps/assets/{html-viewer-Bfjrowsp.js.map → html-viewer-C-FI9kDC.js.map} +1 -1
  185. package/dist/shell-source-maps/assets/{import-dialog-DeGzN4TA.js.map → import-dialog-DDaXN05w.js.map} +1 -1
  186. package/dist/shell-source-maps/assets/{import-table-dialog-BcSfnTNF.js.map → import-table-dialog-CHWoi7_S.js.map} +1 -1
  187. package/dist/shell-source-maps/assets/{invitations-page-CVkFsOgL.js.map → invitations-page-BE0tj3Aw.js.map} +1 -1
  188. package/dist/shell-source-maps/assets/{layout-grid-Cmzqqy11.js.map → layout-grid-7R6t_Nlh.js.map} +1 -1
  189. package/dist/shell-source-maps/assets/{legend-item-dXfws39r.js.map → legend-item-C-DA-JTo.js.map} +1 -1
  190. package/dist/shell-source-maps/assets/{list-page-C7H5G772.js.map → list-page-Dj-oZ99M.js.map} +1 -1
  191. package/dist/shell-source-maps/assets/{maplibre-C1Y1UO5-.js.map → maplibre-D0uTAdwG.js.map} +1 -1
  192. package/dist/shell-source-maps/assets/{markdown-content-Be_Vsipv.js.map → markdown-content-BpKVfSRq.js.map} +1 -1
  193. package/dist/shell-source-maps/assets/{members-page-vnYWXsnN.js.map → members-page-Ced4meCg.js.map} +1 -1
  194. package/dist/shell-source-maps/assets/{message-content-BgtfnCSo.js.map → message-content-DSZOlZUY.js.map} +1 -1
  195. package/dist/shell-source-maps/assets/{messages-BJNycdpS.js.map → messages-CEK97JXa.js.map} +1 -1
  196. package/dist/shell-source-maps/assets/nl-BU1R957e.js.map +1 -0
  197. package/dist/shell-source-maps/assets/{organization-page-Cbb97Ebt.js.map → organization-page-Dp_D2xbC.js.map} +1 -1
  198. package/dist/shell-source-maps/assets/{organizations-page-Cq7fzpZa.js.map → organizations-page-CtrgjIWL.js.map} +1 -1
  199. package/dist/shell-source-maps/assets/parse-worker-zWUgfCm6.js.map +1 -0
  200. package/dist/shell-source-maps/assets/{pending-invitation-row-xX2VAQLM.js.map → pending-invitation-row-Bs60Zx0i.js.map} +1 -1
  201. package/dist/shell-source-maps/assets/{period-chart-CgHgMZ2l.js.map → period-chart-CIgxhMTn.js.map} +1 -1
  202. package/dist/shell-source-maps/assets/{person-row-CjXGB6eY.js.map → person-row-BH3iAvuG.js.map} +1 -1
  203. package/dist/shell-source-maps/assets/{public-form-page-DROsvcsL.js.map → public-form-page-NPPZ_rgo.js.map} +1 -1
  204. package/dist/shell-source-maps/assets/{record-lines-D-pcqwS2.js.map → record-lines-hY9wRXCf.js.map} +1 -1
  205. package/dist/shell-source-maps/assets/{record-map-COL77PxJ.js.map → record-map-Dzt7xpK8.js.map} +1 -1
  206. package/dist/shell-source-maps/assets/{record-opens-AboxTqcw.js.map → record-opens-DN1LnH9j.js.map} +1 -1
  207. package/dist/shell-source-maps/assets/{record-page-Ctj-uKq1.js.map → record-page-CSsNYC0Q.js.map} +1 -1
  208. package/dist/shell-source-maps/assets/{record-preview--cdSUcRq.js.map → record-preview-B1WiPOw4.js.map} +1 -1
  209. package/dist/shell-source-maps/assets/{records-map-C5es9EjJ.js.map → records-map-BLcMBygH.js.map} +1 -1
  210. package/dist/shell-source-maps/assets/render-node-DyvozeRy.js.map +1 -0
  211. package/dist/shell-source-maps/assets/{reorder-button-ClD-Ptqm.js.map → reorder-button-NNfcfua7.js.map} +1 -1
  212. package/dist/shell-source-maps/assets/{run-trace-view-BlfDwdyz.js.map → run-trace-view-BoBj-5R0.js.map} +1 -1
  213. package/dist/shell-source-maps/assets/{runner-install-field-E1dq6epi.js.map → runner-install-field-BdfsPY9H.js.map} +1 -1
  214. package/dist/shell-source-maps/assets/{runtime-update-Dwwvn6ea.js.map → runtime-update-CRO1fS5O.js.map} +1 -1
  215. package/dist/shell-source-maps/assets/{sheet-source-C2r0xsKl.js.map → sheet-source-DSJ73Heh.js.map} +1 -1
  216. package/dist/shell-source-maps/assets/{sign-in-policy-page-D9_X1fyz.js.map → sign-in-policy-page-RaxuDREW.js.map} +1 -1
  217. package/dist/shell-source-maps/assets/{start-block-queries-CSHzGGu1.js.map → start-block-queries-DTa6akPc.js.map} +1 -1
  218. package/dist/shell-source-maps/assets/{step-catalog-DFsFCluU.js.map → step-catalog-UHxllpni.js.map} +1 -1
  219. package/dist/shell-source-maps/assets/{step-panel-DmMSxA8x.js.map → step-panel-BkpaCVJd.js.map} +1 -1
  220. package/dist/shell-source-maps/assets/{timeline-display-Br58uLQ8.js.map → timeline-display-CFIOdA59.js.map} +1 -1
  221. package/dist/shell-source-maps/assets/{trash-DzKZquG9.js.map → trash-IV6Ox5bV.js.map} +1 -1
  222. package/dist/shell-source-maps/assets/{update-set-DwG0XGif.js.map → update-set-BTHuLrBr.js.map} +1 -1
  223. package/dist/shell-source-maps/assets/{use-calendar-move-DusjGuvd.js.map → use-calendar-move-CaU_5smA.js.map} +1 -1
  224. package/dist/shell-source-maps/assets/{use-display-rows-llOhHJvA.js.map → use-display-rows-C_H7lxLW.js.map} +1 -1
  225. package/dist/shell-source-maps/assets/{use-my-invitations-tnMnjktl.js.map → use-my-invitations-DSp8OwP9.js.map} +1 -1
  226. package/dist/shell-source-maps/assets/{use-paged-search-BWcRlArY.js.map → use-paged-search-DOcO0Rbz.js.map} +1 -1
  227. package/dist/shell-source-maps/assets/{use-run-trace-B2K4dLw0.js.map → use-run-trace-BsH3vq5k.js.map} +1 -1
  228. package/dist/shell-source-maps/assets/{use-workflow-page-ted3LYxk.js.map → use-workflow-page-DDl2MUPY.js.map} +1 -1
  229. package/dist/shell-source-maps/assets/{use-workflow-types-f_gVwLT2.js.map → use-workflow-types-nJ6UhHeL.js.map} +1 -1
  230. package/dist/shell-source-maps/assets/{workflow-canvas-T1QChoXq.js.map → workflow-canvas-xG0FmrJj.js.map} +1 -1
  231. package/dist/shell-source-maps/assets/{workflow-field-D0Yp-t1X.js.map → workflow-field-fuI75chK.js.map} +1 -1
  232. package/dist/shell-source-maps/assets/{workflow-graph-editor-CJmYosOs.js.map → workflow-graph-editor-DCCcZ5AP.js.map} +1 -1
  233. package/dist/shell-source-maps/assets/{workflow-run-field-CaJfI9Xi.js.map → workflow-run-field-BxIU66mn.js.map} +1 -1
  234. package/dist/shell-source-maps/assets/{workflow-status-field-DlZvZQNx.js.map → workflow-status-field-Bnk5IHI5.js.map} +1 -1
  235. package/dist/shell-source-maps/assets/{workflow-workbench-BcZEcj70.js.map → workflow-workbench-7EvpXFq6.js.map} +1 -1
  236. package/dist/status/messages.d.ts +2 -2
  237. package/dist/users/messages.d.ts +2 -2
  238. package/package.json +5 -5
  239. package/dist/shell/assets/en-DnsB2haa.js +0 -2
  240. package/dist/shell/assets/export-worker-DbK8hf_0.js +0 -15
  241. package/dist/shell/assets/nl-Ce2dHlet.js +0 -2
  242. package/dist/shell/assets/parse-worker-MvbeuzYJ.js +0 -35
  243. package/dist/shell-source-maps/assets/app-B4Vl9AEn.js.map +0 -1
  244. package/dist/shell-source-maps/assets/en-DnsB2haa.js.map +0 -1
  245. package/dist/shell-source-maps/assets/export-worker-DbK8hf_0.js.map +0 -1
  246. package/dist/shell-source-maps/assets/nl-Ce2dHlet.js.map +0 -1
  247. package/dist/shell-source-maps/assets/parse-worker-MvbeuzYJ.js.map +0 -1
  248. package/dist/shell-source-maps/assets/render-node-BbfwkxfK.js.map +0 -1
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-w7lrzAmt.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-B4Vl9AEn.js","assets/vendor-t7Q7QbPu.js","assets/app-lQJl2mz_.css","assets/lib-xyflow-system-hojcPWkY.js","assets/lib-d3-interpolate-C7dFwq8w.js","assets/lib-d3-color-B6XHLQii.js","assets/lib-d3-selection-C1a5EtaJ.js","assets/lib-d3-drag-CUJR_Vab.js","assets/lib-d3-dispatch-Bjkn7q4t.js","assets/lib-d3-zoom-DuEhbOrX.js","assets/lib-d3-transition-CUMO2iZu.js","assets/lib-d3-timer-CduGpaSm.js","assets/lib-d3-ease-ouQSXgQM.js","assets/lib-xyflow-react-CuNAzocq.js","assets/lib-classcat-otpLnDWv.js","assets/lib-zustand-r6mNROKr.js","assets/lib-use-sync-external-store-D4s7MiFL.js","assets/lib-xyflow-react-DLioOiRN.css","assets/use-elk-u1Ql5AOs.js","assets/lib-elkjs-ylMkguT9.js"])))=>i.map(i=>d[i]);
2
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$s as r,A as i,Aa as a,Cc as o,Cl as s,Cn as c,Cr as l,Dc as u,Dl as d,Dn as f,Ec as p,En as m,Fa as h,Fn as g,Fs as _,Ft as v,Ga as y,Gc as b,Gn as x,Hc as S,Hi as C,Hs as w,I as T,Ii as E,Is as ee,It as te,Ja as ne,Js as re,Kn as ie,Kr as D,Ks as ae,Lc as oe,Ls as se,Ml as ce,Mn as le,Mt as ue,N as de,Nn as fe,Nt as pe,O as me,Oa as he,Ol as ge,On as _e,Oo as ve,Pa as ye,Pl as be,Ps as O,Pt as xe,Qc as Se,Qn as Ce,Qs as we,Ra as Te,Ri as Ee,Rs as k,Sa as De,Sc as A,Sn as Oe,Sr as j,Ss as ke,Tc as M,Ti as Ae,Tl as je,Tn as Me,Ts as Ne,Un as Pe,Uo as N,Ur as Fe,Us as Ie,V as Le,Wn as Re,Ws as ze,Xl as Be,Xr as Ve,Xt as P,Ya as He,Yl as Ue,Ys as We,Zi as Ge,Zt as Ke,_c as qe,_r as F,_t as Je,a as Ye,ac as Xe,an as Ze,ao as Qe,as as $e,at as et,b as tt,bc as nt,bn as rt,br as it,c as at,ca as ot,cn as st,co as ct,cr as lt,cs as I,da as ut,dr as dt,ds as L,ec as ft,en as pt,fn as mt,fs as ht,ga as gt,gc as _t,gl as vt,gn as yt,gr as R,gs as bt,gt as xt,ha as St,hc as Ct,hl as wt,hn as Tt,ho as Et,hr as Dt,hs as z,ic as Ot,ir as kt,ja as At,ji as jt,ka as Mt,kc as Nt,ki as Pt,la as Ft,ln as It,ls as Lt,mn as Rt,ms as zt,nc as Bt,nn as Vt,ns as Ht,nu as Ut,oc as Wt,ol as B,oo as V,os as Gt,pc as Kt,pn as qt,pr as Jt,ps as H,qn as Yt,qr as Xt,qs as Zt,rc as Qt,rr as $t,ru as en,sc as tn,sl as U,sn as nn,so as rn,sr as an,ss as W,tc as on,tl as sn,ts as cn,u as ln,un as G,ur as un,us as K,uu as dn,v as fn,vc as pn,vi as mn,vo as hn,vr as gn,vs as q,w as _n,wn as vn,wt as yn,x as bn,xn,xo as Sn,xr as J,xs as Cn,y as wn,yl as Tn,yn as En,yo as Dn,yr as On,ys as kn,z as An,zc as jn,zs as Mn}from"./app-B4Vl9AEn.js";import{C as Nn,f as Pn,o as Fn,s as In}from"./vendor-t7Q7QbPu.js";import{C as Ln,Ct as Rn,Dt as zn,Et as Bn,O as Vn,Ot as Hn,Q as Un,St as Wn,Tt as Gn,X as Kn,Z as qn,_t as Jn,at as Yn,b as Xn,ct as Zn,dt as Qn,ft as $n,gt as er,it as tr,jt as nr,k as rr,l as ir,lt as ar,mt as or,n as sr,nt as cr,o as lr,ot as ur,rt as dr,st as fr,t as pr,tt as mr,ut as hr,wt as gr,x as _r,xt as vr,y as yr}from"./embedded-list-B0wJoqm3.js";import{t as br}from"./circle-alert-DYA4c4B7.js";import{t as xr}from"./page-header-Ddz2r5ic.js";import{n as Sr,t as Cr}from"./pending-invitation-row-xX2VAQLM.js";import{n as wr,t as Tr}from"./person-row-CjXGB6eY.js";import{n as Er,t as Dr}from"./use-paged-search-BWcRlArY.js";import{n as Or,t as kr}from"./client-publisher-D39SlIhp.js";import{t as Ar}from"./copy-field-D_iD-sgT.js";var jr={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};jr.node;var Mr=B(jr),Nr={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};Nr.node;var Pr=B(Nr),Fr={name:`key-square`,size:24,node:[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]};Fr.node;var Ir=B(Fr),Lr={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};Lr.node;var Rr=B(Lr),zr={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};zr.node;var Br=B(zr),Vr={name:`shield-user`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]};Vr.node;var Hr=B(Vr),Ur={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Ur.node;var Wr=B(Ur),Gr={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};Gr.node;var Kr=B(Gr),qr=[`done`,`error`,`running`];Wt(`TextField`,!1),Wt(`NumberField`,!1),Wt(`DateField`,!1),Wt(`BooleanField`,!1),Wt(`UrlField`,!1),Wt(`ChipField`,!1);var Jr=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Yr=e=>typeof e!=`string`&&!e.custom&&Jr.has(e.type),Xr=e=>typeof e==`string`||Yr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Zr=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Qr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),$r=(e,{locales:t,options:n},r)=>{let i=typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))?Number(e):e;return typeof i==`number`?i.toLocaleString(t??r,n):String(i)},ei=(e,t,n)=>{let r=e instanceof Date?e:typeof e==`string`||typeof e==`number`?new Date(e):void 0;if(!r||Number.isNaN(r.getTime()))return``;if(t.format===`relative`)return n.relative(Math.round((n.now-r.getTime())/1e3));let{showDate:i=!0,showTime:a=!1,options:o}=t,s=t.locales??n.locale;if(i&&a)return r.toLocaleString(s,o);if(a)return r.toLocaleTimeString(s,o);let c=o??(typeof e==`string`&&e.length<=10?{timeZone:`UTC`}:void 0);return r.toLocaleDateString(s,c)},ti=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,ni=new Set([`http:`,`https:`,`mailto:`,`tel:`]),ri=e=>{let t=e.replace(/^[\u0000- ]+/,``).replace(/[\t\n\r]/g,``),n=/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(t)?.[1];return n===void 0?t.startsWith(`/`)||!t.includes(`:`)?e:void 0:ni.has(`${n.toLowerCase()}:`)?e:void 0},ii=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),ai=e=>e==null||e===``?void 0:String(e),oi=(e,t)=>e<t?-1:+(e>t),si=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=ai(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=ai(r);s!==void 0&&!o.has(s)&&o.set(s,{id:s,value:r}),a.set(e,{id:e,row:t,...s!==void 0&&{group:s}})}let s=t.flatMap(e=>{let t=r.map(t=>ai(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=ai(e[i.source]),s=ai(e[i.target]);return n===void 0||o===void 0||s===void 0||!a.has(o)||!a.has(s)?[]:[{id:n,source:o,target:s,row:e}]});return{groups:[...o.values()].sort((e,t)=>oi(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>oi(e.id,t.id)),edges:s.sort((e,t)=>oi(e.source,t.source)||oi(e.target,t.target)||oi(e.id,t.id))}},Y=e(t(),1),X=e(n(),1),ci=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=q(),s=Rn(e.name,void 0),c=Ge(),[l,u]=(0,Y.useState)(!1),d=o[e.name]?.actions?.find(e=>e.name===n);if(!d||d.run?.kind===`link`)return null;let f=t.map(t=>rt(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let m=f.length-p.length,h=vr(`actionCount`,{label:r??d.label,count:p.length}),g=e=>s.runEach(d,p,m,e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>Bn(d)?u(!0):void g(),children:h}),l&&(0,X.jsx)(Gn,{action:d,label:h,danger:i===`danger`||i===void 0&&zn(d),records:p.map(e=>e.record),names:p.map(t=>Wn(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),g()},onSubmit:async e=>{u(!1),await g(e)}})]})},li=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=Dt(),c=gr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,Y.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{size:`sm`,variant:f,className:i,loading:c.running,disabled:!!c.blocked,title:c.blocked,"aria-label":a===void 0?void 0:`${d}: ${a}`,onClick:()=>Bn(c.action)?u(!0):void c.run(),children:d}),l&&(0,X.jsx)(Gn,{action:c.action,label:d,danger:f===`danger`,records:c.record?[c.record]:[],onCancel:()=>u(!1),onConfirm:()=>{u(!1),c.run()},onSubmit:async e=>{await c.submit(e),u(!1)}})]})},ui=({node:e,className:t})=>{let n=G(e),r=it(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,X.jsx)(ci,{...n,model:i,items:r.items,className:t}):(0,X.jsx)(li,{...n,className:t})},di=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=G(e);return(0,X.jsx)(J,{title:i,description:a,actions:n.actions,className:U(`h-full`,r),children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},fi=({children:e,wrap:t=(e,t)=>(0,X.jsx)(Y.Fragment,{children:e},t)})=>{let n=it();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...rt(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,X.jsx)(dt,{value:s,row:{index:o,count:i.length},children:e}),c)})},pi=({children:e})=>(0,X.jsx)(fi,{children:e}),mi=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:u,children:d,className:f})=>{let p=nn(t),m=c(e,{filter:n,sort:r,pageSize:i,enabled:!p}),h=p??m,g=p?p.rows:m.data?.items??[];return(0,X.jsx)(J,{title:a,description:o,actions:u,className:f,children:h.isPending?(0,X.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(A,{className:`h-24 w-56`},t))}):h.error?(0,X.jsx)(l,{title:V(`couldNotLoad`),error:h.error}):g.length===0?(0,X.jsx)(j,{children:s??V(`nothingYet`)}):(0,X.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,X.jsx)(gn,{value:{model:e,items:g,...p&&{planned:!0}},children:(0,X.jsx)(fi,{wrap:(e,t)=>(0,X.jsx)(`li`,{className:`flex w-60 shrink-0 snap-start flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:e},t),children:d})})})})},hi=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=G(e),o=q().resources[i];return o?(0,X.jsx)(mi,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},gi=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=G(e),{resources:u,views:d}=q(),f=u[r];return f?(0,X.jsx)(J,{title:i,description:a,actions:t.actions,className:U(`h-full`,n),children:(0,X.jsx)($n,{model:f,view:d[r],...l})}):null},_i=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=Oe(e,t),a=i.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(A,{className:`h-4 w-1/2`}),(0,X.jsx)(A,{className:`h-4 w-1/3`})]}):i.error?(0,X.jsx)(l,{title:V(`couldNotLoad`),error:i.error}):i.data?(0,X.jsx)(dt,{value:i.data,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,X.jsx)(j,{children:V(`nothingYet`)});return(0,X.jsx)(`div`,{className:n,children:a})},vi=e=>{if(typeof e!=`string`&&typeof e!=`number`)return;let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?void 0:t},yi=e=>e==null?``:String(e),bi=(e,t,n)=>n===0?0:(e-t)/n*100,xi=(e,t,n)=>{let r=new Map;for(let i of e){let e=vi(i[t.start]);if(e===void 0)continue;let a=vi(i[t.end]),o=Math.max(e,a??n),s=r.get(yi(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(yi(i[t.lane]),s);let c=s.bars.get(yi(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(yi(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},Si=e=>{let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start)){let e=t.find(e=>e.at(-1).end<=n.start);e?e.push(n):t.push([n])}return t},Ci=(e,t,n)=>{let r=xi(e,t,n),i=[...r.values()].flatMap(e=>[...e.bars.values()].flatMap(e=>e.records));if(i.length===0)return{lanes:[],from:n,to:n};let a=Math.min(...i.map(e=>e.start)),o=Math.max(...i.map(e=>e.end)),s=o-a;return{lanes:[...r.entries()].map(([e,n])=>{let r=[...n.bars.entries()].map(([e,r])=>{let i=r.records.sort((e,t)=>e.start-t.start).map(({record:e,start:n,end:r,open:i})=>({record:e,value:e[t.color],start:n,end:r,open:i,left:bi(n,a,s),width:bi(r,a,s)-bi(n,a,s)})),o=i[0].start,c=Math.max(...i.map(e=>e.end));return{key:e,value:r.value,lane:n.value,start:o,end:c,left:bi(o,a,s),width:bi(c,a,s)-bi(o,a,s),segments:i}});return{key:e,value:n.value,rows:Si(r)}}),from:a,to:o}},wi=(e,t)=>{let n=e.end-e.start;return{left:bi(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},Ti=6e4,Ei=60*Ti,Z=24*Ei,Di=[5*Ti,15*Ti,30*Ti,Ei,3*Ei,6*Ei,12*Ei,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],Oi=365*Z,ki=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Ai=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=Di.find(n=>ki(e,t,n,i,a)<=6)??Math.ceil(r/5/Oi)*Oi,s=[];for(let c=Math.ceil((e+i)/o)*o;c<=t+a;c+=o){let a=c-n(c-i);a+n(a)===c&&a>=e&&a<=t&&s.push({at:a,left:bi(a,e,r)})}return{daily:o>=Z,ticks:s}},ji=e=>({lane:yi(e.lane),bar:e.key}),Mi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ni=(e,t)=>{let n=Object.fromEntries(new Intl.DateTimeFormat(`en-US`,{timeZone:t,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}).formatToParts(e).map(e=>[e.type,e.value]));return Date.UTC(Number(n.year),Number(n.month)-1,Number(n.day),Number(n.hour),Number(n.minute))-Math.floor(e/6e4)*6e4},Pi=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Fi=({from:e,to:t,dated:n})=>{let r=n?`UTC`:De(),i=e=>n?0:Ni(e,r),{daily:a,ticks:o}=Ai(e,t,i);return(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`relative h-5 min-w-0 flex-1 border-b border-border text-xs text-muted-foreground tabular-nums`,children:o.map(e=>(0,X.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Pi(e.left)}`,style:{left:`${e.left}%`},children:a?ut(e.at+i(e.at)):gt(e.at,r)},e.at))})},Ii=(e,t,n)=>{let r=String(n),i=t?.waitingValues?.includes(r)??!1,a=t?.valueColors&&Object.hasOwn(t.valueColors,r)?t.valueColors[r]:void 0;return a!==void 0&&be(a)?{className:zt[a],striped:i}:{color:er(e,t,n===void 0?null:n,-1),striped:i}},Li=e=>({...e.color!==void 0&&{backgroundColor:e.color},...e.striped&&{backgroundImage:`repeating-linear-gradient(-45deg, transparent 0 4px, color-mix(in srgb, var(--background) 55%, transparent) 4px 6px)`}}),Ri=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Ii(t,n,r.value),{left:o,width:s}=wi(e,r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...Li(a)}},i)}),zi=(e,t)=>t?ot(e):Ft(e),Bi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return V(`timelineRange`,{from:zi(n,a),to:i?V(`timelineNow`):zi(r,a)})},Vi=(e,t,n,r)=>`${Ae(t.fields[r.color],e.value,n?.fields[r.color])}: ${Bi(t,r,e.start,e.end,e.open)}`,Hi=(e,t,n,r,i)=>{let a=e.segments.some(t=>t.open&&t.end===e.end);return[`${i??Ae(t.fields[r.bar],e.value,n?.fields[r.bar])}: ${Bi(t,r,e.start,e.end,a)}`,...e.segments.map(e=>Vi(e,t,n,r))].join(`; `)},Ui=`absolute inset-y-0 flex overflow-hidden rounded-sm ring-offset-1 ring-offset-background outline-none hover:ring-2 hover:ring-border-strong focus-visible:ring-2 focus-visible:ring-primary`,Wi=({bar:e,model:t,view:n,fields:r,point:i,choose:a})=>{let o=q().resources[t.fields[r.bar]?.relation?.resource??``],s=g(o??t,e.key,o!==void 0),c=Hi(e,t,n,r,o?s:void 0),l={onMouseEnter:()=>i.hover(e),onMouseLeave:()=>i.hover(null),onFocus:()=>i.focus(e),onBlur:()=>i.focus(null)},u={left:`${e.left}%`,width:`max(${e.width}%, 4px)`},d=(0,X.jsx)(Ri,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,X.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Ui,...l,children:d});let f=a.chosen===e.key;return(0,X.jsx)(nt,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:U(Ui,f&&`ring-2 ring-foreground`),...l,children:d})},Gi=({shape:e,...t})=>{let{model:n,fields:r}=t,i=n.fields[r.lane];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,X.jsx)(Fi,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,X.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,X.jsx)(Me,{model:n,field:i,value:e.value})}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 border-l border-border pl-px`,children:e.rows.map((e,n)=>(0,X.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,X.jsx)(Wi,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ki=({model:e,view:t,fields:n,value:r})=>{let i=Ii(e.fields[n.color],t?.fields[n.color],r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:Li(i)})},qi=({values:e,...t})=>{let n=t.model.fields[t.fields.color],r=(n.enumValues??[]).filter(t=>e.has(t));return(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(Ki,{...t,value:e}),Ae(n,e,t.view?.fields[t.fields.color])]},e))})},Ji=({bar:e,...t})=>{let{model:n,view:r,fields:i}=t;if(!e)return(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:V(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:(0,X.jsx)(Me,{model:n,field:n.fields[i.bar],value:e.value})}),(0,X.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Bi(n,i,e.start,e.end,a)})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,X.jsx)(Ki,{...t,value:e.value}),Ae(n.fields[i.color],e.value,r?.fields[i.color]),`: `,Bi(n,i,e.start,e.end,e.open)]},a))})]})},Yi=500,Xi=(e,t,{filter:n=``,sort:r,fields:i,limit:a})=>({queryKey:[...wt.list(t.name,n,r,a,`timeline`),i.join(`,`)],queryFn:async()=>{let o=[],s;do{let c=await e.list(t.name,{filter:n||void 0,orderBy:r,pageSize:Math.min(Yi,a-o.length),fields:i,etag:!1,...s&&{pageToken:s}});o.push(...c.items),s=c.nextPageToken||void 0}while(s&&o.length<a);return{rows:o.toReversed(),cut:s!==void 0}}}),Zi=(e,{enabled:t=!0,...n})=>Fn({...Xi(Ne(),e,n),enabled:t,placeholderData:Pn}),Qi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=on,title:s,description:c,empty:u,actions:d,className:f,choose:p,details:m})=>{let[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),y=e=>e?ji(e):null,b={hover:e=>g(y(e)),focus:e=>v(y(e))},x=nn(i),S=Zi(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!x}),C=x??S,w=x?x.rows:S.data?.rows??[],T=!x&&S.data?.cut===!0,E=Ci(w,n,Date.now());return(0,X.jsxs)(J,{title:s,description:c,actions:d,className:U(`h-full`,f),children:[(()=>{if(C.isPending)return(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(A,{className:`h-6`},t))});if(C.error)return(0,X.jsx)(l,{title:V(`couldNotLoad`),error:C.error});if(E.lanes.length===0)return(0,X.jsx)(j,{children:u??V(`nothingYet`)});let r=new Set(w.map(e=>String(e[n.color])));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(qi,{model:e,view:t,fields:n,values:r}),(0,X.jsx)(Gi,{shape:E,model:e,view:t,fields:n,point:b,...p&&{choose:p}}),T&&(0,X.jsx)(j,{children:V(`timelineCut`,{count:w.length})}),(0,X.jsx)(`div`,{"aria-live":`polite`,children:(0,X.jsx)(Ji,{bar:Mi(E,h)??Mi(E,_),model:e,view:t,fields:n})})]})})(),m]})},$i=(e,t)=>e.type===`integer`?Number(t):t,ea=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=lt(),a=r[e],o=t=>i({[e]:t}),s=n.model.fields[n.fields.bar],c=a===void 0?null:(0,X.jsx)(pn,{name:e,children:(0,X.jsx)(_i,{model:n.model,query:{filter:Jn(s,$i(s,a),n.filter),sort:n.sort},children:t},a)});return(0,X.jsx)(Qi,{...n,choose:{barTo:o,chosen:a},details:c})},ta=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,lane:c,bar:l,start:u,end:d,color:f,children:p,...m}=G(e),{resources:h,views:g}=q(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Bt(e),sort:Qt(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,X.jsx)(Qi,{...v}):(0,X.jsx)(ea,{...v,select:s,children:r})},na=({node:e,children:t})=>{let n=Xe(e),r=un(),{resources:i}=q();if(!n||!r)return t;let a=r.given[n.param],o=n.resource===void 0?void 0:i[n.resource];return a===void 0||!o?null:(0,X.jsx)(pn,{name:n.param,children:(0,X.jsx)(_i,{model:o,query:{key:a},className:``,children:t},a)})},ra=(0,Y.lazy)(()=>Nn(()=>import(`./graph-view-w7lrzAmt.js`).then(e=>({default:e.GraphView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),ia=(0,X.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,X.jsx)(u,{})}),aa=({node:e,at:t,slots:n,children:r,className:i})=>{let a=G(e),o=Ze(e,t),s=un(),c=o.nodes,u=o.edges,{label:d,group:f,status:p,source:m,target:h}=a,g=(0,Y.useMemo)(()=>({label:d,source:m,target:h,...f!==void 0&&{group:f},...p!==void 0&&{status:p}}),[d,m,h,f,p]),_=JSON.stringify([c?.rows,u?.rows,g]),v=(0,Y.useMemo)(()=>c&&u&&si({nodes:c.rows,edges:u.rows,key:c.model.primaryKey[0],edgeKey:u.model.primaryKey,fields:g}),[_]);if(!c||!u||!v)return null;let y=c.error??u.error;if(y&&e.fallback)throw y;if(y)return(0,X.jsx)(l,{title:V(`couldNotLoad`),error:y});if(c.isPending||u.isPending)return ia;if(v.nodes.length===0)return(0,X.jsx)(j,{children:a.empty??V(`nothingYet`)});let b=a.select,x=b!==void 0&&s?{chosen:s.given[b],linkTo:e=>s.linkTo({[b]:e})}:void 0;return(0,X.jsxs)(`div`,{className:U(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Y.Suspense,{fallback:ia,children:(0,X.jsx)(ra,{shape:v,nodes:c,edges:u,fields:g,props:a,...x&&{select:x},...a.node!==void 0&&{content:n.node}})})}),r.length>0&&x?.chosen!==void 0&&(0,X.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,X.jsx)(na,{node:e,children:r})})]})},oa=({onPick:e,accept:t})=>{let n=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{ref:n,type:`file`,multiple:!0,hidden:!0,accept:t,"aria-label":P(`filesToAttach`),onChange:t=>{e([...t.target.files??[]]),t.target.value=``}}),(0,X.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":P(`attachFiles`),title:P(`attachFiles`),onClick:()=>n.current?.click(),children:(0,X.jsx)(jn,{className:`size-4`})})]})},sa=`message`,ca=(e,t,n,r)=>[{op:`create`,resource:e,ref:sa,data:t},...r.map(e=>({op:`create`,resource:n.resource,data:{[n.field]:{$ref:sa},[n.file]:e}}))],la=e=>{let t=e.results[0];if(t?.op!==`create`)throw Error(`A message batch starts with the message it creates`);return t.record},ua=(e,t,n,r)=>[...e.attachments?r.map(t=>({op:`delete`,resource:e.attachments.resource,key:t.key})):[],{op:`delete`,resource:e.resource,key:ln(t,n)}],da=(e,t)=>{if(!(t===void 0||e.size<=t))return P(`fileTooLarge`,{size:Ee(e.size),max:Ee(t)})},fa=(e,t,n)=>e.map((e,r)=>({key:t+r,name:e.name,size:e.size,sent:0,refusal:da(e,n)})),pa=e=>e.ticket===void 0&&e.refusal===void 0,ma=e=>e.flatMap(e=>e.ticket===void 0?[]:[e.ticket]),ha=e=>!e.some(pa)&&ma(e).length>0,ga=e=>e.refusal===void 0?e.ticket!==void 0||e.size===0?Ee(e.size):P(`uploadedPercent`,{percent:Math.floor(Math.min(e.sent,e.size)/e.size*100)}):e.refusal,_a=({uploads:e,onRemove:t})=>(0,X.jsx)(`ul`,{"aria-label":P(`filesToSend`),className:`flex flex-wrap gap-2`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex max-w-full items-center gap-1 rounded-md border border-border py-0.5 pl-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:e.name}),(0,X.jsx)(`span`,{role:e.refusal===void 0?void 0:`alert`,className:U(`min-w-0`,e.refusal===void 0?`text-muted-foreground`:`text-danger-text`),children:ga(e)}),(0,X.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":P(`takeFileOff`,{name:e.name}),title:P(`takeFileOff`,{name:e.name}),onClick:()=>t(e.key),children:(0,X.jsx)(Nt,{className:`size-3.5`})})]},e.key))}),va=e=>{let t=Ne(),{resources:n}=q(),r=e&&n[e.resource]?.fields[e.file]?.file?.maxSize,[i,a]=(0,Y.useState)([]),o=(0,Y.useRef)(0),s=(0,Y.useRef)(new Map),c=(e,t)=>a(n=>n.map(n=>n.key===e?{...n,...t}:n)),l=(e,n,r)=>{let i=new AbortController;s.current.set(n.key,i),t.upload(e.resource,e.file,r,{signal:i.signal,onProgress:e=>c(n.key,{sent:e})}).then(e=>c(n.key,{ticket:e.value}),e=>{i.signal.aborted||c(n.key,{refusal:P(`fileNotUploaded`,{reason:mn(e)})})}).finally(()=>s.current.delete(n.key))};return(0,Y.useEffect)(()=>{let e=s.current;return()=>e.forEach(e=>e.abort())},[]),{uploads:i,tickets:ma(i),uploading:i.some(pa),ready:ha(i),pick:t=>{if(!e||t.length===0)return;let n=fa(t,o.current,r);o.current+=t.length,a(e=>[...e,...n]),n.forEach((n,r)=>{n.refusal===void 0&&l(e,n,t[r])})},remove:e=>{s.current.get(e)?.abort(),a(t=>t.filter(t=>t.key!==e))},sent:e=>a(t=>t.filter(t=>pa(t)||t.ticket!==void 0&&!e.includes(t.ticket)))}},Q=vt(`app/conversation`),ya=({resource:e,field:t,values:n,placeholder:r,searchPeople:i,mentions:a,attachments:o,onDraft:s,onSent:c})=>{let{resources:u}=q(),d=Ne(),f=vn(),p=kn(e),[m,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(),y=va(o);if(!u[e]||!Te(p,`create`))return null;let b=o&&u[o.resource]?.fields[o.file],x=b&&E(b);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[_!==void 0&&(0,X.jsx)(l,{title:Q(`notSent`),error:_}),(0,X.jsx)(yn,{onSend:async(r,i)=>{g(!0),v(void 0);let s=y.tickets,l={...n,...r!==``&&{[t]:r},...a!==void 0&&{[a]:i}},p=o&&s.length>0?d.batchWrite(ca(e,l,o,s)).then(la):d.create(e,l).then(e=>e.record),m=u[e],_=await p.then(e=>(c?.(String(h(m,e))),!0),e=>(v(e),!1));return g(!1),_?(f(e),o&&y.sent(s),o&&s.length>0&&f(o.resource),!0):!1},busy:m||y.uploading,placeholder:r,searchPeople:i,onDraft:s,...o&&{actions:(0,X.jsx)(oa,{onPick:y.pick,accept:x}),attachments:y.uploads.length>0&&(0,X.jsx)(_a,{uploads:y.uploads,onRemove:y.remove}),canSendEmpty:y.ready,onFiles:y.pick}})]})},ba=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=G(e);return(0,X.jsx)(ya,{resource:t,field:n,values:r,placeholder:i})},xa=({node:e,children:t,className:n})=>{let{open:r}=G(e);return(0,X.jsx)(`details`,{open:r,className:U(`[&[open]>summary]:mb-2`,n),children:t})},Sa=({children:e,className:t})=>(0,X.jsx)(`summary`,{className:U(`cursor-pointer font-medium`,t),children:e}),Ca=({node:e,className:t})=>{let{source:n,emptyText:r}=G(e),i=Tt(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,X.jsx)(A,{className:U(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,X.jsx)(`p`,{className:U(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=xt(a);return o?(0,X.jsx)(`div`,{className:U(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,X.jsx)(Je,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,X.jsx)(`pre`,{className:U(`overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-border bg-background p-3 font-mono text-[0.6875rem] leading-[18px]`,t),children:a})},wa=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),Ta=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>ge(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},Ea=({node:e,className:t})=>{let{source:n,label:r,format:i}=G(e),{views:a}=q(),o=Tt(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,X.jsx)(A,{className:`h-4 w-24`}):o.state===`plain`?wa(o.value):(0,X.jsx)(Me,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,X.jsx)(`div`,{className:t,children:s});let c=r??Ta(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:U(`min-w-0`,t),children:[(0,X.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate`,children:s})]})},Da={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},Oa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ka={1:``,2:`md:col-span-2`,3:`md:col-span-2 xl:col-span-3`,4:`sm:col-span-2 md:col-span-2 xl:col-span-4`},Aa=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ja=({node:e,children:t,className:n})=>{let{columns:r=2}=G(e),i=e.children,a=i.length>0&&i.every(Aa);return(0,X.jsx)(`div`,{className:U(`grid grid-cols-1 gap-4`,a?Oa[r]:Da[r],n),children:t.map((e,t)=>{let n=i[t],r=typeof n==`object`?n.props.span:void 0;return(0,X.jsx)(`div`,{className:U(`min-w-0`,r&&ka[r]),children:e},t)})})},Ma=({src:e,alt:t,width:n,height:r,className:i})=>(0,X.jsx)(`img`,{src:e,alt:t??``,width:n,height:r,className:i??`max-w-full`}),Na=({width:e,height:t,space:n,theme:r})=>{let i=e??Math.ceil(n/100)*100;if(i!==0)return{width:String(i),...t!==void 0&&{height:String(t)},theme:r}},Pa=e=>({staleTime:1/0,refetchOnWindowFocus:!1,...e!==void 0&&{refetchInterval:e*1e3}}),Fa=e=>e instanceof Blob&&e.type.startsWith(`image/`),Ia=e=>{let[t,n]=(0,Y.useState)();return(0,Y.useEffect)(()=>{if(!e)return n(void 0);let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t},La=e=>{let[t,n]=(0,Y.useState)();return[t!==void 0&&t===e,()=>n(e)]},Ra=({name:e,alt:t,width:n,height:r,refresh:i,className:a})=>{let o=Ne(),{theme:s}=He(),[c,l]=et(),u=Na({width:n,height:r,space:l,theme:s}),d=Fn({queryKey:wt.image(e,u??{}),enabled:u!==void 0,placeholderData:Pn,...Pa(i),queryFn:async()=>{let t=await o.invoke(e,{query:u,cache:`no-store`});if(!Fa(t))throw Error(`The function "${e}" answered no picture`);return t}}),f=Ia(d.data),[p,m]=La(f),h={...n!==void 0&&{width:n},...r!==void 0&&{height:r}};return(0,X.jsx)(`div`,{ref:c,className:U(`min-w-0`,a),children:d.isError||p?t&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:t}):f?(0,X.jsx)(`img`,{src:f,alt:t??``,onError:m,style:h,className:n===void 0?`w-full max-w-full object-contain`:`max-w-full object-contain`}):(0,X.jsx)(A,{className:`w-full max-w-full`,style:{height:r??160,...n!==void 0&&{width:n}}})})},za=({node:e,className:t})=>{let n=G(e);return n.src===void 0?(0,X.jsx)(Ra,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,X.jsx)(Ma,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},Ba=e=>function({node:t,className:n}){let r=G(t),{views:i}=q(),a=Tt(r.source);return a.state===`missing`?null:a.state===`loading`?(0,X.jsx)(A,{className:`inline-block h-3 w-16 align-middle`}):Zr(t.type,a.value)?r.emptyText?(0,X.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:a.field,hints:i[a.model.name]?.fields[a.field.name],props:r})})},Va=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?d(e,n?.valueLabels):Qr(e),Ha=Ba(Va),Ua=Ba(({value:e,props:t})=>(0,X.jsx)(`span`,{className:`tabular-nums`,children:$r(e,t,Tn())})),Wa=Ba(({value:e,props:t})=>{let n=ei(e,t,{locale:Tn(),now:Date.now(),relative:St});return(0,X.jsx)(`time`,{dateTime:String(e),children:n})}),Ga=Ba(({value:e,props:t})=>{let n=ti(e,t,{yes:C(`yes`),no:C(`no`)});return e?(0,X.jsx)(Ce,{label:n,className:`align-middle`}):(0,X.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ka=Ba(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=ri(n);return i===void 0?r:(0,X.jsx)(`a`,{href:i,className:`font-medium text-primary-text hover:underline`,.../^https?:/i.test(i)&&{target:`_blank`,rel:`noreferrer`},children:r})}),qa=Ba(e=>(0,X.jsx)(fe,{value:e.value,hints:e.hints,children:Va(e)})),Ja=`font-medium text-primary-text hover:underline`,Ya=({node:e,children:t,className:n})=>{let r=G(e),i={...F(R()),params:an()},a=r.variant?U(p({variant:r.variant}),n):n??Ja,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=Ut(r.to,Ie(i));return(0,X.jsx)(D,{to:e,className:a,children:o??Kt(e)})}let s=r.href??``;return(0,X.jsx)(`a`,{href:s,className:a,...s.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??s})},Xa=(e,t,n)=>Object.fromEntries(t.map(t=>{let r=e.fields[t];if(r.type===`file`)return[t,n?.[t]??null];if(n)return[t,r.type===`boolean`?!!n[t]:me(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:me(i)]})),Za=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let a=e.fields[t];return at(r)?r.key===me(n[t])?[]:[[t,a.type===`integer`?Number(r.key):r.key]]:_n(a,r,n[t])?[[t,i(a,r)]]:[]})),Qa=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:s,onClose:c})=>{let{resources:u,views:d}=q(),f=Ne(),p=ne(),m=vn(),h=d[e.name],[g,_]=(0,Y.useState)(()=>Xa(e,a,t?.record)),[v,y]=(0,Y.useState)({}),[b,x]=(0,Y.useState)(0),S=fn(b),[C,w]=(0,Y.useState)(),[T,E]=(0,Y.useState)(!1),[ee,te]=(0,Y.useState)(!1);_t(ee||T,`input-lost`);let re=async()=>{E(!0),w(void 0),await(n===`create`?f.create(e.name,{...Ye(e,u,g),...s}):f.update(e.name,t.key,Za(e,g,t.record),t.etag??`*`)).then(async()=>{await m(e.name),p.show({state:`success`,title:V(`saved`,{label:i??r})}),c()},e=>{let t=wn(e);y(t),Object.keys(t).length>0&&x(e=>e+1),w(e)}),E(!1)};return(0,X.jsx)(o,{title:i??r,onClose:c,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:c,children:V(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:T,onClick:()=>void re(),children:V(n===`create`?`create`:`save`)})]}),children:(0,X.jsxs)(`form`,{ref:S,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),re()},children:[C!==void 0&&Object.keys(v).length===0&&(0,X.jsx)(l,{title:V(`notSaved`),error:C}),a.map(n=>{let r=e.fields[n],i=g[n],a=r.relation?u[r.relation.resource]:void 0,o=h?.fields[n]?.label??ge(n),s=v[n];return(0,X.jsx)(An,{name:n,label:o,help:h?.fields[n]?.help,error:s&&tt(r,o,s),children:(0,X.jsx)(bn,{field:r,hints:h?.fields[n],value:at(i)?i.key:i,stored:t?.record[n],relationLabel:at(i)?i.label:void 0,relationPicker:a?{target:a,view:d[a.name]}:void 0,invalid:!!v[n],resource:e.name,onChange:e=>{y(({[n]:e,...t})=>t),te(!0),_(t=>({...t,[n]:e}))}})},n)})]})})},$a=({model:e,recordKey:t,children:n})=>{let r=Oe(e,{key:t});return(0,X.jsx)(X.Fragment,{children:n(r.data??void 0)})},eo=({node:e})=>{let t=G(e),n=Dt(),{resources:r}=q(),i=r[t.resource??n?.model.name??``],a=kn(i?.name??``),[o,s]=(0,Y.useState)(!1);if(!i||!(t.mode===`create`?Te(a,`create`):Te(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,X.jsx)(Qa,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,X.jsx)($a,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},to=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=G(e);return(0,X.jsx)(`div`,{className:U(`flex-1`,r),children:(0,X.jsxs)(`div`,{className:U(`flex flex-col gap-6 px-4 pb-16 pt-6 md:px-10 md:py-8`,o!==`full`&&`mx-auto max-w-[1200px]`),children:[(0,X.jsx)(xr,{title:i,subtitle:a,actions:n.actions}),t]})})},no=(e,t)=>{let n=R(),r=typeof e==`string`?Jt(n,e):void 0,i=qt(r&&`frame`in r?r.frame:void 0,r&&`path`in r?r.path:``);return typeof e==`number`?e:e===void 0?t:r&&`item`in r?Number(r.item):i.state===`ready`?Number(i.value):i.state===`loading`?void 0:NaN},ro=({node:e,className:t})=>{let{value:n,max:r,label:i}=G(e),a=no(n,0),o=no(r,100);if(a===void 0||o===void 0)return(0,X.jsx)(A,{className:`h-6 w-full`});if(!Number.isFinite(a)||!Number.isFinite(o))return null;let s=o>0?Math.min(1,Math.max(0,a/o)):0;return(0,X.jsxs)(`div`,{className:U(`min-w-0`,t),children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[a.toLocaleString(Tn()),` / `,o.toLocaleString(Tn())]})]}),(0,X.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":o,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:s>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${s*100}%`}})})]})},io=({model:e,at:t,filter:n,sort:r,recordKey:i,title:a,description:o,empty:s,actions:c,children:u,className:d})=>{let f=nn(t),p=Oe(e,{filter:n,sort:r,key:i,enabled:!f}),m=f?En(e,f):p,h=e=>m.data?(0,X.jsx)(dt,{value:m.data,children:e}):void 0,g=m.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(A,{className:`h-4 w-1/2`}),(0,X.jsx)(A,{className:`h-4 w-1/3`})]}):m.error?(0,X.jsx)(l,{title:V(`couldNotLoad`),error:m.error}):m.data?h((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:u})):(0,X.jsx)(j,{children:s??V(`nothingYet`)});return(0,X.jsx)(J,{title:a,description:o,actions:c?h(c):void 0,className:U(`h-full`,d),children:g})},ao=({node:e,at:t,children:n,slots:r,className:i})=>{let{resource:a,filter:o,sort:s,recordKey:c,title:l,description:u,empty:d}=G(e),f=q().resources[a];return f?(0,X.jsx)(io,{model:f,...t!==void 0&&{at:t},filter:o,sort:s,recordKey:c,title:l,description:u,empty:d,actions:r.actions,className:i,children:n}):null},oo=vt(`app/related-cards`),so=({children:e})=>{let t=(0,Y.useRef)(null),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,Y.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=()=>a(e.scrollHeight>e.parentElement.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[n]),(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,X.jsx)(`div`,{className:U(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,X.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,X.jsx)(M,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:oo(n?`showLess`:`showMore`)})]})},co=e=>e==null||e===``,lo=({scope:e,path:t,labelled:n=!0,clamped:r=!1})=>{let{views:i}=q(),a=qt(e,t);if(a.state===`missing`||a.state===`ready`&&co(a.value))return null;let o=a.state===`loading`?(0,X.jsx)(A,{className:`h-4 w-24`}):(0,X.jsx)(Me,{model:a.model,field:a.field,value:a.value}),s=r?(0,X.jsx)(so,{children:o}):o;if(!n)return(0,X.jsx)(`div`,{className:`min-w-0`,children:s});let c=Ta(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`dd`,{className:`mt-0.5`,children:s})]})},uo=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:s})=>{let c=Ge(),{resources:l}=q(),u=c(e.model,t,e.record,e.key),d=a.length>0||o!==void 0;return(0,X.jsxs)(`li`,{"data-card":e.key,className:U(`relative grid min-w-0 items-center gap-x-4 gap-y-1 rounded-lg border border-border bg-surface px-4 py-2.5`,d?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:[i&&(0,X.jsx)(pt,{view:t,field:i,record:e.record}),(0,X.jsxs)(`div`,{className:U(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,X.jsx)(D,{to:{kind:`record`,resource:e.model.name,key:h(e.model,e.record)},className:`line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere] text-primary-text hover:underline`,children:u}),r&&(0,X.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,X.jsx)(lo,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-y-0.5 text-body text-muted-foreground`,children:n.map(t=>(0,X.jsx)(`div`,{className:`flex max-w-full min-w-0 items-center whitespace-nowrap empty:hidden [&>div]:truncate [:not(:empty)~&]:before:mx-2 [:not(:empty)~&]:before:content-['·'_/_'']`,children:(0,X.jsx)(lo,{scope:e,path:t,labelled:!1})},t))}),d&&(0,X.jsx)(dt,{value:e,children:(0,X.jsxs)(`div`,{className:`col-start-2 flex flex-wrap items-center justify-end gap-2 sm:row-span-2 sm:row-start-1`,children:[o&&(0,X.jsx)(mr,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,X.jsx)(li,{name:e,about:u,onRun:e=>s?.(e,u)},e))]})})]})},fo=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let s=Ge(),{resources:c}=q(),l=s(e.model,t,e.record,e.key);return(0,X.jsxs)(`li`,{"data-card":e.key,className:`relative flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[r&&(0,X.jsx)(pt,{view:t,field:r,record:e.record}),(0,X.jsx)(D,{to:{kind:`record`,resource:e.model.name,key:h(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:l}),n.length>0&&(0,X.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,X.jsx)(lo,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,X.jsx)(dt,{value:e,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,X.jsx)(mr,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,X.jsx)(li,{name:e,about:l,onRun:e=>o?.(e,l)},e))]})})]})},po=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,mo=e=>[...e.querySelectorAll(`button`)].find(po)??e.querySelector(`a`),ho=(e,t,n)=>{let r=e.indexOf(n),i=e=>t.includes(e);return e.slice(r+1).find(i)??e.slice(0,Math.max(r,0)).findLast(i)},go=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},_o=e=>{let t=(0,Y.useRef)(null),n=(0,Y.useRef)({current:e,previous:e}),r=(0,Y.useRef)(void 0),[i,a]=(0,Y.useState)(``),o=(e,n,i)=>{if(r.current=void 0,i.includes(e.key)||!t.current||(a(oo(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=ho(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?mo(s):go(t.current))?.focus()};return(0,Y.useEffect)(()=>{let t=n.current.current;n.current={current:e,previous:t},r.current&&o(r.current,t,e)},[e]),{root:t,acted:(e,t,i)=>{let{current:a,previous:s}=n.current;if(a.includes(e)){r.current={key:e,action:t,title:i};return}o({key:e,action:t,title:i},s,a)},announcement:i}},vo=({compact:e,limit:t})=>(0,X.jsx)(`div`,{className:e?`flex flex-col gap-2`:`flex flex-col gap-3`,children:Array.from({length:e?Math.min(t,3):2},(t,n)=>(0,X.jsx)(A,{className:e?`h-17.5 w-full max-sm:h-24`:`h-24 w-full`},n))}),yo=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,button:o,limit:s,display:u,empty:d,carousel:f,compact:p,tone:m,planned:h})=>{let g=Ht(),_=hr(),v=t?.names?.plural??ge(e.name),y=r||At(e,t),b=c(e,{filter:n,sort:y,pageSize:s,enabled:!h}),x=xn(e,n,!h),S=h?h.rows:{isPending:b.isPending,error:b.error},C=h?h.rows.rows:b.data?.items,w=h?{data:h.total&&!h.total.isPending&&!h.total.error?cr(h.total):void 0}:x,T=(0,Y.useMemo)(()=>(C??[]).map(t=>rt(e,t)),[e,C]),E=_o((0,Y.useMemo)(()=>T.map(e=>e.key),[T]));return(0,X.jsxs)(`div`,{ref:E.root,children:[(()=>{if(S.isPending)return(0,X.jsx)(vo,{compact:!!p,limit:s});if(S.error)return(0,X.jsx)(l,{title:oo(`couldNotLoad`),error:S.error});if(T.length===0)return(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:d??oo(`nothingYet`)});let r=T.map(e=>{let n=(t,n)=>E.acted(e.key,t,n);return p?(0,X.jsx)(uo,{scope:e,view:t,fields:i,time:p.time,tone:m,actions:a,button:o,onActed:n},e.key):(0,X.jsx)(fo,{scope:e,view:t,fields:i,tone:m,actions:a,button:o,onActed:n},e.key)}),c=w.data===void 0?void 0:Zn(T.length,w.data,!1);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f===void 0?(0,X.jsx)(`ul`,{className:p?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,X.jsx)(Qn,{scroll:_,label:v,share:f,children:r}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c}),(0,X.jsxs)(D,{to:ur(e,t,g,{filter:n,orderBy:y,display:dr(t,g,{preferred:u})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[ar(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:v.toLowerCase()}),(0,X.jsx)(nr,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:E.announcement})]})},bo={"1/4":1/4,"1/3":1/3,"1/2":1/2,"2/3":2/3},xo=({node:e,at:t,slots:n,className:r})=>{let i=G(e),{resource:a,filter:o=``,sort:c=``,fields:l,cardActions:u=[],limit:d=10,display:f,title:p,description:m,empty:h}=i,{layout:g,cardWidth:_}=ii(i),{resources:v,views:y}=q(),[b,x]=st([t,t===void 0?void 0:`${t}#total`]),S=(0,Y.useMemo)(()=>b&&{rows:b,total:x},[b,x]),C=v[a];if(!C)return null;let w=y[C.name];return(0,X.jsx)(`section`,{className:U(`min-w-0`,r),"aria-label":p,children:(0,X.jsx)(T,{title:p,help:m,actions:n.actions,children:(0,X.jsx)(yo,{model:C,view:w,filter:o,sort:c,fields:l??s(C,w),actions:u,limit:d,display:f,empty:h,carousel:g===`carousel`?bo[_]:void 0,...S&&{planned:S}})})})},So=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=q(),o=Ve(i,a,e.name),s=Vn(e.name,t.listOf,!0),c=(t.names?.plural??ge(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,X.jsx)(l,{title:Ln(`couldNotLoadYour`,{plural:c}),error:s.error});if(!s.data)return(0,X.jsx)(A,{className:`h-24`});let u=rr(o.model,s.data);return u?(0,X.jsx)(_r,{...r,model:o.model,view:o.view,filter:``,scope:u,list:e.name,empty:n}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??Ln(`noneYet`,{plural:c})})},Co=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=ce(h(e,i)),{name:o,chips:s,title:c,body:l}=yr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,X.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,X.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,X.jsx)(D,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,X.jsx)(Kn,{chips:s})})}),(0,X.jsx)(_r,{...l})]})},wo=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=q(),a=t.searchesOf,o=r[a.resource],s=Xn(e.name,!0),c=(t.names?.plural??ge(e.name)).toLowerCase();return o?s.error?(0,X.jsx)(l,{title:qn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??qn(`noneYet`,{plural:c})}):(0,X.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,X.jsx)(Co,{model:e,view:t,target:o,targetView:i[a.resource],row:n},ce(h(e,n))))}):(0,X.jsx)(A,{className:`h-40`}):null},To=({node:e,slots:t,className:n})=>{let{resource:r,filter:i=``,sort:a,limit:o,display:s,title:c,description:l,empty:u}=G(e),{resources:d,views:f}=q(),p=d[r];if(!p)return null;let m=f[p.name];return(0,X.jsx)(J,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,X.jsx)(wo,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,X.jsx)(_r,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,X.jsx)(So,{model:p,view:m,limit:o,display:s,empty:u})})},Eo=e=>e.type===`boolean`||e.type===`enum`,Do=({model:e,fields:t,title:n,description:r,stored:i,className:a})=>{let{resources:o,views:s}=q(),c=kn(e.name),u=Ne(),d=ne(),f=vn(),p=s[e.name],[m,h]=(0,Y.useState)(i),[g,_]=(0,Y.useState)(()=>Xa(e,t,i?.record)),[v,y]=(0,Y.useState)({}),[b,x]=(0,Y.useState)(),[S,C]=(0,Y.useState)(!1),w=(0,Y.useRef)(Promise.resolve()),T=(0,Y.useRef)(i),E=Xa(e,t,void 0),ee=m?Te(c,`update`)&&m.permissions?.update!==!1:Te(c,`create`),te=t.filter(t=>!Eo(e.fields[t])),re=te.some(t=>m?_n(e.fields[t],g[t],m.record[t]):g[t]!==E[t]),ie=async t=>{let n=T.current;if(n){let r=await u.update(e.name,n.key,Za(e,t,n.record),n.etag??`*`);return{...rt(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await u.create(e.name,Ye(e,o,{...E,...t}));return{...rt(e,r.record),etag:r.etag}},D=t=>{let r=w.current.then(async()=>{C(!0),x(void 0),await ie(t).then(async r=>{T.current=r,h(r),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await f(e.name),d.show({state:`success`,title:V(`saved`,{label:n??V(`settings`)})})},e=>{y(t=>({...t,...wn(e)})),x(e)}),C(!1)});w.current=r},ae=(t,n)=>{_(e=>({...e,[t]:n})),Eo(e.fields[t])&&D({[t]:n})};return(0,X.jsx)(J,{title:n,description:r,className:U(`h-full`,a),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),re&&D(Object.fromEntries(te.map(e=>[e,g[e]])))},children:[b!==void 0&&Object.keys(v).length===0&&(0,X.jsx)(l,{title:V(`notSaved`),error:b}),t.map(t=>{let n=e.fields[t],r=p?.fields[t]?.label??ge(t),i=v[t];return(0,X.jsx)(An,{name:t,label:r,help:p?.fields[t]?.help,error:i&&tt(n,r,i),children:(0,X.jsx)(bn,{field:n,hints:p?.fields[t],value:g[t],stored:m?.record[t]??E[t],invalid:!!i,locked:!ee||n.readOnly,resource:e.name,onChange:e=>ae(t,e)})},t)}),ee&&re&&(0,X.jsx)(`div`,{children:(0,X.jsx)(M,{type:`submit`,variant:`primary`,size:`sm`,loading:S,children:V(`save`)})})]})})},Oo=e=>{let t=Oe(e.model,{});return t.isPending?(0,X.jsx)(J,{title:e.title,description:e.description,className:e.className,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(A,{className:`h-4 w-1/2`}),(0,X.jsx)(A,{className:`h-4 w-1/3`})]})}):t.error?(0,X.jsx)(J,{title:e.title,description:e.description,className:e.className,children:(0,X.jsx)(l,{title:V(`couldNotLoad`),error:t.error})}):(0,X.jsx)(Do,{...e,stored:t.data??void 0})},ko=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=G(e),o=q().resources[n];return o?(0,X.jsx)(Oo,{...a,model:o,fields:r.filter(e=>Object.hasOwn(o.fields,e)),stored:void 0,className:t}):null},Ao=(e,t)=>jo(e,t?[t]:[]),jo=(e,t)=>{let{resources:n}=q(),i=Ne(),a=JSON.stringify(e),o=(0,Y.useMemo)(()=>JSON.parse(a).map(ft),[a]),s=e=>t.some(t=>`item`in t?typeof t.item==`object`&&t.item!==null&&Object.hasOwn(t.item,e):Object.hasOwn(t.model.fields,e)),c=[...new Set(o.flatMap(e=>e.ok?e.paths:[]))],l=new Map(c.flatMap(e=>{let t=we(e,s);return t===void 0?[]:[[e,t]]})),u=c.filter(e=>!l.has(e)),d=[...new Set(l.values())].flatMap(e=>n[e]?[n[e]]:[]),f=u.map(e=>Jt(t,e)),p=Rt(u.map((e,t)=>{let n=f[t];return n&&`frame`in n?{scope:n.frame,path:n.path}:{scope:void 0,path:e}})),m=In({queries:d.map(e=>yt(i,e))});return o.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=l.get(n);if(e===void 0){let e=u.indexOf(n),r=f[e];if(r&&`item`in r){t[n]=r.item;continue}let i=p[e];if(i.state===`loading`)return;i.state===`ready`&&(t[n]=i.value);continue}let r=d.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(m[r].isPending)return;else t[n]=m[r].data??0}return r(e,t)})},Mo=(e,t)=>typeof e.props.fallback==`string`?e.props.fallback:t.fallback,No=({node:e,children:t,slots:n,className:r})=>{let{when:i}=G(e),[a]=jo([i],R());if(a===void 0)return null;let o=a?t:Mo(e,n);return o==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:o}):(0,X.jsx)(`div`,{className:r,children:o})},Po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(w(e,F(t)).props.when)]),Fo=({node:e,children:t,slots:n,className:r})=>{let i=R(),a=jo(Po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?Mo(e,n):t[o];return s==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:s}):(0,X.jsx)(`div`,{className:r,children:s})},Io=({children:e})=>(0,X.jsx)(X.Fragment,{children:e}),Lo=`text-2xl font-semibold tracking-tight tabular-nums`,Ro=({model:e,at:t,filter:n})=>{let{views:r}=q(),i=nn(t),a=xn(e,n,!i),o=i??a;if(o.isPending)return(0,X.jsx)(A,{className:`h-8 w-16`});if(o.error)return(0,X.jsx)(`span`,{className:`text-danger-text`,children:V(`couldNotCount`)});let s=i?cr(i):a.data;return(0,X.jsx)(D,{to:or(r[e.name],e.name,n),className:`${Lo} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:s.toLocaleString(Tn())})},zo=({field:e,format:t})=>{let n=Tt(e);return n.state===`loading`?(0,X.jsx)(A,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,X.jsx)(`span`,{className:Lo,children:wa(n.value)}):(0,X.jsx)(`span`,{className:Lo,children:(0,X.jsx)(Me,{model:n.model,field:n.field,value:n.value,format:t})})},Bo=({node:e,at:t,className:n})=>{let{label:r,value:i,resource:a,filter:o,field:s,format:c,description:l}=G(e),{resources:u}=q(),d=a===void 0?void 0:u[a];return(0,X.jsxs)(J,{className:U(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,X.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,X.jsx)(`span`,{className:Lo,children:i}),d&&(0,X.jsx)(Ro,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,X.jsx)(zo,{field:s,format:c})]}),l&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},Vo=(e,t,n)=>{let r=Ht(),i=tr(t),[a,o]=(0,Y.useState)(()=>Yn(localStorage,i)),s=(0,Y.useCallback)(e=>{o(e),fr(localStorage,i,e)},[i]);return[dr(e,r,{picked:a,preferred:n}),s]},Ho=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:c,className:l})=>{let{resources:u,views:d}=q(),f=d[e.name],{fields:p}=y(),m=Te(kn(e.name),`update`),{go:h,href:g}=Xt(),_=Ht(),v=!cn(),b=(0,Y.useMemo)(()=>n?.map(Zt)??s(e,f),[n,e,f]),x=(0,Y.useMemo)(()=>mt(e,f,b,{resources:u,views:d,fieldTypes:p}),[e,f,b,u,d,p]),S=(0,Y.useMemo)(()=>_?It(n)(x):x,[_,n,x]),C=(0,Y.useMemo)(()=>r?ir(S,e,f,r,u,v):S,[S,e,f,r,u,v]),w=(0,Y.useMemo)(()=>t.map(t=>({...t,id:ye(e,t)})),[t,e]),T=(0,Y.useMemo)(()=>({total:w.length,rowAt:e=>w[e]}),[w]),E=lr({model:e,view:f,opens:void 0,resources:u,views:d,canUpdate:m}),ee=e=>({href:g(e),onFollow:()=>h(e)});return(0,X.jsx)(J,{title:i,description:a,actions:c,className:l,children:w.length===0?(0,X.jsx)(j,{children:o??V(`nothingYet`)}):(0,X.jsx)(Un,{fit:!0,columns:C,source:T,latencyMs:0,onOpenRow:e=>h(E.address(e)),rowLink:e=>ee(E.address(e)),rowActions:E.actions(ee),rowNumbers:!1,selectable:!1})})},Uo=e=>{let t=it();return t?.model?(0,X.jsx)(Ho,{...e,model:t.model,items:t.items}):null},Wo=({model:e,view:t,filter:n=``,sort:r=``,columns:i,button:a,bulk:o,limit:s=10,display:c,title:l,description:u,empty:d,actions:f,className:p,chosen:m,planned:h})=>{let[g,_]=Vo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?Ue:g,y=(0,Y.useMemo)(()=>i?.map(Zt),[i]),b=(0,Y.useMemo)(()=>It(i),[i]);return(0,X.jsxs)(J,{title:l,description:u,actions:(0,X.jsxs)(X.Fragment,{children:[!m&&(0,X.jsx)(pr,{view:t,value:v,onChange:_}),f]}),className:U(`h-full`,p),children:[(0,X.jsx)(sr,{model:e,view:t,filter:n,sort:r,columns:y,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:b,...m&&{rowTo:m.rowTo,chosenKey:m.key},...h&&{planned:h}}),m?.details]})},Go=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,children:c,...l}=G(e),{resources:u,views:d}=q(),[f,p]=st([t,t===void 0?void 0:`${t}#total`]),m=(0,Y.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,X.jsx)(Uo,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,X.jsx)(Wo,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,X.jsx)(Ko,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},Ko=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=lt(),a=t=>i({[e]:t}),o=r[e],s=o===void 0?null:(0,X.jsx)(pn,{name:e,children:(0,X.jsx)(_i,{model:n.model,query:{key:o},children:t},o)});return(0,X.jsx)(Wo,{...n,chosen:{rowTo:a,key:o,details:s}})},qo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=a(),{navigate:o}=qe(),s=Mt(e),c=he(s,r),l=e=>i(e===s[0]?.name?void 0:e);return(0,X.jsxs)(`div`,{className:U(`flex flex-col gap-6`,n),children:[(0,X.jsxs)(`select`,{"aria-label":V(`tabs`),value:c?.name??``,onChange:e=>o(l(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!c&&(0,X.jsx)(`option`,{value:``,disabled:!0}),s.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,X.jsx)(`nav`,{"aria-label":V(`tabs`),className:`hidden border-b md:block`,children:(0,X.jsx)(`ul`,{className:`flex gap-1`,children:s.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Ct,{to:l(e.name),"aria-current":e===c?`page`:void 0,className:U(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===c?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),c?(0,X.jsx)(Y.Fragment,{children:t[s.indexOf(c)]},c.name):(0,X.jsx)(rn,{children:V(`noTab`,{name:r??``})})]})},Jo=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Yo=e=>e===void 0?1/0:Date.parse(e),Xo=(e,t)=>{let n=e=>e.more&&e.items.length>0?Yo(e.items.at(-1).time):-1/0,r=Math.max(n(e),n(t)),i=[],a=0,o=0;for(;a<e.items.length||o<t.items.length;){let n=o>=t.items.length||a<e.items.length&&Yo(e.items[a].time)>=Yo(t.items[o].time)?e.items[a++]:t.items[o++];if(Yo(n.time)<r)break;i.push(n)}return i},Zo=({value:e,hints:t,mark:n})=>{let r=d(e,t?.valueLabels);return n===`done`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(sn,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(u,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&Pt(t?.valueColors,e)!==`red`?r:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,X.jsx)(br,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},Qo=({value:e})=>{let t=typeof e==`string`?Pe(e):e;return t===Re?(0,X.jsx)(ie,{children:String(e)}):(0,X.jsx)(x,{value:t})},$o=({label:e,children:t})=>(0,X.jsxs)(`div`,{className:`grid gap-1`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),es=({call:e,statusHints:t})=>{let[n,r]=(0,Y.useState)(!1),i=(0,Y.useId)(),a=e.status!==void 0&&(0,X.jsx)(Zo,{value:e.status,hints:t,mark:e.state}),o=(0,X.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:e.name}),s=e.input!==void 0||e.result!==void 0||e.error!==void 0;return(0,X.jsxs)(`div`,{"data-tool-call":!0,className:`flex min-w-0 flex-col gap-1 pl-11 text-xs text-muted-foreground`,children:[s?(0,X.jsxs)(M,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,X.jsx)(Se,{"aria-hidden":!0,className:U(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,X.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,X.jsx)($o,{label:Q(`callInput`),children:(0,X.jsx)(Qo,{value:e.input})}),e.result!==void 0&&(0,X.jsx)($o,{label:Q(`callResult`),children:(0,X.jsx)(Qo,{value:e.result})}),e.error!==void 0&&(0,X.jsx)($o,{label:Q(`callError`),children:(0,X.jsx)(ie,{children:e.error})})]})]})},ts=(e,t)=>e.map(e=>({kind:`message`,row:e,time:typeof e[t]==`string`?e[t]:void 0})),ns=e=>{if(typeof e==`object`&&e&&`id`in e){let{id:t,name:n}=e;return{id:String(t),...typeof n==`string`&&{name:n}}}return{id:String(e??``),...typeof e==`string`&&{name:e}}},rs=(e,{key:t,sender:n,text:r,status:i},a=Date.now())=>{let o=[],s;for(let c of[...e].reverse()){let e=c.time,l=s?.time!==void 0&&e!==void 0&&te(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:v(e,a)}),c.kind===`call`){o.push(c),s={author:void 0,time:e};continue}let{row:u}=c,d=n===void 0?void 0:ns(u[n]),f=d?.id??``,p=i===void 0||u[i]==null||u[i]===``?void 0:String(u[i]);o.push({kind:`message`,key:t(u),...d&&{author:d},time:e,text:u[r]==null?``:String(u[r]),...p!==void 0&&{status:p},continued:l&&s?.author===f}),s={author:f,time:e}}return o},is=e=>qr.includes(e??``)?e:void 0,as=e=>e==null||e===``?void 0:String(e),os=e=>`call:${JSON.stringify(e)}`,ss=(e,t,n)=>{let r=as(e[n.status]),i=is(r),a=n.input===void 0?void 0:e[n.input],o=n.result===void 0?void 0:e[n.result],s=n.error===void 0?void 0:as(e[n.error]);return{kind:`call`,key:t,name:String(e[n.name]??``),time:typeof e[n.time]==`string`?e[n.time]:void 0,...r!==void 0&&{status:r},...i!==void 0&&{state:i},...a!=null&&{input:a},...o!=null&&{result:o},...s!==void 0&&{error:s}}},cs=({planned:e,limit:t,expanded:n,expand:r,own:i})=>{if(!e)return i;let a=n&&!i.error&&i.pages<2&&(i.pages===0||i.hasNextPage),o={items:e.rows,labels:e.labels??{},hasNextPage:e.rows.length>=t,isFetchingNextPage:a,isFetchNextPageError:!1,isLoading:e.isPending};return n&&i.error&&i.pages===0?{...o,error:i.error,fetchNextPage:i.refetch,refetch:i.refetch}:n&&!a?i:{...o,error:e.error,fetchNextPage:r,refetch:r}},ls=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,Y.useState)(!1),s=Fe(e,{...r,pageSize:t,enabled:n&&(!i||a)}),c=s.data?.pages.length??0,{hasNextPage:l,isFetchingNextPage:u,fetchNextPage:d,error:f}=s;return(0,Y.useEffect)(()=>{i&&a&&!f&&c===1&&l&&!u&&d()},[i,a,f,c,l,u,d]),cs({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},us=(e,t,n)=>{let{views:r}=q(),i=e?.model.name??``,a=ls(i,{filter:e?.filter,orderBy:e&&Ot(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>ss(t,os(h(e.model,t)),e.fields)),hasNextPage:a.hasNextPage,isFetchingNextPage:a.isFetchingNextPage,list:a,statusHints:r[i]?.fields[e.fields.status]}:{calls:[],hasNextPage:!1,isFetchingNextPage:!1,list:a,statusHints:void 0}},ds=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,fs=(e,t)=>e.isLoading?t.loading:t.empty,ps=e=>e.items.length>0&&!!e.error,ms=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),hs=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},gs=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:u,planned:d})=>{let{resources:f,views:p}=q(),m=ee(),g=m?.state.kind===`signed-in`?m.state.user.id:void 0,_=n===void 0?[]:[n],v=$t(f,p,e,_),y=ls(e.name,{filter:t,orderBy:Ot(r),pageSize:o,labels:v},d?.messages),b=us(u,o,d?.calls),x=ds(y);if(x===`error`)return(0,X.jsx)(l,{title:Q(`couldNotLoad`),error:y.error,onRetry:ms(y)});if(x===`loading`)return(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(j,{children:Q(`loadingMessages`)})});let S=kt(f,e,_,y.items,y.labels),C=Xo({items:b.calls,more:b.hasNextPage},{items:ts(S,r),more:y.hasNextPage}),w=rs(C,{key:t=>String(h(e,t)),sender:n,time:r,text:i,status:a}),T=a===void 0?void 0:p[e.name]?.fields[a],E=e.fields[i]!==void 0&&jt(e.fields[i],p[e.name]?.fields[i]),te=w.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===g);return(0,X.jsxs)(X.Fragment,{children:[ps(y)&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(l,{title:Q(`couldNotLoad`),error:y.error,onRetry:ms(y)})}),u&&b.list.error&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(l,{title:Q(`couldNotLoadCalls`),error:b.list.error,onRetry:ms(b.list)})}),(0,X.jsx)(ue,{length:C.length,followKey:te?.key,working:c,empty:fs(b.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:y.hasNextPage||b.hasNextPage?()=>hs([y,b.list]):void 0,loadingEarlier:y.isFetchingNextPage||b.isFetchingNextPage,children:w.map(e=>e.kind===`day`?(0,X.jsx)(xe,{label:e.label},e.key):e.kind===`call`?(0,X.jsx)(es,{call:e,statusHints:b.statusHints},e.key):(0,X.jsx)(pe,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,X.jsx)(Zo,{value:e.status,hints:T}),children:E&&e.text!==``?(0,X.jsx)(le,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},_s=({children:e})=>(0,X.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),vs=({node:e,at:t,slots:n,className:r})=>{let{title:i,description:a,resource:o,filter:s,sender:c,time:l,text:u,status:d,working:f,calls:p,limit:m,empty:h}=G(e),{resources:g}=q(),[_]=jo(f===void 0?[]:[f],R()),[v,y]=st([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let x=p&&g[p.resource];return(0,X.jsx)(`section`,{className:U(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,X.jsx)(T,{title:i,help:a,actions:n.actions,children:(0,X.jsx)(_s,{children:(0,X.jsx)(gs,{model:b,filter:s,sender:c,time:l,text:u,status:d,calls:p&&x&&{model:x,filter:p.filter,fields:p},limit:m,empty:h,working:f===void 0?void 0:_===!0,...(v||y)&&{planned:{messages:v,calls:y}}})})})})},ys=({children:e,className:t})=>(0,X.jsx)(`div`,{className:t,children:e}),bs=({children:e,className:t})=>(0,X.jsx)(`div`,{className:U(`flex`,t),children:e}),xs=({children:e,className:t})=>(0,X.jsx)(`div`,{className:U(`flex flex-col`,t),children:e}),Ss=({node:e,children:t,className:n})=>{let{as:r=`p`}=G(e);return(0,X.jsx)(r,{className:n,children:t})},Cs=({node:e,children:t})=>{let{source:n}=G(e),r=ze(F(R()),n),i=(0,Y.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,X.jsx)(gn,{value:i,children:t})},ws=({node:e,className:t})=>{let{source:n,choices:r,label:i=n,defaultValue:a}=G(e),{values:o,linkTo:s}=lt(),c=o[n];return(0,X.jsxs)(`div`,{className:U(`flex flex-wrap items-center gap-2`,t),children:[(0,X.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:i}),r?(0,X.jsx)(Le,{label:i,value:c??``,options:r.map(e=>({value:String(e.id),label:e.name})),link:e=>s({[n]:a!==void 0&&e===String(a)?void 0:e})}):(0,X.jsx)(`span`,{children:c})]})},Ts=({model:e,filter:t,perPage:n,more:r,planned:i,expanded:a,expand:o,own:s})=>{if(t===void 0)return{read:{isPending:!1,error:null},list:{model:e,items:[]}};if(i&&!a){let t=i.rows.slice(0,n),a=r&&t.length===n?o:void 0;return{read:i,list:{model:e,items:t,planned:!0,...a&&{loadMore:a}}}}if(i&&!s.error&&s.pages<2&&(s.pages===0||s.hasNextPage))return{read:i,list:{model:e,items:i.rows.slice(0,n),planned:!0,loadMore:()=>{},loadingMore:!0}};let c=r&&s.hasNextPage?()=>void s.fetchNextPage():void 0;return{read:{isPending:s.isPending,error:s.error},list:{model:e,items:s.items,...c&&{loadMore:c,loadingMore:s.isFetchingNextPage}}}},Es=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,Y.useState)(!1),c=Fe(e.name,{filter:t,orderBy:n,pageSize:r,enabled:t!==void 0&&(!a||o)}),l=c.data?.pages.length??0,{hasNextPage:u,isFetchingNextPage:d,fetchNextPage:f,error:p}=c;return(0,Y.useEffect)(()=>{a&&o&&!p&&l===1&&u&&!d&&f()},[a,o,p,l,u,d,f]),Ts({model:e,filter:t,perPage:r,more:i,planned:a,expanded:o,expand:()=>s(!0),own:{pages:l,items:c.items,hasNextPage:u,isFetchingNextPage:d,isPending:c.isPending,error:p,fetchNextPage:f}})},Ds=({node:e,at:t,children:n})=>{let r=G(e),i=q().resources[r.reference],a=Ie(F(R())),o=nn(t);return i?(0,X.jsx)(Os,{model:i,...We(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},Os=({empty:e,children:t,...n})=>{let{read:r,list:i}=Es(n);return(0,X.jsx)(On,{read:r,list:i,empty:e,children:t})},ks=({node:e,at:t,children:n})=>{let r=G(e),i=q().resources[r.reference],a=Ie(F(R())),o=nn(t);return i?(0,X.jsx)(Os,{model:i,...re(r,i.primaryKey[0],a),more:!1,empty:r.empty,...o&&{planned:o},children:n}):null},As=({model:e,at:t,recordKey:n,link:r=`edit`,children:i,className:a})=>{let{views:o}=q(),s=nn(t),c=Oe(e,{key:n,enabled:!s}),u=s?En(e,s):c;if(u.isPending)return(0,X.jsx)(A,{className:`h-4 w-24`});if(u.error)return(0,X.jsx)(l,{title:V(`couldNotLoad`),error:u.error});if(!u.data)return null;let d=i.length>0?(0,X.jsx)(dt,{value:u.data,children:i}):je(e,o[e.name],u.data.record,n);return r===!1?(0,X.jsx)(`span`,{className:a,children:d}):(0,X.jsx)(D,{to:{kind:`record`,resource:e.name,key:n},className:a??`font-medium text-primary-text hover:underline`,children:d})},js=({node:e,at:t,children:n,className:r})=>{let{reference:i,source:a,link:o,empty:s}=G(e),c=q().resources[i],l=ze(F(R()),a);return c?l==null||l===``?s===void 0?null:(0,X.jsx)(`span`,{className:r,children:s}):(0,X.jsx)(As,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},Ms=(e,t)=>t.map(t=>Et(e,t)).join(`, `),$=vt(`users`),Ns=({roles:e})=>{let{session:t}=_(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)([]),o=(0,Y.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,Y.useEffect)(o,[o]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Sr,{title:$(`inviteSomeone`),description:$(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,X.jsx)(wr,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,X.jsx)(K,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,X.jsx)(Cr,{email:n.email,gives:Ms(e,n.roles),expiresAt:n.expiresAt,onResend:async()=>{let e=await t.users.invite({email:n.email,roles:n.roles});return o(),e},onRevoke:async()=>{await t.users.revoke(n.id),o()}},n.id))})})]})},Ps=({roles:e,onCreated:t})=>{let{session:n}=_(),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)([]),{busy:d,error:f,run:p}=ct(),m=()=>p(async()=>{await n.users.create({email:r.trim(),name:a.trim(),roles:l,...s&&{password:s}}),i(``),o(``),c(``),u([]),t()}),h=!r.trim()||!a.trim()||l.length===0||s!==``&&s.length<12;return(0,X.jsxs)(K,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,X.jsx)(L,{message:f}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,X.jsx)(N,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,X.jsx)(N,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,X.jsx)(N,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(wr,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,X.jsx)(`div`,{children:(0,X.jsx)(M,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},Fs=({user:e,roles:t,self:n})=>{let{session:r}=_(),[i,a]=(0,Y.useState)(e),{busy:o,error:s,run:c,setError:l}=ct(),u=e=>{if(e.length===0)return l($(`keepOneRole`));c(async()=>{await r.users.setRoles(i.id,e),a({...i,roles:e})})},d=e=>void c(async()=>{await(e?r.users.block(i.id):r.users.unblock(i.id)),a({...i,blocked:e})});return(0,X.jsx)(Tr,{name:i.name,email:i.email,self:n,error:s,actions:(0,X.jsxs)(X.Fragment,{children:[i.blocked&&(0,X.jsx)(H,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,X.jsx)(M,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,X.jsx)(M,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,X.jsx)(wr,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},Is=({roles:e,version:t})=>{let{session:n,state:r}=_(),[i,a]=(0,Y.useState)(``),o=(0,Y.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=Dr(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,X.jsx)(Er,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,X.jsx)(Fs,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},Ls=()=>{let{session:e}=_(),[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)();return(0,Y.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof k?z(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},Rs=()=>{let{roles:e,error:t}=Ls(),[n,r]=(0,Y.useState)(0);return(0,X.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,X.jsx)(L,{message:t}),(0,X.jsx)(Is,{roles:e,version:n}),(0,X.jsx)(Ns,{roles:e}),(0,X.jsx)(Ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},zs=({sender:e,busy:t,error:n,onSave:r,onClose:i})=>{let[a,s]=(0,Y.useState)(e?.address??``),[c,l]=(0,Y.useState)(e?.name??``),[u,d]=(0,Y.useState)(e?.signature??``),[f,p]=(0,Y.useState)(e?.isDefault??!1);return(0,X.jsxs)(o,{title:e?e.address:O(`addFromAddress`),description:O(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:i,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:i,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:t,disabled:!a.trim(),onClick:()=>r({address:a.trim(),name:c.trim(),signature:u,isDefault:f}),children:O(e?`save`:`addAddress`)})]}),children:[!e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`fromAddress`),(0,X.jsx)(N,{autoFocus:!0,type:`email`,value:a,maxLength:254,placeholder:O(`fromAddressPlaceholder`),onChange:e=>s(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[O(`fromName`),(0,X.jsx)(N,{value:c,maxLength:100,placeholder:O(`fromNamePlaceholder`),onChange:e=>l(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{children:O(`defaultFromAddress`)}),(0,X.jsx)(de,{checked:f,onChange:p,label:O(`defaultFromAddress`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[O(`signature`),(0,X.jsx)(Yt,{value:u,maxLength:2e3,placeholder:O(`signaturePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,X.jsx)(L,{message:n})]})},Bs=e=>e.signature?O(`ownSignature`):O(`genericSignature`),Vs=({senders:{address:e,senders:t},onAdd:n,onUpdate:r,onRemove:i})=>{let[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=(0,Y.useRef)(!1),p=t.find(e=>e.isDefault),m=()=>{d(void 0),l(void 0)},h=async e=>{if(!f.current){f.current=!0,s(!0),l(void 0);try{await e(),d(void 0)}catch(e){if(e instanceof TypeError)return l(O(`noAnswerFromServer`));if(!(e instanceof k))throw e;l(z(e))}finally{f.current=!1,s(!1)}}},g=e=>h(async()=>{let t=e.name||null,i=e.signature.trim()?e.signature:null;if(u?.kind===`change`)return r(u.sender.id,{name:t,signature:i,isDefault:e.isDefault});let a=await n({address:e.address,...t&&{name:t},...i&&{signature:i}});e.isDefault&&await r(a.id,{isDefault:!0})});return(0,X.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,X.jsx)(`h3`,{className:`font-semibold`,children:O(`fromAddresses`)}),(0,X.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:O(`fromAddressesDescription`)}),(0,X.jsx)(L,{message:u?void 0:c}),(e||t.length>0)&&(0,X.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:O(`mailboxOwnAddress`)})]}),p?(0,X.jsx)(M,{size:`sm`,variant:`ghost`,loading:a,onClick:()=>void h(()=>r(p.id,{isDefault:!1})),children:O(`makeDefault`)}):(0,X.jsx)(H,{tone:`blue`,children:O(`default`)})]}),t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,X.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Bs(e)})]}),e.isDefault&&(0,X.jsx)(H,{tone:`blue`,children:O(`default`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>d({kind:`change`,sender:e}),children:O(`edit`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>d({kind:`remove`,sender:e}),children:O(`remove`)})]},e.id))]}),(0,X.jsxs)(M,{onClick:()=>d({kind:`add`}),children:[(0,X.jsx)(oe,{className:`size-3.5`}),O(`addFromAddress`)]}),u?.kind===`add`&&(0,X.jsx)(zs,{busy:a,error:c,onSave:e=>void g(e),onClose:m}),u?.kind===`change`&&(0,X.jsx)(zs,{sender:u.sender,busy:a,error:c,onSave:e=>void g(e),onClose:m},u.sender.id),u?.kind===`remove`&&(0,X.jsx)(o,{title:O(`removeFromAddress`,{address:u.sender.address}),description:O(`removeFromAddressDescription`),onClose:m,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:m,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:a,onClick:()=>void h(()=>i(u.sender.id)),children:O(`remove`)})]}),children:(0,X.jsx)(L,{message:c})})]})},Hs=(e,t,n)=>Object.fromEntries(Hn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,f(`signInOnly`,{provider:n(e.provider),name:e.name})])),Us=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=_(),{account:i}=t,[a]=(0,Y.useState)(Gt),o=(0,Y.useCallback)(async()=>{let[t,n,r]=await Promise.all([i.linkedPersonalMail(e),i.linkedProviders(),i.mailSenders()]);return{mail:t,providers:n,senders:r}},[i,e]),{data:s,error:c,reload:l}=W(o,O(`couldNotReadMethods`));return s?(0,X.jsx)(Lt,{title:O(`mailbox`),description:O(`mailboxDescription`),providers:e.map(({id:e,name:t})=>({id:e,name:t})),linked:s.mail,notes:Hs(e,s,e=>r.find(t=>t.id===e)?.name??se(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&bt(a,e.length===1?e[0].name:O(`theProvider`)),children:(0,X.jsx)(Vs,{senders:s.senders,onAdd:async e=>{let t=await i.addMailSender(e);return m(),await l(),t},onUpdate:async(e,t)=>{await i.updateMailSender(e,t),m(),await l()},onRemove:async e=>{await i.removeMailSender(e),m(),await l()}})}):(0,X.jsx)(I,{error:c})},Ws=()=>{let{personalMail:e}=_();return e.length>0?(0,X.jsx)(Us,{links:e}):null},Gs=e=>Or(e.name)??`An unnamed app`,Ks=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),qs=({apps:e,onDisconnect:t})=>{let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(),[s,c]=(0,Y.useState)(),l=async e=>{r(!0),a(void 0);try{await t(e.clientId),c(void 0)}catch(e){if(!(e instanceof k))throw e;a(z(e))}r(!1)};return(0,X.jsxs)(K,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,X.jsx)(L,{message:s?void 0:i}),e.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`No apps are connected. Add this app's MCP address to an AI assistant to connect one.`}):(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=kr(e.clientId);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Pr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:Gs(e)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,ot(Date.parse(e.allowedAt)),` · `,Ks(e)]})]}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>c(e),children:`Disconnect`})]},e.clientId)})}),s&&(0,X.jsx)(o,{title:`Disconnect ${Gs(s)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>c(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>c(void 0),children:`Cancel`}),(0,X.jsx)(M,{variant:`danger`,loading:n,onClick:()=>void l(s),children:`Disconnect`})]}),children:i&&(0,X.jsx)(L,{message:i})})]})},Js=(e,t)=>{let n=new URL(`https://claude.ai/customize/connectors`);return n.searchParams.set(`modal`,`add-custom-connector`),t&&n.searchParams.set(`connectorName`,t),n.searchParams.set(`connectorUrl`,e),n.href},Ys=({url:e,appName:t})=>(0,X.jsx)(K,{title:O(`mcpAddress`),description:O(`mcpAddressDescription`),children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Ar,{value:e,copyLabel:O(`copyMcpAddress`)}),(0,X.jsxs)(`a`,{href:Js(e,t),target:`_blank`,rel:`noreferrer`,className:p(),children:[(0,X.jsx)(b,{className:`size-3.5`}),O(`addToClaude`)]})]})}),Xs=()=>{let{account:e}=_().session,{data:t,error:n,reload:r}=W((0,Y.useCallback)(()=>e.connectedApps(),[e]),O(`couldNotReadMethods`));return t?(0,X.jsx)(qs,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,X.jsx)(I,{error:n})},Zs=({url:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ys,{url:e,appName:q().appName}),(0,X.jsx)(Xs,{})]}),Qs=()=>{let{mcp:e}=_();return e?(0,X.jsx)(Zs,{url:e.url}):null},$s={30:30,90:90,365:365,never:void 0},ec={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},tc=e=>ot(Date.parse(e)),nc=e=>e?O(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:tc(e)}):O(`neverExpires`),rc=e=>[O(`createdOn`,{date:tc(e.createdAt)}),nc(e.expiresAt),e.lastUsedAt?O(`lastUsedOn`,{date:tc(e.lastUsedAt)}):O(`notUsedYet`),e.organization?O(`actsAsIn`,{role:e.role,organization:e.organization}):O(`actsAs`,{role:e.role})].join(` · `),ic=({tokens:e,onCreate:t,onRevoke:n})=>{let[r,i]=(0,Y.useState)(!1),[a,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(`90`),[m,h]=(0,Y.useState)(),g=()=>{l(void 0),s(void 0),h(void 0)},_=(0,Y.useRef)(!1),v=async e=>{if(!_.current){_.current=!0,i(!0),s(void 0);try{l(await e()),h(void 0)}catch(e){if(e instanceof TypeError)return s(O(`noAnswerFromServer`));if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):s(z(e))}finally{_.current=!1,i(!1)}}},y=()=>v(async()=>{let e=$s[f];return{kind:`created`,created:await t({name:u.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,X.jsxs)(K,{title:O(`accessTokens`),description:O(`accessTokensDescription`),children:[(0,X.jsx)(L,{message:c?void 0:a}),e.length===0?(0,X.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:O(`noAccessTokens`)}):(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Ir,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:rc(e)})]}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>l({kind:`revoke`,token:e}),children:O(`revoke`)})]},e.id))}),(0,X.jsxs)(M,{onClick:()=>{d(``),p(`90`),l({kind:`create`})},children:[(0,X.jsx)(oe,{className:`size-3.5`}),O(`newAccessToken`)]}),c?.kind===`create`&&(0,X.jsxs)(o,{title:O(`newAccessToken`),description:O(`newAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:g,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:r,disabled:!u.trim(),onClick:()=>void y(),children:O(`createAccessToken`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`name`),(0,X.jsx)(N,{autoFocus:!0,value:u,maxLength:100,placeholder:O(`accessTokenNamePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[O(`accessTokenExpiry`),(0,X.jsx)(_e,{value:f,onChange:e=>p(e.target.value),children:Object.keys($s).map(e=>(0,X.jsx)(`option`,{value:e,children:O(ec[e])},e))})]}),m===`asked`&&(0,X.jsx)(Sn,{purpose:`change`,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:O(`confirmedCreateAccessToken`)}),(0,X.jsx)(L,{message:a})]}),c?.kind===`created`&&(0,X.jsx)(o,{title:O(`accessTokenCreated`,{name:c.created.personalAccessToken.name}),description:O(`accessTokenCreatedDescription`),onClose:g,actions:(0,X.jsx)(M,{variant:`primary`,onClick:g,children:O(`done`)}),children:(0,X.jsx)(Ar,{value:c.created.token,copyLabel:O(`copyAccessToken`)})}),c?.kind===`revoke`&&(0,X.jsx)(o,{title:O(`revokeAccessToken`,{name:c.token.name}),description:O(`revokeAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:g,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:r,onClick:()=>void v(async()=>(await n(c.token.id),void 0)),children:O(`revoke`)})]}),children:(0,X.jsx)(L,{message:a})})]})},ac=()=>{let{account:e}=_().session,{data:t,error:n,reload:r}=W((0,Y.useCallback)(()=>e.personalAccessTokens(),[e]),O(`couldNotReadAccessTokens`));return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{message:n}),(0,X.jsx)(ic,{tokens:t,onCreate:t=>e.createPersonalAccessToken(t).then(e=>(r(),e),async e=>{throw await r(),e}),onRevoke:t=>e.revokePersonalAccessToken(t).finally(r)})]}):(0,X.jsx)(I,{error:n})},oc=()=>_().personalAccessTokens?(0,X.jsx)(ac,{}):null,sc={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},cc=e=>e.provider===`google`,lc=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[i,a]=(0,Y.useState)(),[s,c]=(0,Y.useState)(r),[l,u]=(0,Y.useState)(),[d,f]=(0,Y.useState)(),p=async(e,t)=>{a(e),c(void 0),f(void 0);try{await t(),u(void 0)}catch(e){if(!(e instanceof k))throw e;c(z(e))}finally{a(void 0)}};return(0,X.jsxs)(K,{title:O(`connections`),description:O(`connectionsDescription`),children:[(0,X.jsx)(L,{message:l?void 0:s}),(0,X.jsx)(ht,{message:d}),(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(Br,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,X.jsx)(M,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void p(e.key,()=>t(e)),children:e.accounts.length>0?O(`connectAgain`,{name:e.label}):O(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[O(`connectedOn`,{date:ot(Date.parse(t.created_at))}),` · `,(0,X.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,X.jsx)(H,{tone:`amber`,children:O(`connectionNeedsSignIn`)}):(0,X.jsx)(H,{tone:`green`,children:O(`connected`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>u({connection:e,accountId:t.id}),children:O(`disconnect`)})]}),t.used_by.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:O(`connectionUsedBy`)}),t.used_by.map(e=>(0,X.jsx)(Ke,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),l&&(0,X.jsx)(o,{title:O(`disconnectTitle`,{name:l.connection.label}),description:cc(l.connection)?`${O(`disconnectDescription`)} ${O(`disconnectWholeGrant`)}`:O(`disconnectDescription`),onClose:()=>u(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>u(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:i===l.accountId,onClick:()=>void p(l.accountId,async()=>f(O(sc[await n(l.accountId)]))),children:O(`disconnect`)})]}),children:s&&(0,X.jsx)(L,{message:s})})]})},uc=()=>{let{session:e,connectAccount:t}=_(),{account:n}=e,[r]=(0,Y.useState)(Gt),{data:i,error:a,reload:o}=W((0,Y.useCallback)(()=>n.workflowConnections(),[n]),O(`couldNotReadMethods`));return i?i.length===0?null:(0,X.jsx)(lc,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&bt(r,O(`theProvider`))}):(0,X.jsx)(I,{error:a})},dc=e=>e.code===`LAST_ADMIN`?O(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?O(`deleteAccountLocked`):z(e),fc=({hasPassword:e,onDelete:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(!1),f=(0,Y.useId)(),p=async()=>{s(!0),l(void 0),d(!1);try{await t(e?r:void 0)}catch(e){if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?d(!0):l(dc(e)),s(!1)}};return(0,X.jsxs)(o,{title:O(`deleteAccountQuestion`),description:O(`deleteAccountWarning`),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:n,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,type:`submit`,form:f,loading:a,disabled:e&&!r,children:O(`deleteAccountConfirm`)})]}),children:[(0,X.jsxs)(`form`,{id:f,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),p()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`deleteAccountPassword`),(0,X.jsx)(N,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,invalid:!!c,onChange:e=>i(e.target.value)})]}),(0,X.jsx)(L,{message:c})]}),u&&(0,X.jsx)(Sn,{purpose:`change`,minutes:15,onConfirmed:()=>void p()})]})},pc=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(K,{title:O(`deleteAccount`),description:O(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,X.jsx)(M,{variant:`danger`,onClick:()=>i(!0),children:O(`deleteAccount`)}),r&&(0,X.jsx)(fc,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},mc=()=>{let{session:e,state:t,deleteAccount:n}=_(),{account:r}=e,{data:i,error:a}=W((0,Y.useCallback)(()=>r.signInMethods(),[r]),O(`couldNotReadMethods`));return i?(0,X.jsx)(pc,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,X.jsx)(I,{error:a})},hc=[[/Edg(e|A|iOS)?\//,`Edge`],[/OPR\/|Opera/,`Opera`],[/SamsungBrowser\//,`Samsung Internet`],[/Firefox\/|FxiOS\//,`Firefox`],[/Chrome\/|CriOS\//,`Chrome`],[/Safari\//,`Safari`]],gc=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/CrOS/,`ChromeOS`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/Linux/,`Linux`]],_c=(e,t)=>e.find(([e])=>e.test(t))?.[1],vc=e=>e?{browser:_c(hc,e),system:_c(gc,e)}:{},yc=e=>e.device?O(`deviceThrough`,{device:e.device,provider:e.name}):e.name,bc=(e,t)=>{if(e.staff)return t?O(`staffOf`,{operator:t}):O(`staff`);let{browser:n,system:r}=vc(e.userAgent);return n&&r?O(`browserOn`,{browser:n,system:r}):r?O(`aBrowserOn`,{system:r}):n??O(`unknownDevice`)},xc=e=>{if(e.staff)return Hr;let{system:t}=vc(e.userAgent);return t===`iPhone`||t===`Android`?Wr:t===`iPad`?Kr:Rr},Sc=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),Cc=(e,t)=>e.kind===`one`?O(`signOutDevice`,{name:bc(e.session,t)}):e.kind===`link`?O(`signOutDevice`,{name:yc(e.link)}):O(`signOutOthersTitle`),wc=e=>O(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),Tc=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(),[d,f]=(0,Y.useState)(),p=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),m=e.filter(e=>!e.current),h=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),g=async e=>{c(!0),u(void 0);try{await h(e),f(void 0)}catch(e){if(!(e instanceof k))throw e;u(z(e))}c(!1)},_=e=>{u(void 0),f(e)};return(0,X.jsxs)(K,{title:O(`devices`),description:O(`devicesDescription`),children:[p.length===0&&n.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:O(`noDevices`)}):(0,X.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[Sc(p).map(e=>{let n=xc(e);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:bc(e,t)}),e.current&&(0,X.jsx)(H,{tone:`green`,children:O(`thisDevice`)})]}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[O(`signedInFromUntil`,{from:Ft(Date.parse(e.createdAt)),until:Ft(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`one`,session:e}),children:O(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Wr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:yc(t)}),n&&(0,X.jsx)(H,{tone:`green`,children:O(`thisDevice`)})]}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:O(`linkedOn`,{date:Ft(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`link`,link:t}),children:O(`signOut`)})]},t.id)})]}),m.length>0&&(0,X.jsx)(M,{className:`mt-3`,onClick:()=>_({kind:`others`}),children:O(`signOutOthers`)}),d&&(0,X.jsx)(o,{title:Cc(d,t),description:wc(d),onClose:()=>f(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>f(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:s,onClick:()=>void g(d),children:O(`signOut`)})]}),children:(0,X.jsx)(L,{message:l})})]})},Ec=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=_(),{account:r}=e,i=(0,Y.useCallback)(async()=>{let[e,t]=await Promise.all([r.sessions(),n?r.deviceLinks():[]]);return{sessions:e,links:t}},[r,n]),{data:a,error:o,reload:s}=W(i,O(`couldNotReadDevices`));return a?(0,X.jsx)(Tc,{sessions:a.sessions,links:a.links,operator:t,onSignOut:e=>r.revokeSession(e).then(s),onSignOutOthers:()=>r.revokeOtherSessions().then(s),onSignOutLink:e=>r.signOutDeviceLink(e).then(s)}):(0,X.jsx)(I,{error:o})},Dc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},Oc=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(),g=e===`required`&&t.length<=1,_=async e=>{s(!0),l(void 0),h(void 0);try{await e(),d(void 0)}catch(e){if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):l(z(e))}s(!1)};return(0,X.jsxs)(K,{title:O(`passkeys`),status:e===`required`&&(0,X.jsx)(H,{tone:`blue`,children:O(`required`)}),description:O(Dc[e]),children:[(0,X.jsx)(L,{message:u?void 0:c}),t.length>0&&(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(S,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??O(`passkey`)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?O(`addedOn`,{date:ot(Date.parse(e.createdAt))}):O(`addedEarlier`),` · `,e.backedUp?O(`synced`):O(`oneDevice`)]})]}),(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>{p(e.name??``),d({kind:`rename`,passkey:e})},children:O(`rename`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,disabled:g,title:g?O(`keepLastPasskey`):void 0,onClick:()=>d({kind:`remove`,passkey:e}),children:O(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,X.jsxs)(M,{loading:a&&!u,onClick:()=>void _(n),children:[(0,X.jsx)(oe,{className:`size-3.5`}),O(`addPasskey`)]}),m===`asked`&&(0,X.jsx)(Sn,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:O(`confirmedAddPasskey`)}),u?.kind===`rename`&&(0,X.jsxs)(o,{title:O(`renamePasskey`),description:O(`renamePasskeyDescription`),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>d(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:a,disabled:!f.trim(),onClick:()=>void _(()=>r(u.passkey.id,f.trim())),children:O(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`name`),(0,X.jsx)(N,{autoFocus:!0,value:f,maxLength:60,onChange:e=>p(e.target.value)})]}),(0,X.jsx)(L,{message:c})]}),u?.kind===`remove`&&(0,X.jsx)(o,{title:O(`removePasskey`),description:O(`removePasskeyDescription`,{name:u.passkey.name??O(`thisPasskey`)}),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>d(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:a,onClick:()=>void _(()=>i(u.passkey.id)),children:O(`remove`)})]}),children:c&&(0,X.jsx)(L,{message:c})})]})},kc=()=>{let{account:e}=_().session,t=(0,Y.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=W(t,O(`couldNotReadMethods`));if(!n)return(0,X.jsx)(I,{error:r});let[a,o]=n;return(0,X.jsx)(Oc,{rule:a.policy.passkey,passkeys:o,onAdd:()=>e.addPasskey().then(i),onRename:(t,n)=>e.renamePasskey(t,n).then(i),onRemove:t=>e.removePasskey(t).then(i)})},Ac=e=>e.code===`PASSWORD_TOO_SHORT`?O(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?O(`passwordTooLong`):z(e),jc=(e,t)=>{if(e.length<12)return O(`useAtLeast`,{length:12});if(e!==t)return O(`passwordsDiffer`)},Mc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),m=(0,Y.useId)(),h=(!e||r)&&a&&c,g=async()=>{let e=jc(a,c);if(p(e),!e){d(!0);try{await t({current:r,next:a})}catch(e){if(!(e instanceof k))throw e;p(Ac(e)),d(!1)}}};return(0,X.jsx)(o,{title:O(e?`changePassword`:`setPassword`),description:O(`atLeast`,{length:12}),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:n,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,type:`submit`,form:m,loading:u,disabled:!h,children:O(`save`)})]}),children:(0,X.jsxs)(`form`,{id:m,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),g()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`currentPassword`),(0,X.jsx)(N,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`newPassword`),(0,X.jsx)(N,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!f,onChange:e=>s(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`repeatPassword`),(0,X.jsx)(N,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:c,invalid:!!f,onChange:e=>l(e.target.value)})]}),e&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:O(`changeSignsOutOthers`)}),(0,X.jsx)(L,{message:f})]})})},Nc=({rule:e,hasPassword:t,staff:n})=>O(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),Pc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=!n&&e===`allowed`;return(0,X.jsxs)(K,{title:O(`password`),description:Nc({rule:e,hasPassword:t,staff:n}),children:[(0,X.jsx)(ht,{message:s?O(`passwordSaved`):void 0}),l&&(0,X.jsx)(M,{onClick:()=>{c(!1),o(!0)},children:O(t?`changePassword`:`setPassword`)}),a&&(0,X.jsx)(Mc,{hasPassword:t,onClose:()=>o(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):i(n)),o(!1),c(!0)}})]})},Fc=()=>{let{session:e,state:t}=_(),{account:n}=e,{data:r,error:i,reload:a}=W((0,Y.useCallback)(()=>n.signInMethods(),[n]),O(`couldNotReadMethods`));return r?(0,X.jsx)(Pc,{rule:r.policy.password,hasPassword:r.account.password,staff:t.kind===`signed-in`&&!!t.staff,onChange:(e,t)=>n.changePassword(e,t).then(a),onSet:e=>n.setPassword(e).then(a)}):(0,X.jsx)(I,{error:i})},Ic=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=async e=>{f(!0),m(void 0);try{await e()}catch(e){if(!(e instanceof k))throw e;m(z(e))}f(!1)},g=i.trim(),_=()=>h(async()=>{await t.request(g),u(``),c(g)}),v=e=>h(async()=>{await t.confirm(s,e),n()});return s?(0,X.jsxs)(o,{title:O(`changeEmail`),description:O(`codeSentTo`,{email:s,minutes:10}),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{variant:`ghost`,onClick:()=>{c(void 0),m(void 0)},children:O(`otherAddress`)}),(0,X.jsx)(M,{variant:`primary`,loading:d,disabled:l.length<6,onClick:()=>void v(l),children:O(`changeEmail`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`code`),(0,X.jsx)(ve,{name:`code`,required:!0,autoFocus:!0,value:l,invalid:!!p,onChange:u,onComplete:e=>!d&&void v(e)})]}),(0,X.jsx)(L,{message:p})]}):(0,X.jsxs)(o,{title:O(`changeEmail`),description:O(`changeEmailDescription`),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:r,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:d,disabled:!g||g.toLowerCase()===e.toLowerCase(),onClick:()=>void _(),children:O(`sendCode`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`newEmail`),(0,X.jsx)(N,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(L,{message:p})]})},Lc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(),g=async()=>{p(!0),h(void 0);try{await n(u.trim()),s(!1)}catch(e){if(!(e instanceof k))throw e;h(z(e))}p(!1)};return(0,X.jsxs)(K,{title:O(`profile`),description:O(`profileDescription`),children:[(0,X.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:O(`name`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:O(`email`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(M,{onClick:()=>{d(e),h(void 0),s(!0)},children:O(`changeName`)}),r&&(0,X.jsx)(M,{onClick:()=>l(!0),children:O(`changeEmail`)})]}),a&&(0,X.jsxs)(o,{title:O(`changeName`),description:O(`changeNameDescription`),onClose:()=>s(!1),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>s(!1),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:f,disabled:!u.trim()||u.trim()===e,onClick:()=>void g(),children:O(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`name`),(0,X.jsx)(N,{autoFocus:!0,value:u,maxLength:100,onChange:e=>d(e.target.value)})]}),(0,X.jsx)(L,{message:m})]}),c&&r&&(0,X.jsx)(Ic,{email:t,change:r,onClose:()=>l(!1),onDone:()=>{l(!1),i?.()}})]})},Rc=()=>{let{session:e,changeEmail:t}=_(),{data:n,loaded:r,error:i,reload:a}=W((0,Y.useCallback)(()=>e.session(),[e]),O(`couldNotReadProfile`));if(!r)return(0,X.jsx)(I,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,X.jsx)(Lc,{name:n.name,email:n.email,onRename:t=>e.account.updateName(t).then(a),emailChange:o,onEmailChanged:a})},zc=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:s})=>{let[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),[m,h]=(0,Y.useState)(!1),g=async()=>{d(!0),p(void 0),h(!1);try{await a(i?c:void 0)}catch(e){if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(!0):p(z(e)),d(!1)}};return(0,X.jsxs)(o,{title:e,description:t,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:s,children:O(`cancel`)}),(0,X.jsx)(M,{variant:r?`danger`:`primary`,loading:u,disabled:i&&!c,onClick:()=>void g(),children:n})]}),children:[i&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`yourPassword`),(0,X.jsx)(N,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:c,invalid:!!f,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&c&&void g()})]}),f&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:f}),m&&(0,X.jsx)(Sn,{purpose:`change`,minutes:15,onConfirmed:()=>void g()})]})},Bc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},Vc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:s,onNewBackupCodes:c,onChanged:l}=e,[u,d]=(0,Y.useState)(),f=()=>d(void 0),p=n?(0,X.jsx)(H,{tone:`green`,children:O(`on`)}):t===`required`?(0,X.jsx)(H,{tone:`amber`,children:O(`required`)}):(0,X.jsx)(H,{children:O(`off`)}),m=O(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:Bc[t]);return u?.kind===`setup`?(0,X.jsx)(K,{title:O(`twoFactor`),status:p,description:m,children:(0,X.jsx)(`div`,{className:`max-w-sm`,children:(0,X.jsx)(hn,{offerEmailedCodes:i&&!u.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:f,onDone:()=>{f(),l()}})})}):(0,X.jsxs)(K,{title:O(`twoFactor`),status:p,description:m,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,X.jsx)(M,{variant:`primary`,onClick:()=>d({kind:`setup`,appOnly:!1}),children:O(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,X.jsx)(M,{onClick:()=>d({kind:`setup`,appOnly:!0}),children:O(`addAuthenticator`)}),n&&r&&(0,X.jsx)(M,{onClick:()=>d({kind:`new-codes`}),children:O(`newBackupCodes`)}),n&&(0,X.jsx)(M,{variant:`danger`,disabled:t===`required`,title:t===`required`?O(`twoFactorIsRequired`):void 0,onClick:()=>d({kind:`turn-off`}),children:O(`turnOff`)})]}),u?.kind===`turn-off`&&(0,X.jsx)(zc,{title:O(`turnOffTitle`),description:O(`turnOffDescription`),confirmLabel:O(`turnOff`),danger:!0,needsPassword:a,onClose:f,onConfirm:async e=>{await s(e),f(),l()}}),u?.kind===`new-codes`&&(0,X.jsx)(zc,{title:O(`newCodesTitle`),description:O(`newCodesDescription`),confirmLabel:O(`makeNewCodes`),needsPassword:a,onClose:f,onConfirm:async e=>d({kind:`codes`,codes:await c(e)})}),u?.kind===`codes`&&(0,X.jsx)(o,{title:O(`yourNewCodes`),description:O(`keepCodesSafe`),onClose:f,actions:(0,X.jsx)(M,{variant:`primary`,onClick:f,children:O(`savedCodes`)}),children:(0,X.jsx)(Dn,{codes:u.codes})})]})},Hc=()=>{let{account:e}=_().session,{data:t,error:n,reload:r}=W((0,Y.useCallback)(()=>e.signInMethods(),[e]),O(`couldNotReadMethods`));return t?(0,X.jsx)(Vc,{rule:t.policy.twoFactor,enabled:t.account.twoFactor,authenticatorApp:t.account.authenticatorApp,mail:t.mail,needsPassword:t.account.password,onStartApp:t=>e.startAuthenticatorApp(t),onConfirmApp:t=>e.confirmAuthenticatorApp(t),onEmailedCodes:t=>e.turnOnEmailedCodes(t),onTurnOff:t=>e.turnOffTwoFactor(t),onNewBackupCodes:t=>e.newBackupCodes(t),onChanged:r}):(0,X.jsx)(I,{error:n})},Uc=({problem:e,fallback:t})=>t===void 0?(0,X.jsx)(rn,{children:e}):(0,X.jsxs)(X.Fragment,{children:[!1,t]}),Wc=({name:e,registered:t,fallback:n,children:r})=>t?(0,X.jsx)(Qe,{name:e,fallback:n===void 0?void 0:(0,X.jsx)(Uc,{problem:V.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,X.jsx)(Uc,{problem:V.rich(`noComponent`,{component:e}),fallback:n}),Gc={Page:to,Grid:ja,Card:di,Stat:Bo,RecordCard:ao,Field:Ea,Diff:Ca,Table:Go,CardRow:hi,RecordRow:To,RecordCards:xo,Chart:gi,Timeline:ta,Graph:aa,Progress:ro,Image:za,ModalForm:eo,Thread:vs,Composer:ba,Action:ui,Show:No,Switch:Fo,Match:Io,Link:Ya,Settings:ko,Tabs:qo,Tab:Jo,Users:Rs,Profile:Rc,Password:Fc,Passkeys:kc,TwoFactor:Hc,ConnectedAccounts:$e,PersonalMail:Ws,Connections:uc,Devices:Ec,ConnectedApps:Qs,PersonalAccessTokens:oc,DeleteAccount:mc,Box:ys,Row:bs,Column:xs,Text:Ss,ReferenceManyField:Ds,ReferenceArrayField:ks,ArrayField:Cs,RecordsIterator:pi,ReferenceField:js,SelectInput:ws,Details:xa,Summary:Sa,TextField:Ha,NumberField:Ua,DateField:Wa,BooleanField:Ga,UrlField:Ka,ChipField:qa},Kc=new Set(`Page.Grid.Card.Stat.RecordCard.Field.Diff.Table.CardRow.RecordRow.RecordCards.Chart.Timeline.Graph.Progress.Image.Thread.Link.Tabs.Settings.Show.Switch.Action.Box.Row.Column.Text.ReferenceField.SelectInput.Details.Summary.TextField.NumberField.DateField.BooleanField.UrlField.ChipField`.split(`.`)),qc=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:ae(t,...n,r)}})),Jc=({text:e})=>{let t=R(),n=an(),r={...F(t),params:n};return(0,X.jsx)(X.Fragment,{children:en(e,e=>dn(ze(r,e)))})},Yc=(e,t)=>e.includes(`{{`)?(0,X.jsx)(Jc,{text:e},t):(0,X.jsx)(Y.Fragment,{children:e},t),Xc=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?Yc(e,n):(0,X.jsx)(rl,{node:e,at:t},n)),Zc=e=>{let t=[];for(let n of e){let e=t.at(-1);Xr(n.child)&&e&&Xr(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Xr(n.child)?(0,X.jsx)(`p`,{className:`leading-6`,children:Xc(e)},t):(0,X.jsx)(rl,{node:n.child,at:n.at},t)})},Qc=e=>tn(e)||Array.isArray(e)&&e.length>0&&e.every(tn),$c=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>Qc(n)?[[e,(0,X.jsx)(X.Fragment,{children:Zc(el(n,t,e))})]]:[])),el=(e,t,n)=>Array.isArray(e)?qc(e,t,`props`,n):[{child:e,...t!==void 0&&{at:ae(t,`props`,n)}}],tl=e=>typeof e==`object`&&!!e&&!Array.isArray(e),nl=(e,t)=>{let n=tl(e.props.components)?e.props.components:{},r=Object.fromEntries(Object.entries(n).flatMap(([e,t])=>tn(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=Mn(t,String(e.props.i18nKey),tl(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||tn(e)?e:String(e)):[i]},rl=({node:e,at:t})=>{let{components:n}=y(),r=R(),i=an(),a=Cn(),o=(0,Y.useMemo)(()=>ke(w(e,{...F(r),params:i}),a),[e,r,i,a]);if(o.type===`Trans`&&!o.custom)return(0,X.jsx)(X.Fragment,{children:Xc(nl(o,a).map(e=>({child:e})))});if(o.custom){let e=n?.[o.type],r=o.children.length>0?(0,X.jsx)(na,{node:o,children:Zc(qc(o.children,t,`children`))}):void 0;return(0,X.jsx)(Wc,{name:o.type,registered:!!e,fallback:o.fallback&&(0,X.jsx)(X.Fragment,{children:Zc(qc(o.fallback,t,`fallback`))}),children:e&&(0,X.jsx)(Vt,{node:o,...t!==void 0&&{at:t},children:(0,X.jsx)(e,{...Be(o.props),children:r})})})}let s=Gc[o.type];if(!s)return(0,X.jsx)(rn,{children:V.rich(`unknownBlock`,{type:o.type})});let c=typeof o.props.className==`string`?o.props.className:void 0,l=qc(o.children,t,`children`),u=(0,X.jsx)(s,{node:o,at:t,slots:$c(o,t),className:c,children:o.type===`Text`||o.type===`Link`||o.type===`Summary`?Xc(l):Zc(o.type===`Switch`?l.filter(({child:e})=>typeof e!=`string`):l)}),d=c===void 0||Kc.has(o.type)?u:(0,X.jsx)(`div`,{className:c,children:u});return o.fallback?(0,X.jsx)(Qe,{name:o.type,resetKey:o,fallback:(0,X.jsx)(X.Fragment,{children:Zc(qc(o.fallback,t,`fallback`))}),children:d}):d};export{ms as a,ns as c,yo as d,lo as f,ua as h,gs as i,Vo as l,ya as m,Wc as n,ps as o,oo as p,_s as r,ds as s,rl as t,Ao as u};
3
- //# debugId=5b7f0931-7ca6-43e8-b23e-b0aedde3ac49
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-IPDrZVmC.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-DANB5cb3.js","assets/vendor-t7Q7QbPu.js","assets/app-lQJl2mz_.css","assets/lib-xyflow-system-hojcPWkY.js","assets/lib-d3-interpolate-C7dFwq8w.js","assets/lib-d3-color-B6XHLQii.js","assets/lib-d3-selection-C1a5EtaJ.js","assets/lib-d3-drag-CUJR_Vab.js","assets/lib-d3-dispatch-Bjkn7q4t.js","assets/lib-d3-zoom-DuEhbOrX.js","assets/lib-d3-transition-CUMO2iZu.js","assets/lib-d3-timer-CduGpaSm.js","assets/lib-d3-ease-ouQSXgQM.js","assets/lib-xyflow-react-CuNAzocq.js","assets/lib-classcat-otpLnDWv.js","assets/lib-zustand-r6mNROKr.js","assets/lib-use-sync-external-store-D4s7MiFL.js","assets/lib-xyflow-react-DLioOiRN.css","assets/use-elk-u1Ql5AOs.js","assets/lib-elkjs-ylMkguT9.js"])))=>i.map(i=>d[i]);
2
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$s as r,A as i,Aa as a,Cc as o,Cl as s,Cn as c,Cr as l,Dc as u,Dl as d,Dn as f,Ec as p,En as m,Fa as h,Fn as g,Fs as _,Ft as v,Ga as y,Gc as b,Gn as x,Hc as S,Hi as C,Hs as w,I as T,Ii as E,Is as ee,It as te,Ja as ne,Js as re,Kn as ie,Kr as D,Ks as ae,Lc as oe,Ls as se,Ml as ce,Mn as le,Mt as ue,N as de,Nn as fe,Nt as pe,O as me,Oa as he,Ol as ge,On as _e,Oo as ve,Pa as ye,Pl as be,Ps as O,Pt as xe,Qc as Se,Qn as Ce,Qs as we,Ra as Te,Ri as Ee,Rs as k,Sa as De,Sc as A,Sn as Oe,Sr as j,Ss as ke,Tc as M,Ti as Ae,Tl as je,Tn as Me,Ts as Ne,Un as Pe,Uo as N,Ur as Fe,Us as Ie,V as Le,Wn as Re,Ws as ze,Xl as Be,Xr as Ve,Xt as P,Ya as He,Yl as Ue,Ys as We,Zi as Ge,Zt as Ke,_c as qe,_r as F,_t as Je,a as Ye,ac as Xe,an as Ze,ao as Qe,as as $e,at as et,b as tt,bc as nt,bn as rt,br as it,c as at,ca as ot,cn as st,co as ct,cr as lt,cs as I,da as ut,dr as dt,ds as L,ec as ft,en as pt,fn as mt,fs as ht,ga as gt,gc as _t,gl as vt,gn as yt,gr as R,gs as bt,gt as xt,ha as St,hc as Ct,hl as wt,hn as Tt,ho as Et,hr as Dt,hs as z,ic as Ot,ir as kt,ja as At,ji as jt,ka as Mt,kc as Nt,ki as Pt,la as Ft,ln as It,ls as Lt,mn as Rt,ms as zt,nc as Bt,nn as Vt,ns as Ht,nu as Ut,oc as Wt,ol as B,oo as V,os as Gt,pc as Kt,pn as qt,pr as Jt,ps as H,qn as Yt,qr as Xt,qs as Zt,rc as Qt,rr as $t,ru as en,sc as tn,sl as U,sn as nn,so as rn,sr as an,ss as W,tc as on,tl as sn,ts as cn,u as ln,un as G,ur as un,us as K,uu as dn,v as fn,vc as pn,vi as mn,vo as hn,vr as gn,vs as q,w as _n,wn as vn,wt as yn,x as bn,xn,xo as Sn,xr as J,xs as Cn,y as wn,yl as Tn,yn as En,yo as Dn,yr as On,ys as kn,z as An,zc as jn,zs as Mn}from"./app-DANB5cb3.js";import{C as Nn,f as Pn,o as Fn,s as In}from"./vendor-t7Q7QbPu.js";import{C as Ln,Ct as Rn,Dt as zn,Et as Bn,O as Vn,Ot as Hn,Q as Un,St as Wn,Tt as Gn,X as Kn,Z as qn,_t as Jn,at as Yn,b as Xn,ct as Zn,dt as Qn,ft as $n,gt as er,it as tr,jt as nr,k as rr,l as ir,lt as ar,mt as or,n as sr,nt as cr,o as lr,ot as ur,rt as dr,st as fr,t as pr,tt as mr,ut as hr,wt as gr,x as _r,xt as vr,y as yr}from"./embedded-list-CepLmiOu.js";import{t as br}from"./circle-alert-BZyGgZSj.js";import{t as xr}from"./page-header-Ddz2r5ic.js";import{n as Sr,t as Cr}from"./pending-invitation-row-Bs60Zx0i.js";import{n as wr,t as Tr}from"./person-row-BH3iAvuG.js";import{n as Er,t as Dr}from"./use-paged-search-DOcO0Rbz.js";import{n as Or,t as kr}from"./client-publisher-D39SlIhp.js";import{t as Ar}from"./copy-field-DpbjVuK4.js";var jr={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};jr.node;var Mr=B(jr),Nr={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};Nr.node;var Pr=B(Nr),Fr={name:`key-square`,size:24,node:[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]};Fr.node;var Ir=B(Fr),Lr={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};Lr.node;var Rr=B(Lr),zr={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};zr.node;var Br=B(zr),Vr={name:`shield-user`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]};Vr.node;var Hr=B(Vr),Ur={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Ur.node;var Wr=B(Ur),Gr={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};Gr.node;var Kr=B(Gr),qr=[`done`,`error`,`running`];Wt(`TextField`,!1),Wt(`NumberField`,!1),Wt(`DateField`,!1),Wt(`BooleanField`,!1),Wt(`UrlField`,!1),Wt(`ChipField`,!1);var Jr=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Yr=e=>typeof e!=`string`&&!e.custom&&Jr.has(e.type),Xr=e=>typeof e==`string`||Yr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Zr=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Qr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),$r=(e,{locales:t,options:n},r)=>{let i=typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))?Number(e):e;return typeof i==`number`?i.toLocaleString(t??r,n):String(i)},ei=(e,t,n)=>{let r=e instanceof Date?e:typeof e==`string`||typeof e==`number`?new Date(e):void 0;if(!r||Number.isNaN(r.getTime()))return``;if(t.format===`relative`)return n.relative(Math.round((n.now-r.getTime())/1e3));let{showDate:i=!0,showTime:a=!1,options:o}=t,s=t.locales??n.locale;if(i&&a)return r.toLocaleString(s,o);if(a)return r.toLocaleTimeString(s,o);let c=o??(typeof e==`string`&&e.length<=10?{timeZone:`UTC`}:void 0);return r.toLocaleDateString(s,c)},ti=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,ni=new Set([`http:`,`https:`,`mailto:`,`tel:`]),ri=e=>{let t=e.replace(/^[\u0000- ]+/,``).replace(/[\t\n\r]/g,``),n=/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(t)?.[1];return n===void 0?t.startsWith(`/`)||!t.includes(`:`)?e:void 0:ni.has(`${n.toLowerCase()}:`)?e:void 0},ii=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),ai=e=>e==null||e===``?void 0:String(e),oi=(e,t)=>e<t?-1:+(e>t),si=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=ai(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=ai(r);s!==void 0&&!o.has(s)&&o.set(s,{id:s,value:r}),a.set(e,{id:e,row:t,...s!==void 0&&{group:s}})}let s=t.flatMap(e=>{let t=r.map(t=>ai(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=ai(e[i.source]),s=ai(e[i.target]);return n===void 0||o===void 0||s===void 0||!a.has(o)||!a.has(s)?[]:[{id:n,source:o,target:s,row:e}]});return{groups:[...o.values()].sort((e,t)=>oi(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>oi(e.id,t.id)),edges:s.sort((e,t)=>oi(e.source,t.source)||oi(e.target,t.target)||oi(e.id,t.id))}},Y=e(t(),1),X=e(n(),1),ci=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=q(),s=Rn(e.name,void 0),c=Ge(),[l,u]=(0,Y.useState)(!1),d=o[e.name]?.actions?.find(e=>e.name===n);if(!d||d.run?.kind===`link`)return null;let f=t.map(t=>rt(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let m=f.length-p.length,h=vr(`actionCount`,{label:r??d.label,count:p.length}),g=e=>s.runEach(d,p,m,e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>Bn(d)?u(!0):void g(),children:h}),l&&(0,X.jsx)(Gn,{action:d,label:h,danger:i===`danger`||i===void 0&&zn(d),records:p.map(e=>e.record),names:p.map(t=>Wn(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),g()},onSubmit:async e=>{u(!1),await g(e)}})]})},li=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=Dt(),c=gr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,Y.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{size:`sm`,variant:f,className:i,loading:c.running,disabled:!!c.blocked,title:c.blocked,"aria-label":a===void 0?void 0:`${d}: ${a}`,onClick:()=>Bn(c.action)?u(!0):void c.run(),children:d}),l&&(0,X.jsx)(Gn,{action:c.action,label:d,danger:f===`danger`,records:c.record?[c.record]:[],onCancel:()=>u(!1),onConfirm:()=>{u(!1),c.run()},onSubmit:async e=>{await c.submit(e),u(!1)}})]})},ui=({node:e,className:t})=>{let n=G(e),r=it(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,X.jsx)(ci,{...n,model:i,items:r.items,className:t}):(0,X.jsx)(li,{...n,className:t})},di=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=G(e);return(0,X.jsx)(J,{title:i,description:a,actions:n.actions,className:U(`h-full`,r),children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},fi=({children:e,wrap:t=(e,t)=>(0,X.jsx)(Y.Fragment,{children:e},t)})=>{let n=it();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...rt(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,X.jsx)(dt,{value:s,row:{index:o,count:i.length},children:e}),c)})},pi=({children:e})=>(0,X.jsx)(fi,{children:e}),mi=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:u,children:d,className:f})=>{let p=nn(t),m=c(e,{filter:n,sort:r,pageSize:i,enabled:!p}),h=p??m,g=p?p.rows:m.data?.items??[];return(0,X.jsx)(J,{title:a,description:o,actions:u,className:f,children:h.isPending?(0,X.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(A,{className:`h-24 w-56`},t))}):h.error?(0,X.jsx)(l,{title:V(`couldNotLoad`),error:h.error}):g.length===0?(0,X.jsx)(j,{children:s??V(`nothingYet`)}):(0,X.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,X.jsx)(gn,{value:{model:e,items:g,...p&&{planned:!0}},children:(0,X.jsx)(fi,{wrap:(e,t)=>(0,X.jsx)(`li`,{className:`flex w-60 shrink-0 snap-start flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:e},t),children:d})})})})},hi=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=G(e),o=q().resources[i];return o?(0,X.jsx)(mi,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},gi=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=G(e),{resources:u,views:d}=q(),f=u[r];return f?(0,X.jsx)(J,{title:i,description:a,actions:t.actions,className:U(`h-full`,n),children:(0,X.jsx)($n,{model:f,view:d[r],...l})}):null},_i=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=Oe(e,t),a=i.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(A,{className:`h-4 w-1/2`}),(0,X.jsx)(A,{className:`h-4 w-1/3`})]}):i.error?(0,X.jsx)(l,{title:V(`couldNotLoad`),error:i.error}):i.data?(0,X.jsx)(dt,{value:i.data,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,X.jsx)(j,{children:V(`nothingYet`)});return(0,X.jsx)(`div`,{className:n,children:a})},vi=e=>{if(typeof e!=`string`&&typeof e!=`number`)return;let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?void 0:t},yi=e=>e==null?``:String(e),bi=(e,t,n)=>n===0?0:(e-t)/n*100,xi=(e,t,n)=>{let r=new Map;for(let i of e){let e=vi(i[t.start]);if(e===void 0)continue;let a=vi(i[t.end]),o=Math.max(e,a??n),s=r.get(yi(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(yi(i[t.lane]),s);let c=s.bars.get(yi(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(yi(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},Si=e=>{let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start)){let e=t.find(e=>e.at(-1).end<=n.start);e?e.push(n):t.push([n])}return t},Ci=(e,t,n)=>{let r=xi(e,t,n),i=[...r.values()].flatMap(e=>[...e.bars.values()].flatMap(e=>e.records));if(i.length===0)return{lanes:[],from:n,to:n};let a=Math.min(...i.map(e=>e.start)),o=Math.max(...i.map(e=>e.end)),s=o-a;return{lanes:[...r.entries()].map(([e,n])=>{let r=[...n.bars.entries()].map(([e,r])=>{let i=r.records.sort((e,t)=>e.start-t.start).map(({record:e,start:n,end:r,open:i})=>({record:e,value:e[t.color],start:n,end:r,open:i,left:bi(n,a,s),width:bi(r,a,s)-bi(n,a,s)})),o=i[0].start,c=Math.max(...i.map(e=>e.end));return{key:e,value:r.value,lane:n.value,start:o,end:c,left:bi(o,a,s),width:bi(c,a,s)-bi(o,a,s),segments:i}});return{key:e,value:n.value,rows:Si(r)}}),from:a,to:o}},wi=(e,t)=>{let n=e.end-e.start;return{left:bi(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},Ti=6e4,Ei=60*Ti,Z=24*Ei,Di=[5*Ti,15*Ti,30*Ti,Ei,3*Ei,6*Ei,12*Ei,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],Oi=365*Z,ki=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Ai=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=Di.find(n=>ki(e,t,n,i,a)<=6)??Math.ceil(r/5/Oi)*Oi,s=[];for(let c=Math.ceil((e+i)/o)*o;c<=t+a;c+=o){let a=c-n(c-i);a+n(a)===c&&a>=e&&a<=t&&s.push({at:a,left:bi(a,e,r)})}return{daily:o>=Z,ticks:s}},ji=e=>({lane:yi(e.lane),bar:e.key}),Mi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ni=(e,t)=>{let n=Object.fromEntries(new Intl.DateTimeFormat(`en-US`,{timeZone:t,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}).formatToParts(e).map(e=>[e.type,e.value]));return Date.UTC(Number(n.year),Number(n.month)-1,Number(n.day),Number(n.hour),Number(n.minute))-Math.floor(e/6e4)*6e4},Pi=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Fi=({from:e,to:t,dated:n})=>{let r=n?`UTC`:De(),i=e=>n?0:Ni(e,r),{daily:a,ticks:o}=Ai(e,t,i);return(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`relative h-5 min-w-0 flex-1 border-b border-border text-xs text-muted-foreground tabular-nums`,children:o.map(e=>(0,X.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Pi(e.left)}`,style:{left:`${e.left}%`},children:a?ut(e.at+i(e.at)):gt(e.at,r)},e.at))})},Ii=(e,t,n)=>{let r=String(n),i=t?.waitingValues?.includes(r)??!1,a=t?.valueColors&&Object.hasOwn(t.valueColors,r)?t.valueColors[r]:void 0;return a!==void 0&&be(a)?{className:zt[a],striped:i}:{color:er(e,t,n===void 0?null:n,-1),striped:i}},Li=e=>({...e.color!==void 0&&{backgroundColor:e.color},...e.striped&&{backgroundImage:`repeating-linear-gradient(-45deg, transparent 0 4px, color-mix(in srgb, var(--background) 55%, transparent) 4px 6px)`}}),Ri=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Ii(t,n,r.value),{left:o,width:s}=wi(e,r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...Li(a)}},i)}),zi=(e,t)=>t?ot(e):Ft(e),Bi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return V(`timelineRange`,{from:zi(n,a),to:i?V(`timelineNow`):zi(r,a)})},Vi=(e,t,n,r)=>`${Ae(t.fields[r.color],e.value,n?.fields[r.color])}: ${Bi(t,r,e.start,e.end,e.open)}`,Hi=(e,t,n,r,i)=>{let a=e.segments.some(t=>t.open&&t.end===e.end);return[`${i??Ae(t.fields[r.bar],e.value,n?.fields[r.bar])}: ${Bi(t,r,e.start,e.end,a)}`,...e.segments.map(e=>Vi(e,t,n,r))].join(`; `)},Ui=`absolute inset-y-0 flex overflow-hidden rounded-sm ring-offset-1 ring-offset-background outline-none hover:ring-2 hover:ring-border-strong focus-visible:ring-2 focus-visible:ring-primary`,Wi=({bar:e,model:t,view:n,fields:r,point:i,choose:a})=>{let o=q().resources[t.fields[r.bar]?.relation?.resource??``],s=g(o??t,e.key,o!==void 0),c=Hi(e,t,n,r,o?s:void 0),l={onMouseEnter:()=>i.hover(e),onMouseLeave:()=>i.hover(null),onFocus:()=>i.focus(e),onBlur:()=>i.focus(null)},u={left:`${e.left}%`,width:`max(${e.width}%, 4px)`},d=(0,X.jsx)(Ri,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,X.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Ui,...l,children:d});let f=a.chosen===e.key;return(0,X.jsx)(nt,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:U(Ui,f&&`ring-2 ring-foreground`),...l,children:d})},Gi=({shape:e,...t})=>{let{model:n,fields:r}=t,i=n.fields[r.lane];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,X.jsx)(Fi,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,X.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,X.jsx)(Me,{model:n,field:i,value:e.value})}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 border-l border-border pl-px`,children:e.rows.map((e,n)=>(0,X.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,X.jsx)(Wi,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ki=({model:e,view:t,fields:n,value:r})=>{let i=Ii(e.fields[n.color],t?.fields[n.color],r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:Li(i)})},qi=({values:e,...t})=>{let n=t.model.fields[t.fields.color],r=(n.enumValues??[]).filter(t=>e.has(t));return(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(Ki,{...t,value:e}),Ae(n,e,t.view?.fields[t.fields.color])]},e))})},Ji=({bar:e,...t})=>{let{model:n,view:r,fields:i}=t;if(!e)return(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:V(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:(0,X.jsx)(Me,{model:n,field:n.fields[i.bar],value:e.value})}),(0,X.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Bi(n,i,e.start,e.end,a)})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,X.jsx)(Ki,{...t,value:e.value}),Ae(n.fields[i.color],e.value,r?.fields[i.color]),`: `,Bi(n,i,e.start,e.end,e.open)]},a))})]})},Yi=500,Xi=(e,t,{filter:n=``,sort:r,fields:i,limit:a})=>({queryKey:[...wt.list(t.name,n,r,a,`timeline`),i.join(`,`)],queryFn:async()=>{let o=[],s;do{let c=await e.list(t.name,{filter:n||void 0,orderBy:r,pageSize:Math.min(Yi,a-o.length),fields:i,etag:!1,...s&&{pageToken:s}});o.push(...c.items),s=c.nextPageToken||void 0}while(s&&o.length<a);return{rows:o.toReversed(),cut:s!==void 0}}}),Zi=(e,{enabled:t=!0,...n})=>Fn({...Xi(Ne(),e,n),enabled:t,placeholderData:Pn}),Qi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=on,title:s,description:c,empty:u,actions:d,className:f,choose:p,details:m})=>{let[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),y=e=>e?ji(e):null,b={hover:e=>g(y(e)),focus:e=>v(y(e))},x=nn(i),S=Zi(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!x}),C=x??S,w=x?x.rows:S.data?.rows??[],T=!x&&S.data?.cut===!0,E=Ci(w,n,Date.now());return(0,X.jsxs)(J,{title:s,description:c,actions:d,className:U(`h-full`,f),children:[(()=>{if(C.isPending)return(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(A,{className:`h-6`},t))});if(C.error)return(0,X.jsx)(l,{title:V(`couldNotLoad`),error:C.error});if(E.lanes.length===0)return(0,X.jsx)(j,{children:u??V(`nothingYet`)});let r=new Set(w.map(e=>String(e[n.color])));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(qi,{model:e,view:t,fields:n,values:r}),(0,X.jsx)(Gi,{shape:E,model:e,view:t,fields:n,point:b,...p&&{choose:p}}),T&&(0,X.jsx)(j,{children:V(`timelineCut`,{count:w.length})}),(0,X.jsx)(`div`,{"aria-live":`polite`,children:(0,X.jsx)(Ji,{bar:Mi(E,h)??Mi(E,_),model:e,view:t,fields:n})})]})})(),m]})},$i=(e,t)=>e.type===`integer`?Number(t):t,ea=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=lt(),a=r[e],o=t=>i({[e]:t}),s=n.model.fields[n.fields.bar],c=a===void 0?null:(0,X.jsx)(pn,{name:e,children:(0,X.jsx)(_i,{model:n.model,query:{filter:Jn(s,$i(s,a),n.filter),sort:n.sort},children:t},a)});return(0,X.jsx)(Qi,{...n,choose:{barTo:o,chosen:a},details:c})},ta=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,lane:c,bar:l,start:u,end:d,color:f,children:p,...m}=G(e),{resources:h,views:g}=q(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Bt(e),sort:Qt(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,X.jsx)(Qi,{...v}):(0,X.jsx)(ea,{...v,select:s,children:r})},na=({node:e,children:t})=>{let n=Xe(e),r=un(),{resources:i}=q();if(!n||!r)return t;let a=r.given[n.param],o=n.resource===void 0?void 0:i[n.resource];return a===void 0||!o?null:(0,X.jsx)(pn,{name:n.param,children:(0,X.jsx)(_i,{model:o,query:{key:a},className:``,children:t},a)})},ra=(0,Y.lazy)(()=>Nn(()=>import(`./graph-view-IPDrZVmC.js`).then(e=>({default:e.GraphView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),ia=(0,X.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,X.jsx)(u,{})}),aa=({node:e,at:t,slots:n,children:r,className:i})=>{let a=G(e),o=Ze(e,t),s=un(),c=o.nodes,u=o.edges,{label:d,group:f,status:p,source:m,target:h}=a,g=(0,Y.useMemo)(()=>({label:d,source:m,target:h,...f!==void 0&&{group:f},...p!==void 0&&{status:p}}),[d,m,h,f,p]),_=JSON.stringify([c?.rows,u?.rows,g]),v=(0,Y.useMemo)(()=>c&&u&&si({nodes:c.rows,edges:u.rows,key:c.model.primaryKey[0],edgeKey:u.model.primaryKey,fields:g}),[_]);if(!c||!u||!v)return null;let y=c.error??u.error;if(y&&e.fallback)throw y;if(y)return(0,X.jsx)(l,{title:V(`couldNotLoad`),error:y});if(c.isPending||u.isPending)return ia;if(v.nodes.length===0)return(0,X.jsx)(j,{children:a.empty??V(`nothingYet`)});let b=a.select,x=b!==void 0&&s?{chosen:s.given[b],linkTo:e=>s.linkTo({[b]:e})}:void 0;return(0,X.jsxs)(`div`,{className:U(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Y.Suspense,{fallback:ia,children:(0,X.jsx)(ra,{shape:v,nodes:c,edges:u,fields:g,props:a,...x&&{select:x},...a.node!==void 0&&{content:n.node}})})}),r.length>0&&x?.chosen!==void 0&&(0,X.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,X.jsx)(na,{node:e,children:r})})]})},oa=({onPick:e,accept:t})=>{let n=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{ref:n,type:`file`,multiple:!0,hidden:!0,accept:t,"aria-label":P(`filesToAttach`),onChange:t=>{e([...t.target.files??[]]),t.target.value=``}}),(0,X.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":P(`attachFiles`),title:P(`attachFiles`),onClick:()=>n.current?.click(),children:(0,X.jsx)(jn,{className:`size-4`})})]})},sa=`message`,ca=(e,t,n,r)=>[{op:`create`,resource:e,ref:sa,data:t},...r.map(e=>({op:`create`,resource:n.resource,data:{[n.field]:{$ref:sa},[n.file]:e}}))],la=e=>{let t=e.results[0];if(t?.op!==`create`)throw Error(`A message batch starts with the message it creates`);return t.record},ua=(e,t,n,r)=>[...e.attachments?r.map(t=>({op:`delete`,resource:e.attachments.resource,key:t.key})):[],{op:`delete`,resource:e.resource,key:ln(t,n)}],da=(e,t)=>{if(!(t===void 0||e.size<=t))return P(`fileTooLarge`,{size:Ee(e.size),max:Ee(t)})},fa=(e,t,n)=>e.map((e,r)=>({key:t+r,name:e.name,size:e.size,sent:0,refusal:da(e,n)})),pa=e=>e.ticket===void 0&&e.refusal===void 0,ma=e=>e.flatMap(e=>e.ticket===void 0?[]:[e.ticket]),ha=e=>!e.some(pa)&&ma(e).length>0,ga=e=>e.refusal===void 0?e.ticket!==void 0||e.size===0?Ee(e.size):P(`uploadedPercent`,{percent:Math.floor(Math.min(e.sent,e.size)/e.size*100)}):e.refusal,_a=({uploads:e,onRemove:t})=>(0,X.jsx)(`ul`,{"aria-label":P(`filesToSend`),className:`flex flex-wrap gap-2`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex max-w-full items-center gap-1 rounded-md border border-border py-0.5 pl-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:e.name}),(0,X.jsx)(`span`,{role:e.refusal===void 0?void 0:`alert`,className:U(`min-w-0`,e.refusal===void 0?`text-muted-foreground`:`text-danger-text`),children:ga(e)}),(0,X.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":P(`takeFileOff`,{name:e.name}),title:P(`takeFileOff`,{name:e.name}),onClick:()=>t(e.key),children:(0,X.jsx)(Nt,{className:`size-3.5`})})]},e.key))}),va=e=>{let t=Ne(),{resources:n}=q(),r=e&&n[e.resource]?.fields[e.file]?.file?.maxSize,[i,a]=(0,Y.useState)([]),o=(0,Y.useRef)(0),s=(0,Y.useRef)(new Map),c=(e,t)=>a(n=>n.map(n=>n.key===e?{...n,...t}:n)),l=(e,n,r)=>{let i=new AbortController;s.current.set(n.key,i),t.upload(e.resource,e.file,r,{signal:i.signal,onProgress:e=>c(n.key,{sent:e})}).then(e=>c(n.key,{ticket:e.value}),e=>{i.signal.aborted||c(n.key,{refusal:P(`fileNotUploaded`,{reason:mn(e)})})}).finally(()=>s.current.delete(n.key))};return(0,Y.useEffect)(()=>{let e=s.current;return()=>e.forEach(e=>e.abort())},[]),{uploads:i,tickets:ma(i),uploading:i.some(pa),ready:ha(i),pick:t=>{if(!e||t.length===0)return;let n=fa(t,o.current,r);o.current+=t.length,a(e=>[...e,...n]),n.forEach((n,r)=>{n.refusal===void 0&&l(e,n,t[r])})},remove:e=>{s.current.get(e)?.abort(),a(t=>t.filter(t=>t.key!==e))},sent:e=>a(t=>t.filter(t=>pa(t)||t.ticket!==void 0&&!e.includes(t.ticket)))}},Q=vt(`app/conversation`),ya=({resource:e,field:t,values:n,placeholder:r,searchPeople:i,mentions:a,attachments:o,onDraft:s,onSent:c})=>{let{resources:u}=q(),d=Ne(),f=vn(),p=kn(e),[m,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(),y=va(o);if(!u[e]||!Te(p,`create`))return null;let b=o&&u[o.resource]?.fields[o.file],x=b&&E(b);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[_!==void 0&&(0,X.jsx)(l,{title:Q(`notSent`),error:_}),(0,X.jsx)(yn,{onSend:async(r,i)=>{g(!0),v(void 0);let s=y.tickets,l={...n,...r!==``&&{[t]:r},...a!==void 0&&{[a]:i}},p=o&&s.length>0?d.batchWrite(ca(e,l,o,s)).then(la):d.create(e,l).then(e=>e.record),m=u[e],_=await p.then(e=>(c?.(String(h(m,e))),!0),e=>(v(e),!1));return g(!1),_?(f(e),o&&y.sent(s),o&&s.length>0&&f(o.resource),!0):!1},busy:m||y.uploading,placeholder:r,searchPeople:i,onDraft:s,...o&&{actions:(0,X.jsx)(oa,{onPick:y.pick,accept:x}),attachments:y.uploads.length>0&&(0,X.jsx)(_a,{uploads:y.uploads,onRemove:y.remove}),canSendEmpty:y.ready,onFiles:y.pick}})]})},ba=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=G(e);return(0,X.jsx)(ya,{resource:t,field:n,values:r,placeholder:i})},xa=({node:e,children:t,className:n})=>{let{open:r}=G(e);return(0,X.jsx)(`details`,{open:r,className:U(`[&[open]>summary]:mb-2`,n),children:t})},Sa=({children:e,className:t})=>(0,X.jsx)(`summary`,{className:U(`cursor-pointer font-medium`,t),children:e}),Ca=({node:e,className:t})=>{let{source:n,emptyText:r}=G(e),i=Tt(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,X.jsx)(A,{className:U(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,X.jsx)(`p`,{className:U(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=xt(a);return o?(0,X.jsx)(`div`,{className:U(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,X.jsx)(Je,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,X.jsx)(`pre`,{className:U(`overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-border bg-background p-3 font-mono text-[0.6875rem] leading-[18px]`,t),children:a})},wa=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),Ta=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>ge(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},Ea=({node:e,className:t})=>{let{source:n,label:r,format:i}=G(e),{views:a}=q(),o=Tt(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,X.jsx)(A,{className:`h-4 w-24`}):o.state===`plain`?wa(o.value):(0,X.jsx)(Me,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,X.jsx)(`div`,{className:t,children:s});let c=r??Ta(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:U(`min-w-0`,t),children:[(0,X.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate`,children:s})]})},Da={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},Oa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ka={1:``,2:`md:col-span-2`,3:`md:col-span-2 xl:col-span-3`,4:`sm:col-span-2 md:col-span-2 xl:col-span-4`},Aa=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ja=({node:e,children:t,className:n})=>{let{columns:r=2}=G(e),i=e.children,a=i.length>0&&i.every(Aa);return(0,X.jsx)(`div`,{className:U(`grid grid-cols-1 gap-4`,a?Oa[r]:Da[r],n),children:t.map((e,t)=>{let n=i[t],r=typeof n==`object`?n.props.span:void 0;return(0,X.jsx)(`div`,{className:U(`min-w-0`,r&&ka[r]),children:e},t)})})},Ma=({src:e,alt:t,width:n,height:r,className:i})=>(0,X.jsx)(`img`,{src:e,alt:t??``,width:n,height:r,className:i??`max-w-full`}),Na=({width:e,height:t,space:n,theme:r})=>{let i=e??Math.ceil(n/100)*100;if(i!==0)return{width:String(i),...t!==void 0&&{height:String(t)},theme:r}},Pa=e=>({staleTime:1/0,refetchOnWindowFocus:!1,...e!==void 0&&{refetchInterval:e*1e3}}),Fa=e=>e instanceof Blob&&e.type.startsWith(`image/`),Ia=e=>{let[t,n]=(0,Y.useState)();return(0,Y.useEffect)(()=>{if(!e)return n(void 0);let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t},La=e=>{let[t,n]=(0,Y.useState)();return[t!==void 0&&t===e,()=>n(e)]},Ra=({name:e,alt:t,width:n,height:r,refresh:i,className:a})=>{let o=Ne(),{theme:s}=He(),[c,l]=et(),u=Na({width:n,height:r,space:l,theme:s}),d=Fn({queryKey:wt.image(e,u??{}),enabled:u!==void 0,placeholderData:Pn,...Pa(i),queryFn:async()=>{let t=await o.invoke(e,{query:u,cache:`no-store`});if(!Fa(t))throw Error(`The function "${e}" answered no picture`);return t}}),f=Ia(d.data),[p,m]=La(f),h={...n!==void 0&&{width:n},...r!==void 0&&{height:r}};return(0,X.jsx)(`div`,{ref:c,className:U(`min-w-0`,a),children:d.isError||p?t&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:t}):f?(0,X.jsx)(`img`,{src:f,alt:t??``,onError:m,style:h,className:n===void 0?`w-full max-w-full object-contain`:`max-w-full object-contain`}):(0,X.jsx)(A,{className:`w-full max-w-full`,style:{height:r??160,...n!==void 0&&{width:n}}})})},za=({node:e,className:t})=>{let n=G(e);return n.src===void 0?(0,X.jsx)(Ra,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,X.jsx)(Ma,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},Ba=e=>function({node:t,className:n}){let r=G(t),{views:i}=q(),a=Tt(r.source);return a.state===`missing`?null:a.state===`loading`?(0,X.jsx)(A,{className:`inline-block h-3 w-16 align-middle`}):Zr(t.type,a.value)?r.emptyText?(0,X.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:a.field,hints:i[a.model.name]?.fields[a.field.name],props:r})})},Va=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?d(e,n?.valueLabels):Qr(e),Ha=Ba(Va),Ua=Ba(({value:e,props:t})=>(0,X.jsx)(`span`,{className:`tabular-nums`,children:$r(e,t,Tn())})),Wa=Ba(({value:e,props:t})=>{let n=ei(e,t,{locale:Tn(),now:Date.now(),relative:St});return(0,X.jsx)(`time`,{dateTime:String(e),children:n})}),Ga=Ba(({value:e,props:t})=>{let n=ti(e,t,{yes:C(`yes`),no:C(`no`)});return e?(0,X.jsx)(Ce,{label:n,className:`align-middle`}):(0,X.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ka=Ba(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=ri(n);return i===void 0?r:(0,X.jsx)(`a`,{href:i,className:`font-medium text-primary-text hover:underline`,.../^https?:/i.test(i)&&{target:`_blank`,rel:`noreferrer`},children:r})}),qa=Ba(e=>(0,X.jsx)(fe,{value:e.value,hints:e.hints,children:Va(e)})),Ja=`font-medium text-primary-text hover:underline`,Ya=({node:e,children:t,className:n})=>{let r=G(e),i={...F(R()),params:an()},a=r.variant?U(p({variant:r.variant}),n):n??Ja,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=Ut(r.to,Ie(i));return(0,X.jsx)(D,{to:e,className:a,children:o??Kt(e)})}let s=r.href??``;return(0,X.jsx)(`a`,{href:s,className:a,...s.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??s})},Xa=(e,t,n)=>Object.fromEntries(t.map(t=>{let r=e.fields[t];if(r.type===`file`)return[t,n?.[t]??null];if(n)return[t,r.type===`boolean`?!!n[t]:me(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:me(i)]})),Za=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let a=e.fields[t];return at(r)?r.key===me(n[t])?[]:[[t,a.type===`integer`?Number(r.key):r.key]]:_n(a,r,n[t])?[[t,i(a,r)]]:[]})),Qa=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:s,onClose:c})=>{let{resources:u,views:d}=q(),f=Ne(),p=ne(),m=vn(),h=d[e.name],[g,_]=(0,Y.useState)(()=>Xa(e,a,t?.record)),[v,y]=(0,Y.useState)({}),[b,x]=(0,Y.useState)(0),S=fn(b),[C,w]=(0,Y.useState)(),[T,E]=(0,Y.useState)(!1),[ee,te]=(0,Y.useState)(!1);_t(ee||T,`input-lost`);let re=async()=>{E(!0),w(void 0),await(n===`create`?f.create(e.name,{...Ye(e,u,g),...s}):f.update(e.name,t.key,Za(e,g,t.record),t.etag??`*`)).then(async()=>{await m(e.name),p.show({state:`success`,title:V(`saved`,{label:i??r})}),c()},e=>{let t=wn(e);y(t),Object.keys(t).length>0&&x(e=>e+1),w(e)}),E(!1)};return(0,X.jsx)(o,{title:i??r,onClose:c,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:c,children:V(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:T,onClick:()=>void re(),children:V(n===`create`?`create`:`save`)})]}),children:(0,X.jsxs)(`form`,{ref:S,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),re()},children:[C!==void 0&&Object.keys(v).length===0&&(0,X.jsx)(l,{title:V(`notSaved`),error:C}),a.map(n=>{let r=e.fields[n],i=g[n],a=r.relation?u[r.relation.resource]:void 0,o=h?.fields[n]?.label??ge(n),s=v[n];return(0,X.jsx)(An,{name:n,label:o,help:h?.fields[n]?.help,error:s&&tt(r,o,s),children:(0,X.jsx)(bn,{field:r,hints:h?.fields[n],value:at(i)?i.key:i,stored:t?.record[n],relationLabel:at(i)?i.label:void 0,relationPicker:a?{target:a,view:d[a.name]}:void 0,invalid:!!v[n],resource:e.name,onChange:e=>{y(({[n]:e,...t})=>t),te(!0),_(t=>({...t,[n]:e}))}})},n)})]})})},$a=({model:e,recordKey:t,children:n})=>{let r=Oe(e,{key:t});return(0,X.jsx)(X.Fragment,{children:n(r.data??void 0)})},eo=({node:e})=>{let t=G(e),n=Dt(),{resources:r}=q(),i=r[t.resource??n?.model.name??``],a=kn(i?.name??``),[o,s]=(0,Y.useState)(!1);if(!i||!(t.mode===`create`?Te(a,`create`):Te(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,X.jsx)(Qa,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,X.jsx)($a,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},to=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=G(e);return(0,X.jsx)(`div`,{className:U(`flex-1`,r),children:(0,X.jsxs)(`div`,{className:U(`flex flex-col gap-6 px-4 pb-16 pt-6 md:px-10 md:py-8`,o!==`full`&&`mx-auto max-w-[1200px]`),children:[(0,X.jsx)(xr,{title:i,subtitle:a,actions:n.actions}),t]})})},no=(e,t)=>{let n=R(),r=typeof e==`string`?Jt(n,e):void 0,i=qt(r&&`frame`in r?r.frame:void 0,r&&`path`in r?r.path:``);return typeof e==`number`?e:e===void 0?t:r&&`item`in r?Number(r.item):i.state===`ready`?Number(i.value):i.state===`loading`?void 0:NaN},ro=({node:e,className:t})=>{let{value:n,max:r,label:i}=G(e),a=no(n,0),o=no(r,100);if(a===void 0||o===void 0)return(0,X.jsx)(A,{className:`h-6 w-full`});if(!Number.isFinite(a)||!Number.isFinite(o))return null;let s=o>0?Math.min(1,Math.max(0,a/o)):0;return(0,X.jsxs)(`div`,{className:U(`min-w-0`,t),children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[a.toLocaleString(Tn()),` / `,o.toLocaleString(Tn())]})]}),(0,X.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":o,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:s>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${s*100}%`}})})]})},io=({model:e,at:t,filter:n,sort:r,recordKey:i,title:a,description:o,empty:s,actions:c,children:u,className:d})=>{let f=nn(t),p=Oe(e,{filter:n,sort:r,key:i,enabled:!f}),m=f?En(e,f):p,h=e=>m.data?(0,X.jsx)(dt,{value:m.data,children:e}):void 0,g=m.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(A,{className:`h-4 w-1/2`}),(0,X.jsx)(A,{className:`h-4 w-1/3`})]}):m.error?(0,X.jsx)(l,{title:V(`couldNotLoad`),error:m.error}):m.data?h((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:u})):(0,X.jsx)(j,{children:s??V(`nothingYet`)});return(0,X.jsx)(J,{title:a,description:o,actions:c?h(c):void 0,className:U(`h-full`,d),children:g})},ao=({node:e,at:t,children:n,slots:r,className:i})=>{let{resource:a,filter:o,sort:s,recordKey:c,title:l,description:u,empty:d}=G(e),f=q().resources[a];return f?(0,X.jsx)(io,{model:f,...t!==void 0&&{at:t},filter:o,sort:s,recordKey:c,title:l,description:u,empty:d,actions:r.actions,className:i,children:n}):null},oo=vt(`app/related-cards`),so=({children:e})=>{let t=(0,Y.useRef)(null),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,Y.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=()=>a(e.scrollHeight>e.parentElement.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[n]),(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,X.jsx)(`div`,{className:U(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,X.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,X.jsx)(M,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:oo(n?`showLess`:`showMore`)})]})},co=e=>e==null||e===``,lo=({scope:e,path:t,labelled:n=!0,clamped:r=!1})=>{let{views:i}=q(),a=qt(e,t);if(a.state===`missing`||a.state===`ready`&&co(a.value))return null;let o=a.state===`loading`?(0,X.jsx)(A,{className:`h-4 w-24`}):(0,X.jsx)(Me,{model:a.model,field:a.field,value:a.value}),s=r?(0,X.jsx)(so,{children:o}):o;if(!n)return(0,X.jsx)(`div`,{className:`min-w-0`,children:s});let c=Ta(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`dd`,{className:`mt-0.5`,children:s})]})},uo=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:s})=>{let c=Ge(),{resources:l}=q(),u=c(e.model,t,e.record,e.key),d=a.length>0||o!==void 0;return(0,X.jsxs)(`li`,{"data-card":e.key,className:U(`relative grid min-w-0 items-center gap-x-4 gap-y-1 rounded-lg border border-border bg-surface px-4 py-2.5`,d?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:[i&&(0,X.jsx)(pt,{view:t,field:i,record:e.record}),(0,X.jsxs)(`div`,{className:U(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,X.jsx)(D,{to:{kind:`record`,resource:e.model.name,key:h(e.model,e.record)},className:`line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere] text-primary-text hover:underline`,children:u}),r&&(0,X.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,X.jsx)(lo,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-y-0.5 text-body text-muted-foreground`,children:n.map(t=>(0,X.jsx)(`div`,{className:`flex max-w-full min-w-0 items-center whitespace-nowrap empty:hidden [&>div]:truncate [:not(:empty)~&]:before:mx-2 [:not(:empty)~&]:before:content-['·'_/_'']`,children:(0,X.jsx)(lo,{scope:e,path:t,labelled:!1})},t))}),d&&(0,X.jsx)(dt,{value:e,children:(0,X.jsxs)(`div`,{className:`col-start-2 flex flex-wrap items-center justify-end gap-2 sm:row-span-2 sm:row-start-1`,children:[o&&(0,X.jsx)(mr,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,X.jsx)(li,{name:e,about:u,onRun:e=>s?.(e,u)},e))]})})]})},fo=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let s=Ge(),{resources:c}=q(),l=s(e.model,t,e.record,e.key);return(0,X.jsxs)(`li`,{"data-card":e.key,className:`relative flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[r&&(0,X.jsx)(pt,{view:t,field:r,record:e.record}),(0,X.jsx)(D,{to:{kind:`record`,resource:e.model.name,key:h(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:l}),n.length>0&&(0,X.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,X.jsx)(lo,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,X.jsx)(dt,{value:e,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,X.jsx)(mr,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,X.jsx)(li,{name:e,about:l,onRun:e=>o?.(e,l)},e))]})})]})},po=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,mo=e=>[...e.querySelectorAll(`button`)].find(po)??e.querySelector(`a`),ho=(e,t,n)=>{let r=e.indexOf(n),i=e=>t.includes(e);return e.slice(r+1).find(i)??e.slice(0,Math.max(r,0)).findLast(i)},go=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},_o=e=>{let t=(0,Y.useRef)(null),n=(0,Y.useRef)({current:e,previous:e}),r=(0,Y.useRef)(void 0),[i,a]=(0,Y.useState)(``),o=(e,n,i)=>{if(r.current=void 0,i.includes(e.key)||!t.current||(a(oo(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=ho(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?mo(s):go(t.current))?.focus()};return(0,Y.useEffect)(()=>{let t=n.current.current;n.current={current:e,previous:t},r.current&&o(r.current,t,e)},[e]),{root:t,acted:(e,t,i)=>{let{current:a,previous:s}=n.current;if(a.includes(e)){r.current={key:e,action:t,title:i};return}o({key:e,action:t,title:i},s,a)},announcement:i}},vo=({compact:e,limit:t})=>(0,X.jsx)(`div`,{className:e?`flex flex-col gap-2`:`flex flex-col gap-3`,children:Array.from({length:e?Math.min(t,3):2},(t,n)=>(0,X.jsx)(A,{className:e?`h-17.5 w-full max-sm:h-24`:`h-24 w-full`},n))}),yo=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,button:o,limit:s,display:u,empty:d,carousel:f,compact:p,tone:m,planned:h})=>{let g=Ht(),_=hr(),v=t?.names?.plural??ge(e.name),y=r||At(e,t),b=c(e,{filter:n,sort:y,pageSize:s,enabled:!h}),x=xn(e,n,!h),S=h?h.rows:{isPending:b.isPending,error:b.error},C=h?h.rows.rows:b.data?.items,w=h?{data:h.total&&!h.total.isPending&&!h.total.error?cr(h.total):void 0}:x,T=(0,Y.useMemo)(()=>(C??[]).map(t=>rt(e,t)),[e,C]),E=_o((0,Y.useMemo)(()=>T.map(e=>e.key),[T]));return(0,X.jsxs)(`div`,{ref:E.root,children:[(()=>{if(S.isPending)return(0,X.jsx)(vo,{compact:!!p,limit:s});if(S.error)return(0,X.jsx)(l,{title:oo(`couldNotLoad`),error:S.error});if(T.length===0)return(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:d??oo(`nothingYet`)});let r=T.map(e=>{let n=(t,n)=>E.acted(e.key,t,n);return p?(0,X.jsx)(uo,{scope:e,view:t,fields:i,time:p.time,tone:m,actions:a,button:o,onActed:n},e.key):(0,X.jsx)(fo,{scope:e,view:t,fields:i,tone:m,actions:a,button:o,onActed:n},e.key)}),c=w.data===void 0?void 0:Zn(T.length,w.data,!1);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f===void 0?(0,X.jsx)(`ul`,{className:p?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,X.jsx)(Qn,{scroll:_,label:v,share:f,children:r}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c}),(0,X.jsxs)(D,{to:ur(e,t,g,{filter:n,orderBy:y,display:dr(t,g,{preferred:u})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[ar(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:v.toLowerCase()}),(0,X.jsx)(nr,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:E.announcement})]})},bo={"1/4":1/4,"1/3":1/3,"1/2":1/2,"2/3":2/3},xo=({node:e,at:t,slots:n,className:r})=>{let i=G(e),{resource:a,filter:o=``,sort:c=``,fields:l,cardActions:u=[],limit:d=10,display:f,title:p,description:m,empty:h}=i,{layout:g,cardWidth:_}=ii(i),{resources:v,views:y}=q(),[b,x]=st([t,t===void 0?void 0:`${t}#total`]),S=(0,Y.useMemo)(()=>b&&{rows:b,total:x},[b,x]),C=v[a];if(!C)return null;let w=y[C.name];return(0,X.jsx)(`section`,{className:U(`min-w-0`,r),"aria-label":p,children:(0,X.jsx)(T,{title:p,help:m,actions:n.actions,children:(0,X.jsx)(yo,{model:C,view:w,filter:o,sort:c,fields:l??s(C,w),actions:u,limit:d,display:f,empty:h,carousel:g===`carousel`?bo[_]:void 0,...S&&{planned:S}})})})},So=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=q(),o=Ve(i,a,e.name),s=Vn(e.name,t.listOf,!0),c=(t.names?.plural??ge(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,X.jsx)(l,{title:Ln(`couldNotLoadYour`,{plural:c}),error:s.error});if(!s.data)return(0,X.jsx)(A,{className:`h-24`});let u=rr(o.model,s.data);return u?(0,X.jsx)(_r,{...r,model:o.model,view:o.view,filter:``,scope:u,list:e.name,empty:n}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??Ln(`noneYet`,{plural:c})})},Co=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=ce(h(e,i)),{name:o,chips:s,title:c,body:l}=yr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,X.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,X.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,X.jsx)(D,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,X.jsx)(Kn,{chips:s})})}),(0,X.jsx)(_r,{...l})]})},wo=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=q(),a=t.searchesOf,o=r[a.resource],s=Xn(e.name,!0),c=(t.names?.plural??ge(e.name)).toLowerCase();return o?s.error?(0,X.jsx)(l,{title:qn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??qn(`noneYet`,{plural:c})}):(0,X.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,X.jsx)(Co,{model:e,view:t,target:o,targetView:i[a.resource],row:n},ce(h(e,n))))}):(0,X.jsx)(A,{className:`h-40`}):null},To=({node:e,slots:t,className:n})=>{let{resource:r,filter:i=``,sort:a,limit:o,display:s,title:c,description:l,empty:u}=G(e),{resources:d,views:f}=q(),p=d[r];if(!p)return null;let m=f[p.name];return(0,X.jsx)(J,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,X.jsx)(wo,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,X.jsx)(_r,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,X.jsx)(So,{model:p,view:m,limit:o,display:s,empty:u})})},Eo=e=>e.type===`boolean`||e.type===`enum`,Do=({model:e,fields:t,title:n,description:r,stored:i,className:a})=>{let{resources:o,views:s}=q(),c=kn(e.name),u=Ne(),d=ne(),f=vn(),p=s[e.name],[m,h]=(0,Y.useState)(i),[g,_]=(0,Y.useState)(()=>Xa(e,t,i?.record)),[v,y]=(0,Y.useState)({}),[b,x]=(0,Y.useState)(),[S,C]=(0,Y.useState)(!1),w=(0,Y.useRef)(Promise.resolve()),T=(0,Y.useRef)(i),E=Xa(e,t,void 0),ee=m?Te(c,`update`)&&m.permissions?.update!==!1:Te(c,`create`),te=t.filter(t=>!Eo(e.fields[t])),re=te.some(t=>m?_n(e.fields[t],g[t],m.record[t]):g[t]!==E[t]),ie=async t=>{let n=T.current;if(n){let r=await u.update(e.name,n.key,Za(e,t,n.record),n.etag??`*`);return{...rt(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await u.create(e.name,Ye(e,o,{...E,...t}));return{...rt(e,r.record),etag:r.etag}},D=t=>{let r=w.current.then(async()=>{C(!0),x(void 0),await ie(t).then(async r=>{T.current=r,h(r),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await f(e.name),d.show({state:`success`,title:V(`saved`,{label:n??V(`settings`)})})},e=>{y(t=>({...t,...wn(e)})),x(e)}),C(!1)});w.current=r},ae=(t,n)=>{_(e=>({...e,[t]:n})),Eo(e.fields[t])&&D({[t]:n})};return(0,X.jsx)(J,{title:n,description:r,className:U(`h-full`,a),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),re&&D(Object.fromEntries(te.map(e=>[e,g[e]])))},children:[b!==void 0&&Object.keys(v).length===0&&(0,X.jsx)(l,{title:V(`notSaved`),error:b}),t.map(t=>{let n=e.fields[t],r=p?.fields[t]?.label??ge(t),i=v[t];return(0,X.jsx)(An,{name:t,label:r,help:p?.fields[t]?.help,error:i&&tt(n,r,i),children:(0,X.jsx)(bn,{field:n,hints:p?.fields[t],value:g[t],stored:m?.record[t]??E[t],invalid:!!i,locked:!ee||n.readOnly,resource:e.name,onChange:e=>ae(t,e)})},t)}),ee&&re&&(0,X.jsx)(`div`,{children:(0,X.jsx)(M,{type:`submit`,variant:`primary`,size:`sm`,loading:S,children:V(`save`)})})]})})},Oo=e=>{let t=Oe(e.model,{});return t.isPending?(0,X.jsx)(J,{title:e.title,description:e.description,className:e.className,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(A,{className:`h-4 w-1/2`}),(0,X.jsx)(A,{className:`h-4 w-1/3`})]})}):t.error?(0,X.jsx)(J,{title:e.title,description:e.description,className:e.className,children:(0,X.jsx)(l,{title:V(`couldNotLoad`),error:t.error})}):(0,X.jsx)(Do,{...e,stored:t.data??void 0})},ko=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=G(e),o=q().resources[n];return o?(0,X.jsx)(Oo,{...a,model:o,fields:r.filter(e=>Object.hasOwn(o.fields,e)),stored:void 0,className:t}):null},Ao=(e,t)=>jo(e,t?[t]:[]),jo=(e,t)=>{let{resources:n}=q(),i=Ne(),a=JSON.stringify(e),o=(0,Y.useMemo)(()=>JSON.parse(a).map(ft),[a]),s=e=>t.some(t=>`item`in t?typeof t.item==`object`&&t.item!==null&&Object.hasOwn(t.item,e):Object.hasOwn(t.model.fields,e)),c=[...new Set(o.flatMap(e=>e.ok?e.paths:[]))],l=new Map(c.flatMap(e=>{let t=we(e,s);return t===void 0?[]:[[e,t]]})),u=c.filter(e=>!l.has(e)),d=[...new Set(l.values())].flatMap(e=>n[e]?[n[e]]:[]),f=u.map(e=>Jt(t,e)),p=Rt(u.map((e,t)=>{let n=f[t];return n&&`frame`in n?{scope:n.frame,path:n.path}:{scope:void 0,path:e}})),m=In({queries:d.map(e=>yt(i,e))});return o.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=l.get(n);if(e===void 0){let e=u.indexOf(n),r=f[e];if(r&&`item`in r){t[n]=r.item;continue}let i=p[e];if(i.state===`loading`)return;i.state===`ready`&&(t[n]=i.value);continue}let r=d.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(m[r].isPending)return;else t[n]=m[r].data??0}return r(e,t)})},Mo=(e,t)=>typeof e.props.fallback==`string`?e.props.fallback:t.fallback,No=({node:e,children:t,slots:n,className:r})=>{let{when:i}=G(e),[a]=jo([i],R());if(a===void 0)return null;let o=a?t:Mo(e,n);return o==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:o}):(0,X.jsx)(`div`,{className:r,children:o})},Po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(w(e,F(t)).props.when)]),Fo=({node:e,children:t,slots:n,className:r})=>{let i=R(),a=jo(Po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?Mo(e,n):t[o];return s==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:s}):(0,X.jsx)(`div`,{className:r,children:s})},Io=({children:e})=>(0,X.jsx)(X.Fragment,{children:e}),Lo=`text-2xl font-semibold tracking-tight tabular-nums`,Ro=({model:e,at:t,filter:n})=>{let{views:r}=q(),i=nn(t),a=xn(e,n,!i),o=i??a;if(o.isPending)return(0,X.jsx)(A,{className:`h-8 w-16`});if(o.error)return(0,X.jsx)(`span`,{className:`text-danger-text`,children:V(`couldNotCount`)});let s=i?cr(i):a.data;return(0,X.jsx)(D,{to:or(r[e.name],e.name,n),className:`${Lo} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:s.toLocaleString(Tn())})},zo=({field:e,format:t})=>{let n=Tt(e);return n.state===`loading`?(0,X.jsx)(A,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,X.jsx)(`span`,{className:Lo,children:wa(n.value)}):(0,X.jsx)(`span`,{className:Lo,children:(0,X.jsx)(Me,{model:n.model,field:n.field,value:n.value,format:t})})},Bo=({node:e,at:t,className:n})=>{let{label:r,value:i,resource:a,filter:o,field:s,format:c,description:l}=G(e),{resources:u}=q(),d=a===void 0?void 0:u[a];return(0,X.jsxs)(J,{className:U(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,X.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,X.jsx)(`span`,{className:Lo,children:i}),d&&(0,X.jsx)(Ro,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,X.jsx)(zo,{field:s,format:c})]}),l&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},Vo=(e,t,n)=>{let r=Ht(),i=tr(t),[a,o]=(0,Y.useState)(()=>Yn(localStorage,i)),s=(0,Y.useCallback)(e=>{o(e),fr(localStorage,i,e)},[i]);return[dr(e,r,{picked:a,preferred:n}),s]},Ho=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:c,className:l})=>{let{resources:u,views:d}=q(),f=d[e.name],{fields:p}=y(),m=Te(kn(e.name),`update`),{go:h,href:g}=Xt(),_=Ht(),v=!cn(),b=(0,Y.useMemo)(()=>n?.map(Zt)??s(e,f),[n,e,f]),x=(0,Y.useMemo)(()=>mt(e,f,b,{resources:u,views:d,fieldTypes:p}),[e,f,b,u,d,p]),S=(0,Y.useMemo)(()=>_?It(n)(x):x,[_,n,x]),C=(0,Y.useMemo)(()=>r?ir(S,e,f,r,u,v):S,[S,e,f,r,u,v]),w=(0,Y.useMemo)(()=>t.map(t=>({...t,id:ye(e,t)})),[t,e]),T=(0,Y.useMemo)(()=>({total:w.length,rowAt:e=>w[e]}),[w]),E=lr({model:e,view:f,opens:void 0,resources:u,views:d,canUpdate:m}),ee=e=>({href:g(e),onFollow:()=>h(e)});return(0,X.jsx)(J,{title:i,description:a,actions:c,className:l,children:w.length===0?(0,X.jsx)(j,{children:o??V(`nothingYet`)}):(0,X.jsx)(Un,{fit:!0,columns:C,source:T,latencyMs:0,onOpenRow:e=>h(E.address(e)),rowLink:e=>ee(E.address(e)),rowActions:E.actions(ee),rowNumbers:!1,selectable:!1})})},Uo=e=>{let t=it();return t?.model?(0,X.jsx)(Ho,{...e,model:t.model,items:t.items}):null},Wo=({model:e,view:t,filter:n=``,sort:r=``,columns:i,button:a,bulk:o,limit:s=10,display:c,title:l,description:u,empty:d,actions:f,className:p,chosen:m,planned:h})=>{let[g,_]=Vo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?Ue:g,y=(0,Y.useMemo)(()=>i?.map(Zt),[i]),b=(0,Y.useMemo)(()=>It(i),[i]);return(0,X.jsxs)(J,{title:l,description:u,actions:(0,X.jsxs)(X.Fragment,{children:[!m&&(0,X.jsx)(pr,{view:t,value:v,onChange:_}),f]}),className:U(`h-full`,p),children:[(0,X.jsx)(sr,{model:e,view:t,filter:n,sort:r,columns:y,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:b,...m&&{rowTo:m.rowTo,chosenKey:m.key},...h&&{planned:h}}),m?.details]})},Go=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,children:c,...l}=G(e),{resources:u,views:d}=q(),[f,p]=st([t,t===void 0?void 0:`${t}#total`]),m=(0,Y.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,X.jsx)(Uo,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,X.jsx)(Wo,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,X.jsx)(Ko,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},Ko=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=lt(),a=t=>i({[e]:t}),o=r[e],s=o===void 0?null:(0,X.jsx)(pn,{name:e,children:(0,X.jsx)(_i,{model:n.model,query:{key:o},children:t},o)});return(0,X.jsx)(Wo,{...n,chosen:{rowTo:a,key:o,details:s}})},qo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=a(),{navigate:o}=qe(),s=Mt(e),c=he(s,r),l=e=>i(e===s[0]?.name?void 0:e);return(0,X.jsxs)(`div`,{className:U(`flex flex-col gap-6`,n),children:[(0,X.jsxs)(`select`,{"aria-label":V(`tabs`),value:c?.name??``,onChange:e=>o(l(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!c&&(0,X.jsx)(`option`,{value:``,disabled:!0}),s.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,X.jsx)(`nav`,{"aria-label":V(`tabs`),className:`hidden border-b md:block`,children:(0,X.jsx)(`ul`,{className:`flex gap-1`,children:s.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Ct,{to:l(e.name),"aria-current":e===c?`page`:void 0,className:U(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===c?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),c?(0,X.jsx)(Y.Fragment,{children:t[s.indexOf(c)]},c.name):(0,X.jsx)(rn,{children:V(`noTab`,{name:r??``})})]})},Jo=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Yo=e=>e===void 0?1/0:Date.parse(e),Xo=(e,t)=>{let n=e=>e.more&&e.items.length>0?Yo(e.items.at(-1).time):-1/0,r=Math.max(n(e),n(t)),i=[],a=0,o=0;for(;a<e.items.length||o<t.items.length;){let n=o>=t.items.length||a<e.items.length&&Yo(e.items[a].time)>=Yo(t.items[o].time)?e.items[a++]:t.items[o++];if(Yo(n.time)<r)break;i.push(n)}return i},Zo=({value:e,hints:t,mark:n})=>{let r=d(e,t?.valueLabels);return n===`done`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(sn,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(u,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&Pt(t?.valueColors,e)!==`red`?r:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,X.jsx)(br,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},Qo=({value:e})=>{let t=typeof e==`string`?Pe(e):e;return t===Re?(0,X.jsx)(ie,{children:String(e)}):(0,X.jsx)(x,{value:t})},$o=({label:e,children:t})=>(0,X.jsxs)(`div`,{className:`grid gap-1`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),es=({call:e,statusHints:t})=>{let[n,r]=(0,Y.useState)(!1),i=(0,Y.useId)(),a=e.status!==void 0&&(0,X.jsx)(Zo,{value:e.status,hints:t,mark:e.state}),o=(0,X.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:e.name}),s=e.input!==void 0||e.result!==void 0||e.error!==void 0;return(0,X.jsxs)(`div`,{"data-tool-call":!0,className:`flex min-w-0 flex-col gap-1 pl-11 text-xs text-muted-foreground`,children:[s?(0,X.jsxs)(M,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,X.jsx)(Se,{"aria-hidden":!0,className:U(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,X.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,X.jsx)($o,{label:Q(`callInput`),children:(0,X.jsx)(Qo,{value:e.input})}),e.result!==void 0&&(0,X.jsx)($o,{label:Q(`callResult`),children:(0,X.jsx)(Qo,{value:e.result})}),e.error!==void 0&&(0,X.jsx)($o,{label:Q(`callError`),children:(0,X.jsx)(ie,{children:e.error})})]})]})},ts=(e,t)=>e.map(e=>({kind:`message`,row:e,time:typeof e[t]==`string`?e[t]:void 0})),ns=e=>{if(typeof e==`object`&&e&&`id`in e){let{id:t,name:n}=e;return{id:String(t),...typeof n==`string`&&{name:n}}}return{id:String(e??``),...typeof e==`string`&&{name:e}}},rs=(e,{key:t,sender:n,text:r,status:i},a=Date.now())=>{let o=[],s;for(let c of[...e].reverse()){let e=c.time,l=s?.time!==void 0&&e!==void 0&&te(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:v(e,a)}),c.kind===`call`){o.push(c),s={author:void 0,time:e};continue}let{row:u}=c,d=n===void 0?void 0:ns(u[n]),f=d?.id??``,p=i===void 0||u[i]==null||u[i]===``?void 0:String(u[i]);o.push({kind:`message`,key:t(u),...d&&{author:d},time:e,text:u[r]==null?``:String(u[r]),...p!==void 0&&{status:p},continued:l&&s?.author===f}),s={author:f,time:e}}return o},is=e=>qr.includes(e??``)?e:void 0,as=e=>e==null||e===``?void 0:String(e),os=e=>`call:${JSON.stringify(e)}`,ss=(e,t,n)=>{let r=as(e[n.status]),i=is(r),a=n.input===void 0?void 0:e[n.input],o=n.result===void 0?void 0:e[n.result],s=n.error===void 0?void 0:as(e[n.error]);return{kind:`call`,key:t,name:String(e[n.name]??``),time:typeof e[n.time]==`string`?e[n.time]:void 0,...r!==void 0&&{status:r},...i!==void 0&&{state:i},...a!=null&&{input:a},...o!=null&&{result:o},...s!==void 0&&{error:s}}},cs=({planned:e,limit:t,expanded:n,expand:r,own:i})=>{if(!e)return i;let a=n&&!i.error&&i.pages<2&&(i.pages===0||i.hasNextPage),o={items:e.rows,labels:e.labels??{},hasNextPage:e.rows.length>=t,isFetchingNextPage:a,isFetchNextPageError:!1,isLoading:e.isPending};return n&&i.error&&i.pages===0?{...o,error:i.error,fetchNextPage:i.refetch,refetch:i.refetch}:n&&!a?i:{...o,error:e.error,fetchNextPage:r,refetch:r}},ls=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,Y.useState)(!1),s=Fe(e,{...r,pageSize:t,enabled:n&&(!i||a)}),c=s.data?.pages.length??0,{hasNextPage:l,isFetchingNextPage:u,fetchNextPage:d,error:f}=s;return(0,Y.useEffect)(()=>{i&&a&&!f&&c===1&&l&&!u&&d()},[i,a,f,c,l,u,d]),cs({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},us=(e,t,n)=>{let{views:r}=q(),i=e?.model.name??``,a=ls(i,{filter:e?.filter,orderBy:e&&Ot(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>ss(t,os(h(e.model,t)),e.fields)),hasNextPage:a.hasNextPage,isFetchingNextPage:a.isFetchingNextPage,list:a,statusHints:r[i]?.fields[e.fields.status]}:{calls:[],hasNextPage:!1,isFetchingNextPage:!1,list:a,statusHints:void 0}},ds=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,fs=(e,t)=>e.isLoading?t.loading:t.empty,ps=e=>e.items.length>0&&!!e.error,ms=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),hs=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},gs=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:u,planned:d})=>{let{resources:f,views:p}=q(),m=ee(),g=m?.state.kind===`signed-in`?m.state.user.id:void 0,_=n===void 0?[]:[n],v=$t(f,p,e,_),y=ls(e.name,{filter:t,orderBy:Ot(r),pageSize:o,labels:v},d?.messages),b=us(u,o,d?.calls),x=ds(y);if(x===`error`)return(0,X.jsx)(l,{title:Q(`couldNotLoad`),error:y.error,onRetry:ms(y)});if(x===`loading`)return(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(j,{children:Q(`loadingMessages`)})});let S=kt(f,e,_,y.items,y.labels),C=Xo({items:b.calls,more:b.hasNextPage},{items:ts(S,r),more:y.hasNextPage}),w=rs(C,{key:t=>String(h(e,t)),sender:n,time:r,text:i,status:a}),T=a===void 0?void 0:p[e.name]?.fields[a],E=e.fields[i]!==void 0&&jt(e.fields[i],p[e.name]?.fields[i]),te=w.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===g);return(0,X.jsxs)(X.Fragment,{children:[ps(y)&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(l,{title:Q(`couldNotLoad`),error:y.error,onRetry:ms(y)})}),u&&b.list.error&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(l,{title:Q(`couldNotLoadCalls`),error:b.list.error,onRetry:ms(b.list)})}),(0,X.jsx)(ue,{length:C.length,followKey:te?.key,working:c,empty:fs(b.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:y.hasNextPage||b.hasNextPage?()=>hs([y,b.list]):void 0,loadingEarlier:y.isFetchingNextPage||b.isFetchingNextPage,children:w.map(e=>e.kind===`day`?(0,X.jsx)(xe,{label:e.label},e.key):e.kind===`call`?(0,X.jsx)(es,{call:e,statusHints:b.statusHints},e.key):(0,X.jsx)(pe,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,X.jsx)(Zo,{value:e.status,hints:T}),children:E&&e.text!==``?(0,X.jsx)(le,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},_s=({children:e})=>(0,X.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),vs=({node:e,at:t,slots:n,className:r})=>{let{title:i,description:a,resource:o,filter:s,sender:c,time:l,text:u,status:d,working:f,calls:p,limit:m,empty:h}=G(e),{resources:g}=q(),[_]=jo(f===void 0?[]:[f],R()),[v,y]=st([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let x=p&&g[p.resource];return(0,X.jsx)(`section`,{className:U(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,X.jsx)(T,{title:i,help:a,actions:n.actions,children:(0,X.jsx)(_s,{children:(0,X.jsx)(gs,{model:b,filter:s,sender:c,time:l,text:u,status:d,calls:p&&x&&{model:x,filter:p.filter,fields:p},limit:m,empty:h,working:f===void 0?void 0:_===!0,...(v||y)&&{planned:{messages:v,calls:y}}})})})})},ys=({children:e,className:t})=>(0,X.jsx)(`div`,{className:t,children:e}),bs=({children:e,className:t})=>(0,X.jsx)(`div`,{className:U(`flex`,t),children:e}),xs=({children:e,className:t})=>(0,X.jsx)(`div`,{className:U(`flex flex-col`,t),children:e}),Ss=({node:e,children:t,className:n})=>{let{as:r=`p`}=G(e);return(0,X.jsx)(r,{className:n,children:t})},Cs=({node:e,children:t})=>{let{source:n}=G(e),r=ze(F(R()),n),i=(0,Y.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,X.jsx)(gn,{value:i,children:t})},ws=({node:e,className:t})=>{let{source:n,choices:r,label:i=n,defaultValue:a}=G(e),{values:o,linkTo:s}=lt(),c=o[n];return(0,X.jsxs)(`div`,{className:U(`flex flex-wrap items-center gap-2`,t),children:[(0,X.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:i}),r?(0,X.jsx)(Le,{label:i,value:c??``,options:r.map(e=>({value:String(e.id),label:e.name})),link:e=>s({[n]:a!==void 0&&e===String(a)?void 0:e})}):(0,X.jsx)(`span`,{children:c})]})},Ts=({model:e,filter:t,perPage:n,more:r,planned:i,expanded:a,expand:o,own:s})=>{if(t===void 0)return{read:{isPending:!1,error:null},list:{model:e,items:[]}};if(i&&!a){let t=i.rows.slice(0,n),a=r&&t.length===n?o:void 0;return{read:i,list:{model:e,items:t,planned:!0,...a&&{loadMore:a}}}}if(i&&!s.error&&s.pages<2&&(s.pages===0||s.hasNextPage))return{read:i,list:{model:e,items:i.rows.slice(0,n),planned:!0,loadMore:()=>{},loadingMore:!0}};let c=r&&s.hasNextPage?()=>void s.fetchNextPage():void 0;return{read:{isPending:s.isPending,error:s.error},list:{model:e,items:s.items,...c&&{loadMore:c,loadingMore:s.isFetchingNextPage}}}},Es=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,Y.useState)(!1),c=Fe(e.name,{filter:t,orderBy:n,pageSize:r,enabled:t!==void 0&&(!a||o)}),l=c.data?.pages.length??0,{hasNextPage:u,isFetchingNextPage:d,fetchNextPage:f,error:p}=c;return(0,Y.useEffect)(()=>{a&&o&&!p&&l===1&&u&&!d&&f()},[a,o,p,l,u,d,f]),Ts({model:e,filter:t,perPage:r,more:i,planned:a,expanded:o,expand:()=>s(!0),own:{pages:l,items:c.items,hasNextPage:u,isFetchingNextPage:d,isPending:c.isPending,error:p,fetchNextPage:f}})},Ds=({node:e,at:t,children:n})=>{let r=G(e),i=q().resources[r.reference],a=Ie(F(R())),o=nn(t);return i?(0,X.jsx)(Os,{model:i,...We(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},Os=({empty:e,children:t,...n})=>{let{read:r,list:i}=Es(n);return(0,X.jsx)(On,{read:r,list:i,empty:e,children:t})},ks=({node:e,at:t,children:n})=>{let r=G(e),i=q().resources[r.reference],a=Ie(F(R())),o=nn(t);return i?(0,X.jsx)(Os,{model:i,...re(r,i.primaryKey[0],a),more:!1,empty:r.empty,...o&&{planned:o},children:n}):null},As=({model:e,at:t,recordKey:n,link:r=`edit`,children:i,className:a})=>{let{views:o}=q(),s=nn(t),c=Oe(e,{key:n,enabled:!s}),u=s?En(e,s):c;if(u.isPending)return(0,X.jsx)(A,{className:`h-4 w-24`});if(u.error)return(0,X.jsx)(l,{title:V(`couldNotLoad`),error:u.error});if(!u.data)return null;let d=i.length>0?(0,X.jsx)(dt,{value:u.data,children:i}):je(e,o[e.name],u.data.record,n);return r===!1?(0,X.jsx)(`span`,{className:a,children:d}):(0,X.jsx)(D,{to:{kind:`record`,resource:e.name,key:n},className:a??`font-medium text-primary-text hover:underline`,children:d})},js=({node:e,at:t,children:n,className:r})=>{let{reference:i,source:a,link:o,empty:s}=G(e),c=q().resources[i],l=ze(F(R()),a);return c?l==null||l===``?s===void 0?null:(0,X.jsx)(`span`,{className:r,children:s}):(0,X.jsx)(As,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},Ms=(e,t)=>t.map(t=>Et(e,t)).join(`, `),$=vt(`users`),Ns=({roles:e})=>{let{session:t}=_(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)([]),o=(0,Y.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,Y.useEffect)(o,[o]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Sr,{title:$(`inviteSomeone`),description:$(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,X.jsx)(wr,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,X.jsx)(K,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,X.jsx)(Cr,{email:n.email,gives:Ms(e,n.roles),expiresAt:n.expiresAt,onResend:async()=>{let e=await t.users.invite({email:n.email,roles:n.roles});return o(),e},onRevoke:async()=>{await t.users.revoke(n.id),o()}},n.id))})})]})},Ps=({roles:e,onCreated:t})=>{let{session:n}=_(),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)([]),{busy:d,error:f,run:p}=ct(),m=()=>p(async()=>{await n.users.create({email:r.trim(),name:a.trim(),roles:l,...s&&{password:s}}),i(``),o(``),c(``),u([]),t()}),h=!r.trim()||!a.trim()||l.length===0||s!==``&&s.length<12;return(0,X.jsxs)(K,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,X.jsx)(L,{message:f}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,X.jsx)(N,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,X.jsx)(N,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,X.jsx)(N,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(wr,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,X.jsx)(`div`,{children:(0,X.jsx)(M,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},Fs=({user:e,roles:t,self:n})=>{let{session:r}=_(),[i,a]=(0,Y.useState)(e),{busy:o,error:s,run:c,setError:l}=ct(),u=e=>{if(e.length===0)return l($(`keepOneRole`));c(async()=>{await r.users.setRoles(i.id,e),a({...i,roles:e})})},d=e=>void c(async()=>{await(e?r.users.block(i.id):r.users.unblock(i.id)),a({...i,blocked:e})});return(0,X.jsx)(Tr,{name:i.name,email:i.email,self:n,error:s,actions:(0,X.jsxs)(X.Fragment,{children:[i.blocked&&(0,X.jsx)(H,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,X.jsx)(M,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,X.jsx)(M,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,X.jsx)(wr,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},Is=({roles:e,version:t})=>{let{session:n,state:r}=_(),[i,a]=(0,Y.useState)(``),o=(0,Y.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=Dr(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,X.jsx)(Er,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,X.jsx)(Fs,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},Ls=()=>{let{session:e}=_(),[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)();return(0,Y.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof k?z(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},Rs=()=>{let{roles:e,error:t}=Ls(),[n,r]=(0,Y.useState)(0);return(0,X.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,X.jsx)(L,{message:t}),(0,X.jsx)(Is,{roles:e,version:n}),(0,X.jsx)(Ns,{roles:e}),(0,X.jsx)(Ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},zs=()=>(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(ht,{message:O(`checkUnavailable`)})}),Bs=(e,t)=>t.status===`waiting`?(0,X.jsx)(ht,{message:O(`checkWaiting`,{address:e})}):t.status===`confirmed`?(0,X.jsx)(ht,{message:O(`checkConfirmed`,{address:e})}):t.status===`mismatch`?(0,X.jsx)(L,{message:O(`checkMismatch`,{address:e,from:t.from})}):t.status===`timed_out`?(0,X.jsx)(ht,{message:O(`checkTimedOut`)}):null,Vs=({address:e,state:t,error:n,onCheck:r})=>{if(t.status===`unchecked`)return(0,X.jsx)(zs,{});let i=t.status===`waiting`;return(0,X.jsxs)(`div`,{className:`mt-4`,children:[Bs(e,t),(0,X.jsx)(L,{message:n}),(0,X.jsx)(M,{size:`sm`,loading:i,onClick:r,children:t.status===`idle`||i?O(`checkFromAddress`):O(`checkAgain`)})]})},Hs=3e3,Us=async({start:e,result:t,wait:n,stopped:r,onState:i})=>{i({status:`waiting`});let a=await e();if(!r()){if(a.status!==`waiting`)return i(a);for(let e=0;e<40;e++){if(await n(Hs),r())return;let e=await t(a.check);if(r())return;if(e.status!==`waiting`)return i(e)}i({status:`timed_out`})}},Ws=e=>new Promise(t=>setTimeout(t,e)),Gs=(e,t=!1)=>{let[n,r]=(0,Y.useState)({status:`idle`}),[i,a]=(0,Y.useState)(),o=(0,Y.useRef)(!1),s=(0,Y.useRef)(!1),c=(0,Y.useRef)(e);c.current=e;let l=(0,Y.useCallback)(async()=>{if(!o.current){o.current=!0,a(void 0);try{await Us({...c.current,wait:Ws,stopped:()=>s.current,onState:r})}catch(e){if(s.current)return;if(r({status:`idle`}),e instanceof TypeError)return a(O(`noAnswerFromServer`));if(!(e instanceof k))throw e;a(z(e))}finally{o.current=!1}}},[]);return(0,Y.useEffect)(()=>(s.current=!1,t&&l(),()=>{s.current=!0}),[t,l]),{state:n,error:i,check:l}},Ks=({address:e,calls:t,auto:n=!1})=>{let{state:r,error:i,check:a}=Gs(t,n);return(0,X.jsx)(Vs,{address:e,state:r,error:i,onCheck:()=>void a()})},qs=({sender:e,check:t,busy:n,error:r,onSave:i,onClose:a})=>{let[s,c]=(0,Y.useState)(e?.address??``),[l,u]=(0,Y.useState)(e?.name??``),[d,f]=(0,Y.useState)(e?.signature??``),[p,m]=(0,Y.useState)(e?.isDefault??!1);return(0,X.jsxs)(o,{title:e?e.address:O(`addFromAddress`),description:O(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:a,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:a,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:n,disabled:!s.trim(),onClick:()=>i({address:s.trim(),name:l.trim(),signature:d,isDefault:p}),children:O(e?`save`:`addAddress`)})]}),children:[!e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`fromAddress`),(0,X.jsx)(N,{autoFocus:!0,type:`email`,value:s,maxLength:254,placeholder:O(`fromAddressPlaceholder`),onChange:e=>c(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[O(`fromName`),(0,X.jsx)(N,{value:l,maxLength:100,placeholder:O(`fromNamePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{children:O(`defaultFromAddress`)}),(0,X.jsx)(de,{checked:p,onChange:m,label:O(`defaultFromAddress`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[O(`signature`),(0,X.jsx)(Yt,{value:d,maxLength:2e3,placeholder:O(`signaturePlaceholder`),onChange:e=>f(e.target.value)})]}),(0,X.jsx)(L,{message:r}),t&&!t.available&&(0,X.jsx)(zs,{}),e&&t?.available&&t.calls&&(0,X.jsx)(Ks,{address:e.address,calls:t.calls,...t.auto&&{auto:!0}})]})},Js=e=>e.signature?O(`ownSignature`):O(`genericSignature`),Ys=({senders:{address:e,senders:t,checks:n=!1},onAdd:r,onUpdate:i,onRemove:a,onCheck:s,onCheckResult:c})=>{let[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(),[p,m]=(0,Y.useState)(),h=(0,Y.useRef)(!1),g=t.find(e=>e.isDefault),_=()=>{m(void 0),f(void 0)},v=async e=>{if(!h.current){h.current=!0,u(!0),f(void 0);try{m(await e()||void 0)}catch(e){if(e instanceof TypeError)return f(O(`noAnswerFromServer`));if(!(e instanceof k))throw e;f(z(e))}finally{h.current=!1,u(!1)}}},y=e=>v(async()=>{let t=e.name||null,a=e.signature.trim()?e.signature:null;if(p?.kind===`change`)return void await i(p.sender.id,{name:t,signature:a,isDefault:e.isDefault});let o=await r({address:e.address,...t&&{name:t},...a&&{signature:a}});if(e.isDefault&&await i(o.id,{isDefault:!0}),n)return{kind:`change`,sender:{...o,isDefault:e.isDefault},autoCheck:!0}});return(0,X.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,X.jsx)(`h3`,{className:`font-semibold`,children:O(`fromAddresses`)}),(0,X.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:O(`fromAddressesDescription`)}),(0,X.jsx)(L,{message:p?void 0:d}),(e||t.length>0)&&(0,X.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:O(`mailboxOwnAddress`)})]}),g?(0,X.jsx)(M,{size:`sm`,variant:`ghost`,loading:l,onClick:()=>void v(async()=>void await i(g.id,{isDefault:!1})),children:O(`makeDefault`)}):(0,X.jsx)(H,{tone:`blue`,children:O(`default`)})]}),t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,X.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Js(e)})]}),e.isDefault&&(0,X.jsx)(H,{tone:`blue`,children:O(`default`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>m({kind:`change`,sender:e}),children:O(`edit`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>m({kind:`remove`,sender:e}),children:O(`remove`)})]},e.id))]}),(0,X.jsxs)(M,{onClick:()=>m({kind:`add`}),children:[(0,X.jsx)(oe,{className:`size-3.5`}),O(`addFromAddress`)]}),p?.kind===`add`&&(0,X.jsx)(qs,{check:{available:n},busy:l,error:d,onSave:e=>void y(e),onClose:_}),p?.kind===`change`&&(0,X.jsx)(qs,{sender:p.sender,check:((e,t=!1)=>({available:n,calls:{start:()=>s(e.id),result:t=>c(e.id,t)},...t&&{auto:t}}))(p.sender,p.autoCheck),busy:l,error:d,onSave:e=>void y(e),onClose:_},p.sender.id),p?.kind===`remove`&&(0,X.jsx)(o,{title:O(`removeFromAddress`,{address:p.sender.address}),description:O(`removeFromAddressDescription`),onClose:_,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:_,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:l,onClick:()=>void v(()=>a(p.sender.id)),children:O(`remove`)})]}),children:(0,X.jsx)(L,{message:d})})]})},Xs=(e,t,n)=>Object.fromEntries(Hn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,f(`signInOnly`,{provider:n(e.provider),name:e.name})])),Zs=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=_(),{account:i}=t,[a]=(0,Y.useState)(Gt),o=(0,Y.useCallback)(async()=>{let[t,n,r]=await Promise.all([i.linkedPersonalMail(e),i.linkedProviders(),i.mailSenders()]);return{mail:t,providers:n,senders:r}},[i,e]),{data:s,error:c,reload:l}=W(o,O(`couldNotReadMethods`));return s?(0,X.jsx)(Lt,{title:O(`mailbox`),description:O(`mailboxDescription`),providers:e.map(({id:e,name:t})=>({id:e,name:t})),linked:s.mail,notes:Xs(e,s,e=>r.find(t=>t.id===e)?.name??se(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&bt(a,e.length===1?e[0].name:O(`theProvider`)),children:(0,X.jsx)(Ys,{senders:s.senders,onAdd:async e=>{let t=await i.addMailSender(e);return m(),await l(),t},onUpdate:async(e,t)=>{await i.updateMailSender(e,t),m(),await l()},onRemove:async e=>{await i.removeMailSender(e),m(),await l()},onCheck:e=>i.checkMailSender(e),onCheckResult:(e,t)=>i.mailSenderCheckResult(e,t)})}):(0,X.jsx)(I,{error:c})},Qs=()=>{let{personalMail:e}=_();return e.length>0?(0,X.jsx)(Zs,{links:e}):null},$s=e=>Or(e.name)??`An unnamed app`,ec=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),tc=({apps:e,onDisconnect:t})=>{let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(),[s,c]=(0,Y.useState)(),l=async e=>{r(!0),a(void 0);try{await t(e.clientId),c(void 0)}catch(e){if(!(e instanceof k))throw e;a(z(e))}r(!1)};return(0,X.jsxs)(K,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,X.jsx)(L,{message:s?void 0:i}),e.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`No apps are connected. Add this app's MCP address to an AI assistant to connect one.`}):(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=kr(e.clientId);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Pr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:$s(e)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,ot(Date.parse(e.allowedAt)),` · `,ec(e)]})]}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>c(e),children:`Disconnect`})]},e.clientId)})}),s&&(0,X.jsx)(o,{title:`Disconnect ${$s(s)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>c(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>c(void 0),children:`Cancel`}),(0,X.jsx)(M,{variant:`danger`,loading:n,onClick:()=>void l(s),children:`Disconnect`})]}),children:i&&(0,X.jsx)(L,{message:i})})]})},nc=(e,t)=>{let n=new URL(`https://claude.ai/customize/connectors`);return n.searchParams.set(`modal`,`add-custom-connector`),t&&n.searchParams.set(`connectorName`,t),n.searchParams.set(`connectorUrl`,e),n.href},rc=({url:e,appName:t})=>(0,X.jsx)(K,{title:O(`mcpAddress`),description:O(`mcpAddressDescription`),children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Ar,{value:e,copyLabel:O(`copyMcpAddress`)}),(0,X.jsxs)(`a`,{href:nc(e,t),target:`_blank`,rel:`noreferrer`,className:p(),children:[(0,X.jsx)(b,{className:`size-3.5`}),O(`addToClaude`)]})]})}),ic=()=>{let{account:e}=_().session,{data:t,error:n,reload:r}=W((0,Y.useCallback)(()=>e.connectedApps(),[e]),O(`couldNotReadMethods`));return t?(0,X.jsx)(tc,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,X.jsx)(I,{error:n})},ac=({url:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(rc,{url:e,appName:q().appName}),(0,X.jsx)(ic,{})]}),oc=()=>{let{mcp:e}=_();return e?(0,X.jsx)(ac,{url:e.url}):null},sc={30:30,90:90,365:365,never:void 0},cc={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},lc=e=>ot(Date.parse(e)),uc=e=>e?O(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:lc(e)}):O(`neverExpires`),dc=e=>[O(`createdOn`,{date:lc(e.createdAt)}),uc(e.expiresAt),e.lastUsedAt?O(`lastUsedOn`,{date:lc(e.lastUsedAt)}):O(`notUsedYet`),e.organization?O(`actsAsIn`,{role:e.role,organization:e.organization}):O(`actsAs`,{role:e.role})].join(` · `),fc=({tokens:e,onCreate:t,onRevoke:n})=>{let[r,i]=(0,Y.useState)(!1),[a,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(`90`),[m,h]=(0,Y.useState)(),g=()=>{l(void 0),s(void 0),h(void 0)},_=(0,Y.useRef)(!1),v=async e=>{if(!_.current){_.current=!0,i(!0),s(void 0);try{l(await e()),h(void 0)}catch(e){if(e instanceof TypeError)return s(O(`noAnswerFromServer`));if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):s(z(e))}finally{_.current=!1,i(!1)}}},y=()=>v(async()=>{let e=sc[f];return{kind:`created`,created:await t({name:u.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,X.jsxs)(K,{title:O(`accessTokens`),description:O(`accessTokensDescription`),children:[(0,X.jsx)(L,{message:c?void 0:a}),e.length===0?(0,X.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:O(`noAccessTokens`)}):(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Ir,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:dc(e)})]}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>l({kind:`revoke`,token:e}),children:O(`revoke`)})]},e.id))}),(0,X.jsxs)(M,{onClick:()=>{d(``),p(`90`),l({kind:`create`})},children:[(0,X.jsx)(oe,{className:`size-3.5`}),O(`newAccessToken`)]}),c?.kind===`create`&&(0,X.jsxs)(o,{title:O(`newAccessToken`),description:O(`newAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:g,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:r,disabled:!u.trim(),onClick:()=>void y(),children:O(`createAccessToken`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`name`),(0,X.jsx)(N,{autoFocus:!0,value:u,maxLength:100,placeholder:O(`accessTokenNamePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[O(`accessTokenExpiry`),(0,X.jsx)(_e,{value:f,onChange:e=>p(e.target.value),children:Object.keys(sc).map(e=>(0,X.jsx)(`option`,{value:e,children:O(cc[e])},e))})]}),m===`asked`&&(0,X.jsx)(Sn,{purpose:`change`,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:O(`confirmedCreateAccessToken`)}),(0,X.jsx)(L,{message:a})]}),c?.kind===`created`&&(0,X.jsx)(o,{title:O(`accessTokenCreated`,{name:c.created.personalAccessToken.name}),description:O(`accessTokenCreatedDescription`),onClose:g,actions:(0,X.jsx)(M,{variant:`primary`,onClick:g,children:O(`done`)}),children:(0,X.jsx)(Ar,{value:c.created.token,copyLabel:O(`copyAccessToken`)})}),c?.kind===`revoke`&&(0,X.jsx)(o,{title:O(`revokeAccessToken`,{name:c.token.name}),description:O(`revokeAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:g,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:r,onClick:()=>void v(async()=>(await n(c.token.id),void 0)),children:O(`revoke`)})]}),children:(0,X.jsx)(L,{message:a})})]})},pc=()=>{let{account:e}=_().session,{data:t,error:n,reload:r}=W((0,Y.useCallback)(()=>e.personalAccessTokens(),[e]),O(`couldNotReadAccessTokens`));return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{message:n}),(0,X.jsx)(fc,{tokens:t,onCreate:t=>e.createPersonalAccessToken(t).then(e=>(r(),e),async e=>{throw await r(),e}),onRevoke:t=>e.revokePersonalAccessToken(t).finally(r)})]}):(0,X.jsx)(I,{error:n})},mc=()=>_().personalAccessTokens?(0,X.jsx)(pc,{}):null,hc={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},gc=e=>e.provider===`google`,_c=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[i,a]=(0,Y.useState)(),[s,c]=(0,Y.useState)(r),[l,u]=(0,Y.useState)(),[d,f]=(0,Y.useState)(),p=async(e,t)=>{a(e),c(void 0),f(void 0);try{await t(),u(void 0)}catch(e){if(!(e instanceof k))throw e;c(z(e))}finally{a(void 0)}};return(0,X.jsxs)(K,{title:O(`connections`),description:O(`connectionsDescription`),children:[(0,X.jsx)(L,{message:l?void 0:s}),(0,X.jsx)(ht,{message:d}),(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(Br,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,X.jsx)(M,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void p(e.key,()=>t(e)),children:e.accounts.length>0?O(`connectAgain`,{name:e.label}):O(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[O(`connectedOn`,{date:ot(Date.parse(t.created_at))}),` · `,(0,X.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,X.jsx)(H,{tone:`amber`,children:O(`connectionNeedsSignIn`)}):(0,X.jsx)(H,{tone:`green`,children:O(`connected`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>u({connection:e,accountId:t.id}),children:O(`disconnect`)})]}),t.used_by.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:O(`connectionUsedBy`)}),t.used_by.map(e=>(0,X.jsx)(Ke,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),l&&(0,X.jsx)(o,{title:O(`disconnectTitle`,{name:l.connection.label}),description:gc(l.connection)?`${O(`disconnectDescription`)} ${O(`disconnectWholeGrant`)}`:O(`disconnectDescription`),onClose:()=>u(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>u(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:i===l.accountId,onClick:()=>void p(l.accountId,async()=>f(O(hc[await n(l.accountId)]))),children:O(`disconnect`)})]}),children:s&&(0,X.jsx)(L,{message:s})})]})},vc=()=>{let{session:e,connectAccount:t}=_(),{account:n}=e,[r]=(0,Y.useState)(Gt),{data:i,error:a,reload:o}=W((0,Y.useCallback)(()=>n.workflowConnections(),[n]),O(`couldNotReadMethods`));return i?i.length===0?null:(0,X.jsx)(_c,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&bt(r,O(`theProvider`))}):(0,X.jsx)(I,{error:a})},yc=e=>e.code===`LAST_ADMIN`?O(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?O(`deleteAccountLocked`):z(e),bc=({hasPassword:e,onDelete:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(!1),f=(0,Y.useId)(),p=async()=>{s(!0),l(void 0),d(!1);try{await t(e?r:void 0)}catch(e){if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?d(!0):l(yc(e)),s(!1)}};return(0,X.jsxs)(o,{title:O(`deleteAccountQuestion`),description:O(`deleteAccountWarning`),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:n,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,type:`submit`,form:f,loading:a,disabled:e&&!r,children:O(`deleteAccountConfirm`)})]}),children:[(0,X.jsxs)(`form`,{id:f,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),p()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`deleteAccountPassword`),(0,X.jsx)(N,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,invalid:!!c,onChange:e=>i(e.target.value)})]}),(0,X.jsx)(L,{message:c})]}),u&&(0,X.jsx)(Sn,{purpose:`change`,minutes:15,onConfirmed:()=>void p()})]})},xc=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(K,{title:O(`deleteAccount`),description:O(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,X.jsx)(M,{variant:`danger`,onClick:()=>i(!0),children:O(`deleteAccount`)}),r&&(0,X.jsx)(bc,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},Sc=()=>{let{session:e,state:t,deleteAccount:n}=_(),{account:r}=e,{data:i,error:a}=W((0,Y.useCallback)(()=>r.signInMethods(),[r]),O(`couldNotReadMethods`));return i?(0,X.jsx)(xc,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,X.jsx)(I,{error:a})},Cc=[[/Edg(e|A|iOS)?\//,`Edge`],[/OPR\/|Opera/,`Opera`],[/SamsungBrowser\//,`Samsung Internet`],[/Firefox\/|FxiOS\//,`Firefox`],[/Chrome\/|CriOS\//,`Chrome`],[/Safari\//,`Safari`]],wc=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/CrOS/,`ChromeOS`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/Linux/,`Linux`]],Tc=(e,t)=>e.find(([e])=>e.test(t))?.[1],Ec=e=>e?{browser:Tc(Cc,e),system:Tc(wc,e)}:{},Dc=e=>e.device?O(`deviceThrough`,{device:e.device,provider:e.name}):e.name,Oc=(e,t)=>{if(e.staff)return t?O(`staffOf`,{operator:t}):O(`staff`);let{browser:n,system:r}=Ec(e.userAgent);return n&&r?O(`browserOn`,{browser:n,system:r}):r?O(`aBrowserOn`,{system:r}):n??O(`unknownDevice`)},kc=e=>{if(e.staff)return Hr;let{system:t}=Ec(e.userAgent);return t===`iPhone`||t===`Android`?Wr:t===`iPad`?Kr:Rr},Ac=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),jc=(e,t)=>e.kind===`one`?O(`signOutDevice`,{name:Oc(e.session,t)}):e.kind===`link`?O(`signOutDevice`,{name:Dc(e.link)}):O(`signOutOthersTitle`),Mc=e=>O(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),Nc=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(),[d,f]=(0,Y.useState)(),p=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),m=e.filter(e=>!e.current),h=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),g=async e=>{c(!0),u(void 0);try{await h(e),f(void 0)}catch(e){if(!(e instanceof k))throw e;u(z(e))}c(!1)},_=e=>{u(void 0),f(e)};return(0,X.jsxs)(K,{title:O(`devices`),description:O(`devicesDescription`),children:[p.length===0&&n.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:O(`noDevices`)}):(0,X.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[Ac(p).map(e=>{let n=kc(e);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:Oc(e,t)}),e.current&&(0,X.jsx)(H,{tone:`green`,children:O(`thisDevice`)})]}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[O(`signedInFromUntil`,{from:Ft(Date.parse(e.createdAt)),until:Ft(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`one`,session:e}),children:O(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Wr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:Dc(t)}),n&&(0,X.jsx)(H,{tone:`green`,children:O(`thisDevice`)})]}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:O(`linkedOn`,{date:Ft(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`link`,link:t}),children:O(`signOut`)})]},t.id)})]}),m.length>0&&(0,X.jsx)(M,{className:`mt-3`,onClick:()=>_({kind:`others`}),children:O(`signOutOthers`)}),d&&(0,X.jsx)(o,{title:jc(d,t),description:Mc(d),onClose:()=>f(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>f(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:s,onClick:()=>void g(d),children:O(`signOut`)})]}),children:(0,X.jsx)(L,{message:l})})]})},Pc=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=_(),{account:r}=e,i=(0,Y.useCallback)(async()=>{let[e,t]=await Promise.all([r.sessions(),n?r.deviceLinks():[]]);return{sessions:e,links:t}},[r,n]),{data:a,error:o,reload:s}=W(i,O(`couldNotReadDevices`));return a?(0,X.jsx)(Nc,{sessions:a.sessions,links:a.links,operator:t,onSignOut:e=>r.revokeSession(e).then(s),onSignOutOthers:()=>r.revokeOtherSessions().then(s),onSignOutLink:e=>r.signOutDeviceLink(e).then(s)}):(0,X.jsx)(I,{error:o})},Fc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},Ic=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(),g=e===`required`&&t.length<=1,_=async e=>{s(!0),l(void 0),h(void 0);try{await e(),d(void 0)}catch(e){if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):l(z(e))}s(!1)};return(0,X.jsxs)(K,{title:O(`passkeys`),status:e===`required`&&(0,X.jsx)(H,{tone:`blue`,children:O(`required`)}),description:O(Fc[e]),children:[(0,X.jsx)(L,{message:u?void 0:c}),t.length>0&&(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(S,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??O(`passkey`)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?O(`addedOn`,{date:ot(Date.parse(e.createdAt))}):O(`addedEarlier`),` · `,e.backedUp?O(`synced`):O(`oneDevice`)]})]}),(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>{p(e.name??``),d({kind:`rename`,passkey:e})},children:O(`rename`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,disabled:g,title:g?O(`keepLastPasskey`):void 0,onClick:()=>d({kind:`remove`,passkey:e}),children:O(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,X.jsxs)(M,{loading:a&&!u,onClick:()=>void _(n),children:[(0,X.jsx)(oe,{className:`size-3.5`}),O(`addPasskey`)]}),m===`asked`&&(0,X.jsx)(Sn,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:O(`confirmedAddPasskey`)}),u?.kind===`rename`&&(0,X.jsxs)(o,{title:O(`renamePasskey`),description:O(`renamePasskeyDescription`),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>d(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:a,disabled:!f.trim(),onClick:()=>void _(()=>r(u.passkey.id,f.trim())),children:O(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`name`),(0,X.jsx)(N,{autoFocus:!0,value:f,maxLength:60,onChange:e=>p(e.target.value)})]}),(0,X.jsx)(L,{message:c})]}),u?.kind===`remove`&&(0,X.jsx)(o,{title:O(`removePasskey`),description:O(`removePasskeyDescription`,{name:u.passkey.name??O(`thisPasskey`)}),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>d(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:a,onClick:()=>void _(()=>i(u.passkey.id)),children:O(`remove`)})]}),children:c&&(0,X.jsx)(L,{message:c})})]})},Lc=()=>{let{account:e}=_().session,t=(0,Y.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=W(t,O(`couldNotReadMethods`));if(!n)return(0,X.jsx)(I,{error:r});let[a,o]=n;return(0,X.jsx)(Ic,{rule:a.policy.passkey,passkeys:o,onAdd:()=>e.addPasskey().then(i),onRename:(t,n)=>e.renamePasskey(t,n).then(i),onRemove:t=>e.removePasskey(t).then(i)})},Rc=e=>e.code===`PASSWORD_TOO_SHORT`?O(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?O(`passwordTooLong`):z(e),zc=(e,t)=>{if(e.length<12)return O(`useAtLeast`,{length:12});if(e!==t)return O(`passwordsDiffer`)},Bc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),m=(0,Y.useId)(),h=(!e||r)&&a&&c,g=async()=>{let e=zc(a,c);if(p(e),!e){d(!0);try{await t({current:r,next:a})}catch(e){if(!(e instanceof k))throw e;p(Rc(e)),d(!1)}}};return(0,X.jsx)(o,{title:O(e?`changePassword`:`setPassword`),description:O(`atLeast`,{length:12}),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:n,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,type:`submit`,form:m,loading:u,disabled:!h,children:O(`save`)})]}),children:(0,X.jsxs)(`form`,{id:m,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),g()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`currentPassword`),(0,X.jsx)(N,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`newPassword`),(0,X.jsx)(N,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!f,onChange:e=>s(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`repeatPassword`),(0,X.jsx)(N,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:c,invalid:!!f,onChange:e=>l(e.target.value)})]}),e&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:O(`changeSignsOutOthers`)}),(0,X.jsx)(L,{message:f})]})})},Vc=({rule:e,hasPassword:t,staff:n})=>O(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),Hc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=!n&&e===`allowed`;return(0,X.jsxs)(K,{title:O(`password`),description:Vc({rule:e,hasPassword:t,staff:n}),children:[(0,X.jsx)(ht,{message:s?O(`passwordSaved`):void 0}),l&&(0,X.jsx)(M,{onClick:()=>{c(!1),o(!0)},children:O(t?`changePassword`:`setPassword`)}),a&&(0,X.jsx)(Bc,{hasPassword:t,onClose:()=>o(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):i(n)),o(!1),c(!0)}})]})},Uc=()=>{let{session:e,state:t}=_(),{account:n}=e,{data:r,error:i,reload:a}=W((0,Y.useCallback)(()=>n.signInMethods(),[n]),O(`couldNotReadMethods`));return r?(0,X.jsx)(Hc,{rule:r.policy.password,hasPassword:r.account.password,staff:t.kind===`signed-in`&&!!t.staff,onChange:(e,t)=>n.changePassword(e,t).then(a),onSet:e=>n.setPassword(e).then(a)}):(0,X.jsx)(I,{error:i})},Wc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=async e=>{f(!0),m(void 0);try{await e()}catch(e){if(!(e instanceof k))throw e;m(z(e))}f(!1)},g=i.trim(),_=()=>h(async()=>{await t.request(g),u(``),c(g)}),v=e=>h(async()=>{await t.confirm(s,e),n()});return s?(0,X.jsxs)(o,{title:O(`changeEmail`),description:O(`codeSentTo`,{email:s,minutes:10}),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{variant:`ghost`,onClick:()=>{c(void 0),m(void 0)},children:O(`otherAddress`)}),(0,X.jsx)(M,{variant:`primary`,loading:d,disabled:l.length<6,onClick:()=>void v(l),children:O(`changeEmail`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`code`),(0,X.jsx)(ve,{name:`code`,required:!0,autoFocus:!0,value:l,invalid:!!p,onChange:u,onComplete:e=>!d&&void v(e)})]}),(0,X.jsx)(L,{message:p})]}):(0,X.jsxs)(o,{title:O(`changeEmail`),description:O(`changeEmailDescription`),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:r,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:d,disabled:!g||g.toLowerCase()===e.toLowerCase(),onClick:()=>void _(),children:O(`sendCode`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`newEmail`),(0,X.jsx)(N,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(L,{message:p})]})},Gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(),g=async()=>{p(!0),h(void 0);try{await n(u.trim()),s(!1)}catch(e){if(!(e instanceof k))throw e;h(z(e))}p(!1)};return(0,X.jsxs)(K,{title:O(`profile`),description:O(`profileDescription`),children:[(0,X.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:O(`name`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:O(`email`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(M,{onClick:()=>{d(e),h(void 0),s(!0)},children:O(`changeName`)}),r&&(0,X.jsx)(M,{onClick:()=>l(!0),children:O(`changeEmail`)})]}),a&&(0,X.jsxs)(o,{title:O(`changeName`),description:O(`changeNameDescription`),onClose:()=>s(!1),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>s(!1),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:f,disabled:!u.trim()||u.trim()===e,onClick:()=>void g(),children:O(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`name`),(0,X.jsx)(N,{autoFocus:!0,value:u,maxLength:100,onChange:e=>d(e.target.value)})]}),(0,X.jsx)(L,{message:m})]}),c&&r&&(0,X.jsx)(Wc,{email:t,change:r,onClose:()=>l(!1),onDone:()=>{l(!1),i?.()}})]})},Kc=()=>{let{session:e,changeEmail:t}=_(),{data:n,loaded:r,error:i,reload:a}=W((0,Y.useCallback)(()=>e.session(),[e]),O(`couldNotReadProfile`));if(!r)return(0,X.jsx)(I,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,X.jsx)(Gc,{name:n.name,email:n.email,onRename:t=>e.account.updateName(t).then(a),emailChange:o,onEmailChanged:a})},qc=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:s})=>{let[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),[m,h]=(0,Y.useState)(!1),g=async()=>{d(!0),p(void 0),h(!1);try{await a(i?c:void 0)}catch(e){if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(!0):p(z(e)),d(!1)}};return(0,X.jsxs)(o,{title:e,description:t,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:s,children:O(`cancel`)}),(0,X.jsx)(M,{variant:r?`danger`:`primary`,loading:u,disabled:i&&!c,onClick:()=>void g(),children:n})]}),children:[i&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`yourPassword`),(0,X.jsx)(N,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:c,invalid:!!f,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&c&&void g()})]}),f&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:f}),m&&(0,X.jsx)(Sn,{purpose:`change`,minutes:15,onConfirmed:()=>void g()})]})},Jc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},Yc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:s,onNewBackupCodes:c,onChanged:l}=e,[u,d]=(0,Y.useState)(),f=()=>d(void 0),p=n?(0,X.jsx)(H,{tone:`green`,children:O(`on`)}):t===`required`?(0,X.jsx)(H,{tone:`amber`,children:O(`required`)}):(0,X.jsx)(H,{children:O(`off`)}),m=O(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:Jc[t]);return u?.kind===`setup`?(0,X.jsx)(K,{title:O(`twoFactor`),status:p,description:m,children:(0,X.jsx)(`div`,{className:`max-w-sm`,children:(0,X.jsx)(hn,{offerEmailedCodes:i&&!u.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:f,onDone:()=>{f(),l()}})})}):(0,X.jsxs)(K,{title:O(`twoFactor`),status:p,description:m,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,X.jsx)(M,{variant:`primary`,onClick:()=>d({kind:`setup`,appOnly:!1}),children:O(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,X.jsx)(M,{onClick:()=>d({kind:`setup`,appOnly:!0}),children:O(`addAuthenticator`)}),n&&r&&(0,X.jsx)(M,{onClick:()=>d({kind:`new-codes`}),children:O(`newBackupCodes`)}),n&&(0,X.jsx)(M,{variant:`danger`,disabled:t===`required`,title:t===`required`?O(`twoFactorIsRequired`):void 0,onClick:()=>d({kind:`turn-off`}),children:O(`turnOff`)})]}),u?.kind===`turn-off`&&(0,X.jsx)(qc,{title:O(`turnOffTitle`),description:O(`turnOffDescription`),confirmLabel:O(`turnOff`),danger:!0,needsPassword:a,onClose:f,onConfirm:async e=>{await s(e),f(),l()}}),u?.kind===`new-codes`&&(0,X.jsx)(qc,{title:O(`newCodesTitle`),description:O(`newCodesDescription`),confirmLabel:O(`makeNewCodes`),needsPassword:a,onClose:f,onConfirm:async e=>d({kind:`codes`,codes:await c(e)})}),u?.kind===`codes`&&(0,X.jsx)(o,{title:O(`yourNewCodes`),description:O(`keepCodesSafe`),onClose:f,actions:(0,X.jsx)(M,{variant:`primary`,onClick:f,children:O(`savedCodes`)}),children:(0,X.jsx)(Dn,{codes:u.codes})})]})},Xc=()=>{let{account:e}=_().session,{data:t,error:n,reload:r}=W((0,Y.useCallback)(()=>e.signInMethods(),[e]),O(`couldNotReadMethods`));return t?(0,X.jsx)(Yc,{rule:t.policy.twoFactor,enabled:t.account.twoFactor,authenticatorApp:t.account.authenticatorApp,mail:t.mail,needsPassword:t.account.password,onStartApp:t=>e.startAuthenticatorApp(t),onConfirmApp:t=>e.confirmAuthenticatorApp(t),onEmailedCodes:t=>e.turnOnEmailedCodes(t),onTurnOff:t=>e.turnOffTwoFactor(t),onNewBackupCodes:t=>e.newBackupCodes(t),onChanged:r}):(0,X.jsx)(I,{error:n})},Zc=({problem:e,fallback:t})=>t===void 0?(0,X.jsx)(rn,{children:e}):(0,X.jsxs)(X.Fragment,{children:[!1,t]}),Qc=({name:e,registered:t,fallback:n,children:r})=>t?(0,X.jsx)(Qe,{name:e,fallback:n===void 0?void 0:(0,X.jsx)(Zc,{problem:V.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,X.jsx)(Zc,{problem:V.rich(`noComponent`,{component:e}),fallback:n}),$c={Page:to,Grid:ja,Card:di,Stat:Bo,RecordCard:ao,Field:Ea,Diff:Ca,Table:Go,CardRow:hi,RecordRow:To,RecordCards:xo,Chart:gi,Timeline:ta,Graph:aa,Progress:ro,Image:za,ModalForm:eo,Thread:vs,Composer:ba,Action:ui,Show:No,Switch:Fo,Match:Io,Link:Ya,Settings:ko,Tabs:qo,Tab:Jo,Users:Rs,Profile:Kc,Password:Uc,Passkeys:Lc,TwoFactor:Xc,ConnectedAccounts:$e,PersonalMail:Qs,Connections:vc,Devices:Pc,ConnectedApps:oc,PersonalAccessTokens:mc,DeleteAccount:Sc,Box:ys,Row:bs,Column:xs,Text:Ss,ReferenceManyField:Ds,ReferenceArrayField:ks,ArrayField:Cs,RecordsIterator:pi,ReferenceField:js,SelectInput:ws,Details:xa,Summary:Sa,TextField:Ha,NumberField:Ua,DateField:Wa,BooleanField:Ga,UrlField:Ka,ChipField:qa},el=new Set(`Page.Grid.Card.Stat.RecordCard.Field.Diff.Table.CardRow.RecordRow.RecordCards.Chart.Timeline.Graph.Progress.Image.Thread.Link.Tabs.Settings.Show.Switch.Action.Box.Row.Column.Text.ReferenceField.SelectInput.Details.Summary.TextField.NumberField.DateField.BooleanField.UrlField.ChipField`.split(`.`)),tl=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:ae(t,...n,r)}})),nl=({text:e})=>{let t=R(),n=an(),r={...F(t),params:n};return(0,X.jsx)(X.Fragment,{children:en(e,e=>dn(ze(r,e)))})},rl=(e,t)=>e.includes(`{{`)?(0,X.jsx)(nl,{text:e},t):(0,X.jsx)(Y.Fragment,{children:e},t),il=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?rl(e,n):(0,X.jsx)(dl,{node:e,at:t},n)),al=e=>{let t=[];for(let n of e){let e=t.at(-1);Xr(n.child)&&e&&Xr(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Xr(n.child)?(0,X.jsx)(`p`,{className:`leading-6`,children:il(e)},t):(0,X.jsx)(dl,{node:n.child,at:n.at},t)})},ol=e=>tn(e)||Array.isArray(e)&&e.length>0&&e.every(tn),sl=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>ol(n)?[[e,(0,X.jsx)(X.Fragment,{children:al(cl(n,t,e))})]]:[])),cl=(e,t,n)=>Array.isArray(e)?tl(e,t,`props`,n):[{child:e,...t!==void 0&&{at:ae(t,`props`,n)}}],ll=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ul=(e,t)=>{let n=ll(e.props.components)?e.props.components:{},r=Object.fromEntries(Object.entries(n).flatMap(([e,t])=>tn(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=Mn(t,String(e.props.i18nKey),ll(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||tn(e)?e:String(e)):[i]},dl=({node:e,at:t})=>{let{components:n}=y(),r=R(),i=an(),a=Cn(),o=(0,Y.useMemo)(()=>ke(w(e,{...F(r),params:i}),a),[e,r,i,a]);if(o.type===`Trans`&&!o.custom)return(0,X.jsx)(X.Fragment,{children:il(ul(o,a).map(e=>({child:e})))});if(o.custom){let e=n?.[o.type],r=o.children.length>0?(0,X.jsx)(na,{node:o,children:al(tl(o.children,t,`children`))}):void 0;return(0,X.jsx)(Qc,{name:o.type,registered:!!e,fallback:o.fallback&&(0,X.jsx)(X.Fragment,{children:al(tl(o.fallback,t,`fallback`))}),children:e&&(0,X.jsx)(Vt,{node:o,...t!==void 0&&{at:t},children:(0,X.jsx)(e,{...Be(o.props),children:r})})})}let s=$c[o.type];if(!s)return(0,X.jsx)(rn,{children:V.rich(`unknownBlock`,{type:o.type})});let c=typeof o.props.className==`string`?o.props.className:void 0,l=tl(o.children,t,`children`),u=(0,X.jsx)(s,{node:o,at:t,slots:sl(o,t),className:c,children:o.type===`Text`||o.type===`Link`||o.type===`Summary`?il(l):al(o.type===`Switch`?l.filter(({child:e})=>typeof e!=`string`):l)}),d=c===void 0||el.has(o.type)?u:(0,X.jsx)(`div`,{className:c,children:u});return o.fallback?(0,X.jsx)(Qe,{name:o.type,resetKey:o,fallback:(0,X.jsx)(X.Fragment,{children:al(tl(o.fallback,t,`fallback`))}),children:d}):d};export{ms as a,ns as c,yo as d,lo as f,ua as h,gs as i,Vo as l,ya as m,Qc as n,ps as o,oo as p,_s as r,ds as s,dl as t,Ao as u};
3
+ //# debugId=f2be8cde-4728-48c4-af02-b802f6ab262b