@protobase/ui 0.117.0 → 0.117.2

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 (208) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/app/change-confirm/messages.d.ts +2 -2
  3. package/dist/app/charts/messages.d.ts +2 -2
  4. package/dist/app/conversation/messages.d.ts +2 -2
  5. package/dist/app/conversation/thread-state.d.ts +1 -1
  6. package/dist/app/create/messages.d.ts +2 -2
  7. package/dist/app/delete/messages.d.ts +2 -2
  8. package/dist/app/displays/messages.d.ts +2 -2
  9. package/dist/app/embedded-list/messages.d.ts +2 -2
  10. package/dist/app/export/messages.d.ts +2 -2
  11. package/dist/app/field-messages.d.ts +2 -2
  12. package/dist/app/field-types/json/messages.d.ts +2 -2
  13. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  14. package/dist/app/field-types/workflow/definition.d.ts +1 -1
  15. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  16. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  17. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  18. package/dist/app/field-types/workflow-status/messages.d.ts +2 -2
  19. package/dist/app/file-viewers/messages.d.ts +2 -2
  20. package/dist/app/focus/messages.d.ts +2 -2
  21. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  22. package/dist/app/gallery/messages.d.ts +2 -2
  23. package/dist/app/hand-order/messages.d.ts +2 -2
  24. package/dist/app/history/messages.d.ts +2 -2
  25. package/dist/app/import/messages.d.ts +2 -2
  26. package/dist/app/list-messages.d.ts +2 -2
  27. package/dist/app/messages.d.ts +2 -2
  28. package/dist/app/meta-gate-messages.d.ts +2 -2
  29. package/dist/app/new-version/messages.d.ts +2 -2
  30. package/dist/app/pages/guide/billing-config.d.ts +1 -1
  31. package/dist/app/pages/guide/billing-views.d.ts +1 -1
  32. package/dist/app/pages/messages.d.ts +2 -2
  33. package/dist/app/record-chart/messages.d.ts +2 -2
  34. package/dist/app/record-messages.d.ts +2 -2
  35. package/dist/app/record-row/messages.d.ts +2 -2
  36. package/dist/app/related-cards/messages.d.ts +2 -2
  37. package/dist/app/runtime/messages.d.ts +2 -2
  38. package/dist/app/saved/messages.d.ts +2 -2
  39. package/dist/app/saved/use-favorite.d.ts +1 -1
  40. package/dist/app/search/messages.d.ts +2 -2
  41. package/dist/app/searches/messages.d.ts +2 -2
  42. package/dist/app/searches/use-save-search.d.ts +1 -1
  43. package/dist/app-shell/messages.d.ts +2 -2
  44. package/dist/assistant-dock/messages.d.ts +2 -2
  45. package/dist/auth/messages.d.ts +2 -2
  46. package/dist/calls/messages.d.ts +2 -2
  47. package/dist/carousel/messages.d.ts +2 -2
  48. package/dist/chat/messages.d.ts +2 -2
  49. package/dist/compact-table/messages.d.ts +2 -2
  50. package/dist/data-grid/column-spec.d.ts +1 -1
  51. package/dist/data-grid/messages.d.ts +2 -2
  52. package/dist/filter-panel/messages.d.ts +2 -2
  53. package/dist/forms/messages.d.ts +2 -2
  54. package/dist/inline-child-table/messages.d.ts +2 -2
  55. package/dist/invitations/messages.d.ts +2 -2
  56. package/dist/live/messages.d.ts +2 -2
  57. package/dist/locale/texts-gate.d.ts +21 -2
  58. package/dist/locale/texts-gate.js +33 -6
  59. package/dist/mentions/messages.d.ts +2 -2
  60. package/dist/mocks/orders.d.ts +2 -2
  61. package/dist/notifications/bell/messages.d.ts +2 -2
  62. package/dist/organizations/messages.d.ts +2 -2
  63. package/dist/package.js +1 -1
  64. package/dist/plugins/messages.d.ts +2 -2
  65. package/dist/record-view/messages.d.ts +2 -2
  66. package/dist/shell/assets/{account-page-dcJyxP-d.js → account-page-U7RldneI.js} +2 -2
  67. package/dist/shell/assets/{app-DTl8rg8j.js → app-94a88jzE.js} +11 -11
  68. package/dist/shell/assets/{assistant-shell-Bw1jJrLm.js → assistant-shell-BJWCAwCu.js} +2 -2
  69. package/dist/shell/assets/{board-display-DDFDZzOk.js → board-display-DSazq67h.js} +2 -2
  70. package/dist/shell/assets/{calendar-display-B0R6JkIL.js → calendar-display-CpqjM4oV.js} +2 -2
  71. package/dist/shell/assets/{call-rings-CzvSKlfI.js → call-rings-DnL8InVq.js} +2 -2
  72. package/dist/shell/assets/{calls-BgwbMyeR.js → calls-CTRygR5f.js} +2 -2
  73. package/dist/shell/assets/{circle-alert-CANqQIsU.js → circle-alert-B63XjMgn.js} +2 -2
  74. package/dist/shell/assets/{composed-page-gwTeW0b3.js → composed-page-BVm_6eWU.js} +2 -2
  75. package/dist/shell/assets/{composer-section-gsOgYgY2.js → composer-section-DETU2Obd.js} +2 -2
  76. package/dist/shell/assets/{connect-route-CtL1EJIN.js → connect-route-BILeY04q.js} +2 -2
  77. package/dist/shell/assets/{copy-field-CamvXHHQ.js → copy-field-CmFjZmVI.js} +2 -2
  78. package/dist/shell/assets/{create-route-Cx8yqS-H.js → create-route-BT69PwsI.js} +2 -2
  79. package/dist/shell/assets/{custom-step-container-field-0-Q_RuZy.js → custom-step-container-field-CZDuNAGK.js} +2 -2
  80. package/dist/shell/assets/{embedded-list-56J4XDiR.js → embedded-list-C9U2ypuX.js} +3 -3
  81. package/dist/shell/assets/{export-dialog-CEp2g6vx.js → export-dialog-DoaQ8h-M.js} +2 -2
  82. package/dist/shell/assets/{graph-view-CgjfBK_g.js → graph-view-COd5Mp2P.js} +2 -2
  83. package/dist/shell/assets/{group-donut-DGZUg_gn.js → group-donut-DUBQuhYa.js} +2 -2
  84. package/dist/shell/assets/{guest-call-page-BhTshbrl.js → guest-call-page-Bu41Ptk4.js} +3 -3
  85. package/dist/shell/assets/{html-viewer-GD1mwLEo.js → html-viewer-Bz3ots0-.js} +2 -2
  86. package/dist/shell/assets/{import-dialog-ByRCf2Cp.js → import-dialog-B0lJXEBq.js} +2 -2
  87. package/dist/shell/assets/{import-table-dialog-CiDY_0RT.js → import-table-dialog-CaZameXo.js} +2 -2
  88. package/dist/shell/assets/{index-PtDa8a1m.js → index-YZpQ8sMq.js} +1 -1
  89. package/dist/shell/assets/{invitations-page-Bh-RCnnl.js → invitations-page-DPzcVGHk.js} +2 -2
  90. package/dist/shell/assets/{layout-grid-DJrFC12w.js → layout-grid-hoLv1QVh.js} +2 -2
  91. package/dist/shell/assets/{legend-item-YdN_NHUz.js → legend-item-CU6Kt-GZ.js} +2 -2
  92. package/dist/shell/assets/{list-page-BU1MrXbN.js → list-page-C8Z3OhmV.js} +4 -4
  93. package/dist/shell/assets/{maplibre-BedvDUG2.js → maplibre-BOVzS79J.js} +2 -2
  94. package/dist/shell/assets/{markdown-content-BlKajH2l.js → markdown-content-BMDl_vl_.js} +2 -2
  95. package/dist/shell/assets/{members-page-BYUO0Dq2.js → members-page-O752tFj8.js} +2 -2
  96. package/dist/shell/assets/{messages-DQ0cj-Ao.js → messages-TLh-JbDm.js} +2 -2
  97. package/dist/shell/assets/{organization-page-BrC1nHC-.js → organization-page-DDwBkk8F.js} +2 -2
  98. package/dist/shell/assets/{organizations-page-CaUeWdr4.js → organizations-page-DNYezYgw.js} +2 -2
  99. package/dist/shell/assets/{pending-invitation-row-juUdWvG6.js → pending-invitation-row-DRjEfn76.js} +2 -2
  100. package/dist/shell/assets/{period-chart-BUZhUb5l.js → period-chart-B_Vtp_OD.js} +2 -2
  101. package/dist/shell/assets/{person-row-DH3JhMfz.js → person-row-ehgAozYT.js} +2 -2
  102. package/dist/shell/assets/{public-form-page-d3TamPPE.js → public-form-page-JM_r4BIq.js} +2 -2
  103. package/dist/shell/assets/{record-lines-NtlHP9Lz.js → record-lines-B8maPngL.js} +2 -2
  104. package/dist/shell/assets/{record-map-BDXoF9AS.js → record-map-BJI9HhZO.js} +2 -2
  105. package/dist/shell/assets/{record-opens-C1KgR6ff.js → record-opens-BP2LRuAM.js} +2 -2
  106. package/dist/shell/assets/{record-page-D88DdoET.js → record-page-DsLORKNo.js} +3 -3
  107. package/dist/shell/assets/{record-preview-BT9_Hdcn.js → record-preview-BDMeb9qp.js} +2 -2
  108. package/dist/shell/assets/{records-map-BjHcY5gU.js → records-map-D2IAAn9Z.js} +2 -2
  109. package/dist/shell/assets/{render-node-v6KfRocH.js → render-node-CAL7-6hf.js} +3 -3
  110. package/dist/shell/assets/{reorder-button-B3GeKMOJ.js → reorder-button-D9hO_nqd.js} +2 -2
  111. package/dist/shell/assets/{run-trace-view-Ddc0SELh.js → run-trace-view-CqCld741.js} +2 -2
  112. package/dist/shell/assets/{runner-install-field-CiD9Pw1j.js → runner-install-field-Cpd0yW2w.js} +2 -2
  113. package/dist/shell/assets/{runtime-update-CoXcnfxB.js → runtime-update-Cg98ENel.js} +2 -2
  114. package/dist/shell/assets/{shared-protobase-ui-CwLnXvxx.js → shared-protobase-ui-JVA65IEp.js} +1 -1
  115. package/dist/shell/assets/{sheet-source-DbJu1SrV.js → sheet-source-fKebPN-3.js} +2 -2
  116. package/dist/shell/assets/{sign-in-policy-page-B40iAeJa.js → sign-in-policy-page-DtxdycdZ.js} +2 -2
  117. package/dist/shell/assets/{start-block-queries-C_udrEM9.js → start-block-queries-DIJZ-fEE.js} +2 -2
  118. package/dist/shell/assets/{step-catalog-7obnZV6X.js → step-catalog-DefIkvlp.js} +2 -2
  119. package/dist/shell/assets/{step-panel-BM_xu6Yy.js → step-panel-DhFvGljv.js} +2 -2
  120. package/dist/shell/assets/{timeline-display-CdLfWAbQ.js → timeline-display-CsGry__i.js} +2 -2
  121. package/dist/shell/assets/{trash-BHo3HvFy.js → trash-B3Zy6Kx1.js} +2 -2
  122. package/dist/shell/assets/{update-set-DTikSoau.js → update-set-C_skfvwV.js} +2 -2
  123. package/dist/shell/assets/{use-calendar-move-Bhha2yOp.js → use-calendar-move-CZtjDwpL.js} +2 -2
  124. package/dist/shell/assets/{use-display-rows-CS_0O_UE.js → use-display-rows-DHVZ49lA.js} +2 -2
  125. package/dist/shell/assets/{use-paged-search-ChxCRCpF.js → use-paged-search-COK4rUdF.js} +2 -2
  126. package/dist/shell/assets/{use-run-trace-BfRRgSgG.js → use-run-trace-CRPYmppF.js} +2 -2
  127. package/dist/shell/assets/{use-workflow-page-CTdBd8_8.js → use-workflow-page-NQnBpQBn.js} +2 -2
  128. package/dist/shell/assets/{use-workflow-types-cZQ59ATf.js → use-workflow-types-BONTV-ip.js} +2 -2
  129. package/dist/shell/assets/{workflow-canvas-B0kWJeH0.js → workflow-canvas-wK7am90B.js} +2 -2
  130. package/dist/shell/assets/{workflow-field-DXIk6V2Y.js → workflow-field-D4NB5B1z.js} +3 -3
  131. package/dist/shell/assets/{workflow-graph-editor-Cem4aY2u.js → workflow-graph-editor-CBPqhazd.js} +2 -2
  132. package/dist/shell/assets/{workflow-run-field-BeMn3eOH.js → workflow-run-field-C1N-mmHl.js} +3 -3
  133. package/dist/shell/assets/{workflow-status-field-0wvGDiva.js → workflow-status-field-DEgDvkpV.js} +2 -2
  134. package/dist/shell/assets/{workflow-workbench-qT5c0xnH.js → workflow-workbench-mJR1exSe.js} +2 -2
  135. package/dist/shell/index.html +3 -3
  136. package/dist/shell/protobase.shell.json +3 -3
  137. package/dist/shell/protobase.sw.js +2 -2
  138. package/dist/shell-source-maps/assets/{account-page-dcJyxP-d.js.map → account-page-U7RldneI.js.map} +1 -1
  139. package/dist/shell-source-maps/assets/app-94a88jzE.js.map +1 -0
  140. package/dist/shell-source-maps/assets/{assistant-shell-Bw1jJrLm.js.map → assistant-shell-BJWCAwCu.js.map} +1 -1
  141. package/dist/shell-source-maps/assets/{board-display-DDFDZzOk.js.map → board-display-DSazq67h.js.map} +1 -1
  142. package/dist/shell-source-maps/assets/{calendar-display-B0R6JkIL.js.map → calendar-display-CpqjM4oV.js.map} +1 -1
  143. package/dist/shell-source-maps/assets/{call-rings-CzvSKlfI.js.map → call-rings-DnL8InVq.js.map} +1 -1
  144. package/dist/shell-source-maps/assets/{calls-BgwbMyeR.js.map → calls-CTRygR5f.js.map} +1 -1
  145. package/dist/shell-source-maps/assets/{circle-alert-CANqQIsU.js.map → circle-alert-B63XjMgn.js.map} +1 -1
  146. package/dist/shell-source-maps/assets/{composed-page-gwTeW0b3.js.map → composed-page-BVm_6eWU.js.map} +1 -1
  147. package/dist/shell-source-maps/assets/{composer-section-gsOgYgY2.js.map → composer-section-DETU2Obd.js.map} +1 -1
  148. package/dist/shell-source-maps/assets/{connect-route-CtL1EJIN.js.map → connect-route-BILeY04q.js.map} +1 -1
  149. package/dist/shell-source-maps/assets/{copy-field-CamvXHHQ.js.map → copy-field-CmFjZmVI.js.map} +1 -1
  150. package/dist/shell-source-maps/assets/{create-route-Cx8yqS-H.js.map → create-route-BT69PwsI.js.map} +1 -1
  151. package/dist/shell-source-maps/assets/{custom-step-container-field-0-Q_RuZy.js.map → custom-step-container-field-CZDuNAGK.js.map} +1 -1
  152. package/dist/shell-source-maps/assets/{embedded-list-56J4XDiR.js.map → embedded-list-C9U2ypuX.js.map} +1 -1
  153. package/dist/shell-source-maps/assets/{export-dialog-CEp2g6vx.js.map → export-dialog-DoaQ8h-M.js.map} +1 -1
  154. package/dist/shell-source-maps/assets/{graph-view-CgjfBK_g.js.map → graph-view-COd5Mp2P.js.map} +1 -1
  155. package/dist/shell-source-maps/assets/{group-donut-DGZUg_gn.js.map → group-donut-DUBQuhYa.js.map} +1 -1
  156. package/dist/shell-source-maps/assets/{guest-call-page-BhTshbrl.js.map → guest-call-page-Bu41Ptk4.js.map} +1 -1
  157. package/dist/shell-source-maps/assets/{html-viewer-GD1mwLEo.js.map → html-viewer-Bz3ots0-.js.map} +1 -1
  158. package/dist/shell-source-maps/assets/{import-dialog-ByRCf2Cp.js.map → import-dialog-B0lJXEBq.js.map} +1 -1
  159. package/dist/shell-source-maps/assets/{import-table-dialog-CiDY_0RT.js.map → import-table-dialog-CaZameXo.js.map} +1 -1
  160. package/dist/shell-source-maps/assets/{invitations-page-Bh-RCnnl.js.map → invitations-page-DPzcVGHk.js.map} +1 -1
  161. package/dist/shell-source-maps/assets/{layout-grid-DJrFC12w.js.map → layout-grid-hoLv1QVh.js.map} +1 -1
  162. package/dist/shell-source-maps/assets/{legend-item-YdN_NHUz.js.map → legend-item-CU6Kt-GZ.js.map} +1 -1
  163. package/dist/shell-source-maps/assets/{list-page-BU1MrXbN.js.map → list-page-C8Z3OhmV.js.map} +1 -1
  164. package/dist/shell-source-maps/assets/{maplibre-BedvDUG2.js.map → maplibre-BOVzS79J.js.map} +1 -1
  165. package/dist/shell-source-maps/assets/{markdown-content-BlKajH2l.js.map → markdown-content-BMDl_vl_.js.map} +1 -1
  166. package/dist/shell-source-maps/assets/{members-page-BYUO0Dq2.js.map → members-page-O752tFj8.js.map} +1 -1
  167. package/dist/shell-source-maps/assets/{messages-DQ0cj-Ao.js.map → messages-TLh-JbDm.js.map} +1 -1
  168. package/dist/shell-source-maps/assets/{organization-page-BrC1nHC-.js.map → organization-page-DDwBkk8F.js.map} +1 -1
  169. package/dist/shell-source-maps/assets/{organizations-page-CaUeWdr4.js.map → organizations-page-DNYezYgw.js.map} +1 -1
  170. package/dist/shell-source-maps/assets/{pending-invitation-row-juUdWvG6.js.map → pending-invitation-row-DRjEfn76.js.map} +1 -1
  171. package/dist/shell-source-maps/assets/{period-chart-BUZhUb5l.js.map → period-chart-B_Vtp_OD.js.map} +1 -1
  172. package/dist/shell-source-maps/assets/{person-row-DH3JhMfz.js.map → person-row-ehgAozYT.js.map} +1 -1
  173. package/dist/shell-source-maps/assets/{public-form-page-d3TamPPE.js.map → public-form-page-JM_r4BIq.js.map} +1 -1
  174. package/dist/shell-source-maps/assets/{record-lines-NtlHP9Lz.js.map → record-lines-B8maPngL.js.map} +1 -1
  175. package/dist/shell-source-maps/assets/{record-map-BDXoF9AS.js.map → record-map-BJI9HhZO.js.map} +1 -1
  176. package/dist/shell-source-maps/assets/{record-opens-C1KgR6ff.js.map → record-opens-BP2LRuAM.js.map} +1 -1
  177. package/dist/shell-source-maps/assets/{record-page-D88DdoET.js.map → record-page-DsLORKNo.js.map} +1 -1
  178. package/dist/shell-source-maps/assets/{record-preview-BT9_Hdcn.js.map → record-preview-BDMeb9qp.js.map} +1 -1
  179. package/dist/shell-source-maps/assets/{records-map-BjHcY5gU.js.map → records-map-D2IAAn9Z.js.map} +1 -1
  180. package/dist/shell-source-maps/assets/{render-node-v6KfRocH.js.map → render-node-CAL7-6hf.js.map} +1 -1
  181. package/dist/shell-source-maps/assets/{reorder-button-B3GeKMOJ.js.map → reorder-button-D9hO_nqd.js.map} +1 -1
  182. package/dist/shell-source-maps/assets/{run-trace-view-Ddc0SELh.js.map → run-trace-view-CqCld741.js.map} +1 -1
  183. package/dist/shell-source-maps/assets/{runner-install-field-CiD9Pw1j.js.map → runner-install-field-Cpd0yW2w.js.map} +1 -1
  184. package/dist/shell-source-maps/assets/{runtime-update-CoXcnfxB.js.map → runtime-update-Cg98ENel.js.map} +1 -1
  185. package/dist/shell-source-maps/assets/{sheet-source-DbJu1SrV.js.map → sheet-source-fKebPN-3.js.map} +1 -1
  186. package/dist/shell-source-maps/assets/{sign-in-policy-page-B40iAeJa.js.map → sign-in-policy-page-DtxdycdZ.js.map} +1 -1
  187. package/dist/shell-source-maps/assets/{start-block-queries-C_udrEM9.js.map → start-block-queries-DIJZ-fEE.js.map} +1 -1
  188. package/dist/shell-source-maps/assets/{step-catalog-7obnZV6X.js.map → step-catalog-DefIkvlp.js.map} +1 -1
  189. package/dist/shell-source-maps/assets/{step-panel-BM_xu6Yy.js.map → step-panel-DhFvGljv.js.map} +1 -1
  190. package/dist/shell-source-maps/assets/{timeline-display-CdLfWAbQ.js.map → timeline-display-CsGry__i.js.map} +1 -1
  191. package/dist/shell-source-maps/assets/{trash-BHo3HvFy.js.map → trash-B3Zy6Kx1.js.map} +1 -1
  192. package/dist/shell-source-maps/assets/{update-set-DTikSoau.js.map → update-set-C_skfvwV.js.map} +1 -1
  193. package/dist/shell-source-maps/assets/{use-calendar-move-Bhha2yOp.js.map → use-calendar-move-CZtjDwpL.js.map} +1 -1
  194. package/dist/shell-source-maps/assets/{use-display-rows-CS_0O_UE.js.map → use-display-rows-DHVZ49lA.js.map} +1 -1
  195. package/dist/shell-source-maps/assets/{use-paged-search-ChxCRCpF.js.map → use-paged-search-COK4rUdF.js.map} +1 -1
  196. package/dist/shell-source-maps/assets/{use-run-trace-BfRRgSgG.js.map → use-run-trace-CRPYmppF.js.map} +1 -1
  197. package/dist/shell-source-maps/assets/{use-workflow-page-CTdBd8_8.js.map → use-workflow-page-NQnBpQBn.js.map} +1 -1
  198. package/dist/shell-source-maps/assets/{use-workflow-types-cZQ59ATf.js.map → use-workflow-types-BONTV-ip.js.map} +1 -1
  199. package/dist/shell-source-maps/assets/{workflow-canvas-B0kWJeH0.js.map → workflow-canvas-wK7am90B.js.map} +1 -1
  200. package/dist/shell-source-maps/assets/{workflow-field-DXIk6V2Y.js.map → workflow-field-D4NB5B1z.js.map} +1 -1
  201. package/dist/shell-source-maps/assets/{workflow-graph-editor-Cem4aY2u.js.map → workflow-graph-editor-CBPqhazd.js.map} +1 -1
  202. package/dist/shell-source-maps/assets/{workflow-run-field-BeMn3eOH.js.map → workflow-run-field-C1N-mmHl.js.map} +1 -1
  203. package/dist/shell-source-maps/assets/{workflow-status-field-0wvGDiva.js.map → workflow-status-field-DEgDvkpV.js.map} +1 -1
  204. package/dist/shell-source-maps/assets/{workflow-workbench-qT5c0xnH.js.map → workflow-workbench-mJR1exSe.js.map} +1 -1
  205. package/dist/status/messages.d.ts +2 -2
  206. package/dist/users/messages.d.ts +2 -2
  207. package/package.json +5 -5
  208. package/dist/shell-source-maps/assets/app-DTl8rg8j.js.map +0 -1
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-CgjfBK_g.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-DTl8rg8j.js","assets/vendor-t7Q7QbPu.js","assets/app-BAQxWF5r.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{$a as r,$n as i,$o as a,$s as o,$t as s,Al as c,As as l,At as u,B as d,Ba as f,Bc as p,Bi as m,Bo as h,Br as g,C as _,Cc as v,Cl as y,Cn as b,D as x,Ds as S,Ec as C,En as w,Es as T,F as E,Fn as ee,Go as te,Gt as ne,Ha as re,Ho as D,Hs as ie,In as ae,Io as oe,Ir as se,Jn as ce,Js as O,Jt as le,Ko as k,Ks as ue,Ln as de,Lo as fe,Lr as pe,M as me,Ma as he,Mc as A,Mo as ge,Ms as _e,Mt as ve,No as ye,Nr as be,Ns as xe,Nt as Se,Oa as Ce,Oi as we,Os as Te,Pn as Ee,Pt as De,Qc as Oe,Qi as ke,Qn as Ae,Qo as je,Qs as Me,R as Ne,Rn as Pe,Ro as j,Sa as Fe,Sl as Ie,Ts as Le,Ua as Re,Uc as ze,Un as Be,Uo as Ve,Us as He,V as Ue,Va as M,Vi as We,Vo as N,Vs as Ge,Wo as P,Ws as Ke,Xa as qe,Xo as Je,Xt as Ye,Yc as Xe,Yn as Ze,Yo as F,Ys as I,Za as Qe,Zc as $e,Zi as et,Zs as L,_ as tt,_a as nt,_n as rt,_t as it,aa as at,at as ot,b as st,bo as R,bs as ct,cn as lt,cr as z,cs as B,da as ut,dr as dt,ds as ft,ea as pt,fr as V,fs as H,gc as mt,gl as ht,gn as gt,gs as _t,gt as vt,hi as yt,hl as bt,hn as xt,hs as St,i as Ct,ia as wt,il as Tt,in as U,ir as Et,ja as Dt,jc as W,js as Ot,jt as kt,k as At,ki as jt,ks as Mt,lc as Nt,ln as Pt,lr as Ft,ls as G,mn as It,mr as K,ms as Lt,nl as Rt,nn as zt,nr as Bt,ns as Vt,on as Ht,oo as Ut,or as Wt,pc as Gt,pn as Kt,pr as qt,ps as Jt,qa as Yt,qc as Xt,qo as Zt,rn as Qt,s as $t,sn as en,sr as q,tn,tr as nn,un as rn,ur as an,us as on,v as sn,va as cn,vn as ln,vs as un,wn as dn,ws as fn,wt as pn,xi as mn,xs as hn,y as gn,ya as _n,yi as vn,yn,ys as bn,zc as xn,zi as Sn,zo as J,zs as Cn}from"./app-DTl8rg8j.js";import{C as wn,f as Tn,o as En,s as Dn}from"./vendor-t7Q7QbPu.js";import{C as On,Ct as kn,Dt as An,Et as jn,Mt as Mn,O as Nn,Ot as Pn,Q as Fn,St as In,Tt as Ln,X as Rn,Z as zn,_t as Bn,at as Vn,b as Hn,ct as Un,dt as Wn,ft as Gn,gt as Kn,it as qn,k as Jn,kt as Yn,l as Xn,lt as Zn,mt as Qn,n as $n,nt as er,o as tr,ot as nr,rt as rr,st as ir,t as ar,tt as or,ut as sr,wt as cr,x as lr,xt as ur,y as dr}from"./embedded-list-56J4XDiR.js";import{t as fr}from"./circle-alert-CANqQIsU.js";import{t as pr}from"./page-header-Ddz2r5ic.js";import{n as mr,t as hr}from"./pending-invitation-row-juUdWvG6.js";import{n as gr,t as _r}from"./person-row-DH3JhMfz.js";import{n as vr,t as yr}from"./use-paged-search-ChxCRCpF.js";import{n as br,t as xr}from"./client-publisher-D39SlIhp.js";import{t as Sr}from"./copy-field-CamvXHHQ.js";var Cr={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`}]]};Cr.node;var wr=W(Cr),Tr={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`}]]};Tr.node;var Er=W(Tr),Dr={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`}]]};Dr.node;var Or=W(Dr),kr={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`}]]};kr.node;var Ar=W(kr),jr={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`]};jr.node;var Mr=W(jr),Nr={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`}]]};Nr.node;var Pr=W(Nr),Fr={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`}]]};Fr.node;var Ir=W(Fr),Lr={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`}]]};Lr.node;var Rr=W(Lr),zr=[`done`,`error`,`running`];_e(`TextField`,!1),_e(`NumberField`,!1),_e(`DateField`,!1),_e(`BooleanField`,!1),_e(`UrlField`,!1),_e(`ChipField`,!1);var Br=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Vr=e=>typeof e!=`string`&&!e.custom&&Br.has(e.type),Hr=e=>typeof e==`string`||Vr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Ur=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Wr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),Gr=(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)},Kr=(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)},qr=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,Jr=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Yr=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:Jr.has(`${n.toLowerCase()}:`)?e:void 0},Xr=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),Zr=e=>e==null||e===``?void 0:String(e),Qr=(e,t)=>e<t?-1:+(e>t),$r=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=Zr(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=Zr(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=>Zr(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=Zr(e[i.source]),s=Zr(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)=>Qr(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>Qr(e.id,t.id)),edges:s.sort((e,t)=>Qr(e.source,t.source)||Qr(e.target,t.target)||Qr(e.id,t.id))}},Y=e(t(),1),X=e(n(),1),ei=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=F(),s=kn(e.name,void 0),c=Sn(),[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=>It(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let m=f.length-p.length,h=ur(`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)(L,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>jn(d)?u(!0):void g(),children:h}),l&&(0,X.jsx)(Ln,{action:d,label:h,danger:i===`danger`||i===void 0&&An(d),records:p.map(e=>e.record),names:p.map(t=>In(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),g()},onSubmit:async e=>{u(!1),await g(e)}})]})},ti=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=Wt(),c=cr(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)(L,{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:()=>jn(c.action)?u(!0):void c.run(),children:d}),l&&(0,X.jsx)(Ln,{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)}})]})},ni=({node:e,className:t})=>{let n=U(e),r=dt(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,X.jsx)(ei,{...n,model:i,items:r.items,className:t}):(0,X.jsx)(ti,{...n,className:t})},ri=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=U(e);return(0,X.jsx)(V,{title:i,description:a,actions:n.actions,className:A(`h-full`,r),children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},ii=({children:e,wrap:t=(e,t)=>(0,X.jsx)(Y.Fragment,{children:e},t)})=>{let n=dt();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...It(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,X.jsx)(Bt,{value:s,row:{index:o,count:i.length},children:e}),c)})},ai=({children:e})=>(0,X.jsx)(ii,{children:e}),oi=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=tn(t),f=rt(e,{filter:n,sort:r,pageSize:i,enabled:!d}),p=d??f,m=d?d.rows:f.data?.items??[];return(0,X.jsx)(V,{title:a,description:o,actions:c,className:u,children:p.isPending?(0,X.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(O,{className:`h-24 w-56`},t))}):p.error?(0,X.jsx)(K,{title:M(`couldNotLoad`),error:p.error}):m.length===0?(0,X.jsx)(qt,{children:s??M(`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)(Ft,{value:{model:e,items:m,...d&&{planned:!0}},children:(0,X.jsx)(ii,{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:l})})})})},si=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=U(e),o=F().resources[i];return o?(0,X.jsx)(oi,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},ci=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=U(e),{resources:u,views:d}=F(),f=u[r];return f?(0,X.jsx)(V,{title:i,description:a,actions:t.actions,className:A(`h-full`,n),children:(0,X.jsx)(Gn,{model:f,view:d[r],...l})}):null},li=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=gt(e,t),a=i.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(O,{className:`h-4 w-1/2`}),(0,X.jsx)(O,{className:`h-4 w-1/3`})]}):i.error?(0,X.jsx)(K,{title:M(`couldNotLoad`),error:i.error}):i.data?(0,X.jsx)(Bt,{value:i.data,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,X.jsx)(qt,{children:M(`nothingYet`)});return(0,X.jsx)(`div`,{className:n,children:a})},ui=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},di=e=>e==null?``:String(e),fi=(e,t,n)=>n===0?0:(e-t)/n*100,pi=(e,t,n)=>{let r=new Map;for(let i of e){let e=ui(i[t.start]);if(e===void 0)continue;let a=ui(i[t.end]),o=Math.max(e,a??n),s=r.get(di(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(di(i[t.lane]),s);let c=s.bars.get(di(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(di(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},mi=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},hi=(e,t,n)=>{let r=pi(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:fi(n,a,s),width:fi(r,a,s)-fi(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:fi(o,a,s),width:fi(c,a,s)-fi(o,a,s),segments:i}});return{key:e,value:n.value,rows:mi(r)}}),from:a,to:o}},gi=(e,t)=>{let n=e.end-e.start;return{left:fi(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},_i=6e4,vi=60*_i,Z=24*vi,yi=[5*_i,15*_i,30*_i,vi,3*vi,6*vi,12*vi,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],bi=365*Z,xi=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Si=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=yi.find(n=>xi(e,t,n,i,a)<=6)??Math.ceil(r/5/bi)*bi,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:fi(a,e,r)})}return{daily:o>=Z,ticks:s}},Ci=e=>({lane:di(e.lane),bar:e.key}),wi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ti=(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},Ei=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Di=({from:e,to:t,dated:n})=>{let r=n?`UTC`:ut(),i=e=>n?0:Ti(e,r),{daily:a,ticks:o}=Si(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 ${Ei(e.left)}`,style:{left:`${e.left}%`},children:a?pt(e.at+i(e.at)):at(e.at,r)},e.at))})},Oi=(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&&Tt(a)?{className:te[a],striped:i}:{color:Kn(e,t,n===void 0?null:n,-1),striped:i}},ki=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)`}}),Ai=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Oi(t,n,r.value),{left:o,width:s}=gi(e,r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:A(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...ki(a)}},i)}),ji=(e,t)=>t?et(e):ke(e),Mi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return M(`timelineRange`,{from:ji(n,a),to:i?M(`timelineNow`):ji(r,a)})},Ni=(e,t,n,r)=>`${yt(t.fields[r.color],e.value,n?.fields[r.color])}: ${Mi(t,r,e.start,e.end,e.open)}`,Pi=(e,t,n,r,i)=>{let a=e.segments.some(t=>t.open&&t.end===e.end);return[`${i??yt(t.fields[r.bar],e.value,n?.fields[r.bar])}: ${Mi(t,r,e.start,e.end,a)}`,...e.segments.map(e=>Ni(e,t,n,r))].join(`; `)},Fi=`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`,Ii=({bar:e,model:t,view:n,fields:r,point:i,choose:a})=>{let o=F().resources[t.fields[r.bar]?.relation?.resource??``],s=w(o??t,e.key,o!==void 0),c=Pi(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)(Ai,{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:Fi,...l,children:d});let f=a.chosen===e.key;return(0,X.jsx)(ue,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:A(Fi,f&&`ring-2 ring-foreground`),...l,children:d})},Li=({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)(Di,{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)(yn,{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)(Ii,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ri=({model:e,view:t,fields:n,value:r})=>{let i=Oi(e.fields[n.color],t?.fields[n.color],r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:A(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:ki(i)})},zi=({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)(Ri,{...t,value:e}),yt(n,e,t.view?.fields[t.fields.color])]},e))})},Bi=({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:M(`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)(yn,{model:n,field:n.fields[i.bar],value:e.value})}),(0,X.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Mi(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)(Ri,{...t,value:e.value}),yt(n.fields[i.color],e.value,r?.fields[i.color]),`: `,Mi(n,i,e.start,e.end,e.open)]},a))})]})},Vi=500,Hi=(e,t,{filter:n=``,sort:r,fields:i,limit:a})=>({queryKey:[...xn.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(Vi,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}}}),Ui=(e,{enabled:t=!0,...n})=>En({...Hi(Vt(),e,n),enabled:t,placeholderData:Tn}),Wi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=S,title:s,description:c,empty:l,actions:u,className:d,choose:f,details:p})=>{let[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),v=e=>e?Ci(e):null,y={hover:e=>h(v(e)),focus:e=>_(v(e))},b=tn(i),x=Ui(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!b}),C=b??x,w=b?b.rows:x.data?.rows??[],T=!b&&x.data?.cut===!0,E=hi(w,n,Date.now());return(0,X.jsxs)(V,{title:s,description:c,actions:u,className:A(`h-full`,d),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)(O,{className:`h-6`},t))});if(C.error)return(0,X.jsx)(K,{title:M(`couldNotLoad`),error:C.error});if(E.lanes.length===0)return(0,X.jsx)(qt,{children:l??M(`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)(zi,{model:e,view:t,fields:n,values:r}),(0,X.jsx)(Li,{shape:E,model:e,view:t,fields:n,point:y,...f&&{choose:f}}),T&&(0,X.jsx)(qt,{children:M(`timelineCut`,{count:w.length})}),(0,X.jsx)(`div`,{"aria-live":`polite`,children:(0,X.jsx)(Bi,{bar:wi(E,m)??wi(E,g),model:e,view:t,fields:n})})]})})(),p]})},Gi=(e,t)=>e.type===`integer`?Number(t):t,Ki=({select:e,children:t,...n})=>{let{given:r,linkTo:a}=i(),o=r[e],s=t=>a({[e]:t}),c=n.model.fields[n.fields.bar],l=o===void 0?null:(0,X.jsx)(Ke,{name:e,children:(0,X.jsx)(li,{model:n.model,query:{filter:Bn(c,Gi(c,o),n.filter),sort:n.sort},children:t},o)});return(0,X.jsx)(Wi,{...n,choose:{barTo:s,chosen:o},details:l})},qi=({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}=U(e),{resources:h,views:g}=F(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Te(e),sort:Mt(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,X.jsx)(Wi,{...v}):(0,X.jsx)(Ki,{...v,select:s,children:r})},Ji=({node:e,children:t})=>{let n=Ot(e),r=nn(),{resources:i}=F();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)(Ke,{name:n.param,children:(0,X.jsx)(li,{model:o,query:{key:a},className:``,children:t},a)})},Yi=(0,Y.lazy)(()=>wn(()=>import(`./graph-view-CgjfBK_g.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]))),Xi=(0,X.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,X.jsx)(o,{})}),Zi=({node:e,at:t,slots:n,children:r,className:i})=>{let a=U(e),o=s(e,t),c=nn(),l=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([l?.rows,u?.rows,g]),v=(0,Y.useMemo)(()=>l&&u&&$r({nodes:l.rows,edges:u.rows,key:l.model.primaryKey[0],edgeKey:u.model.primaryKey,fields:g}),[_]);if(!l||!u||!v)return null;let y=l.error??u.error;if(y&&e.fallback)throw y;if(y)return(0,X.jsx)(K,{title:M(`couldNotLoad`),error:y});if(l.isPending||u.isPending)return Xi;if(v.nodes.length===0)return(0,X.jsx)(qt,{children:a.empty??M(`nothingYet`)});let b=a.select,x=b!==void 0&&c?{chosen:c.given[b],linkTo:e=>c.linkTo({[b]:e})}:void 0;return(0,X.jsxs)(`div`,{className:A(`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:Xi,children:(0,X.jsx)(Yi,{shape:v,nodes:l,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)(Ji,{node:e,children:r})})]})},Q=p(`app/conversation`),Qi=({resource:e,field:t,values:n,placeholder:r})=>{let{resources:i}=F(),a=Vt(),o=ln(),s=Je(e),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)();return!i[e]||!Fe(s,`create`)?null:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[u!==void 0&&(0,X.jsx)(K,{title:Q(`notSent`),error:u}),(0,X.jsx)(pn,{onSend:async r=>{l(!0),d(void 0);let i=await a.create(e,{...n,[t]:r}).then(()=>!0,e=>(d(e),!1));return l(!1),i&&o(e),i},busy:c,placeholder:r})]})},$i=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=U(e);return(0,X.jsx)(Qi,{resource:t,field:n,values:r,placeholder:i})},ea=({node:e,children:t,className:n})=>{let{open:r}=U(e);return(0,X.jsx)(`details`,{open:r,className:A(`[&[open]>summary]:mb-2`,n),children:t})},ta=({children:e,className:t})=>(0,X.jsx)(`summary`,{className:A(`cursor-pointer font-medium`,t),children:e}),na=({node:e,className:t})=>{let{source:n,emptyText:r}=U(e),i=Pt(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,X.jsx)(O,{className:A(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,X.jsx)(`p`,{className:A(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=vt(a);return o?(0,X.jsx)(`div`,{className:A(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,X.jsx)(it,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,X.jsx)(`pre`,{className:A(`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})},ra=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),ia=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>Oe(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},aa=({node:e,className:t})=>{let{source:n,label:r,format:i}=U(e),{views:a}=F(),o=Pt(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,X.jsx)(O,{className:`h-4 w-24`}):o.state===`plain`?ra(o.value):(0,X.jsx)(yn,{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??ia(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:A(`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})]})},oa={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},sa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ca={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`},la=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ua=({node:e,children:t,className:n})=>{let{columns:r=2}=U(e),i=e.children,a=i.length>0&&i.every(la);return(0,X.jsx)(`div`,{className:A(`grid grid-cols-1 gap-4`,a?sa[r]:oa[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:A(`min-w-0`,r&&ca[r]),children:e},t)})})},da=({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`}),fa=({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}}),ma=e=>e instanceof Blob&&e.type.startsWith(`image/`),ha=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},ga=e=>{let[t,n]=(0,Y.useState)();return[t!==void 0&&t===e,()=>n(e)]},_a=({name:e,alt:t,width:n,height:r,refresh:i,className:a})=>{let o=Vt(),{theme:s}=he(),[c,l]=ot(),u=fa({width:n,height:r,space:l,theme:s}),d=En({queryKey:xn.image(e,u??{}),enabled:u!==void 0,placeholderData:Tn,...pa(i),queryFn:async()=>{let t=await o.invoke(e,{query:u,cache:`no-store`});if(!ma(t))throw Error(`The function "${e}" answered no picture`);return t}}),f=ha(d.data),[p,m]=ga(f),h={...n!==void 0&&{width:n},...r!==void 0&&{height:r}};return(0,X.jsx)(`div`,{ref:c,className:A(`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)(O,{className:`w-full max-w-full`,style:{height:r??160,...n!==void 0&&{width:n}}})})},va=({node:e,className:t})=>{let n=U(e);return n.src===void 0?(0,X.jsx)(_a,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,X.jsx)(da,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},ya=e=>function({node:t,className:n}){let r=U(t),{views:i}=F(),a=Pt(r.source);return a.state===`missing`?null:a.state===`loading`?(0,X.jsx)(O,{className:`inline-block h-3 w-16 align-middle`}):Ur(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})})},ba=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?$e(e,n?.valueLabels):Wr(e),xa=ya(ba),Sa=ya(({value:e,props:t})=>(0,X.jsx)(`span`,{className:`tabular-nums`,children:Gr(e,t,ze())})),Ca=ya(({value:e,props:t})=>{let n=Kr(e,t,{locale:ze(),now:Date.now(),relative:wt});return(0,X.jsx)(`time`,{dateTime:String(e),children:n})}),wa=ya(({value:e,props:t})=>{let n=qr(e,t,{yes:we(`yes`),no:we(`no`)});return e?(0,X.jsx)(Be,{label:n,className:`align-middle`}):(0,X.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ta=ya(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=Yr(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})}),Ea=ya(e=>(0,X.jsx)(dn,{value:e.value,hints:e.hints,children:ba(e)})),Da=`font-medium text-primary-text hover:underline`,Oa=({node:e,children:t,className:n})=>{let r=U(e),i={...z(q()),params:Ae()},a=r.variant?A(Me({variant:r.variant}),n):n??Da,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=Ie(r.to,St(i));return(0,X.jsx)(se,{to:e,className:a,children:o??Cn(e)})}let s=r.href??``;return(0,X.jsx)(`a`,{href:s,className:a,...s.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??s})},ka=(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]:x(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:x(i)]})),Aa=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return $t(r)?r.key===x(n[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:_(i,r,n[t])?[[t,At(i,r)]]:[]})),ja=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=F(),u=Vt(),d=Dt(),f=ln(),p=l[e.name],[m,h]=(0,Y.useState)(()=>ka(e,a,t?.record)),[g,_]=(0,Y.useState)({}),[v,y]=(0,Y.useState)(0),b=tt(v),[x,S]=(0,Y.useState)(),[C,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(!1);ie(T||C,`input-lost`);let ee=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...Ct(e,c,m),...o}):u.update(e.name,t.key,Aa(e,m,t.record),t.etag??`*`)).then(async()=>{await f(e.name),d.show({state:`success`,title:M(`saved`,{label:i??r})}),s()},e=>{let t=sn(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,X.jsx)(I,{title:i??r,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:s,children:M(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:C,onClick:()=>void ee(),children:M(n===`create`?`create`:`save`)})]}),children:(0,X.jsxs)(`form`,{ref:b,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),ee()},children:[x!==void 0&&Object.keys(g).length===0&&(0,X.jsx)(K,{title:M(`notSaved`),error:x}),a.map(n=>{let r=e.fields[n],i=m[n],a=r.relation?c[r.relation.resource]:void 0,o=p?.fields[n]?.label??Oe(n),s=g[n];return(0,X.jsx)(Ne,{name:n,label:o,help:p?.fields[n]?.help,error:s&&gn(r,o,s),children:(0,X.jsx)(st,{field:r,hints:p?.fields[n],value:$t(i)?i.key:i,stored:t?.record[n],relationLabel:$t(i)?i.label:void 0,relationPicker:a?{target:a,view:l[a.name]}:void 0,invalid:!!g[n],resource:e.name,onChange:e=>{_(({[n]:e,...t})=>t),E(!0),h(t=>({...t,[n]:e}))}})},n)})]})})},Ma=({model:e,recordKey:t,children:n})=>{let r=gt(e,{key:t});return(0,X.jsx)(X.Fragment,{children:n(r.data??void 0)})},Na=({node:e})=>{let t=U(e),n=Wt(),{resources:r}=F(),i=r[t.resource??n?.model.name??``],a=Je(i?.name??``),[o,s]=(0,Y.useState)(!1);if(!i||!(t.mode===`create`?Fe(a,`create`):Fe(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,X.jsx)(ja,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,X.jsx)(Ma,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},Pa=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=U(e);return(0,X.jsx)(`div`,{className:A(`flex-1`,r),children:(0,X.jsxs)(`div`,{className:A(`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)(pr,{title:i,subtitle:a,actions:n.actions}),t]})})},Fa=(e,t)=>{let n=q(),r=typeof e==`string`?Et(n,e):void 0,i=en(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},Ia=({node:e,className:t})=>{let{value:n,max:r,label:i}=U(e),a=Fa(n,0),o=Fa(r,100);if(a===void 0||o===void 0)return(0,X.jsx)(O,{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:A(`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(ze()),` / `,o.toLocaleString(ze())]})]}),(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}%`}})})]})},La=({model:e,at:t,filter:n,sort:r,recordKey:i,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=tn(t),f=gt(e,{filter:n,sort:r,key:i,enabled:!d}),p=d?Kt(e,d):f,m=e=>p.data?(0,X.jsx)(Bt,{value:p.data,children:e}):void 0,h=p.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(O,{className:`h-4 w-1/2`}),(0,X.jsx)(O,{className:`h-4 w-1/3`})]}):p.error?(0,X.jsx)(K,{title:M(`couldNotLoad`),error:p.error}):p.data?m((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:l})):(0,X.jsx)(qt,{children:s??M(`nothingYet`)});return(0,X.jsx)(V,{title:a,description:o,actions:c?m(c):void 0,className:A(`h-full`,u),children:h})},Ra=({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}=U(e),f=F().resources[a];return f?(0,X.jsx)(La,{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},za=p(`app/related-cards`),Ba=({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:A(`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)(L,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:za(n?`showLess`:`showMore`)})]})},Va=e=>e==null||e===``,Ha=({scope:e,path:t,labelled:n=!0,clamped:r=!1})=>{let{views:i}=F(),a=en(e,t);if(a.state===`missing`||a.state===`ready`&&Va(a.value))return null;let o=a.state===`loading`?(0,X.jsx)(O,{className:`h-4 w-24`}):(0,X.jsx)(yn,{model:a.model,field:a.field,value:a.value}),s=r?(0,X.jsx)(Ba,{children:o}):o;if(!n)return(0,X.jsx)(`div`,{className:`min-w-0`,children:s});let c=ia(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})]})},Ua=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:s})=>{let c=Sn(),{resources:l}=F(),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:A(`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)(le,{view:t,field:i,record:e.record}),(0,X.jsxs)(`div`,{className:A(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,X.jsx)(se,{to:{kind:`record`,resource:e.model.name,key:We(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)(Ha,{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)(Ha,{scope:e,path:t,labelled:!1})},t))}),d&&(0,X.jsx)(Bt,{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)(or,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,X.jsx)(ti,{name:e,about:u,onRun:e=>s?.(e,u)},e))]})})]})},Wa=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let s=Sn(),{resources:c}=F(),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)(le,{view:t,field:r,record:e.record}),(0,X.jsx)(se,{to:{kind:`record`,resource:e.model.name,key:We(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)(Ha,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,X.jsx)(Bt,{value:e,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,X.jsx)(or,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,X.jsx)(ti,{name:e,about:l,onRun:e=>o?.(e,l)},e))]})})]})},Ga=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,Ka=e=>[...e.querySelectorAll(`button`)].find(Ga)??e.querySelector(`a`),qa=(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)},Ja=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},Ya=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(za(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=qa(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?Ka(s):Ja(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}},Xa=({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)(O,{className:e?`h-17.5 w-full max-sm:h-24`:`h-24 w-full`},n))}),Za=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,button:o,limit:s,display:c,empty:l,carousel:u,compact:d,tone:f,planned:p})=>{let m=ye(),h=sr(),g=t?.names?.plural??Oe(e.name),_=r||jt(e,t),v=rt(e,{filter:n,sort:_,pageSize:s,enabled:!p}),y=xt(e,n,!p),b=p?p.rows:{isPending:v.isPending,error:v.error},x=p?p.rows.rows:v.data?.items,S=p?{data:p.total&&!p.total.isPending&&!p.total.error?er(p.total):void 0}:y,C=(0,Y.useMemo)(()=>(x??[]).map(t=>It(e,t)),[e,x]),w=Ya((0,Y.useMemo)(()=>C.map(e=>e.key),[C]));return(0,X.jsxs)(`div`,{ref:w.root,children:[(()=>{if(b.isPending)return(0,X.jsx)(Xa,{compact:!!d,limit:s});if(b.error)return(0,X.jsx)(K,{title:za(`couldNotLoad`),error:b.error});if(C.length===0)return(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:l??za(`nothingYet`)});let r=C.map(e=>{let n=(t,n)=>w.acted(e.key,t,n);return d?(0,X.jsx)(Ua,{scope:e,view:t,fields:i,time:d.time,tone:f,actions:a,button:o,onActed:n},e.key):(0,X.jsx)(Wa,{scope:e,view:t,fields:i,tone:f,actions:a,button:o,onActed:n},e.key)}),p=S.data===void 0?void 0:Un(C.length,S.data,!1);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u===void 0?(0,X.jsx)(`ul`,{className:d?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,X.jsx)(Wn,{scroll:h,label:g,share:u,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:p}),(0,X.jsxs)(se,{to:nr(e,t,m,{filter:n,orderBy:_,display:rr(t,m,{preferred:c})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[Zn(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:g.toLowerCase()}),(0,X.jsx)(Mn,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:w.announcement})]})},Qa={"1/4":1/4,"1/3":1/3,"1/2":1/2,"2/3":2/3},$a=({node:e,at:t,slots:n,className:r})=>{let i=U(e),{resource:a,filter:o=``,sort:s=``,fields:c,cardActions:l=[],limit:u=10,display:d,title:f,description:p,empty:m}=i,{layout:h,cardWidth:g}=Xr(i),{resources:_,views:v}=F(),[y,b]=zt([t,t===void 0?void 0:`${t}#total`]),x=(0,Y.useMemo)(()=>y&&{rows:y,total:b},[y,b]),S=_[a];if(!S)return null;let C=v[S.name];return(0,X.jsx)(`section`,{className:A(`min-w-0`,r),"aria-label":f,children:(0,X.jsx)(E,{title:f,help:p,actions:n.actions,children:(0,X.jsx)(Za,{model:S,view:C,filter:o,sort:s,fields:c??Xt(S,C),actions:l,limit:u,display:d,empty:m,carousel:h===`carousel`?Qa[g]:void 0,...x&&{planned:x}})})})},eo=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=F(),o=g(i,a,e.name),s=Nn(e.name,t.listOf,!0),c=(t.names?.plural??Oe(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,X.jsx)(K,{title:On(`couldNotLoadYour`,{plural:c}),error:s.error});if(!s.data)return(0,X.jsx)(O,{className:`h-24`});let l=Jn(o.model,s.data);return l?(0,X.jsx)(lr,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??On(`noneYet`,{plural:c})})},to=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=Rt(We(e,i)),{name:o,chips:s,title:c,body:l}=dr({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)(se,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,X.jsx)(Rn,{chips:s})})}),(0,X.jsx)(lr,{...l})]})},no=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=F(),a=t.searchesOf,o=r[a.resource],s=Hn(e.name,!0),c=(t.names?.plural??Oe(e.name)).toLowerCase();return o?s.error?(0,X.jsx)(K,{title:zn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??zn(`noneYet`,{plural:c})}):(0,X.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,X.jsx)(to,{model:e,view:t,target:o,targetView:i[a.resource],row:n},Rt(We(e,n))))}):(0,X.jsx)(O,{className:`h-40`}):null},ro=({node:e,slots:t,className:n})=>{let{resource:r,filter:i=``,sort:a,limit:o,display:s,title:c,description:l,empty:u}=U(e),{resources:d,views:f}=F(),p=d[r];if(!p)return null;let m=f[p.name];return(0,X.jsx)(V,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,X.jsx)(no,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,X.jsx)(lr,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,X.jsx)(eo,{model:p,view:m,limit:o,display:s,empty:u})})},io=e=>e.type===`boolean`||e.type===`enum`,ao=({model:e,fields:t,title:n,description:r,stored:i,className:a})=>{let{resources:o,views:s}=F(),c=Je(e.name),l=Vt(),u=Dt(),d=ln(),f=s[e.name],[p,m]=(0,Y.useState)(i),[h,g]=(0,Y.useState)(()=>ka(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=ka(e,t,void 0),ee=p?Fe(c,`update`)&&p.permissions?.update!==!1:Fe(c,`create`),te=t.filter(t=>!io(e.fields[t])),ne=te.some(t=>p?_(e.fields[t],h[t],p.record[t]):h[t]!==E[t]),re=async t=>{let n=T.current;if(n){let r=await l.update(e.name,n.key,Aa(e,t,n.record),n.etag??`*`);return{...It(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await l.create(e.name,Ct(e,o,{...E,...t}));return{...It(e,r.record),etag:r.etag}},D=t=>{let r=w.current.then(async()=>{C(!0),x(void 0),await re(t).then(async r=>{T.current=r,m(r),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await d(e.name),u.show({state:`success`,title:M(`saved`,{label:n??M(`settings`)})})},e=>{y(t=>({...t,...sn(e)})),x(e)}),C(!1)});w.current=r},ie=(t,n)=>{g(e=>({...e,[t]:n})),io(e.fields[t])&&D({[t]:n})};return(0,X.jsx)(V,{title:n,description:r,className:A(`h-full`,a),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),ne&&D(Object.fromEntries(te.map(e=>[e,h[e]])))},children:[b!==void 0&&Object.keys(v).length===0&&(0,X.jsx)(K,{title:M(`notSaved`),error:b}),t.map(t=>{let n=e.fields[t],r=f?.fields[t]?.label??Oe(t),i=v[t];return(0,X.jsx)(Ne,{name:t,label:r,help:f?.fields[t]?.help,error:i&&gn(n,r,i),children:(0,X.jsx)(st,{field:n,hints:f?.fields[t],value:h[t],stored:p?.record[t]??E[t],invalid:!!i,locked:!ee||n.readOnly,resource:e.name,onChange:e=>ie(t,e)})},t)}),ee&&ne&&(0,X.jsx)(`div`,{children:(0,X.jsx)(L,{type:`submit`,variant:`primary`,size:`sm`,loading:S,children:M(`save`)})})]})})},oo=e=>{let t=gt(e.model,{});return t.isPending?(0,X.jsx)(V,{title:e.title,description:e.description,className:e.className,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(O,{className:`h-4 w-1/2`}),(0,X.jsx)(O,{className:`h-4 w-1/3`})]})}):t.error?(0,X.jsx)(V,{title:e.title,description:e.description,className:e.className,children:(0,X.jsx)(K,{title:M(`couldNotLoad`),error:t.error})}):(0,X.jsx)(ao,{...e,stored:t.data??void 0})},so=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=U(e),o=F().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},co=(e,t)=>lo(e,t?[t]:[]),lo=(e,t)=>{let{resources:n}=F(),r=Vt(),i=JSON.stringify(e),a=(0,Y.useMemo)(()=>JSON.parse(i).map(T),[i]),o=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)),s=[...new Set(a.flatMap(e=>e.ok?e.paths:[]))],c=new Map(s.flatMap(e=>{let t=fn(e,o);return t===void 0?[]:[[e,t]]})),l=s.filter(e=>!c.has(e)),u=[...new Set(c.values())].flatMap(e=>n[e]?[n[e]]:[]),d=l.map(e=>Et(t,e)),f=lt(l.map((e,t)=>{let n=d[t];return n&&`frame`in n?{scope:n.frame,path:n.path}:{scope:void 0,path:e}})),p=Dn({queries:u.map(e=>rn(r,e))});return a.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=c.get(n);if(e===void 0){let e=l.indexOf(n),r=d[e];if(r&&`item`in r){t[n]=r.item;continue}let i=f[e];if(i.state===`loading`)return;i.state===`ready`&&(t[n]=i.value);continue}let r=u.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(p[r].isPending)return;else t[n]=p[r].data??0}return Le(e,t)})},uo=(e,t)=>typeof e.props.fallback==`string`?e.props.fallback:t.fallback,fo=({node:e,children:t,slots:n,className:r})=>{let{when:i}=U(e),[a]=lo([i],q());if(a===void 0)return null;let o=a?t:uo(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(Lt(e,z(t)).props.when)]),mo=({node:e,children:t,slots:n,className:r})=>{let i=q(),a=lo(po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?uo(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})},ho=({children:e})=>(0,X.jsx)(X.Fragment,{children:e}),go=`text-2xl font-semibold tracking-tight tabular-nums`,_o=({model:e,at:t,filter:n})=>{let{views:r}=F(),i=tn(t),a=xt(e,n,!i),o=i??a;if(o.isPending)return(0,X.jsx)(O,{className:`h-8 w-16`});if(o.error)return(0,X.jsx)(`span`,{className:`text-danger-text`,children:M(`couldNotCount`)});let s=i?er(i):a.data;return(0,X.jsx)(se,{to:Qn(r[e.name],e.name,n),className:`${go} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:s.toLocaleString(ze())})},vo=({field:e,format:t})=>{let n=Pt(e);return n.state===`loading`?(0,X.jsx)(O,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,X.jsx)(`span`,{className:go,children:ra(n.value)}):(0,X.jsx)(`span`,{className:go,children:(0,X.jsx)(yn,{model:n.model,field:n.field,value:n.value,format:t})})},yo=({node:e,at:t,className:n})=>{let{label:r,value:i,resource:a,filter:o,field:s,format:c,description:l}=U(e),{resources:u}=F(),d=a===void 0?void 0:u[a];return(0,X.jsxs)(V,{className:A(`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:go,children:i}),d&&(0,X.jsx)(_o,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,X.jsx)(vo,{field:s,format:c})]}),l&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},bo=(e,t,n)=>{let r=ye(),i=qn(t),[a,o]=(0,Y.useState)(()=>Vn(localStorage,i)),s=(0,Y.useCallback)(e=>{o(e),ir(localStorage,i,e)},[i]);return[rr(e,r,{picked:a,preferred:n}),s]},xo=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:s,className:c})=>{let{resources:l,views:u}=F(),d=u[e.name],{fields:f}=Ce(),p=Fe(Je(e.name),`update`),{go:h,href:g}=pe(),_=ye(),v=!ge(),y=(0,Y.useMemo)(()=>n?.map(bn)??Xt(e,d),[n,e,d]),b=(0,Y.useMemo)(()=>Ht(e,d,y,{resources:l,views:u,fieldTypes:f}),[e,d,y,l,u,f]),x=(0,Y.useMemo)(()=>_?Qt(n)(b):b,[_,n,b]),S=(0,Y.useMemo)(()=>r?Xn(x,e,d,r,l,v):x,[x,e,d,r,l,v]),C=(0,Y.useMemo)(()=>t.map(t=>({...t,id:m(e,t)})),[t,e]),w=(0,Y.useMemo)(()=>({total:C.length,rowAt:e=>C[e]}),[C]),T=tr({model:e,view:d,opens:void 0,resources:l,views:u,canUpdate:p}),E=e=>({href:g(e),onFollow:()=>h(e)});return(0,X.jsx)(V,{title:i,description:a,actions:s,className:c,children:C.length===0?(0,X.jsx)(qt,{children:o??M(`nothingYet`)}):(0,X.jsx)(Fn,{fit:!0,columns:S,source:w,latencyMs:0,onOpenRow:e=>h(T.address(e)),rowLink:e=>E(T.address(e)),rowActions:T.actions(E),rowNumbers:!1,selectable:!1})})},So=e=>{let t=dt();return t?.model?(0,X.jsx)(xo,{...e,model:t.model,items:t.items}):null},Co=({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,_]=bo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?bt:g,y=(0,Y.useMemo)(()=>i?.map(bn),[i]),b=(0,Y.useMemo)(()=>Qt(i),[i]);return(0,X.jsxs)(V,{title:l,description:u,actions:(0,X.jsxs)(X.Fragment,{children:[!m&&(0,X.jsx)(ar,{view:t,value:v,onChange:_}),f]}),className:A(`h-full`,p),children:[(0,X.jsx)($n,{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]})},wo=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,children:c,...l}=U(e),{resources:u,views:d}=F(),[f,p]=zt([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)(So,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,X.jsx)(Co,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,X.jsx)(To,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},To=({select:e,children:t,...n})=>{let{given:r,linkTo:a}=i(),o=t=>a({[e]:t}),s=r[e],c=s===void 0?null:(0,X.jsx)(Ke,{name:e,children:(0,X.jsx)(li,{model:n.model,query:{key:s},children:t},s)});return(0,X.jsx)(Co,{...n,chosen:{rowTo:o,key:s,details:c}})},Eo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=_n(),{navigate:a}=He(),o=cn(e),s=nt(o,r),c=e=>i(e===o[0]?.name?void 0:e);return(0,X.jsxs)(`div`,{className:A(`flex flex-col gap-6`,n),children:[(0,X.jsxs)(`select`,{"aria-label":M(`tabs`),value:s?.name??``,onChange:e=>a(c(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!s&&(0,X.jsx)(`option`,{value:``,disabled:!0}),o.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,X.jsx)(`nav`,{"aria-label":M(`tabs`),className:`hidden border-b md:block`,children:(0,X.jsx)(`ul`,{className:`flex gap-1`,children:o.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Ge,{to:c(e.name),"aria-current":e===s?`page`:void 0,className:A(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===s?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),s?(0,X.jsx)(Y.Fragment,{children:t[o.indexOf(s)]},s.name):(0,X.jsx)(re,{children:M(`noTab`,{name:r??``})})]})},Do=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Oo=e=>e===void 0?1/0:Date.parse(e),ko=(e,t)=>{let n=e=>e.more&&e.items.length>0?Oo(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&&Oo(e.items[a].time)>=Oo(t.items[o].time)?e.items[a++]:t.items[o++];if(Oo(n.time)<r)break;i.push(n)}return i},Ao=({value:e,hints:t,mark:n})=>{let r=$e(e,t?.valueLabels);return n===`done`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(C,{"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)(o,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&vn(t?.valueColors,e)!==`red`?r:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,X.jsx)(fr,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},jo=({value:e})=>{let t=typeof e==`string`?Ee(e):e;return t===ee?(0,X.jsx)(de,{children:String(e)}):(0,X.jsx)(ae,{value:t})},Mo=({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]}),No=({call:e,statusHints:t})=>{let[n,r]=(0,Y.useState)(!1),i=(0,Y.useId)(),a=e.status!==void 0&&(0,X.jsx)(Ao,{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)(L,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,X.jsx)(v,{"aria-hidden":!0,className:A(`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)(Mo,{label:Q(`callInput`),children:(0,X.jsx)(jo,{value:e.input})}),e.result!==void 0&&(0,X.jsx)(Mo,{label:Q(`callResult`),children:(0,X.jsx)(jo,{value:e.result})}),e.error!==void 0&&(0,X.jsx)(Mo,{label:Q(`callError`),children:(0,X.jsx)(de,{children:e.error})})]})]})},Po=(e,t)=>e.map(e=>({kind:`message`,row:e,time:typeof e[t]==`string`?e[t]:void 0})),Fo=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}}},Io=(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&&De(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:Se(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:Fo(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},Lo=e=>zr.includes(e??``)?e:void 0,Ro=e=>e==null||e===``?void 0:String(e),zo=e=>`call:${JSON.stringify(e)}`,Bo=(e,t,n)=>{let r=Ro(e[n.status]),i=Lo(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:Ro(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}}},Vo=({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}},Ho=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,Y.useState)(!1),s=be(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]),Vo({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},Uo=(e,t,n)=>{let{views:r}=F(),i=e?.model.name??``,a=Ho(i,{filter:e?.filter,orderBy:e&&l(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>Bo(t,zo(We(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}},Wo=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,Go=(e,t)=>e.isLoading?t.loading:t.empty,Ko=e=>e.items.length>0&&!!e.error,qo=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),Jo=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},Yo=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:d,planned:f})=>{let{resources:p,views:m}=F(),h=on(),g=h?.state.kind===`signed-in`?h.state.user.id:void 0,_=n===void 0?[]:[n],v=ce(p,m,e,_),y=Ho(e.name,{filter:t,orderBy:l(r),pageSize:o,labels:v},f?.messages),x=Uo(d,o,f?.calls),S=Wo(y);if(S===`error`)return(0,X.jsx)(K,{title:Q(`couldNotLoad`),error:y.error,onRetry:qo(y)});if(S===`loading`)return(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(qt,{children:Q(`loadingMessages`)})});let C=Ze(p,e,_,y.items,y.labels),w=ko({items:x.calls,more:x.hasNextPage},{items:Po(C,r),more:y.hasNextPage}),T=Io(w,{key:t=>String(We(e,t)),sender:n,time:r,text:i,status:a}),E=a===void 0?void 0:m[e.name]?.fields[a],ee=e.fields[i]!==void 0&&mn(e.fields[i],m[e.name]?.fields[i]),te=T.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===g);return(0,X.jsxs)(X.Fragment,{children:[Ko(y)&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(K,{title:Q(`couldNotLoad`),error:y.error,onRetry:qo(y)})}),d&&x.list.error&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(K,{title:Q(`couldNotLoadCalls`),error:x.list.error,onRetry:qo(x.list)})}),(0,X.jsx)(u,{length:w.length,followKey:te?.key,working:c,empty:Go(x.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:y.hasNextPage||x.hasNextPage?()=>Jo([y,x.list]):void 0,loadingEarlier:y.isFetchingNextPage||x.isFetchingNextPage,children:T.map(e=>e.kind===`day`?(0,X.jsx)(ve,{label:e.label},e.key):e.kind===`call`?(0,X.jsx)(No,{call:e,statusHints:x.statusHints},e.key):(0,X.jsx)(kt,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,X.jsx)(Ao,{value:e.status,hints:E}),children:ee&&e.text!==``?(0,X.jsx)(b,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},Xo=({children:e})=>(0,X.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),Zo=({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}=U(e),{resources:g}=F(),[_]=lo(f===void 0?[]:[f],q()),[v,y]=zt([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:A(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,X.jsx)(E,{title:i,help:a,actions:n.actions,children:(0,X.jsx)(Xo,{children:(0,X.jsx)(Yo,{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}}})})})})},Qo=({children:e,className:t})=>(0,X.jsx)(`div`,{className:t,children:e}),$o=({children:e,className:t})=>(0,X.jsx)(`div`,{className:A(`flex`,t),children:e}),es=({children:e,className:t})=>(0,X.jsx)(`div`,{className:A(`flex flex-col`,t),children:e}),ts=({node:e,children:t,className:n})=>{let{as:r=`p`}=U(e);return(0,X.jsx)(r,{className:n,children:t})},ns=({node:e,children:t})=>{let{source:n}=U(e),r=_t(z(q()),n),i=(0,Y.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,X.jsx)(Ft,{value:i,children:t})},rs=({node:e,className:t})=>{let{source:n,choices:r,label:a=n,defaultValue:o}=U(e),{values:s,linkTo:c}=i(),l=s[n];return(0,X.jsxs)(`div`,{className:A(`flex flex-wrap items-center gap-2`,t),children:[(0,X.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:a}),r?(0,X.jsx)(d,{label:a,value:l??``,options:r.map(e=>({value:String(e.id),label:e.name})),link:e=>c({[n]:o!==void 0&&e===String(o)?void 0:e})}):(0,X.jsx)(`span`,{children:l})]})},is=({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}}}},as=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,Y.useState)(!1),c=be(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]),is({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}})},os=({node:e,at:t,children:n})=>{let r=U(e),i=F().resources[r.reference],a=St(z(q())),o=tn(t);return i?(0,X.jsx)(ss,{model:i,...hn(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},ss=({empty:e,children:t,...n})=>{let{read:r,list:i}=as(n);return(0,X.jsx)(an,{read:r,list:i,empty:e,children:t})},cs=({node:e,at:t,children:n})=>{let r=U(e),i=F().resources[r.reference],a=St(z(q())),o=tn(t);return i?(0,X.jsx)(ss,{model:i,...ct(r,i.primaryKey[0],a),more:!1,empty:r.empty,...o&&{planned:o},children:n}):null},ls=({model:e,at:t,recordKey:n,link:r=`edit`,children:i,className:a})=>{let{views:o}=F(),s=tn(t),c=gt(e,{key:n,enabled:!s}),l=s?Kt(e,s):c;if(l.isPending)return(0,X.jsx)(O,{className:`h-4 w-24`});if(l.error)return(0,X.jsx)(K,{title:M(`couldNotLoad`),error:l.error});if(!l.data)return null;let u=i.length>0?(0,X.jsx)(Bt,{value:l.data,children:i}):Xe(e,o[e.name],l.data.record,n);return r===!1?(0,X.jsx)(`span`,{className:a,children:u}):(0,X.jsx)(se,{to:{kind:`record`,resource:e.name,key:n},className:a??`font-medium text-primary-text hover:underline`,children:u})},us=({node:e,at:t,children:n,className:r})=>{let{reference:i,source:a,link:o,empty:s}=U(e),c=F().resources[i],l=_t(z(q()),a);return c?l==null||l===``?s===void 0?null:(0,X.jsx)(`span`,{className:r,children:s}):(0,X.jsx)(ls,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},ds=(e,t)=>t.map(t=>Yt(e,t)).join(`, `),$=p(`users`),fs=({roles:e})=>{let{session:t}=G(),[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)(mr,{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)(gr,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,X.jsx)(N,{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)(hr,{email:n.email,gives:ds(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}=G(),[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}=Re(),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)(N,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,X.jsx)(D,{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)(R,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,X.jsx)(R,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,X.jsx)(R,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(gr,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,X.jsx)(`div`,{children:(0,X.jsx)(L,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},ms=({user:e,roles:t,self:n})=>{let{session:r}=G(),[i,a]=(0,Y.useState)(e),{busy:o,error:s,run:c,setError:l}=Re(),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)(_r,{name:i.name,email:i.email,self:n,error:s,actions:(0,X.jsxs)(X.Fragment,{children:[i.blocked&&(0,X.jsx)(P,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,X.jsx)(L,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,X.jsx)(L,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,X.jsx)(gr,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},hs=({roles:e,version:t})=>{let{session:n,state:r}=G(),[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=yr(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,X.jsx)(vr,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,X.jsx)(ms,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},gs=()=>{let{session:e}=G(),[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)();return(0,Y.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof H?k(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},_s=()=>{let{roles:e,error:t}=gs(),[n,r]=(0,Y.useState)(0);return(0,X.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,X.jsx)(D,{message:t}),(0,X.jsx)(hs,{roles:e,version:n}),(0,X.jsx)(fs,{roles:e}),(0,X.jsx)(ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},vs=({sender:e,busy:t,error:n,onSave:r,onClose:i})=>{let[a,o]=(0,Y.useState)(e?.address??``),[s,c]=(0,Y.useState)(e?.name??``),[l,u]=(0,Y.useState)(e?.signature??``),[d,f]=(0,Y.useState)(e?.isDefault??!1);return(0,X.jsxs)(I,{title:e?e.address:B(`addFromAddress`),description:B(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:i,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:i,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:t,disabled:!a.trim(),onClick:()=>r({address:a.trim(),name:s.trim(),signature:l,isDefault:d}),children:B(e?`save`:`addAddress`)})]}),children:[!e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`fromAddress`),(0,X.jsx)(R,{autoFocus:!0,type:`email`,value:a,maxLength:254,placeholder:B(`fromAddressPlaceholder`),onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[B(`fromName`),(0,X.jsx)(R,{value:s,maxLength:100,placeholder:B(`fromNamePlaceholder`),onChange:e=>c(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:B(`defaultFromAddress`)}),(0,X.jsx)(me,{checked:d,onChange:f,label:B(`defaultFromAddress`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[B(`signature`),(0,X.jsx)(Pe,{value:l,maxLength:2e3,placeholder:B(`signaturePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,X.jsx)(D,{message:n})]})},ys=e=>e.signature?B(`ownSignature`):B(`genericSignature`),bs=({senders:{address:e,senders:t},onAdd:n,onUpdate:r,onRemove:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(),d=(0,Y.useRef)(!1),f=t.find(e=>e.isDefault),p=()=>{u(void 0),c(void 0)},m=async e=>{if(!d.current){d.current=!0,o(!0),c(void 0);try{await e(),u(void 0)}catch(e){if(e instanceof TypeError)return c(B(`noAnswerFromServer`));if(!(e instanceof H))throw e;c(k(e))}finally{d.current=!1,o(!1)}}},h=e=>m(async()=>{let t=e.name||null,i=e.signature.trim()?e.signature:null;if(l?.kind===`change`)return r(l.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:B(`fromAddresses`)}),(0,X.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:B(`fromAddressesDescription`)}),(0,X.jsx)(D,{message:l?void 0:s}),(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)(wr,{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:B(`mailboxOwnAddress`)})]}),f?(0,X.jsx)(L,{size:`sm`,variant:`ghost`,loading:a,onClick:()=>void m(()=>r(f.id,{isDefault:!1})),children:B(`makeDefault`)}):(0,X.jsx)(P,{tone:`blue`,children:B(`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)(wr,{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:ys(e)})]}),e.isDefault&&(0,X.jsx)(P,{tone:`blue`,children:B(`default`)}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>u({kind:`change`,sender:e}),children:B(`edit`)}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>u({kind:`remove`,sender:e}),children:B(`remove`)})]},e.id))]}),(0,X.jsxs)(L,{onClick:()=>u({kind:`add`}),children:[(0,X.jsx)(Nt,{className:`size-3.5`}),B(`addFromAddress`)]}),l?.kind===`add`&&(0,X.jsx)(vs,{busy:a,error:s,onSave:e=>void h(e),onClose:p}),l?.kind===`change`&&(0,X.jsx)(vs,{sender:l.sender,busy:a,error:s,onSave:e=>void h(e),onClose:p},l.sender.id),l?.kind===`remove`&&(0,X.jsx)(I,{title:B(`removeFromAddress`,{address:l.sender.address}),description:B(`removeFromAddressDescription`),onClose:p,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:p,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,loading:a,onClick:()=>void m(()=>i(l.sender.id)),children:B(`remove`)})]}),children:(0,X.jsx)(D,{message:s})})]})},xs=(e,t,n)=>Object.fromEntries(Pn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,Yn(`signInOnly`,{provider:n(e.provider),name:e.name})])),Ss=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=G(),{account:i}=t,[a]=(0,Y.useState)(fe),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}=j(o,B(`couldNotReadMethods`));return s?(0,X.jsx)(h,{title:B(`mailbox`),description:B(`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??ft(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&Zt(a,e.length===1?e[0].name:B(`theProvider`)),children:(0,X.jsx)(bs,{senders:s.senders,onAdd:async e=>{let t=await i.addMailSender(e);return await l(),t},onUpdate:async(e,t)=>{await i.updateMailSender(e,t),await l()},onRemove:async e=>{await i.removeMailSender(e),await l()}})}):(0,X.jsx)(J,{error:c})},Cs=()=>{let{personalMail:e}=G();return e.length>0?(0,X.jsx)(Ss,{links:e}):null},ws=e=>br(e.name)??`An unnamed app`,Ts=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),Es=({apps:e,onDisconnect:t})=>{let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(),c=async e=>{r(!0),a(void 0);try{await t(e.clientId),s(void 0)}catch(e){if(!(e instanceof H))throw e;a(k(e))}r(!1)};return(0,X.jsxs)(N,{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)(D,{message:o?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=xr(e.clientId);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Er,{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:ws(e)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,et(Date.parse(e.allowedAt)),` · `,Ts(e)]})]}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>s(e),children:`Disconnect`})]},e.clientId)})}),o&&(0,X.jsx)(I,{title:`Disconnect ${ws(o)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>s(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>s(void 0),children:`Cancel`}),(0,X.jsx)(L,{variant:`danger`,loading:n,onClick:()=>void c(o),children:`Disconnect`})]}),children:i&&(0,X.jsx)(D,{message:i})})]})},Ds=(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},Os=({url:e,appName:t})=>(0,X.jsx)(N,{title:B(`mcpAddress`),description:B(`mcpAddressDescription`),children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Sr,{value:e,copyLabel:B(`copyMcpAddress`)}),(0,X.jsxs)(`a`,{href:Ds(e,t),target:`_blank`,rel:`noreferrer`,className:Me(),children:[(0,X.jsx)(mt,{className:`size-3.5`}),B(`addToClaude`)]})]})}),ks=()=>{let{account:e}=G().session,{data:t,error:n,reload:r}=j((0,Y.useCallback)(()=>e.connectedApps(),[e]),B(`couldNotReadMethods`));return t?(0,X.jsx)(Es,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,X.jsx)(J,{error:n})},As=({url:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Os,{url:e,appName:F().appName}),(0,X.jsx)(ks,{})]}),js=()=>{let{mcp:e}=G();return e?(0,X.jsx)(As,{url:e.url}):null},Ms={30:30,90:90,365:365,never:void 0},Ns={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},Ps=e=>et(Date.parse(e)),Fs=e=>e?B(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:Ps(e)}):B(`neverExpires`),Is=e=>[B(`createdOn`,{date:Ps(e.createdAt)}),Fs(e.expiresAt),e.lastUsedAt?B(`lastUsedOn`,{date:Ps(e.lastUsedAt)}):B(`notUsedYet`),e.organization?B(`actsAsIn`,{role:e.role,organization:e.organization}):B(`actsAs`,{role:e.role})].join(` · `),Ls=({tokens:e,onCreate:t,onRevoke:n})=>{let[i,a]=(0,Y.useState)(!1),[o,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,a(!0),s(void 0);try{l(await e()),h(void 0)}catch(e){if(e instanceof TypeError)return s(B(`noAnswerFromServer`));if(!(e instanceof H))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):s(k(e))}finally{_.current=!1,a(!1)}}},y=()=>v(async()=>{let e=Ms[f];return{kind:`created`,created:await t({name:u.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,X.jsxs)(N,{title:B(`accessTokens`),description:B(`accessTokensDescription`),children:[(0,X.jsx)(D,{message:c?void 0:o}),e.length===0?(0,X.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:B(`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)(Or,{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:Is(e)})]}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>l({kind:`revoke`,token:e}),children:B(`revoke`)})]},e.id))}),(0,X.jsxs)(L,{onClick:()=>{d(``),p(`90`),l({kind:`create`})},children:[(0,X.jsx)(Nt,{className:`size-3.5`}),B(`newAccessToken`)]}),c?.kind===`create`&&(0,X.jsxs)(I,{title:B(`newAccessToken`),description:B(`newAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:g,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:i,disabled:!u.trim(),onClick:()=>void y(),children:B(`createAccessToken`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`name`),(0,X.jsx)(R,{autoFocus:!0,value:u,maxLength:100,placeholder:B(`accessTokenNamePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[B(`accessTokenExpiry`),(0,X.jsx)(Ue,{value:f,onChange:e=>p(e.target.value),children:Object.keys(Ms).map(e=>(0,X.jsx)(`option`,{value:e,children:B(Ns[e])},e))})]}),m===`asked`&&(0,X.jsx)(r,{purpose:`change`,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:B(`confirmedCreateAccessToken`)}),(0,X.jsx)(D,{message:o})]}),c?.kind===`created`&&(0,X.jsx)(I,{title:B(`accessTokenCreated`,{name:c.created.personalAccessToken.name}),description:B(`accessTokenCreatedDescription`),onClose:g,actions:(0,X.jsx)(L,{variant:`primary`,onClick:g,children:B(`done`)}),children:(0,X.jsx)(Sr,{value:c.created.token,copyLabel:B(`copyAccessToken`)})}),c?.kind===`revoke`&&(0,X.jsx)(I,{title:B(`revokeAccessToken`,{name:c.token.name}),description:B(`revokeAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:g,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,loading:i,onClick:()=>void v(async()=>(await n(c.token.id),void 0)),children:B(`revoke`)})]}),children:(0,X.jsx)(D,{message:o})})]})},Rs=()=>{let{account:e}=G().session,{data:t,error:n,reload:r}=j((0,Y.useCallback)(()=>e.personalAccessTokens(),[e]),B(`couldNotReadAccessTokens`));return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(D,{message:n}),(0,X.jsx)(Ls,{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)(J,{error:n})},zs=()=>G().personalAccessTokens?(0,X.jsx)(Rs,{}):null,Bs={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},Vs=e=>e.provider===`google`,Hs=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(r),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=async(e,t)=>{a(e),s(void 0),d(void 0);try{await t(),l(void 0)}catch(e){if(!(e instanceof H))throw e;s(k(e))}finally{a(void 0)}};return(0,X.jsxs)(N,{title:B(`connections`),description:B(`connectionsDescription`),children:[(0,X.jsx)(D,{message:c?void 0:o}),(0,X.jsx)(Ve,{message:u}),(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)(Mr,{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)(L,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void f(e.key,()=>t(e)),children:e.accounts.length>0?B(`connectAgain`,{name:e.label}):B(`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:[B(`connectedOn`,{date:et(Date.parse(t.created_at))}),` · `,(0,X.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,X.jsx)(P,{tone:`amber`,children:B(`connectionNeedsSignIn`)}):(0,X.jsx)(P,{tone:`green`,children:B(`connected`)}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>l({connection:e,accountId:t.id}),children:B(`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:B(`connectionUsedBy`)}),t.used_by.map(e=>(0,X.jsx)(ne,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),c&&(0,X.jsx)(I,{title:B(`disconnectTitle`,{name:c.connection.label}),description:Vs(c.connection)?`${B(`disconnectDescription`)} ${B(`disconnectWholeGrant`)}`:B(`disconnectDescription`),onClose:()=>l(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>l(void 0),children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,loading:i===c.accountId,onClick:()=>void f(c.accountId,async()=>d(B(Bs[await n(c.accountId)]))),children:B(`disconnect`)})]}),children:o&&(0,X.jsx)(D,{message:o})})]})},Us=()=>{let{session:e,connectAccount:t}=G(),{account:n}=e,[r]=(0,Y.useState)(fe),{data:i,error:a,reload:o}=j((0,Y.useCallback)(()=>n.workflowConnections(),[n]),B(`couldNotReadMethods`));return i?i.length===0?null:(0,X.jsx)(Hs,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&Zt(r,B(`theProvider`))}):(0,X.jsx)(J,{error:a})},Ws=e=>e.code===`LAST_ADMIN`?B(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?B(`deleteAccountLocked`):k(e),Gs=({hasPassword:e,onDelete:t,onClose:n})=>{let[i,a]=(0,Y.useState)(``),[o,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?i:void 0)}catch(e){if(!(e instanceof H))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?d(!0):l(Ws(e)),s(!1)}};return(0,X.jsxs)(I,{title:B(`deleteAccountQuestion`),description:B(`deleteAccountWarning`),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:n,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,type:`submit`,form:f,loading:o,disabled:e&&!i,children:B(`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:[B(`deleteAccountPassword`),(0,X.jsx)(R,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:i,invalid:!!c,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(D,{message:c})]}),u&&(0,X.jsx)(r,{purpose:`change`,minutes:15,onConfirmed:()=>void p()})]})},Ks=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(N,{title:B(`deleteAccount`),description:B(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,X.jsx)(L,{variant:`danger`,onClick:()=>i(!0),children:B(`deleteAccount`)}),r&&(0,X.jsx)(Gs,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},qs=()=>{let{session:e,state:t,deleteAccount:n}=G(),{account:r}=e,{data:i,error:a}=j((0,Y.useCallback)(()=>r.signInMethods(),[r]),B(`couldNotReadMethods`));return i?(0,X.jsx)(Ks,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,X.jsx)(J,{error:a})},Js=[[/Edg(e|A|iOS)?\//,`Edge`],[/OPR\/|Opera/,`Opera`],[/SamsungBrowser\//,`Samsung Internet`],[/Firefox\/|FxiOS\//,`Firefox`],[/Chrome\/|CriOS\//,`Chrome`],[/Safari\//,`Safari`]],Ys=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/CrOS/,`ChromeOS`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/Linux/,`Linux`]],Xs=(e,t)=>e.find(([e])=>e.test(t))?.[1],Zs=e=>e?{browser:Xs(Js,e),system:Xs(Ys,e)}:{},Qs=e=>e.device?B(`deviceThrough`,{device:e.device,provider:e.name}):e.name,$s=(e,t)=>{if(e.staff)return t?B(`staffOf`,{operator:t}):B(`staff`);let{browser:n,system:r}=Zs(e.userAgent);return n&&r?B(`browserOn`,{browser:n,system:r}):r?B(`aBrowserOn`,{system:r}):n??B(`unknownDevice`)},ec=e=>{if(e.staff)return Pr;let{system:t}=Zs(e.userAgent);return t===`iPhone`||t===`Android`?Ir:t===`iPad`?Rr:Ar},tc=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),nc=(e,t)=>e.kind===`one`?B(`signOutDevice`,{name:$s(e.session,t)}):e.kind===`link`?B(`signOutDevice`,{name:Qs(e.link)}):B(`signOutOthersTitle`),rc=e=>B(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),ic=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),p=e.filter(e=>!e.current),m=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),h=async e=>{s(!0),l(void 0);try{await m(e),d(void 0)}catch(e){if(!(e instanceof H))throw e;l(k(e))}s(!1)},g=e=>{l(void 0),d(e)};return(0,X.jsxs)(N,{title:B(`devices`),description:B(`devicesDescription`),children:[f.length===0&&n.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:B(`noDevices`)}):(0,X.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[tc(f).map(e=>{let n=ec(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:$s(e,t)}),e.current&&(0,X.jsx)(P,{tone:`green`,children:B(`thisDevice`)})]}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[B(`signedInFromUntil`,{from:ke(Date.parse(e.createdAt)),until:ke(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`one`,session:e}),children:B(`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)(Ir,{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:Qs(t)}),n&&(0,X.jsx)(P,{tone:`green`,children:B(`thisDevice`)})]}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:B(`linkedOn`,{date:ke(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`link`,link:t}),children:B(`signOut`)})]},t.id)})]}),p.length>0&&(0,X.jsx)(L,{className:`mt-3`,onClick:()=>g({kind:`others`}),children:B(`signOutOthers`)}),u&&(0,X.jsx)(I,{title:nc(u,t),description:rc(u),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>d(void 0),children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,loading:o,onClick:()=>void h(u),children:B(`signOut`)})]}),children:(0,X.jsx)(D,{message:c})})]})},ac=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=G(),{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}=j(i,B(`couldNotReadDevices`));return a?(0,X.jsx)(ic,{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)(J,{error:o})},oc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},sc=({rule:e,passkeys:t,onAdd:n,onRename:i,onRemove:a})=>{let[o,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 H))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):l(k(e))}s(!1)};return(0,X.jsxs)(N,{title:B(`passkeys`),status:e===`required`&&(0,X.jsx)(P,{tone:`blue`,children:B(`required`)}),description:B(oc[e]),children:[(0,X.jsx)(D,{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)(Gt,{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??B(`passkey`)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?B(`addedOn`,{date:et(Date.parse(e.createdAt))}):B(`addedEarlier`),` · `,e.backedUp?B(`synced`):B(`oneDevice`)]})]}),(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>{p(e.name??``),d({kind:`rename`,passkey:e})},children:B(`rename`)}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,disabled:g,title:g?B(`keepLastPasskey`):void 0,onClick:()=>d({kind:`remove`,passkey:e}),children:B(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,X.jsxs)(L,{loading:o&&!u,onClick:()=>void _(n),children:[(0,X.jsx)(Nt,{className:`size-3.5`}),B(`addPasskey`)]}),m===`asked`&&(0,X.jsx)(r,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:B(`confirmedAddPasskey`)}),u?.kind===`rename`&&(0,X.jsxs)(I,{title:B(`renamePasskey`),description:B(`renamePasskeyDescription`),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>d(void 0),children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:o,disabled:!f.trim(),onClick:()=>void _(()=>i(u.passkey.id,f.trim())),children:B(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`name`),(0,X.jsx)(R,{autoFocus:!0,value:f,maxLength:60,onChange:e=>p(e.target.value)})]}),(0,X.jsx)(D,{message:c})]}),u?.kind===`remove`&&(0,X.jsx)(I,{title:B(`removePasskey`),description:B(`removePasskeyDescription`,{name:u.passkey.name??B(`thisPasskey`)}),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>d(void 0),children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,loading:o,onClick:()=>void _(()=>a(u.passkey.id)),children:B(`remove`)})]}),children:c&&(0,X.jsx)(D,{message:c})})]})},cc=()=>{let{account:e}=G().session,t=(0,Y.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=j(t,B(`couldNotReadMethods`));if(!n)return(0,X.jsx)(J,{error:r});let[a,o]=n;return(0,X.jsx)(sc,{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)})},lc=e=>e.code===`PASSWORD_TOO_SHORT`?B(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?B(`passwordTooLong`):k(e),uc=(e,t)=>{if(e.length<12)return B(`useAtLeast`,{length:12});if(e!==t)return B(`passwordsDiffer`)},dc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(),p=(0,Y.useId)(),m=(!e||r)&&a&&s,h=async()=>{let e=uc(a,s);if(f(e),!e){u(!0);try{await t({current:r,next:a})}catch(e){if(!(e instanceof H))throw e;f(lc(e)),u(!1)}}};return(0,X.jsx)(I,{title:B(e?`changePassword`:`setPassword`),description:B(`atLeast`,{length:12}),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:n,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,type:`submit`,form:p,loading:l,disabled:!m,children:B(`save`)})]}),children:(0,X.jsxs)(`form`,{id:p,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`currentPassword`),(0,X.jsx)(R,{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:[B(`newPassword`),(0,X.jsx)(R,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!d,onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`repeatPassword`),(0,X.jsx)(R,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:s,invalid:!!d,onChange:e=>c(e.target.value)})]}),e&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:B(`changeSignsOutOthers`)}),(0,X.jsx)(D,{message:d})]})})},fc=({rule:e,hasPassword:t,staff:n})=>B(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)(N,{title:B(`password`),description:fc({rule:e,hasPassword:t,staff:n}),children:[(0,X.jsx)(Ve,{message:s?B(`passwordSaved`):void 0}),l&&(0,X.jsx)(L,{onClick:()=>{c(!1),o(!0)},children:B(t?`changePassword`:`setPassword`)}),a&&(0,X.jsx)(dc,{hasPassword:t,onClose:()=>o(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):i(n)),o(!1),c(!0)}})]})},mc=()=>{let{session:e,state:t}=G(),{account:n}=e,{data:r,error:i,reload:a}=j((0,Y.useCallback)(()=>n.signInMethods(),[n]),B(`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)(J,{error:i})},hc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),m=async e=>{d(!0),p(void 0);try{await e()}catch(e){if(!(e instanceof H))throw e;p(k(e))}d(!1)},h=i.trim(),g=()=>m(async()=>{await t.request(h),l(``),s(h)}),_=e=>m(async()=>{await t.confirm(o,e),n()});return o?(0,X.jsxs)(I,{title:B(`changeEmail`),description:B(`codeSentTo`,{email:o,minutes:10}),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{variant:`ghost`,onClick:()=>{s(void 0),p(void 0)},children:B(`otherAddress`)}),(0,X.jsx)(L,{variant:`primary`,loading:u,disabled:c.length<6,onClick:()=>void _(c),children:B(`changeEmail`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`code`),(0,X.jsx)(Ut,{name:`code`,required:!0,autoFocus:!0,value:c,invalid:!!f,onChange:l,onComplete:e=>!u&&void _(e)})]}),(0,X.jsx)(D,{message:f})]}):(0,X.jsxs)(I,{title:B(`changeEmail`),description:B(`changeEmailDescription`),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:r,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:u,disabled:!h||h.toLowerCase()===e.toLowerCase(),onClick:()=>void g(),children:B(`sendCode`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`newEmail`),(0,X.jsx)(R,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(D,{message:f})]})},gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=async()=>{f(!0),m(void 0);try{await n(l.trim()),o(!1)}catch(e){if(!(e instanceof H))throw e;m(k(e))}f(!1)};return(0,X.jsxs)(N,{title:B(`profile`),description:B(`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:B(`name`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:B(`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)(L,{onClick:()=>{u(e),m(void 0),o(!0)},children:B(`changeName`)}),r&&(0,X.jsx)(L,{onClick:()=>c(!0),children:B(`changeEmail`)})]}),a&&(0,X.jsxs)(I,{title:B(`changeName`),description:B(`changeNameDescription`),onClose:()=>o(!1),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>o(!1),children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:d,disabled:!l.trim()||l.trim()===e,onClick:()=>void h(),children:B(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`name`),(0,X.jsx)(R,{autoFocus:!0,value:l,maxLength:100,onChange:e=>u(e.target.value)})]}),(0,X.jsx)(D,{message:p})]}),s&&r&&(0,X.jsx)(hc,{email:t,change:r,onClose:()=>c(!1),onDone:()=>{c(!1),i?.()}})]})},_c=()=>{let{session:e,changeEmail:t}=G(),{data:n,loaded:r,error:i,reload:a}=j((0,Y.useCallback)(()=>e.session(),[e]),B(`couldNotReadProfile`));if(!r)return(0,X.jsx)(J,{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})},vc=({title:e,description:t,confirmLabel:n,danger:i,needsPassword:a,onConfirm:o,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 o(a?c:void 0)}catch(e){if(!(e instanceof H))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(!0):p(k(e)),d(!1)}};return(0,X.jsxs)(I,{title:e,description:t,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:s,children:B(`cancel`)}),(0,X.jsx)(L,{variant:i?`danger`:`primary`,loading:u,disabled:a&&!c,onClick:()=>void g(),children:n})]}),children:[a&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`yourPassword`),(0,X.jsx)(R,{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)(r,{purpose:`change`,minutes:15,onConfirmed:()=>void g()})]})},yc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},bc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,Y.useState)(),d=()=>u(void 0),f=n?(0,X.jsx)(P,{tone:`green`,children:B(`on`)}):t===`required`?(0,X.jsx)(P,{tone:`amber`,children:B(`required`)}):(0,X.jsx)(P,{children:B(`off`)}),p=B(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:yc[t]);return l?.kind===`setup`?(0,X.jsx)(N,{title:B(`twoFactor`),status:f,description:p,children:(0,X.jsx)(`div`,{className:`max-w-sm`,children:(0,X.jsx)(qe,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,X.jsxs)(N,{title:B(`twoFactor`),status:f,description:p,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,X.jsx)(L,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:B(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,X.jsx)(L,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:B(`addAuthenticator`)}),n&&r&&(0,X.jsx)(L,{onClick:()=>u({kind:`new-codes`}),children:B(`newBackupCodes`)}),n&&(0,X.jsx)(L,{variant:`danger`,disabled:t===`required`,title:t===`required`?B(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:B(`turnOff`)})]}),l?.kind===`turn-off`&&(0,X.jsx)(vc,{title:B(`turnOffTitle`),description:B(`turnOffDescription`),confirmLabel:B(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,X.jsx)(vc,{title:B(`newCodesTitle`),description:B(`newCodesDescription`),confirmLabel:B(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,X.jsx)(I,{title:B(`yourNewCodes`),description:B(`keepCodesSafe`),onClose:d,actions:(0,X.jsx)(L,{variant:`primary`,onClick:d,children:B(`savedCodes`)}),children:(0,X.jsx)(Qe,{codes:l.codes})})]})},xc=()=>{let{account:e}=G().session,{data:t,error:n,reload:r}=j((0,Y.useCallback)(()=>e.signInMethods(),[e]),B(`couldNotReadMethods`));return t?(0,X.jsx)(bc,{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)(J,{error:n})},Sc=({problem:e,fallback:t})=>t===void 0?(0,X.jsx)(re,{children:e}):(0,X.jsxs)(X.Fragment,{children:[!1,t]}),Cc=({name:e,registered:t,fallback:n,children:r})=>t?(0,X.jsx)(f,{name:e,fallback:n===void 0?void 0:(0,X.jsx)(Sc,{problem:M.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,X.jsx)(Sc,{problem:M.rich(`noComponent`,{component:e}),fallback:n}),wc={Page:Pa,Grid:ua,Card:ri,Stat:yo,RecordCard:Ra,Field:aa,Diff:na,Table:wo,CardRow:si,RecordRow:ro,RecordCards:$a,Chart:ci,Timeline:qi,Graph:Zi,Progress:Ia,Image:va,ModalForm:Na,Thread:Zo,Composer:$i,Action:ni,Show:fo,Switch:mo,Match:ho,Link:Oa,Settings:so,Tabs:Eo,Tab:Do,Users:_s,Profile:_c,Password:mc,Passkeys:cc,TwoFactor:xc,ConnectedAccounts:oe,PersonalMail:Cs,Connections:Us,Devices:ac,ConnectedApps:js,PersonalAccessTokens:zs,DeleteAccount:qs,Box:Qo,Row:$o,Column:es,Text:ts,ReferenceManyField:os,ReferenceArrayField:cs,ArrayField:ns,RecordsIterator:ai,ReferenceField:us,SelectInput:rs,Details:ea,Summary:ta,TextField:xa,NumberField:Sa,DateField:Ca,BooleanField:wa,UrlField:Ta,ChipField:Ea},Tc=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(`.`)),Ec=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:un(t,...n,r)}})),Dc=({text:e})=>{let t=q(),n=Ae(),r={...z(t),params:n};return(0,X.jsx)(X.Fragment,{children:y(e,e=>c(_t(r,e)))})},Oc=(e,t)=>e.includes(`{{`)?(0,X.jsx)(Dc,{text:e},t):(0,X.jsx)(Y.Fragment,{children:e},t),kc=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?Oc(e,n):(0,X.jsx)(Ic,{node:e,at:t},n)),Ac=e=>{let t=[];for(let n of e){let e=t.at(-1);Hr(n.child)&&e&&Hr(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Hr(n.child)?(0,X.jsx)(`p`,{className:`leading-6`,children:kc(e)},t):(0,X.jsx)(Ic,{node:n.child,at:n.at},t)})},jc=e=>xe(e)||Array.isArray(e)&&e.length>0&&e.every(xe),Mc=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>jc(n)?[[e,(0,X.jsx)(X.Fragment,{children:Ac(Nc(n,t,e))})]]:[])),Nc=(e,t,n)=>Array.isArray(e)?Ec(e,t,`props`,n):[{child:e,...t!==void 0&&{at:un(t,`props`,n)}}],Pc=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fc=(e,t)=>{let n=Pc(e.props.components)?e.props.components:{},r=Object.fromEntries(Object.entries(n).flatMap(([e,t])=>xe(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=Jt(t,String(e.props.i18nKey),Pc(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||xe(e)?e:String(e)):[i]},Ic=({node:e,at:t})=>{let{components:n}=Ce(),r=q(),i=Ae(),o=je(),s=(0,Y.useMemo)(()=>a(Lt(e,{...z(r),params:i}),o),[e,r,i,o]);if(s.type===`Trans`&&!s.custom)return(0,X.jsx)(X.Fragment,{children:kc(Fc(s,o).map(e=>({child:e})))});if(s.custom){let e=n?.[s.type],r=s.children.length>0?(0,X.jsx)(Ji,{node:s,children:Ac(Ec(s.children,t,`children`))}):void 0;return(0,X.jsx)(Cc,{name:s.type,registered:!!e,fallback:s.fallback&&(0,X.jsx)(X.Fragment,{children:Ac(Ec(s.fallback,t,`fallback`))}),children:e&&(0,X.jsx)(Ye,{node:s,...t!==void 0&&{at:t},children:(0,X.jsx)(e,{...ht(s.props),children:r})})})}let c=wc[s.type];if(!c)return(0,X.jsx)(re,{children:M.rich(`unknownBlock`,{type:s.type})});let l=typeof s.props.className==`string`?s.props.className:void 0,u=Ec(s.children,t,`children`),d=(0,X.jsx)(c,{node:s,at:t,slots:Mc(s,t),className:l,children:s.type===`Text`||s.type===`Link`||s.type===`Summary`?kc(u):Ac(s.type===`Switch`?u.filter(({child:e})=>typeof e!=`string`):u)}),p=l===void 0||Tc.has(s.type)?d:(0,X.jsx)(`div`,{className:l,children:d});return s.fallback?(0,X.jsx)(f,{name:s.type,resetKey:s,fallback:(0,X.jsx)(X.Fragment,{children:Ac(Ec(s.fallback,t,`fallback`))}),children:p}):p};export{bo as a,Ha as c,Yo as i,za as l,Cc as n,co as o,Xo as r,Za as s,Ic as t,Qi as u};
3
- //# debugId=2fe8a7d1-a1c1-466d-8270-f31b76d97ef9
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-COd5Mp2P.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-94a88jzE.js","assets/vendor-t7Q7QbPu.js","assets/app-BAQxWF5r.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{$a as r,$n as i,$o as a,$s as o,$t as s,Al as c,As as l,At as u,B as d,Ba as f,Bc as p,Bi as m,Bo as h,Br as g,C as _,Cc as v,Cl as y,Cn as b,D as x,Ds as S,Ec as C,En as w,Es as T,F as E,Fn as ee,Go as te,Gt as ne,Ha as re,Ho as D,Hs as ie,In as ae,Io as oe,Ir as se,Jn as ce,Js as O,Jt as le,Ko as k,Ks as ue,Ln as de,Lo as fe,Lr as pe,M as me,Ma as he,Mc as A,Mo as ge,Ms as _e,Mt as ve,No as ye,Nr as be,Ns as xe,Nt as Se,Oa as Ce,Oi as we,Os as Te,Pn as Ee,Pt as De,Qc as Oe,Qi as ke,Qn as Ae,Qo as je,Qs as Me,R as Ne,Rn as Pe,Ro as j,Sa as Fe,Sl as Ie,Ts as Le,Ua as Re,Uc as ze,Un as Be,Uo as Ve,Us as He,V as Ue,Va as M,Vi as We,Vo as N,Vs as Ge,Wo as P,Ws as Ke,Xa as qe,Xo as Je,Xt as Ye,Yc as Xe,Yn as Ze,Yo as F,Ys as I,Za as Qe,Zc as $e,Zi as et,Zs as L,_ as tt,_a as nt,_n as rt,_t as it,aa as at,at as ot,b as st,bo as R,bs as ct,cn as lt,cr as z,cs as B,da as ut,dr as dt,ds as ft,ea as pt,fr as V,fs as H,gc as mt,gl as ht,gn as gt,gs as _t,gt as vt,hi as yt,hl as bt,hn as xt,hs as St,i as Ct,ia as wt,il as Tt,in as U,ir as Et,ja as Dt,jc as W,js as Ot,jt as kt,k as At,ki as jt,ks as Mt,lc as Nt,ln as Pt,lr as Ft,ls as G,mn as It,mr as K,ms as Lt,nl as Rt,nn as zt,nr as Bt,ns as Vt,on as Ht,oo as Ut,or as Wt,pc as Gt,pn as Kt,pr as qt,ps as Jt,qa as Yt,qc as Xt,qo as Zt,rn as Qt,s as $t,sn as en,sr as q,tn,tr as nn,un as rn,ur as an,us as on,v as sn,va as cn,vn as ln,vs as un,wn as dn,ws as fn,wt as pn,xi as mn,xs as hn,y as gn,ya as _n,yi as vn,yn,ys as bn,zc as xn,zi as Sn,zo as J,zs as Cn}from"./app-94a88jzE.js";import{C as wn,f as Tn,o as En,s as Dn}from"./vendor-t7Q7QbPu.js";import{C as On,Ct as kn,Dt as An,Et as jn,Mt as Mn,O as Nn,Ot as Pn,Q as Fn,St as In,Tt as Ln,X as Rn,Z as zn,_t as Bn,at as Vn,b as Hn,ct as Un,dt as Wn,ft as Gn,gt as Kn,it as qn,k as Jn,kt as Yn,l as Xn,lt as Zn,mt as Qn,n as $n,nt as er,o as tr,ot as nr,rt as rr,st as ir,t as ar,tt as or,ut as sr,wt as cr,x as lr,xt as ur,y as dr}from"./embedded-list-C9U2ypuX.js";import{t as fr}from"./circle-alert-B63XjMgn.js";import{t as pr}from"./page-header-Ddz2r5ic.js";import{n as mr,t as hr}from"./pending-invitation-row-DRjEfn76.js";import{n as gr,t as _r}from"./person-row-ehgAozYT.js";import{n as vr,t as yr}from"./use-paged-search-COK4rUdF.js";import{n as br,t as xr}from"./client-publisher-D39SlIhp.js";import{t as Sr}from"./copy-field-CmFjZmVI.js";var Cr={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`}]]};Cr.node;var wr=W(Cr),Tr={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`}]]};Tr.node;var Er=W(Tr),Dr={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`}]]};Dr.node;var Or=W(Dr),kr={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`}]]};kr.node;var Ar=W(kr),jr={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`]};jr.node;var Mr=W(jr),Nr={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`}]]};Nr.node;var Pr=W(Nr),Fr={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`}]]};Fr.node;var Ir=W(Fr),Lr={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`}]]};Lr.node;var Rr=W(Lr),zr=[`done`,`error`,`running`];_e(`TextField`,!1),_e(`NumberField`,!1),_e(`DateField`,!1),_e(`BooleanField`,!1),_e(`UrlField`,!1),_e(`ChipField`,!1);var Br=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Vr=e=>typeof e!=`string`&&!e.custom&&Br.has(e.type),Hr=e=>typeof e==`string`||Vr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Ur=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Wr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),Gr=(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)},Kr=(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)},qr=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,Jr=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Yr=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:Jr.has(`${n.toLowerCase()}:`)?e:void 0},Xr=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),Zr=e=>e==null||e===``?void 0:String(e),Qr=(e,t)=>e<t?-1:+(e>t),$r=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=Zr(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=Zr(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=>Zr(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=Zr(e[i.source]),s=Zr(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)=>Qr(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>Qr(e.id,t.id)),edges:s.sort((e,t)=>Qr(e.source,t.source)||Qr(e.target,t.target)||Qr(e.id,t.id))}},Y=e(t(),1),X=e(n(),1),ei=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=F(),s=kn(e.name,void 0),c=Sn(),[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=>It(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let m=f.length-p.length,h=ur(`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)(L,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>jn(d)?u(!0):void g(),children:h}),l&&(0,X.jsx)(Ln,{action:d,label:h,danger:i===`danger`||i===void 0&&An(d),records:p.map(e=>e.record),names:p.map(t=>In(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),g()},onSubmit:async e=>{u(!1),await g(e)}})]})},ti=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=Wt(),c=cr(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)(L,{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:()=>jn(c.action)?u(!0):void c.run(),children:d}),l&&(0,X.jsx)(Ln,{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)}})]})},ni=({node:e,className:t})=>{let n=U(e),r=dt(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,X.jsx)(ei,{...n,model:i,items:r.items,className:t}):(0,X.jsx)(ti,{...n,className:t})},ri=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=U(e);return(0,X.jsx)(V,{title:i,description:a,actions:n.actions,className:A(`h-full`,r),children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},ii=({children:e,wrap:t=(e,t)=>(0,X.jsx)(Y.Fragment,{children:e},t)})=>{let n=dt();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...It(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,X.jsx)(Bt,{value:s,row:{index:o,count:i.length},children:e}),c)})},ai=({children:e})=>(0,X.jsx)(ii,{children:e}),oi=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=tn(t),f=rt(e,{filter:n,sort:r,pageSize:i,enabled:!d}),p=d??f,m=d?d.rows:f.data?.items??[];return(0,X.jsx)(V,{title:a,description:o,actions:c,className:u,children:p.isPending?(0,X.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(O,{className:`h-24 w-56`},t))}):p.error?(0,X.jsx)(K,{title:M(`couldNotLoad`),error:p.error}):m.length===0?(0,X.jsx)(qt,{children:s??M(`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)(Ft,{value:{model:e,items:m,...d&&{planned:!0}},children:(0,X.jsx)(ii,{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:l})})})})},si=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=U(e),o=F().resources[i];return o?(0,X.jsx)(oi,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},ci=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=U(e),{resources:u,views:d}=F(),f=u[r];return f?(0,X.jsx)(V,{title:i,description:a,actions:t.actions,className:A(`h-full`,n),children:(0,X.jsx)(Gn,{model:f,view:d[r],...l})}):null},li=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=gt(e,t),a=i.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(O,{className:`h-4 w-1/2`}),(0,X.jsx)(O,{className:`h-4 w-1/3`})]}):i.error?(0,X.jsx)(K,{title:M(`couldNotLoad`),error:i.error}):i.data?(0,X.jsx)(Bt,{value:i.data,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,X.jsx)(qt,{children:M(`nothingYet`)});return(0,X.jsx)(`div`,{className:n,children:a})},ui=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},di=e=>e==null?``:String(e),fi=(e,t,n)=>n===0?0:(e-t)/n*100,pi=(e,t,n)=>{let r=new Map;for(let i of e){let e=ui(i[t.start]);if(e===void 0)continue;let a=ui(i[t.end]),o=Math.max(e,a??n),s=r.get(di(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(di(i[t.lane]),s);let c=s.bars.get(di(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(di(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},mi=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},hi=(e,t,n)=>{let r=pi(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:fi(n,a,s),width:fi(r,a,s)-fi(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:fi(o,a,s),width:fi(c,a,s)-fi(o,a,s),segments:i}});return{key:e,value:n.value,rows:mi(r)}}),from:a,to:o}},gi=(e,t)=>{let n=e.end-e.start;return{left:fi(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},_i=6e4,vi=60*_i,Z=24*vi,yi=[5*_i,15*_i,30*_i,vi,3*vi,6*vi,12*vi,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],bi=365*Z,xi=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Si=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=yi.find(n=>xi(e,t,n,i,a)<=6)??Math.ceil(r/5/bi)*bi,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:fi(a,e,r)})}return{daily:o>=Z,ticks:s}},Ci=e=>({lane:di(e.lane),bar:e.key}),wi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ti=(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},Ei=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Di=({from:e,to:t,dated:n})=>{let r=n?`UTC`:ut(),i=e=>n?0:Ti(e,r),{daily:a,ticks:o}=Si(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 ${Ei(e.left)}`,style:{left:`${e.left}%`},children:a?pt(e.at+i(e.at)):at(e.at,r)},e.at))})},Oi=(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&&Tt(a)?{className:te[a],striped:i}:{color:Kn(e,t,n===void 0?null:n,-1),striped:i}},ki=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)`}}),Ai=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Oi(t,n,r.value),{left:o,width:s}=gi(e,r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:A(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...ki(a)}},i)}),ji=(e,t)=>t?et(e):ke(e),Mi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return M(`timelineRange`,{from:ji(n,a),to:i?M(`timelineNow`):ji(r,a)})},Ni=(e,t,n,r)=>`${yt(t.fields[r.color],e.value,n?.fields[r.color])}: ${Mi(t,r,e.start,e.end,e.open)}`,Pi=(e,t,n,r,i)=>{let a=e.segments.some(t=>t.open&&t.end===e.end);return[`${i??yt(t.fields[r.bar],e.value,n?.fields[r.bar])}: ${Mi(t,r,e.start,e.end,a)}`,...e.segments.map(e=>Ni(e,t,n,r))].join(`; `)},Fi=`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`,Ii=({bar:e,model:t,view:n,fields:r,point:i,choose:a})=>{let o=F().resources[t.fields[r.bar]?.relation?.resource??``],s=w(o??t,e.key,o!==void 0),c=Pi(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)(Ai,{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:Fi,...l,children:d});let f=a.chosen===e.key;return(0,X.jsx)(ue,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:A(Fi,f&&`ring-2 ring-foreground`),...l,children:d})},Li=({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)(Di,{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)(yn,{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)(Ii,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ri=({model:e,view:t,fields:n,value:r})=>{let i=Oi(e.fields[n.color],t?.fields[n.color],r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:A(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:ki(i)})},zi=({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)(Ri,{...t,value:e}),yt(n,e,t.view?.fields[t.fields.color])]},e))})},Bi=({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:M(`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)(yn,{model:n,field:n.fields[i.bar],value:e.value})}),(0,X.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Mi(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)(Ri,{...t,value:e.value}),yt(n.fields[i.color],e.value,r?.fields[i.color]),`: `,Mi(n,i,e.start,e.end,e.open)]},a))})]})},Vi=500,Hi=(e,t,{filter:n=``,sort:r,fields:i,limit:a})=>({queryKey:[...xn.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(Vi,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}}}),Ui=(e,{enabled:t=!0,...n})=>En({...Hi(Vt(),e,n),enabled:t,placeholderData:Tn}),Wi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=S,title:s,description:c,empty:l,actions:u,className:d,choose:f,details:p})=>{let[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),v=e=>e?Ci(e):null,y={hover:e=>h(v(e)),focus:e=>_(v(e))},b=tn(i),x=Ui(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!b}),C=b??x,w=b?b.rows:x.data?.rows??[],T=!b&&x.data?.cut===!0,E=hi(w,n,Date.now());return(0,X.jsxs)(V,{title:s,description:c,actions:u,className:A(`h-full`,d),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)(O,{className:`h-6`},t))});if(C.error)return(0,X.jsx)(K,{title:M(`couldNotLoad`),error:C.error});if(E.lanes.length===0)return(0,X.jsx)(qt,{children:l??M(`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)(zi,{model:e,view:t,fields:n,values:r}),(0,X.jsx)(Li,{shape:E,model:e,view:t,fields:n,point:y,...f&&{choose:f}}),T&&(0,X.jsx)(qt,{children:M(`timelineCut`,{count:w.length})}),(0,X.jsx)(`div`,{"aria-live":`polite`,children:(0,X.jsx)(Bi,{bar:wi(E,m)??wi(E,g),model:e,view:t,fields:n})})]})})(),p]})},Gi=(e,t)=>e.type===`integer`?Number(t):t,Ki=({select:e,children:t,...n})=>{let{given:r,linkTo:a}=i(),o=r[e],s=t=>a({[e]:t}),c=n.model.fields[n.fields.bar],l=o===void 0?null:(0,X.jsx)(Ke,{name:e,children:(0,X.jsx)(li,{model:n.model,query:{filter:Bn(c,Gi(c,o),n.filter),sort:n.sort},children:t},o)});return(0,X.jsx)(Wi,{...n,choose:{barTo:s,chosen:o},details:l})},qi=({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}=U(e),{resources:h,views:g}=F(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Te(e),sort:Mt(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,X.jsx)(Wi,{...v}):(0,X.jsx)(Ki,{...v,select:s,children:r})},Ji=({node:e,children:t})=>{let n=Ot(e),r=nn(),{resources:i}=F();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)(Ke,{name:n.param,children:(0,X.jsx)(li,{model:o,query:{key:a},className:``,children:t},a)})},Yi=(0,Y.lazy)(()=>wn(()=>import(`./graph-view-COd5Mp2P.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]))),Xi=(0,X.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,X.jsx)(o,{})}),Zi=({node:e,at:t,slots:n,children:r,className:i})=>{let a=U(e),o=s(e,t),c=nn(),l=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([l?.rows,u?.rows,g]),v=(0,Y.useMemo)(()=>l&&u&&$r({nodes:l.rows,edges:u.rows,key:l.model.primaryKey[0],edgeKey:u.model.primaryKey,fields:g}),[_]);if(!l||!u||!v)return null;let y=l.error??u.error;if(y&&e.fallback)throw y;if(y)return(0,X.jsx)(K,{title:M(`couldNotLoad`),error:y});if(l.isPending||u.isPending)return Xi;if(v.nodes.length===0)return(0,X.jsx)(qt,{children:a.empty??M(`nothingYet`)});let b=a.select,x=b!==void 0&&c?{chosen:c.given[b],linkTo:e=>c.linkTo({[b]:e})}:void 0;return(0,X.jsxs)(`div`,{className:A(`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:Xi,children:(0,X.jsx)(Yi,{shape:v,nodes:l,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)(Ji,{node:e,children:r})})]})},Q=p(`app/conversation`),Qi=({resource:e,field:t,values:n,placeholder:r})=>{let{resources:i}=F(),a=Vt(),o=ln(),s=Je(e),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)();return!i[e]||!Fe(s,`create`)?null:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[u!==void 0&&(0,X.jsx)(K,{title:Q(`notSent`),error:u}),(0,X.jsx)(pn,{onSend:async r=>{l(!0),d(void 0);let i=await a.create(e,{...n,[t]:r}).then(()=>!0,e=>(d(e),!1));return l(!1),i&&o(e),i},busy:c,placeholder:r})]})},$i=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=U(e);return(0,X.jsx)(Qi,{resource:t,field:n,values:r,placeholder:i})},ea=({node:e,children:t,className:n})=>{let{open:r}=U(e);return(0,X.jsx)(`details`,{open:r,className:A(`[&[open]>summary]:mb-2`,n),children:t})},ta=({children:e,className:t})=>(0,X.jsx)(`summary`,{className:A(`cursor-pointer font-medium`,t),children:e}),na=({node:e,className:t})=>{let{source:n,emptyText:r}=U(e),i=Pt(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,X.jsx)(O,{className:A(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,X.jsx)(`p`,{className:A(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=vt(a);return o?(0,X.jsx)(`div`,{className:A(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,X.jsx)(it,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,X.jsx)(`pre`,{className:A(`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})},ra=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),ia=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>Oe(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},aa=({node:e,className:t})=>{let{source:n,label:r,format:i}=U(e),{views:a}=F(),o=Pt(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,X.jsx)(O,{className:`h-4 w-24`}):o.state===`plain`?ra(o.value):(0,X.jsx)(yn,{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??ia(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:A(`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})]})},oa={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},sa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ca={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`},la=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ua=({node:e,children:t,className:n})=>{let{columns:r=2}=U(e),i=e.children,a=i.length>0&&i.every(la);return(0,X.jsx)(`div`,{className:A(`grid grid-cols-1 gap-4`,a?sa[r]:oa[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:A(`min-w-0`,r&&ca[r]),children:e},t)})})},da=({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`}),fa=({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}}),ma=e=>e instanceof Blob&&e.type.startsWith(`image/`),ha=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},ga=e=>{let[t,n]=(0,Y.useState)();return[t!==void 0&&t===e,()=>n(e)]},_a=({name:e,alt:t,width:n,height:r,refresh:i,className:a})=>{let o=Vt(),{theme:s}=he(),[c,l]=ot(),u=fa({width:n,height:r,space:l,theme:s}),d=En({queryKey:xn.image(e,u??{}),enabled:u!==void 0,placeholderData:Tn,...pa(i),queryFn:async()=>{let t=await o.invoke(e,{query:u,cache:`no-store`});if(!ma(t))throw Error(`The function "${e}" answered no picture`);return t}}),f=ha(d.data),[p,m]=ga(f),h={...n!==void 0&&{width:n},...r!==void 0&&{height:r}};return(0,X.jsx)(`div`,{ref:c,className:A(`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)(O,{className:`w-full max-w-full`,style:{height:r??160,...n!==void 0&&{width:n}}})})},va=({node:e,className:t})=>{let n=U(e);return n.src===void 0?(0,X.jsx)(_a,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,X.jsx)(da,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},ya=e=>function({node:t,className:n}){let r=U(t),{views:i}=F(),a=Pt(r.source);return a.state===`missing`?null:a.state===`loading`?(0,X.jsx)(O,{className:`inline-block h-3 w-16 align-middle`}):Ur(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})})},ba=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?$e(e,n?.valueLabels):Wr(e),xa=ya(ba),Sa=ya(({value:e,props:t})=>(0,X.jsx)(`span`,{className:`tabular-nums`,children:Gr(e,t,ze())})),Ca=ya(({value:e,props:t})=>{let n=Kr(e,t,{locale:ze(),now:Date.now(),relative:wt});return(0,X.jsx)(`time`,{dateTime:String(e),children:n})}),wa=ya(({value:e,props:t})=>{let n=qr(e,t,{yes:we(`yes`),no:we(`no`)});return e?(0,X.jsx)(Be,{label:n,className:`align-middle`}):(0,X.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ta=ya(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=Yr(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})}),Ea=ya(e=>(0,X.jsx)(dn,{value:e.value,hints:e.hints,children:ba(e)})),Da=`font-medium text-primary-text hover:underline`,Oa=({node:e,children:t,className:n})=>{let r=U(e),i={...z(q()),params:Ae()},a=r.variant?A(Me({variant:r.variant}),n):n??Da,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=Ie(r.to,St(i));return(0,X.jsx)(se,{to:e,className:a,children:o??Cn(e)})}let s=r.href??``;return(0,X.jsx)(`a`,{href:s,className:a,...s.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??s})},ka=(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]:x(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:x(i)]})),Aa=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return $t(r)?r.key===x(n[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:_(i,r,n[t])?[[t,At(i,r)]]:[]})),ja=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=F(),u=Vt(),d=Dt(),f=ln(),p=l[e.name],[m,h]=(0,Y.useState)(()=>ka(e,a,t?.record)),[g,_]=(0,Y.useState)({}),[v,y]=(0,Y.useState)(0),b=tt(v),[x,S]=(0,Y.useState)(),[C,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(!1);ie(T||C,`input-lost`);let ee=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...Ct(e,c,m),...o}):u.update(e.name,t.key,Aa(e,m,t.record),t.etag??`*`)).then(async()=>{await f(e.name),d.show({state:`success`,title:M(`saved`,{label:i??r})}),s()},e=>{let t=sn(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,X.jsx)(I,{title:i??r,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:s,children:M(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:C,onClick:()=>void ee(),children:M(n===`create`?`create`:`save`)})]}),children:(0,X.jsxs)(`form`,{ref:b,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),ee()},children:[x!==void 0&&Object.keys(g).length===0&&(0,X.jsx)(K,{title:M(`notSaved`),error:x}),a.map(n=>{let r=e.fields[n],i=m[n],a=r.relation?c[r.relation.resource]:void 0,o=p?.fields[n]?.label??Oe(n),s=g[n];return(0,X.jsx)(Ne,{name:n,label:o,help:p?.fields[n]?.help,error:s&&gn(r,o,s),children:(0,X.jsx)(st,{field:r,hints:p?.fields[n],value:$t(i)?i.key:i,stored:t?.record[n],relationLabel:$t(i)?i.label:void 0,relationPicker:a?{target:a,view:l[a.name]}:void 0,invalid:!!g[n],resource:e.name,onChange:e=>{_(({[n]:e,...t})=>t),E(!0),h(t=>({...t,[n]:e}))}})},n)})]})})},Ma=({model:e,recordKey:t,children:n})=>{let r=gt(e,{key:t});return(0,X.jsx)(X.Fragment,{children:n(r.data??void 0)})},Na=({node:e})=>{let t=U(e),n=Wt(),{resources:r}=F(),i=r[t.resource??n?.model.name??``],a=Je(i?.name??``),[o,s]=(0,Y.useState)(!1);if(!i||!(t.mode===`create`?Fe(a,`create`):Fe(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,X.jsx)(ja,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,X.jsx)(Ma,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},Pa=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=U(e);return(0,X.jsx)(`div`,{className:A(`flex-1`,r),children:(0,X.jsxs)(`div`,{className:A(`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)(pr,{title:i,subtitle:a,actions:n.actions}),t]})})},Fa=(e,t)=>{let n=q(),r=typeof e==`string`?Et(n,e):void 0,i=en(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},Ia=({node:e,className:t})=>{let{value:n,max:r,label:i}=U(e),a=Fa(n,0),o=Fa(r,100);if(a===void 0||o===void 0)return(0,X.jsx)(O,{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:A(`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(ze()),` / `,o.toLocaleString(ze())]})]}),(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}%`}})})]})},La=({model:e,at:t,filter:n,sort:r,recordKey:i,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=tn(t),f=gt(e,{filter:n,sort:r,key:i,enabled:!d}),p=d?Kt(e,d):f,m=e=>p.data?(0,X.jsx)(Bt,{value:p.data,children:e}):void 0,h=p.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(O,{className:`h-4 w-1/2`}),(0,X.jsx)(O,{className:`h-4 w-1/3`})]}):p.error?(0,X.jsx)(K,{title:M(`couldNotLoad`),error:p.error}):p.data?m((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:l})):(0,X.jsx)(qt,{children:s??M(`nothingYet`)});return(0,X.jsx)(V,{title:a,description:o,actions:c?m(c):void 0,className:A(`h-full`,u),children:h})},Ra=({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}=U(e),f=F().resources[a];return f?(0,X.jsx)(La,{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},za=p(`app/related-cards`),Ba=({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:A(`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)(L,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:za(n?`showLess`:`showMore`)})]})},Va=e=>e==null||e===``,Ha=({scope:e,path:t,labelled:n=!0,clamped:r=!1})=>{let{views:i}=F(),a=en(e,t);if(a.state===`missing`||a.state===`ready`&&Va(a.value))return null;let o=a.state===`loading`?(0,X.jsx)(O,{className:`h-4 w-24`}):(0,X.jsx)(yn,{model:a.model,field:a.field,value:a.value}),s=r?(0,X.jsx)(Ba,{children:o}):o;if(!n)return(0,X.jsx)(`div`,{className:`min-w-0`,children:s});let c=ia(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})]})},Ua=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:s})=>{let c=Sn(),{resources:l}=F(),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:A(`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)(le,{view:t,field:i,record:e.record}),(0,X.jsxs)(`div`,{className:A(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,X.jsx)(se,{to:{kind:`record`,resource:e.model.name,key:We(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)(Ha,{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)(Ha,{scope:e,path:t,labelled:!1})},t))}),d&&(0,X.jsx)(Bt,{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)(or,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,X.jsx)(ti,{name:e,about:u,onRun:e=>s?.(e,u)},e))]})})]})},Wa=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let s=Sn(),{resources:c}=F(),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)(le,{view:t,field:r,record:e.record}),(0,X.jsx)(se,{to:{kind:`record`,resource:e.model.name,key:We(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)(Ha,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,X.jsx)(Bt,{value:e,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,X.jsx)(or,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,X.jsx)(ti,{name:e,about:l,onRun:e=>o?.(e,l)},e))]})})]})},Ga=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,Ka=e=>[...e.querySelectorAll(`button`)].find(Ga)??e.querySelector(`a`),qa=(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)},Ja=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},Ya=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(za(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=qa(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?Ka(s):Ja(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}},Xa=({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)(O,{className:e?`h-17.5 w-full max-sm:h-24`:`h-24 w-full`},n))}),Za=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,button:o,limit:s,display:c,empty:l,carousel:u,compact:d,tone:f,planned:p})=>{let m=ye(),h=sr(),g=t?.names?.plural??Oe(e.name),_=r||jt(e,t),v=rt(e,{filter:n,sort:_,pageSize:s,enabled:!p}),y=xt(e,n,!p),b=p?p.rows:{isPending:v.isPending,error:v.error},x=p?p.rows.rows:v.data?.items,S=p?{data:p.total&&!p.total.isPending&&!p.total.error?er(p.total):void 0}:y,C=(0,Y.useMemo)(()=>(x??[]).map(t=>It(e,t)),[e,x]),w=Ya((0,Y.useMemo)(()=>C.map(e=>e.key),[C]));return(0,X.jsxs)(`div`,{ref:w.root,children:[(()=>{if(b.isPending)return(0,X.jsx)(Xa,{compact:!!d,limit:s});if(b.error)return(0,X.jsx)(K,{title:za(`couldNotLoad`),error:b.error});if(C.length===0)return(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:l??za(`nothingYet`)});let r=C.map(e=>{let n=(t,n)=>w.acted(e.key,t,n);return d?(0,X.jsx)(Ua,{scope:e,view:t,fields:i,time:d.time,tone:f,actions:a,button:o,onActed:n},e.key):(0,X.jsx)(Wa,{scope:e,view:t,fields:i,tone:f,actions:a,button:o,onActed:n},e.key)}),p=S.data===void 0?void 0:Un(C.length,S.data,!1);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u===void 0?(0,X.jsx)(`ul`,{className:d?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,X.jsx)(Wn,{scroll:h,label:g,share:u,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:p}),(0,X.jsxs)(se,{to:nr(e,t,m,{filter:n,orderBy:_,display:rr(t,m,{preferred:c})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[Zn(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:g.toLowerCase()}),(0,X.jsx)(Mn,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:w.announcement})]})},Qa={"1/4":1/4,"1/3":1/3,"1/2":1/2,"2/3":2/3},$a=({node:e,at:t,slots:n,className:r})=>{let i=U(e),{resource:a,filter:o=``,sort:s=``,fields:c,cardActions:l=[],limit:u=10,display:d,title:f,description:p,empty:m}=i,{layout:h,cardWidth:g}=Xr(i),{resources:_,views:v}=F(),[y,b]=zt([t,t===void 0?void 0:`${t}#total`]),x=(0,Y.useMemo)(()=>y&&{rows:y,total:b},[y,b]),S=_[a];if(!S)return null;let C=v[S.name];return(0,X.jsx)(`section`,{className:A(`min-w-0`,r),"aria-label":f,children:(0,X.jsx)(E,{title:f,help:p,actions:n.actions,children:(0,X.jsx)(Za,{model:S,view:C,filter:o,sort:s,fields:c??Xt(S,C),actions:l,limit:u,display:d,empty:m,carousel:h===`carousel`?Qa[g]:void 0,...x&&{planned:x}})})})},eo=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=F(),o=g(i,a,e.name),s=Nn(e.name,t.listOf,!0),c=(t.names?.plural??Oe(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,X.jsx)(K,{title:On(`couldNotLoadYour`,{plural:c}),error:s.error});if(!s.data)return(0,X.jsx)(O,{className:`h-24`});let l=Jn(o.model,s.data);return l?(0,X.jsx)(lr,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??On(`noneYet`,{plural:c})})},to=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=Rt(We(e,i)),{name:o,chips:s,title:c,body:l}=dr({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)(se,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,X.jsx)(Rn,{chips:s})})}),(0,X.jsx)(lr,{...l})]})},no=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=F(),a=t.searchesOf,o=r[a.resource],s=Hn(e.name,!0),c=(t.names?.plural??Oe(e.name)).toLowerCase();return o?s.error?(0,X.jsx)(K,{title:zn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??zn(`noneYet`,{plural:c})}):(0,X.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,X.jsx)(to,{model:e,view:t,target:o,targetView:i[a.resource],row:n},Rt(We(e,n))))}):(0,X.jsx)(O,{className:`h-40`}):null},ro=({node:e,slots:t,className:n})=>{let{resource:r,filter:i=``,sort:a,limit:o,display:s,title:c,description:l,empty:u}=U(e),{resources:d,views:f}=F(),p=d[r];if(!p)return null;let m=f[p.name];return(0,X.jsx)(V,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,X.jsx)(no,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,X.jsx)(lr,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,X.jsx)(eo,{model:p,view:m,limit:o,display:s,empty:u})})},io=e=>e.type===`boolean`||e.type===`enum`,ao=({model:e,fields:t,title:n,description:r,stored:i,className:a})=>{let{resources:o,views:s}=F(),c=Je(e.name),l=Vt(),u=Dt(),d=ln(),f=s[e.name],[p,m]=(0,Y.useState)(i),[h,g]=(0,Y.useState)(()=>ka(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=ka(e,t,void 0),ee=p?Fe(c,`update`)&&p.permissions?.update!==!1:Fe(c,`create`),te=t.filter(t=>!io(e.fields[t])),ne=te.some(t=>p?_(e.fields[t],h[t],p.record[t]):h[t]!==E[t]),re=async t=>{let n=T.current;if(n){let r=await l.update(e.name,n.key,Aa(e,t,n.record),n.etag??`*`);return{...It(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await l.create(e.name,Ct(e,o,{...E,...t}));return{...It(e,r.record),etag:r.etag}},D=t=>{let r=w.current.then(async()=>{C(!0),x(void 0),await re(t).then(async r=>{T.current=r,m(r),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await d(e.name),u.show({state:`success`,title:M(`saved`,{label:n??M(`settings`)})})},e=>{y(t=>({...t,...sn(e)})),x(e)}),C(!1)});w.current=r},ie=(t,n)=>{g(e=>({...e,[t]:n})),io(e.fields[t])&&D({[t]:n})};return(0,X.jsx)(V,{title:n,description:r,className:A(`h-full`,a),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),ne&&D(Object.fromEntries(te.map(e=>[e,h[e]])))},children:[b!==void 0&&Object.keys(v).length===0&&(0,X.jsx)(K,{title:M(`notSaved`),error:b}),t.map(t=>{let n=e.fields[t],r=f?.fields[t]?.label??Oe(t),i=v[t];return(0,X.jsx)(Ne,{name:t,label:r,help:f?.fields[t]?.help,error:i&&gn(n,r,i),children:(0,X.jsx)(st,{field:n,hints:f?.fields[t],value:h[t],stored:p?.record[t]??E[t],invalid:!!i,locked:!ee||n.readOnly,resource:e.name,onChange:e=>ie(t,e)})},t)}),ee&&ne&&(0,X.jsx)(`div`,{children:(0,X.jsx)(L,{type:`submit`,variant:`primary`,size:`sm`,loading:S,children:M(`save`)})})]})})},oo=e=>{let t=gt(e.model,{});return t.isPending?(0,X.jsx)(V,{title:e.title,description:e.description,className:e.className,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(O,{className:`h-4 w-1/2`}),(0,X.jsx)(O,{className:`h-4 w-1/3`})]})}):t.error?(0,X.jsx)(V,{title:e.title,description:e.description,className:e.className,children:(0,X.jsx)(K,{title:M(`couldNotLoad`),error:t.error})}):(0,X.jsx)(ao,{...e,stored:t.data??void 0})},so=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=U(e),o=F().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},co=(e,t)=>lo(e,t?[t]:[]),lo=(e,t)=>{let{resources:n}=F(),r=Vt(),i=JSON.stringify(e),a=(0,Y.useMemo)(()=>JSON.parse(i).map(T),[i]),o=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)),s=[...new Set(a.flatMap(e=>e.ok?e.paths:[]))],c=new Map(s.flatMap(e=>{let t=fn(e,o);return t===void 0?[]:[[e,t]]})),l=s.filter(e=>!c.has(e)),u=[...new Set(c.values())].flatMap(e=>n[e]?[n[e]]:[]),d=l.map(e=>Et(t,e)),f=lt(l.map((e,t)=>{let n=d[t];return n&&`frame`in n?{scope:n.frame,path:n.path}:{scope:void 0,path:e}})),p=Dn({queries:u.map(e=>rn(r,e))});return a.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=c.get(n);if(e===void 0){let e=l.indexOf(n),r=d[e];if(r&&`item`in r){t[n]=r.item;continue}let i=f[e];if(i.state===`loading`)return;i.state===`ready`&&(t[n]=i.value);continue}let r=u.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(p[r].isPending)return;else t[n]=p[r].data??0}return Le(e,t)})},uo=(e,t)=>typeof e.props.fallback==`string`?e.props.fallback:t.fallback,fo=({node:e,children:t,slots:n,className:r})=>{let{when:i}=U(e),[a]=lo([i],q());if(a===void 0)return null;let o=a?t:uo(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(Lt(e,z(t)).props.when)]),mo=({node:e,children:t,slots:n,className:r})=>{let i=q(),a=lo(po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?uo(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})},ho=({children:e})=>(0,X.jsx)(X.Fragment,{children:e}),go=`text-2xl font-semibold tracking-tight tabular-nums`,_o=({model:e,at:t,filter:n})=>{let{views:r}=F(),i=tn(t),a=xt(e,n,!i),o=i??a;if(o.isPending)return(0,X.jsx)(O,{className:`h-8 w-16`});if(o.error)return(0,X.jsx)(`span`,{className:`text-danger-text`,children:M(`couldNotCount`)});let s=i?er(i):a.data;return(0,X.jsx)(se,{to:Qn(r[e.name],e.name,n),className:`${go} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:s.toLocaleString(ze())})},vo=({field:e,format:t})=>{let n=Pt(e);return n.state===`loading`?(0,X.jsx)(O,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,X.jsx)(`span`,{className:go,children:ra(n.value)}):(0,X.jsx)(`span`,{className:go,children:(0,X.jsx)(yn,{model:n.model,field:n.field,value:n.value,format:t})})},yo=({node:e,at:t,className:n})=>{let{label:r,value:i,resource:a,filter:o,field:s,format:c,description:l}=U(e),{resources:u}=F(),d=a===void 0?void 0:u[a];return(0,X.jsxs)(V,{className:A(`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:go,children:i}),d&&(0,X.jsx)(_o,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,X.jsx)(vo,{field:s,format:c})]}),l&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},bo=(e,t,n)=>{let r=ye(),i=qn(t),[a,o]=(0,Y.useState)(()=>Vn(localStorage,i)),s=(0,Y.useCallback)(e=>{o(e),ir(localStorage,i,e)},[i]);return[rr(e,r,{picked:a,preferred:n}),s]},xo=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:s,className:c})=>{let{resources:l,views:u}=F(),d=u[e.name],{fields:f}=Ce(),p=Fe(Je(e.name),`update`),{go:h,href:g}=pe(),_=ye(),v=!ge(),y=(0,Y.useMemo)(()=>n?.map(bn)??Xt(e,d),[n,e,d]),b=(0,Y.useMemo)(()=>Ht(e,d,y,{resources:l,views:u,fieldTypes:f}),[e,d,y,l,u,f]),x=(0,Y.useMemo)(()=>_?Qt(n)(b):b,[_,n,b]),S=(0,Y.useMemo)(()=>r?Xn(x,e,d,r,l,v):x,[x,e,d,r,l,v]),C=(0,Y.useMemo)(()=>t.map(t=>({...t,id:m(e,t)})),[t,e]),w=(0,Y.useMemo)(()=>({total:C.length,rowAt:e=>C[e]}),[C]),T=tr({model:e,view:d,opens:void 0,resources:l,views:u,canUpdate:p}),E=e=>({href:g(e),onFollow:()=>h(e)});return(0,X.jsx)(V,{title:i,description:a,actions:s,className:c,children:C.length===0?(0,X.jsx)(qt,{children:o??M(`nothingYet`)}):(0,X.jsx)(Fn,{fit:!0,columns:S,source:w,latencyMs:0,onOpenRow:e=>h(T.address(e)),rowLink:e=>E(T.address(e)),rowActions:T.actions(E),rowNumbers:!1,selectable:!1})})},So=e=>{let t=dt();return t?.model?(0,X.jsx)(xo,{...e,model:t.model,items:t.items}):null},Co=({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,_]=bo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?bt:g,y=(0,Y.useMemo)(()=>i?.map(bn),[i]),b=(0,Y.useMemo)(()=>Qt(i),[i]);return(0,X.jsxs)(V,{title:l,description:u,actions:(0,X.jsxs)(X.Fragment,{children:[!m&&(0,X.jsx)(ar,{view:t,value:v,onChange:_}),f]}),className:A(`h-full`,p),children:[(0,X.jsx)($n,{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]})},wo=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,children:c,...l}=U(e),{resources:u,views:d}=F(),[f,p]=zt([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)(So,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,X.jsx)(Co,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,X.jsx)(To,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},To=({select:e,children:t,...n})=>{let{given:r,linkTo:a}=i(),o=t=>a({[e]:t}),s=r[e],c=s===void 0?null:(0,X.jsx)(Ke,{name:e,children:(0,X.jsx)(li,{model:n.model,query:{key:s},children:t},s)});return(0,X.jsx)(Co,{...n,chosen:{rowTo:o,key:s,details:c}})},Eo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=_n(),{navigate:a}=He(),o=cn(e),s=nt(o,r),c=e=>i(e===o[0]?.name?void 0:e);return(0,X.jsxs)(`div`,{className:A(`flex flex-col gap-6`,n),children:[(0,X.jsxs)(`select`,{"aria-label":M(`tabs`),value:s?.name??``,onChange:e=>a(c(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!s&&(0,X.jsx)(`option`,{value:``,disabled:!0}),o.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,X.jsx)(`nav`,{"aria-label":M(`tabs`),className:`hidden border-b md:block`,children:(0,X.jsx)(`ul`,{className:`flex gap-1`,children:o.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Ge,{to:c(e.name),"aria-current":e===s?`page`:void 0,className:A(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===s?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),s?(0,X.jsx)(Y.Fragment,{children:t[o.indexOf(s)]},s.name):(0,X.jsx)(re,{children:M(`noTab`,{name:r??``})})]})},Do=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Oo=e=>e===void 0?1/0:Date.parse(e),ko=(e,t)=>{let n=e=>e.more&&e.items.length>0?Oo(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&&Oo(e.items[a].time)>=Oo(t.items[o].time)?e.items[a++]:t.items[o++];if(Oo(n.time)<r)break;i.push(n)}return i},Ao=({value:e,hints:t,mark:n})=>{let r=$e(e,t?.valueLabels);return n===`done`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(C,{"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)(o,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&vn(t?.valueColors,e)!==`red`?r:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,X.jsx)(fr,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},jo=({value:e})=>{let t=typeof e==`string`?Ee(e):e;return t===ee?(0,X.jsx)(de,{children:String(e)}):(0,X.jsx)(ae,{value:t})},Mo=({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]}),No=({call:e,statusHints:t})=>{let[n,r]=(0,Y.useState)(!1),i=(0,Y.useId)(),a=e.status!==void 0&&(0,X.jsx)(Ao,{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)(L,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,X.jsx)(v,{"aria-hidden":!0,className:A(`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)(Mo,{label:Q(`callInput`),children:(0,X.jsx)(jo,{value:e.input})}),e.result!==void 0&&(0,X.jsx)(Mo,{label:Q(`callResult`),children:(0,X.jsx)(jo,{value:e.result})}),e.error!==void 0&&(0,X.jsx)(Mo,{label:Q(`callError`),children:(0,X.jsx)(de,{children:e.error})})]})]})},Po=(e,t)=>e.map(e=>({kind:`message`,row:e,time:typeof e[t]==`string`?e[t]:void 0})),Fo=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}}},Io=(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&&De(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:Se(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:Fo(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},Lo=e=>zr.includes(e??``)?e:void 0,Ro=e=>e==null||e===``?void 0:String(e),zo=e=>`call:${JSON.stringify(e)}`,Bo=(e,t,n)=>{let r=Ro(e[n.status]),i=Lo(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:Ro(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}}},Vo=({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}},Ho=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,Y.useState)(!1),s=be(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]),Vo({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},Uo=(e,t,n)=>{let{views:r}=F(),i=e?.model.name??``,a=Ho(i,{filter:e?.filter,orderBy:e&&l(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>Bo(t,zo(We(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}},Wo=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,Go=(e,t)=>e.isLoading?t.loading:t.empty,Ko=e=>e.items.length>0&&!!e.error,qo=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),Jo=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},Yo=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:d,planned:f})=>{let{resources:p,views:m}=F(),h=on(),g=h?.state.kind===`signed-in`?h.state.user.id:void 0,_=n===void 0?[]:[n],v=ce(p,m,e,_),y=Ho(e.name,{filter:t,orderBy:l(r),pageSize:o,labels:v},f?.messages),x=Uo(d,o,f?.calls),S=Wo(y);if(S===`error`)return(0,X.jsx)(K,{title:Q(`couldNotLoad`),error:y.error,onRetry:qo(y)});if(S===`loading`)return(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(qt,{children:Q(`loadingMessages`)})});let C=Ze(p,e,_,y.items,y.labels),w=ko({items:x.calls,more:x.hasNextPage},{items:Po(C,r),more:y.hasNextPage}),T=Io(w,{key:t=>String(We(e,t)),sender:n,time:r,text:i,status:a}),E=a===void 0?void 0:m[e.name]?.fields[a],ee=e.fields[i]!==void 0&&mn(e.fields[i],m[e.name]?.fields[i]),te=T.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===g);return(0,X.jsxs)(X.Fragment,{children:[Ko(y)&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(K,{title:Q(`couldNotLoad`),error:y.error,onRetry:qo(y)})}),d&&x.list.error&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(K,{title:Q(`couldNotLoadCalls`),error:x.list.error,onRetry:qo(x.list)})}),(0,X.jsx)(u,{length:w.length,followKey:te?.key,working:c,empty:Go(x.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:y.hasNextPage||x.hasNextPage?()=>Jo([y,x.list]):void 0,loadingEarlier:y.isFetchingNextPage||x.isFetchingNextPage,children:T.map(e=>e.kind===`day`?(0,X.jsx)(ve,{label:e.label},e.key):e.kind===`call`?(0,X.jsx)(No,{call:e,statusHints:x.statusHints},e.key):(0,X.jsx)(kt,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,X.jsx)(Ao,{value:e.status,hints:E}),children:ee&&e.text!==``?(0,X.jsx)(b,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},Xo=({children:e})=>(0,X.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),Zo=({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}=U(e),{resources:g}=F(),[_]=lo(f===void 0?[]:[f],q()),[v,y]=zt([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:A(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,X.jsx)(E,{title:i,help:a,actions:n.actions,children:(0,X.jsx)(Xo,{children:(0,X.jsx)(Yo,{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}}})})})})},Qo=({children:e,className:t})=>(0,X.jsx)(`div`,{className:t,children:e}),$o=({children:e,className:t})=>(0,X.jsx)(`div`,{className:A(`flex`,t),children:e}),es=({children:e,className:t})=>(0,X.jsx)(`div`,{className:A(`flex flex-col`,t),children:e}),ts=({node:e,children:t,className:n})=>{let{as:r=`p`}=U(e);return(0,X.jsx)(r,{className:n,children:t})},ns=({node:e,children:t})=>{let{source:n}=U(e),r=_t(z(q()),n),i=(0,Y.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,X.jsx)(Ft,{value:i,children:t})},rs=({node:e,className:t})=>{let{source:n,choices:r,label:a=n,defaultValue:o}=U(e),{values:s,linkTo:c}=i(),l=s[n];return(0,X.jsxs)(`div`,{className:A(`flex flex-wrap items-center gap-2`,t),children:[(0,X.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:a}),r?(0,X.jsx)(d,{label:a,value:l??``,options:r.map(e=>({value:String(e.id),label:e.name})),link:e=>c({[n]:o!==void 0&&e===String(o)?void 0:e})}):(0,X.jsx)(`span`,{children:l})]})},is=({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}}}},as=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,Y.useState)(!1),c=be(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]),is({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}})},os=({node:e,at:t,children:n})=>{let r=U(e),i=F().resources[r.reference],a=St(z(q())),o=tn(t);return i?(0,X.jsx)(ss,{model:i,...hn(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},ss=({empty:e,children:t,...n})=>{let{read:r,list:i}=as(n);return(0,X.jsx)(an,{read:r,list:i,empty:e,children:t})},cs=({node:e,at:t,children:n})=>{let r=U(e),i=F().resources[r.reference],a=St(z(q())),o=tn(t);return i?(0,X.jsx)(ss,{model:i,...ct(r,i.primaryKey[0],a),more:!1,empty:r.empty,...o&&{planned:o},children:n}):null},ls=({model:e,at:t,recordKey:n,link:r=`edit`,children:i,className:a})=>{let{views:o}=F(),s=tn(t),c=gt(e,{key:n,enabled:!s}),l=s?Kt(e,s):c;if(l.isPending)return(0,X.jsx)(O,{className:`h-4 w-24`});if(l.error)return(0,X.jsx)(K,{title:M(`couldNotLoad`),error:l.error});if(!l.data)return null;let u=i.length>0?(0,X.jsx)(Bt,{value:l.data,children:i}):Xe(e,o[e.name],l.data.record,n);return r===!1?(0,X.jsx)(`span`,{className:a,children:u}):(0,X.jsx)(se,{to:{kind:`record`,resource:e.name,key:n},className:a??`font-medium text-primary-text hover:underline`,children:u})},us=({node:e,at:t,children:n,className:r})=>{let{reference:i,source:a,link:o,empty:s}=U(e),c=F().resources[i],l=_t(z(q()),a);return c?l==null||l===``?s===void 0?null:(0,X.jsx)(`span`,{className:r,children:s}):(0,X.jsx)(ls,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},ds=(e,t)=>t.map(t=>Yt(e,t)).join(`, `),$=p(`users`),fs=({roles:e})=>{let{session:t}=G(),[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)(mr,{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)(gr,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,X.jsx)(N,{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)(hr,{email:n.email,gives:ds(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}=G(),[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}=Re(),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)(N,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,X.jsx)(D,{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)(R,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,X.jsx)(R,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,X.jsx)(R,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(gr,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,X.jsx)(`div`,{children:(0,X.jsx)(L,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},ms=({user:e,roles:t,self:n})=>{let{session:r}=G(),[i,a]=(0,Y.useState)(e),{busy:o,error:s,run:c,setError:l}=Re(),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)(_r,{name:i.name,email:i.email,self:n,error:s,actions:(0,X.jsxs)(X.Fragment,{children:[i.blocked&&(0,X.jsx)(P,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,X.jsx)(L,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,X.jsx)(L,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,X.jsx)(gr,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},hs=({roles:e,version:t})=>{let{session:n,state:r}=G(),[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=yr(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,X.jsx)(vr,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,X.jsx)(ms,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},gs=()=>{let{session:e}=G(),[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)();return(0,Y.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof H?k(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},_s=()=>{let{roles:e,error:t}=gs(),[n,r]=(0,Y.useState)(0);return(0,X.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,X.jsx)(D,{message:t}),(0,X.jsx)(hs,{roles:e,version:n}),(0,X.jsx)(fs,{roles:e}),(0,X.jsx)(ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},vs=({sender:e,busy:t,error:n,onSave:r,onClose:i})=>{let[a,o]=(0,Y.useState)(e?.address??``),[s,c]=(0,Y.useState)(e?.name??``),[l,u]=(0,Y.useState)(e?.signature??``),[d,f]=(0,Y.useState)(e?.isDefault??!1);return(0,X.jsxs)(I,{title:e?e.address:B(`addFromAddress`),description:B(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:i,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:i,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:t,disabled:!a.trim(),onClick:()=>r({address:a.trim(),name:s.trim(),signature:l,isDefault:d}),children:B(e?`save`:`addAddress`)})]}),children:[!e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`fromAddress`),(0,X.jsx)(R,{autoFocus:!0,type:`email`,value:a,maxLength:254,placeholder:B(`fromAddressPlaceholder`),onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[B(`fromName`),(0,X.jsx)(R,{value:s,maxLength:100,placeholder:B(`fromNamePlaceholder`),onChange:e=>c(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:B(`defaultFromAddress`)}),(0,X.jsx)(me,{checked:d,onChange:f,label:B(`defaultFromAddress`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[B(`signature`),(0,X.jsx)(Pe,{value:l,maxLength:2e3,placeholder:B(`signaturePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,X.jsx)(D,{message:n})]})},ys=e=>e.signature?B(`ownSignature`):B(`genericSignature`),bs=({senders:{address:e,senders:t},onAdd:n,onUpdate:r,onRemove:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(),d=(0,Y.useRef)(!1),f=t.find(e=>e.isDefault),p=()=>{u(void 0),c(void 0)},m=async e=>{if(!d.current){d.current=!0,o(!0),c(void 0);try{await e(),u(void 0)}catch(e){if(e instanceof TypeError)return c(B(`noAnswerFromServer`));if(!(e instanceof H))throw e;c(k(e))}finally{d.current=!1,o(!1)}}},h=e=>m(async()=>{let t=e.name||null,i=e.signature.trim()?e.signature:null;if(l?.kind===`change`)return r(l.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:B(`fromAddresses`)}),(0,X.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:B(`fromAddressesDescription`)}),(0,X.jsx)(D,{message:l?void 0:s}),(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)(wr,{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:B(`mailboxOwnAddress`)})]}),f?(0,X.jsx)(L,{size:`sm`,variant:`ghost`,loading:a,onClick:()=>void m(()=>r(f.id,{isDefault:!1})),children:B(`makeDefault`)}):(0,X.jsx)(P,{tone:`blue`,children:B(`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)(wr,{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:ys(e)})]}),e.isDefault&&(0,X.jsx)(P,{tone:`blue`,children:B(`default`)}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>u({kind:`change`,sender:e}),children:B(`edit`)}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>u({kind:`remove`,sender:e}),children:B(`remove`)})]},e.id))]}),(0,X.jsxs)(L,{onClick:()=>u({kind:`add`}),children:[(0,X.jsx)(Nt,{className:`size-3.5`}),B(`addFromAddress`)]}),l?.kind===`add`&&(0,X.jsx)(vs,{busy:a,error:s,onSave:e=>void h(e),onClose:p}),l?.kind===`change`&&(0,X.jsx)(vs,{sender:l.sender,busy:a,error:s,onSave:e=>void h(e),onClose:p},l.sender.id),l?.kind===`remove`&&(0,X.jsx)(I,{title:B(`removeFromAddress`,{address:l.sender.address}),description:B(`removeFromAddressDescription`),onClose:p,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:p,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,loading:a,onClick:()=>void m(()=>i(l.sender.id)),children:B(`remove`)})]}),children:(0,X.jsx)(D,{message:s})})]})},xs=(e,t,n)=>Object.fromEntries(Pn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,Yn(`signInOnly`,{provider:n(e.provider),name:e.name})])),Ss=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=G(),{account:i}=t,[a]=(0,Y.useState)(fe),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}=j(o,B(`couldNotReadMethods`));return s?(0,X.jsx)(h,{title:B(`mailbox`),description:B(`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??ft(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&Zt(a,e.length===1?e[0].name:B(`theProvider`)),children:(0,X.jsx)(bs,{senders:s.senders,onAdd:async e=>{let t=await i.addMailSender(e);return await l(),t},onUpdate:async(e,t)=>{await i.updateMailSender(e,t),await l()},onRemove:async e=>{await i.removeMailSender(e),await l()}})}):(0,X.jsx)(J,{error:c})},Cs=()=>{let{personalMail:e}=G();return e.length>0?(0,X.jsx)(Ss,{links:e}):null},ws=e=>br(e.name)??`An unnamed app`,Ts=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),Es=({apps:e,onDisconnect:t})=>{let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(),c=async e=>{r(!0),a(void 0);try{await t(e.clientId),s(void 0)}catch(e){if(!(e instanceof H))throw e;a(k(e))}r(!1)};return(0,X.jsxs)(N,{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)(D,{message:o?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=xr(e.clientId);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Er,{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:ws(e)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,et(Date.parse(e.allowedAt)),` · `,Ts(e)]})]}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>s(e),children:`Disconnect`})]},e.clientId)})}),o&&(0,X.jsx)(I,{title:`Disconnect ${ws(o)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>s(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>s(void 0),children:`Cancel`}),(0,X.jsx)(L,{variant:`danger`,loading:n,onClick:()=>void c(o),children:`Disconnect`})]}),children:i&&(0,X.jsx)(D,{message:i})})]})},Ds=(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},Os=({url:e,appName:t})=>(0,X.jsx)(N,{title:B(`mcpAddress`),description:B(`mcpAddressDescription`),children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Sr,{value:e,copyLabel:B(`copyMcpAddress`)}),(0,X.jsxs)(`a`,{href:Ds(e,t),target:`_blank`,rel:`noreferrer`,className:Me(),children:[(0,X.jsx)(mt,{className:`size-3.5`}),B(`addToClaude`)]})]})}),ks=()=>{let{account:e}=G().session,{data:t,error:n,reload:r}=j((0,Y.useCallback)(()=>e.connectedApps(),[e]),B(`couldNotReadMethods`));return t?(0,X.jsx)(Es,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,X.jsx)(J,{error:n})},As=({url:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Os,{url:e,appName:F().appName}),(0,X.jsx)(ks,{})]}),js=()=>{let{mcp:e}=G();return e?(0,X.jsx)(As,{url:e.url}):null},Ms={30:30,90:90,365:365,never:void 0},Ns={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},Ps=e=>et(Date.parse(e)),Fs=e=>e?B(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:Ps(e)}):B(`neverExpires`),Is=e=>[B(`createdOn`,{date:Ps(e.createdAt)}),Fs(e.expiresAt),e.lastUsedAt?B(`lastUsedOn`,{date:Ps(e.lastUsedAt)}):B(`notUsedYet`),e.organization?B(`actsAsIn`,{role:e.role,organization:e.organization}):B(`actsAs`,{role:e.role})].join(` · `),Ls=({tokens:e,onCreate:t,onRevoke:n})=>{let[i,a]=(0,Y.useState)(!1),[o,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,a(!0),s(void 0);try{l(await e()),h(void 0)}catch(e){if(e instanceof TypeError)return s(B(`noAnswerFromServer`));if(!(e instanceof H))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):s(k(e))}finally{_.current=!1,a(!1)}}},y=()=>v(async()=>{let e=Ms[f];return{kind:`created`,created:await t({name:u.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,X.jsxs)(N,{title:B(`accessTokens`),description:B(`accessTokensDescription`),children:[(0,X.jsx)(D,{message:c?void 0:o}),e.length===0?(0,X.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:B(`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)(Or,{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:Is(e)})]}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>l({kind:`revoke`,token:e}),children:B(`revoke`)})]},e.id))}),(0,X.jsxs)(L,{onClick:()=>{d(``),p(`90`),l({kind:`create`})},children:[(0,X.jsx)(Nt,{className:`size-3.5`}),B(`newAccessToken`)]}),c?.kind===`create`&&(0,X.jsxs)(I,{title:B(`newAccessToken`),description:B(`newAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:g,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:i,disabled:!u.trim(),onClick:()=>void y(),children:B(`createAccessToken`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`name`),(0,X.jsx)(R,{autoFocus:!0,value:u,maxLength:100,placeholder:B(`accessTokenNamePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[B(`accessTokenExpiry`),(0,X.jsx)(Ue,{value:f,onChange:e=>p(e.target.value),children:Object.keys(Ms).map(e=>(0,X.jsx)(`option`,{value:e,children:B(Ns[e])},e))})]}),m===`asked`&&(0,X.jsx)(r,{purpose:`change`,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:B(`confirmedCreateAccessToken`)}),(0,X.jsx)(D,{message:o})]}),c?.kind===`created`&&(0,X.jsx)(I,{title:B(`accessTokenCreated`,{name:c.created.personalAccessToken.name}),description:B(`accessTokenCreatedDescription`),onClose:g,actions:(0,X.jsx)(L,{variant:`primary`,onClick:g,children:B(`done`)}),children:(0,X.jsx)(Sr,{value:c.created.token,copyLabel:B(`copyAccessToken`)})}),c?.kind===`revoke`&&(0,X.jsx)(I,{title:B(`revokeAccessToken`,{name:c.token.name}),description:B(`revokeAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:g,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,loading:i,onClick:()=>void v(async()=>(await n(c.token.id),void 0)),children:B(`revoke`)})]}),children:(0,X.jsx)(D,{message:o})})]})},Rs=()=>{let{account:e}=G().session,{data:t,error:n,reload:r}=j((0,Y.useCallback)(()=>e.personalAccessTokens(),[e]),B(`couldNotReadAccessTokens`));return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(D,{message:n}),(0,X.jsx)(Ls,{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)(J,{error:n})},zs=()=>G().personalAccessTokens?(0,X.jsx)(Rs,{}):null,Bs={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},Vs=e=>e.provider===`google`,Hs=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(r),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=async(e,t)=>{a(e),s(void 0),d(void 0);try{await t(),l(void 0)}catch(e){if(!(e instanceof H))throw e;s(k(e))}finally{a(void 0)}};return(0,X.jsxs)(N,{title:B(`connections`),description:B(`connectionsDescription`),children:[(0,X.jsx)(D,{message:c?void 0:o}),(0,X.jsx)(Ve,{message:u}),(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)(Mr,{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)(L,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void f(e.key,()=>t(e)),children:e.accounts.length>0?B(`connectAgain`,{name:e.label}):B(`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:[B(`connectedOn`,{date:et(Date.parse(t.created_at))}),` · `,(0,X.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,X.jsx)(P,{tone:`amber`,children:B(`connectionNeedsSignIn`)}):(0,X.jsx)(P,{tone:`green`,children:B(`connected`)}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>l({connection:e,accountId:t.id}),children:B(`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:B(`connectionUsedBy`)}),t.used_by.map(e=>(0,X.jsx)(ne,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),c&&(0,X.jsx)(I,{title:B(`disconnectTitle`,{name:c.connection.label}),description:Vs(c.connection)?`${B(`disconnectDescription`)} ${B(`disconnectWholeGrant`)}`:B(`disconnectDescription`),onClose:()=>l(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>l(void 0),children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,loading:i===c.accountId,onClick:()=>void f(c.accountId,async()=>d(B(Bs[await n(c.accountId)]))),children:B(`disconnect`)})]}),children:o&&(0,X.jsx)(D,{message:o})})]})},Us=()=>{let{session:e,connectAccount:t}=G(),{account:n}=e,[r]=(0,Y.useState)(fe),{data:i,error:a,reload:o}=j((0,Y.useCallback)(()=>n.workflowConnections(),[n]),B(`couldNotReadMethods`));return i?i.length===0?null:(0,X.jsx)(Hs,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&Zt(r,B(`theProvider`))}):(0,X.jsx)(J,{error:a})},Ws=e=>e.code===`LAST_ADMIN`?B(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?B(`deleteAccountLocked`):k(e),Gs=({hasPassword:e,onDelete:t,onClose:n})=>{let[i,a]=(0,Y.useState)(``),[o,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?i:void 0)}catch(e){if(!(e instanceof H))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?d(!0):l(Ws(e)),s(!1)}};return(0,X.jsxs)(I,{title:B(`deleteAccountQuestion`),description:B(`deleteAccountWarning`),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:n,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,type:`submit`,form:f,loading:o,disabled:e&&!i,children:B(`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:[B(`deleteAccountPassword`),(0,X.jsx)(R,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:i,invalid:!!c,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(D,{message:c})]}),u&&(0,X.jsx)(r,{purpose:`change`,minutes:15,onConfirmed:()=>void p()})]})},Ks=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(N,{title:B(`deleteAccount`),description:B(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,X.jsx)(L,{variant:`danger`,onClick:()=>i(!0),children:B(`deleteAccount`)}),r&&(0,X.jsx)(Gs,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},qs=()=>{let{session:e,state:t,deleteAccount:n}=G(),{account:r}=e,{data:i,error:a}=j((0,Y.useCallback)(()=>r.signInMethods(),[r]),B(`couldNotReadMethods`));return i?(0,X.jsx)(Ks,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,X.jsx)(J,{error:a})},Js=[[/Edg(e|A|iOS)?\//,`Edge`],[/OPR\/|Opera/,`Opera`],[/SamsungBrowser\//,`Samsung Internet`],[/Firefox\/|FxiOS\//,`Firefox`],[/Chrome\/|CriOS\//,`Chrome`],[/Safari\//,`Safari`]],Ys=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/CrOS/,`ChromeOS`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/Linux/,`Linux`]],Xs=(e,t)=>e.find(([e])=>e.test(t))?.[1],Zs=e=>e?{browser:Xs(Js,e),system:Xs(Ys,e)}:{},Qs=e=>e.device?B(`deviceThrough`,{device:e.device,provider:e.name}):e.name,$s=(e,t)=>{if(e.staff)return t?B(`staffOf`,{operator:t}):B(`staff`);let{browser:n,system:r}=Zs(e.userAgent);return n&&r?B(`browserOn`,{browser:n,system:r}):r?B(`aBrowserOn`,{system:r}):n??B(`unknownDevice`)},ec=e=>{if(e.staff)return Pr;let{system:t}=Zs(e.userAgent);return t===`iPhone`||t===`Android`?Ir:t===`iPad`?Rr:Ar},tc=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),nc=(e,t)=>e.kind===`one`?B(`signOutDevice`,{name:$s(e.session,t)}):e.kind===`link`?B(`signOutDevice`,{name:Qs(e.link)}):B(`signOutOthersTitle`),rc=e=>B(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),ic=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),p=e.filter(e=>!e.current),m=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),h=async e=>{s(!0),l(void 0);try{await m(e),d(void 0)}catch(e){if(!(e instanceof H))throw e;l(k(e))}s(!1)},g=e=>{l(void 0),d(e)};return(0,X.jsxs)(N,{title:B(`devices`),description:B(`devicesDescription`),children:[f.length===0&&n.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:B(`noDevices`)}):(0,X.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[tc(f).map(e=>{let n=ec(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:$s(e,t)}),e.current&&(0,X.jsx)(P,{tone:`green`,children:B(`thisDevice`)})]}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[B(`signedInFromUntil`,{from:ke(Date.parse(e.createdAt)),until:ke(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`one`,session:e}),children:B(`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)(Ir,{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:Qs(t)}),n&&(0,X.jsx)(P,{tone:`green`,children:B(`thisDevice`)})]}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:B(`linkedOn`,{date:ke(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`link`,link:t}),children:B(`signOut`)})]},t.id)})]}),p.length>0&&(0,X.jsx)(L,{className:`mt-3`,onClick:()=>g({kind:`others`}),children:B(`signOutOthers`)}),u&&(0,X.jsx)(I,{title:nc(u,t),description:rc(u),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>d(void 0),children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,loading:o,onClick:()=>void h(u),children:B(`signOut`)})]}),children:(0,X.jsx)(D,{message:c})})]})},ac=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=G(),{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}=j(i,B(`couldNotReadDevices`));return a?(0,X.jsx)(ic,{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)(J,{error:o})},oc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},sc=({rule:e,passkeys:t,onAdd:n,onRename:i,onRemove:a})=>{let[o,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 H))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):l(k(e))}s(!1)};return(0,X.jsxs)(N,{title:B(`passkeys`),status:e===`required`&&(0,X.jsx)(P,{tone:`blue`,children:B(`required`)}),description:B(oc[e]),children:[(0,X.jsx)(D,{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)(Gt,{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??B(`passkey`)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?B(`addedOn`,{date:et(Date.parse(e.createdAt))}):B(`addedEarlier`),` · `,e.backedUp?B(`synced`):B(`oneDevice`)]})]}),(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>{p(e.name??``),d({kind:`rename`,passkey:e})},children:B(`rename`)}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,disabled:g,title:g?B(`keepLastPasskey`):void 0,onClick:()=>d({kind:`remove`,passkey:e}),children:B(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,X.jsxs)(L,{loading:o&&!u,onClick:()=>void _(n),children:[(0,X.jsx)(Nt,{className:`size-3.5`}),B(`addPasskey`)]}),m===`asked`&&(0,X.jsx)(r,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:B(`confirmedAddPasskey`)}),u?.kind===`rename`&&(0,X.jsxs)(I,{title:B(`renamePasskey`),description:B(`renamePasskeyDescription`),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>d(void 0),children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:o,disabled:!f.trim(),onClick:()=>void _(()=>i(u.passkey.id,f.trim())),children:B(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`name`),(0,X.jsx)(R,{autoFocus:!0,value:f,maxLength:60,onChange:e=>p(e.target.value)})]}),(0,X.jsx)(D,{message:c})]}),u?.kind===`remove`&&(0,X.jsx)(I,{title:B(`removePasskey`),description:B(`removePasskeyDescription`,{name:u.passkey.name??B(`thisPasskey`)}),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>d(void 0),children:B(`cancel`)}),(0,X.jsx)(L,{variant:`danger`,loading:o,onClick:()=>void _(()=>a(u.passkey.id)),children:B(`remove`)})]}),children:c&&(0,X.jsx)(D,{message:c})})]})},cc=()=>{let{account:e}=G().session,t=(0,Y.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=j(t,B(`couldNotReadMethods`));if(!n)return(0,X.jsx)(J,{error:r});let[a,o]=n;return(0,X.jsx)(sc,{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)})},lc=e=>e.code===`PASSWORD_TOO_SHORT`?B(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?B(`passwordTooLong`):k(e),uc=(e,t)=>{if(e.length<12)return B(`useAtLeast`,{length:12});if(e!==t)return B(`passwordsDiffer`)},dc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(),p=(0,Y.useId)(),m=(!e||r)&&a&&s,h=async()=>{let e=uc(a,s);if(f(e),!e){u(!0);try{await t({current:r,next:a})}catch(e){if(!(e instanceof H))throw e;f(lc(e)),u(!1)}}};return(0,X.jsx)(I,{title:B(e?`changePassword`:`setPassword`),description:B(`atLeast`,{length:12}),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:n,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,type:`submit`,form:p,loading:l,disabled:!m,children:B(`save`)})]}),children:(0,X.jsxs)(`form`,{id:p,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`currentPassword`),(0,X.jsx)(R,{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:[B(`newPassword`),(0,X.jsx)(R,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!d,onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`repeatPassword`),(0,X.jsx)(R,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:s,invalid:!!d,onChange:e=>c(e.target.value)})]}),e&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:B(`changeSignsOutOthers`)}),(0,X.jsx)(D,{message:d})]})})},fc=({rule:e,hasPassword:t,staff:n})=>B(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)(N,{title:B(`password`),description:fc({rule:e,hasPassword:t,staff:n}),children:[(0,X.jsx)(Ve,{message:s?B(`passwordSaved`):void 0}),l&&(0,X.jsx)(L,{onClick:()=>{c(!1),o(!0)},children:B(t?`changePassword`:`setPassword`)}),a&&(0,X.jsx)(dc,{hasPassword:t,onClose:()=>o(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):i(n)),o(!1),c(!0)}})]})},mc=()=>{let{session:e,state:t}=G(),{account:n}=e,{data:r,error:i,reload:a}=j((0,Y.useCallback)(()=>n.signInMethods(),[n]),B(`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)(J,{error:i})},hc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),m=async e=>{d(!0),p(void 0);try{await e()}catch(e){if(!(e instanceof H))throw e;p(k(e))}d(!1)},h=i.trim(),g=()=>m(async()=>{await t.request(h),l(``),s(h)}),_=e=>m(async()=>{await t.confirm(o,e),n()});return o?(0,X.jsxs)(I,{title:B(`changeEmail`),description:B(`codeSentTo`,{email:o,minutes:10}),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{variant:`ghost`,onClick:()=>{s(void 0),p(void 0)},children:B(`otherAddress`)}),(0,X.jsx)(L,{variant:`primary`,loading:u,disabled:c.length<6,onClick:()=>void _(c),children:B(`changeEmail`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`code`),(0,X.jsx)(Ut,{name:`code`,required:!0,autoFocus:!0,value:c,invalid:!!f,onChange:l,onComplete:e=>!u&&void _(e)})]}),(0,X.jsx)(D,{message:f})]}):(0,X.jsxs)(I,{title:B(`changeEmail`),description:B(`changeEmailDescription`),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:r,children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:u,disabled:!h||h.toLowerCase()===e.toLowerCase(),onClick:()=>void g(),children:B(`sendCode`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`newEmail`),(0,X.jsx)(R,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(D,{message:f})]})},gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=async()=>{f(!0),m(void 0);try{await n(l.trim()),o(!1)}catch(e){if(!(e instanceof H))throw e;m(k(e))}f(!1)};return(0,X.jsxs)(N,{title:B(`profile`),description:B(`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:B(`name`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:B(`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)(L,{onClick:()=>{u(e),m(void 0),o(!0)},children:B(`changeName`)}),r&&(0,X.jsx)(L,{onClick:()=>c(!0),children:B(`changeEmail`)})]}),a&&(0,X.jsxs)(I,{title:B(`changeName`),description:B(`changeNameDescription`),onClose:()=>o(!1),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>o(!1),children:B(`cancel`)}),(0,X.jsx)(L,{variant:`primary`,loading:d,disabled:!l.trim()||l.trim()===e,onClick:()=>void h(),children:B(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`name`),(0,X.jsx)(R,{autoFocus:!0,value:l,maxLength:100,onChange:e=>u(e.target.value)})]}),(0,X.jsx)(D,{message:p})]}),s&&r&&(0,X.jsx)(hc,{email:t,change:r,onClose:()=>c(!1),onDone:()=>{c(!1),i?.()}})]})},_c=()=>{let{session:e,changeEmail:t}=G(),{data:n,loaded:r,error:i,reload:a}=j((0,Y.useCallback)(()=>e.session(),[e]),B(`couldNotReadProfile`));if(!r)return(0,X.jsx)(J,{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})},vc=({title:e,description:t,confirmLabel:n,danger:i,needsPassword:a,onConfirm:o,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 o(a?c:void 0)}catch(e){if(!(e instanceof H))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(!0):p(k(e)),d(!1)}};return(0,X.jsxs)(I,{title:e,description:t,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:s,children:B(`cancel`)}),(0,X.jsx)(L,{variant:i?`danger`:`primary`,loading:u,disabled:a&&!c,onClick:()=>void g(),children:n})]}),children:[a&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`yourPassword`),(0,X.jsx)(R,{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)(r,{purpose:`change`,minutes:15,onConfirmed:()=>void g()})]})},yc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},bc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,Y.useState)(),d=()=>u(void 0),f=n?(0,X.jsx)(P,{tone:`green`,children:B(`on`)}):t===`required`?(0,X.jsx)(P,{tone:`amber`,children:B(`required`)}):(0,X.jsx)(P,{children:B(`off`)}),p=B(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:yc[t]);return l?.kind===`setup`?(0,X.jsx)(N,{title:B(`twoFactor`),status:f,description:p,children:(0,X.jsx)(`div`,{className:`max-w-sm`,children:(0,X.jsx)(qe,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,X.jsxs)(N,{title:B(`twoFactor`),status:f,description:p,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,X.jsx)(L,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:B(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,X.jsx)(L,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:B(`addAuthenticator`)}),n&&r&&(0,X.jsx)(L,{onClick:()=>u({kind:`new-codes`}),children:B(`newBackupCodes`)}),n&&(0,X.jsx)(L,{variant:`danger`,disabled:t===`required`,title:t===`required`?B(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:B(`turnOff`)})]}),l?.kind===`turn-off`&&(0,X.jsx)(vc,{title:B(`turnOffTitle`),description:B(`turnOffDescription`),confirmLabel:B(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,X.jsx)(vc,{title:B(`newCodesTitle`),description:B(`newCodesDescription`),confirmLabel:B(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,X.jsx)(I,{title:B(`yourNewCodes`),description:B(`keepCodesSafe`),onClose:d,actions:(0,X.jsx)(L,{variant:`primary`,onClick:d,children:B(`savedCodes`)}),children:(0,X.jsx)(Qe,{codes:l.codes})})]})},xc=()=>{let{account:e}=G().session,{data:t,error:n,reload:r}=j((0,Y.useCallback)(()=>e.signInMethods(),[e]),B(`couldNotReadMethods`));return t?(0,X.jsx)(bc,{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)(J,{error:n})},Sc=({problem:e,fallback:t})=>t===void 0?(0,X.jsx)(re,{children:e}):(0,X.jsxs)(X.Fragment,{children:[!1,t]}),Cc=({name:e,registered:t,fallback:n,children:r})=>t?(0,X.jsx)(f,{name:e,fallback:n===void 0?void 0:(0,X.jsx)(Sc,{problem:M.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,X.jsx)(Sc,{problem:M.rich(`noComponent`,{component:e}),fallback:n}),wc={Page:Pa,Grid:ua,Card:ri,Stat:yo,RecordCard:Ra,Field:aa,Diff:na,Table:wo,CardRow:si,RecordRow:ro,RecordCards:$a,Chart:ci,Timeline:qi,Graph:Zi,Progress:Ia,Image:va,ModalForm:Na,Thread:Zo,Composer:$i,Action:ni,Show:fo,Switch:mo,Match:ho,Link:Oa,Settings:so,Tabs:Eo,Tab:Do,Users:_s,Profile:_c,Password:mc,Passkeys:cc,TwoFactor:xc,ConnectedAccounts:oe,PersonalMail:Cs,Connections:Us,Devices:ac,ConnectedApps:js,PersonalAccessTokens:zs,DeleteAccount:qs,Box:Qo,Row:$o,Column:es,Text:ts,ReferenceManyField:os,ReferenceArrayField:cs,ArrayField:ns,RecordsIterator:ai,ReferenceField:us,SelectInput:rs,Details:ea,Summary:ta,TextField:xa,NumberField:Sa,DateField:Ca,BooleanField:wa,UrlField:Ta,ChipField:Ea},Tc=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(`.`)),Ec=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:un(t,...n,r)}})),Dc=({text:e})=>{let t=q(),n=Ae(),r={...z(t),params:n};return(0,X.jsx)(X.Fragment,{children:y(e,e=>c(_t(r,e)))})},Oc=(e,t)=>e.includes(`{{`)?(0,X.jsx)(Dc,{text:e},t):(0,X.jsx)(Y.Fragment,{children:e},t),kc=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?Oc(e,n):(0,X.jsx)(Ic,{node:e,at:t},n)),Ac=e=>{let t=[];for(let n of e){let e=t.at(-1);Hr(n.child)&&e&&Hr(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Hr(n.child)?(0,X.jsx)(`p`,{className:`leading-6`,children:kc(e)},t):(0,X.jsx)(Ic,{node:n.child,at:n.at},t)})},jc=e=>xe(e)||Array.isArray(e)&&e.length>0&&e.every(xe),Mc=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>jc(n)?[[e,(0,X.jsx)(X.Fragment,{children:Ac(Nc(n,t,e))})]]:[])),Nc=(e,t,n)=>Array.isArray(e)?Ec(e,t,`props`,n):[{child:e,...t!==void 0&&{at:un(t,`props`,n)}}],Pc=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fc=(e,t)=>{let n=Pc(e.props.components)?e.props.components:{},r=Object.fromEntries(Object.entries(n).flatMap(([e,t])=>xe(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=Jt(t,String(e.props.i18nKey),Pc(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||xe(e)?e:String(e)):[i]},Ic=({node:e,at:t})=>{let{components:n}=Ce(),r=q(),i=Ae(),o=je(),s=(0,Y.useMemo)(()=>a(Lt(e,{...z(r),params:i}),o),[e,r,i,o]);if(s.type===`Trans`&&!s.custom)return(0,X.jsx)(X.Fragment,{children:kc(Fc(s,o).map(e=>({child:e})))});if(s.custom){let e=n?.[s.type],r=s.children.length>0?(0,X.jsx)(Ji,{node:s,children:Ac(Ec(s.children,t,`children`))}):void 0;return(0,X.jsx)(Cc,{name:s.type,registered:!!e,fallback:s.fallback&&(0,X.jsx)(X.Fragment,{children:Ac(Ec(s.fallback,t,`fallback`))}),children:e&&(0,X.jsx)(Ye,{node:s,...t!==void 0&&{at:t},children:(0,X.jsx)(e,{...ht(s.props),children:r})})})}let c=wc[s.type];if(!c)return(0,X.jsx)(re,{children:M.rich(`unknownBlock`,{type:s.type})});let l=typeof s.props.className==`string`?s.props.className:void 0,u=Ec(s.children,t,`children`),d=(0,X.jsx)(c,{node:s,at:t,slots:Mc(s,t),className:l,children:s.type===`Text`||s.type===`Link`||s.type===`Summary`?kc(u):Ac(s.type===`Switch`?u.filter(({child:e})=>typeof e!=`string`):u)}),p=l===void 0||Tc.has(s.type)?d:(0,X.jsx)(`div`,{className:l,children:d});return s.fallback?(0,X.jsx)(f,{name:s.type,resetKey:s,fallback:(0,X.jsx)(X.Fragment,{children:Ac(Ec(s.fallback,t,`fallback`))}),children:p}):p};export{bo as a,Ha as c,Yo as i,za as l,Cc as n,co as o,Xo as r,Za as s,Ic as t,Qi as u};
3
+ //# debugId=802fbfba-85f5-4b9a-98ea-cc4ca5352e3a