@protobase/ui 0.121.11 → 0.121.12

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 (302) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/app/app.js +3 -2
  3. package/dist/app/change-confirm/messages.d.ts +2 -2
  4. package/dist/app/charts/messages.d.ts +2 -2
  5. package/dist/app/confirm-sign-in-messages.d.ts +2 -2
  6. package/dist/app/conversation/message-composer.d.ts +5 -1
  7. package/dist/app/conversation/message-composer.js +10 -3
  8. package/dist/app/conversation-page/conversation-header.js +1 -1
  9. package/dist/app/conversation-page/conversation-message.js +1 -1
  10. package/dist/app/conversation-page/conversation-messages.js +1 -1
  11. package/dist/app/conversation-page/conversation-page.d.ts +5 -4
  12. package/dist/app/conversation-page/conversation-page.js +22 -6
  13. package/dist/app/conversation-page/message-editor.js +1 -1
  14. package/dist/app/conversation-page/message-ops.d.ts +3 -1
  15. package/dist/app/conversation-page/message-ops.js +7 -1
  16. package/dist/app/conversation-page/messages.d.ts +2 -2
  17. package/dist/app/conversation-page/reply-labels.js +1 -1
  18. package/dist/app/conversation-page/thread-panel.js +1 -1
  19. package/dist/app/conversation-page/use-message-writes.js +1 -1
  20. package/dist/app/create/messages.d.ts +2 -2
  21. package/dist/app/custom-section.d.ts +1 -1
  22. package/dist/app/delete/messages.d.ts +2 -2
  23. package/dist/app/displays/list-cards.d.ts +1 -1
  24. package/dist/app/displays/messages.d.ts +2 -2
  25. package/dist/app/export/messages.d.ts +2 -2
  26. package/dist/app/field-types/widget-part.d.ts +1 -1
  27. package/dist/app/field-types/workflow/definition.d.ts +1 -1
  28. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  29. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  30. package/dist/app/file-viewers/messages.d.ts +2 -2
  31. package/dist/app/focus/messages.d.ts +2 -2
  32. package/dist/app/hand-order/messages.d.ts +2 -2
  33. package/dist/app/history/messages.d.ts +2 -2
  34. package/dist/app/import/messages.d.ts +2 -2
  35. package/dist/app/list-messages.d.ts +2 -2
  36. package/dist/app/messages.d.ts +2 -2
  37. package/dist/app/meta-gate-messages.d.ts +2 -2
  38. package/dist/app/new-version/messages.d.ts +2 -2
  39. package/dist/app/pages/custom-boundary.d.ts +1 -1
  40. package/dist/app/pages/custom-chosen.d.ts +1 -1
  41. package/dist/app/pages/messages.d.ts +2 -2
  42. package/dist/app/record-messages.d.ts +2 -2
  43. package/dist/app/record-row/messages.d.ts +2 -2
  44. package/dist/app/related-cards/messages.d.ts +2 -2
  45. package/dist/app/saved/messages.d.ts +2 -2
  46. package/dist/app/saved/saved-list.d.ts +1 -1
  47. package/dist/app/saved/use-favorite.d.ts +1 -1
  48. package/dist/app/searches/messages.d.ts +2 -2
  49. package/dist/app/searches/use-save-search.d.ts +1 -1
  50. package/dist/app/use-nav-recent.d.ts +2 -2
  51. package/dist/app/use-nav-recent.js +5 -4
  52. package/dist/app-shell/messages.d.ts +2 -2
  53. package/dist/app-shell/nav.d.ts +5 -3
  54. package/dist/app-shell/record-marks.d.ts +1 -1
  55. package/dist/app-shell/record-marks.js +5 -3
  56. package/dist/app-shell/sidebar-records.d.ts +1 -1
  57. package/dist/app-shell/sidebar-records.js +6 -1
  58. package/dist/assistant-dock/messages.d.ts +2 -2
  59. package/dist/auth/messages.d.ts +2 -2
  60. package/dist/calls/messages.d.ts +2 -2
  61. package/dist/chat/composer.d.ts +3 -1
  62. package/dist/chat/composer.js +6 -2
  63. package/dist/chat/messages.d.ts +2 -2
  64. package/dist/compact-table/messages.d.ts +2 -2
  65. package/dist/data/api-provider.d.ts +33 -0
  66. package/dist/data/meta-data.d.ts +4 -0
  67. package/dist/data/use-live-updates.d.ts +5 -2
  68. package/dist/data/use-live-updates.js +25 -3
  69. package/dist/data/use-meta.js +1 -0
  70. package/dist/data-grid/messages.d.ts +2 -2
  71. package/dist/filter-panel/messages.d.ts +2 -2
  72. package/dist/index.d.ts +5 -1
  73. package/dist/index.js +5 -1
  74. package/dist/invitations/messages.d.ts +2 -2
  75. package/dist/locale/en.js +7 -2
  76. package/dist/locale/en.json.d.ts +5 -0
  77. package/dist/locale/messages.d.ts +10 -0
  78. package/dist/locale/nl.js +7 -2
  79. package/dist/locale/texts-gate.d.ts +1 -1
  80. package/dist/notifications/bell/messages.d.ts +2 -2
  81. package/dist/organizations/messages.d.ts +2 -2
  82. package/dist/package.js +1 -1
  83. package/dist/plugins/before-sign-in.d.ts +1 -1
  84. package/dist/plugins/plugin-api.exports.js +5 -1
  85. package/dist/primitives/messages.d.ts +2 -2
  86. package/dist/record-view/messages.d.ts +2 -2
  87. package/dist/relay/count-unread.d.ts +12 -0
  88. package/dist/relay/count-unread.js +34 -0
  89. package/dist/relay/relay-context.d.ts +17 -0
  90. package/dist/relay/relay-context.js +23 -0
  91. package/dist/relay/relay-provider.d.ts +11 -0
  92. package/dist/relay/relay-provider.js +58 -0
  93. package/dist/relay/relay-store.d.ts +31 -0
  94. package/dist/relay/relay-store.js +77 -0
  95. package/dist/relay/typing-line.d.ts +11 -0
  96. package/dist/relay/typing-line.js +30 -0
  97. package/dist/relay/typing.d.ts +37 -0
  98. package/dist/relay/typing.js +78 -0
  99. package/dist/relay/unread.d.ts +30 -0
  100. package/dist/relay/unread.js +35 -0
  101. package/dist/relay/use-relay-marks.d.ts +11 -0
  102. package/dist/relay/use-relay-marks.js +53 -0
  103. package/dist/relay/use-typing-sender.d.ts +11 -0
  104. package/dist/relay/use-typing-sender.js +32 -0
  105. package/dist/relay/use-unread-counts.d.ts +9 -0
  106. package/dist/relay/use-unread-counts.js +61 -0
  107. package/dist/relay/use-view-channel.d.ts +7 -0
  108. package/dist/relay/use-view-channel.js +21 -0
  109. package/dist/shell/assets/{account-page-Cz2-SP3Z.js → account-page-BsAc4o17.js} +2 -2
  110. package/dist/shell/assets/app-Bb88M0VJ.js +36 -0
  111. package/dist/shell/assets/{assistant-shell-CeW3U4tB.js → assistant-shell-CdVAnpMe.js} +2 -2
  112. package/dist/shell/assets/board-display-DKT7398I.js +2 -0
  113. package/dist/shell/assets/calendar-display-0c2dGTmG.js +2 -0
  114. package/dist/shell/assets/{call-rings-DwSrOHCr.js → call-rings-BV5na0xp.js} +2 -2
  115. package/dist/shell/assets/{calls-D1l4an28.js → calls-n9IoOXzL.js} +2 -2
  116. package/dist/shell/assets/{circle-alert-BEHXqTnA.js → circle-alert-kISSXwIV.js} +2 -2
  117. package/dist/shell/assets/{composed-page-CzszGryH.js → composed-page-hn7I0Ulk.js} +2 -2
  118. package/dist/shell/assets/{composer-section-v7aZuaJs.js → composer-section-Cb1kOpwt.js} +2 -2
  119. package/dist/shell/assets/{connect-route-B68buTBD.js → connect-route-l21XyxhS.js} +2 -2
  120. package/dist/shell/assets/{copy-field-CpG80Fod.js → copy-field-D22CFeg3.js} +2 -2
  121. package/dist/shell/assets/create-route-CSe9DhbY.js +2 -0
  122. package/dist/shell/assets/{custom-step-container-field-CooxBIkH.js → custom-step-container-field-C5l4j0FI.js} +4 -4
  123. package/dist/shell/assets/embedded-list-DjvOszEj.js +3 -0
  124. package/dist/shell/assets/en-DnsB2haa.js +2 -0
  125. package/dist/shell/assets/{export-dialog-CYGeeQBj.js → export-dialog-Bh3TSYyL.js} +2 -2
  126. package/dist/shell/assets/export-worker-DbK8hf_0.js +15 -0
  127. package/dist/shell/assets/{first-organization-page-B_TzRjNV.js → first-organization-page-BtfoRENE.js} +2 -2
  128. package/dist/shell/assets/{graph-view-DJGoThHW.js → graph-view-C4fwqz7Q.js} +2 -2
  129. package/dist/shell/assets/{group-donut-CtKQKKqq.js → group-donut-Bcnc0EaM.js} +2 -2
  130. package/dist/shell/assets/{guest-call-page-C2N1bb85.js → guest-call-page-D09z7u-V.js} +3 -3
  131. package/dist/shell/assets/{html-viewer-DHWsvJdf.js → html-viewer-BtwOBvDg.js} +2 -2
  132. package/dist/shell/assets/{import-dialog-BAmU6oMk.js → import-dialog-Dwx_yEfS.js} +2 -2
  133. package/dist/shell/assets/{import-table-dialog-C1TyvD2-.js → import-table-dialog-T3V3RoDY.js} +2 -2
  134. package/dist/shell/assets/{index-fJt7aRZ4.js → index-DvNpfiwE.js} +1 -1
  135. package/dist/shell/assets/invitations-page-X90SMPsK.js +2 -0
  136. package/dist/shell/assets/{layout-grid-CPhU6Mm7.js → layout-grid-Bp_eP5eU.js} +2 -2
  137. package/dist/shell/assets/{legend-item-DYmqDhq7.js → legend-item-CEZ-8FXv.js} +2 -2
  138. package/dist/shell/assets/list-page-BUtWO_Zd.js +4 -0
  139. package/dist/shell/assets/{maplibre-DXJkokbV.js → maplibre-Cv3xuTP_.js} +2 -2
  140. package/dist/shell/assets/{markdown-content-9-JeVEDq.js → markdown-content-jO-R6jpp.js} +2 -2
  141. package/dist/shell/assets/members-page-BZyldmfB.js +2 -0
  142. package/dist/shell/assets/{message-content-XnNocBEs.js → message-content-DJEa6jyY.js} +2 -2
  143. package/dist/shell/assets/messages-BIP4feL2.js +2 -0
  144. package/dist/shell/assets/nl-Ce2dHlet.js +2 -0
  145. package/dist/shell/assets/organization-page-CjQ7oJk4.js +2 -0
  146. package/dist/shell/assets/organizations-page-2cKqhNJh.js +2 -0
  147. package/dist/shell/assets/parse-worker-MvbeuzYJ.js +35 -0
  148. package/dist/shell/assets/{pending-invitation-row-C2tovkDY.js → pending-invitation-row-Cef2WdTI.js} +2 -2
  149. package/dist/shell/assets/{period-chart-DuLmYnEh.js → period-chart-BPq3Knz8.js} +2 -2
  150. package/dist/shell/assets/{person-row-B4SoiUz7.js → person-row-BLVor9QR.js} +2 -2
  151. package/dist/shell/assets/public-form-page-CMaHcrdf.js +2 -0
  152. package/dist/shell/assets/record-lines-jznjVtIQ.js +2 -0
  153. package/dist/shell/assets/{record-map-CUyHGUuT.js → record-map-9KEjeN_F.js} +2 -2
  154. package/dist/shell/assets/{record-opens-DtAuS5Iw.js → record-opens-CQLXpqJS.js} +2 -2
  155. package/dist/shell/assets/record-page-JFlxtSyg.js +3 -0
  156. package/dist/shell/assets/{record-preview-CF37imVo.js → record-preview-CUs7j-lh.js} +2 -2
  157. package/dist/shell/assets/{records-map-CLUkYUGA.js → records-map-CLF98-H0.js} +2 -2
  158. package/dist/shell/assets/render-node-DoB1k2WS.js +3 -0
  159. package/dist/shell/assets/reorder-button-Cg-WKutS.js +2 -0
  160. package/dist/shell/assets/{run-trace-view-B02ogfCg.js → run-trace-view-CmujelWd.js} +2 -2
  161. package/dist/shell/assets/{runner-install-field-B7d2ZTdV.js → runner-install-field-wpoIgnks.js} +2 -2
  162. package/dist/shell/assets/{runtime-update-LXdNfKZi.js → runtime-update-BaNRaM6l.js} +2 -2
  163. package/dist/shell/assets/shared-protobase-ui-630Rm7Jd.js +1 -0
  164. package/dist/shell/assets/sheet-source-7m5PMllh.js +3 -0
  165. package/dist/shell/assets/sign-in-policy-page-GgyC3l_6.js +2 -0
  166. package/dist/shell/assets/start-block-queries-B8K1ZsVK.js +2 -0
  167. package/dist/shell/assets/step-catalog-Dktva0VF.js +2 -0
  168. package/dist/shell/assets/{step-panel-C6qUOSA3.js → step-panel-CjUWMleA.js} +2 -2
  169. package/dist/shell/assets/timeline-display-CCPZ8VKv.js +2 -0
  170. package/dist/shell/assets/{trash-BiidFj0N.js → trash-BfIEK322.js} +2 -2
  171. package/dist/shell/assets/{update-set-B0qCO072.js → update-set-Drag3hOc.js} +2 -2
  172. package/dist/shell/assets/use-calendar-move-fM4kqYZF.js +2 -0
  173. package/dist/shell/assets/{use-display-rows-BpKLVhjZ.js → use-display-rows-CEB1AStC.js} +2 -2
  174. package/dist/shell/assets/use-my-invitations-DxoZihem.js +2 -0
  175. package/dist/shell/assets/{use-paged-search-BUf2evnc.js → use-paged-search-tHTP8FRX.js} +2 -2
  176. package/dist/shell/assets/{use-run-trace-D3CBWHfm.js → use-run-trace-b8SpFDRU.js} +2 -2
  177. package/dist/shell/assets/{use-workflow-page-DjHS4PFJ.js → use-workflow-page-oeKIRs_g.js} +2 -2
  178. package/dist/shell/assets/{use-workflow-types-D0XJQUAl.js → use-workflow-types-D1TLbN3E.js} +2 -2
  179. package/dist/shell/assets/{workflow-canvas-D1yNhbc_.js → workflow-canvas-CJQ0Ll0M.js} +4 -4
  180. package/dist/shell/assets/{workflow-field-BJb4Ns2G.js → workflow-field-CpGs8ZXh.js} +3 -3
  181. package/dist/shell/assets/{workflow-graph-editor-DzpB5Wg4.js → workflow-graph-editor-CLlL2jNQ.js} +2 -2
  182. package/dist/shell/assets/{workflow-run-field-BrkKGYZ3.js → workflow-run-field-R43RqM3Z.js} +3 -3
  183. package/dist/shell/assets/workflow-status-field-BaytFzWg.js +2 -0
  184. package/dist/shell/assets/workflow-workbench-DYClQZZ1.js +4 -0
  185. package/dist/shell/index.html +3 -3
  186. package/dist/shell/protobase.shell.json +2 -2
  187. package/dist/shell/protobase.sw.js +2 -2
  188. package/dist/shell-source-maps/assets/{account-page-Cz2-SP3Z.js.map → account-page-BsAc4o17.js.map} +1 -1
  189. package/dist/shell-source-maps/assets/app-Bb88M0VJ.js.map +1 -0
  190. package/dist/shell-source-maps/assets/{assistant-shell-CeW3U4tB.js.map → assistant-shell-CdVAnpMe.js.map} +1 -1
  191. package/dist/shell-source-maps/assets/{board-display-tgOCC0v0.js.map → board-display-DKT7398I.js.map} +1 -1
  192. package/dist/shell-source-maps/assets/{calendar-display-DRWz8QYh.js.map → calendar-display-0c2dGTmG.js.map} +1 -1
  193. package/dist/shell-source-maps/assets/{call-rings-DwSrOHCr.js.map → call-rings-BV5na0xp.js.map} +1 -1
  194. package/dist/shell-source-maps/assets/{calls-D1l4an28.js.map → calls-n9IoOXzL.js.map} +1 -1
  195. package/dist/shell-source-maps/assets/{circle-alert-BEHXqTnA.js.map → circle-alert-kISSXwIV.js.map} +1 -1
  196. package/dist/shell-source-maps/assets/{composed-page-CzszGryH.js.map → composed-page-hn7I0Ulk.js.map} +1 -1
  197. package/dist/shell-source-maps/assets/{composer-section-v7aZuaJs.js.map → composer-section-Cb1kOpwt.js.map} +1 -1
  198. package/dist/shell-source-maps/assets/{connect-route-B68buTBD.js.map → connect-route-l21XyxhS.js.map} +1 -1
  199. package/dist/shell-source-maps/assets/{copy-field-CpG80Fod.js.map → copy-field-D22CFeg3.js.map} +1 -1
  200. package/dist/shell-source-maps/assets/{create-route-BMWFJF8g.js.map → create-route-CSe9DhbY.js.map} +1 -1
  201. package/dist/shell-source-maps/assets/{custom-step-container-field-CooxBIkH.js.map → custom-step-container-field-C5l4j0FI.js.map} +1 -1
  202. package/dist/shell-source-maps/assets/{embedded-list-nfw7Gvsq.js.map → embedded-list-DjvOszEj.js.map} +1 -1
  203. package/dist/shell-source-maps/assets/en-DnsB2haa.js.map +1 -0
  204. package/dist/shell-source-maps/assets/{export-dialog-CYGeeQBj.js.map → export-dialog-Bh3TSYyL.js.map} +1 -1
  205. package/dist/shell-source-maps/assets/export-worker-DbK8hf_0.js.map +1 -0
  206. package/dist/shell-source-maps/assets/{first-organization-page-B_TzRjNV.js.map → first-organization-page-BtfoRENE.js.map} +1 -1
  207. package/dist/shell-source-maps/assets/{graph-view-DJGoThHW.js.map → graph-view-C4fwqz7Q.js.map} +1 -1
  208. package/dist/shell-source-maps/assets/{group-donut-CtKQKKqq.js.map → group-donut-Bcnc0EaM.js.map} +1 -1
  209. package/dist/shell-source-maps/assets/{guest-call-page-C2N1bb85.js.map → guest-call-page-D09z7u-V.js.map} +1 -1
  210. package/dist/shell-source-maps/assets/{html-viewer-DHWsvJdf.js.map → html-viewer-BtwOBvDg.js.map} +1 -1
  211. package/dist/shell-source-maps/assets/{import-dialog-BAmU6oMk.js.map → import-dialog-Dwx_yEfS.js.map} +1 -1
  212. package/dist/shell-source-maps/assets/{import-table-dialog-C1TyvD2-.js.map → import-table-dialog-T3V3RoDY.js.map} +1 -1
  213. package/dist/shell-source-maps/assets/{invitations-page-D_Z4B5Uu.js.map → invitations-page-X90SMPsK.js.map} +1 -1
  214. package/dist/shell-source-maps/assets/{layout-grid-CPhU6Mm7.js.map → layout-grid-Bp_eP5eU.js.map} +1 -1
  215. package/dist/shell-source-maps/assets/{legend-item-DYmqDhq7.js.map → legend-item-CEZ-8FXv.js.map} +1 -1
  216. package/dist/shell-source-maps/assets/{list-page-Cl4AAwTy.js.map → list-page-BUtWO_Zd.js.map} +1 -1
  217. package/dist/shell-source-maps/assets/{maplibre-DXJkokbV.js.map → maplibre-Cv3xuTP_.js.map} +1 -1
  218. package/dist/shell-source-maps/assets/{markdown-content-9-JeVEDq.js.map → markdown-content-jO-R6jpp.js.map} +1 -1
  219. package/dist/shell-source-maps/assets/{members-page-BIYD2hUu.js.map → members-page-BZyldmfB.js.map} +1 -1
  220. package/dist/shell-source-maps/assets/{message-content-XnNocBEs.js.map → message-content-DJEa6jyY.js.map} +1 -1
  221. package/dist/shell-source-maps/assets/{messages-DhhNH_o2.js.map → messages-BIP4feL2.js.map} +1 -1
  222. package/dist/shell-source-maps/assets/nl-Ce2dHlet.js.map +1 -0
  223. package/dist/shell-source-maps/assets/{organization-page-C7rfPxxc.js.map → organization-page-CjQ7oJk4.js.map} +1 -1
  224. package/dist/shell-source-maps/assets/{organizations-page-B5wqljdT.js.map → organizations-page-2cKqhNJh.js.map} +1 -1
  225. package/dist/shell-source-maps/assets/parse-worker-MvbeuzYJ.js.map +1 -0
  226. package/dist/shell-source-maps/assets/{pending-invitation-row-C2tovkDY.js.map → pending-invitation-row-Cef2WdTI.js.map} +1 -1
  227. package/dist/shell-source-maps/assets/{period-chart-DuLmYnEh.js.map → period-chart-BPq3Knz8.js.map} +1 -1
  228. package/dist/shell-source-maps/assets/{person-row-B4SoiUz7.js.map → person-row-BLVor9QR.js.map} +1 -1
  229. package/dist/shell-source-maps/assets/{public-form-page-BRHFIOvT.js.map → public-form-page-CMaHcrdf.js.map} +1 -1
  230. package/dist/shell-source-maps/assets/{record-lines-Bt1Un_65.js.map → record-lines-jznjVtIQ.js.map} +1 -1
  231. package/dist/shell-source-maps/assets/{record-map-CUyHGUuT.js.map → record-map-9KEjeN_F.js.map} +1 -1
  232. package/dist/shell-source-maps/assets/{record-opens-DtAuS5Iw.js.map → record-opens-CQLXpqJS.js.map} +1 -1
  233. package/dist/shell-source-maps/assets/record-page-JFlxtSyg.js.map +1 -0
  234. package/dist/shell-source-maps/assets/{record-preview-CF37imVo.js.map → record-preview-CUs7j-lh.js.map} +1 -1
  235. package/dist/shell-source-maps/assets/{records-map-CLUkYUGA.js.map → records-map-CLF98-H0.js.map} +1 -1
  236. package/dist/shell-source-maps/assets/render-node-DoB1k2WS.js.map +1 -0
  237. package/dist/shell-source-maps/assets/{reorder-button-BozBSEHe.js.map → reorder-button-Cg-WKutS.js.map} +1 -1
  238. package/dist/shell-source-maps/assets/{run-trace-view-B02ogfCg.js.map → run-trace-view-CmujelWd.js.map} +1 -1
  239. package/dist/shell-source-maps/assets/{runner-install-field-B7d2ZTdV.js.map → runner-install-field-wpoIgnks.js.map} +1 -1
  240. package/dist/shell-source-maps/assets/{runtime-update-LXdNfKZi.js.map → runtime-update-BaNRaM6l.js.map} +1 -1
  241. package/dist/shell-source-maps/assets/{sheet-source-G8rOez-U.js.map → sheet-source-7m5PMllh.js.map} +1 -1
  242. package/dist/shell-source-maps/assets/{sign-in-policy-page-DOTM6MOA.js.map → sign-in-policy-page-GgyC3l_6.js.map} +1 -1
  243. package/dist/shell-source-maps/assets/{start-block-queries-Dfg8kMRu.js.map → start-block-queries-B8K1ZsVK.js.map} +1 -1
  244. package/dist/shell-source-maps/assets/{step-catalog-CoBzB5jS.js.map → step-catalog-Dktva0VF.js.map} +1 -1
  245. package/dist/shell-source-maps/assets/{step-panel-C6qUOSA3.js.map → step-panel-CjUWMleA.js.map} +1 -1
  246. package/dist/shell-source-maps/assets/{timeline-display-5BAMjA9V.js.map → timeline-display-CCPZ8VKv.js.map} +1 -1
  247. package/dist/shell-source-maps/assets/{trash-BiidFj0N.js.map → trash-BfIEK322.js.map} +1 -1
  248. package/dist/shell-source-maps/assets/{update-set-B0qCO072.js.map → update-set-Drag3hOc.js.map} +1 -1
  249. package/dist/shell-source-maps/assets/{use-calendar-move-BGAc9T_n.js.map → use-calendar-move-fM4kqYZF.js.map} +1 -1
  250. package/dist/shell-source-maps/assets/{use-display-rows-BpKLVhjZ.js.map → use-display-rows-CEB1AStC.js.map} +1 -1
  251. package/dist/shell-source-maps/assets/{use-my-invitations-BQKKClDc.js.map → use-my-invitations-DxoZihem.js.map} +1 -1
  252. package/dist/shell-source-maps/assets/{use-paged-search-BUf2evnc.js.map → use-paged-search-tHTP8FRX.js.map} +1 -1
  253. package/dist/shell-source-maps/assets/{use-run-trace-D3CBWHfm.js.map → use-run-trace-b8SpFDRU.js.map} +1 -1
  254. package/dist/shell-source-maps/assets/{use-workflow-page-DjHS4PFJ.js.map → use-workflow-page-oeKIRs_g.js.map} +1 -1
  255. package/dist/shell-source-maps/assets/{use-workflow-types-D0XJQUAl.js.map → use-workflow-types-D1TLbN3E.js.map} +1 -1
  256. package/dist/shell-source-maps/assets/{workflow-canvas-D1yNhbc_.js.map → workflow-canvas-CJQ0Ll0M.js.map} +1 -1
  257. package/dist/shell-source-maps/assets/{workflow-field-BJb4Ns2G.js.map → workflow-field-CpGs8ZXh.js.map} +1 -1
  258. package/dist/shell-source-maps/assets/{workflow-graph-editor-DzpB5Wg4.js.map → workflow-graph-editor-CLlL2jNQ.js.map} +1 -1
  259. package/dist/shell-source-maps/assets/{workflow-run-field-BrkKGYZ3.js.map → workflow-run-field-R43RqM3Z.js.map} +1 -1
  260. package/dist/shell-source-maps/assets/workflow-status-field-BaytFzWg.js.map +1 -0
  261. package/dist/shell-source-maps/assets/{workflow-workbench-C-DxYJbt.js.map → workflow-workbench-DYClQZZ1.js.map} +1 -1
  262. package/dist/status/messages.d.ts +2 -2
  263. package/dist/users/messages.d.ts +2 -2
  264. package/package.json +5 -5
  265. package/dist/shell/assets/app-B3ocPAqs.js +0 -34
  266. package/dist/shell/assets/board-display-tgOCC0v0.js +0 -2
  267. package/dist/shell/assets/calendar-display-DRWz8QYh.js +0 -2
  268. package/dist/shell/assets/create-route-BMWFJF8g.js +0 -2
  269. package/dist/shell/assets/embedded-list-nfw7Gvsq.js +0 -3
  270. package/dist/shell/assets/en-0TxR0Vfb.js +0 -2
  271. package/dist/shell/assets/export-worker-AFqbgGzG.js +0 -15
  272. package/dist/shell/assets/invitations-page-D_Z4B5Uu.js +0 -2
  273. package/dist/shell/assets/list-page-Cl4AAwTy.js +0 -4
  274. package/dist/shell/assets/members-page-BIYD2hUu.js +0 -2
  275. package/dist/shell/assets/messages-DhhNH_o2.js +0 -2
  276. package/dist/shell/assets/nl-mDiTKi5y.js +0 -2
  277. package/dist/shell/assets/organization-page-C7rfPxxc.js +0 -2
  278. package/dist/shell/assets/organizations-page-B5wqljdT.js +0 -2
  279. package/dist/shell/assets/parse-worker-C5wWzRYH.js +0 -35
  280. package/dist/shell/assets/public-form-page-BRHFIOvT.js +0 -2
  281. package/dist/shell/assets/record-lines-Bt1Un_65.js +0 -2
  282. package/dist/shell/assets/record-page-DfvcIO5T.js +0 -3
  283. package/dist/shell/assets/render-node-CK68QvoX.js +0 -3
  284. package/dist/shell/assets/reorder-button-BozBSEHe.js +0 -2
  285. package/dist/shell/assets/shared-protobase-ui-B7gMFgle.js +0 -1
  286. package/dist/shell/assets/sheet-source-G8rOez-U.js +0 -3
  287. package/dist/shell/assets/sign-in-policy-page-DOTM6MOA.js +0 -2
  288. package/dist/shell/assets/start-block-queries-Dfg8kMRu.js +0 -2
  289. package/dist/shell/assets/step-catalog-CoBzB5jS.js +0 -2
  290. package/dist/shell/assets/timeline-display-5BAMjA9V.js +0 -2
  291. package/dist/shell/assets/use-calendar-move-BGAc9T_n.js +0 -2
  292. package/dist/shell/assets/use-my-invitations-BQKKClDc.js +0 -2
  293. package/dist/shell/assets/workflow-status-field-dbB3IT68.js +0 -2
  294. package/dist/shell/assets/workflow-workbench-C-DxYJbt.js +0 -4
  295. package/dist/shell-source-maps/assets/app-B3ocPAqs.js.map +0 -1
  296. package/dist/shell-source-maps/assets/en-0TxR0Vfb.js.map +0 -1
  297. package/dist/shell-source-maps/assets/export-worker-AFqbgGzG.js.map +0 -1
  298. package/dist/shell-source-maps/assets/nl-mDiTKi5y.js.map +0 -1
  299. package/dist/shell-source-maps/assets/parse-worker-C5wWzRYH.js.map +0 -1
  300. package/dist/shell-source-maps/assets/record-page-DfvcIO5T.js.map +0 -1
  301. package/dist/shell-source-maps/assets/render-node-CK68QvoX.js.map +0 -1
  302. package/dist/shell-source-maps/assets/workflow-status-field-dbB3IT68.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-C4fwqz7Q.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-Bb88M0VJ.js","assets/vendor-t7Q7QbPu.js","assets/app-lQJl2mz_.css","assets/lib-xyflow-system-hojcPWkY.js","assets/lib-d3-interpolate-C7dFwq8w.js","assets/lib-d3-color-B6XHLQii.js","assets/lib-d3-selection-C1a5EtaJ.js","assets/lib-d3-drag-CUJR_Vab.js","assets/lib-d3-dispatch-Bjkn7q4t.js","assets/lib-d3-zoom-DuEhbOrX.js","assets/lib-d3-transition-CUMO2iZu.js","assets/lib-d3-timer-CduGpaSm.js","assets/lib-d3-ease-ouQSXgQM.js","assets/lib-xyflow-react-CuNAzocq.js","assets/lib-classcat-otpLnDWv.js","assets/lib-zustand-r6mNROKr.js","assets/lib-use-sync-external-store-D4s7MiFL.js","assets/lib-xyflow-react-DLioOiRN.css","assets/use-elk-u1Ql5AOs.js","assets/lib-elkjs-ylMkguT9.js"])))=>i.map(i=>d[i]);
