@protobase/ui 0.119.3 → 0.119.5
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/app/charts/messages.d.ts +2 -2
- package/dist/app/confirm-sign-in-messages.d.ts +2 -2
- package/dist/app/delete/messages.d.ts +2 -2
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-types/json/messages.d.ts +2 -2
- package/dist/app/field-types/runner-install/messages.d.ts +2 -2
- 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/focus/messages.d.ts +2 -2
- package/dist/app/gallery/gallery-layout.d.ts +2 -2
- package/dist/app/hand-order/messages.d.ts +2 -2
- package/dist/app/import/messages.d.ts +2 -2
- package/dist/app/list-messages.d.ts +2 -2
- package/dist/app/messages.d.ts +2 -2
- package/dist/app/meta-gate-messages.d.ts +2 -2
- 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-row/messages.d.ts +2 -2
- package/dist/app/runtime/messages.d.ts +2 -2
- package/dist/app/saved/messages.d.ts +2 -2
- package/dist/app/saved/use-favorite.d.ts +1 -1
- package/dist/app/searches/messages.d.ts +2 -2
- package/dist/app/searches/use-save-search.d.ts +1 -1
- package/dist/app-shell/messages.d.ts +2 -2
- 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/forms/messages.d.ts +2 -2
- package/dist/invitations/messages.d.ts +2 -2
- package/dist/markdown/markdown-html.js +2 -29
- package/dist/markdown/safe-html.d.ts +11 -0
- package/dist/markdown/safe-html.js +35 -0
- package/dist/mentions/link-text.d.ts +7 -0
- package/dist/mentions/link-text.js +19 -0
- package/dist/mentions/mention-text.d.ts +2 -0
- package/dist/mentions/mention-text.js +3 -1
- package/dist/mentions/mentioned-text.d.ts +7 -7
- package/dist/mentions/mentioned-text.js +14 -4
- package/dist/mentions/message-content.d.ts +10 -0
- package/dist/mentions/message-content.js +17 -0
- package/dist/mentions/message-html.d.ts +11 -0
- package/dist/mentions/message-html.js +55 -0
- package/dist/mentions/message-lines.d.ts +4 -0
- package/dist/mentions/message-lines.js +38 -0
- package/dist/notifications/bell/messages.d.ts +2 -2
- package/dist/organizations/messages.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/primitives/messages.d.ts +2 -2
- package/dist/shell/assets/{account-page-d4bA-Rnh.js → account-page-ve4BUXRh.js} +2 -2
- package/dist/shell/assets/{app-xwgcmboV.css → app-DLkpxjgP.css} +1 -1
- package/dist/shell/assets/{app-B94YfKGx.js → app-DU-Bny4k.js} +7 -7
- package/dist/shell/assets/{assistant-shell-DTNOfaAZ.js → assistant-shell-KyMQvcsn.js} +2 -2
- package/dist/shell/assets/board-display-BaMLmYUJ.js +2 -0
- package/dist/shell/assets/calendar-display-CzQPcItV.js +2 -0
- package/dist/shell/assets/{call-rings-D8cGALi4.js → call-rings-DUzC7UYz.js} +2 -2
- package/dist/shell/assets/{calls-DLSo4hNS.js → calls-drZLv0wW.js} +2 -2
- package/dist/shell/assets/{circle-alert-C8YjGdRx.js → circle-alert-COV0WNyG.js} +2 -2
- package/dist/shell/assets/composed-page-CBJLOXNJ.js +2 -0
- package/dist/shell/assets/{composer-section-6TvE0L2w.js → composer-section-05sGMnpR.js} +2 -2
- package/dist/shell/assets/{connect-route-C8Km-e8S.js → connect-route-KBsPFlW4.js} +2 -2
- package/dist/shell/assets/{copy-field-DXp0fGDR.js → copy-field-14Vmg95D.js} +2 -2
- package/dist/shell/assets/create-route-DAprAV2h.js +2 -0
- package/dist/shell/assets/{custom-step-container-field-B8ut5WnP.js → custom-step-container-field-D0cmhURR.js} +4 -4
- package/dist/shell/assets/embedded-list-Ra3OLUh6.js +3 -0
- package/dist/shell/assets/{export-dialog-gSUSlzOy.js → export-dialog-Cz26bxgN.js} +2 -2
- package/dist/shell/assets/{first-organization-page-C7YZ32Kt.js → first-organization-page-C9ejBI4S.js} +2 -2
- package/dist/shell/assets/{graph-view-_7poAZsr.js → graph-view-B3TE-xbG.js} +2 -2
- package/dist/shell/assets/{group-donut-XjNEBVUq.js → group-donut-BAyTgqYv.js} +2 -2
- package/dist/shell/assets/{guest-call-page-Cj6F3D3u.js → guest-call-page-CEcPrLXS.js} +3 -3
- package/dist/shell/assets/{html-viewer-CmYTAzWa.js → html-viewer-DaeVR6PB.js} +2 -2
- package/dist/shell/assets/{import-dialog-bNG6qX6Q.js → import-dialog-6I25EI49.js} +2 -2
- package/dist/shell/assets/import-table-dialog-COsPNket.js +2 -0
- package/dist/shell/assets/{index-CYraq2Hi.js → index-CLyiQa16.js} +1 -1
- package/dist/shell/assets/{invitations-page-XV6kL2Mk.js → invitations-page-TBz_-ekD.js} +2 -2
- package/dist/shell/assets/{layout-grid-dpoR6hFU.js → layout-grid-BTGS8Vdw.js} +2 -2
- package/dist/shell/assets/{legend-item-WwKh2W6n.js → legend-item-DkIaBiD0.js} +2 -2
- package/dist/shell/assets/list-page-Dpq9M7YO.js +4 -0
- package/dist/shell/assets/{maplibre-Bm0OQH9k.js → maplibre-JTZsxvhv.js} +2 -2
- package/dist/shell/assets/{markdown-content-BZLiLira.js → markdown-content-DBVa63k_.js} +2 -2
- package/dist/shell/assets/members-page-CHRY9H9W.js +2 -0
- package/dist/shell/assets/message-content-DzyGCvgQ.js +3 -0
- package/dist/shell/assets/messages-BwcGcxFR.js +2 -0
- package/dist/shell/assets/organization-page-BE182e_K.js +2 -0
- package/dist/shell/assets/organizations-page-DaN6zQZj.js +2 -0
- package/dist/shell/assets/{pending-invitation-row-BZVOux9W.js → pending-invitation-row-DvqK-Lh5.js} +2 -2
- package/dist/shell/assets/{period-chart-GDqLnl9l.js → period-chart-Cn9bgVfB.js} +2 -2
- package/dist/shell/assets/{person-row-DgXLW9D8.js → person-row-CSBZnBQc.js} +2 -2
- package/dist/shell/assets/public-form-page-CaNVr6BS.js +2 -0
- package/dist/shell/assets/{record-lines-CDTPiIdF.js → record-lines-3DhkRSpH.js} +2 -2
- package/dist/shell/assets/{record-map-Dcmuv9J8.js → record-map-D4rgUOwb.js} +2 -2
- package/dist/shell/assets/{record-opens-D7SV04zf.js → record-opens-BSFQWqio.js} +2 -2
- package/dist/shell/assets/record-page-Cbx9gqMY.js +3 -0
- package/dist/shell/assets/{record-preview-DsIrTWKZ.js → record-preview-Bdzkrw0H.js} +2 -2
- package/dist/shell/assets/{records-map-G0QXqaUR.js → records-map-BfkBfva4.js} +2 -2
- package/dist/shell/assets/render-node-ChsAMZVA.js +3 -0
- package/dist/shell/assets/reorder-button-pGaEX5DI.js +2 -0
- package/dist/shell/assets/{run-trace-view-DLY3Mt5m.js → run-trace-view-Cd3DppYM.js} +2 -2
- package/dist/shell/assets/{runner-install-field-Iwp4UP6o.js → runner-install-field-CK3olYt5.js} +2 -2
- package/dist/shell/assets/{runtime-update-DKcAQek2.js → runtime-update-BNTp15Vo.js} +2 -2
- package/dist/shell/assets/safe-html-CmkqDcA6.js +2 -0
- package/dist/shell/assets/shared-protobase-ui-gnK6D3Al.js +1 -0
- package/dist/shell/assets/sheet-source-DONoSDqu.js +3 -0
- package/dist/shell/assets/sign-in-policy-page-C4MEEpwM.js +2 -0
- package/dist/shell/assets/start-block-queries-B7qJvkWD.js +2 -0
- package/dist/shell/assets/step-catalog-CgPcuEu_.js +2 -0
- package/dist/shell/assets/{step-panel-BXHWAw8x.js → step-panel-CoFQOZfZ.js} +2 -2
- package/dist/shell/assets/timeline-display-F8qMrey9.js +2 -0
- package/dist/shell/assets/{trash-MHAT5Hf3.js → trash-BFH8OA7M.js} +2 -2
- package/dist/shell/assets/{update-set-B0D_tNDz.js → update-set-CivHicWr.js} +2 -2
- package/dist/shell/assets/use-calendar-move-CezBW0KE.js +2 -0
- package/dist/shell/assets/{use-display-rows-vjthlkqo.js → use-display-rows-7iLrRpz6.js} +2 -2
- package/dist/shell/assets/use-my-invitations-B7w0Q5kk.js +2 -0
- package/dist/shell/assets/{use-paged-search-DRj8498k.js → use-paged-search-CblCRsCd.js} +2 -2
- package/dist/shell/assets/{use-run-trace-CWGAibgF.js → use-run-trace-vMzYYuXG.js} +2 -2
- package/dist/shell/assets/{use-workflow-page-C9ZEXX5R.js → use-workflow-page-Dac4wyOA.js} +2 -2
- package/dist/shell/assets/{use-workflow-types-DDh28X2_.js → use-workflow-types-Bi8u42jQ.js} +2 -2
- package/dist/shell/assets/{workflow-canvas-n_YJtaOh.js → workflow-canvas-2owtFZNz.js} +4 -4
- package/dist/shell/assets/{workflow-field-CpkY17Cc.js → workflow-field-Ct0HoH5Z.js} +3 -3
- package/dist/shell/assets/{workflow-graph-editor-V-ZGHSrC.js → workflow-graph-editor-oAKVQAgf.js} +2 -2
- package/dist/shell/assets/{workflow-run-field-CoUJGVdX.js → workflow-run-field-C7ff1D9_.js} +3 -3
- package/dist/shell/assets/workflow-status-field-iHUr4FZM.js +2 -0
- package/dist/shell/assets/workflow-workbench-BCsEjQVw.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-d4bA-Rnh.js.map → account-page-ve4BUXRh.js.map} +1 -1
- package/dist/shell-source-maps/assets/app-DU-Bny4k.js.map +1 -0
- package/dist/shell-source-maps/assets/{assistant-shell-DTNOfaAZ.js.map → assistant-shell-KyMQvcsn.js.map} +1 -1
- package/dist/shell-source-maps/assets/{board-display-ClTe26F0.js.map → board-display-BaMLmYUJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calendar-display-CwBcu_JO.js.map → calendar-display-CzQPcItV.js.map} +1 -1
- package/dist/shell-source-maps/assets/{call-rings-D8cGALi4.js.map → call-rings-DUzC7UYz.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calls-DLSo4hNS.js.map → calls-drZLv0wW.js.map} +1 -1
- package/dist/shell-source-maps/assets/{circle-alert-C8YjGdRx.js.map → circle-alert-COV0WNyG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composed-page-DBHl-wl_.js.map → composed-page-CBJLOXNJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composer-section-6TvE0L2w.js.map → composer-section-05sGMnpR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{connect-route-C8Km-e8S.js.map → connect-route-KBsPFlW4.js.map} +1 -1
- package/dist/shell-source-maps/assets/{copy-field-DXp0fGDR.js.map → copy-field-14Vmg95D.js.map} +1 -1
- package/dist/shell-source-maps/assets/{create-route-s8RsjtyM.js.map → create-route-DAprAV2h.js.map} +1 -1
- package/dist/shell-source-maps/assets/{custom-step-container-field-B8ut5WnP.js.map → custom-step-container-field-D0cmhURR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{embedded-list-OJQKeuBN.js.map → embedded-list-Ra3OLUh6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{export-dialog-gSUSlzOy.js.map → export-dialog-Cz26bxgN.js.map} +1 -1
- package/dist/shell-source-maps/assets/{first-organization-page-C7YZ32Kt.js.map → first-organization-page-C9ejBI4S.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-_7poAZsr.js.map → graph-view-B3TE-xbG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{group-donut-XjNEBVUq.js.map → group-donut-BAyTgqYv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{guest-call-page-Cj6F3D3u.js.map → guest-call-page-CEcPrLXS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-CmYTAzWa.js.map → html-viewer-DaeVR6PB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-dialog-bNG6qX6Q.js.map → import-dialog-6I25EI49.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-table-dialog-BbI7GJ8R.js.map → import-table-dialog-COsPNket.js.map} +1 -1
- package/dist/shell-source-maps/assets/{invitations-page-XV6kL2Mk.js.map → invitations-page-TBz_-ekD.js.map} +1 -1
- package/dist/shell-source-maps/assets/{layout-grid-dpoR6hFU.js.map → layout-grid-BTGS8Vdw.js.map} +1 -1
- package/dist/shell-source-maps/assets/{legend-item-WwKh2W6n.js.map → legend-item-DkIaBiD0.js.map} +1 -1
- package/dist/shell-source-maps/assets/{list-page-DImD2FRO.js.map → list-page-Dpq9M7YO.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-Bm0OQH9k.js.map → maplibre-JTZsxvhv.js.map} +1 -1
- package/dist/shell-source-maps/assets/markdown-content-DBVa63k_.js.map +1 -0
- package/dist/shell-source-maps/assets/{members-page-ZcqzlQu6.js.map → members-page-CHRY9H9W.js.map} +1 -1
- package/dist/shell-source-maps/assets/message-content-DzyGCvgQ.js.map +1 -0
- package/dist/shell-source-maps/assets/{messages-vzi5T1Xo.js.map → messages-BwcGcxFR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organization-page-CjrQmpot.js.map → organization-page-BE182e_K.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organizations-page-C7gJsoCx.js.map → organizations-page-DaN6zQZj.js.map} +1 -1
- package/dist/shell-source-maps/assets/{pending-invitation-row-BZVOux9W.js.map → pending-invitation-row-DvqK-Lh5.js.map} +1 -1
- package/dist/shell-source-maps/assets/{period-chart-GDqLnl9l.js.map → period-chart-Cn9bgVfB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{person-row-DgXLW9D8.js.map → person-row-CSBZnBQc.js.map} +1 -1
- package/dist/shell-source-maps/assets/{public-form-page-DjLnqHPx.js.map → public-form-page-CaNVr6BS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-lines-CDTPiIdF.js.map → record-lines-3DhkRSpH.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-Dcmuv9J8.js.map → record-map-D4rgUOwb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-opens-D7SV04zf.js.map → record-opens-BSFQWqio.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-page-DGWHTUdD.js.map → record-page-Cbx9gqMY.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-preview-DsIrTWKZ.js.map → record-preview-Bdzkrw0H.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-G0QXqaUR.js.map → records-map-BfkBfva4.js.map} +1 -1
- package/dist/shell-source-maps/assets/{render-node-0_Pb8ixy.js.map → render-node-ChsAMZVA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{reorder-button-BhhzhhTO.js.map → reorder-button-pGaEX5DI.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-DLY3Mt5m.js.map → run-trace-view-Cd3DppYM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runner-install-field-Iwp4UP6o.js.map → runner-install-field-CK3olYt5.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runtime-update-DKcAQek2.js.map → runtime-update-BNTp15Vo.js.map} +1 -1
- package/dist/shell-source-maps/assets/safe-html-CmkqDcA6.js.map +1 -0
- package/dist/shell-source-maps/assets/{sheet-source-DxVQhlKF.js.map → sheet-source-DONoSDqu.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sign-in-policy-page-E1eBhmUM.js.map → sign-in-policy-page-C4MEEpwM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{start-block-queries-Bu7xMabd.js.map → start-block-queries-B7qJvkWD.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-catalog-BPk6WuYH.js.map → step-catalog-CgPcuEu_.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-BXHWAw8x.js.map → step-panel-CoFQOZfZ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{timeline-display-CJHQiDm9.js.map → timeline-display-F8qMrey9.js.map} +1 -1
- package/dist/shell-source-maps/assets/{trash-MHAT5Hf3.js.map → trash-BFH8OA7M.js.map} +1 -1
- package/dist/shell-source-maps/assets/{update-set-B0D_tNDz.js.map → update-set-CivHicWr.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-calendar-move-O_48Gqvs.js.map → use-calendar-move-CezBW0KE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-display-rows-vjthlkqo.js.map → use-display-rows-7iLrRpz6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-my-invitations-DDPuugTE.js.map → use-my-invitations-B7w0Q5kk.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-paged-search-DRj8498k.js.map → use-paged-search-CblCRsCd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-run-trace-CWGAibgF.js.map → use-run-trace-vMzYYuXG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-page-C9ZEXX5R.js.map → use-workflow-page-Dac4wyOA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-types-DDh28X2_.js.map → use-workflow-types-Bi8u42jQ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-n_YJtaOh.js.map → workflow-canvas-2owtFZNz.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-field-CpkY17Cc.js.map → workflow-field-Ct0HoH5Z.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-V-ZGHSrC.js.map → workflow-graph-editor-oAKVQAgf.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-run-field-CoUJGVdX.js.map → workflow-run-field-C7ff1D9_.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-status-field-nmrhtSls.js.map → workflow-status-field-iHUr4FZM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-workbench-DvzNEdn3.js.map → workflow-workbench-BCsEjQVw.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/board-display-ClTe26F0.js +0 -2
- package/dist/shell/assets/calendar-display-CwBcu_JO.js +0 -2
- package/dist/shell/assets/composed-page-DBHl-wl_.js +0 -2
- package/dist/shell/assets/create-route-s8RsjtyM.js +0 -2
- package/dist/shell/assets/embedded-list-OJQKeuBN.js +0 -3
- package/dist/shell/assets/import-table-dialog-BbI7GJ8R.js +0 -2
- package/dist/shell/assets/list-page-DImD2FRO.js +0 -4
- package/dist/shell/assets/members-page-ZcqzlQu6.js +0 -2
- package/dist/shell/assets/messages-vzi5T1Xo.js +0 -2
- package/dist/shell/assets/organization-page-CjrQmpot.js +0 -2
- package/dist/shell/assets/organizations-page-C7gJsoCx.js +0 -2
- package/dist/shell/assets/public-form-page-DjLnqHPx.js +0 -2
- package/dist/shell/assets/record-page-DGWHTUdD.js +0 -3
- package/dist/shell/assets/render-node-0_Pb8ixy.js +0 -3
- package/dist/shell/assets/reorder-button-BhhzhhTO.js +0 -2
- package/dist/shell/assets/shared-protobase-ui-XTZSVgEm.js +0 -1
- package/dist/shell/assets/sheet-source-DxVQhlKF.js +0 -3
- package/dist/shell/assets/sign-in-policy-page-E1eBhmUM.js +0 -2
- package/dist/shell/assets/start-block-queries-Bu7xMabd.js +0 -2
- package/dist/shell/assets/step-catalog-BPk6WuYH.js +0 -2
- package/dist/shell/assets/timeline-display-CJHQiDm9.js +0 -2
- package/dist/shell/assets/use-calendar-move-O_48Gqvs.js +0 -2
- package/dist/shell/assets/use-my-invitations-DDPuugTE.js +0 -2
- package/dist/shell/assets/workflow-status-field-nmrhtSls.js +0 -2
- package/dist/shell/assets/workflow-workbench-DvzNEdn3.js +0 -4
- package/dist/shell-source-maps/assets/app-B94YfKGx.js.map +0 -1
- package/dist/shell-source-maps/assets/markdown-content-BZLiLira.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MessageValue } from "../locale/messages.js";
|
|
2
2
|
//#region src/status/messages.d.ts
|
|
3
3
|
export declare const text: {
|
|
4
|
-
(id: "
|
|
5
|
-
rich(id: "
|
|
4
|
+
(id: "cancel" | "online" | "custom" | "away" | "setStatus" | "editStatus" | "availability" | "automatic" | "busy" | "doNotDisturb" | "doNotDisturbHint" | "statusText" | "statusPlaceholder" | "clearsAfter" | "never" | "thirtyMinutes" | "oneHour" | "fourHours" | "today" | "thisWeek" | "clearsAt" | "pickTime" | "save" | "clear" | "couldNotSave" | "until", values?: Record<string, MessageValue>): string;
|
|
5
|
+
rich(id: "cancel" | "online" | "custom" | "away" | "setStatus" | "editStatus" | "availability" | "automatic" | "busy" | "doNotDisturb" | "doNotDisturbHint" | "statusText" | "statusPlaceholder" | "clearsAfter" | "never" | "thirtyMinutes" | "oneHour" | "fourHours" | "today" | "thisWeek" | "clearsAt" | "pickTime" | "save" | "clear" | "couldNotSave" | "until", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
|
|
6
6
|
};
|
|
7
7
|
//#endregion
|
package/dist/users/messages.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MessageValue } from "../locale/messages.js";
|
|
2
2
|
//#region src/users/messages.d.ts
|
|
3
3
|
export declare const text: {
|
|
4
|
-
(id: "
|
|
5
|
-
rich(id: "
|
|
4
|
+
(id: "name" | "people" | "email" | "password" | "passwordOptional" | "block" | "inviteSomeone" | "inviteDescription" | "notAcceptedYet" | "sendingAgain" | "nobodyWaiting" | "couldNotReadRoles" | "addAnAccount" | "addDescription" | "addAccount" | "peopleDescription" | "findSomeone" | "emailAddress" | "keepOneRole" | "blocked" | "unblock", values?: Record<string, MessageValue>): string;
|
|
5
|
+
rich(id: "name" | "people" | "email" | "password" | "passwordOptional" | "block" | "inviteSomeone" | "inviteDescription" | "notAcceptedYet" | "sendingAgain" | "nobodyWaiting" | "couldNotReadRoles" | "addAnAccount" | "addDescription" | "addAccount" | "peopleDescription" | "findSomeone" | "emailAddress" | "keepOneRole" | "blocked" | "unblock", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
|
|
6
6
|
};
|
|
7
7
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/ui",
|
|
3
|
-
"version": "0.119.
|
|
3
|
+
"version": "0.119.5",
|
|
4
4
|
"description": "The Protobase admin app and the React hooks and components for custom UI.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@dnd-kit/core": "^6.3.1",
|
|
42
42
|
"@dnd-kit/sortable": "^10.0.0",
|
|
43
|
-
"@protobase/client": "0.119.
|
|
44
|
-
"@protobase/layout": "0.119.
|
|
45
|
-
"@protobase/schema": "0.119.
|
|
46
|
-
"@protobase/workflows": "0.119.
|
|
43
|
+
"@protobase/client": "0.119.5",
|
|
44
|
+
"@protobase/layout": "0.119.5",
|
|
45
|
+
"@protobase/schema": "0.119.5",
|
|
46
|
+
"@protobase/workflows": "0.119.5",
|
|
47
47
|
"@sentry/browser": "^11.7.0",
|
|
48
48
|
"@tanstack/react-query": "^5.104.1",
|
|
49
49
|
"@tanstack/react-table": "^9.2.6",
|
|
@@ -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,Ea as i,Ga as a,Hc as o,Pa as s,Xl as c,ai as l,ci as u,cl as d,fl as f,ic as p,ja as m,ls as h,mr as g,ns as _,oi as v,rs as y,sc as b,si as x,ui as S,vn as C,wa as w,wn as T,xa as E}from"./app-B94YfKGx.js";import{i as D}from"./vendor-t7Q7QbPu.js";import{w as O}from"./embedded-list-OJQKeuBN.js";import{r as k}from"./record-preview-DsIrTWKZ.js";import{_ as A,a as j,g as M,i as N,n as ee,o as P,t as F,v as I}from"./lib-dnd-kit-core-xi-7xL_N.js";import{a as L,i as R,n as z,t as B}from"./lib-dnd-kit-sortable-CNDSKqCD.js";import{a as V,i as te,l as ne,n as H,o as U,r as W,s as G,t as K}from"./messages-vzi5T1Xo.js";import{n as re,r as q,t as ie}from"./board-dnd-pi-vIUTz.js";import{t as ae}from"./use-display-rows-vjthlkqo.js";var J=e=>typeof e==`number`&&Number.isInteger(e),oe=(e,t,n)=>{let r=0;for(;r<t&&J(e[r])&&(r===0||e[r]>e[r-1]);)r+=1;let i=e.length;for(;i-1>n&&J(e[i-1])&&(i===e.length||e[i-1]<e[i]);)--i;let a=Math.min(t,r),o=a===0?1:e[a-1]+1,s=Math.max(n,i-1);for(;s+1<e.length&&e[s+1]<=o+(s-a);)s+=1;return{first:a,last:s,start:o}},Y=e(t(),1),se=({model:e,by:t,value:n,fields:r,filter:i,orderBy:a})=>{let{resources:o,views:s}=_(),c=k({resources:o,views:s,model:e,columns:r,filter:u(i,t,n),orderBy:a});return ae(e,c.page,c.key,!0)},X=e(n(),1),ce=(e,t)=>{if(!t)return e;let n=new Map(e.map(e=>[e.key,e])),r=new Set(t);return[...t.flatMap(e=>n.get(e)??[]),...e.filter(e=>!r.has(e.key))]},le=({model:e,view:t,display:n,column:a,fields:s,filter:c,orderBy:u,limit:f,moves:m,movable:h,placeable:_,dragged:v})=>{let y=se({model:e,by:n.by,value:a.value,fields:s,filter:c,orderBy:u}),x=l(e,t,n),C=new Set(y.rows.map(e=>e.key)),w=new Map(m.map(e=>[e.row.key,e])),E=y.rows.filter(e=>w.has(e.key)&&w.get(e.key).to!==a.value),D=m.filter(e=>e.to===a.value&&!C.has(e.row.key)).map(e=>e.row),O=y.rows.filter(e=>!E.includes(e)).map(e=>w.has(e.key)?w.get(e.key).row:e),k=m.findLast(e=>e.to===a.value&&e.order),A=ce([...D,...O],k?.order),j=A.slice(0,f),N=y.more||A.length>j.length,{setNodeRef:ee,isOver:P}=M({id:q(a.value),data:{column:a,rows:j,more:N}}),F=y.total-E.length+D.length;if(a.value===null&&!y.loading&&F===0&&!P)return null;let I=(t?.names?.plural??d(e.name)).toLowerCase(),R=t?.fields[n.by];return(0,X.jsxs)(`section`,{ref:ee,"aria-label":`${a.label}, ${F}`,className:o(`flex w-72 shrink-0 snap-start flex-col gap-2 rounded-lg bg-surface p-2`,P&&`ring-2 ring-primary/30`),children:[(0,X.jsxs)(`header`,{className:`flex items-center justify-between gap-2 px-1 pt-0.5`,children:[(0,X.jsx)(`h2`,{className:`min-w-0 truncate text-body font-medium`,children:a.value===null?(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:a.label}):(0,X.jsx)(T,{value:a.value,hints:R,children:a.label})}),!y.loading&&(0,X.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:F.toLocaleString(r())})]}),y.loading?Array.from({length:3},(e,t)=>(0,X.jsx)(p,{className:`h-20`},t)):y.error?(0,X.jsx)(g,{title:S(`couldNotLoadRows`),error:y.error}):j.length===0?(0,X.jsx)(`p`,{className:`px-1 py-4 text-center text-xs text-muted-foreground`,children:S(`noPlural`,{plural:I})}):(0,X.jsx)(B,{id:q(a.value),items:j.map(e=>e.key),strategy:L,children:(0,X.jsx)(`ul`,{className:`-mb-2 flex flex-col`,children:j.map(n=>(0,X.jsx)(ue,{model:e,view:t,card:x,row:n,column:a,rows:j,more:N,draggable:(h||_)&&i(n.record,`update`),placeable:_,dragged:v},n.key))})}),f===void 0&&y.more&&(0,X.jsx)(b,{size:`sm`,variant:`ghost`,onClick:y.loadMore,children:S(`showMore`)})]})},ue=({model:e,view:t,card:n,row:r,column:i,rows:a,more:s,draggable:c,placeable:l,dragged:u})=>{let{setNodeRef:d,setActivatorNodeRef:f,listeners:p,isDragging:m,isOver:h,active:g,transform:_,transition:v}=R({id:r.key,data:{row:r,column:i,rows:a,more:s},disabled:{draggable:!c,droppable:!l}}),y=h&&g?.data.current?.column?.value!==i.value;return(0,X.jsx)(`li`,{ref:e=>{d(e),f(e?.querySelector(`a[data-card-link]`)??e)},...p,onDragStart:e=>e.preventDefault(),onClickCapture:e=>{u()&&(e.preventDefault(),e.stopPropagation())},style:{transform:_?`translate3d(${_.x}px, ${_.y}px, 0)`:void 0,transition:v},className:o(`relative pb-2`,c&&`cursor-grab touch-manipulation`,m&&`opacity-40`,y&&`before:absolute before:inset-x-0 before:-top-1 before:h-0.5 before:rounded-full before:bg-primary`),children:(0,X.jsx)(O,{model:e,view:t,display:n,row:r,swipe:!1})})},de=e=>e.kind===`and`?e.args.flatMap(de):[e],fe=e=>e.kind===`string`?String(e.value):void 0,pe=(e,t)=>{if(e.kind===`compare`&&e.op===`=`&&e.field.path.join(`.`)===t){let t=fe(e.value);return t===void 0?void 0:[t]}if(e.kind===`in`&&e.field.path.join(`.`)===t){let t=e.values.map(fe);return t.every(e=>e!==void 0)?t:void 0}},me=(e,t,n)=>{let r=c(e);if(!r.ok||!r.ast)return n;let i=de(r.ast).map(e=>pe(e,t)).filter(e=>e!==void 0);return n.filter(e=>i.every(t=>e.value!==null&&t.includes(e.value)))},he=(e,t)=>t!==null&&Object.hasOwn(e,t)?e[t]:void 0,ge=(e,t,n)=>{let r=e.findIndex(e=>e.key===t.key);return r===-1?[...e.slice(0,n),t,...e.slice(n)]:z(e,r,n)},Z=(e,t,n)=>{let r=e.findIndex(e=>e.key===t.key);return{order:ge(e,t,n),first:r===-1?n:Math.min(r,n),last:r===-1?n:Math.max(r,n)}},_e=(e,t,n,r,i,a,o,s,c)=>{let l=E(e,i.record),d=o.findIndex(e=>e.key===i.key),p=W(e,n,u(r,t,a.value),o.map(e=>e.record),d,s),m=c===void 0?[]:[{op:`reorder`,resource:e.name,field:n,keys:[l],start:c,etags:{[f(l)]:`*`}}];return[...(i.record[t]??null)===a.value?[]:[{op:`update`,resource:e.name,key:l,data:{[t]:a.value},etag:`*`}],...m,p]},ve=(e,t,n,r)=>{let i=t=>f(E(e,t)),a=H(r.results,i),o=new Map(n.map(e=>{let n=i(e.record);return[n,a.has(n)?{...e.record,[t]:a.get(n)}:e.record]})),s=new Map;for(let e of r.results){let t=e.op===`reorder`||e.op===`move`?e.records:e.op===`update`?[e]:[];for(let{record:e,etag:n}of t)s.set(i(e),{record:e,etag:n})}return[...s].flatMap(([e,t])=>{let n=o.get(e);return n?[{before:n,...t}]:[]})},Q=e=>e!=null&&e!==``,ye=({model:e,rank:t,rows:n,row:r,index:i,bounds:a,title:o})=>{let s=n.some(e=>e.key===r.key)?n.length-1:n.length,c;for(let l=i;l<=s;l++){let{order:i,first:u,last:d}=Z(n,r,l),p=i.map(e=>e.record[t]),m=oe(p,u,d),h=new Map(i.map((t,n)=>[f(E(e,t.record)),n>=m.first&&n<=m.last?m.start+n-m.first:p[n]])),g=e=>h.has(e.key)?h.get(e.key):e.rank,_=Number(h.get(f(E(e,r.record)))),v=a.after.filter(e=>Q(g(e))&&Number(g(e))>=_),y=a.before.find(e=>Q(g(e))&&Number(g(e))<=_),b=y?K(`dependsOn`,{record:y.title,other:o}):v[0]&&K(`dependsOn`,{record:o,other:v[0].title});if(!b)return{place:{index:l},...c!==void 0&&{reason:c}};if(c??=b,l!==s||y)continue;let x=Math.max(...v.map(e=>Number(g(e))))+1;if(a.before.every(e=>!Q(g(e))||Number(g(e))>x))return{place:{index:l,bump:x},reason:c}}return{reason:c}},be=({model:e,view:t,by:n,rank:r,filter:i,drop:a,labelOf:o,titleOf:c})=>{let l=h(),u=s(),d=C(),[f,p]=(0,Y.useState)([]),m=(0,Y.useRef)(void 0),g=e=>p(t=>t.filter(t=>t.row.key!==e)),_=r?[n,r]:[n],v=D({mutationFn:e=>e(),onError:e=>u.show(U(e,S(`couldNotUndo`),{place:`board`})),onSettled:()=>d(e.name)}),y=async(t,r)=>{let i=a&&he(a,r.value);if(!i)throw Error(`The column ${r.label} takes no cards`);let o=E(e,t.record),s=typeof t.record.etag==`string`?t.record.etag:`*`,c=await i({resource:e.name,record:t.record,recordKey:o,etag:s,to:r.value,client:l});return{landed:(await l.get(e.name,o)).record[n]??null,...c&&{undo:c}}},b=(t,n)=>({landed:n.value,undo:()=>l.batchWrite(V(e,t,_))}),x=(e,t,r)=>{let i={...e,record:{...e.record,[n]:t.value}},a=r?.map(e=>e.key);p(n=>[...n.filter(t=>t.row.key!==e.key),{row:i,to:t.value,...a&&{order:a}}])},w=async(n,i,a)=>{if(!e.position?.after)return{index:a.index};let o=await te(l,e,t,n.record),s=ye({model:e,rank:r,rows:a.rows,row:n,index:a.index,bounds:o,title:c(n)}),d=!s.place||s.place.bump===void 0&&s.place.index===a.rows.findIndex(e=>e.key===n.key);if(s.reason!==void 0&&u.show({state:`warning`,title:d?G(`notMoved`):G(`movedToPlace`,{place:s.place.index+1}),description:s.reason}),!d)return s.place.index!==a.index&&x(n,i,Z(a.rows,n,s.place.index).order),s.place},T=async(t,a,o)=>{let s=await w(t,a,o);if(!s)return;let{order:c}=Z(o.rows,t,s.index);return b(ve(e,r,c,await l.batchWrite(_e(e,n,r,i,t,a,c,o.more,s.bump))),a)},O=D({mutationFn:async({row:t,to:i,place:o})=>{if(o&&!r)throw Error(`A board places a card only by its rank`);let s=t.record[n]??null;if(a&&i.value!==s)return y(t,i);if(o)return T(t,i,o);let c=typeof t.record.etag==`string`?t.record.etag:`*`,u=await l.update(e.name,E(e,t.record),{[n]:i.value},c);return b([{before:t.record,record:u.record,etag:u.etag}],i)},onMutate:({row:e,to:t,place:n})=>x(e,t,n&&Z(n.rows,e,n.index).order),onSuccess:(e,{row:t,to:r})=>{if(!e)return;let{landed:i,undo:a}=e;m.current!==void 0&&u.dismiss(m.current),m.current=void 0;let s=t.record[n]??null,c=i===s?s===r.value?S(`orderChanged`):S(`stayedIn`,{column:o(i)}):S(`movedTo`,{column:o(i)});if(!a){u.show({state:`success`,title:c});return}let l=u.show({state:`success`,title:c,action:{label:S(`undo`),onClick:()=>{u.dismiss(l),m.current=void 0,v.mutate(a)}}});m.current=l},onError:(e,{row:t,to:r})=>{g(t.key);let i=(t.record[n]??null)===r.value?S(`couldNotReorder`):S(`couldNotMoveTo`,{to:r.label});u.show(U(e,i,{place:`board`,title:c(t)}))},onSettled:async(t,n,{row:r})=>{await d(e.name),g(r.key)}});return{moves:f,move:(e,t,n)=>O.mutate({row:e,to:t,...n&&{place:n}})}},$=(e,t)=>{let n=e.data.current;if(!n?.column||!n.rows)return;let r=n.more===!0;if(n.sortable)return{column:n.column,rows:n.rows,more:r,index:n.sortable.index};let i=n.rows.some(e=>e.key===t.key);return{column:n.column,rows:n.rows,more:r,index:i?n.rows.length-1:n.rows.length}},xe=({model:e,view:t,display:n,fields:r,filter:i,orderBy:o,limit:s})=>{let c=v(e,t,n),u=me(i,n.by,c),d=l(e,t,n),f=y(e.name),{boardDrops:p}=m(),h=t?.list?.drag,g=typeof h?.board==`string`?h.board:void 0,_=g===void 0?void 0:p?.[g],b=t=>w(f,`update`)&&(h?.board===!0?!e.fields[n.by]?.readOnly:_!==void 0&&he(_,t)!==void 0),C=u.some(e=>b(e.value)),T=x(e),E=h?.rank===!0&&T!==void 0&&ne(e,f)!==void 0,D=T?`${T} asc`:o,k=e=>c.find(t=>t.value===e)?.label??String(e),M=e=>String(e.labels[d.title]??e.record[d.title]??e.key),{moves:L,move:R}=be({model:e,view:t,by:n.by,rank:T,filter:i,drop:_,labelOf:k,titleOf:M}),[z,B]=(0,Y.useState)(),V=(0,Y.useRef)(!1),te=I(A(j,{activationConstraint:{distance:4}}),A(P,{activationConstraint:{delay:250,tolerance:5}}),A(N,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:ie}));if(g!==void 0&&!_)return(0,X.jsx)(a,{children:S.rich(`noDrop`,{drop:g})});let H=e=>u.find(t=>q(t.value)===e),U=e=>e.record[n.by]??null,W=(e,t)=>b(U(e))&&b(t.value),G=(e,t)=>{if(!t)return{over:S(`noColumn`)};let n=E?$(t,e):void 0;if(!n)return{over:H(t.id)?.label??S(`noColumn`)};let r=n.rows.some(t=>t.key===e.key)?n.rows.length:n.rows.length+1;return{over:S(`placeOf`,{column:n.column.label,place:n.index+1,count:r}),place:S(`place`,{column:n.column.label,place:n.index+1})}},K=(e,t)=>{let n=(E?$(t,e)?.column:void 0)??H(t.id);return n!==void 0&&n.value!==U(e)&&!W(e,n)};return(0,X.jsxs)(F,{sensors:te,collisionDetection:re,onDragStart:({active:e})=>{V.current=!0,B(e.data.current.row)},onDragEnd:({active:e,over:t})=>{B(void 0),setTimeout(()=>V.current=!1);let n=e.data.current.row;if(!t)return;let r=E?$(t,n):void 0;if(!r){let e=H(t.id);e&&e.value!==U(n)&&W(n,e)&&R(n,e);return}let i=r.rows.findIndex(e=>e.key===n.key);if(i!==-1||W(n,r.column)){if(i===-1&&_)return R(n,r.column);i!==r.index&&R(n,r.column,{rows:r.rows,more:r.more,index:r.index})}},onDragCancel:()=>{B(void 0),setTimeout(()=>V.current=!1)},accessibility:{announcements:{onDragStart:({active:e})=>S(`pickedUp`,{title:M(e.data.current.row)}),onDragOver:({active:e,over:t})=>S(`isOver`,{title:M(e.data.current.row),over:G(e.data.current.row,t).over}),onDragEnd:({active:e,over:t})=>{let n=e.data.current.row;if(!t||K(n,t))return S(`putBack`,{title:M(n)});let r=G(n,t);return S(`wasMovedTo`,{title:M(n),to:r.place??r.over})},onDragCancel:({active:e})=>S(`cancelled`,{title:M(e.data.current.row)})},screenReaderInstructions:{draggable:S(E?C?`boardAnywhere`:`boardWithin`:`boardAcross`)}},children:[(0,X.jsx)(`div`,{className:`relative min-w-0 flex-1 overflow-x-auto`,children:(0,X.jsx)(`div`,{className:`flex snap-x items-start gap-3 pb-2`,children:u.map(a=>(0,X.jsx)(le,{model:e,view:t,display:n,column:a,fields:r,filter:i,orderBy:D,limit:s,moves:L,movable:b(a.value),placeable:E,dragged:()=>V.current},q(a.value)))})}),(0,X.jsx)(ee,{children:z&&(0,X.jsx)(O,{model:e,view:t,display:d,row:z,swipe:!1})})]})};export{xe as BoardDisplay};
|
|
2
|
-
//# debugId=a54dedba-174f-41f3-b844-c5abc462a768
|
|
@@ -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{Ea as r,Hc as i,Ji as a,Lr as o,Qi as s,Xi as c,aa as l,ca as u,ia as d,ic as f,mr as p,ra as m,rs as h,ui as g,wa as _}from"./app-B94YfKGx.js";import{_ as v,a as y,g as b,i as x,n as S,o as ee,t as te,v as ne}from"./lib-dnd-kit-core-xi-7xL_N.js";import{n as re}from"./board-dnd-pi-vIUTz.js";import{_ as ie,a as C,b as w,c as T,d as ae,f as E,i as oe,l as D,n as O,o as k,p as A,r as j,s as M,t as N,y as P}from"./use-calendar-move-O_48Gqvs.js";var F=e(t(),1),I=e(n(),1),L=e=>{let t=A(e),n=e=>Date.parse(`${e}T00:00:00Z`);return e.scale===`month`?s(n(e.day)):c(n(t[0]),n(t.at(-1)))},R=({view:e,now:t,linkTo:n,onView:r})=>{let i=e.scale===`month`&&l(t,u()).startsWith(e.day.slice(0,7)),a=n=>n===`week`&&i?w(`week`,t):E({scale:n,day:e.day},t),o=(t,n)=>({view:a(t),label:n,current:e.scale===t});return(0,I.jsx)(D,{heading:L(e),unit:e.scale===`month`?`month`:`week`,previous:P(e,-1),today:w(e.scale,t),next:P(e,1),scales:[o(`month`,g(`month`)),o(`week`,g(`week`))],scalesLabel:g(`calendarScale`),linkTo:n,onView:r})},z=({day:e,count:t,children:n,more:r,inMonth:a,today:o,week:s})=>{let{setNodeRef:c,isOver:l}=b({id:T(e)}),u=Date.parse(`${e}T00:00:00Z`);return(0,I.jsxs)(`section`,{ref:c,"aria-label":`${d(u)}, ${t}`,className:i(`flex min-w-0 flex-col gap-1 bg-background p-1`,s?`min-h-28 sm:min-h-64`:`min-h-24`,!a&&`bg-surface`,l&&`ring-2 ring-inset ring-primary/30`),children:[(0,I.jsxs)(`header`,{className:i(`flex items-center gap-1 px-0.5 text-xs`,a?`text-foreground`:`text-muted-foreground`),children:[s&&(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:m(u)}),(0,I.jsx)(`span`,{"aria-current":o?`date`:void 0,className:i(`inline-flex size-5 items-center justify-center rounded-full tabular-nums`,o&&`bg-primary font-medium text-primary-foreground`),children:Number(e.slice(8))})]}),n,r]})},B=3,V=({model:e,view:t,display:n,fields:s,filter:c,at:d,linkTo:b,now:w=Date.now()})=>{let[D,P]=(0,F.useState)(),L=E(b?d:D,w),V=A(L),H=j({model:e,display:n,range:ie(L),fields:s,filter:c}),{moves:U,move:se}=O(e,n),W=ae(N(H.rows,U),n,e,V),G=h(e.name),K=_(G,`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[q,J]=(0,F.useState)(),Y=(0,F.useRef)(!1),ce=ne(v(y,{activationConstraint:{distance:4}}),v(ee,{activationConstraint:{delay:250,tolerance:5}}),v(x,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:M})),le=l(w,u()),X=L.scale===`week`,Z=e=>a(Date.parse(`${String(e).slice(T(``).length)}T00:00:00Z`)),Q=r=>k(e,t,n,r.row),ue={onDragStart:({active:e})=>g(`pickedUp`,{title:Q(e.data.current)}),onDragOver:({active:e,over:t})=>g(`isOver`,{title:Q(e.data.current),over:t?Z(t.id):g(`noDay`)}),onDragEnd:({active:e,over:t})=>t?g(`wasMovedTo`,{title:Q(e.data.current),to:Z(t.id)}):g(`putBack`,{title:Q(e.data.current)}),onDragCancel:({active:e})=>g(`cancelled`,{title:Q(e.data.current)})},$=()=>{J(void 0),setTimeout(()=>Y.current=!1)},de=({active:e})=>{Y.current=!0,J(e.data.current)},fe=({active:e,over:t})=>{$();let{row:n,day:r}=e.data.current,i=t?String(t.id).slice(T(``).length):void 0;i&&i!==r&&se(n,r,i)},pe=(e,t)=>{let n=E({scale:`week`,day:e},w),r=g(`moreHidden`,{count:t}),i=`self-start rounded px-1 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-primary`;return b?(0,I.jsx)(o,{to:b(n),className:i,children:r}):(0,I.jsx)(`button`,{type:`button`,className:i,onClick:()=>P(n),children:r})};return(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,I.jsx)(R,{view:L,now:w,linkTo:b,onView:P}),H.error&&(0,I.jsx)(p,{title:g(`couldNotLoadRows`),error:H.error}),H.capped&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`capped`,{limit:500,unit:L.scale})}),(0,I.jsxs)(te,{sensors:ce,collisionDetection:re,onDragStart:de,onDragEnd:fe,onDragCancel:$,accessibility:{announcements:ue,screenReaderInstructions:{draggable:g(`calendarInstructions`)}},children:[(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[!X&&(0,I.jsx)(`div`,{"aria-hidden":!0,className:`grid grid-cols-7 gap-px border-b border-border bg-border`,children:V.slice(0,7).map(e=>(0,I.jsx)(`span`,{className:`bg-surface px-1.5 py-1 text-xs font-medium text-muted-foreground`,children:m(Date.parse(`${e}T00:00:00Z`))},e))}),(0,I.jsx)(`div`,{className:i(`grid gap-px bg-border`,X?`grid-cols-1 sm:grid-cols-7`:`grid-cols-7`),children:V.map(i=>{let a=W.get(i),o=X?a:a.slice(0,B);return(0,I.jsx)(z,{day:i,count:a.length,inMonth:X||i.startsWith(L.day.slice(0,7)),today:i===le,week:X,more:o.length<a.length&&pe(i,a.length-o.length),children:H.loading?(0,I.jsx)(f,{className:`h-4`}):o.map(a=>(0,I.jsx)(oe,{model:e,view:t,display:n,row:a,day:i,movable:K&&r(a.record,`update`),dragged:()=>Y.current},a.key))},i)})})]}),(0,I.jsx)(S,{children:q&&(0,I.jsx)(C,{model:e,view:t,display:n,row:q.row,day:q.day})})]})]})};export{V as CalendarDisplay};
|
|
2
|
-
//# debugId=b005cbbf-24e3-47c4-aa0f-0105768fe3ea
|
|
@@ -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{t}from"./react-CuiNlnus.js";import{Ni as n,Wa as r,Xn as i,Ys as a,Zn as o,en as s,ns as c,pa as l,ts as u}from"./app-B94YfKGx.js";import{t as d}from"./render-node-0_Pb8ixy.js";import{t as f}from"./start-block-queries-Bu7xMabd.js";var p=e(t(),1),m=({name:e,tab:t,params:m})=>{let h=c().pages[e];if(!h)return(0,p.jsx)(u,{title:r(`notFound`),children:r.rich(`noPage`,{page:e})});let g=t=>a(o({page:e,...t&&{tab:t},given:m??{}}));return(0,p.jsx)(l,{route:{...t&&{tab:t},pathOf:g},children:(0,p.jsx)(i,{page:e,...t&&{tab:t},tree:h.tree,...m&&{given:m},children:(0,p.jsxs)(s,{tree:h.tree,plan:h.reads,children:[(0,p.jsx)(f,{tree:h.tree,plan:h.reads}),(0,p.jsx)(n,{children:(0,p.jsx)(d,{node:h.tree,at:``})})]})})})};export{m as ComposedPage};
|
|
2
|
-
//# debugId=c11e5fb0-97f9-4cbe-b14c-3c5663d8d95d
|
|
@@ -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{N as r,Nl as i,P as a,Qs as o,R as s,Rr as c,cl as l,do as u,jl as d,ns as f,r as p,rs as m,tc as h,ts as g,wa as _}from"./app-B94YfKGx.js";import{ComposedPage as v}from"./composed-page-DBHl-wl_.js";import{t as y}from"./record-opens-D7SV04zf.js";var b=e(t(),1),x=e(n(),1),S=({noun:e,collection:t,sections:n,width:i,saving:o,message:c,onSubmit:l,onCancel:d,ref:f})=>(0,x.jsx)(r,{ref:f,title:u(`title`,{noun:e}),eyebrow:t,width:i,submit:u(`submit`,{noun:e}),saving:o,error:c?Error(c):void 0,errorTitle:u(`notCreated`),onSubmit:l,onCancel:d,children:n.map(e=>(0,x.jsx)(a,{title:e.title,help:e.help,children:(0,x.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:e.fields.map(e=>(0,x.jsx)(s,{name:e.name,label:e.label,required:e.required,help:e.help,error:e.error,wide:e.wide,children:e.editor},e.name))})},e.title))}),C=({resource:e,values:t})=>{let n=f(),r=n.resources[e],i=m(e);return r?_(i,`create`)?(0,x.jsx)(w,{resource:e,values:t}):(0,x.jsx)(g,{title:u(`notAllowed`),children:u(`cannotCreate`,{plural:n.views[e]?.names?.plural.toLowerCase()??e})}):(0,x.jsx)(g,{title:h(`notFound`),children:h(`noResource`,{name:e})})},w=({resource:e,values:t})=>{let n=f().views[e],{go:r}=c(),[i,a]=(0,b.useState)(),s=p({resource:e,values:t,onCreated:(e,t)=>a(t)});o(!i&&(s.touched||s.saving),`input-lost`),(0,b.useEffect)(()=>{i&&r(i,{replace:!0})},[i,r]);let u=n?.names?.singular??l(e);return(0,x.jsx)(S,{ref:s.ref,noun:u,collection:n?.names?.plural??l(e),sections:s.sections,width:n?.recordWidth,saving:s.saving,message:s.message,onSubmit:()=>void s.submit(),onCancel:()=>r({kind:`list`,resource:e})})},T=({resource:e,values:t})=>{let n=f(),r=n.views[e];return r?.createOpens&&d(r.createOpens).every(e=>t?.[e])?(0,x.jsx)(y,{to:i(r.createOpens,t)}):r?.create?n.pages[r.create.page]?(0,x.jsx)(v,{name:r.create.page}):(0,x.jsx)(g,{title:u(`notAllowed`),children:u(`cannotCreate`,{plural:r.names?.plural.toLowerCase()??l(e)})}):(0,x.jsx)(C,{resource:e,values:t},new URLSearchParams(t).toString())};export{T as CreateRoute};
|
|
2
|
-
//# debugId=2cf11b23-b723-4aae-86aa-916d4bbcff67
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/period-chart-GDqLnl9l.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-B94YfKGx.js","assets/vendor-t7Q7QbPu.js","assets/app-xwgcmboV.css","assets/lib-recharts-B1lKFZ5P.js","assets/lib-use-sync-external-store-D4s7MiFL.js","assets/lib-clsx-BBppEdNc.js","assets/lib-es-toolkit-9HrAkr3v.js","assets/lib-d3-shape-BSwuGxur.js","assets/lib-d3-path-CT8ZQkbZ.js","assets/lib-reselect-BYC6G6Ab.js","assets/lib-redux-ChC-A5Uc.js","assets/lib-immer--vWzY_El.js","assets/lib-reduxjs-toolkit-_9NgzJLa.js","assets/lib-redux-thunk-D6AwDtTm.js","assets/lib-react-redux-CLjAzhcU.js","assets/lib-decimal.js-light-Dtl_aJ-w.js","assets/lib-victory-vendor-C-WmaPT-.js","assets/lib-d3-scale-BM-TVblA.js","assets/lib-d3-array-Cuc1v5vu.js","assets/lib-internmap-O20L0ujd.js","assets/lib-d3-interpolate-C7dFwq8w.js","assets/lib-d3-color-B6XHLQii.js","assets/lib-d3-format-CvZ7dVit.js","assets/lib-d3-time-BLMe3IGs.js","assets/lib-d3-time-format-xk4cmG0i.js","assets/lib-eventemitter3-CoExthpv.js","assets/lib-react-is-BhamKBF2.js","assets/lib-tiny-invariant-D6Do54jy.js","assets/legend-item-WwKh2W6n.js","assets/group-donut-XjNEBVUq.js","assets/records-map-G0QXqaUR.js","assets/maplibre-Bm0OQH9k.js","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/board-display-ClTe26F0.js","assets/record-preview-DsIrTWKZ.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/messages-vzi5T1Xo.js","assets/board-dnd-pi-vIUTz.js","assets/use-display-rows-vjthlkqo.js","assets/calendar-display-CwBcu_JO.js","assets/use-calendar-move-O_48Gqvs.js","assets/timeline-display-CJHQiDm9.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{$c as i,$o as a,$r as o,Ai as s,An as c,B as l,Bo as u,Br as d,Ci as f,Cn as p,Cr as m,D as h,Dc as g,Di as _,Do as v,Dr as y,Ea as b,Ec as x,Ei as S,En as C,Fi as w,Fl as T,Fs as E,Ft as ee,Ga as D,Gr as O,Hc as k,Hl as A,Hn as j,Hr as M,Il as N,Is as P,J as te,Jl as F,Jn as I,Jr as ne,Kl as L,Kn as R,Kr as z,Ks as B,Kt as V,Lc as re,Li as ie,Ll as ae,Ln as oe,Lr as se,Lt as ce,Mc as le,Mi as ue,Ml as de,Mn as fe,Nc as pe,Nl as me,Oi as he,Ol as ge,Pa as _e,Pc as ve,Ql as ye,Qo as be,Qr as xe,R as Se,Ri as Ce,Rl as we,Rr as Te,Si as Ee,Ss as H,St as De,Ua as Oe,Ui as ke,Ul as Ae,Ur as je,Vc as U,Vl as Me,Wa as W,Wl as Ne,Wr as Pe,Ws as Fe,Xc as G,Xl as Ie,Xr as Le,Y as Re,Yc as ze,Yn as Be,Yr as Ve,Zo as He,_a as Ue,aa as We,ac as Ge,an as Ke,b as qe,ba as Je,bi as Ye,bo as Xe,bs as Ze,ca as Qe,cc as $e,cl as K,dc as et,dl as tt,ei as nt,fa as rt,fi as it,fl as at,gi as ot,hi as st,ic as q,ii as ct,il as lt,ja as ut,ji as dt,k as ft,ko as pt,ll as mt,ls as ht,mc as gt,mr as _t,nc as vt,ni as yt,ns as J,ol as bt,pi as xt,q as St,qn as Ct,qr as wt,rs as Tt,s as Et,sa as Dt,sc as Ot,sl as kt,tc as At,ti as jt,to as Mt,uc as Nt,ui as Y,ul as Pt,un as Ft,us as It,va as Lt,vi as Rt,vn as zt,vo as Bt,wa as Vt,wc as Ht,wi as Ut,wn as Wt,xa as Gt,xs as Kt,ya as qt,yi as Jt,zn as Yt,zo as Xt,zr as Zt}from"./app-B94YfKGx.js";import{C as Qt,f as $t,h as en,i as tn,o as nn,s as rn}from"./vendor-t7Q7QbPu.js";import{a as an,n as on}from"./update-set-B0D_tNDz.js";import{t as sn}from"./layout-grid-dpoR6hFU.js";import{t as cn}from"./lib-tanstack-react-table-uAPG3Sdi.js";import{a as ln,i as un,n as dn,t as fn}from"./lib-tanstack-table-core-2MHQ7o_e.js";import{i as pn,r as mn,t as hn}from"./record-preview-DsIrTWKZ.js";import{_ as gn,a as _n,i as vn,o as yn,s as bn,t as xn,v as Sn}from"./lib-dnd-kit-core-xi-7xL_N.js";import{a as Cn,i as wn,r as Tn,t as En}from"./lib-dnd-kit-sortable-CNDSKqCD.js";var Dn={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};Dn.node;var On=U(Dn),kn={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};kn.node;var An=U(kn),jn={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};jn.node;var Mn=U(jn),Nn={name:`chart-gantt`,size:24,node:[[`path`,{d:`M10 6h8`,key:`zvc2xc`}],[`path`,{d:`M12 16h6`,key:`yi5mkt`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M8 11h7`,key:`wz2hg0`}]]};Nn.node;var Pn=U(Nn),Fn={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};Fn.node;var In=U(Fn),Ln={name:`columns-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]],aliases:[`panels-left-right`]};Ln.node;var Rn=U(Ln),zn={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};zn.node;var Bn=U(zn),Vn={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};Vn.node;var Hn=U(Vn),Un={name:`map`,size:24,node:[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]};Un.node;var Wn=U(Un),Gn={name:`square-kanban`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 7v7`,key:`1x2jlm`}],[`path`,{d:`M12 7v4`,key:`xawao1`}],[`path`,{d:`M16 7v9`,key:`1hp2iy`}]],aliases:[`kanban-square`]};Gn.node;var Kn=U(Gn),X=e(t(),1),qn=e(n(),1),Z=e(r(),1),Jn=G(`mailbox`),Yn=({offers:e,problem:t,onConnect:n})=>{let r=Ze()?.signInProviders??[],[i,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(),l=t?.code===`link_expired`,u=e.map(e=>e.link.name),d=e=>r.find(t=>t.id===e)?.name??Kt(e),f=async t=>{o(!0),c(void 0);try{await n(e.find(e=>e.link.id===t))}catch(e){if(!(e instanceof H))throw e;c(a(e)),o(!1)}};return(0,Z.jsx)(De,{title:Jn(l?`expiredTitle`:`missingTitle`),tone:`warning`,actions:e.map(({link:e,again:t})=>({id:e.id,label:Jn(t?`connectAgain`:`connect`,{name:e.name}),style:`primary`,disabled:i})),onAction:e=>void f(e),children:(0,Z.jsxs)(`div`,{className:`space-y-1 text-body`,children:[(0,Z.jsx)(`p`,{children:Jn(l?`expired`:`missing`,{names:u.join(`, `)})}),e.filter(e=>e.signInOnly).map(({link:e})=>(0,Z.jsx)(`p`,{children:Jn(`signInOnly`,{provider:d(e.provider),name:e.name})},e.id)),s&&(0,Z.jsx)(`p`,{role:`alert`,className:`font-medium text-danger-text`,children:s})]})})},Xn=new Map([[`personal-mail-not-linked`,`not_linked`],[`personal-mail-link-expired`,`link_expired`]]),Zn=e=>{if(!B(e))return;let t=Xn.get(e.slug);if(!t)return;let{provider:n}=e.problem;return{code:t,...typeof n==`string`&&{provider:n}}},Qn=(e,t,n)=>{if(n?.code===`link_expired`){let t=e.filter(e=>e.id===n.provider);return(t.length>0?t:e).map(e=>({link:e,again:!0,signInOnly:!1}))}return!n&&t.mail.length>0?[]:e.map(e=>{let n=t.mail.includes(e.id);return{link:e,again:n,signInOnly:!n&&t.providers.includes(e.provider)}})},$n=(e,t)=>{let n=Ze(),r=n?.personalMail??[],i=n!==null&&r.length>0&&(t||e!==void 0),[o,s]=(0,X.useState)(),[c,l]=(0,X.useState)(),u=n?.session.account;(0,X.useEffect)(()=>{if(!i||!u)return;let e=!0;return Promise.all([u.linkedPersonalMail(r),u.linkedProviders()]).then(([t,n])=>{e&&s({mail:t,providers:n})},t=>{if(!(t instanceof H))throw t;e&&l(a(t))}),()=>{e=!1}},[i,u,r]);let d=e=>n.linkPersonalMail(e.link);return i?c?{offers:[],error:c,connect:d}:{offers:o&&Qn(r,o,e),connect:d}:{offers:[],connect:d}},er=(e,t)=>{let n=Zn(t),r=e.mailbox===!0,{offers:i,error:a,connect:o}=$n(n,r),s=i!==void 0&&i.length>0;return{notice:s?(0,Z.jsx)(Yn,{offers:i,problem:n,onConnect:o}):a?(0,Z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}):void 0,explained:n!==void 0&&s,blocked:s||r&&i===void 0}},tr=(e,t)=>{let n=e.from===void 0?void 0:t?.[e.from];return Array.isArray(n)?n.filter(e=>typeof e==`string`):[]},nr=(e,t)=>e.items?e.items:[...new Set(t.flatMap(t=>tr(e,t)))],rr=(e,t,n)=>Object.fromEntries(Object.entries(t).map(([t,r])=>{let i=e.find(e=>e.name===t);return i?.kind===`checklist`?[t,i.items??tr(i,n)]:[t,r]})),ir=({label:e,boxes:t,ticked:n,onChange:r})=>{let{id:i,"aria-describedby":a,"aria-invalid":o}=pt();if(t.length===0)return(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:W(`nothingToTick`)});let s=(e,t)=>r(t?[...n,e]:n.filter(t=>t!==e));return(0,Z.jsx)(`div`,{id:i,role:`group`,"aria-label":e,"aria-describedby":a,"aria-invalid":o,children:(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:t.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded py-1.5 text-sm active:opacity-70`,children:[(0,Z.jsx)(Mt,{checked:n.includes(e),onChange:t=>s(e,t),className:`mt-0.5`}),(0,Z.jsx)(`span`,{children:e})]})},e))})})},ar={WebkitTextSecurity:`disc`},or=({name:e,value:t,invalid:n,onChange:r})=>(0,Z.jsx)(v,{type:`text`,name:e,autoComplete:`off`,style:ar,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0,"data-form-type":`other`,"data-gramm":`false`,"data-gramm_editor":`false`,"data-enable-grammarly":`false`,value:t,invalid:n,onChange:e=>r(e.target.value)}),sr=`••••••`,cr=(e,t)=>e.flatMap(e=>{let n=t[e.name];return e.kind===`secret`&&typeof n==`string`&&n!==``?[n]:[]}),lr=(e,t)=>{let n=Array(e.length).fill(!1);for(let r of t)for(let t=e.indexOf(r);t!==-1;t=e.indexOf(r,t+1))n.fill(!0,t,t+r.length);return n},ur=(e,t)=>{let n=lr(e,t.filter(e=>e!==``)),r=``;for(let t=0;t<e.length;t++)n[t]?(t===0||!n[t-1])&&(r+=sr):r+=e[t];return r},dr=(e,t)=>{if(t.length===0)return e;if(B(e)){let n=t.map(e=>JSON.stringify(e).slice(1,-1));return new Fe(JSON.parse(ur(JSON.stringify(e.problem),n)))}if(!(e instanceof Error))return e;let n=Error(ur(e.message,t));return n.name=e.name,n},fr=(e,t)=>Object.fromEntries(Object.entries(e).map(([e,n])=>[e,ur(n,t)])),pr={text:`text`,integer:`integer`,decimal:`decimal`,boolean:`boolean`,date:`date`,secret:`text`},mr=e=>{let t={name:e.name,column:e.name,nullable:!0,readOnly:!1,filterable:!1,sortable:!1,aliases:[]};return e.kind===`custom`||e.kind===`checklist`?{...t,type:`json`}:e.kind===`choice`?e.resource===void 0?{...t,type:`enum`,enumValues:(e.options??[]).map(e=>e.value)}:{...t,type:`relation`,relation:{resource:e.resource,columns:[e.name]}}:{...t,type:pr[e.kind]}},hr=e=>({label:e.label,...e.multiline&&{multiline:!0},...e.options&&{valueLabels:Object.fromEntries(e.options.map(e=>[e.value,e.label]))}}),gr=e=>Object.fromEntries(e.map(e=>e.kind===`custom`?[e.name,e.default??null]:e.kind===`checklist`?[e.name,[]]:e.kind===`boolean`?[e.name,!!e.default]:[e.name,h(e.default)])),_r=(e,t)=>e.kind===`custom`?t??null:e.kind===`checklist`?Array.isArray(t)?t:[]:e.kind===`secret`?typeof t==`string`&&t!==``?t:null:Et(t)?t.key:e.resource===void 0?ft(mr(e),t):String(t??``)===``?null:String(t),vr=(e,t)=>{let n=Object.fromEntries(e.map(e=>[e.name,_r(e,t[e.name])])),r=an(e,n);return{shown:r,values:Object.fromEntries(Object.entries(n).filter(([e])=>r.has(e)))}},yr=/^-?\d+(\.\d+)?$/,br=/^\d{4}-\d{2}-\d{2}$/,xr=(e,t,n)=>{if(e.kind===`checklist`){let e=n.filter(e=>!(Array.isArray(t)&&t.includes(e))).length;return e===0?void 0:W(`tickEvery`,{count:e})}if(t===null||t===``)return e.required?W(`required`):void 0;if(e.kind===`integer`&&!Number.isInteger(t))return W(`wholeNumber`);if(e.kind===`decimal`&&!yr.test(String(t)))return W(`number`);if(e.kind===`date`&&!br.test(String(t)))return W(`dateFormat`);if(e.max!==void 0&&String(t).length>e.max)return W(`atMost`,{max:e.max})},Sr=(e,t,n={})=>Object.fromEntries(e.flatMap(e=>{if(!Object.hasOwn(t,e.name))return[];let r=xr(e,t[e.name],n[e.name]??[]);return r?[[e.name,r]]:[]})),Cr=({input:e,held:t,invalid:n,onChange:r,boxes:i})=>{let{resources:a,views:o}=J(),{components:s}=ut();if(e.kind===`custom`){let i=s?.[e.component??``];if(!i)throw Error(`Input "${e.name}": the app has no component "${e.component}"`);return(0,Z.jsx)(i,{input:e,value:t??null,onChange:r,invalid:n,props:e.props??{}})}if(e.kind===`checklist`)return(0,Z.jsx)(ir,{label:e.label,boxes:i,ticked:Array.isArray(t)?t:[],onChange:r});if(e.kind===`secret`)return(0,Z.jsx)(or,{name:e.name,value:typeof t==`string`?t:``,invalid:n,onChange:r});let c=e.resource===void 0?void 0:a[e.resource];return(0,Z.jsx)(qe,{field:mr(e),hints:hr(e),value:Et(t)?t.key:t,stored:void 0,relationLabel:Et(t)?t.label:void 0,relationPicker:c?{target:c,view:o[c.name]}:void 0,invalid:n,onChange:r})},wr=({action:e,label:t,danger:n,records:r=[],names:i=[],onCancel:a,onSubmit:o})=>{let[s,c]=(0,X.useState)(()=>gr(e.inputs)),[l,u]=(0,X.useState)({}),[d,f]=(0,X.useState)(),[p,h]=(0,X.useState)(!1),g=(0,X.useId)(),{shown:_,values:v}=vr(e.inputs,s),y=er(e,d),b=Object.fromEntries(e.inputs.filter(e=>e.kind===`checklist`).map(e=>[e.name,nr(e,r)])),x=async()=>{let t=Sr(e.inputs,v,b);if(u(t),f(void 0),Object.keys(t).length>0||y.blocked)return;h(!0);let n=cr(e.inputs,v);await o(v).catch(t=>{u(fr(m(t,e.inputs),n)),f(dr(t,n))}),h(!1)},S=(e,t)=>{u(({[e]:t,...n})=>n),c(n=>({...n,[e]:t}))};return(0,Z.jsx)(ke,{title:t,description:e.confirm,open:!0,onClose:a,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ot,{onClick:a,children:W(`cancel`)}),(0,Z.jsx)(Ot,{variant:n?`danger`:`primary`,type:`submit`,form:g,loading:p,disabled:y.blocked,children:t})]}),children:(0,Z.jsxs)(`form`,{id:g,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),x()},children:[d!==void 0&&Object.keys(l).length===0&&!y.explained&&(0,Z.jsx)(_t,{title:W(`failed`,{label:t}),error:d}),y.notice,i.length>1&&(0,Z.jsx)(`p`,{className:`text-sm`,children:W(`forRecords`,{records:i.join(`, `)})}),e.inputs.filter(e=>_.has(e.name)).map(e=>(0,Z.jsx)(Se,{label:e.label,required:e.required,help:e.help,error:l[e.name],children:(0,Z.jsx)(Cr,{input:e,held:s[e.name],invalid:!!l[e.name],onChange:t=>S(e.name,t),boxes:b[e.name]??[]})},e.name))]})})},Tr=({action:e,label:t,danger:n,onCancel:r,onConfirm:i})=>{let a=er(e,void 0);return(0,Z.jsx)(Ge,{title:`${t}?`,description:e.confirm,onClose:r,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ot,{onClick:r,children:W(`cancel`)}),(0,Z.jsx)(Ot,{variant:n?`danger`:`primary`,disabled:a.blocked,onClick:i,children:t})]}),children:a.notice})},Er=e=>e.variant===`danger`||e.run?.kind===`delete`,Dr=e=>!!(e.confirm||e.inputs?.length),Or=({action:e,label:t,danger:n,records:r,names:i,onCancel:a,onConfirm:o,onSubmit:s})=>{let{inputs:c}=e;return c?.length?(0,Z.jsx)(wr,{action:{...e,inputs:c},label:t,danger:n,records:r,names:i,onCancel:a,onSubmit:s}):(0,Z.jsx)(Tr,{action:e,label:t,danger:n,onCancel:a,onConfirm:o})},kr=()=>{let e=Ze(),t=_e();return n=>{let r=Zn(n),i=e?.personalMail??[];if(!e||!r)return;let o=i.find(e=>e.id===r.provider)??(i.length===1?i[0]:void 0);if(!o)return;let s=async()=>{try{await e.linkPersonalMail(o)}catch(e){if(!(e instanceof H))throw e;t.show({state:`error`,title:Jn(`connect`,{name:o.name}),description:a(e)})}};return{label:Jn(r.code===`link_expired`?`connectAgain`:`connect`,{name:o.name}),onClick:()=>void s()}}},Ar=(e,t)=>{if(e.when===void 0)return!0;if(!t)return!1;let n=P(e.when);return n.ok&&E(n,t)},jr=(e,t={})=>T(e,e=>encodeURIComponent(A(Ae(t,e)))),Mr=e=>{if(typeof e!=`string`||!URL.canParse(e))return;let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`?t.href:void 0},Nr=(e,t={})=>{let n=we(e);return n===void 0?jr(e,t):Mr(Ae(t,n))},Pr=e=>{e!==void 0&&(/^https?:/i.test(e)?window.open(e,`_blank`,`noopener,noreferrer`):window.location.assign(e))},Fr=e=>URL.canParse(e)?new URL(e).hostname.replace(/^www\./,``):``,Ir=(e,t)=>Object.entries(t).every(([t,n])=>Object.is(e[t],n)),Lr=(e,t,n={})=>{if(!Ar(e,t))return e.otherwise===`disable`?e:void 0;let r=e.run;if(r?.kind===`update`)return t&&!e.inputs?.length&&Ir(t,r.values)?void 0:e;if(r?.kind===`link`&&`to`in r&&Me(r.to)!==void 0){let i=me(r.to,t);return i.kind!==`page`&&Object.hasOwn(n,i.resource)?e:void 0}if(r?.kind!==`link`||!(`href`in r))return e;let i=Nr(r.href,t);if(i!==void 0)return e.label.includes(`{{host}}`)?{...e,label:e.label.replaceAll(ae,Fr(i))}:e},Rr=async(e,t,n,r)=>{let i=e.map(e=>({record:e,verdict:t(e)})),a={done:0,skipped:i.filter(e=>e.verdict===`skip`).length,failed:0,refused:i.flatMap(e=>e.verdict===`refuse`?[e.record]:[])};for(let{record:e}of i.filter(e=>e.verdict===`run`)){let t=await n(e).then(()=>void 0,e=>({error:e}));t?r(t.error)?a.refused.push(e):(a.failed+=1,a.failed===1&&(a.error=t.error)):a.done+=1}return a},zr=e=>`“${e}”`,Br=e=>e instanceof Error?e.message:W(`somethingWrong`),Vr=(e,t,n)=>{let{views:r,resources:i}=J(),{actions:a,components:o}=ut(),s=Tt(e),c=ht(),l=It(e),u=_e(),d=kr(),f=zt(),{go:p}=Te(),m=Ce(),[h,g]=(0,X.useState)(),_=(r[e]?.actions??[]).flatMap(e=>Lr(e,t?.record,i)??[]),v=(e,t)=>{let n=e.run?.kind;if((n===`update`||n===`delete`||n===`ai`)&&!t)return W(`needsRecord`);if(!Ar(e,t?.record))return e.reason??W(`doesNotApply`);if((n===`update`||n===`ai`)&&(!Vt(s,`update`)||t?.permissions?.update===!1)||e.run?.kind===`ai`&&t?.permissions?.fields?.[e.run.writes]===`read`)return W(`cannotChange`);if(n===`delete`&&(!Vt(s,`delete`)||t?.permissions?.delete===!1))return W(`cannotDelete`);if(!e.run&&!a?.[e.name])return W(`noHandler`,{name:e.name});let r=e.inputs?.find(e=>e.kind===`custom`&&!o?.[e.component??``]);if(r)return W(`noInputComponent`,{component:String(r.component),input:r.name})},y=e=>v(e,t),b=(e,t)=>{let{run:n}=e,r=n?.kind;return r===`update`||r===`ai`?Vt(s,`update`)&&(t.permissions?.update===!1||n?.kind===`ai`&&t.permissions?.fields?.[n.writes]===`read`):r===`delete`&&Vt(s,`delete`)&&t.permissions?.delete===!1},x=async(t,n,r)=>{let{run:i}=t;if(i?.kind===`link`){`to`in i?p(me(i.to,n?.record)):Pr(Nr(i.href,n?.record));return}i?.kind===`update`?await c.update(e,n.key,on(i.values,r??{}),n.etag??`*`):i?.kind===`delete`?await c.remove(e,n.key,{etag:n.etag}):i?.kind===`ai`?await c.generate(e,n.key,t.name):await a[t.name]({resource:e,record:n?.record,recordKey:n?.key,etag:n?.etag,client:l,navigate:p,...r&&{values:r}})},S=async(t,r,i)=>{await x(t,r,i),t.run?.kind!==`link`&&(await f(e),u.show({state:`success`,title:W(`done`,{label:t.label})}),n?.(t))},C=async(e,n=t)=>{v(e,n)||(g(e.name),await S(e,n).catch(t=>{let n=d(t);u.show({state:`error`,title:W(`failed`,{label:e.label}),description:Br(t),...n&&{action:n}})}),g(void 0))},w=async(e,n)=>{y(e)||(g(e.name),await S(e,t,rr(e.inputs??[],n,t?.record)).finally(()=>g(void 0)))},T=(e,t)=>Lr(e,t.record,i)!==void 0&&!v(e,t),E=(e,t)=>T(e,t)?`run`:Lr(e,t.record,i)!==void 0&&Ar(e,t.record)&&b(e,t)?`refuse`:`skip`;return{actions:_,blocked:y,blockedOn:v,appliesOn:T,verdictOn:E,running:h,run:C,submit:w,runEach:async(t,i,a=0,o)=>{g(t.name);let s=e=>o?rr(t.inputs??[],o,e.record):void 0,c=await Rr(i,e=>E(t,e),e=>x(t,e,s(e)),e=>e instanceof Fe&&e.status===403);g(void 0),await f(e);let l=c.refused.map(t=>zr(m(t.model,r[e],t.record,t.key))),d=W(`doneOn`,{label:t.label,done:c.done,skipped:c.skipped+a,failed:c.failed,refused:l.length}),p=[l.length>0&&W(`refusedOn`,{records:l.join(`, `),count:l.length}),c.failed>0&&ur(Br(c.error),cr(t.inputs??[],o??{}))].filter(Boolean).join(` `);return u.show({state:c.failed>0||l.length>0?`error`:`success`,title:d,...p&&{description:p}}),c.done>0&&n?.(t),c}}},Hr=(e,t,n,r)=>{let i=Vr(e,n,r),a=i.actions.find(e=>e.name===t);return{action:a,record:n?.record,blocked:a?i.blocked(a):W(`noAction`,{name:t}),running:i.running===t,run:()=>a?i.run(a):Promise.resolve(),submit:e=>a?i.submit(a,e):Promise.resolve()}},Ur=G(`app/list`),Wr=G(`app/charts`),Gr=Ne(),Kr=e=>e>=0&&e<8?`var(--chart-${e+1})`:`var(--faint-foreground)`,qr=(e,t,n,r)=>{let i=String(n);if(n===null)return`var(--faint-foreground)`;let a=Jt(t?.valueColors,n);return a===void 0?e.type===`enum`?Kr(e.enumValues?.indexOf(i)??-1):e.type===`boolean`?Kr(+!n):Kr(r):a},Jr=(e,t,n)=>n.value===null?Wr(`notSet`):e.type===`enum`?kt(String(n.value),t?.valueLabels):e.type===`boolean`?n.value?Wr(`yes`):Wr(`no`):n.label??String(n.value),Yr=(e,t,n=``)=>{let r=L(t===null?Gr.isNull(e.name):Gr.eq(e.name,t));return n.trim()?`(${n}) AND ${r}`:r},Xr=(e,t)=>t.kind===`count`?e.count:e[t.kind]??null,Zr=(e,t,n,r,i=``)=>e.map((e,a)=>({key:String(e.value),label:Jr(t,n,e),value:Xr(e,r),count:e.count,color:qr(t,n,e.value,a),filter:Yr(t,e.value,i)})),Qr=(e,t)=>e.map(e=>({at:Date.parse(`${String(e.value)}Z`),value:Xr(e,t),count:e.count})),$r=(e,t)=>{if(e===null)return`—`;if(t.kind===`count`)return e.toLocaleString(i());let n=t.hints?.decimals??(Number.isInteger(e)?0:2),r=e.toLocaleString(i(),{minimumFractionDigits:n,maximumFractionDigits:n});return`${t.hints?.prefix??``}${r}${t.hints?.suffix??``}`},ei=(e,t,n)=>{let r=e?.type===`relation`&&e.relation?t[e.relation.resource]:void 0;return r&&r.primaryKey.length===1?lt(r,n[r.name]):void 0},ti=({model:e,groupBy:t,splitBy:n,sum:r,average:i,filter:a=``,granularity:o=`day`,range:s=`30d`,limit:c=10},l,u)=>{let d=e.fields[t];if(!d)return;let f=d.type===`date`||d.type===`timestamp`,p=ei(d,l,u),m=f&&n!==void 0?e.fields[n]:void 0,h=ei(m,l,u),g=m?{splitBy:m.name,splitLimit:8,...h&&{splitLabel:h}}:{},_=f?{granularity:o,range:s,timeZone:Qe(),...g}:{limit:c,...p&&{label:p}};return{groupBy:t,filter:a,...r&&{sum:r},...i&&{average:i},..._}},ni=(e,t,n)=>n?{kind:`list`,resource:t,filter:n}:e?.list?.filter?{kind:`list`,resource:t,filter:``}:{kind:`list`,resource:t},ri=({resource:e,view:t,slices:n,measure:r})=>{let i=Math.max(0,...n.map(e=>e.value??0));return(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(n=>{let a=i>0&&n.value!==null?Math.max(0,n.value)/i:0;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(se,{to:ni(t,e,n.filter),className:`group grid grid-cols-[minmax(6rem,35%)_1fr_auto] items-center gap-3 rounded-md px-1 py-1 hover:bg-muted`,title:r.kind===`count`?void 0:Wr(`records`,{count:$r(n.count,{kind:`count`})}),children:[(0,Z.jsx)(`span`,{className:`truncate group-hover:text-primary-text`,children:n.label}),(0,Z.jsx)(`span`,{className:`h-3 rounded-r bg-muted`,"aria-hidden":!0,children:(0,Z.jsx)(`span`,{className:`block h-full rounded-r`,style:{width:`${a*100}%`,background:`var(--chart-1)`}})}),(0,Z.jsx)(`span`,{className:`text-right font-medium tabular-nums`,children:$r(n.value,r)})]})},n.key)})})},ii=w(()=>Qt(()=>import(`./period-chart-GDqLnl9l.js`).then(e=>e.PeriodChart),__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,23,24,25,26,27,28,29,30,31])),({compact:e})=>(0,Z.jsx)(q,{className:e?`h-24 w-full`:`h-40 w-full`})),ai=w(()=>Qt(()=>import(`./group-donut-XjNEBVUq.js`).then(e=>e.GroupDonut),__vite__mapDeps([32,1,2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,3,4,5])),()=>(0,Z.jsx)(q,{className:`size-36 rounded-full`})),oi=1e-6,si=(e,t,n,r,i,a=``)=>{let o=t.map((e,t)=>({key:`s${t}`,label:Jr(n,r,e),color:qr(n,r,e.value,t),filter:Yr(n,e.value,a)})),s=i.kind===`count`?0:null,c=(e,t)=>{let n=e.splits?.find(e=>e.value===t);return n?i.kind===`count`?n.count:n[i.kind]??null:s},l=Qr(e,i).map((n,r)=>{let a=e[r],o=t.map(e=>c(a,e.value)),s=Object.fromEntries(o.map((e,t)=>[`s${t}`,e]));if(i.kind===`average`)return{...n,...s};let l=n.value===null?null:n.value-o.reduce((e,t)=>e+(t??0),0);return{...n,...s,other:l===null?null:l<oi?0:l}});return i.kind!==`average`&&l.some(e=>(e.other??0)>0)?{series:[...o,{key:`other`,label:Wr(`other`),color:`var(--border-strong)`}],points:l}:{series:o,points:l.map(({other:e,...t})=>t)}},ci=(e,t,n,r)=>{let i=n??r,a=i===void 0?void 0:e.fields[i];return!a||i===void 0?{kind:`count`}:{kind:n===void 0?`average`:`sum`,field:a,hints:t?.fields[i]}},li=({model:e,view:t,groupBy:n,splitBy:r,type:i=`bar`,sum:a,average:o,filter:s=``,granularity:c=`day`,range:l=`30d`,limit:u=10,empty:d=Wr(`nothingYet`)})=>{let{resources:f,views:p}=J(),m=e.fields[n],h=m?.type===`date`||m?.type===`timestamp`,g=h&&r!==void 0?e.fields[r]:void 0,_=ti({model:e,groupBy:n,splitBy:r,sum:a,average:o,filter:s,granularity:c,range:l,limit:u},f,p),v=y(e.name,_??{groupBy:n},_!==void 0),b=ci(e,t,a,o);if(!m)return null;if(v.isPending)return(0,Z.jsx)(q,{className:`h-36 w-full`});if(v.error)return(0,Z.jsx)(`p`,{className:`text-danger-text`,children:Wr(`couldNotLoad`)});let{groups:x}=v.data;if(x.every(e=>e.count===0))return(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:d});let S=i===`line`?`line`:`bar`;if(h&&g&&v.data.splits){let{series:n,points:r}=si(x,v.data.splits,g,t?.fields[g.name],b,s);return(0,Z.jsx)(ii,{points:r,measure:b,bucket:c,type:S,series:n,resource:e.name,view:t})}if(h)return(0,Z.jsx)(ii,{points:Qr(x,b),measure:b,bucket:c,type:S});let C=Zr(x,m,t?.fields[n],b,s);return i===`donut`?(0,Z.jsx)(ai,{resource:e.name,view:t,slices:C,measure:b}):(0,Z.jsx)(ri,{resource:e.name,view:t,slices:C,measure:b})},ui=`0.75rem`,di=e=>{if(!(e>0&&e<=1))throw Error(`An item's share of a row is above 0 and at most 1, not ${e}`);return`calc((100% + ${ui}) * ${e} - ${ui})`},fi=e=>e===void 0?{width:`min(256px, 100%)`,minWidth:`0px`}:{width:di(e),minWidth:`min(100%, 12rem)`},pi=`absolute top-1/2 z-10 hidden size-8 -translate-y-1/2 items-center justify-center rounded-full border border-border-strong bg-background shadow-pop hover:bg-muted sm:flex`,mi=({scroll:e,label:t,share:n,children:r})=>{let i=fi(n);return(0,Z.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Z.jsx)(`ul`,{ref:e.ref,"aria-label":t,className:`relative flex snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain pb-1 *:w-(--snap-item-width) *:min-w-(--snap-item-min-width) *:shrink-0 *:snap-start`,style:{gap:ui,scrollbarWidth:`thin`,"--snap-item-width":i.width,"--snap-item-min-width":i.minWidth},children:r}),e.back&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":Nt(`previous`,{label:t.toLowerCase()}),onClick:()=>e.page(-1),className:`${pi} -left-3`,children:(0,Z.jsx)(ve,{className:`size-4`,"aria-hidden":!0})}),e.on&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":Nt(`next`,{label:t.toLowerCase()}),onClick:()=>e.page(1),className:`${pi} -right-3`,children:(0,Z.jsx)(pe,{className:`size-4`,"aria-hidden":!0})})]})},hi=(e,t)=>{let n={left:e.scrollLeft,width:e.clientWidth};return{...n,back:n.left>0,on:n.left+n.width<e.scrollWidth-1,watched:t(n)}},gi=(e,t)=>e.width===t.width&&e.back===t.back&&e.on===t.on&&e.watched===t.watched,_i=(e=()=>``)=>{let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)({left:0,width:0,back:!1,on:!1,watched:``}),a=()=>{if(!t)return;let n=hi(t,e);i(e=>gi(e,n)?e:n)},o=(0,X.useRef)(a);return(0,X.useLayoutEffect)(()=>{o.current=a,a()}),(0,X.useLayoutEffect)(()=>{if(!t)return;let e=()=>o.current(),n=new ResizeObserver(e);return n.observe(t),t.addEventListener(`scroll`,e,{passive:!0}),()=>{n.disconnect(),t.removeEventListener(`scroll`,e)}},[t]),{ref:n,view:{left:r.left,width:r.width},back:r.back,on:r.on,page:e=>{if(!t)return;let n=parseFloat(getComputedStyle(t).columnGap)||0;t.scrollBy({left:e*Math.max(1,t.clientWidth-n),behavior:`smooth`})}}},vi=G(`app/embedded-list`),yi=(e,t,n)=>{if(!(e>=t))return vi(n?`firstOfAbout`:`firstOf`,{shown:e,total:t.toLocaleString(i())})},bi=`protobase:embedded-display:`,xi=e=>`${bi}${e}`,Si=(e,t)=>ye(()=>e.getItem(t)??void 0,void 0),Ci=(e,t,n)=>ye(()=>e.setItem(t,n),void 0),wi=(e,t,{picked:n,preferred:r})=>{let i=O(e).map(e=>e.name);return n!==void 0&&i.includes(n)?n:Pe(e,t,r!==void 0&&i.includes(r)?r:void 0)},Ti=(e,t,n,{resource:r=e.name,...i})=>Zt({kind:`list`,resource:r},i,{...d(e,t,n),display:Pe(t,n)}),Ei=e=>e.total??Number(e.rows[0]?.count??0),Di=e=>e==null||e===``,Oi=e=>typeof e==`string`&&URL.canParse(e)&&new URL(e).protocol===`https:`?new URL(e).href:void 0,ki=e=>typeof e==`number`||typeof e==`boolean`||typeof e==`string`&&/^(-?\d+(\.\d+)?|true|false)$/.test(e),Ai=(e,t)=>{if(e.kind!==`list`||e.filter===void 0)return!1;let n=Object.hasOwn(t,e.resource)?t[e.resource]:void 0;if(!n)return!1;let r=Ie(e.filter);return!r.ok||!r.ast?!1:F(n,r.ast).ok},ji=(e,t,n,r,i)=>{let a=Pt(e).find(e=>!mt(e).some(e=>Di(r[e])));if(!a)return;let o=T(a.label,e=>{let i=t.fields[e];return i?ot(i,r[e],n?.fields[e]):String(r[e])}),s=tt(a);if(`href`in s){let e=Oi(r[we(s.href)??``]);return e===void 0?void 0:{label:o,href:e}}if(N(s.to)!==void 0){let e=me(s.to,r);return Ai(e,i)?{label:o,to:e}:void 0}if(de(s.to).every(e=>ki(r[e])))return{label:o,to:me(s.to,r)}},Mi=({button:e,model:t,view:n,record:r,models:i})=>{let a=ji(e,t,n,r,i);if(!a)return null;let o=k($e({variant:`secondary`,size:`sm`}),`min-w-0 max-w-full shrink`),s=(0,Z.jsx)(`span`,{className:`truncate`,children:a.label});return`href`in a?(0,Z.jsxs)(`a`,{href:a.href,target:`_blank`,rel:`noreferrer`,title:a.label,className:o,children:[s,(0,Z.jsxs)(`span`,{className:`sr-only`,children:[` `,At(`opensNewTab`)]}),(0,Z.jsx)(x,{"aria-hidden":!0,className:`size-3.5 shrink-0`})]}):(0,Z.jsx)(se,{to:a.to,title:a.label,className:o,children:s})},Ni=un({rowSortingFeature:fn,rowSelectionFeature:dn}),Pi=ln(),Fi=e=>Pi.columns(e.map(e=>Pi.accessor(t=>e.value?e.value(t):t[e.id],{id:e.id,header:e.header,enableSorting:e.sortable??!1,cell:t=>e.render?e.render(t.row.original):Yt(e,t.getValue(),t.row.original)}))),Ii=(e,t)=>e.flatMap(e=>{let n=e.available?t.filter(e.available):t;return n.length===0?[]:[{action:e,rows:n,skipped:t.length-n.length}]}),Li=async(e,t,n)=>{let r=await e.onRun(t,n);if(!r)return t;let i=new Set(r.map(e=>e.id));return t.filter(e=>!i.has(e.id))},Ri=()=>{let e=!1;return async(t,n,r)=>{if(!e){e=!0;try{return await Li(t,n,r)}finally{e=!1}}}},zi=({total:e,selectedCount:t,bulkActions:n=[],className:r})=>(0,Z.jsx)(`div`,{className:k(`flex h-9 shrink-0 items-center border-t bg-surface px-3 text-xs text-muted-foreground`,r),children:(0,Z.jsxs)(`span`,{className:`flex items-center tabular-nums`,children:[s(e),t>0&&(0,Z.jsx)(`span`,{className:`ml-3 font-medium text-primary-text`,children:S(`selected`,{count:dt(t)})}),t>0&&n.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:e.onRun,className:k(`ml-3 rounded border bg-background px-2 py-0.5 font-medium hover:bg-muted`,e.destructive?`border-danger/40 text-danger-text`:`text-foreground`),children:e.label},e.label))]})}),Bi=(e,t)=>typeof e.label==`string`?e.label:e.label(t),Vi=(e,t)=>e.filter(e=>e.available?.(t)??!0),Hi=({row:e,actions:t})=>{let{open:n,setOpen:r,place:i,button:a,menu:o}=rt();return(0,Z.jsxs)(`div`,{className:`relative flex justify-center bg-inherit`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{ref:a,type:`button`,"aria-label":S(`rowActions`),"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(!n),className:`inline-flex items-center justify-center rounded p-1 text-faint-foreground hover:bg-muted hover:text-foreground pointer-coarse:size-11`,children:(0,Z.jsx)(g,{className:`size-4`})}),(0,Z.jsx)(Bt,{open:n,title:S(`rowActions`),onClose:()=>r(!1),menu:(0,Z.jsx)(`ul`,{ref:o,role:`menu`,onClick:e=>e.stopPropagation(),style:i??{visibility:`hidden`},className:`fixed z-50 min-w-36 rounded-md border bg-background py-1 shadow-pop`,children:t.map((t,n)=>{let i=Bi(t,e),a=t.blocked?.(e),o=k(`block w-full px-3 py-1.5 text-left hover:bg-muted disabled:cursor-default disabled:opacity-60 disabled:hover:bg-transparent`,t.destructive&&`text-danger-text`);return(0,Z.jsx)(`li`,{role:`none`,children:t.link&&a===void 0?(0,Z.jsx)(vt,{role:`menuitem`,to:t.link(e),onClick:()=>r(!1),className:o,children:i}):(0,Z.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:a!==void 0,title:a,className:o,onClick:()=>{r(!1),t.onSelect?.(e)},children:i})},n)})})})]})},Ui=e=>52+Math.ceil(String(e).length*1.33)*7,Wi=.6,Gi=(e,t)=>Math.max(e.minWidth??0,e.width*t),Ki=(e,t)=>e.fixed?`${Math.max(e.minWidth??0,e.width)}px`:`minmax(${Gi(e,t)}px, ${e.width}fr)`,qi=(e,t,n=0,r=Wi)=>`${t}px ${e.map(e=>Ki(e,r)).join(` `)}${n>0?` ${n}px`:``}`,Ji=(e,t,n=0,r=Wi)=>t+n+e.reduce((e,t)=>e+(t.fixed?Math.max(t.minWidth??0,t.width):Gi(t,r)),0),Yi=()=>{let e=(0,X.useRef)(null),t=(0,X.useRef)(null),[n,r]=(0,X.useState)({scrolled:!1,more:!1}),i=(0,X.useCallback)(()=>{let t=e.current;if(!t)return;let n={scrolled:t.scrollLeft>1,more:t.scrollLeft+t.clientWidth<t.scrollWidth-1};r(e=>e.scrolled===n.scrolled&&e.more===n.more?e:n)},[]);return{ref:e,attach:(0,X.useCallback)(n=>{if(t.current?.disconnect(),t.current=null,e.current=n,!n)return;let r=new ResizeObserver(i);r.observe(n);for(let e of Array.from(n.children))r.observe(e);t.current=r,i()},[i]),onScroll:i,...n}},Xi=`protobase:pinned:`,Zi=(e,t)=>`${Xi}${e}:${t}`,Qi=(e,t)=>ye(()=>{let n=e.getItem(t);if(n===null)return;let r=JSON.parse(n);return Array.isArray(r)&&r.every(e=>typeof e==`string`)?r:void 0},void 0),$i=(e,t,n)=>ye(()=>e.setItem(t,JSON.stringify(n)),void 0),ea=(e,t=[])=>{let[n,r]=(0,X.useState)(()=>e?Qi(localStorage,e):void 0),i=(0,X.useCallback)(t=>{r(t),e&&$i(localStorage,e,t)},[e]);return[n??t,i]},ta=e=>{let t=e.findIndex(e=>e.title);return t<0||t>1?[]:e.slice(0,t+1).map(e=>e.id)},na=e=>Object.fromEntries(e.map(({id:e,width:t,minWidth:n,fixed:r})=>[e,{width:t,minWidth:n,fixed:r}])),ra=e=>e.map(({id:e,minWidth:t,maxWidth:n})=>`${e}:${t??``}:${n??``}`).sort().join(` `),ia=(e,t)=>{let n=ra(e),[r,i]=(0,X.useState)(),a=r?.key===n?r:void 0;!a&&t.length>0&&i({key:n,sizes:na(Ut(e,t))});let o=a?.sizes;return(0,X.useMemo)(()=>o?e.map(e=>({...e,...o[e.id]})):e,[e,o])},aa=(e,t)=>Math.max(Math.min(64,e),Math.round(e+t)),oa=(e,t)=>e.map(e=>e.id in t?{...e,fixed:!0,width:t[e.id],minWidth:void 0}:e),sa=e=>Object.fromEntries([...e.querySelectorAll(`[data-col-id]`)].map(e=>[e.dataset.colId,e.offsetWidth])),ca=e=>{let[t,n]=(0,X.useState)({}),r=()=>({...e.current?sa(e.current):{},...t});return{widths:t,onPointerDown:(e,t)=>{if(t.button!==0)return;t.preventDefault();let i=r(),a=t.clientX,o=t=>n({...i,[e]:aa(i[e]??0,t.clientX-a)}),s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},onKeyDown:(e,t)=>{let i=t.key===`ArrowRight`?16:t.key===`ArrowLeft`?-16:0;if(i===0)return;t.preventDefault();let a=r();n({...a,[e]:aa(a[e]??0,i)})}}},la=()=>parseFloat(getComputedStyle(document.documentElement).fontSize),ua=()=>(0,X.useSyncExternalStore)(e=>(window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)),la,()=>16),da=2,fa=2.25,pa=1.75,ma=2,ha=2.25,ga=(e,{compact:t,withBelow:n})=>({header:da*e,row:((t?pa:fa)+(n?ma:0))*e,footer:ha*e}),_a=e=>e===`money`||e===`number`||e===`signed`||e===`percent`,va=()=>S(`unsortable`),ya=({header:e,pinned:t,sortable:n,onTogglePin:r})=>{let{open:i,setOpen:a,place:o,button:s,menu:c}=rt();return(0,Z.jsxs)(`div`,{className:`relative ml-auto shrink-0`,children:[(0,Z.jsx)(`button`,{ref:s,type:`button`,"aria-label":S(`columnMenu`,{header:e}),"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>a(!i),className:`relative inline-flex size-5 items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground focus-visible:opacity-100 after:absolute after:-inset-2 after:content-[''] md:opacity-0 md:group-hover/cell:opacity-100 aria-expanded:opacity-100`,children:(0,Z.jsx)(g,{className:`size-3.5`})}),(0,Z.jsx)(Bt,{open:i,title:S(`columnMenu`,{header:e}),onClose:()=>a(!1),menu:(0,Z.jsxs)(`ul`,{ref:c,role:`menu`,style:o??{visibility:`hidden`},className:`fixed z-50 min-w-32 rounded-md border bg-background py-1 text-body font-normal text-foreground shadow-pop`,children:[!n&&(0,Z.jsx)(`li`,{role:`none`,children:(0,Z.jsx)(`span`,{role:`menuitem`,"aria-disabled":`true`,className:`block min-h-9 whitespace-nowrap px-3 py-1.5 text-muted-foreground`,children:va()})}),(0,Z.jsx)(`li`,{role:`none`,children:(0,Z.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block min-h-9 w-full whitespace-nowrap px-3 py-1.5 text-left hover:bg-muted`,onClick:()=>{a(!1),r()},children:S(t?`unpin`:`pinToLeft`)})})]})})]})},ba=({id:e,header:t,width:n,resize:r})=>(0,Z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":S(`resizeColumn`,{header:t}),"aria-valuemin":64,"aria-valuenow":n,tabIndex:0,onPointerDown:t=>r.onPointerDown(e,t),onKeyDown:t=>r.onKeyDown(e,t),className:`group/resize absolute inset-y-0 right-0 z-10 flex w-2 cursor-col-resize touch-none justify-end outline-none`,children:(0,Z.jsx)(`div`,{className:`h-full w-0.5 bg-transparent group-hover/resize:bg-primary group-focus-visible/resize:bg-primary group-active/resize:bg-primary`})}),xa=({sorted:e})=>e===`asc`?(0,Z.jsx)(Mn,{className:`size-3 text-foreground`}):e===`desc`?(0,Z.jsx)(On,{className:`size-3 text-foreground`}):(0,Z.jsx)(le,{className:`size-3 opacity-0 group-hover/head:opacity-100`}),Sa=({spec:e})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.header}),e.highlight&&(0,Z.jsx)(`span`,{className:`rounded bg-primary px-1 text-[0.625rem] font-semibold uppercase leading-4 text-primary-foreground`,children:S(`new`)})]}),Ca=({cells:e,specs:t,gutter:n,selectedCount:r,selectable:i,trailing:a,minScale:o,pins:s={},lastPinned:c,scrolled:l,onTogglePin:u,resize:d,widths:f={},onClearSelection:p})=>(0,Z.jsxs)(`div`,{className:`grid h-8 shrink-0 items-center border-b bg-surface text-body font-medium text-muted-foreground`,style:{gridTemplateColumns:qi(t,n,a,o)},role:`row`,children:[(0,Z.jsxs)(`div`,{className:k(`sticky left-0 z-10 flex h-full items-center gap-2 bg-inherit pl-3`,l&&!c&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),style:{width:n},children:[i&&(0,Z.jsx)(Mt,{checked:!1,indeterminate:r>0,label:S(r>0?`clearSelection`:`noRowsSelected`),disabled:r===0,onChange:p,className:k(r===0&&`opacity-60`)}),n>40&&(0,Z.jsx)(`span`,{className:`w-6 text-right text-faint-foreground`,children:`#`})]}),e.map(({spec:e,sorted:t,onSort:n})=>{let r=e.id in s;return(0,Z.jsxs)(`div`,{"data-col-id":e.id,style:r?{left:s[e.id]}:void 0,className:k(`group/cell flex h-full min-w-0 items-center`,r?`sticky z-10 bg-inherit`:`relative`,r&&l&&e.id===c&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`,e.highlight&&`bg-primary-soft text-primary-text`),children:[e.sortable?(0,Z.jsxs)(`button`,{type:`button`,onClick:n,className:k(`group/head flex h-full min-w-0 flex-1 items-center gap-1 pl-3 pr-1 text-left`,_a(e.kind)&&`justify-end`,`hover:text-foreground`,t&&`text-foreground`),children:[(0,Z.jsx)(Sa,{spec:e}),(0,Z.jsx)(xa,{sorted:t})]}):(0,Z.jsx)(`div`,{title:va(),className:k(`flex h-full min-w-0 flex-1 items-center gap-1 pl-3 pr-1 text-left`,_a(e.kind)&&`justify-end`),children:(0,Z.jsx)(Sa,{spec:e})}),(0,Z.jsx)(`div`,{className:`pr-1.5`,children:(0,Z.jsx)(ya,{header:e.header,pinned:r,sortable:!!e.sortable,onTogglePin:()=>u(e.id)})}),d&&(0,Z.jsx)(ba,{id:e.id,header:e.header,width:f[e.id],resize:d})]},e.id)}),a?(0,Z.jsx)(`div`,{className:`sticky right-0 z-10 h-full bg-inherit`}):null]}),wa=e=>({gridTemplateColumns:qi(e.specs,e.gutter,e.trailing,e.minScale),height:e.height,transform:`translateY(${e.offset}px)`}),Ta=(e,t)=>k(`flex h-full min-w-0 items-center overflow-hidden whitespace-nowrap px-3`,_a(e.kind)&&`justify-end`,e.highlight&&`bg-primary-soft/60`,t.pins&&e.id in t.pins&&`sticky z-10 bg-inherit`,t.scrolled&&e.id===t.lastPinned&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),Ea=(e,t)=>t&&e.id in t?{left:t[e.id]}:void 0,Da=({width:e,index:t,selectable:n,selected:r,onToggle:i,edge:a})=>(0,Z.jsxs)(`div`,{onClick:n?e=>{e.stopPropagation(),i?.()}:void 0,className:k(`sticky left-0 z-10 flex h-full items-center gap-2 bg-inherit pl-3`,n&&`cursor-default`,a&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),style:{width:e},children:[n&&(0,Z.jsx)(Mt,{checked:!!r,label:S(`selectRow`,{row:t+1})}),e>40&&(0,Z.jsx)(`span`,{className:`min-w-6 text-right text-[0.6875rem] tabular-nums text-faint-foreground`,children:dt(t+1)})]}),Oa=(e,t,n)=>({gridTemplateColumns:qi(e.specs,e.gutter,e.trailing,e.minScale),height:e.height,top:e.offset,transform:t===0?void 0:`translateY(${t}px)`,transition:n}),ka=e=>t=>{t.target.closest(`a`)||e()},Aa=({cells:e,selected:t,current:n=!1,onToggle:r,onOpen:i,menu:a,handle:o,rowRef:s,dragY:c,transition:l,dragging:u,...d})=>(0,Z.jsxs)(`div`,{ref:s,role:`row`,"aria-current":n||void 0,"data-pressable":i?``:void 0,onClick:i&&ka(i),className:k(`absolute inset-x-0 top-0 grid items-center border-b`,t||n?`bg-primary-soft`:`bg-background hover:bg-surface`,i&&`cursor-pointer`,u&&`z-30 bg-surface shadow-pop`),style:c===void 0?wa(d):Oa(d,c,l),children:[o?(0,Z.jsx)(`div`,{className:k(`sticky left-0 z-10 flex h-full items-center bg-inherit pl-1.5`,d.scrolled&&!d.lastPinned&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),style:{width:d.gutter},children:o}):(0,Z.jsx)(Da,{width:d.gutter,index:d.index,selectable:d.selectable,selected:t,onToggle:r,edge:d.scrolled&&!d.lastPinned}),e.map(({spec:e,content:t,props:n,chosen:r,editing:i,editable:a})=>(0,Z.jsx)(`div`,{role:n?`gridcell`:`cell`,...n,className:k(Ta(e,d),n&&`scroll-mb-[calc(var(--pb-sticky-bottom,0px)+3rem)] scroll-mt-[calc(var(--pb-sticky-top,0px)+2rem)] outline-none`,a&&!i&&`cursor-default`,r&&`shadow-[inset_0_0_0_2px_var(--primary)]`,i&&`z-30 overflow-visible bg-background px-1`),style:Ea(e,d.pins),children:t},e.id)),a&&(0,Z.jsx)(`div`,{className:`sticky right-0 z-10 flex h-full items-center justify-center bg-inherit`,children:a})]}),ja=[`w-3/4`,`w-1/2`,`w-2/3`,`w-5/6`,`w-2/5`],Ma=e=>(0,Z.jsxs)(`div`,{role:`row`,"aria-busy":!0,className:`absolute inset-x-0 top-0 grid items-center border-b bg-background`,style:wa(e),children:[(0,Z.jsx)(Da,{width:e.gutter,index:e.index,selectable:!1,edge:e.scrolled&&!e.lastPinned}),e.specs.map((t,n)=>(0,Z.jsx)(`div`,{className:Ta(t,e),style:Ea(t,e.pins),children:(0,Z.jsx)(q,{className:k(`h-2.5`,ja[(e.index+n)%ja.length],_a(t.kind)&&`ml-auto`)})},t.id))]}),Na=1e7,Pa=(e,t,n)=>{let r=e*t,i=Math.min(r,Na);return{rowHeight:t,trueHeight:r,contentHeight:i,scaled:r>i,maxTop:Math.max(0,r-n),maxScroll:Math.max(0,i-n)}},Fa=(e,t)=>!e.scaled||t<=0?t:t>=e.maxScroll?e.maxTop+t-e.maxScroll:t/e.maxScroll*e.maxTop,Ia=(e,t)=>!e.scaled||t<=0?t:t>=e.maxTop?e.maxScroll+t-e.maxTop:t/e.maxTop*e.maxScroll,La=(e,t,n,r)=>{let i=t*e.rowHeight;return e.scaled?i-n+r:i},Ra=(e,t,n,r,i)=>{let a=Math.min(e,Math.max(0,Math.floor(t/n)-i)),o=Math.min(e-1,Math.floor((t+r)/n)+i);return{first:a,last:Math.max(a-1,o)}},za=e=>{let t=document.scrollingElement??document.documentElement;for(let n=e.parentElement;n&&n!==t&&n!==document.body;n=n.parentElement)if(/auto|scroll/.test(getComputedStyle(n).overflowY))return n;return t},Ba=e=>e===(document.scrollingElement??document.documentElement),Va=e=>Ba(e)?window:e,Ha=e=>Number.parseFloat(e)||0,Ua=e=>{let t=getComputedStyle(e),n=Ba(e)?{top:0,height:e.clientHeight}:{top:e.getBoundingClientRect().top+e.clientTop,height:e.clientHeight},r=Ha(t.scrollPaddingTop);return{top:n.top+r,height:Math.max(0,n.height-r-Ha(t.scrollPaddingBottom))}},Wa=6,Ga=(e,t,n)=>{let r=Pa(t,n,e.height),i=Fa(r,e.position);return{geometry:r,top:i,topIndex:Math.floor(Math.max(0,i)/n),...Ra(t,i,n,e.height,Wa)}},Ka=({total:e,rowHeight:t,initialIndex:n,inset:r=0,settle:i,ready:a=!0,onScroll:o})=>{let s=(0,X.useRef)(null),c=(0,X.useRef)(null),[l,u]=(0,X.useState)({position:0,height:0}),d=(0,X.useRef)({total:e,rowHeight:t,initialIndex:n,inset:r,ready:a,onScroll:o});d.current={total:e,rowHeight:t,initialIndex:n,inset:r,ready:a,onScroll:o};let f=(0,X.useCallback)(()=>{let e=s.current;if(!e||!c.current)return;let t=Ua(c.current),n=d.current.inset;return{position:t.top+n-e.getBoundingClientRect().top,height:Math.max(0,t.height-n)}},[]),p=(0,X.useRef)({pending:!0,laidOut:!1}),m=(0,X.useRef)(l);m.current=l;let h=(0,X.useCallback)(()=>{let e=f();if(!e)return;let t=m.current,{total:n,rowHeight:r,onScroll:i}=d.current,a=Ga(t,n,r),o=Ga(e,n,r);p.current.pending||i?.(Math.max(0,o.top));let s=!o.geometry.scaled&&a.first===o.first&&a.last===o.last&&a.topIndex===o.topIndex;(t.height!==e.height||t.position!==e.position&&!s)&&(m.current=e,u(e))},[f]),g=(0,X.useCallback)(()=>{if(!p.current.pending||!p.current.laidOut||!d.current.ready)return;let e=f(),t=c.current;if(!e||!t)return;p.current.pending=!1;let{total:n,rowHeight:r,initialIndex:i}=d.current;i>0?t.scrollTop+=Ia(Pa(n,r,e.height),i*r)-e.position:e.position>0&&(t.scrollTop=0)},[f]);(0,X.useLayoutEffect)(()=>{let e=s.current;if(!e)return;let t=za(e);c.current=t;let n=Va(t);n.addEventListener(`scroll`,h,{passive:!0}),window.addEventListener(`resize`,h,{passive:!0});let r=new ResizeObserver(()=>{p.current.laidOut=!0,g(),h()});return r.observe(t),r.observe(e),h(),()=>{n.removeEventListener(`scroll`,h),window.removeEventListener(`resize`,h),r.disconnect(),c.current=null}},[h,g]),(0,X.useLayoutEffect)(()=>{g(),h()});let _=(0,X.useCallback)(e=>{let t=f();if(!t||!c.current)return;let n=Pa(d.current.total,d.current.rowHeight,t.height);c.current.scrollTop+=Ia(n,e)-t.position,h()},[f,h]),v=(0,X.useCallback)(()=>!p.current.pending,[]),y=Ga(l,e,t),b=i?i(y.top):y.top,{first:x,last:S}=i?Ra(e,b,t,l.height,Wa):y,C=Array.from({length:S-x+1},(e,t)=>({index:x+t,offset:La(y.geometry,x+t,b,l.position)}));return{ref:s,height:l.height,top:b,geometry:y.geometry,rows:C,first:x,last:S,scrollTo:_,started:v}},qa=e=>e===`ArrowUp`||e===`ArrowDown`||e===`ArrowLeft`||e===`ArrowRight`,Ja=(e,t,n,r)=>{let i=n.indexOf(e.column);if(t===`ArrowUp`)return e.index>0?{...e,index:e.index-1}:void 0;if(t===`ArrowDown`)return e.index<r-1?{...e,index:e.index+1}:void 0;let a=n[t===`ArrowLeft`?i-1:i+1];return i>=0&&a!==void 0?{...e,column:a}:void 0},Ya=(e,t,n,r)=>{let i=t.indexOf(e);return(r===1?t.slice(i+1):t.slice(0,Math.max(0,i)).reverse()).find(n)},Xa=e=>`${e.index}:${e.column}`,Za=({editor:e,columns:t,total:n,rowAt:r,onOpenRow:i,container:a})=>{let[o,s]=(0,X.useState)(),[c,l]=(0,X.useState)(!1),u=(0,X.useRef)(!1),d=(0,X.useRef)(!1);if((0,X.useEffect)(()=>{if(!o||c||!u.current)return;u.current=!1;let e=a.current?.querySelector(`[data-cell="${Xa(o)}"]`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`nearest`,inline:`nearest`}))},[o,c,a]),!e)return;let f=t=>{let n=r(t.index);return n!==void 0&&e.editable(n,t.column)},p=(e,t=!1)=>{u.current=!0,s(e),l(t&&f(e))},m=n=>{if(!o)return;let i=r(o.index),s=n&&i?Ya(o.column,t,t=>e.editable(i,t),n):void 0,c=!!a.current?.contains(document.activeElement);p(s?{...o,column:s}:o,s!==void 0),u.current=c};return{cell:(n,r,i,a)=>{let l={index:n,column:i},u=o?.index===n&&o.column===i,f=e.editable(r,i),h=u||!o&&n===0&&i===t[0];return{content:u&&c?e.render(r,i,m):a,chosen:u,editing:u&&c,editable:f,props:{"data-cell":Xa(l),tabIndex:h?0:-1,"aria-selected":u,onMouseDown:()=>{d.current=u},onFocus:e=>{e.target===e.currentTarget&&!u&&s(l)},onClick:e=>{f&&(e.stopPropagation(),d.current&&!c&&p(l,!0))},onDoubleClick:e=>{f&&(e.stopPropagation(),u&&c||p(l,!0))}}}},onKeyDown:e=>{if(c||!o||!(e.target instanceof HTMLElement)||e.target.dataset.cell!==Xa(o))return;let a=e.key===`Tab`?e.shiftKey?`ArrowLeft`:`ArrowRight`:e.key;if(qa(a)){let i=Ja(o,a,t,n);if(!i&&e.key===`Tab`)return;e.preventDefault(),i&&r(i.index)&&p(i);return}if(e.key===`Enter`||e.key===`F2`){e.preventDefault();let t=r(o.index);f(o)?p(o,!0):e.key===`Enter`&&t&&i?.(t);return}e.key===`Escape`&&s(void 0)}}},Qa=({ids:e,rowAt:t,reorder:n,children:r})=>{let i=Sn(gn(_n,{activationConstraint:{distance:4}}),gn(yn,{activationConstraint:{delay:250,tolerance:5}}),gn(vn,{coordinateGetter:Tn})),a=t=>e.indexOf(String(t)),o=e=>{let r=t(a(e));return r?n.label(r):S(`row`)};return(0,Z.jsx)(xn,{sensors:i,collisionDetection:bn,onDragEnd:({active:e,over:t})=>{t&&e.id!==t.id&&n.onMove(a(e.id),a(t.id))},accessibility:{announcements:{onDragStart:({active:t})=>S(`pickedUp`,{name:o(t.id),row:a(t.id)+1,rows:e.length}),onDragOver:({active:t,over:n})=>n?S(`isOver`,{name:o(t.id),row:a(n.id)+1,rows:e.length}):void 0,onDragEnd:({active:t,over:n})=>n?S(`droppedAt`,{name:o(t.id),row:a(n.id)+1,rows:e.length}):S(`putBack`,{name:o(t.id)}),onDragCancel:({active:e})=>S(`cancelled`,{name:o(e.id),row:a(e.id)+1})},screenReaderInstructions:{draggable:S(`reorderInstructions`)}},children:(0,Z.jsx)(En,{items:e,strategy:Cn,children:r})})},$a=({row:e,label:t,...n})=>{let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,transition:c,isDragging:l}=wn({id:e.id}),u=(0,Z.jsx)(`button`,{ref:o,type:`button`,"aria-label":S(`move`,{label:t}),...r,...i,onClick:e=>e.stopPropagation(),style:{touchAction:`none`},className:`flex size-7 cursor-grab items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground focus-visible:text-foreground active:cursor-grabbing pointer-coarse:size-9`,children:(0,Z.jsx)(Bn,{className:`size-4`})});return(0,Z.jsx)(Aa,{...n,rowRef:a,handle:u,dragY:s?.y??0,transition:c,dragging:l})},eo=({columns:e,source:t,naturalSort:n,initialScrollIndex:r=0,onScrollIndex:i,latencyMs:a=150,sort:o,onSortChange:s,onOpenRow:c,rowLink:l,chosenRow:u,rowActions:d,cellEditor:f,rowPatches:p,bulkActions:m,pinKey:h,defaultPinned:g,rowNumbers:_=!0,compact:v=!1,selectable:y=!0,reorder:b,fit:x=!1,scroll:S=`own`,className:C})=>{let w=y&&!b,{header:T,row:E,footer:ee}=ga(ua(),{compact:v,withBelow:e.some(e=>e.below)}),D=!Xt(),O=(g??(D?[]:ta(e))).join(` `),[A,j]=ea(h,(0,X.useMemo)(()=>O?O.split(` `):[],[O])),M=(0,X.useMemo)(()=>[...A.flatMap(t=>e.find(e=>e.id===t)??[]),...e.filter(e=>!A.includes(e.id))],[e,A]),N=M.slice(0,M.filter(e=>A.includes(e.id)).length).map(e=>e.id),{total:P}=t,[te,F]=(0,X.useState)(n?[{id:n.columnId,desc:n.direction===`desc`}]:[]),I=o?[{id:o.columnId,desc:o.direction===`desc`}]:te,ne=e=>{let t=typeof e==`function`?e(I):e,n=t[0];s&&n&&s({columnId:n.id,direction:n.desc?`desc`:`asc`}),o||F(t)},[L,R]=(0,X.useState)({}),z=(0,X.useMemo)(()=>Fi(M),[M]),B=I[0],V=!!(!o&&n&&B&&B.id===n.columnId&&(B.desc?`desc`:`asc`)!==n.direction),re=t.rowAt,ie=(0,X.useCallback)(e=>re(V?P-1-e:e),[re,V,P]),[ae]=(0,X.useState)(r),{ref:oe,geometry:se,rows:ce,first:le,last:ue}=Ka({total:P,rowHeight:E,initialIndex:ae,inset:T,onScroll:i&&(e=>i(e/E))}),de=D||!_?40:Ui(P),fe=pn({total:P,rowAt:re?ie:void 0,loadRows:t.loadRows,cachedRows:t.cachedRows,revision:t.revision,latencyMs:a},le,ue),pe=(0,X.useCallback)(e=>{let t=fe(e),n=t&&p?.get(t.id);return n?{...t,...n}:t},[fe,p]),me=ce.map(({index:e,offset:t})=>({index:e,offset:t,row:pe(e)})),he=(0,X.useMemo)(()=>me.flatMap(({row:e})=>e?[e]:[]),[pe,le,ue]),ge=(0,X.useRef)(null),_e=ca(ge),ve=ia(M,he),ye=(0,X.useMemo)(()=>oa(ve,_e.widths),[ve,_e.widths]),be=cn({features:Ni,columns:z,data:he,state:{sorting:I,rowSelection:L},onSortingChange:ne,onRowSelectionChange:R,manualSorting:!0,enableMultiSort:!1,enableSortingRemoval:!1,getRowId:e=>e.id}),xe=new Map(be.getRowModel().rows.map(e=>[e.id,e])),Se=Object.keys(L).length,Ce=(0,X.useRef)(new Map),[we]=(0,X.useState)(Ri);for(let e of be.getRowModel().rows)e.getIsSelected()&&Ce.current.set(e.id,e.original);let Te=d&&d.length>0?40:0,Ee=D?1:Wi,H=Yi(),De=()=>{H.onScroll(),ge.current&&H.ref.current&&(ge.current.scrollLeft=H.ref.current.scrollLeft)},[Oe,ke]=(0,X.useState)({});(0,X.useLayoutEffect)(()=>{let e=ge.current?.querySelector(`[role=row]`);if(!e)return;let t=de,n={};for(let r of N)n[r]=t,t+=e.querySelector(`[data-col-id="${r}"]`)?.offsetWidth??0;JSON.stringify(Oe)!==JSON.stringify(n)&&ke(n)});let Ae=N.at(-1),je=e=>j(A.includes(e)?A.filter(t=>t!==e):[...A,e]),U=be.getHeaderGroups().flatMap(e=>e.headers.map(e=>({spec:M.find(t=>t.id===e.column.id),sorted:e.column.getIsSorted(),onSort:t=>e.column.getToggleSortingHandler()?.(t)}))),Me=(0,X.useRef)(null),W=Za({editor:f,columns:(0,X.useMemo)(()=>M.map(e=>e.id),[M]),total:P,rowAt:pe,onOpenRow:c,container:Me}),Ne=(M.find(e=>e.title)??M[0])?.id,Pe=Ji(ye,de,Te,Ee),Fe=S===`own`,G=!x||w&&!!m?.length,Ie=(0,Z.jsx)(`div`,{ref:ge,className:k(`sticky z-20 shrink-0 overflow-hidden`,Fe?`top-0`:`top-[var(--pb-sticky-top,0px)]`),children:(0,Z.jsx)(`div`,{style:{minWidth:Pe},children:(0,Z.jsx)(Ca,{cells:U,specs:ye,gutter:de,trailing:Te,minScale:Ee,pins:Oe,lastPinned:Ae,scrolled:H.scrolled,onTogglePin:je,resize:_e,widths:_e.widths,selectable:w,selectedCount:Se,onClearSelection:()=>R({})})})}),Le=me.map(({index:e,offset:t,row:n})=>{let r={specs:ye,gutter:de,index:e,offset:t,height:E,selectable:w,trailing:Te,minScale:Ee,scrolled:H.scrolled,pins:Oe,lastPinned:Ae},i=n?xe.get(n.id):void 0;if(!i||!n)return(0,Z.jsx)(Ma,{...r},`skeleton-${e}`);let a=Te?Vi(d,n):[],o={...r,selected:i.getIsSelected(),current:n.id===u,onToggle:()=>i.toggleSelected(),onOpen:c?()=>c(n):void 0,menu:a.length>0?(0,Z.jsx)(Hi,{row:n,actions:a}):void 0,cells:i.getAllCells().map(t=>{let r=M.find(e=>e.id===t.column.id),i=(0,Z.jsx)(be.FlexRender,{cell:t}),a=!!f?.editable(n,t.column.id),o=l&&t.column.id===Ne&&!a?(0,Z.jsx)(vt,{to:l(n),className:`flex min-w-0 items-center hover:underline`,children:i}):i,s=r.below?(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[o,r.below(n)]}):o;return{spec:r,...W?W.cell(e,n,t.column.id,s):{content:s}}})};return b?(0,Z.jsx)($a,{...o,row:n,label:b.label(n)},n.id):(0,Z.jsx)(Aa,{...o},n.id)}),Re=(0,Z.jsx)(`div`,{ref:H.attach,onScroll:De,className:`overflow-x-auto overflow-y-hidden overscroll-x-contain [-webkit-overflow-scrolling:touch]`,children:(0,Z.jsx)(`div`,{ref:oe,className:`relative`,style:{minWidth:Pe,height:se.contentHeight},children:b?(0,Z.jsx)(Qa,{ids:Array.from({length:P},(e,t)=>pe(t)?.id??`missing-${t}`),rowAt:pe,reorder:b,children:Le}):Le})});return(0,Z.jsxs)(`div`,{ref:Me,role:`grid`,"aria-rowcount":P,onKeyDown:W?.onKeyDown,className:k(`flex flex-col rounded-lg border bg-background`,Fe?`min-h-0 overflow-hidden`:`overflow-clip`,C),style:x&&Fe?{height:T+P*E+(G?ee:0)+2}:void 0,children:[(0,Z.jsxs)(`div`,{className:k(`relative`,Fe&&`flex min-h-0 flex-1 flex-col`),children:[Fe?(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,children:[Ie,Re]}):(0,Z.jsxs)(Z.Fragment,{children:[Ie,Re]}),H.more&&(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 right-0 z-20 w-8 bg-gradient-to-l from-backdrop/15 to-transparent`})]}),G&&(0,Z.jsx)(zi,{total:P,className:Fe?void 0:`sticky bottom-[var(--pb-sticky-bottom,0px)] z-20`,selectedCount:Se,bulkActions:Ii(m??[],Object.keys(L).flatMap(e=>Ce.current.get(e)??[])).map(({action:e,rows:t,skipped:n})=>({label:e.label(t.length),destructive:e.destructive,onRun:()=>void we(e,t,n).then(e=>{if(!e)return;let t=new Set(e.map(e=>e.id));R(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.has(e))));for(let e of t)Ce.current.delete(e)})}))})]})},to=G(`app/searches`),no=`inline-flex h-6 items-center rounded-full border border-primary-border bg-primary-soft px-2.5 text-xs font-medium text-primary-text`,ro=({chips:e,className:t})=>(0,Z.jsx)(`ul`,{className:k(`flex flex-wrap gap-1.5`,t),"aria-label":to(`filters`),children:e.map(e=>(0,Z.jsx)(`li`,{className:no,children:e.label},e.key))}),io=({chips:e})=>(0,Z.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,t)=>(0,Z.jsxs)(`span`,{className:no,children:[t>0&&(0,Z.jsx)(`span`,{className:`sr-only`,children:`, `}),e.label]},e.key))}),ao=e=>e.map(e=>e.label).join(`, `),oo=G(`filter-panel`),so=[`today`,`7d`,`30d`,`year`],co=new Set([`today`,`yesterday`,`24h`,`7d`,`30d`,`90d`,`month`,`quarter`,`year`]),lo=e=>co.has(e)?oo(e):void 0,uo={facets:{},toggles:[]},fo=(e,t,n)=>{let r=e.facets[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{...e,facets:{...e.facets,[t]:i}}},po=(e,t)=>({...e,toggles:e.toggles.includes(t)?e.toggles.filter(e=>e!==t):[...e.toggles,t]}),mo=(e,t,n)=>{let{[t]:r,...i}=e.ranges??{};return{...e,ranges:n?{...i,[t]:n}:i}},ho=(e,t)=>e.options.find(e=>e.value===t)?.label??e.labels?.[t]??t,go=(e,t)=>{let n=e.facets.flatMap(e=>(t.facets[e.id]??[]).map(t=>({key:`facet:${e.id}:${t}`,label:`${e.label}: ${ho(e,t)}`}))),r=(e.ranges??[]).flatMap(e=>{let n=t.ranges?.[e.id];return n?[{key:`range:${e.id}`,label:`${e.label}: ${e.format(n[0])} – ${e.format(n[1])}`}]:[]}),i=t.date?[{key:`date`,label:lo(t.date)??t.date}]:[],a=t.toggles.map(t=>({key:`toggle:${t}`,label:e.toggles?.find(e=>e.id===t)?.label??t}));return[...n,...r,...i,...a]},_o=(e,t)=>{if(t===`date`)return{...e,date:void 0};let[n,r,i]=t.split(`:`);if(n===`range`)return mo(e,r,void 0);if(n===`toggle`)return po(e,r);if(n===`facet`)return fo(e,r,i);throw Error(`Unknown filter chip key: ${t}`)},vo=(e,t)=>e.toLowerCase().includes(t.trim().toLowerCase()),Q=Ne(),yo={start:0,end:0},bo={"24h":{amount:24,unit:`h`},"7d":{amount:7,unit:`d`},"30d":{amount:30,unit:`d`},"90d":{amount:90,unit:`d`}},xo=e=>new Date(e).toISOString().replace(`.000Z`,`Z`),So=(e,t,n)=>{let r=We(t.getTime(),n),[i,a]=[Number(r.slice(0,4)),Number(r.slice(5,7))-1],o=e=>new Date(e).toISOString().slice(0,10);return e===`year`?o(Date.UTC(i,0,1)):e===`quarter`?o(Date.UTC(i,Math.floor(a/3)*3,1)):e===`month`?o(Date.UTC(i,a,1)):e===`yesterday`?o(Date.parse(`${r}T00:00:00Z`)-864e5):r},Co=[`year`,`quarter`,`month`,`yesterday`,`today`],wo=(e,t,n)=>t===`date`?e:xo(Dt(e,n)),To=(e,t,n)=>t===`date`?{kind:`string`,value:wo(e,t,n),span:yo}:{kind:`timestamp`,value:wo(e,t,n),span:yo},Eo=(e,t,n,r,i)=>{if(t in bo)return[Q.gte(e,Q.ago(t))];let a=Q.gte(e,To(So(t,n,i),r,i));return t===`yesterday`?[a,Q.lt(e,To(So(`today`,n,i),r,i))]:[a]},Do=(e,t,n=new Date,r=Qe())=>{let i=e.facets.flatMap(e=>{let n=t.facets[e.id]??[];if(n.length===0)return[];if(e.flags){let t=e.options.filter(e=>n.includes(e.value)).map(e=>Q.eq(e.value,!0));return t.length===0?[]:[t.length===1?t[0]:Q.or(...t)]}return[n.length===1?Q.eq(e.id,n[0]):Q.in(e.id,n)]}),a=(e.ranges??[]).flatMap(e=>{let n=t.ranges?.[e.id];return n?[Q.gte(e.id,n[0]),Q.lte(e.id,n[1])]:[]}),o=e.dateField&&t.date?Eo(e.dateField,t.date,n,e.dateKind,r):[],s=(e.toggles??[]).filter(e=>t.toggles.includes(e.id)).map(e=>Q.eq(e.id,!0));return[...i,...a,...o,...s]},Oo=e=>e.length===0?``:L(Q.and(...e)),ko=(e,t,n=[],r=new Date,i=Qe())=>Oo([...Do(e,t,r,i),...n]),Ao=e=>e.kind===`and`?e.args.flatMap(Ao):[e],$=e=>e.field.path.join(`.`),jo=e=>e.kind===`compare`&&e.op===`=`&&e.value.kind===`boolean`&&e.value.value,Mo=(e,t)=>{let n=e.kind===`or`?e.args:[e];if(!n.every(jo))return;let r=n.map($),i=t.get(r[0]);return i!==void 0&&r.every(e=>t.get(e)===i)?{group:i,fields:r}:void 0},No=e=>e.kind===`number`?String(e.raw):e.kind===`string`?String(e.value):void 0,Po=(e,t,n)=>{let r=e.value;if(r.kind===`now`&&r.offset?.sign===`-`){let{amount:e,unit:t}=r.offset.duration;return Object.entries(bo).find(([,n])=>n.amount===e&&n.unit===t)?.[0]}if(r.kind===`timestamp`)return Co.find(e=>wo(So(e,t,n),`timestamp`,n)===r.value);if(r.kind===`string`)return Co.find(e=>So(e,t,n)===r.value)},Fo=(e,t,n=new Date,r=Qe())=>{let i=Ie(t);if(!i.ok)return{ok:!1,errors:i.errors};let a={facets:{},toggles:[]},o=[],s=new Set(e.facets.filter(e=>!e.flags).map(e=>e.id)),c=new Map(e.facets.filter(e=>e.flags).flatMap(e=>e.options.map(t=>[t.value,e.id]))),l=new Set((e.toggles??[]).map(e=>e.id)),u=new Set((e.ranges??[]).map(e=>e.id)),d=new Map,f,p;for(let t of i.ast?Ao(i.ast):[]){let i=Mo(t,c);if(i&&!a.facets[i.group])a.facets[i.group]=i.fields;else if(t.kind===`compare`&&s.has($(t))&&t.op===`=`&&No(t.value)!==void 0)a.facets[$(t)]=[...a.facets[$(t)]??[],No(t.value)];else if(t.kind===`in`&&s.has($(t))&&t.values.every(e=>No(e)!==void 0))a.facets[$(t)]=[...a.facets[$(t)]??[],...t.values.map(e=>No(e))];else if(t.kind===`compare`&&e.dateField===$(t)&&t.op===`>=`&&Po(t,n,r)&&!a.date)a.date=Po(t,n,r),f=t;else if(t.kind===`compare`&&e.dateField===$(t)&&t.op===`<`&&(t.value.kind===`timestamp`||t.value.kind===`string`)&&t.value.value===wo(So(`today`,n,r),t.value.kind===`string`?`date`:`timestamp`,r))p=t;else if(t.kind===`compare`&&l.has($(t))&&t.op===`=`&&t.value.kind===`boolean`&&t.value.value)a.toggles.push($(t));else if(t.kind===`compare`&&u.has($(t))&&(t.op===`>=`||t.op===`<=`)&&t.value.kind===`number`){let e=d.get($(t))??{clauses:[]};t.op===`>=`?e.low=t.value.value:e.high=t.value.value,e.clauses.push(t),d.set($(t),e)}else o.push(t)}a.date===`yesterday`&&!p&&(o.push(f),a.date=void 0),p&&a.date!==`yesterday`&&o.push(p);for(let[e,t]of d)t.low!==void 0&&t.high!==void 0?a.ranges={...a.ranges,[e]:[t.low,t.high]}:o.push(...t.clauses);return{ok:!0,state:a,extras:o}},Io=[`integer`,`bigint`,`decimal`],Lo=(e,t)=>{let n=e?.fields[t]?.type;return n!==void 0&&Io.includes(n)},Ro=(e,t)=>e.kind===`range`||e.kind===`facets`&&Lo(t,e.field),zo=e=>e.secondary?{secondary:!0}:{},Bo=e=>({id:e.field,label:e.field,min:0,max:0,step:1,histogram:[],format:String,...zo(e)}),Vo=(e,t)=>{let n=e?.filters??[],r=n.find(e=>e.kind===`dateRange`);return{facets:n.flatMap(e=>e.kind===`facets`&&!Ro(e,t)?[{id:e.field,label:e.field,options:[],searchable:e.search,...t?.fields[e.field]?.type===`relation`&&{combobox:!0},...zo(e)}]:e.kind===`flags`?[{id:e.fields.join(`|`),label:e.label,options:e.fields.map(e=>({value:e,label:e,count:0})),flags:!0,...zo(e)}]:[]),ranges:n.flatMap(e=>e.kind!==`flags`&&Ro(e,t)?[Bo(e)]:[]),...r&&{dateField:r.field,...r.secondary&&{dateSecondary:!0},dateKind:t?.fields[r.field]?.type===`date`?`date`:`timestamp`,...r.presets.length>0&&{datePresets:r.presets}},toggles:n.flatMap(e=>e.kind===`toggle`?[{id:e.field,label:e.field,...zo(e)}]:[])}},Ho=(e,t)=>(e?.filters??[]).some(e=>e.kind===`range`&&e.field===t&&e.histogram),Uo=(e,t)=>{let n=e?.fields[t],r=n?.suffix??``,i=n?.currency;return i===void 0?e=>`${n?.prefix??``}${e}${r}`:e=>`${ue(e*100,i).replace(`.00`,``)}${r}`},Wo=Ne(),Go={start:0,end:0},Ko=(e,t,n)=>{let r=Fo(Vo(t,e),n);return r.ok?Object.fromEntries(Object.entries(r.state.facets).filter(([t,n])=>e.fields[t]?.type===`relation`&&n.length>0)):{}},qo=(e,t,n)=>{let r=e=>t?.fields[e]?.label??K(e),i=Vo(t,e);return{...i,facets:i.facets.map(i=>{if(i.flags)return{...i,options:i.options.map(e=>({...e,label:r(e.value)}))};let a=e.fields[i.id]?.enumValues??[],o=e.fields[i.id]?.type===`enum`?Object.fromEntries(a.map(e=>[e,kt(e,t?.fields[i.id]?.valueLabels)])):n[i.id]??{};return{...i,label:r(i.id),labels:o}}),ranges:(i.ranges??[]).map(e=>({...e,label:r(e.id),format:Uo(t,e.id)})),toggles:i.toggles?.map(e=>({...e,label:r(e.id)}))}},Jo=(e,t,n,r={})=>{let i=qo(e,t,r),a=Fo(i,n);if(!a.ok)return[{key:`unreadable`,label:to(`unreadableFilter`)}];let o=a.extras.map((e,t)=>({key:`extra:${t}`,label:e.kind===`search`?`"${e.text}"`:L(e)}));return[...go(i,a.state),...o]},Yo=e=>Object.fromEntries(e.facets.filter(e=>!e.flags).map(e=>[e.id,{...e.labels,...Object.fromEntries(e.options.map(e=>[e.value,e.label]))}])),Xo=(e,t,n)=>{if(typeof n!=`string`||n===``)return e;let r=Wo.gt(t,{kind:`timestamp`,value:new Date(n).toISOString(),span:Go}),i=Ie(e);if(!i.ok)throw Error(`The saved filter cannot be read: ${i.errors.map(e=>e.message).join(`; `)}`);return L(i.ast?Wo.and(i.ast,r):r)},Zo=(e,t)=>typeof t!=`string`||t===``?!0:typeof e!=`string`||e===``?!1:new Date(e).getTime()>new Date(t).getTime(),Qo=(e,t)=>{let n=ht(),r=en(),{resources:i,views:a}=J(),o=a[e.name],s=Object.entries(Ko(e,o,t)),c=rn({queries:s.map(([t,o])=>{let s=i[e.fields[t].relation.resource];return{queryKey:ze.labels(`chips:${e.name}.${t}`,o.join(`,`)),enabled:s!==void 0,queryFn:async()=>Object.fromEntries(await Ct(r,n,s,o,a[s.name]))}})});return Jo(e,o,t,Object.fromEntries(s.flatMap(([e],t)=>c[t]?.data?[[e,c[t].data]]:[])))},$o=({target:e,id:t})=>(0,Z.jsx)(Z.Fragment,{children:C(e,t)??t}),es=Ne(),ts=e=>{if(typeof e==`string`||typeof e==`number`)return e;if(e&&typeof e==`object`&&`id`in e)return ts(e.id)},ns=(e,t,n)=>n.flatMap(n=>{let r=ts(n[t]);return r===void 0?[]:[{key:at(Gt(e,n)),target:r}]}),rs=(e,t)=>e.find(e=>at(e.target)===t),is=(e,t)=>[...e,{key:``,target:t}],as=(e,t)=>e.filter(e=>at(e.target)!==t),os=(e,t)=>{let[n]=e.primaryKey;if(e.primaryKey.length!==1||n===void 0)throw Error(`${e.name} has a composite key, so its saved records cannot be listed`);let r=[...new Set(t.map(e=>e.target))];return r.length===0?void 0:es.in(n,r)},ss=(e,t)=>ze.list(e,``,``,500,`saved:${t}`),cs=(e,t,n)=>{let r=ht(),i=J().resources[e];return nn({queryKey:ss(e,t),enabled:n&&i!==void 0,queryFn:async()=>{let n=[],a;do{let o=await r.list(e,{pageSize:500,fields:[...i.primaryKey,t],...a&&{pageToken:a}});n.push(...o.items),a=o.nextPageToken||void 0}while(a);return ns(i,t,n)}})},ls=G(`app/saved`),us=e=>e instanceof Error?e.message:ls(`somethingWrong`),ds=(e,t,n)=>{let r=J(),i=ht(),a=en(),o=_e(),s=zt(),{resource:c,field:l}=e,u=r.permissions[c],d=r.resources[c]!==void 0&&u!==void 0&&Vt(u,`create`)&&Vt(u,`delete`),f=r.signIn?.[c]?.signIn,p=cs(c,l,d),m=p.data&&rs(p.data,t),h=ss(c,l),g=tn({mutationFn:async e=>{e?await i.remove(c,e.key):await i.create(c,{[l]:n})},onMutate:async e=>{await a.cancelQueries({queryKey:h,exact:!0});let r=a.getQueryData(h);return a.setQueryData(h,(r=[])=>e?as(r,t):is(r,n)),{before:r}},onError:(e,t,n)=>{a.setQueryData(h,n?.before),o.show({state:`error`,title:ls(t?`couldNotTakeOff`:`couldNotSave`),description:us(e)})},onSettled:()=>s(c)});return{mode:d?`save`:f?`sign-in`:void 0,prompt:f,saved:m!==void 0,ready:p.data!==void 0&&!g.isPending,toggle:()=>g.mutate(m)}},fs=({favorite:e,recordKey:t,target:n,className:r})=>{let i=ds(e,t,n),[a,o]=(0,X.useState)(!1);if(!i.mode)return null;let s=e.label??ls(`favorite`),c=k(`absolute right-2 top-2 flex size-8 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/30`,r);return i.mode===`sign-in`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":s,"aria-haspopup":`dialog`,className:c,onClick:()=>o(!0),children:(0,Z.jsx)(Ht,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsx)(ee,{as:`dialog`,prompt:i.prompt,open:a,onClose:()=>o(!1)})]}):(0,Z.jsx)(`button`,{type:`button`,"aria-label":s,"aria-pressed":i.saved,"aria-disabled":!i.ready,className:c,onClick:()=>i.ready&&i.toggle(),children:(0,Z.jsx)(Ht,{className:k(`size-4`,i.saved&&`fill-current text-danger`),"aria-hidden":!0})})},ps=6,ms=(e,t,n)=>{let r=e.bottom+ps;return{top:r+t.height>n.height-ps?Math.max(ps,e.top-ps-t.height):r,left:Math.max(ps,Math.min(e.left,n.width-ps-t.width))}},hs=(e,t)=>{let n=wt(e).find(e=>e.kind===`cards`);if(!n)return{kind:`cards`,name:`dot`,badge:t};let{photos:r,favorite:i,dots:a,...o}=n;return o},gs=(e,t,n,r)=>(e?.list?.relatedColumns??[]).filter(e=>r.includes(e.name)).flatMap(e=>{let r=t[e.resource];return r?[{column:e,fields:yt(r,n[r.name],hs(n[r.name],e.status))}]:[]}),_s=G(`app/related-dots`),vs=(e,{values:t,label:n,singular:r,plural:i})=>{if(e.length===0)return _s(`none`,{plural:i});let a=new Map;for(let t of e)t!=null&&a.set(String(t),(a.get(String(t))??0)+1);let o=[...t,...[...a.keys()].filter(e=>!t.includes(e))].filter(e=>a.has(e)).map(e=>`${a.get(e)} ${n(e)}`),s=`${e.length} ${e.length===1?r:i}`;return o.length===0?s:`${s}: ${o.join(`, `)}`},ys=`flex shrink-0 items-center justify-center rounded-full p-0.5 pointer-coarse:p-1.5`,bs=`size-2.5 rounded-full`,xs=`flex min-w-0 items-center gap-0.5`,Ss=150,Cs=288,ws=({shown:e,row:t,target:n,view:r,column:i,Card:a,onEnter:o,onLeave:s})=>{let c=(0,X.useRef)(null),[l,u]=(0,X.useState)();return(0,X.useLayoutEffect)(()=>{c.current&&u(ms(e.dot,{width:Cs,height:c.current.offsetHeight},{width:window.innerWidth,height:window.innerHeight}))},[e]),(0,qn.createPortal)((0,Z.jsx)(`div`,{ref:c,"data-dot-card":!0,onMouseEnter:o,onMouseLeave:s,style:{width:Cs,...l??{visibility:`hidden`,top:0,left:0}},className:`fixed z-50 rounded-lg shadow-pop`,children:(0,Z.jsx)(a,{model:n,view:r,display:hs(r,i.status),row:t})}),document.body)},Ts=({column:e,records:t,target:n,view:r,wrap:i=!1,Card:a})=>{let o=(0,X.useMemo)(()=>t.map(e=>z(n,e)),[t,n]),[s,c]=(0,X.useState)(),l=(0,X.useRef)(void 0),u=(0,X.useRef)(`mouse`),d=(0,X.useRef)(null),f=n.fields[e.status],p=r?.fields[e.status],m=t=>f?ot(f,t.record[e.status],p):``,h=bt(n,r),g=e=>e.labels[h]??String(e.record[h]??e.key),_=(r?.names?.singular??K(n.name)).toLowerCase(),v=(r?.names?.plural??K(n.name)).toLowerCase(),y=vs(o.map(t=>t.record[e.status]),{values:f?.enumValues??[],label:e=>f?ot(f,e,p):e,singular:_,plural:v}),b=()=>window.clearTimeout(l.current),x=()=>{b(),l.current=window.setTimeout(()=>c(void 0),Ss)},S=(e,t)=>{b(),c({key:e,dot:t.getBoundingClientRect()})};(0,X.useEffect)(()=>b,[]),(0,X.useEffect)(()=>{if(!s)return;let e=()=>c(void 0),t=t=>t.key===`Escape`&&e(),n=t=>{let n=t.target;!d.current?.contains(n)&&!n?.closest?.(`[data-dot-card]`)&&e()};return document.addEventListener(`keydown`,t),document.addEventListener(`pointerdown`,n),document.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{document.removeEventListener(`keydown`,t),document.removeEventListener(`pointerdown`,n),document.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[s]);let C=e=>t=>{u.current===`touch`&&s?.key!==e&&(t.preventDefault(),S(e,t.currentTarget))},w=e=>{e.relatedTarget?.closest?.(`[data-dot-card]`)||x()},T=s&&o.find(e=>e.key===s.key);return(0,Z.jsxs)(`div`,{ref:d,className:k(xs,i&&`pointer-events-none flex-wrap`),onClick:e=>e.stopPropagation(),onPointerDown:e=>u.current=e.pointerType,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:y}),o.map(t=>{let r=t.record[e.status],i=Jt(p?.valueColors,r);return(0,Z.jsx)(se,{to:{kind:`record`,resource:n.name,key:t.key},"aria-label":`${g(t)}, ${m(t)}`,onPointerEnter:e=>e.pointerType!==`touch`&&S(t.key,e.currentTarget),onPointerLeave:e=>e.pointerType!==`touch`&&x(),onFocus:e=>e.currentTarget.matches(`:focus-visible`)&&S(t.key,e.currentTarget),onBlur:w,onClick:C(t.key),className:k(ys,`pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`),children:(0,Z.jsx)(`span`,{"aria-hidden":!0,style:i===void 0?void 0:{backgroundColor:i},className:k(bs,i===void 0&&be[Ye(p?.valueColors,r)],s?.key===t.key&&`ring-2 ring-foreground/30`)})},t.key)}),s&&T&&(0,Z.jsx)(ws,{shown:s,row:T,target:n,view:r,column:e,Card:a,onEnter:b,onLeave:x})]})},Es=({count:e})=>(0,Z.jsx)(`span`,{"aria-hidden":!0,className:k(xs,`invisible flex-wrap`),children:Array.from({length:e},(e,t)=>(0,Z.jsx)(`span`,{className:ys,children:(0,Z.jsx)(`span`,{className:bs})},t))}),Ds=`flex flex-col gap-1.5`,Os=({dots:e})=>(0,Z.jsx)(`span`,{className:Ds,children:e.map(({column:e,records:t})=>(0,Z.jsx)(Es,{count:t.length},e.name))}),ks=({dots:e,Card:t})=>{let{resources:n,views:r}=J();return(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-[calc(0.75rem+1px)] bottom-[calc(0.75rem+1px)] ${Ds}`,children:e.map(({column:e,records:i})=>{let a=n[e.resource];return a&&(0,Z.jsx)(Ts,{column:e,records:i,target:a,view:r[a.name],Card:t,wrap:!0},e.name)})})},As=(e,t,n)=>(t.dots??[]).flatMap(t=>{let r=e?.list?.relatedColumns?.find(e=>e.name===t),i=n.record[t];return r&&Array.isArray(i)&&i.length>0?[{column:r,records:i}]:[]}),js=({value:e})=>{let t=he(e,{width:320,height:240});return t?(0,Z.jsx)(j,{image:t,loading:`lazy`,className:`size-full object-cover`}):null},Ms=({children:e})=>(0,Z.jsx)(`span`,{className:`-mx-3 -mt-3 mb-1.5 block aspect-[4/3] overflow-hidden rounded-t-lg border-b border-border bg-muted`,children:e}),Ns=({value:e})=>(0,Z.jsx)(Ms,{children:(0,Z.jsx)(js,{value:e})}),Ps=10,Fs=(e,t)=>{let n=_(e)?e.uri:void 0,r=t.filter(e=>_(e)&&e.uri!==n);return(n===void 0?r:[e,...r]).slice(0,Ps)},Is=({photos:e,cover:t,swipe:n=!0,children:r})=>{let i=Fs(t,e),a=St(i.length),o=(0,Z.jsx)(Ms,{children:(0,Z.jsx)(te,{"data-card-photos":!0,carousel:a,swipe:n,slides:i.map(e=>(0,Z.jsx)(js,{value:e}))})});return(0,Z.jsxs)(Z.Fragment,{children:[r(o),(0,Z.jsx)(Re,{carousel:a,count:i.length,swipe:n,reveal:`group-has-[[data-card-photos]:hover]/card:opacity-100`,className:`inset-x-px top-px aspect-[4/3]`})]})},Ls=({icon:e,children:t})=>{let n=ce(e);return(0,Z.jsxs)(`dd`,{className:`flex items-center gap-1 tabular-nums`,children:[n&&(0,Z.jsx)(n,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t]})},Rs=({model:e,view:t,display:n,row:r,swipe:i=!0,mark:a})=>{let{image:o,title:s,subtitle:l,amount:u,badge:d,code:m,meta:h,footer:g,flags:_}=je(e,t,n),v=e=>t?.fields[e]?.label??K(e),{resources:y,views:b}=J(),x=n=>{let i=e.fields[n];if(!i)return``;let a=r.record[n],o=i.type===`relation`&&i.relation?y[i.relation.resource]:void 0;return o&&b[o.name]?.titleFrom&&a!=null?(0,Z.jsx)($o,{target:o,id:String(a)}):r.labels[n]===void 0&&Ee(i,t?.fields[n])&&typeof a==`string`&&a!==``?f(a):i.type===`json`&&a!=null?Rt(a):t?.fields[n]?.format===`url`&&typeof a==`string`&&a!==``?st(e,t,n,r.record)??a:r.labels[n]??ot(i,a,t?.fields[n])},{fields:S,components:C}=ut(),w=hn(e),T=n.card===void 0?void 0:C?.[n.card],E=n=>{let i=e.fields[n],a=i&&fe(S,i,t?.fields[n]);return a?(0,Z.jsx)(c,{shown:a,part:`display`,field:i,value:r.record[n],fallback:x(n)}):x(n)},ee=n=>{let i=e.fields[n],a=r.record[n];return!i||!Ee(i,t?.fields[n])||fe(S,i,t?.fields[n])||typeof a!=`string`||a===``?E(n):(0,Z.jsx)(p,{source:a,inLink:!0})},D=n=>{let i=e.fields[n],a=t?.fields[n],o=r.record[n];return!i||a?.format!==`badge`||fe(S,i,a)||o==null||o===``?E(n):(0,Z.jsx)(Wt,{value:o,hints:a,children:x(n)})},O=n=>{let i=e.fields[n];if(!i)return;if(r.labels[n]!==void 0||fe(S,i,t?.fields[n]))return(0,Z.jsx)(`strong`,{className:`font-semibold text-foreground`,children:E(n)});let a=M(i,r.record[n],t?.fields[n]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`strong`,{className:`font-semibold text-foreground`,children:a.amount}),a.suffix]})},k=T?void 0:n.photos,A=d===void 0?void 0:r.record[d],j=_.filter(e=>r.record[e]===!0),N=o===void 0?void 0:r.record[o],P=ne(r,u),te=Ve(r,m),F=Le(r,g),I=o!==void 0||k!==void 0,L=n.favorite,R=T?[]:As(t,n,r),z=(t,n)=>(0,Z.jsx)(se,{to:{kind:`record`,resource:e.name,key:r.key},onClick:()=>w(r.record),"data-card-link":!0,className:`${t} after:absolute after:inset-0 after:rounded-lg after:content-[''] focus-visible:outline-hidden`,children:n}),B=(n,i)=>(0,Z.jsxs)(Z.Fragment,{children:[I&&n,(0,Z.jsxs)(`span`,{className:`flex items-start justify-between gap-2 ${L&&!I?`pr-8`:``}`,children:[i?z(`min-w-0 truncate font-medium`,E(s)):(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:E(s)}),d!==void 0&&A!=null&&(0,Z.jsx)(Wt,{value:A,hints:t?.fields[d],children:x(d)})]}),l!==void 0&&(0,Z.jsx)(`span`,{className:t?.fields[l]?.markdown?`line-clamp-3 break-words text-muted-foreground`:t?.fields[l]?.multiline?`line-clamp-3 whitespace-pre-line break-words text-muted-foreground`:`truncate text-muted-foreground`,children:ee(l)}),P!==void 0&&(0,Z.jsx)(`span`,{className:`truncate tabular-nums text-muted-foreground`,children:O(P)}),te!==void 0&&(0,Z.jsx)(oe,{children:nt(e.fields[te],r.record[te])??x(te)}),h.length>0&&(0,Z.jsx)(`dl`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-0.5 pt-1 text-xs text-muted-foreground`,children:Le(r,h).map(e=>(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Z.jsx)(`dt`,{className:`sr-only`,children:v(e)}),(0,Z.jsx)(Ls,{icon:t?.fields[e]?.icon,children:D(e)})]},e))}),j.length>0&&(0,Z.jsx)(`ul`,{className:`flex flex-wrap gap-1`,"aria-label":Y(`features`),children:j.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(He,{dot:!1,children:v(e)})},e))}),F.length>0&&(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground ${h.length>0?``:`mt-auto`}`,children:F.map((e,t)=>(0,Z.jsxs)(`span`,{children:[t>0&&(0,Z.jsx)(`span`,{"aria-hidden":!0,children:` • `}),E(e)]},e))}),R.length>0&&(0,Z.jsx)(Os,{dots:R})]}),V=e=>(0,Z.jsxs)(`div`,{className:`relative isolate flex h-full flex-col gap-1.5 rounded-lg border border-border bg-background p-3 hover:border-border-strong hover:bg-surface has-[[data-card-link]:focus-visible]:ring-2 has-[[data-card-link]:focus-visible]:ring-primary/30`,children:[a&&!I&&(0,Z.jsx)(He,{tone:`blue`,className:`self-start`,children:a}),T?(0,Z.jsxs)(Z.Fragment,{children:[z(`absolute inset-0`,(0,Z.jsx)(`span`,{className:`sr-only`,children:E(s)})),(0,Z.jsx)(Oe,{name:n.card,fallback:B(e,!1),children:(0,Z.jsx)(T,{row:r})})]}):B(e,!0)]});return(0,Z.jsxs)(`div`,{className:k?`group/card relative h-full`:L||a||R.length>0?`relative h-full`:`h-full`,children:[k?(0,Z.jsx)(Is,{photos:r.photos??[],cover:N,swipe:i,children:t=>V((0,Z.jsx)(se,{to:{kind:`record`,resource:e.name,key:r.key},onClick:()=>w(r.record),tabIndex:-1,"aria-hidden":!0,className:`relative z-[1] block`,children:t}))},r.key):V((0,Z.jsx)(Ns,{value:N})),a&&I&&(0,Z.jsx)(He,{tone:`blue`,className:`pointer-events-none absolute top-2 left-2 shadow-sm`,children:a}),R.length>0&&(0,Z.jsx)(ks,{dots:R,Card:Rs}),L&&(0,Z.jsx)(fs,{favorite:L,recordKey:r.key,target:Gt(e,r.record),className:I?void 0:`right-1.5 top-1.5`})]})},zs=12,Bs=3,Vs=(e,t,n)=>{let r=Math.max(1,Math.min(256,t))+zs,i=Math.floor(Math.max(0,e)/r),a=Math.ceil((Math.max(0,e)+t)/r);return{start:Math.max(0,i-Bs),end:Math.min(n,a+Bs)}},Hs=50,Us=(e,t,n)=>({from:Math.max(0,e-Hs),to:Math.min(n,t+Hs)}),Ws=e=>`calc(${e} * (min(256px, 100%) + ${ui}) - ${ui})`,Gs=G(`app/record-row`),Ks=({count:e})=>(0,Z.jsx)(`li`,{"aria-hidden":!0,style:{width:Ws(e),minWidth:0,scrollSnapAlign:`none`}}),qs=({model:e,view:t,display:n,source:r,label:i,isNew:a})=>{let{total:o}=r,s=e=>Vs(e.left,e.width,o),c=_i(e=>{let{start:t,end:n}=s(e);return`${t}-${n}`}),{start:l,end:u}=s(c.view),d=Us(l,u,o),f=pn({total:o,rowAt:r.rowAt,loadRows:r.loadRows,cachedRows:r.cachedRows,revision:r.revision,latencyMs:0},l,Math.max(l,u-1));return(0,Z.jsxs)(mi,{scroll:c,label:i,children:[d.from>0&&(0,Z.jsx)(Ks,{count:d.from}),Array.from({length:d.to-d.from},(r,i)=>{let s=d.from+i;if(s<l||s>=u)return(0,Z.jsx)(`li`,{"aria-hidden":!0},`place-${s}`);let c=f(s);if(!c)return(0,Z.jsx)(`li`,{"aria-hidden":!0,children:(0,Z.jsx)(q,{className:`h-full min-h-24 rounded-lg`})},`skeleton-${s}`);let p=z(e,c);return(0,Z.jsx)(`li`,{"aria-posinset":s+1,"aria-setsize":o,className:`grid grid-cols-[minmax(0,1fr)]`,children:(0,Z.jsx)(Rs,{model:e,view:t,display:n,row:p,swipe:!1,mark:a?.(p)?Gs(`new`):void 0})},p.key)}),d.to<o&&(0,Z.jsx)(Ks,{count:o-d.to})]})},Js=Ne(),Ys=(e,t)=>{if(!t)return e;let n=Ie(e);if(!n.ok)throw Error(`The filter cannot be read: ${n.errors.map(e=>e.message).join(`; `)}`);return L(n.ast?Js.and(n.ast,t):t)},Xs=(e,t,{filter:n,sort:r,scope:i})=>({columns:xe(e,t,[]),filter:Ys(n,i),orderBy:r||Ue(e,t)}),Zs=(e,t)=>{let n=wt(e).filter(e=>e.kind===`cards`);return n.find(e=>e.name===t)??n[0]??{kind:`cards`,name:`cards`}},Qs=()=>(0,Z.jsx)(`div`,{className:`flex gap-3 overflow-hidden`,children:Array.from({length:3},(e,t)=>(0,Z.jsx)(q,{className:`h-24 w-64 shrink-0`},t))}),$s=({model:e,view:t,filter:n,sort:r=``,display:a,limit:o,chips:s=!0,empty:c,note:l,isNew:d,viewAll:f,scope:p,list:m})=>{let{resources:h,views:g}=J(),_=u(),v=Zs(t,a),y=(0,X.useMemo)(()=>Xs(e,t,{filter:n,sort:r,scope:p}),[e,t,n,r,p]),{orderBy:b}=y,x=mn({resources:h,views:g,model:e,...y}),S=Qo(e,n),C=(t?.names?.singular??K(e.name)).toLowerCase(),w=t?.names?.plural??K(e.name),T=x.source?.total,E=(0,X.useMemo)(()=>x.source&&{...x.source,total:Math.min(x.source.total,o??1/0)},[x.source,o]);return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[s&&S.length>0||T!==void 0||l?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[s&&S.length>0?(0,Z.jsx)(ro,{chips:S}):(0,Z.jsx)(`span`,{}),(0,Z.jsxs)(`p`,{className:`flex flex-wrap gap-x-3 text-muted-foreground`,children:[l&&(0,Z.jsx)(`span`,{children:l}),T!==void 0&&(0,Z.jsx)(`span`,{className:`tabular-nums`,children:`${T.toLocaleString(i())} ${T===1?C:w.toLowerCase()}`})]})]}):null,x.isLoading?(0,Z.jsx)(Qs,{}):x.error?(0,Z.jsx)(_t,{title:Gs(`couldNotLoad`),error:x.error}):!E||E.total===0?(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:c??Gs(`noneMatch`,{plural:w.toLowerCase()})}):(0,Z.jsx)(qs,{model:e,view:t,display:v,source:E,label:w,isNew:d}),(0,Z.jsxs)(se,{to:Ti(e,t,_,{filter:n,orderBy:b,display:v.name,savedSearch:f?.savedSearch,resource:m}),onClick:f?.onOpen,className:`flex items-center gap-1 self-end font-medium text-primary-text hover:underline`,children:[f?.label??(0,Z.jsxs)(Z.Fragment,{children:[Gs(`viewAll`),` `,(0,Z.jsx)(`span`,{className:`sr-only`,children:w.toLowerCase()})]}),(0,Z.jsx)(An,{className:`size-3.5`,"aria-hidden":!0})]})]})},ec=e=>ze.list(e,``,``,500,`saved-searches`),tc=(e,t)=>{let n=ht(),{resources:r,views:i}=J(),a=r[e];return nn({queryKey:ec(e),enabled:t&&a!==void 0,queryFn:async()=>{let t=[],r;do{let o=await n.list(e,{pageSize:500,orderBy:Ue(a,i[e]),...r&&{pageToken:r}});t.push(...o.items),r=o.nextPageToken||void 0}while(r);return t}})},nc=({model:e,of:t,target:n,targetView:r,row:i,recordKey:a})=>{let o=ht(),s=zt(),c=String(i[t.filter]??``),l=Qo(n,c),u=t.name===void 0?void 0:i[t.name],d=typeof u==`string`&&u!==``?u:void 0,f=t.unseen,p=tn({mutationFn:t=>o.update(e.name,a,{[f.seenAt]:t},i.etag??`*`),onSettled:()=>s(e.name)}),m=nn({...Ft(o,n,f?Xo(c,f.field,i[f.seenAt]):``),enabled:f!==void 0}),h=(r?.names?.plural??K(n.name)).toLowerCase(),g={model:n,view:r,filter:c,sort:f?`${f.field} desc`:void 0,limit:t.limit,chips:d!==void 0,empty:to(`noneMatch`,{plural:h}),note:f&&m.data===0&&to(`noNew`,{plural:h}),isNew:f&&(e=>Zo(e.record[f.field],i[f.seenAt])),viewAll:{label:to(`viewAll`),savedSearch:a,...f&&{onOpen:()=>p.mutate(new Date().toISOString())}}};return{name:d,chips:l,title:d??ao(l),body:g}},rc=({list:e,empty:t,loading:n,children:r})=>(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.loading?n:e.error?(0,Z.jsx)(_t,{title:Y(`couldNotLoadRows`),error:e.error}):e.rows.length===0?(0,Z.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:t}):r}),ic=({list:e})=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-3 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[e.rows.length.toLocaleString(i()),` of `,e.total.toLocaleString(i())]}),e.more&&(0,Z.jsx)(Ot,{size:`sm`,onClick:e.loadMore,children:Y(`showMore`)})]}),ac=`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,oc=`relative flex snap-x snap-mandatory gap-3 overflow-x-auto pb-1`,sc=({model:e,view:t,display:n,list:r,row:i=!1,footer:a=!0})=>{let o=(t?.names?.plural??K(e.name)).toLowerCase();return(0,Z.jsxs)(rc,{list:r,empty:Y(`noneMatch`,{plural:o}),loading:(0,Z.jsx)(`div`,{className:ac,children:Array.from({length:6},(e,t)=>(0,Z.jsx)(q,{className:`h-24`},t))}),children:[(0,Z.jsx)(`ul`,{className:i?oc:ac,"aria-label":t?.names?.plural??K(e.name),children:r.rows.map(r=>(0,Z.jsx)(`li`,{className:k(i&&`w-64 shrink-0 snap-start`),children:(0,Z.jsx)(Rs,{model:e,view:t,display:n,row:r,swipe:!i})},r.key))}),a&&(0,Z.jsx)(ic,{list:r})]})},cc=({display:e,list:t})=>{let{components:n}=ut(),r=n?.[e.component];return r?(0,Z.jsx)(V,{value:t,children:(0,Z.jsx)(`div`,{className:`relative min-w-0 flex-1 overflow-x-auto`,children:(0,Z.jsx)(Oe,{name:e.component,children:(0,Z.jsx)(r,{...ge(e.props??{})})})})}):(0,Z.jsx)(D,{children:Y.rich(`noComponent`,{component:e.component})})},lc=Ne(),uc={bounds:{south:-90,west:-180,north:90,east:180},zoom:0},dc=22,fc=e=>Math.floor(e*1e6)/1e6,pc=e=>Math.ceil(e*1e6)/1e6,mc=e=>((e+180)%360+360)%360-180,hc=(e,t)=>{let n=[lc.gte(e.latitude,fc(Math.max(t.south,-90))),lc.lte(e.latitude,pc(Math.min(t.north,90)))];if(t.east-t.west>=360)return lc.and(...n);let r=lc.gte(e.longitude,fc(mc(t.west))),i=lc.lte(e.longitude,pc(mc(t.east)));return mc(t.west)<=mc(t.east)?lc.and(...n,r,i):lc.and(...n,lc.or(r,i))},gc=(e,t,n)=>{let r=L(hc(t,n));return e.trim()===``?r:`(${e}) AND ${r}`},_c=e=>Math.min(Math.max(Math.floor(e),0),dc),vc=(e,t)=>{let n=[...e.map(e=>({south:e.latitude,west:e.longitude,north:e.latitude,east:e.longitude})),...t.map(e=>e.bounds)];if(n.length!==0)return{south:Math.min(...n.map(e=>e.south)),west:Math.min(...n.map(e=>e.west)),north:Math.max(...n.map(e=>e.north)),east:Math.max(...n.map(e=>e.east))}},yc=e=>{if(typeof e==`number`)return e;if(typeof e==`string`&&e.trim()!==``)return Number(e)},bc=(e,t)=>{let n=yc(e[t.latitude]),r=yc(e[t.longitude]);if(n!==void 0&&r!==void 0&&Math.abs(n)<=90&&Math.abs(r)<=180)return{latitude:n,longitude:r}},xc=6371008.8,Sc=64,Cc=(e,t)=>t.approximate===void 0?t.exact!==void 0&&e[t.exact]===!1:e[t.approximate]===!0,wc=(e,t)=>{let n=t/xc,r=e.latitude*Math.PI/180,i=e.longitude*Math.PI/180;return{type:`Polygon`,coordinates:[Array.from({length:65},(e,t)=>{let a=t%Sc/Sc*2*Math.PI,o=Math.asin(Math.sin(r)*Math.cos(n)+Math.cos(r)*Math.sin(n)*Math.cos(a));return[(i+Math.atan2(Math.sin(a)*Math.sin(n)*Math.cos(r),Math.cos(n)-Math.sin(r)*Math.sin(o)))*180/Math.PI,o*180/Math.PI]})]}},Tc=e=>Array.isArray(e)&&e.length>=2&&typeof e[0]==`number`&&typeof e[1]==`number`&&Math.abs(e[0])<=180&&Math.abs(e[1])<=90,Ec=(e,t)=>Array.isArray(e)&&e.length>=t&&e.every(Tc),Dc=e=>Array.isArray(e)&&e.length>0&&e.every(e=>Ec(e,4)),Oc=e=>Array.isArray(e)&&e.length>0&&e.every(e=>Ec(e,2)),kc=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch(e){if(e instanceof SyntaxError)return;throw e}},Ac=e=>{let t=kc(e);if(typeof t!=`object`||!t)return;let n=t.type===`Feature`?t.geometry:t;if(typeof n!=`object`||!n)return;let{type:r,coordinates:i}=n;if(r===`Polygon`&&Dc(i)||r===`MultiPolygon`&&Array.isArray(i)&&i.length>0&&i.every(Dc)||r===`LineString`&&Ec(i,2)||r===`MultiLineString`&&Oc(i))return{type:r,coordinates:i}},jc=(e,t,n)=>{if(!Cc(e,t))return;let r=t.area===void 0?void 0:Ac(e[t.area]);if(r)return r;let i=t.radius===void 0?void 0:yc(e[t.radius]);return i!==void 0&&Number.isFinite(i)&&i>0?wc(n,i):t.defaultRadius===void 0?void 0:wc(n,t.defaultRadius)},Mc=(e,t)=>e.flatMap(e=>{let n=bc(e.record,t);if(!n)return[];if(!Cc(e.record,t))return[{key:e.key,...n}];let r=jc(e.record,t,n);return[{key:e.key,...n,approximate:!0,...r&&{area:r}}]}),Nc=(e,t)=>{let n=[];for(let r of e){let e=n.find(e=>Math.hypot(e.at.x-r.x,e.at.y-r.y)<=t);e?e.keys.push(r.key):n.push({at:r,keys:[r.key]})}return n.map(e=>({keys:e.keys,at:e.at.key}))},Pc=(e,t)=>{if(!e)return;let n=new Set(t.map(e=>e.key)),r=e.keys.filter(e=>n.has(e));if(r.length===0)return;let i=r.indexOf(e.keys[e.index]);return{keys:r,index:Math.max(i,0)}},Fc=(e,t)=>({keys:e.keys,index:((e.index+t)%e.keys.length+e.keys.length)%e.keys.length}),Ic=({model:e,view:t,display:n,fields:r,filter:i,orderBy:a,area:o})=>{let s=ht(),{resources:c,views:l}=J(),u={latitude:n.latitude,longitude:n.longitude},d=o?gc(i,u,o.bounds):``,f=o?_c(o.zoom):0;return nn({queryKey:ze.map(e.name,`${u.latitude},${u.longitude}`,f,d,a),enabled:o!==void 0,placeholderData:$t,queryFn:async()=>{let n=await s.map(e.name,{...u,zoom:f,filter:d,orderBy:a,labels:I(c,l,e,r),photos:it(t)});return{rows:Be(c,e,r,xt(e,n.items,n.photos),n.labels).map(t=>z(e,t)),buckets:n.buckets,total:n.totalSize}}})},Lc=(0,X.lazy)(()=>Qt(()=>import(`./records-map-G0QXqaUR.js`).then(e=>({default:e.RecordsMap})),__vite__mapDeps([33,1,2,3,4,5,34,35,36,37,38,39]))),Rc=250,zc=`flex size-8 items-center justify-center rounded-full border border-border bg-background hover:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,Bc=({model:e,view:t,display:n,filter:r,orderBy:a,fields:s,at:c,onMove:l,footer:u=!0,flush:d=!1})=>{let f=J().maps,p=f?.style,[m,h]=(0,X.useState)(),[g,_]=(0,X.useState)(),v=ie(g,Rc),[y,b]=(0,X.useState)(c===void 0),x=Ic({model:e,view:t,display:n,fields:s,filter:r,orderBy:a,area:y?uc:v}),S=x.isPlaceholderData?void 0:x.data,C=x.data?.rows??[],w=x.data?.buckets??[],T=Mc(C,n),E=y&&S?vc(Mc(S.rows,n),S.buckets):void 0,ee=o(t,n),O=(t?.names?.plural??K(e.name)).toLowerCase(),A=(t?.names?.singular??K(e.name)).toLowerCase(),j=Pc(m,C),M=j&&C.find(e=>e.key===j.keys[j.index]),N=new Set(T.filter(e=>e.approximate).map(e=>e.key)),P=e=>{let t=e.filter(e=>N.has(e)).length;return e.length===1?Y(t===1?`showOneApproximate`:`showOne`,{singular:A}):t===0?Y(`showMany`,{count:e.length,plural:O}):t===e.length?Y(`showManyApproximate`,{count:e.length,plural:O}):Y(`showManySomeApproximate`,{count:e.length,plural:O,near:t})},te=e=>Y(`zoomIn`,{count:e.toLocaleString(i()),noun:e===1?A:O}),F=(0,X.useRef)(null),[I,ne]=(0,X.useState)(0);if((0,X.useLayoutEffect)(()=>ne(F.current?.offsetHeight??0),[M?.key]),!p)return(0,Z.jsx)(D,{children:Y(`needsStyle`)});let L=S?.total===0;return(0,Z.jsxs)(`div`,{className:k(`flex h-full min-h-[36rem] flex-1 flex-col sm:min-h-[28rem]`,d&&`max-md:-mx-5 max-md:-mb-4 max-md:min-h-0`),children:[(0,Z.jsxs)(`div`,{className:k(`relative min-h-0 flex-1 overflow-hidden rounded-lg border border-border bg-muted`,d&&`max-md:rounded-none max-md:border-0`),children:[(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Lc,{style:p,layers:f?.layers,initial:c,points:T,buckets:w,fit:E,onFitted:()=>b(!1),onMove:(e,t)=>{_(e),l?.(t)},selected:j?.keys,covered:j?I:0,onSelect:e=>h({keys:e,index:0}),onClear:()=>h(void 0),markerLabel:P,bucketLabel:te})}),x.error&&(0,Z.jsx)(`div`,{className:`absolute inset-x-3 top-3 z-10`,children:(0,Z.jsx)(_t,{title:Y(`couldNotLoadRows`),error:x.error})}),L&&(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-10 flex justify-center`,children:(0,Z.jsxs)(`p`,{className:`pointer-events-auto flex items-center gap-3 rounded-full border border-border bg-background px-4 py-1.5 text-muted-foreground shadow`,role:`status`,children:[Y(y?`noneMatch`:`noneHere`,{plural:O}),!y&&(0,Z.jsx)(Ot,{size:`sm`,onClick:()=>b(!0),children:Y(`showAll`)})]})}),j&&M&&(0,Z.jsx)(`div`,{ref:F,className:`pointer-events-none absolute inset-x-3 bottom-3 z-10 flex justify-center`,children:(0,Z.jsxs)(`div`,{className:`pointer-events-auto flex w-full max-w-[16rem] flex-col gap-2 sm:max-w-xs`,role:`group`,"aria-label":Y(`chosen`,{singular:A}),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[N.has(M.key)&&(0,Z.jsxs)(`span`,{className:`mr-auto flex items-center gap-1 rounded-full border border-border bg-background px-2 py-1 text-xs`,children:[(0,Z.jsx)(In,{className:`size-3.5`,"aria-hidden":!0}),Y(`approximatePosition`)]}),j.keys.length>1&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":Y(`previous`),className:zc,onClick:()=>h(Fc(j,-1)),children:(0,Z.jsx)(ve,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsxs)(`span`,{className:`rounded-full border border-border bg-background px-2 py-1 text-xs tabular-nums`,"aria-live":`polite`,children:[j.index+1,` / `,j.keys.length]}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":Y(`next`),className:zc,onClick:()=>h(Fc(j,1)),children:(0,Z.jsx)(pe,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":Y(`close`),className:zc,onClick:()=>h(void 0),children:(0,Z.jsx)(et,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsx)(`div`,{className:`shadow-lg`,children:(0,Z.jsx)(Rs,{model:e,view:t,display:ee,row:M})})]})})]}),u&&(0,Z.jsx)(`p`,{className:`hidden py-3 text-xs text-muted-foreground md:block`,children:Vc(x.data,O)})]})},Vc=(e,t)=>{if(!e)return`\xA0`;let n=e.total.toLocaleString(i());return e.buckets.length===0&&e.rows.length<e.total?`${e.rows.length.toLocaleString(i())} of ${n} ${t} in view`:`${n} ${t} in view`},Hc=()=>(0,Z.jsx)(q,{className:`min-h-60 flex-1 rounded-lg`}),Uc=w(()=>Qt(()=>import(`./board-display-ClTe26F0.js`).then(e=>e.BoardDisplay),__vite__mapDeps([40,1,2,3,4,5,41,42,43,44,45,46,47,48])),Hc),Wc=w(()=>Qt(()=>import(`./calendar-display-CwBcu_JO.js`).then(e=>e.CalendarDisplay),__vite__mapDeps([49,1,2,3,4,5,42,43,44,47,50,41,48])),Hc),Gc=w(()=>Qt(()=>import(`./timeline-display-CJHQiDm9.js`).then(e=>e.TimelineDisplay),__vite__mapDeps([51,1,2,3,4,5,42,43,44,50,41,48])),Hc),Kc={table:gt,cards:sn,kanban:Kn,board:Rn,list:Hn,calendar:re,timeline:Pn,map:Wn},qc=({view:e,value:t,onChange:n,menu:r=!1,choices:i=O(e)})=>{if(i.length<2)return null;let a=i.map(e=>({value:e.name,label:e.label,icon:e.icon===void 0?void 0:Kc[e.icon]}));return r?(0,Z.jsx)(l,{label:Y(`display`),value:t,onChange:n,options:a}):(0,Z.jsx)(Xe,{label:Y(`display`),size:`md`,value:t,onChange:n,options:a})},Jc=[[`asc`,`ascending`],[`desc`,`descending`]],Yc=({model:e,view:t,display:n,orderBy:r,onChange:i,className:a})=>{let o=Lt(r),s=ct(e,t,n),c=s.includes(o.columnId)?s:[o.columnId,...s],l=e=>t?.fields[e]?.label??K(e);return(0,Z.jsx)(`select`,{"aria-label":Y(`sort`),value:`${o.columnId} ${o.direction}`,onChange:e=>i(e.target.value),className:k(`h-8 rounded-md border border-border-strong bg-background px-2.5 shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20`,a),children:c.flatMap(e=>Jc.map(([t,n])=>(0,Z.jsxs)(`option`,{value:`${e} ${t}`,children:[l(e),`, `,Y(n)]},`${e} ${t}`)))})},Xc=8,Zc=22,Qc=20,$c={wide:288,narrow:192},el=(e,t)=>z(e,t).record,tl=(e,t,n,r)=>i=>(0,Z.jsx)(Mi,{button:n,model:e,view:t,record:el(e,i),models:r}),nl=(e,t,n,r)=>i=>{let a=ji(n,e,t,el(e,i),r);return a?Math.ceil(a.label.length*Xc)+Zc+(`href`in a?Qc:0)+24:0},rl=(e,t,n,r,i)=>({id:`_row_button`,header:``,kind:`text`,width:152,minWidth:96,maxWidth:i,sortable:!1,render:tl(e,t,n,r),fit:nl(e,t,n,r)}),il=(e,t,n,r,i,a)=>{if(!a)return[...e,rl(t,n,r,i,$c.wide)];let[o,...s]=e;return o?[{...o,below:tl(t,n,r,i)},...s]:[rl(t,n,r,i,$c.narrow)]},al=(e,t,n)=>{let r=Object.hasOwn(e.fields,t)?e.fields[t]:void 0;return r?.type===`relation`&&r.relation!==void 0&&n[r.relation.resource]?.primaryKey.length===1},ol=(e,t,n)=>{if(e.open!==void 0)return e.open!==e.field&&al(t,e.open,n)?e.open:void 0;let r=t.primaryKey.filter(r=>r!==e.field&&r!==t.tenant&&al(t,r,n));return r.length===1?r[0]:void 0},sl=(e,t)=>{let n=e[t],r=typeof n==`object`&&n&&`id`in n?n.id:n;return typeof r==`string`||typeof r==`number`?r:void 0},cl=(e,t)=>(t?.names?.singular??K(e.name)).toLowerCase(),ll=({model:e,view:t,opens:n,resources:r,views:i,canUpdate:a})=>{let o=t=>({kind:`record`,resource:e.name,key:Gt(e,t)}),s=n&&e.fields[n]?.relation?.resource,c=s?r[s]:void 0,l=e=>{let t=n&&c?sl(e,n):void 0;return c&&t!==void 0?{kind:`record`,resource:c.name,key:t}:void 0},u=e=>l(e)??o(e),d=cl(e,t);return{address:u,actions:t=>{let n={label:vi(`open`,{singular:d}),link:e=>t(o(e))};if(!c)return[n];let r=e=>a&&b(e,`update`);return[{label:vi(`open`,{singular:cl(c,i[c.name])}),available:e=>l(e)!==void 0,link:e=>t(l(e))},{label:vi(`edit`,{singular:d}),available:r,link:n=>t({kind:`record`,resource:e.name,key:Gt(e,n),edit:!0})},{...n,available:e=>!r(e)}]}}},ul=(e,t,{href:n,go:r})=>{if(`to`in e){let i=me(e.to,t);return{href:n(i),onFollow:()=>r(i)}}let i=Nr(e.href,t);if(i===void 0)throw Error(`A link action without a target on the record is not shown`);return{href:i,newTab:/^https?:/i.test(i)}},dl=(e,t)=>({model:e,record:Object.fromEntries(Object.entries(z(e,t).record).filter(([t])=>Object.hasOwn(e.fields,t))),key:t.id,...typeof t.etag==`string`&&{etag:t.etag},...typeof t.permissions==`object`&&t.permissions!==null&&{permissions:t.permissions}}),fl=e=>{let{views:t,resources:n}=J(),r=Vr(e.name,void 0),i=Te(),a=Ce(),[o,s]=(0,X.useState)(),c=t[e.name]?.actions??[],l=c.filter(e=>!e.inputs?.length),u=async(e,t)=>`row`in e?(await r.run(e.action,e.row),[]):(await r.runEach(e.action,e.selection,e.skipped,t)).refused,d=e=>new Promise(t=>{e.action.confirm||e.action.inputs?.length?s({...e,settle:t}):t(u(e))});return{rowActions:l.map(t=>{let a=r=>Lr(t,dl(e,r).record,n),o={label:e=>a(e)?.label??t.label,destructive:Er(t)},s=t.run,c=n=>r.blockedOn(t,dl(e,n)),l=e=>a(e)!==void 0;return s?.kind===`link`?{...o,available:l,blocked:c,link:t=>ul(s,dl(e,t).record,i)}:{...o,available:l,blocked:c,onSelect:n=>void d({action:t,row:dl(e,n)})}}),bulkActions:c.filter(e=>e.bulk&&e.run?.kind!==`link`).map(t=>({label:e=>Ur(`actionCount`,{label:t.label,count:e}),destructive:Er(t),available:n=>r.verdictOn(t,dl(e,n))!==`skip`,onRun:async(n,r)=>{let i=n.map(t=>dl(e,t)),a=await d({action:t,selection:i,skipped:r});return n.filter((e,t)=>a.includes(i[t]))}})),prompt:o&&(0,Z.jsx)(Or,{action:o.action,label:`row`in o?o.action.label:Ur(`actionCount`,{label:o.action.label,count:o.selection.length}),danger:Er(o.action),records:`row`in o?[o.row.record]:o.selection.map(e=>e.record),names:`row`in o?[]:o.selection.map(n=>zr(a(e,t[e.name],n.record,n.key))),onCancel:()=>{s(void 0),o.settle(`row`in o?[o.row]:o.selection)},onConfirm:()=>{s(void 0),o.settle(u(o))},onSubmit:async e=>{s(void 0);let t=u(o,e);o.settle(t),await t}})}},pl=({client:e,queryClient:t,resources:n,views:r},{model:i,filter:a,orderBy:o,limit:s,fields:c,read:l})=>({queryKey:[...ze.list(i.name,a,o,s,`embedded`),c.join(`,`),l?.join(`,`)??`*`],queryFn:async()=>{let u=I(n,r,i,c),d=it(r[i.name]),f=await e.search(i.name,{filter:a||void 0,orderBy:o||void 0,pageSize:s,count:`exact`,labels:u,photos:d,fields:l});await R(t,e,n,r,i,c,f.items);let p=Be(n,i,c,xt(i,f.items,f.photos),f.labels).map((e,t)=>({...e,id:Je(i,f.items[t])}));return f.nextPageToken===``?{rows:p,total:p.length,estimated:!1}:{rows:p,total:f.totalSize??f.totalSizeEstimate,estimated:f.totalSize===void 0}}}),ml=(e,t=!0)=>{let{resources:n,views:r}=J();return nn({...pl({client:ht(),queryClient:en(),resources:n,views:r},e),placeholderData:$t,enabled:t})},hl=(e,t,n,{rows:r,total:i})=>{let a=r.isPending||!!i?.isPending,o=r.error??i?.error??null;if(a||o)return{isPending:a,error:o,data:void 0};let s=Be(e,t,n,xt(t,r.rows,r.photos),r.labels).map((e,n)=>({...e,id:Je(t,r.rows[n])}));return{isPending:a,error:o,data:{rows:s,total:i?Ei(i):s.length,estimated:!1}}},gl=({view:e,value:t,onChange:n})=>(0,Z.jsx)(qc,{view:e,value:t,onChange:n,menu:!Xt()}),_l=()=>(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Z.jsx)(q,{className:`h-4 w-full`},t))}),vl=({model:e,view:t,filter:n,sort:r,columns:i,limit:a,display:o,empty:s,row:c=!1,viewAll:l,link:d=!0,opens:f,button:p,bulk:m=!1,phoneColumns:h,rowTo:g,chosenKey:_,planned:v})=>{let{resources:y,views:b}=J(),x=Vt(Tt(e.name),`update`),{fields:S}=ut(),{go:C,href:w}=Te(),T=u(),E=!Xt(),ee=r||Ue(e,t),[D,O]=(0,X.useState)(ee),{specs:k,fields:A,read:j}=(0,X.useMemo)(()=>Ke({model:e,view:t,resources:y,views:b,fieldTypes:S,columns:i,button:p,opens:f,bulk:m,phoneColumns:h,xs:T}),[e,t,y,b,S,i?.join(`,`),p,f,m,h,T]),M=(0,X.useMemo)(()=>p?il(k,e,t,p,y,E):k,[k,e,t,p,y,E]),N=v!==void 0&&D===ee,P=ml({model:e,filter:n,orderBy:D,limit:a,fields:A,read:j},!N),te=(0,X.useMemo)(()=>v&&hl(y,e,A,v),[v,y,e,A]),F=N?te:P,I=fl(e),ne=F.data?.rows,L=(0,X.useMemo)(()=>ne&&{total:ne.length,rowAt:e=>ne[e]},[ne]),R=jt(t,o),B=t?.names?.plural??K(e.name),V=d&&(0,Z.jsxs)(se,{to:Ti(e,t,T,l?{filter:l.filter,orderBy:Ue(e,t),display:o,savedSearch:l.savedSearch}:{filter:n,orderBy:D,display:o}),onClick:l?.onOpen,className:`flex items-center gap-1 self-end font-medium text-primary-text hover:underline`,children:[l?l.label:(0,Z.jsxs)(Z.Fragment,{children:[vi(`viewAll`),` `,(0,Z.jsx)(`span`,{className:`sr-only`,children:B.toLowerCase()})]}),(0,Z.jsx)(An,{className:`size-3.5`,"aria-hidden":!0})]}),re=e=>(0,Z.jsxs)(Z.Fragment,{children:[e,I.prompt]});if(F.isPending)return re((0,Z.jsx)(_l,{}));if(F.error)return re((0,Z.jsx)(_t,{title:vi(`couldNotLoad`),error:F.error}));let ie=F.data;if(!ie||!L||L.total===0){let e=(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:s??vi(`nothingYet`)});return re(l&&d?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,V]}):e)}let ae={resource:e.name,rows:ie.rows.map(t=>z(e,t)),total:ie.total,loading:!1,error:null,more:!1,loadMore:()=>void 0},oe=ll({model:e,view:t,opens:f,resources:y,views:b,canUpdate:x}),ce=e=>({href:w(e),onFollow:()=>C(e)}),le=t=>at(Gt(e,t)),ue=e=>g?g(le(e)):ce(oe.address(e)),de=_===void 0?void 0:ie.rows.find(e=>le(e)===_)?.id,fe=yi(L.total,ie.total,ie.estimated);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[R?R.kind===`cards`?(0,Z.jsx)(sc,{model:e,view:t,display:R,list:ae,row:c||T,footer:!1}):R.kind===`map`?(0,Z.jsx)(Bc,{model:e,view:t,display:R,filter:n,orderBy:D,fields:A,footer:!1}):R.kind===`board`?(0,Z.jsx)(Uc,{model:e,view:t,display:R,fields:A,filter:n,orderBy:D,limit:a}):R.kind===`calendar`?(0,Z.jsx)(Wc,{model:e,view:t,display:R,fields:A,filter:n}):R.kind===`timeline`?(0,Z.jsx)(Gc,{model:e,view:t,display:R,fields:A,filter:n}):(0,Z.jsx)(cc,{display:R,list:ae}):(0,Z.jsx)(eo,{fit:!0,columns:M,source:L,latencyMs:0,sort:Lt(D),onSortChange:e=>O(qt(e)),onOpenRow:e=>ue(e).onFollow?.(),rowLink:ue,chosenRow:de,rowActions:oe.actions(ce),rowNumbers:!1,selectable:m,...m&&{bulkActions:I.bulkActions}}),I.prompt,fe&&d?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:fe}),V]}):V]})};export{Ka as $,Qo as A,Bn as At,ho as B,Gs as C,Vr as Ct,ls as D,Er as Dt,gs as E,Dr as Et,Vo as F,po as G,_o as H,ko as I,oo as J,lo as K,Fo as L,Jo as M,An as Mt,Uo as N,On as Nt,cs as O,Qn as Ot,Ho as P,eo as Q,go as R,Xs as S,zr as St,Ts as T,Or as Tt,mo as U,vo as V,fo as W,io as X,ro as Y,to as Z,bc as _,Yr as _t,ul as a,Si as at,tc as b,Wr as bt,sl as c,yi as ct,Yc as d,mi as dt,Zi as et,Uc as f,li as ft,Nc as g,qr as gt,Bc as h,ti as ht,fl as i,xi as it,Yo as j,Mn as jt,os as k,Jn as kt,il as l,vi as lt,Gc as m,ni as mt,vl as n,Ei as nt,ll as o,Ti as ot,Wc as p,ii as pt,so as q,pl as r,wi as rt,ol as s,Ci as st,gl as t,Mi as tt,qc as u,_i as ut,cc as v,$r as vt,Rs as w,Hr as wt,$s as x,Ur as xt,nc as y,Qr as yt,uo as z};
|
|
3
|
-
//# debugId=0e25029e-b813-49f1-8b25-3af4d8471999
|
|
@@ -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{Do as r,Lr as i,R as a,Rr as o,Ui as s,Yc as c,cc as l,ds as u,mr as d,pc as f,sc as p}from"./app-B94YfKGx.js";import{h as m}from"./vendor-t7Q7QbPu.js";import{a as h,c as g,d as _,i as v,n as y,o as b,p as x,r as S,t as C}from"./sheet-source-DxVQhlKF.js";import{a as ee,c as w,d as T,h as E,i as D,n as O,o as k,r as A,s as j,t as M}from"./list-page-DImD2FRO.js";var N=e=>e===null||typeof e==`string`&&e.trim()===``,P=/^-?(0|[1-9]\d*)$/,F=/^-?(0|[1-9]\d*)\.\d+$/,I=/^(\d{4})-(\d{2})-(\d{2})$/,L=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,6})?)?(Z|[+-]\d{2}:\d{2})?$/,R=e=>{let t=I.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=new Date(Date.UTC(n,r-1,i));return a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i},z=e=>{if(P.test(e))return`whole`;if(F.test(e))return`decimal`;if(/^(true|false)$/i.test(e))return`boolean`;if(R(e))return`date`;let t=L.exec(e);return!t?.[1]||!R(t[1])||Number(t[2])>23||Number(t[3])>59||Number(t[4]??0)>59?`text`:t[5]?`zoned`:`local`},B=e=>typeof e==`boolean`?`boolean`:typeof e==`number`?Number.isInteger(e)?`whole`:`decimal`:typeof e==`string`?z(e.trim()):`json`in e?`json`:e.date.includes(`T`)?`local`:`date`,V=e=>typeof e==`number`?e.toLocaleString(`en-US`,{useGrouping:!1,maximumFractionDigits:100}):e.trim(),H=1e3,te=2147483647n,ne={boolean:`boolean`,date:`date`,local:`timestamp`,zoned:`timestamp`,json:`json`},re=()=>{let e=new Set,t=1,n=0,r=!1,i=0,a=a=>{if(a===null||N(a))return;typeof a==`string`&&(i=Math.max(i,a.length));let o=B(a);if(e.add(o),o!==`whole`&&o!==`decimal`)return;let[s=``,c=``]=V(a).replace(`-`,``).split(`.`);if(t=Math.max(t,s.length),n=Math.max(n,c.length),o===`whole`&&!r){let e=BigInt(V(a));r=(e<0n?-e-1n:e)>te}},o=()=>{let e=Math.min(H,Math.max(t,15)+n);return{type:`decimal`,precision:e,scale:Math.min(n,e)}};return{add:a,type:()=>{if(e.has(`json`))return{type:`json`};let t=e.size===1?[...e][0]:void 0;return t===`whole`?r?o():{type:`integer`}:e.size===2&&e.has(`whole`)&&e.has(`decimal`)||t===`decimal`?o():t&&t!==`text`?{type:ne[t]}:{type:i>500?`long_text`:`text`}},decimal:o}},ie=e=>{switch(e){case`integer`:return[`integer`,`decimal`,`text`,`long_text`];case`decimal`:case`boolean`:case`date`:case`timestamp`:return[e,`text`,`long_text`];case`text`:return[`text`,`long_text`];case`long_text`:case`json`:return[e]}},U=(e,t)=>{let n=e[t],r=e[O];return{table:e=>({label:x(n,e),help:n?.fields[e]?.help}),field:e=>({label:x(r,e),help:r?.fields[e]?.help}),type:e=>r?.fields.type?.valueLabels?.[e]??e}},W=(e,t,n)=>e===`form`?T(`nameForm`,{max:n}):T(e===`reserved_word`?`nameReservedWord`:`nameReservedField`,{name:t}),G=e=>{if(e.trim()===``)return T(`needed`);if(e.trim().length>200)return T(`labelTooLong`,{max:200})},K=(e,t,n)=>{let r=E(e.name,`table`,n),i={name:r?W(r,e.name,n):t.has(e.name)?T(`nameTaken`,{name:e.name}):void 0,pluralLabel:G(e.pluralLabel),singularLabel:G(e.singularLabel),fields:{}},a=D(e);a.length===0&&(i.noFields=T(`noFields`));let o=new Set;for(let e of a){let t=E(e.name,`field`),n=t?W(t,e.name,63):o.has(e.name)?T(`nameTwice`,{name:e.name}):void 0;o.add(e.name);let r=G(e.label);(n||r)&&(i.fields[e.column]={...n&&{name:n},...r&&{label:r}})}return i},q=e=>!!(e.name||e.pluralLabel||e.singularLabel||e.noFields||Object.keys(e.fields).length>0),J=e(n(),1),Y=``,ae=({field:e,column:t,examples:n,problems:i,texts:o,onChange:s})=>{let c=o.field(`type`),l=o.field(`label`),u=o.field(`name`),d=ie(e.inferred.type).map(e=>({value:e,label:o.type(e)})),f=e.include&&e.type===`decimal`;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 py-3 sm:grid-cols-2 sm:gap-4`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`truncate font-medium`,children:t}),(0,J.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.length>0?n.join(`, `):T(`emptyInFirstRows`)})]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,J.jsx)(b,{label:c.label,name:T(`typeFor`,{name:t}),value:e.include?e.type:Y,options:[...d,{value:Y,label:T(`doNotImport`)}],onChange:e=>s(e===Y?{include:!1}:{include:!0,type:e}),help:f?T(`decimalSize`,{precision:e.decimal.precision,scale:e.decimal.scale}):void 0}),e.include&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(a,{label:l.label,error:i?.label,required:!0,children:(0,J.jsx)(r,{wrapperClassName:`max-sm:min-h-11`,"aria-label":T(`labelFor`,{name:t}),value:e.label,onChange:e=>s({label:e.target.value})})}),(0,J.jsx)(a,{label:u.label,error:i?.name,required:!0,children:(0,J.jsx)(r,{wrapperClassName:`max-sm:min-h-11`,className:`font-mono`,"aria-label":T(`nameFor`,{name:t}),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,value:e.name,onChange:e=>s({name:e.target.value})})})]})]})]})},X=``,Z=({proposal:e,problems:t,texts:n,onChange:i})=>{let o=D(e).filter(e=>e.type===`text`),s=n.table(`plural_label`),c=n.table(`singular_label`),l=n.table(`name`),u=n.table(`title_field`);return(0,J.jsxs)(`section`,{"aria-label":T(`newTable`),className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,J.jsx)(a,{label:s.label,help:s.help,error:t.pluralLabel,required:!0,children:(0,J.jsx)(r,{wrapperClassName:`max-sm:min-h-11`,value:e.pluralLabel,onChange:e=>i({pluralLabel:e.target.value})})}),(0,J.jsx)(a,{label:c.label,help:c.help,error:t.singularLabel,required:!0,children:(0,J.jsx)(r,{wrapperClassName:`max-sm:min-h-11`,value:e.singularLabel,onChange:e=>i({singularLabel:e.target.value})})}),(0,J.jsx)(a,{label:l.label,help:l.help,error:t.name,required:!0,children:(0,J.jsx)(r,{wrapperClassName:`max-sm:min-h-11`,className:`font-mono`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,value:e.name,onChange:e=>i({name:e.target.value})})}),(0,J.jsx)(b,{label:u.label,value:e.titleField??X,options:[{value:X,label:T(`noTitle`)},...o.map(e=>({value:e.name,label:e.label||e.name}))],onChange:e=>i({titleField:e||void 0}),help:u.help})]})},oe=({flow:e,problems:t,texts:n})=>{let{proposal:r,read:i}=e;return!r||!i?null:(0,J.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,J.jsx)(Z,{proposal:r,problems:t,texts:n,onChange:e.changeTable}),(0,J.jsx)(`p`,{className:`-mb-3 text-xs text-muted-foreground`,children:T(`typesFromCells`,{rows:i.rows})}),(0,J.jsx)(`section`,{"aria-label":T(`columns`),className:`flex flex-col divide-y divide-border border-y`,children:r.fields.map(r=>(0,J.jsx)(ae,{field:r,column:j(i.headers,r.column),examples:i.sample.map(e=>k(e.cells[r.column]??null)).filter(e=>e!==``).slice(0,3),problems:t.fields[r.column],texts:n,onChange:t=>e.change(r.column,t)},r.column))}),t.noFields&&(0,J.jsxs)(`p`,{role:`alert`,className:`flex gap-2 rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-warning-text`,children:[(0,J.jsx)(f,{className:`mt-0.5 size-4 shrink-0`}),(0,J.jsx)(`span`,{children:t.noFields})]})]})},Q=e(t(),1),se=5,ce=async(e,t,n,r)=>{let i,a=[],o=[],s=0;for await(let c of e.rows(t)){r?.throwIfAborted();for(let e of c){if(!i){i=e.cells.map(k),a=i.map(()=>re());continue}e.cells.every(w)||(s++,o.length<se&&o.push(e),a.forEach((t,n)=>t.add(e.cells[n]??null)))}n(s)}return{headers:i??[],types:a.map(e=>e.type()),decimals:a.map(e=>e.decimal()),sample:o,rows:s}},$={created:0,updated:0,skipped:0,failed:0,notWritten:[]},le={decimal:`.`,dateOrder:`dmy`,booleanText:!0},ue=({tables:e,resources:t,sourceFor:n=C})=>{let r=u(),i=m(),{go:a}=o(),s=e.tenant!==void 0,l=s?42:63,d=(0,Q.useMemo)(()=>new Set(s?[]:Object.keys(t)),[s,t]),[f,p]=(0,Q.useState)({kind:`file`,reading:!1}),[h,g]=(0,Q.useState)(),[v,b]=(0,Q.useState)(),[x,S]=(0,Q.useState)(),[w,T]=(0,Q.useState)(),[E,O]=(0,Q.useState)(),[k,j]=(0,Q.useState)(),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(void 0),F=e=>t=>{g(t),p(e)},I=(e,t,n)=>{let r=new AbortController;P.current=r,p({kind:`reading`,rows:0}),ce(t,n,e=>p({kind:`reading`,rows:e}),r.signal).then(t=>{r.signal.aborted||(T(t),O(ee(e.name,t,d,l)),p({kind:`fields`}))}).catch(e=>{r.signal.aborted||F({kind:`file`,reading:!1})(e)})},L=e=>{g(void 0),p({kind:`file`,reading:!0});let t=n(e);t.sheets().then(n=>{if(b({file:e,source:t,sheets:n}),S(n[0]),n.length<=1)return I(e,t,n[0]);p({kind:`file`,reading:!1})}).catch(F({kind:`file`,reading:!1}))},R=()=>{v&&(g(void 0),I(v.file,v.source,x))},z=(e,t)=>O(n=>n&&A(n,e,t)),B=e=>O(t=>t&&{...t,...e}),V=async e=>{await i.refetchQueries({queryKey:c.meta});let t=i.getQueryData(c.meta),n=t?.resources[e];if(!t||!n)throw Error(`The server does not serve the new table ${e} yet`);return{model:n,resources:t.resources,views:t.views}},H=async(e,t)=>{if(!v||!w)return;let n={...await V(e),lookups:y(r)},i={mode:`create`,columns:D(t).map(e=>({column:e.column,field:e.name})),options:le};N.current=!1;let o=$;p({kind:`importing`,progress:$,total:w.rows,cancelling:!1});let s=await _(v.source,x,i,n,{client:r(e),onProgress:e=>{o=e,p({kind:`importing`,progress:e,total:w.rows,cancelling:N.current})},cancelled:()=>N.current}).catch(e=>({...o,cancelled:!1,stopped:e})),c=`stopped`in s?s.stopped:void 0;if(c===void 0&&!s.cancelled&&s.notWritten.length===0)return a({kind:`list`,resource:e});p({kind:`done`,result:s,stopped:c})};return{step:f,error:h,file:v?.file,sheets:v?.sheets??[],sheet:x,setSheet:S,read:w,proposal:E,table:k,taken:d,maxTableBytes:l,choose:L,openSheet:R,change:z,changeTable:B,create:()=>{E&&(g(void 0),p({kind:`creating`}),r(e.name).batchWrite(M(e.name,E)).then(({results:e})=>{let[t]=e,n=t?.op===`create`?String(t.record.table_name):E.name;return j(n),H(n,E).catch(e=>p({kind:`done`,result:{...$,cancelled:!1},stopped:e}))},F({kind:`fields`})))},cancel:()=>{N.current=!0,p(e=>e.kind===`importing`?{...e,cancelling:!0}:e)},back:()=>{P.current?.abort(),g(void 0),p({kind:`file`,reading:!1})},stop:()=>P.current?.abort()}},de=e=>e.step.kind===`fields`?T(`couldNotMakeTable`):T(`couldNotReadFile`),fe=({tables:e,resources:t,views:n,onClose:r,sourceFor:a})=>{let o=ue({tables:e,resources:t,sourceFor:a}),c=U(n,e.name),{step:u,proposal:f}=o,m=f?K(f,o.taken,o.maxTableBytes):void 0,_=o.read?.headers??[],y=u.kind===`creating`||u.kind===`importing`,b=()=>{y||(o.stop(),r())},x=(0,J.jsx)(p,{onClick:b,children:T(`cancel`)});return(0,J.jsx)(s,{open:!0,wide:!0,title:T(`tableFromFile`),description:o.file&&u.kind!==`file`?o.file.name:void 0,onClose:b,actions:(()=>{switch(u.kind){case`file`:return(0,J.jsxs)(J.Fragment,{children:[x,o.sheets.length>1&&(0,J.jsx)(p,{variant:`primary`,loading:u.reading,onClick:o.openSheet,children:T(`next`)})]});case`reading`:return(0,J.jsx)(p,{onClick:o.back,children:T(`back`)});case`fields`:case`creating`:{let e=o.read?.rows??0;return(0,J.jsxs)(J.Fragment,{children:[x,(0,J.jsx)(p,{variant:`primary`,loading:u.kind===`creating`,disabled:!m||q(m),onClick:o.create,children:T(`makeTable`,{rows:e})})]})}case`importing`:return(0,J.jsx)(p,{variant:`danger`,disabled:u.cancelling,onClick:o.cancel,children:T(`cancelImport`)});case`done`:return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(p,{onClick:r,children:T(`done`)}),o.table&&(0,J.jsx)(i,{to:{kind:`list`,resource:o.table},className:l({variant:`primary`}),children:T(`openTable`)})]})}})(),children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.error!==void 0&&(0,J.jsx)(d,{title:de(o),error:o.error}),(()=>{switch(u.kind){case`file`:return(0,J.jsx)(h,{file:o.file,sheets:o.sheets,sheet:o.sheet,reading:u.reading,onChoose:o.choose,onSheet:o.setSheet});case`reading`:return(0,J.jsx)(g,{rows:u.rows});case`fields`:case`creating`:return m&&(0,J.jsx)(oe,{flow:o,problems:m,texts:c});case`importing`:return(0,J.jsx)(S,{progress:u.progress,total:u.total,cancelling:u.cancelling});case`done`:return(0,J.jsx)(v,{result:u.result,stopped:u.stopped,headers:_,fileName:o.file?.name})}})()]})})};export{fe as ImportTableDialog};
|
|
2
|
-
//# debugId=5b23b189-f116-46d0-ae8c-d7cc96e99bc4
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/import-dialog-bNG6qX6Q.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-B94YfKGx.js","assets/vendor-t7Q7QbPu.js","assets/app-xwgcmboV.css","assets/sheet-source-DxVQhlKF.js","assets/import-table-dialog-BbI7GJ8R.js","assets/export-dialog-gSUSlzOy.js","assets/embedded-list-OJQKeuBN.js","assets/update-set-B0D_tNDz.js","assets/layout-grid-dpoR6hFU.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-DsIrTWKZ.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"])))=>i.map(i=>d[i]);
|
|
2
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$s as r,Bo as i,C as a,Ca as o,Co as s,Do as c,Ea as l,Eo as u,Fc as d,Fi as f,Ft as p,Gn as m,Hc as h,Ic as g,Jn as _,Kl as v,Kr as y,Ks as b,Li as x,Lo as S,Lr as C,M as w,Mr as T,Nn as E,O as ee,Oc as te,Pa as D,Qc as ne,Ql as re,Qr as ie,Rc as ae,Ri as oe,Rr as se,S as ce,Sa as le,T as O,Ti as k,Tn as ue,Ui as de,Vc as A,Vr as j,Wl as M,Wn as N,Xc as fe,Xl as pe,Yc as P,Zr as me,_a as he,b as ge,bo as _e,ca as ve,cc as ye,cl as F,dc as be,fc as xe,fl as Se,hc as Ce,ic as I,il as we,ja as Te,ji as L,jr as Ee,k as De,kn as Oe,kt as R,ls as z,lt as ke,mi as Ae,mr as je,ns as Me,ol as Ne,qn as B,ri as Pe,rl as Fe,rs as Ie,sc as V,si as Le,sl as H,tc as U,to as Re,ts as ze,ui as Be,un as Ve,va as He,vl as Ue,vn as We,wa as W,wo as Ge,xa as Ke,ya as qe,yc as Je,yo as Ye,ys as Xe,zo as Ze}from"./app-B94YfKGx.js";import{C as Qe,f as $e,h as et,i as G,o as tt,s as K}from"./vendor-t7Q7QbPu.js";import{n as nt}from"./view-chart-ChBtewKd.js";import{$ as rt,A as it,B as at,D as ot,E as st,F as ct,G as lt,H as ut,I as dt,J as q,K as ft,L as pt,M as mt,N as ht,O as gt,P as _t,Q as vt,R as yt,T as bt,U as xt,V as St,W as Ct,X as wt,Y as Tt,Z as J,b as Et,d as Dt,et as Ot,f as kt,ft as At,h as jt,i as Mt,j as Nt,k as Pt,m as Ft,n as It,p as Lt,pt as Rt,q as zt,u as Bt,v as Vt,w as Ht,x as Ut,xt as Y,y as Wt,z as Gt}from"./embedded-list-OJQKeuBN.js";import{a as Kt,i as qt,n as Jt,r as Yt,t as Xt}from"./reorder-button-BhhzhhTO.js";import{t as Zt}from"./trash-MHAT5Hf3.js";import{t as Qt}from"./page-header-Ddz2r5ic.js";import{i as $t,r as en,t as tn}from"./record-preview-DsIrTWKZ.js";import{c as nn,l as rn}from"./messages-vzi5T1Xo.js";import{t as an}from"./use-display-rows-vjthlkqo.js";var on=new Set(`all.analyse.analyze.and.any.array.as.asc.asymmetric.both.case.cast.check.collate.column.constraint.create.current_catalog.current_date.current_role.current_time.current_timestamp.current_user.default.deferrable.desc.distinct.do.else.end.except.false.fetch.for.foreign.from.grant.group.having.in.initially.intersect.into.lateral.leading.limit.localtime.localtimestamp.not.null.offset.on.only.or.order.placing.primary.references.returning.select.session_user.some.symmetric.system_user.table.then.to.trailing.true.union.unique.user.using.variadic.when.where.window.with`.split(`.`)),sn=/^[a-z][a-z0-9_]*$/,cn=[`id`,`etag`,`organization_id`],ln=e=>sn.test(e)&&new TextEncoder().encode(e).length<=63,un=(e,t,n=63)=>{if(typeof e!=`string`||!ln(e)||new TextEncoder().encode(e).length>n)return`form`;if(on.has(e))return`reserved_word`;if(t===`field`&&cn.includes(e))return`reserved_field`},dn={name:`bookmark-check`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}],[`path`,{d:`m9 10 2 2 4-4`,key:`1gnqz4`}]]};dn.node;var fn=A(dn),pn={name:`bookmark-plus`,size:24,node:[[`path`,{d:`M12 7v6`,key:`lw1j43`}],[`path`,{d:`M15 10H9`,key:`o6yqo3`}],[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};pn.node;var mn=A(pn),hn={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};hn.node;var gn=A(hn),_n={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};_n.node;var vn=A(_n),yn={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};yn.node;var bn=A(yn),xn=e=>e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``),Sn=(e,t,n)=>(/^[a-z]/.test(e)?e:`${t}_${e}`).slice(0,n).replace(/_+$/,``),Cn=(e,t,n)=>{let r=e;for(let i=2;t.has(r)||on.has(r);i++){let t=`_${i}`;r=`${e.slice(0,n-t.length).replace(/_+$/,``)}${t}`}return r},wn=e=>e<26?String.fromCharCode(97+e):wn(Math.floor(e/26)-1)+wn(e%26),Tn=e=>{let t=new Set(cn);return e.map((e,n)=>{let r=xn(e),i=Cn(r===``?`column_${wn(n)}`:Sn(r,`column`,63),t,63);return t.add(i),i})},En=(e,t=[],n=63)=>{let r=xn(e.replace(/\.(csv|tsv|txt|xlsx|json)$/i,``));if(r!==``)return Cn(Sn(r,`table`,n),new Set(t),n)},X=e(n(),1),Dn=`inline-flex h-6 items-center gap-1 rounded-full border border-primary-border bg-primary-soft pl-2.5 pr-1.5 text-xs font-medium text-primary-text`,On=({chips:e,lockedLabels:t=[],onRemove:n,onClear:r,scroll:i})=>e.length===0&&t.length===0?null:(0,X.jsxs)(`div`,{className:i?`flex flex-nowrap items-center gap-1.5 overflow-x-auto pb-1 [&>*]:shrink-0`:`flex flex-wrap items-center gap-1.5`,children:[t.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex h-6 items-center gap-1.5 rounded-full border border-border-strong bg-muted px-2.5 text-xs font-medium text-foreground`,children:[(0,X.jsx)(gn,{className:`size-3 text-muted-foreground`}),e]},e)),e.map(e=>(0,X.jsxs)(`span`,{className:Dn,children:[e.label,(0,X.jsx)(`button`,{type:`button`,"aria-label":q(`remove`,{label:e.label}),onClick:()=>n(e.key),className:`rounded-full p-0.5 hover:bg-primary-border/60`,children:(0,X.jsx)(be,{className:`size-3`})})]},e.key)),e.length>0&&(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`ml-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:q(`clearAll`)})]}),kn=({value:e,presets:t=zt,onChange:n})=>(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let r=ft(t);return(0,X.jsx)(`button`,{type:`button`,disabled:!r,title:r?void 0:q(`unknownPreset`,{id:t}),onClick:()=>n(e===t?void 0:t),className:h(`h-7 rounded-md border px-2.5 text-body font-medium transition-colors`,!r&&`border-dashed text-danger-text`,e===t?`border-primary-border bg-primary-soft text-primary-text`:`border-border-strong bg-background text-muted-foreground hover:bg-muted`),children:r??q(`unsupported`,{id:t})},t)})}),An=(e,t)=>e.onSearch?e.options:e.options.filter(e=>St(e.label,t)),jn=(e,t,n)=>t===0?-1:n===`ArrowDown`?e<0?0:(e+1)%t:e<0?t-1:(e-1+t)%t,Z=e(t(),1),Mn=({config:e,selected:t,onToggle:n,inline:r=!1})=>{let i=(0,Z.useId)(),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(-1),f=r||c,p=An(e,o),m=(0,Z.useRef)(e.onSearch);m.current=e.onSearch,(0,Z.useEffect)(()=>()=>m.current?.(``),[]);let _=t=>{s(t),d(-1),e.onSearch?.(t)};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex min-h-8 cursor-text flex-wrap items-center gap-1 rounded-md border border-border-strong bg-background px-2 py-1 shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20`,onClick:()=>a.current?.focus(),children:[(0,X.jsx)(Ce,{className:`size-3.5 shrink-0 text-muted-foreground`}),t.map(t=>(0,X.jsx)(E,{label:at(e,t),onRemove:()=>n(t)},t)),(0,X.jsx)(`input`,{ref:a,autoFocus:r,role:`combobox`,"aria-label":e.label,"aria-expanded":f,"aria-controls":`${i}-options`,"aria-autocomplete":`list`,"aria-activedescendant":p[u]?`${i}-${u}`:void 0,placeholder:t.length>0?``:q(`searchIn`,{label:e.label}),className:`h-6 min-w-16 flex-1 bg-transparent text-foreground outline-none placeholder:text-faint-foreground`,value:o,onChange:e=>_(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),d(jn(u,p.length,e.key));return}if(e.key===`Enter`&&p[u]){e.preventDefault(),n(p[u].value);return}if(e.key===`Backspace`&&o===``&&t.length>0){n(t[t.length-1]);return}e.key===`Escape`&&o!==``&&(e.stopPropagation(),_(``))},onFocus:()=>l(!0),onBlur:()=>{l(!1),d(-1),!r&&o!==``&&_(``)}})]}),f&&(0,X.jsxs)(`ul`,{id:`${i}-options`,role:`listbox`,"aria-label":e.label,"aria-multiselectable":!0,className:h(`flex max-h-60 flex-col gap-px overflow-y-auto`,!r&&`rounded-md border bg-background p-1 shadow-sm`),children:[p.map((e,r)=>{let a=t.includes(e.value);return(0,X.jsxs)(`li`,{id:`${i}-${r}`,role:`option`,"aria-selected":a,tabIndex:-1,className:h(`flex cursor-pointer items-center gap-2 rounded px-1.5 py-1 hover:bg-muted`,r===u&&`bg-muted`),onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.value),children:[(0,X.jsx)(`span`,{className:h(`inline-flex size-4 shrink-0 items-center justify-center rounded border`,a?`border-primary bg-primary text-primary-foreground`:`border-border-strong bg-background`),children:a&&(0,X.jsx)(g,{className:`size-3`,strokeWidth:3})}),(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:L(e.count)})]},e.value)}),e.failed&&(0,X.jsx)(`li`,{className:`px-1.5 py-1 text-xs text-danger-text`,children:q(`couldNotLoadCounts`)}),!e.failed&&p.length===0&&(0,X.jsx)(`li`,{className:`px-1.5 py-1 text-xs text-faint-foreground`,children:q(`noMatches`)})]})]})},Nn=({config:e,selected:t,onToggle:n})=>{let[r,i]=(0,Z.useState)(``),a=e.options.filter(e=>St(e.label,r));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.searchable&&(0,X.jsx)(c,{wrapperClassName:`mb-1 h-7`,leading:(0,X.jsx)(Ce,{className:`size-3.5`}),placeholder:q(`searchIn`,{label:e.label}),value:r,onChange:e=>i(e.target.value)}),a.map(e=>(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-1 hover:bg-muted`,children:[(0,X.jsx)(Re,{checked:t.includes(e.value),onChange:()=>n(e.value),label:e.label}),(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:L(e.count)})]},e.value)),e.failed&&(0,X.jsx)(`span`,{className:`px-1 py-1 text-xs text-danger-text`,children:q(`couldNotLoadCounts`)}),!e.failed&&a.length===0&&(0,X.jsx)(`span`,{className:`px-1 py-1 text-xs text-faint-foreground`,children:q(`noMatches`)})]})},Pn=({label:e,activeCount:t,width:n=240,defaultOpen:r=!1,children:i})=>{let[a,o]=(0,Z.useState)(r),[c,l]=(0,Z.useState)({width:n}),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>{if(!a||!f.current)return;let e=f.current.getBoundingClientRect(),t=document.documentElement.clientWidth,r=Math.min(n,s(t));l({width:r,right:e.left+r>t?e.right-Ge(e.right,r,t):void 0})},[a,n]);let m=u(a,f,p,c);return(0,Z.useEffect)(()=>{if(!a)return;let e=e=>{e.target instanceof Node&&!f.current?.contains(e.target)&&o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]),(0,X.jsxs)(`div`,{ref:f,className:`relative`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(!a),className:h(`inline-flex h-8 items-center gap-1.5 rounded-md border bg-background px-2.5 font-medium shadow-sm transition-colors hover:bg-muted`,t>0?`border-primary-border text-primary-text`:`border-border-strong text-foreground`),children:[e,t>0&&(0,X.jsx)(`span`,{className:`rounded-full bg-primary px-1.5 text-[0.6875rem] leading-4 text-primary-foreground`,children:t}),(0,X.jsx)(d,{className:`size-3.5 text-muted-foreground`})]}),a&&(0,X.jsx)(`div`,{ref:p,className:h(`absolute top-full z-30 mt-1.5 rounded-lg border bg-background p-3 shadow-pop`,c.right===void 0&&`left-0`),style:{...c,...m},children:typeof i==`function`?i(()=>o(!1)):i})]})},Fn=({title:e,children:t})=>(0,X.jsxs)(`section`,{className:`flex flex-col gap-2 border-b py-3 last:border-b-0`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),t]}),In=({items:e,onPick:t,close:n})=>{let r=(0,Z.useRef)([]);return(0,Z.useEffect)(()=>r.current[0]?.focus(),[]),(0,X.jsx)(`ul`,{role:`menu`,"aria-label":q(`moreFilters`),onKeyDown:t=>{if(t.key===`Escape`)return n();let i=R(t.key,r.current.indexOf(document.activeElement),e.length);i!==void 0&&(t.preventDefault(),r.current[i]?.focus())},className:`-mx-3 -my-3`,children:e.map((e,i)=>(0,X.jsx)(`li`,{role:`none`,children:(0,X.jsx)(`button`,{ref:e=>{r.current[i]=e},type:`button`,role:`menuitem`,className:ke,onClick:()=>{n(),t(e.key)},children:e.label})},e.key))})},Ln=({items:e,onPick:t})=>e.length===0?null:(0,X.jsx)(Pn,{label:q(`moreFilters`),activeCount:0,children:n=>(0,X.jsx)(In,{items:e,onPick:t,close:n})}),Rn=(e,t,n,r,i)=>{let a=n+(r-n)*e/t;return n+(r-n)*(e+1)/t>i[0]&&a<i[1]},zn=(e,t,n)=>n===t?0:(e-t)/(n-t),Bn=(e,t,n)=>t===0?[Math.min(n,e[1]),e[1]]:[e[0],Math.max(n,e[0])],Vn=1e3,Hn=({config:e,value:t,onChange:n})=>{let{min:r,max:i,step:a,histogram:o,format:s}=e,[c,l]=(0,Z.useState)(),u=c??t??[r,i],d=Math.max(...o),f=()=>{c&&(l(void 0),n(c[0]===r&&c[1]===i?void 0:c))},p=x(c,Vn);return(0,Z.useEffect)(()=>{p&&f()},[p]),e.failed?(0,X.jsx)(`p`,{className:`text-xs text-danger-text`,children:q(`couldNotLoadCounts`)}):(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsxs)(`div`,{className:`px-[7px]`,children:[o.length>0&&(0,X.jsx)(`div`,{className:`mb-1 flex h-12 items-end gap-0.5`,children:o.map((e,t)=>(0,X.jsx)(`span`,{className:h(`flex-1 rounded-t-sm`,Rn(t,o.length,r,i,u)?`bg-primary/70`:`bg-border`),style:{height:`${Math.max(6,e/d*100)}%`}},t))}),(0,X.jsxs)(`div`,{className:`relative h-4`,children:[(0,X.jsx)(`span`,{className:`absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-border`}),(0,X.jsx)(`span`,{className:`absolute top-1/2 h-1 -translate-y-1/2 rounded-full bg-primary`,style:{left:`${zn(u[0],r,i)*100}%`,right:`${100-zn(u[1],r,i)*100}%`}})]})]}),(0,X.jsx)(`div`,{className:`relative -mt-4 h-4`,children:[0,1].map(t=>(0,X.jsx)(`input`,{type:`range`,className:`pb-range`,"aria-label":q(t===0?`minimum`:`maximum`,{label:e.label}),min:r,max:i,step:a,value:u[t],onChange:e=>l(Bn(u,t,Number(e.target.value))),onPointerUp:f,onTouchEnd:f,onBlur:f},t))}),(0,X.jsxs)(`div`,{className:`mt-2 flex justify-between text-xs tabular-nums text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:s(u[0])}),(0,X.jsx)(`span`,{children:s(u[1])})]})]})},Un=e=>[...new Set(e.map(e=>e.key.split(`:`).slice(0,2).join(`:`)))],Wn=(e,t)=>{let n=t.filter(t=>!e.includes(t));return n.length===0?e:[...e,...n]},Gn=(e,t)=>{let n=[...e.facets.map(e=>({key:`facet:${e.id}`,label:e.label,secondary:e.secondary})),...(e.ranges??[]).map(e=>({key:`range:${e.id}`,label:e.label,secondary:e.secondary})),...e.datePresets?[{key:`date`,label:q(`date`),secondary:e.dateSecondary}]:[],...(e.toggles??[]).map(e=>({key:`toggle:${e.id}`,label:e.label,secondary:e.secondary}))],r=new Set,i=[];for(let e of n)!e.secondary||t.includes(e.key)?r.add(e.key):i.push({key:e.key,label:e.label});return{shown:r,more:i}},Kn=({label:e,checked:t,onChange:n})=>(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between gap-3 py-1`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(w,{checked:t,onChange:n,label:e})]}),qn=(e,t)=>e.some(e=>e.length>0)||!!t,Jn=({groups:e,trailing:t})=>{if(!qn(e,t))return null;let n=e.filter(e=>e.length>0);return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.map((e,t)=>(0,X.jsxs)(Z.Fragment,{children:[t>0&&(0,X.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`}),e]},t)),t&&(0,X.jsx)(`div`,{className:`flex min-w-32 flex-1 justify-end`,children:t})]})},Yn=(e,t,n)=>{let[r,i]=(0,Z.useState)(t??Gt);return[e??r,e=>{i(e),n?.(e)}]},Xn=({config:e,layout:t,value:n,defaultValue:r,onChange:i,lockedLabels:a,defaultOpenMenu:o,fullWidth:s,leading:c,trailing:l})=>{let[u,d]=Yn(n,r,i),f=yt(e,u),p=Un(f),[m,h]=(0,Z.useState)(()=>p),[g,_]=(0,Z.useState)();(0,Z.useEffect)(()=>h(e=>Wn(e,p)),[p.join(`,`)]);let v=(0,X.jsx)(On,{chips:f,lockedLabels:a,onRemove:e=>d(ut(u,e)),onClear:()=>d(Gt)}),y=(e,t=!1)=>{let n=u.facets[e.id]??[],r=t=>d(Ct(u,e.id,t));return e.combobox?(0,X.jsx)(Mn,{config:e,selected:n,onToggle:r,inline:t}):(0,X.jsx)(Nn,{config:e,selected:n,onToggle:r})},b=e.ranges??[],x=e=>(0,X.jsx)(Hn,{config:e,value:u.ranges?.[e.id],onChange:t=>d(xt(u,e.id,t))}),S=e.datePresets&&(0,X.jsx)(kn,{value:u.date,presets:Array.isArray(e.datePresets)?e.datePresets:void 0,onChange:e=>d({...u,date:e})}),C=(e.toggles??[]).map(e=>(0,X.jsx)(Kn,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(lt(u,e.id))},e.id));if(t===`panel`)return(0,X.jsxs)(`aside`,{className:s?`flex w-full flex-col gap-1`:`flex w-64 shrink-0 flex-col gap-1 overflow-y-auto rounded-lg border bg-background px-4 py-3`,children:[(0,X.jsx)(`div`,{className:`flex items-center justify-between pb-1`,children:(0,X.jsx)(`h2`,{className:`font-semibold`,children:q(`filters`)})}),(f.length>0||(a?.length??0)>0)&&(0,X.jsx)(`div`,{className:`border-b pb-3`,children:v}),c,e.facets.map(e=>(0,X.jsx)(Fn,{title:e.label,children:y(e)},e.id)),b.map(e=>(0,X.jsx)(Fn,{title:e.label,children:x(e)},e.id)),S&&(0,X.jsx)(Fn,{title:q(`date`),children:S}),C.length>0&&(0,X.jsx)(Fn,{title:q(`showOnly`),children:C})]});let{shown:w,more:T}=Gn(e,m),E=e=>{h(t=>Wn(t,[e])),_(e)},ee=[...e.facets.filter(e=>w.has(`facet:${e.id}`)).map(e=>(0,X.jsx)(Pn,{label:e.label,activeCount:(u.facets[e.id]??[]).length,width:e.combobox?280:void 0,defaultOpen:o===e.id||g===`facet:${e.id}`,children:y(e,!0)},e.id)),...b.filter(e=>w.has(`range:${e.id}`)).map(e=>(0,X.jsx)(Pn,{label:e.label,activeCount:+!!u.ranges?.[e.id],width:280,defaultOpen:o===e.id||g===`range:${e.id}`,children:x(e)},`range:${e.id}`)),...S&&w.has(`date`)?[(0,X.jsx)(Z.Fragment,{children:S},`date`)]:[]],te=(e.toggles??[]).filter(e=>w.has(`toggle:${e.id}`)).map(e=>(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:(0,X.jsx)(Kn,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(lt(u,e.id))})},e.id)),D=[c?[(0,X.jsx)(Z.Fragment,{children:c},`leading`)]:[],ee,te,T.length>0?[(0,X.jsx)(Ln,{items:T,onPick:E},`more`)]:[]];return!qn(D,l)&&f.length===0&&!a?.length?null:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(Jn,{groups:D,trailing:l}),v]})},Q=fe(`app/export`),Zn=()=>new DOMException(Q(`cancelled`),`AbortError`),Qn=async({client:e,resource:t,filters:n,orderBy:r,plan:i,labels:a,limit:o,port:s,sink:c,signal:l,onProgress:u})=>{let d=i.columns.map(e=>e.name),f=0;try{await c.write(await s.send({kind:`start`,plan:i,locale:ne()}));for(let[i,p]of n.entries()){let m=``;do{let h=await e.search(t,{filter:p,orderBy:r,pageSize:500,pageToken:m,fields:d,labels:a});if(l.aborted)throw Zn();let g=h.items.slice(0,o-f);if(await c.write(await s.send({kind:`page`,records:g,labels:h.labels??{}})),f+=g.length,u(f),m=h.nextPageToken,f>=o)return await $n(s,c),{rows:f,truncated:g.length<h.items.length||m!==``||i+1<n.length}}while(m!==``)}return await $n(s,c),{rows:f,truncated:!1}}catch(e){throw await c.abort(),e}finally{s.close()}},$n=async(e,t)=>{await t.write(await e.send({kind:`finish`})),await t.close()},er=1048575,tr=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3
|
-
`,nr=`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,rr=`http://schemas.openxmlformats.org/package/2006/relationships`;`${tr}`,`${tr}${rr}${nr}`,`${tr}${rr}${nr}${nr}`,new TextEncoder;var ir=M(),ar=e=>e?.export!==!1,or=e=>Object.values(e.fields).flatMap(e=>e.sensitive?[]:[e.name]),sr=(e,t)=>{let n=new Set(or(e));return Fe(e,t).filter(e=>n.has(e))},cr=(e,t,n)=>Object.fromEntries(Ae(e,t,[],n).map(e=>[e.id,e.header])),lr=(e,t,n)=>{let r=cr(e,t,n);return n.flatMap(n=>{let i=e.fields[n];return i?[{name:n,header:r[n],field:i,hints:t?.fields[n]??{}}]:[]})},ur=(e,t)=>{let n=e?.export?e.export.maxRows??1/0:1/0;return Math.min(n,t===`xlsx`?er:1/0)},dr=e=>e.primaryKey.length===1,fr=(e,t)=>{let[n]=e.primaryKey;if(!n||e.primaryKey.length!==1)throw Error(`Not implemented: selected rows are exported by a single-field key`);let r=[];for(let e=0;e<t.length;e+=500)r.push(v(ir.in(n,t.slice(e,e+500))));return r},pr=e=>{if(e.kind!==`counting`)return e.kind===`exact`?e.rows:Math.max(e.rows,10001)},mr=fe(`app/import`),hr=e=>typeof e==`object`&&!!e&&`date`in e,gr=e=>typeof e==`object`&&!!e&&`json`in e,_r=e=>e===null||typeof e==`string`&&e.trim()===``,vr=e=>e===null?``:hr(e)?e.date.replace(`T`,` `):gr(e)?JSON.stringify(e.json):typeof e==`boolean`?e?`TRUE`:`FALSE`:String(e),yr=e=>e<26?String.fromCharCode(65+e):yr(Math.floor(e/26)-1)+yr(e%26),br=(e,t)=>e[t]?.trim()?e[t]:mr(`column`,{letters:yr(t)}),xr=(e,t,n,r)=>{let i=Tn(t.headers),a=t.headers.map((e,n)=>({column:n,include:!0,name:i[n],label:br(t.headers,n).trim(),type:t.types[n].type,inferred:t.types[n],decimal:t.decimals[n]}));return{name:En(e,n,r)??``,pluralLabel:e.replace(/\.[^.]+$/,``).trim(),singularLabel:``,titleField:a.find(e=>e.type===`text`)?.name,fields:a}},Sr=e=>e.fields.filter(e=>e.include),Cr=(e,t,n)=>{let r=e.fields.find(e=>e.column===t),i=e.fields.map(e=>e.column===t?{...e,...n}:e),a=i.find(e=>e.column===t),o=r?.name===e.titleField,s=a.include&&a.type===`text`;return o?{...e,fields:i,titleField:s?a.name:void 0}:{...e,fields:i}},wr=`user_table_fields`,Tr=`table`,Er=(e,t)=>{let n=Sr(t).map((e,t)=>({op:`create`,resource:wr,data:{table_id:{$ref:Tr},name:e.name,label:e.label.trim(),type:e.type,position:t+1,...e.type===`decimal`&&{precision:e.decimal.precision,scale:e.decimal.scale}}})),r=t.titleField?[{op:`update`,resource:e,key:{$ref:Tr},etag:`*`,data:{title_field:t.titleField}}]:[];return[{op:`create`,resource:e,ref:Tr,data:{name:t.name,singular_label:t.singularLabel.trim(),plural_label:t.pluralLabel.trim()}},...n,...r]},Dr=(e,t)=>{let n=new Map(t.map(e=>[e.value,e.count]));return e.map(([e,t])=>({value:e,label:t,...n.get(e)!==void 0&&{count:n.get(e)}}))},Or=(e,t)=>[...new Set(t.filter(t=>!e.includes(t)))],kr=M(),Ar=(e,t,n)=>{let r=z(),[i,a]=(0,Z.useState)({}),o=e=>!!e?.search?.length&&e.primaryKey.length===1,s=e=>{let n=t[e.name];return[e.primaryKey[0],...n?.titleFrom?n.titleFrom.fields:[we(e,n)]]},c=(e,r)=>{let i=t[e.name],a=String(r[e.primaryKey[0]]);return[a,i?.titleFrom?n(e,i,r,a):String(r[we(e,i)])]},l=K({queries:e.map(({id:e,target:t})=>{let n=(i[e]??``).trim();return{queryKey:[`reference-search`,e,t?.name??``,n],enabled:o(t)&&n!==``,placeholderData:$e,queryFn:async()=>(await r.list(t.name,{filter:v(kr.search(n)),fields:s(t),pageSize:20})).items}})});return e.map(({id:e,target:t},n)=>{if(!o(t))return{};let r=t=>a(n=>({...n,[e]:t}));return(i[e]??``).trim()===``?{onSearch:r}:{onSearch:r,matches:(l[n]?.data??[]).map(e=>c(t,e))}})},jr=24,Mr=({model:e,resources:t,views:n,view:r,state:i,extras:a,titleOf:o})=>{let s=z(),c=T(s),l=et(),u=ct(r,e),d=e=>r?.fields[e]?.label??F(e),f=n=>{let r=e.fields[n];return r?.type===`relation`&&r.relation?t[r.relation.resource]:void 0},p=e=>!!(e&&n[e.name]?.titleFrom),h=u.facets.flatMap(e=>(e.flags?e.options.map(e=>e.value):[e.id]).map(t=>({group:e.id,field:t}))),g=K({queries:h.map(({group:t,field:r})=>{let o=dt(u,{...i,facets:{...i.facets,[t]:[]}},a),s=f(r),l=s?.primaryKey.length===1&&!p(s)?we(s,n[s.name]):void 0;return{queryKey:P.facets(e.name,r,o),queryFn:()=>c.facets(e.name,r,{filter:o,limit:50,...l&&{label:l}})}})}),_=(e,t)=>g[h.findIndex(n=>n.group===e&&n.field===t)],v=(e,t)=>_(e,t)?.data,y=e=>(v(e,e)??[]).flatMap(e=>e.value===null?[]:[String(e.value)]),b=K({queries:u.facets.map(t=>{let r=f(t.id),a=Or(y(t.id),i.facets[t.id]??[]);return{queryKey:P.labels(`facet:${e.name}.${t.id}`,a.join(`,`)),enabled:!!r&&!p(r)&&a.length>0,queryFn:async()=>[...await B(l,s,r,a,n[r.name])]}})}),x=K({queries:u.facets.map(t=>{let r=f(t.id),a=r&&p(r)?N(r,n[r.name]):void 0,o=[...new Set([...y(t.id),...i.facets[t.id]??[]])];return{queryKey:P.labels(`facet-title:${e.name}.${t.id}`,o.join(`,`)),enabled:a!==void 0&&o.length>0,queryFn:async()=>[...await m(s,r,a,o)]}})}),S=(e,t)=>{let r=f(e);return(x[t]?.data??[]).map(([e,t])=>[e,o(r,n[r.name],t,e)])},C=Ar(u.facets.map(e=>({id:e.id,target:e.combobox?f(e.id):void 0})),n,o),w=u.ranges??[],E=K({queries:w.map(t=>{let n=dt(u,xt(i,t.id,void 0),a),o=_t(r,t.id)?jr:1;return{queryKey:P.histogram(e.name,t.id,o,n),queryFn:()=>c.histogram(e.name,t.id,{filter:n,buckets:o})}})});return{facets:u.facets.map((t,n)=>{if(t.flags){let e=e=>{let n=v(t.id,e);return n&&{count:n.find(e=>String(e.value)===`true`)?.count??0}},n=t.options.map(({value:t})=>({value:t,label:d(t),...e(t)})),r=t.options.some(({value:e})=>_(t.id,e)?.isError);return{...t,options:n,...r&&{failed:r}}}let i=e.fields[t.id],a=(v(t.id,t.id)??[]).flatMap(e=>e.label===void 0?[]:[[String(e.value),e.label]]),o=i?.type===`enum`?(i.enumValues??[]).map(e=>[e,H(e,r?.fields[t.id]?.valueLabels)]):[],s=new Map([...o,...a,...b[n]?.data??[],...S(t.id,n)]),c=(v(t.id,t.id)??[]).flatMap(e=>e.value===null?[]:[{value:String(e.value),label:s.get(String(e.value))??String(e.value),count:e.count}]),l=C[n],u=_(t.id,t.id)?.isError;return{...t,label:d(t.id),...u&&{failed:u},options:l.matches?Dr(l.matches,c):c,...s.size>0&&{labels:Object.fromEntries(s)},...l.onSearch&&{onSearch:l.onSearch}}}),ranges:w.flatMap((e,t)=>{let n=E[t];if(n?.isError)return[{...e,label:d(e.id),min:0,max:0,step:1,histogram:[],format:ht(r,e.id),failed:!0}];let i=n?.data;return!i||i.min===null||i.max===null?[]:[{...e,label:d(e.id),min:Math.floor(i.min),max:Math.ceil(i.max),step:Math.max(1,Math.round((i.max-i.min)/100)),histogram:_t(r,e.id)?i.buckets.map(e=>e.count):[],format:ht(r,e.id)}]}),...u.dateField&&{datePresets:u.datePresets??!0,dateField:u.dateField,dateKind:u.dateKind,...u.dateSecondary&&{dateSecondary:!0}},toggles:u.toggles?.map(e=>({...e,label:d(e.id)}))}},Nr=f(()=>Qe(()=>import(`./import-dialog-bNG6qX6Q.js`).then(e=>e.ImportDialog),__vite__mapDeps([0,1,2,3,4,5,6]))),Pr=f(()=>Qe(()=>import(`./import-table-dialog-BbI7GJ8R.js`).then(e=>e.ImportTableDialog),__vite__mapDeps([7,1,2,3,4,5,6]))),Fr=({model:e})=>{let{resources:t,views:n}=Me(),r=Ie(e.name),i=Ie(wr),[a,o]=(0,Z.useState)(!1),s=n[e.name]?.import;return s===!1||!W(r,`create`)||s===`table`&&!W(i,`create`)?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(V,{onClick:()=>o(!0),"aria-haspopup":`dialog`,children:[(0,X.jsx)(xe,{className:`size-3.5`}),mr(s===`table`?`fromFile`:`import`)]}),a&&s===`table`&&(0,X.jsx)(Pr,{tables:e,resources:t,views:n,onClose:()=>o(!1)}),a&&s!==`table`&&(0,X.jsx)(Nr,{model:e,resources:t,views:n,canUpdate:W(r,`update`),onClose:()=>o(!1)})]})},Ir=()=>{let e=new Worker(new URL(`/assets/export-worker-DfIG4xQy.js`,``+import.meta.url),{type:`module`,name:`protobase-export`}),t=[];return e.onmessage=e=>t.shift()?.resolve(e.data.bytes),e.onerror=e=>{e.preventDefault();let n=Error(Q(`couldNotBuild`,{message:e.message}));for(let e of t.splice(0))e.reject(n)},{send:n=>new Promise((r,i)=>{t.push({resolve:r,reject:i}),e.postMessage(n)}),close:()=>e.terminate()}},Lr={xlsx:{mime:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,extension:`.xlsx`,description:`workbook`},csv:{mime:`text/csv`,extension:`.csv`,description:`csvFile`}},Rr=/[\\/:*?"<>|\u0000-\u001f]/g,zr=(e,t,n=new Date)=>{let r=[n.getFullYear(),String(n.getMonth()+1).padStart(2,`0`),String(n.getDate()).padStart(2,`0`)].join(`-`);return`${e.replace(Rr,` `).trim()} ${r}${Lr[t].extension}`},Br=8e6,Vr=(e,t)=>{let n=new Blob([],{type:Lr[t].mime}),r=[],i=0,a=()=>{n=new Blob([n,...r],{type:Lr[t].mime}),r=[],i=0};return{write:async e=>{e.length!==0&&(r.push(e),i+=e.length,i>=Br&&a())},close:async()=>{a();let t=URL.createObjectURL(n),r=document.createElement(`a`);r.href=t,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(t),6e4)},abort:async()=>{r=[],n=new Blob([])}}},Hr=()=>globalThis.showSaveFilePicker,Ur=()=>typeof Hr()==`function`,Wr=async(e,t)=>{let n=Hr();if(!n)throw Error(`This browser cannot save a file as it is built`);let r=Lr[t],i;try{i=await n({suggestedName:e,types:[{description:Q(r.description),accept:{[r.mime]:[r.extension]}}]})}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;throw e}let a=await i.createWritable();return{write:async e=>{e.length>0&&await a.write(e)},close:()=>a.close(),abort:()=>a.abort()}},Gr=f(()=>Qe(()=>import(`./export-dialog-gSUSlzOy.js`).then(e=>e.ExportDialog),__vite__mapDeps([8,1,2,3,4,5,9,10,11,12,13,14,15,16,17,18,19,20,21]))),Kr=f(()=>Qe(()=>import(`./export-dialog-gSUSlzOy.js`).then(e=>e.ExportProgressDialog),__vite__mapDeps([8,1,2,3,4,5,9,10,11,12,13,14,15,16,17,18,19,20,21]))),qr=(e,t)=>Ur()?Wr(e,t):Promise.resolve(Vr(e,t)),Jr=(e,t)=>{let n=t[e.primaryKey[0]];return typeof n==`object`&&n&&`id`in n?n.id:n},Yr=({model:e,view:t,resources:n,views:r,plural:i,filter:a,orderBy:o,createPort:s=Ir,createSink:c=qr})=>{let l=z(),u=D(),[d,f]=(0,Z.useState)({kind:`closed`}),p=(0,Z.useRef)(void 0),m=(0,Z.useRef)(void 0),h=tt({queryKey:P.exportCount(e.name,a),enabled:d.kind===`settings`,queryFn:async()=>{let t=await l.list(e.name,{filter:a||void 0,pageSize:1,count:`exact`,fields:e.primaryKey});return t.totalSize===void 0?{kind:`estimate`,rows:t.totalSizeEstimate}:{kind:`exact`,rows:t.totalSize}}}).data??{kind:`counting`},g=(e,t=m.current)=>{let n=m.current;n&&n===t&&(m.current=void 0,n.settle(e?[]:n.rows))},v=(t=[])=>(g(!1),f({kind:`settings`,selected:dr(e)?t.map(t=>Jr(e,t)):[]}),new Promise(e=>{m.current={rows:t,settle:e}})),y=()=>{f({kind:`closed`}),g(!1)},x=async(d,v)=>{let y=zr(i,d.format),x=await c(y,d.format);if(!x)return;let S=m.current,C=ur(t,d.format),w=d.scope===`selected`?v.length:pr(h),T=w===void 0?void 0:Math.min(w,C),E=new AbortController;p.current=E,f({kind:`running`,done:0,total:T});try{let c=await Qn({client:l,resource:e.name,filters:d.scope===`selected`?fr(e,v):[a],orderBy:o,plan:{format:d.format,mode:d.mode,name:i,columns:lr(e,t,d.columns)},labels:d.mode===`shown`?_(n,r,e,d.columns):{},limit:C,port:s(),sink:x,signal:E.signal,onProgress:e=>E.signal.aborted||f({kind:`running`,done:e,total:T})});u.show({state:`success`,title:Q(`exported`,{count:L(c.rows),plural:i}),description:c.truncated?Q(`truncated`,{name:y,count:L(c.rows)}):y}),g(!0,S)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;if(!b(e))throw e;u.show({state:`error`,title:Q(`couldNotExport`,{plural:i}),description:e.message})}finally{p.current=void 0,f(e=>e.kind===`running`?{kind:`closed`}:e),g(!1,S)}},S=()=>{p.current?.abort(),y()},C=or(e),w=cr(e,t,C);return{open:v,dialogs:d.kind===`settings`?(0,X.jsx)(Gr,{plural:i,view:t,fields:C.map(e=>({name:e,label:w[e]})),initialColumns:sr(e,t),count:h,selected:d.selected.length>0?d.selected.length:void 0,open:!0,onExport:e=>void x(e,d.selected),onClose:y}):d.kind===`running`?(0,X.jsx)(Kr,{plural:i,done:d.done,total:d.total,onCancel:S}):null}},Xr=({state:e,onClearSearch:t,onClearFilters:n,create:r})=>(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-8 text-center text-muted-foreground`,children:[(0,X.jsx)(`p`,{children:e.message}),(e.clearSearch||e.clearFilters||e.create&&r)&&(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[e.clearSearch&&(0,X.jsx)(V,{onClick:t,children:Y(`clearSearch`)}),e.clearFilters&&(0,X.jsx)(V,{onClick:n,children:Y(`clearFilters`)}),e.create&&r]})]}),Zr=({plural:e,search:t,filtered:n,scoped:r,canCreate:i})=>t?{message:Y(`noMatchSearch`,{plural:e,search:t}),clearSearch:!0,clearFilters:n,create:!1}:n?{message:Y(`noMatchFilters`,{plural:e}),clearSearch:!1,clearFilters:!0,create:!1}:r?{message:Y(`noMatch`,{plural:e}),clearSearch:!1,clearFilters:!1,create:!1}:{message:Y(`noneYet`,{plural:e}),clearSearch:!1,clearFilters:!1,create:i},Qr=(e,t)=>{},$r=({windowMs:e=1e3,comebacks:t=2,onHold:n=Qr}={})=>{let r,i=[],a;return(o,s)=>{if(a?.among.has(o))return a.value;if(a&&(a=void 0,i=[]),o===r||(r=o,i=i.filter(t=>s-t.at<=e),i.push({value:o,at:s,comeback:i.some(e=>e.value===o)}),i.filter(e=>e.comeback).length<t))return o;let c=new Set(i.slice(-2*t).map(e=>e.value));return a={value:Math.min(...c),among:c},n(a.value,[...c]),a.value}},ei=e=>Math.max(1,Math.floor((e+12)/252)),ti=(e,t)=>Math.max(0,(e-(t-1)*12)/t),ni=(e,t,n,r)=>({start:e*n,end:Math.max(0,Math.min(r,(t+1)*n)-1)}),ri=(e,t,n)=>{let r=e/t.rowHeight;return t.columns===n.columns?r*n.rowHeight:Math.floor(Math.floor(r)*t.columns/n.columns)*n.rowHeight},ii=(e,t)=>{let n=e/t.rowHeight;return Math.floor(n)*t.columns+n%1},ai=(e,t)=>Math.floor(Math.floor(e)/t)+e%1,oi=8,si=(e,t,n)=>{let r=e.get(t);if(r!==void 0&&r>=n)return e;let i=new Map(e);i.delete(t),i.set(t,n);for(let e of i.keys()){if(i.size<=oi)break;i.delete(e)}return i},ci=({source:e,label:t,initialIndex:n,onScrollIndex:r,minHeight:i,children:a})=>{let{total:o}=e,[s]=(0,Z.useState)(n),[c,l]=(0,Z.useState)(0),u=ei(c),d=ti(c,u),[f,p]=(0,Z.useState)(()=>new Map),m=Math.ceil(Math.max(i(d),f.get(d)??0)),h=m+12,g={columns:u,rowHeight:h},_=(0,Z.useRef)({layout:g,top:0}),v=_.current.top>0&&(_.current.layout.columns!==u||_.current.layout.rowHeight!==h),y=e=>v?ri(_.current.top,_.current.layout,g):e,b=d>0&&f.has(d),x=rt({total:Math.ceil(o/u),rowHeight:h,initialIndex:ai(s,u),settle:y,ready:b,onScroll:e=>r(ii(e,g))});(0,Z.useLayoutEffect)(()=>{v&&x.scrollTo(x.top),_.current={layout:g,top:x.started()?x.top:0}});let S=ni(x.first,x.last,u,o),C=$t({total:o,rowAt:e.rowAt,loadRows:e.loadRows,cachedRows:e.cachedRows,revision:e.revision,latencyMs:0},S.start,S.end),[w]=(0,Z.useState)(()=>$r());(0,Z.useLayoutEffect)(()=>{let e=x.ref.current;if(!e)return;let t=()=>l(w(e.clientWidth,performance.now())),n=new ResizeObserver(t);return n.observe(e),t(),()=>n.disconnect()},[w]);let T=(0,Z.useRef)(d);T.current=d;let[E]=(0,Z.useState)(()=>new ResizeObserver(e=>{let t=Math.max(...e.map(e=>e.borderBoxSize[0]?.blockSize??e.contentRect.height)),n=T.current;p(e=>si(e,n,t))}));(0,Z.useLayoutEffect)(()=>()=>E.disconnect(),[E]),(0,Z.useLayoutEffect)(()=>{let e=x.ref.current;if(b||d===0||!e)return;let t=[...e.querySelectorAll(`:scope > li[aria-posinset]`)];if(t.length===0)return;let n=Math.max(...t.map(e=>e.getBoundingClientRect().height));p(e=>si(e,d,n))});let ee=(0,Z.useCallback)(e=>{if(e)return E.observe(e),()=>E.unobserve(e)},[E]);return(0,X.jsx)(`ul`,{ref:x.ref,className:`relative min-w-0 flex-auto`,"aria-label":t,style:{height:x.geometry.contentHeight},children:x.rows.flatMap(({index:e,offset:t})=>Array.from({length:u},(n,r)=>{let i=e*u+r;if(i>=o)return[];let s=C(i),c={top:t,left:r*(d+12),width:d,minHeight:m};return s?(0,X.jsx)(`li`,{ref:ee,"aria-posinset":i+1,"aria-setsize":o,className:`absolute grid grid-cols-[minmax(0,1fr)]`,style:c,children:a(s)},s.id):(0,X.jsx)(`li`,{"aria-hidden":!0,className:`absolute grid grid-cols-[minmax(0,1fr)]`,style:c,children:(0,X.jsx)(I,{className:`h-full rounded-lg`})},`skeleton-${i}`)}))})},li=`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,ui=e=>e*.75,di=44,fi=({model:e,view:t,display:n,list:r,empty:i})=>{let a=t?.names?.plural??F(e.name),o=n.card===void 0&&(n.image!==void 0||n.photos!==void 0);return r.isLoading?(0,X.jsx)(`div`,{"aria-busy":!0,className:`min-h-0 flex-1 overflow-hidden ${li}`,children:Array.from({length:6},(e,t)=>(0,X.jsx)(I,{className:`h-24`},t))}):r.error?(0,X.jsx)(je,{title:Be(`couldNotLoadRows`),error:r.error}):!r.source||r.source.total===0?i??(0,X.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:Be(`noneMatch`,{plural:a.toLowerCase()})}):(0,X.jsx)(ci,{source:r.source,label:a,initialIndex:r.initialIndex,onScrollIndex:r.onScrollIndex,minHeight:e=>(o?ui(e):0)+di,children:r=>(0,X.jsx)(Ht,{model:e,view:t,display:n,row:y(e,r)})})},pi=`protobase:list-places`,mi=50,hi=(e,t)=>`${e} ${t}`,gi=e=>{if(typeof e!=`object`||!e)return!1;let{entry:t,url:n,place:r}=e;return typeof t==`string`&&typeof n==`string`&&typeof r==`number`&&Number.isFinite(r)&&r>=0},_i=e=>re(()=>{let t=e.getItem(pi);if(t===null)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(gi):[]},[]),vi=e=>{let t=new Map(_i(e).map(e=>[hi(e.entry,e.url),e]));return{placeOf:(e,n)=>{let r=t.get(hi(e,n));return r?r.place:[...t.values()].findLast(e=>e.url===n)?.place??0},save:(e,n,r)=>{let i=hi(e,n);t.delete(i),t.set(i,{entry:e,url:n,place:r});for(let e of[...t.keys()].slice(0,Math.max(0,t.size-mi)))t.delete(e)},persist:()=>re(()=>e.setItem(pi,JSON.stringify([...t.values()])),void 0)}},yi={getItem:()=>null,setItem:()=>{}},bi,xi=()=>bi??=vi(re(()=>window.sessionStorage,void 0)??yi),Si=()=>{let{entry:e,path:t,params:n}=r(),i=`${t}?${n.toString()}`,a=xi();(0,Z.useEffect)(()=>{let e=()=>a.persist(),t=()=>document.visibilityState===`hidden`&&a.persist();return window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t),a.persist()}},[a]);let o=(0,Z.useCallback)(t=>a.save(e,i,t),[a,e,i]);return{initialIndex:a.placeOf(e,i),remember:o}},Ci=e=>e.reduce((e,t)=>e+t.count,0),wi=e=>{let t=Math.floor(e.length/2),n=Ci(e.slice(0,t)),r=Ci(e.slice(e.length-t));return n===0?0:(r-n)/n*100},Ti=fe(`activity-chart`),Ei=({title:e,defaultGranularity:t=`day`,data:n,granularity:r,onGranularityChange:i,periodLabel:a,state:o,className:s})=>{let[c,l]=(0,Z.useState)(t),u=r??c,d=i??l,f=wi(n),p=n.map(({at:e,count:t})=>({at:e,value:t,count:t}));return(0,X.jsxs)(`section`,{className:h(`rounded-lg border bg-background px-4 pb-2 pt-3`,s),children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`h2`,{className:`font-semibold`,children:e}),o===void 0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`font-semibold tabular-nums`,children:L(Ci(n))}),(0,X.jsxs)(`span`,{className:h(`text-xs font-medium tabular-nums`,f>=0?`text-success-text`:`text-danger-text`),children:[f>=0?`+`:`−`,Math.abs(f).toFixed(1),`%`]})]}),(0,X.jsx)(`span`,{className:`hidden text-xs text-muted-foreground sm:inline`,children:a??`last ${u===`day`?`30 days`:`12 weeks`}`})]}),(0,X.jsx)(_e,{value:u,onChange:d,options:[{value:`day`,label:Ti(`day`)},{value:`week`,label:Ti(`week`)}]})]}),(0,X.jsxs)(`div`,{className:`mt-2`,children:[o===`failed`&&(0,X.jsx)(`p`,{className:`py-6 text-danger-text`,children:Ti(`couldNotLoad`)}),o===`loading`&&(0,X.jsx)(I,{className:`h-24 w-full`}),o===void 0&&(0,X.jsx)(Rt,{points:p,measure:{kind:`count`},bucket:u,type:`bar`,compact:!0})]})]})},Di={"7d":`last 7 days`,"30d":`last 30 days`,"90d":`last 90 days`,"1y":`last year`,all:`all time`},Oi=({resource:e,chart:t,title:n,filter:r})=>{let[i,a]=(0,Z.useState)(t.granularity===`week`?`week`:`day`),o=i===`week`?`90d`:t.range,s=Ee(e,{field:t.field,range:o,granularity:i,filter:r,timeZone:ve()}),c=s.data?.points.map(e=>({at:Date.parse(`${e.bucket}Z`),count:e.count}))??[];return(0,X.jsx)(Ei,{title:n,data:c,granularity:i,onGranularityChange:a,periodLabel:i===`week`?`last 12 weeks`:Di[o],state:s.isError?`failed`:s.isPending?`loading`:void 0})},ki=(e,t,n)=>{let r=e.sum??e.average;if(r===void 0)return n;let i=t?.fields[r]?.label??F(r);return e.sum===void 0?U(`average`,{label:i}):`${i}`},Ai=({model:e,view:t,chart:n,plural:r,filter:i})=>{let a=t?.fields[n.groupBy]?.label??F(n.groupBy);return(0,X.jsxs)(`section`,{className:`rounded-lg border bg-background px-4 pb-3 pt-3`,"aria-label":`${ki(n,t,r)} by ${a.toLowerCase()}`,children:[(0,X.jsxs)(`h2`,{className:`mb-2 font-semibold`,children:[ki(n,t,r),` by `,a.toLowerCase()]}),(0,X.jsx)(At,{model:e,view:t,groupBy:n.groupBy,type:n.type,sum:n.sum,average:n.average,limit:n.limit,filter:i})]})},ji=({value:e,onCommit:t,placeholder:n,className:r})=>{let[i,a]=(0,Z.useState)(e);return(0,Z.useEffect)(()=>a(e),[e]),(0,Z.useEffect)(()=>{if(i===e)return;let n=setTimeout(()=>t(i),350);return()=>clearTimeout(n)},[i,e,t]),(0,X.jsx)(c,{wrapperClassName:h(`min-w-0 flex-1 sm:w-72 sm:flex-initial`,r),leading:(0,X.jsx)(Ce,{className:`size-4`}),placeholder:n,"aria-label":Y(`search`),value:i,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&t(i)})},Mi=(e,t,n,r,i)=>{let a=n?.list?.relatedColumns??[];if(a.length===0)return e;let o=new Map(e.map(e=>[e.id,e]));return Fe(t,n).flatMap(e=>{let t=o.get(e);if(t)return[t];let n=a.find(t=>t.name===e),s=n&&r[n.resource];if(!n||!s)return[];let c=n.label??F(n.name);return[{id:n.name,header:c,kind:`text`,width:160,minWidth:k(c,!1),sortable:!1,render:e=>(0,X.jsx)(bt,{column:n,records:e[n.name]??[],target:s,view:i[s.name],Card:Ht})}]})},Ni=({model:e,view:t,target:n,children:r})=>{let i=gt(e.name,t.listOf,!0),a=t.names?.plural??F(e.name),o=e=>(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[(0,X.jsx)(Qt,{title:a,subtitle:t.help}),e]});if(i.error)return o((0,X.jsx)(je,{title:ot(`couldNotLoadYour`,{plural:a.toLowerCase()}),error:i.error}));if(!i.data)return o((0,X.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(I,{className:`h-24`},t))}));let s=Pt(n,i.data);return s?r(s):o((0,X.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:ot(`noneYet`,{plural:a.toLowerCase()})}))},Pi=({title:e,chips:t,label:n,required:r,initial:i=``,busy:a,onSave:o,onClose:s})=>{let l=(0,Z.useId)(),[u,d]=(0,Z.useState)(i),f=`${l}-form`;return(0,X.jsx)(de,{open:!0,title:e,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:s,children:J(`cancel`)}),(0,X.jsx)(V,{type:`submit`,form:f,variant:`primary`,loading:a,children:J(`save`)})]}),children:(0,X.jsxs)(`form`,{id:f,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o(u.trim()===``?null:u.trim())},children:[t.length>0&&(0,X.jsx)(Tt,{chips:t}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:l,className:`font-medium`,children:n}),!r&&(0,X.jsx)(`span`,{id:`${l}-hint`,className:`text-xs text-muted-foreground`,children:J(`optional`)})]}),(0,X.jsx)(c,{id:l,value:u,required:r,pattern:r?`.*\\S.*`:void 0,"aria-describedby":r?void 0:`${l}-hint`,autoFocus:!0,autoComplete:`off`,onChange:e=>d(e.target.value)})]})]})})},$=M(),Fi={start:0,end:0},Ii=(e,t)=>$.and(t,{kind:`present`,field:e.field,span:Fi}),Li=e=>{switch(e.kind){case`and`:case`or`:return{...e,args:e.args.map(Li)};case`not`:return Ri(e.arg);case`search`:case`present`:case`isNull`:case`related`:return e;default:return Ii(e,e)}},Ri=e=>{switch(e.kind){case`and`:return $.or(...e.args.map(Ri));case`or`:return $.and(...e.args.map(Ri));case`not`:return Li(e.arg);case`search`:case`present`:case`isNull`:case`related`:return $.not(e);default:return Ii(e,$.not(e))}},zi=e=>{let t=pe(e);if(!t.ok)throw Error(`The filter cannot be read: ${t.errors.map(e=>e.message).join(`; `)}`);return t.ast},Bi=e=>e.kind===`and`||e.kind===`or`?e.args.some(Bi):e.kind===`not`?Bi(e.arg):e.kind===`related`,Vi=(e,t)=>![zi(e),zi(t)].some(e=>e&&Bi(e)),Hi=(e,t)=>{let n=zi(e);if(!n)return null;let r=zi(t),i=$.not(Li(n));return v(r?$.and(r,i):i)},Ui=(e,t)=>Hi(t,e),Wi=e=>e.key.startsWith(`extra:`)?`extra:${e.label}`:e.key,Gi=(e,t)=>{let n=new Map(e.map(e=>[Wi(e),e])),r=new Map(t.map(e=>[Wi(e),e])),i=e.filter(e=>!r.has(Wi(e))).map(e=>({kind:`removed`,label:e.label})),a=t.flatMap(e=>{let t=n.get(Wi(e));return t&&t.label!==e.label?[{kind:`changed`,label:e.label,before:t.label}]:[]}),o=t.filter(e=>!n.has(Wi(e))).map(e=>({kind:`added`,label:e.label}));return[...i,...a,...o]},Ki=(e,t,n,r)=>{let i=e-t;if(i===0)return J(`asMany`,{plural:r});let a=Math.abs(i)===1?n:r;return i>0?J(`more`,{count:i,noun:a}):J(`fewer`,{count:-i,noun:a})},qi=12,Ji={added:{word:`added`,className:`text-success-text`},removed:{word:`removed`,className:`text-danger-text`},changed:{word:`changed`,className:`text-primary-text`}},Yi=({changes:e})=>(0,X.jsx)(`ul`,{"aria-label":J(`filterChanges`),className:`divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`grid grid-cols-[72px_1fr] gap-3 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`font-medium ${Ji[e.kind].className}`,children:J(Ji[e.kind].word)}),e.kind===`changed`?(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,X.jsx)(`span`,{className:`font-medium`,children:e.label})]}):(0,X.jsx)(`span`,{className:e.kind===`removed`?`text-muted-foreground line-through`:`font-medium`,children:e.label})]},`${e.kind}:${e.label}`))}),Xi=(e,t)=>{let n=tt({...Ve(z(),e,t??``),enabled:t!==null});return t===null?0:n.data},Zi=(e,t,n)=>`${e} ${e===1?t:n}`,Qi=({model:e,view:t,title:n,filter:r,total:i,plural:a})=>{let o=t?.list?.displays?.find(e=>e.kind===`cards`);return(0,X.jsxs)(`section`,{"aria-label":n,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`h3`,{className:`font-semibold`,children:[n,` `,(0,X.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,i??`…`,`)`]})]}),i!==void 0&&i>qi&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:J(`firstOf`,{limit:qi,total:i})}),r===null||i===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noPlural`,{plural:a})}):(0,X.jsx)(It,{model:e,view:t,filter:r,sort:he(e,t),limit:qi,display:o?.name??`table`,row:!0,link:!1,empty:`No ${a}.`})]})},$i=({model:e,view:t,before:n,after:r})=>{let i=(0,Z.useMemo)(()=>Hi(n,r),[n,r]),a=(0,Z.useMemo)(()=>Ui(n,r),[n,r]),o=Xi(e,i),s=Xi(e,a),c=(t?.names?.singular??F(e.name)).toLowerCase(),l=(t?.names?.plural??F(e.name)).toLowerCase();return(0,X.jsxs)(X.Fragment,{children:[o!==void 0&&s!==void 0?(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`font-semibold`,children:Ki(o,s,c,l)}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`: `,J(`addedRemoved`,{added:Zi(o,c,l),removed:s})]})]}):(0,X.jsx)(I,{className:`h-4 w-48`}),(0,X.jsx)(Qi,{model:e,view:t,title:J(`added`),filter:i,total:o,plural:l}),(0,X.jsx)(Qi,{model:e,view:t,title:J(`removed`),filter:a,total:s,plural:l})]})},ea=({model:e,view:t,title:n,before:r,after:i,saveNewLabel:a,updating:o,creating:s,onUpdate:c,onSaveNew:l,onCancel:u})=>{let d=Gi(it(e,r),it(e,i));return(0,X.jsx)(de,{open:!0,wide:!0,title:n,onClose:u,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:u,children:J(`cancel`)}),(0,X.jsx)(V,{loading:s,disabled:o,onClick:l,children:a}),(0,X.jsx)(V,{variant:`primary`,loading:o,disabled:s,onClick:c,children:J(`update`)})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d.length>0&&(0,X.jsx)(Yi,{changes:d}),Vi(r,i)?(0,X.jsx)($i,{model:e,view:t,before:r,after:i}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noRecordsDiff`)})]})})},ta=()=>{let{address:e,set:t}=se();return{key:e?.kind===`list`?e.savedSearch:void 0,open:e=>t({savedSearch:e})}},na=e=>e instanceof Error?e.message:J(`somethingWrong`),ra=(e,t)=>{let n=Me(),r=z(),i=D(),a=We(),{href:o,open:s}=se(),c=ta(),{resource:l}=e,u=n.resources[l],d=n.views[l]?.searchesOf,f=n.permissions[l],p=u!==void 0&&d!==void 0&&f!==void 0&&W(f,`create`)&&W(f,`delete`),m=n.signIn?.[l]?.signIn,h=Et(l,p),g=e=>Se(Ke(u,e)),_=d&&h.data?.find(e=>e[d.filter]===t),v=_||c.key===void 0||!f||!W(f,`update`)?void 0:h.data?.find(e=>g(e)===c.key),y=n.views[l]?.names,b=y?.plural??`saved searches`,x=d?.name===void 0?void 0:u?.fields[d.name],S=G({mutationFn:e=>r.create(l,{[d.filter]:t,...d.name&&{[d.name]:e}}),onSuccess:e=>{c.open(g(e.record)),i.show({state:`success`,title:J(`searchSaved`),action:{label:J(`openPlural`,{plural:b}),href:o({kind:`list`,resource:l}),onNavigate:s}})},onError:e=>i.show({state:`error`,title:J(`couldNotSave`),description:na(e)}),onSettled:()=>a(l)}),C=G({mutationFn:e=>r.remove(l,g(e)),onError:e=>i.show({state:`error`,title:J(`couldNotTakeOff`),description:na(e)}),onSettled:()=>a(l)}),w=G({mutationFn:e=>r.update(l,g(e),{[d.filter]:t},e.etag??`*`),onSuccess:()=>i.show({state:`success`,title:J(`searchUpdated`)}),onError:e=>i.show({state:`error`,title:J(`couldNotUpdate`),description:na(e)}),onSettled:()=>a(l)}),T=S.isPending||C.isPending||w.isPending;return{mode:p?`save`:m?`sign-in`:void 0,prompt:m,saved:_!==void 0,opened:v&&{filter:String(v[d.filter]??``),name:d.name&&typeof v[d.name]==`string`&&v[d.name]!==``?String(v[d.name]):void 0},noun:(y?.singular??F(l)).toLowerCase(),naming:x&&{label:n.views[l]?.fields[x.name]?.label??F(x.name),required:!x.nullable},ready:h.data!==void 0&&!T,updating:w.isPending,creating:S.isPending,remove:()=>_&&C.mutate(_),saveNew:(e,t)=>S.mutate(e,t),update:e=>v&&w.mutate(v,e)}},ia=({model:e,view:t,search:n,filter:r,chips:i,className:a})=>{let o=ra(n,r),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)();if(!o.mode)return null;let m=n.label??J(`saveSearch`);if(o.mode===`sign-in`)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(V,{className:a,"aria-haspopup":`dialog`,onClick:()=>c(!0),children:[(0,X.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),m]}),(0,X.jsx)(p,{as:`dialog`,prompt:o.prompt,open:s,onClose:()=>c(!1)})]});let h=e=>{u(!1),o.naming?f(e):o.saveNew(null)},g=d!==void 0&&o.naming&&(0,X.jsx)(Pi,{title:d,chips:i,label:o.naming.label,required:o.naming.required,busy:o.creating,onSave:e=>o.saveNew(e,{onSuccess:()=>f(void 0)}),onClose:()=>f(void 0)}),_=o.opened;if(_){let n=J(`saveAsNew`,{noun:o.noun});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(V,{className:a,"aria-haspopup":`dialog`,"aria-disabled":!o.ready,onClick:()=>o.ready&&u(!0),children:[(0,X.jsx)(vn,{className:`size-3.5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`max-w-60 truncate`,children:J(`updateName`,{name:_.name??o.noun})})]}),(0,X.jsxs)(V,{className:a,"aria-haspopup":o.naming?`dialog`:void 0,"aria-disabled":!o.ready,onClick:()=>o.ready&&h(n),children:[(0,X.jsx)(mn,{className:`size-3.5`,"aria-hidden":!0}),n]}),l&&(0,X.jsx)(ea,{model:e,view:t,title:_.name?J(`updateNameQuestion`,{name:_.name}):J(`updateNounQuestion`,{noun:o.noun}),before:_.filter,after:r,saveNewLabel:n,updating:o.updating,creating:o.creating,onUpdate:()=>o.update({onSuccess:()=>u(!1)}),onSaveNew:()=>h(n),onCancel:()=>u(!1)}),g]})}let v=o.saved?fn:ae;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(V,{className:a,"aria-pressed":o.saved,"aria-haspopup":!o.saved&&o.naming?`dialog`:void 0,"aria-disabled":!o.ready,onClick:()=>o.ready&&(o.saved?o.remove():h(m)),children:[(0,X.jsx)(v,{className:o.saved?`size-3.5 text-primary`:`size-3.5`,"aria-hidden":!0}),m]}),g]})},aa=e=>e instanceof Error?e.message:J(`somethingWrong`),oa=({model:e,view:t,name:n,value:r,onChange:i})=>{let a=(0,Z.useId)(),o=e.fields[n],s=t.fields[n],c=s?.label??F(n);if(o?.type===`boolean`)return(0,X.jsx)(w,{checked:r===!0,onChange:i,label:c});if(o?.type!==`enum`)throw Error(`Not implemented: "${n}" is ${o?.type??`unknown`}, and a saved search's controls are enums or booleans`);return(0,X.jsxs)(`label`,{htmlFor:a,className:`flex items-center gap-2 text-muted-foreground`,children:[c,(0,X.jsx)(`select`,{id:a,value:String(r??``),onChange:e=>i(e.target.value),className:`h-8 rounded-md border border-border-strong bg-background px-2 text-foreground shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20`,children:(o.enumValues??[]).map(e=>(0,X.jsx)(`option`,{value:e,children:H(e,s?.valueLabels)},e))})]})},sa=(e,t,n)=>Object.entries(n).map(([n,r])=>`${t.fields[n]?.label??F(n)}: ${e.fields[n]?.type===`boolean`?J(r===!0?`on`:`off`):H(String(r),t.fields[n]?.valueLabels)}`).join(`, `),ca=({model:e,view:t,recordKey:n,title:r,row:i,fields:a})=>{let o=z(),s=D(),c=We(),l=G({mutationFn:t=>o.update(e.name,n,t,i.etag??`*`),onSuccess:(n,i)=>s.show({state:`success`,title:J(`saved`,{title:r}),description:sa(e,t,i)}),onError:e=>s.show({state:`error`,title:J(`couldNotChange`),description:aa(e)}),onSettled:()=>c(e.name)});return(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:a.map(n=>(0,X.jsx)(oa,{model:e,view:t,name:n,value:l.isPending&&n in(l.variables??{})?l.variables[n]:i[n],onChange:e=>l.mutate({[n]:e})},n))})},la=e=>e instanceof Error?e.message:J(`somethingWrong`),ua=({model:e,view:t,of:n,target:r,targetView:i,row:a,recordKey:o,canRename:s,onDelete:c})=>{let l=z(),u=D(),d=We(),[f,p]=(0,Z.useState)(!1),{name:m,chips:h,title:g,body:_}=Wt({model:e,of:n,target:r,targetView:i,row:a,recordKey:o}),v=G({mutationFn:t=>l.update(e.name,o,{[n.name]:t},a.etag??`*`),onSuccess:()=>p(!1),onError:e=>u.show({state:`error`,title:J(`couldNotRename`),description:la(e)}),onSettled:()=>d(e.name)}),y=n.name===void 0?void 0:e.fields[n.name];return(0,X.jsxs)(`section`,{"aria-label":g,className:`flex flex-col gap-3 rounded-lg border bg-surface p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,X.jsx)(C,{to:{kind:`record`,resource:e.name,key:o},className:`hover:underline`,children:m??(0,X.jsx)(wt,{chips:h})})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.controls&&(0,X.jsx)(ca,{model:e,view:t,recordKey:o,title:g,row:a,fields:n.controls}),s&&y&&(0,X.jsx)(V,{variant:`ghost`,"aria-label":J(`renameTitle`,{title:g}),"aria-haspopup":`dialog`,onClick:()=>p(!0),children:(0,X.jsx)(Kt,{className:`size-3.5`,"aria-hidden":!0})}),c&&(0,X.jsx)(V,{variant:`ghost`,"aria-label":J(`deleteTitle`,{title:g}),onClick:()=>c(g),children:(0,X.jsx)(Zt,{className:`size-3.5`,"aria-hidden":!0})})]})]}),f&&y&&(0,X.jsx)(Pi,{title:J(`renameTitle`,{title:g}),chips:h,label:t.fields[y.name]?.label??F(y.name),required:!y.nullable,initial:m,busy:v.isPending,onSave:e=>v.mutate(e),onClose:()=>p(!1)}),(0,X.jsx)(Ut,{..._})]})},da=({model:e,view:t})=>{let{resources:n,views:r}=Me(),i=t.searchesOf,a=n[i.resource],o=r[i.resource],s=Et(e.name,!0),c=Ie(e.name),l=qt({model:e,view:t}),u=t.names?.plural??F(e.name),d=e=>(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[l.dialogs,(0,X.jsx)(Qt,{title:u,subtitle:t.help}),e]});if(!a)return d((0,X.jsx)(ze,{title:J(`notFound`),children:J.rich(`noResource`,{resource:i.resource})}));if(s.error)return d((0,X.jsx)(je,{title:J(`couldNotLoadYour`,{plural:u.toLowerCase()}),error:s.error}));if(!s.data)return d((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:2},(e,t)=>(0,X.jsx)(I,{className:`h-56`},t))}));if(s.data.length===0){let e=(o?.names?.plural??F(a.name)).toLowerCase();return d((0,X.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:J.rich(`noSavedYet`,{plural:u.toLowerCase(),list:(0,X.jsx)(C,{to:{kind:`list`,resource:a.name},className:`font-medium text-primary-text hover:underline`,children:e})})}))}return d((0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:s.data.map(n=>{let r=Se(Ke(e,n)),s=W(c,`delete`)?e=>void l.start({key:r,title:e,etag:n.etag,snapshot:n}):void 0;return(0,X.jsx)(ua,{model:e,view:t,of:i,target:a,targetView:o,row:n,recordKey:r,canRename:W(c,`update`),onDelete:s},r)})}))},fa=({field:e,hints:t,resource:n,stored:r,onSave:i,close:o})=>{let[s,c]=(0,Z.useState)(()=>ee(e,r)),l=(0,Z.useRef)(null),u=(0,Z.useRef)(!1),d=!t?.widget&&(e.type===`boolean`||e.type===`enum`);(0,Z.useEffect)(()=>{l.current?.querySelector(`input, select, textarea, button, [tabindex]`)?.focus()},[]);let f=(t,n,c=s)=>{u.current||(u.current=!0,t&&a(e,c,r)&&i(De(e,c)),o(n))};return(0,X.jsx)(`div`,{ref:l,className:`w-full min-w-0`,onKeyDown:e=>{ce(e.target)||(e.key===`Enter`?(e.preventDefault(),f(!0)):e.key===`Tab`?(e.preventDefault(),f(!0,e.shiftKey?-1:1)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f(!1)))},onBlur:e=>{!l.current?.contains(e.relatedTarget)&&!ce(e.relatedTarget)&&f(!0)},children:(0,X.jsx)(ge,{field:e,hints:t,value:s,stored:r,resource:n,onChange:e=>{c(e),d&&f(!0,void 0,e)}})})},pa=fe(`app/list-edit`),ma=e=>{let t=z(),n=et(),r=D(),[i,a]=(0,Z.useState)(new Map),o=(0,Z.useRef)(i),s=(0,Z.useRef)(new Map),c=(e,t)=>{o.current=new Map(o.current).set(e,{...o.current.get(e),...t}),a(o.current)},l=async(i,a,s)=>{let l=Ke(e,i),u=String(o.current.get(i.id)?.etag??i.etag);try{let r=await t.update(e.name,l,{[a]:s},u);c(i.id,{[a]:r.record[a],etag:r.etag}),n.setQueryData(P.record(e.name,Se(l)),r),n.invalidateQueries({queryKey:[`page`,e.name]}),n.invalidateQueries({queryKey:[`list`,e.name]}),n.invalidateQueries({queryKey:[`map`,e.name]}),n.invalidateQueries({queryKey:[`count`,e.name]})}catch(n){if(!b(n))throw c(i.id,{[a]:i[a]}),n;let o=n.status===412,s=o?await t.get(e.name,l):void 0;c(i.id,s?{[a]:s.record[a],etag:s.etag}:{[a]:i[a]});let u=n.errors.find(e=>e.field===a)?.message??n.message;r.show({state:`error`,title:pa(o?`changedBySomeoneElse`:`couldNotSave`),description:u})}};return{patches:i,save:(e,t,n)=>{c(e.id,{[t]:n});let r=(s.current.get(e.id)??Promise.resolve()).then(()=>l(e,t,n));return s.current.set(e.id,r.catch(()=>void 0)),r}}},ha=(e,t,n)=>{let r=ma(e),i=t?.list?.editable??[];return{editor:i.length>0&&W(n,`update`)?{editable:(t,n)=>i.includes(n)&&e.fields[n]!==void 0&&O(e.fields[n])&&l(t,`update`),render:(n,i,a)=>(0,X.jsx)(fa,{field:e.fields[i],hints:t?.fields[i],resource:e.name,stored:n[i],onSave:e=>void r.save(n,i,e),close:a})}:void 0,patches:r.patches}},ga=M(),_a=e=>e.find(e=>e.kind===`search`),va=({address:e})=>{let{resources:t,views:n,signIn:r}=Me(),i=t[e.resource],a=r?.[e.resource];if(!i)return a?(0,X.jsx)(p,{as:`page`,prompt:a.signIn}):(0,X.jsx)(ze,{title:U(`notFound`),children:U(`noResource`,{name:e.resource})});let o=Ue(n[e.resource],e.list);if(e.list!==void 0&&!o)return(0,X.jsx)(ze,{title:U(`notFound`),children:Y(`noList`,{name:e.list})});if(o?.searchesOf)return(0,X.jsx)(da,{model:i,view:o});let s=j(t,n,e.resource,e.list);if(o&&s.listOf){let t=s.model;return(0,X.jsx)(Ni,{model:i,view:o,target:t,children:n=>(0,X.jsx)(ya,{model:t,address:e,scope:n,heading:{title:o.names?.plural??F(i.name),subtitle:o.help}})})}return(0,X.jsx)(ya,{model:i,address:e})},ya=({model:e,address:t,scope:n,heading:r})=>{let a=Me(),{set:s,listTo:c,go:u,href:d}=se(),f=e.name,p=Ue(a.views[f],t.list),m=(0,Z.useMemo)(()=>ct(p,e),[p,e]),{fields:h}=Te(),g=(0,Z.useMemo)(()=>Mi(ue(Oe(Ae(e,p),e,p,h),e,a.resources,a.views),e,p,a.resources,a.views),[e,p,h,a.resources,a.views]),_=t.filter,v=(0,Z.useMemo)(()=>pt(m,_),[m,_]),b=v.ok?v.state:Gt,x=v.ok?v.extras:[],{orderBy:w,filterLayout:T}=t,E=Ze(),ee=i(),[D,ne]=(0,Z.useState)(!1),re=n?[...x,n]:x,ae=oe(),ce=Mr({model:e,resources:a.resources,views:a.views,view:p,state:b,extras:re,titleOf:ae}),O=n?dt(m,b,re):v.ok?_:``,k=(0,Z.useMemo)(()=>ie(e,p,g.map(e=>e.id)),[e,p,g]),de=(0,Z.useMemo)(()=>st(p,a.resources,a.views,k),[p,a.resources,a.views,k]),A=en({resources:a.resources,views:a.views,model:e,columns:k,filter:O,orderBy:w,related:de}),j=Pe(e,p,t.display),M=Ie(f),N=n?void 0:rn(e,M),[fe,pe]=(0,Z.useState)(!1),P=fe&&N!==void 0,he=!j&&!P&&nn(p,N,w,O),ge=P||j?.kind!==`map`;S(ge);let _e=an(e,A.page,A.key,j?.kind===`custom`),ve=Si(),be=Ne(e,p),xe=e=>({key:e.id,title:String(typeof e[be]==`object`?e[be].name:e[be]??e.id),etag:typeof e.etag==`string`?e.etag:void 0,snapshot:e}),Se=p?.names?.singular??F(f),Ce=ha(e,p,M),{state:I}=Xe(),we=Yt(e),L=qt({model:e,view:p,restore:we,onReview:e=>u({kind:`record`,resource:f,key:e.key})}),Ee=Mt(e),De=p?.actions.some(e=>e.run?.kind===`delete`)??!1,R=(e,t=x)=>s({filter:dt(m,e,t)}),z=_a(x),ke=e=>{let t=x.filter(e=>e.kind!==`search`);R(b,e?[...t,ga.search(e)]:t)},B=p?.names?.plural??F(f),H=j?.kind===`calendar`||j?.kind===`timeline`||j?.kind===`board`&&Le(e)?void 0:j,U=H&&(0,X.jsx)(Dt,{model:e,view:p,display:H,orderBy:w,onChange:e=>s({orderBy:e})}),Re=e.search?.length?(0,X.jsx)(ji,{value:z?.kind===`search`?z.text:``,onCommit:ke,placeholder:Y(`searchPlural`,{plural:B}),className:E?void 0:`min-h-11`}):null,ze=(0,X.jsx)(Xn,{layout:T,config:ce,value:b,onChange:R,leading:T===`bar`?U:void 0,trailing:Re}),Be=T===`bar`?ze:(0,X.jsx)(Jn,{groups:[U?[U]:[]],trailing:Re}),Ve=yt(ce,b),We=(0,X.jsx)(On,{scroll:!0,chips:Ve,onRemove:e=>R(ut(b,e)),onClear:()=>R(Gt)}),Ge=H&&(0,X.jsx)(Fn,{title:Y(`sort`),children:(0,X.jsx)(Dt,{model:e,view:p,display:H,orderBy:w,onChange:e=>s({orderBy:e}),className:`min-h-11 w-full`})}),Qe=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(V,{className:`min-h-11`,onClick:()=>ne(!0),"aria-haspopup":`dialog`,children:[(0,X.jsx)(bn,{className:`size-3.5`}),Ve.length>0?Y(`filtersCount`,{count:Ve.length}):Y(`filters`)]}),Re??(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:We})]}),Re&&We,(0,X.jsx)(Ye,{title:Y(`filters`),open:D,onClose:()=>ne(!1),children:(0,X.jsx)(Xn,{layout:`panel`,fullWidth:!0,config:ce,value:b,onChange:R,leading:Ge})})]}),$e=!n&&o(p,a.pages,M)&&(0,X.jsxs)(C,{to:{kind:`create`,resource:f},className:ye({variant:`primary`}),children:[(0,X.jsx)(Je,{className:`size-3.5`}),Y(`newRecord`,{singular:Se})]}),et=p?.saveSearch&&!n&&v.ok&&_&&(0,X.jsx)(ia,{model:e,view:p,search:p.saveSearch,filter:_,chips:mt(e,p,_,Nt(ce))}),G=!n&&(0,X.jsx)(Fr,{model:e}),tt=Yr({model:e,view:p,resources:a.resources,views:a.views,plural:B,filter:O,orderBy:w}),K=ar(p)&&(0,X.jsxs)(V,{onClick:()=>tt.open(),...!E&&{"aria-label":Y(`export`),title:Y(`export`)},children:[(0,X.jsx)(te,{className:`size-3.5`}),E&&Y(`export`)]}),rt=N&&!he&&(0,X.jsx)(Xt,{sorting:P,onChange:pe,iconOnly:!E}),it=t=>!P&&(0,X.jsx)(Bt,{view:p,choices:me(e,p,ee),value:j?.name??`table`,onChange:e=>s({display:e}),menu:t}),at=tn(e),ot=t=>{at(y(e,t).record),u({kind:`record`,resource:f,key:Ke(e,t)})},lt=async e=>{let t=e.map(xe),n=await L.startBulk(t);return e.filter((e,r)=>n.includes(t[r]))},q=A.source?(0,X.jsx)(vt,{columns:g,source:A.source,sort:He(w),onSortChange:e=>s({orderBy:qe(e)}),onOpenRow:ot,rowLink:t=>({href:d({kind:`record`,resource:f,key:Ke(e,t)}),onFollow:()=>ot(t)}),cellEditor:Ce.editor,rowPatches:Ce.patches,initialScrollIndex:ve.initialIndex,onScrollIndex:ve.remember,rowActions:[{label:Y(`openRecord`,{singular:Se}),onSelect:ot},...Ee.rowActions,...W(M,`delete`)&&!De?[{label:Y(`delete`),destructive:!0,available:e=>l(e,`delete`),onSelect:e=>void L.start(xe(e))}]:[]],bulkActions:[...ar(p)&&dr(e)?[{label:e=>Y(`exportCount`,{count:e}),onRun:e=>tt.open(e)}]:[],...Ee.bulkActions,...W(M,`delete`)?[{label:e=>Y(`deleteCount`,{count:e}),destructive:!0,onRun:e=>lt(e)}]:[]],rowNumbers:!1,pinKey:I.kind===`signed-in`?Ot(I.user.id,le(f,t.list)):void 0,scroll:`parent`,className:`flex-1`}):(0,X.jsx)(`div`,{"aria-busy":!0,className:`flex-1 rounded-lg border bg-surface`}),ft={...A,initialIndex:ve.initialIndex,onScrollIndex:ve.remember},ht=Zr({plural:B,search:z?.kind===`search`?z.text:``,filtered:Ve.length>0,scoped:!!n||x.some(e=>e.kind!==`search`),canCreate:!!$e}),gt=(0,X.jsx)(Xr,{state:ht,onClearSearch:()=>ke(``),onClearFilters:()=>R(Gt),create:$e}),_t=P?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:Y(`dragToSort`)}),(0,X.jsx)(Jt,{model:e,view:p,field:N,filter:``,columns:Fe(e,p)})]}):he?(0,X.jsx)(Jt,{model:e,view:p,field:N,filter:``,columns:Fe(e,p),sort:{value:He(w),onChange:e=>s({orderBy:qe(e)})}}):j?j.kind===`cards`?(0,X.jsx)(fi,{model:e,view:p,display:j,list:ft,empty:gt},A.key.join(` `)):j.kind===`map`?(0,X.jsx)(jt,{model:e,view:p,display:j,filter:O,orderBy:w,fields:k,at:t.map,onMove:e=>s({map:e}),flush:!0}):j.kind===`board`?(0,X.jsx)(kt,{model:e,view:p,display:j,fields:k,filter:O,orderBy:w}):j.kind===`calendar`?(0,X.jsx)(Lt,{model:e,view:p,display:j,fields:k,filter:O,at:t.calendar,linkTo:e=>c({calendar:e})}):j.kind===`timeline`?(0,X.jsx)(Ft,{model:e,view:p,display:j,fields:k,filter:O,at:t.timeline,linkTo:e=>c({timeline:e})}):(0,X.jsx)(Vt,{display:j,list:_e}):A.source?.total===0&&!A.error?gt:q;return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[L.dialogs,tt.dialogs,Ee.prompt,(0,X.jsx)(Qt,{title:r?.title??B,subtitle:r?r.subtitle:p?.help,subtitleBelow:!0,actions:(0,X.jsxs)(X.Fragment,{children:[it(!E),rt,et,G,K,$e]})}),!v.ok&&(0,X.jsx)(je,{title:Y(`unreadableFilter`),error:Error(v.errors.map(e=>e.message).join(`; `))}),A.error&&!j&&!P&&(0,X.jsx)(je,{title:Y(`couldNotLoadRows`),error:A.error}),p?.chart&&!P&&(nt(p.chart)?(0,X.jsx)(Ai,{model:e,view:p,chart:p.chart,plural:B,filter:O}):(0,X.jsx)(Oi,{resource:f,chart:p.chart,title:Y(`created`,{plural:B}),filter:O})),!P&&(E?Be:Qe),E&&T===`panel`&&!P?(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,X.jsx)(`div`,{className:ge?`sticky top-[calc(var(--pb-sticky-top,0px)+1rem)] flex max-h-[calc(100dvh-var(--pb-sticky-top,0px)-var(--pb-sticky-bottom,0px)-2rem)] shrink-0 self-start`:`flex shrink-0`,children:ze}),_t]}):_t]})};export{va as ListPage,xr as a,_r as c,mr as d,pr as f,un as h,Sr as i,hr as l,Q as m,wr as n,vr as o,ur as p,Cr as r,br as s,Er as t,gr as u};
|
|
4
|
-
//# debugId=c8983d85-44e8-4c31-8c2c-caaaad250f6e
|
|
@@ -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{$o as r,Jo as i,Ka as a,Ma as o,Oa as s,Ss as c,Ya as l,Yc as u,Yo as d,Za as f,eo as p,go as m,lc as h,sc as g,ys as _}from"./app-B94YfKGx.js";import{o as v}from"./vendor-t7Q7QbPu.js";import{t as y}from"./page-header-Ddz2r5ic.js";import{n as b,t as x}from"./person-row-DgXLW9D8.js";var S=e(t(),1),C=e(n(),1),w=e=>e?.role===`owner`?[`owner`,`admin`,`member`]:[`admin`,`member`],T=({member:e,current:t,status:n,presence:r,onChanged:i})=>{let{session:o,organizations:c}=_(),u=s(),d=t.organization.id,{busy:h,error:v,run:y}=a(),S=c?.roles??[],T=e.id===t.memberId,E=w(t),D=e.role===`owner`&&t.role!==`owner`,O=S.filter(e=>e.membership);return(0,C.jsx)(x,{name:e.name,email:e.email,self:T,error:v,...(n||r)&&{status:(0,C.jsx)(m,{status:n,presence:r})},actions:(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`select`,{"aria-label":u(`roleOf`,{name:e.name}),value:e.role,disabled:h||D,onChange:t=>void y(async()=>{await o.organizations.setRole(d,e.id,t.target.value),i()}),className:`h-7 rounded-md border border-border-strong bg-background px-2 text-body`,children:(D?[e.role]:E).map(e=>(0,C.jsx)(`option`,{value:e,children:f(e)},e))}),!T&&(0,C.jsx)(g,{size:`sm`,variant:`danger`,loading:h,disabled:D,onClick:()=>void y(async()=>{await o.organizations.removeMember(d,e.id),i()}),children:p(`remove`)})]}),children:(0,C.jsx)(b,{roles:O,selected:e.appRoles,grantable:l(S,t),disabled:h,onChange:t=>void y(async()=>{await o.organizations.setAppRoles(e.id,t),i()})})})},E=({current:e,statuses:t,presence:n})=>{let{session:a}=_(),l=s(),f=e?.organization?.id,m=v({queryKey:u.organizationMembers(f??``),queryFn:()=>a.organizations.members(f),enabled:!!f,retry:!1}),g=m.data,b=m.error?m.error instanceof c?r(m.error):p(`couldNotReadMembers`):void 0,{refetch:x}=m,w=(0,S.useCallback)(()=>void x(),[x]);return e?.organization?(0,C.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,C.jsx)(y,{title:p(`members`),subtitle:p(`whoWorks`,{organization:e.organization.name})}),(0,C.jsxs)(i,{title:p(`members`),description:l(`membersDescription`),children:[(0,C.jsx)(d,{message:b}),g?(0,C.jsx)(`ul`,{className:`divide-y rounded-md border`,children:g.map(r=>(0,C.jsx)(T,{member:r,current:e,status:t?.find(e=>e.userId===r.userId),presence:o(n,r.userId),onChanged:w},`${r.id}/${r.role}/${r.appRoles.join()}`))}):!b&&(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,C.jsx)(h,{}),` `,p(`loading`)]})]})]}):null};export{E as MembersPage,w as assignableOrganizationRoles};
|
|
2
|
-
//# debugId=1972ace5-42ee-4fa2-8023-aab7042a7f01
|