@protobase/ui 0.116.0 → 0.117.0

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 (328) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/app/app.js +84 -50
  3. package/dist/app/bottom-bar-from-meta.d.ts +8 -2
  4. package/dist/app/bottom-bar-from-meta.js +23 -11
  5. package/dist/app/charts/messages.d.ts +2 -2
  6. package/dist/app/comments/messages.d.ts +2 -2
  7. package/dist/app/confirm-sign-in-messages.d.ts +2 -2
  8. package/dist/app/create/messages.d.ts +2 -2
  9. package/dist/app/delete/messages.d.ts +2 -2
  10. package/dist/app/displays/messages.d.ts +2 -2
  11. package/dist/app/export/export-dialog.js +1 -1
  12. package/dist/app/export/messages.d.ts +2 -2
  13. package/dist/app/field-types/custom-step-container/messages.d.ts +2 -2
  14. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  15. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  16. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  17. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  18. package/dist/app/field-types/workflow-status/messages.d.ts +2 -2
  19. package/dist/app/file-viewers/messages.d.ts +2 -2
  20. package/dist/app/focus/messages.d.ts +2 -2
  21. package/dist/app/gallery/lightbox.js +1 -1
  22. package/dist/app/gallery/messages.d.ts +2 -2
  23. package/dist/app/hand-order/messages.d.ts +2 -2
  24. package/dist/app/history/messages.d.ts +2 -2
  25. package/dist/app/import/import-dialog.js +1 -1
  26. package/dist/app/import/messages.d.ts +2 -2
  27. package/dist/app/import/new-table/import-table-dialog.js +1 -1
  28. package/dist/app/list-messages.d.ts +2 -2
  29. package/dist/app/list-page.js +1 -1
  30. package/dist/app/messages.d.ts +2 -2
  31. package/dist/app/meta-gate-messages.d.ts +2 -2
  32. package/dist/app/new-version/messages.d.ts +2 -2
  33. package/dist/app/pages/action-inputs/action-inputs-dialog.js +1 -1
  34. package/dist/app/pages/messages.d.ts +2 -2
  35. package/dist/app/pages/record-actions.js +1 -1
  36. package/dist/app/record-chart/messages.d.ts +2 -2
  37. package/dist/app/record-messages.d.ts +2 -2
  38. package/dist/app/record-row/messages.d.ts +2 -2
  39. package/dist/app/refresh-mark.js +46 -10
  40. package/dist/app/related-cards/messages.d.ts +2 -2
  41. package/dist/app/runtime/messages.d.ts +2 -2
  42. package/dist/app/saved/messages.d.ts +2 -2
  43. package/dist/app/searches/messages.d.ts +2 -2
  44. package/dist/app/searches/update-search-dialog.js +1 -1
  45. package/dist/app-shell/account-entry.d.ts +17 -0
  46. package/dist/app-shell/account-entry.js +40 -0
  47. package/dist/app-shell/app-shell.d.ts +13 -1
  48. package/dist/app-shell/app-shell.js +80 -10
  49. package/dist/app-shell/back-target.d.ts +3 -2
  50. package/dist/app-shell/back-target.js +4 -3
  51. package/dist/app-shell/bottom-bar.d.ts +15 -3
  52. package/dist/app-shell/bottom-bar.js +70 -42
  53. package/dist/app-shell/brand-bar.d.ts +15 -0
  54. package/dist/app-shell/brand-bar.js +19 -0
  55. package/dist/app-shell/brand-status-bar.d.ts +8 -0
  56. package/dist/app-shell/brand-status-bar.js +27 -0
  57. package/dist/app-shell/breadcrumb.d.ts +4 -2
  58. package/dist/app-shell/breadcrumb.js +45 -37
  59. package/dist/app-shell/drawer.d.ts +2 -1
  60. package/dist/app-shell/drawer.js +22 -5
  61. package/dist/app-shell/global-search.d.ts +3 -1
  62. package/dist/app-shell/global-search.js +4 -4
  63. package/dist/app-shell/index.js +2 -2
  64. package/dist/app-shell/leading-slot.d.ts +9 -0
  65. package/dist/app-shell/leading-slot.js +10 -0
  66. package/dist/app-shell/logo.js +2 -1
  67. package/dist/app-shell/menu-page.d.ts +19 -0
  68. package/dist/app-shell/menu-page.js +29 -0
  69. package/dist/app-shell/messages.d.ts +2 -2
  70. package/dist/app-shell/more-page.d.ts +45 -0
  71. package/dist/app-shell/more-page.js +30 -0
  72. package/dist/app-shell/native-tab-bar.d.ts +47 -0
  73. package/dist/app-shell/native-tab-bar.js +45 -0
  74. package/dist/app-shell/page-scroll.d.ts +3 -2
  75. package/dist/app-shell/page-scroll.js +5 -3
  76. package/dist/app-shell/profile-menu.d.ts +5 -1
  77. package/dist/app-shell/profile-menu.js +138 -117
  78. package/dist/app-shell/sidebar.d.ts +12 -1
  79. package/dist/app-shell/sidebar.js +20 -10
  80. package/dist/app-shell/tab-icon.d.ts +7 -0
  81. package/dist/app-shell/tab-icon.js +38 -0
  82. package/dist/app-shell/top-bar.d.ts +19 -3
  83. package/dist/app-shell/top-bar.js +104 -60
  84. package/dist/app-shell/use-native-bottom-bar.d.ts +16 -0
  85. package/dist/app-shell/use-native-bottom-bar.js +62 -0
  86. package/dist/assistant-dock/messages.d.ts +2 -2
  87. package/dist/auth/messages.d.ts +2 -2
  88. package/dist/calls/call-guests-panel.js +2 -2
  89. package/dist/calls/messages.d.ts +2 -2
  90. package/dist/carousel/messages.d.ts +2 -2
  91. package/dist/chat/messages.d.ts +2 -2
  92. package/dist/data-grid/header-menu.js +33 -28
  93. package/dist/data-grid/messages.d.ts +2 -2
  94. package/dist/data-grid/row-menu.js +38 -33
  95. package/dist/filter-panel/messages.d.ts +2 -2
  96. package/dist/focus-page/bar-actions.js +1 -1
  97. package/dist/format/messages.d.ts +2 -2
  98. package/dist/index.d.ts +2 -1
  99. package/dist/index.js +5 -4
  100. package/dist/inline-child-table/messages.d.ts +2 -2
  101. package/dist/invitations/messages.d.ts +2 -2
  102. package/dist/live/messages.d.ts +2 -2
  103. package/dist/locale/en.js +7 -0
  104. package/dist/locale/en.json.d.ts +7 -0
  105. package/dist/locale/messages.d.ts +14 -0
  106. package/dist/locale/nl.js +7 -0
  107. package/dist/mailbox/messages.d.ts +2 -2
  108. package/dist/mocks/customers.d.ts +1 -1
  109. package/dist/mocks/invoices.d.ts +2 -2
  110. package/dist/mocks/orders.d.ts +1 -1
  111. package/dist/notifications/bell/messages.d.ts +2 -2
  112. package/dist/notifications/bell/notification-bell.js +40 -35
  113. package/dist/organizations/messages.d.ts +2 -2
  114. package/dist/package.js +1 -1
  115. package/dist/primitives/avatar.d.ts +1 -1
  116. package/dist/primitives/avatar.js +2 -1
  117. package/dist/primitives/drawer-math.d.ts +39 -0
  118. package/dist/primitives/drawer-math.js +43 -0
  119. package/dist/primitives/menu-select.js +51 -44
  120. package/dist/primitives/menu-surface.d.ts +22 -0
  121. package/dist/primitives/menu-surface.js +29 -0
  122. package/dist/primitives/messages.d.ts +2 -2
  123. package/dist/primitives/popover-menu.js +1 -0
  124. package/dist/primitives/sheet-drag.d.ts +5 -5
  125. package/dist/primitives/sheet-drag.js +10 -16
  126. package/dist/primitives/sheet.d.ts +5 -2
  127. package/dist/primitives/sheet.js +9 -6
  128. package/dist/primitives/use-drawer-drag.d.ts +34 -0
  129. package/dist/primitives/use-drawer-drag.js +103 -0
  130. package/dist/primitives/use-sheet-drag.d.ts +2 -2
  131. package/dist/primitives/use-sheet-drag.js +10 -9
  132. package/dist/record-view/action-menu.js +45 -40
  133. package/dist/shell/assets/{account-page-9Aq9kvrG.js → account-page-dcJyxP-d.js} +2 -2
  134. package/dist/shell/assets/app-BAQxWF5r.css +2 -0
  135. package/dist/shell/assets/app-DTl8rg8j.js +34 -0
  136. package/dist/shell/assets/{assistant-shell-BGtjYwwY.js → assistant-shell-Bw1jJrLm.js} +2 -2
  137. package/dist/shell/assets/board-display-DDFDZzOk.js +2 -0
  138. package/dist/shell/assets/{calendar-display-DKXi1P_o.js → calendar-display-B0R6JkIL.js} +2 -2
  139. package/dist/shell/assets/call-rings-CzvSKlfI.js +2 -0
  140. package/dist/shell/assets/{calls-DR-Ci2ND.js → calls-BgwbMyeR.js} +2 -2
  141. package/dist/shell/assets/{circle-alert-C0Jeesr7.js → circle-alert-CANqQIsU.js} +2 -2
  142. package/dist/shell/assets/composed-page-gwTeW0b3.js +2 -0
  143. package/dist/shell/assets/{composer-section-rLoyhseD.js → composer-section-gsOgYgY2.js} +2 -2
  144. package/dist/shell/assets/{connect-route-B9xNNieq.js → connect-route-CtL1EJIN.js} +2 -2
  145. package/dist/shell/assets/{copy-field-DkCyHPwg.js → copy-field-CamvXHHQ.js} +2 -2
  146. package/dist/shell/assets/create-route-Cx8yqS-H.js +2 -0
  147. package/dist/shell/assets/{custom-step-container-field-Do5pWJ_q.js → custom-step-container-field-0-Q_RuZy.js} +4 -4
  148. package/dist/shell/assets/embedded-list-56J4XDiR.js +3 -0
  149. package/dist/shell/assets/en-CtEQkQWj.js +2 -0
  150. package/dist/shell/assets/{export-dialog-CovrAwYy.js → export-dialog-CEp2g6vx.js} +2 -2
  151. package/dist/shell/assets/export-worker-DlWkifnE.js +15 -0
  152. package/dist/shell/assets/{graph-view-BfRhAOfb.js → graph-view-CgjfBK_g.js} +2 -2
  153. package/dist/shell/assets/{group-donut-DC8GLnC8.js → group-donut-DGZUg_gn.js} +2 -2
  154. package/dist/shell/assets/{guest-call-page-Dc8M5yz6.js → guest-call-page-BhTshbrl.js} +3 -3
  155. package/dist/shell/assets/{html-viewer-DH_s-gLB.js → html-viewer-GD1mwLEo.js} +2 -2
  156. package/dist/shell/assets/{import-dialog-Ge24RdwQ.js → import-dialog-ByRCf2Cp.js} +2 -2
  157. package/dist/shell/assets/import-table-dialog-CiDY_0RT.js +2 -0
  158. package/dist/shell/assets/{index-Bi_Jks-d.js → index-PtDa8a1m.js} +1 -1
  159. package/dist/shell/assets/invitations-page-Bh-RCnnl.js +2 -0
  160. package/dist/shell/assets/{layout-grid-DCBxzjaE.js → layout-grid-DJrFC12w.js} +2 -2
  161. package/dist/shell/assets/{legend-item-BZXnHPzh.js → legend-item-YdN_NHUz.js} +2 -2
  162. package/dist/shell/assets/{lib-vis.gl-react-maplibre-CdxVSk--.js → lib-vis.gl-react-maplibre-1cv426UN.js} +2 -2
  163. package/dist/shell/assets/list-page-BU1MrXbN.js +4 -0
  164. package/dist/shell/assets/maplibre-BedvDUG2.js +2 -0
  165. package/dist/shell/assets/{markdown-content-DMl-cVjQ.js → markdown-content-BlKajH2l.js} +2 -2
  166. package/dist/shell/assets/members-page-BYUO0Dq2.js +2 -0
  167. package/dist/shell/assets/{messages-D5XhIbDz.js → messages-DQ0cj-Ao.js} +2 -2
  168. package/dist/shell/assets/nl-9OWL4NdF.js +2 -0
  169. package/dist/shell/assets/organization-page-BrC1nHC-.js +2 -0
  170. package/dist/shell/assets/organizations-page-CaUeWdr4.js +2 -0
  171. package/dist/shell/assets/parse-worker-NutG5-Js.js +35 -0
  172. package/dist/shell/assets/{pending-invitation-row-BIO4J3ts.js → pending-invitation-row-juUdWvG6.js} +2 -2
  173. package/dist/shell/assets/{period-chart-CoT2IDzy.js → period-chart-BUZhUb5l.js} +2 -2
  174. package/dist/shell/assets/{person-row-DBeHOA2K.js → person-row-DH3JhMfz.js} +2 -2
  175. package/dist/shell/assets/public-form-page-d3TamPPE.js +2 -0
  176. package/dist/shell/assets/record-lines-NtlHP9Lz.js +2 -0
  177. package/dist/shell/assets/{record-map-BR34Q9uI.js → record-map-BDXoF9AS.js} +2 -2
  178. package/dist/shell/assets/{record-opens-Dbjd4FLe.js → record-opens-C1KgR6ff.js} +2 -2
  179. package/dist/shell/assets/record-page-D88DdoET.js +3 -0
  180. package/dist/shell/assets/record-preview-BT9_Hdcn.js +2 -0
  181. package/dist/shell/assets/{records-map-CXanq-qN.js → records-map-BjHcY5gU.js} +2 -2
  182. package/dist/shell/assets/render-node-v6KfRocH.js +3 -0
  183. package/dist/shell/assets/reorder-button-B3GeKMOJ.js +2 -0
  184. package/dist/shell/assets/{run-trace-view-D1DZCrDs.js → run-trace-view-Ddc0SELh.js} +2 -2
  185. package/dist/shell/assets/{runner-install-field-C2XhrG0M.js → runner-install-field-CiD9Pw1j.js} +2 -2
  186. package/dist/shell/assets/{runtime-update-C5TxLpYf.js → runtime-update-CoXcnfxB.js} +2 -2
  187. package/dist/shell/assets/shared-protobase-ui-CwLnXvxx.js +1 -0
  188. package/dist/shell/assets/sheet-source-DbJu1SrV.js +3 -0
  189. package/dist/shell/assets/sign-in-policy-page-B40iAeJa.js +2 -0
  190. package/dist/shell/assets/start-block-queries-C_udrEM9.js +2 -0
  191. package/dist/shell/assets/step-catalog-7obnZV6X.js +2 -0
  192. package/dist/shell/assets/{step-panel-TfW-31Gv.js → step-panel-BM_xu6Yy.js} +2 -2
  193. package/dist/shell/assets/timeline-display-CdLfWAbQ.js +2 -0
  194. package/dist/shell/assets/{trash-BjnGkZfx.js → trash-BHo3HvFy.js} +2 -2
  195. package/dist/shell/assets/{update-set-BahNKmxv.js → update-set-DTikSoau.js} +2 -2
  196. package/dist/shell/assets/use-calendar-move-Bhha2yOp.js +2 -0
  197. package/dist/shell/assets/{use-display-rows-DsBBYuKB.js → use-display-rows-CS_0O_UE.js} +2 -2
  198. package/dist/shell/assets/{use-paged-search-DaT4uUhX.js → use-paged-search-ChxCRCpF.js} +2 -2
  199. package/dist/shell/assets/{use-run-trace-DHk7l8MX.js → use-run-trace-BfRRgSgG.js} +2 -2
  200. package/dist/shell/assets/{use-workflow-page-DPIhXcnb.js → use-workflow-page-CTdBd8_8.js} +2 -2
  201. package/dist/shell/assets/{use-workflow-types-Bp8iqkBg.js → use-workflow-types-cZQ59ATf.js} +2 -2
  202. package/dist/shell/assets/{vendor-DQHyyBk1.js → vendor-t7Q7QbPu.js} +2 -2
  203. package/dist/shell/assets/{workflow-canvas-CiGUTx4K.js → workflow-canvas-B0kWJeH0.js} +4 -4
  204. package/dist/shell/assets/{workflow-field-lqBx3RDj.js → workflow-field-DXIk6V2Y.js} +3 -3
  205. package/dist/shell/assets/{workflow-graph-editor-DgufTFii.js → workflow-graph-editor-Cem4aY2u.js} +2 -2
  206. package/dist/shell/assets/{workflow-run-field-C4BtvPnB.js → workflow-run-field-BeMn3eOH.js} +3 -3
  207. package/dist/shell/assets/workflow-status-field-0wvGDiva.js +2 -0
  208. package/dist/shell/assets/workflow-workbench-qT5c0xnH.js +4 -0
  209. package/dist/shell/index.html +5 -5
  210. package/dist/shell/protobase.shell.json +3 -3
  211. package/dist/shell/protobase.sw.js +2 -2
  212. package/dist/shell-source-maps/assets/{account-page-9Aq9kvrG.js.map → account-page-dcJyxP-d.js.map} +1 -1
  213. package/dist/shell-source-maps/assets/app-DTl8rg8j.js.map +1 -0
  214. package/dist/shell-source-maps/assets/{assistant-shell-BGtjYwwY.js.map → assistant-shell-Bw1jJrLm.js.map} +1 -1
  215. package/dist/shell-source-maps/assets/{board-display-Ck6nnv4b.js.map → board-display-DDFDZzOk.js.map} +1 -1
  216. package/dist/shell-source-maps/assets/{calendar-display-DKXi1P_o.js.map → calendar-display-B0R6JkIL.js.map} +1 -1
  217. package/dist/shell-source-maps/assets/{call-rings-Bs9dtURX.js.map → call-rings-CzvSKlfI.js.map} +1 -1
  218. package/dist/shell-source-maps/assets/{calls-DR-Ci2ND.js.map → calls-BgwbMyeR.js.map} +1 -1
  219. package/dist/shell-source-maps/assets/{circle-alert-C0Jeesr7.js.map → circle-alert-CANqQIsU.js.map} +1 -1
  220. package/dist/shell-source-maps/assets/{composed-page-Bdzzzuyj.js.map → composed-page-gwTeW0b3.js.map} +1 -1
  221. package/dist/shell-source-maps/assets/{composer-section-rLoyhseD.js.map → composer-section-gsOgYgY2.js.map} +1 -1
  222. package/dist/shell-source-maps/assets/{connect-route-B9xNNieq.js.map → connect-route-CtL1EJIN.js.map} +1 -1
  223. package/dist/shell-source-maps/assets/{copy-field-DkCyHPwg.js.map → copy-field-CamvXHHQ.js.map} +1 -1
  224. package/dist/shell-source-maps/assets/{create-route-DBrv5Kqi.js.map → create-route-Cx8yqS-H.js.map} +1 -1
  225. package/dist/shell-source-maps/assets/{custom-step-container-field-Do5pWJ_q.js.map → custom-step-container-field-0-Q_RuZy.js.map} +1 -1
  226. package/dist/shell-source-maps/assets/embedded-list-56J4XDiR.js.map +1 -0
  227. package/dist/shell-source-maps/assets/en-CtEQkQWj.js.map +1 -0
  228. package/dist/shell-source-maps/assets/{export-dialog-CovrAwYy.js.map → export-dialog-CEp2g6vx.js.map} +1 -1
  229. package/dist/shell-source-maps/assets/export-worker-DlWkifnE.js.map +1 -0
  230. package/dist/shell-source-maps/assets/{graph-view-BfRhAOfb.js.map → graph-view-CgjfBK_g.js.map} +1 -1
  231. package/dist/shell-source-maps/assets/{group-donut-DC8GLnC8.js.map → group-donut-DGZUg_gn.js.map} +1 -1
  232. package/dist/shell-source-maps/assets/{guest-call-page-Dc8M5yz6.js.map → guest-call-page-BhTshbrl.js.map} +1 -1
  233. package/dist/shell-source-maps/assets/{html-viewer-DH_s-gLB.js.map → html-viewer-GD1mwLEo.js.map} +1 -1
  234. package/dist/shell-source-maps/assets/{import-dialog-Ge24RdwQ.js.map → import-dialog-ByRCf2Cp.js.map} +1 -1
  235. package/dist/shell-source-maps/assets/{import-table-dialog-D1aVXF3R.js.map → import-table-dialog-CiDY_0RT.js.map} +1 -1
  236. package/dist/shell-source-maps/assets/{invitations-page-CFwYUoqb.js.map → invitations-page-Bh-RCnnl.js.map} +1 -1
  237. package/dist/shell-source-maps/assets/{layout-grid-DCBxzjaE.js.map → layout-grid-DJrFC12w.js.map} +1 -1
  238. package/dist/shell-source-maps/assets/{legend-item-BZXnHPzh.js.map → legend-item-YdN_NHUz.js.map} +1 -1
  239. package/dist/shell-source-maps/assets/{lib-vis.gl-react-maplibre-CdxVSk--.js.map → lib-vis.gl-react-maplibre-1cv426UN.js.map} +1 -1
  240. package/dist/shell-source-maps/assets/{list-page-DwIEEzTz.js.map → list-page-BU1MrXbN.js.map} +1 -1
  241. package/dist/shell-source-maps/assets/{maplibre-C7kZagL3.js.map → maplibre-BedvDUG2.js.map} +1 -1
  242. package/dist/shell-source-maps/assets/{markdown-content-DMl-cVjQ.js.map → markdown-content-BlKajH2l.js.map} +1 -1
  243. package/dist/shell-source-maps/assets/{members-page-BfrzLCXo.js.map → members-page-BYUO0Dq2.js.map} +1 -1
  244. package/dist/shell-source-maps/assets/{messages-D5XhIbDz.js.map → messages-DQ0cj-Ao.js.map} +1 -1
  245. package/dist/shell-source-maps/assets/nl-9OWL4NdF.js.map +1 -0
  246. package/dist/shell-source-maps/assets/{organization-page-DxA2154P.js.map → organization-page-BrC1nHC-.js.map} +1 -1
  247. package/dist/shell-source-maps/assets/{organizations-page-Bf4oXbvZ.js.map → organizations-page-CaUeWdr4.js.map} +1 -1
  248. package/dist/shell-source-maps/assets/parse-worker-NutG5-Js.js.map +1 -0
  249. package/dist/shell-source-maps/assets/{pending-invitation-row-BIO4J3ts.js.map → pending-invitation-row-juUdWvG6.js.map} +1 -1
  250. package/dist/shell-source-maps/assets/{period-chart-CoT2IDzy.js.map → period-chart-BUZhUb5l.js.map} +1 -1
  251. package/dist/shell-source-maps/assets/{person-row-DBeHOA2K.js.map → person-row-DH3JhMfz.js.map} +1 -1
  252. package/dist/shell-source-maps/assets/{public-form-page-Dhinql3j.js.map → public-form-page-d3TamPPE.js.map} +1 -1
  253. package/dist/shell-source-maps/assets/{record-lines-Dmb8bl38.js.map → record-lines-NtlHP9Lz.js.map} +1 -1
  254. package/dist/shell-source-maps/assets/{record-map-BR34Q9uI.js.map → record-map-BDXoF9AS.js.map} +1 -1
  255. package/dist/shell-source-maps/assets/{record-opens-Dbjd4FLe.js.map → record-opens-C1KgR6ff.js.map} +1 -1
  256. package/dist/shell-source-maps/assets/{record-page-Dnpo_8uE.js.map → record-page-D88DdoET.js.map} +1 -1
  257. package/dist/shell-source-maps/assets/{record-preview-CarOT-Gn.js.map → record-preview-BT9_Hdcn.js.map} +1 -1
  258. package/dist/shell-source-maps/assets/{records-map-CXanq-qN.js.map → records-map-BjHcY5gU.js.map} +1 -1
  259. package/dist/shell-source-maps/assets/{render-node-DGYXKoGV.js.map → render-node-v6KfRocH.js.map} +1 -1
  260. package/dist/shell-source-maps/assets/{reorder-button-9_dAk_3O.js.map → reorder-button-B3GeKMOJ.js.map} +1 -1
  261. package/dist/shell-source-maps/assets/{run-trace-view-D1DZCrDs.js.map → run-trace-view-Ddc0SELh.js.map} +1 -1
  262. package/dist/shell-source-maps/assets/{runner-install-field-C2XhrG0M.js.map → runner-install-field-CiD9Pw1j.js.map} +1 -1
  263. package/dist/shell-source-maps/assets/{runtime-update-C5TxLpYf.js.map → runtime-update-CoXcnfxB.js.map} +1 -1
  264. package/dist/shell-source-maps/assets/{sheet-source-DqFYbJpm.js.map → sheet-source-DbJu1SrV.js.map} +1 -1
  265. package/dist/shell-source-maps/assets/{sign-in-policy-page-vjGTg9Do.js.map → sign-in-policy-page-B40iAeJa.js.map} +1 -1
  266. package/dist/shell-source-maps/assets/{start-block-queries-CmVDv8_F.js.map → start-block-queries-C_udrEM9.js.map} +1 -1
  267. package/dist/shell-source-maps/assets/{step-catalog-PWiIgJSI.js.map → step-catalog-7obnZV6X.js.map} +1 -1
  268. package/dist/shell-source-maps/assets/{step-panel-TfW-31Gv.js.map → step-panel-BM_xu6Yy.js.map} +1 -1
  269. package/dist/shell-source-maps/assets/{timeline-display-eBf3tuig.js.map → timeline-display-CdLfWAbQ.js.map} +1 -1
  270. package/dist/shell-source-maps/assets/{trash-BjnGkZfx.js.map → trash-BHo3HvFy.js.map} +1 -1
  271. package/dist/shell-source-maps/assets/{update-set-BahNKmxv.js.map → update-set-DTikSoau.js.map} +1 -1
  272. package/dist/shell-source-maps/assets/{use-calendar-move-Bfp2yC0P.js.map → use-calendar-move-Bhha2yOp.js.map} +1 -1
  273. package/dist/shell-source-maps/assets/{use-display-rows-DsBBYuKB.js.map → use-display-rows-CS_0O_UE.js.map} +1 -1
  274. package/dist/shell-source-maps/assets/{use-paged-search-DaT4uUhX.js.map → use-paged-search-ChxCRCpF.js.map} +1 -1
  275. package/dist/shell-source-maps/assets/{use-run-trace-DHk7l8MX.js.map → use-run-trace-BfRRgSgG.js.map} +1 -1
  276. package/dist/shell-source-maps/assets/{use-workflow-page-DPIhXcnb.js.map → use-workflow-page-CTdBd8_8.js.map} +1 -1
  277. package/dist/shell-source-maps/assets/{use-workflow-types-Bp8iqkBg.js.map → use-workflow-types-cZQ59ATf.js.map} +1 -1
  278. package/dist/shell-source-maps/assets/{vendor-DQHyyBk1.js.map → vendor-t7Q7QbPu.js.map} +1 -1
  279. package/dist/shell-source-maps/assets/{workflow-canvas-CiGUTx4K.js.map → workflow-canvas-B0kWJeH0.js.map} +1 -1
  280. package/dist/shell-source-maps/assets/{workflow-field-lqBx3RDj.js.map → workflow-field-DXIk6V2Y.js.map} +1 -1
  281. package/dist/shell-source-maps/assets/{workflow-graph-editor-DgufTFii.js.map → workflow-graph-editor-Cem4aY2u.js.map} +1 -1
  282. package/dist/shell-source-maps/assets/{workflow-run-field-C4BtvPnB.js.map → workflow-run-field-BeMn3eOH.js.map} +1 -1
  283. package/dist/shell-source-maps/assets/{workflow-status-field-CqDaP0V9.js.map → workflow-status-field-0wvGDiva.js.map} +1 -1
  284. package/dist/shell-source-maps/assets/{workflow-workbench-CgL6wHPG.js.map → workflow-workbench-qT5c0xnH.js.map} +1 -1
  285. package/dist/status/messages.d.ts +2 -2
  286. package/dist/status/status-dialog.js +1 -1
  287. package/dist/theme.css +6 -0
  288. package/dist/users/messages.d.ts +2 -2
  289. package/package.json +5 -5
  290. package/dist/shell/assets/app-BnDutf0s.js +0 -34
  291. package/dist/shell/assets/app-DcrDZ6Fc.css +0 -2
  292. package/dist/shell/assets/board-display-Ck6nnv4b.js +0 -2
  293. package/dist/shell/assets/call-rings-Bs9dtURX.js +0 -2
  294. package/dist/shell/assets/composed-page-Bdzzzuyj.js +0 -2
  295. package/dist/shell/assets/create-route-DBrv5Kqi.js +0 -2
  296. package/dist/shell/assets/embedded-list-CPgxhzPw.js +0 -3
  297. package/dist/shell/assets/en-B0Sx6LpA.js +0 -2
  298. package/dist/shell/assets/export-worker-DnXy8F95.js +0 -15
  299. package/dist/shell/assets/import-table-dialog-D1aVXF3R.js +0 -2
  300. package/dist/shell/assets/invitations-page-CFwYUoqb.js +0 -2
  301. package/dist/shell/assets/list-page-DwIEEzTz.js +0 -4
  302. package/dist/shell/assets/maplibre-C7kZagL3.js +0 -2
  303. package/dist/shell/assets/members-page-BfrzLCXo.js +0 -2
  304. package/dist/shell/assets/nl-DD4sTnQJ.js +0 -2
  305. package/dist/shell/assets/organization-page-DxA2154P.js +0 -2
  306. package/dist/shell/assets/organizations-page-Bf4oXbvZ.js +0 -2
  307. package/dist/shell/assets/parse-worker-BYXW4dAv.js +0 -35
  308. package/dist/shell/assets/public-form-page-Dhinql3j.js +0 -2
  309. package/dist/shell/assets/record-lines-Dmb8bl38.js +0 -2
  310. package/dist/shell/assets/record-page-Dnpo_8uE.js +0 -3
  311. package/dist/shell/assets/record-preview-CarOT-Gn.js +0 -2
  312. package/dist/shell/assets/render-node-DGYXKoGV.js +0 -3
  313. package/dist/shell/assets/reorder-button-9_dAk_3O.js +0 -2
  314. package/dist/shell/assets/shared-protobase-ui-HnfzBwws.js +0 -1
  315. package/dist/shell/assets/sheet-source-DqFYbJpm.js +0 -3
  316. package/dist/shell/assets/sign-in-policy-page-vjGTg9Do.js +0 -2
  317. package/dist/shell/assets/start-block-queries-CmVDv8_F.js +0 -2
  318. package/dist/shell/assets/step-catalog-PWiIgJSI.js +0 -2
  319. package/dist/shell/assets/timeline-display-eBf3tuig.js +0 -2
  320. package/dist/shell/assets/use-calendar-move-Bfp2yC0P.js +0 -2
  321. package/dist/shell/assets/workflow-status-field-CqDaP0V9.js +0 -2
  322. package/dist/shell/assets/workflow-workbench-CgL6wHPG.js +0 -4
  323. package/dist/shell-source-maps/assets/app-BnDutf0s.js.map +0 -1
  324. package/dist/shell-source-maps/assets/embedded-list-CPgxhzPw.js.map +0 -1
  325. package/dist/shell-source-maps/assets/en-B0Sx6LpA.js.map +0 -1
  326. package/dist/shell-source-maps/assets/export-worker-DnXy8F95.js.map +0 -1
  327. package/dist/shell-source-maps/assets/nl-DD4sTnQJ.js.map +0 -1
  328. package/dist/shell-source-maps/assets/parse-worker-BYXW4dAv.js.map +0 -1
@@ -0,0 +1,34 @@
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-BU1MrXbN.js","assets/react-CuiNlnus.js","assets/vendor-t7Q7QbPu.js","assets/view-chart-ChBtewKd.js","assets/embedded-list-56J4XDiR.js","assets/update-set-DTikSoau.js","assets/layout-grid-DJrFC12w.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-BT9_Hdcn.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-B3GeKMOJ.js","assets/messages-DQ0cj-Ao.js","assets/trash-BHo3HvFy.js","assets/page-header-Ddz2r5ic.js","assets/use-display-rows-CS_0O_UE.js","assets/list-page-GUjJKojE.css","assets/record-page-D88DdoET.js","assets/render-node-v6KfRocH.js","assets/circle-alert-CANqQIsU.js","assets/pending-invitation-row-juUdWvG6.js","assets/person-row-DH3JhMfz.js","assets/use-paged-search-ChxCRCpF.js","assets/client-publisher-D39SlIhp.js","assets/copy-field-CamvXHHQ.js","assets/record-sidebar-HqyBXBwn.js","assets/start-block-queries-C_udrEM9.js","assets/record-opens-C1KgR6ff.js","assets/create-route-Cx8yqS-H.js","assets/composed-page-gwTeW0b3.js","assets/account-page-dcJyxP-d.js","assets/sign-in-policy-page-B40iAeJa.js","assets/organization-page-BrC1nHC-.js","assets/organizations-page-CaUeWdr4.js","assets/members-page-BYUO0Dq2.js","assets/invitations-page-Bh-RCnnl.js","assets/connect-route-CtL1EJIN.js","assets/public-form-page-d3TamPPE.js","assets/lib-altcha-lib-BK1uKcxH.js","assets/guest-call-page-BhTshbrl.js","assets/assistant-shell-Bw1jJrLm.js","assets/call-rings-CzvSKlfI.js","assets/runtime-update-CoXcnfxB.js","assets/workflow-field-DXIk6V2Y.js","assets/use-run-trace-BfRRgSgG.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-cZQ59ATf.js","assets/use-workflow-page-CTdBd8_8.js","assets/workflow-run-field-BeMn3eOH.js","assets/workflow-status-field-0wvGDiva.js","assets/lib-zod-B92j-KH2.js","assets/custom-step-container-field-0-Q_RuZy.js","assets/runner-install-field-CiD9Pw1j.js","assets/markdown-content-BlKajH2l.js","assets/lib-dompurify-Dr60P-Rn.js","assets/lib-marked-Bg9_sE-m.js","assets/html-viewer-GD1mwLEo.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 j,x as ie,y as ae}from"./vendor-t7Q7QbPu.js";var M=e(n(),1),N=e(i(),1),oe=r(),P=t({default:()=>se}),se={},ce=(e,t)=>{try{return e()}catch(e){if(!(e instanceof DOMException))throw e;return t}},le=e=>e.addEventListener(`touchstart`,ue,{passive:!0}),ue=()=>{},de=(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(de(`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(de(`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(de(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(de(`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(de(`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(de(`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`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=>de(`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(de(`invalid-value`,r.message,r.hint,n.span)),!r},Ze=(e,t,n,r)=>{e.errors.push(de(`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(de(`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(de(`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=>de(`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)=>{let n=Object.hasOwn(t.fields,e.by)?t.fields[e.by]:void 0;return n?n.type===`enum`?n.filterable?[]:[`"${e.by}" on ${t.name} is not filterable, and each column of the board filters by its value`]:[`"${e.by}" on ${t.name} is ${n.type}, not an enum, whose values are the board's columns`]:[]},Mn=(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)]:[]]},Nn=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),Pn=/^[a-z0-9][a-z0-9_-]*$/,Fn=e=>{if(!e.startsWith(`/-/forms/`))return;let t=e.slice(9);return Pn.test(t)?{name:t}:void 0},In=e=>e.flatMap(e=>e.kind===`group`||e.kind===`tab`?In(e.items):e.kind===`custom`?[e,...In(e.fallback??[])]:[e]),Ln=(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}},Rn=[`neutral`,`info`,`success`,`warning`,`danger`],zn=20,Bn=(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},Vn=(e,t)=>{let n=St(t);if(!n.ok)return n.errors;let r=Ct(e,n.items);return r.ok?[]:r.errors},Hn=(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])=>!Rn.includes(e)).map(([e,t])=>`tone "${t}" for "${e}" is not one of ${Rn.join(`, `)}`),...e.limit===void 0||Number.isInteger(e.limit)&&e.limit>=1&&e.limit<=zn?[]:[`limit must be a whole number from 1 to ${zn}`],...e.filter===void 0?[]:Bn(t,e.filter).map(e=>`filter: ${e.message}`),...e.orderBy===void 0?[]:Vn(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`]],Un=[`neutral`,`blue`,`green`,`amber`,`red`,`violet`],Wn=e=>Un.includes(e),Gn=e=>`${e}/workflows/types`,Kn=(e,t)=>`${e}/workflows/runners/${encodeURIComponent(t)}/registration`,qn=e=>`${e}/workflows/runs`,Jn=`after`,Yn=`revision`,Xn=(e,t,n)=>{let r=`${qn(e)}/${encodeURIComponent(t)}/trace`;return!n||n.after===0?r:`${r}?${new URLSearchParams({[Jn]:String(n.after),[Yn]:n.revision})}`},Zn=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(`,`)},Qn=e(l(),1),$n=e=>{try{return new Qn.default.Comparator(e),!0}catch(e){if(e instanceof TypeError)return!1;throw e}},er=(e,t)=>{let n=t.trim().split(/\s+/);if(Qn.default.valid(e)!==null&&t.trim()!==``&&n.every($n))return Qn.default.satisfies(e,t,{includePrerelease:!0})},tr=(e,t)=>{if(e.api!==t.api)return`it is built for plugin API ${e.api}, and this app has plugin API ${t.api}`;let n=er(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}`},nr=`[Filtered]`,rr=/authorization|cookie|passw|secret|token|api[-_]?key|credential|session|csrf|signature|^sig$/i,ir=new Set([`url`,`query_string`,`from`,`to`]),ar=12,or=e=>e.replace(/(^|&)([^=&]*)=([^&]*)/g,(e,t,n)=>rr.test(n)?`${t}${n}=${nr}`:e),sr=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)}${or(r)}${n===-1?``:e.slice(n)}`},cr=(e,t,n)=>rr.test(e)?nr:typeof t==`string`&&ir.has(e)?e===`query_string`?or(t):sr(t):lr(t,n+1),lr=(e,t)=>t>ar||typeof e!=`object`||!e?e:Array.isArray(e)?e.map(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`?[e[0],cr(e[0],e[1],t)]:lr(e,t+1)):Object.fromEntries(Object.entries(e).map(([e,n])=>[e,cr(e,n,t)])),ur=e=>lr(e,0),dr=`protobase-app`,fr=[`unknown-field`,`not-filterable`,`not-sortable`,`unsupported-traversal`,`invalid-traversal`],pr=e=>e.replace(/(["']?)\{\{\s*[^{}]*?\s*\}\}\1/g,(e,t)=>t?`${t}x${t}`:`0`),mr=(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(pr(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=>fr.includes(e.code)).map(e=>`filter: ${e.message}`)},hr=(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}`)},gr=(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?mr(n,e.filter):[],...e.orderBy?hr(n,e.orderBy):[]]:s:[`unknown resource "${e.resource}"`]}default:return[`an address's kind is list, record, create or page, not "${String(e.kind)}"`]}},_r=e=>typeof e==`object`&&!!e&&!Array.isArray(e),vr=`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`,yr=e=>Array.isArray(e)?e:[e],br=e=>{let t=e.href;return t===void 0?{to:e.to}:{href:t}},xr=e=>{let t=br(e);return[...new Set([...qt(e.label),...`href`in t?qt(t.href):Kt(t.to)])]},Sr=e=>[...new Set(yr(e).flatMap(xr))],Cr=(e,t,n)=>e.flatMap(e=>Object.hasOwn(t.fields,e)?[]:[`${n}: "{{${e}}}" is not a field of ${t.name}`]),wr=(e,t,n)=>{if(!_r(e))return[vr];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=Cr(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,...Cr([n],t,`href`)]}return!_r(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,...gr(e.to,{...n,source:t,filterFromRecord:!0}).map(e=>`to: ${e}`)]},Tr=(e,t,n)=>Array.isArray(e)?e.length===0?[`a row button list needs at least one choice`]:e.flatMap((e,r)=>wr(e,t,n).map(e=>`choice ${r+1}: ${e}`)):wr(e,t,n),Er=(e,t,n)=>{if(!Array.isArray(e))return Tr(e,t,n).length===0?e:void 0;let r=yr(e).filter(e=>wr(e,t,n).length===0);return r.length===0?void 0:r},Dr={messages:[],replying:!1},Or=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);return n===-1?[...e,t]:e.map((e,r)=>r===n?t:e)},kr=(e,t,n)=>{let r=e.find(e=>e.id===t);return Or(e,r?{...r,parts:Or(r.parts,n)}:{id:t,from:`assistant`,parts:[n]})},Ar=(e,t)=>{switch(t.type){case`state`:return t.state;case`message`:return{...e,messages:Or(e.messages,t.message)};case`part`:return{...e,messages:kr(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}}}}},jr=e=>{if(!(e instanceof DOMException&&e.name===`AbortError`))throw e},Mr=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(jr),{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`)},Nr=[`en`,`nl`],Pr=e=>Nr.includes(e),Fr=e=>e.map(e=>e.split(`-`)[0].toLowerCase()).find(Pr)??`en`,Ir=e=>e.charAt(0).toUpperCase()+e.slice(1),F=e=>Ir(e.replace(/(Id|Code|_id|_code)$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/_+/g,` `).trim().toLowerCase()||e),Lr=(e,t)=>t?.[e]??e,Rr=[`name`,`title`,`number`,`sku`,`email`,`code`,`description`],zr=e=>e?.type===`text`&&!e.sensitive,Br=(e,t)=>t?.title??Rr.find(t=>zr(e.fields[t]))??Object.values(e.fields).find(zr)?.name??e.primaryKey[0],Vr=(e,t)=>t?.title??t?.list?.columns.find(t=>e.fields[t]?.type===`text`)??Br(e),Hr=(e,t,n,r)=>{let i=Vr(e,t),a=n[i];return a==null?r:e.fields[i]?.type===`enum`?Lr(String(a),t?.fields[i]?.valueLabels):String(a)},Ur=`protobase-api-origin`,Wr={fingerprint:`fingerprint`,shellVersion:`shell_version`},Gr=`/api/mobile/release`,Kr=`/api/mobile/releases`,qr=({fingerprint:e,shellVersion:t})=>new URLSearchParams({[Wr.fingerprint]:e,[Wr.shellVersion]:t}).toString(),Jr=`/api/auth`,Yr=`second-step`,Xr={ios:`capacitor://localhost`,android:`https://localhost`},Zr={database:`protobase-push`,store:`registration`,key:`current`},Qr=`protobase.sw.js`,$r=`token`,ei=(e,t)=>`${e}?${new URLSearchParams({[$r]:t})}`,ti=(e,t)=>`${e}/notifications/devices${t===void 0?``:`/${encodeURIComponent(t)}`}`,ni=`app`,ri=e=>`${e}/files`,ii=(e,t,n)=>`${e}/${t}/${n}`,ai=e=>{let t=/^([a-z][a-z0-9-]*):([A-Za-z0-9_-][^?#]*)/.exec(e);return t?{provider:t[1],path:t[2]}:void 0},oi=e=>`${e}${e.includes(`?`)?`&`:`?`}via=${ni}`,si=/^[^\s\u0000-\u001f\u007f-\u009f]+$/,ci=e=>{if(typeof e!=`string`||e.length>2048||!si.test(e)||!URL.canParse(e))return;let t=new URL(e);if(t.protocol===`https:`||t.protocol===`http:`)return t.href},li=/^[A-Za-z0-9_-]{1,64}$/,ui=(e,t)=>{let n=`${e}/notifications/history`;if(t===void 0)return n;if(typeof t==`string`)return`${n}/${t}`;if(!li.test(t.read))throw Error(`A history entry id is letters, digits, "_" and "-" only`);return`${n}/${t.read}/read`},di=(e,t)=>`${e}/status${t===void 0?``:`/${t}`}`,fi=/\p{Cc}/u,pi=e=>{if(fi.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`},mi=(e,t=Date.now())=>{if(e&&!(e.clearsAt!==null&&Date.parse(e.clearsAt)<=t)&&(e.availability!==`automatic`||e.text!==null))return e},hi=(e,t)=>t?.list?.columns??Object.values(e.fields).filter(e=>!e.writeOnly).slice(0,6).map(e=>e.name),gi={json:[`json`],members:[`json`],workflow:[`json`],workflow_run:[`uuid`],workflow_status:[`enum`],custom_step_container:[`json`],runner_install:[`uuid`]},_i=(e,t)=>`${e}/calls/guests${t?`/${t}`:``}`,vi=`$rings`,yi=`decline`,bi=(e,t)=>{let n=`${e}/calls/rings`;return t===void 0?n:`${n}/${encodeURIComponent(t.decline)}/${yi}`},xi=`calls`,Si=`en`,Ci,wi=()=>Ci??Si,Ti=()=>Si,Ei=e=>{Si=e},Di=e=>{Ci=e},Oi=(e=globalThis.navigator?.languages??[])=>Fr(e),ki={en:`en-GB`,nl:`nl-NL`},Ai=()=>ki[wi()],ji={en:()=>s(()=>import(`./en-CtEQkQWj.js`).then(e=>e.default),[]),nl:()=>s(()=>import(`./nl-9OWL4NdF.js`).then(e=>e.default),[])},Mi={},Ni=new Map,Pi=(e,t)=>{Mi[e]=t},Fi=e=>Mi[e]!==void 0,Ii=e=>{if(Fi(e))return Promise.resolve();let t=Ni.get(e)??ji[e]().then(t=>Pi(e,t));return Ni.set(e,t),t},Li=async e=>{await Ii(e),Ei(e)},Ri=e=>{let t=Mi[e];if(!t)throw Error(`The ${e} texts are not loaded: await loadTexts('${e}') first`);return t},zi={lower:e=>e.join(``).toLowerCase()},Bi=new Map,Vi=(e,t)=>{let n=wi(),r=`${n}\0${e}\0${t}`,i=Bi.get(r);if(i)return i;let a=Ri(n)[e][t];if(a===void 0)throw Error(`No text ${e}.${t} in ${n}`);let o=new j(a,Ai());return Bi.set(r,o),o},I=e=>{let t=(t,n)=>Vi(e,t).format({...n,...zi});return t.rich=(t,n)=>{let r=Vi(e,t).format({...n,...zi});return Array.isArray(r)?(0,M.createElement)(M.Fragment,null,...r):r},t},L={meta:[`meta`],activeRole:[`session`,`active-role`],organizations:[`session`,`organizations`],organizationMembers:e=>[`session`,`members`,e],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`],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]},Hi=(e,t)=>t.has(e[1])||e[0]===`plan`&&e[2].some(e=>t.has(e)),Ui=e=>{let t=e?.session();if(t)return(e?.queries(`user:${t.user.id}`)?.state.queries.find(e=>JSON.stringify(e.queryKey)===JSON.stringify(L.meta)))?.state.data},Wi=e=>Ui(e)?.plugins??[],Gi={name:`@protobase/ui`,version:`0.117.0`,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`}},Ki=Gi.protobase.pluginApi,qi=Gi.version,Ji=`session`,Yi=`queries`,Xi=e=>`user:${e.user.id}`,Zi=async(e,t)=>{let[n,r]=await Promise.all([e.read(Ji),e.read(Yi)]),i=n?.buster===t?n.value:void 0,a=r?.buster===t&&i&&r.value.owner===Xi(i)?r.value:void 0,o=[...n&&!i?[Ji]:[],...r&&!a?[Yi]:[]];return o.length>0&&await e.remove(o),{session:()=>i,queries:e=>a?.owner===e?a:void 0,saveSession:n=>(a&&a.owner!==Xi(n)&&(a=void 0),i=n,e.write(Ji,{buster:t,value:n})),saveQueries:n=>(a=n,e.write(Yi,{buster:t,value:n})),clear:()=>(i=void 0,a=void 0,e.remove([Ji,Yi]))}},Qi=(0,M.createContext)(void 0),$i=Qi.Provider,ea=()=>(0,M.useContext)(Qi),ta=`protobase-start-cache`,na=`records`,ra=(e=indexedDB)=>{let t,n=()=>t??=new Promise((t,n)=>{let r=e.open(ta,1);r.onupgradeneeded=()=>r.result.createObjectStore(na),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(na,e),o=t(a.objectStore(na));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)})}},ia=async()=>{if(typeof indexedDB<`u`)try{return await Zi(ra(),qi)}catch(e){if(e instanceof DOMException)return;throw e}},aa=I(`plugins`),oa=e=>typeof e==`string`&&e.trim()!==``,sa=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return{problem:aa(`notObject`)};let{name:t,version:n,api:r,protobase:i,entry:a,css:o}=e;return oa(t)?Number.isInteger(r)?oa(i)?oa(a)?o!==void 0&&!oa(o)?{problem:aa(`badStylesheet`)}:n!==void 0&&!oa(n)?{problem:aa(`badVersion`)}:{manifest:{name:t,api:r,protobase:i,entry:a,...n!==void 0&&{version:n},...o!==void 0&&{css:o}}}:{problem:aa(`noModule`)}:{problem:aa(`noVersions`)}:{problem:aa(`noApi`)}:{problem:aa(`noName`)}},ca=/^[A-Z][A-Za-z0-9]*$/,la=e=>typeof e==`function`||typeof e==`object`&&!!e&&`$$typeof`in e,ua=e=>{let t=e.default??{},n=Object.entries(e).filter(e=>e[0]!=="default"&&ca.test(e[0])&&la(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)}}},R=e(a(),1),da=class extends Error{name=`UiConflictError`},fa=e=>Object.keys(e).some(e=>e==="default"||/^[A-Z]/.test(e))?ua(e):e,pa=(e,t)=>[...(e.extends??[]).map(fa).flatMap((e,n)=>pa(e,e.name??`${t} extends[${n}]`)),{ui:e,label:t}],ma=(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 da(`${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},ha=e=>e.length<=1?e[0]:()=>e.map((e,t)=>(0,R.jsx)(e,{},t)),ga=e=>e.length<=1?e[0]:({children:t,...n})=>e.reduceRight((e,t)=>(0,R.jsx)(t,{...n,children:e}),t),_a=(...e)=>{let t=e.flatMap((e,t)=>pa(e,e.name??`UI config ${t+1}`)),n=ma(`The component`,t,e=>e.components),r=ma(`The action handler`,t,e=>e.actions),i=ma(`The field type`,t,e=>e.fields),a=ma(`The file viewer`,t,e=>e.fileViewers),o=ma(`The drop rule`,t,e=>e.dropRules),s=ma(`The board drop`,t,e=>e.boardDrops),c=ma(`The title rule`,t,e=>e.titles),l=ma(`The marks hook`,t,e=>e.marks),u=ha(t.flatMap(({ui:e})=>e.shell?.actions?[e.shell.actions]:[])),d=ha(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=ga(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}}},va=(0,M.createContext)(null),ya=va.Provider,ba=()=>{let e=(0,M.useContext)(va);if(!e)throw Error(`usePlugin is for the components of a plugin the app loaded`);return e},xa=(e,t,n)=>{let r=n=>(0,R.jsx)(ya,{value:e,children:(0,R.jsx)(t,{...n})});return r.displayName=`${e.name}:${n}`,r},Sa=(e,t,n)=>({of:n.of,display:xa(e,n.display,`fields.${t}.display`),...n.editor&&{editor:xa(e,n.editor,`fields.${t}.editor`)},...n.cell&&{cell:xa(e,n.cell,`fields.${t}.cell`)}}),Ca=(e,t)=>{let n=_a({...ua(t),name:e.name}),r=Object.fromEntries(Object.entries(n.components??{}).map(([t,n])=>[t,xa(e,n,t)])),i=n.fields&&Object.fromEntries(Object.entries(n.fields).map(([t,n])=>[t,Sa(e,t,n)])),a=n.fileViewers&&Object.fromEntries(Object.entries(n.fileViewers).map(([t,n])=>[t,{component:xa(e,n.component,`fileViewers.${t}`)}])),o=n.shell&&{...n.shell.actions&&{actions:xa(e,n.shell.actions,`shell.actions`)},...n.shell.rightPanel&&{rightPanel:xa(e,n.shell.rightPanel,`shell.rightPanel`)},...n.shell.logo&&{logo:xa(e,n.shell.logo,`shell.logo`)},...n.shell.bell&&{bell:xa(e,n.shell.bell,`shell.bell`)}},s=n.beforeSignIn&&xa(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}}},wa={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),[])},Ta={api:Ki,version:qi},Ea=e=>e instanceof Error?e.message:String(e),Da=async(e,t,n,r=Ta)=>{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(aa(`answered`,{status:n.status}));let s=sa(n.json);if(`problem`in s)return a(s.problem);let{manifest:c}=s;o=c.name;let l=tr(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:Ca(d,u)}}catch(e){return a(aa(`couldNotLoad`,{reason:Ea(e)}),o)}},Oa=`protobase:plugins-changed`,ka=(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=Da(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))}},Aa=(e,t,n)=>Promise.race([Promise.all(t.map(t=>e.load(t))),new Promise(e=>setTimeout(e,n))]).then(()=>void 0),ja=(0,M.createContext)(null),Ma=({loader:e=wa,source:t,children:n})=>{let r=(0,M.useMemo)(()=>t??ka(e),[t,e]);return(0,M.useEffect)(()=>{let e=()=>r.forget();return window.addEventListener(Oa,e),()=>window.removeEventListener(Oa,e)},[r]),(0,R.jsx)(ja.Provider,{value:r,children:n})},Na=()=>{let e=(0,M.useContext)(ja);if(!e)throw Error(`usePluginSource must be used inside PluginSourceProvider`);return e},Pa=1e4,Fa=[],Ia=(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)(()=>La(e,t,i)??{key:`[]`,loads:Fa,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()},Pa);return e.forEach((e,n)=>{t.load(e).then(e=>{s[n]=e,c()})}),()=>{n=!1,clearTimeout(l)}},[i,t]),e.length===0?{loads:Fa,settled:!0}:a.key===i||a.refs===r&&a.settled?a:La(e,t,i)??{loads:Fa,settled:!1}},La=(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},Ra=`protobase.liveUpdate.page`,za=e=>typeof e==`string`&&e.startsWith(`/`)&&!e.startsWith(`//`),Ba=(e,t,n)=>{let r=n.state,i=typeof r?.protobaseEntry==`string`?r.protobaseEntry:void 0;e.setItem(Ra,JSON.stringify({url:`${t.pathname}${t.search}${t.hash}`,entry:i}))},Va=e=>e.removeItem(Ra),Ha=e=>e.getItem(Ra)!==null,Ua=(e,t)=>{let n=e.getItem(Ra);if(n===null)return;Va(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;za(i)&&t.replaceState(typeof a==`string`?{protobaseEntry:a}:null,``,i)},Wa=()=>{let e=ce(()=>window.sessionStorage,void 0);return e&&{keep:()=>Ba(e,window.location,window.history),forget:()=>Va(e)}},z=(...e)=>e.filter(Boolean).join(` `),Ga=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function Ka(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:Ga(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var qa=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},Ja=e=>{let t=qa(e);return t.charAt(0).toUpperCase()+t.slice(1)},Ya=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Xa={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 Za(e){return e!=null}function Qa(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??Xa.width,a=e.size??e.height??Xa.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?Ya(...c):Ya(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??Xa[`stroke-width`])*Number(e.size??e.width??Xa.width)/Number(t.size??t.width??Xa.width):t.strokeWidth??Xa[`stroke-width`];return[`svg`,{...Object.entries(Xa).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&Za(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&Za(t.width)&&{[r(`width`)]:t.width},...`height`in t&&Za(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 $a(e,t={}){return Qa(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var eo=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},to=(0,M.createContext)({}),no=()=>(0,M.useContext)(to),ro=(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=``}=no()??{},y=!!c||eo(d),[b,x,S=[]]=$a(u,{color:e??_,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??g,className:Ya(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 B(e,t=[],n=[]){let r=typeof e==`string`?Ka(e,t,n):e,i=(0,M.forwardRef)(({className:e,...t},n)=>(0,M.createElement)(ro,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=Ja(r.name)),i}var io={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`}]]};io.node;var ao=B(io),oo={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};oo.node;var so=B(oo),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 lo=B(co),uo={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};uo.node;var fo=B(uo),po={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`}]]};po.node;var mo=B(po),ho={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`}]]};ho.node;var go=B(ho),_o={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`}]]};_o.node;var vo=B(_o),yo={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`}]]};yo.node;var bo=B(yo),xo={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`}]]};xo.node;var So=B(xo),Co={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`}]]};Co.node;var wo=B(Co),To={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`}]]};To.node;var Eo=B(To),Do={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`}]]};Do.node;var Oo=B(Do),ko={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`]};ko.node;var Ao=B(ko),jo={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`}]]};jo.node;var Mo=B(jo),No={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`}]]};No.node;var Po=B(No),Fo={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Fo.node;var Io=B(Fo),Lo={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};Lo.node;var Ro=B(Lo),zo={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};zo.node;var Bo=B(zo),Vo={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Vo.node;var Ho=B(Vo),Uo={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`}]]};Uo.node;var Wo=B(Uo),Go={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`]};Go.node;var Ko=B(Go),qo={name:`circle-minus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-circle`]};qo.node;var Jo=B(qo),Yo={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`]};Yo.node;var Xo=B(Yo),Zo={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Zo.node;var Qo=B(Zo),$o={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};$o.node;var es=B($o),ts={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`}]]};ts.node;var ns=B(ts),rs={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`}]]};rs.node;var is=B(rs),as={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`}]]};as.node;var os=B(as),ss={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`}]]};ss.node;var cs=B(ss),ls={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`}]]};ls.node;var us=B(ls),ds={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`]};ds.node;var fs=B(ds),ps={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`]};ps.node;var ms=B(ps),hs={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`]};hs.node;var gs=B(hs),_s={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`}]]};_s.node;var vs=B(_s),ys={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`}]]};ys.node;var bs=B(ys),xs={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`}]]};xs.node;var Ss=B(xs),Cs={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`]};Cs.node;var ws=B(Cs),Ts={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`]};Ts.node;var Es=B(Ts),Ds={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`}]]};Ds.node;var Os=B(Ds),ks={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`}]]};ks.node;var As=B(ks),js={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`}]]};js.node;var Ms=B(js),Ns={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`]};Ns.node;var Ps=B(Ns),Fs={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`}]]};Fs.node;var Is=B(Fs),Ls={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`}]]};Ls.node;var Rs=B(Ls),zs={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`}]]};zs.node;var Bs=B(zs),Vs={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`}]]};Vs.node;var Hs=B(Vs),Us={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`}]]};Us.node;var Ws=B(Us),Gs={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`}]]};Gs.node;var Ks=B(Gs),qs={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};qs.node;var Js=B(qs),Ys={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`}]]};Ys.node;var Xs=B(Ys),Zs={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`}]]};Zs.node;var Qs=B(Zs),$s={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`}]]};$s.node;var ec=B($s),tc={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`}]]};tc.node;var nc=B(tc),rc={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};rc.node;var ic=B(rc),ac={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`}]]};ac.node;var oc=B(ac),sc={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`}]]};sc.node;var cc=B(sc),lc={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};lc.node;var uc=B(lc),dc={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`}]]};dc.node;var fc=B(dc),pc={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`}]]};pc.node;var mc=B(pc),hc={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`}]]};hc.node;var gc=B(hc),_c={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`}]]};_c.node;var vc=B(_c),yc={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`}]]};yc.node;var bc=B(yc),xc={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`}]]};xc.node;var Sc=B(xc),Cc={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`}]]};Cc.node;var wc=B(Cc),Tc={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`}]]};Tc.node;var Ec=B(Tc),Dc={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`}]]};Dc.node;var Oc=B(Dc),kc={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`}]]};kc.node;var Ac=B(kc),jc={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`}]]};jc.node;var Mc=B(jc),Nc={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`}]]};Nc.node;var Pc=B(Nc),Fc={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Fc.node;var Ic=B(Fc),Lc={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`}]]};Lc.node;var Rc=B(Lc),zc={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`}]]};zc.node;var Bc=B(zc),Vc={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`}]]};Vc.node;var Hc=B(Vc),Uc={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`]};Uc.node;var Wc=B(Uc),Gc={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`}]]};Gc.node;var Kc=B(Gc),qc={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`}]]};qc.node;var Jc=B(qc),Yc={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Yc.node;var Xc=B(Yc),Zc={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`]};Zc.node;var Qc=B(Zc),$c={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`}]]};$c.node;var el=B($c),tl={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`}]]};tl.node;var nl=B(tl),rl={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`}]]};rl.node;var il=B(rl),al={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`}]]};al.node;var ol=B(al),sl={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`}]]};sl.node;var cl=B(sl),ll={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`]};ll.node;var ul=B(ll),dl={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};dl.node;var fl=B(dl),pl={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`}]]};pl.node;var ml=B(pl),hl={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`}]]};hl.node;var gl=B(hl),_l={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`}]]};_l.node;var vl=B(_l),yl={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`}]]};yl.node;var bl=B(yl),xl={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`}]]};xl.node;var Sl=B(xl),Cl={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Cl.node;var wl=B(Cl),Tl={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`]};Tl.node;var El=B(Tl),Dl={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`}]]};Dl.node;var Ol=B(Dl),kl={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`}]]};kl.node;var Al=B(kl),jl={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`]};jl.node;var Ml=B(jl),Nl={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`]};Nl.node;var Pl=B(Nl),Fl={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`}]]};Fl.node;var Il=B(Fl),Ll={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`}]]};Ll.node;var Rl=B(Ll),zl={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`}]]};zl.node;var Bl=B(zl),Vl={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`}]]};Vl.node;var Hl=B(Vl),Ul={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`}]]};Ul.node;var Wl=B(Ul),Gl={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`}]]};Gl.node;var Kl=B(Gl),ql={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`}]]};ql.node;var Jl=B(ql),Yl={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};Yl.node;var Xl=B(Yl),Zl=I(`primitives`),Ql=({className:e,hidden:t=!1})=>(0,R.jsx)(Js,{...t?{"aria-hidden":!0}:{"aria-label":Zl(`loading`)},className:z(`size-4 animate-spin`,e)}),$l={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`},eu={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`},tu=({variant:e=`secondary`,size:t=`md`}={})=>z(`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`,$l[e],eu[t]),V=({variant:e=`secondary`,size:t=`md`,loading:n,className:r,children:i,disabled:a,...o})=>(0,R.jsxs)(`button`,{type:`button`,disabled:a||n,"aria-busy":n||void 0,className:z(tu({variant:e,size:t}),r),...o,children:[n&&(0,R.jsx)(Ql,{hidden:!0,className:`size-3.5`}),i]}),nu=`data-pb-scroll-locked`,ru=()=>{let{body:e,documentElement:t}=document,n=e.style.overflow,r=t.hasAttribute(nu);return window.innerWidth>t.clientWidth&&t.setAttribute(nu,``),e.style.overflow=`hidden`,()=>{e.style.overflow=n,r||t.removeAttribute(nu)}},iu=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,au=[],ou=(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=ru(),o={};au.push(o);let s=()=>[...n.querySelectorAll(iu)];(s()[0]??n).focus();let c=e=>{if(au.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),au.splice(au.indexOf(o),1),a(),i?.focus()}},[t,e])},su=({title:e,description:t,onClose:n,actions:r,children:i,wide:a=!1,name:o})=>{let s=(0,M.useRef)(null);return ou(s,!0,n),(0,N.createPortal)((0,R.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,R.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,className:z(`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,R.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t&&(0,R.jsx)(`p`,{className:`mt-1.5 text-muted-foreground`,children:t}),i&&(0,R.jsx)(`div`,{className:`mt-4`,children:i}),(0,R.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)},cu=({className:e,style:t})=>(0,R.jsx)(`span`,{"data-placeholder":!0,className:z(`block h-3 rounded bg-muted`,uu,e),style:t}),lu=`[animation:pb-reveal_1ms_180ms_backwards]`,uu=`[animation:pb-reveal_1ms_180ms_backwards,pb-shimmer_1.4s_180ms_ease-in-out_infinite] motion-reduce:[animation:pb-reveal_1ms_180ms_backwards]`,H=I(`app-shell`),du=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,fu=({parts:e,onNavigate:t,trailing:n})=>{let r=e.at(-1),i=r!==void 0&&(typeof r==`string`||!r.above);return(0,R.jsxs)(`nav`,{"aria-label":H(`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,R.jsx)(cu,{className:`w-24`}):o,d=a&&!l,f=z(`truncate`,d?`font-semibold max-md:text-mobile-title max-md:font-bold`:`text-muted-foreground`);return(0,R.jsxs)(`span`,{className:z(`min-w-0 items-center gap-1.5`,d?`flex`:`hidden md:flex`),children:[i>0&&(0,R.jsx)(Ho,{className:`hidden size-3.5 shrink-0 text-faint-foreground md:block`}),s?(0,R.jsx)(`a`,{href:s,"aria-current":d?`page`:void 0,"aria-label":c?o:void 0,"aria-busy":c||void 0,onClick:e=>{t&&du(e)&&(e.preventDefault(),t(s))},className:z(f,`rounded-sm hover:text-foreground hover:underline`),children:u}):(0,R.jsx)(`span`,{className:f,"aria-label":c?o:void 0,"aria-busy":c||void 0,children:u}),d&&n]},`${i}-${o}`)}),!i&&n]})},pu=({to:e,onClick:t,...n})=>{let{href:r,onFollow:i,newTab:a}=e;return(0,R.jsx)(`a`,{href:r,...a&&{target:`_blank`,rel:`noreferrer`},onClick:e=>{t?.(e),i&&!e.defaultPrevented&&du(e)&&(e.preventDefault(),i())},...n})},U=I(`app`),mu=(0,M.createContext)([]),hu=({name:e,children:t})=>{let n=(0,M.useContext)(mu),r=(0,M.useMemo)(()=>[...n,e],[n,e]);return(0,R.jsx)(mu.Provider,{value:r,children:t})},gu=()=>(0,M.useContext)(mu),_u=(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)))},vu=(e,{replace:t=!1,keepScroll:n=!1}={})=>({kind:`link`,full:e,replace:t,keepScroll:n}),yu=(e,t)=>t(e.full,e.replace,e.keepScroll),bu=`protobase:page-places`,xu=50,Su=e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&typeof e[1]==`number`&&Number.isFinite(e[1])&&e[1]>=0,Cu=e=>ce(()=>{let t=e.getItem(bu);if(t===null)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(Su):[]},[]),wu=e=>{let t=new Map(Cu(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-xu)))t.delete(e)},persist:()=>ce(()=>e.setItem(bu,JSON.stringify([...t])),void 0)}},Tu=3e3,Eu=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,Tu);return r.observe(document.body),window.addEventListener(`scroll`,i,{passive:!0}),a},Du=(0,M.createContext)(null),Ou=()=>{let e=(0,M.useContext)(Du);if(!e)throw Error(`useRouter must be used inside Router`);return e},ku=()=>`${window.location.pathname}${window.location.search}`,Au=e=>new URL(e,`http://local`).pathname,ju=()=>window.history.state??{},Mu=()=>ju().protobaseIndex??0,Nu=()=>Math.random().toString(36).slice(2),Pu=()=>{let e=ju();if(e.protobaseEntry)return e.protobaseEntry;let t=Nu();return window.history.replaceState({...e,protobaseEntry:t},``),t},Fu={getItem:()=>null,setItem:()=>{}},Iu=({basePath:e=``,initialUrl:t,children:n})=>{let r=t!==void 0,[i,a]=(0,M.useState)(()=>({url:t??ku(),entry:r?Nu():Pu()})),[o]=(0,M.useState)(()=>wu(r?Fu:ce(()=>window.sessionStorage,void 0)??Fu)),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)(r?0:Mu()),d=(0,M.useRef)(!1),f=(0,M.useRef)(!1),p=(0,M.useRef)(void 0),m=(0,M.useRef)(!1),[h,g]=(0,M.useState)(),_=(0,M.useCallback)(()=>o.save(l.current.entry,window.scrollY),[o]);(0,M.useLayoutEffect)(()=>Eu(o.placeOf(i.entry)),[o,i.entry]),(0,M.useEffect)(()=>{if(r)return;window.history.scrollRestoration=`manual`,window.history.replaceState({...ju(),protobaseIndex:u.current,protobaseEntry:l.current.entry},``);let e=()=>{_(),o.persist()},t=()=>document.visibilityState===`hidden`&&e();window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t);let n=()=>{let e=Mu();if(d.current){d.current=!1,u.current=e,p.current!==void 0&&window.history.go(p.current),p.current=void 0;return}let t=e-u.current;if(!f.current&&s.current.size>0&&_u(l.current.url,ku(),s.current.values())){d.current=!0,window.history.go(-t),g({kind:`history`,delta:t,inputLost:c()});return}f.current=!1,u.current=e,_(),a({url:ku(),entry:Pu()})};return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n),window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t)}},[r,_,o]);let v=(0,M.useCallback)((e,t,n=!1)=>{let i=t?l.current.entry:Nu();if(!r){u.current+=+!t;let n=t?ju().protobasePrevious:l.current.url;window.history[t?`replaceState`:`pushState`]({protobaseIndex:u.current,protobaseEntry:i,protobasePrevious:n},``,e)}_(),n&&o.save(i,window.scrollY),a({url:e,entry:i})},[r,_,o]),y=(0,M.useCallback)((t,n)=>{let r=vu(`${e}${t}`,n);if(s.current.size>0&&_u(l.current.url,r.full,s.current.values()))return g({...r,inputLost:c()});yu(r,v)},[e,v]),b=(0,M.useCallback)(t=>{let n=r?void 0:ju().protobasePrevious;if(n!==void 0&&Au(n)===Au(`${e}${t}`))return window.history.back();y(t)},[r,e,y]),x=(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)},[]),S=(0,M.useCallback)(()=>{if(s.current.size>0)return g({kind:`reload`,inputLost:c()});window.location.reload()},[]),C=(0,M.useCallback)(()=>m.current,[]),w=(0,M.useCallback)(()=>s.current.size>0,[]),T=()=>{if(h){if(g(void 0),h.kind===`link`)return yu(h,v);if(h.kind===`reload`)return m.current=!0,window.location.reload();f.current=!0,d.current?p.current=h.delta:window.history.go(h.delta)}},E=(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:y,back:b,registerGuard:x,reload:S,reloadConfirmed:C,holdsChanges:w}},[i,e,y,b,x,S,C,w]);return(0,R.jsxs)(Du.Provider,{value:E,children:[n,h?.kind===`reload`&&(0,R.jsx)(su,{title:U(`reloadTitle`),description:U(h.inputLost?`reloadInputLost`:`reloadDraftKept`),onClose:()=>g(void 0),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:()=>g(void 0),children:U(`keepEditing`)}),(0,R.jsx)(V,{variant:`primary`,onClick:T,children:U(`reload`)})]})}),h&&h.kind!==`reload`&&(0,R.jsx)(su,{title:U(`leaveTitle`),description:U(h.inputLost?`leaveInputLost`:`leaveDescription`),onClose:()=>g(void 0),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:()=>g(void 0),children:U(`stay`)}),(0,R.jsx)(V,{variant:`primary`,onClick:T,children:U(`leave`)})]})})]})},Lu=({to:e,replace:t,...n})=>{let{navigate:r,basePath:i}=Ou();return(0,R.jsx)(pu,{to:{href:`${i}${e}`,onFollow:()=>r(e,{replace:t})},...n})},Ru=(e,t=`draft-kept`)=>{let{registerGuard:n,reloadConfirmed:r}=Ou(),i=gu();(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])},zu=[`always`,`editing`,`reading`],Bu=e=>e!==void 0&&!zu.includes(e),W={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`},Vu=[`list`,`display`,`filter`,`orderBy`,`filterLayout`,`savedSearch`],Hu=e=>`${e.latitude.toFixed(5)},${e.longitude.toFixed(5)},${e.zoom.toFixed(2)}`,Uu=(e,t,n=-t)=>Number.isFinite(e)&&e>=n&&e<=t,Wu=e=>{let t=e?.split(`,`);if(t?.length!==3||t.some(e=>e.trim()===``))return;let[n,r,i]=t.map(Number);return Uu(n,90)&&Uu(r,180)&&Uu(i,22,0)?{latitude:n,longitude:r,zoom:i}:void 0},Gu=e=>`${e.scale},${e.day}`,Ku=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},qu=(e,t)=>{let n=e?.split(`,`);if(n?.length!==2)return;let[r,i]=n;return t.includes(r)&&Ku(i)?{scale:r,day:i}:void 0},Ju=e=>{let t=new URLSearchParams;for(let n of Vu){let r=e[n];r===void 0||r===``&&n!==`filter`||t.set(W[n],r)}e.map&&t.set(W.map,Hu(e.map)),e.calendar&&t.set(W.calendar,Gu(e.calendar)),e.timeline&&t.set(W.timeline,Gu(e.timeline));let n=t.toString();return n?`?${n}`:``},Yu=e=>{let t=new URLSearchParams;e.edit&&t.set(W.edit,`true`);for(let n of e.open??[])t.append(W.open,n);e.tab&&t.set(W.tab,e.tab),e.standard&&t.set(W.standard,`true`),e.call&&t.set(W.call,e.call),e.version!==void 0&&t.set(W.version,String(e.version)),e.run&&t.set(W.run,e.run),e.panel&&t.set(W.panel,e.panel),e.file&&t.set(W.file,e.file);let n=t.toString();return n?`?${n}`:``},Xu=(e,t=``)=>{switch(e.kind){case`page`:return`${t}/${encodeURIComponent(e.page)}${e.tab?`/${encodeURIComponent(e.tab)}`:``}${Qu(e.params)}`;case`create`:return`${t}/${encodeURIComponent(e.resource)}/${W.create}${Qu(e.values)}`;case`record`:return`${t}/${encodeURIComponent(e.resource)}/${encodeURIComponent(Zn(e.key))}${Yu(e)}`;case`list`:return`${t}/${encodeURIComponent(e.resource)}${Ju(e)}`}},Zu=e=>{try{return e.split(`/`).filter(Boolean).map(decodeURIComponent)}catch(e){if(e instanceof URIError)return;throw e}},Qu=(e={})=>{let t=new URLSearchParams(Object.entries(e).filter(([,e])=>e!==``)).toString();return t?`?${t}`:``},$u=e=>e!==null&&/^[1-9]\d{0,8}$/.test(e)?Number(e):void 0,ed=e=>e===`bar`||e===`panel`?e:void 0,td=(e,t)=>{let n=new URL(e,`http://app`),r=Zu(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===W.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(W.open).filter(e=>e!==``))],t=n.searchParams.get(W.tab)||void 0,r=n.searchParams.get(W.standard)===`true`,o=n.searchParams.get(W.call)===`join`,s=$u(n.searchParams.get(W.version)),c=n.searchParams.get(W.run)||void 0,l=n.searchParams.get(W.panel)||void 0,u=n.searchParams.get(W.file)||void 0;return{kind:`record`,resource:i,key:a,...n.searchParams.get(W.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}}}let o=n.searchParams,s=o.get(W.list)||void 0,c=o.get(W.display)||void 0,l=o.get(W.filter)??void 0,u=o.get(W.orderBy)||void 0,d=ed(o.get(W.filterLayout)),f=Wu(o.get(W.map)),p=qu(o.get(W.calendar),[`month`,`week`]),m=qu(o.get(W.timeline),[`week`,`month`,`quarter`]),h=o.get(W.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}}},nd={signature:`sig`},rd=e=>{let t=e.startsWith(`?`)?e.slice(1):e;return new URLSearchParams(t).has(nd.signature)?{oauthQuery:t}:{}},id=`/-/sign-in`,ad={step:`step`,next:`next`},od=[`sign-in`,`forgot-password`,`email-code`,`sign-up`,`sign-up-code`,`sign-up-details`],sd=e=>od.includes(e),cd=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}`},ld=({step:e=`sign-in`,next:t}={})=>{let n=new URLSearchParams;e!==`sign-in`&&n.set(ad.step,e);let r=cd(t);r&&r!==`/`&&n.set(ad.next,r);let i=n.toString();return i?`${id}?${i}`:id},ud=(e,t)=>{if(e!==`/-/sign-in`)return;let n=t.get(ad.step),r=cd(t.get(ad.next));return{step:sd(n)?n:`sign-in`,...r&&{next:r}}},dd=e=>typeof e==`string`?e:e&&yt(e),fd=e=>{let t=Object.entries(e??{}).map(([e,t])=>`${e}.${t}`);return t.length>0?t:void 0},pd=e=>({photos:e&&`${e.resource}.${e.field}.${e.image}`,photos_order_by:e?.sort}),md=(e={})=>({filter:dd(e.filter)||void 0,order_by:e.orderBy,page_size:e.pageSize,page_token:e.pageToken||void 0,fields:e.fields?.join(`,`),labels:fd(e.labels)?.join(`,`),...pd(e.photos),count:e.count,limit_per:e.limitPer&&`${e.limitPer.field}:${e.limitPer.count}`,etag:e.etag===!1?`false`:void 0}),hd=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}`:``},gd=e=>e.startsWith(`/`)&&!e.startsWith(`//`),_d=e=>{if(typeof e!=`object`||!e)return!1;let{uri:t,url:n}=e;return typeof t==`string`&&typeof n==`string`&&gd(n)},vd=e=>e!==void 0&&URL.canParse(e)?new URL(e).origin:void 0,yd=(e,t)=>({...e,url:`${t}${e.url}`,...e.variants&&{variants:Object.fromEntries(Object.entries(e.variants).map(([e,n])=>[e,gd(n.url)?{...n,url:`${t}${n.url}`}:n]))}}),bd=(e,t)=>t===void 0||typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,_d(n)?yd(n,t):n])),xd=(e,t)=>t===void 0?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n.map(e=>_d(e)?yd(e,t):e)])),Sd=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:[]}},Cd=class extends Sd{constructor(e){super(e),this.name=`PreconditionFailedError`}},wd=e=>e instanceof Sd,Td=e=>typeof e==`object`&&!!e&&`type`in e&&`status`in e,Ed=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.json():void 0,n=Td(t)?t:{type:`urn:protobase:problem:unknown`,title:e.statusText||`Request failed`,status:e.status};return n.status===412?new Cd(n):new Sd(n)},Dd=(e=`/api/v1`)=>e.replace(/\/[^/]*$/,``),Od=(e={})=>{let t=e.baseUrl??`/api/v1`,n=Dd(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 Ed(g);return g}},kd=(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(/\/$/,``)}`}},Ad=(e,t)=>{if(!e.url.startsWith(`/`)&&!/^https?:\/\//i.test(e.url))return e.url;let n=ai(e.uri);if(!n)return e.url;let{link:r,api:i}=kd(e.url,t),a=ri(i);return r.startsWith(`${a}/`)?oi(r):oi(ii(a,n.provider,n.path))},jd=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()]})),Md=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:jd(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)}),Nd=e=>Math.min(3e4,1e3*2**e),Pd=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),Fd=(e,t,n=Nd)=>{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:hd({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 Mr(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 Pd(n(o++),i)}})(),()=>r.abort()},Id=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)}}},Ld=new TextEncoder,Rd=new TextDecoder,zd=4,Bd=(e,t)=>{let n=Ld.encode(JSON.stringify(e)),r=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i=new Uint8Array(zd+n.length+r.length);return new DataView(i.buffer).setUint32(0,n.length),i.set(n,zd),i.set(r,zd+n.length),i.buffer},Vd=e=>{let t=zd+new DataView(e).getUint32(0);return{...JSON.parse(Rd.decode(new Uint8Array(e,zd,t-zd))),payload:e.slice(t)}},Hd=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),Ud=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`ChannelRefusal`}},Wd=5e3,Gd=1,Kd=`protobase.channels`,qd=({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 Ud(`disconnected`,`The connection dropped before the server answered`));h.clear()},_=async e=>{let n=await t?.();s===e&&e.readyState===Gd&&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?[Kd]:[Kd,`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)},Wd),i()},y.onmessage=({data:e})=>{if(f=Date.now(),typeof e!=`string`&&!(e instanceof ArrayBuffer))return;let t=typeof e==`string`?JSON.parse(e):Vd(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 Ud(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===Gd&&(s.send(t===void 0?JSON.stringify(e):Bd(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 Ud(`disconnected`,`The connection is down`));h.set(i,{resolve:n,reject:r})}),post:y}},Jd=e=>{if(!(e instanceof Ud&&e.code===`disconnected`))throw e},Yd=()=>new Ud(`not-joined`,`The channel is not joined yet`),Xd=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(Jd)}}).catch(n=>{if(t.get(i)===e&&e.holders===0&&n instanceof Ud)return a(i);if(!(n instanceof Ud)||n.code===`disconnected`)return Jd(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=qd({...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 Yd();let o=Hd(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 Ud(`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=Zn(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)}}},Zd=({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(ei(a,o)),[]);return c.binaryType=`arraybuffer`,{socket:c,expiresAt:new Date(s)}}}),Qd=e=>({register:async t=>(await e({method:`POST`,path:ti(``),system:!0,body:t})).json(),remove:async t=>{await e({method:`DELETE`,path:ti(``,t),system:!0})}}),$d=e=>({own:async()=>(await(await e({method:`GET`,path:di(``),system:!0})).json()).status,set:async t=>(await(await e({method:`PUT`,path:di(``),system:!0,body:t})).json()).status,clear:async()=>{await e({method:`DELETE`,path:di(``),system:!0})},people:async()=>(await(await e({method:`GET`,path:di(``,`people`),system:!0})).json()).statuses}),ef=e=>async(t,n)=>(await e({method:`GET`,path:Xn(``,t,n),system:!0})).json(),tf=e=>async()=>(await e({method:`GET`,path:Gn(``),system:!0})).json(),nf=e=>async t=>(await e({method:`POST`,path:Kn(``,t),system:!0})).json(),rf=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:ui(``),query:i,system:!0})).json()},unread:async()=>(await(await e({method:`GET`,path:ui(``,`unread`),system:!0})).json()).count,markRead:async t=>{await e({method:`POST`,path:ui(``,{read:t}),body:{},system:!0})},markAllRead:async t=>{await e({method:`POST`,path:ui(``,`read`),body:{upTo:t},system:!0})}}),af=e=>Math.min(3e4,1e3*2**e),of=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),sf=(e,t,n=af)=>({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 Mr(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 of(n(c++),s)}})(),()=>o.abort()}}),cf=e=>({list:async()=>(await(await e({method:`GET`,path:bi(``),system:!0})).json()).items,decline:async t=>{await e({method:`POST`,path:bi(``,{decline:t}),system:!0,body:{}})}}),lf=e=>({allowed:async()=>(await(await e({method:`GET`,path:_i(``,`organization`),system:!0})).json()).allowed,setAllowed:async t=>{await e({method:`PUT`,path:_i(``,`organization`),system:!0,body:{allowed:t}})}}),uf=4e3,df=e=>typeof e==`string`?e:e.toModel().name,ff=(e=`/api/v1`,t)=>{let n=new URL(`${e.replace(/\/[^/]*$/,``)}${t}`,globalThis.location?.href);return n.protocol=n.protocol===`https:`?`wss:`:`ws:`,n.toString()},pf=(e,t)=>`/${df(e)}/${Zn(t)}`,mf=(e,t)=>`${pf(e,t)}:calls`,hf=(e,t,n)=>({items:e.items.map(e=>bd(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:xd(e.photos,n)},...t.headers.get(`x-protobase-warning`)&&{warning:t.headers.get(`x-protobase-warning`)}}),gf=({created_at:e,...t})=>({...t,createdAt:e}),_f=e=>e.headers.get(`etag`)??``,vf=async(e,t)=>{let{permissions:n,...r}=await e.json();return{record:bd(r,t),etag:_f(e),...n&&{permissions:n}}},yf=(e,t)=>({results:(e.results??[]).map(e=>e.op===`create`||e.op===`update`?{...e,record:bd(e.record,t)}:e.op===`reorder`||e.op===`move`?{...e,records:e.records.map(e=>({...e,record:bd(e.record,t)}))}:e)}),bf=(e={})=>{let t=Od(e),n=vd(e.baseUrl),r=async(e,r)=>{let i=md(r),a=await t({method:`POST`,path:`/${df(e)}:search`,body:{...i,fields:r?.fields,labels:fd(r?.labels)}});return hf(await a.json(),a,n)},i=async(e,i)=>{let a=hd(md(i));if(a.length>uf)return r(e,i);let o=await t({method:`GET`,path:`/${df(e)}`,query:a});return hf(await o.json(),o,n)},a=async(e,r)=>vf(await t({method:`GET`,path:pf(e,r)}),n),o=async(e,r)=>{let i=await t({method:`POST`,path:`/${df(e)}`,body:r});return{record:bd(await i.json(),n),etag:_f(i),location:i.headers.get(`location`)??``}},s=async(e,r,i,a)=>vf(await t({method:`PATCH`,path:pf(e,r),body:i,headers:{"if-match":a}}),n),c=async(e,n,{etag:r}={})=>{await t({method:`DELETE`,path:pf(e,n),headers:r?{"if-match":r}:void 0})},l=async(e,r)=>{let i=await t({method:`POST`,path:`${pf(e,r)}:undelete`});return{record:bd(await i.json(),n),etag:_f(i)}},u=async(e,n,r)=>(await(await t({method:`POST`,path:`${pf(e,n)}:reveal`,body:{field:r}})).json()).value,d=async(e,r,i)=>vf(await t({method:`POST`,path:`${pf(e,r)}:generate`,body:{action:i}}),n),f=async(e,n,{pageSize:r,pageToken:i}={})=>{let a=hd({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${pf(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=hd({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${pf(e,n)}:comments`,query:a})).json();return{items:o.items.map(gf),nextPageToken:o.next_page_token}},m=async(e,n,{body:r,mentions:i=[]})=>gf(await(await t({method:`POST`,path:`${pf(e,n)}:comments`,body:{body:r,mentions:i}})).json()),h=async(e,n,r)=>(await(await t({method:`GET`,path:`${pf(e,n)}:mentionable`,query:hd({q:r})})).json()).items,g=async e=>{let r=e=>typeof e==`object`&&e&&`$ref`in e?e:Zn(e),i=e.map(e=>({...e,resource:df(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 yf(await(await t({method:`POST`,path:`:batchWrite`,body:{ops:i}})).json(),n)},_=async(e,n,r={})=>(await(await t({method:`GET`,path:`/${df(e)}:facets`,query:hd({field:n,filter:dd(r.filter)||void 0,limit:r.limit,label:r.label})})).json()).facets,v=async(e,n)=>{let r=await(await t({method:`GET`,path:`/${df(e)}:aggregate`,query:hd({group_by:n.groupBy,filter:dd(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:`/${df(e)}:series`,query:hd({field:n.field,range:n.range,from:n.from,to:n.to,granularity:n.granularity,time_zone:n.timeZone,filter:dd(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:`/${df(e)}:histogram`,query:hd({field:n,buckets:r.buckets,filter:dd(r.filter)||void 0})})).json(),x=async(e,r)=>{let i=await(await t({method:`GET`,path:`/${df(e)}:map`,query:hd({latitude:r.latitude,longitude:r.longitude,zoom:r.zoom,filter:dd(r.filter)||void 0,order_by:r.orderBy,fields:r.fields?.join(`,`),labels:fd(r.labels)?.join(`,`),...pd(r.photos)})})).json();return{items:i.items.map(e=>bd(e,n)),buckets:i.buckets,totalSize:i.total_size,...i.labels!==void 0&&{labels:i.labels},...i.photos!==void 0&&{photos:xd(i.photos,n)}}},S=async(e,r)=>{let i=await t({method:`GET`,path:`/${df(e)}:seek`,query:hd({...md(r),position:r.position})});return hf(await i.json(),i,n)},C=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:_f(r)}},w=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()},T=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`?Md(i):void 0,c=await(await t({method:`POST`,path:`/${df(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},E=e=>`/forms/${encodeURIComponent(e)}`,D=async e=>(await t({method:`GET`,path:E(e),system:!0})).json(),O=async e=>(await t({method:`GET`,path:`${E(e)}:challenge`,system:!0})).json(),k=async(e,n,r)=>{await t({method:`POST`,path:E(e),body:{values:n,proof:r},system:!0})},A=Id(e=>Fd(t,e)),ee=e.webSocket??((e,t)=>new WebSocket(e,t)),{channel:te}=Xd({url:()=>ff(e.baseUrl,`/channels`),...e.token&&{token:()=>e.token({refresh:!1})},socket:ee,retryDelay:e=>Math.min(3e4,1e3*2**e)}),ne=Zd({send:t,socketUrl:t=>ff(e.baseUrl,t),socket:ee}),re=Qd(t),j=rf(t),{calls:ie,watchCalls:ae}=sf(t,mf),M=$d(t),N=tf(t),oe=ef(t),P=nf(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,map:x,seek:S,meta:C,invoke:w,upload:T,form:D,formChallenge:O,submitForm:k,live:A,channel:te,bridges:ne,devices:re,notifications:j,status:M,calls:ie,watchCalls:ae,rings:cf(t),callGuests:lf(t),workflowTypes:N,workflowRunTrace:oe,runnerRegistration:P,fileReadUrl:(t,n)=>Ad(n,Dd(e.baseUrl))}},xf=e=>typeof e==`string`?e:e.toModel().name,Sf=(e,t)=>{let n=n=>t(xf(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=>xf(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),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),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)}},Cf=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.type==`string`&&Array.isArray(e.children),wf=Symbol(`recorded`),Tf=[],Ef=0,Df=0,Of=e=>{if(Df===0)throw Error(`A record block's children are a function of its record only inside a typed layout: layout(), recordLayout() or defineTemplate()`);Ef+=1;let t=Ef;Tf.push(t);try{return{scope:t,built:e(t)}}finally{Tf.pop()}},kf=new WeakMap,Af=(e,t)=>{kf.set(e,t)},jf=(e,t)=>{let n=kf.get(e);n!==void 0&&kf.set(t,n)},Mf=/^\d+[smhdw]$/,Nf=class e{offset;constructor(e){this.offset=e}plus(t){return new e({sign:`+`,duration:Pf(t)})}minus(t){return new e({sign:`-`,duration:Pf(t)})}toString(){return this.offset?`now() ${this.offset.sign} ${this.offset.duration}`:`now()`}},Pf=e=>{if(!Mf.test(e))throw Error(`"${e}" is not a duration: write a number and s, m, h, d or w, such as '7d'`);return e},Ff=class{text;op;constructor(e,t){this.text=e,this.op=t}and(e){return If(`and`,this,e)}or(e){return If(`or`,this,e)}toString(){return this.text}},If=(e,t,n)=>{let r=t=>t.op===`term`||t.op===e?t.text:`(${t.text})`;return new Ff(`${r(t)} ${e.toUpperCase()} ${r(n)}`,e)},Lf=e=>(typeof e==`object`||typeof e==`function`)&&e!==null&&wf in e,Rf=e=>`{{~${e[wf].scope}~${e[wf].path.join(`.`)}}}`,zf=({path:e,scope:t})=>`~~${t}~${e.join(`.`)}~~`,Bf=e=>{if(Lf(e))return Rf(e);if(e instanceof Nf)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`)},Vf=e=>new Ff(e,`term`),Hf=e=>({eq:t=>Vf(t===null?`isNull(${e})`:`${e} = ${Bf(t)}`),ne:t=>Vf(t===null?`NOT isNull(${e})`:`${e} != ${Bf(t)}`),lt:t=>Vf(`${e} < ${Bf(t)}`),le:t=>Vf(`${e} <= ${Bf(t)}`),gt:t=>Vf(`${e} > ${Bf(t)}`),ge:t=>Vf(`${e} >= ${Bf(t)}`),in:t=>Vf(`in(${e}, ${t.map(Bf).join(`, `)})`),contains:t=>Vf(`${e}:${Bf(t)}`),isNull:()=>Vf(`isNull(${e})`)}),Uf=new Set(Object.keys(Hf(``))),Wf=(e=[],t=Tf.at(-1)??0)=>new Proxy({},{get:(n,r)=>{if(r===wf)return{path:e,scope:t};if(r===Symbol.toPrimitive||r===`toString`||r===`toJSON`)return()=>Rf({[wf]:{path:e,scope:t}});if(typeof r!=`symbol`)return Uf.has(r)?Hf(zf({path:e,scope:t}))[r]:Wf([...e,r],t)},has:(e,t)=>t===wf}),Gf=(e=[])=>new Proxy({},{get:(t,n)=>{if(typeof n!=`symbol`)return Uf.has(n)&&e.length>0?Hf(e.join(`.`))[n]:Gf([...e,n])}}),Kf=`Layouts are static data, sent to the browser as JSON: use <Action name="..."> for behaviour, or register a custom component for React code.`,qf=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`}`,Jf=e=>{let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Yf=(e,t)=>{if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(Lf(e))return Rf(e);if(e instanceof Ff||e instanceof Nf)return e.toString();if(typeof e==`number`&&Number.isFinite(e))return e;if(Array.isArray(e))return e.map((e,n)=>Yf(e,`${t.slice(0,-1)}[${n}]>`));if(typeof e==`object`&&Jf(e)){let n=Object.fromEntries(Object.entries(e).flatMap(([e,n])=>n===void 0?[]:[[e,Yf(n,`${t.slice(0,-1)}.${e}>`)]]));return jf(e,n),n}throw Error(`${t} is ${qf(e)}. ${Kf}`)},Xf=(e,t)=>{if(e==null||typeof e==`boolean`)return[];if(typeof e==`string`)return[e];if(Lf(e))return[Rf(e)];if(typeof e==`number`&&Number.isFinite(e))return[String(e)];if(Array.isArray(e))return e.flatMap(e=>Xf(e,t));if(Cf(e))return e.type===`Fragment`&&!e.custom?e.children:[e];throw Error(`${t} has a child that is ${qf(e)}. ${Kf}`)},Zf=e=>typeof e==`function`&&typeof e.blockName==`string`,Qf=[`RecordCard`,`CardRow`,`ReferenceField`,`RecordsIterator`],$f=[`filter`,`edgeFilter`,`animated`,`dashed`,`dotted`],ep=(e,t)=>{let n={...t};for(let t of $f){let r=n[t];if(typeof r==`function`){let i=r(Gf());if(!(i instanceof Ff))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 Ff))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},tp=(e,t,n)=>{if(typeof t!=`function`)return{children:Xf(t,n)};if(!Qf.includes(e))throw Error(`<${e}> takes elements as children; only ${Qf.join(`, `)} take a function of their record`);let{scope:r,built:i}=Of(e=>Xf(t(Wf([],e)),n));return{children:i,scope:r}},np={Graph:`node`},rp=new Set([`Graph`]),ip=(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||Cf(n)?n:i(Xf(n,r))};let{scope:a,built:o}=Of(e=>Xf(n(Wf([],e)),r));return{value:i(o),scope:a}},ap=(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(!Zf(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; ${Kf}`);let n=e.blockName,{children:r,...i}=t,a=!e.custom&&rp.has(n),{fallback:o,...s}=i,c=a?s:i,l=e.custom?c:ep(n,c),u=e.custom?void 0:np[n],d=u===void 0?void 0:ip(n,u,l[u]);u!==void 0&&(l[u]=d.value);let f=e.custom?{children:Xf(r,`<${n}>`)}:tp(n,r,`<${n}>`),p={type:n,props:Object.fromEntries(Object.entries(l).flatMap(([e,t])=>t===void 0?[]:[[e,Yf(t,`<${n} ${e}>`)]])),children:f.children},m=f.scope??d?.scope;return m!==void 0&&Af(p,m),e.custom&&(p.custom=!0),e.fallback&&(p.fallback=e.fallback),a&&o!==void 0&&(p.fallback=Xf(o,`<${n} fallback>`)),e.reads&&(p.reads=e.reads),p},op=(e,t,n,r)=>{let i=Object.assign(e=>ap(i,e),{blockName:e,custom:t,...n&&{fallback:n},...r&&{reads:r}});return i},sp=e=>op(e,!1),cp=e=>sp(e);cp(`ReferenceManyField`),cp(`ReferenceArrayField`),sp(`ArrayField`),cp(`RecordsIterator`),cp(`ReferenceField`);var lp=e=>`${e} desc`,up=new Set([`Table`,`Timeline`,`Graph`]),dp=e=>e===`Graph`?`nodes`:`resource`,fp=e=>Array.isArray(e)?e:[e],pp=e=>typeof e==`string`?e:void 0,mp=e=>{if(!e.custom){let t=up.has(e.type)?pp(e.props.select):void 0;return t===void 0?void 0:{param:t,resource:pp(e.props[dp(e.type)])}}let t=e.reads&&fp(e.reads).find(e=>e.select!==void 0),n=t&&pp(e.props[t.select]);return n===void 0?void 0:{param:n,resource:pp(e.props[t.resource])}},hp={stack:[]},gp=e=>typeof e==`string`?e:void 0,_p=(e,t)=>({stack:[...e.stack,t],...e.root!==void 0&&{root:e.root}}),vp=(e,t)=>({...e,list:t}),yp=(e,t)=>{let n=Sp(e),r=mp(e);if(r)return _p(t,{resource:r.resource,repeated:!1,block:n});if(e.custom)return t;switch(e.type){case`RecordCard`:case`CardRow`:return _p(t,{resource:gp(e.props.resource),repeated:e.type===`CardRow`,block:n});case`ReferenceField`:return _p(t,{resource:gp(e.props.reference),repeated:!1,block:n});case`ReferenceManyField`:case`ReferenceArrayField`:return vp(t,{resource:gp(e.props.reference),items:!1,block:n});case`ArrayField`:return vp(t,{items:!0,block:n});case`RecordsIterator`:return t.list?_p(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}},bp=(e,t)=>e.custom?t:e.type===`RecordCard`?yp(e,t):e.type===`Graph`?_p(t,{resource:gp(e.props.nodes),repeated:!0,block:Sp(e)}):t,xp=e=>!e.custom&&e.type===`Graph`?[`nodes`]:[`resource`,`reference`,`name`,`source`],Sp=e=>`<${e.type}${xp(e).map(t=>typeof e.props[t]==`string`?` ${t}="${e.props[t]}"`:``).join(``)}>`,Cp=e=>Cf(e)||Array.isArray(e)&&e.length>0&&e.every(Cf),wp=(e,t,n={path:Sp(e),scope:hp})=>{let r=yp(e,n.scope),i=bp(e,n.scope),a=e.children.flatMap(e=>{if(typeof e==`string`)return[e];let i=wp(e,t,{path:`${n.path} › ${Sp(e)}`,scope:r});return i?[i]:[]}),o=Object.fromEntries(Object.entries(e.props).flatMap(([e,r])=>{if(!Cp(r))return[[e,r]];let a=(Array.isArray(r)?r:[r]).flatMap(r=>wp(r,t,{path:`${n.path} ${e}={${Sp(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=wp(e,t,{path:`${n.path} fallback={${Sp(e)}}`,scope:n.scope});return r?[r]:[]});return t({...e,props:o,children:a,...s&&{fallback:s}},n)},Tp=(e,t,n={path:Sp(e),scope:hp})=>{t(e,n);let r=yp(e,n.scope),i=bp(e,n.scope);for(let i of e.children)typeof i!=`string`&&Tp(i,t,{path:`${n.path} › ${Sp(i)}`,scope:r});for(let[r,a]of Object.entries(e.props))if(Cp(a))for(let e of Array.isArray(a)?a:[a])Tp(e,t,{path:`${n.path} ${r}={${Sp(e)}}`,scope:i});for(let r of e.fallback??[])typeof r!=`string`&&Tp(r,t,{path:`${n.path} fallback={${Sp(r)}}`,scope:n.scope})};op(`SelectInput`,!1);var Ep=e=>{let t=new Map;return Tp(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},Dp=(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),Op=(e,t={})=>{let n={};for(let[r,i]of Ep(e)){let e=Dp(i,Object.hasOwn(t,r)?t[r]:void 0);e!==void 0&&(n[r]=e)}return n},G=e=>({kind:e}),K=e=>({kind:e,required:!0}),kp={title:G(`shown`),description:G(`shown`),actions:G(`elements`)},Ap={resource:K(`text`),filter:G(`text`),sort:G(`text`)},jp={resource:`resource`,filter:`filter`,sort:`sort`},Mp={sort:G(`sort`),filter:G(`filter`),perPage:G(`integer`)},Np={source:K(`text`),emptyText:G(`text`)},Pp={locales:G(`locales`),options:G(`intlOptions`)},Fp={Page:{children:!0,props:{title:K(`shown`),description:G(`shown`),actions:G(`elements`),width:G(`pageWidth`)}},Grid:{children:!0,props:{columns:G(`columns`),span:G(`span`)}},Card:{children:!0,props:{...kp,span:G(`span`)}},Stat:{children:!1,props:{label:K(`shown`),value:G(`scalar`),resource:G(`text`),filter:G(`text`),field:G(`text`),format:G(`format`),description:G(`shown`),span:G(`span`)},reads:{resource:`resource`,filter:`filter`}},RecordCard:{children:!0,props:{...Ap,...kp,recordKey:G(`text`),empty:G(`shown`),span:G(`span`)},reads:jp},Field:{children:!1,props:{source:K(`text`),label:G(`label`),format:G(`format`)}},Diff:{children:!1,props:Np},Table:{children:!0,reads:jp,props:{...Ap,resource:G(`text`),...kp,columns:G(`tableColumns`),button:G(`rowButton`),bulk:G(`boolean`),limit:G(`integer`),display:G(`text`),empty:G(`shown`),span:G(`span`),select:G(`text`)}},SelectInput:{children:!1,props:{source:K(`text`),choices:G(`choices`),label:G(`shown`),defaultValue:G(`scalar`)}},CardRow:{children:!0,props:{...Ap,...kp,limit:G(`integer`),empty:G(`shown`),span:G(`span`)},reads:jp},RecordRow:{children:!1,props:{...Ap,...kp,limit:G(`integer`),display:G(`text`),empty:G(`shown`),span:G(`span`)},reads:jp},RecordCards:{children:!1,reads:{...jp,fields:`fields`},props:{...Ap,...kp,layout:G(`cardsLayout`),cardWidth:G(`cardWidth`),fields:G(`texts`),cardActions:G(`texts`),limit:G(`integer`),display:G(`text`),empty:G(`shown`),span:G(`span`)}},Chart:{children:!1,reads:{resource:`resource`,filter:`filter`},props:{...kp,resource:K(`text`),filter:G(`text`),groupBy:K(`text`),splitBy:G(`text`),type:G(`chartType`),sum:G(`text`),average:G(`text`),granularity:G(`bucket`),range:G(`range`),limit:G(`integer`),empty:G(`shown`),span:G(`span`)}},Timeline:{children:!0,reads:{resource:`resource`,filter:`filter`},props:{...kp,resource:K(`text`),filter:G(`text`),lane:K(`text`),bar:K(`text`),start:K(`text`),end:K(`text`),color:K(`text`),limit:G(`integer`),empty:G(`shown`),span:G(`span`),select:G(`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:K(`text`),edges:K(`text`),source:K(`text`),target:K(`text`),label:K(`text`),group:G(`text`),status:G(`text`),node:G(`elements`),filter:G(`text`),edgeFilter:G(`text`),edgeLabel:G(`text`),edgeStatus:G(`text`),animated:G(`text`),dashed:G(`text`),dotted:G(`text`),layout:G(`graphLayout`),direction:G(`graphDirection`),x:G(`text`),y:G(`text`),select:G(`text`),empty:G(`shown`)}},Progress:{children:!1,props:{value:K(`amount`),max:G(`amount`),label:G(`shown`),span:G(`span`)}},ModalForm:{children:!1,props:{mode:K(`mode`),label:K(`shown`),fields:K(`texts`),resource:G(`text`),recordKey:G(`text`),title:G(`shown`),values:G(`values`),variant:G(`variant`)}},Thread:{children:!1,reads:{resource:`resource`,filter:`filter`},props:{...kp,resource:K(`text`),filter:G(`text`),sender:G(`text`),time:K(`text`),text:K(`text`),status:G(`text`),working:G(`text`),calls:G(`toolCalls`),limit:G(`integer`),empty:G(`shown`),span:G(`span`)}},Composer:{children:!1,props:{resource:K(`text`),field:K(`text`),values:G(`values`),placeholder:G(`text`),span:G(`span`)}},Image:{children:!1,props:{function:G(`text`),src:G(`text`),alt:G(`text`),width:G(`integer`),height:G(`integer`),refresh:G(`integer`)}},Action:{children:!1,props:{name:K(`text`),resource:G(`text`),label:G(`shown`),variant:G(`variant`)}},ReferenceManyField:{children:!0,reads:{resource:`reference`,filter:`filter`,sort:`sort`},props:{reference:K(`text`),target:K(`text`),source:G(`text`),...Mp,empty:G(`shown`),pagination:G(`pagination`)}},ReferenceArrayField:{children:!0,reads:{resource:`reference`,filter:`filter`,sort:`sort`},props:{source:K(`text`),reference:K(`text`),...Mp,empty:G(`shown`)}},ArrayField:{children:!0,props:{source:K(`text`)}},RecordsIterator:{children:!0,props:{}},ReferenceField:{children:!0,reads:{resource:`reference`},props:{source:K(`text`),reference:K(`text`),link:G(`referenceLink`),empty:G(`shown`)}},Show:{children:!0,props:{when:K(`text`),fallback:G(`content`)}},Switch:{children:!0,props:{fallback:G(`content`)}},Match:{children:!0,props:{when:K(`text`)}},Link:{children:!0,props:{href:G(`text`),to:G(`address`),variant:G(`variant`)}},Tabs:{children:!0,props:{}},Tab:{children:!0,props:{name:K(`text`),label:K(`shown`)}},Settings:{children:!1,props:{resource:K(`text`),fields:G(`texts`),title:G(`shown`),description:G(`shown`),span:G(`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:K(`text`)}},Divider:{children:!1,props:{}},Row:{children:!0,props:{}},Column:{children:!0,props:{}},Text:{children:!0,props:{as:G(`textAs`)}},Trans:{children:!1,props:{i18nKey:K(`text`),values:G(`transValues`),components:G(`transComponents`)}},Details:{children:!0,props:{open:G(`boolean`)}},Summary:{children:!0,props:{}},TextField:{children:!1,props:Np},NumberField:{children:!1,props:{...Np,...Pp}},DateField:{children:!1,props:{...Np,...Pp,showDate:G(`boolean`),showTime:G(`boolean`),format:G(`dateFormat`)}},BooleanField:{children:!1,props:{...Np,valueLabelTrue:G(`text`),valueLabelFalse:G(`text`)}},UrlField:{children:!1,props:{...Np,content:G(`text`)}},ChipField:{children:!1,props:Np}},Ip=Object.fromEntries(Object.entries(Fp).map(([e,t])=>[e,{...t,props:{...t.props,className:G(`text`)}}])),Lp=[`relative`,`absolute`,`compact`,`percent`,`badge`,`code`],Rp=[`primary`,`secondary`,`danger`,`ghost`],zp=[`bar`,`line`,`donut`],Bp=[`hour`,`day`,`week`,`month`,`year`],Vp=[`7d`,`30d`,`90d`,`1y`,`all`],Hp=[`stack`,`carousel`],Up=[`1/4`,`1/3`,`1/2`,`2/3`],Wp=[`column`,`full`],Gp=[`p`,`span`,`strong`,`em`,`h1`,`h2`,`h3`,`h4`],Kp=e=>[t=>typeof t==`string`&&e.includes(t),e.join(`, `)];Lp.join(`, `),Rp.join(`, `),Kp(zp),Kp(Bp),Kp(Vp),Kp(Hp),Kp(Up),Kp(Wp),Kp(Gp),Kp([`relative`]),Kp([`layered`,`force`]),Kp([`down`,`right`]);var qp=e=>`${e} desc`,Jp=/(["'])\{\{\s*([^{}]*?)\s*\}\}\1|\{\{\s*([^{}]*?)\s*\}\}/g,Yp=e=>{let t=[],n=``,r=0;for(let i of e.matchAll(Jp)){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}},Xp=(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}},Zp=e=>`${String(e.props.start)} asc`,Qp=e=>`${String(e.props.start)} desc`,$p=2e4,em=e=>typeof e==`object`&&!!e&&e.kind===`member`,tm=e=>em(e)?[e.path.join(`.`)]:typeof e!=`object`||!e?[]:Object.values(e).flatMap(tm),nm=e=>em(e)?{...e,path:[e.path.join(`.`)]}:Array.isArray(e)?e.map(nm):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,nm(t)])),rm=new Set([`string`,`number`,`boolean`,`duration`,`timestamp`]),im=e=>rm.has(e.kind),am=e=>{let[t,...n]=e.args;if(t&&em(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(im))return{kind:`or`,args:n.map(n=>({kind:`compare`,op:`=`,left:t,right:n,span:e.span})),span:e.span}}},om=e=>Array.isArray(e)?e.map(om):typeof e!=`object`||!e?e:(e.kind===`call`?am(e):void 0)||Object.fromEntries(Object.entries(e).map(([e,t])=>[e,om(t)])),sm=new Set([`isNull`,`in`,`now`]),cm=e=>Array.isArray(e)?e.flatMap(cm):typeof e!=`object`||!e?[]:[...e.kind===`call`?[e.name]:[],...Object.values(e).flatMap(cm)],lm={extensions:{arithmetic:`now-offset`,durationUnits:!0}},um=e=>{let t=C(e,lm);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=cm(t.ast).find(e=>!sm.has(e));return n===void 0?{ok:!0,ast:t.ast,paths:[...new Set(tm(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()`}},dm={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5},fm=(e,t)=>{if(Array.isArray(e))return e.map(e=>fm(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)*dm[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,fm(n,t)]))},pm=(e,t,n=Date.now())=>e.ast!==void 0&&o(nm(om(fm(e.ast,n))),t),mm=(e,t)=>{let[n,r,...i]=e.split(`.`);return n&&r===`count`&&i.length===0&&!t(n)?n:void 0},hm=[`animated`,`dashed`,`dotted`],gm=e=>um(Yp(e).text),_m=e=>typeof e==`object`&&!!e&&!Array.isArray(e),vm=e=>typeof e==`number`||typeof e==`boolean`?String(e):`"${String(e).replace(/\\/g,`\\\\`).replaceAll(`"`,`\\"`)}"`,ym=e=>{if(typeof e==`string`)return e;if(_m(e))return e.order===`DESC`?`${e.field} desc`:String(e.field)},bm=e=>{if(typeof e==`string`)return e;if(!_m(e))return;let t=Object.entries(e).map(([e,t])=>t===null?`isNull(${e})`:`${e} = ${vm(t)}`);return t.length===0?void 0:t.join(` AND `)},xm=(...e)=>{let t=e.filter(e=>e!==void 0&&e.trim()!==``);return t.length<=1?t[0]:t.map(e=>`(${e})`).join(` AND `)},Sm=(e,t,n)=>t==null?void 0:xm(`${e} = ${vm(t)}`,bm(n)),Cm=(e,t,n)=>{let r=Array.isArray(t)?t.filter(e=>typeof e==`string`||typeof e==`number`):[];return r.length===0?void 0:xm(`in(${e}, ${r.map(vm).join(`, `)})`,bm(n))},wm=(e,t,n)=>({filter:Sm(e.target,n(e.source??`this.id`),e.filter),sort:ym(e.sort)??lp(t),perPage:e.perPage??25}),Tm=(e,t,n)=>({filter:Cm(t,n(e.source),e.filter),sort:ym(e.sort)??lp(t),perPage:e.perPage??500}),Em=e=>e.part===void 0?e.block:`${e.block}#${e.part}`,Dm=e=>typeof e==`string`?e:e.name,Om=e=>typeof e==`string`?void 0:e.priority,km=({title:e,badge:t})=>e?0:t?1:2,Am=(e,t)=>e.map((e,n)=>({name:Dm(e),given:Om(e),derived:km(t(Dm(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),jm=(e,t)=>{let n=e.filter(e=>Om(e)!==void 0),r=n.length>0?n:e,i=new Set(Am(r,t).slice(0,3));return e.map(Dm).filter(e=>i.has(e))},Mm=e=>{let t=e.custom?e.reads:Ip[e.type]?.reads;return t?Array.isArray(t)?t.map(e=>({reads:e,part:e.resource})):[{reads:t}]:[]},Nm=(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 Cf(n)?n:void 0},Pm=(e,...t)=>e+t.map(e=>`/${String(e).replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`).join(``),Fm=e=>typeof e==`object`&&!!e,Im=(e,t)=>t.reduce((e,t)=>Fm(e)&&Object.hasOwn(e,t)?e[t]:void 0,e),Lm=(e,t)=>{let n=Lt(t);if(!n)return;if(n.kind===`data`){if(n.variable===`root`)return e.root===void 0?void 0:Im(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:Im(e,n.names)}let[i,...a]=n.names,o=r.findLast(e=>Fm(e)&&Object.hasOwn(e,i));return Fm(o)?Im(o[i],a):void 0},Rm=e=>t=>Lm(e,t),zm=e=>e===void 0?null:typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===null?e:Xt(e),Bm=(e,t)=>Object.fromEntries(Object.entries(e).map(([e,n])=>{let r=typeof n==`string`?Bt(n):void 0;return[e,r===void 0?Um(n,t):zm(t(r))]})),Vm=[`title`,`description`,`empty`,`label`,`recordKey`],Hm=[`filter`,`when`,`working`,`edgeFilter`,`animated`,`dashed`,`dotted`],Um=(e,t)=>typeof e==`string`?Yt(e,e=>Xt(t(e))):Array.isArray(e)?e.map(e=>Um(e,t)):Fm(e)?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Um(n,t)])):e,Wm=(e,t)=>{if(e.custom||!JSON.stringify(e.props).includes(`{{`))return e;let n=Rm(t),r={...e.props};for(let e of Vm)typeof r[e]==`string`&&(r[e]=Yt(r[e],e=>Xt(n(e))));for(let e of Vm){let n=r[e];Cf(n)&&n.type===`Trans`&&(r[e]=Wm(n,t))}for(let e of Hm)typeof r[e]==`string`&&(r[e]=tn(r[e],n));return Fm(r.filter)&&(r.filter=Bm(r.filter,n)),r.values!==void 0&&(r.values=Um(r.values,n)),Fm(r.calls)&&typeof r.calls.filter==`string`&&(r.calls={...r.calls,filter:tn(r.calls.filter,n)}),{...e,props:r}},Gm=(e,t)=>{if(!e.custom||!e.reads)return e;let n=Rm(t),r={...e.props},i=new Set(fp(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):Fm(i)&&(r[t]=Bm(i,n))}return{...e,props:r}},Km=new Set([1,2,3,4,5,6]),qm=8,Jm=(e,t)=>{for(let n of e){Km.has(n.type)&&n.value!==void 0&&t.values.add(n.value),n.type===qm&&n.value!==void 0&&t.tags.add(n.value);for(let e of Object.values(n.options??{}))Jm(e.value,t);n.children&&Jm(n.children,t)}},Ym=(e,t)=>{let n={values:new Set,tags:new Set};return Jm(new j(e,t).getAst(),n),{values:[...n.values],tags:[...n.tags]}},Xm=new Map,Zm=(e,t,n={},r={})=>{let i=e?.messages[t];if(i===void 0||!e)return t;let a=`${e.locale}\u0000${i}`,o=Xm.get(a);return o||(o=new j(i,e.locale),Xm.set(a,o)),o.format({...n,...r})},Qm=(e,t,n={})=>{let r=Zm(e,t,n,Object.fromEntries((e?.messages[t]?Ym(e.messages[t],e.locale).tags:[]).map(e=>[e,e=>e.join(``)])));return Array.isArray(r)?r.join(``):r};op(`Trans`,!1);var $m=e=>Cf(e)&&e.type===`Trans`&&!e.custom,eh=(e,t)=>e.filter===void 0?e:{...e,filter:tn(e.filter,Rm({stack:[],...t}))},th=(e,t)=>{let n=new Map(t.reads.map(e=>[Em(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},nh=(e,t,n)=>{if(!e.split)return t;let r=Lm(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])))},rh=(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]}))}),ih=(e,t)=>{if(e.kind===`group`){let n=e.items.flatMap(e=>ih(e,t));return n.length>0?[{...e,items:n}]:[]}if(e.kind===`tab`){let n=e.items.flatMap(e=>ih(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=>Xp(t,e.resource,n).ok),o=a&&a.length>0?{...i,columns:a}:i,s=r===void 0?void 0:Er(r,t[e.resource],{models:t,pages:new Set});return[s===void 0?o:{...o,button:s}]},ah=(e,t,n)=>e.run?.kind!==`link`||!(`to`in e.run)||gr(e.run.to,{models:n,pages:new Set,source:t}).length===0,oh=(e,t)=>({...e,layout:e.layout.flatMap(e=>ih(e,t)),actions:e.actions.filter(n=>ah(n,t[e.resource],t))}),sh=(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=>rh(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=>oh(e,a)),permissions:Object.fromEntries(n.flatMap(t=>e.permissions?.[t.name]?[[t.name,e.permissions[t.name]]]:[]))}},ch=class extends Error{status;code;constructor(e,t,n){super(e),this.status=t,this.code=n,this.name=`AuthError`}},q=(e,t)=>new ch(e?.message||t,e?.status??500,e?.code),lh=e=>new Date(e).toISOString(),uh=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:lh(e.createdAt),updatedAt:lh(e.updatedAt),expiresAt:lh(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`)}}),dh=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}}),fh=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`)}}),ph=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`)}}),mh=(e,t)=>new ch(e?.message||e?.error_description||t,e?.status??500,e?.code??e?.error),hh=e=>({client:async t=>{let{data:n,error:r}=await e.$fetch(`/oauth2/public-client`,{query:{client_id:t}});if(r||!n)throw mh(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 mh(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 mh(i,`Could not answer the request`);return{url:r.url}}}),gh=(e,t,n)=>g({baseURL:e,basePath:t,plugins:[m(),re(),b(),ae()],disableDefaultFetchPlugins:!0,fetchOptions:{customFetchImpl:n}}),_h=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):typeof e==`string`?JSON.parse(e):[],vh=e=>{let t=e.split(`,`);return t.includes(`owner`)?`owner`:t.includes(`admin`)?`admin`:`member`},yh=e=>({id:e.id,userId:e.userId,name:e.user.name||e.user.email,email:e.user.email,role:vh(e.role),appRoles:_h(e.appRoles),createdAt:new Date(e.createdAt).toISOString()}),bh=e=>({id:e.id,email:e.email,role:vh(e.role),appRoles:_h(e.appRoles),status:e.status,expiresAt:new Date(e.expiresAt).toISOString(),...e.organizationName&&{organizationName:e.organizationName}}),xh=(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(),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(yh),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(bh),invite:async(e,t)=>{let r=await n(`/organization/invite-member`,`Could not send the invitation`,{body:{organizationId:e,...t}});return{invitation:bh(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:bh(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(bh),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}}))}},Sh=(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()}}),Ch=20,wh=e=>Array.isArray(e)?e:(e??``).split(`,`).map(e=>e.trim()).filter(Boolean),Th=e=>({id:e.id,name:e.name||e.email,email:e.email,roles:wh(e.role),blocked:!!e.banned,createdAt:new Date(e.createdAt).toISOString()}),Eh=e=>({id:e.id,email:e.email,roles:e.roles,expiresAt:new Date(e.expiresAt).toISOString()}),Dh=e=>({invitation:Eh(e),...e.link&&{link:e.link}}),Oh=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(Ch),sortBy:`createdAt`,sortDirection:`asc`,...n>0&&{offset:String(n)},...e&&{searchValue:e,searchField:`email`}}});return{users:r.users.map(Th),total:r.total}},create:async e=>Th((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=>Dh(await t(`/users/invite`,`Could not send the invitation`,{body:e})),invitations:async()=>(await t(`/users/invitations`,`Could not read the invitations`)).invitations.map(Eh),revoke:e=>t(`/users/invitations/cancel`,`Could not revoke the invitation`,{body:{id:e}}),roles:()=>t(`/users/roles`,`Could not read the roles`)}},kh=(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 ie({optionsJSON:r.data}).catch(e=>{throw new ch(`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}}},Ah=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}}),jh=e=>new Date(e).toISOString(),Mh=({startedAt:e,expiresAt:t,endedAt:n,...r})=>({...r,startedAt:jh(e),expiresAt:jh(t),...n&&{endedAt:jh(n)}}),Nh=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?Mh(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(Mh)}}),Ph=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},Fh=(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=gh(t,n,i),o=Nh(a),s,c,l,u=()=>{s=void 0,clearTimeout(l)},d=async()=>{let{data:t}=await a.$fetch(`/token`);if(!t?.token){u();return}return s={token:t.token,expiresAt:Ph(t.token)},clearTimeout(l),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 ch(`This server has no sign-in. Is the API URL right?`,404);if(!e.ok)throw new ch(`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},...Pr(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},...kh(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:{...dh(a),...uh(a),...ph(a),...fh(a)},connect:hh(a),organizations:xh(a,()=>f({refresh:!0})),roles:Sh(a,()=>f({refresh:!0})),signInPolicy:Ah(a),users:Oh(a),staff:{...o,stop:async()=>{u(),await o.stop()}}}},Ih=e=>Math.min(3e4,1e3*2**e),Lh=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),Rh=`http://same-origin.invalid`,zh=(e,t)=>{let n=new URL(e,Rh),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===Rh?`${r.pathname}${r.search}`:r.href},Bh=e=>{let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>fetch(e,t)),r=e.retryDelayMs??Ih,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 Ed(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 Mr(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 Lh(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=zh(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 Ed(c);return c}}},Vh=e=>e.Capacitor?.isNativePlatform()?e.Capacitor:void 0,Hh=[101,204,205,304],Uh=/%2f|%5c/i,Wh=e=>Object.hasOwn(Xr,e),Gh=(e,t)=>e.origin===t&&!e.username&&!e.password&&e.pathname.startsWith(`/api/auth/`)&&!Uh.test(e.pathname),Kh=({status:e,headers:t,data:n})=>Hh.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),qh=(e,t)=>{let n=e.getPlatform();if(!Wh(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(!Gh(a,t))throw Error(`Native sign-in requests go to ${t}${Jr}/ 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(Kh(s),{status:s.status,headers:c})}},Jh=e=>e?.isPluginAvailable(`ProtobaseAuth`)?e:void 0,Yh,Xh,Zh=({dsn:e,environment:t})=>(Yh??=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:[dr],behaviour:`drop-error-if-exclusively-contains-third-party-frames`})],beforeSend:e=>ur(e)}),Xh=(e,t)=>n.captureException(e,t?{contexts:{react:{componentStack:t}}}:void 0)}),__vite__mapDeps([0,1,2,3,4])),Yh),Qh=(e,t)=>Xh?.(e,t??void 0),$h=e=>Xh?.(e),eg=class extends Error{reason;constructor(e){super(`The push service gave the app no push token: ${e}`),this.reason=e,this.name=`PushRegistrationError`}},tg=class extends Error{service;constructor(e,t){super(`The push service gave the app no push token within ${t} ms`),this.service=e}},ng=class extends Error{constructor(){super(`Push is off, but this device could not store that the user turned it off`)}},rg=e=>e instanceof eg?{kind:`registration`,reason:e.reason}:e instanceof tg?{kind:`no-token`,service:e.service}:e instanceof ng?{kind:`off-not-stored`}:e instanceof Sd?{kind:`refused`,reason:e.message}:{kind:`other`,reason:e instanceof Error?e.message:String(e)},ig=`PushNotifications`,ag=(e,t)=>Promise.race([t,new Promise(t=>setTimeout(t,e))]),og=class extends Error{},sg=(e,t)=>e instanceof Sd&&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(ig,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 tg(e.getPlatform()===`ios`?`apns`:`fcm`,l))),l);r=[e.addListener(ig,`registration`,e=>i(()=>t(e.value))),e.addListener(ig,`registrationError`,e=>i(()=>n(new eg(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 og;let i=await a.register({...await t(r),userAgent:s,userId:e.id});if(!n())throw new og;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 eg)throw await h(e),e;if(await m(),e instanceof og)return`off`;if(!sg(e,`device-held`))throw e;try{await i()}catch(e){if(e instanceof eg)throw await h(e),e;if(await m(),e instanceof og)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 ng},b=async e=>{await n.clear(),await ag(c,Promise.allSettled([d(`removeAllDeliveredNotifications`),d(`unregister`),e?.deviceId?a.remove(e.deviceId):Promise.resolve()]))},x=async()=>{await n.clear(),await ag(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 og)return;if(e instanceof eg)return h(e);if(!sg(e,`device-held`)&&!sg(e,`other-user`))throw e;await m()}}}}}},lg=`ProtobasePush`,ug=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(lg,`apns`,{});return{kind:`apns`,token:t.toLowerCase(),appId:n,environment:r}}},dg=e=>e.replace(/[\u0000-\u001f\u007f]/g,``).slice(0,512),fg=(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(`/${Qr}`),t.serviceWorker.ready),clearBadge:async()=>{`clearAppBadge`in t&&await t.clearAppBadge()},userAgent:dg(t.userAgent)}},pg=/\bAndroid (\d+)/,mg=(e,t)=>{if(e===`ios`)return!0;let n=pg.exec(t)?.[1];return e===`android`&&n!==void 0&&Number(n)>=13},hg=`protobase:push-choices`,gg=e=>{let t=new Map,n=()=>{try{let t=JSON.parse(e().getItem(hg)??`{}`);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(hg,JSON.stringify({...n(),[r]:i})),!0}catch{return!1}}}},_g=(e=indexedDB)=>{let t=(t,n)=>new Promise((r,i)=>{let a=e.open(Zr.database,1);a.onupgradeneeded=()=>a.result.createObjectStore(Zr.store),a.onerror=()=>i(a.error),a.onsuccess=()=>{let e=a.result,o=n(e.transaction(Zr.store,t).objectStore(Zr.store));o.onsuccess=()=>(e.close(),r(o.result)),o.onerror=()=>(e.close(),i(o.error))}});return{read:()=>t(`readonly`,e=>e.get(Zr.key)),write:async e=>void await t(`readwrite`,t=>t.put(e,Zr.key)),clear:async()=>void await t(`readwrite`,e=>e.delete(Zr.key))}},vg=e=>Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0)),yg=(e,t)=>Promise.race([t,new Promise(t=>setTimeout(t,e))]),bg=class extends Error{},xg=(e,t)=>e instanceof Sd&&e.status===409&&e.slug===t,Sg=({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 bg;let e=await c.pushManager.getSubscription()??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:vg(a)}),i={userId:n.id,endpoint:e.endpoint,appName:r};if(await t.write(i),!o())throw new bg;await d(e,i)};try{await h()}catch(e){if(xg(e,`device-held`))return await u(c),m(c,h);if(await u(c),e instanceof bg||xg(e,`other-user`))return`off`;throw e}return`on`},m=async(e,t)=>{try{await t()}catch(t){if(await u(e),t instanceof bg||xg(t,`device-held`)||xg(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 yg(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 yg(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(!xg(e,`device-held`)&&!xg(e,`other-user`))throw e;await u(r)}}}},Cg={state:async()=>`unsupported`,turnOn:async()=>`unsupported`,turnOff:async()=>{},forget:async()=>{},adopt:async()=>{}},wg=({nativeBridge:e,...t})=>{if(typeof window>`u`)return Cg;if(e){let n=ug(e);if(!n)return Cg;let{devices:r,user:i,waitMs:a}=t;return cg({bridge:e,device:n,records:_g(),choices:gg(()=>localStorage),permissionAsked:mg(e.getPlatform(),navigator.userAgent),devices:r,user:i,userAgent:dg(navigator.userAgent),report:$h,...a!==void 0&&{waitMs:a}})}let n=fg();return n.supported?Sg({...t,browser:n,records:_g()}):Cg},Tg=e=>e===`http:`||e===`https:`,Eg=(e,t=(e,t)=>fetch(e,t))=>{if(Tg(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)}}},Dg=e=>e!==void 0&&URL.canParse(e)&&Tg(new URL(e).protocol),Og=async(e,t)=>{let n=!1;try{n=!!await e?.()}finally{n||await t()}},kg=`sign-in`,Ag=`error`,jg=e=>{let t=new URL(e).searchParams;if(!t.has(Ag))return t.get(`sign-in`)||void 0},Mg=e=>new URL(e).searchParams.get(Ag)||void 0,Ng=[`totp`,`otp`],Pg=e=>{let t=new URL(e).searchParams.get(Yr);if(t!==null)return t.split(`,`).filter(e=>Ng.includes(e))},Fg=e=>{let t=new URL(e);for(let e of[kg,Ag,Yr])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},Ig={github:`GitHub`,gitlab:`GitLab`,google:`Google`,microsoft:`Microsoft`,apple:`Apple`},Lg=(e,t=[])=>t.find(t=>t.provider===e)?.name??Ig[e]??e.charAt(0).toUpperCase()+e.slice(1),Rg=e=>e.filter(({linkOnly:e})=>!e),zg=e=>e.kind===`signed-in`&&!e.staff,Bg=(e,t)=>e.kind===`loading`||e.kind===`error`?`leave`:e.kind!==`signed-in`||!zg(e)?`clear`:t?{save:{user:e.user,status:t}}:`leave`,Vg=(0,M.createContext)(null),Hg=[`password`],Ug=[],Wg=[],Gg=[],Kg=[],qg=[],J=()=>{let e=(0,M.useContext)(Vg);if(!e)throw Error(`useAuth must be used inside AuthProvider`);return e},Jg=()=>(0,M.useContext)(Vg),Yg=({session:e,origin:t,nativeBridge:n,afterSignIn:r,children:i})=>{let a=ea(),[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??Hg,f=l?.signInFirst??`password`,p=Jh(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??Ug,S=l?.socialProviders??Ug,C=l?.platformProviders??Kg,w=l?.personalMail??Wg,T=l?.samlProviders??Gg,E=l?.staffSignIn,D=!!l?.deviceLinks,O=l?.organizations,k=!!l?.anonymous,A=l?.plugins??qg,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()=>{}),j=(0,M.useRef)(0),ie=(0,M.useCallback)(()=>{j.current+=1,re.current(),c(e=>e.kind===`signed-in`?{kind:`signed-out`}:e)},[]),ae=(0,M.useRef)(ie);ae.current=ie;let N=(0,M.useMemo)(()=>{if(e)return e;let n=Dg(t)?void 0:Eg(window.location),r=n?.origin??t;return Fh({...r&&{origin:r},...n&&{fetch:n.fetch},...p&&{fetch:qh(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 P=(0,M.useMemo)(()=>{let e=bf({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 wg({...n&&{nativeBridge:n},devices:e.devices,meta:r,user:()=>oe.current})},[N,t,n]);re.current=P.forget;let se=(0,M.useRef)(r);se.current=r;let ce=(0,M.useCallback)(async(e,t=j.current)=>{let[{missing:n},r]=await Promise.all([N.account.signInMethods(),N.staff.current()]);j.current===t&&(c(n.length>0?{kind:`setup-required`,user:e,missing:n}:{kind:`signed-in`,user:e,...r&&{staff:r}}),n.length===0&&P.adopt({id:e.id,own:!r}))},[N,P]),le=(0,M.useCallback)(async e=>{let t=j.current;await Og(se.current,()=>ce(e,t))},[ce]),ue=(0,M.useCallback)(async e=>e.kind===`two-factor`?c({kind:`two-factor`,methods:e.methods}):le(e.user),[le]),de=(0,M.useCallback)(()=>{let e=j.current;c(e=>e.kind===`signed-in`?e:{kind:`loading`}),N.status().then(async t=>{if(u(t),j.current!==e)return;if(t.needsAdmin)return c({kind:`needs-admin`,...t.firstAdminUrl&&{firstAdminUrl:t.firstAdminUrl}});let n=await N.session();if(j.current!==e)return;if(n)return ce(n,e);let r=Pg(window.location.href);c(r?{kind:`two-factor`,methods:r}:{kind:t.anonymous?`visitor`:`signed-out`})}).catch(t=>{j.current===e&&c(e=>e.kind===`signed-in`?e:{kind:`error`,...t instanceof Error&&{message:t.message}})})},[N,ce]);(0,M.useEffect)(de,[de]),(0,M.useEffect)(()=>{if(!a)return;let e=Bg(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:Lg(e,C),...C.some(t=>t.provider===e&&t.button===!1)&&{linkOnly:!0}})),...T],platformProviders:C,deviceLinks:D,staffSignIn:E,...O&&{organizations:O},markSignedOut:ie,recheck:de,beforeSignIn:A,locale:ee,identity:te,adoptSession:async()=>{let e=await N.session();return e?(await le(e),!0):!1},...k&&{browse:()=>{c(e=>e.kind===`signed-out`?{kind:`visitor`}:e)}},signIn:async(e,t)=>ue(await N.signIn(e,t)),sendSignInCode:e=>N.sendSignInCode(e),signInWithCode:async(e,t)=>ue(await N.signInWithCode(e,t)),sendSignUpCode:e=>N.sendSignUpCode(e),verifySignUpCode:(e,t)=>N.verifySignUpCode(e,t),signUp:async e=>le(await N.signUp(e)),signInWithPasskey:async e=>le(await N.signInWithPasskey(e)),verifyTwoFactor:async e=>le(await N.verifyTwoFactor(e)),signInSocial:async e=>{let t=new URL(Fg(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(Fg(window.location.href),window.location.href).href))},personalMail:w,linkPersonalMail:async e=>{window.location.assign(await N.account.linkPersonalMail(e,new URL(Fg(window.location.href),window.location.href).href))},connectAccount:async e=>{window.location.assign(await N.account.connectAccount(e,new URL(Fg(window.location.href),window.location.href).href))},stopStaffSession:async()=>{j.current+=1,await P.forget(),await N.staff.stop(),c(ne())},signOut:async()=>{j.current+=1,await P.turnOff(),await N.signOut(),c(ne())},deleteAccount:async e=>{await N.deleteAccount(e),j.current+=1,await P.forget(),c(ne())},push:P}),[P,s,N,d,f,m,h,g,_,v,y,b,x,S,C,D,w,T,E,O,k,A,ee,te,ne,ie,de,ue,le]);return(0,R.jsx)(Vg.Provider,{value:fe,children:i})},Xg=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)}}},Zg=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Qg=(e,{apiOrigin:t,userId:n,basePath:r})=>{if(!Zg(e)||n===void 0||e.user!==n)return;let i=ci(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}`}},$g=`protobase.push.tap`,e_=({storage:e,reloading:t})=>({receive:(n,r)=>{if(!t())return r(n);e.setItem($g,JSON.stringify(n??null))},resume:t=>{let n=e.getItem($g);if(n===null)return;e.removeItem($g);let r;try{r=JSON.parse(n)}catch(e){if(e instanceof SyntaxError)return;throw e}t(r)}}),t_=`ProtobaseExternal`,n_=async(e,{bridge:t,navigate:n})=>{if(e.kind===`in-app`)return n(e.path);t.isPluginAvailable(t_)&&await t.nativePromise(t_,`open`,{url:e.url})},r_=e=>typeof e==`object`&&e?e.notification?.data:void 0,i_=({nativeBridge:e,apiOrigin:t})=>{let{state:n}=J(),{navigate:r,basePath:i}=Ou(),a=n.kind===`signed-in`?n.user.id:void 0,o=(0,M.useRef)(()=>{});o.current=n=>{let o=Qg(n,{apiOrigin:t,userId:a,basePath:i});o&&n_(o,{bridge:e,navigate:r})};let[s]=(0,M.useState)(()=>Xg(e=>o.current(e))),[c]=(0,M.useState)(()=>{let e=ce(()=>window.sessionStorage,void 0);return e&&e_({storage:e,reloading:()=>Ha(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(ig,`pushNotificationActionPerformed`,e=>c?c.receive(r_(e),s.tap):s.tap(r_(e)));return c?.resume(s.tap),()=>void t.remove()},[e,s,c]),null},Y=I(`account`),a_=`/-/account`,o_=`/-/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?`${a_}/${encodeURIComponent(e)}`:a_,l_=(e,t,n)=>[{id:`account`,label:Y(`account`),icon:Pl,href:`${e}${a_}`,active:s_(t)!==void 0},...n?[{id:`sign-in-policy`,label:Y(`signInPolicy`),icon:ol,href:`${e}${o_}`,active:t===o_}]:[]],u_=()=>{let e=0;return{refetchOnWindowFocus:()=>e>0?!1:`always`,paused:()=>e>0,pause:()=>{e+=1;let t=!1;return()=>{t||(t=!0,--e)}}}},d_=(0,M.createContext)(null),f_=e=>{let t=(0,M.useContext)(d_);(0,M.useEffect)(()=>e&&t?t.pause():void 0,[e,t])},p_=e=>{let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),window.addEventListener(`focus`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t),window.removeEventListener(`focus`,t)}},m_=(0,M.createContext)(0),h_=(e,t)=>e.data!==void 0&&e.dataUpdatedAt<t,g_=(e,t)=>{let n=e.filter(e=>h_(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`},__=(e,t)=>e.getQueryCache().subscribe(e=>{e.type===`updated`&&e.action.type===`error`&&h_(e.query.state,t)&&e.query.setState({status:`success`,error:null})}),v_=()=>{let e=x().getQueryCache(),t=(0,M.useContext)(m_),n=(0,M.useCallback)(t=>e.subscribe(t),[e]),r=(0,M.useCallback)(()=>g_(e.findAll({type:`active`}),t),[e,t]);return(0,M.useSyncExternalStore)(n,r,r)},y_=(0,M.createContext)(null),b_=(0,M.createContext)(null),x_=(0,M.createContext)(null),X=()=>{let e=(0,M.useContext)(y_);if(!e)throw Error(`useClient must be used inside ApiProvider`);return e},S_=e=>{let t=X();return(0,M.useContext)(x_)?.(e)??t},C_=()=>{let e=X(),t=(0,M.useContext)(x_);return(0,M.useCallback)(n=>t?.(n)??e,[e,t])},w_=()=>{let e=(0,M.useContext)(b_);if(!e)throw Error(`useSourceClients must be used inside ApiProvider`);return e},T_=({client:e,resourceClient:t,children:n})=>(0,R.jsx)(y_.Provider,{value:e,children:(0,R.jsx)(x_.Provider,{value:t,children:n})}),E_=({baseUrl:e,client:t,sources:n,fetch:r,queryClient:i,token:a,onUnauthenticated:o,persistence:s,children:c})=>{let[l]=(0,M.useState)(u_),[{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?__(u,d):void 0,[s,u,d]),(0,M.useEffect)(()=>v.setEventListener(p_),[]);let f=(0,M.useRef)(void 0),p=(0,M.useMemo)(()=>t??bf({baseUrl:e,fetch:r,token:a,onUnauthenticated:o,onMetaVersion:e=>{let t=f.current;f.current=e,t!==void 0&&t!==e&&(u.getQueryData(L.meta)?.versionChange||u.invalidateQueries({queryKey:L.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=bf({baseUrl:t.url,fetch:r,token:a,onMetaVersion:e=>{let n=o;o=e,n!==void 0&&n!==e&&u.invalidateQueries({queryKey:L.sourceMetas(t.url)},{cancelRefetch:!1})}});return e.set(t.url,s),s}},[n,r,a,u]);return(0,R.jsx)(E,{client:u,children:(0,R.jsx)(y_.Provider,{value:p,children:(0,R.jsx)(b_.Provider,{value:m,children:(0,R.jsx)(d_.Provider,{value:l,children:(0,R.jsx)(m_.Provider,{value:d,children:c})})})})})},D_=(0,M.createContext)(null),O_={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,A_=()=>{let e=X(),t=x(),n=(0,M.useContext)(D_),r=(0,M.useContext)(m_),i=O({queryKey:L.meta,staleTime:0,refetchOnWindowFocus:`always`,enabled:e=>!e.state.data?.versionChange,queryFn:async()=>{let n=t.getQueryData(L.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(L.meta);return k_(a&&h_(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,M_=e=>e.map(e=>({data:e.data?.meta,error:e.error})),N_=(e,t)=>{let n=x(),r=ee({queries:e.map(e=>{let r=L.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:sh(a.meta,e)}}}}),combine:M_});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])},P_=(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}},F_=(e,t)=>e.sources?.find(e=>e.source.resources.includes(t)),I_=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()}}},L_=(0,M.createContext)(void 0),R_=({value:e,children:t})=>(0,R.jsx)(L_.Provider,{value:e,children:t}),z_=()=>{let e=(0,M.useContext)(L_);return(0,M.useEffect)(()=>e?.hold(),[e]),null},B_=({locale:e,children:t})=>(Fi(e)||(0,M.use)(Ii(e)),t),V_=({locale:e,children:t})=>(0,R.jsx)(M.Suspense,{fallback:(0,R.jsx)(z_,{}),children:(0,R.jsx)(B_,{locale:e,children:t})}),H_=({locale:e,children:t})=>(0,R.jsx)(V_,{locale:e??Ti(),children:(0,R.jsx)(U_,{locale:e,children:t})}),U_=({locale:e,children:t})=>{Di(e);let n=wi();return(0,M.useEffect)(()=>{document.documentElement.lang=n},[n]),(0,R.jsx)(M.Fragment,{children:t},n)},W_=(0,M.createContext)(void 0),G_=()=>(0,M.useContext)(W_),K_=e=>typeof e==`object`&&!!e&&!Array.isArray(e),q_=(e,t)=>Qm(t,String(e.props.i18nKey),K_(e.props.values)?e.props.values:{}),J_=(e,t)=>e.custom||!Object.values(e.props).some($m)?e:{...e,props:Object.fromEntries(Object.entries(e.props).map(([e,n])=>[e,$m(n)?q_(n,t):n]))},Y_=(e,t)=>{let n=J_(e,t);if(e.custom||e.type!==`Tabs`)return n;let r=n.children.map(e=>typeof e==`string`?e:J_(e,t));return r.some((e,t)=>e!==n.children[t])?{...n,children:r}:n},X_=`app/built-in-views`,Z_=I(X_),Q_=(e,t)=>Object.hasOwn(Ri(wi())[X_],e)?Z_(e):t,$_=(e,t)=>({...t,...t.label!==void 0&&{label:Q_(`${e}.label`,t.label)},...t.help!==void 0&&{help:Q_(`${e}.help`,t.help)},...t.valueLabels&&{valueLabels:Object.fromEntries(Object.entries(t.valueLabels).map(([t,n])=>[t,Q_(`${e}.values.${t}`,n)]))}}),ev=(e,t)=>{let n=t;return{...t,...n.title!==void 0&&{title:Q_(`${e}.title`,n.title)},...n.help!==void 0&&{help:Q_(`${e}.help`,n.help)},...n.empty!==void 0&&{empty:Q_(`${e}.empty`,n.empty)}}},tv=e=>e.name===`record_history`&&e.table.name===`history`?`changes.history`:`${e.table.schema??`public`}.${e.table.name}`,nv=(e,t)=>({...t,label:Q_(`${e}.label`,t.label),...t.confirm!==void 0&&{confirm:Q_(`${e}.confirm`,t.confirm)}}),rv=(e,t)=>{if(!t)return e;let n=tv(t);return{...e,...e.names&&{names:{singular:Q_(`${n}.names.singular`,e.names.singular),plural:Q_(`${n}.names.plural`,e.names.plural)}},...e.help!==void 0&&{help:Q_(`${n}.help`,e.help)},fields:Object.fromEntries(Object.entries(e.fields).map(([e,t])=>[e,$_(`${n}.fields.${e}`,t)])),layout:e.layout.map((e,t)=>ev(`${n}.layout.${t}`,e)),actions:e.actions.map(e=>nv(`${n}.actions.${e.name}`,e))}},iv=e=>({...e,views:Object.fromEntries(Object.entries(e.views).map(([t,n])=>[t,rv(n,e.resources[n.resource])]))}),av=I(`app/meta-gate`),ov=()=>{let e=(0,M.useContext)(D_);if(!e)throw Error(`useAdminMeta must be used inside MetaGate`);return e},sv=({title:e,children:t})=>(0,R.jsx)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center p-8`,children:(0,R.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,R.jsx)(`h1`,{className:`text-base font-semibold`,children:e}),(0,R.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]})}),cv=({meta:e,children:t})=>{let n=X(),r=w_(),i=(0,M.useMemo)(()=>(e.sources??[]).map(e=>e.source),[e.sources]),a=N_(i,r),o=(0,M.useMemo)(()=>P_(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:Sf(n,t),resourceClient:t}},[i,n,r]);return(0,R.jsx)(T_,{client:s.client,resourceClient:s.resourceClient,children:(0,R.jsx)(H_,{locale:e.locale,children:(0,R.jsx)(W_.Provider,{value:e.texts,children:(0,R.jsx)(lv,{meta:o,children:t})})})})},lv=({meta:e,children:t})=>{let n=(0,M.useMemo)(()=>iv(e),[e]);return(0,R.jsx)(D_.Provider,{value:n,children:t})},uv=({children:e})=>{let t=A_();return t.isPending?(0,R.jsxs)(`div`,{className:z(`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,lu),children:[(0,R.jsx)(z_,{}),(0,R.jsx)(Ql,{}),` `,av(`loading`)]}):t.error?(0,R.jsx)(sv,{title:av(`cannotReach`),children:wd(t.error)?t.error.message:av(`noAnswer`)}):(0,R.jsx)(cv,{meta:t.data,children:e})},dv=e=>ov().permissions[e]??O_,fv=(e,t)=>{let n=wp(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},pv=I(`auth/errors`),mv={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`},hv=(e,t)=>{let n=t?e[t]:void 0;return n&&pv(n)},gv=e=>hv(mv,e.code),_v=e=>gv(e)??(e.status===429?pv(`tooManyRequests`):e.message),vv=e=>gv(e)??(e.status===429?pv(`tooManyRequests`):e.status===401?pv(`wrongEmailOrPassword`):e.message),yv={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=>hv(yv,typeof e==`string`?e:e.code)||(typeof e==`string`?pv(`staffFailed`):e.status===429?pv(`tooManyRequests`):e.message),xv={signup_disabled:e=>pv(`signupDisabled`,{name:e}),account_not_linked:e=>pv(`notLinked`,{name:e}),account_already_linked_to_different_user:e=>pv(`linkedToOther`,{name:e}),unable_to_link_account:e=>pv(`couldNotLink`,{name:e}),access_denied:e=>pv(`accessDenied`,{name:e}),EMAIL_DOMAIN_NOT_ALLOWED:e=>pv(`domainNotAllowed`,{name:e})},Sv=(e,t)=>xv[e]?.(t)??pv(`providerFailed`,{name:t}),Cv=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`,Tv=`#111827`,Ev=e=>{let t=Cv(e);return 1.05/(t+.05)>=(t+.05)/(Cv(Tv)+.05)?wv:Tv},Dv={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`},Ov={neutral:`bg-faint-foreground`,blue:`bg-primary`,green:`bg-success`,amber:`bg-warning`,red:`bg-danger`,violet:`bg-violet`},kv=`polygon(0 0, calc(100% - 0.625rem) 0, 100% 50%, calc(100% - 0.625rem) 100%, 0 100%)`,Av=({tone:e=`neutral`,dot:t=!0,color:n,shape:r,children:i,className:a})=>(0,R.jsxs)(`span`,{style:{...n!==void 0&&{backgroundColor:n,color:Ev(n)},...r===`arrow`&&{clipPath:kv}},className:z(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&&Dv[e],a),children:[t&&n===void 0&&r===void 0&&(0,R.jsx)(`span`,{className:z(`size-1.5 rounded-full`,Ov[e])}),i]}),jv=({title:e,status:t,description:n,children:r})=>(0,R.jsxs)(`section`,{"aria-label":e,className:`rounded-lg border bg-background p-4 sm:p-5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t]}),(0,R.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}),r&&(0,R.jsx)(`div`,{className:`mt-4`,children:r})]}),Mv=({message:e})=>e?(0,R.jsx)(`p`,{role:`alert`,className:`mb-3 text-body font-medium text-danger-text`,children:e}):null,Nv=({message:e})=>e?(0,R.jsx)(`p`,{role:`status`,className:`mb-3 font-medium`,children:e}):null,Pv=({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 ch))throw e;f(_v(e)),u(void 0)}};return(0,R.jsxs)(jv,{title:o,description:s,children:[(0,R.jsx)(Mv,{message:d}),(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,R.jsx)(Ks,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),a[e.id]&&(0,R.jsx)(`span`,{className:`block text-muted-foreground`,children:a[e.id]})]}),t.includes(e.id)&&(0,R.jsx)(Av,{tone:`green`,children:Y(`connected`)}),(!t.includes(e.id)||i)&&(0,R.jsx)(V,{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]})},Fv=({error:e})=>e?(0,R.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:e}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Ql,{}),` `,Y(`loading`)]}),Iv=(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 ch?_v(e):t)})},[e,t]);return(0,M.useEffect)(()=>{s()},[s]),{data:n?.value,loaded:n!==void 0,error:i,reload:s}},Lv=()=>{let e=Mg(window.location.href);return e&&window.history.replaceState(window.history.state,``,Fg(window.location.href)),e},Rv=({providers:e})=>{let{session:t,linkProvider:n}=J(),{account:r}=t,[i]=(0,M.useState)(Lv),{data:a,error:o}=Iv((0,M.useCallback)(()=>r.linkedProviders(),[r]),Y(`couldNotReadMethods`));return a?(0,R.jsx)(Pv,{providers:e,linked:a,onConnect:n,error:i&&Sv(i,e.length===1?e[0].name:Y(`theProvider`))}):(0,R.jsx)(Fv,{error:o})},zv=({signInProviders:e,socialProviders:t,platformProviders:n})=>e.filter(e=>t.includes(e.id)&&!n.some(t=>t.provider===e.id&&t.hidden)),Bv=()=>{let e=zv(J());return e.length>0?(0,R.jsx)(Rv,{providers:e}):null},Vv=()=>{let{account:e}=ov(),t=J(),{mcp:n,personalAccessTokens:r,accountDeletion:i}=t,a=zv(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:fv(e.tree,t)}},[e,n,r,a,o,i])},Hv=e=>(0,M.useSyncExternalStore)(t=>{let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},()=>window.matchMedia(e).matches,()=>!1),Uv=()=>Hv(`(min-width: 768px)`),Wv=()=>Hv(`not all and (min-width: 640px)`),Gv=`ProtobaseTabBar`,Kv=(e,t)=>{let n=typeof e==`object`&&e?e[t]:void 0;return typeof n==`number`&&Number.isFinite(n)?n:void 0},qv=e=>{if(!e?.isPluginAvailable(`ProtobaseTabBar`))return;let t=(t,n,r,i)=>{let a=e.addListener(Gv,t,e=>{let t=Kv(e,n);t!==void 0&&r(t)&&i(t)});return()=>void a.remove()};return{set:async t=>{let n=Kv(await e.nativePromise(Gv,`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)}},Jv=(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}),Yv=(0,M.createContext)(void 0),Xv=()=>(0,M.useContext)(Yv),Zv=new Map,Qv=72,$v=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=Zv.get(n);return r||(r=new Promise(e=>{let t=new Image;t.onload=()=>{let n=document.createElement(`canvas`);n.width=Qv,n.height=Qv;let r=n.getContext(`2d`);if(!r)return e(null);r.drawImage(t,0,0,Qv,Qv),e(n.toDataURL(`image/png`))},t.onerror=()=>e(null),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}),Zv.set(n,r)),r},ey=(e,t,n,r,i=[])=>{let a=Xv(),[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=>$v(e.querySelector(`svg`)));return Promise.all(c).then(e=>{o&&a.set(Jv(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}},ty=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,ny=`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`,ry=({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??H(`search`)]:[],H(`more`)],f=d.length-1,p=e.map(e=>e.icon.displayName??e.icon.name),{native:m,height:h}=ey(u,d,l?f:e.findIndex(e=>e.active),n?e.length:void 0,p);return(0,R.jsxs)(R.Fragment,{children:[s&&(0,R.jsx)(`div`,{"aria-hidden":!0,className:`h-[var(--pb-sticky-bottom)] shrink-0 md:hidden`}),(0,R.jsxs)(`nav`,{ref:u,"aria-label":H(`tabs`),"aria-hidden":m||void 0,className:z(`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,R.jsxs)(`a`,{href:e.href,"aria-current":e.active?`page`:void 0,...e.external?{target:`_blank`,rel:`noreferrer`}:{},onClick:n=>{!e.external&&t&&ty(n)&&(n.preventDefault(),t(e.href))},className:z(ny,e.active?`text-primary-text`:`text-muted-foreground`),children:[(0,R.jsx)(n,{className:`size-6`,strokeWidth:e.active?2.2:1.9,"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`max-w-full truncate px-0.5`,children:e.label})]},e.id)}),n&&(0,R.jsxs)(`button`,{type:`button`,onClick:n,className:z(ny,`text-muted-foreground`),children:[(0,R.jsx)(Xc,{className:`size-6`,strokeWidth:1.9,"aria-hidden":!0}),r??H(`search`)]}),(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":a,"aria-controls":o,"data-current":l||void 0,onClick:i,className:z(ny,l?`text-primary-text`:`text-muted-foreground`),children:[(0,R.jsx)(gs,{className:`size-6`,strokeWidth:l?2.2:1.9,"aria-hidden":!0}),H(`more`)]})]})]})},iy=`protobase:close-sidebar`,ay=e=>{(0,M.useEffect)(()=>(window.addEventListener(iy,e),()=>window.removeEventListener(iy,e)),[e])},oy=.35,sy=`cubic-bezier(0.25, 1, 0.5, 1)`,cy=(e,t)=>Math.abs(t)>=500?t>0:e>=.5,ly=e=>e>0?40*(1-1/(.55*e/40+1)):0,uy=e=>oy*Math.min(Math.max(e,0),1),dy=(e,t,n)=>e!==0&&Math.abs(t)<=n*Math.abs(e),fy=(e,t,n)=>Math.hypot(e,t)>=10&&dy(e,t,n),py=(e,t,n)=>{let r=e+t/Math.max(1,n);return r<=1?Math.max(r,0):1+ly((r-1)*n)/Math.max(1,n)},my=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,hy=(e,t,n)=>e===`x`?t:-n,gy=(e,t,n)=>e===`x`?n:t,_y=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},vy=({axis:e,panel:t,backdrop:n,onDraggedClosed:r})=>{let i=(0,M.useRef)(void 0),a=(0,M.useRef)(!1),o=()=>{let n=t.current;return n?e===`x`?n.offsetWidth:n.offsetHeight:1},s=(r,i)=>{let a=t.current;if(!a)return;let s=i&&!my()?`350ms ${sy}`:`none`,c=(r-1)*o();a.style.transition=s===`none`?`none`:`transform ${s}`,a.style.transform=r===1?``:e===`x`?`translateX(${c}px)`:`translateY(${-c}px)`;let l=n.current;l&&(l.style.transition=s===`none`?`none`:`opacity ${s}`,l.style.opacity=String(uy(r)/oy))},c=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,c=hy(e,r,a);if(!n.dragging){let i=gy(e,r,a);if(Math.hypot(c,i)<10)return;if(!fy(c,i,n.onBackdrop?1:.58)){n.ignored=!0;return}n.dragging=!0,n.x=t.clientX,n.y=t.clientY,t.currentTarget.setPointerCapture?.(t.pointerId);return}n.along=c,n.samples.push({along:c,time:t.timeStamp}),s(py(n.from,c,o()),!1)},onPointerUp:()=>{let e=i.current;if(i.current=void 0,!e?.dragging)return;a.current=!0;let t=py(e.from,e.along,o());if(cy(Math.min(t,1),_y(e.samples)))return s(1,!0);s(0,!0),setTimeout(r,my()?0:350)},onPointerCancel:()=>{i.current?.dragging&&s(1,!0),i.current=void 0}});return{panelHandlers:c(!1),backdropHandlers:c(!0),dragged:()=>a.current}},yy=({id:e,open:t,onClose:n,children:r})=>{let i=(0,M.useRef)(null),a=(0,M.useRef)(null);ou(i,t,n);let o=(0,M.useRef)(!1),{panelHandlers:s,backdropHandlers:c,dragged:l}=vy({axis:`x`,panel:i,backdrop:a,onDraggedClosed:()=>{o.current=!0,n()}}),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(t);return t!==f&&(p(t),d(!t&&!o.current),t&&(o.current=!1)),(0,M.useEffect)(()=>{if(!u)return;let e=setTimeout(()=>d(!1),200);return()=>clearTimeout(e)},[u]),!t&&!u?null:(0,R.jsxs)(`div`,{className:z(`fixed inset-0 z-50 md:hidden`,u&&`pointer-events-none`),children:[(0,R.jsx)(`div`,{ref:a,className:z(`absolute inset-0 touch-none bg-backdrop/40 motion-reduce:[animation:none]`,u?`[animation:pb-fade-out_200ms_ease-in_forwards]`:`[animation:pb-fade-in_200ms_ease-out]`),onClick:()=>!l()&&n(),...c,"aria-hidden":!0}),(0,R.jsx)(`div`,{ref:i,id:e,role:`dialog`,"aria-modal":`true`,"aria-label":H(`navigation`),"aria-hidden":u||void 0,tabIndex:-1,className:z(`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`,u?`[animation:pb-drawer-out_200ms_ease-in_forwards]`:`[animation:pb-drawer-in_200ms_ease-out]`),onClick:e=>e.target.closest(`a`)&&n(),...s,children:r})]})},by=(0,M.createContext)(()=>{}),xy=e=>{let t=(0,M.useContext)(by);(0,M.useLayoutEffect)(()=>(t(e),()=>t(void 0)),[t,e])},Sy=e=>{(0,M.useLayoutEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`scrollbar-gutter`,`stable`),()=>{t.style.removeProperty(`scrollbar-gutter`)}},[e])},Cy=[`--pb-sticky-top`,`--pb-sticky-bottom`,`scroll-padding-top`,`scroll-padding-bottom`],wy=(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 Cy)r.style.removeProperty(e)}},[e,t,n,r,i])},Ty=`flex min-w-0 items-center gap-2.5`,Ey={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))]`},Dy=({initials:e,hue:t,size:n=`sm`,className:r})=>(0,R.jsx)(`span`,{className:z(`inline-flex shrink-0 select-none items-center justify-center rounded-full font-semibold text-white ring-2 ring-background`,Ey[n],r),style:{background:`oklch(0.58 0.13 ${t})`},children:e}),Oy=({people:e,size:t=`sm`})=>(0,R.jsx)(`span`,{className:`inline-flex -space-x-1`,children:e.map(e=>(0,R.jsx)(Dy,{...e,size:t},e.initials))}),ky=e=>[...e].reduce((e,t)=>(e*31+t.charCodeAt(0))%360,7),Ay=e=>e.split(/[\s@.]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join(``),jy=`fill-[#ff5a1f] dark:fill-[#ff6a33]`,My=`fill-[#14161a] dark:fill-[#f1f0ea]`,Ny=({className:e})=>(0,R.jsxs)(`svg`,{viewBox:`0 0 32 32`,className:z(`size-7 shrink-0`,e),"aria-hidden":!0,children:[(0,R.jsx)(`path`,{className:jy,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,R.jsx)(`path`,{className:My,d:`M17 0h10a5 5 0 0 1 5 5v22a5 5 0 0 1-5 5H5a5 5 0 0 1-5-5V17h17z`})]}),Py={sm:`size-7`,lg:`size-10`},Fy={sm:`md`,lg:`lg`},Iy=({appName:e,appIcon:t,size:n=`sm`,className:r})=>t?(0,R.jsx)(`img`,{src:t,alt:``,className:z(Py[n],`shrink-0 object-contain`,r)}):e&&e!==`Protobase`?(0,R.jsx)(Dy,{initials:Ay(e).slice(0,1),hue:ky(e),size:Fy[n],className:r}):(0,R.jsx)(Ny,{className:z(Py[n],r)}),Ly=`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`,Ry=({className:e})=>(0,R.jsx)(`svg`,{viewBox:`54.8 -720 3743.8 925`,className:z(`h-3.5 w-auto`,e),role:`img`,"aria-label":`Protobase`,children:(0,R.jsx)(`path`,{className:My,d:Ly})}),zy=({compact:e,workspace:t,appName:n,appIcon:r})=>(0,R.jsxs)(`div`,{className:Ty,children:[(0,R.jsx)(Iy,{appName:n,appIcon:r}),!e&&(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 leading-tight`,children:[r||n&&n!==`Protobase`?(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:n??`Protobase`}):(0,R.jsx)(Ry,{className:`self-start`}),t&&(0,R.jsx)(`div`,{className:`truncate text-[0.6875rem] text-muted-foreground`,children:t})]})]}),By=`protobase:logo-tap`,Vy=(e=window)=>{let t=!e.dispatchEvent(new Event(By,{cancelable:!0}));return e.parent&&e.parent!==e&&e.parent.postMessage({type:By},`*`),t},Hy=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}},Uy=`bg-primary border-transparent`,Wy=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`},Gy=(0,M.createContext)(void 0),Ky=()=>{let e=(0,M.useContext)(Gy);return e?{id:e.id,name:e.name,"aria-describedby":e.describedBy,"aria-invalid":e.invalid||void 0,"aria-required":e.required||void 0}:{}},qy=({leading:e,trailing:t,invalid:n,className:r,wrapperClassName:i,...a})=>{let o=Ky();return(0,R.jsxs)(`span`,{className:z(`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,R.jsx)(`input`,{className:z(`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]})},Jy=({children:e})=>(0,R.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}),Yy=(e,t,n)=>Math.min(n-4,Math.max(e,4+t)),Xy=e=>e-8,Zy=(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=Xy(r);n.current.style.maxWidth=`${a}px`;let o=t.current.getBoundingClientRect().right,s=n.current.getBoundingClientRect().width;i({right:o-Yy(o,s,r),maxWidth:a})},[e]),r},Qy=()=>{let e=window.visualViewport;return e?{top:e.offsetTop,height:e.height}:{top:0,height:window.innerHeight}},$y=(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},eb=(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($y(r,i,o,Qy())?-(i+2*o):void 0)},[e,r,o]),i===void 0?void 0:{top:i}},tb=(e,t,n)=>t===0?-1:e<0?n===1?0:t-1:(e+n+t)%t,nb=e=>e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0,rb=({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=Zy(m,g,_),y=eb(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=>tb(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,R.jsxs)(`div`,{ref:g,className:z(`relative`,t),children:[(0,R.jsx)(qy,{ref:b,wrapperClassName:z(`w-full bg-surface shadow-none`,n),leading:e.loading?(0,R.jsx)(Ql,{className:`size-4`}):(0,R.jsx)(Xc,{className:`size-4`}),trailing:e.text?(0,R.jsx)(`button`,{type:`button`,"aria-label":H(`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,R.jsx)(Xl,{className:`size-3.5`})}):i?(0,R.jsx)(`span`,{className:`hidden md:inline-flex`,children:(0,R.jsx)(Jy,{children:`⌘K`})}):void 0,placeholder:e.placeholder,"aria-label":H(`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,R.jsxs)(`div`,{ref:_,id:s,role:`listbox`,"aria-label":H(`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,R.jsx)(`p`,{className:`px-3 py-2 text-muted-foreground`,children:e.loading?H(`searching`):H(`noMatches`,{query:e.query})}),e.groups.map(e=>(0,R.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,R.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,R.jsx)(`p`,{className:`px-3 py-1.5 text-danger-text`,children:H(`couldNotSearch`,{label:e.label})}),e.hits.map(e=>{w+=1;let t=w;return(0,R.jsxs)(`a`,{id:h(t),href:e.href,tabIndex:-1,role:`option`,"aria-selected":t===d,className:z(`block px-3 py-1.5`,t===d?`bg-primary-soft text-primary-text`:`hover:bg-muted`),onMouseDown:e=>e.preventDefault(),onClick:t=>{nb(t)||(t.preventDefault(),x(e.href))},onMouseEnter:()=>f(t),children:[(0,R.jsx)(`span`,{className:`block truncate font-semibold`,children:e.title}),e.subtitle&&(0,R.jsx)(`span`,{className:z(`block truncate text-xs`,t===d?`text-primary-text/80`:`text-muted-foreground`),children:e.subtitle})]},e.id)})]},e.id))]})]})},ib=`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))]`,ab=`size-[min(2.75rem,max(44px,13vw))] shrink-0`,ob=`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))]`,sb=`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))]`,cb=({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,R.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=Hy(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,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`header`,{ref:v,className:z(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?Uy:`bg-background`),children:[a&&(0,R.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-full h-screen bg-primary md:hidden`}),(0,R.jsxs)(`div`,{className:z(`contents`,a&&`text-primary-foreground [&_*]:text-primary-foreground`),children:[f&&(0,R.jsx)(`button`,{type:`button`,"aria-label":H(`openNavigation`),"aria-expanded":!!p,"aria-controls":m,onClick:f,className:z(`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,R.jsx)(ic,{})}),o&&(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,R.jsx)(`div`,{className:`min-w-0`,children:o}),y]}),!o&&s&&(0,R.jsxs)(`div`,{className:z(`flex min-w-0 items-center gap-2.5`,`flex-1`),children:[w&&(0,R.jsx)(`a`,{href:w.href,"aria-label":H(`backTo`,{label:w.label}),onClick:e=>{let t=r??n;t&&du(e)&&(e.preventDefault(),t(w.href))},className:z(`size-7`,`relative flex shrink-0 items-center justify-center rounded-full text-foreground after:absolute after:-inset-2 [&_svg]:size-6`),children:(0,R.jsx)(Bo,{"aria-hidden":!0})}),(0,R.jsx)(fu,{parts:e,onNavigate:n,trailing:y})]}),!o&&!s&&w&&(0,R.jsxs)(`a`,{href:w.href,"aria-label":H(`backTo`,{label:w.label}),onClick:e=>{let t=r??n;t&&du(e)&&(e.preventDefault(),t(w.href))},className:z(w.shown?sb:`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,R.jsx)(Bo,{className:`shrink-0`,"aria-hidden":!0}),w.shown&&(0,R.jsx)(`span`,{className:`truncate`,children:w.label})]}),!o&&!s&&(0,R.jsx)(fu,{parts:e,onNavigate:n,trailing:y}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-1 md:gap-3`,children:[h&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`hidden md:block`,children:(0,R.jsx)(rb,{ref:T,search:h})}),l&&(0,R.jsx)(`button`,{type:`button`,"aria-label":H(`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,R.jsx)(Xc,{})})]}),i,(0,R.jsx)(`div`,{ref:_,className:`contents md:hidden`}),c]})]}),h&&S&&(0,R.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,R.jsx)(rb,{className:`min-w-0 flex-1`,fieldClassName:ob,autoFocus:!0,showShortcut:!1,search:{...h,onSelect:e=>{h.onSelect(e),C(!1)}}}),(0,R.jsx)(`button`,{type:`button`,"aria-label":H(`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,R.jsx)(Xl,{})})]})]}),g&&(0,R.jsx)(`div`,{"aria-hidden":!0,className:`h-[var(--pb-sticky-top,calc(3rem+var(--pb-safe-top)))] shrink-0 md:hidden`})]})},lb=({label:e,current:t,others:n,rowClassName:r,onSwitch:i})=>(0,R.jsxs)(`div`,{className:`border-b py-1`,role:`group`,"aria-label":e,children:[t&&(0,R.jsxs)(`div`,{className:z(r,`text-foreground hover:bg-transparent`),"aria-current":`true`,children:[(0,R.jsx)(Io,{className:`size-4`}),(0,R.jsx)(`span`,{className:`truncate`,children:t.label})]}),n.map(e=>(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>i(e.id),className:r,children:[(0,R.jsx)(`span`,{className:`size-4`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))]}),ub={sm:{group:`h-7`,option:`px-2.5 text-body`},md:{group:`h-8`,option:`px-3 text-body`}},db={group:(e=`sm`)=>z(`inline-flex`,ub[e].group,`rounded-md bg-muted p-0.5`),option:(e,t=`sm`)=>z(`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`)},fb=({value:e,options:t,onChange:n,label:r,size:i=`sm`,iconOnly:a=!1})=>(0,R.jsx)(`span`,{role:`group`,"aria-label":r,className:db.group(i),children:t.map(t=>(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":t.value===e,...a&&{"aria-label":t.label,title:t.label},onClick:()=>n(t.value),className:db.option(t.value===e,i),children:[t.icon&&(0,R.jsx)(t.icon,{className:`size-3.5`}),!a&&t.label]},t.value))}),pb=()=>[{value:`light`,label:H(`light`),icon:gl},{value:`dark`,label:H(`dark`),icon:vc},{value:`system`,label:H(`system`),icon:gc}],mb=({theme:e,className:t})=>(0,R.jsxs)(`div`,{className:t,children:[(0,R.jsx)(ml,{className:`size-4`}),(0,R.jsx)(`span`,{className:`flex-1`,children:H(`theme`)}),(0,R.jsx)(fb,{label:H(`theme`),iconOnly:!0,value:e.preference,options:pb(),onChange:e.onChange})]}),hb=10,gb=100,_b=e=>e>=0?e:-ly(-e),vb=e=>{let t=e.at(-1);if(!t)return 0;let n=e.find(e=>t.time-e.time<=gb)??t,r=t.time-n.time;return r>0?(t.y-n.y)/r:0},yb=(e,t,n)=>e<=hb?!1:!cy(1-e/Math.max(1,t),-n*1e3),bb=(e,t,n)=>e<=0&&n>0&&dy(n,t,.58),xb=350,Sb=sy,Cb=()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,wb=({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&&!Cb()?`${xb}ms ${Sb}`:`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,Cb()))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||Cb())return s.current();o.current=!0,c(t.offsetHeight,!0),setTimeout(()=>s.current(),xb)}},[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(_b(e-n.y),!1))},f=()=>{let t=a.current;a.current=void 0;let n=e.current;if(t?.dragging&&n){if(yb(_b(t.samples.at(-1).y-t.y),n.offsetHeight,vb(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)<hb&&Math.abs(i)<hb)return;if(!bb(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)<hb)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)>=hb&&(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)}}}},Tb=({title:e,open:t,onClose:n,children:r,inset:i=`sides`})=>{let a=(0,M.useRef)(null),o=(0,M.useRef)(null),s=(0,M.useRef)(null),{dismiss:c,header:l}=wb({panel:a,backdrop:o,content:s,open:t,onClose:n});return ou(a,t,c),t?(0,N.createPortal)((0,R.jsxs)(`div`,{className:`fixed inset-0 z-[80]`,children:[(0,R.jsx)(`div`,{ref:o,className:`absolute inset-0 bg-backdrop/40`,onClick:c,"aria-hidden":!0}),(0,R.jsxs)(`div`,{ref:a,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,R.jsxs)(`header`,{className:`relative flex shrink-0 touch-none select-none items-center justify-between border-b px-4 pt-4`,...l,children:[(0,R.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,R.jsx)(`button`,{type:`button`,"aria-label":Zl(`close`),onClick:c,className:`-mr-2 inline-flex size-11 items-center justify-center rounded-md text-muted-foreground hover:bg-muted`,children:(0,R.jsx)(Xl,{className:`size-5`})}),(0,R.jsx)(`button`,{type:`button`,"aria-label":Zl(`dragToClose`),onClick:c,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,R.jsx)(`span`,{className:`h-1 w-9 rounded-full bg-border-strong`})})]}),(0,R.jsx)(`div`,{ref:s,className:z(`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},Eb=`py-1 text-menu-sheet [&>*]:min-h-12 [&_[role=menuitem]]:min-h-12 [&_svg]:size-5 [&_[role=group]_button]:min-h-10 [&_[role=group]_button]:min-w-10 [&_[role=group]_button]:justify-center`,Db=({open:e,title:t,onClose:n,menu:r,inPlaceOnDesktop:i})=>{let a=Uv();return e?a?i?r:(0,N.createPortal)(r,document.body):(0,R.jsx)(Tb,{title:t,open:!0,onClose:n,inset:`none`,children:(0,M.cloneElement)(r,{className:Eb,style:void 0})}):null},Ob=`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`,kb=({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=>{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,R.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,R.jsxs)(`a`,{role:`menuitem`,href:i,onClick:e=>S(e,i),className:`block border-b px-3 pb-2 pt-1.5 hover:bg-muted`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,R.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.email})]}):(0,R.jsxs)(`div`,{className:`border-b px-3 pb-2 pt-1.5`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,R.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.email})]}),u&&(0,R.jsx)(`div`,{className:`border-b py-1`,children:(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,className:Ob,onClick:()=>{h(!1),u.onOpen()},children:[(0,R.jsx)(ws,{className:`size-4 shrink-0`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:u.label})]})}),s&&(s.current||s.others.length>0)&&(0,R.jsx)(lb,{label:H(`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:Ob,onSwitch:e=>{h(!1),s.onSwitch(e)}}),c&&c.roles.length>1&&(0,R.jsx)(lb,{label:H(`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:Ob,onSwitch:e=>{h(!1),c.onSwitch(e)}}),x.map((e,t)=>(0,R.jsx)(`div`,{role:`group`,className:z(`py-1`,(t<x.length-1||l||o)&&`border-b`),children:e.map(e=>{let t=e.icon;return(0,R.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:z(Ob,e.active&&`bg-muted text-foreground`),children:[(0,R.jsx)(t,{className:`size-4`}),e.label]},e.id)})},e[0]?.id)),l&&(0,R.jsx)(`div`,{className:z(o&&`border-b`),children:(0,R.jsx)(mb,{theme:l,className:z(Ob,`hover:bg-transparent`)})}),o&&(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:o,className:Ob,children:[(0,R.jsx)(Qs,{className:`size-4`}),H(`signOut`)]})]});return(0,R.jsxs)(`div`,{ref:_,className:`relative`,children:[(0,R.jsxs)(`button`,{type:`button`,className:f?z(ab,`flex items-center justify-center rounded-md 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??H(`profileMenu`),"aria-haspopup":`menu`,"aria-expanded":g,onClick:C,children:[f?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`contents`,children:(0,R.jsx)(Dy,{initials:e.initials,hue:e.hue,size:`bar`,className:`ring-0`})}):(0,R.jsx)(Dy,{initials:e.initials,hue:e.hue,size:`md`,className:`ring-0`}),!t&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 leading-tight`,children:[u?.mark?(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,R.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),u.mark]}):(0,R.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,R.jsx)(Av,{tone:e.roleTone,dot:!1,className:`mt-0.5 h-4 px-1.5 text-[0.625rem]`,children:e.role})]}),(0,R.jsx)(Wo,{className:`size-3.5 shrink-0 text-faint-foreground`})]})]}),n===void 0?(0,R.jsx)(Db,{open:g,title:H(`profileMenu`),onClose:()=>h(!1),menu:w,inPlaceOnDesktop:!0}):g&&w]})},Ab={"text-large":`h-8 gap-2.5 px-2.5`,"text-small":`h-7 gap-2 px-2 text-body`},jb={"text-large":`ml-[20px]`,"text-small":`ml-[17px]`},Mb=({create:e,mode:t,onNavigate:n})=>(0,R.jsx)(`div`,{className:z(`border-l border-transparent pl-1.5`,jb[t]),children:(0,R.jsxs)(`a`,{href:e.href,onClick:n&&(t=>{t.preventDefault(),n(e.href)}),className:z(`flex items-center rounded-md text-faint-foreground transition-colors hover:bg-muted hover:text-foreground`,Ab[t]),children:[(0,R.jsx)(Ic,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label})]})}),Nb=`protobase:nav-open:`,Pb=e=>`${Nb}${e}`,Fb=(e,t)=>ce(()=>e.getItem(t)!==`false`,!0),Ib=(e,t,n)=>ce(()=>n?e.removeItem(t):e.setItem(t,`false`),void 0),Lb=({label:e,side:t=`right`,visible:n,children:r})=>(0,R.jsxs)(`span`,{className:`group/tooltip relative inline-flex`,children:[r,(0,R.jsx)(`span`,{role:`tooltip`,className:z(`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})]}),Rb=e=>e===`text-large`||e===`text-small`||e===`icon-expand`,zb=e=>e===`text-large`||e===`text-small`,Bb={"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`},Vb={"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`},Hb=({item:e,mode:t,active:n,onNavigate:r,className:i})=>{let a=e.icon,o=(0,R.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:z(`flex shrink-0 items-center rounded-md font-medium transition-colors`,Vb[t],n?`bg-primary-soft text-primary-text`:`text-muted-foreground hover:bg-muted hover:text-foreground`,i),children:[(0,R.jsx)(a,{className:z(`shrink-0`,t===`text-small`?`size-4`:`size-[18px]`),strokeWidth:n?2.2:1.9}),(Rb(t)||t===`icon-label`)&&(0,R.jsx)(`span`,{className:`whitespace-nowrap`,children:e.label}),zb(t)&&e.count&&(0,R.jsx)(`span`,{className:`ml-auto rounded bg-muted px-1.5 text-[0.6875rem] tabular-nums text-muted-foreground`,children:e.count}),zb(t)&&e.problem&&(0,R.jsx)(El,{"aria-hidden":!0,className:`ml-auto size-3.5 shrink-0 text-warning-text`})]});return t===`icon-tooltip`?(0,R.jsx)(Lb,{label:e.label,children:o}):o},Ub=99,Wb=e=>e===void 0||e<=0?void 0:e>Ub?`${Ub}+`:String(e),Gb=({count:e,className:t})=>{let n=Wb(e);return n?(0,R.jsx)(Av,{tone:`red`,dot:!1,className:z(`h-4 min-w-4 justify-center px-1 text-[0.625rem] font-semibold`,t),children:n}):null},Kb={neutral:`text-faint-foreground`,info:`text-primary`,success:`text-success`,warning:`text-warning`,danger:`text-danger`},qb={neutral:(0,R.jsx)(`circle`,{cx:`5`,cy:`5`,r:`3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`}),info:(0,R.jsx)(`path`,{d:`M5 0.8 9.2 5 5 9.2 0.8 5Z`,fill:`currentColor`}),success:(0,R.jsx)(`circle`,{cx:`5`,cy:`5`,r:`4`,fill:`currentColor`}),warning:(0,R.jsx)(`path`,{d:`M5 0.6 9.6 9H0.4Z`,fill:`currentColor`,strokeLinejoin:`round`}),danger:(0,R.jsx)(`rect`,{x:`1.2`,y:`1.2`,width:`7.6`,height:`7.6`,rx:`1`,fill:`currentColor`})},Jb=({tone:e,pulse:t=!1,className:n})=>(0,R.jsxs)(`span`,{"aria-hidden":!0,className:z(`relative flex size-2.5 shrink-0`,Kb[e],n),"data-tone":e,"data-pulse":t||void 0,children:[t&&(0,R.jsx)(`svg`,{viewBox:`0 0 10 10`,className:`absolute inset-0 size-2.5 animate-ping opacity-60 motion-reduce:animate-none`,children:qb[e]}),(0,R.jsx)(`svg`,{viewBox:`0 0 10 10`,className:`relative size-2.5`,children:qb[e]})]}),Yb=I(`status`),Xb=({presence:e})=>{let t=Yb(e);return(0,R.jsx)(`span`,{role:`img`,"aria-label":t,title:t,className:`flex shrink-0`,children:(0,R.jsx)(Jb,{tone:e===`online`?`success`:`neutral`})})},Zb=e=>Yb(e===`busy`?`busy`:e===`do_not_disturb`?`doNotDisturb`:`automatic`),Qb=({availability:e,title:t})=>{if(e===`automatic`)return null;let n=Zb(e);return(0,R.jsx)(e===`busy`?es:Jo,{role:`img`,"aria-label":n,className:z(`size-3.5 shrink-0`,e===`busy`?`text-warning`:`text-danger`),children:(0,R.jsx)(`title`,{children:t??n})})},$b=({status:e,presence:t,textShown:n=`full`,className:r})=>{let i=mi(e);if(!i&&!t)return null;let a=i?.text??void 0;return(0,R.jsxs)(`span`,{className:z(`inline-flex min-w-0 items-center gap-1 text-muted-foreground`,r),title:a,children:[t&&(0,R.jsx)(Xb,{presence:t}),i&&(0,R.jsx)(Qb,{availability:i.availability,...n===`hover`&&a&&{title:a}}),i&&n===`hover`&&i.availability===`automatic`&&a&&(0,R.jsx)(`span`,{role:`img`,"aria-label":a,className:`size-1.5 shrink-0 rounded-full bg-faint-foreground`}),a&&n===`full`&&(0,R.jsx)(`span`,{className:`truncate text-xs`,children:a})]})},ex=(e,t)=>e.map(e=>{let n=t&&Object.hasOwn(t,e.id)?t[e.id]:void 0;return n?{...e,mark:n}:e}),tx=e=>{if(!e)return[];let t=mi(e.status);return[e.presence&&Yb(e.presence),t&&t.availability!==`automatic`?Zb(t.availability):void 0,t?.text??void 0]},nx=e=>{let t=[e.status?.label,...tx(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(`, `)})`}},rx=({records:e,mode:t,onNavigate:n})=>e.map(e=>{let{ariaLabel:r,title:i}=nx(e),a=n&&(t=>{t.preventDefault(),n(e.href)}),o=e.mark?.strong===!0;return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`a`,{href:e.href,onClick:a,"aria-label":r,title:i,"aria-current":e.active?`page`:void 0,className:z(`flex min-w-0 items-center rounded-md transition-colors`,Ab[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,R.jsx)(Jb,{tone:e.status.tone,pulse:e.status.pulse}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label}),e.mark?.person&&(0,R.jsx)($b,{...e.mark.person,textShown:`hover`,className:`ml-1.5 shrink-0`}),(0,R.jsx)(Gb,{count:e.mark?.count,className:`ml-auto shrink-0`})]})},e.id)}),ix=({records:e,useMarks:t,...n})=>(0,R.jsx)(rx,{records:ex(e,t()),...n}),ax=({records:e,useMarks:t,mode:n,onNavigate:r})=>t?(0,R.jsx)(ix,{records:e,useMarks:t,mode:n,onNavigate:r}):(0,R.jsx)(rx,{records:e,mode:n,onNavigate:r}),ox=({item:e,recent:t,mode:n,active:r,onNavigate:i})=>{let a=Pb(e.id),[o,s]=(0,M.useState)(()=>Fb(localStorage,a)),c=(0,M.useId)(),l=e.href??`#${e.id}`;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(Hb,{item:e,mode:n,active:r,onNavigate:i,className:`pr-8`}),(0,R.jsx)(`button`,{type:`button`,"aria-expanded":o,"aria-controls":c,"aria-label":H(`recent`,{plural:e.label.toLowerCase()}),onClick:()=>{Ib(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,R.jsx)(Ho,{className:z(`size-3.5 transition-transform`,o&&`rotate-90`)})})]}),o&&(0,R.jsxs)(`ul`,{id:c,"aria-label":H(`recent`,{plural:e.label.toLowerCase()}),className:z(`flex flex-col gap-0.5 border-l pl-1.5`,jb[n]),children:[t.state===`loading`&&(0,R.jsx)(`li`,{role:`status`,"aria-label":H(`loading`),className:z(`flex items-center`,Ab[n]),children:(0,R.jsx)(cu,{className:`w-3/4`})}),t.state===`error`&&(0,R.jsx)(`li`,{className:z(`flex items-center text-faint-foreground`,Ab[n]),children:H(`couldNotLoad`)}),t.state===`ready`&&(0,R.jsx)(ax,{records:t.records,useMarks:t.useMarks,mode:n,onNavigate:i}),(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{...(e=>({href:e,onClick:i&&(t=>{t.preventDefault(),i(e)})}))(l),className:z(`flex items-center rounded-md text-faint-foreground transition-colors hover:bg-muted hover:text-foreground`,Ab[n]),children:H(`viewAll`)})})]})]})},sx=({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=zy,notice:b,fill:x,page:S,search:C,accountInTopBar:w})=>{let T=e===`icon-expand`,E=T&&o,D=zb(e)||T;return(0,R.jsx)(`nav`,{"aria-label":H(`resources`),className:S?`w-full`:z(v?`sticky top-0 h-dvh self-start`:`relative`,`z-30 shrink-0`,x?`w-full`:Bb[e]),children:(0,R.jsxs)(`div`,{className:z(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,R.jsx)(`div`,{className:z(`flex h-12 shrink-0 items-center px-3.5`,e===`icon-label`&&`justify-center px-0`),onClick:()=>Vy(),children:(0,R.jsx)(y,{compact:!D,workspace:r,appName:i,appIcon:a})}),C&&(0,R.jsx)(`div`,{className:`px-5 pt-3 pb-3`,children:(0,R.jsx)(rb,{search:C,className:`w-full`,showShortcut:!1,inline:!0})}),(!C||C.query===``&&!C.loading)&&(0,R.jsx)(`div`,{className:z(S?`pb-2`:`flex-1 overflow-y-auto overflow-x-hidden pb-2`,`px-2`),children:c.map((n,r)=>(0,R.jsxs)(`div`,{className:z(`flex flex-col gap-0.5`,r>0&&`mt-3`),children:[D?n.label&&(0,R.jsx)(`h2`,{className:z(`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,R.jsxs)(R.Fragment,{children:[n.label&&(0,R.jsx)(`h2`,{className:`sr-only`,children:n.label}),r>0&&(0,R.jsx)(`div`,{className:`mx-auto mb-1 h-px w-6 bg-border`})]}),n.items.map(n=>(0,R.jsxs)(M.Fragment,{children:[n.recent&&zb(e)?(0,R.jsx)(ox,{item:n,recent:n.recent,mode:e,active:n.id===t,onNavigate:d}):(0,R.jsx)(Hb,{item:n,mode:e,active:n.id===t,onNavigate:d}),n.create&&zb(e)&&(0,R.jsx)(Mb,{create:n.create,mode:e,onNavigate:d})]},n.id))]},n.label))}),b,!(S&&n)&&(0,R.jsx)(`div`,{className:z(`shrink-0 border-t p-2 empty:hidden`,e!==`text-large`&&e!==`text-small`&&!T&&`flex justify-center`),children:n&&w?null:n?(0,R.jsx)(kb,{user:n,compact:!D,open:s,items:l,account:u,onNavigate:d,onSignOut:f,organizations:m,roles:h,theme:g,status:_}):(0,R.jsxs)(R.Fragment,{children:[g&&D&&(0,R.jsx)(mb,{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,R.jsxs)(pu,{to:p,"aria-label":H(`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,R.jsx)(Xs,{className:`size-4 shrink-0`}),D&&(0,R.jsx)(`span`,{className:`whitespace-nowrap`,children:H(`signIn`)})]})]})})]})})},cx=e=>Uv()&&zb(e),lx=(0,M.createContext)(null),ux=()=>(0,M.useContext)(lx),dx=`/-/menu`,fx=(e,t,{starting:n,morePage:r})=>e===`/-/menu`&&(n||!r)?t??`/`:void 0,px=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])},mx=({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)},hx=(e,t)=>mx({desktop:Uv(),tabs:e,menuPage:t}),gx=e=>!e,_x=({desktop:e,more:t,inBottomBar:n})=>e||!t?`top-bar`:n?`bottom-bar`:`more-page`,vx=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})`},yx=(e,t)=>{(0,M.useEffect)(()=>{let n=Vh(window);if(!e||!t.current||!n?.isPluginAvailable(`SystemBars`))return;let r=Wy(vx(getComputedStyle(t.current).backgroundColor));return n.nativePromise(`SystemBars`,`setStyle`,{style:r}),()=>void n.nativePromise(`SystemBars`,`setStyle`,{style:`DEFAULT`})},[e,t])},bx=({user:e,signIn:t,onBrand:n,...r})=>!e&&!t?null:(0,R.jsx)(`div`,{className:`flex shrink-0 items-center justify-end`,onClick:e=>e.stopPropagation(),children:e?(0,R.jsx)(kb,{user:e,compact:!0,inTopBar:!0,label:H(`accountOf`,{name:e.name}),...r}):t&&(0,R.jsx)(pu,{to:t,"aria-label":H(`signIn`),className:z(`size-[min(2.75rem,max(44px,13vw))] shrink-0`,`flex items-center justify-center rounded-md hover:bg-muted`),children:(0,R.jsx)(`span`,{className:z(`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,R.jsx)(Pl,{className:`size-[min(1.25rem,max(20px,6vw))]`,"aria-hidden":!0})})})}),xx=`app-drawer`,Sx={refreshing:`[animation:pb-stale_1.4s_ease-in-out_infinite] motion-reduce:[animation:none] motion-reduce:opacity-60`,failed:`opacity-60`},Cx=({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,onSignOut:w,signIn:T,organizations:E,roles:D,theme:O,status:k,search:A,pageScroll:ee=!1,className:te,overlays:ne,children:re})=>{let j=Uv(),ie=cx(e),[ae,N]=(0,M.useState)(!1);(0,M.useEffect)(()=>{j&&N(!1)},[j]),ay((0,M.useCallback)(()=>N(!1),[]));let oe=!j&&y&&y.length>0?y:void 0,P=hx(oe,b),se=gx(j),ce=P.on&&S?()=>S(P.href):()=>N(!0),le=P.on&&P.shown;px(le);let[ue,de]=(0,M.useState)(!1),fe=(0,M.useRef)(null),pe=l??zy;yx(P.on,fe);let me=A&&_x({desktop:j,more:P.on,inBottomBar:!!x}),he=me===`bottom-bar`,ge=()=>de(!0),_e=P.on?P.shown?[H(`more`)]:P.onTab?n:[{label:H(`more`),href:P.href},...n]:n,ve=P.on&&!!oe?.[0]?.shown,[ye,be]=(0,M.useState)(),xe=ye??ee,Se=(0,M.useRef)(null),[Ce,we]=(0,M.useState)(null),Te=(0,M.useRef)(null);wy(xe,Se,Te,!!oe),Sy(xe);let Ee=e=>(0,R.jsx)(sx,{...e,accountInTopBar:se,...e.page&&A&&me===`more-page`&&{search:A},activeItem:t,user:a,workspace:o,appName:s,appIcon:c,forceExpanded:m,profileMenuOpen:h,groups:g,userMenu:_,account:v,onNavigate:S,onSignOut:w,signIn:T,organizations:E,roles:D,theme:O,status:k,logo:l});return(0,R.jsxs)(by.Provider,{value:be,children:[(0,R.jsx)(`span`,{ref:fe,"aria-hidden":!0,className:`hidden bg-primary`}),(0,R.jsxs)(`div`,{className:z(xe?`flex min-h-full w-full overflow-x-clip`:`relative flex h-full min-h-0 w-full overflow-hidden`,le?`bg-sidebar`:`bg-background`,te),children:[j?Ee({mode:e,sticky:xe,notice:ie&&f}):(0,R.jsx)(yy,{id:xx,open:ae,onClose:()=>N(!1),children:Ee({mode:`text-large`,fill:!0})}),(0,R.jsxs)(`div`,{className:z(`flex min-w-0 flex-1 flex-col`,!oe&&`pb-[var(--pb-safe-bottom)]`),children:[(0,R.jsx)(cb,{ref:Se,slotRef:we,sticky:xe,breadcrumb:_e,titleStatus:r,onNavigate:S,onBack:C,actions:u,brand:P.on,backInLeadingSlot:P.on,...ve&&{leading:(0,R.jsx)(`div`,{className:`flex min-w-0 items-center`,onClick:()=>Vy(),children:(0,R.jsx)(pe,{compact:!1,workspace:o,appName:s,appIcon:c})})},account:se&&(0,R.jsx)(bx,{onBrand:P.on,user:a,signIn:T,open:h,items:_,account:v,onNavigate:S,onSignOut:w,organizations:E,roles:D,theme:O,status:k}),searchButton:me===`top-bar`,searchOpen:ue,onSearchOpenChange:de,onMenu:j||oe?void 0:()=>N(!0),menuOpen:ae,menuControls:xx,search:A}),p,(0,R.jsx)(`main`,{className:z(xe?`flex flex-1 flex-col`:`flex min-h-0 flex-1 flex-col`,i&&Sx[i]),"aria-busy":i===`refreshing`||void 0,children:(0,R.jsxs)(lx.Provider,{value:Ce,children:[le?Ee({mode:`text-large`,page:!0}):re,ne]})}),oe&&(0,R.jsx)(ry,{ref:Te,sticky:xe,tabs:oe,onNavigate:S,...he&&{onSearch:ge,searchLabel:x===!0?void 0:x},onMore:ce,moreOpen:ae,moreControls:xx})]}),d&&(0,R.jsx)(`div`,{className:xe?`sticky top-0 flex h-dvh shrink-0 self-start pt-[var(--pb-safe-top)]`:`flex shrink-0`,children:d})]})]})},wx=4194304,Tx=(e,t=wx)=>{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},Ex=new TextEncoder,Dx=e=>Ex.encode(JSON.stringify(e)??``).length,Ox=1e3,kx=JSON.stringify(L.meta),Ax=e=>e.state.status===`success`&&e.state.fetchFailureCount===0&&!(e.queryHash===kx&&e.state.data?.versionChange),jx=(e,t,n,r,i,a=wx)=>{let o=T(e,{shouldDehydrateQuery:Ax}).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=Tx(c.map(e=>({hash:e.queryHash,bytes:e.queryHash.length+r(e.state.data),lastUsed:l(e),pinned:e.queryHash===kx||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)]))}},Mx=({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 Dx(e);let t=a.get(e);if(t!==void 0)return t;let n=Dx(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=jx(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,Ox)});return()=>{c(),clearTimeout(a)}}}},Nx=(e,t)=>e.replace(/\D/g,``).slice(0,t),Px=(e,t,n)=>{let r=Nx(t??``,n);return r.length===n?r:Nx(e,n)},Fx=(e,t,n,r)=>{let i=t.replace(/\D/g,``);return i.length>=r?i.slice(0,r):Nx(e.slice(0,n)+i+e.slice(n+i.length),r)},Ix=({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,R.jsxs)(`div`,{className:z(`relative`,a&&`opacity-50`,o),children:[(0,R.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,R.jsx)(`div`,{"data-slot":t,"data-digit":b[t],className:z(`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,R.jsx)(`span`,{className:`h-6 w-px animate-pulse bg-foreground`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-border-strong`}))},t)})}),(0,R.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(Px(e.target.value,t??n?.getData(`text/plain`),r))},onPaste:e=>{if(p?.(e),e.defaultPrevented)return;e.preventDefault();let t=e.currentTarget,n=Fx(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)}})]})},Lx=I(`app/create`),Rx=({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?[Lx(`title`,{noun:i})]:[],...s];let c=a??(o?void 0:e.key);return[...c?[c]:[],...s]},zx=(e,t)=>[...e.filter(Boolean),t].join(` · `),Bx=e=>{(0,M.useEffect)(()=>{if(e===void 0)return;let t=document.title;return document.title=e,()=>{document.title=t}},[e])},Vx=({title:e,description:t,size:n=`sm`,appName:r,icon:i,footer:a,children:o})=>{let s=Jg()?.identity;return Bx(s?.appName),(0,R.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,R.jsx)(`div`,{className:`flex w-full flex-1 items-center justify-center`,children:(0,R.jsxs)(`div`,{className:z(`w-full`,n===`sm`?`max-w-sm`:`max-w-lg`),children:[(0,R.jsxs)(`div`,{className:`mb-6 flex flex-col items-center text-center short:mb-4`,children:[(0,R.jsx)(Iy,{appName:r??s?.appName,appIcon:i??s?.appIcon,size:`lg`,className:`short:hidden`}),(0,R.jsx)(`h1`,{className:`mt-4 text-xl font-semibold tracking-tight short:mt-0`,children:e}),t&&(0,R.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]}),(0,R.jsx)(`div`,{className:`rounded-lg border bg-background p-5 shadow-sm`,children:o})]})}),a]})},Z=I(`auth`),Hx=({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,R.jsx)(V,{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`)})},Ux=({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,R.jsxs)(Vx,{title:e,description:t,children:[(0,R.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:n}),u&&(0,R.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,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),i(f)},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`code`),(0,R.jsx)(Ix,{ref:m,name:`code`,required:!0,autoFocus:!0,value:f,invalid:!!l,onChange:p,onComplete:e=>!c&&i(e)})]}),l&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:l}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:c,className:`min-h-10`,children:r}),(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-x-2 sm:justify-between`,children:[(0,R.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:s}),(0,R.jsx)(Hx,{onResend:a,disabled:c,cooldown:d})]})]})]})},Wx=({email:e,onBack:t,...n})=>(0,R.jsx)(Ux,{title:Z(`checkEmail`),description:Z(`signInCodeDescription`),explanation:(0,R.jsx)(R.Fragment,{children:Z.rich(`signInCodeSent`,{email:(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e}),minutes:10})}),submitLabel:Z(`signIn`),onChangeAddress:t,changeAddressLabel:Z(`backToSignIn`),...n}),Gx=({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 ch))throw e;s(_v(e))}a(!1)};return(0,R.jsx)(Wx,{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`))})})},Kx=`protobase users create you@example.com`,qx=({command:e=Kx,firstAdminUrl:t,onCheckAgain:n,busy:r})=>(0,R.jsxs)(Vx,{title:Z(`noAdminTitle`),description:Z(`noAdminDescription`),children:[t?(0,R.jsx)(Jx,{url:t}):(0,R.jsx)(Yx,{command:e}),(0,R.jsx)(V,{variant:t?`secondary`:`primary`,className:`mt-4 min-h-10 w-full`,loading:r,onClick:n,children:Z(`reload`)})]}),Jx=({url:e})=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`firstAdminExplanation`)}),(0,R.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:z(tu({variant:`primary`}),`mt-4 min-h-10 w-full`),children:[Z(`firstAdminLink`),(0,R.jsx)(vs,{className:`size-4`})]})]}),Yx=({command:e})=>{let[t,n]=(0,M.useState)(!1);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`noAdminExplanation`)}),(0,R.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,R.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-xs`,children:e}),(0,R.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,R.jsx)(Io,{className:`size-4 text-success`}):(0,R.jsx)(ns,{className:`size-4`})})]})]})},Xx=({onSubmit:e,back:t,busy:n,error:r,sentTo:i})=>{let[a,o]=(0,M.useState)(``);return i?(0,R.jsxs)(Vx,{title:Z(`checkEmail`),children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Z.rich(`resetSent`,{email:(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:i})})}),(0,R.jsx)(pu,{to:t,className:z(tu({variant:`primary`}),`mt-4 min-h-10 w-full`),children:Z(`backToSignIn`)})]}):(0,R.jsx)(Vx,{title:Z(`resetTitle`),description:Z(`resetDescription`),children:(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(a.trim())},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`email`),(0,R.jsx)(qy,{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,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:r}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:n,className:`min-h-10`,children:Z(`sendResetLink`)}),(0,R.jsx)(pu,{to:t,className:z(tu({variant:`ghost`}),`min-h-10`),children:Z(`backToSignIn`)})]})})},Zx=`password-reset`,Qx=e=>{let t=new URL(e);return`${t.origin}${t.pathname}?${Zx}`},$x=e=>{let t=new URL(e).searchParams;if(t.has(`password-reset`))return{token:t.get(`token`)||void 0}},eS=e=>{let t=new URL(e);for(let e of[Zx,`token`,`error`])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},tS=({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,Qx(window.location.href)),s(e)}catch(e){if(!(e instanceof ch))throw e;a(e.status===429?Z(`tooManyRequests`):e.message)}r(!1)};return(0,R.jsx)(Xx,{busy:n,error:i,sentTo:o,back:e,onSubmit:e=>void c(e)})},nS=({name:e,workspace:t})=>(0,R.jsx)(Vx,{title:Z(`signingInWith`,{name:e}),description:t,children:(0,R.jsxs)(`p`,{role:`status`,className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Ql,{}),` `,Z(`takingYouTo`,{name:e})]})}),rS=({provider:e,workspace:t,onFailed:n})=>{let{signInProviders:r,signInSocial:i}=J(),a=r.find(t=>t.id===e),o=a?.name??Lg(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 ch))throw e;n(vv(e))})}},[a,o,e,i,n]),(0,R.jsx)(nS,{name:o,workspace:t})},iS=({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,R.jsxs)(Vx,{title:Z(`linkExpiredTitle`),children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`linkExpiredExplanation`)}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[n&&(0,R.jsx)(V,{variant:`primary`,className:`min-h-10`,onClick:n,children:Z(`sendNewLink`)}),(0,R.jsx)(V,{variant:n?`ghost`:`primary`,className:`min-h-10`,onClick:r,children:Z(`backToSignIn`)})]})]});let f=u?Z(`passwordsDiffer`):a;return(0,R.jsx)(Vx,{title:Z(`choosePassword`),description:Z(`atLeast`,{length:12}),children:(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),d(o!==c),o===c&&e(o)},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`newPassword`),(0,R.jsx)(qy,{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,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`repeatPassword`),(0,R.jsx)(qy,{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,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:Z(`setPassword`)})]})})},aS=e=>e.status===429?Z(`tooManyAttempts`):e.code===`PASSWORD_TOO_SHORT`?Z(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?Z(`passwordTooLong`):_v(e),oS=({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 ch))throw e;e.code===`INVALID_TOKEN`?u(!0):c(aS(e)),o(!1)}};return(0,R.jsx)(iS,{busy:a,error:s,invalidLink:l,onRequestNewLink:n,onBack:r,onSubmit:e=>void d(e)})},sS=I(`app/confirm-sign-in`),cS=({minutes:e,purpose:t=`show`,withPassword:n=!1,onConfirmed:r})=>{let i=Jg(),[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,R.jsxs)(`section`,{"aria-label":sS(`confirmTitle`),className:`mt-2 flex flex-col gap-2 rounded-md border border-border bg-surface p-3`,children:[(0,R.jsx)(`p`,{className:`font-medium`,children:sS(`confirmTitle`)}),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:sS(t===`change`?`confirmWhyChange`:`confirmWhy`,{minutes:e})}),g&&g.passkeys>0&&(0,R.jsx)(V,{variant:`primary`,size:`sm`,className:`self-start`,loading:m.isPending,onClick:()=>m.mutate(),children:sS(`usePasskey`)}),g?.authenticatorApp&&(0,R.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),h.mutate(a.trim())},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[sS(`authenticatorCode`),(0,R.jsx)(Ix,{name:`code`,required:!0,value:a,invalid:h.isError,onChange:o,onComplete:e=>h.mutate(e)})]}),(0,R.jsx)(V,{type:`submit`,size:`sm`,loading:h.isPending,children:sS(`confirm`)})]}),v&&(0,R.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),y.mutate(s)},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[sS(`password`),(0,R.jsx)(qy,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:s,onChange:e=>c(e.target.value)})]}),(0,R.jsx)(V,{type:`submit`,size:`sm`,loading:y.isPending,children:sS(`confirm`)})]}),_&&!d&&(0,R.jsx)(V,{variant:`primary`,size:`sm`,className:`self-start`,loading:x.isPending,onClick:()=>x.mutate(),children:sS(`emailCode`)}),_&&d&&(0,R.jsxs)(`form`,{className:`flex flex-col gap-2`,onSubmit:e=>{e.preventDefault(),b.mutate(l.trim())},children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:sS(`codeSent`,{minutes:10})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[sS(`emailedCode`),(0,R.jsx)(Ix,{name:`code`,required:!0,value:l,invalid:b.isError,onChange:u,onComplete:e=>b.mutate(e)})]}),(0,R.jsx)(V,{type:`submit`,size:`sm`,loading:b.isPending,children:sS(`confirm`)}),(0,R.jsx)(V,{size:`sm`,variant:`ghost`,loading:x.isPending,onClick:()=>x.mutate(),children:sS(`emailNewCode`)})]})]}),g&&g.passkeys===0&&!g.authenticatorApp&&_===void 0&&!v&&(0,R.jsx)(`p`,{children:sS(`nothingToConfirmWith`)}),C&&(0,R.jsx)(`p`,{role:`alert`,className:`font-medium text-danger-text`,children:C.message})]})},lS=(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)},uS=({codes:e})=>{let[t,n]=(0,M.useState)(!1),r=`${e.join(`
3
+ `)}\n`;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.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,R.jsx)(`li`,{children:e},e))}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsxs)(V,{size:`sm`,onClick:()=>{navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},children:[t?(0,R.jsx)(Io,{className:`size-3.5 text-success`}):(0,R.jsx)(ns,{className:`size-3.5`}),Y(t?`copied`:`copy`)]}),(0,R.jsxs)(V,{size:`sm`,onClick:()=>lS(r,`backup-codes.txt`),children:[(0,R.jsx)(us,{className:`size-3.5`}),Y(`download`)]})]})]})},dS=({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,R.jsxs)(`svg`,{viewBox:`0 0 ${n} ${n}`,role:`img`,"aria-label":Y(`qrCode`),shapeRendering:`crispEdges`,className:t,children:[(0,R.jsx)(`rect`,{width:n,height:n,fill:`#fff`}),(0,R.jsx)(`path`,{d:r,fill:`#000`})]})},fS=e=>(new URL(e).searchParams.get(`secret`)??``).replace(/(.{4})(?=.)/g,`$1 `),pS=()=>[{value:`app`,label:Y(`authenticatorApp`),description:Y(`authenticatorAppDescription`)},{value:`email`,label:Y(`emailedCode`),description:Y(`emailedCodeDescription`)}],mS=({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?pS():pS().filter(e=>e.value===`app`),S=async e=>{g(!0),v(void 0),b(!1);try{await e()}catch(e){if(!(e instanceof ch))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?b(!0):v(_v(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,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:_});return s.kind===`backup-codes`?(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Y(`twoFactorIsOn`)}),(0,R.jsx)(uS,{codes:s.codes}),(0,R.jsx)(V,{variant:`primary`,onClick:a,className:`min-h-10`,children:Y(`savedCodes`)})]}):s.kind===`scan`?(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),w(s.setup)},children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Y(`scanCode`)}),(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,R.jsx)(dS,{uri:s.setup.totpURI,className:`size-44 rounded-md border`}),(0,R.jsxs)(`p`,{className:`text-center text-xs text-muted-foreground`,children:[Y(`cannotScan`),(0,R.jsx)(`span`,{className:`mt-1 block break-all font-mono text-body text-foreground`,children:fS(s.setup.totpURI)})]})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Y(`codeFromApp`),(0,R.jsx)(Ix,{name:`code`,required:!0,autoFocus:!0,value:p,invalid:!!_,onChange:m,onComplete:e=>!h&&void w(s.setup,e)})]}),T,(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:Y(`turnOn`)}),o&&(0,R.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:Y(`cancel`)})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":Y(`secondStep`),className:`flex flex-col gap-2`,children:x.map(e=>(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e.value,onClick:()=>u(e.value),className:z(`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,R.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,R.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted-foreground`,children:e.description})]},e.value))}),t&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Y(`yourPassword`),(0,R.jsx)(qy,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:d,invalid:!!_,onChange:e=>f(e.target.value),className:`min-h-6`})]}),T,(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:Y(`continue`)}),o&&(0,R.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:Y(`cancel`)})]}),y&&(0,R.jsx)(cS,{purpose:`change`,minutes:15,onConfirmed:()=>void C()})]})},hS=e=>Z(e===`twoFactor`?`turnOnTwoFactor`:`addPasskey`),gS=({step:e,twoFactor:t,onAddPasskey:n,busy:r,error:i,onSignOut:a})=>(0,R.jsxs)(Vx,{title:hS(e),description:Z(`requiredForEveryAccount`),children:[e===`twoFactor`?(0,R.jsx)(mS,{...t}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`passkeyExplanation`)}),i&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,R.jsxs)(V,{variant:`primary`,loading:r,onClick:n,className:`min-h-10`,children:[(0,R.jsx)(Is,{className:`size-4`}),Z(`addPasskey`)]})]}),(0,R.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 ch?_v(e):Z(`couldNotReadAccount`)))},[t]);let u=async()=>{s(!0),l(void 0);try{await t.account.addPasskey(),n()}catch(e){if(!(e instanceof ch))throw e;l(_v(e)),s(!1)}};return!i&&!c?(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Ql,{}),` `,Z(`loading`)]}):(0,R.jsx)(gS,{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}})},vS=({className:e})=>(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:z(`size-4 shrink-0`,e),"aria-hidden":!0,children:(0,R.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`})}),yS=({id:e,className:t})=>e===`github`?(0,R.jsx)(vS,{className:t}):null,bS=`https://protobase.net/`,xS=()=>(0,R.jsx)(`footer`,{className:`mt-8 text-center`,children:(0,R.jsx)(`a`,{href:bS,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`)})}),SS=()=>(0,R.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`h-px flex-1 bg-border`}),Z(`or`),(0,R.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),CS=({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,R.jsxs)(Vx,{title:Z(`signInTitle`,{name:h??`Protobase`}),description:r,appName:h,footer:g&&(0,R.jsx)(xS,{}),children:[i&&(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[D.map(e=>(0,R.jsxs)(V,{onClick:()=>f?.(e.id),disabled:t,className:`min-h-10 w-full`,children:[(0,R.jsx)(yS,{id:e.id}),Z(`continueWith`,{name:e.name})]},e.id)),E&&(0,R.jsxs)(V,{onClick:()=>c?.(),disabled:t,className:`min-h-10 w-full`,children:[(0,R.jsx)(Is,{className:`size-4`}),Z(`signInWithPasskey`)]}),E&&l.slice(1).map(e=>(0,R.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>c?.(e),disabled:t,className:`w-full`,children:Z(`passkeyFor`,{domain:e})},e))]}),w||T?(0,R.jsx)(SS,{}):n&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-4 text-body font-medium text-danger-text`,children:n})]}),(w||T)&&(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),k?e(_.trim(),y):A()},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`email`),(0,R.jsx)(qy,{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,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`password`),(0,R.jsx)(qy,{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,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:n}),k&&(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:t,className:`min-h-10`,children:Z(`signIn`)}),T&&(0,R.jsxs)(V,{variant:k?`secondary`:`primary`,type:k?`button`:`submit`,onClick:k?A:void 0,loading:t&&!k,disabled:t,className:`min-h-10`,children:[(0,R.jsx)(ec,{className:`size-4`}),Z(`emailSignInCode`)]}),O&&(0,R.jsx)(V,{variant:`ghost`,onClick:()=>S(!0),disabled:t,className:`min-h-10`,children:Z(`usePassword`)}),k&&u&&(0,R.jsx)(pu,{to:u,className:`self-center font-medium text-primary-text hover:underline`,children:Z(`forgotPassword`)})]}),p&&(0,R.jsxs)(`p`,{className:`mt-4 text-center text-muted-foreground`,children:[Z(`newHere`),` `,(0,R.jsx)(pu,{to:p,className:`font-medium text-primary-text hover:underline`,children:Z(`createAnAccount`)})]}),m&&(0,R.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`)})]})},wS=({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 ch))throw e;y(t(e)),_(!1)}};return(0,R.jsx)(CS,{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:Rg(u),onContinueWith:e=>void b(()=>l(e),vv),passkeyDomains:p,onPasskey:e=>void b(()=>h(e),_v),onSendCode:e=>void b(async()=>{await m(e),a(e)},_v),onSubmit:(e,t)=>void b(()=>c(e,t),vv)})},TS=({email:e,onBack:t,...n})=>(0,R.jsx)(Ux,{title:Z(`checkEmail`),description:Z(`signUpCodeDescription`),explanation:(0,R.jsx)(R.Fragment,{children:Z.rich(`signUpCodeSent`,{email:(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e}),minutes:10})}),submitLabel:Z(`continue`),onChangeAddress:t,changeAddressLabel:Z(`useAnotherAddress`),...n}),ES=({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,R.jsxs)(Vx,{title:Z(`detailsTitle`),description:Z(`detailsDescription`),children:[(0,R.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:Z.rich(`codeWasRight`,{email:(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e})})}),(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({...i&&{name:s.trim()},...f&&l&&{password:l}})},children:[i&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`yourName`),(0,R.jsx)(qy,{name:`name`,autoComplete:`name`,required:!0,autoFocus:!0,maxLength:200,value:s,onChange:e=>c(e.target.value),className:`min-h-6`})]}),f&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(p?`passwordOptional`:`password`),(0,R.jsx)(qy,{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,R.jsxs)(`p`,{id:d,className:`text-xs text-muted-foreground`,children:[Z(`atLeast`,{length:12}),p&&Z(`withoutPassword`)]})]}),o&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:o}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:a,className:`min-h-10`,children:Z(`createAccount`)}),(0,R.jsx)(V,{variant:`ghost`,onClick:n,className:`min-h-10`,children:Z(`useAnotherAddress`)})]})]})},DS=({onSubmit:e,onSignIn:t,onBrowse:n,busy:r,error:i,workspace:a})=>{let[o,s]=(0,M.useState)(``);return(0,R.jsxs)(Vx,{title:Z(`createAnAccount`),description:a,children:[(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(o.trim())},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`email`),(0,R.jsx)(qy,{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,R.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`codeToConfirm`)}),i&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,R.jsxs)(V,{variant:`primary`,type:`submit`,loading:r,className:`min-h-10`,children:[(0,R.jsx)(ec,{className:`size-4`}),Z(`emailCode`)]}),(0,R.jsxs)(`p`,{className:`text-center text-muted-foreground`,children:[Z(`haveAccount`),` `,(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`font-medium text-primary-text hover:underline`,children:Z(`signIn`)})]})]}),n&&(0,R.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`)})]})},OS=({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 ch))throw e;_(_v(e))}h(!1)};return t===void 0?(0,R.jsx)(DS,{workspace:e,busy:m,error:g,onSignIn:o,onBrowse:s,onSubmit:e=>void b(async()=>{await l(e),r(e)})}):n===void 0?(0,R.jsx)(TS,{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,R.jsx)(ES,{email:t,methods:c,askName:f,busy:m,error:g,onBack:a,onSubmit:e=>void b(()=>d({ticket:n,...e}))})},kS=`staff-sign-in`,AS=`staff-error`,jS=e=>{let t=new URL(e).searchParams,n=t.get(AS);if(!t.has(`staff-sign-in`)&&!n)return;let r=t.has(kS);return{email:r&&t.get(`email`)||``,reason:r&&t.get(`reason`)||``,...n&&{error:n}}},MS=e=>{let t=new URL(e);if(t.searchParams.has(`staff-sign-in`))for(let e of[kS,`email`,`reason`])t.searchParams.delete(e);return t.searchParams.delete(AS),`${t.pathname}${t.search}${t.hash}`},NS=10,PS=({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,R.jsx)(Vx,{title:Z(`signInAsPerson`),description:Z(`forStaffOf`,{operator:e}),children:(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),r(s.trim(),l.trim())},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`theirEmail`),(0,R.jsx)(qy,{type:`email`,name:`email`,required:!0,autoFocus:!t,value:s,onChange:e=>c(e.target.value),className:`min-h-6`})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`reason`),(0,R.jsx)(`textarea`,{name:`reason`,required:!0,minLength:NS,rows:3,value:l,placeholder:Z(`reasonExample`),onChange:e=>u(e.target.value),className:z(`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,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Z(`staffExplanation`,{operator:e})}),o&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:o}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:a,className:`min-h-10`,children:Z(`continueWith`,{name:e})}),(0,R.jsx)(V,{variant:`ghost`,onClick:i,className:`min-h-10`,children:Z(`backToSignIn`)})]})}):(0,R.jsxs)(Vx,{title:Z(`staffTitle`),description:Z(`staffUnavailable`),children:[o&&(0,R.jsx)(`p`,{role:`alert`,className:`mb-4 text-body font-medium text-danger-text`,children:o}),(0,R.jsx)(V,{variant:`primary`,className:`min-h-10 w-full`,onClick:i,children:Z(`backToSignIn`)})]})},FS=({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}${MS(window.location.href)}`;window.location.assign(await n.staff.start({email:e,reason:t,callbackURL:r}))}catch(e){if(!(e instanceof ch))throw e;s(bv(e)),a(!1)}};return(0,R.jsx)(PS,{operator:r,email:e.email,reason:e.reason,busy:i,error:o,onBack:t,onSubmit:(e,t)=>void c(e,t)})},IS=({checked:e,indeterminate:t,onChange:n,label:r,disabled:i,className:a})=>(0,R.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t?`mixed`:e,"aria-label":r,disabled:i,onClick:()=>n?.(!e),className:z(`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,R.jsx)(uc,{className:`size-3`,strokeWidth:3}):e&&(0,R.jsx)(Io,{className:`size-3`,strokeWidth:3})}),LS={totp:`totpInstruction`,otp:`otpInstruction`,backup:`backupInstruction`},RS=({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,R.jsxs)(Vx,{title:Z(`twoFactorTitle`),description:Z(`twoFactorDescription`),children:[m?(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`codeToFinish`)}),a&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,R.jsx)(V,{variant:`primary`,loading:i,onClick:n,className:`min-h-10`,children:Z(`emailCode`)})]}):(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({method:c,code:u.trim(),trustDevice:f})},children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Z(LS[c],{minutes:10})}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(c===`backup`?`backupCode`:`code`),c===`backup`?(0,R.jsx)(qy,{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,R.jsx)(Ix,{name:`code`,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:d})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(IS,{checked:f,onChange:p,label:Z(`trustBrowser`)}),Z(`trustBrowserFor`)]}),a&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:Z(`verify`)})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-col items-center gap-2 border-t pt-4`,children:[c!==`totp`&&e.includes(`totp`)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(`totp`),className:`font-medium text-primary-text hover:underline`,children:Z(`useAuthenticator`)}),c!==`otp`&&e.includes(`otp`)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(`otp`),className:`font-medium text-primary-text hover:underline`,children:Z(`emailCodeInstead`)}),c!==`backup`&&e.includes(`totp`)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(`backup`),className:`font-medium text-primary-text hover:underline`,children:Z(`useBackupCode`)}),(0,R.jsx)(`button`,{type:`button`,onClick:r,className:`font-medium text-muted-foreground hover:underline`,children:Z(`backToSignIn`)})]})]})},zS=({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 ch))throw e;s(_v(e))}a(!1)};return(0,R.jsx)(RS,{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)})})},BS=()=>{let{path:e,params:t,basePath:n,navigate:r}=Ou(),i=(0,M.useMemo)(()=>ud(e,t),[e,t]),a=Fg(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(ld({step:e,next:o}),t),[r,o]);return{address:i,next:o,open:s,link:(0,M.useCallback)((e=`sign-in`,t)=>({href:`${n}${ld({step:e,next:o})}`,onFollow:()=>s(e,t)}),[n,o,s]),leave:(0,M.useCallback)(()=>r(o??`/`,{replace:!0}),[r,o])}},VS=e=>{let t=new URL(e),n=t.searchParams.get(`token`);return t.pathname.endsWith(`/-/invitation`)&&n?{token:n}:void 0},HS=e=>`${new URL(e).pathname.slice(0,-13)}/`,Q=I(`organizations`),US=`/-/organizations`,WS=`/-/organization`,GS=`/-/organization/members`,KS=`/-/organization/invitations`,qS={[US]:`organizations`,[WS]:`organization`,[GS]:`members`,[KS]:`invitations`},JS=e=>{let t=qS[e];return t&&Q(t)},YS=e=>Q(e),XS=(e,t)=>e.find(e=>e.name===t)?.label??t,ZS=e=>e?.role===`owner`||e?.role===`admin`,QS=(e,t,n)=>{let r=(n,r,i,a)=>({id:n,label:r,icon:i,href:`${e}${a}`,active:t===a});return[r(`organizations`,Q(`manageOrganizations`),bc,US),...n?.organization?[r(`organization`,Q(`organization`),Ao,WS)]:[],...ZS(n)?[r(`members`,Q(`members`),Il,GS),r(`invitations`,Q(`invitations`),ec,KS)]:[]]},$S=(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)))},eC=()=>{let[e,t]=(0,M.useState)(!1),[n,r]=(0,M.useState)();return{busy:e,error:n,run:async e=>{t(!0),r(void 0);try{await e()}catch(e){if(!(e instanceof ch))throw e;r(_v(e))}t(!1)},setError:r}},tC=({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}=eC(),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,R.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Q(n?`makeAccountToJoin`:`makeAccount`,{email:t.email})}),f&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,R.jsx)(qy,{"aria-label":Q(`yourName`),placeholder:Q(`yourName`),autoComplete:`name`,value:s,onChange:e=>c(e.target.value)}),m&&(0,R.jsx)(qy,{"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,R.jsx)(V,{type:`submit`,variant:`primary`,loading:d,disabled:!s.trim()||m&&!h&&l.length<12,children:Q(n?`createAndJoin`:`createYourAccount`)})]})},nC=({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}=eC();if((0,M.useEffect)(()=>{r.organizations.invitation(e).then(c,e=>u(e instanceof ch?_v(e):Q(`invalidLink`)))},[r,e]),l)return(0,R.jsx)(Vx,{title:Q(`invitation`),description:l,children:(0,R.jsx)(V,{className:`w-full`,onClick:t,children:Q(`goToApp`)})});if(!s)return(0,R.jsx)(Vx,{title:Q(`invitation`),children:(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Ql,{}),` `,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,R.jsx)(Vx,{title:Q(`join`,{name:r}),description:i,children:s.hasAccount?m&&h?(0,R.jsx)(V,{variant:`primary`,className:`w-full`,onClick:t,children:Q(`goToApp`)}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:Q(`hasAccount`,{email:s.email})}),m?(0,R.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:Q(`signOut`)}):(0,R.jsx)(pu,{to:n,className:z(tu({variant:`primary`}),`w-full`),children:Q(`signInAs`,{email:s.email})})]}):m?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:Q(`otherAddress`,{invited:s.email,signedIn:m.email})}),(0,R.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:Q(`signOutToAccept`)})]}):(0,R.jsx)(tC,{token:e,preview:s,joins:!1,onDone:t})})}let g=s.organization,_=s.appRoles.map(e=>XS(o?.roles??[],e)),v=YS(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,R.jsxs)(Vx,{title:Q(`join`,{name:g.name}),description:y,children:[(0,R.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:Q(`otherAddress`,{invited:s.email,signedIn:m.email})}),(0,R.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:Q(`signOutToAccept`)})]}):(0,R.jsx)(Vx,{title:Q(`join`,{name:g.name}),description:y,children:m?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,R.jsx)(V,{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,R.jsx)(pu,{to:n,className:z(tu({variant:`primary`}),`w-full`),children:Q(`signInAsToJoin`,{email:s.email})}):(0,R.jsx)(tC,{token:e,preview:s,joins:!0,onDone:t})})},rC=({children:e})=>(0,R.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-dashed border-warning bg-warning-soft p-3 text-warning-text`,children:e}),iC=I(`app/pages`),aC=class extends M.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){Qh(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,R.jsx)(rC,{children:iC.rich(`couldNotDraw`,{name:this.props.name})}):this.props.fallback:this.props.children}},oC=(e,t)=>{let n=_a(e??{}),r=[],i=[];for(let e of t){if(e.kind===`off`){i.push(e);continue}try{_a(...r,e.ui,n),r.push(e.ui)}catch(t){if(!(t instanceof da))throw t;i.push({kind:`off`,url:e.plugin.url,name:e.plugin.name,reason:t.message})}}return{ui:r.length===0?n:_a(...r,n),off:i}},sC=({children:e})=>{let{state:t,beforeSignIn:n,adoptSession:r}=J(),{path:i,params:a,navigate:o}=Ou(),{loads:s,settled:c}=Ia(n,Na()),l=(0,M.useMemo)(()=>oC(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,R.jsx)(aC,{name:`beforeSignIn`,fallback:e,children:(0,R.jsx)(l,{signedIn:r,params:a,removeParams:u,children:e})}):e:(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(z_,{}),(0,R.jsx)(Ql,{}),` `,aa(`loading`)]})},cC=()=>{let e=window.location.href,t=$x(e);if(t)return{kind:`reset-password`,token:t.token};let n=jS(e);if(n)return{kind:`staff-sign-in`,link:n};let r=VS(e);if(r)return{kind:`invitation`,token:r.token};let i=jg(e);if(i)return{kind:`provider-sign-in`,provider:i};let a=Mg(e);return a?{kind:`sign-in`,providerError:a}:{kind:`sign-in`}},lC=({to:e})=>{let{navigate:t}=Ou();return(0,M.useEffect)(()=>t(e,{replace:!0}),[t,e]),null},uC=({workspace:e,children:t})=>{let n=dC(e,t);return(0,R.jsx)(sC,{children:n})},dC=(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}=Ou(),{address:p,next:m,open:h,link:g,leave:_}=BS(),[v,y]=(0,M.useState)(cC),[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=Pg(E)!==void 0;(0,M.useEffect)(()=>{O&&((v.kind===`provider-sign-in`||k)&&D(Fg),(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&&Mg(E)!==void 0;(0,M.useEffect)(()=>{!O&&v.kind===`sign-in`&&v.providerError&&A&&D(Fg)},[O,v,A,D]);let ee=(0,M.useCallback)(e=>y({kind:`sign-in`,error:e}),[]),te=e=>{D(eS),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,R.jsxs)(`div`,{className:z(`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,lu),children:[(0,R.jsx)(z_,{}),(0,R.jsx)(Ql,{}),` `,Z(`loading`)]});case`error`:return(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`cannotReach`,{message:n.message??Z(`noAnswer`)})}),(0,R.jsx)(V,{onClick:r,children:Z(`tryAgain`)})]});case`needs-admin`:return(0,R.jsx)(qx,{firstAdminUrl:n.firstAdminUrl,onCheckAgain:r})}if(n.kind===`signed-in`&&p)return(0,R.jsx)(lC,{to:m??`/`});if(v.kind===`reset-password`)return(0,R.jsx)(oS,{token:v.token,onDone:()=>void ne(),onRequestNewLink:i?()=>{y({kind:`sign-in`}),f(ld({step:`forgot-password`}),{replace:!0})}:void 0,onBack:()=>te({kind:`sign-in`})});if(v.kind===`staff-sign-in`)return(0,R.jsx)(FS,{link:v.link,onBack:()=>{D(MS),y({kind:`sign-in`})}});let j=n.kind===`signed-out`||n.kind===`visitor`;if(v.kind===`invitation`&&(n.kind===`signed-in`||j&&!p))return(0,R.jsx)(nC,{token:v.token,onDone:()=>{D(HS),y({kind:`sign-in`})},signIn:g()});if(n.kind===`signed-in`)return t;if(n.kind===`two-factor`)return(0,R.jsx)(zS,{methods:n.methods,onBack:re});if(n.kind===`setup-required`)return(0,R.jsx)(_S,{missing:n.missing},n.missing.join());if(v.kind===`provider-sign-in`)return(0,R.jsx)(rS,{provider:v.provider,workspace:e,onFailed:ee});let ie=v.kind===`sign-in`?v:{kind:`sign-in`};if(!p){let e=ie.notice||ie.error||ie.providerError;return n.kind===`visitor`&&!e?t:(0,R.jsx)(lC,{to:ld({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,R.jsx)(tS,{back:g(`sign-in`,{replace:!0})});if(ae===`email-code`)return(0,R.jsx)(Gx,{email:b,onBack:N(`sign-in`)});if(ae===`sign-up`||ae===`sign-up-code`||ae===`sign-up-details`)return(0,R.jsx)(OS,{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 P=ie.providerError&&Sv(ie.providerError,o.length===1?o[0].name:`the provider`),se=ie.error??P;return(0,R.jsx)(wS,{workspace:e,notice:ie.notice,error:se,forgotPassword:i?g(`forgot-password`):void 0,onCodeSent:e=>{x(e),h(`email-code`)},signUp:s?g(`sign-up`):void 0,onBrowse:oe},se)},fC=e=>e.charAt(0).toUpperCase()+e.slice(1),pC=e=>(e.role??`user`).split(`,`).map(e=>e.trim()),mC=e=>pC(e).includes(`admin`),hC=e=>fC(e.replace(/[_-]+/g,` `).trim()),gC=e=>{let t=pC(e),n=t.includes(`admin`);return{name:e.name||e.email,email:e.email,initials:Ay(e.name||e.email)||`?`,hue:ky(e.id||e.email),role:n?Z(`admin`):hC(t[0]??`user`),roleTone:n?`violet`:`blue`}},_C=3e4,vC=(e,t=Date.now())=>Math.max(1e3,Ph(e)-t-_C),yC=()=>{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),vC(s))))};return a(),()=>{e=!1,clearTimeout(r)}},[t,n]),n?r:void 0},bC=({children:e})=>(0,R.jsx)(H_,{locale:J().locale,children:e}),xC=e=>{if(e?.kind!==`signed-in`)return;let{id:t,name:n}=e.user;return{id:t,...n&&{name:n}}},SC=()=>{let e=Jg()?.state;return(0,M.useMemo)(()=>xC(e),[e])},CC=e=>{let t=xC(e);return t?`user:${t.id}`:`state:${e.kind}`},wC=(e,t)=>{let n=new Set,r,i=()=>{r=void 0;let i=new Set(n);n.clear();let a=e=>Hi(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)}},TC=e=>{let t=X(),n=x(),r=(0,M.useContext)(d_),i=(0,M.useMemo)(()=>Object.values(e.resources).filter(t=>t.live&&!F_(e,t.name)).map(e=>e.name).sort().join(`,`),[e]);(0,M.useEffect)(()=>{if(!i)return;let e=wC(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])},EC=(e,t,n=!0)=>{let r=X(),i=Zn(t);return O({queryKey:L.record(e,i),enabled:n,queryFn:()=>r.get(e,t)})},DC=(e,t,n=!0)=>{let r=X(),i=x(),a=Zn(t);return O({queryKey:L.record(e,a),enabled:n,queryFn:()=>r.get(e,t),placeholderData:()=>i.getQueryData(L.recordPreview(e,a))})},OC=()=>{let{path:e}=Ou();return(0,M.useMemo)(()=>Fn(e),[e])},kC=`/-/call-guest`,AC=(e,t)=>`${e}${kC}#${t}`,jC=(e,t)=>{let n=t.replace(/^#/,``);return e===`/-/call-guest`&&n?{token:n}:void 0},MC=()=>{let{path:e}=Ou();return(0,M.useMemo)(()=>jC(e,globalThis.location?.hash??``),[e])},NC=[`light`,`dark`,`system`],PC=`protobase:theme`,FC=`(prefers-color-scheme: dark)`,IC=e=>NC.includes(e),LC=e=>ce(()=>{let t=e.getItem(PC);return IC(t)?t:`system`},`system`),RC=(e,t)=>ce(()=>t===`system`?e.removeItem(PC):e.setItem(PC,t),void 0),zC=(e,t)=>e===`system`?t?`dark`:`light`:e,BC=(0,M.createContext)(void 0),VC=({children:e})=>{let[t,n]=(0,M.useState)(()=>LC(localStorage)),r=zC(t,Hv(FC));return(0,M.useEffect)(()=>{document.documentElement.dataset.theme=r},[r]),(0,M.useEffect)(()=>{let e=e=>{(e.key===`protobase:theme`||e.key===null)&&n(LC(localStorage))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),(0,R.jsx)(BC.Provider,{value:{preference:t,theme:r,choose:e=>{RC(localStorage,e),n(e)}},children:e})},HC=()=>{let e=(0,M.useContext)(BC);if(!e)throw Error(`useTheme needs a ThemeProvider above it`);return e},UC=I(`toasts`),WC=`-my-0.5 rounded px-1.5 py-0.5 font-medium text-primary-text hover:bg-primary-soft`,GC=({action:e})=>{if(`onClick`in e)return(0,R.jsx)(`button`,{type:`button`,onClick:e.onClick,className:WC,children:e.label});let{href:t,onNavigate:n}=e;return(0,R.jsx)(`a`,{href:t,onClick:e=>{n&&du(e)&&(e.preventDefault(),n(t))},className:WC,children:e.label})},KC={loading:(0,R.jsx)(Ql,{className:`text-primary`}),success:(0,R.jsx)(Ko,{className:`size-4 text-success`}),warning:(0,R.jsx)(El,{className:`size-4 text-warning`}),error:(0,R.jsx)(Xo,{className:`size-4 text-danger`}),info:(0,R.jsx)(Kc,{className:`size-4 text-primary`}),call:(0,R.jsx)(Ec,{className:`size-4 animate-pulse text-success`})},qC=({state:e,title:t,description:n,action:r,actions:i=[],onDismiss:a})=>(0,R.jsxs)(`div`,{role:e===`error`||e===`call`?`alert`:`status`,className:z(`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,R.jsx)(`span`,{className:`mt-0.5`,children:KC[e]}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`font-medium text-foreground`,children:t}),n&&(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:n})]}),r&&(0,R.jsx)(GC,{action:r}),i.map(e=>(0,R.jsx)(GC,{action:e},e.label)),a&&(0,R.jsx)(`button`,{type:`button`,"aria-label":UC(`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,R.jsx)(Xl,{className:`size-3.5`})})]}),JC={loading:1/0,success:3500,warning:8e3,error:8e3,info:8e3,call:1/0},YC=8e3,XC=(0,M.createContext)(null),ZC=()=>{let e=(0,M.useContext)(XC);if(!e)throw Error(`useToast must be used inside ToastProvider`);return e},QC=({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?YC:JC[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,R.jsxs)(XC.Provider,{value:l,children:[e,(0,R.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,R.jsx)(`div`,{className:`pointer-events-auto`,children:(0,R.jsx)(qC,{state:e.state,title:e.title,description:e.description,action:e.action,...e.actions&&{actions:e.actions},onDismiss:()=>c(e)})},e.id))})]})},$C=({open:e,onToggle:t})=>(0,R.jsxs)(V,{size:`sm`,variant:e?`primary`:`secondary`,"aria-pressed":e,onClick:t,className:`max-md:size-9 max-md:p-0`,children:[(0,R.jsx)(ul,{className:`size-3.5`}),(0,R.jsx)(`span`,{className:`max-md:sr-only`,children:U(`assistant`)})]}),ew={bell:wo,"book-open":Eo,bookmark:Oo,building:Ao,"credit-card":os,"external-link":vs,"file-text":Os,globe:fs,heart:Ms,key:Is,"layout-dashboard":Bs,"life-buoy":Ws,mail:ec,package:Sc,receipt:Hc,settings:il,shield:ol,"shopping-cart":cl,tags:Sl,users:Il,warehouse:Wl};Object.keys(ew);var tw=(e,t)=>e?ew[e]??t:t,nw=(e,t)=>tw(e.views[t]?.icon??e.signIn?.[t]?.icon,vl),rw=(e,t,n,r=!1)=>(e.bottomBar?.items??[]).flatMap((i,a)=>i.kind===`search`?[]:i.kind===`link`?[{id:`link-${a}`,label:i.label,icon:tw(i.icon,vs),href:i.href,external:!0}]:i.kind===`page`?[{id:i.page,label:i.label,icon:tw(i.icon??e.pages[i.page]?.icon,Bs),href:Xu({kind:`page`,page:i.page},t),active:i.page===n,shown:r&&i.page===n}]:[{id:i.resource,label:i.label,icon:tw(i.icon,nw(e,i.resource)),href:Xu({kind:`list`,resource:i.resource},t),active:i.resource===n,shown:r&&i.resource===n}]),iw=e=>{let t=e.bottomBar?.items.find(e=>e.kind===`search`);return t?.kind===`search`?t.label??!0:void 0},aw=({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:Xu({kind:`page`,page:r.name},e)}];if(!t||t.kind===`page`)return[U(`admin`)];let l=Xu({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=Xu(t,e),p=t.kind===`create`?{label:U(`new`),href:f}:o===void 0&&s?{label:U(`loadingRecord`),href:f,loading:!0}:{label:o??t.key,href:f};return[...c,...d,p]},ow=()=>{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))}},sw=(0,M.createContext)(void 0),cw=()=>()=>{},lw=()=>void 0,uw=()=>{let e=(0,M.useContext)(sw);return(0,M.useSyncExternalStore)(e?.subscribe??cw,e?.get??lw,e?.get??lw)},dw=(e,t)=>e&&Object.hasOwn(e,t)?e[t]:void 0,fw=e=>e,pw=e=>e,mw=(0,M.createContext)({}),hw=()=>(0,M.useContext)(mw),gw=({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},_w=({children:e})=>{let{presence:t}=hw(),[n]=(0,M.useState)(ow),[r,i]=(0,M.useState)({hook:t,key:0});return r.hook!==t&&i({hook:t,key:r.key+1}),(0,R.jsxs)(sw.Provider,{value:n,children:[t&&(0,R.jsx)(gw,{usePresence:t,store:n},r.key),e]})},vw=[],yw=e=>{let{session:t}=J(),n=O({queryKey:L.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:r}=n,i=(0,M.useCallback)(()=>void r(),[r]),a=e?n.data:void 0,o=e&&n.error?n.error instanceof ch?_v(n.error):Q(`couldNotReadOrganizations`):void 0;return{current:a?.current,organizations:a?.organizations??vw,...o&&{error:o},reload:i}},bw=e=>window.location.assign(`${e}/`),xw=(e,t)=>t?.active?{...e,role:t.active}:e,Sw=I(`roles`),Cw=(e,t)=>e instanceof ch?_v(e):t,ww=(e,t=!0)=>{let{session:n}=J(),r=ZC(),i=O({queryKey:L.activeRole,queryFn:()=>n.roles.current(),enabled:t,retry:!1});(0,M.useEffect)(()=>{i.error&&r.show({state:`error`,title:Cw(i.error,Sw(`couldNotReadRoles`))})},[i.error,r]);let a=(0,M.useCallback)(t=>void n.roles.switchTo(t).then(e,e=>r.show({state:`error`,title:Cw(e,Sw(`couldNotSwitch`))})),[n,r,e]);return{...t&&i.data&&{current:i.data},switchTo:a}},Tw=(e,t)=>e[t]||e.conditional.includes(t),Ew=(e,t)=>e.permissions?.[t]??!0,Dw=(e,t)=>e?.fields?e.fields[t]??`hidden`:`edit`,Ow=(e,t,n)=>e?.create?Object.hasOwn(t,e.create.page):Tw(n,`create`),kw=e=>new Set((e.userMenu?.items??[]).flatMap(e=>e.kind===`resource`?[e.resource]:e.kind===`page`?[e.page]:[])),Aw=(e,t,n)=>(e.userMenu?.items??[]).map((r,i)=>{if(r.kind===`link`)return{id:`link-${i}`,label:r.label,icon:tw(r.icon,vs),href:r.href,external:!0};if(r.kind===`page`){let i=e.pages[r.page];return{id:r.page,label:r.label??i?.title??F(r.page),icon:tw(r.icon??i?.icon,Bs),href:Xu({kind:`page`,page:r.page},t),active:r.page===n}}return{id:r.resource,label:r.label??e.views[r.resource]?.names?.plural??F(r.resource),icon:tw(r.icon,nw(e,r.resource)),href:Xu({kind:`list`,resource:r.resource},t),active:r.resource===n}}),jw=(e,t)=>t===void 0?e:`${e}/${t}`,Mw={sales:`sales`,crm:`crm`,catalog:`catalog`,inventory:`inventory`,core:`admin`,hr:`hr`,table_definitions:`tables`,user_tables:`tables`},Nw=(e=`public`)=>e===`public`?``:Mw[e]?U(Mw[e]):F(e),Pw=(e,t,n,r,i)=>!n?.create||!Ow(t,e.pages,e.permissions[t.resource]??O_)?{}:{create:{label:n.create===!0?Lx(`title`,{noun:r}):n.create.label,href:Xu({kind:`create`,resource:t.resource},i)}},Fw=(e,t=``,n={})=>{let r=new Map,i=new Map,a=kw(e);for(let n of Object.values(e.pages)){if(n.nav?.hidden||a.has(n.name))continue;let e=n.nav?.group??U(`pages`),o=r.get(e)??{label:e,items:[]};o.items.push({id:n.name,label:n.title,icon:tw(n.icon,Bs),href:Xu({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??Nw(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||Ow(s,e.pages,e.permissions[s.resource]??O_);!s.nav?.hidden&&u&&l(c,{id:jw(o.name),label:s.names?.plural??F(o.name),icon:nw(e,o.name),href:Xu({kind:`list`,resource:o.name},t),...n[o.name]&&{recent:n[o.name]},...Pw(e,s,s.nav,s.names?.singular??F(o.name),t)},s.nav?.order);for(let n of s.lists??[])n.nav?.hidden||l(n.nav?.group??c,{id:jw(o.name,n.name),label:n.names.plural,icon:nw(e,o.name),href:Xu({kind:`list`,resource:o.name,list:n.name},t),...Pw(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??U(`account`),s=r.get(o)??{label:o,items:[]};s.items.push({id:n.resource,label:n.names?.plural??F(n.resource),icon:nw(e,n.resource),href:Xu({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:F(r),icon:vl,href:Xu({kind:`list`,resource:r},t),problem:U(`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))}))},Iw=e=>{let t=Fw(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},Lw=(0,M.createContext)(null),Rw=({route:e,children:t})=>(0,R.jsx)(Lw.Provider,{value:e,children:t}),zw=()=>{let e=(0,M.useContext)(Lw);if(!e)throw Error(`Tabs render inside a page that gives them their addresses: a composed page`);return e},Bw=e=>e.children.filter(e=>typeof e!=`string`).map(e=>({node:e,...e.props})),Vw=e=>{let t=e.children.find(e=>typeof e!=`string`&&!e.custom&&e.type===`Tabs`);return t?Bw(t):[]},Hw=(e,t)=>t===void 0?e[0]:e.find(e=>e.name===t),Uw=e=>{let t=hw().shell?.logo;return t?(0,R.jsx)(aC,{name:`shell.logo`,fallback:(0,R.jsx)(zy,{...e}),children:(0,R.jsx)(t,{...e})}):(0,R.jsx)(zy,{...e})},Ww=(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-Yy(e.right,t.width,n)}},Gw=()=>{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=Xy(document.documentElement.clientWidth);a.current.style.maxWidth=`${t}px`;let n=a.current.getBoundingClientRect();r({...Ww(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=>{(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}},Kw=(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:rg(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:rg(e)})}try{t({state:await e.state()})}catch(e){console.error(`Whether notifications are on could not be read:`,e)}finally{t({busy:!1})}}}),qw=(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)}},Jw=()=>{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:qw(n);return()=>{t=!1,r?.()}},[e,n,l]);let d=(0,M.useCallback)(()=>u(e=>e+1),[]),{turnOn:f,turnOff:p}=(0,M.useMemo)(()=>Kw(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}},Yw=new Map,Xw=(e,t)=>{let n=Ai(),r=`${n}|${e}`;return Yw.has(r)||Yw.set(r,t(n)),Yw.get(r)},Zw=I(`format`),Qw=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,$w=new Map,eT=e=>{let t=$w.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 $w.set(e,n),n},tT=(e,t)=>{let n=Object.fromEntries(eT(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)}},nT=(e,t)=>{let n=tT(e,t);return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-Math.floor(e/1e3)*1e3},rT=e=>String(e).padStart(2,`0`),iT=(e,t)=>{let n=tT(e,t);return`${n.year}-${rT(n.month)}-${rT(n.day)}`},aT=(e,t)=>e-nT(e-nT(e,t),t),oT=(e,t)=>aT(Date.parse(`${e}T00:00:00Z`),t),sT=(e,t)=>{let n=Xw(`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})`},cT=(e,t)=>()=>Xw(`date:${e}`,e=>new Intl.DateTimeFormat(e,{...t,timeZone:`UTC`})),lT=cT(`day`,{day:`numeric`,month:`short`,year:`numeric`}),uT=cT(`dayShort`,{day:`numeric`,month:`short`}),dT=cT(`month`,{month:`long`,year:`numeric`}),fT=cT(`monthName`,{month:`long`}),pT=cT(`weekday`,{weekday:`short`}),mT=cT(`weekdayDate`,{weekday:`long`,day:`numeric`,month:`short`,year:`numeric`}),hT=e=>lT().format(e),gT=e=>uT().format(e),_T=e=>Xw(`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})})),vT=(e,t=Qw())=>{let n=_T(t);return`${n.day.format(e)}, ${n.time.format(e)}`},yT=e=>dT().format(e),bT=e=>fT().format(e),xT=(e,t)=>dT().formatRange(e,t),ST=e=>pT().format(e),CT=e=>mT().format(e),wT=(e,t)=>lT().formatRange(e,t),TT=(e,t=Qw())=>_T(t).time.format(e),ET=e=>e<60?Zw(`secondsAgo`,{count:e}):e<3600?Zw(`minutesAgo`,{count:Math.floor(e/60)}):e<86400?Zw(`hoursAgo`,{count:Math.floor(e/3600)}):Zw(`daysAgo`,{count:Math.floor(e/86400)}),DT=()=>Xw(`relative`,e=>new Intl.RelativeTimeFormat(e,{numeric:`auto`})),OT=[[`year`,31536e3],[`month`,2592e3],[`day`,86400],[`hour`,3600],[`minute`,60]],kT=e=>{let t=Math.abs(e),[n,r]=OT.find(([,e])=>t>=e)??[`second`,1];return n===`second`&&t<45?Zw(`justNow`):DT().format(-Math.sign(e)*Math.floor(t/r),n)},AT=I(`notifications/bell`),jT=`flex w-full gap-2.5 px-3 py-2.5 text-left`,MT=({item:e,target:t,onNavigate:n,onOpen:r,now:i})=>{let a=e.readAt===null,o=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:z(`mt-1.5 size-2 shrink-0 rounded-full`,a?Ov.blue:`bg-transparent`),children:a&&(0,R.jsx)(`span`,{className:`sr-only`,children:AT(`unread`)})}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:z(`block text-body text-foreground`,a&&`font-semibold`),children:e.title}),e.body&&(0,R.jsx)(`span`,{className:`mt-0.5 line-clamp-2 block text-xs text-muted-foreground`,children:e.body}),(0,R.jsx)(`time`,{dateTime:e.createdAt,className:`mt-0.5 block text-xs text-faint-foreground`,children:kT((i-Date.parse(e.createdAt))/1e3)})]})]}),s=()=>r(e),c=e=>{e.button===1&&s()};return t?t.kind===`app`?(0,R.jsx)(pu,{to:{href:t.href,onFollow:()=>n(t.path)},onClick:s,onAuxClick:c,className:z(jT,`hover:bg-muted`),children:o}):(0,R.jsx)(`a`,{href:t.href,onClick:s,onAuxClick:c,className:z(jT,`hover:bg-muted`),children:o}):(0,R.jsx)(`div`,{className:jT,children:o})},NT=({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,R.jsxs)(`div`,{className:`flex max-h-[min(32rem,calc(100dvh-var(--pb-sticky-top,3rem)-1rem))] flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 border-b px-3`,children:[(0,R.jsx)(`h2`,{className:`flex-1 text-body font-semibold`,children:AT(`notifications`)}),m&&h&&(0,R.jsx)(V,{size:`sm`,variant:`ghost`,loading:c,onClick:()=>s(m),children:AT(`markAllRead`)})]}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[t?(0,R.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,R.jsx)(Ql,{className:`size-4`})}):n?(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-3 py-6 text-center text-body text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:AT(`loadFailed`)}),(0,R.jsx)(V,{size:`sm`,onClick:r,children:AT(`tryAgain`)})]}):e.length===0?(0,R.jsx)(`p`,{className:`px-3 py-8 text-center text-body text-muted-foreground`,children:AT(`empty`)}):(0,R.jsx)(`ul`,{className:`divide-y`,children:e.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(MT,{item:e,target:l(e),onNavigate:u,onOpen:d,now:p})},e.id))}),i&&!t&&!n&&(0,R.jsx)(`div`,{className:`flex justify-center border-t py-2`,children:(0,R.jsx)(V,{size:`sm`,variant:`ghost`,loading:a,onClick:o,children:AT(`showMore`)})})]}),f]})},PT=(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}},FT=e=>e.kind===`registration`?AT(`pushRegistrationFailed`,{reason:e.reason}):e.kind===`no-token`?AT(e.service===`apns`?`pushNoTokenApns`:`pushNoTokenFcm`):e.kind===`off-not-stored`?AT(`pushOffNotStored`):e.kind===`refused`?AT(`pushRefused`,{reason:e.reason}):AT(`pushFailed`,{reason:e.reason}),IT=({state:e,busy:t=!1,failure:n,onTurnOn:r,onTurnOff:i})=>{if(e===`loading`||e===`unsupported`)return null;if(e===`blocked`)return(0,R.jsxs)(`p`,{className:`flex gap-2 border-t px-3 py-2.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(bo,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),AT(`pushBlocked`)]});let a=e===`on`,o=!a&&n;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-t px-3 py-2.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(So,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),o?(0,R.jsx)(`span`,{role:`alert`,className:`min-w-0 flex-1 text-danger-text`,children:FT(o)}):(0,R.jsx)(`span`,{className:`min-w-0 flex-1`,children:AT(a?`pushOn`:`pushOff`)}),(0,R.jsx)(V,{size:`sm`,variant:a?`secondary`:`primary`,loading:t,onClick:a?i:r,children:AT(a?`turnOff`:o&&o.kind!==`off-not-stored`?`tryAgain`:`turnOn`)})]})},LT=3e4,RT=e=>wd(e)&&e.status===403,zT=({enabled:e=!0}={})=>{let t=X();return O({queryKey:L.inboxUnread,queryFn:()=>t.notifications.unread(),refetchInterval:e=>!RT(e.state.error)&&LT,enabled:e})},BT=({enabled:e=!0}={})=>{let t=X(),n=A({queryKey:L.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}},VT=(e,t)=>{let n=new Date().toISOString(),r=0;e.setQueryData(L.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(L.inboxUnread,e=>e===void 0?e:Math.max(0,e-r))},HT=()=>{let e=X(),t=x(),n=()=>t.invalidateQueries({queryKey:L.inbox}),r=S({mutationFn:t=>e.notifications.markRead(t.id),onMutate:e=>VT(t,t=>t.id===e.id),onSettled:n}),i=S({mutationFn:t=>e.notifications.markAllRead(t.createdAt),onMutate:e=>VT(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}},UT=99,WT=e=>e===void 0||e<=0?AT(`notifications`):e>UT?AT(`notificationsManyUnread`):AT(`notificationsUnread`,{count:String(e)}),GT=()=>{let{open:e,setOpen:t,place:n,button:r,menu:i}=Gw(),a=zT(),o=BT({enabled:e}),{markRead:s,markAllRead:c,markingAll:l}=HT(),u=Jw(),{navigate:d,basePath:f}=Ou(),[p,m]=(0,M.useState)(Date.now),h=WT(a.data),g=window.location.origin;return RT(a.error)?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(V,{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,R.jsx)(wo,{className:`size-4 max-md:size-5`}),(0,R.jsx)(Gb,{count:a.data,className:`pointer-events-none absolute -top-1 -right-1.5 max-md:top-0 max-md:right-0`})]}),(0,R.jsx)(Db,{open:e,title:WT(void 0),onClose:()=>t(!1),menu:(0,R.jsx)(`div`,{ref:i,role:`dialog`,"aria-label":WT(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,R.jsx)(NT,{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=>PT(e.url,{origin:g,basePath:f}),onNavigate:e=>d(e),onOpen:e=>{s(e),t(!1)},footer:(0,R.jsx)(IT,{state:u.state,busy:u.busy,failure:u.failure,onTurnOn:()=>void u.turnOn(),onTurnOff:()=>void u.turnOff()}),now:p})})})]})},KT=({own:e})=>e?(0,R.jsx)(aC,{name:`shell.bell`,fallback:null,children:(0,R.jsx)(e,{})}):(0,R.jsx)(GT,{}),qT=(0,M.createContext)([]),JT=()=>(0,M.useContext)(qT),YT=({ui:e,children:t})=>{let{plugins:n=[]}=ov(),{loads:r,settled:i}=Ia(n,Na()),a=(0,M.useMemo)(()=>oC(e,r),[e,r]);return i?(0,R.jsx)(mw.Provider,{value:a.ui,children:(0,R.jsx)(qT.Provider,{value:a.off,children:t})}):(0,R.jsxs)(`div`,{className:z(`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,lu),children:[(0,R.jsx)(z_,{}),(0,R.jsx)(Ql,{}),` `,aa(`loading`)]})},XT=({off:e})=>{let[t,n]=(0,M.useState)(!1);return t||e.length===0?null:(0,R.jsxs)(`div`,{role:`region`,"aria-label":aa(`pluginsOff`),className:`flex items-start gap-3 border-b border-warning/40 bg-warning-soft px-4 py-2 text-warning-text`,children:[(0,R.jsx)(Bc,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,R.jsx)(`ul`,{className:`min-w-0 flex-1 space-y-0.5 break-words`,children:e.map(e=>(0,R.jsx)(`li`,{children:aa.rich(`pluginOff`,{plugin:(0,R.jsx)(`span`,{className:`font-semibold`,children:e.name??e.url}),reason:e.reason})},e.url))}),(0,R.jsx)(`button`,{type:`button`,"aria-label":aa(`dismiss`),className:`rounded p-0.5 hover:bg-warning/10`,onClick:()=>n(!0),children:(0,R.jsx)(Xl,{"aria-hidden":!0,className:`size-4`})})]})},ZT=({title:e,description:t,open:n,onClose:r,actions:i,children:a,wide:o})=>{let s=Uv();return n?s?(0,R.jsx)(su,{title:e,description:t,onClose:r,actions:i,wide:o,children:a}):(0,R.jsx)(Tb,{title:e,open:!0,onClose:r,children:(0,R.jsxs)(`div`,{className:`pt-3`,children:[t&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:t}),a&&(0,R.jsx)(`div`,{className:`mt-4`,children:a}),(0,R.jsx)(`div`,{className:`mt-5 flex flex-col-reverse gap-2 [&>*]:min-h-11`,children:i})]})}):null},QT=({failed:e})=>(0,R.jsxs)(`span`,{"data-fetching":!0,className:`inline-flex items-center text-muted-foreground`,children:[(0,R.jsx)(`span`,{role:`status`,className:`sr-only`,children:U(e?`refreshFailed`:`refreshing`)}),e?(0,R.jsx)($T,{}):(0,R.jsx)(`span`,{className:lu,children:(0,R.jsx)(Ql,{hidden:!0})})]}),$T=()=>{let[e,t]=(0,M.useState)(!1),n=(0,M.useContext)(k),r=(0,M.useContext)(m_);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":U(`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,R.jsx)(El,{"aria-hidden":!0,className:`size-4 text-warning`})}),(0,R.jsx)(ZT,{title:U(`refreshFailedTitle`),description:U(`refreshFailedHelp`),open:e,onClose:()=>t(!1),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:()=>t(!1),children:U(`refreshClose`)}),(0,R.jsx)(V,{variant:`primary`,onClick:()=>{t(!1),n?.refetchQueries({type:`active`,predicate:e=>h_(e.state,r)})},children:U(`refreshRetry`)})]})})]})},eE=15e3,tE=()=>{let e=Jg();return A_().data?.status&&e?.state.kind===`signed-in`?String(e.state.user.id):void 0},nE=()=>{let e=X(),t=tE();return O({queryKey:L.statuses(t??``),enabled:t!==void 0,refetchInterval:eE,queryFn:()=>e.status.people()})},rE=()=>{let e=X(),t=tE();return O({queryKey:L.ownStatus(t??``),enabled:t!==void 0,refetchInterval:eE,queryFn:()=>e.status.own()})},iE=(e,t=Date.now())=>e.isSuccess&&!e.isFetching&&t-e.dataUpdatedAt>=1e4,aE=(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})},oE=()=>{let e=Jg(),t=e?.state.kind===`signed-in`?e.state.user:void 0,n=O({queryKey:L.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=nE().data,i=(0,M.useMemo)(()=>n.data&&(r?aE(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&&iE(n)&&setTimeout(()=>void o(),0),t},[a,n,o]);return{...n,data:i,member:s}},sE=(e,t,n)=>{let r=t[n];return e.fields[n]?.type===`relation`&&typeof r==`object`&&r&&`id`in r?r.id:r},cE=(e,t)=>e.primaryKey.map(n=>String(sE(e,t,n))).join(`,`),lE=(e,t)=>{let n=e.primaryKey.map(n=>sE(e,t,n));return n.length===1?n[0]:n},uE=(e,t)=>t?.titleFrom?.fields??[],dE=(e,t)=>(n,r,i,a)=>{let o=r?.titleFrom;if(!o)return Hr(n,r,i,a);let s=e[o.rule];return!s||o.unreadable||o.fields.some(e=>i[e]===void 0)?a:s(i,t)||a},fE=()=>void 0,pE=(0,M.createContext)(dE({},{user:void 0,member:fE})),mE=()=>(0,M.useContext)(pE),hE=({rules:e,user:t,children:n})=>{let r=(0,M.useMemo)(()=>dE(e,{user:t,member:fE}),[e,t]);return(0,R.jsx)(pE.Provider,{value:r,children:n})},gE=({rules:e,user:t,children:n})=>{let{member:r}=oE(),i=(0,M.useMemo)(()=>dE(e,{user:t,member:r}),[e,t,r]);return(0,R.jsx)(pE.Provider,{value:i,children:n})},_E=({children:e})=>{let{views:t}=ov(),{titles:n}=hw(),r=Jg(),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,R.jsx)(gE,{rules:a,user:i,children:e}):(0,R.jsx)(hE,{rules:a,user:i,children:e})},vE=e=>wd(e)?e.status===401||e.status===403?U(`signInRefused`,{message:e.message}):e.message:U(`noAnswer`),yE=({status:e})=>{let t=x();return e.state===`error`?(0,R.jsx)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center p-8`,children:(0,R.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,R.jsx)(`h1`,{className:`text-base font-semibold`,children:U(`cannotReach`,{label:e.source.label})}),(0,R.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[vE(e.error),` `,U(`restWorks`)]}),(0,R.jsx)(V,{className:`mt-3`,onClick:()=>void t.refetchQueries({queryKey:L.sourceMetas(e.source.url)}),children:U(`tryAgain`)})]})}):(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Ql,{}),` `,U(`loadingFrom`,{label:e.source.label})]})},bE=(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},xE=I(`app/search`),SE=(e,t)=>e.toLowerCase().includes(t.trim().toLowerCase()),CE=(e,t,n=``)=>{let r=Fw(e,n).flatMap(e=>e.items.filter(e=>e.href!==void 0&&!e.problem)).filter(e=>SE(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||!Ow(a,e.pages,e.permissions[r.name]??O_))return[];let o=a.names?.singular??F(r.name),s=Lx(`title`,{noun:o});return!SE(s,t)&&!SE(o,i)&&!SE(a.names?.plural??F(r.name),i)?[]:[{id:`new:${r.name}`,title:s,href:Xu({kind:`create`,resource:r.name},n)}]});return[...r.length>0?[{id:`go-to`,label:xE(`goTo`),hits:r.map(e=>({id:`go-to:${e.id}`,title:e.label,href:e.href}))}]:[],...a.length>0?[{id:`create`,label:xE(`create`),hits:a.slice(0,5)}]:[]]},wE=At(),TE=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??F(t.name)}]}),EE=e=>{let t=e.map(e=>e.label.toLowerCase());return t.length===0?xE(`search`):t.length===1?xE(`searchOne`,{name:t[0]}):t.length===2?xE(`searchTwo`,{first:t[0],second:t[1]}):xE(`searchMore`,{first:t[0],second:t[1]})},DE=e=>yt(wE.search(e.trim())),OE=e=>!e.view?.searchResult?.title?.length&&e.view?.titleFrom!==void 0,kE=e=>{let t=e.view?.searchResult?.title;return t?.length?t:OE(e)?[]:[Vr(e.model,e.view)]},AE=e=>{let t=kE(e);return e.view?.searchResult?.subtitle??e.model.search?.find(e=>!t.includes(e))},jE=e=>{let t=AE(e),n=OE(e)?uE(e.model,e.view):[],r=[...kE(e),...n,...t?[t]:[],...e.model.search??[]];return[...new Set([...e.model.primaryKey,...r.filter(t=>Object.hasOwn(e.model.fields,t))])]},ME=(e,t,n)=>{let r=t[n];return r==null?``:e.model.fields[n]?.type===`enum`?Lr(String(r),e.view?.fields[n]?.valueLabels):String(r)},NE=(e,t,n,r=``,i=dE({},{user:void 0,member:()=>void 0}))=>{let a=Zn(lE(e.model,t)),o=kE(e),s=AE(e),c=vt(e.model,t,n,[...o,...s?[s]:[]])??s,l=c?ME(e,t,c):``;return{id:a,title:OE(e)?i(e.model,e.view,t,a):o.map(n=>ME(e,t,n)).filter(Boolean).join(` `)||a,...l&&{subtitle:l},href:Xu({kind:`record`,resource:e.model.name,key:a},r)}},PE=()=>{let e=ov(),t=X(),{basePath:n}=Ou(),r=mE(),i=(0,M.useMemo)(()=>TE(e),[e]),[a,o]=(0,M.useState)(``),s=a.trim(),c=bE(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:DE(c),pageSize:5,fields:jE(e)})}))}),f=(0,M.useMemo)(()=>u?CE(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=>NE(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:EE(i),text:a,setText:o,query:u?c:``,loading:l&&(s!==c||d.some(e=>e.isFetching)),groups:m}},FE=(0,M.createContext)(void 0),IE=()=>(0,M.useContext)(FE),LE=I(`app/new-version`),RE=()=>{let{versionChange:e,appName:t}=ov(),{reload:n}=Ou(),r=IE();return!e||r?null:(0,R.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,R.jsx)(Kc,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`break-words font-semibold`,children:t?LE.rich(`bannerTitle`,{app:t}):LE(`title`)}),(0,R.jsx)(`span`,{className:`text-xs`,children:LE(`bannerLine`)})]})]})},zE=()=>{let e=!!ov().versionChange,{reload:t}=Ou(),n=IE();return!e||n?null:(0,R.jsxs)(V,{size:`sm`,variant:`ghost`,"aria-label":LE(`reloadPageHint`),title:LE(`reloadPageHint`),onClick:t,className:`max-md:size-9 max-md:p-0`,children:[(0,R.jsx)(Kc,{className:`size-3.5 text-primary`}),(0,R.jsx)(`span`,{className:`max-md:sr-only`,children:LE(`reloadPage`)})]})},BE=()=>document.querySelector(`[aria-modal="true"]`)!==null,VE=()=>{let[e,t]=(0,M.useState)(BE);return(0,M.useEffect)(()=>{let e=new MutationObserver(()=>t(BE()));return e.observe(document.body,{childList:!0,subtree:!0}),t(BE()),()=>e.disconnect()},[]),e},HE=()=>{let e=!!ov().versionChange,t=VE(),[n,r]=(0,M.useState)(!1),i=ZC(),{reload:a}=Ou(),o=IE(),s=e&&!n&&!t&&!o;return(0,M.useEffect)(()=>{if(!s)return;let e=i.show({state:`info`,sticky:!0,title:LE(`title`),description:LE(`description`),action:{label:LE(`reload`),onClick:a},onClose:()=>r(!0)});return()=>i.dismiss(e)},[s,i,a]),null},UE=(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,R.jsx)(t,{...e})};return Object.assign(e=>(0,R.jsx)(M.Suspense,{fallback:(0,R.jsx)(`span`,{"aria-busy":!0,className:`contents`,children:t(e)}),children:(0,R.jsx)(a,{...e})}),{preload:i})},WE=()=>(0,R.jsxs)(`div`,{role:`status`,"aria-label":U(`loading`),"aria-busy":!0,className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[(0,R.jsx)(cu,{className:`h-7 w-48`}),(0,R.jsx)(cu,{className:`h-9 w-full max-w-96`}),(0,R.jsx)(cu,{className:`min-h-60 flex-1 rounded-lg`})]}),GE=[32,24,40,28,20],KE=()=>(0,R.jsxs)(`div`,{role:`status`,"aria-label":U(`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,R.jsx)(cu,{className:`h-8 w-3/4 max-w-96`}),(0,R.jsxs)(`div`,{className:`mt-10 grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(cu,{className:`h-5 w-32`}),(0,R.jsx)(`div`,{className:`mt-5 divide-y divide-border border-t`,children:GE.map((e,t)=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] gap-x-4 py-3`,children:[(0,R.jsx)(cu,{className:`h-4 w-24`}),(0,R.jsx)(cu,{className:`h-4`,style:{width:`${e*2}%`}})]},t))})]}),(0,R.jsx)(cu,{className:`h-40 rounded-lg max-md:hidden`})]})]}),qE=2e3,JE={type:`active`,predicate:e=>e.state.data===void 0},YE=(e,t)=>e.some(e=>h_(e.state,t))&&!e.some(e=>e.state.dataUpdatedAt>=t),XE=({children:e})=>{let t=x(),n=(0,M.useContext)(m_),r=h(JE),[i,a]=(0,M.useState)(()=>YE(t.getQueryCache().getAll(),n));return(0,M.useEffect)(()=>{if(i)return;let e=setTimeout(()=>a(!0),qE);return()=>clearTimeout(e)},[i]),(0,M.useEffect)(()=>{if(i||r>0)return;let e=setTimeout(()=>t.isFetching(JE)===0&&a(!0),0);return()=>clearTimeout(e)},[i,r,t]),(0,R.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,"aria-busy":!i||void 0,children:[(0,R.jsx)(`div`,{className:z(`flex min-h-0 flex-1 flex-col`,!i&&`invisible`),children:e}),!i&&(0,R.jsx)(QE,{})]})},ZE=()=>(0,R.jsx)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(QE,{})}),QE=()=>(0,R.jsxs)(`div`,{role:`status`,"aria-label":U(`loading`),className:`absolute inset-x-0 top-0 flex flex-col gap-4 p-4 md:p-6`,children:[(0,R.jsx)(cu,{className:`h-6 w-48`}),(0,R.jsx)(cu,{className:`h-24`}),(0,R.jsx)(cu,{className:`h-40`}),(0,R.jsx)(cu,{className:`h-40`})]}),$E=UE(()=>s(()=>import(`./list-page-BU1MrXbN.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,R.jsx)(WE,{})),eD=UE(()=>s(()=>import(`./record-page-D88DdoET.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,R.jsx)(KE,{})),tD=UE(()=>s(()=>import(`./create-route-Cx8yqS-H.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,R.jsx)(KE,{})),nD=UE(()=>s(()=>import(`./composed-page-gwTeW0b3.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,R.jsx)(ZE,{})),rD=UE(()=>s(()=>import(`./account-page-dcJyxP-d.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,R.jsx)(ZE,{})),iD=UE(()=>s(()=>import(`./sign-in-policy-page-B40iAeJa.js`).then(e=>e.SignInPolicyPage),__vite__mapDeps([42,1,6,25])),()=>(0,R.jsx)(ZE,{})),aD=UE(()=>s(()=>import(`./organization-page-BrC1nHC-.js`).then(e=>e.OrganizationPage),__vite__mapDeps([43,1,6,25])),()=>(0,R.jsx)(ZE,{})),oD=UE(()=>s(()=>import(`./organizations-page-CaUeWdr4.js`).then(e=>e.OrganizationsPage),__vite__mapDeps([44,1,6,25,33])),()=>(0,R.jsx)(ZE,{})),sD=UE(()=>s(()=>import(`./members-page-BYUO0Dq2.js`).then(e=>e.MembersPage),__vite__mapDeps([45,1,6,7,25,32])),()=>(0,R.jsx)(ZE,{})),cD=UE(()=>s(()=>import(`./invitations-page-Bh-RCnnl.js`).then(e=>e.InvitationsPage),__vite__mapDeps([46,1,6,25,31,32,45,7])),()=>(0,R.jsx)(ZE,{})),lD=UE(()=>s(()=>import(`./connect-route-CtL1EJIN.js`).then(e=>e.ConnectRoute),__vite__mapDeps([47,1,6,34])),()=>(0,R.jsx)(z_,{})),uD=UE(()=>s(()=>import(`./public-form-page-d3TamPPE.js`).then(e=>e.PublicFormPage),__vite__mapDeps([48,1,6,7,49])),()=>(0,R.jsx)(z_,{})),dD=UE(()=>s(()=>import(`./guest-call-page-BhTshbrl.js`).then(e=>e.GuestCallPage),__vite__mapDeps([50,1,6,7])),()=>(0,R.jsx)(z_,{})),fD=UE(()=>s(()=>import(`./assistant-shell-Bw1jJrLm.js`).then(e=>e.AssistantPanel),__vite__mapDeps([51,1,6]))),pD=UE(()=>s(()=>import(`./call-rings-CzvSKlfI.js`).then(e=>e.CallRings),__vite__mapDeps([52,1,6,7]))),mD=UE(()=>s(()=>import(`./runtime-update-CoXcnfxB.js`).then(e=>e.RuntimeUpdateButton),__vite__mapDeps([53,1,6]))),hD,gD=()=>hD??=Promise.allSettled([$E.preload(),eD.preload(),nD.preload()]),_D=(e,t)=>Xw(`money:${e}:${t??``}`,n=>new Intl.NumberFormat(n,{style:`currency`,currency:e,...t!==void 0&&{minimumFractionDigits:t,maximumFractionDigits:t}})),vD=(e,t,n)=>_D(t,n).format(e/100),yD=()=>Xw(`grouped`,e=>new Intl.NumberFormat(e)),bD=e=>yD().format(e),xD=e=>e>0?`+${yD().format(e)}`:yD().format(e).replace(`-`,`−`),SD=e=>`${e}%`,CD=e=>{if(e<1e4)return Zw(`rows`,{count:bD(e),n:e});let t=10**(Math.floor(Math.log10(e))-3);return Zw(`aboutRows`,{count:bD(Math.round(e/t)*t)})},wD=({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 ch))throw e;a(_v(e)),r(!1)}};return(0,R.jsxs)(`div`,{role:`region`,"aria-label":U(`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,R.jsx)(Ml,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,R.jsx)(`p`,{className:`min-w-64 flex-1 break-words`,children:U.rich(`staffSignedIn`,{staff:(0,R.jsx)(`span`,{className:`font-semibold`,children:e.staffName??e.staff}),user:(0,R.jsx)(`span`,{className:`font-semibold`,children:e.user}),until:vT(Date.parse(e.expiresAt)),reason:e.reason})}),i&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,R.jsx)(V,{size:`sm`,loading:n,onClick:()=>void o(),children:U(`stopStaffSession`)})]})},TD=(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=dw(t,n);return[e,{...i,person:{...a&&{status:a},...o&&{presence:o}}}]}))},ED=(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`:``},DD=e=>{let[t=``,n]=e.trim().split(/\s+/);return{columnId:t,direction:n===`desc`?`desc`:`asc`}},OD=e=>`${e.columnId} ${e.direction}`,kD=(e,t,n)=>({filter:n.filter??``,orderBy:n.orderBy??ED(e,t),pageSize:n.limit??3,fields:[...new Set([...e.primaryKey,Vr(e,t),...uE(e,t),...n.status===void 0?[]:[n.status]])]}),AD=(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?Lr(i,t.fields[n.status]?.valueLabels):i,tone:n.tones?.[i]??`neutral`,pulse:n.pulse?.includes(i)??!1}},jD=(e,t,n,r,i,a,o)=>r.map(r=>{let s=Zn(lE(e,r)),c=AD(e,t,n,r);return{id:s,label:o(e,t,r,s),href:Xu({kind:`record`,resource:e.name,key:s},i),...c&&{status:c},active:s===a}}),MD=(e,t,n,r,i)=>{let a=n.find(t=>Zn(lE(e,t))===r);return a!==void 0&&t.some(e=>!Object.is(a[e],i[e]))},ND=(e,t,n)=>{if(t.marks===void 0||!n||!Object.hasOwn(n,t.marks))return;let r=n[t.marks];return()=>r(e)},PD=e=>e&&(()=>TD(e(),uw(),nE().data)),FD=({model:e,request:t})=>L.navRecent(e.name,t.filter,t.orderBy,t.pageSize),ID=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(FD(n));e&&MD(n.model,n.request.fields,e.items,a,o)&&t.invalidateQueries({queryKey:FD(n),exact:!0})}}),[t,e])},LD=(e,t,n)=>{let r=X(),i=mE(),{marks:a}=hw(),o=(0,M.useMemo)(()=>{let t=kw(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:kD(r,n,i),useMarks:PD(ND(r.name,i,a))}]:[]})},[e,a]);ID(o);let s=ee({queries:o.map(e=>({queryKey:FD(e),queryFn:()=>r.list(e.model.name,e.request)}))});return Object.fromEntries(o.map(({model:e,view:r,recent:a,useMarks:o},c)=>{let l=s[c];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:jD(e,r,a,l.data.items,t,u,i),...o&&{useMarks:o}}]}))},RD=I(`live`),zD=e=>typeof e==`object`&&!!e&&typeof e.uri==`string`,BD=e=>typeof e==`object`&&!!e&&typeof e.uploaded?.value==`string`,VD=e=>{if(BD(e))return{...e.uploaded.file,...e.preview&&{url:e.preview},corrected:e.uploaded.corrected};if(zD(e))return`missing`in e?{name:RD(`fileMissing`),type:``,missing:!0}:e},HD=[`bytes`,`kB`,`MB`,`GB`],UD=e=>{let t=e,n=0;for(;t>=1e3&&n<HD.length-1;)t/=1e3,n+=1;return n===0?`${e} ${e===1?`byte`:`bytes`}`:`${t<10?t.toFixed(1):Math.round(t)} ${HD[n]}`},WD=e=>e.startsWith(`image/`)&&e!==`image/svg+xml`,GD=2,KD=1e5,qD=(e,t)=>(e.width!==void 0||e.height!==void 0)&&(e.width??KD)>=t.width*GD&&(e.height??KD)>=t.height*GD,JD=e=>(e.width??KD)*(e.height??KD),YD=(e,t)=>{let n=VD(e);if(!(!n||`missing`in n||!n.url||!WD(n.type)))return{url:(`variants`in n&&n.variants?Object.values(n.variants):[]).filter(e=>qD(e,t)).sort((e,t)=>JD(e)-JD(t))[0]?.url??n.url,...`placeholder`in n&&n.placeholder!==void 0&&{placeholder:n.placeholder}}},XD=e=>{let t=e.file?.accept??[];return t.length===0||t.includes(`*/*`)?void 0:t.join(`,`)},ZD=e=>BD(e)?e.uploaded.value:zD(e)?e.uri:null,QD=(e,t)=>{if(BD(e))return!0;let n=e=>zD(e)?e.uri:null;return n(e)!==n(t)},$D=I(`data-grid`),eO=e=>typeof e==`object`&&e&&`name`in e?String(e.name):String(e),tO=(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`${vD(Number(t),e.currency,e.decimals)}${e.suffix??``}`;case`date`:return hT(Number(t));case`datetime`:return e.relative?kT(Math.round((Date.now()-Number(t))/1e3)):vT(Number(t));case`number`:return`${e.prefix??``}${bD(Number(t))}${e.suffix??``}`;case`signed`:return`${e.prefix??``}${xD(Number(t))}${e.suffix??``}`;case`percent`:return Number(t)===0?`—`:SD(Number(t));case`status`:return Lr(String(t),e.labels);case`relation`:return eO(t);case`boolean`:return t?void 0:$D(`no`);case`file`:return VD(t)?.name??`—`;case`user`:return e.users?.(String(t))?.name??String(t)}},nO=(e,t)=>Math.ceil(e.length*7.2)+24+(t?16:0)+28,rO=e=>Math.ceil(Math.max(0,...e.map(e=>e.length))*7.2)+56,iO={body:7.5,mono:7.2,numeric:8},aO=24,oO=16,sO=new Set([`status`,`money`,`number`,`signed`,`percent`,`date`,`datetime`,`boolean`]),cO=new Set([`money`,`number`,`signed`,`percent`,`date`,`datetime`]),lO=80,uO=400,dO=240,fO=e=>e===`id`?iO.mono:cO.has(e)?iO.numeric:iO.body,pO=(e,t)=>e.value?e.value(t):t[e.id],mO=(e,t)=>{let n=t.map(t=>tO(e,pO(e,t)));if(e.kind===`status`)return rO(n.map(e=>e??``));let r=e.kind===`user`||e.kind===`file`?aO:0;return Math.max(0,...n.map(t=>t===void 0?oO:Math.ceil(t.length*fO(e.kind))))+r+24},hO=(e,t,n)=>Math.min(n,Math.max(t,e)),gO=(e,t)=>{if(sO.has(e.kind)&&!e.title)return{...e,fixed:!0,width:Math.max(e.minWidth??0,t)};let n={...e,fixed:!1,width:hO(t,lO,uO)};return e.kind===`id`?{...n,minWidth:Math.max(nO(e.header,e.sortable??!1),Math.min(t,dO))}:n},_O=(e,t)=>{if(!e.fit)return e;let n=Math.max(0,...t.map(e.fit));return{...e,fixed:!0,width:hO(n,e.minWidth??0,e.maxWidth??1/0)}},vO=(e,t)=>{if(t.length===0)return e;let n=e.map(e=>e.render?_O(e,t):gO(e,mO(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)},yO=[[/^\s*(```|~~~).*$/,``],[/^\s*\[[^\]]+\]:\s+\S.*$/,``],[/^\s*([-*_]\s*){3,}$/,``],[/^\s*\|?(\s*:?-+:?\s*\|)+\s*:?-*:?\s*$/,``],[/^\s*#{1,6}\s+/,``],[/^\s*(>\s?)+/,``],[/^\s*([-*+]|\d+[.)])\s+(\[[ xX]\]\s+)?/,``]],bO=[[/!\[([^\]]*)\]\([^)]*\)/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`]],xO=200,SO=e=>{let t=e.split(/\r?\n/).map(e=>yO.reduce((e,[t,n])=>e.replace(t,n),e)),n=bO.reduce((e,[t,n])=>e.replace(t,n),t.join(`
4
+ `)).replace(/\s+/g,` `).trim();return n.length>xO?`${n.slice(0,199).trimEnd()}…`:n},CO=(e,t)=>e.type===`text`&&!!t?.markdown,wO=new Set([`email`,`phone`,`url`]),TO=e=>e?.format!==void 0&&wO.has(e.format)?e.format:void 0,EO=(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},DO=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`}:{},OO=(e,t)=>{let n=String(t);return e&&Object.hasOwn(e,n)?e[n]:void 0},kO=(e,t)=>{let n=OO(e,t);return n===void 0||Wn(n)?void 0:n},AO=(e,t)=>{let n=OO(e,t);return n!==void 0&&Wn(n)?n:`neutral`},jO=e=>typeof e!=`object`||!e,MO=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e,NO=e=>Array.isArray(e)?e.length===0?`[]`:`[…]`:typeof e==`object`&&e?Object.keys(e).length===0?`{}`:`{…}`:e===``?`""`:MO(String(e),40),PO=e=>{let t=``;for(let n of e)if(t=t===``?n:`${t}, ${n}`,t.length>160)break;return MO(t,160)};function*FO(e){let t=e;for(let e in t)jO(t[e])&&(yield`${e}: ${NO(t[e])}`);for(let e in t)jO(t[e])||(yield`${e}: ${NO(t[e])}`)}function*IO(e){for(let t of e)yield NO(t)}var LO=e=>Array.isArray(e)?e.length===0?`[]`:e.every(jO)?PO(IO(e)):RD(`jsonItems`,{count:e.length}):typeof e==`object`&&e?Object.keys(e).length===0?`{}`:PO(FO(e)):MO(String(e),160),RO=(e,t)=>`${t.prefix??``}${e}${t.suffix??``}`,zO=(e,t,n={},r=Qw(),i=Date.now())=>{if(t==null||t===``)return`—`;switch(e.type){case`boolean`:return RD(t?`yes`:`no`);case`file`:return VD(t)?.name??`—`;case`enum`:return Lr(String(t),n.valueLabels);case`timestamp`:{let e=Date.parse(String(t));return n.format===`relative`?kT(Math.round((i-e)/1e3)):vT(e,r)}case`date`:return hT(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)}%`:RO(Number(e).toLocaleString(Ai(),{minimumFractionDigits:n.decimals??0,maximumFractionDigits:n.decimals??20}),n)}case`integer`:case`bigint`:return RO(String(t),n);default:return typeof t==`object`?JSON.stringify(t):String(t)}},BO=(e,t,n=Qw(),r={})=>{if(e.type!==`timestamp`||typeof t!=`string`)return;let i=Date.parse(t);if(!Number.isNaN(i))return r.format===`relative`?vT(i,n):RD(`shownIn`,{zone:sT(i,n)})},VO=e=>e==null||e===``,HO=(e,t,n,r,i)=>{let a=e.fields[n];return a?a.type===`relation`?i[n]??eO(r):zO(a,r,t?.fields[n]):String(r)},UO=(e,t,n,r,i={})=>{let a=t?.fields[n]?.linkText;if(a===void 0||qt(a).some(e=>VO(r[e])))return;let o=Yt(a,n=>HO(e,t,n,r[n],i)).trim();return o===``?void 0:o},WO={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},GO=new Set([`datetime`,`date`,`boolean`,`percent`]),KO=(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`}},qO=e=>Math.round(Number.parseFloat(String(e))*100),JO=(e,t,n=[],r=hi(e,t))=>{let i=Vr(e,t);return r.flatMap((r,a)=>{let o=e.fields[r];if(!o)return[];let s=t?.fields[r],c=KO(o,s,a),l=Object.fromEntries((o.enumValues??[]).map(e=>[e,Lr(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??F(r),kind:c,width:(r===`name`?260:WO[c])+d,sortable:o.sortable,minWidth:Math.max(c===`id`?150:0,nO(s?.label??F(r),o.sortable),c===`status`?rO(Object.values(l)):0,d>0?WO[c]+d:0),...GO.has(c)&&{fixed:!0},...r===i&&{title:!0},...c===`text`&&r!==i&&TO(s)&&{link:TO(s)},...c===`text`&&r!==i&&s?.linkText!==void 0&&{linkText:n=>UO(e,t,r,n)},...n.includes(r)&&{highlight:!0},...o.type===`enum`&&{tones:Object.fromEntries((o.enumValues??[]).map(e=>[e,AO(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:qO(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:LO(e[r])},...CO(o,s)&&{value:e=>typeof e[r]==`string`?SO(e[r]):e[r]},...(c===`percent`||c===`number`&&o.type===`decimal`)&&{value:e=>e[r]==null?null:Number(e[r])}}]})},YO=`$photos`,XO=e=>{for(let t of e?.list?.displays??[])if(t.kind===`cards`&&t.photos)return t.photos},ZO=(e,t,n)=>{if(n===void 0||e.primaryKey.length!==1)return t;let r=e.primaryKey[0];return t.map(e=>({...e,[YO]:n[String(e[r])]??[]}))},QO=(e,t)=>t.filter(t=>e[t]!==null&&e[t]!==void 0&&e[t]!==``),$O=I(`app/displays`),ek=(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:Lr(e,i?.valueLabels)}));return r.nullable?[...a,{value:null,label:$O(`noValue`,{label:i?.label??F(n.by)})}]:a},tk=e=>e.position&&e.position.within===void 0?e.position.field:void 0,nk=(e,t,n)=>{let r=yt(n===null?jt.isNull(t):jt.eq(t,n));return e===``?r:`(${e}) AND ${r}`},rk=(e,t,n)=>({kind:`cards`,name:n.name,title:n.title??Vr(e,t),...n.subtitle!==void 0&&{subtitle:n.subtitle},...n.badge!==void 0&&{badge:n.badge},...n.meta&&{meta:n.meta}}),ik=e=>{if(!wd(e))return e instanceof Error?e.message:$O(`somethingWrong`);let t=e.errors.map(e=>e.message);return t.length>0?t.join(`; `):e.message},ak=e=>e?.list?.displays??[],ok=(e,t)=>t??e?.list?.default,sk=(e,t,n)=>{let r=ok(e,n);return r===void 0?t?ak(e).find(e=>e.kind===`cards`)?.name??`table`:Tn:r},ck=`rows`,lk=(e,t)=>{if(ak(t).some(e=>e.kind===`cards`||e.name===`rows`))return;let n=Vr(e,t),r=hi(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:ck,label:$O(`list`),icon:`list`,title:n,...i!==void 0&&{badge:i},footer:a}},uk=(e,t)=>t.name===`rows`&&!ak(e).some(e=>e.name===`rows`),dk=(e,t,n)=>{let r=sk(t,n);return n&&ok(t)===void 0&&r===`table`&&lk(e,t)?ck:r},fk=(e,t,n)=>(n===`rows`?lk(e,t):void 0)??pk(t,n),pk=(e,t)=>{if(t===`table`)return;let n=t=>ak(e).find(e=>e.name===t);return n(t)??n(e?.list?.default)},mk={cards:`cards`,map:`map`,board:`kanban`,calendar:`calendar`,timeline:`timeline`},hk=e=>[{name:Tn,label:$O(`table`),icon:`table`},...ak(e).map(e=>({name:e.name,label:e.label??F(e.name),icon:e.icon??mk[e.kind]}))],gk=(e,t,n)=>{let r=hk(t);return n&&lk(e,t)?[...r,{name:ck,label:$O(`list`),icon:`list`}]:r},_k=(e,t,n)=>({image:n.image,title:n.title??Vr(e,t),subtitle:n.subtitle,amount:n.amount??[],badge:n.badge,code:n.code,meta:n.meta??[],footer:n.footer??[],flags:n.flags??[]}),vk=(e,t)=>QO(e.record,t),yk=(e,t)=>vk(e,t)[0],bk=(e,t)=>t===void 0?void 0:vk(e,[t])[0],xk=(e,t)=>e?.type===`text`&&typeof t==`string`?t:void 0,Sk=(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:zO(e,t,n)}:{amount:zO(e,t,i),suffix:r}},Ck=(e,t)=>{let n=ak(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}},wk=(e,t,n)=>{if(n.kind===`custom`)return n.fields;if(n.kind===`map`)return[n.latitude,n.longitude,...wk(e,t,Ck(t,n))];if(n.kind===`board`){let r=rk(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??Vr(e,t)].filter(e=>e!==void 0);if(n.kind===`timeline`)return[n.start,n.end,n.group,n.title??Vr(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}=_k(e,t,n);return[r,i,a,...o,s,c,...l,...u,...d].filter(e=>e!==void 0)},Tk=e=>(e?.actions??[]).flatMap(e=>(e.inputs??[]).flatMap(e=>e.from===void 0?[]:[e.from])),Ek=(e,t)=>t.flatMap(t=>qt(e?.fields[t]?.linkText??``)),Dk=(e,t,n)=>{let r=lk(e,t),i=r?[...ak(t),r]:ak(t),a=[...n,...i.flatMap(n=>wk(e,t,n))];return[...new Set([...a,...Ek(t,a),...Tk(t)])]},Ok=(e,t,n)=>{let r=uk(t,n)?[Vr(e,t),...hi(e,t)]:wk(e,t,n);return[...new Set(r)].filter(t=>e.fields[t]?.sortable)},kk=e=>typeof e==`object`&&!!e&&`id`in e&&`name`in e,Ak=(e,t)=>{let n={},r={},i=Array.isArray(t.$photos)?t[YO]:void 0;for(let[i,a]of Object.entries(t))(i!==`id`&&i!==`$photos`||Object.hasOwn(e.fields,i))&&(e.fields[i]?.type===`relation`&&kk(a)?(n[i]=a.id,r[i]=a.name):n[i]=a);return{key:Zn(lE(e,n)),record:n,labels:r,...i&&{photos:i}}},jk=(e,t,n,r)=>{let i=e[n],a=Ln(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}},Mk=(e,t,n=!1)=>({display:e?dk(e,t,n):sk(t,n),orderBy:e?ED(e,t):``,filterLayout:`bar`,filter:t?.list?.filter??``}),Nk=(e,t)=>e?.kind===`record`?{kind:`record`,resource:e.resource,key:Zn(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?.kind===`list`?{...t(e.resource,e.list),...e}:e,Pk=(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}}},Fk=()=>{let{path:e,params:t,basePath:n,navigate:r,back:i}=Ou(),{pages:a,resources:o,views:s}=ov(),c=Wv(),l=(0,M.useMemo)(()=>new Set(Object.keys(a)),[a]),u=t.toString(),d=(0,M.useMemo)(()=>td(u?`${e}?${u}`:e,l),[e,u,l]),f=(0,M.useCallback)((e,t)=>{let n=jk(o,s,e,t);return Mk(n.model,n.view,c)},[o,s,c]),p=(0,M.useMemo)(()=>Nk(d,f),[d,f]),m=(0,M.useCallback)((e,t)=>r(Xu(e),t),[r]),h=(0,M.useCallback)(e=>{if(d?.kind!==`list`)throw Error(`listTo and set change the list the app shows; use go to move to another address`);return Pk(d,e,f(d.resource,d.list))},[d,f]),g=(0,M.useCallback)(e=>m(h(e),{replace:!0}),[h,m]),_=(0,M.useCallback)(e=>Xu(e,n),[n]),v=(0,M.useCallback)(e=>e.startsWith(`${n}/`)?e.slice(n.length):e,[n]);return{address:p,set:g,listTo:h,go:m,href:_,open:(0,M.useCallback)(e=>r(v(e)),[v,r]),back:(0,M.useCallback)(e=>i(v(e)),[v,i])}},Ik=({to:e,...t})=>(0,R.jsx)(Lu,{to:Xu(e),...t}),Lk=`SplashScreen`,Rk=e=>{if(e?.isPluginAvailable(Lk))return{show:()=>e.nativePromise(Lk,`show`,{autoHide:!1}),hide:()=>e.nativePromise(Lk,`hide`,{})}},zk=({answer:e,current:t,next:n})=>!e?.bundleId||e.required||e.bundleId===t||e.bundleId===n?{kind:`none`}:{kind:`take`,bundleId:e.bundleId},Bk=e=>{let t=typeof e==`object`&&e?e.bundleId:void 0;return typeof t==`string`?t:null},Vk=({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=zk({answer:e,current:Bk(n),next:Bk(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=Bk(n);if(a===null||a===Bk(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)}},Hk=e=>/(?:^|\s)ProtobaseNative\/([0-9a-f]{16})(?:\s|$)/.exec(e)?.[1],Uk=/^[A-Za-z0-9_-]{1,64}$/,Wk=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Gk=e=>{if(!Wk(e))return;let{bundleId:t,url:n,required:r}=e;if((t===null||typeof t==`string`&&Uk.test(t))&&(n===null||typeof n==`string`)&&typeof r==`boolean`)return{bundleId:t,url:n,required:r}},Kk=15e3,qk=e=>e instanceof TypeError||e instanceof DOMException&&e.name===`TimeoutError`,Jk=async(e,{apiOrigin:t,fingerprint:n,shellVersion:r})=>{let i=`${t}${Gr}?${qr({fingerprint:n,shellVersion:r})}`;try{let t=await e(i,{credentials:`omit`,cache:`no-store`,signal:AbortSignal.timeout(Kk)});return t.status===200?Gk(await t.json()):void 0}catch(e){if(qk(e)||e instanceof SyntaxError)return;throw e}},Yk=({bridge:e,apiOrigin:t,userAgent:n,fetch:r})=>{if(!e?.Exception||!e.isPluginAvailable(`LiveUpdate`))return;let i=Hk(n);return Vk({bridge:{nativePromise:e.nativePromise.bind(e),Exception:e.Exception},check:async()=>i&&t?Jk(r,{apiOrigin:t,fingerprint:i,shellVersion:qi}):void 0,releasesUrl:`${t}${Kr}`,splash:Rk(e)})},Xk=({updater:e,children:t})=>((0,M.useEffect)(()=>{e&&e.ready()},[e]),(0,R.jsx)(FE.Provider,{value:e,children:t})),Zk=async(e,t)=>{let n=!1,r=!1;try{r=await e.applyNext(()=>{t.keep(),n=!0})}finally{!r&&n&&t.forget()}return r},Qk=2e4,$k=async(e,t)=>{let n,r=new Promise(e=>{n=setTimeout(()=>e(!1),Qk)}),i=e.check();return await Promise.race([i.then(()=>!0),r]).finally(()=>clearTimeout(n))?t?Zk(e,t):!1:(i.then(()=>void 0),!1)},eA=`protobase:ui-ready`,tA=(e=window)=>void e.requestAnimationFrame(()=>e.setTimeout(()=>e.dispatchEvent(new Event(eA)),0)),nA=`pb-start`,rA=`pb-start-hand-off`,iA=e=>{let t=e.getElementById(nA);t&&(t.dispatchEvent(new Event(rA)),t.remove())},aA=9e5,oA=(e,t)=>{e();let n=setInterval(()=>{t()&&e()},aA);return()=>clearInterval(n)},sA=()=>{let e=IE(),t=J().state.kind===`signed-in`,n=!!ov().versionChange;return(0,M.useEffect)(()=>{if(e&&t)return oA(()=>void e.check(),()=>document.visibilityState===`visible`)},[e,t,n]),null},cA=(e=Date.now)=>{let t;return{leave:()=>{t=e()},back:()=>{let n=t===void 0?0:e()-t;return t=void 0,n}}},lA=({updater:e,holdsChanges:t,page:n,now:r})=>{let i=cA(r);return{leave:i.leave,back:async()=>{let r=i.back();n&&r>=3e5&&!t()&&await Zk(e,n)||await e.check()}}},uA=()=>{let e=IE(),{holdsChanges:t}=Ou();return(0,M.useEffect)(()=>{if(!e)return;let n=lA({updater:e,holdsChanges:t,page:Wa()}),r=()=>{if(document.visibilityState===`hidden`)return n.leave();n.back()};return document.addEventListener(`visibilitychange`,r),()=>document.removeEventListener(`visibilitychange`,r)},[e,t]),null},dA=[`never`,`thirty_minutes`,`one_hour`,`four_hours`,`today`,`this_week`,`custom`],fA={thirty_minutes:30,one_hour:60,four_hours:240},pA=(e,t)=>new Date(e.getFullYear(),e.getMonth(),e.getDate()+t),mA=(e,t,n=``)=>{if(e===`never`)return null;if(e===`today`)return pA(t,1).toISOString();if(e===`this_week`)return pA(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()+fA[e]*6e4).toISOString()},hA=e=>String(e).padStart(2,`0`),gA=e=>{let t=new Date(e);return`${t.getFullYear()}-${hA(t.getMonth()+1)}-${hA(t.getDate())}T${hA(t.getHours())}:${hA(t.getMinutes())}`},_A=(e,t=Date.now())=>{let n=mi(e,t);return n?{availability:n.availability,text:n.text??``,clears:n.clearsAt===null?`never`:`custom`,custom:n.clearsAt===null?``:gA(n.clearsAt)}:{availability:`automatic`,text:``,clears:`never`,custom:``}},vA=(e,t)=>{let n=e.text.trim(),r=n===``?void 0:pi(n);if(r)return{problem:`text`,message:r};let i=mA(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}}},yA={never:`never`,thirty_minutes:`thirtyMinutes`,one_hour:`oneHour`,four_hours:`fourHours`,today:`today`,this_week:`thisWeek`,custom:`custom`},bA=({current:e,onSave:t,onClear:n,onClose:r})=>{let[i,a]=(0,M.useState)(()=>_A(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=vA(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 Sd))throw e;l(e.status===400?e.message:Yb(`couldNotSave`)),s(!1)}},y=()=>{d(!0),`input`in g&&v(()=>t(g.input))};return(0,R.jsx)(su,{title:Yb(e?`editStatus`:`setStatus`),onClose:r,actions:(0,R.jsxs)(R.Fragment,{children:[e&&(0,R.jsx)(V,{variant:`ghost`,className:`sm:mr-auto`,disabled:o,onClick:()=>void v(n),children:Yb(`clear`)}),(0,R.jsx)(V,{onClick:r,children:Yb(`cancel`)}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,form:f,loading:o,children:Yb(`save`)})]}),children:(0,R.jsxs)(`form`,{id:f,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`label`,{htmlFor:p,className:`font-medium`,children:Yb(`statusText`)}),(0,R.jsx)(qy,{id:p,name:`status`,autoComplete:`off`,autoFocus:!0,placeholder:Yb(`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,R.jsx)(`span`,{id:`${p}-problem`,className:`text-xs text-danger-text`,children:_.message})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 font-medium`,children:[Yb(`availability`),(0,R.jsx)(fb,{label:Yb(`availability`),value:i.availability,onChange:e=>h({availability:e}),options:[{value:`automatic`,label:Yb(`automatic`)},{value:`busy`,label:Yb(`busy`)},{value:`do_not_disturb`,label:Yb(`doNotDisturb`)}]}),i.availability===`do_not_disturb`&&(0,R.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:Yb(`doNotDisturbHint`)})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Yb(`clearsAfter`),(0,R.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:dA.map(e=>(0,R.jsx)(`option`,{value:e,children:Yb(yA[e])},e))})]}),i.clears===`custom`&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`label`,{htmlFor:m,className:`font-medium`,children:Yb(`clearsAt`)}),(0,R.jsx)(qy,{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,R.jsx)(`span`,{id:`${m}-problem`,className:`text-xs text-danger-text`,children:Yb(`pickTime`)})]}),c&&(0,R.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:c})]})})},xA=e=>{let t=X(),n=x(),r=rE(),[i,a]=(0,M.useState)(!1);if(!e||!r.isSuccess)return{};let o=mi(r.data),s=()=>n.invalidateQueries({queryKey:[`statuses`]});return{menu:{mark:o&&(0,R.jsx)($b,{status:o,textShown:`hover`}),label:o?(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-foreground`,children:[(0,R.jsx)(Qb,{availability:o.availability}),(0,R.jsx)(`span`,{className:`truncate`,children:o.text??Zb(o.availability)})]}):Yb(`setStatus`),onOpen:()=>a(!0)},...i&&{dialog:(0,R.jsx)(bA,{current:o,onSave:async e=>{await t.status.set(e),await s()},onClear:async()=>{await t.status.clear(),await s()},onClose:()=>a(!1)})}}},SA=e=>e?.kind===`page`?e.page:e?.kind===`list`?jw(e.resource,e.list):e?.resource,CA=e=>e?.kind===`record`?e:void 0,wA=({workspace:e,sidebarMode:t,assistant:n,runtime:r})=>{let i=ov(),{state:a,session:o,signOut:s,stopStaffSession:c,organizations:l}=J(),u=BS();if(a.kind!==`signed-in`&&a.kind!==`visitor`)throw Error(`The shell is only rendered for a signed-in user or a visitor`);let d=a.kind===`signed-in`?a.user:void 0,f=a.kind===`signed-in`?a.staff:void 0,{path:p,params:m,basePath:h,navigate:g}=Ou(),{address:_,go:v,open:y,back:b}=Fk(),x=SA(_),S=CA(_),C=PE(),w=HC(),T=LD(i,h,{resource:S?.resource,key:S?.key}),E=v_();TC(i);let D=Fw(i,h,T),O=(0,M.useMemo)(()=>Iw(i),[i]),k=_?.kind===`page`?i.pages[_.page]:void 0;(0,M.useEffect)(()=>{p===`/`&&(O?v(O,{replace:!0}):d&&g(a_,{replace:!0}))},[p,O,v,d,g]);let A=_?.kind===`page`?void 0:_?.resource,ee=A?F_(i,A):void 0,te=A?Ln(i.views[A],_?.kind===`list`?_.list:void 0):void 0,ne=D.find(e=>e.items.some(e=>e.id===x)),re=A?i.resources[A]:void 0,j=DC(S?.resource??``,S?.key??``,!!(re&&S)),ie=mE(),ae=re&&S&&j.data?ie(re,te,j.data.record,S.key):void 0,N=!!S&&(j.isLoading||ee?.state===`loading`),{shell:oe}=hw(),P=oe?.actions,se=oe?.rightPanel,ce=i.bell&&d&&!f&&(0,R.jsx)(KT,{own:oe?.bell}),le=xA(!!(i.status&&d&&!f)),ue=nE().data,de=uw(),[fe,pe]=(0,M.useState)(!1),me=i.assistant?.url,he=me&&(0,R.jsx)($C,{open:fe,onToggle:()=>pe(!fe)}),ge=me&&fe&&(0,R.jsx)(fD,{url:me,client:n,page:m.size>0?`${p}?${m}`:p,onClose:()=>pe(!1)}),_e=i.errorReporting;(0,M.useEffect)(()=>{_e&&Zh(_e)},[_e]);let ve=i.runtime?.url,ye=ve&&(0,R.jsx)(mD,{url:ve,client:r}),be=cx(t??`text-small`),xe=i.versionChange&&!be&&(0,R.jsx)(zE,{}),Se=ww((0,M.useCallback)(()=>bw(h),[h]),!!d),Ce=d&&xw(d,Se.current),we=Ce?mC(Ce):!1,Te=JT(),Ee=yw(!!(l&&d)),De=Ee.current,Oe=!!l&&De!==void 0&&!De.organization,ke=l&&d?JS(p):void 0,Ae=Vv(),je=d?s_(p):void 0,Me=je&&Ae?Hw(Vw(Ae.tree),je.tab):void 0,Ne=p===dx,Pe=rw(i,h,x,_?.kind===`list`||_?.kind===`page`),Fe=Pe.find(e=>!e.external)?.href.slice(h.length),Ie={href:`${h}${dx}`,shown:Ne},Le=mx({desktop:Uv(),tabs:Pe,menuPage:Ie}).on,Re=(0,M.useRef)(!1);(0,M.useEffect)(()=>{let e=!Re.current;Re.current=!0;let t=fx(p,Fe,{starting:e,morePage:Le});t&&g(t,{replace:!0})},[p,Fe,Le,g]);let ze=Ne?U(`menu`):d?je?Ae?.title??U(`account`):p===`/-/sign-in-policy`?U(`signInPolicy`):ke:void 0,Be=te?.names?.plural??(A&&F(A)),Ve=_?.kind===`record`&&!_.standard&&!!i.views[_.resource]?.record,He=ze?[ze]:aw({basePath:h,address:_,group:ne?.label,page:k,resourceLabel:Be,headingless:Ve,recordTitle:ae,recordLoading:N}),Ue=te?.names?.singular??(A&&F(A)),We=k&&_?.kind===`page`?Hw(Vw(k.tree),_.tab):void 0;Bx(zx(Rx({address:_,page:k?{title:k.title,...We&&{tab:We.label}}:je&&Ae&&{title:Ae.title,...Me&&{tab:Me.label}},accountPage:ze,resourceLabel:Be,singular:Ue,recordTitle:ae,recordLoading:N}),i.appName));let Ge=je?(0,R.jsx)(rD,{...je}):d&&p===`/-/sign-in-policy`?we?(0,R.jsx)(iD,{}):(0,R.jsx)(sv,{title:U(`adminsOnly`),children:U(`onlyAdminPolicy`)}):ke&&p===`/-/organization`?(0,R.jsx)(aD,{current:De,basePath:h,onChanged:Ee.reload}):ke&&(p===`/-/organization/members`||p===`/-/organization/invitations`)?ZS(De)?p===`/-/organization/members`?(0,R.jsx)(sD,{current:De,statuses:ue,presence:de}):(0,R.jsx)(cD,{current:De}):(0,R.jsx)(sv,{title:U(`ownersOnly`),children:U(`onlyOwners`)}):ke&&p===`/-/organizations`||Oe?(0,R.jsx)(oD,{state:Ee,basePath:h}):_?_.kind===`page`?k?(0,R.jsx)(nD,{name:k.name,..._.tab&&{tab:_.tab},..._.params&&{params:_.params}},k.name):(0,R.jsx)(sv,{title:U(`notFound`),children:U.rich(`noPage`,{page:_.page})}):ee&&ee.state!==`ready`?(0,R.jsx)(yE,{status:ee}):_.kind===`create`?(0,R.jsx)(tD,{resource:_.resource,values:_.values},_.resource):_.kind===`record`?(0,R.jsx)(eD,{resource:_.resource,recordKey:_.key},`${_.resource}/${_.key}`):(0,R.jsx)($E,{address:_},jw(_.resource,_.list)):p===`/`?(0,R.jsx)(sv,{title:U(`chooseResource`),children:U(`pickFromSidebar`)}):(0,R.jsx)(sv,{title:U(`notFound`),children:U(`nothingHere`)}),Ke=we&&Te.length>0;return(0,R.jsx)(Cx,{pageScroll:!0,sidebarMode:t??`text-small`,activeItem:x??``,breadcrumb:He,titleStatus:(E===`refreshing`||E===`failed`)&&(0,R.jsx)(QT,{failed:E===`failed`}),staleContent:E===`failed`?`failed`:void 0,user:Ce&&gC(Ce),onSignOut:d&&(()=>void s()),signIn:d?void 0:u.link(),workspace:De?.organization?.name??e,appName:i.appName,appIcon:i.appIcon,logo:Uw,navGroups:D,bottomBar:Pe,menuPage:Ie,bottomBarSearch:iw(i),userMenu:[Aw(i,h,x),l&&d?QS(h,p,De):[],d?l_(h,p,we):[]],account:d&&`${h}/-/account`,organizations:l&&{...De?.organization&&{current:{id:De.organization.id,name:De.organization.name}},others:Ee.organizations.filter(e=>e.id!==De?.organization?.id),onSwitch:e=>void o.organizations.switchTo(e).then(()=>bw(h))},theme:{preference:w.preference,onChange:w.choose},...le.menu&&{status:le.menu},roles:Se.current?.active?{active:Se.current.active,roles:Se.current.roles,onSwitch:Se.switchTo}:void 0,onNavigate:y,onBack:b,sidebarNotice:(0,R.jsx)(RE,{}),banner:(f||Ke)&&(0,R.jsxs)(R.Fragment,{children:[f&&(0,R.jsx)(wD,{signIn:f,onStop:c}),Ke&&(0,R.jsx)(XT,{off:Te})]}),search:C.available?{placeholder:C.placeholder,text:C.text,onTextChange:C.setText,query:C.query,loading:C.loading,groups:C.groups,onSelect:y}:void 0,actions:(P||ce||xe||ye||he)&&(0,R.jsxs)(R.Fragment,{children:[P&&(0,R.jsx)(aC,{name:`shell.actions`,fallback:null,children:(0,R.jsx)(P,{})}),ce,xe,ye,he]}),overlays:(le.dialog||i.calls&&d&&!f)&&(0,R.jsxs)(R.Fragment,{children:[le.dialog,i.calls&&d&&!f&&(0,R.jsx)(pD,{})]}),rightPanel:(se||ge)&&(0,R.jsxs)(R.Fragment,{children:[se&&(0,R.jsx)(aC,{name:`shell.rightPanel`,fallback:null,children:(0,R.jsx)(se,{})}),ge]}),children:(0,R.jsx)(aC,{name:`page`,fallback:(0,R.jsx)(sv,{title:U(`pageNotLoaded`),children:U(`pageNotLoadedHelp`)}),resetKey:m.size>0?`${p}?${m}`:p,children:Ge})})},TA=({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=cx(i??`text-small`),{path:f}=Ou(),p=CC(c),m=zg(c),h=ea(),g=(0,M.useMemo)(()=>h&&m?Mx({cache:h,owner:p}):void 0,[h,m,p]);return(0,R.jsx)(E_,{baseUrl:e,client:t,sources:n,token:c.kind===`visitor`?void 0:l.token,onUnauthenticated:u,persistence:g,children:(0,R.jsx)(uv,{children:(0,R.jsxs)(QC,{children:[!d&&(0,R.jsx)(HE,{}),(0,R.jsx)(sA,{}),f===`/-/connect`?(0,R.jsx)(lD,{}):(0,R.jsx)(YT,{ui:a,children:(0,R.jsx)(_w,{children:(0,R.jsx)(_E,{children:(0,R.jsx)(wA,{workspace:r,sidebarMode:i,assistant:o,runtime:s})})})})]})})},p)},EA=({baseUrl:e,client:t,ui:n,children:r})=>{let i=OC();return i?(0,R.jsx)(E_,{baseUrl:e,client:t,children:(0,R.jsx)(mw.Provider,{value:n??{},children:(0,R.jsx)(uD,{name:i.name},i.name)})}):r},DA=({baseUrl:e,children:t})=>{let n=MC(),{basePath:r}=Ou();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,R.jsx)(dD,{link:n.token,systemPath:a,base:`${window.location.origin}${r}`})},OA=({auth:e,workspace:t,basePath:n,initialUrl:r,pluginLoader:i,pluginSource:a,locale:o,nativeBridge:s,startCache:c,...l})=>{Ei(o??`en`);let u=l.baseUrl&&new URL(l.baseUrl,window.location.href).origin,d=(0,M.useMemo)(()=>Yk({bridge:s,apiOrigin:u,userAgent:navigator.userAgent,fetch:window.fetch.bind(window)}),[s,u]),f=(0,M.useMemo)(()=>d&&(()=>$k(d,Wa())),[d]),p=(0,M.useMemo)(()=>qv(s),[s]),m=(0,M.useMemo)(()=>I_(()=>{iA(document),Rk(s)?.hide(),tA()}),[s]);return(0,M.useEffect)(()=>m.start(),[m]),(0,M.useEffect)(()=>void gD(),[]),(0,R.jsx)(R_,{value:m,children:(0,R.jsx)($i,{value:c,children:(0,R.jsx)(VC,{children:(0,R.jsx)(Yv.Provider,{value:p,children:(0,R.jsx)(Xk,{updater:d,children:(0,R.jsx)(Yg,{session:e,...u&&{origin:u},...s&&{nativeBridge:s},...f&&{afterSignIn:f},children:(0,R.jsxs)(Iu,{basePath:n,initialUrl:r,children:[(0,R.jsx)(uA,{}),s&&u&&(0,R.jsx)(i_,{nativeBridge:s,apiOrigin:u}),(0,R.jsx)(Ma,{...i&&{loader:i},...a&&{source:a},children:(0,R.jsx)(bC,{children:(0,R.jsx)(EA,{baseUrl:l.baseUrl,client:l.client,ui:l.ui,children:(0,R.jsx)(DA,{...l.baseUrl&&{baseUrl:l.baseUrl},children:(0,R.jsx)(uC,{workspace:t,children:(0,R.jsx)(TA,{workspace:t,...l})})})})})})]})})})})})})})},kA=`protobase:first-frame`,AA=e=>ce(()=>e.sessionStorage.getItem(kA)===`1`,!1),jA=(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`},MA=async e=>{e.getPlatform()===`ios`&&e.isPluginAvailable(`Keyboard`)&&await e.nativePromise(`Keyboard`,`setAccessoryBarVisible`,{isVisible:!0})},NA=(e,t)=>{t===`ios`&&(e.dataset.pbTextSize=`system`)},PA=e=>[...e.split(`,`).map(e=>e.trim()).filter(e=>e&&!/^maximum-scale\s*=/.test(e)),`maximum-scale=1`].join(`, `),FA=e=>{let t=e.querySelector(`meta[name="viewport"]`);t&&t.setAttribute(`content`,PA(t.getAttribute(`content`)??``))},IA=e=>{if(e.length===0)return;if(e.length>1)throw Error(`The page has ${e.length} ${Ur} 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 ${Ur} meta tag holds "${t}", which is not an http or https origin such as https://shop.example.com`);return t},LA=()=>IA([...document.querySelectorAll(`meta[name="${Ur}"]`)].map(e=>e.content)),RA=document.getElementById(`root`);if(!RA)throw Error(`index.html needs an element with id "root"`);le(document);var zA=Vh(window);if(zA){FA(document),NA(document.documentElement,zA.getPlatform()),MA(zA);let e=ce(()=>window.sessionStorage,void 0);e&&Ua(e,window.history)}var BA=Oi(),VA=Ii(BA).catch(()=>void 0),HA=ka(wa);ia().then(async e=>{let t=Ui(e);await Promise.race([Promise.all([Aa(HA,Wi(e),Pa),VA,...t?.locale?[Ii(t.locale).catch(()=>void 0)]:[],...t?[gD()]:[]]),new Promise(e=>setTimeout(e,Pa))]);let n=(0,R.jsx)(M.StrictMode,{children:(0,R.jsx)(OA,{baseUrl:`${LA()??``}/api/v1`,ui:ua(P),locale:BA,nativeBridge:zA,startCache:e,pluginSource:HA})});if(AA(window))return jA(RA,n);(0,oe.createRoot)(RA).render(n)});var UA=(e,t,{filter:n,orderBy:r,pageSize:i=50,fields:a,labels:o,startToken:s=``})=>{let c=dd(n)??``;return{queryKey:[...L.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}},WA=(e,{enabled:t=!0,refetchInterval:n,...r}={})=>{let i=A({...UA(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]??{}))]))}},GA=(e,t,n,r=!0)=>{let i=X(),a=dd(n)??``;return O({queryKey:L.facets(e,t,a),enabled:r,queryFn:()=>i.facets(e,t,{filter:a,limit:50})})},KA=(e,t,n=!0)=>{let r=X(),i=dd(t.filter)??``;return O({queryKey:L.series(e,t.field,`${t.range??``}${t.from??``}${t.to??``}`,t.granularity??``,i),enabled:n,queryFn:()=>r.series(e,{...t,filter:i})})},qA=(e,t,n,r=20,i=!0)=>{let a=X(),o=dd(n)??``;return O({queryKey:L.histogram(e,t,r,o),enabled:i,queryFn:()=>a.histogram(e,t,{filter:o,buckets:r})})},JA=(e,t,n)=>{let r={...n,filter:dd(n.filter)??``};return{queryKey:L.aggregate(t,JSON.stringify(r)),queryFn:()=>e.aggregate(t,r)}},YA=(e,t,n=!0)=>O({...JA(X(),e,t),enabled:n}),XA=(e,t,n=!0)=>{let r=X();return ee({queries:t.map(t=>{let i={...t,filter:dd(t.filter)??``};return{queryKey:L.aggregate(e,JSON.stringify(i)),enabled:n,queryFn:()=>r.aggregate(e,i)}})})},ZA=(e,t)=>{let n=X(),r=x(),i=Zn(t);return S({mutationFn:({patch:r,etag:i})=>n.update(e,t,r,i),onSuccess:t=>{r.setQueryData(L.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`&&Hi(t.queryKey,new Set([e]))})}})},QA=e=>e instanceof Cd,$A=class extends Error{errors;constructor(e){super(Object.values(e).join(`; `)),this.errors=e,this.name=`ActionInputError`}},ej=(e,t)=>{let n=new Set(t.map(e=>e.name)),r=e instanceof $A?Object.entries(e.errors):wd(e)?e.errors.flatMap(e=>e.field?[[e.field,e.message]]:[]):[];return Object.fromEntries(r.filter(([e])=>n.has(e)))},tj=e=>{if(!(!zD(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}}},nj=(e,t)=>e&&Object.hasOwn(e,t)?e[t]:void 0,rj=(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)},ij=(e,t,n)=>e?.nonce===t?e.value:n,aj=(e,t)=>{let[n,r]=(0,M.useState)(),i=(0,M.useCallback)(n=>r(r=>({nonce:e,value:n(ij(r,e,t))})),[e,t]);return[ij(n,e,t),i]},oj=`data-protobase-link`,sj=`(() => {
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('${oj}')
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
+ })()`,cj=`allow-scripts`,lj=(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(`; `),uj=()=>Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``),dj=`meta[http-equiv], base, noscript`,fj=(e,t,n)=>{let r=new DOMParser().parseFromString(e,`text/html`);for(let e of r.querySelectorAll(dj))e.remove();let i=r.createElement(`meta`);i.httpEquiv=`Content-Security-Policy`,i.content=lj(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=sj,r.head.prepend(i,a,o),`<!doctype html>${r.documentElement.outerHTML}`},pj=1,mj=(e,t,n)=>e?.kind===`fixed`?e:e&&n!==e.viewport&&Math.abs(t-e.height-(n-e.viewport))<=pj?{kind:`fixed`}:{kind:`measured`,height:t,viewport:n},hj=e=>e?.kind===`measured`&&e.height>0?{style:{height:e.height}}:{className:`min-h-[60vh]`},gj=1e5,_j=(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),gj)};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),gj)}}},vj=[],yj=(e,t)=>{let n=Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop)||0;window.scrollTo({top:e.getBoundingClientRect().top+window.scrollY+t-n})},bj=({html:e,title:t,links:n=vj,onLink:r,scripts:i=`bridge`,className:a})=>{let o=(0,M.useRef)(null),s=(0,M.useMemo)(()=>{let t=uj();return{nonce:t,srcDoc:fj(e,i,t)}},[e,i]),[c,l]=aj(s.nonce,void 0),[u,d]=aj(s.nonce,0),f=`${s.nonce}:${u}`,p=(0,M.useRef)({key:f,count:0});(0,M.useEffect)(()=>{let e=e=>{let t=_j(e,o.current?.contentWindow,n.length),i=o.current?.clientHeight;t?.kind===`height`&&i!==void 0&&l(e=>mj(e,t.height,i)),t?.kind===`link`&&r?.(n[t.index],{newTab:t.newTab}),t?.kind===`scroll`&&o.current&&yj(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=hj(c);return(0,R.jsx)(`iframe`,{ref:o,title:t,sandbox:cj,referrerPolicy:`no-referrer`,allow:i===`bridge`?`fullscreen`:void 0,srcDoc:u>1?``:s.srcDoc,onLoad:m,className:z(`block w-full border-0 bg-white`,h.className,a),style:h.style},f)},xj=e=>e.split(/[?#]/,1)[0].split(`/`).includes(`..`),Sj=(e,t)=>{let n=t.trim(),r=Cj(n);if(!(xj(n)||xj(r)))return rj(e,n)??rj(e,r)},Cj=e=>{try{return decodeURI(e)}catch(t){if(t instanceof URIError)return e;throw t}},wj=(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(`,`),Tj=(e,t)=>e.replace(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi,(e,n,r)=>{let i=t(r.trim());return i?`url("${i}")`:e}),Ej=e=>{if(!URL.canParse(e))return;let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:void 0},Dj=[`img[src]`,`source[src]`,`video[src]`,`audio[src]`,`track[src]`,`input[src]`].join(`, `),Oj=(e,t)=>{let n=(e,t,n)=>n!==void 0&&e.setAttribute(t,n);for(let r of e.querySelectorAll(Dj))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`,wj(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`,Tj(r.getAttribute(`style`),t));for(let n of e.querySelectorAll(`style`))n.textContent=Tj(n.textContent,t)},kj=e=>new DOMParser().parseFromString(e,`text/html`),Aj=(e,t)=>{let n=new Set;return Oj(kj(e),e=>{let r=Sj(t,e);r&&n.add(r)}),[...n]},jj=(e,t,n,r)=>{let i=kj(e);for(let e of i.querySelectorAll(`[${oj}]`))e.removeAttribute(oj);Oj(i,e=>{let r=Sj(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=Sj(t,n),o=i?void 0:Ej(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(oj,String(a.length)),a.push(s)}return{html:`<!doctype html>${i.documentElement.outerHTML}`,links:a}},Mj=e=>JSON.stringify(e.map(e=>[e.uri,`key`in e?e.key:null,`field`in e?e.field:null])),Nj=(0,M.createContext)(void 0),Pj=()=>{let e=(0,M.useContext)(Nj);if(e===void 0)throw Error(`useViewedResource must be used inside a file viewer`);return e},Fj=class extends Error{status;name=`FileReadError`;constructor(e){super(`The file could not be read: its link answered ${e}`),this.status=e}},Ij=e=>{let t=Pj(),n=S_(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 Fj(r.status);return r.text()}})},Lj=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error),r.readAsDataURL(e)}),Rj=e=>{let t=Pj(),n=S_(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 Fj(r.status);return Lj(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)}},zj=(e,t,n)=>{let r=Mj(t),{contents:i,ready:a}=Rj((0,M.useMemo)(()=>e===void 0?[]:Aj(e,t),[e,r])),o=[...i.keys()].join(`
28
+ `);return(0,M.useMemo)(()=>e===void 0||!a?void 0:jj(e,t,i,n),[e,r,a,o,n])},Bj=e=>{if(!wd(e))return[{message:e instanceof Error?e.message:U(`somethingWentWrong`)}];let t=e.errors.map(e=>({message:e.message,hint:e.hint}));return t.length>0?t:[{message:e.message}]},Vj=({error:e,title:t,onRetry:n})=>(0,R.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,R.jsx)(El,{className:`mt-0.5 size-4 shrink-0`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`font-medium`,children:t}),Bj(e).map(e=>(0,R.jsxs)(`p`,{className:`text-body`,children:[e.message,e.hint&&(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.hint]})]},e.message))]}),n&&(0,R.jsx)(V,{size:`sm`,onClick:n,children:U(`tryAgain`)})]}),Hj=({title:e,description:t,actions:n,className:r,bodyClassName:i,children:a})=>(0,R.jsxs)(`section`,{className:z(`flex min-w-0 flex-col rounded-lg border border-border bg-background`,r),"aria-label":e,children:[(e||t||n)&&(0,R.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-2 px-4 pt-4`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[e&&(0,R.jsx)(`h2`,{className:`text-base font-semibold tracking-tight`,children:e}),t&&(0,R.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t})]}),n&&(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),(0,R.jsx)(`div`,{className:z(`min-w-0 flex-1 p-4`,i),children:a})]}),Uj=({children:e})=>(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:e}),Wj=(0,M.createContext)(void 0),Gj=({value:e,children:t})=>(0,R.jsx)(Wj.Provider,{value:e,children:t}),Kj=()=>(0,M.useContext)(Wj),qj=({read:e,list:t,empty:n,children:r})=>e.isPending?(0,R.jsx)(cu,{className:`h-4 w-full`}):e.error?(0,R.jsx)(Vj,{title:iC(`couldNotLoad`),error:e.error}):t.items.length===0&&n!==void 0?(0,R.jsx)(Uj,{children:n}):(0,R.jsxs)(Gj,{value:t,children:[r,t.loadMore&&(0,R.jsx)(V,{size:`sm`,onClick:t.loadMore,loading:t.loadingMore,className:`self-start`,children:iC(`loadMore`)})]}),Jj=e=>`item`in e,Yj=(0,M.createContext)(void 0),Xj=(0,M.createContext)([]),Zj=({value:e,row:t,children:n})=>{let r=(0,M.useContext)(Xj),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,R.jsx)($j,{stack:o,children:n})},Qj=({value:e,children:t})=>{let n=(0,M.useMemo)(()=>[{...e,root:!0}],[e]);return(0,R.jsx)($j,{stack:n,children:t})},$j=({stack:e,children:t})=>{let n=e.at(-1);return(0,R.jsx)(Xj.Provider,{value:e,children:(0,R.jsx)(Yj.Provider,{value:Jj(n)?void 0:n,children:(0,R.jsx)(Gj,{value:void 0,children:t})})})},eM=()=>(0,M.useContext)(Yj),tM=()=>(0,M.useContext)(Xj),nM=e=>{let t=e[0];return t?.root&&!Jj(t)?t.record:void 0},rM=e=>{let t=nM(e);return{stack:(t?e.slice(1):e).map(e=>({record:Jj(e)?e.item:e.record,...e.row&&{row:e.row}})),...t&&{root:t}}},iM=e=>typeof e==`object`&&!!e,aM=(e,t)=>t.reduce((e,t)=>iM(e)&&Object.hasOwn(e,t)?e[t]:void 0,e),oM=(e,t)=>{let n=Lt(t);if(!n)return;let r=e=>{if(e)return Jj(e)?{item:aM(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=>Jj(e)?iM(e.item)&&Object.hasOwn(e.item,i):Object.hasOwn(e.model.fields,i))??e.at(-1))},sM=(0,M.createContext)(null),cM={},lM=(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}}},uM=({page:e,tab:t,tree:n,given:r=cM,children:i})=>{let a=(0,M.useMemo)(()=>Op(n,r),[n,r]),o=(0,M.useMemo)(()=>({page:e,...t&&{tab:t},given:r,values:a}),[e,t,r,a]);return(0,R.jsx)(sM.Provider,{value:o,children:i})},dM=()=>(0,M.useContext)(sM)?.values??cM,fM=()=>(0,M.useContext)(sM)?.given??cM,pM=()=>{let e=mM();if(!e)throw Error(`A SelectInput and a select render inside a composed page, whose address holds their values`);return e},mM=()=>{let e=(0,M.useContext)(sM),{go:t,href:n}=Fk();return e?{values:e.values,given:e.given,linkTo:r=>{let i=lM(e,r);return{href:n(i),onFollow:()=>t(i,{keepScroll:!0})}}}:void 0},hM=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}}},gM=At(),_M=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=Br(n,i),c=await e.fetchQuery({queryKey:L.labels(n.name,o.join(`,`)),staleTime:3e5,queryFn:async()=>(await t.list(n.name,{filter:yt(gM.in(a,o)),fields:[a,s],pageSize:o.length})).items.map(e=>[String(e[a]),String(e[s])])});return new Map(c)},vM=(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}]:[]}),yM=(e,t,n,r)=>Object.fromEntries(vM(e,n,r).filter(({target:e})=>e.primaryKey.length===1&&!t[e.name]?.titleFrom).map(({name:e,target:n})=>[e,Br(n,t[n.name])])),bM=(e,t,n,r,i={})=>{let a=vM(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})},xM=At(),SM=(e,t)=>{let n=t?.titleFrom;if(n&&!n.unreadable&&e.primaryKey.length===1)return n.fields},CM=(e,t,n)=>L.titleRow(e.name,t,n.join(`,`)),wM=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(xM.in(i,a)),fields:[i,...n],pageSize:a.length});return new Map(o.items.map(e=>[String(e[i]),e]))},TM=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||!SM(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=SM(o,r[i]),c=await wM(t,o,s,a);for(let t of new Set(a))e.setQueryData(CM(o,t,s),{row:c.get(t)??null})}))},EM=({label:e,className:t})=>(0,R.jsx)(`span`,{role:e===void 0?void 0:`img`,"aria-label":e,title:e,className:z(`inline-flex size-4 items-center justify-center rounded-full bg-success-soft text-success-text`,t),children:(0,R.jsx)(Io,{className:`size-3`,strokeWidth:3})}),DM=(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`},OM=e=>URL.canParse(e)?[new URL(e).hostname]:[],kM=()=>{let e=(0,M.useContext)(D_);return(0,M.useMemo)(()=>[...e?.files?.trustedHosts??[],...(e?.sources??[]).flatMap(({source:e})=>OM(e.url))],[e?.files,e?.sources])},AM=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)))},jM=({image:e,alt:t=``,className:n,loading:r})=>{let[i,a]=(0,M.useState)(),o=kM(),s=(0,M.useMemo)(()=>e.placeholder===void 0?void 0:AM(e.placeholder),[e.placeholder]),c=s!==void 0&&i!==e.url;return(0,R.jsx)(`img`,{src:e.url,alt:t,loading:r,decoding:`async`,referrerPolicy:DM(e.url,window.location.href,o),onLoad:()=>a(e.url),className:n,style:c?{backgroundImage:`url("${s}")`,backgroundSize:`cover`,backgroundPosition:`center`}:void 0})},MM=e=>t=>{let n=t.currentTarget;n.scrollWidth>Math.ceil(n.getBoundingClientRect().width)?n.title=e:n.removeAttribute(`title`)},NM=({text:e,className:t})=>(0,R.jsx)(`span`,{className:z(`truncate`,t),onMouseEnter:MM(e),children:e}),PM=e=>e.stopPropagation(),FM=({format:e,value:t,label:n,className:r})=>{let i=EO(e,t);return i?(0,R.jsx)(`a`,{href:i,...e===`url`?{target:`_blank`,rel:`noreferrer`}:{},onClick:PM,className:z(`font-medium text-primary-text hover:underline`,r),children:n??t}):(0,R.jsx)(`span`,{className:r,children:t})},IM=e=>(0,R.jsx)(`span`,{className:`text-faint-foreground`,children:e}),LM=(e,t,n)=>{if(t==null)return IM(`—`);let r=tO(e,t)??``;switch(e.kind){case`text`:return e.link?(0,R.jsx)(FM,{format:e.link,value:r,label:n&&e.linkText?.(n),className:`block min-w-0 truncate`}):(0,R.jsx)(NM,{text:r});case`id`:return(0,R.jsx)(NM,{text:r,className:`font-mono text-xs text-muted-foreground`});case`money`:return(0,R.jsx)(`span`,{className:`tabular-nums`,children:r});case`date`:return(0,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:r});case`datetime`:return(0,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,title:e.relative?vT(Number(t)):$D(`shownIn`,{zone:sT(Number(t),Qw())}),children:r});case`number`:return(0,R.jsx)(`span`,{className:`tabular-nums`,children:r});case`signed`:return(0,R.jsx)(`span`,{className:z(`tabular-nums`,Number(t)<0?`text-danger-text`:`text-success-text`),children:r});case`percent`:return Number(t)===0?IM(`—`):(0,R.jsx)(`span`,{className:`tabular-nums`,children:r});case`status`:return(0,R.jsx)(Av,{tone:e.tones?.[String(t)]??`neutral`,color:kO(e.colors,t),shape:e.shape,children:r});case`relation`:return(0,R.jsx)(NM,{text:r,className:`font-medium text-primary-text hover:underline`});case`boolean`:return t?(0,R.jsx)(EM,{}):IM($D(`no`));case`file`:{let e=VD(t);if(!e)return IM(`—`);if(`missing`in e)return(0,R.jsx)(NM,{text:e.name,className:`text-danger-text`});let n=YD(t,{width:20,height:20});return(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[n?(0,R.jsx)(jM,{image:n,className:`size-5 shrink-0 rounded-sm object-cover`}):(0,R.jsx)(wc,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(NM,{text:e.name})]})}case`user`:{let n=e.users?.(String(t));return n?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-2 truncate`,children:[(0,R.jsx)(Dy,{initials:n.initials,hue:n.hue,size:`xs`,className:`ring-0`}),(0,R.jsx)(NM,{text:n.name,className:`text-muted-foreground`})]}):(0,R.jsx)(NM,{text:r,className:`text-muted-foreground`})}}},RM=e=>{e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`},zM=({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=Ky();return(0,M.useLayoutEffect)(()=>{o.current&&RM(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,RM(e))});return n.observe(e),()=>n.disconnect()},[]),(0,R.jsx)(`textarea`,{ref:s,rows:n,value:r,className:z(`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})},BM=({children:e})=>(0,R.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}),VM=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
+ `)}},HM=I(`app/field-types/json`),UM=({value:e})=>{let[t,n]=(0,M.useState)(!1),r=JSON.stringify(e,null,2),{lines:i,folded:a}=VM(r);return a===null?(0,R.jsx)(BM,{children:r}):(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsx)(BM,{children:t?r:a}),(0,R.jsx)(V,{size:`sm`,variant:`ghost`,className:`-ml-2 justify-self-start`,"aria-expanded":t,onClick:()=>n(!t),children:t?HM(`showLess`):HM(`showAll`,{count:i})})]})},WM=Symbol(`not JSON`),GM=e=>{if(e.trim()===``)return null;try{return JSON.parse(e)}catch(e){if(!(e instanceof SyntaxError))throw e;return WM}},KM=({value:e})=>e===null?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,R.jsx)(UM,{value:e}),qM=({value:e})=>(0,R.jsx)(NM,{text:LO(e)}),JM=({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&&GM(r)===WM;return(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsx)(zM,{value:a,rows:3,invalid:n||o,className:`font-mono text-xs`,onChange:e=>{i(e.target.value);let n=GM(e.target.value);n!==WM&&t(n)}}),o&&(0,R.jsx)(`p`,{className:`text-xs text-danger-text`,children:HM(`notJson`)})]})},YM={of:[...gi.json],display:KM,editor:JM,cell:qM,wide:!0},XM=({editor:e,cell:t,...n},r)=>{let i=(e,t)=>UE(()=>r().then(t=>e(t)??(()=>null)),()=>(0,R.jsx)(cu,{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`)}}},ZM=I(`app/field-types/members`),QM=({id:e,name:t})=>(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(Dy,{initials:t&&Ay(t)||`?`,hue:ky(e),size:`xs`,className:`ring-0`}),(0,R.jsx)(`span`,{className:t===void 0?`truncate text-muted-foreground`:`truncate`,children:t??ZM(`unknownMember`)})]}),$M=At(),eN=e=>e.split(/\s+/).filter(Boolean),tN=(e,t,n,r=!1)=>{let i=eN(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($M.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=>$M.eq(t,`*${e.replaceAll(`*`,``)}*`));return{filter:yt($M.and(...o)),local:!1}},nN=(e,t)=>{if(e==null)return!1;let n=String(e).toLowerCase();return eN(t).every(e=>n.includes(e.toLowerCase()))},rN=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],iN=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],aN=(e,t)=>e.filter(e=>nN(e.name,t)).map(e=>({key:e.id,label:e.name})),oN=()=>{let e=Jg(),t=oE();return{...t,needsOrganizations:!e?.organizations,failed:t.isError}},sN=({value:e,line:t})=>{let n=oN(),r=rN(e);return r.length===0?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):n.needsOrganizations?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:ZM(`needsOrganizations`)}):n.failed?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:ZM(`couldNotLoadMembers`)}):n.isLoading?(0,R.jsx)(cu,{className:`h-4 w-24`}):(0,R.jsx)(`span`,{className:z(`flex min-w-0 items-center gap-x-3 gap-y-1`,t?`overflow-hidden`:`flex-wrap`),children:r.map(e=>(0,R.jsx)(QM,{id:e,name:n.member(e)?.name},e))})},cN=e=>(0,R.jsx)(sN,{...e,line:!1}),lN=e=>(0,R.jsx)(sN,{...e,line:!0}),uN=({label:e,onRemove:t})=>(0,R.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,R.jsx)(`span`,{className:`truncate`,children:e}),(0,R.jsx)(`button`,{type:`button`,"aria-label":Zl(`remove`,{label:e}),className:`rounded p-0.5 hover:bg-primary-border/60`,onMouseDown:e=>e.preventDefault(),onClick:t,children:(0,R.jsx)(Xl,{className:`size-3`})})]}),dN=()=>{let[e,t]=(0,M.useState)(``),[n,r]=(0,M.useState)(!1);return{text:e,setText:t,open:n,setOpen:r}},fN=(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])},pN=({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;fN(_,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,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(qy,{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,R.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,R.jsx)(`li`,{id:C(t),role:`option`,"aria-selected":t===h,className:z(`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,R.jsx)(`li`,{ref:b,"aria-hidden":!0,className:`h-px`}),l&&(0,R.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:U(`couldNotLoadOptions`)}),!S&&!c&&!l&&t.length===0&&(0,R.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:U(`noMatches`)}),c&&(0,R.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:U(`loading`)})]})]})},mN=({value:e,invalid:t,onChange:n})=>{let r=dN(),i=oN(),a=rN(e);if(i.needsOrganizations)return(0,R.jsx)(`p`,{className:`py-1.5 text-muted-foreground`,children:ZM(`needsOrganizations`)});let o=e=>i.member(e)?.name??ZM(`unknownMember`);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(pN,{search:r,options:aN(i.data??[],r.text),chosen:a,several:!0,closedText:``,placeholder:ZM(`searchMembers`),invalid:t,loading:i.isLoading,failed:i.failed,onChoose:e=>n(iN(a,e.key))}),a.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>(0,R.jsx)(uN,{label:o(e),onRemove:()=>n(a.filter(t=>t!==e))},e))})]})},hN={json:YM,members:{of:[...gi.members],display:cN,editor:mN,cell:lN},workflow:XM({of:[...gi.workflow],wide:!0,editor:!0,cell:!0},()=>s(()=>import(`./workflow-field-DXIk6V2Y.js`).then(e=>e.workflowField),__vite__mapDeps([54,1,6,7,55,56,57,58,59,60,61,62,63]))),workflow_run:XM({of:[...gi.workflow_run],wide:!0,editor:!1,cell:!0},()=>s(()=>import(`./workflow-run-field-BeMn3eOH.js`).then(e=>e.workflowRunField),__vite__mapDeps([64,1,6,7]))),workflow_status:XM({of:[...gi.workflow_status],editor:!1,cell:!0},()=>s(()=>import(`./workflow-status-field-0wvGDiva.js`).then(e=>e.workflowStatusField),__vite__mapDeps([65,1,6,10,7,66,8,63,55,56,57,58,59,60,61]))),custom_step_container:XM({of:[...gi.custom_step_container],wide:!0,editor:!0,cell:!0},()=>s(()=>import(`./custom-step-container-field-0-Q_RuZy.js`).then(e=>e.customStepContainerField),__vite__mapDeps([67,1,6]))),runner_install:XM({of:[...gi.runner_install],editor:!1,cell:!0},()=>s(()=>import(`./runner-install-field-CiD9Pw1j.js`).then(e=>e.runnerInstallField),__vite__mapDeps([68,1,6,35])))},gN=(e,t)=>{if(e&&Object.hasOwn(e,t))return e[t];if(Object.hasOwn(hN,t))return hN[t]},_N=(e,t,n)=>{let r=n?.widget;if(!r||t.sensitive)return;let i=gN(e,r.name);return i?.of.includes(t.type)?{name:r.name,widget:i,props:r.props??{}}:void 0},vN=(e,t)=>_N(hw().fields,e,t),yN=(e,t,n)=>{let r=_N(e,t,n);return!!(n?.multiline||n?.markdown||(r?r.widget.wide:t.type===`json`))},bN=I(`app/field-types`),xN=({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,R.jsx)(e,{...c})}let l=o.editor;return l&&i?(0,R.jsx)(l,{...c,onChange:i,invalid:a}):void 0},SN=({fallback:e,...t})=>{let n=xN(t);return n?(0,R.jsx)(aC,{name:bN(`fieldType`,{name:t.shown.name}),fallback:e,children:n}):e},CN=(e,t)=>e.type===`relation`&&typeof t==`object`&&t&&`id`in t?t.id:t,wN=(e,t,n,r)=>e.map(e=>{let i=t.fields[e.id],a=i&&_N(r,i,n?.fields[e.id]);return a?{...e,render:t=>(0,R.jsx)(SN,{shown:a,part:`cell`,field:i,value:CN(i,t[e.id]),fallback:LM(e,e.value?e.value(t):t[e.id],t)})}:e}),TN=(e,t,n,r,i)=>{let a=r?.titleFrom;return a?{queryKey:CM(n,i,a.fields),queryFn:async()=>({row:(await wM(t,n,a.fields,[i])).get(i)??null})}:{queryKey:L.relatedLabel(n.name,i),queryFn:async()=>({label:(await _M(e,t,n,[i],r)).get(i)??i})}},EN=(e,t,n,r,i)=>{if(e)return`label`in e?e.label:e.row?t(n,r,e.row,i):i},DN=(e,t,n=!0)=>{let{views:r}=ov(),i=X(),a=x(),o=mE(),s=r[e.name];return EN(O({...TN(a,i,e,s,t),staleTime:3e5,enabled:n}).data,o,e,s,t)},ON=e=>String(typeof e==`object`&&e&&`id`in e?e.id:e),kN=({target:e,id:t})=>(0,R.jsx)(NM,{text:DN(e,t)??t,className:`font-medium text-primary-text hover:underline`}),AN=(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?LM(e,null):(0,R.jsx)(kN,{target:a,id:ON(t[e.id])})}}),jN=({value:e,hints:t,children:n})=>(0,R.jsx)(Av,{tone:AO(t?.valueColors,e),color:kO(t?.valueColors,e),shape:t?.badgeShape,children:n}),MN=(0,M.lazy)(()=>s(()=>import(`./markdown-content-BlKajH2l.js`).then(e=>({default:e.MarkdownContent})),__vite__mapDeps([69,1,6,70,71]))),NN=e=>(0,R.jsx)(M.Suspense,{fallback:(0,R.jsx)(`div`,{className:z(`whitespace-pre-line break-words`,e.className),children:e.source}),children:(0,R.jsx)(MN,{...e})}),PN=I(`app/file-viewers`),FN=({name:e})=>(0,R.jsxs)(`div`,{className:`space-y-3 px-4 py-6 md:px-10`,"aria-busy":`true`,children:[(0,R.jsx)(`span`,{role:`status`,className:`sr-only`,children:PN(`loading`,{name:e})}),(0,R.jsx)(cu,{className:`h-6 w-2/3`}),(0,R.jsx)(cu,{className:`h-40`})]}),IN=(0,M.lazy)(()=>s(()=>import(`./html-viewer-GD1mwLEo.js`).then(e=>({default:e.HtmlViewer})),__vite__mapDeps([72,1,6]))),LN={"text/html":{component:e=>(0,R.jsx)(M.Suspense,{fallback:(0,R.jsx)(FN,{name:e.file.name}),children:(0,R.jsx)(IN,{...e})})}},RN=(e,t)=>nj(e.fileViewers,t)??nj(LN,t),zN=({file:e,className:t})=>(0,R.jsxs)(`a`,{href:e.url,download:e.name,className:z(tu({size:`sm`}),`gap-1.5`,t),children:[(0,R.jsx)(us,{className:`size-4`,"aria-hidden":`true`}),PN(`download`)]}),BN=(e,t)=>Object.values(e.fields).filter(n=>n.type===`relation`&&n.filterable&&n.name!==e.tenant&&t[n.name]!=null),VN=e=>typeof e==`object`&&e&&`id`in e?e.id:e,HN=(e,t)=>{let n=BN(e,t);if(n.length!==0)return n.map(e=>`${e.name} = ${JSON.stringify(VN(t[e.name]))}`).join(` AND `)},UN=(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=tj(a[t.name]);r&&r.uri!==n.uri&&!i.has(r.uri)&&i.set(r.uri,{...r,key:lE(e,a),field:t.name})}return[...i.values()]},WN=100,GN=(e,t)=>t.type===`file`?[t.name,...[t.file?.typeField,t.file?.sizeField].filter(t=>t!==void 0&&Object.hasOwn(e.fields,t))]:[],KN=(e,t,n)=>{let r=HN(e,t),i=[...e.primaryKey,...Object.values(e.fields).flatMap(t=>GN(e,t))],a=WA(e.name,{filter:r,pageSize:WN,fields:i,enabled:r!==void 0});return{siblings:UN(e,r===void 0?[t]:[t,...a.items],n),ready:r===void 0||!a.isPending}},qN=(e,t,n,r)=>{if(t.fields[r]?.type!==`file`)return;let i=tj(n[r]);if(!i)return;let a=RN(e,i.type);return a?{field:r,file:i,viewer:a}:{field:r,file:i}},JN=({model:e,record:t,viewed:n,back:r})=>{let{file:i,viewer:a}=n;return(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col`,children:[(0,R.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,R.jsxs)(Ik,{to:r,className:z(tu({variant:`ghost`,size:`sm`}),`gap-1.5`),children:[(0,R.jsx)(so,{className:`size-4`,"aria-hidden":`true`}),PN(`backToRecord`)]}),(0,R.jsxs)(`h1`,{className:`min-w-0 flex-1 truncate font-medium`,title:i.name,children:[i.name,i.size!==void 0&&(0,R.jsx)(`span`,{className:`ml-2 text-xs font-normal text-muted-foreground`,children:UD(i.size)})]}),(0,R.jsx)(zN,{file:i})]}),(0,R.jsx)(`div`,{className:`flex-1`,children:a?(0,R.jsx)(YN,{model:e,record:t,file:i,viewer:a}):(0,R.jsx)(XN,{file:i})})]})},YN=({model:e,record:t,file:n,viewer:r})=>{let{siblings:i,ready:a}=KN(e,t,n);if(!a)return(0,R.jsx)(FN,{name:n.name});let o=r.component;return(0,R.jsx)(Nj.Provider,{value:e.name,children:(0,R.jsx)(aC,{name:n.type,fallback:(0,R.jsx)(ZN,{file:n}),children:(0,R.jsx)(o,{file:n,siblings:i})})})},XN=({file:e})=>(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-3 px-4 py-6 md:px-10`,role:`status`,children:[(0,R.jsx)(`p`,{children:PN(`noPreview`,{name:e.name})}),(0,R.jsx)(zN,{file:e})]}),ZN=({file:e})=>(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-3 px-4 py-6 md:px-10`,role:`alert`,children:[(0,R.jsx)(`p`,{children:PN(`couldNotShow`,{name:e.name})}),(0,R.jsx)(zN,{file:e})]}),QN=({field:e,model:t,record:n,name:r,url:i,className:a})=>{let o=hw(),s=e&&t&&n&&t.primaryKey.every(e=>n[e]!=null)?qN(o,t,n,e):void 0;return s?.viewer&&t&&n?(0,R.jsx)(Ik,{to:{kind:`record`,resource:t.name,key:lE(t,n),file:s.field},className:a,children:r}):(0,R.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:a,children:r})},$N=({target:e,id:t,known:n})=>{let r=DN(e,t,n===void 0);return(0,R.jsx)(Ik,{to:{kind:`record`,resource:e.name,key:t},className:`font-medium text-primary-text hover:underline`,children:n??r??t})},eP=({field:e,value:t,known:n})=>{let{resources:r}=ov(),i=e.relation?r[e.relation.resource]:void 0;return i?(0,R.jsx)($N,{target:i,id:String(t),known:n}):(0,R.jsx)(`span`,{children:String(t)})},tP=()=>(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,R.jsx)(`span`,{className:`sr-only`,children:U(`noValue`)})]}),nP=({field:e,value:t,hints:n,relationLabel:r,linkText:i,model:a,record:o})=>{if(t==null||t===``)return(0,R.jsx)(tP,{});if(e.type===`relation`)return(0,R.jsx)(eP,{field:e,value:t,known:r});let s=e.type===`file`?VD(t):void 0;if(s&&`url`in s&&s.url){let n=YD(t,{width:40,height:40});return(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[n&&(0,R.jsx)(jM,{image:n,className:`size-10 shrink-0 rounded border border-border object-cover`}),(0,R.jsx)(QN,{field:e.name,model:a,record:o,name:s.name,url:s.url,className:`truncate font-medium text-primary-text hover:underline`})]})}if(CO(e,n))return(0,R.jsx)(NN,{source:String(t)});if(e.type===`json`)return(0,R.jsx)(UM,{value:t});let c=zO(e,t,n),l=e.type===`text`?TO(n):void 0;return l?(0,R.jsx)(FM,{format:l,value:c,label:i}):e.type===`enum`||n.format===`badge`?(0,R.jsx)(jN,{value:t,hints:n,children:c}):e.type===`timestamp`||e.type===`date`?(0,R.jsx)(`time`,{dateTime:String(t),title:BO(e,t,void 0,n),children:c}):(0,R.jsx)(`span`,{title:BO(e,t,void 0,n),className:z(n.format===`code`&&`font-mono text-xs`,(e.type===`decimal`||e.type===`integer`)&&`tabular-nums`,n.multiline&&`whitespace-pre-line break-words`),children:c})},rP=({model:e,field:t,value:n,format:r,relationLabel:i,record:a,relationLabels:o})=>{let{views:s}=ov(),c={...s[e.name]?.fields[t.name],...r&&{format:r}},l=a&&c.format===`url`?UO(e,s[e.name],t.name,a,o):void 0;return(0,R.jsx)(nP,{field:t,value:n,hints:c,relationLabel:i,linkText:l,model:e,record:a})},iP=e=>{let{views:t}=ov(),n=vN(e.field,t[e.model.name]?.fields[e.field.name]),r=(0,R.jsx)(rP,{...e});return n?(0,R.jsx)(SN,{shown:n,part:`display`,field:e.field,value:e.value,fallback:r}):r},aP=(e,t)=>({model:e,record:t,key:Zn(lE(e,t)),etag:typeof t.etag==`string`?t.etag:void 0,permissions:t.permissions}),oP=(e,t,n=``)=>({queryKey:L.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}}),sP=(e,t=``,n=!0)=>O({...oP(X(),e,t),enabled:n}),cP=(e,t,{filter:n=``,sort:r=``,key:i})=>({queryKey:i===void 0?L.firstRecord(t.name,n,r):L.record(t.name,i),queryFn:async()=>{if(i!==void 0){let n=await e.get(t.name,i);return{...aP(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]?aP(t,a.items[0]):null}}),lP=(e,{enabled:t=!0,...n})=>O({...cP(X(),e,n),enabled:t}),uP=(e,t,{filter:n=``,sort:r=``,pageSize:i,pageToken:a=``})=>({queryKey:L.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})}),dP=(e,{enabled:t=!0,...n})=>O({...uP(X(),e,n),enabled:t,placeholderData:y}),fP=(e,t)=>({isPending:t.isPending,error:t.error,data:t.rows[0]?{...aP(e,t.rows[0]),planned:!0}:t.isPending?void 0:null}),pP=()=>{let e=x();return(0,M.useCallback)(t=>e.invalidateQueries({predicate:e=>Hi(e.queryKey,new Set([t]))}),[e])},mP=(e,t,n)=>{if(!t)return[];let r=Xp(e,t.model.name,n);return r.ok?r.steps:[]},hP=(e,t,n,r,i)=>({queryKey:L.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:L.record(a,String(i)),queryFn:()=>e.get(a,String(i))})).record}return r[i.at(-1).field.name]??null}}),gP=(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}},_P=(e,t)=>{let{resources:n}=ov(),r=mP(n,e,t);return gP(e,r,O(hP(X(),x(),e,t,r)))},vP=e=>{let t=oM(tM(),e),n=_P(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},yP=e=>{let{resources:t}=ov(),n=X(),r=x(),i=e.map(({scope:e,path:n})=>mP(t,e,n)),a=ee({queries:e.map(({scope:e,path:t},a)=>hP(n,r,e,t,i[a]))});return e.map(({scope:e},t)=>gP(e,i[t],a[t]))},bP=e=>e.includes(`.`),xP=({model:e,row:t,column:n})=>{let r=_P(aP(e,Ak(e,t).record),n);return r.state===`loading`?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`…`}):r.state===`missing`?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,R.jsx)(iP,{model:r.model,field:r.field,value:r.value})},SP=(e,t,{resources:n,views:r})=>{let i=Xp(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??F(o),kind:`text`,width:200,render:n=>(0,R.jsx)(xP,{model:e,row:n,column:t})}},CP=(e,t,n,r)=>{let i=new Map(AN(wN(JO(e,t,[],n.filter(e=>!bP(e))),e,t,r.fieldTypes),e,r.resources,r.views).map(e=>[e.id,e]));return n.flatMap(t=>bP(t)?[SP(e,t,r)]:i.get(t)??[])},wP=(e,t,{shown:n,opens:r,bulk:i})=>{if(i)return;let a=[...e.primaryKey,...n.map(e=>e.split(`.`)[0]),...r?[r]:[],Vr(e,t),...uE(e,t)];return[...new Set(a)].filter(t=>Object.hasOwn(e.fields,t))},TP=({model:e,view:t,resources:n,views:r,fieldTypes:i,columns:a,button:o,opens:s,bulk:c,phoneColumns:l,xs:u})=>{let d=CP(e,t,a??hi(e,t),{resources:n,views:r,fieldTypes:i}),f=u&&l?l(d):d,p=Dk(e,t,[...f.map(e=>e.id),...o?Sr(o):[]]);return{specs:f,fields:p,read:wP(e,t,{shown:p,opens:s,bulk:c})}},EP=e=>e.props,DP=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(Dm(e))),i=new Set(jm(r,e=>n.get(e)));return t.filter(e=>i.has(e.id))},OP=(e,t)=>e.orderBy||t||void 0,kP=(e,t)=>e&&t?[...new Set([...e,...t])].sort():void 0,AP={Table:(e,t,n)=>{let{resource:r,columns:i,button:a,bulk:o=!1}=EP(e),s=r===void 0?void 0:n.resources[r];if(!s)return;let c=n.views[s.name],{fields:l,read:u}=TP({...n,model:s,view:c,columns:i?.map(Dm),button:a,bulk:o,phoneColumns:DP(i)}),d=XO(c);return{read:{...t,orderBy:OP(t,ED(s,c)),fields:kP(t.fields,u)},extras:{labels:yM(n.resources,n.views,s,l),...d&&{photos:d}},then:e=>TM(n.queryClient,n.client,n.resources,n.views,s,l,e.rows)}},RecordCards:(e,t,n)=>{let r=n.resources[EP(e).resource];if(r)return{read:{...t,orderBy:OP(t,ED(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}=EP(e),a=n.resources[r];if(a)return{read:t,extras:{labels:yM(n.resources,n.views,a,i===void 0?[]:[i])}}}},jP=(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 AP[e.type]?.(e,t,n)}},MP=new Set([`RecordCard`,`CardRow`,`Stat`,`ReferenceManyField`,`ReferenceArrayField`,`ReferenceField`]),NP=(e,t)=>{let n=Nm(e,t.block);return n?.custom?n.reads!==void 0&&t.part!==`chosen`:t.part===void 0&&n!==void 0&&MP.has(n.type)},PP=(e,t,n)=>(n?.reads??[]).flatMap(r=>{let i=Nm(t,r.block),a=i&&jP(i,r,e);if(!a&&!NP(t,r))return[];let o=eh(a?.read??r,{params:e.params,...e.root&&{root:e.root}}),s=a?.extras??{},c=async()=>{let t=await hM(e.client,o,s);return await a?.then?.(t),t};return[{read:o,queryKey:[...L.planRead(th(r,n),o),s],queryFn:c}]}),FP=(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,IP=(0,M.createContext)(new Map),LP=({tree:e,plan:t,children:n})=>{let r=X(),i=x(),{resources:a,views:o}=ov(),s=hw().fields,c=Wv(),l=dM(),u=nM(tM()),d=(0,M.useMemo)(()=>PP({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)=>[Em(e),{read:e,query:f[t]}]));return(0,R.jsx)(IP.Provider,{value:p,children:n})},RP=(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?nh(a,o.data.rows,{...rM(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}}},zP=e=>BP([e])[0],BP=e=>{let t=(0,M.useContext)(IP),n=tM(),r=dM(),i=(0,M.useRef)([]),a=e.map((e,a)=>FP(i.current[a],RP(t,n,r,e)));return i.current=a,a},VP=(0,M.createContext)(void 0),HP=({node:e,at:t,children:n})=>{let r=(0,M.useMemo)(()=>({node:e,...t!==void 0&&{at:t}}),[e,t]);return(0,R.jsx)(VP.Provider,{value:r,children:n})},UP=(e,t)=>t===void 0?void 0:e.props[t],WP=e=>{let t=(0,M.useContext)(VP);if(!t)throw Error(`${e} is for a custom component in a layout`);return t},GP=()=>{let{node:e,at:t}=WP(`useComponentReads`),n=tM(),r=dM();return KP((0,M.useMemo)(()=>Gm(e,{...rM(n),params:r}),[e,n,r]),t)},KP=(e,t)=>{let{resources:n,views:r}=ov(),i=X(),a=Mm(e).flatMap(({reads:t,part:r})=>{let i=n[String(UP(e,t.resource))];return i?[{reads:t,part:r,model:i}]:[]}),o=BP(t===void 0?[]:a.map(({part:e})=>Em({block:t,part:e}))),s=ee({queries:a.map(({reads:t,model:n},r)=>{let a=bm(UP(e,t.filter))??``,s=ym(UP(e,t.sort))??``,c=UP(e,t.limit),l=typeof c==`number`?c:500;return{enabled:o[r]===void 0,queryKey:L.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}]}))},qP=()=>{let{node:e}=WP(`useComponentSelect`),t=mM(),n=mp(e)?.param;if(n!==void 0&&t)return{chosen:t.given[n],linkTo:e=>t.linkTo({[n]:e})}},JP=({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,R.jsxs)(jN,{value:a,hints:o,children:[(0,R.jsxs)(`span`,{className:`sr-only`,children:[o?.label??n,`: `]}),zO(i,a,o)]})},YP=(e,t)=>{let n=kO(e,t);return n===void 0?{className:Ov[AO(e,t)]}:{style:{backgroundColor:n}}},XP=({view:e,field:t,record:n})=>{let r=YP(e?.fields[t]?.valueColors,n[t]);return(0,R.jsx)(`span`,{"aria-hidden":!0,"data-tone-edge":!0,style:r.style,className:z(`absolute -inset-y-px -left-px w-1 rounded-l-lg`,r.className)})},ZP=(0,M.createContext)(void 0),QP=({value:e,children:t})=>(0,R.jsx)(ZP.Provider,{value:e,children:t}),$P=()=>{let e=(0,M.useContext)(ZP);if(!e)throw Error(`useListDisplay is used inside a list display, which the list page draws`);return e},eF=()=>(0,M.useContext)(ZP),tF=({row:e,resource:t,recordKey:n,...r})=>{let i=eF(),a=eM(),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,R.jsx)(Ik,{to:{kind:`record`,resource:o,key:e?e.key:n},...r})},$=I(`calls`),nF=(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)},rF=({track:e,...t})=>{let n=(0,M.useCallback)(t=>t?nF(t,e):void 0,[e]);return(0,R.jsx)(`video`,{ref:n,autoPlay:!0,playsInline:!0,muted:!0,...t})},iF=({track:e})=>{let t=(0,M.useCallback)(t=>t?nF(t,e):void 0,[e]);return(0,R.jsx)(`audio`,{ref:t,autoPlay:!0})},aF=e=>z(`size-10 rounded-full`,!e&&`bg-danger-soft text-danger-text`),oF=({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,R.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,R.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,R.jsx)(rF,{track:n,"aria-label":$(`preview`),className:`size-full -scale-x-100 object-cover`}):(0,R.jsx)(Dy,{initials:Ay(e),hue:ky(t),size:`md`,className:`size-16 text-xl ring-0`})}),s.length>0&&(0,R.jsx)(`div`,{role:`status`,className:`flex w-full max-w-md flex-col gap-1`,children:s.map(e=>(0,R.jsx)(`p`,{className:`rounded-md bg-warning-soft px-3 py-1.5 text-xs text-foreground`,children:e},e))}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(V,{size:`icon`,"aria-label":$(`microphone`),"aria-pressed":r,disabled:!a,className:aF(r),onClick:c,children:r?(0,R.jsx)(cc,{className:`size-4`}):(0,R.jsx)(oc,{className:`size-4`})}),(0,R.jsx)(V,{size:`icon`,"aria-label":$(`camera`),"aria-pressed":i,disabled:!o,className:aF(i),onClick:l,children:i?(0,R.jsx)(Bl,{className:`size-4`}):(0,R.jsx)(Rl,{className:`size-4`})}),(0,R.jsx)(V,{variant:`primary`,className:`h-10 rounded-full px-5`,onClick:u,children:f}),(0,R.jsx)(pu,{to:d,className:`px-2 text-sm text-muted-foreground hover:text-foreground`,children:$(`leave`)})]})]}),sF=()=>{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-BgwbMyeR.js`);return{GuestRefused:e}},[]);await e().catch(e=>{if(!(e instanceof n))throw e;t(!0)})})()},[]),refused:e}},cF={all:[`camera`,`microphone`,`screen`,`screen-audio`],camera:[`camera`,`microphone`],microphone:[`microphone`]},lF={call:void 0,hour:36e5},uF=({name:e,children:t})=>(0,R.jsxs)(`li`,{className:`flex items-center justify-between gap-2 py-1.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-sm text-foreground`,children:e}),(0,R.jsx)(`span`,{className:`flex shrink-0 gap-1.5`,children:t})]}),dF=({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}=sF(),g=()=>m(async()=>{let e=lF[c],{link:t,token:i}=await n.link({publish:cF[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,R.jsx)(ZT,{title:$(`guests`),description:$(`addressesVisible`),open:i,onClose:a,actions:(0,R.jsx)(V,{onClick:a,children:$(`close`)}),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h&&(0,R.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,R.jsxs)(`section`,{"aria-label":$(`inLobby`),children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:$(`inLobby`)}),(0,R.jsx)(`ul`,{children:e.guests.map(({guest:e,name:t})=>(0,R.jsxs)(uF,{name:t,children:[(0,R.jsx)(V,{size:`sm`,variant:`primary`,onClick:()=>m(()=>n.admit(e)),children:$(`admit`)}),(0,R.jsx)(V,{size:`sm`,onClick:()=>m(()=>n.deny(e)),children:$(`deny`)})]},e))})]}),t.length>0&&(0,R.jsxs)(`section`,{"aria-label":$(`guestsInCall`),children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:$(`guestsInCall`)}),(0,R.jsx)(`ul`,{children:t.map(({guest:e,name:t})=>(0,R.jsx)(uF,{name:t,children:(0,R.jsx)(V,{size:`sm`,variant:`danger`,onClick:()=>m(()=>n.remove(e)),children:$(`remove`)})},e))})]}),(0,R.jsxs)(`section`,{"aria-label":$(`guestLinks`),className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:$(`guestLinks`)}),e.links.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:$(`noLinks`)}),(0,R.jsx)(`ul`,{children:e.links.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-1.5`,children:[u?.id===e.id&&(0,R.jsx)(qy,{readOnly:!0,value:u.url,"aria-label":$(`copyLink`),onFocus:e=>e.currentTarget.select(),trailing:(0,R.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,R.jsx)(Io,{className:`size-4 text-success`}):(0,R.jsx)(ns,{className:`size-4`})})}),(0,R.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,R.jsx)(V,{size:`sm`,onClick:()=>m(()=>n.revoke(e.id)),children:$(`revoke`)})]})]},e.id))}),(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[$(`guestsMaySend`),(0,R.jsx)(fb,{label:$(`guestsMaySend`),value:o,onChange:s,options:[{value:`all`,label:$(`sendAll`)},{value:`camera`,label:$(`sendCamera`)},{value:`microphone`,label:$(`sendMicrophone`)}]})]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[$(`linkLasts`),(0,R.jsx)(fb,{label:$(`linkLasts`),value:c,onChange:l,options:[{value:`call`,label:$(`linkUntilEnd`)},{value:`hour`,label:$(`forAnHour`)}]})]}),(0,R.jsx)(V,{variant:`primary`,onClick:g,children:$(`newLink`)})]})]})]})})},fF=({waiting:e,guests:t})=>{let{run:n,refused:r}=sF(),i=e[0];return i?(0,R.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,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r?$(`guestRefused`):$(`waitingGuest`,{name:i.name})}),(0,R.jsx)(V,{size:`sm`,variant:`primary`,onClick:()=>n(()=>t.admit(i.guest)),children:$(`admit`)}),(0,R.jsx)(V,{size:`sm`,onClick:()=>n(()=>t.deny(i.guest)),children:$(`deny`)})]}):null},pF={ended:`ended`,removed:`removed`,full:`full`,refused:`refused`,unavailable:`unavailable`,denied:`denied`},mF=({reason:e,onJoinAgain:t})=>(0,R.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,R.jsx)(`p`,{className:`text-sm text-foreground`,children:$(e===`rejoin`?`ended`:pF[e])}),t&&e!==`removed`&&e!==`refused`&&e!==`denied`&&(0,R.jsx)(V,{onClick:t,children:$(`callAgain`)})]}),hF=(e,t)=>t<640?e<=2?1:2:Math.min(4,Math.ceil(Math.sqrt(e))),gF=({people:e,sharers:t,width:n})=>t[0]===void 0?e<=1?{kind:`alone`}:{kind:`grid`,columns:hF(e,n)}:{kind:`share`,sharer:t[0]},_F=({roundTripMs:e,lostRatio:t})=>(e??0)>400||(t??0)>.05?`poor`:`good`,vF=(e,t,n)=>e===`failed`||e!==`connected`&&n-t>=15e3,yF=(e,t=.05)=>{let n;for(let[r,i]of e)i>=t&&(!n||i>n[1])&&(n=[r,i]);return n?.[0]},bF=(e,t)=>e.find(e=>e.source===t&&e.track),xF=({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=>bF(d,e)),g=o.find(t=>t.member===e),_=vF(g?.state,s.get(e)??c,c)?`failed`:g?.state===`connected`?_F(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:_}}}),SF=e=>z(`size-10 rounded-full`,!e&&`bg-danger-soft text-danger-text`),CF=({microphoneOn:e,cameraOn:t,sharing:n,onMicrophone:r,onCamera:i,onShare:a,guests:o,leave:s})=>(0,R.jsxs)(`div`,{role:`toolbar`,"aria-label":$(`joinCall`),className:`flex shrink-0 flex-wrap items-center justify-center gap-2 py-2`,children:[(0,R.jsx)(V,{size:`icon`,"aria-label":$(`microphone`),"aria-pressed":e,title:$(`microphone`),className:SF(e),onClick:r,children:e?(0,R.jsx)(cc,{className:`size-4`}):(0,R.jsx)(oc,{className:`size-4`})}),(0,R.jsx)(V,{size:`icon`,"aria-label":$(`camera`),"aria-pressed":t,title:$(`camera`),className:SF(t),onClick:i,children:t?(0,R.jsx)(Bl,{className:`size-4`}):(0,R.jsx)(Rl,{className:`size-4`})}),a&&(0,R.jsx)(V,{size:`icon`,"aria-label":$(n?`stopSharing`:`shareScreen`),"aria-pressed":!!n,title:$(n?`stopSharing`:`shareScreen`),className:`size-10 rounded-full`,onClick:a,children:n?(0,R.jsx)(mc,{className:`size-4`}):(0,R.jsx)(fc,{className:`size-4`})}),o&&(0,R.jsxs)(V,{size:`icon`,"aria-label":$(`guests`),title:$(`guests`),className:`relative size-10 rounded-full`,onClick:o.onOpen,children:[(0,R.jsx)(Al,{className:`size-4`}),(0,R.jsx)(Gb,{count:o.waiting,className:`absolute -top-1 -right-1`})]}),(0,R.jsxs)(pu,{to:s,className:z(tu({variant:`danger`}),`h-10 rounded-full px-4`),children:[(0,R.jsx)(Oc,{className:`size-4`}),$(`leave`)]})]}),wF=({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,R.jsxs)(`figure`,{"data-member":e.member,"data-speaking":e.speaking?`true`:void 0,"aria-label":i,className:z(`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,R.jsx)(rF,{track:r,className:z(`size-full`,t?`object-contain`:`object-cover`,e.self&&!t&&`-scale-x-100`)}):(0,R.jsx)(Dy,{initials:Ay(e.name),hue:ky(e.member),size:`md`,className:`size-16 text-xl ring-0`}),e.connection===`failed`&&!e.self&&(0,R.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,R.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,R.jsx)(oc,{role:`img`,"aria-label":$(`muted`),className:`size-3 shrink-0`}),!t&&e.connection===`poor`&&(0,R.jsx)(Kl,{role:`img`,"aria-label":$(`poorConnection`),className:`size-3 shrink-0 text-warning`}),(0,R.jsx)(`span`,{className:`truncate`,children:i})]})]})},TF=()=>{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}},EF=4,DF=({people:e,columns:t})=>(0,R.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,R.jsx)(wF,{person:e},e.member))}),OF=({people:e,sharer:t,narrow:n})=>{let r=e.slice(0,EF),i=e.length-r.length;return(0,R.jsxs)(`div`,{className:z(`flex size-full min-h-0 gap-2`,n?`flex-col`:`flex-row`),children:[(0,R.jsx)(wF,{person:t,screen:!0,className:`min-h-0 flex-1`}),(0,R.jsxs)(`div`,{className:z(`flex shrink-0 gap-2`,n?`h-20 flex-row`:`w-40 flex-col`),children:[r.map(e=>(0,R.jsx)(wF,{person:e,className:n?`aspect-video h-full`:`aspect-video w-full`},e.member)),i>0&&(0,R.jsxs)(`p`,{className:`flex items-center justify-center rounded-lg bg-muted px-2 text-xs text-muted-foreground`,children:[`+`,i]})]})]})},kF=({layout:e,people:t,narrow:n})=>e.kind===`share`?(0,R.jsx)(OF,{people:t,sharer:t.find(t=>t.member===e.sharer),narrow:n}):e.kind===`grid`?(0,R.jsx)(DF,{people:t,columns:e.columns}):(0,R.jsxs)(`div`,{className:`relative size-full min-h-0`,children:[(0,R.jsx)(wF,{person:t[0],className:`size-full`}),(0,R.jsx)(`p`,{className:`absolute inset-x-0 top-3 text-center text-sm text-white drop-shadow`,children:$(`alone`)})]}),AF=({people:e,state:t,notices:n=[],controls:r,aside:i,children:a,className:o})=>{let{ref:s,width:c}=TF(),l=c>0&&c<640,u=gF({people:e.length,sharers:e.filter(e=>e.screen).map(e=>e.member),width:c}),d=[...t===`resuming`?[$(`reconnecting`)]:[],...n];return(0,R.jsxs)(`section`,{ref:s,"aria-label":$(`joinCall`),"data-layout":u.kind,className:z(`flex size-full min-h-0 flex-col gap-2 bg-background p-2`,o),children:[d.length>0&&(0,R.jsx)(`div`,{role:`status`,className:`flex shrink-0 flex-col gap-1`,children:d.map(e=>(0,R.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,R.jsx)(Ql,{className:`size-3`}),e]},e))}),i,(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:t===`joining`?(0,R.jsxs)(`p`,{role:`status`,className:`flex size-full items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Ql,{className:`size-4`}),$(`connecting`)]}):(0,R.jsx)(kF,{layout:u,people:e,narrow:l})}),(0,R.jsx)(CF,{...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,R.jsx)(iF,{track:t},e)),a]})},jF=({leave:e})=>(0,R.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,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,R.jsx)(Ql,{className:`size-4`}),$(`waiting`)]}),(0,R.jsx)(pu,{to:e,className:`px-2 text-sm text-muted-foreground hover:text-foreground`,children:$(`leave`)})]}),MF=200,NF=1e3,PF=(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)},FF=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=yF(new Map([...r].map(([e,t])=>[e,PF(t,i)])));e&&(a={member:e,at:Date.now()}),n(a&&Date.now()-a.at<NF?a.member:void 0)},MF);return()=>{clearInterval(o),t.close()}},[r]),t},IF=new Set([`NotAllowedError`,`SecurityError`]),LF=new Set([`NotFoundError`,`NotReadableError`,`OverconstrainedError`]),RF=async(e,t)=>{try{return{track:(await e.getUserMedia({[t]:!0})).getTracks()[0],blocked:!1}}catch(e){if(!(e instanceof DOMException))throw e;if(IF.has(e.name))return{blocked:!0};if(LF.has(e.name))return{blocked:!1};throw e}},zF=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)||!(IF.has(e.name)||LF.has(e.name)))throw e}let[t,n]=[await RF(e,`audio`),await RF(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}},BF=class extends Error{reason;constructor(e){super(`Not let into the call: ${e}`),this.reason=e,this.name=`NotLetIn`}},VF=1e3,HF=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>(clearTimeout(r),n()),{once:!0})}),UF=async(e,t,n,r)=>{let{LobbyRefused:i}=await s(async()=>{let{LobbyRefused:e}=await import(`./calls-BgwbMyeR.js`);return{LobbyRefused:e}},[]),a=e=>e instanceof i?new BF(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 BF(`denied`);if(t.state===`ended`)throw new BF(`ended`);await HF(VF,r)}throw await e.leave(o),new BF(`ended`)},WF=2e3,GF=e=>{for(let t of e)t?.stop()},KF=(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=zF().then(t=>{if(e){GF([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,GF(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),WF);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 BF))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-BgwbMyeR.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),GF([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]),j=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,...j&&{toggleScreen:re}}},qF=(e,t)=>[...e?.blocked.microphone?[$(`noMicrophone`)]:[],...e?.blocked.camera?[$(`noCamera`)]:[],...e?.none?[$(`noDevices`)]:[],...t?[$(`refused`)]:[]],JF=({url:e,leave:t,nameOf:n=e=>e,admission:r,name:i,className:a})=>{let o=KF(e,{...r&&{admission:r}}),[s,c]=(0,M.useState)(!1),{basePath:l}=Ou(),u=Jg(),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=FF(h.kind===`in`?_:new Map),y=qF(m,o.refusedSending);if(h.kind===`left`)return(0,R.jsx)(mF,{reason:h.reason,onJoinAgain:()=>void o.join()});if(h.kind===`waiting`)return(0,R.jsx)(jF,{leave:t});if(h.kind===`check`)return(0,R.jsx)(oF,{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=xF({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,R.jsx)(AF,{...a&&{className:a},people:C,state:h.kind===`joining`?`joining`:h.resuming?`resuming`:`joined`,notices:y,...b&&x&&{aside:(0,R.jsx)(fF,{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,R.jsx)(dF,{lobby:b,inCall:S,guests:x,linkOf:e=>AC(`${window.location.origin}${l}`,e),open:s,onClose:()=>c(!1)})})},YF=(e,t)=>{let{address:n,href:r,open:i}=Fk(),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}))}},XF=({resource:e,recordKey:t,...n})=>{let{joining:r,leave:i}=YF(e,t);return r?(0,R.jsx)(JF,{leave:i,...n},`${e}/${t}`):null},ZF=(e,t)=>{let n=X(),r=x(),i=L.recordCalls(e,t),a=O({queryKey:i,queryFn:()=>n.calls(e,t)});return(0,M.useEffect)(()=>{let i=L.recordCalls(e,t),a=n.channel(e,t),o=a.on(xi,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)}},QF=({resource:e,recordKey:t,className:n})=>{let{ongoing:r,isPending:i}=ZF(e,t),{joining:a,join:o}=YF(e,t);if(i)return null;if(!r)return a?null:(0,R.jsxs)(pu,{to:o,className:z(tu({size:`sm`}),n),children:[(0,R.jsx)(Ac,{className:`size-3.5`}),$(`startCall`)]});let s=r.members.length;return(0,R.jsxs)(`span`,{role:`status`,className:z(`inline-flex items-center gap-1.5 rounded-md bg-success-soft px-2 py-0.5 text-body text-foreground`,n),children:[(0,R.jsx)(Ac,{className:`size-3.5 text-success`}),$(`inProgress`),(0,R.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,R.jsx)(`span`,{"aria-label":$(`people`,{count:s}),children:s}),!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,R.jsx)(pu,{to:o,className:tu({variant:`primary`,size:`sm`}),children:$(`join`)})]})]})},$F={wallet:Hl,"file-text":Os,send:el,ruler:Jc,bed:vo,bath:go,house:Ps,"door-open":cs,"land-plot":Rs,leaf:Hs,tag:bl,key:Is,calendar:Mo,heart:Ms,history:Wc,bell:wo,bookmark:Oo,"external-link":vs,ban:mo,play:Mc,stop:fl,power:Rc,restart:Kc,terminal:wl,camera:Po,"hard-drive":As,server:nl,network:bc,archive:ao,copy:ns,"arrow-right-left":lo,download:us,upload:Ol,cpu:is,memory:nc,plug:Pc,wrench:Jl,plus:Ic,table:vl},eI=e=>e!==void 0&&Object.hasOwn($F,e)?$F[e]:void 0,tI=({benefits:e})=>e&&e.length>0?(0,R.jsx)(`ul`,{className:`flex flex-col gap-2 text-left`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(Io,{className:`mt-0.5 size-4 shrink-0 text-primary`,"aria-hidden":!0}),e]},e))}):null,nI=({prompt:e})=>{let{canSignUp:t}=J(),{link:n}=BS(),r=tu({variant:`primary`}),i=e.signUp?(0,R.jsx)(`a`,{href:e.signUp.href,target:`_blank`,rel:`noreferrer`,className:r,children:e.signUp.label}):t&&(0,R.jsx)(pu,{to:n(`sign-up`),className:r,children:Z(`createAnAccount`)});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(pu,{to:n(),className:i?tu():r,children:Z(`signIn`)}),i]})},rI=e=>{let{prompt:t}=e,n=(0,M.useId)();if(e.as===`dialog`)return(0,R.jsx)(ZT,{title:t.title,description:t.description,open:e.open,onClose:e.onClose,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:e.onClose,children:Z(`notNow`)}),(0,R.jsx)(nI,{prompt:t})]}),children:(0,R.jsx)(tI,{benefits:t.benefits})});let r=eI(t.icon)??Xs;return(0,R.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,R.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,R.jsx)(r,{className:`size-6`,"aria-hidden":!0})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`h1`,{id:n,className:`text-lg font-semibold`,children:t.title}),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:t.description})]}),(0,R.jsx)(tI,{benefits:t.benefits}),(0,R.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,R.jsx)(nI,{prompt:t})})]})},iI=I(`chat`),aI=e=>new Date(Date.parse(`${e}T00:00:00Z`)-864e5).toISOString().slice(0,10),oI=(e,t,n=Qw())=>iT(Date.parse(e),n)===iT(Date.parse(t),n),sI=(e,t=Date.now(),n=Qw())=>{let r=iT(Date.parse(e),n),i=iT(t,n);return r===i?iI(`today`):r===aI(i)?iI(`yesterday`):CT(Date.parse(`${r}T00:00:00Z`))},cI=({tone:e=`day`,label:t})=>{let n=t??iI(`newMessages`),r=z(`h-px flex-1`,e===`new`?`bg-danger`:`bg-border`);return(0,R.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,R.jsx)(`span`,{className:r}),(0,R.jsx)(`span`,{className:e===`new`?`text-danger`:`text-muted-foreground`,children:n}),(0,R.jsx)(`span`,{className:r})]})},lI=({children:e,className:t})=>(0,R.jsx)(`p`,{className:z(`text-xs text-muted-foreground`,t),children:e}),uI=({time:e})=>{let t=Date.parse(e);return(0,R.jsx)(`time`,{dateTime:e,title:vT(t),className:`text-xs text-muted-foreground`,children:TT(t)})},dI=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,R.jsxs)(`div`,{"data-from":`person`,className:z(`flex min-w-0 gap-3`,o&&`-mt-3`),children:[(0,R.jsx)(`div`,{className:`w-8 shrink-0`,children:!o&&(a??(0,R.jsx)(Dy,{initials:Ay(s)||`?`,hue:ky(r.id),size:`md`,className:`ring-0`}))}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[!o&&(0,R.jsxs)(`p`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:s}),i&&(0,R.jsx)(uI,{time:i})]}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 whitespace-pre-wrap break-words text-foreground`,children:t}),n&&(0,R.jsx)(lI,{children:n})]})]})}if(e.alone){let{time:r,continued:i}=e;return(0,R.jsxs)(`div`,{"data-from":`person`,className:z(`flex min-w-0 flex-col gap-0.5`,i&&`-mt-3`),children:[!i&&r&&(0,R.jsx)(uI,{time:r}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 whitespace-pre-wrap break-words text-foreground`,children:t}),n&&(0,R.jsx)(lI,{children:n})]})}let r=(0,R.jsx)(`div`,{"data-from":e.from,className:z(`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,R.jsxs)(`div`,{className:z(`flex min-w-0 flex-col gap-1`,e.from===`user`&&`items-end`),children:[r,(0,R.jsx)(lI,{className:e.from===`user`?`text-right`:void 0,children:n})]}):r},fI=({working:e})=>(0,R.jsx)(`div`,{role:`status`,className:`shrink-0 pl-11`,children:e&&(0,R.jsxs)(`p`,{"data-chat-working":!0,className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`flex gap-1`,children:[0,200,400].map(e=>(0,R.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))}),iI(`working`)]})}),pI=e=>e.scrollHeight-e.scrollTop-e.clientHeight<=24,mI=(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},hI=(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:pI(e),first:t.firstElementChild??void 0,followKey:n,...a}},gI=(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},_I=e=>e.querySelector(`[data-chat-divider][data-tone="new"]`),vI=({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=hI(c.current,l.current,a))},f=()=>u.current.atEnd&&u.current.first!==void 0,p=gI(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=_I(l.current),i=r?r.getBoundingClientRect().top-e.getBoundingClientRect().top:void 0,o=mI(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,R.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,R.jsx)(V,{size:`sm`,className:`self-center`,loading:i,onClick:r,children:iI(`loadEarlier`)}),h&&(0,R.jsx)(`div`,{className:`m-auto max-w-60 text-center text-muted-foreground`,children:t}),(0,R.jsx)(`div`,{ref:l,role:`log`,"aria-live":`polite`,className:z(`flex flex-col gap-4`,h&&`hidden`),children:e}),s!==void 0&&(0,R.jsx)(fI,{working:s})]})},yI=(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}},bI=(e,t)=>{let n=/(?:^|\s)@([^\s@]*)$/.exec(e.slice(0,t));return n?{start:t-n[1].length-1,query:n[1]}:void 0},xI=(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(` `)}},SI=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),CI=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(SI).join(`|`)})(?![\\p{L}\\p{N}_])`,`gu`)},wI=(e,t)=>{let n=CI(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))]},TI=(e,t)=>{let n=CI(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},EI=I(`mentions`),DI=({id:e,optionId:t,people:n,active:r,onActive:i,onPick:a,failed:o,at:s})=>(0,R.jsxs)(`ul`,{id:e,role:`listbox`,"aria-label":EI(`peopleToMention`),className:z(`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,R.jsx)(`li`,{id:t(n),role:`option`,"aria-selected":n===r,className:z(`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,R.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:EI(o?`couldNotSearch`:`noOneFound`)})]}),OI=(e,t)=>{let n=bE(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},kI={text:``,picked:[]},AI=8,jI=({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?bI(e.text,l):void 0,S=d&&x!==void 0&&x.start!==h,C=OI(n,S?x.query:void 0),w=S&&C&&`people`in C?C.people.slice(0,AI):[],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=xI(e.text,x,n.name);y.current=r.caret,t({text:r.text,picked:[...e.picked,n]})},k=e=>{if(S){let t=yI(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,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(zM,{...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,R.jsx)(DI,{id:b,optionId:E,people:w,active:p,onActive:m,onPick:O,failed:`failed`in C,at:r})]})},MI=({text:e,mentions:t})=>(0,R.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:TI(e,t).map((e,t)=>`mention`in e?(0,R.jsxs)(`span`,{className:`font-medium text-primary`,children:[`@`,e.mention]},t):e.text)}),NI=e=>e.types.includes(`Files`),PI=e=>e.types.includes(`text/plain`)?[]:[...e.files],FI=(e,{busy:t,canSendEmpty:n})=>t?!1:e!==``||n===!0,II=({onSend:e,busy:t,placeholder:n,inputRef:r,searchPeople:i,attachments:a,actions:o,canSendEmpty:s,onFiles:c})=>{let[l,u]=(0,M.useState)(kI),d=l.text.trim(),f=FI(d,{busy:t,canSendEmpty:s}),p=()=>{if(!f)return;let t=e?.(d,wI(d,l.picked));if(!(t instanceof Promise)){u(kI);return}t.then(e=>{e&&u(e=>e.text.trim()===d?kI:e)})};return(0,R.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),p()},onDragOver:e=>{c&&NI(e.dataTransfer)&&e.preventDefault()},onDrop:e=>{c&&NI(e.dataTransfer)&&(e.preventDefault(),c([...e.dataTransfer.files]))},children:[a&&(0,R.jsx)(`div`,{className:`basis-full`,children:a}),o,(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(jI,{ref:r,rows:1,"aria-label":iI(`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=PI(e.clipboardData);t.length!==0&&(e.preventDefault(),c(t))}})}),(0,R.jsx)(V,{type:`submit`,variant:`primary`,className:`w-8 px-0`,"aria-label":iI(`send`),disabled:!f,children:(0,R.jsx)(Qc,{className:`size-4`})})]})},LI=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},RI=I(`side-panel`),zI=({title:e,icon:t,status:n,onClose:r,footer:i,children:a})=>{let o=LI(!Uv());return(0,R.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,R.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-background px-4`,children:[t,(0,R.jsx)(`h2`,{className:`flex-1 font-semibold`,children:e}),n&&(0,R.jsx)(`span`,{className:`truncate text-xs font-medium text-muted-foreground`,children:n}),r&&(0,R.jsx)(V,{variant:`ghost`,size:`sm`,className:`w-7 px-0`,"aria-label":RI(`close`),onClick:r,children:(0,R.jsx)(Xl,{className:`size-4`})})]}),a,i&&(0,R.jsx)(`footer`,{className:`shrink-0 space-y-2 border-t border-border bg-background p-3`,children:i})]})},BI=I(`action-card`),VI={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`}},HI=({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,R.jsxs)(`section`,{"aria-label":e,className:s?`whitespace-normal text-foreground`:z(`shrink-0 overflow-hidden rounded-lg border bg-background whitespace-normal text-foreground shadow-sm`,VI[t].border),children:[!s&&(0,R.jsxs)(`header`,{className:z(`flex items-center gap-2 px-3 py-2`,VI[t].header),children:[(0,R.jsx)(`h3`,{className:`min-w-0 flex-1 font-semibold`,children:e}),n&&(0,R.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:n})]}),(o||r||i.length>0)&&(0,R.jsxs)(`div`,{className:z(`space-y-2.5`,!s&&`px-3 py-2.5`),children:[o,r&&(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}),i.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-0.5`,children:i.map(e=>(0,R.jsx)(V,{size:`sm`,variant:e.style??`secondary`,className:z(e.style===`primary`&&`flex-1`),disabled:e.disabled,onClick:()=>d(e),children:e.label},e.id))}),u.map(e=>(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e))]}),c&&(0,R.jsx)(su,{title:`${c.label}?`,description:c.confirm,onClose:()=>l(void 0),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:()=>l(void 0),children:BI(`cancel`)}),(0,R.jsx)(V,{variant:c.style===`danger`?`danger`:`primary`,onClick:()=>{l(void 0),a?.(c.id)},children:c.label})]})})]})},UI=({fields:e})=>(0,R.jsx)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-body`,children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:`contents`,children:[(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,R.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.value})]},`${t}-${e.label}`))}),WI=e=>e==null?`null`:typeof e==`object`?JSON.stringify(e):String(e),GI=I(`compact-table`),KI=({columns:e,rows:t,caption:n,truncated:r,className:i})=>(0,R.jsxs)(`section`,{"aria-label":n??GI(`table`),className:z(`shrink-0 overflow-hidden rounded-lg border border-border-strong bg-background shadow-sm`,i),children:[n&&(0,R.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,R.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:GI(`noRows`)}):(0,R.jsx)(`div`,{className:`max-h-64 overflow-auto`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-left text-[0.6875rem]`,children:[(0,R.jsx)(`thead`,{className:`sticky top-0 bg-background`,children:(0,R.jsx)(`tr`,{children:e.map(e=>(0,R.jsx)(`th`,{scope:`col`,className:`border-b border-border px-2 py-1 font-semibold whitespace-nowrap`,children:e},e))})}),(0,R.jsx)(`tbody`,{children:t.map((e,t)=>(0,R.jsx)(`tr`,{className:`border-b border-border last:border-b-0`,children:e.map((e,t)=>(0,R.jsx)(`td`,{className:z(`px-2 py-1 whitespace-nowrap`,e===null&&`text-faint-foreground`),children:WI(e)},t))},t))})]})}),(0,R.jsxs)(`footer`,{className:`border-t border-border px-3 py-1.5 text-[0.6875rem] text-muted-foreground`,children:[GI(`rows`,{count:t.length}),r&&GI(`cutOff`)]})]}),qI=(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++})},JI=e=>({added:e.filter(e=>e.kind===`add`).length,removed:e.filter(e=>e.kind===`del`).length}),YI=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},XI={add:`bg-success-soft text-success-text`,del:`bg-danger-soft text-danger-text`,ctx:`text-muted-foreground`,hunk:`bg-surface text-faint-foreground`},ZI={add:`+`,del:`−`,ctx:``,hunk:``},QI=`bg-background py-1 font-mono text-[0.6875rem] leading-[18px]`,$I=({line:e})=>(0,R.jsxs)(`div`,{className:z(`flex min-w-0`,e?XI[e.kind]:`bg-surface`),children:[(0,R.jsx)(`span`,{className:`w-8 shrink-0 select-none pr-2 text-right opacity-60`,children:e?.newNo??e?.oldNo}),(0,R.jsx)(`span`,{className:`w-3 shrink-0 select-none`,children:e&&ZI[e.kind]}),(0,R.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words pr-3`,children:e?.text})]}),eL=({line:e})=>(0,R.jsx)($I,{line:e&&e.kind===`ctx`?{...e,newNo:void 0}:e}),tL=({lines:e,className:t})=>(0,R.jsx)(`pre`,{className:z(`overflow-x-auto`,QI,t),children:e.map((e,t)=>(0,R.jsx)($I,{line:e},t))}),nL=({lines:e,className:t})=>(0,R.jsx)(`pre`,{className:z(`grid-cols-2`,QI,t),children:YI(e).map((e,t)=>e.kind===`hunk`?(0,R.jsx)(`div`,{className:z(`col-span-2 px-3`,XI.hunk),children:e.text},t):(0,R.jsxs)(`div`,{className:`contents`,children:[(0,R.jsx)(eL,{line:e.old}),(0,R.jsx)($I,{line:e.new})]},t))}),rL=({source:e,start:t,path:n,split:r,className:i})=>{let a=typeof e==`string`?qI(e,t):e,o=JI(a);return(0,R.jsxs)(`div`,{className:z(`overflow-hidden`,i),children:[n&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border bg-surface px-3 py-1.5`,children:[(0,R.jsx)(Es,{className:`size-3.5 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.6875rem] text-foreground`,children:n}),(0,R.jsxs)(`span`,{className:`text-[0.6875rem] font-medium text-success-text`,children:[`+`,o.added]}),o.removed>0&&(0,R.jsxs)(`span`,{className:`text-[0.6875rem] font-medium text-danger-text`,children:[`−`,o.removed]})]}),a.length>0&&!r&&(0,R.jsx)(tL,{lines:a}),a.length>0&&r&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(tL,{lines:a,className:`md:hidden`}),(0,R.jsx)(nL,{lines:a,className:`hidden md:grid`})]})]})},iL={a:7,b:8,t:9,n:10,v:11,f:12,r:13,'"':34,"\\":92},aL=new TextEncoder,oL=new TextDecoder,sL=e=>{if(!e.startsWith(`"`))return;let t=[],n=1;for(;n<e.length;){let r=String.fromCodePoint(e.codePointAt(n));if(r===`"`)return{path:oL.decode(new Uint8Array(t)),rest:e.slice(n+1)};if(r!==`\\`){t.push(...aL.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=iL[e[n+1]??``];if(a===void 0)return;t.push(a),n+=2}},cL=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,lL=/^(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 )/,uL=e=>{let t=sL(e.slice(4)),n=t?t.path:e.slice(4).split(` `)[0];if(n!==`/dev/null`)return n.replace(/^[ab]\//,``)},dL=(e,t)=>{let n=sL(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)}},fL=e=>{if(!e.startsWith(`diff --git `))return;let t=e.slice(11),n=sL(t);if(n)return n.rest.startsWith(` `)?dL(n.path,n.rest.slice(1)):void 0;let r=t.indexOf(` "b/`);if(r!==-1)return dL(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&&dL(...a)},pL=(e,t)=>{let n=t.find(t=>e.startsWith(t));if(n===void 0)return;let r=e.slice(n.length);return sL(r)?.path??r},mL=(e,t)=>fL(e[t])!==void 0||e[t].startsWith(`--- `)&&e[t+1]?.startsWith(`+++ `)===!0,hL=e=>{let t=e.replace(/\r\n/g,`
32
+ `).split(`
33
+ `);t.at(-1)===``&&t.pop();let n=0;for(;n<t.length&&!mL(t,n);)n++;let r=[],i;for(;n<t.length;){let e=t[n],a=r.at(-1);if(e===`-- `)break;let o=fL(e);if(o!==void 0){r.push({path:o.new,lines:[]}),i=o,n++;continue}if(e.startsWith(`--- `)&&t[n+1]?.startsWith(`+++ `)){let a=uL(e),o=uL(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&&lL.test(e)){let t=pL(e,[`rename from `,`copy from `]),r=pL(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=cL.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},gL={pending:(0,R.jsx)(Qo,{className:`size-3 text-faint-foreground`}),running:(0,R.jsx)(Ql,{className:`size-3.5 text-primary`}),done:(0,R.jsx)(Io,{className:`size-3.5 text-success`,strokeWidth:2.5}),failed:(0,R.jsx)(Xl,{className:`size-3.5 text-danger`,strokeWidth:2.5})},_L={pending:`text-muted-foreground`,running:`text-foreground`,done:`text-muted-foreground`,failed:`text-danger-text`},vL=({steps:e,className:t})=>(0,R.jsx)(`ul`,{className:z(`shrink-0 space-y-2`,t),children:e.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex items-start gap-2.5`,"data-state":e.state,children:[(0,R.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 items-center justify-center`,children:gL[e.state]}),(0,R.jsx)(`span`,{className:_L[e.state],children:e.label})]},`${t}-${e.label}`))}),yL=I(`assistant-dock`),bL=({part:e,note:t})=>e.fallback?(0,R.jsx)(HI,{title:e.fallback.title,note:t,children:e.fallback.body&&(0,R.jsx)(`p`,{children:e.fallback.body})}):(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`${e.name}: ${t}`}),xL=class extends M.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){Qh(e,t.componentStack)}render(){return this.state.failed?(0,R.jsx)(bL,{part:this.props.part,note:yL(`couldNotDraw`)}):this.props.children}},SL=({part:e})=>{let{components:t={}}=hw(),n=Object.hasOwn(t,e.name)?t[e.name]:void 0;return n?(0,R.jsx)(xL,{part:e,children:(0,R.jsx)(n,{...e.props})}):(0,R.jsx)(bL,{part:e,note:yL(`cannotShowLive`)})},CL=({part:e,onAction:t})=>{switch(e.type){case`text`:return(0,R.jsx)(`p`,{children:e.text});case`table`:return(0,R.jsx)(KI,{columns:e.columns,rows:e.rows,caption:e.caption,truncated:e.truncated});case`card`:return(0,R.jsxs)(HI,{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,R.jsx)(`p`,{children:e.body}),e.code&&(0,R.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,R.jsx)(UI,{fields:e.fields}),e.steps&&e.steps.length>0&&(0,R.jsx)(vL,{steps:e.steps}),e.diffs?.map((e,t)=>(0,R.jsx)(rL,{source:e.source,start:e.start,path:e.path,className:`rounded-md border border-border`},`${t}-${e.path}`))]});case`widget`:return(0,R.jsx)(SL,{part:e})}},wL=(0,M.createContext)(void 0),TL=e=>e instanceof Error?e:Error(yL(`backendNoAnswer`)),EL=(e,t)=>typeof e==`function`?e(t):e,DL=(e,{refreshMs:t=!1}={})=>{let n=(0,M.useContext)(wL),[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:TL(e)}));if(!t)return;c.current=o.data,i(o);let l=EL(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:TL(e)}));c.current=a.data,i(a)}}},OL=({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,R.jsx)(zI,{title:yL(`assistant`),icon:(0,R.jsx)(ul,{className:`size-4 text-primary`}),status:t?yL(`reconnecting`):e.status,onClose:a,footer:(0,R.jsxs)(R.Fragment,{children:[n&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body text-danger-text`,children:n}),(0,R.jsx)(II,{inputRef:s,onSend:r,busy:e.replying,placeholder:e.placeholder??yL(`askQuestion`)})]}),children:(0,R.jsx)(wL.Provider,{value:o,children:(0,R.jsx)(vI,{length:e.messages.reduce((e,t)=>e+t.parts.length,0),empty:yL(`empty`),children:e.messages.map(e=>(0,R.jsx)(dI,{from:e.from,children:e.parts.map(e=>(0,R.jsx)(CL,{part:e,onAction:i},e.id))},e.id))})})})},kL=e=>e instanceof Error?e.message:yL(`noAnswer`),AL=e=>{let[t,n]=(0,M.useState)(Dr),[r,i]=(0,M.useState)(!1),[a,o]=(0,M.useState)();(0,M.useEffect)(()=>{if(e)return e.connect(e=>n(t=>Ar(t,e)),e=>i(e.state===`retrying`))},[e]);let s=e=>{o(void 0),e.catch(e=>o(kL(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))}},jL=e=>{let t=yC(),n=(0,M.useRef)(t);n.current=t;let r=t!==void 0;return(0,M.useMemo)(()=>r?Bh({url:e,token:()=>n.current}):void 0,[e,r])},ML=`flex w-full items-center gap-2 px-3 py-2.5 text-left hover:bg-muted disabled:cursor-default disabled:opacity-60`,NL=I(`record-view`),PL=({actions:e,label:t=NL(`actions`),className:n})=>{let{open:r,setOpen:i,place:a,button:o,menu:s}=Gw();return e.length===0?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{ref:o,type:`button`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":r,onClick:()=>i(!r),className:n,children:(0,R.jsx)(ms,{className:`size-5`})}),(0,R.jsx)(Db,{open:r,title:t,onClose:()=>i(!1),menu:(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(t,{className:z(`size-4 shrink-0`,o===`danger`?`text-danger-text`:`text-muted-foreground`),"aria-hidden":!0}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:z(`block font-medium`,o===`danger`&&`text-danger-text`),children:e}),r&&(0,R.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:r})]})]});return(0,R.jsx)(`li`,{role:`none`,onClick:()=>i(!1),children:s&&!r?s({className:ML,children:c,role:`menuitem`}):(0,R.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:n,disabled:!!r||a,title:r,className:ML,children:c})},e)})})})]})},FL=(0,M.createContext)(void 0),IL=()=>{let e=(0,M.useContext)(FL);if(!e)throw Error(`A focus part is used outside a FocusPage`);return e},LL=()=>{let e=(0,M.useContext)(FL);return e&&{size:e.size}},RL=I(`focus-page`),zL=2,BL=({action:e})=>{let t=e.icon,n=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),e.name]});return e.render&&!e.blocked?e.render({className:tu(),children:n}):(0,R.jsx)(V,{variant:e.tone===`danger`?`danger`:`secondary`,onClick:()=>!e.blocked&&e.onRun?.(),"aria-disabled":!!e.blocked,loading:e.running,title:e.blocked,children:n})},VL=(e,t)=>t===`wide`||t===`medium`?e.filter(e=>e.inBar).slice(0,zL):[],HL=()=>{let{store:e,size:t}=IL();return VL((0,M.useSyncExternalStore)(e.subscribe,e.actions),t).map(e=>(0,R.jsx)(BL,{action:e},e.name))},UL=()=>{let{store:e,size:t}=IL(),n=(0,M.useSyncExternalStore)(e.subscribe,e.actions),r=ux(),i=Uv(),a=VL(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,R.jsx)(PL,{actions:s,label:RL(`more`),className:ib}),r):(0,R.jsx)(PL,{actions:s,label:RL(`more`),className:tu({size:`icon`})})},WL=e=>e>=1100?`wide`:e>=950?`medium`:e>=720?`narrow`:`compact`,GL=(e,t=1)=>e>0&&t>0&&e-t*380<480,KL=[`refused`,`conflict`,`draft`,`info`],qL=e=>KL.indexOf(e),JL=()=>{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])=>qL(e)-qL(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()})}},YL=()=>{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]},XL=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],ZL=`flex min-w-0 shrink-0 items-center gap-2 empty:hidden`,QL=({label:e,children:t})=>{xy(!1);let[n]=(0,M.useState)(JL),[r,i]=(0,M.useState)({}),a=XL(i),[o,s]=YL(),[c,l]=YL(),u=WL(s),d=GL(l,(0,M.useSyncExternalStore)(n.subscribe,n.openPanels)),f=(0,M.useMemo)(()=>({store:n,hosts:r,size:u}),[n,r,u]);return(0,R.jsx)(FL.Provider,{value:f,children:(0,R.jsxs)(`section`,{"aria-label":e,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`h1`,{className:`sr-only`,children:e}),(0,R.jsxs)(`div`,{ref:o,role:`group`,"aria-label":RL(`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,R.jsx)(`div`,{ref:a.mode,className:z(ZL,`shrink`)}),(0,R.jsx)(`div`,{ref:a.controls,className:ZL}),(0,R.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,R.jsx)(`div`,{ref:a.state,className:z(ZL,`shrink text-xs text-muted-foreground`)}),(0,R.jsx)(HL,{}),(0,R.jsx)(`div`,{ref:a.secondary,className:ZL}),(0,R.jsx)(`div`,{ref:a.primary,className:ZL}),(0,R.jsx)(UL,{})]}),(0,R.jsx)(`div`,{ref:a.notice,className:`shrink-0 empty:hidden`}),(0,R.jsxs)(`div`,{ref:c,className:`relative flex min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{ref:a.start,className:z(`h-full shrink-0 empty:hidden`,d&&`absolute inset-y-0 left-0 z-10 shadow-pop`)}),(0,R.jsx)(`div`,{className:`relative isolate min-h-0 min-w-0 flex-1`,children:t}),(0,R.jsx)(`div`,{ref:a.end,className:z(`h-full shrink-0 empty:hidden`,d&&`absolute inset-y-0 right-0 z-10 shadow-pop`)})]})]})})},$L=({zone:e,fallback:t=!1,children:n})=>{let{store:r,hosts:i}=IL();(0,M.useLayoutEffect)(()=>t?void 0:r.fill(e),[r,e,t]);let a=eR(e),o=i[e];return o&&!(t&&a)?(0,N.createPortal)(n,o):null},eR=e=>{let{store:t}=IL();return(0,M.useSyncExternalStore)(t.subscribe,()=>t.filled(e))},tR=({actions:e})=>{let{store:t}=IL(),n=(0,M.useId)();return(0,M.useLayoutEffect)(()=>t.setActions(n,e)),(0,M.useEffect)(()=>()=>t.setActions(n,void 0),[t,n]),null},nR={refused:`bg-danger-soft`,conflict:`bg-warning-soft`,draft:`bg-surface`,info:`bg-surface`},rR=({level:e,actions:t,children:n})=>{let{store:r,hosts:i}=IL(),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,R.jsxs)(`div`,{role:e===`refused`||e===`conflict`?`alert`:`status`,className:z(`flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-3 py-2 text-body`,nR[e]),children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1 basis-48`,children:n}),t&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t})]}),s)},iR=({side:e=`end`,title:t,icon:n,status:r,onClose:i,footer:a,takesFocus:o=!1,children:s})=>{let{hosts:c,store:l}=IL(),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,R.jsx)(zI,{title:t,icon:n,status:r,onClose:i,footer:a,children:(0,R.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},aR=(0,M.createContext)(void 0),oR=()=>(0,M.useContext)(aR),sR=(e,t)=>t.every(t=>e.includes(t)),cR=(e,t)=>sR([e.title,e.description??``,...e.keywords??[]].join(` `).toLowerCase(),t),lR=(e,t)=>sR(e.title.toLowerCase(),t),uR=(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=>cR(e,n));return t.length>0?[{...e,items:[...t.filter(e=>lR(e,n)),...t.filter(e=>!lR(e,n))]}]:[]}),i=e=>lR(e.items[0],n);return[...r.filter(i),...r.filter(e=>!i(e))]},dR=I(`search-picker`),fR=({groups:e,label:t=dR(`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)(()=>uR(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,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(qy,{ref:c,type:`search`,role:`combobox`,"aria-label":t,"aria-expanded":!0,"aria-controls":l,"aria-activedescendant":f&&p(f),placeholder:t,leading:(0,R.jsx)(Xc,{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,R.jsx)(`div`,{id:l,role:`listbox`,"aria-label":t,className:`flex flex-col gap-3`,children:u.map(e=>(0,R.jsxs)(`div`,{role:`group`,"aria-label":e.title,children:[(0,R.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,R.jsxs)(`div`,{id:p(e),role:`option`,"aria-selected":e===f,className:z(`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,R.jsx)(t,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`block font-medium`,children:e.title}),e.description&&(0,R.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description})]})]},e.id)})]},e.title))}),d.length===0&&(0,R.jsx)(`p`,{className:`px-2 text-body text-muted-foreground`,children:dR(`nothing`,{query:i.trim()})})]})},pR=I(`carousel`),mR=`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`,hR=`[@media(hover:none)]:opacity-100`,gR=({carousel:e,count:t,swipe:n,reveal:r,className:i})=>{if(t<2)return null;let{index:a,press:o}=e;return(0,R.jsxs)(`div`,{className:z(`group/arrows pointer-events-none absolute`,i),children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":pR(`previousPhoto`),className:z(mR,r,!n&&hR,`left-2`),onClick:()=>o(-1),children:(0,R.jsx)(Bo,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(`button`,{type:`button`,"aria-label":pR(`nextPhoto`),className:z(mR,r,!n&&hR,`right-2`),onClick:()=>o(1),children:(0,R.jsx)(Ho,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsxs)(`span`,{className:`absolute inset-x-0 bottom-2 flex justify-center`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:pR(`photoOf`,{index:a+1,count:t})}),(0,R.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,R.jsx)(`span`,{className:z(`size-1.5 rounded-full`,t===a?`bg-foreground`:`bg-foreground/35`)},t))})]})]})},_R={width:640,height:480},vR=e=>e.flatMap(e=>{if(`src`in e)return[{image:{url:e.src},alt:e.alt}];let t=YD(e,_R);return t?[{image:t,alt:e.alt??``}]:[]}),yR=({carousel:e,swipe:t,slides:n,className:r,...i})=>(0,R.jsx)(`span`,{...i,ref:e.track,tabIndex:-1,onPointerDown:e.touch,onScroll:t=>e.scrolled(t.currentTarget),className:z(`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,R.jsx)(`span`,{className:`block size-full shrink-0 snap-start snap-always`,children:e},t))}),bR=(e,t)=>t===0?0:(e%t+t)%t,xR=(e,t,n)=>t<=0||n===0?0:Math.min(n-1,Math.max(0,Math.round(e/t))),SR=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=bR((n.current??r)+t,e),a(n.current)},touch:()=>{n.current=void 0},scrolled:t=>{i(xR(t.scrollLeft,t.clientWidth,e)),n.current!==void 0&&Math.abs(t.scrollLeft-n.current*t.clientWidth)<1&&(n.current=void 0)}}},CR=({images:e,label:t,fit:n=`cover`,swipe:r=!0,className:i})=>{let a=vR(e),o=SR(a.length);return(0,R.jsxs)(`div`,{role:`group`,"aria-roledescription":`carousel`,"aria-label":t,className:z(`group/carousel relative overflow-hidden`,i),children:[(0,R.jsx)(yR,{"data-carousel-track":!0,carousel:o,swipe:r,slides:a.map(({image:e,alt:t})=>(0,R.jsx)(jM,{image:e,alt:t,loading:`lazy`,className:z(`size-full`,n===`cover`?`object-cover`:`object-contain`)}))}),(0,R.jsx)(gR,{carousel:o,count:a.length,swipe:r,reveal:`group-hover/carousel:opacity-100`,className:`inset-0`})]})},wR=500,TR=(e=window)=>e.top!==e.self,ER=(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)}},DR=()=>{let e=!1;return{down:(t,n=!1)=>{e=t&&!n},take:()=>{let t=e;return e=!1,t}}},OR=(e,t)=>n=>n?e(!0):t(()=>e(!1)),kR=e=>{let[t,n]=(0,M.useState)(!1);return(0,M.useEffect)(()=>ER(document,e,OR(n,N.flushSync)),[e]),t},AR=(e,t)=>{let n=(0,M.useRef)(DR());return{onPointerDown:()=>n.current.down(e),onKeyDown:t=>n.current.down(e,t.repeat),onClick:()=>{n.current.take()&&t()}}},jR=({invalid:e,className:t,children:n,...r})=>{let i=Ky();return(0,R.jsx)(`select`,{...i,...e&&{"aria-invalid":!0},className:z(`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})},MR=({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=Zy(a,s,u),f=eb(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,R.jsxs)(`div`,{ref:s,className:`relative shrink-0`,children:[(0,R.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,R.jsx)(m.icon,{className:`size-3.5`}),m?.label??i,(0,R.jsx)(Ro,{className:`size-3.5 text-muted-foreground`})]}),(0,R.jsx)(Db,{open:a,title:i,onClose:()=>o(!1),inPlaceOnDesktop:!0,menu:(0,R.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=yI(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:z(`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,R.jsxs)(R.Fragment,{children:[t.icon?(0,R.jsx)(t.icon,{className:`size-3.5`}):(0,R.jsx)(`span`,{className:`size-3.5`}),(0,R.jsx)(`span`,{className:`flex-1`,children:t.label}),t.value===e&&(0,R.jsx)(Io,{className:`size-3.5 text-primary-text`})]});return(0,R.jsx)(`li`,{role:`none`,children:r?(0,R.jsx)(pu,{...a,to:r(t.value),onClick:h,children:o}):(0,R.jsx)(`button`,{...a,type:`button`,onClick:()=>{h(),t.value!==e&&n(t.value)},children:o})},t.value)})})})]})},NR=({name:e,label:t,options:n,value:r,onChange:i})=>(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":t,className:`flex flex-col gap-2`,children:n.map(t=>(0,R.jsxs)(`label`,{className:z(`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,R.jsx)(`input`,{type:`radio`,name:e,value:t.value,checked:t.value===r,disabled:t.disabled,onChange:()=>i(t.value),className:`sr-only`}),(0,R.jsx)(`span`,{className:z(`block font-medium`,t.value===r&&`text-primary-text`),children:t.label}),t.description&&(0,R.jsx)(`span`,{className:`mt-0.5 block text-xs leading-snug text-muted-foreground`,children:t.description})]},t.value))}),PR=({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,R.jsxs)(`div`,{className:s?`sm:col-span-2`:void 0,children:[(0,R.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[c?(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:t}):(0,R.jsxs)(`label`,{htmlFor:u,className:`font-medium text-foreground`,children:[t,n&&(0,R.jsx)(`span`,{className:`ml-0.5 text-danger-text`,"aria-hidden":`true`,children:`*`})]}),o&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-warning-text`,title:NL(`savedDifferent`,{name:o.user.name}),children:[(0,R.jsx)(El,{className:`size-3.5`}),(0,R.jsx)(Dy,{initials:o.user.initials,hue:o.user.hue,size:`xs`})]})]}),(0,R.jsx)(Gy,{value:{id:u,name:e,describedBy:d,invalid:!!a,required:!!n},children:l}),r&&(0,R.jsx)(`p`,{id:`${u}-help`,className:`mt-1.5 text-xs text-muted-foreground`,children:r}),i&&(0,R.jsxs)(`p`,{id:`${u}-example`,className:`mt-0.5 text-xs text-faint-foreground`,children:[NL(`example`),` `,i]}),a&&(0,R.jsx)(`p`,{id:`${u}-error`,className:`mt-1.5 text-body font-medium text-danger-text`,children:a}),o&&(0,R.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,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:o.user.name}),` `,NL(`savedThis`,{ago:o.ago}),` `,(0,R.jsx)(`strong`,{children:o.theirValue})]}),(0,R.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,R.jsx)(V,{size:`sm`,onClick:o.onKeepMine,children:NL(`keepMine`)}),(0,R.jsx)(V,{size:`sm`,onClick:o.onUseTheirs,children:NL(`useTheirs`)})]})]})]})},FR=(0,M.createContext)(0),IR=()=>(0,M.useContext)(FR),LR={2:`h2`,3:`h3`,4:`h4`,5:`h5`,6:`h6`},RR=()=>Math.min(Math.max(IR(),1)+1,6),zR=({title:e,help:t,actions:n,count:r,level:i,children:a})=>{let o=RR(),s=i??o,c=LR[s],l=e?(0,R.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,R.jsx)(FR.Provider,{value:s,children:a}):a;return(0,R.jsxs)(R.Fragment,{children:[n?(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[l??(0,R.jsx)(`span`,{}),n]}):l,t&&(0,R.jsx)(`p`,{className:`mt-1 max-w-xl leading-6 text-muted-foreground`,children:t}),u?(0,R.jsx)(`div`,{className:`mt-5`,children:d}):d]})},BR=({title:e,help:t,actions:n,count:r,level:i,children:a})=>(0,R.jsx)(`section`,{className:`py-8 first:pt-8`,children:(0,R.jsx)(zR,{title:e,help:t,actions:n,count:r,level:i,children:a})}),VR=({title:e,eyebrow:t,width:n,submit:r,saving:i,disabled:a,error:o,errorTitle:s=Lx(`notSaved`),onSubmit:c,onCancel:l,children:u,ref:d})=>{let f=(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l&&(0,R.jsx)(V,{className:`max-sm:min-h-11`,onClick:l,children:Lx(`cancel`)}),(0,R.jsx)(V,{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,R.jsx)(`div`,{className:`mt-4`,children:(0,R.jsx)(Vj,{title:s,error:o})}),m=(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:u}),h=e=>{e.preventDefault(),c()};return e===void 0?(0,R.jsxs)(`form`,{ref:d,className:`max-w-[760px]`,onSubmit:h,children:[p,m,(0,R.jsx)(`footer`,{className:`border-t pt-6 sm:flex sm:justify-end`,children:f})]}):(0,R.jsx)(`form`,{ref:d,className:`flex-1`,onSubmit:h,children:(0,R.jsxs)(`div`,{className:z(n!==`full`&&`mx-auto max-w-[760px]`,`px-4 py-6 md:px-10 md:py-8`),children:[(0,R.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,R.jsxs)(`div`,{children:[t&&(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),(0,R.jsx)(`h1`,{className:`mt-1 text-2xl font-semibold tracking-tight`,children:e})]}),f]}),p,m]})})},HR=({checked:e,onChange:t,label:n})=>{let r=Ky();return(0,R.jsx)(`button`,{type:`button`,role:`switch`,id:r.id,"aria-describedby":r[`aria-describedby`],"aria-checked":e,"aria-label":n,onClick:()=>t?.(!e),className:z(`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors`,e?`bg-primary`:`bg-border-strong`),children:(0,R.jsx)(`span`,{className:z(`size-4 rounded-full bg-white shadow transition-transform`,e?`translate-x-[18px]`:`translate-x-0.5`)})})},UR=({target:e,view:t,value:n,label:r,chosen:i=[n],several:a=!1,invalid:o,onChange:s})=>{let c=dN(),l=e.primaryKey[0],u=Br(e,t),[d,f]=(0,M.useState)(!1),p=mE(),m=tN(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]),_=WA(e.name,{filter:m.filter,fields:h,enabled:c.open}),v=m.filter!==void 0&&_.error instanceof Sd&&_.error.slug===`expensive-query`;(0,M.useEffect)(()=>{v&&f(!0)},[v]);let y=m.local?_.items.filter(e=>nN(g(e),c.text)):_.items,{fetchNextPage:b}=_,x=(0,M.useCallback)(()=>b({cancelRefetch:!1}),[b]);return(0,R.jsx)(pN,{search:c,options:y.map(e=>({key:String(e[l]),label:g(e)})),chosen:i,several:a,closedText:r??n,placeholder:U(`searchPlural`,{plural:(t?.names?.plural??F(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)})},WR=(e=Ai())=>new Intl.NumberFormat(e).formatToParts(1.5).find(e=>e.type===`decimal`)?.value===`,`?`,`:`.`,GR=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),KR=(e,t)=>{let n=`[${GR(t===`.`?`,`:`.`)}\\s\\u00a0\\u202f']`,r=RegExp(`^([-+]?)(\\d{1,3}(?:${n}\\d{3})+|\\d+)(?:${GR(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()))},qR=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),JR=new Set([`text`,`integer`,`bigint`,`decimal`,`date`,`currency`,`country`]),YR=new Set([`uuid`,`timestamp`,`relation`]),XR=(e,t)=>e.readOnly||YR.has(e.type)?!1:e.type!==`json`||t?.widget!==void 0,ZR=e=>!e.readOnly&&!e.nullable&&e.type!==`boolean`,QR=new Set([`integer`,`bigint`,`decimal`]),$R=e=>{try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return e;throw t}},ez=(e,t)=>KR(e,t)??e,tz=(e,t,n=WR())=>{if(e.type===`boolean`)return!!t;if(e.type===`file`)return ZD(t);let r=String(t).trim();if(r===``)return e.nullable?null:``;let i=QR.has(e.type)?ez(r,n):r;if(e.type===`integer`)return Number(i);if(e.type===`relation`)return typeof t==`number`?t:i;if(JR.has(e.type)||e.type===`enum`)return i;if(e.type===`json`)return $R(i);throw Error(`Not implemented: editing ${e.type} fields`)},nz=(e,t,n=WR())=>e.type===`boolean`?!!t:String(t??``).trim()===``?null:tz(e,t,n),rz=(e,t)=>e.type===`boolean`?!!t:qR(t),iz=(e,t,n,r=WR())=>{if(e.type===`boolean`)return!!t!=!!n;if(e.type===`file`)return QD(t,n);let i=String(t??``).trim(),a=qR(n);return e.type===`decimal`||e.type===`integer`?i===``||a===``?i!==a:Number(ez(i,r))!==Number(a):i!==a},az=`••••••••••`,oz=e=>wd(e)&&e.slug===`strong-sign-in-required`?e.problem.minutes??15:void 0,sz=({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=qR(n)!==``,f=t?.label??F(e.name),p=(0,R.jsx)(V,{variant:`ghost`,size:`sm`,className:`-mr-1.5 px-1.5`,"aria-label":U(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,R.jsx)(bs,{className:`size-3.5`}):(0,R.jsx)(Ss,{className:`size-3.5`}))}),m=oz(u.error),h=m===void 0?u.error&&(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(Vj,{title:U(`couldNotShow`,{label:f}),error:u.error})}):(0,R.jsx)(cS,{minutes:m,onConfirmed:()=>u.mutate()});if(i)return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,R.jsx)(`span`,{className:z(c?t?.format===`code`?`font-mono text-xs`:``:`tracking-widest text-muted-foreground`),children:c?zO(e,u.data,t):az}),r&&p]}),h]});let g=d?qR(n):c&&u.isSuccess?qR(u.data):``;return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(qy,{type:c?`text`:`password`,autoComplete:`off`,invalid:a,"aria-label":f,className:z(t?.format===`code`&&`font-mono text-xs`),placeholder:d||!r?o??(e.writeOnly?U(`setNewValue`):void 0):az,value:g,trailing:p,onChange:e=>s(e.target.value)}),h]})},cz=({value:e})=>{let t=YD(e,{width:40,height:40});return t?(0,R.jsx)(jM,{image:t,className:`size-10 shrink-0 rounded border border-border object-cover`}):(0,R.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded border border-border bg-muted text-muted-foreground`,children:(0,R.jsx)(Os,{className:`size-4`})})},lz=({value:e,field:t,resource:n,record:r})=>{let i=(0,M.useContext)(D_)?.resources[n],a=VD(e);if(!a)return(0,R.jsx)(`div`,{className:`py-1.5 text-muted-foreground`,children:`—`});if(`missing`in a)return(0,R.jsx)(`div`,{className:`py-1.5 text-danger-text`,children:U(`fileMissing`)});let o=`url`in a?a.url:void 0,s=`corrected`in a?a.corrected:void 0;return(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 py-1`,children:[(0,R.jsx)(cz,{value:e}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[o&&!o.startsWith(`blob:`)?(0,R.jsx)(QN,{field:t,model:i,record:BD(e)?void 0:r,name:a.name,url:o,className:`block truncate font-medium text-primary-text hover:underline`}):(0,R.jsx)(`span`,{className:`block truncate font-medium`,children:a.name}),(0,R.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[a.type,a.size!==void 0&&` · ${UD(a.size)}`,s&&` · sent as ${s.from}`]})]})]})},uz=({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??F(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,...WD(r.file.type)&&{preview:URL.createObjectURL(t)}}},onSuccess:e=>s(e),onSettled:()=>d(void 0)});if(a||e.readOnly)return(0,R.jsx)(lz,{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,R.jsx)(`input`,{ref:l,type:`file`,hidden:!0,accept:XD(e),"aria-label":U(`chooseFileFor`,{label:m}),onChange:e=>g(e.target.files)}),y=h.error&&(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(Vj,{title:U(`notUploaded`),error:h.error})});return h.isPending?(0,R.jsxs)(`div`,{className:`py-1.5`,role:`status`,"aria-label":U(`uploadingLabel`,{label:m}),children:[(0,R.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,R.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${Math.round((u??0)*100)}%`}})}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:U(`uploading`,{percent:Math.round((u??0)*100)})})]}):VD(i)?(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(lz,{value:i,field:e.name,resource:n,record:r})}),(0,R.jsx)(V,{size:`sm`,onClick:()=>l.current?.click(),children:U(`replace`)}),e.nullable&&(0,R.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>s(null),children:U(`remove`)})]}),v,y]}):(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),p(!0)},onDragLeave:()=>p(!1),onDrop:_,className:z(`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,R.jsx)(Ol,{className:`size-4 shrink-0`}),(0,R.jsx)(`span`,{className:`flex-1`,children:U(`dropFile`)}),(0,R.jsxs)(V,{size:`sm`,onClick:()=>l.current?.click(),children:[(0,R.jsx)(wc,{className:`size-3.5`}),U(`chooseFile`)]})]}),v,y]})},dz=I(`markdown`),fz=()=>[{value:`write`,label:dz(`write`)},{value:`preview`,label:dz(`preview`)}],pz=({value:e,onChange:t,label:n,invalid:r,placeholder:i})=>{let[a,o]=(0,M.useState)(`write`);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:`self-start`,children:(0,R.jsx)(fb,{value:a,options:fz(),onChange:o,label:n})}),a===`write`?(0,R.jsx)(zM,{rows:5,invalid:r,placeholder:i,value:e,onChange:e=>t(e.target.value)}):(0,R.jsx)(`div`,{className:`min-h-[7.5rem] rounded-md border border-border px-2.5 py-1.5`,children:e.trim()===``?(0,R.jsx)(`span`,{className:`text-faint-foreground`,children:dz(`nothingToPreview`)}):(0,R.jsx)(NN,{source:e})})]})},mz=new Set([`integer`,`bigint`,`decimal`]),hz=e=>e===`integer`||e===`bigint`?{inputMode:`numeric`,enterKeyHint:`done`}:e===`decimal`?{inputMode:`decimal`,enterKeyHint:`done`}:{},gz=e=>typeof e==`object`&&e&&`key`in e?e.key:e,_z=(e,t,n,r,i)=>t?.confirm!==void 0&&!iz(e,n,r)&&iz(e,gz(i),r),vz=I(`app/change-confirm`),yz=e=>e instanceof Element&&e.closest(`[data-dialog="change-confirm"]`)!==null,bz=({field:e,hints:t,value:n,stored:r,onChange:i})=>{let[a,o]=(0,M.useState)(),s=a=>{_z(e,t,n,r,a)?o({next:a}):i(a)},c=()=>o(void 0);return{onChange:s,dialog:a&&(0,R.jsx)(su,{name:`change-confirm`,title:vz(`title`,{label:t?.label??F(e.name)}),description:t?.confirm,onClose:c,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:c,children:vz(`cancel`)}),(0,R.jsx)(V,{variant:`primary`,onClick:()=>{o(void 0),i(a.next)},children:vz(`change`)})]})})}},xz=({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,R.jsx)(uz,{field:e,hints:t,resource:d??``,record:f,value:n,locked:c||!d,invalid:s,onChange:m});if(e.sensitive)return(0,R.jsx)(sz,{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,R.jsx)(UR,{target:o.target,view:o.view,value:String(n),label:i,invalid:s,onChange:(e,t)=>m({key:e,label:t})});return a?(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),(0,R.jsx)(Ik,{to:a,"aria-label":U(`openLabel`,{label:i??String(n)}),title:U(`open`),className:z(tu({variant:`ghost`}),`w-8 px-0`),children:(0,R.jsx)(fo,{className:`size-4`})})]}):e}if(e.type===`relation`){if(r==null||r===``)return(0,R.jsx)(`div`,{className:`py-1.5`,children:(0,R.jsx)(nP,{field:e,value:r,hints:t??{}})});let n=i??String(r);return(0,R.jsx)(`div`,{className:`py-1.5`,children:a?(0,R.jsx)(Ik,{to:a,className:`font-medium text-primary-text hover:underline`,children:n}):n})}if(!XR(e)||c)return(0,R.jsx)(`div`,{className:`min-w-0 break-words py-1.5 text-foreground`,children:(0,R.jsx)(nP,{field:e,value:r,hints:t??{},linkText:p})});if(e.type===`boolean`)return(0,R.jsx)(HR,{checked:!!n,onChange:m,label:t?.label??F(e.name)});let h=!!t?.multiline&&e.type===`text`;return CO(e,t)?(0,R.jsx)(pz,{label:t?.label??F(e.name),invalid:s,placeholder:l,value:String(n),onChange:m}):e.type===`enum`?(0,R.jsxs)(jR,{invalid:s,value:String(n),onChange:e=>m(e.target.value),children:[n===``&&(0,R.jsx)(`option`,{value:``,children:U(`choose`)}),(e.enumValues??[]).map(e=>(0,R.jsx)(`option`,{value:e,children:Lr(e,t?.valueLabels)},e))]}):h?(0,R.jsx)(zM,{invalid:s,placeholder:l,value:String(n),onChange:e=>m(e.target.value)}):(0,R.jsx)(qy,{invalid:s,leading:t?.prefix?(0,R.jsx)(`span`,{children:t.prefix}):void 0,trailing:t?.suffix?(0,R.jsx)(`span`,{children:t.suffix.trim()}):void 0,placeholder:l,className:z(mz.has(e.type)&&`text-right tabular-nums`),...hz(e.type),...DO(e.type===`text`?TO(t):void 0),value:String(n),onChange:e=>m(e.target.value)})},Sz=(e,t,n,r)=>e.sensitive||e.type===`file`?!1:n||e.readOnly?!0:e.type===`relation`?!r:!XR(e,t),Cz=e=>{let{field:t,hints:n,value:r,stored:i,invalid:a,locked:o,onChange:s}=e,c=vN(t,n),l=(0,R.jsx)(xz,{...e});return c?o||!XR(t,n)?(0,R.jsx)(SN,{shown:c,part:`display`,field:t,value:i,fallback:l}):t.type===`file`||t.type===`relation`?l:(0,R.jsx)(SN,{shown:c,part:`editor`,field:t,value:nz(t,r),invalid:!!a,onChange:e=>s(rz(t,e)),fallback:l}):l},wz=e=>{let t=bz(e);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Cz,{...e,onChange:t.onChange}),t.dialog]})},Tz=I(`app/field`),Ez=(e,t)=>typeof e?.[t]==`number`?e[t]:void 0,Dz=(e,t)=>{let n=Ez(t,`min`),r=Ez(t,`max`);if(n!==void 0)return Tz(`atLeastCharacters`,{label:e,count:bD(n),n});if(r!==void 0)return Tz(`atMostCharacters`,{label:e,count:bD(r),n:r})},Oz=e=>{let t=Ez(e,`min`),n=Ez(e,`max`);return t===void 0?n===void 0?Tz(`wholeNumber`):Tz(`wholeNumberAtMost`,{max:bD(n)}):Tz(`wholeNumberAtLeast`,{min:bD(t)})},kz=e=>{let t=Ez(e,`precision`),n=Ez(e,`scale`);if(t===void 0||n===void 0)return Tz(`number`);let r=bD(10**(t-n));return n===0?Tz(`wholeNumberBelow`,{below:r}):Tz(`decimalsBelow`,{scale:n,below:r})},Az={text:Dz,integer:(e,t)=>Oz(t),bigint:()=>Tz(`wholeNumber`),decimal:(e,t)=>kz(t),date:()=>Tz(`date`),timestamp:()=>Tz(`timestamp`),country:()=>Tz(`country`),currency:()=>Tz(`currency`),uuid:()=>Tz(`uuid`),enum:()=>Tz(`enum`),relation:()=>Tz(`relation`),json:()=>Tz(`json`)},jz=(e,t,n)=>n.code===`required`?Tz(`required`,{label:t}):n.code!==`invalid-value`||!e?n.message:Az[e.type]?.(t,n.params)??n.message,Mz=e=>{if(!wd(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},Nz=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?Tz(`checkField`):Tz(`checkFields`,{count:t.size})],...n].join(` `)},Pz=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},Fz=I(`app/record`),Iz=2e3,Lz=Symbol(`nothing saved`),Rz=(e,t)=>{let n=ZC(),[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:Fz(`savingSubject`,{subject:t})}):void 0;o(void 0),e===`button`&&i(`saving`);try{return await r()===Lz?(a!==void 0&&n.dismiss(a),e===`button`&&i(`idle`),!0):(a!==void 0&&n.update(a,{state:`success`,title:Fz(`subjectSaved`,{subject:t})}),e===`button`&&(i(`saved`),s.current=setTimeout(()=>i(`idle`),Iz)),!0)}catch(t){if(!wd(t))throw t;let r=t.status===412?Fz(`changedBySomeoneElse`):Fz(`couldNotSave`),s=Nz(t);return a!==void 0&&n.update(a,{state:`error`,title:r,description:s}),e===`button`&&(i(`idle`),o(`${r}: ${s}`)),!1}}}},zz=(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},Bz=(e,t,n)=>(e??t?.helpWhen??`always`)===`always`||n,Vz=(e,t,n)=>e?.help!==void 0&&Bz(e.helpWhen,t,n)?e.help:void 0,Hz=(e,t)=>e===`editing`?t:e!==`reading`||!t,Uz=e=>typeof e==`object`&&!!e&&`key`in e,Wz=(e,t,n)=>t.name!==e.tenant&&!t.readOnly&&!n?.notOnCreate&&(t.type===`relation`||XR(t,n)),Gz=(e,t)=>{let n=Object.values(e.fields).filter(n=>Wz(e,n,t?.fields[n.name])).map(e=>e.name),r=new Set,i=In(t?.layout??[]).flatMap(e=>{if(e.kind!==`section`||Bu(e.when)||!Hz(e.when,!0))return[];let i=e.fields.filter(e=>n.includes(e)&&!r.has(e)&&Hz(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?Lx(`details`):Lx(`otherFields`),fields:a}]},Kz=(e,t)=>(e?.primaryKey.length===1?e.fields[e.primaryKey[0]]?.type:void 0)===`integer`?Number(t):t,qz=(e,t,n)=>Object.fromEntries(Object.entries(n).flatMap(([n,r])=>{let i=e.fields[n];return i?Uz(r)?[[n,Kz(t[i.relation?.resource??``],r.key)]]:i.type===`boolean`?[[n,!!r]]:i.type===`file`?r?[[n,tz(i,r)]]:[]:String(r).trim()===``?[]:[[n,tz(i,r)]]:[]})),Jz=e=>!e.nullable&&!e.default&&e.type!==`boolean`,Yz=(e,t)=>e.type===`relation`?{key:t,label:t}:e.type===`boolean`?t===`true`:t,Xz=new Set([`integer`,`bigint`,`decimal`]),Zz=e=>{if(!Xz.has(e.type)||!e.default||!(`value`in e.default))return;let t=e.default.value;return t==null?void 0:String(t)},Qz=(e,t,n={})=>Object.fromEntries(t.flatMap(t=>t.fields.flatMap(t=>{let r=e.fields[t];if(Object.hasOwn(n,t))return[[t,Yz(r,n[t])]];let i=r.default;return Zz(r)!==void 0||!i||!(`value`in i)||i.value===null||i.value===void 0?[]:[[t,typeof i.value==`boolean`?i.value:qR(i.value)]]}))),$z=e=>!!(e.default&&`db`in e.default),eB=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),tB=({resource:e,values:t,onCreated:n,feedback:r})=>{let i=ov(),a=i.resources[e],o=i.views[e],s=X(),c=x(),{fields:l}=hw(),u=o?.names?.singular??F(e),d=Rz(r??o?.saveFeedback??`toast`,Lx(`subject`,{noun:u})),f=Gz(a,o),[p,m]=(0,M.useState)(()=>Qz(a,f,t)),[h,g]=(0,M.useState)({}),[_,v]=(0,M.useState)(0),y=Pz(_),[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&&_M(c,s,t,[n],i.views[t.name]).then(t=>{let r=t.get(n);r&&m(t=>Uz(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=>eB(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,{...qz(a,i.resources,p),...t})}catch(t){let r=wd(t)?t.existing:void 0;if(r)return n(void 0,{kind:`record`,resource:e,key:r.key}),Lz;let i=Mz(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:lE(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??F(e),c=h[e];return{name:e,label:s,help:o?.fields[e]?.help,required:Jz(t),error:c&&jz(t,s,c),wide:yN(l,t,o?.fields[e]),editor:(0,R.jsx)(wz,{field:t,hints:o?.fields[e],value:Uz(n)?n.key:n??(t.type!==`boolean`&&``),stored:void 0,relationLabel:Uz(n)?n.label:void 0,placeholder:$z(t)?Lx(`setByDatabase`):Zz(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}},nB=({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,R.jsxs)(`form`,{ref:e.ref,className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),i?i():e.submit()},children:[e.message&&(0,R.jsx)(Vj,{title:Lx(`notCreated`),error:Error(e.message)}),a,o.map(e=>(0,R.jsx)(PR,{name:e.name,label:e.label,required:e.required,help:e.help,error:e.error,wide:e.wide,children:e.editor},e.name)),(0,R.jsx)(V,{variant:`primary`,type:`submit`,className:`max-md:min-h-11`,loading:e.saving,disabled:r,children:n})]})},rB=(e,t,n)=>{let r=X(),i=x(),a=[...new Set(n)].sort();return O({queryKey:L.pickedLabels(e.name,a.join(`,`)),enabled:a.length>0,placeholderData:y,queryFn:()=>_M(i,r,e,a,t)}).data??new Map},iB=e=>{let{resources:t,views:n}=ov(),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=rB(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,R.jsx)(UR,{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,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(UR,{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,R.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.map(e=>(0,R.jsx)(uN,{label:l(e),onRemove:()=>f(d.filter(t=>t!==e))},e))})]})};export{tR as $,cS as $a,xr as $c,wT as $i,pM as $n,Y_ as $o,xk as $r,Ql as $s,KP as $t,WR as A,uw as Aa,so as Ac,DD as Ai,Xt as Al,SN as An,xy as Ao,qA as Ar,qp as As,vI as At,MR as B,aC as Ba,I as Bc,cE as Bi,ce as Bl,FM as Bn,Pv as Bo,jk as Br,Bu as Bs,XF as Bt,iz as C,Dw as Ca,Ho as Cc,vO as Ci,Yt as Cl,NN as Cn,By as Co,ej as Cr,hm as Cs,zI as Ct,qR as D,fw as Da,Mo as Dc,YD as Di,Jt as Dl,EN as Dn,Ay as Do,YA as Dr,$p as Ds,kI as Dt,ZR as E,pw as Ea,Io as Ec,zD as Ei,dn as El,DN as En,ky as Eo,JA as Er,um as Es,jI as Et,zR as F,EC as Fa,_a as Fc,XE as Fi,_t as Fl,WM as Fn,Vv as Fo,eA as Fr,Cd as Fs,rI as Ft,AR as G,ZS as Ga,_i as Gc,nE as Gi,wM as Gn,Ov as Go,Ak as Gr,U as Gs,tF as Gt,wR as H,rC as Ha,wi as Hc,oE as Hi,jM as Hn,Mv as Ho,_k as Hr,Ru as Hs,JF as Ht,FR as I,wC as Ia,ua as Ic,KE as Ii,dt as Il,UM as In,Bv as Io,Ik as Ir,wd as Is,nI as It,yR as J,Q as Ja,Br as Jc,HT as Ji,yM as Jn,sv as Jo,bk as Jr,cu as Js,XP as Jt,CR as K,YS as Ka,gi as Kc,ZT as Ki,TM as Kn,_v as Ko,ak as Kr,pu as Ks,QP as Kt,IR as L,SC as La,Ki as Lc,UE as Li,ut as Ll,BM as Ln,Lv as Lo,Fk as Lr,Ed as Ls,eI as Lt,HR as M,HC as Ma,z as Mc,CD as Mi,At as Ml,_N as Mn,Uv as Mo,UA as Mr,op as Ms,cI as Mt,VR as N,AC as Na,Oa as Nc,bD as Ni,jt as Nl,uN as Nn,Wv as No,WA as Nr,Cf as Ns,sI as Nt,rz as O,hw as Oa,Oo as Oc,RD as Oi,pn as Ol,TN as On,Dy as Oo,XA as Or,Qp as Os,wI as Ot,BR as P,DC as Pa,ba as Pc,vD as Pi,yt as Pl,GM as Pn,Hv as Po,OA as Pr,Sd as Ps,oI as Pt,oR as Q,lS as Qa,F as Qc,vT as Qi,dM as Qn,G_ as Qo,Ck as Qr,tu as Qs,qP as Qt,PR as R,yC as Ra,qi as Rc,bE as Ri,je as Rl,zM as Rn,Iv as Ro,Pk as Rr,rd as Rs,QF as Rt,yz as S,Tw as Sa,Wo as Sc,SO as Si,nn as Sl,FN as Sn,Ky as So,$A as Sr,gm as Ss,HI as St,XR as T,bw as Ta,Ro as Tc,$D as Ti,fn as Tl,AN as Tn,Ny as To,ZA as Tr,pm as Ts,MI as Tt,TR as U,eC as Ua,Ai as Uc,eE as Ui,EM as Un,Nv as Uo,sk as Ur,Ou as Us,UF as Ut,jR as V,iC as Va,Li as Vc,lE as Vi,NM as Vn,jv as Vo,Sk as Vr,Lu as Vs,YF as Vt,kR as W,$S as Wa,vi as Wc,rE as Wi,SM as Wn,Av as Wo,hk as Wr,hu as Ws,$ as Wt,fR as X,mS as Xa,Vr as Xc,ET as Xi,uM as Xn,dv as Xo,gk as Xr,ou as Xs,HP as Xt,gR as Y,IS as Ya,Hr as Yc,zT as Yi,bM as Yn,ov as Yo,vk as Yr,su as Ys,JP as Yt,aR as Z,uS as Za,Lr as Zc,hT as Zi,lM as Zn,av as Zo,Dk as Zr,V as Zs,GP as Zt,Pz as _,Hw as _a,gs as _c,LO as _i,_n as _l,dP as _n,Yy as _o,Ij as _r,Nm as _s,rL as _t,$z as a,TT as aa,Xc as ac,ek as ai,Hn as al,TP as an,Lx as ao,nM as ar,d_ as as,YL as at,wz as b,jw as ba,Xo as bc,TO as bi,an as bl,JN as bn,qy as bo,bj as br,Tm as bs,KI as bt,Jz as c,iT as ca,Rc as cc,ik as ci,Pn as cl,yP as cn,Qb as co,rM as cr,Y as cs,NL as ct,Vz as d,Qw as da,Sc as dc,XO as di,Mn as dl,cP as dn,Db as do,Kj as dr,Lg as ds,AL as dt,gT as ea,Zl as ec,pk as ei,yr as el,LP as en,Ux as eo,fM as er,A_ as es,rR as et,Bz as f,nT as fa,ec as fc,ZO as fi,kn as fl,uP as fn,Tb as fo,Hj as fr,ch as fs,OL as ft,Fz as g,Rw as ga,vs as gc,BO as gi,Sn as gl,lP as gn,Xy as go,Fj as gr,Lm as gs,hL as gt,Rz as h,Gw as ha,Os as hc,zO as hi,Tn as hl,sP as hn,ib as ho,zj as hr,Rm as hs,vL as ht,qz as i,kT as ia,vl as ic,rk as ii,Wn as il,EP as in,Bx as io,oM as ir,C_ as is,QL as it,KR as j,ZC as ja,B as jc,OD as ji,Vt as jl,yN as jn,iy as jo,KA as jr,mp as js,dI as jt,tz as k,dw as ka,wo as kc,ED as ki,Ut as kl,wN as kn,Oy as ko,GA as kr,Zp as ks,yI as kt,Kz as l,aT as la,Ic as lc,$O as li,jn as ll,vP as ln,$b as lo,Gj as lr,J as ls,ML as lt,Hz as m,Jw as ma,Ms as mc,UO as mi,Dn as ml,aP as mn,db as mo,Vj as mr,Wm as ms,CL as mt,nB as n,bT as na,Ol as nc,fk as ni,Zn as nl,BP as nn,Vx as no,Zj as nr,X as ns,$L as nt,Qz as o,ST as oa,Wc as oc,tk as oi,Ln as ol,CP as on,Ix as oo,eM as or,f_ as os,LL as ot,zz as p,Xw as pa,Is as pc,JO as pi,Nn as pl,fP as pn,fb as po,Uj as pr,Zm as ps,DL as pt,SR as q,XS as qa,hi as qc,BT as qi,_M as qn,Sv as qo,yk as qr,du as qs,$P as qt,tB as r,xT as ra,El as rc,Ok as ri,Un as rl,DP as rn,zx as ro,Qj as rr,S_ as rs,eR as rt,Uz as s,CT as sa,Bc as sc,nk as si,In as sl,_P as sn,ux as so,tM as sr,c_ as ss,PL as st,iB as t,yT as ta,Xl as tc,wk as ti,br as tl,zP as tn,Hx as to,mM as tr,E_ as ts,iR as tt,Zz as u,oT as ua,Mc as uc,QO as ui,En as ul,oP as un,Jb as uo,qj as ur,Jg as us,jL as ut,Mz as v,Bw as va,us as vc,kO as vi,hn as vl,pP as vn,Zy as vo,Pj as vr,Pm as vs,JI as vt,nz as w,Ew as wa,Bo as wc,nO as wi,Wt as wl,jN as wn,Iy as wo,QA as wr,mm as ws,II as wt,Sz as x,Ow as xa,Ko as xc,CO as xi,rn as xl,qN as xn,Gy as xo,rj as xr,wm as xs,UI as xt,jz as y,zw as ya,ns as yc,AO as yi,Kt as yl,iP as yn,eb as yo,jj as yr,Dm as ys,qI as yt,NR as z,mC as za,L as zc,mE as zi,ge as zl,LM as zn,Fv as zo,Mk as zr,Xu as zs,ZF as zt};
34
+ //# debugId=d397cae0-f231-45d2-936d-ac473e04df57