2
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$s as r,A as i,Aa as a,Cc as o,Cl as s,Cn as c,Cr as l,Dc as u,Dl as d,Dn as f,Ec as p,En as m,Fa as h,Fn as g,Fs as _,Ft as v,Ga as y,Gc as b,Gn as x,Hc as S,Hi as C,Hs as w,I as T,Ii as E,Is as ee,It as te,Ja as ne,Js as re,Kn as ie,Kr as D,Ks as ae,Lc as oe,Ls as se,Ml as ce,Mn as le,Mt as ue,N as de,Nn as fe,Nt as pe,O as me,Oa as he,Ol as ge,On as _e,Oo as ve,Pa as ye,Pl as be,Ps as O,Pt as xe,Qc as Se,Qn as Ce,Qs as we,Ra as Te,Ri as Ee,Rs as k,Sa as De,Sc as A,Sn as Oe,Sr as j,Ss as ke,Tc as M,Ti as Ae,Tl as je,Tn as Me,Ts as Ne,Un as Pe,Uo as N,Ur as Fe,Us as Ie,V as Le,Wn as Re,Ws as ze,Xl as Be,Xr as Ve,Xt as P,Ya as He,Yl as Ue,Ys as We,Zi as Ge,Zt as Ke,_c as qe,_r as F,_t as Je,a as Ye,ac as Xe,an as Ze,ao as Qe,as as $e,at as et,b as tt,bc as nt,bn as rt,br as it,c as at,ca as ot,cn as st,co as ct,cr as lt,cs as I,da as ut,dr as dt,ds as L,ec as ft,en as pt,fn as mt,fs as ht,ga as gt,gc as _t,gl as vt,gn as yt,gr as R,gs as bt,gt as xt,ha as St,hc as Ct,hl as wt,hn as Tt,ho as Et,hr as Dt,hs as z,ic as Ot,ir as kt,ja as At,ji as jt,ka as Mt,kc as Nt,ki as Pt,la as Ft,ln as It,ls as Lt,mn as Rt,ms as zt,nc as Bt,nn as Vt,ns as Ht,nu as Ut,oc as Wt,ol as B,oo as V,os as Gt,pc as Kt,pn as qt,pr as Jt,ps as H,qn as Yt,qr as Xt,qs as Zt,rc as Qt,rr as $t,ru as en,sc as tn,sl as U,sn as nn,so as rn,sr as an,ss as W,tc as on,tl as sn,ts as cn,u as ln,un as G,ur as un,us as K,uu as dn,v as fn,vc as pn,vi as mn,vo as hn,vr as gn,vs as q,w as _n,wn as vn,wt as yn,x as bn,xn,xo as Sn,xr as J,xs as Cn,y as wn,yl as Tn,yn as En,yo as Dn,yr as On,ys as kn,z as An,zc as jn,zs as Mn}from"./app-Bb88M0VJ.js";import{C as Nn,f as Pn,o as Fn,s as In}from"./vendor-t7Q7QbPu.js";import{C as Ln,Ct as Rn,Dt as zn,Et as Bn,O as Vn,Ot as Hn,Q as Un,St as Wn,Tt as Gn,X as Kn,Z as qn,_t as Jn,at as Yn,b as Xn,ct as Zn,dt as Qn,ft as $n,gt as er,it as tr,jt as nr,k as rr,l as ir,lt as ar,mt as or,n as sr,nt as cr,o as lr,ot as ur,rt as dr,st as fr,t as pr,tt as mr,ut as hr,wt as gr,x as _r,xt as vr,y as yr}from"./embedded-list-DjvOszEj.js";import{t as br}from"./circle-alert-kISSXwIV.js";import{t as xr}from"./page-header-Ddz2r5ic.js";import{n as Sr,t as Cr}from"./pending-invitation-row-Cef2WdTI.js";import{n as wr,t as Tr}from"./person-row-BLVor9QR.js";import{n as Er,t as Dr}from"./use-paged-search-tHTP8FRX.js";import{n as Or,t as kr}from"./client-publisher-D39SlIhp.js";import{t as Ar}from"./copy-field-D22CFeg3.js";var jr={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};jr.node;var Mr=B(jr),Nr={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};Nr.node;var Pr=B(Nr),Fr={name:`key-square`,size:24,node:[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]};Fr.node;var Ir=B(Fr),Lr={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};Lr.node;var Rr=B(Lr),zr={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};zr.node;var Br=B(zr),Vr={name:`shield-user`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]};Vr.node;var Hr=B(Vr),Ur={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Ur.node;var Wr=B(Ur),Gr={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};Gr.node;var Kr=B(Gr),qr=[`done`,`error`,`running`];Wt(`TextField`,!1),Wt(`NumberField`,!1),Wt(`DateField`,!1),Wt(`BooleanField`,!1),Wt(`UrlField`,!1),Wt(`ChipField`,!1);var Jr=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Yr=e=>typeof e!=`string`&&!e.custom&&Jr.has(e.type),Xr=e=>typeof e==`string`||Yr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Zr=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Qr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),$r=(e,{locales:t,options:n},r)=>{let i=typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))?Number(e):e;return typeof i==`number`?i.toLocaleString(t??r,n):String(i)},ei=(e,t,n)=>{let r=e instanceof Date?e:typeof e==`string`||typeof e==`number`?new Date(e):void 0;if(!r||Number.isNaN(r.getTime()))return``;if(t.format===`relative`)return n.relative(Math.round((n.now-r.getTime())/1e3));let{showDate:i=!0,showTime:a=!1,options:o}=t,s=t.locales??n.locale;if(i&&a)return r.toLocaleString(s,o);if(a)return r.toLocaleTimeString(s,o);let c=o??(typeof e==`string`&&e.length<=10?{timeZone:`UTC`}:void 0);return r.toLocaleDateString(s,c)},ti=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,ni=new Set([`http:`,`https:`,`mailto:`,`tel:`]),ri=e=>{let t=e.replace(/^[\u0000- ]+/,``).replace(/[\t\n\r]/g,``),n=/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(t)?.[1];return n===void 0?t.startsWith(`/`)||!t.includes(`:`)?e:void 0:ni.has(`${n.toLowerCase()}:`)?e:void 0},ii=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),ai=e=>e==null||e===``?void 0:String(e),oi=(e,t)=>e<t?-1:+(e>t),si=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=ai(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=ai(r);s!==void 0&&!o.has(s)&&o.set(s,{id:s,value:r}),a.set(e,{id:e,row:t,...s!==void 0&&{group:s}})}let s=t.flatMap(e=>{let t=r.map(t=>ai(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=ai(e[i.source]),s=ai(e[i.target]);return n===void 0||o===void 0||s===void 0||!a.has(o)||!a.has(s)?[]:[{id:n,source:o,target:s,row:e}]});return{groups:[...o.values()].sort((e,t)=>oi(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>oi(e.id,t.id)),edges:s.sort((e,t)=>oi(e.source,t.source)||oi(e.target,t.target)||oi(e.id,t.id))}},Y=e(t(),1),X=e(n(),1),ci=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=q(),s=Rn(e.name,void 0),c=Ge(),[l,u]=(0,Y.useState)(!1),d=o[e.name]?.actions?.find(e=>e.name===n);if(!d||d.run?.kind===`link`)return null;let f=t.map(t=>rt(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let m=f.length-p.length,h=vr(`actionCount`,{label:r??d.label,count:p.length}),g=e=>s.runEach(d,p,m,e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>Bn(d)?u(!0):void g(),children:h}),l&&(0,X.jsx)(Gn,{action:d,label:h,danger:i===`danger`||i===void 0&&zn(d),records:p.map(e=>e.record),names:p.map(t=>Wn(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),g()},onSubmit:async e=>{u(!1),await g(e)}})]})},li=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=Dt(),c=gr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,Y.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{size:`sm`,variant:f,className:i,loading:c.running,disabled:!!c.blocked,title:c.blocked,"aria-label":a===void 0?void 0:`${d}: ${a}`,onClick:()=>Bn(c.action)?u(!0):void c.run(),children:d}),l&&(0,X.jsx)(Gn,{action:c.action,label:d,danger:f===`danger`,records:c.record?[c.record]:[],onCancel:()=>u(!1),onConfirm:()=>{u(!1),c.run()},onSubmit:async e=>{await c.submit(e),u(!1)}})]})},ui=({node:e,className:t})=>{let n=G(e),r=it(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,X.jsx)(ci,{...n,model:i,items:r.items,className:t}):(0,X.jsx)(li,{...n,className:t})},di=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=G(e);return(0,X.jsx)(J,{title:i,description:a,actions:n.actions,className:U(`h-full`,r),children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},fi=({children:e,wrap:t=(e,t)=>(0,X.jsx)(Y.Fragment,{children:e},t)})=>{let n=it();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...rt(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,X.jsx)(dt,{value:s,row:{index:o,count:i.length},children:e}),c)})},pi=({children:e})=>(0,X.jsx)(fi,{children:e}),mi=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:u,children:d,className:f})=>{let p=nn(t),m=c(e,{filter:n,sort:r,pageSize:i,enabled:!p}),h=p??m,g=p?p.rows:m.data?.items??[];return(0,X.jsx)(J,{title:a,description:o,actions:u,className:f,children:h.isPending?(0,X.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(A,{className:`h-24 w-56`},t))}):h.error?(0,X.jsx)(l,{title:V(`couldNotLoad`),error:h.error}):g.length===0?(0,X.jsx)(j,{children:s??V(`nothingYet`)}):(0,X.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,X.jsx)(gn,{value:{model:e,items:g,...p&&{planned:!0}},children:(0,X.jsx)(fi,{wrap:(e,t)=>(0,X.jsx)(`li`,{className:`flex w-60 shrink-0 snap-start flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:e},t),children:d})})})})},hi=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=G(e),o=q().resources[i];return o?(0,X.jsx)(mi,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},gi=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=G(e),{resources:u,views:d}=q(),f=u[r];return f?(0,X.jsx)(J,{title:i,description:a,actions:t.actions,className:U(`h-full`,n),children:(0,X.jsx)($n,{model:f,view:d[r],...l})}):null},_i=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=Oe(e,t),a=i.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(A,{className:`h-4 w-1/2`}),(0,X.jsx)(A,{className:`h-4 w-1/3`})]}):i.error?(0,X.jsx)(l,{title:V(`couldNotLoad`),error:i.error}):i.data?(0,X.jsx)(dt,{value:i.data,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,X.jsx)(j,{children:V(`nothingYet`)});return(0,X.jsx)(`div`,{className:n,children:a})},vi=e=>{if(typeof e!=`string`&&typeof e!=`number`)return;let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?void 0:t},yi=e=>e==null?``:String(e),bi=(e,t,n)=>n===0?0:(e-t)/n*100,xi=(e,t,n)=>{let r=new Map;for(let i of e){let e=vi(i[t.start]);if(e===void 0)continue;let a=vi(i[t.end]),o=Math.max(e,a??n),s=r.get(yi(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(yi(i[t.lane]),s);let c=s.bars.get(yi(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(yi(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},Si=e=>{let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start)){let e=t.find(e=>e.at(-1).end<=n.start);e?e.push(n):t.push([n])}return t},Ci=(e,t,n)=>{let r=xi(e,t,n),i=[...r.values()].flatMap(e=>[...e.bars.values()].flatMap(e=>e.records));if(i.length===0)return{lanes:[],from:n,to:n};let a=Math.min(...i.map(e=>e.start)),o=Math.max(...i.map(e=>e.end)),s=o-a;return{lanes:[...r.entries()].map(([e,n])=>{let r=[...n.bars.entries()].map(([e,r])=>{let i=r.records.sort((e,t)=>e.start-t.start).map(({record:e,start:n,end:r,open:i})=>({record:e,value:e[t.color],start:n,end:r,open:i,left:bi(n,a,s),width:bi(r,a,s)-bi(n,a,s)})),o=i[0].start,c=Math.max(...i.map(e=>e.end));return{key:e,value:r.value,lane:n.value,start:o,end:c,left:bi(o,a,s),width:bi(c,a,s)-bi(o,a,s),segments:i}});return{key:e,value:n.value,rows:Si(r)}}),from:a,to:o}},wi=(e,t)=>{let n=e.end-e.start;return{left:bi(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},Ti=6e4,Ei=60*Ti,Z=24*Ei,Di=[5*Ti,15*Ti,30*Ti,Ei,3*Ei,6*Ei,12*Ei,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],Oi=365*Z,ki=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Ai=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=Di.find(n=>ki(e,t,n,i,a)<=6)??Math.ceil(r/5/Oi)*Oi,s=[];for(let c=Math.ceil((e+i)/o)*o;c<=t+a;c+=o){let a=c-n(c-i);a+n(a)===c&&a>=e&&a<=t&&s.push({at:a,left:bi(a,e,r)})}return{daily:o>=Z,ticks:s}},ji=e=>({lane:yi(e.lane),bar:e.key}),Mi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ni=(e,t)=>{let n=Object.fromEntries(new Intl.DateTimeFormat(`en-US`,{timeZone:t,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}).formatToParts(e).map(e=>[e.type,e.value]));return Date.UTC(Number(n.year),Number(n.month)-1,Number(n.day),Number(n.hour),Number(n.minute))-Math.floor(e/6e4)*6e4},Pi=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Fi=({from:e,to:t,dated:n})=>{let r=n?`UTC`:De(),i=e=>n?0:Ni(e,r),{daily:a,ticks:o}=Ai(e,t,i);return(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`relative h-5 min-w-0 flex-1 border-b border-border text-xs text-muted-foreground tabular-nums`,children:o.map(e=>(0,X.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Pi(e.left)}`,style:{left:`${e.left}%`},children:a?ut(e.at+i(e.at)):gt(e.at,r)},e.at))})},Ii=(e,t,n)=>{let r=String(n),i=t?.waitingValues?.includes(r)??!1,a=t?.valueColors&&Object.hasOwn(t.valueColors,r)?t.valueColors[r]:void 0;return a!==void 0&&be(a)?{className:zt[a],striped:i}:{color:er(e,t,n===void 0?null:n,-1),striped:i}},Li=e=>({...e.color!==void 0&&{backgroundColor:e.color},...e.striped&&{backgroundImage:`repeating-linear-gradient(-45deg, transparent 0 4px, color-mix(in srgb, var(--background) 55%, transparent) 4px 6px)`}}),Ri=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Ii(t,n,r.value),{left:o,width:s}=wi(e,r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...Li(a)}},i)}),zi=(e,t)=>t?ot(e):Ft(e),Bi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return V(`timelineRange`,{from:zi(n,a),to:i?V(`timelineNow`):zi(r,a)})},Vi=(e,t,n,r)=>`${Ae(t.fields[r.color],e.value,n?.fields[r.color])}: ${Bi(t,r,e.start,e.end,e.open)}`,Hi=(e,t,n,r,i)=>{let a=e.segments.some(t=>t.open&&t.end===e.end);return[`${i??Ae(t.fields[r.bar],e.value,n?.fields[r.bar])}: ${Bi(t,r,e.start,e.end,a)}`,...e.segments.map(e=>Vi(e,t,n,r))].join(`; `)},Ui=`absolute inset-y-0 flex overflow-hidden rounded-sm ring-offset-1 ring-offset-background outline-none hover:ring-2 hover:ring-border-strong focus-visible:ring-2 focus-visible:ring-primary`,Wi=({bar:e,model:t,view:n,fields:r,point:i,choose:a})=>{let o=q().resources[t.fields[r.bar]?.relation?.resource??``],s=g(o??t,e.key,o!==void 0),c=Hi(e,t,n,r,o?s:void 0),l={onMouseEnter:()=>i.hover(e),onMouseLeave:()=>i.hover(null),onFocus:()=>i.focus(e),onBlur:()=>i.focus(null)},u={left:`${e.left}%`,width:`max(${e.width}%, 4px)`},d=(0,X.jsx)(Ri,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,X.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Ui,...l,children:d});let f=a.chosen===e.key;return(0,X.jsx)(nt,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:U(Ui,f&&`ring-2 ring-foreground`),...l,children:d})},Gi=({shape:e,...t})=>{let{model:n,fields:r}=t,i=n.fields[r.lane];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,X.jsx)(Fi,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,X.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,X.jsx)(Me,{model:n,field:i,value:e.value})}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 border-l border-border pl-px`,children:e.rows.map((e,n)=>(0,X.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,X.jsx)(Wi,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ki=({model:e,view:t,fields:n,value:r})=>{let i=Ii(e.fields[n.color],t?.fields[n.color],r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:Li(i)})},qi=({values:e,...t})=>{let n=t.model.fields[t.fields.color],r=(n.enumValues??[]).filter(t=>e.has(t));return(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(Ki,{...t,value:e}),Ae(n,e,t.view?.fields[t.fields.color])]},e))})},Ji=({bar:e,...t})=>{let{model:n,view:r,fields:i}=t;if(!e)return(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:V(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:(0,X.jsx)(Me,{model:n,field:n.fields[i.bar],value:e.value})}),(0,X.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Bi(n,i,e.start,e.end,a)})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,X.jsx)(Ki,{...t,value:e.value}),Ae(n.fields[i.color],e.value,r?.fields[i.color]),`: `,Bi(n,i,e.start,e.end,e.open)]},a))})]})},Yi=500,Xi=(e,t,{filter:n=``,sort:r,fields:i,limit:a})=>({queryKey:[...wt.list(t.name,n,r,a,`timeline`),i.join(`,`)],queryFn:async()=>{let o=[],s;do{let c=await e.list(t.name,{filter:n||void 0,orderBy:r,pageSize:Math.min(Yi,a-o.length),fields:i,etag:!1,...s&&{pageToken:s}});o.push(...c.items),s=c.nextPageToken||void 0}while(s&&o.length<a);return{rows:o.toReversed(),cut:s!==void 0}}}),Zi=(e,{enabled:t=!0,...n})=>Fn({...Xi(Ne(),e,n),enabled:t,placeholderData:Pn}),Qi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=on,title:s,description:c,empty:u,actions:d,className:f,choose:p,details:m})=>{let[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),y=e=>e?ji(e):null,b={hover:e=>g(y(e)),focus:e=>v(y(e))},x=nn(i),S=Zi(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!x}),C=x??S,w=x?x.rows:S.data?.rows??[],T=!x&&S.data?.cut===!0,E=Ci(w,n,Date.now());return(0,X.jsxs)(J,{title:s,description:c,actions:d,className:U(`h-full`,f),children:[(()=>{if(C.isPending)return(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(A,{className:`h-6`},t))});if(C.error)return(0,X.jsx)(l,{title:V(`couldNotLoad`),error:C.error});if(E.lanes.length===0)return(0,X.jsx)(j,{children:u??V(`nothingYet`)});let r=new Set(w.map(e=>String(e[n.color])));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(qi,{model:e,view:t,fields:n,values:r}),(0,X.jsx)(Gi,{shape:E,model:e,view:t,fields:n,point:b,...p&&{choose:p}}),T&&(0,X.jsx)(j,{children:V(`timelineCut`,{count:w.length})}),(0,X.jsx)(`div`,{"aria-live":`polite`,children:(0,X.jsx)(Ji,{bar:Mi(E,h)??Mi(E,_),model:e,view:t,fields:n})})]})})(),m]})},$i=(e,t)=>e.type===`integer`?Number(t):t,ea=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=lt(),a=r[e],o=t=>i({[e]:t}),s=n.model.fields[n.fields.bar],c=a===void 0?null:(0,X.jsx)(pn,{name:e,children:(0,X.jsx)(_i,{model:n.model,query:{filter:Jn(s,$i(s,a),n.filter),sort:n.sort},children:t},a)});return(0,X.jsx)(Qi,{...n,choose:{barTo:o,chosen:a},details:c})},ta=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,lane:c,bar:l,start:u,end:d,color:f,children:p,...m}=G(e),{resources:h,views:g}=q(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Bt(e),sort:Qt(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,X.jsx)(Qi,{...v}):(0,X.jsx)(ea,{...v,select:s,children:r})},na=({node:e,children:t})=>{let n=Xe(e),r=un(),{resources:i}=q();if(!n||!r)return t;let a=r.given[n.param],o=n.resource===void 0?void 0:i[n.resource];return a===void 0||!o?null:(0,X.jsx)(pn,{name:n.param,children:(0,X.jsx)(_i,{model:o,query:{key:a},className:``,children:t},a)})},ra=(0,Y.lazy)(()=>Nn(()=>import(`./graph-view-C4fwqz7Q.js`).then(e=>({default:e.GraphView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),ia=(0,X.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,X.jsx)(u,{})}),aa=({node:e,at:t,slots:n,children:r,className:i})=>{let a=G(e),o=Ze(e,t),s=un(),c=o.nodes,u=o.edges,{label:d,group:f,status:p,source:m,target:h}=a,g=(0,Y.useMemo)(()=>({label:d,source:m,target:h,...f!==void 0&&{group:f},...p!==void 0&&{status:p}}),[d,m,h,f,p]),_=JSON.stringify([c?.rows,u?.rows,g]),v=(0,Y.useMemo)(()=>c&&u&&si({nodes:c.rows,edges:u.rows,key:c.model.primaryKey[0],edgeKey:u.model.primaryKey,fields:g}),[_]);if(!c||!u||!v)return null;let y=c.error??u.error;if(y&&e.fallback)throw y;if(y)return(0,X.jsx)(l,{title:V(`couldNotLoad`),error:y});if(c.isPending||u.isPending)return ia;if(v.nodes.length===0)return(0,X.jsx)(j,{children:a.empty??V(`nothingYet`)});let b=a.select,x=b!==void 0&&s?{chosen:s.given[b],linkTo:e=>s.linkTo({[b]:e})}:void 0;return(0,X.jsxs)(`div`,{className:U(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Y.Suspense,{fallback:ia,children:(0,X.jsx)(ra,{shape:v,nodes:c,edges:u,fields:g,props:a,...x&&{select:x},...a.node!==void 0&&{content:n.node}})})}),r.length>0&&x?.chosen!==void 0&&(0,X.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,X.jsx)(na,{node:e,children:r})})]})},oa=({onPick:e,accept:t})=>{let n=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{ref:n,type:`file`,multiple:!0,hidden:!0,accept:t,"aria-label":P(`filesToAttach`),onChange:t=>{e([...t.target.files??[]]),t.target.value=``}}),(0,X.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":P(`attachFiles`),title:P(`attachFiles`),onClick:()=>n.current?.click(),children:(0,X.jsx)(jn,{className:`size-4`})})]})},sa=`message`,ca=(e,t,n,r)=>[{op:`create`,resource:e,ref:sa,data:t},...r.map(e=>({op:`create`,resource:n.resource,data:{[n.field]:{$ref:sa},[n.file]:e}}))],la=e=>{let t=e.results[0];if(t?.op!==`create`)throw Error(`A message batch starts with the message it creates`);return t.record},ua=(e,t,n,r)=>[...e.attachments?r.map(t=>({op:`delete`,resource:e.attachments.resource,key:t.key})):[],{op:`delete`,resource:e.resource,key:ln(t,n)}],da=(e,t)=>{if(!(t===void 0||e.size<=t))return P(`fileTooLarge`,{size:Ee(e.size),max:Ee(t)})},fa=(e,t,n)=>e.map((e,r)=>({key:t+r,name:e.name,size:e.size,sent:0,refusal:da(e,n)})),pa=e=>e.ticket===void 0&&e.refusal===void 0,ma=e=>e.flatMap(e=>e.ticket===void 0?[]:[e.ticket]),ha=e=>!e.some(pa)&&ma(e).length>0,ga=e=>e.refusal===void 0?e.ticket!==void 0||e.size===0?Ee(e.size):P(`uploadedPercent`,{percent:Math.floor(Math.min(e.sent,e.size)/e.size*100)}):e.refusal,_a=({uploads:e,onRemove:t})=>(0,X.jsx)(`ul`,{"aria-label":P(`filesToSend`),className:`flex flex-wrap gap-2`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex max-w-full items-center gap-1 rounded-md border border-border py-0.5 pl-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:e.name}),(0,X.jsx)(`span`,{role:e.refusal===void 0?void 0:`alert`,className:U(`min-w-0`,e.refusal===void 0?`text-muted-foreground`:`text-danger-text`),children:ga(e)}),(0,X.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":P(`takeFileOff`,{name:e.name}),title:P(`takeFileOff`,{name:e.name}),onClick:()=>t(e.key),children:(0,X.jsx)(Nt,{className:`size-3.5`})})]},e.key))}),va=e=>{let t=Ne(),{resources:n}=q(),r=e&&n[e.resource]?.fields[e.file]?.file?.maxSize,[i,a]=(0,Y.useState)([]),o=(0,Y.useRef)(0),s=(0,Y.useRef)(new Map),c=(e,t)=>a(n=>n.map(n=>n.key===e?{...n,...t}:n)),l=(e,n,r)=>{let i=new AbortController;s.current.set(n.key,i),t.upload(e.resource,e.file,r,{signal:i.signal,onProgress:e=>c(n.key,{sent:e})}).then(e=>c(n.key,{ticket:e.value}),e=>{i.signal.aborted||c(n.key,{refusal:P(`fileNotUploaded`,{reason:mn(e)})})}).finally(()=>s.current.delete(n.key))};return(0,Y.useEffect)(()=>{let e=s.current;return()=>e.forEach(e=>e.abort())},[]),{uploads:i,tickets:ma(i),uploading:i.some(pa),ready:ha(i),pick:t=>{if(!e||t.length===0)return;let n=fa(t,o.current,r);o.current+=t.length,a(e=>[...e,...n]),n.forEach((n,r)=>{n.refusal===void 0&&l(e,n,t[r])})},remove:e=>{s.current.get(e)?.abort(),a(t=>t.filter(t=>t.key!==e))},sent:e=>a(t=>t.filter(t=>pa(t)||t.ticket!==void 0&&!e.includes(t.ticket)))}},Q=vt(`app/conversation`),ya=({resource:e,field:t,values:n,placeholder:r,searchPeople:i,mentions:a,attachments:o,onDraft:s,onSent:c})=>{let{resources:u}=q(),d=Ne(),f=vn(),p=kn(e),[m,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(),y=va(o);if(!u[e]||!Te(p,`create`))return null;let b=o&&u[o.resource]?.fields[o.file],x=b&&E(b);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[_!==void 0&&(0,X.jsx)(l,{title:Q(`notSent`),error:_}),(0,X.jsx)(yn,{onSend:async(r,i)=>{g(!0),v(void 0);let s=y.tickets,l={...n,...r!==``&&{[t]:r},...a!==void 0&&{[a]:i}},p=o&&s.length>0?d.batchWrite(ca(e,l,o,s)).then(la):d.create(e,l).then(e=>e.record),m=u[e],_=await p.then(e=>(c?.(String(h(m,e))),!0),e=>(v(e),!1));return g(!1),_?(f(e),o&&y.sent(s),o&&s.length>0&&f(o.resource),!0):!1},busy:m||y.uploading,placeholder:r,searchPeople:i,onDraft:s,...o&&{actions:(0,X.jsx)(oa,{onPick:y.pick,accept:x}),attachments:y.uploads.length>0&&(0,X.jsx)(_a,{uploads:y.uploads,onRemove:y.remove}),canSendEmpty:y.ready,onFiles:y.pick}})]})},ba=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=G(e);return(0,X.jsx)(ya,{resource:t,field:n,values:r,placeholder:i})},xa=({node:e,children:t,className:n})=>{let{open:r}=G(e);return(0,X.jsx)(`details`,{open:r,className:U(`[&[open]>summary]:mb-2`,n),children:t})},Sa=({children:e,className:t})=>(0,X.jsx)(`summary`,{className:U(`cursor-pointer font-medium`,t),children:e}),Ca=({node:e,className:t})=>{let{source:n,emptyText:r}=G(e),i=Tt(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,X.jsx)(A,{className:U(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,X.jsx)(`p`,{className:U(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=xt(a);return o?(0,X.jsx)(`div`,{className:U(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,X.jsx)(Je,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,X.jsx)(`pre`,{className:U(`overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-border bg-background p-3 font-mono text-[0.6875rem] leading-[18px]`,t),children:a})},wa=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),Ta=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>ge(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},Ea=({node:e,className:t})=>{let{source:n,label:r,format:i}=G(e),{views:a}=q(),o=Tt(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,X.jsx)(A,{className:`h-4 w-24`}):o.state===`plain`?wa(o.value):(0,X.jsx)(Me,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,X.jsx)(`div`,{className:t,children:s});let c=r??Ta(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:U(`min-w-0`,t),children:[(0,X.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate`,children:s})]})},Da={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},Oa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ka={1:``,2:`md:col-span-2`,3:`md:col-span-2 xl:col-span-3`,4:`sm:col-span-2 md:col-span-2 xl:col-span-4`},Aa=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ja=({node:e,children:t,className:n})=>{let{columns:r=2}=G(e),i=e.children,a=i.length>0&&i.every(Aa);return(0,X.jsx)(`div`,{className:U(`grid grid-cols-1 gap-4`,a?Oa[r]:Da[r],n),children:t.map((e,t)=>{let n=i[t],r=typeof n==`object`?n.props.span:void 0;return(0,X.jsx)(`div`,{className:U(`min-w-0`,r&&ka[r]),children:e},t)})})},Ma=({src:e,alt:t,width:n,height:r,className:i})=>(0,X.jsx)(`img`,{src:e,alt:t??``,width:n,height:r,className:i??`max-w-full`}),Na=({width:e,height:t,space:n,theme:r})=>{let i=e??Math.ceil(n/100)*100;if(i!==0)return{width:String(i),...t!==void 0&&{height:String(t)},theme:r}},Pa=e=>({staleTime:1/0,refetchOnWindowFocus:!1,...e!==void 0&&{refetchInterval:e*1e3}}),Fa=e=>e instanceof Blob&&e.type.startsWith(`image/`),Ia=e=>{let[t,n]=(0,Y.useState)();return(0,Y.useEffect)(()=>{if(!e)return n(void 0);let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t},La=e=>{let[t,n]=(0,Y.useState)();return[t!==void 0&&t===e,()=>n(e)]},Ra=({name:e,alt:t,width:n,height:r,refresh:i,className:a})=>{let o=Ne(),{theme:s}=He(),[c,l]=et(),u=Na({width:n,height:r,space:l,theme:s}),d=Fn({queryKey:wt.image(e,u??{}),enabled:u!==void 0,placeholderData:Pn,...Pa(i),queryFn:async()=>{let t=await o.invoke(e,{query:u,cache:`no-store`});if(!Fa(t))throw Error(`The function "${e}" answered no picture`);return t}}),f=Ia(d.data),[p,m]=La(f),h={...n!==void 0&&{width:n},...r!==void 0&&{height:r}};return(0,X.jsx)(`div`,{ref:c,className:U(`min-w-0`,a),children:d.isError||p?t&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:t}):f?(0,X.jsx)(`img`,{src:f,alt:t??``,onError:m,style:h,className:n===void 0?`w-full max-w-full object-contain`:`max-w-full object-contain`}):(0,X.jsx)(A,{className:`w-full max-w-full`,style:{height:r??160,...n!==void 0&&{width:n}}})})},za=({node:e,className:t})=>{let n=G(e);return n.src===void 0?(0,X.jsx)(Ra,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,X.jsx)(Ma,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},Ba=e=>function({node:t,className:n}){let r=G(t),{views:i}=q(),a=Tt(r.source);return a.state===`missing`?null:a.state===`loading`?(0,X.jsx)(A,{className:`inline-block h-3 w-16 align-middle`}):Zr(t.type,a.value)?r.emptyText?(0,X.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:a.field,hints:i[a.model.name]?.fields[a.field.name],props:r})})},Va=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?d(e,n?.valueLabels):Qr(e),Ha=Ba(Va),Ua=Ba(({value:e,props:t})=>(0,X.jsx)(`span`,{className:`tabular-nums`,children:$r(e,t,Tn())})),Wa=Ba(({value:e,props:t})=>{let n=ei(e,t,{locale:Tn(),now:Date.now(),relative:St});return(0,X.jsx)(`time`,{dateTime:String(e),children:n})}),Ga=Ba(({value:e,props:t})=>{let n=ti(e,t,{yes:C(`yes`),no:C(`no`)});return e?(0,X.jsx)(Ce,{label:n,className:`align-middle`}):(0,X.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ka=Ba(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=ri(n);return i===void 0?r:(0,X.jsx)(`a`,{href:i,className:`font-medium text-primary-text hover:underline`,.../^https?:/i.test(i)&&{target:`_blank`,rel:`noreferrer`},children:r})}),qa=Ba(e=>(0,X.jsx)(fe,{value:e.value,hints:e.hints,children:Va(e)})),Ja=`font-medium text-primary-text hover:underline`,Ya=({node:e,children:t,className:n})=>{let r=G(e),i={...F(R()),params:an()},a=r.variant?U(p({variant:r.variant}),n):n??Ja,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=Ut(r.to,Ie(i));return(0,X.jsx)(D,{to:e,className:a,children:o??Kt(e)})}let s=r.href??``;return(0,X.jsx)(`a`,{href:s,className:a,...s.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??s})},Xa=(e,t,n)=>Object.fromEntries(t.map(t=>{let r=e.fields[t];if(r.type===`file`)return[t,n?.[t]??null];if(n)return[t,r.type===`boolean`?!!n[t]:me(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:me(i)]})),Za=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let a=e.fields[t];return at(r)?r.key===me(n[t])?[]:[[t,a.type===`integer`?Number(r.key):r.key]]:_n(a,r,n[t])?[[t,i(a,r)]]:[]})),Qa=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:s,onClose:c})=>{let{resources:u,views:d}=q(),f=Ne(),p=ne(),m=vn(),h=d[e.name],[g,_]=(0,Y.useState)(()=>Xa(e,a,t?.record)),[v,y]=(0,Y.useState)({}),[b,x]=(0,Y.useState)(0),S=fn(b),[C,w]=(0,Y.useState)(),[T,E]=(0,Y.useState)(!1),[ee,te]=(0,Y.useState)(!1);_t(ee||T,`input-lost`);let re=async()=>{E(!0),w(void 0),await(n===`create`?f.create(e.name,{...Ye(e,u,g),...s}):f.update(e.name,t.key,Za(e,g,t.record),t.etag??`*`)).then(async()=>{await m(e.name),p.show({state:`success`,title:V(`saved`,{label:i??r})}),c()},e=>{let t=wn(e);y(t),Object.keys(t).length>0&&x(e=>e+1),w(e)}),E(!1)};return(0,X.jsx)(o,{title:i??r,onClose:c,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:c,children:V(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:T,onClick:()=>void re(),children:V(n===`create`?`create`:`save`)})]}),children:(0,X.jsxs)(`form`,{ref:S,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),re()},children:[C!==void 0&&Object.keys(v).length===0&&(0,X.jsx)(l,{title:V(`notSaved`),error:C}),a.map(n=>{let r=e.fields[n],i=g[n],a=r.relation?u[r.relation.resource]:void 0,o=h?.fields[n]?.label??ge(n),s=v[n];return(0,X.jsx)(An,{name:n,label:o,help:h?.fields[n]?.help,error:s&&tt(r,o,s),children:(0,X.jsx)(bn,{field:r,hints:h?.fields[n],value:at(i)?i.key:i,stored:t?.record[n],relationLabel:at(i)?i.label:void 0,relationPicker:a?{target:a,view:d[a.name]}:void 0,invalid:!!v[n],resource:e.name,onChange:e=>{y(({[n]:e,...t})=>t),te(!0),_(t=>({...t,[n]:e}))}})},n)})]})})},$a=({model:e,recordKey:t,children:n})=>{let r=Oe(e,{key:t});return(0,X.jsx)(X.Fragment,{children:n(r.data??void 0)})},eo=({node:e})=>{let t=G(e),n=Dt(),{resources:r}=q(),i=r[t.resource??n?.model.name??``],a=kn(i?.name??``),[o,s]=(0,Y.useState)(!1);if(!i||!(t.mode===`create`?Te(a,`create`):Te(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,X.jsx)(Qa,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,X.jsx)($a,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},to=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=G(e);return(0,X.jsx)(`div`,{className:U(`flex-1`,r),children:(0,X.jsxs)(`div`,{className:U(`flex flex-col gap-6 px-4 pb-16 pt-6 md:px-10 md:py-8`,o!==`full`&&`mx-auto max-w-[1200px]`),children:[(0,X.jsx)(xr,{title:i,subtitle:a,actions:n.actions}),t]})})},no=(e,t)=>{let n=R(),r=typeof e==`string`?Jt(n,e):void 0,i=qt(r&&`frame`in r?r.frame:void 0,r&&`path`in r?r.path:``);return typeof e==`number`?e:e===void 0?t:r&&`item`in r?Number(r.item):i.state===`ready`?Number(i.value):i.state===`loading`?void 0:NaN},ro=({node:e,className:t})=>{let{value:n,max:r,label:i}=G(e),a=no(n,0),o=no(r,100);if(a===void 0||o===void 0)return(0,X.jsx)(A,{className:`h-6 w-full`});if(!Number.isFinite(a)||!Number.isFinite(o))return null;let s=o>0?Math.min(1,Math.max(0,a/o)):0;return(0,X.jsxs)(`div`,{className:U(`min-w-0`,t),children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[a.toLocaleString(Tn()),` / `,o.toLocaleString(Tn())]})]}),(0,X.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":o,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:s>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${s*100}%`}})})]})},io=({model:e,at:t,filter:n,sort:r,recordKey:i,title:a,description:o,empty:s,actions:c,children:u,className:d})=>{let f=nn(t),p=Oe(e,{filter:n,sort:r,key:i,enabled:!f}),m=f?En(e,f):p,h=e=>m.data?(0,X.jsx)(dt,{value:m.data,children:e}):void 0,g=m.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(A,{className:`h-4 w-1/2`}),(0,X.jsx)(A,{className:`h-4 w-1/3`})]}):m.error?(0,X.jsx)(l,{title:V(`couldNotLoad`),error:m.error}):m.data?h((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:u})):(0,X.jsx)(j,{children:s??V(`nothingYet`)});return(0,X.jsx)(J,{title:a,description:o,actions:c?h(c):void 0,className:U(`h-full`,d),children:g})},ao=({node:e,at:t,children:n,slots:r,className:i})=>{let{resource:a,filter:o,sort:s,recordKey:c,title:l,description:u,empty:d}=G(e),f=q().resources[a];return f?(0,X.jsx)(io,{model:f,...t!==void 0&&{at:t},filter:o,sort:s,recordKey:c,title:l,description:u,empty:d,actions:r.actions,className:i,children:n}):null},oo=vt(`app/related-cards`),so=({children:e})=>{let t=(0,Y.useRef)(null),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,Y.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=()=>a(e.scrollHeight>e.parentElement.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[n]),(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,X.jsx)(`div`,{className:U(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,X.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,X.jsx)(M,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:oo(n?`showLess`:`showMore`)})]})},co=e=>e==null||e===``,lo=({scope:e,path:t,labelled:n=!0,clamped:r=!1})=>{let{views:i}=q(),a=qt(e,t);if(a.state===`missing`||a.state===`ready`&&co(a.value))return null;let o=a.state===`loading`?(0,X.jsx)(A,{className:`h-4 w-24`}):(0,X.jsx)(Me,{model:a.model,field:a.field,value:a.value}),s=r?(0,X.jsx)(so,{children:o}):o;if(!n)return(0,X.jsx)(`div`,{className:`min-w-0`,children:s});let c=Ta(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`dd`,{className:`mt-0.5`,children:s})]})},uo=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:s})=>{let c=Ge(),{resources:l}=q(),u=c(e.model,t,e.record,e.key),d=a.length>0||o!==void 0;return(0,X.jsxs)(`li`,{"data-card":e.key,className:U(`relative grid min-w-0 items-center gap-x-4 gap-y-1 rounded-lg border border-border bg-surface px-4 py-2.5`,d?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:[i&&(0,X.jsx)(pt,{view:t,field:i,record:e.record}),(0,X.jsxs)(`div`,{className:U(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,X.jsx)(D,{to:{kind:`record`,resource:e.model.name,key:h(e.model,e.record)},className:`line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere] text-primary-text hover:underline`,children:u}),r&&(0,X.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,X.jsx)(lo,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-y-0.5 text-body text-muted-foreground`,children:n.map(t=>(0,X.jsx)(`div`,{className:`flex max-w-full min-w-0 items-center whitespace-nowrap empty:hidden [&>div]:truncate [:not(:empty)~&]:before:mx-2 [:not(:empty)~&]:before:content-['·'_/_'']`,children:(0,X.jsx)(lo,{scope:e,path:t,labelled:!1})},t))}),d&&(0,X.jsx)(dt,{value:e,children:(0,X.jsxs)(`div`,{className:`col-start-2 flex flex-wrap items-center justify-end gap-2 sm:row-span-2 sm:row-start-1`,children:[o&&(0,X.jsx)(mr,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,X.jsx)(li,{name:e,about:u,onRun:e=>s?.(e,u)},e))]})})]})},fo=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let s=Ge(),{resources:c}=q(),l=s(e.model,t,e.record,e.key);return(0,X.jsxs)(`li`,{"data-card":e.key,className:`relative flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[r&&(0,X.jsx)(pt,{view:t,field:r,record:e.record}),(0,X.jsx)(D,{to:{kind:`record`,resource:e.model.name,key:h(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:l}),n.length>0&&(0,X.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,X.jsx)(lo,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,X.jsx)(dt,{value:e,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,X.jsx)(mr,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,X.jsx)(li,{name:e,about:l,onRun:e=>o?.(e,l)},e))]})})]})},po=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,mo=e=>[...e.querySelectorAll(`button`)].find(po)??e.querySelector(`a`),ho=(e,t,n)=>{let r=e.indexOf(n),i=e=>t.includes(e);return e.slice(r+1).find(i)??e.slice(0,Math.max(r,0)).findLast(i)},go=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},_o=e=>{let t=(0,Y.useRef)(null),n=(0,Y.useRef)({current:e,previous:e}),r=(0,Y.useRef)(void 0),[i,a]=(0,Y.useState)(``),o=(e,n,i)=>{if(r.current=void 0,i.includes(e.key)||!t.current||(a(oo(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=ho(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?mo(s):go(t.current))?.focus()};return(0,Y.useEffect)(()=>{let t=n.current.current;n.current={current:e,previous:t},r.current&&o(r.current,t,e)},[e]),{root:t,acted:(e,t,i)=>{let{current:a,previous:s}=n.current;if(a.includes(e)){r.current={key:e,action:t,title:i};return}o({key:e,action:t,title:i},s,a)},announcement:i}},vo=({compact:e,limit:t})=>(0,X.jsx)(`div`,{className:e?`flex flex-col gap-2`:`flex flex-col gap-3`,children:Array.from({length:e?Math.min(t,3):2},(t,n)=>(0,X.jsx)(A,{className:e?`h-17.5 w-full max-sm:h-24`:`h-24 w-full`},n))}),yo=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,button:o,limit:s,display:u,empty:d,carousel:f,compact:p,tone:m,planned:h})=>{let g=Ht(),_=hr(),v=t?.names?.plural??ge(e.name),y=r||At(e,t),b=c(e,{filter:n,sort:y,pageSize:s,enabled:!h}),x=xn(e,n,!h),S=h?h.rows:{isPending:b.isPending,error:b.error},C=h?h.rows.rows:b.data?.items,w=h?{data:h.total&&!h.total.isPending&&!h.total.error?cr(h.total):void 0}:x,T=(0,Y.useMemo)(()=>(C??[]).map(t=>rt(e,t)),[e,C]),E=_o((0,Y.useMemo)(()=>T.map(e=>e.key),[T]));return(0,X.jsxs)(`div`,{ref:E.root,children:[(()=>{if(S.isPending)return(0,X.jsx)(vo,{compact:!!p,limit:s});if(S.error)return(0,X.jsx)(l,{title:oo(`couldNotLoad`),error:S.error});if(T.length===0)return(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:d??oo(`nothingYet`)});let r=T.map(e=>{let n=(t,n)=>E.acted(e.key,t,n);return p?(0,X.jsx)(uo,{scope:e,view:t,fields:i,time:p.time,tone:m,actions:a,button:o,onActed:n},e.key):(0,X.jsx)(fo,{scope:e,view:t,fields:i,tone:m,actions:a,button:o,onActed:n},e.key)}),c=w.data===void 0?void 0:Zn(T.length,w.data,!1);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f===void 0?(0,X.jsx)(`ul`,{className:p?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,X.jsx)(Qn,{scroll:_,label:v,share:f,children:r}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c}),(0,X.jsxs)(D,{to:ur(e,t,g,{filter:n,orderBy:y,display:dr(t,g,{preferred:u})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[ar(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:v.toLowerCase()}),(0,X.jsx)(nr,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:E.announcement})]})},bo={"1/4":1/4,"1/3":1/3,"1/2":1/2,"2/3":2/3},xo=({node:e,at:t,slots:n,className:r})=>{let i=G(e),{resource:a,filter:o=``,sort:c=``,fields:l,cardActions:u=[],limit:d=10,display:f,title:p,description:m,empty:h}=i,{layout:g,cardWidth:_}=ii(i),{resources:v,views:y}=q(),[b,x]=st([t,t===void 0?void 0:`${t}#total`]),S=(0,Y.useMemo)(()=>b&&{rows:b,total:x},[b,x]),C=v[a];if(!C)return null;let w=y[C.name];return(0,X.jsx)(`section`,{className:U(`min-w-0`,r),"aria-label":p,children:(0,X.jsx)(T,{title:p,help:m,actions:n.actions,children:(0,X.jsx)(yo,{model:C,view:w,filter:o,sort:c,fields:l??s(C,w),actions:u,limit:d,display:f,empty:h,carousel:g===`carousel`?bo[_]:void 0,...S&&{planned:S}})})})},So=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=q(),o=Ve(i,a,e.name),s=Vn(e.name,t.listOf,!0),c=(t.names?.plural??ge(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,X.jsx)(l,{title:Ln(`couldNotLoadYour`,{plural:c}),error:s.error});if(!s.data)return(0,X.jsx)(A,{className:`h-24`});let u=rr(o.model,s.data);return u?(0,X.jsx)(_r,{...r,model:o.model,view:o.view,filter:``,scope:u,list:e.name,empty:n}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??Ln(`noneYet`,{plural:c})})},Co=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=ce(h(e,i)),{name:o,chips:s,title:c,body:l}=yr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,X.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,X.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,X.jsx)(D,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,X.jsx)(Kn,{chips:s})})}),(0,X.jsx)(_r,{...l})]})},wo=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=q(),a=t.searchesOf,o=r[a.resource],s=Xn(e.name,!0),c=(t.names?.plural??ge(e.name)).toLowerCase();return o?s.error?(0,X.jsx)(l,{title:qn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??qn(`noneYet`,{plural:c})}):(0,X.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,X.jsx)(Co,{model:e,view:t,target:o,targetView:i[a.resource],row:n},ce(h(e,n))))}):(0,X.jsx)(A,{className:`h-40`}):null},To=({node:e,slots:t,className:n})=>{let{resource:r,filter:i=``,sort:a,limit:o,display:s,title:c,description:l,empty:u}=G(e),{resources:d,views:f}=q(),p=d[r];if(!p)return null;let m=f[p.name];return(0,X.jsx)(J,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,X.jsx)(wo,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,X.jsx)(_r,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,X.jsx)(So,{model:p,view:m,limit:o,display:s,empty:u})})},Eo=e=>e.type===`boolean`||e.type===`enum`,Do=({model:e,fields:t,title:n,description:r,stored:i,className:a})=>{let{resources:o,views:s}=q(),c=kn(e.name),u=Ne(),d=ne(),f=vn(),p=s[e.name],[m,h]=(0,Y.useState)(i),[g,_]=(0,Y.useState)(()=>Xa(e,t,i?.record)),[v,y]=(0,Y.useState)({}),[b,x]=(0,Y.useState)(),[S,C]=(0,Y.useState)(!1),w=(0,Y.useRef)(Promise.resolve()),T=(0,Y.useRef)(i),E=Xa(e,t,void 0),ee=m?Te(c,`update`)&&m.permissions?.update!==!1:Te(c,`create`),te=t.filter(t=>!Eo(e.fields[t])),re=te.some(t=>m?_n(e.fields[t],g[t],m.record[t]):g[t]!==E[t]),ie=async t=>{let n=T.current;if(n){let r=await u.update(e.name,n.key,Za(e,t,n.record),n.etag??`*`);return{...rt(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await u.create(e.name,Ye(e,o,{...E,...t}));return{...rt(e,r.record),etag:r.etag}},D=t=>{let r=w.current.then(async()=>{C(!0),x(void 0),await ie(t).then(async r=>{T.current=r,h(r),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await f(e.name),d.show({state:`success`,title:V(`saved`,{label:n??V(`settings`)})})},e=>{y(t=>({...t,...wn(e)})),x(e)}),C(!1)});w.current=r},ae=(t,n)=>{_(e=>({...e,[t]:n})),Eo(e.fields[t])&&D({[t]:n})};return(0,X.jsx)(J,{title:n,description:r,className:U(`h-full`,a),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),re&&D(Object.fromEntries(te.map(e=>[e,g[e]])))},children:[b!==void 0&&Object.keys(v).length===0&&(0,X.jsx)(l,{title:V(`notSaved`),error:b}),t.map(t=>{let n=e.fields[t],r=p?.fields[t]?.label??ge(t),i=v[t];return(0,X.jsx)(An,{name:t,label:r,help:p?.fields[t]?.help,error:i&&tt(n,r,i),children:(0,X.jsx)(bn,{field:n,hints:p?.fields[t],value:g[t],stored:m?.record[t]??E[t],invalid:!!i,locked:!ee||n.readOnly,resource:e.name,onChange:e=>ae(t,e)})},t)}),ee&&re&&(0,X.jsx)(`div`,{children:(0,X.jsx)(M,{type:`submit`,variant:`primary`,size:`sm`,loading:S,children:V(`save`)})})]})})},Oo=e=>{let t=Oe(e.model,{});return t.isPending?(0,X.jsx)(J,{title:e.title,description:e.description,className:e.className,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(A,{className:`h-4 w-1/2`}),(0,X.jsx)(A,{className:`h-4 w-1/3`})]})}):t.error?(0,X.jsx)(J,{title:e.title,description:e.description,className:e.className,children:(0,X.jsx)(l,{title:V(`couldNotLoad`),error:t.error})}):(0,X.jsx)(Do,{...e,stored:t.data??void 0})},ko=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=G(e),o=q().resources[n];return o?(0,X.jsx)(Oo,{...a,model:o,fields:r.filter(e=>Object.hasOwn(o.fields,e)),stored:void 0,className:t}):null},Ao=(e,t)=>jo(e,t?[t]:[]),jo=(e,t)=>{let{resources:n}=q(),i=Ne(),a=JSON.stringify(e),o=(0,Y.useMemo)(()=>JSON.parse(a).map(ft),[a]),s=e=>t.some(t=>`item`in t?typeof t.item==`object`&&t.item!==null&&Object.hasOwn(t.item,e):Object.hasOwn(t.model.fields,e)),c=[...new Set(o.flatMap(e=>e.ok?e.paths:[]))],l=new Map(c.flatMap(e=>{let t=we(e,s);return t===void 0?[]:[[e,t]]})),u=c.filter(e=>!l.has(e)),d=[...new Set(l.values())].flatMap(e=>n[e]?[n[e]]:[]),f=u.map(e=>Jt(t,e)),p=Rt(u.map((e,t)=>{let n=f[t];return n&&`frame`in n?{scope:n.frame,path:n.path}:{scope:void 0,path:e}})),m=In({queries:d.map(e=>yt(i,e))});return o.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=l.get(n);if(e===void 0){let e=u.indexOf(n),r=f[e];if(r&&`item`in r){t[n]=r.item;continue}let i=p[e];if(i.state===`loading`)return;i.state===`ready`&&(t[n]=i.value);continue}let r=d.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(m[r].isPending)return;else t[n]=m[r].data??0}return r(e,t)})},Mo=(e,t)=>typeof e.props.fallback==`string`?e.props.fallback:t.fallback,No=({node:e,children:t,slots:n,className:r})=>{let{when:i}=G(e),[a]=jo([i],R());if(a===void 0)return null;let o=a?t:Mo(e,n);return o==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:o}):(0,X.jsx)(`div`,{className:r,children:o})},Po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(w(e,F(t)).props.when)]),Fo=({node:e,children:t,slots:n,className:r})=>{let i=R(),a=jo(Po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?Mo(e,n):t[o];return s==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:s}):(0,X.jsx)(`div`,{className:r,children:s})},Io=({children:e})=>(0,X.jsx)(X.Fragment,{children:e}),Lo=`text-2xl font-semibold tracking-tight tabular-nums`,Ro=({model:e,at:t,filter:n})=>{let{views:r}=q(),i=nn(t),a=xn(e,n,!i),o=i??a;if(o.isPending)return(0,X.jsx)(A,{className:`h-8 w-16`});if(o.error)return(0,X.jsx)(`span`,{className:`text-danger-text`,children:V(`couldNotCount`)});let s=i?cr(i):a.data;return(0,X.jsx)(D,{to:or(r[e.name],e.name,n),className:`${Lo} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:s.toLocaleString(Tn())})},zo=({field:e,format:t})=>{let n=Tt(e);return n.state===`loading`?(0,X.jsx)(A,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,X.jsx)(`span`,{className:Lo,children:wa(n.value)}):(0,X.jsx)(`span`,{className:Lo,children:(0,X.jsx)(Me,{model:n.model,field:n.field,value:n.value,format:t})})},Bo=({node:e,at:t,className:n})=>{let{label:r,value:i,resource:a,filter:o,field:s,format:c,description:l}=G(e),{resources:u}=q(),d=a===void 0?void 0:u[a];return(0,X.jsxs)(J,{className:U(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,X.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,X.jsx)(`span`,{className:Lo,children:i}),d&&(0,X.jsx)(Ro,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,X.jsx)(zo,{field:s,format:c})]}),l&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},Vo=(e,t,n)=>{let r=Ht(),i=tr(t),[a,o]=(0,Y.useState)(()=>Yn(localStorage,i)),s=(0,Y.useCallback)(e=>{o(e),fr(localStorage,i,e)},[i]);return[dr(e,r,{picked:a,preferred:n}),s]},Ho=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:c,className:l})=>{let{resources:u,views:d}=q(),f=d[e.name],{fields:p}=y(),m=Te(kn(e.name),`update`),{go:h,href:g}=Xt(),_=Ht(),v=!cn(),b=(0,Y.useMemo)(()=>n?.map(Zt)??s(e,f),[n,e,f]),x=(0,Y.useMemo)(()=>mt(e,f,b,{resources:u,views:d,fieldTypes:p}),[e,f,b,u,d,p]),S=(0,Y.useMemo)(()=>_?It(n)(x):x,[_,n,x]),C=(0,Y.useMemo)(()=>r?ir(S,e,f,r,u,v):S,[S,e,f,r,u,v]),w=(0,Y.useMemo)(()=>t.map(t=>({...t,id:ye(e,t)})),[t,e]),T=(0,Y.useMemo)(()=>({total:w.length,rowAt:e=>w[e]}),[w]),E=lr({model:e,view:f,opens:void 0,resources:u,views:d,canUpdate:m}),ee=e=>({href:g(e),onFollow:()=>h(e)});return(0,X.jsx)(J,{title:i,description:a,actions:c,className:l,children:w.length===0?(0,X.jsx)(j,{children:o??V(`nothingYet`)}):(0,X.jsx)(Un,{fit:!0,columns:C,source:T,latencyMs:0,onOpenRow:e=>h(E.address(e)),rowLink:e=>ee(E.address(e)),rowActions:E.actions(ee),rowNumbers:!1,selectable:!1})})},Uo=e=>{let t=it();return t?.model?(0,X.jsx)(Ho,{...e,model:t.model,items:t.items}):null},Wo=({model:e,view:t,filter:n=``,sort:r=``,columns:i,button:a,bulk:o,limit:s=10,display:c,title:l,description:u,empty:d,actions:f,className:p,chosen:m,planned:h})=>{let[g,_]=Vo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?Ue:g,y=(0,Y.useMemo)(()=>i?.map(Zt),[i]),b=(0,Y.useMemo)(()=>It(i),[i]);return(0,X.jsxs)(J,{title:l,description:u,actions:(0,X.jsxs)(X.Fragment,{children:[!m&&(0,X.jsx)(pr,{view:t,value:v,onChange:_}),f]}),className:U(`h-full`,p),children:[(0,X.jsx)(sr,{model:e,view:t,filter:n,sort:r,columns:y,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:b,...m&&{rowTo:m.rowTo,chosenKey:m.key},...h&&{planned:h}}),m?.details]})},Go=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,children:c,...l}=G(e),{resources:u,views:d}=q(),[f,p]=st([t,t===void 0?void 0:`${t}#total`]),m=(0,Y.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,X.jsx)(Uo,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,X.jsx)(Wo,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,X.jsx)(Ko,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},Ko=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=lt(),a=t=>i({[e]:t}),o=r[e],s=o===void 0?null:(0,X.jsx)(pn,{name:e,children:(0,X.jsx)(_i,{model:n.model,query:{key:o},children:t},o)});return(0,X.jsx)(Wo,{...n,chosen:{rowTo:a,key:o,details:s}})},qo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=a(),{navigate:o}=qe(),s=Mt(e),c=he(s,r),l=e=>i(e===s[0]?.name?void 0:e);return(0,X.jsxs)(`div`,{className:U(`flex flex-col gap-6`,n),children:[(0,X.jsxs)(`select`,{"aria-label":V(`tabs`),value:c?.name??``,onChange:e=>o(l(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!c&&(0,X.jsx)(`option`,{value:``,disabled:!0}),s.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,X.jsx)(`nav`,{"aria-label":V(`tabs`),className:`hidden border-b md:block`,children:(0,X.jsx)(`ul`,{className:`flex gap-1`,children:s.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Ct,{to:l(e.name),"aria-current":e===c?`page`:void 0,className:U(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===c?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),c?(0,X.jsx)(Y.Fragment,{children:t[s.indexOf(c)]},c.name):(0,X.jsx)(rn,{children:V(`noTab`,{name:r??``})})]})},Jo=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Yo=e=>e===void 0?1/0:Date.parse(e),Xo=(e,t)=>{let n=e=>e.more&&e.items.length>0?Yo(e.items.at(-1).time):-1/0,r=Math.max(n(e),n(t)),i=[],a=0,o=0;for(;a<e.items.length||o<t.items.length;){let n=o>=t.items.length||a<e.items.length&&Yo(e.items[a].time)>=Yo(t.items[o].time)?e.items[a++]:t.items[o++];if(Yo(n.time)<r)break;i.push(n)}return i},Zo=({value:e,hints:t,mark:n})=>{let r=d(e,t?.valueLabels);return n===`done`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(sn,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(u,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&Pt(t?.valueColors,e)!==`red`?r:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,X.jsx)(br,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},Qo=({value:e})=>{let t=typeof e==`string`?Pe(e):e;return t===Re?(0,X.jsx)(ie,{children:String(e)}):(0,X.jsx)(x,{value:t})},$o=({label:e,children:t})=>(0,X.jsxs)(`div`,{className:`grid gap-1`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),es=({call:e,statusHints:t})=>{let[n,r]=(0,Y.useState)(!1),i=(0,Y.useId)(),a=e.status!==void 0&&(0,X.jsx)(Zo,{value:e.status,hints:t,mark:e.state}),o=(0,X.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:e.name}),s=e.input!==void 0||e.result!==void 0||e.error!==void 0;return(0,X.jsxs)(`div`,{"data-tool-call":!0,className:`flex min-w-0 flex-col gap-1 pl-11 text-xs text-muted-foreground`,children:[s?(0,X.jsxs)(M,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,X.jsx)(Se,{"aria-hidden":!0,className:U(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,X.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,X.jsx)($o,{label:Q(`callInput`),children:(0,X.jsx)(Qo,{value:e.input})}),e.result!==void 0&&(0,X.jsx)($o,{label:Q(`callResult`),children:(0,X.jsx)(Qo,{value:e.result})}),e.error!==void 0&&(0,X.jsx)($o,{label:Q(`callError`),children:(0,X.jsx)(ie,{children:e.error})})]})]})},ts=(e,t)=>e.map(e=>({kind:`message`,row:e,time:typeof e[t]==`string`?e[t]:void 0})),ns=e=>{if(typeof e==`object`&&e&&`id`in e){let{id:t,name:n}=e;return{id:String(t),...typeof n==`string`&&{name:n}}}return{id:String(e??``),...typeof e==`string`&&{name:e}}},rs=(e,{key:t,sender:n,text:r,status:i},a=Date.now())=>{let o=[],s;for(let c of[...e].reverse()){let e=c.time,l=s?.time!==void 0&&e!==void 0&&te(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:v(e,a)}),c.kind===`call`){o.push(c),s={author:void 0,time:e};continue}let{row:u}=c,d=n===void 0?void 0:ns(u[n]),f=d?.id??``,p=i===void 0||u[i]==null||u[i]===``?void 0:String(u[i]);o.push({kind:`message`,key:t(u),...d&&{author:d},time:e,text:u[r]==null?``:String(u[r]),...p!==void 0&&{status:p},continued:l&&s?.author===f}),s={author:f,time:e}}return o},is=e=>qr.includes(e??``)?e:void 0,as=e=>e==null||e===``?void 0:String(e),os=e=>`call:${JSON.stringify(e)}`,ss=(e,t,n)=>{let r=as(e[n.status]),i=is(r),a=n.input===void 0?void 0:e[n.input],o=n.result===void 0?void 0:e[n.result],s=n.error===void 0?void 0:as(e[n.error]);return{kind:`call`,key:t,name:String(e[n.name]??``),time:typeof e[n.time]==`string`?e[n.time]:void 0,...r!==void 0&&{status:r},...i!==void 0&&{state:i},...a!=null&&{input:a},...o!=null&&{result:o},...s!==void 0&&{error:s}}},cs=({planned:e,limit:t,expanded:n,expand:r,own:i})=>{if(!e)return i;let a=n&&!i.error&&i.pages<2&&(i.pages===0||i.hasNextPage),o={items:e.rows,labels:e.labels??{},hasNextPage:e.rows.length>=t,isFetchingNextPage:a,isFetchNextPageError:!1,isLoading:e.isPending};return n&&i.error&&i.pages===0?{...o,error:i.error,fetchNextPage:i.refetch,refetch:i.refetch}:n&&!a?i:{...o,error:e.error,fetchNextPage:r,refetch:r}},ls=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,Y.useState)(!1),s=Fe(e,{...r,pageSize:t,enabled:n&&(!i||a)}),c=s.data?.pages.length??0,{hasNextPage:l,isFetchingNextPage:u,fetchNextPage:d,error:f}=s;return(0,Y.useEffect)(()=>{i&&a&&!f&&c===1&&l&&!u&&d()},[i,a,f,c,l,u,d]),cs({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},us=(e,t,n)=>{let{views:r}=q(),i=e?.model.name??``,a=ls(i,{filter:e?.filter,orderBy:e&&Ot(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>ss(t,os(h(e.model,t)),e.fields)),hasNextPage:a.hasNextPage,isFetchingNextPage:a.isFetchingNextPage,list:a,statusHints:r[i]?.fields[e.fields.status]}:{calls:[],hasNextPage:!1,isFetchingNextPage:!1,list:a,statusHints:void 0}},ds=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,fs=(e,t)=>e.isLoading?t.loading:t.empty,ps=e=>e.items.length>0&&!!e.error,ms=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),hs=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},gs=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:u,planned:d})=>{let{resources:f,views:p}=q(),m=ee(),g=m?.state.kind===`signed-in`?m.state.user.id:void 0,_=n===void 0?[]:[n],v=$t(f,p,e,_),y=ls(e.name,{filter:t,orderBy:Ot(r),pageSize:o,labels:v},d?.messages),b=us(u,o,d?.calls),x=ds(y);if(x===`error`)return(0,X.jsx)(l,{title:Q(`couldNotLoad`),error:y.error,onRetry:ms(y)});if(x===`loading`)return(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(j,{children:Q(`loadingMessages`)})});let S=kt(f,e,_,y.items,y.labels),C=Xo({items:b.calls,more:b.hasNextPage},{items:ts(S,r),more:y.hasNextPage}),w=rs(C,{key:t=>String(h(e,t)),sender:n,time:r,text:i,status:a}),T=a===void 0?void 0:p[e.name]?.fields[a],E=e.fields[i]!==void 0&&jt(e.fields[i],p[e.name]?.fields[i]),te=w.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===g);return(0,X.jsxs)(X.Fragment,{children:[ps(y)&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(l,{title:Q(`couldNotLoad`),error:y.error,onRetry:ms(y)})}),u&&b.list.error&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(l,{title:Q(`couldNotLoadCalls`),error:b.list.error,onRetry:ms(b.list)})}),(0,X.jsx)(ue,{length:C.length,followKey:te?.key,working:c,empty:fs(b.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:y.hasNextPage||b.hasNextPage?()=>hs([y,b.list]):void 0,loadingEarlier:y.isFetchingNextPage||b.isFetchingNextPage,children:w.map(e=>e.kind===`day`?(0,X.jsx)(xe,{label:e.label},e.key):e.kind===`call`?(0,X.jsx)(es,{call:e,statusHints:b.statusHints},e.key):(0,X.jsx)(pe,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,X.jsx)(Zo,{value:e.status,hints:T}),children:E&&e.text!==``?(0,X.jsx)(le,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},_s=({children:e})=>(0,X.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),vs=({node:e,at:t,slots:n,className:r})=>{let{title:i,description:a,resource:o,filter:s,sender:c,time:l,text:u,status:d,working:f,calls:p,limit:m,empty:h}=G(e),{resources:g}=q(),[_]=jo(f===void 0?[]:[f],R()),[v,y]=st([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let x=p&&g[p.resource];return(0,X.jsx)(`section`,{className:U(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,X.jsx)(T,{title:i,help:a,actions:n.actions,children:(0,X.jsx)(_s,{children:(0,X.jsx)(gs,{model:b,filter:s,sender:c,time:l,text:u,status:d,calls:p&&x&&{model:x,filter:p.filter,fields:p},limit:m,empty:h,working:f===void 0?void 0:_===!0,...(v||y)&&{planned:{messages:v,calls:y}}})})})})},ys=({children:e,className:t})=>(0,X.jsx)(`div`,{className:t,children:e}),bs=({children:e,className:t})=>(0,X.jsx)(`div`,{className:U(`flex`,t),children:e}),xs=({children:e,className:t})=>(0,X.jsx)(`div`,{className:U(`flex flex-col`,t),children:e}),Ss=({node:e,children:t,className:n})=>{let{as:r=`p`}=G(e);return(0,X.jsx)(r,{className:n,children:t})},Cs=({node:e,children:t})=>{let{source:n}=G(e),r=ze(F(R()),n),i=(0,Y.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,X.jsx)(gn,{value:i,children:t})},ws=({node:e,className:t})=>{let{source:n,choices:r,label:i=n,defaultValue:a}=G(e),{values:o,linkTo:s}=lt(),c=o[n];return(0,X.jsxs)(`div`,{className:U(`flex flex-wrap items-center gap-2`,t),children:[(0,X.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:i}),r?(0,X.jsx)(Le,{label:i,value:c??``,options:r.map(e=>({value:String(e.id),label:e.name})),link:e=>s({[n]:a!==void 0&&e===String(a)?void 0:e})}):(0,X.jsx)(`span`,{children:c})]})},Ts=({model:e,filter:t,perPage:n,more:r,planned:i,expanded:a,expand:o,own:s})=>{if(t===void 0)return{read:{isPending:!1,error:null},list:{model:e,items:[]}};if(i&&!a){let t=i.rows.slice(0,n),a=r&&t.length===n?o:void 0;return{read:i,list:{model:e,items:t,planned:!0,...a&&{loadMore:a}}}}if(i&&!s.error&&s.pages<2&&(s.pages===0||s.hasNextPage))return{read:i,list:{model:e,items:i.rows.slice(0,n),planned:!0,loadMore:()=>{},loadingMore:!0}};let c=r&&s.hasNextPage?()=>void s.fetchNextPage():void 0;return{read:{isPending:s.isPending,error:s.error},list:{model:e,items:s.items,...c&&{loadMore:c,loadingMore:s.isFetchingNextPage}}}},Es=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,Y.useState)(!1),c=Fe(e.name,{filter:t,orderBy:n,pageSize:r,enabled:t!==void 0&&(!a||o)}),l=c.data?.pages.length??0,{hasNextPage:u,isFetchingNextPage:d,fetchNextPage:f,error:p}=c;return(0,Y.useEffect)(()=>{a&&o&&!p&&l===1&&u&&!d&&f()},[a,o,p,l,u,d,f]),Ts({model:e,filter:t,perPage:r,more:i,planned:a,expanded:o,expand:()=>s(!0),own:{pages:l,items:c.items,hasNextPage:u,isFetchingNextPage:d,isPending:c.isPending,error:p,fetchNextPage:f}})},Ds=({node:e,at:t,children:n})=>{let r=G(e),i=q().resources[r.reference],a=Ie(F(R())),o=nn(t);return i?(0,X.jsx)(Os,{model:i,...We(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},Os=({empty:e,children:t,...n})=>{let{read:r,list:i}=Es(n);return(0,X.jsx)(On,{read:r,list:i,empty:e,children:t})},ks=({node:e,at:t,children:n})=>{let r=G(e),i=q().resources[r.reference],a=Ie(F(R())),o=nn(t);return i?(0,X.jsx)(Os,{model:i,...re(r,i.primaryKey[0],a),more:!1,empty:r.empty,...o&&{planned:o},children:n}):null},As=({model:e,at:t,recordKey:n,link:r=`edit`,children:i,className:a})=>{let{views:o}=q(),s=nn(t),c=Oe(e,{key:n,enabled:!s}),u=s?En(e,s):c;if(u.isPending)return(0,X.jsx)(A,{className:`h-4 w-24`});if(u.error)return(0,X.jsx)(l,{title:V(`couldNotLoad`),error:u.error});if(!u.data)return null;let d=i.length>0?(0,X.jsx)(dt,{value:u.data,children:i}):je(e,o[e.name],u.data.record,n);return r===!1?(0,X.jsx)(`span`,{className:a,children:d}):(0,X.jsx)(D,{to:{kind:`record`,resource:e.name,key:n},className:a??`font-medium text-primary-text hover:underline`,children:d})},js=({node:e,at:t,children:n,className:r})=>{let{reference:i,source:a,link:o,empty:s}=G(e),c=q().resources[i],l=ze(F(R()),a);return c?l==null||l===``?s===void 0?null:(0,X.jsx)(`span`,{className:r,children:s}):(0,X.jsx)(As,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},Ms=(e,t)=>t.map(t=>Et(e,t)).join(`, `),$=vt(`users`),Ns=({roles:e})=>{let{session:t}=_(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)([]),o=(0,Y.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,Y.useEffect)(o,[o]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Sr,{title:$(`inviteSomeone`),description:$(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,X.jsx)(wr,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,X.jsx)(K,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,X.jsx)(Cr,{email:n.email,gives:Ms(e,n.roles),expiresAt:n.expiresAt,onResend:async()=>{let e=await t.users.invite({email:n.email,roles:n.roles});return o(),e},onRevoke:async()=>{await t.users.revoke(n.id),o()}},n.id))})})]})},Ps=({roles:e,onCreated:t})=>{let{session:n}=_(),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)([]),{busy:d,error:f,run:p}=ct(),m=()=>p(async()=>{await n.users.create({email:r.trim(),name:a.trim(),roles:l,...s&&{password:s}}),i(``),o(``),c(``),u([]),t()}),h=!r.trim()||!a.trim()||l.length===0||s!==``&&s.length<12;return(0,X.jsxs)(K,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,X.jsx)(L,{message:f}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,X.jsx)(N,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,X.jsx)(N,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,X.jsx)(N,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(wr,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,X.jsx)(`div`,{children:(0,X.jsx)(M,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},Fs=({user:e,roles:t,self:n})=>{let{session:r}=_(),[i,a]=(0,Y.useState)(e),{busy:o,error:s,run:c,setError:l}=ct(),u=e=>{if(e.length===0)return l($(`keepOneRole`));c(async()=>{await r.users.setRoles(i.id,e),a({...i,roles:e})})},d=e=>void c(async()=>{await(e?r.users.block(i.id):r.users.unblock(i.id)),a({...i,blocked:e})});return(0,X.jsx)(Tr,{name:i.name,email:i.email,self:n,error:s,actions:(0,X.jsxs)(X.Fragment,{children:[i.blocked&&(0,X.jsx)(H,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,X.jsx)(M,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,X.jsx)(M,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,X.jsx)(wr,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},Is=({roles:e,version:t})=>{let{session:n,state:r}=_(),[i,a]=(0,Y.useState)(``),o=(0,Y.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=Dr(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,X.jsx)(Er,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,X.jsx)(Fs,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},Ls=()=>{let{session:e}=_(),[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)();return(0,Y.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof k?z(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},Rs=()=>{let{roles:e,error:t}=Ls(),[n,r]=(0,Y.useState)(0);return(0,X.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,X.jsx)(L,{message:t}),(0,X.jsx)(Is,{roles:e,version:n}),(0,X.jsx)(Ns,{roles:e}),(0,X.jsx)(Ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},zs=({sender:e,busy:t,error:n,onSave:r,onClose:i})=>{let[a,s]=(0,Y.useState)(e?.address??``),[c,l]=(0,Y.useState)(e?.name??``),[u,d]=(0,Y.useState)(e?.signature??``),[f,p]=(0,Y.useState)(e?.isDefault??!1);return(0,X.jsxs)(o,{title:e?e.address:O(`addFromAddress`),description:O(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:i,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:i,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:t,disabled:!a.trim(),onClick:()=>r({address:a.trim(),name:c.trim(),signature:u,isDefault:f}),children:O(e?`save`:`addAddress`)})]}),children:[!e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`fromAddress`),(0,X.jsx)(N,{autoFocus:!0,type:`email`,value:a,maxLength:254,placeholder:O(`fromAddressPlaceholder`),onChange:e=>s(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[O(`fromName`),(0,X.jsx)(N,{value:c,maxLength:100,placeholder:O(`fromNamePlaceholder`),onChange:e=>l(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{children:O(`defaultFromAddress`)}),(0,X.jsx)(de,{checked:f,onChange:p,label:O(`defaultFromAddress`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[O(`signature`),(0,X.jsx)(Yt,{value:u,maxLength:2e3,placeholder:O(`signaturePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,X.jsx)(L,{message:n})]})},Bs=e=>e.signature?O(`ownSignature`):O(`genericSignature`),Vs=({senders:{address:e,senders:t},onAdd:n,onUpdate:r,onRemove:i})=>{let[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=(0,Y.useRef)(!1),p=t.find(e=>e.isDefault),m=()=>{d(void 0),l(void 0)},h=async e=>{if(!f.current){f.current=!0,s(!0),l(void 0);try{await e(),d(void 0)}catch(e){if(e instanceof TypeError)return l(O(`noAnswerFromServer`));if(!(e instanceof k))throw e;l(z(e))}finally{f.current=!1,s(!1)}}},g=e=>h(async()=>{let t=e.name||null,i=e.signature.trim()?e.signature:null;if(u?.kind===`change`)return r(u.sender.id,{name:t,signature:i,isDefault:e.isDefault});let a=await n({address:e.address,...t&&{name:t},...i&&{signature:i}});e.isDefault&&await r(a.id,{isDefault:!0})});return(0,X.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,X.jsx)(`h3`,{className:`font-semibold`,children:O(`fromAddresses`)}),(0,X.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:O(`fromAddressesDescription`)}),(0,X.jsx)(L,{message:u?void 0:c}),(e||t.length>0)&&(0,X.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:O(`mailboxOwnAddress`)})]}),p?(0,X.jsx)(M,{size:`sm`,variant:`ghost`,loading:a,onClick:()=>void h(()=>r(p.id,{isDefault:!1})),children:O(`makeDefault`)}):(0,X.jsx)(H,{tone:`blue`,children:O(`default`)})]}),t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,X.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Bs(e)})]}),e.isDefault&&(0,X.jsx)(H,{tone:`blue`,children:O(`default`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>d({kind:`change`,sender:e}),children:O(`edit`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>d({kind:`remove`,sender:e}),children:O(`remove`)})]},e.id))]}),(0,X.jsxs)(M,{onClick:()=>d({kind:`add`}),children:[(0,X.jsx)(oe,{className:`size-3.5`}),O(`addFromAddress`)]}),u?.kind===`add`&&(0,X.jsx)(zs,{busy:a,error:c,onSave:e=>void g(e),onClose:m}),u?.kind===`change`&&(0,X.jsx)(zs,{sender:u.sender,busy:a,error:c,onSave:e=>void g(e),onClose:m},u.sender.id),u?.kind===`remove`&&(0,X.jsx)(o,{title:O(`removeFromAddress`,{address:u.sender.address}),description:O(`removeFromAddressDescription`),onClose:m,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:m,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:a,onClick:()=>void h(()=>i(u.sender.id)),children:O(`remove`)})]}),children:(0,X.jsx)(L,{message:c})})]})},Hs=(e,t,n)=>Object.fromEntries(Hn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,f(`signInOnly`,{provider:n(e.provider),name:e.name})])),Us=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=_(),{account:i}=t,[a]=(0,Y.useState)(Gt),o=(0,Y.useCallback)(async()=>{let[t,n,r]=await Promise.all([i.linkedPersonalMail(e),i.linkedProviders(),i.mailSenders()]);return{mail:t,providers:n,senders:r}},[i,e]),{data:s,error:c,reload:l}=W(o,O(`couldNotReadMethods`));return s?(0,X.jsx)(Lt,{title:O(`mailbox`),description:O(`mailboxDescription`),providers:e.map(({id:e,name:t})=>({id:e,name:t})),linked:s.mail,notes:Hs(e,s,e=>r.find(t=>t.id===e)?.name??se(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&bt(a,e.length===1?e[0].name:O(`theProvider`)),children:(0,X.jsx)(Vs,{senders:s.senders,onAdd:async e=>{let t=await i.addMailSender(e);return m(),await l(),t},onUpdate:async(e,t)=>{await i.updateMailSender(e,t),m(),await l()},onRemove:async e=>{await i.removeMailSender(e),m(),await l()}})}):(0,X.jsx)(I,{error:c})},Ws=()=>{let{personalMail:e}=_();return e.length>0?(0,X.jsx)(Us,{links:e}):null},Gs=e=>Or(e.name)??`An unnamed app`,Ks=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),qs=({apps:e,onDisconnect:t})=>{let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(),[s,c]=(0,Y.useState)(),l=async e=>{r(!0),a(void 0);try{await t(e.clientId),c(void 0)}catch(e){if(!(e instanceof k))throw e;a(z(e))}r(!1)};return(0,X.jsxs)(K,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,X.jsx)(L,{message:s?void 0:i}),e.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`No apps are connected. Add this app's MCP address to an AI assistant to connect one.`}):(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=kr(e.clientId);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Pr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:Gs(e)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,ot(Date.parse(e.allowedAt)),` · `,Ks(e)]})]}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>c(e),children:`Disconnect`})]},e.clientId)})}),s&&(0,X.jsx)(o,{title:`Disconnect ${Gs(s)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>c(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>c(void 0),children:`Cancel`}),(0,X.jsx)(M,{variant:`danger`,loading:n,onClick:()=>void l(s),children:`Disconnect`})]}),children:i&&(0,X.jsx)(L,{message:i})})]})},Js=(e,t)=>{let n=new URL(`https://claude.ai/customize/connectors`);return n.searchParams.set(`modal`,`add-custom-connector`),t&&n.searchParams.set(`connectorName`,t),n.searchParams.set(`connectorUrl`,e),n.href},Ys=({url:e,appName:t})=>(0,X.jsx)(K,{title:O(`mcpAddress`),description:O(`mcpAddressDescription`),children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Ar,{value:e,copyLabel:O(`copyMcpAddress`)}),(0,X.jsxs)(`a`,{href:Js(e,t),target:`_blank`,rel:`noreferrer`,className:p(),children:[(0,X.jsx)(b,{className:`size-3.5`}),O(`addToClaude`)]})]})}),Xs=()=>{let{account:e}=_().session,{data:t,error:n,reload:r}=W((0,Y.useCallback)(()=>e.connectedApps(),[e]),O(`couldNotReadMethods`));return t?(0,X.jsx)(qs,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,X.jsx)(I,{error:n})},Zs=({url:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ys,{url:e,appName:q().appName}),(0,X.jsx)(Xs,{})]}),Qs=()=>{let{mcp:e}=_();return e?(0,X.jsx)(Zs,{url:e.url}):null},$s={30:30,90:90,365:365,never:void 0},ec={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},tc=e=>ot(Date.parse(e)),nc=e=>e?O(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:tc(e)}):O(`neverExpires`),rc=e=>[O(`createdOn`,{date:tc(e.createdAt)}),nc(e.expiresAt),e.lastUsedAt?O(`lastUsedOn`,{date:tc(e.lastUsedAt)}):O(`notUsedYet`),e.organization?O(`actsAsIn`,{role:e.role,organization:e.organization}):O(`actsAs`,{role:e.role})].join(` · `),ic=({tokens:e,onCreate:t,onRevoke:n})=>{let[r,i]=(0,Y.useState)(!1),[a,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(`90`),[m,h]=(0,Y.useState)(),g=()=>{l(void 0),s(void 0),h(void 0)},_=(0,Y.useRef)(!1),v=async e=>{if(!_.current){_.current=!0,i(!0),s(void 0);try{l(await e()),h(void 0)}catch(e){if(e instanceof TypeError)return s(O(`noAnswerFromServer`));if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):s(z(e))}finally{_.current=!1,i(!1)}}},y=()=>v(async()=>{let e=$s[f];return{kind:`created`,created:await t({name:u.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,X.jsxs)(K,{title:O(`accessTokens`),description:O(`accessTokensDescription`),children:[(0,X.jsx)(L,{message:c?void 0:a}),e.length===0?(0,X.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:O(`noAccessTokens`)}):(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Ir,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:rc(e)})]}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>l({kind:`revoke`,token:e}),children:O(`revoke`)})]},e.id))}),(0,X.jsxs)(M,{onClick:()=>{d(``),p(`90`),l({kind:`create`})},children:[(0,X.jsx)(oe,{className:`size-3.5`}),O(`newAccessToken`)]}),c?.kind===`create`&&(0,X.jsxs)(o,{title:O(`newAccessToken`),description:O(`newAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:g,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:r,disabled:!u.trim(),onClick:()=>void y(),children:O(`createAccessToken`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`name`),(0,X.jsx)(N,{autoFocus:!0,value:u,maxLength:100,placeholder:O(`accessTokenNamePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[O(`accessTokenExpiry`),(0,X.jsx)(_e,{value:f,onChange:e=>p(e.target.value),children:Object.keys($s).map(e=>(0,X.jsx)(`option`,{value:e,children:O(ec[e])},e))})]}),m===`asked`&&(0,X.jsx)(Sn,{purpose:`change`,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:O(`confirmedCreateAccessToken`)}),(0,X.jsx)(L,{message:a})]}),c?.kind===`created`&&(0,X.jsx)(o,{title:O(`accessTokenCreated`,{name:c.created.personalAccessToken.name}),description:O(`accessTokenCreatedDescription`),onClose:g,actions:(0,X.jsx)(M,{variant:`primary`,onClick:g,children:O(`done`)}),children:(0,X.jsx)(Ar,{value:c.created.token,copyLabel:O(`copyAccessToken`)})}),c?.kind===`revoke`&&(0,X.jsx)(o,{title:O(`revokeAccessToken`,{name:c.token.name}),description:O(`revokeAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:g,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:r,onClick:()=>void v(async()=>(await n(c.token.id),void 0)),children:O(`revoke`)})]}),children:(0,X.jsx)(L,{message:a})})]})},ac=()=>{let{account:e}=_().session,{data:t,error:n,reload:r}=W((0,Y.useCallback)(()=>e.personalAccessTokens(),[e]),O(`couldNotReadAccessTokens`));return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{message:n}),(0,X.jsx)(ic,{tokens:t,onCreate:t=>e.createPersonalAccessToken(t).then(e=>(r(),e),async e=>{throw await r(),e}),onRevoke:t=>e.revokePersonalAccessToken(t).finally(r)})]}):(0,X.jsx)(I,{error:n})},oc=()=>_().personalAccessTokens?(0,X.jsx)(ac,{}):null,sc={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},cc=e=>e.provider===`google`,lc=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[i,a]=(0,Y.useState)(),[s,c]=(0,Y.useState)(r),[l,u]=(0,Y.useState)(),[d,f]=(0,Y.useState)(),p=async(e,t)=>{a(e),c(void 0),f(void 0);try{await t(),u(void 0)}catch(e){if(!(e instanceof k))throw e;c(z(e))}finally{a(void 0)}};return(0,X.jsxs)(K,{title:O(`connections`),description:O(`connectionsDescription`),children:[(0,X.jsx)(L,{message:l?void 0:s}),(0,X.jsx)(ht,{message:d}),(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(Br,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,X.jsx)(M,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void p(e.key,()=>t(e)),children:e.accounts.length>0?O(`connectAgain`,{name:e.label}):O(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[O(`connectedOn`,{date:ot(Date.parse(t.created_at))}),` · `,(0,X.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,X.jsx)(H,{tone:`amber`,children:O(`connectionNeedsSignIn`)}):(0,X.jsx)(H,{tone:`green`,children:O(`connected`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>u({connection:e,accountId:t.id}),children:O(`disconnect`)})]}),t.used_by.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:O(`connectionUsedBy`)}),t.used_by.map(e=>(0,X.jsx)(Ke,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),l&&(0,X.jsx)(o,{title:O(`disconnectTitle`,{name:l.connection.label}),description:cc(l.connection)?`${O(`disconnectDescription`)} ${O(`disconnectWholeGrant`)}`:O(`disconnectDescription`),onClose:()=>u(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>u(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:i===l.accountId,onClick:()=>void p(l.accountId,async()=>f(O(sc[await n(l.accountId)]))),children:O(`disconnect`)})]}),children:s&&(0,X.jsx)(L,{message:s})})]})},uc=()=>{let{session:e,connectAccount:t}=_(),{account:n}=e,[r]=(0,Y.useState)(Gt),{data:i,error:a,reload:o}=W((0,Y.useCallback)(()=>n.workflowConnections(),[n]),O(`couldNotReadMethods`));return i?i.length===0?null:(0,X.jsx)(lc,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&bt(r,O(`theProvider`))}):(0,X.jsx)(I,{error:a})},dc=e=>e.code===`LAST_ADMIN`?O(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?O(`deleteAccountLocked`):z(e),fc=({hasPassword:e,onDelete:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(!1),f=(0,Y.useId)(),p=async()=>{s(!0),l(void 0),d(!1);try{await t(e?r:void 0)}catch(e){if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?d(!0):l(dc(e)),s(!1)}};return(0,X.jsxs)(o,{title:O(`deleteAccountQuestion`),description:O(`deleteAccountWarning`),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:n,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,type:`submit`,form:f,loading:a,disabled:e&&!r,children:O(`deleteAccountConfirm`)})]}),children:[(0,X.jsxs)(`form`,{id:f,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),p()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`deleteAccountPassword`),(0,X.jsx)(N,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,invalid:!!c,onChange:e=>i(e.target.value)})]}),(0,X.jsx)(L,{message:c})]}),u&&(0,X.jsx)(Sn,{purpose:`change`,minutes:15,onConfirmed:()=>void p()})]})},pc=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(K,{title:O(`deleteAccount`),description:O(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,X.jsx)(M,{variant:`danger`,onClick:()=>i(!0),children:O(`deleteAccount`)}),r&&(0,X.jsx)(fc,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},mc=()=>{let{session:e,state:t,deleteAccount:n}=_(),{account:r}=e,{data:i,error:a}=W((0,Y.useCallback)(()=>r.signInMethods(),[r]),O(`couldNotReadMethods`));return i?(0,X.jsx)(pc,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,X.jsx)(I,{error:a})},hc=[[/Edg(e|A|iOS)?\//,`Edge`],[/OPR\/|Opera/,`Opera`],[/SamsungBrowser\//,`Samsung Internet`],[/Firefox\/|FxiOS\//,`Firefox`],[/Chrome\/|CriOS\//,`Chrome`],[/Safari\//,`Safari`]],gc=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/CrOS/,`ChromeOS`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/Linux/,`Linux`]],_c=(e,t)=>e.find(([e])=>e.test(t))?.[1],vc=e=>e?{browser:_c(hc,e),system:_c(gc,e)}:{},yc=e=>e.device?O(`deviceThrough`,{device:e.device,provider:e.name}):e.name,bc=(e,t)=>{if(e.staff)return t?O(`staffOf`,{operator:t}):O(`staff`);let{browser:n,system:r}=vc(e.userAgent);return n&&r?O(`browserOn`,{browser:n,system:r}):r?O(`aBrowserOn`,{system:r}):n??O(`unknownDevice`)},xc=e=>{if(e.staff)return Hr;let{system:t}=vc(e.userAgent);return t===`iPhone`||t===`Android`?Wr:t===`iPad`?Kr:Rr},Sc=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),Cc=(e,t)=>e.kind===`one`?O(`signOutDevice`,{name:bc(e.session,t)}):e.kind===`link`?O(`signOutDevice`,{name:yc(e.link)}):O(`signOutOthersTitle`),wc=e=>O(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),Tc=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(),[d,f]=(0,Y.useState)(),p=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),m=e.filter(e=>!e.current),h=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),g=async e=>{c(!0),u(void 0);try{await h(e),f(void 0)}catch(e){if(!(e instanceof k))throw e;u(z(e))}c(!1)},_=e=>{u(void 0),f(e)};return(0,X.jsxs)(K,{title:O(`devices`),description:O(`devicesDescription`),children:[p.length===0&&n.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:O(`noDevices`)}):(0,X.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[Sc(p).map(e=>{let n=xc(e);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:bc(e,t)}),e.current&&(0,X.jsx)(H,{tone:`green`,children:O(`thisDevice`)})]}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[O(`signedInFromUntil`,{from:Ft(Date.parse(e.createdAt)),until:Ft(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`one`,session:e}),children:O(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Wr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:yc(t)}),n&&(0,X.jsx)(H,{tone:`green`,children:O(`thisDevice`)})]}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:O(`linkedOn`,{date:Ft(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`link`,link:t}),children:O(`signOut`)})]},t.id)})]}),m.length>0&&(0,X.jsx)(M,{className:`mt-3`,onClick:()=>_({kind:`others`}),children:O(`signOutOthers`)}),d&&(0,X.jsx)(o,{title:Cc(d,t),description:wc(d),onClose:()=>f(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>f(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:s,onClick:()=>void g(d),children:O(`signOut`)})]}),children:(0,X.jsx)(L,{message:l})})]})},Ec=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=_(),{account:r}=e,i=(0,Y.useCallback)(async()=>{let[e,t]=await Promise.all([r.sessions(),n?r.deviceLinks():[]]);return{sessions:e,links:t}},[r,n]),{data:a,error:o,reload:s}=W(i,O(`couldNotReadDevices`));return a?(0,X.jsx)(Tc,{sessions:a.sessions,links:a.links,operator:t,onSignOut:e=>r.revokeSession(e).then(s),onSignOutOthers:()=>r.revokeOtherSessions().then(s),onSignOutLink:e=>r.signOutDeviceLink(e).then(s)}):(0,X.jsx)(I,{error:o})},Dc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},Oc=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(),g=e===`required`&&t.length<=1,_=async e=>{s(!0),l(void 0),h(void 0);try{await e(),d(void 0)}catch(e){if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):l(z(e))}s(!1)};return(0,X.jsxs)(K,{title:O(`passkeys`),status:e===`required`&&(0,X.jsx)(H,{tone:`blue`,children:O(`required`)}),description:O(Dc[e]),children:[(0,X.jsx)(L,{message:u?void 0:c}),t.length>0&&(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(S,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??O(`passkey`)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?O(`addedOn`,{date:ot(Date.parse(e.createdAt))}):O(`addedEarlier`),` · `,e.backedUp?O(`synced`):O(`oneDevice`)]})]}),(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>{p(e.name??``),d({kind:`rename`,passkey:e})},children:O(`rename`)}),(0,X.jsx)(M,{size:`sm`,variant:`ghost`,disabled:g,title:g?O(`keepLastPasskey`):void 0,onClick:()=>d({kind:`remove`,passkey:e}),children:O(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,X.jsxs)(M,{loading:a&&!u,onClick:()=>void _(n),children:[(0,X.jsx)(oe,{className:`size-3.5`}),O(`addPasskey`)]}),m===`asked`&&(0,X.jsx)(Sn,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:O(`confirmedAddPasskey`)}),u?.kind===`rename`&&(0,X.jsxs)(o,{title:O(`renamePasskey`),description:O(`renamePasskeyDescription`),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>d(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:a,disabled:!f.trim(),onClick:()=>void _(()=>r(u.passkey.id,f.trim())),children:O(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`name`),(0,X.jsx)(N,{autoFocus:!0,value:f,maxLength:60,onChange:e=>p(e.target.value)})]}),(0,X.jsx)(L,{message:c})]}),u?.kind===`remove`&&(0,X.jsx)(o,{title:O(`removePasskey`),description:O(`removePasskeyDescription`,{name:u.passkey.name??O(`thisPasskey`)}),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>d(void 0),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`danger`,loading:a,onClick:()=>void _(()=>i(u.passkey.id)),children:O(`remove`)})]}),children:c&&(0,X.jsx)(L,{message:c})})]})},kc=()=>{let{account:e}=_().session,t=(0,Y.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=W(t,O(`couldNotReadMethods`));if(!n)return(0,X.jsx)(I,{error:r});let[a,o]=n;return(0,X.jsx)(Oc,{rule:a.policy.passkey,passkeys:o,onAdd:()=>e.addPasskey().then(i),onRename:(t,n)=>e.renamePasskey(t,n).then(i),onRemove:t=>e.removePasskey(t).then(i)})},Ac=e=>e.code===`PASSWORD_TOO_SHORT`?O(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?O(`passwordTooLong`):z(e),jc=(e,t)=>{if(e.length<12)return O(`useAtLeast`,{length:12});if(e!==t)return O(`passwordsDiffer`)},Mc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),m=(0,Y.useId)(),h=(!e||r)&&a&&c,g=async()=>{let e=jc(a,c);if(p(e),!e){d(!0);try{await t({current:r,next:a})}catch(e){if(!(e instanceof k))throw e;p(Ac(e)),d(!1)}}};return(0,X.jsx)(o,{title:O(e?`changePassword`:`setPassword`),description:O(`atLeast`,{length:12}),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:n,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,type:`submit`,form:m,loading:u,disabled:!h,children:O(`save`)})]}),children:(0,X.jsxs)(`form`,{id:m,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),g()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`currentPassword`),(0,X.jsx)(N,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`newPassword`),(0,X.jsx)(N,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!f,onChange:e=>s(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`repeatPassword`),(0,X.jsx)(N,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:c,invalid:!!f,onChange:e=>l(e.target.value)})]}),e&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:O(`changeSignsOutOthers`)}),(0,X.jsx)(L,{message:f})]})})},Nc=({rule:e,hasPassword:t,staff:n})=>O(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),Pc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=!n&&e===`allowed`;return(0,X.jsxs)(K,{title:O(`password`),description:Nc({rule:e,hasPassword:t,staff:n}),children:[(0,X.jsx)(ht,{message:s?O(`passwordSaved`):void 0}),l&&(0,X.jsx)(M,{onClick:()=>{c(!1),o(!0)},children:O(t?`changePassword`:`setPassword`)}),a&&(0,X.jsx)(Mc,{hasPassword:t,onClose:()=>o(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):i(n)),o(!1),c(!0)}})]})},Fc=()=>{let{session:e,state:t}=_(),{account:n}=e,{data:r,error:i,reload:a}=W((0,Y.useCallback)(()=>n.signInMethods(),[n]),O(`couldNotReadMethods`));return r?(0,X.jsx)(Pc,{rule:r.policy.password,hasPassword:r.account.password,staff:t.kind===`signed-in`&&!!t.staff,onChange:(e,t)=>n.changePassword(e,t).then(a),onSet:e=>n.setPassword(e).then(a)}):(0,X.jsx)(I,{error:i})},Ic=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=async e=>{f(!0),m(void 0);try{await e()}catch(e){if(!(e instanceof k))throw e;m(z(e))}f(!1)},g=i.trim(),_=()=>h(async()=>{await t.request(g),u(``),c(g)}),v=e=>h(async()=>{await t.confirm(s,e),n()});return s?(0,X.jsxs)(o,{title:O(`changeEmail`),description:O(`codeSentTo`,{email:s,minutes:10}),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{variant:`ghost`,onClick:()=>{c(void 0),m(void 0)},children:O(`otherAddress`)}),(0,X.jsx)(M,{variant:`primary`,loading:d,disabled:l.length<6,onClick:()=>void v(l),children:O(`changeEmail`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`code`),(0,X.jsx)(ve,{name:`code`,required:!0,autoFocus:!0,value:l,invalid:!!p,onChange:u,onComplete:e=>!d&&void v(e)})]}),(0,X.jsx)(L,{message:p})]}):(0,X.jsxs)(o,{title:O(`changeEmail`),description:O(`changeEmailDescription`),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:r,children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:d,disabled:!g||g.toLowerCase()===e.toLowerCase(),onClick:()=>void _(),children:O(`sendCode`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`newEmail`),(0,X.jsx)(N,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(L,{message:p})]})},Lc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(),g=async()=>{p(!0),h(void 0);try{await n(u.trim()),s(!1)}catch(e){if(!(e instanceof k))throw e;h(z(e))}p(!1)};return(0,X.jsxs)(K,{title:O(`profile`),description:O(`profileDescription`),children:[(0,X.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:O(`name`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:O(`email`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(M,{onClick:()=>{d(e),h(void 0),s(!0)},children:O(`changeName`)}),r&&(0,X.jsx)(M,{onClick:()=>l(!0),children:O(`changeEmail`)})]}),a&&(0,X.jsxs)(o,{title:O(`changeName`),description:O(`changeNameDescription`),onClose:()=>s(!1),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:()=>s(!1),children:O(`cancel`)}),(0,X.jsx)(M,{variant:`primary`,loading:f,disabled:!u.trim()||u.trim()===e,onClick:()=>void g(),children:O(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`name`),(0,X.jsx)(N,{autoFocus:!0,value:u,maxLength:100,onChange:e=>d(e.target.value)})]}),(0,X.jsx)(L,{message:m})]}),c&&r&&(0,X.jsx)(Ic,{email:t,change:r,onClose:()=>l(!1),onDone:()=>{l(!1),i?.()}})]})},Rc=()=>{let{session:e,changeEmail:t}=_(),{data:n,loaded:r,error:i,reload:a}=W((0,Y.useCallback)(()=>e.session(),[e]),O(`couldNotReadProfile`));if(!r)return(0,X.jsx)(I,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,X.jsx)(Lc,{name:n.name,email:n.email,onRename:t=>e.account.updateName(t).then(a),emailChange:o,onEmailChanged:a})},zc=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:s})=>{let[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),[m,h]=(0,Y.useState)(!1),g=async()=>{d(!0),p(void 0),h(!1);try{await a(i?c:void 0)}catch(e){if(!(e instanceof k))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(!0):p(z(e)),d(!1)}};return(0,X.jsxs)(o,{title:e,description:t,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{onClick:s,children:O(`cancel`)}),(0,X.jsx)(M,{variant:r?`danger`:`primary`,loading:u,disabled:i&&!c,onClick:()=>void g(),children:n})]}),children:[i&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[O(`yourPassword`),(0,X.jsx)(N,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:c,invalid:!!f,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&c&&void g()})]}),f&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:f}),m&&(0,X.jsx)(Sn,{purpose:`change`,minutes:15,onConfirmed:()=>void g()})]})},Bc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},Vc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:s,onNewBackupCodes:c,onChanged:l}=e,[u,d]=(0,Y.useState)(),f=()=>d(void 0),p=n?(0,X.jsx)(H,{tone:`green`,children:O(`on`)}):t===`required`?(0,X.jsx)(H,{tone:`amber`,children:O(`required`)}):(0,X.jsx)(H,{children:O(`off`)}),m=O(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:Bc[t]);return u?.kind===`setup`?(0,X.jsx)(K,{title:O(`twoFactor`),status:p,description:m,children:(0,X.jsx)(`div`,{className:`max-w-sm`,children:(0,X.jsx)(hn,{offerEmailedCodes:i&&!u.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:f,onDone:()=>{f(),l()}})})}):(0,X.jsxs)(K,{title:O(`twoFactor`),status:p,description:m,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,X.jsx)(M,{variant:`primary`,onClick:()=>d({kind:`setup`,appOnly:!1}),children:O(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,X.jsx)(M,{onClick:()=>d({kind:`setup`,appOnly:!0}),children:O(`addAuthenticator`)}),n&&r&&(0,X.jsx)(M,{onClick:()=>d({kind:`new-codes`}),children:O(`newBackupCodes`)}),n&&(0,X.jsx)(M,{variant:`danger`,disabled:t===`required`,title:t===`required`?O(`twoFactorIsRequired`):void 0,onClick:()=>d({kind:`turn-off`}),children:O(`turnOff`)})]}),u?.kind===`turn-off`&&(0,X.jsx)(zc,{title:O(`turnOffTitle`),description:O(`turnOffDescription`),confirmLabel:O(`turnOff`),danger:!0,needsPassword:a,onClose:f,onConfirm:async e=>{await s(e),f(),l()}}),u?.kind===`new-codes`&&(0,X.jsx)(zc,{title:O(`newCodesTitle`),description:O(`newCodesDescription`),confirmLabel:O(`makeNewCodes`),needsPassword:a,onClose:f,onConfirm:async e=>d({kind:`codes`,codes:await c(e)})}),u?.kind===`codes`&&(0,X.jsx)(o,{title:O(`yourNewCodes`),description:O(`keepCodesSafe`),onClose:f,actions:(0,X.jsx)(M,{variant:`primary`,onClick:f,children:O(`savedCodes`)}),children:(0,X.jsx)(Dn,{codes:u.codes})})]})},Hc=()=>{let{account:e}=_().session,{data:t,error:n,reload:r}=W((0,Y.useCallback)(()=>e.signInMethods(),[e]),O(`couldNotReadMethods`));return t?(0,X.jsx)(Vc,{rule:t.policy.twoFactor,enabled:t.account.twoFactor,authenticatorApp:t.account.authenticatorApp,mail:t.mail,needsPassword:t.account.password,onStartApp:t=>e.startAuthenticatorApp(t),onConfirmApp:t=>e.confirmAuthenticatorApp(t),onEmailedCodes:t=>e.turnOnEmailedCodes(t),onTurnOff:t=>e.turnOffTwoFactor(t),onNewBackupCodes:t=>e.newBackupCodes(t),onChanged:r}):(0,X.jsx)(I,{error:n})},Uc=({problem:e,fallback:t})=>t===void 0?(0,X.jsx)(rn,{children:e}):(0,X.jsxs)(X.Fragment,{children:[!1,t]}),Wc=({name:e,registered:t,fallback:n,children:r})=>t?(0,X.jsx)(Qe,{name:e,fallback:n===void 0?void 0:(0,X.jsx)(Uc,{problem:V.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,X.jsx)(Uc,{problem:V.rich(`noComponent`,{component:e}),fallback:n}),Gc={Page:to,Grid:ja,Card:di,Stat:Bo,RecordCard:ao,Field:Ea,Diff:Ca,Table:Go,CardRow:hi,RecordRow:To,RecordCards:xo,Chart:gi,Timeline:ta,Graph:aa,Progress:ro,Image:za,ModalForm:eo,Thread:vs,Composer:ba,Action:ui,Show:No,Switch:Fo,Match:Io,Link:Ya,Settings:ko,Tabs:qo,Tab:Jo,Users:Rs,Profile:Rc,Password:Fc,Passkeys:kc,TwoFactor:Hc,ConnectedAccounts:$e,PersonalMail:Ws,Connections:uc,Devices:Ec,ConnectedApps:Qs,PersonalAccessTokens:oc,DeleteAccount:mc,Box:ys,Row:bs,Column:xs,Text:Ss,ReferenceManyField:Ds,ReferenceArrayField:ks,ArrayField:Cs,RecordsIterator:pi,ReferenceField:js,SelectInput:ws,Details:xa,Summary:Sa,TextField:Ha,NumberField:Ua,DateField:Wa,BooleanField:Ga,UrlField:Ka,ChipField:qa},Kc=new Set(`Page.Grid.Card.Stat.RecordCard.Field.Diff.Table.CardRow.RecordRow.RecordCards.Chart.Timeline.Graph.Progress.Image.Thread.Link.Tabs.Settings.Show.Switch.Action.Box.Row.Column.Text.ReferenceField.SelectInput.Details.Summary.TextField.NumberField.DateField.BooleanField.UrlField.ChipField`.split(`.`)),qc=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:ae(t,...n,r)}})),Jc=({text:e})=>{let t=R(),n=an(),r={...F(t),params:n};return(0,X.jsx)(X.Fragment,{children:en(e,e=>dn(ze(r,e)))})},Yc=(e,t)=>e.includes(`{{`)?(0,X.jsx)(Jc,{text:e},t):(0,X.jsx)(Y.Fragment,{children:e},t),Xc=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?Yc(e,n):(0,X.jsx)(rl,{node:e,at:t},n)),Zc=e=>{let t=[];for(let n of e){let e=t.at(-1);Xr(n.child)&&e&&Xr(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Xr(n.child)?(0,X.jsx)(`p`,{className:`leading-6`,children:Xc(e)},t):(0,X.jsx)(rl,{node:n.child,at:n.at},t)})},Qc=e=>tn(e)||Array.isArray(e)&&e.length>0&&e.every(tn),$c=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>Qc(n)?[[e,(0,X.jsx)(X.Fragment,{children:Zc(el(n,t,e))})]]:[])),el=(e,t,n)=>Array.isArray(e)?qc(e,t,`props`,n):[{child:e,...t!==void 0&&{at:ae(t,`props`,n)}}],tl=e=>typeof e==`object`&&!!e&&!Array.isArray(e),nl=(e,t)=>{let n=tl(e.props.components)?e.props.components:{},r=Object.fromEntries(Object.entries(n).flatMap(([e,t])=>tn(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=Mn(t,String(e.props.i18nKey),tl(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||tn(e)?e:String(e)):[i]},rl=({node:e,at:t})=>{let{components:n}=y(),r=R(),i=an(),a=Cn(),o=(0,Y.useMemo)(()=>ke(w(e,{...F(r),params:i}),a),[e,r,i,a]);if(o.type===`Trans`&&!o.custom)return(0,X.jsx)(X.Fragment,{children:Xc(nl(o,a).map(e=>({child:e})))});if(o.custom){let e=n?.[o.type],r=o.children.length>0?(0,X.jsx)(na,{node:o,children:Zc(qc(o.children,t,`children`))}):void 0;return(0,X.jsx)(Wc,{name:o.type,registered:!!e,fallback:o.fallback&&(0,X.jsx)(X.Fragment,{children:Zc(qc(o.fallback,t,`fallback`))}),children:e&&(0,X.jsx)(Vt,{node:o,...t!==void 0&&{at:t},children:(0,X.jsx)(e,{...Be(o.props),children:r})})})}let s=Gc[o.type];if(!s)return(0,X.jsx)(rn,{children:V.rich(`unknownBlock`,{type:o.type})});let c=typeof o.props.className==`string`?o.props.className:void 0,l=qc(o.children,t,`children`),u=(0,X.jsx)(s,{node:o,at:t,slots:$c(o,t),className:c,children:o.type===`Text`||o.type===`Link`||o.type===`Summary`?Xc(l):Zc(o.type===`Switch`?l.filter(({child:e})=>typeof e!=`string`):l)}),d=c===void 0||Kc.has(o.type)?u:(0,X.jsx)(`div`,{className:c,children:u});return o.fallback?(0,X.jsx)(Qe,{name:o.type,resetKey:o,fallback:(0,X.jsx)(X.Fragment,{children:Zc(qc(o.fallback,t,`fallback`))}),children:d}):d};export{ms as a,ns as c,yo as d,lo as f,ua as h,gs as i,Vo as l,ya as m,Wc as n,ps as o,oo as p,_s as r,ds as s,rl as t,Ao as u};
3
+ //# debugId=e8075936-5920-4b33-9cdd-6e307ba45c7e
@@ -0,0 +1,2 @@
1
+ (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{Cc as r,Cr as i,Fa as a,Ga as o,Ja as s,Ml as c,Ol as l,Pa as u,Sc as d,Tc as f,Ti as p,Tl as m,Ts as h,fn as g,fu as _,gl as v,hl as y,ir as b,lc as x,mu as S,ol as C,qr as w,rr as T,si as E,so as D,ti as O,tl as k,uc as A,vs as j,wn as M}from"./app-Bb88M0VJ.js";import{h as N,o as P}from"./vendor-t7Q7QbPu.js";import{Q as F}from"./embedded-list-DjvOszEj.js";import{n as I}from"./lib-dnd-kit-sortable-CNDSKqCD.js";import{a as L,i as R,n as z,o as B,r as ee,s as V,t as H}from"./messages-BIP4feL2.js";var U={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};U.node;var W=C(U),G={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};G.node;var K=C(G),q=e(t(),1),J=v(`app/delete`),Y=_(),X=({blockingPlural:e,noun:t})=>J(`stillPointAt`,{plural:e,noun:t}),Z=({blockedBy:e,resources:t,views:n,noun:r,key:i})=>{let{resource:a,field:o}=e;if(!t[a])return;let s=n[a]?.names?.plural??l(a),c=X({blockingPlural:s,noun:r});if(!o||i===void 0)return{text:c};let u={kind:`list`,resource:a,filter:S(Y.eq(o,i))};return{text:c,link:{label:J(`show`,{plural:s}),to:u}}},Q=e(n(),1),te=({title:e,noun:t,busy:n,onConfirm:i,onCancel:a})=>(0,Q.jsx)(r,{title:J(`confirmTitle`,{title:e}),description:J(`confirmDescription`,{noun:t,title:e}),onClose:a,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(f,{onClick:a,children:J(`cancel`)}),(0,Q.jsx)(f,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:i,children:J(`delete`)})]})}),ne=({title:e,changes:t,busy:n,onReview:i,onDeleteAnyway:a,onCancel:o})=>(0,Q.jsx)(r,{title:J(`changedTitle`,{title:e}),description:J(`changedDescription`),onClose:o,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(f,{onClick:i,children:J(`reviewChanges`)}),(0,Q.jsx)(f,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:a,children:J(`deleteAnyway`)})]}),children:t.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noVisibleChanges`)}):(0,Q.jsx)(`ul`,{className:`divide-y rounded-md border`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`grid grid-cols-[96px_1fr] gap-3 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.after})]})]},e.field))})}),$=e=>{if(e.stage===`confirm`)return(0,Q.jsx)(r,{title:J(`bulkConfirmTitle`,{count:e.count,noun:e.noun,plural:e.plural}),description:J(`bulkConfirmDescription`),onClose:e.onCancel,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(f,{onClick:e.onCancel,children:J(`cancel`)}),(0,Q.jsx)(f,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,onClick:e.onConfirm,children:J(`deleteCount`,{count:e.count})})]})});if(e.stage===`running`)return(0,Q.jsx)(r,{title:J(`deleting`),description:J(`progress`,{done:e.done,total:e.total}),onClose:()=>void 0,actions:(0,Q.jsx)(f,{loading:!0,disabled:!0,children:J(`working`)})});let t=e.total-e.failures.length;return(0,Q.jsx)(r,{title:e.failures.length===0?J(`deleted`,{count:t}):J(`deletedOf`,{count:t,total:e.total}),description:e.failures.length===0?void 0:J(`kept`,{count:e.failures.length}),onClose:e.onClose,actions:(0,Q.jsx)(f,{variant:`primary`,onClick:e.onClose,children:J(`done`)}),children:e.failures.length>0&&(0,Q.jsx)(`ul`,{className:`max-h-48 divide-y overflow-y-auto rounded-md border`,children:e.failures.map(e=>(0,Q.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-danger-text`,children:e.message})]},e.title))})})},re=new Set([`updated_at`,`updatedAt`]),ie=(e,t,n,r)=>Object.values(e.fields).flatMap(e=>{if(re.has(e.name)||JSON.stringify(n[e.name]??null)===JSON.stringify(r[e.name]??null))return[];let i=t?.fields[e.name];return[{field:e.name,label:i?.label??l(e.name),before:p(e,n[e.name],i),after:p(e,r[e.name],i)}]}),ae=4,oe=({model:e,view:t,onDeleted:n,onReview:r,restore:i})=>{let a=h(),o=N(),c=s(),[u,d]=(0,q.useState)(),[f,p]=(0,q.useState)(!1),m=t?.names?.singular??l(e.name),g=t?.names?.plural??l(e.name),{resources:_,views:v}=j(),{href:y,open:b}=w(),S=(t,n)=>t.blockedBy&&Z({blockedBy:t.blockedBy,resources:_,views:v,noun:m,...e.primaryKey.length===1&&{key:n.key}}),C=()=>{for(let t of[`page`,`list`,`first-page`,`map`])o.invalidateQueries({queryKey:[t,e.name]});for(let t of[`facets`,`series`,`aggregate`,`histogram`,`count`])o.invalidateQueries({queryKey:[t,e.name]})},T=async(t,n)=>{let r=n??(await a.get(e.name,t.key)).etag;try{await a.remove(e.name,t.key,{etag:r})}catch(e){if(!(e instanceof x))throw e;return e}},E=t=>{C(),d(void 0),n?.(t),c.show({state:`success`,title:J(`deletedToast`,{title:t.title}),...e.softDelete&&i&&{action:{label:J(`undo`),onClick:()=>{i(t).then(()=>{C(),c.show({state:`success`,title:J(`restored`,{title:t.title})})},e=>{if(!A(e))throw e;C(),c.show({state:e.status===409?`success`:`error`,title:e.status===409?J(`alreadyBack`,{title:t.title}):J(`couldNotRestore`,{title:t.title}),description:e.status===409?void 0:e.message})})}}}})},D=async(n,r)=>{p(!0);try{if(!await T(n,r))return E(n);let i=(await a.get(e.name,n.key)).record;d({kind:`conflict`,target:n,fresh:i,changes:ie(e,t,n.snapshot,i)})}catch(e){if(!A(e))throw e;d(void 0);let t=S(e,n);c.show({state:`error`,title:J(`couldNotDelete`,{title:n.title}),description:t?.text??e.message,...t?.link&&{action:{label:t.link.label,href:y(t.link.to),onNavigate:b}}})}finally{p(!1)}},O=async e=>{try{return await T(e,e.etag)?{title:e.title,message:J(`changedSinceLoaded`)}:void 0}catch(t){if(!A(t))throw t;return{title:e.title,message:S(t,e)?.text??t.message}}},k=async e=>{let t=[],n=[],r=0;d({kind:`bulk-running`,done:r,total:e.length});let i=[...e];return await Promise.all(Array.from({length:Math.min(ae,e.length)},async()=>{for(let a=i.shift();a;a=i.shift()){let i=await O(a);i&&(t.push(i),n.push(a)),r+=1,d({kind:`bulk-running`,done:r,total:e.length})}})),C(),d({kind:`bulk-done`,total:e.length,failures:t}),n},M=()=>d(void 0);return{dialogs:u&&(0,Q.jsxs)(Q.Fragment,{children:[u.kind===`confirm`&&(0,Q.jsx)(te,{title:u.target.title,noun:m,busy:f,onCancel:M,onConfirm:()=>void D(u.target,u.target.etag)}),u.kind===`conflict`&&(0,Q.jsx)(ne,{title:u.target.title,changes:u.changes,busy:f,onCancel:M,onReview:()=>{M(),r?.(u.target,u.fresh)},onDeleteAnyway:()=>void D(u.target,`*`)}),u.kind===`bulk-confirm`&&(0,Q.jsx)($,{stage:`confirm`,count:u.targets.length,noun:m,plural:g,onCancel:()=>{M(),u.settle(u.targets)},onConfirm:()=>u.settle(k(u.targets))}),u.kind===`bulk-running`&&(0,Q.jsx)($,{stage:`running`,done:u.done,total:u.total}),u.kind===`bulk-done`&&(0,Q.jsx)($,{stage:`done`,total:u.total,failures:u.failures,onClose:M})]}),start:t=>e.softDelete?D(t,t.etag):d({kind:`confirm`,target:t}),startBulk:e=>new Promise(t=>d({kind:`bulk-confirm`,targets:e,settle:t}))}},se=e=>{let t=h();return e.softDelete?async n=>void await t.undelete(e.name,n.key):void 0},ce=(e,t,n)=>({order:r,index:i})=>{let o=t=>r.findIndex(n=>c(a(e,n))===t),s=t.after.find(e=>o(e.key)>i);if(s)return H(`dependsOn`,{record:n,other:s.title});let l=t.before.find(e=>o(e.key)!==-1&&o(e.key)<i);return l?H(`dependsOn`,{record:l.title,other:n}):void 0},le=(e,t,n,r)=>{let i=e[t],a;for(let o=n;o<e.length;o++){let n=r({record:i,order:I(e,t,o),index:o});if(n===void 0)return{to:o,...a!==void 0&&{reason:a}};a??=n}return{to:t,reason:a}},ue=({model:e,view:t,field:n,filter:r,fields:i,rule:a})=>{let o=h(),c=s(),l=M(),{resources:d,views:f}=j(),p=`${n} asc`,g=P({queryKey:[...y.list(e.name,r,p,500,`hand-order`),i.join(`,`)],queryFn:async()=>{let t=T(d,f,e,i),n=[],a=``;do{let s=await o.search(e.name,{filter:r||void 0,orderBy:p,pageSize:500,labels:t,...a&&{pageToken:a}});n.push(...b(d,e,i,s.items,s.labels).map((t,n)=>({...t,id:u(e,s.items[n])}))),a=s.nextPageToken}while(a);return n}}),[_,v]=(0,q.useState)(),x=(0,q.useRef)(void 0),S=(0,q.useRef)([]),C=(0,q.useRef)(void 0),w=(0,q.useRef)(Promise.resolve()),E=(0,q.useRef)(0),D=(0,q.useRef)(void 0),k=async()=>{let t=x.current,r=S.current;if(S.current=[],!t||r.length===0)return;let i=await o.batchWrite(r),a=new Map(i.results.flatMap(e=>e.op===`move`?e.records:[]).map(t=>[u(e,t.record),t])),s=z(i.results,t=>u(e,t)),l=L(e,[...a].map(([e,t])=>({...t,before:{[n]:s.get(e)}})),[n]);D.current!==void 0&&c.dismiss(D.current),D.current=c.show({state:`success`,title:V(`orderChanged`),action:{label:V(`undo`),onClick:()=>W(l)}}),x.current&&=x.current.map(e=>{let t=a.get(e.id);return t?{...e,[n]:t.record[n],etag:t.etag}:e})},A=(e,t)=>n=>{x.current=void 0,S.current=[],v(void 0),c.show(B(n,e,{place:`list`,title:t?C.current:void 0}))},N=async()=>{--E.current,!(E.current>0)&&(await l(e.name),!(E.current>0)&&(x.current=void 0,v(void 0)))},F=(n,r)=>{let i=x.current??g.data;if(!i||n===r)return;if(!e.position?.after)return H(i,n,r,a);let s=O(e,i[n]).record,c=i[n].id;R(o,e,t,s).then(n=>{let i=x.current??g.data,o=ce(e,n,m(e,t,s,c));H(i,i.findIndex(e=>e.id===c),r,e=>o(e)??a?.(e))},A(V(`couldNotChange`),!1))},H=(i,a,o,s)=>{if(a===-1||a===o)return;let c=s?U(i,a,o,s):o;a!==c&&(x.current=I(i,a,c),S.current=[...S.current,ee(e,n,r,x.current,c)],v(x.current),E.current+=1,C.current=m(e,t,O(e,i[a]).record,i[a].id),w.current=w.current.then(k).catch(A(V(`couldNotChange`),!0)).then(N))},U=(t,n,r,i)=>{let a=le(t.map(t=>O(e,t).record),n,r,i);return a.reason!==void 0&&c.show({state:`warning`,title:a.to===n?V(`notMoved`):V(`movedToPlace`,{place:a.to+1}),description:a.reason}),a.to},W=e=>{D.current!==void 0&&c.dismiss(D.current),D.current=void 0,E.current+=1,w.current=w.current.then(async()=>{await o.batchWrite(e),x.current=void 0,S.current=[],v(void 0)}).catch(A(V(`couldNotUndo`),!1)).then(N)};return{rows:_??g.data,loading:g.isPending,error:g.error,move:F}},de=({model:e,view:t,field:n,filter:r,columns:s,sort:c})=>{let{resources:l,views:u}=j(),{fields:f,dropRules:p}=o(),{go:h,href:_}=w(),v=c!==void 0,y=(0,q.useMemo)(()=>g(e,t,s,{resources:l,views:u,fieldTypes:f}).map(e=>v?e:{...e,sortable:!1}),[e,t,s.join(`,`),l,u,f,v]),b=(0,q.useMemo)(()=>E(e,t,y.map(e=>e.id)),[e,t,y]),x=t?.list?.drag?.rule,S=x===void 0?void 0:p?.[x],C=ue({model:e,view:t,field:n,filter:r,fields:b,...S&&{rule:S}}),T=C.rows,O=(0,q.useMemo)(()=>T&&{total:T.length,rowAt:e=>T[e]},[T]);if(x!==void 0&&!S)return(0,Q.jsx)(D,{children:V.rich(`noRule`,{rule:x})});if(C.loading)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Q.jsx)(d,{className:`h-4 w-full`},t))});if(C.error)return(0,Q.jsx)(i,{title:V(`couldNotLoad`),error:C.error});if(!O||O.total===0)return(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:V(`nothingYet`)});let k=t=>h({kind:`record`,resource:e.name,key:a(e,t)});return(0,Q.jsx)(F,{fit:!0,scroll:`parent`,columns:y,source:O,latencyMs:0,onOpenRow:k,rowLink:t=>({href:_({kind:`record`,resource:e.name,key:a(e,t)}),onFollow:()=>k(t)}),...c&&{sort:c.value,onSortChange:c.onChange},rowNumbers:!1,reorder:{label:n=>m(e,t,n,n.id),onMove:C.move}})},fe=({sorting:e,onChange:t,size:n,iconOnly:r=!1})=>{let i=V(e?`done`:`reorder`);return(0,Q.jsxs)(f,{size:n,variant:e?`primary`:`secondary`,onClick:()=>t(!e),...r&&{"aria-label":i,title:i},children:[e?(0,Q.jsx)(k,{className:`size-3.5`}):(0,Q.jsx)(W,{className:`size-3.5`}),!r&&i]})};export{K as a,oe as i,de as n,se as r,fe as t};
2
+ //# debugId=a0f962ae-b528-47c1-9911-fe674ad230b2
@@ -1,2 +1,2 @@
1
- (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{gc as r,yr as i}from"./app-B3ocPAqs.js";import{t as a}from"./workflow-canvas-D1yNhbc_.js";import{a as o,i as s,n as c}from"./step-panel-C6qUOSA3.js";import{t as l}from"./use-run-trace-D3CBWHfm.js";import{t as u}from"./use-workflow-types-D0XJQUAl.js";import{n as d,t as f}from"./graph-frame-PVfWqgbJ.js";var p=e(t(),1),m=e(n(),1),h=new Map,g=({trace:e,types:t,notice:n,idle:l})=>{let{definition:u,steps:g,going:_,place:v}=e,y=(0,p.useMemo)(()=>v&&o(g,{inProgress:_,...v}),[v,g,_]),[b,x]=(0,p.useState)();if(e.error)return(0,m.jsx)(i,{error:e.error,title:s(`loadFailed`)});if(!e.run||!e.id||!u||!y)return(0,m.jsx)(r,{className:`h-[28rem] w-full max-sm:h-[22rem]`});let S=[...y].filter(([,e])=>e.status===`failed`).map(([e])=>e).sort((e,t)=>t.split(`/`).length-e.split(`/`).length)[0],C=b===void 0?S:b??void 0,w={...e.run,id:e.id,created_at:String(e.run.created_at)};return(0,m.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!_&&g.length===0&&(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`noTrace`)}),(0,m.jsx)(f,{canvas:(0,m.jsx)(a,{definition:u,problems:h,selected:C,onSelect:e=>x(e??null),traces:y,...t&&{types:t}}),panel:(0,m.jsxs)(m.Fragment,{children:[n,C===void 0?l??(0,m.jsx)(d,{children:s(`pickNode`)}):(0,m.jsx)(c,{definition:u,run:w,selected:C,...t&&{types:t}})]})})]})},_=({runId:e})=>{let t=l(e),n=u().data;return(0,m.jsx)(g,{trace:t,...n&&{types:n}})};export{_ as RunTrace};
2
- //# debugId=74da881f-0a0a-42a6-9639-66d6e1c61d57
1
+ (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{Cr as r,Sc as i}from"./app-Bb88M0VJ.js";import{t as a}from"./workflow-canvas-CJQ0Ll0M.js";import{a as o,i as s,n as c}from"./step-panel-CjUWMleA.js";import{t as l}from"./use-run-trace-b8SpFDRU.js";import{t as u}from"./use-workflow-types-D1TLbN3E.js";import{n as d,t as f}from"./graph-frame-PVfWqgbJ.js";var p=e(t(),1),m=e(n(),1),h=new Map,g=({trace:e,types:t,notice:n,idle:l})=>{let{definition:u,steps:g,going:_,place:v}=e,y=(0,p.useMemo)(()=>v&&o(g,{inProgress:_,...v}),[v,g,_]),[b,x]=(0,p.useState)();if(e.error)return(0,m.jsx)(r,{error:e.error,title:s(`loadFailed`)});if(!e.run||!e.id||!u||!y)return(0,m.jsx)(i,{className:`h-[28rem] w-full max-sm:h-[22rem]`});let S=[...y].filter(([,e])=>e.status===`failed`).map(([e])=>e).sort((e,t)=>t.split(`/`).length-e.split(`/`).length)[0],C=b===void 0?S:b??void 0,w={...e.run,id:e.id,created_at:String(e.run.created_at)};return(0,m.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!_&&g.length===0&&(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`noTrace`)}),(0,m.jsx)(f,{canvas:(0,m.jsx)(a,{definition:u,problems:h,selected:C,onSelect:e=>x(e??null),traces:y,...t&&{types:t}}),panel:(0,m.jsxs)(m.Fragment,{children:[n,C===void 0?l??(0,m.jsx)(d,{children:s(`pickNode`)}):(0,m.jsx)(c,{definition:u,run:w,selected:C,...t&&{types:t}})]})})]})},_=({runId:e})=>{let t=l(e),n=u().data;return(0,m.jsx)(g,{trace:t,...n&&{types:n}})};export{_ as RunTrace};
2
+ //# debugId=a6ba37a5-59d6-48e7-8394-7dcb887e7cd8
@@ -1,2 +1,2 @@
1
- (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{aa as r,gl as i,nc as a,ul as o,yc as s,ys as c}from"./app-B3ocPAqs.js";import{t as l}from"./copy-field-CpG80Fod.js";var u=e(t(),1),d=o(`app/field-types/runner-install`),f=e(n(),1),p=e=>e instanceof a?e.slug===`runner-registered`?d(`registered`):e.slug===`runner-revoked`?d(`revoked`):e.status===404?d(`notYours`):d(`failed`):d(`failed`),m=({value:e})=>{let t=c(),[n,i]=(0,u.useState)(),[a,o]=(0,u.useState)(!1),[m,h]=(0,u.useState)();if(e===null)return null;let g=async()=>{o(!0),h(void 0),await t.runnerRegistration(e).then(i,e=>h(p(e))),o(!1)};return(0,f.jsxs)(`div`,{className:`grid gap-2`,children:[n&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(l,{value:n.command,copyLabel:d(`copy`)}),(0,f.jsx)(`p`,{className:`text-body text-muted-foreground`,children:d(`shownOnce`,{until:r(Date.parse(n.expires_at))})})]}),m&&(0,f.jsx)(`p`,{role:`alert`,className:`text-body text-danger-text`,children:m}),(0,f.jsx)(s,{size:`sm`,variant:n?`secondary`:`primary`,className:`justify-self-start`,loading:a,onClick:()=>void g(),children:d(n?`again`:`issue`)})]})},h={of:[...i.runner_install],display:m,cell:()=>null};export{h as runnerInstallField};
2
- //# debugId=7b776653-7558-4fd9-8694-4930f27cec79
1
+ (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{Sl as r,Tc as i,Ts as a,cc as o,gl as s,la as c}from"./app-Bb88M0VJ.js";import{t as l}from"./copy-field-D22CFeg3.js";var u=e(t(),1),d=s(`app/field-types/runner-install`),f=e(n(),1),p=e=>e instanceof o?e.slug===`runner-registered`?d(`registered`):e.slug===`runner-revoked`?d(`revoked`):e.status===404?d(`notYours`):d(`failed`):d(`failed`),m=({value:e})=>{let t=a(),[n,r]=(0,u.useState)(),[o,s]=(0,u.useState)(!1),[m,h]=(0,u.useState)();if(e===null)return null;let g=async()=>{s(!0),h(void 0),await t.runnerRegistration(e).then(r,e=>h(p(e))),s(!1)};return(0,f.jsxs)(`div`,{className:`grid gap-2`,children:[n&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(l,{value:n.command,copyLabel:d(`copy`)}),(0,f.jsx)(`p`,{className:`text-body text-muted-foreground`,children:d(`shownOnce`,{until:c(Date.parse(n.expires_at))})})]}),m&&(0,f.jsx)(`p`,{role:`alert`,className:`text-body text-danger-text`,children:m}),(0,f.jsx)(i,{size:`sm`,variant:n?`secondary`:`primary`,className:`justify-self-start`,loading:o,onClick:()=>void g(),children:d(n?`again`:`issue`)})]})},h={of:[...r.runner_install],display:m,cell:()=>null};export{h as runnerInstallField};
2
+ //# debugId=30a68220-9e4b-490f-a883-2a062c8cea5f
@@ -1,2 +1,2 @@
1
- (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{Za as r,_c as i,aa as a,ac as o,el as s,ic as c,nc as l,ra as u,ul as d,va as f,xc as p,yc as m}from"./app-B3ocPAqs.js";var h={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};h.node;var g=s(h),_=e=>typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!==null&&`code`in e.error&&`message`in e.error,v=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.clone().json():void 0;return _(t)?new l({type:`urn:protobase:problem:${t.error.code}`,title:e.statusText||`Request failed`,status:e.status,detail:t.error.message}):o(e)},y=e=>{let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>fetch(e,t)),r=async(r,i)=>{let a=await e.token(),o=await n(`${t}${r}`,{method:i,headers:{accept:`application/json`,...a&&{authorization:`Bearer ${a}`}}});if(!o.ok)throw await v(o);return await o.json()};return{status:()=>r(``,`GET`),update:()=>r(`/update`,`POST`)}},b=e(t(),1),x=d(`app/runtime`),S=e=>!!(e?.updateAvailable&&e.indicator),C=e=>e?5e3:18e5,w=(e,t)=>{if(!e.updateStage)return x(`updatingNow`);let n=x(e.updateStage);if(!e.updateStartedAt)return n;let r=Math.max(0,Math.floor((t-Date.parse(e.updateStartedAt))/1e3));return x(`started`,{stage:n,ago:u(r)})},T=(e,t=Date.now(),n=f())=>e.updating?w(e,t):e.nextUpdateAt?x(`nextOn`,{policy:x(e.policy),when:a(Date.parse(e.nextUpdateAt),n)}):x(e.policy),E=(e,t=f())=>{let n=a(Date.parse(e.finishedAt),t),r=x(e.outcome,{version:e.toVersion,when:n});return e.message?`${r}: ${e.message}`:`${r}.`},D=e=>c(e)&&e.status<500&&e.problem.detail?e.problem.detail:c(e)&&e.status===409?x(`alreadyLatest`):c(e)&&e.status===403?x(`onlyAdmin`):x(`couldNotStart`),O=e(n(),1),k=({label:e,value:t})=>(0,O.jsxs)(`div`,{className:`flex justify-between gap-4 py-1`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,O.jsx)(`span`,{className:`font-medium tabular-nums`,children:t})]}),A=({status:e,requesting:t,error:n,checkError:r,onUpdate:a,onClose:o})=>{let s=e.updating?void 0:e.lastUpdate;return(0,O.jsxs)(i,{title:x(`runtimeUpdate`),description:e.updating?(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,O.jsx)(p,{className:`size-3.5`}),T(e)]}):T(e),onClose:o,actions:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(m,{onClick:o,children:x(`close`)}),(0,O.jsx)(m,{variant:`primary`,loading:t,disabled:e.updating||!e.updateAvailable,onClick:a,children:e.updating?x(`updating`):x(`updateNow`)})]}),children:[(0,O.jsx)(k,{label:x(`currentVersion`),value:e.version}),(0,O.jsx)(k,{label:x(`latestVersion`),value:e.latest}),s&&(0,O.jsx)(`p`,{className:s.outcome===`failed`?`mt-3 text-danger-text`:`mt-3 text-muted-foreground`,children:E(s)}),n!==void 0&&(0,O.jsx)(`p`,{role:`alert`,className:`mt-3 text-danger-text`,children:D(n)}),r!==void 0&&(0,O.jsx)(`p`,{className:`mt-3 text-muted-foreground`,children:x(`checkFailed`)})]})},j=e=>{let t=r(),n=(0,b.useRef)(t);n.current=t;let i=t!==void 0;return(0,b.useMemo)(()=>i?y({url:e,token:()=>n.current}):void 0,[e,i])},M=e=>{let[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(),l=t?.updating??!1;return(0,b.useEffect)(()=>{if(!e)return;let t=!0,r=()=>e.status().then(e=>{t&&(n(e),c(void 0))},e=>t&&c(e));r();let i=setInterval(()=>void r(),C(l));return()=>{t=!1,clearInterval(i)}},[e,l]),{status:t,update:(0,b.useCallback)(async()=>{e&&(i(!0),o(void 0),await e.update().then(n,o),i(!1))},[e]),requesting:r,error:a,checkError:s}},N=({client:e})=>{let{status:t,update:n,requesting:r,error:i,checkError:a}=M(e),[o,s]=(0,b.useState)(!1);return!t||!o&&!S(t)?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(m,{size:`sm`,variant:`ghost`,"aria-label":x(`updateAvailable`),title:x(`updateAvailable`),onClick:()=>s(!0),className:`max-md:size-9 max-md:p-0`,children:[(0,O.jsx)(g,{className:`size-3.5 text-primary`}),(0,O.jsx)(`span`,{className:`max-md:sr-only`,children:x(`update`)})]}),o&&(0,O.jsx)(A,{status:t,requesting:r,error:i,checkError:a,onUpdate:()=>void n(),onClose:()=>s(!1)})]})},P=({url:e})=>(0,O.jsx)(N,{client:j(e)}),F=({url:e,client:t})=>t?(0,O.jsx)(N,{client:t}):(0,O.jsx)(P,{url:e});export{F as RuntimeUpdateButton};
2
- //# debugId=0b5dd35f-2998-4d1c-a2ae-35bc6509ad67
1
+ (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{Cc as r,Dc as i,Sa as a,Tc as o,cc as s,dc as c,gl as l,la as u,ol as d,ro as f,sa as p,uc as m}from"./app-Bb88M0VJ.js";var h={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};h.node;var g=d(h),_=e=>typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!==null&&`code`in e.error&&`message`in e.error,v=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.clone().json():void 0;return _(t)?new s({type:`urn:protobase:problem:${t.error.code}`,title:e.statusText||`Request failed`,status:e.status,detail:t.error.message}):c(e)},y=e=>{let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>fetch(e,t)),r=async(r,i)=>{let a=await e.token(),o=await n(`${t}${r}`,{method:i,headers:{accept:`application/json`,...a&&{authorization:`Bearer ${a}`}}});if(!o.ok)throw await v(o);return await o.json()};return{status:()=>r(``,`GET`),update:()=>r(`/update`,`POST`)}},b=e(t(),1),x=l(`app/runtime`),S=e=>!!(e?.updateAvailable&&e.indicator),C=e=>e?5e3:18e5,w=(e,t)=>{if(!e.updateStage)return x(`updatingNow`);let n=x(e.updateStage);if(!e.updateStartedAt)return n;let r=Math.max(0,Math.floor((t-Date.parse(e.updateStartedAt))/1e3));return x(`started`,{stage:n,ago:p(r)})},T=(e,t=Date.now(),n=a())=>e.updating?w(e,t):e.nextUpdateAt?x(`nextOn`,{policy:x(e.policy),when:u(Date.parse(e.nextUpdateAt),n)}):x(e.policy),E=(e,t=a())=>{let n=u(Date.parse(e.finishedAt),t),r=x(e.outcome,{version:e.toVersion,when:n});return e.message?`${r}: ${e.message}`:`${r}.`},D=e=>m(e)&&e.status<500&&e.problem.detail?e.problem.detail:m(e)&&e.status===409?x(`alreadyLatest`):m(e)&&e.status===403?x(`onlyAdmin`):x(`couldNotStart`),O=e(n(),1),k=({label:e,value:t})=>(0,O.jsxs)(`div`,{className:`flex justify-between gap-4 py-1`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,O.jsx)(`span`,{className:`font-medium tabular-nums`,children:t})]}),A=({status:e,requesting:t,error:n,checkError:a,onUpdate:s,onClose:c})=>{let l=e.updating?void 0:e.lastUpdate;return(0,O.jsxs)(r,{title:x(`runtimeUpdate`),description:e.updating?(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,O.jsx)(i,{className:`size-3.5`}),T(e)]}):T(e),onClose:c,actions:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(o,{onClick:c,children:x(`close`)}),(0,O.jsx)(o,{variant:`primary`,loading:t,disabled:e.updating||!e.updateAvailable,onClick:s,children:e.updating?x(`updating`):x(`updateNow`)})]}),children:[(0,O.jsx)(k,{label:x(`currentVersion`),value:e.version}),(0,O.jsx)(k,{label:x(`latestVersion`),value:e.latest}),l&&(0,O.jsx)(`p`,{className:l.outcome===`failed`?`mt-3 text-danger-text`:`mt-3 text-muted-foreground`,children:E(l)}),n!==void 0&&(0,O.jsx)(`p`,{role:`alert`,className:`mt-3 text-danger-text`,children:D(n)}),a!==void 0&&(0,O.jsx)(`p`,{className:`mt-3 text-muted-foreground`,children:x(`checkFailed`)})]})},j=e=>{let t=f(),n=(0,b.useRef)(t);n.current=t;let r=t!==void 0;return(0,b.useMemo)(()=>r?y({url:e,token:()=>n.current}):void 0,[e,r])},M=e=>{let[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(),l=t?.updating??!1;return(0,b.useEffect)(()=>{if(!e)return;let t=!0,r=()=>e.status().then(e=>{t&&(n(e),c(void 0))},e=>t&&c(e));r();let i=setInterval(()=>void r(),C(l));return()=>{t=!1,clearInterval(i)}},[e,l]),{status:t,update:(0,b.useCallback)(async()=>{e&&(i(!0),o(void 0),await e.update().then(n,o),i(!1))},[e]),requesting:r,error:a,checkError:s}},N=({client:e})=>{let{status:t,update:n,requesting:r,error:i,checkError:a}=M(e),[s,c]=(0,b.useState)(!1);return!t||!s&&!S(t)?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(o,{size:`sm`,variant:`ghost`,"aria-label":x(`updateAvailable`),title:x(`updateAvailable`),onClick:()=>c(!0),className:`max-md:size-9 max-md:p-0`,children:[(0,O.jsx)(g,{className:`size-3.5 text-primary`}),(0,O.jsx)(`span`,{className:`max-md:sr-only`,children:x(`update`)})]}),s&&(0,O.jsx)(A,{status:t,requesting:r,error:i,checkError:a,onUpdate:()=>void n(),onClose:()=>c(!1)})]})},P=({url:e})=>(0,O.jsx)(N,{client:j(e)}),F=({url:e,client:t})=>t?(0,O.jsx)(N,{client:t}):(0,O.jsx)(P,{url:e});export{F as RuntimeUpdateButton};
2
+ //# debugId=5a35168c-ea5d-4c73-aca1-35e51f7da1a2
@@ -0,0 +1 @@
1
+ (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{$ as e,$i as t,$t as n,Ar as r,At as ee,B as te,Br as i,Bt as a,Cc as o,Co as s,Cs as c,Ct as l,Dc as u,Dt as d,Ea as f,Ec as p,Er as m,Es as h,Et as g,F as _,Ft as v,G as y,Go as b,Gr as x,H as S,Ht as C,Io as w,It as T,Ja as E,Jo as D,Jt as O,K as k,Ko as A,Kr as j,Lt as M,Mn as N,Mo as P,Mt as F,Nr as I,Nt as L,On as R,Oo as z,Or as B,P as V,Po as H,Pr as U,Pt as W,Q as G,Qa as K,Rr as q,So as J,St as Y,Ta as X,Tc as Z,Tr as Q,Ts as ne,Tt as re,U as ie,Ua as ae,Uo as oe,Ur as se,Ut as ce,V as le,Vt as ue,W as de,Wa as fe,Wr as pe,Wt as me,X as he,Yt as ge,Zt as _e,_l as ve,_t as $,aa as ye,bc as be,bt as xe,cl as Se,dl as Ce,dt as we,ea as Te,en as Ee,es as De,et as Oe,fl as ke,ft as Ae,gt as je,hr as Me,ht as Ne,i as Pe,ia as Fe,in as Ie,it as Le,jo as Re,jr as ze,ko as Be,kr as Ve,ll as He,lt as Ue,ml as We,mt as Ge,na as Ke,no as qe,nt as Je,oa as Ye,ot as Xe,pl as Ze,pt as Qe,qa as $e,qn as et,qo as tt,qr as nt,qt as rt,r as it,ra as at,rn as ot,ro as st,rt as ct,t as lt,ta as ut,tn as dt,to as ft,tt as pt,ul as mt,ut as ht,vt as gt,wo as _t,wr as vt,ws as yt,wt as bt,xt,yt as St,z as Ct,zr as wt}from"./app-Bb88M0VJ.js";import{h as Tt,o as Et}from"./vendor-t7Q7QbPu.js";export{Y as ActionCard,ze as ActionInputError,yt as ApiProvider,pe as App,j as AppLink,tt as AppMark,Ae as AssistantDock,_t as AuthLayout,Re as AvailabilityMark,Z as Button,a as CallMark,me as CallView,k as Carousel,W as ChatDivider,L as ChatMessage,F as ChatThread,te as Choices,J as CodeForm,xe as CompactTable,bt as Composer,o as Dialog,$ as DiffView,Ct as Field,dt as FieldBadge,xt as FieldList,Q as FileReadError,e as FocusActions,Oe as FocusNotice,Le as FocusPage,pt as FocusPanel,Je as FocusSlot,V as Form,Ve as HtmlFrame,it as InPlaceForm,oe as Input,D as LogoMark,N as Markdown,g as MentionBox,re as MentionedText,le as MenuSelect,H as MenuSurface,z as OtpInput,Ge as PartView,C as RecordCall,_e as RecordLink,lt as RecordPicker,s as ResendCodeButton,at as ResponsiveDialog,be as RouteLink,he as SearchPicker,_ as Section,w as Segmented,R as Select,l as SidePanel,M as SignInPrompt,u as Spinner,P as StatusMark,Ne as StepList,et as Textarea,Ee as ToneEdge,ge as TypingLine,S as allowDelayMs,p as buttonClass,v as chatDayLabel,De as closeSidebarEvent,ae as definePlugin,fe as defineUi,gt as diffStats,d as emptyDraft,He as extensionPointsOf,r as fileNamed,I as isConflict,ie as isFramed,A as logoTapEvent,ee as mentionedIds,Ue as menuItemClass,Ce as mergeUi,St as parseDiff,je as parsePatch,Ze as pluginApi,Se as pluginsChangedEvent,We as protobaseVersion,T as sameChatDay,ve as showTextsIn,B as siblingPage,Be as signedOutEvent,Te as statusRefreshMs,ke as uiFromModule,x as uiReadyEvent,st as useApiToken,nt as useAppAddress,de as useArmedAfterFocus,we as useAssistant,ht as useAssistantClient,Qe as useBackendData,ne as useClient,ot as useComponentReads,Ie as useComponentSelect,Pe as useCreateForm,q as useFacets,b as useFieldControl,m as useFileText,Xe as useFocusPage,G as useFocusRecord,ct as useFocusZoneFilled,y as useGuardedPress,wt as useHistogram,Fe as useInbox,Me as useLayoutRecord,se as useList,n as useListDisplay,ye as useMarkNotificationsRead,t as useMembers,c as useMeta,ut as useOwnStatus,mt as usePlugin,f as usePopoverMenu,$e as usePresence,X as usePushNotifications,Et as useQuery,Tt as useQueryClient,K as useRecord,ce as useRecordCallAddress,ue as useRecordCalls,h as useResourceClient,i as useSeries,vt as useSiblingPage,qe as useSignedInUser,Ke as useStatuses,E as useToast,ft as useTypers,O as useTypingSender,Ye as useUnreadNotifications,U as useUpdateRecord,rt as useViewChannel};
@@ -0,0 +1,3 @@
1
+ (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{Cr as r,Dc as i,Dl as a,M as o,Ol as s,Tc as c,Ti as l,bo as u,fu as d,mu as f,ol as p,qc as m,sl as h,uc as g,vl as _,yl as v}from"./app-Bb88M0VJ.js";import{c as y,d as b,l as ee,o as x,u as S}from"./list-page-BUtWO_Zd.js";var C={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};C.node;var te=p(C),w=e(t(),1),T=e(n(),1),ne=e=>/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,re=(e,t)=>{let n=[...t].sort((e,t)=>e.line-t.line).map(t=>[...e.map((e,n)=>x(t.cells[n]??null)),String(t.line),t.problems.join(`; `)]);return`${[[...e,b(`line`),b(`problems`)],...n].map(e=>e.map(ne).join(`,`)).join(`\r
2
+ `)}\r\n`},E=({label:e,counts:t})=>(0,T.jsx)(`dl`,{"aria-label":e,className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:t.map(([e,t])=>(0,T.jsxs)(`div`,{className:`rounded-lg border px-3 py-2`,children:[(0,T.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,T.jsx)(`dd`,{className:`text-lg font-semibold tabular-nums`,children:t.toLocaleString(v())})]},e))}),D=(e,t)=>e?.fields[t]?.label??s(t),ie=new Set([`text`,`integer`,`bigint`,`decimal`,`boolean`,`date`,`timestamp`,`uuid`,`enum`,`relation`,`currency`,`country`]),O=(e,t)=>{let n=e.relation?t[e.relation.resource]:void 0;return n?.primaryKey.length===1?n:void 0},ae=(e,t,{json:n=!1}={})=>Object.values(e.fields).filter(r=>r.readOnly||r.name===e.tenant?!1:r.type===`json`?n:ie.has(r.type)?r.type!==`relation`||O(r,t)!==void 0:!1),oe=new Set([`text`,`integer`,`bigint`,`uuid`,`date`,`currency`,`country`,`enum`]),se=e=>{let t=e.primaryKey.length===1?[e.fields[e.primaryKey[0]]]:[],n=Object.values(e.fields).filter(t=>t.filterable&&!t.sensitive&&oe.has(t.type)&&!e.primaryKey.includes(t.name));return[...t,...n]},k=(e,t)=>O(e,t),A=e=>!e.nullable&&!e.default,j=e=>e.toLowerCase().replace(/[\s_-]+/g,``),ce=(e,t,n)=>{let r=new Set;return e.flatMap((e,i)=>{let a=j(e);if(a===``)return[];let o=t.find(e=>!r.has(e.name)&&(j(D(n,e.name))===a||j(e.name)===a));return o?(r.add(o.name),[{column:i,field:o.name}]):[]})},le=(e,t,n)=>{if(e===`update`)return[];let r=new Set(n.map(e=>e.field));return t.filter(e=>A(e)&&!r.has(e.name))},M=e=>({ok:!0,value:e}),N=e=>({ok:!1,problem:e}),P=e=>`“${x(e)}”`,F=(e,t)=>{if(typeof e==`number`)return String(e);if(typeof e==`string`)return o(e,t.decimal)},ue=(e,t,n)=>{let r=F(t,n);if(r===void 0)return N(b(`notNumber`,{cell:P(t)}));let[i,a=``]=r.split(`.`);if(/[1-9]/.test(a)||/e/i.test(r))return N(b(`notWholeNumber`,{cell:P(t)}));if(e.type===`bigint`)return M(String(BigInt(i)));let o=Number(i);return Number.isSafeInteger(o)?M(o):N(b(`tooLarge`,{cell:P(t)}))},de=(e,t)=>{let n=F(e,t);return n===void 0?N(b(`notNumber`,{cell:P(e)})):M(n)},fe=new Set([`true`,`yes`,`1`]),pe=new Set([`false`,`no`,`0`]),me=e=>{if(typeof e==`boolean`)return M(e);let t=typeof e==`string`||typeof e==`number`?String(e).trim().toLowerCase():``;return fe.has(t)?M(!0):pe.has(t)?M(!1):N(b(`notBoolean`,{cell:P(e)}))},I=e=>String(e).padStart(2,`0`),he=(e,t,n)=>{let r=new Date(Date.UTC(e,t-1,n));if(r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n)return`${e}-${I(t)}-${I(n)}`},L=`(\\d{1,2}):(\\d{2})(?::(\\d{2})(?:\\.\\d+)?)?`,ge=(e,t)=>{let n=RegExp(`^(\\d{4})[-/](\\d{1,2})[-/](\\d{1,2})(?:[T ]${L}(Z|[+-]\\d{2}:?\\d{2})?)?$`).exec(e.trim()),r=RegExp(`^(\\d{1,2})[./-](\\d{1,2})[./-](\\d{4})(?: ${L})?$`).exec(e.trim());if(!n&&!r)return;let[i,a,o]=n?[n[1],n[2],n[3]].map(Number):t===`dmy`?[r[3],r[2],r[1]].map(Number):[r[3],r[1],r[2]].map(Number),s=he(i,a,o);if(!s)return;let[c,l,u=`0`]=n?n.slice(4,7):r.slice(4,7);if(c===void 0)return{date:s};if(!(Number(c)>23||Number(l)>59||Number(u)>59))return{date:s,time:`${I(Number(c))}:${l}:${I(Number(u))}`,zone:n?.[7]}},R=(e,t)=>{if(ee(e)){let[t,n]=e.date.split(`T`);return{date:t,time:n}}return typeof e==`string`?ge(e,t.dateOrder):void 0},z=(e,t)=>N(b(`notDate`,{cell:P(e),dayFirst:t.dateOrder===`dmy`})),_e=(e,t)=>{let n=R(e,t);return n?n.time&&n.time!==`00:00:00`?N(b(`hasTime`,{cell:P(e)})):M(n.date):z(e,t)},ve=(e,t)=>{let n=R(e,t);if(!n)return z(e,t);if(n.zone)return M(new Date(`${n.date}T${n.time}${n.zone===`Z`?`Z`:n.zone.replace(/^([+-]\d{2})(\d{2})$/,`$1:$2`)}`).toISOString());let[r,i,a]=n.date.split(`-`).map(Number),[o,s,c]=(n.time??`00:00:00`).split(`:`).map(Number);return M(new Date(r,i-1,a,o,s,c).toISOString())},B=e=>e.trim().toLowerCase().replace(/\s+/g,` `),ye=(e,t,n)=>{let r=e.enumValues??[],i=B(x(n)),o=r.filter(e=>B(e)===i||B(a(e,t?.valueLabels))===i);return o.length===1?M(o[0]):o.length>1?N(b(`severalValues`,{cell:P(n),values:o.map(e=>a(e,t?.valueLabels)).join(`, `)})):N(b(`notOneOf`,{cell:P(n),values:r.map(e=>a(e,t?.valueLabels)).join(`, `)}))},be=(e,t)=>typeof e==`boolean`&&!t.booleanText?N(b(`notText`,{cell:P(e)})):M(x(e)),xe=e=>S(e)?M(e.json):M(e),V=(e,t,n,r)=>{if(y(n))return e.nullable?M(null):N(b(`emptyRequired`));if(e.type===`json`)return xe(n);if(S(n))return N(b(`nestedValue`,{cell:P(n)}));switch(e.type){case`integer`:case`bigint`:return ue(e,n,r);case`decimal`:return de(n,r);case`boolean`:return me(n);case`date`:return _e(n,r);case`timestamp`:return ve(n,r);case`enum`:return ye(e,t,n);case`text`:case`uuid`:case`currency`:case`country`:return be(n,r);default:throw Error(`Not implemented: importing ${e.type} fields, which importableFields leaves out`)}},Se=(e,t)=>e[t]?.names?.singular??s(t),Ce=(e,t)=>e[t]?.names?.plural??s(t),we=(e,t,n)=>{let{model:r,resources:i,views:a}=n,o=a[r.name],s={},c={},l=[],u=[];for(let{column:n,field:d,matchBy:f}of t.columns){let p=r.fields[d],m=e.cells[n]??null,h=D(o,d),g=k(p,i);if(g&&!y(m)){let e=f??g.primaryKey[0],n=V(g.fields[e],a[g.name]?.fields[e],m,t.options);n.ok?u.push({field:d,finding:{model:g,field:e,value:n.value}}):l.push(`${h}: ${n.problem}`),s[d]=x(m);continue}let _=V(p,o?.fields[d],m,t.options);_.ok?c[d]=s[d]=_.value:l.push(`${h}: ${_.problem}`)}let d;if(t.match&&t.mode!==`create`){let n=r.fields[t.match.field],i=V({...n,nullable:!1},o?.fields[n.name],e.cells[t.match.column]??null,t.options);i.ok?d={model:r,field:n.name,value:i.value}:l.push(`${D(o,n.name)}: ${i.problem}`)}return{values:s,data:c,problems:l,relations:u,match:d}},H=(e,t)=>{let n=e.lookups.keysOf(t.model.name,t.field,t.value),r=`${D(e.views[t.model.name],t.field).toLowerCase()} “${String(t.value)}”`;return n.length===1?{key:n[0]}:n.length===0?{none:b(`noneHas`,{singular:Se(e.views,t.model.name),named:r})}:{several:b(`severalHave`,{count:n.length,plural:Ce(e.views,t.model.name),named:r})}},Te=e=>e.cells.every(y),U=async(e,t,n)=>{let{model:r,views:i}=n,a=e.filter(e=>!Te(e)).map(e=>({row:e,...we(e,t,n)})),o=new Map;for(let e of a.flatMap(e=>[...e.relations.map(e=>e.finding),...e.match?[e.match]:[]])){let t=`${e.model.name}.${e.field}`;o.has(t)||o.set(t,{model:e.model,field:e.field,values:[]}),o.get(t).values.push(e.value)}for(let{model:e,field:t,values:r}of o.values())await n.lookups.load(e,t,r);return a.map(({row:e,values:a,data:o,problems:s,relations:c,match:l})=>{let u={...o};for(let{field:e,finding:t}of c){let a=H(n,t);`key`in a?u[e]=a.key:s.push(`${D(i[r.name],e)}: ${a.none??a.several}`)}let d=l&&H(n,l);d?.several&&s.push(b(`notOneRecord`,{found:d.several})),d?.none&&t.mode===`update`&&s.push(b(`nothingToUpdate`,{found:d.none}));let f={line:e.line,cells:e.cells,values:a,problems:s};return s.length>0?f:d&&`key`in d?{...f,op:{op:`update`,resource:r.name,key:d.key,etag:`*`,data:u}}:{...f,op:{op:`create`,resource:r.name,data:u}}})},Ee=5,De=5,Oe=async(e,t)=>{let n=e.rows(t),{value:r=[]}=await n.next();await n.return(void 0);let[i,...a]=r;return{headers:(i?.cells??[]).map(x),sample:a.slice(0,Ee)}};async function*W(e,t){let n=!0;for await(let r of e.rows(t))yield n?r.slice(1):r,n=!1}var ke=async(e,t,n,r,i,a)=>{let o={rows:0,creates:0,updates:0,problems:[],preview:[]};for await(let s of W(e,t)){a?.throwIfAborted();for(let e of await U(s,n,r))o.rows++,o.preview.length<De&&o.preview.push(e),e.op?.op===`create`?o.creates++:e.op?.op===`update`?o.updates++:o.problems.push({line:e.line,cells:e.cells,problems:e.problems});i(o.rows)}return o},Ae=(e,t)=>{if(!g(e))return[e.message];let n=e.errors.filter(e=>e.field);return n.length===0?[e.message]:n.map(e=>`${D(t.views[t.model.name],e.field)}: ${e.message}`)},je=async(e,t,n,r,{client:i,onProgress:a,cancelled:o})=>{let s={created:0,updated:0,skipped:0,failed:0,notWritten:[]},c=async e=>{let t=[...e];for(;t.length>0;){let e=t.map(e=>e.op);try{let{results:t}=await i.batchWrite(e);for(let e of t)e.op===`create`?s.created++:e.op===`update`&&s.updated++;return}catch(e){let n=g(e)?e.operation:void 0;if(n===void 0||!t[n])throw e;let[i]=t.splice(n,1);s.failed++,s.notWritten.push({line:i.line,cells:i.cells,problems:Ae(e,r)})}}},l=[],u=async e=>{for(;l.length>=100||e&&l.length>0;){if(o())return!1;await c(l.splice(0,100)),a({...s})}return!0};for await(let i of W(e,t)){for(let e of await U(i,n,r))e.op?l.push(e):(s.skipped++,s.notWritten.push({line:e.line,cells:e.cells,problems:e.problems}));if(!await u(!1))return{...s,cancelled:!0}}return await u(!0)?{...s,cancelled:!1}:{...s,cancelled:!0}},G=50,K=(e,t,n)=>u(re(t,n),b(`notImportedFile`,{name:(e??`import`).replace(/\.[^.]+$/,``)}),`text/csv`),q=({rows:e})=>(0,T.jsxs)(`ul`,{"aria-label":b(`rowsNotImported`),className:`flex flex-col gap-1 text-body`,children:[e.slice(0,G).map(e=>(0,T.jsxs)(`li`,{children:[(0,T.jsx)(`span`,{className:`font-medium`,children:b(`rowProblems`,{line:e.line})}),` `,e.problems.join(`; `)]},e.line)),e.length>G&&(0,T.jsx)(`li`,{className:`text-muted-foreground`,children:b(`andMore`,{count:(e.length-G).toLocaleString(v())})})]}),Me=({rows:e})=>(0,T.jsxs)(`p`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,T.jsx)(i,{className:`size-3.5`}),b(`checkingRows`,{count:e.toLocaleString(v())})]}),Ne=({check:e,model:t,resources:n,views:r,columns:i,headers:a,fileName:o})=>{let s=r[t.name],u=i.map(e=>t.fields[e.field]);return(0,T.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,T.jsx)(E,{label:b(`check`),counts:[[b(`rows`),e.rows],[b(`toCreate`),e.creates],[b(`toUpdate`),e.updates],[b(`withProblems`),e.problems.length]]}),e.preview.length>0&&(0,T.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,T.jsxs)(`table`,{"aria-label":b(`firstRows`),className:`w-full text-left text-body`,children:[(0,T.jsx)(`thead`,{className:`bg-muted text-muted-foreground`,children:(0,T.jsxs)(`tr`,{children:[(0,T.jsx)(`th`,{className:`px-2 py-1.5 font-medium`,children:b(`row`)}),u.map(e=>(0,T.jsx)(`th`,{className:`whitespace-nowrap px-2 py-1.5 font-medium`,children:D(s,e.name)},e.name))]})}),(0,T.jsx)(`tbody`,{className:`divide-y`,children:e.preview.map(e=>(0,T.jsxs)(`tr`,{className:e.problems.length>0?`bg-danger-soft`:void 0,children:[(0,T.jsx)(`td`,{className:`px-2 py-1.5 tabular-nums text-muted-foreground`,children:e.line}),u.map(t=>(0,T.jsx)(`td`,{className:`max-w-48 truncate px-2 py-1.5`,children:k(t,n)?String(e.values[t.name]??`—`):t.name in e.values?l(t,e.values[t.name],s?.fields[t.name]):``},t.name))]},e.line))})]})}),e.problems.length>0&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsx)(`h3`,{className:`font-medium`,children:b(`problemRows`)}),(0,T.jsxs)(c,{size:`sm`,onClick:()=>K(o,a,e.problems),children:[(0,T.jsx)(m,{className:`size-3.5`}),b(`download`)]})]}),(0,T.jsx)(q,{rows:e.problems})]}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`batches`,{size:100})})]})},Pe=[`.xlsx`,`.csv`,`.json`],Fe=[`text/csv`,`application/json`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],Ie=[`text/comma-separated-values`,`application/csv`,`text/x-csv`,`application/vnd.ms-excel`,`text/plain`,`application/octet-stream`],Le=e=>/\bAndroid\b/.test(e),Re=e=>[...Pe,...Fe,...Le(e)?Ie:[]].join(`,`),J=({label:e,name:t,value:n,options:r,onChange:i,help:a,className:o})=>{let s=(0,w.useId)();return(0,T.jsxs)(`div`,{className:h(`flex min-w-0 flex-col gap-1.5`,o),children:[(0,T.jsx)(`label`,{htmlFor:s,className:`font-medium`,children:e}),(0,T.jsx)(`select`,{id:s,"aria-label":t,value:n,onChange:e=>i(e.target.value),className:`h-8 w-full min-w-0 rounded-md border border-border-strong bg-background px-2 shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 max-sm:min-h-11`,children:r.map(e=>(0,T.jsx)(`option`,{value:e.value,children:e.label},e.value))}),a&&(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a})]})},Y=({file:e,sheets:t,sheet:n,reading:r,onChoose:a,onSheet:o})=>{let s=(0,w.useId)();return(0,T.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsx)(`label`,{htmlFor:s,className:`font-medium`,children:b(`file`)}),(0,T.jsx)(`input`,{id:s,type:`file`,accept:Re(globalThis.navigator?.userAgent??``),disabled:r,onChange:e=>{let t=e.target.files?.[0];t&&a(t)},className:`file:mr-3 file:h-8 file:rounded-md file:border file:border-border-strong file:bg-background file:px-3 file:font-medium file:text-foreground max-sm:file:min-h-11`}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`fileHint`)})]}),r&&(0,T.jsxs)(`p`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,T.jsx)(i,{className:`size-3.5`}),b(`reading`,{name:e?.name??b(`theFile`)})]}),!r&&t.length>1&&(0,T.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,T.jsx)(te,{className:`mb-2 size-4 shrink-0 text-muted-foreground`}),(0,T.jsx)(J,{className:`flex-1`,label:b(`sheet`),value:n??``,options:t.map(e=>({value:e,label:e})),onChange:o})]})]})},X=e=>e.toLocaleString(v()),ze=({progress:e,total:t,cancelling:n})=>{let r=e.created+e.updated+e.failed;return(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:b(n?`stopping`:`saving`)}),(0,T.jsxs)(`span`,{className:`tabular-nums`,children:[X(r),` / `,X(t)]})]}),(0,T.jsx)(`div`,{role:`progressbar`,"aria-label":b(`rowsSaved`),"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":t,className:`h-2 overflow-hidden rounded-full bg-muted`,children:(0,T.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${t>0?Math.min(100,r/t*100):0}%`}})})]})},Be=({result:e,stopped:t,headers:n,fileName:i})=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t!==void 0&&(0,T.jsx)(r,{title:b(`stopped`),error:t}),e.cancelled&&(0,T.jsx)(`p`,{role:`status`,children:b(`cancelled`)}),(0,T.jsx)(E,{label:b(`summary`),counts:[[b(`created`),e.created],[b(`updated`),e.updated],[b(`skipped`),e.skipped],[b(`failed`),e.failed]]}),e.notWritten.length>0&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsx)(`h3`,{className:`font-medium`,children:b(`rowsNotImported`)}),(0,T.jsxs)(c,{size:`sm`,onClick:()=>K(i,n,e.notWritten),children:[(0,T.jsx)(m,{className:`size-3.5`}),b(`download`)]})]}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`notWrittenHint`)}),(0,T.jsx)(q,{rows:[...e.notWritten].sort((e,t)=>e.line-t.line)})]})]}),Ve=d(),Z=100,Q=e=>String(e),He=e=>{let t=new Map,n=(e,n)=>{let r=`${e}.${n}`;return t.has(r)||t.set(r,new Map),t.get(r)};return{load:async(t,r,i)=>{let a=n(t.name,r),o=[...new Map(i.filter(e=>!a.has(Q(e))).map(e=>[Q(e),e])).values()],s=t.primaryKey[0];for(let n=0;n<o.length;n+=Z){let i=o.slice(n,n+Z);for(let e of i)a.set(Q(e),[]);let c=f(Ve.in(r,i)),l;do{let n=await e(t.name).list(t.name,{filter:c,fields:[...new Set([s,r])],pageSize:1e3,pageToken:l});for(let e of n.items)a.get(Q(e[r]))?.push(e[s]);l=n.nextPageToken||void 0}while(l)}},keysOf:(e,t,r)=>n(e,t).get(Q(r))??[]}},Ue=500,$=()=>{let e=new Worker(new URL(`/assets/parse-worker-MvbeuzYJ.js`,``+import.meta.url),{type:`module`}),t=[],n;return e.onmessage=e=>{if(n){let t=n;n=void 0,t(e.data)}else t.push(e.data)},e.onerror=e=>{e.preventDefault();let r={type:`error`,message:b(`unreadable`)};n?n(r):t.push(r)},{send:t=>e.postMessage(t),receive:()=>t.length>0?Promise.resolve(t.shift()):new Promise(e=>n=e),stop:()=>e.terminate()}},We=e=>({sheets:async()=>{let t=$();try{t.send({type:`sheets`,file:e,locale:_()});let n=await t.receive();if(n.type===`error`)throw Error(n.message);if(n.type!==`sheets`)throw Error(`The parse worker answered ${n.type} to a request for sheets`);return n.sheets}finally{t.stop()}},rows:async function*(t){let n=$();try{for(n.send({type:`read`,file:e,sheet:t,chunk:Ue,locale:_()});;){let e=await n.receive();if(e.type===`error`)throw Error(e.message);if(e.type===`end`)return;if(e.type!==`rows`)throw Error(`The parse worker answered ${e.type} to a read`);yield e.rows,n.send({type:`next`})}}finally{n.stop()}}});export{A as _,Y as a,Me as c,je as d,ce as f,k as g,se as h,Be as i,ke as l,ae as m,He as n,J as o,D as p,ze as r,Ne as s,We as t,Oe as u,le as v};
3
+ //# debugId=3b9b93cc-9658-4ffc-b01b-2a2a82a7871b
@@ -0,0 +1,2 @@
1
+ (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{Dc as r,Fs as i,Ps as a,Rs as o,Tc as s,ds as c,hs as l,la as u,ps as d,sl as f,us as p,yl as m}from"./app-Bb88M0VJ.js";import{t as h}from"./page-header-Ddz2r5ic.js";var g=e(t(),1),_=()=>[{value:`allowed`,label:a(`on`)},{value:`forbidden`,label:a(`off`)}],v=()=>[{value:`allowed`,label:a(`optional`)},{value:`required`,label:a(`required`)},{value:`forbidden`,label:a(`off`)}],y=()=>[{method:`password`,label:a(`password`),description:a(`passwordDescription`),rules:_()},{method:`emailCode`,label:a(`emailedSignInCode`),description:a(`emailedSignInCodeDescription`),rules:_()},{method:`passkey`,label:a(`passkeys`),description:a(`passkeysPolicyDescription`),rules:v()},{method:`twoFactor`,label:a(`twoFactor`),description:a(`twoFactorPolicyDescription`),rules:v()},{method:`staffAccess`,label:a(`staffAccess`),description:a(`staffAccessDescription`),rules:[{value:`allowed`,label:a(`on`)},{value:`notify`,label:a(`emailThePerson`)},{value:`forbidden`,label:a(`off`)}]},{method:`platformSignIn`,label:a(`platformSignIn`),description:a(`platformSignInDescription`),rules:_()}],b=(e,t)=>{let n=y().find(t=>t.method===e)?.rules.find(e=>e.value===t)?.label;if(n===void 0)throw Error(`No label for the ${t} rule of ${e}`);return n},x=e(n(),1),S=({row:e,value:t,onChange:n})=>(0,x.jsx)(`span`,{role:`radiogroup`,"aria-label":e.label,className:`inline-flex h-8 shrink-0 rounded-md bg-muted p-0.5`,children:e.rules.map(e=>(0,x.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t,onClick:()=>n(e.value),className:f(`rounded px-3 text-body font-medium transition-colors`,e.value===t?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value))}),C=({method:e},t,{mail:n,effective:r,policy:i})=>{if(e===`emailCode`&&!n)return a(`codeNeedsMail`);if(e===`password`&&!n&&t.password===`forbidden`)return a(`passwordStaysOn`);if(e===`staffAccess`&&!n&&t.staffAccess===`notify`)return a(`staffNeedsMail`);if(e===`platformSignIn`&&t.platformSignIn===`allowed`&&t.passkey===`required`)return a(`platformOff`);if(t[e]===i[e]&&r[e]!==i[e])return a(`appliesAs`,{rule:b(e,r[e])})},w=({operator:e,platformProviders:t=[]})=>y().flatMap(n=>n.method===`staffAccess`&&!e?[]:n.method===`platformSignIn`?t.length>0?[{...n,label:a(`platformSignInWith`,{provider:new Intl.ListFormat(m(),{type:`conjunction`}).format(t)})}]:[]:[n]),T=({state:e,onSave:t,busy:n,error:r,notice:i})=>{let[o,c]=(0,g.useState)(e.policy),l=w(e),d=l.some(({method:t})=>o[t]!==e.policy[t]);return(0,x.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t(o)},children:[(0,x.jsx)(`ul`,{className:`divide-y rounded-lg border bg-background`,children:l.map(t=>{let n=C(t,o,e);return(0,x.jsxs)(`li`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h2`,{className:`font-semibold`,children:t.label}),(0,x.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t.description}),n&&(0,x.jsx)(`p`,{className:`mt-1.5 text-xs font-medium text-warning-text`,children:n})]}),(0,x.jsx)(S,{row:t,value:o[t.method],onChange:e=>c({...o,[t.method]:e})})]},t.method)})}),r&&(0,x.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-body font-medium text-danger-text`,children:r}),i&&!d&&(0,x.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.savedAt?e.savedBy?a(`lastSavedBy`,{name:e.savedBy,time:u(Date.parse(e.savedAt))}):a(`lastSaved`,{time:u(Date.parse(e.savedAt))}):a(`neverChanged`)}),(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[d&&(0,x.jsx)(s,{onClick:()=>c(e.policy),children:a(`reset`)}),(0,x.jsx)(s,{variant:`primary`,type:`submit`,loading:n,disabled:!d,children:a(`save`)})]})]})]})},E=(e,t)=>e.endedAt?(0,x.jsx)(d,{tone:`neutral`,children:a(`stopped`,{time:u(Date.parse(e.endedAt))})}):Date.parse(e.expiresAt)<=t?(0,x.jsx)(d,{tone:`neutral`,children:a(`ended`,{time:u(Date.parse(e.expiresAt))})}):(0,x.jsx)(d,{tone:`amber`,children:a(`signedInUntil`,{time:u(Date.parse(e.expiresAt))})}),D=({signIns:e,operator:t,error:n,now:r=Date.now()})=>(0,x.jsxs)(p,{title:a(`staffSignIns`),description:a(`staffSignInsDescription`,{operator:t}),children:[(0,x.jsx)(c,{message:n}),e&&e.length===0&&(0,x.jsx)(`p`,{className:`text-muted-foreground`,children:a(`noStaffSignIns`)}),e&&e.length>0&&(0,x.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,x.jsxs)(`li`,{className:`flex flex-col gap-1.5 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,x.jsx)(`span`,{className:`font-medium break-all`,children:e.staffName?`${e.staffName} (${e.staff})`:e.staff}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:a(`as`)}),(0,x.jsx)(`span`,{className:`font-medium break-all`,children:e.user})]}),(0,x.jsx)(`p`,{className:`break-words`,children:e.reason}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{children:u(Date.parse(e.startedAt))}),E(e,r)]})]},e.id))})]}),O=({operator:e})=>{let{session:t}=i(),[n,r]=(0,g.useState)(),[s,c]=(0,g.useState)();return(0,g.useEffect)(()=>{t.staff.log().then(r,e=>c(e instanceof o?l(e):a(`couldNotReadStaffSignIns`)))},[t]),(0,x.jsx)(D,{operator:e,signIns:n,error:s})},k=()=>{let{session:e}=i(),[t,n]=(0,g.useState)(),[s,c]=(0,g.useState)(!1),[u,d]=(0,g.useState)(),[f,p]=(0,g.useState)();(0,g.useEffect)(()=>{e.signInPolicy.read().then(n,e=>d(e instanceof o?l(e):a(`couldNotReadPolicy`)))},[e]);let m=async t=>{c(!0),d(void 0),p(void 0);try{n(await e.signInPolicy.save(t)),p(a(`policySaved`))}catch(e){if(!(e instanceof o))throw e;d(l(e))}c(!1)};return(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,x.jsx)(h,{title:a(`signInPolicy`),subtitle:a(`policySubtitle`)}),t?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{state:t,busy:s,error:u,notice:f,onSave:e=>void m(e)},t.savedAt??`default`),t.operator&&(0,x.jsx)(O,{operator:t.operator})]}):u?(0,x.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:u}):(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(r,{}),` `,a(`loading`)]})]})};export{k as SignInPolicyPage};
2
+ //# debugId=068320b7-97fe-4027-bfd0-2863aad16972
@@ -0,0 +1,2 @@
1
+ (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}from"./react-CuiNlnus.js";import{Fr as n,Ga as r,Gs as i,Hr as a,Hs as o,Ts as s,_n as c,dn as l,gn as u,gr as d,ic as f,ja as p,ln as m,lr as h,mr as g,ns as _,qs as v,rr as y,sr as b,un as x,vn as S,vs as C}from"./app-Bb88M0VJ.js";import{h as w}from"./vendor-t7Q7QbPu.js";import{S as T,ht as E,r as D}from"./embedded-list-DjvOszEj.js";import{n as O}from"./record-preview-CUs7j-lh.js";var k=e(t(),1),A=e=>({queryKey:e.queryKey,start:t=>t.prefetchQuery(e)}),j=e=>({queryKey:e.queryKey,start:t=>t.prefetchInfiniteQuery(e)}),M={Table:(e,t,n)=>{let{resource:r,filter:i=``,sort:a=``,columns:o,button:s,bulk:u=!1,limit:d=10,select:f}=x(e),h=r===void 0?void 0:n.resources[r];if(!h)return[];if(t.part===`chosen`){let e=f===void 0?void 0:n.given[f];return e?[A(c(n.client,h,{key:e}))]:[]}let g=n.views[h.name],{fields:_,read:y}=l({...n,model:h,view:g,columns:o?.map(v),button:s,bulk:u,phoneColumns:m(o)});return[A(D(n,{model:h,filter:i,orderBy:a||p(h,g),limit:d,fields:_,read:y}))]},Chart:(e,t,{client:r,resources:i,views:a})=>{let{resource:o,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m}=x(e),h=i[o],g=h&&E({model:h,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m},i,a);return h&&g?[A(n(r,h.name,g))]:[]},RecordCards:(e,t,{client:n,resources:r,views:i})=>{let{resource:a,filter:o=``,sort:s=``,limit:c=10}=x(e),l=r[a];if(!l)return[];let d=s||p(l,i[l.name]);return[A(S(n,l,{filter:o,sort:d,pageSize:c})),A(u(n,l,o))]},RecordRow:(e,t,{client:n,queryClient:r,resources:i,views:a})=>{let{resource:o,filter:s=``,sort:c=``}=x(e),l=i[o];if(!l)return[];let u=a[l.name];return u?.searchesOf||u?.listOf!==void 0?[]:[A(O({queryClient:r,client:n,resources:i,views:a,model:l,...T(l,u,{filter:s,sort:c})}))]},Thread:(e,t,{client:n,resources:r,views:i})=>{let{resource:o,filter:s,sender:c,time:l,calls:u,limit:d=50}=x(e);if(t.part===`calls`){let e=u&&r[u.resource];return e?[j(a(n,e.name,{filter:u.filter,orderBy:f(u.time),pageSize:d}))]:[]}let p=r[o];if(!p)return[];let m=y(r,i,p,c===void 0?[]:[c]);return[j(a(n,p.name,{filter:s,orderBy:f(l),pageSize:d,labels:m}))]}},N=(e,t,{client:n,resources:r})=>{let i=r[t.resource];return i?[A(u(n,i))]:[]},P=(e,t,n)=>(n?.reads??[]).flatMap(n=>{let r=i(t,n.block);if(!r||r.custom)return[];if(n.part===`condition`)return N(r,n,e);if(n.split)return[];let a=M[r.type];return a?a(o(r,{stack:[],params:e.params,...e.root&&{root:e.root}}),n,e):[]}),F=({tree:e,plan:t})=>{let n=s(),i=w(),{resources:a,views:o}=C(),c=r().fields,l=_(),u=b(),f=h(),p=g(d()),m=(0,k.useMemo)(()=>P({client:n,queryClient:i,resources:a,views:o,fieldTypes:c,xs:l,params:u,given:f,...p&&{root:p}},e,t),[n,i,a,o,c,l,u,f,p,e,t]);return(0,k.useEffect)(()=>{for(let e of m)e.start(i)},[m,i]),null};export{F as t};
2
+ //# debugId=7c2b566c-54a4-4405-bb5e-aa1cfcc20b10
@@ -0,0 +1,2 @@
1
+ (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{Bc as r,Cc as i,Cs as a,Fc as o,Lc as s,N as c,Ol as l,On as u,Tc as d,Uo as f,Vc as p,Xc as ee,Yc as m,gl as te,il as ne,jc as re,ol as h,qn as ie,z as g}from"./app-Bb88M0VJ.js";import{t as ae}from"./circle-alert-kISSXwIV.js";import{a as oe,c as se,d as ce,f as le,g as ue,h as de,i as fe,m as pe,o as me,p as he,r as ge,s as _e,u as ve}from"./workflow-canvas-CJQ0Ll0M.js";import{t as ye}from"./trash-BfIEK322.js";import{A as be,D as xe,F as Se,M as _,_ as Ce,a as we,c as v,f as Te,g as Ee,h as y,i as De,k as b,m as Oe,n as ke,o as x,s as S,u as Ae,x as je}from"./workflows-Bey4jszG.js";import{E as C,S as Me,T as w,_ as Ne,s as T,x as E}from"./use-run-trace-b8SpFDRU.js";import{n as D}from"./use-workflow-types-D1TLbN3E.js";var Pe={type:`object`,title:`File`,properties:{uri:{type:`string`},name:{type:`string`},type:{type:`string`},size:{type:`integer`}}},Fe=(e,t)=>e.relation&&t?.(e.relation.resource)===`integer`?{type:`integer`}:{type:`string`},Ie=(e,t,n)=>{if(e.file)return t===`read`?Pe:{type:`string`};switch(e.type){case`integer`:return{type:`integer`};case`boolean`:return{type:`boolean`};case`json`:return{};case`enum`:return{type:`string`,...e.enumValues&&{enum:e.enumValues}};case`relation`:return t===`read`?Fe(e,n):{type:[`string`,`integer`]};case`bigint`:return t===`read`?{type:`string`}:{type:[`string`,`integer`]};case`decimal`:return t===`read`?{type:`string`}:{type:[`string`,`number`]};default:return{type:`string`}}},Le=(e,t,n)=>{let r=Ie(e,t,n);if(t===`read`||!e.nullable||r.type===void 0)return r;let i=Array.isArray(r.type)?r.type:[r.type];return{...r,type:[...i,`null`],...Array.isArray(r.enum)&&{enum:[...r.enum,null]}}},Re=(e,t,n=e.name,r)=>({type:`object`,title:n,properties:Object.fromEntries(Object.values(e.fields).filter(e=>t===`read`||!e.readOnly).map(e=>[e.name,Le(e,t,r)]))}),ze=e=>t=>{let n=e(t);return n?.primaryKey.length===1?n.fields[n.primaryKey[0]]?.type:void 0},Be={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Be.node;var O=h(Be),Ve={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};Ve.node;var He=h(Ve),Ue={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};Ue.node;var We=h(Ue),Ge={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};Ge.node;var Ke=h(Ge),qe={name:`pen-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]],aliases:[`edit-3`]};qe.node;var Je=h(qe),Ye={name:`repeat`,size:24,node:[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]};Ye.node;var Xe=h(Ye),Ze={name:`timer`,size:24,node:[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]};Ze.node;var Qe=h(Ze),k=(e,t)=>{let n=structuredClone(e);return t(n),n},A=new Set([`Task`,`Pass`,`Wait`,`Map`,`Block`]),j=(e,t)=>{if(!A.has(e.Type))return;let n=e;delete n.End,n.Next=t},M=(e,t)=>{let n=E(e,t);if(!n)throw Error(`No Map or Block at ${t.join(`/`)}`);return n},$e=(e,t)=>{let n=new Set(Ne(e.stateMachine)),r=1;for(;n.has(`${t} ${r}`);)r++;return`${t} ${r}`},et=e=>`task`in e?{Type:`Task`,Resource:e.task,Arguments:{},End:!0}:e.type===`Choice`?{Type:`Choice`,Choices:[]}:e.type===`Wait`?{Type:`Wait`,Seconds:60,End:!0}:e.type===`Succeed`?{Type:`Succeed`}:e.type===`Fail`?{Type:`Fail`}:e.type===`Pass`?{Type:`Pass`,End:!0}:e.type===`Block`?{Type:`Block`,Processor:{StartAt:``,States:{}},Cache:{Ttl:`1 hour`},End:!0}:{Type:`Map`,Items:`{% [] %}`,ItemProcessor:{StartAt:``,States:{}},End:!0},N=(e,t,n,r,i)=>k(e,e=>{let a=M(e,t),o=y(e)===`data`,s=et(n);if(o&&delete s.End,a.States[r]=s,!o&&(a.StartAt===void 0||!Object.hasOwn(a.States,a.StartAt))&&(a.StartAt=r),s.Type!==`Map`&&s.Type!==`Block`)return;let c=$e(e,i),l=o?{States:{[c]:{Type:`Pass`}}}:{StartAt:c,States:{[c]:{Type:`Pass`,End:!0}}};s.Type===`Map`?s.ItemProcessor=l:s.Processor=l}),P=e=>e.Type===`Choice`||A.has(e.Type),tt=(e,t,n)=>{let r=e.States[t],i=e.States[n];if(!r||!A.has(r.Type))return;let a=r.Next;(a===void 0||P(i))&&(j(r,n),a!==void 0&&(i.Type===`Choice`?i.Default=a:A.has(i.Type)&&j(i,a)))},nt=(e,t,n)=>{let r=M(e,t);if(n!==void 0&&n!==t.join(`/`)){let{name:e}=w(n);return A.has(r.States[e]?.Type)?e:void 0}return Object.keys(r.States).reverse().find(e=>r.States[e].End===!0)},rt=e=>e.kind===`start`?[]:w(e.source).scope,it=e=>e.ErrorEquals.length===1&&e.ErrorEquals[0]===`States.ALL`,at=(e,t)=>{if(t.kind===`start`)return e.stateMachine.StartAt||void 0;let{scope:n,name:r}=w(t.source),i=E(e,n)?.States[r];if(i){if(t.kind===`next`)return i.Next;if(t.kind==="default")return i.Type===`Choice`?i.Default:void 0;if(t.kind===`catch`)return`Catch`in i?i.Catch?.find(it)?.Next:void 0}},ot=(e,t,n,r,i)=>{if(i.kind===`start`)return ct(e,t,n,r);let{scope:a,name:o}=w(i.source);if(i.kind===`next`)return st(e,a,t,n,r,o);let s=at(e,i);return k(N(e,a,t,n,r),e=>{let t=M(e,a),r=t.States[o],c=t.States[n];if(r&&(s===void 0||P(c))){if(i.kind===`rule`&&r.Type===`Choice`&&(r.Choices=[...r.Choices??[],{Condition:``,Next:n}]),i.kind==="default"&&r.Type===`Choice`&&(r.Default=n),i.kind===`catch`&&(r.Type===`Task`||r.Type===`Map`||r.Type===`Block`)){let e=r.Catch?.find(it);e?e.Next=n:r.Catch=[...r.Catch??[],{ErrorEquals:[`States.ALL`],Next:n}]}s!==void 0&&(c.Type===`Choice`?c.Default=s:A.has(c.Type)&&j(c,s))}})},st=(e,t,n,r,i,a)=>{let o=N(e,t,n,r,i);return a===void 0||y(e)===`data`?o:k(o,e=>tt(M(e,t),a,r))},ct=(e,t,n,r)=>{let i=e.stateMachine.StartAt??``,a=N(e,[],t,n,r);return y(e)===`data`?a:k(a,e=>{let t=e.stateMachine.States[n];(i===``||P(t))&&(e.stateMachine.StartAt=n,i!==``&&A.has(t.Type)&&j(t,i),i!==``&&t.Type===`Choice`&&(t.Default=i))})},lt=(e,t)=>{`Next`in e&&e.Next===t&&(delete e.Next,e.End=!0),e.Type===`Choice`&&(e.Choices=(e.Choices??[]).filter(e=>e.Next!==t),e.Default===t&&delete e.Default),`Catch`in e&&e.Catch&&(e.Catch=e.Catch.filter(e=>e.Next!==t),e.Catch.length===0&&delete e.Catch)},ut=(e,t)=>k(e,e=>{let{scope:n,name:r}=w(t),i=M(e,n);delete i.States[r];for(let e of Object.values(i.States))lt(e,r);i.StartAt===r&&(i.StartAt=Object.keys(i.States)[0]??``)}),dt=(e,t,n,r)=>k(e,e=>{let{scope:i,name:a}=w(r);if(t===`start`){e.stateMachine.StartAt=a;return}let o=w(n);if(o.scope.join(`/`)!==i.join(`/`))throw Error(`A state leads only to states of its own machine`);let s=M(e,i).States[o.name];s&&(t===`next`&&j(s,a),t===`rule`&&s.Type===`Choice`&&(s.Choices=[...s.Choices??[],{Condition:``,Next:a}]),t==="default"&&s.Type===`Choice`&&(s.Default=a),t===`catch`&&(s.Type===`Task`||s.Type===`Map`||s.Type===`Block`)&&(s.Catch=[...s.Catch??[],{ErrorEquals:[`States.ALL`],Next:a}]))}),ft=(e,t)=>k(e,e=>{if(t.kind===`start`)return;let{scope:n,name:r}=w(t.source),i=M(e,n).States[r];if(!i)return;let a=Number(/\[(\d+)\]/.exec(t.field)?.[1]);t.kind===`next`&&`Next`in i&&(delete i.Next,i.End=!0),t.kind===`rule`&&i.Type===`Choice`&&(i.Choices=i.Choices.filter((e,t)=>t!==a)),t.kind==="default"&&i.Type===`Choice`&&delete i.Default,t.kind===`catch`&&`Catch`in i&&i.Catch&&(i.Catch=i.Catch.filter((e,t)=>t!==a),i.Catch.length===0&&delete i.Catch)}),pt=(e,t,n)=>k(e,e=>{let{scope:r,name:i}=w(t);M(e,r).States[i]=n}),mt=(e,t,n)=>{e.States=Object.fromEntries(Object.entries(e.States).map(([e,r])=>[e===t?n:e,r])),e.StartAt===t&&(e.StartAt=n);for(let r of Object.values(e.States)){if(`Next`in r&&r.Next===t&&(r.Next=n),r.Type===`Choice`){for(let e of r.Choices??[])e.Next===t&&(e.Next=n);r.Default===t&&(r.Default=n)}if(`Catch`in r)for(let e of r.Catch??[])e.Next===t&&(e.Next=n)}},ht=e=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)&&![`true`,`false`,`null`].includes(e)?e:`\`${e}\``,gt=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),F=(e,t,n)=>{if(typeof e==`string`){if(!e.trimStart().startsWith(`{%`))return e;let r=RegExp(`\\$states\\.context\\.Steps\\.(?:${gt(t)}(?![A-Za-z0-9_])|\`${gt(t)}\`)`,`g`);return e.split(/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\/\*[\s\S]*?\*\/)/).map((e,t)=>t%2==1?e:e.replace(r,()=>`$states.context.Steps.${ht(n)}`)).join(``)}return Array.isArray(e)?e.map(e=>F(e,t,n)):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,r])=>[e,F(r,t,n)])):e},_t=(e,t,n)=>k(e,e=>{let{scope:r,name:i}=w(t);mt(M(e,r),i,n),e.stateMachine=F(e.stateMachine,i,n)}),vt=(e,t)=>k(e,e=>{let{scope:n,name:r}=w(t);M(e,n).StartAt=r}),yt=(e,t)=>k(e,e=>{e.trigger=t}),I=e=>typeof e==`object`&&!!e&&!Array.isArray(e),bt=e=>Array.isArray(e.enum)&&e.enum.every(e=>typeof e==`string`)?{kind:`choice`,options:e.enum}:e.type===`string`?{kind:`text`}:e.type===`number`||e.type===`integer`||e.type===`boolean`?{kind:`value`}:e.type===`array`&&I(e.items)&&e.items.type===`string`?{kind:`names`}:{kind:`json`},L=e=>{let t=I(e.properties)?e.properties:{},n=Array.isArray(e.required)?e.required:[];return Object.entries(t).map(([e,t])=>{let r=I(t)?t:{},i=typeof r.title==`string`?r.title:void 0;return{name:e,...bt(r),required:n.includes(e),...i&&{title:i}}})},R=e=>e.message.startsWith(`is missing`),xt=e=>new Map([...e].map(([e,t])=>[e,t.filter(e=>!R(e))])),St=e=>{let t=new Map,n=[],r=(e,n)=>t.set(e,[...t.get(e)??[],n]);for(let{state:t,field:i,message:a}of e){let e={...i!==void 0&&{field:i},message:a};t===void 0?i?.startsWith(`trigger`)||i===`StartAt`||i===`stateMachine.StartAt`?r(``,e):n.push(e):r(t,e)}return{byNode:t,whole:n}},Ct=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),wt=e=>t=>e.flatMap(e=>{let n=t[e.name];return n===void 0||n===``?e.required?[{field:e.name,message:`is missing`}]:[]:e.kind===`names`&&!Ct(n)?[{field:e.name,message:`is a list of names, separated by commas`}]:[]}),Tt=(e,t,n)=>{let r=t.step_types.filter(e=>e.available),i=t.triggers.filter(e=>e.available&&e.id!==`manual`),a=[...t.step_types,...t.triggers].filter(e=>!e.available);return Te(e,{resources:r.map(e=>e.id),required:Object.fromEntries(r.map(e=>[e.id,L(e.input).filter(e=>e.required).map(e=>e.name)])),triggers:Object.fromEntries(i.map(e=>[e.id,wt(L(e.input))])),unavailable:Object.fromEntries(a.map(e=>[e.id,e.reason??``])),versioned:ke(r.map(e=>e.id)),...n&&{pins:n}})},Et=e=>{let t=new Map;for(let{state:n,field:r,message:i}of we(e))n!==void 0&&t.set(n,[...t.get(n)??[],{...r!==void 0&&{field:r},message:i}]);return t},z=e(n(),1),Dt=({problems:e})=>e.length>0&&(0,z.jsxs)(`div`,{className:`rounded-md border border-danger/30 bg-danger-soft px-3 py-2 text-body text-danger-text`,children:[(0,z.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,z.jsx)(ae,{className:`size-4`,"aria-hidden":`true`}),e.every(R)?D(`fillInToSave`,{count:e.length}):D(`cannotSave`,{count:e.length})]}),(0,z.jsx)(`ul`,{className:`mt-1 list-disc pl-6`,children:e.map((e,t)=>(0,z.jsx)(`li`,{children:e.field?D(`fieldProblem`,{field:e.field,message:e.message}):e.message},t))})]}),Ot=({warnings:e})=>e.length>0&&(0,z.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning-soft px-3 py-2 text-body text-warning-text`,children:[(0,z.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,z.jsx)(re,{className:`size-4`,"aria-hidden":`true`}),D(`warningsSaveAnyway`,{count:e.length})]}),(0,z.jsx)(`ul`,{className:`mt-1 list-disc pl-6`,children:e.map((e,t)=>(0,z.jsx)(`li`,{children:e.field?D(`fieldProblem`,{field:e.field,message:e.message}):e.message},t))})]}),B=e(t(),1),kt=({name:e,taken:t,disabled:n,onRename:r})=>{let[i,a]=(0,B.useState)(e),o=i.trim(),s=o===``?D(`nameNeeded`):o!==e&&t.includes(o)?D(`nameTaken`):void 0,c=()=>{!s&&o!==e&&r(o)};return(0,z.jsx)(g,{label:D(`name`),error:s,children:(0,z.jsx)(f,{value:i,invalid:!!s,disabled:n,onChange:e=>a(e.target.value),onBlur:c,onKeyDown:e=>{e.key===`Enter`&&c()}})})},V=(e,t)=>{let n=e.filter(e=>e.field===t||e.field?.startsWith(`${t}.`)||e.field?.startsWith(`${t}[`));return n.length>0?n.map(e=>e.message).join(`; `):void 0},H=({label:e,value:t,names:n,none:r,error:i,disabled:a,onChange:o})=>(0,z.jsx)(g,{label:e,error:i,children:(0,z.jsxs)(u,{invalid:!!i,value:t??``,disabled:a,onChange:e=>o(e.target.value===``?void 0:e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:r}),t!==void 0&&!n.includes(t)&&(0,z.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})}),At=e=>e===void 0?``:typeof e==`string`?e:JSON.stringify(e,null,2),jt=e=>{if(e.trim()!==``)try{return JSON.parse(e)}catch(t){if(!(t instanceof SyntaxError))throw t;return e}},Mt=e=>{let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length>0?t:void 0},Nt=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):At(e),Pt=(0,B.createContext)(void 0),Ft=()=>(0,B.useContext)(Pt),It=e=>e===``?void 0:e,Lt={text:It,value:jt,choice:It,json:jt,names:Mt},U=({label:e,kind:t,options:n=[],required:r,help:i,value:a,error:o,onChange:s,disabled:c,read:l=Lt[t],write:d=t===`names`?Nt:At})=>{let[p,ee]=(0,B.useState)(),m=p!==void 0&&JSON.stringify(l(p))===JSON.stringify(a)?p:d(a),te=Ft(),ne=e=>{ee(e),s(l(e))},re=te!==void 0&&!c&&(a==null||typeof a==`string`)&&(t===`text`||t===`json`||t===`value`);return(0,z.jsxs)(g,{label:e,required:r,help:i,error:o,wide:t===`json`,children:[t===`choice`?(0,z.jsxs)(u,{invalid:!!o,value:m,disabled:c,onChange:e=>s(e.target.value===``?void 0:e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:D(`defaultChoice`)}),n.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}):t===`json`?(0,z.jsx)(ie,{invalid:!!o,rows:2,className:`font-mono text-xs`,value:m,disabled:c,onChange:e=>ne(e.target.value)}):(0,z.jsx)(f,{invalid:!!o,value:m,disabled:c,onChange:e=>ne(e.target.value)}),re&&(0,z.jsx)(`button`,{type:`button`,"aria-label":D(`insertValueInto`,{field:e}),className:`mt-1 text-xs font-medium text-primary-text hover:underline max-md:min-h-11`,onClick:()=>te({label:e,value:a,set:s}),children:D(`insertValue`)})]})},Rt=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),zt=e=>Array.isArray(e)?e.join(`, `):``,W=({state:e,names:t,problems:n,disabled:r,onChange:i})=>{let a=e.Catch??[],o=t=>{let{Catch:n,...r}=e;i(t.length>0?{...r,Catch:t}:r)},c=(e,t)=>o(a.map((n,r)=>r===e?t:n));return(0,z.jsxs)(z.Fragment,{children:[a.map((e,i)=>(0,z.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-md border border-danger/40 p-3`,children:[(0,z.jsx)(`legend`,{className:`px-1 text-xs font-medium text-danger-text`,children:D(`errorPathNumber`,{number:i+1})}),(0,z.jsx)(U,{label:D(`errors`),kind:`text`,help:D(`errorsHelp`),value:e.ErrorEquals??[],read:Rt,write:zt,error:V(n,`Catch[${i}].ErrorEquals`),disabled:r,onChange:t=>c(i,{...e,ErrorEquals:t})}),(0,z.jsx)(H,{label:D(`thenGoesTo`),value:e.Next||void 0,names:t,none:D(`chooseStep`),error:V(n,`Catch[${i}].Next`),disabled:r,onChange:t=>c(i,{...e,Next:t??``})}),!r&&(0,z.jsxs)(d,{size:`sm`,variant:`ghost`,className:`self-start`,onClick:()=>o(a.filter((e,t)=>t!==i)),children:[(0,z.jsx)(ye,{className:`size-3.5`}),D(`removeErrorPath`)]})]},i)),!r&&(0,z.jsx)(`div`,{children:(0,z.jsxs)(d,{size:`sm`,onClick:()=>o([...a,{ErrorEquals:[`States.ALL`],Next:``}]),children:[(0,z.jsx)(s,{className:`size-3.5`}),D(`addErrorPath`)]})})]})},Bt=({state:e,names:t,problems:n,disabled:r,onChange:i})=>{let a=e.Choices??[],o=(t,n)=>i({...e,Choices:a.map((e,r)=>r===t?n:e)});return(0,z.jsxs)(z.Fragment,{children:[a.map((s,c)=>(0,z.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-md border p-3`,children:[(0,z.jsx)(`legend`,{className:`px-1 text-xs font-medium text-muted-foreground`,children:D(`ruleNumber`,{number:c+1})}),(0,z.jsx)(U,{label:D(`condition`),kind:`text`,help:D(`conditionHelp`),value:s.Condition,error:V(n,`Choices[${c}].Condition`),disabled:r,onChange:e=>o(c,{...s,Condition:typeof e==`string`?e:``})}),(0,z.jsx)(H,{label:D(`thenGoesTo`),value:s.Next||void 0,names:t,none:D(`chooseStep`),error:V(n,`Choices[${c}].Next`),disabled:r,onChange:e=>o(c,{...s,Next:e??``})}),!r&&(0,z.jsxs)(d,{size:`sm`,variant:`ghost`,className:`self-start`,onClick:()=>i({...e,Choices:a.filter((e,t)=>t!==c)}),children:[(0,z.jsx)(ye,{className:`size-3.5`}),D(`removeRule`)]})]},c)),!r&&(0,z.jsx)(`div`,{children:(0,z.jsxs)(d,{size:`sm`,onClick:()=>i({...e,Choices:[...a,{Condition:``,Next:``}]}),children:[(0,z.jsx)(s,{className:`size-3.5`}),D(`addRule`)]})}),(0,z.jsx)(H,{label:D(`otherwiseGoesTo`),value:e.Default,names:t,none:D(`noDefault`),error:V(n,`Default`),disabled:r,onChange:t=>{let{Default:n,...r}=e;i(t===void 0?r:{...r,Default:t})}})]})},G=(e,t)=>{let{Cache:n,...r}=e;return t===void 0?r:{...r,Cache:t}},Vt=({state:e,types:t,disabled:n,onChange:r})=>{let[a,o]=(0,B.useState)(!1),s=_e(e,t);return s?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(g,{label:D(`cacheResults`),help:D(s.forces?`cacheForceHelp`:`cacheHelp`),children:(0,z.jsx)(c,{checked:s.on,onChange:t=>{if(!n){if(!t)return r(G(e,s.offValue));if(s.disclaimer)return o(!0);r(G(e,!0))}}})}),a&&(0,z.jsx)(i,{title:D(`cacheConfirmTitle`),description:s.disclaimer,onClose:()=>o(!1),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(d,{onClick:()=>o(!1),children:D(`cacheCancel`)}),(0,z.jsx)(d,{variant:`primary`,onClick:()=>(o(!1),r(G(e,!0))),children:D(`cacheConfirm`)})]})})]}):null},Ht=(e,t,n)=>{let{[t]:r,...i}=e;return n==null||n===``?i:{...i,[t]:n}},Ut=(e,t)=>{let{type:n}=b(e.Resource);if(t){let{Cache:t,...r}=e;return{...r,Resource:`${n}${be}`}}let{HeartbeatSeconds:r,TimeoutSeconds:i,...a}=e;return{...a,Resource:n,...i!==void 0&&i<=Se.taskTimeoutSeconds&&{TimeoutSeconds:i}}},Wt=e=>Oe(e)===void 0,Gt=(e,t)=>({...e,Resource:`${t}${b(e.Resource).waits&&Wt(t)?be:``}`}),Kt=(e,t,n)=>{let{[t]:r,...i}=typeof e.Arguments==`object`&&e.Arguments!==null?e.Arguments:{};return{...e,Arguments:n===void 0?i:{...i,[t]:n}}},qt=({state:e,types:t,problems:n,disabled:r,onChange:i})=>{let a=t.step_types.filter(e=>e.available),{type:o,waits:s}=b(e.Resource),l=Wt(o),d=t.step_types.find(e=>e.id===o),f=typeof e.Arguments==`string`||!d;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(g,{label:D(`stepType`),error:V(n,`Resource`),children:(0,z.jsxs)(u,{value:o,disabled:r,onChange:t=>i(Gt(e,t.target.value)),children:[!a.some(e=>e.id===o)&&(0,z.jsx)(`option`,{value:o,children:he(o,d?.label)}),a.map(e=>(0,z.jsx)(`option`,{value:e.id,children:he(e.id,e.label)},e.id))]})}),f?(0,z.jsx)(U,{label:D(`arguments`),kind:`json`,value:e.Arguments,error:V(n,`Arguments`),disabled:r,onChange:t=>i({...e,Arguments:t??{}})}):L(d.input).map(t=>(0,z.jsx)(U,{label:se(t.name,t.title),kind:t.kind,options:t.options,required:t.required,...t.kind===`names`&&{help:D(`namesHelp`)},value:e.Arguments?.[t.name],error:V(n,`Arguments.${t.name}`),disabled:r,onChange:n=>i(Kt(e,t.name,n))},`${o}:${t.name}`)),l&&(0,z.jsx)(g,{label:D(`waitsForResult`),help:D(`waitsForResultHelp`),children:(0,z.jsx)(c,{checked:s,onChange:t=>!r&&i(Ut(e,t))})}),s||!l?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{label:D(`waitTimeout`),help:D(`waitTimeoutHelp`),kind:`json`,value:e.TimeoutSeconds,error:V(n,`TimeoutSeconds`),disabled:r,onChange:t=>i(Ht(e,`TimeoutSeconds`,t))}),(0,z.jsx)(U,{label:D(`heartbeatSeconds`),help:D(`heartbeatHelp`),kind:`json`,value:e.HeartbeatSeconds,error:V(n,`HeartbeatSeconds`),disabled:r,onChange:t=>i(Ht(e,`HeartbeatSeconds`,t))})]}):(0,z.jsx)(Vt,{state:e,types:t,disabled:r,onChange:i})]})},K=(e,t,n)=>{let{[t]:r,...i}=e;return n===void 0?i:{...i,[t]:n}},Jt=({state:e,problems:t,disabled:n,onChange:r})=>(0,z.jsx)(U,{label:D(`onlyWhen`),kind:`text`,help:D(`onlyWhenHelp`),value:e.Condition,error:V(t,`Condition`),disabled:n,onChange:t=>r(K(e,`Condition`,t))}),q=e=>{let{state:t,names:n,problems:r,disabled:i,onChange:a}=e;if(e.data)return(0,z.jsx)(Jt,{...e});let o=t;return(0,z.jsx)(H,{label:D(`goesOnTo`),value:o.Next,names:n,none:D(`endsHere`),error:V(r,`Next`)??V(r,`End`),disabled:i,onChange:e=>{let{Next:t,End:n,...r}=o;a(e===void 0?{...r,End:!0}:{...r,Next:e})}})},Yt=e=>{let{state:t,types:n,problems:r,disabled:i,onChange:a}=e,o=(e,n,o,s)=>(0,z.jsx)(U,{label:n,kind:o,help:s,value:t[e],error:V(r,e),disabled:i,onChange:n=>a(K(t,e,n))});if(t.Type===`Task`)return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(qt,{state:t,types:n,problems:r,disabled:i,onChange:a}),(0,z.jsx)(q,{...e}),!e.data&&(0,z.jsx)(W,{...e,state:t})]});if(t.Type===`Choice`)return(0,z.jsx)(Bt,{...e,state:t});if(t.Type===`Map`)return(0,z.jsxs)(z.Fragment,{children:[o(`Items`,D(`items`),`json`,D(`itemsHelp`)),o(`MaxConcurrency`,D(`maxConcurrency`),`json`),(0,z.jsx)(q,{...e}),!e.data&&(0,z.jsx)(W,{...e,state:t})]});if(t.Type===`Block`){let n=(e,n,o,s)=>(0,z.jsx)(U,{label:n,kind:o,help:s,value:t.Cache?.[e],error:V(r,`Cache.${e}`)??(e===`Ttl`?V(r,`Cache`):void 0),disabled:i,onChange:n=>a({...t,Cache:K(t.Cache??{Ttl:``},e,n)})});return(0,z.jsxs)(z.Fragment,{children:[o(`Arguments`,D(`blockArguments`),`json`,D(`blockArgumentsHelp`)),n(`Ttl`,D(`blockTtl`),`text`,D(`blockTtlHelp`)),n(`Key`,D(`blockKey`),`json`,D(`blockKeyHelp`)),(0,z.jsx)(q,{...e}),!e.data&&(0,z.jsx)(W,{...e,state:t})]})}return t.Type===`Wait`?(0,z.jsxs)(z.Fragment,{children:[o(`Seconds`,D(`seconds`),`json`),(0,z.jsx)(q,{...e})]}):t.Type===`Pass`?(0,z.jsxs)(z.Fragment,{children:[o(`Output`,D(`output`),`json`,D(`outputHelp`)),(0,z.jsx)(q,{...e})]}):t.Type===`Succeed`?o(`Output`,D(`output`),`json`,D(`outputHelp`)):t.Type===`Fail`?(0,z.jsxs)(z.Fragment,{children:[e.data&&(0,z.jsx)(Jt,{...e}),o(`Error`,D(`error`),`text`),o(`Cause`,D(`cause`),`text`)]}):null},Xt=(e,t,n,r)=>{let{[n]:i,...a}=t;return{[e]:r===void 0?a:{...a,[n]:r}}},Zt=({trigger:e,types:t,problems:n,disabled:r,onChange:i})=>{let a=de(e),o=t.triggers.filter(e=>e.available),s=o.find(e=>e.id===a),c=a!==void 0&&!s?a:void 0,l=a===void 0?{}:e[a]??{};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(g,{label:D(`startsWhen`),error:V(n,`trigger`),help:c&&D(`triggerOtherHelp`),children:(0,z.jsxs)(u,{value:a??``,disabled:r,onChange:e=>i({[e.target.value]:{}}),children:[c!==void 0&&(0,z.jsx)(`option`,{value:c,children:ue(c,t.triggers.find(e=>e.id===c)?.label)}),a===void 0&&(0,z.jsx)(`option`,{value:``,children:D(`triggerUnknown`)}),o.map(e=>(0,z.jsx)(`option`,{value:e.id,children:ue(e.id,e.label)},e.id))]})}),s&&L(s.input).map(e=>(0,z.jsx)(U,{label:se(e.name,e.title),kind:e.kind,options:e.options,required:e.required,...e.kind===`names`&&{help:D(`namesHelp`)},value:l[e.name],error:V(n,`trigger.${s.id}.${e.name}`),disabled:r,onChange:t=>i(Xt(s.id,l,e.name,t))},`${s.id}:${e.name}`)),c!==void 0&&(0,z.jsx)(U,{label:D(`triggerInput`),kind:`json`,value:l,error:V(n,`trigger.${c}`),disabled:!0,onChange:()=>void 0})]})},Qt=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.Type==`string`,$t=({kind:e,name:t})=>(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),(0,z.jsx)(`h3`,{className:`truncate font-semibold text-foreground`,children:t})]}),en=({definition:e,types:t,selected:n,problems:r,warnings:i=[],onChange:a,onSelect:o})=>{let s=C(e,n);if(!s)return null;let{scope:c,name:l}=w(n),u=E(e,c),f=!a,p=e=>a?.(e);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)($t,{kind:ve(s,t),name:l}),(0,z.jsx)(Dt,{problems:r}),(0,z.jsx)(Ot,{warnings:i}),(0,z.jsx)(kt,{name:l,taken:Ne(e.stateMachine),disabled:f,onRename:t=>{p(_t(e,n,t)),o(Me(c,t))}},n),(0,z.jsx)(Yt,{state:s,types:t,names:Object.keys(u.States),problems:r,disabled:f,data:y(e)===`data`,onChange:t=>p(pt(e,n,t))}),(0,z.jsxs)(`details`,{children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-body font-medium text-muted-foreground`,children:D(`asJson`)}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(U,{label:D(`stepJson`),kind:`json`,help:D(`stepJsonHelp`),value:s,disabled:f,onChange:t=>{Qt(t)&&p(pt(e,n,t))}},n)})]}),a&&(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[y(e)===`sequence`&&u.StartAt!==l&&(0,z.jsxs)(d,{size:`sm`,onClick:()=>p(vt(e,n)),children:[(0,z.jsx)(He,{className:`size-3.5`}),D(`startHere`)]}),(0,z.jsxs)(d,{size:`sm`,variant:`danger`,onClick:()=>{p(ut(e,n)),o(void 0)},children:[(0,z.jsx)(ye,{className:`size-3.5`}),D(`removeStep`)]})]})]})},tn=e=>{let{definition:t,types:n,selected:r,problems:i,onChange:a}=e;return(0,z.jsx)(`section`,{"aria-label":D(`chosenStep`),className:`flex flex-col gap-4 rounded-lg border bg-background p-4`,children:r===``?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)($t,{kind:D(`trigger`),name:pe(t.trigger,n)}),(0,z.jsx)(Dt,{problems:i}),(0,z.jsx)(Zt,{trigger:t.trigger,types:n,problems:i,disabled:!a,onChange:e=>a?.(yt(t,e))})]}):(0,z.jsx)(en,{...e,selected:r})})},nn=e=>typeof e==`object`&&!!e&&!Array.isArray(e),J=(e,t,n,r)=>{let i=structuredClone(e),{scope:a,name:o}=w(t),s=E(i,a)?.States[o];if(s&&n[0]===`#condition`)return r===void 0?delete s.Condition:s.Condition=r,i;if(!s||s.Type!==`Task`)return e;nn(s.Arguments)||(s.Arguments={});let c=s.Arguments;for(let e of n.slice(0,-1))nn(c[e])||(c[e]={}),c=c[e];let l=n.at(-1);return r===void 0?delete c[l]:c[l]=r,i},rn=e=>[`=`,`!=`,`>`,`<`,`matches`,`and`,`or`,`not`,...e?[`expression`]:[]],an=e=>e.kind===`compare`||e.kind===`matches`?{value:``}:{value:e.kind===`logic`&&e.op===`and`},on=e=>e===`not`?{kind:`not`,sides:[{value:!1}]}:e===`and`||e===`or`?{kind:`logic`,op:e,sides:[{value:e===`and`},{value:e===`and`}]}:e===`matches`?{kind:`matches`,sides:[{value:``},{pattern:`.*`,flags:``}]}:{kind:`compare`,op:e,sides:[{value:``},{value:``}]},sn=`{% true %}`,cn=(e,t)=>{if(t.length===0)return e;let n=e.sides[t[0]];return n&&v(n)?cn(n,t.slice(1)):void 0},Y=(e,t,n)=>({...e,sides:e.sides.map((e,r)=>r===t?n:e)}),X=(e,t,n)=>{if(t.length===0)return n(e);let r=e.sides[t[0]],i=r&&v(r)?X(r,t.slice(1),n):void 0;return i&&Y(e,t[0],i)},ln=(e,t,n)=>{if(e.kind===`logic`&&t===e.sides.length)return{...e,sides:[...e.sides,n]};if(!(t>=e.sides.length)){if(e.kind===`matches`&&t===1)return!v(n)&&`value`in n&&typeof n.value==`string`?Y(e,1,{pattern:n.value||`.*`,flags:e.sides[1].flags}):void 0;if(e.kind!==`compare`&&e.kind!==`matches`||!v(n))return Y(e,t,n)}},un=(e,t,n,r)=>{let i=x(C(e,t)?.Condition),a=i&&n.length>0&&X(i,n.slice(0,-1),e=>ln(e,n.at(-1),r));return a&&x(S(a))?J(e,t,[T],S(a)):e},dn=(e,t,n,r)=>{let i=C(e,t)?.Condition;if(n.length===0)return i!==void 0&&i!==``?e:J(e,t,[T],r===`expression`?sn:S(on(r)));let a=x(i),o=a&&cn(a,n.slice(0,-1)),s=n.at(-1),c=o?.sides[s],l=o?.kind===`logic`&&s===o.sides.length;return r===`expression`||!o||o.kind===`compare`||o.kind===`matches`||!l&&(!c||v(c)||!(`value`in c))?e:un(e,t,n,on(r))},fn=(e,t,n)=>{if(n.length===0)return J(e,t,[T],void 0);let r=x(C(e,t)?.Condition),i=n.at(-1),a=r&&X(r,n.slice(0,-1),e=>{if(!(i>=e.sides.length))return e.kind===`logic`&&e.sides.length>2?{...e,sides:e.sides.filter((e,t)=>t!==i)}:ln(e,i,an(e))});return a?J(e,t,[T],S(a)):e},pn=e=>{let t=[];if(`Next`in e&&e.Next!==void 0&&t.push(e.Next),e.Type===`Choice`){for(let n of e.Choices??[])t.push(n.Next);e.Default!==void 0&&t.push(e.Default)}if(`Catch`in e)for(let n of e.Catch??[])n.Next!==void 0&&t.push(n.Next);return t},mn=(e,t)=>{let n=new Set,r=[t];for(;r.length>0;){let t=r.shift(),i=e.States[t];!n.has(t)&&i&&(n.add(t),r.push(...pn(i)))}return[...n]},Z=e=>e.StartAt===void 0?Object.keys(e.States):mn(e,e.StartAt),hn=e=>{if(e.Resource!==`app:http`||typeof e.Arguments!=`object`||e.Arguments===null)return!1;let t=e.Arguments.method;return t===void 0||typeof t==`string`&&t.toUpperCase()===`GET`},gn=(e,t,n)=>t.flatMap(t=>{let r=e.States[t];if(!r)return[];let i=_(r),a=i?gn(i,Z(i),n):[];return r.Type===`Task`?(n?.step_types.find(e=>e.id===r.Resource)?.writes??!0)===!1||hn(r)?[]:[{name:t,kind:ve(r,n)}]:a}),_n=(e,t)=>{if(!e||t||!(`Assign`in e)||!e.Assign)return e;let n=Object.fromEntries(Object.entries(e.Assign).filter(([,e])=>e!==De)),{Assign:r,...i}=e;return Object.keys(n).length===0?i:{...i,Assign:n}},vn=(e,t,n)=>{let r=e?.stateMachine.States[n],i=r!==void 0&&`Output`in r;return JSON.stringify(_n(r,i))!==JSON.stringify(_n(t.stateMachine.States[n],i))},yn=(e,t)=>{let n=Ce(e),r=new Set([t]);for(let e=!0;e;){e=!1;for(let[t,i]of n)!r.has(t)&&[...Ee(i)].some(e=>r.has(e))&&(r.add(t),e=!0)}return Object.keys(e.States).filter(e=>r.has(e))},bn=(e,t,n=e.stateMachine.StartAt)=>{let r=e.stateMachine;return gn(r,y(e)===`data`?n===void 0?Z(r):yn(r,n):n===void 0?Z(r):mn(r,n),t)},xn=/^[A-Za-z_][A-Za-z0-9_]*$/,Sn=e=>xn.test(e)?e:`\`${e.replaceAll("`",``)}\``,Cn=e=>{let t=JSON.stringify(e)??``;return t.length>60?`${t.slice(0,59)}…`:t},wn=100,Tn=4,En=e=>{let t=[{path:``,sample:Cn(e)}],n=(e,r,i)=>{if(!(i===Tn||typeof r!=`object`||!r||t.length>=wn)){if(Array.isArray(r)){if(r.length===0)return;let a=`${e}[0]`;t.push({path:a,sample:Cn(r[0])}),n(a,r[0],i+1);return}for(let[a,o]of Object.entries(r)){let r=e===``?Sn(a):`${e}.${Sn(a)}`;t.push({path:r,sample:Cn(o)}),n(r,o,i+1)}}};return n(``,e,0),t.slice(0,wn)},Dn=(e,t)=>t===``?e:`${e}${t.startsWith(`[`)?``:`.`}${t}`,On=(e,t)=>{if(e==null||e===``)return`{% ${t} %}`;if(typeof e!=`string`)throw Error(`A value is inserted only into a field that holds text`);let n=/^\{%([\s\S]*)%\}$/.exec(e.trim());return n?`{% (${n[1].trim()}) & ${t} %}`:`{% ${JSON.stringify(e)} & ${t} %}`},kn=(e,t)=>{let{scope:n,name:r}=w(t),i=(e,t,n)=>Object.keys(e.States).filter(n=>n!==t&&mn(e,n).includes(t)).filter(t=>[`Task`,`Map`,`Block`].includes(e.States[t].Type)).map(e=>[...n,e].join(`/`)),a=i(E(e,n),r,n),o=n.findLastIndex((t,r)=>E(e,n.slice(0,r))?.States[n[r]]?.Type===`Block`);return[...n.flatMap((t,r)=>r<=o?[]:i(E(e,n.slice(0,r)),t,n.slice(0,r))),...a]},An=`{% $states.result %}`,jn=(e,t)=>{let{scope:n,name:r}=w(t),i=E(e,n)?.States[r];return i!==void 0&&`Output`in i},Mn=e=>`Assign`in e&&e.Assign?e.Assign:{},Nn=e=>Object.values(e.States).flatMap(e=>[...Object.keys(Mn(e)),..._(e)?Nn(_(e)):[]]),Pn=(e,t)=>{let n=t.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^(\d)/,`step_$1`)||`value`,r=new Set(Nn(e.stateMachine));if(!r.has(n))return n;let i=2;for(;r.has(`${n}_${i}`);)i++;return`${n}_${i}`},Fn=(e,t)=>{let{scope:n,name:r}=w(t),i=E(e,n).States[r],a=Object.entries(Mn(i)).find(([,e])=>e===An);if(a)return{definition:e,variable:a[0],added:!1};let o=Pn(e,r),s=structuredClone(e),c=E(s,n).States[r];return c.Assign={...c.Assign,[o]:An},{definition:s,variable:o,added:!0}},Q=(e,t)=>e.pure.find(e=>e.id===t),In=(e,t)=>{let n=me(t.handle);if(!n)return;let r=Q(e,t.node);return r?r.kind===`break`?{node:r.source,path:[...r.path,...n]}:void 0:{node:t.node,path:n}},Ln=(e,t)=>{let n=oe(t.handle);if(n===void 0)return;let r=Q(e,t.node);if(!r)return e.inputs.has(t.node)?{step:t.node,keys:[n]}:void 0;if(r.kind===`make`)return{step:r.target,keys:[r.key,n]};if(r.kind===`select`)return{step:r.target,keys:[r.key],select:r};if((r.kind!==`condition`||r.part.kind!==`matches`||n!==`1`)&&r.kind===`condition`&&r.part.kind!==`expression`)return{step:r.target,keys:[T],side:{node:r,at:[...r.at,Number(n)]}}},Rn=(e,t)=>e.path.length===1&&e.path[0]===`#status`&&t.keys.length===1&&t.keys[0]===`#condition`&&!t.side,zn=(e,t,n)=>{let r=Q(e,t.node);if(n===`out`){let n=me(t.handle);return(r?.kind===`break`?r.outputs:e.outputs.get(t.node)??[]).find(e=>JSON.stringify(e.path)===JSON.stringify(n))?.type}let i=oe(t.handle);if(!(r?.kind===`condition`&&r.part.kind===`compare`||r?.kind===`select`))return(r?.kind===`make`||r?.kind===`condition`?r.inputs:e.inputs.get(t.node)??[]).find(e=>e.key===i)?.type},Bn=(e,t)=>w(t).scope.some((t,n,r)=>C(e,r.slice(0,n+1).join(`/`))?.Type===`Block`),Vn=(e,t)=>{let{scope:n}=w(t);for(let t=n.length;t>0;t--)if(C(e,n.slice(0,t).join(`/`))?.Type===`Block`)return n.slice(0,t).join(`/`)},Hn=(e,t,n)=>{let{scope:r,name:i}=w(t);if(w(n).scope.join(`/`)!==r.join(`/`))return!1;let a=Ce(E(e,r)),o=new Set,s=[i];for(;s.length>0;){let e=s.pop();if(e===w(n).name)return!0;o.has(e)||(o.add(e),s.push(...Ee(a.get(e)??{data:new Set,status:new Set,handled:new Set})))}return!1},Un=(e,t,n,r)=>{let i=In(t,n),a=Ln(t,r);if(!i||!a)return{reason:`notPins`};let o=Vn(e,a.step);if(o!==void 0&&i.node!==``&&!i.node.startsWith(`${o}/`))return{reason:`otherScope`,step:w(i.node).name};if(y(e)===`data`&&i.node!==``){let[t,n]=[w(i.node).scope.join(`/`),w(a.step).scope.join(`/`)];if(t!==``&&t!==n&&!n.startsWith(`${t}/`))return{reason:`otherScope`,step:w(i.node).name};if(Hn(e,i.node,a.step))return{reason:`notBefore`,step:w(i.node).name};if(i.path[0]!==`#status`&&jn(e,i.node))return{reason:`shapesOutput`,step:w(i.node).name}}else if(i.node===``){if(Bn(e,a.step))return{reason:`notBefore`,step:w(a.step).name}}else{if(!kn(e,a.step).includes(i.node))return{reason:`notBefore`,step:w(i.node).name};if(jn(e,i.node))return{reason:`shapesOutput`,step:w(i.node).name}}if(Rn(i,a))return;let s=zn(t,n,`out`),c=zn(t,r,`in`);if(s&&c&&!xe(s,c))return{reason:`type`,source:s,target:c}},Wn=(e,t,n,r)=>{if(Un(e,t,n,r))return e;let i=In(t,n),a=Ln(t,r),o=e,s;if(i.node===``)s={base:{input:!0},path:i.path};else if(i.path[0]===`#status`)s={base:{step:w(i.node).name},path:i.path.slice(1)};else{let t=Fn(e,i.node);o=t.definition,s={base:{variable:t.variable},path:i.path}}let c=`step`in s.base&&s.path.length===0?{...s,path:[`Status`]}:s;return a.side?un(o,a.step,a.side.at,{read:c}):a.select?J(o,a.step,a.keys,Ae({...a.select.part,operand:{read:c}})):Rn(i,a)?J(o,a.step,a.keys,S({kind:`compare`,op:`=`,sides:[{read:c},{value:`SUCCEEDED`}]})):J(o,a.step,a.keys,je(s))},Gn=(e,t,n)=>{let r=Ln(t,{node:n.target,handle:n.targetHandle});if(r?.side)return fn(e,r.step,r.side.at);if(r?.select)return J(e,r.step,r.keys,Ae({...r.select.part,operand:{value:``}}));if(r)return J(e,r.step,r.keys,void 0);let i=Q(t,n.target)??Q(t,n.source);return i?Kn(e,t,i):e},Kn=(e,t,n)=>{if(n.kind===`make`||n.kind===`select`)return J(e,n.target,[n.key],void 0);if(n.kind===`condition`)return fn(e,n.target,n.at);let r=e=>t.edges.filter(t=>t.source===e.id&&!t.expression).flatMap(e=>{let n=Q(t,e.target);return n?.kind===`break`?r(n):[e]});return ge(t,r(n),e=>fe(t,e)).reduce((e,n)=>Gn(e,t,n),e)},qn=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,Jn={connect:dt,disconnect:ft,removeState:ut,setArgument:J,connectData:Wn,disconnectData:Gn,removePure:Kn,wireRefusal:Un,addCondition:dn,conditionChoices:rn,setConditionSide:un,addSelect:(e,t,n)=>{let r=C(e,t)?.Arguments?.[n];if(r!==void 0&&!qn(r)||typeof r==`string`&&r.startsWith(`{%`))return e;let i=r??``;return J(e,t,[n],Ae({operand:{value:``},cases:[{when:``,then:i}],otherwise:i}))}},Yn=(e,t,n={})=>({inputs:Object.fromEntries(e.step_types.map(e=>[e.id,e.input])),outputs:Object.fromEntries([...e.step_types,...e.triggers].flatMap(e=>e.output?[[e.id,e.output]]:[])),records:(e,r)=>{let i=t[e];return i&&Re(i,r,n[e]?.names?.singular??l(e),ze(e=>t[e]))},emails:t=>{let n=e.templates?.find(e=>e.name===t);return n&&{schema:n.schema,languages:n.languages}}}),Xn=e=>{let{data:t}=a();return(0,B.useMemo)(()=>Yn(e,t?.resources??{},t?.views),[e,t?.resources,t?.views])},$=te(`app/field-types/workflow-page`),Zn={"app:http":{icon:Ke,keywords:[`api`,`fetch`,`url`,`webhook`,`get`,`post`]},"app:mail.send":{icon:p,keywords:[`email`,`send`,`message`]},"app:records.create":{icon:O,keywords:[`insert`,`add`,`new`,`row`]},"app:records.update":{icon:O,keywords:[`change`,`edit`,`row`]},"app:records.get":{icon:O,keywords:[`read`,`find`,`row`]},"app:records.list":{icon:O,keywords:[`read`,`find`,`query`,`rows`]}},Qn=[{type:`Choice`,icon:We,description:()=>$(`flowChoice`),keywords:[`if`,`branch`,`switch`,`condition`]},{type:`Map`,icon:Xe,description:()=>$(`flowMap`),keywords:[`loop`,`each`,`list`,`repeat`]},{type:`Block`,icon:r,description:()=>$(`flowBlock`),keywords:[`cache`,`once`,`group`,`reuse`,`wrap`]},{type:`Wait`,icon:Qe,description:()=>$(`flowWait`),keywords:[`delay`,`sleep`,`pause`,`later`]},{type:`Pass`,icon:Je,description:()=>$(`flowPass`),keywords:[`variable`,`assign`,`transform`]},{type:`Succeed`,icon:ee,description:()=>$(`flowSucceed`),keywords:[`end`,`stop`,`done`]},{type:`Fail`,icon:m,description:()=>$(`flowFail`),keywords:[`end`,`stop`,`error`]}],$n=e=>({id:`task:${e.id}`,title:le(e.id,e.label),description:e.description,keywords:[e.id,...Zn[e.id]?.keywords??[]],icon:Zn[e.id]?.icon??(e.id.startsWith(`app:`)?ne:o)}),er=e=>e.slice(0,Math.max(e.indexOf(`:`),0)),tr=e=>e===`custom`?$(`customSteps`):e,nr=e=>{let t=new Set(Object.values(ke(e.step_types.map(e=>e.id)))),n=e.step_types.filter(e=>e.available&&(!Oe(e.id)||t.has(e.id))),r=[...new Set(n.map(e=>er(e.id)).filter(e=>e!==`app`))];return[{title:$(`builtIn`),items:n.filter(e=>er(e.id)===`app`).map($n)},...r.map(e=>({title:tr(e),items:n.filter(t=>er(t.id)===e).map($n)})),{title:$(`flow`),items:Qn.map(e=>({id:`type:${e.type}`,title:ce(e.type),description:e.description(),keywords:e.keywords,icon:e.icon}))}].filter(e=>e.items.length>0)},rr=e=>e.startsWith(`task:`)?{task:e.slice(5)}:{type:e.slice(5)};export{ht as A,st as C,at as D,$e as E,nt as O,N as S,ct as T,Tt as _,Jn as a,Et as b,En as c,On as d,vn as f,Dt as g,Pt as h,Xn as i,rt as k,jn as l,tn as m,nr as n,kn as o,bn as p,$ as r,Dn as s,rr as t,Fn as u,R as v,ot as w,xt as x,St as y};
2
+ //# debugId=e4b6f6b4-5456-4d52-b935-247609e24224