@protobase/ui 0.121.10 → 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 (321) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/activity-chart/messages.d.ts +2 -2
  3. package/dist/app/app.js +3 -2
  4. package/dist/app/change-confirm/messages.d.ts +2 -2
  5. package/dist/app/charts/messages.d.ts +2 -2
  6. package/dist/app/confirm-sign-in-messages.d.ts +2 -2
  7. package/dist/app/conversation/message-composer.d.ts +5 -1
  8. package/dist/app/conversation/message-composer.js +10 -3
  9. package/dist/app/conversation/messages.d.ts +2 -2
  10. package/dist/app/conversation/thread-state.d.ts +1 -1
  11. package/dist/app/conversation-page/conversation-header.js +1 -1
  12. package/dist/app/conversation-page/conversation-message.js +1 -1
  13. package/dist/app/conversation-page/conversation-messages.js +1 -1
  14. package/dist/app/conversation-page/conversation-page.d.ts +5 -4
  15. package/dist/app/conversation-page/conversation-page.js +22 -6
  16. package/dist/app/conversation-page/message-editor.js +1 -1
  17. package/dist/app/conversation-page/message-ops.d.ts +3 -1
  18. package/dist/app/conversation-page/message-ops.js +7 -1
  19. package/dist/app/conversation-page/messages.d.ts +2 -2
  20. package/dist/app/conversation-page/reply-labels.js +1 -1
  21. package/dist/app/conversation-page/thread-panel.js +1 -1
  22. package/dist/app/conversation-page/use-message-writes.js +1 -1
  23. package/dist/app/create/messages.d.ts +2 -2
  24. package/dist/app/custom-section.d.ts +1 -1
  25. package/dist/app/delete/messages.d.ts +2 -2
  26. package/dist/app/displays/list-cards.d.ts +1 -1
  27. package/dist/app/displays/messages.d.ts +2 -2
  28. package/dist/app/embedded-list/messages.d.ts +2 -2
  29. package/dist/app/export/export-worker.js +1 -1
  30. package/dist/app/export/messages.d.ts +2 -2
  31. package/dist/app/field-messages.d.ts +2 -2
  32. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  33. package/dist/app/field-types/widget-part.d.ts +1 -1
  34. package/dist/app/field-types/workflow/definition.d.ts +1 -1
  35. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  36. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  37. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  38. package/dist/app/file-viewers/messages.d.ts +2 -2
  39. package/dist/app/focus/messages.d.ts +2 -2
  40. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  41. package/dist/app/gallery/messages.d.ts +2 -2
  42. package/dist/app/hand-order/messages.d.ts +2 -2
  43. package/dist/app/history/messages.d.ts +2 -2
  44. package/dist/app/import/messages.d.ts +2 -2
  45. package/dist/app/list-messages.d.ts +2 -2
  46. package/dist/app/list-page.js +1 -1
  47. package/dist/app/main.js +1 -1
  48. package/dist/app/messages.d.ts +2 -2
  49. package/dist/app/meta-gate-messages.d.ts +2 -2
  50. package/dist/app/new-version/messages.d.ts +2 -2
  51. package/dist/app/pages/custom-boundary.d.ts +1 -1
  52. package/dist/app/pages/custom-chosen.d.ts +1 -1
  53. package/dist/app/pages/messages.d.ts +2 -2
  54. package/dist/app/record-chart/messages.d.ts +2 -2
  55. package/dist/app/record-lines.js +1 -1
  56. package/dist/app/record-messages.d.ts +2 -2
  57. package/dist/app/record-page.js +1 -1
  58. package/dist/app/record-row/messages.d.ts +2 -2
  59. package/dist/app/related-cards/messages.d.ts +2 -2
  60. package/dist/app/runtime/messages.d.ts +2 -2
  61. package/dist/app/saved/saved-list.d.ts +1 -1
  62. package/dist/app/saved/use-favorite.d.ts +1 -1
  63. package/dist/app/searches/messages.d.ts +2 -2
  64. package/dist/app/searches/use-save-search.d.ts +1 -1
  65. package/dist/app/use-nav-recent.d.ts +2 -2
  66. package/dist/app/use-nav-recent.js +5 -4
  67. package/dist/app-shell/messages.d.ts +2 -2
  68. package/dist/app-shell/nav.d.ts +5 -3
  69. package/dist/app-shell/record-marks.d.ts +1 -1
  70. package/dist/app-shell/record-marks.js +5 -3
  71. package/dist/app-shell/sidebar-records.d.ts +1 -1
  72. package/dist/app-shell/sidebar-records.js +6 -1
  73. package/dist/assistant-dock/messages.d.ts +2 -2
  74. package/dist/auth/messages.d.ts +2 -2
  75. package/dist/calls/messages.d.ts +2 -2
  76. package/dist/chat/composer.d.ts +3 -1
  77. package/dist/chat/composer.js +6 -2
  78. package/dist/chat/messages.d.ts +2 -2
  79. package/dist/compact-table/messages.d.ts +2 -2
  80. package/dist/data/api-provider.d.ts +33 -0
  81. package/dist/data/meta-data.d.ts +4 -0
  82. package/dist/data/use-live-updates.d.ts +5 -2
  83. package/dist/data/use-live-updates.js +25 -3
  84. package/dist/data/use-meta.js +1 -0
  85. package/dist/data-grid/messages.d.ts +2 -2
  86. package/dist/filter-panel/messages.d.ts +2 -2
  87. package/dist/index.d.ts +5 -1
  88. package/dist/index.js +5 -1
  89. package/dist/invitations/messages.d.ts +2 -2
  90. package/dist/locale/en.js +7 -2
  91. package/dist/locale/en.json.d.ts +5 -0
  92. package/dist/locale/messages.d.ts +10 -0
  93. package/dist/locale/nl.js +7 -2
  94. package/dist/locale/texts-gate.d.ts +1 -1
  95. package/dist/mailbox/messages.d.ts +2 -2
  96. package/dist/mentions/messages.d.ts +2 -2
  97. package/dist/mocks/orders.d.ts +2 -2
  98. package/dist/notifications/bell/messages.d.ts +2 -2
  99. package/dist/organizations/messages.d.ts +2 -2
  100. package/dist/package.js +1 -1
  101. package/dist/plugins/before-sign-in.d.ts +1 -1
  102. package/dist/plugins/messages.d.ts +2 -2
  103. package/dist/plugins/plugin-api.exports.js +5 -1
  104. package/dist/primitives/messages.d.ts +2 -2
  105. package/dist/record-view/messages.d.ts +2 -2
  106. package/dist/relay/count-unread.d.ts +12 -0
  107. package/dist/relay/count-unread.js +34 -0
  108. package/dist/relay/relay-context.d.ts +17 -0
  109. package/dist/relay/relay-context.js +23 -0
  110. package/dist/relay/relay-provider.d.ts +11 -0
  111. package/dist/relay/relay-provider.js +58 -0
  112. package/dist/relay/relay-store.d.ts +31 -0
  113. package/dist/relay/relay-store.js +77 -0
  114. package/dist/relay/typing-line.d.ts +11 -0
  115. package/dist/relay/typing-line.js +30 -0
  116. package/dist/relay/typing.d.ts +37 -0
  117. package/dist/relay/typing.js +78 -0
  118. package/dist/relay/unread.d.ts +30 -0
  119. package/dist/relay/unread.js +35 -0
  120. package/dist/relay/use-relay-marks.d.ts +11 -0
  121. package/dist/relay/use-relay-marks.js +53 -0
  122. package/dist/relay/use-typing-sender.d.ts +11 -0
  123. package/dist/relay/use-typing-sender.js +32 -0
  124. package/dist/relay/use-unread-counts.d.ts +9 -0
  125. package/dist/relay/use-unread-counts.js +61 -0
  126. package/dist/relay/use-view-channel.d.ts +7 -0
  127. package/dist/relay/use-view-channel.js +21 -0
  128. package/dist/shell/assets/{account-page-K162oV2K.js → account-page-BsAc4o17.js} +2 -2
  129. package/dist/shell/assets/app-Bb88M0VJ.js +36 -0
  130. package/dist/shell/assets/{assistant-shell-BudITySr.js → assistant-shell-CdVAnpMe.js} +2 -2
  131. package/dist/shell/assets/board-display-DKT7398I.js +2 -0
  132. package/dist/shell/assets/calendar-display-0c2dGTmG.js +2 -0
  133. package/dist/shell/assets/{call-rings-pKCPyD1-.js → call-rings-BV5na0xp.js} +2 -2
  134. package/dist/shell/assets/{calls-CLQwaemL.js → calls-n9IoOXzL.js} +2 -2
  135. package/dist/shell/assets/{circle-alert-05wFSlkE.js → circle-alert-kISSXwIV.js} +2 -2
  136. package/dist/shell/assets/{composed-page-D3_OTQB4.js → composed-page-hn7I0Ulk.js} +2 -2
  137. package/dist/shell/assets/{composer-section-BoFYW5rp.js → composer-section-Cb1kOpwt.js} +2 -2
  138. package/dist/shell/assets/{connect-route-D0m9ozLK.js → connect-route-l21XyxhS.js} +2 -2
  139. package/dist/shell/assets/{copy-field-DjAdwdDh.js → copy-field-D22CFeg3.js} +2 -2
  140. package/dist/shell/assets/create-route-CSe9DhbY.js +2 -0
  141. package/dist/shell/assets/{custom-step-container-field-DTCgqZMO.js → custom-step-container-field-C5l4j0FI.js} +4 -4
  142. package/dist/shell/assets/embedded-list-DjvOszEj.js +3 -0
  143. package/dist/shell/assets/en-DnsB2haa.js +2 -0
  144. package/dist/shell/assets/{export-dialog-BVmThgqO.js → export-dialog-Bh3TSYyL.js} +2 -2
  145. package/dist/shell/assets/export-worker-DbK8hf_0.js +15 -0
  146. package/dist/shell/assets/{first-organization-page-B986-W2g.js → first-organization-page-BtfoRENE.js} +2 -2
  147. package/dist/shell/assets/{graph-view-BEerNiMa.js → graph-view-C4fwqz7Q.js} +2 -2
  148. package/dist/shell/assets/{group-donut-DgttsF8V.js → group-donut-Bcnc0EaM.js} +2 -2
  149. package/dist/shell/assets/{guest-call-page-CKEva7eV.js → guest-call-page-D09z7u-V.js} +3 -3
  150. package/dist/shell/assets/{html-viewer-FMIvHlJ9.js → html-viewer-BtwOBvDg.js} +2 -2
  151. package/dist/shell/assets/{import-dialog-CjFrTZBf.js → import-dialog-Dwx_yEfS.js} +2 -2
  152. package/dist/shell/assets/{import-table-dialog-CoTd03ud.js → import-table-dialog-T3V3RoDY.js} +2 -2
  153. package/dist/shell/assets/{index-BrTE5pLB.js → index-DvNpfiwE.js} +1 -1
  154. package/dist/shell/assets/invitations-page-X90SMPsK.js +2 -0
  155. package/dist/shell/assets/{layout-grid-o1f0ZIIR.js → layout-grid-Bp_eP5eU.js} +2 -2
  156. package/dist/shell/assets/{legend-item-CamCYS1J.js → legend-item-CEZ-8FXv.js} +2 -2
  157. package/dist/shell/assets/list-page-BUtWO_Zd.js +4 -0
  158. package/dist/shell/assets/{maplibre-DVBhKlXN.js → maplibre-Cv3xuTP_.js} +2 -2
  159. package/dist/shell/assets/{markdown-content-CfblNnhw.js → markdown-content-jO-R6jpp.js} +2 -2
  160. package/dist/shell/assets/members-page-BZyldmfB.js +2 -0
  161. package/dist/shell/assets/{message-content--7TsRUEK.js → message-content-DJEa6jyY.js} +2 -2
  162. package/dist/shell/assets/messages-BIP4feL2.js +2 -0
  163. package/dist/shell/assets/nl-Ce2dHlet.js +2 -0
  164. package/dist/shell/assets/organization-page-CjQ7oJk4.js +2 -0
  165. package/dist/shell/assets/organizations-page-2cKqhNJh.js +2 -0
  166. package/dist/shell/assets/parse-worker-MvbeuzYJ.js +35 -0
  167. package/dist/shell/assets/{pending-invitation-row-By5UWOua.js → pending-invitation-row-Cef2WdTI.js} +2 -2
  168. package/dist/shell/assets/{period-chart-C3ZV_QjX.js → period-chart-BPq3Knz8.js} +2 -2
  169. package/dist/shell/assets/{person-row-Dvc6wiac.js → person-row-BLVor9QR.js} +2 -2
  170. package/dist/shell/assets/public-form-page-CMaHcrdf.js +2 -0
  171. package/dist/shell/assets/record-lines-jznjVtIQ.js +2 -0
  172. package/dist/shell/assets/{record-map-M24QGWvA.js → record-map-9KEjeN_F.js} +2 -2
  173. package/dist/shell/assets/{record-opens-CNOaCrB0.js → record-opens-CQLXpqJS.js} +2 -2
  174. package/dist/shell/assets/record-page-JFlxtSyg.js +3 -0
  175. package/dist/shell/assets/{record-preview-Bk9A5TNd.js → record-preview-CUs7j-lh.js} +2 -2
  176. package/dist/shell/assets/{records-map-D1JVIHvn.js → records-map-CLF98-H0.js} +2 -2
  177. package/dist/shell/assets/render-node-DoB1k2WS.js +3 -0
  178. package/dist/shell/assets/reorder-button-Cg-WKutS.js +2 -0
  179. package/dist/shell/assets/{run-trace-view-CBYw9RPI.js → run-trace-view-CmujelWd.js} +2 -2
  180. package/dist/shell/assets/{runner-install-field--7xa6MIJ.js → runner-install-field-wpoIgnks.js} +2 -2
  181. package/dist/shell/assets/{runtime-update-DWO9xR0h.js → runtime-update-BaNRaM6l.js} +2 -2
  182. package/dist/shell/assets/shared-protobase-ui-630Rm7Jd.js +1 -0
  183. package/dist/shell/assets/sheet-source-7m5PMllh.js +3 -0
  184. package/dist/shell/assets/sign-in-policy-page-GgyC3l_6.js +2 -0
  185. package/dist/shell/assets/start-block-queries-B8K1ZsVK.js +2 -0
  186. package/dist/shell/assets/step-catalog-Dktva0VF.js +2 -0
  187. package/dist/shell/assets/{step-panel-xClc_YhC.js → step-panel-CjUWMleA.js} +2 -2
  188. package/dist/shell/assets/timeline-display-CCPZ8VKv.js +2 -0
  189. package/dist/shell/assets/{trash-DTqja_Bl.js → trash-BfIEK322.js} +2 -2
  190. package/dist/shell/assets/{update-set-g33TLRML.js → update-set-Drag3hOc.js} +2 -2
  191. package/dist/shell/assets/use-calendar-move-fM4kqYZF.js +2 -0
  192. package/dist/shell/assets/{use-display-rows-sN3JfCRy.js → use-display-rows-CEB1AStC.js} +2 -2
  193. package/dist/shell/assets/use-my-invitations-DxoZihem.js +2 -0
  194. package/dist/shell/assets/{use-paged-search-DrjHdSz7.js → use-paged-search-tHTP8FRX.js} +2 -2
  195. package/dist/shell/assets/{use-run-trace-DFLNmghw.js → use-run-trace-b8SpFDRU.js} +2 -2
  196. package/dist/shell/assets/{use-workflow-page-Cfztiqhc.js → use-workflow-page-oeKIRs_g.js} +2 -2
  197. package/dist/shell/assets/{use-workflow-types-BFToPBTN.js → use-workflow-types-D1TLbN3E.js} +2 -2
  198. package/dist/shell/assets/{workflow-canvas-D7hU35fr.js → workflow-canvas-CJQ0Ll0M.js} +4 -4
  199. package/dist/shell/assets/{workflow-field-D7X0A1GO.js → workflow-field-CpGs8ZXh.js} +3 -3
  200. package/dist/shell/assets/{workflow-graph-editor-16CoiFFG.js → workflow-graph-editor-CLlL2jNQ.js} +2 -2
  201. package/dist/shell/assets/{workflow-run-field-DJLolq5e.js → workflow-run-field-R43RqM3Z.js} +3 -3
  202. package/dist/shell/assets/workflow-status-field-BaytFzWg.js +2 -0
  203. package/dist/shell/assets/workflow-workbench-DYClQZZ1.js +4 -0
  204. package/dist/shell/index.html +3 -3
  205. package/dist/shell/protobase.shell.json +2 -2
  206. package/dist/shell/protobase.sw.js +2 -2
  207. package/dist/shell-source-maps/assets/{account-page-K162oV2K.js.map → account-page-BsAc4o17.js.map} +1 -1
  208. package/dist/shell-source-maps/assets/app-Bb88M0VJ.js.map +1 -0
  209. package/dist/shell-source-maps/assets/{assistant-shell-BudITySr.js.map → assistant-shell-CdVAnpMe.js.map} +1 -1
  210. package/dist/shell-source-maps/assets/{board-display-Bs4z3PwA.js.map → board-display-DKT7398I.js.map} +1 -1
  211. package/dist/shell-source-maps/assets/{calendar-display-tHm1Uuwv.js.map → calendar-display-0c2dGTmG.js.map} +1 -1
  212. package/dist/shell-source-maps/assets/{call-rings-pKCPyD1-.js.map → call-rings-BV5na0xp.js.map} +1 -1
  213. package/dist/shell-source-maps/assets/{calls-CLQwaemL.js.map → calls-n9IoOXzL.js.map} +1 -1
  214. package/dist/shell-source-maps/assets/{circle-alert-05wFSlkE.js.map → circle-alert-kISSXwIV.js.map} +1 -1
  215. package/dist/shell-source-maps/assets/{composed-page-D3_OTQB4.js.map → composed-page-hn7I0Ulk.js.map} +1 -1
  216. package/dist/shell-source-maps/assets/{composer-section-BoFYW5rp.js.map → composer-section-Cb1kOpwt.js.map} +1 -1
  217. package/dist/shell-source-maps/assets/{connect-route-D0m9ozLK.js.map → connect-route-l21XyxhS.js.map} +1 -1
  218. package/dist/shell-source-maps/assets/{copy-field-DjAdwdDh.js.map → copy-field-D22CFeg3.js.map} +1 -1
  219. package/dist/shell-source-maps/assets/{create-route-CZDGdfY8.js.map → create-route-CSe9DhbY.js.map} +1 -1
  220. package/dist/shell-source-maps/assets/{custom-step-container-field-DTCgqZMO.js.map → custom-step-container-field-C5l4j0FI.js.map} +1 -1
  221. package/dist/shell-source-maps/assets/{embedded-list-wbLEr5-r.js.map → embedded-list-DjvOszEj.js.map} +1 -1
  222. package/dist/shell-source-maps/assets/en-DnsB2haa.js.map +1 -0
  223. package/dist/shell-source-maps/assets/{export-dialog-BVmThgqO.js.map → export-dialog-Bh3TSYyL.js.map} +1 -1
  224. package/dist/shell-source-maps/assets/export-worker-DbK8hf_0.js.map +1 -0
  225. package/dist/shell-source-maps/assets/{first-organization-page-B986-W2g.js.map → first-organization-page-BtfoRENE.js.map} +1 -1
  226. package/dist/shell-source-maps/assets/{graph-view-BEerNiMa.js.map → graph-view-C4fwqz7Q.js.map} +1 -1
  227. package/dist/shell-source-maps/assets/{group-donut-DgttsF8V.js.map → group-donut-Bcnc0EaM.js.map} +1 -1
  228. package/dist/shell-source-maps/assets/{guest-call-page-CKEva7eV.js.map → guest-call-page-D09z7u-V.js.map} +1 -1
  229. package/dist/shell-source-maps/assets/{html-viewer-FMIvHlJ9.js.map → html-viewer-BtwOBvDg.js.map} +1 -1
  230. package/dist/shell-source-maps/assets/{import-dialog-CjFrTZBf.js.map → import-dialog-Dwx_yEfS.js.map} +1 -1
  231. package/dist/shell-source-maps/assets/{import-table-dialog-CoTd03ud.js.map → import-table-dialog-T3V3RoDY.js.map} +1 -1
  232. package/dist/shell-source-maps/assets/{invitations-page-Ds817tOV.js.map → invitations-page-X90SMPsK.js.map} +1 -1
  233. package/dist/shell-source-maps/assets/{layout-grid-o1f0ZIIR.js.map → layout-grid-Bp_eP5eU.js.map} +1 -1
  234. package/dist/shell-source-maps/assets/{legend-item-CamCYS1J.js.map → legend-item-CEZ-8FXv.js.map} +1 -1
  235. package/dist/shell-source-maps/assets/{list-page-CHdsbqR8.js.map → list-page-BUtWO_Zd.js.map} +1 -1
  236. package/dist/shell-source-maps/assets/{maplibre-DVBhKlXN.js.map → maplibre-Cv3xuTP_.js.map} +1 -1
  237. package/dist/shell-source-maps/assets/{markdown-content-CfblNnhw.js.map → markdown-content-jO-R6jpp.js.map} +1 -1
  238. package/dist/shell-source-maps/assets/{members-page-CCLPZ9sH.js.map → members-page-BZyldmfB.js.map} +1 -1
  239. package/dist/shell-source-maps/assets/{message-content--7TsRUEK.js.map → message-content-DJEa6jyY.js.map} +1 -1
  240. package/dist/shell-source-maps/assets/{messages-BaKJKIHo.js.map → messages-BIP4feL2.js.map} +1 -1
  241. package/dist/shell-source-maps/assets/nl-Ce2dHlet.js.map +1 -0
  242. package/dist/shell-source-maps/assets/{organization-page-DE4U9Xbi.js.map → organization-page-CjQ7oJk4.js.map} +1 -1
  243. package/dist/shell-source-maps/assets/{organizations-page-DcRX2C5D.js.map → organizations-page-2cKqhNJh.js.map} +1 -1
  244. package/dist/shell-source-maps/assets/parse-worker-MvbeuzYJ.js.map +1 -0
  245. package/dist/shell-source-maps/assets/{pending-invitation-row-By5UWOua.js.map → pending-invitation-row-Cef2WdTI.js.map} +1 -1
  246. package/dist/shell-source-maps/assets/{period-chart-C3ZV_QjX.js.map → period-chart-BPq3Knz8.js.map} +1 -1
  247. package/dist/shell-source-maps/assets/{person-row-Dvc6wiac.js.map → person-row-BLVor9QR.js.map} +1 -1
  248. package/dist/shell-source-maps/assets/{public-form-page-C2K3mhKj.js.map → public-form-page-CMaHcrdf.js.map} +1 -1
  249. package/dist/shell-source-maps/assets/{record-lines-DLM3i7dN.js.map → record-lines-jznjVtIQ.js.map} +1 -1
  250. package/dist/shell-source-maps/assets/{record-map-M24QGWvA.js.map → record-map-9KEjeN_F.js.map} +1 -1
  251. package/dist/shell-source-maps/assets/{record-opens-CNOaCrB0.js.map → record-opens-CQLXpqJS.js.map} +1 -1
  252. package/dist/shell-source-maps/assets/record-page-JFlxtSyg.js.map +1 -0
  253. package/dist/shell-source-maps/assets/{record-preview-Bk9A5TNd.js.map → record-preview-CUs7j-lh.js.map} +1 -1
  254. package/dist/shell-source-maps/assets/{records-map-D1JVIHvn.js.map → records-map-CLF98-H0.js.map} +1 -1
  255. package/dist/shell-source-maps/assets/render-node-DoB1k2WS.js.map +1 -0
  256. package/dist/shell-source-maps/assets/{reorder-button-CrDVuiOd.js.map → reorder-button-Cg-WKutS.js.map} +1 -1
  257. package/dist/shell-source-maps/assets/{run-trace-view-CBYw9RPI.js.map → run-trace-view-CmujelWd.js.map} +1 -1
  258. package/dist/shell-source-maps/assets/{runner-install-field--7xa6MIJ.js.map → runner-install-field-wpoIgnks.js.map} +1 -1
  259. package/dist/shell-source-maps/assets/{runtime-update-DWO9xR0h.js.map → runtime-update-BaNRaM6l.js.map} +1 -1
  260. package/dist/shell-source-maps/assets/{sheet-source-DKZ31RE_.js.map → sheet-source-7m5PMllh.js.map} +1 -1
  261. package/dist/shell-source-maps/assets/{sign-in-policy-page-B-m5Pcyb.js.map → sign-in-policy-page-GgyC3l_6.js.map} +1 -1
  262. package/dist/shell-source-maps/assets/{start-block-queries-OldcFqiL.js.map → start-block-queries-B8K1ZsVK.js.map} +1 -1
  263. package/dist/shell-source-maps/assets/{step-catalog-N67Ej6Fl.js.map → step-catalog-Dktva0VF.js.map} +1 -1
  264. package/dist/shell-source-maps/assets/{step-panel-xClc_YhC.js.map → step-panel-CjUWMleA.js.map} +1 -1
  265. package/dist/shell-source-maps/assets/{timeline-display-DwR4-qO_.js.map → timeline-display-CCPZ8VKv.js.map} +1 -1
  266. package/dist/shell-source-maps/assets/{trash-DTqja_Bl.js.map → trash-BfIEK322.js.map} +1 -1
  267. package/dist/shell-source-maps/assets/{update-set-g33TLRML.js.map → update-set-Drag3hOc.js.map} +1 -1
  268. package/dist/shell-source-maps/assets/{use-calendar-move-BaNKG9_2.js.map → use-calendar-move-fM4kqYZF.js.map} +1 -1
  269. package/dist/shell-source-maps/assets/{use-display-rows-sN3JfCRy.js.map → use-display-rows-CEB1AStC.js.map} +1 -1
  270. package/dist/shell-source-maps/assets/{use-my-invitations-BIsBGgmc.js.map → use-my-invitations-DxoZihem.js.map} +1 -1
  271. package/dist/shell-source-maps/assets/{use-paged-search-DrjHdSz7.js.map → use-paged-search-tHTP8FRX.js.map} +1 -1
  272. package/dist/shell-source-maps/assets/{use-run-trace-DFLNmghw.js.map → use-run-trace-b8SpFDRU.js.map} +1 -1
  273. package/dist/shell-source-maps/assets/{use-workflow-page-Cfztiqhc.js.map → use-workflow-page-oeKIRs_g.js.map} +1 -1
  274. package/dist/shell-source-maps/assets/{use-workflow-types-BFToPBTN.js.map → use-workflow-types-D1TLbN3E.js.map} +1 -1
  275. package/dist/shell-source-maps/assets/{workflow-canvas-D7hU35fr.js.map → workflow-canvas-CJQ0Ll0M.js.map} +1 -1
  276. package/dist/shell-source-maps/assets/{workflow-field-D7X0A1GO.js.map → workflow-field-CpGs8ZXh.js.map} +1 -1
  277. package/dist/shell-source-maps/assets/{workflow-graph-editor-16CoiFFG.js.map → workflow-graph-editor-CLlL2jNQ.js.map} +1 -1
  278. package/dist/shell-source-maps/assets/{workflow-run-field-DJLolq5e.js.map → workflow-run-field-R43RqM3Z.js.map} +1 -1
  279. package/dist/shell-source-maps/assets/workflow-status-field-BaytFzWg.js.map +1 -0
  280. package/dist/shell-source-maps/assets/{workflow-workbench-DErE_AKt.js.map → workflow-workbench-DYClQZZ1.js.map} +1 -1
  281. package/dist/status/messages.d.ts +2 -2
  282. package/dist/users/messages.d.ts +2 -2
  283. package/package.json +5 -5
  284. package/dist/shell/assets/app-vx5mZ2uE.js +0 -34
  285. package/dist/shell/assets/board-display-Bs4z3PwA.js +0 -2
  286. package/dist/shell/assets/calendar-display-tHm1Uuwv.js +0 -2
  287. package/dist/shell/assets/create-route-CZDGdfY8.js +0 -2
  288. package/dist/shell/assets/embedded-list-wbLEr5-r.js +0 -3
  289. package/dist/shell/assets/en-0TxR0Vfb.js +0 -2
  290. package/dist/shell/assets/export-worker-AFqbgGzG.js +0 -15
  291. package/dist/shell/assets/invitations-page-Ds817tOV.js +0 -2
  292. package/dist/shell/assets/list-page-CHdsbqR8.js +0 -4
  293. package/dist/shell/assets/members-page-CCLPZ9sH.js +0 -2
  294. package/dist/shell/assets/messages-BaKJKIHo.js +0 -2
  295. package/dist/shell/assets/nl-mDiTKi5y.js +0 -2
  296. package/dist/shell/assets/organization-page-DE4U9Xbi.js +0 -2
  297. package/dist/shell/assets/organizations-page-DcRX2C5D.js +0 -2
  298. package/dist/shell/assets/parse-worker-C5wWzRYH.js +0 -35
  299. package/dist/shell/assets/public-form-page-C2K3mhKj.js +0 -2
  300. package/dist/shell/assets/record-lines-DLM3i7dN.js +0 -2
  301. package/dist/shell/assets/record-page-DVmkJFmF.js +0 -3
  302. package/dist/shell/assets/render-node-C-yLArnA.js +0 -3
  303. package/dist/shell/assets/reorder-button-CrDVuiOd.js +0 -2
  304. package/dist/shell/assets/shared-protobase-ui-DGEYEBZj.js +0 -1
  305. package/dist/shell/assets/sheet-source-DKZ31RE_.js +0 -3
  306. package/dist/shell/assets/sign-in-policy-page-B-m5Pcyb.js +0 -2
  307. package/dist/shell/assets/start-block-queries-OldcFqiL.js +0 -2
  308. package/dist/shell/assets/step-catalog-N67Ej6Fl.js +0 -2
  309. package/dist/shell/assets/timeline-display-DwR4-qO_.js +0 -2
  310. package/dist/shell/assets/use-calendar-move-BaNKG9_2.js +0 -2
  311. package/dist/shell/assets/use-my-invitations-BIsBGgmc.js +0 -2
  312. package/dist/shell/assets/workflow-status-field-weFyKOIV.js +0 -2
  313. package/dist/shell/assets/workflow-workbench-DErE_AKt.js +0 -4
  314. package/dist/shell-source-maps/assets/app-vx5mZ2uE.js.map +0 -1
  315. package/dist/shell-source-maps/assets/en-0TxR0Vfb.js.map +0 -1
  316. package/dist/shell-source-maps/assets/export-worker-AFqbgGzG.js.map +0 -1
  317. package/dist/shell-source-maps/assets/nl-mDiTKi5y.js.map +0 -1
  318. package/dist/shell-source-maps/assets/parse-worker-C5wWzRYH.js.map +0 -1
  319. package/dist/shell-source-maps/assets/record-page-DVmkJFmF.js.map +0 -1
  320. package/dist/shell-source-maps/assets/render-node-C-yLArnA.js.map +0 -1
  321. package/dist/shell-source-maps/assets/workflow-status-field-weFyKOIV.js.map +0 -1
@@ -1,34 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lib-sentry-browser-BoddUTMM.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/lib-sentry-core-CKUQogx-.js","assets/lib-sentry-conventions-CEhiYCma.js","assets/lib-sentry-browser-utils-CoRYOaCJ.js","assets/list-page-CHdsbqR8.js","assets/react-CuiNlnus.js","assets/vendor-t7Q7QbPu.js","assets/view-chart-ChBtewKd.js","assets/embedded-list-wbLEr5-r.js","assets/update-set-g33TLRML.js","assets/layout-grid-o1f0ZIIR.js","assets/lib-tanstack-react-table-uAPG3Sdi.js","assets/lib-tanstack-store-KbP08Dw1.js","assets/lib-tanstack-react-store-BKI8EKbh.js","assets/lib-use-sync-external-store-D4s7MiFL.js","assets/lib-tanstack-table-core-2MHQ7o_e.js","assets/record-preview-Bk9A5TNd.js","assets/lib-dnd-kit-core-xi-7xL_N.js","assets/lib-dnd-kit-utilities-Bvr0fWXF.js","assets/lib-dnd-kit-accessibility-AUTLnqh4.js","assets/lib-dnd-kit-sortable-CNDSKqCD.js","assets/reorder-button-CrDVuiOd.js","assets/messages-BaKJKIHo.js","assets/trash-DTqja_Bl.js","assets/page-header-Ddz2r5ic.js","assets/use-display-rows-sN3JfCRy.js","assets/list-page-GUjJKojE.css","assets/record-page-DVmkJFmF.js","assets/render-node-C-yLArnA.js","assets/circle-alert-05wFSlkE.js","assets/pending-invitation-row-By5UWOua.js","assets/person-row-Dvc6wiac.js","assets/use-paged-search-DrjHdSz7.js","assets/client-publisher-D39SlIhp.js","assets/copy-field-DjAdwdDh.js","assets/record-sidebar-HqyBXBwn.js","assets/start-block-queries-OldcFqiL.js","assets/record-opens-CNOaCrB0.js","assets/create-route-CZDGdfY8.js","assets/composed-page-D3_OTQB4.js","assets/account-page-K162oV2K.js","assets/sign-in-policy-page-B-m5Pcyb.js","assets/organization-page-DE4U9Xbi.js","assets/first-organization-page-B986-W2g.js","assets/use-my-invitations-BIsBGgmc.js","assets/organizations-page-DcRX2C5D.js","assets/members-page-CCLPZ9sH.js","assets/invitations-page-Ds817tOV.js","assets/connect-route-D0m9ozLK.js","assets/public-form-page-C2K3mhKj.js","assets/lib-altcha-lib-BK1uKcxH.js","assets/guest-call-page-CKEva7eV.js","assets/assistant-shell-BudITySr.js","assets/call-rings-pKCPyD1-.js","assets/runtime-update-DWO9xR0h.js","assets/workflow-field-D7X0A1GO.js","assets/use-run-trace-DFLNmghw.js","assets/workflows-Bey4jszG.js","assets/lib-ajv-BPyvefs9.js","assets/lib-fast-deep-equal-BGljVuDb.js","assets/lib-json-schema-traverse-DxXzBYGi.js","assets/lib-fast-uri-DriPOqOU.js","assets/lib-jsonata-Cu4QFOo8.js","assets/use-workflow-types-BFToPBTN.js","assets/use-workflow-page-Cfztiqhc.js","assets/workflow-run-field-DJLolq5e.js","assets/workflow-status-field-weFyKOIV.js","assets/lib-zod-CxxP7Qhu.js","assets/custom-step-container-field-DTCgqZMO.js","assets/runner-install-field--7xa6MIJ.js","assets/markdown-content-CfblNnhw.js","assets/lib-dompurify-Dr60P-Rn.js","assets/lib-marked-Bg9_sE-m.js","assets/safe-html-CmkqDcA6.js","assets/html-viewer-FMIvHlJ9.js","assets/message-content--7TsRUEK.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,r as t}from"./rolldown-runtime-DFwUHQ4A.js";import{i as n,n as r,r as i,t as a}from"./react-CuiNlnus.js";import{A as o,C as s,D as c,E as l,M as u,O as d,S as f,T as p,_ as m,a as h,b as g,c as _,d as v,f as y,g as b,h as x,i as S,j as C,k as w,l as T,m as E,n as D,o as O,p as k,r as A,s as ee,t as te,u as ne,v as re,w as ie,x as j,y as ae}from"./vendor-t7Q7QbPu.js";var M=e(n(),1),N=e(i(),1),oe=r(),se=t({default:()=>ce}),ce={},le=(e,t)=>{try{return e()}catch(e){if(!(e instanceof DOMException))throw e;return t}},ue=e=>e.addEventListener(`touchstart`,de,{passive:!0}),de=()=>{},P=(e,t,n,r)=>({code:e,message:t,hint:n,span:r}),fe=(e,t)=>{let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++){let o=e[r-1]===t[a-1]?0:1;i[a]=Math.min(n[a]+1,i[a-1]+1,n[a-1]+o)}n=i}return n[t.length]},pe=(e,t)=>{let n=e.toLowerCase(),r=t.map(e=>({candidate:e,score:fe(n,e.toLowerCase())})).sort((e,t)=>e.score-t.score)[0];return r&&r.score<=Math.max(2,Math.floor(e.length/3))?r.candidate:void 0},me=(e,t)=>Object.hasOwn(e.fields,t)?e.fields[t]:Object.values(e.fields).find(e=>e.aliases.includes(t)),he=(e,t,n)=>{if(t.path.length>1){e.errors.push(P(`unsupported-traversal`,`Traversal into "${t.path.join(`.`)}" is not supported yet`,`Filter on fields of this resource only`,t.span));return}let r=t.path[0],i=me(e.model,r);if(!i){let i=Object.values(e.model.fields).filter(e=>e[n]).map(e=>e.name),a=pe(r,i);e.errors.push(P(`unknown-field`,`Unknown field "${r}"`,a?`Did you mean "${a}"?`:`Available fields: ${i.join(`, `)}`,t.span));return}if(!i[n]){let r=n===`filterable`?`filterable`:`sortable`;e.errors.push(P(n===`filterable`?`not-filterable`:`not-sortable`,`Field "${i.name}" is not ${r}`,`Mark it with .${r}() in data.ts`,t.span));return}return i},ge={in:{params:[{name:`field`,type:`field`}],rest:{name:`value`,type:`any`}},search:{params:[{name:`text`,type:`string`}]},similar:{params:[{name:`field`,type:`field`,of:[`string`]},{name:`text`,type:`string`}]},regex:{params:[{name:`field`,type:`field`,of:[`string`]},{name:`pattern`,type:`string`}]},isNull:{params:[{name:`field`,type:`field`}]},related:{params:[{name:`field`,type:`field`},{name:`key`,type:`field`}],rest:{name:`filter`,type:`any`}},now:{params:[],returns:`timestamp`}},_e={extensions:{arithmetic:`now-offset`,durationUnits:!0}},ve=e=>{switch(e.type){case`text`:return`string`;case`integer`:case`bigint`:return`integer`;case`boolean`:case`timestamp`:case`enum`:return e.type;default:return`any`}},ye=e=>({fields:Object.fromEntries(Object.values(e.fields).map(e=>[e.name,{type:ve(e),filterable:e.filterable,sortable:e.sortable,aliases:e.aliases,...e.enumValues&&{values:e.enumValues}}])),functions:ge}),be=(e,t,n,r)=>{e.errors.push(P(`unsupported`,t,n,r))},xe=(e,t)=>t.kind===`member`?{kind:`field`,path:t.path,span:t.span}:be(e,`Only fields can be compared`,`Put a field name on the left, for example total > 100`,t.span),Se=(e,t)=>{switch(t.kind){case`member`:return{kind:`string`,value:t.path.join(`.`),span:t.span};case`call`:return t.name===`now`&&t.args.length===0?{kind:`now`,span:t.span}:be(e,`${t.name}() cannot be used as a value`,`Only now() is a value function`,t.span);case`binary`:{let n=t.left;return n.kind===`call`&&n.name===`now`&&n.args.length===0&&t.right.kind===`duration`?{kind:`now`,offset:{sign:t.op,duration:t.right},span:t.span}:be(e,`Arithmetic is only supported as now() +/- duration`,`Write now() - 30d`,t.span)}default:return t}},Ce=(e,t)=>(`kind`in t&&[`member`,`call`,`binary`].includes(t.kind)?void 0:t)||(t.kind===`member`?{kind:`string`,value:t.path.join(`.`),span:t.span}:be(e,`Expected a literal value`,`Use strings, numbers, true/false, durations or timestamps`,t.span)),we=e=>{switch(e.kind){case`member`:return e.path.join(`.`);case`string`:case`timestamp`:return e.kind,e.value;case`number`:return e.raw;case`boolean`:return String(e.value);case`duration`:return`${e.amount}${e.unit}`;default:return``}},Te=e=>[`sequence`,`and`,`or`,`not`,`compare`,`has`,`present`,`global`,`call`].includes(e.kind),Ee=e=>{let[t,n,r,...i]=e;if(!(i.length>0)&&!(t&&t.kind!==`string`)&&!(n&&(n.kind!==`number`||!Number.isSafeInteger(n.value)||n.value<1))&&!(r&&r.kind!==`string`))return{...t?.kind===`string`&&{orderBy:t.value},...n?.kind===`number`&&{limit:n.value},...r?.kind===`string`&&{pageToken:r.value}}},De=(e,t,n,r)=>{let[,i,...a]=t.args,o=`related(field, resource.field, (filter), "order_by", limit, "page_token"), each after the field optional`;if(!n||i?.kind!==`member`||i.path.length!==2)return r(o);let s=a[0]&&Te(a[0])?a[0]:void 0,c=Ee(s?a.slice(1):a);if(!c)return r(o);let l={kind:`related`,field:n,resource:i.path[0],key:i.path[1],...c,span:t.span};if(!s)return l;let u=Ae(e,s);return u&&{...l,filter:u}},Oe=(e,t)=>{let[n,r,...i]=t.args,a=n?.kind===`member`?xe(e,n):void 0,o=e=>e?.kind===`string`?e.value:void 0,s=n=>{e.errors.push(P(`invalid-arguments`,`Invalid arguments to ${t.name}()`,`Usage: ${n}`,t.span))};switch(t.name){case`in`:{let n=t.args.slice(1).map(t=>Ce(e,t));return!a||n.length===0?s(`in(field, value1, value2, ...)`):n.every(e=>e)?{kind:`in`,field:a,values:n,span:t.span}:void 0}case`search`:return o(n)!==void 0&&!r?{kind:`search`,text:o(n),span:t.span}:s(`search("text")`);case`similar`:return a&&o(r)!==void 0&&i.length===0?{kind:`similar`,field:a,text:o(r),span:t.span}:s(`similar(field, "text")`);case`regex`:return a&&o(r)!==void 0&&i.length===0?{kind:`regex`,field:a,pattern:o(r),span:t.span}:s(`regex(field, "pattern")`);case`isNull`:return a&&!r?{kind:`isNull`,field:a,span:t.span}:s(`isNull(field)`);case`related`:return De(e,t,a,s);default:e.errors.push(P(`unknown-function`,`Unknown function "${t.name}"`,`Available functions: ${Object.keys(ge).join(`, `)}`,t.span));return}},ke=e=>e.every(e=>e)?e:void 0,Ae=(e,t)=>{switch(t.kind){case`sequence`:case`and`:case`or`:{let n=ke(t.args.map(t=>Ae(e,t)));return n&&{kind:t.kind===`or`?`or`:`and`,args:n,span:t.span}}case`not`:{let n=Ae(e,t.arg);return n&&{kind:`not`,arg:n,span:t.span}}case`compare`:{let n=xe(e,t.left),r=Se(e,t.right);return n&&r&&{kind:`compare`,op:t.op,field:n,value:r,span:t.span}}case`has`:{let n=xe(e,t.left),r=Ce(e,t.right);return n&&r&&{kind:`has`,field:n,value:r,span:t.span}}case`present`:{let n=xe(e,t.left);return n&&{kind:`present`,field:n,span:t.span}}case`global`:return{kind:`search`,text:we(t.value),span:t.span};case`call`:return Oe(e,t)}},je=(e,t={})=>{let n=C(e,{..._e,...t}),r={errors:[]},i=n.ast&&Ae(r,n.ast),a=[...n.errors,...r.errors].sort((e,t)=>e.span.start-t.span.start);return a.length===0?{ok:!0,ast:i,errors:[]}:{ok:!1,ast:i,errors:a}},Me=(e,t)=>t===2?e%4==0&&(e%100!=0||e%400==0)?29:28:[4,6,9,11].includes(t)?30:31,Ne=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return r>=1&&r<=12&&i>=1&&i<=Me(n,r)},Pe=e=>{let t=/^(\d{4}-\d{2}-\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|[+-](\d{2}):(\d{2}))$/.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[2]),Number(t[3]),Number(t[4])],[a,o]=[Number(t[5]??0),Number(t[6]??0)];return Ne(t[1])&&n<=23&&r<=59&&i<=59&&a<=23&&o<=59},Fe=(e,t)=>({message:e,hint:t}),Ie=-(2n**63n),Le=2n**63n-1n,Re=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,ze=e=>e.kind===`number`?e.raw:e.kind===`string`?e.value:void 0,Be=(e,t=`Write ${e} values like the examples in the docs`)=>Fe(`Expected ${e}`,t),Ve=e=>{let t=ze(e),n=t===void 0?NaN:Number(t);if(t===void 0||t.trim()===``||!Number.isSafeInteger(n))return Be(`a whole number`,`Use an integer such as 42, or a bigint field for larger values`)},He=e=>{let t=ze(e);if(t===void 0||!/^-?\d+$/.test(t)||BigInt(t)<Ie||BigInt(t)>Le)return Be(`a 64-bit integer`,`Use plain digits such as 9007199254740993 (no exponent or fraction)`)},Ue=e=>{let t=ze(e);if(t===void 0||!/^-?\d+(\.\d+)?$/.test(t))return Be(`a decimal number`,`Use plain digits such as 100.50, or quote it: "100.50" (no exponent)`)},We=(e,t)=>{if(t.kind===`now`)return e.type===`date`||e.type===`timestamp`?void 0:Fe(`now() only works with date and timestamp fields`,`Field "${e.name}" is ${e.type}`);switch(e.type){case`text`:return t.kind===`string`?void 0:Be(`a quoted string`,`Wrap the text in double quotes`);case`integer`:return Ve(t);case`bigint`:return He(t);case`decimal`:return Ue(t);case`boolean`:return t.kind===`boolean`?void 0:Be(`true or false`);case`date`:return t.kind===`string`&&Ne(t.value)?void 0:Be(`a date`,`Quote a calendar date: "2012-04-21"`);case`timestamp`:return t.kind===`timestamp`||t.kind===`string`&&Pe(t.value)?void 0:Be(`an RFC-3339 timestamp`,`Use 2012-04-21T11:30:00Z, or now() - 7d`);case`uuid`:return t.kind===`string`&&Re.test(t.value)?void 0:Be(`a uuid`,`Quote a uuid like "0b5a4f0e-6f2a-4a3c-9d4e-1f2a3b4c5d6e"`);case`enum`:return t.kind===`string`&&e.enumValues?.includes(t.value)?void 0:Fe(`Invalid enum value`,`Allowed values: ${(e.enumValues??[]).join(`, `)}`);case`currency`:return t.kind===`string`&&/^[A-Z]{3}$/.test(t.value)?void 0:Be(`an ISO 4217 currency code`,`Use three capital letters, for example "EUR"`);case`country`:return t.kind===`string`&&/^[A-Z]{2}$/.test(t.value)?void 0:Be(`an ISO 3166-1 country code`,`Use two capital letters, for example "NL"`);case`mail_sender`:return t.kind===`string`?void 0:Be(`a mail address`,`Quote the address: "billing@example.com"`);case`relation`:return t.kind===`string`||t.kind===`number`&&Number.isSafeInteger(t.value)?void 0:Be(`a record key`,`Use the related record key: 42 or "abc"`);case`json`:case`file`:return Fe(`${e.type} fields cannot be compared`,`Use field:value on json fields, or isNull(field)`)}},Ge=[`=`,`!=`],Ke=[`=`,`!=`,`<`,`<=`,`>`,`>=`],qe=e=>{switch(e){case`text`:case`integer`:case`bigint`:case`decimal`:case`date`:case`timestamp`:return Ke;case`json`:case`file`:return[];default:return Ge}},Je=e=>e===`json`||e===`file`,Ye=e=>P(`unsupported-traversal`,`related() only works in a list's filter, ANDed with the rest`,`Put it at the top of the filter or of a subfilter, joined with AND`,e),Xe=(e,t,n)=>{let r=We(t,n);return r&&e.errors.push(P(`invalid-value`,r.message,r.hint,n.span)),!r},Ze=(e,t,n,r)=>{e.errors.push(P(`operator-not-allowed`,t,n,r))},Qe=(e,t)=>(e===`=`||e===`!=`)&&t.kind===`string`&&t.value.includes(`*`),$e=(e,t)=>{let n=he(e,t.field,`filterable`);if(!n)return;let r=qe(n.type);if(!r.includes(t.op)){Ze(e,`Operator "${t.op}" is not supported for ${n.type} fields`,r.length?`Supported: ${r.join(` `)}`:`Use field:value on json fields, or isNull(field)`,t.span);return}if(Qe(t.op,t.value)&&n.type!==`text`){e.errors.push(P(`wildcard-not-allowed`,`Wildcards are only supported on text fields, not ${n.type}`,`Remove the "*" or filter a text field`,t.value.span));return}if(Qe(t.op,t.value)||Xe(e,n,t.value))return{...t,field:n}},et=(e,t)=>{let n=he(e,t.field,`filterable`);if(n){if(n.type!==`json`){Ze(e,`":" is only supported on json fields, not ${n.type}`,`Use = on ${n.type} fields, or field:* to test for a value`,t.span);return}return{...t,field:n}}},tt=(e,t)=>{let n=he(e,t.field,`filterable`);if(n){if(Je(n.type)){Ze(e,`in() is not supported for ${n.type} fields`,`Use field:value on json fields`,t.span);return}return t.values.map(t=>Xe(e,n,t)).every(Boolean)?{...t,field:n}:void 0}},nt=(e,t,n)=>{let r=he(e,n,`filterable`);if(r&&r.type!==`text`){Ze(e,`${t}() only works on text fields, not ${r.type}`,`Field "${r.name}" is ${r.type}`,n.span);return}return r},rt=(e,t)=>{switch(t.kind){case`and`:case`or`:{let n=t.args.map(t=>rt(e,t));return n.every(e=>e)?{...t,args:n}:void 0}case`not`:{let n=rt(e,t.arg);return n&&{...t,arg:n}}case`compare`:return $e(e,t);case`has`:return et(e,t);case`in`:return tt(e,t);case`search`:if(e.model.search?.length)return t;e.errors.push(P(`no-search-fields`,`This resource has no search fields`,`Declare them with .search((r) => [r.title]) in data.ts`,t.span));return;case`present`:case`isNull`:{let n=he(e,t.field,`filterable`);return n&&{...t,field:n}}case`similar`:case`regex`:{let n=nt(e,t.kind,t.field);return n&&{...t,field:n}}case`related`:e.errors.push(Ye(t.span));return}},it=(e,t)=>{let n={model:e,errors:[]},r=rt(n,t);return!r||n.errors.length>0?{ok:!1,errors:[...n.errors].sort((e,t)=>e.span.start-t.span.start)}:{ok:!0,filter:r}},at=(e,t)=>`path`in e?{kind:`member`,path:e.path,span:e.span}:{kind:`member`,path:[e.name],field:{name:e.name,spec:{type:ve(e)}},span:t},ot=(e,t,n)=>({kind:`call`,name:e,args:t,span:n}),st=(e,t)=>({kind:`string`,value:e,span:t}),ct=({orderBy:e,limit:t,pageToken:n,span:r})=>{if(e===void 0&&t===void 0)return[];let i=st(e??``,r);if(t===void 0)return[i];let a={kind:`number`,value:t,raw:String(t),span:r};return n===void 0?[i,a]:[i,a,st(n,r)]},lt=e=>{if(e.kind!==`now`)return e;let t={kind:`call`,name:`now`,args:[],span:e.span};return e.offset?{kind:`binary`,op:e.offset.sign,left:t,right:e.offset.duration,span:e.span}:t},ut=(e,t={})=>{let n=e=>ut(e,t);switch(e.kind){case`and`:case`or`:return{kind:e.kind,args:e.args.map(n),span:e.span};case`not`:return{kind:`not`,arg:n(e.arg),span:e.span};case`compare`:return{kind:`compare`,op:e.op,left:at(e.field,e.span),right:lt(e.value),span:e.span};case`has`:return{kind:`has`,left:at(e.field,e.span),right:e.value,span:e.span};case`present`:return{kind:`present`,left:at(e.field,e.span),span:e.span};case`in`:return t.expand?{kind:`or`,args:e.values.map(t=>({kind:`compare`,op:`=`,left:at(e.field,e.span),right:t,span:e.span})),span:e.span}:ot(`in`,[at(e.field,e.span),...e.values],e.span);case`search`:return ot(`search`,[st(e.text,e.span)],e.span);case`similar`:return ot(`similar`,[at(e.field,e.span),st(e.text,e.span)],e.span);case`regex`:return ot(`regex`,[at(e.field,e.span),st(e.pattern,e.span)],e.span);case`isNull`:return t.expand?{kind:`not`,arg:{kind:`present`,left:at(e.field,e.span),span:e.span},span:e.span}:ot(`isNull`,[at(e.field,e.span)],e.span);case`related`:return{kind:`call`,name:`related`,args:[at(e.field,e.span),{kind:`member`,path:[e.resource,e.key],span:e.span},...e.filter?[n(e.filter)]:[],...ct(e)],span:e.span}}},dt=(e,t)=>{let n=it(e,t);if(!n.ok&&n.errors.some(e=>e.code===`unsupported-traversal`))return n;let r=w(ut(t),ye(e));return r.ok?it(e,t):{ok:!1,errors:r.errors}},ft=/^[\d\s+\-().\/]+$/,pt=e=>ft.test(e)?e.replace(/\D/g,``):``,mt=e=>{let t=e.split(/\s+/).filter(Boolean).map(e=>({text:e,digits:pt(e),whole:!1})),n=t.length>1?pt(e.trim()):``;return n?[{text:e.trim(),digits:n,whole:!0},...t]:t},ht=(e,t,n)=>e==null?!1:n===`digitsEnd`?t.digits!==``&&String(e).replace(/\D/g,``).endsWith(t.digits):!t.whole&&String(e).toLowerCase().includes(t.text.toLowerCase()),gt=(e,t,n)=>(e.search??[]).filter(r=>ht(t[r],n,e.searchMatch?.[r])),_t=(e,t,n)=>{let r=mt(n),i=r.filter(e=>!e.whole),a=r.find(e=>e.whole);return a&&gt(e,t,a).length>0?!0:i.length>0&&i.every(n=>gt(e,t,n).length>0)},vt=(e,t,n,r)=>{for(let i of mt(n)){let n=gt(e,t,i);if(n.length>0&&!n.some(e=>r.includes(e)))return n[0]}},yt=e=>u(ut(e)),bt=e=>e.map(e=>({path:e.path.path,direction:e.direction,span:e.span})),xt=e=>e.replace(/([^\s,])(\s+)(asc|desc)(?=\s|,|$)/gi,(e,t,n,r)=>`${t}${n}${r.toLowerCase()}`),St=e=>{let t=d(xt(e)),n=t.items.map(e=>({path:{kind:`field`,path:e.path,span:e.span},direction:e.direction,span:e.span}));return t.ok?{ok:!0,items:n,errors:[]}:{ok:!1,items:n,errors:t.errors}},Ct=(e,t)=>{let n=t.filter(e=>e.path.path.length>1).map(e=>P(`unsupported-traversal`,`Traversal into "${e.path.path.join(`.`)}" is not supported yet`,`Sort on fields of this resource only`,e.path.span));if(n.length>0)return{ok:!1,errors:n};let r=c(bt(t),ye(e));return r.ok?{ok:!0,sort:r.items.map(e=>[e.path[0],e.direction])}:{ok:!1,errors:r.errors}},wt=e=>{let t=/^(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)([smhdw])$/.exec(e);if(!t)throw Error(`Invalid duration "${e}", expected for example 30d or 1.5h`);return{kind:`duration`,amount:Number(t[1]),unit:t[2],span:{start:0,end:0}}},Tt={start:0,end:0},Et=e=>({kind:`field`,path:e.split(`.`),span:Tt}),Dt=e=>{if(typeof e==`string`)return{kind:`string`,value:e,span:Tt};if(typeof e==`boolean`)return{kind:`boolean`,value:e,span:Tt};if(!Number.isFinite(e))throw Error(`Filter numbers must be finite`);return{kind:`number`,value:e,raw:String(e),span:Tt}},Ot=e=>typeof e==`object`?e:Dt(e),kt=(e,t)=>{if(t.length===0)throw Error(`where.${e} needs at least one filter`);return t.length===1?t[0]:{kind:e,args:t,span:Tt}},At=()=>{let e=e=>(t,n)=>({kind:`compare`,op:e,field:Et(t),value:Ot(n),span:Tt}),t=e=>t=>({kind:`now`,offset:{sign:e,duration:wt(t)},span:Tt});return{eq:e(`=`),ne:e(`!=`),lt:e(`<`),lte:e(`<=`),gt:e(`>`),gte:e(`>=`),between:(t,n,r)=>kt(`and`,[e(`>=`)(t,n),e(`<=`)(t,r)]),has:(e,t)=>({kind:`has`,field:Et(e),value:Dt(t),span:Tt}),present:e=>({kind:`present`,field:Et(e),span:Tt}),in:(e,t)=>({kind:`in`,field:Et(e),values:t.map(Dt),span:Tt}),isNull:e=>({kind:`isNull`,field:Et(e),span:Tt}),search:e=>({kind:`search`,text:e,span:Tt}),similar:(e,t)=>({kind:`similar`,field:Et(e),text:t,span:Tt}),regex:(e,t)=>({kind:`regex`,field:Et(e),pattern:t,span:Tt}),related:(e,t,n,r,i)=>({kind:`related`,field:Et(e),resource:t,key:n,...r&&{filter:r},...i,span:Tt}),and:(...e)=>kt(`and`,e),or:(...e)=>kt(`or`,e),not:e=>({kind:`not`,arg:e,span:Tt}),now:()=>({kind:`now`,span:Tt}),ago:t(`-`),fromNow:t(`+`)}},jt=At(),Mt=`[A-Za-z_][A-Za-z0-9_]*`,Nt=`${Mt}(?:\\.${Mt})*`,Pt=`@(?:root|params)(?:\\.${Nt})?|@index|@first|@last|(?:\\.\\./)*(?:this(?:\\.${Nt})?|\\./${Nt}|${Nt})`,Ft=RegExp(`^(?:${Pt})$`),It=/\{\{\s*([^{}]*?)\s*\}\}/g,Lt=e=>{if(!Ft.test(e))return;if(e.startsWith(`@`)){let[t,...n]=e.slice(1).split(`.`);return{kind:`data`,variable:t,names:n}}let t=e,n=0;for(;t.startsWith(`../`);)t=t.slice(3),n+=1;return t===`this`?{kind:`context`,up:n,explicit:!0,names:[]}:t.startsWith(`this.`)?{kind:`context`,up:n,explicit:!0,names:t.slice(5).split(`.`)}:t.startsWith(`./`)?{kind:`context`,up:n,explicit:!0,names:t.slice(2).split(`.`)}:{kind:`context`,up:n,explicit:n>0,names:t.split(`.`)}},Rt=e=>[...e.matchAll(It)].map(e=>e[1]),zt=(e,t)=>e.replace(It,(e,n)=>t(n)),Bt=e=>{let t=/^\{\{\s*([^{}]*?)\s*\}\}$/.exec(e);return t&&Lt(t[1])?t[1]:void 0},Vt=(e,t)=>{let n=Lt(t);if(!(!n||n.kind!==`context`||n.up>0))return n.names.reduce((e,t)=>typeof e==`object`&&e&&Object.hasOwn(e,t)?e[t]:void 0,e)},Ht=Rt,Ut=e=>e.kind===`page`?void 0:Bt(e.resource),Wt=e=>e.kind===`list`&&e.filter!==void 0?Bt(e.filter):void 0,Gt=e=>{if(e.kind===`page`)return[...e.tab===void 0?[]:[e.tab],...Object.values(e.params??{})];let t=Ut(e)===void 0?[]:[e.resource];return e.kind===`record`?[...t,...(Array.isArray(e.key)?e.key:[e.key]).filter(e=>typeof e==`string`),...[e.tab,e.run,e.panel].filter(e=>e!==void 0)]:e.kind===`list`?[...t,...[e.filter,e.orderBy].filter(e=>e!==void 0)]:[...t,...Object.values(e.values??{})]},Kt=e=>[...new Set(Gt(e).flatMap(Ht))],qt=e=>[...new Set(Ht(e))],Jt=qt,Yt=zt,Xt=e=>e==null?``:String(e),Zt=(e,t)=>Yt(e,e=>Xt(t(e))),Qt=/(["'])\{\{\s*([^{}]*?)\s*\}\}\1|\{\{\s*([^{}]*?)\s*\}\}/g,$t=e=>typeof e==`string`&&e!==``&&!/^[\w.:+-]+$/.test(e)?JSON.stringify(e):Xt(e),en=/(?:[=<>:,]|!=)\s*$/,tn=(e,t)=>e.replace(Qt,(n,r,i,a,o)=>{if(r)return`${r}${Xt(t(i)).replace(/\\/g,`\\\\`).replaceAll(r,`\\${r}`)}${r}`;let s=t(a);return en.test(e.slice(0,o))?$t(s):Xt(s)}),nn=(e,t)=>{if(e.kind===`page`)return{...e,...e.tab!==void 0&&{tab:Zt(e.tab,t)},...e.params&&{params:Object.fromEntries(Object.entries(e.params).map(([e,n])=>[e,Zt(n,t)]))}};let n=Ut(e)===void 0?e.resource:Zt(e.resource,t);if(e.kind===`record`){let r=e=>typeof e==`string`?Zt(e,t):e;return{...e,resource:n,key:Array.isArray(e.key)?e.key.map(r):r(e.key),...e.tab!==void 0&&{tab:Zt(e.tab,t)},...e.run!==void 0&&{run:Zt(e.run,t)},...e.panel!==void 0&&{panel:Zt(e.panel,t)}}}return e.kind===`create`?{...e,resource:n,...e.values&&{values:Object.fromEntries(Object.entries(e.values).map(([e,n])=>[e,Zt(n,t)]))}}:{...e,resource:n,...e.filter!==void 0&&{filter:tn(e.filter,t)},...e.orderBy!==void 0&&{orderBy:Zt(e.orderBy,t)}}},rn=(e,t={})=>nn(e,e=>Vt(t,e)),an=e=>e.kind===`list`&&e.filter!==void 0?[...new Set([...e.filter.matchAll(Qt)].flatMap(e=>e[3]===void 0?[]:[e[3]]))]:[],on=/(["'])(?:\\[\s\S]|(?!\1)[^\\])*\1/g,sn=/^(["'])\{\{\s*[^{}]*?\s*\}\}\1$/,cn=e=>[...new Set([...e.matchAll(on)].flatMap(([e])=>sn.test(e)?[]:Ht(e)))],ln=e=>/^([a-z][a-z0-9+.-]*:|\/\/)/i.test(e),un=e=>ln(e)?void 0:`href "${e}" points inside the app; give the link \`to\` instead, an address such as { kind: 'record', resource: 'orders', key: '{{order_id}}' }`,dn=Bt,fn=`{{host}}`,pn=(e,t)=>`href`in t?dn(t.href)?void 0:un(t.href):e.includes(`{{host}}`)?`the label names ${fn}, which only a link with an href has`:void 0,mn=Symbol(`protobase.ref`),hn=e=>Object.defineProperty({name:e},mn,{value:!0}),gn=e=>typeof e==`object`&&!!e&&e[mn]===!0,_n=(e,t)=>new Proxy({},{get:(n,r)=>{if(typeof r!=`symbol`){if(t&&!t.includes(r))throw Error(`Unknown field "${r}"`);return e(r)}}}),vn=e=>({$field:e}),yn=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===1&&typeof e.$field==`string`,bn=e=>typeof e==`object`&&!!e&&!Array.isArray(e),xn=e=>gn(e)?vn(e.name):Array.isArray(e)?e.map(xn):bn(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,xn(t)])):e,Sn=e=>yn(e)?e.$field:Array.isArray(e)?e.map(Sn):bn(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Sn(t)])):e,Cn=e=>yn(e)?[e.$field]:Array.isArray(e)?e.flatMap(Cn):bn(e)?Object.values(e).flatMap(Cn):[],wn=({label:e,icon:t})=>({...e!==void 0&&{label:e},...t!==void 0&&{icon:t}}),Tn=`table`,En=(e,t)=>{if(!e.custom)throw Error(`${t} takes a component declared with component(...), not the built-in block ${e.blockName}`);return e.blockName},Dn={cards:(e,t={})=>({kind:`cards`,name:t.name??`cards`,...wn(t),...e.image&&{image:e.image.name},...e.title&&{title:e.title.name},...e.subtitle&&{subtitle:e.subtitle.name},...e.amount&&{amount:e.amount.map(e=>e.name)},...e.badge&&{badge:e.badge.name},...e.code&&{code:e.code.name},...e.meta&&{meta:e.meta.map(e=>e.name)},...e.footer&&{footer:e.footer.map(e=>e.name)},...e.flags&&{flags:e.flags.map(e=>e.name)},...e.dots&&{dots:e.dots.map(e=>e.name)},...t.card&&{card:En(t.card,`d.cards card`)},...t.photos&&{photos:{...t.photos}},...t.favorite&&{favorite:{...t.favorite}}}),map:(e,t={})=>({kind:`map`,name:t.name??`map`,...wn(t),latitude:e.latitude.name,longitude:e.longitude.name,...t.cards!==void 0&&{cards:t.cards},...e.approximate&&{approximate:e.approximate.name},...e.exact&&{exact:e.exact.name},...e.radius&&{radius:e.radius.name},...t.defaultRadius!==void 0&&{defaultRadius:t.defaultRadius},...e.area&&{area:e.area.name}}),board:(e,t={})=>({kind:`board`,name:t.name??`board`,...wn(t),by:e.by.name,...e.title&&{title:e.title.name},...e.subtitle&&{subtitle:e.subtitle.name},...e.badge&&{badge:e.badge.name},...e.meta&&{meta:e.meta.map(e=>e.name)}}),calendar:(e,t={})=>({kind:`calendar`,name:t.name??`calendar`,...wn(t),start:e.start.name,...e.end&&{end:e.end.name},...e.title&&{title:e.title.name}}),timeline:(e,t={})=>({kind:`timeline`,name:t.name??`timeline`,...wn(t),start:e.start.name,...e.end&&{end:e.end.name},...e.group&&{group:e.group.name},...e.title&&{title:e.title.name}}),custom:(e,t)=>({kind:`custom`,name:t.name,label:t.label,...wn({icon:t.icon}),component:En(e,`d.custom`),fields:t.fields.map(e=>e.name),...t.props&&{props:xn(t.props)}})},On=/^[a-z][a-zA-Z0-9-]*$/,kn=e=>{let t=(e.displays??[]).map(e=>e.name);return[...t.filter(e=>!On.test(e)).map(e=>`display name "${e}" must start with a lowercase letter and hold only letters, digits and dashes`),...t.filter(e=>e===Tn).map(()=>`"${Tn}" is the list's own display; give the display another name`),...t.filter((e,n)=>t.indexOf(e)!==n).map(e=>`display "${e}" is defined twice`),...(e.displays??[]).flatMap(t=>t.kind===`map`&&t.cards!==void 0&&!e.displays.some(e=>e.kind===`cards`&&e.name===t.cards)?[`display "${t.name}" names cards "${t.cards}", which is not a cards display of the list`]:[]),...(e.displays??[]).flatMap(t=>t.kind===`cards`?(t.dots??[]).filter(t=>!e.relatedColumns?.some(e=>e.name===t)).map(e=>`display "${t.name}" shows dots of "${e}", which is not a related column of the list`):[]),...(e.displays??[]).flatMap(e=>e.kind===`map`?An(e).map(t=>`display "${e.name}": ${t}`):[]),...e.default===void 0||e.default===`table`||t.includes(e.default)?[]:[`default "${e.default}" is not one of the displays (${[Tn,...t].join(`, `)})`]]},An=e=>{let{approximate:t,exact:n,radius:r,defaultRadius:i,area:a}=e;return t!==void 0&&n!==void 0?[`name approximate or exact, not both`]:[...(r!==void 0||i!==void 0||a!==void 0)&&t===void 0&&n===void 0?[`an area around approximate positions needs the approximate or exact field`]:[],...i===void 0||Number.isFinite(i)&&i>0?[]:[`defaultRadius ${i} is not a number of metres above 0`]]},jn=(e,t,n)=>{let r=Object.hasOwn(t.fields,e.by)?t.fields[e.by]:void 0;return r?r.type===`enum`?r.filterable?typeof n==`object`?Mn(e.by,r.enumValues??[],n,t):[]:[`"${e.by}" on ${t.name} is not filterable, and each column of the board filters by its value`]:[`"${e.by}" on ${t.name} is ${r.type}, not an enum, whose values are the board's columns`]:[]},Mn=(e,t,{set:n=e,columns:r},i)=>{let a=r?.filter(e=>!t.includes(e))??[];if(a.length>0)return a.map(t=>`drag.board takes cards in column "${t}", which is no value of "${e}"`);let o=Object.hasOwn(i.fields,n)?i.fields[n]:void 0;return o?o.readOnly?[`drag.board sets "${n}", which is read-only`]:o.type===`enum`?(r??t).filter(e=>!o.enumValues?.includes(e)).map(e=>`drag.board sets "${n}" to "${e}", which is no value of "${n}"`):[]:[`drag.board sets "${n}", which ${i.name} does not have`]},Nn=(e,t)=>{let n=e=>Object.hasOwn(t.fields,e)?t.fields[e]:void 0,r=n(e.start),i=e.end===void 0?void 0:n(e.end);if(!r)return[];if(r.type!==`date`&&r.type!==`timestamp`)return[`start "${e.start}" on ${t.name} is ${r.type}, not a date or timestamp`];let a=n=>`${n===e.start?`start`:`end`} "${n}" on ${t.name} is not filterable, and the ${e.kind} filters by it for the days it shows`;return[...r.filterable?[]:[a(e.start)],...i&&i.type!==r.type?[`end "${e.end}" on ${t.name} is ${i.type}, not ${r.type} like start "${e.start}"`]:[],...i&&i.type===r.type&&!i.filterable?[a(e.end)]:[]]},Pn=e=>e.kind===`map`?[e.latitude,e.longitude,e.approximate,e.exact,e.radius,e.area].filter(e=>e!==void 0):e.kind===`custom`?[...e.fields,...Cn(e.props)]:e.kind===`board`?[e.by,e.title,e.subtitle,e.badge,...e.meta??[]].filter(e=>e!==void 0):e.kind===`calendar`?[e.start,e.end,e.title].filter(e=>e!==void 0):e.kind===`timeline`?[e.start,e.end,e.group,e.title].filter(e=>e!==void 0):[e.image,e.title,e.subtitle,...e.amount??[],e.badge,e.code,...e.meta??[],...e.footer??[],...e.flags??[]].filter(e=>e!==void 0),Fn=/^[a-z0-9][a-z0-9_-]*$/,In=e=>{if(!e.startsWith(`/-/forms/`))return;let t=e.slice(9);return Fn.test(t)?{name:t}:void 0},Ln=e=>e.flatMap(e=>e.kind===`group`||e.kind===`tab`?Ln(e.items):e.kind===`custom`?[e,...Ln(e.fallback??[])]:[e]),Rn=(e,t)=>{if(t===void 0)return e;let n=e?.lists?.find(e=>e.name===t);if(!e||!n)return;let{list:r,chart:i,help:a,nav:o,lists:s,names:c,...l}=e,{name:u,...d}=n;return{...l,...d}},zn=[`neutral`,`info`,`success`,`warning`,`danger`],Bn=20,Vn=(e,t)=>{let n=je(t);if(!n.ok)return n.errors;if(!n.ast)return[];let r=dt(e,n.ast);return r.ok?[]:r.errors},Hn=(e,t)=>{let n=St(t);if(!n.ok)return n.errors;let r=Ct(e,n.items);return r.ok?[]:r.errors},Un=(e,t)=>[...e.status===void 0||Object.hasOwn(t.fields,e.status)?[]:[`status field "${e.status}" does not exist`],...e.status===void 0&&e.pulse!==void 0?[`pulse needs a status field`]:[],...Object.entries(e.tones??{}).filter(([,e])=>!zn.includes(e)).map(([e,t])=>`tone "${t}" for "${e}" is not one of ${zn.join(`, `)}`),...e.limit===void 0||Number.isInteger(e.limit)&&e.limit>=1&&e.limit<=Bn?[]:[`limit must be a whole number from 1 to ${Bn}`],...e.filter===void 0?[]:Vn(t,e.filter).map(e=>`filter: ${e.message}`),...e.orderBy===void 0?[]:Hn(t,e.orderBy).map(e=>`orderBy: ${e.message}`),...e.marks===void 0||typeof e.marks==`string`&&e.marks!==``?[]:[`marks needs the name of a hook in the project UI's marks`]],Wn=`members`,Gn=(e,t)=>{if(!e||!(`conversation`in e))return[];let{subtitle:n,members:r}=e.conversation;return[...n===void 0||Object.hasOwn(t.fields,n)?[]:[`conversation subtitle names field "${n}", which the resource does not have`],...r===void 0||Object.hasOwn(t.fields,r)?[]:[`conversation members names field "${r}", which the resource does not have`]]},Kn=e=>{if(e&&`conversation`in e&&e.conversation.members!==void 0)return{titleFrom:{rule:Wn,fields:[e.conversation.members]}}},qn=[`neutral`,`blue`,`green`,`amber`,`red`,`violet`],Jn=e=>qn.includes(e),Yn=e=>`${e}/workflows/types`,Xn=(e,t)=>`${e}/workflows/runners/${encodeURIComponent(t)}/registration`,Zn=e=>`${e}/workflows/runs`,Qn=`after`,$n=`revision`,er=(e,t,n)=>{let r=`${Zn(e)}/${encodeURIComponent(t)}/trace`;return!n||n.after===0?r:`${r}?${new URLSearchParams({[Qn]:String(n.after),[$n]:n.revision})}`},tr=e=>{if(!Array.isArray(e))return String(e);let t=e;return t.length===1?String(t[0]):t.map(e=>encodeURIComponent(String(e))).join(`,`)},nr=e(l(),1),rr=(e,t)=>{let n=Object.entries(e.imports).flatMap(([e,n])=>{let r=t.imports[e];return r===void 0?[e]:n.filter(e=>e!==`*`&&!r.includes(e)).map(t=>`${t} from ${e}`)}),r=e.extensionPoints.filter(e=>!t.extensionPoints.includes(e)).map(e=>`the extension point ${e}`);return[...n,...r]},ir=e=>{try{return new nr.default.Comparator(e),!0}catch(e){if(e instanceof TypeError)return!1;throw e}},ar=(e,t)=>{let n=t.trim().split(/\s+/);if(nr.default.valid(e)!==null&&t.trim()!==``&&n.every(ir))return nr.default.satisfies(e,t,{includePrerelease:!0})},or=(e,t)=>{if(e.api!==t.api)return`it is built for plugin API ${e.api}, and this app has plugin API ${t.api}`;if(e.protobase!==void 0){let n=ar(t.version,e.protobase);if(n===void 0)return`its Protobase range "${e.protobase}" is not one this app reads, such as >=0.12.0`;if(!n)return`it needs Protobase ${e.protobase}, and this app runs ${t.version}`}let n=rr(e,t);if(n.length>0)return`it uses what this app does not have: ${n.join(`, `)}`},sr=`[Filtered]`,cr=/authorization|cookie|passw|secret|token|api[-_]?key|credential|session|csrf|signature|^sig$/i,lr=new Set([`url`,`query_string`,`from`,`to`]),ur=12,dr=e=>e.replace(/(^|&)([^=&]*)=([^&]*)/g,(e,t,n)=>cr.test(n)?`${t}${n}=${sr}`:e),fr=e=>{let t=e.indexOf(`?`);if(t===-1)return e;let n=e.indexOf(`#`,t),r=n===-1?e.slice(t+1):e.slice(t+1,n);return`${e.slice(0,t+1)}${dr(r)}${n===-1?``:e.slice(n)}`},pr=(e,t,n)=>cr.test(e)?sr:typeof t==`string`&&lr.has(e)?e===`query_string`?dr(t):fr(t):mr(t,n+1),mr=(e,t)=>t>ur||typeof e!=`object`||!e?e:Array.isArray(e)?e.map(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`?[e[0],pr(e[0],e[1],t)]:mr(e,t+1)):Object.fromEntries(Object.entries(e).map(([e,n])=>[e,pr(e,n,t)])),hr=e=>mr(e,0),gr=`protobase-app`,_r=[`unknown-field`,`not-filterable`,`not-sortable`,`unsupported-traversal`,`invalid-traversal`],vr=e=>e.replace(/(["']?)\{\{\s*[^{}]*?\s*\}\}\1/g,(e,t)=>t?`${t}x${t}`:`0`),yr=(e,t)=>{let n=cn(t);if(n.length>0)return n.map(e=>`filter: "{{${e}}}" sits inside a longer quoted value; quote it alone, such as title = "{{${e}}}"`);let r=je(vr(t));if(!r.ok)return r.errors.map(e=>`filter: ${e.message}`);if(!r.ast)return[];let i=dt(e,r.ast);return i.ok?[]:i.errors.filter(e=>_r.includes(e.code)).map(e=>`filter: ${e.message}`)},br=(e,t)=>{if(Kt({kind:`list`,resource:e.name,orderBy:t}).length>0)return[];let n=St(t);if(!n.ok)return n.errors.map(e=>`orderBy: ${e.message}`);let r=Ct(e,n.items);return r.ok?[]:r.errors.map(e=>`orderBy: ${e.message}`)},xr=(e,{models:t,pages:n,source:r,placeholderError:i,createPages:a,filterFromRecord:o})=>{let s=Kt(e).flatMap(e=>{if(i){let t=i(e);return t===void 0?[]:[t]}return r?Object.hasOwn(r.fields,e)?[]:[`"{{${e}}}" is not a field of ${r.name}`]:[`"{{${e}}}" takes a value from the record, but the link sits on none`]}),c=o===!0&&Wt(e)!==void 0;if(e.kind!==`page`&&Ut(e)!==void 0){if(!(e.kind===`list`?e.filter!==void 0&&!c||e.orderBy!==void 0:e.kind===`create`&&e.values!==void 0))return s;let t=o?`no order or values, and a filter only as one field, such as filter: '{{filter}}'`:`no filter, order or values`;return[...s,`a link whose resource comes from the record ("${e.resource}") names ${t}`]}switch(e.kind){case`page`:return n&&!n.has(e.page)?[...s,`unknown page "${e.page}"`]:s;case`list`:case`record`:case`create`:{let n=Object.hasOwn(t,e.resource)?t[e.resource]:void 0;return n?e.kind===`create`&&a?.has(e.resource)?s:e.kind===`create`?[...s,...Object.keys(e.values??{}).filter(e=>!Object.hasOwn(n.fields,e)).map(t=>`values: unknown field "${t}" on ${e.resource}`)]:e.kind===`list`?[...s,...e.filter&&!c?yr(n,e.filter):[],...e.orderBy?br(n,e.orderBy):[]]:s:[`unknown resource "${e.resource}"`]}default:return[`an address's kind is list, record, create or page, not "${String(e.kind)}"`]}},Sr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Cr=`a row button is { label, to } or { label, href }, such as { label: 'Open', to: { kind: 'record', resource: 'tasks', key: '{{id}}' } } or { label: 'Report', href: '{{report_url}}' }, or a list of them`,wr=e=>Array.isArray(e)?e:[e],Tr=e=>{let t=e.href;return t===void 0?{to:e.to}:{href:t}},Er=e=>{let t=Tr(e);return[...new Set([...qt(e.label),...`href`in t?qt(t.href):Kt(t.to)])]},Dr=e=>[...new Set(wr(e).flatMap(Er))],Or=(e,t,n)=>e.flatMap(e=>Object.hasOwn(t.fields,e)?[]:[`${n}: "{{${e}}}" is not a field of ${t.name}`]),kr=(e,t,n)=>{if(!Sr(e))return[Cr];if(typeof e.label!=`string`||e.label.trim()===``)return[`a row button needs a label`];if(e.to!==void 0&&e.href!==void 0)return["a row button opens an address in `to` or an outside page in `href`, not both"];let r=Or(qt(e.label),t,`label`);if(e.href!==void 0){let n=typeof e.href==`string`?dn(e.href):void 0;return n===void 0?[...r,`href: a row button's href is the one field that holds the page's https URL, such as '{{report_url}}'`]:[...r,...Or([n],t,`href`)]}return!Sr(e.to)||typeof e.to.kind!=`string`?["a row button needs an address in `to`, such as { kind: 'record', resource: 'tasks', key: '{{id}}' }, or an outside page in `href`"]:[...r,...xr(e.to,{...n,source:t,filterFromRecord:!0}).map(e=>`to: ${e}`)]},Ar=(e,t,n)=>Array.isArray(e)?e.length===0?[`a row button list needs at least one choice`]:e.flatMap((e,r)=>kr(e,t,n).map(e=>`choice ${r+1}: ${e}`)):kr(e,t,n),jr=(e,t,n)=>{if(!Array.isArray(e))return Ar(e,t,n).length===0?e:void 0;let r=wr(e).filter(e=>kr(e,t,n).length===0);return r.length===0?void 0:r},Mr={messages:[],replying:!1},Nr=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);return n===-1?[...e,t]:e.map((e,r)=>r===n?t:e)},Pr=(e,t,n)=>{let r=e.find(e=>e.id===t);return Nr(e,r?{...r,parts:Nr(r.parts,n)}:{id:t,from:`assistant`,parts:[n]})},Fr=(e,t)=>{switch(t.type){case`state`:return t.state;case`message`:return{...e,messages:Nr(e.messages,t.message)};case`part`:return{...e,messages:Pr(e.messages,t.messageId,t.part)};case`patch`:{let{replying:n=e.replying,status:r=e.status,placeholder:i=e.placeholder}=t;return{messages:e.messages,replying:n,...r!=null&&{status:r},...i!=null&&{placeholder:i}}}}},Ir=e=>{if(!(e instanceof DOMException&&e.name===`AbortError`))throw e},Lr=async(e,t,n)=>{let r=p({onEvent:e=>t(e.data)}),i=new TextDecoder,a=e.getReader();for(n?.addEventListener(`abort`,()=>void a.cancel().catch(Ir),{once:!0});;){let{done:e,value:t}=await a.read();if(e)break;r.feed(i.decode(t,{stream:!0}))}r.feed(`${i.decode()}\n\n`)},Rr=[`en`,`nl`],zr=e=>Rr.includes(e),Br=e=>e.map(e=>e.split(`-`)[0].toLowerCase()).find(zr)??`en`,Vr=e=>e.charAt(0).toUpperCase()+e.slice(1),Hr=e=>Vr(e.replace(/(Id|Code|_id|_code)$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/_+/g,` `).trim().toLowerCase()||e),Ur=(e,t)=>t?.[e]??e,Wr=[`name`,`title`,`number`,`sku`,`email`,`code`,`description`],Gr=e=>e?.type===`text`&&!e.sensitive,Kr=(e,t)=>t?.title??Wr.find(t=>Gr(e.fields[t]))??Object.values(e.fields).find(Gr)?.name??e.primaryKey[0],qr=(e,t)=>t?.title??t?.list?.columns.find(t=>e.fields[t]?.type===`text`)??Kr(e),Jr=(e,t,n,r)=>{let i=qr(e,t),a=n[i];return a==null?r:e.fields[i]?.type===`enum`?Ur(String(a),t?.fields[i]?.valueLabels):String(a)},Yr=`protobase-api-origin`,Xr={fingerprint:`fingerprint`,shellVersion:`shell_version`},Zr=`/api/mobile/release`,Qr=`/api/mobile/releases`,$r=({fingerprint:e,shellVersion:t})=>new URLSearchParams({[Xr.fingerprint]:e,[Xr.shellVersion]:t}).toString(),ei=`/api/auth`,ti=`second-step`,ni={ios:`capacitor://localhost`,android:`https://localhost`},ri={database:`protobase-push`,store:`registration`,key:`current`},ii=`protobase.sw.js`,ai=`token`,oi=(e,t)=>`${e}?${new URLSearchParams({[ai]:t})}`,si=(e,t)=>`${e}/notifications/devices${t===void 0?``:`/${encodeURIComponent(t)}`}`,ci=`app`,li=e=>`${e}/files`,ui=(e,t,n)=>`${e}/${t}/${n}`,di=e=>{let t=/^([a-z][a-z0-9-]*):([A-Za-z0-9_-][^?#]*)/.exec(e);return t?{provider:t[1],path:t[2]}:void 0},fi=e=>`${e}${e.includes(`?`)?`&`:`?`}via=${ci}`,pi=/^[^\s\u0000-\u001f\u007f-\u009f]+$/,mi=e=>{if(typeof e!=`string`||e.length>2048||!pi.test(e)||!URL.canParse(e))return;let t=new URL(e);if(t.protocol===`https:`||t.protocol===`http:`)return t.href},hi=/^[A-Za-z0-9_-]{1,64}$/,gi=(e,t)=>{let n=`${e}/notifications/history`;if(t===void 0)return n;if(typeof t==`string`)return`${n}/${t}`;if(!hi.test(t.read))throw Error(`A history entry id is letters, digits, "_" and "-" only`);return`${n}/${t.read}/read`},_i=(e,t)=>`${e}/status${t===void 0?``:`/${t}`}`,vi=/\p{Cc}/u,yi=e=>{if(vi.test(e))return`A status is one line of text, without control characters`;if([...e].length>100)return`A status is at most 100 characters`},bi=(e,t=Date.now())=>{if(e&&!(e.clearsAt!==null&&Date.parse(e.clearsAt)<=t)&&(e.availability!==`automatic`||e.text!==null))return e},xi=(e,t)=>t?.list?.columns??Object.values(e.fields).filter(e=>!e.writeOnly).slice(0,6).map(e=>e.name),Si={json:[`json`],members:[`json`],workflow:[`json`],workflow_run:[`uuid`],workflow_status:[`enum`],custom_step_container:[`json`],runner_install:[`uuid`]},Ci=(e,t)=>`${e}/calls/guests${t?`/${t}`:``}`,wi=`$rings`,Ti=`decline`,Ei=(e,t)=>{let n=`${e}/calls/rings`;return t===void 0?n:`${n}/${encodeURIComponent(t.decline)}/${Ti}`},Di=`calls`,Oi=`en`,ki,Ai=()=>ki??Oi,ji=()=>Oi,Mi=e=>{Oi=e},Ni=e=>{ki=e},Pi=(e=globalThis.navigator?.languages??[])=>Br(e),Fi={en:`en-GB`,nl:`nl-NL`},Ii=()=>Fi[Ai()],Li={en:()=>s(()=>import(`./en-0TxR0Vfb.js`).then(e=>e.default),[]),nl:()=>s(()=>import(`./nl-mDiTKi5y.js`).then(e=>e.default),[])},Ri={},zi=new Map,Bi=(e,t)=>{Ri[e]=t},Vi=e=>Ri[e]!==void 0,Hi=e=>{if(Vi(e))return Promise.resolve();let t=zi.get(e)??Li[e]().then(t=>Bi(e,t));return zi.set(e,t),t},Ui=async e=>{await Hi(e),Mi(e)},Wi=e=>{let t=Ri[e];if(!t)throw Error(`The ${e} texts are not loaded: await loadTexts('${e}') first`);return t},Gi={lower:e=>e.join(``).toLowerCase()},Ki=new Map,qi=(e,t)=>{let n=Ai(),r=`${n}\0${e}\0${t}`,i=Ki.get(r);if(i)return i;let a=Wi(n)[e][t];if(a===void 0)throw Error(`No text ${e}.${t} in ${n}`);let o=new ie(a,Ii());return Ki.set(r,o),o},F=e=>{let t=(t,n)=>qi(e,t).format({...n,...Gi});return t.rich=(t,n)=>{let r=qi(e,t).format({...n,...Gi});return Array.isArray(r)?(0,M.createElement)(M.Fragment,null,...r):r},t},I={meta:[`meta`],activeRole:[`session`,`active-role`],organizations:[`session`,`organizations`],organizationMembers:e=>[`session`,`members`,e],myInvitations:[`session`,`my-invitations`],sourceMeta:(e,t)=>[`source-meta`,e,t.join(`,`)],sourceMetas:e=>[`source-meta`,e],list:(e,t,n,r,i)=>[`list`,e,t,n,r,i],page:(e,t,n,r,i)=>[`page`,e,t,n,r,i],pages:(e,t,n)=>[`page`,e,t,n],navRecent:(e,t,n,r)=>[`list`,e,t,n,r,`nav-recent`],startRecord:(e,t,n,r)=>[`list`,e,t,n,`start-record`,r],reactionsOf:(e,t)=>[`list`,e,t,`reactions-of`],attachmentsOf:(e,t)=>[`list`,e,t,`attachments-of`],first:(e,t,n)=>[`first-page`,e,t,n],record:(e,t)=>[`record`,e,t],image:(e,t)=>[`image`,e,t],recordPreview:(e,t)=>[`record-preview`,e,t],history:(e,t,n)=>[`record`,e,t,`history`,n],comments:(e,t)=>[`record`,e,t,`comments`],facets:(e,t,n)=>[`facets`,e,t,n],series:(e,t,n,r,i)=>[`series`,e,t,n,r,i],aggregate:(e,t)=>[`aggregate`,e,t],histogram:(e,t,n,r)=>[`histogram`,e,t,n,r],map:(e,t,n,r,i)=>[`map`,e,t,n,r,i],relatedLabel:(e,t)=>[`related-label`,e,t],titleRow:(e,t,n)=>[`title-row`,e,t,n],labels:(e,t)=>[`labels`,e,t],pickedLabels:(e,t)=>[`picked-labels`,e,t],count:(e,t)=>[`count`,e,t],planRead:(e,t)=>[`plan`,e[0],e,t],exportCount:(e,t)=>[`list`,e,t,`export-count`],firstRecord:(e,t,n)=>[`first-record`,e,t,n],pathValue:(e,t,n)=>[`path-value`,e,t,n],inbox:[`inbox`],inboxUnread:[`inbox`,`unread`],inboxPages:[`inbox`,`pages`],members:e=>[`members`,e],statuses:e=>[`statuses`,e],ownStatus:e=>[`statuses`,e,`own`],rings:[`call-rings`],recordCalls:(e,t)=>[`record-calls`,e,t],workflowTypes:[`workflow-types`],workflowRunTrace:e=>[`workflow-run-trace`,e],publicForm:e=>[`public-form`,e]},Ji=(e,t)=>t.has(e[1])||e[0]===`plan`&&e[2].some(e=>t.has(e)),Yi=e=>{let t=e?.session();if(t)return(e?.queries(`user:${t.user.id}`)?.state.queries.find(e=>JSON.stringify(e.queryKey)===JSON.stringify(I.meta)))?.state.data},Xi=e=>Yi(e)?.plugins??[],Zi={name:`@protobase/ui`,version:`0.121.10`,description:`The Protobase admin app and the React hooks and components for custom UI.`,license:`Apache-2.0`,repository:{type:`git`,url:`git+https://github.com/PrototeamHQ/protobase.git`,directory:`packages/ui`},homepage:`https://docs.protobase.net`,type:`module`,protobase:{pluginApi:1},sideEffects:[`*.css`,`./dist/app/main.js`],engines:{node:`>=22.12.0`},exports:{".":`./src/index.ts`,"./theme.css":`./src/theme.css`,"./styles.css":`./src/styles.css`,"./unstable/*":{types:[`./src/*.ts`,`./src/*.tsx`],default:`./src/*`}},types:`./src/index.ts`,files:[`dist`],scripts:{build:`tsdown && protobase build-shell dist/shell --source-maps dist/shell-source-maps`,prepack:`tsdown && protobase build-shell dist/shell --source-maps dist/shell-source-maps`},publishConfig:{access:`public`,exports:{".":`./dist/index.js`,"./theme.css":`./dist/theme.css`,"./styles.css":`./dist/styles.css`,"./unstable/*":`./dist/*.js`},types:`./dist/index.d.ts`},dependencies:{"@dnd-kit/core":`^6.3.1`,"@dnd-kit/sortable":`^10.0.0`,"@protobase/client":`workspace:*`,"@protobase/layout":`workspace:*`,"@protobase/schema":`workspace:*`,"@protobase/workflows":`workspace:*`,"@sentry/browser":`^11.7.0`,"@tanstack/react-query":`^5.104.1`,"@tanstack/react-table":`^9.2.6`,"@xyflow/react":`^12.12.1`,"altcha-lib":`^2.6.0`,dompurify:`^3.4.17`,elkjs:`0.12.1`,fflate:`^0.8.3`,"intl-messageformat":`^12.1.4`,"lucide-react":`^1.52.0`,"maplibre-gl":`^6.14.0`,marked:`^18.1.1`,papaparse:`^5.7.0`,pmtiles:`^4.5.0`,react:`^19.3.0`,"react-dom":`^19.3.0`,"react-map-gl":`^8.1.3`,recharts:`^3.10.1`,tailwindcss:`^4.3.3`,thumbhash:`^0.1.1`,uqr:`^0.1.3`},devDependencies:{"@types/papaparse":`^5.5.2`}},Qi=Zi.protobase.pluginApi,$i=Zi.version,ea=`session`,ta=`queries`,na=e=>`user:${e.user.id}`,ra=async(e,t)=>{let[n,r]=await Promise.all([e.read(ea),e.read(ta)]),i=n?.buster===t?n.value:void 0,a=r?.buster===t&&i&&r.value.owner===na(i)?r.value:void 0,o=[...n&&!i?[ea]:[],...r&&!a?[ta]:[]];return o.length>0&&await e.remove(o),{session:()=>i,queries:e=>a?.owner===e?a:void 0,saveSession:n=>(a&&a.owner!==na(n)&&(a=void 0),i=n,e.write(ea,{buster:t,value:n})),saveQueries:n=>(a=n,e.write(ta,{buster:t,value:n})),clear:()=>(i=void 0,a=void 0,e.remove([ea,ta]))}},ia=(0,M.createContext)(void 0),aa=ia.Provider,oa=()=>(0,M.useContext)(ia),sa=`protobase-start-cache`,ca=`records`,la=(e=indexedDB)=>{let t,n=()=>t??=new Promise((t,n)=>{let r=e.open(sa,1);r.onupgradeneeded=()=>r.result.createObjectStore(ca),r.onerror=()=>n(r.error),r.onsuccess=()=>t(r.result)}),r=async(e,t)=>{let r=await n();return new Promise((n,i)=>{let a=r.transaction(ca,e),o=t(a.objectStore(ca));a.oncomplete=()=>n(o?.result),a.onabort=()=>i(a.error??new DOMException(`The start cache transaction was aborted`,`AbortError`))})};return{read:e=>r(`readonly`,t=>t.get(e)),write:async(e,t)=>void await r(`readwrite`,n=>n.put(t,e)),remove:async e=>void await r(`readwrite`,t=>{for(let n of e)t.delete(n)})}},ua=async()=>{if(typeof indexedDB<`u`)try{return await ra(la(),$i)}catch(e){if(e instanceof DOMException)return;throw e}},da=F(`plugins`),fa=e=>typeof e==`string`&&e.trim()!==``,pa=e=>Array.isArray(e)&&e.every(fa),ma=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(pa),ha=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return{problem:da(`notObject`)};let{name:t,version:n,api:r,protobase:i,imports:a,extensionPoints:o,entry:s,css:c}=e;return fa(t)?Number.isInteger(r)?i!==void 0&&!fa(i)?{problem:da(`badVersions`)}:!ma(a)||!pa(o)?{problem:da(`noUses`)}:fa(s)?c!==void 0&&!fa(c)?{problem:da(`badStylesheet`)}:n!==void 0&&!fa(n)?{problem:da(`badVersion`)}:{manifest:{name:t,api:r,imports:a,extensionPoints:o,entry:s,...i!==void 0&&{protobase:i},...n!==void 0&&{version:n},...c!==void 0&&{css:c}}}:{problem:da(`noModule`)}:{problem:da(`noApi`)}:{problem:da(`noName`)}},ga=/^[A-Z][A-Za-z0-9]*$/,_a=e=>typeof e==`function`||typeof e==`object`&&!!e&&`$$typeof`in e,va=e=>{let t=e.default??{},n=Object.entries(e).filter(e=>e[0]!=="default"&&ga.test(e[0])&&_a(e[1]));if(n.length===0)return t;for(let[e,r]of n)if(t.components&&Object.hasOwn(t.components,e)&&t.components[e]!==r)throw Error(`The component "${e}" is exported by name and given in components as another one; keep the export`);return{...t,components:{...t.components,...Object.fromEntries(n)}}},L=e(a(),1),ya=class extends Error{name=`UiConflictError`},ba=e=>Object.keys(e).some(e=>e==="default"||/^[A-Z]/.test(e))?va(e):e,xa=(e,t)=>[...(e.extends??[]).map(ba).flatMap((e,n)=>xa(e,e.name??`${t} extends[${n}]`)),{ui:e,label:t}],Sa=(e,t,n)=>{let r={},i=new Map;for(let{ui:a,label:o}of t)for(let[t,s]of Object.entries(n(a)??{})){if(Object.hasOwn(r,t)&&r[t]!==s)throw new ya(`${e} "${t}" is defined twice, by ${i.get(t)} and by ${o}; rename one of them`);r[t]=s,i.set(t,i.get(t)??o)}return r},Ca=e=>e.length<=1?e[0]:()=>e.map((e,t)=>(0,L.jsx)(e,{},t)),wa=e=>e.length<=1?e[0]:({children:t,...n})=>e.reduceRight((e,t)=>(0,L.jsx)(t,{...n,children:e}),t),Ta=(...e)=>{let t=e.flatMap((e,t)=>xa(e,e.name??`UI config ${t+1}`)),n=Sa(`The component`,t,e=>e.components),r=Sa(`The action handler`,t,e=>e.actions),i=Sa(`The field type`,t,e=>e.fields),a=Sa(`The file viewer`,t,e=>e.fileViewers),o=Sa(`The drop rule`,t,e=>e.dropRules),s=Sa(`The board drop`,t,e=>e.boardDrops),c=Sa(`The title rule`,t,e=>e.titles),l=Sa(`The marks hook`,t,e=>e.marks),u=Ca(t.flatMap(({ui:e})=>e.shell?.actions?[e.shell.actions]:[])),d=Ca(t.flatMap(({ui:e})=>e.shell?.rightPanel?[e.shell.rightPanel]:[])),f=t.findLast(({ui:e})=>e.shell?.logo)?.ui.shell?.logo,p=t.findLast(({ui:e})=>e.shell?.bell)?.ui.shell?.bell,m=t.findLast(({ui:e})=>e.presence)?.ui.presence,h=wa(t.flatMap(({ui:e})=>e.beforeSignIn?[e.beforeSignIn]:[])),g=e.at(-1)?.name;return{...g&&{name:g},components:n,actions:r,...Object.keys(i).length>0&&{fields:i},...Object.keys(a).length>0&&{fileViewers:a},...Object.keys(o).length>0&&{dropRules:o},...Object.keys(s).length>0&&{boardDrops:s},...Object.keys(c).length>0&&{titles:c},...Object.keys(l).length>0&&{marks:l},...(u||d||f||p)&&{shell:{...u&&{actions:u},...d&&{rightPanel:d},...f&&{logo:f},...p&&{bell:p}}},...m&&{presence:m},...h&&{beforeSignIn:h}}},Ea=(0,M.createContext)(null),Da=Ea.Provider,Oa=()=>{let e=(0,M.useContext)(Ea);if(!e)throw Error(`usePlugin is for the components of a plugin the app loaded`);return e},ka=(e,t,n)=>{let r=n=>(0,L.jsx)(Da,{value:e,children:(0,L.jsx)(t,{...n})});return r.displayName=`${e.name}:${n}`,r},Aa=(e,t,n)=>({of:n.of,display:ka(e,n.display,`fields.${t}.display`),...n.editor&&{editor:ka(e,n.editor,`fields.${t}.editor`)},...n.cell&&{cell:ka(e,n.cell,`fields.${t}.cell`)}}),ja=(e,t)=>{let n=Ta({...va(t),name:e.name}),r=Object.fromEntries(Object.entries(n.components??{}).map(([t,n])=>[t,ka(e,n,t)])),i=n.fields&&Object.fromEntries(Object.entries(n.fields).map(([t,n])=>[t,Aa(e,t,n)])),a=n.fileViewers&&Object.fromEntries(Object.entries(n.fileViewers).map(([t,n])=>[t,{component:ka(e,n.component,`fileViewers.${t}`)}])),o=n.shell&&{...n.shell.actions&&{actions:ka(e,n.shell.actions,`shell.actions`)},...n.shell.rightPanel&&{rightPanel:ka(e,n.shell.rightPanel,`shell.rightPanel`)},...n.shell.logo&&{logo:ka(e,n.shell.logo,`shell.logo`)},...n.shell.bell&&{bell:ka(e,n.shell.bell,`shell.bell`)}},s=n.beforeSignIn&&ka(e,n.beforeSignIn,`beforeSignIn`);return{name:e.name,components:r,...n.actions&&{actions:n.actions},...n.dropRules&&{dropRules:n.dropRules},...n.boardDrops&&{boardDrops:n.boardDrops},...n.titles&&{titles:n.titles},...n.marks&&{marks:n.marks},...i&&{fields:i},...a&&{fileViewers:a},...o&&{shell:o},...s&&{beforeSignIn:s}}},Ma={pluginApi:1,exports:`ActionCard.ActionInputError.ApiProvider.App.AppLink.AppMark.AssistantDock.AuthLayout.AvailabilityMark.Button.CallMark.CallView.Carousel.ChatDivider.ChatMessage.ChatThread.Choices.CodeForm.CompactTable.Composer.Dialog.DiffView.Field.FieldBadge.FieldList.FileReadError.FocusActions.FocusNotice.FocusPage.FocusPanel.FocusSlot.Form.HtmlFrame.InPlaceForm.Input.LogoMark.Markdown.MentionBox.MentionedText.MenuSelect.MenuSurface.OtpInput.PartView.RecordCall.RecordLink.RecordPicker.ResendCodeButton.ResponsiveDialog.RouteLink.SearchPicker.Section.Segmented.Select.SidePanel.SignInPrompt.Spinner.StatusMark.StepList.Textarea.ToneEdge.allowDelayMs.buttonClass.chatDayLabel.closeSidebarEvent.definePlugin.defineUi.diffStats.emptyDraft.extensionPointsOf.fileNamed.isConflict.isFramed.logoTapEvent.mentionedIds.menuItemClass.mergeUi.parseDiff.parsePatch.pluginApi.pluginsChangedEvent.protobaseVersion.sameChatDay.showTextsIn.siblingPage.signedOutEvent.statusRefreshMs.uiFromModule.uiReadyEvent.useApiToken.useAppAddress.useArmedAfterFocus.useAssistant.useAssistantClient.useBackendData.useClient.useComponentReads.useComponentSelect.useCreateForm.useFacets.useFieldControl.useFileText.useFocusPage.useFocusRecord.useFocusZoneFilled.useGuardedPress.useHistogram.useInbox.useLayoutRecord.useList.useListDisplay.useMarkNotificationsRead.useMembers.useMeta.useOwnStatus.usePlugin.usePopoverMenu.usePresence.usePushNotifications.useQuery.useQueryClient.useRecord.useRecordCallAddress.useRecordCalls.useResourceClient.useSeries.useSiblingPage.useSignedInUser.useStatuses.useToast.useUnreadNotifications.useUpdateRecord`.split(`.`)},Na=[`components`,`actions`,`fields`,`fileViewers`,`dropRules`,`boardDrops`,`titles`,`marks`,`shell.actions`,`shell.rightPanel`,`shell.logo`,`shell.bell`,`beforeSignIn`],Pa=(e,t)=>t.split(`.`).reduce((e,t)=>e?.[t],e),Fa=e=>e!=null&&(typeof e!=`object`||Object.keys(e).length!==0),Ia=e=>Na.filter(t=>Fa(Pa(e,t))),La={imports:{react:Object.keys(M),"react/jsx-runtime":Object.keys(L),"react-dom":Object.keys(N),"@protobase/ui":Ma.exports},extensionPoints:Na},Ra={readJson:async e=>{let t=await fetch(e,{cache:`no-cache`,credentials:`same-origin`});return t.ok?{json:await t.json()}:{status:t.status}},addStylesheet:e=>{if([...document.querySelectorAll(`link[rel="stylesheet"]`)].some(t=>t.href===e))return;let t=document.createElement(`link`);t.rel=`stylesheet`,t.href=e,document.head.append(t)},importModule:e=>s(()=>import(e),[])},za={api:Qi,version:$i,...La},Ba=e=>e instanceof Error?e.message:String(e),Va=async(e,t,n,r=za)=>{let i=new URL(e.url,n).href,a=(e,t)=>({kind:`off`,url:i,...t&&{name:t},reason:e}),o;try{let n=await t.readJson(i);if(`status`in n)return a(da(`answered`,{status:n.status}));let s=ha(n.json);if(`problem`in s)return a(s.problem);let{manifest:c}=s;o=c.name;let l=or(c,r);if(l)return a(l,o);c.css&&t.addStylesheet(new URL(c.css,i).href);let u=await t.importModule(new URL(c.entry,i).href),d={name:o,...c.version&&{version:c.version},url:i,settings:e.settings??{}};return{kind:`loaded`,plugin:d,ui:ja(d,u)}}catch(e){return a(da(`couldNotLoad`,{reason:Ba(e)}),o)}},Ha=`protobase:plugins-changed`,Ua=(e,t=()=>window.location.href)=>{let n=new Map,r=new Map,i=new Set,a=0;return{load:i=>{let a=JSON.stringify(i),o=n.get(a);if(o)return o;let s=Va(i,e,t());return n.set(a,s),s.then(e=>r.set(a,e)),s},loaded:e=>r.get(JSON.stringify(e)),forget:()=>{n.clear(),r.clear(),a+=1;for(let e of i)e()},revision:()=>a,subscribe:e=>(i.add(e),()=>void i.delete(e))}},Wa=(e,t,n)=>Promise.race([Promise.all(t.map(t=>e.load(t))),new Promise(e=>setTimeout(e,n))]).then(()=>void 0),Ga=(0,M.createContext)(null),Ka=({loader:e=Ra,source:t,children:n})=>{let r=(0,M.useMemo)(()=>t??Ua(e),[t,e]);return(0,M.useEffect)(()=>{let e=()=>r.forget();return window.addEventListener(Ha,e),()=>window.removeEventListener(Ha,e)},[r]),(0,L.jsx)(Ga.Provider,{value:r,children:n})},qa=()=>{let e=(0,M.useContext)(Ga);if(!e)throw Error(`usePluginSource must be used inside PluginSourceProvider`);return e},Ja=1e4,Ya=[],Xa=(e,t)=>{let n=(0,M.useSyncExternalStore)(t.subscribe,t.revision,t.revision),r=JSON.stringify(e),i=`${r}#${n}`,[a,o]=(0,M.useState)(()=>Za(e,t,i)??{key:`[]`,loads:Ya,settled:!0});return(0,M.useEffect)(()=>{if(e.length===0)return;let n=!0,a=!1,s=e.map(()=>void 0),c=()=>{if(!n)return;let t=s.filter(e=>e!==void 0),c=a||t.length===e.length;o(e=>e.refs===r&&e.settled&&!c?e:{key:i,refs:r,loads:t,settled:c})},l=setTimeout(()=>{a=!0,c()},Ja);return e.forEach((e,n)=>{t.load(e).then(e=>{s[n]=e,c()})}),()=>{n=!1,clearTimeout(l)}},[i,t]),e.length===0?{loads:Ya,settled:!0}:a.key===i||a.refs===r&&a.settled?a:Za(e,t,i)??{loads:Ya,settled:!1}},Za=(e,t,n)=>{if(e.length===0)return;let r=e.map(e=>t.loaded(e));return r.every(e=>e!==void 0)?{key:n,refs:JSON.stringify(e),loads:r,settled:!0}:void 0},Qa=`protobase.liveUpdate.page`,$a=e=>typeof e==`string`&&e.startsWith(`/`)&&!e.startsWith(`//`),eo=(e,t,n)=>{let r=n.state,i=typeof r?.protobaseEntry==`string`?r.protobaseEntry:void 0;e.setItem(Qa,JSON.stringify({url:`${t.pathname}${t.search}${t.hash}`,entry:i}))},to=e=>e.removeItem(Qa),no=e=>e.getItem(Qa)!==null,ro=(e,t)=>{let n=e.getItem(Qa);if(n===null)return;to(e);let r;try{r=JSON.parse(n)}catch(e){if(e instanceof SyntaxError)return;throw e}if(typeof r!=`object`||!r)return;let{url:i,entry:a}=r;$a(i)&&t.replaceState(typeof a==`string`?{protobaseEntry:a}:null,``,i)},io=()=>{let e=le(()=>window.sessionStorage,void 0);return e&&{keep:()=>eo(e,window.location,window.history),forget:()=>to(e)}},R=(...e)=>e.filter(Boolean).join(` `),ao=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function oo(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:ao(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var so=e=>{let t=``,n=!1;for(let r of e){if(r===`-`||r===`_`||r<=` `){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t},co=e=>{let t=so(e);return t.charAt(0).toUpperCase()+t.slice(1)},lo=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),uo={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function fo(e){return e!=null}function po(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??uo.width,a=e.size??e.height??uo.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?lo(...c):lo(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??uo[`stroke-width`])*Number(e.size??e.width??uo.width)/Number(t.size??t.width??uo.width):t.strokeWidth??uo[`stroke-width`];return[`svg`,{...Object.entries(uo).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&fo(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&fo(t.width)&&{[r(`width`)]:t.width},...`height`in t&&fo(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function mo(e,t={}){return po(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var ho=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},go=(0,M.createContext)({}),_o=()=>(0,M.useContext)(go),vo=(0,M.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:g=!1,color:_=`currentColor`,className:v=``}=_o()??{},y=!!c||ho(d),[b,x,S=[]]=mo(u,{color:e??_,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??g,className:lo(v,s),hasA11yProp:y,attributes:d});return(0,M.createElement)(b,{ref:f,...x},[...S.map(([e,t])=>(0,M.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function z(e,t=[],n=[]){let r=typeof e==`string`?oo(e,t,n):e,i=(0,M.forwardRef)(({className:e,...t},n)=>(0,M.createElement)(vo,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=co(r.name)),i}var yo={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};yo.node;var bo=z(yo),xo={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};xo.node;var So=z(xo),Co={name:`arrow-right-left`,size:24,node:[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]};Co.node;var wo=z(Co),To={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};To.node;var Eo=z(To),Do={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};Do.node;var Oo=z(Do),ko={name:`bath`,size:24,node:[[`path`,{d:`M10 4 8 6`,key:`1rru8s`}],[`path`,{d:`M17 19v2`,key:`ts1sot`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`M7 19v2`,key:`12npes`}],[`path`,{d:`M9 5 7.621 3.621A2.121 2.121 0 0 0 4 5v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5`,key:`14ym8i`}]]};ko.node;var Ao=z(ko),jo={name:`bed`,size:24,node:[[`path`,{d:`M2 4v16`,key:`vw9hq8`}],[`path`,{d:`M2 8h18a2 2 0 0 1 2 2v10`,key:`1dgv2r`}],[`path`,{d:`M2 17h20`,key:`18nfp3`}],[`path`,{d:`M6 8v9`,key:`1yriud`}]]};jo.node;var Mo=z(jo),No={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};No.node;var Po=z(No),Fo={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};Fo.node;var Io=z(Fo),Lo={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};Lo.node;var Ro=z(Lo),zo={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};zo.node;var Bo=z(zo),Vo={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};Vo.node;var Ho=z(Vo),Uo={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};Uo.node;var Wo=z(Uo),Go={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};Go.node;var Ko=z(Go),qo={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};qo.node;var Jo=z(qo),Yo={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Yo.node;var Xo=z(Yo),Zo={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};Zo.node;var Qo=z(Zo),$o={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};$o.node;var es=z($o),ts={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};ts.node;var ns=z(ts),rs={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};rs.node;var is=z(rs),as={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};as.node;var os=z(as),ss={name:`circle-minus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-circle`]};ss.node;var cs=z(ss),ls={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};ls.node;var us=z(ls),ds={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};ds.node;var fs=z(ds),ps={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};ps.node;var ms=z(ps),hs={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};hs.node;var gs=z(hs),_s={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};_s.node;var vs=z(_s),ys={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};ys.node;var bs=z(ys),xs={name:`door-open`,size:24,node:[[`path`,{d:`M10 21H2`,key:`1sthdo`}],[`path`,{d:`M10 3H7a2 2 0 00-2 2v16`,key:`15gt7x`}],[`path`,{d:`M14 12h.01`,key:`1jfl7z`}],[`path`,{d:`M19 21V5a2 2 0 00-1.675-1.974l-6.163-1.013A1 1 0 0010 3v18a1 1 0 001.124.992z`,key:`tyvg9a`}],[`path`,{d:`M22 21h-3`,key:`1ec3tr`}]]};xs.node;var Ss=z(xs),Cs={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};Cs.node;var ws=z(Cs),Ts={name:`earth`,size:24,node:[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]],aliases:[`globe-2`]};Ts.node;var Es=z(Ts),Ds={name:`ellipsis-vertical`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]],aliases:[`more-vertical`]};Ds.node;var Os=z(Ds),ks={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};ks.node;var As=z(ks),js={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};js.node;var Ms=z(js),Ns={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Ns.node;var Ps=z(Ns),Fs={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Fs.node;var Is=z(Fs),Ls={name:`face-slightly-smiling-plus`,size:24,node:[[`path`,{d:`M13.267 2.08a10 10 0 108.653 8.653`,key:`1wbpyh`}],[`path`,{d:`M15 10V9`,key:`4dkmfx`}],[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M16.472 15a6 6 0 01-8.943 0`,key:`7qomzy`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M9 10V9`,key:`1lazqi`}]],aliases:[`smile-plus`]};Ls.node;var Rs=z(Ls),zs={name:`file-code-corner`,size:24,node:[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]],aliases:[`file-code-2`]};zs.node;var Bs=z(zs),Vs={name:`file-text`,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:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};Vs.node;var Hs=z(Vs),Us={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};Us.node;var Ws=z(Us),Gs={name:`heart`,size:24,node:[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]};Gs.node;var Ks=z(Gs),qs={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};qs.node;var Js=z(qs),Ys={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 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-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Ys.node;var Xs=z(Ys),Zs={name:`land-plot`,size:24,node:[[`path`,{d:`m12 8 6-3-6-3v10`,key:`mvpnpy`}],[`path`,{d:`m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12`,key:`ek95tt`}],[`path`,{d:`m6.49 12.85 11.02 6.3`,key:`1kt42w`}],[`path`,{d:`M17.51 12.85 6.5 19.15`,key:`v55bdg`}]]};Zs.node;var Qs=z(Zs),$s={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};$s.node;var ec=z($s),tc={name:`leaf`,size:24,node:[[`path`,{d:`M11 20a10 10 0 0010-10 25.9 25.9 0 00-1.04-7.281 1 1 0 00-1.755-.325C15.833 5.5 13 5.5 9.8 6.1A7 7 0 0011 20`,key:`1wjnjv`}],[`path`,{d:`M2 21a5 5 0 012.911-4.544C7.613 15.212 8.351 15.24 11 13`,key:`c1ejpn`}]]};tc.node;var nc=z(tc),rc={name:`life-buoy`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.93 4.93 4.24 4.24`,key:`1ymg45`}],[`path`,{d:`m14.83 9.17 4.24-4.24`,key:`1cb5xl`}],[`path`,{d:`m14.83 14.83 4.24 4.24`,key:`q42g0n`}],[`path`,{d:`m9.17 14.83-4.24 4.24`,key:`bqpfvv`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]};rc.node;var ic=z(rc),ac={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};ac.node;var oc=z(ac),sc={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};sc.node;var cc=z(sc),lc={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};lc.node;var uc=z(lc),dc={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};dc.node;var fc=z(dc),pc={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};pc.node;var mc=z(pc),hc={name:`memory-stick`,size:24,node:[[`path`,{d:`M12 12v-2`,key:`fwoke6`}],[`path`,{d:`M12 18v-2`,key:`qj6yno`}],[`path`,{d:`M16 12v-2`,key:`heuere`}],[`path`,{d:`M16 18v-2`,key:`s1ct0w`}],[`path`,{d:`M2 11h1.5`,key:`15p63e`}],[`path`,{d:`M20 18v-2`,key:`12ehxp`}],[`path`,{d:`M20.5 11H22`,key:`khsy7a`}],[`path`,{d:`M4 18v-2`,key:`1c3oqr`}],[`path`,{d:`M8 12v-2`,key:`1mwtfd`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`rect`,{x:`2`,y:`6`,width:`20`,height:`10`,rx:`2`,key:`1qcswk`}]]};hc.node;var gc=z(hc),_c={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};_c.node;var vc=z(_c),yc={name:`mic-off`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]};yc.node;var bc=z(yc),xc={name:`mic`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]};xc.node;var Sc=z(xc),Cc={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Cc.node;var wc=z(Cc),Tc={name:`monitor-up`,size:24,node:[[`path`,{d:`m9 10 3-3 3 3`,key:`11gsxs`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}]]};Tc.node;var Ec=z(Tc),Dc={name:`monitor-x`,size:24,node:[[`path`,{d:`m14.5 12.5-5-5`,key:`1jahn5`}],[`path`,{d:`m9.5 12.5 5-5`,key:`1k2t7b`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}]]};Dc.node;var Oc=z(Dc),kc={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};kc.node;var Ac=z(kc),jc={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};jc.node;var Mc=z(jc),Nc={name:`network`,size:24,node:[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]};Nc.node;var Pc=z(Nc),Fc={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};Fc.node;var Ic=z(Fc),Lc={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};Lc.node;var Rc=z(Lc),zc={name:`phone-incoming`,size:24,node:[[`path`,{d:`M16 2v6h6`,key:`1mfrl5`}],[`path`,{d:`m22 2-6 6`,key:`6f0sa0`}],[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};zc.node;var Bc=z(zc),Vc={name:`phone-off`,size:24,node:[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473`,key:`10hv5p`}]]};Vc.node;var Hc=z(Vc),Uc={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};Uc.node;var Wc=z(Uc),Gc={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Gc.node;var Kc=z(Gc),qc={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};qc.node;var Jc=z(qc),Yc={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Yc.node;var Xc=z(Yc),Zc={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};Zc.node;var Qc=z(Zc),$c={name:`puzzle`,size:24,node:[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]};$c.node;var el=z($c),tl={name:`receipt`,size:24,node:[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};tl.node;var nl=z(tl),rl={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};rl.node;var il=z(rl),al={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};al.node;var ol=z(al),sl={name:`ruler-dimension-line`,size:24,node:[[`path`,{d:`M10 15v-3`,key:`1pjskw`}],[`path`,{d:`M14 15v-3`,key:`1o1mqj`}],[`path`,{d:`M18 15v-3`,key:`cws6he`}],[`path`,{d:`M2 8V4`,key:`3jv1jz`}],[`path`,{d:`M22 6H2`,key:`1iqbfk`}],[`path`,{d:`M22 8V4`,key:`16f4ou`}],[`path`,{d:`M6 15v-3`,key:`1ij1qe`}],[`rect`,{x:`2`,y:`12`,width:`20`,height:`8`,rx:`2`,key:`1tqiko`}]]};sl.node;var cl=z(sl),ll={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};ll.node;var ul=z(ll),dl={name:`send-horizontal`,size:24,node:[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]],aliases:[`send-horizonal`]};dl.node;var fl=z(dl),pl={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};pl.node;var ml=z(pl),hl={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};hl.node;var gl=z(hl),_l={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};_l.node;var vl=z(_l),yl={name:`shield-check`,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:`m9 12 2 2 4-4`,key:`dzmm74`}]]};yl.node;var bl=z(yl),xl={name:`shopping-cart`,size:24,node:[[`path`,{d:`m2.05 2.05 1.099-.028a1 1 0 0 1 1.008.815l2.69 14.347A1 1 0 0 0 7.83 18H18`,key:`uebgi3`}],[`path`,{d:`M4.563 5h16.435a1 1 0 0 1 .981 1.204l-1.026 6.226A2 2 0 0 1 18.962 14H6.25`,key:`1j7c9p`}],[`circle`,{cx:`18`,cy:`20`,r:`2`,key:`t9985n`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};xl.node;var Sl=z(xl),Cl={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};Cl.node;var wl=z(Cl),Tl={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Tl.node;var El=z(Tl),Dl={name:`sun-moon`,size:24,node:[[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715`,key:`xlf6rm`}],[`path`,{d:`M16 12a4 4 0 0 0-4-4`,key:`6vsxu`}],[`path`,{d:`m19 5-1.256 1.256`,key:`1yg6a6`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}]]};Dl.node;var Ol=z(Dl),kl={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};kl.node;var Al=z(kl),jl={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};jl.node;var Ml=z(jl),Nl={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};Nl.node;var Pl=z(Nl),Fl={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};Fl.node;var Il=z(Fl),Ll={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Ll.node;var Rl=z(Ll),zl={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};zl.node;var Bl=z(zl),Vl={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};Vl.node;var Hl=z(Vl),Ul={name:`user-plus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};Ul.node;var Wl=z(Ul),Gl={name:`user-round-cog`,size:24,node:[[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`m15.228 16.852-.923-.383`,key:`npixar`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`M2 21a8 8 0 0 1 10.434-7.62`,key:`1yezr2`}],[`path`,{d:`m20.772 16.852.924-.383`,key:`htqkph`}],[`path`,{d:`m20.772 19.148.924.383`,key:`9w9pjp`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]],aliases:[`user-cog-2`]};Gl.node;var Kl=z(Gl),ql={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};ql.node;var Jl=z(ql),Yl={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};Yl.node;var Xl=z(Yl),Zl={name:`video-off`,size:24,node:[[`path`,{d:`M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196`,key:`w8jjjt`}],[`path`,{d:`M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2`,key:`1xawa7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Zl.node;var Ql=z(Zl),$l={name:`video`,size:24,node:[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]};$l.node;var eu=z($l),tu={name:`wallet`,size:24,node:[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]};tu.node;var nu=z(tu),ru={name:`warehouse`,size:24,node:[[`path`,{d:`M18 21V10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1v11`,key:`pb2vm6`}],[`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 1.132-1.803l7.95-3.974a2 2 0 0 1 1.837 0l7.948 3.974A2 2 0 0 1 22 8z`,key:`doq5xv`}],[`path`,{d:`M6 13h12`,key:`yf64js`}],[`path`,{d:`M6 17h12`,key:`1jwigz`}]]};ru.node;var iu=z(ru),au={name:`wifi-off`,size:24,node:[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};au.node;var ou=z(au),su={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};su.node;var cu=z(su),lu={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};lu.node;var uu=z(lu),du=F(`primitives`),fu=({className:e,hidden:t=!1})=>(0,L.jsx)(cc,{...t?{"aria-hidden":!0}:{"aria-label":du(`loading`)},className:R(`size-4 animate-spin`,e)}),pu={primary:`bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm`,secondary:`bg-background text-foreground border border-border-strong hover:bg-muted shadow-sm`,ghost:`text-muted-foreground hover:bg-muted hover:text-foreground`,danger:`bg-background text-danger-text border border-border-strong hover:bg-danger-soft shadow-sm`},mu={sm:`h-7 px-2.5 text-body gap-1.5`,md:`h-8 px-3 text-body gap-2`,icon:`size-7 text-body`},hu=({variant:e=`secondary`,size:t=`md`}={})=>R(`inline-flex shrink-0 items-center justify-center rounded-md font-medium transition-colors aria-disabled:cursor-not-allowed aria-disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:opacity-60 disabled:cursor-default`,pu[e],mu[t]),B=({variant:e=`secondary`,size:t=`md`,loading:n,busyLabel:r,className:i,children:a,disabled:o,...s})=>{let c=(0,L.jsxs)(`button`,{type:`button`,disabled:o||n,"aria-busy":n||void 0,className:R(hu({variant:e,size:t}),i),...s,children:[n&&(0,L.jsx)(fu,{hidden:!0,className:`size-3.5`}),n&&r!==void 0?r:a]});return r===void 0?c:(0,L.jsxs)(L.Fragment,{children:[c,(0,L.jsx)(`span`,{role:`status`,className:`sr-only`,children:n&&r})]})},gu=`data-pb-scroll-locked`,_u=()=>{let{body:e,documentElement:t}=document,n=e.style.overflow,r=t.hasAttribute(gu);return window.innerWidth>t.clientWidth&&t.setAttribute(gu,``),e.style.overflow=`hidden`,()=>{e.style.overflow=n,r||t.removeAttribute(gu)}},vu=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,yu=[],bu=(e,t,n)=>{let r=(0,M.useRef)(n);r.current=n,(0,M.useEffect)(()=>{if(!t||!e.current)return;let n=e.current,i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=_u(),o={};yu.push(o);let s=()=>[...n.querySelectorAll(vu)];(s()[0]??n).focus();let c=e=>{if(yu.at(-1)!==o)return;if(e.key===`Escape`)return r.current();if(e.key!==`Tab`)return;let t=s();if(t.length===0)return e.preventDefault();let i=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===i?(e.preventDefault(),a.focus()):!e.shiftKey&&document.activeElement===a?(e.preventDefault(),i.focus()):n.contains(document.activeElement)||(e.preventDefault(),i.focus())};return document.addEventListener(`keydown`,c),()=>{document.removeEventListener(`keydown`,c),yu.splice(yu.indexOf(o),1),a(),i?.focus()}},[t,e])},xu=({title:e,description:t,onClose:n,actions:r,children:i,wide:a=!1,name:o})=>{let s=(0,M.useRef)(null);return bu(s,!0,n),(0,N.createPortal)((0,L.jsx)(`div`,{"data-dialog":o??``,className:`fixed inset-0 z-[90] flex items-center justify-center bg-backdrop/30 p-4 pb-[calc(1rem+var(--pb-safe-bottom))] pl-[calc(1rem+var(--pb-safe-left))] pr-[calc(1rem+var(--pb-safe-right))] pt-[calc(1rem+var(--pb-safe-top))]`,onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,L.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,className:R(`outline-none max-h-[min(90vh,100%)] w-full overflow-y-auto rounded-lg border bg-background p-4 shadow-pop sm:p-5`,a?`max-w-3xl`:`max-w-md`),children:[(0,L.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t&&(0,L.jsx)(`p`,{className:`mt-1.5 text-muted-foreground`,children:t}),i&&(0,L.jsx)(`div`,{className:`mt-4`,children:i}),(0,L.jsx)(`div`,{className:`mt-5 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end [&>*]:min-h-11 sm:[&>*]:min-h-0`,children:r})]})}),document.body)},Su=({className:e,style:t})=>(0,L.jsx)(`span`,{"data-placeholder":!0,className:R(`block h-3 rounded bg-muted`,wu,e),style:t}),Cu=`[animation:pb-reveal_1ms_180ms_backwards]`,wu=`[animation:pb-reveal_1ms_180ms_backwards,pb-shimmer_1.4s_180ms_ease-in-out_infinite] motion-reduce:[animation:pb-reveal_1ms_180ms_backwards]`,V=F(`app-shell`),Tu=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Eu=({parts:e,onNavigate:t,trailing:n})=>{let r=e.at(-1),i=r!==void 0&&(typeof r==`string`||!r.above);return(0,L.jsxs)(`nav`,{"aria-label":V(`breadcrumb`),className:`flex min-w-0 items-center gap-1.5`,children:[e.map((r,i)=>{let a=i===e.length-1,{label:o,href:s,loading:c,above:l}=typeof r==`string`?{label:r,href:void 0,loading:!1,above:!1}:r,u=c?(0,L.jsx)(Su,{className:`w-24`}):o,d=a&&!l,f=R(`truncate`,d?`font-semibold max-md:text-mobile-title max-md:font-bold`:`text-muted-foreground`);return(0,L.jsxs)(`span`,{className:R(`min-w-0 items-center gap-1.5`,d?`flex`:`hidden md:flex`),children:[i>0&&(0,L.jsx)(ns,{className:`hidden size-3.5 shrink-0 text-faint-foreground md:block`}),s?(0,L.jsx)(`a`,{href:s,"aria-current":d?`page`:void 0,"aria-label":c?o:void 0,"aria-busy":c||void 0,onClick:e=>{t&&Tu(e)&&(e.preventDefault(),t(s))},className:R(f,`rounded-sm hover:text-foreground hover:underline`),children:u}):(0,L.jsx)(`span`,{className:f,"aria-label":c?o:void 0,"aria-busy":c||void 0,children:u}),d&&n]},`${i}-${o}`)}),!i&&n]})},Du=({to:e,onClick:t,...n})=>{let{href:r,onFollow:i,newTab:a}=e;return(0,L.jsx)(`a`,{href:r,...a&&{target:`_blank`,rel:`noreferrer`},onClick:e=>{t?.(e),i&&!e.defaultPrevented&&Tu(e)&&(e.preventDefault(),i())},...n})},H=F(`app`),Ou=(0,M.createContext)([]),ku=({name:e,children:t})=>{let n=(0,M.useContext)(Ou),r=(0,M.useMemo)(()=>[...n,e],[n,e]);return(0,L.jsx)(Ou.Provider,{value:r,children:t})},Au=()=>(0,M.useContext)(Ou),ju=(e,t,n)=>{let r=new URL(e,`http://local`),i=new URL(t,`http://local`);return r.pathname!==i.pathname||[...n].some(e=>e.params.some(e=>r.searchParams.get(e)!==i.searchParams.get(e)))},Mu=(e,{replace:t=!1,keepScroll:n=!1}={})=>({kind:`link`,full:e,replace:t,keepScroll:n}),Nu=(e,t)=>t(e.full,e.replace,e.keepScroll),Pu=`protobase:page-places`,Fu=50,Iu=e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&typeof e[1]==`number`&&Number.isFinite(e[1])&&e[1]>=0,Lu=e=>le(()=>{let t=e.getItem(Pu);if(t===null)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(Iu):[]},[]),Ru=e=>{let t=new Map(Lu(e));return{placeOf:e=>t.get(e)??0,save:(e,n)=>{t.delete(e),t.set(e,Math.max(0,Math.round(n)));for(let e of[...t.keys()].slice(0,Math.max(0,t.size-Fu)))t.delete(e)},persist:()=>le(()=>e.setItem(Pu,JSON.stringify([...t])),void 0)}},zu=3e3,Bu=e=>{let t=0,n=()=>(window.scrollTo({top:e,behavior:`instant`}),t=window.scrollY,t>=e-1);if(n())return()=>{};let r=new ResizeObserver(()=>n()&&a()),i=()=>Math.abs(window.scrollY-t)>1&&a(),a=()=>{r.disconnect(),clearTimeout(o),window.removeEventListener(`scroll`,i)},o=setTimeout(a,zu);return r.observe(document.body),window.addEventListener(`scroll`,i,{passive:!0}),a},Vu=(0,M.createContext)(null),Hu=()=>{let e=(0,M.useContext)(Vu);if(!e)throw Error(`useRouter must be used inside Router`);return e},Uu=()=>`${window.location.pathname}${window.location.search}`,Wu=e=>new URL(e,`http://local`).pathname,Gu=()=>window.history.state??{},Ku=()=>Gu().protobaseIndex??0,qu=()=>Math.random().toString(36).slice(2),Ju=()=>{let e=Gu();if(e.protobaseEntry)return e.protobaseEntry;let t=qu();return window.history.replaceState({...e,protobaseEntry:t},``),t},Yu={getItem:()=>null,setItem:()=>{}},Xu=({basePath:e=``,initialUrl:t,children:n})=>{let r=t!==void 0,[i,a]=(0,M.useState)(()=>({url:t??Uu(),entry:r?qu():Ju()})),[o]=(0,M.useState)(()=>Ru(r?Yu:le(()=>window.sessionStorage,void 0)??Yu)),s=(0,M.useRef)(new Map),c=()=>[...s.current.values()].some(e=>e.kind===`input-lost`),l=(0,M.useRef)(i);l.current=i;let u=(0,M.useRef)(new Map);u.current.set(i.entry,i.url);let d=(0,M.useRef)(r?0:Ku()),f=(0,M.useRef)(!1),p=(0,M.useRef)(!1),m=(0,M.useRef)(void 0),h=(0,M.useRef)(!1),[g,_]=(0,M.useState)(),v=(0,M.useCallback)(()=>o.save(l.current.entry,window.scrollY),[o]);(0,M.useLayoutEffect)(()=>Bu(o.placeOf(i.entry)),[o,i.entry]),(0,M.useLayoutEffect)(()=>{if(r)return;window.history.scrollRestoration=`manual`,window.history.replaceState({...Gu(),protobaseIndex:d.current,protobaseEntry:l.current.entry},``);let e=()=>{v(),o.persist()},t=()=>document.visibilityState===`hidden`&&e();window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t);let n=()=>{let e=Ku();if(f.current){f.current=!1,d.current=e,m.current!==void 0&&window.history.go(m.current),m.current=void 0;return}let t=e-d.current;if(!p.current&&s.current.size>0&&ju(l.current.url,Uu(),s.current.values())){f.current=!0,window.history.go(-t),_({kind:`history`,delta:t,inputLost:c()});return}p.current=!1,d.current=e,v(),a({url:Uu(),entry:Ju()})};return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n),window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t)}},[r,v,o]);let y=(0,M.useCallback)((e,t,n=!1)=>{let i=t?l.current.entry:qu();if(!r){d.current+=+!t;let n=Gu(),r=t?{protobasePrevious:n.protobasePrevious,protobasePreviousEntry:n.protobasePreviousEntry}:{protobasePrevious:l.current.url,protobasePreviousEntry:l.current.entry};window.history[t?`replaceState`:`pushState`]({protobaseIndex:d.current,protobaseEntry:i,...r},``,e)}v(),n&&o.save(i,window.scrollY),u.current.set(i,e),a({url:e,entry:i})},[r,v,o]),b=(0,M.useCallback)((t,n)=>{let r=Mu(`${e}${t}`,n);if(s.current.size>0&&ju(l.current.url,r.full,s.current.values()))return _({...r,inputLost:c()});Nu(r,y)},[e,y]),x=(0,M.useCallback)(t=>{if(r)return!1;let n=Gu(),i=(n.protobasePreviousEntry&&u.current.get(n.protobasePreviousEntry))??n.protobasePrevious;return i!==void 0&&Wu(i)===Wu(`${e}${t}`)},[r,e]),S=(0,M.useCallback)(e=>{if(x(e))return window.history.back();b(e)},[x,b]),C=(0,M.useCallback)((e=`draft-kept`,t=[])=>{let n=Symbol(`guard`);return s.current.set(n,{kind:e,params:t}),()=>void s.current.delete(n)},[]),w=(0,M.useCallback)(()=>{if(s.current.size>0)return _({kind:`reload`,inputLost:c()});window.location.reload()},[]),T=(0,M.useCallback)(()=>h.current,[]),E=(0,M.useCallback)(()=>s.current.size>0,[]),D=()=>{if(g){if(_(void 0),g.kind===`link`)return Nu(g,y);if(g.kind===`reload`)return h.current=!0,window.location.reload();p.current=!0,f.current?m.current=g.delta:window.history.go(g.delta)}},O=(0,M.useMemo)(()=>{let t=new URL(i.url,`http://local`);return{path:t.pathname.slice(e.length)||`/`,params:t.searchParams,basePath:e,entry:i.entry,navigate:b,back:S,backIsHistory:x,registerGuard:C,reload:w,reloadConfirmed:T,holdsChanges:E}},[i,e,b,S,x,C,w,T,E]);return(0,L.jsxs)(Vu.Provider,{value:O,children:[n,g?.kind===`reload`&&(0,L.jsx)(xu,{title:H(`reloadTitle`),description:H(g.inputLost?`reloadInputLost`:`reloadDraftKept`),onClose:()=>_(void 0),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:()=>_(void 0),children:H(`keepEditing`)}),(0,L.jsx)(B,{variant:`primary`,onClick:D,children:H(`reload`)})]})}),g&&g.kind!==`reload`&&(0,L.jsx)(xu,{title:H(`leaveTitle`),description:H(g.inputLost?`leaveInputLost`:`leaveDescription`),onClose:()=>_(void 0),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:()=>_(void 0),children:H(`stay`)}),(0,L.jsx)(B,{variant:`primary`,onClick:D,children:H(`leave`)})]})})]})},Zu=({to:e,replace:t,...n})=>{let{navigate:r,basePath:i}=Hu();return(0,L.jsx)(Du,{to:{href:`${i}${e}`,onFollow:()=>r(e,{replace:t})},...n})},Qu=(e,t=`draft-kept`)=>{let{registerGuard:n,reloadConfirmed:r}=Hu(),i=Au();(0,M.useEffect)(()=>e?n(t,i):void 0,[e,t,i,n]),(0,M.useEffect)(()=>{if(!e)return;let t=e=>{r()||e.preventDefault()};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e,r])},$u=[`always`,`editing`,`reading`],ed=e=>e!==void 0&&!$u.includes(e),U={list:`list`,filter:`filter`,orderBy:`order_by`,display:`display`,filterLayout:`layout`,map:`map`,calendar:`calendar`,timeline:`timeline`,savedSearch:`saved_search`,create:`new`,edit:`edit`,open:`open`,tab:`tab`,standard:`standard`,call:`call`,version:`version`,run:`run`,panel:`panel`,file:`file`,thread:`thread`},td=[`list`,`display`,`filter`,`orderBy`,`filterLayout`,`savedSearch`],nd=e=>`${e.latitude.toFixed(5)},${e.longitude.toFixed(5)},${e.zoom.toFixed(2)}`,rd=(e,t,n=-t)=>Number.isFinite(e)&&e>=n&&e<=t,id=e=>{let t=e?.split(`,`);if(t?.length!==3||t.some(e=>e.trim()===``))return;let[n,r,i]=t.map(Number);return rd(n,90)&&rd(r,180)&&rd(i,22,0)?{latitude:n,longitude:r,zoom:i}:void 0},ad=e=>`${e.scale},${e.day}`,od=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;let[n,r,i]=t.slice(1).map(Number),a=new Date(Date.UTC(n,r-1,i));return a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i},sd=(e,t)=>{let n=e?.split(`,`);if(n?.length!==2)return;let[r,i]=n;return t.includes(r)&&od(i)?{scale:r,day:i}:void 0},cd=e=>{let t=new URLSearchParams;for(let n of td){let r=e[n];r===void 0||r===``&&n!==`filter`||t.set(U[n],r)}e.map&&t.set(U.map,nd(e.map)),e.calendar&&t.set(U.calendar,ad(e.calendar)),e.timeline&&t.set(U.timeline,ad(e.timeline));let n=t.toString();return n?`?${n}`:``},ld=e=>{let t=new URLSearchParams;e.edit&&t.set(U.edit,`true`);for(let n of e.open??[])t.append(U.open,n);e.tab&&t.set(U.tab,e.tab),e.standard&&t.set(U.standard,`true`),e.call&&t.set(U.call,e.call),e.version!==void 0&&t.set(U.version,String(e.version)),e.run&&t.set(U.run,e.run),e.panel&&t.set(U.panel,e.panel),e.file&&t.set(U.file,e.file),e.thread&&t.set(U.thread,e.thread);let n=t.toString();return n?`?${n}`:``},ud=(e,t=``)=>{switch(e.kind){case`page`:return`${t}/${encodeURIComponent(e.page)}${e.tab?`/${encodeURIComponent(e.tab)}`:``}${fd(e.params)}`;case`create`:return`${t}/${encodeURIComponent(e.resource)}/${U.create}${fd(e.values)}`;case`record`:return`${t}/${encodeURIComponent(e.resource)}/${encodeURIComponent(tr(e.key))}${ld(e)}`;case`list`:return`${t}/${encodeURIComponent(e.resource)}${cd(e)}`}},dd=e=>{try{return e.split(`/`).filter(Boolean).map(decodeURIComponent)}catch(e){if(e instanceof URIError)return;throw e}},fd=(e={})=>{let t=new URLSearchParams(Object.entries(e).filter(([,e])=>e!==``)).toString();return t?`?${t}`:``},pd=e=>e!==null&&/^[1-9]\d{0,8}$/.test(e)?Number(e):void 0,md=e=>e===`bar`||e===`panel`?e:void 0,hd=(e,t)=>{let n=new URL(e,`http://app`),r=dd(n.pathname);if(!r||r.length===0||r.length>2)return;let[i,a]=r;if(i===`-`)return;if(t.has(i)){let e=Object.fromEntries([...n.searchParams].filter(([,e])=>e!==``));return{kind:`page`,page:i,...a!==void 0&&{tab:a},...Object.keys(e).length>0&&{params:e}}}if(a===U.create){let e=Object.fromEntries([...n.searchParams].filter(([,e])=>e!==``));return{kind:`create`,resource:i,...Object.keys(e).length>0&&{values:e}}}if(a!==void 0){let e=[...new Set(n.searchParams.getAll(U.open).filter(e=>e!==``))],t=n.searchParams.get(U.tab)||void 0,r=n.searchParams.get(U.standard)===`true`,o=n.searchParams.get(U.call)===`join`,s=pd(n.searchParams.get(U.version)),c=n.searchParams.get(U.run)||void 0,l=n.searchParams.get(U.panel)||void 0,u=n.searchParams.get(U.file)||void 0,d=n.searchParams.get(U.thread)||void 0;return{kind:`record`,resource:i,key:a,...n.searchParams.get(U.edit)===`true`&&{edit:!0},...e.length>0&&{open:e},...t&&{tab:t},...r&&{standard:r},...o&&{call:`join`},...s!==void 0&&{version:s},...c&&{run:c},...l&&{panel:l},...u&&{file:u},...d&&{thread:d}}}let o=n.searchParams,s=o.get(U.list)||void 0,c=o.get(U.display)||void 0,l=o.get(U.filter)??void 0,u=o.get(U.orderBy)||void 0,d=md(o.get(U.filterLayout)),f=id(o.get(U.map)),p=sd(o.get(U.calendar),[`month`,`week`]),m=sd(o.get(U.timeline),[`week`,`month`,`quarter`]),h=o.get(U.savedSearch)||void 0;return{kind:`list`,resource:i,...s&&{list:s},...c&&{display:c},...l!==void 0&&{filter:l},...u&&{orderBy:u},...d&&{filterLayout:d},...f&&{map:f},...p&&{calendar:p},...m&&{timeline:m},...h&&{savedSearch:h}}},gd={signature:`sig`},_d=e=>{let t=e.startsWith(`?`)?e.slice(1):e;return new URLSearchParams(t).has(gd.signature)?{oauthQuery:t}:{}},vd=`/-/sign-in`,yd={step:`step`,next:`next`},bd=[`sign-in`,`forgot-password`,`email-code`,`sign-up`,`sign-up-code`,`sign-up-details`],xd=e=>bd.includes(e),Sd=e=>{if(!e?.startsWith(`/`))return;let t=new URL(e,`http://local`);if(t.origin===`http://local`&&t.pathname!==`/-/sign-in`)return`${t.pathname}${t.search}`},Cd=({step:e=`sign-in`,next:t}={})=>{let n=new URLSearchParams;e!==`sign-in`&&n.set(yd.step,e);let r=Sd(t);r&&r!==`/`&&n.set(yd.next,r);let i=n.toString();return i?`${vd}?${i}`:vd},wd=(e,t)=>{if(e!==`/-/sign-in`)return;let n=t.get(yd.step),r=Sd(t.get(yd.next));return{step:xd(n)?n:`sign-in`,...r&&{next:r}}},Td=e=>typeof e==`string`?e:e&&yt(e),Ed=e=>{let t=Object.entries(e??{}).map(([e,t])=>`${e}.${t}`);return t.length>0?t:void 0},Dd=e=>({photos:e&&`${e.resource}.${e.field}.${e.image}`,photos_order_by:e?.sort}),Od=(e={})=>({filter:Td(e.filter)||void 0,order_by:e.orderBy,page_size:e.pageSize,page_token:e.pageToken||void 0,fields:e.fields?.join(`,`),labels:Ed(e.labels)?.join(`,`),...Dd(e.photos),count:e.count,limit_per:e.limitPer&&`${e.limitPer.field}:${e.limitPer.count}`,etag:e.etag===!1?`false`:void 0}),kd=e=>{let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!==void 0&&t.set(n,String(r));let n=t.toString();return n?`?${n}`:``},Ad=e=>e.startsWith(`/`)&&!e.startsWith(`//`),jd=e=>{if(typeof e!=`object`||!e)return!1;let{uri:t,url:n}=e;return typeof t==`string`&&typeof n==`string`&&Ad(n)},Md=e=>e!==void 0&&URL.canParse(e)?new URL(e).origin:void 0,Nd=(e,t)=>({...e,url:`${t}${e.url}`,...e.variants&&{variants:Object.fromEntries(Object.entries(e.variants).map(([e,n])=>[e,Ad(n.url)?{...n,url:`${t}${n.url}`}:n]))}}),Pd=(e,t)=>t===void 0||typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,jd(n)?Nd(n,t):n])),Fd=(e,t)=>t===void 0?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n.map(e=>jd(e)?Nd(e,t):e)])),Id=class extends Error{problem;constructor(e){super(e.detail??e.title),this.problem=e,this.name=`ApiError`}get status(){return this.problem.status}get slug(){return this.problem.type.split(`:`).at(-1)??``}get operation(){return this.problem.operation??this.errors.find(e=>e.operation!==void 0)?.operation}get blockedBy(){return this.problem.blockedBy}get existing(){return this.problem.existing}get errors(){return this.problem.errors??[]}get filterErrors(){return this.slug===`invalid-filter`?this.errors:[]}},Ld=class extends Id{constructor(e){super(e),this.name=`PreconditionFailedError`}},Rd=e=>e instanceof Id,zd=e=>typeof e==`object`&&!!e&&`type`in e&&`status`in e,Bd=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.json():void 0,n=zd(t)?t:{type:`urn:protobase:problem:unknown`,title:e.statusText||`Request failed`,status:e.status};return n.status===412?new Ld(n):new Id(n)},Vd=(e=`/api/v1`)=>e.replace(/\/[^/]*$/,``),Hd=(e={})=>{let t=e.baseUrl??`/api/v1`,n=Vd(t),r=e.fetch??((e,t)=>fetch(e,t));return async({method:i,path:a,query:o=``,body:s,headers:c,accept:l=[],system:u,raw:d,via:f,signal:p,cache:m})=>{let h=async l=>{let h=await e.token?.({refresh:l});return(f??r)(`${u?n:t}${a}${o}`,{method:i,headers:{...s!==void 0&&{"content-type":`application/json`},...h&&{authorization:`Bearer ${h}`},...e.headers?.(),...c},body:d??(s===void 0?void 0:JSON.stringify(s)),...p&&{signal:p},...m&&{cache:m}})},g=await h(!1);g.status===401&&e.token&&(g=await h(!0),g.status===401&&e.onUnauthenticated?.());let _=g.headers.get(`x-meta-version`);if(_&&e.onMetaVersion?.(_),!g.ok&&!l.includes(g.status))throw await Bd(g);return g}},Ud=(e,t)=>{if(!URL.canParse(t))return{link:e,api:t};let n=new URL(t);return{link:new URL(e,n).href,api:`${n.origin}${n.pathname.replace(/\/$/,``)}`}},Wd=(e,t)=>{if(!e.url.startsWith(`/`)&&!/^https?:\/\//i.test(e.url))return e.url;let n=di(e.uri);if(!n)return e.url;let{link:r,api:i}=Ud(e.url,t),a=li(i);return r.startsWith(`${a}/`)?fi(r):fi(ui(a,n.provider,n.path))},Gd=e=>new Headers(e.trim().split(/[\r\n]+/).filter(Boolean).map(e=>{let t=e.indexOf(`:`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]})),Kd=e=>(t,n={})=>new Promise((r,i)=>{let a=new XMLHttpRequest;a.open(n.method??`GET`,String(t)),new Headers(n.headers).forEach((e,t)=>a.setRequestHeader(t,e)),a.responseType=`blob`,a.upload.onprogress=t=>e(t.loaded,t.lengthComputable?t.total:t.loaded),a.onload=()=>{let e=a.status===204||a.status===304;r(new Response(e?null:a.response,{status:a.status,statusText:a.statusText,headers:Gd(a.getAllResponseHeaders())}))},a.onerror=()=>i(TypeError(`Network request failed`)),a.onabort=()=>i(new DOMException(`The upload was aborted`,`AbortError`)),n.signal?.addEventListener(`abort`,()=>a.abort()),a.send(n.body)}),qd=e=>Math.min(3e4,1e3*2**e),Jd=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),Yd=(e,t,n=qd)=>{let r=new AbortController,{signal:i}=r,a,o=0,s=e=>{o=0,a=e.cursor,e.type===`resync`&&t.onResync(),e.type===`changes`&&t.onChanges(e.changes)},c=async()=>{let t=await e({method:`GET`,path:`/live`,query:kd({after:a}),headers:{accept:`text/event-stream`},system:!0,signal:i});if(!t.body)throw Error(`The server answered the live stream without a body`);await Lr(t.body,e=>s(JSON.parse(e)),i)};return(async()=>{for(;!i.aborted;){let e=await c().then(()=>void 0,e=>e);if(i.aborted)return;t.onRetry?.(e),await Jd(n(o++),i)}})(),()=>r.abort()},Xd=e=>{let t=new Set,n,r=e=>{for(let n of[...t])e(n)};return i=>{let a={...i};return t.add(a),n??=e({onChanges:e=>r(t=>t.onChanges(e)),onResync:()=>r(e=>e.onResync()),onRetry:e=>r(t=>t.onRetry?.(e))}),()=>{!t.delete(a)||t.size>0||(n?.(),n=void 0)}}},Zd=new TextEncoder,Qd=new TextDecoder,$d=4,ef=(e,t)=>{let n=Zd.encode(JSON.stringify(e)),r=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i=new Uint8Array($d+n.length+r.length);return new DataView(i.buffer).setUint32(0,n.length),i.set(n,$d),i.set(r,$d+n.length),i.buffer},tf=e=>{let t=$d+new DataView(e).getUint32(0);return{...JSON.parse(Qd.decode(new Uint8Array(e,$d,t-$d))),payload:e.slice(t)}},nf=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),rf=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`ChannelRefusal`}},af=5e3,of=1,sf=`protobase.channels`,cf=({url:e,token:t,socket:n,retryDelay:r,onOpen:i,onDown:a,onMessage:o})=>{let s,c=!1,l=0,u=0,d,f=0,p,m,h=new Map,g=()=>{for(let{reject:e}of h.values())e(new rf(`disconnected`,`The connection dropped before the server answered`));h.clear()},_=async e=>{let n=await t?.();s===e&&e.readyState===of&&n!==void 0&&n!==d&&(d=n,e.send(JSON.stringify({type:`token`,token:n})))},v=async()=>{let u=await t?.();if(!c||s)return;d=u;let y=n(e(),u===void 0?[sf]:[sf,`bearer.${u}`]);s=y,y.binaryType=`arraybuffer`,y.onopen=()=>{l=0,f=Date.now(),p=setInterval(()=>{if(Date.now()-f>1e4)return y.close();y.send(JSON.stringify({type:`ping`})),_(y)},af),i()},y.onmessage=({data:e})=>{if(f=Date.now(),typeof e!=`string`&&!(e instanceof ArrayBuffer))return;let t=typeof e==`string`?JSON.parse(e):tf(e);if(t.type!==`reply`)return o(t);let n=h.get(t.ref);h.delete(t.ref),t.ok?n?.resolve(t):n?.reject(new rf(t.error.code,t.error.message))},y.onclose=()=>{s===y&&(clearInterval(p),s=void 0,g(),c&&(a(),m=setTimeout(()=>{m=void 0,v()},r(l++))))}},y=(e,t)=>s?.readyState===of&&(s.send(t===void 0?JSON.stringify(e):ef(e,t)),!0);return{start:()=>{c=!0,!s&&m===void 0&&v()},stop:()=>{c=!1,clearTimeout(m),m=void 0,clearInterval(p);let e=s;s=void 0,g(),e?.close(1e3)},request:(e,t)=>new Promise((n,r)=>{let i=String(++u);if(!y({...e,ref:i},t))return r(new rf(`disconnected`,`The connection is down`));h.set(i,{resolve:n,reject:r})}),post:y}},lf=e=>{if(!(e instanceof rf&&e.code===`disconnected`))throw e},uf=()=>new rf(`not-joined`,`The channel is not joined yet`),df=e=>{let t=new Map,n=new Map,r=(e,t)=>{e.status=t;for(let n of e.statusListeners)n(t)},i=(e,t)=>{let n=[...e.presence.values()];for(let r of e.presenceListeners)r(n,t)},a=e=>{t.delete(e),t.size===0&&c.stop()},o=e=>{let i=`${e.resource}/${e.key}`;c.request({type:`join`,resource:e.resource,key:e.key}).then(o=>{if(t.get(i)===e){if(e.holders===0)return c.post({type:`leave`,channel:o.channel}),a(i);e.name=o.channel,n.set(e.name,e),r(e,{state:`joined`}),e.tracked&&c.request({type:`track`,channel:e.name,state:e.tracked.state}).catch(lf)}}).catch(n=>{if(t.get(i)===e&&e.holders===0&&n instanceof rf)return a(i);if(!(n instanceof rf)||n.code===`disconnected`)return lf(n);r(e,{state:`refused`,error:{code:n.code,message:n.message}})})},s=e=>{if(e.type===`pong`||e.type===`reply`||e.type===`error`)return;let t=n.get(e.channel);if(t){if(e.type===`presence`)return t.presence=new Map(e.entries.map(e=>[e.id,e])),i(t);if(e.type===`presence_diff`){for(let n of e.leaves)t.presence.delete(n.id);for(let n of[...e.joins,...e.updates])t.presence.set(n.id,n);return i(t,{joins:e.joins,updates:e.updates,leaves:e.leaves})}if(e.type===`broadcast`){let{event:n,payload:r,user:i,server:a}=e;for(let e of t.eventListeners.get(n)??[])e({event:n,payload:r,user:i,...a&&{server:a}});return}n.delete(e.channel),t.presence.clear(),i(t),r(t,{state:`closed`,error:e.error})}},c=cf({...e,onOpen:()=>{for(let[e,n]of t)n.status.state===`joining`&&(n.holders===0?a(e):o(n))},onDown:()=>{n.clear();for(let e of t.values())e.status.state===`joined`&&r(e,{state:`joining`})},onMessage:s}),l=(e,t)=>{--t.holders,!(t.holders>0)&&(t.tracked=void 0,t.status.state!==`joining`&&(t.name!==void 0&&(n.delete(t.name),c.post({type:`leave`,channel:t.name})),a(e)))},u=(e,t)=>{let n=!1,r=new Set,i=(e,t)=>{e.add(t);let n=()=>{e.delete(t),r.delete(n)};return r.add(n),n},a=()=>t.status.state===`joined`?t.name:void 0;return{status:()=>t.status,onStatus:e=>i(t.statusListeners,e),presence:()=>[...t.presence.values()],onPresence:e=>i(t.presenceListeners,e),track:async e=>{t.tracked={state:e};let n=a();n!==void 0&&await c.request({type:`track`,channel:n,state:e})},untrack:async()=>{t.tracked=void 0;let e=a();e!==void 0&&await c.request({type:`untrack`,channel:e})},send:async(e,t,{self:n,ack:r}={})=>{let i=a();if(i===void 0)throw uf();let o=nf(t)?t:void 0,s={type:`send`,channel:i,event:e,...o===void 0&&{payload:t},...n&&{self:n}};if(r){await c.request({...s,ack:r},o);return}if(!c.post(s,o))throw new rf(`disconnected`,`The connection is down`)},on:(e,n)=>{let r=t.eventListeners.get(e)??new Set;return t.eventListeners.set(e,r),i(r,n)},leave:()=>{if(!n){n=!0;for(let e of[...r])e();l(e,t)}}}};return{channel:(e,n)=>{let r=tr(n),i=`${e}/${r}`,a=t.get(i);if(a)return a.holders+=1,u(i,a);let s={resource:e,key:r,status:{state:`joining`},presence:new Map,holders:1,statusListeners:new Set,presenceListeners:new Set,eventListeners:new Map};return t.set(i,s),c.start(),o(s),u(i,s)}}},ff=({send:e,socketUrl:t,socket:n})=>({open:async(r,i)=>{let a=`/functions/${encodeURIComponent(r)}`,{token:o,expires_at:s}=await(await e({method:`POST`,path:a,system:!0,body:{target:i}})).json(),c=n(t(oi(a,o)),[]);return c.binaryType=`arraybuffer`,{socket:c,expiresAt:new Date(s)}}}),pf=e=>({register:async t=>(await e({method:`POST`,path:si(``),system:!0,body:t})).json(),remove:async t=>{await e({method:`DELETE`,path:si(``,t),system:!0})}}),mf=e=>({own:async()=>(await(await e({method:`GET`,path:_i(``),system:!0})).json()).status,set:async t=>(await(await e({method:`PUT`,path:_i(``),system:!0,body:t})).json()).status,clear:async()=>{await e({method:`DELETE`,path:_i(``),system:!0})},people:async()=>(await(await e({method:`GET`,path:_i(``,`people`),system:!0})).json()).statuses}),hf=e=>async(t,n)=>(await e({method:`GET`,path:er(``,t,n),system:!0})).json(),gf=e=>async()=>(await e({method:`GET`,path:Yn(``),system:!0})).json(),_f=e=>async t=>(await e({method:`POST`,path:Xn(``,t),system:!0})).json(),vf=e=>({list:async({cursor:t,limit:n}={})=>{let r=new URLSearchParams({...t!==void 0&&{cursor:t},...n!==void 0&&{limit:String(n)}}),i=r.size>0?`?${r}`:``;return(await e({method:`GET`,path:gi(``),query:i,system:!0})).json()},unread:async()=>(await(await e({method:`GET`,path:gi(``,`unread`),system:!0})).json()).count,markRead:async t=>{await e({method:`POST`,path:gi(``,{read:t}),body:{},system:!0})},markAllRead:async t=>{await e({method:`POST`,path:gi(``,`read`),body:{upTo:t},system:!0})}}),yf=e=>Math.min(3e4,1e3*2**e),bf=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),xf=(e,t,n=yf)=>({calls:async(n,r)=>(await(await e({method:`GET`,path:t(n,r)})).json()).items,watchCalls:(r,i,a)=>{let o=new AbortController,{signal:s}=o,c=0,l=async()=>{let n=await e({method:`GET`,path:t(r,i),query:`?watch=true`,headers:{accept:`text/event-stream`},signal:s});if(!n.body)throw Error(`The server answered the calls stream without a body`);await Lr(n.body,e=>{c=0,a.onCalls(JSON.parse(e).items)},s)};return(async()=>{for(;!s.aborted;){let e=await l().then(()=>void 0,e=>e);if(s.aborted)return;a.onRetry?.(e),await bf(n(c++),s)}})(),()=>o.abort()}}),Sf=e=>({list:async()=>(await(await e({method:`GET`,path:Ei(``),system:!0})).json()).items,decline:async t=>{await e({method:`POST`,path:Ei(``,{decline:t}),system:!0,body:{}})}}),Cf=e=>({allowed:async()=>(await(await e({method:`GET`,path:Ci(``,`organization`),system:!0})).json()).allowed,setAllowed:async t=>{await e({method:`PUT`,path:Ci(``,`organization`),system:!0,body:{allowed:t}})}}),wf=4e3,Tf=e=>typeof e==`string`?e:e.toModel().name,Ef=(e=`/api/v1`,t)=>{let n=new URL(`${e.replace(/\/[^/]*$/,``)}${t}`,globalThis.location?.href);return n.protocol=n.protocol===`https:`?`wss:`:`ws:`,n.toString()},Df=(e,t)=>`/${Tf(e)}/${tr(t)}`,Of=(e,t)=>`${Df(e,t)}:calls`,kf=(e,t,n)=>({items:e.items.map(e=>Pd(e,n)),nextPageToken:e.next_page_token,totalSizeEstimate:e.total_size_estimate,...e.prev_page_token!==void 0&&{prevPageToken:e.prev_page_token},...e.total_size!==void 0&&{totalSize:e.total_size},...e.labels!==void 0&&{labels:e.labels},...e.photos!==void 0&&{photos:Fd(e.photos,n)},...t.headers.get(`x-protobase-warning`)&&{warning:t.headers.get(`x-protobase-warning`)}}),Af=({created_at:e,...t})=>({...t,createdAt:e}),jf=e=>e.headers.get(`etag`)??``,Mf=async(e,t)=>{let{permissions:n,...r}=await e.json();return{record:Pd(r,t),etag:jf(e),...n&&{permissions:n}}},Nf=(e,t)=>({results:(e.results??[]).map(e=>e.op===`create`||e.op===`update`?{...e,record:Pd(e.record,t)}:e.op===`reorder`||e.op===`move`?{...e,records:e.records.map(e=>({...e,record:Pd(e.record,t)}))}:e)}),Pf=(e={})=>{let t=Hd(e),n=Md(e.baseUrl),r=async(e,r)=>{let i=Od(r),a=await t({method:`POST`,path:`/${Tf(e)}:search`,body:{...i,fields:r?.fields,labels:Ed(r?.labels)}});return kf(await a.json(),a,n)},i=async(e,i)=>{let a=kd(Od(i));if(a.length>wf)return r(e,i);let o=await t({method:`GET`,path:`/${Tf(e)}`,query:a});return kf(await o.json(),o,n)},a=async(e,r)=>Mf(await t({method:`GET`,path:Df(e,r)}),n),o=async(e,r)=>{let i=await t({method:`POST`,path:`/${Tf(e)}`,body:r});return{record:Pd(await i.json(),n),etag:jf(i),location:i.headers.get(`location`)??``}},s=async(e,r,i,a)=>Mf(await t({method:`PATCH`,path:Df(e,r),body:i,headers:{"if-match":a}}),n),c=async(e,n,{etag:r}={})=>{await t({method:`DELETE`,path:Df(e,n),headers:r?{"if-match":r}:void 0})},l=async(e,r)=>{let i=await t({method:`POST`,path:`${Df(e,r)}:undelete`});return{record:Pd(await i.json(),n),etag:jf(i)}},u=async(e,n,r)=>(await(await t({method:`POST`,path:`${Df(e,n)}:reveal`,body:{field:r}})).json()).value,d=async(e,r,i)=>Mf(await t({method:`POST`,path:`${Df(e,r)}:generate`,body:{action:i}}),n),f=async(e,n,{pageSize:r,pageToken:i}={})=>{let a=kd({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${Df(e,n)}:history`,query:a})).json();return{items:o.items.map(({database_role:e,...t})=>({...t,databaseRole:e})),nextPageToken:o.next_page_token}},p=async(e,n,{pageSize:r,pageToken:i}={})=>{let a=kd({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${Df(e,n)}:comments`,query:a})).json();return{items:o.items.map(Af),nextPageToken:o.next_page_token}},m=async(e,n,{body:r,mentions:i=[]})=>Af(await(await t({method:`POST`,path:`${Df(e,n)}:comments`,body:{body:r,mentions:i}})).json()),h=async(e,n,r)=>(await(await t({method:`GET`,path:`${Df(e,n)}:mentionable`,query:kd({q:r})})).json()).items,g=async e=>{let r=e=>typeof e==`object`&&e&&`$ref`in e?e:tr(e),i=e.map(e=>({...e,resource:Tf(e.resource),...`key`in e&&{key:r(e.key)},...e.op===`reorder`&&{keys:e.keys.map(r)},...e.op===`move`&&{after:e.after&&r(e.after),...e.before!==void 0&&{before:e.before&&r(e.before)}}}));return Nf(await(await t({method:`POST`,path:`:batchWrite`,body:{ops:i}})).json(),n)},_=async(e,n,r={})=>(await(await t({method:`GET`,path:`/${Tf(e)}:facets`,query:kd({field:n,filter:Td(r.filter)||void 0,limit:r.limit,label:r.label})})).json()).facets,v=async(e,n)=>{let r=await(await t({method:`GET`,path:`/${Tf(e)}:aggregate`,query:kd({group_by:n.groupBy,filter:Td(n.filter)||void 0,sum:n.sum,average:n.average,maximum:n.maximum,limit:n.limit,label:n.label,granularity:n.granularity,range:n.range,from:n.from,to:n.to,time_zone:n.timeZone,split_by:n.splitBy,split_limit:n.splitLimit,split_label:n.splitLabel})})).json();return{groupBy:r.group_by,granularity:r.granularity,timeZone:r.time_zone,groups:r.groups,...r.split_by!==void 0&&{splitBy:r.split_by,splits:r.splits}}},y=async(e,n)=>{let r=await(await t({method:`GET`,path:`/${Tf(e)}:series`,query:kd({field:n.field,range:n.range,from:n.from,to:n.to,granularity:n.granularity,time_zone:n.timeZone,filter:Td(n.filter)||void 0})})).json();return{field:r.field,granularity:r.granularity,timeZone:r.time_zone,points:r.points}},b=async(e,n,r={})=>(await t({method:`GET`,path:`/${Tf(e)}:histogram`,query:kd({field:n,buckets:r.buckets,filter:Td(r.filter)||void 0})})).json(),x=async(e,n)=>{let r=await(await t({method:`POST`,path:`/${Tf(e)}:batchAggregates`,body:{facets:(n.facets??[]).map(e=>({...e,filter:Td(e.filter)||void 0})),histograms:(n.histograms??[]).map(e=>({...e,filter:Td(e.filter)||void 0})),series:(n.series??[]).map(({timeZone:e,filter:t,...n})=>({...n,time_zone:e,filter:Td(t)||void 0}))}})).json();return{facets:r.facets.map(e=>e.facets),histograms:r.histograms,series:r.series.map(e=>({field:e.field,granularity:e.granularity,timeZone:e.time_zone,points:e.points}))}},S=async(e,r)=>{let i=await(await t({method:`GET`,path:`/${Tf(e)}:map`,query:kd({latitude:r.latitude,longitude:r.longitude,zoom:r.zoom,filter:Td(r.filter)||void 0,order_by:r.orderBy,fields:r.fields?.join(`,`),labels:Ed(r.labels)?.join(`,`),...Dd(r.photos)})})).json();return{items:i.items.map(e=>Pd(e,n)),buckets:i.buckets,totalSize:i.total_size,...i.labels!==void 0&&{labels:i.labels},...i.photos!==void 0&&{photos:Fd(i.photos,n)}}},C=async(e,r)=>{let i=await t({method:`GET`,path:`/${Tf(e)}:seek`,query:kd({...Od(r),position:r.position})});return kf(await i.json(),i,n)},w=async(e,{signal:n}={})=>{let r=await t({method:`GET`,path:`/meta`,system:!0,headers:e?{"if-none-match":e}:void 0,accept:[304],...n&&{signal:n}});return r.status===304?{status:`unchanged`}:{status:`modified`,meta:await r.json(),etag:jf(r)}},T=async(e,{method:n,body:r,path:i=``,query:a,headers:o,cache:s}={})=>{let c=await t({method:n??(r===void 0?`GET`:`POST`),path:`/functions/${encodeURIComponent(e)}${i}`,query:a?`?${new URLSearchParams(a)}`:``,body:r,headers:o,system:!0,...s&&{cache:s}});if(c.status===204)return;let l=c.headers.get(`content-type`);return l?.includes(`json`)?c.json():!l||l.startsWith(`text/`)?c.text():c.blob()},E=async(e,n,r,{onProgress:i,signal:a}={})=>{let o=`name`in r&&typeof r.name==`string`?r.name:void 0,s=i&&typeof XMLHttpRequest<`u`?Kd(i):void 0,c=await(await t({method:`POST`,path:`/${Tf(e)}:upload`,query:`?${new URLSearchParams({field:n,...o!==void 0&&{name:o}})}`,raw:r,headers:{"content-type":r.type||`application/octet-stream`},...s&&{via:s},...a&&{signal:a}})).json();return i?.(r.size,r.size),c},D=e=>`/forms/${encodeURIComponent(e)}`,O=async e=>(await t({method:`GET`,path:D(e),system:!0})).json(),k=async e=>(await t({method:`GET`,path:`${D(e)}:challenge`,system:!0})).json(),A=async(e,n,r)=>{await t({method:`POST`,path:D(e),body:{values:n,proof:r},system:!0})},ee=Xd(e=>Yd(t,e)),te=e.webSocket??((e,t)=>new WebSocket(e,t)),{channel:ne}=df({url:()=>Ef(e.baseUrl,`/channels`),...e.token&&{token:()=>e.token({refresh:!1})},socket:te,retryDelay:e=>Math.min(3e4,1e3*2**e)}),re=ff({send:t,socketUrl:t=>Ef(e.baseUrl,t),socket:te}),ie=pf(t),j=vf(t),{calls:ae,watchCalls:M}=xf(t,Of),N=mf(t),oe=gf(t),se=hf(t),ce=_f(t);return{list:i,search:r,get:a,create:o,update:s,remove:c,undelete:l,generate:d,reveal:u,history:f,comments:p,comment:m,mentionable:h,batchWrite:g,facets:_,aggregate:v,series:y,histogram:b,batchAggregates:x,map:S,seek:C,meta:w,invoke:T,upload:E,form:O,formChallenge:k,submitForm:A,live:ee,channel:ne,bridges:re,devices:ie,notifications:j,status:N,calls:ae,watchCalls:M,rings:Sf(t),callGuests:Cf(t),workflowTypes:oe,workflowRunTrace:se,runnerRegistration:ce,functionSocketUrl:(t,n)=>Ef(e.baseUrl,`/functions/${encodeURIComponent(t)}${n?`?${new URLSearchParams(n)}`:``}`),fileReadUrl:(t,n)=>Wd(n,Vd(e.baseUrl))}},Ff=e=>typeof e==`string`?e:e.toModel().name,If=(e,t)=>{let n=n=>t(Ff(n))??e;return{list:(e,t)=>n(e).list(e,t),search:(e,t)=>n(e).search(e,t),get:(e,t)=>n(e).get(e,t),create:(e,t)=>n(e).create(e,t),update:(e,t,r,i)=>n(e).update(e,t,r,i),remove:(e,t,r)=>n(e).remove(e,t,r),undelete:(e,t)=>n(e).undelete(e,t),generate:(e,t,r)=>n(e).generate(e,t,r),reveal:(e,t,r)=>n(e).reveal(e,t,r),history:(e,t,r)=>n(e).history(e,t,r),comments:(e,t,r)=>n(e).comments(e,t,r),comment:(e,t,r)=>n(e).comment(e,t,r),mentionable:(e,t,r)=>n(e).mentionable(e,t,r),batchWrite:t=>{let r=[...new Set(t.map(e=>n(e.resource)))];return r.length>1?Promise.reject(Error(`A batch writes to one API, but these writes are for ${[...new Set(t.map(e=>Ff(e.resource)))].join(`, `)}, which different APIs serve`)):(r[0]??e).batchWrite(t)},facets:(e,t,r)=>n(e).facets(e,t,r),aggregate:(e,t)=>n(e).aggregate(e,t),series:(e,t)=>n(e).series(e,t),histogram:(e,t,r)=>n(e).histogram(e,t,r),batchAggregates:(e,t)=>n(e).batchAggregates(e,t),map:(e,t)=>n(e).map(e,t),seek:(e,t)=>n(e).seek(e,t),meta:(t,n)=>e.meta(t,n),fileReadUrl:(e,t)=>n(e).fileReadUrl(e,t),invoke:(t,n)=>e.invoke(t,n),functionSocketUrl:(t,n)=>e.functionSocketUrl(t,n),upload:(e,t,r,i)=>n(e).upload(e,t,r,i),form:t=>e.form(t),formChallenge:t=>e.formChallenge(t),submitForm:(t,n,r)=>e.submitForm(t,n,r),live:t=>e.live(t),channel:(t,n)=>e.channel(t,n),bridges:e.bridges,devices:e.devices,notifications:e.notifications,status:e.status,rings:e.rings,callGuests:e.callGuests,calls:(e,t)=>n(e).calls(e,t),watchCalls:(e,t,r)=>n(e).watchCalls(e,t,r),workflowTypes:()=>n(`workflows`).workflowTypes(),workflowRunTrace:(e,t)=>n(`workflow_runs`).workflowRunTrace(e,t),runnerRegistration:e=>n(`workflow_runners`).runnerRegistration(e)}},Lf=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.type==`string`&&Array.isArray(e.children),Rf=Symbol(`recorded`),zf=[],Bf=0,Vf=0,Hf=e=>{if(Vf===0)throw Error(`A record block's children are a function of its record only inside a typed layout: layout(), recordLayout() or defineTemplate()`);Bf+=1;let t=Bf;zf.push(t);try{return{scope:t,built:e(t)}}finally{zf.pop()}},Uf=new WeakMap,Wf=(e,t)=>{Uf.set(e,t)},Gf=(e,t)=>{let n=Uf.get(e);n!==void 0&&Uf.set(t,n)},Kf=/^\d+[smhdw]$/,qf=class e{offset;constructor(e){this.offset=e}plus(t){return new e({sign:`+`,duration:Jf(t)})}minus(t){return new e({sign:`-`,duration:Jf(t)})}toString(){return this.offset?`now() ${this.offset.sign} ${this.offset.duration}`:`now()`}},Jf=e=>{if(!Kf.test(e))throw Error(`"${e}" is not a duration: write a number and s, m, h, d or w, such as '7d'`);return e},Yf=class{text;op;constructor(e,t){this.text=e,this.op=t}and(e){return Xf(`and`,this,e)}or(e){return Xf(`or`,this,e)}toString(){return this.text}},Xf=(e,t,n)=>{let r=t=>t.op===`term`||t.op===e?t.text:`(${t.text})`;return new Yf(`${r(t)} ${e.toUpperCase()} ${r(n)}`,e)},Zf=e=>(typeof e==`object`||typeof e==`function`)&&e!==null&&Rf in e,Qf=e=>`{{~${e[Rf].scope}~${e[Rf].path.join(`.`)}}}`,$f=({path:e,scope:t})=>`~~${t}~${e.join(`.`)}~~`,ep=e=>{if(Zf(e))return Qf(e);if(e instanceof qf)return e.toString();if(e instanceof Date)return JSON.stringify(e.toISOString());if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`||e===null)return String(e);throw Error(`${String(e)} cannot be a filter value: compare with text, a number, true or false, null, now() or a recorded field`)},tp=e=>new Yf(e,`term`),np=e=>({eq:t=>tp(t===null?`isNull(${e})`:`${e} = ${ep(t)}`),ne:t=>tp(t===null?`NOT isNull(${e})`:`${e} != ${ep(t)}`),lt:t=>tp(`${e} < ${ep(t)}`),le:t=>tp(`${e} <= ${ep(t)}`),gt:t=>tp(`${e} > ${ep(t)}`),ge:t=>tp(`${e} >= ${ep(t)}`),in:t=>tp(`in(${e}, ${t.map(ep).join(`, `)})`),contains:t=>tp(`${e}:${ep(t)}`),isNull:()=>tp(`isNull(${e})`)}),rp=new Set(Object.keys(np(``))),ip=(e=[],t=zf.at(-1)??0)=>new Proxy({},{get:(n,r)=>{if(r===Rf)return{path:e,scope:t};if(r===Symbol.toPrimitive||r===`toString`||r===`toJSON`)return()=>Qf({[Rf]:{path:e,scope:t}});if(typeof r!=`symbol`)return rp.has(r)?np($f({path:e,scope:t}))[r]:ip([...e,r],t)},has:(e,t)=>t===Rf}),ap=(e=[])=>new Proxy({},{get:(t,n)=>{if(typeof n!=`symbol`)return rp.has(n)&&e.length>0?np(e.join(`.`))[n]:ap([...e,n])}}),op=`Layouts are static data, sent to the browser as JSON: use <Action name="..."> for behaviour, or register a custom component for React code.`,sp=e=>typeof e==`function`?`a function`:typeof e==`number`?String(e):typeof e!=`object`||!e?`a ${typeof e}`:`a ${e.constructor?.name??`object without prototype`}`,cp=e=>{let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},lp=(e,t)=>{if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(Zf(e))return Qf(e);if(e instanceof Yf||e instanceof qf)return e.toString();if(typeof e==`number`&&Number.isFinite(e))return e;if(Array.isArray(e))return e.map((e,n)=>lp(e,`${t.slice(0,-1)}[${n}]>`));if(typeof e==`object`&&cp(e)){let n=Object.fromEntries(Object.entries(e).flatMap(([e,n])=>n===void 0?[]:[[e,lp(n,`${t.slice(0,-1)}.${e}>`)]]));return Gf(e,n),n}throw Error(`${t} is ${sp(e)}. ${op}`)},up=(e,t)=>{if(e==null||typeof e==`boolean`)return[];if(typeof e==`string`)return[e];if(Zf(e))return[Qf(e)];if(typeof e==`number`&&Number.isFinite(e))return[String(e)];if(Array.isArray(e))return e.flatMap(e=>up(e,t));if(Lf(e))return e.type===`Fragment`&&!e.custom?e.children:[e];throw Error(`${t} has a child that is ${sp(e)}. ${op}`)},dp=e=>typeof e==`function`&&typeof e.blockName==`string`,fp=[`RecordCard`,`CardRow`,`ReferenceField`,`RecordsIterator`],pp=[`filter`,`edgeFilter`,`animated`,`dashed`,`dotted`],mp=(e,t)=>{let n={...t};for(let t of pp){let r=n[t];if(typeof r==`function`){let i=r(ap());if(!(i instanceof Yf))throw Error(`<${e} ${t}> is an arrow that gives no condition: write (f) => f.status.eq('open'), or the ${t} as AIP-160 text`);n[t]=i.text}else if(typeof r==`object`&&r&&!(r instanceof Yf))throw Error(`<${e} ${t}> is an object: write the ${t} as an arrow, (f) => f.status.eq('open'), or as AIP-160 text`)}if(n.sort!==void 0){if(!Array.isArray(n.sort)||!n.sort.every(e=>typeof e==`string`))throw Error(`<${e} sort> takes a list of fields, each with asc or desc if it likes: sort={['next_run_at asc']}`);n.sort=n.sort.join(`, `)}return n},hp=(e,t,n)=>{if(typeof t!=`function`)return{children:up(t,n)};if(!fp.includes(e))throw Error(`<${e}> takes elements as children; only ${fp.join(`, `)} take a function of their record`);let{scope:r,built:i}=Hf(e=>up(t(ip([],e)),n));return{children:i,scope:r}},gp={Graph:`node`},_p=new Set([`Graph`]),vp=(e,t,n)=>{let r=`<${e} ${t}>`,i=e=>{let[t]=e;return e.length===1&&typeof t==`object`?t:{type:`Box`,props:{},children:e}};if(typeof n!=`function`)return{value:n===void 0||Lf(n)?n:i(up(n,r))};let{scope:a,built:o}=Hf(e=>up(n(ip([],e)),r));return{value:i(o),scope:a}},yp=(e,t)=>{if(typeof e==`string`)throw Error(`<${e}> is an HTML element, not a layout block: use the blocks from @protobase/layout or a custom component`);if(!dp(e))throw Error(`<${typeof e==`function`&&e.name?e.name:`unknown`}> is not a layout block. Components in a layout are declared with component('Name') and implemented in the app; ${op}`);let n=e.blockName,{children:r,...i}=t,a=!e.custom&&_p.has(n),{fallback:o,...s}=i,c=a?s:i,l=e.custom?c:mp(n,c),u=e.custom?void 0:gp[n],d=u===void 0?void 0:vp(n,u,l[u]);u!==void 0&&(l[u]=d.value);let f=e.custom?{children:up(r,`<${n}>`)}:hp(n,r,`<${n}>`),p={type:n,props:Object.fromEntries(Object.entries(l).flatMap(([e,t])=>t===void 0?[]:[[e,lp(t,`<${n} ${e}>`)]])),children:f.children},m=f.scope??d?.scope;return m!==void 0&&Wf(p,m),e.custom&&(p.custom=!0),e.fallback&&(p.fallback=e.fallback),a&&o!==void 0&&(p.fallback=up(o,`<${n} fallback>`)),e.reads&&(p.reads=e.reads),p},bp=(e,t,n,r)=>{let i=Object.assign(e=>yp(i,e),{blockName:e,custom:t,...n&&{fallback:n},...r&&{reads:r}});return i},xp=e=>bp(e,!1),Sp=e=>xp(e);Sp(`ReferenceManyField`),Sp(`ReferenceArrayField`),xp(`ArrayField`),Sp(`RecordsIterator`),Sp(`ReferenceField`);var Cp=e=>`${e} desc`,wp=new Set([`Table`,`Timeline`,`Graph`]),Tp=e=>e===`Graph`?`nodes`:`resource`,Ep=e=>Array.isArray(e)?e:[e],Dp=e=>typeof e==`string`?e:void 0,Op=e=>{if(!e.custom){let t=wp.has(e.type)?Dp(e.props.select):void 0;return t===void 0?void 0:{param:t,resource:Dp(e.props[Tp(e.type)])}}let t=e.reads&&Ep(e.reads).find(e=>e.select!==void 0),n=t&&Dp(e.props[t.select]);return n===void 0?void 0:{param:n,resource:Dp(e.props[t.resource])}},kp={stack:[]},Ap=e=>typeof e==`string`?e:void 0,jp=(e,t)=>({stack:[...e.stack,t],...e.root!==void 0&&{root:e.root}}),Mp=(e,t)=>({...e,list:t}),Np=(e,t)=>{let n=Ip(e),r=Op(e);if(r)return jp(t,{resource:r.resource,repeated:!1,block:n});if(e.custom)return t;switch(e.type){case`RecordCard`:case`CardRow`:return jp(t,{resource:Ap(e.props.resource),repeated:e.type===`CardRow`,block:n});case`ReferenceField`:return jp(t,{resource:Ap(e.props.reference),repeated:!1,block:n});case`ReferenceManyField`:case`ReferenceArrayField`:return Mp(t,{resource:Ap(e.props.reference),items:!1,block:n});case`ArrayField`:return Mp(t,{items:!0,block:n});case`RecordsIterator`:return t.list?jp(t,{...t.list.resource!==void 0&&{resource:t.list.resource},repeated:!0,...t.list.items&&{item:!0},block:t.list.block}):t;default:return t}},Pp=(e,t)=>e.custom?t:e.type===`RecordCard`?Np(e,t):e.type===`Graph`?jp(t,{resource:Ap(e.props.nodes),repeated:!0,block:Ip(e)}):t,Fp=e=>!e.custom&&e.type===`Graph`?[`nodes`]:[`resource`,`reference`,`name`,`source`],Ip=e=>`<${e.type}${Fp(e).map(t=>typeof e.props[t]==`string`?` ${t}="${e.props[t]}"`:``).join(``)}>`,Lp=e=>Lf(e)||Array.isArray(e)&&e.length>0&&e.every(Lf),Rp=(e,t,n={path:Ip(e),scope:kp})=>{let r=Np(e,n.scope),i=Pp(e,n.scope),a=e.children.flatMap(e=>{if(typeof e==`string`)return[e];let i=Rp(e,t,{path:`${n.path} › ${Ip(e)}`,scope:r});return i?[i]:[]}),o=Object.fromEntries(Object.entries(e.props).flatMap(([e,r])=>{if(!Lp(r))return[[e,r]];let a=(Array.isArray(r)?r:[r]).flatMap(r=>Rp(r,t,{path:`${n.path} ${e}={${Ip(r)}}`,scope:i})??[]);return a.length===0?[]:[[e,Array.isArray(r)?a:a[0]]]})),s=e.fallback?.flatMap(e=>{if(typeof e==`string`)return[e];let r=Rp(e,t,{path:`${n.path} fallback={${Ip(e)}}`,scope:n.scope});return r?[r]:[]});return t({...e,props:o,children:a,...s&&{fallback:s}},n)},zp=(e,t,n={path:Ip(e),scope:kp})=>{t(e,n);let r=Np(e,n.scope),i=Pp(e,n.scope);for(let i of e.children)typeof i!=`string`&&zp(i,t,{path:`${n.path} › ${Ip(i)}`,scope:r});for(let[r,a]of Object.entries(e.props))if(Lp(a))for(let e of Array.isArray(a)?a:[a])zp(e,t,{path:`${n.path} ${r}={${Ip(e)}}`,scope:i});for(let r of e.fallback??[])typeof r!=`string`&&zp(r,t,{path:`${n.path} fallback={${Ip(r)}}`,scope:n.scope})};bp(`SelectInput`,!1);var Bp=e=>{let t=new Map;return zp(e,e=>{e.custom||e.type!==`SelectInput`||typeof e.props.source!=`string`||t.has(e.props.source)||t.set(e.props.source,e.props)}),t},Vp=(e,t)=>t!==void 0&&t!==``&&(e.choices===void 0||e.choices.some(e=>String(e.id)===t))?t:e.defaultValue===void 0?void 0:String(e.defaultValue),Hp=(e,t={})=>{let n={};for(let[r,i]of Bp(e)){let e=Vp(i,Object.hasOwn(t,r)?t[r]:void 0);e!==void 0&&(n[r]=e)}return n},W=e=>({kind:e}),G=e=>({kind:e,required:!0}),Up={title:W(`shown`),description:W(`shown`),actions:W(`elements`)},Wp={resource:G(`text`),filter:W(`text`),sort:W(`text`)},Gp={resource:`resource`,filter:`filter`,sort:`sort`},Kp={sort:W(`sort`),filter:W(`filter`),perPage:W(`integer`)},qp={source:G(`text`),emptyText:W(`text`)},Jp={locales:W(`locales`),options:W(`intlOptions`)},Yp={Page:{children:!0,props:{title:G(`shown`),description:W(`shown`),actions:W(`elements`),width:W(`pageWidth`)}},Grid:{children:!0,props:{columns:W(`columns`),span:W(`span`)}},Card:{children:!0,props:{...Up,span:W(`span`)}},Stat:{children:!1,props:{label:G(`shown`),value:W(`scalar`),resource:W(`text`),filter:W(`text`),field:W(`text`),format:W(`format`),description:W(`shown`),span:W(`span`)},reads:{resource:`resource`,filter:`filter`}},RecordCard:{children:!0,props:{...Wp,...Up,recordKey:W(`text`),empty:W(`shown`),span:W(`span`)},reads:Gp},Field:{children:!1,props:{source:G(`text`),label:W(`label`),format:W(`format`)}},Diff:{children:!1,props:qp},Table:{children:!0,reads:Gp,props:{...Wp,resource:W(`text`),...Up,columns:W(`tableColumns`),button:W(`rowButton`),bulk:W(`boolean`),limit:W(`integer`),display:W(`text`),empty:W(`shown`),span:W(`span`),select:W(`text`)}},SelectInput:{children:!1,props:{source:G(`text`),choices:W(`choices`),label:W(`shown`),defaultValue:W(`scalar`)}},CardRow:{children:!0,props:{...Wp,...Up,limit:W(`integer`),empty:W(`shown`),span:W(`span`)},reads:Gp},RecordRow:{children:!1,props:{...Wp,...Up,limit:W(`integer`),display:W(`text`),empty:W(`shown`),span:W(`span`)},reads:Gp},RecordCards:{children:!1,reads:{...Gp,fields:`fields`},props:{...Wp,...Up,layout:W(`cardsLayout`),cardWidth:W(`cardWidth`),fields:W(`texts`),cardActions:W(`texts`),limit:W(`integer`),display:W(`text`),empty:W(`shown`),span:W(`span`)}},Chart:{children:!1,reads:{resource:`resource`,filter:`filter`},props:{...Up,resource:G(`text`),filter:W(`text`),groupBy:G(`text`),splitBy:W(`text`),type:W(`chartType`),sum:W(`text`),average:W(`text`),granularity:W(`bucket`),range:W(`range`),limit:W(`integer`),empty:W(`shown`),span:W(`span`)}},Timeline:{children:!0,reads:{resource:`resource`,filter:`filter`},props:{...Up,resource:G(`text`),filter:W(`text`),lane:G(`text`),bar:G(`text`),start:G(`text`),end:G(`text`),color:G(`text`),limit:W(`integer`),empty:W(`shown`),span:W(`span`),select:W(`text`)}},Graph:{children:!0,reads:[{resource:`nodes`,filter:`filter`,fields:[`label`,`group`,`status`,`x`,`y`],select:`select`},{resource:`edges`,filter:`edgeFilter`,fields:[`source`,`target`,`edgeLabel`,`edgeStatus`]}],props:{nodes:G(`text`),edges:G(`text`),source:G(`text`),target:G(`text`),label:G(`text`),group:W(`text`),status:W(`text`),node:W(`elements`),filter:W(`text`),edgeFilter:W(`text`),edgeLabel:W(`text`),edgeStatus:W(`text`),animated:W(`text`),dashed:W(`text`),dotted:W(`text`),layout:W(`graphLayout`),direction:W(`graphDirection`),x:W(`text`),y:W(`text`),select:W(`text`),empty:W(`shown`)}},Progress:{children:!1,props:{value:G(`amount`),max:W(`amount`),label:W(`shown`),span:W(`span`)}},ModalForm:{children:!1,props:{mode:G(`mode`),label:G(`shown`),fields:G(`texts`),resource:W(`text`),recordKey:W(`text`),title:W(`shown`),values:W(`values`),variant:W(`variant`)}},Thread:{children:!1,reads:{resource:`resource`,filter:`filter`},props:{...Up,resource:G(`text`),filter:W(`text`),sender:W(`text`),time:G(`text`),text:G(`text`),status:W(`text`),working:W(`text`),calls:W(`toolCalls`),limit:W(`integer`),empty:W(`shown`),span:W(`span`)}},Composer:{children:!1,props:{resource:G(`text`),field:G(`text`),values:W(`values`),placeholder:W(`text`),span:W(`span`)}},Image:{children:!1,props:{function:W(`text`),src:W(`text`),alt:W(`text`),width:W(`integer`),height:W(`integer`),refresh:W(`integer`)}},Action:{children:!1,props:{name:G(`text`),resource:W(`text`),label:W(`shown`),variant:W(`variant`)}},ReferenceManyField:{children:!0,reads:{resource:`reference`,filter:`filter`,sort:`sort`},props:{reference:G(`text`),target:G(`text`),source:W(`text`),...Kp,empty:W(`shown`),pagination:W(`pagination`)}},ReferenceArrayField:{children:!0,reads:{resource:`reference`,filter:`filter`,sort:`sort`},props:{source:G(`text`),reference:G(`text`),...Kp,empty:W(`shown`)}},ArrayField:{children:!0,props:{source:G(`text`)}},RecordsIterator:{children:!0,props:{}},ReferenceField:{children:!0,reads:{resource:`reference`},props:{source:G(`text`),reference:G(`text`),link:W(`referenceLink`),empty:W(`shown`)}},Show:{children:!0,props:{when:G(`text`),fallback:W(`content`)}},Switch:{children:!0,props:{fallback:W(`content`)}},Match:{children:!0,props:{when:G(`text`)}},Link:{children:!0,props:{href:W(`text`),to:W(`address`),variant:W(`variant`)}},Tabs:{children:!0,props:{}},Tab:{children:!0,props:{name:G(`text`),label:G(`shown`)}},Settings:{children:!1,props:{resource:G(`text`),fields:W(`texts`),title:W(`shown`),description:W(`shown`),span:W(`span`)}},Users:{children:!1,props:{}},Profile:{children:!1,props:{}},Password:{children:!1,props:{}},Passkeys:{children:!1,props:{}},TwoFactor:{children:!1,props:{}},ConnectedAccounts:{children:!1,props:{}},PersonalMail:{children:!1,props:{}},Connections:{children:!1,props:{}},Devices:{children:!1,props:{}},ConnectedApps:{children:!1,props:{}},PersonalAccessTokens:{children:!1,props:{}},DeleteAccount:{children:!1,props:{}},Box:{children:!0,props:{}},Email:{children:!0,props:{}},Button:{children:!0,props:{href:G(`text`)}},Divider:{children:!1,props:{}},Row:{children:!0,props:{}},Column:{children:!0,props:{}},Text:{children:!0,props:{as:W(`textAs`)}},Trans:{children:!1,props:{i18nKey:G(`text`),values:W(`transValues`),components:W(`transComponents`)}},Details:{children:!0,props:{open:W(`boolean`)}},Summary:{children:!0,props:{}},TextField:{children:!1,props:qp},NumberField:{children:!1,props:{...qp,...Jp}},DateField:{children:!1,props:{...qp,...Jp,showDate:W(`boolean`),showTime:W(`boolean`),format:W(`dateFormat`)}},BooleanField:{children:!1,props:{...qp,valueLabelTrue:W(`text`),valueLabelFalse:W(`text`)}},UrlField:{children:!1,props:{...qp,content:W(`text`)}},ChipField:{children:!1,props:qp}},Xp=Object.fromEntries(Object.entries(Yp).map(([e,t])=>[e,{...t,props:{...t.props,className:W(`text`)}}])),Zp=[`relative`,`absolute`,`compact`,`percent`,`badge`,`code`],Qp=[`primary`,`secondary`,`danger`,`ghost`],$p=[`bar`,`line`,`donut`],em=[`hour`,`day`,`week`,`month`,`year`],tm=[`7d`,`30d`,`90d`,`1y`,`all`],nm=[`stack`,`carousel`],rm=[`1/4`,`1/3`,`1/2`,`2/3`],im=[`column`,`full`],am=[`p`,`span`,`strong`,`em`,`h1`,`h2`,`h3`,`h4`],om=e=>[t=>typeof t==`string`&&e.includes(t),e.join(`, `)];Zp.join(`, `),Qp.join(`, `),om($p),om(em),om(tm),om(nm),om(rm),om(im),om(am),om([`relative`]),om([`layered`,`force`]),om([`down`,`right`]);var sm=e=>`${e} desc`,cm=/(["'])\{\{\s*([^{}]*?)\s*\}\}\1|\{\{\s*([^{}]*?)\s*\}\}/g,lm=e=>{let t=[],n=``,r=0;for(let i of e.matchAll(cm)){n+=e.slice(r,i.index);let a=i[1]!==void 0;t.push({path:a?i[2]:i[3],start:n.length,quoted:a}),n+=a?`${i[1]}x${i[1]}`:`0`,r=i.index+i[0].length}return{text:n+e.slice(r),slots:t}},um=(e,t,n)=>{let r=[],i=e[t],a=n.split(`.`);for(let[o,s]of a.entries()){if(!i)return{ok:!1,message:`unknown resource "${t}"`};let c=Object.hasOwn(i.fields,s)?i.fields[s]:void 0;if(!c)return{ok:!1,message:`unknown field "${a.slice(0,o+1).join(`.`)}" on ${i.name}`};if(r.push({model:i,field:c}),o===a.length-1)break;if(c.type!==`relation`||!c.relation)return{ok:!1,message:`"${a.slice(0,o+1).join(`.`)}" is not a relation, so "${n}" cannot go through it`};t=c.relation.resource,i=e[t]}return{ok:!0,steps:r}},dm=e=>`${String(e.props.start)} asc`,fm=e=>`${String(e.props.start)} desc`,pm=2e4,mm=e=>typeof e==`object`&&!!e&&e.kind===`member`,hm=e=>mm(e)?[e.path.join(`.`)]:typeof e!=`object`||!e?[]:Object.values(e).flatMap(hm),gm=e=>mm(e)?{...e,path:[e.path.join(`.`)]}:Array.isArray(e)?e.map(gm):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,gm(t)])),_m=new Set([`string`,`number`,`boolean`,`duration`,`timestamp`]),vm=e=>_m.has(e.kind),ym=e=>{let[t,...n]=e.args;if(t&&mm(t)){if(e.name===`isNull`&&n.length===0)return{kind:`not`,arg:{kind:`present`,left:t,span:e.span},span:e.span};if(e.name===`in`&&n.length!==0&&n.every(vm))return{kind:`or`,args:n.map(n=>({kind:`compare`,op:`=`,left:t,right:n,span:e.span})),span:e.span}}},bm=e=>Array.isArray(e)?e.map(bm):typeof e!=`object`||!e?e:(e.kind===`call`?ym(e):void 0)||Object.fromEntries(Object.entries(e).map(([e,t])=>[e,bm(t)])),xm=new Set([`isNull`,`in`,`now`]),Sm=e=>Array.isArray(e)?e.flatMap(Sm):typeof e!=`object`||!e?[]:[...e.kind===`call`?[e.name]:[],...Object.values(e).flatMap(Sm)],Cm={extensions:{arithmetic:`now-offset`,durationUnits:!0}},wm=e=>{let t=C(e,Cm);if(!t.ok)return{ok:!1,message:t.errors.map(e=>e.message).join(`; `)};if(!t.ast)return{ok:!1,message:`the condition is empty`};let n=Sm(t.ast).find(e=>!xm.has(e));return n===void 0?{ok:!0,ast:t.ast,paths:[...new Set(hm(t.ast))]}:{ok:!1,message:`${n}() only works in a list's filter, which the API reads; a condition can call isNull(), in() and now()`}},Tm={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5},Em=(e,t)=>{if(Array.isArray(e))return e.map(e=>Em(e,t));if(typeof e!=`object`||!e)return e;let n=e;if(n.kind===`call`&&n.name===`now`)return{kind:`string`,value:new Date(t).toISOString()};if(n.kind===`binary`&&n.left?.kind===`call`&&n.left.name===`now`&&n.right?.kind===`duration`){let e=(n.right.amount??0)*Tm[n.right.unit??`s`];return{kind:`string`,value:new Date(n.op===`-`?t-e:t+e).toISOString()}}return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Em(n,t)]))},Dm=(e,t,n=Date.now())=>e.ast!==void 0&&o(gm(bm(Em(e.ast,n))),t),Om=(e,t)=>{let[n,r,...i]=e.split(`.`);return n&&r===`count`&&i.length===0&&!t(n)?n:void 0},km=[`animated`,`dashed`,`dotted`],Am=e=>wm(lm(e).text),jm=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Mm=e=>typeof e==`number`||typeof e==`boolean`?String(e):`"${String(e).replace(/\\/g,`\\\\`).replaceAll(`"`,`\\"`)}"`,Nm=e=>{if(typeof e==`string`)return e;if(jm(e))return e.order===`DESC`?`${e.field} desc`:String(e.field)},Pm=e=>{if(typeof e==`string`)return e;if(!jm(e))return;let t=Object.entries(e).map(([e,t])=>t===null?`isNull(${e})`:`${e} = ${Mm(t)}`);return t.length===0?void 0:t.join(` AND `)},Fm=(...e)=>{let t=e.filter(e=>e!==void 0&&e.trim()!==``);return t.length<=1?t[0]:t.map(e=>`(${e})`).join(` AND `)},Im=(e,t,n)=>t==null?void 0:Fm(`${e} = ${Mm(t)}`,Pm(n)),Lm=(e,t,n)=>{let r=Array.isArray(t)?t.filter(e=>typeof e==`string`||typeof e==`number`):[];return r.length===0?void 0:Fm(`in(${e}, ${r.map(Mm).join(`, `)})`,Pm(n))},Rm=(e,t,n)=>({filter:Im(e.target,n(e.source??`this.id`),e.filter),sort:Nm(e.sort)??Cp(t),perPage:e.perPage??25}),zm=(e,t,n)=>({filter:Lm(t,n(e.source),e.filter),sort:Nm(e.sort)??Cp(t),perPage:e.perPage??500}),Bm=e=>e.part===void 0?e.block:`${e.block}#${e.part}`,Vm=e=>typeof e==`string`?e:e.name,Hm=e=>typeof e==`string`?void 0:e.priority,Um=({title:e,badge:t})=>e?0:t?1:2,Wm=(e,t)=>e.map((e,n)=>({name:Vm(e),given:Hm(e),derived:Um(t(Vm(e))),index:n})).sort((e,t)=>e.given!==void 0&&t.given!==void 0?e.given-t.given||e.index-t.index:e.given===void 0?t.given===void 0?e.derived-t.derived||e.index-t.index:1:-1).map(({name:e})=>e),Gm=(e,t)=>{let n=e.filter(e=>Hm(e)!==void 0),r=n.length>0?n:e,i=new Set(Wm(r,t).slice(0,3));return e.map(Vm).filter(e=>i.has(e))},Km=e=>{let t=e.custom?e.reads:Xp[e.type]?.reads;return t?Array.isArray(t)?t.map(e=>({reads:e,part:e.resource})):[{reads:t}]:[]},qm=(e,t)=>{if(t===``)return e;let n=e;for(let e of t.slice(1).split(`/`)){let t=e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if(typeof n!=`object`||!n||!Object.hasOwn(n,t))return;n=n[t]}return Lf(n)?n:void 0},Jm=(e,...t)=>e+t.map(e=>`/${String(e).replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`).join(``),Ym=e=>typeof e==`object`&&!!e,Xm=(e,t)=>t.reduce((e,t)=>Ym(e)&&Object.hasOwn(e,t)?e[t]:void 0,e),Zm=(e,t)=>{let n=Lt(t);if(!n)return;if(n.kind===`data`){if(n.variable===`root`)return e.root===void 0?void 0:Xm(e.root,n.names);if(n.variable===`params`)return e.params&&Object.hasOwn(e.params,n.names[0])?e.params[n.names[0]]:void 0;let t=e.stack.findLast(e=>e.row!==void 0)?.row;return t?n.variable===`index`?t.index:n.variable===`first`?t.index===0:t.index===t.count-1:void 0}let r=[...e.root===void 0?[]:[e.root],...e.stack.map(e=>e.record)];if(n.explicit){let e=r[r.length-1-n.up];return e===void 0?void 0:Xm(e,n.names)}let[i,...a]=n.names,o=r.findLast(e=>Ym(e)&&Object.hasOwn(e,i));return Ym(o)?Xm(o[i],a):void 0},Qm=e=>t=>Zm(e,t),$m=e=>e===void 0?null:typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===null?e:Xt(e),eh=(e,t)=>Object.fromEntries(Object.entries(e).map(([e,n])=>{let r=typeof n==`string`?Bt(n):void 0;return[e,r===void 0?rh(n,t):$m(t(r))]})),th=[`title`,`description`,`empty`,`label`,`recordKey`],nh=[`filter`,`when`,`working`,`edgeFilter`,`animated`,`dashed`,`dotted`],rh=(e,t)=>typeof e==`string`?Yt(e,e=>Xt(t(e))):Array.isArray(e)?e.map(e=>rh(e,t)):Ym(e)?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,rh(n,t)])):e,ih=(e,t)=>{if(e.custom||!JSON.stringify(e.props).includes(`{{`))return e;let n=Qm(t),r={...e.props};for(let e of th)typeof r[e]==`string`&&(r[e]=Yt(r[e],e=>Xt(n(e))));for(let e of th){let n=r[e];Lf(n)&&n.type===`Trans`&&(r[e]=ih(n,t))}for(let e of nh)typeof r[e]==`string`&&(r[e]=tn(r[e],n));return Ym(r.filter)&&(r.filter=eh(r.filter,n)),r.values!==void 0&&(r.values=rh(r.values,n)),Ym(r.calls)&&typeof r.calls.filter==`string`&&(r.calls={...r.calls,filter:tn(r.calls.filter,n)}),{...e,props:r}},ah=(e,t)=>{if(!e.custom||!e.reads)return e;let n=Qm(t),r={...e.props},i=new Set(Ep(e.reads).flatMap(({filter:e})=>e===void 0?[]:[e]));for(let t of i){let i=e.props[t];typeof i==`string`?r[t]=tn(i,n):Ym(i)&&(r[t]=eh(i,n))}return{...e,props:r}},oh=new Set([1,2,3,4,5,6]),sh=8,ch=(e,t)=>{for(let n of e){oh.has(n.type)&&n.value!==void 0&&t.values.add(n.value),n.type===sh&&n.value!==void 0&&t.tags.add(n.value);for(let e of Object.values(n.options??{}))ch(e.value,t);n.children&&ch(n.children,t)}},lh=(e,t)=>{let n={values:new Set,tags:new Set};return ch(new ie(e,t).getAst(),n),{values:[...n.values],tags:[...n.tags]}},uh=new Map,dh=(e,t,n={},r={})=>{let i=e?.messages[t];if(i===void 0||!e)return t;let a=`${e.locale}\u0000${i}`,o=uh.get(a);return o||(o=new ie(i,e.locale),uh.set(a,o)),o.format({...n,...r})},fh=(e,t,n={})=>{let r=dh(e,t,n,Object.fromEntries((e?.messages[t]?lh(e.messages[t],e.locale).tags:[]).map(e=>[e,e=>e.join(``)])));return Array.isArray(r)?r.join(``):r};bp(`Trans`,!1);var ph=e=>Lf(e)&&e.type===`Trans`&&!e.custom,mh=(e,t)=>e.filter===void 0?e:{...e,filter:tn(e.filter,Qm({stack:[],...t}))},hh=(e,t)=>{let n=new Map(t.reads.map(e=>[Bm(e),e])),r=[e.resource];for(let t=e.split&&n.get(e.split.parent);t;t=t.split&&n.get(t.split.parent))r.push(t.resource);return r},gh=(e,t,n)=>{if(!e.split)return t;let r=Zm(n,e.split.source);if(r==null||r===``)return[];let i=e.kind===`aggregate`?`value`:e.split.field,a=new Set((Array.isArray(r)?r:[r]).map(String));return t.filter(e=>a.has(String(e[i])))},_h=(e,t)=>({...e,fields:Object.fromEntries(Object.entries(e.fields).map(([e,n])=>{if(!n.relation||Object.hasOwn(t,n.relation.resource))return[e,n];let{relation:r,...i}=n;return[e,i]}))}),vh=(e,t)=>{if(e.kind===`group`){let n=e.items.flatMap(e=>vh(e,t));return n.length>0?[{...e,items:n}]:[]}if(e.kind===`tab`){let n=e.items.flatMap(e=>vh(e,t));return n.length>0?[{...e,items:n}]:[]}if(e.kind!==`related`)return[e];if(!Object.hasOwn(t,e.resource)||e.through&&!Object.hasOwn(t,e.through.resource))return[];let{columns:n,button:r,...i}=e,a=n?.filter(n=>um(t,e.resource,n).ok),o=a&&a.length>0?{...i,columns:a}:i,s=r===void 0?void 0:jr(r,t[e.resource],{models:t,pages:new Set});return[s===void 0?o:{...o,button:s}]},yh=(e,t,n)=>e.run?.kind!==`link`||!(`to`in e.run)||xr(e.run.to,{models:n,pages:new Set,source:t}).length===0,bh=(e,t)=>({...e,layout:e.layout.flatMap(e=>vh(e,t)),actions:e.actions.filter(n=>yh(n,t[e.resource],t))}),xh=(e,t)=>{let n=e.resources.filter(e=>t.resources.includes(e.name)),r=Object.fromEntries(n.map(e=>[e.name,e])),i=n.map(e=>_h(e,r)),a=Object.fromEntries(i.map(e=>[e.name,e]));return{resources:i,views:e.views.filter(e=>Object.hasOwn(a,e.resource)).map(e=>bh(e,a)),permissions:Object.fromEntries(n.flatMap(t=>e.permissions?.[t.name]?[[t.name,e.permissions[t.name]]]:[]))}},Sh=class extends TypeError{constructor(e){super(`The server could not be reached`,e),this.name=`NetworkError`}},Ch=e=>async(t,n)=>{try{return await e(t,n)}catch(e){throw e instanceof TypeError?new Sh({cause:e}):e}},K=class extends Error{status;code;constructor(e,t,n){super(e),this.status=t,this.code=n,this.name=`AuthError`}},q=(e,t)=>new K(e?.message||t,e?.status??500,e?.code),wh=e=>new Date(e).toISOString(),Th=e=>({updateName:async t=>{let{error:n}=await e.updateUser({name:t});if(n)throw q(n,`Could not change your name`)},changePassword:async(t,n)=>{let{error:r}=await e.changePassword({currentPassword:t,newPassword:n,revokeOtherSessions:!0});if(r)throw q(r,`Could not change your password`)},setPassword:async t=>{let{error:n}=await e.$fetch(`/account/set-password`,{method:`POST`,body:{newPassword:t}});if(n)throw q(n,`Could not set your password`)},requestEmailChange:async t=>{let{error:n}=await e.$fetch(`/email-otp/request-email-change`,{method:`POST`,body:{newEmail:t}});if(n)throw q(n,`Could not send the code`)},changeEmail:async(t,n)=>{let{error:r}=await e.$fetch(`/email-otp/change-email`,{method:`POST`,body:{newEmail:t,otp:n}});if(r)throw q(r,`Could not change your address`)},sessions:async()=>{let[t,n]=await Promise.all([e.listSessions(),e.getSession()]);if(t.error||!t.data)throw q(t.error,`Could not read your devices`);let r=n.data?.session.token;return t.data.map(e=>{let t=e.impersonatedBy;return{token:e.token,current:e.token===r,...e.userAgent&&{userAgent:e.userAgent},...e.ipAddress&&{ipAddress:e.ipAddress},createdAt:wh(e.createdAt),updatedAt:wh(e.updatedAt),expiresAt:wh(e.expiresAt),...t&&{staff:t}}})},revokeSession:async t=>{let{error:n}=await e.revokeSession({token:t});if(n)throw q(n,`Could not sign out the device`)},revokeOtherSessions:async()=>{let{error:t}=await e.revokeOtherSessions();if(t)throw q(t,`Could not sign out your other devices`)},deviceLinks:async()=>{let{data:t,error:n}=await e.$fetch(`/account/device-links`,{method:`GET`});if(n||!t)throw q(n,`Could not read your devices`);return t.links},signOutDeviceLink:async t=>{let{error:n}=await e.$fetch(`/account/device-links/sign-out`,{method:`POST`,body:{id:t}});if(n)throw q(n,`Could not sign out the device`)}}),Eh=e=>({signInMethods:async()=>{let{data:t,error:n}=await e.$fetch(`/account/sign-in-methods`);if(n||!t)throw q(n,`Could not read your sign-in methods`);return t},passkeys:async()=>{let{data:t,error:n}=await e.passkey.listUserPasskeys();if(n||!t)throw q(n,`Could not read your passkeys`);return t.map(e=>({id:e.id,backedUp:e.backedUp,...e.name&&{name:e.name},...e.createdAt&&{createdAt:new Date(e.createdAt).toISOString()}}))},addPasskey:async t=>{let{error:n}=await e.passkey.addPasskey(t?{name:t}:{});if(n)throw q(n,`Could not add the passkey`)},renamePasskey:async(t,n)=>{let{error:r}=await e.passkey.updatePasskey({id:t,name:n});if(r)throw q(r,`Could not rename the passkey`)},removePasskey:async t=>{let{error:n}=await e.passkey.deletePasskey({id:t});if(n)throw q(n,`Could not remove the passkey`)},startAuthenticatorApp:async t=>{let{data:n,error:r}=await e.twoFactor.enable({method:`totp`,...t&&{password:t}});if(r||n?.method!==`totp`)throw q(r,`Could not start two-factor authentication`);return{totpURI:n.totpURI,backupCodes:n.backupCodes}},confirmAuthenticatorApp:async t=>{let{error:n}=await e.twoFactor.verifyTotp({code:t});if(n)throw q(n,`The code did not work`)},turnOnEmailedCodes:async t=>{let{error:n}=await e.twoFactor.enable({method:`otp`,...t&&{password:t}});if(n)throw q(n,`Could not turn on two-factor authentication`)},turnOffTwoFactor:async t=>{let{error:n}=await e.twoFactor.disable(t?{password:t}:{});if(n)throw q(n,`Could not turn off two-factor authentication`)},linkedProviders:async()=>{let{data:t,error:n}=await e.listAccounts();if(n||!t)throw q(n,`Could not read your linked accounts`);return[...new Set(t.map(e=>e.providerId).filter(e=>e!==`credential`))]},linkProvider:async(t,n)=>{let{data:r,error:i}=await e.linkSocial({provider:t,callbackURL:n,errorCallbackURL:n,disableRedirect:!0});if(i||!r?.url)throw q(i,`Could not start linking the account`);return r.url},linkedPersonalMail:async t=>{let{data:n,error:r}=await e.listAccounts();if(r||!n)throw q(r,`Could not read your linked accounts`);return t.filter(e=>n.some(t=>t.providerId===e.provider&&e.scopes.every(e=>t.scopes.includes(e)))).map(e=>e.id)},linkPersonalMail:async(t,n)=>{let{data:r,error:i}=await e.linkSocial({provider:t.provider,scopes:t.scopes,additionalParams:t.params,callbackURL:n,errorCallbackURL:n,disableRedirect:!0});if(i||!r?.url)throw q(i,`Could not start linking the mailbox`);return r.url},workflowConnections:async()=>{let{data:t,error:n}=await e.$fetch(`/connections`);if(n?.status===404)return[];if(n||!t)throw q(n,`Could not read your connections`);return t.connections},connectAccount:async(t,n)=>{let{data:r,error:i}=await e.linkSocial({provider:t.provider,scopes:t.scopes,additionalParams:t.link_params,callbackURL:n,errorCallbackURL:n,disableRedirect:!0});if(i||!r?.url)throw q(i,`Could not start connecting the account`);return r.url},disconnectAccount:async t=>{let{data:n,error:r}=await e.$fetch(`/connections/disconnect`,{method:`POST`,body:{accountId:t}});if(r||!n)throw q(r,`Could not disconnect the account`);return n.revocation},connectedApps:async()=>{let{data:t,error:n}=await e.$fetch(`/account/connected-apps`);if(n||!t)throw q(n,`Could not read your connected apps`);return t.apps},disconnectApp:async t=>{let{error:n}=await e.$fetch(`/account/connected-apps/disconnect`,{method:`POST`,body:{clientId:t}});if(n)throw q(n,`Could not disconnect the app`)},sendConfirmationCode:async()=>{let{error:t}=await e.$fetch(`/account/confirmation-code/send`,{method:`POST`});if(t)throw q(t,`Could not email a code`)},confirmWithCode:async t=>{let{error:n}=await e.$fetch(`/account/confirmation-code/verify`,{method:`POST`,body:{code:t}});if(n)throw q(n,`The code did not work`)},confirmWithPassword:async t=>{let{error:n}=await e.$fetch(`/account/confirm-password`,{method:`POST`,body:{password:t}});if(n)throw q(n,`The password did not work`)},newBackupCodes:async t=>{let{data:n,error:r}=await e.twoFactor.generateBackupCodes(t?{password:t}:{});if(r||!n)throw q(r,`Could not make new backup codes`);return n.backupCodes}}),Dh=e=>({mailSenders:async()=>{let{data:t,error:n}=await e.$fetch(`/account/mail-senders`);if(n||!t)throw q(n,`Could not read your From addresses`);return t},addMailSender:async t=>{let{data:n,error:r}=await e.$fetch(`/account/mail-senders/add`,{method:`POST`,body:t});if(r||!n)throw q(r,`Could not add the From address`);return n.sender},updateMailSender:async(t,n)=>{let{data:r,error:i}=await e.$fetch(`/account/mail-senders/update`,{method:`POST`,body:{id:t,...n}});if(i||!r)throw q(i,`Could not change the From address`);return r.sender},removeMailSender:async t=>{let{error:n}=await e.$fetch(`/account/mail-senders/remove`,{method:`POST`,body:{id:t}});if(n)throw q(n,`Could not remove the From address`)}}),Oh=e=>({personalAccessTokens:async()=>{let{data:t,error:n}=await e.$fetch(`/account/personal-access-tokens`);if(n||!t)throw q(n,`Could not read your access tokens`);return t.tokens},createPersonalAccessToken:async t=>{let{data:n,error:r}=await e.$fetch(`/account/personal-access-tokens/create`,{method:`POST`,body:t});if(r||!n)throw q(r,`Could not make the access token`);return n},revokePersonalAccessToken:async t=>{let{error:n}=await e.$fetch(`/account/personal-access-tokens/revoke`,{method:`POST`,body:{id:t}});if(n)throw q(n,`Could not revoke the access token`)}}),kh=(e,t)=>new K(e?.message||e?.error_description||t,e?.status??500,e?.code??e?.error),Ah=e=>({client:async t=>{let{data:n,error:r}=await e.$fetch(`/oauth2/public-client`,{query:{client_id:t}});if(r||!n)throw kh(r,`Could not read the app asking`);return n},resume:async t=>{let{data:n,error:r}=await e.$fetch(`/oauth2/continue`,{method:`POST`,body:{postLogin:!0,oauth_query:t}});if(r||!n?.url)throw kh(r,`Could not go on with the request`);return{url:n.url}},answer:async(t,n)=>{let{data:r,error:i}=await e.$fetch(`/oauth2/consent`,{method:`POST`,body:{accept:t,oauth_query:n}});if(i||!r?.url)throw kh(i,`Could not answer the request`);return{url:r.url}}}),jh=(e,t,n)=>g({baseURL:e,basePath:t,plugins:[m(),re(),b(),ae()],disableDefaultFetchPlugins:!0,fetchOptions:{customFetchImpl:Ch(n)}}),Mh=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):typeof e==`string`?JSON.parse(e):[],Nh=e=>{let t=e.split(`,`);return t.includes(`owner`)?`owner`:t.includes(`admin`)?`admin`:`member`},Ph=e=>({id:e.id,userId:e.userId,name:e.user.name||e.user.email,email:e.user.email,role:Nh(e.role),appRoles:Mh(e.appRoles),createdAt:new Date(e.createdAt).toISOString()}),Fh=e=>({id:e.id,email:e.email,role:Nh(e.role),appRoles:Mh(e.appRoles),status:e.status,expiresAt:new Date(e.expiresAt).toISOString(),...e.organizationName&&{organizationName:e.organizationName}}),Ih=(e,t)=>{let n=async(t,n,r={})=>{let{data:i,error:a}=await e.$fetch(t,{method:r.method??(r.body?`POST`:`GET`),...r.body&&{body:r.body},...r.query&&{query:r.query}});if(a)throw q(a,n);return i},r=async e=>(await t().catch(e=>{if(!(e instanceof Sh))throw e}),e);return{list:async()=>await n(`/organization/list`,`Could not read your organizations`)??[],current:()=>n(`/organization/current`,`Could not read the current organization`),switchTo:async e=>r(await n(`/organization/switch`,`Could not switch the organization`,{body:{organizationId:e}})),search:(e,t=0)=>n(`/organization/search`,`Could not search the organizations`,{query:{query:e,...t>0&&{offset:String(t)}}}),create:async e=>r(await n(`/organization/create`,`Could not create the organization`,{body:e})),rename:(e,t)=>n(`/organization/update`,`Could not change the organization`,{body:{organizationId:e,data:t}}),remove:async e=>r(await n(`/organization/delete`,`Could not delete the organization`,{body:{organizationId:e}})),leave:async e=>r(await n(`/organization/leave`,`Could not leave the organization`,{body:{organizationId:e}})),members:async e=>(await n(`/organization/list-members`,`Could not read the members`,{query:{organizationId:e,limit:`1000`}})).members.map(Ph),people:async()=>(await n(`/organization/people`,`Could not read the people`)).people,setRole:(e,t,r)=>n(`/organization/update-member-role`,`Could not change the role`,{body:{organizationId:e,memberId:t,role:r}}),setAppRoles:(e,t)=>n(`/organization/set-app-roles`,`Could not change the app roles`,{body:{memberId:e,appRoles:t}}),removeMember:(e,t)=>n(`/organization/remove-member`,`Could not remove the member`,{body:{organizationId:e,memberIdOrEmail:t}}),transferOwnership:(e,t=`admin`)=>n(`/organization/transfer-ownership`,`Could not hand the organization over`,{body:{memberId:e,keepAs:t}}),invitations:async e=>(await n(`/organization/list-invitations`,`Could not read the invitations`,{query:{organizationId:e}})??[]).map(Fh),invite:async(e,t)=>{let r=await n(`/organization/invite-member`,`Could not send the invitation`,{body:{organizationId:e,...t}});return{invitation:Fh(r),...r.link&&{link:r.link}}},resend:async(e,t)=>{let r=await n(`/organization/invite-member`,`Could not send the invitation again`,{body:{organizationId:e,email:t.email,role:t.role,resend:!0}});return{invitation:Fh(r),...r.link&&{link:r.link}}},revoke:e=>n(`/organization/cancel-invitation`,`Could not revoke the invitation`,{body:{invitationId:e}}),myInvitations:async()=>(await n(`/organization/list-user-invitations`,`Could not read your invitations`)??[]).map(Fh),invitation:e=>n(`/invitation`,`This invitation link is not valid`,{query:{token:e}}),accept:async e=>r(await n(`/invitation/accept`,`Could not accept the invitation`,{body:{token:e}})),acceptMine:async e=>r(await n(`/invitation/accept-own`,`Could not accept the invitation`,{body:{invitationId:e}})),signUpFromInvitation:async(e,t)=>r(await n(`/invitation/sign-up`,`Could not create your account`,{body:{token:e,...t}}))}},Lh=(e,t)=>({current:async()=>{let{data:t,error:n}=await e.$fetch(`/role/current`,{method:`GET`});if(n)throw q(n,`Could not read your roles`);return t},switchTo:async n=>{let{error:r}=await e.$fetch(`/role/switch`,{method:`POST`,body:{role:n}});if(r)throw q(r,`Could not switch the role`);await t()}}),Rh=20,zh=e=>Array.isArray(e)?e:(e??``).split(`,`).map(e=>e.trim()).filter(Boolean),Bh=e=>({id:e.id,name:e.name||e.email,email:e.email,roles:zh(e.role),blocked:!!e.banned,createdAt:new Date(e.createdAt).toISOString()}),Vh=e=>({id:e.id,email:e.email,roles:e.roles,expiresAt:new Date(e.expiresAt).toISOString()}),Hh=e=>({invitation:Vh(e),...e.link&&{link:e.link}}),Uh=e=>{let t=async(t,n,r={})=>{let{data:i,error:a}=await e.$fetch(t,{method:r.body?`POST`:`GET`,...r.body&&{body:r.body},...r.query&&{query:r.query}});if(a)throw q(a,n);return i};return{search:async(e,n=0)=>{let r=await t(`/admin/list-users`,`Could not read the users`,{query:{limit:String(Rh),sortBy:`createdAt`,sortDirection:`asc`,...n>0&&{offset:String(n)},...e&&{searchValue:e,searchField:`email`}}});return{users:r.users.map(Bh),total:r.total}},create:async e=>Bh((await t(`/admin/create-user`,`Could not create the account`,{body:{email:e.email,name:e.name,role:e.roles,...e.password&&{password:e.password}}})).user),setRoles:(e,n)=>t(`/admin/set-role`,`Could not change the roles`,{body:{userId:e,role:n}}),block:e=>t(`/admin/ban-user`,`Could not block the account`,{body:{userId:e}}),unblock:e=>t(`/admin/unban-user`,`Could not unblock the account`,{body:{userId:e}}),invite:async e=>Hh(await t(`/users/invite`,`Could not send the invitation`,{body:e})),invitations:async()=>(await t(`/users/invitations`,`Could not read the invitations`)).invitations.map(Vh),revoke:e=>t(`/users/invitations/cancel`,`Could not revoke the invitation`,{body:{id:e}}),roles:()=>t(`/users/roles`,`Could not read the roles`)}},Wh=(e,t)=>{let n=async e=>e?.twoFactorRedirect?{kind:`two-factor`,methods:e.twoFactorMethods??[]}:(await t(),{kind:`signed-in`,user:e?.user});return{signIn:async(t,r)=>{let{data:i,error:a}=await e.signIn.email({email:t,password:r});if(a||!i)throw q(a,`Sign-in failed`);return n(i)},sendSignInCode:async t=>{let{error:n}=await e.emailOtp.sendVerificationOtp({email:t,type:`sign-in`});if(n)throw q(n,`Could not send the code`)},signInWithCode:async(t,r)=>{let{data:i,error:a}=await e.signIn.emailOtp({email:t,otp:r});if(a||!i)throw q(a,`Sign-in failed`);return n(i)},sendSignUpCode:async t=>{let{error:n}=await e.$fetch(`/sign-up/send-code`,{method:`POST`,body:{email:t}});if(n)throw q(n,`Could not send the code`)},verifySignUpCode:async(t,n)=>{let{data:r,error:i}=await e.$fetch(`/sign-up/verify-code`,{method:`POST`,body:{email:t,code:n}});if(i||!r)throw q(i,`Could not check the code`);return r.ticket},signUp:async n=>{let{data:r,error:i}=await e.$fetch(`/sign-up/create`,{method:`POST`,body:n});if(i||!r)throw q(i,`Could not create your account`);return await t(),r.user},signInWithPasskey:async n=>{let r=await e.$fetch(`/passkey/generate-authenticate-options`,{method:`GET`,...n&&{query:{rpId:n}}});if(r.error||!r.data)throw q(r.error,`Sign-in failed`);let{clientExtensionResults:i,...a}=await j({optionsJSON:r.data}).catch(e=>{throw new K(`Auth cancelled`,400,e instanceof f?e.code:`AUTH_CANCELLED`)}),o=await e.$fetch(`/passkey/verify-authentication`,{method:`POST`,body:{response:a}});if(o.error||!o.data)throw q(o.error,`Sign-in failed`);return await t(),o.data.user},sendTwoFactorCode:async()=>{let{error:t}=await e.twoFactor.sendOtp();if(t)throw q(t,`Could not send the code`)},verifyTwoFactor:async({method:n,code:r,trustDevice:i=!1})=>{let{data:a,error:o}=await(n===`totp`?e.twoFactor.verifyTotp:n===`otp`?e.twoFactor.verifyOtp:e.twoFactor.verifyBackupCode)({code:r,trustDevice:i});if(o||!a)throw q(o,`The code did not work`);return await t(),a.user}}},Gh=e=>({read:async()=>{let{data:t,error:n}=await e.$fetch(`/policy/sign-in`);if(n||!t)throw q(n,`Could not read the sign-in policy`);return t},save:async t=>{let{data:n,error:r}=await e.$fetch(`/policy/sign-in`,{method:`POST`,body:t});if(r||!n)throw q(r,`Could not save the sign-in policy`);return n}}),Kh=e=>new Date(e).toISOString(),qh=({startedAt:e,expiresAt:t,endedAt:n,...r})=>({...r,startedAt:Kh(e),expiresAt:Kh(t),...n&&{endedAt:Kh(n)}}),Jh=e=>({start:async t=>{let{data:n,error:r}=await e.$fetch(`/staff/sign-in`,{method:`POST`,body:t});if(r||!n?.url)throw q(r,`Could not start the staff sign-in`);return n.url},current:async()=>{let{data:t,error:n}=await e.$fetch(`/staff/session`);if(n||!t)throw q(n,`Could not read the session`);return t.staff?qh(t.staff):void 0},stop:async()=>{let{error:t}=await e.$fetch(`/staff/stop`,{method:`POST`,body:{}});if(t)throw q(t,`Could not end the staff session`)},log:async()=>{let{data:t,error:n}=await e.$fetch(`/staff/sign-ins`);if(n||!t)throw q(n,`Could not read the staff sign-ins`);return t.signIns.map(qh)}}),Yh=e=>{let t=e.split(`.`)[1];if(!t)throw Error(`Not a JWT`);let n=JSON.parse(atob(t.replace(/-/g,`+`).replace(/_/g,`/`)));if(typeof n.exp!=`number`)throw Error(`The token has no expiry`);return n.exp*1e3},Xh=(e={})=>{let t=e.origin??globalThis.location?.origin??`http://localhost`,n=e.basePath??`/api/auth`,r=e.refreshMarginMs??6e4,i=e.fetch??((e,t)=>fetch(e,t)),a=jh(t,n,i),o=Jh(a),s,c,l,u=()=>{s=void 0,clearTimeout(l)},d=async()=>{u();let{data:t}=await a.$fetch(`/token`);if(t?.token)return s={token:t.token,expiresAt:Yh(t.token)},l=setTimeout(()=>void f({refresh:!0}).then(t=>t||e.onSignedOut?.()),Math.max(1e3,s.expiresAt-Date.now()-r)),s.token},f=async({refresh:e=!1}={})=>!e&&s&&s.expiresAt-Date.now()>r?s.token:(c??=d().finally(()=>{c=void 0}),c);return{token:f,status:async()=>{let e=await i(`${t}${n}/status`);if(e.status===404)throw new K(`This server has no sign-in. Is the API URL right?`,404);if(!e.ok)throw new K(`Could not read the sign-in status`,e.status);let r=await e.json();return{needsAdmin:!!r.needsAdmin,...r.needsAdmin&&r.firstAdminUrl&&{firstAdminUrl:r.firstAdminUrl},signInMethods:r.signInMethods??[`password`],...r.signInFirst===`emailCode`&&{signInFirst:`emailCode`},passwordReset:!!r.passwordReset,...r.changeEmail&&{changeEmail:!0},...r.accountDeletion&&{accountDeletion:!0},...r.signUp&&{signUp:!0},...r.signUp&&r.signUpFields&&{signUpFields:r.signUpFields},socialProviders:r.socialProviders??[],...r.platformProviders&&{platformProviders:r.platformProviders},...r.deviceLinks&&{deviceLinks:!0},samlProviders:r.samlProviders??[],...r.staffSignIn&&{staffSignIn:r.staffSignIn},...r.passkeyDomains&&{passkeyDomains:r.passkeyDomains},...r.organizations&&{organizations:r.organizations},...r.anonymous&&{anonymous:!0},...r.mcp&&{mcp:{url:r.mcp.url}},...r.personalAccessTokens&&{personalAccessTokens:!0},...r.personalMail&&r.personalMail.length>0&&{personalMail:r.personalMail},...r.plugins&&r.plugins.length>0&&{plugins:r.plugins},...zr(r.locale)&&{locale:r.locale}}},session:async()=>{let{data:e,error:t}=await a.getSession();if(t&&t.status!==401)throw q(t,`Could not read your session`);return e?.user},...Wh(a,()=>f({refresh:!0})),signInSocial:async(e,t)=>{let{data:n,error:r}=await a.signIn.social({provider:e,callbackURL:t,errorCallbackURL:t,disableRedirect:!0});if(r||!n?.url)throw q(r,`Sign-in failed`);return n.url},signInSaml:async(e,t)=>{let{data:n,error:r}=await a.$fetch(`/sign-in/sso`,{method:`POST`,body:{providerId:e,callbackURL:t,errorCallbackURL:t}});if(r||!n?.url)throw q(r,`Sign-in failed`);return n.url},signOut:async()=>{u(),await a.signOut()},deleteAccount:async e=>{let{error:t}=await a.deleteUser(e?{password:e}:{});if(t)throw q(t,`Could not delete your account`);u()},requestPasswordReset:async(e,t)=>{let{error:n}=await a.requestPasswordReset({email:e,redirectTo:t});if(n)throw q(n,`Could not send the reset link`)},resetPassword:async(e,t)=>{let{error:n}=await a.resetPassword({token:e,newPassword:t});if(n)throw q(n,`Could not set the password`)},account:{...Eh(a),...Th(a),...Oh(a),...Dh(a)},connect:Ah(a),organizations:Ih(a,()=>f({refresh:!0})),roles:Lh(a,()=>f({refresh:!0})),signInPolicy:Gh(a),users:Uh(a),staff:{...o,stop:async()=>{u(),await o.stop()}}}},Zh=e=>Math.min(3e4,1e3*2**e),Qh=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),$h=`http://same-origin.invalid`,eg=(e,t)=>{let n=new URL(e,$h),r=new URL(t,`${n.href}/`);if(r.origin!==n.origin)throw Error(`${t} is not on the assistant backend's origin`);return n.origin===$h?`${r.pathname}${r.search}`:r.href},tg=e=>{let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>fetch(e,t)),r=e.retryDelayMs??Zh,i=async(r,i)=>{let a=await e.token(),o=await n(`${t}${r}`,{method:i.method,headers:{...i.body===void 0?{accept:`text/event-stream`}:{"content-type":`application/json`},...a&&{authorization:`Bearer ${a}`}},body:i.body===void 0?void 0:JSON.stringify(i.body),signal:i.signal});if(!o.ok)throw await Bd(o);return o},a=async(e,t,n)=>{let r=await i(`/events`,{method:`GET`,signal:e});if(!r.body)throw Error(`The assistant backend answered the event stream without a body`);n(),await Lr(r.body,e=>t(JSON.parse(e)),e)};return{connect:(e,t)=>{let n=new AbortController,{signal:i}=n;return(async()=>{let n=0;for(;!i.aborted;){t?.({state:`connecting`});let o=await a(i,e,()=>{n=0,t?.({state:`open`})}).then(()=>void 0,e=>e??Error(`The assistant stream failed`));if(i.aborted)return;t?.({state:`retrying`,...o!==void 0&&{error:o}}),await Qh(r(n++),i)}})(),()=>n.abort()},send:async(e,t)=>{await i(`/messages`,{method:`POST`,body:{text:e,...t&&{page:t}}})},act:async(e,t)=>{await i(`/actions`,{method:`POST`,body:{partId:e,actionId:t}})},fetch:async(r,i={})=>{let a=eg(t,r),o=await e.token(),s=new Headers(i.headers);o&&s.set(`authorization`,`Bearer ${o}`);let c=await n(a,{...i,headers:s});if(!c.ok)throw await Bd(c);return c}}},ng=e=>e.Capacitor?.isNativePlatform()?e.Capacitor:void 0,rg=[101,204,205,304],ig=/%2f|%5c/i,ag=e=>Object.hasOwn(ni,e),og=(e,t)=>e.origin===t&&!e.username&&!e.password&&e.pathname.startsWith(`/api/auth/`)&&!ig.test(e.pathname),sg=({status:e,headers:t,data:n})=>rg.includes(e)?null:Object.entries(t).some(([e,t])=>e.toLowerCase()===`content-type`&&t.startsWith(`application/json`))?JSON.stringify(n):typeof n==`string`?n:JSON.stringify(n),cg=(e,t)=>{let n=e.getPlatform();if(!ag(n))throw Error(`Signing in through native HTTP is for iOS and Android, not ${n}`);return async(n,r)=>{let i=new Request(n,r),a=new URL(i.url);if(!og(a,t))throw Error(`Native sign-in requests go to ${t}${ei}/ only, not ${i.url}`);let o=i.method!==`GET`&&i.method!==`HEAD`,s=await e.nativePromise(`ProtobaseAuth`,`request`,{url:a.href,method:i.method,headers:Object.fromEntries(i.headers),...o&&{data:await i.text()}}),c=Object.entries(s.headers).filter(([e])=>e.toLowerCase()!==`set-cookie`);return new Response(sg(s),{status:s.status,headers:c})}},lg=e=>e?.isPluginAvailable(`ProtobaseAuth`)?e:void 0,ug,dg,fg=({dsn:e,environment:t})=>(ug??=s(()=>import(`./lib-sentry-browser-BoddUTMM.js`).then(e=>e.t).then(n=>{n.init({dsn:e,...t&&{environment:t},integrations:e=>[...e.filter(e=>e.name!==`BrowserSession`),n.thirdPartyErrorFilterIntegration({filterKeys:[gr],behaviour:`drop-error-if-exclusively-contains-third-party-frames`})],beforeSend:e=>hr(e)}),dg=(e,t)=>n.captureException(e,t?{contexts:{react:{componentStack:t}}}:void 0)}),__vite__mapDeps([0,1,2,3,4])),ug),pg=(e,t)=>dg?.(e,t??void 0),mg=e=>dg?.(e),hg=class extends Error{reason;constructor(e){super(`The push service gave the app no push token: ${e}`),this.reason=e,this.name=`PushRegistrationError`}},gg=class extends Error{service;constructor(e,t){super(`The push service gave the app no push token within ${t} ms`),this.service=e}},_g=class extends Error{constructor(){super(`Push is off, but this device could not store that the user turned it off`)}},vg=e=>e instanceof hg?{kind:`registration`,reason:e.reason}:e instanceof gg?{kind:`no-token`,service:e.service}:e instanceof _g?{kind:`off-not-stored`}:e instanceof Id?{kind:`refused`,reason:e.message}:{kind:`other`,reason:e instanceof Error?e.message:String(e)},yg=`PushNotifications`,bg=(e,t)=>Promise.race([t,new Promise(t=>setTimeout(t,e))]),xg=class extends Error{},Sg=(e,t)=>e instanceof Id&&e.status===409&&e.slug===t,Cg=({bridge:e,device:t,records:n,choices:r,permissionAsked:i,devices:a,user:o,userAgent:s,waitMs:c=3e3,tokenMs:l=15e3,report:u})=>{let d=(t,n={})=>e.nativePromise(yg,t,n),f=async()=>(await d(`checkPermissions`)).receive,p=()=>new Promise((t,n)=>{let r=[],i=e=>{clearTimeout(a);for(let e of r)e.remove();r=[],e()},a=setTimeout(()=>i(()=>n(new gg(e.getPlatform()===`ios`?`apns`:`fcm`,l))),l);r=[e.addListener(yg,`registration`,e=>i(()=>t(e.value))),e.addListener(yg,`registrationError`,e=>i(()=>n(new hg(e.error))))],d(`register`).catch(e=>i(()=>n(e)))}),m=async()=>{await n.clear(),await d(`removeAllDeliveredNotifications`),await d(`unregister`)},h=async e=>{u(e),await m()},g=async e=>{let n=()=>o()?.id===e.id&&o()?.own===!0,r=await p();if(!n())throw new xg;let i=await a.register({...await t(r),userAgent:s,userId:e.id});if(!n())throw new xg;return{device:i,token:r}},_=async()=>{let e=await f();if(e===`denied`)return`blocked`;let[t,r]=[o(),await n.read()];return t&&e===`granted`&&r?.userId===t.id?`on`:`off`},v=async()=>{let e=o();if(!e?.own)return _();let t=await f();if((t===`prompt`||t===`prompt-with-rationale`)&&(t=(await d(`requestPermissions`)).receive),t!==`granted`)return _();r.set(e.id,`on`);let i=async()=>{let{device:t,token:r}=await g(e);await n.write({userId:e.id,endpoint:r,deviceId:t.id})};try{await i()}catch(e){if(e instanceof hg)throw await h(e),e;if(await m(),e instanceof xg)return`off`;if(!Sg(e,`device-held`))throw e;try{await i()}catch(e){if(e instanceof hg)throw await h(e),e;if(await m(),e instanceof xg)return`off`;throw e}}return`on`},y=async({chosen:e=!1}={})=>{let t=o(),i=!e||!t?.own||r.set(t.id,`off`);if(await b(await n.read()),!i)throw new _g},b=async e=>{await n.clear(),await bg(c,Promise.allSettled([d(`removeAllDeliveredNotifications`),d(`unregister`),e?.deviceId?a.remove(e.deviceId):Promise.resolve()]))},x=async()=>{await n.clear(),await bg(c,Promise.allSettled([d(`removeAllDeliveredNotifications`),d(`unregister`)]))},S=e=>{let t=r.of(e);return t===void 0?i:t===`on`};return{state:_,turnOn:v,turnOff:y,forget:x,adopt:async e=>{let t=await n.read();if(t&&t.userId!==e.id)return m();if(e.own){if(t&&r.of(e.id)===`off`)return b(t);if(t||S(e.id)){if(await f()!==`granted`)return t&&m();try{let{device:r,token:i}=await g(e);await n.write({userId:e.id,endpoint:i,deviceId:r.id}),t?.deviceId&&t.deviceId!==r.id&&await a.remove(t.deviceId)}catch(e){if(e instanceof xg)return;if(e instanceof hg)return h(e);if(!Sg(e,`device-held`)&&!Sg(e,`other-user`))throw e;await m()}}}}}},wg=`ProtobasePush`,Tg=e=>{if(!e.isPluginAvailable(`PushNotifications`))return;let t=e.getPlatform();if(t===`android`)return async e=>({kind:`fcm`,token:e});if(t===`ios`&&e.isPluginAvailable(`ProtobasePush`))return async t=>{let{appId:n,environment:r}=await e.nativePromise(wg,`apns`,{});return{kind:`apns`,token:t.toLowerCase(),appId:n,environment:r}}},Eg=e=>e.replace(/[\u0000-\u001f\u007f]/g,``).slice(0,512),Dg=(e=window)=>{let{navigator:t}=e;return{supported:`serviceWorker`in t&&`PushManager`in e&&`Notification`in e&&`userActivation`in t,permission:()=>e.Notification.permission,requestPermission:()=>e.Notification.requestPermission(),activated:()=>t.userActivation.isActive,existingRegistration:()=>t.serviceWorker.getRegistration(`/`),registration:async()=>(await t.serviceWorker.getRegistration(`/`)||await t.serviceWorker.register(`/${ii}`),t.serviceWorker.ready),clearBadge:async()=>{`clearAppBadge`in t&&await t.clearAppBadge()},userAgent:Eg(t.userAgent)}},Og=/\bAndroid (\d+)/,kg=(e,t)=>{if(e===`ios`)return!0;let n=Og.exec(t)?.[1];return e===`android`&&n!==void 0&&Number(n)>=13},Ag=`protobase:push-choices`,jg=e=>{let t=new Map,n=()=>{try{let t=JSON.parse(e().getItem(Ag)??`{}`);return typeof t==`object`&&t&&!Array.isArray(t)?t:void 0}catch{return}};return{of:e=>{let r=t.get(e);if(r)return r;let i=n();if(!i)return`unknown`;let a=Object.hasOwn(i,e)?i[e]:void 0;return a===`on`||a===`off`?a:void 0},set:(r,i)=>{t.set(r,i);try{return e().setItem(Ag,JSON.stringify({...n(),[r]:i})),!0}catch{return!1}}}},Mg=(e=indexedDB)=>{let t=(t,n)=>new Promise((r,i)=>{let a=e.open(ri.database,1);a.onupgradeneeded=()=>a.result.createObjectStore(ri.store),a.onerror=()=>i(a.error),a.onsuccess=()=>{let e=a.result,o=n(e.transaction(ri.store,t).objectStore(ri.store));o.onsuccess=()=>(e.close(),r(o.result)),o.onerror=()=>(e.close(),i(o.error))}});return{read:()=>t(`readonly`,e=>e.get(ri.key)),write:async e=>void await t(`readwrite`,t=>t.put(e,ri.key)),clear:async()=>void await t(`readwrite`,e=>e.delete(ri.key))}},Ng=e=>Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0)),Pg=(e,t)=>Promise.race([t,new Promise(t=>setTimeout(t,e))]),Fg=class extends Error{},Ig=(e,t)=>e instanceof Id&&e.status===409&&e.slug===t,Lg=({browser:e,records:t,devices:n,meta:r,user:i,waitMs:a=3e3})=>{let o,s=()=>o??=r(),c=async n=>{await t.clear();for(let e of n?await n.getNotifications():[])e.close();await e.clearBadge()},l=async e=>{let t=await e?.pushManager.getSubscription();t&&await t.unsubscribe()},u=async e=>{await c(e),await l(e)},d=async(r,i)=>{let a=r.toJSON().keys??{},o=await n.register({kind:`web`,endpoint:r.endpoint,keys:{p256dh:a.p256dh??``,auth:a.auth??``},userAgent:e.userAgent,userId:i.userId});await t.write({...i,deviceId:o.id})},f=async()=>{if(!e.supported||!(await s()).webPushKey)return`unsupported`;if(e.permission()===`denied`)return`blocked`;let n=i(),r=await e.existingRegistration(),[a,o]=await Promise.all([r?.pushManager.getSubscription(),t.read()]);return n&&a&&o?.userId===n.id&&o.endpoint===a.endpoint?`on`:`off`},p=async()=>{let n=i();if(!e.supported||!e.activated()||!n?.own||e.permission()==="default"&&await e.requestPermission()!==`granted`||e.permission()!==`granted`)return f();let{appName:r,webPushKey:a}=await s();if(!a)return`unsupported`;let o=()=>i()?.id===n.id&&i()?.own===!0,c=await e.registration();if(!o())return f();let[l,p]=await Promise.all([c.pushManager.getSubscription(),t.read()]);l&&(p?.userId!==n.id||p.endpoint!==l.endpoint)&&await u(c);let h=async()=>{if(!o())throw new Fg;let e=await c.pushManager.getSubscription()??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Ng(a)}),i={userId:n.id,endpoint:e.endpoint,appName:r};if(await t.write(i),!o())throw new Fg;await d(e,i)};try{await h()}catch(e){if(Ig(e,`device-held`))return await u(c),m(c,h);if(await u(c),e instanceof Fg||Ig(e,`other-user`))return`off`;throw e}return`on`},m=async(e,t)=>{try{await t()}catch(t){if(await u(e),t instanceof Fg||Ig(t,`device-held`)||Ig(t,`other-user`))return`off`;throw t}return`on`};return{state:f,turnOn:p,turnOff:async()=>{if(!e.supported)return;let r=await e.existingRegistration(),i=await t.read();await c(r),await Pg(a,Promise.allSettled([l(r),i?.deviceId?n.remove(i.deviceId):Promise.resolve()]))},forget:async()=>{if(!e.supported)return;let t=await e.existingRegistration();await c(t),await Pg(a,Promise.allSettled([l(t)]))},adopt:async n=>{if(!e.supported)return;let r=await e.existingRegistration(),[i,a]=await Promise.all([r?.pushManager.getSubscription(),t.read()]);if(!r)return a?t.clear():void 0;if(!a||a.userId!==n.id)return i||a?u(r):void 0;if(!n.own)return;if(!i||e.permission()!==`granted`||a.endpoint!==i.endpoint&&!a.renew)return u(r);let o={userId:a.userId,endpoint:i.endpoint,appName:a.appName};await t.write(o);try{await d(i,o)}catch(e){if(!Ig(e,`device-held`)&&!Ig(e,`other-user`))throw e;await u(r)}}}},Rg={state:async()=>`unsupported`,turnOn:async()=>`unsupported`,turnOff:async()=>{},forget:async()=>{},adopt:async()=>{}},zg=({nativeBridge:e,...t})=>{if(typeof window>`u`)return Rg;if(e){let n=Tg(e);if(!n)return Rg;let{devices:r,user:i,waitMs:a}=t;return Cg({bridge:e,device:n,records:Mg(),choices:jg(()=>localStorage),permissionAsked:kg(e.getPlatform(),navigator.userAgent),devices:r,user:i,userAgent:Eg(navigator.userAgent),report:mg,...a!==void 0&&{waitMs:a}})}let n=Dg();return n.supported?Lg({...t,browser:n,records:Mg()}):Rg},Bg=e=>e===`http:`||e===`https:`,Vg=(e,t=(e,t)=>fetch(e,t))=>{if(Bg(e.protocol))return;let n=`${e.protocol}//${e.host}`;return{origin:`https://${e.host}`,fetch:(e,r)=>{let i=new URL(e instanceof Request?e.url:e),a=`${n}${i.pathname}${i.search}`;return e instanceof Request?t(new Request(a,e),r):t(a,r)}}},Hg=e=>e!==void 0&&URL.canParse(e)&&Bg(new URL(e).protocol),Ug=async(e,t)=>{let n=!1;try{n=!!await e?.()}finally{n||await t()}},Wg=`sign-in`,Gg=`error`,Kg=e=>{let t=new URL(e).searchParams;if(!t.has(Gg))return t.get(`sign-in`)||void 0},qg=e=>new URL(e).searchParams.get(Gg)||void 0,Jg=[`totp`,`otp`],Yg=e=>{let t=new URL(e).searchParams.get(ti);if(t!==null)return t.split(`,`).filter(e=>Jg.includes(e))},Xg=e=>{let t=new URL(e);for(let e of[Wg,Gg,ti])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},Zg={github:`GitHub`,gitlab:`GitLab`,google:`Google`,microsoft:`Microsoft`,apple:`Apple`},Qg=(e,t=[])=>t.find(t=>t.provider===e)?.name??Zg[e]??e.charAt(0).toUpperCase()+e.slice(1),$g=e=>e.filter(({linkOnly:e})=>!e),e_=e=>e.kind===`signed-in`&&!e.staff,t_=(e,t)=>e.kind===`loading`||e.kind===`error`?`leave`:e.kind!==`signed-in`||!e_(e)?`clear`:t?{save:{user:e.user,status:t}}:`leave`,n_=(0,M.createContext)(null),r_=[`password`],i_=[],a_=[],o_=[],s_=[],c_=[],J=()=>{let e=(0,M.useContext)(n_);if(!e)throw Error(`useAuth must be used inside AuthProvider`);return e},l_=()=>(0,M.useContext)(n_),u_=({session:e,origin:t,nativeBridge:n,afterSignIn:r,children:i})=>{let a=oa(),[o]=(0,M.useState)(()=>a?.session()),[s,c]=(0,M.useState)(()=>o?{kind:`signed-in`,user:o.user}:{kind:`loading`}),[l,u]=(0,M.useState)(o?.status),d=l?.signInMethods??r_,f=l?.signInFirst??`password`,p=lg(n),m=!!l?.passwordReset&&!p,h=!!l?.changeEmail,g=!!l?.accountDeletion,_=l?.mcp,v=!!l?.personalAccessTokens,y=!!l?.signUp,b=l?.signUpFields?.includes(`name`)??!0,x=l?.passkeyDomains??i_,S=l?.socialProviders??i_,C=l?.platformProviders??s_,w=l?.personalMail??a_,T=l?.samlProviders??o_,E=l?.staffSignIn,D=!!l?.deviceLinks,O=l?.organizations,k=!!l?.anonymous,A=l?.plugins??c_,ee=l?.locale,te=(0,M.useMemo)(()=>({...l?.appName&&{appName:l.appName},...l?.appIcon&&{appIcon:l.appIcon},runsOnNote:!!l?.runsOnNote}),[l]),ne=(0,M.useCallback)(()=>k?{kind:`visitor`}:{kind:`signed-out`},[k]),re=(0,M.useRef)(async()=>{}),ie=(0,M.useRef)(0),j=(0,M.useCallback)(()=>{ie.current+=1,re.current(),c(e=>e.kind===`signed-in`?{kind:`signed-out`}:e)},[]),ae=(0,M.useRef)(j);ae.current=j;let N=(0,M.useMemo)(()=>{if(e)return e;let n=Hg(t)?void 0:Vg(window.location),r=n?.origin??t;return Xh({...r&&{origin:r},...n&&{fetch:n.fetch},...p&&{fetch:cg(p,r??window.location.origin)},onSignedOut:()=>ae.current()})},[e,t,p]),oe=(0,M.useRef)(void 0);oe.current=s.kind===`signed-in`?{id:s.user.id,own:!s.staff}:void 0;let se=(0,M.useMemo)(()=>{let e=Pf({baseUrl:`${t??globalThis.location?.origin??``}/api/v1`,token:({refresh:e})=>N.token({refresh:e})}),r=async()=>{let t=await e.meta();if(t.status!==`modified`)throw Error(`The app answered /meta without its content`);return{appName:t.meta.appName,...t.meta.notifications?.webPushKey&&{webPushKey:t.meta.notifications.webPushKey}}};return zg({...n&&{nativeBridge:n},devices:e.devices,meta:r,user:()=>oe.current})},[N,t,n]);re.current=se.forget;let ce=(0,M.useRef)(r);ce.current=r;let le=(0,M.useCallback)(async(e,t=ie.current)=>{let[{missing:n},r]=await Promise.all([N.account.signInMethods(),N.staff.current()]);ie.current===t&&(c(n.length>0?{kind:`setup-required`,user:e,missing:n}:{kind:`signed-in`,user:e,...r&&{staff:r}}),n.length===0&&se.adopt({id:e.id,own:!r}))},[N,se]),ue=(0,M.useCallback)(async e=>{let t=ie.current;await Ug(ce.current,()=>le(e,t))},[le]),de=(0,M.useCallback)(async e=>e.kind===`two-factor`?c({kind:`two-factor`,methods:e.methods}):ue(e.user),[ue]),P=(0,M.useCallback)(()=>{let e=ie.current;c(e=>e.kind===`signed-in`?e:{kind:`loading`}),N.status().then(async t=>{if(u(t),ie.current!==e)return;if(t.needsAdmin)return c({kind:`needs-admin`,...t.firstAdminUrl&&{firstAdminUrl:t.firstAdminUrl}});let n=await N.session();if(ie.current!==e)return;if(n)return le(n,e);let r=Yg(window.location.href);c(r?{kind:`two-factor`,methods:r}:{kind:t.anonymous?`visitor`:`signed-out`})}).catch(t=>{ie.current===e&&c(e=>e.kind===`signed-in`?e:{kind:`error`,...t instanceof Error&&{message:t.message}})})},[N,le]);(0,M.useEffect)(P,[P]),(0,M.useEffect)(()=>{if(!a)return;let e=t_(s,l);e===`clear`?a.clear():e!==`leave`&&a.saveSession(e.save)},[a,s,l]);let fe=(0,M.useMemo)(()=>({state:s,session:N,signInMethods:d,signInFirst:f,passwordReset:m,changeEmail:h,accountDeletion:g,mcp:_,personalAccessTokens:v,canSignUp:y,signUpAsksName:b,passkeyDomains:x,socialProviders:S,signInProviders:[...S.map(e=>({id:e,name:Qg(e,C),...C.some(t=>t.provider===e&&t.button===!1)&&{linkOnly:!0}})),...T],platformProviders:C,deviceLinks:D,staffSignIn:E,...O&&{organizations:O},markSignedOut:j,recheck:P,beforeSignIn:A,locale:ee,identity:te,adoptSession:async()=>{let e=await N.session();return e?(await ue(e),!0):!1},...k&&{browse:()=>{c(e=>e.kind===`signed-out`?{kind:`visitor`}:e)}},signIn:async(e,t)=>de(await N.signIn(e,t)),sendSignInCode:e=>N.sendSignInCode(e),signInWithCode:async(e,t)=>de(await N.signInWithCode(e,t)),sendSignUpCode:e=>N.sendSignUpCode(e),verifySignUpCode:(e,t)=>N.verifySignUpCode(e,t),signUp:async e=>ue(await N.signUp(e)),signInWithPasskey:async e=>ue(await N.signInWithPasskey(e)),verifyTwoFactor:async e=>ue(await N.verifyTwoFactor(e)),signInSocial:async e=>{let t=new URL(Xg(window.location.href),window.location.href).href,n=T.some(t=>t.id===e);window.location.assign(await(n?N.signInSaml(e,t):N.signInSocial(e,t)))},linkProvider:async e=>{window.location.assign(await N.account.linkProvider(e,new URL(Xg(window.location.href),window.location.href).href))},personalMail:w,linkPersonalMail:async e=>{window.location.assign(await N.account.linkPersonalMail(e,new URL(Xg(window.location.href),window.location.href).href))},connectAccount:async e=>{window.location.assign(await N.account.connectAccount(e,new URL(Xg(window.location.href),window.location.href).href))},stopStaffSession:async()=>{ie.current+=1,await se.forget(),await N.staff.stop(),c(ne())},signOut:async()=>{ie.current+=1,await se.turnOff(),await N.signOut(),c(ne())},deleteAccount:async e=>{await N.deleteAccount(e),ie.current+=1,await se.forget(),c(ne())},push:se}),[se,s,N,d,f,m,h,g,_,v,y,b,x,S,C,D,w,T,E,O,k,A,ee,te,ne,j,P,de,ue]);return(0,L.jsx)(n_.Provider,{value:fe,children:i})},d_=e=>{let t=!1,n=[];return{tap:r=>t?e(r):void n.push(r),settle:r=>{if(t=r,r)for(let t of n.splice(0))e(t)}}},f_=e=>typeof e==`object`&&!!e&&!Array.isArray(e),p_=(e,{apiOrigin:t,userId:n,basePath:r})=>{if(!f_(e)||n===void 0||e.user!==n)return;let i=mi(e.url);if(i===void 0)return;let a=new URL(i);if(a.origin!==t)return{kind:`browser`,url:i};let o=`${a.pathname}${a.search}${a.hash}`;if(o.startsWith(`//`)||new URL(o,t).origin!==t)return;if(r===``)return{kind:`in-app`,path:o};if(a.pathname!==r&&!a.pathname.startsWith(`${r}/`))return;let s=o.slice(r.length);return{kind:`in-app`,path:s.startsWith(`/`)?s:`/${s}`}},m_=`protobase.push.tap`,h_=({storage:e,reloading:t})=>({receive:(n,r)=>{if(!t())return r(n);e.setItem(m_,JSON.stringify(n??null))},resume:t=>{let n=e.getItem(m_);if(n===null)return;e.removeItem(m_);let r;try{r=JSON.parse(n)}catch(e){if(e instanceof SyntaxError)return;throw e}t(r)}}),g_=`ProtobaseExternal`,__=async(e,{bridge:t,navigate:n})=>{if(e.kind===`in-app`)return n(e.path);t.isPluginAvailable(g_)&&await t.nativePromise(g_,`open`,{url:e.url})},v_=e=>typeof e==`object`&&e?e.notification?.data:void 0,y_=({nativeBridge:e,apiOrigin:t})=>{let{state:n}=J(),{navigate:r,basePath:i}=Hu(),a=n.kind===`signed-in`?n.user.id:void 0,o=(0,M.useRef)(()=>{});o.current=n=>{let o=p_(n,{apiOrigin:t,userId:a,basePath:i});o&&__(o,{bridge:e,navigate:r})};let[s]=(0,M.useState)(()=>d_(e=>o.current(e))),[c]=(0,M.useState)(()=>{let e=le(()=>window.sessionStorage,void 0);return e&&h_({storage:e,reloading:()=>no(e)})});return(0,M.useEffect)(()=>s.settle(n.kind!==`loading`),[s,n.kind,a]),(0,M.useEffect)(()=>{if(!e.isPluginAvailable(`PushNotifications`))return;let t=e.addListener(yg,`pushNotificationActionPerformed`,e=>c?c.receive(v_(e),s.tap):s.tap(v_(e)));return c?.resume(s.tap),()=>void t.remove()},[e,s,c]),null},Y=F(`account`),b_=`/-/account`,x_=`/-/sign-in-policy`,S_=e=>{if(e===`/-/account`)return{};if(!e.startsWith(`/-/account/`))return;let t=e.slice(11);if(!(t===``||t.includes(`/`)))try{return{tab:decodeURIComponent(t)}}catch(e){if(e instanceof URIError)return;throw e}},C_=e=>e?`${b_}/${encodeURIComponent(e)}`:b_,w_=(e,t,n)=>[{id:`account`,label:Y(`account`),icon:Jl,href:`${e}${b_}`,active:S_(t)!==void 0},...n?[{id:`sign-in-policy`,label:Y(`signInPolicy`),icon:bl,href:`${e}${x_}`,active:t===x_}]:[]],T_=()=>{let e=0;return{refetchOnWindowFocus:()=>e>0?!1:`always`,paused:()=>e>0,pause:()=>{e+=1;let t=!1;return()=>{t||(t=!0,--e)}}}},E_=(0,M.createContext)(null),D_=e=>{let t=(0,M.useContext)(E_);(0,M.useEffect)(()=>e&&t?t.pause():void 0,[e,t])},O_=e=>{let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),window.addEventListener(`focus`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t),window.removeEventListener(`focus`,t)}},k_=(0,M.createContext)(0),A_=(e,t)=>e.data!==void 0&&e.dataUpdatedAt<t,j_=(e,t)=>e.data!==void 0&&!A_(e,t),M_=e=>e.isError||e.failureCount>0,N_=(e,t)=>{let n=e.filter(e=>A_(e.state,t));return n.length===0?`fresh`:n.some(e=>e.state.status===`error`||e.state.fetchFailureCount>0||e.state.fetchStatus===`paused`)?`failed`:n.some(e=>e.state.fetchStatus===`fetching`)?`refreshing`:`stale`},P_=(e,t)=>e.getQueryCache().subscribe(e=>{e.type===`updated`&&e.action.type===`error`&&A_(e.query.state,t)&&e.query.setState({status:`success`,error:null})}),F_=()=>{let e=x().getQueryCache(),t=(0,M.useContext)(k_),n=(0,M.useCallback)(t=>e.subscribe(t),[e]),r=(0,M.useCallback)(()=>N_(e.findAll({type:`active`}),t),[e,t]);return(0,M.useSyncExternalStore)(n,r,r)},I_=(0,M.createContext)(null),L_=(0,M.createContext)(null),R_=(0,M.createContext)(null),X=()=>{let e=(0,M.useContext)(I_);if(!e)throw Error(`useClient must be used inside ApiProvider`);return e},z_=e=>{let t=X();return(0,M.useContext)(R_)?.(e)??t},B_=()=>{let e=X(),t=(0,M.useContext)(R_);return(0,M.useCallback)(n=>t?.(n)??e,[e,t])},V_=()=>{let e=(0,M.useContext)(L_);if(!e)throw Error(`useSourceClients must be used inside ApiProvider`);return e},H_=({client:e,resourceClient:t,children:n})=>(0,L.jsx)(I_.Provider,{value:e,children:(0,L.jsx)(R_.Provider,{value:t,children:n})}),U_=({baseUrl:e,client:t,sources:n,fetch:r,queryClient:i,token:a,onUnauthenticated:o,persistence:s,children:c})=>{let[l]=(0,M.useState)(T_),[{queryClient:u,startedAt:d}]=(0,M.useState)(()=>{let e=i??new _({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:l.refetchOnWindowFocus}}});return s?.restore(e),{queryClient:e,startedAt:Date.now()}});(0,M.useEffect)(()=>s?.subscribe(u),[s,u]),(0,M.useEffect)(()=>s?P_(u,d):void 0,[s,u,d]),(0,M.useEffect)(()=>v.setEventListener(O_),[]);let f=(0,M.useRef)(void 0),p=(0,M.useMemo)(()=>t??Pf({baseUrl:e,fetch:r,token:a,onUnauthenticated:o,onMetaVersion:e=>{let t=f.current;f.current=e,t!==void 0&&t!==e&&(u.getQueryData(I.meta)?.versionChange||u.invalidateQueries({queryKey:I.meta},{cancelRefetch:!1}))}}),[t,e,r,u,a,o]),m=(0,M.useMemo)(()=>{let e=new Map;return t=>{let i=n?.[t.url]??e.get(t.url);if(i)return i;let o,s=Pf({baseUrl:t.url,fetch:r,token:a,onMetaVersion:e=>{let n=o;o=e,n!==void 0&&n!==e&&u.invalidateQueries({queryKey:I.sourceMetas(t.url)},{cancelRefetch:!1})}});return e.set(t.url,s),s}},[n,r,a,u]);return(0,L.jsx)(E,{client:u,children:(0,L.jsx)(I_.Provider,{value:p,children:(0,L.jsx)(L_.Provider,{value:m,children:(0,L.jsx)(E_.Provider,{value:l,children:(0,L.jsx)(k_.Provider,{value:d,children:c})})})})})},W_=(0,M.createContext)(null),G_={create:!0,update:!0,delete:!0,conditional:[]},K_=(e,t)=>e?e.versionChange?e:t.protobaseVersion===e.protobaseVersion?t:{...e,versionChange:{...t.protobaseVersion&&{to:t.protobaseVersion}}}:t,q_=()=>{let e=X(),t=x(),n=(0,M.useContext)(W_),r=(0,M.useContext)(k_),i=O({queryKey:I.meta,staleTime:0,refetchOnWindowFocus:`always`,enabled:e=>!e.state.data?.versionChange,queryFn:async()=>{let n=t.getQueryData(I.meta),i=await e.meta(n?.etag);if(i.status===`unchanged`){if(!n)throw Error(`The server answered 304 to a request without If-None-Match`);return n}let a=t.getQueryState(I.meta);return K_(a&&A_(a,r)?void 0:n,{etag:i.etag,appName:i.meta.appName,...i.meta.protobaseVersion&&{protobaseVersion:i.meta.protobaseVersion},...i.meta.appIcon&&{appIcon:i.meta.appIcon},resources:Object.fromEntries(i.meta.resources.map(e=>[e.name,e])),views:Object.fromEntries(i.meta.views.map(e=>[e.resource,e])),pages:Object.fromEntries((i.meta.pages??[]).map(e=>[e.name,e])),...i.meta.account&&{account:i.meta.account},permissions:i.meta.permissions??{},...i.meta.userMenu&&{userMenu:i.meta.userMenu},...i.meta.signIn&&{signIn:Object.fromEntries(i.meta.signIn.map(e=>[e.resource,e]))},...i.meta.bottomBar&&{bottomBar:i.meta.bottomBar},...i.meta.assistant&&{assistant:i.meta.assistant},...i.meta.runtime&&{runtime:i.meta.runtime},...i.meta.errorReporting&&{errorReporting:i.meta.errorReporting},...i.meta.maps&&{maps:i.meta.maps},...i.meta.notifications?.bell&&{bell:!0},...i.meta.status&&{status:!0},...i.meta.calls&&{calls:!0},...i.meta.locale&&{locale:i.meta.locale},...i.meta.texts&&{texts:i.meta.texts},...i.meta.files&&{files:i.meta.files},...i.meta.plugins&&{plugins:i.meta.plugins},...i.meta.sources&&{sources:i.meta.sources.map(e=>({source:e,state:`loading`}))}})}});return(0,M.useMemo)(()=>n&&i.data?{...i,data:n}:i,[n,i])},J_=1e4,Y_=e=>e.map(e=>({data:e.data?.meta,error:e.error})),X_=(e,t)=>{let n=x(),r=ee({queries:e.map(e=>{let r=I.sourceMeta(e.url,e.resources);return{queryKey:r,staleTime:0,refetchOnWindowFocus:`always`,queryFn:async()=>{let i=n.getQueryData(r),a=await t(e).meta(i?.etag,{signal:AbortSignal.timeout(J_)});if(a.status===`unchanged`){if(!i)throw Error(`${e.label} answered 304 to a request without If-None-Match`);return i}return{etag:a.etag,meta:xh(a.meta,e)}}}}),combine:Y_});return(0,M.useMemo)(()=>e.map((e,t)=>{let{data:n,error:i}=r[t];return n?{source:e,state:`ready`,meta:n}:i?{source:e,state:`error`,error:i}:{source:e,state:`loading`}}),[e,r])},Z_=(e,t)=>{if(t.length===0)return e;let n=t.flatMap(e=>e.state===`ready`?[e.meta]:[]),r=t.map(e=>e.state===`error`?{source:e.source,state:`error`,error:e.error}:{source:e.source,state:e.state});return{...e,resources:{...e.resources,...Object.fromEntries(n.flatMap(e=>e.resources.map(e=>[e.name,e])))},views:{...e.views,...Object.fromEntries(n.flatMap(e=>e.views.map(e=>[e.resource,e])))},permissions:{...e.permissions,...Object.assign({},...n.map(e=>e.permissions))},sources:r}},Q_=(e,t)=>e.sources?.find(e=>e.source.resources.includes(t)),$_=e=>{let t=0,n=!1,r=!1,i=()=>queueMicrotask(()=>{!n||r||t>0||(r=!0,e())});return{hold:()=>{t+=1;let e=!1;return()=>{e||(e=!0,--t,i())}},start:()=>{n=!0,i()}}},ev=(0,M.createContext)(void 0),tv=({value:e,children:t})=>(0,L.jsx)(ev.Provider,{value:e,children:t}),nv=()=>{let e=(0,M.useContext)(ev);return(0,M.useEffect)(()=>e?.hold(),[e]),null},rv=({locale:e,children:t})=>(Vi(e)||(0,M.use)(Hi(e)),t),iv=()=>(0,L.jsxs)(`div`,{role:`alert`,className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`The app did not load. Check your connection, then try again.`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded-md border border-border-strong px-3 py-1.5 text-body font-medium hover:bg-muted`,onClick:()=>window.location.reload(),children:`Try again`})]}),av=class extends M.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,L.jsx)(iv,{}):this.props.children}},ov=({locale:e,children:t})=>(0,L.jsx)(av,{children:(0,L.jsx)(M.Suspense,{fallback:(0,L.jsx)(nv,{}),children:(0,L.jsx)(rv,{locale:e,children:t})})}),sv=({locale:e,children:t})=>(0,L.jsx)(ov,{locale:e??ji(),children:(0,L.jsx)(cv,{locale:e,children:t})}),cv=({locale:e,children:t})=>{Ni(e);let n=Ai();return(0,M.useEffect)(()=>{document.documentElement.lang=n},[n]),(0,L.jsx)(M.Fragment,{children:t},n)},lv=(0,M.createContext)(void 0),uv=()=>(0,M.useContext)(lv),dv=e=>typeof e==`object`&&!!e&&!Array.isArray(e),fv=(e,t)=>fh(t,String(e.props.i18nKey),dv(e.props.values)?e.props.values:{}),pv=(e,t)=>e.custom||!Object.values(e.props).some(ph)?e:{...e,props:Object.fromEntries(Object.entries(e.props).map(([e,n])=>[e,ph(n)?fv(n,t):n]))},mv=(e,t)=>{let n=pv(e,t);if(e.custom||e.type!==`Tabs`)return n;let r=n.children.map(e=>typeof e==`string`?e:pv(e,t));return r.some((e,t)=>e!==n.children[t])?{...n,children:r}:n},hv=`app/built-in-views`,gv=F(hv),_v=(e,t)=>Object.hasOwn(Wi(Ai())[hv],e)?gv(e):t,vv=(e,t)=>({...t,...t.label!==void 0&&{label:_v(`${e}.label`,t.label)},...t.help!==void 0&&{help:_v(`${e}.help`,t.help)},...t.valueLabels&&{valueLabels:Object.fromEntries(Object.entries(t.valueLabels).map(([t,n])=>[t,_v(`${e}.values.${t}`,n)]))}}),yv=(e,t)=>{let n=t;return{...t,...n.title!==void 0&&{title:_v(`${e}.title`,n.title)},...n.help!==void 0&&{help:_v(`${e}.help`,n.help)},...n.empty!==void 0&&{empty:_v(`${e}.empty`,n.empty)}}},bv=e=>e.name===`record_history`&&e.table.name===`history`?`changes.history`:`${e.table.schema??`public`}.${e.table.name}`,xv=(e,t)=>({...t,label:_v(`${e}.label`,t.label),...t.confirm!==void 0&&{confirm:_v(`${e}.confirm`,t.confirm)}}),Sv=(e,t)=>{if(!t)return e;let n=bv(t);return{...e,...e.names&&{names:{singular:_v(`${n}.names.singular`,e.names.singular),plural:_v(`${n}.names.plural`,e.names.plural)}},...e.help!==void 0&&{help:_v(`${n}.help`,e.help)},fields:Object.fromEntries(Object.entries(e.fields).map(([e,t])=>[e,vv(`${n}.fields.${e}`,t)])),layout:e.layout.map((e,t)=>yv(`${n}.layout.${t}`,e)),actions:e.actions.map(e=>xv(`${n}.actions.${e.name}`,e))}},Cv=e=>({...e,views:Object.fromEntries(Object.entries(e.views).map(([t,n])=>[t,Sv(n,e.resources[n.resource])]))}),wv=F(`app/meta-gate`),Tv=()=>{let e=(0,M.useContext)(W_);if(!e)throw Error(`useAdminMeta must be used inside MetaGate`);return e},Ev=({title:e,children:t})=>(0,L.jsx)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center p-8`,children:(0,L.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,L.jsx)(`h1`,{className:`text-base font-semibold`,children:e}),(0,L.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]})}),Dv=({meta:e,children:t})=>{let n=X(),r=V_(),i=(0,M.useMemo)(()=>(e.sources??[]).map(e=>e.source),[e.sources]),a=X_(i,r),o=(0,M.useMemo)(()=>Z_(e,a),[e,a]),s=(0,M.useMemo)(()=>{let e=new Map(i.flatMap(e=>e.resources.map(t=>[t,e]))),t=t=>{let n=e.get(t);return n&&r(n)};return{client:If(n,t),resourceClient:t}},[i,n,r]);return(0,L.jsx)(H_,{client:s.client,resourceClient:s.resourceClient,children:(0,L.jsx)(sv,{locale:e.locale,children:(0,L.jsx)(lv.Provider,{value:e.texts,children:(0,L.jsx)(Ov,{meta:o,children:t})})})})},Ov=({meta:e,children:t})=>{let n=(0,M.useMemo)(()=>Cv(e),[e]);return(0,L.jsx)(W_.Provider,{value:n,children:t})},kv=({children:e})=>{let t=q_();return t.isPending?(0,L.jsxs)(`div`,{className:R(`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,Cu),children:[(0,L.jsx)(nv,{}),(0,L.jsx)(fu,{}),` `,wv(`loading`)]}):t.error?(0,L.jsx)(Ev,{title:wv(`cannotReach`),children:Rd(t.error)?t.error.message:wv(`noAnswer`)}):(0,L.jsx)(Dv,{meta:t.data,children:e})},Av=e=>Tv().permissions[e]??G_,jv=(e,t)=>{let n=Rp(e,e=>e.custom?e:t.has(e.type)||(e.type===`Tab`||e.type===`Tabs`)&&e.children.length===0?null:e);if(!n)throw Error(`The account page keeps its Page, which no hidden block replaces`);return n},Mv=F(`auth/errors`),Nv={INVALID_EMAIL_OR_PASSWORD:`wrongEmailOrPassword`,INVALID_PASSWORD:`wrongPassword`,INVALID_OTP:`wrongOrExpiredCode`,OTP_EXPIRED:`codeExpired`,OTP_HAS_EXPIRED:`codeExpired`,TOO_MANY_ATTEMPTS:`tooManyCodes`,INVALID_CODE:`wrongCode`,INVALID_BACKUP_CODE:`wrongBackupCode`,TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:`tooManyCodesSignIn`,ACCOUNT_TEMPORARILY_LOCKED:`locked`,INVALID_TWO_FACTOR_COOKIE:`tooSlow`,AUTH_CANCELLED:`passkeyClosed`,ERROR_CEREMONY_ABORTED:`passkeyClosed`,REGISTRATION_CANCELLED:`passkeyClosed`,PASSKEY_NOT_FOUND:`passkeyNotFound`,AUTHENTICATION_FAILED:`passkeyFailed`,PREVIOUSLY_REGISTERED:`passkeyAdded`,ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED:`passkeyAdded`,PASSWORD_COMPROMISED:`passwordLeaked`,EMAIL_DOMAIN_NOT_ALLOWED:`signUpDomainNotAllowed`,DEVICE_LINK_NOT_FOUND:`deviceLinkNotFound`},Pv=(e,t)=>{let n=t?e[t]:void 0;return n&&Mv(n)},Fv=e=>Pv(Nv,e.code),Iv=e=>Fv(e)??(e.status===429?Mv(`tooManyRequests`):e.message),Lv=()=>Mv(`unreachable`),Rv=e=>Fv(e)??(e.status===429?Mv(`tooManyRequests`):e.status===401?Mv(`wrongEmailOrPassword`):e.message),zv={STAFF_PERMISSION_MISSING:`staffPermissionMissing`,STAFF_SIGN_IN_NOT_STRONG:`staffNotStrong`,STAFF_SIGN_IN_STALE:`staffStale`,STAFF_SIGN_IN_EXPIRED:`staffExpired`,STAFF_SIGN_IN_FAILED:`staffProviderFailed`,STAFF_USER_UNAVAILABLE:`staffUserUnavailable`,STAFF_REASON_REQUIRED:`staffReasonRequired`,SIGN_IN_METHOD_FORBIDDEN:`staffForbidden`,INVALID_CALLBACK_URL:`untrustedCallback`},Bv=e=>Pv(zv,typeof e==`string`?e:e.code)||(typeof e==`string`?Mv(`staffFailed`):e.status===429?Mv(`tooManyRequests`):e.message),Vv={signup_disabled:e=>Mv(`signupDisabled`,{name:e}),account_not_linked:e=>Mv(`notLinked`,{name:e}),account_already_linked_to_different_user:e=>Mv(`linkedToOther`,{name:e}),unable_to_link_account:e=>Mv(`couldNotLink`,{name:e}),access_denied:e=>Mv(`accessDenied`,{name:e}),EMAIL_DOMAIN_NOT_ALLOWED:e=>Mv(`domainNotAllowed`,{name:e})},Hv=(e,t)=>Vv[e]?.(t)??Mv(`providerFailed`,{name:t}),Uv=e=>{let t=e.slice(1),n=t.length===3?[...t].map(e=>e+e).join(``):t,[r,i,a]=[0,2,4].map(e=>{let t=Number.parseInt(n.slice(e,e+2),16)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a},Wv=`#ffffff`,Gv=`#111827`,Kv=e=>{let t=Uv(e);return 1.05/(t+.05)>=(t+.05)/(Uv(Gv)+.05)?Wv:Gv},qv={neutral:`bg-muted text-muted-foreground`,blue:`bg-primary-soft text-primary-text`,green:`bg-success-soft text-success-text`,amber:`bg-warning-soft text-warning-text`,red:`bg-danger-soft text-danger-text`,violet:`bg-violet-soft text-violet-text`},Jv={neutral:`bg-faint-foreground`,blue:`bg-primary`,green:`bg-success`,amber:`bg-warning`,red:`bg-danger`,violet:`bg-violet`},Yv=`polygon(0 0, calc(100% - 0.625rem) 0, 100% 50%, calc(100% - 0.625rem) 100%, 0 100%)`,Xv=({tone:e=`neutral`,dot:t=!0,color:n,shape:r,children:i,className:a})=>(0,L.jsxs)(`span`,{style:{...n!==void 0&&{backgroundColor:n,color:Kv(n)},...r===`arrow`&&{clipPath:Yv}},className:R(r===`arrow`?`inline-flex h-5 items-center gap-1.5 rounded-l-sm pr-4 pl-2 text-xs font-semibold whitespace-nowrap`:`inline-flex h-5 items-center gap-1.5 rounded-full px-2 text-xs font-medium whitespace-nowrap`,n===void 0&&qv[e],a),children:[t&&n===void 0&&r===void 0&&(0,L.jsx)(`span`,{className:R(`size-1.5 rounded-full`,Jv[e])}),i]}),Zv=({title:e,status:t,description:n,children:r})=>(0,L.jsxs)(`section`,{"aria-label":e,className:`rounded-lg border bg-background p-4 sm:p-5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t]}),(0,L.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}),r&&(0,L.jsx)(`div`,{className:`mt-4`,children:r})]}),Qv=({message:e})=>e?(0,L.jsx)(`p`,{role:`alert`,className:`mb-3 text-body font-medium text-danger-text`,children:e}):null,$v=({message:e})=>e?(0,L.jsx)(`p`,{role:`status`,className:`mb-3 font-medium`,children:e}):null,ey=({providers:e,linked:t,onConnect:n,error:r,reconnect:i=!1,notes:a={},title:o=Y(`connectedAccounts`),description:s=Y(`connectedAccountsDescription`),children:c})=>{let[l,u]=(0,M.useState)(),[d,f]=(0,M.useState)(r),p=async e=>{u(e),f(void 0);try{await n(e)}catch(e){if(!(e instanceof K))throw e;f(Iv(e)),u(void 0)}};return(0,L.jsxs)(Zv,{title:o,description:s,children:[(0,L.jsx)(Qv,{message:d}),(0,L.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,L.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,L.jsx)(oc,{className:`size-4 shrink-0 text-muted-foreground`}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),a[e.id]&&(0,L.jsx)(`span`,{className:`block text-muted-foreground`,children:a[e.id]})]}),t.includes(e.id)&&(0,L.jsx)(Xv,{tone:`green`,children:Y(`connected`)}),(!t.includes(e.id)||i)&&(0,L.jsx)(B,{size:`sm`,loading:l===e.id,disabled:l!==void 0,onClick:()=>void p(e.id),children:Y(t.includes(e.id)?`connectAgain`:`connect`,{name:e.name})})]},e.id))}),c]})},ty=({error:e})=>e?(0,L.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:e}):(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{}),` `,Y(`loading`)]}),ny=(e,t)=>{let[n,r]=(0,M.useState)(),[i,a]=(0,M.useState)(),o=(0,M.useRef)(0),s=(0,M.useCallback)(()=>{let n=++o.current;return e().then(e=>{n===o.current&&(r({value:e}),a(void 0))},e=>{n===o.current&&a(e instanceof K?Iv(e):t)})},[e,t]);return(0,M.useEffect)(()=>{s()},[s]),{data:n?.value,loaded:n!==void 0,error:i,reload:s}},ry=()=>{let e=qg(window.location.href);return e&&window.history.replaceState(window.history.state,``,Xg(window.location.href)),e},iy=({providers:e})=>{let{session:t,linkProvider:n}=J(),{account:r}=t,[i]=(0,M.useState)(ry),{data:a,error:o}=ny((0,M.useCallback)(()=>r.linkedProviders(),[r]),Y(`couldNotReadMethods`));return a?(0,L.jsx)(ey,{providers:e,linked:a,onConnect:n,error:i&&Hv(i,e.length===1?e[0].name:Y(`theProvider`))}):(0,L.jsx)(ty,{error:o})},ay=({signInProviders:e,socialProviders:t,platformProviders:n})=>e.filter(e=>t.includes(e.id)&&!n.some(t=>t.provider===e.id&&t.hidden)),oy=()=>{let e=ay(J());return e.length>0?(0,L.jsx)(iy,{providers:e}):null},sy=()=>{let{account:e}=Tv(),t=J(),{mcp:n,personalAccessTokens:r,accountDeletion:i}=t,a=ay(t).length>0,o=t.personalMail.length>0;return(0,M.useMemo)(()=>{if(!e)return;let t=new Set([...n?[]:[`ConnectedApps`],...r?[]:[`PersonalAccessTokens`],...a?[]:[`ConnectedAccounts`],...o?[]:[`PersonalMail`],...i?[]:[`DeleteAccount`]]);return{...e,tree:jv(e.tree,t)}},[e,n,r,a,o,i])},cy=e=>(0,M.useSyncExternalStore)(t=>{let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},()=>window.matchMedia(e).matches,()=>!1),ly=()=>cy(`(min-width: 768px)`),uy=()=>cy(`not all and (min-width: 640px)`),dy=`ProtobaseTabBar`,fy=(e,t)=>{let n=typeof e==`object`&&e?e[t]:void 0;return typeof n==`number`&&Number.isFinite(n)?n:void 0},py=e=>{if(!e?.isPluginAvailable(`ProtobaseTabBar`))return;let t=(t,n,r,i)=>{let a=e.addListener(dy,t,e=>{let t=fy(e,n);t!==void 0&&r(t)&&i(t)});return()=>void a.remove()};return{set:async t=>{let n=fy(await e.nativePromise(dy,`set`,t),`height`);return n!==void 0&&n>=0?{height:n}:{}},onTap:e=>t(`tap`,`index`,Number.isInteger,e),onHeight:e=>t(`height`,`height`,e=>e>=0,e)}},my=(e,t,n,r)=>({visible:!0,tabs:e.map((e,n)=>({label:e,icon:t[n]??null,...n===r&&{search:!0}})),selected:n>=0&&n<e.length?n:null}),hy=(0,M.createContext)(void 0),gy=()=>(0,M.useContext)(hy),_y=new Map,vy=72,yy=e=>{if(!e)return Promise.resolve(null);let t=e.cloneNode(!0);t.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),t.setAttribute(`width`,`24`),t.setAttribute(`height`,`24`),t.removeAttribute(`class`);let n=new XMLSerializer().serializeToString(t).replaceAll(`currentColor`,`#000`),r=_y.get(n);return r||(r=new Promise(e=>{let t=new Image;t.onload=()=>{let n=document.createElement(`canvas`);n.width=vy,n.height=vy;let r=n.getContext(`2d`);if(!r)return e(null);r.drawImage(t,0,0,vy,vy),e(n.toDataURL(`image/png`))},t.onerror=()=>e(null),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}),_y.set(n,r)),r},by=(e,t,n,r,i=[])=>{let a=gy(),[o,s]=(0,M.useState)(!1),[c,l]=(0,M.useState)(),u=JSON.stringify({labels:t,selected:n,search:r,icons:i}),d=(0,M.useRef)(void 0),f=(0,M.useRef)(u);f.current=u,(0,M.useEffect)(()=>{let i=e.current;if(!a||!i)return;let o=!0,c=[...i.children].map(e=>yy(e.querySelector(`svg`)));return Promise.all(c).then(e=>{o&&a.set(my(t,e,n,r)).then(e=>{o&&(d.current=u,s(!1),e.height!==void 0&&l(e.height))},()=>o&&s(!0))}),()=>{o=!1}},[a,u]),(0,M.useEffect)(()=>{if(a)return()=>void a.set({visible:!1})},[a]);let p=(0,M.useRef)(e);return p.current=e,(0,M.useEffect)(()=>a?.onTap(e=>{d.current===f.current&&(p.current.current?.children[e])?.click()}),[a]),(0,M.useEffect)(()=>a?.onHeight(l),[a]),{native:!!a&&!o,height:c}},xy=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Sy=`flex min-h-[49px] min-w-0 flex-1 flex-col items-center justify-center gap-1 pb-1 pt-1.5 text-[0.625rem] font-medium leading-none`,Cy=({tabs:e,onNavigate:t,onSearch:n,searchLabel:r,onMore:i,moreOpen:a,moreControls:o,sticky:s,ref:c})=>{let l=!e.some(e=>e.active),u=(0,M.useRef)(null);(0,M.useImperativeHandle)(c,()=>u.current);let d=[...e.map(e=>e.label),...n?[r??V(`search`)]:[],V(`more`)],f=d.length-1,p=e.map(e=>e.icon.displayName??e.icon.name),{native:m,height:h}=by(u,d,l?f:e.findIndex(e=>e.active),n?e.length:void 0,p);return(0,L.jsxs)(L.Fragment,{children:[s&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`h-[var(--pb-sticky-bottom)] shrink-0 md:hidden`}),(0,L.jsxs)(`nav`,{ref:u,"aria-label":V(`tabs`),"aria-hidden":m||void 0,className:R(`flex shrink-0 border-t bg-background pb-[var(--pb-safe-bottom)] md:hidden`,s&&`fixed bottom-0 left-[var(--pb-safe-left)] right-[var(--pb-safe-right)] z-30`,m&&`invisible`),style:m&&h!==void 0?{height:h}:void 0,children:[e.map(e=>{let n=e.icon;return(0,L.jsxs)(`a`,{href:e.href,"aria-current":e.active?`page`:void 0,...e.external?{target:`_blank`,rel:`noreferrer`}:{},onClick:n=>{!e.external&&t&&xy(n)&&(n.preventDefault(),t(e.href))},className:R(Sy,e.active?`text-primary-text`:`text-muted-foreground`),children:[(0,L.jsx)(n,{className:`size-6`,strokeWidth:e.active?2.2:1.9,"aria-hidden":!0}),(0,L.jsx)(`span`,{className:`max-w-full truncate px-0.5`,children:e.label})]},e.id)}),n&&(0,L.jsxs)(`button`,{type:`button`,onClick:n,className:R(Sy,`text-muted-foreground`),children:[(0,L.jsx)(ul,{className:`size-6`,strokeWidth:1.9,"aria-hidden":!0}),r??V(`search`)]}),(0,L.jsxs)(`button`,{type:`button`,"aria-expanded":a,"aria-controls":o,"data-current":l||void 0,onClick:i,className:R(Sy,l?`text-primary-text`:`text-muted-foreground`),children:[(0,L.jsx)(As,{className:`size-6`,strokeWidth:l?2.2:1.9,"aria-hidden":!0}),V(`more`)]})]})]})},wy=`protobase:close-sidebar`,Ty=e=>{(0,M.useEffect)(()=>(window.addEventListener(wy,e),()=>window.removeEventListener(wy,e)),[e])},Ey=.35,Dy=`cubic-bezier(0.25, 1, 0.5, 1)`,Oy=(e,t)=>Math.abs(t)>=500?t>0:e>=.5,ky=e=>e>0?40*(1-1/(.55*e/40+1)):0,Ay=e=>Ey*Math.min(Math.max(e,0),1),jy=(e,t,n)=>e!==0&&Math.abs(t)<=n*Math.abs(e),My=(e,t,n)=>Math.hypot(e,t)>=10&&jy(e,t,n),Ny=(e,t,n)=>{let r=e+t/Math.max(1,n);return r<=1?Math.max(r,0):1+ky((r-1)*n)/Math.max(1,n)},Py=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Fy=(e,t,n)=>e===`x`?t:-n,Iy=(e,t,n)=>e===`x`?n:t,Ly=e=>{let t=e.at(-1);if(!t)return 0;let n=e.find(e=>t.time-e.time<=100)??t,r=t.time-n.time;return r>0?(t.along-n.along)/r*1e3:0},Ry=({axis:e,panel:t,backdrop:n,onDraggedClosed:r})=>{let i=(0,M.useRef)(void 0),a=(0,M.useRef)(!1),o=(0,M.useRef)(void 0),s=()=>clearTimeout(o.current);(0,M.useEffect)(()=>()=>clearTimeout(o.current),[]);let c=()=>{let n=t.current;return n?e===`x`?n.offsetWidth:n.offsetHeight:1},l=(r,i)=>{let a=t.current;if(!a)return;let o=i&&!Py()?`350ms ${Dy}`:`none`,s=(r-1)*c();a.style.transition=o===`none`?`none`:`transform ${o}`,a.style.transform=r===1?``:e===`x`?`translateX(${s}px)`:`translateY(${-s}px)`;let l=n.current;l&&(l.style.transition=o===`none`?`none`:`opacity ${o}`,l.style.opacity=String(Ay(r)/Ey))},u=(e,t)=>{if(s(),Oy(Math.min(e,1),t))return l(1,!0);l(0,!0),o.current=setTimeout(r,Py()?0:350)},d=t=>({onPointerDown:e=>{e.pointerType!==`mouse`&&(a.current=!1,i.current={x:e.clientX,y:e.clientY,from:1,along:0,dragging:!1,onBackdrop:t,samples:[],ignored:!1})},onPointerMove:t=>{let n=i.current;if(!n||n.ignored)return;let r=t.clientX-n.x,a=t.clientY-n.y,o=Fy(e,r,a);if(!n.dragging){let i=Iy(e,r,a);if(Math.hypot(o,i)<10)return;if(!My(o,i,n.onBackdrop?1:.58)){n.ignored=!0;return}n.dragging=!0,s(),n.x=t.clientX,n.y=t.clientY,t.currentTarget.setPointerCapture?.(t.pointerId);return}n.along=o,n.samples.push({along:o,time:t.timeStamp}),l(Ny(n.from,o,c()),!1)},onPointerUp:()=>{let e=i.current;i.current=void 0,e?.dragging&&(a.current=!0,u(Ny(e.from,e.along,c()),Ly(e.samples)))},onPointerCancel:()=>{i.current?.dragging&&l(1,!0),i.current=void 0}});return{panelHandlers:d(!1),backdropHandlers:d(!0),dragged:()=>a.current,follow:e=>{s(),l(e,!1)},settle:u}},zy=({id:e,open:t,onClose:n,children:r,underFinger:i,control:a})=>{let o=(0,M.useRef)(null),s=(0,M.useRef)(null);(0,M.useLayoutEffect)(()=>{if(!t)return;let e=document.activeElement;e instanceof HTMLElement&&e.matches(`input, textarea, select, [contenteditable]`)&&e.blur()},[t]),bu(o,t,n);let c=(0,M.useRef)(!1),{panelHandlers:l,backdropHandlers:u,dragged:d,follow:f,settle:p}=Ry({axis:`x`,panel:o,backdrop:s,onDraggedClosed:()=>{c.current=!0,n()}});(0,M.useLayoutEffect)(()=>{if(a&&t)return a.current={follow:f,settle:p},()=>{a.current=null}});let[m,h]=(0,M.useState)(!1),[g,_]=(0,M.useState)(t);return t!==g&&(_(t),h(!t&&!c.current),t&&(c.current=!1)),(0,M.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>h(!1),200);return()=>clearTimeout(e)},[m]),!t&&!m?null:(0,L.jsxs)(`div`,{className:R(`fixed inset-0 z-50 md:hidden`,m&&`pointer-events-none`),children:[(0,L.jsx)(`div`,{ref:s,className:R(`absolute inset-0 touch-none bg-backdrop/40 motion-reduce:[animation:none]`,m?`[animation:pb-fade-out_200ms_ease-in_forwards]`:!i&&`[animation:pb-fade-in_200ms_ease-out]`),style:i&&!m?{opacity:0}:void 0,onClick:()=>!d()&&n(),...u,"aria-hidden":!0}),(0,L.jsx)(`div`,{ref:o,id:e,role:`dialog`,"aria-modal":`true`,"aria-label":V(`navigation`),"aria-hidden":m||void 0,tabIndex:-1,className:R(`absolute inset-y-0 left-0 flex w-[min(88vw,384px)] touch-pan-y bg-sidebar pl-[var(--pb-safe-left)] shadow-pop outline-none motion-reduce:[animation:none] before:absolute before:inset-y-0 before:right-full before:w-10 before:bg-sidebar`,m?`[animation:pb-drawer-out_200ms_ease-in_forwards]`:!i&&`[animation:pb-drawer-in_200ms_ease-out]`),style:i&&!m?{transform:`translateX(-100%)`}:void 0,onClick:e=>e.target.closest(`a`)&&n(),...l,children:r})]})},By=e=>{let t=e.at(-1),n=typeof t==`object`&&!!t.above,r=n?t:e.slice(0,-1).findLast(e=>typeof e==`object`&&!!e.href);if(typeof r==`object`&&r.href&&!r.loading)return{label:r.label,href:r.href,shown:n}},Vy=({desktop:e,back:t,bottomBar:n,drawerOpen:r})=>e?`none`:t?`back`:!n&&!r?`sidebar`:`none`,Hy=`ProtobaseEdgeSwipe`,Uy=(e,{nativeBack:t,behindIsBack:n})=>e===`back`?t&&n?`back`:`page`:e,Wy=e=>{if(e?.isPluginAvailable(`ProtobaseEdgeSwipe`))return{set:t=>e.nativePromise(Hy,`set`,{action:t})}},Gy=(0,M.createContext)(void 0),Ky=()=>!!(0,M.useContext)(Gy),qy=(e,t)=>{let n=(0,M.useContext)(Gy);(0,M.useEffect)(()=>{n?.set(e).catch(()=>void 0)},[n,e,t])},Jy=120,Yy=e=>{let t=document.createElement(`div`);return t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:fixed;left:0;top:${e-22}px;z-index:90;width:44px;height:44px;border-radius:9999px;display:flex;align-items:center;justify-content:center;background:var(--background);color:var(--foreground);box-shadow:var(--shadow-pop);pointer-events:none;transform:translateX(-48px);opacity:0`,t.innerHTML=`<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m15 18-6-6 6-6"/></svg>`,document.body.append(t),t},Xy=(e,t,n)=>{let r=Math.min(t,1.15);e.style.transition=n&&!Zy()?`transform 350ms ${Dy}, opacity 350ms`:`none`,e.style.transform=`translateX(${-48+r*64}px) scale(${.8+.2*Math.min(t,1)})`,e.style.opacity=String(Math.min(t*1.5,1))},Zy=()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Qy=(e,t)=>{let n=e.at(-1);if(!n)return 0;let r=e.find(e=>t-e.time<=100)??n,i=n.time-r.time;return i>0?(n.dx-r.dx)/i*1e3:0},$y=({action:e,onBack:t,openDrawer:n,closeDrawer:r,drawer:i})=>{let a=e===`sidebar`?`sidebar`:e===`page`?`back`:`none`,o=(0,M.useRef)({action:a,onBack:t,openDrawer:n,closeDrawer:r});o.current={action:a,onBack:t,openDrawer:n,closeDrawer:r},(0,M.useEffect)(()=>{let e,t=()=>window.innerWidth,n=(e,t)=>i.current?i.current.settle(e,t):o.current.closeDrawer(),r=e=>{Xy(e,0,!0),setTimeout(()=>e.remove(),Zy()?0:350)},a=()=>{let t=e;e=void 0,t?.dragging&&(t.action===`sidebar`?n(0,0):t.mark&&r(t.mark))},s=t=>{let n=t.touches[0],r=o.current.action;a(),e=r!==`none`&&t.touches.length===1&&n&&n.clientX<=24?{action:r,x:n.clientX,y:n.clientY,dragging:!1,dx:0,samples:[]}:void 0},c=n=>{let r=n.touches[0];if(!e||!r)return;let a=r.clientX-e.x,s=r.clientY-e.y;if(!e.dragging){if(Math.hypot(a,s)<10)return;if(a<=0||!My(a,s,.58)){e=void 0;return}e.dragging=!0,e.x=r.clientX,e.action===`sidebar`?o.current.openDrawer():e.mark=Yy(r.clientY);return}e.dx=Math.max(0,a),e.samples.push({dx:e.dx,time:n.timeStamp}),e.action===`sidebar`?i.current?.follow(e.dx/Math.min(t()*.88,384)):e.mark&&Xy(e.mark,e.dx/Jy,!1)},l=i=>{let a=e;if(e=void 0,!a?.dragging)return;let s=Qy(a.samples,i.timeStamp);if(a.action===`sidebar`)return n(a.dx/Math.min(t()*.88,384),s);let c=a.mark;c&&(Oy(a.dx/Jy,s)&&o.current.onBack(),r(c))};return document.addEventListener(`touchstart`,s,{passive:!0}),document.addEventListener(`touchmove`,c,{passive:!0}),document.addEventListener(`touchend`,l),document.addEventListener(`touchcancel`,a),()=>{a(),document.removeEventListener(`touchstart`,s),document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),document.removeEventListener(`touchcancel`,a)}},[i])},eb=(0,M.createContext)(()=>{}),tb=e=>{let t=(0,M.useContext)(eb);(0,M.useLayoutEffect)(()=>(t(e),()=>t(void 0)),[t,e])},nb=e=>{(0,M.useLayoutEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`scrollbar-gutter`,`stable`),()=>{t.style.removeProperty(`scrollbar-gutter`)}},[e])},rb=[`--pb-sticky-top`,`--pb-sticky-bottom`,`scroll-padding-top`,`scroll-padding-bottom`],ib=(e,t,n,r,i=!0)=>{(0,M.useLayoutEffect)(()=>{if(!e)return;let r=document.documentElement,i=()=>{let e=`${t.current?.offsetHeight??0}px`,i=n.current?`${n.current.offsetHeight}px`:`var(--pb-safe-bottom)`;r.style.setProperty(`--pb-sticky-top`,e),r.style.setProperty(`--pb-sticky-bottom`,i),r.style.setProperty(`scroll-padding-top`,e),r.style.setProperty(`scroll-padding-bottom`,i)},a=new ResizeObserver(i);for(let e of[t.current,n.current])e&&a.observe(e);return i(),()=>{a.disconnect();for(let e of rb)r.style.removeProperty(e)}},[e,t,n,r,i])},ab=`flex min-w-0 items-center gap-2.5`,ob={xs:`size-5 text-[0.5625rem]`,sm:`size-6 text-[0.625rem]`,md:`size-8 text-xs`,lg:`size-10 text-base`,bar:`size-[min(2rem,max(32px,9vw))] text-[min(0.75rem,max(12px,3.4vw))]`},sb=({initials:e,hue:t,size:n=`sm`,className:r})=>(0,L.jsx)(`span`,{className:R(`inline-flex shrink-0 select-none items-center justify-center rounded-full font-semibold text-white`,ob[n],r),style:{background:`oklch(0.58 0.13 ${t})`},children:e}),cb=({people:e,size:t=`sm`})=>(0,L.jsx)(`span`,{className:`inline-flex -space-x-1`,children:e.map(e=>(0,L.jsx)(sb,{...e,size:t,className:`ring-2 ring-background`},e.initials))}),lb=e=>[...e].reduce((e,t)=>(e*31+t.charCodeAt(0))%360,7),ub=e=>e.split(/[\s@.]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join(``),db=`fill-[#ff5a1f] dark:fill-[#ff6a33]`,fb=`fill-[#14161a] dark:fill-[#f1f0ea]`,pb=({className:e})=>(0,L.jsxs)(`svg`,{viewBox:`0 0 32 32`,className:R(`size-7 shrink-0`,e),"aria-hidden":!0,children:[(0,L.jsx)(`path`,{className:db,fillRule:`evenodd`,d:`M0 5a5 5 0 0 1 5-5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zM4 5a1 1 0 0 1 1-1h5v6H4z`}),(0,L.jsx)(`path`,{className:fb,d:`M17 0h10a5 5 0 0 1 5 5v22a5 5 0 0 1-5 5H5a5 5 0 0 1-5-5V17h17z`})]}),mb={sm:`size-7`,lg:`size-10`},hb={sm:`md`,lg:`lg`},gb=({appName:e,appIcon:t,size:n=`sm`,className:r})=>t?(0,L.jsx)(`img`,{src:t,alt:``,className:R(mb[n],`shrink-0 object-contain`,r)}):e&&e!==`Protobase`?(0,L.jsx)(sb,{initials:ub(e).slice(0,1),hue:lb(e),size:hb[n],className:r}):(0,L.jsx)(pb,{className:R(mb[n],r)}),_b=`M312.3 9.9Q257 9.9 217.1 -21.1Q177.3 -52.1 168.4 -108.8L181.1 -110.3V205H54.8V-510H176.7V-404.5L168.3 -407Q179.7 -460.8 221.2 -490.4Q262.7 -520 319.8 -520Q376.2 -520 417 -488.4Q457.8 -456.8 479.8 -398.6Q501.8 -340.5 501.8 -259.9Q501.8 -177.6 478.3 -116.8Q454.9 -55.9 412.5 -23Q370.1 9.9 312.3 9.9ZM274.4 -92.6Q320.2 -92.6 345.8 -133.8Q371.4 -175.1 371.4 -256.4Q371.4 -337.7 345.7 -377.6Q320.1 -417.5 274 -417.5Q228.6 -417.5 202.7 -376.4Q176.9 -335.3 176.9 -254Q176.9 -173.3 202.7 -132.9Q228.4 -92.6 274.4 -92.6Z M549.8 0V-510H671.7V-388.3H676.1V0H549.8ZM676.1 -286.5 661.3 -386.2Q677.9 -455.2 711.8 -487.6Q745.7 -520 794.3 -520Q809 -520 818 -516.6V-394.2Q814.2 -395.6 807.1 -396.1Q800 -396.6 789.4 -396.6Q734.6 -396.6 705.3 -370.5Q676.1 -344.4 676.1 -286.5Z M1043.8 10Q974.7 10 922.6 -23.6Q870.6 -57.2 842.1 -117.5Q813.6 -177.8 813.6 -257Q813.6 -336.5 842.2 -395.5Q870.8 -454.5 922.5 -487.2Q974.2 -520 1043.8 -520Q1113.7 -520 1165.4 -487.2Q1217.1 -454.5 1245.6 -395.5Q1274 -336.5 1274 -257Q1274 -177.8 1245.5 -117.5Q1217 -57.2 1165.3 -23.6Q1113.6 10 1043.8 10ZM1043.8 -90.5Q1073.5 -90.5 1095.9 -108.9Q1118.2 -127.3 1130.9 -164.4Q1143.6 -201.5 1143.6 -257.5Q1143.6 -339.8 1116 -379.7Q1088.4 -419.5 1043.8 -419.5Q999.3 -419.5 971.6 -379.5Q944 -339.5 944 -257.5Q944 -201.5 956.7 -164.4Q969.4 -127.3 991.8 -108.9Q1014.3 -90.5 1043.8 -90.5Z M1509 10.2Q1427.2 10.2 1387.6 -29.2Q1348 -68.6 1348 -147.7V-613.8L1474.2 -666.1V-146.7Q1474.2 -118.4 1489.9 -104.3Q1505.6 -90.3 1539.2 -90.3Q1552 -90.3 1562.7 -92.5Q1573.3 -94.8 1582.5 -98.7V-1.9Q1571.6 4 1552 7.1Q1532.4 10.2 1509 10.2ZM1270.1 -411V-510H1580.6V-411H1270.1Z M1810.8 10Q1741.7 10 1689.6 -23.6Q1637.6 -57.2 1609.1 -117.5Q1580.6 -177.8 1580.6 -257Q1580.6 -336.5 1609.2 -395.5Q1637.8 -454.5 1689.5 -487.2Q1741.2 -520 1810.8 -520Q1880.7 -520 1932.4 -487.2Q1984.1 -454.5 2012.6 -395.5Q2041 -336.5 2041 -257Q2041 -177.8 2012.5 -117.5Q1984 -57.2 1932.3 -23.6Q1880.6 10 1810.8 10ZM1810.8 -90.5Q1840.5 -90.5 1862.9 -108.9Q1885.2 -127.3 1897.9 -164.4Q1910.6 -201.5 1910.6 -257.5Q1910.6 -339.8 1883 -379.7Q1855.4 -419.5 1810.8 -419.5Q1766.3 -419.5 1738.6 -379.5Q1711 -339.5 1711 -257.5Q1711 -201.5 1723.7 -164.4Q1736.4 -127.3 1758.8 -108.9Q1781.3 -90.5 1810.8 -90.5Z M2343.3 9.9Q2288 9.9 2247.7 -21.1Q2207.4 -52.1 2198.5 -108.8L2205.8 -110.3V0H2085.8V-720H2212.1V-404.5L2203.7 -407Q2215.1 -460.8 2255.6 -490.4Q2296.2 -520 2351 -520Q2407.3 -520 2448 -488.4Q2488.8 -456.8 2510.8 -398.6Q2532.8 -340.5 2532.8 -259.9Q2532.8 -177.6 2509.3 -116.8Q2485.9 -55.9 2443.5 -23Q2401.1 9.9 2343.3 9.9ZM2305.4 -92.6Q2350.7 -92.6 2376.6 -133.8Q2402.4 -175.1 2402.4 -256.4Q2402.4 -337.7 2376.5 -377.6Q2350.6 -417.5 2305 -417.5Q2260.5 -417.5 2234.2 -376.4Q2207.9 -335.3 2207.9 -254Q2207.9 -173.3 2234.1 -132.9Q2260.3 -92.6 2305.4 -92.6Z M2834 0Q2828 -19.1 2825.7 -41.7Q2823.3 -64.2 2823.3 -91.8H2818.6V-356Q2818.6 -391.9 2803.1 -409.1Q2787.5 -426.3 2756.2 -426.3Q2724.2 -426.3 2706.4 -408.7Q2688.7 -391.2 2686.3 -358.9H2571.2Q2574.6 -429.6 2625.4 -474.8Q2676.1 -520 2763.5 -520Q2850.2 -520 2896.1 -476.5Q2941.9 -432.9 2941.9 -352.2V-91.8Q2941.9 -69.5 2944.7 -46.7Q2947.5 -23.8 2954.1 0H2834ZM2690.6 10Q2631.9 10 2595.4 -26.3Q2558.9 -62.5 2558.9 -124.5Q2558.9 -185 2594.3 -224Q2629.8 -263 2704.5 -287.6L2845.4 -337.4V-248.7L2753.4 -219.3Q2716.5 -206.1 2699.3 -186.6Q2682.2 -167.2 2682.2 -139Q2682.2 -112.4 2697.5 -98.4Q2712.9 -84.3 2739.4 -84.3Q2773.2 -84.3 2795.9 -104.1Q2818.6 -123.9 2818.6 -153.1L2829.9 -85.8Q2812.6 -37.4 2776.8 -13.7Q2741 10 2690.6 10Z M3168 10Q3080.6 10 3030.1 -34.2Q2979.6 -78.4 2974.7 -158.1H3082.4Q3086.3 -120 3108.9 -100.5Q3131.5 -80.9 3169.8 -80.9Q3202 -80.9 3218.9 -93.9Q3235.8 -106.9 3235.8 -131.3Q3235.8 -151.1 3224.3 -165.6Q3212.9 -180.1 3178.9 -195.4L3111.2 -224.8Q3053 -247.7 3023.8 -284.2Q2994.5 -320.8 2994.5 -373.9Q2994.5 -440.1 3040.1 -480Q3085.7 -520 3162.8 -520Q3242.2 -520 3288.4 -480Q3334.6 -440 3339.5 -367.9H3231.8Q3228.6 -399.7 3211.3 -414.4Q3194 -429.1 3164 -429.1Q3136.1 -429.1 3120.5 -417Q3104.8 -405 3104.8 -382.7Q3104.8 -364.2 3117.7 -349.8Q3130.6 -335.5 3162.4 -321.6L3236.6 -289.6Q3288.6 -269.2 3317.4 -229.2Q3346.1 -189.1 3346.1 -136.9Q3346.1 -69 3299.2 -29.5Q3252.3 10 3168 10Z M3587.8 10Q3520 10 3469.2 -23.3Q3418.5 -56.6 3390.5 -116.5Q3362.6 -176.3 3362.6 -255.8Q3362.6 -336.4 3390.9 -395.7Q3419.3 -454.9 3470.7 -487.5Q3522 -520 3591.1 -520Q3656.6 -520 3702.7 -489.8Q3748.8 -459.7 3773.7 -403.1Q3798.6 -346.5 3798.6 -266.5Q3798.6 -253.7 3798 -242.5Q3797.5 -231.3 3795.8 -221.4H3440V-306.9H3709L3681.8 -277.9Q3681.6 -355.2 3657.7 -390.7Q3633.8 -426.3 3589.3 -426.3Q3541.7 -426.3 3515.6 -384Q3489.5 -341.7 3489.5 -255Q3489.5 -168.4 3515 -126.1Q3540.5 -83.7 3590.6 -83.7Q3623.7 -83.7 3644.6 -102Q3665.5 -120.3 3673.8 -156.3H3788.9Q3772.2 -81.6 3721.5 -35.8Q3670.8 10 3587.8 10Z`,vb=({className:e})=>(0,L.jsx)(`svg`,{viewBox:`54.8 -720 3743.8 925`,className:R(`h-3.5 w-auto`,e),role:`img`,"aria-label":`Protobase`,children:(0,L.jsx)(`path`,{className:fb,d:_b})}),yb=({compact:e,workspace:t,appName:n,appIcon:r})=>(0,L.jsxs)(`div`,{className:ab,children:[(0,L.jsx)(gb,{appName:n,appIcon:r}),!e&&(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 leading-tight`,children:[r||n&&n!==`Protobase`?(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:n??`Protobase`}):(0,L.jsx)(vb,{className:`self-start`}),t&&(0,L.jsx)(`div`,{className:`truncate text-[0.6875rem] text-muted-foreground`,children:t})]})]}),bb=`protobase:logo-tap`,xb=(e=window)=>{let t=!e.dispatchEvent(new Event(bb,{cancelable:!0}));return e.parent&&e.parent!==e&&e.parent.postMessage({type:bb},`*`),t},Sb=`bg-primary border-transparent`,Cb=e=>{let[t=255,n=255,r=255]=(e.match(/\d+(\.\d+)?/g)??[]).map(Number);return .299*t+.587*n+.114*r<150?`DARK`:`LIGHT`},wb=(0,M.createContext)(void 0),Tb=()=>{let e=(0,M.useContext)(wb);return e?{id:e.id,name:e.name,"aria-describedby":e.describedBy,"aria-invalid":e.invalid||void 0,"aria-required":e.required||void 0}:{}},Eb=({leading:e,trailing:t,invalid:n,className:r,wrapperClassName:i,...a})=>{let o=Tb();return(0,L.jsxs)(`span`,{className:R(`flex h-8 items-center gap-2 rounded-md border bg-background px-2.5 text-muted-foreground shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20`,n?`border-danger`:`border-border-strong`,i),children:[e,(0,L.jsx)(`input`,{className:R(`min-w-0 flex-1 bg-transparent text-body text-foreground outline-none placeholder:text-faint-foreground`,r),...o,...n&&{"aria-invalid":!0},...a}),t]})},Db=({children:e})=>(0,L.jsx)(`kbd`,{className:`inline-flex h-5 items-center rounded border border-border-strong bg-background px-1.5 font-sans text-[0.6875rem] font-medium text-muted-foreground`,children:e}),Ob=(e,t,n)=>Math.min(n-4,Math.max(e,4+t)),kb=e=>e-8,Ab=(e,t,n)=>{let[r,i]=(0,M.useState)();return(0,M.useLayoutEffect)(()=>{if(!e||!t.current||!n.current){i(void 0);return}let r=document.documentElement.clientWidth,a=kb(r);n.current.style.maxWidth=`${a}px`;let o=t.current.getBoundingClientRect().right,s=n.current.getBoundingClientRect().width;i({right:o-Ob(o,s,r),maxWidth:a})},[e]),r},jb=()=>{let e=window.visualViewport;return e?{top:e.offsetTop,height:e.height}:{top:0,height:window.innerHeight}},Mb=(e,t,n,r)=>{let i=r.top+r.height-4-e.bottom,a=e.top-r.top-4;return n+t>i&&a>i},Nb=(e,t,n,r)=>{let[i,a]=(0,M.useState)(),[o,s]=(0,M.useState)(0);return(0,M.useEffect)(()=>{let t=window.visualViewport;if(!e||!t)return;let n=()=>s(e=>e+1);return t.addEventListener(`resize`,n),()=>t.removeEventListener(`resize`,n)},[e]),(0,M.useLayoutEffect)(()=>{if(!e||!t.current||!n.current){a(void 0);return}let r=t.current.getBoundingClientRect(),i=n.current.getBoundingClientRect().height,o=parseFloat(getComputedStyle(n.current).marginTop);a(Mb(r,i,o,jb())?-(i+2*o):void 0)},[e,r,o]),i===void 0?void 0:{top:i}},Pb=(e,t,n)=>t===0?-1:e<0?n===1?0:t-1:(e+n+t)%t,Fb=e=>e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0,Ib=({search:e,className:t=`w-96`,fieldClassName:n,autoFocus:r,showShortcut:i=!0,inline:a,ref:o})=>{let s=(0,M.useId)(),c=(0,M.useRef)(null),[l,u]=(0,M.useState)(!1),[d,f]=(0,M.useState)(-1),p=e.groups.flatMap(e=>e.hits),m=(l||!!a)&&(e.query!==``||e.loading),h=e=>`${s}-${e}`,g=(0,M.useRef)(null),_=(0,M.useRef)(null),v=Ab(m,g,_),y=Nb(m,g,_,`${v?.right} ${e.loading} ${p.length} ${e.groups.length}`),b=e=>{c.current=e,typeof o==`function`?o(e):o&&(o.current=e)},x=t=>{e.onSelect(t),f(-1),c.current?.blur()},S=()=>{e.onTextChange(``),f(-1),c.current?.focus()},C=t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`)t.preventDefault(),f(e=>Pb(e,p.length,t.key===`ArrowDown`?1:-1));else if(t.key===`Enter`){let e=p[d]??p[0];if(!e)return;t.preventDefault(),x(e.href)}else t.key===`Escape`&&(e.text?e.onTextChange(``):t.currentTarget.blur(),f(-1))},w=-1;return(0,L.jsxs)(`div`,{ref:g,className:R(`relative`,t),children:[(0,L.jsx)(Eb,{ref:b,wrapperClassName:R(`w-full bg-surface shadow-none`,n),leading:e.loading?(0,L.jsx)(fu,{className:`size-4`}):(0,L.jsx)(ul,{className:`size-4`}),trailing:e.text?(0,L.jsx)(`button`,{type:`button`,"aria-label":V(`clearSearch`),className:`-mr-1 inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground`,onMouseDown:e=>e.preventDefault(),onClick:S,children:(0,L.jsx)(uu,{className:`size-3.5`})}):i?(0,L.jsx)(`span`,{className:`hidden md:inline-flex`,children:(0,L.jsx)(Db,{children:`⌘K`})}):void 0,placeholder:e.placeholder,"aria-label":V(`globalSearch`),role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":m,"aria-controls":s,"aria-activedescendant":m&&p[d]?h(d):void 0,autoFocus:r,value:e.text,onChange:t=>{e.onTextChange(t.target.value),f(-1)},onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:C}),m&&(0,L.jsxs)(`div`,{ref:_,id:s,role:`listbox`,"aria-label":V(`searchResults`),style:a?void 0:{...v,...y},className:a?`mt-2 py-1`:`absolute right-0 top-full z-40 mt-1 max-h-96 w-full min-w-72 overflow-y-auto rounded-lg border bg-background py-1 shadow-pop`,children:[e.groups.length===0&&(0,L.jsx)(`p`,{className:`px-3 py-2 text-muted-foreground`,children:e.loading?V(`searching`):V(`noMatches`,{query:e.query})}),e.groups.map(e=>(0,L.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,L.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[0.6875rem] font-medium uppercase tracking-wide text-faint-foreground`,children:e.label}),e.failed&&(0,L.jsx)(`p`,{className:`px-3 py-1.5 text-danger-text`,children:V(`couldNotSearch`,{label:e.label})}),e.hits.map(e=>{w+=1;let t=w;return(0,L.jsxs)(`a`,{id:h(t),href:e.href,tabIndex:-1,role:`option`,"aria-selected":t===d,className:R(`block px-3 py-1.5`,t===d?`bg-primary-soft text-primary-text`:`hover:bg-muted`),onMouseDown:e=>e.preventDefault(),onClick:t=>{Fb(t)||(t.preventDefault(),x(e.href))},onMouseEnter:()=>f(t),children:[(0,L.jsx)(`span`,{className:`block truncate font-semibold`,children:e.title}),e.subtitle&&(0,L.jsx)(`span`,{className:R(`block truncate text-xs`,t===d?`text-primary-text/80`:`text-muted-foreground`),children:e.subtitle})]},e.id)})]},e.id))]})]})},Lb=`inline-flex size-[min(2.75rem,max(44px,13vw))] shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden [&_svg]:size-[min(1.25rem,max(20px,6vw))]`,Rb=`size-[min(2.75rem,max(44px,13vw))] shrink-0`,zb=`max-h-[max(40px,calc(13vw-4px),calc(1.25em+2px))] text-body [&>input]:leading-[1.25] [&>svg]:size-[min(1rem,max(16px,6vw))] [&>button]:size-[min(1.5rem,max(24px,9vw))] [&>button>svg]:size-[min(0.875rem,max(14px,5vw))]`,Bb=`inline-flex min-h-[min(2.75rem,max(44px,13vw))] min-w-0 items-center gap-1 rounded-md pr-2 pl-3 text-muted-foreground hover:bg-muted hover:text-foreground md:hidden [&_svg]:size-[min(1.25rem,max(20px,6vw))]`,Vb=({breadcrumb:e,titleStatus:t,onNavigate:n,onBack:r,actions:i,brand:a,leading:o,backInLeadingSlot:s,account:c,searchButton:l=!0,searchOpen:u,onSearchOpenChange:d,onMenu:f,menuOpen:p,menuControls:m,search:h,sticky:g,slotRef:_,ref:v})=>{let y=(0,L.jsx)(`span`,{className:`flex shrink-0 items-center empty:hidden`,children:t}),[b,x]=(0,M.useState)(!1),S=u??b,C=e=>d?d(e):x(e),w=By(e),T=(0,M.useRef)(null);return(0,M.useLayoutEffect)(()=>{if(!h)return;let e=e=>{if(e.key.toLowerCase()!==`k`||!(e.metaKey||e.ctrlKey))return;e.preventDefault();let t=T.current;t&&t.offsetParent!==null?t.focus():C(!0)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`header`,{ref:v,className:R(g?`sticky top-0 z-30 max-md:fixed max-md:left-[var(--pb-safe-left)] max-md:right-[var(--pb-safe-right)]`:`relative`,`flex shrink-0 items-center gap-1 border-b pt-[var(--pb-safe-top,--spacing(2))] pr-2 pb-2 pl-4 h-[calc(3rem+var(--pb-safe-top))] md:gap-4 md:px-5 md:pt-[var(--pb-safe-top)] md:pb-0`,a?Sb:`bg-background`),children:[a&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-full h-screen bg-primary md:hidden`}),(0,L.jsxs)(`div`,{className:R(`contents`,a&&`text-primary-foreground [&_*]:text-primary-foreground [&_button:hover]:bg-primary-foreground/15`),children:[f&&(0,L.jsx)(`button`,{type:`button`,"aria-label":V(`openNavigation`),"aria-expanded":!!p,"aria-controls":m,onClick:f,className:R(`inline-flex size-[min(2.75rem,max(44px,13vw))] shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden [&_svg]:size-[min(1.25rem,max(20px,6vw))]`,`-ml-3`),children:(0,L.jsx)(vc,{})}),o&&(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,L.jsx)(`div`,{className:`min-w-0`,children:o}),y]}),!o&&s&&(0,L.jsxs)(`div`,{className:R(`flex min-w-0 items-center gap-2.5`,`flex-1`),children:[w&&(0,L.jsx)(`a`,{href:w.href,"aria-label":V(`backTo`,{label:w.label}),onClick:e=>{let t=r??n;t&&Tu(e)&&(e.preventDefault(),t(w.href))},className:R(`size-[min(1.75rem,max(28px,8vw))]`,`relative flex shrink-0 items-center justify-center rounded-full text-foreground after:absolute after:-inset-2 [&_svg]:size-[min(1.5rem,max(24px,7vw))]`),children:(0,L.jsx)(es,{"aria-hidden":!0})}),(0,L.jsx)(Eu,{parts:e,onNavigate:n,trailing:y})]}),!o&&!s&&w&&(0,L.jsxs)(`a`,{href:w.href,"aria-label":V(`backTo`,{label:w.label}),onClick:e=>{let t=r??n;t&&Tu(e)&&(e.preventDefault(),t(w.href))},className:R(w.shown?Bb:`inline-flex size-[min(2.75rem,max(44px,13vw))] shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden [&_svg]:size-[min(1.25rem,max(20px,6vw))]`,!f&&`-ml-3`),children:[(0,L.jsx)(es,{className:`shrink-0`,"aria-hidden":!0}),w.shown&&(0,L.jsx)(`span`,{className:`truncate`,children:w.label})]}),!o&&!s&&(0,L.jsx)(Eu,{parts:e,onNavigate:n,trailing:y}),(0,L.jsxs)(`div`,{className:`ml-auto flex items-center gap-1 md:gap-3`,children:[h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`hidden md:block`,children:(0,L.jsx)(Ib,{ref:T,search:h})}),l&&(0,L.jsx)(`button`,{type:`button`,"aria-label":V(`search`),"aria-expanded":S,onClick:()=>C(!0),className:`inline-flex size-[min(2.75rem,max(44px,13vw))] shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden [&_svg]:size-[min(1.25rem,max(20px,6vw))]`,children:(0,L.jsx)(ul,{})})]}),i,(0,L.jsx)(`div`,{ref:_,className:`contents md:hidden`}),c]})]}),h&&S&&(0,L.jsxs)(`div`,{className:`absolute inset-0 z-20 flex items-center gap-1 bg-background px-3 pt-[var(--pb-safe-top)] md:hidden`,children:[(0,L.jsx)(Ib,{className:`min-w-0 flex-1`,fieldClassName:zb,autoFocus:!0,showShortcut:!1,search:{...h,onSelect:e=>{h.onSelect(e),C(!1)}}}),(0,L.jsx)(`button`,{type:`button`,"aria-label":V(`closeSearch`),onClick:()=>C(!1),className:`inline-flex size-[min(2.75rem,max(44px,13vw))] shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden [&_svg]:size-[min(1.25rem,max(20px,6vw))]`,children:(0,L.jsx)(uu,{})})]})]}),g&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`h-[var(--pb-sticky-top,calc(3rem+var(--pb-safe-top)))] shrink-0 md:hidden`})]})},Hb=({label:e,current:t,others:n,rowClassName:r,onSwitch:i})=>(0,L.jsxs)(`div`,{className:`border-b py-1`,role:`group`,"aria-label":e,children:[t&&(0,L.jsxs)(`div`,{className:R(r,`text-foreground hover:bg-transparent`),"aria-current":`true`,children:[(0,L.jsx)(Xo,{className:`size-4`}),(0,L.jsx)(`span`,{className:`truncate`,children:t.label})]}),n.map(e=>(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>i(e.id),className:r,children:[(0,L.jsx)(`span`,{className:`size-4`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))]}),Ub={sm:{group:`h-[2em]`,option:`px-2.5 text-body`},md:{group:`h-[2.2857em]`,option:`px-3 text-body`}},Wb={group:(e=`sm`)=>R(`inline-flex`,Ub[e].group,`rounded-md bg-muted p-0.5`),option:(e,t=`sm`)=>R(`inline-flex items-center gap-1.5 rounded`,Ub[t].option,`font-medium transition-colors`,e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`)},Gb=({value:e,options:t,onChange:n,label:r,size:i=`sm`,iconOnly:a=!1})=>(0,L.jsx)(`span`,{role:`group`,"aria-label":r,"data-segmented":``,className:Wb.group(i),children:t.map(t=>(0,L.jsxs)(`button`,{type:`button`,"aria-pressed":t.value===e,...a&&{"aria-label":t.label,title:t.label},onClick:()=>n(t.value),className:Wb.option(t.value===e,i),children:[t.icon&&(0,L.jsx)(t.icon,{className:`size-[1em]`}),!a&&t.label]},t.value))}),Kb=()=>[{value:`light`,label:V(`light`),icon:Al},{value:`dark`,label:V(`dark`),icon:Mc},{value:`system`,label:V(`system`),icon:Ac}],qb=({theme:e,className:t})=>(0,L.jsxs)(`div`,{className:t,children:[(0,L.jsx)(Ol,{className:`size-4`}),(0,L.jsx)(`span`,{className:`flex-1`,children:V(`theme`)}),(0,L.jsx)(Gb,{label:V(`theme`),iconOnly:!0,value:e.preference,options:Kb(),onChange:e.onChange})]}),Jb=10,Yb=100,Xb=e=>e>=0?e:-ky(-e),Zb=e=>{let t=e.at(-1);if(!t)return 0;let n=e.find(e=>t.time-e.time<=Yb)??t,r=t.time-n.time;return r>0?(t.y-n.y)/r:0},Qb=(e,t,n)=>e<=Jb?!1:!Oy(1-e/Math.max(1,t),-n*1e3),$b=(e,t,n)=>e<=0&&n>0&&jy(n,t,.58),ex=350,tx=Dy,nx=()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,rx=({panel:e,backdrop:t,content:n,open:r,onClose:i})=>{let a=(0,M.useRef)(void 0),o=(0,M.useRef)(!1),s=(0,M.useRef)(i);s.current=i;let c=(0,M.useCallback)((n,r)=>{let i=e.current;if(!i)return;let a=r&&!nx()?`${ex}ms ${tx}`:`none`;i.style.transition=a===`none`?`none`:`transform ${a}`,i.style.transform=n===0?``:`translateY(${n}px)`;let o=t.current;o&&(o.style.transition=a===`none`?`none`:`opacity ${a}`,o.style.opacity=String(1-Math.max(0,n)/Math.max(1,i.offsetHeight)))},[e,t]);(0,M.useLayoutEffect)(()=>{let t=e.current;if(!r||!t||(o.current=!1,nx()))return;c(t.offsetHeight,!1);let n=requestAnimationFrame(()=>c(0,!0));return()=>cancelAnimationFrame(n)},[r,e,c]);let l=(0,M.useCallback)(()=>{let t=e.current;if(!o.current){if(!t||nx())return s.current();o.current=!0,c(t.offsetHeight,!0),setTimeout(()=>s.current(),ex)}},[e,c]),u=(e,t,n)=>{a.current={x:e,y:t,samples:[{y:t,time:n}],dragging:!1,scrolling:!1}},d=(e,t)=>{let n=a.current;n&&(n.samples.push({y:e,time:t}),c(Xb(e-n.y),!1))},f=()=>{let t=a.current;a.current=void 0;let n=e.current;if(t?.dragging&&n){if(Qb(Xb(t.samples.at(-1).y-t.y),n.offsetHeight,Zb(t.samples)))return l();c(0,!0)}};return(0,M.useEffect)(()=>{let e=n.current;if(!r||!e)return;let t=e=>{let t=e.touches[0];e.touches.length===1&&t&&u(t.clientX,t.clientY,e.timeStamp)},i=t=>{let n=a.current,r=t.touches[0];if(n&&r&&!n.scrolling){if(!n.dragging){let t=r.clientX-n.x,i=r.clientY-n.y;if(Math.abs(t)<Jb&&Math.abs(i)<Jb)return;if(!$b(e.scrollTop,t,i)){n.scrolling=!0;return}n.dragging=!0,n.y=r.clientY}t.preventDefault(),d(r.clientY,t.timeStamp)}};return e.addEventListener(`touchstart`,t,{passive:!0}),e.addEventListener(`touchmove`,i,{passive:!1}),e.addEventListener(`touchend`,f),e.addEventListener(`touchcancel`,f),()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchmove`,i),e.removeEventListener(`touchend`,f),e.removeEventListener(`touchcancel`,f)}}),{dismiss:l,header:{onPointerDown:e=>{if(e.button!==0)return;u(e.clientX,e.clientY,e.timeStamp);let t=t=>{let n=a.current;if(n&&t.pointerId===e.pointerId){if(!n.dragging){if(Math.abs(t.clientY-n.y)<Jb)return;n.dragging=!0,n.y=t.clientY}d(t.clientY,t.timeStamp)}},n=r=>{if(r.pointerId!==e.pointerId)return;let i=a.current;i&&!i.dragging&&Math.abs(r.clientY-i.y)>=Jb&&(i.dragging=!0,i.samples.push({y:r.clientY,time:r.timeStamp})),window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n),f()};window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n)}}}},ix=({title:e,open:t,onClose:n,children:r,inset:i=`sides`,header:a=`title`})=>{let o=(0,M.useRef)(null),s=(0,M.useRef)(null),c=(0,M.useRef)(null),{dismiss:l,header:u}=rx({panel:o,backdrop:s,content:c,open:t,onClose:n});return bu(o,t,l),t?(0,N.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[80]`,children:[(0,L.jsx)(`div`,{ref:s,className:`absolute inset-0 bg-backdrop/40`,onClick:l,"aria-hidden":!0}),(0,L.jsxs)(`div`,{ref:o,role:`dialog`,"aria-modal":`true`,"aria-label":e,tabIndex:-1,className:`absolute inset-x-0 bottom-0 flex max-h-[85vh] flex-col rounded-t-xl border-t bg-background pl-[var(--pb-safe-left)] pr-[var(--pb-safe-right)] shadow-pop outline-none will-change-transform`,children:[(0,L.jsxs)(`header`,{className:R(`relative flex shrink-0 touch-none select-none items-center justify-between`,a===`title`?`border-b px-4 pt-4`:`h-5`),...u,children:[a===`title`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,L.jsx)(`button`,{type:`button`,"aria-label":du(`close`),onClick:l,className:`-mr-2 inline-flex size-11 items-center justify-center rounded-md text-muted-foreground hover:bg-muted`,children:(0,L.jsx)(uu,{className:`size-5`})})]}),(0,L.jsx)(`button`,{type:`button`,"aria-label":du(`dragToClose`),onClick:l,className:`absolute left-1/2 top-0 flex h-4 w-16 -translate-x-1/2 items-start justify-center pt-1.5`,children:(0,L.jsx)(`span`,{className:`h-1 w-9 rounded-full bg-border-strong`})})]}),(0,L.jsx)(`div`,{ref:c,className:R(`min-h-0 flex-1 overflow-y-auto overscroll-contain pb-[calc(1.5rem+max(var(--pb-safe-bottom),var(--pb-sticky-bottom,0px)))]`,i===`sides`&&`px-4`),children:r})]})]}),document.body):null},ax=`py-1 text-menu-sheet [&>*]:min-h-[2.6em] [&_[role=menuitem]]:min-h-[2.6em] [&_svg]:size-[1.2em] [&_[data-segmented]]:h-[2.3em] [&_[data-segmented]_button]:min-w-[2.3em] [&_[data-segmented]_button]:justify-center [&_[data-menu-heading]]:py-[0.75em] [&_[data-menu-heading]>:first-child]:text-[1.15em] [&_[data-menu-heading]>:first-child]:font-semibold [&_[data-menu-heading]>:last-child]:text-[0.9em]`,ox=({open:e,title:t,onClose:n,menu:r,inPlaceOnDesktop:i})=>{let a=ly();return e?a?i?r:(0,N.createPortal)(r,document.body):(0,L.jsx)(ix,{title:t,open:!0,onClose:n,inset:`none`,header:`handle`,children:(0,M.cloneElement)(r,{className:ax,style:void 0})}):null},sx=`flex min-h-11 w-full items-center gap-2.5 px-3 py-1.5 text-left text-muted-foreground hover:bg-muted md:min-h-0`,cx=({user:e,compact:t,open:n,items:r=[],account:i,onNavigate:a,onSignOut:o,organizations:s,roles:c,theme:l,status:u,label:d,inTopBar:f})=>{let p=c?.roles.find(e=>e.name===c.active),[m,h]=(0,M.useState)(!1),g=n??m,_=(0,M.useRef)(null),v=(0,M.useRef)(null),[y,b]=(0,M.useState)();(0,M.useEffect)(()=>{if(!g||n!==void 0)return;let e=e=>{if(v.current?.closest(`[aria-modal="true"]`))return;let t=_.current?.contains(e.target)||v.current?.contains(e.target);(e instanceof KeyboardEvent?e.key===`Escape`:!t)&&h(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[g,n]);let x=r.filter(e=>e.length>0),S=(e,t,n)=>{h(!1),!n&&a&&(e.preventDefault(),a(t))},C=()=>{let e=_.current?.getBoundingClientRect();e&&b({left:e.left,bottom:window.innerHeight-e.top+8}),h(!m)},w=(0,L.jsxs)(`div`,{ref:v,role:`menu`,className:n===void 0?`fixed z-[60] w-56 overflow-hidden rounded-lg border bg-background py-1 shadow-pop`:`absolute bottom-full left-0 z-50 mb-2 w-56 overflow-hidden rounded-lg border bg-background py-1 shadow-pop`,style:n===void 0&&y?{left:y.left,bottom:y.bottom}:void 0,children:[i?(0,L.jsxs)(`a`,{role:`menuitem`,href:i,onClick:e=>S(e,i),"data-menu-heading":``,className:`block border-b px-3 pb-2 pt-1.5 hover:bg-muted`,children:[(0,L.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,L.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.email})]}):(0,L.jsxs)(`div`,{"data-menu-heading":``,className:`border-b px-3 pb-2 pt-1.5`,children:[(0,L.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,L.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.email})]}),u&&(0,L.jsx)(`div`,{className:`border-b py-1`,children:(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,className:sx,onClick:()=>{h(!1),u.onOpen()},children:[(0,L.jsx)(Rs,{className:`size-4 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:u.label})]})}),s&&(s.current||s.others.length>0)&&(0,L.jsx)(Hb,{label:s.label??V(`organizations`),...s.current&&{current:{id:s.current.id,label:s.current.name}},others:s.others.map(({id:e,name:t})=>({id:e,label:t})),rowClassName:sx,onSwitch:e=>{h(!1),s.onSwitch(e)}}),c&&c.roles.length>1&&(0,L.jsx)(Hb,{label:V(`roles`),...p&&{current:{id:p.name,label:p.label}},others:c.roles.filter(e=>e!==p).map(({name:e,label:t})=>({id:e,label:t})),rowClassName:sx,onSwitch:e=>{h(!1),c.onSwitch(e)}}),x.map((e,t)=>(0,L.jsx)(`div`,{role:`group`,className:R(`py-1`,(t<x.length-1||l||o)&&`border-b`),children:e.map(e=>{let t=e.icon;return(0,L.jsxs)(`a`,{role:`menuitem`,href:e.href,"aria-current":e.active?`page`:void 0,...e.external?{target:`_blank`,rel:`noreferrer`}:{},onClick:t=>S(t,e.href,e.external),className:R(sx,e.active&&`bg-muted text-foreground`),children:[(0,L.jsx)(t,{className:`size-4`}),e.label]},e.id)})},e[0]?.id)),l&&(0,L.jsx)(`div`,{className:R(o&&`border-b`),children:(0,L.jsx)(qb,{theme:l,className:R(sx,`hover:bg-transparent`)})}),o&&(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:o,className:sx,children:[(0,L.jsx)(fc,{className:`size-4`}),V(`signOut`)]})]});return(0,L.jsxs)(`div`,{ref:_,className:`relative`,children:[(0,L.jsxs)(`button`,{type:`button`,className:f?R(Rb,`flex items-center justify-center rounded-full hover:bg-muted`):`flex min-h-11 w-full items-center gap-2.5 rounded-md p-1 text-left hover:bg-muted md:min-h-0`,"aria-label":d??V(`profileMenu`),"aria-haspopup":`menu`,"aria-expanded":g,onClick:C,children:[f?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`contents`,children:(0,L.jsx)(sb,{initials:e.initials,hue:e.hue,size:`bar`})}):(0,L.jsx)(sb,{initials:e.initials,hue:e.hue,size:`md`}),!t&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 leading-tight`,children:[u?.mark?(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),u.mark]}):(0,L.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,L.jsx)(Xv,{tone:e.roleTone,dot:!1,className:`mt-0.5 h-4 px-1.5 text-[0.625rem]`,children:e.role})]}),(0,L.jsx)(is,{className:`size-3.5 shrink-0 text-faint-foreground`})]})]}),n===void 0?(0,L.jsx)(ox,{open:g,title:V(`profileMenu`),onClose:()=>h(!1),menu:w,inPlaceOnDesktop:!0}):g&&w]})},lx={"text-large":`h-8 gap-2.5 px-2.5`,"text-small":`h-7 gap-2 px-2 text-body`},ux={"text-large":`ml-[20px]`,"text-small":`ml-[17px]`},dx=({create:e,mode:t,onNavigate:n})=>(0,L.jsx)(`div`,{className:R(`border-l border-transparent pl-1.5`,ux[t]),children:(0,L.jsxs)(`a`,{href:e.href,onClick:n&&(t=>{t.preventDefault(),n(e.href)}),className:R(`flex items-center rounded-md text-faint-foreground transition-colors hover:bg-muted hover:text-foreground`,lx[t]),children:[(0,L.jsx)(Xc,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.label})]})}),fx=`protobase:nav-open:`,px=e=>`${fx}${e}`,mx=(e,t)=>le(()=>e.getItem(t)!==`false`,!0),hx=(e,t,n)=>le(()=>n?e.removeItem(t):e.setItem(t,`false`),void 0),gx=({label:e,side:t=`right`,visible:n,children:r})=>(0,L.jsxs)(`span`,{className:`group/tooltip relative inline-flex`,children:[r,(0,L.jsx)(`span`,{role:`tooltip`,className:R(`pointer-events-none absolute z-50 whitespace-nowrap rounded-md bg-foreground px-2 py-1 text-xs font-medium text-background opacity-0 shadow-md transition-opacity group-hover/tooltip:opacity-100`,n&&`opacity-100`,t===`right`&&`left-full top-1/2 ml-2 -translate-y-1/2`,t===`top`&&`bottom-full left-1/2 mb-2 -translate-x-1/2`,t===`bottom`&&`left-1/2 top-full mt-2 -translate-x-1/2`),children:e})]}),_x=e=>e===`text-large`||e===`text-small`||e===`icon-expand`,vx=e=>e===`text-large`||e===`text-small`,yx={"text-large":`w-60 max-w-[33vw]`,"text-small":`w-52 max-w-[33vw]`,icon:`w-14`,"icon-label":`w-[76px]`,"icon-tooltip":`w-14`,"icon-expand":`w-14`},bx={"text-large":`h-9 gap-3 px-3 text-sm`,"text-small":`h-7 gap-2.5 px-2.5 text-body`,icon:`size-9 justify-center`,"icon-label":`w-full flex-col gap-0.5 py-1.5 text-[0.625rem]`,"icon-tooltip":`size-9 justify-center`,"icon-expand":`h-8 gap-3 px-3`},xx=({item:e,mode:t,active:n,onNavigate:r,className:i})=>{let a=e.icon,o=(0,L.jsxs)(`a`,{onClick:r&&(t=>{t.preventDefault(),r(e.href??`#${e.id}`)}),href:e.href??`#${e.id}`,"aria-label":e.problem?`${e.label}: ${e.problem}`:e.label,"aria-current":n?`page`:void 0,title:e.problem,className:R(`flex shrink-0 items-center rounded-md font-medium transition-colors`,bx[t],n?`bg-primary-soft text-primary-text`:`text-muted-foreground hover:bg-muted hover:text-foreground`,i),children:[(0,L.jsx)(a,{className:R(`shrink-0`,t===`text-small`?`size-4`:`size-[18px]`),strokeWidth:n?2.2:1.9}),(_x(t)||t===`icon-label`)&&(0,L.jsx)(`span`,{className:`whitespace-nowrap`,children:e.label}),vx(t)&&e.count&&(0,L.jsx)(`span`,{className:`ml-auto rounded bg-muted px-1.5 text-[0.6875rem] tabular-nums text-muted-foreground`,children:e.count}),vx(t)&&e.problem&&(0,L.jsx)(Bl,{"aria-hidden":!0,className:`ml-auto size-3.5 shrink-0 text-warning-text`})]});return t===`icon-tooltip`?(0,L.jsx)(gx,{label:e.label,children:o}):o},Sx=99,Cx=e=>e===void 0||e<=0?void 0:e>Sx?`${Sx}+`:String(e),wx=({count:e,className:t})=>{let n=Cx(e);return n?(0,L.jsx)(Xv,{tone:`red`,dot:!1,className:R(`h-4 min-w-4 justify-center px-1 text-[0.625rem] font-semibold`,t),children:n}):null},Tx={neutral:`text-faint-foreground`,info:`text-primary`,success:`text-success`,warning:`text-warning`,danger:`text-danger`},Ex={neutral:(0,L.jsx)(`circle`,{cx:`5`,cy:`5`,r:`3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`}),info:(0,L.jsx)(`path`,{d:`M5 0.8 9.2 5 5 9.2 0.8 5Z`,fill:`currentColor`}),success:(0,L.jsx)(`circle`,{cx:`5`,cy:`5`,r:`4`,fill:`currentColor`}),warning:(0,L.jsx)(`path`,{d:`M5 0.6 9.6 9H0.4Z`,fill:`currentColor`,strokeLinejoin:`round`}),danger:(0,L.jsx)(`rect`,{x:`1.2`,y:`1.2`,width:`7.6`,height:`7.6`,rx:`1`,fill:`currentColor`})},Dx=({tone:e,pulse:t=!1,className:n})=>(0,L.jsxs)(`span`,{"aria-hidden":!0,className:R(`relative flex size-2.5 shrink-0`,Tx[e],n),"data-tone":e,"data-pulse":t||void 0,children:[t&&(0,L.jsx)(`svg`,{viewBox:`0 0 10 10`,className:`absolute inset-0 size-2.5 animate-ping opacity-60 motion-reduce:animate-none`,children:Ex[e]}),(0,L.jsx)(`svg`,{viewBox:`0 0 10 10`,className:`relative size-2.5`,children:Ex[e]})]}),Ox=F(`status`),kx=({presence:e})=>{let t=Ox(e);return(0,L.jsx)(`span`,{role:`img`,"aria-label":t,title:t,className:`flex shrink-0`,children:(0,L.jsx)(Dx,{tone:e===`online`?`success`:`neutral`})})},Ax=e=>Ox(e===`busy`?`busy`:e===`do_not_disturb`?`doNotDisturb`:`automatic`),jx=({availability:e,title:t})=>{if(e===`automatic`)return null;let n=Ax(e);return(0,L.jsx)(e===`busy`?ms:cs,{role:`img`,"aria-label":n,className:R(`size-3.5 shrink-0`,e===`busy`?`text-warning`:`text-danger`),children:(0,L.jsx)(`title`,{children:t??n})})},Mx=({status:e,presence:t,textShown:n=`full`,className:r})=>{let i=bi(e);if(!i&&!t)return null;let a=i?.text??void 0;return(0,L.jsxs)(`span`,{className:R(`inline-flex min-w-0 items-center gap-1 text-muted-foreground`,r),title:a,children:[t&&(0,L.jsx)(kx,{presence:t}),i&&(0,L.jsx)(jx,{availability:i.availability,...n===`hover`&&a&&{title:a}}),i&&n===`hover`&&i.availability===`automatic`&&a&&(0,L.jsx)(`span`,{role:`img`,"aria-label":a,className:`size-1.5 shrink-0 rounded-full bg-faint-foreground`}),a&&n===`full`&&(0,L.jsx)(`span`,{className:`truncate text-xs`,children:a})]})},Nx=(e,t)=>e.map(e=>{let n=t&&Object.hasOwn(t,e.id)?t[e.id]:void 0;return n?{...e,mark:n}:e}),Px=e=>{if(!e)return[];let t=bi(e.status);return[e.presence&&Ox(e.presence),t&&t.availability!==`automatic`?Ax(t.availability):void 0,t?.text??void 0]},Fx=e=>{let t=[e.status?.label,...Px(e.mark?.person),e.mark?.label].filter(e=>e!==void 0&&e!==``);return{ariaLabel:[e.label,...t].join(`, `),title:t.length===0?e.label:`${e.label} (${t.join(`, `)})`}},Ix=({records:e,mode:t,onNavigate:n})=>e.map(e=>{let{ariaLabel:r,title:i}=Fx(e),a=n&&(t=>{t.preventDefault(),n(e.href)}),o=e.mark?.strong===!0;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`a`,{href:e.href,onClick:a,"aria-label":r,title:i,"aria-current":e.active?`page`:void 0,className:R(`flex min-w-0 items-center rounded-md transition-colors`,lx[t],o?`font-bold`:`font-medium`,e.active||o?`text-foreground`:`text-muted-foreground`,e.active?`bg-muted`:`hover:bg-muted hover:text-foreground`),children:[e.status&&(0,L.jsx)(Dx,{tone:e.status.tone,pulse:e.status.pulse}),(0,L.jsx)(`span`,{className:`truncate`,children:e.label}),e.mark?.person&&(0,L.jsx)(Mx,{...e.mark.person,textShown:`hover`,className:`ml-1.5 shrink-0`}),(0,L.jsx)(wx,{count:e.mark?.count,className:`ml-auto shrink-0`})]})},e.id)}),Lx=({records:e,useMarks:t,...n})=>(0,L.jsx)(Ix,{records:Nx(e,t()),...n}),Rx=({records:e,useMarks:t,mode:n,onNavigate:r})=>t?(0,L.jsx)(Lx,{records:e,useMarks:t,mode:n,onNavigate:r}):(0,L.jsx)(Ix,{records:e,mode:n,onNavigate:r}),zx=({item:e,recent:t,mode:n,active:r,onNavigate:i})=>{let a=px(e.id),[o,s]=(0,M.useState)(()=>mx(localStorage,a)),c=(0,M.useId)(),l=e.href??`#${e.id}`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(xx,{item:e,mode:n,active:r,onNavigate:i,className:`pr-8`}),(0,L.jsx)(`button`,{type:`button`,"aria-expanded":o,"aria-controls":c,"aria-label":V(`recent`,{plural:e.label.toLowerCase()}),onClick:()=>{hx(localStorage,a,!o),s(!o)},className:`absolute right-1 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground`,children:(0,L.jsx)(ns,{className:R(`size-3.5 transition-transform`,o&&`rotate-90`)})})]}),o&&(0,L.jsxs)(`ul`,{id:c,"aria-label":V(`recent`,{plural:e.label.toLowerCase()}),className:R(`flex flex-col gap-0.5 border-l pl-1.5`,ux[n]),children:[t.state===`loading`&&(0,L.jsx)(`li`,{role:`status`,"aria-label":V(`loading`),className:R(`flex items-center`,lx[n]),children:(0,L.jsx)(Su,{className:`w-3/4`})}),t.state===`error`&&(0,L.jsx)(`li`,{className:R(`flex items-center text-faint-foreground`,lx[n]),children:V(`couldNotLoad`)}),t.state===`ready`&&(0,L.jsx)(Rx,{records:t.records,useMarks:t.useMarks,mode:n,onNavigate:i}),(0,L.jsx)(`li`,{children:(0,L.jsx)(`a`,{...(e=>({href:e,onClick:i&&(t=>{t.preventDefault(),i(e)})}))(l),className:R(`flex items-center rounded-md text-faint-foreground transition-colors hover:bg-muted hover:text-foreground`,lx[n]),children:V(`viewAll`)})})]})]})},Bx=({mode:e,activeItem:t,user:n,workspace:r,appName:i,appIcon:a,forceExpanded:o,profileMenuOpen:s,groups:c=[],userMenu:l,account:u,onNavigate:d,onSignOut:f,signIn:p,organizations:m,roles:h,theme:g,status:_,sticky:v,logo:y=yb,notice:b,fill:x,page:S,search:C,accountInTopBar:w})=>{let T=e===`icon-expand`,E=T&&o,D=vx(e)||T;return(0,L.jsx)(`nav`,{"aria-label":V(`resources`),className:S?`w-full`:R(v?`sticky top-0 h-dvh self-start`:`relative`,`z-30 shrink-0`,x?`w-full`:yx[e]),children:(0,L.jsxs)(`div`,{className:R(S?`group/side flex flex-col bg-sidebar`:`group/side absolute inset-y-0 left-0 flex flex-col overflow-hidden border-r bg-sidebar pb-[var(--pb-safe-bottom)] pt-[var(--pb-safe-top)]`,T?`w-14 transition-[width,box-shadow] duration-150 hover:w-60 hover:shadow-pop focus-within:w-60 focus-within:shadow-pop`:`w-full`,E&&`w-60 shadow-pop`),children:[!S&&(0,L.jsx)(`div`,{className:R(`flex h-12 shrink-0 items-center px-3.5`,e===`icon-label`&&`justify-center px-0`),onClick:()=>xb(),children:(0,L.jsx)(y,{compact:!D,workspace:r,appName:i,appIcon:a})}),C&&(0,L.jsx)(`div`,{className:`px-5 pt-3 pb-3`,children:(0,L.jsx)(Ib,{search:C,className:`w-full`,showShortcut:!1,inline:!0})}),(!C||C.query===``&&!C.loading)&&(0,L.jsx)(`div`,{className:R(S?`pb-2`:`flex-1 overflow-y-auto overflow-x-hidden pb-2`,`px-2`),children:c.map((n,r)=>(0,L.jsxs)(`div`,{className:R(`flex flex-col gap-0.5`,r>0&&`mt-3`),children:[D?n.label&&(0,L.jsx)(`h2`,{className:R(`px-3 pb-1 pt-1 text-xs font-medium uppercase tracking-wide text-faint-foreground`,T&&`h-4 whitespace-nowrap py-0 opacity-0 transition-opacity group-hover/side:opacity-100 group-focus-within/side:opacity-100`,E&&`opacity-100`),children:n.label}):(0,L.jsxs)(L.Fragment,{children:[n.label&&(0,L.jsx)(`h2`,{className:`sr-only`,children:n.label}),r>0&&(0,L.jsx)(`div`,{className:`mx-auto mb-1 h-px w-6 bg-border`})]}),n.items.map(n=>(0,L.jsxs)(M.Fragment,{children:[n.recent&&vx(e)?(0,L.jsx)(zx,{item:n,recent:n.recent,mode:e,active:n.id===t,onNavigate:d}):(0,L.jsx)(xx,{item:n,mode:e,active:n.id===t,onNavigate:d}),n.create&&vx(e)&&(0,L.jsx)(dx,{create:n.create,mode:e,onNavigate:d})]},n.id))]},n.label))}),b,!(S&&n)&&(0,L.jsx)(`div`,{className:R(`shrink-0 border-t p-2 empty:hidden`,e!==`text-large`&&e!==`text-small`&&!T&&`flex justify-center`),children:n&&w?null:n?(0,L.jsx)(cx,{user:n,compact:!D,open:s,items:l,account:u,onNavigate:d,onSignOut:f,organizations:m,roles:h,theme:g,status:_}):(0,L.jsxs)(L.Fragment,{children:[g&&D&&(0,L.jsx)(qb,{theme:g,className:`flex min-h-11 w-full items-center gap-2.5 whitespace-nowrap p-1.5 text-muted-foreground md:min-h-0`}),p&&!S&&!w&&(0,L.jsxs)(Du,{to:p,"aria-label":V(`signIn`),className:`flex min-h-11 w-full items-center gap-2.5 rounded-md p-1.5 text-left font-medium text-muted-foreground hover:bg-muted hover:text-foreground md:min-h-0`,children:[(0,L.jsx)(uc,{className:`size-4 shrink-0`}),D&&(0,L.jsx)(`span`,{className:`whitespace-nowrap`,children:V(`signIn`)})]})]})})]})})},Vx=e=>ly()&&vx(e),Hx=(0,M.createContext)(null),Ux=()=>(0,M.useContext)(Hx),Wx=`/-/menu`,Gx=(e,t,{starting:n,morePage:r})=>e===`/-/menu`&&(n||!r)?t??`/`:void 0,Kx=e=>{(0,M.useLayoutEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`background-color`,`var(--color-sidebar)`),document.body.style.setProperty(`background-color`,`var(--color-sidebar)`),()=>{t.style.removeProperty(`background-color`),document.body.style.removeProperty(`background-color`)}},[e])},qx=({desktop:e,tabs:t,menuPage:n})=>e||!t||t.length===0||!n?{on:!1}:{on:!0,href:n.href,shown:n.shown,onTab:t.some(e=>e.active)},Jx=(e,t)=>qx({desktop:ly(),tabs:e,menuPage:t}),Yx=e=>!e,Xx=e=>!e,Zx=({desktop:e,more:t,inBottomBar:n})=>e||!t?`top-bar`:n?`bottom-bar`:`more-page`,Qx=e=>{let t=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0});if(!t)return e;t.fillStyle=e,t.fillRect(0,0,1,1);let[n,r,i]=t.getImageData(0,0,1,1).data;return`rgb(${n}, ${r}, ${i})`},$x=(e,t)=>{(0,M.useEffect)(()=>{let n=ng(window);if(!e||!t.current||!n?.isPluginAvailable(`SystemBars`))return;let r=Cb(Qx(getComputedStyle(t.current).backgroundColor));return n.nativePromise(`SystemBars`,`setStyle`,{style:r}),()=>void n.nativePromise(`SystemBars`,`setStyle`,{style:`DEFAULT`})},[e,t])},eS=({user:e,signIn:t,onBrand:n,...r})=>!e&&!t?null:(0,L.jsx)(`div`,{className:`flex shrink-0 items-center justify-end`,onClick:e=>e.stopPropagation(),children:e?(0,L.jsx)(cx,{user:e,compact:!0,inTopBar:!0,label:V(`accountOf`,{name:e.name}),...r}):t&&(0,L.jsx)(Du,{to:t,"aria-label":V(`signIn`),className:R(`size-[min(2.75rem,max(44px,13vw))] shrink-0`,`flex items-center justify-center rounded-full hover:bg-muted`),children:(0,L.jsx)(`span`,{className:R(`flex size-[min(2rem,max(32px,9vw))] items-center justify-center rounded-full`,n?`bg-primary-foreground/20 text-primary-foreground`:`bg-muted text-muted-foreground`),children:(0,L.jsx)(Jl,{className:`size-[min(1.25rem,max(20px,6vw))]`,"aria-hidden":!0})})})}),tS=`app-drawer`,nS={refreshing:`[animation:pb-stale_1.4s_ease-in-out_infinite] motion-reduce:[animation:none] motion-reduce:opacity-60`,failed:`opacity-60`},rS=({sidebarMode:e,activeItem:t,breadcrumb:n,titleStatus:r,staleContent:i,user:a,workspace:o,appName:s,appIcon:c,logo:l,actions:u,rightPanel:d,sidebarNotice:f,banner:p,forceExpanded:m,profileMenuOpen:h,navGroups:g,userMenu:_,account:v,bottomBar:y,menuPage:b,bottomBarSearch:x,onNavigate:S,onBack:C,backIsHistory:w,onSignOut:T,signIn:E,organizations:D,roles:O,theme:k,status:A,search:ee,pageScroll:te=!1,className:ne,overlays:re,children:ie})=>{let j=ly(),ae=Vx(e),[N,oe]=(0,M.useState)(!1),[se,ce]=(0,M.useState)(!1),le=(0,M.useRef)(null),ue=(0,M.useCallback)(()=>{oe(!1),ce(!1)},[]);(0,M.useEffect)(()=>{j&&ue()},[j,ue]),Ty(ue);let de=!j&&y&&y.length>0?y:void 0,P=Jx(de,b),fe=Yx(j),pe=Xx(j),me=P.on&&S?()=>S(P.href):()=>oe(!0),he=P.on&&P.shown;Kx(he);let[ge,_e]=(0,M.useState)(!1),ve=(0,M.useRef)(null),ye=l??yb;$x(pe,ve);let be=ee&&Zx({desktop:j,more:P.on,inBottomBar:!!x}),xe=be===`bottom-bar`,Se=()=>_e(!0),Ce=P.on?P.shown?[V(`more`)]:P.onTab?n:[{label:V(`more`),href:P.href},...n]:n,we=P.on&&!!de?.[0]?.shown,Te=By(Ce),Ee=Uy(Vy({desktop:j,back:!!Te,bottomBar:!!de,drawerOpen:N}),{nativeBack:Ky(),behindIsBack:Te!==void 0&&!!w?.(Te.href)});qy(Ee,JSON.stringify(Ce));let[De,Oe]=(0,M.useState)(),ke=De??te,Ae=(0,M.useRef)(null);$y({action:Ee,onBack:()=>Te&&(C??S)?.(Te.href),openDrawer:()=>{ce(!0),oe(!0)},closeDrawer:ue,drawer:le});let[je,Me]=(0,M.useState)(null),Ne=(0,M.useRef)(null);ib(ke,Ae,Ne,!!de),nb(ke);let Pe=e=>(0,L.jsx)(Bx,{...e,accountInTopBar:fe,...e.page&&ee&&be===`more-page`&&{search:ee},activeItem:t,user:a,workspace:o,appName:s,appIcon:c,forceExpanded:m,profileMenuOpen:h,groups:g,userMenu:_,account:v,onNavigate:S,onSignOut:T,signIn:E,organizations:D,roles:O,theme:k,status:A,logo:l});return(0,L.jsxs)(eb.Provider,{value:Oe,children:[(0,L.jsx)(`span`,{ref:ve,"aria-hidden":!0,className:`hidden bg-primary`}),(0,L.jsxs)(`div`,{className:R(ke?`flex min-h-full w-full overflow-x-clip`:`relative flex h-full min-h-0 w-full overflow-hidden`,he?`bg-sidebar`:`bg-background`,ne),children:[j?Pe({mode:e,sticky:ke,notice:ae&&f}):(0,L.jsx)(zy,{id:tS,open:N,onClose:ue,underFinger:se,control:le,children:Pe({mode:`text-large`,fill:!0})}),(0,L.jsxs)(`div`,{className:R(`flex min-w-0 flex-1 flex-col`,!de&&`pb-[var(--pb-safe-bottom)]`),children:[(0,L.jsx)(Vb,{ref:Ae,slotRef:Me,sticky:ke,breadcrumb:Ce,titleStatus:r,onNavigate:S,onBack:C,actions:u,brand:pe,backInLeadingSlot:pe,...we&&{leading:(0,L.jsx)(`div`,{className:`flex min-w-0 items-center`,onClick:()=>xb(),children:(0,L.jsx)(ye,{compact:!1,workspace:o,appName:s,appIcon:c})})},account:fe&&(0,L.jsx)(eS,{onBrand:pe,user:a,signIn:E,open:h,items:_,account:v,onNavigate:S,onSignOut:T,organizations:D,roles:O,theme:k,status:A}),searchButton:be===`top-bar`,searchOpen:ge,onSearchOpenChange:_e,onMenu:j||de?void 0:()=>oe(!0),menuOpen:N,menuControls:tS,search:ee}),p,(0,L.jsx)(`main`,{className:R(ke?`flex flex-1 flex-col`:`flex min-h-0 flex-1 flex-col`,i&&nS[i]),"aria-busy":i===`refreshing`||void 0,children:(0,L.jsxs)(Hx.Provider,{value:je,children:[he?Pe({mode:`text-large`,page:!0}):ie,re]})}),de&&(0,L.jsx)(Cy,{ref:Ne,sticky:ke,tabs:de,onNavigate:S,...xe&&{onSearch:Se,searchLabel:x===!0?void 0:x},onMore:me,moreOpen:N,moreControls:tS})]}),d&&(0,L.jsx)(`div`,{className:ke?`sticky top-0 flex h-dvh shrink-0 self-start pt-[var(--pb-safe-top)]`:`flex shrink-0`,children:d})]})]})},iS=`protobase:signed-out`,aS=(e=window)=>{e.dispatchEvent(new Event(iS)),e.parent&&e.parent!==e&&e.parent.postMessage({type:iS},`*`)},oS=4194304,sS=(e,t=oS)=>{let n=e.reduce((e,t)=>e+t.bytes,0),r=new Set(e.map(e=>e.hash)),i=e.filter(e=>!e.pinned).sort((e,t)=>e.lastUsed-t.lastUsed);for(let e of i){if(n<=t)break;r.delete(e.hash),n-=e.bytes}return r},cS=new TextEncoder,lS=e=>cS.encode(JSON.stringify(e)??``).length,uS=1e3,dS=JSON.stringify(I.meta),fS=e=>e.state.status===`success`&&e.state.fetchFailureCount===0&&!(e.queryHash===dS&&e.state.data?.versionChange),pS=(e,t,n,r,i,a=oS)=>{let o=T(e,{shouldDehydrateQuery:fS}).queries,s=new Set(o.map(e=>e.queryHash)),c=[...o,...t.filter(e=>!s.has(e.queryHash))],l=e=>n[e.queryHash]??e.state.dataUpdatedAt,u=sS(c.map(e=>({hash:e.queryHash,bytes:e.queryHash.length+r(e.state.data),lastUsed:l(e),pinned:e.queryHash===dS||i.has(e.queryHash)})),a),d=c.filter(e=>u.has(e.queryHash));return{queries:d,used:Object.fromEntries(d.map(e=>[e.queryHash,l(e)]))}},mS=({cache:e,owner:t})=>{let n=e.queries(t),r={...n?.used},i=n?.state.queries??[],a=new WeakMap,o=e=>{if(typeof e!=`object`||!e)return lS(e);let t=a.get(e);if(t!==void 0)return t;let n=lS(e);return a.set(e,n),n};return{restore:e=>{n&&(ne(e,n.state),e.invalidateQueries({refetchType:`none`}))},subscribe:n=>{let a,s=()=>{a=void 0;let s=Date.now(),c=new Set(n.getQueryCache().findAll({type:`active`}).map(e=>e.queryHash));for(let e of c)r[e]=s;let l=pS(n,i,r,o,c);i=l.queries,r=l.used,e.saveQueries({owner:t,used:r,state:{mutations:[],queries:i}})},c=n.getQueryCache().subscribe(e=>{if(e.type===`observerAdded`)r[e.query.queryHash]=Date.now();else if(e.type!==`added`&&e.type!==`removed`&&e.type!==`updated`)return;a??=setTimeout(s,uS)});return()=>{c(),clearTimeout(a)}}}},hS=(e,t)=>e.replace(/\D/g,``).slice(0,t),gS=(e,t,n)=>{let r=hS(t??``,n);return r.length===n?r:hS(e,n)},_S=(e,t,n,r)=>{let i=t.replace(/\D/g,``);return i.length>=r?i.slice(0,r):hS(e.slice(0,n)+i+e.slice(n+i.length),r)},vS=({value:e,onChange:t,onComplete:n,length:r=6,invalid:i,disabled:a,className:o,ref:s,onFocus:c,onBlur:l,onSelect:u,onKeyDown:d,onClick:f,onPaste:p,...m})=>{let h=(0,M.useRef)(null),[g,_]=(0,M.useState)(!1),[v,y]=(0,M.useState)(e.length),b=e.slice(0,r),x=Math.min(v,r-1),S=e=>{h.current=e,typeof s==`function`?s(e):s&&(s.current=e)},C=e=>{e!==b&&(t(e),e.length===r&&n?.(e))},w=e=>{let t=h.current;if(!t)return;let n=Math.max(0,Math.min(e,b.length));t.setSelectionRange(n,n<b.length?n+1:n),y(n)},T=e=>{if(d?.(e),e.defaultPrevented||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey)return;let t=e.currentTarget.selectionStart??b.length,n={ArrowLeft:t-1,ArrowRight:t+1,Home:0,End:b.length}[e.key];n!==void 0&&(e.preventDefault(),w(n))},E=e=>{f?.(e);let t=e.currentTarget.getBoundingClientRect();e.clientX<=t.left||e.clientX>=t.right||w(Math.floor((e.clientX-t.left)/t.width*r))};return(0,L.jsxs)(`div`,{className:R(`relative`,a&&`opacity-50`,o),children:[(0,L.jsx)(`div`,{"aria-hidden":!0,className:`flex justify-center gap-2`,children:Array.from({length:r},(e,t)=>{let n=g&&t===x;return(0,L.jsx)(`div`,{"data-slot":t,"data-digit":b[t],className:R(`flex h-12 min-w-0 max-w-12 flex-1 items-center justify-center rounded-md border bg-background font-mono text-xl font-semibold text-foreground shadow-sm transition-colors before:content-[attr(data-digit)]`,i?`border-danger`:n?`border-primary`:`border-border-strong`,n&&(i?`ring-2 ring-danger/20`:`ring-2 ring-primary/20`)),children:b[t]===void 0&&(n?(0,L.jsx)(`span`,{className:`h-6 w-px animate-pulse bg-foreground`}):(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-border-strong`}))},t)})}),(0,L.jsx)(`input`,{ref:S,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,pattern:`[0-9]{${r}}`,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,"aria-invalid":i||void 0,disabled:a,value:b,className:`absolute inset-0 size-full cursor-text bg-transparent text-transparent caret-transparent outline-none selection:bg-transparent disabled:cursor-not-allowed`,...m,onChange:e=>{let{data:t,dataTransfer:n}=e.nativeEvent;C(gS(e.target.value,t??n?.getData(`text/plain`),r))},onPaste:e=>{if(p?.(e),e.defaultPrevented)return;e.preventDefault();let t=e.currentTarget,n=_S(b,e.clipboardData.getData(`text`),t.selectionStart??b.length,r);C(n),y(n.length)},onSelect:e=>{u?.(e);let t=e.currentTarget,n=t.selectionStart??b.length;n===t.selectionEnd&&n<t.value.length&&t.setSelectionRange(n,n+1),y(n)},onKeyDown:T,onClick:E,onFocus:e=>{_(!0),c?.(e)},onBlur:e=>{_(!1),l?.(e)}})]})},yS=F(`app/create`),bS=({address:e,page:t,accountPage:n,resourceLabel:r,singular:i,recordTitle:a,recordLoading:o})=>{if(t)return t.tab?[t.tab,t.title]:[t.title];if(n)return[n];if(!e||e.kind===`page`)return[];let s=r?[r]:[];if(e.kind===`list`)return s;if(e.kind===`create`)return[...i?[yS(`title`,{noun:i})]:[],...s];let c=a??(o?void 0:e.key);return[...c?[c]:[],...s]},xS=(e,t)=>[...e.filter(Boolean),t].join(` · `),SS=e=>{(0,M.useEffect)(()=>{if(e===void 0)return;let t=document.title;return document.title=e,()=>{document.title=t}},[e])},CS=({title:e,description:t,size:n=`sm`,appName:r,icon:i,footer:a,children:o})=>{let s=l_()?.identity;return SS(s?.appName),(0,L.jsxs)(`div`,{className:`flex min-h-full w-full flex-col items-center bg-background px-4 pb-[calc(2.5rem+var(--pb-safe-bottom))] pt-[calc(2.5rem+var(--pb-safe-top))] short:pb-[calc(1rem+var(--pb-safe-bottom))] short:pt-[calc(1rem+var(--pb-safe-top))]`,children:[(0,L.jsx)(`div`,{className:`flex w-full flex-1 items-center justify-center`,children:(0,L.jsxs)(`div`,{className:R(`w-full`,n===`sm`?`max-w-sm`:`max-w-lg`),children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col items-center text-center short:mb-4`,children:[(0,L.jsx)(gb,{appName:r??s?.appName,appIcon:i??s?.appIcon,size:`lg`,className:`short:hidden`}),(0,L.jsx)(`h1`,{className:`mt-4 text-xl font-semibold tracking-tight short:mt-0`,children:e}),t&&(0,L.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]}),(0,L.jsx)(`div`,{className:`rounded-lg border bg-background p-5 shadow-sm`,children:o})]})}),a]})},Z=F(`auth`),wS=({onResend:e,cooldown:t=30,disabled:n})=>{let[r,i]=(0,M.useState)(()=>Date.now()+t*1e3),[a,o]=(0,M.useState)(()=>Date.now()),s=Math.max(0,Math.ceil((r-a)/1e3));return(0,M.useEffect)(()=>{if(s===0)return;let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[s]),(0,L.jsx)(B,{variant:`ghost`,disabled:n||s>0,onClick:()=>{let n=Date.now();i(n+t*1e3),o(n),e()},className:`min-h-10`,children:s>0?Z(`sendNewCodeIn`,{seconds:s}):Z(`sendNewCode`)})},TS=({title:e,description:t,explanation:n,submitLabel:r,onSubmit:i,onResend:a,onChangeAddress:o,changeAddressLabel:s,busy:c,error:l,notice:u,resendCooldown:d})=>{let[f,p]=(0,M.useState)(``),m=(0,M.useRef)(null);return(0,M.useEffect)(()=>{u&&(p(``),m.current?.focus())},[u]),(0,L.jsxs)(CS,{title:e,description:t,children:[(0,L.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:n}),u&&(0,L.jsx)(`p`,{role:`status`,className:`mb-4 rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:u}),(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),i(f)},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`code`),(0,L.jsx)(vS,{ref:m,name:`code`,required:!0,autoFocus:!0,value:f,invalid:!!l,onChange:p,onComplete:e=>!c&&i(e)})]}),l&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:l}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:c,className:`min-h-10`,children:r}),(0,L.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-x-2 sm:justify-between`,children:[(0,L.jsx)(B,{variant:`ghost`,onClick:o,className:`min-h-10`,children:s}),(0,L.jsx)(wS,{onResend:a,disabled:c,cooldown:d})]})]})]})},ES=({email:e,onBack:t,...n})=>(0,L.jsx)(TS,{title:Z(`checkEmail`),description:Z(`signInCodeDescription`),explanation:(0,L.jsx)(L.Fragment,{children:Z.rich(`signInCodeSent`,{email:(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e}),minutes:10})}),submitLabel:Z(`signIn`),onChangeAddress:t,changeAddressLabel:Z(`backToSignIn`),...n}),DS=({email:e,onBack:t})=>{let{signInWithCode:n,sendSignInCode:r}=J(),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(),[c,l]=(0,M.useState)(),u=async e=>{a(!0),s(void 0),l(void 0);try{await e()}catch(e){if(!(e instanceof K))throw e;s(Iv(e))}a(!1)};return(0,L.jsx)(ES,{email:e,busy:i,error:o,notice:c,onBack:t,onSubmit:t=>void u(()=>n(e,t)),onResend:()=>void u(async()=>{await r(e),l(Z(`newCodeSent`))})})},OS=`protobase users create you@example.com`,kS=({command:e=OS,firstAdminUrl:t,onCheckAgain:n,busy:r})=>(0,L.jsxs)(CS,{title:Z(`noAdminTitle`),description:Z(`noAdminDescription`),children:[t?(0,L.jsx)(AS,{url:t}):(0,L.jsx)(jS,{command:e}),(0,L.jsx)(B,{variant:t?`secondary`:`primary`,className:`mt-4 min-h-10 w-full`,loading:r,onClick:n,children:Z(`reload`)})]}),AS=({url:e})=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`firstAdminExplanation`)}),(0,L.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:R(hu({variant:`primary`}),`mt-4 min-h-10 w-full`),children:[Z(`firstAdminLink`),(0,L.jsx)(Ms,{className:`size-4`})]})]}),jS=({command:e})=>{let[t,n]=(0,M.useState)(!1);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`noAdminExplanation`)}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-md border bg-surface py-1.5 pl-3 pr-1.5`,children:[(0,L.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-xs`,children:e}),(0,L.jsx)(`button`,{type:`button`,"aria-label":Z(`copyCommand`),onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},className:`inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted pointer-coarse:size-11`,children:t?(0,L.jsx)(Xo,{className:`size-4 text-success`}):(0,L.jsx)(gs,{className:`size-4`})})]})]})},MS=({onSubmit:e,back:t,busy:n,error:r,sentTo:i})=>{let[a,o]=(0,M.useState)(``);return i?(0,L.jsxs)(CS,{title:Z(`checkEmail`),children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z.rich(`resetSent`,{email:(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:i})})}),(0,L.jsx)(Du,{to:t,className:R(hu({variant:`primary`}),`mt-4 min-h-10 w-full`),children:Z(`backToSignIn`)})]}):(0,L.jsx)(CS,{title:Z(`resetTitle`),description:Z(`resetDescription`),children:(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(a.trim())},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`email`),(0,L.jsx)(Eb,{type:`email`,name:`email`,autoComplete:`username`,required:!0,autoFocus:!0,value:a,invalid:!!r,onChange:e=>o(e.target.value),className:`min-h-6`})]}),r&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:r}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:n,className:`min-h-10`,children:Z(`sendResetLink`)}),(0,L.jsx)(Du,{to:t,className:R(hu({variant:`ghost`}),`min-h-10`),children:Z(`backToSignIn`)})]})})},NS=`password-reset`,PS=e=>{let t=new URL(e);return`${t.origin}${t.pathname}?${NS}`},FS=e=>{let t=new URL(e).searchParams;if(t.has(`password-reset`))return{token:t.get(`token`)||void 0}},IS=e=>{let t=new URL(e);for(let e of[NS,`token`,`error`])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},LS=({back:e})=>{let{session:t}=J(),[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(),[o,s]=(0,M.useState)(),c=async e=>{r(!0),a(void 0);try{await t.requestPasswordReset(e,PS(window.location.href)),s(e)}catch(e){if(!(e instanceof K))throw e;a(e.status===429?Z(`tooManyRequests`):e.message)}r(!1)};return(0,L.jsx)(MS,{busy:n,error:i,sentTo:o,back:e,onSubmit:e=>void c(e)})},RS=({name:e,workspace:t})=>(0,L.jsx)(CS,{title:Z(`signingInWith`,{name:e}),description:t,children:(0,L.jsxs)(`p`,{role:`status`,className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{}),` `,Z(`takingYouTo`,{name:e})]})}),zS=({provider:e,workspace:t,onFailed:n})=>{let{signInProviders:r,signInSocial:i}=J(),a=r.find(t=>t.id===e),o=a?.name??Qg(e),s=(0,M.useRef)(!1);return(0,M.useEffect)(()=>{if(!s.current){if(s.current=!0,!a)return n(Z(`providerNotOffered`,{name:o}));i(e).catch(e=>{if(!(e instanceof K))throw e;n(Rv(e))})}},[a,o,e,i,n]),(0,L.jsx)(RS,{name:o,workspace:t})},BS=({onSubmit:e,invalidLink:t,onRequestNewLink:n,onBack:r,busy:i,error:a})=>{let[o,s]=(0,M.useState)(``),[c,l]=(0,M.useState)(``),[u,d]=(0,M.useState)(!1);if(t)return(0,L.jsxs)(CS,{title:Z(`linkExpiredTitle`),children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`linkExpiredExplanation`)}),(0,L.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[n&&(0,L.jsx)(B,{variant:`primary`,className:`min-h-10`,onClick:n,children:Z(`sendNewLink`)}),(0,L.jsx)(B,{variant:n?`ghost`:`primary`,className:`min-h-10`,onClick:r,children:Z(`backToSignIn`)})]})]});let f=u?Z(`passwordsDiffer`):a;return(0,L.jsx)(CS,{title:Z(`choosePassword`),description:Z(`atLeast`,{length:12}),children:(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),d(o!==c),o===c&&e(o)},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`newPassword`),(0,L.jsx)(Eb,{type:`password`,name:`new-password`,autoComplete:`new-password`,required:!0,minLength:12,autoFocus:!0,value:o,invalid:!!f,onChange:e=>s(e.target.value),className:`min-h-6`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`repeatPassword`),(0,L.jsx)(Eb,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,required:!0,minLength:12,value:c,invalid:!!f,onChange:e=>l(e.target.value),className:`min-h-6`})]}),f&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:Z(`setPassword`)})]})})},VS=e=>e.status===429?Z(`tooManyAttempts`):e.code===`PASSWORD_TOO_SHORT`?Z(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?Z(`passwordTooLong`):Iv(e),HS=({token:e,onDone:t,onRequestNewLink:n,onBack:r})=>{let{session:i}=J(),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(),[l,u]=(0,M.useState)(!e),d=async n=>{o(!0),c(void 0);try{await i.resetPassword(e,n),t()}catch(e){if(!(e instanceof K))throw e;e.code===`INVALID_TOKEN`?u(!0):c(VS(e)),o(!1)}};return(0,L.jsx)(BS,{busy:a,error:s,invalidLink:l,onRequestNewLink:n,onBack:r,onSubmit:e=>void d(e)})},US=F(`app/confirm-sign-in`),WS=({minutes:e,purpose:t=`show`,withPassword:n=!1,onConfirmed:r})=>{let i=l_(),[a,o]=(0,M.useState)(``),[s,c]=(0,M.useState)(``),[l,u]=(0,M.useState)(``),[d,f]=(0,M.useState)(!1),p=O({queryKey:[`account-sign-in-methods`],queryFn:()=>i.session.account.signInMethods(),enabled:!!i}),m=S({mutationFn:()=>i.signInWithPasskey(),onSuccess:r}),h=S({mutationFn:e=>i.verifyTwoFactor({method:`totp`,code:e}),onSuccess:r}),g=p.data?.account,_=g?g.twoFactor&&!g.authenticatorApp?`second-step`:p.data?.mail&&g.passkeys===0&&!g.twoFactor?`confirmation`:void 0:void 0,v=n&&g!==void 0&&g.password&&g.passkeys===0&&!g.twoFactor,y=S({mutationFn:e=>i.session.account.confirmWithPassword(e),onSuccess:r}),b=S({mutationFn:async e=>{_===`second-step`?await i.verifyTwoFactor({method:`otp`,code:e}):await i.session.account.confirmWithCode(e)},onSuccess:r}),x=S({mutationFn:()=>_===`second-step`?i.session.sendTwoFactorCode():i.session.account.sendConfirmationCode(),onSuccess:()=>{f(!0),u(``),b.reset()}}),C=m.error??h.error??y.error??x.error??b.error??p.error;return(0,L.jsxs)(`section`,{"aria-label":US(`confirmTitle`),className:`mt-2 flex flex-col gap-2 rounded-md border border-border bg-surface p-3`,children:[(0,L.jsx)(`p`,{className:`font-medium`,children:US(`confirmTitle`)}),(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:US(t===`change`?`confirmWhyChange`:`confirmWhy`,{minutes:e})}),g&&g.passkeys>0&&(0,L.jsx)(B,{variant:`primary`,size:`sm`,className:`self-start`,loading:m.isPending,onClick:()=>m.mutate(),children:US(`usePasskey`)}),g?.authenticatorApp&&(0,L.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),h.mutate(a.trim())},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[US(`authenticatorCode`),(0,L.jsx)(vS,{name:`code`,required:!0,value:a,invalid:h.isError,onChange:o,onComplete:e=>h.mutate(e)})]}),(0,L.jsx)(B,{type:`submit`,size:`sm`,loading:h.isPending,children:US(`confirm`)})]}),v&&(0,L.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),y.mutate(s)},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[US(`password`),(0,L.jsx)(Eb,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:s,onChange:e=>c(e.target.value)})]}),(0,L.jsx)(B,{type:`submit`,size:`sm`,loading:y.isPending,children:US(`confirm`)})]}),_&&!d&&(0,L.jsx)(B,{variant:`primary`,size:`sm`,className:`self-start`,loading:x.isPending,onClick:()=>x.mutate(),children:US(`emailCode`)}),_&&d&&(0,L.jsxs)(`form`,{className:`flex flex-col gap-2`,onSubmit:e=>{e.preventDefault(),b.mutate(l.trim())},children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:US(`codeSent`,{minutes:10})}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[US(`emailedCode`),(0,L.jsx)(vS,{name:`code`,required:!0,value:l,invalid:b.isError,onChange:u,onComplete:e=>b.mutate(e)})]}),(0,L.jsx)(B,{type:`submit`,size:`sm`,loading:b.isPending,children:US(`confirm`)}),(0,L.jsx)(B,{size:`sm`,variant:`ghost`,loading:x.isPending,onClick:()=>x.mutate(),children:US(`emailNewCode`)})]})]}),g&&g.passkeys===0&&!g.authenticatorApp&&_===void 0&&!v&&(0,L.jsx)(`p`,{children:US(`nothingToConfirmWith`)}),C&&(0,L.jsx)(`p`,{role:`alert`,className:`font-medium text-danger-text`,children:C.message})]})},GS=(e,t,n=`text/plain`)=>{let r=URL.createObjectURL(new Blob([e],{type:n}));Object.assign(document.createElement(`a`),{href:r,download:t}).click(),URL.revokeObjectURL(r)},KS=({codes:e})=>{let[t,n]=(0,M.useState)(!1),r=`${e.join(`
3
- `)}\n`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`ul`,{"aria-label":Y(`backupCodes`),className:`grid grid-cols-2 gap-x-4 gap-y-1 rounded-md border bg-surface p-3 font-mono`,children:e.map(e=>(0,L.jsx)(`li`,{children:e},e))}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsxs)(B,{size:`sm`,onClick:()=>{navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},children:[t?(0,L.jsx)(Xo,{className:`size-3.5 text-success`}):(0,L.jsx)(gs,{className:`size-3.5`}),Y(t?`copied`:`copy`)]}),(0,L.jsxs)(B,{size:`sm`,onClick:()=>GS(r,`backup-codes.txt`),children:[(0,L.jsx)(ws,{className:`size-3.5`}),Y(`download`)]})]})]})},qS=({uri:e,className:t})=>{let{size:n,path:r}=(0,M.useMemo)(()=>{let t=D(e,{ecc:`M`,border:2}),n=t.data.flatMap((e,t)=>e.flatMap((e,n)=>e?[`M${n} ${t}h1v1h-1z`]:[]));return{size:t.size,path:n.join(``)}},[e]);return(0,L.jsxs)(`svg`,{viewBox:`0 0 ${n} ${n}`,role:`img`,"aria-label":Y(`qrCode`),shapeRendering:`crispEdges`,className:t,children:[(0,L.jsx)(`rect`,{width:n,height:n,fill:`#fff`}),(0,L.jsx)(`path`,{d:r,fill:`#000`})]})},JS=e=>(new URL(e).searchParams.get(`secret`)??``).replace(/(.{4})(?=.)/g,`$1 `),YS=()=>[{value:`app`,label:Y(`authenticatorApp`),description:Y(`authenticatorAppDescription`)},{value:`email`,label:Y(`emailedCode`),description:Y(`emailedCodeDescription`)}],XS=({offerEmailedCodes:e,needsPassword:t,onStartApp:n,onConfirmApp:r,onEmailedCodes:i,onDone:a,onCancel:o})=>{let[s,c]=(0,M.useState)({kind:`choose`}),[l,u]=(0,M.useState)(`app`),[d,f]=(0,M.useState)(``),[p,m]=(0,M.useState)(``),[h,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(),[y,b]=(0,M.useState)(!1),x=e?YS():YS().filter(e=>e.value===`app`),S=async e=>{g(!0),v(void 0),b(!1);try{await e()}catch(e){if(!(e instanceof K))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?b(!0):v(Iv(e))}g(!1)},C=()=>S(async()=>{let e=t?d:void 0;if(l===`email`)return await i(e),a();c({kind:`scan`,setup:await n(e)})}),w=(e,t=p)=>S(async()=>{await r(t),c({kind:`backup-codes`,codes:e.backupCodes})}),T=_&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:_});return s.kind===`backup-codes`?(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Y(`twoFactorIsOn`)}),(0,L.jsx)(KS,{codes:s.codes}),(0,L.jsx)(B,{variant:`primary`,onClick:a,className:`min-h-10`,children:Y(`savedCodes`)})]}):s.kind===`scan`?(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),w(s.setup)},children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Y(`scanCode`)}),(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,L.jsx)(qS,{uri:s.setup.totpURI,className:`size-44 rounded-md border`}),(0,L.jsxs)(`p`,{className:`text-center text-xs text-muted-foreground`,children:[Y(`cannotScan`),(0,L.jsx)(`span`,{className:`mt-1 block break-all font-mono text-body text-foreground`,children:JS(s.setup.totpURI)})]})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Y(`codeFromApp`),(0,L.jsx)(vS,{name:`code`,required:!0,autoFocus:!0,value:p,invalid:!!_,onChange:m,onComplete:e=>!h&&void w(s.setup,e)})]}),T,(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:Y(`turnOn`)}),o&&(0,L.jsx)(B,{variant:`ghost`,onClick:o,className:`min-h-10`,children:Y(`cancel`)})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,L.jsx)(`div`,{role:`radiogroup`,"aria-label":Y(`secondStep`),className:`flex flex-col gap-2`,children:x.map(e=>(0,L.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e.value,onClick:()=>u(e.value),className:R(`rounded-md border p-3 text-left transition-colors`,l===e.value?`border-primary bg-primary-soft`:`border-border-strong hover:bg-muted`),children:[(0,L.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,L.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted-foreground`,children:e.description})]},e.value))}),t&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Y(`yourPassword`),(0,L.jsx)(Eb,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:d,invalid:!!_,onChange:e=>f(e.target.value),className:`min-h-6`})]}),T,(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:Y(`continue`)}),o&&(0,L.jsx)(B,{variant:`ghost`,onClick:o,className:`min-h-10`,children:Y(`cancel`)})]}),y&&(0,L.jsx)(WS,{purpose:`change`,minutes:15,onConfirmed:()=>void C()})]})},ZS=e=>Z(e===`twoFactor`?`turnOnTwoFactor`:`addPasskey`),QS=({step:e,twoFactor:t,onAddPasskey:n,busy:r,error:i,onSignOut:a})=>(0,L.jsxs)(CS,{title:ZS(e),description:Z(`requiredForEveryAccount`),children:[e===`twoFactor`?(0,L.jsx)(XS,{...t}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`passkeyExplanation`)}),i&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,L.jsxs)(B,{variant:`primary`,loading:r,onClick:n,className:`min-h-10`,children:[(0,L.jsx)(Xs,{className:`size-4`}),Z(`addPasskey`)]})]}),(0,L.jsx)(`button`,{type:`button`,onClick:a,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:underline`,children:Z(`signOut`)})]}),$S=({missing:e})=>{let{session:t,recheck:n,signOut:r}=J(),[i,a]=(0,M.useState)(),[o,s]=(0,M.useState)(!1),[c,l]=(0,M.useState)();(0,M.useEffect)(()=>{t.account.signInMethods().then(a,e=>l(e instanceof K?Iv(e):Z(`couldNotReadAccount`)))},[t]);let u=async()=>{s(!0),l(void 0);try{await t.account.addPasskey(),n()}catch(e){if(!(e instanceof K))throw e;l(Iv(e)),s(!1)}};return!i&&!c?(0,L.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{}),` `,Z(`loading`)]}):(0,L.jsx)(QS,{step:e[0],busy:o,error:c,onAddPasskey:()=>void u(),onSignOut:()=>void r(),twoFactor:{offerEmailedCodes:i?.mail??!1,needsPassword:i?.account.password??!0,onStartApp:e=>t.account.startAuthenticatorApp(e),onConfirmApp:e=>t.account.confirmAuthenticatorApp(e),onEmailedCodes:e=>t.account.turnOnEmailedCodes(e),onDone:n}})},eC=({className:e})=>(0,L.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:R(`size-4 shrink-0`,e),"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M10.226 17.284c-2.965-.36-5.054-2.493-5.054-5.256 0-1.123.404-2.336 1.078-3.144-.292-.741-.247-2.314.09-2.965.898-.112 2.111.36 2.83 1.01.853-.269 1.752-.404 2.853-.404 1.1 0 1.999.135 2.807.382.696-.629 1.932-1.1 2.83-.988.315.606.36 2.179.067 2.942.72.854 1.101 2 1.101 3.167 0 2.763-2.089 4.852-5.098 5.234.763.494 1.28 1.572 1.28 2.807v2.336c0 .674.561 1.056 1.235.786 4.066-1.55 7.255-5.615 7.255-10.646C23.5 6.188 18.334 1 11.978 1 5.62 1 .5 6.188.5 12.545c0 4.986 3.167 9.12 7.435 10.669.606.225 1.19-.18 1.19-.786V20.63a2.9 2.9 0 0 1-1.078.224c-1.483 0-2.359-.808-2.987-2.313-.247-.607-.517-.966-1.034-1.033-.27-.023-.359-.135-.359-.27 0-.27.45-.471.898-.471.652 0 1.213.404 1.797 1.235.45.651.921.943 1.483.943.561 0 .92-.202 1.437-.719.382-.381.674-.718.944-.943`})}),tC=({id:e,className:t})=>e===`github`?(0,L.jsx)(eC,{className:t}):null,nC=`https://protobase.net/`,rC=()=>(0,L.jsx)(`footer`,{className:`mt-8 text-center`,children:(0,L.jsx)(`a`,{href:nC,rel:`nofollow noreferrer`,className:`inline-block text-sm font-normal leading-6 text-muted-foreground no-underline hover:underline focus-visible:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,children:Z(`runsOnProtobase`)})}),iC=()=>(0,L.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`h-px flex-1 bg-border`}),Z(`or`),(0,L.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),aC=({onSubmit:e,busy:t,error:n,workspace:r,notice:i,methods:a=[`password`],first:o=`password`,onSendCode:s,onPasskey:c,passkeyDomains:l=[],forgotPassword:u,providers:d=[],onContinueWith:f,signUp:p,onBrowse:m,appName:h,runsOnNote:g=!1})=>{let[_,v]=(0,M.useState)(``),[y,b]=(0,M.useState)(``),[x,S]=(0,M.useState)(!1),C=(0,M.useRef)(null),w=a.includes(`password`),T=a.includes(`emailCode`)&&s!==void 0,E=a.includes(`passkey`)&&c!==void 0,D=f?d:[],O=o===`emailCode`&&w&&T&&!x,k=w&&!O,A=()=>{C.current?.reportValidity()&&s?.(_.trim())};return(0,L.jsxs)(CS,{title:Z(`signInTitle`,{name:h??`Protobase`}),description:r,appName:h,footer:g&&(0,L.jsx)(rC,{}),children:[i&&(0,L.jsx)(`p`,{role:`status`,className:`mb-4 rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(D.length>0||E)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[D.map(e=>(0,L.jsxs)(B,{onClick:()=>f?.(e.id),disabled:t,className:`min-h-10 w-full`,children:[(0,L.jsx)(tC,{id:e.id}),Z(`continueWith`,{name:e.name})]},e.id)),E&&(0,L.jsxs)(B,{onClick:()=>c?.(),disabled:t,className:`min-h-10 w-full`,children:[(0,L.jsx)(Xs,{className:`size-4`}),Z(`signInWithPasskey`)]}),E&&l.slice(1).map(e=>(0,L.jsx)(B,{variant:`ghost`,size:`sm`,onClick:()=>c?.(e),disabled:t,className:`w-full`,children:Z(`passkeyFor`,{domain:e})},e))]}),w||T?(0,L.jsx)(iC,{}):n&&(0,L.jsx)(`p`,{role:`alert`,className:`mt-4 text-body font-medium text-danger-text`,children:n})]}),(w||T)&&(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),k?e(_.trim(),y):A()},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`email`),(0,L.jsx)(Eb,{ref:C,type:`email`,name:`email`,autoComplete:`username webauthn`,required:!0,autoFocus:!0,value:_,invalid:!!n,onChange:e=>v(e.target.value),className:`min-h-6`})]}),k&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`password`),(0,L.jsx)(Eb,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:y,invalid:!!n,onChange:e=>b(e.target.value),className:`min-h-6`})]}),n&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:n}),k&&(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:t,className:`min-h-10`,children:Z(`signIn`)}),T&&(0,L.jsxs)(B,{variant:k?`secondary`:`primary`,type:k?`button`:`submit`,onClick:k?A:void 0,loading:t&&!k,disabled:t,className:`min-h-10`,children:[(0,L.jsx)(mc,{className:`size-4`}),Z(`emailSignInCode`)]}),O&&(0,L.jsx)(B,{variant:`ghost`,onClick:()=>S(!0),disabled:t,className:`min-h-10`,children:Z(`usePassword`)}),k&&u&&(0,L.jsx)(Du,{to:u,className:`self-center font-medium text-primary-text hover:underline`,children:Z(`forgotPassword`)})]}),p&&(0,L.jsxs)(`p`,{className:`mt-4 text-center text-muted-foreground`,children:[Z(`newHere`),` `,(0,L.jsx)(Du,{to:p,className:`font-medium text-primary-text hover:underline`,children:Z(`createAnAccount`)})]}),m&&(0,L.jsx)(`button`,{type:`button`,onClick:m,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:Z(`browse`)})]})},oC=({workspace:e,notice:t,forgotPassword:n,signUp:r,onBrowse:i,onCodeSent:a,error:o})=>{let{identity:s,signIn:c,signInSocial:l,signInProviders:u,signInMethods:d,signInFirst:f,passkeyDomains:p,sendSignInCode:m,signInWithPasskey:h}=J(),[g,_]=(0,M.useState)(!1),[v,y]=(0,M.useState)(o),b=async(e,t)=>{_(!0),y(void 0);try{await e()}catch(e){if(!(e instanceof K))throw e;y(t(e)),_(!1)}};return(0,L.jsx)(aC,{busy:g,error:v,workspace:e,notice:t,methods:d,first:f,forgotPassword:n,signUp:r,onBrowse:i,...s.appName&&{appName:s.appName},runsOnNote:s.runsOnNote,providers:$g(u),onContinueWith:e=>void b(()=>l(e),Rv),passkeyDomains:p,onPasskey:e=>void b(()=>h(e),Iv),onSendCode:e=>void b(async()=>{await m(e),a(e)},Iv),onSubmit:(e,t)=>void b(()=>c(e,t),Rv)})},sC=({email:e,onBack:t,...n})=>(0,L.jsx)(TS,{title:Z(`checkEmail`),description:Z(`signUpCodeDescription`),explanation:(0,L.jsx)(L.Fragment,{children:Z.rich(`signUpCodeSent`,{email:(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e}),minutes:10})}),submitLabel:Z(`continue`),onChangeAddress:t,changeAddressLabel:Z(`useAnotherAddress`),...n}),cC=({email:e,onSubmit:t,onBack:n,methods:r,askName:i=!0,busy:a,error:o})=>{let[s,c]=(0,M.useState)(``),[l,u]=(0,M.useState)(``),d=(0,M.useId)(),f=r.includes(`password`),p=r.includes(`emailCode`);return(0,L.jsxs)(CS,{title:Z(`detailsTitle`),description:Z(`detailsDescription`),children:[(0,L.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:Z.rich(`codeWasRight`,{email:(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e})})}),(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({...i&&{name:s.trim()},...f&&l&&{password:l}})},children:[i&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`yourName`),(0,L.jsx)(Eb,{name:`name`,autoComplete:`name`,required:!0,autoFocus:!0,maxLength:200,value:s,onChange:e=>c(e.target.value),className:`min-h-6`})]}),f&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(p?`passwordOptional`:`password`),(0,L.jsx)(Eb,{type:`password`,name:`password`,autoComplete:`new-password`,"aria-describedby":d,required:!p,minLength:12,maxLength:128,value:l,onChange:e=>u(e.target.value),className:`min-h-6`})]}),(0,L.jsxs)(`p`,{id:d,className:`text-xs text-muted-foreground`,children:[Z(`atLeast`,{length:12}),p&&Z(`withoutPassword`)]})]}),o&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:o}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:a,className:`min-h-10`,children:Z(`createAccount`)}),(0,L.jsx)(B,{variant:`ghost`,onClick:n,className:`min-h-10`,children:Z(`useAnotherAddress`)})]})]})},lC=({onSubmit:e,onSignIn:t,onBrowse:n,busy:r,error:i,workspace:a})=>{let[o,s]=(0,M.useState)(``);return(0,L.jsxs)(CS,{title:Z(`createAnAccount`),description:a,children:[(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(o.trim())},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`email`),(0,L.jsx)(Eb,{type:`email`,name:`email`,autoComplete:`email`,required:!0,autoFocus:!0,value:o,invalid:!!i,onChange:e=>s(e.target.value),className:`min-h-6`})]}),(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`codeToConfirm`)}),i&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,L.jsxs)(B,{variant:`primary`,type:`submit`,loading:r,className:`min-h-10`,children:[(0,L.jsx)(mc,{className:`size-4`}),Z(`emailCode`)]}),(0,L.jsxs)(`p`,{className:`text-center text-muted-foreground`,children:[Z(`haveAccount`),` `,(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`font-medium text-primary-text hover:underline`,children:Z(`signIn`)})]})]}),n&&(0,L.jsx)(`button`,{type:`button`,onClick:n,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:Z(`browseWithoutAccount`)})]})},uC=({workspace:e,email:t,ticket:n,onCodeSent:r,onVerified:i,onBack:a,onSignIn:o,onBrowse:s})=>{let{signInMethods:c,sendSignUpCode:l,verifySignUpCode:u,signUp:d,signUpAsksName:f}=J(),p=f||c.includes(`password`)&&!c.includes(`emailCode`),[m,h]=(0,M.useState)(!1),[g,_]=(0,M.useState)(),[v,y]=(0,M.useState)(),b=async e=>{h(!0),_(void 0),y(void 0);try{await e()}catch(e){if(!(e instanceof K))throw e;_(Iv(e))}h(!1)};return t===void 0?(0,L.jsx)(lC,{workspace:e,busy:m,error:g,onSignIn:o,onBrowse:s,onSubmit:e=>void b(async()=>{await l(e),r(e)})}):n===void 0?(0,L.jsx)(sC,{email:t,busy:m,error:g,notice:v,onBack:a,onSubmit:e=>void b(async()=>{let n=await u(t,e);p?i(n):await d({ticket:n})}),onResend:()=>void b(async()=>{await l(t),y(Z(`newCodeSent`))})}):(0,L.jsx)(cC,{email:t,methods:c,askName:f,busy:m,error:g,onBack:a,onSubmit:e=>void b(()=>d({ticket:n,...e}))})},dC=`staff-sign-in`,fC=`staff-error`,pC=e=>{let t=new URL(e).searchParams,n=t.get(fC);if(!t.has(`staff-sign-in`)&&!n)return;let r=t.has(dC);return{email:r&&t.get(`email`)||``,reason:r&&t.get(`reason`)||``,...n&&{error:n}}},mC=e=>{let t=new URL(e);if(t.searchParams.has(`staff-sign-in`))for(let e of[dC,`email`,`reason`])t.searchParams.delete(e);return t.searchParams.delete(fC),`${t.pathname}${t.search}${t.hash}`},hC=10,gC=({operator:e,email:t=``,reason:n=``,onSubmit:r,onBack:i,busy:a,error:o})=>{let[s,c]=(0,M.useState)(t),[l,u]=(0,M.useState)(n);return e?(0,L.jsx)(CS,{title:Z(`signInAsPerson`),description:Z(`forStaffOf`,{operator:e}),children:(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),r(s.trim(),l.trim())},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`theirEmail`),(0,L.jsx)(Eb,{type:`email`,name:`email`,required:!0,autoFocus:!t,value:s,onChange:e=>c(e.target.value),className:`min-h-6`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`reason`),(0,L.jsx)(`textarea`,{name:`reason`,required:!0,minLength:hC,rows:3,value:l,placeholder:Z(`reasonExample`),onChange:e=>u(e.target.value),className:R(`resize-y rounded-md border bg-background px-2.5 py-1.5 font-normal shadow-sm outline-none placeholder:text-faint-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`,o?`border-danger`:`border-border-strong`)})]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Z(`staffExplanation`,{operator:e})}),o&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:o}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:a,className:`min-h-10`,children:Z(`continueWith`,{name:e})}),(0,L.jsx)(B,{variant:`ghost`,onClick:i,className:`min-h-10`,children:Z(`backToSignIn`)})]})}):(0,L.jsxs)(CS,{title:Z(`staffTitle`),description:Z(`staffUnavailable`),children:[o&&(0,L.jsx)(`p`,{role:`alert`,className:`mb-4 text-body font-medium text-danger-text`,children:o}),(0,L.jsx)(B,{variant:`primary`,className:`min-h-10 w-full`,onClick:i,children:Z(`backToSignIn`)})]})},_C=({link:e,onBack:t})=>{let{session:n,staffSignIn:r}=J(),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(e.error&&Bv(e.error)),c=async(e,t)=>{a(!0),s(void 0);try{let r=`${window.location.origin}${mC(window.location.href)}`;window.location.assign(await n.staff.start({email:e,reason:t,callbackURL:r}))}catch(e){if(!(e instanceof K))throw e;s(Bv(e)),a(!1)}};return(0,L.jsx)(gC,{operator:r,email:e.email,reason:e.reason,busy:i,error:o,onBack:t,onSubmit:(e,t)=>void c(e,t)})},vC=({checked:e,indeterminate:t,onChange:n,label:r,disabled:i,className:a})=>(0,L.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t?`mixed`:e,"aria-label":r,disabled:i,onClick:()=>n?.(!e),className:R(`relative inline-flex size-4 shrink-0 items-center justify-center rounded border transition-colors after:absolute after:-inset-1 after:content-[""] pointer-coarse:after:-inset-3.5`,e||t?`border-primary bg-primary text-primary-foreground`:`border-border-strong bg-background hover:border-faint-foreground`,a),children:t?(0,L.jsx)(wc,{className:`size-3`,strokeWidth:3}):e&&(0,L.jsx)(Xo,{className:`size-3`,strokeWidth:3})}),yC={totp:`totpInstruction`,otp:`otpInstruction`,backup:`backupInstruction`},bC=({methods:e,onVerify:t,onSendCode:n,onBack:r,busy:i,error:a,codeSent:o,initialStep:s})=>{let[c,l]=(0,M.useState)(s??(e.includes(`totp`)?`totp`:`otp`)),[u,d]=(0,M.useState)(``),[f,p]=(0,M.useState)(!1),m=c===`otp`&&!o,h=e=>{l(e),d(``),e===`otp`&&!o&&n()};return(0,L.jsxs)(CS,{title:Z(`twoFactorTitle`),description:Z(`twoFactorDescription`),children:[m?(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`codeToFinish`)}),a&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,L.jsx)(B,{variant:`primary`,loading:i,onClick:n,className:`min-h-10`,children:Z(`emailCode`)})]}):(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({method:c,code:u.trim(),trustDevice:f})},children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(yC[c],{minutes:10})}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(c===`backup`?`backupCode`:`code`),c===`backup`?(0,L.jsx)(Eb,{name:`code`,autoComplete:`off`,spellCheck:!1,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:e=>d(e.target.value),className:`min-h-6 font-mono`}):(0,L.jsx)(vS,{name:`code`,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:d})]}),(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(vC,{checked:f,onChange:p,label:Z(`trustBrowser`)}),Z(`trustBrowserFor`)]}),a&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:Z(`verify`)})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex flex-col items-center gap-2 border-t pt-4`,children:[c!==`totp`&&e.includes(`totp`)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(`totp`),className:`font-medium text-primary-text hover:underline`,children:Z(`useAuthenticator`)}),c!==`otp`&&e.includes(`otp`)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(`otp`),className:`font-medium text-primary-text hover:underline`,children:Z(`emailCodeInstead`)}),c!==`backup`&&e.includes(`totp`)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(`backup`),className:`font-medium text-primary-text hover:underline`,children:Z(`useBackupCode`)}),(0,L.jsx)(`button`,{type:`button`,onClick:r,className:`font-medium text-muted-foreground hover:underline`,children:Z(`backToSignIn`)})]})]})},xC=({methods:e,onBack:t})=>{let{verifyTwoFactor:n,session:r}=J(),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(),[c,l]=(0,M.useState)(!1),u=async e=>{a(!0),s(void 0);try{await e()}catch(e){if(!(e instanceof K))throw e;s(Iv(e))}a(!1)};return(0,L.jsx)(bC,{methods:e,busy:i,error:o,codeSent:c,onBack:t,onVerify:e=>void u(()=>n(e)),onSendCode:()=>void u(async()=>{await r.sendTwoFactorCode(),l(!0)})})},SC=()=>{let{path:e,params:t,basePath:n,navigate:r}=Hu(),i=(0,M.useMemo)(()=>wd(e,t),[e,t]),a=Xg(new URL(t.size>0?`${e}?${t}`:e,`http://local`).href),o=i?i.next:a,s=(0,M.useCallback)((e=`sign-in`,t)=>r(Cd({step:e,next:o}),t),[r,o]);return{address:i,next:o,open:s,link:(0,M.useCallback)((e=`sign-in`,t)=>({href:`${n}${Cd({step:e,next:o})}`,onFollow:()=>s(e,t)}),[n,o,s]),leave:(0,M.useCallback)(()=>r(o??`/`,{replace:!0}),[r,o])}},CC=e=>{let t=new URL(e),n=t.searchParams.get(`token`);return t.pathname.endsWith(`/-/invitation`)&&n?{token:n}:void 0},wC=e=>`${new URL(e).pathname.slice(0,-13)}/`,Q=F(`organizations`),TC=`/-/organizations`,EC=`/-/organization`,DC=`/-/organization/members`,OC=`/-/organization/invitations`,kC=`/-/first-organization`,AC=`/-/first-organization/new`,jC={[TC]:`organizations`,[EC]:`organization`,[DC]:`members`,[OC]:`invitations`,[kC]:`createTitle`,[AC]:`createTitle`},MC=(e,t)=>{let n=jC[e];return n&&t(n)},NC=e=>e===`/-/first-organization`||e===`/-/first-organization/new`,PC=e=>Q(e),FC=(e,t)=>e.find(e=>e.name===t)?.label??t,IC=e=>e?.role===`owner`||e?.role===`admin`,LC=(e,t,n,r)=>{let i=(n,r,i,a)=>({id:n,label:r,icon:i,href:`${e}${a}`,active:t===a});return[i(`organizations`,n(`manageOrganizations`),Pc,TC),...r?.organization?[i(`organization`,n(`organization`),Wo,EC)]:[],...IC(r)?[i(`members`,n(`members`),Xl,DC),i(`invitations`,n(`invitations`),mc,OC)]:[]]},RC=(e,t)=>{let n=[...t?.globalRoles??[],...t?.appRoles??[]],r=e.filter(e=>e.membership).map(e=>e.name);if(n.includes(`admin`))return new Set(r);let i=n.flatMap(t=>e.find(e=>e.name===t)?.grants??[]);return new Set([...n,...i].filter(e=>r.includes(e)))},zC=async(e,{setBusy:t,setError:n})=>{t(!0),n(void 0);try{await e()}catch(e){if(e instanceof K)return n(Iv(e));if(e instanceof Sh)return n(Lv());throw e}finally{t(!1)}},BC=()=>{let[e,t]=(0,M.useState)(!1),[n,r]=(0,M.useState)();return{busy:e,error:n,run:e=>zC(e,{setBusy:t,setError:r}),setError:r}},VC=({token:e,preview:t,joins:n,onDone:r})=>{let{session:i,signInMethods:a,recheck:o}=J(),[s,c]=(0,M.useState)(``),[l,u]=(0,M.useState)(``),{busy:d,error:f,run:p}=BC(),m=a.includes(`password`),h=a.includes(`emailCode`),g=()=>p(async()=>{await i.organizations.signUpFromInvitation(e,{name:s.trim(),...m&&l&&{password:l}}),r(),o()});return(0,L.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Q(n?`makeAccountToJoin`:`makeAccount`,{email:t.email})}),f&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,L.jsx)(Eb,{"aria-label":Q(`yourName`),placeholder:Q(`yourName`),autoComplete:`name`,value:s,onChange:e=>c(e.target.value)}),m&&(0,L.jsx)(Eb,{"aria-label":Q(`password`),type:`password`,autoComplete:`new-password`,placeholder:Q(h?`passwordOptional`:`passwordRequired`,{length:12}),value:l,onChange:e=>u(e.target.value)}),(0,L.jsx)(B,{type:`submit`,variant:`primary`,loading:d,disabled:!s.trim()||m&&!h&&l.length<12,children:Q(n?`createAndJoin`:`createYourAccount`)})]})},HC=({token:e,onDone:t,signIn:n})=>{let{session:r,state:i,signOut:a,organizations:o}=J(),[s,c]=(0,M.useState)(),[l,u]=(0,M.useState)(),{busy:d,error:f,run:p}=BC();if((0,M.useEffect)(()=>{r.organizations.invitation(e).then(c,e=>u(e instanceof K?Iv(e):Q(`invalidLink`)))},[r,e]),l)return(0,L.jsx)(CS,{title:Q(`invitation`),description:l,children:(0,L.jsx)(B,{className:`w-full`,onClick:t,children:Q(`goToApp`)})});if(!s)return(0,L.jsx)(CS,{title:Q(`invitation`),children:(0,L.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{}),` `,Q(`loading`)]})});let m=i.kind===`signed-in`?i.user:void 0,h=m?.email.toLowerCase()===s.email.toLowerCase();if(!s.organization){let r=s.app?.name??``,i=Q(`invitesToApp`,{inviter:s.inviter.name,app:r});return(0,L.jsx)(CS,{title:Q(`join`,{name:r}),description:i,children:s.hasAccount?m&&h?(0,L.jsx)(B,{variant:`primary`,className:`w-full`,onClick:t,children:Q(`goToApp`)}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:Q(`hasAccount`,{email:s.email})}),m?(0,L.jsx)(B,{className:`w-full`,onClick:()=>void a(),children:Q(`signOut`)}):(0,L.jsx)(Du,{to:n,className:R(hu({variant:`primary`}),`w-full`),children:Q(`signInAs`,{email:s.email})})]}):m?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:Q(`otherAddress`,{invited:s.email,signedIn:m.email})}),(0,L.jsx)(B,{className:`w-full`,onClick:()=>void a(),children:Q(`signOutToAccept`)})]}):(0,L.jsx)(VC,{token:e,preview:s,joins:!1,onDone:t})})}let g=s.organization,_=s.appRoles.map(e=>FC(o?.roles??[],e)),v=PC(s.role).toLowerCase(),y=_.length>0?Q(`invitesToWith`,{inviter:s.inviter.name,organization:g.name,role:v,roles:_.join(`, `)}):Q(`invitesTo`,{inviter:s.inviter.name,organization:g.name,role:v});return m&&!h?(0,L.jsxs)(CS,{title:Q(`join`,{name:g.name}),description:y,children:[(0,L.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:Q(`otherAddress`,{invited:s.email,signedIn:m.email})}),(0,L.jsx)(B,{className:`w-full`,onClick:()=>void a(),children:Q(`signOutToAccept`)})]}):(0,L.jsx)(CS,{title:Q(`join`,{name:g.name}),description:y,children:m?(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,L.jsx)(B,{variant:`primary`,className:`w-full`,loading:d,onClick:()=>void p(async()=>{await r.organizations.accept(e),t()}),children:Q(`join`,{name:g.name})})]}):s.hasAccount?(0,L.jsx)(Du,{to:n,className:R(hu({variant:`primary`}),`w-full`),children:Q(`signInAsToJoin`,{email:s.email})}):(0,L.jsx)(VC,{token:e,preview:s,joins:!0,onDone:t})})},UC=({children:e})=>(0,L.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-dashed border-warning bg-warning-soft p-3 text-warning-text`,children:e}),WC=F(`app/pages`),GC=class extends M.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){pg(e,t.componentStack)}componentDidUpdate(e){this.state.failed&&e.resetKey!==this.props.resetKey&&this.setState({failed:!1})}render(){return this.state.failed?this.props.fallback===void 0?(0,L.jsx)(UC,{children:WC.rich(`couldNotDraw`,{name:this.props.name})}):this.props.fallback:this.props.children}},KC=(e,t)=>{let n=Ta(e??{}),r=[],i=[];for(let e of t){if(e.kind===`off`){i.push(e);continue}try{Ta(...r,e.ui,n),r.push(e.ui)}catch(t){if(!(t instanceof ya))throw t;i.push({kind:`off`,url:e.plugin.url,name:e.plugin.name,reason:t.message})}}return{ui:r.length===0?n:Ta(...r,n),off:i}},qC=({children:e})=>{let{state:t,beforeSignIn:n,adoptSession:r}=J(),{path:i,params:a,navigate:o}=Hu(),{loads:s,settled:c}=Xa(n,qa()),l=(0,M.useMemo)(()=>KC(void 0,s).ui.beforeSignIn,[s]),u=(0,M.useCallback)(e=>{let t=new URLSearchParams(a);for(let n of e)t.delete(n);o(t.size>0?`${i}?${t}`:i,{replace:!0})},[i,a,o]);return t.kind!==`signed-out`&&t.kind!==`visitor`?e:c?l?(0,L.jsx)(GC,{name:`beforeSignIn`,fallback:e,children:(0,L.jsx)(l,{signedIn:r,params:a,removeParams:u,children:e})}):e:(0,L.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(nv,{}),(0,L.jsx)(fu,{}),` `,da(`loading`)]})},JC=()=>{let e=window.location.href,t=FS(e);if(t)return{kind:`reset-password`,token:t.token};let n=pC(e);if(n)return{kind:`staff-sign-in`,link:n};let r=CC(e);if(r)return{kind:`invitation`,token:r.token};let i=Kg(e);if(i)return{kind:`provider-sign-in`,provider:i};let a=qg(e);return a?{kind:`sign-in`,providerError:a}:{kind:`sign-in`}},YC=({to:e})=>{let{navigate:t}=Hu();return(0,M.useEffect)(()=>t(e,{replace:!0}),[t,e]),null},XC=({workspace:e,children:t})=>{let n=ZC(e,t);return(0,L.jsx)(qC,{children:n})},ZC=(e,t)=>{let{state:n,recheck:r,passwordReset:i,signOut:a,signInProviders:o,canSignUp:s,browse:c}=J(),{path:l,params:u,basePath:d,navigate:f}=Hu(),{address:p,next:m,open:h,link:g,leave:_}=SC(),[v,y]=(0,M.useState)(JC),[b,x]=(0,M.useState)(),[S,C]=(0,M.useState)(),[w,T]=(0,M.useState)(),E=new URL(`${d}${l}${u.size>0?`?${u}`:``}`,window.location.origin).href,D=(0,M.useCallback)(e=>{let t=e(E).slice(d.length);f(t.startsWith(`/`)?t:`/${t}`,{replace:!0})},[E,d,f]),O=n.kind===`signed-in`||n.kind===`two-factor`||n.kind===`setup-required`,k=Yg(E)!==void 0;(0,M.useEffect)(()=>{O&&((v.kind===`provider-sign-in`||k)&&D(Xg),(v.kind===`provider-sign-in`||v.kind===`sign-in`&&(v.notice||v.error||v.providerError))&&y({kind:`sign-in`}),x(void 0),C(void 0),T(void 0))},[O,v,k,D]);let A=p!==void 0&&qg(E)!==void 0;(0,M.useEffect)(()=>{!O&&v.kind===`sign-in`&&v.providerError&&A&&D(Xg)},[O,v,A,D]);let ee=(0,M.useCallback)(e=>y({kind:`sign-in`,error:e}),[]),te=e=>{D(IS),y(e)},ne=async()=>{n.kind===`signed-in`&&await a(),te({kind:`sign-in`,notice:Z(`passwordChanged`)})},re=()=>{y({kind:`sign-in`}),a().then(()=>h(`sign-in`,{replace:!0}))};switch(n.kind){case`loading`:return(0,L.jsxs)(`div`,{className:R(`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,Cu),children:[(0,L.jsx)(nv,{}),(0,L.jsx)(fu,{}),` `,Z(`loading`)]});case`error`:return(0,L.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`cannotReach`,{message:n.message??Z(`noAnswer`)})}),(0,L.jsx)(B,{onClick:r,children:Z(`tryAgain`)})]});case`needs-admin`:return(0,L.jsx)(kS,{firstAdminUrl:n.firstAdminUrl,onCheckAgain:r})}if(n.kind===`signed-in`&&p)return(0,L.jsx)(YC,{to:m??`/`});if(v.kind===`reset-password`)return(0,L.jsx)(HS,{token:v.token,onDone:()=>void ne(),onRequestNewLink:i?()=>{y({kind:`sign-in`}),f(Cd({step:`forgot-password`}),{replace:!0})}:void 0,onBack:()=>te({kind:`sign-in`})});if(v.kind===`staff-sign-in`)return(0,L.jsx)(_C,{link:v.link,onBack:()=>{D(mC),y({kind:`sign-in`})}});let ie=n.kind===`signed-out`||n.kind===`visitor`;if(v.kind===`invitation`&&(n.kind===`signed-in`||ie&&!p))return(0,L.jsx)(HC,{token:v.token,onDone:()=>{D(wC),y({kind:`sign-in`})},signIn:g()});if(n.kind===`signed-in`)return t;if(n.kind===`two-factor`)return(0,L.jsx)(xC,{methods:n.methods,onBack:re});if(n.kind===`setup-required`)return(0,L.jsx)($S,{missing:n.missing},n.missing.join());if(v.kind===`provider-sign-in`)return(0,L.jsx)(zS,{provider:v.provider,workspace:e,onFailed:ee});let j=v.kind===`sign-in`?v:{kind:`sign-in`};if(!p){let e=j.notice||j.error||j.providerError;return n.kind===`visitor`&&!e?t:(0,L.jsx)(YC,{to:Cd({next:m})})}let ae={"sign-in":!0,"forgot-password":i,"email-code":b!==void 0,"sign-up":s,"sign-up-code":s&&S!==void 0,"sign-up-details":s&&w!==void 0}[p.step]?p.step:`sign-in`,N=e=>()=>h(e,{replace:!0}),oe=c&&(()=>{c(),_()});if(ae===`forgot-password`)return(0,L.jsx)(LS,{back:g(`sign-in`,{replace:!0})});if(ae===`email-code`)return(0,L.jsx)(DS,{email:b,onBack:N(`sign-in`)});if(ae===`sign-up`||ae===`sign-up-code`||ae===`sign-up-details`)return(0,L.jsx)(uC,{workspace:e,email:ae===`sign-up`?void 0:S,ticket:ae===`sign-up-details`?w:void 0,onCodeSent:e=>{C(e),T(void 0),h(`sign-up-code`)},onVerified:e=>{T(e),h(`sign-up-details`,{replace:!0})},onBack:N(`sign-up`),onSignIn:()=>h(`sign-in`),onBrowse:oe},ae);let se=j.providerError&&Hv(j.providerError,o.length===1?o[0].name:`the provider`),ce=j.error??se;return(0,L.jsx)(oC,{workspace:e,notice:j.notice,error:ce,forgotPassword:i?g(`forgot-password`):void 0,onCodeSent:e=>{x(e),h(`email-code`)},signUp:s?g(`sign-up`):void 0,onBrowse:oe},ce)},QC=e=>e.charAt(0).toUpperCase()+e.slice(1),$C=e=>(e.role??`user`).split(`,`).map(e=>e.trim()),ew=e=>$C(e).includes(`admin`),tw=e=>QC(e.replace(/[_-]+/g,` `).trim()),nw=e=>{let t=$C(e),n=t.includes(`admin`);return{name:e.name||e.email,email:e.email,initials:ub(e.name||e.email)||`?`,hue:lb(e.id||e.email),role:n?Z(`admin`):tw(t[0]??`user`),roleTone:n?`violet`:`blue`}},rw=3e4,iw=(e,t=Date.now())=>Math.max(1e3,Yh(e)-t-rw),aw=()=>{let{state:e,session:t}=J(),n=e.kind===`signed-in`,[r,i]=(0,M.useState)();return(0,M.useEffect)(()=>{if(!n)return;let e=!0,r,a=async n=>{let o=await t.token(),s=o!==void 0&&o===n?await t.token({refresh:!0}):o;e&&(i(s),s&&(r=setTimeout(()=>void a(s),iw(s))))};return a(),()=>{e=!1,clearTimeout(r)}},[t,n]),n?r:void 0},ow=({children:e})=>(0,L.jsx)(sv,{locale:J().locale,children:e}),sw=e=>{if(e?.kind!==`signed-in`)return;let{id:t,name:n}=e.user;return{id:t,...n&&{name:n}}},cw=()=>{let e=l_()?.state;return(0,M.useMemo)(()=>sw(e),[e])},lw=e=>{let t=sw(e);return t?`user:${t.id}`:`state:${e.kind}`},uw=(e,t)=>{let n=new Set,r,i=()=>{r=void 0;let i=new Set(n);n.clear();let a=e=>Ji(e,i);e.invalidateQueries({predicate:e=>a(e.queryKey)&&e.queryKey[0]!==`record`}),e.invalidateQueries({predicate:e=>a(e.queryKey)&&e.queryKey[0]===`record`,refetchType:t()?`none`:`active`})};return{changed:e=>{for(let t of e)n.add(t);n.size>0&&!r&&(r=setTimeout(i,300))},stop:()=>clearTimeout(r)}},dw=e=>{let t=X(),n=x(),r=(0,M.useContext)(E_),i=(0,M.useMemo)(()=>Object.values(e.resources).filter(t=>t.live&&!Q_(e,t.name)).map(e=>e.name).sort().join(`,`),[e]);(0,M.useEffect)(()=>{if(!i)return;let e=uw(n,()=>r?.paused()??!1),a=t.live({onChanges:t=>e.changed(t.map(e=>e.resource)),onResync:()=>e.changed(i.split(`,`))});return()=>{a(),e.stop()}},[t,n,r,i])},fw=(e,t,n=!0)=>{let r=X(),i=tr(t);return O({queryKey:I.record(e,i),enabled:n,queryFn:()=>r.get(e,t)})},pw=(e,t,n=!0)=>{let r=X(),i=x(),a=tr(t);return O({queryKey:I.record(e,a),enabled:n,queryFn:()=>r.get(e,t),placeholderData:()=>i.getQueryData(I.recordPreview(e,a))})},mw=()=>{let{path:e}=Hu();return(0,M.useMemo)(()=>In(e),[e])},hw=`/-/call-guest`,gw=(e,t)=>`${e}${hw}#${t}`,_w=(e,t)=>{let n=t.replace(/^#/,``);return e===`/-/call-guest`&&n?{token:n}:void 0},vw=()=>{let{path:e}=Hu();return(0,M.useMemo)(()=>_w(e,globalThis.location?.hash??``),[e])},yw=[`light`,`dark`,`system`],bw=`protobase:theme`,xw=`(prefers-color-scheme: dark)`,Sw=e=>yw.includes(e),Cw=e=>le(()=>{let t=e.getItem(bw);return Sw(t)?t:`system`},`system`),ww=(e,t)=>le(()=>t===`system`?e.removeItem(bw):e.setItem(bw,t),void 0),Tw=(e,t)=>e===`system`?t?`dark`:`light`:e,Ew=(0,M.createContext)(void 0),Dw=({children:e})=>{let[t,n]=(0,M.useState)(()=>Cw(localStorage)),r=Tw(t,cy(xw));return(0,M.useEffect)(()=>{document.documentElement.dataset.theme=r},[r]),(0,M.useEffect)(()=>{let e=e=>{(e.key===`protobase:theme`||e.key===null)&&n(Cw(localStorage))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),(0,L.jsx)(Ew.Provider,{value:{preference:t,theme:r,choose:e=>{ww(localStorage,e),n(e)}},children:e})},Ow=()=>{let e=(0,M.useContext)(Ew);if(!e)throw Error(`useTheme needs a ThemeProvider above it`);return e},kw=F(`toasts`),Aw=`-my-0.5 rounded px-1.5 py-0.5 font-medium text-primary-text hover:bg-primary-soft`,jw=({action:e})=>{if(`onClick`in e)return(0,L.jsx)(`button`,{type:`button`,onClick:e.onClick,className:Aw,children:e.label});let{href:t,onNavigate:n}=e;return(0,L.jsx)(`a`,{href:t,onClick:e=>{n&&Tu(e)&&(e.preventDefault(),n(t))},className:Aw,children:e.label})},Mw={loading:(0,L.jsx)(fu,{className:`text-primary`}),success:(0,L.jsx)(os,{className:`size-4 text-success`}),warning:(0,L.jsx)(Bl,{className:`size-4 text-warning`}),error:(0,L.jsx)(us,{className:`size-4 text-danger`}),info:(0,L.jsx)(ol,{className:`size-4 text-primary`}),call:(0,L.jsx)(Bc,{className:`size-4 animate-pulse text-success`})},Nw=({state:e,title:t,description:n,action:r,actions:i=[],onDismiss:a})=>(0,L.jsxs)(`div`,{role:e===`error`||e===`call`?`alert`:`status`,className:R(`flex w-full max-w-80 items-start gap-3 rounded-lg border bg-background p-3 shadow-pop [animation:pb-slide-in_160ms_ease-out]`,e===`warning`&&`border-warning/40`,e===`error`&&`border-danger/40`),children:[(0,L.jsx)(`span`,{className:`mt-0.5`,children:Mw[e]}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`font-medium text-foreground`,children:t}),n&&(0,L.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:n})]}),r&&(0,L.jsx)(jw,{action:r}),i.map(e=>(0,L.jsx)(jw,{action:e},e.label)),a&&(0,L.jsx)(`button`,{type:`button`,"aria-label":kw(`dismiss`),onClick:a,className:`inline-flex items-center justify-center rounded p-0.5 text-faint-foreground hover:bg-muted hover:text-foreground pointer-coarse:size-9`,children:(0,L.jsx)(uu,{className:`size-3.5`})})]}),Pw={loading:1/0,success:3500,warning:8e3,error:8e3,info:8e3,call:1/0},Fw=8e3,Iw=(0,M.createContext)(null),Lw=()=>{let e=(0,M.useContext)(Iw);if(!e)throw Error(`useToast must be used inside ToastProvider`);return e},Rw=({children:e})=>{let[t,n]=(0,M.useState)([]),r=(0,M.useRef)(1),i=(0,M.useRef)(new Map),a=(0,M.useRef)(new Set),o=(0,M.useCallback)(e=>{clearTimeout(i.current.get(e)),i.current.delete(e),a.current.delete(e),n(t=>t.filter(t=>t.id!==e))},[]),s=(0,M.useCallback)((e,t,n=!1)=>{if(clearTimeout(i.current.get(e)),a.current.has(e))return;let r=n?Fw:Pw[t];r!==1/0&&i.current.set(e,setTimeout(()=>o(e),r))},[o]),c=e=>{e.onClose?.(),o(e.id)},l=(0,M.useMemo)(()=>({show:e=>{let t=r.current++;return e.sticky&&a.current.add(t),n(n=>[...n,{...e,id:t}]),s(t,e.state,!!e.action),t},update:(e,t)=>{n(n=>n.map(n=>n.id===e?{...n,...t}:n)),t.state&&s(e,t.state,!!t.action)},dismiss:o}),[o,s]);return(0,L.jsxs)(Iw.Provider,{value:l,children:[e,(0,L.jsx)(`div`,{className:`pointer-events-none fixed inset-x-4 bottom-[calc(6rem+var(--pb-safe-bottom))] z-[100] flex flex-col items-end gap-2 md:inset-x-auto md:bottom-[calc(1rem+var(--pb-safe-bottom))] md:right-[calc(1rem+var(--pb-safe-right))]`,children:t.map(e=>(0,L.jsx)(`div`,{className:`pointer-events-auto`,children:(0,L.jsx)(Nw,{state:e.state,title:e.title,description:e.description,action:e.action,...e.actions&&{actions:e.actions},onDismiss:()=>c(e)})},e.id))})]})},zw=({open:e,onToggle:t})=>(0,L.jsxs)(B,{size:`sm`,variant:e?`primary`:`secondary`,"aria-pressed":e,onClick:t,className:`max-md:size-9 max-md:p-0`,children:[(0,L.jsx)(wl,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`max-md:sr-only`,children:H(`assistant`)})]}),Bw={bell:Ro,"book-open":Bo,bookmark:Ho,building:Wo,"credit-card":bs,"external-link":Ms,"file-text":Hs,globe:Es,heart:Ks,key:Xs,"layout-dashboard":ec,"life-buoy":ic,mail:mc,package:Ic,receipt:nl,settings:vl,shield:bl,"shopping-cart":Sl,tags:Il,users:Xl,warehouse:iu};Object.keys(Bw);var Vw=(e,t)=>e?Bw[e]??t:t,Hw=(e,t)=>Vw(e.views[t]?.icon??e.signIn?.[t]?.icon,Ml),Uw=(e,t,n,r=!1)=>(e.bottomBar?.items??[]).flatMap((i,a)=>i.kind===`search`?[]:i.kind===`link`?[{id:`link-${a}`,label:i.label,icon:Vw(i.icon,Ms),href:i.href,external:!0}]:i.kind===`page`?[{id:i.page,label:i.label,icon:Vw(i.icon??e.pages[i.page]?.icon,ec),href:ud({kind:`page`,page:i.page},t),active:i.page===n,shown:r&&i.page===n}]:[{id:i.resource,label:i.label,icon:Vw(i.icon,Hw(e,i.resource)),href:ud({kind:`list`,resource:i.resource},t),active:i.resource===n,shown:r&&i.resource===n}]),Ww=e=>{let t=e.bottomBar?.items.find(e=>e.kind===`search`);return t?.kind===`search`?t.label??!0:void 0},Gw=({basePath:e,address:t,group:n,page:r,resourceLabel:i,headingless:a,recordTitle:o,recordLoading:s})=>{let c=n&&n!==i?[n]:[];if(r)return[...c,{label:r.title,href:ud({kind:`page`,page:r.name},e)}];if(!t||t.kind===`page`)return[H(`admin`)];let l=ud({kind:`list`,resource:t.resource,...t.kind===`list`&&t.list&&{list:t.list}},e),u=t.kind===`record`&&!a,d=i?[{label:i,href:l,...u&&{above:!0}}]:[];if(t.kind===`list`||u)return[...c,...d];let f=ud(t,e),p=t.kind===`create`?{label:H(`new`),href:f}:o===void 0&&s?{label:H(`loadingRecord`),href:f,loading:!0}:{label:o??t.key,href:f};return[...c,...d,p]},Kw=()=>{let e,t=new Set;return{get:()=>e,set:n=>{if(n!==e){e=n;for(let e of t)e()}},subscribe:e=>(t.add(e),()=>void t.delete(e))}},qw=(0,M.createContext)(void 0),Jw=()=>()=>{},Yw=()=>void 0,Xw=()=>{let e=(0,M.useContext)(qw);return(0,M.useSyncExternalStore)(e?.subscribe??Jw,e?.get??Yw,e?.get??Yw)},Zw=(e,t)=>e&&Object.hasOwn(e,t)?e[t]:void 0,Qw=e=>e,$w=e=>e,eT=(0,M.createContext)({}),tT=()=>(0,M.useContext)(eT),nT=({usePresence:e,store:t})=>{let n=e();return(0,M.useEffect)(()=>t.set(n),[t,n]),(0,M.useEffect)(()=>()=>t.set(void 0),[t]),null},rT=({children:e})=>{let{presence:t}=tT(),[n]=(0,M.useState)(Kw),[r,i]=(0,M.useState)({hook:t,key:0});return r.hook!==t&&i({hook:t,key:r.key+1}),(0,L.jsxs)(qw.Provider,{value:n,children:[t&&(0,L.jsx)(nT,{usePresence:t,store:n},r.key),e]})},iT=e=>{let t={word:e?.singular??Q(`word`),words:e?.plural??Q(`words`)};return(e,n)=>Q(e,{...t,...n})},aT=()=>{let e=J().organizations?.names;return(0,M.useMemo)(()=>iT(e),[e])},oT=[],sT=e=>{let{session:t}=J(),n=aT(),r=(0,M.useContext)(k_),i=O({queryKey:I.organizations,queryFn:async()=>{let[e,n]=await Promise.all([t.organizations.current(),t.organizations.list()]);return{current:e,organizations:n}},enabled:e,retry:!1}),{refetch:a}=i,o=(0,M.useCallback)(()=>void a(),[a]),s=e?i.data:void 0,c=e&&i.error?i.error instanceof K?Iv(i.error):n(`couldNotReadOrganizations`):void 0;return{current:s?.current,organizations:s?.organizations??oT,fresh:e&&j_(i,r),failed:e&&M_(i),...c&&{error:c},reload:o}},cT=e=>window.location.assign(`${e}/`),lT=(e,t)=>t?.active?{...e,role:t.active}:e,uT=F(`roles`),dT=(e,t)=>e instanceof K?Iv(e):t,fT=(e,t=!0)=>{let{session:n}=J(),r=Lw(),i=O({queryKey:I.activeRole,queryFn:()=>n.roles.current(),enabled:t,retry:!1});(0,M.useEffect)(()=>{i.error&&r.show({state:`error`,title:dT(i.error,uT(`couldNotReadRoles`))})},[i.error,r]);let a=(0,M.useCallback)(t=>void n.roles.switchTo(t).then(e,e=>r.show({state:`error`,title:dT(e,uT(`couldNotSwitch`))})),[n,r,e]);return{...t&&i.data&&{current:i.data},switchTo:a}},pT=(e,t)=>e[t]||e.conditional.includes(t),mT=(e,t)=>e.permissions?.[t]??!0,hT=(e,t)=>e?.fields?e.fields[t]??`hidden`:`edit`,gT=(e,t,n)=>e?.create?Object.hasOwn(t,e.create.page):pT(n,`create`),_T=e=>new Set((e.userMenu?.items??[]).flatMap(e=>e.kind===`resource`?[e.resource]:e.kind===`page`?[e.page]:[])),vT=(e,t,n)=>(e.userMenu?.items??[]).map((r,i)=>{if(r.kind===`link`)return{id:`link-${i}`,label:r.label,icon:Vw(r.icon,Ms),href:r.href,external:!0};if(r.kind===`page`){let i=e.pages[r.page];return{id:r.page,label:r.label??i?.title??Hr(r.page),icon:Vw(r.icon??i?.icon,ec),href:ud({kind:`page`,page:r.page},t),active:r.page===n}}return{id:r.resource,label:r.label??e.views[r.resource]?.names?.plural??Hr(r.resource),icon:Vw(r.icon,Hw(e,r.resource)),href:ud({kind:`list`,resource:r.resource},t),active:r.resource===n}}),yT=(e,t)=>t===void 0?e:`${e}/${t}`,bT={sales:`sales`,crm:`crm`,catalog:`catalog`,inventory:`inventory`,core:`admin`,hr:`hr`,table_definitions:`tables`,user_tables:`tables`},xT=(e=`public`)=>e===`public`?``:bT[e]?H(bT[e]):Hr(e),ST=(e,t,n,r,i)=>!n?.create||!gT(t,e.pages,e.permissions[t.resource]??G_)?{}:{create:{label:n.create===!0?yS(`title`,{noun:r}):n.create.label,href:ud({kind:`create`,resource:t.resource},i)}},CT=(e,t=``,n={})=>{let r=new Map,i=new Map,a=_T(e);for(let n of Object.values(e.pages)){if(n.nav?.hidden||a.has(n.name))continue;let e=n.nav?.group??H(`pages`),o=r.get(e)??{label:e,items:[]};o.items.push({id:n.name,label:n.title,icon:Vw(n.icon,ec),href:ud({kind:`page`,page:n.name},t)}),r.set(e,o),i.set(n.name,n.nav?.order??2**53-1)}for(let o of Object.values(e.resources)){let s=e.views[o.name];if(!s||a.has(o.name))continue;let c=s.nav?.group??xT(o.table.schema),l=(e,t,n)=>{let a=r.get(e)??{label:e,items:[]};a.items.push(t),r.set(e,a),i.set(t.id,n??2**53-1)},u=!s.nav?.creatorsOnly||gT(s,e.pages,e.permissions[s.resource]??G_);!s.nav?.hidden&&u&&l(c,{id:yT(o.name),label:s.names?.plural??Hr(o.name),icon:Hw(e,o.name),href:ud({kind:`list`,resource:o.name},t),...n[o.name]&&{recent:n[o.name]},...ST(e,s,s.nav,s.names?.singular??Hr(o.name),t)},s.nav?.order);for(let n of s.lists??[])n.nav?.hidden||l(n.nav?.group??c,{id:yT(o.name,n.name),label:n.names.plural,icon:Hw(e,o.name),href:ud({kind:`list`,resource:o.name,list:n.name},t),...ST(e,s,n.nav,n.names.singular,t)},n.nav?.order)}for(let n of Object.values(e.signIn??{})){if(n.nav?.hidden||a.has(n.resource))continue;let o=n.nav?.group??H(`account`),s=r.get(o)??{label:o,items:[]};s.items.push({id:n.resource,label:n.names?.plural??Hr(n.resource),icon:Hw(e,n.resource),href:ud({kind:`list`,resource:n.resource},t)}),r.set(o,s),i.set(n.resource,n.nav?.order??2**53-1)}for(let n of e.sources??[]){if(n.state!==`error`)continue;let e=r.get(n.source.label)??{label:n.source.label,items:[]};for(let r of n.source.resources)e.items.push({id:r,label:Hr(r),icon:Ml,href:ud({kind:`list`,resource:r},t),problem:H(`cannotReach`,{label:n.source.label})});r.set(n.source.label,e)}return[...r.values()].map(e=>({...e,items:[...e.items].sort((e,t)=>(i.get(e.id)??0)-(i.get(t.id)??0))}))},wT=e=>{let t=CT(e).flatMap(e=>e.items).find(e=>!e.problem);if(t&&e.pages[t.id])return{kind:`page`,page:t.id};if(t){let[e,n]=t.id.split(`/`);return{kind:`list`,resource:e,...n!==void 0&&{list:n}}}let n=Object.keys(e.pages)[0];if(n)return{kind:`page`,page:n};let r=Object.keys(e.resources)[0];return r?{kind:`list`,resource:r}:void 0},TT=(e,t,n)=>{let r=t[n];return e.fields[n]?.type===`relation`&&typeof r==`object`&&r&&`id`in r?r.id:r},ET=(e,t)=>e.primaryKey.map(n=>String(TT(e,t,n))).join(`,`),DT=(e,t)=>{let n=e.primaryKey.map(n=>TT(e,t,n));return n.length===1?n[0]:n},OT=(e,t)=>{let n=t?.list?.sort?.[0];if(n)return`${n[0]} ${n[1]}`;let r=e.primaryKey[0];return e.fields[r]?.sortable?`${r} asc`:``},kT=e=>{let[t=``,n]=e.trim().split(/\s+/);return{columnId:t,direction:n===`desc`?`desc`:`asc`}},AT=e=>`${e.columnId} ${e.direction}`,jT=e=>{for(let t of CT(e).flatMap(e=>e.items)){let n=t.problem?void 0:e.views[t.id]?.nav?.start,r=e.resources[t.id];if(n&&r)return{model:r,start:n}}},MT=({model:e,start:t},n)=>({filter:t.filter,orderBy:t.orderBy??OT(e,n.views[e.name]),pageSize:1,fields:[...e.primaryKey]}),NT=(e,t)=>{let n=t[0];return n&&tr(DT(e,n))},PT=({entry:e,fallback:t,enabled:n,organization:r,metaSettled:i,lookup:a})=>{let o={state:`ready`,...t&&{address:t}};if(r===null)return o;if(r!==``&&!i)return n?{state:`resolving`}:o;if(!e)return o;if(r===void 0||a.pending)return n?{state:`resolving`}:o;if(a.failed)return o;let s=a.rows&&NT(e.model,a.rows);return s===void 0?o:{state:`ready`,address:{kind:`record`,resource:e.model.name,key:s}}},FT=(e,t,n,r)=>t?.data?.etag===e.etag&&(j_(t,n)||r),IT=(e,t,n)=>{let r=X(),i=(0,M.useContext)(k_),a=q_(),o=x().getQueryState(I.meta),s=(0,M.useMemo)(()=>jT(e),[e]),c=(0,M.useMemo)(()=>wT(e),[e]),l=s&&MT(s,e),u=O({queryKey:I.startRecord(s?.model.name??``,l?.filter??``,l?.orderBy??``,n??``),queryFn:()=>r.list(s.model.name,l),enabled:t&&!!s&&typeof n==`string`,retry:!1});return PT({entry:s,fallback:c,enabled:t,organization:n,metaSettled:FT(e,o,i,M_(a)),lookup:{pending:u.isPending,failed:M_(u),...u.data&&{rows:u.data.items}}})},LT=(0,M.createContext)(null),RT=({route:e,children:t})=>(0,L.jsx)(LT.Provider,{value:e,children:t}),zT=()=>{let e=(0,M.useContext)(LT);if(!e)throw Error(`Tabs render inside a page that gives them their addresses: a composed page`);return e},BT=e=>e.children.filter(e=>typeof e!=`string`).map(e=>({node:e,...e.props})),VT=e=>{let t=e.children.find(e=>typeof e!=`string`&&!e.custom&&e.type===`Tabs`);return t?BT(t):[]},HT=(e,t)=>t===void 0?e[0]:e.find(e=>e.name===t),UT=e=>{let t=tT().shell?.logo;return t?(0,L.jsx)(GC,{name:`shell.logo`,fallback:(0,L.jsx)(yb,{...e}),children:(0,L.jsx)(t,{...e})}):(0,L.jsx)(yb,{...e})},WT=(e,t,n)=>{let r=e.bottom+4;return{top:r+t.height>window.innerHeight-4?Math.max(4,e.top-4-t.height):r,right:n-Ob(e.right,t.width,n)}},GT=()=>{let[e,t]=(0,M.useState)(!1),[n,r]=(0,M.useState)(),i=(0,M.useRef)(null),a=(0,M.useRef)(null);return(0,M.useLayoutEffect)(()=>{if(!e||!i.current||!a.current){r(void 0);return}a.current.style.right=`0px`;let t=kb(document.documentElement.clientWidth);a.current.style.maxWidth=`${t}px`;let n=a.current.getBoundingClientRect();r({...WT(i.current.getBoundingClientRect(),n,n.right),maxWidth:t})},[e]),(0,M.useEffect)(()=>{if(!e)return;let n=e=>e instanceof Node&&!!(i.current?.contains(e)||a.current?.contains(e)),r=e=>{a.current?.closest(`[aria-modal="true"]`)||(e instanceof KeyboardEvent?e.key===`Escape`:!n(e.target))&&t(!1)},o=e=>{a.current?.closest(`[aria-modal="true"]`)||n(e.target)||t(!1)};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,r),document.addEventListener(`scroll`,o,!0),window.addEventListener(`resize`,o),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,r),document.removeEventListener(`scroll`,o,!0),window.removeEventListener(`resize`,o)}},[e]),{open:e,setOpen:t,place:n,button:i,menu:a}},KT=(e,t)=>({turnOn:async()=>{t({failure:void 0,busy:!0});try{t({state:await e.turnOn()})}catch(e){console.error(`Notifications could not be turned on:`,e),t({failure:vg(e)})}finally{t({busy:!1})}},turnOff:async()=>{t({failure:void 0,busy:!0});try{await e.turnOff({chosen:!0})}catch(e){console.error(`Notifications could not be turned off for good:`,e),t({failure:vg(e)})}try{t({state:await e.state()})}catch(e){console.error(`Whether notifications are on could not be read:`,e)}finally{t({busy:!1})}}}),qT=(e,t=window)=>{let n,r=!1,i=()=>{t.document.visibilityState===`visible`&&e()};return t.addEventListener(`focus`,e),t.document.addEventListener(`visibilitychange`,i),`permissions`in t.navigator&&t.navigator.permissions.query({name:`notifications`}).then(t=>{r||(n=t,t.addEventListener(`change`,e))},e=>{if(!(e instanceof TypeError))throw e}),()=>{r=!0,t.removeEventListener(`focus`,e),t.document.removeEventListener(`visibilitychange`,i),n?.removeEventListener(`change`,e)}},JT=()=>{let{push:e,state:t}=J(),n=t.kind===`signed-in`?t.user.id:void 0,[r,i]=(0,M.useState)(`loading`),[a,o]=(0,M.useState)(),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(0);(0,M.useEffect)(()=>{let t=!0,n=()=>void e.state().then(e=>t&&i(e));n();let r=typeof window>`u`?void 0:qT(n);return()=>{t=!1,r?.()}},[e,n,l]);let d=(0,M.useCallback)(()=>u(e=>e+1),[]),{turnOn:f,turnOff:p}=(0,M.useMemo)(()=>KT(e,e=>{e.state&&i(e.state),`failure`in e&&o(e.failure),e.busy!==void 0&&c(e.busy)}),[e]);return{state:r,busy:s,failure:a,turnOn:f,turnOff:p,refresh:d}},YT=new Map,XT=(e,t)=>{let n=Ii(),r=`${n}|${e}`;return YT.has(r)||YT.set(r,t(n)),YT.get(r)},ZT=F(`format`),QT=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,$T=new Map,eE=e=>{let t=$T.get(e);if(t)return t;let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`});return $T.set(e,n),n},tE=(e,t)=>{let n=Object.fromEntries(eE(t).formatToParts(e).map(e=>[e.type,e.value]));return{year:Number(n.year),month:Number(n.month),day:Number(n.day),hour:Number(n.hour),minute:Number(n.minute),second:Number(n.second)}},nE=(e,t)=>{let n=tE(e,t);return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-Math.floor(e/1e3)*1e3},rE=e=>String(e).padStart(2,`0`),iE=(e,t)=>{let n=tE(e,t);return`${n.year}-${rE(n.month)}-${rE(n.day)}`},aE=(e,t)=>e-nE(e-nE(e,t),t),oE=(e,t)=>aE(Date.parse(`${e}T00:00:00Z`),t),sE=(e,t)=>{let n=XT(`zoneName:${t}`,e=>new Intl.DateTimeFormat(e,{timeZone:t,timeZoneName:`shortOffset`})).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??t;return t===`UTC`||t===`Etc/UTC`?`UTC`:`${t} (${n})`},cE=(e,t)=>()=>XT(`date:${e}`,e=>new Intl.DateTimeFormat(e,{...t,timeZone:`UTC`})),lE=cE(`day`,{day:`numeric`,month:`short`,year:`numeric`}),uE=cE(`dayShort`,{day:`numeric`,month:`short`}),dE=cE(`month`,{month:`long`,year:`numeric`}),fE=cE(`monthName`,{month:`long`}),pE=cE(`weekday`,{weekday:`short`}),mE=cE(`weekdayDate`,{weekday:`long`,day:`numeric`,month:`short`,year:`numeric`}),hE=e=>lE().format(e),gE=e=>uE().format(e),_E=e=>XT(`zoned:${e}`,t=>({day:new Intl.DateTimeFormat(t,{day:`numeric`,month:`short`,year:`numeric`,timeZone:e}),time:new Intl.DateTimeFormat(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1,timeZone:e})})),vE=(e,t=QT())=>{let n=_E(t);return`${n.day.format(e)}, ${n.time.format(e)}`},yE=e=>dE().format(e),bE=e=>fE().format(e),xE=(e,t)=>dE().formatRange(e,t),SE=e=>pE().format(e),CE=e=>mE().format(e),wE=(e,t)=>lE().formatRange(e,t),TE=(e,t=QT())=>_E(t).time.format(e),EE=e=>e<60?ZT(`secondsAgo`,{count:e}):e<3600?ZT(`minutesAgo`,{count:Math.floor(e/60)}):e<86400?ZT(`hoursAgo`,{count:Math.floor(e/3600)}):ZT(`daysAgo`,{count:Math.floor(e/86400)}),DE=()=>XT(`relative`,e=>new Intl.RelativeTimeFormat(e,{numeric:`auto`})),OE=[[`year`,31536e3],[`month`,2592e3],[`day`,86400],[`hour`,3600],[`minute`,60]],kE=e=>{let t=Math.abs(e),[n,r]=OE.find(([,e])=>t>=e)??[`second`,1];return n===`second`&&t<45?ZT(`justNow`):DE().format(-Math.sign(e)*Math.floor(t/r),n)},AE=F(`notifications/bell`),jE=`flex w-full gap-2.5 px-3 py-2.5 text-left`,ME=({item:e,target:t,onNavigate:n,onOpen:r,now:i})=>{let a=e.readAt===null,o=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:R(`mt-1.5 size-2 shrink-0 rounded-full`,a?Jv.blue:`bg-transparent`),children:a&&(0,L.jsx)(`span`,{className:`sr-only`,children:AE(`unread`)})}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:R(`block text-body text-foreground`,a&&`font-semibold`),children:e.title}),e.body&&(0,L.jsx)(`span`,{className:`mt-0.5 line-clamp-2 block text-xs text-muted-foreground`,children:e.body}),(0,L.jsx)(`time`,{dateTime:e.createdAt,className:`mt-0.5 block text-xs text-faint-foreground`,children:kE((i-Date.parse(e.createdAt))/1e3)})]})]}),s=()=>r(e),c=e=>{e.button===1&&s()};return t?t.kind===`app`?(0,L.jsx)(Du,{to:{href:t.href,onFollow:()=>n(t.path)},onClick:s,onAuxClick:c,className:R(jE,`hover:bg-muted`),children:o}):(0,L.jsx)(`a`,{href:t.href,onClick:s,onAuxClick:c,className:R(jE,`hover:bg-muted`),children:o}):(0,L.jsx)(`div`,{className:jE,children:o})},NE=({items:e,loading:t,failed:n,onRetry:r,hasMore:i,loadingMore:a,onMore:o,onMarkAllRead:s,markingAll:c,targetOf:l,onNavigate:u,onOpen:d,footer:f,now:p})=>{let m=e[0],h=e.some(e=>e.readAt===null);return(0,L.jsxs)(`div`,{className:`flex max-h-[min(32rem,calc(100dvh-var(--pb-sticky-top,3rem)-1rem))] flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 border-b px-3`,children:[(0,L.jsx)(`h2`,{className:`flex-1 text-body font-semibold`,children:AE(`notifications`)}),m&&h&&(0,L.jsx)(B,{size:`sm`,variant:`ghost`,loading:c,onClick:()=>s(m),children:AE(`markAllRead`)})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[t?(0,L.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,L.jsx)(fu,{className:`size-4`})}):n?(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-3 py-6 text-center text-body text-muted-foreground`,children:[(0,L.jsx)(`p`,{children:AE(`loadFailed`)}),(0,L.jsx)(B,{size:`sm`,onClick:r,children:AE(`tryAgain`)})]}):e.length===0?(0,L.jsx)(`p`,{className:`px-3 py-8 text-center text-body text-muted-foreground`,children:AE(`empty`)}):(0,L.jsx)(`ul`,{className:`divide-y`,children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(ME,{item:e,target:l(e),onNavigate:u,onOpen:d,now:p})},e.id))}),i&&!t&&!n&&(0,L.jsx)(`div`,{className:`flex justify-center border-t py-2`,children:(0,L.jsx)(B,{size:`sm`,variant:`ghost`,loading:a,onClick:o,children:AE(`showMore`)})})]}),f]})},PE=(e,{origin:t,basePath:n})=>{if(e===null||!URL.canParse(e,t))return;let r=new URL(e,t);if(r.protocol!==`http:`&&r.protocol!==`https:`)return;if(r.origin!==t)return{kind:`page`,href:r.href};let i=`${r.pathname}${r.search}${r.hash}`;return n===``?{kind:`app`,href:i,path:i}:r.pathname===n||r.pathname.startsWith(`${n}/`)?{kind:`app`,href:i,path:i.slice(n.length)||`/`}:{kind:`page`,href:i}},FE=e=>e.kind===`registration`?AE(`pushRegistrationFailed`,{reason:e.reason}):e.kind===`no-token`?AE(e.service===`apns`?`pushNoTokenApns`:`pushNoTokenFcm`):e.kind===`off-not-stored`?AE(`pushOffNotStored`):e.kind===`refused`?AE(`pushRefused`,{reason:e.reason}):AE(`pushFailed`,{reason:e.reason}),IE=({state:e,busy:t=!1,failure:n,onTurnOn:r,onTurnOff:i})=>{if(e===`loading`||e===`unsupported`)return null;if(e===`blocked`)return(0,L.jsxs)(`p`,{className:`flex gap-2 border-t px-3 py-2.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(Po,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),AE(`pushBlocked`)]});let a=e===`on`,o=!a&&n;return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-t px-3 py-2.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(Io,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),o?(0,L.jsx)(`span`,{role:`alert`,className:`min-w-0 flex-1 text-danger-text`,children:FE(o)}):(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:AE(a?`pushOn`:`pushOff`)}),(0,L.jsx)(B,{size:`sm`,variant:a?`secondary`:`primary`,loading:t,onClick:a?i:r,children:AE(a?`turnOff`:o&&o.kind!==`off-not-stored`?`tryAgain`:`turnOn`)})]})},LE=3e4,RE=e=>Rd(e)&&e.status===403,zE=({enabled:e=!0}={})=>{let t=X();return O({queryKey:I.inboxUnread,queryFn:()=>t.notifications.unread(),refetchInterval:e=>!RE(e.state.error)&&LE,enabled:e})},BE=({enabled:e=!0}={})=>{let t=X(),n=A({queryKey:I.inboxPages,queryFn:({pageParam:e})=>t.notifications.list(e===``?{}:{cursor:e}),initialPageParam:``,getNextPageParam:e=>e.next??void 0,enabled:e}),r=n.data?.pages.flatMap(e=>e.items)??[];return{...n,items:r}},VE=(e,t)=>{let n=new Date().toISOString(),r=0;e.setQueryData(I.inboxPages,e=>e&&{...e,pages:e.pages.map(e=>({...e,items:e.items.map(e=>e.readAt!==null||!t(e)?e:(r+=1,{...e,readAt:n}))}))}),e.setQueryData(I.inboxUnread,e=>e===void 0?e:Math.max(0,e-r))},HE=()=>{let e=X(),t=x(),n=()=>t.invalidateQueries({queryKey:I.inbox}),r=S({mutationFn:t=>e.notifications.markRead(t.id),onMutate:e=>VE(t,t=>t.id===e.id),onSettled:n}),i=S({mutationFn:t=>e.notifications.markAllRead(t.createdAt),onMutate:e=>VE(t,t=>t.createdAt<=e.createdAt),onSettled:n}),a=r.mutate;return{markRead:(0,M.useCallback)(e=>{e.readAt===null&&a(e)},[a]),markAllRead:i.mutate,markingAll:i.isPending}},UE=99,WE=e=>e===void 0||e<=0?AE(`notifications`):e>UE?AE(`notificationsManyUnread`):AE(`notificationsUnread`,{count:String(e)}),GE=()=>{let{open:e,setOpen:t,place:n,button:r,menu:i}=GT(),a=zE(),o=BE({enabled:e}),{markRead:s,markAllRead:c,markingAll:l}=HE(),u=JT(),{navigate:d,basePath:f}=Hu(),[p,m]=(0,M.useState)(Date.now),h=WE(a.data),g=window.location.origin;return RE(a.error)?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(B,{ref:r,size:`icon`,variant:`ghost`,"aria-label":h,title:h,"aria-haspopup":`dialog`,"aria-expanded":e,onClick:()=>{e||(m(Date.now()),a.refetch(),o.data&&o.refetch(),u.busy||u.refresh()),t(!e)},className:`relative max-md:size-9`,children:[(0,L.jsx)(Ro,{className:`size-4 max-md:size-5`}),(0,L.jsx)(wx,{count:a.data,className:`pointer-events-none absolute -top-1 -right-1.5 max-md:top-0 max-md:right-0`})]}),(0,L.jsx)(ox,{open:e,title:WE(void 0),onClose:()=>t(!1),menu:(0,L.jsx)(`div`,{ref:i,role:`dialog`,"aria-label":WE(void 0),style:n??{visibility:`hidden`},className:`fixed z-50 w-[min(22rem,calc(100%-0.5rem))] rounded-md border bg-background shadow-pop`,children:(0,L.jsx)(NE,{items:o.items,loading:o.isPending,failed:o.isError,onRetry:()=>void o.refetch(),hasMore:o.hasNextPage,loadingMore:o.isFetchingNextPage,onMore:()=>void o.fetchNextPage(),onMarkAllRead:c,markingAll:l,targetOf:e=>PE(e.url,{origin:g,basePath:f}),onNavigate:e=>d(e),onOpen:e=>{s(e),t(!1)},footer:(0,L.jsx)(IE,{state:u.state,busy:u.busy,failure:u.failure,onTurnOn:()=>void u.turnOn(),onTurnOff:()=>void u.turnOff()}),now:p})})})]})},KE=({own:e})=>e?(0,L.jsx)(GC,{name:`shell.bell`,fallback:null,children:(0,L.jsx)(e,{})}):(0,L.jsx)(GE,{}),qE=(0,M.createContext)([]),JE=()=>(0,M.useContext)(qE),YE=({ui:e,children:t})=>{let{plugins:n=[]}=Tv(),{loads:r,settled:i}=Xa(n,qa()),a=(0,M.useMemo)(()=>KC(e,r),[e,r]);return i?(0,L.jsx)(eT.Provider,{value:a.ui,children:(0,L.jsx)(qE.Provider,{value:a.off,children:t})}):(0,L.jsxs)(`div`,{className:R(`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,Cu),children:[(0,L.jsx)(nv,{}),(0,L.jsx)(fu,{}),` `,da(`loading`)]})},XE=({off:e})=>{let[t,n]=(0,M.useState)(!1);return t||e.length===0?null:(0,L.jsxs)(`div`,{role:`region`,"aria-label":da(`pluginsOff`),className:`flex items-start gap-3 border-b border-warning/40 bg-warning-soft px-4 py-2 text-warning-text`,children:[(0,L.jsx)(el,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,L.jsx)(`ul`,{className:`min-w-0 flex-1 space-y-0.5 break-words`,children:e.map(e=>(0,L.jsx)(`li`,{children:da.rich(`pluginOff`,{plugin:(0,L.jsx)(`span`,{className:`font-semibold`,children:e.name??e.url}),reason:e.reason})},e.url))}),(0,L.jsx)(`button`,{type:`button`,"aria-label":da(`dismiss`),className:`rounded p-0.5 hover:bg-warning/10`,onClick:()=>n(!0),children:(0,L.jsx)(uu,{"aria-hidden":!0,className:`size-4`})})]})},ZE=({title:e,description:t,open:n,onClose:r,actions:i,children:a,wide:o})=>{let s=ly();return n?s?(0,L.jsx)(xu,{title:e,description:t,onClose:r,actions:i,wide:o,children:a}):(0,L.jsx)(ix,{title:e,open:!0,onClose:r,children:(0,L.jsxs)(`div`,{className:`pt-3`,children:[t&&(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:t}),a&&(0,L.jsx)(`div`,{className:`mt-4`,children:a}),(0,L.jsx)(`div`,{className:`mt-5 flex flex-col-reverse gap-2 [&>*]:min-h-11`,children:i})]})}):null},QE=({failed:e})=>(0,L.jsxs)(`span`,{"data-fetching":!0,className:`inline-flex items-center text-muted-foreground`,children:[(0,L.jsx)(`span`,{role:`status`,className:`sr-only`,children:H(e?`refreshFailed`:`refreshing`)}),e?(0,L.jsx)($E,{}):(0,L.jsx)(`span`,{className:Cu,children:(0,L.jsx)(fu,{hidden:!0})})]}),$E=()=>{let[e,t]=(0,M.useState)(!1),n=(0,M.useContext)(k),r=(0,M.useContext)(k_);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,"aria-label":H(`refreshWhy`),onClick:()=>t(!0),className:`-m-3 inline-flex size-11 items-center justify-center rounded-md md:-m-1 md:size-7`,children:(0,L.jsx)(Bl,{"aria-hidden":!0,className:`size-4 text-warning`})}),(0,L.jsx)(ZE,{title:H(`refreshFailedTitle`),description:H(`refreshFailedHelp`),open:e,onClose:()=>t(!1),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:()=>t(!1),children:H(`refreshClose`)}),(0,L.jsx)(B,{variant:`primary`,onClick:()=>{t(!1),n?.refetchQueries({type:`active`,predicate:e=>A_(e.state,r)})},children:H(`refreshRetry`)})]})})]})},eD=15e3,tD=()=>{let e=l_();return q_().data?.status&&e?.state.kind===`signed-in`?String(e.state.user.id):void 0},nD=()=>{let e=X(),t=tD();return O({queryKey:I.statuses(t??``),enabled:t!==void 0,refetchInterval:eD,queryFn:()=>e.status.people()})},rD=()=>{let e=X(),t=tD();return O({queryKey:I.ownStatus(t??``),enabled:t!==void 0,refetchInterval:eD,queryFn:()=>e.status.own()})},iD=(e,t=Date.now())=>e.isSuccess&&!e.isFetching&&t-e.dataUpdatedAt>=1e4,aD=(e,t)=>{let n=new Map(t.map(e=>[e.userId,e]));return e.map(e=>{let t=n.get(e.id);return t?{...e,status:t}:e})},oD=()=>{let e=l_(),t=e?.state.kind===`signed-in`?e.state.user:void 0,n=O({queryKey:I.members(t?.id??``),enabled:t!==void 0,queryFn:()=>{if(!e?.organizations)throw Error(`useMembers() needs organizations: turn them on in the auth config.`);return e.session.organizations.people()}}),r=nD().data,i=(0,M.useMemo)(()=>n.data&&(r?aD(n.data,r):n.data),[n.data,r]),a=(0,M.useMemo)(()=>new Map((i??[]).map(e=>[e.id,e])),[i]),{refetch:o}=n,s=(0,M.useCallback)(e=>{let t=a.get(e);return!t&&iD(n)&&setTimeout(()=>void o(),0),t},[a,n,o]);return{...n,data:i,member:s}},sD=(e,t)=>Array.isArray(e)?e.filter(e=>typeof e==`string`&&e!==t):[],cD=e=>(t,{user:n,member:r})=>{let i=sD(t[e],n?.id).map(e=>r(e)?.name);if(i.length!==0&&i.every(Boolean))return i.join(`, `)},lD=(e,t)=>t?.titleFrom?.fields??[],uD=(e,t)=>(n,r,i,a)=>{let o=r?.titleFrom;if(!o)return Jr(n,r,i,a);let s=o.rule===`members`?cD(o.fields[0]):e[o.rule];return!s||o.unreadable||o.fields.some(e=>i[e]===void 0)?a:s(i,t)||a},dD=()=>void 0,fD=(0,M.createContext)(uD({},{user:void 0,member:dD})),pD=()=>(0,M.useContext)(fD),mD=({rules:e,user:t,children:n})=>{let r=(0,M.useMemo)(()=>uD(e,{user:t,member:dD}),[e,t]);return(0,L.jsx)(fD.Provider,{value:r,children:n})},hD=({rules:e,user:t,children:n})=>{let{member:r}=oD(),i=(0,M.useMemo)(()=>uD(e,{user:t,member:r}),[e,t,r]);return(0,L.jsx)(fD.Provider,{value:i,children:n})},gD=({children:e})=>{let{views:t}=Tv(),{titles:n}=tT(),r=l_(),i=r?.state.kind===`signed-in`?r.state.user:void 0,a=n??{};return Object.values(t).some(e=>e.titleFrom!==void 0)&&i&&r?.organizations?(0,L.jsx)(hD,{rules:a,user:i,children:e}):(0,L.jsx)(mD,{rules:a,user:i,children:e})},_D=e=>Rd(e)?e.status===401||e.status===403?H(`signInRefused`,{message:e.message}):e.message:H(`noAnswer`),vD=({status:e})=>{let t=x();return e.state===`error`?(0,L.jsx)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center p-8`,children:(0,L.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,L.jsx)(`h1`,{className:`text-base font-semibold`,children:H(`cannotReach`,{label:e.source.label})}),(0,L.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[_D(e.error),` `,H(`restWorks`)]}),(0,L.jsx)(B,{className:`mt-3`,onClick:()=>void t.refetchQueries({queryKey:I.sourceMetas(e.source.url)}),children:H(`tryAgain`)})]})}):(0,L.jsxs)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{}),` `,H(`loadingFrom`,{label:e.source.label})]})},yD=(e,t)=>{let[n,r]=(0,M.useState)(e);return(0,M.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n},bD=F(`app/search`),xD=(e,t)=>e.toLowerCase().includes(t.trim().toLowerCase()),SD=(e,t,n=``)=>{let r=CT(e,n).flatMap(e=>e.items.filter(e=>e.href!==void 0&&!e.problem)).filter(e=>xD(e.label,t)).slice(0,5),i=t.trim().replace(/^new\s+/i,``),a=Object.values(e.resources).flatMap(r=>{let a=e.views[r.name];if(!a||a.nav?.hidden||!gT(a,e.pages,e.permissions[r.name]??G_))return[];let o=a.names?.singular??Hr(r.name),s=yS(`title`,{noun:o});return!xD(s,t)&&!xD(o,i)&&!xD(a.names?.plural??Hr(r.name),i)?[]:[{id:`new:${r.name}`,title:s,href:ud({kind:`create`,resource:r.name},n)}]});return[...r.length>0?[{id:`go-to`,label:bD(`goTo`),hits:r.map(e=>({id:`go-to:${e.id}`,title:e.label,href:e.href}))}]:[],...a.length>0?[{id:`create`,label:bD(`create`),hits:a.slice(0,5)}]:[]]},CD=e=>e==null||e===``,wD=(e,t)=>{let n=e.find(e=>!Kt(e).some(e=>CD(t[e])));return n&&rn(n,t)},TD=At(),ED=e=>Object.values(e.resources).flatMap(t=>{let n=e.views[t.name];return!t.search?.length||!n||n.nav?.hidden||e.permissions[t.name]?.read===!1?[]:[{model:t,view:n,label:n.names?.plural??Hr(t.name)}]}),DD=e=>{let t=e.map(e=>e.label.toLowerCase());return t.length===0?bD(`search`):t.length===1?bD(`searchOne`,{name:t[0]}):t.length===2?bD(`searchTwo`,{first:t[0],second:t[1]}):bD(`searchMore`,{first:t[0],second:t[1]})},OD=e=>yt(TD.search(e.trim())),kD=e=>!e.view?.searchResult?.title?.length&&e.view?.titleFrom!==void 0,AD=e=>{let t=e.view?.searchResult?.title;return t?.length?t:kD(e)?[]:[qr(e.model,e.view)]},jD=e=>{let t=AD(e);return e.view?.searchResult?.subtitle??e.model.search?.find(e=>!t.includes(e))},MD=e=>{let t=jD(e),n=kD(e)?lD(e.model,e.view):[],r=(e.view?.recordOpens??[]).flatMap(Kt),i=[...AD(e),...n,...t?[t]:[],...e.model.search??[],...r];return[...new Set([...e.model.primaryKey,...i.filter(t=>Object.hasOwn(e.model.fields,t))])]},ND=(e,t,n)=>{let r=t[n];return r==null?``:e.model.fields[n]?.type===`enum`?Ur(String(r),e.view?.fields[n]?.valueLabels):String(r)},PD=(e,t,n,r=``,i=uD({},{user:void 0,member:()=>void 0}))=>{let a=tr(DT(e.model,t)),o=AD(e),s=jD(e),c=vt(e.model,t,n,[...o,...s?[s]:[]])??s,l=c?ND(e,t,c):``;return{id:a,title:kD(e)?i(e.model,e.view,t,a):o.map(n=>ND(e,t,n)).filter(Boolean).join(` `)||a,...l&&{subtitle:l},href:ud(wD(e.view?.recordOpens??[],t)??{kind:`record`,resource:e.model.name,key:a},r)}},FD=()=>{let e=Tv(),t=X(),{basePath:n}=Hu(),r=pD(),i=(0,M.useMemo)(()=>ED(e),[e]),[a,o]=(0,M.useState)(``),s=a.trim(),c=yD(s,200),l=s.length>=2,u=l&&c.length>=2,d=ee({queries:i.map(e=>({queryKey:[`global-search`,e.model.name,c],enabled:u,staleTime:1/0,gcTime:0,queryFn:()=>t.list(e.model.name,{filter:OD(c),pageSize:5,fields:MD(e)})}))}),f=(0,M.useMemo)(()=>u?SD(e,c,n):[],[u,e,c,n]),p=i.flatMap((e,t)=>{let i=d[t];if(!u||!i)return[];if(i.error)return[{id:e.model.name,label:e.label,hits:[],failed:!0}];let a=(i.data?.items??[]).map(t=>PD(e,t,c,n,r));return a.length>0?[{id:e.model.name,label:e.label,hits:a}]:[]}),m=[...f,...p];return{available:Object.keys(e.pages).length>0||Object.keys(e.resources).length>0,placeholder:DD(i),text:a,setText:o,query:u?c:``,loading:l&&(s!==c||d.some(e=>e.isFetching)),groups:m}},ID=(0,M.createContext)(void 0),LD=()=>(0,M.useContext)(ID),RD=F(`app/new-version`),zD=()=>{let{versionChange:e,appName:t}=Tv(),{reload:n}=Hu(),r=LD();return!e||r?null:(0,L.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full shrink-0 items-start gap-2 border-t border-warning/40 bg-warning-soft px-3.5 py-2 text-left text-warning-text transition-colors hover:bg-warning/15 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary`,children:[(0,L.jsx)(ol,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`break-words font-semibold`,children:t?RD.rich(`bannerTitle`,{app:t}):RD(`title`)}),(0,L.jsx)(`span`,{className:`text-xs`,children:RD(`bannerLine`)})]})]})},BD=()=>{let e=!!Tv().versionChange,{reload:t}=Hu(),n=LD();return!e||n?null:(0,L.jsxs)(B,{size:`sm`,variant:`ghost`,"aria-label":RD(`reloadPageHint`),title:RD(`reloadPageHint`),onClick:t,className:`max-md:size-9 max-md:p-0`,children:[(0,L.jsx)(ol,{className:`size-3.5 text-primary`}),(0,L.jsx)(`span`,{className:`max-md:sr-only`,children:RD(`reloadPage`)})]})},VD=()=>document.querySelector(`[aria-modal="true"]`)!==null,HD=()=>{let[e,t]=(0,M.useState)(VD);return(0,M.useEffect)(()=>{let e=new MutationObserver(()=>t(VD()));return e.observe(document.body,{childList:!0,subtree:!0}),t(VD()),()=>e.disconnect()},[]),e},UD=()=>{let e=!!Tv().versionChange,t=HD(),[n,r]=(0,M.useState)(!1),i=Lw(),{reload:a}=Hu(),o=LD(),s=e&&!n&&!t&&!o;return(0,M.useEffect)(()=>{if(!s)return;let e=i.show({state:`info`,sticky:!0,title:RD(`title`),description:RD(`description`),action:{label:RD(`reload`),onClick:a},onClose:()=>r(!0)});return()=>i.dismiss(e)},[s,i,a]),null},WD=(e,t=()=>null)=>{let n,r,i=()=>r??=e().then(e=>n=e,e=>{throw r=void 0,e}),a=e=>{let t=n??(0,M.use)(i());return(0,L.jsx)(t,{...e})};return Object.assign(e=>(0,L.jsx)(M.Suspense,{fallback:(0,L.jsx)(`span`,{"aria-busy":!0,className:`contents`,children:t(e)}),children:(0,L.jsx)(a,{...e})}),{preload:i})},GD=()=>(0,L.jsxs)(`div`,{role:`status`,"aria-label":H(`loading`),"aria-busy":!0,className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[(0,L.jsx)(Su,{className:`h-7 w-48`}),(0,L.jsx)(Su,{className:`h-9 w-full max-w-96`}),(0,L.jsx)(Su,{className:`min-h-60 flex-1 rounded-lg`})]}),KD=[32,24,40,28,20],qD=()=>(0,L.jsxs)(`div`,{role:`status`,"aria-label":H(`loading`),"aria-busy":!0,className:`mx-auto w-full max-w-[1100px] px-4 pb-8 pt-6 md:px-10 md:py-8`,children:[(0,L.jsx)(Su,{className:`h-8 w-3/4 max-w-96`}),(0,L.jsxs)(`div`,{className:`mt-10 grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(Su,{className:`h-5 w-32`}),(0,L.jsx)(`div`,{className:`mt-5 divide-y divide-border border-t`,children:KD.map((e,t)=>(0,L.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] gap-x-4 py-3`,children:[(0,L.jsx)(Su,{className:`h-4 w-24`}),(0,L.jsx)(Su,{className:`h-4`,style:{width:`${e*2}%`}})]},t))})]}),(0,L.jsx)(Su,{className:`h-40 rounded-lg max-md:hidden`})]})]}),JD=2e3,YD={type:`active`,predicate:e=>e.state.data===void 0},XD=(e,t)=>e.some(e=>A_(e.state,t))&&!e.some(e=>e.state.dataUpdatedAt>=t),ZD=({children:e})=>{let t=x(),n=(0,M.useContext)(k_),r=h(YD),[i,a]=(0,M.useState)(()=>XD(t.getQueryCache().getAll(),n));return(0,M.useEffect)(()=>{if(i)return;let e=setTimeout(()=>a(!0),JD);return()=>clearTimeout(e)},[i]),(0,M.useEffect)(()=>{if(i||r>0)return;let e=setTimeout(()=>t.isFetching(YD)===0&&a(!0),0);return()=>clearTimeout(e)},[i,r,t]),(0,L.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,"aria-busy":!i||void 0,children:[(0,L.jsx)(`div`,{className:R(`flex min-h-0 flex-1 flex-col`,!i&&`invisible`),children:e}),!i&&(0,L.jsx)($D,{})]})},QD=()=>(0,L.jsx)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:(0,L.jsx)($D,{})}),$D=()=>(0,L.jsxs)(`div`,{role:`status`,"aria-label":H(`loading`),className:`absolute inset-x-0 top-0 flex flex-col gap-4 p-4 md:p-6`,children:[(0,L.jsx)(Su,{className:`h-6 w-48`}),(0,L.jsx)(Su,{className:`h-24`}),(0,L.jsx)(Su,{className:`h-40`}),(0,L.jsx)(Su,{className:`h-40`})]}),eO=WD(()=>s(()=>import(`./list-page-CHdsbqR8.js`).then(e=>e.ListPage),__vite__mapDeps([5,1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])),()=>(0,L.jsx)(GD,{})),tO=WD(()=>s(()=>import(`./record-page-DVmkJFmF.js`).then(e=>e.RecordPage),__vite__mapDeps([28,1,6,7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,29,30,25,31,32,33,34,35,24,36,37,38])),()=>(0,L.jsx)(qD,{})),nO=WD(()=>s(()=>import(`./create-route-CZDGdfY8.js`).then(e=>e.CreateRoute),__vite__mapDeps([39,1,6,40,29,7,9,10,11,12,13,14,15,16,17,18,19,20,21,30,25,31,32,33,34,35,37,38])),()=>(0,L.jsx)(qD,{})),rO=WD(()=>s(()=>import(`./composed-page-D3_OTQB4.js`).then(e=>e.ComposedPage),__vite__mapDeps([40,1,6,29,7,9,10,11,12,13,14,15,16,17,18,19,20,21,30,25,31,32,33,34,35,37])),()=>(0,L.jsx)(QD,{})),iO=WD(()=>s(()=>import(`./account-page-K162oV2K.js`).then(e=>e.AccountPage),__vite__mapDeps([41,1,6,29,7,9,10,11,12,13,14,15,16,17,18,19,20,21,30,25,31,32,33,34,35])),()=>(0,L.jsx)(QD,{})),aO=WD(()=>s(()=>import(`./sign-in-policy-page-B-m5Pcyb.js`).then(e=>e.SignInPolicyPage),__vite__mapDeps([42,1,6,25])),()=>(0,L.jsx)(QD,{})),oO=WD(()=>s(()=>import(`./organization-page-DE4U9Xbi.js`).then(e=>e.OrganizationPage),__vite__mapDeps([43,1,6,25])),()=>(0,L.jsx)(QD,{})),sO=WD(()=>s(()=>import(`./first-organization-page-B986-W2g.js`).then(e=>e.FirstOrganizationPage),__vite__mapDeps([44,1,6,45,7])),()=>(0,L.jsx)(QD,{})),cO=WD(()=>s(()=>import(`./organizations-page-DcRX2C5D.js`).then(e=>e.OrganizationsPage),__vite__mapDeps([46,1,6,25,33,45,7])),()=>(0,L.jsx)(QD,{})),lO=WD(()=>s(()=>import(`./members-page-CCLPZ9sH.js`).then(e=>e.MembersPage),__vite__mapDeps([47,1,6,7,25,32])),()=>(0,L.jsx)(QD,{})),uO=WD(()=>s(()=>import(`./invitations-page-Ds817tOV.js`).then(e=>e.InvitationsPage),__vite__mapDeps([48,1,6,25,31,32,47,7])),()=>(0,L.jsx)(QD,{})),dO=WD(()=>s(()=>import(`./connect-route-D0m9ozLK.js`).then(e=>e.ConnectRoute),__vite__mapDeps([49,1,6,34])),()=>(0,L.jsx)(nv,{})),fO=WD(()=>s(()=>import(`./public-form-page-C2K3mhKj.js`).then(e=>e.PublicFormPage),__vite__mapDeps([50,1,6,7,51])),()=>(0,L.jsx)(nv,{})),pO=WD(()=>s(()=>import(`./guest-call-page-CKEva7eV.js`).then(e=>e.GuestCallPage),__vite__mapDeps([52,1,6,7])),()=>(0,L.jsx)(nv,{})),mO=WD(()=>s(()=>import(`./assistant-shell-BudITySr.js`).then(e=>e.AssistantPanel),__vite__mapDeps([53,1,6]))),hO=WD(()=>s(()=>import(`./call-rings-pKCPyD1-.js`).then(e=>e.CallRings),__vite__mapDeps([54,1,6,7]))),gO=WD(()=>s(()=>import(`./runtime-update-DWO9xR0h.js`).then(e=>e.RuntimeUpdateButton),__vite__mapDeps([55,1,6]))),_O,vO=()=>_O??=Promise.allSettled([eO.preload(),tO.preload(),rO.preload()]),yO=(e,t)=>XT(`money:${e}:${t??``}`,n=>new Intl.NumberFormat(n,{style:`currency`,currency:e,...t!==void 0&&{minimumFractionDigits:t,maximumFractionDigits:t}})),bO=(e,t,n)=>yO(t,n).format(e/100),xO=()=>XT(`grouped`,e=>new Intl.NumberFormat(e)),SO=e=>xO().format(e),CO=e=>e>0?`+${xO().format(e)}`:xO().format(e).replace(`-`,`−`),wO=e=>`${e}%`,TO=e=>{if(e<1e4)return ZT(`rows`,{count:SO(e),n:e});let t=10**(Math.floor(Math.log10(e))-3);return ZT(`aboutRows`,{count:SO(Math.round(e/t)*t)})},EO=({signIn:e,onStop:t})=>{let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(),o=async()=>{r(!0),a(void 0);try{await t()}catch(e){if(!(e instanceof K))throw e;a(Iv(e)),r(!1)}};return(0,L.jsxs)(`div`,{role:`region`,"aria-label":H(`staffSession`),className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-warning/40 bg-warning-soft px-4 py-2 text-warning-text`,children:[(0,L.jsx)(Kl,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,L.jsx)(`p`,{className:`min-w-64 flex-1 break-words`,children:H.rich(`staffSignedIn`,{staff:(0,L.jsx)(`span`,{className:`font-semibold`,children:e.staffName??e.staff}),user:(0,L.jsx)(`span`,{className:`font-semibold`,children:e.user}),until:vE(Date.parse(e.expiresAt)),reason:e.reason})}),i&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,L.jsx)(B,{size:`sm`,loading:n,onClick:()=>void o(),children:H(`stopStaffSession`)})]})},DO=(e,t,n)=>{if(!e)return;let r=new Map((n??[]).map(e=>[e.userId,e]));return Object.fromEntries(Object.entries(e).map(([e,{person:n,...i}])=>{if(n===void 0)return[e,i];let a=r.get(n),o=Zw(t,n);return[e,{...i,person:{...a&&{status:a},...o&&{presence:o}}}]}))},OO=(e,t,n)=>({filter:n.filter??``,orderBy:n.orderBy??OT(e,t),pageSize:n.limit??3,fields:[...new Set([...e.primaryKey,qr(e,t),...lD(e,t),...n.status===void 0?[]:[n.status]])]}),kO=(e,t,n,r)=>{if(n.status===void 0)return;let i=String(r[n.status]??``);return{label:e.fields[n.status]?.type===`enum`&&i?Ur(i,t.fields[n.status]?.valueLabels):i,tone:n.tones?.[i]??`neutral`,pulse:n.pulse?.includes(i)??!1}},AO=(e,t,n,r,i,a,o)=>r.map(r=>{let s=tr(DT(e,r)),c=kO(e,t,n,r);return{id:s,label:o(e,t,r,s),href:ud({kind:`record`,resource:e.name,key:s},i),...c&&{status:c},active:s===a}}),jO=(e,t,n,r,i)=>{let a=n.find(t=>tr(DT(e,t))===r);return a!==void 0&&t.some(e=>!Object.is(a[e],i[e]))},MO=(e,t,n)=>{if(t.marks===void 0||!n||!Object.hasOwn(n,t.marks))return;let r=n[t.marks];return()=>r(e)},NO=e=>e&&(()=>DO(e(),Xw(),nD().data)),PO=({model:e,request:t})=>I.navRecent(e.name,t.filter,t.orderBy,t.pageSize),FO=e=>{let t=x();(0,M.useEffect)(()=>t.getQueryCache().subscribe(n=>{if(n.type!==`updated`||n.action.type!==`success`)return;let[r,i,a]=n.query.queryKey,o=n.action.data?.record;if(r===`record`&&typeof a==`string`&&o)for(let n of e){if(n.model.name!==i)continue;let e=t.getQueryData(PO(n));e&&jO(n.model,n.request.fields,e.items,a,o)&&t.invalidateQueries({queryKey:PO(n),exact:!0})}}),[t,e])},IO=(e,t,n,r=!0)=>{let i=X(),a=pD(),{marks:o}=tT(),s=(0,M.useMemo)(()=>{if(!r)return[];let t=_T(e);return Object.values(e.views).flatMap(n=>{let r=e.resources[n.resource],i=n.nav?.recent;return r&&i&&!n.nav?.hidden&&!t.has(r.name)?[{model:r,view:n,recent:i,request:OO(r,n,i),useMarks:NO(MO(r.name,i,o))}]:[]})},[e,o,r]);FO(s);let c=ee({queries:s.map(e=>({queryKey:PO(e),queryFn:()=>i.list(e.model.name,e.request)}))});return Object.fromEntries(s.map(({model:e,view:r,recent:i,useMarks:o},s)=>{let l=c[s];if(l.isPending)return[e.name,{state:`loading`}];if(l.isError)return[e.name,{state:`error`}];let u=n.resource===e.name?n.key:void 0;return[e.name,{state:`ready`,records:AO(e,r,i,l.data.items,t,u,a),...o&&{useMarks:o}}]}))},LO=F(`live`),RO=e=>typeof e==`object`&&!!e&&typeof e.uri==`string`,zO=e=>typeof e==`object`&&!!e&&typeof e.uploaded?.value==`string`,BO=e=>{if(zO(e))return{...e.uploaded.file,...e.preview&&{url:e.preview},corrected:e.uploaded.corrected};if(RO(e))return`missing`in e?{name:LO(`fileMissing`),type:``,missing:!0}:e},VO=[`bytes`,`kB`,`MB`,`GB`],HO=e=>{let t=e,n=0;for(;t>=1e3&&n<VO.length-1;)t/=1e3,n+=1;return n===0?`${e} ${e===1?`byte`:`bytes`}`:`${t<10?t.toFixed(1):Math.round(t)} ${VO[n]}`},UO=e=>e.startsWith(`image/`)&&e!==`image/svg+xml`,WO=2,GO=1e5,KO=(e,t)=>(e.width!==void 0||e.height!==void 0)&&(e.width??GO)>=t.width*WO&&(e.height??GO)>=t.height*WO,qO=e=>(e.width??GO)*(e.height??GO),JO=(e,t)=>{let n=BO(e);if(!(!n||`missing`in n||!n.url||!UO(n.type)))return{url:(`variants`in n&&n.variants?Object.values(n.variants):[]).filter(e=>KO(e,t)).sort((e,t)=>qO(e)-qO(t))[0]?.url??n.url,...`placeholder`in n&&n.placeholder!==void 0&&{placeholder:n.placeholder}}},YO=e=>{let t=e.file?.accept??[];return t.length===0||t.includes(`*/*`)?void 0:t.join(`,`)},XO=e=>zO(e)?e.uploaded.value:RO(e)?e.uri:null,ZO=(e,t)=>{if(zO(e))return!0;let n=e=>RO(e)?e.uri:null;return n(e)!==n(t)},QO=F(`data-grid`),$O=e=>typeof e==`object`&&e&&`name`in e?String(e.name):String(e),ek=(e,t)=>{if(t==null)return`—`;switch(e.kind){case`text`:case`id`:return String(t);case`money`:if(e.currency===void 0)throw Error(`Money column "${e.id}" has no currency`);return`${bO(Number(t),e.currency,e.decimals)}${e.suffix??``}`;case`date`:return hE(Number(t));case`datetime`:return e.relative?kE(Math.round((Date.now()-Number(t))/1e3)):vE(Number(t));case`number`:return`${e.prefix??``}${SO(Number(t))}${e.suffix??``}`;case`signed`:return`${e.prefix??``}${CO(Number(t))}${e.suffix??``}`;case`percent`:return Number(t)===0?`—`:wO(Number(t));case`status`:return Ur(String(t),e.labels);case`relation`:return $O(t);case`boolean`:return t?void 0:QO(`no`);case`file`:return BO(t)?.name??`—`;case`user`:return e.users?.(String(t))?.name??String(t)}},tk=(e,t)=>Math.ceil(e.length*7.2)+24+(t?16:0)+28,nk=e=>Math.ceil(Math.max(0,...e.map(e=>e.length))*7.2)+56,rk={body:7.5,mono:7.2,numeric:8},ik=24,ak=16,ok=new Set([`status`,`money`,`number`,`signed`,`percent`,`date`,`datetime`,`boolean`]),sk=new Set([`money`,`number`,`signed`,`percent`,`date`,`datetime`]),ck=80,lk=400,uk=240,dk=e=>e===`id`?rk.mono:sk.has(e)?rk.numeric:rk.body,fk=(e,t)=>e.value?e.value(t):t[e.id],pk=(e,t)=>{let n=t.map(t=>ek(e,fk(e,t)));if(e.kind===`status`)return nk(n.map(e=>e??``));let r=e.kind===`user`||e.kind===`file`?ik:0;return Math.max(0,...n.map(t=>t===void 0?ak:Math.ceil(t.length*dk(e.kind))))+r+24},mk=(e,t,n)=>Math.min(n,Math.max(t,e)),hk=(e,t)=>{if(ok.has(e.kind)&&!e.title)return{...e,fixed:!0,width:Math.max(e.minWidth??0,t)};let n={...e,fixed:!1,width:mk(t,ck,lk)};return e.kind===`id`?{...n,minWidth:Math.max(tk(e.header,e.sortable??!1),Math.min(t,uk))}:n},gk=(e,t)=>{if(!e.fit)return e;let n=Math.max(0,...t.map(e.fit));return{...e,fixed:!0,width:mk(n,e.minWidth??0,e.maxWidth??1/0)}},_k=(e,t)=>{if(t.length===0)return e;let n=e.map(e=>e.render?gk(e,t):hk(e,pk(e,t))),r=n.filter((t,n)=>!t.fixed&&!t.title&&!e[n].render).map(e=>e.width),i=Math.max(0,...r);return n.map((t,n)=>t.title&&!e[n].render?{...t,width:Math.max(t.width,i)}:t)},vk=[[/^\s*(```|~~~).*$/,``],[/^\s*\[[^\]]+\]:\s+\S.*$/,``],[/^\s*([-*_]\s*){3,}$/,``],[/^\s*\|?(\s*:?-+:?\s*\|)+\s*:?-*:?\s*$/,``],[/^\s*#{1,6}\s+/,``],[/^\s*(>\s?)+/,``],[/^\s*([-*+]|\d+[.)])\s+(\[[ xX]\]\s+)?/,``]],yk=[[/!\[([^\]]*)\]\([^)]*\)/g,`$1`],[/\[([^\]]*)\]\([^)]*\)/g,`$1`],[/\[([^\]]+)\]\[[^\]]*\]/g,`$1`],[/<((?:https?|mailto):[^>\s]+)>/gi,`$1`],[/<\/?[a-z][^>]*>/gi,``],[/`([^`]+)`/g,`$1`],[/(?<!\\)(\*\*|__)(?=\S)(.+?)(?<=\S)\1/g,`$2`],[/(?<![\\\w*])\*(?=\S)(.+?)(?<=\S)\*/g,`$1`],[/(?<![\\\w])_(?=\S)(.+?)(?<=\S)_(?!\w)/g,`$1`],[/(?<!\\)~~(.+?)~~/g,`$1`],[/\s*\|\s*/g,` `],[/\\([\\`*_{}[\]()#+\-.!>~|])/g,`$1`]],bk=200,xk=e=>{let t=e.split(/\r?\n/).map(e=>vk.reduce((e,[t,n])=>e.replace(t,n),e)),n=yk.reduce((e,[t,n])=>e.replace(t,n),t.join(`
4
- `)).replace(/\s+/g,` `).trim();return n.length>bk?`${n.slice(0,199).trimEnd()}…`:n},Sk=(e,t)=>e.type===`text`&&!!t?.markdown,Ck=new Set([`email`,`phone`,`url`]),wk=e=>e?.format!==void 0&&Ck.has(e.format)?e.format:void 0,Tk=(e,t)=>{let n=t.trim();if(e===`email`)return/^[^\s@]+@[^\s@]+$/.test(n)?`mailto:${n}`:void 0;if(e===`phone`){let e=n.replace(/[^\d+]/g,``).replace(/(?!^)\+/g,``);return/\d/.test(e)?`tel:${e}`:void 0}return/^https?:\/\/\S+$/i.test(n)?n:void 0},Ek=e=>e===`email`?{type:`email`,inputMode:`email`,autoComplete:`email`}:e===`phone`?{type:`tel`,inputMode:`tel`,autoComplete:`tel`}:e===`url`?{type:`url`,inputMode:`url`,autoComplete:`url`}:{},Dk=(e,t)=>{let n=String(t);return e&&Object.hasOwn(e,n)?e[n]:void 0},Ok=(e,t)=>{let n=Dk(e,t);return n===void 0||Jn(n)?void 0:n},kk=(e,t)=>{let n=Dk(e,t);return n!==void 0&&Jn(n)?n:`neutral`},Ak=e=>typeof e!=`object`||!e,jk=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e,Mk=e=>Array.isArray(e)?e.length===0?`[]`:`[…]`:typeof e==`object`&&e?Object.keys(e).length===0?`{}`:`{…}`:e===``?`""`:jk(String(e),40),Nk=e=>{let t=``;for(let n of e)if(t=t===``?n:`${t}, ${n}`,t.length>160)break;return jk(t,160)};function*Pk(e){let t=e;for(let e in t)Ak(t[e])&&(yield`${e}: ${Mk(t[e])}`);for(let e in t)Ak(t[e])||(yield`${e}: ${Mk(t[e])}`)}function*Fk(e){for(let t of e)yield Mk(t)}var Ik=e=>Array.isArray(e)?e.length===0?`[]`:e.every(Ak)?Nk(Fk(e)):LO(`jsonItems`,{count:e.length}):typeof e==`object`&&e?Object.keys(e).length===0?`{}`:Nk(Pk(e)):jk(String(e),160),Lk=(e,t)=>`${t.prefix??``}${e}${t.suffix??``}`,Rk=(e,t,n={},r=QT(),i=Date.now())=>{if(t==null||t===``)return`—`;switch(e.type){case`boolean`:return LO(t?`yes`:`no`);case`file`:return BO(t)?.name??`—`;case`enum`:return Ur(String(t),n.valueLabels);case`timestamp`:{let e=Date.parse(String(t));return n.format===`relative`?kE(Math.round((i-e)/1e3)):vE(e,r)}case`date`:return hE(Date.parse(String(t)));case`decimal`:{let e=n.decimals===void 0?String(t):Number(t).toFixed(n.decimals);return n.format===`percent`?`${Number(t)}%`:Lk(Number(e).toLocaleString(Ii(),{minimumFractionDigits:n.decimals??0,maximumFractionDigits:n.decimals??20}),n)}case`integer`:case`bigint`:return Lk(String(t),n);default:return typeof t==`object`?JSON.stringify(t):String(t)}},zk=(e,t,n=QT(),r={})=>{if(e.type!==`timestamp`||typeof t!=`string`)return;let i=Date.parse(t);if(!Number.isNaN(i))return r.format===`relative`?vE(i,n):LO(`shownIn`,{zone:sE(i,n)})},Bk=e=>e==null||e===``,Vk=(e,t,n,r,i)=>{let a=e.fields[n];return a?a.type===`relation`?i[n]??$O(r):Rk(a,r,t?.fields[n]):String(r)},Hk=(e,t,n,r,i={})=>{let a=t?.fields[n]?.linkText;if(a===void 0||qt(a).some(e=>Bk(r[e])))return;let o=Yt(a,n=>Vk(e,t,n,r[n],i)).trim();return o===``?void 0:o},Uk={text:200,id:140,money:120,date:110,datetime:170,status:150,relation:200,boolean:64,number:100,signed:110,percent:110,user:130,file:180},Wk=new Set([`datetime`,`date`,`boolean`,`percent`]),Gk=(e,t,n)=>{switch(e.type){case`relation`:return`relation`;case`file`:return`file`;case`enum`:return`status`;case`boolean`:return`boolean`;case`timestamp`:return`datetime`;case`date`:return`date`;case`decimal`:return t?.format===`percent`?`percent`:t?.currency===void 0?`number`:`money`;case`integer`:case`bigint`:return t?.format===`signed`?`signed`:`number`;default:return t?.format===`code`||n===0&&e.name===`id`?`id`:`text`}},Kk=e=>Math.round(Number.parseFloat(String(e))*100),qk=(e,t,n=[],r=xi(e,t))=>{let i=qr(e,t);return r.flatMap((r,a)=>{let o=e.fields[r];if(!o)return[];let s=t?.fields[r],c=Gk(o,s,a),l=Object.fromEntries((o.enumValues??[]).map(e=>[e,Ur(e,s?.valueLabels)])),u=(c===`number`||c===`signed`)&&s?.prefix?s.prefix:void 0,d=Math.ceil(((u?.length??0)+(s?.suffix?.length??0))*7.2);return[{id:r,header:s?.label??Hr(r),kind:c,width:(r===`name`?260:Uk[c])+d,sortable:o.sortable,minWidth:Math.max(c===`id`?150:0,tk(s?.label??Hr(r),o.sortable),c===`status`?nk(Object.values(l)):0,d>0?Uk[c]+d:0),...Wk.has(c)&&{fixed:!0},...r===i&&{title:!0},...c===`text`&&r!==i&&wk(s)&&{link:wk(s)},...c===`text`&&r!==i&&s?.linkText!==void 0&&{linkText:n=>Hk(e,t,r,n)},...n.includes(r)&&{highlight:!0},...o.type===`enum`&&{tones:Object.fromEntries((o.enumValues??[]).map(e=>[e,kk(s?.valueColors,e)])),labels:l},...o.type===`enum`&&s?.valueColors&&{colors:s.valueColors},...o.type===`enum`&&s?.badgeShape&&{shape:s.badgeShape},...u!==void 0&&{prefix:u},...s?.suffix!==void 0&&{suffix:s.suffix},...c===`datetime`&&s?.format===`relative`&&{relative:!0},...c===`money`&&s?.decimals!==void 0&&{decimals:s.decimals},...c===`money`&&s?.currency!==void 0&&{currency:s.currency,value:e=>e[r]==null?null:Kk(e[r])},...(c===`datetime`||c===`date`)&&{value:e=>e[r]==null?null:Date.parse(String(e[r]))},...o.type===`json`&&{value:e=>e[r]==null?null:Ik(e[r])},...Sk(o,s)&&{value:e=>typeof e[r]==`string`?xk(e[r]):e[r]},...(c===`percent`||c===`number`&&o.type===`decimal`)&&{value:e=>e[r]==null?null:Number(e[r])}}]})},Jk=`$photos`,Yk=e=>{for(let t of e?.list?.displays??[])if(t.kind===`cards`&&t.photos)return t.photos},Xk=(e,t,n)=>{if(n===void 0||e.primaryKey.length!==1)return t;let r=e.primaryKey[0];return t.map(e=>({...e,[Jk]:n[String(e[r])]??[]}))},Zk=(e,t)=>t.filter(t=>e[t]!==null&&e[t]!==void 0&&e[t]!==``),Qk=F(`app/displays`),$k=(e,t,n)=>{let r=e.fields[n.by];if(!r)return[];let i=t?.fields[n.by],a=(r.enumValues??[]).map(e=>({value:e,label:Ur(e,i?.valueLabels)}));return r.nullable?[...a,{value:null,label:Qk(`noValue`,{label:i?.label??Hr(n.by)})}]:a},eA=e=>e.position&&e.position.within===void 0?e.position.field:void 0,tA=(e,t,n)=>{let r=yt(n===null?jt.isNull(t):jt.eq(t,n));return e===``?r:`(${e}) AND ${r}`},nA=(e,t,n)=>({kind:`cards`,name:n.name,title:n.title??qr(e,t),...n.subtitle!==void 0&&{subtitle:n.subtitle},...n.badge!==void 0&&{badge:n.badge},...n.meta&&{meta:n.meta}}),rA=e=>{if(!Rd(e))return e instanceof Error?e.message:Qk(`somethingWrong`);let t=e.errors.map(e=>e.message);return t.length>0?t.join(`; `):e.message},iA=e=>e?.list?.displays??[],aA=(e,t)=>t??e?.list?.default,oA=(e,t,n)=>{let r=aA(e,n);return r===void 0?t?iA(e).find(e=>e.kind===`cards`)?.name??`table`:Tn:r},sA=`rows`,cA=(e,t)=>{if(iA(t).some(e=>e.kind===`cards`||e.name===`rows`))return;let n=qr(e,t),r=xi(e,t).filter(t=>t!==n&&e.fields[t]!==void 0),i=r.find(t=>e.fields[t].type===`enum`),a=r.filter(t=>t!==i&&e.fields[t].type!==`boolean`).slice(0,2);return{kind:`cards`,name:sA,label:Qk(`list`),icon:`list`,title:n,...i!==void 0&&{badge:i},footer:a}},lA=(e,t)=>t.name===`rows`&&!iA(e).some(e=>e.name===`rows`),uA=(e,t,n)=>{let r=oA(t,n);return n&&aA(t)===void 0&&r===`table`&&cA(e,t)?sA:r},dA=(e,t,n)=>(n===`rows`?cA(e,t):void 0)??fA(t,n),fA=(e,t)=>{if(t===`table`)return;let n=t=>iA(e).find(e=>e.name===t);return n(t)??n(e?.list?.default)},pA={cards:`cards`,map:`map`,board:`kanban`,calendar:`calendar`,timeline:`timeline`},mA=e=>[{name:Tn,label:Qk(`table`),icon:`table`},...iA(e).map(e=>({name:e.name,label:e.label??Hr(e.name),icon:e.icon??pA[e.kind]}))],hA=(e,t,n)=>{let r=mA(t);return n&&cA(e,t)?[...r,{name:sA,label:Qk(`list`),icon:`list`}]:r},gA=(e,t,n)=>({image:n.image,title:n.title??qr(e,t),subtitle:n.subtitle,amount:n.amount??[],badge:n.badge,code:n.code,meta:n.meta??[],footer:n.footer??[],flags:n.flags??[]}),_A=(e,t)=>Zk(e.record,t),vA=(e,t)=>_A(e,t)[0],yA=(e,t)=>t===void 0?void 0:_A(e,[t])[0],bA=(e,t)=>e?.type===`text`&&typeof t==`string`?t:void 0,xA=(e,t,n={})=>{let{suffix:r,...i}=n;return e.type!==`decimal`&&e.type!==`integer`&&e.type!==`bigint`||r===void 0||n.format===`percent`?{amount:Rk(e,t,n)}:{amount:Rk(e,t,i),suffix:r}},SA=(e,t)=>{let n=iA(e).filter(e=>e.kind===`cards`);return(t.cards===void 0?n[0]:n.find(e=>e.name===t.cards))??{kind:`cards`,name:t.name}},CA=(e,t,n)=>{if(n.kind===`custom`)return n.fields;if(n.kind===`map`)return[n.latitude,n.longitude,...CA(e,t,SA(t,n))];if(n.kind===`board`){let r=nA(e,t,n);return[n.by,r.title,r.subtitle,r.badge,...r.meta??[]].filter(e=>e!==void 0)}if(n.kind===`calendar`)return[n.start,n.end,n.title??qr(e,t)].filter(e=>e!==void 0);if(n.kind===`timeline`)return[n.start,n.end,n.group,n.title??qr(e,t)].filter(e=>e!==void 0);let{image:r,title:i,subtitle:a,amount:o,badge:s,code:c,meta:l,footer:u,flags:d}=gA(e,t,n);return[r,i,a,...o,s,c,...l,...u,...d].filter(e=>e!==void 0)},wA=e=>(e?.actions??[]).flatMap(e=>(e.inputs??[]).flatMap(e=>e.from===void 0?[]:[e.from])),TA=(e,t)=>t.flatMap(t=>qt(e?.fields[t]?.linkText??``)),EA=(e,t,n)=>{let r=cA(e,t),i=r?[...iA(t),r]:iA(t),a=[...n,...i.flatMap(n=>CA(e,t,n))];return[...new Set([...a,...TA(t,a),...wA(t)])]},DA=(e,t,n)=>{let r=lA(t,n)?[qr(e,t),...xi(e,t)]:CA(e,t,n);return[...new Set(r)].filter(t=>e.fields[t]?.sortable)},OA=e=>typeof e==`object`&&!!e&&`id`in e&&`name`in e,kA=(e,t)=>{let n={},r={},i=Array.isArray(t.$photos)?t[Jk]:void 0;for(let[i,a]of Object.entries(t))(i!==`id`&&i!==`$photos`||Object.hasOwn(e.fields,i))&&(e.fields[i]?.type===`relation`&&OA(a)?(n[i]=a.id,r[i]=a.name):n[i]=a);return{key:tr(DT(e,n)),record:n,labels:r,...i&&{photos:i}}},AA=(e,t,n,r)=>{let i=e[n],a=Rn(t[n],r),o=a?.listOf,s=o===void 0?void 0:i?.fields[o]?.relation?.resource;return s!==void 0&&e[s]?{model:e[s],view:t[s],listOf:!0}:{model:i,view:a,listOf:!1}},jA=(e,t,n=!1)=>({display:e?uA(e,t,n):oA(t,n),orderBy:e?OT(e,t):``,filterLayout:`bar`,filter:t?.list?.filter??``}),MA=(e,t)=>e?.kind===`record`?{kind:`record`,resource:e.resource,key:tr(e.key),...e.edit&&{edit:!0},...e.open&&{open:e.open},...e.tab&&{tab:e.tab},...e.standard&&{standard:!0},...e.call&&{call:e.call},...e.version!==void 0&&{version:e.version},...e.run&&{run:e.run},...e.panel&&{panel:e.panel},...e.file&&{file:e.file},...e.thread&&{thread:e.thread}}:e?.kind===`list`?{...t(e.resource,e.list),...e}:e,NA=(e,t,n)=>{let r={...e,...t},i=e=>r[e]!==void 0&&r[e]!==n[e];return{kind:`list`,resource:e.resource,...e.list&&{list:e.list},...i(`filter`)&&{filter:r.filter},...i(`display`)&&{display:r.display},...i(`orderBy`)&&{orderBy:r.orderBy},...i(`filterLayout`)&&{filterLayout:r.filterLayout},...r.map&&{map:r.map},...r.calendar&&{calendar:r.calendar},...r.timeline&&{timeline:r.timeline},...r.savedSearch&&{savedSearch:r.savedSearch}}},PA=()=>{let{path:e,params:t,basePath:n,navigate:r,back:i,backIsHistory:a}=Hu(),{pages:o,resources:s,views:c}=Tv(),l=uy(),u=(0,M.useMemo)(()=>new Set(Object.keys(o)),[o]),d=t.toString(),f=(0,M.useMemo)(()=>hd(d?`${e}?${d}`:e,u),[e,d,u]),p=(0,M.useCallback)((e,t)=>{let n=AA(s,c,e,t);return jA(n.model,n.view,l)},[s,c,l]),m=(0,M.useMemo)(()=>MA(f,p),[f,p]),h=(0,M.useCallback)((e,t)=>r(ud(e),t),[r]),g=(0,M.useCallback)(e=>{if(f?.kind!==`list`)throw Error(`listTo and set change the list the app shows; use go to move to another address`);return NA(f,e,p(f.resource,f.list))},[f,p]),_=(0,M.useCallback)(e=>h(g(e),{replace:!0}),[g,h]),v=(0,M.useCallback)(e=>ud(e,n),[n]),y=(0,M.useCallback)(e=>e.startsWith(`${n}/`)?e.slice(n.length):e,[n]);return{address:m,set:_,listTo:g,go:h,href:v,open:(0,M.useCallback)(e=>r(y(e)),[y,r]),back:(0,M.useCallback)(e=>i(y(e)),[y,i]),backIsHistory:(0,M.useCallback)(e=>a(y(e)),[y,a])}},FA=({to:e,...t})=>(0,L.jsx)(Zu,{to:ud(e),...t}),IA=`SplashScreen`,LA=e=>{if(e?.isPluginAvailable(IA))return{show:()=>e.nativePromise(IA,`show`,{autoHide:!1}),hide:()=>e.nativePromise(IA,`hide`,{})}},RA=({answer:e,current:t,next:n})=>!e?.bundleId||e.required||e.bundleId===t||e.bundleId===n?{kind:`none`}:{kind:`take`,bundleId:e.bundleId},zA=e=>{let t=typeof e==`object`&&e?e.bundleId:void 0;return typeof t==`string`?t:null},BA=({bridge:e,check:t,releasesUrl:n,splash:r})=>{let i=(t,n={})=>e.nativePromise(`LiveUpdate`,t,n),a=t=>t instanceof e.Exception,o=async(e,t)=>{try{return await e()}catch(e){if(!a(e))throw e;return t}},s=async e=>{await i(`downloadBundle`,{bundleId:e,url:`${n}/${e}`,artifactType:`manifest`}),await i(`setNextBundle`,{bundleId:e})},c=()=>o(async()=>{let[e,n,r]=await Promise.all([t(),i(`getCurrentBundle`),i(`getNextBundle`)]),a=RA({answer:e,current:zA(n),next:zA(r)});a.kind!==`none`&&await s(a.bundleId)},void 0),l=e=>o(async()=>{let[t,n]=await Promise.all([i(`getCurrentBundle`),i(`getNextBundle`)]),a=zA(n);if(a===null||a===zA(t))return!1;e();let o=!1;try{await r?.show(),await i(`reload`),o=!0}finally{o||await r?.hide()}return!0},!1),u;return{ready:()=>i(`ready`),applyNext:l,check:()=>(u??=c().finally(()=>{u=void 0}),u)}},VA=e=>/(?:^|\s)ProtobaseNative\/([0-9a-f]{16})(?:\s|$)/.exec(e)?.[1],HA=/^[A-Za-z0-9_-]{1,64}$/,UA=e=>typeof e==`object`&&!!e&&!Array.isArray(e),WA=e=>{if(!UA(e))return;let{bundleId:t,url:n,required:r}=e;if((t===null||typeof t==`string`&&HA.test(t))&&(n===null||typeof n==`string`)&&typeof r==`boolean`)return{bundleId:t,url:n,required:r}},GA=15e3,KA=e=>e instanceof TypeError||e instanceof DOMException&&e.name===`TimeoutError`,qA=async(e,{apiOrigin:t,fingerprint:n,shellVersion:r})=>{let i=`${t}${Zr}?${$r({fingerprint:n,shellVersion:r})}`;try{let t=await e(i,{credentials:`omit`,cache:`no-store`,signal:AbortSignal.timeout(GA)});return t.status===200?WA(await t.json()):void 0}catch(e){if(KA(e)||e instanceof SyntaxError)return;throw e}},JA=({bridge:e,apiOrigin:t,userAgent:n,fetch:r})=>{if(!e?.Exception||!e.isPluginAvailable(`LiveUpdate`))return;let i=VA(n);return BA({bridge:{nativePromise:e.nativePromise.bind(e),Exception:e.Exception},check:async()=>i&&t?qA(r,{apiOrigin:t,fingerprint:i,shellVersion:$i}):void 0,releasesUrl:`${t}${Qr}`,splash:LA(e)})},YA=({updater:e,children:t})=>((0,M.useEffect)(()=>{e&&e.ready()},[e]),(0,L.jsx)(ID.Provider,{value:e,children:t})),XA=async(e,t)=>{let n=!1,r=!1;try{r=await e.applyNext(()=>{t.keep(),n=!0})}finally{!r&&n&&t.forget()}return r},ZA=2e4,QA=async(e,t)=>{let n,r=new Promise(e=>{n=setTimeout(()=>e(!1),ZA)}),i=e.check();return await Promise.race([i.then(()=>!0),r]).finally(()=>clearTimeout(n))?t?XA(e,t):!1:(i.then(()=>void 0),!1)},$A=`protobase:ui-ready`,ej=(e=window)=>void e.requestAnimationFrame(()=>e.setTimeout(()=>e.dispatchEvent(new Event($A)),0)),tj=`pb-start`,nj=`pb-start-hand-off`,rj=e=>{let t=e.getElementById(tj);t&&(t.dispatchEvent(new Event(nj)),t.remove())},ij=9e5,aj=(e,t)=>{e();let n=setInterval(()=>{t()&&e()},ij);return()=>clearInterval(n)},oj=()=>{let e=LD(),t=J().state.kind===`signed-in`,n=!!Tv().versionChange;return(0,M.useEffect)(()=>{if(e&&t)return aj(()=>void e.check(),()=>document.visibilityState===`visible`)},[e,t,n]),null},sj=(e=Date.now)=>{let t;return{leave:()=>{t=e()},back:()=>{let n=t===void 0?0:e()-t;return t=void 0,n}}},cj=({updater:e,holdsChanges:t,page:n,now:r})=>{let i=sj(r);return{leave:i.leave,back:async()=>{let r=i.back();n&&r>=3e5&&!t()&&await XA(e,n)||await e.check()}}},lj=()=>{let e=LD(),{holdsChanges:t}=Hu();return(0,M.useEffect)(()=>{if(!e)return;let n=cj({updater:e,holdsChanges:t,page:io()}),r=()=>{if(document.visibilityState===`hidden`)return n.leave();n.back()};return document.addEventListener(`visibilitychange`,r),()=>document.removeEventListener(`visibilitychange`,r)},[e,t]),null},uj=[`never`,`thirty_minutes`,`one_hour`,`four_hours`,`today`,`this_week`,`custom`],dj={thirty_minutes:30,one_hour:60,four_hours:240},fj=(e,t)=>new Date(e.getFullYear(),e.getMonth(),e.getDate()+t),pj=(e,t,n=``)=>{if(e===`never`)return null;if(e===`today`)return fj(t,1).toISOString();if(e===`this_week`)return fj(t,(8-t.getDay())%7||7).toISOString();if(e===`custom`){let e=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?$/.test(n)?new Date(n):void 0;return e&&!Number.isNaN(e.getTime())?e.toISOString():void 0}return new Date(t.getTime()+dj[e]*6e4).toISOString()},mj=e=>String(e).padStart(2,`0`),hj=e=>{let t=new Date(e);return`${t.getFullYear()}-${mj(t.getMonth()+1)}-${mj(t.getDate())}T${mj(t.getHours())}:${mj(t.getMinutes())}`},gj=(e,t=Date.now())=>{let n=bi(e,t);return n?{availability:n.availability,text:n.text??``,clears:n.clearsAt===null?`never`:`custom`,custom:n.clearsAt===null?``:hj(n.clearsAt)}:{availability:`automatic`,text:``,clears:`never`,custom:``}},_j=(e,t)=>{let n=e.text.trim(),r=n===``?void 0:yi(n);if(r)return{problem:`text`,message:r};let i=pj(e.clears,t,e.custom);return i===void 0||i!==null&&Date.parse(i)<=t.getTime()?{problem:`time`}:{input:{availability:e.availability,text:n===``?null:n,clearsAt:i}}},vj={never:`never`,thirty_minutes:`thirtyMinutes`,one_hour:`oneHour`,four_hours:`fourHours`,today:`today`,this_week:`thisWeek`,custom:`custom`},yj=({current:e,onSave:t,onClear:n,onClose:r})=>{let[i,a]=(0,M.useState)(()=>gj(e)),[o,s]=(0,M.useState)(!1),[c,l]=(0,M.useState)(),[u,d]=(0,M.useState)(!1),f=(0,M.useId)(),p=(0,M.useId)(),m=(0,M.useId)(),h=e=>a({...i,...e}),g=_j(i,new Date),_=u&&`problem`in g?g:void 0,v=async e=>{s(!0),l(void 0);try{await e(),r()}catch(e){if(!(e instanceof Id))throw e;l(e.status===400?e.message:Ox(`couldNotSave`)),s(!1)}},y=()=>{d(!0),`input`in g&&v(()=>t(g.input))};return(0,L.jsx)(xu,{title:Ox(e?`editStatus`:`setStatus`),onClose:r,actions:(0,L.jsxs)(L.Fragment,{children:[e&&(0,L.jsx)(B,{variant:`ghost`,className:`sm:mr-auto`,disabled:o,onClick:()=>void v(n),children:Ox(`clear`)}),(0,L.jsx)(B,{onClick:r,children:Ox(`cancel`)}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,form:f,loading:o,children:Ox(`save`)})]}),children:(0,L.jsxs)(`form`,{id:f,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`label`,{htmlFor:p,className:`font-medium`,children:Ox(`statusText`)}),(0,L.jsx)(Eb,{id:p,name:`status`,autoComplete:`off`,autoFocus:!0,placeholder:Ox(`statusPlaceholder`),value:i.text,maxLength:200,invalid:_?.problem===`text`,..._?.problem===`text`&&{"aria-describedby":`${p}-problem`},onChange:e=>h({text:e.target.value})}),_?.problem===`text`&&(0,L.jsx)(`span`,{id:`${p}-problem`,className:`text-xs text-danger-text`,children:_.message})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5 font-medium`,children:[Ox(`availability`),(0,L.jsx)(Gb,{label:Ox(`availability`),value:i.availability,onChange:e=>h({availability:e}),options:[{value:`automatic`,label:Ox(`automatic`)},{value:`busy`,label:Ox(`busy`)},{value:`do_not_disturb`,label:Ox(`doNotDisturb`)}]}),i.availability===`do_not_disturb`&&(0,L.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:Ox(`doNotDisturbHint`)})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Ox(`clearsAfter`),(0,L.jsx)(`select`,{name:`clears`,value:i.clears,onChange:e=>h({clears:e.target.value}),className:`h-8 rounded-md border border-border-strong bg-background px-2 font-normal`,children:uj.map(e=>(0,L.jsx)(`option`,{value:e,children:Ox(vj[e])},e))})]}),i.clears===`custom`&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`label`,{htmlFor:m,className:`font-medium`,children:Ox(`clearsAt`)}),(0,L.jsx)(Eb,{id:m,type:`datetime-local`,name:`clears-at`,value:i.custom,invalid:_?.problem===`time`,..._?.problem===`time`&&{"aria-describedby":`${m}-problem`},onChange:e=>h({custom:e.target.value})}),_?.problem===`time`&&(0,L.jsx)(`span`,{id:`${m}-problem`,className:`text-xs text-danger-text`,children:Ox(`pickTime`)})]}),c&&(0,L.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:c})]})})},bj=e=>{let t=X(),n=x(),r=rD(),[i,a]=(0,M.useState)(!1);if(!e||!r.isSuccess)return{};let o=bi(r.data),s=()=>n.invalidateQueries({queryKey:[`statuses`]});return{menu:{mark:o&&(0,L.jsx)(Mx,{status:o,textShown:`hover`}),label:o?(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-foreground`,children:[(0,L.jsx)(jx,{availability:o.availability}),(0,L.jsx)(`span`,{className:`truncate`,children:o.text??Ax(o.availability)})]}):Ox(`setStatus`),onOpen:()=>a(!0)},...i&&{dialog:(0,L.jsx)(yj,{current:o,onSave:async e=>{await t.status.set(e),await s()},onClear:async()=>{await t.status.clear(),await s()},onClose:()=>a(!1)})}}},xj=e=>e?.kind===`page`?e.page:e?.kind===`list`?yT(e.resource,e.list):e?.resource,Sj=e=>e?.kind===`record`?e:void 0,Cj=({workspace:e,sidebarMode:t,assistant:n,runtime:r})=>{let i=Tv(),{state:a,session:o,signOut:s,stopStaffSession:c,organizations:l}=J(),[u,d]=(0,M.useState)(!1),f=async()=>{d(!1),await s(),aS()},p=SC();if(a.kind!==`signed-in`&&a.kind!==`visitor`)throw Error(`The shell is only rendered for a signed-in user or a visitor`);let m=a.kind===`signed-in`?a.user:void 0,h=a.kind===`signed-in`?a.staff:void 0,{path:g,params:_,basePath:v,navigate:y}=Hu(),{address:b,go:x,open:S,back:C,backIsHistory:w}=PA(),T=xj(b),E=Sj(b),D=FD(),O=Ow(),k=sT(!!(l&&m)),A=k.current,ee=aT(),te=!!l&&A!==void 0&&!A.organization&&k.fresh,ne=!!(l&&m)&&!k.error&&(A===void 0||!A.organization&&!k.fresh),re=!te&&!ne,ie=IO(i,v,{resource:E?.resource,key:E?.key},re),j=F_();dw(i);let ae=re?CT(i,v,ie):[],N=!l||!m?``:k.fresh?A?.organization?.id??``:k.failed?null:void 0,oe=IT(i,g===`/`&&re,N),se=b?.kind===`page`?i.pages[b.page]:void 0;(0,M.useEffect)(()=>{g===`/`&&re&&oe.state!==`resolving`&&(oe.address?x(oe.address,{replace:!0}):m&&y(b_,{replace:!0}))},[g,re,oe,x,m,y]);let ce=b?.kind===`page`?void 0:b?.resource,le=ce?Q_(i,ce):void 0,ue=ce?Rn(i.views[ce],b?.kind===`list`?b.list:void 0):void 0,de=ae.find(e=>e.items.some(e=>e.id===T)),P=ce?i.resources[ce]:void 0,fe=pw(E?.resource??``,E?.key??``,!!(P&&E)),pe=pD(),me=P&&E&&fe.data?pe(P,ue,fe.data.record,E.key):void 0,he=!!E&&(fe.isLoading||le?.state===`loading`),{shell:ge}=tT(),_e=ge?.actions,ve=ge?.rightPanel,ye=i.bell&&m&&!h&&(0,L.jsx)(KE,{own:ge?.bell}),be=bj(!!(i.status&&m&&!h)),xe=nD().data,Se=Xw(),[Ce,we]=(0,M.useState)(!1),Te=i.assistant?.url,Ee=Te&&(0,L.jsx)(zw,{open:Ce,onToggle:()=>we(!Ce)}),De=Te&&Ce&&(0,L.jsx)(mO,{url:Te,client:n,page:_.size>0?`${g}?${_}`:g,onClose:()=>we(!1)}),Oe=i.errorReporting;(0,M.useEffect)(()=>{Oe&&fg(Oe)},[Oe]);let ke=i.runtime?.url,Ae=ke&&(0,L.jsx)(gO,{url:ke,client:r}),je=Vx(t??`text-small`),Me=i.versionChange&&!je&&(0,L.jsx)(BD,{}),Ne=fT((0,M.useCallback)(()=>cT(v),[v]),!!m),Pe=m&&lT(m,Ne.current),Fe=Pe?ew(Pe):!1,Ie=JE(),Le=l&&m?MC(g,ee):void 0,Re=sy(),ze=m?S_(g):void 0,Be=NC(g)||g===`/-/organizations`||g===`/-/sign-in-policy`||g===`/-/menu`||!!ze,Ve=NC(g);(0,M.useEffect)(()=>{te&&!Be?y(kC,{replace:!0}):re&&A?.organization&&Ve&&y(`/`,{replace:!0})},[te,Be,re,A,Ve,y]);let He=ze&&Re?HT(VT(Re.tree),ze.tab):void 0,Ue=g===Wx,We=re?Uw(i,v,T,b?.kind===`list`||b?.kind===`page`):[],Ge=We.find(e=>!e.external)?.href.slice(v.length),Ke={href:`${v}${Wx}`,shown:Ue},qe=qx({desktop:ly(),tabs:We,menuPage:Ke}).on,Je=(0,M.useRef)(!1);(0,M.useEffect)(()=>{let e=!Je.current;Je.current=!0;let t=Gx(g,Ge,{starting:e,morePage:qe});t&&y(t,{replace:!0})},[g,Ge,qe,y]);let Ye=Ue?H(`menu`):m?ze?Re?.title??H(`account`):g===`/-/sign-in-policy`?H(`signInPolicy`):Le:void 0,Xe=ue?.names?.plural??(ce&&Hr(ce)),Ze=b?.kind===`record`&&!b.standard&&!!i.views[b.resource]?.record,Qe=Ye?[Ye]:Gw({basePath:v,address:b,group:de?.label,page:se,resourceLabel:Xe,headingless:Ze,recordTitle:me,recordLoading:he}),$e=ue?.names?.singular??(ce&&Hr(ce)),et=se&&b?.kind===`page`?HT(VT(se.tree),b.tab):void 0;SS(xS(bS({address:b,page:se?{title:se.title,...et&&{tab:et.label}}:ze&&Re&&{title:Re.title,...He&&{tab:He.label}},accountPage:Ye,resourceLabel:Xe,singular:$e,recordTitle:me,recordLoading:he}),i.appName));let tt=ze?(0,L.jsx)(iO,{...ze}):m&&g===`/-/sign-in-policy`?Fe?(0,L.jsx)(aO,{}):(0,L.jsx)(Ev,{title:H(`adminsOnly`),children:H(`onlyAdminPolicy`)}):Le&&g===`/-/organization`?(0,L.jsx)(oO,{current:A,basePath:v,onChanged:k.reload}):Le&&(g===`/-/organization/members`||g===`/-/organization/invitations`)?IC(A)?g===`/-/organization/members`?(0,L.jsx)(lO,{current:A,statuses:xe,presence:Se}):(0,L.jsx)(uO,{current:A}):(0,L.jsx)(Ev,{title:H(`ownersOnly`),children:H(`onlyOwners`)}):Le&&g===`/-/organizations`?(0,L.jsx)(cO,{state:k,basePath:v}):ne&&k.failed?(0,L.jsx)(Ev,{title:ee(`couldNotReadOrganizations`),children:(0,L.jsx)(B,{className:`mt-3`,onClick:k.reload,children:ee(`tryAgain`)})}):te||ne?null:b?b.kind===`page`?se?(0,L.jsx)(rO,{name:se.name,...b.tab&&{tab:b.tab},...b.params&&{params:b.params}},se.name):(0,L.jsx)(Ev,{title:H(`notFound`),children:H.rich(`noPage`,{page:b.page})}):le&&le.state!==`ready`?(0,L.jsx)(vD,{status:le}):b.kind===`create`?(0,L.jsx)(nO,{resource:b.resource,values:b.values},b.resource):b.kind===`record`?(0,L.jsx)(tO,{resource:b.resource,recordKey:b.key},`${b.resource}/${b.key}`):(0,L.jsx)(eO,{address:b},yT(b.resource,b.list)):g===`/`?oe.state===`resolving`||oe.address?null:(0,L.jsx)(Ev,{title:H(`chooseResource`),children:H(`pickFromSidebar`)}):(0,L.jsx)(Ev,{title:H(`notFound`),children:H(`nothingHere`)}),nt=Fe&&Ie.length>0,rt=u&&(0,L.jsx)(xu,{title:H(`signOutQuestion`),description:H(`signOutHelp`),onClose:()=>d(!1),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:()=>d(!1),children:H(`signOutCancel`)}),(0,L.jsx)(B,{variant:`primary`,onClick:()=>void f(),children:H(`signOutConfirm`)})]})});return m&&te&&NC(g)?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(sO,{path:g,basePath:v,email:m.email,mayCreate:l?.create===`everyone`||ew(m),seesAll:(A?.globalRoles.length??0)>0,onSignOut:()=>d(!0)}),rt]}):(0,L.jsx)(rS,{pageScroll:!0,sidebarMode:t??`text-small`,activeItem:T??``,breadcrumb:Qe,titleStatus:(j===`refreshing`||j===`failed`)&&(0,L.jsx)(QE,{failed:j===`failed`}),staleContent:j===`failed`?`failed`:void 0,user:Pe&&nw(Pe),onSignOut:m&&(()=>d(!0)),signIn:m?void 0:p.link(),workspace:A?.organization?.name??e,appName:i.appName,appIcon:i.appIcon,logo:UT,navGroups:ae,bottomBar:We,menuPage:Ke,bottomBarSearch:Ww(i),userMenu:[re?vT(i,v,T):[],l&&m?LC(v,g,ee,A):[],m?w_(v,g,Fe):[]],account:m&&`${v}/-/account`,organizations:l&&{label:ee(`organizations`),...A?.organization&&{current:{id:A.organization.id,name:A.organization.name}},others:k.organizations.filter(e=>e.id!==A?.organization?.id),onSwitch:e=>void o.organizations.switchTo(e).then(()=>cT(v))},theme:{preference:O.preference,onChange:O.choose},...be.menu&&{status:be.menu},roles:Ne.current?.active?{active:Ne.current.active,roles:Ne.current.roles,onSwitch:Ne.switchTo}:void 0,onNavigate:S,onBack:C,backIsHistory:w,sidebarNotice:(0,L.jsx)(zD,{}),banner:(h||nt)&&(0,L.jsxs)(L.Fragment,{children:[h&&(0,L.jsx)(EO,{signIn:h,onStop:c}),nt&&(0,L.jsx)(XE,{off:Ie})]}),search:D.available&&re?{placeholder:D.placeholder,text:D.text,onTextChange:D.setText,query:D.query,loading:D.loading,groups:D.groups,onSelect:S}:void 0,actions:(_e||ye||Me||Ae||Ee)&&(0,L.jsxs)(L.Fragment,{children:[_e&&(0,L.jsx)(GC,{name:`shell.actions`,fallback:null,children:(0,L.jsx)(_e,{})}),ye,Me,Ae,Ee]}),overlays:(0,L.jsxs)(L.Fragment,{children:[be.dialog,i.calls&&m&&!h&&(0,L.jsx)(hO,{}),rt]}),rightPanel:(ve||De)&&(0,L.jsxs)(L.Fragment,{children:[ve&&(0,L.jsx)(GC,{name:`shell.rightPanel`,fallback:null,children:(0,L.jsx)(ve,{})}),De]}),children:(0,L.jsx)(GC,{name:`page`,fallback:(0,L.jsx)(Ev,{title:H(`pageNotLoaded`),children:H(`pageNotLoadedHelp`)}),resetKey:_.size>0?`${g}?${_}`:g,children:tt})})},wj=({baseUrl:e,client:t,sources:n,workspace:r,sidebarMode:i,ui:a,assistant:o,runtime:s})=>{let{state:c,session:l,markSignedOut:u}=J(),d=Vx(i??`text-small`),{path:f}=Hu(),p=lw(c),m=e_(c),h=oa(),g=(0,M.useMemo)(()=>h&&m?mS({cache:h,owner:p}):void 0,[h,m,p]);return(0,L.jsx)(U_,{baseUrl:e,client:t,sources:n,token:c.kind===`visitor`?void 0:l.token,onUnauthenticated:u,persistence:g,children:(0,L.jsx)(kv,{children:(0,L.jsxs)(Rw,{children:[!d&&(0,L.jsx)(UD,{}),(0,L.jsx)(oj,{}),f===`/-/connect`?(0,L.jsx)(dO,{}):(0,L.jsx)(YE,{ui:a,children:(0,L.jsx)(rT,{children:(0,L.jsx)(gD,{children:(0,L.jsx)(Cj,{workspace:r,sidebarMode:i,assistant:o,runtime:s})})})})]})})},p)},Tj=({baseUrl:e,client:t,ui:n,children:r})=>{let i=mw();return i?(0,L.jsx)(U_,{baseUrl:e,client:t,children:(0,L.jsx)(eT.Provider,{value:n??{},children:(0,L.jsx)(fO,{name:i.name},i.name)})}):r},Ej=({baseUrl:e,children:t})=>{let n=vw(),{basePath:r}=Hu();if(!n)return t;let i=new URL(e??`/api/v1`,window.location.href),a=`${i.origin}${i.pathname.slice(0,i.pathname.lastIndexOf(`/`))}`;return(0,L.jsx)(pO,{link:n.token,systemPath:a,base:`${window.location.origin}${r}`})},Dj=({auth:e,workspace:t,basePath:n,initialUrl:r,pluginLoader:i,pluginSource:a,locale:o,nativeBridge:s,startCache:c,...l})=>{Mi(o??`en`);let u=l.baseUrl&&new URL(l.baseUrl,window.location.href).origin,d=(0,M.useMemo)(()=>JA({bridge:s,apiOrigin:u,userAgent:navigator.userAgent,fetch:window.fetch.bind(window)}),[s,u]),f=(0,M.useMemo)(()=>d&&(()=>QA(d,io())),[d]),p=(0,M.useMemo)(()=>py(s),[s]),m=(0,M.useMemo)(()=>Wy(s),[s]),h=(0,M.useMemo)(()=>$_(()=>{rj(document),LA(s)?.hide(),ej()}),[s]);return(0,M.useEffect)(()=>h.start(),[h]),(0,M.useEffect)(()=>void vO(),[]),(0,L.jsx)(tv,{value:h,children:(0,L.jsx)(aa,{value:c,children:(0,L.jsx)(Dw,{children:(0,L.jsx)(hy.Provider,{value:p,children:(0,L.jsx)(Gy.Provider,{value:m,children:(0,L.jsx)(YA,{updater:d,children:(0,L.jsx)(u_,{session:e,...u&&{origin:u},...s&&{nativeBridge:s},...f&&{afterSignIn:f},children:(0,L.jsxs)(Xu,{basePath:n,initialUrl:r,children:[(0,L.jsx)(lj,{}),s&&u&&(0,L.jsx)(y_,{nativeBridge:s,apiOrigin:u}),(0,L.jsx)(Ka,{...i&&{loader:i},...a&&{source:a},children:(0,L.jsx)(ow,{children:(0,L.jsx)(Tj,{baseUrl:l.baseUrl,client:l.client,ui:l.ui,children:(0,L.jsx)(Ej,{...l.baseUrl&&{baseUrl:l.baseUrl},children:(0,L.jsx)(XC,{workspace:t,children:(0,L.jsx)(wj,{workspace:t,...l})})})})})})]})})})})})})})})},Oj=`protobase:first-frame`,kj=e=>le(()=>e.sessionStorage.getItem(Oj)===`1`,!1),Aj=(e,t)=>{let n=(0,oe.createRoot)(e);(0,N.flushSync)(()=>n.render(t));let r=e.innerHTML;n.unmount(),e.innerHTML=r,e.dataset.firstFrame=`frozen`},jj=async e=>{e.getPlatform()===`ios`&&e.isPluginAvailable(`Keyboard`)&&await e.nativePromise(`Keyboard`,`setAccessoryBarVisible`,{isVisible:!0})},Mj=(e,t)=>{t===`ios`&&(e.dataset.pbTextSize=`system`)},Nj=e=>[...e.split(`,`).map(e=>e.trim()).filter(e=>e&&!/^maximum-scale\s*=/.test(e)),`maximum-scale=1`].join(`, `),Pj=e=>{let t=e.querySelector(`meta[name="viewport"]`);t&&t.setAttribute(`content`,Nj(t.getAttribute(`content`)??``))},Fj=e=>{if(e.length===0)return;if(e.length>1)throw Error(`The page has ${e.length} ${Yr} meta tags; it may have one`);let t=e[0],n=URL.canParse(t)?new URL(t):void 0;if(!n||n.protocol!==`http:`&&n.protocol!==`https:`||n.origin!==t)throw Error(`The page's ${Yr} meta tag holds "${t}", which is not an http or https origin such as https://shop.example.com`);return t},Ij=()=>Fj([...document.querySelectorAll(`meta[name="${Yr}"]`)].map(e=>e.content)),Lj=document.getElementById(`root`);if(!Lj)throw Error(`index.html needs an element with id "root"`);ue(document);var Rj=ng(window);if(Rj){Pj(document),Mj(document.documentElement,Rj.getPlatform()),jj(Rj);let e=le(()=>window.sessionStorage,void 0);e&&ro(e,window.history)}var zj=Pi(),Bj=Hi(zj).catch(()=>void 0),Vj=Ua(Ra);ua().then(async e=>{let t=Yi(e);await Promise.race([Promise.all([Wa(Vj,Xi(e),Ja),Bj,...t?.locale?[Hi(t.locale).catch(()=>void 0)]:[],...t?[vO()]:[]]),new Promise(e=>setTimeout(e,Ja))]);let n=(0,L.jsx)(M.StrictMode,{children:(0,L.jsx)(Dj,{baseUrl:`${Ij()??``}/api/v1`,ui:va(se),locale:zj,nativeBridge:Rj,startCache:e,pluginSource:Vj})});if(kj(window))return Aj(Lj,n);(0,oe.createRoot)(Lj).render(n)});var Hj=(e,t,{filter:n,orderBy:r,pageSize:i=50,fields:a,labels:o,startToken:s=``})=>{let c=Td(n)??``;return{queryKey:[...I.list(t,c,r??``,i,s),a?.join(`,`)??``,...o?[o]:[]],initialPageParam:s,queryFn:({pageParam:n})=>e.list(t,{filter:c,orderBy:r,pageSize:i,fields:a,labels:o,pageToken:n}),getNextPageParam:e=>e.nextPageToken||void 0}},Uj=(e,{enabled:t=!0,refetchInterval:n,...r}={})=>{let i=A({...Hj(X(),e,r),enabled:t,refetchInterval:n}),a=i.data?.pages??[];return{...i,items:a.flatMap(e=>e.items),totalEstimate:a[0]?.totalSizeEstimate,labels:Object.fromEntries(Object.keys(r.labels??{}).map(e=>[e,Object.assign({},...a.map(t=>t.labels?.[e]??{}))]))}},Wj=e=>{let t=new Map,n=async(t,{batch:n,waiting:r})=>{let i=await e.batchAggregates(t,n).then(e=>({result:e}),e=>({error:e}));for(let e of r)`error`in i?e.reject(i.error):e.resolve(i.result[e.kind][e.index])},r=(e,r)=>{t.get(e)===r&&(t.delete(e),n(e,r))},i=(e,n,i)=>new Promise((a,o)=>{let s=t.get(e);s&&s.batch[n].length>=100&&r(e,s);let c=t.get(e)??{batch:{facets:[],histograms:[],series:[]},waiting:[]};t.has(e)||(t.set(e,c),setTimeout(()=>r(e,c),0));let l=c.batch[n];l.push(i),c.waiting.push({kind:n,index:l.length-1,resolve:a,reject:o})});return{facets:(e,t,n={})=>i(e,`facets`,{field:t,...n}),histogram:(e,t,n={})=>i(e,`histograms`,{field:t,...n}),series:(e,t)=>i(e,`series`,t)}},Gj=new WeakMap,Kj=e=>{let t=Gj.get(e);if(t)return t;let n=Wj(e);return Gj.set(e,n),n},qj=(e,t,n,r=!0)=>{let i=Kj(X()),a=Td(n)??``;return O({queryKey:I.facets(e,t,a),enabled:r,queryFn:()=>i.facets(e,t,{filter:a,limit:50})})},Jj=(e,t,n=!0)=>{let r=Kj(X()),i=Td(t.filter)??``;return O({queryKey:I.series(e,t.field,`${t.range??``}${t.from??``}${t.to??``}`,t.granularity??``,i),enabled:n,queryFn:()=>r.series(e,{...t,filter:i})})},Yj=(e,t,n,r=20,i=!0)=>{let a=Kj(X()),o=Td(n)??``;return O({queryKey:I.histogram(e,t,r,o),enabled:i,queryFn:()=>a.histogram(e,t,{filter:o,buckets:r})})},Xj=(e,t,n)=>{let r={...n,filter:Td(n.filter)??``};return{queryKey:I.aggregate(t,JSON.stringify(r)),queryFn:()=>e.aggregate(t,r)}},Zj=(e,t,n=!0)=>O({...Xj(X(),e,t),enabled:n}),Qj=(e,t,n=!0)=>{let r=X();return ee({queries:t.map(t=>{let i={...t,filter:Td(t.filter)??``};return{queryKey:I.aggregate(e,JSON.stringify(i)),enabled:n,queryFn:()=>r.aggregate(e,i)}})})},$j=(e,t)=>{let n=X(),r=x(),i=tr(t);return S({mutationFn:({patch:r,etag:i})=>n.update(e,t,r,i),onSuccess:t=>{r.setQueryData(I.record(e,i),t),r.invalidateQueries({queryKey:[`page`,e]}),r.invalidateQueries({queryKey:[`list`,e]}),r.invalidateQueries({queryKey:[`map`,e]}),r.invalidateQueries({queryKey:[`count`,e]}),r.invalidateQueries({queryKey:[`aggregate`,e]}),r.invalidateQueries({predicate:t=>t.queryKey[0]===`plan`&&Ji(t.queryKey,new Set([e]))})}})},eM=e=>e instanceof Ld,tM=class extends Error{errors;constructor(e){super(Object.values(e).join(`; `)),this.errors=e,this.name=`ActionInputError`}},nM=(e,t)=>{let n=new Set(t.map(e=>e.name)),r=e instanceof tM?Object.entries(e.errors):Rd(e)?e.errors.flatMap(e=>e.field?[[e.field,e.message]]:[]):[];return Object.fromEntries(r.filter(([e])=>n.has(e)))},rM=e=>{if(!(!RO(e)||`missing`in e||!e.url))return{uri:e.uri,name:e.name,type:e.type,url:e.url,...e.size!==void 0&&{size:e.size}}},iM=(e,t)=>e&&Object.hasOwn(e,t)?e[t]:void 0,aM=(e,t)=>{if(/^[a-z][a-z0-9+.-]*:/i.test(t)||t.startsWith(`/`)||t.startsWith(`#`))return;let n=t.split(/[?#]/,1)[0],r=n.slice(n.lastIndexOf(`/`)+1);return e.find(e=>e.name===r)},oM=(e,t,n)=>e?.nonce===t?e.value:n,sM=(e,t)=>{let[n,r]=(0,M.useState)(),i=(0,M.useCallback)(n=>r(r=>({nonce:e,value:n(oM(r,e,t))})),[e,t]);return[oM(n,e,t),i]},cM=`data-protobase-link`,lM=`(() => {
5
- const post = (message) => parent.postMessage({ protobase: 'html-frame', ...message }, '*')
6
- const place = (hash) => {
7
- const name = decodeURIComponent(hash.slice(1))
8
- const target = name === '' || name === 'top' ? null : document.getElementById(name) ?? document.getElementsByName(name)[0]
9
- if (!target) return 0
10
- if (target.tabIndex < 0 && !target.hasAttribute('tabindex')) target.setAttribute('tabindex', '-1')
11
- target.focus({ preventScroll: true })
12
- return target.getBoundingClientRect().top + window.scrollY
13
- }
14
- const follow = (event) => {
15
- const link = event.target instanceof Element ? event.target.closest('a, area') : null
16
- if (!link) return
17
- event.preventDefault()
18
- const index = link.getAttribute('${cM}')
19
- const href = link.getAttribute('href') ?? ''
20
- if (index !== null) post({ link: Number(index), newTab: event.button === 1 || event.ctrlKey || event.metaKey || event.shiftKey })
21
- else if (href.startsWith('#') && event.button === 0) post({ scroll: place(href) })
22
- }
23
- document.addEventListener('click', follow, true)
24
- document.addEventListener('auxclick', (event) => event.button === 1 && follow(event), true)
25
- const height = () => post({ height: document.documentElement.getBoundingClientRect().height })
26
- new ResizeObserver(height).observe(document.documentElement)
27
- })()`,uM=`allow-scripts`,dM=(e,t)=>[`default-src 'none'`,e===`bridge`?`script-src 'nonce-${t}'`:`script-src 'unsafe-inline'`,`img-src data:`,`media-src data:`,`style-src 'unsafe-inline' data:`,`font-src data:`,`base-uri 'none'`,`form-action 'none'`].join(`; `),fM=()=>Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``),pM=`meta[http-equiv], base, noscript`,mM=(e,t,n)=>{let r=new DOMParser().parseFromString(e,`text/html`);for(let e of r.querySelectorAll(pM))e.remove();let i=r.createElement(`meta`);i.httpEquiv=`Content-Security-Policy`,i.content=dM(t,n);let a=r.createElement(`meta`);a.name=`referrer`,a.content=`no-referrer`;let o=r.createElement(`script`);return t===`bridge`&&o.setAttribute(`nonce`,n),o.textContent=lM,r.head.prepend(i,a,o),`<!doctype html>${r.documentElement.outerHTML}`},hM=1,gM=(e,t,n)=>e?.kind===`fixed`?e:e&&n!==e.viewport&&Math.abs(t-e.height-(n-e.viewport))<=hM?{kind:`fixed`}:{kind:`measured`,height:t,viewport:n},_M=e=>e?.kind===`measured`&&e.height>0?{style:{height:e.height}}:{className:`min-h-[60vh]`},vM=1e5,yM=(e,t,n)=>{if(!t||e.source!==t)return;let r=e.data;if(typeof r==`object`&&r&&`protobase`in r&&r.protobase===`html-frame`){if(`link`in r&&Number.isInteger(r.link)&&r.link>=0&&r.link<n)return{kind:`link`,index:r.link,newTab:`newTab`in r&&r.newTab===!0};if(`height`in r&&typeof r.height==`number`&&Number.isFinite(r.height)&&r.height>=0)return{kind:`height`,height:Math.min(Math.ceil(r.height),vM)};if(`scroll`in r&&typeof r.scroll==`number`&&Number.isFinite(r.scroll))return{kind:`scroll`,top:Math.min(Math.max(Math.round(r.scroll),0),vM)}}},bM=[],xM=(e,t)=>{let n=Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop)||0;window.scrollTo({top:e.getBoundingClientRect().top+window.scrollY+t-n})},SM=({html:e,title:t,links:n=bM,onLink:r,scripts:i=`bridge`,className:a})=>{let o=(0,M.useRef)(null),s=(0,M.useMemo)(()=>{let t=fM();return{nonce:t,srcDoc:mM(e,i,t)}},[e,i]),[c,l]=sM(s.nonce,void 0),[u,d]=sM(s.nonce,0),f=`${s.nonce}:${u}`,p=(0,M.useRef)({key:f,count:0});(0,M.useEffect)(()=>{let e=e=>{let t=yM(e,o.current?.contentWindow,n.length),i=o.current?.clientHeight;t?.kind===`height`&&i!==void 0&&l(e=>gM(e,t.height,i)),t?.kind===`link`&&r?.(n[t.index],{newTab:t.newTab}),t?.kind===`scroll`&&o.current&&xM(o.current,t.top)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[n,r,l]);let m=()=>{p.current.key!==f&&(p.current={key:f,count:0}),p.current.count+=1,p.current.count>1&&d(e=>e+1)},h=_M(c);return(0,L.jsx)(`iframe`,{ref:o,title:t,sandbox:uM,referrerPolicy:`no-referrer`,allow:i===`bridge`?`fullscreen`:void 0,srcDoc:u>1?``:s.srcDoc,onLoad:m,className:R(`block w-full border-0 bg-white`,h.className,a),style:h.style},f)},CM=e=>e.split(/[?#]/,1)[0].split(`/`).includes(`..`),wM=(e,t)=>{let n=t.trim(),r=TM(n);if(!(CM(n)||CM(r)))return aM(e,n)??aM(e,r)},TM=e=>{try{return decodeURI(e)}catch(t){if(t instanceof URIError)return e;throw t}},EM=(e,t)=>e.split(`,`).map(e=>{let n=/^(\s*)(\S+)([\s\S]*)$/.exec(e),r=n&&t(n[2]);return n&&r?`${n[1]}${r}${n[3]}`:e}).join(`,`),DM=(e,t)=>e.replace(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi,(e,n,r)=>{let i=t(r.trim());return i?`url("${i}")`:e}),OM=e=>{if(!URL.canParse(e))return;let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:void 0},kM=[`img[src]`,`source[src]`,`video[src]`,`audio[src]`,`track[src]`,`input[src]`].join(`, `),AM=(e,t)=>{let n=(e,t,n)=>n!==void 0&&e.setAttribute(t,n);for(let r of e.querySelectorAll(kM))n(r,`src`,t(r.getAttribute(`src`)));for(let r of e.querySelectorAll(`video[poster]`))n(r,`poster`,t(r.getAttribute(`poster`)));for(let r of e.querySelectorAll(`img[srcset], source[srcset]`))n(r,`srcset`,EM(r.getAttribute(`srcset`),t));for(let r of e.querySelectorAll(`link[href]`))n(r,`href`,t(r.getAttribute(`href`)));for(let r of e.querySelectorAll(`image[href]`))n(r,`href`,t(r.getAttribute(`href`)));for(let r of e.querySelectorAll(`[style]`))n(r,`style`,DM(r.getAttribute(`style`),t));for(let n of e.querySelectorAll(`style`))n.textContent=DM(n.textContent,t)},jM=e=>new DOMParser().parseFromString(e,`text/html`),MM=(e,t)=>{let n=new Set;return AM(jM(e),e=>{let r=wM(t,e);r&&n.add(r)}),[...n]},NM=(e,t,n,r)=>{let i=jM(e);for(let e of i.querySelectorAll(`[${cM}]`))e.removeAttribute(cM);AM(i,e=>{let r=wM(t,e);return r&&n.get(r.uri)});let a=[];for(let e of i.querySelectorAll(`a[href], area[href]`)){let n=e.getAttribute(`href`);if(n.startsWith(`#`))continue;e.removeAttribute(`target`);let i=wM(t,n),o=i?void 0:OM(n);if(!i&&!o){e.removeAttribute(`href`);continue}let s=i?{kind:`file`,file:i}:{kind:`external`,url:o},c=r?.(s);c!==void 0&&e.setAttribute(`href`,c),e.setAttribute(cM,String(a.length)),a.push(s)}return{html:`<!doctype html>${i.documentElement.outerHTML}`,links:a}},PM=e=>JSON.stringify(e.map(e=>[e.uri,`key`in e?e.key:null,`field`in e?e.field:null])),FM=(0,M.createContext)(void 0),IM=()=>{let e=(0,M.useContext)(FM);if(e===void 0)throw Error(`useViewedResource must be used inside a file viewer`);return e},LM=class extends Error{status;name=`FileReadError`;constructor(e){super(`The file could not be read: its link answered ${e}`),this.status=e}},RM=e=>{let t=IM(),n=z_(t);return O({queryKey:[`file-text`,t,e.uri],staleTime:1/0,queryFn:async()=>{let r=await fetch(n.fileReadUrl(t,e));if(!r.ok)throw new LM(r.status);return r.text()}})},zM=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error),r.readAsDataURL(e)}),BM=e=>{let t=IM(),n=z_(t),r=ee({queries:e.map(e=>({queryKey:[`file-data-url`,t,e.uri],staleTime:1/0,retry:!1,queryFn:async()=>{let r=await fetch(n.fileReadUrl(t,e));if(!r.ok)throw new LM(r.status);return zM(new Blob([await r.arrayBuffer()],{type:e.type}))}}))}),i=new Map;return r.forEach((t,n)=>t.data!==void 0&&i.set(e[n].uri,t.data)),{contents:i,ready:r.every(e=>!e.isPending)}},VM=(e,t,n)=>{let r=PM(t),{contents:i,ready:a}=BM((0,M.useMemo)(()=>e===void 0?[]:MM(e,t),[e,r])),o=[...i.keys()].join(`
28
- `);return(0,M.useMemo)(()=>e===void 0||!a?void 0:NM(e,t,i,n),[e,r,a,o,n])},HM=e=>{if(!Rd(e))return[{message:e instanceof Error?e.message:H(`somethingWentWrong`)}];let t=e.errors.map(e=>({message:e.message,hint:e.hint}));return t.length>0?t:[{message:e.message}]},UM=({error:e,title:t,onRetry:n})=>(0,L.jsxs)(`div`,{role:`alert`,className:`flex gap-2.5 rounded-lg border border-danger/30 bg-danger-soft px-3 py-2 text-danger-text`,children:[(0,L.jsx)(Bl,{className:`mt-0.5 size-4 shrink-0`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`font-medium`,children:t}),HM(e).map(e=>(0,L.jsxs)(`p`,{className:`text-body`,children:[e.message,e.hint&&(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.hint]})]},e.message))]}),n&&(0,L.jsx)(B,{size:`sm`,onClick:n,children:H(`tryAgain`)})]}),WM=({title:e,description:t,actions:n,className:r,bodyClassName:i,children:a})=>(0,L.jsxs)(`section`,{className:R(`flex min-w-0 flex-col rounded-lg border border-border bg-background`,r),"aria-label":e,children:[(e||t||n)&&(0,L.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-2 px-4 pt-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[e&&(0,L.jsx)(`h2`,{className:`text-base font-semibold tracking-tight`,children:e}),t&&(0,L.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t})]}),n&&(0,L.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),(0,L.jsx)(`div`,{className:R(`min-w-0 flex-1 p-4`,i),children:a})]}),GM=({children:e})=>(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:e}),KM=(0,M.createContext)(void 0),qM=({value:e,children:t})=>(0,L.jsx)(KM.Provider,{value:e,children:t}),JM=()=>(0,M.useContext)(KM),YM=({read:e,list:t,empty:n,children:r})=>e.isPending?(0,L.jsx)(Su,{className:`h-4 w-full`}):e.error?(0,L.jsx)(UM,{title:WC(`couldNotLoad`),error:e.error}):t.items.length===0&&n!==void 0?(0,L.jsx)(GM,{children:n}):(0,L.jsxs)(qM,{value:t,children:[r,t.loadMore&&(0,L.jsx)(B,{size:`sm`,onClick:t.loadMore,loading:t.loadingMore,className:`self-start`,children:WC(`loadMore`)})]}),XM=e=>`item`in e,ZM=(0,M.createContext)(void 0),QM=(0,M.createContext)([]),$M=({value:e,row:t,children:n})=>{let r=(0,M.useContext)(QM),i=t?.index,a=t?.count,o=(0,M.useMemo)(()=>[...r,i===void 0||a===void 0?e:{...e,row:{index:i,count:a}}],[r,e,i,a]);return(0,L.jsx)(tN,{stack:o,children:n})},eN=({value:e,children:t})=>{let n=(0,M.useMemo)(()=>[{...e,root:!0}],[e]);return(0,L.jsx)(tN,{stack:n,children:t})},tN=({stack:e,children:t})=>{let n=e.at(-1);return(0,L.jsx)(QM.Provider,{value:e,children:(0,L.jsx)(ZM.Provider,{value:XM(n)?void 0:n,children:(0,L.jsx)(qM,{value:void 0,children:t})})})},nN=()=>(0,M.useContext)(ZM),rN=()=>(0,M.useContext)(QM),iN=e=>{let t=e[0];return t?.root&&!XM(t)?t.record:void 0},aN=e=>{let t=iN(e);return{stack:(t?e.slice(1):e).map(e=>({record:XM(e)?e.item:e.record,...e.row&&{row:e.row}})),...t&&{root:t}}},oN=e=>typeof e==`object`&&!!e,sN=(e,t)=>t.reduce((e,t)=>oN(e)&&Object.hasOwn(e,t)?e[t]:void 0,e),cN=(e,t)=>{let n=Lt(t);if(!n)return;let r=e=>{if(e)return XM(e)?{item:sN(e.item,n.names)}:n.names.length===0?void 0:{frame:e,path:n.names.join(`.`)}};if(n.kind===`data`)return n.variable===`root`&&e[0]?.root?r(e[0]):void 0;if(n.explicit)return r(e[e.length-1-n.up]);let i=n.names[0];return r(e.findLast(e=>XM(e)?oN(e.item)&&Object.hasOwn(e.item,i):Object.hasOwn(e.model.fields,i))??e.at(-1))},lN=(0,M.createContext)(null),uN={},dN=(e,t={})=>{let n=Object.fromEntries(Object.entries({...e.given,...t}).filter(e=>e[1]!==void 0&&e[1]!==``));return{kind:`page`,page:e.page,...e.tab&&{tab:e.tab},...Object.keys(n).length>0&&{params:n}}},fN=({page:e,tab:t,tree:n,given:r=uN,children:i})=>{let a=(0,M.useMemo)(()=>Hp(n,r),[n,r]),o=(0,M.useMemo)(()=>({page:e,...t&&{tab:t},given:r,values:a}),[e,t,r,a]);return(0,L.jsx)(lN.Provider,{value:o,children:i})},pN=()=>(0,M.useContext)(lN)?.values??uN,mN=()=>(0,M.useContext)(lN)?.given??uN,hN=()=>{let e=gN();if(!e)throw Error(`A SelectInput and a select render inside a composed page, whose address holds their values`);return e},gN=()=>{let e=(0,M.useContext)(lN),{go:t,href:n}=PA();return e?{values:e.values,given:e.given,linkTo:r=>{let i=dN(e,r);return{href:n(i),onFollow:()=>t(i,{keepScroll:!0})}}}:void 0},_N=async(e,t,n={})=>{let r=t.filter||void 0,i=t.etag?{}:{etag:!1};if(t.kind===`aggregate`)return{rows:(await e.aggregate(t.resource,{groupBy:t.groupBy[0],filter:r,...t.pageSize!==void 0&&{limit:t.pageSize}})).groups.map(({value:e,count:t})=>({value:e,count:t}))};if(t.kind===`count`){let n=await e.list(t.resource,{filter:r,pageSize:1,count:`exact`,fields:t.fields,...i});return{rows:[],total:n.totalSize??n.totalSizeEstimate}}let a=await e.list(t.resource,{filter:r,orderBy:t.orderBy,pageSize:t.pageSize,fields:t.fields,limitPer:t.limitPer,...n,...i});return{rows:a.items,...a.labels&&{labels:a.labels},...a.photos&&{photos:a.photos}}},vN=At(),yN=async(e,t,n,r,i)=>{let a=n.primaryKey[0],o=[...new Set(r)].sort();if(o.length===0||n.primaryKey.length!==1)return new Map;let s=Kr(n,i),c=await e.fetchQuery({queryKey:I.labels(n.name,o.join(`,`)),staleTime:3e5,queryFn:async()=>(await t.list(n.name,{filter:yt(vN.in(a,o)),fields:[a,s],pageSize:o.length})).items.map(e=>[String(e[a]),String(e[s])])});return new Map(c)},bN=(e,t,n)=>n.flatMap(n=>{let r=t.fields[n],i=r?.type===`relation`&&r.relation?e[r.relation.resource]:void 0;return i?[{name:n,target:i}]:[]}),xN=(e,t,n,r)=>Object.fromEntries(bN(e,n,r).filter(({target:e})=>e.primaryKey.length===1&&!t[e.name]?.titleFrom).map(({name:e,target:n})=>[e,Kr(n,t[n.name])])),SN=(e,t,n,r,i={})=>{let a=bN(e,t,n);return r.map(e=>{let t={...e};for(let{name:n}of a)e[n]!=null&&(t[n]={id:e[n],name:i[n]?.[String(e[n])]??String(e[n])});return t})},CN=At(),wN=(e,t)=>{let n=t?.titleFrom;if(n&&!n.unreadable&&e.primaryKey.length===1)return n.fields},TN=(e,t,n)=>I.titleRow(e.name,t,n.join(`,`)),EN=async(e,t,n,r)=>{let i=t.primaryKey[0],a=[...new Set(r)];if(a.length===0)return new Map;let o=await e.list(t.name,{filter:yt(CN.in(i,a)),fields:[i,...n],pageSize:a.length});return new Map(o.items.map(e=>[String(e[i]),e]))},DN=async(e,t,n,r,i,a,o)=>{let s=new Map;for(let e of a){let t=i.fields[e],a=t?.type===`relation`&&t.relation?n[t.relation.resource]:void 0;if(!a||!wN(a,r[a.name]))continue;let c=o.flatMap(t=>t[e]==null?[]:[String(t[e])]);s.set(a.name,[...s.get(a.name)??[],...c])}await Promise.all([...s].map(async([i,a])=>{let o=n[i],s=wN(o,r[i]),c=await EN(t,o,s,a);for(let t of new Set(a))e.setQueryData(TN(o,t,s),{row:c.get(t)??null})}))},ON=({label:e,className:t})=>(0,L.jsx)(`span`,{role:e===void 0?void 0:`img`,"aria-label":e,title:e,className:R(`inline-flex size-4 items-center justify-center rounded-full bg-success-soft text-success-text`,t),children:(0,L.jsx)(Xo,{className:`size-3`,strokeWidth:3})}),kN=(e,t,n)=>{if(!URL.canParse(e,t))return`no-referrer`;let r=new URL(e,t);if((r.protocol===`http:`||r.protocol===`https:`)&&!(r.origin===new URL(t).origin||n.includes(r.hostname)))return`no-referrer`},AN=e=>URL.canParse(e)?[new URL(e).hostname]:[],jN=()=>{let e=(0,M.useContext)(W_);return(0,M.useMemo)(()=>[...e?.files?.trustedHosts??[],...(e?.sources??[]).flatMap(({source:e})=>AN(e.url))],[e?.files,e?.sources])},MN=e=>{let t;try{t=atob(e)}catch(e){if(e instanceof DOMException&&e.name===`InvalidCharacterError`)return;throw e}return te(Uint8Array.from(t,e=>e.charCodeAt(0)))},NN=({image:e,alt:t=``,className:n,loading:r})=>{let[i,a]=(0,M.useState)(),o=jN(),s=(0,M.useMemo)(()=>e.placeholder===void 0?void 0:MN(e.placeholder),[e.placeholder]),c=s!==void 0&&i!==e.url;return(0,L.jsx)(`img`,{src:e.url,alt:t,loading:r,decoding:`async`,referrerPolicy:kN(e.url,window.location.href,o),onLoad:()=>a(e.url),className:n,style:c?{backgroundImage:`url("${s}")`,backgroundSize:`cover`,backgroundPosition:`center`}:void 0})},PN=e=>t=>{let n=t.currentTarget;n.scrollWidth>Math.ceil(n.getBoundingClientRect().width)?n.title=e:n.removeAttribute(`title`)},FN=({text:e,className:t})=>(0,L.jsx)(`span`,{className:R(`truncate`,t),onMouseEnter:PN(e),children:e}),IN=e=>e.stopPropagation(),LN=({format:e,value:t,label:n,className:r})=>{let i=Tk(e,t);return i?(0,L.jsx)(`a`,{href:i,...e===`url`?{target:`_blank`,rel:`noreferrer`}:{},onClick:IN,className:R(`font-medium text-primary-text hover:underline`,r),children:n??t}):(0,L.jsx)(`span`,{className:r,children:t})},RN=e=>(0,L.jsx)(`span`,{className:`text-faint-foreground`,children:e}),zN=(e,t,n)=>{if(t==null)return RN(`—`);let r=ek(e,t)??``;switch(e.kind){case`text`:return e.link?(0,L.jsx)(LN,{format:e.link,value:r,label:n&&e.linkText?.(n),className:`block min-w-0 truncate`}):(0,L.jsx)(FN,{text:r});case`id`:return(0,L.jsx)(FN,{text:r,className:`font-mono text-xs text-muted-foreground`});case`money`:return(0,L.jsx)(`span`,{className:`tabular-nums`,children:r});case`date`:return(0,L.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:r});case`datetime`:return(0,L.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,title:e.relative?vE(Number(t)):QO(`shownIn`,{zone:sE(Number(t),QT())}),children:r});case`number`:return(0,L.jsx)(`span`,{className:`tabular-nums`,children:r});case`signed`:return(0,L.jsx)(`span`,{className:R(`tabular-nums`,Number(t)<0?`text-danger-text`:`text-success-text`),children:r});case`percent`:return Number(t)===0?RN(`—`):(0,L.jsx)(`span`,{className:`tabular-nums`,children:r});case`status`:return(0,L.jsx)(Xv,{tone:e.tones?.[String(t)]??`neutral`,color:Ok(e.colors,t),shape:e.shape,children:r});case`relation`:return(0,L.jsx)(FN,{text:r,className:`font-medium text-primary-text hover:underline`});case`boolean`:return t?(0,L.jsx)(ON,{}):RN(QO(`no`));case`file`:{let e=BO(t);if(!e)return RN(`—`);if(`missing`in e)return(0,L.jsx)(FN,{text:e.name,className:`text-danger-text`});let n=JO(t,{width:20,height:20});return(0,L.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[n?(0,L.jsx)(NN,{image:n,className:`size-5 shrink-0 rounded-sm object-cover`}):(0,L.jsx)(Rc,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(FN,{text:e.name})]})}case`user`:{let n=e.users?.(String(t));return n?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2 truncate`,children:[(0,L.jsx)(sb,{initials:n.initials,hue:n.hue,size:`xs`,className:`ring-0`}),(0,L.jsx)(FN,{text:n.name,className:`text-muted-foreground`})]}):(0,L.jsx)(FN,{text:r,className:`text-muted-foreground`})}}},BN=e=>{e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`},VN=({invalid:e,className:t,rows:n=3,value:r,ref:i,...a})=>{let o=(0,M.useRef)(null),s=(0,M.useCallback)(e=>{o.current=e,typeof i==`function`?i(e):i&&(i.current=e)},[i]),c=Tb();return(0,M.useLayoutEffect)(()=>{o.current&&BN(o.current)},[r]),(0,M.useEffect)(()=>{let e=o.current;if(!e)return;let t=e.clientWidth,n=new ResizeObserver(()=>{e.clientWidth!==t&&(t=e.clientWidth,BN(e))});return n.observe(e),()=>n.disconnect()},[]),(0,L.jsx)(`textarea`,{ref:s,rows:n,value:r,className:R(`block w-full resize-none overflow-hidden rounded-md border bg-background px-2.5 py-1.5 text-body text-foreground shadow-sm outline-none placeholder:text-faint-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`,e?`border-danger`:`border-border-strong`,t),...c,...e&&{"aria-invalid":!0},...a})},HN=({children:e})=>(0,L.jsx)(`pre`,{className:`whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md bg-muted/60 px-3 py-2 font-mono text-xs text-foreground`,children:e}),UN=e=>{let t=e.split(`
29
- `);return t.length<=20?{lines:t.length,folded:null}:{lines:t.length,folded:t.slice(0,20).join(`
30
- `)}},WN=F(`app/field-types/json`),GN=({value:e})=>{let[t,n]=(0,M.useState)(!1),r=JSON.stringify(e,null,2),{lines:i,folded:a}=UN(r);return a===null?(0,L.jsx)(HN,{children:r}):(0,L.jsxs)(`div`,{className:`grid gap-1`,children:[(0,L.jsx)(HN,{children:t?r:a}),(0,L.jsx)(B,{size:`sm`,variant:`ghost`,className:`-ml-2 justify-self-start`,"aria-expanded":t,onClick:()=>n(!t),children:t?WN(`showLess`):WN(`showAll`,{count:i})})]})},KN=Symbol(`not JSON`),qN=e=>{if(e.trim()===``)return null;try{return JSON.parse(e)}catch(e){if(!(e instanceof SyntaxError))throw e;return KN}},JN=({value:e})=>e===null?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,L.jsx)(GN,{value:e}),YN=({value:e})=>(0,L.jsx)(FN,{text:Ik(e)}),XN=({value:e,onChange:t,invalid:n})=>{let[r,i]=(0,M.useState)(),a=r??(e===null?``:JSON.stringify(e,null,2)),o=r!==void 0&&qN(r)===KN;return(0,L.jsxs)(`div`,{className:`grid gap-1`,children:[(0,L.jsx)(VN,{value:a,rows:3,invalid:n||o,className:`font-mono text-xs`,onChange:e=>{i(e.target.value);let n=qN(e.target.value);n!==KN&&t(n)}}),o&&(0,L.jsx)(`p`,{className:`text-xs text-danger-text`,children:WN(`notJson`)})]})},ZN={of:[...Si.json],display:JN,editor:XN,cell:YN,wide:!0},QN=({editor:e,cell:t,...n},r)=>{let i=(e,t)=>WD(()=>r().then(t=>e(t)??(()=>null)),()=>(0,L.jsx)(Su,{className:t})),a=n.wide?`h-24 w-full`:`h-4 w-24`;return{...n,display:i(e=>e.display,a),...e&&{editor:i(e=>e.editor,a)},...t&&{cell:i(e=>e.cell,`h-3 w-16`)}}},$N=F(`app/field-types/members`),eP=({id:e,name:t})=>(0,L.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(sb,{initials:t&&ub(t)||`?`,hue:lb(e),size:`xs`,className:`ring-0`}),(0,L.jsx)(`span`,{className:t===void 0?`truncate text-muted-foreground`:`truncate`,children:t??$N(`unknownMember`)})]}),tP=At(),nP=e=>e.split(/\s+/).filter(Boolean),rP=(e,t,n,r=!1)=>{let i=nP(n);if(i.length===0)return{filter:void 0,local:!1};if(r)return{filter:void 0,local:!0};if(e.search?.length)return{filter:yt(tP.search(n)),local:!1};let a=e.fields[t];if(a?.type!==`text`||!a.filterable)return{filter:void 0,local:!0};let o=i.map(e=>tP.eq(t,`*${e.replaceAll(`*`,``)}*`));return{filter:yt(tP.and(...o)),local:!1}},iP=(e,t)=>{if(e==null)return!1;let n=String(e).toLowerCase();return nP(t).every(e=>n.includes(e.toLowerCase()))},aP=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],oP=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],sP=(e,t)=>e.filter(e=>iP(e.name,t)).map(e=>({key:e.id,label:e.name})),cP=()=>{let e=l_(),t=oD();return{...t,needsOrganizations:!e?.organizations,failed:t.isError}},lP=({value:e,line:t})=>{let n=cP(),r=aP(e);return r.length===0?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):n.needsOrganizations?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:$N(`needsOrganizations`)}):n.failed?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:$N(`couldNotLoadMembers`)}):n.isLoading?(0,L.jsx)(Su,{className:`h-4 w-24`}):(0,L.jsx)(`span`,{className:R(`flex min-w-0 items-center gap-x-3 gap-y-1`,t?`overflow-hidden`:`flex-wrap`),children:r.map(e=>(0,L.jsx)(eP,{id:e,name:n.member(e)?.name},e))})},uP=e=>(0,L.jsx)(lP,{...e,line:!1}),dP=e=>(0,L.jsx)(lP,{...e,line:!0}),fP=({label:e,onRemove:t})=>(0,L.jsxs)(`span`,{className:`inline-flex h-5 max-w-full items-center gap-0.5 rounded bg-primary-soft pl-1.5 pr-0.5 text-xs font-medium text-primary-text`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:e}),(0,L.jsx)(`button`,{type:`button`,"aria-label":du(`remove`,{label:e}),className:`rounded p-0.5 hover:bg-primary-border/60`,onMouseDown:e=>e.preventDefault(),onClick:t,children:(0,L.jsx)(uu,{className:`size-3`})})]}),pP=()=>{let[e,t]=(0,M.useState)(``),[n,r]=(0,M.useState)(!1);return{text:e,setText:t,open:n,setOpen:r}},mP=(e,t,n,r)=>{(0,M.useEffect)(()=>{if(!e||!t||!r)return;let n=new IntersectionObserver(e=>e.some(e=>e.isIntersecting)&&r(),{root:e});return n.observe(t),()=>n.disconnect()},[e,t,n,r])},hP=({search:e,options:t,chosen:n,several:r,closedText:i,placeholder:a,invalid:o,paging:s,loading:c,failed:l,onChoose:u})=>{let{text:d,setText:f,open:p,setOpen:m}=e,[h,g]=(0,M.useState)(-1),[_,v]=(0,M.useState)(null),[y,b]=(0,M.useState)(null),x=(0,M.useId)(),S=s?.more??!1;mP(_,y,s?.loaded??0,s?.loadMore);let C=e=>`${x}-${e}`,w=(0,M.useRef)(null);(0,M.useEffect)(()=>{!p&&document.activeElement===w.current&&w.current?.select()},[p]),(0,M.useEffect)(()=>{p&&h>=0&&document.getElementById(C(h))?.scrollIntoView({block:`nearest`})});let T=()=>{f(``),g(-1),m(!1)},E=e=>{if(u(e),!r)return T();f(``),g(-1)};return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Eb,{ref:w,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":p,"aria-controls":x,"aria-activedescendant":p&&t[h]?C(h):void 0,invalid:o,placeholder:a,value:p?d:i,onFocus:()=>m(!0),onBlur:T,onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!p)return m(!0);let n=e.key===`ArrowDown`?1:-1;g(e=>Math.min(Math.max(e+n,0),t.length-1));return}if(e.key===`Enter`&&p&&t[h]){e.preventDefault(),E(t[h]);return}e.key===`Escape`&&p&&(e.preventDefault(),e.stopPropagation(),T())},onChange:e=>{f(e.target.value),g(e.target.value.trim()?0:-1),m(!0)}}),p&&(0,L.jsxs)(`ul`,{ref:v,id:x,role:`listbox`,"aria-multiselectable":r||void 0,className:`absolute z-30 mt-1 max-h-60 w-full overflow-y-auto rounded-md border bg-background py-1 shadow-pop`,onMouseDown:e=>e.preventDefault(),children:[t.map((e,t)=>(0,L.jsx)(`li`,{id:C(t),role:`option`,"aria-selected":t===h,className:R(`cursor-pointer truncate px-3 py-1.5`,t===h&&`bg-muted`,n.includes(e.key)&&`font-medium`),onMouseMove:()=>t!==h&&g(t),onClick:()=>E(e),children:e.label},e.key)),S&&(0,L.jsx)(`li`,{ref:b,"aria-hidden":!0,className:`h-px`}),l&&(0,L.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:H(`couldNotLoadOptions`)}),!S&&!c&&!l&&t.length===0&&(0,L.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:H(`noMatches`)}),c&&(0,L.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:H(`loading`)})]})]})},gP=({value:e,invalid:t,onChange:n})=>{let r=pP(),i=cP(),a=aP(e);if(i.needsOrganizations)return(0,L.jsx)(`p`,{className:`py-1.5 text-muted-foreground`,children:$N(`needsOrganizations`)});let o=e=>i.member(e)?.name??$N(`unknownMember`);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(hP,{search:r,options:sP(i.data??[],r.text),chosen:a,several:!0,closedText:``,placeholder:$N(`searchMembers`),invalid:t,loading:i.isLoading,failed:i.failed,onChoose:e=>n(oP(a,e.key))}),a.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>(0,L.jsx)(fP,{label:o(e),onRemove:()=>n(a.filter(t=>t!==e))},e))})]})},_P={json:ZN,members:{of:[...Si.members],display:uP,editor:gP,cell:dP},workflow:QN({of:[...Si.workflow],wide:!0,editor:!0,cell:!0},()=>s(()=>import(`./workflow-field-D7X0A1GO.js`).then(e=>e.workflowField),__vite__mapDeps([56,1,6,7,57,58,59,60,61,62,63,64,65]))),workflow_run:QN({of:[...Si.workflow_run],wide:!0,editor:!1,cell:!0},()=>s(()=>import(`./workflow-run-field-DJLolq5e.js`).then(e=>e.workflowRunField),__vite__mapDeps([66,1,6,7]))),workflow_status:QN({of:[...Si.workflow_status],editor:!1,cell:!0},()=>s(()=>import(`./workflow-status-field-weFyKOIV.js`).then(e=>e.workflowStatusField),__vite__mapDeps([67,1,6,10,7,68,8,65,57,58,59,60,61,62,63]))),custom_step_container:QN({of:[...Si.custom_step_container],wide:!0,editor:!0,cell:!0},()=>s(()=>import(`./custom-step-container-field-DTCgqZMO.js`).then(e=>e.customStepContainerField),__vite__mapDeps([69,1,6]))),runner_install:QN({of:[...Si.runner_install],editor:!1,cell:!0},()=>s(()=>import(`./runner-install-field--7xa6MIJ.js`).then(e=>e.runnerInstallField),__vite__mapDeps([70,1,6,35])))},vP=(e,t)=>{if(e&&Object.hasOwn(e,t))return e[t];if(Object.hasOwn(_P,t))return _P[t]},yP=(e,t,n)=>{let r=n?.widget;if(!r||t.sensitive)return;let i=vP(e,r.name);return i?.of.includes(t.type)?{name:r.name,widget:i,props:r.props??{}}:void 0},bP=(e,t)=>yP(tT().fields,e,t),xP=(e,t,n)=>{let r=yP(e,t,n);return!!(n?.multiline||n?.markdown||(r?r.widget.wide:t.type===`json`))},SP=F(`app/field-types`),CP=({shown:e,part:t,field:n,value:r,onChange:i,invalid:a=!1})=>{let{widget:o,props:s}=e,c={field:n,value:r??null,props:s};if(t!==`editor`){let e=t===`cell`?o.cell??o.display:o.display;return(0,L.jsx)(e,{...c})}let l=o.editor;return l&&i?(0,L.jsx)(l,{...c,onChange:i,invalid:a}):void 0},wP=({fallback:e,...t})=>{let n=CP(t);return n?(0,L.jsx)(GC,{name:SP(`fieldType`,{name:t.shown.name}),fallback:e,children:n}):e},TP=(e,t)=>e.type===`relation`&&typeof t==`object`&&t&&`id`in t?t.id:t,EP=(e,t,n,r)=>e.map(e=>{let i=t.fields[e.id],a=i&&yP(r,i,n?.fields[e.id]);return a?{...e,render:t=>(0,L.jsx)(wP,{shown:a,part:`cell`,field:i,value:TP(i,t[e.id]),fallback:zN(e,e.value?e.value(t):t[e.id],t)})}:e}),DP=(e,t,n,r,i)=>{let a=r?.titleFrom;return a?{queryKey:TN(n,i,a.fields),queryFn:async()=>({row:(await EN(t,n,a.fields,[i])).get(i)??null})}:{queryKey:I.relatedLabel(n.name,i),queryFn:async()=>({label:(await yN(e,t,n,[i],r)).get(i)??i})}},OP=(e,t,n,r,i)=>{if(e)return`label`in e?e.label:e.row?t(n,r,e.row,i):i},kP=(e,t,n=!0)=>{let{views:r}=Tv(),i=X(),a=x(),o=pD(),s=r[e.name];return OP(O({...DP(a,i,e,s,t),staleTime:3e5,enabled:n}).data,o,e,s,t)},AP=e=>String(typeof e==`object`&&e&&`id`in e?e.id:e),jP=({target:e,id:t})=>(0,L.jsx)(FN,{text:kP(e,t)??t,className:`font-medium text-primary-text hover:underline`}),MP=(e,t,n,r)=>e.map(e=>{let i=t.fields[e.id],a=i?.type===`relation`&&i.relation?n[i.relation.resource]:void 0;return e.render||!a||!r[a.name]?.titleFrom?e:{...e,render:t=>t[e.id]==null?zN(e,null):(0,L.jsx)(jP,{target:a,id:AP(t[e.id])})}}),NP=({value:e,hints:t,children:n})=>(0,L.jsx)(Xv,{tone:kk(t?.valueColors,e),color:Ok(t?.valueColors,e),shape:t?.badgeShape,children:n}),PP=(0,M.lazy)(()=>s(()=>import(`./markdown-content-CfblNnhw.js`).then(e=>({default:e.MarkdownContent})),__vite__mapDeps([71,1,6,72,73,74]))),FP=e=>(0,L.jsx)(M.Suspense,{fallback:(0,L.jsx)(`div`,{className:R(`whitespace-pre-line break-words`,e.className),children:e.source}),children:(0,L.jsx)(PP,{...e})}),IP=F(`app/file-viewers`),LP=({name:e})=>(0,L.jsxs)(`div`,{className:`space-y-3 px-4 py-6 md:px-10`,"aria-busy":`true`,children:[(0,L.jsx)(`span`,{role:`status`,className:`sr-only`,children:IP(`loading`,{name:e})}),(0,L.jsx)(Su,{className:`h-6 w-2/3`}),(0,L.jsx)(Su,{className:`h-40`})]}),RP=(0,M.lazy)(()=>s(()=>import(`./html-viewer-FMIvHlJ9.js`).then(e=>({default:e.HtmlViewer})),__vite__mapDeps([75,1,6]))),zP={"text/html":{component:e=>(0,L.jsx)(M.Suspense,{fallback:(0,L.jsx)(LP,{name:e.file.name}),children:(0,L.jsx)(RP,{...e})})}},BP=(e,t)=>iM(e.fileViewers,t)??iM(zP,t),VP=({file:e,className:t})=>(0,L.jsxs)(`a`,{href:e.url,download:e.name,className:R(hu({size:`sm`}),`gap-1.5`,t),children:[(0,L.jsx)(ws,{className:`size-4`,"aria-hidden":`true`}),IP(`download`)]}),HP=(e,t)=>Object.values(e.fields).filter(n=>n.type===`relation`&&n.filterable&&n.name!==e.tenant&&t[n.name]!=null),UP=e=>typeof e==`object`&&e&&`id`in e?e.id:e,WP=(e,t)=>{let n=HP(e,t);if(n.length!==0)return n.map(e=>`${e.name} = ${JSON.stringify(UP(t[e.name]))}`).join(` AND `)},GP=(e,t,n)=>{let r=Object.values(e.fields).filter(e=>e.type===`file`),i=new Map;for(let a of t)for(let t of r){let r=rM(a[t.name]);r&&r.uri!==n.uri&&!i.has(r.uri)&&i.set(r.uri,{...r,key:DT(e,a),field:t.name})}return[...i.values()]},KP=100,qP=(e,t)=>t.type===`file`?[t.name,...[t.file?.typeField,t.file?.sizeField].filter(t=>t!==void 0&&Object.hasOwn(e.fields,t))]:[],JP=(e,t,n)=>{let r=WP(e,t),i=[...e.primaryKey,...Object.values(e.fields).flatMap(t=>qP(e,t))],a=Uj(e.name,{filter:r,pageSize:KP,fields:i,enabled:r!==void 0});return{siblings:GP(e,r===void 0?[t]:[t,...a.items],n),ready:r===void 0||!a.isPending}},YP=(e,t,n,r)=>{if(t.fields[r]?.type!==`file`)return;let i=rM(n[r]);if(!i)return;let a=BP(e,i.type);return a?{field:r,file:i,viewer:a}:{field:r,file:i}},XP=({model:e,record:t,viewed:n,back:r})=>{let{file:i,viewer:a}=n;return(0,L.jsxs)(`div`,{className:`flex flex-1 flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3 md:px-10`,children:[(0,L.jsxs)(FA,{to:r,className:R(hu({variant:`ghost`,size:`sm`}),`gap-1.5`),children:[(0,L.jsx)(So,{className:`size-4`,"aria-hidden":`true`}),IP(`backToRecord`)]}),(0,L.jsxs)(`h1`,{className:`min-w-0 flex-1 truncate font-medium`,title:i.name,children:[i.name,i.size!==void 0&&(0,L.jsx)(`span`,{className:`ml-2 text-xs font-normal text-muted-foreground`,children:HO(i.size)})]}),(0,L.jsx)(VP,{file:i})]}),(0,L.jsx)(`div`,{className:`flex-1`,children:a?(0,L.jsx)(ZP,{model:e,record:t,file:i,viewer:a}):(0,L.jsx)(QP,{file:i})})]})},ZP=({model:e,record:t,file:n,viewer:r})=>{let{siblings:i,ready:a}=JP(e,t,n);if(!a)return(0,L.jsx)(LP,{name:n.name});let o=r.component;return(0,L.jsx)(FM.Provider,{value:e.name,children:(0,L.jsx)(GC,{name:n.type,fallback:(0,L.jsx)($P,{file:n}),children:(0,L.jsx)(o,{file:n,siblings:i})})})},QP=({file:e})=>(0,L.jsxs)(`div`,{className:`flex flex-col items-start gap-3 px-4 py-6 md:px-10`,role:`status`,children:[(0,L.jsx)(`p`,{children:IP(`noPreview`,{name:e.name})}),(0,L.jsx)(VP,{file:e})]}),$P=({file:e})=>(0,L.jsxs)(`div`,{className:`flex flex-col items-start gap-3 px-4 py-6 md:px-10`,role:`alert`,children:[(0,L.jsx)(`p`,{children:IP(`couldNotShow`,{name:e.name})}),(0,L.jsx)(VP,{file:e})]}),eF=({field:e,model:t,record:n,name:r,url:i,className:a})=>{let o=tT(),s=e&&t&&n&&t.primaryKey.every(e=>n[e]!=null)?YP(o,t,n,e):void 0;return s?.viewer&&t&&n?(0,L.jsx)(FA,{to:{kind:`record`,resource:t.name,key:DT(t,n),file:s.field},className:a,children:r}):(0,L.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:a,children:r})},tF=({invalid:e,className:t,children:n,...r})=>{let i=Tb();return(0,L.jsx)(`select`,{...i,...e&&{"aria-invalid":!0},className:R(`h-8 w-full min-w-0 rounded-md border bg-background px-2 shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20`,e?`border-danger`:`border-border-strong`,t),...r,children:n})},nF=F(`mailbox`),rF=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase(),iF=({address:e,senders:t})=>[...e&&!t.some(t=>rF(t.address,e))?[{address:e}]:[],...t.map(e=>({address:e.address,...e.name&&{name:e.name}}))],aF=({address:e,name:t})=>t?`${t} <${e}>`:e,oF=3e4,sF,cF=new Set,lF=({owner:e,mailSenders:t})=>{if(sF&&sF.owner===e&&Date.now()-sF.at<oF)return sF.read;let n=t().then(iF);return sF={owner:e,at:Date.now(),read:n},n.then(void 0,()=>{sF?.read===n&&(sF=void 0)}),n},uF=e=>(cF.add(e),()=>void cF.delete(e)),dF=()=>{sF=void 0;for(let e of cF)e()},fF=()=>{let e=l_(),t=e&&e.personalMail.length>0&&e.state.kind===`signed-in`?e.state.user.id:void 0,n=e?.session.account,[r,i]=(0,M.useState)(0),a=(0,M.useCallback)(()=>i(e=>e+1),[]);(0,M.useEffect)(()=>uF(a),[a]);let[o,s]=(0,M.useState)({});return(0,M.useEffect)(()=>{if(t===void 0||!n)return;let e=!0;return lF({owner:t,mailSenders:n.mailSenders}).then(n=>{e&&s({owner:t,reads:r,options:n})},n=>{if(!(n instanceof K)&&!(n instanceof Sh))throw n;let i=n instanceof K?Iv(n):nF(`sendersNotRead`);e&&s({owner:t,reads:r,error:i,retry:a})}),()=>{e=!1}},[t,n,r,a]),t===void 0?{options:[]}:o.owner===t&&(o.reads===r||o.options)?o:{}},pF=e=>(0,L.jsx)(mF,{...e,...fF()}),mF=({field:e,value:t,invalid:n,onChange:r,options:i,error:a,retry:o})=>{let s=String(t??``),c=i?.find(e=>s!==``&&rF(e.address,s)),l=s!==``&&i!==void 0&&!c;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(tF,{invalid:n,disabled:i===void 0&&!a,value:c?.address??s,onChange:e=>r(e.target.value),children:[(e.nullable||s===``)&&(0,L.jsx)(`option`,{value:``,children:nF(e.nullable?`defaultSender`:`chooseSender`)}),s!==``&&!c&&(0,L.jsx)(`option`,{value:s,children:l?nF(`senderNotAvailable`,{address:s}):s}),(i??[]).map(e=>(0,L.jsx)(`option`,{value:e.address,children:aF(e)},e.address))]}),l&&(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:nF.rich(`senderNotYours`,{account:(0,L.jsx)(Zu,{to:`/-/account`,className:`font-medium text-primary-text hover:underline`,children:nF(`accountPage`)})})}),a&&(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:a}),o&&(0,L.jsx)(B,{size:`sm`,onClick:o,children:nF(`tryAgain`)})]})]})},hF=({value:e})=>{let{options:t}=fF(),n=t?.find(t=>rF(t.address,e));return(0,L.jsx)(`span`,{className:`break-words`,children:n?aF(n):e})},gF=({target:e,id:t,known:n})=>{let r=kP(e,t,n===void 0);return(0,L.jsx)(FA,{to:{kind:`record`,resource:e.name,key:t},className:`font-medium text-primary-text hover:underline`,children:n??r??t})},_F=({field:e,value:t,known:n})=>{let{resources:r}=Tv(),i=e.relation?r[e.relation.resource]:void 0;return i?(0,L.jsx)(gF,{target:i,id:String(t),known:n}):(0,L.jsx)(`span`,{children:String(t)})},vF=()=>(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,L.jsx)(`span`,{className:`sr-only`,children:H(`noValue`)})]}),yF=({field:e,value:t,hints:n,relationLabel:r,linkText:i,model:a,record:o})=>{if(t==null||t===``)return(0,L.jsx)(vF,{});if(e.type===`relation`)return(0,L.jsx)(_F,{field:e,value:t,known:r});let s=e.type===`file`?BO(t):void 0;if(s&&`url`in s&&s.url){let n=JO(t,{width:40,height:40});return(0,L.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[n&&(0,L.jsx)(NN,{image:n,className:`size-10 shrink-0 rounded border border-border object-cover`}),(0,L.jsx)(eF,{field:e.name,model:a,record:o,name:s.name,url:s.url,className:`truncate font-medium text-primary-text hover:underline`})]})}if(Sk(e,n))return(0,L.jsx)(FP,{source:String(t)});if(e.type===`json`)return(0,L.jsx)(GN,{value:t});if(e.type===`mail_sender`)return(0,L.jsx)(hF,{value:String(t)});let c=Rk(e,t,n),l=e.type===`text`?wk(n):void 0;return l?(0,L.jsx)(LN,{format:l,value:c,label:i}):e.type===`enum`||n.format===`badge`?(0,L.jsx)(NP,{value:t,hints:n,children:c}):e.type===`timestamp`||e.type===`date`?(0,L.jsx)(`time`,{dateTime:String(t),title:zk(e,t,void 0,n),children:c}):(0,L.jsx)(`span`,{title:zk(e,t,void 0,n),className:R(n.format===`code`&&`font-mono text-xs`,(e.type===`decimal`||e.type===`integer`)&&`tabular-nums`,n.multiline&&`whitespace-pre-line break-words`),children:c})},bF=({model:e,field:t,value:n,format:r,relationLabel:i,record:a,relationLabels:o})=>{let{views:s}=Tv(),c={...s[e.name]?.fields[t.name],...r&&{format:r}},l=a&&c.format===`url`?Hk(e,s[e.name],t.name,a,o):void 0;return(0,L.jsx)(yF,{field:t,value:n,hints:c,relationLabel:i,linkText:l,model:e,record:a})},xF=e=>{let{views:t}=Tv(),n=bP(e.field,t[e.model.name]?.fields[e.field.name]),r=(0,L.jsx)(bF,{...e});return n?(0,L.jsx)(wP,{shown:n,part:`display`,field:e.field,value:e.value,fallback:r}):r},SF=(e,t)=>({model:e,record:t,key:tr(DT(e,t)),etag:typeof t.etag==`string`?t.etag:void 0,permissions:t.permissions}),CF=(e,t,n=``)=>({queryKey:I.count(t.name,n),queryFn:async()=>{let r=await e.list(t.name,{filter:n||void 0,pageSize:1,count:`exact`,fields:t.primaryKey});return r.totalSize??r.totalSizeEstimate}}),wF=(e,t=``,n=!0)=>O({...CF(X(),e,t),enabled:n}),TF=(e,t,{filter:n=``,sort:r=``,key:i})=>({queryKey:i===void 0?I.firstRecord(t.name,n,r):I.record(t.name,i),queryFn:async()=>{if(i!==void 0){let n=await e.get(t.name,i);return{...SF(t,n.record),etag:n.etag,permissions:n.permissions}}let a=await e.list(t.name,{filter:n||void 0,orderBy:r||void 0,pageSize:1});return a.items[0]?SF(t,a.items[0]):null}}),EF=(e,{enabled:t=!0,...n})=>O({...TF(X(),e,n),enabled:t}),DF=(e,t,{filter:n=``,sort:r=``,pageSize:i,pageToken:a=``})=>({queryKey:I.list(t.name,n,r,i,a),queryFn:()=>e.list(t.name,{filter:n||void 0,orderBy:r||void 0,pageSize:i,pageToken:a||void 0})}),OF=(e,{enabled:t=!0,...n})=>O({...DF(X(),e,n),enabled:t,placeholderData:y}),kF=(e,t)=>({isPending:t.isPending,error:t.error,data:t.rows[0]?{...SF(e,t.rows[0]),planned:!0}:t.isPending?void 0:null}),AF=()=>{let e=x();return(0,M.useCallback)(t=>e.invalidateQueries({predicate:e=>Ji(e.queryKey,new Set([t]))}),[e])},jF=(e,t,n)=>{if(!t)return[];let r=um(e,t.model.name,n);return r.ok?r.steps:[]},MF=(e,t,n,r,i)=>({queryKey:I.pathValue(n?.model.name??``,n?.key??``,r),enabled:i.length>1,queryFn:async()=>{let r=n.record;for(let n of i.slice(0,-1)){let i=r[n.field.name];if(i==null)return null;let a=n.field.relation.resource;r=(await t.fetchQuery({queryKey:I.record(a,String(i)),queryFn:()=>e.get(a,String(i))})).record}return r[i.at(-1).field.name]??null}}),NF=(e,t,n)=>{let r=t.at(-1);return!e||!r?{state:`missing`}:t.length===1?{state:`ready`,value:e.record[r.field.name],field:r.field,model:r.model}:n.isPending?{state:`loading`}:{state:`ready`,value:n.data??null,field:r.field,model:r.model}},PF=(e,t)=>{let{resources:n}=Tv(),r=jF(n,e,t);return NF(e,r,O(MF(X(),x(),e,t,r)))},FF=e=>{let t=cN(rN(),e),n=PF(t&&`frame`in t?t.frame:void 0,t&&`path`in t?t.path:e);return t&&`item`in t?{state:`plain`,value:t.item}:n},IF=e=>{let{resources:t}=Tv(),n=X(),r=x(),i=e.map(({scope:e,path:n})=>jF(t,e,n)),a=ee({queries:e.map(({scope:e,path:t},a)=>MF(n,r,e,t,i[a]))});return e.map(({scope:e},t)=>NF(e,i[t],a[t]))},LF=e=>e.includes(`.`),RF=({model:e,row:t,column:n})=>{let r=PF(SF(e,kA(e,t).record),n);return r.state===`loading`?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`…`}):r.state===`missing`?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,L.jsx)(xF,{model:r.model,field:r.field,value:r.value})},zF=(e,t,{resources:n,views:r})=>{let i=um(n,e.name,t),a=i.ok?i.steps.at(-1):void 0,o=a?.field.name??t;return{id:t,header:r[a?.model.name??e.name]?.fields[o]?.label??Hr(o),kind:`text`,width:200,render:n=>(0,L.jsx)(RF,{model:e,row:n,column:t})}},BF=(e,t,n,r)=>{let i=new Map(MP(EP(qk(e,t,[],n.filter(e=>!LF(e))),e,t,r.fieldTypes),e,r.resources,r.views).map(e=>[e.id,e]));return n.flatMap(t=>LF(t)?[zF(e,t,r)]:i.get(t)??[])},VF=(e,t,{shown:n,opens:r,bulk:i})=>{if(i)return;let a=[...e.primaryKey,...n.map(e=>e.split(`.`)[0]),...r?[r]:[],qr(e,t),...lD(e,t)];return[...new Set(a)].filter(t=>Object.hasOwn(e.fields,t))},HF=({model:e,view:t,resources:n,views:r,fieldTypes:i,columns:a,button:o,opens:s,bulk:c,phoneColumns:l,xs:u})=>{let d=BF(e,t,a??xi(e,t),{resources:n,views:r,fieldTypes:i}),f=u&&l?l(d):d,p=EA(e,t,[...f.map(e=>e.id),...o?Dr(o):[]]);return{specs:f,fields:p,read:VF(e,t,{shown:p,opens:s,bulk:c})}},UF=e=>e.props,WF=e=>t=>{let n=new Map(t.map(e=>[e.id,{title:e.title,badge:e.kind===`status`}])),r=(e??t.map(e=>e.id)).filter(e=>n.has(Vm(e))),i=new Set(Gm(r,e=>n.get(e)));return t.filter(e=>i.has(e.id))},GF=(e,t)=>e.orderBy||t||void 0,KF=(e,t)=>e&&t?[...new Set([...e,...t])].sort():void 0,qF={Table:(e,t,n)=>{let{resource:r,columns:i,button:a,bulk:o=!1}=UF(e),s=r===void 0?void 0:n.resources[r];if(!s)return;let c=n.views[s.name],{fields:l,read:u}=HF({...n,model:s,view:c,columns:i?.map(Vm),button:a,bulk:o,phoneColumns:WF(i)}),d=Yk(c);return{read:{...t,orderBy:GF(t,OT(s,c)),fields:KF(t.fields,u)},extras:{labels:xN(n.resources,n.views,s,l),...d&&{photos:d}},then:e=>DN(n.queryClient,n.client,n.resources,n.views,s,l,e.rows)}},RecordCards:(e,t,n)=>{let r=n.resources[UF(e).resource];if(r)return{read:{...t,orderBy:GF(t,OT(r,n.views[r.name])),fields:void 0},extras:{}}},Thread:(e,t,n)=>{if(t.part===`calls`)return{read:t,extras:{}};let{resource:r,sender:i}=UF(e),a=n.resources[r];if(a)return{read:t,extras:{labels:xN(n.resources,n.views,a,i===void 0?[]:[i])}}}},JF=(e,t,n)=>{if(t.split&&!e.custom){if(t.part===`total`)return{read:t,extras:{}};if(t.part===void 0||t.part===`calls`)return qF[e.type]?.(e,t,n)}},YF=new Set([`RecordCard`,`CardRow`,`Stat`,`ReferenceManyField`,`ReferenceArrayField`,`ReferenceField`]),XF=(e,t)=>{let n=qm(e,t.block);return n?.custom?n.reads!==void 0&&t.part!==`chosen`:t.part===void 0&&n!==void 0&&YF.has(n.type)},ZF=(e,t,n)=>(n?.reads??[]).flatMap(r=>{let i=qm(t,r.block),a=i&&JF(i,r,e);if(!a&&!XF(t,r))return[];let o=mh(a?.read??r,{params:e.params,...e.root&&{root:e.root}}),s=a?.extras??{},c=async()=>{let t=await _N(e.client,o,s);return await a?.then?.(t),t};return[{read:o,queryKey:[...I.planRead(hh(r,n),o),s],queryFn:c}]}),QF=(e,t)=>!e||!t?t:e.isPending===t.isPending&&e.error===t.error&&e.total===t.total&&e.labels===t.labels&&e.photos===t.photos&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>e===t.rows[n])?e:t,$F=(0,M.createContext)(new Map),eI=({tree:e,plan:t,children:n})=>{let r=X(),i=x(),{resources:a,views:o}=Tv(),s=tT().fields,c=uy(),l=pN(),u=iN(rN()),d=(0,M.useMemo)(()=>ZF({client:r,queryClient:i,resources:a,views:o,fieldTypes:s,xs:c,params:l,...u&&{root:u}},e,t),[r,i,a,o,s,c,l,u,e,t]),f=ee({queries:d.map(({queryKey:e,queryFn:t})=>({queryKey:e,queryFn:t}))}),p=new Map(d.map(({read:e},t)=>[Bm(e),{read:e,query:f[t]}]));return(0,L.jsx)($F.Provider,{value:p,children:n})},tI=(e,t,n,r)=>{let i=r===void 0?void 0:e.get(r);if(!i)return;let{read:a,query:o}=i,s=t.at(-1);if(a.split&&!(s&&`model`in s&&s.planned))return;let c=o.data?gh(a,o.data.rows,{...aN(t),params:n}):[],{total:l,labels:u,photos:d}=o.data??{};return{isPending:o.isPending,error:o.error,rows:c,...l!==void 0&&{total:l},...u&&{labels:u},...d&&{photos:d}}},nI=e=>rI([e])[0],rI=e=>{let t=(0,M.useContext)($F),n=rN(),r=pN(),i=(0,M.useRef)([]),a=e.map((e,a)=>QF(i.current[a],tI(t,n,r,e)));return i.current=a,a},iI=(0,M.createContext)(void 0),aI=({node:e,at:t,children:n})=>{let r=(0,M.useMemo)(()=>({node:e,...t!==void 0&&{at:t}}),[e,t]);return(0,L.jsx)(iI.Provider,{value:r,children:n})},oI=(e,t)=>t===void 0?void 0:e.props[t],sI=e=>{let t=(0,M.useContext)(iI);if(!t)throw Error(`${e} is for a custom component in a layout`);return t},cI=()=>{let{node:e,at:t}=sI(`useComponentReads`),n=rN(),r=pN();return lI((0,M.useMemo)(()=>ah(e,{...aN(n),params:r}),[e,n,r]),t)},lI=(e,t)=>{let{resources:n,views:r}=Tv(),i=X(),a=Km(e).flatMap(({reads:t,part:r})=>{let i=n[String(oI(e,t.resource))];return i?[{reads:t,part:r,model:i}]:[]}),o=rI(t===void 0?[]:a.map(({part:e})=>Bm({block:t,part:e}))),s=ee({queries:a.map(({reads:t,model:n},r)=>{let a=Pm(oI(e,t.filter))??``,s=Nm(oI(e,t.sort))??``,c=oI(e,t.limit),l=typeof c==`number`?c:500;return{enabled:o[r]===void 0,queryKey:I.list(n.name,a,s,l,``),queryFn:()=>i.list(n.name,{filter:a||void 0,orderBy:s||void 0,pageSize:l})}})});return Object.fromEntries(a.map(({reads:e,model:t},n)=>{let i=o[n],a=s[n],c=i??{isPending:a.isPending,error:a.error,rows:a.data?.items??[]};return[e.resource,{model:t,view:r[t.name],rows:c.rows,isPending:c.isPending,error:c.error}]}))},uI=()=>{let{node:e}=sI(`useComponentSelect`),t=gN(),n=Op(e)?.param;if(n!==void 0&&t)return{chosen:t.given[n],linkTo:e=>t.linkTo({[n]:e})}},dI=({model:e,view:t,field:n,record:r})=>{let i=e.fields[n],a=r[n];if(!i||a==null)return null;let o=t?.fields[n];return(0,L.jsxs)(NP,{value:a,hints:o,children:[(0,L.jsxs)(`span`,{className:`sr-only`,children:[o?.label??n,`: `]}),Rk(i,a,o)]})},fI=(e,t)=>{let n=Ok(e,t);return n===void 0?{className:Jv[kk(e,t)]}:{style:{backgroundColor:n}}},pI=({view:e,field:t,record:n})=>{let r=fI(e?.fields[t]?.valueColors,n[t]);return(0,L.jsx)(`span`,{"aria-hidden":!0,"data-tone-edge":!0,style:r.style,className:R(`absolute -inset-y-px -left-px w-1 rounded-l-lg`,r.className)})},mI=(0,M.createContext)(void 0),hI=({value:e,children:t})=>(0,L.jsx)(mI.Provider,{value:e,children:t}),gI=()=>{let e=(0,M.useContext)(mI);if(!e)throw Error(`useListDisplay is used inside a list display, which the list page draws`);return e},_I=()=>(0,M.useContext)(mI),vI=({row:e,resource:t,recordKey:n,...r})=>{let i=_I(),a=nN(),o=t??i?.resource??a?.model.name;if(o===void 0)throw Error(`RecordLink needs a resource outside a list display or a record`);return(0,L.jsx)(FA,{to:{kind:`record`,resource:o,key:e?e.key:n},...r})},$=F(`calls`),yI=(e,t)=>{e.srcObject=new MediaStream([t]);let n=()=>{t.readyState===`live`&&e.play().catch(e=>{if(!(e instanceof DOMException&&(e.name===`AbortError`||e.name===`NotAllowedError`)))throw e})};return e.addEventListener(`pause`,n),()=>e.removeEventListener(`pause`,n)},bI=({track:e,...t})=>{let n=(0,M.useCallback)(t=>t?yI(t,e):void 0,[e]);return(0,L.jsx)(`video`,{ref:n,autoPlay:!0,playsInline:!0,muted:!0,...t})},xI=({track:e})=>{let t=(0,M.useCallback)(t=>t?yI(t,e):void 0,[e]);return(0,L.jsx)(`audio`,{ref:t,autoPlay:!0})},SI=e=>R(`size-10 rounded-full`,!e&&`bg-danger-soft text-danger-text`),CI=({name:e,member:t,camera:n,microphoneOn:r,cameraOn:i,microphone:a,cameraAvailable:o,notices:s,onMicrophone:c,onCamera:l,onJoin:u,cancel:d,joinLabel:f=$(`joinCall`)})=>(0,L.jsxs)(`section`,{"aria-label":$(`preview`),className:`flex size-full min-h-0 flex-col items-center justify-center gap-3 bg-background p-4`,children:[(0,L.jsx)(`figure`,{className:`relative flex aspect-video w-full max-w-md items-center justify-center overflow-hidden rounded-lg bg-neutral-900`,children:n&&i?(0,L.jsx)(bI,{track:n,"aria-label":$(`preview`),className:`size-full -scale-x-100 object-cover`}):(0,L.jsx)(sb,{initials:ub(e),hue:lb(t),size:`md`,className:`size-16 text-xl ring-0`})}),s.length>0&&(0,L.jsx)(`div`,{role:`status`,className:`flex w-full max-w-md flex-col gap-1`,children:s.map(e=>(0,L.jsx)(`p`,{className:`rounded-md bg-warning-soft px-3 py-1.5 text-xs text-foreground`,children:e},e))}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(B,{size:`icon`,"aria-label":$(`microphone`),"aria-pressed":r,disabled:!a,className:SI(r),onClick:c,children:r?(0,L.jsx)(Sc,{className:`size-4`}):(0,L.jsx)(bc,{className:`size-4`})}),(0,L.jsx)(B,{size:`icon`,"aria-label":$(`camera`),"aria-pressed":i,disabled:!o,className:SI(i),onClick:l,children:i?(0,L.jsx)(eu,{className:`size-4`}):(0,L.jsx)(Ql,{className:`size-4`})}),(0,L.jsx)(B,{variant:`primary`,className:`h-10 rounded-full px-5`,onClick:u,children:f}),(0,L.jsx)(Du,{to:d,className:`px-2 text-sm text-muted-foreground hover:text-foreground`,children:$(`leave`)})]})]}),wI=()=>{let[e,t]=(0,M.useState)(!1);return{run:(0,M.useCallback)(e=>{t(!1),(async()=>{let{GuestRefused:n}=await s(async()=>{let{GuestRefused:e}=await import(`./calls-CLQwaemL.js`);return{GuestRefused:e}},[]);await e().catch(e=>{if(!(e instanceof n))throw e;t(!0)})})()},[]),refused:e}},TI={all:[`camera`,`microphone`,`screen`,`screen-audio`],camera:[`camera`,`microphone`],microphone:[`microphone`]},EI={call:void 0,hour:36e5},DI=({name:e,children:t})=>(0,L.jsxs)(`li`,{className:`flex items-center justify-between gap-2 py-1.5`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate text-sm text-foreground`,children:e}),(0,L.jsx)(`span`,{className:`flex shrink-0 gap-1.5`,children:t})]}),OI=({lobby:e,inCall:t,guests:n,linkOf:r,open:i,onClose:a})=>{let[o,s]=(0,M.useState)(`camera`),[c,l]=(0,M.useState)(`call`),[u,d]=(0,M.useState)(),[f,p]=(0,M.useState)(!1),{run:m,refused:h}=wI(),g=()=>m(async()=>{let e=EI[c],{link:t,token:i}=await n.link({publish:TI[o],...e!==void 0&&{expiresAt:new Date(Date.now()+e)}});d({id:t.id,url:r(i)})}),_=e=>void navigator.clipboard.writeText(e).then(()=>{p(!0),setTimeout(()=>p(!1),2e3)});return(0,L.jsx)(ZE,{title:$(`guests`),description:$(`addressesVisible`),open:i,onClose:a,actions:(0,L.jsx)(B,{onClick:a,children:$(`close`)}),children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h&&(0,L.jsx)(`p`,{role:`alert`,className:`rounded-md bg-warning-soft px-3 py-1.5 text-xs text-foreground`,children:$(`guestRefused`)}),e.guests.length>0&&(0,L.jsxs)(`section`,{"aria-label":$(`inLobby`),children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:$(`inLobby`)}),(0,L.jsx)(`ul`,{children:e.guests.map(({guest:e,name:t})=>(0,L.jsxs)(DI,{name:t,children:[(0,L.jsx)(B,{size:`sm`,variant:`primary`,onClick:()=>m(()=>n.admit(e)),children:$(`admit`)}),(0,L.jsx)(B,{size:`sm`,onClick:()=>m(()=>n.deny(e)),children:$(`deny`)})]},e))})]}),t.length>0&&(0,L.jsxs)(`section`,{"aria-label":$(`guestsInCall`),children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:$(`guestsInCall`)}),(0,L.jsx)(`ul`,{children:t.map(({guest:e,name:t})=>(0,L.jsx)(DI,{name:t,children:(0,L.jsx)(B,{size:`sm`,variant:`danger`,onClick:()=>m(()=>n.remove(e)),children:$(`remove`)})},e))})]}),(0,L.jsxs)(`section`,{"aria-label":$(`guestLinks`),className:`flex flex-col gap-2`,children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:$(`guestLinks`)}),e.links.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:$(`noLinks`)}),(0,L.jsx)(`ul`,{children:e.links.map(e=>(0,L.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-1.5`,children:[u?.id===e.id&&(0,L.jsx)(Eb,{readOnly:!0,value:u.url,"aria-label":$(`copyLink`),onFocus:e=>e.currentTarget.select(),trailing:(0,L.jsx)(`button`,{type:`button`,"aria-label":$(f?`copied`:`copyLink`),onClick:()=>_(u.url),className:`inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted pointer-coarse:size-11`,children:f?(0,L.jsx)(Xo,{className:`size-4 text-success`}):(0,L.jsx)(gs,{className:`size-4`})})}),(0,L.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:[e.expires_at?$(`linkUntil`,{until:new Date(e.expires_at).toLocaleString()}):$(`linkUntilEnd`),(0,L.jsx)(B,{size:`sm`,onClick:()=>m(()=>n.revoke(e.id)),children:$(`revoke`)})]})]},e.id))}),(0,L.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[$(`guestsMaySend`),(0,L.jsx)(Gb,{label:$(`guestsMaySend`),value:o,onChange:s,options:[{value:`all`,label:$(`sendAll`)},{value:`camera`,label:$(`sendCamera`)},{value:`microphone`,label:$(`sendMicrophone`)}]})]}),(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[$(`linkLasts`),(0,L.jsx)(Gb,{label:$(`linkLasts`),value:c,onChange:l,options:[{value:`call`,label:$(`linkUntilEnd`)},{value:`hour`,label:$(`forAnHour`)}]})]}),(0,L.jsx)(B,{variant:`primary`,onClick:g,children:$(`newLink`)})]})]})]})})},kI=({waiting:e,guests:t})=>{let{run:n,refused:r}=wI(),i=e[0];return i?(0,L.jsxs)(`div`,{role:`status`,className:`flex shrink-0 flex-wrap items-center gap-2 rounded-md bg-primary-soft px-3 py-1.5 text-xs text-foreground`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r?$(`guestRefused`):$(`waitingGuest`,{name:i.name})}),(0,L.jsx)(B,{size:`sm`,variant:`primary`,onClick:()=>n(()=>t.admit(i.guest)),children:$(`admit`)}),(0,L.jsx)(B,{size:`sm`,onClick:()=>n(()=>t.deny(i.guest)),children:$(`deny`)})]}):null},AI={ended:`ended`,removed:`removed`,full:`full`,refused:`refused`,unavailable:`unavailable`,denied:`denied`},jI=({reason:e,onJoinAgain:t})=>(0,L.jsxs)(`section`,{role:`status`,className:`flex size-full min-h-0 flex-col items-center justify-center gap-3 bg-background p-4 text-center`,children:[(0,L.jsx)(`p`,{className:`text-sm text-foreground`,children:$(e===`rejoin`?`ended`:AI[e])}),t&&e!==`removed`&&e!==`refused`&&e!==`denied`&&(0,L.jsx)(B,{onClick:t,children:$(`callAgain`)})]}),MI=(e,t)=>t<640?e<=2?1:2:Math.min(4,Math.ceil(Math.sqrt(e))),NI=({people:e,sharers:t,width:n})=>t[0]===void 0?e<=1?{kind:`alone`}:{kind:`grid`,columns:MI(e,n)}:{kind:`share`,sharer:t[0]},PI=({roundTripMs:e,lostRatio:t})=>(e??0)>400||(t??0)>.05?`poor`:`good`,FI=(e,t,n)=>e===`failed`||e!==`connected`&&n-t>=15e3,II=(e,t=.05)=>{let n;for(let[r,i]of e)i>=t&&(!n||i>n[1])&&(n=[r,i]);return n?.[0]},LI=(e,t)=>e.find(e=>e.source===t&&e.track),RI=({members:e,self:t,tracks:n,own:r,nameOf:i,speaker:a,connections:o,seen:s,now:c})=>(e.some(e=>e.member===t)?e:[{member:t,joined_at:``},...e]).map(({member:e,name:l})=>{let u={member:e,name:e.startsWith(`guest:`)?$(`guestName`,{name:l??``}):l??i(e),...a===e&&{speaking:!0}};if(e===t)return{...u,self:!0,...r.camera&&{camera:r.camera},...r.microphone&&{microphone:r.microphone},...r.screen&&{screen:r.screen},microphoneOff:!r.microphone||!r.microphoneOn,cameraOff:!r.camera||!r.cameraOn};let d=n.filter(t=>t.member===e),[f,p,m,h]=[`camera`,`microphone`,`screen`,`screen-audio`].map(e=>LI(d,e)),g=o.find(t=>t.member===e),_=FI(g?.state,s.get(e)??c,c)?`failed`:g?.state===`connected`?PI(g):void 0;return{...u,...f&&{camera:f.track},...p&&{microphone:p.track},...m&&{screen:m.track},...h&&{screenAudio:h.track},microphoneOff:!p||p.muted,cameraOff:!f||f.muted,..._&&{connection:_}}}),zI=e=>R(`size-10 rounded-full`,!e&&`bg-danger-soft text-danger-text`),BI=({microphoneOn:e,cameraOn:t,sharing:n,onMicrophone:r,onCamera:i,onShare:a,guests:o,leave:s})=>(0,L.jsxs)(`div`,{role:`toolbar`,"aria-label":$(`joinCall`),className:`flex shrink-0 flex-wrap items-center justify-center gap-2 py-2`,children:[(0,L.jsx)(B,{size:`icon`,"aria-label":$(`microphone`),"aria-pressed":e,title:$(`microphone`),className:zI(e),onClick:r,children:e?(0,L.jsx)(Sc,{className:`size-4`}):(0,L.jsx)(bc,{className:`size-4`})}),(0,L.jsx)(B,{size:`icon`,"aria-label":$(`camera`),"aria-pressed":t,title:$(`camera`),className:zI(t),onClick:i,children:t?(0,L.jsx)(eu,{className:`size-4`}):(0,L.jsx)(Ql,{className:`size-4`})}),a&&(0,L.jsx)(B,{size:`icon`,"aria-label":$(n?`stopSharing`:`shareScreen`),"aria-pressed":!!n,title:$(n?`stopSharing`:`shareScreen`),className:`size-10 rounded-full`,onClick:a,children:n?(0,L.jsx)(Oc,{className:`size-4`}):(0,L.jsx)(Ec,{className:`size-4`})}),o&&(0,L.jsxs)(B,{size:`icon`,"aria-label":$(`guests`),title:$(`guests`),className:`relative size-10 rounded-full`,onClick:o.onOpen,children:[(0,L.jsx)(Wl,{className:`size-4`}),(0,L.jsx)(wx,{count:o.waiting,className:`absolute -top-1 -right-1`})]}),(0,L.jsxs)(Du,{to:s,className:R(hu({variant:`danger`}),`h-10 rounded-full px-4`),children:[(0,L.jsx)(Hc,{className:`size-4`}),$(`leave`)]})]}),VI=({person:e,screen:t=!1,className:n})=>{let r=t?e.screen:e.cameraOff?void 0:e.camera,i=t?e.self?$(`youAreSharing`):$(`sharing`,{name:e.name}):e.self?`${e.name} (${$(`you`)})`:e.name;return(0,L.jsxs)(`figure`,{"data-member":e.member,"data-speaking":e.speaking?`true`:void 0,"aria-label":i,className:R(`relative flex min-h-0 min-w-0 items-center justify-center overflow-hidden rounded-lg bg-neutral-900 ring-offset-2 ring-offset-background`,e.speaking&&!t&&`ring-2 ring-success`,n),children:[r?(0,L.jsx)(bI,{track:r,className:R(`size-full`,t?`object-contain`:`object-cover`,e.self&&!t&&`-scale-x-100`)}):(0,L.jsx)(sb,{initials:ub(e.name),hue:lb(e.member),size:`md`,className:`size-16 text-xl ring-0`}),e.connection===`failed`&&!e.self&&(0,L.jsx)(`p`,{role:`status`,className:`absolute inset-x-1 top-1 truncate rounded bg-black/70 px-2 py-1 text-center text-xs text-white`,children:$(`cannotConnect`,{name:e.name})}),(0,L.jsxs)(`figcaption`,{className:`absolute bottom-1.5 left-1.5 flex max-w-[calc(100%-0.75rem)] items-center gap-1 rounded bg-black/60 px-1.5 py-0.5 text-xs text-white`,children:[!t&&e.microphoneOff&&(0,L.jsx)(bc,{role:`img`,"aria-label":$(`muted`),className:`size-3 shrink-0`}),!t&&e.connection===`poor`&&(0,L.jsx)(ou,{role:`img`,"aria-label":$(`poorConnection`),className:`size-3 shrink-0 text-warning`}),(0,L.jsx)(`span`,{className:`truncate`,children:i})]})]})},HI=()=>{let[e,t]=(0,M.useState)(0);return{ref:(0,M.useCallback)(e=>{if(!e)return;t(e.clientWidth);let n=new ResizeObserver(([e])=>t(e.contentRect.width));return n.observe(e),()=>n.disconnect()},[]),width:e}},UI=4,WI=({people:e,columns:t})=>(0,L.jsx)(`div`,{className:`grid size-full min-h-0 gap-2`,style:{gridTemplateColumns:`repeat(${t}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${Math.ceil(e.length/t)}, minmax(0, 1fr))`},children:e.map(e=>(0,L.jsx)(VI,{person:e},e.member))}),GI=({people:e,sharer:t,narrow:n})=>{let r=e.slice(0,UI),i=e.length-r.length;return(0,L.jsxs)(`div`,{className:R(`flex size-full min-h-0 gap-2`,n?`flex-col`:`flex-row`),children:[(0,L.jsx)(VI,{person:t,screen:!0,className:`min-h-0 flex-1`}),(0,L.jsxs)(`div`,{className:R(`flex shrink-0 gap-2`,n?`h-20 flex-row`:`w-40 flex-col`),children:[r.map(e=>(0,L.jsx)(VI,{person:e,className:n?`aspect-video h-full`:`aspect-video w-full`},e.member)),i>0&&(0,L.jsxs)(`p`,{className:`flex items-center justify-center rounded-lg bg-muted px-2 text-xs text-muted-foreground`,children:[`+`,i]})]})]})},KI=({layout:e,people:t,narrow:n})=>e.kind===`share`?(0,L.jsx)(GI,{people:t,sharer:t.find(t=>t.member===e.sharer),narrow:n}):e.kind===`grid`?(0,L.jsx)(WI,{people:t,columns:e.columns}):(0,L.jsxs)(`div`,{className:`relative size-full min-h-0`,children:[(0,L.jsx)(VI,{person:t[0],className:`size-full`}),(0,L.jsx)(`p`,{className:`absolute inset-x-0 top-3 text-center text-sm text-white drop-shadow`,children:$(`alone`)})]}),qI=({people:e,state:t,notices:n=[],controls:r,aside:i,children:a,className:o})=>{let{ref:s,width:c}=HI(),l=c>0&&c<640,u=NI({people:e.length,sharers:e.filter(e=>e.screen).map(e=>e.member),width:c}),d=[...t===`resuming`?[$(`reconnecting`)]:[],...n];return(0,L.jsxs)(`section`,{ref:s,"aria-label":$(`joinCall`),"data-layout":u.kind,className:R(`flex size-full min-h-0 flex-col gap-2 bg-background p-2`,o),children:[d.length>0&&(0,L.jsx)(`div`,{role:`status`,className:`flex shrink-0 flex-col gap-1`,children:d.map(e=>(0,L.jsxs)(`p`,{className:`flex items-center gap-2 rounded-md bg-warning-soft px-3 py-1.5 text-xs text-foreground`,children:[e===$(`reconnecting`)&&(0,L.jsx)(fu,{className:`size-3`}),e]},e))}),i,(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:t===`joining`?(0,L.jsxs)(`p`,{role:`status`,className:`flex size-full items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{className:`size-4`}),$(`connecting`)]}):(0,L.jsx)(KI,{layout:u,people:e,narrow:l})}),(0,L.jsx)(BI,{...r}),e.filter(e=>!e.self).flatMap(e=>[[`microphone`,e.microphone],[`screen-audio`,e.screenAudio]].map(([t,n])=>n&&{key:`${e.member} ${t}`,track:n})).filter(e=>e!==void 0).map(({key:e,track:t})=>(0,L.jsx)(xI,{track:t},e)),a]})},JI=({leave:e})=>(0,L.jsxs)(`section`,{role:`status`,className:`flex size-full min-h-0 flex-col items-center justify-center gap-3 bg-background p-4 text-center`,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,L.jsx)(fu,{className:`size-4`}),$(`waiting`)]}),(0,L.jsx)(Du,{to:e,className:`px-2 text-sm text-muted-foreground hover:text-foreground`,children:$(`leave`)})]}),YI=200,XI=1e3,ZI=(e,t)=>{e.getFloatTimeDomainData(t);let n=0;for(let e of t)n+=e*e;return Math.min(1,Math.sqrt(n/t.length)*4)},QI=e=>{let[t,n]=(0,M.useState)(),r=[...e].map(([e,t])=>`${e}:${t.id}`).join(`,`);return(0,M.useEffect)(()=>{if(e.size===0||typeof AudioContext>`u`)return;let t=new AudioContext,r=new Map([...e].map(([e,n])=>{let r=t.createAnalyser();return r.fftSize=512,t.createMediaStreamSource(new MediaStream([n])).connect(r),[e,r]})),i=new Float32Array(512),a,o=setInterval(()=>{let e=II(new Map([...r].map(([e,t])=>[e,ZI(t,i)])));e&&(a={member:e,at:Date.now()}),n(a&&Date.now()-a.at<XI?a.member:void 0)},YI);return()=>{clearInterval(o),t.close()}},[r]),t},$I=new Set([`NotAllowedError`,`SecurityError`]),eL=new Set([`NotFoundError`,`NotReadableError`,`OverconstrainedError`]),tL=async(e,t)=>{try{return{track:(await e.getUserMedia({[t]:!0})).getTracks()[0],blocked:!1}}catch(e){if(!(e instanceof DOMException))throw e;if($I.has(e.name))return{blocked:!0};if(eL.has(e.name))return{blocked:!1};throw e}},nL=async(e=navigator.mediaDevices)=>{try{let t=await e.getUserMedia({audio:!0,video:!0});return{microphone:t.getAudioTracks()[0],camera:t.getVideoTracks()[0],blocked:{microphone:!1,camera:!1},none:!1}}catch(e){if(!(e instanceof DOMException)||!($I.has(e.name)||eL.has(e.name)))throw e}let[t,n]=[await tL(e,`audio`),await tL(e,`video`)];return{...t.track&&{microphone:t.track},...n.track&&{camera:n.track},blocked:{microphone:t.blocked,camera:n.blocked},none:!t.track&&!n.track&&!t.blocked&&!n.blocked}},rL=class extends Error{reason;constructor(e){super(`Not let into the call: ${e}`),this.reason=e,this.name=`NotLetIn`}},iL=1e3,aL=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>(clearTimeout(r),n()),{once:!0})}),oL=async(e,t,n,r)=>{let{LobbyRefused:i}=await s(async()=>{let{LobbyRefused:e}=await import(`./calls-CLQwaemL.js`);return{LobbyRefused:e}},[]),a=e=>e instanceof i?new rL(e.status===404?`refused`:e.status===429?`unavailable`:`ended`):e,{token:o}=await e.enter(t,n).catch(e=>Promise.reject(a(e)));for(;!r.aborted;){let t=await e.wait(o).catch(e=>Promise.reject(a(e)));if(t.state===`admitted`)return o;if(t.state===`denied`)throw new rL(`denied`);if(t.state===`ended`)throw new rL(`ended`);await aL(iL,r)}throw await e.leave(o),new rL(`ended`)},sL=2e3,cL=e=>{for(let t of e)t?.stop()},lL=(e,{admission:t}={})=>{let[n,r]=(0,M.useState)({kind:`check`}),[i,a]=(0,M.useState)(),o=(0,M.useRef)(new AbortController),[c,l]=(0,M.useState)(),[u,d]=(0,M.useState)(!0),[f,p]=(0,M.useState)(!0),[m,h]=(0,M.useState)([]),[g,_]=(0,M.useState)([]),[v,y]=(0,M.useState)([]),[b,x]=(0,M.useState)(),[S,C]=(0,M.useState)(!1),w=(0,M.useRef)(void 0),T=(0,M.useRef)(!1),E=(0,M.useRef)([]),D=(0,M.useRef)(new Map),O=(0,M.useRef)(Promise.resolve(void 0));(0,M.useEffect)(()=>{let e=!1;return T.current=!1,O.current=nL().then(t=>{if(e){cL([t.microphone,t.camera]);return}return E.current.push(t.microphone,t.camera),l(t),t}),()=>{e=!0,T.current=!0,o.current.abort(),w.current?.leave(),w.current=void 0,cL(E.current),E.current=[]}},[]),(0,M.useEffect)(()=>{for(let{member:e}of g)D.current.has(e)||D.current.set(e,Date.now())},[g]),(0,M.useEffect)(()=>{if(n.kind!==`in`)return;let e=setInterval(()=>void w.current?.connections().then(y),sL);return()=>clearInterval(e)},[n.kind]);let k=async()=>{if(!t)return{};r({kind:`waiting`}),o.current=new AbortController;let e=await t(o.current.signal).then(e=>e,e=>{if(!(e instanceof rL))throw e;r({kind:`left`,reason:e.reason})});return e===void 0?void 0:{guest:e}},A=(0,M.useCallback)(async()=>{let t=await k();if(!t||T.current)return;r({kind:`joining`});let{joinCall:n,PublishRefused:i}=await s(async()=>{let{joinCall:e,PublishRefused:t}=await import(`./calls-CLQwaemL.js`);return{joinCall:e,PublishRefused:t}},[]),o=await n({url:e,...t,onLobby:a,onTracks:h,onMembers:_,onState:e=>{(e.state===`joined`||e.state===`resuming`)&&r({kind:`in`,resuming:e.state===`resuming`}),e.state===`left`&&r({kind:`left`,reason:e.reason})}}).then(e=>e,()=>void 0);if(!o)return;if(T.current)return o.leave();w.current=o;let c=await O.current,l={...c?.microphone&&{microphone:c.microphone},...c?.camera&&{camera:c.camera}};await o.publish(l).then(()=>{l.microphone&&o.mute(`microphone`,!u),l.camera&&o.mute(`camera`,!f)},e=>{if(!(e instanceof i))throw e;C(!0)})},[e,t,u,f]),ee=(0,M.useCallback)(()=>{let e=!u;d(e),c?.microphone&&(c.microphone.enabled=e),w.current?.mute(`microphone`,!e)},[u,c]),te=(0,M.useCallback)(()=>{let e=!f;p(e),c?.camera&&(c.camera.enabled=e),w.current?.mute(`camera`,!e)},[f,c]),ne=(0,M.useCallback)(async e=>{x(void 0),cL([e.video,e.audio]),await w.current?.unpublish(`screen`),e.audio&&await w.current?.unpublish(`screen-audio`)},[]),re=(0,M.useCallback)(async()=>{if(b)return ne(b);let e;try{e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0})}catch(e){if(e instanceof DOMException&&e.name===`NotAllowedError`)return;throw e}let t={video:e.getVideoTracks()[0],...e.getAudioTracks()[0]&&{audio:e.getAudioTracks()[0]}};E.current.push(t.video,t.audio),t.video.addEventListener(`ended`,()=>void ne(t)),await w.current?.publish({screen:t.video,...t.audio&&{"screen-audio":t.audio}}),x(t)},[b,ne]),ie=typeof navigator<`u`&&typeof navigator.mediaDevices?.getDisplayMedia==`function`;return{phase:n,devices:c,microphoneOn:u,cameraOn:f,tracks:m,members:g,connections:v,screen:b,refusedSending:S,seen:D.current,self:w.current?.participant,lobby:i,guests:w.current?.guests,join:A,toggleMicrophone:ee,toggleCamera:te,...ie&&{toggleScreen:re}}},uL=(e,t)=>[...e?.blocked.microphone?[$(`noMicrophone`)]:[],...e?.blocked.camera?[$(`noCamera`)]:[],...e?.none?[$(`noDevices`)]:[],...t?[$(`refused`)]:[]],dL=({url:e,leave:t,nameOf:n=e=>e,admission:r,name:i,className:a})=>{let o=lL(e,{...r&&{admission:r}}),[s,c]=(0,M.useState)(!1),{basePath:l}=Hu(),u=l_(),d=u?.state.kind===`signed-in`?u.state.user:void 0,f=o.self??d?.id??``,[p]=(0,M.useState)(()=>Date.now()),{devices:m,phase:h}=o,g={...m?.microphone&&{microphone:m.microphone},...m?.camera&&{camera:m.camera},...o.screen&&{screen:o.screen.video},microphoneOn:o.microphoneOn,cameraOn:o.cameraOn},_=new Map([...m?.microphone&&o.microphoneOn?[[f,m.microphone]]:[],...o.tracks.filter(e=>e.source===`microphone`&&e.track&&!e.muted).map(e=>[e.member,e.track])]),v=QI(h.kind===`in`?_:new Map),y=uL(m,o.refusedSending);if(h.kind===`left`)return(0,L.jsx)(jI,{reason:h.reason,onJoinAgain:()=>void o.join()});if(h.kind===`waiting`)return(0,L.jsx)(JI,{leave:t});if(h.kind===`check`)return(0,L.jsx)(CI,{name:i??d?.name??$(`you`),...r&&{joinLabel:$(`askToJoin`)},member:f,...m?.camera&&{camera:m.camera},microphoneOn:o.microphoneOn,cameraOn:o.cameraOn,microphone:!!m?.microphone,cameraAvailable:!!m?.camera,notices:y,onMicrophone:o.toggleMicrophone,onCamera:o.toggleCamera,onJoin:()=>void o.join(),cancel:t});let{lobby:b,guests:x}=o,S=o.members.filter(e=>e.member.startsWith(`guest:`)).map(e=>({guest:e.member.slice(6),name:e.name??``})),C=RI({members:o.members,self:f,tracks:o.tracks,own:g,nameOf:n,...v&&{speaker:v},connections:o.connections,seen:o.seen,now:Math.max(p,Date.now())});return(0,L.jsx)(qI,{...a&&{className:a},people:C,state:h.kind===`joining`?`joining`:h.resuming?`resuming`:`joined`,notices:y,...b&&x&&{aside:(0,L.jsx)(kI,{waiting:b.guests,guests:x})},controls:{microphoneOn:o.microphoneOn&&!!m?.microphone,cameraOn:o.cameraOn&&!!m?.camera,sharing:!!o.screen,onMicrophone:o.toggleMicrophone,onCamera:o.toggleCamera,...o.toggleScreen&&{onShare:()=>void o.toggleScreen()},...b&&{guests:{waiting:b.guests.length,onOpen:()=>c(!0)}},leave:t},children:b&&x&&(0,L.jsx)(OI,{lobby:b,inCall:S,guests:x,linkOf:e=>gw(`${window.location.origin}${l}`,e),open:s,onClose:()=>c(!1)})})},fL=(e,t)=>{let{address:n,href:r,open:i}=PA(),a=n?.kind===`record`&&n.resource===e&&n.key===t&&n.call===`join`,o=e=>({href:e,onFollow:()=>i(e)});return{joining:a,join:o(r({kind:`record`,resource:e,key:t,call:`join`})),leave:o(r({kind:`record`,resource:e,key:t}))}},pL=({resource:e,recordKey:t,...n})=>{let{joining:r,leave:i}=fL(e,t);return r?(0,L.jsx)(dL,{leave:i,...n},`${e}/${t}`):null},mL=(e,t)=>{let n=X(),r=x(),i=I.recordCalls(e,t),a=O({queryKey:i,queryFn:()=>n.calls(e,t)});return(0,M.useEffect)(()=>{let i=I.recordCalls(e,t),a=n.channel(e,t),o=a.on(Di,e=>e.server&&r.setQueryData(i,e.payload.items)),s=a.onStatus(e=>e.state===`joined`&&void r.invalidateQueries({queryKey:i}));return()=>{o(),s(),a.leave()}},[n,r,e,t]),{...a,ongoing:a.data?.find(e=>e.ended_at===null)}},hL=({resource:e,recordKey:t,className:n})=>{let{ongoing:r,isPending:i}=mL(e,t),{joining:a,join:o}=fL(e,t);if(i)return null;if(!r)return a?null:(0,L.jsxs)(Du,{to:o,className:R(hu({size:`sm`}),n),children:[(0,L.jsx)(Wc,{className:`size-3.5`}),$(`startCall`)]});let s=r.members.length;return(0,L.jsxs)(`span`,{role:`status`,className:R(`inline-flex items-center gap-1.5 rounded-md bg-success-soft px-2 py-0.5 text-body text-foreground`,n),children:[(0,L.jsx)(Wc,{className:`size-3.5 text-success`}),$(`inProgress`),(0,L.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,L.jsx)(`span`,{"aria-label":$(`people`,{count:s}),children:s}),!a&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,L.jsx)(Du,{to:o,className:hu({variant:`primary`,size:`sm`}),children:$(`join`)})]})]})},gL={wallet:nu,"file-text":Hs,send:ml,ruler:cl,bed:Mo,bath:Ao,house:Js,"door-open":Ss,"land-plot":Qs,leaf:nc,tag:Pl,key:Xs,calendar:Ko,heart:Ks,history:il,bell:Ro,bookmark:Ho,"external-link":Ms,ban:Oo,play:Kc,stop:El,power:Qc,restart:ol,terminal:Rl,camera:Jo,"hard-drive":Ws,server:gl,network:Pc,archive:bo,copy:gs,"arrow-right-left":wo,download:ws,upload:Hl,cpu:vs,memory:gc,plug:Jc,wrench:cu,plus:Xc,table:Ml},_L=e=>e!==void 0&&Object.hasOwn(gL,e)?gL[e]:void 0,vL=({benefits:e})=>e&&e.length>0?(0,L.jsx)(`ul`,{className:`flex flex-col gap-2 text-left`,children:e.map(e=>(0,L.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(Xo,{className:`mt-0.5 size-4 shrink-0 text-primary`,"aria-hidden":!0}),e]},e))}):null,yL=({prompt:e})=>{let{canSignUp:t}=J(),{link:n}=SC(),r=hu({variant:`primary`}),i=e.signUp?(0,L.jsx)(`a`,{href:e.signUp.href,target:`_blank`,rel:`noreferrer`,className:r,children:e.signUp.label}):t&&(0,L.jsx)(Du,{to:n(`sign-up`),className:r,children:Z(`createAnAccount`)});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Du,{to:n(),className:i?hu():r,children:Z(`signIn`)}),i]})},bL=e=>{let{prompt:t}=e,n=(0,M.useId)();if(e.as===`dialog`)return(0,L.jsx)(ZE,{title:t.title,description:t.description,open:e.open,onClose:e.onClose,actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:e.onClose,children:Z(`notNow`)}),(0,L.jsx)(yL,{prompt:t})]}),children:(0,L.jsx)(vL,{benefits:t.benefits})});let r=_L(t.icon)??uc;return(0,L.jsxs)(`section`,{"aria-labelledby":n,className:`mx-auto flex w-full max-w-md flex-col items-center gap-4 px-5 py-10 text-center sm:py-16`,children:[(0,L.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,L.jsx)(r,{className:`size-6`,"aria-hidden":!0})}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`h1`,{id:n,className:`text-lg font-semibold`,children:t.title}),(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:t.description})]}),(0,L.jsx)(vL,{benefits:t.benefits}),(0,L.jsx)(`div`,{className:`mt-2 flex w-full flex-col-reverse gap-2 sm:w-auto sm:flex-row sm:justify-center [&>*]:min-h-11 sm:[&>*]:min-h-0`,children:(0,L.jsx)(yL,{prompt:t})})]})},xL=F(`chat`),SL=e=>new Date(Date.parse(`${e}T00:00:00Z`)-864e5).toISOString().slice(0,10),CL=(e,t,n=QT())=>iE(Date.parse(e),n)===iE(Date.parse(t),n),wL=(e,t=Date.now(),n=QT())=>{let r=iE(Date.parse(e),n),i=iE(t,n);return r===i?xL(`today`):r===SL(i)?xL(`yesterday`):CE(Date.parse(`${r}T00:00:00Z`))},TL=({tone:e=`day`,label:t})=>{let n=t??xL(`newMessages`),r=R(`h-px flex-1`,e===`new`?`bg-danger`:`bg-border`);return(0,L.jsxs)(`div`,{role:`separator`,"aria-label":n,"data-tone":e,"data-chat-divider":``,className:`flex items-center gap-3 text-xs font-medium`,children:[(0,L.jsx)(`span`,{className:r}),(0,L.jsx)(`span`,{className:e===`new`?`text-danger`:`text-muted-foreground`,children:n}),(0,L.jsx)(`span`,{className:r})]})},EL=({children:e,className:t})=>(0,L.jsx)(`p`,{className:R(`text-xs text-muted-foreground`,t),children:e}),DL=({time:e})=>{let t=Date.parse(e);return(0,L.jsx)(`time`,{dateTime:e,title:vE(t),className:`text-xs text-muted-foreground`,children:TE(t)})},OL=e=>{let{children:t,footer:n}=e;if(e.author){let{author:r,time:i,avatar:a,continued:o}=e,s=r.name??r.id;return(0,L.jsxs)(`div`,{"data-from":`person`,className:R(`flex min-w-0 gap-3`,o&&`-mt-3`),children:[(0,L.jsx)(`div`,{className:`w-8 shrink-0`,children:!o&&(a??(0,L.jsx)(sb,{initials:ub(s)||`?`,hue:lb(r.id),size:`md`,className:`ring-0`}))}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[!o&&(0,L.jsxs)(`p`,{className:`flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:s}),i&&(0,L.jsx)(DL,{time:i})]}),(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 whitespace-pre-wrap break-words text-foreground`,children:t}),n&&(0,L.jsx)(EL,{children:n})]})]})}if(e.alone){let{time:r,continued:i}=e;return(0,L.jsxs)(`div`,{"data-from":`person`,className:R(`flex min-w-0 flex-col gap-0.5`,i&&`-mt-3`),children:[!i&&r&&(0,L.jsx)(DL,{time:r}),(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 whitespace-pre-wrap break-words text-foreground`,children:t}),n&&(0,L.jsx)(EL,{children:n})]})}let r=(0,L.jsx)(`div`,{"data-from":e.from,className:R(`flex min-w-0 flex-col gap-2 whitespace-pre-wrap break-words`,e.from===`user`?`ml-8 self-end rounded-lg rounded-br-sm bg-primary px-3 py-2 text-primary-foreground shadow-sm`:`mr-4 text-foreground`),children:t});return n?(0,L.jsxs)(`div`,{className:R(`flex min-w-0 flex-col gap-1`,e.from===`user`&&`items-end`),children:[r,(0,L.jsx)(EL,{className:e.from===`user`?`text-right`:void 0,children:n})]}):r},kL=({working:e})=>(0,L.jsx)(`div`,{role:`status`,className:`shrink-0 pl-11`,children:e&&(0,L.jsxs)(`p`,{"data-chat-working":!0,className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`flex gap-1`,children:[0,200,400].map(e=>(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground [animation:pb-shimmer_1.2s_ease-in-out_infinite]`,style:{animationDelay:`${e}ms`}},e))}),xL(`working`)]})}),AL=e=>e.scrollHeight-e.scrollTop-e.clientHeight<=24,jL=(e,t)=>{if(t.followKey!==e.followKey)return t.scrollHeight;if(e.first===void 0&&t.first!==void 0&&t.newLineTop!==void 0)return Math.max(0,t.scrollTop+t.newLineTop-16);if(e.first!==void 0&&t.first!==e.first&&e.anchor&&t.anchorTop!==void 0)return t.scrollTop+t.anchorTop-e.anchor.top;if(e.atEnd)return t.scrollHeight},ML=(e,t,n)=>{let r=e.getBoundingClientRect().top,i=Array.from(t.children).find(e=>!e.hasAttribute(`data-chat-divider`)&&e.getBoundingClientRect().bottom>r),a=i&&{anchor:{element:i,top:i.getBoundingClientRect().top-r}};return{atEnd:AL(e),first:t.firstElementChild??void 0,followKey:n,...a}},NL=(e,t)=>{let n=(0,M.useRef)({onReadToEnd:e,atEnd:t});(0,M.useLayoutEffect)(()=>{n.current={onReadToEnd:e,atEnd:t}});let r=(0,M.useCallback)(()=>{document.visibilityState===`visible`&&n.current.onReadToEnd?.()},[]);return(0,M.useEffect)(()=>{let e=()=>{n.current.atEnd()&&r()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[r]),r},PL=e=>e.querySelector(`[data-chat-divider][data-tone="new"]`),FL=({children:e,empty:t,length:n,onLoadEarlier:r,loadingEarlier:i,followKey:a,onReadToEnd:o,working:s})=>{let c=(0,M.useRef)(null),l=(0,M.useRef)(null),u=(0,M.useRef)({atEnd:!0,first:void 0,followKey:a}),d=()=>{c.current&&l.current&&(u.current=ML(c.current,l.current,a))},f=()=>u.current.atEnd&&u.current.first!==void 0,p=NL(o,f),m=()=>{let e=u.current.atEnd;d(),!e&&f()&&p()};(0,M.useLayoutEffect)(()=>{let e=c.current;if(!e||!l.current)return;let t=u.current,n=t.anchor&&t.anchor.element.isConnected?t.anchor.element.getBoundingClientRect().top-e.getBoundingClientRect().top:void 0,r=PL(l.current),i=r?r.getBoundingClientRect().top-e.getBoundingClientRect().top:void 0,o=jL(t,{first:l.current.firstElementChild??void 0,anchorTop:n,scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,followKey:a,newLineTop:i});o!==void 0&&(e.scrollTop=o),d(),f()&&p()},[n,a,s]),(0,M.useEffect)(()=>{let e=c.current;if(!e||!l.current)return;let t=new ResizeObserver(()=>{u.current.atEnd&&(e.scrollTop=e.scrollHeight)});return t.observe(e),t.observe(l.current),()=>t.disconnect()},[]);let h=n===0&&!!t;return(0,L.jsxs)(`div`,{ref:c,onScroll:m,className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4 [overflow-anchor:none]`,children:[r&&(0,L.jsx)(B,{size:`sm`,className:`self-center`,loading:i,onClick:r,children:xL(`loadEarlier`)}),h&&(0,L.jsx)(`div`,{className:`m-auto max-w-60 text-center text-muted-foreground`,children:t}),(0,L.jsx)(`div`,{ref:l,role:`log`,"aria-live":`polite`,className:R(`flex flex-col gap-4`,h&&`hidden`),children:e}),s!==void 0&&(0,L.jsx)(kL,{working:s})]})},IL=(e,t,n)=>{if(n!==0){if(e===`Home`)return 0;if(e===`End`)return n-1;if(e===`ArrowDown`)return t<0?0:(t+1)%n;if(e===`ArrowUp`)return t<0?n-1:(t-1+n)%n}},LL=(e,t)=>{let n=/(?:^|\s)@([^\s@]*)$/.exec(e.slice(0,t));return n?{start:t-n[1].length-1,query:n[1]}:void 0},RL=(e,t,n)=>{let r=e.slice(t.start+1+t.query.length),i=`@${n}${r.startsWith(` `)?``:` `}`;return{text:`${e.slice(0,t.start)}${i}${r}`,caret:t.start+i.length+ +!!r.startsWith(` `)}},zL=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),BL=e=>{let t=[...new Set(e)].filter(Boolean).sort((e,t)=>t.length-e.length);return t.length===0?void 0:RegExp(`(?<![\\p{L}\\p{N}_@])@(${t.map(zL).join(`|`)})(?![\\p{L}\\p{N}_])`,`gu`)},VL=(e,t)=>{let n=BL(t.map(e=>e.name)),r=new Set(n?[...e.matchAll(n)].map(e=>e[1]):[]);return[...new Set(t.filter(e=>r.has(e.name)).map(e=>e.id))]},HL=`rounded-sm bg-primary/10 px-0.5 font-medium text-primary [strong_&]:font-bold`,UL=(e,t)=>{let n=BL(t.flatMap(e=>e.name?[e.name]:[]));if(!n)return[{text:e}];let r=[],i=0;for(let t of e.matchAll(n))t.index>i&&r.push({text:e.slice(i,t.index)}),r.push({mention:t[1]}),i=t.index+t[0].length;return i<e.length&&r.push({text:e.slice(i)}),r},WL=F(`mentions`),GL=({id:e,optionId:t,people:n,active:r,onActive:i,onPick:a,failed:o,at:s})=>(0,L.jsxs)(`ul`,{id:e,role:`listbox`,"aria-label":WL(`peopleToMention`),className:R(`absolute z-30 w-full max-w-sm rounded-md border bg-background py-1 shadow-pop`,s===`above`?`bottom-full mb-1`:`mt-1`),onMouseDown:e=>e.preventDefault(),children:[n.map((e,n)=>(0,L.jsx)(`li`,{id:t(n),role:`option`,"aria-selected":n===r,className:R(`cursor-pointer truncate px-3 py-1.5`,n===r&&`bg-muted`),onMouseMove:()=>n!==r&&i(n),onClick:()=>a(e),children:e.name},e.id)),n.length===0&&(0,L.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:WL(o?`couldNotSearch`:`noOneFound`)})]}),KL=(e,t)=>{let n=yD(t,150),[r,i]=(0,M.useState)(),a=(0,M.useRef)(e);return a.current=e,(0,M.useEffect)(()=>{let e=a.current;if(n===void 0||!e)return;let t=!0;return e(n).then(e=>t&&i({people:e}),()=>t&&i({failed:!0})),()=>{t=!1}},[n]),t===void 0?void 0:r},qL={text:``,picked:[]},JL=8,YL=({value:e,onChange:t,searchPeople:n,listAt:r=`below`,onKeyDown:i,onFocus:a,onBlur:o,ref:s,...c})=>{let[l,u]=(0,M.useState)(0),[d,f]=(0,M.useState)(!1),[p,m]=(0,M.useState)(0),[h,g]=(0,M.useState)(),_=(0,M.useRef)(null),v=(0,M.useCallback)(e=>{_.current=e,typeof s==`function`?s(e):s&&(s.current=e)},[s]),y=(0,M.useRef)(void 0),b=(0,M.useId)(),x=n?LL(e.text,l):void 0,S=d&&x!==void 0&&x.start!==h,C=KL(n,S?x.query:void 0),w=S&&C&&`people`in C?C.people.slice(0,JL):[],T=S&&C!==void 0,E=e=>`${b}-${e}`;(0,M.useEffect)(()=>m(0),[x?.query]);let D=x?.start;(0,M.useEffect)(()=>{D===void 0&&g(void 0)},[D]),(0,M.useLayoutEffect)(()=>{y.current!==void 0&&_.current&&(_.current.setSelectionRange(y.current,y.current),u(y.current),y.current=void 0)},[e.text]);let O=n=>{if(!x)return;let r=RL(e.text,x,n.name);y.current=r.caret,t({text:r.text,picked:[...e.picked,n]})},k=e=>{if(S){let t=IL(e.key,p,w.length);if(t!==void 0&&(e.key===`ArrowDown`||e.key===`ArrowUp`)){e.preventDefault(),m(t);return}if((e.key===`Enter`||e.key===`Tab`)&&w[p]){e.preventDefault(),O(w[p]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),g(x.start);return}}i?.(e)},A=n&&{role:`combobox`,"aria-multiline":!0,"aria-autocomplete":`list`,"aria-expanded":T,"aria-controls":b,"aria-activedescendant":T&&w[p]?E(p):void 0};return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(VN,{...c,...A,ref:v,value:e.text,onChange:n=>{t({...e,text:n.target.value}),u(n.target.selectionStart)},onSelect:e=>u(e.currentTarget.selectionStart),onFocus:e=>{f(!0),a?.(e)},onBlur:e=>{f(!1),o?.(e)},onKeyDown:k}),T&&(0,L.jsx)(GL,{id:b,optionId:E,people:w,active:p,onActive:m,onPick:O,failed:`failed`in C,at:r})]})},XL=class extends M.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){this.props.onError(e,t.componentStack)}render(){return this.state.failed?this.props.fallback:this.props.children}},ZL=((e,t,n=pg)=>{let r=!1,i,a=t=>({number:t,Part:(0,M.lazy)(()=>e().then(e=>({default:e}),e=>{throw r=!0,i=e,n(e),e}))}),o=a(0),s=new Set,c=e=>(s.add(e),()=>s.delete(e)),l=()=>{if(r){r=!1,o=a(o.number+1);for(let e of s)e()}},u=(e,t)=>{e!==i&&n(e,t)};return e=>{(0,M.useEffect)(l,[]);let{number:n,Part:r}=(0,M.useSyncExternalStore)(c,()=>o);return(0,L.jsx)(XL,{fallback:(0,L.jsx)(t,{...e}),onError:u,children:(0,L.jsx)(M.Suspense,{fallback:(0,L.jsx)(t,{...e}),children:(0,L.jsx)(r,{...e})})},n)}})(()=>s(()=>import(`./message-content--7TsRUEK.js`).then(e=>e.MessageContent),__vite__mapDeps([76,1,6,72,73,74])),({text:e,mentions:t})=>(0,L.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:UL(e,t).map((e,t)=>`mention`in e?(0,L.jsxs)(`span`,{className:HL,children:[`@`,e.mention]},t):e.text)})),QL=e=>e.types.includes(`Files`),$L=e=>e.types.includes(`text/plain`)?[]:[...e.files],eR=(e,{busy:t,canSendEmpty:n})=>t?!1:e!==``||n===!0,tR=({onSend:e,busy:t,placeholder:n,inputRef:r,searchPeople:i,attachments:a,actions:o,canSendEmpty:s,onFiles:c})=>{let[l,u]=(0,M.useState)(qL),d=l.text.trim(),f=eR(d,{busy:t,canSendEmpty:s}),p=()=>{if(!f)return;let t=e?.(d,VL(d,l.picked));if(!(t instanceof Promise)){u(qL);return}t.then(e=>{e&&u(e=>e.text.trim()===d?qL:e)})};return(0,L.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),p()},onDragOver:e=>{c&&QL(e.dataTransfer)&&e.preventDefault()},onDrop:e=>{c&&QL(e.dataTransfer)&&(e.preventDefault(),c([...e.dataTransfer.files]))},children:[a&&(0,L.jsx)(`div`,{className:`basis-full`,children:a}),o,(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(YL,{ref:r,rows:1,"aria-label":xL(`message`),placeholder:n,value:l,onChange:u,searchPeople:i,listAt:`above`,onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),p())},onPaste:e=>{if(!c)return;let t=$L(e.clipboardData);t.length!==0&&(e.preventDefault(),c(t))}})}),(0,L.jsx)(B,{type:`submit`,variant:`primary`,className:`w-8 px-0`,"aria-label":xL(`send`),disabled:!f,children:(0,L.jsx)(fl,{className:`size-4`})})]})},nR=e=>{let[t,n]=(0,M.useState)();return(0,M.useEffect)(()=>{let t=window.visualViewport;if(!e||!t)return n(void 0);let r=()=>n({top:t.offsetTop,height:t.height});return r(),t.addEventListener(`resize`,r),t.addEventListener(`scroll`,r),()=>{t.removeEventListener(`resize`,r),t.removeEventListener(`scroll`,r)}},[e]),e?t:void 0},rR=F(`side-panel`),iR=({title:e,icon:t,status:n,onClose:r,footer:i,children:a})=>{let o=nR(!ly());return(0,L.jsxs)(`aside`,{"aria-label":e,className:`flex h-full w-[380px] max-w-full shrink-0 flex-col border-l border-border bg-surface max-md:fixed max-md:inset-0 max-md:z-40 max-md:w-full max-md:border-l-0`,style:o&&{top:o.top,bottom:`auto`,height:o.height},children:[(0,L.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-background px-4`,children:[t,(0,L.jsx)(`h2`,{className:`flex-1 font-semibold`,children:e}),n&&(0,L.jsx)(`span`,{className:`truncate text-xs font-medium text-muted-foreground`,children:n}),r&&(0,L.jsx)(B,{variant:`ghost`,size:`sm`,className:`w-7 px-0`,"aria-label":rR(`close`),onClick:r,children:(0,L.jsx)(uu,{className:`size-4`})})]}),a,i&&(0,L.jsx)(`footer`,{className:`shrink-0 space-y-2 border-t border-border bg-background p-3`,children:i})]})},aR=F(`action-card`),oR={neutral:{border:`border-border-strong`,header:`bg-surface text-foreground`},info:{border:`border-primary-border`,header:`bg-primary-soft text-primary-text`},success:{border:`border-success/40`,header:`bg-success-soft text-success-text`},warning:{border:`border-warning/40`,header:`bg-warning-soft text-warning-text`},danger:{border:`border-danger/40`,header:`bg-danger-soft text-danger-text`}},sR=({title:e,tone:t=`neutral`,badge:n,note:r,actions:i=[],onAction:a,children:o,frameless:s=!1})=>{let[c,l]=(0,M.useState)(),u=i.flatMap(e=>e.hint?[e.hint]:[]),d=e=>e.confirm?l(e):a?.(e.id);return(0,L.jsxs)(`section`,{"aria-label":e,className:s?`whitespace-normal text-foreground`:R(`shrink-0 overflow-hidden rounded-lg border bg-background whitespace-normal text-foreground shadow-sm`,oR[t].border),children:[!s&&(0,L.jsxs)(`header`,{className:R(`flex items-center gap-2 px-3 py-2`,oR[t].header),children:[(0,L.jsx)(`h3`,{className:`min-w-0 flex-1 font-semibold`,children:e}),n&&(0,L.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:n})]}),(o||r||i.length>0)&&(0,L.jsxs)(`div`,{className:R(`space-y-2.5`,!s&&`px-3 py-2.5`),children:[o,r&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}),i.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-0.5`,children:i.map(e=>(0,L.jsx)(B,{size:`sm`,variant:e.style??`secondary`,className:R(e.style===`primary`&&`flex-1`),disabled:e.disabled,onClick:()=>d(e),children:e.label},e.id))}),u.map(e=>(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e))]}),c&&(0,L.jsx)(xu,{title:`${c.label}?`,description:c.confirm,onClose:()=>l(void 0),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:()=>l(void 0),children:aR(`cancel`)}),(0,L.jsx)(B,{variant:c.style===`danger`?`danger`:`primary`,onClick:()=>{l(void 0),a?.(c.id)},children:c.label})]})})]})},cR=({fields:e})=>(0,L.jsx)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-body`,children:e.map((e,t)=>(0,L.jsxs)(`div`,{className:`contents`,children:[(0,L.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,L.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.value})]},`${t}-${e.label}`))}),lR=e=>e==null?`null`:typeof e==`object`?JSON.stringify(e):String(e),uR=F(`compact-table`),dR=({columns:e,rows:t,caption:n,truncated:r,className:i})=>(0,L.jsxs)(`section`,{"aria-label":n??uR(`table`),className:R(`shrink-0 overflow-hidden rounded-lg border border-border-strong bg-background shadow-sm`,i),children:[n&&(0,L.jsx)(`code`,{className:`block whitespace-pre-wrap break-words bg-surface px-3 py-2 font-mono text-[0.6875rem] text-foreground`,children:n}),t.length===0?(0,L.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:uR(`noRows`)}):(0,L.jsx)(`div`,{className:`max-h-64 overflow-auto`,children:(0,L.jsxs)(`table`,{className:`w-full border-collapse text-left text-[0.6875rem]`,children:[(0,L.jsx)(`thead`,{className:`sticky top-0 bg-background`,children:(0,L.jsx)(`tr`,{children:e.map(e=>(0,L.jsx)(`th`,{scope:`col`,className:`border-b border-border px-2 py-1 font-semibold whitespace-nowrap`,children:e},e))})}),(0,L.jsx)(`tbody`,{children:t.map((e,t)=>(0,L.jsx)(`tr`,{className:`border-b border-border last:border-b-0`,children:e.map((e,t)=>(0,L.jsx)(`td`,{className:R(`px-2 py-1 whitespace-nowrap`,e===null&&`text-faint-foreground`),children:lR(e)},t))},t))})]})}),(0,L.jsxs)(`footer`,{className:`border-t border-border px-3 py-1.5 text-[0.6875rem] text-muted-foreground`,children:[uR(`rows`,{count:t.length}),r&&uR(`cutOff`)]})]}),fR=(e,t=1)=>{let n=t,r=t;return e.split(`
31
- `).map(e=>e.startsWith(`+`)?{kind:`add`,text:e.slice(1),newNo:r++}:e.startsWith(`-`)?{kind:`del`,text:e.slice(1),oldNo:n++}:{kind:`ctx`,text:e.startsWith(` `)?e.slice(1):e,oldNo:n++,newNo:r++})},pR=e=>({added:e.filter(e=>e.kind===`add`).length,removed:e.filter(e=>e.kind===`del`).length}),mR=e=>{let t=[],n=[],r=[],i=()=>{for(let e=0;e<Math.max(n.length,r.length);e++)t.push({kind:`pair`,old:n[e],new:r[e]});n=[],r=[]};for(let a of e){if(a.kind===`del`){r.length>0&&i(),n.push(a);continue}if(a.kind===`add`){r.push(a);continue}i(),t.push(a.kind===`hunk`?{kind:`hunk`,text:a.text}:{kind:`pair`,old:a,new:a})}return i(),t},hR={add:`bg-success-soft text-success-text`,del:`bg-danger-soft text-danger-text`,ctx:`text-muted-foreground`,hunk:`bg-surface text-faint-foreground`},gR={add:`+`,del:`−`,ctx:``,hunk:``},_R=`bg-background py-1 font-mono text-[0.6875rem] leading-[18px]`,vR=({line:e})=>(0,L.jsxs)(`div`,{className:R(`flex min-w-0`,e?hR[e.kind]:`bg-surface`),children:[(0,L.jsx)(`span`,{className:`w-8 shrink-0 select-none pr-2 text-right opacity-60`,children:e?.newNo??e?.oldNo}),(0,L.jsx)(`span`,{className:`w-3 shrink-0 select-none`,children:e&&gR[e.kind]}),(0,L.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words pr-3`,children:e?.text})]}),yR=({line:e})=>(0,L.jsx)(vR,{line:e&&e.kind===`ctx`?{...e,newNo:void 0}:e}),bR=({lines:e,className:t})=>(0,L.jsx)(`pre`,{className:R(`overflow-x-auto`,_R,t),children:e.map((e,t)=>(0,L.jsx)(vR,{line:e},t))}),xR=({lines:e,className:t})=>(0,L.jsx)(`pre`,{className:R(`grid-cols-2`,_R,t),children:mR(e).map((e,t)=>e.kind===`hunk`?(0,L.jsx)(`div`,{className:R(`col-span-2 px-3`,hR.hunk),children:e.text},t):(0,L.jsxs)(`div`,{className:`contents`,children:[(0,L.jsx)(yR,{line:e.old}),(0,L.jsx)(vR,{line:e.new})]},t))}),SR=({source:e,start:t,path:n,split:r,className:i})=>{let a=typeof e==`string`?fR(e,t):e,o=pR(a);return(0,L.jsxs)(`div`,{className:R(`overflow-hidden`,i),children:[n&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border bg-surface px-3 py-1.5`,children:[(0,L.jsx)(Bs,{className:`size-3.5 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.6875rem] text-foreground`,children:n}),(0,L.jsxs)(`span`,{className:`text-[0.6875rem] font-medium text-success-text`,children:[`+`,o.added]}),o.removed>0&&(0,L.jsxs)(`span`,{className:`text-[0.6875rem] font-medium text-danger-text`,children:[`−`,o.removed]})]}),a.length>0&&!r&&(0,L.jsx)(bR,{lines:a}),a.length>0&&r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(bR,{lines:a,className:`md:hidden`}),(0,L.jsx)(xR,{lines:a,className:`hidden md:grid`})]})]})},CR={a:7,b:8,t:9,n:10,v:11,f:12,r:13,'"':34,"\\":92},wR=new TextEncoder,TR=new TextDecoder,ER=e=>{if(!e.startsWith(`"`))return;let t=[],n=1;for(;n<e.length;){let r=String.fromCodePoint(e.codePointAt(n));if(r===`"`)return{path:TR.decode(new Uint8Array(t)),rest:e.slice(n+1)};if(r!==`\\`){t.push(...wR.encode(r)),n+=r.length;continue}let i=/^[0-3][0-7]{2}/.exec(e.slice(n+1));if(i){t.push(parseInt(i[0],8)),n+=4;continue}let a=CR[e[n+1]??``];if(a===void 0)return;t.push(a),n+=2}},DR=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,OR=/^(index |old mode |new mode |deleted file mode |new file mode |similarity index |dissimilarity index |rename from |rename to |copy from |copy to |Binary files )/,kR=e=>{let t=ER(e.slice(4)),n=t?t.path:e.slice(4).split(` `)[0];if(n!==`/dev/null`)return n.replace(/^[ab]\//,``)},AR=(e,t)=>{let n=ER(t);if(n&&n.rest!==``)return;let r=n?n.path:t;if(e.startsWith(`a/`)&&r.startsWith(`b/`))return{old:e.slice(2),new:r.slice(2)}},jR=e=>{if(!e.startsWith(`diff --git `))return;let t=e.slice(11),n=ER(t);if(n)return n.rest.startsWith(` `)?AR(n.path,n.rest.slice(1)):void 0;let r=t.indexOf(` "b/`);if(r!==-1)return AR(t.slice(0,r),t.slice(r+1));let i=[...t.matchAll(/ b\//g)].map(e=>[t.slice(0,e.index),t.slice(e.index+1)]),a=i.find(([e,t])=>e.slice(2)===t.slice(2))??i.at(-1);return a&&AR(...a)},MR=(e,t)=>{let n=t.find(t=>e.startsWith(t));if(n===void 0)return;let r=e.slice(n.length);return ER(r)?.path??r},NR=(e,t)=>jR(e[t])!==void 0||e[t].startsWith(`--- `)&&e[t+1]?.startsWith(`+++ `)===!0,PR=e=>{let t=e.replace(/\r\n/g,`
32
- `).split(`
33
- `);t.at(-1)===``&&t.pop();let n=0;for(;n<t.length&&!NR(t,n);)n++;let r=[],i;for(;n<t.length;){let e=t[n],a=r.at(-1);if(e===`-- `)break;let o=jR(e);if(o!==void 0){r.push({path:o.new,lines:[]}),i=o,n++;continue}if(e.startsWith(`--- `)&&t[n+1]?.startsWith(`+++ `)){let a=kR(e),o=kR(t[n+1]);(i===void 0||(a??i.old)!==i.old||(o??i.new)!==i.new)&&r.push({path:o??a??``,lines:[]}),i=void 0,n+=2;continue}if(a&&a.lines.length===0&&OR.test(e)){let t=MR(e,[`rename from `,`copy from `]),r=MR(e,[`rename to `,`copy to `]);i&&t!==void 0&&(i.old=t),i&&r!==void 0&&(i.new=r,a.path=r),n++;continue}let s=DR.exec(e);if(!a||!s)return;i=void 0,a.lines.push({kind:`hunk`,text:e});let c=Number(s[1]),l=Number(s[3]),u=s[2]===void 0?1:Number(s[2]),d=s[4]===void 0?1:Number(s[4]);for(n++;u>0||d>0;){let e=t[n];if(e===void 0)return;if(n++,!e.startsWith(`\\`)){if(e.startsWith(`+`))a.lines.push({kind:`add`,text:e.slice(1),newNo:l++}),d--;else if(e.startsWith(`-`))a.lines.push({kind:`del`,text:e.slice(1),oldNo:c++}),u--;else if(e.startsWith(` `)||e===``)a.lines.push({kind:`ctx`,text:e.slice(1),oldNo:c++,newNo:l++}),u--,d--;else return;if(u<0||d<0)return}}for(;t[n]?.startsWith(`\\`);)n++}return r.length>0?r:void 0},FR={pending:(0,L.jsx)(fs,{className:`size-3 text-faint-foreground`}),running:(0,L.jsx)(fu,{className:`size-3.5 text-primary`}),done:(0,L.jsx)(Xo,{className:`size-3.5 text-success`,strokeWidth:2.5}),failed:(0,L.jsx)(uu,{className:`size-3.5 text-danger`,strokeWidth:2.5})},IR={pending:`text-muted-foreground`,running:`text-foreground`,done:`text-muted-foreground`,failed:`text-danger-text`},LR=({steps:e,className:t})=>(0,L.jsx)(`ul`,{className:R(`shrink-0 space-y-2`,t),children:e.map((e,t)=>(0,L.jsxs)(`li`,{className:`flex items-start gap-2.5`,"data-state":e.state,children:[(0,L.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 items-center justify-center`,children:FR[e.state]}),(0,L.jsx)(`span`,{className:IR[e.state],children:e.label})]},`${t}-${e.label}`))}),RR=F(`assistant-dock`),zR=({part:e,note:t})=>e.fallback?(0,L.jsx)(sR,{title:e.fallback.title,note:t,children:e.fallback.body&&(0,L.jsx)(`p`,{children:e.fallback.body})}):(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`${e.name}: ${t}`}),BR=class extends M.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){pg(e,t.componentStack)}render(){return this.state.failed?(0,L.jsx)(zR,{part:this.props.part,note:RR(`couldNotDraw`)}):this.props.children}},VR=({part:e})=>{let{components:t={}}=tT(),n=Object.hasOwn(t,e.name)?t[e.name]:void 0;return n?(0,L.jsx)(BR,{part:e,children:(0,L.jsx)(n,{...e.props})}):(0,L.jsx)(zR,{part:e,note:RR(`cannotShowLive`)})},HR=({part:e,onAction:t})=>{switch(e.type){case`text`:return(0,L.jsx)(`p`,{children:e.text});case`table`:return(0,L.jsx)(dR,{columns:e.columns,rows:e.rows,caption:e.caption,truncated:e.truncated});case`card`:return(0,L.jsxs)(sR,{title:e.title,tone:e.tone,badge:e.badge,note:e.note,actions:e.actions,onAction:n=>t?.(e.id,n),children:[e.body&&(0,L.jsx)(`p`,{children:e.body}),e.code&&(0,L.jsx)(`pre`,{className:`overflow-x-auto rounded-md bg-surface px-2.5 py-2 font-mono text-[0.6875rem] whitespace-pre-wrap break-words`,children:e.code}),e.fields&&e.fields.length>0&&(0,L.jsx)(cR,{fields:e.fields}),e.steps&&e.steps.length>0&&(0,L.jsx)(LR,{steps:e.steps}),e.diffs?.map((e,t)=>(0,L.jsx)(SR,{source:e.source,start:e.start,path:e.path,className:`rounded-md border border-border`},`${t}-${e.path}`))]});case`widget`:return(0,L.jsx)(VR,{part:e})}},UR=(0,M.createContext)(void 0),WR=e=>e instanceof Error?e:Error(RR(`backendNoAnswer`)),GR=(e,t)=>typeof e==`function`?e(t):e,KR=(e,{refreshMs:t=!1}={})=>{let n=(0,M.useContext)(UR),[r,i]=(0,M.useState)({}),[a,o]=(0,M.useState)(0),s=(0,M.useRef)(t);s.current=t;let c=(0,M.useRef)(void 0);return(0,M.useEffect)(()=>{if(!n){i({error:Error(`useBackendData works only in a widget the assistant dock draws`)});return}let t=!0,r,a=async()=>{let o=await n.fetch(e).then(e=>e.json()).then(e=>({data:e}),e=>({data:c.current,error:WR(e)}));if(!t)return;c.current=o.data,i(o);let l=GR(s.current,o.data);l!==!1&&(r=setTimeout(a,l))};return a(),()=>{t=!1,clearTimeout(r)}},[n,e,a]),{...r,reload:()=>o(e=>e+1),post:async(e,t)=>{if(!n)throw Error(`useBackendData works only in a widget the assistant dock draws`);let r={method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t??{})},a=await n.fetch(e,r).then(e=>e.json()).then(e=>({data:e}),e=>({data:c.current,error:WR(e)}));c.current=a.data,i(a)}}},qR=({state:e,offline:t,error:n,onSend:r,onAction:i,onClose:a,client:o})=>{let s=(0,M.useRef)(null);return(0,M.useEffect)(()=>{e.placeholder&&s.current?.focus()},[e.placeholder]),(0,L.jsx)(iR,{title:RR(`assistant`),icon:(0,L.jsx)(wl,{className:`size-4 text-primary`}),status:t?RR(`reconnecting`):e.status,onClose:a,footer:(0,L.jsxs)(L.Fragment,{children:[n&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body text-danger-text`,children:n}),(0,L.jsx)(tR,{inputRef:s,onSend:r,busy:e.replying,placeholder:e.placeholder??RR(`askQuestion`)})]}),children:(0,L.jsx)(UR.Provider,{value:o,children:(0,L.jsx)(FL,{length:e.messages.reduce((e,t)=>e+t.parts.length,0),empty:RR(`empty`),children:e.messages.map(e=>(0,L.jsx)(OL,{from:e.from,children:e.parts.map(e=>(0,L.jsx)(HR,{part:e,onAction:i},e.id))},e.id))})})})},JR=e=>e instanceof Error?e.message:RR(`noAnswer`),YR=e=>{let[t,n]=(0,M.useState)(Mr),[r,i]=(0,M.useState)(!1),[a,o]=(0,M.useState)();(0,M.useEffect)(()=>{if(e)return e.connect(e=>n(t=>Fr(t,e)),e=>i(e.state===`retrying`))},[e]);let s=e=>{o(void 0),e.catch(e=>o(JR(e)))};return{state:t,offline:r,error:a,send:(t,n)=>e&&s(e.send(t,n)),act:(t,n)=>e&&s(e.act(t,n))}},XR=e=>{let t=aw(),n=(0,M.useRef)(t);n.current=t;let r=t!==void 0;return(0,M.useMemo)(()=>r?tg({url:e,token:()=>n.current}):void 0,[e,r])},ZR=`flex w-full items-center gap-2 px-3 py-2.5 text-left hover:bg-muted disabled:cursor-default disabled:opacity-60`,QR=F(`record-view`),$R=({actions:e,label:t=QR(`actions`),className:n})=>{let{open:r,setOpen:i,place:a,button:o,menu:s}=GT();return e.length===0?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{ref:o,type:`button`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":r,onClick:()=>i(!r),className:n,children:(0,L.jsx)(Os,{className:`size-5`})}),(0,L.jsx)(ox,{open:r,title:t,onClose:()=>i(!1),menu:(0,L.jsx)(`ul`,{ref:s,role:`menu`,"aria-label":t,style:a??{visibility:`hidden`},className:`fixed z-50 max-h-[calc(100dvh-1rem)] min-w-48 overflow-y-auto rounded-md border bg-background py-1 shadow-pop`,children:e.map(({name:e,icon:t,onRun:n,blocked:r,running:a,tone:o,render:s})=>{let c=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(t,{className:R(`size-4 shrink-0`,o===`danger`?`text-danger-text`:`text-muted-foreground`),"aria-hidden":!0}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:R(`block font-medium`,o===`danger`&&`text-danger-text`),children:e}),r&&(0,L.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:r})]})]});return(0,L.jsx)(`li`,{role:`none`,onClick:()=>i(!1),children:s&&!r?s({className:ZR,children:c,role:`menuitem`}):(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:n,disabled:!!r||a,title:r,className:ZR,children:c})},e)})})})]})},ez=(0,M.createContext)(void 0),tz=()=>{let e=(0,M.useContext)(ez);if(!e)throw Error(`A focus part is used outside a FocusPage`);return e},nz=()=>{let e=(0,M.useContext)(ez);return e&&{size:e.size}},rz=F(`focus-page`),iz=2,az=({action:e})=>{let t=e.icon,n=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),e.name]});return e.render&&!e.blocked?e.render({className:hu(),children:n}):(0,L.jsx)(B,{variant:e.tone===`danger`?`danger`:`secondary`,onClick:()=>!e.blocked&&e.onRun?.(),"aria-disabled":!!e.blocked,loading:e.running,title:e.blocked,children:n})},oz=(e,t)=>t===`wide`||t===`medium`?e.filter(e=>e.inBar).slice(0,iz):[],sz=()=>{let{store:e,size:t}=tz();return oz((0,M.useSyncExternalStore)(e.subscribe,e.actions),t).map(e=>(0,L.jsx)(az,{action:e},e.name))},cz=()=>{let{store:e,size:t}=tz(),n=(0,M.useSyncExternalStore)(e.subscribe,e.actions),r=Ux(),i=ly(),a=oz(n,t),o=n.filter(e=>!a.includes(e)),s=[...o.filter(e=>e.tone!==`danger`),...o.filter(e=>e.tone===`danger`)];return r&&!i?(0,N.createPortal)((0,L.jsx)($R,{actions:s,label:rz(`more`),className:Lb}),r):(0,L.jsx)($R,{actions:s,label:rz(`more`),className:hu({size:`icon`})})},lz=e=>e>=1100?`wide`:e>=950?`medium`:e>=720?`narrow`:`compact`,uz=(e,t=1)=>e>0&&t>0&&e-t*380<480,dz=[`refused`,`conflict`,`draft`,`info`],fz=e=>dz.indexOf(e),pz=()=>{let e=new Map,t=new Map,n=new Map,r=new Map,i=new Set,a=[],o,s=()=>{a=[...e.values()].flat(),o=[...t].sort(([,e],[,t])=>fz(e)-fz(t))[0]?.[0];for(let e of i)e()};return{subscribe:e=>(i.add(e),()=>{i.delete(e)}),actions:()=>a,notice:()=>o,filled:e=>(n.get(e)??0)>0,openPanels:()=>new Set(r.values()).size,openPanel:(e,t)=>(r.set(e,t),s(),()=>{r.delete(e),s()}),setActions:(t,n)=>{n?e.set(t,n):e.delete(t),s()},setNotice:(e,n)=>{n?t.set(e,n):t.delete(e),s()},fill:e=>(n.set(e,(n.get(e)??0)+1),s(),()=>{n.set(e,(n.get(e)??1)-1),s()})}},mz=()=>{let[e,t]=(0,M.useState)(0),n=(0,M.useRef)(void 0);return[(0,M.useCallback)(e=>{n.current?.disconnect(),e&&(t(e.getBoundingClientRect().width),n.current=new ResizeObserver(([e])=>t(e.contentRect.width)),n.current.observe(e))},[]),e]},hz=e=>(0,M.useState)(()=>{let t=t=>n=>e(e=>e[t]===n?e:{...e,[t]:n});return{mode:t(`mode`),controls:t(`controls`),state:t(`state`),secondary:t(`secondary`),primary:t(`primary`),notice:t(`notice`),start:t(`start`),end:t(`end`)}})[0],gz=`flex min-w-0 shrink-0 items-center gap-2 empty:hidden`,_z=({label:e,children:t})=>{tb(!1);let[n]=(0,M.useState)(pz),[r,i]=(0,M.useState)({}),a=hz(i),[o,s]=mz(),[c,l]=mz(),u=lz(s),d=uz(l,(0,M.useSyncExternalStore)(n.subscribe,n.openPanels)),f=(0,M.useMemo)(()=>({store:n,hosts:r,size:u}),[n,r,u]);return(0,L.jsx)(ez.Provider,{value:f,children:(0,L.jsxs)(`section`,{"aria-label":e,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,L.jsx)(`h1`,{className:`sr-only`,children:e}),(0,L.jsxs)(`div`,{ref:o,role:`group`,"aria-label":rz(`tools`),className:`flex min-h-12 shrink-0 items-center gap-2 border-b bg-background px-3 max-md:min-h-14`,children:[(0,L.jsx)(`div`,{ref:a.mode,className:R(gz,`shrink`)}),(0,L.jsx)(`div`,{ref:a.controls,className:gz}),(0,L.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,L.jsx)(`div`,{ref:a.state,className:R(gz,`shrink text-xs text-muted-foreground`)}),(0,L.jsx)(sz,{}),(0,L.jsx)(`div`,{ref:a.secondary,className:gz}),(0,L.jsx)(`div`,{ref:a.primary,className:gz}),(0,L.jsx)(cz,{})]}),(0,L.jsx)(`div`,{ref:a.notice,className:`shrink-0 empty:hidden`}),(0,L.jsxs)(`div`,{ref:c,className:`relative flex min-h-0 flex-1`,children:[(0,L.jsx)(`div`,{ref:a.start,className:R(`h-full shrink-0 empty:hidden`,d&&`absolute inset-y-0 left-0 z-10 shadow-pop`)}),(0,L.jsx)(`div`,{className:`relative isolate min-h-0 min-w-0 flex-1`,children:t}),(0,L.jsx)(`div`,{ref:a.end,className:R(`h-full shrink-0 empty:hidden`,d&&`absolute inset-y-0 right-0 z-10 shadow-pop`)})]})]})})},vz=({zone:e,fallback:t=!1,children:n})=>{let{store:r,hosts:i}=tz();(0,M.useLayoutEffect)(()=>t?void 0:r.fill(e),[r,e,t]);let a=yz(e),o=i[e];return o&&!(t&&a)?(0,N.createPortal)(n,o):null},yz=e=>{let{store:t}=tz();return(0,M.useSyncExternalStore)(t.subscribe,()=>t.filled(e))},bz=({actions:e})=>{let{store:t}=tz(),n=(0,M.useId)();return(0,M.useLayoutEffect)(()=>t.setActions(n,e)),(0,M.useEffect)(()=>()=>t.setActions(n,void 0),[t,n]),null},xz={refused:`bg-danger-soft`,conflict:`bg-warning-soft`,draft:`bg-surface`,info:`bg-surface`},Sz=({level:e,actions:t,children:n})=>{let{store:r,hosts:i}=tz(),a=(0,M.useId)();(0,M.useLayoutEffect)(()=>(r.setNotice(a,e),()=>r.setNotice(a,void 0)),[r,a,e]);let o=(0,M.useSyncExternalStore)(r.subscribe,r.notice)===a,s=i.notice;return!o||!s?null:(0,N.createPortal)((0,L.jsxs)(`div`,{role:e===`refused`||e===`conflict`?`alert`:`status`,className:R(`flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-3 py-2 text-body`,xz[e]),children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1 basis-48`,children:n}),t&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t})]}),s)},Cz=({side:e=`end`,title:t,icon:n,status:r,onClose:i,footer:a,takesFocus:o=!1,children:s})=>{let{hosts:c,store:l}=tz(),u=c[e],d=(0,M.useId)();(0,M.useLayoutEffect)(()=>l.openPanel(d,e),[l,d,e]);let f=(0,M.useRef)(null),[p]=(0,M.useState)(()=>document.activeElement),m=!!u;return(0,M.useEffect)(()=>{if(o&&m)return f.current?.contains(document.activeElement)||f.current?.focus(),()=>{p instanceof HTMLElement&&p.isConnected&&p.focus()}},[o,m,p]),u?(0,N.createPortal)((0,L.jsx)(iR,{title:t,icon:n,status:r,onClose:i,footer:a,children:(0,L.jsx)(`div`,{ref:f,tabIndex:-1,className:`min-h-0 flex-1 overflow-y-auto p-4 outline-none`,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),i())},children:s})}),u):null},wz=(0,M.createContext)(void 0),Tz=()=>(0,M.useContext)(wz),Ez=(e,t)=>t.every(t=>e.includes(t)),Dz=(e,t)=>Ez([e.title,e.description??``,...e.keywords??[]].join(` `).toLowerCase(),t),Oz=(e,t)=>Ez(e.title.toLowerCase(),t),kz=(e,t)=>{let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return[...e];let r=e.flatMap(e=>{let t=e.items.filter(e=>Dz(e,n));return t.length>0?[{...e,items:[...t.filter(e=>Oz(e,n)),...t.filter(e=>!Oz(e,n))]}]:[]}),i=e=>Oz(e.items[0],n);return[...r.filter(i),...r.filter(e=>!i(e))]},Az=F(`search-picker`),jz=({groups:e,label:t=Az(`search`),autoFocus:n=!1,onPick:r})=>{let[i,a]=(0,M.useState)(``),[o,s]=(0,M.useState)(0),c=(0,M.useRef)(null),l=(0,M.useId)(),u=(0,M.useMemo)(()=>kz(e,i),[e,i]),d=u.flatMap(e=>e.items),f=d[Math.min(o,d.length-1)],p=e=>`${l}-${d.indexOf(e)}`;(0,M.useEffect)(()=>{n&&c.current?.focus()},[n]);let m=f&&p(f);return(0,M.useEffect)(()=>{m&&document.getElementById(m)?.scrollIntoView({block:`nearest`})},[m]),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(Eb,{ref:c,type:`search`,role:`combobox`,"aria-label":t,"aria-expanded":!0,"aria-controls":l,"aria-activedescendant":f&&p(f),placeholder:t,leading:(0,L.jsx)(ul,{className:`size-4`,"aria-hidden":!0}),value:i,onChange:e=>{a(e.target.value),s(0)},onKeyDown:e=>{if(!(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229)){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),d.length===0)return;let t=Math.min(o,d.length-1);s((t+(e.key===`ArrowDown`?1:d.length-1))%d.length)}e.key===`Enter`&&f&&!e.nativeEvent.isComposing&&(e.preventDefault(),r(f))}}}),(0,L.jsx)(`div`,{id:l,role:`listbox`,"aria-label":t,className:`flex flex-col gap-3`,children:u.map(e=>(0,L.jsxs)(`div`,{role:`group`,"aria-label":e.title,children:[(0,L.jsx)(`div`,{className:`px-2 pb-1 text-xs font-medium text-muted-foreground`,children:e.title}),e.items.map(e=>{let t=e.icon;return(0,L.jsxs)(`div`,{id:p(e),role:`option`,"aria-selected":e===f,className:R(`flex cursor-pointer items-start gap-2.5 rounded-md px-2 py-2 max-md:min-h-11`,e===f?`bg-muted`:`hover:bg-muted`),onMouseEnter:()=>s(d.indexOf(e)),onClick:()=>r(e),children:[t&&(0,L.jsx)(t,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block font-medium`,children:e.title}),e.description&&(0,L.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description})]})]},e.id)})]},e.title))}),d.length===0&&(0,L.jsx)(`p`,{className:`px-2 text-body text-muted-foreground`,children:Az(`nothing`,{query:i.trim()})})]})},Mz=F(`carousel`),Nz=`pointer-events-auto absolute top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm opacity-0 transition-opacity group-hover/arrows:opacity-100 group-has-[:focus-visible]/arrows:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,Pz=`[@media(hover:none)]:opacity-100`,Fz=({carousel:e,count:t,swipe:n,reveal:r,className:i})=>{if(t<2)return null;let{index:a,press:o}=e;return(0,L.jsxs)(`div`,{className:R(`group/arrows pointer-events-none absolute`,i),children:[(0,L.jsx)(`button`,{type:`button`,"aria-label":Mz(`previousPhoto`),className:R(Nz,r,!n&&Pz,`left-2`),onClick:()=>o(-1),children:(0,L.jsx)(es,{className:`size-4`,"aria-hidden":!0})}),(0,L.jsx)(`button`,{type:`button`,"aria-label":Mz(`nextPhoto`),className:R(Nz,r,!n&&Pz,`right-2`),onClick:()=>o(1),children:(0,L.jsx)(ns,{className:`size-4`,"aria-hidden":!0})}),(0,L.jsxs)(`span`,{className:`absolute inset-x-0 bottom-2 flex justify-center`,"aria-live":`polite`,children:[(0,L.jsx)(`span`,{className:`sr-only`,children:Mz(`photoOf`,{index:a+1,count:t})}),(0,L.jsx)(`span`,{className:`flex items-center gap-1 rounded-full bg-background/70 px-1.5 py-1 leading-none`,"aria-hidden":!0,children:Array.from({length:t},(e,t)=>(0,L.jsx)(`span`,{className:R(`size-1.5 rounded-full`,t===a?`bg-foreground`:`bg-foreground/35`)},t))})]})]})},Iz={width:640,height:480},Lz=e=>e.flatMap(e=>{if(`src`in e)return[{image:{url:e.src},alt:e.alt}];let t=JO(e,Iz);return t?[{image:t,alt:e.alt??``}]:[]}),Rz=({carousel:e,swipe:t,slides:n,className:r,...i})=>(0,L.jsx)(`span`,{...i,ref:e.track,tabIndex:-1,onPointerDown:e.touch,onScroll:t=>e.scrolled(t.currentTarget),className:R(`flex size-full snap-x snap-mandatory outline-none [scrollbar-width:none] motion-safe:scroll-smooth [&::-webkit-scrollbar]:hidden`,t?`overflow-x-auto overscroll-x-contain`:`overflow-x-hidden`,r),children:n.map((e,t)=>(0,L.jsx)(`span`,{className:`block size-full shrink-0 snap-start snap-always`,children:e},t))}),zz=(e,t)=>t===0?0:(e%t+t)%t,Bz=(e,t,n)=>t<=0||n===0?0:Math.min(n-1,Math.max(0,Math.round(e/t))),Vz=e=>{let t=(0,M.useRef)(null),n=(0,M.useRef)(void 0),[r,i]=(0,M.useState)(0),a=e=>{let n=t.current;n&&n.scrollTo({left:e*n.clientWidth})};return{track:t,index:r,press:t=>{n.current=zz((n.current??r)+t,e),a(n.current)},touch:()=>{n.current=void 0},scrolled:t=>{i(Bz(t.scrollLeft,t.clientWidth,e)),n.current!==void 0&&Math.abs(t.scrollLeft-n.current*t.clientWidth)<1&&(n.current=void 0)}}},Hz=({images:e,label:t,fit:n=`cover`,swipe:r=!0,className:i})=>{let a=Lz(e),o=Vz(a.length);return(0,L.jsxs)(`div`,{role:`group`,"aria-roledescription":`carousel`,"aria-label":t,className:R(`group/carousel relative overflow-hidden`,i),children:[(0,L.jsx)(Rz,{"data-carousel-track":!0,carousel:o,swipe:r,slides:a.map(({image:e,alt:t})=>(0,L.jsx)(NN,{image:e,alt:t,loading:`lazy`,className:R(`size-full`,n===`cover`?`object-cover`:`object-contain`)}))}),(0,L.jsx)(Fz,{carousel:o,count:a.length,swipe:r,reveal:`group-hover/carousel:opacity-100`,className:`inset-0`})]})},Uz=500,Wz=(e=window)=>e.top!==e.self,Gz=(e,t,n)=>{let r=!1,i,a=e=>{r!==e&&(r=e,n(e))},o=()=>{clearTimeout(i),a(!1)},s=()=>{o(),e.defaultView&&e.visibilityState===`visible`&&e.hasFocus()&&(i=setTimeout(()=>a(!0),t))},c=()=>e.visibilityState===`visible`?s():o(),l=()=>{r||s()},u=e=>{`persisted`in e&&e.persisted&&s()};return e.defaultView?.addEventListener(`focus`,s),e.defaultView?.addEventListener(`blur`,o),e.defaultView?.addEventListener(`pagehide`,o),e.defaultView?.addEventListener(`pageshow`,u),e.addEventListener(`visibilitychange`,c),e.addEventListener(`pointerdown`,l,!0),e.addEventListener(`keydown`,l,!0),s(),()=>{clearTimeout(i),e.defaultView?.removeEventListener(`focus`,s),e.defaultView?.removeEventListener(`blur`,o),e.defaultView?.removeEventListener(`pagehide`,o),e.defaultView?.removeEventListener(`pageshow`,u),e.removeEventListener(`visibilitychange`,c),e.removeEventListener(`pointerdown`,l,!0),e.removeEventListener(`keydown`,l,!0)}},Kz=()=>{let e=!1;return{down:(t,n=!1)=>{e=t&&!n},take:()=>{let t=e;return e=!1,t}}},qz=(e,t)=>n=>n?e(!0):t(()=>e(!1)),Jz=e=>{let[t,n]=(0,M.useState)(!1);return(0,M.useEffect)(()=>Gz(document,e,qz(n,N.flushSync)),[e]),t},Yz=(e,t)=>{let n=(0,M.useRef)(Kz());return{onPointerDown:()=>n.current.down(e),onKeyDown:t=>n.current.down(e,t.repeat),onClick:()=>{n.current.take()&&t()}}},Xz=({value:e,options:t,onChange:n,link:r,label:i})=>{let[a,o]=(0,M.useState)(!1),s=(0,M.useRef)(null),c=(0,M.useRef)(null),l=(0,M.useRef)([]),u=(0,M.useRef)(null),d=Ab(a,s,u),f=Nb(a,s,u,d?.right),p=t.findIndex(t=>t.value===e),m=t[p];(0,M.useEffect)(()=>{if(!a)return;l.current[Math.max(p,0)]?.focus();let e=e=>{e.target instanceof Node&&!s.current?.contains(e.target)&&!u.current?.contains(e.target)&&o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]);let h=()=>{o(!1),c.current?.focus()};return(0,L.jsxs)(`div`,{ref:s,className:`relative shrink-0`,children:[(0,L.jsxs)(`button`,{ref:c,type:`button`,"aria-label":m?`${i}: ${m.label}`:i,"aria-haspopup":`menu`,"aria-expanded":a,onClick:()=>o(!a),className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border-strong bg-background px-2.5 text-body font-medium shadow-sm transition-colors hover:bg-muted pointer-coarse:h-11`,children:[m?.icon&&(0,L.jsx)(m.icon,{className:`size-3.5`}),m?.label??i,(0,L.jsx)(Qo,{className:`size-3.5 text-muted-foreground`})]}),(0,L.jsx)(ox,{open:a,title:i,onClose:()=>o(!1),inPlaceOnDesktop:!0,menu:(0,L.jsx)(`ul`,{ref:u,role:`menu`,"aria-label":i,onKeyDown:e=>{if(e.key===`Escape`)return h();if(e.key===`Tab`)return o(!1);let n=IL(e.key,l.current.indexOf(document.activeElement),t.length);n!==void 0&&(e.preventDefault(),l.current[n]?.focus())},style:{...d,...f},className:`absolute right-0 top-full z-30 mt-1 w-max min-w-40 rounded-md border bg-background py-1 text-body shadow-pop`,children:t.map((t,i)=>{let a={ref:e=>{l.current[i]=e},role:`menuitemradio`,"aria-checked":t.value===e,className:R(`flex min-h-9 w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-muted focus:bg-muted focus:outline-none pointer-coarse:min-h-11`,t.value===e&&`font-medium`)},o=(0,L.jsxs)(L.Fragment,{children:[t.icon?(0,L.jsx)(t.icon,{className:`size-3.5`}):(0,L.jsx)(`span`,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`flex-1`,children:t.label}),t.value===e&&(0,L.jsx)(Xo,{className:`size-3.5 text-primary-text`})]});return(0,L.jsx)(`li`,{role:`none`,children:r?(0,L.jsx)(Du,{...a,to:r(t.value),onClick:h,children:o}):(0,L.jsx)(`button`,{...a,type:`button`,onClick:()=>{h(),t.value!==e&&n(t.value)},children:o})},t.value)})})})]})},Zz=({name:e,label:t,options:n,value:r,onChange:i})=>(0,L.jsx)(`div`,{role:`radiogroup`,"aria-label":t,className:`flex flex-col gap-2`,children:n.map(t=>(0,L.jsxs)(`label`,{className:R(`block rounded-lg border p-3 transition-colors has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-primary`,t.disabled?`cursor-default bg-background opacity-60`:t.value===r?`cursor-pointer border-primary bg-primary-soft`:`cursor-pointer bg-background hover:bg-surface`),children:[(0,L.jsx)(`input`,{type:`radio`,name:e,value:t.value,checked:t.value===r,disabled:t.disabled,onChange:()=>i(t.value),className:`sr-only`}),(0,L.jsx)(`span`,{className:R(`block font-medium`,t.value===r&&`text-primary-text`),children:t.label}),t.description&&(0,L.jsx)(`span`,{className:`mt-0.5 block text-xs leading-snug text-muted-foreground`,children:t.description})]},t.value))}),Qz=({name:e,label:t,required:n,help:r,example:i,error:a,conflict:o,wide:s,readOnly:c,children:l})=>{let u=(0,M.useId)(),d=[r&&`${u}-help`,i&&`${u}-example`,a&&`${u}-error`].filter(Boolean).join(` `)||void 0;return(0,L.jsxs)(`div`,{className:s?`sm:col-span-2`:void 0,children:[(0,L.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[c?(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:t}):(0,L.jsxs)(`label`,{htmlFor:u,className:`font-medium text-foreground`,children:[t,n&&(0,L.jsx)(`span`,{className:`ml-0.5 text-danger-text`,"aria-hidden":`true`,children:`*`})]}),o&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-warning-text`,title:QR(`savedDifferent`,{name:o.user.name}),children:[(0,L.jsx)(Bl,{className:`size-3.5`}),(0,L.jsx)(sb,{initials:o.user.initials,hue:o.user.hue,size:`xs`})]})]}),(0,L.jsx)(wb,{value:{id:u,name:e,describedBy:d,invalid:!!a,required:!!n},children:l}),r&&(0,L.jsx)(`p`,{id:`${u}-help`,className:`mt-1.5 text-xs text-muted-foreground`,children:r}),i&&(0,L.jsxs)(`p`,{id:`${u}-example`,className:`mt-0.5 text-xs text-faint-foreground`,children:[QR(`example`),` `,i]}),a&&(0,L.jsx)(`p`,{id:`${u}-error`,className:`mt-1.5 text-body font-medium text-danger-text`,children:a}),o&&(0,L.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3 rounded-md border border-warning/30 bg-warning-soft px-3 py-2 text-body text-warning-text`,children:[(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:o.user.name}),` `,QR(`savedThis`,{ago:o.ago}),` `,(0,L.jsx)(`strong`,{children:o.theirValue})]}),(0,L.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,L.jsx)(B,{size:`sm`,onClick:o.onKeepMine,children:QR(`keepMine`)}),(0,L.jsx)(B,{size:`sm`,onClick:o.onUseTheirs,children:QR(`useTheirs`)})]})]})]})},$z=(0,M.createContext)(0),eB=()=>(0,M.useContext)($z),tB={2:`h2`,3:`h3`,4:`h4`,5:`h5`,6:`h6`},nB=()=>Math.min(Math.max(eB(),1)+1,6),rB=({title:e,help:t,actions:n,count:r,level:i,children:a})=>{let o=nB(),s=i??o,c=tB[s],l=e?(0,L.jsxs)(c,{className:`flex items-center gap-2 text-base font-semibold text-foreground`,children:[e,r]}):null,u=!!(l||n||t),d=l?(0,L.jsx)($z.Provider,{value:s,children:a}):a;return(0,L.jsxs)(L.Fragment,{children:[n?(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[l??(0,L.jsx)(`span`,{}),n]}):l,t&&(0,L.jsx)(`p`,{className:`mt-1 max-w-xl leading-6 text-muted-foreground`,children:t}),u?(0,L.jsx)(`div`,{className:`mt-5`,children:d}):d]})},iB=({title:e,help:t,actions:n,count:r,level:i,children:a})=>(0,L.jsx)(`section`,{className:`py-8 first:pt-8`,children:(0,L.jsx)(rB,{title:e,help:t,actions:n,count:r,level:i,children:a})}),aB=({title:e,eyebrow:t,width:n,submit:r,saving:i,disabled:a,error:o,errorTitle:s=yS(`notSaved`),onSubmit:c,onCancel:l,children:u,ref:d})=>{let f=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l&&(0,L.jsx)(B,{className:`max-sm:min-h-11`,onClick:l,children:yS(`cancel`)}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,className:`max-sm:min-h-11 max-sm:flex-1`,loading:i,disabled:a,children:r})]}),p=o!==void 0&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(UM,{title:s,error:o})}),m=(0,L.jsx)(`div`,{className:`divide-y divide-border`,children:u}),h=e=>{e.preventDefault(),c()};return e===void 0?(0,L.jsxs)(`form`,{ref:d,className:`max-w-[760px]`,onSubmit:h,children:[p,m,(0,L.jsx)(`footer`,{className:`border-t pt-6 sm:flex sm:justify-end`,children:f})]}):(0,L.jsx)(`form`,{ref:d,className:`flex-1`,onSubmit:h,children:(0,L.jsxs)(`div`,{className:R(n!==`full`&&`mx-auto max-w-[760px]`,`px-4 py-6 md:px-10 md:py-8`),children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-4 border-b pb-6 sm:flex-row sm:items-end sm:justify-between sm:gap-6`,children:[(0,L.jsxs)(`div`,{children:[t&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),(0,L.jsx)(`h1`,{className:`mt-1 text-2xl font-semibold tracking-tight`,children:e})]}),f]}),p,m]})})},oB=({checked:e,onChange:t,label:n})=>{let r=Tb();return(0,L.jsx)(`button`,{type:`button`,role:`switch`,id:r.id,"aria-describedby":r[`aria-describedby`],"aria-checked":e,"aria-label":n,onClick:()=>t?.(!e),className:R(`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors`,e?`bg-primary`:`bg-border-strong`),children:(0,L.jsx)(`span`,{className:R(`size-4 rounded-full bg-white shadow transition-transform`,e?`translate-x-[18px]`:`translate-x-0.5`)})})},sB=({target:e,view:t,value:n,label:r,chosen:i=[n],several:a=!1,invalid:o,onChange:s})=>{let c=pP(),l=e.primaryKey[0],u=Kr(e,t),[d,f]=(0,M.useState)(!1),p=pD(),m=rP(e,u,c.text,d||t?.titleFrom!==void 0&&!e.search?.length),h=[...new Set([l,u,...t?.titleFrom?.fields??[]])],g=n=>t?.titleFrom?p(e,t,n,String(n[l])):String(n[u]),_=Uj(e.name,{filter:m.filter,fields:h,enabled:c.open}),v=m.filter!==void 0&&_.error instanceof Id&&_.error.slug===`expensive-query`;(0,M.useEffect)(()=>{v&&f(!0)},[v]);let y=m.local?_.items.filter(e=>iP(g(e),c.text)):_.items,{fetchNextPage:b}=_,x=(0,M.useCallback)(()=>b({cancelRefetch:!1}),[b]);return(0,L.jsx)(hP,{search:c,options:y.map(e=>({key:String(e[l]),label:g(e)})),chosen:i,several:a,closedText:r??n,placeholder:H(`searchPlural`,{plural:(t?.names?.plural??Hr(e.name)).toLowerCase()}),invalid:o,paging:{more:!!_.hasNextPage,loaded:_.items.length,loadMore:x},loading:_.isPending||_.isFetchingNextPage,failed:!!_.error&&!v,onChoose:e=>s(e.key,e.label)})},cB=(e=Ii())=>new Intl.NumberFormat(e).formatToParts(1.5).find(e=>e.type===`decimal`)?.value===`,`?`,`:`.`,lB=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),uB=(e,t)=>{let n=`[${lB(t===`.`?`,`:`.`)}\\s\\u00a0\\u202f']`,r=RegExp(`^([-+]?)(\\d{1,3}(?:${n}\\d{3})+|\\d+)(?:${lB(t)}(\\d+))?$`).exec(e.trim());if(r)return`${r[1]===`-`?`-`:``}${r[2].replace(/\D/g,``)}${r[3]?`.${r[3]}`:``}`;if(t===`.`&&/^[-+]?\d+(\.\d+)?e[-+]?\d+$/i.test(e.trim()))return String(Number(e.trim()))},dB=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),fB=new Set([`text`,`integer`,`bigint`,`decimal`,`date`,`currency`,`country`,`mail_sender`]),pB=new Set([`uuid`,`timestamp`,`relation`]),mB=(e,t)=>e.readOnly||pB.has(e.type)?!1:e.type!==`json`||t?.widget!==void 0,hB=e=>!e.readOnly&&!e.nullable&&e.type!==`boolean`,gB=new Set([`integer`,`bigint`,`decimal`]),_B=e=>{try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return e;throw t}},vB=(e,t)=>uB(e,t)??e,yB=(e,t,n=cB())=>{if(e.type===`boolean`)return!!t;if(e.type===`file`)return XO(t);let r=String(t).trim();if(r===``)return e.nullable?null:``;let i=gB.has(e.type)?vB(r,n):r;if(e.type===`integer`)return Number(i);if(e.type===`relation`)return typeof t==`number`?t:i;if(fB.has(e.type)||e.type===`enum`)return i;if(e.type===`json`)return _B(i);throw Error(`Not implemented: editing ${e.type} fields`)},bB=(e,t,n=cB())=>e.type===`boolean`?!!t:String(t??``).trim()===``?null:yB(e,t,n),xB=(e,t)=>e.type===`boolean`?!!t:dB(t),SB=(e,t,n,r=cB())=>{if(e.type===`boolean`)return!!t!=!!n;if(e.type===`file`)return ZO(t,n);let i=String(t??``).trim(),a=dB(n);return e.type===`decimal`||e.type===`integer`?i===``||a===``?i!==a:Number(vB(i,r))!==Number(a):i!==a},CB=`••••••••••`,wB=e=>Rd(e)&&e.slug===`strong-sign-in-required`?e.problem.minutes??15:void 0,TB=({field:e,hints:t,value:n,reveal:r,locked:i,invalid:a,placeholder:o,onChange:s})=>{let[c,l]=(0,M.useState)(!1),u=S({mutationFn:async()=>r(),onSuccess:()=>l(!0)}),d=dB(n)!==``,f=t?.label??Hr(e.name),p=(0,L.jsx)(B,{variant:`ghost`,size:`sm`,className:`-mr-1.5 px-1.5`,"aria-label":H(c?`hide`:`show`,{label:f}),"aria-pressed":c,loading:u.isPending,onClick:()=>{c||d||!r||u.isSuccess?l(!c):u.mutate()},children:!u.isPending&&(c?(0,L.jsx)(Ps,{className:`size-3.5`}):(0,L.jsx)(Is,{className:`size-3.5`}))}),m=wB(u.error),h=m===void 0?u.error&&(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(UM,{title:H(`couldNotShow`,{label:f}),error:u.error})}):(0,L.jsx)(WS,{minutes:m,onConfirmed:()=>u.mutate()});if(i)return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,L.jsx)(`span`,{className:R(c?t?.format===`code`?`font-mono text-xs`:``:`tracking-widest text-muted-foreground`),children:c?Rk(e,u.data,t):CB}),r&&p]}),h]});let g=d?dB(n):c&&u.isSuccess?dB(u.data):``;return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(Eb,{type:c?`text`:`password`,autoComplete:`off`,invalid:a,"aria-label":f,className:R(t?.format===`code`&&`font-mono text-xs`),placeholder:d||!r?o??(e.writeOnly?H(`setNewValue`):void 0):CB,value:g,trailing:p,onChange:e=>s(e.target.value)}),h]})},EB=({value:e})=>{let t=JO(e,{width:40,height:40});return t?(0,L.jsx)(NN,{image:t,className:`size-10 shrink-0 rounded border border-border object-cover`}):(0,L.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded border border-border bg-muted text-muted-foreground`,children:(0,L.jsx)(Hs,{className:`size-4`})})},DB=({value:e,field:t,resource:n,record:r})=>{let i=(0,M.useContext)(W_)?.resources[n],a=BO(e);if(!a)return(0,L.jsx)(`div`,{className:`py-1.5 text-muted-foreground`,children:`—`});if(`missing`in a)return(0,L.jsx)(`div`,{className:`py-1.5 text-danger-text`,children:H(`fileMissing`)});let o=`url`in a?a.url:void 0,s=`corrected`in a?a.corrected:void 0;return(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 py-1`,children:[(0,L.jsx)(EB,{value:e}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[o&&!o.startsWith(`blob:`)?(0,L.jsx)(eF,{field:t,model:i,record:zO(e)?void 0:r,name:a.name,url:o,className:`block truncate font-medium text-primary-text hover:underline`}):(0,L.jsx)(`span`,{className:`block truncate font-medium`,children:a.name}),(0,L.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[a.type,a.size!==void 0&&` · ${HO(a.size)}`,s&&` · sent as ${s.from}`]})]})]})},OB=({field:e,hints:t,resource:n,record:r,value:i,locked:a,invalid:o,onChange:s})=>{let c=X(),l=(0,M.useRef)(null),[u,d]=(0,M.useState)(),[f,p]=(0,M.useState)(!1),m=t?.label??Hr(e.name),h=S({mutationFn:async t=>{d(0);let r=await c.upload(n,e.name,t,{onProgress:(e,t)=>d(t>0?e/t:0)});return{uploaded:r,...UO(r.file.type)&&{preview:URL.createObjectURL(t)}}},onSuccess:e=>s(e),onSettled:()=>d(void 0)});if(a||e.readOnly)return(0,L.jsx)(DB,{value:i,field:e.name,resource:n,record:r});let g=e=>{let t=e?.[0];t&&h.mutate(t)},_=e=>{e.preventDefault(),p(!1),g(e.dataTransfer.files)},v=(0,L.jsx)(`input`,{ref:l,type:`file`,hidden:!0,accept:YO(e),"aria-label":H(`chooseFileFor`,{label:m}),onChange:e=>g(e.target.files)}),y=h.error&&(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(UM,{title:H(`notUploaded`),error:h.error})});return h.isPending?(0,L.jsxs)(`div`,{className:`py-1.5`,role:`status`,"aria-label":H(`uploadingLabel`,{label:m}),children:[(0,L.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${Math.round((u??0)*100)}%`}})}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:H(`uploading`,{percent:Math.round((u??0)*100)})})]}):BO(i)?(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(DB,{value:i,field:e.name,resource:n,record:r})}),(0,L.jsx)(B,{size:`sm`,onClick:()=>l.current?.click(),children:H(`replace`)}),e.nullable&&(0,L.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>s(null),children:H(`remove`)})]}),v,y]}):(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),p(!0)},onDragLeave:()=>p(!1),onDrop:_,className:R(`flex items-center gap-3 rounded-md border border-dashed px-3 py-2.5 text-muted-foreground`,f?`border-primary bg-primary/5`:o?`border-danger`:`border-border-strong`),children:[(0,L.jsx)(Hl,{className:`size-4 shrink-0`}),(0,L.jsx)(`span`,{className:`flex-1`,children:H(`dropFile`)}),(0,L.jsxs)(B,{size:`sm`,onClick:()=>l.current?.click(),children:[(0,L.jsx)(Rc,{className:`size-3.5`}),H(`chooseFile`)]})]}),v,y]})},kB=F(`markdown`),AB=()=>[{value:`write`,label:kB(`write`)},{value:`preview`,label:kB(`preview`)}],jB=({value:e,onChange:t,label:n,invalid:r,placeholder:i})=>{let[a,o]=(0,M.useState)(`write`);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`span`,{className:`self-start`,children:(0,L.jsx)(Gb,{value:a,options:AB(),onChange:o,label:n})}),a===`write`?(0,L.jsx)(VN,{rows:5,invalid:r,placeholder:i,value:e,onChange:e=>t(e.target.value)}):(0,L.jsx)(`div`,{className:`min-h-[7.5rem] rounded-md border border-border px-2.5 py-1.5`,children:e.trim()===``?(0,L.jsx)(`span`,{className:`text-faint-foreground`,children:kB(`nothingToPreview`)}):(0,L.jsx)(FP,{source:e})})]})},MB=new Set([`integer`,`bigint`,`decimal`]),NB=e=>e===`integer`||e===`bigint`?{inputMode:`numeric`,enterKeyHint:`done`}:e===`decimal`?{inputMode:`decimal`,enterKeyHint:`done`}:{},PB=e=>typeof e==`object`&&e&&`key`in e?e.key:e,FB=(e,t,n,r,i)=>t?.confirm!==void 0&&!SB(e,n,r)&&SB(e,PB(i),r),IB=F(`app/change-confirm`),LB=e=>e instanceof Element&&e.closest(`[data-dialog="change-confirm"]`)!==null,RB=({field:e,hints:t,value:n,stored:r,onChange:i})=>{let[a,o]=(0,M.useState)(),s=a=>{FB(e,t,n,r,a)?o({next:a}):i(a)},c=()=>o(void 0);return{onChange:s,dialog:a&&(0,L.jsx)(xu,{name:`change-confirm`,title:IB(`title`,{label:t?.label??Hr(e.name)}),description:t?.confirm,onClose:c,actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:c,children:IB(`cancel`)}),(0,L.jsx)(B,{variant:`primary`,onClick:()=>{o(void 0),i(a.next)},children:IB(`change`)})]})})}},zB=({field:e,hints:t,value:n,stored:r,relationLabel:i,relationTo:a,relationPicker:o,invalid:s,locked:c,placeholder:l,reveal:u,resource:d,record:f,linkText:p,onChange:m})=>{if(e.type===`file`)return(0,L.jsx)(OB,{field:e,hints:t,resource:d??``,record:f,value:n,locked:c||!d,invalid:s,onChange:m});if(e.sensitive)return(0,L.jsx)(TB,{field:e,hints:t,value:n,reveal:u,locked:c||e.readOnly,invalid:s,placeholder:l,onChange:m});if(e.type===`relation`&&o&&!e.readOnly&&!c){let e=(0,L.jsx)(sB,{target:o.target,view:o.view,value:String(n),label:i,invalid:s,onChange:(e,t)=>m({key:e,label:t})});return a?(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),(0,L.jsx)(FA,{to:a,"aria-label":H(`openLabel`,{label:i??String(n)}),title:H(`open`),className:R(hu({variant:`ghost`}),`w-8 px-0`),children:(0,L.jsx)(Eo,{className:`size-4`})})]}):e}if(e.type===`relation`){if(r==null||r===``)return(0,L.jsx)(`div`,{className:`py-1.5`,children:(0,L.jsx)(yF,{field:e,value:r,hints:t??{}})});let n=i??String(r);return(0,L.jsx)(`div`,{className:`py-1.5`,children:a?(0,L.jsx)(FA,{to:a,className:`font-medium text-primary-text hover:underline`,children:n}):n})}if(!mB(e)||c)return(0,L.jsx)(`div`,{className:`min-w-0 break-words py-1.5 text-foreground`,children:(0,L.jsx)(yF,{field:e,value:r,hints:t??{},linkText:p})});if(e.type===`boolean`)return(0,L.jsx)(oB,{checked:!!n,onChange:m,label:t?.label??Hr(e.name)});let h=!!t?.multiline&&e.type===`text`;return Sk(e,t)?(0,L.jsx)(jB,{label:t?.label??Hr(e.name),invalid:s,placeholder:l,value:String(n),onChange:m}):e.type===`mail_sender`?(0,L.jsx)(pF,{field:e,value:n,invalid:s,onChange:m}):e.type===`enum`?(0,L.jsxs)(tF,{invalid:s,value:String(n),onChange:e=>m(e.target.value),children:[n===``&&(0,L.jsx)(`option`,{value:``,children:H(`choose`)}),(e.enumValues??[]).map(e=>(0,L.jsx)(`option`,{value:e,children:Ur(e,t?.valueLabels)},e))]}):h?(0,L.jsx)(VN,{invalid:s,placeholder:l,value:String(n),onChange:e=>m(e.target.value)}):(0,L.jsx)(Eb,{invalid:s,leading:t?.prefix?(0,L.jsx)(`span`,{children:t.prefix}):void 0,trailing:t?.suffix?(0,L.jsx)(`span`,{children:t.suffix.trim()}):void 0,placeholder:l,className:R(MB.has(e.type)&&`text-right tabular-nums`),...NB(e.type),...Ek(e.type===`text`?wk(t):void 0),value:String(n),onChange:e=>m(e.target.value)})},BB=(e,t,n,r)=>e.sensitive||e.type===`file`?!1:n||e.readOnly?!0:e.type===`relation`?!r:!mB(e,t),VB=e=>{let{field:t,hints:n,value:r,stored:i,invalid:a,locked:o,onChange:s}=e,c=bP(t,n),l=(0,L.jsx)(zB,{...e});return c?o||!mB(t,n)?(0,L.jsx)(wP,{shown:c,part:`display`,field:t,value:i,fallback:l}):t.type===`file`||t.type===`relation`?l:(0,L.jsx)(wP,{shown:c,part:`editor`,field:t,value:bB(t,r),invalid:!!a,onChange:e=>s(xB(t,e)),fallback:l}):l},HB=e=>{let t=RB(e);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(VB,{...e,onChange:t.onChange}),t.dialog]})},UB=F(`app/field`),WB=(e,t)=>typeof e?.[t]==`number`?e[t]:void 0,GB=(e,t)=>{let n=WB(t,`min`),r=WB(t,`max`);if(n!==void 0)return UB(`atLeastCharacters`,{label:e,count:SO(n),n});if(r!==void 0)return UB(`atMostCharacters`,{label:e,count:SO(r),n:r})},KB=e=>{let t=WB(e,`min`),n=WB(e,`max`);return t===void 0?n===void 0?UB(`wholeNumber`):UB(`wholeNumberAtMost`,{max:SO(n)}):UB(`wholeNumberAtLeast`,{min:SO(t)})},qB=e=>{let t=WB(e,`precision`),n=WB(e,`scale`);if(t===void 0||n===void 0)return UB(`number`);let r=SO(10**(t-n));return n===0?UB(`wholeNumberBelow`,{below:r}):UB(`decimalsBelow`,{scale:n,below:r})},JB={text:GB,integer:(e,t)=>KB(t),bigint:()=>UB(`wholeNumber`),decimal:(e,t)=>qB(t),date:()=>UB(`date`),timestamp:()=>UB(`timestamp`),country:()=>UB(`country`),currency:()=>UB(`currency`),uuid:()=>UB(`uuid`),enum:()=>UB(`enum`),relation:()=>UB(`relation`),json:()=>UB(`json`),mail_sender:(e,t)=>typeof t?.address==`string`?UB(`mailSender`,{address:t.address}):void 0},YB=(e,t,n)=>n.code===`required`?UB(`required`,{label:t}):n.code!==`invalid-value`||!e?n.message:JB[e.type]?.(t,n.params)??n.message,XB=e=>{if(!Rd(e))return{};let t={};for(let n of e.errors)n.field&&n.field!==`_record`&&!Object.hasOwn(t,n.field)&&(t[n.field]=n);return t},ZB=e=>{if(e.operation!==void 0)return e.message;let t=new Set(e.errors.flatMap(e=>e.field&&e.field!==`_record`?[e.field]:[])),n=e.errors.flatMap(e=>e.field===`_record`?[e.message]:[]);return t.size===0&&n.length===0?e.message:[...t.size===0?[]:[t.size===1?UB(`checkField`):UB(`checkFields`,{count:t.size})],...n].join(` `)},QB=e=>{let t=(0,M.useRef)(null),n=(0,M.useRef)(!1);return(0,M.useEffect)(()=>{e>0&&(n.current=!0)},[e]),(0,M.useEffect)(()=>{if(!n.current)return;let e=t.current?.querySelector(`[aria-invalid="true"]`);e&&(e.focus(),n.current=!1)}),t},$B=F(`app/record`),eV=2e3,tV=Symbol(`nothing saved`),nV=(e,t)=>{let n=Lw(),[r,i]=(0,M.useState)(`idle`),[a,o]=(0,M.useState)(),s=(0,M.useRef)(void 0);return(0,M.useEffect)(()=>()=>clearTimeout(s.current),[]),{phase:r,message:a,run:async r=>{let a=e===`toast`?n.show({state:`loading`,title:$B(`savingSubject`,{subject:t})}):void 0;o(void 0),e===`button`&&i(`saving`);try{return await r()===tV?(a!==void 0&&n.dismiss(a),e===`button`&&i(`idle`),!0):(a!==void 0&&n.update(a,{state:`success`,title:$B(`subjectSaved`,{subject:t})}),e===`button`&&(i(`saved`),s.current=setTimeout(()=>i(`idle`),eV)),!0)}catch(t){if(!Rd(t))throw t;let r=t.status===412?$B(`changedBySomeoneElse`):$B(`couldNotSave`),s=ZB(t);return a!==void 0&&n.update(a,{state:`error`,title:r,description:s}),e===`button`&&(i(`idle`),o(`${r}: ${s}`)),!1}}}},rV=(e,t,n)=>t?e===void 0||e===`edit`||n?{shown:`form`,offersEdit:!1,editing:!0}:{shown:e,offersEdit:t,editing:!1}:{shown:`read`,offersEdit:!1,editing:!1},iV=(e,t,n)=>(e??t?.helpWhen??`always`)===`always`||n,aV=(e,t,n)=>e?.help!==void 0&&iV(e.helpWhen,t,n)?e.help:void 0,oV=(e,t)=>e===`editing`?t:e!==`reading`||!t,sV=e=>typeof e==`object`&&!!e&&`key`in e,cV=(e,t,n)=>t.name!==e.tenant&&!t.readOnly&&!n?.notOnCreate&&(t.type===`relation`||mB(t,n)),lV=(e,t)=>{let n=Object.values(e.fields).filter(n=>cV(e,n,t?.fields[n.name])).map(e=>e.name),r=new Set,i=Ln(t?.layout??[]).flatMap(e=>{if(e.kind!==`section`||ed(e.when)||!oV(e.when,!0))return[];let i=e.fields.filter(e=>n.includes(e)&&!r.has(e)&&oV(t?.fields[e]?.when,!0));return i.forEach(e=>r.add(e)),i.length>0?[{title:e.title,help:e.help,fields:i}]:[]}),a=n.filter(t=>!r.has(t)&&!e.fields[t].writeOnly);return a.length===0?i:[...i,{title:i.length===0?yS(`details`):yS(`otherFields`),fields:a}]},uV=(e,t)=>(e?.primaryKey.length===1?e.fields[e.primaryKey[0]]?.type:void 0)===`integer`?Number(t):t,dV=(e,t,n)=>Object.fromEntries(Object.entries(n).flatMap(([n,r])=>{let i=e.fields[n];return i?sV(r)?[[n,uV(t[i.relation?.resource??``],r.key)]]:i.type===`boolean`?[[n,!!r]]:i.type===`file`?r?[[n,yB(i,r)]]:[]:String(r).trim()===``?[]:[[n,yB(i,r)]]:[]})),fV=e=>!e.nullable&&!e.default&&e.type!==`boolean`,pV=(e,t)=>e.type===`relation`?{key:t,label:t}:e.type===`boolean`?t===`true`:t,mV=new Set([`integer`,`bigint`,`decimal`]),hV=e=>{if(!mV.has(e.type)||!e.default||!(`value`in e.default))return;let t=e.default.value;return t==null?void 0:String(t)},gV=(e,t,n={})=>Object.fromEntries(t.flatMap(t=>t.fields.flatMap(t=>{let r=e.fields[t];if(Object.hasOwn(n,t))return[[t,pV(r,n[t])]];let i=r.default;return hV(r)!==void 0||!i||!(`value`in i)||i.value===null||i.value===void 0?[]:[[t,typeof i.value==`boolean`?i.value:dB(i.value)]]}))),_V=e=>!!(e.default&&`db`in e.default),vV=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),yV=({resource:e,values:t,onCreated:n,feedback:r})=>{let i=Tv(),a=i.resources[e],o=i.views[e],s=X(),c=x(),{fields:l}=tT(),u=o?.names?.singular??Hr(e),d=nV(r??o?.saveFeedback??`toast`,yS(`subject`,{noun:u})),f=lV(a,o),[p,m]=(0,M.useState)(()=>gV(a,f,t)),[h,g]=(0,M.useState)({}),[_,v]=(0,M.useState)(0),y=QB(_),[b,S]=(0,M.useState)(!1),C=(0,M.useRef)(!1),[w,T]=(0,M.useState)(!1);(0,M.useEffect)(()=>{for(let[e,n]of Object.entries(t??{})){let t=i.resources[a.fields[e]?.relation?.resource??``];t&&yN(c,s,t,[n],i.views[t.name]).then(t=>{let r=t.get(n);r&&m(t=>sV(t[e])&&t[e].key===n&&t[e].label!==r?{...t,[e]:{key:n,label:r}}:t)})}},[t,i,a,s,c]);let E=(e,t)=>{g(t=>vV(t,e)),S(!0),m(n=>({...n,[e]:t}))},D=async(e={})=>{if(C.current)return!1;C.current=!0,T(!0);try{return await O(e)}finally{C.current=!1,T(!1)}},O=t=>d.run(async()=>{let r;try{r=await s.create(e,{...dV(a,i.resources,p),...t})}catch(t){let r=Rd(t)?t.existing:void 0;if(r)return n(void 0,{kind:`record`,resource:e,key:r.key}),tV;let i=XB(t);throw g(i),Object.keys(i).length>0&&v(e=>e+1),t}for(let t of[`page`,`list`,`first-page`,`map`,`facets`,`series`,`aggregate`,`count`])c.invalidateQueries({queryKey:[t,e]});n(r.record,{kind:`record`,resource:e,key:DT(a,r.record)})});return{ref:y,sections:f.map(e=>({title:e.title,help:e.help,fields:e.fields.map(e=>{let t=a.fields[e],n=p[e],r=t.relation?i.resources[t.relation.resource]:void 0,s=o?.fields[e]?.label??Hr(e),c=h[e];return{name:e,label:s,help:o?.fields[e]?.help,required:fV(t),error:c&&YB(t,s,c),wide:xP(l,t,o?.fields[e]),editor:(0,L.jsx)(HB,{field:t,hints:o?.fields[e],value:sV(n)?n.key:n??(t.type!==`boolean`&&``),stored:void 0,relationLabel:sV(n)?n.label:void 0,placeholder:_V(t)?yS(`setByDatabase`):hV(t),relationPicker:r?{target:r,view:i.views[r.name]}:void 0,invalid:!!h[e],resource:a.name,onChange:t=>E(e,t)})}})})),set:E,submit:D,touched:b,saving:w,message:d.message}},bV=({form:e,fields:t,submit:n,disabled:r,onSubmit:i,children:a})=>{let o=e.sections.flatMap(e=>e.fields).filter(e=>t.includes(e.name));return(0,L.jsxs)(`form`,{ref:e.ref,className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),i?i():e.submit()},children:[e.message&&(0,L.jsx)(UM,{title:yS(`notCreated`),error:Error(e.message)}),a,o.map(e=>(0,L.jsx)(Qz,{name:e.name,label:e.label,required:e.required,help:e.help,error:e.error,wide:e.wide,children:e.editor},e.name)),(0,L.jsx)(B,{variant:`primary`,type:`submit`,className:`max-md:min-h-11`,loading:e.saving,disabled:r,children:n})]})},xV=(e,t,n)=>{let r=X(),i=x(),a=[...new Set(n)].sort();return O({queryKey:I.pickedLabels(e.name,a.join(`,`)),enabled:a.length>0,placeholderData:y,queryFn:()=>yN(i,r,e,a,t)}).data??new Map},SV=e=>{let{resources:t,views:n}=Tv(),r=t[e.resource];if(!r)throw Error(`RecordPicker: the app has no resource named "${e.resource}"`);if(r.primaryKey.length!==1)throw Error(`RecordPicker: "${e.resource}" has a composite key, which a picker cannot name`);let i=n[e.resource],a=e.multiple?e.value:e.value===void 0?[]:[e.value],[o,s]=(0,M.useState)({}),c=xV(r,i,a),l=e=>o[e]??c.get(e)??e,u=(e,t)=>s(n=>({...n,[e]:t}));if(!e.multiple){let{value:t,onChange:n}=e;return(0,L.jsx)(sB,{target:r,view:i,value:t??``,label:t===void 0?void 0:l(t),invalid:e.invalid,onChange:(e,t)=>{u(e,t),n(e)}})}let{value:d,onChange:f}=e;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(sB,{target:r,view:i,value:``,chosen:d,several:!0,invalid:e.invalid,onChange:(e,t)=>{u(e,t),f(d.includes(e)?d.filter(t=>t!==e):[...d,e])}}),d.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.map(e=>(0,L.jsx)(fP,{label:l(e),onRemove:()=>f(d.filter(t=>t!==e))},e))})]})};export{bz as $,GC as $a,So as $c,ZE as $i,fn as $l,xN as $n,oy as $o,vA as $r,Op as $s,cI as $t,yB as A,ET as Aa,Qc as Ac,tk as Ai,Gn as Al,MP as An,Gb as Ao,$j as Ar,l_ as As,VL as At,Zz as B,Qw as Ba,As as Bc,SO as Bi,kn as Bl,KN as Bn,bb as Bo,Dj as Br,Jm as Bs,hL as Bt,LB as C,RT as Ca,uu as Cc,Ik as Ci,Er as Cl,nF as Cn,iS as Co,IM as Cr,j_ as Cs,iR as Ct,hB as D,OT as Da,ul as Dc,Sk as Di,qn as Dl,LP as Dn,Dx as Do,tM as Dr,C_ as Ds,qL as Dt,mB as E,zT as Ea,Ml as Ec,wk as Ei,tr as El,YP as En,Mx as Eo,aM as Er,D_ as Es,YL as Et,iB as F,hT as Fa,mc as Fc,UO as Fi,Ln as Fl,wP as Fn,Ab as Fo,Yj as Fr,lh as Fs,wL as Ft,Yz as G,Ow as Ga,is as Gc,wD as Gi,_n as Gl,LN as Gn,sb as Go,jA as Gr,km as Gs,oL as Gt,Uz as H,Zw as Ha,gs as Hc,ZD as Hi,Dn as Hl,HN as Hn,pb as Ho,FA as Hr,zm as Hs,pL as Ht,rB as I,mT as Ia,Xs as Ic,RO as Ii,Fn as Il,xP as In,Nb as Io,Jj as Ir,ih as Is,CL as It,Rz as J,fw as Ja,Qo as Jc,sD as Ji,an as Jl,ON as Jn,wy as Jo,gA as Jr,wm as Js,hI as Jt,Hz as K,gw as Ka,ns as Kc,yD as Ki,hn as Kl,FN as Kn,cb as Ko,AA as Kr,Om as Ks,$ as Kt,$z as L,cT as La,Ks as Lc,JO as Li,jn as Ll,yP as Ln,Eb as Lo,Kj as Lr,Qm as Ls,bL as Lt,uB as M,yT as Ma,Kc as Mc,YO as Mi,Un as Ml,OP as Mn,Lb as Mo,Zj as Mr,K as Ms,FL as Mt,oB as N,gT as Na,Rc as Nc,BO as Ni,Hn as Nl,DP as Nn,kb as No,Qj as Nr,dh as Ns,OL as Nt,dB as O,kT as Oa,il as Oc,xk as Oi,Jn as Ol,FP as On,ox as Oo,nM as Or,Y as Os,UL as Ot,aB as P,pT as Pa,Ic as Pc,HO as Pi,Rn as Pl,EP as Pn,Ob as Po,qj as Pr,fh as Ps,TL as Pt,Tz as Q,ew as Qa,Ro as Qc,nD as Qi,Wt as Ql,yN as Qn,sy as Qo,iA as Qr,sm as Qs,aI as Qt,eB as R,aT as Ra,Hs as Rc,LO as Ri,En as Rl,fP as Rn,wb as Ro,Hj as Rr,Zm as Rs,yL as Rt,BB as S,GT as Sa,du as Sc,zk as Si,Hr as Sl,dF as Sn,vS as So,RM as Sr,k_ as Ss,sR as St,bB as T,BT as Ta,Bl as Tc,kk as Ti,Tr as Tl,XP as Tn,jx as To,SM as Tr,E_ as Ts,ZL as Tt,Wz as U,Xw as Ua,us as Uc,qD as Ui,Tn as Ul,VN as Un,lb as Uo,PA as Ur,Rm as Us,fL as Ut,Xz as V,tT as Va,ws as Vc,bO as Vi,Pn as Vl,GN as Vn,gb as Vo,$A as Vr,Vm as Vs,mL as Vt,Jz as W,Lw as Wa,os as Wc,WD as Wi,Sn as Wl,zN as Wn,ub as Wo,NA as Wr,Am as Ws,dL as Wt,jz as X,cw as Xa,Ko as Xc,eD as Xi,nn as Xl,EN as Xn,uy as Xo,mA as Xr,fm as Xs,pI as Xt,Fz as Y,uw as Ya,Xo as Yc,oD as Yi,rn as Yl,wN as Yn,ly as Yo,oA as Yr,pm as Ys,gI as Yt,wz as Z,aw as Za,Ho as Zc,rD as Zi,Yt as Zl,DN as Zn,cy as Zo,kA as Zr,dm as Zs,dI as Zt,$B as _,oE as _a,xu as _c,Yk as _i,xi as _l,wF as _n,wS as _o,WM as _r,q_ as _s,SR as _t,dV as a,vE as aa,Bd as ac,bA as ai,Ta as al,WF as an,RC as ao,mN as ar,Qv as as,mz as at,Vt as au,YB as b,XT as ba,hu as bc,Hk as bi,qr as bl,AF as bn,SS as bo,VM as br,z_ as bs,dR as bt,sV as c,yE as ca,ed as cc,dA as ci,$i as cl,BF as cn,TC as co,eN as cr,Jv as cs,QR as ct,yt as cu,hV as d,kE as da,Hu as dc,$k as di,Ui as dl,FF as dn,vC as do,nN as dr,Ev as ds,YR as dt,ut as du,BE as ea,bp as ec,yA as ei,z as el,uI as en,WC as eo,SN as er,ry as es,Sz as et,dn as eu,aV as f,TE as fa,ku as fc,eA as fi,Ai as fl,CF as fn,XS as fo,rN as fr,Tv as fs,qR as ft,je as fu,nV as g,aE as ga,Su as gc,Zk as gi,Si as gl,SF as gn,TS as go,JM as gr,mv as gs,PR as gt,oV as h,iE as ha,Tu as hc,Qk as hi,Ci as hl,kF as hn,WS as ho,YM as hr,uv as hs,LR as ht,yV as i,hE as ia,Rd as ic,SA as ii,Oa as il,rI as in,kC as io,hN as ir,Zv as is,_z as it,Xt as iu,cB as j,DT as ja,Xc as jc,QO as ji,Vn as jl,kP as jn,Wb as jo,Xj as jr,Qg as js,IL as jt,xB as k,AT as ka,el as kc,_k as ki,Kn as kl,NP as kn,ix as ko,eM as kr,J as ks,HL as kt,fV as l,bE as la,Zu as lc,DA as li,I as ll,PF as ln,FC as lo,cN as lr,Iv as ls,ZR as lt,_t as lu,rV as m,CE as ma,Du as mc,rA as mi,wi as ml,DF as mn,GS as mo,qM as mr,wv as ms,HR as mt,le as mu,xV as n,zE as na,Id as nc,hA as ni,Ha as nl,eI as nn,BC as no,dN as nr,ty as ns,vz as nt,pn as nu,_V as o,wE as oa,_d as oc,fA as oi,va as ol,UF as on,IC as oo,gN as or,$v as os,nz as ot,At as ou,iV as p,SE as pa,H as pc,tA as pi,Ii as pl,TF as pn,KS as po,aN as pr,Av as ps,KR as pt,ge as pu,Vz as q,pw as qa,es as qc,pD as qi,Kt as ql,NN as qn,tb as qo,xA as qr,Dm as qs,vI as qt,bV as r,EE as ra,Ld as rc,EA as ri,Ia as rl,nI as rn,AC as ro,pN as rr,ey as rs,yz as rt,Ut as ru,gV as s,gE as sa,ud as sc,CA as si,Qi as sl,HF as sn,PC as so,$M as sr,Xv as ss,$R as st,jt as su,SV as t,HE as ta,Lf as tc,_A as ti,R as tl,lI as tn,UC as to,fN as tr,ny as ts,Cz as tt,Jt as tu,uV as u,xE as ua,Qu as uc,nA as ui,F as ul,IF as un,Q as uo,iN as ur,Hv as us,XR as ut,dt as uu,QB as v,QT as va,bu as vc,Xk as vi,Kr as vl,EF as vn,CS as vo,GM as vr,U_ as vs,pR as vt,SB as w,HT as wa,Hl as wc,Ok as wi,wr as wl,tF as wn,Ux as wo,NM as wr,M_ as ws,tR as wt,HB as x,JT as xa,fu as xc,Rk as xi,Ur as xl,xF as xn,yS as xo,LM as xr,B_ as xs,cR as xt,XB as y,nE as ya,B as yc,qk as yi,Jr as yl,OF as yn,xS as yo,UM as yr,X as ys,fR as yt,Qz as z,$w as za,Ms as zc,TO as zi,Nn as zl,qN as zn,Tb as zo,Uj as zr,qm as zs,_L as zt};
34
- //# debugId=2fc79999-dae1-4f95-81a9-237299affbae