@protobase/ui 0.117.7 → 0.118.1
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.
- package/dist/account/messages.d.ts +2 -2
- package/dist/activity-chart/activity-chart.d.ts +3 -1
- package/dist/activity-chart/activity-chart.js +21 -14
- package/dist/activity-chart/messages.d.ts +2 -2
- package/dist/app/app.js +67 -31
- package/dist/app/change-confirm/messages.d.ts +2 -2
- package/dist/app/charts/chart-params.js +1 -1
- package/dist/app/charts/messages.d.ts +2 -2
- package/dist/app/comments/messages.d.ts +2 -2
- package/dist/app/confirm-sign-in-messages.d.ts +2 -2
- package/dist/app/conversation/thread-state.d.ts +1 -1
- package/dist/app/create/messages.d.ts +2 -2
- package/dist/app/custom-section.d.ts +1 -1
- package/dist/app/delete/messages.d.ts +2 -2
- package/dist/app/displays/calendar-event.js +1 -1
- package/dist/app/displays/list-cards.d.ts +1 -1
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/displays/use-calendar-move.js +1 -1
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-messages.d.ts +2 -2
- package/dist/app/field-types/custom-step-container/messages.d.ts +2 -2
- package/dist/app/field-types/widget-part.d.ts +1 -1
- package/dist/app/field-types/workflow/definition.d.ts +1 -1
- package/dist/app/field-types/workflow/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
- package/dist/app/file-viewers/messages.d.ts +2 -2
- package/dist/app/focus/messages.d.ts +2 -2
- package/dist/app/gallery/messages.d.ts +2 -2
- package/dist/app/hand-order/messages.d.ts +2 -2
- package/dist/app/history/messages.d.ts +2 -2
- package/dist/app/import/messages.d.ts +2 -2
- package/dist/app/lazy-routes.d.ts +4 -0
- package/dist/app/lazy-routes.js +2 -1
- package/dist/app/list-chart.d.ts +1 -1
- package/dist/app/list-chart.js +6 -4
- package/dist/app/list-messages.d.ts +2 -2
- package/dist/app/list-page.js +1 -1
- package/dist/app/messages.d.ts +2 -2
- package/dist/app/meta-gate-messages.d.ts +2 -2
- package/dist/app/nav-recent.js +1 -1
- package/dist/app/pages/custom-boundary.d.ts +1 -1
- package/dist/app/pages/custom-chosen.d.ts +1 -1
- package/dist/app/pages/messages.d.ts +2 -2
- package/dist/app/record-chart/messages.d.ts +2 -2
- package/dist/app/record-messages.d.ts +2 -2
- package/dist/app/record-mode/shown-layout.d.ts +1 -1
- package/dist/app/record-row/messages.d.ts +2 -2
- package/dist/app/related-cards/messages.d.ts +2 -2
- package/dist/app/saved/messages.d.ts +2 -2
- package/dist/app/saved/saved-list.d.ts +1 -1
- package/dist/app/searches/messages.d.ts +2 -2
- package/dist/app/searches/update-search-dialog.js +1 -1
- package/dist/app/start-record.d.ts +22 -0
- package/dist/app/start-record.js +33 -0
- package/dist/app/use-nav-recent.d.ts +2 -2
- package/dist/app/use-nav-recent.js +8 -3
- package/dist/app/use-start-address.d.ts +21 -0
- package/dist/app/use-start-address.js +49 -0
- package/dist/app-shell/messages.d.ts +2 -2
- package/dist/app-shell/profile-menu.d.ts +2 -0
- package/dist/app-shell/profile-menu.js +1 -1
- package/dist/assistant-dock/messages.d.ts +2 -2
- package/dist/auth/messages.d.ts +2 -2
- package/dist/calls/messages.d.ts +2 -2
- package/dist/compact-table/messages.d.ts +2 -2
- package/dist/data/aggregate-loader.d.ts +38 -0
- package/dist/data/aggregate-loader.js +68 -0
- package/dist/data/api-provider.d.ts +3 -0
- package/dist/data/query-keys.d.ts +4 -0
- package/dist/data/query-keys.js +11 -0
- package/dist/data/start-cache/restored-state.d.ts +7 -0
- package/dist/data/start-cache/restored-state.js +5 -1
- package/dist/data/use-aggregates.js +7 -6
- package/dist/data-grid/messages.d.ts +2 -2
- package/dist/filter-panel/facet-combobox.js +38 -31
- package/dist/filter-panel/facet-group.js +5 -1
- package/dist/filter-panel/filter-config.d.ts +4 -0
- package/dist/filter-panel/messages.d.ts +2 -2
- package/dist/filter-panel/range-filter.js +4 -0
- package/dist/invitations/messages.d.ts +2 -2
- package/dist/live/messages.d.ts +2 -2
- package/dist/live/use-filter-config.d.ts +3 -2
- package/dist/live/use-filter-config.js +31 -8
- package/dist/locale/en.js +42 -23
- package/dist/locale/en.json.d.ts +19 -0
- package/dist/locale/messages.d.ts +38 -0
- package/dist/locale/nl.js +42 -23
- package/dist/locale/texts-gate.d.ts +1 -1
- package/dist/notifications/bell/messages.d.ts +2 -2
- package/dist/organizations/all-organizations.js +5 -3
- package/dist/organizations/first-organization-page.d.ts +21 -0
- package/dist/organizations/first-organization-page.js +125 -0
- package/dist/organizations/invitations-page.js +3 -1
- package/dist/organizations/members-page.js +5 -2
- package/dist/organizations/messages.d.ts +2 -2
- package/dist/organizations/my-invitation-row.d.ts +11 -0
- package/dist/organizations/my-invitation-row.js +34 -0
- package/dist/organizations/new-organization-form.d.ts +10 -0
- package/dist/organizations/new-organization-form.js +76 -0
- package/dist/organizations/organization-page.js +9 -6
- package/dist/organizations/organization-paths.d.ts +7 -2
- package/dist/organizations/organization-paths.js +14 -8
- package/dist/organizations/organization-word.d.ts +14 -0
- package/dist/organizations/organization-word.js +22 -0
- package/dist/organizations/organizations-page.d.ts +0 -2
- package/dist/organizations/organizations-page.js +31 -98
- package/dist/organizations/use-my-invitations.d.ts +17 -0
- package/dist/organizations/use-my-invitations.js +30 -0
- package/dist/organizations/use-organizations.d.ts +4 -0
- package/dist/organizations/use-organizations.js +8 -3
- package/dist/package.js +1 -1
- package/dist/plugins/before-sign-in.d.ts +1 -1
- package/dist/primitives/messages.d.ts +2 -2
- package/dist/record-view/messages.d.ts +2 -2
- package/dist/shell/assets/{account-page-B_azef82.js → account-page-D9hXd-u3.js} +2 -2
- package/dist/shell/assets/app-D6luJ1k4.js +34 -0
- package/dist/shell/assets/{app-Dq5eubgK.css → app-xwgcmboV.css} +1 -1
- package/dist/shell/assets/{assistant-shell-BDKCWgs7.js → assistant-shell-DDkCxLNG.js} +2 -2
- package/dist/shell/assets/board-display-plYPsh6z.js +2 -0
- package/dist/shell/assets/calendar-display-B3kFBd2k.js +2 -0
- package/dist/shell/assets/{call-rings-ClQinnwb.js → call-rings-B5rBD5EL.js} +2 -2
- package/dist/shell/assets/{calls-s6XuZsjs.js → calls-z1AEvYOC.js} +2 -2
- package/dist/shell/assets/{circle-alert-CCchwpE2.js → circle-alert-C_1i142n.js} +2 -2
- package/dist/shell/assets/{composed-page-Cj-OwCZB.js → composed-page--UJ8tsC0.js} +2 -2
- package/dist/shell/assets/{composer-section-BWJgscVY.js → composer-section-tfrO2pIi.js} +2 -2
- package/dist/shell/assets/{connect-route-DpM6_5A-.js → connect-route-rVNQDWcE.js} +2 -2
- package/dist/shell/assets/{copy-field-DJZYMDoO.js → copy-field-D9agQmK0.js} +2 -2
- package/dist/shell/assets/create-route-C4xN9aXd.js +2 -0
- package/dist/shell/assets/{custom-step-container-field-B0SWYcOK.js → custom-step-container-field-BanmPoI-.js} +4 -4
- package/dist/shell/assets/embedded-list-B_e_Quer.js +3 -0
- package/dist/shell/assets/en-BrEwbNhJ.js +2 -0
- package/dist/shell/assets/{export-dialog-DOtYGy3R.js → export-dialog-g69vJ8j2.js} +2 -2
- package/dist/shell/assets/export-worker-DuHOhIiP.js +15 -0
- package/dist/shell/assets/first-organization-page-Cijgw9tC.js +2 -0
- package/dist/shell/assets/{graph-view-G-uTEd7F.js → graph-view-DXDcn-Fx.js} +2 -2
- package/dist/shell/assets/{group-donut-C_BThKYK.js → group-donut-B3bCn83A.js} +2 -2
- package/dist/shell/assets/{guest-call-page-CUucHFn7.js → guest-call-page-rAD4EXPd.js} +3 -3
- package/dist/shell/assets/{html-viewer-CxMoymHe.js → html-viewer-BxhCE5h2.js} +2 -2
- package/dist/shell/assets/{import-dialog-DJdNJeuD.js → import-dialog-adjnDUuk.js} +2 -2
- package/dist/shell/assets/import-table-dialog-yV9UTlBY.js +2 -0
- package/dist/shell/assets/{index-BpuPTpcS.js → index-BBHelxJ2.js} +1 -1
- package/dist/shell/assets/invitations-page-FKTUQL8J.js +2 -0
- package/dist/shell/assets/{layout-grid-IQchsfWp.js → layout-grid-B3Php1Rf.js} +2 -2
- package/dist/shell/assets/{legend-item-BlI2FIuO.js → legend-item-BbV6BD6w.js} +2 -2
- package/dist/shell/assets/list-page-CNhV2TuF.js +4 -0
- package/dist/shell/assets/{maplibre-BNosce4R.js → maplibre-D4xk_BLC.js} +2 -2
- package/dist/shell/assets/{markdown-content-C_-l2O5-.js → markdown-content-CnNrPGcY.js} +2 -2
- package/dist/shell/assets/members-page-CnxFoeyp.js +2 -0
- package/dist/shell/assets/{messages-DAlS_OLf.js → messages-BHPGrBhJ.js} +2 -2
- package/dist/shell/assets/nl-Dto12ewP.js +2 -0
- package/dist/shell/assets/organization-page-B6k9pMkb.js +2 -0
- package/dist/shell/assets/organizations-page-D33Ruydz.js +2 -0
- package/dist/shell/assets/parse-worker-BRxyLV_D.js +35 -0
- package/dist/shell/assets/{pending-invitation-row-nDslRIg_.js → pending-invitation-row-D_vU7ynw.js} +2 -2
- package/dist/shell/assets/{period-chart-Dbykq15D.js → period-chart-DPlEbvX7.js} +2 -2
- package/dist/shell/assets/{person-row-RUXD4Z6I.js → person-row-DMY-aQjx.js} +2 -2
- package/dist/shell/assets/public-form-page-DTgXLDpt.js +2 -0
- package/dist/shell/assets/record-lines-SeXhFNSm.js +2 -0
- package/dist/shell/assets/{record-map-SrorcD8G.js → record-map-BiLFEqYi.js} +2 -2
- package/dist/shell/assets/{record-opens-BkQP4ve9.js → record-opens-Ct9iF9FZ.js} +2 -2
- package/dist/shell/assets/record-page-TxDSHcMe.js +3 -0
- package/dist/shell/assets/{record-preview-C8xkvcPt.js → record-preview-J1o4Sqs-.js} +2 -2
- package/dist/shell/assets/{records-map-DgQ3MJFS.js → records-map-Cwdig5mb.js} +2 -2
- package/dist/shell/assets/render-node-BpHo-wre.js +3 -0
- package/dist/shell/assets/reorder-button-CBOmzmhg.js +2 -0
- package/dist/shell/assets/{run-trace-view-C2MAxHm8.js → run-trace-view-1fk6kU1U.js} +2 -2
- package/dist/shell/assets/{runner-install-field-BYzWk3Ye.js → runner-install-field-C_hTvogl.js} +2 -2
- package/dist/shell/assets/{runtime-update-CVNAIIII.js → runtime-update-8hRmQkq-.js} +2 -2
- package/dist/shell/assets/shared-protobase-ui-Tq2sgl9G.js +1 -0
- package/dist/shell/assets/{sheet-source-BNfkNzNO.js → sheet-source-CD5hImgE.js} +3 -3
- package/dist/shell/assets/sign-in-policy-page-BQ8ck7Ar.js +2 -0
- package/dist/shell/assets/start-block-queries-4uvupY9E.js +2 -0
- package/dist/shell/assets/step-catalog-B2eQNTOp.js +2 -0
- package/dist/shell/assets/{step-panel-DDSMdJhn.js → step-panel-BVdV2FNT.js} +2 -2
- package/dist/shell/assets/timeline-display-BxihBkFH.js +2 -0
- package/dist/shell/assets/{trash-Du1HjUvA.js → trash-5PpoeP3R.js} +2 -2
- package/dist/shell/assets/{update-set-BQN3GDI3.js → update-set-BnRA9YhA.js} +2 -2
- package/dist/shell/assets/use-calendar-move-Bu9MSBcs.js +2 -0
- package/dist/shell/assets/{use-display-rows-BWZ3ByZb.js → use-display-rows-ERQ-vbki.js} +2 -2
- package/dist/shell/assets/use-my-invitations-CnAvjXV0.js +2 -0
- package/dist/shell/assets/{use-paged-search-DvGQocxR.js → use-paged-search-CcEitpWG.js} +2 -2
- package/dist/shell/assets/{use-run-trace-CNqw_HuX.js → use-run-trace-CV461SQS.js} +2 -2
- package/dist/shell/assets/{use-workflow-page-jjK3t-vf.js → use-workflow-page-peSmP1Jq.js} +2 -2
- package/dist/shell/assets/{use-workflow-types-CxeOmx1U.js → use-workflow-types-xM8CZO96.js} +2 -2
- package/dist/shell/assets/{workflow-canvas-BgC2BoRd.js → workflow-canvas-CkKd9u0-.js} +4 -4
- package/dist/shell/assets/{workflow-field-DAk0UqrK.js → workflow-field-WovRhNaT.js} +3 -3
- package/dist/shell/assets/{workflow-graph-editor-0KyZBj6R.js → workflow-graph-editor-DRZ2UtBp.js} +2 -2
- package/dist/shell/assets/{workflow-run-field-rlISvE35.js → workflow-run-field-CrBAVhOq.js} +3 -3
- package/dist/shell/assets/workflow-status-field-DgjtbjlH.js +2 -0
- package/dist/shell/assets/workflow-workbench-D8vU7ifz.js +4 -0
- package/dist/shell/index.html +4 -4
- package/dist/shell/protobase.shell.json +2 -2
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/{account-page-B_azef82.js.map → account-page-D9hXd-u3.js.map} +1 -1
- package/dist/shell-source-maps/assets/app-D6luJ1k4.js.map +1 -0
- package/dist/shell-source-maps/assets/{assistant-shell-BDKCWgs7.js.map → assistant-shell-DDkCxLNG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{board-display-RfXJJ01f.js.map → board-display-plYPsh6z.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calendar-display-CWANjACC.js.map → calendar-display-B3kFBd2k.js.map} +1 -1
- package/dist/shell-source-maps/assets/{call-rings-ClQinnwb.js.map → call-rings-B5rBD5EL.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calls-s6XuZsjs.js.map → calls-z1AEvYOC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{circle-alert-CCchwpE2.js.map → circle-alert-C_1i142n.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composed-page-Cj-OwCZB.js.map → composed-page--UJ8tsC0.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composer-section-BWJgscVY.js.map → composer-section-tfrO2pIi.js.map} +1 -1
- package/dist/shell-source-maps/assets/{connect-route-DpM6_5A-.js.map → connect-route-rVNQDWcE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{copy-field-DJZYMDoO.js.map → copy-field-D9agQmK0.js.map} +1 -1
- package/dist/shell-source-maps/assets/{create-route-CQeYkXaB.js.map → create-route-C4xN9aXd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{custom-step-container-field-B0SWYcOK.js.map → custom-step-container-field-BanmPoI-.js.map} +1 -1
- package/dist/shell-source-maps/assets/{embedded-list-CQ7VmI-J.js.map → embedded-list-B_e_Quer.js.map} +1 -1
- package/dist/shell-source-maps/assets/en-BrEwbNhJ.js.map +1 -0
- package/dist/shell-source-maps/assets/{export-dialog-DOtYGy3R.js.map → export-dialog-g69vJ8j2.js.map} +1 -1
- package/dist/shell-source-maps/assets/export-worker-DuHOhIiP.js.map +1 -0
- package/dist/shell-source-maps/assets/first-organization-page-Cijgw9tC.js.map +1 -0
- package/dist/shell-source-maps/assets/{graph-view-G-uTEd7F.js.map → graph-view-DXDcn-Fx.js.map} +1 -1
- package/dist/shell-source-maps/assets/{group-donut-C_BThKYK.js.map → group-donut-B3bCn83A.js.map} +1 -1
- package/dist/shell-source-maps/assets/{guest-call-page-CUucHFn7.js.map → guest-call-page-rAD4EXPd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-CxMoymHe.js.map → html-viewer-BxhCE5h2.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-dialog-DJdNJeuD.js.map → import-dialog-adjnDUuk.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-table-dialog-vxHtntUq.js.map → import-table-dialog-yV9UTlBY.js.map} +1 -1
- package/dist/shell-source-maps/assets/invitations-page-FKTUQL8J.js.map +1 -0
- package/dist/shell-source-maps/assets/{layout-grid-IQchsfWp.js.map → layout-grid-B3Php1Rf.js.map} +1 -1
- package/dist/shell-source-maps/assets/{legend-item-BlI2FIuO.js.map → legend-item-BbV6BD6w.js.map} +1 -1
- package/dist/shell-source-maps/assets/list-page-CNhV2TuF.js.map +1 -0
- package/dist/shell-source-maps/assets/{maplibre-BNosce4R.js.map → maplibre-D4xk_BLC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{markdown-content-C_-l2O5-.js.map → markdown-content-CnNrPGcY.js.map} +1 -1
- package/dist/shell-source-maps/assets/members-page-CnxFoeyp.js.map +1 -0
- package/dist/shell-source-maps/assets/{messages-DAlS_OLf.js.map → messages-BHPGrBhJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/nl-Dto12ewP.js.map +1 -0
- package/dist/shell-source-maps/assets/organization-page-B6k9pMkb.js.map +1 -0
- package/dist/shell-source-maps/assets/organizations-page-D33Ruydz.js.map +1 -0
- package/dist/shell-source-maps/assets/parse-worker-BRxyLV_D.js.map +1 -0
- package/dist/shell-source-maps/assets/{pending-invitation-row-nDslRIg_.js.map → pending-invitation-row-D_vU7ynw.js.map} +1 -1
- package/dist/shell-source-maps/assets/{period-chart-Dbykq15D.js.map → period-chart-DPlEbvX7.js.map} +1 -1
- package/dist/shell-source-maps/assets/{person-row-RUXD4Z6I.js.map → person-row-DMY-aQjx.js.map} +1 -1
- package/dist/shell-source-maps/assets/{public-form-page-CI1ghnwR.js.map → public-form-page-DTgXLDpt.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-lines-sVjQkysF.js.map → record-lines-SeXhFNSm.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-SrorcD8G.js.map → record-map-BiLFEqYi.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-opens-BkQP4ve9.js.map → record-opens-Ct9iF9FZ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-page-CA2bmhxx.js.map → record-page-TxDSHcMe.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-preview-C8xkvcPt.js.map → record-preview-J1o4Sqs-.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-DgQ3MJFS.js.map → records-map-Cwdig5mb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{render-node-eKuGRuq5.js.map → render-node-BpHo-wre.js.map} +1 -1
- package/dist/shell-source-maps/assets/{reorder-button-DFrAk-Xc.js.map → reorder-button-CBOmzmhg.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-C2MAxHm8.js.map → run-trace-view-1fk6kU1U.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runner-install-field-BYzWk3Ye.js.map → runner-install-field-C_hTvogl.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runtime-update-CVNAIIII.js.map → runtime-update-8hRmQkq-.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sheet-source-BNfkNzNO.js.map → sheet-source-CD5hImgE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sign-in-policy-page-DqH94QZl.js.map → sign-in-policy-page-BQ8ck7Ar.js.map} +1 -1
- package/dist/shell-source-maps/assets/{start-block-queries-CAEd4yVp.js.map → start-block-queries-4uvupY9E.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-catalog-wasAn9L1.js.map → step-catalog-B2eQNTOp.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-DDSMdJhn.js.map → step-panel-BVdV2FNT.js.map} +1 -1
- package/dist/shell-source-maps/assets/{timeline-display-CLcdY1TN.js.map → timeline-display-BxihBkFH.js.map} +1 -1
- package/dist/shell-source-maps/assets/{trash-Du1HjUvA.js.map → trash-5PpoeP3R.js.map} +1 -1
- package/dist/shell-source-maps/assets/{update-set-BQN3GDI3.js.map → update-set-BnRA9YhA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-calendar-move-C8LZwkOo.js.map → use-calendar-move-Bu9MSBcs.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-display-rows-BWZ3ByZb.js.map → use-display-rows-ERQ-vbki.js.map} +1 -1
- package/dist/shell-source-maps/assets/use-my-invitations-CnAvjXV0.js.map +1 -0
- package/dist/shell-source-maps/assets/{use-paged-search-DvGQocxR.js.map → use-paged-search-CcEitpWG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-run-trace-CNqw_HuX.js.map → use-run-trace-CV461SQS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-page-jjK3t-vf.js.map → use-workflow-page-peSmP1Jq.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-types-CxeOmx1U.js.map → use-workflow-types-xM8CZO96.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-BgC2BoRd.js.map → workflow-canvas-CkKd9u0-.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-field-DAk0UqrK.js.map → workflow-field-WovRhNaT.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-0KyZBj6R.js.map → workflow-graph-editor-DRZ2UtBp.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-run-field-rlISvE35.js.map → workflow-run-field-CrBAVhOq.js.map} +1 -1
- package/dist/shell-source-maps/assets/workflow-status-field-DgjtbjlH.js.map +1 -0
- package/dist/shell-source-maps/assets/{workflow-workbench-CYjY4iZy.js.map → workflow-workbench-D8vU7ifz.js.map} +1 -1
- package/dist/status/messages.d.ts +2 -2
- package/dist/users/messages.d.ts +2 -2
- package/package.json +5 -5
- package/dist/shell/assets/app-1j5nx8lw.js +0 -34
- package/dist/shell/assets/board-display-RfXJJ01f.js +0 -2
- package/dist/shell/assets/calendar-display-CWANjACC.js +0 -2
- package/dist/shell/assets/create-route-CQeYkXaB.js +0 -2
- package/dist/shell/assets/embedded-list-CQ7VmI-J.js +0 -3
- package/dist/shell/assets/en-Dm9QE1tF.js +0 -2
- package/dist/shell/assets/export-worker-CHLq663S.js +0 -15
- package/dist/shell/assets/import-table-dialog-vxHtntUq.js +0 -2
- package/dist/shell/assets/invitations-page-a0oQdGxB.js +0 -2
- package/dist/shell/assets/list-page-BXVd_Eq3.js +0 -4
- package/dist/shell/assets/members-page-Bm3GFEhM.js +0 -2
- package/dist/shell/assets/nl-Cyam8kgY.js +0 -2
- package/dist/shell/assets/organization-page-BbzBkLeU.js +0 -2
- package/dist/shell/assets/organizations-page-BkarXyu5.js +0 -2
- package/dist/shell/assets/parse-worker-DI-FeZWV.js +0 -35
- package/dist/shell/assets/public-form-page-CI1ghnwR.js +0 -2
- package/dist/shell/assets/record-lines-sVjQkysF.js +0 -2
- package/dist/shell/assets/record-page-CA2bmhxx.js +0 -3
- package/dist/shell/assets/render-node-eKuGRuq5.js +0 -3
- package/dist/shell/assets/reorder-button-DFrAk-Xc.js +0 -2
- package/dist/shell/assets/shared-protobase-ui-C_Oyn30V.js +0 -1
- package/dist/shell/assets/sign-in-policy-page-DqH94QZl.js +0 -2
- package/dist/shell/assets/start-block-queries-CAEd4yVp.js +0 -2
- package/dist/shell/assets/step-catalog-wasAn9L1.js +0 -2
- package/dist/shell/assets/timeline-display-CLcdY1TN.js +0 -2
- package/dist/shell/assets/use-calendar-move-C8LZwkOo.js +0 -2
- package/dist/shell/assets/workflow-status-field-jZ1pLRdt.js +0 -2
- package/dist/shell/assets/workflow-workbench-CYjY4iZy.js +0 -4
- package/dist/shell-source-maps/assets/app-1j5nx8lw.js.map +0 -1
- package/dist/shell-source-maps/assets/en-Dm9QE1tF.js.map +0 -1
- package/dist/shell-source-maps/assets/export-worker-CHLq663S.js.map +0 -1
- package/dist/shell-source-maps/assets/invitations-page-a0oQdGxB.js.map +0 -1
- package/dist/shell-source-maps/assets/list-page-BXVd_Eq3.js.map +0 -1
- package/dist/shell-source-maps/assets/members-page-Bm3GFEhM.js.map +0 -1
- package/dist/shell-source-maps/assets/nl-Cyam8kgY.js.map +0 -1
- package/dist/shell-source-maps/assets/organization-page-BbzBkLeU.js.map +0 -1
- package/dist/shell-source-maps/assets/organizations-page-BkarXyu5.js.map +0 -1
- package/dist/shell-source-maps/assets/parse-worker-DI-FeZWV.js.map +0 -1
- package/dist/shell-source-maps/assets/workflow-status-field-jZ1pLRdt.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,Bc as i,Ls as a,Qo as o,Qs as s,R as c,Vc as l,Yo as u,_ as d,a as f,b as p,c as m,ec as h,i as g,io as _,mr as v,no as y,o as b,rs as x,u as S,v as C,y as w}from"./app-1j5nx8lw.js";import{o as T}from"./vendor-t7Q7QbPu.js";import{n as E,t as D}from"./lib-altcha-lib-BK1uKcxH.js";var O=e(t(),1),k=l(`forms`),A=async(e,t)=>{let n=await e.formChallenge(t),r=await E({challenge:n,deriveKey:D});if(!r)throw Error(k(`checkTooLong`));return{challenge:n,solution:{counter:r.counter,derivedKey:r.derivedKey}}},j=e(n(),1),M=({name:e})=>{let t=x(),n=T({queryKey:i.publicForm(e),queryFn:()=>t.form(e)});return n.isPending?(0,j.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,j.jsx)(h,{}),` `,k(`loading`)]}):n.error?a(n.error)&&n.error.status===404?(0,j.jsx)(u,{title:k(`notFound`),children:k(`noForm`)}):(0,j.jsx)(u,{title:o(`cannotReach`),children:a(n.error)?n.error.message:o(`noAnswer`)}):(0,j.jsx)(N,{form:n.data})},N=({form:e})=>{let t=x(),{resource:n,view:i}=e,a=e.title??i.names?.singular??r(i.resource);_(a);let[o,l]=(0,O.useState)(()=>b(n,[{title:a,fields:e.fields}])),[u,h]=(0,O.useState)({}),[T,E]=(0,O.useState)(),[D,M]=(0,O.useState)(!1),[N,P]=(0,O.useState)(!1),[F,I]=(0,O.useState)(0),L=d(F);if(N)return(0,j.jsx)(y,{title:a,size:`md`,children:(0,j.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:e.thanks})});let R=(e,t)=>{h(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),l(n=>({...n,[e]:t}))},z=async()=>{M(!0),E(void 0);try{await t.submitForm(e.name,g(n,{},o),await A(t,e.name)),P(!0)}catch(e){let t=C(e);h(t),Object.keys(t).length>0?I(e=>e+1):E(e)}finally{M(!1)}};return(0,j.jsx)(y,{title:a,size:`md`,children:(0,j.jsxs)(`form`,{ref:L,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),z()},children:[e.fields.map(e=>{let t=n.fields[e],a=i.fields[e],s=a?.label??r(e),l=u[e];return(0,j.jsx)(c,{name:e,label:s,help:a?.help,required:m(t),error:l&&w(t,s,l),children:(0,j.jsx)(p,{field:t,hints:a,value:o[e]??(t.type!==`boolean`&&``),stored:void 0,placeholder:f(t)?k(`setByDatabase`):S(t),invalid:!!l,onChange:t=>R(e,t)})},e)}),T!==void 0&&(0,j.jsx)(v,{title:k(`notSent`),error:T}),(0,j.jsx)(s,{variant:`primary`,type:`submit`,loading:D,className:`min-h-10`,children:k(`send`)})]})})};export{M as PublicFormPage};
|
|
2
|
-
//# debugId=88d60867-c116-41a1-b4a8-231b9085784f
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,Nc as i,Ni as a,P as o,Qs as s,Sa as c,So as l,Vc as u,Xc as d,Xo as f,Zo as p,b as m,bo as h,g,l as _,s as v,uc as y,vc as b,wa as x,y as S,yo as C}from"./app-1j5nx8lw.js";import{At as w}from"./embedded-list-CQ7VmI-J.js";import{_ as T,a as E,i as D,o as O,s as k,t as A,v as j}from"./lib-dnd-kit-core-xi-7xL_N.js";import{a as M,i as N,r as P,t as F}from"./lib-dnd-kit-sortable-CNDSKqCD.js";import"./record-page-CA2bmhxx.js";var I=e=>e.width??`minmax(8rem,1fr)`,L=e=>({"--line-columns":e.map(I).join(` `)}),R=e=>`${e.reduce((e,t)=>e+(t.width?.endsWith(`px`)?parseInt(t.width)/16:8),6)}rem`,z=`grid grid-cols-[28px_var(--line-columns)_32px] items-center gap-2 pointer-coarse:grid-cols-[44px_var(--line-columns)_44px]`,B=e(t(),1),V=e(n(),1),H=({items:e,label:t})=>{let[n,r]=(0,B.useState)(!1),a=(0,B.useRef)(null),o=(0,B.useRef)(null),s=C(n,a,o),c=h(n,a,o,s?.right);return(0,B.useEffect)(()=>{if(!n)return;let e=e=>{(e instanceof KeyboardEvent?e.key===`Escape`:!a.current?.contains(e.target))&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[n]),(0,V.jsxs)(`div`,{ref:a,className:`relative flex justify-center`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(!n),className:`inline-flex size-7 items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground pointer-coarse:size-11`,children:(0,V.jsx)(b,{className:`size-4`})}),n&&(0,V.jsx)(`ul`,{ref:o,role:`menu`,style:{...s,...c},className:`absolute right-0 top-full z-30 mt-1 w-max min-w-36 rounded-md border bg-background py-1 shadow-pop`,children:e.map(e=>(0,V.jsx)(`li`,{role:`none`,children:(0,V.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:e.disabled,className:i(`block min-h-9 w-full px-3 py-1.5 text-left hover:bg-muted disabled:text-faint-foreground disabled:hover:bg-transparent`,e.destructive&&`text-danger-text`),onClick:()=>{r(!1),e.onSelect()},children:e.label})},e.label))})]})},U=u(`inline-child-table`),W=({line:e,name:t,columns:n,position:r,count:a,reorderable:o,onRemove:s,onMove:c,error:l})=>{let{attributes:u,listeners:d,setNodeRef:f,setActivatorNodeRef:p,transform:m,transition:h,isDragging:g}=N({id:e.id,disabled:!o}),_=[...o?[{label:U(`moveUp`),disabled:r===0,onSelect:()=>c(r-1)},{label:U(`moveDown`),disabled:r===a-1,onSelect:()=>c(r+1)}]:[],...s?[{label:U(`removeLine`),destructive:!0,onSelect:s}]:[]];return(0,V.jsxs)(`div`,{ref:f,"data-line-id":e.id,"aria-invalid":l?!0:void 0,style:{transform:m?`translate3d(0, ${m.y}px, 0)`:void 0,transition:h},className:i(`group relative border-b border-border bg-background px-2 py-1 last:border-b-0 hover:bg-surface`,z,g&&`z-10 bg-surface opacity-80 shadow-pop`,l&&`bg-danger-soft`),children:[o?(0,V.jsx)(`button`,{ref:p,type:`button`,"aria-label":U(`dragToReorder`,{name:t}),...u,...d,style:{touchAction:`none`},className:`flex size-7 cursor-grab items-center justify-center rounded text-faint-foreground opacity-60 hover:bg-muted hover:opacity-100 focus-visible:opacity-100 active:cursor-grabbing pointer-coarse:size-11`,children:(0,V.jsx)(w,{className:`size-4`})}):(0,V.jsx)(`span`,{}),n.map(t=>(0,V.jsx)(`div`,{className:i(`min-w-0`,t.align===`right`&&`text-right`),children:t.cell(e)},t.key)),_.length>0?(0,V.jsx)(H,{label:U(`actionsFor`,{name:t}),items:_}):(0,V.jsx)(`span`,{}),l&&(0,V.jsx)(`p`,{role:`alert`,className:`col-span-full px-2 pb-1 text-xs text-danger-text`,children:l})]})},G=(e,t,n)=>{if(t===n||t<0||t>=e.length)return[...e];let r=[...e],[i]=r.splice(t,1);return r.splice(Math.min(Math.max(n,0),r.length),0,i),r},K=`px-2 text-[0.6875rem] font-medium uppercase tracking-wide text-muted-foreground`,q=(e,t)=>{let n=n=>{let r=e.find(e=>e.id===n);return r?t(r):U(`line`)},r=t=>e.findIndex(e=>e.id===t)+1;return{onDragStart:({active:t})=>U(`pickedUp`,{name:n(t.id),place:r(t.id),count:e.length}),onDragOver:({active:t,over:i})=>i?U(`over`,{name:n(t.id),place:r(i.id),count:e.length}):void 0,onDragEnd:({active:t,over:i})=>i?U(`dropped`,{name:n(t.id),place:r(i.id),count:e.length}):U(`droppedAtStart`,{name:n(t.id)}),onDragCancel:({active:e})=>U(`cancelled`,{name:n(e.id),place:r(e.id)})}},J=({lines:e,columns:t,lineName:n,onReorder:r,reorderable:a=!!r,onAdd:o,onRemove:c,removable:l=()=>!0,lineError:u,footer:d})=>{let f=j(T(E,{activationConstraint:{distance:4}}),T(O,{activationConstraint:{delay:250,tolerance:5}}),T(D,{coordinateGetter:P})),p=(t,n)=>{let i=e[t];!i||!r||n<0||n>=e.length||t===n||r(G(e,t,n),{id:i.id,from:t,to:n})};return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,style:L(t),children:[(0,V.jsxs)(`div`,{className:`${z} border-b border-border bg-surface px-2 py-2`,children:[(0,V.jsx)(`span`,{}),t.map(e=>(0,V.jsx)(`span`,{className:i(K,e.align===`right`&&`text-right`),children:e.label},e.key)),(0,V.jsx)(`span`,{})]}),e.length===0&&(0,V.jsx)(`p`,{className:`px-4 py-3 text-muted-foreground`,children:U(`noLines`)}),(0,V.jsx)(A,{sensors:f,collisionDetection:k,onDragEnd:({active:t,over:n})=>{n&&t.id!==n.id&&p(e.findIndex(e=>e.id===t.id),e.findIndex(e=>e.id===n.id))},accessibility:{announcements:q(e,n),screenReaderInstructions:{draggable:U(`instructions`)}},children:(0,V.jsx)(F,{items:e.map(e=>e.id),strategy:M,children:e.map((r,i)=>(0,V.jsx)(W,{line:r,name:n(r),columns:t,position:i,count:e.length,reorderable:a,onRemove:c&&l(r)?()=>c(r):void 0,onMove:e=>p(i,e),error:u?.(r)},r.id))})}),o&&(0,V.jsx)(`div`,{className:`border-t border-border bg-surface px-2 py-1.5`,children:(0,V.jsxs)(s,{variant:`ghost`,size:`sm`,onClick:o,children:[(0,V.jsx)(y,{className:`size-3.5`}),U(`addLine`)]})})]}),d]})},Y=({field:e,hints:t,label:n,lineNumber:r,resource:i,value:a,stored:o,relationLabel:s,relationTo:c,relationPicker:u,locked:d,problem:f,onChange:p})=>{let h=(0,B.useId)(),_=f&&S(e,n,f);return(0,V.jsxs)(l.Provider,{value:{id:h,invalid:!!f,required:!1,..._&&{describedBy:`${h}-error`}},children:[(0,V.jsx)(`label`,{htmlFor:h,className:`sr-only`,children:g(`lineField`,{label:n,place:r})}),(0,V.jsx)(m,{field:e,hints:t,value:a,stored:o,relationLabel:s,relationTo:c,relationPicker:u,locked:d,invalid:!!f,resource:i,onChange:p}),_&&(0,V.jsx)(`p`,{id:`${h}-error`,className:`px-1 pt-0.5 text-xs text-danger-text`,children:_})]})},X=({lines:e,editable:t,saving:n})=>{let{resources:i,views:s}=f(),{item:l,model:u,columns:m,data:h,draft:y}=e,b=p(u.name),S=s[u.name],[C,w]=(0,B.useState)({}),T=t&&h.complete&&!h.loading&&!n,E=T&&c(b,`update`),D=T&&c(b,`create`),O=T&&c(b,`delete`),k=e=>e.stored?E&&x(e.stored,`update`):D,A=e=>y.shown.indexOf(e)+1,j=e=>y.rejection?.id===e.id?y.rejection:void 0,M=m.map(e=>{let t=u.fields[e],n=S?.fields[e],a=n?.label??r(e),o=t.relation?i[t.relation.resource]:void 0,c=o&&o.primaryKey.length===1?o:void 0;return{key:e,label:a,...[`integer`,`bigint`,`decimal`].includes(t.type)&&{align:`right`,width:`minmax(6rem,0.6fr)`},cell:r=>{let i=y.value(r.id,e),o=i==null||i===``?void 0:String(i);return(0,V.jsx)(Y,{field:t,hints:n,label:a,lineNumber:A(r),resource:u.name,value:i,stored:r.stored?.[e],relationLabel:o===void 0?void 0:C[`${r.id}/${e}`]??h.labels[e]?.[o],relationTo:c&&o!==void 0?{kind:`record`,resource:c.name,key:o}:void 0,relationPicker:c&&{target:c,view:s[c.name]},locked:!k(r),problem:j(r)?.fields[e],onChange:t=>{if(!c||!v(t))return y.change(r.id,e,t);w(n=>({...n,[`${r.id}/${e}`]:t.label})),y.change(r.id,e,_(c,t.key))}})}}});return(0,V.jsxs)(o,{title:l.title,help:l.help,children:[!h.complete&&(0,V.jsx)(`p`,{className:`mb-2 text-muted-foreground`,children:g(`tooManyLines`,{limit:a(1e3)})}),(0,V.jsx)(`div`,{className:`-mx-4 overflow-x-auto px-4 [-webkit-overflow-scrolling:touch] md:mx-0 md:px-0`,children:(0,V.jsx)(`div`,{style:{minWidth:R(M)},children:(0,V.jsx)(J,{lines:y.shown,columns:M,lineName:e=>d(u,S,e.stored??{},``)||g(`lineNumber`,{place:A(e)}),onReorder:e=>y.setOrder(e.map(e=>e.id)),reorderable:E,onAdd:D?()=>void y.add():void 0,onRemove:D||O?e=>y.remove(e.id):void 0,removable:e=>e.stored?O&&x(e.stored,`delete`):D,lineError:e=>{let t=j(e);if(t&&!m.some(e=>t.fields[e]))return t.message}})})})]})};export{X as RecordLines};
|
|
2
|
-
//# debugId=2c563424-cac1-4f5f-97ca-27af43642a54
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/record-map-SrorcD8G.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/maplibre-BNosce4R.js","assets/app-1j5nx8lw.js","assets/vendor-t7Q7QbPu.js","assets/app-Dq5eubgK.css","assets/lib-maplibre-gl-CFGgq6sa.js","assets/lib-maplibre-gl-DBE96hFo.css","assets/lib-vis.gl-react-maplibre-1cv426UN.js","assets/lib-pmtiles-G7iEFxNu.js","assets/lib-fflate-HbhbPPwS.js","assets/record-lines-sVjQkysF.js","assets/embedded-list-CQ7VmI-J.js","assets/update-set-BQN3GDI3.js","assets/layout-grid-IQchsfWp.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-C8xkvcPt.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/composer-section-BWJgscVY.js","assets/render-node-eKuGRuq5.js","assets/circle-alert-CCchwpE2.js","assets/page-header-Ddz2r5ic.js","assets/pending-invitation-row-nDslRIg_.js","assets/person-row-RUXD4Z6I.js","assets/use-paged-search-DvGQocxR.js","assets/client-publisher-D39SlIhp.js","assets/copy-field-DJZYMDoO.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,r as n,t as r}from"./react-CuiNlnus.js";import{$ as i,$c as a,$s as o,An as s,Ao as c,Ba as l,Bc as u,Bi as d,Bn as f,C as p,Ca as m,D as h,Dc as g,Di as _,Dn as v,Do as y,Dr as b,Dt as x,E as S,Ei as C,Et as w,Fa as ee,Fl as T,Go as E,Hn as D,I as O,Ii as k,Ir as A,Jc as j,Jn as M,Js as te,Ks as N,Li as P,Lr as ne,Ls as re,Lt as ie,Mc as ae,Mn as oe,Nc as F,Ni as se,Nl as I,No as ce,Nr as le,O as ue,Oa as de,On as fe,Oo as pe,Or as me,Ot as he,P as L,Pa as ge,Po as _e,Qi as ve,Qs as R,R as ye,Sa as be,Si as xe,Tc as Se,Tr as Ce,Tt as we,Us as Te,Vc as z,Vi as Ee,Vl as B,Vs as De,Wc as V,Xo as H,Yo as U,Ys as W,Z as Oe,Zo as ke,Zs as G,_ as Ae,_i as je,_l as Me,_n as Ne,b as Pe,bi as Fe,bn as Ie,ci as Le,cl as Re,co as ze,ct as K,d as Be,da as Ve,en as He,et as Ue,f as We,g as q,gi as Ge,h as Ke,hi as qe,ho as Je,ia as Ye,it as Xe,ja as Ze,jn as Qe,jo as $e,k as et,ki as tt,ko as nt,l as rt,m as it,mi as at,mn as ot,mo as st,mr as J,nc as ct,nr as lt,nt as ut,ot as dt,p as ft,po as pt,qs as mt,rl as ht,rr as gt,rs as Y,rt as _t,s as vt,ss as yt,st as bt,uc as xt,ui as St,un as Ct,us as wt,v as Tt,w as Et,wc as Dt,wn as Ot,wr as kt,x as At,xa as jt,xi as Mt,xn as Nt,y as Pt,yn as Ft,zi as It,zl as Lt}from"./app-1j5nx8lw.js";import{C as Rt,h as zt,i as Bt,o as Vt,r as Ht,s as Ut}from"./vendor-t7Q7QbPu.js";import{Ct as Wt,Dt as Gt,Et as Kt,Mt as qt,Tt as Jt,_ as Yt,a as Xt,c as Zt,lt as Qt,n as $t,ot as en,pt as tn,rt as nn,s as rn,t as an,tt as on,yt as sn}from"./embedded-list-CQ7VmI-J.js";import{a as cn,i as ln,n as un,r as dn,t as fn}from"./reorder-button-DFrAk-Xc.js";import{a as pn,c as mn,i as hn,l as gn,n as _n,o as vn,r as yn,s as bn,t as xn}from"./render-node-eKuGRuq5.js";import{t as Sn}from"./trash-Du1HjUvA.js";import{n as Cn,t as wn}from"./record-sidebar-HqyBXBwn.js";import{t as Tn}from"./start-block-queries-CAEd4yVp.js";import{n as En,t as Dn}from"./record-opens-BkQP4ve9.js";import{u as On}from"./messages-DAlS_OLf.js";var kn={name:`images`,size:24,node:[[`path`,{d:`m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16`,key:`9kzy35`}],[`path`,{d:`M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2`,key:`1t0f0t`}],[`circle`,{cx:`13`,cy:`7`,r:`1`,fill:`currentColor`,key:`1obus6`}],[`rect`,{x:`8`,y:`2`,width:`14`,height:`14`,rx:`2`,key:`1gvhby`}]]};kn.node;var An=ae(kn),jn={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};jn.node;var Mn=ae(jn),Nn={name:`list-tree`,size:24,node:[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]};Nn.node;var Pn=ae(Nn),Fn={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};Fn.node;var In=ae(Fn),Ln={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};Ln.node;var Rn=ae(Ln),X=e(r(),1),zn=({collection:e,title:t,badge:n,lastEditedBy:r,presence:i=[],actions:a})=>(0,X.jsxs)(`header`,{className:`flex flex-col gap-4 border-b border-border pb-6 md:flex-row md:items-end md:justify-between md:gap-6`,children:[(0,X.jsxs)(`div`,{children:[e&&(0,X.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,X.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-foreground md:text-2xl`,children:t}),n]}),r&&(0,X.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:r.name?(0,X.jsxs)(X.Fragment,{children:[K(`lastEditedBy`),` `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:r.name}),` `,r.ago]}):(0,X.jsx)(X.Fragment,{children:K(`lastUpdated`,{ago:r.ago})})})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[i.length>0&&(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(c,{people:i,size:`md`}),K(`viewing`,{count:i.length})]}),a]})]}),Z=e(t(),1),Bn=`text-base font-semibold text-foreground`,Vn=({title:e,help:t,count:n,open:r,toggle:i,children:a})=>{let o=(0,Z.useId)();return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:F(`py-8`,r&&`pb-0`),children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2`,children:[i?(0,X.jsxs)(A,{to:i,replace:!0,"aria-expanded":r,"aria-controls":o,className:F(`inline-flex items-center gap-1.5`,Bn),children:[(0,X.jsx)(Dt,{className:F(`size-4 transition-transform`,r&&`rotate-90`)}),e]}):(0,X.jsx)(`span`,{className:Bn,children:e}),n]}),t&&(0,X.jsx)(`p`,{className:F(`mt-1 max-w-xl leading-6 text-muted-foreground`,i&&`pl-5.5`),children:t})]}),r&&(0,X.jsx)(`div`,{id:o,className:`divide-y divide-border`,children:(0,X.jsx)(O.Provider,{value:2,children:a})})]})},Hn=({tabs:e})=>(0,X.jsx)(`nav`,{"aria-label":K(`tabs`),className:`overflow-x-auto py-6`,children:(0,X.jsx)(`span`,{className:Je.group(`md`),children:e.map(e=>(0,X.jsx)(A,{to:e.to,replace:!0,"aria-current":e.current?`page`:void 0,className:F(Je.option(e.current,`md`),`whitespace-nowrap`),children:e.title},e.title))})}),Un=({rows:e})=>(0,X.jsx)(`dl`,{className:`border-t border-border`,children:e.map(e=>(0,X.jsxs)(`div`,{className:F(`grid gap-x-4 border-b border-border py-2.5`,e.wide?`grid-cols-1 gap-y-1.5`:`grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`),children:[(0,X.jsxs)(`dt`,{className:`min-w-0 text-muted-foreground`,children:[e.label,e.help&&(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-faint-foreground`,children:e.help})]}),(0,X.jsx)(`dd`,{className:`min-w-0 break-words text-foreground`,children:e.value})]},e.label))}),Wn=({facts:e})=>(0,X.jsx)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-5 sm:flex sm:flex-wrap sm:gap-x-10`,children:e.map(({label:e,value:t,icon:n})=>(0,X.jsxs)(`div`,{title:e,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(n,{className:`size-5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:e})]}):e}),(0,X.jsx)(`dd`,{className:`min-w-0 break-words text-base font-semibold text-foreground`,children:t})]},e))}),Gn=`flex min-h-11 items-center gap-2 rounded-md border border-border-strong px-3 text-left hover:bg-surface disabled:cursor-default disabled:opacity-60 md:min-h-0 md:w-full md:items-start md:gap-3 md:rounded-none md:border-0 md:px-4 md:py-3`,Kn=({actions:e})=>(0,X.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:[(0,X.jsx)(`h2`,{className:`hidden border-b border-border px-4 py-2.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground md:block`,children:K(`actions`)}),(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-2 p-2 md:block md:divide-y md:divide-border md:p-0`,children:e.map(({name:e,description:t,icon:n,onRun:r,blocked:i,running:a,tone:o,render:s})=>{let c=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(n,{className:F(`size-4 shrink-0 md:mt-0.5`,o===`danger`?`text-danger-text`:`text-muted-foreground`),"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:F(`block font-medium`,o===`danger`?`text-danger-text`:`text-foreground`),children:e}),t&&(0,X.jsx)(`span`,{className:`mt-0.5 hidden text-xs leading-snug text-muted-foreground md:block`,children:t})]})]});return(0,X.jsx)(`li`,{children:s?s({className:Gn,children:c}):(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:!!i||a,title:i,className:Gn,children:c})},e)})})]}),qn=e(n(),1),Jn=1e3,Yn=(e,t,n,r,i)=>{let a=le(e?.name??``,{enabled:!!(e&&t),filter:t?`${t.name} = "${r}"`:void 0,pageSize:500,labels:i,...n&&e?.fields[n]?.sortable&&{orderBy:`${n} asc`}}),o=(0,Z.useMemo)(()=>n?[...a.items].sort((e,t)=>Number(e[n])-Number(t[n])):a.items,[a.data,n]),s=a.hasNextPage&&a.items.length<1e3;return(0,Z.useEffect)(()=>{s&&!a.isFetchingNextPage&&a.fetchNextPage()},[s,a.isFetchingNextPage]),{items:o,labels:a.labels,loading:(a.isPending||s)&&!!e,complete:!a.hasNextPage}},Xn=(e,t)=>[`${t}_at`,`${t}At`].find(t=>e.fields[t]),Zn=(e,t)=>e.sidebar?e.title?(0,X.jsx)(Cn,{title:e.title,children:t}):t:e.title?(0,X.jsx)(L,{title:e.title,children:t}):(0,X.jsx)(`section`,{className:`py-8`,children:t}),Qn=({item:e,scope:t,fallback:n})=>{let{components:r}=de(),i=r?.[e.component],a=i&&(0,X.jsx)(lt,{value:t,children:(0,X.jsx)(i,{...Me(e.props??{})})});return n===void 0?Zn(e,(0,X.jsx)(_n,{name:e.component,registered:!!i,fallback:void 0,children:a})):(0,X.jsx)(_n,{name:e.component,registered:!!i,fallback:n,children:Zn(e,a)})},$n=({component:e,scope:t,standard:n})=>{let{components:r}=de(),i=r?.[e];return i?(0,X.jsx)(l,{name:e,fallback:n,children:(0,X.jsx)(er,{children:(0,X.jsx)(lt,{value:t,children:(0,X.jsx)(i,{})})})}):n},er=({children:e})=>($e(!1),(0,X.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)]`,children:e})),tr=(e,t,n)=>`protobase:draft:${e}:${t}:${n}`,nr=(e,t,n)=>B(()=>{let r=e.getItem(t);if(r===null)return;let i=JSON.parse(r);if(i&&i.etag===n&&typeof i.fields==`object`&&i.fields!==null)return{etag:n,fields:i.fields,...Array.isArray(i.order)&&{order:i.order.map(String)}}},void 0),rr=(e,t,n)=>B(()=>n?e.setItem(t,JSON.stringify(n)):e.removeItem(t),void 0),ir=e=>ie(e)??Rn,ar=({model:e,stored:t,recordKey:n,edit:r,onDelete:i})=>{let a=ne(),{go:o}=a,s={model:e,record:t.record,key:n,etag:t.etag,permissions:t.permissions},c=Wt(e.name,s,t=>t.run?.kind===`delete`&&o({kind:`list`,resource:e.name},{replace:!0})),[l,u]=(0,Z.useState)(),d=c.actions.map(e=>{let n=c.blocked(e),r=e.run?.kind===`link`&&!n?Xt(e.run,t.record,a):void 0;return{name:e.label,icon:ir(e.icon),blocked:n,running:c.running===e.name,...Gt(e)&&{tone:`danger`},onRun:()=>Kt(e)?u(e):void c.run(e),...r&&{render:({className:e,children:t,role:n})=>(0,X.jsx)(mt,{to:r,role:n,className:e,children:t})}}}),f=c.actions.some(e=>e.run?.kind===`delete`);return{actions:[...r?[{name:q(`edit`),icon:cn,render:({className:e,children:t,role:n})=>(0,X.jsx)(A,{to:r,role:n,className:e,children:t})}]:[],...d,...i&&!f?[{name:q(`delete`),icon:Sn,tone:`danger`,onRun:i}]:[]],prompt:l&&(0,X.jsx)(Jt,{action:l,label:l.label,danger:Gt(l),records:[t.record],onCancel:()=>u(void 0),onConfirm:()=>{u(void 0),c.run(l)},onSubmit:async e=>{await c.submit(l,e),u(void 0)}})}},or=e=>{let t=ze(),{actions:n,prompt:r}=ar(e);return n.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:t?`max-md:hidden`:void 0,children:(0,X.jsx)(Kn,{actions:n})}),t&&(0,qn.createPortal)((0,X.jsx)(bt,{actions:n,label:q(`recordActions`),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))]`}),t),r]})},sr=e=>{let t=typeof e.resource==`string`?e.resource:e.resource.toModel().name;return e.op===`reorder`?`reorder ${t} by ${e.field}`:`${e.op} ${t}`},cr=(e,t)=>{let n=e.operation,r=n===void 0?void 0:t[n];return r?N(`operationFailed`,{index:n+1,label:sr(r),message:e.message}):N(`nothingSaved`,{message:e.message})},lr=(e,t)=>new e.constructor({...e.problem,detail:cr(e,t)}),ur=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),dr=({model:e,stored:t,recordKey:n,mode:r,subject:i,draftKey:a,lines:o})=>{let s=Y(),c=zt(),l=Ce(e.name,n),d=Ke(r,i),[f]=(0,Z.useState)(()=>a?nr(localStorage,a,t.etag):void 0),[m,g]=(0,Z.useState)(f?.fields??{}),[_,v]=(0,Z.useState)(!!f),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)({}),[C,w]=(0,Z.useState)({}),[ee,T]=(0,Z.useState)(0),E=Object.entries(m).filter(([n,r])=>p(e.fields[n],r,t.record[n])),D=E.length>0,O=D||!!o?.dirty;(0,Z.useEffect)(()=>{f?.order&&o?.setOrder(f.order)},[]),(0,Z.useEffect)(()=>{if(!a)return;let n=Object.fromEntries(Object.entries(m).filter(([t])=>!e.fields[t]?.sensitive)),r=Object.keys(n).length>0||!!o?.order;rr(localStorage,a,r?{etag:t.etag,fields:n,...o?.order&&{order:o.order}}:void 0)},[a,e,m,o?.order,t.etag]);let k=n=>n in m?m[n]:[`boolean`,`file`].includes(e.fields[n].type)?t.record[n]:h(t.record[n]),A=(n,r)=>{w(e=>ur(e,n));let i=typeof r==`string`?r!==h(t.record[n]):p(e.fields[n],r,t.record[n]);g(e=>i?{...e,[n]:r}:ur(e,n))},j=async()=>{let r=await s.get(e.name,n);c.setQueryData(u.record(e.name,n),r);let i={},a={};for(let[n,o]of Object.entries(m)){let s=e.fields[n];p(s,o,r.record[n])&&(a[n]=o,h(r.record[n])!==h(t.record[n])&&(i[n]=s.type===`file`?qe(s,r.record[n]):h(r.record[n])))}g(a),S(i)},M=()=>Object.fromEntries(E.map(([t,n])=>[t,et(e.fields[t],n)])),te=e=>{let t=Tt(e);w(t),Object.keys(t).length>0&&T(e=>e+1)},N=async()=>{try{await l.mutateAsync({patch:M(),etag:t.etag})}catch(e){throw kt(e)?await j():re(e)&&te(e),e}},P=async r=>{let i=D?[{op:`update`,resource:e.name,key:n,data:M(),etag:t.etag}]:[],a=[...i,...r.ops];try{await s.batchWrite(a)}catch(e){if(kt(e))await j(),await c.invalidateQueries({queryKey:[`list`]}),b(!0);else if(re(e)){let t=e.operation===void 0?-1:e.operation-i.length,n=r.rows[t];t<0?te(e):n&&o?.reject(n,e)}throw re(e)?lr(e,a):e}await Promise.all([c.invalidateQueries({queryKey:u.record(e.name,n)}),c.invalidateQueries({queryKey:[`list`]}),c.invalidateQueries({queryKey:[`page`]}),c.invalidateQueries({queryKey:[`map`]}),c.invalidateQueries({queryKey:[`aggregate`]})]),o?.reset()};return{value:k,change:A,save:()=>d.run(async()=>{let e=o?.plan();e&&e.ops.length>0?await P(e):await N(),g({}),S({}),w({}),b(!1),v(!1)}),dirty:O,discard:()=>{g({}),S({}),w({}),b(!1),v(!1),o?.reset()},restored:_&&O,dismissRestored:()=>v(!1),linesConflict:y,saving:d.phase===`saving`,phase:d.phase,message:d.message,conflicts:x,errors:C,rejections:ee,keepMine:e=>S(t=>ur(t,e)),useTheirs:e=>{S(t=>ur(t,e)),g(t=>ur(t,e))}}},Q=z(`focus-record`),fr=({fields:e,onKeepMine:t,onUseTheirs:n})=>(0,X.jsx)(X.Fragment,{children:e.map(({name:e,label:r})=>[(0,X.jsx)(R,{size:`sm`,onClick:()=>t(e),children:Q(`keepMine`,{field:r})},`mine:${e}`),(0,X.jsx)(R,{size:`sm`,onClick:()=>n(e),children:Q(`useTheirs`,{field:r})},`theirs:${e}`)])}),pr=({record:e,label:t})=>{let{dirty:n,saving:r,save:i}=e,a=_t(`primary`),o=dt()?.size===`compact`,s=(0,X.jsx)(R,{variant:!a||n?`primary`:`secondary`,loading:r,"aria-disabled":!n,className:`max-md:min-h-11`,onClick:()=>void(n&&!r&&i()),children:t});return o&&!n?null:a?(0,X.jsx)(ut,{zone:`secondary`,children:s}):(0,X.jsx)(ut,{zone:`primary`,fallback:!0,children:s})},mr=({record:e,saved:t,readOnly:n})=>{let r=dt()?.size,i=n?Q(`readOnly`):e.saving?Q(`saving`):e.dirty?Q(r===`wide`?`unsaved`:`unsavedShort`):t?Q(`saved`):void 0;return i?(0,X.jsx)(ut,{zone:`state`,fallback:!0,children:(0,X.jsxs)(`span`,{role:`status`,title:n?Q(`readOnlyWhy`):void 0,className:`flex items-center gap-1 truncate`,children:[!n&&!e.dirty&&!e.saving&&(0,X.jsx)(g,{className:`size-3.5 text-success-text`,"aria-hidden":!0}),i]})}):null},hr=({model:e,recordKey:t,stored:n,page:r})=>{let o=H().views[e.name],{address:s,go:c}=ne(),l=It()(e,o,n.record,t),{state:d}=wt(),f=dr({model:e,stored:n,recordKey:t,mode:`button`,subject:l,draftKey:d.kind===`signed-in`?`${tr(d.user.id,e.name,t)}:focus`:void 0});Te(f.dirty||f.saving),yt(f.dirty);let p=zt(),[h,g]=(0,Z.useState)(!1),_=o?.names?.singular??a(e.name),v=ke(e.name),y=dn(e),b=s?.kind===`record`&&s.version!==void 0&&s.version!==Number(n.record.version),x=`surface`in r&&(m(n.permissions,r.surface)===`read`||e.fields[r.surface]?.readOnly===!0),S=be(v,`update`)&&n.permissions?.update!==!1&&!x,C=!S||b,w=be(v,`delete`)&&n.permissions?.delete!==!1,ee=ln({model:e,view:o,restore:y,onDeleted:()=>c({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void p.invalidateQueries({queryKey:u.record(e.name,t)})}),{actions:T,prompt:E}=ar({model:e,stored:n,recordKey:t,onDelete:w?()=>void ee.start({key:t,title:l,etag:n.etag,snapshot:n.record}):void 0}),D=(0,Z.useMemo)(()=>({kind:`record`,resource:e.name,key:t,standard:!0}),[e.name,t]),O=T.filter(e=>e.tone===`danger`),k=[...T.filter(e=>e.tone!==`danger`),...f.dirty?[{name:Q(`discardChanges`),icon:In,onRun:()=>g(!0)}]:[],{name:Q(`detailsOf`,{noun:_}),icon:Pn,render:({className:e,children:t,role:n})=>(0,X.jsx)(A,{to:D,role:n,className:e,children:t})},...O],j={model:e,record:n.record,key:t,...n.etag!==void 0&&{etag:n.etag},...n.permissions&&{permissions:n.permissions},readOnly:C,mayUpdate:S,value:f.value,change:(e,t)=>C?void 0:f.change(e,t),dirty:f.dirty,saving:f.saving,refused:f.message!==void 0,save:async()=>!C&&!!await f.save(),discard:f.discard,details:D},M=`surface`in r?r.surface:void 0,te=h&&f.dirty&&(0,X.jsx)(Ue,{level:`draft`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{size:`sm`,variant:`danger`,onClick:()=>{f.discard(),g(!1)},children:Q(`discardChanges`)}),(0,X.jsx)(R,{size:`sm`,onClick:()=>g(!1),children:Q(`keep`)})]}),children:Q(`discardAsk`)}),N=Object.keys(f.conflicts).length>0,P=M?f.errors[M]:void 0,re=P&&M?Pt(e.fields[M],o?.fields[M]?.label??a(M),P):void 0;return(0,X.jsxs)(Oe.Provider,{value:j,children:[!C&&(0,X.jsx)(pr,{record:j,label:Q(`save`)}),(0,X.jsx)(mr,{record:j,saved:f.phase===`saved`,readOnly:C}),(0,X.jsx)(i,{actions:k}),f.message&&!h&&(0,X.jsxs)(Ue,{level:`refused`,actions:(0,X.jsx)(A,{to:D,className:`text-body font-medium text-primary-text hover:underline`,children:Q(`detailsOf`,{noun:_})}),children:[(0,X.jsx)(`strong`,{className:`font-medium`,children:Q(`notSaved`)}),` `,re??f.message]}),N&&(0,X.jsx)(Ue,{level:`conflict`,actions:(0,X.jsx)(fr,{fields:Object.keys(f.conflicts).map(e=>({name:e,label:o?.fields[e]?.label??a(e)})),onKeepMine:f.keepMine,onUseTheirs:f.useTheirs}),children:Q(`conflict`)}),te,f.restored&&!h&&(0,X.jsx)(Ue,{level:`draft`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{size:`sm`,onClick:f.dismissRestored,children:Q(`keep`)}),(0,X.jsx)(R,{size:`sm`,onClick:f.discard,children:Q(`discard`)})]}),children:Q(`restored`)}),M?(0,X.jsx)(gr,{model:e,name:M,stored:n,editor:f,readOnly:C}):(0,X.jsx)(_r,{name:r.component,model:e,stored:n,recordKey:t}),ee.dialogs,E]})},gr=({model:e,name:t,stored:n,editor:r,readOnly:i})=>{let a=H().views[e.name]?.fields[t];if(m(n.permissions,t)===`hidden`)throw Error(`The surface's field ${t} is hidden from this reader`);return(0,X.jsx)(`div`,{className:`absolute inset-0`,children:(0,X.jsx)(Pe,{field:e.fields[t],hints:a,value:r.value(t),stored:n.record[t],locked:i,invalid:!!r.errors[t],resource:e.name,onChange:e=>r.change(t,e)})})},_r=({name:e,model:t,stored:n,recordKey:r})=>{let i=de().components?.[e];if(!i)throw Error(`No component is registered as ${e}`);return(0,X.jsx)(`div`,{className:`absolute inset-0`,children:(0,X.jsx)(lt,{value:{model:t,record:n.record,key:r,etag:n.etag,permissions:n.permissions},children:(0,X.jsx)(i,{})})})},vr=({model:e,recordKey:t,stored:n,page:r,standard:i})=>{let a=It()(e,H().views[e.name],n.record,t);return(0,X.jsx)(l,{name:`surface`in r?r.surface:r.component,fallback:i,resetKey:e,children:(0,X.jsx)(Xe,{label:a,children:(0,X.jsx)(hr,{model:e,recordKey:t,stored:n,page:r})})})},yr=(0,Z.lazy)(()=>Rt(()=>import(`./record-map-SrorcD8G.js`).then(e=>({default:e.RecordMap})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),br=15,xr=({item:e,record:t})=>{let n=H().maps,r=n?.style,i=Yt(t,e);if(!r||!i)return null;let a=(0,X.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted ${e.sidebar?`h-48`:`h-64 md:h-80`}`,children:(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(yr,{style:r,layers:n?.layers,position:i,zoom:e.zoom??br},`${i.latitude},${i.longitude}`)})});return e.sidebar?(0,X.jsx)(Cn,{title:e.title,children:a}):(0,X.jsx)(L,{title:e.title,children:a})},Sr={"1h":`minute`,"24h":`5_minutes`,"7d":`hour`},Cr=(e,t,n)=>{let r=new Map;e.forEach((e,i)=>{for(let a of e){let e=Date.parse(`${String(a.value)}Z`),o=r.get(e)??{at:e,value:null,count:0};o[t[i]]=a[n]??null,o.count=Math.max(o.count,a.count),r.set(e,o)}});let i=Object.fromEntries(t.map(e=>[e,null]));return[...r.values()].sort((e,t)=>e.at-t.at).map(e=>({...i,...e}))},wr=z(`app/record-chart`),Tr=I(),Er=[`1h`,`24h`,`7d`],Dr={"1h":`hour`,"24h":`day`,"7d":`week`},Or=({item:e,recordKey:t})=>{let{resources:n,views:r}=H(),[i,o]=(0,Z.useState)(e.range??`1h`),[s,c]=(0,Z.useState)(`average`),l=n[e.resource],u=r[e.resource],d=Sr[i],f=T(Tr.eq(e.field,t)),p=e.series.map(t=>({groupBy:e.at,filter:f,...s===`average`?{average:t}:{maximum:t},range:i,granularity:d,timeZone:Ve()})),m=me(e.resource,p,!!l);if(!l)return null;let h=e.series.map(e=>({kind:s,field:l.fields[e],...u?.fields[e]&&{hints:u.fields[e]}})),g=e.series.map((e,t)=>({key:`s${t}`,label:u?.fields[e]?.label??a(e),color:`var(--chart-${t+1})`,measure:h[t]})),_=m.every(e=>e.data)?Cr(m.map(e=>e.data.groups),g.map(e=>e.key),s):[],v=(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(st,{label:wr(`measure`),value:s,onChange:c,options:[{value:`average`,label:wr(`average`)},{value:`maximum`,label:wr(`maximum`)}]}),(0,X.jsx)(st,{label:wr(`range`),value:i,onChange:o,options:Er.map(e=>({value:e,label:wr(Dr[e])}))})]});return(0,X.jsx)(L,{title:e.title,help:e.help,actions:v,children:m.some(e=>e.error)?(0,X.jsx)(`p`,{className:`text-danger-text`,children:wr(`couldNotLoad`)}):m.some(e=>e.isPending)?(0,X.jsx)(W,{className:`h-40 w-full`}):_.every(e=>e.count===0)?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:wr(`noSamples`)}):(0,X.jsx)(tn,{points:_,measure:h[0],bucket:d,type:`line`,series:g,...g.length>1&&{resource:e.resource,view:u}})})},kr=z(`app/record-trend`),Ar=(e,t)=>kr(`total_${t}`,{count:e}),jr=I(),Mr={kind:`count`},Nr=({item:e,recordKey:t})=>{let n=T(jr.eq(e.field,t)),r=b(e.resource,{groupBy:e.at,filter:n,granularity:e.granularity,range:e.range,timeZone:Ve()});return(0,X.jsx)(L,{title:e.title,help:e.help,children:(0,X.jsx)(`div`,{"aria-busy":r.isPending,children:(()=>{if(r.isPending)return(0,X.jsx)(W,{className:`h-[calc(10rem+2rem)] w-full`});if(r.error)return(0,X.jsx)(J,{title:kr(`couldNotLoad`),error:r.error,onRetry:()=>void r.refetch()});let t=r.data.groups.reduce((e,t)=>e+t.count,0);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mb-3 leading-5 text-foreground`,children:Ar(t,e.range)}),(0,X.jsx)(tn,{points:sn(r.data.groups,Mr),measure:Mr,bucket:e.granularity,type:`bar`})]})})()})})},Pr=(e=[],t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],Fr=(e,t=[],n)=>!e.collapsed||t.includes(e.title)||e.items.some(e=>e.kind===`section`&&e.fields.some(n)),Ir=e=>{let t=e.findIndex(e=>e.kind===`tab`);if(t===-1)return{before:e,tabs:[],after:[]};let n=[];for(let r of e.slice(t)){if(r.kind!==`tab`)break;n.push(r)}return{before:e.slice(0,t),tabs:n,after:e.slice(t+n.length)}},Lr=(e,t)=>e.find(e=>e.title===t)??e[0],Rr=e=>Re(e.items).flatMap(e=>e.kind===`section`?e.fields:[]),zr=(e,t,n)=>{if(t&&!Rr(t).some(n))return e.find(e=>Rr(e).some(n))},Br={added:[],edits:{},removed:[]},Vr=(e,t)=>{let n=[...e.filter(e=>!t.removed.includes(e)),...t.added];return t.order?[...t.order.filter(e=>n.includes(e)),...n.filter(e=>!t.order.includes(e))]:n},Hr=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return i&&p(i,r,n[t])?[[t,et(i,r)]]:[]})),Ur=(e,t)=>Object.fromEntries(Object.entries(t).flatMap(([t,n])=>{let r=e.fields[t];return!r||r.type!==`boolean`&&String(n??``).trim()===``?[]:[[t,et(r,n)]]})),Wr=({model:e,position:t,link:n,stored:r,state:i})=>{let a={ops:[],rows:[]},o=(e,t)=>{a.ops.push(e),a.rows.push(t)},s=new Map(r.map(t=>[d(e,t),t])),c=[...s.keys()],l=Vr(c,i),u=t=>Ee(e,s.get(t)),f=e=>{let t=s.get(e).etag;return typeof t==`string`?t:void 0};for(let t of i.removed){if(!s.has(t))continue;let n=f(t);o({op:`delete`,resource:e.name,key:u(t),...n&&{etag:n}},t)}let p=new Set;for(let[t,n]of Object.entries(i.edits)){if(!s.has(t)||i.removed.includes(t))continue;let r=Hr(e,n,s.get(t));if(Object.keys(r).length===0)continue;let a=f(t);o({op:`update`,resource:e.name,key:u(t),data:r,...a&&{etag:a}},t),p.add(t)}let m=l.filter(e=>s.has(e)),h=l.filter(e=>!s.has(e)),g=(e,t)=>Object.fromEntries(e.flatMap(e=>{let n=t||p.has(e)?`*`:f(e);return n?[[ht(u(e)),n]]:[]})),_=(n,r,i)=>({op:`reorder`,resource:e.name,field:t,keys:n,...r!==1&&{start:r},etags:i}),v=(r,a,o)=>({op:`create`,resource:e.name,data:{...Ur(e,i.edits[r]??{}),[n.field]:n.value,[t]:a},...o&&{ref:o}}),y=e=>Number(e[t])||0,b=m.some((e,t)=>e!==c.filter(e=>m.includes(e))[t]);if(h.every(e=>l.indexOf(e)>=m.length)){b&&o(_(m.map(u),1,g(m,!1)));let e=b?m.length:Math.max(0,...m.map(e=>y(s.get(e))));return h.forEach((t,n)=>o(v(t,e+1+n),t)),a}let x=Math.max(l.length,...r.map(y))+1;m.length>0&&o(_(m.map(u),x,g(m,!1)));let S=e=>`line${h.indexOf(e)+1}`;for(let e of h)o(v(e,l.indexOf(e)+1,S(e)),e);return o(_(l.map(e=>s.has(e)?u(e):{$ref:S(e)}),1,g(m,!0))),a},Gr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Kr=(e,t)=>{let[n,r]=(0,Z.useState)(Br),[i,a]=(0,Z.useState)(),o=(0,Z.useRef)(1),s=(0,Z.useMemo)(()=>new Map(e?t.map(t=>[d(e.model,t),t]):[]),[e,t]),c=Vr([...s.keys()],n).map(e=>({id:e,stored:s.get(e)})),l=()=>e?Wr({...e,stored:t,state:n}):{ops:[],rows:[]},u=l().ops.length>0,f=(0,Z.useMemo)(()=>{let e=Vr([...s.keys()],n).filter(e=>s.has(e)),t=[...s.keys()].filter(t=>e.includes(t));return n.order!==void 0&&e.some((e,n)=>e!==t[n])?e:void 0},[s,n]),p=(t,r)=>{let i=n.edits[t];if(i&&r in i)return i[r];let a=e?.model.fields[r],o=s.get(t)?.[r];return a?[`boolean`,`file`].includes(a.type)?o:ue(a,o):o},m=e=>a(t=>t?.id===e?void 0:t);return{shown:c,dirty:u,order:f,value:p,change:(e,t,n)=>{m(e),r(r=>({...r,edits:{...r.edits,[e]:{...r.edits[e],[t]:n}}}))},add:()=>{let e=`new:${o.current++}`;return r(t=>({...t,added:[...t.added,e]})),e},remove:e=>{m(e),r(t=>t.added.includes(e)?{...t,added:t.added.filter(t=>t!==e),edits:Gr(t.edits,e)}:{...t,removed:[...t.removed,e]})},setOrder:e=>r(t=>({...t,order:e})),reset:()=>{r(Br),a(void 0)},reject:(e,t)=>a({id:e,fields:Tt(t),message:t.message}),rejection:i,plan:l}},qr=(e,t)=>{let n=Re(t?.layout??[]).find(e=>e.kind===`related`&&e.lines===!0);if(n?.kind!==`related`)return;let r=e[n.resource],i=r?.fields[n.field],a=r?.position?.field;if(r&&i&&a&&r.position?.within===n.field)return{item:n,model:r,link:i,position:a}},Jr=(e,t,n,r)=>j(e,t).filter(t=>{let i=e.fields[t];return i&&!i.writeOnly&&t!==n&&t!==r&&t!==e.tenant&&!e.primaryKey.includes(t)}),Yr=(e,t)=>{let{resources:n,views:r}=H(),i=(0,Z.useMemo)(()=>qr(n,r[e.name]),[n,r,e]),a=i?.model,o=i?Jr(i.model,r[i.model.name],i.link.name,i.position):[],s=Yn(a,i?.link,i?.position,t,a?M(n,r,a,o):void 0),c=Kr((0,Z.useMemo)(()=>i?{model:i.model,position:i.position,link:{field:i.link.name,value:rt(e,t)}}:void 0,[i,e,t]),s.items);return{item:i?.item,model:a,columns:o,data:s,draft:c}},Xr=e=>{let t=e>=5?5:e===4?3:e;return{shown:t,more:e-t}},Zr=(e,t)=>Math.abs(e)<40||Math.abs(e)<=Math.abs(t)?0:e<0?1:-1,Qr=e=>e===`ArrowRight`?1:e===`ArrowLeft`?-1:0,$r=(e,t,n)=>Math.min(Math.max(e+t,0),Math.max(n-1,0)),ei=e=>e.key===`i`&&!e.ctrlKey&&!e.metaKey&&!e.altKey,ti=`protobase:lightbox-details`,ni=e=>B(()=>e.getItem(ti)===`true`,!1),ri=(e,t)=>B(()=>t?e.setItem(ti,`true`):e.removeItem(ti),void 0),$=z(`app/gallery`),ii=`flex size-10 shrink-0 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm transition-colors hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,ai=({title:e,photos:t,index:n,onIndex:r,onClose:i,details:a,detailsTitle:o=$(`details`)})=>{let s=(0,Z.useRef)(null),c=(0,Z.useRef)(void 0),l=(0,Z.useId)(),u=ce(),[d,f]=(0,Z.useState)(()=>ni(localStorage)),[p,m]=(0,Z.useState)(!1);G(s,!0,i),(0,Z.useEffect)(()=>m(!0),[]);let h=t.length,g=e=>{let t=$r(n,e,h);t!==n&&r(t)},v=_(t[n],{width:1600,height:1200}),y=a?.(n),b=y!==void 0,x=e=>{f(e),ri(localStorage,e)};return(0,X.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,onKeyDown:e=>{if(b&&ei(e))return e.preventDefault(),x(!d);let t=Qr(e.key);t!==0&&(e.preventDefault(),g(t))},className:`fixed inset-0 z-[90] flex flex-col overflow-y-auto overscroll-contain bg-backdrop pl-[var(--pb-safe-left)] pr-[var(--pb-safe-right)] outline-none md:flex-row`,children:[(0,X.jsxs)(`div`,{className:`flex h-dvh shrink-0 flex-col md:sticky md:top-0 md:min-w-0 md:flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 p-3 pt-[calc(0.75rem+var(--pb-safe-top))]`,children:[(0,X.jsx)(`span`,{className:`rounded-full bg-background/85 px-3 py-1 font-medium tabular-nums text-foreground`,"aria-live":`polite`,children:`${n+1} / ${h}`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,X.jsx)(`button`,{type:`button`,className:F(ii,`aria-expanded:bg-foreground aria-expanded:text-background`),"aria-label":o,"aria-expanded":d,"aria-controls":u?l:void 0,"aria-keyshortcuts":`i`,onClick:()=>x(!d),children:(0,X.jsx)(Mn,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,className:ii,"aria-label":$(`close`),onClick:i,children:(0,X.jsx)(ct,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 touch-pan-y items-center justify-center px-3 pb-[calc(0.75rem+var(--pb-safe-bottom))] md:px-16`,onPointerDown:e=>{e.pointerType===`touch`&&(c.current={x:e.clientX,y:e.clientY})},onPointerUp:e=>{c.current&&=(g(Zr(e.clientX-c.current.x,e.clientY-c.current.y)),void 0)},onPointerCancel:()=>c.current=void 0,children:[v&&(0,X.jsx)(D,{image:v,className:`max-h-full max-w-full select-none object-contain`},v.url),h>1&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:F(ii,`absolute left-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":$(`previousPhoto`),"aria-disabled":n===0,onClick:()=>g(-1),children:(0,X.jsx)(Se,{className:`size-5`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,className:F(ii,`absolute right-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":$(`nextPhoto`),"aria-disabled":n===h-1,onClick:()=>g(1),children:(0,X.jsx)(Dt,{className:`size-5`,"aria-hidden":!0})})]})]})]}),b&&d&&u&&(0,X.jsxs)(`aside`,{id:l,"aria-label":o,className:`min-h-dvh w-[360px] shrink-0 border-l border-border bg-background p-5 pt-[calc(1.25rem+var(--pb-safe-top))] text-foreground`,children:[(0,X.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:o}),y]}),(0,X.jsx)(pt,{title:o,open:b&&d&&!u&&p,onClose:()=>x(!1),children:(0,X.jsx)(`div`,{className:`pt-3`,children:y})})]})},oi=(e,t,n)=>{let r=Re(t?.layout??[]).flatMap(e=>e.kind===`section`&&it(e.when,!1)?e.fields:[]);return(r.length>0?[...new Set(r)]:Object.keys(e.fields).filter(t=>t!==e.tenant&&!e.primaryKey.includes(t))).filter(r=>e.fields[r]&&!e.fields[r].sensitive&&!n.includes(r)&&it(t?.fields[r]?.when,!1))},si=({model:e,view:t,photoKey:n,fields:r})=>{let i=ee(e.name,n),o=(t?.names?.singular??a(e.name)).toLowerCase();if(i.isPending)return(0,X.jsx)(W,{className:`h-4 w-48`});if(i.error)return(0,X.jsx)(J,{title:$(`couldNotLoadOne`,{singular:o}),error:i.error});let s=r.filter(e=>m(i.data.permissions,e)!==`hidden`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Un,{rows:s.map(n=>({label:t?.fields[n]?.label??a(n),value:(0,X.jsx)(Ft,{model:e,field:e.fields[n],value:i.data.record[n]})}))}),(0,X.jsx)(A,{to:{kind:`record`,resource:e.name,key:n},className:`mt-3 inline-block font-medium text-primary-text hover:underline`,children:$(`open`,{singular:o})})]})},ci=e=>_(e,{width:0,height:0})!==void 0,li=(e,t)=>{let n=e.primaryKey.map(e=>t[e]);if(!n.some(e=>e==null))return ht(n)},ui=(e,t,n,r)=>{let i=n===void 0?[]:t.flatMap(e=>{let t=e[n];if(!C(t)||!ci(t))return[];let i=r&&li(r,e);return[{file:t,...i!==void 0&&{key:i}}]});if(!C(e)||!ci(e))return i;let a=t=>C(t.file)&&t.file.uri===e.uri,o=i.find(a)?.key;return[{file:e,...o!==void 0&&{key:o}},...i.filter(e=>!a(e))]},di=I(),fi=(e,t,n)=>{let r=Y(),{resources:i}=H(),a=e.photos?i[e.photos.resource]:void 0,o=e.photos?T(di.eq(e.photos.field,n)):``,s=e.photos?.sort??``,c=Vt({queryKey:u.list(a?.name??``,o,s,500,`gallery`),enabled:a!==void 0,queryFn:async()=>(await r.list(a.name,{filter:o,...s&&{orderBy:s},pageSize:500})).items});return{holder:a,items:ui(e.image===void 0?void 0:t[e.image],c.data??[],e.photos?.image,a),isPending:a!==void 0&&c.isPending,error:c.error}},pi={1:[`md:col-span-4 md:row-span-2`],2:[`md:col-span-2 md:row-span-2`,`md:col-span-2 md:row-span-2`],3:[`md:col-span-2 md:row-span-2`,`md:col-span-2`,`md:col-span-2`],5:[`md:col-span-2 md:row-span-2`,``,``,``,``]},mi=({photo:e,large:t})=>{let n=_(e,t?{width:960,height:720}:{width:480,height:360});return n?(0,X.jsx)(D,{image:n,loading:`lazy`,className:`size-full object-cover transition-transform duration-300 group-hover/tile:scale-[1.02]`}):null},hi=({item:e,record:t,recordKey:n})=>{let{views:r}=H(),i=fi(e,t,n),o=ke(i.holder?.name??``),[s,c]=(0,Z.useState)();if(i.isPending)return(0,X.jsx)(L,{title:e.title,children:(0,X.jsx)(W,{className:`aspect-[4/3] w-full rounded-lg md:aspect-[2/1]`})});if(i.error)return(0,X.jsx)(L,{title:e.title,children:(0,X.jsx)(J,{title:$(`couldNotLoad`),error:i.error})});let l=i.items.length;if(l===0)return null;let{shown:u,more:d}=Xr(l),f=i.holder,p=f&&r[f.name],m=f?oi(f,p,[e.photos?.image,e.photos?.field].filter(e=>e!==void 0)):[],h=f!==void 0&&o.read!==!1&&m.length>0;return(0,X.jsxs)(L,{title:e.title,children:[(0,X.jsx)(`div`,{className:`grid aspect-[4/3] grid-cols-4 grid-rows-2 gap-1.5 overflow-hidden rounded-lg md:aspect-[2/1]`,children:i.items.slice(0,u).map((e,t)=>{let n=t===u-1&&d>0;return(0,X.jsxs)(`button`,{type:`button`,"aria-label":n?$(`showAll`,{count:l}):$(`showPhoto`,{index:t+1,count:l}),onClick:()=>c(t),className:F(`group/tile relative overflow-hidden bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,t===0?`col-span-4 row-span-2`:`max-md:hidden`,pi[u][t]),children:[(0,X.jsx)(mi,{photo:e.file,large:t===0}),n&&(0,X.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-backdrop/55 text-lg font-semibold text-white`,"aria-hidden":!0,children:`+${d}`}),t===0&&l>1&&(0,X.jsxs)(`span`,{className:`absolute bottom-2 right-2 flex items-center gap-1.5 rounded-full bg-background/85 px-2.5 py-1 text-xs font-medium tabular-nums text-foreground md:hidden`,"aria-hidden":!0,children:[(0,X.jsx)(An,{className:`size-3.5`}),l]})]},t)})}),s!==void 0&&(0,X.jsx)(ai,{title:e.title,photos:i.items.map(e=>e.file),index:s,onIndex:c,onClose:()=>c(void 0),details:e=>{let t=i.items[e]?.key;return h&&t!==void 0?(0,X.jsx)(si,{model:f,view:p,photoKey:t,fields:m},t):void 0},detailsTitle:f&&$(`holderDetails`,{singular:p?.names?.singular??a(f.name)})})]})},gi=z(`app/history`),_i=e=>e.actor?e.actor.name??e.actor.id:e.databaseRole?gi(`databaseRole`,{role:e.databaseRole}):gi(`database`),vi=(e,t,n)=>{let r=(e.operation===`create`?[]:e.changed).flatMap(r=>{let i=t.fields[r];if(!i||r===t.softDelete)return[];let o=n?.fields[r],s=o?.label??a(r);return i.sensitive||!e.before||!e.after?[{name:r,label:s}]:[{name:r,label:s,before:qe(i,e.before[r],o),after:qe(i,e.after[r],o)}]}),i=e.operation===`update`&&r.length===0?gi(`changedThis`):gi(e.operation);return{who:_i(e),verb:i,fields:r}},yi=1500,bi=(e,t,n,r)=>{let i=Y(),a=Ht({queryKey:u.history(e,t,n),initialPageParam:``,queryFn:({pageParam:r})=>i.history(e,t,{pageSize:n,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0}),{refetch:o}=a;return(0,Z.useEffect)(()=>{let e=setTimeout(()=>void o(),yi);return()=>clearTimeout(e)},[r,o]),{...a,items:a.data?.pages.flatMap(e=>e.items)??[]}},xi=()=>(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(W,{className:`h-4 w-full`},t))}),Si=({change:e,model:t,view:n})=>{let{who:r,verb:i,fields:a}=vi(e,t,n),o=Date.parse(e.at);return(0,X.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-3 first:pt-0 last:pb-0`,children:[(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),` `,(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i}),` `,(0,X.jsxs)(`time`,{dateTime:e.at,title:ve(o),className:`text-muted-foreground`,children:[`· `,Ye(Math.max(0,Math.round((Date.now()-o)/1e3)))]})]}),a.length>0&&(0,X.jsx)(`dl`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1`,children:a.map(e=>(0,X.jsxs)(`div`,{className:`contents`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,X.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.before===void 0?(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`changed`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`del`,{className:`text-muted-foreground`,children:e.before}),` → `,(0,X.jsx)(`ins`,{className:`no-underline`,children:e.after})]})})]},e.name))})]})},Ci=({item:e,model:t,view:n,recordKey:r,etag:i})=>{let a=bi(t.name,r,e.limit??10,i);return(0,X.jsx)(L,{title:e.title,children:a.isPending?(0,X.jsx)(xi,{}):a.error?(0,X.jsx)(J,{title:`Could not load the history`,error:a.error}):a.items.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`No changes kept yet.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`ol`,{className:`divide-y divide-border`,children:a.items.map(e=>(0,X.jsx)(Si,{change:e,model:t,view:n},e.id))}),a.hasNextPage&&(0,X.jsx)(R,{size:`sm`,className:`mt-4`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Show more`})]})})},wi=({comment:e})=>(0,X.jsx)(we,{text:e.body,mentions:e.mentions}),Ti=(e,t)=>{let n=Y(),r=zt();return Bt({mutationFn:r=>n.comment(e,t,r),onSuccess:()=>r.invalidateQueries({queryKey:u.comments(e,t)})})},Ei=z(`app/comments`),Di=({resource:e,recordKey:t})=>{let[n,r]=(0,Z.useState)(x),i=Y(),a=Ze(),o=Ti(e,t),s=(0,Z.useCallback)(n=>i.mentionable(e,t,n),[i,e,t]);Te(n.text.trim()!==``||o.isPending,`input-lost`);let c=()=>{n.text.trim()===``||o.isPending||o.mutate({body:n.text,mentions:he(n.text,n.picked)},{onSuccess:()=>r(x),onError:e=>a.show({state:`error`,title:Ei(`couldNotPost`),description:Le(e)})})};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(w,{"aria-label":Ei(`comment`),placeholder:Ei(`placeholder`),value:n,onChange:r,searchPeople:s,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),c())}}),(0,X.jsx)(`div`,{children:(0,X.jsx)(R,{variant:`primary`,size:`sm`,disabled:n.text.trim()===``,loading:o.isPending,onClick:c,children:Ei(`comment`)})})]})},Oi=20,ki=(e,t)=>{let n=Y(),r=Ht({queryKey:u.comments(e,t),initialPageParam:``,queryFn:({pageParam:r})=>n.comments(e,t,{pageSize:Oi,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0});return{...r,items:r.data?.pages.flatMap(e=>e.items).reverse()??[]}},Ai=()=>(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(W,{className:`h-4 w-full`},t))}),ji=({comment:e})=>{let t=e.author.name??e.author.id,n=Date.parse(e.createdAt);return(0,X.jsxs)(`li`,{className:`flex gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,X.jsx)(nt,{initials:pe(t)||`?`,hue:y(e.author.id),size:`md`,className:`ring-0`}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),` `,(0,X.jsxs)(`time`,{dateTime:e.createdAt,title:ve(n),className:`text-muted-foreground`,children:[`· `,Ye(Math.max(0,Math.round((Date.now()-n)/1e3)))]})]}),(0,X.jsx)(wi,{comment:e})]})]})},Mi=({item:e,resource:t,recordKey:n,canWrite:r})=>{let i=ki(t,n);return(0,X.jsxs)(L,{title:e.title,children:[i.isPending?(0,X.jsx)(Ai,{}):i.error?(0,X.jsx)(J,{title:Ei(`couldNotLoad`),error:i.error}):(0,X.jsxs)(X.Fragment,{children:[i.hasNextPage&&(0,X.jsx)(R,{size:`sm`,className:`mb-4`,disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:Ei(`showEarlier`)}),i.items.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:Ei(`noComments`)}):(0,X.jsx)(`ol`,{className:`divide-y divide-border`,children:i.items.map(e=>(0,X.jsx)(ji,{comment:e},e.id))})]}),r&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Di,{resource:t,recordKey:n})})]})},Ni=e=>e.kind===`group`||e.kind===`tab`?e.items:e.kind===`custom`?e.fallback??[]:[],Pi=e=>e.kind===`tab`?void 0:e.when,Fi=e=>e.flatMap(e=>[e,...Fi(Ni(e))]).filter(e=>De(Pi(e))),Ii=e=>(e.fallback??[]).map((t,n)=>[t,e.fallbackAt?.[n]??n]),Li=(e,t,n,r)=>{let i=0,a=e=>{let a=Pi(e);return De(a)?!r&&t[i++]===!0:it(a,n)},o=e=>e.flatMap(e=>{let t=a(e);if(e.kind===`custom`&&e.fallback){let n=e.fallback.map(e=>o([e])),r=n.flatMap((e,t)=>e.length>0?[t]:[]);return t?[{...e,fallback:n.flat(),fallbackAt:r}]:[]}if(e.kind!==`group`&&e.kind!==`tab`)return t?[e]:[];let n=o(e.items);return t&&n.length>0?[{...e,items:n}]:[]});return o(e)},Ri=(e,t,n,r)=>{let i=r?[]:Fi(e).map(e=>Pi(e));return Li(e,vn(i,t),n,r)},zi=I(),Bi=(e,t)=>{let[n,...r]=e.primaryKey;if(!(!e.tenantAcross||e.tenant===void 0||n===void 0||r.length>0||!e.fields[n]?.filterable))return{filter:T(zi.eq(n,t)),pageSize:1,fields:[n,e.tenant]}},Vi=(e,t,n)=>{let r=t?.[e.tenant];if(r!=null&&String(r)!==n)return String(r)},Hi=(e,t)=>{let n=Y(),{session:r,organizations:i}=wt(),a=(0,Z.useMemo)(()=>i?Bi(e,t):void 0,[i,e,t]),[o,s]=(0,Z.useState)(a?{state:`looking`}:{state:`missing`});return(0,Z.useEffect)(()=>{a&&(async()=>{let[t,i]=await Promise.all([n.list(e.name,a),r.organizations.current()]),o=Vi(e,t.items[0],i.organization?.id);if(o===void 0)return s({state:`missing`});s({state:`switching`}),await r.organizations.switchTo(o),window.location.reload()})().catch(e=>s({state:`failed`,error:e}))},[n,r,e,a]),o},Ui=(e,t,n,r)=>{let i=Y(),a=zt(),o=It(),s=Object.values(e.fields).filter(n=>n.type===`relation`&&n.relation&&n.name!==e.tenant&&r[n.name]!=null&&t[n.relation.resource]?.primaryKey.length===1),c=Ut({queries:s.map(e=>{let o=t[e.relation.resource];return fe(a,i,o,n[o.name],String(r[e.name]))})}),l=s.map(e=>({kind:`record`,resource:e.relation.resource,key:String(r[e.name])}));return{addresses:Object.fromEntries(s.map((e,t)=>[e.name,l[t]])),labels:Object.fromEntries(s.map((e,i)=>{let a=t[e.relation.resource];return[e.name,v(c[i]?.data,o,a,n[a.name],String(r[e.name]))]}))}},Wi=I(),Gi=(e,t,n,r,i)=>{if(e.primaryKey.length!==1)return[];let o=new Set(Ki(r,i).flatMap(e=>e.kind===`thread`?[`${e.resource}.${e.field}`,...e.calls?[`${e.calls.resource}.${e.calls.field}`]:[]]:e.kind===`related`&&!e.through&&!e.from?[`${e.resource}.${e.field}`]:[])),s=Object.values(t).flatMap(t=>Object.values(t.fields).filter(t=>t.type===`relation`&&t.relation?.resource===e.name&&t.relation.columns.length===1&&t.filterable).filter(e=>e.name!==t.tenant&&!o.has(`${t.name}.${e.name}`)).map(e=>({source:t,field:e.name})));return s.map(({source:e,field:t})=>{let r=n[e.name],i=r?.names?.plural??a(e.name),o=s.filter(t=>t.source.name===e.name).length>1;return{resource:e.name,field:t,label:o?`${i} (${r?.fields[t]?.label??a(t)})`:i}})},Ki=(e,t)=>e.flatMap(e=>e.kind===`group`||e.kind===`tab`?Ki(e.items,t):e.kind===`custom`&&!t(e.component)?[e,...Ki(e.fallback??[],t)]:[e]),qi=(e,t)=>({kind:`list`,resource:e.resource,filter:T(Wi.eq(e.field,t))}),Ji=I(),Yi=(e,t,n)=>{let r=Y(),i=Ut({queries:e.map(e=>{let i=T(Ji.eq(e.field,n));return{queryKey:u.list(e.resource,i,``,1,`incoming`),queryFn:async()=>{let n=await r.list(e.resource,{filter:i,pageSize:1,count:`exact`,fields:t[e.resource].primaryKey});return{count:n.totalSize??n.totalSizeEstimate,exact:n.totalSize!==void 0}}}})});return e.flatMap((e,t)=>{let n=i[t];return n.error?[]:[{relation:e,count:n.data}]})},Xi=({model:e,recordKey:t,layout:n})=>{let{resources:r,views:i}=H(),{components:a}=de(),o=Yi(Gi(e,r,i,n,e=>!!a?.[e]),r,t);return o.length===0?null:(0,X.jsx)(Cn,{title:q(`relatedRecords`),children:(0,X.jsx)(`ul`,{className:`-mx-2`,children:o.map(({relation:e,count:n})=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(A,{to:qi(e,t),className:`group flex items-center justify-between gap-3 rounded-md px-2 py-2 hover:bg-muted`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-medium text-primary-text`,children:e.label}),(0,X.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 tabular-nums text-muted-foreground`,children:[n===void 0?(0,X.jsx)(W,{className:`h-4 w-6`}):`${se(n.count)}${n.exact?``:`+`}`,(0,X.jsx)(Dt,{className:`size-4 text-faint-foreground group-hover:text-foreground`})]})]})},`${e.resource}.${e.field}`))})})},Zi=({count:e,names:t})=>e===null?null:e===void 0?(0,X.jsx)(W,{className:`inline-block h-5 w-7 rounded-full`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{dot:!1,className:F(`tabular-nums`,e===0&&`bg-transparent ring-1 ring-border ring-inset`),children:(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.toLocaleString(V())})}),(0,X.jsx)(`span`,{className:`sr-only`,children:t?K(`headingCount`,{count:e,...t}):K(`headingCountRecords`,{count:e})})]}),Qi=(e,t,n,r,i)=>{if(!(e.through||t===null)&&jt(n,r,i))return{kind:`create`,resource:e.resource,values:{[e.field]:String(t)}}},$i=({empty:e})=>(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:e??gn(`nothingYet`)}),ea=(e,t)=>(t?.names?.singular??a(e.name)).toLowerCase(),ta=({title:e,help:t,count:n,model:r,view:i,filter:s,sort:c,fields:l,button:u,empty:d,add:f})=>{let p=_e(),{resources:m}=H(),h=c||tt(r,i),g=Ne(r,{filter:s,sort:h,pageSize:2});if(g.isPending)return(0,X.jsx)(L,{title:e,help:t,count:n,children:(0,X.jsx)(W,{className:`h-24 w-full`})});if(g.error)return(0,X.jsx)(L,{title:e,help:t,count:n,children:(0,X.jsx)(J,{title:gn(`couldNotLoad`),error:g.error})});let[_,v]=g.data.items;if(!_){let a=f&&(0,X.jsxs)(A,{to:f,className:o({size:`sm`}),children:[(0,X.jsx)(xt,{className:`size-3.5`}),gn(`add`,{singular:ea(r,i)})]});return(0,X.jsx)(L,{title:e,help:t,count:n,actions:a,children:(0,X.jsx)($i,{empty:d})})}let y=ot(r,_),b=ea(r,i),x=i?.names?.plural??a(r.name),S=l.length>1,C=l.map(e=>(0,X.jsx)(mn,{scope:y,path:e,labelled:S},e)),w=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[u&&(0,X.jsx)(on,{button:u,model:r,view:i,record:_,models:m}),(0,X.jsx)(A,{to:{kind:`record`,resource:r.name,key:Ee(r,_)},className:o({size:`sm`}),children:gn(`open`,{singular:b})})]});return(0,X.jsx)(L,{title:e,help:t,count:n,actions:w,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[S?(0,X.jsx)(`dl`,{className:`flex flex-col gap-4`,children:C}):C,v&&(0,X.jsxs)(A,{to:en(r,i,p,{filter:s,orderBy:h,display:nn(i,p,{})}),className:`flex items-center gap-1 self-start font-medium text-primary-text hover:underline`,children:[Qt(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:x.toLowerCase()}),(0,X.jsx)(qt,{className:`size-3.5`,"aria-hidden":!0})]})]})})},na=I(),ra=(...e)=>{let t=e.filter(e=>!!e);return t.length===1?t[0]:t.map(e=>`(${e})`).join(` AND `)},ia=(e,t,n)=>{let{through:r}=e;if(t===null)return null;if(!r)return ra(T(na.eq(e.field,t)),e.filter);let i=r.key??n[r.resource]?.primaryKey[0],a=Lt(ra(T(na.eq(r.field,t)),r.filter));return!a.ok||!i?null:ra(T(na.related(e.field,r.resource,i,a.ast)),e.filter)},aa=e=>{if(e.some(e=>e===null))return null;if(!e.some(e=>e===void 0))return e.reduce((e,t)=>e+t,0)},oa=(e,t=!0)=>{let n=Y(),{resources:r}=H(),i=e.flatMap(({item:e,value:t})=>{let n=r[e.resource];return n?[{model:n,match:ia(e,t,r)}]:[]}),a=Ut({queries:i.map(({model:e,match:r})=>({...Ct(n,e,r??``),enabled:t&&r!==null}))});return aa(i.map(({match:e},t)=>{if(e===null)return 0;let n=a[t];return n.isError?null:n.isSuccess?n.data??null:void 0}))},sa=I(),ca=({empty:e})=>(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:e??q(`nothingYet`)}),la=({item:e,value:t,owner:n})=>{let{resources:r,views:i,pages:a}=H(),o=r[e.resource],s=o&&i[o.name],c=ia(e,t,r),[l,u]=pn(s,`related:${n}:${e.title}`,e.display),d=ke(e.resource),[f,p]=(0,Z.useState)(!1),m=oa([{item:e,value:t}],!!(e.hideEmpty||e.count));if(!o||e.hideEmpty&&(m===void 0||m===0))return null;let h={title:e.title,help:e.help,count:e.count?(0,X.jsx)(Zi,{count:m,names:s?.names}):void 0},g=rn(e,o,r),_=e.columns??j(o,s).filter(t=>t!==e.field),v=t=>c===null?(0,X.jsx)(ca,{empty:e.empty}):t(c);if(e.presentation===`cards`||e.presentation===`compact`){let t=e.presentation===`compact`?{time:e.time}:void 0,n=t?_.filter(t=>t!==e.time):_,r=e.tone===void 0||n.includes(e.tone)?n:[e.tone,...n];return(0,X.jsx)(L,{...h,children:v(n=>(0,X.jsx)(bn,{model:o,view:s,filter:n,sort:e.sort??``,fields:r,actions:e.actions??[],button:e.button,limit:e.limit??10,display:e.display,empty:e.empty,compact:t,tone:e.tone}))})}if(e.presentation===`record`)return c===null?(0,X.jsx)(L,{...h,children:(0,X.jsx)(ca,{empty:e.empty})}):(0,X.jsx)(ta,{...h,model:o,view:s,filter:c,sort:e.sort??``,fields:_,button:e.button,empty:e.empty,add:Qi(e,t,s,a,d)},c);let y=On(e,o,d),b=(0,X.jsx)(an,{view:s,value:l,onChange:u}),x=y?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!f&&b,(0,X.jsx)(fn,{size:`sm`,sorting:f,onChange:p})]}):b;return f&&y?(0,X.jsx)(L,{...h,actions:x,children:(0,X.jsx)(un,{model:o,view:s,field:y,filter:T(sa.eq(e.field,t)),columns:_})}):(0,X.jsx)(L,{...h,actions:x,children:v(t=>(0,X.jsx)($t,{model:o,view:s,filter:t,sort:e.sort??``,columns:_,limit:e.limit??10,display:l,empty:e.empty,opens:g,button:e.button},t))})},ua=(e,t,n)=>{if(e.from===void 0)return n;let r=t[e.from];return typeof r==`boolean`?r:Zt(t,e.from)??null},da=({sections:e})=>{let t=oa(e),{views:n}=H(),r=new Set(e.map(({item:e})=>e.resource)),[i]=r,a=r.size===1?n[i]?.names:void 0;return(0,X.jsx)(Zi,{count:t,names:a})},fa=(e,t,n,r,i)=>{let a=e.fields.status?.type===`enum`&&!r.includes(`status`)?`status`:void 0,o=t?.titleBadge??a;if(o===void 0||!e.fields[o]||!i(o))return;let s=n[o];if(s!=null&&s!==``)return o},pa=I(),ma=(e,t)=>T(pa.eq(e,t)),ha=({item:e,scope:t})=>{let{resources:n}=H(),[r]=vn(e.working===void 0?[]:[e.working],t),i=n[e.resource];if(!i)return null;let a=e.calls&&n[e.calls.resource],o=e.calls&&a&&{model:a,filter:ma(e.calls.field,t.key),fields:e.calls};return(0,X.jsx)(L,{title:e.title,help:e.help,children:(0,X.jsx)(yn,{children:(0,X.jsx)(hn,{model:i,filter:ma(e.field,t.key),sender:e.sender,time:e.time,text:e.text,status:e.status,calls:o,limit:e.limit,empty:e.empty,working:e.working===void 0?void 0:r===!0})})})},ga=({item:e,scope:t})=>{let n=e.tree,r=e.reads;return(0,X.jsx)(gt,{value:t,children:(0,X.jsxs)(He,{tree:n,plan:r,children:[(0,X.jsx)(Tn,{tree:n,plan:r}),(0,X.jsx)(xn,{node:n,at:``})]})})},_a=P(()=>Rt(()=>import(`./record-lines-sVjQkysF.js`).then(e=>e.RecordLines),__vite__mapDeps([12,1,2,4,5,6,13,14,15,16,17,18,19,20,21,22,23,24,25])),()=>(0,X.jsx)(W,{className:`h-32 w-full rounded-lg`})),va=P(()=>Rt(()=>import(`./composer-section-BWJgscVY.js`).then(e=>e.ComposerSection),__vite__mapDeps([26,1,2,4,5,6,27,13,14,15,16,17,18,19,20,21,22,23,24,25,28,29,30,31,32,33,34])),()=>(0,X.jsx)(W,{className:`h-24 w-full rounded-lg`})),ya=(e,t)=>t===e.tenant||e.primaryKey.includes(t),ba=(e,t,n)=>{if(t&&t.layout.length>0)return t.layout;let r=Object.values(e.fields).filter(t=>!ya(e,t.name)&&!t.writeOnly),i=r.filter(e=>!e.readOnly),a=(i.length>0&&!n?i:r).map(e=>e.name);return[{kind:`section`,title:q(`details`),fields:a},...e.history?[{kind:`history`,title:q(`history`)}]:[],...e.comments?[{kind:`comments`,title:q(`comments`)}]:[]]},xa=({resource:e,recordKey:t})=>{let{resources:n,views:r}=H(),{address:i}=ne(),a=de(),o=n[e],s=ge(e,t);if(!o)return(0,X.jsx)(U,{title:N(`notFound`),children:N(`noResource`,{name:e})});if(s.isPending)return(0,X.jsx)(k,{});if(s.error)return(0,X.jsx)(`div`,{className:`p-8`,children:re(s.error)&&s.error.status===404?(0,X.jsx)(Sa,{model:o,recordKey:t}):(0,X.jsx)(J,{title:q(`couldNotLoad`),error:s.error})});let c=(0,X.jsx)(Ca,{model:o,recordKey:t,stored:s.data,preview:s.isPlaceholderData},s.isPlaceholderData?`preview`:`loaded`),l=i?.kind===`record`&&i.file!==void 0&&!s.isPlaceholderData?Nt(a,o,s.data.record,i.file):void 0,u={kind:`record`,resource:e,key:t,...(r[e]?.recordOpens!==void 0||r[e]?.record!==void 0)&&{standard:!0}};if(l)return(0,X.jsx)(Ie,{model:o,record:s.data.record,viewed:l,back:u},l.file.uri);let d=i?.kind===`record`&&i.standard===!0,f=r[e]?.recordOpens;if(f&&!d){if(s.isPlaceholderData)return(0,X.jsx)(k,{});let e=En(f,s.data.record);if(e)return(0,X.jsx)(Dn,{to:e})}let p=r[e]?.record;if(!p||d)return c;if(s.isPlaceholderData)return(0,X.jsx)(k,{});if(`surface`in p||p.focus)return(0,X.jsx)(vr,{model:o,recordKey:t,stored:s.data,page:p,standard:c});let{record:m,etag:h,permissions:g}=s.data;return(0,X.jsx)($n,{component:p.component,scope:{model:o,record:m,key:t,etag:h,permissions:g},standard:c})},Sa=({model:e,recordKey:t})=>{let n=Hi(e,t);return n.state===`looking`?(0,X.jsx)(k,{}):n.state===`switching`?(0,X.jsx)(U,{title:q(`loading`),children:q(`openingElsewhere`)}):n.state===`failed`?(0,X.jsx)(J,{title:q(`couldNotLoad`),error:n.error}):(0,X.jsx)(U,{title:N(`notFound`),children:q(`noRecord`)})},Ca=({model:e,recordKey:t,stored:n,preview:r})=>{let i=H(),{address:c,go:l}=ne(),d=i.views[e.name],p=It()(e,d,n.record,t),{state:h}=wt(),_=Yr(e,t),v=dr({model:e,stored:n,recordKey:t,mode:d?.saveFeedback??`toast`,subject:p,draftKey:!r&&h.kind===`signed-in`?tr(h.user.id,e.name,t):void 0,lines:_.draft}),y=zt(),b=Y(),x=Ae(v.rejections),C=ke(e.name),w=dn(e),ee=c?.kind===`record`&&c.version!==void 0,T=be(C,`update`)&&n.permissions?.update!==!1&&!ee,{shown:E,offersEdit:D,editing:O}=ft(d?.recordMode,T,c?.kind===`record`&&c.edit===!0);Te(v.dirty&&E===`form`||v.saving),yt(v.dirty);let k=c?.kind===`record`?c.open:void 0,j=c?.kind===`record`&&c.edit===!0,M=c?.kind===`record`?c.tab:void 0,N=c?.kind===`record`&&c.standard===!0,P=(n=[],r=!1,i)=>({kind:`record`,resource:e.name,key:t,...r&&{edit:r},...n.length>0&&{open:n},...i&&{tab:i},...N&&{standard:N}}),re=P(k,!1,M),ae=P(k,!0,M),se=E===`form`&&d?.recordMode!==void 0&&d.recordMode!==`edit`,I=be(C,`delete`)&&n.permissions?.delete!==!1,ce=ln({model:e,view:d,restore:w,onDeleted:()=>l({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void y.invalidateQueries({queryKey:u.record(e.name,t)})}),le=Ui(e,i.resources,i.views,n.record),ue=t=>{let n=e.fields[t],r=n?.relation?i.resources[n.relation.resource]:void 0;if(r&&r.primaryKey.length===1&&t!==e.tenant&&!e.primaryKey.includes(t))return r},fe=Object.values(e.fields).filter(e=>ue(e.name)),pe={...n.record,...Object.fromEntries(fe.map(e=>[e.name,Et(e,v.value(e.name))]))},me=Ui(e,i.resources,i.views,pe),he=(e,t)=>{let n=ue(e);if(!n||!vt(t))return v.change(e,t);y.setQueryData(u.relatedLabel(n.name,t.key),{label:t.label}),v.change(e,rt(n,t.key))},{fields:ge}=de(),_e={model:e,record:n.record,key:t,etag:n.etag,permissions:n.permissions},ve=Ri(ba(e,d,E===`read`),_e,O,r),{before:Se,tabs:Ce,after:we}=Ir(ve),z=Lr(Ce,M),Ee=e=>O&&(v.errors[e]!==void 0||v.conflicts[e]!==void 0);(0,Z.useEffect)(()=>{if(v.rejections===0)return;let e=zr(Ce,z,Ee);e&&l(P(k,j,e===Ce[0]?void 0:e.title),{replace:!0})},[v.rejections]);let B=ve.flatMap(e=>e.kind===`sidebar`?e.fields:[]),De=Xn(e,`updated`),V=e=>d?.fields[e],U=t=>m(n.permissions,t)!==`hidden`&&it(V(t)?.when,O)&&(E===`form`||!e.fields[t]?.writeOnly),Oe=e=>!r||Object.hasOwn(n.record,e),G=fa(e,d,n.record,B,U),Me=G&&(0,X.jsxs)(Ot,{value:n.record[G],hints:V(G),children:[(0,X.jsxs)(`span`,{className:`sr-only`,children:[V(G)?.label??a(G),`: `]}),qe(e.fields[G],n.record[G],V(G))]}),Ne=r=>{let o=e.fields[r],s=m(n.permissions,r);if(!o||s===`hidden`)return null;let c=v.conflicts[r],l=ue(r),u=V(r)?.label??a(r),f=v.errors[r],p=E!==`form`||s===`read`;return(0,X.jsx)(ye,{name:r,label:u,required:E===`form`&&s!==`read`&&S(o),help:Be(V(r),d,O),error:f&&Pt(o,u,f),wide:Qe(ge,o,V(r)),readOnly:At(o,V(r),p,!!l),conflict:c===void 0?void 0:{user:{name:q(`someoneElse`),initials:`?`,hue:40},ago:q(`justNow`),theirValue:c||`—`,onKeepMine:()=>v.keepMine(r),onUseTheirs:()=>v.useTheirs(r)},children:Oe(r)?(0,X.jsx)(Pe,{field:o,hints:V(r),value:v.value(r),stored:n.record[r],relationLabel:me.labels[r],relationTo:me.addresses[r],relationPicker:l&&{target:l,view:i.views[l.name]},locked:p,invalid:!!v.errors[r],reveal:o.sensitive&&!o.writeOnly?()=>b.reveal(e.name,t,r):void 0,resource:e.name,record:n.record,linkText:V(r)?.format===`url`?at(e,d,r,n.record,le.labels):void 0,onChange:e=>he(r,e)}):(0,X.jsx)(W,{className:`h-9`})},o.sensitive?`${r}:${n.etag}`:r)},Ie=r=>{let i=e.fields[r],o=Oe(r)?i.sensitive?(0,X.jsx)(Pe,{field:i,hints:V(r),value:``,stored:n.record[r],locked:!0,reveal:()=>b.reveal(e.name,t,r),resource:e.name,onChange:e=>v.change(r,e)}):(0,X.jsx)(Ft,{model:e,field:i,value:n.record[r],relationLabel:le.labels[r],record:n.record,relationLabels:le.labels}):(0,X.jsx)(W,{className:`h-4 w-32`});return{label:V(r)?.label??a(r),help:Be(V(r),d,O),wide:Qe(ge,i,V(r)),value:o}},Le=ve.findIndex(e=>e.kind===`sidebar`),Re=(0,X.jsx)(wn,{title:q(`summary`),rows:B.flatMap(t=>{let r=e.fields[t];if(!r||!U(t))return[];if(!Oe(t))return[{label:V(t)?.label??a(t),value:(0,X.jsx)(W,{className:`h-4 w-24`})}];let i=n.record[t],o=Mt(r,V(t))&&typeof i==`string`&&i!==``,c=r.type===`json`&&i!=null,l=o?xe(i):c?je(i):qe(r,i,V(t)),u=r.type===`text`&&typeof i==`string`&&i!==``?Fe(V(t)):void 0,p=r.type===`enum`?(0,X.jsx)(Ot,{value:i,hints:V(t),children:l}):u?(0,X.jsx)(f,{format:u,value:l,label:at(e,d,t,n.record,le.labels)}):(0,X.jsx)(`span`,{title:Ge(r,i,void 0,V(t)),children:l}),m=oe(ge,r,V(t));return[{label:V(t)?.label??a(t),title:l,value:m?(0,X.jsx)(s,{shown:m,part:`display`,field:r,value:n.record[t],fallback:p}):p}]})}),ze=async()=>{await v.save()&&se&&l(re,{replace:!0})},K=I?()=>void ce.start({key:t,title:p,etag:n.etag,snapshot:n.record}):void 0,Ve=E===`form`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(R,{variant:`primary`,className:`max-md:min-h-11 max-md:flex-1 md:w-full`,loading:v.saving,disabled:!v.dirty&&v.phase!==`saved`,onClick:()=>void ze(),children:[v.phase===`saved`&&(0,X.jsx)(g,{className:`size-4`}),v.phase===`saved`?q(`saved`):q(`save`)]}),se&&(0,X.jsx)(A,{to:re,className:F(o(),`max-md:min-h-11 md:w-full`),onClick:e=>te(e)&&v.discard(),children:q(`cancel`)}),v.dirty&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground max-md:order-first`,children:q(`unsavedChanges`)})]}),He=(i,a)=>{if(i.kind===`group`){let e=i.items.flatMap(He);if(e.length===0)return[];let r=Fr(i,k,Ee),a=i.collapsed?P(Pr(k,i.title),j,M):void 0,o=i.items.flatMap(e=>e.kind===`related`&&(e.from===void 0||Oe(e.from))?[{item:e,value:ua(e,n.record,t)}]:[]),s=i.count?(0,X.jsx)(da,{sections:o}):void 0;return[(0,X.jsx)(Vn,{title:i.title,help:i.help,count:s,open:r,toggle:a,children:e},`group:${i.title}`)]}if(i.kind===`related`&&i.lines)return!_.model||!_.item||r?[]:[(0,X.jsx)(_a,{lines:{..._,model:_.model,item:_.item},editable:E===`form`,saving:v.saving},`lines:${i.title}`)];if(i.kind===`related`)return i.from!==void 0&&!Oe(i.from)?[]:[(0,X.jsx)(la,{item:i,value:ua(i,n.record,t),owner:e.name},`related:${i.title}`)];if(i.kind===`chart`)return[(0,X.jsx)(Or,{item:i,recordKey:t},`chart:${a}`)];if(i.kind===`trend`)return[(0,X.jsx)(Nr,{item:i,recordKey:t},`trend:${a}`)];if(r&&(i.kind===`custom`||i.kind===`map`||i.kind===`gallery`||i.kind===`blocks`))return[];if(i.kind===`custom`)return i.sidebar?[]:[(0,X.jsx)(Qn,{item:i,scope:_e,fallback:i.fallback&&(0,X.jsx)(X.Fragment,{children:Ii(i).flatMap(([e,t])=>He(e,t))})},`custom:${a}`)];if(i.kind===`map`)return i.sidebar?[]:[(0,X.jsx)(xr,{item:i,record:n.record},`map:${a}`)];if(i.kind===`gallery`)return[(0,X.jsx)(hi,{item:i,record:n.record,recordKey:t},`gallery:${a}`)];if(i.kind===`history`)return[(0,X.jsx)(Ci,{item:i,model:e,view:d,recordKey:t,etag:n.etag},`history:${a}`)];if(i.kind===`thread`)return[(0,X.jsx)(ha,{item:i,scope:_e},`thread:${a}`)];if(i.kind===`blocks`)return[(0,X.jsx)(ga,{item:i,scope:_e},`blocks:${a}`)];if(i.kind===`composer`)return r?[]:[(0,X.jsx)(va,{item:i,owner:e,recordKey:t},`composer:${a}`)];if(i.kind===`comments`)return[(0,X.jsx)(Mi,{item:i,resource:e.name,recordKey:t,canWrite:h.kind!==`visitor`},`comments:${a}`)];if(i.kind!==`section`)return[];let o=i.fields.filter(t=>e.fields[t]&&U(t)),s=E===`read`&&i.presentation===`facts`,c=s?St(n.record,o):o;return c.length===0?[]:[(0,X.jsx)(L,{title:i.title,help:We(i.helpWhen,d,O)?i.help:void 0,children:s?(0,X.jsx)(Wn,{facts:c.map(e=>({label:Ie(e).label,value:Ie(e).value,icon:ie(V(e)?.icon)}))}):E===`read`?(0,X.jsx)(Un,{rows:c.map(Ie)}):(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:c.map(Ne)})},i.title)]},Ue=(e,t)=>e.kind===`map`?(0,X.jsx)(xr,{item:e,record:n.record},`map:${t}`):e.kind===`custom`?(0,X.jsx)(Qn,{item:e,scope:_e,fallback:e.fallback&&(0,X.jsx)(X.Fragment,{children:Ii(e).map(([e,t])=>Ue(e,t))})},`custom:${t}`):null;return(0,X.jsxs)(`div`,{ref:x,className:`flex flex-1 flex-col`,inert:r,children:[ce.dialogs,(0,X.jsx)(`div`,{className:`flex-1`,children:(0,X.jsxs)(`div`,{className:F(d?.recordWidth!==`full`&&`mx-auto max-w-[1100px]`,`px-4 pb-8 pt-6 md:px-10 md:py-8`),children:[(0,X.jsx)(zn,{title:p,badge:Me}),v.message&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(J,{title:q(`notSaved`),error:Error(v.message)})}),v.linesConflict&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(J,{title:q(`linesChanged`),error:Error(q(`linesReloaded`))})}),E!==`form`&&D&&v.dirty&&(0,X.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 rounded-lg border bg-surface px-3 py-2`,role:`status`,children:[(0,X.jsx)(`span`,{children:q(`unsavedKept`)}),(0,X.jsxs)(`span`,{className:`flex gap-2`,children:[(0,X.jsx)(A,{to:ae,className:o({size:`sm`}),children:q(`continueEditing`)}),(0,X.jsx)(R,{size:`sm`,onClick:v.discard,children:q(`discard`)})]})]}),E===`form`&&v.restored&&(0,X.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 rounded-lg border bg-surface px-3 py-2`,role:`status`,children:[(0,X.jsx)(`span`,{children:q(`unsavedRestored`)}),(0,X.jsxs)(`span`,{className:`flex gap-2`,children:[(0,X.jsx)(R,{size:`sm`,onClick:v.dismissRestored,children:q(`keep`)}),(0,X.jsx)(R,{size:`sm`,onClick:v.discard,children:q(`discard`)})]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,X.jsxs)(`div`,{className:`divide-y divide-border`,children:[Se.flatMap(He),z&&(0,X.jsx)(Hn,{tabs:Ce.map((e,t)=>({title:e.title,to:P(k,j,t===0?void 0:e.title),current:e===z}))}),z&&(0,X.jsx)(`div`,{className:`divide-y divide-border`,children:z.items.flatMap(He)},`tab:${z.title}`),we.flatMap(He)]}),(0,X.jsxs)(`aside`,{className:`space-y-4 md:sticky md:top-[var(--pb-sticky-top,0px)] md:max-h-[calc(100dvh-var(--pb-sticky-top,0px)-var(--pb-sticky-bottom,0px))] md:self-start md:overflow-y-auto md:pb-4 md:pt-8`,children:[Ve&&(0,X.jsx)(`div`,{className:`hidden flex-col items-center gap-2 md:flex`,children:Ve}),!r&&(0,X.jsx)(or,{model:e,stored:n,recordKey:t,edit:D?ae:void 0,onDelete:K}),Le===-1&&Re,ve.map((e,t)=>(e.kind===`custom`||e.kind===`map`)&&e.sidebar&&!r?Ue(e,t):t===Le?(0,X.jsx)(Z.Fragment,{children:Re},`summary`):null),(0,X.jsx)(wn,{title:q(`details`),rows:[Xn(e,`created`),De].flatMap(t=>{let r=t?e.fields[t]:void 0;return!t||!r||!U(t)||B.includes(t)?[]:[{label:V(t)?.label??a(t),value:Oe(t)?(0,X.jsx)(`span`,{title:Ge(r,n.record[t],void 0,V(t)),children:qe(r,n.record[t],V(t))}):(0,X.jsx)(W,{className:`h-4 w-24`})}]})}),!r&&(0,X.jsx)(Xi,{model:e,recordKey:t,layout:ve})]})]})]})}),Ve&&(0,X.jsx)(`div`,{className:`sticky bottom-[var(--pb-sticky-bottom,0px)] z-20 flex shrink-0 items-center gap-2 border-t bg-background p-3 md:hidden`,children:Ve})]})};export{xa as RecordPage,Jn as t};
|
|
3
|
-
//# debugId=80d9b9a1-c719-4648-9381-560b5633a2d1
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-G-uTEd7F.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-1j5nx8lw.js","assets/vendor-t7Q7QbPu.js","assets/app-Dq5eubgK.css","assets/lib-xyflow-system-hojcPWkY.js","assets/lib-d3-interpolate-C7dFwq8w.js","assets/lib-d3-color-B6XHLQii.js","assets/lib-d3-selection-C1a5EtaJ.js","assets/lib-d3-drag-CUJR_Vab.js","assets/lib-d3-dispatch-Bjkn7q4t.js","assets/lib-d3-zoom-DuEhbOrX.js","assets/lib-d3-transition-CUMO2iZu.js","assets/lib-d3-timer-CduGpaSm.js","assets/lib-d3-ease-ouQSXgQM.js","assets/lib-xyflow-react-CuNAzocq.js","assets/lib-classcat-otpLnDWv.js","assets/lib-zustand-r6mNROKr.js","assets/lib-use-sync-external-store-D4s7MiFL.js","assets/lib-xyflow-react-DLioOiRN.css","assets/use-elk-u1Ql5AOs.js","assets/lib-elkjs-ylMkguT9.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$a as r,$c as i,$n as a,$o as o,$s as s,$t as c,As as l,At as u,B as d,Ba as f,Bc as p,Bi as m,Bo as h,Br as g,Bs as _,C as v,Cl as y,Cn as b,D as x,Dc as S,Ds as C,En as w,Es as T,F as E,Fn as ee,Go as D,Gs as te,Gt as ne,Ha as re,Ho as O,Hs as ie,In as ae,Ir as oe,Jc as se,Jn as ce,Jo as le,Jt as ue,Ko as de,Ln as fe,Lo as pe,Lr as me,M as he,Ma as ge,Mc as k,Ms as _e,Mt as ve,Nc as A,No as ye,Nr as be,Ns as xe,Nt as Se,Oa as Ce,Oi as we,Os as Te,Pn as Ee,Po as De,Ps as Oe,Pt as ke,Qc as Ae,Qi as je,Qn as Me,Qs as j,R as Ne,Rn as Pe,Ro as Fe,Sa as Ie,Ss as Le,Ts as Re,Ua as ze,Un as Be,Uo as M,Us as Ve,V as He,Va as N,Vc as Ue,Vi as We,Vo as Ge,Wc as Ke,Wo as qe,Ws as Je,Xa as Ye,Xc as Xe,Xo as P,Xs as F,Xt as Ze,Yn as Qe,Ys as I,Za as $e,Zi as et,Zo as tt,_ as nt,_a as rt,_c as it,_l as at,_n as ot,_s as st,_t as ct,aa as lt,al as ut,at as dt,b as ft,bs as pt,cn as mt,cr as L,da as ht,dr as gt,ds as _t,ea as vt,ec as yt,es as bt,fr as R,fs as xt,gl as St,gn as Ct,gs as wt,gt as Tt,hi as Et,hn as Dt,hs as Ot,i as kt,ia as At,in as z,ir as jt,ja as Mt,jl as Nt,js as Pt,jt as Ft,k as It,ki as Lt,ks as Rt,ln as zt,lr as Bt,ls as B,mc as Vt,mn as Ht,mr as V,ms as Ut,nn as Wt,nr as Gt,on as Kt,oo as qt,or as Jt,pn as Yt,pr as H,ps as U,qa as Xt,qo as W,qs as Zt,rl as Qt,rn as $t,rs as en,s as tn,sn as nn,sr as G,tn as rn,tr as an,uc as on,un as sn,ur as cn,us as K,v as ln,va as un,vn as dn,wc as fn,wl as pn,wn as mn,wt as hn,xi as gn,xo as q,xs as _n,y as vn,ya as yn,yi as bn,yn as xn,ys as Sn,zi as Cn,zo as J}from"./app-1j5nx8lw.js";import{C as wn,f as Tn,o as En,s as Dn}from"./vendor-t7Q7QbPu.js";import{C as On,Ct as kn,Dt as An,Et as jn,Mt as Mn,O as Nn,Ot as Pn,Q as Fn,St as In,Tt as Ln,X as Rn,Z as zn,_t as Bn,at as Vn,b as Hn,ct as Un,dt as Wn,ft as Gn,gt as Kn,it as qn,k as Jn,kt as Yn,l as Xn,lt as Zn,mt as Qn,n as $n,nt as er,o as tr,ot as nr,rt as rr,st as ir,t as ar,tt as or,ut as sr,wt as cr,x as lr,xt as ur,y as dr}from"./embedded-list-CQ7VmI-J.js";import{t as fr}from"./circle-alert-CCchwpE2.js";import{t as pr}from"./page-header-Ddz2r5ic.js";import{n as mr,t as hr}from"./pending-invitation-row-nDslRIg_.js";import{n as gr,t as _r}from"./person-row-RUXD4Z6I.js";import{n as vr,t as yr}from"./use-paged-search-DvGQocxR.js";import{n as br,t as xr}from"./client-publisher-D39SlIhp.js";import{t as Sr}from"./copy-field-DJZYMDoO.js";var Cr={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};Cr.node;var wr=k(Cr),Tr={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};Tr.node;var Er=k(Tr),Dr={name:`key-square`,size:24,node:[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]};Dr.node;var Or=k(Dr),kr={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};kr.node;var Ar=k(kr),jr={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};jr.node;var Mr=k(jr),Nr={name:`shield-user`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]};Nr.node;var Pr=k(Nr),Fr={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Fr.node;var Ir=k(Fr),Lr={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};Lr.node;var Rr=k(Lr),zr=[`done`,`error`,`running`];xe(`TextField`,!1),xe(`NumberField`,!1),xe(`DateField`,!1),xe(`BooleanField`,!1),xe(`UrlField`,!1),xe(`ChipField`,!1);var Br=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Vr=e=>typeof e!=`string`&&!e.custom&&Br.has(e.type),Hr=e=>typeof e==`string`||Vr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Ur=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Wr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),Gr=(e,{locales:t,options:n},r)=>{let i=typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))?Number(e):e;return typeof i==`number`?i.toLocaleString(t??r,n):String(i)},Kr=(e,t,n)=>{let r=e instanceof Date?e:typeof e==`string`||typeof e==`number`?new Date(e):void 0;if(!r||Number.isNaN(r.getTime()))return``;if(t.format===`relative`)return n.relative(Math.round((n.now-r.getTime())/1e3));let{showDate:i=!0,showTime:a=!1,options:o}=t,s=t.locales??n.locale;if(i&&a)return r.toLocaleString(s,o);if(a)return r.toLocaleTimeString(s,o);let c=o??(typeof e==`string`&&e.length<=10?{timeZone:`UTC`}:void 0);return r.toLocaleDateString(s,c)},qr=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,Jr=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Yr=e=>{let t=e.replace(/^[\u0000- ]+/,``).replace(/[\t\n\r]/g,``),n=/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(t)?.[1];return n===void 0?t.startsWith(`/`)||!t.includes(`:`)?e:void 0:Jr.has(`${n.toLowerCase()}:`)?e:void 0},Xr=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),Zr=e=>e==null||e===``?void 0:String(e),Qr=(e,t)=>e<t?-1:+(e>t),$r=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=Zr(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=Zr(r);s!==void 0&&!o.has(s)&&o.set(s,{id:s,value:r}),a.set(e,{id:e,row:t,...s!==void 0&&{group:s}})}let s=t.flatMap(e=>{let t=r.map(t=>Zr(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=Zr(e[i.source]),s=Zr(e[i.target]);return n===void 0||o===void 0||s===void 0||!a.has(o)||!a.has(s)?[]:[{id:n,source:o,target:s,row:e}]});return{groups:[...o.values()].sort((e,t)=>Qr(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>Qr(e.id,t.id)),edges:s.sort((e,t)=>Qr(e.source,t.source)||Qr(e.target,t.target)||Qr(e.id,t.id))}},Y=e(t(),1),X=e(n(),1),ei=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=P(),s=kn(e.name,void 0),c=Cn(),[l,u]=(0,Y.useState)(!1),d=o[e.name]?.actions?.find(e=>e.name===n);if(!d||d.run?.kind===`link`)return null;let f=t.map(t=>Ht(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let m=f.length-p.length,h=ur(`actionCount`,{label:r??d.label,count:p.length}),g=e=>s.runEach(d,p,m,e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>jn(d)?u(!0):void g(),children:h}),l&&(0,X.jsx)(Ln,{action:d,label:h,danger:i===`danger`||i===void 0&&An(d),records:p.map(e=>e.record),names:p.map(t=>In(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),g()},onSubmit:async e=>{u(!1),await g(e)}})]})},ti=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=Jt(),c=cr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,Y.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{size:`sm`,variant:f,className:i,loading:c.running,disabled:!!c.blocked,title:c.blocked,"aria-label":a===void 0?void 0:`${d}: ${a}`,onClick:()=>jn(c.action)?u(!0):void c.run(),children:d}),l&&(0,X.jsx)(Ln,{action:c.action,label:d,danger:f===`danger`,records:c.record?[c.record]:[],onCancel:()=>u(!1),onConfirm:()=>{u(!1),c.run()},onSubmit:async e=>{await c.submit(e),u(!1)}})]})},ni=({node:e,className:t})=>{let n=z(e),r=gt(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,X.jsx)(ei,{...n,model:i,items:r.items,className:t}):(0,X.jsx)(ti,{...n,className:t})},ri=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=z(e);return(0,X.jsx)(R,{title:i,description:a,actions:n.actions,className:A(`h-full`,r),children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},ii=({children:e,wrap:t=(e,t)=>(0,X.jsx)(Y.Fragment,{children:e},t)})=>{let n=gt();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...Ht(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,X.jsx)(Gt,{value:s,row:{index:o,count:i.length},children:e}),c)})},ai=({children:e})=>(0,X.jsx)(ii,{children:e}),oi=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=rn(t),f=ot(e,{filter:n,sort:r,pageSize:i,enabled:!d}),p=d??f,m=d?d.rows:f.data?.items??[];return(0,X.jsx)(R,{title:a,description:o,actions:c,className:u,children:p.isPending?(0,X.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(I,{className:`h-24 w-56`},t))}):p.error?(0,X.jsx)(V,{title:N(`couldNotLoad`),error:p.error}):m.length===0?(0,X.jsx)(H,{children:s??N(`nothingYet`)}):(0,X.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,X.jsx)(Bt,{value:{model:e,items:m,...d&&{planned:!0}},children:(0,X.jsx)(ii,{wrap:(e,t)=>(0,X.jsx)(`li`,{className:`flex w-60 shrink-0 snap-start flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:e},t),children:l})})})})},si=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=z(e),o=P().resources[i];return o?(0,X.jsx)(oi,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},ci=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=z(e),{resources:u,views:d}=P(),f=u[r];return f?(0,X.jsx)(R,{title:i,description:a,actions:t.actions,className:A(`h-full`,n),children:(0,X.jsx)(Gn,{model:f,view:d[r],...l})}):null},li=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=Ct(e,t),a=i.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(I,{className:`h-4 w-1/2`}),(0,X.jsx)(I,{className:`h-4 w-1/3`})]}):i.error?(0,X.jsx)(V,{title:N(`couldNotLoad`),error:i.error}):i.data?(0,X.jsx)(Gt,{value:i.data,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,X.jsx)(H,{children:N(`nothingYet`)});return(0,X.jsx)(`div`,{className:n,children:a})},ui=e=>{if(typeof e!=`string`&&typeof e!=`number`)return;let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?void 0:t},di=e=>e==null?``:String(e),fi=(e,t,n)=>n===0?0:(e-t)/n*100,pi=(e,t,n)=>{let r=new Map;for(let i of e){let e=ui(i[t.start]);if(e===void 0)continue;let a=ui(i[t.end]),o=Math.max(e,a??n),s=r.get(di(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(di(i[t.lane]),s);let c=s.bars.get(di(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(di(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},mi=e=>{let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start)){let e=t.find(e=>e.at(-1).end<=n.start);e?e.push(n):t.push([n])}return t},hi=(e,t,n)=>{let r=pi(e,t,n),i=[...r.values()].flatMap(e=>[...e.bars.values()].flatMap(e=>e.records));if(i.length===0)return{lanes:[],from:n,to:n};let a=Math.min(...i.map(e=>e.start)),o=Math.max(...i.map(e=>e.end)),s=o-a;return{lanes:[...r.entries()].map(([e,n])=>{let r=[...n.bars.entries()].map(([e,r])=>{let i=r.records.sort((e,t)=>e.start-t.start).map(({record:e,start:n,end:r,open:i})=>({record:e,value:e[t.color],start:n,end:r,open:i,left:fi(n,a,s),width:fi(r,a,s)-fi(n,a,s)})),o=i[0].start,c=Math.max(...i.map(e=>e.end));return{key:e,value:r.value,lane:n.value,start:o,end:c,left:fi(o,a,s),width:fi(c,a,s)-fi(o,a,s),segments:i}});return{key:e,value:n.value,rows:mi(r)}}),from:a,to:o}},gi=(e,t)=>{let n=e.end-e.start;return{left:fi(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},_i=6e4,vi=60*_i,Z=24*vi,yi=[5*_i,15*_i,30*_i,vi,3*vi,6*vi,12*vi,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],bi=365*Z,xi=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Si=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=yi.find(n=>xi(e,t,n,i,a)<=6)??Math.ceil(r/5/bi)*bi,s=[];for(let c=Math.ceil((e+i)/o)*o;c<=t+a;c+=o){let a=c-n(c-i);a+n(a)===c&&a>=e&&a<=t&&s.push({at:a,left:fi(a,e,r)})}return{daily:o>=Z,ticks:s}},Ci=e=>({lane:di(e.lane),bar:e.key}),wi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ti=(e,t)=>{let n=Object.fromEntries(new Intl.DateTimeFormat(`en-US`,{timeZone:t,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}).formatToParts(e).map(e=>[e.type,e.value]));return Date.UTC(Number(n.year),Number(n.month)-1,Number(n.day),Number(n.hour),Number(n.minute))-Math.floor(e/6e4)*6e4},Ei=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Di=({from:e,to:t,dated:n})=>{let r=n?`UTC`:ht(),i=e=>n?0:Ti(e,r),{daily:a,ticks:o}=Si(e,t,i);return(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`relative h-5 min-w-0 flex-1 border-b border-border text-xs text-muted-foreground tabular-nums`,children:o.map(e=>(0,X.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Ei(e.left)}`,style:{left:`${e.left}%`},children:a?vt(e.at+i(e.at)):lt(e.at,r)},e.at))})},Oi=(e,t,n)=>{let r=String(n),i=t?.waitingValues?.includes(r)??!1,a=t?.valueColors&&Object.hasOwn(t.valueColors,r)?t.valueColors[r]:void 0;return a!==void 0&&ut(a)?{className:de[a],striped:i}:{color:Kn(e,t,n===void 0?null:n,-1),striped:i}},ki=e=>({...e.color!==void 0&&{backgroundColor:e.color},...e.striped&&{backgroundImage:`repeating-linear-gradient(-45deg, transparent 0 4px, color-mix(in srgb, var(--background) 55%, transparent) 4px 6px)`}}),Ai=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Oi(t,n,r.value),{left:o,width:s}=gi(e,r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:A(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...ki(a)}},i)}),ji=(e,t)=>t?et(e):je(e),Mi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return N(`timelineRange`,{from:ji(n,a),to:i?N(`timelineNow`):ji(r,a)})},Ni=(e,t,n,r)=>`${Et(t.fields[r.color],e.value,n?.fields[r.color])}: ${Mi(t,r,e.start,e.end,e.open)}`,Pi=(e,t,n,r,i)=>{let a=e.segments.some(t=>t.open&&t.end===e.end);return[`${i??Et(t.fields[r.bar],e.value,n?.fields[r.bar])}: ${Mi(t,r,e.start,e.end,a)}`,...e.segments.map(e=>Ni(e,t,n,r))].join(`; `)},Fi=`absolute inset-y-0 flex overflow-hidden rounded-sm ring-offset-1 ring-offset-background outline-none hover:ring-2 hover:ring-border-strong focus-visible:ring-2 focus-visible:ring-primary`,Ii=({bar:e,model:t,view:n,fields:r,point:i,choose:a})=>{let o=P().resources[t.fields[r.bar]?.relation?.resource??``],s=w(o??t,e.key,o!==void 0),c=Pi(e,t,n,r,o?s:void 0),l={onMouseEnter:()=>i.hover(e),onMouseLeave:()=>i.hover(null),onFocus:()=>i.focus(e),onBlur:()=>i.focus(null)},u={left:`${e.left}%`,width:`max(${e.width}%, 4px)`},d=(0,X.jsx)(Ai,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,X.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Fi,...l,children:d});let f=a.chosen===e.key;return(0,X.jsx)(Zt,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:A(Fi,f&&`ring-2 ring-foreground`),...l,children:d})},Li=({shape:e,...t})=>{let{model:n,fields:r}=t,i=n.fields[r.lane];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,X.jsx)(Di,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,X.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,X.jsx)(xn,{model:n,field:i,value:e.value})}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 border-l border-border pl-px`,children:e.rows.map((e,n)=>(0,X.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,X.jsx)(Ii,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ri=({model:e,view:t,fields:n,value:r})=>{let i=Oi(e.fields[n.color],t?.fields[n.color],r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:A(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:ki(i)})},zi=({values:e,...t})=>{let n=t.model.fields[t.fields.color],r=(n.enumValues??[]).filter(t=>e.has(t));return(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(Ri,{...t,value:e}),Et(n,e,t.view?.fields[t.fields.color])]},e))})},Bi=({bar:e,...t})=>{let{model:n,view:r,fields:i}=t;if(!e)return(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:N(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:(0,X.jsx)(xn,{model:n,field:n.fields[i.bar],value:e.value})}),(0,X.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Mi(n,i,e.start,e.end,a)})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,X.jsx)(Ri,{...t,value:e.value}),Et(n.fields[i.color],e.value,r?.fields[i.color]),`: `,Mi(n,i,e.start,e.end,e.open)]},a))})]})},Vi=500,Hi=(e,t,{filter:n=``,sort:r,fields:i,limit:a})=>({queryKey:[...p.list(t.name,n,r,a,`timeline`),i.join(`,`)],queryFn:async()=>{let o=[],s;do{let c=await e.list(t.name,{filter:n||void 0,orderBy:r,pageSize:Math.min(Vi,a-o.length),fields:i,etag:!1,...s&&{pageToken:s}});o.push(...c.items),s=c.nextPageToken||void 0}while(s&&o.length<a);return{rows:o.toReversed(),cut:s!==void 0}}}),Ui=(e,{enabled:t=!0,...n})=>En({...Hi(en(),e,n),enabled:t,placeholderData:Tn}),Wi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=Te,title:s,description:c,empty:l,actions:u,className:d,choose:f,details:p})=>{let[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),v=e=>e?Ci(e):null,y={hover:e=>h(v(e)),focus:e=>_(v(e))},b=rn(i),x=Ui(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!b}),S=b??x,C=b?b.rows:x.data?.rows??[],w=!b&&x.data?.cut===!0,T=hi(C,n,Date.now());return(0,X.jsxs)(R,{title:s,description:c,actions:u,className:A(`h-full`,d),children:[(()=>{if(S.isPending)return(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(I,{className:`h-6`},t))});if(S.error)return(0,X.jsx)(V,{title:N(`couldNotLoad`),error:S.error});if(T.lanes.length===0)return(0,X.jsx)(H,{children:l??N(`nothingYet`)});let r=new Set(C.map(e=>String(e[n.color])));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(zi,{model:e,view:t,fields:n,values:r}),(0,X.jsx)(Li,{shape:T,model:e,view:t,fields:n,point:y,...f&&{choose:f}}),w&&(0,X.jsx)(H,{children:N(`timelineCut`,{count:C.length})}),(0,X.jsx)(`div`,{"aria-live":`polite`,children:(0,X.jsx)(Bi,{bar:wi(T,m)??wi(T,g),model:e,view:t,fields:n})})]})})(),p]})},Gi=(e,t)=>e.type===`integer`?Number(t):t,Ki=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=a(),o=r[e],s=t=>i({[e]:t}),c=n.model.fields[n.fields.bar],l=o===void 0?null:(0,X.jsx)(te,{name:e,children:(0,X.jsx)(li,{model:n.model,query:{filter:Bn(c,Gi(c,o),n.filter),sort:n.sort},children:t},o)});return(0,X.jsx)(Wi,{...n,choose:{barTo:s,chosen:o},details:l})},qi=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,lane:c,bar:u,start:d,end:f,color:p,children:m,...h}=z(e),{resources:g,views:_}=P(),v=g[o];if(!v)return null;let y={...h,model:v,view:_[v.name],fields:{lane:c,bar:u,start:d,end:f,color:p},readSort:Rt(e),sort:l(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,X.jsx)(Wi,{...y}):(0,X.jsx)(Ki,{...y,select:s,children:r})},Ji=({node:e,children:t})=>{let n=_e(e),r=an(),{resources:i}=P();if(!n||!r)return t;let a=r.given[n.param],o=n.resource===void 0?void 0:i[n.resource];return a===void 0||!o?null:(0,X.jsx)(te,{name:n.param,children:(0,X.jsx)(li,{model:o,query:{key:a},className:``,children:t},a)})},Yi=(0,Y.lazy)(()=>wn(()=>import(`./graph-view-G-uTEd7F.js`).then(e=>({default:e.GraphView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),Xi=(0,X.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,X.jsx)(yt,{})}),Zi=({node:e,at:t,slots:n,children:r,className:i})=>{let a=z(e),o=c(e,t),s=an(),l=o.nodes,u=o.edges,{label:d,group:f,status:p,source:m,target:h}=a,g=(0,Y.useMemo)(()=>({label:d,source:m,target:h,...f!==void 0&&{group:f},...p!==void 0&&{status:p}}),[d,m,h,f,p]),_=JSON.stringify([l?.rows,u?.rows,g]),v=(0,Y.useMemo)(()=>l&&u&&$r({nodes:l.rows,edges:u.rows,key:l.model.primaryKey[0],edgeKey:u.model.primaryKey,fields:g}),[_]);if(!l||!u||!v)return null;let y=l.error??u.error;if(y&&e.fallback)throw y;if(y)return(0,X.jsx)(V,{title:N(`couldNotLoad`),error:y});if(l.isPending||u.isPending)return Xi;if(v.nodes.length===0)return(0,X.jsx)(H,{children:a.empty??N(`nothingYet`)});let b=a.select,x=b!==void 0&&s?{chosen:s.given[b],linkTo:e=>s.linkTo({[b]:e})}:void 0;return(0,X.jsxs)(`div`,{className:A(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Y.Suspense,{fallback:Xi,children:(0,X.jsx)(Yi,{shape:v,nodes:l,edges:u,fields:g,props:a,...x&&{select:x},...a.node!==void 0&&{content:n.node}})})}),r.length>0&&x?.chosen!==void 0&&(0,X.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,X.jsx)(Ji,{node:e,children:r})})]})},Q=Ue(`app/conversation`),Qi=({resource:e,field:t,values:n,placeholder:r})=>{let{resources:i}=P(),a=en(),o=dn(),s=tt(e),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)();return!i[e]||!Ie(s,`create`)?null:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[u!==void 0&&(0,X.jsx)(V,{title:Q(`notSent`),error:u}),(0,X.jsx)(hn,{onSend:async r=>{l(!0),d(void 0);let i=await a.create(e,{...n,[t]:r}).then(()=>!0,e=>(d(e),!1));return l(!1),i&&o(e),i},busy:c,placeholder:r})]})},$i=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=z(e);return(0,X.jsx)(Qi,{resource:t,field:n,values:r,placeholder:i})},ea=({node:e,children:t,className:n})=>{let{open:r}=z(e);return(0,X.jsx)(`details`,{open:r,className:A(`[&[open]>summary]:mb-2`,n),children:t})},ta=({children:e,className:t})=>(0,X.jsx)(`summary`,{className:A(`cursor-pointer font-medium`,t),children:e}),na=({node:e,className:t})=>{let{source:n,emptyText:r}=z(e),i=zt(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,X.jsx)(I,{className:A(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,X.jsx)(`p`,{className:A(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=Tt(a);return o?(0,X.jsx)(`div`,{className:A(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,X.jsx)(ct,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,X.jsx)(`pre`,{className:A(`overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-border bg-background p-3 font-mono text-[0.6875rem] leading-[18px]`,t),children:a})},ra=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),ia=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>i(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},aa=({node:e,className:t})=>{let{source:n,label:r,format:i}=z(e),{views:a}=P(),o=zt(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,X.jsx)(I,{className:`h-4 w-24`}):o.state===`plain`?ra(o.value):(0,X.jsx)(xn,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,X.jsx)(`div`,{className:t,children:s});let c=r??ia(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:A(`min-w-0`,t),children:[(0,X.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate`,children:s})]})},oa={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},sa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ca={1:``,2:`md:col-span-2`,3:`md:col-span-2 xl:col-span-3`,4:`sm:col-span-2 md:col-span-2 xl:col-span-4`},la=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ua=({node:e,children:t,className:n})=>{let{columns:r=2}=z(e),i=e.children,a=i.length>0&&i.every(la);return(0,X.jsx)(`div`,{className:A(`grid grid-cols-1 gap-4`,a?sa[r]:oa[r],n),children:t.map((e,t)=>{let n=i[t],r=typeof n==`object`?n.props.span:void 0;return(0,X.jsx)(`div`,{className:A(`min-w-0`,r&&ca[r]),children:e},t)})})},da=({src:e,alt:t,width:n,height:r,className:i})=>(0,X.jsx)(`img`,{src:e,alt:t??``,width:n,height:r,className:i??`max-w-full`}),fa=({width:e,height:t,space:n,theme:r})=>{let i=e??Math.ceil(n/100)*100;if(i!==0)return{width:String(i),...t!==void 0&&{height:String(t)},theme:r}},pa=e=>({staleTime:1/0,refetchOnWindowFocus:!1,...e!==void 0&&{refetchInterval:e*1e3}}),ma=e=>e instanceof Blob&&e.type.startsWith(`image/`),ha=e=>{let[t,n]=(0,Y.useState)();return(0,Y.useEffect)(()=>{if(!e)return n(void 0);let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t},ga=e=>{let[t,n]=(0,Y.useState)();return[t!==void 0&&t===e,()=>n(e)]},_a=({name:e,alt:t,width:n,height:r,refresh:i,className:a})=>{let o=en(),{theme:s}=ge(),[c,l]=dt(),u=fa({width:n,height:r,space:l,theme:s}),d=En({queryKey:p.image(e,u??{}),enabled:u!==void 0,placeholderData:Tn,...pa(i),queryFn:async()=>{let t=await o.invoke(e,{query:u,cache:`no-store`});if(!ma(t))throw Error(`The function "${e}" answered no picture`);return t}}),f=ha(d.data),[m,h]=ga(f),g={...n!==void 0&&{width:n},...r!==void 0&&{height:r}};return(0,X.jsx)(`div`,{ref:c,className:A(`min-w-0`,a),children:d.isError||m?t&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:t}):f?(0,X.jsx)(`img`,{src:f,alt:t??``,onError:h,style:g,className:n===void 0?`w-full max-w-full object-contain`:`max-w-full object-contain`}):(0,X.jsx)(I,{className:`w-full max-w-full`,style:{height:r??160,...n!==void 0&&{width:n}}})})},va=({node:e,className:t})=>{let n=z(e);return n.src===void 0?(0,X.jsx)(_a,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,X.jsx)(da,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},ya=e=>function({node:t,className:n}){let r=z(t),{views:i}=P(),a=zt(r.source);return a.state===`missing`?null:a.state===`loading`?(0,X.jsx)(I,{className:`inline-block h-3 w-16 align-middle`}):Ur(t.type,a.value)?r.emptyText?(0,X.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:a.field,hints:i[a.model.name]?.fields[a.field.name],props:r})})},ba=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?Ae(e,n?.valueLabels):Wr(e),xa=ya(ba),Sa=ya(({value:e,props:t})=>(0,X.jsx)(`span`,{className:`tabular-nums`,children:Gr(e,t,Ke())})),Ca=ya(({value:e,props:t})=>{let n=Kr(e,t,{locale:Ke(),now:Date.now(),relative:At});return(0,X.jsx)(`time`,{dateTime:String(e),children:n})}),wa=ya(({value:e,props:t})=>{let n=qr(e,t,{yes:we(`yes`),no:we(`no`)});return e?(0,X.jsx)(Be,{label:n,className:`align-middle`}):(0,X.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ta=ya(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=Yr(n);return i===void 0?r:(0,X.jsx)(`a`,{href:i,className:`font-medium text-primary-text hover:underline`,.../^https?:/i.test(i)&&{target:`_blank`,rel:`noreferrer`},children:r})}),Ea=ya(e=>(0,X.jsx)(mn,{value:e.value,hints:e.hints,children:ba(e)})),Da=`font-medium text-primary-text hover:underline`,Oa=({node:e,children:t,className:n})=>{let r=z(e),i={...L(G()),params:Me()},a=r.variant?A(s({variant:r.variant}),n):n??Da,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=y(r.to,wt(i));return(0,X.jsx)(oe,{to:e,className:a,children:o??_(e)})}let c=r.href??``;return(0,X.jsx)(`a`,{href:c,className:a,...c.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??c})},ka=(e,t,n)=>Object.fromEntries(t.map(t=>{let r=e.fields[t];if(r.type===`file`)return[t,n?.[t]??null];if(n)return[t,r.type===`boolean`?!!n[t]:x(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:x(i)]})),Aa=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return tn(r)?r.key===x(n[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:v(i,r,n[t])?[[t,It(i,r)]]:[]})),ja=({model:e,record:t,mode:n,label:r,title:a,fields:o,values:s,onClose:c})=>{let{resources:l,views:u}=P(),d=en(),f=Mt(),p=dn(),m=u[e.name],[h,g]=(0,Y.useState)(()=>ka(e,o,t?.record)),[_,v]=(0,Y.useState)({}),[y,b]=(0,Y.useState)(0),x=nt(y),[S,C]=(0,Y.useState)(),[w,T]=(0,Y.useState)(!1),[E,ee]=(0,Y.useState)(!1);Ve(E||w,`input-lost`);let D=async()=>{T(!0),C(void 0),await(n===`create`?d.create(e.name,{...kt(e,l,h),...s}):d.update(e.name,t.key,Aa(e,h,t.record),t.etag??`*`)).then(async()=>{await p(e.name),f.show({state:`success`,title:N(`saved`,{label:a??r})}),c()},e=>{let t=ln(e);v(t),Object.keys(t).length>0&&b(e=>e+1),C(e)}),T(!1)};return(0,X.jsx)(F,{title:a??r,onClose:c,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:c,children:N(`cancel`)}),(0,X.jsx)(j,{variant:`primary`,loading:w,onClick:()=>void D(),children:N(n===`create`?`create`:`save`)})]}),children:(0,X.jsxs)(`form`,{ref:x,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),D()},children:[S!==void 0&&Object.keys(_).length===0&&(0,X.jsx)(V,{title:N(`notSaved`),error:S}),o.map(n=>{let r=e.fields[n],a=h[n],o=r.relation?l[r.relation.resource]:void 0,s=m?.fields[n]?.label??i(n),c=_[n];return(0,X.jsx)(Ne,{name:n,label:s,help:m?.fields[n]?.help,error:c&&vn(r,s,c),children:(0,X.jsx)(ft,{field:r,hints:m?.fields[n],value:tn(a)?a.key:a,stored:t?.record[n],relationLabel:tn(a)?a.label:void 0,relationPicker:o?{target:o,view:u[o.name]}:void 0,invalid:!!_[n],resource:e.name,onChange:e=>{v(({[n]:e,...t})=>t),ee(!0),g(t=>({...t,[n]:e}))}})},n)})]})})},Ma=({model:e,recordKey:t,children:n})=>{let r=Ct(e,{key:t});return(0,X.jsx)(X.Fragment,{children:n(r.data??void 0)})},Na=({node:e})=>{let t=z(e),n=Jt(),{resources:r}=P(),i=r[t.resource??n?.model.name??``],a=tt(i?.name??``),[o,s]=(0,Y.useState)(!1);if(!i||!(t.mode===`create`?Ie(a,`create`):Ie(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,X.jsx)(ja,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,X.jsx)(Ma,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},Pa=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=z(e);return(0,X.jsx)(`div`,{className:A(`flex-1`,r),children:(0,X.jsxs)(`div`,{className:A(`flex flex-col gap-6 px-4 pb-16 pt-6 md:px-10 md:py-8`,o!==`full`&&`mx-auto max-w-[1200px]`),children:[(0,X.jsx)(pr,{title:i,subtitle:a,actions:n.actions}),t]})})},Fa=(e,t)=>{let n=G(),r=typeof e==`string`?jt(n,e):void 0,i=nn(r&&`frame`in r?r.frame:void 0,r&&`path`in r?r.path:``);return typeof e==`number`?e:e===void 0?t:r&&`item`in r?Number(r.item):i.state===`ready`?Number(i.value):i.state===`loading`?void 0:NaN},Ia=({node:e,className:t})=>{let{value:n,max:r,label:i}=z(e),a=Fa(n,0),o=Fa(r,100);if(a===void 0||o===void 0)return(0,X.jsx)(I,{className:`h-6 w-full`});if(!Number.isFinite(a)||!Number.isFinite(o))return null;let s=o>0?Math.min(1,Math.max(0,a/o)):0;return(0,X.jsxs)(`div`,{className:A(`min-w-0`,t),children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[a.toLocaleString(Ke()),` / `,o.toLocaleString(Ke())]})]}),(0,X.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":o,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:s>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${s*100}%`}})})]})},La=({model:e,at:t,filter:n,sort:r,recordKey:i,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=rn(t),f=Ct(e,{filter:n,sort:r,key:i,enabled:!d}),p=d?Yt(e,d):f,m=e=>p.data?(0,X.jsx)(Gt,{value:p.data,children:e}):void 0,h=p.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(I,{className:`h-4 w-1/2`}),(0,X.jsx)(I,{className:`h-4 w-1/3`})]}):p.error?(0,X.jsx)(V,{title:N(`couldNotLoad`),error:p.error}):p.data?m((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:l})):(0,X.jsx)(H,{children:s??N(`nothingYet`)});return(0,X.jsx)(R,{title:a,description:o,actions:c?m(c):void 0,className:A(`h-full`,u),children:h})},Ra=({node:e,at:t,children:n,slots:r,className:i})=>{let{resource:a,filter:o,sort:s,recordKey:c,title:l,description:u,empty:d}=z(e),f=P().resources[a];return f?(0,X.jsx)(La,{model:f,...t!==void 0&&{at:t},filter:o,sort:s,recordKey:c,title:l,description:u,empty:d,actions:r.actions,className:i,children:n}):null},za=Ue(`app/related-cards`),Ba=({children:e})=>{let t=(0,Y.useRef)(null),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,Y.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=()=>a(e.scrollHeight>e.parentElement.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[n]),(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,X.jsx)(`div`,{className:A(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,X.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,X.jsx)(j,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:za(n?`showLess`:`showMore`)})]})},Va=e=>e==null||e===``,Ha=({scope:e,path:t,labelled:n=!0,clamped:r=!1})=>{let{views:i}=P(),a=nn(e,t);if(a.state===`missing`||a.state===`ready`&&Va(a.value))return null;let o=a.state===`loading`?(0,X.jsx)(I,{className:`h-4 w-24`}):(0,X.jsx)(xn,{model:a.model,field:a.field,value:a.value}),s=r?(0,X.jsx)(Ba,{children:o}):o;if(!n)return(0,X.jsx)(`div`,{className:`min-w-0`,children:s});let c=ia(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`dd`,{className:`mt-0.5`,children:s})]})},Ua=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:s})=>{let c=Cn(),{resources:l}=P(),u=c(e.model,t,e.record,e.key),d=a.length>0||o!==void 0;return(0,X.jsxs)(`li`,{"data-card":e.key,className:A(`relative grid min-w-0 items-center gap-x-4 gap-y-1 rounded-lg border border-border bg-surface px-4 py-2.5`,d?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:[i&&(0,X.jsx)(ue,{view:t,field:i,record:e.record}),(0,X.jsxs)(`div`,{className:A(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,X.jsx)(oe,{to:{kind:`record`,resource:e.model.name,key:We(e.model,e.record)},className:`line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere] text-primary-text hover:underline`,children:u}),r&&(0,X.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,X.jsx)(Ha,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-y-0.5 text-body text-muted-foreground`,children:n.map(t=>(0,X.jsx)(`div`,{className:`flex max-w-full min-w-0 items-center whitespace-nowrap empty:hidden [&>div]:truncate [:not(:empty)~&]:before:mx-2 [:not(:empty)~&]:before:content-['·'_/_'']`,children:(0,X.jsx)(Ha,{scope:e,path:t,labelled:!1})},t))}),d&&(0,X.jsx)(Gt,{value:e,children:(0,X.jsxs)(`div`,{className:`col-start-2 flex flex-wrap items-center justify-end gap-2 sm:row-span-2 sm:row-start-1`,children:[o&&(0,X.jsx)(or,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,X.jsx)(ti,{name:e,about:u,onRun:e=>s?.(e,u)},e))]})})]})},Wa=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let s=Cn(),{resources:c}=P(),l=s(e.model,t,e.record,e.key);return(0,X.jsxs)(`li`,{"data-card":e.key,className:`relative flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[r&&(0,X.jsx)(ue,{view:t,field:r,record:e.record}),(0,X.jsx)(oe,{to:{kind:`record`,resource:e.model.name,key:We(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:l}),n.length>0&&(0,X.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,X.jsx)(Ha,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,X.jsx)(Gt,{value:e,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,X.jsx)(or,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,X.jsx)(ti,{name:e,about:l,onRun:e=>o?.(e,l)},e))]})})]})},Ga=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,Ka=e=>[...e.querySelectorAll(`button`)].find(Ga)??e.querySelector(`a`),qa=(e,t,n)=>{let r=e.indexOf(n),i=e=>t.includes(e);return e.slice(r+1).find(i)??e.slice(0,Math.max(r,0)).findLast(i)},Ja=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},Ya=e=>{let t=(0,Y.useRef)(null),n=(0,Y.useRef)({current:e,previous:e}),r=(0,Y.useRef)(void 0),[i,a]=(0,Y.useState)(``),o=(e,n,i)=>{if(r.current=void 0,i.includes(e.key)||!t.current||(a(za(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=qa(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?Ka(s):Ja(t.current))?.focus()};return(0,Y.useEffect)(()=>{let t=n.current.current;n.current={current:e,previous:t},r.current&&o(r.current,t,e)},[e]),{root:t,acted:(e,t,i)=>{let{current:a,previous:s}=n.current;if(a.includes(e)){r.current={key:e,action:t,title:i};return}o({key:e,action:t,title:i},s,a)},announcement:i}},Xa=({compact:e,limit:t})=>(0,X.jsx)(`div`,{className:e?`flex flex-col gap-2`:`flex flex-col gap-3`,children:Array.from({length:e?Math.min(t,3):2},(t,n)=>(0,X.jsx)(I,{className:e?`h-17.5 w-full max-sm:h-24`:`h-24 w-full`},n))}),Za=({model:e,view:t,filter:n,sort:r,fields:a,actions:o,button:s,limit:c,display:l,empty:u,carousel:d,compact:f,tone:p,planned:m})=>{let h=De(),g=sr(),_=t?.names?.plural??i(e.name),v=r||Lt(e,t),y=ot(e,{filter:n,sort:v,pageSize:c,enabled:!m}),b=Dt(e,n,!m),x=m?m.rows:{isPending:y.isPending,error:y.error},S=m?m.rows.rows:y.data?.items,C=m?{data:m.total&&!m.total.isPending&&!m.total.error?er(m.total):void 0}:b,w=(0,Y.useMemo)(()=>(S??[]).map(t=>Ht(e,t)),[e,S]),T=Ya((0,Y.useMemo)(()=>w.map(e=>e.key),[w]));return(0,X.jsxs)(`div`,{ref:T.root,children:[(()=>{if(x.isPending)return(0,X.jsx)(Xa,{compact:!!f,limit:c});if(x.error)return(0,X.jsx)(V,{title:za(`couldNotLoad`),error:x.error});if(w.length===0)return(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:u??za(`nothingYet`)});let r=w.map(e=>{let n=(t,n)=>T.acted(e.key,t,n);return f?(0,X.jsx)(Ua,{scope:e,view:t,fields:a,time:f.time,tone:p,actions:o,button:s,onActed:n},e.key):(0,X.jsx)(Wa,{scope:e,view:t,fields:a,tone:p,actions:o,button:s,onActed:n},e.key)}),i=C.data===void 0?void 0:Un(w.length,C.data,!1);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d===void 0?(0,X.jsx)(`ul`,{className:f?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,X.jsx)(Wn,{scroll:g,label:_,share:d,children:r}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i}),(0,X.jsxs)(oe,{to:nr(e,t,h,{filter:n,orderBy:v,display:rr(t,h,{preferred:l})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[Zn(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:_.toLowerCase()}),(0,X.jsx)(Mn,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:T.announcement})]})},Qa={"1/4":1/4,"1/3":1/3,"1/2":1/2,"2/3":2/3},$a=({node:e,at:t,slots:n,className:r})=>{let i=z(e),{resource:a,filter:o=``,sort:s=``,fields:c,cardActions:l=[],limit:u=10,display:d,title:f,description:p,empty:m}=i,{layout:h,cardWidth:g}=Xr(i),{resources:_,views:v}=P(),[y,b]=Wt([t,t===void 0?void 0:`${t}#total`]),x=(0,Y.useMemo)(()=>y&&{rows:y,total:b},[y,b]),S=_[a];if(!S)return null;let C=v[S.name];return(0,X.jsx)(`section`,{className:A(`min-w-0`,r),"aria-label":f,children:(0,X.jsx)(E,{title:f,help:p,actions:n.actions,children:(0,X.jsx)(Za,{model:S,view:C,filter:o,sort:s,fields:c??se(S,C),actions:l,limit:u,display:d,empty:m,carousel:h===`carousel`?Qa[g]:void 0,...x&&{planned:x}})})})},eo=({model:e,view:t,empty:n,...r})=>{let{resources:a,views:o}=P(),s=g(a,o,e.name),c=Nn(e.name,t.listOf,!0),l=(t.names?.plural??i(e.name)).toLowerCase();if(!s.listOf)return null;if(c.error)return(0,X.jsx)(V,{title:On(`couldNotLoadYour`,{plural:l}),error:c.error});if(!c.data)return(0,X.jsx)(I,{className:`h-24`});let u=Jn(s.model,c.data);return u?(0,X.jsx)(lr,{...r,model:s.model,view:s.view,filter:``,scope:u,list:e.name,empty:n}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??On(`noneYet`,{plural:l})})},to=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=Qt(We(e,i)),{name:o,chips:s,title:c,body:l}=dr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,X.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,X.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,X.jsx)(oe,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,X.jsx)(Rn,{chips:s})})}),(0,X.jsx)(lr,{...l})]})},no=({model:e,view:t,empty:n})=>{let{resources:r,views:a}=P(),o=t.searchesOf,s=r[o.resource],c=Hn(e.name,!0),l=(t.names?.plural??i(e.name)).toLowerCase();return s?c.error?(0,X.jsx)(V,{title:zn(`couldNotLoadYour`,{plural:l}),error:c.error}):c.data?c.data.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??zn(`noneYet`,{plural:l})}):(0,X.jsx)(`div`,{className:`flex flex-col divide-y`,children:c.data.map(n=>(0,X.jsx)(to,{model:e,view:t,target:s,targetView:a[o.resource],row:n},Qt(We(e,n))))}):(0,X.jsx)(I,{className:`h-40`}):null},ro=({node:e,slots:t,className:n})=>{let{resource:r,filter:i=``,sort:a,limit:o,display:s,title:c,description:l,empty:u}=z(e),{resources:d,views:f}=P(),p=d[r];if(!p)return null;let m=f[p.name];return(0,X.jsx)(R,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,X.jsx)(no,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,X.jsx)(lr,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,X.jsx)(eo,{model:p,view:m,limit:o,display:s,empty:u})})},io=e=>e.type===`boolean`||e.type===`enum`,ao=({model:e,fields:t,title:n,description:r,stored:a,className:o})=>{let{resources:s,views:c}=P(),l=tt(e.name),u=en(),d=Mt(),f=dn(),p=c[e.name],[m,h]=(0,Y.useState)(a),[g,_]=(0,Y.useState)(()=>ka(e,t,a?.record)),[y,b]=(0,Y.useState)({}),[x,S]=(0,Y.useState)(),[C,w]=(0,Y.useState)(!1),T=(0,Y.useRef)(Promise.resolve()),E=(0,Y.useRef)(a),ee=ka(e,t,void 0),D=m?Ie(l,`update`)&&m.permissions?.update!==!1:Ie(l,`create`),te=t.filter(t=>!io(e.fields[t])),ne=te.some(t=>m?v(e.fields[t],g[t],m.record[t]):g[t]!==ee[t]),re=async t=>{let n=E.current;if(n){let r=await u.update(e.name,n.key,Aa(e,t,n.record),n.etag??`*`);return{...Ht(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await u.create(e.name,kt(e,s,{...ee,...t}));return{...Ht(e,r.record),etag:r.etag}},O=t=>{let r=T.current.then(async()=>{w(!0),S(void 0),await re(t).then(async r=>{E.current=r,h(r),b(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await f(e.name),d.show({state:`success`,title:N(`saved`,{label:n??N(`settings`)})})},e=>{b(t=>({...t,...ln(e)})),S(e)}),w(!1)});T.current=r},ie=(t,n)=>{_(e=>({...e,[t]:n})),io(e.fields[t])&&O({[t]:n})};return(0,X.jsx)(R,{title:n,description:r,className:A(`h-full`,o),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),ne&&O(Object.fromEntries(te.map(e=>[e,g[e]])))},children:[x!==void 0&&Object.keys(y).length===0&&(0,X.jsx)(V,{title:N(`notSaved`),error:x}),t.map(t=>{let n=e.fields[t],r=p?.fields[t]?.label??i(t),a=y[t];return(0,X.jsx)(Ne,{name:t,label:r,help:p?.fields[t]?.help,error:a&&vn(n,r,a),children:(0,X.jsx)(ft,{field:n,hints:p?.fields[t],value:g[t],stored:m?.record[t]??ee[t],invalid:!!a,locked:!D||n.readOnly,resource:e.name,onChange:e=>ie(t,e)})},t)}),D&&ne&&(0,X.jsx)(`div`,{children:(0,X.jsx)(j,{type:`submit`,variant:`primary`,size:`sm`,loading:C,children:N(`save`)})})]})})},oo=e=>{let t=Ct(e.model,{});return t.isPending?(0,X.jsx)(R,{title:e.title,description:e.description,className:e.className,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(I,{className:`h-4 w-1/2`}),(0,X.jsx)(I,{className:`h-4 w-1/3`})]})}):t.error?(0,X.jsx)(R,{title:e.title,description:e.description,className:e.className,children:(0,X.jsx)(V,{title:N(`couldNotLoad`),error:t.error})}):(0,X.jsx)(ao,{...e,stored:t.data??void 0})},so=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=z(e),o=P().resources[n];return o?(0,X.jsx)(oo,{...a,model:o,fields:r.filter(e=>Object.hasOwn(o.fields,e)),stored:void 0,className:t}):null},co=(e,t)=>lo(e,t?[t]:[]),lo=(e,t)=>{let{resources:n}=P(),r=en(),i=JSON.stringify(e),a=(0,Y.useMemo)(()=>JSON.parse(i).map(C),[i]),o=e=>t.some(t=>`item`in t?typeof t.item==`object`&&t.item!==null&&Object.hasOwn(t.item,e):Object.hasOwn(t.model.fields,e)),s=[...new Set(a.flatMap(e=>e.ok?e.paths:[]))],c=new Map(s.flatMap(e=>{let t=Re(e,o);return t===void 0?[]:[[e,t]]})),l=s.filter(e=>!c.has(e)),u=[...new Set(c.values())].flatMap(e=>n[e]?[n[e]]:[]),d=l.map(e=>jt(t,e)),f=mt(l.map((e,t)=>{let n=d[t];return n&&`frame`in n?{scope:n.frame,path:n.path}:{scope:void 0,path:e}})),p=Dn({queries:u.map(e=>sn(r,e))});return a.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=c.get(n);if(e===void 0){let e=l.indexOf(n),r=d[e];if(r&&`item`in r){t[n]=r.item;continue}let i=f[e];if(i.state===`loading`)return;i.state===`ready`&&(t[n]=i.value);continue}let r=u.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(p[r].isPending)return;else t[n]=p[r].data??0}return T(e,t)})},uo=(e,t)=>typeof e.props.fallback==`string`?e.props.fallback:t.fallback,fo=({node:e,children:t,slots:n,className:r})=>{let{when:i}=z(e),[a]=lo([i],G());if(a===void 0)return null;let o=a?t:uo(e,n);return o==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:o}):(0,X.jsx)(`div`,{className:r,children:o})},po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(Ot(e,L(t)).props.when)]),mo=({node:e,children:t,slots:n,className:r})=>{let i=G(),a=lo(po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?uo(e,n):t[o];return s==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:s}):(0,X.jsx)(`div`,{className:r,children:s})},ho=({children:e})=>(0,X.jsx)(X.Fragment,{children:e}),go=`text-2xl font-semibold tracking-tight tabular-nums`,_o=({model:e,at:t,filter:n})=>{let{views:r}=P(),i=rn(t),a=Dt(e,n,!i),o=i??a;if(o.isPending)return(0,X.jsx)(I,{className:`h-8 w-16`});if(o.error)return(0,X.jsx)(`span`,{className:`text-danger-text`,children:N(`couldNotCount`)});let s=i?er(i):a.data;return(0,X.jsx)(oe,{to:Qn(r[e.name],e.name,n),className:`${go} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:s.toLocaleString(Ke())})},vo=({field:e,format:t})=>{let n=zt(e);return n.state===`loading`?(0,X.jsx)(I,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,X.jsx)(`span`,{className:go,children:ra(n.value)}):(0,X.jsx)(`span`,{className:go,children:(0,X.jsx)(xn,{model:n.model,field:n.field,value:n.value,format:t})})},yo=({node:e,at:t,className:n})=>{let{label:r,value:i,resource:a,filter:o,field:s,format:c,description:l}=z(e),{resources:u}=P(),d=a===void 0?void 0:u[a];return(0,X.jsxs)(R,{className:A(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,X.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,X.jsx)(`span`,{className:go,children:i}),d&&(0,X.jsx)(_o,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,X.jsx)(vo,{field:s,format:c})]}),l&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},bo=(e,t,n)=>{let r=De(),i=qn(t),[a,o]=(0,Y.useState)(()=>Vn(localStorage,i)),s=(0,Y.useCallback)(e=>{o(e),ir(localStorage,i,e)},[i]);return[rr(e,r,{picked:a,preferred:n}),s]},xo=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:s,className:c})=>{let{resources:l,views:u}=P(),d=u[e.name],{fields:f}=Ce(),p=Ie(tt(e.name),`update`),{go:h,href:g}=me(),_=De(),v=!ye(),y=(0,Y.useMemo)(()=>n?.map(pt)??se(e,d),[n,e,d]),b=(0,Y.useMemo)(()=>Kt(e,d,y,{resources:l,views:u,fieldTypes:f}),[e,d,y,l,u,f]),x=(0,Y.useMemo)(()=>_?$t(n)(b):b,[_,n,b]),S=(0,Y.useMemo)(()=>r?Xn(x,e,d,r,l,v):x,[x,e,d,r,l,v]),C=(0,Y.useMemo)(()=>t.map(t=>({...t,id:m(e,t)})),[t,e]),w=(0,Y.useMemo)(()=>({total:C.length,rowAt:e=>C[e]}),[C]),T=tr({model:e,view:d,opens:void 0,resources:l,views:u,canUpdate:p}),E=e=>({href:g(e),onFollow:()=>h(e)});return(0,X.jsx)(R,{title:i,description:a,actions:s,className:c,children:C.length===0?(0,X.jsx)(H,{children:o??N(`nothingYet`)}):(0,X.jsx)(Fn,{fit:!0,columns:S,source:w,latencyMs:0,onOpenRow:e=>h(T.address(e)),rowLink:e=>E(T.address(e)),rowActions:T.actions(E),rowNumbers:!1,selectable:!1})})},So=e=>{let t=gt();return t?.model?(0,X.jsx)(xo,{...e,model:t.model,items:t.items}):null},Co=({model:e,view:t,filter:n=``,sort:r=``,columns:i,button:a,bulk:o,limit:s=10,display:c,title:l,description:u,empty:d,actions:f,className:p,chosen:m,planned:h})=>{let[g,_]=bo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?St:g,y=(0,Y.useMemo)(()=>i?.map(pt),[i]),b=(0,Y.useMemo)(()=>$t(i),[i]);return(0,X.jsxs)(R,{title:l,description:u,actions:(0,X.jsxs)(X.Fragment,{children:[!m&&(0,X.jsx)(ar,{view:t,value:v,onChange:_}),f]}),className:A(`h-full`,p),children:[(0,X.jsx)($n,{model:e,view:t,filter:n,sort:r,columns:y,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:b,...m&&{rowTo:m.rowTo,chosenKey:m.key},...h&&{planned:h}}),m?.details]})},wo=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,children:c,...l}=z(e),{resources:u,views:d}=P(),[f,p]=Wt([t,t===void 0?void 0:`${t}#total`]),m=(0,Y.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,X.jsx)(So,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,X.jsx)(Co,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,X.jsx)(To,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},To=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=a(),o=t=>i({[e]:t}),s=r[e],c=s===void 0?null:(0,X.jsx)(te,{name:e,children:(0,X.jsx)(li,{model:n.model,query:{key:s},children:t},s)});return(0,X.jsx)(Co,{...n,chosen:{rowTo:o,key:s,details:c}})},Eo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=yn(),{navigate:a}=Je(),o=un(e),s=rt(o,r),c=e=>i(e===o[0]?.name?void 0:e);return(0,X.jsxs)(`div`,{className:A(`flex flex-col gap-6`,n),children:[(0,X.jsxs)(`select`,{"aria-label":N(`tabs`),value:s?.name??``,onChange:e=>a(c(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!s&&(0,X.jsx)(`option`,{value:``,disabled:!0}),o.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,X.jsx)(`nav`,{"aria-label":N(`tabs`),className:`hidden border-b md:block`,children:(0,X.jsx)(`ul`,{className:`flex gap-1`,children:o.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(ie,{to:c(e.name),"aria-current":e===s?`page`:void 0,className:A(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===s?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),s?(0,X.jsx)(Y.Fragment,{children:t[o.indexOf(s)]},s.name):(0,X.jsx)(re,{children:N(`noTab`,{name:r??``})})]})},Do=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Oo=e=>e===void 0?1/0:Date.parse(e),ko=(e,t)=>{let n=e=>e.more&&e.items.length>0?Oo(e.items.at(-1).time):-1/0,r=Math.max(n(e),n(t)),i=[],a=0,o=0;for(;a<e.items.length||o<t.items.length;){let n=o>=t.items.length||a<e.items.length&&Oo(e.items[a].time)>=Oo(t.items[o].time)?e.items[a++]:t.items[o++];if(Oo(n.time)<r)break;i.push(n)}return i},Ao=({value:e,hints:t,mark:n})=>{let r=Ae(e,t?.valueLabels);return n===`done`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(S,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(yt,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&bn(t?.valueColors,e)!==`red`?r:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,X.jsx)(fr,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},jo=({value:e})=>{let t=typeof e==`string`?Ee(e):e;return t===ee?(0,X.jsx)(fe,{children:String(e)}):(0,X.jsx)(ae,{value:t})},Mo=({label:e,children:t})=>(0,X.jsxs)(`div`,{className:`grid gap-1`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),No=({call:e,statusHints:t})=>{let[n,r]=(0,Y.useState)(!1),i=(0,Y.useId)(),a=e.status!==void 0&&(0,X.jsx)(Ao,{value:e.status,hints:t,mark:e.state}),o=(0,X.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:e.name}),s=e.input!==void 0||e.result!==void 0||e.error!==void 0;return(0,X.jsxs)(`div`,{"data-tool-call":!0,className:`flex min-w-0 flex-col gap-1 pl-11 text-xs text-muted-foreground`,children:[s?(0,X.jsxs)(j,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,X.jsx)(fn,{"aria-hidden":!0,className:A(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,X.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,X.jsx)(Mo,{label:Q(`callInput`),children:(0,X.jsx)(jo,{value:e.input})}),e.result!==void 0&&(0,X.jsx)(Mo,{label:Q(`callResult`),children:(0,X.jsx)(jo,{value:e.result})}),e.error!==void 0&&(0,X.jsx)(Mo,{label:Q(`callError`),children:(0,X.jsx)(fe,{children:e.error})})]})]})},Po=(e,t)=>e.map(e=>({kind:`message`,row:e,time:typeof e[t]==`string`?e[t]:void 0})),Fo=e=>{if(typeof e==`object`&&e&&`id`in e){let{id:t,name:n}=e;return{id:String(t),...typeof n==`string`&&{name:n}}}return{id:String(e??``),...typeof e==`string`&&{name:e}}},Io=(e,{key:t,sender:n,text:r,status:i},a=Date.now())=>{let o=[],s;for(let c of[...e].reverse()){let e=c.time,l=s?.time!==void 0&&e!==void 0&&ke(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:Se(e,a)}),c.kind===`call`){o.push(c),s={author:void 0,time:e};continue}let{row:u}=c,d=n===void 0?void 0:Fo(u[n]),f=d?.id??``,p=i===void 0||u[i]==null||u[i]===``?void 0:String(u[i]);o.push({kind:`message`,key:t(u),...d&&{author:d},time:e,text:u[r]==null?``:String(u[r]),...p!==void 0&&{status:p},continued:l&&s?.author===f}),s={author:f,time:e}}return o},Lo=e=>zr.includes(e??``)?e:void 0,Ro=e=>e==null||e===``?void 0:String(e),zo=e=>`call:${JSON.stringify(e)}`,Bo=(e,t,n)=>{let r=Ro(e[n.status]),i=Lo(r),a=n.input===void 0?void 0:e[n.input],o=n.result===void 0?void 0:e[n.result],s=n.error===void 0?void 0:Ro(e[n.error]);return{kind:`call`,key:t,name:String(e[n.name]??``),time:typeof e[n.time]==`string`?e[n.time]:void 0,...r!==void 0&&{status:r},...i!==void 0&&{state:i},...a!=null&&{input:a},...o!=null&&{result:o},...s!==void 0&&{error:s}}},Vo=({planned:e,limit:t,expanded:n,expand:r,own:i})=>{if(!e)return i;let a=n&&!i.error&&i.pages<2&&(i.pages===0||i.hasNextPage),o={items:e.rows,labels:e.labels??{},hasNextPage:e.rows.length>=t,isFetchingNextPage:a,isFetchNextPageError:!1,isLoading:e.isPending};return n&&i.error&&i.pages===0?{...o,error:i.error,fetchNextPage:i.refetch,refetch:i.refetch}:n&&!a?i:{...o,error:e.error,fetchNextPage:r,refetch:r}},Ho=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,Y.useState)(!1),s=be(e,{...r,pageSize:t,enabled:n&&(!i||a)}),c=s.data?.pages.length??0,{hasNextPage:l,isFetchingNextPage:u,fetchNextPage:d,error:f}=s;return(0,Y.useEffect)(()=>{i&&a&&!f&&c===1&&l&&!u&&d()},[i,a,f,c,l,u,d]),Vo({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},Uo=(e,t,n)=>{let{views:r}=P(),i=e?.model.name??``,a=Ho(i,{filter:e?.filter,orderBy:e&&Pt(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>Bo(t,zo(We(e.model,t)),e.fields)),hasNextPage:a.hasNextPage,isFetchingNextPage:a.isFetchingNextPage,list:a,statusHints:r[i]?.fields[e.fields.status]}:{calls:[],hasNextPage:!1,isFetchingNextPage:!1,list:a,statusHints:void 0}},Wo=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,Go=(e,t)=>e.isLoading?t.loading:t.empty,Ko=e=>e.items.length>0&&!!e.error,qo=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),Jo=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},Yo=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:l,planned:d})=>{let{resources:f,views:p}=P(),m=_t(),h=m?.state.kind===`signed-in`?m.state.user.id:void 0,g=n===void 0?[]:[n],_=ce(f,p,e,g),v=Ho(e.name,{filter:t,orderBy:Pt(r),pageSize:o,labels:_},d?.messages),y=Uo(l,o,d?.calls),x=Wo(v);if(x===`error`)return(0,X.jsx)(V,{title:Q(`couldNotLoad`),error:v.error,onRetry:qo(v)});if(x===`loading`)return(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(H,{children:Q(`loadingMessages`)})});let S=Qe(f,e,g,v.items,v.labels),C=ko({items:y.calls,more:y.hasNextPage},{items:Po(S,r),more:v.hasNextPage}),w=Io(C,{key:t=>String(We(e,t)),sender:n,time:r,text:i,status:a}),T=a===void 0?void 0:p[e.name]?.fields[a],E=e.fields[i]!==void 0&&gn(e.fields[i],p[e.name]?.fields[i]),ee=w.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===h);return(0,X.jsxs)(X.Fragment,{children:[Ko(v)&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(V,{title:Q(`couldNotLoad`),error:v.error,onRetry:qo(v)})}),l&&y.list.error&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(V,{title:Q(`couldNotLoadCalls`),error:y.list.error,onRetry:qo(y.list)})}),(0,X.jsx)(u,{length:C.length,followKey:ee?.key,working:c,empty:Go(y.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:v.hasNextPage||y.hasNextPage?()=>Jo([v,y.list]):void 0,loadingEarlier:v.isFetchingNextPage||y.isFetchingNextPage,children:w.map(e=>e.kind===`day`?(0,X.jsx)(ve,{label:e.label},e.key):e.kind===`call`?(0,X.jsx)(No,{call:e,statusHints:y.statusHints},e.key):(0,X.jsx)(Ft,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,X.jsx)(Ao,{value:e.status,hints:T}),children:E&&e.text!==``?(0,X.jsx)(b,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},Xo=({children:e})=>(0,X.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),Zo=({node:e,at:t,slots:n,className:r})=>{let{title:i,description:a,resource:o,filter:s,sender:c,time:l,text:u,status:d,working:f,calls:p,limit:m,empty:h}=z(e),{resources:g}=P(),[_]=lo(f===void 0?[]:[f],G()),[v,y]=Wt([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let x=p&&g[p.resource];return(0,X.jsx)(`section`,{className:A(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,X.jsx)(E,{title:i,help:a,actions:n.actions,children:(0,X.jsx)(Xo,{children:(0,X.jsx)(Yo,{model:b,filter:s,sender:c,time:l,text:u,status:d,calls:p&&x&&{model:x,filter:p.filter,fields:p},limit:m,empty:h,working:f===void 0?void 0:_===!0,...(v||y)&&{planned:{messages:v,calls:y}}})})})})},Qo=({children:e,className:t})=>(0,X.jsx)(`div`,{className:t,children:e}),$o=({children:e,className:t})=>(0,X.jsx)(`div`,{className:A(`flex`,t),children:e}),es=({children:e,className:t})=>(0,X.jsx)(`div`,{className:A(`flex flex-col`,t),children:e}),ts=({node:e,children:t,className:n})=>{let{as:r=`p`}=z(e);return(0,X.jsx)(r,{className:n,children:t})},ns=({node:e,children:t})=>{let{source:n}=z(e),r=st(L(G()),n),i=(0,Y.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,X.jsx)(Bt,{value:i,children:t})},rs=({node:e,className:t})=>{let{source:n,choices:r,label:i=n,defaultValue:o}=z(e),{values:s,linkTo:c}=a(),l=s[n];return(0,X.jsxs)(`div`,{className:A(`flex flex-wrap items-center gap-2`,t),children:[(0,X.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:i}),r?(0,X.jsx)(d,{label:i,value:l??``,options:r.map(e=>({value:String(e.id),label:e.name})),link:e=>c({[n]:o!==void 0&&e===String(o)?void 0:e})}):(0,X.jsx)(`span`,{children:l})]})},is=({model:e,filter:t,perPage:n,more:r,planned:i,expanded:a,expand:o,own:s})=>{if(t===void 0)return{read:{isPending:!1,error:null},list:{model:e,items:[]}};if(i&&!a){let t=i.rows.slice(0,n),a=r&&t.length===n?o:void 0;return{read:i,list:{model:e,items:t,planned:!0,...a&&{loadMore:a}}}}if(i&&!s.error&&s.pages<2&&(s.pages===0||s.hasNextPage))return{read:i,list:{model:e,items:i.rows.slice(0,n),planned:!0,loadMore:()=>{},loadingMore:!0}};let c=r&&s.hasNextPage?()=>void s.fetchNextPage():void 0;return{read:{isPending:s.isPending,error:s.error},list:{model:e,items:s.items,...c&&{loadMore:c,loadingMore:s.isFetchingNextPage}}}},as=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,Y.useState)(!1),c=be(e.name,{filter:t,orderBy:n,pageSize:r,enabled:t!==void 0&&(!a||o)}),l=c.data?.pages.length??0,{hasNextPage:u,isFetchingNextPage:d,fetchNextPage:f,error:p}=c;return(0,Y.useEffect)(()=>{a&&o&&!p&&l===1&&u&&!d&&f()},[a,o,p,l,u,d,f]),is({model:e,filter:t,perPage:r,more:i,planned:a,expanded:o,expand:()=>s(!0),own:{pages:l,items:c.items,hasNextPage:u,isFetchingNextPage:d,isPending:c.isPending,error:p,fetchNextPage:f}})},os=({node:e,at:t,children:n})=>{let r=z(e),i=P().resources[r.reference],a=wt(L(G())),o=rn(t);return i?(0,X.jsx)(ss,{model:i,...Le(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},ss=({empty:e,children:t,...n})=>{let{read:r,list:i}=as(n);return(0,X.jsx)(cn,{read:r,list:i,empty:e,children:t})},cs=({node:e,at:t,children:n})=>{let r=z(e),i=P().resources[r.reference],a=wt(L(G())),o=rn(t);return i?(0,X.jsx)(ss,{model:i,..._n(r,i.primaryKey[0],a),more:!1,empty:r.empty,...o&&{planned:o},children:n}):null},ls=({model:e,at:t,recordKey:n,link:r=`edit`,children:i,className:a})=>{let{views:o}=P(),s=rn(t),c=Ct(e,{key:n,enabled:!s}),l=s?Yt(e,s):c;if(l.isPending)return(0,X.jsx)(I,{className:`h-4 w-24`});if(l.error)return(0,X.jsx)(V,{title:N(`couldNotLoad`),error:l.error});if(!l.data)return null;let u=i.length>0?(0,X.jsx)(Gt,{value:l.data,children:i}):Xe(e,o[e.name],l.data.record,n);return r===!1?(0,X.jsx)(`span`,{className:a,children:u}):(0,X.jsx)(oe,{to:{kind:`record`,resource:e.name,key:n},className:a??`font-medium text-primary-text hover:underline`,children:u})},us=({node:e,at:t,children:n,className:r})=>{let{reference:i,source:a,link:o,empty:s}=z(e),c=P().resources[i],l=st(L(G()),a);return c?l==null||l===``?s===void 0?null:(0,X.jsx)(`span`,{className:r,children:s}):(0,X.jsx)(ls,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},ds=(e,t)=>t.map(t=>Xt(e,t)).join(`, `),$=Ue(`users`),fs=({roles:e})=>{let{session:t}=K(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)([]),o=(0,Y.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,Y.useEffect)(o,[o]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(mr,{title:$(`inviteSomeone`),description:$(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,X.jsx)(gr,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,X.jsx)(O,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,X.jsx)(hr,{email:n.email,gives:ds(e,n.roles),expiresAt:n.expiresAt,onResend:async()=>{let e=await t.users.invite({email:n.email,roles:n.roles});return o(),e},onRevoke:async()=>{await t.users.revoke(n.id),o()}},n.id))})})]})},ps=({roles:e,onCreated:t})=>{let{session:n}=K(),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)([]),{busy:d,error:f,run:p}=ze(),m=()=>p(async()=>{await n.users.create({email:r.trim(),name:a.trim(),roles:l,...s&&{password:s}}),i(``),o(``),c(``),u([]),t()}),h=!r.trim()||!a.trim()||l.length===0||s!==``&&s.length<12;return(0,X.jsxs)(O,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,X.jsx)(M,{message:f}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,X.jsx)(q,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,X.jsx)(q,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,X.jsx)(q,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(gr,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,X.jsx)(`div`,{children:(0,X.jsx)(j,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},ms=({user:e,roles:t,self:n})=>{let{session:r}=K(),[i,a]=(0,Y.useState)(e),{busy:o,error:s,run:c,setError:l}=ze(),u=e=>{if(e.length===0)return l($(`keepOneRole`));c(async()=>{await r.users.setRoles(i.id,e),a({...i,roles:e})})},d=e=>void c(async()=>{await(e?r.users.block(i.id):r.users.unblock(i.id)),a({...i,blocked:e})});return(0,X.jsx)(_r,{name:i.name,email:i.email,self:n,error:s,actions:(0,X.jsxs)(X.Fragment,{children:[i.blocked&&(0,X.jsx)(D,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,X.jsx)(j,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,X.jsx)(j,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,X.jsx)(gr,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},hs=({roles:e,version:t})=>{let{session:n,state:r}=K(),[i,a]=(0,Y.useState)(``),o=(0,Y.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=yr(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,X.jsx)(vr,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,X.jsx)(ms,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},gs=()=>{let{session:e}=K(),[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)();return(0,Y.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof U?W(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},_s=()=>{let{roles:e,error:t}=gs(),[n,r]=(0,Y.useState)(0);return(0,X.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,X.jsx)(M,{message:t}),(0,X.jsx)(hs,{roles:e,version:n}),(0,X.jsx)(fs,{roles:e}),(0,X.jsx)(ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},vs=({sender:e,busy:t,error:n,onSave:r,onClose:i})=>{let[a,o]=(0,Y.useState)(e?.address??``),[s,c]=(0,Y.useState)(e?.name??``),[l,u]=(0,Y.useState)(e?.signature??``),[d,f]=(0,Y.useState)(e?.isDefault??!1);return(0,X.jsxs)(F,{title:e?e.address:B(`addFromAddress`),description:B(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:i,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:i,children:B(`cancel`)}),(0,X.jsx)(j,{variant:`primary`,loading:t,disabled:!a.trim(),onClick:()=>r({address:a.trim(),name:s.trim(),signature:l,isDefault:d}),children:B(e?`save`:`addAddress`)})]}),children:[!e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`fromAddress`),(0,X.jsx)(q,{autoFocus:!0,type:`email`,value:a,maxLength:254,placeholder:B(`fromAddressPlaceholder`),onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[B(`fromName`),(0,X.jsx)(q,{value:s,maxLength:100,placeholder:B(`fromNamePlaceholder`),onChange:e=>c(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{children:B(`defaultFromAddress`)}),(0,X.jsx)(he,{checked:d,onChange:f,label:B(`defaultFromAddress`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[B(`signature`),(0,X.jsx)(Pe,{value:l,maxLength:2e3,placeholder:B(`signaturePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,X.jsx)(M,{message:n})]})},ys=e=>e.signature?B(`ownSignature`):B(`genericSignature`),bs=({senders:{address:e,senders:t},onAdd:n,onUpdate:r,onRemove:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(),d=(0,Y.useRef)(!1),f=t.find(e=>e.isDefault),p=()=>{u(void 0),c(void 0)},m=async e=>{if(!d.current){d.current=!0,o(!0),c(void 0);try{await e(),u(void 0)}catch(e){if(e instanceof TypeError)return c(B(`noAnswerFromServer`));if(!(e instanceof U))throw e;c(W(e))}finally{d.current=!1,o(!1)}}},h=e=>m(async()=>{let t=e.name||null,i=e.signature.trim()?e.signature:null;if(l?.kind===`change`)return r(l.sender.id,{name:t,signature:i,isDefault:e.isDefault});let a=await n({address:e.address,...t&&{name:t},...i&&{signature:i}});e.isDefault&&await r(a.id,{isDefault:!0})});return(0,X.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,X.jsx)(`h3`,{className:`font-semibold`,children:B(`fromAddresses`)}),(0,X.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:B(`fromAddressesDescription`)}),(0,X.jsx)(M,{message:l?void 0:s}),(e||t.length>0)&&(0,X.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(wr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:B(`mailboxOwnAddress`)})]}),f?(0,X.jsx)(j,{size:`sm`,variant:`ghost`,loading:a,onClick:()=>void m(()=>r(f.id,{isDefault:!1})),children:B(`makeDefault`)}):(0,X.jsx)(D,{tone:`blue`,children:B(`default`)})]}),t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(wr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,X.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:ys(e)})]}),e.isDefault&&(0,X.jsx)(D,{tone:`blue`,children:B(`default`)}),(0,X.jsx)(j,{size:`sm`,variant:`ghost`,onClick:()=>u({kind:`change`,sender:e}),children:B(`edit`)}),(0,X.jsx)(j,{size:`sm`,variant:`ghost`,onClick:()=>u({kind:`remove`,sender:e}),children:B(`remove`)})]},e.id))]}),(0,X.jsxs)(j,{onClick:()=>u({kind:`add`}),children:[(0,X.jsx)(on,{className:`size-3.5`}),B(`addFromAddress`)]}),l?.kind===`add`&&(0,X.jsx)(vs,{busy:a,error:s,onSave:e=>void h(e),onClose:p}),l?.kind===`change`&&(0,X.jsx)(vs,{sender:l.sender,busy:a,error:s,onSave:e=>void h(e),onClose:p},l.sender.id),l?.kind===`remove`&&(0,X.jsx)(F,{title:B(`removeFromAddress`,{address:l.sender.address}),description:B(`removeFromAddressDescription`),onClose:p,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:p,children:B(`cancel`)}),(0,X.jsx)(j,{variant:`danger`,loading:a,onClick:()=>void m(()=>i(l.sender.id)),children:B(`remove`)})]}),children:(0,X.jsx)(M,{message:s})})]})},xs=(e,t,n)=>Object.fromEntries(Pn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,Yn(`signInOnly`,{provider:n(e.provider),name:e.name})])),Ss=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=K(),{account:i}=t,[a]=(0,Y.useState)(Fe),o=(0,Y.useCallback)(async()=>{let[t,n,r]=await Promise.all([i.linkedPersonalMail(e),i.linkedProviders(),i.mailSenders()]);return{mail:t,providers:n,senders:r}},[i,e]),{data:s,error:c,reload:l}=J(o,B(`couldNotReadMethods`));return s?(0,X.jsx)(Ge,{title:B(`mailbox`),description:B(`mailboxDescription`),providers:e.map(({id:e,name:t})=>({id:e,name:t})),linked:s.mail,notes:xs(e,s,e=>r.find(t=>t.id===e)?.name??xt(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&le(a,e.length===1?e[0].name:B(`theProvider`)),children:(0,X.jsx)(bs,{senders:s.senders,onAdd:async e=>{let t=await i.addMailSender(e);return await l(),t},onUpdate:async(e,t)=>{await i.updateMailSender(e,t),await l()},onRemove:async e=>{await i.removeMailSender(e),await l()}})}):(0,X.jsx)(h,{error:c})},Cs=()=>{let{personalMail:e}=K();return e.length>0?(0,X.jsx)(Ss,{links:e}):null},ws=e=>br(e.name)??`An unnamed app`,Ts=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),Es=({apps:e,onDisconnect:t})=>{let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(),c=async e=>{r(!0),a(void 0);try{await t(e.clientId),s(void 0)}catch(e){if(!(e instanceof U))throw e;a(W(e))}r(!1)};return(0,X.jsxs)(O,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,X.jsx)(M,{message:o?void 0:i}),e.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`No apps are connected. Add this app's MCP address to an AI assistant to connect one.`}):(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=xr(e.clientId);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Er,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:ws(e)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,et(Date.parse(e.allowedAt)),` · `,Ts(e)]})]}),(0,X.jsx)(j,{size:`sm`,variant:`ghost`,onClick:()=>s(e),children:`Disconnect`})]},e.clientId)})}),o&&(0,X.jsx)(F,{title:`Disconnect ${ws(o)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>s(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:()=>s(void 0),children:`Cancel`}),(0,X.jsx)(j,{variant:`danger`,loading:n,onClick:()=>void c(o),children:`Disconnect`})]}),children:i&&(0,X.jsx)(M,{message:i})})]})},Ds=(e,t)=>{let n=new URL(`https://claude.ai/customize/connectors`);return n.searchParams.set(`modal`,`add-custom-connector`),t&&n.searchParams.set(`connectorName`,t),n.searchParams.set(`connectorUrl`,e),n.href},Os=({url:e,appName:t})=>(0,X.jsx)(O,{title:B(`mcpAddress`),description:B(`mcpAddressDescription`),children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Sr,{value:e,copyLabel:B(`copyMcpAddress`)}),(0,X.jsxs)(`a`,{href:Ds(e,t),target:`_blank`,rel:`noreferrer`,className:s(),children:[(0,X.jsx)(it,{className:`size-3.5`}),B(`addToClaude`)]})]})}),ks=()=>{let{account:e}=K().session,{data:t,error:n,reload:r}=J((0,Y.useCallback)(()=>e.connectedApps(),[e]),B(`couldNotReadMethods`));return t?(0,X.jsx)(Es,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,X.jsx)(h,{error:n})},As=({url:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Os,{url:e,appName:P().appName}),(0,X.jsx)(ks,{})]}),js=()=>{let{mcp:e}=K();return e?(0,X.jsx)(As,{url:e.url}):null},Ms={30:30,90:90,365:365,never:void 0},Ns={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},Ps=e=>et(Date.parse(e)),Fs=e=>e?B(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:Ps(e)}):B(`neverExpires`),Is=e=>[B(`createdOn`,{date:Ps(e.createdAt)}),Fs(e.expiresAt),e.lastUsedAt?B(`lastUsedOn`,{date:Ps(e.lastUsedAt)}):B(`notUsedYet`),e.organization?B(`actsAsIn`,{role:e.role,organization:e.organization}):B(`actsAs`,{role:e.role})].join(` · `),Ls=({tokens:e,onCreate:t,onRevoke:n})=>{let[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(`90`),[m,h]=(0,Y.useState)(),g=()=>{l(void 0),s(void 0),h(void 0)},_=(0,Y.useRef)(!1),v=async e=>{if(!_.current){_.current=!0,a(!0),s(void 0);try{l(await e()),h(void 0)}catch(e){if(e instanceof TypeError)return s(B(`noAnswerFromServer`));if(!(e instanceof U))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):s(W(e))}finally{_.current=!1,a(!1)}}},y=()=>v(async()=>{let e=Ms[f];return{kind:`created`,created:await t({name:u.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,X.jsxs)(O,{title:B(`accessTokens`),description:B(`accessTokensDescription`),children:[(0,X.jsx)(M,{message:c?void 0:o}),e.length===0?(0,X.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:B(`noAccessTokens`)}):(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Or,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Is(e)})]}),(0,X.jsx)(j,{size:`sm`,variant:`ghost`,onClick:()=>l({kind:`revoke`,token:e}),children:B(`revoke`)})]},e.id))}),(0,X.jsxs)(j,{onClick:()=>{d(``),p(`90`),l({kind:`create`})},children:[(0,X.jsx)(on,{className:`size-3.5`}),B(`newAccessToken`)]}),c?.kind===`create`&&(0,X.jsxs)(F,{title:B(`newAccessToken`),description:B(`newAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:g,children:B(`cancel`)}),(0,X.jsx)(j,{variant:`primary`,loading:i,disabled:!u.trim(),onClick:()=>void y(),children:B(`createAccessToken`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`name`),(0,X.jsx)(q,{autoFocus:!0,value:u,maxLength:100,placeholder:B(`accessTokenNamePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[B(`accessTokenExpiry`),(0,X.jsx)(He,{value:f,onChange:e=>p(e.target.value),children:Object.keys(Ms).map(e=>(0,X.jsx)(`option`,{value:e,children:B(Ns[e])},e))})]}),m===`asked`&&(0,X.jsx)(r,{purpose:`change`,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:B(`confirmedCreateAccessToken`)}),(0,X.jsx)(M,{message:o})]}),c?.kind===`created`&&(0,X.jsx)(F,{title:B(`accessTokenCreated`,{name:c.created.personalAccessToken.name}),description:B(`accessTokenCreatedDescription`),onClose:g,actions:(0,X.jsx)(j,{variant:`primary`,onClick:g,children:B(`done`)}),children:(0,X.jsx)(Sr,{value:c.created.token,copyLabel:B(`copyAccessToken`)})}),c?.kind===`revoke`&&(0,X.jsx)(F,{title:B(`revokeAccessToken`,{name:c.token.name}),description:B(`revokeAccessTokenDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:g,children:B(`cancel`)}),(0,X.jsx)(j,{variant:`danger`,loading:i,onClick:()=>void v(async()=>(await n(c.token.id),void 0)),children:B(`revoke`)})]}),children:(0,X.jsx)(M,{message:o})})]})},Rs=()=>{let{account:e}=K().session,{data:t,error:n,reload:r}=J((0,Y.useCallback)(()=>e.personalAccessTokens(),[e]),B(`couldNotReadAccessTokens`));return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{message:n}),(0,X.jsx)(Ls,{tokens:t,onCreate:t=>e.createPersonalAccessToken(t).then(e=>(r(),e),async e=>{throw await r(),e}),onRevoke:t=>e.revokePersonalAccessToken(t).finally(r)})]}):(0,X.jsx)(h,{error:n})},zs=()=>K().personalAccessTokens?(0,X.jsx)(Rs,{}):null,Bs={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},Vs=e=>e.provider===`google`,Hs=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(r),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=async(e,t)=>{a(e),s(void 0),d(void 0);try{await t(),l(void 0)}catch(e){if(!(e instanceof U))throw e;s(W(e))}finally{a(void 0)}};return(0,X.jsxs)(O,{title:B(`connections`),description:B(`connectionsDescription`),children:[(0,X.jsx)(M,{message:c?void 0:o}),(0,X.jsx)(qe,{message:u}),(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,X.jsx)(j,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void f(e.key,()=>t(e)),children:e.accounts.length>0?B(`connectAgain`,{name:e.label}):B(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[B(`connectedOn`,{date:et(Date.parse(t.created_at))}),` · `,(0,X.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,X.jsx)(D,{tone:`amber`,children:B(`connectionNeedsSignIn`)}):(0,X.jsx)(D,{tone:`green`,children:B(`connected`)}),(0,X.jsx)(j,{size:`sm`,variant:`ghost`,onClick:()=>l({connection:e,accountId:t.id}),children:B(`disconnect`)})]}),t.used_by.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:B(`connectionUsedBy`)}),t.used_by.map(e=>(0,X.jsx)(ne,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),c&&(0,X.jsx)(F,{title:B(`disconnectTitle`,{name:c.connection.label}),description:Vs(c.connection)?`${B(`disconnectDescription`)} ${B(`disconnectWholeGrant`)}`:B(`disconnectDescription`),onClose:()=>l(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:()=>l(void 0),children:B(`cancel`)}),(0,X.jsx)(j,{variant:`danger`,loading:i===c.accountId,onClick:()=>void f(c.accountId,async()=>d(B(Bs[await n(c.accountId)]))),children:B(`disconnect`)})]}),children:o&&(0,X.jsx)(M,{message:o})})]})},Us=()=>{let{session:e,connectAccount:t}=K(),{account:n}=e,[r]=(0,Y.useState)(Fe),{data:i,error:a,reload:o}=J((0,Y.useCallback)(()=>n.workflowConnections(),[n]),B(`couldNotReadMethods`));return i?i.length===0?null:(0,X.jsx)(Hs,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&le(r,B(`theProvider`))}):(0,X.jsx)(h,{error:a})},Ws=e=>e.code===`LAST_ADMIN`?B(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?B(`deleteAccountLocked`):W(e),Gs=({hasPassword:e,onDelete:t,onClose:n})=>{let[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(!1),f=(0,Y.useId)(),p=async()=>{s(!0),l(void 0),d(!1);try{await t(e?i:void 0)}catch(e){if(!(e instanceof U))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?d(!0):l(Ws(e)),s(!1)}};return(0,X.jsxs)(F,{title:B(`deleteAccountQuestion`),description:B(`deleteAccountWarning`),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:n,children:B(`cancel`)}),(0,X.jsx)(j,{variant:`danger`,type:`submit`,form:f,loading:o,disabled:e&&!i,children:B(`deleteAccountConfirm`)})]}),children:[(0,X.jsxs)(`form`,{id:f,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),p()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`deleteAccountPassword`),(0,X.jsx)(q,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:i,invalid:!!c,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(M,{message:c})]}),u&&(0,X.jsx)(r,{purpose:`change`,minutes:15,onConfirmed:()=>void p()})]})},Ks=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(O,{title:B(`deleteAccount`),description:B(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,X.jsx)(j,{variant:`danger`,onClick:()=>i(!0),children:B(`deleteAccount`)}),r&&(0,X.jsx)(Gs,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},qs=()=>{let{session:e,state:t,deleteAccount:n}=K(),{account:r}=e,{data:i,error:a}=J((0,Y.useCallback)(()=>r.signInMethods(),[r]),B(`couldNotReadMethods`));return i?(0,X.jsx)(Ks,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,X.jsx)(h,{error:a})},Js=[[/Edg(e|A|iOS)?\//,`Edge`],[/OPR\/|Opera/,`Opera`],[/SamsungBrowser\//,`Samsung Internet`],[/Firefox\/|FxiOS\//,`Firefox`],[/Chrome\/|CriOS\//,`Chrome`],[/Safari\//,`Safari`]],Ys=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/CrOS/,`ChromeOS`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/Linux/,`Linux`]],Xs=(e,t)=>e.find(([e])=>e.test(t))?.[1],Zs=e=>e?{browser:Xs(Js,e),system:Xs(Ys,e)}:{},Qs=e=>e.device?B(`deviceThrough`,{device:e.device,provider:e.name}):e.name,$s=(e,t)=>{if(e.staff)return t?B(`staffOf`,{operator:t}):B(`staff`);let{browser:n,system:r}=Zs(e.userAgent);return n&&r?B(`browserOn`,{browser:n,system:r}):r?B(`aBrowserOn`,{system:r}):n??B(`unknownDevice`)},ec=e=>{if(e.staff)return Pr;let{system:t}=Zs(e.userAgent);return t===`iPhone`||t===`Android`?Ir:t===`iPad`?Rr:Ar},tc=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),nc=(e,t)=>e.kind===`one`?B(`signOutDevice`,{name:$s(e.session,t)}):e.kind===`link`?B(`signOutDevice`,{name:Qs(e.link)}):B(`signOutOthersTitle`),rc=e=>B(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),ic=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),p=e.filter(e=>!e.current),m=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),h=async e=>{s(!0),l(void 0);try{await m(e),d(void 0)}catch(e){if(!(e instanceof U))throw e;l(W(e))}s(!1)},g=e=>{l(void 0),d(e)};return(0,X.jsxs)(O,{title:B(`devices`),description:B(`devicesDescription`),children:[f.length===0&&n.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:B(`noDevices`)}):(0,X.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[tc(f).map(e=>{let n=ec(e);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:$s(e,t)}),e.current&&(0,X.jsx)(D,{tone:`green`,children:B(`thisDevice`)})]}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[B(`signedInFromUntil`,{from:je(Date.parse(e.createdAt)),until:je(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,X.jsx)(j,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`one`,session:e}),children:B(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Ir,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:Qs(t)}),n&&(0,X.jsx)(D,{tone:`green`,children:B(`thisDevice`)})]}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:B(`linkedOn`,{date:je(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,X.jsx)(j,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`link`,link:t}),children:B(`signOut`)})]},t.id)})]}),p.length>0&&(0,X.jsx)(j,{className:`mt-3`,onClick:()=>g({kind:`others`}),children:B(`signOutOthers`)}),u&&(0,X.jsx)(F,{title:nc(u,t),description:rc(u),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:()=>d(void 0),children:B(`cancel`)}),(0,X.jsx)(j,{variant:`danger`,loading:o,onClick:()=>void h(u),children:B(`signOut`)})]}),children:(0,X.jsx)(M,{message:c})})]})},ac=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=K(),{account:r}=e,i=(0,Y.useCallback)(async()=>{let[e,t]=await Promise.all([r.sessions(),n?r.deviceLinks():[]]);return{sessions:e,links:t}},[r,n]),{data:a,error:o,reload:s}=J(i,B(`couldNotReadDevices`));return a?(0,X.jsx)(ic,{sessions:a.sessions,links:a.links,operator:t,onSignOut:e=>r.revokeSession(e).then(s),onSignOutOthers:()=>r.revokeOtherSessions().then(s),onSignOutLink:e=>r.signOutDeviceLink(e).then(s)}):(0,X.jsx)(h,{error:o})},oc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},sc=({rule:e,passkeys:t,onAdd:n,onRename:i,onRemove:a})=>{let[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(),g=e===`required`&&t.length<=1,_=async e=>{s(!0),l(void 0),h(void 0);try{await e(),d(void 0)}catch(e){if(!(e instanceof U))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):l(W(e))}s(!1)};return(0,X.jsxs)(O,{title:B(`passkeys`),status:e===`required`&&(0,X.jsx)(D,{tone:`blue`,children:B(`required`)}),description:B(oc[e]),children:[(0,X.jsx)(M,{message:u?void 0:c}),t.length>0&&(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Vt,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??B(`passkey`)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?B(`addedOn`,{date:et(Date.parse(e.createdAt))}):B(`addedEarlier`),` · `,e.backedUp?B(`synced`):B(`oneDevice`)]})]}),(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(j,{size:`sm`,variant:`ghost`,onClick:()=>{p(e.name??``),d({kind:`rename`,passkey:e})},children:B(`rename`)}),(0,X.jsx)(j,{size:`sm`,variant:`ghost`,disabled:g,title:g?B(`keepLastPasskey`):void 0,onClick:()=>d({kind:`remove`,passkey:e}),children:B(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,X.jsxs)(j,{loading:o&&!u,onClick:()=>void _(n),children:[(0,X.jsx)(on,{className:`size-3.5`}),B(`addPasskey`)]}),m===`asked`&&(0,X.jsx)(r,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:B(`confirmedAddPasskey`)}),u?.kind===`rename`&&(0,X.jsxs)(F,{title:B(`renamePasskey`),description:B(`renamePasskeyDescription`),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:()=>d(void 0),children:B(`cancel`)}),(0,X.jsx)(j,{variant:`primary`,loading:o,disabled:!f.trim(),onClick:()=>void _(()=>i(u.passkey.id,f.trim())),children:B(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`name`),(0,X.jsx)(q,{autoFocus:!0,value:f,maxLength:60,onChange:e=>p(e.target.value)})]}),(0,X.jsx)(M,{message:c})]}),u?.kind===`remove`&&(0,X.jsx)(F,{title:B(`removePasskey`),description:B(`removePasskeyDescription`,{name:u.passkey.name??B(`thisPasskey`)}),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:()=>d(void 0),children:B(`cancel`)}),(0,X.jsx)(j,{variant:`danger`,loading:o,onClick:()=>void _(()=>a(u.passkey.id)),children:B(`remove`)})]}),children:c&&(0,X.jsx)(M,{message:c})})]})},cc=()=>{let{account:e}=K().session,t=(0,Y.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=J(t,B(`couldNotReadMethods`));if(!n)return(0,X.jsx)(h,{error:r});let[a,o]=n;return(0,X.jsx)(sc,{rule:a.policy.passkey,passkeys:o,onAdd:()=>e.addPasskey().then(i),onRename:(t,n)=>e.renamePasskey(t,n).then(i),onRemove:t=>e.removePasskey(t).then(i)})},lc=e=>e.code===`PASSWORD_TOO_SHORT`?B(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?B(`passwordTooLong`):W(e),uc=(e,t)=>{if(e.length<12)return B(`useAtLeast`,{length:12});if(e!==t)return B(`passwordsDiffer`)},dc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(),p=(0,Y.useId)(),m=(!e||r)&&a&&s,h=async()=>{let e=uc(a,s);if(f(e),!e){u(!0);try{await t({current:r,next:a})}catch(e){if(!(e instanceof U))throw e;f(lc(e)),u(!1)}}};return(0,X.jsx)(F,{title:B(e?`changePassword`:`setPassword`),description:B(`atLeast`,{length:12}),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:n,children:B(`cancel`)}),(0,X.jsx)(j,{variant:`primary`,type:`submit`,form:p,loading:l,disabled:!m,children:B(`save`)})]}),children:(0,X.jsxs)(`form`,{id:p,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`currentPassword`),(0,X.jsx)(q,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`newPassword`),(0,X.jsx)(q,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!d,onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`repeatPassword`),(0,X.jsx)(q,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:s,invalid:!!d,onChange:e=>c(e.target.value)})]}),e&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:B(`changeSignsOutOthers`)}),(0,X.jsx)(M,{message:d})]})})},fc=({rule:e,hasPassword:t,staff:n})=>B(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),pc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=!n&&e===`allowed`;return(0,X.jsxs)(O,{title:B(`password`),description:fc({rule:e,hasPassword:t,staff:n}),children:[(0,X.jsx)(qe,{message:s?B(`passwordSaved`):void 0}),l&&(0,X.jsx)(j,{onClick:()=>{c(!1),o(!0)},children:B(t?`changePassword`:`setPassword`)}),a&&(0,X.jsx)(dc,{hasPassword:t,onClose:()=>o(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):i(n)),o(!1),c(!0)}})]})},mc=()=>{let{session:e,state:t}=K(),{account:n}=e,{data:r,error:i,reload:a}=J((0,Y.useCallback)(()=>n.signInMethods(),[n]),B(`couldNotReadMethods`));return r?(0,X.jsx)(pc,{rule:r.policy.password,hasPassword:r.account.password,staff:t.kind===`signed-in`&&!!t.staff,onChange:(e,t)=>n.changePassword(e,t).then(a),onSet:e=>n.setPassword(e).then(a)}):(0,X.jsx)(h,{error:i})},hc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),m=async e=>{d(!0),p(void 0);try{await e()}catch(e){if(!(e instanceof U))throw e;p(W(e))}d(!1)},h=i.trim(),g=()=>m(async()=>{await t.request(h),l(``),s(h)}),_=e=>m(async()=>{await t.confirm(o,e),n()});return o?(0,X.jsxs)(F,{title:B(`changeEmail`),description:B(`codeSentTo`,{email:o,minutes:10}),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{variant:`ghost`,onClick:()=>{s(void 0),p(void 0)},children:B(`otherAddress`)}),(0,X.jsx)(j,{variant:`primary`,loading:u,disabled:c.length<6,onClick:()=>void _(c),children:B(`changeEmail`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`code`),(0,X.jsx)(qt,{name:`code`,required:!0,autoFocus:!0,value:c,invalid:!!f,onChange:l,onComplete:e=>!u&&void _(e)})]}),(0,X.jsx)(M,{message:f})]}):(0,X.jsxs)(F,{title:B(`changeEmail`),description:B(`changeEmailDescription`),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:r,children:B(`cancel`)}),(0,X.jsx)(j,{variant:`primary`,loading:u,disabled:!h||h.toLowerCase()===e.toLowerCase(),onClick:()=>void g(),children:B(`sendCode`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`newEmail`),(0,X.jsx)(q,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(M,{message:f})]})},gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=async()=>{f(!0),m(void 0);try{await n(l.trim()),o(!1)}catch(e){if(!(e instanceof U))throw e;m(W(e))}f(!1)};return(0,X.jsxs)(O,{title:B(`profile`),description:B(`profileDescription`),children:[(0,X.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:B(`name`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:B(`email`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(j,{onClick:()=>{u(e),m(void 0),o(!0)},children:B(`changeName`)}),r&&(0,X.jsx)(j,{onClick:()=>c(!0),children:B(`changeEmail`)})]}),a&&(0,X.jsxs)(F,{title:B(`changeName`),description:B(`changeNameDescription`),onClose:()=>o(!1),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:()=>o(!1),children:B(`cancel`)}),(0,X.jsx)(j,{variant:`primary`,loading:d,disabled:!l.trim()||l.trim()===e,onClick:()=>void h(),children:B(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`name`),(0,X.jsx)(q,{autoFocus:!0,value:l,maxLength:100,onChange:e=>u(e.target.value)})]}),(0,X.jsx)(M,{message:p})]}),s&&r&&(0,X.jsx)(hc,{email:t,change:r,onClose:()=>c(!1),onDone:()=>{c(!1),i?.()}})]})},_c=()=>{let{session:e,changeEmail:t}=K(),{data:n,loaded:r,error:i,reload:a}=J((0,Y.useCallback)(()=>e.session(),[e]),B(`couldNotReadProfile`));if(!r)return(0,X.jsx)(h,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,X.jsx)(gc,{name:n.name,email:n.email,onRename:t=>e.account.updateName(t).then(a),emailChange:o,onEmailChanged:a})},vc=({title:e,description:t,confirmLabel:n,danger:i,needsPassword:a,onConfirm:o,onClose:s})=>{let[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),[m,h]=(0,Y.useState)(!1),g=async()=>{d(!0),p(void 0),h(!1);try{await o(a?c:void 0)}catch(e){if(!(e instanceof U))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(!0):p(W(e)),d(!1)}};return(0,X.jsxs)(F,{title:e,description:t,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{onClick:s,children:B(`cancel`)}),(0,X.jsx)(j,{variant:i?`danger`:`primary`,loading:u,disabled:a&&!c,onClick:()=>void g(),children:n})]}),children:[a&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`yourPassword`),(0,X.jsx)(q,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:c,invalid:!!f,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&c&&void g()})]}),f&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:f}),m&&(0,X.jsx)(r,{purpose:`change`,minutes:15,onConfirmed:()=>void g()})]})},yc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},bc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,Y.useState)(),d=()=>u(void 0),f=n?(0,X.jsx)(D,{tone:`green`,children:B(`on`)}):t===`required`?(0,X.jsx)(D,{tone:`amber`,children:B(`required`)}):(0,X.jsx)(D,{children:B(`off`)}),p=B(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:yc[t]);return l?.kind===`setup`?(0,X.jsx)(O,{title:B(`twoFactor`),status:f,description:p,children:(0,X.jsx)(`div`,{className:`max-w-sm`,children:(0,X.jsx)(Ye,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,X.jsxs)(O,{title:B(`twoFactor`),status:f,description:p,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,X.jsx)(j,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:B(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,X.jsx)(j,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:B(`addAuthenticator`)}),n&&r&&(0,X.jsx)(j,{onClick:()=>u({kind:`new-codes`}),children:B(`newBackupCodes`)}),n&&(0,X.jsx)(j,{variant:`danger`,disabled:t===`required`,title:t===`required`?B(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:B(`turnOff`)})]}),l?.kind===`turn-off`&&(0,X.jsx)(vc,{title:B(`turnOffTitle`),description:B(`turnOffDescription`),confirmLabel:B(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,X.jsx)(vc,{title:B(`newCodesTitle`),description:B(`newCodesDescription`),confirmLabel:B(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,X.jsx)(F,{title:B(`yourNewCodes`),description:B(`keepCodesSafe`),onClose:d,actions:(0,X.jsx)(j,{variant:`primary`,onClick:d,children:B(`savedCodes`)}),children:(0,X.jsx)($e,{codes:l.codes})})]})},xc=()=>{let{account:e}=K().session,{data:t,error:n,reload:r}=J((0,Y.useCallback)(()=>e.signInMethods(),[e]),B(`couldNotReadMethods`));return t?(0,X.jsx)(bc,{rule:t.policy.twoFactor,enabled:t.account.twoFactor,authenticatorApp:t.account.authenticatorApp,mail:t.mail,needsPassword:t.account.password,onStartApp:t=>e.startAuthenticatorApp(t),onConfirmApp:t=>e.confirmAuthenticatorApp(t),onEmailedCodes:t=>e.turnOnEmailedCodes(t),onTurnOff:t=>e.turnOffTwoFactor(t),onNewBackupCodes:t=>e.newBackupCodes(t),onChanged:r}):(0,X.jsx)(h,{error:n})},Sc=({problem:e,fallback:t})=>t===void 0?(0,X.jsx)(re,{children:e}):(0,X.jsxs)(X.Fragment,{children:[!1,t]}),Cc=({name:e,registered:t,fallback:n,children:r})=>t?(0,X.jsx)(f,{name:e,fallback:n===void 0?void 0:(0,X.jsx)(Sc,{problem:N.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,X.jsx)(Sc,{problem:N.rich(`noComponent`,{component:e}),fallback:n}),wc={Page:Pa,Grid:ua,Card:ri,Stat:yo,RecordCard:Ra,Field:aa,Diff:na,Table:wo,CardRow:si,RecordRow:ro,RecordCards:$a,Chart:ci,Timeline:qi,Graph:Zi,Progress:Ia,Image:va,ModalForm:Na,Thread:Zo,Composer:$i,Action:ni,Show:fo,Switch:mo,Match:ho,Link:Oa,Settings:so,Tabs:Eo,Tab:Do,Users:_s,Profile:_c,Password:mc,Passkeys:cc,TwoFactor:xc,ConnectedAccounts:pe,PersonalMail:Cs,Connections:Us,Devices:ac,ConnectedApps:js,PersonalAccessTokens:zs,DeleteAccount:qs,Box:Qo,Row:$o,Column:es,Text:ts,ReferenceManyField:os,ReferenceArrayField:cs,ArrayField:ns,RecordsIterator:ai,ReferenceField:us,SelectInput:rs,Details:ea,Summary:ta,TextField:xa,NumberField:Sa,DateField:Ca,BooleanField:wa,UrlField:Ta,ChipField:Ea},Tc=new Set(`Page.Grid.Card.Stat.RecordCard.Field.Diff.Table.CardRow.RecordRow.RecordCards.Chart.Timeline.Graph.Progress.Image.Thread.Link.Tabs.Settings.Show.Switch.Action.Box.Row.Column.Text.ReferenceField.SelectInput.Details.Summary.TextField.NumberField.DateField.BooleanField.UrlField.ChipField`.split(`.`)),Ec=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:Sn(t,...n,r)}})),Dc=({text:e})=>{let t=G(),n=Me(),r={...L(t),params:n};return(0,X.jsx)(X.Fragment,{children:pn(e,e=>Nt(st(r,e)))})},Oc=(e,t)=>e.includes(`{{`)?(0,X.jsx)(Dc,{text:e},t):(0,X.jsx)(Y.Fragment,{children:e},t),kc=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?Oc(e,n):(0,X.jsx)(Ic,{node:e,at:t},n)),Ac=e=>{let t=[];for(let n of e){let e=t.at(-1);Hr(n.child)&&e&&Hr(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Hr(n.child)?(0,X.jsx)(`p`,{className:`leading-6`,children:kc(e)},t):(0,X.jsx)(Ic,{node:n.child,at:n.at},t)})},jc=e=>Oe(e)||Array.isArray(e)&&e.length>0&&e.every(Oe),Mc=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>jc(n)?[[e,(0,X.jsx)(X.Fragment,{children:Ac(Nc(n,t,e))})]]:[])),Nc=(e,t,n)=>Array.isArray(e)?Ec(e,t,`props`,n):[{child:e,...t!==void 0&&{at:Sn(t,`props`,n)}}],Pc=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fc=(e,t)=>{let n=Pc(e.props.components)?e.props.components:{},r=Object.fromEntries(Object.entries(n).flatMap(([e,t])=>Oe(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=Ut(t,String(e.props.i18nKey),Pc(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||Oe(e)?e:String(e)):[i]},Ic=({node:e,at:t})=>{let{components:n}=Ce(),r=G(),i=Me(),a=o(),s=(0,Y.useMemo)(()=>bt(Ot(e,{...L(r),params:i}),a),[e,r,i,a]);if(s.type===`Trans`&&!s.custom)return(0,X.jsx)(X.Fragment,{children:kc(Fc(s,a).map(e=>({child:e})))});if(s.custom){let e=n?.[s.type],r=s.children.length>0?(0,X.jsx)(Ji,{node:s,children:Ac(Ec(s.children,t,`children`))}):void 0;return(0,X.jsx)(Cc,{name:s.type,registered:!!e,fallback:s.fallback&&(0,X.jsx)(X.Fragment,{children:Ac(Ec(s.fallback,t,`fallback`))}),children:e&&(0,X.jsx)(Ze,{node:s,...t!==void 0&&{at:t},children:(0,X.jsx)(e,{...at(s.props),children:r})})})}let c=wc[s.type];if(!c)return(0,X.jsx)(re,{children:N.rich(`unknownBlock`,{type:s.type})});let l=typeof s.props.className==`string`?s.props.className:void 0,u=Ec(s.children,t,`children`),d=(0,X.jsx)(c,{node:s,at:t,slots:Mc(s,t),className:l,children:s.type===`Text`||s.type===`Link`||s.type===`Summary`?kc(u):Ac(s.type===`Switch`?u.filter(({child:e})=>typeof e!=`string`):u)}),p=l===void 0||Tc.has(s.type)?d:(0,X.jsx)(`div`,{className:l,children:d});return s.fallback?(0,X.jsx)(f,{name:s.type,resetKey:s,fallback:(0,X.jsx)(X.Fragment,{children:Ac(Ec(s.fallback,t,`fallback`))}),children:p}):p};export{bo as a,Ha as c,Yo as i,za as l,Cc as n,co as o,Xo as r,Za as s,Ic as t,Qi as u};
|
|
3
|
-
//# debugId=1e2ae191-baae-403e-8e99-7607c8378479
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,Bc as i,Bi as a,Dc as o,Fl as s,Gr as c,Ha as l,Is as u,Jn as d,Lr as f,Ls as p,Mc as m,Nl as h,Oa as g,Qs as _,Vc as v,Vi as y,Xc as b,Xo as x,Xs as S,Yn as C,Ys as w,Zr as T,hi as E,ja as D,mr as O,on as k,rl as A,rs as j,vn as M}from"./app-1j5nx8lw.js";import{h as N,o as P}from"./vendor-t7Q7QbPu.js";import{Q as F}from"./embedded-list-CQ7VmI-J.js";import{n as I}from"./lib-dnd-kit-sortable-CNDSKqCD.js";import{a as L,i as R,n as z,o as B,r as ee,s as V,t as H}from"./messages-DAlS_OLf.js";var U={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};U.node;var W=m(U),G={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};G.node;var K=m(G),q=e(t(),1),J=v(`app/delete`),Y=h(),X=({blockingPlural:e,noun:t})=>J(`stillPointAt`,{plural:e,noun:t}),Z=({blockedBy:e,resources:t,views:n,noun:i,key:a})=>{let{resource:o,field:c}=e;if(!t[o])return;let l=n[o]?.names?.plural??r(o),u=X({blockingPlural:l,noun:i});if(!c||a===void 0)return{text:u};let d={kind:`list`,resource:o,filter:s(Y.eq(c,a))};return{text:u,link:{label:J(`show`,{plural:l}),to:d}}},Q=e(n(),1),te=({title:e,noun:t,busy:n,onConfirm:r,onCancel:i})=>(0,Q.jsx)(S,{title:J(`confirmTitle`,{title:e}),description:J(`confirmDescription`,{noun:t,title:e}),onClose:i,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_,{onClick:i,children:J(`cancel`)}),(0,Q.jsx)(_,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:r,children:J(`delete`)})]})}),ne=({title:e,changes:t,busy:n,onReview:r,onDeleteAnyway:i,onCancel:a})=>(0,Q.jsx)(S,{title:J(`changedTitle`,{title:e}),description:J(`changedDescription`),onClose:a,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_,{onClick:r,children:J(`reviewChanges`)}),(0,Q.jsx)(_,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:i,children:J(`deleteAnyway`)})]}),children:t.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noVisibleChanges`)}):(0,Q.jsx)(`ul`,{className:`divide-y rounded-md border`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`grid grid-cols-[96px_1fr] gap-3 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.after})]})]},e.field))})}),$=e=>{if(e.stage===`confirm`)return(0,Q.jsx)(S,{title:J(`bulkConfirmTitle`,{count:e.count,noun:e.noun,plural:e.plural}),description:J(`bulkConfirmDescription`),onClose:e.onCancel,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_,{onClick:e.onCancel,children:J(`cancel`)}),(0,Q.jsx)(_,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,onClick:e.onConfirm,children:J(`deleteCount`,{count:e.count})})]})});if(e.stage===`running`)return(0,Q.jsx)(S,{title:J(`deleting`),description:J(`progress`,{done:e.done,total:e.total}),onClose:()=>void 0,actions:(0,Q.jsx)(_,{loading:!0,disabled:!0,children:J(`working`)})});let t=e.total-e.failures.length;return(0,Q.jsx)(S,{title:e.failures.length===0?J(`deleted`,{count:t}):J(`deletedOf`,{count:t,total:e.total}),description:e.failures.length===0?void 0:J(`kept`,{count:e.failures.length}),onClose:e.onClose,actions:(0,Q.jsx)(_,{variant:`primary`,onClick:e.onClose,children:J(`done`)}),children:e.failures.length>0&&(0,Q.jsx)(`ul`,{className:`max-h-48 divide-y overflow-y-auto rounded-md border`,children:e.failures.map(e=>(0,Q.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-danger-text`,children:e.message})]},e.title))})})},re=new Set([`updated_at`,`updatedAt`]),ie=(e,t,n,i)=>Object.values(e.fields).flatMap(e=>{if(re.has(e.name)||JSON.stringify(n[e.name]??null)===JSON.stringify(i[e.name]??null))return[];let a=t?.fields[e.name];return[{field:e.name,label:a?.label??r(e.name),before:E(e,n[e.name],a),after:E(e,i[e.name],a)}]}),ae=4,oe=({model:e,view:t,onDeleted:n,onReview:i,restore:a})=>{let o=j(),s=N(),c=D(),[l,d]=(0,q.useState)(),[m,h]=(0,q.useState)(!1),g=t?.names?.singular??r(e.name),_=t?.names?.plural??r(e.name),{resources:v,views:y}=x(),{href:b,open:S}=f(),C=(t,n)=>t.blockedBy&&Z({blockedBy:t.blockedBy,resources:v,views:y,noun:g,...e.primaryKey.length===1&&{key:n.key}}),w=()=>{for(let t of[`page`,`list`,`first-page`,`map`])s.invalidateQueries({queryKey:[t,e.name]});for(let t of[`facets`,`series`,`aggregate`,`histogram`,`count`])s.invalidateQueries({queryKey:[t,e.name]})},T=async(t,n)=>{let r=n??(await o.get(e.name,t.key)).etag;try{await o.remove(e.name,t.key,{etag:r})}catch(e){if(!(e instanceof u))throw e;return e}},E=t=>{w(),d(void 0),n?.(t),c.show({state:`success`,title:J(`deletedToast`,{title:t.title}),...e.softDelete&&a&&{action:{label:J(`undo`),onClick:()=>{a(t).then(()=>{w(),c.show({state:`success`,title:J(`restored`,{title:t.title})})},e=>{if(!p(e))throw e;w(),c.show({state:e.status===409?`success`:`error`,title:e.status===409?J(`alreadyBack`,{title:t.title}):J(`couldNotRestore`,{title:t.title}),description:e.status===409?void 0:e.message})})}}}})},O=async(n,r)=>{h(!0);try{if(!await T(n,r))return E(n);let i=(await o.get(e.name,n.key)).record;d({kind:`conflict`,target:n,fresh:i,changes:ie(e,t,n.snapshot,i)})}catch(e){if(!p(e))throw e;d(void 0);let t=C(e,n);c.show({state:`error`,title:J(`couldNotDelete`,{title:n.title}),description:t?.text??e.message,...t?.link&&{action:{label:t.link.label,href:b(t.link.to),onNavigate:S}}})}finally{h(!1)}},k=async e=>{try{return await T(e,e.etag)?{title:e.title,message:J(`changedSinceLoaded`)}:void 0}catch(t){if(!p(t))throw t;return{title:e.title,message:C(t,e)?.text??t.message}}},A=async e=>{let t=[],n=[],r=0;d({kind:`bulk-running`,done:r,total:e.length});let i=[...e];return await Promise.all(Array.from({length:Math.min(ae,e.length)},async()=>{for(let a=i.shift();a;a=i.shift()){let i=await k(a);i&&(t.push(i),n.push(a)),r+=1,d({kind:`bulk-running`,done:r,total:e.length})}})),w(),d({kind:`bulk-done`,total:e.length,failures:t}),n},M=()=>d(void 0);return{dialogs:l&&(0,Q.jsxs)(Q.Fragment,{children:[l.kind===`confirm`&&(0,Q.jsx)(te,{title:l.target.title,noun:g,busy:m,onCancel:M,onConfirm:()=>void O(l.target,l.target.etag)}),l.kind===`conflict`&&(0,Q.jsx)(ne,{title:l.target.title,changes:l.changes,busy:m,onCancel:M,onReview:()=>{M(),i?.(l.target,l.fresh)},onDeleteAnyway:()=>void O(l.target,`*`)}),l.kind===`bulk-confirm`&&(0,Q.jsx)($,{stage:`confirm`,count:l.targets.length,noun:g,plural:_,onCancel:()=>{M(),l.settle(l.targets)},onConfirm:()=>l.settle(A(l.targets))}),l.kind===`bulk-running`&&(0,Q.jsx)($,{stage:`running`,done:l.done,total:l.total}),l.kind===`bulk-done`&&(0,Q.jsx)($,{stage:`done`,total:l.total,failures:l.failures,onClose:M})]}),start:t=>e.softDelete?O(t,t.etag):d({kind:`confirm`,target:t}),startBulk:e=>new Promise(t=>d({kind:`bulk-confirm`,targets:e,settle:t}))}},se=e=>{let t=j();return e.softDelete?async n=>void await t.undelete(e.name,n.key):void 0},ce=(e,t,n)=>({order:r,index:i})=>{let a=t=>r.findIndex(n=>A(y(e,n))===t),o=t.after.find(e=>a(e.key)>i);if(o)return H(`dependsOn`,{record:n,other:o.title});let s=t.before.find(e=>a(e.key)!==-1&&a(e.key)<i);return s?H(`dependsOn`,{record:s.title,other:n}):void 0},le=(e,t,n,r)=>{let i=e[t],a;for(let o=n;o<e.length;o++){let n=r({record:i,order:I(e,t,o),index:o});if(n===void 0)return{to:o,...a!==void 0&&{reason:a}};a??=n}return{to:t,reason:a}},ue=({model:e,view:t,field:n,filter:r,fields:o,rule:s})=>{let l=j(),u=D(),f=M(),{resources:p,views:m}=x(),h=`${n} asc`,g=P({queryKey:[...i.list(e.name,r,h,500,`hand-order`),o.join(`,`)],queryFn:async()=>{let t=d(p,m,e,o),n=[],i=``;do{let s=await l.search(e.name,{filter:r||void 0,orderBy:h,pageSize:500,labels:t,...i&&{pageToken:i}});n.push(...C(p,e,o,s.items,s.labels).map((t,n)=>({...t,id:a(e,s.items[n])}))),i=s.nextPageToken}while(i);return n}}),[_,v]=(0,q.useState)(),y=(0,q.useRef)(void 0),S=(0,q.useRef)([]),w=(0,q.useRef)(void 0),T=(0,q.useRef)(Promise.resolve()),E=(0,q.useRef)(0),O=(0,q.useRef)(void 0),k=async()=>{let t=y.current,r=S.current;if(S.current=[],!t||r.length===0)return;let i=await l.batchWrite(r),o=new Map(i.results.flatMap(e=>e.op===`move`?e.records:[]).map(t=>[a(e,t.record),t])),s=z(i.results,t=>a(e,t)),c=L(e,[...o].map(([e,t])=>({...t,before:{[n]:s.get(e)}})),[n]);O.current!==void 0&&u.dismiss(O.current),O.current=u.show({state:`success`,title:V(`orderChanged`),action:{label:V(`undo`),onClick:()=>W(c)}}),y.current&&=y.current.map(e=>{let t=o.get(e.id);return t?{...e,[n]:t.record[n],etag:t.etag}:e})},A=(e,t)=>n=>{y.current=void 0,S.current=[],v(void 0),u.show(B(n,e,{place:`list`,title:t?w.current:void 0}))},N=async()=>{--E.current,!(E.current>0)&&(await f(e.name),!(E.current>0)&&(y.current=void 0,v(void 0)))},F=(n,r)=>{let i=y.current??g.data;if(!i||n===r)return;if(!e.position?.after)return H(i,n,r,s);let a=c(e,i[n]).record,o=i[n].id;R(l,e,t,a).then(n=>{let i=y.current??g.data,c=ce(e,n,b(e,t,a,o));H(i,i.findIndex(e=>e.id===o),r,e=>c(e)??s?.(e))},A(V(`couldNotChange`),!1))},H=(i,a,o,s)=>{if(a===-1||a===o)return;let l=s?U(i,a,o,s):o;a!==l&&(y.current=I(i,a,l),S.current=[...S.current,ee(e,n,r,y.current,l)],v(y.current),E.current+=1,w.current=b(e,t,c(e,i[a]).record,i[a].id),T.current=T.current.then(k).catch(A(V(`couldNotChange`),!0)).then(N))},U=(t,n,r,i)=>{let a=le(t.map(t=>c(e,t).record),n,r,i);return a.reason!==void 0&&u.show({state:`warning`,title:a.to===n?V(`notMoved`):V(`movedToPlace`,{place:a.to+1}),description:a.reason}),a.to},W=e=>{O.current!==void 0&&u.dismiss(O.current),O.current=void 0,E.current+=1,T.current=T.current.then(async()=>{await l.batchWrite(e),y.current=void 0,S.current=[],v(void 0)}).catch(A(V(`couldNotUndo`),!1)).then(N)};return{rows:_??g.data,loading:g.isPending,error:g.error,move:F}},de=({model:e,view:t,field:n,filter:r,columns:i,sort:a})=>{let{resources:o,views:s}=x(),{fields:c,dropRules:u}=g(),{go:d,href:p}=f(),m=a!==void 0,h=(0,q.useMemo)(()=>k(e,t,i,{resources:o,views:s,fieldTypes:c}).map(e=>m?e:{...e,sortable:!1}),[e,t,i.join(`,`),o,s,c,m]),_=(0,q.useMemo)(()=>T(e,t,h.map(e=>e.id)),[e,t,h]),v=t?.list?.drag?.rule,S=v===void 0?void 0:u?.[v],C=ue({model:e,view:t,field:n,filter:r,fields:_,...S&&{rule:S}}),E=C.rows,D=(0,q.useMemo)(()=>E&&{total:E.length,rowAt:e=>E[e]},[E]);if(v!==void 0&&!S)return(0,Q.jsx)(l,{children:V.rich(`noRule`,{rule:v})});if(C.loading)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Q.jsx)(w,{className:`h-4 w-full`},t))});if(C.error)return(0,Q.jsx)(O,{title:V(`couldNotLoad`),error:C.error});if(!D||D.total===0)return(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:V(`nothingYet`)});let A=t=>d({kind:`record`,resource:e.name,key:y(e,t)});return(0,Q.jsx)(F,{fit:!0,scroll:`parent`,columns:h,source:D,latencyMs:0,onOpenRow:A,rowLink:t=>({href:p({kind:`record`,resource:e.name,key:y(e,t)}),onFollow:()=>A(t)}),...a&&{sort:a.value,onSortChange:a.onChange},rowNumbers:!1,reorder:{label:n=>b(e,t,n,n.id),onMove:C.move}})},fe=({sorting:e,onChange:t,size:n,iconOnly:r=!1})=>{let i=V(e?`done`:`reorder`);return(0,Q.jsxs)(_,{size:n,variant:e?`primary`:`secondary`,onClick:()=>t(!e),...r&&{"aria-label":i,title:i},children:[e?(0,Q.jsx)(o,{className:`size-3.5`}):(0,Q.jsx)(W,{className:`size-3.5`}),!r&&i]})};export{K as a,oe as i,de as n,se as r,fe as t};
|
|
2
|
-
//# debugId=c5ac093e-5dcb-45d7-9aff-a638c444eaf8
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{$ as e,$s as t,Aa as n,Ar as r,At as ee,B as te,Bt as i,Cn as a,Co as o,Ct as s,Da as c,Dt as l,Ea as u,Eo as d,Et as f,Fa as p,Fc as m,Fr as h,Ft as g,G as _,Gi as v,Gt as y,H as b,Hc as x,Hi as S,Ht as C,Ic as w,Ir as T,Ji as E,Jt as D,K as O,Ki as k,La as A,Lc as j,Lr as M,Mo as N,Mt as P,N as F,Nr as I,Nt as L,Ot as R,P as z,Pc as B,Pr as V,Pt as H,Q as U,Qs as W,Qt as G,R as K,Ra as q,Rc as J,Rn as Y,Rt as X,Sr as Z,St as Q,To as ne,Tr as re,Tt as ie,U as ae,Ui as oe,V as se,Vt as ce,W as le,Wi as ue,X as $,Xs as de,Yi as fe,Yt as pe,Zt as me,_r as he,_t as ge,br as _e,bt as ve,dt as ye,ec as be,eo as xe,et as Se,fo as Ce,ft as we,gr as Te,gt as Ee,hr as De,ht as Oe,is as ke,it as Ae,jr as je,jt as Me,kr as Ne,lo as Pe,ma as Fe,mo as Ie,mt as Le,n as Re,no as ze,ns as Be,nt as Ve,oo as He,or as Ue,ot as We,pt as Ge,qi as Ke,qs as qe,qt as Je,r as Ye,rs as Xe,rt as Ze,so as Qe,t as $e,to as et,ts as tt,tt as nt,uo as rt,ut as it,vt as at,wo as ot,wr as st,wt as ct,xo as lt,xr as ut,xt as dt,yr as ft,yt as pt,z as mt,zc as ht,zt as gt}from"./app-1j5nx8lw.js";import{h as _t,o as vt}from"./vendor-t7Q7QbPu.js";export{Q as ActionCard,Z as ActionInputError,Be as ApiProvider,V as App,T as AppLink,ne as AppMark,we as AssistantDock,ze as AuthLayout,Pe as AvailabilityMark,W as Button,X as CallMark,C as CallView,O as Carousel,P as ChatDivider,Me as ChatMessage,ee as ChatThread,mt as Choices,xe as CodeForm,ve as CompactTable,ct as Composer,de as Dialog,ge as DiffView,K as Field,pe as FieldBadge,dt as FieldList,Te as FileReadError,e as FocusActions,Se as FocusNotice,Ae as FocusPage,nt as FocusPanel,Ve as FocusSlot,F as Form,_e as HtmlFrame,Re as InPlaceForm,lt as Input,d as LogoMark,a as Markdown,f as MentionBox,ie as MentionedText,te as MenuSelect,Ce as MenuSurface,He as OtpInput,Le as PartView,i as RecordCall,y as RecordLink,$e as RecordPicker,et as ResendCodeButton,k as ResponsiveDialog,qe as RouteLink,$ as SearchPicker,z as Section,Ie as Segmented,se as Select,s as SidePanel,g as SignInPrompt,be as Spinner,rt as StatusMark,Oe as StepList,Y as Textarea,D as ToneEdge,b as allowDelayMs,t as buttonClass,L as chatDayLabel,N as closeSidebarEvent,u as definePlugin,c as defineUi,at as diffStats,l as emptyDraft,ut as fileNamed,st as isConflict,ae as isFramed,ot as logoTapEvent,R as mentionedIds,w as mergeUi,pt as parseDiff,Ee as parsePatch,J as pluginApi,B as pluginsChangedEvent,ht as protobaseVersion,H as sameChatDay,x as showTextsIn,ft as siblingPage,Qe as signedOutEvent,oe as statusRefreshMs,j as uiFromModule,h as uiReadyEvent,q as useApiToken,M as useAppAddress,le as useArmedAfterFocus,ye as useAssistant,it as useAssistantClient,Ge as useBackendData,Xe as useClient,me as useComponentReads,G as useComponentSelect,Ye as useCreateForm,Ne as useFacets,o as useFieldControl,he as useFileText,We as useFocusPage,U as useFocusRecord,Ze as useFocusZoneFilled,_ as useGuardedPress,r as useHistogram,Ke as useInbox,Ue as useLayoutRecord,I as useList,Je as useListDisplay,E as useMarkNotificationsRead,S as useMembers,tt as useMeta,ue as useOwnStatus,m as usePlugin,n as usePresence,Fe as usePushNotifications,vt as useQuery,_t as useQueryClient,p as useRecord,ce as useRecordCallAddress,gt as useRecordCalls,ke as useResourceClient,je as useSeries,De as useSiblingPage,A as useSignedInUser,v as useStatuses,fe as useUnreadNotifications,re as useUpdateRecord};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Go as r,Ho as i,Nc as a,Qi as o,Qs as s,Uo as c,Wc as l,ec as u,ls as d,ps as f,qo as p,us as m}from"./app-1j5nx8lw.js";import{t as h}from"./page-header-Ddz2r5ic.js";var g=e(t(),1),_=()=>[{value:`allowed`,label:d(`on`)},{value:`forbidden`,label:d(`off`)}],v=()=>[{value:`allowed`,label:d(`optional`)},{value:`required`,label:d(`required`)},{value:`forbidden`,label:d(`off`)}],y=()=>[{method:`password`,label:d(`password`),description:d(`passwordDescription`),rules:_()},{method:`emailCode`,label:d(`emailedSignInCode`),description:d(`emailedSignInCodeDescription`),rules:_()},{method:`passkey`,label:d(`passkeys`),description:d(`passkeysPolicyDescription`),rules:v()},{method:`twoFactor`,label:d(`twoFactor`),description:d(`twoFactorPolicyDescription`),rules:v()},{method:`staffAccess`,label:d(`staffAccess`),description:d(`staffAccessDescription`),rules:[{value:`allowed`,label:d(`on`)},{value:`notify`,label:d(`emailThePerson`)},{value:`forbidden`,label:d(`off`)}]},{method:`platformSignIn`,label:d(`platformSignIn`),description:d(`platformSignInDescription`),rules:_()}],b=(e,t)=>{let n=y().find(t=>t.method===e)?.rules.find(e=>e.value===t)?.label;if(n===void 0)throw Error(`No label for the ${t} rule of ${e}`);return n},x=e(n(),1),S=({row:e,value:t,onChange:n})=>(0,x.jsx)(`span`,{role:`radiogroup`,"aria-label":e.label,className:`inline-flex h-8 shrink-0 rounded-md bg-muted p-0.5`,children:e.rules.map(e=>(0,x.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t,onClick:()=>n(e.value),className:a(`rounded px-3 text-body font-medium transition-colors`,e.value===t?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value))}),C=({method:e},t,{mail:n,effective:r,policy:i})=>{if(e===`emailCode`&&!n)return d(`codeNeedsMail`);if(e===`password`&&!n&&t.password===`forbidden`)return d(`passwordStaysOn`);if(e===`staffAccess`&&!n&&t.staffAccess===`notify`)return d(`staffNeedsMail`);if(e===`platformSignIn`&&t.platformSignIn===`allowed`&&t.passkey===`required`)return d(`platformOff`);if(t[e]===i[e]&&r[e]!==i[e])return d(`appliesAs`,{rule:b(e,r[e])})},w=({operator:e,platformProviders:t=[]})=>y().flatMap(n=>n.method===`staffAccess`&&!e?[]:n.method===`platformSignIn`?t.length>0?[{...n,label:d(`platformSignInWith`,{provider:new Intl.ListFormat(l(),{type:`conjunction`}).format(t)})}]:[]:[n]),T=({state:e,onSave:t,busy:n,error:r,notice:i})=>{let[a,c]=(0,g.useState)(e.policy),l=w(e),u=l.some(({method:t})=>a[t]!==e.policy[t]);return(0,x.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t(a)},children:[(0,x.jsx)(`ul`,{className:`divide-y rounded-lg border bg-background`,children:l.map(t=>{let n=C(t,a,e);return(0,x.jsxs)(`li`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h2`,{className:`font-semibold`,children:t.label}),(0,x.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t.description}),n&&(0,x.jsx)(`p`,{className:`mt-1.5 text-xs font-medium text-warning-text`,children:n})]}),(0,x.jsx)(S,{row:t,value:a[t.method],onChange:e=>c({...a,[t.method]:e})})]},t.method)})}),r&&(0,x.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-body font-medium text-danger-text`,children:r}),i&&!u&&(0,x.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.savedAt?e.savedBy?d(`lastSavedBy`,{name:e.savedBy,time:o(Date.parse(e.savedAt))}):d(`lastSaved`,{time:o(Date.parse(e.savedAt))}):d(`neverChanged`)}),(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[u&&(0,x.jsx)(s,{onClick:()=>c(e.policy),children:d(`reset`)}),(0,x.jsx)(s,{variant:`primary`,type:`submit`,loading:n,disabled:!u,children:d(`save`)})]})]})]})},E=(e,t)=>e.endedAt?(0,x.jsx)(r,{tone:`neutral`,children:d(`stopped`,{time:o(Date.parse(e.endedAt))})}):Date.parse(e.expiresAt)<=t?(0,x.jsx)(r,{tone:`neutral`,children:d(`ended`,{time:o(Date.parse(e.expiresAt))})}):(0,x.jsx)(r,{tone:`amber`,children:d(`signedInUntil`,{time:o(Date.parse(e.expiresAt))})}),D=({signIns:e,operator:t,error:n,now:r=Date.now()})=>(0,x.jsxs)(i,{title:d(`staffSignIns`),description:d(`staffSignInsDescription`,{operator:t}),children:[(0,x.jsx)(c,{message:n}),e&&e.length===0&&(0,x.jsx)(`p`,{className:`text-muted-foreground`,children:d(`noStaffSignIns`)}),e&&e.length>0&&(0,x.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,x.jsxs)(`li`,{className:`flex flex-col gap-1.5 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,x.jsx)(`span`,{className:`font-medium break-all`,children:e.staffName?`${e.staffName} (${e.staff})`:e.staff}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:d(`as`)}),(0,x.jsx)(`span`,{className:`font-medium break-all`,children:e.user})]}),(0,x.jsx)(`p`,{className:`break-words`,children:e.reason}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{children:o(Date.parse(e.startedAt))}),E(e,r)]})]},e.id))})]}),O=({operator:e})=>{let{session:t}=m(),[n,r]=(0,g.useState)(),[i,a]=(0,g.useState)();return(0,g.useEffect)(()=>{t.staff.log().then(r,e=>a(e instanceof f?p(e):d(`couldNotReadStaffSignIns`)))},[t]),(0,x.jsx)(D,{operator:e,signIns:n,error:i})},k=()=>{let{session:e}=m(),[t,n]=(0,g.useState)(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(),[s,c]=(0,g.useState)();(0,g.useEffect)(()=>{e.signInPolicy.read().then(n,e=>o(e instanceof f?p(e):d(`couldNotReadPolicy`)))},[e]);let l=async t=>{i(!0),o(void 0),c(void 0);try{n(await e.signInPolicy.save(t)),c(d(`policySaved`))}catch(e){if(!(e instanceof f))throw e;o(p(e))}i(!1)};return(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,x.jsx)(h,{title:d(`signInPolicy`),subtitle:d(`policySubtitle`)}),t?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{state:t,busy:r,error:a,notice:s,onSave:e=>void l(e)},t.savedAt??`default`),t.operator&&(0,x.jsx)(O,{operator:t.operator})]}):a?(0,x.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:a}):(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(u,{}),` `,d(`loading`)]})]})};export{k as SignInPolicyPage};
|
|
2
|
-
//# debugId=ea1fde10-6650-4451-9547-a7b845878763
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t}from"./react-CuiNlnus.js";import{Er as n,Jn as r,Mr as i,Oa as a,Po as o,Qn as s,Xo as c,an as l,ar as u,bs as d,dn as f,er as p,fn as m,hs as h,in as g,js as _,ki as v,rn as y,rs as b,sr as x,un as S,vs as C}from"./app-1j5nx8lw.js";import{h as w}from"./vendor-t7Q7QbPu.js";import{S as T,ht as E,r as D}from"./embedded-list-CQ7VmI-J.js";import{n as O}from"./record-preview-C8xkvcPt.js";var k=e(t(),1),A=e=>({queryKey:e.queryKey,start:t=>t.prefetchQuery(e)}),j=e=>({queryKey:e.queryKey,start:t=>t.prefetchInfiniteQuery(e)}),M={Table:(e,t,n)=>{let{resource:r,filter:i=``,sort:a=``,columns:o,button:s,bulk:c=!1,limit:u=10,select:p}=g(e),m=r===void 0?void 0:n.resources[r];if(!m)return[];if(t.part===`chosen`){let e=p===void 0?void 0:n.given[p];return e?[A(f(n.client,m,{key:e}))]:[]}let h=n.views[m.name],{fields:_,read:b}=l({...n,model:m,view:h,columns:o?.map(d),button:s,bulk:c,phoneColumns:y(o)});return[A(D(n,{model:m,filter:i,orderBy:a||v(m,h),limit:u,fields:_,read:b}))]},Chart:(e,t,{client:r,resources:i,views:a})=>{let{resource:o,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m}=g(e),h=i[o],_=h&&E({model:h,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m},i,a);return h&&_?[A(n(r,h.name,_))]:[]},RecordCards:(e,t,{client:n,resources:r,views:i})=>{let{resource:a,filter:o=``,sort:s=``,limit:c=10}=g(e),l=r[a];if(!l)return[];let u=s||v(l,i[l.name]);return[A(m(n,l,{filter:o,sort:u,pageSize:c})),A(S(n,l,o))]},RecordRow:(e,t,{client:n,queryClient:r,resources:i,views:a})=>{let{resource:o,filter:s=``,sort:c=``}=g(e),l=i[o];if(!l)return[];let u=a[l.name];return u?.searchesOf||u?.listOf!==void 0?[]:[A(O({queryClient:r,client:n,resources:i,views:a,model:l,...T(l,u,{filter:s,sort:c})}))]},Thread:(e,t,{client:n,resources:a,views:o})=>{let{resource:s,filter:c,sender:l,time:u,calls:d,limit:f=50}=g(e);if(t.part===`calls`){let e=d&&a[d.resource];return e?[j(i(n,e.name,{filter:d.filter,orderBy:_(d.time),pageSize:f}))]:[]}let p=a[s];if(!p)return[];let m=r(a,o,p,l===void 0?[]:[l]);return[j(i(n,p.name,{filter:c,orderBy:_(u),pageSize:f,labels:m}))]}},N=(e,t,{client:n,resources:r})=>{let i=r[t.resource];return i?[A(S(n,i))]:[]},P=(e,t,n)=>(n?.reads??[]).flatMap(n=>{let r=C(t,n.block);if(!r||r.custom)return[];if(n.part===`condition`)return N(r,n,e);if(n.split)return[];let i=M[r.type];return i?i(h(r,{stack:[],params:e.params,...e.root&&{root:e.root}}),n,e):[]}),F=({tree:e,plan:t})=>{let n=b(),r=w(),{resources:i,views:l}=c(),d=a().fields,f=o(),m=s(),h=p(),g=u(x()),_=(0,k.useMemo)(()=>P({client:n,queryClient:r,resources:i,views:l,fieldTypes:d,xs:f,params:m,given:h,...g&&{root:g}},e,t),[n,r,i,l,d,f,m,h,g,e,t]);return(0,k.useEffect)(()=>{for(let e of _)e.start(r)},[_,r]),null};export{F as t};
|
|
2
|
-
//# debugId=8011de32-5691-4f04-9b6c-7c0f4c40a93b
|