@protobase/ui 0.119.2 → 0.119.3

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 (192) 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/create/messages.d.ts +2 -2
  5. package/dist/app/delete/messages.d.ts +2 -2
  6. package/dist/app/displays/messages.d.ts +2 -2
  7. package/dist/app/export/messages.d.ts +2 -2
  8. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  9. package/dist/app/field-types/workflow/definition.d.ts +1 -1
  10. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  11. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  12. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  13. package/dist/app/file-viewers/messages.d.ts +2 -2
  14. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  15. package/dist/app/history/messages.d.ts +2 -2
  16. package/dist/app/import/messages.d.ts +2 -2
  17. package/dist/app/list-messages.d.ts +2 -2
  18. package/dist/app/messages.d.ts +2 -2
  19. package/dist/app/meta-gate-messages.d.ts +2 -2
  20. package/dist/app/pages/messages.d.ts +2 -2
  21. package/dist/app/record-chart/messages.d.ts +2 -2
  22. package/dist/app/record-messages.d.ts +2 -2
  23. package/dist/app/record-mode/shown-layout.d.ts +1 -1
  24. package/dist/app/related-cards/messages.d.ts +2 -2
  25. package/dist/app/runtime/messages.d.ts +2 -2
  26. package/dist/app/saved/use-favorite.d.ts +1 -1
  27. package/dist/app/searches/messages.d.ts +2 -2
  28. package/dist/app/searches/use-save-search.d.ts +1 -1
  29. package/dist/app/start-target.d.ts +38 -0
  30. package/dist/app/start-target.js +38 -0
  31. package/dist/app/use-start-address.d.ts +6 -9
  32. package/dist/app/use-start-address.js +23 -21
  33. package/dist/app-shell/messages.d.ts +2 -2
  34. package/dist/assistant-dock/messages.d.ts +2 -2
  35. package/dist/auth/messages.d.ts +2 -2
  36. package/dist/calls/messages.d.ts +2 -2
  37. package/dist/data-grid/messages.d.ts +2 -2
  38. package/dist/filter-panel/messages.d.ts +2 -2
  39. package/dist/forms/messages.d.ts +2 -2
  40. package/dist/invitations/messages.d.ts +2 -2
  41. package/dist/mocks/orders.d.ts +1 -1
  42. package/dist/notifications/bell/messages.d.ts +2 -2
  43. package/dist/organizations/messages.d.ts +2 -2
  44. package/dist/package.js +1 -1
  45. package/dist/primitives/messages.d.ts +2 -2
  46. package/dist/shell/assets/{account-page-CAJ1kqbM.js → account-page-d4bA-Rnh.js} +2 -2
  47. package/dist/shell/assets/{app-CJRcPkz6.js → app-B94YfKGx.js} +11 -11
  48. package/dist/shell/assets/{assistant-shell-BfbbDVaC.js → assistant-shell-DTNOfaAZ.js} +2 -2
  49. package/dist/shell/assets/{board-display-NQNgdfOF.js → board-display-ClTe26F0.js} +2 -2
  50. package/dist/shell/assets/{calendar-display-CFPrjZFk.js → calendar-display-CwBcu_JO.js} +2 -2
  51. package/dist/shell/assets/{call-rings-B8E1WcyM.js → call-rings-D8cGALi4.js} +2 -2
  52. package/dist/shell/assets/{calls-CdQzy7k0.js → calls-DLSo4hNS.js} +2 -2
  53. package/dist/shell/assets/{circle-alert-d8QhxvKR.js → circle-alert-C8YjGdRx.js} +2 -2
  54. package/dist/shell/assets/{composed-page-DMVnOjIP.js → composed-page-DBHl-wl_.js} +2 -2
  55. package/dist/shell/assets/{composer-section-DnZcEvIv.js → composer-section-6TvE0L2w.js} +2 -2
  56. package/dist/shell/assets/{connect-route-4mPmCyC4.js → connect-route-C8Km-e8S.js} +2 -2
  57. package/dist/shell/assets/{copy-field-BERLdksL.js → copy-field-DXp0fGDR.js} +2 -2
  58. package/dist/shell/assets/{create-route-GDRDDl56.js → create-route-s8RsjtyM.js} +2 -2
  59. package/dist/shell/assets/{custom-step-container-field-CdOcEE3E.js → custom-step-container-field-B8ut5WnP.js} +2 -2
  60. package/dist/shell/assets/{embedded-list-BfLZckNm.js → embedded-list-OJQKeuBN.js} +3 -3
  61. package/dist/shell/assets/{export-dialog-D4o9o8bz.js → export-dialog-gSUSlzOy.js} +2 -2
  62. package/dist/shell/assets/{first-organization-page-B3iq4sHy.js → first-organization-page-C7YZ32Kt.js} +2 -2
  63. package/dist/shell/assets/{graph-view-Df89qpKC.js → graph-view-_7poAZsr.js} +2 -2
  64. package/dist/shell/assets/{group-donut-CrztmwCW.js → group-donut-XjNEBVUq.js} +2 -2
  65. package/dist/shell/assets/{guest-call-page-BBIOrY9i.js → guest-call-page-Cj6F3D3u.js} +3 -3
  66. package/dist/shell/assets/{html-viewer--TQtevzN.js → html-viewer-CmYTAzWa.js} +2 -2
  67. package/dist/shell/assets/{import-dialog-BWTCBbXg.js → import-dialog-bNG6qX6Q.js} +2 -2
  68. package/dist/shell/assets/{import-table-dialog-DPkK6vH5.js → import-table-dialog-BbI7GJ8R.js} +2 -2
  69. package/dist/shell/assets/{index-Bh5wY9w1.js → index-CYraq2Hi.js} +1 -1
  70. package/dist/shell/assets/{invitations-page-B9lumTnF.js → invitations-page-XV6kL2Mk.js} +2 -2
  71. package/dist/shell/assets/{layout-grid-9bzmoNfC.js → layout-grid-dpoR6hFU.js} +2 -2
  72. package/dist/shell/assets/{legend-item-CMOXfVzG.js → legend-item-WwKh2W6n.js} +2 -2
  73. package/dist/shell/assets/{list-page-DKvupZUF.js → list-page-DImD2FRO.js} +4 -4
  74. package/dist/shell/assets/{maplibre-BSd2GULM.js → maplibre-Bm0OQH9k.js} +2 -2
  75. package/dist/shell/assets/{markdown-content-CJbhy8aC.js → markdown-content-BZLiLira.js} +2 -2
  76. package/dist/shell/assets/{members-page-q2id0vrY.js → members-page-ZcqzlQu6.js} +2 -2
  77. package/dist/shell/assets/{messages-ZPG4Y__r.js → messages-vzi5T1Xo.js} +2 -2
  78. package/dist/shell/assets/{organization-page-DqYnaJRl.js → organization-page-CjrQmpot.js} +2 -2
  79. package/dist/shell/assets/{organizations-page-Dm5Y0fGB.js → organizations-page-C7gJsoCx.js} +2 -2
  80. package/dist/shell/assets/{pending-invitation-row-Ce5VDMYl.js → pending-invitation-row-BZVOux9W.js} +2 -2
  81. package/dist/shell/assets/{period-chart-D3lbH2Ni.js → period-chart-GDqLnl9l.js} +2 -2
  82. package/dist/shell/assets/{person-row-D5tS8OTp.js → person-row-DgXLW9D8.js} +2 -2
  83. package/dist/shell/assets/{public-form-page-aK2MyEzM.js → public-form-page-DjLnqHPx.js} +2 -2
  84. package/dist/shell/assets/{record-lines-BVk1yL7T.js → record-lines-CDTPiIdF.js} +2 -2
  85. package/dist/shell/assets/{record-map-CQG_MBk2.js → record-map-Dcmuv9J8.js} +2 -2
  86. package/dist/shell/assets/{record-opens-583Ej1N1.js → record-opens-D7SV04zf.js} +2 -2
  87. package/dist/shell/assets/{record-page-CCop2gY_.js → record-page-DGWHTUdD.js} +3 -3
  88. package/dist/shell/assets/{record-preview-DA3ekFy9.js → record-preview-DsIrTWKZ.js} +2 -2
  89. package/dist/shell/assets/{records-map-eORDbX4I.js → records-map-G0QXqaUR.js} +2 -2
  90. package/dist/shell/assets/{render-node-DYlEB-c6.js → render-node-0_Pb8ixy.js} +3 -3
  91. package/dist/shell/assets/{reorder-button-CBM6uNGv.js → reorder-button-BhhzhhTO.js} +2 -2
  92. package/dist/shell/assets/{run-trace-view-Bc39GS76.js → run-trace-view-DLY3Mt5m.js} +2 -2
  93. package/dist/shell/assets/{runner-install-field-1DavXWJz.js → runner-install-field-Iwp4UP6o.js} +2 -2
  94. package/dist/shell/assets/{runtime-update-BmJNn1bb.js → runtime-update-DKcAQek2.js} +2 -2
  95. package/dist/shell/assets/{shared-protobase-ui-CYjgvFkX.js → shared-protobase-ui-XTZSVgEm.js} +1 -1
  96. package/dist/shell/assets/{sheet-source-DRkb3sPj.js → sheet-source-DxVQhlKF.js} +2 -2
  97. package/dist/shell/assets/{sign-in-policy-page-J-Gl8EDX.js → sign-in-policy-page-E1eBhmUM.js} +2 -2
  98. package/dist/shell/assets/{start-block-queries-Db9-BBtv.js → start-block-queries-Bu7xMabd.js} +2 -2
  99. package/dist/shell/assets/{step-catalog-Dx8trv3T.js → step-catalog-BPk6WuYH.js} +2 -2
  100. package/dist/shell/assets/{step-panel-CollAT6S.js → step-panel-BXHWAw8x.js} +2 -2
  101. package/dist/shell/assets/{timeline-display-Db0NWucC.js → timeline-display-CJHQiDm9.js} +2 -2
  102. package/dist/shell/assets/{trash-BgljKjXT.js → trash-MHAT5Hf3.js} +2 -2
  103. package/dist/shell/assets/{update-set-SMllxKkh.js → update-set-B0D_tNDz.js} +2 -2
  104. package/dist/shell/assets/{use-calendar-move-BcrMLvrG.js → use-calendar-move-O_48Gqvs.js} +2 -2
  105. package/dist/shell/assets/{use-display-rows-DT7QTMsG.js → use-display-rows-vjthlkqo.js} +2 -2
  106. package/dist/shell/assets/{use-my-invitations-oCZ6ZQ-U.js → use-my-invitations-DDPuugTE.js} +2 -2
  107. package/dist/shell/assets/{use-paged-search-BlDRyMbE.js → use-paged-search-DRj8498k.js} +2 -2
  108. package/dist/shell/assets/{use-run-trace-D_6T2CH7.js → use-run-trace-CWGAibgF.js} +2 -2
  109. package/dist/shell/assets/{use-workflow-page-CBp2KwrR.js → use-workflow-page-C9ZEXX5R.js} +2 -2
  110. package/dist/shell/assets/{use-workflow-types-ygVBJ9Yg.js → use-workflow-types-DDh28X2_.js} +2 -2
  111. package/dist/shell/assets/{workflow-canvas-BC2ifgGd.js → workflow-canvas-n_YJtaOh.js} +2 -2
  112. package/dist/shell/assets/{workflow-field-D_yT-vSa.js → workflow-field-CpkY17Cc.js} +3 -3
  113. package/dist/shell/assets/{workflow-graph-editor-BSTyuKLQ.js → workflow-graph-editor-V-ZGHSrC.js} +2 -2
  114. package/dist/shell/assets/{workflow-run-field-CKXk25MP.js → workflow-run-field-CoUJGVdX.js} +3 -3
  115. package/dist/shell/assets/{workflow-status-field-BQDIaBJw.js → workflow-status-field-nmrhtSls.js} +2 -2
  116. package/dist/shell/assets/{workflow-workbench-CHPH8qPu.js → workflow-workbench-DvzNEdn3.js} +2 -2
  117. package/dist/shell/index.html +3 -3
  118. package/dist/shell/protobase.shell.json +2 -2
  119. package/dist/shell/protobase.sw.js +2 -2
  120. package/dist/shell-source-maps/assets/{account-page-CAJ1kqbM.js.map → account-page-d4bA-Rnh.js.map} +1 -1
  121. package/dist/shell-source-maps/assets/app-B94YfKGx.js.map +1 -0
  122. package/dist/shell-source-maps/assets/{assistant-shell-BfbbDVaC.js.map → assistant-shell-DTNOfaAZ.js.map} +1 -1
  123. package/dist/shell-source-maps/assets/{board-display-NQNgdfOF.js.map → board-display-ClTe26F0.js.map} +1 -1
  124. package/dist/shell-source-maps/assets/{calendar-display-CFPrjZFk.js.map → calendar-display-CwBcu_JO.js.map} +1 -1
  125. package/dist/shell-source-maps/assets/{call-rings-B8E1WcyM.js.map → call-rings-D8cGALi4.js.map} +1 -1
  126. package/dist/shell-source-maps/assets/{calls-CdQzy7k0.js.map → calls-DLSo4hNS.js.map} +1 -1
  127. package/dist/shell-source-maps/assets/{circle-alert-d8QhxvKR.js.map → circle-alert-C8YjGdRx.js.map} +1 -1
  128. package/dist/shell-source-maps/assets/{composed-page-DMVnOjIP.js.map → composed-page-DBHl-wl_.js.map} +1 -1
  129. package/dist/shell-source-maps/assets/{composer-section-DnZcEvIv.js.map → composer-section-6TvE0L2w.js.map} +1 -1
  130. package/dist/shell-source-maps/assets/{connect-route-4mPmCyC4.js.map → connect-route-C8Km-e8S.js.map} +1 -1
  131. package/dist/shell-source-maps/assets/{copy-field-BERLdksL.js.map → copy-field-DXp0fGDR.js.map} +1 -1
  132. package/dist/shell-source-maps/assets/{create-route-GDRDDl56.js.map → create-route-s8RsjtyM.js.map} +1 -1
  133. package/dist/shell-source-maps/assets/{custom-step-container-field-CdOcEE3E.js.map → custom-step-container-field-B8ut5WnP.js.map} +1 -1
  134. package/dist/shell-source-maps/assets/{embedded-list-BfLZckNm.js.map → embedded-list-OJQKeuBN.js.map} +1 -1
  135. package/dist/shell-source-maps/assets/{export-dialog-D4o9o8bz.js.map → export-dialog-gSUSlzOy.js.map} +1 -1
  136. package/dist/shell-source-maps/assets/{first-organization-page-B3iq4sHy.js.map → first-organization-page-C7YZ32Kt.js.map} +1 -1
  137. package/dist/shell-source-maps/assets/{graph-view-Df89qpKC.js.map → graph-view-_7poAZsr.js.map} +1 -1
  138. package/dist/shell-source-maps/assets/{group-donut-CrztmwCW.js.map → group-donut-XjNEBVUq.js.map} +1 -1
  139. package/dist/shell-source-maps/assets/{guest-call-page-BBIOrY9i.js.map → guest-call-page-Cj6F3D3u.js.map} +1 -1
  140. package/dist/shell-source-maps/assets/{html-viewer--TQtevzN.js.map → html-viewer-CmYTAzWa.js.map} +1 -1
  141. package/dist/shell-source-maps/assets/{import-dialog-BWTCBbXg.js.map → import-dialog-bNG6qX6Q.js.map} +1 -1
  142. package/dist/shell-source-maps/assets/{import-table-dialog-DPkK6vH5.js.map → import-table-dialog-BbI7GJ8R.js.map} +1 -1
  143. package/dist/shell-source-maps/assets/{invitations-page-B9lumTnF.js.map → invitations-page-XV6kL2Mk.js.map} +1 -1
  144. package/dist/shell-source-maps/assets/{layout-grid-9bzmoNfC.js.map → layout-grid-dpoR6hFU.js.map} +1 -1
  145. package/dist/shell-source-maps/assets/{legend-item-CMOXfVzG.js.map → legend-item-WwKh2W6n.js.map} +1 -1
  146. package/dist/shell-source-maps/assets/{list-page-DKvupZUF.js.map → list-page-DImD2FRO.js.map} +1 -1
  147. package/dist/shell-source-maps/assets/{maplibre-BSd2GULM.js.map → maplibre-Bm0OQH9k.js.map} +1 -1
  148. package/dist/shell-source-maps/assets/{markdown-content-CJbhy8aC.js.map → markdown-content-BZLiLira.js.map} +1 -1
  149. package/dist/shell-source-maps/assets/{members-page-q2id0vrY.js.map → members-page-ZcqzlQu6.js.map} +1 -1
  150. package/dist/shell-source-maps/assets/{messages-ZPG4Y__r.js.map → messages-vzi5T1Xo.js.map} +1 -1
  151. package/dist/shell-source-maps/assets/{organization-page-DqYnaJRl.js.map → organization-page-CjrQmpot.js.map} +1 -1
  152. package/dist/shell-source-maps/assets/{organizations-page-Dm5Y0fGB.js.map → organizations-page-C7gJsoCx.js.map} +1 -1
  153. package/dist/shell-source-maps/assets/{pending-invitation-row-Ce5VDMYl.js.map → pending-invitation-row-BZVOux9W.js.map} +1 -1
  154. package/dist/shell-source-maps/assets/{period-chart-D3lbH2Ni.js.map → period-chart-GDqLnl9l.js.map} +1 -1
  155. package/dist/shell-source-maps/assets/{person-row-D5tS8OTp.js.map → person-row-DgXLW9D8.js.map} +1 -1
  156. package/dist/shell-source-maps/assets/{public-form-page-aK2MyEzM.js.map → public-form-page-DjLnqHPx.js.map} +1 -1
  157. package/dist/shell-source-maps/assets/{record-lines-BVk1yL7T.js.map → record-lines-CDTPiIdF.js.map} +1 -1
  158. package/dist/shell-source-maps/assets/{record-map-CQG_MBk2.js.map → record-map-Dcmuv9J8.js.map} +1 -1
  159. package/dist/shell-source-maps/assets/{record-opens-583Ej1N1.js.map → record-opens-D7SV04zf.js.map} +1 -1
  160. package/dist/shell-source-maps/assets/{record-page-CCop2gY_.js.map → record-page-DGWHTUdD.js.map} +1 -1
  161. package/dist/shell-source-maps/assets/{record-preview-DA3ekFy9.js.map → record-preview-DsIrTWKZ.js.map} +1 -1
  162. package/dist/shell-source-maps/assets/{records-map-eORDbX4I.js.map → records-map-G0QXqaUR.js.map} +1 -1
  163. package/dist/shell-source-maps/assets/{render-node-DYlEB-c6.js.map → render-node-0_Pb8ixy.js.map} +1 -1
  164. package/dist/shell-source-maps/assets/{reorder-button-CBM6uNGv.js.map → reorder-button-BhhzhhTO.js.map} +1 -1
  165. package/dist/shell-source-maps/assets/{run-trace-view-Bc39GS76.js.map → run-trace-view-DLY3Mt5m.js.map} +1 -1
  166. package/dist/shell-source-maps/assets/{runner-install-field-1DavXWJz.js.map → runner-install-field-Iwp4UP6o.js.map} +1 -1
  167. package/dist/shell-source-maps/assets/{runtime-update-BmJNn1bb.js.map → runtime-update-DKcAQek2.js.map} +1 -1
  168. package/dist/shell-source-maps/assets/{sheet-source-DRkb3sPj.js.map → sheet-source-DxVQhlKF.js.map} +1 -1
  169. package/dist/shell-source-maps/assets/{sign-in-policy-page-J-Gl8EDX.js.map → sign-in-policy-page-E1eBhmUM.js.map} +1 -1
  170. package/dist/shell-source-maps/assets/{start-block-queries-Db9-BBtv.js.map → start-block-queries-Bu7xMabd.js.map} +1 -1
  171. package/dist/shell-source-maps/assets/{step-catalog-Dx8trv3T.js.map → step-catalog-BPk6WuYH.js.map} +1 -1
  172. package/dist/shell-source-maps/assets/{step-panel-CollAT6S.js.map → step-panel-BXHWAw8x.js.map} +1 -1
  173. package/dist/shell-source-maps/assets/{timeline-display-Db0NWucC.js.map → timeline-display-CJHQiDm9.js.map} +1 -1
  174. package/dist/shell-source-maps/assets/{trash-BgljKjXT.js.map → trash-MHAT5Hf3.js.map} +1 -1
  175. package/dist/shell-source-maps/assets/{update-set-SMllxKkh.js.map → update-set-B0D_tNDz.js.map} +1 -1
  176. package/dist/shell-source-maps/assets/{use-calendar-move-BcrMLvrG.js.map → use-calendar-move-O_48Gqvs.js.map} +1 -1
  177. package/dist/shell-source-maps/assets/{use-display-rows-DT7QTMsG.js.map → use-display-rows-vjthlkqo.js.map} +1 -1
  178. package/dist/shell-source-maps/assets/{use-my-invitations-oCZ6ZQ-U.js.map → use-my-invitations-DDPuugTE.js.map} +1 -1
  179. package/dist/shell-source-maps/assets/{use-paged-search-BlDRyMbE.js.map → use-paged-search-DRj8498k.js.map} +1 -1
  180. package/dist/shell-source-maps/assets/{use-run-trace-D_6T2CH7.js.map → use-run-trace-CWGAibgF.js.map} +1 -1
  181. package/dist/shell-source-maps/assets/{use-workflow-page-CBp2KwrR.js.map → use-workflow-page-C9ZEXX5R.js.map} +1 -1
  182. package/dist/shell-source-maps/assets/{use-workflow-types-ygVBJ9Yg.js.map → use-workflow-types-DDh28X2_.js.map} +1 -1
  183. package/dist/shell-source-maps/assets/{workflow-canvas-BC2ifgGd.js.map → workflow-canvas-n_YJtaOh.js.map} +1 -1
  184. package/dist/shell-source-maps/assets/{workflow-field-D_yT-vSa.js.map → workflow-field-CpkY17Cc.js.map} +1 -1
  185. package/dist/shell-source-maps/assets/{workflow-graph-editor-BSTyuKLQ.js.map → workflow-graph-editor-V-ZGHSrC.js.map} +1 -1
  186. package/dist/shell-source-maps/assets/{workflow-run-field-CKXk25MP.js.map → workflow-run-field-CoUJGVdX.js.map} +1 -1
  187. package/dist/shell-source-maps/assets/{workflow-status-field-BQDIaBJw.js.map → workflow-status-field-nmrhtSls.js.map} +1 -1
  188. package/dist/shell-source-maps/assets/{workflow-workbench-CHPH8qPu.js.map → workflow-workbench-DvzNEdn3.js.map} +1 -1
  189. package/dist/status/messages.d.ts +2 -2
  190. package/dist/users/messages.d.ts +2 -2
  191. package/package.json +5 -5
  192. package/dist/shell-source-maps/assets/app-CJRcPkz6.js.map +0 -1
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-Df89qpKC.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-CJRcPkz6.js","assets/vendor-t7Q7QbPu.js","assets/app-xwgcmboV.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,$c as i,$n as a,$o as o,$s as s,$t as c,As as l,At as u,B as d,Bo as f,Bs as p,C as m,Cc as h,Cn as g,Cs as _,D as v,Dl as y,Do as b,Ec as x,En as S,Es as C,F as w,Fa as T,Fl as E,Fn as ee,Fs as te,Ga as ne,Go as D,Gt as re,Hc as O,Hl as ie,Hs as ae,Ic as oe,In as se,Is as ce,Ji as le,Jn as ue,Jo as k,Jt as de,Ka as fe,Ko as A,Ln as pe,Lr as me,Ls as he,M as ge,Mt as _e,Nc as ve,Nt as ye,Ol as be,Os as xe,Pa as Se,Pl as Ce,Pn as we,Pr as Te,Ps as Ee,Pt as De,Qn as Oe,Qo as ke,Qs as Ae,R as je,Ri as Me,Rn as Ne,Rr as Pe,Rs as Fe,Si as Ie,Ss as j,Ts as Le,Ua as Re,Un as ze,Uo as Be,Us as Ve,V as He,Vc as M,Vr as Ue,Vs as We,Wa as N,Wo as Ge,Xc as Ke,Xo as qe,Xt as Je,Yc as Ye,Yi as Xe,Yn as Ze,Yo as P,Ys as Qe,Zi as $e,Zo as F,Zs as et,_ as tt,_a as nt,_n as rt,_t as it,ac as I,al as at,ao as ot,as as st,at as ct,b as lt,ba as ut,bi as dt,bs as ft,ca as pt,cc as mt,cl as ht,cn as gt,cr as L,dr as _t,ec as vt,es as yt,fl as bt,fo as xt,fr as R,ga as St,gi as Ct,gn as wt,gt as Tt,ha as Et,hn as Dt,i as Ot,ic as z,in as B,ir as kt,ja as At,js as jt,jt as Mt,k as Nt,ki as Pt,ks as Ft,lc as It,ln as Lt,lr as Rt,ls as zt,ma as Bt,ml as Vt,mn as Ht,mr as V,na as Ut,nc as Wt,nn as Gt,no as Kt,nr as qt,ns as H,on as Jt,or as Yt,os as Xt,pn as Zt,pr as U,qo as Qt,rl as $t,rn as en,ro as tn,rs as nn,s as rn,sc as W,sl as an,sn as on,sr as G,ta as sn,tn as cn,tr as ln,un,ur as dn,v as fn,vn as pn,vs as K,wa as mn,wn as hn,ws as gn,wt as _n,xa as vn,xs as yn,y as bn,yc as xn,yn as Sn,ys as q,zo as Cn,zs as wn}from"./app-CJRcPkz6.js";import{C as Tn,f as En,o as Dn,s as On}from"./vendor-t7Q7QbPu.js";import{C as kn,Ct as An,Dt as jn,Et as Mn,Mt as Nn,O as Pn,Ot as Fn,Q as In,St as Ln,Tt as Rn,X as zn,Z as Bn,_t as Vn,at as Hn,b as Un,ct as Wn,dt as Gn,ft as Kn,gt as qn,it as Jn,k as Yn,kt as Xn,l as Zn,lt as Qn,mt as $n,n as er,nt as tr,o as nr,ot as rr,rt as ir,st as ar,t as or,tt as sr,ut as cr,wt as lr,x as ur,xt as dr,y as fr}from"./embedded-list-BfLZckNm.js";import{t as pr}from"./circle-alert-d8QhxvKR.js";import{t as mr}from"./page-header-Ddz2r5ic.js";import{n as hr,t as gr}from"./pending-invitation-row-Ce5VDMYl.js";import{n as _r,t as vr}from"./person-row-D5tS8OTp.js";import{n as yr,t as br}from"./use-paged-search-BlDRyMbE.js";import{n as xr,t as Sr}from"./client-publisher-D39SlIhp.js";import{t as Cr}from"./copy-field-BERLdksL.js";var wr={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`}]]};wr.node;var Tr=M(wr),Er={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`}]]};Er.node;var Dr=M(Er),Or={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`}]]};Or.node;var kr=M(Or),Ar={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`}]]};Ar.node;var jr=M(Ar),Mr={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`]};Mr.node;var Nr=M(Mr),Pr={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`}]]};Pr.node;var Fr=M(Pr),Ir={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`}]]};Ir.node;var Lr=M(Ir),Rr={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`}]]};Rr.node;var zr=M(Rr),Br=[`done`,`error`,`running`];ae(`TextField`,!1),ae(`NumberField`,!1),ae(`DateField`,!1),ae(`BooleanField`,!1),ae(`UrlField`,!1),ae(`ChipField`,!1);var Vr=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Hr=e=>typeof e!=`string`&&!e.custom&&Vr.has(e.type),Ur=e=>typeof e==`string`||Hr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Wr=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Gr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),Kr=(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)},qr=(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)},Jr=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,Yr=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Xr=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:Yr.has(`${n.toLowerCase()}:`)?e:void 0},Zr=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),Qr=e=>e==null||e===``?void 0:String(e),$r=(e,t)=>e<t?-1:+(e>t),ei=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=Qr(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=Qr(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=>Qr(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=Qr(e[i.source]),s=Qr(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)=>$r(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>$r(e.id,t.id)),edges:s.sort((e,t)=>$r(e.source,t.source)||$r(e.target,t.target)||$r(e.id,t.id))}},J=e(t(),1),Y=e(n(),1),ti=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=H(),s=An(e.name,void 0),c=Me(),[l,u]=(0,J.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=>Ht(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let m=f.length-p.length,h=dr(`actionCount`,{label:r??d.label,count:p.length}),g=e=>s.runEach(d,p,m,e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>Mn(d)?u(!0):void g(),children:h}),l&&(0,Y.jsx)(Rn,{action:d,label:h,danger:i===`danger`||i===void 0&&jn(d),records:p.map(e=>e.record),names:p.map(t=>Ln(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),g()},onSubmit:async e=>{u(!1),await g(e)}})]})},ni=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=Yt(),c=lr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,J.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{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:()=>Mn(c.action)?u(!0):void c.run(),children:d}),l&&(0,Y.jsx)(Rn,{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)}})]})},ri=({node:e,className:t})=>{let n=B(e),r=_t(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,Y.jsx)(ti,{...n,model:i,items:r.items,className:t}):(0,Y.jsx)(ni,{...n,className:t})},ii=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=B(e);return(0,Y.jsx)(R,{title:i,description:a,actions:n.actions,className:O(`h-full`,r),children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},ai=({children:e,wrap:t=(e,t)=>(0,Y.jsx)(J.Fragment,{children:e},t)})=>{let n=_t();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...Ht(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,Y.jsx)(qt,{value:s,row:{index:o,count:i.length},children:e}),c)})},oi=({children:e})=>(0,Y.jsx)(ai,{children:e}),si=({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=cn(t),f=rt(e,{filter:n,sort:r,pageSize:i,enabled:!d}),p=d??f,m=d?d.rows:f.data?.items??[];return(0,Y.jsx)(R,{title:a,description:o,actions:c,className:u,children:p.isPending?(0,Y.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(z,{className:`h-24 w-56`},t))}):p.error?(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:p.error}):m.length===0?(0,Y.jsx)(U,{children:s??N(`nothingYet`)}):(0,Y.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,Y.jsx)(Rt,{value:{model:e,items:m,...d&&{planned:!0}},children:(0,Y.jsx)(ai,{wrap:(e,t)=>(0,Y.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})})})})},ci=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=B(e),o=H().resources[i];return o?(0,Y.jsx)(si,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},li=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=B(e),{resources:u,views:d}=H(),f=u[r];return f?(0,Y.jsx)(R,{title:i,description:a,actions:t.actions,className:O(`h-full`,n),children:(0,Y.jsx)(Kn,{model:f,view:d[r],...l})}):null},ui=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=wt(e,t),a=i.isPending?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(z,{className:`h-4 w-1/2`}),(0,Y.jsx)(z,{className:`h-4 w-1/3`})]}):i.error?(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:i.error}):i.data?(0,Y.jsx)(qt,{value:i.data,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,Y.jsx)(U,{children:N(`nothingYet`)});return(0,Y.jsx)(`div`,{className:n,children:a})},di=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},fi=e=>e==null?``:String(e),X=(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=di(i[t.start]);if(e===void 0)continue;let a=di(i[t.end]),o=Math.max(e,a??n),s=r.get(fi(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(fi(i[t.lane]),s);let c=s.bars.get(fi(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(fi(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:X(n,a,s),width:X(r,a,s)-X(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:X(o,a,s),width:X(c,a,s)-X(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:X(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:X(a,e,r)})}return{daily:o>=Z,ticks:s}},Ci=e=>({lane:fi(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`:pt(),i=e=>n?0:Ti(e,r),{daily:a,ticks:o}=Si(e,t,i);return(0,Y.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,Y.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Ei(e.left)}`,style:{left:`${e.left}%`},children:a?$e(e.at+i(e.at)):Ut(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&&Vt(a)?{className:ke[a],striped:i}:{color:qn(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,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...ki(a)}},i)}),ji=(e,t)=>t?le(e):Xe(e),Mi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return N(`timelineRange`,{from:ji(n,a),to:i?N(`timelineNow`):ji(r,a)})},Ni=(e,t,n,r)=>`${Ct(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??Ct(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=H().resources[t.fields[r.bar]?.relation?.resource??``],s=S(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,Y.jsx)(Ai,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,Y.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Fi,...l,children:d});let f=a.chosen===e.key;return(0,Y.jsx)(Wt,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:O(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,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,Y.jsx)(Di,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,Y.jsx)(Sn,{model:n,field:i,value:e.value})}),(0,Y.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,Y.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,Y.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,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`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,Y.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Ri,{...t,value:e}),Ct(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,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:N(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:(0,Y.jsx)(Sn,{model:n,field:n.fields[i.bar],value:e.value})}),(0,Y.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Mi(n,i,e.start,e.end,a)})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,Y.jsx)(Ri,{...t,value:e.value}),Ct(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:[...Ye.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})=>Dn({...Hi(zt(),e,n),enabled:t,placeholderData:En}),Wi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=he,title:s,description:c,empty:l,actions:u,className:d,choose:f,details:p})=>{let[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),v=e=>e?Ci(e):null,y={hover:e=>h(v(e)),focus:e=>_(v(e))},b=cn(i),x=Ui(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!b}),S=b??x,C=b?b.rows:x.data?.rows??[],w=!b&&x.data?.cut===!0,T=hi(C,n,Date.now());return(0,Y.jsxs)(R,{title:s,description:c,actions:u,className:O(`h-full`,d),children:[(()=>{if(S.isPending)return(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(z,{className:`h-6`},t))});if(S.error)return(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:S.error});if(T.lanes.length===0)return(0,Y.jsx)(U,{children:l??N(`nothingYet`)});let r=new Set(C.map(e=>String(e[n.color])));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(zi,{model:e,view:t,fields:n,values:r}),(0,Y.jsx)(Li,{shape:T,model:e,view:t,fields:n,point:y,...f&&{choose:f}}),w&&(0,Y.jsx)(U,{children:N(`timelineCut`,{count:C.length})}),(0,Y.jsx)(`div`,{"aria-live":`polite`,children:(0,Y.jsx)(Bi,{bar:wi(T,m)??wi(T,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:i}=a(),o=r[e],s=t=>i({[e]:t}),c=n.model.fields[n.fields.bar],l=o===void 0?null:(0,Y.jsx)(vt,{name:e,children:(0,Y.jsx)(ui,{model:n.model,query:{filter:Vn(c,Gi(c,o),n.filter),sort:n.sort},children:t},o)});return(0,Y.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}=B(e),{resources:h,views:g}=H(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Fe(e),sort:wn(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,Y.jsx)(Wi,{...v}):(0,Y.jsx)(Ki,{...v,select:s,children:r})},Ji=({node:e,children:t})=>{let n=We(e),r=ln(),{resources:i}=H();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,Y.jsx)(vt,{name:n.param,children:(0,Y.jsx)(ui,{model:o,query:{key:a},className:``,children:t},a)})},Yi=(0,J.lazy)(()=>Tn(()=>import(`./graph-view-Df89qpKC.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,Y.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,Y.jsx)(It,{})}),Zi=({node:e,at:t,slots:n,children:r,className:i})=>{let a=B(e),o=c(e,t),s=ln(),l=o.nodes,u=o.edges,{label:d,group:f,status:p,source:m,target:h}=a,g=(0,J.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,J.useMemo)(()=>l&&u&&ei({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,Y.jsx)(V,{title:N(`couldNotLoad`),error:y});if(l.isPending||u.isPending)return Xi;if(v.nodes.length===0)return(0,Y.jsx)(U,{children:a.empty??N(`nothingYet`)});let b=a.select,x=b!==void 0&&s?{chosen:s.given[b],linkTo:e=>s.linkTo({[b]:e})}:void 0;return(0,Y.jsxs)(`div`,{className:O(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(J.Suspense,{fallback:Xi,children:(0,Y.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,Y.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,Y.jsx)(Ji,{node:e,children:r})})]})},Q=Ke(`app/conversation`),Qi=({resource:e,field:t,values:n,placeholder:r})=>{let{resources:i}=H(),a=zt(),o=pn(),s=nn(e),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)();return!i[e]||!mn(s,`create`)?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[u!==void 0&&(0,Y.jsx)(V,{title:Q(`notSent`),error:u}),(0,Y.jsx)(_n,{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}=B(e);return(0,Y.jsx)(Qi,{resource:t,field:n,values:r,placeholder:i})},ea=({node:e,children:t,className:n})=>{let{open:r}=B(e);return(0,Y.jsx)(`details`,{open:r,className:O(`[&[open]>summary]:mb-2`,n),children:t})},ta=({children:e,className:t})=>(0,Y.jsx)(`summary`,{className:O(`cursor-pointer font-medium`,t),children:e}),na=({node:e,className:t})=>{let{source:n,emptyText:r}=B(e),i=Lt(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,Y.jsx)(z,{className:O(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,Y.jsx)(`p`,{className:O(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=Tt(a);return o?(0,Y.jsx)(`div`,{className:O(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,Y.jsx)(it,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,Y.jsx)(`pre`,{className:O(`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=>ht(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},aa=({node:e,className:t})=>{let{source:n,label:r,format:i}=B(e),{views:a}=H(),o=Lt(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,Y.jsx)(z,{className:`h-4 w-24`}):o.state===`plain`?ra(o.value):(0,Y.jsx)(Sn,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,Y.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,Y.jsxs)(`div`,{className:O(`min-w-0`,t),children:[(0,Y.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,Y.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}=B(e),i=e.children,a=i.length>0&&i.every(la);return(0,Y.jsx)(`div`,{className:O(`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,Y.jsx)(`div`,{className:O(`min-w-0`,r&&ca[r]),children:e},t)})})},da=({src:e,alt:t,width:n,height:r,className:i})=>(0,Y.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,J.useState)();return(0,J.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,J.useState)();return[t!==void 0&&t===e,()=>n(e)]},_a=({name:e,alt:t,width:n,height:r,refresh:i,className:a})=>{let o=zt(),{theme:s}=T(),[c,l]=ct(),u=fa({width:n,height:r,space:l,theme:s}),d=Dn({queryKey:Ye.image(e,u??{}),enabled:u!==void 0,placeholderData:En,...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,Y.jsx)(`div`,{ref:c,className:O(`min-w-0`,a),children:d.isError||p?t&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:t}):f?(0,Y.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,Y.jsx)(z,{className:`w-full max-w-full`,style:{height:r??160,...n!==void 0&&{width:n}}})})},va=({node:e,className:t})=>{let n=B(e);return n.src===void 0?(0,Y.jsx)(_a,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,Y.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=B(t),{views:i}=H(),a=Lt(r.source);return a.state===`missing`?null:a.state===`loading`?(0,Y.jsx)(z,{className:`inline-block h-3 w-16 align-middle`}):Wr(t.type,a.value)?r.emptyText?(0,Y.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,Y.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,Y.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`?an(e,n?.valueLabels):Gr(e),xa=ya(ba),Sa=ya(({value:e,props:t})=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:Kr(e,t,i())})),Ca=ya(({value:e,props:t})=>{let n=qr(e,t,{locale:i(),now:Date.now(),relative:sn});return(0,Y.jsx)(`time`,{dateTime:String(e),children:n})}),wa=ya(({value:e,props:t})=>{let n=Jr(e,t,{yes:Pt(`yes`),no:Pt(`no`)});return e?(0,Y.jsx)(ze,{label:n,className:`align-middle`}):(0,Y.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ta=ya(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=Xr(n);return i===void 0?r:(0,Y.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,Y.jsx)(hn,{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=B(e),i={...L(G()),params:Oe()},a=r.variant?O(mt({variant:r.variant}),n):n??Da,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=Ce(r.to,Le(i));return(0,Y.jsx)(me,{to:e,className:a,children:o??Qe(e)})}let s=r.href??``;return(0,Y.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]:v(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:v(i)]})),Aa=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return rn(r)?r.key===v(n[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:m(i,r,n[t])?[[t,Nt(i,r)]]:[]})),ja=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=H(),u=zt(),d=Se(),f=pn(),p=l[e.name],[m,h]=(0,J.useState)(()=>ka(e,a,t?.record)),[g,_]=(0,J.useState)({}),[v,y]=(0,J.useState)(0),b=tt(v),[x,S]=(0,J.useState)(),[C,w]=(0,J.useState)(!1),[T,E]=(0,J.useState)(!1);Ae(T||C,`input-lost`);let ee=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...Ot(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:N(`saved`,{label:i??r})}),s()},e=>{let t=fn(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,Y.jsx)(I,{title:i??r,onClose:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:s,children:N(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:C,onClick:()=>void ee(),children:N(n===`create`?`create`:`save`)})]}),children:(0,Y.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,Y.jsx)(V,{title:N(`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??ht(n),s=g[n];return(0,Y.jsx)(je,{name:n,label:o,help:p?.fields[n]?.help,error:s&&bn(r,o,s),children:(0,Y.jsx)(lt,{field:r,hints:p?.fields[n],value:rn(i)?i.key:i,stored:t?.record[n],relationLabel:rn(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=wt(e,{key:t});return(0,Y.jsx)(Y.Fragment,{children:n(r.data??void 0)})},Na=({node:e})=>{let t=B(e),n=Yt(),{resources:r}=H(),i=r[t.resource??n?.model.name??``],a=nn(i?.name??``),[o,s]=(0,J.useState)(!1);if(!i||!(t.mode===`create`?mn(a,`create`):mn(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,Y.jsx)(ja,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,Y.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}=B(e);return(0,Y.jsx)(`div`,{className:O(`flex-1`,r),children:(0,Y.jsxs)(`div`,{className:O(`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,Y.jsx)(mr,{title:i,subtitle:a,actions:n.actions}),t]})})},Fa=(e,t)=>{let n=G(),r=typeof e==`string`?kt(n,e):void 0,i=on(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:a}=B(e),o=Fa(n,0),s=Fa(r,100);if(o===void 0||s===void 0)return(0,Y.jsx)(z,{className:`h-6 w-full`});if(!Number.isFinite(o)||!Number.isFinite(s))return null;let c=s>0?Math.min(1,Math.max(0,o/s)):0;return(0,Y.jsxs)(`div`,{className:O(`min-w-0`,t),children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:a}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[o.toLocaleString(i()),` / `,s.toLocaleString(i())]})]}),(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":a,"aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":s,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:c>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${c*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=cn(t),f=wt(e,{filter:n,sort:r,key:i,enabled:!d}),p=d?Zt(e,d):f,m=e=>p.data?(0,Y.jsx)(qt,{value:p.data,children:e}):void 0,h=p.isPending?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(z,{className:`h-4 w-1/2`}),(0,Y.jsx)(z,{className:`h-4 w-1/3`})]}):p.error?(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:p.error}):p.data?m((0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:l})):(0,Y.jsx)(U,{children:s??N(`nothingYet`)});return(0,Y.jsx)(R,{title:a,description:o,actions:c?m(c):void 0,className:O(`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}=B(e),f=H().resources[a];return f?(0,Y.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=Ke(`app/related-cards`),Ba=({children:e})=>{let t=(0,J.useRef)(null),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1);return(0,J.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,Y.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,Y.jsx)(`div`,{className:O(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,Y.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,Y.jsx)(W,{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}=H(),a=on(e,t);if(a.state===`missing`||a.state===`ready`&&Va(a.value))return null;let o=a.state===`loading`?(0,Y.jsx)(z,{className:`h-4 w-24`}):(0,Y.jsx)(Sn,{model:a.model,field:a.field,value:a.value}),s=r?(0,Y.jsx)(Ba,{children:o}):o;if(!n)return(0,Y.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,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,Y.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=Me(),{resources:l}=H(),u=c(e.model,t,e.record,e.key),d=a.length>0||o!==void 0;return(0,Y.jsxs)(`li`,{"data-card":e.key,className:O(`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,Y.jsx)(de,{view:t,field:i,record:e.record}),(0,Y.jsxs)(`div`,{className:O(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,Y.jsx)(me,{to:{kind:`record`,resource:e.model.name,key:vn(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,Y.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,Y.jsx)(Ha,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,Y.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,Y.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,Y.jsx)(Ha,{scope:e,path:t,labelled:!1})},t))}),d&&(0,Y.jsx)(qt,{value:e,children:(0,Y.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,Y.jsx)(sr,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,Y.jsx)(ni,{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=Me(),{resources:c}=H(),l=s(e.model,t,e.record,e.key);return(0,Y.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,Y.jsx)(de,{view:t,field:r,record:e.record}),(0,Y.jsx)(me,{to:{kind:`record`,resource:e.model.name,key:vn(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:l}),n.length>0&&(0,Y.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,Y.jsx)(Ha,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,Y.jsx)(qt,{value:e,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,Y.jsx)(sr,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,Y.jsx)(ni,{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,J.useRef)(null),n=(0,J.useRef)({current:e,previous:e}),r=(0,J.useRef)(void 0),[i,a]=(0,J.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,J.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,Y.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,Y.jsx)(z,{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:p,planned:m})=>{let h=f(),g=cr(),_=t?.names?.plural??ht(e.name),v=r||nt(e,t),y=rt(e,{filter:n,sort:v,pageSize:s,enabled:!m}),b=Dt(e,n,!m),x=m?m.rows:{isPending:y.isPending,error:y.error},S=m?m.rows.rows:y.data?.items,C=m?{data:m.total&&!m.total.isPending&&!m.total.error?tr(m.total):void 0}:b,w=(0,J.useMemo)(()=>(S??[]).map(t=>Ht(e,t)),[e,S]),T=Ya((0,J.useMemo)(()=>w.map(e=>e.key),[w]));return(0,Y.jsxs)(`div`,{ref:T.root,children:[(()=>{if(x.isPending)return(0,Y.jsx)(Xa,{compact:!!d,limit:s});if(x.error)return(0,Y.jsx)(V,{title:za(`couldNotLoad`),error:x.error});if(w.length===0)return(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:l??za(`nothingYet`)});let r=w.map(e=>{let n=(t,n)=>T.acted(e.key,t,n);return d?(0,Y.jsx)(Ua,{scope:e,view:t,fields:i,time:d.time,tone:p,actions:a,button:o,onActed:n},e.key):(0,Y.jsx)(Wa,{scope:e,view:t,fields:i,tone:p,actions:a,button:o,onActed:n},e.key)}),f=C.data===void 0?void 0:Wn(w.length,C.data,!1);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u===void 0?(0,Y.jsx)(`ul`,{className:d?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,Y.jsx)(Gn,{scroll:g,label:_,share:u,children:r}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f}),(0,Y.jsxs)(me,{to:rr(e,t,h,{filter:n,orderBy:v,display:ir(t,h,{preferred:c})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[Qn(`viewAll`),` `,(0,Y.jsx)(`span`,{className:`sr-only`,children:_.toLowerCase()}),(0,Y.jsx)(Nn,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,Y.jsx)(`p`,{role:`status`,className:`sr-only`,children:T.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=B(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}=Zr(i),{resources:_,views:v}=H(),[y,b]=Gt([t,t===void 0?void 0:`${t}#total`]),x=(0,J.useMemo)(()=>y&&{rows:y,total:b},[y,b]),S=_[a];if(!S)return null;let C=v[S.name];return(0,Y.jsx)(`section`,{className:O(`min-w-0`,r),"aria-label":f,children:(0,Y.jsx)(w,{title:f,help:p,actions:n.actions,children:(0,Y.jsx)(Za,{model:S,view:C,filter:o,sort:s,fields:c??$t(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}=H(),o=Ue(i,a,e.name),s=Pn(e.name,t.listOf,!0),c=(t.names?.plural??ht(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,Y.jsx)(V,{title:kn(`couldNotLoadYour`,{plural:c}),error:s.error});if(!s.data)return(0,Y.jsx)(z,{className:`h-24`});let l=Yn(o.model,s.data);return l?(0,Y.jsx)(ur,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:n??kn(`noneYet`,{plural:c})})},to=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=bt(vn(e,i)),{name:o,chips:s,title:c,body:l}=fr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,Y.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,Y.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,Y.jsx)(me,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,Y.jsx)(zn,{chips:s})})}),(0,Y.jsx)(ur,{...l})]})},no=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=H(),a=t.searchesOf,o=r[a.resource],s=Un(e.name,!0),c=(t.names?.plural??ht(e.name)).toLowerCase();return o?s.error?(0,Y.jsx)(V,{title:Bn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:n??Bn(`noneYet`,{plural:c})}):(0,Y.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,Y.jsx)(to,{model:e,view:t,target:o,targetView:i[a.resource],row:n},bt(vn(e,n))))}):(0,Y.jsx)(z,{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}=B(e),{resources:d,views:f}=H(),p=d[r];if(!p)return null;let m=f[p.name];return(0,Y.jsx)(R,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,Y.jsx)(no,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,Y.jsx)(ur,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,Y.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}=H(),c=nn(e.name),l=zt(),u=Se(),d=pn(),f=s[e.name],[p,h]=(0,J.useState)(i),[g,_]=(0,J.useState)(()=>ka(e,t,i?.record)),[v,y]=(0,J.useState)({}),[b,x]=(0,J.useState)(),[S,C]=(0,J.useState)(!1),w=(0,J.useRef)(Promise.resolve()),T=(0,J.useRef)(i),E=ka(e,t,void 0),ee=p?mn(c,`update`)&&p.permissions?.update!==!1:mn(c,`create`),te=t.filter(t=>!io(e.fields[t])),ne=te.some(t=>p?m(e.fields[t],g[t],p.record[t]):g[t]!==E[t]),D=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{...Ht(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await l.create(e.name,Ot(e,o,{...E,...t}));return{...Ht(e,r.record),etag:r.etag}},re=t=>{let r=w.current.then(async()=>{C(!0),x(void 0),await D(t).then(async r=>{T.current=r,h(r),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await d(e.name),u.show({state:`success`,title:N(`saved`,{label:n??N(`settings`)})})},e=>{y(t=>({...t,...fn(e)})),x(e)}),C(!1)});w.current=r},ie=(t,n)=>{_(e=>({...e,[t]:n})),io(e.fields[t])&&re({[t]:n})};return(0,Y.jsx)(R,{title:n,description:r,className:O(`h-full`,a),children:(0,Y.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),ne&&re(Object.fromEntries(te.map(e=>[e,g[e]])))},children:[b!==void 0&&Object.keys(v).length===0&&(0,Y.jsx)(V,{title:N(`notSaved`),error:b}),t.map(t=>{let n=e.fields[t],r=f?.fields[t]?.label??ht(t),i=v[t];return(0,Y.jsx)(je,{name:t,label:r,help:f?.fields[t]?.help,error:i&&bn(n,r,i),children:(0,Y.jsx)(lt,{field:n,hints:f?.fields[t],value:g[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,Y.jsx)(`div`,{children:(0,Y.jsx)(W,{type:`submit`,variant:`primary`,size:`sm`,loading:S,children:N(`save`)})})]})})},oo=e=>{let t=wt(e.model,{});return t.isPending?(0,Y.jsx)(R,{title:e.title,description:e.description,className:e.className,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(z,{className:`h-4 w-1/2`}),(0,Y.jsx)(z,{className:`h-4 w-1/3`})]})}):t.error?(0,Y.jsx)(R,{title:e.title,description:e.description,className:e.className,children:(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:t.error})}):(0,Y.jsx)(ao,{...e,stored:t.data??void 0})},so=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=B(e),o=H().resources[n];return o?(0,Y.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}=H(),r=zt(),i=JSON.stringify(e),a=(0,J.useMemo)(()=>JSON.parse(i).map(ce),[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=Ee(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=>kt(t,e)),f=gt(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=On({queries:u.map(e=>un(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 te(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}=B(e),[a]=lo([i],G());if(a===void 0)return null;let o=a?t:uo(e,n);return o==null?null:r===void 0?(0,Y.jsx)(Y.Fragment,{children:o}):(0,Y.jsx)(`div`,{className:r,children:o})},po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(gn(e,L(t)).props.when)]),mo=({node:e,children:t,slots:n,className:r})=>{let i=G(),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,Y.jsx)(Y.Fragment,{children:s}):(0,Y.jsx)(`div`,{className:r,children:s})},ho=({children:e})=>(0,Y.jsx)(Y.Fragment,{children:e}),go=`text-2xl font-semibold tracking-tight tabular-nums`,_o=({model:e,at:t,filter:n})=>{let{views:r}=H(),a=cn(t),o=Dt(e,n,!a),s=a??o;if(s.isPending)return(0,Y.jsx)(z,{className:`h-8 w-16`});if(s.error)return(0,Y.jsx)(`span`,{className:`text-danger-text`,children:N(`couldNotCount`)});let c=a?tr(a):o.data;return(0,Y.jsx)(me,{to:$n(r[e.name],e.name,n),className:`${go} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:c.toLocaleString(i())})},vo=({field:e,format:t})=>{let n=Lt(e);return n.state===`loading`?(0,Y.jsx)(z,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,Y.jsx)(`span`,{className:go,children:ra(n.value)}):(0,Y.jsx)(`span`,{className:go,children:(0,Y.jsx)(Sn,{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}=B(e),{resources:u}=H(),d=a===void 0?void 0:u[a];return(0,Y.jsxs)(R,{className:O(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,Y.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,Y.jsx)(`span`,{className:go,children:i}),d&&(0,Y.jsx)(_o,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,Y.jsx)(vo,{field:s,format:c})]}),l&&(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},bo=(e,t,n)=>{let r=f(),i=Jn(t),[a,o]=(0,J.useState)(()=>Hn(localStorage,i)),s=(0,J.useCallback)(e=>{o(e),ar(localStorage,i,e)},[i]);return[ir(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}=H(),d=u[e.name],{fields:p}=At(),m=mn(nn(e.name),`update`),{go:h,href:g}=Pe(),_=f(),v=!Cn(),y=(0,J.useMemo)(()=>n?.map(Ft)??$t(e,d),[n,e,d]),b=(0,J.useMemo)(()=>Jt(e,d,y,{resources:l,views:u,fieldTypes:p}),[e,d,y,l,u,p]),x=(0,J.useMemo)(()=>_?en(n)(b):b,[_,n,b]),S=(0,J.useMemo)(()=>r?Zn(x,e,d,r,l,v):x,[x,e,d,r,l,v]),C=(0,J.useMemo)(()=>t.map(t=>({...t,id:ut(e,t)})),[t,e]),w=(0,J.useMemo)(()=>({total:C.length,rowAt:e=>C[e]}),[C]),T=nr({model:e,view:d,opens:void 0,resources:l,views:u,canUpdate:m}),E=e=>({href:g(e),onFollow:()=>h(e)});return(0,Y.jsx)(R,{title:i,description:a,actions:s,className:c,children:C.length===0?(0,Y.jsx)(U,{children:o??N(`nothingYet`)}):(0,Y.jsx)(In,{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=_t();return t?.model?(0,Y.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?y:g,b=(0,J.useMemo)(()=>i?.map(Ft),[i]),x=(0,J.useMemo)(()=>en(i),[i]);return(0,Y.jsxs)(R,{title:l,description:u,actions:(0,Y.jsxs)(Y.Fragment,{children:[!m&&(0,Y.jsx)(or,{view:t,value:v,onChange:_}),f]}),className:O(`h-full`,p),children:[(0,Y.jsx)(er,{model:e,view:t,filter:n,sort:r,columns:b,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:x,...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}=B(e),{resources:u,views:d}=H(),[f,p]=Gt([t,t===void 0?void 0:`${t}#total`]),m=(0,J.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,Y.jsx)(So,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,Y.jsx)(Co,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,Y.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:i}=a(),o=t=>i({[e]:t}),s=r[e],c=s===void 0?null:(0,Y.jsx)(vt,{name:e,children:(0,Y.jsx)(ui,{model:n.model,query:{key:s},children:t},s)});return(0,Y.jsx)(Co,{...n,chosen:{rowTo:o,key:s,details:c}})},Eo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=St(),{navigate:a}=s(),o=Et(e),c=Bt(o,r),l=e=>i(e===o[0]?.name?void 0:e);return(0,Y.jsxs)(`div`,{className:O(`flex flex-col gap-6`,n),children:[(0,Y.jsxs)(`select`,{"aria-label":N(`tabs`),value:c?.name??``,onChange:e=>a(l(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!c&&(0,Y.jsx)(`option`,{value:``,disabled:!0}),o.map(e=>(0,Y.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,Y.jsx)(`nav`,{"aria-label":N(`tabs`),className:`hidden border-b md:block`,children:(0,Y.jsx)(`ul`,{className:`flex gap-1`,children:o.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(et,{to:l(e.name),"aria-current":e===c?`page`:void 0,className:O(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===c?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),c?(0,Y.jsx)(J.Fragment,{children:t[o.indexOf(c)]},c.name):(0,Y.jsx)(ne,{children:N(`noTab`,{name:r??``})})]})},Do=({children:e})=>(0,Y.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=an(e,t?.valueLabels);return n===`done`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(oe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(It,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&dt(t?.valueColors,e)!==`red`?r:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,Y.jsx)(pr,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},jo=({value:e})=>{let t=typeof e==`string`?we(e):e;return t===ee?(0,Y.jsx)(pe,{children:String(e)}):(0,Y.jsx)(se,{value:t})},Mo=({label:e,children:t})=>(0,Y.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),No=({call:e,statusHints:t})=>{let[n,r]=(0,J.useState)(!1),i=(0,J.useId)(),a=e.status!==void 0&&(0,Y.jsx)(Ao,{value:e.status,hints:t,mark:e.state}),o=(0,Y.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,Y.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,Y.jsxs)(W,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,Y.jsx)(ve,{"aria-hidden":!0,className:O(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,Y.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callInput`),children:(0,Y.jsx)(jo,{value:e.input})}),e.result!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callResult`),children:(0,Y.jsx)(jo,{value:e.result})}),e.error!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callError`),children:(0,Y.jsx)(pe,{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:ye(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=>Br.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,J.useState)(!1),s=Te(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,J.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}=H(),i=e?.model.name??``,a=Ho(i,{filter:e?.filter,orderBy:e&&p(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>Bo(t,zo(vn(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:l,planned:d})=>{let{resources:f,views:m}=H(),h=ft(),_=h?.state.kind===`signed-in`?h.state.user.id:void 0,v=n===void 0?[]:[n],y=ue(f,m,e,v),b=Ho(e.name,{filter:t,orderBy:p(r),pageSize:o,labels:y},d?.messages),x=Uo(l,o,d?.calls),S=Wo(b);if(S===`error`)return(0,Y.jsx)(V,{title:Q(`couldNotLoad`),error:b.error,onRetry:qo(b)});if(S===`loading`)return(0,Y.jsx)(`div`,{className:`p-4`,children:(0,Y.jsx)(U,{children:Q(`loadingMessages`)})});let C=Ze(f,e,v,b.items,b.labels),w=ko({items:x.calls,more:x.hasNextPage},{items:Po(C,r),more:b.hasNextPage}),T=Io(w,{key:t=>String(vn(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&&Ie(e.fields[i],m[e.name]?.fields[i]),te=T.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===_);return(0,Y.jsxs)(Y.Fragment,{children:[Ko(b)&&(0,Y.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,Y.jsx)(V,{title:Q(`couldNotLoad`),error:b.error,onRetry:qo(b)})}),l&&x.list.error&&(0,Y.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,Y.jsx)(V,{title:Q(`couldNotLoadCalls`),error:x.list.error,onRetry:qo(x.list)})}),(0,Y.jsx)(u,{length:w.length,followKey:te?.key,working:c,empty:Go(x.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:b.hasNextPage||x.hasNextPage?()=>Jo([b,x.list]):void 0,loadingEarlier:b.isFetchingNextPage||x.isFetchingNextPage,children:T.map(e=>e.kind===`day`?(0,Y.jsx)(_e,{label:e.label},e.key):e.kind===`call`?(0,Y.jsx)(No,{call:e,statusHints:x.statusHints},e.key):(0,Y.jsx)(Mt,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,Y.jsx)(Ao,{value:e.status,hints:E}),children:ee&&e.text!==``?(0,Y.jsx)(g,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},Xo=({children:e})=>(0,Y.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}=B(e),{resources:g}=H(),[_]=lo(f===void 0?[]:[f],G()),[v,y]=Gt([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let x=p&&g[p.resource];return(0,Y.jsx)(`section`,{className:O(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,Y.jsx)(w,{title:i,help:a,actions:n.actions,children:(0,Y.jsx)(Xo,{children:(0,Y.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,Y.jsx)(`div`,{className:t,children:e}),$o=({children:e,className:t})=>(0,Y.jsx)(`div`,{className:O(`flex`,t),children:e}),es=({children:e,className:t})=>(0,Y.jsx)(`div`,{className:O(`flex flex-col`,t),children:e}),ts=({node:e,children:t,className:n})=>{let{as:r=`p`}=B(e);return(0,Y.jsx)(r,{className:n,children:t})},ns=({node:e,children:t})=>{let{source:n}=B(e),r=C(L(G()),n),i=(0,J.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,Y.jsx)(Rt,{value:i,children:t})},rs=({node:e,className:t})=>{let{source:n,choices:r,label:i=n,defaultValue:o}=B(e),{values:s,linkTo:c}=a(),l=s[n];return(0,Y.jsxs)(`div`,{className:O(`flex flex-wrap items-center gap-2`,t),children:[(0,Y.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:i}),r?(0,Y.jsx)(d,{label:i,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,Y.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,J.useState)(!1),c=Te(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,J.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=B(e),i=H().resources[r.reference],a=Le(L(G())),o=cn(t);return i?(0,Y.jsx)(ss,{model:i,...jt(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,Y.jsx)(dn,{read:r,list:i,empty:e,children:t})},cs=({node:e,at:t,children:n})=>{let r=B(e),i=H().resources[r.reference],a=Le(L(G())),o=cn(t);return i?(0,Y.jsx)(ss,{model:i,...l(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}=H(),s=cn(t),c=wt(e,{key:n,enabled:!s}),l=s?Zt(e,s):c;if(l.isPending)return(0,Y.jsx)(z,{className:`h-4 w-24`});if(l.error)return(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:l.error});if(!l.data)return null;let u=i.length>0?(0,Y.jsx)(qt,{value:l.data,children:i}):at(e,o[e.name],l.data.record,n);return r===!1?(0,Y.jsx)(`span`,{className:a,children:u}):(0,Y.jsx)(me,{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}=B(e),c=H().resources[i],l=C(L(G()),a);return c?l==null||l===``?s===void 0?null:(0,Y.jsx)(`span`,{className:r,children:s}):(0,Y.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=>r(e,t)).join(`, `),$=Ke(`users`),fs=({roles:e})=>{let{session:t}=q(),[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)([]),o=(0,J.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,J.useEffect)(o,[o]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(hr,{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,Y.jsx)(_r,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,Y.jsx)(k,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,Y.jsx)(gr,{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}=q(),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)([]),{busy:d,error:f,run:p}=fe(),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,Y.jsxs)(k,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,Y.jsx)(P,{message:f}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Y.jsx)(b,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,Y.jsx)(b,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,Y.jsx)(b,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,Y.jsx)(_r,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(W,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},ms=({user:e,roles:t,self:n})=>{let{session:r}=q(),[i,a]=(0,J.useState)(e),{busy:o,error:s,run:c,setError:l}=fe(),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,Y.jsx)(vr,{name:i.name,email:i.email,self:n,error:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[i.blocked&&(0,Y.jsx)(F,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,Y.jsx)(W,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,Y.jsx)(W,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,Y.jsx)(_r,{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}=q(),[i,a]=(0,J.useState)(``),o=(0,J.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=br(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,Y.jsx)(yr,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,Y.jsx)(ms,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},gs=()=>{let{session:e}=q(),[t,n]=(0,J.useState)([]),[r,i]=(0,J.useState)();return(0,J.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof j?o(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},_s=()=>{let{roles:e,error:t}=gs(),[n,r]=(0,J.useState)(0);return(0,Y.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,Y.jsx)(P,{message:t}),(0,Y.jsx)(hs,{roles:e,version:n}),(0,Y.jsx)(fs,{roles:e}),(0,Y.jsx)(ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},vs=({sender:e,busy:t,error:n,onSave:r,onClose:i})=>{let[a,o]=(0,J.useState)(e?.address??``),[s,c]=(0,J.useState)(e?.name??``),[l,u]=(0,J.useState)(e?.signature??``),[d,f]=(0,J.useState)(e?.isDefault??!1);return(0,Y.jsxs)(I,{title:e?e.address:K(`addFromAddress`),description:K(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:i,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:i,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:t,disabled:!a.trim(),onClick:()=>r({address:a.trim(),name:s.trim(),signature:l,isDefault:d}),children:K(e?`save`:`addAddress`)})]}),children:[!e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`fromAddress`),(0,Y.jsx)(b,{autoFocus:!0,type:`email`,value:a,maxLength:254,placeholder:K(`fromAddressPlaceholder`),onChange:e=>o(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[K(`fromName`),(0,Y.jsx)(b,{value:s,maxLength:100,placeholder:K(`fromNamePlaceholder`),onChange:e=>c(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{children:K(`defaultFromAddress`)}),(0,Y.jsx)(ge,{checked:d,onChange:f,label:K(`defaultFromAddress`)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[K(`signature`),(0,Y.jsx)(Ne,{value:l,maxLength:2e3,placeholder:K(`signaturePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,Y.jsx)(P,{message:n})]})},ys=e=>e.signature?K(`ownSignature`):K(`genericSignature`),bs=({senders:{address:e,senders:t},onAdd:n,onUpdate:r,onRemove:i})=>{let[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(),f=(0,J.useRef)(!1),p=t.find(e=>e.isDefault),m=()=>{d(void 0),l(void 0)},h=async e=>{if(!f.current){f.current=!0,s(!0),l(void 0);try{await e(),d(void 0)}catch(e){if(e instanceof TypeError)return l(K(`noAnswerFromServer`));if(!(e instanceof j))throw e;l(o(e))}finally{f.current=!1,s(!1)}}},g=e=>h(async()=>{let t=e.name||null,i=e.signature.trim()?e.signature:null;if(u?.kind===`change`)return r(u.sender.id,{name:t,signature:i,isDefault:e.isDefault});let a=await n({address:e.address,...t&&{name:t},...i&&{signature:i}});e.isDefault&&await r(a.id,{isDefault:!0})});return(0,Y.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold`,children:K(`fromAddresses`)}),(0,Y.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:K(`fromAddressesDescription`)}),(0,Y.jsx)(P,{message:u?void 0:c}),(e||t.length>0)&&(0,Y.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Tr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:K(`mailboxOwnAddress`)})]}),p?(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,loading:a,onClick:()=>void h(()=>r(p.id,{isDefault:!1})),children:K(`makeDefault`)}):(0,Y.jsx)(F,{tone:`blue`,children:K(`default`)})]}),t.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Tr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,Y.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:ys(e)})]}),e.isDefault&&(0,Y.jsx)(F,{tone:`blue`,children:K(`default`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>d({kind:`change`,sender:e}),children:K(`edit`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>d({kind:`remove`,sender:e}),children:K(`remove`)})]},e.id))]}),(0,Y.jsxs)(W,{onClick:()=>d({kind:`add`}),children:[(0,Y.jsx)(xn,{className:`size-3.5`}),K(`addFromAddress`)]}),u?.kind===`add`&&(0,Y.jsx)(vs,{busy:a,error:c,onSave:e=>void g(e),onClose:m}),u?.kind===`change`&&(0,Y.jsx)(vs,{sender:u.sender,busy:a,error:c,onSave:e=>void g(e),onClose:m},u.sender.id),u?.kind===`remove`&&(0,Y.jsx)(I,{title:K(`removeFromAddress`,{address:u.sender.address}),description:K(`removeFromAddressDescription`),onClose:m,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:m,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:a,onClick:()=>void h(()=>i(u.sender.id)),children:K(`remove`)})]}),children:(0,Y.jsx)(P,{message:c})})]})},xs=(e,t,n)=>Object.fromEntries(Fn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,Xn(`signInOnly`,{provider:n(e.provider),name:e.name})])),Ss=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=q(),{account:i}=t,[a]=(0,J.useState)(Ge),o=(0,J.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}=D(o,K(`couldNotReadMethods`));return s?(0,Y.jsx)(Qt,{title:K(`mailbox`),description:K(`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??yn(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&yt(a,e.length===1?e[0].name:K(`theProvider`)),children:(0,Y.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,Y.jsx)(A,{error:c})},Cs=()=>{let{personalMail:e}=q();return e.length>0?(0,Y.jsx)(Ss,{links:e}):null},ws=e=>xr(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,J.useState)(!1),[i,a]=(0,J.useState)(),[s,c]=(0,J.useState)(),l=async e=>{r(!0),a(void 0);try{await t(e.clientId),c(void 0)}catch(e){if(!(e instanceof j))throw e;a(o(e))}r(!1)};return(0,Y.jsxs)(k,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,Y.jsx)(P,{message:s?void 0:i}),e.length===0?(0,Y.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,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=Sr(e.clientId);return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Dr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:ws(e)}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,le(Date.parse(e.allowedAt)),` · `,Ts(e)]})]}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>c(e),children:`Disconnect`})]},e.clientId)})}),s&&(0,Y.jsx)(I,{title:`Disconnect ${ws(s)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>c(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>c(void 0),children:`Cancel`}),(0,Y.jsx)(W,{variant:`danger`,loading:n,onClick:()=>void l(s),children:`Disconnect`})]}),children:i&&(0,Y.jsx)(P,{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,Y.jsx)(k,{title:K(`mcpAddress`),description:K(`mcpAddressDescription`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(Cr,{value:e,copyLabel:K(`copyMcpAddress`)}),(0,Y.jsxs)(`a`,{href:Ds(e,t),target:`_blank`,rel:`noreferrer`,className:mt(),children:[(0,Y.jsx)(x,{className:`size-3.5`}),K(`addToClaude`)]})]})}),ks=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.connectedApps(),[e]),K(`couldNotReadMethods`));return t?(0,Y.jsx)(Es,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,Y.jsx)(A,{error:n})},As=({url:e})=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Os,{url:e,appName:H().appName}),(0,Y.jsx)(ks,{})]}),js=()=>{let{mcp:e}=q();return e?(0,Y.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=>le(Date.parse(e)),Fs=e=>e?K(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:Ps(e)}):K(`neverExpires`),Is=e=>[K(`createdOn`,{date:Ps(e.createdAt)}),Fs(e.expiresAt),e.lastUsedAt?K(`lastUsedOn`,{date:Ps(e.lastUsedAt)}):K(`notUsedYet`),e.organization?K(`actsAsIn`,{role:e.role,organization:e.organization}):K(`actsAs`,{role:e.role})].join(` · `),Ls=({tokens:e,onCreate:t,onRevoke:n})=>{let[r,i]=(0,J.useState)(!1),[a,s]=(0,J.useState)(),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(`90`),[m,h]=(0,J.useState)(),g=()=>{l(void 0),s(void 0),h(void 0)},_=(0,J.useRef)(!1),v=async e=>{if(!_.current){_.current=!0,i(!0),s(void 0);try{l(await e()),h(void 0)}catch(e){if(e instanceof TypeError)return s(K(`noAnswerFromServer`));if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):s(o(e))}finally{_.current=!1,i(!1)}}},y=()=>v(async()=>{let e=Ms[f];return{kind:`created`,created:await t({name:u.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,Y.jsxs)(k,{title:K(`accessTokens`),description:K(`accessTokensDescription`),children:[(0,Y.jsx)(P,{message:c?void 0:a}),e.length===0?(0,Y.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:K(`noAccessTokens`)}):(0,Y.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(kr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Is(e)})]}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>l({kind:`revoke`,token:e}),children:K(`revoke`)})]},e.id))}),(0,Y.jsxs)(W,{onClick:()=>{d(``),p(`90`),l({kind:`create`})},children:[(0,Y.jsx)(xn,{className:`size-3.5`}),K(`newAccessToken`)]}),c?.kind===`create`&&(0,Y.jsxs)(I,{title:K(`newAccessToken`),description:K(`newAccessTokenDescription`),onClose:g,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:g,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:r,disabled:!u.trim(),onClick:()=>void y(),children:K(`createAccessToken`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`name`),(0,Y.jsx)(b,{autoFocus:!0,value:u,maxLength:100,placeholder:K(`accessTokenNamePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[K(`accessTokenExpiry`),(0,Y.jsx)(He,{value:f,onChange:e=>p(e.target.value),children:Object.keys(Ms).map(e=>(0,Y.jsx)(`option`,{value:e,children:K(Ns[e])},e))})]}),m===`asked`&&(0,Y.jsx)(ot,{purpose:`change`,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,Y.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:K(`confirmedCreateAccessToken`)}),(0,Y.jsx)(P,{message:a})]}),c?.kind===`created`&&(0,Y.jsx)(I,{title:K(`accessTokenCreated`,{name:c.created.personalAccessToken.name}),description:K(`accessTokenCreatedDescription`),onClose:g,actions:(0,Y.jsx)(W,{variant:`primary`,onClick:g,children:K(`done`)}),children:(0,Y.jsx)(Cr,{value:c.created.token,copyLabel:K(`copyAccessToken`)})}),c?.kind===`revoke`&&(0,Y.jsx)(I,{title:K(`revokeAccessToken`,{name:c.token.name}),description:K(`revokeAccessTokenDescription`),onClose:g,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:g,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:r,onClick:()=>void v(async()=>(await n(c.token.id),void 0)),children:K(`revoke`)})]}),children:(0,Y.jsx)(P,{message:a})})]})},Rs=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.personalAccessTokens(),[e]),K(`couldNotReadAccessTokens`));return t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(P,{message:n}),(0,Y.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,Y.jsx)(A,{error:n})},zs=()=>q().personalAccessTokens?(0,Y.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,J.useState)(),[s,c]=(0,J.useState)(r),[l,u]=(0,J.useState)(),[d,f]=(0,J.useState)(),p=async(e,t)=>{a(e),c(void 0),f(void 0);try{await t(),u(void 0)}catch(e){if(!(e instanceof j))throw e;c(o(e))}finally{a(void 0)}};return(0,Y.jsxs)(k,{title:K(`connections`),description:K(`connectionsDescription`),children:[(0,Y.jsx)(P,{message:l?void 0:s}),(0,Y.jsx)(qe,{message:d}),(0,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(Nr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,Y.jsx)(W,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void p(e.key,()=>t(e)),children:e.accounts.length>0?K(`connectAgain`,{name:e.label}):K(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[K(`connectedOn`,{date:le(Date.parse(t.created_at))}),` · `,(0,Y.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,Y.jsx)(F,{tone:`amber`,children:K(`connectionNeedsSignIn`)}):(0,Y.jsx)(F,{tone:`green`,children:K(`connected`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>u({connection:e,accountId:t.id}),children:K(`disconnect`)})]}),t.used_by.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:K(`connectionUsedBy`)}),t.used_by.map(e=>(0,Y.jsx)(re,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),l&&(0,Y.jsx)(I,{title:K(`disconnectTitle`,{name:l.connection.label}),description:Vs(l.connection)?`${K(`disconnectDescription`)} ${K(`disconnectWholeGrant`)}`:K(`disconnectDescription`),onClose:()=>u(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>u(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:i===l.accountId,onClick:()=>void p(l.accountId,async()=>f(K(Bs[await n(l.accountId)]))),children:K(`disconnect`)})]}),children:s&&(0,Y.jsx)(P,{message:s})})]})},Us=()=>{let{session:e,connectAccount:t}=q(),{account:n}=e,[r]=(0,J.useState)(Ge),{data:i,error:a,reload:o}=D((0,J.useCallback)(()=>n.workflowConnections(),[n]),K(`couldNotReadMethods`));return i?i.length===0?null:(0,Y.jsx)(Hs,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&yt(r,K(`theProvider`))}):(0,Y.jsx)(A,{error:a})},Ws=e=>e.code===`LAST_ADMIN`?K(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?K(`deleteAccountLocked`):o(e),Gs=({hasPassword:e,onDelete:t,onClose:n})=>{let[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(),[l,u]=(0,J.useState)(!1),d=(0,J.useId)(),f=async()=>{o(!0),c(void 0),u(!1);try{await t(e?r:void 0)}catch(e){if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?u(!0):c(Ws(e)),o(!1)}};return(0,Y.jsxs)(I,{title:K(`deleteAccountQuestion`),description:K(`deleteAccountWarning`),onClose:n,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:n,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,type:`submit`,form:d,loading:a,disabled:e&&!r,children:K(`deleteAccountConfirm`)})]}),children:[(0,Y.jsxs)(`form`,{id:d,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),f()},children:[e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`deleteAccountPassword`),(0,Y.jsx)(b,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,invalid:!!s,onChange:e=>i(e.target.value)})]}),(0,Y.jsx)(P,{message:s})]}),l&&(0,Y.jsx)(ot,{purpose:`change`,minutes:15,onConfirmed:()=>void f()})]})},Ks=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,J.useState)(!1);return(0,Y.jsxs)(k,{title:K(`deleteAccount`),description:K(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,Y.jsx)(W,{variant:`danger`,onClick:()=>i(!0),children:K(`deleteAccount`)}),r&&(0,Y.jsx)(Gs,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},qs=()=>{let{session:e,state:t,deleteAccount:n}=q(),{account:r}=e,{data:i,error:a}=D((0,J.useCallback)(()=>r.signInMethods(),[r]),K(`couldNotReadMethods`));return i?(0,Y.jsx)(Ks,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,Y.jsx)(A,{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?K(`deviceThrough`,{device:e.device,provider:e.name}):e.name,$s=(e,t)=>{if(e.staff)return t?K(`staffOf`,{operator:t}):K(`staff`);let{browser:n,system:r}=Zs(e.userAgent);return n&&r?K(`browserOn`,{browser:n,system:r}):r?K(`aBrowserOn`,{system:r}):n??K(`unknownDevice`)},ec=e=>{if(e.staff)return Fr;let{system:t}=Zs(e.userAgent);return t===`iPhone`||t===`Android`?Lr:t===`iPad`?zr:jr},tc=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),nc=(e,t)=>e.kind===`one`?K(`signOutDevice`,{name:$s(e.session,t)}):e.kind===`link`?K(`signOutDevice`,{name:Qs(e.link)}):K(`signOutOthersTitle`),rc=e=>K(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),ic=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(),[d,f]=(0,J.useState)(),p=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),m=e.filter(e=>!e.current),h=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),g=async e=>{c(!0),u(void 0);try{await h(e),f(void 0)}catch(e){if(!(e instanceof j))throw e;u(o(e))}c(!1)},_=e=>{u(void 0),f(e)};return(0,Y.jsxs)(k,{title:K(`devices`),description:K(`devicesDescription`),children:[p.length===0&&n.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:K(`noDevices`)}):(0,Y.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[tc(p).map(e=>{let n=ec(e);return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`bdi`,{className:`truncate font-medium`,children:$s(e,t)}),e.current&&(0,Y.jsx)(F,{tone:`green`,children:K(`thisDevice`)})]}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[K(`signedInFromUntil`,{from:Xe(Date.parse(e.createdAt)),until:Xe(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`one`,session:e}),children:K(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Lr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`bdi`,{className:`truncate font-medium`,children:Qs(t)}),n&&(0,Y.jsx)(F,{tone:`green`,children:K(`thisDevice`)})]}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:K(`linkedOn`,{date:Xe(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`link`,link:t}),children:K(`signOut`)})]},t.id)})]}),m.length>0&&(0,Y.jsx)(W,{className:`mt-3`,onClick:()=>_({kind:`others`}),children:K(`signOutOthers`)}),d&&(0,Y.jsx)(I,{title:nc(d,t),description:rc(d),onClose:()=>f(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>f(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:s,onClick:()=>void g(d),children:K(`signOut`)})]}),children:(0,Y.jsx)(P,{message:l})})]})},ac=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=q(),{account:r}=e,i=(0,J.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}=D(i,K(`couldNotReadDevices`));return a?(0,Y.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,Y.jsx)(A,{error:o})},oc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},sc=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(),[f,p]=(0,J.useState)(``),[m,g]=(0,J.useState)(),_=e===`required`&&t.length<=1,v=async e=>{s(!0),l(void 0),g(void 0);try{await e(),d(void 0)}catch(e){if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?g(`asked`):l(o(e))}s(!1)};return(0,Y.jsxs)(k,{title:K(`passkeys`),status:e===`required`&&(0,Y.jsx)(F,{tone:`blue`,children:K(`required`)}),description:K(oc[e]),children:[(0,Y.jsx)(P,{message:u?void 0:c}),t.length>0&&(0,Y.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(h,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??K(`passkey`)}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?K(`addedOn`,{date:le(Date.parse(e.createdAt))}):K(`addedEarlier`),` · `,e.backedUp?K(`synced`):K(`oneDevice`)]})]}),(0,Y.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>{p(e.name??``),d({kind:`rename`,passkey:e})},children:K(`rename`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:_,title:_?K(`keepLastPasskey`):void 0,onClick:()=>d({kind:`remove`,passkey:e}),children:K(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,Y.jsxs)(W,{loading:a&&!u,onClick:()=>void v(n),children:[(0,Y.jsx)(xn,{className:`size-3.5`}),K(`addPasskey`)]}),m===`asked`&&(0,Y.jsx)(ot,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>g(`done`)}),m===`done`&&(0,Y.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:K(`confirmedAddPasskey`)}),u?.kind===`rename`&&(0,Y.jsxs)(I,{title:K(`renamePasskey`),description:K(`renamePasskeyDescription`),onClose:()=>d(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>d(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:a,disabled:!f.trim(),onClick:()=>void v(()=>r(u.passkey.id,f.trim())),children:K(`save`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`name`),(0,Y.jsx)(b,{autoFocus:!0,value:f,maxLength:60,onChange:e=>p(e.target.value)})]}),(0,Y.jsx)(P,{message:c})]}),u?.kind===`remove`&&(0,Y.jsx)(I,{title:K(`removePasskey`),description:K(`removePasskeyDescription`,{name:u.passkey.name??K(`thisPasskey`)}),onClose:()=>d(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>d(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:a,onClick:()=>void v(()=>i(u.passkey.id)),children:K(`remove`)})]}),children:c&&(0,Y.jsx)(P,{message:c})})]})},cc=()=>{let{account:e}=q().session,t=(0,J.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=D(t,K(`couldNotReadMethods`));if(!n)return(0,Y.jsx)(A,{error:r});let[a,o]=n;return(0,Y.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`?K(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?K(`passwordTooLong`):o(e),uc=(e,t)=>{if(e.length<12)return K(`useAtLeast`,{length:12});if(e!==t)return K(`passwordsDiffer`)},dc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(),p=(0,J.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 j))throw e;f(lc(e)),u(!1)}}};return(0,Y.jsx)(I,{title:K(e?`changePassword`:`setPassword`),description:K(`atLeast`,{length:12}),onClose:n,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:n,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,type:`submit`,form:p,loading:l,disabled:!m,children:K(`save`)})]}),children:(0,Y.jsxs)(`form`,{id:p,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`currentPassword`),(0,Y.jsx)(b,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`newPassword`),(0,Y.jsx)(b,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!d,onChange:e=>o(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`repeatPassword`),(0,Y.jsx)(b,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:s,invalid:!!d,onChange:e=>c(e.target.value)})]}),e&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:K(`changeSignsOutOthers`)}),(0,Y.jsx)(P,{message:d})]})})},fc=({rule:e,hasPassword:t,staff:n})=>K(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),pc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:i})=>{let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=!n&&e===`allowed`;return(0,Y.jsxs)(k,{title:K(`password`),description:fc({rule:e,hasPassword:t,staff:n}),children:[(0,Y.jsx)(qe,{message:s?K(`passwordSaved`):void 0}),l&&(0,Y.jsx)(W,{onClick:()=>{c(!1),o(!0)},children:K(t?`changePassword`:`setPassword`)}),a&&(0,Y.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}=q(),{account:n}=e,{data:r,error:i,reload:a}=D((0,J.useCallback)(()=>n.signInMethods(),[n]),K(`couldNotReadMethods`));return r?(0,Y.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,Y.jsx)(A,{error:i})},hc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,J.useState)(``),[s,c]=(0,J.useState)(),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(),h=async e=>{f(!0),m(void 0);try{await e()}catch(e){if(!(e instanceof j))throw e;m(o(e))}f(!1)},g=i.trim(),_=()=>h(async()=>{await t.request(g),u(``),c(g)}),v=e=>h(async()=>{await t.confirm(s,e),n()});return s?(0,Y.jsxs)(I,{title:K(`changeEmail`),description:K(`codeSentTo`,{email:s,minutes:10}),onClose:r,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{variant:`ghost`,onClick:()=>{c(void 0),m(void 0)},children:K(`otherAddress`)}),(0,Y.jsx)(W,{variant:`primary`,loading:d,disabled:l.length<6,onClick:()=>void v(l),children:K(`changeEmail`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`code`),(0,Y.jsx)(xt,{name:`code`,required:!0,autoFocus:!0,value:l,invalid:!!p,onChange:u,onComplete:e=>!d&&void v(e)})]}),(0,Y.jsx)(P,{message:p})]}):(0,Y.jsxs)(I,{title:K(`changeEmail`),description:K(`changeEmailDescription`),onClose:r,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:r,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:d,disabled:!g||g.toLowerCase()===e.toLowerCase(),onClick:()=>void _(),children:K(`sendCode`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`newEmail`),(0,Y.jsx)(b,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,Y.jsx)(P,{message:p})]})},gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(),g=async()=>{p(!0),h(void 0);try{await n(u.trim()),s(!1)}catch(e){if(!(e instanceof j))throw e;h(o(e))}p(!1)};return(0,Y.jsxs)(k,{title:K(`profile`),description:K(`profileDescription`),children:[(0,Y.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:K(`name`)}),(0,Y.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:K(`email`)}),(0,Y.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(W,{onClick:()=>{d(e),h(void 0),s(!0)},children:K(`changeName`)}),r&&(0,Y.jsx)(W,{onClick:()=>l(!0),children:K(`changeEmail`)})]}),a&&(0,Y.jsxs)(I,{title:K(`changeName`),description:K(`changeNameDescription`),onClose:()=>s(!1),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>s(!1),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:f,disabled:!u.trim()||u.trim()===e,onClick:()=>void g(),children:K(`save`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`name`),(0,Y.jsx)(b,{autoFocus:!0,value:u,maxLength:100,onChange:e=>d(e.target.value)})]}),(0,Y.jsx)(P,{message:m})]}),c&&r&&(0,Y.jsx)(hc,{email:t,change:r,onClose:()=>l(!1),onDone:()=>{l(!1),i?.()}})]})},_c=()=>{let{session:e,changeEmail:t}=q(),{data:n,loaded:r,error:i,reload:a}=D((0,J.useCallback)(()=>e.session(),[e]),K(`couldNotReadProfile`));if(!r)return(0,Y.jsx)(A,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,Y.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:r,needsPassword:i,onConfirm:a,onClose:s})=>{let[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(),[m,h]=(0,J.useState)(!1),g=async()=>{d(!0),p(void 0),h(!1);try{await a(i?c:void 0)}catch(e){if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(!0):p(o(e)),d(!1)}};return(0,Y.jsxs)(I,{title:e,description:t,onClose:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:s,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:r?`danger`:`primary`,loading:u,disabled:i&&!c,onClick:()=>void g(),children:n})]}),children:[i&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`yourPassword`),(0,Y.jsx)(b,{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,Y.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:f}),m&&(0,Y.jsx)(ot,{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,J.useState)(),d=()=>u(void 0),f=n?(0,Y.jsx)(F,{tone:`green`,children:K(`on`)}):t===`required`?(0,Y.jsx)(F,{tone:`amber`,children:K(`required`)}):(0,Y.jsx)(F,{children:K(`off`)}),p=K(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:yc[t]);return l?.kind===`setup`?(0,Y.jsx)(k,{title:K(`twoFactor`),status:f,description:p,children:(0,Y.jsx)(`div`,{className:`max-w-sm`,children:(0,Y.jsx)(Kt,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,Y.jsxs)(k,{title:K(`twoFactor`),status:f,description:p,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,Y.jsx)(W,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:K(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,Y.jsx)(W,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:K(`addAuthenticator`)}),n&&r&&(0,Y.jsx)(W,{onClick:()=>u({kind:`new-codes`}),children:K(`newBackupCodes`)}),n&&(0,Y.jsx)(W,{variant:`danger`,disabled:t===`required`,title:t===`required`?K(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:K(`turnOff`)})]}),l?.kind===`turn-off`&&(0,Y.jsx)(vc,{title:K(`turnOffTitle`),description:K(`turnOffDescription`),confirmLabel:K(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,Y.jsx)(vc,{title:K(`newCodesTitle`),description:K(`newCodesDescription`),confirmLabel:K(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,Y.jsx)(I,{title:K(`yourNewCodes`),description:K(`keepCodesSafe`),onClose:d,actions:(0,Y.jsx)(W,{variant:`primary`,onClick:d,children:K(`savedCodes`)}),children:(0,Y.jsx)(tn,{codes:l.codes})})]})},xc=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.signInMethods(),[e]),K(`couldNotReadMethods`));return t?(0,Y.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,Y.jsx)(A,{error:n})},Sc=({problem:e,fallback:t})=>t===void 0?(0,Y.jsx)(ne,{children:e}):(0,Y.jsxs)(Y.Fragment,{children:[!1,t]}),Cc=({name:e,registered:t,fallback:n,children:r})=>t?(0,Y.jsx)(Re,{name:e,fallback:n===void 0?void 0:(0,Y.jsx)(Sc,{problem:N.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,Y.jsx)(Sc,{problem:N.rich(`noComponent`,{component:e}),fallback:n}),wc={Page:Pa,Grid:ua,Card:ii,Stat:yo,RecordCard:Ra,Field:aa,Diff:na,Table:wo,CardRow:ci,RecordRow:ro,RecordCards:$a,Chart:li,Timeline:qi,Graph:Zi,Progress:Ia,Image:va,ModalForm:Na,Thread:Zo,Composer:$i,Action:ri,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:Be,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:oi,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:xe(t,...n,r)}})),Dc=({text:e})=>{let t=G(),n=Oe(),r={...L(t),params:n};return(0,Y.jsx)(Y.Fragment,{children:E(e,e=>ie(C(r,e)))})},Oc=(e,t)=>e.includes(`{{`)?(0,Y.jsx)(Dc,{text:e},t):(0,Y.jsx)(J.Fragment,{children:e},t),kc=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?Oc(e,n):(0,Y.jsx)(Ic,{node:e,at:t},n)),Ac=e=>{let t=[];for(let n of e){let e=t.at(-1);Ur(n.child)&&e&&Ur(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Ur(n.child)?(0,Y.jsx)(`p`,{className:`leading-6`,children:kc(e)},t):(0,Y.jsx)(Ic,{node:n.child,at:n.at},t)})},jc=e=>Ve(e)||Array.isArray(e)&&e.length>0&&e.every(Ve),Mc=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>jc(n)?[[e,(0,Y.jsx)(Y.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:xe(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])=>Ve(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=_(t,String(e.props.i18nKey),Pc(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||Ve(e)?e:String(e)):[i]},Ic=({node:e,at:t})=>{let{components:n}=At(),r=G(),i=Oe(),a=st(),o=(0,J.useMemo)(()=>Xt(gn(e,{...L(r),params:i}),a),[e,r,i,a]);if(o.type===`Trans`&&!o.custom)return(0,Y.jsx)(Y.Fragment,{children:kc(Fc(o,a).map(e=>({child:e})))});if(o.custom){let e=n?.[o.type],r=o.children.length>0?(0,Y.jsx)(Ji,{node:o,children:Ac(Ec(o.children,t,`children`))}):void 0;return(0,Y.jsx)(Cc,{name:o.type,registered:!!e,fallback:o.fallback&&(0,Y.jsx)(Y.Fragment,{children:Ac(Ec(o.fallback,t,`fallback`))}),children:e&&(0,Y.jsx)(Je,{node:o,...t!==void 0&&{at:t},children:(0,Y.jsx)(e,{...be(o.props),children:r})})})}let s=wc[o.type];if(!s)return(0,Y.jsx)(ne,{children:N.rich(`unknownBlock`,{type:o.type})});let c=typeof o.props.className==`string`?o.props.className:void 0,l=Ec(o.children,t,`children`),u=(0,Y.jsx)(s,{node:o,at:t,slots:Mc(o,t),className:c,children:o.type===`Text`||o.type===`Link`||o.type===`Summary`?kc(l):Ac(o.type===`Switch`?l.filter(({child:e})=>typeof e!=`string`):l)}),d=c===void 0||Tc.has(o.type)?u:(0,Y.jsx)(`div`,{className:c,children:u});return o.fallback?(0,Y.jsx)(Re,{name:o.type,resetKey:o,fallback:(0,Y.jsx)(Y.Fragment,{children:Ac(Ec(o.fallback,t,`fallback`))}),children:d}):d};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=d894407e-73aa-4c06-a157-f6139f709c36
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-_7poAZsr.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-B94YfKGx.js","assets/vendor-t7Q7QbPu.js","assets/app-xwgcmboV.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,$c as i,$n as a,$o as o,$s as s,$t as c,As as l,At as u,B as d,Bo as f,Bs as p,C as m,Cc as h,Cn as g,Cs as _,D as v,Dl as y,Do as b,Ec as x,En as S,Es as C,F as w,Fa as T,Fl as E,Fn as ee,Fs as te,Ga as ne,Go as D,Gt as re,Hc as O,Hl as ie,Hs as ae,Ic as oe,In as se,Is as ce,Ji as le,Jn as ue,Jo as k,Jt as de,Ka as fe,Ko as A,Ln as pe,Lr as me,Ls as he,M as ge,Mt as _e,Nc as ve,Nt as ye,Ol as be,Os as xe,Pa as Se,Pl as Ce,Pn as we,Pr as Te,Ps as Ee,Pt as De,Qn as Oe,Qo as ke,Qs as Ae,R as je,Ri as Me,Rn as Ne,Rr as Pe,Rs as Fe,Si as Ie,Ss as j,Ts as Le,Ua as Re,Un as ze,Uo as Be,Us as Ve,V as He,Vc as M,Vr as Ue,Vs as We,Wa as N,Wo as Ge,Xc as Ke,Xo as qe,Xt as Je,Yc as Ye,Yi as Xe,Yn as Ze,Yo as P,Ys as Qe,Zi as $e,Zo as F,Zs as et,_ as tt,_a as nt,_n as rt,_t as it,ac as I,al as at,ao as ot,as as st,at as ct,b as lt,ba as ut,bi as dt,bs as ft,ca as pt,cc as mt,cl as ht,cn as gt,cr as L,dr as _t,ec as vt,es as yt,fl as bt,fo as xt,fr as R,ga as St,gi as Ct,gn as wt,gt as Tt,ha as Et,hn as Dt,i as Ot,ic as z,in as B,ir as kt,ja as At,js as jt,jt as Mt,k as Nt,ki as Pt,ks as Ft,lc as It,ln as Lt,lr as Rt,ls as zt,ma as Bt,ml as Vt,mn as Ht,mr as V,na as Ut,nc as Wt,nn as Gt,no as Kt,nr as qt,ns as H,on as Jt,or as Yt,os as Xt,pn as Zt,pr as U,qo as Qt,rl as $t,rn as en,ro as tn,rs as nn,s as rn,sc as W,sl as an,sn as on,sr as G,ta as sn,tn as cn,tr as ln,un,ur as dn,v as fn,vn as pn,vs as K,wa as mn,wn as hn,ws as gn,wt as _n,xa as vn,xs as yn,y as bn,yc as xn,yn as Sn,ys as q,zo as Cn,zs as wn}from"./app-B94YfKGx.js";import{C as Tn,f as En,o as Dn,s as On}from"./vendor-t7Q7QbPu.js";import{C as kn,Ct as An,Dt as jn,Et as Mn,Mt as Nn,O as Pn,Ot as Fn,Q as In,St as Ln,Tt as Rn,X as zn,Z as Bn,_t as Vn,at as Hn,b as Un,ct as Wn,dt as Gn,ft as Kn,gt as qn,it as Jn,k as Yn,kt as Xn,l as Zn,lt as Qn,mt as $n,n as er,nt as tr,o as nr,ot as rr,rt as ir,st as ar,t as or,tt as sr,ut as cr,wt as lr,x as ur,xt as dr,y as fr}from"./embedded-list-OJQKeuBN.js";import{t as pr}from"./circle-alert-C8YjGdRx.js";import{t as mr}from"./page-header-Ddz2r5ic.js";import{n as hr,t as gr}from"./pending-invitation-row-BZVOux9W.js";import{n as _r,t as vr}from"./person-row-DgXLW9D8.js";import{n as yr,t as br}from"./use-paged-search-DRj8498k.js";import{n as xr,t as Sr}from"./client-publisher-D39SlIhp.js";import{t as Cr}from"./copy-field-DXp0fGDR.js";var wr={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`}]]};wr.node;var Tr=M(wr),Er={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`}]]};Er.node;var Dr=M(Er),Or={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`}]]};Or.node;var kr=M(Or),Ar={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`}]]};Ar.node;var jr=M(Ar),Mr={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`]};Mr.node;var Nr=M(Mr),Pr={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`}]]};Pr.node;var Fr=M(Pr),Ir={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`}]]};Ir.node;var Lr=M(Ir),Rr={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`}]]};Rr.node;var zr=M(Rr),Br=[`done`,`error`,`running`];ae(`TextField`,!1),ae(`NumberField`,!1),ae(`DateField`,!1),ae(`BooleanField`,!1),ae(`UrlField`,!1),ae(`ChipField`,!1);var Vr=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Hr=e=>typeof e!=`string`&&!e.custom&&Vr.has(e.type),Ur=e=>typeof e==`string`||Hr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Wr=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Gr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),Kr=(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)},qr=(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)},Jr=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,Yr=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Xr=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:Yr.has(`${n.toLowerCase()}:`)?e:void 0},Zr=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),Qr=e=>e==null||e===``?void 0:String(e),$r=(e,t)=>e<t?-1:+(e>t),ei=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=Qr(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=Qr(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=>Qr(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=Qr(e[i.source]),s=Qr(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)=>$r(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>$r(e.id,t.id)),edges:s.sort((e,t)=>$r(e.source,t.source)||$r(e.target,t.target)||$r(e.id,t.id))}},J=e(t(),1),Y=e(n(),1),ti=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=H(),s=An(e.name,void 0),c=Me(),[l,u]=(0,J.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=>Ht(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let m=f.length-p.length,h=dr(`actionCount`,{label:r??d.label,count:p.length}),g=e=>s.runEach(d,p,m,e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>Mn(d)?u(!0):void g(),children:h}),l&&(0,Y.jsx)(Rn,{action:d,label:h,danger:i===`danger`||i===void 0&&jn(d),records:p.map(e=>e.record),names:p.map(t=>Ln(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),g()},onSubmit:async e=>{u(!1),await g(e)}})]})},ni=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=Yt(),c=lr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,J.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{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:()=>Mn(c.action)?u(!0):void c.run(),children:d}),l&&(0,Y.jsx)(Rn,{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)}})]})},ri=({node:e,className:t})=>{let n=B(e),r=_t(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,Y.jsx)(ti,{...n,model:i,items:r.items,className:t}):(0,Y.jsx)(ni,{...n,className:t})},ii=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=B(e);return(0,Y.jsx)(R,{title:i,description:a,actions:n.actions,className:O(`h-full`,r),children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},ai=({children:e,wrap:t=(e,t)=>(0,Y.jsx)(J.Fragment,{children:e},t)})=>{let n=_t();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...Ht(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,Y.jsx)(qt,{value:s,row:{index:o,count:i.length},children:e}),c)})},oi=({children:e})=>(0,Y.jsx)(ai,{children:e}),si=({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=cn(t),f=rt(e,{filter:n,sort:r,pageSize:i,enabled:!d}),p=d??f,m=d?d.rows:f.data?.items??[];return(0,Y.jsx)(R,{title:a,description:o,actions:c,className:u,children:p.isPending?(0,Y.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(z,{className:`h-24 w-56`},t))}):p.error?(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:p.error}):m.length===0?(0,Y.jsx)(U,{children:s??N(`nothingYet`)}):(0,Y.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,Y.jsx)(Rt,{value:{model:e,items:m,...d&&{planned:!0}},children:(0,Y.jsx)(ai,{wrap:(e,t)=>(0,Y.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})})})})},ci=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=B(e),o=H().resources[i];return o?(0,Y.jsx)(si,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},li=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=B(e),{resources:u,views:d}=H(),f=u[r];return f?(0,Y.jsx)(R,{title:i,description:a,actions:t.actions,className:O(`h-full`,n),children:(0,Y.jsx)(Kn,{model:f,view:d[r],...l})}):null},ui=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=wt(e,t),a=i.isPending?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(z,{className:`h-4 w-1/2`}),(0,Y.jsx)(z,{className:`h-4 w-1/3`})]}):i.error?(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:i.error}):i.data?(0,Y.jsx)(qt,{value:i.data,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,Y.jsx)(U,{children:N(`nothingYet`)});return(0,Y.jsx)(`div`,{className:n,children:a})},di=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},fi=e=>e==null?``:String(e),X=(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=di(i[t.start]);if(e===void 0)continue;let a=di(i[t.end]),o=Math.max(e,a??n),s=r.get(fi(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(fi(i[t.lane]),s);let c=s.bars.get(fi(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(fi(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:X(n,a,s),width:X(r,a,s)-X(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:X(o,a,s),width:X(c,a,s)-X(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:X(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:X(a,e,r)})}return{daily:o>=Z,ticks:s}},Ci=e=>({lane:fi(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`:pt(),i=e=>n?0:Ti(e,r),{daily:a,ticks:o}=Si(e,t,i);return(0,Y.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,Y.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Ei(e.left)}`,style:{left:`${e.left}%`},children:a?$e(e.at+i(e.at)):Ut(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&&Vt(a)?{className:ke[a],striped:i}:{color:qn(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,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...ki(a)}},i)}),ji=(e,t)=>t?le(e):Xe(e),Mi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return N(`timelineRange`,{from:ji(n,a),to:i?N(`timelineNow`):ji(r,a)})},Ni=(e,t,n,r)=>`${Ct(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??Ct(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=H().resources[t.fields[r.bar]?.relation?.resource??``],s=S(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,Y.jsx)(Ai,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,Y.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Fi,...l,children:d});let f=a.chosen===e.key;return(0,Y.jsx)(Wt,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:O(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,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,Y.jsx)(Di,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,Y.jsx)(Sn,{model:n,field:i,value:e.value})}),(0,Y.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,Y.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,Y.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,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`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,Y.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Ri,{...t,value:e}),Ct(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,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:N(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:(0,Y.jsx)(Sn,{model:n,field:n.fields[i.bar],value:e.value})}),(0,Y.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Mi(n,i,e.start,e.end,a)})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,Y.jsx)(Ri,{...t,value:e.value}),Ct(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:[...Ye.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})=>Dn({...Hi(zt(),e,n),enabled:t,placeholderData:En}),Wi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=he,title:s,description:c,empty:l,actions:u,className:d,choose:f,details:p})=>{let[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),v=e=>e?Ci(e):null,y={hover:e=>h(v(e)),focus:e=>_(v(e))},b=cn(i),x=Ui(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!b}),S=b??x,C=b?b.rows:x.data?.rows??[],w=!b&&x.data?.cut===!0,T=hi(C,n,Date.now());return(0,Y.jsxs)(R,{title:s,description:c,actions:u,className:O(`h-full`,d),children:[(()=>{if(S.isPending)return(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(z,{className:`h-6`},t))});if(S.error)return(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:S.error});if(T.lanes.length===0)return(0,Y.jsx)(U,{children:l??N(`nothingYet`)});let r=new Set(C.map(e=>String(e[n.color])));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(zi,{model:e,view:t,fields:n,values:r}),(0,Y.jsx)(Li,{shape:T,model:e,view:t,fields:n,point:y,...f&&{choose:f}}),w&&(0,Y.jsx)(U,{children:N(`timelineCut`,{count:C.length})}),(0,Y.jsx)(`div`,{"aria-live":`polite`,children:(0,Y.jsx)(Bi,{bar:wi(T,m)??wi(T,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:i}=a(),o=r[e],s=t=>i({[e]:t}),c=n.model.fields[n.fields.bar],l=o===void 0?null:(0,Y.jsx)(vt,{name:e,children:(0,Y.jsx)(ui,{model:n.model,query:{filter:Vn(c,Gi(c,o),n.filter),sort:n.sort},children:t},o)});return(0,Y.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}=B(e),{resources:h,views:g}=H(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Fe(e),sort:wn(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,Y.jsx)(Wi,{...v}):(0,Y.jsx)(Ki,{...v,select:s,children:r})},Ji=({node:e,children:t})=>{let n=We(e),r=ln(),{resources:i}=H();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,Y.jsx)(vt,{name:n.param,children:(0,Y.jsx)(ui,{model:o,query:{key:a},className:``,children:t},a)})},Yi=(0,J.lazy)(()=>Tn(()=>import(`./graph-view-_7poAZsr.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,Y.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,Y.jsx)(It,{})}),Zi=({node:e,at:t,slots:n,children:r,className:i})=>{let a=B(e),o=c(e,t),s=ln(),l=o.nodes,u=o.edges,{label:d,group:f,status:p,source:m,target:h}=a,g=(0,J.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,J.useMemo)(()=>l&&u&&ei({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,Y.jsx)(V,{title:N(`couldNotLoad`),error:y});if(l.isPending||u.isPending)return Xi;if(v.nodes.length===0)return(0,Y.jsx)(U,{children:a.empty??N(`nothingYet`)});let b=a.select,x=b!==void 0&&s?{chosen:s.given[b],linkTo:e=>s.linkTo({[b]:e})}:void 0;return(0,Y.jsxs)(`div`,{className:O(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(J.Suspense,{fallback:Xi,children:(0,Y.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,Y.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,Y.jsx)(Ji,{node:e,children:r})})]})},Q=Ke(`app/conversation`),Qi=({resource:e,field:t,values:n,placeholder:r})=>{let{resources:i}=H(),a=zt(),o=pn(),s=nn(e),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)();return!i[e]||!mn(s,`create`)?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[u!==void 0&&(0,Y.jsx)(V,{title:Q(`notSent`),error:u}),(0,Y.jsx)(_n,{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}=B(e);return(0,Y.jsx)(Qi,{resource:t,field:n,values:r,placeholder:i})},ea=({node:e,children:t,className:n})=>{let{open:r}=B(e);return(0,Y.jsx)(`details`,{open:r,className:O(`[&[open]>summary]:mb-2`,n),children:t})},ta=({children:e,className:t})=>(0,Y.jsx)(`summary`,{className:O(`cursor-pointer font-medium`,t),children:e}),na=({node:e,className:t})=>{let{source:n,emptyText:r}=B(e),i=Lt(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,Y.jsx)(z,{className:O(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,Y.jsx)(`p`,{className:O(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=Tt(a);return o?(0,Y.jsx)(`div`,{className:O(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,Y.jsx)(it,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,Y.jsx)(`pre`,{className:O(`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=>ht(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},aa=({node:e,className:t})=>{let{source:n,label:r,format:i}=B(e),{views:a}=H(),o=Lt(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,Y.jsx)(z,{className:`h-4 w-24`}):o.state===`plain`?ra(o.value):(0,Y.jsx)(Sn,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,Y.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,Y.jsxs)(`div`,{className:O(`min-w-0`,t),children:[(0,Y.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,Y.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}=B(e),i=e.children,a=i.length>0&&i.every(la);return(0,Y.jsx)(`div`,{className:O(`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,Y.jsx)(`div`,{className:O(`min-w-0`,r&&ca[r]),children:e},t)})})},da=({src:e,alt:t,width:n,height:r,className:i})=>(0,Y.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,J.useState)();return(0,J.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,J.useState)();return[t!==void 0&&t===e,()=>n(e)]},_a=({name:e,alt:t,width:n,height:r,refresh:i,className:a})=>{let o=zt(),{theme:s}=T(),[c,l]=ct(),u=fa({width:n,height:r,space:l,theme:s}),d=Dn({queryKey:Ye.image(e,u??{}),enabled:u!==void 0,placeholderData:En,...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,Y.jsx)(`div`,{ref:c,className:O(`min-w-0`,a),children:d.isError||p?t&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:t}):f?(0,Y.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,Y.jsx)(z,{className:`w-full max-w-full`,style:{height:r??160,...n!==void 0&&{width:n}}})})},va=({node:e,className:t})=>{let n=B(e);return n.src===void 0?(0,Y.jsx)(_a,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,Y.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=B(t),{views:i}=H(),a=Lt(r.source);return a.state===`missing`?null:a.state===`loading`?(0,Y.jsx)(z,{className:`inline-block h-3 w-16 align-middle`}):Wr(t.type,a.value)?r.emptyText?(0,Y.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,Y.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,Y.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`?an(e,n?.valueLabels):Gr(e),xa=ya(ba),Sa=ya(({value:e,props:t})=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:Kr(e,t,i())})),Ca=ya(({value:e,props:t})=>{let n=qr(e,t,{locale:i(),now:Date.now(),relative:sn});return(0,Y.jsx)(`time`,{dateTime:String(e),children:n})}),wa=ya(({value:e,props:t})=>{let n=Jr(e,t,{yes:Pt(`yes`),no:Pt(`no`)});return e?(0,Y.jsx)(ze,{label:n,className:`align-middle`}):(0,Y.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ta=ya(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=Xr(n);return i===void 0?r:(0,Y.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,Y.jsx)(hn,{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=B(e),i={...L(G()),params:Oe()},a=r.variant?O(mt({variant:r.variant}),n):n??Da,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=Ce(r.to,Le(i));return(0,Y.jsx)(me,{to:e,className:a,children:o??Qe(e)})}let s=r.href??``;return(0,Y.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]:v(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:v(i)]})),Aa=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return rn(r)?r.key===v(n[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:m(i,r,n[t])?[[t,Nt(i,r)]]:[]})),ja=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=H(),u=zt(),d=Se(),f=pn(),p=l[e.name],[m,h]=(0,J.useState)(()=>ka(e,a,t?.record)),[g,_]=(0,J.useState)({}),[v,y]=(0,J.useState)(0),b=tt(v),[x,S]=(0,J.useState)(),[C,w]=(0,J.useState)(!1),[T,E]=(0,J.useState)(!1);Ae(T||C,`input-lost`);let ee=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...Ot(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:N(`saved`,{label:i??r})}),s()},e=>{let t=fn(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,Y.jsx)(I,{title:i??r,onClose:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:s,children:N(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:C,onClick:()=>void ee(),children:N(n===`create`?`create`:`save`)})]}),children:(0,Y.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,Y.jsx)(V,{title:N(`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??ht(n),s=g[n];return(0,Y.jsx)(je,{name:n,label:o,help:p?.fields[n]?.help,error:s&&bn(r,o,s),children:(0,Y.jsx)(lt,{field:r,hints:p?.fields[n],value:rn(i)?i.key:i,stored:t?.record[n],relationLabel:rn(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=wt(e,{key:t});return(0,Y.jsx)(Y.Fragment,{children:n(r.data??void 0)})},Na=({node:e})=>{let t=B(e),n=Yt(),{resources:r}=H(),i=r[t.resource??n?.model.name??``],a=nn(i?.name??``),[o,s]=(0,J.useState)(!1);if(!i||!(t.mode===`create`?mn(a,`create`):mn(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,Y.jsx)(ja,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,Y.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}=B(e);return(0,Y.jsx)(`div`,{className:O(`flex-1`,r),children:(0,Y.jsxs)(`div`,{className:O(`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,Y.jsx)(mr,{title:i,subtitle:a,actions:n.actions}),t]})})},Fa=(e,t)=>{let n=G(),r=typeof e==`string`?kt(n,e):void 0,i=on(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:a}=B(e),o=Fa(n,0),s=Fa(r,100);if(o===void 0||s===void 0)return(0,Y.jsx)(z,{className:`h-6 w-full`});if(!Number.isFinite(o)||!Number.isFinite(s))return null;let c=s>0?Math.min(1,Math.max(0,o/s)):0;return(0,Y.jsxs)(`div`,{className:O(`min-w-0`,t),children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:a}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[o.toLocaleString(i()),` / `,s.toLocaleString(i())]})]}),(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":a,"aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":s,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:c>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${c*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=cn(t),f=wt(e,{filter:n,sort:r,key:i,enabled:!d}),p=d?Zt(e,d):f,m=e=>p.data?(0,Y.jsx)(qt,{value:p.data,children:e}):void 0,h=p.isPending?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(z,{className:`h-4 w-1/2`}),(0,Y.jsx)(z,{className:`h-4 w-1/3`})]}):p.error?(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:p.error}):p.data?m((0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:l})):(0,Y.jsx)(U,{children:s??N(`nothingYet`)});return(0,Y.jsx)(R,{title:a,description:o,actions:c?m(c):void 0,className:O(`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}=B(e),f=H().resources[a];return f?(0,Y.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=Ke(`app/related-cards`),Ba=({children:e})=>{let t=(0,J.useRef)(null),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1);return(0,J.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,Y.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,Y.jsx)(`div`,{className:O(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,Y.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,Y.jsx)(W,{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}=H(),a=on(e,t);if(a.state===`missing`||a.state===`ready`&&Va(a.value))return null;let o=a.state===`loading`?(0,Y.jsx)(z,{className:`h-4 w-24`}):(0,Y.jsx)(Sn,{model:a.model,field:a.field,value:a.value}),s=r?(0,Y.jsx)(Ba,{children:o}):o;if(!n)return(0,Y.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,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,Y.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=Me(),{resources:l}=H(),u=c(e.model,t,e.record,e.key),d=a.length>0||o!==void 0;return(0,Y.jsxs)(`li`,{"data-card":e.key,className:O(`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,Y.jsx)(de,{view:t,field:i,record:e.record}),(0,Y.jsxs)(`div`,{className:O(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,Y.jsx)(me,{to:{kind:`record`,resource:e.model.name,key:vn(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,Y.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,Y.jsx)(Ha,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,Y.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,Y.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,Y.jsx)(Ha,{scope:e,path:t,labelled:!1})},t))}),d&&(0,Y.jsx)(qt,{value:e,children:(0,Y.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,Y.jsx)(sr,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,Y.jsx)(ni,{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=Me(),{resources:c}=H(),l=s(e.model,t,e.record,e.key);return(0,Y.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,Y.jsx)(de,{view:t,field:r,record:e.record}),(0,Y.jsx)(me,{to:{kind:`record`,resource:e.model.name,key:vn(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:l}),n.length>0&&(0,Y.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,Y.jsx)(Ha,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,Y.jsx)(qt,{value:e,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,Y.jsx)(sr,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,Y.jsx)(ni,{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,J.useRef)(null),n=(0,J.useRef)({current:e,previous:e}),r=(0,J.useRef)(void 0),[i,a]=(0,J.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,J.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,Y.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,Y.jsx)(z,{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:p,planned:m})=>{let h=f(),g=cr(),_=t?.names?.plural??ht(e.name),v=r||nt(e,t),y=rt(e,{filter:n,sort:v,pageSize:s,enabled:!m}),b=Dt(e,n,!m),x=m?m.rows:{isPending:y.isPending,error:y.error},S=m?m.rows.rows:y.data?.items,C=m?{data:m.total&&!m.total.isPending&&!m.total.error?tr(m.total):void 0}:b,w=(0,J.useMemo)(()=>(S??[]).map(t=>Ht(e,t)),[e,S]),T=Ya((0,J.useMemo)(()=>w.map(e=>e.key),[w]));return(0,Y.jsxs)(`div`,{ref:T.root,children:[(()=>{if(x.isPending)return(0,Y.jsx)(Xa,{compact:!!d,limit:s});if(x.error)return(0,Y.jsx)(V,{title:za(`couldNotLoad`),error:x.error});if(w.length===0)return(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:l??za(`nothingYet`)});let r=w.map(e=>{let n=(t,n)=>T.acted(e.key,t,n);return d?(0,Y.jsx)(Ua,{scope:e,view:t,fields:i,time:d.time,tone:p,actions:a,button:o,onActed:n},e.key):(0,Y.jsx)(Wa,{scope:e,view:t,fields:i,tone:p,actions:a,button:o,onActed:n},e.key)}),f=C.data===void 0?void 0:Wn(w.length,C.data,!1);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u===void 0?(0,Y.jsx)(`ul`,{className:d?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,Y.jsx)(Gn,{scroll:g,label:_,share:u,children:r}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f}),(0,Y.jsxs)(me,{to:rr(e,t,h,{filter:n,orderBy:v,display:ir(t,h,{preferred:c})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[Qn(`viewAll`),` `,(0,Y.jsx)(`span`,{className:`sr-only`,children:_.toLowerCase()}),(0,Y.jsx)(Nn,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,Y.jsx)(`p`,{role:`status`,className:`sr-only`,children:T.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=B(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}=Zr(i),{resources:_,views:v}=H(),[y,b]=Gt([t,t===void 0?void 0:`${t}#total`]),x=(0,J.useMemo)(()=>y&&{rows:y,total:b},[y,b]),S=_[a];if(!S)return null;let C=v[S.name];return(0,Y.jsx)(`section`,{className:O(`min-w-0`,r),"aria-label":f,children:(0,Y.jsx)(w,{title:f,help:p,actions:n.actions,children:(0,Y.jsx)(Za,{model:S,view:C,filter:o,sort:s,fields:c??$t(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}=H(),o=Ue(i,a,e.name),s=Pn(e.name,t.listOf,!0),c=(t.names?.plural??ht(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,Y.jsx)(V,{title:kn(`couldNotLoadYour`,{plural:c}),error:s.error});if(!s.data)return(0,Y.jsx)(z,{className:`h-24`});let l=Yn(o.model,s.data);return l?(0,Y.jsx)(ur,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:n??kn(`noneYet`,{plural:c})})},to=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=bt(vn(e,i)),{name:o,chips:s,title:c,body:l}=fr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,Y.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,Y.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,Y.jsx)(me,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,Y.jsx)(zn,{chips:s})})}),(0,Y.jsx)(ur,{...l})]})},no=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=H(),a=t.searchesOf,o=r[a.resource],s=Un(e.name,!0),c=(t.names?.plural??ht(e.name)).toLowerCase();return o?s.error?(0,Y.jsx)(V,{title:Bn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:n??Bn(`noneYet`,{plural:c})}):(0,Y.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,Y.jsx)(to,{model:e,view:t,target:o,targetView:i[a.resource],row:n},bt(vn(e,n))))}):(0,Y.jsx)(z,{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}=B(e),{resources:d,views:f}=H(),p=d[r];if(!p)return null;let m=f[p.name];return(0,Y.jsx)(R,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,Y.jsx)(no,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,Y.jsx)(ur,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,Y.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}=H(),c=nn(e.name),l=zt(),u=Se(),d=pn(),f=s[e.name],[p,h]=(0,J.useState)(i),[g,_]=(0,J.useState)(()=>ka(e,t,i?.record)),[v,y]=(0,J.useState)({}),[b,x]=(0,J.useState)(),[S,C]=(0,J.useState)(!1),w=(0,J.useRef)(Promise.resolve()),T=(0,J.useRef)(i),E=ka(e,t,void 0),ee=p?mn(c,`update`)&&p.permissions?.update!==!1:mn(c,`create`),te=t.filter(t=>!io(e.fields[t])),ne=te.some(t=>p?m(e.fields[t],g[t],p.record[t]):g[t]!==E[t]),D=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{...Ht(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await l.create(e.name,Ot(e,o,{...E,...t}));return{...Ht(e,r.record),etag:r.etag}},re=t=>{let r=w.current.then(async()=>{C(!0),x(void 0),await D(t).then(async r=>{T.current=r,h(r),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await d(e.name),u.show({state:`success`,title:N(`saved`,{label:n??N(`settings`)})})},e=>{y(t=>({...t,...fn(e)})),x(e)}),C(!1)});w.current=r},ie=(t,n)=>{_(e=>({...e,[t]:n})),io(e.fields[t])&&re({[t]:n})};return(0,Y.jsx)(R,{title:n,description:r,className:O(`h-full`,a),children:(0,Y.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),ne&&re(Object.fromEntries(te.map(e=>[e,g[e]])))},children:[b!==void 0&&Object.keys(v).length===0&&(0,Y.jsx)(V,{title:N(`notSaved`),error:b}),t.map(t=>{let n=e.fields[t],r=f?.fields[t]?.label??ht(t),i=v[t];return(0,Y.jsx)(je,{name:t,label:r,help:f?.fields[t]?.help,error:i&&bn(n,r,i),children:(0,Y.jsx)(lt,{field:n,hints:f?.fields[t],value:g[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,Y.jsx)(`div`,{children:(0,Y.jsx)(W,{type:`submit`,variant:`primary`,size:`sm`,loading:S,children:N(`save`)})})]})})},oo=e=>{let t=wt(e.model,{});return t.isPending?(0,Y.jsx)(R,{title:e.title,description:e.description,className:e.className,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(z,{className:`h-4 w-1/2`}),(0,Y.jsx)(z,{className:`h-4 w-1/3`})]})}):t.error?(0,Y.jsx)(R,{title:e.title,description:e.description,className:e.className,children:(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:t.error})}):(0,Y.jsx)(ao,{...e,stored:t.data??void 0})},so=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=B(e),o=H().resources[n];return o?(0,Y.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}=H(),r=zt(),i=JSON.stringify(e),a=(0,J.useMemo)(()=>JSON.parse(i).map(ce),[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=Ee(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=>kt(t,e)),f=gt(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=On({queries:u.map(e=>un(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 te(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}=B(e),[a]=lo([i],G());if(a===void 0)return null;let o=a?t:uo(e,n);return o==null?null:r===void 0?(0,Y.jsx)(Y.Fragment,{children:o}):(0,Y.jsx)(`div`,{className:r,children:o})},po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(gn(e,L(t)).props.when)]),mo=({node:e,children:t,slots:n,className:r})=>{let i=G(),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,Y.jsx)(Y.Fragment,{children:s}):(0,Y.jsx)(`div`,{className:r,children:s})},ho=({children:e})=>(0,Y.jsx)(Y.Fragment,{children:e}),go=`text-2xl font-semibold tracking-tight tabular-nums`,_o=({model:e,at:t,filter:n})=>{let{views:r}=H(),a=cn(t),o=Dt(e,n,!a),s=a??o;if(s.isPending)return(0,Y.jsx)(z,{className:`h-8 w-16`});if(s.error)return(0,Y.jsx)(`span`,{className:`text-danger-text`,children:N(`couldNotCount`)});let c=a?tr(a):o.data;return(0,Y.jsx)(me,{to:$n(r[e.name],e.name,n),className:`${go} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:c.toLocaleString(i())})},vo=({field:e,format:t})=>{let n=Lt(e);return n.state===`loading`?(0,Y.jsx)(z,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,Y.jsx)(`span`,{className:go,children:ra(n.value)}):(0,Y.jsx)(`span`,{className:go,children:(0,Y.jsx)(Sn,{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}=B(e),{resources:u}=H(),d=a===void 0?void 0:u[a];return(0,Y.jsxs)(R,{className:O(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,Y.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,Y.jsx)(`span`,{className:go,children:i}),d&&(0,Y.jsx)(_o,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,Y.jsx)(vo,{field:s,format:c})]}),l&&(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},bo=(e,t,n)=>{let r=f(),i=Jn(t),[a,o]=(0,J.useState)(()=>Hn(localStorage,i)),s=(0,J.useCallback)(e=>{o(e),ar(localStorage,i,e)},[i]);return[ir(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}=H(),d=u[e.name],{fields:p}=At(),m=mn(nn(e.name),`update`),{go:h,href:g}=Pe(),_=f(),v=!Cn(),y=(0,J.useMemo)(()=>n?.map(Ft)??$t(e,d),[n,e,d]),b=(0,J.useMemo)(()=>Jt(e,d,y,{resources:l,views:u,fieldTypes:p}),[e,d,y,l,u,p]),x=(0,J.useMemo)(()=>_?en(n)(b):b,[_,n,b]),S=(0,J.useMemo)(()=>r?Zn(x,e,d,r,l,v):x,[x,e,d,r,l,v]),C=(0,J.useMemo)(()=>t.map(t=>({...t,id:ut(e,t)})),[t,e]),w=(0,J.useMemo)(()=>({total:C.length,rowAt:e=>C[e]}),[C]),T=nr({model:e,view:d,opens:void 0,resources:l,views:u,canUpdate:m}),E=e=>({href:g(e),onFollow:()=>h(e)});return(0,Y.jsx)(R,{title:i,description:a,actions:s,className:c,children:C.length===0?(0,Y.jsx)(U,{children:o??N(`nothingYet`)}):(0,Y.jsx)(In,{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=_t();return t?.model?(0,Y.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?y:g,b=(0,J.useMemo)(()=>i?.map(Ft),[i]),x=(0,J.useMemo)(()=>en(i),[i]);return(0,Y.jsxs)(R,{title:l,description:u,actions:(0,Y.jsxs)(Y.Fragment,{children:[!m&&(0,Y.jsx)(or,{view:t,value:v,onChange:_}),f]}),className:O(`h-full`,p),children:[(0,Y.jsx)(er,{model:e,view:t,filter:n,sort:r,columns:b,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:x,...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}=B(e),{resources:u,views:d}=H(),[f,p]=Gt([t,t===void 0?void 0:`${t}#total`]),m=(0,J.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,Y.jsx)(So,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,Y.jsx)(Co,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,Y.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:i}=a(),o=t=>i({[e]:t}),s=r[e],c=s===void 0?null:(0,Y.jsx)(vt,{name:e,children:(0,Y.jsx)(ui,{model:n.model,query:{key:s},children:t},s)});return(0,Y.jsx)(Co,{...n,chosen:{rowTo:o,key:s,details:c}})},Eo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=St(),{navigate:a}=s(),o=Et(e),c=Bt(o,r),l=e=>i(e===o[0]?.name?void 0:e);return(0,Y.jsxs)(`div`,{className:O(`flex flex-col gap-6`,n),children:[(0,Y.jsxs)(`select`,{"aria-label":N(`tabs`),value:c?.name??``,onChange:e=>a(l(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!c&&(0,Y.jsx)(`option`,{value:``,disabled:!0}),o.map(e=>(0,Y.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,Y.jsx)(`nav`,{"aria-label":N(`tabs`),className:`hidden border-b md:block`,children:(0,Y.jsx)(`ul`,{className:`flex gap-1`,children:o.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(et,{to:l(e.name),"aria-current":e===c?`page`:void 0,className:O(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===c?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),c?(0,Y.jsx)(J.Fragment,{children:t[o.indexOf(c)]},c.name):(0,Y.jsx)(ne,{children:N(`noTab`,{name:r??``})})]})},Do=({children:e})=>(0,Y.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=an(e,t?.valueLabels);return n===`done`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(oe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(It,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&dt(t?.valueColors,e)!==`red`?r:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,Y.jsx)(pr,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},jo=({value:e})=>{let t=typeof e==`string`?we(e):e;return t===ee?(0,Y.jsx)(pe,{children:String(e)}):(0,Y.jsx)(se,{value:t})},Mo=({label:e,children:t})=>(0,Y.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),No=({call:e,statusHints:t})=>{let[n,r]=(0,J.useState)(!1),i=(0,J.useId)(),a=e.status!==void 0&&(0,Y.jsx)(Ao,{value:e.status,hints:t,mark:e.state}),o=(0,Y.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,Y.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,Y.jsxs)(W,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,Y.jsx)(ve,{"aria-hidden":!0,className:O(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,Y.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callInput`),children:(0,Y.jsx)(jo,{value:e.input})}),e.result!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callResult`),children:(0,Y.jsx)(jo,{value:e.result})}),e.error!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callError`),children:(0,Y.jsx)(pe,{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:ye(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=>Br.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,J.useState)(!1),s=Te(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,J.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}=H(),i=e?.model.name??``,a=Ho(i,{filter:e?.filter,orderBy:e&&p(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>Bo(t,zo(vn(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:l,planned:d})=>{let{resources:f,views:m}=H(),h=ft(),_=h?.state.kind===`signed-in`?h.state.user.id:void 0,v=n===void 0?[]:[n],y=ue(f,m,e,v),b=Ho(e.name,{filter:t,orderBy:p(r),pageSize:o,labels:y},d?.messages),x=Uo(l,o,d?.calls),S=Wo(b);if(S===`error`)return(0,Y.jsx)(V,{title:Q(`couldNotLoad`),error:b.error,onRetry:qo(b)});if(S===`loading`)return(0,Y.jsx)(`div`,{className:`p-4`,children:(0,Y.jsx)(U,{children:Q(`loadingMessages`)})});let C=Ze(f,e,v,b.items,b.labels),w=ko({items:x.calls,more:x.hasNextPage},{items:Po(C,r),more:b.hasNextPage}),T=Io(w,{key:t=>String(vn(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&&Ie(e.fields[i],m[e.name]?.fields[i]),te=T.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===_);return(0,Y.jsxs)(Y.Fragment,{children:[Ko(b)&&(0,Y.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,Y.jsx)(V,{title:Q(`couldNotLoad`),error:b.error,onRetry:qo(b)})}),l&&x.list.error&&(0,Y.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,Y.jsx)(V,{title:Q(`couldNotLoadCalls`),error:x.list.error,onRetry:qo(x.list)})}),(0,Y.jsx)(u,{length:w.length,followKey:te?.key,working:c,empty:Go(x.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:b.hasNextPage||x.hasNextPage?()=>Jo([b,x.list]):void 0,loadingEarlier:b.isFetchingNextPage||x.isFetchingNextPage,children:T.map(e=>e.kind===`day`?(0,Y.jsx)(_e,{label:e.label},e.key):e.kind===`call`?(0,Y.jsx)(No,{call:e,statusHints:x.statusHints},e.key):(0,Y.jsx)(Mt,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,Y.jsx)(Ao,{value:e.status,hints:E}),children:ee&&e.text!==``?(0,Y.jsx)(g,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},Xo=({children:e})=>(0,Y.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}=B(e),{resources:g}=H(),[_]=lo(f===void 0?[]:[f],G()),[v,y]=Gt([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let x=p&&g[p.resource];return(0,Y.jsx)(`section`,{className:O(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,Y.jsx)(w,{title:i,help:a,actions:n.actions,children:(0,Y.jsx)(Xo,{children:(0,Y.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,Y.jsx)(`div`,{className:t,children:e}),$o=({children:e,className:t})=>(0,Y.jsx)(`div`,{className:O(`flex`,t),children:e}),es=({children:e,className:t})=>(0,Y.jsx)(`div`,{className:O(`flex flex-col`,t),children:e}),ts=({node:e,children:t,className:n})=>{let{as:r=`p`}=B(e);return(0,Y.jsx)(r,{className:n,children:t})},ns=({node:e,children:t})=>{let{source:n}=B(e),r=C(L(G()),n),i=(0,J.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,Y.jsx)(Rt,{value:i,children:t})},rs=({node:e,className:t})=>{let{source:n,choices:r,label:i=n,defaultValue:o}=B(e),{values:s,linkTo:c}=a(),l=s[n];return(0,Y.jsxs)(`div`,{className:O(`flex flex-wrap items-center gap-2`,t),children:[(0,Y.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:i}),r?(0,Y.jsx)(d,{label:i,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,Y.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,J.useState)(!1),c=Te(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,J.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=B(e),i=H().resources[r.reference],a=Le(L(G())),o=cn(t);return i?(0,Y.jsx)(ss,{model:i,...jt(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,Y.jsx)(dn,{read:r,list:i,empty:e,children:t})},cs=({node:e,at:t,children:n})=>{let r=B(e),i=H().resources[r.reference],a=Le(L(G())),o=cn(t);return i?(0,Y.jsx)(ss,{model:i,...l(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}=H(),s=cn(t),c=wt(e,{key:n,enabled:!s}),l=s?Zt(e,s):c;if(l.isPending)return(0,Y.jsx)(z,{className:`h-4 w-24`});if(l.error)return(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:l.error});if(!l.data)return null;let u=i.length>0?(0,Y.jsx)(qt,{value:l.data,children:i}):at(e,o[e.name],l.data.record,n);return r===!1?(0,Y.jsx)(`span`,{className:a,children:u}):(0,Y.jsx)(me,{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}=B(e),c=H().resources[i],l=C(L(G()),a);return c?l==null||l===``?s===void 0?null:(0,Y.jsx)(`span`,{className:r,children:s}):(0,Y.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=>r(e,t)).join(`, `),$=Ke(`users`),fs=({roles:e})=>{let{session:t}=q(),[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)([]),o=(0,J.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,J.useEffect)(o,[o]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(hr,{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,Y.jsx)(_r,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,Y.jsx)(k,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,Y.jsx)(gr,{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}=q(),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)([]),{busy:d,error:f,run:p}=fe(),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,Y.jsxs)(k,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,Y.jsx)(P,{message:f}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Y.jsx)(b,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,Y.jsx)(b,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,Y.jsx)(b,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,Y.jsx)(_r,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(W,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},ms=({user:e,roles:t,self:n})=>{let{session:r}=q(),[i,a]=(0,J.useState)(e),{busy:o,error:s,run:c,setError:l}=fe(),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,Y.jsx)(vr,{name:i.name,email:i.email,self:n,error:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[i.blocked&&(0,Y.jsx)(F,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,Y.jsx)(W,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,Y.jsx)(W,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,Y.jsx)(_r,{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}=q(),[i,a]=(0,J.useState)(``),o=(0,J.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=br(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,Y.jsx)(yr,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,Y.jsx)(ms,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},gs=()=>{let{session:e}=q(),[t,n]=(0,J.useState)([]),[r,i]=(0,J.useState)();return(0,J.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof j?o(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},_s=()=>{let{roles:e,error:t}=gs(),[n,r]=(0,J.useState)(0);return(0,Y.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,Y.jsx)(P,{message:t}),(0,Y.jsx)(hs,{roles:e,version:n}),(0,Y.jsx)(fs,{roles:e}),(0,Y.jsx)(ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},vs=({sender:e,busy:t,error:n,onSave:r,onClose:i})=>{let[a,o]=(0,J.useState)(e?.address??``),[s,c]=(0,J.useState)(e?.name??``),[l,u]=(0,J.useState)(e?.signature??``),[d,f]=(0,J.useState)(e?.isDefault??!1);return(0,Y.jsxs)(I,{title:e?e.address:K(`addFromAddress`),description:K(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:i,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:i,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:t,disabled:!a.trim(),onClick:()=>r({address:a.trim(),name:s.trim(),signature:l,isDefault:d}),children:K(e?`save`:`addAddress`)})]}),children:[!e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`fromAddress`),(0,Y.jsx)(b,{autoFocus:!0,type:`email`,value:a,maxLength:254,placeholder:K(`fromAddressPlaceholder`),onChange:e=>o(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[K(`fromName`),(0,Y.jsx)(b,{value:s,maxLength:100,placeholder:K(`fromNamePlaceholder`),onChange:e=>c(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{children:K(`defaultFromAddress`)}),(0,Y.jsx)(ge,{checked:d,onChange:f,label:K(`defaultFromAddress`)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[K(`signature`),(0,Y.jsx)(Ne,{value:l,maxLength:2e3,placeholder:K(`signaturePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,Y.jsx)(P,{message:n})]})},ys=e=>e.signature?K(`ownSignature`):K(`genericSignature`),bs=({senders:{address:e,senders:t},onAdd:n,onUpdate:r,onRemove:i})=>{let[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(),f=(0,J.useRef)(!1),p=t.find(e=>e.isDefault),m=()=>{d(void 0),l(void 0)},h=async e=>{if(!f.current){f.current=!0,s(!0),l(void 0);try{await e(),d(void 0)}catch(e){if(e instanceof TypeError)return l(K(`noAnswerFromServer`));if(!(e instanceof j))throw e;l(o(e))}finally{f.current=!1,s(!1)}}},g=e=>h(async()=>{let t=e.name||null,i=e.signature.trim()?e.signature:null;if(u?.kind===`change`)return r(u.sender.id,{name:t,signature:i,isDefault:e.isDefault});let a=await n({address:e.address,...t&&{name:t},...i&&{signature:i}});e.isDefault&&await r(a.id,{isDefault:!0})});return(0,Y.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold`,children:K(`fromAddresses`)}),(0,Y.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:K(`fromAddressesDescription`)}),(0,Y.jsx)(P,{message:u?void 0:c}),(e||t.length>0)&&(0,Y.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Tr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:K(`mailboxOwnAddress`)})]}),p?(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,loading:a,onClick:()=>void h(()=>r(p.id,{isDefault:!1})),children:K(`makeDefault`)}):(0,Y.jsx)(F,{tone:`blue`,children:K(`default`)})]}),t.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Tr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,Y.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:ys(e)})]}),e.isDefault&&(0,Y.jsx)(F,{tone:`blue`,children:K(`default`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>d({kind:`change`,sender:e}),children:K(`edit`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>d({kind:`remove`,sender:e}),children:K(`remove`)})]},e.id))]}),(0,Y.jsxs)(W,{onClick:()=>d({kind:`add`}),children:[(0,Y.jsx)(xn,{className:`size-3.5`}),K(`addFromAddress`)]}),u?.kind===`add`&&(0,Y.jsx)(vs,{busy:a,error:c,onSave:e=>void g(e),onClose:m}),u?.kind===`change`&&(0,Y.jsx)(vs,{sender:u.sender,busy:a,error:c,onSave:e=>void g(e),onClose:m},u.sender.id),u?.kind===`remove`&&(0,Y.jsx)(I,{title:K(`removeFromAddress`,{address:u.sender.address}),description:K(`removeFromAddressDescription`),onClose:m,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:m,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:a,onClick:()=>void h(()=>i(u.sender.id)),children:K(`remove`)})]}),children:(0,Y.jsx)(P,{message:c})})]})},xs=(e,t,n)=>Object.fromEntries(Fn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,Xn(`signInOnly`,{provider:n(e.provider),name:e.name})])),Ss=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=q(),{account:i}=t,[a]=(0,J.useState)(Ge),o=(0,J.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}=D(o,K(`couldNotReadMethods`));return s?(0,Y.jsx)(Qt,{title:K(`mailbox`),description:K(`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??yn(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&yt(a,e.length===1?e[0].name:K(`theProvider`)),children:(0,Y.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,Y.jsx)(A,{error:c})},Cs=()=>{let{personalMail:e}=q();return e.length>0?(0,Y.jsx)(Ss,{links:e}):null},ws=e=>xr(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,J.useState)(!1),[i,a]=(0,J.useState)(),[s,c]=(0,J.useState)(),l=async e=>{r(!0),a(void 0);try{await t(e.clientId),c(void 0)}catch(e){if(!(e instanceof j))throw e;a(o(e))}r(!1)};return(0,Y.jsxs)(k,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,Y.jsx)(P,{message:s?void 0:i}),e.length===0?(0,Y.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,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=Sr(e.clientId);return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Dr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:ws(e)}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,le(Date.parse(e.allowedAt)),` · `,Ts(e)]})]}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>c(e),children:`Disconnect`})]},e.clientId)})}),s&&(0,Y.jsx)(I,{title:`Disconnect ${ws(s)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>c(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>c(void 0),children:`Cancel`}),(0,Y.jsx)(W,{variant:`danger`,loading:n,onClick:()=>void l(s),children:`Disconnect`})]}),children:i&&(0,Y.jsx)(P,{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,Y.jsx)(k,{title:K(`mcpAddress`),description:K(`mcpAddressDescription`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(Cr,{value:e,copyLabel:K(`copyMcpAddress`)}),(0,Y.jsxs)(`a`,{href:Ds(e,t),target:`_blank`,rel:`noreferrer`,className:mt(),children:[(0,Y.jsx)(x,{className:`size-3.5`}),K(`addToClaude`)]})]})}),ks=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.connectedApps(),[e]),K(`couldNotReadMethods`));return t?(0,Y.jsx)(Es,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,Y.jsx)(A,{error:n})},As=({url:e})=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Os,{url:e,appName:H().appName}),(0,Y.jsx)(ks,{})]}),js=()=>{let{mcp:e}=q();return e?(0,Y.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=>le(Date.parse(e)),Fs=e=>e?K(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:Ps(e)}):K(`neverExpires`),Is=e=>[K(`createdOn`,{date:Ps(e.createdAt)}),Fs(e.expiresAt),e.lastUsedAt?K(`lastUsedOn`,{date:Ps(e.lastUsedAt)}):K(`notUsedYet`),e.organization?K(`actsAsIn`,{role:e.role,organization:e.organization}):K(`actsAs`,{role:e.role})].join(` · `),Ls=({tokens:e,onCreate:t,onRevoke:n})=>{let[r,i]=(0,J.useState)(!1),[a,s]=(0,J.useState)(),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(`90`),[m,h]=(0,J.useState)(),g=()=>{l(void 0),s(void 0),h(void 0)},_=(0,J.useRef)(!1),v=async e=>{if(!_.current){_.current=!0,i(!0),s(void 0);try{l(await e()),h(void 0)}catch(e){if(e instanceof TypeError)return s(K(`noAnswerFromServer`));if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):s(o(e))}finally{_.current=!1,i(!1)}}},y=()=>v(async()=>{let e=Ms[f];return{kind:`created`,created:await t({name:u.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,Y.jsxs)(k,{title:K(`accessTokens`),description:K(`accessTokensDescription`),children:[(0,Y.jsx)(P,{message:c?void 0:a}),e.length===0?(0,Y.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:K(`noAccessTokens`)}):(0,Y.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(kr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Is(e)})]}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>l({kind:`revoke`,token:e}),children:K(`revoke`)})]},e.id))}),(0,Y.jsxs)(W,{onClick:()=>{d(``),p(`90`),l({kind:`create`})},children:[(0,Y.jsx)(xn,{className:`size-3.5`}),K(`newAccessToken`)]}),c?.kind===`create`&&(0,Y.jsxs)(I,{title:K(`newAccessToken`),description:K(`newAccessTokenDescription`),onClose:g,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:g,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:r,disabled:!u.trim(),onClick:()=>void y(),children:K(`createAccessToken`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`name`),(0,Y.jsx)(b,{autoFocus:!0,value:u,maxLength:100,placeholder:K(`accessTokenNamePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[K(`accessTokenExpiry`),(0,Y.jsx)(He,{value:f,onChange:e=>p(e.target.value),children:Object.keys(Ms).map(e=>(0,Y.jsx)(`option`,{value:e,children:K(Ns[e])},e))})]}),m===`asked`&&(0,Y.jsx)(ot,{purpose:`change`,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,Y.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:K(`confirmedCreateAccessToken`)}),(0,Y.jsx)(P,{message:a})]}),c?.kind===`created`&&(0,Y.jsx)(I,{title:K(`accessTokenCreated`,{name:c.created.personalAccessToken.name}),description:K(`accessTokenCreatedDescription`),onClose:g,actions:(0,Y.jsx)(W,{variant:`primary`,onClick:g,children:K(`done`)}),children:(0,Y.jsx)(Cr,{value:c.created.token,copyLabel:K(`copyAccessToken`)})}),c?.kind===`revoke`&&(0,Y.jsx)(I,{title:K(`revokeAccessToken`,{name:c.token.name}),description:K(`revokeAccessTokenDescription`),onClose:g,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:g,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:r,onClick:()=>void v(async()=>(await n(c.token.id),void 0)),children:K(`revoke`)})]}),children:(0,Y.jsx)(P,{message:a})})]})},Rs=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.personalAccessTokens(),[e]),K(`couldNotReadAccessTokens`));return t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(P,{message:n}),(0,Y.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,Y.jsx)(A,{error:n})},zs=()=>q().personalAccessTokens?(0,Y.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,J.useState)(),[s,c]=(0,J.useState)(r),[l,u]=(0,J.useState)(),[d,f]=(0,J.useState)(),p=async(e,t)=>{a(e),c(void 0),f(void 0);try{await t(),u(void 0)}catch(e){if(!(e instanceof j))throw e;c(o(e))}finally{a(void 0)}};return(0,Y.jsxs)(k,{title:K(`connections`),description:K(`connectionsDescription`),children:[(0,Y.jsx)(P,{message:l?void 0:s}),(0,Y.jsx)(qe,{message:d}),(0,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(Nr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,Y.jsx)(W,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void p(e.key,()=>t(e)),children:e.accounts.length>0?K(`connectAgain`,{name:e.label}):K(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[K(`connectedOn`,{date:le(Date.parse(t.created_at))}),` · `,(0,Y.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,Y.jsx)(F,{tone:`amber`,children:K(`connectionNeedsSignIn`)}):(0,Y.jsx)(F,{tone:`green`,children:K(`connected`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>u({connection:e,accountId:t.id}),children:K(`disconnect`)})]}),t.used_by.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:K(`connectionUsedBy`)}),t.used_by.map(e=>(0,Y.jsx)(re,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),l&&(0,Y.jsx)(I,{title:K(`disconnectTitle`,{name:l.connection.label}),description:Vs(l.connection)?`${K(`disconnectDescription`)} ${K(`disconnectWholeGrant`)}`:K(`disconnectDescription`),onClose:()=>u(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>u(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:i===l.accountId,onClick:()=>void p(l.accountId,async()=>f(K(Bs[await n(l.accountId)]))),children:K(`disconnect`)})]}),children:s&&(0,Y.jsx)(P,{message:s})})]})},Us=()=>{let{session:e,connectAccount:t}=q(),{account:n}=e,[r]=(0,J.useState)(Ge),{data:i,error:a,reload:o}=D((0,J.useCallback)(()=>n.workflowConnections(),[n]),K(`couldNotReadMethods`));return i?i.length===0?null:(0,Y.jsx)(Hs,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&yt(r,K(`theProvider`))}):(0,Y.jsx)(A,{error:a})},Ws=e=>e.code===`LAST_ADMIN`?K(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?K(`deleteAccountLocked`):o(e),Gs=({hasPassword:e,onDelete:t,onClose:n})=>{let[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(),[l,u]=(0,J.useState)(!1),d=(0,J.useId)(),f=async()=>{o(!0),c(void 0),u(!1);try{await t(e?r:void 0)}catch(e){if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?u(!0):c(Ws(e)),o(!1)}};return(0,Y.jsxs)(I,{title:K(`deleteAccountQuestion`),description:K(`deleteAccountWarning`),onClose:n,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:n,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,type:`submit`,form:d,loading:a,disabled:e&&!r,children:K(`deleteAccountConfirm`)})]}),children:[(0,Y.jsxs)(`form`,{id:d,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),f()},children:[e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`deleteAccountPassword`),(0,Y.jsx)(b,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,invalid:!!s,onChange:e=>i(e.target.value)})]}),(0,Y.jsx)(P,{message:s})]}),l&&(0,Y.jsx)(ot,{purpose:`change`,minutes:15,onConfirmed:()=>void f()})]})},Ks=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,J.useState)(!1);return(0,Y.jsxs)(k,{title:K(`deleteAccount`),description:K(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,Y.jsx)(W,{variant:`danger`,onClick:()=>i(!0),children:K(`deleteAccount`)}),r&&(0,Y.jsx)(Gs,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},qs=()=>{let{session:e,state:t,deleteAccount:n}=q(),{account:r}=e,{data:i,error:a}=D((0,J.useCallback)(()=>r.signInMethods(),[r]),K(`couldNotReadMethods`));return i?(0,Y.jsx)(Ks,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,Y.jsx)(A,{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?K(`deviceThrough`,{device:e.device,provider:e.name}):e.name,$s=(e,t)=>{if(e.staff)return t?K(`staffOf`,{operator:t}):K(`staff`);let{browser:n,system:r}=Zs(e.userAgent);return n&&r?K(`browserOn`,{browser:n,system:r}):r?K(`aBrowserOn`,{system:r}):n??K(`unknownDevice`)},ec=e=>{if(e.staff)return Fr;let{system:t}=Zs(e.userAgent);return t===`iPhone`||t===`Android`?Lr:t===`iPad`?zr:jr},tc=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),nc=(e,t)=>e.kind===`one`?K(`signOutDevice`,{name:$s(e.session,t)}):e.kind===`link`?K(`signOutDevice`,{name:Qs(e.link)}):K(`signOutOthersTitle`),rc=e=>K(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),ic=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(),[d,f]=(0,J.useState)(),p=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),m=e.filter(e=>!e.current),h=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),g=async e=>{c(!0),u(void 0);try{await h(e),f(void 0)}catch(e){if(!(e instanceof j))throw e;u(o(e))}c(!1)},_=e=>{u(void 0),f(e)};return(0,Y.jsxs)(k,{title:K(`devices`),description:K(`devicesDescription`),children:[p.length===0&&n.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:K(`noDevices`)}):(0,Y.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[tc(p).map(e=>{let n=ec(e);return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`bdi`,{className:`truncate font-medium`,children:$s(e,t)}),e.current&&(0,Y.jsx)(F,{tone:`green`,children:K(`thisDevice`)})]}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[K(`signedInFromUntil`,{from:Xe(Date.parse(e.createdAt)),until:Xe(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`one`,session:e}),children:K(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Lr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`bdi`,{className:`truncate font-medium`,children:Qs(t)}),n&&(0,Y.jsx)(F,{tone:`green`,children:K(`thisDevice`)})]}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:K(`linkedOn`,{date:Xe(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`link`,link:t}),children:K(`signOut`)})]},t.id)})]}),m.length>0&&(0,Y.jsx)(W,{className:`mt-3`,onClick:()=>_({kind:`others`}),children:K(`signOutOthers`)}),d&&(0,Y.jsx)(I,{title:nc(d,t),description:rc(d),onClose:()=>f(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>f(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:s,onClick:()=>void g(d),children:K(`signOut`)})]}),children:(0,Y.jsx)(P,{message:l})})]})},ac=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=q(),{account:r}=e,i=(0,J.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}=D(i,K(`couldNotReadDevices`));return a?(0,Y.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,Y.jsx)(A,{error:o})},oc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},sc=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(),[f,p]=(0,J.useState)(``),[m,g]=(0,J.useState)(),_=e===`required`&&t.length<=1,v=async e=>{s(!0),l(void 0),g(void 0);try{await e(),d(void 0)}catch(e){if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?g(`asked`):l(o(e))}s(!1)};return(0,Y.jsxs)(k,{title:K(`passkeys`),status:e===`required`&&(0,Y.jsx)(F,{tone:`blue`,children:K(`required`)}),description:K(oc[e]),children:[(0,Y.jsx)(P,{message:u?void 0:c}),t.length>0&&(0,Y.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(h,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??K(`passkey`)}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?K(`addedOn`,{date:le(Date.parse(e.createdAt))}):K(`addedEarlier`),` · `,e.backedUp?K(`synced`):K(`oneDevice`)]})]}),(0,Y.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>{p(e.name??``),d({kind:`rename`,passkey:e})},children:K(`rename`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:_,title:_?K(`keepLastPasskey`):void 0,onClick:()=>d({kind:`remove`,passkey:e}),children:K(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,Y.jsxs)(W,{loading:a&&!u,onClick:()=>void v(n),children:[(0,Y.jsx)(xn,{className:`size-3.5`}),K(`addPasskey`)]}),m===`asked`&&(0,Y.jsx)(ot,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>g(`done`)}),m===`done`&&(0,Y.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:K(`confirmedAddPasskey`)}),u?.kind===`rename`&&(0,Y.jsxs)(I,{title:K(`renamePasskey`),description:K(`renamePasskeyDescription`),onClose:()=>d(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>d(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:a,disabled:!f.trim(),onClick:()=>void v(()=>r(u.passkey.id,f.trim())),children:K(`save`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`name`),(0,Y.jsx)(b,{autoFocus:!0,value:f,maxLength:60,onChange:e=>p(e.target.value)})]}),(0,Y.jsx)(P,{message:c})]}),u?.kind===`remove`&&(0,Y.jsx)(I,{title:K(`removePasskey`),description:K(`removePasskeyDescription`,{name:u.passkey.name??K(`thisPasskey`)}),onClose:()=>d(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>d(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:a,onClick:()=>void v(()=>i(u.passkey.id)),children:K(`remove`)})]}),children:c&&(0,Y.jsx)(P,{message:c})})]})},cc=()=>{let{account:e}=q().session,t=(0,J.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=D(t,K(`couldNotReadMethods`));if(!n)return(0,Y.jsx)(A,{error:r});let[a,o]=n;return(0,Y.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`?K(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?K(`passwordTooLong`):o(e),uc=(e,t)=>{if(e.length<12)return K(`useAtLeast`,{length:12});if(e!==t)return K(`passwordsDiffer`)},dc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(),p=(0,J.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 j))throw e;f(lc(e)),u(!1)}}};return(0,Y.jsx)(I,{title:K(e?`changePassword`:`setPassword`),description:K(`atLeast`,{length:12}),onClose:n,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:n,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,type:`submit`,form:p,loading:l,disabled:!m,children:K(`save`)})]}),children:(0,Y.jsxs)(`form`,{id:p,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`currentPassword`),(0,Y.jsx)(b,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`newPassword`),(0,Y.jsx)(b,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!d,onChange:e=>o(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`repeatPassword`),(0,Y.jsx)(b,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:s,invalid:!!d,onChange:e=>c(e.target.value)})]}),e&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:K(`changeSignsOutOthers`)}),(0,Y.jsx)(P,{message:d})]})})},fc=({rule:e,hasPassword:t,staff:n})=>K(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),pc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:i})=>{let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=!n&&e===`allowed`;return(0,Y.jsxs)(k,{title:K(`password`),description:fc({rule:e,hasPassword:t,staff:n}),children:[(0,Y.jsx)(qe,{message:s?K(`passwordSaved`):void 0}),l&&(0,Y.jsx)(W,{onClick:()=>{c(!1),o(!0)},children:K(t?`changePassword`:`setPassword`)}),a&&(0,Y.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}=q(),{account:n}=e,{data:r,error:i,reload:a}=D((0,J.useCallback)(()=>n.signInMethods(),[n]),K(`couldNotReadMethods`));return r?(0,Y.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,Y.jsx)(A,{error:i})},hc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,J.useState)(``),[s,c]=(0,J.useState)(),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(),h=async e=>{f(!0),m(void 0);try{await e()}catch(e){if(!(e instanceof j))throw e;m(o(e))}f(!1)},g=i.trim(),_=()=>h(async()=>{await t.request(g),u(``),c(g)}),v=e=>h(async()=>{await t.confirm(s,e),n()});return s?(0,Y.jsxs)(I,{title:K(`changeEmail`),description:K(`codeSentTo`,{email:s,minutes:10}),onClose:r,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{variant:`ghost`,onClick:()=>{c(void 0),m(void 0)},children:K(`otherAddress`)}),(0,Y.jsx)(W,{variant:`primary`,loading:d,disabled:l.length<6,onClick:()=>void v(l),children:K(`changeEmail`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`code`),(0,Y.jsx)(xt,{name:`code`,required:!0,autoFocus:!0,value:l,invalid:!!p,onChange:u,onComplete:e=>!d&&void v(e)})]}),(0,Y.jsx)(P,{message:p})]}):(0,Y.jsxs)(I,{title:K(`changeEmail`),description:K(`changeEmailDescription`),onClose:r,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:r,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:d,disabled:!g||g.toLowerCase()===e.toLowerCase(),onClick:()=>void _(),children:K(`sendCode`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`newEmail`),(0,Y.jsx)(b,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,Y.jsx)(P,{message:p})]})},gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(),g=async()=>{p(!0),h(void 0);try{await n(u.trim()),s(!1)}catch(e){if(!(e instanceof j))throw e;h(o(e))}p(!1)};return(0,Y.jsxs)(k,{title:K(`profile`),description:K(`profileDescription`),children:[(0,Y.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:K(`name`)}),(0,Y.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:K(`email`)}),(0,Y.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(W,{onClick:()=>{d(e),h(void 0),s(!0)},children:K(`changeName`)}),r&&(0,Y.jsx)(W,{onClick:()=>l(!0),children:K(`changeEmail`)})]}),a&&(0,Y.jsxs)(I,{title:K(`changeName`),description:K(`changeNameDescription`),onClose:()=>s(!1),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>s(!1),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:f,disabled:!u.trim()||u.trim()===e,onClick:()=>void g(),children:K(`save`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`name`),(0,Y.jsx)(b,{autoFocus:!0,value:u,maxLength:100,onChange:e=>d(e.target.value)})]}),(0,Y.jsx)(P,{message:m})]}),c&&r&&(0,Y.jsx)(hc,{email:t,change:r,onClose:()=>l(!1),onDone:()=>{l(!1),i?.()}})]})},_c=()=>{let{session:e,changeEmail:t}=q(),{data:n,loaded:r,error:i,reload:a}=D((0,J.useCallback)(()=>e.session(),[e]),K(`couldNotReadProfile`));if(!r)return(0,Y.jsx)(A,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,Y.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:r,needsPassword:i,onConfirm:a,onClose:s})=>{let[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(),[m,h]=(0,J.useState)(!1),g=async()=>{d(!0),p(void 0),h(!1);try{await a(i?c:void 0)}catch(e){if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(!0):p(o(e)),d(!1)}};return(0,Y.jsxs)(I,{title:e,description:t,onClose:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:s,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:r?`danger`:`primary`,loading:u,disabled:i&&!c,onClick:()=>void g(),children:n})]}),children:[i&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`yourPassword`),(0,Y.jsx)(b,{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,Y.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:f}),m&&(0,Y.jsx)(ot,{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,J.useState)(),d=()=>u(void 0),f=n?(0,Y.jsx)(F,{tone:`green`,children:K(`on`)}):t===`required`?(0,Y.jsx)(F,{tone:`amber`,children:K(`required`)}):(0,Y.jsx)(F,{children:K(`off`)}),p=K(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:yc[t]);return l?.kind===`setup`?(0,Y.jsx)(k,{title:K(`twoFactor`),status:f,description:p,children:(0,Y.jsx)(`div`,{className:`max-w-sm`,children:(0,Y.jsx)(Kt,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,Y.jsxs)(k,{title:K(`twoFactor`),status:f,description:p,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,Y.jsx)(W,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:K(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,Y.jsx)(W,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:K(`addAuthenticator`)}),n&&r&&(0,Y.jsx)(W,{onClick:()=>u({kind:`new-codes`}),children:K(`newBackupCodes`)}),n&&(0,Y.jsx)(W,{variant:`danger`,disabled:t===`required`,title:t===`required`?K(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:K(`turnOff`)})]}),l?.kind===`turn-off`&&(0,Y.jsx)(vc,{title:K(`turnOffTitle`),description:K(`turnOffDescription`),confirmLabel:K(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,Y.jsx)(vc,{title:K(`newCodesTitle`),description:K(`newCodesDescription`),confirmLabel:K(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,Y.jsx)(I,{title:K(`yourNewCodes`),description:K(`keepCodesSafe`),onClose:d,actions:(0,Y.jsx)(W,{variant:`primary`,onClick:d,children:K(`savedCodes`)}),children:(0,Y.jsx)(tn,{codes:l.codes})})]})},xc=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.signInMethods(),[e]),K(`couldNotReadMethods`));return t?(0,Y.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,Y.jsx)(A,{error:n})},Sc=({problem:e,fallback:t})=>t===void 0?(0,Y.jsx)(ne,{children:e}):(0,Y.jsxs)(Y.Fragment,{children:[!1,t]}),Cc=({name:e,registered:t,fallback:n,children:r})=>t?(0,Y.jsx)(Re,{name:e,fallback:n===void 0?void 0:(0,Y.jsx)(Sc,{problem:N.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,Y.jsx)(Sc,{problem:N.rich(`noComponent`,{component:e}),fallback:n}),wc={Page:Pa,Grid:ua,Card:ii,Stat:yo,RecordCard:Ra,Field:aa,Diff:na,Table:wo,CardRow:ci,RecordRow:ro,RecordCards:$a,Chart:li,Timeline:qi,Graph:Zi,Progress:Ia,Image:va,ModalForm:Na,Thread:Zo,Composer:$i,Action:ri,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:Be,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:oi,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:xe(t,...n,r)}})),Dc=({text:e})=>{let t=G(),n=Oe(),r={...L(t),params:n};return(0,Y.jsx)(Y.Fragment,{children:E(e,e=>ie(C(r,e)))})},Oc=(e,t)=>e.includes(`{{`)?(0,Y.jsx)(Dc,{text:e},t):(0,Y.jsx)(J.Fragment,{children:e},t),kc=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?Oc(e,n):(0,Y.jsx)(Ic,{node:e,at:t},n)),Ac=e=>{let t=[];for(let n of e){let e=t.at(-1);Ur(n.child)&&e&&Ur(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Ur(n.child)?(0,Y.jsx)(`p`,{className:`leading-6`,children:kc(e)},t):(0,Y.jsx)(Ic,{node:n.child,at:n.at},t)})},jc=e=>Ve(e)||Array.isArray(e)&&e.length>0&&e.every(Ve),Mc=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>jc(n)?[[e,(0,Y.jsx)(Y.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:xe(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])=>Ve(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=_(t,String(e.props.i18nKey),Pc(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||Ve(e)?e:String(e)):[i]},Ic=({node:e,at:t})=>{let{components:n}=At(),r=G(),i=Oe(),a=st(),o=(0,J.useMemo)(()=>Xt(gn(e,{...L(r),params:i}),a),[e,r,i,a]);if(o.type===`Trans`&&!o.custom)return(0,Y.jsx)(Y.Fragment,{children:kc(Fc(o,a).map(e=>({child:e})))});if(o.custom){let e=n?.[o.type],r=o.children.length>0?(0,Y.jsx)(Ji,{node:o,children:Ac(Ec(o.children,t,`children`))}):void 0;return(0,Y.jsx)(Cc,{name:o.type,registered:!!e,fallback:o.fallback&&(0,Y.jsx)(Y.Fragment,{children:Ac(Ec(o.fallback,t,`fallback`))}),children:e&&(0,Y.jsx)(Je,{node:o,...t!==void 0&&{at:t},children:(0,Y.jsx)(e,{...be(o.props),children:r})})})}let s=wc[o.type];if(!s)return(0,Y.jsx)(ne,{children:N.rich(`unknownBlock`,{type:o.type})});let c=typeof o.props.className==`string`?o.props.className:void 0,l=Ec(o.children,t,`children`),u=(0,Y.jsx)(s,{node:o,at:t,slots:Mc(o,t),className:c,children:o.type===`Text`||o.type===`Link`||o.type===`Summary`?kc(l):Ac(o.type===`Switch`?l.filter(({child:e})=>typeof e!=`string`):l)}),d=c===void 0||Tc.has(o.type)?u:(0,Y.jsx)(`div`,{className:c,children:u});return o.fallback?(0,Y.jsx)(Re,{name:o.type,resetKey:o,fallback:(0,Y.jsx)(Y.Fragment,{children:Ac(Ec(o.fallback,t,`fallback`))}),children:d}):d};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=34fcf6fc-8b1c-44df-a08f-4f408681b094