@objectstack/console 17.6.0 → 17.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +428 -0
- package/dist/.objectstack-injection.json +2 -2
- package/dist/.objectui-sha +1 -1
- package/dist/assets/{ActionResultDialog-4kHDGnT3.js → ActionResultDialog-ChYnuROr.js} +3 -3
- package/dist/assets/{AiPendingActionsPage-JjOddm0h.js → AiPendingActionsPage-Dh3-i4BB.js} +1 -1
- package/dist/assets/{ApiConsolePage-BgS26lbp.js → ApiConsolePage-CKYEqlMs.js} +1 -1
- package/dist/assets/{AppDocsIndex-BDoH5ECM.js → AppDocsIndex-B5Tky2xg.js} +1 -1
- package/dist/assets/{AppManagementPage-CCgKmNTj.js → AppManagementPage-ZwyvnHpM.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-DD4fe0Em.js +1 -0
- package/dist/assets/AuditLogPage-Sed6iMqP.js +1 -0
- package/dist/assets/BookPage-DYjUsQIc.js +1 -0
- package/dist/assets/{ComponentNavView-B5g9c6fx.js → ComponentNavView-DrlxM4SY.js} +1 -1
- package/dist/assets/CreateViewDialog-Cp72x_O7.js +1 -0
- package/dist/assets/{DashboardView-BOcovpPd.js → DashboardView-juicRxcP.js} +1 -1
- package/dist/assets/DocPage-CxJaQ-pC.js +1 -0
- package/dist/assets/{DocsIndex-DwW2QsYY.js → DocsIndex-LALVtIVR.js} +1 -1
- package/dist/assets/{DocsLayout-D63StSgd.js → DocsLayout-BAwlJQQf.js} +1 -1
- package/dist/assets/{DocsSlug-CP9fcabi.js → DocsSlug-CkF1E-Zs.js} +1 -1
- package/dist/assets/ExpressionProvider-Dr0e99r1.js +1 -0
- package/dist/assets/FlowRunsPage-R3W3t2s4.js +1 -0
- package/dist/assets/{IntegrationsPage-DvG0x0Nb.js → IntegrationsPage-DIuFLEbF.js} +2 -2
- package/dist/assets/InterfaceListPage-BfoCldGu.js +1 -0
- package/dist/assets/{MarketplaceInstalledPage-B7KETQG2.js → MarketplaceInstalledPage-DyjhcUNB.js} +1 -1
- package/dist/assets/MarketplacePackagePage-BbO27Pgs.js +4 -0
- package/dist/assets/MarketplacePage-DO2_b64U.js +1 -0
- package/dist/assets/{MetadataInspector-EP0I3-Kq.js → MetadataInspector-BQyu9pOE.js} +1 -1
- package/dist/assets/ObjectDataPage-DIY-yefK.js +1 -0
- package/dist/assets/PageView-C-qWu3Jw.js +1 -0
- package/dist/assets/ProfilePage-Qp8DL8CF.js +1 -0
- package/dist/assets/{PublicFormsPage-D3uCTR-8.js → PublicFormsPage-D3AT2EH9.js} +1 -1
- package/dist/assets/RecordDetailView-B3XBEgk2.js +3 -0
- package/dist/assets/{RecordFormPage-kiJI-ieF.js → RecordFormPage-CcoZfUJ3.js} +1 -1
- package/dist/assets/ReportDefaultInspector-DVcWM6sh.js +1 -0
- package/dist/assets/ReportView-pJCFptzp.js +2 -0
- package/dist/assets/RuntimeDraftBar-DObTyFu2.js +1 -0
- package/dist/assets/SchemaForm-BWSWYMLE.js +3 -0
- package/dist/assets/SearchResultsPage-ChVIzFob.js +1 -0
- package/dist/assets/{SettingsHub-DP1mrzEN.js → SettingsHub-CPP9FDe8.js} +1 -1
- package/dist/assets/{SettingsView-u7mc6pcc.js → SettingsView-CrHAROu9.js} +1 -1
- package/dist/assets/{SkeletonDetail-DIwlbHTr.js → SkeletonDetail-CP-35B8x.js} +1 -1
- package/dist/assets/{af-DPUgkQl0.js → af-Bhbso4Pg.js} +1 -1
- package/dist/assets/ai-BAPiCsNk.js +3 -0
- package/dist/assets/app-shell-eager-leaves-D9tgfJOe.js +1 -0
- package/dist/assets/{ar-B-6GTIRU.js → ar-DG8TAFtm.js} +1 -1
- package/dist/assets/{ar-DZ-wEl298ti.js → ar-DZ-BtSien-d.js} +1 -1
- package/dist/assets/{ar-EG-YBT90_S0.js → ar-EG-DpXC0zoY.js} +1 -1
- package/dist/assets/{ar-MA-3uT-EYh6.js → ar-MA-D1qVJLyE.js} +1 -1
- package/dist/assets/{ar-SA-SiQsjhhc.js → ar-SA-BIYKNgv8.js} +1 -1
- package/dist/assets/{ar-TN-CfzXjKzS.js → ar-TN-mUR5Mq3s.js} +1 -1
- package/dist/assets/{az-BqAfcNza.js → az-B7IqwHGK.js} +1 -1
- package/dist/assets/{be-CQgWXa9_.js → be-CnZyPaSX.js} +1 -1
- package/dist/assets/{be-tarask-BmNg0Sir.js → be-tarask--uMMCC7l.js} +1 -1
- package/dist/assets/{bg-D3evgRuS.js → bg-CZwuirtY.js} +1 -1
- package/dist/assets/{bn-uItkARwm.js → bn-BbOX0r-z.js} +1 -1
- package/dist/assets/{bs-DueReOpO.js → bs-B5W75cYR.js} +1 -1
- package/dist/assets/{ca-Cr3AHktR.js → ca-Be69LdIM.js} +1 -1
- package/dist/assets/{ckb-CTi5BET7.js → ckb-B-nKM1Vn.js} +1 -1
- package/dist/assets/{createDerive-CjN1i5vn.js → createDerive-CynsXU-B.js} +1 -1
- package/dist/assets/{cs-43mFX9jr.js → cs-qHngxH7l.js} +1 -1
- package/dist/assets/{cy-BBSkg3F8.js → cy-DscO2Pgf.js} +1 -1
- package/dist/assets/{da-C5oA5qcs.js → da-vibkaLMF.js} +1 -1
- package/dist/assets/data-adapter-BDsrq0TX.js +2 -0
- package/dist/assets/{de-AT-CApxwJzu.js → de-AT--JneEuBw.js} +1 -1
- package/dist/assets/{de-CPtbLlAf.js → de-BCT78XYW.js} +1 -1
- package/dist/assets/default-inspector-registry-Dktr6x_q.js +1 -0
- package/dist/assets/dist-yh3dYtHt.js +14 -0
- package/dist/assets/drillUrlFilters-N0RngQg6.js +1 -0
- package/dist/assets/{el-Dto2xBQU.js → el-Cl0y9T2b.js} +1 -1
- package/dist/assets/en-AU-By42tTB7.js +1 -0
- package/dist/assets/{en-CA-DKuJPN1U.js → en-CA-BqEEoj-Y.js} +1 -1
- package/dist/assets/en-GB-Cx8B9nkB.js +1 -0
- package/dist/assets/en-IE-CX9nv6uO.js +1 -0
- package/dist/assets/en-IN-ByGSBHa4.js +1 -0
- package/dist/assets/en-NZ-BPMwa2ZN.js +1 -0
- package/dist/assets/en-ZA-lj_N4R6c.js +1 -0
- package/dist/assets/{eo-BL8JXIWd.js → eo-oOXROuhF.js} +1 -1
- package/dist/assets/{es-BnoaNxsu.js → es-EudscwjH.js} +1 -1
- package/dist/assets/{et-tPYLNenO.js → et-CB-5LLh6.js} +1 -1
- package/dist/assets/{eu-CUBG6bT0.js → eu-B4-hcseX.js} +1 -1
- package/dist/assets/{fa-IR-Rr2d9xSs.js → fa-IR-CogavcMJ.js} +1 -1
- package/dist/assets/{fi-B0NVIZsV.js → fi-CIBE0mYa.js} +1 -1
- package/dist/assets/{formatLong-1-gt9bpo.js → formatLong-qqgm7lV1.js} +1 -1
- package/dist/assets/{fr-CA-CBDvLXFg.js → fr-CA-BugXMutW.js} +1 -1
- package/dist/assets/{fr-BbhHek8e.js → fr-CDReXYWW.js} +1 -1
- package/dist/assets/{fr-CH-WPNmwPn7.js → fr-CH-fiTiB6X1.js} +1 -1
- package/dist/assets/framework-CAuH4h0L.js +35 -0
- package/dist/assets/{fy-DvOBbvEF.js → fy-t_GzIAg_.js} +1 -1
- package/dist/assets/{gd-BQPiTPX5.js → gd-CSncIxtN.js} +1 -1
- package/dist/assets/getIcon-BDkBRQFw.js +1 -0
- package/dist/assets/{gl-BJCXK8uO.js → gl-_138Mj2S.js} +1 -1
- package/dist/assets/{gu-CctPRz3V.js → gu-COfH-YUT.js} +1 -1
- package/dist/assets/{he-CVFMk6p2.js → he-BXL4lOKY.js} +1 -1
- package/dist/assets/{hi-Ba30-RwS.js → hi-kXuYI0TJ.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-BQ57IrBV.js → highlighted-body-OFNGDK62-CK7x7Gzm.js} +1 -1
- package/dist/assets/{hr-BZUqTbZs.js → hr-DAOsQWzI.js} +1 -1
- package/dist/assets/{ht-BLe05tPx.js → ht-Ch8SKz8p.js} +1 -1
- package/dist/assets/{hu-2CQ_Mkww.js → hu-q6W_rWPT.js} +1 -1
- package/dist/assets/{hy-CclcPG4H.js → hy-0M8OmwnM.js} +1 -1
- package/dist/assets/{i18n-BnUsCaSC.js → i18n-DTfZonAM.js} +3 -3
- package/dist/assets/i18n-locale-ar-O6rs-Cir.js +4 -0
- package/dist/assets/i18n-locale-de-CMc1jk4a.js +4 -0
- package/dist/assets/i18n-locale-en-CbRQO81h.js +4 -0
- package/dist/assets/i18n-locale-es-t47nyoCX.js +4 -0
- package/dist/assets/i18n-locale-fr-E425EqJM.js +4 -0
- package/dist/assets/i18n-locale-ja-y_fk77fz.js +4 -0
- package/dist/assets/i18n-locale-ko-CdnY2uCg.js +4 -0
- package/dist/assets/i18n-locale-pt-BaUOXS6y.js +4 -0
- package/dist/assets/i18n-locale-ru-pFlhX9wg.js +4 -0
- package/dist/assets/i18n-locale-zh-Dkj4ROTN.js +4 -0
- package/dist/assets/i18n-runtime-CdWyaiOD.js +1 -0
- package/dist/assets/{id-6JLB8s-f.js → id-BM_H1_jv.js} +1 -1
- package/dist/assets/index-ocmkyCt6.js +19 -0
- package/dist/assets/index-v2Ijn9Gr.css +2 -0
- package/dist/assets/{infrastructure-Cc34lEqb.js → infrastructure-CSnL6ntj.js} +2 -2
- package/dist/assets/integration-7NqwVHuJ.js +1 -0
- package/dist/assets/{is-to0CWzm1.js → is-B_7jXZfS.js} +1 -1
- package/dist/assets/isSameWeek-D90tBsli.js +1 -0
- package/dist/assets/{it-ea0B8Ujp.js → it-CBM0J9cD.js} +1 -1
- package/dist/assets/{it-CH-DhdfjP5Z.js → it-CH-BQltCNsR.js} +1 -1
- package/dist/assets/{ja-B1bzkgDW.js → ja-DBjnsx21.js} +1 -1
- package/dist/assets/{ja-Hira-CMrY5hXO.js → ja-Hira-BZfSmj1i.js} +1 -1
- package/dist/assets/{ka-DKSXLnXP.js → ka-HwpuKgUY.js} +1 -1
- package/dist/assets/{kk-DHwMv8Dn.js → kk-DLKA9paj.js} +1 -1
- package/dist/assets/{km-tpLG1xNr.js → km-BU5kermq.js} +1 -1
- package/dist/assets/{kn-MLreVnHA.js → kn-BNFqbCoi.js} +1 -1
- package/dist/assets/{ko-CI0DBazn.js → ko-D8n4uMqQ.js} +1 -1
- package/dist/assets/{lb-CmL572Xe.js → lb-B1empQ7m.js} +1 -1
- package/dist/assets/{lt-DRtUOLdw.js → lt-gMukpK3G.js} +1 -1
- package/dist/assets/{lv-COSHgkOP.js → lv-D2O5AnsZ.js} +1 -1
- package/dist/assets/{match-BQoOW8Cj.js → match-BTF6WqJh.js} +1 -1
- package/dist/assets/{match-B-ergJQb.js → match-Cyum2eeW.js} +1 -1
- package/dist/assets/{match-dfBS0YSQ.js → match-ScHH8kYk.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-D4H6EVJQ.js +1 -0
- package/dist/assets/metadata-admin-CEhVmXFv.js +9 -0
- package/dist/assets/{mk-B0IH_YL_.js → mk-D-Zl0xVN.js} +1 -1
- package/dist/assets/{mn-P-QdQ2n3.js → mn-jJbTslgD.js} +1 -1
- package/dist/assets/{ms-CtyEOINy.js → ms-CUuJHLA4.js} +1 -1
- package/dist/assets/{mt-DfuZ2HRm.js → mt-yIcbfxKY.js} +1 -1
- package/dist/assets/{nb-2Hp-5Tnt.js → nb-D9WNypoj.js} +1 -1
- package/dist/assets/{nl-BE-mmxbfNoR.js → nl-BE-B1vKiw2h.js} +1 -1
- package/dist/assets/{nl-CZ_nLREz.js → nl-DC7b5e90.js} +1 -1
- package/dist/assets/{nn-ccWhYsNa.js → nn-uP4yJ9s0.js} +1 -1
- package/dist/assets/{oc-z504BFRV.js → oc-DHTqadJI.js} +1 -1
- package/dist/assets/{pl-DeQ7ASt-.js → pl-Bxnnizf5.js} +1 -1
- package/dist/assets/plugin-calendar-b7C35ANT.js +1 -0
- package/dist/assets/plugin-charts-b-yVtmdI.js +7 -0
- package/dist/assets/{plugin-chatbot-Ck47EhDX.js → plugin-chatbot-D1KW_oIO.js} +8 -8
- package/dist/assets/plugin-dashboard-DTkPoPEb.js +6 -0
- package/dist/assets/plugin-form-UIRm-FpQ.js +1 -0
- package/dist/assets/plugin-gantt-9dtc8zzX.js +63 -0
- package/dist/assets/plugin-grid-Cp4RKtMJ.js +10 -0
- package/dist/assets/plugin-kanban-B2JOPZIJ.js +1 -0
- package/dist/assets/plugin-map-CBJcVJYk.js +1 -0
- package/dist/assets/{plugin-markdown-BOkHcir_.js → plugin-markdown-CNlDzqP-.js} +1 -1
- package/dist/assets/plugin-report-IZzgQb-Q.js +59 -0
- package/dist/assets/plugin-timeline-DsmtjcJ3.js +1 -0
- package/dist/assets/plugin-tree-DTRPBdhe.js +1 -0
- package/dist/assets/plugin-view-D9ixsNDG.js +1 -0
- package/dist/assets/plugins-views-CnvkdSJK.js +3 -0
- package/dist/assets/{pt-BR-D80_lPYF.js → pt-BR-D416seHT.js} +1 -1
- package/dist/assets/{pt-CJJ1RmXd.js → pt-DwHBy9_c.js} +1 -1
- package/dist/assets/{ro-EuFb2TCj.js → ro-DDf1X3Np.js} +1 -1
- package/dist/assets/{ru-CMaVQScp.js → ru-8eM3mcgK.js} +1 -1
- package/dist/assets/{runtime-metadata-persistence-ClOTznqa.js → runtime-metadata-persistence-DX29lQ62.js} +1 -1
- package/dist/assets/{se-DsfdKLdF.js → se-D4JvQeRX.js} +1 -1
- package/dist/assets/{sk-BNV9omI8.js → sk-DvpgttGI.js} +1 -1
- package/dist/assets/{sl-DJS_nINU.js → sl-B3gCZ-_a.js} +1 -1
- package/dist/assets/{sq-HEgjcbHe.js → sq-CVaTmL0V.js} +1 -1
- package/dist/assets/{sr-CO0CFu4X.js → sr-CnH5Ffyz.js} +1 -1
- package/dist/assets/{sr-Latn-eE1Idzey.js → sr-Latn-Dw9w61q6.js} +1 -1
- package/dist/assets/src-BUry7633.js +2 -0
- package/dist/assets/{src-BU7L2v4J.js → src-DMDT5a27.js} +1 -1
- package/dist/assets/src-ZxH3AOCu.js +16 -0
- package/dist/assets/{studioEntry-WeMfaSGn.js → studioEntry-DAqcBFtr.js} +1 -1
- package/dist/assets/{submitRedirect-C2lfZSHt.js → submitRedirect-iy0oOi7I.js} +1 -1
- package/dist/assets/{sv-5uTzgQT3.js → sv-CU7wdxyK.js} +1 -1
- package/dist/assets/{ta-BzgdkBZG.js → ta-DPH6q0HR.js} +1 -1
- package/dist/assets/{te-Ct_pl7ZJ.js → te-BSaThkGV.js} +1 -1
- package/dist/assets/{th-DouAlk0-.js → th-NXP8_Qb8.js} +1 -1
- package/dist/assets/{tr-3XNBsI40.js → tr-DDXoH663.js} +1 -1
- package/dist/assets/types-zod-ChJ30y25.js +1 -0
- package/dist/assets/{ug-B9n24h9G.js → ug-Guus6pPe.js} +1 -1
- package/dist/assets/ui-components-D8wcRNrt.js +37 -0
- package/dist/assets/ui-layout-BYO3rRIl.js +1 -0
- package/dist/assets/{uk-DCAenByf.js → uk-uiy4vsp8.js} +1 -1
- package/dist/assets/use-book-data-DFTswcKm.js +1 -0
- package/dist/assets/{useActionModal-Blp4rhOk.js → useActionModal-h52Z5Pkl.js} +1 -1
- package/dist/assets/useCanAuthorMetadata-TDrVrYGB.js +1 -0
- package/dist/assets/useDatasetCatalog-BOd0Ybr1.js +1 -0
- package/dist/assets/{useNavTargetLabel-BOJncjIb.js → useNavTargetLabel-D8lRdb6O.js} +1 -1
- package/dist/assets/useOpenRecordList-C7oqUD3F.js +1 -0
- package/dist/assets/{usePackageL10n-Ci9uVkRZ.js → usePackageL10n-Jl2XiF2F.js} +1 -1
- package/dist/assets/{useSettingsLabel-CeMnMWsh.js → useSettingsLabel-CSpBDTdy.js} +1 -1
- package/dist/assets/{uz-Cyrl-JSeHEqu-.js → uz-Cyrl-Cmb5bvbf.js} +1 -1
- package/dist/assets/{uz-DT3s9bZS.js → uz-DJWxoTz4.js} +1 -1
- package/dist/assets/vendor-objectstack-C4eD5dbT.js +139 -0
- package/dist/assets/{vi-D2p-h6bY.js → vi-Bb3QoIJC.js} +1 -1
- package/dist/assets/{zh-CN-DHOKqAit.js → zh-CN-C-Hts1ZR.js} +1 -1
- package/dist/assets/{zh-HK-D4iIPY7I.js → zh-HK-CtBAZ_ZS.js} +1 -1
- package/dist/assets/{zh-TW-gORQ_tZh.js → zh-TW-B7DDahD-.js} +1 -1
- package/dist/chunk-membership.json +28 -26
- package/dist/eager-closure.json +107 -101
- package/dist/index.html +4 -4
- package/dist/sdui.manifest.json +486 -63
- package/package.json +1 -1
- package/dist/assets/ApprovalsInboxPage-C6S1vk0X.js +0 -1
- package/dist/assets/AuditLogPage-v2dKXMuk.js +0 -1
- package/dist/assets/BookPage-DwFMcTSN.js +0 -1
- package/dist/assets/CreateViewDialog-D3l-tYHM.js +0 -1
- package/dist/assets/DocPage-B6AkH5WI.js +0 -1
- package/dist/assets/ExpressionProvider-CrL6jhVq.js +0 -1
- package/dist/assets/FlowRunsPage-CxdaiUyk.js +0 -1
- package/dist/assets/InterfaceListPage-C4wPYohR.js +0 -1
- package/dist/assets/MarketplacePackagePage-CfgKDpNH.js +0 -4
- package/dist/assets/MarketplacePage-DNEyU5AE.js +0 -1
- package/dist/assets/ObjectDataPage-CykEm9MD.js +0 -1
- package/dist/assets/PageView-C6u86tni.js +0 -1
- package/dist/assets/ProfilePage-C3SjXMzi.js +0 -1
- package/dist/assets/RecordDetailView-DgR_zhP4.js +0 -3
- package/dist/assets/ReportDefaultInspector-BIinF0EQ.js +0 -1
- package/dist/assets/ReportView-BREO-ADE.js +0 -2
- package/dist/assets/RuntimeDraftBar-BCWfd2yS.js +0 -1
- package/dist/assets/SchemaForm-C4uMMZ13.js +0 -3
- package/dist/assets/SearchResultsPage-C6Hw_Lpn.js +0 -1
- package/dist/assets/ai-DPBykF2N.js +0 -3
- package/dist/assets/app-shell-eager-leaves-Cf2bM6uT.js +0 -1
- package/dist/assets/data-adapter-Cymvlczj.js +0 -1
- package/dist/assets/default-inspector-registry-Bs6GBn00.js +0 -1
- package/dist/assets/dist-BF-ssUpn.js +0 -14
- package/dist/assets/drillUrlFilters-hi-2d3DW.js +0 -1
- package/dist/assets/en-AU-FVwCiDJO.js +0 -1
- package/dist/assets/en-GB-DQ_y5VbJ.js +0 -1
- package/dist/assets/en-IE-DaXOhsZW.js +0 -1
- package/dist/assets/en-IN-CnRZnAom.js +0 -1
- package/dist/assets/en-NZ-CBZLEToK.js +0 -1
- package/dist/assets/en-ZA-BE59v0wZ.js +0 -1
- package/dist/assets/framework-DFR4HNtj.js +0 -35
- package/dist/assets/getIcon-Cfwf-Egt.js +0 -1
- package/dist/assets/i18n-locale-ar-92O_xtDZ.js +0 -4
- package/dist/assets/i18n-locale-de-T5ic3yH9.js +0 -4
- package/dist/assets/i18n-locale-en-rxr7WJYl.js +0 -4
- package/dist/assets/i18n-locale-es-D_WOifJ_.js +0 -4
- package/dist/assets/i18n-locale-fr-3cvyjMkp.js +0 -4
- package/dist/assets/i18n-locale-ja-DXlIkB8I.js +0 -4
- package/dist/assets/i18n-locale-ko-DngRpS45.js +0 -4
- package/dist/assets/i18n-locale-pt-BkPaFCqZ.js +0 -4
- package/dist/assets/i18n-locale-ru-E5wLh-y6.js +0 -4
- package/dist/assets/i18n-locale-zh-BL4_Yand.js +0 -4
- package/dist/assets/i18n-runtime-97_bDVjP.js +0 -1
- package/dist/assets/index-Cadlh4t_.css +0 -2
- package/dist/assets/index-D98sa5GF.js +0 -20
- package/dist/assets/integration-CeAF4JFT.js +0 -1
- package/dist/assets/isSameWeek-DBXaA1Gd.js +0 -1
- package/dist/assets/mermaid-GHXKKRXX-Bb17TtNP.js +0 -1
- package/dist/assets/metadata-admin-CABUxbJl.js +0 -9
- package/dist/assets/plugin-calendar-Cn5HaZU8.js +0 -1
- package/dist/assets/plugin-charts-B6RcFWbo.js +0 -7
- package/dist/assets/plugin-dashboard-DjEx8e5Y.js +0 -6
- package/dist/assets/plugin-form-CLDvL0up.js +0 -1
- package/dist/assets/plugin-gantt-CrVrxVdi.js +0 -63
- package/dist/assets/plugin-grid-D2rmQEW_.js +0 -11
- package/dist/assets/plugin-kanban-BUNHFfIC.js +0 -1
- package/dist/assets/plugin-map-y-7RQQC5.js +0 -1
- package/dist/assets/plugin-report-mT3jpna0.js +0 -59
- package/dist/assets/plugin-timeline-B1EF83D3.js +0 -1
- package/dist/assets/plugin-tree-MTHUt3_S.js +0 -1
- package/dist/assets/plugin-view-DHJI-ahf.js +0 -1
- package/dist/assets/plugins-views-CfkgqD30.js +0 -3
- package/dist/assets/src-BUtIBFDA.js +0 -1
- package/dist/assets/src-C0eXlKtx.js +0 -16
- package/dist/assets/types-zod-DXpXw10W.js +0 -1
- package/dist/assets/ui-components-D6cEVg0T.js +0 -37
- package/dist/assets/ui-layout-DgVDuPEM.js +0 -1
- package/dist/assets/use-book-data-CwRldFxP.js +0 -1
- package/dist/assets/useCanAuthorMetadata-BxCMgFRf.js +0 -1
- package/dist/assets/useOpenRecordList-BrwJFojQ.js +0 -1
- package/dist/assets/vendor-objectstack-DFqu45yM.js +0 -138
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{h as n,p as r,r as i,t as a,v as o}from"./vendor-react-BggL7APJ.js";import{Bn as s,Gi as c,Hi as l,Ht as u,Jt as d,Mn as f,Ui as p,Vt as m,Yn as h,hn as g,ni as _,nr as v,ta as y,xn as b}from"./vendor-objectstack-C4eD5dbT.js";import{$ as x,$n as S,$t as C,A as w,An as T,B as E,Bn as D,Br as O,Ct as k,D as A,Dn as j,E as M,En as N,F as ee,Fr as P,G as te,Gn as ne,Gr as re,H as F,Hn as I,Hr as L,I as ie,Ir as R,Jn as z,Jt as ae,Kn as oe,L as B,Ln as se,Lr as ce,M as le,Mr as ue,N as de,Nr as fe,O as pe,On as me,P as V,Pr as he,Q as ge,Qt as _e,R as ve,Rn as ye,Rr as be,S as H,Si as U,St as xe,Tn as Se,U as Ce,V as we,Vn as Te,Vr as Ee,W as De,Wr as Oe,Wt as ke,X as Ae,Yn as je,Z as Me,_ as Ne,_i as Pe,ai as W,an as Fe,bi as G,bt as K,c as Ie,ci as Le,d as Re,di as ze,en as Be,er as Ve,et as He,f as Ue,fi as We,ft as Ge,g as Ke,gi as qe,h as Je,hi as Ye,ht as Xe,i as Ze,ii as Qe,in as q,j as $e,jr as et,jt as tt,k as nt,kn as J,l as rt,li as Y,lr as it,lt as X,mi as at,n as ot,nn as st,o as ct,oi as lt,on as ut,pi as dt,pt as ft,q as pt,qn as mt,qt as ht,r as gt,rn as _t,rr as vt,si as yt,sn as bt,tn as xt,tr as St,u as Ct,ui as wt,v as Tt,vi as Et,wi as Dt,x as Ot,xi as kt,xt as At,y as jt,z as Mt,zn as Nt,zr as Pt}from"./ui-components-D8wcRNrt.js";import{$i as Ft,$r as It,$t as Lt,Ar as Rt,At as zt,B as Bt,Bi as Vt,Br as Ht,Bt as Ut,D as Wt,Dt as Gt,E as Kt,Ei as qt,Et as Jt,Fi as Yt,Fr as Xt,Ft as Zt,Gi as Qt,Gr as $t,Hr as en,Ht as tn,Ir as nn,It as rn,Jr as an,Jt as on,K as sn,Kr as cn,Kt as ln,Lr as un,Mi as dn,Mr as fn,Nr as pn,Nt as mn,Or as hn,Ot as gn,Pi as _n,Pr as vn,Pt as yn,Qi as Z,Qr as bn,Qt as xn,Rr as Sn,Rt as Cn,T as wn,Ti as Tn,Tr as En,Tt as Dn,Un as On,V as kn,Vr as An,Wr as jn,Xr as Mn,Xt as Nn,Yr as Pn,Yt as Fn,Zr as In,Zt as Ln,_ as Rn,_r as zn,a as Bn,aa as Vn,ai as Hn,br as Un,c as Wn,dr as Gn,dt as Kn,en as qn,f as Jn,g as Yn,gr as Xn,gt as Zn,hr as Qn,ht as $n,ia as er,ii as tr,jr as nr,kr as rr,li as ir,ln as ar,lt as or,m as sr,mi as cr,mt as lr,na as ur,nn as dr,o as fr,oa as pr,or as mr,p as hr,pt as gr,qr as _r,qt as vr,r as yr,ri as br,rn as xr,rt as Sr,sa as Cr,st as wr,u as Tr,vt as Er,y as Dr,z as Or,zt as kr}from"./framework-CAuH4h0L.js";import{g as Ar,h as jr,i as Mr,n as Nr,o as Pr,p as Fr,t as Ir,w as Lr}from"./i18n-runtime-CdWyaiOD.js";import{t as Rr}from"./vendor-icon-activity-CkniytwY.js";import{t as zr}from"./vendor-icon-arrow-left-DmGEbpkA.js";import{t as Br}from"./vendor-icon-arrow-right-left-BH_jvt4r.js";import{t as Vr}from"./vendor-icon-arrow-right-RqsZZ458.js";import{t as Hr}from"./vendor-icon-arrow-up-down-DdDqplfV.js";import{t as Ur}from"./vendor-icon-at-sign-B71HJHhC.js";import{t as Wr}from"./vendor-icon-badge-check-SLEl_RQq.js";import{t as Gr}from"./vendor-icon-bell-off-BnernHBj.js";import{t as Kr}from"./vendor-icon-bell-6t8He8Wt.js";import{t as qr}from"./vendor-icon-bold-C_J_IVlW.js";import{t as Jr}from"./vendor-icon-calendar-BsoUBIef.js";import{t as Yr}from"./vendor-icon-check-vpu9Zukp.js";import{t as Xr}from"./vendor-icon-chevron-down-BEf_jTEE.js";import{t as Zr}from"./vendor-icon-chevron-left-KnDcuFH1.js";import{t as Qr}from"./vendor-icon-chevron-right-DbnKwHYQ.js";import{t as $r}from"./vendor-icon-chevrons-left-gvlDgS8M.js";import{t as ei}from"./vendor-icon-chevrons-right-lic1nOWF.js";import{t as ti}from"./vendor-icon-circle-alert-D1XTr_X9.js";import{t as ni}from"./vendor-icon-circle-check-Bq3OcFQN.js";import{t as ri}from"./vendor-icon-circle-plus-4gej-PPk.js";import{t as ii}from"./vendor-icon-circle-x-Nkh1Yr7N.js";import{t as ai}from"./vendor-icon-circle-5-gUQbxi.js";import{t as oi}from"./vendor-icon-clipboard-paste-DxLRapVV.js";import{t as si}from"./vendor-icon-clock-CTLnah0r.js";import{t as ci}from"./vendor-icon-code-C7LFGCxG.js";import{t as li}from"./vendor-icon-copy-B5M-KdZo.js";import{t as ui}from"./vendor-icon-download-C3csYSaD.js";import{t as di}from"./vendor-icon-ellipsis-vertical-DwMP57JC.js";import{t as fi}from"./vendor-icon-external-link-SBKz5x6R.js";import{t as pi}from"./vendor-icon-eye-off-Dy3GIcvl.js";import{t as mi}from"./vendor-icon-eye-C3HaEGOo.js";import{t as hi}from"./vendor-icon-face-slightly-smiling-plus-BYluVacK.js";import{t as gi}from"./vendor-icon-file-archive-ruJEbEgu.js";import{t as _i}from"./vendor-icon-file-spreadsheet-LZ3f9xT3.js";import{t as vi}from"./vendor-icon-file-text-7BKAVNof.js";import{t as yi}from"./vendor-icon-file-CTChzdTZ.js";import{t as bi}from"./vendor-icon-hash-Lkwzb5Ny.js";import{t as xi}from"./vendor-icon-image-D2YAsa8l.js";import{t as Si}from"./vendor-icon-inbox-ByVQ4l4S.js";import{t as Ci}from"./vendor-icon-italic-Dt0-MsYM.js";import{t as wi}from"./vendor-icon-list-TLz-7vfa.js";import{t as Ti}from"./vendor-icon-loader-circle-D3PsuVaD.js";import{t as Ei}from"./vendor-icon-lock-B_psRnly.js";import{t as Di}from"./vendor-icon-mail-BfkRvgNr.js";import{t as Oi}from"./vendor-icon-message-square-BObk9Jes.js";import{t as ki}from"./vendor-icon-panel-right-close-B1IgPiA5.js";import{t as Ai}from"./vendor-icon-panel-right-open-DRcsA0VE.js";import{t as ji}from"./vendor-icon-paperclip-zxZDBuvr.js";import{t as Mi}from"./vendor-icon-pencil-CMubUBjW.js";import{t as Ni}from"./vendor-icon-phone-H1S8HSi1.js";import{t as Pi}from"./vendor-icon-pin-BWwVcO2t.js";import{t as Fi}from"./vendor-icon-plus-BlfcDDsa.js";import{t as Ii}from"./vendor-icon-rows-2-CyEMxks5.js";import{t as Li}from"./vendor-icon-rows-3-Bl0iGPg_.js";import{t as Ri}from"./vendor-icon-rows-4-DVXDgm1n.js";import{t as zi}from"./vendor-icon-save-CuavGNuU.js";import{t as Bi}from"./vendor-icon-search-B2Uqtp_W.js";import{t as Vi}from"./vendor-icon-send-BlZYLCTK.js";import{t as Hi}from"./vendor-icon-share-2-D3bdPyHy.js";import{t as Ui}from"./vendor-icon-square-check-big-B4UVzWzR.js";import{t as Wi}from"./vendor-icon-square-pen-CrYOuw6J.js";import{t as Gi}from"./vendor-icon-star-DfusowFE.js";import{t as Ki}from"./vendor-icon-sticky-note-Bp3ZFMbg.js";import{t as qi}from"./vendor-icon-tag-iKhUiq-2.js";import{t as Ji}from"./vendor-icon-text-align-justify-BknwtpxF.js";import{t as Yi}from"./vendor-icon-trash-BLsWkwB9.js";import{t as Xi}from"./vendor-icon-triangle-alert-D5n0T3q_.js";import{t as Zi}from"./vendor-icon-type-DudTuHpS.js";import{t as Qi}from"./vendor-icon-undo-2-C9MbW2Vb.js";import{t as $i}from"./vendor-icon-upload-BZ3rElxe.js";import{t as ea}from"./vendor-icon-user-IWwlLQut.js";import{t as ta}from"./vendor-icon-x-CcLtgRNL.js";import{t as na}from"./vendor-icon-zap-3ulAPCbu.js";var Q=e(o(),1);b();function ra(e){let t=e?.type||null,n=t===null?null:Ke({type:t,format:e?.format??void 0});return{declaredType:t,rendererType:n,Renderer:Re(n??``)}}function ia(e){return Re(e)}var aa=`select`;function oa(e,t,n){return ca(e)||ca(t)||sa(e,n)}function sa(e,t){return t&&!(typeof e==`string`&&e.length>0)}function ca(e){return typeof e==`string`&&Je(e)}function la(e,t,n){let r=e?.validations;if(!Array.isArray(r))return null;let i=r.find(e=>!!e&&typeof e==`object`&&e.type===`state_machine`&&e.field===t&&!!e.transitions);if(!i)return null;let a=n==null?``:String(n),o=i.transitions[a];return Array.isArray(o)?new Set([a,...o.map(e=>String(e))]):null}var ua=new Set([`formula`,`summary`,`rollup`,`autonumber`,`auto_number`,`file`,`image`,`avatar`,`video`,`audio`,`signature`]);function da(e){return e?e.readonly===!0?!1:typeof e.type!=`string`||!ua.has(e.type)&&!w(e.type):!0}var fa={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},pa=[`xs`,`sm`,`md`,`lg`,`xl`,`2xl`];function ma(e){for(let t=pa.length-1;t>=0;t--){let n=pa[t];if(e>=fa[n])return n}return`xs`}function ha(){let[e,t]=(0,Q.useState)(()=>typeof window<`u`?window.innerWidth:1024);(0,Q.useEffect)(()=>{if(typeof window>`u`)return;let e,n=()=>{clearTimeout(e),e=setTimeout(()=>{t(window.innerWidth)},100)};return window.addEventListener(`resize`,n),()=>{clearTimeout(e),window.removeEventListener(`resize`,n)}},[]);let n=ma(e),r=pa.indexOf(n);return{breakpoint:n,width:e,isMobile:r<pa.indexOf(`md`),isTablet:r>=pa.indexOf(`md`)&&r<pa.indexOf(`lg`),isDesktop:r>=pa.indexOf(`lg`),isAbove:t=>e>=fa[t],isBelow:t=>e<fa[t]}}function ga(e){let{onRefresh:t,threshold:n=80,enabled:r=!0}=e,i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(0),l=(0,Q.useRef)(0),u=(0,Q.useCallback)(e=>{if(!r||a)return;let t=i.current;t&&t.scrollTop===0&&(l.current=e.touches[0].clientY)},[r,a]),d=(0,Q.useCallback)(e=>{if(!r||a||!l.current)return;let t=e.touches[0].clientY-l.current;t>0&&c(Math.min(t,n*1.5))},[r,a,n]),f=(0,Q.useCallback)(async()=>{if(!r||a)return;let e=s;if(c(0),l.current=0,e>=n){o(!0);try{await t()}finally{o(!1)}}},[r,a,s,n,t]),p=(0,Q.useRef)({handleTouchStart:u,handleTouchMove:d,handleTouchEnd:f});(0,Q.useEffect)(()=>{p.current={handleTouchStart:u,handleTouchMove:d,handleTouchEnd:f}});let m=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{let e=r?i.current:null,t=m.current;(t?t.el:null)!==e&&(t&&ba(t),m.current=e?ya(e,p):null)}),(0,Q.useEffect)(()=>()=>{let e=m.current;e&&ba(e),m.current=null},[]),{ref:i,isRefreshing:a,pullDistance:s}}var _a=`data-pull-to-refresh-host`;function va(e){let t=e.parentElement;return t!==null&&t.closest(`[${_a}]`)!==null}function ya(e,t){let n={el:e,start:n=>{va(e)||t.current.handleTouchStart(n)},move:e=>t.current.handleTouchMove(e),end:()=>{t.current.handleTouchEnd()}};return e.setAttribute(_a,``),e.addEventListener(`touchstart`,n.start,{passive:!0}),e.addEventListener(`touchmove`,n.move,{passive:!0}),e.addEventListener(`touchend`,n.end,{passive:!0}),n}function ba(e){e.el.removeAttribute(_a),e.el.removeEventListener(`touchstart`,e.start),e.el.removeEventListener(`touchmove`,e.move),e.el.removeEventListener(`touchend`,e.end)}var $=a(),xa=(0,Q.createContext)(null);xa.displayName=`MobileContext`;function Sa({pwa:e,offline:t,children:n}){let r=ha(),i=(0,Q.useMemo)(()=>({...r,pwa:e,offline:t}),[r,e,t]);return(0,$.jsx)(xa.Provider,{value:i,children:n})}function Ca(e){return{name:e.name,short_name:e.shortName,description:e.description,theme_color:e.themeColor??`#3b82f6`,background_color:e.backgroundColor??`#ffffff`,display:e.display??`standalone`,start_url:e.startUrl??`/`,scope:e.scope??`/`,orientation:e.orientation??`any`,icons:e.icons?.map(e=>({src:e.src,sizes:e.sizes,type:e.type??`image/png`,purpose:e.purpose??`any`}))??[]}}var wa=new Set([`textarea`,`markdown`,`html`,`grid`,`richtext`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:richtext`]);function Ta(e){return wa.has(e)}function Ea(e,t){let n;return n=e<=3?1:e<=8?2:e<=15?3:4,t!==void 0&&t<640?Math.min(n,1):n}function Da(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&Ta(e.type)?{...e,span:t}:e)}function Oa(e,t,n){if(t!==void 0)return{fields:Da(e,t),columns:t};let r=Ea(e.length,n);return{fields:Da(e,r),columns:r}}var ka=jr({"common.resizeDrawer":`Resize drawer`,"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.saving":`Saving…`,"detail.editFieldsInline":`Edit fields`,"detail.editInlineHint":`Double-click to edit`,"detail.cancel":`Cancel`,"detail.cancelEdit":`Discard changes`,"detail.openInNewTab":`Open in new tab`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addReaction":`Add reaction`,"detail.emojiPicker":`Emoji picker`,"detail.reactionCount":`{{emoji}} {{count}} reactions`,"detail.reactionCount_one":`{{emoji}} {{count}} reaction`,"detail.reactionCount_other":`{{emoji}} {{count}} reactions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading…`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.noValue":`No value`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.showEmptyFields_one":`Show {{count}} empty field`,"detail.showEmptyFields_other":`Show {{count}} empty fields`,"detail.hideEmptyFields":`Hide empty fields`,"detail.editRow":`Edit`,"detail.deleteRow":`Delete`,"detail.deleteRowConfirmation":`Are you sure you want to delete this record?`,"detail.actions":`Actions`,"detail.previousPage":`Previous`,"detail.nextPage":`Next`,"detail.pageOf":`Page {{current}} of {{total}}`,"detail.sortBy":`Sort by`,"detail.filterPlaceholder":`Filter…`,"detail.highlightFields":`Key Fields`,"detail.highlightsLabel":`Record highlights`,"detail.comments":`Comments`,"detail.searchComments":`Search comments…`,"detail.addCommentPlaceholder":`Add a comment… (Ctrl+Enter to submit)`,"detail.noMatchingComments":`No matching comments`,"detail.noCommentsYet":`No comments yet`,"detail.pinned":`Pinned`,"detail.pin":`Pin`,"detail.unpin":`Unpin`,"detail.justNow":`just now`,"detail.minutesAgo":`{{count}}m ago`,"detail.hoursAgo":`{{count}}h ago`,"detail.daysAgo":`{{count}}d ago`,"detail.createdBy":`Created by`,"detail.updatedBy":`Updated by`,"detail.created":`Created`,"detail.updated":`Updated`,"detail.dropFilesToUpload":`Drop files here or click to upload`,"detail.attachmentCount":`{{count}} attachment`,"detail.attachmentCount_one":`{{count}} attachment`,"detail.attachmentCount_other":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"detail.discussion":`Discussion`,"detail.showDiscussion":`Show Discussion ({{count}})`,"detail.hideDiscussion":`Hide discussion`,"detail.bold":`Bold (Ctrl+B)`,"detail.italic":`Italic (Ctrl+I)`,"detail.listFormat":`List`,"detail.inlineCode":`Inline code`,"detail.mentionSomeone":`Mention someone`,"detail.preview":`Preview`,"detail.submitComment":`Submit (Ctrl+Enter)`,"detail.sendComment":`Send`,"detail.writeComment":`Write a comment…`,"detail.subscribedTooltip":`Subscribed — click to unsubscribe`,"detail.unsubscribedTooltip":`Subscribe to notifications`,"detail.noRecords":`No records`,"detail.showEmptyRelated":`+ {{count}} empty`,"detail.showEmptyRelated_one":`+ {{count}} empty`,"detail.showEmptyRelated_other":`+ {{count}} empty`,"detail.allActivity":`All Activity`,"detail.commentsOnly":`Comments Only`,"detail.fieldChangesFilter":`Field Changes`,"detail.tasksOnly":`Tasks Only`,"detail.leaveCommentPlaceholder":`Leave a comment… (Ctrl+Enter to submit)`,"detail.noActivity":`No activity recorded`,"detail.activityAccessDenied":`You don't have permission to view activity on this record.`,"detail.commentsAccessDenied":`You don't have permission to view comments on this record.`,"detail.allFilter":`All`,"detail.createsFilter":`Creates`,"detail.deletesFilter":`Deletes`,"detail.statusChangesFilter":`Status Changes`,"detail.activityEmptyValue":`(empty)`,"detail.activityFieldChanged":`Changed {{field}} from "{{old}}" to "{{new}}"`,"detail.activityCreated":`Created this record`,"detail.activityDeleted":`Deleted this record`,"detail.activityStatusChanged":`Changed status to "{{value}}"`,"detail.activityUpdated":`Updated record`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.viewSource":`View source`,"detail.replyCount":`{{count}} reply`,"detail.replyCount_one":`{{count}} reply`,"detail.replyCount_other":`{{count}} replies`,"detail.replyPlaceholder":`Reply…`,"detail.filterActivity":`Filter activity`,"detail.openDiscussion":`Open discussion panel`,"detail.closeDiscussion":`Close discussion panel`,"detail.subscribeAriaLabel":`Subscribe to notifications`,"detail.unsubscribeAriaLabel":`Unsubscribe from notifications`,"detail.clearSearch":`Clear search`,"detail.concurrentUpdateTitle":`This record was modified by someone else`,"detail.concurrentUpdateDescription":`Another user saved a newer version of {{field}} while you were editing. To prevent silently overwriting their change, please choose how to resolve the conflict.`,"detail.concurrentUpdateYourEdit":`Your edit`,"detail.concurrentUpdateCurrentValue":`Current value`,"detail.concurrentUpdateUpdatedBy":`Updated by {{name}}`,"detail.concurrentUpdateUpdatedAt":`Updated at {{when}}`,"detail.concurrentUpdateReload":`Reload latest`,"detail.concurrentUpdateOverwrite":`Overwrite anyway`,"detail.concurrentUpdateCancel":`Cancel`,"detail.lockedByApproval":`Locked for approval`,"detail.lockedTooltip":`This record has a pending approval request; editing is locked`,"detail.approvalPendingEditable":`In approval · editable`,"detail.approvalPendingTooltip":`This record has a pending approval request; this step still allows editing`,"detail.approvalProgress":`Approvals — {{got}} of {{need}}`,"detail.approvalProgressGroups":`Sign-off — {{got}} of {{need}} groups`,"detail.approvalProgressLabel":`Approval progress`,"detail.cancelApproval":`Recall approval`,"detail.cancelApprovalInFlight":`Recalling…`,"detail.cancelApprovalTooltip":`Recall the pending approval request to unlock this record`,"detail.cancelApprovalTooltipUnlocked":`Recall the pending approval request`,"detail.cancelApprovalFailed":`Failed to recall approval`,"detail.cancelApprovalUnavailable":`Recalling approvals is not supported on this data source`,"detail.pathLabel":`Record path`,"detail.pathStageCompleted":`{{stage}}, completed`,"detail.pathStageCurrent":`{{stage}}, current stage`,"detail.pathStageUpcoming":`{{stage}}, upcoming`,"detail.pathStageLostCurrent":`{{stage}}, closed lost, current stage`,"detail.pathStageLostUpcoming":`{{stage}}, closed lost, not reached`,"detail.pathStageWonUpcoming":`{{stage}}, goal stage, not reached`,"view.malformedFilter":`This view’s filter is malformed, so no records are shown: the {{subject}} condition cannot be applied.`},`detail.back`);function Aa(e){if(typeof e==`string`){let t=e.trim();if(!t)return null;try{return JSON.parse(t)}catch{return t}}return e??null}function ja(e){let t=Aa(e);return t==null||t===``?0:Array.isArray(t)?t.length:typeof t==`object`?Object.keys(t).length:1}function Ma({value:e,field:t}){let{t:n}=ka(),a=Jt(),{appName:o}=r(),s=t?.name||``,c=a?.data?.name,l=o&&c?`/apps/${o}/metadata/permission/${encodeURIComponent(String(c))}`:null,u=ja(e),d=u===0,f=(()=>{if(d)return(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:n(`perm.facet.none`,{defaultValue:`None`})});if(s===`system_permissions`){let t=M(e),r=t.slice(0,6),i=t.length-r.length;return(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[r.map(e=>(0,$.jsx)(Qe,{variant:`outline`,children:e},e)),i>0&&(0,$.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n(`perm.facet.more`,{count:i,defaultValue:`+${i} more`})})]})}let t=(()=>{switch(s){case`object_permissions`:return n(`perm.facet.objects`,{count:u,defaultValue:`${u} object${u===1?``:`s`}`});case`field_permissions`:return n(`perm.facet.fields`,{count:u,defaultValue:`${u} field rule${u===1?``:`s`}`});case`row_level_security`:return n(`perm.facet.rls`,{count:u,defaultValue:`${u} RLS polic${u===1?`y`:`ies`}`});case`tab_permissions`:return n(`perm.facet.tabs`,{count:u,defaultValue:`${u} tab rule${u===1?``:`s`}`});case`admin_scope`:return n(`perm.facet.adminScope`,{defaultValue:`Delegated admin configured`});default:return String(u)}})();return(0,$.jsx)(`span`,{className:`text-foreground`,children:t})})();return(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[f,l?(0,$.jsx)(i,{to:l,className:`text-primary hover:underline whitespace-nowrap`,children:n(`perm.facet.designInStudio`,{defaultValue:`Design in Studio →`})}):(0,$.jsx)(`span`,{className:`text-muted-foreground/60 whitespace-nowrap`,children:n(`perm.facet.designInStudioHint`,{defaultValue:`Design in Studio`})})]})}var Na=new Set([`id`,`_id`,`__v`,`created`,`created_at`,`createdAt`,`created_by`,`modified`,`modified_by`,`updated_at`,`updatedAt`,`updated_by`,`deleted_at`,`is_deleted`,`deleted`,`instance_state`]),Pa=new Set([`formula`,`summary`,`rollup`,`autonumber`,`auto_number`]);function Fa(e,t){return Pa.has(e)||Pa.has(t)}var Ia=new Set([`image`,`avatar`,`signature`,`file`,`video`,`audio`,`markdown`]);function La(e,t){return Ra(e)||Ra(t)}function Ra(e){return typeof e!=`string`||Ia.has(e)?!1:w(e)}function za(e,t){return Ba(e)||Ba(t)}function Ba(e){return typeof e==`string`&&Je(e)}var Va=`options.currency.currencyConfig.precision.scale.useGrouping.min.max.step.format.widget.dueLike.multiple.reference_field.displayField.descriptionField.idField.allow_create.allowCreate.lookup_columns.lookupColumns.lookup_page_size.lookupPageSize.lookupFilters.picker.subtitle.avatar_field.avatarField.depends_on.dependsOn`.split(`.`);function Ha(e,t){let n={...e};if(!t)return n;!n.type&&t.type&&(n.type=t.type);for(let e of Va){let r=t[e];r!==void 0&&n[e]===void 0&&(n[e]=r)}let r=t.reference;return r&&n.reference===void 0&&(n.reference=r),n}var Ua=`inline-plain-text-input`,Wa=new Set([`text`,`email`,`phone`,`url`]);function Ga(e){return e?ot.includes(e)||te(e)!==`field:text`:!1}function Ka(e){let t=e?.type;return!t||Wa.has(t)?!0:t===`select`&&!e.multiple}var qa=({field:e,value:t,onChange:n,dataSource:r,autoFocus:i,error:a,dependentValues:o})=>{let s=e.type;if(e.widget===`permission-facet-link`)return(0,$.jsx)(Ma,{value:t,field:e});if(typeof s==`string`&&$t[s])return(0,$.jsx)(Ze,{field:e});let c=s===`multiselect`||!!e.multiple;if((s===`select`||s===`multiselect`)&&Array.isArray(e.options)&&e.options.length>0)return c?(0,$.jsx)(Mt,{field:{...e,multiple:!0},value:Array.isArray(t)?t:t==null||t===``?[]:[t],onChange:e=>n(e),error:a,dependentValues:o}):(0,$.jsx)(Mt,{field:e,value:t==null?``:String(t),onChange:e=>n(e),error:a,dependentValues:o});if(s===`boolean`)return(0,$.jsx)(E,{field:e,value:!!t,onChange:e=>n(e),error:a});if(s===`image`)return(0,$.jsx)(Ot,{field:e,value:t,onChange:e=>n(e),error:a});if(s===`avatar`)return(0,$.jsx)(jt,{field:e,value:t,onChange:e=>n(e),error:a});if(s===`signature`)return(0,$.jsx)(Tt,{field:e,value:t,onChange:e=>n(e),error:a});if(s===`file`||s===`video`||s===`audio`)return(0,$.jsx)(H,{field:e,value:t,onChange:e=>n(e),error:a});if(s===`markdown`||s===`textarea`)return(0,$.jsx)(De,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});let l=s===`user`,u=s===`lookup`||s===`master_detail`||s===`tree`||!!e.reference&&!Pa.has(s);if(l||u)return(0,$.jsx)(l?V:ee,{field:e,value:t,onChange:e=>n(e),dataSource:r,error:a,dependentValues:o});if(s===`number`)return(0,$.jsx)(Ce,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(s===`currency`)return(0,$.jsx)(F,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(s===`percent`)return(0,$.jsx)(we,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(s===`address`)return(0,$.jsx)(de,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(s===`location`)return(0,$.jsx)(le,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(s===`geolocation`)return(0,$.jsx)($e,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});let d=s===`date`||s===`datetime`;if(!d&&!Ka(e)&&Ga(s)&&nt(s))return(0,$.jsx)(pe,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a,dependentValues:o});if(d)return(0,$.jsx)(ve,{field:e,value:t,onChange:e=>n(e&&new Date(e+`T00:00:00`).toISOString()),autoFocus:i,error:a});let f=t==null?``:String(typeof t==`object`?pt(t)??``:t);return(0,$.jsx)(`input`,{type:`text`,"data-testid":Ua,autoFocus:i,"aria-invalid":a?!0:void 0,className:`w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring`,value:f,onChange:e=>n(e.target.value)})},Ja=Object.freeze({muted:`bg-muted`,"muted/50":`bg-muted/50`,accent:`bg-accent`,"primary/10":`bg-primary/10`,"secondary/10":`bg-secondary/10`,"destructive/10":`bg-destructive/10`}),Ya=Ja;function Xa(e){if(!e)return;let t=e.trim();if(t)return t.startsWith(`bg-`)?t:Object.prototype.hasOwnProperty.call(Ja,t)?Ja[t]:void 0}function Za(e){return It(e)?!1:typeof e==`object`&&e?!0:un({value:e},`value`)!==void 0}var Qa=({name:e})=>/^[a-z0-9][a-z0-9-]*$/i.test(e)?(0,$.jsx)(ke,{name:e,className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e});function $a(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:t===3?e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``:e===2?`md:col-span-2`:e===3?`md:col-span-2 lg:col-span-3`:e>=4?`md:col-span-2 lg:col-span-3 xl:col-span-4`:``}var eo=()=>{},to=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l,virtualScroll:u})=>{let[d,f]=Q.useState(e.defaultCollapsed??!1),[p,m]=Q.useState(null),[h,g]=Q.useState(void 0),[_,v]=Q.useState(!1),{t:y}=ka(),{fieldLabel:b,translateOptions:x}=Fr(),S=kn()?.fieldErrors??null,C=Q.useCallback((e,t)=>{let n;if(t==null)n=``;else if(typeof t==`object`)try{n=JSON.stringify(t)}catch{n=String(t)}else n=String(t);navigator.clipboard.writeText(n).then(()=>{m(e),setTimeout(()=>m(null),2e3)})},[]),w=Q.useCallback(e=>!Za(t?.[e.name]??e.value),[t]),E=Q.useMemo(()=>e.fields.filter(w).length,[e.fields,w]),D=T(),O=D?3:4,k=D?.2:.25,A=e.fields.length-E,M=!a&&e.fields.length>=O&&E/e.fields.length>=k&&A>0,ee=e.fields.length>0&&A===0,P=e.hideEmpty===!0&&ee&&!a,te=!_&&(M||P)?e.fields.filter(e=>!w(e)):e.fields,{fields:ne,columns:F}=Oa(te,e.columns),I=Math.min(F,Math.max(1,te.length)),ie=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,$.jsx)(Zn,{schema:lr(e.render),data:{...t,value:n}});let u=$a(e.span,I),d=r?.fields?.[e.name],f=Ha(e,d);i&&Array.isArray(f.options)&&f.options.length>0&&(f.options=x(i,e.name,f.options));let m=Fa(e.type,d?.type),h=e.readonly===!0||d?.readonly===!0,g=Na.has(e.name),_=La(e.type,d?.type),v=za(e.type,d?.type),w=!h&&!m&&!g&&!_,T=w&&!!s,E=(()=>{if((f.widget||e.widget)===`permission-facet-link`)return(0,$.jsx)(Ma,{value:n,field:f});if(!Za(n))return(0,$.jsx)(tt,{className:`pointer-events-auto`,title:y(`detail.noValue`,{defaultValue:`No value`})});let t=Ke(f)||e.type;if(t===`textarea`)return(0,$.jsx)(De,{field:f,value:String(pt(n)),onChange:eo,readonly:!0});if(t){let e=Re(t);if(e)return(0,$.jsx)(e,{value:n,field:f})}return String(n)})(),O=Za(n)&&!v,k=O&&!T,A=p===e.name,M=b(i||``,e.name,e.label||e.name);return D&&!(a&&w)?(0,$.jsxs)(`div`,{className:U(`flex items-baseline justify-between gap-4 py-2.5 min-h-[44px] group`,O&&`cursor-pointer active:bg-muted/40 transition-colors`),onClick:O?()=>C(e.name,n):void 0,onKeyDown:O?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),C(e.name,n))}:void 0,role:O?`button`:void 0,tabIndex:O?0:void 0,children:[(0,$.jsx)(`span`,{className:`text-[15px] text-muted-foreground shrink-0`,children:M}),(0,$.jsx)(`span`,{className:`text-[15px] text-foreground text-right break-words min-w-0 leading-snug`,children:E})]},e.name):(0,$.jsxs)(`div`,{className:U(`space-y-1.5 group min-w-0`,u),children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:b(i||``,e.name,e.label||e.name)}),a&&w?(0,$.jsxs)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:[(0,$.jsx)(qa,{field:f,value:n,onChange:t=>o?.(e.name,t),dataSource:l,autoFocus:c===e.name,error:S?.[e.name],dependentValues:t}),S?.[e.name]&&(0,$.jsx)(`p`,{role:`alert`,"data-inline-field-hint":e.name,className:`mt-1 text-xs text-destructive`,children:S[e.name]})]}):(0,$.jsxs)(`div`,{className:U(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,k&&`cursor-pointer active:bg-muted/60 transition-colors`,T&&`cursor-pointer hover:bg-muted/40 transition-colors -mx-1.5 px-1.5`),onClick:k?()=>C(e.name,n):void 0,onDoubleClick:T?()=>s?.(e.name):void 0,onKeyDown:k?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),C(e.name,n))}:void 0,role:k?`button`:void 0,tabIndex:k?0:void 0,title:T?y(`detail.editInlineHint`):void 0,children:[(0,$.jsx)(`div`,{className:`text-sm flex-1 min-w-0 break-words py-1`,children:E}),T?(0,$.jsx)(j,{children:(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,"aria-label":y(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),s?.(e.name)},children:(0,$.jsx)(Mi,{className:`h-3 w-3`})})}),(0,$.jsx)(N,{children:y(`detail.editInlineHint`)})]})}):O?(0,$.jsx)(j,{children:(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),C(e.name,n)},children:A?(0,$.jsx)(Yr,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(li,{className:`h-3 w-3`})})}),(0,$.jsx)(N,{children:y(A?`detail.copied`:`detail.copyToClipboard`)})]})}):null]})]},e.name)},R=u?.enabled===!0,z=u?.batchSize??20;if(Q.useEffect(()=>{if(!R){g(void 0);return}if(ne.length<=z){g(void 0);return}g(z);let e=setTimeout(()=>g(void 0),100);return()=>clearTimeout(e)},[R,ne.length,z]),te.length===0&&E===e.fields.length)return null;let ae=h===void 0?ne:ne.slice(0,h),oe=E>0&&M,B=(0,$.jsxs)($.Fragment,{children:[D?(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60`,children:ae.map(ie)}):(0,$.jsx)(`div`,{className:U(`grid gap-3 sm:gap-4`,I===1?`grid-cols-1`:I===2?`grid-cols-1 md:grid-cols-2`:I===3?`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`),children:ae.map(ie)}),oe&&(0,$.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,$.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>v(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[_?(0,$.jsx)(pi,{className:`h-3.5 w-3.5 mr-1.5`}):(0,$.jsx)(mi,{className:`h-3.5 w-3.5 mr-1.5`}),_?y(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):y(`detail.showEmptyFields`,{count:E,defaultValue:`Show {{count}} empty fields`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,$.jsx)(`div`,{className:U(n),children:B}):e.collapsible?(0,$.jsx)(ce,{open:!d,onOpenChange:e=>f(!e),className:n,children:(0,$.jsxs)(Ee,{className:U(e.showBorder===!1?`border-none shadow-none`:``),children:[(0,$.jsx)(Pt,{asChild:!0,children:(0,$.jsxs)(Oe,{className:U(`py-3 px-4 sm:py-4 sm:px-6 cursor-pointer hover:bg-muted/50 transition-colors`,Xa(e.headerColor)),children:[(0,$.jsxs)(re,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(Qa,{name:e.icon}),(0,$.jsx)(`span`,{children:e.title})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:d?(0,$.jsx)(Qr,{className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Xr,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!d&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,$.jsx)(be,{children:(0,$.jsx)(L,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:B})})]})}):(0,$.jsxs)(Ee,{className:U(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,$.jsxs)(Oe,{className:U(`py-3 px-4 sm:py-4 sm:px-6`,Xa(e.headerColor)),children:[(0,$.jsx)(re,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(Qa,{name:e.icon}),(0,$.jsx)(`span`,{children:e.title})]})}),e.description&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]}),(0,$.jsx)(L,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:B})]})},no=({tabs:e,data:t,className:n})=>{let[r,i]=Q.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,$.jsxs)(_e,{value:r,onValueChange:i,className:n,children:[(0,$.jsx)(Be,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,$.jsx)(xt,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{children:e.icon}),(0,$.jsx)(`span`,{children:e.label}),e.badge&&(0,$.jsx)(Qe,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,$.jsx)(C,{value:e.key,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,$.jsx)(Q.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,$.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,$.jsx)(Zn,{schema:lr(e),data:t},n))}):(0,$.jsx)(Zn,{schema:lr(e.content),data:t})})},e.key))]})},ro=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l})=>{let u=e.collapsible??!0,[d,f]=Q.useState(e.defaultCollapsed??!1),p=(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,$.jsx)(to,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l},n))});return u?(0,$.jsxs)(ce,{open:!d,onOpenChange:e=>f(!e),className:n,children:[(0,$.jsx)(Pt,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5`,children:[d?(0,$.jsx)(Qr,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,$.jsx)(Xr,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!d&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,$.jsx)(be,{children:(0,$.jsx)(`div`,{className:`mt-3`,children:p})})]}):(0,$.jsxs)(`div`,{className:U(`space-y-3`,n),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),p]})},io=({fields:e,data:t,className:n,objectName:r,objectSchema:i,dataSource:a})=>{let{fieldLabel:o}=Fr(),{t:s}=ka(),c=kn(),l=c?.editing??!1,u=c?.canEdit??!1,d=c?.draft,f=Q.useMemo(()=>t&&d?{...t,...d}:t,[t,d]);if(!e.length||!t)return null;let p=l?e:e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return p.length===0?null:(0,$.jsx)(j,{children:(0,$.jsx)(`section`,{className:U(`@container border-b border-border/60 pb-4`,n),"aria-label":s(`detail.highlightsLabel`),children:(0,$.jsx)(`div`,{className:U(`flex flex-wrap gap-y-4`),children:p.map(e=>{let n=t[e.name],d=i?.fields?.[e.name],p=e.type||d?.type,m=Ha({name:e.name,label:e.label,type:p||`text`},d),h=f?f[e.name]:n,g=Fa(e.type,d?.type),_=e.readonly===!0||d?.readonly===!0,v=Na.has(e.name),y=La(e.type,d?.type),b=u&&!g&&!_&&!v&&!y,x=l&&b,S=Re(Ke(m)||p||`text`),C=p===`number`||p===`integer`||p===`currency`||p===`percent`||p===`decimal`,w=p===`email`||p===`url`||p===`textarea`||!!p&&an.has(p),T=p===`boolean`,E=!Za(h);return(0,$.jsxs)(`div`,{className:U(`group flex flex-col gap-1 min-w-[7rem] px-5 border-l border-border/60 first:border-l-0 first:pl-0`,w||x?`basis-[16rem] max-w-[24rem]`:`basis-[9rem] max-w-[16rem]`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:o(r||``,e.name,e.label)}),x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(qa,{field:m,value:h,onChange:t=>c.setField(e.name,t),dataSource:a,autoFocus:c.autoFocusField===e.name,error:c.fieldErrors?.[e.name],dependentValues:f}),c.fieldErrors?.[e.name]&&(0,$.jsx)(`p`,{role:`alert`,"data-inline-field-hint":e.name,className:`mt-1 text-xs text-destructive`,children:c.fieldErrors[e.name]})]}):(0,$.jsxs)(`div`,{className:U(`flex items-start justify-between gap-1`,b&&`cursor-pointer rounded-md -mx-1.5 px-1.5 hover:bg-muted/40 transition-colors`),onDoubleClick:b?()=>c.enter(e.name):void 0,title:b?s(`detail.editInlineHint`):void 0,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:T?h?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-600 ring-1 ring-inset ring-emerald-500/30 dark:text-emerald-400`,children:[(0,$.jsx)(Yr,{className:`h-3 w-3`,"aria-hidden":!0}),`Yes`]}):(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-700 ring-1 ring-inset ring-amber-500/30 dark:text-amber-400`,children:[(0,$.jsx)(ta,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):E?(0,$.jsx)(tt,{className:`block`}):(0,$.jsx)(`span`,{title:(Array.isArray(m.options)?m.options.find(e=>e?.value===h)?.label:void 0)??(typeof h==`string`||typeof h==`number`?String(h):void 0),className:U(`block min-w-0 truncate text-sm font-semibold`,C&&`tabular-nums tracking-tight`),children:(0,$.jsx)(S,{value:h,field:m})})}),b&&(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,"aria-label":s(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),c.enter(e.name)},children:(0,$.jsx)(Mi,{className:`h-3 w-3`})})}),(0,$.jsx)(N,{children:s(`detail.editInlineHint`)})]})]})]},e.name)})})})})};function ao(e,t,n){try{let r=new Date(e),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4);if(a<1)return t(`detail.justNow`);if(a<60)return t(`detail.minutesAgo`,{count:a});let o=Math.floor(a/60);if(o<24)return t(`detail.hoursAgo`,{count:o});let s=Math.floor(o/24);return s<7?t(`detail.daysAgo`,{count:s}):r.toLocaleDateString(n)}catch{return e}}var oo=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=ka(),o=Ir(),[s,c]=Q.useState(``),[l,u]=Q.useState(!1),[d,f]=Q.useState(``),p=Q.useCallback(async()=>{let e=s.trim();if(e&&t){u(!0);try{await t(e),c(``)}catch{}finally{u(!1)}}},[s,t]),m=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),p())},[p]),h=Q.useMemo(()=>[...d.trim()?e.filter(e=>{let t=d.trim().toLowerCase();return e.text.toLowerCase().includes(t)||e.author.toLowerCase().includes(t)}):e].sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:0),[e,d]);return(0,$.jsxs)(Ee,{className:U(``,i),children:[(0,$.jsx)(Oe,{children:(0,$.jsxs)(re,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(Oi,{className:`h-4 w-4`}),a(`detail.comments`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,$.jsxs)(L,{className:`space-y-4`,children:[r&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(Bi,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(`input`,{className:`w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.searchComments`),value:d,onChange:e=>f(e.target.value),"aria-label":a(`detail.searchComments`)}),d&&(0,$.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>f(``),"aria-label":a(`detail.clearSearch`),type:`button`,children:(0,$.jsx)(ta,{className:`h-3.5 w-3.5`})})]})}),t&&(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:a(`detail.addCommentPlaceholder`),value:s,onChange:e=>c(e.target.value),onKeyDown:m,disabled:l}),(0,$.jsx)(G,{size:`icon`,variant:`default`,onClick:p,disabled:!s.trim()||l,className:`shrink-0 self-end`,children:(0,$.jsx)(Vi,{className:`h-4 w-4`})})]}),h.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:d.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,$.jsx)(`div`,{className:`space-y-3`,children:h.map(e=>(0,$.jsxs)(`div`,{className:U(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,$.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,$.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground`,children:e.author.charAt(0).toUpperCase()})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ao(e.createdAt,a,o)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,$.jsx)(Pi,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,$.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,$.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>n(e.id),"aria-label":e.pinned?a(`detail.unpin`):a(`detail.pin`),children:[(0,$.jsx)(Pi,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},so={field_change:Wi,create:ri,delete:Yi,comment:Oi,status_change:Br},co={field_change:`bg-blue-100 text-blue-600`,create:`bg-green-100 text-green-600`,delete:`bg-red-100 text-red-600`,comment:`bg-purple-100 text-purple-600`,status_change:`bg-amber-100 text-amber-600`};function lo(e,t,n){try{let r=new Date(e),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4);if(a<1)return t(`detail.justNow`);if(a<60)return t(`detail.minutesAgo`,{count:a});let o=Math.floor(a/60);if(o<24)return t(`detail.hoursAgo`,{count:o});let s=Math.floor(o/24);return s<7?t(`detail.daysAgo`,{count:s}):r.toLocaleDateString(n)}catch{return e}}function uo(e,t){if(e.description)return e.description;let n=t(`detail.activityEmptyValue`);return e.type===`field_change`&&e.field?t(`detail.activityFieldChanged`,{field:e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),old:e.oldValue==null?n:String(e.oldValue),new:e.newValue==null?n:String(e.newValue)}):e.type===`create`?t(`detail.activityCreated`):e.type===`delete`?t(`detail.activityDeleted`):e.type===`status_change`&&e.field?t(`detail.activityStatusChanged`,{value:e.newValue==null?n:String(e.newValue)}):t(`detail.activityUpdated`)}var fo=[`all`,`field_change`,`create`,`delete`,`comment`,`status_change`];function po(e,t){switch(e){case`field_change`:return t(`detail.fieldChangesFilter`);case`create`:return t(`detail.createsFilter`);case`delete`:return t(`detail.deletesFilter`);case`comment`:return t(`detail.comments`);case`status_change`:return t(`detail.statusChangesFilter`);default:return t(`detail.allFilter`)}}var mo=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let{t:i}=ka(),a=Ir(),[o,s]=Q.useState(n),c=Q.useMemo(()=>o===`all`?e:e.filter(e=>e.type===o),[e,o]);return(0,$.jsxs)(Ee,{className:U(``,r),children:[(0,$.jsx)(Oe,{children:(0,$.jsxs)(re,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(Rr,{className:`h-4 w-4`}),i(`detail.activity`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,c.length,`)`]})]})}),(0,$.jsxs)(L,{children:[t&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":i(`detail.filterActivity`),children:fo.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:U(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,o===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>s(e),"aria-pressed":o===e,children:[e!==`all`&&Q.createElement(so[e]||Wi,{className:`h-3 w-3`}),po(e,i)]},e))}),c.length===0?(0,$.jsx)(ft,{title:i(`detail.noActivity`),className:`py-6`}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,$.jsx)(`div`,{className:`space-y-4`,children:c.map(e=>{let t=so[e.type]||Wi,n=co[e.type]||`bg-gray-100 text-gray-600`;return(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:U(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:uo(e,i)})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:lo(e.timestamp,i,a)})]})]},e.id)})})]})]})]})},ho={create:`default`,update:`secondary`,delete:`destructive`,login:`outline`,logout:`outline`,config_change:`secondary`,import:`outline`};function go(e,t){if(!e)return``;let n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?String(e):n.toLocaleString(t)}var _o=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function vo(e,t){if(!e)return``;let n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return String(e);let r=(n.getTime()-Date.now())/1e3;for(let[n,i]of _o){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return go(e,t)}r/=n}return go(e,t)}function yo(e){if(!e)return`?`;let t=e.trim().split(/\s+/).filter(Boolean).slice(0,2);return t.length===0?`?`:t.map(e=>e.charAt(0).toUpperCase()).join(``)}function bo(e){if(!Za(e))return`—`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function xo({entries:e,loading:t,emptyText:n,unknownUserText:r,className:i,locale:a}){let o=Ir(),s=a??o;return t?(0,$.jsx)(`div`,{className:U(`space-y-3`,i),children:Array.from({length:4}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(J,{className:`h-8 w-8 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(J,{className:`h-4 w-1/3`}),(0,$.jsx)(J,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,$.jsx)(`div`,{className:U(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,i),children:n??`No history yet`}):(0,$.jsx)(j,{delayDuration:150,children:(0,$.jsx)(`ol`,{className:U(`space-y-4`,i),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),i=ho[n]??`outline`,a=typeof e.user_name==`string`&&e.user_name.trim()||r||`Unknown user`,o=go(e.created_at,s),c=vo(e.created_at,s),l=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,$.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(W,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[l?(0,$.jsx)(yt,{src:l,alt:a}):null,(0,$.jsx)(lt,{className:`text-[10px] font-medium`,children:yo(e.user_name)})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:a}),e.action&&(0,$.jsx)(Qe,{variant:i,className:`text-[10px] uppercase tracking-wide`,children:e.action}),o&&(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":o,children:c||o})}),(0,$.jsx)(N,{children:o})]})]}),e.summary&&(0,$.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(n===`create`?(0,$.jsxs)(`details`,{className:`mt-1 group`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer list-none text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 select-none`,children:[(0,$.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▸`}),(0,$.jsx)(`span`,{children:e.changes.length===1?`1 field populated`:`${e.changes.length} fields populated`})]}),(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground pl-4`,children:e.changes.map(e=>(0,$.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,$.jsx)(`span`,{className:`text-foreground`,children:bo(e.to)})]},e.field))})]}):(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,$.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,$.jsx)(`span`,{className:`line-through opacity-70`,children:bo(e.from)}),` → `,(0,$.jsx)(`span`,{className:`text-foreground`,children:bo(e.to)})]},e.field))}))]})]},e.id??t)})})})}var So=dn;function Co(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function wo(e){return Za(e)?e:void 0}function To(e,t){let n=Date.now()-e.getTime(),r=Math.max(0,Math.floor(n/1e3));if(r<60)return t(`detail.justNow`);let i=Math.floor(r/60);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);return a<24?t(`detail.hoursAgo`,{count:a}):t(`detail.daysAgo`,{count:Math.floor(a/24)})}function Eo(e,t){try{return new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var Do=({value:e,objectSchema:t,fieldName:n})=>{if(!Za(e))return null;let r=t?.fields?.[n],i=r?.reference||`sys_user`,a={name:n,type:r?.type||`lookup`,reference:i,...r?.reference_field&&{reference_field:r.reference_field}},o=Ke(a)||a.type;if(o){let t=Re(o);if(t)return(0,$.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:Q.createElement(t,{value:e,field:a})})}return(0,$.jsx)(`span`,{children:String(e)})},Oo=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a,locale:o})=>{if(!t&&!n)return null;let s=n?(0,$.jsx)(j,{delayDuration:200,children:(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:To(n,a)})}),(0,$.jsx)(N,{side:`top`,children:Eo(n,o)})]})}):null;return(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,$.jsx)(Do,{value:t,objectSchema:r,fieldName:i}):null,t&&s?(0,$.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,s]})},ko=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=ka(),a=Ir();if(!e)return null;let o=Co(e[So.createdAt]),s=Co(e[So.updatedAt]),c=wo(e[So.createdBy]),l=wo(e[So.updatedBy]),u=!!(o||c),d=o&&s&&Math.abs(s.getTime()-o.getTime())<2e3,f=!!(s||l)&&!(d&&(c!=null&&l!=null&&String(c)===String(l)||!l));return!u&&!f?null:(0,$.jsxs)(`div`,{className:U(`mt-6 pt-3 border-t border-border/40`,`flex flex-wrap items-center gap-x-4 gap-y-1`,`text-xs text-muted-foreground`,r),"data-testid":`record-meta-footer`,children:[u&&(0,$.jsx)(Oo,{label:i(c?`detail.createdBy`:`detail.created`),user:c,date:o,objectSchema:t,userField:So.createdBy,t:i,locale:a}),f&&(0,$.jsx)(Oo,{label:i(l?`detail.updatedBy`:`detail.updated`),user:l,date:s,objectSchema:t,userField:So.updatedBy,t:i,locale:a})]})},Ao=new Map,jo=new Set;function Mo(e){for(let t of Array.from(Ao.keys())){let[,n,r]=JSON.parse(t);sr(e,n,r)&&Ao.delete(t)}for(let t of jo)for(let n of t.recordIds)sr(e,t.object,n)&&t.staled.add(n)}Yn(Mo);var No;function Po(e){No!==void 0&&No!==e&&Ao.clear(),No=e}function Fo(e,t,n=`update`,r=!0){let i=He().userId,a=e&&t?JSON.stringify([i,e,t,n]):``,o=Rn(e,t),[s,c]=Q.useState(()=>a&&Ao.has(a)?Ao.get(a):!0),l=Q.useContext(gn)?.apiFetch;return Q.useEffect(()=>{if(Po(i),!r||!e||!t){c(!0);return}if(Ao.has(a)){c(Ao.get(a));return}c(!0);let o=!1,s={object:e,recordIds:[t],staled:new Set};return jo.add(s),(async()=>{try{let r=await(l??fetch)(`/api/v1/security/explain`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({object:e,operation:n,recordId:t})});if(!r.ok)return;let i=(await r.json())?.record?.visible;if(typeof i!=`boolean`||s.staled.size>0)return;Ao.set(a,i),o||c(i)}catch{}finally{jo.delete(s)}})(),()=>{o=!0}},[a,i,e,t,n,r,l,o]),s}var Io=new Set([`select`,`status`,`multiselect`,`radio`,`checkboxes`,`tags`,`user`,`image`,`avatar`,`signature`,`boolean`,`toggle`,`date`,`datetime`,`repeater`,`file`,`video`,`audio`]);function Lo(e){return!Io.has(e)}function Ro(e,t){let n=ar(e,t);return t===`whole`?n:Number(n.toPrecision(12))}var zo={};function Bo(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=un(e,fn(n));if(r){let t=e.id??e._id;if(!(r===`Untitled`||t!=null&&r===`Record #${t}`))return r}let i=vn(n?.titleFormat,e);if(i)return i}if(e&&typeof e==`object`){let t=e.id??e._id,r=Xt(n,e,{deriveFromRecordKeys:!1});if(!(r===`Untitled`||t!=null&&r===`Record #${t}`))return r}if(t.title)return t.title;if(e&&typeof e==`object`){let t=e.id??e._id,r=Xt(n,e);if(!(r===`Untitled`||t!=null&&r===`Record #${t}`))return r}if(e&&typeof e==`object`){let t=e.id??e._id;if(t!=null&&String(t).trim()!==``)return`Record #${t}`}return r}var Vo=e=>(e||[]).flatMap(e=>Array.isArray(e?.fields)?e.fields:[]),Ho=({section:e,index:t,children:n})=>(0,$.jsx)($n,{componentType:`record:details section ${e?.name??e?.group??e?.title??e?.label??`#${t+1}`}`,children:n}),Uo=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:o=!1,discussionSlot:s,rightRail:c,objectLabel:l,onDataLoaded:u,isFavorite:d,onToggleFavorite:f})=>{let[p,m]=Q.useState(e.data),[g,_]=Q.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[v,y]=Q.useState(!1),b=d??v,x=kn(),S=x?.editing??!1,w=x?.draft??zo,T=x?.autoFocusField??null,[E,D]=Q.useState(null),[O,k]=Q.useState(null),[A,M]=Q.useState(!1),[ee,P]=Q.useState(0),te=Rn(e.objectName||void 0,e.resourceId==null?void 0:String(e.resourceId)),[ne,re]=Q.useState(!1),{t:F}=ka(),{currency:I}=Mr(),L=Ir(),{fieldOptionLabel:ie,fieldLabel:R}=Fr(),z=He(),ae=Q.useMemo(()=>{if(!z?.isLoaded||!e.objectName)return e;let t=t=>z.checkField(e.objectName,t,`read`),n=e=>e&&e.filter(e=>{let n=typeof e==`string`?e:e?.name;return!n||t(n)});return{...e,fields:n(e.fields),sections:e.sections?.map(e=>({...e,fields:n(e.fields)})),summaryFields:n(e.summaryFields)}},[e,z]),oe=Q.useMemo(()=>qn(p,z,e.objectName),[p,z,e.objectName]),B=Q.useMemo(()=>!z?.isLoaded||!e.objectName||z.can(e.objectName,`update`),[z,e.objectName]),se=Q.useMemo(()=>!z?.isLoaded||!e.objectName||z.can(e.objectName,`delete`),[z,e.objectName]),ce=e.resourceId==null?void 0:String(e.resourceId),le=Fo(e.objectName,ce,`update`,B),ue=Fo(e.objectName,ce,`delete`,se),de=Q.useMemo(()=>Hn(O?.userActions?.edit),[O]),fe=Q.useMemo(()=>Hn(O?.userActions?.delete),[O]),pe=O?.fields,V=rn(de?.visibleWhen??!0,p,{fallback:!1,warnOnError:!0,label:`builtin:edit:visibleWhen`,fields:pe}),he=rn(fe?.visibleWhen??!0,p,{fallback:!1,warnOnError:!0,label:`builtin:delete:visibleWhen`,fields:pe}),ge=rn(de?.disabledWhen,p,{fallback:!1,warnOnError:!0,label:`builtin:edit:disabledWhen`,fields:pe}),ve=rn(fe?.disabledWhen,p,{fallback:!1,warnOnError:!0,label:`builtin:delete:disabledWhen`,fields:pe}),ye=de?.disabledWhen!=null&&ge,be=fe?.disabledWhen!=null&&ve,H=Q.useMemo(()=>({...ae,showEdit:ae.showEdit&&B&&le&&V,showDelete:ae.showDelete&&se&&ue&&he}),[ae,B,le,V,se,ue,he]);Q.useEffect(()=>{p&&u&&u(p)},[p,u]);let xe=Q.useMemo(()=>{if(H.summaryFields&&H.summaryFields.length>0)return[];let e=[...Vo(H.sections),...H.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(O?.fields)for(let[e,n]of Object.entries(O.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>Za(p?.[e]),r=[],i=[`status`,`stage`,`state`,`phase`].find(e=>t[e]&&n(e))||Object.keys(t).find(e=>t[e]?.type===`select`&&n(e));i&&r.push(i);let a=Object.keys(t).find(e=>(t[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&n(e));a&&!r.includes(a)&&r.push(a);let o=Object.keys(t).find(e=>(t[e]?.type===`date`||t[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&n(e));return o&&!r.includes(o)&&r.push(o),r},[H.summaryFields,H.sections,H.fields,O,p]),Ce=H.summaryFields&&H.summaryFields.length>0?H.summaryFields:xe,we=Q.useCallback(()=>{H.resourceId&&navigator.clipboard.writeText(String(H.resourceId)).then(()=>{M(!0),setTimeout(()=>M(!1),1500)})},[H.resourceId]);Q.useEffect(()=>{let e=!0;if(H.data)return m(H.data),_(!1),t?.getObjectSchema&&H.objectName&&t.getObjectSchema(H.objectName).then(t=>{e&&k(t)}).catch(()=>{}),()=>{e=!1};if(t&&H.objectName&&H.resourceId){_(!0),k(null),m(null);let n=H.objectName,r=H.resourceId,i=`${n}-`,a=[...Vo(H.sections),...H.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;k(o);let s=Pn(o?.fields,a),c=z?.isLoaded?s.filter(e=>z.checkField(n,e,`read`)):s,l=c.length>0?{$expand:c}:void 0,u=l?t.findOne(n,r,l):t.findOne(n,r),d=()=>{let a=String(r),o=a.startsWith(i)?a.slice(i.length):`${i}${a}`;return(l?t.findOne(n,o,l):t.findOne(n,o)).then(t=>{e&&(m(t),_(!1))}).catch(()=>{e&&(m(null),_(!1))})};return u.catch(()=>null).then(t=>{if(e){if(t){m(t),_(!1);return}return d()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),_(!1))})}else H.api&&H.resourceId&&(_(!0),fetch(`${H.api}/${H.resourceId}`).then(e=>e.json()).then(t=>{e&&m(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&_(!1)}));return()=>{e=!1}},[H.api,H.resourceId,H.objectName,t,H.sections,H.fields,ee,te,z]);let Te=Q.useCallback(()=>{if(a)a();else if(H.onNavigate){let e=H.backUrl||(H.objectName?`/${H.objectName}`:`/`);H.onNavigate(e,{replace:!0})}else H.backUrl?window.location.href=H.backUrl:window.history.back()},[a,H]),Ee=Q.useCallback(()=>{r?r():H.onNavigate&&H.editUrl?H.onNavigate(H.editUrl):H.onNavigate&&H.objectName&&H.resourceId?H.onNavigate(`/${H.objectName}/${H.resourceId}/edit`):H.editUrl&&(window.location.href=H.editUrl)},[r,H]),De=Q.useCallback(async()=>{if(!t?.cancelPendingApproval||!H.objectName||!H.resourceId){D(F(`detail.cancelApprovalUnavailable`));return}re(!0),D(null);try{if(await t.cancelPendingApproval(String(H.objectName),String(H.resourceId)),t.findOne)try{let e=await t.findOne(String(H.objectName),String(H.resourceId));e&&m(e)}catch{}P(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(H.objectName),recordId:String(H.resourceId),reason:`approval-recalled`}}))}catch{}}catch(e){let t=(e?.message||e?.error||String(e??`Cancel failed`)).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``);D(`${F(`detail.cancelApprovalFailed`)}: ${t}`)}finally{re(!1)}},[t,H.objectName,H.resourceId,F]),Oe=Q.useCallback(()=>{let e=H.deleteConfirmation||F(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),H.onNavigate&&H.objectName&&H.onNavigate(`/${H.objectName}`,{replace:!0}))},[i,H]),ke=Q.useCallback(()=>{navigator.share&&H.objectName&&H.resourceId?navigator.share({title:H.title||F(`detail.details`),text:`${H.objectName} #${H.resourceId}`,url:window.location.href}).catch(e=>{console.error(`Share failed:`,e)}):navigator.clipboard.writeText(window.location.href)},[H]),Ae=Q.useCallback(()=>{let e=!b;f&&f(e),d===void 0&&y(e)},[b,d,f]),je=x?.setField,Ne=x&&x.canEdit?x.enter:void 0;Q.useEffect(()=>{if(!H.recordNavigation)return;let e=H.recordNavigation,t=t=>{let n=t.target?.tagName;n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable||(t.key===`ArrowLeft`&&e.currentIndex>0?(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex-1])):t.key===`ArrowRight`&&e.currentIndex<e.recordIds.length-1&&(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex+1])))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[H.recordNavigation]);let Pe=Q.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:F(`detail.share`),icon:`share-2`,type:`script`,onClick:ke}),H.showEdit&&e.push({name:`sys_edit_mobile`,label:F(`detail.edit`),icon:`square-pen`,type:`script`,className:`sm:hidden`,...ye?{disabled:!0}:null,onClick:Ee}),H.showDelete&&e.push({name:`sys_delete`,label:F(`detail.delete`),icon:`trash`,type:`script`,variant:`destructive`,tags:[`separator-before`],...be?{disabled:!0}:null,onClick:Oe}),e},[F,H.showEdit,H.showDelete,ye,be,ke,Ee,Oe]),W=Q.useMemo(()=>{let e=H.actions??[];if(Pe.length===0)return e;let t=!1,n=e.map(e=>{let n=e;if(n&&typeof n==`object`&&n.type===`action:bar`&&(!n.location||n.location===`record_header`)){t=!0;let e=Array.isArray(n.systemActions)?n.systemActions:[];return{...n,systemActions:[...e,...Pe]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:Pe}),n},[H.actions,Pe]);return g||H.loading?(0,$.jsxs)(`div`,{className:U(`space-y-4`,n),children:[(0,$.jsx)(J,{className:`h-10 w-full`}),(0,$.jsx)(J,{className:`h-64 w-full`}),(0,$.jsx)(J,{className:`h-48 w-full`})]}):!p&&!H.data?(0,$.jsxs)(`div`,{className:U(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,$.jsx)(`p`,{className:`text-lg font-semibold`,children:F(`detail.recordNotFound`)}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:F(`detail.recordNotFoundDescription`)}),(H.showBack??!0)&&(0,$.jsxs)(G,{variant:`outline`,size:`sm`,onClick:Te,className:`mt-4 gap-2`,children:[(0,$.jsx)(zr,{className:`h-4 w-4`}),F(`detail.goBack`)]})]}):(0,$.jsx)(j,{children:(0,$.jsxs)(`div`,{className:U(`space-y-6`,n),children:[H.showHeader!==!1&&(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:flex-wrap items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0 sm:min-w-64 w-full sm:w-auto`,children:[(H.showBack??!0)&&(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon`,onClick:Te,className:`shrink-0 mt-1`,children:(0,$.jsx)(zr,{className:`h-4 w-4`})})}),(0,$.jsx)(N,{children:F(`detail.back`)})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,$.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:Bo(oe,H,O,F(`detail.details`))}),Ce.map(e=>{let t=p?.[e];if(!Za(t))return null;let n=Vo(H.sections).concat(H.fields||[]).find(t=>t.name===e),r=O?.fields?.[e],i=n?.type||r?.type,a=R(H.objectName||``,e,n?.label||r?.label||e),o=String(t),s=null;try{if(i===`currency`){let e=Number(t);if(!Number.isNaN(e)){let t=Nr({...r,...n},I);o=t?new Intl.NumberFormat(L,{style:`currency`,currency:t,maximumFractionDigits:0}).format(e):new Intl.NumberFormat(L,{maximumFractionDigits:0}).format(e)}}else if(i===`date`||i===`datetime`){let e=En(t);Number.isNaN(e.getTime())||(o=i===`datetime`?e.toLocaleString(L,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(L,{dateStyle:`medium`}))}else if(i===`percent`){let e=Number(t);if(!Number.isNaN(e)){let t={...r,...n},a=h({type:i,scale:t.scale}),c=Me({type:i,max:t.max});o=Ie(e,c,a,L);let l=Ro(e,c);s=Math.max(0,Math.min(100,l))}}else if(i===`select`||i===`status`||i===`multiselect`){let i=n?.options||r?.options,a=String(t);if(Array.isArray(i)){let e=i.find(e=>String(e?.value??e)===String(t));e?.label&&(a=e.label)}else if(i&&typeof i==`object`){let e=i[String(t)];e?.label&&(a=e.label)}o=H.objectName?ie(H.objectName,e,String(t),a):a}}catch{}let c=Ha({name:e,label:n?.label,type:i||`text`},r),l=Ke(c)||i||`text`,u=o.includes(`[object Object]`),d=u&&Lo(l)?Re(l):null;return u&&!d&&(o=String(pt(t)??``)),d?(0,$.jsxs)(Qe,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"data-summary-chip":e,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:`${a}: `}),(0,$.jsx)(d,{value:t,field:c})]},e):s===null?(0,$.jsx)(Qe,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${a}: ${o}`,"data-summary-chip":e,children:o},e):(0,$.jsxs)(Qe,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15 gap-1.5 pl-2 pr-2`,"aria-label":`${a}: ${o}`,"data-summary-chip":e,children:[(0,$.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,$.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${s}%`}})}),o]},e)}),(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:Ae,"aria-label":F(b?`detail.removeFromFavorites`:`detail.addToFavorites`),children:b?(0,$.jsx)(Gi,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,$.jsx)(Gi,{className:`h-4 w-4 text-muted-foreground`})})}),(0,$.jsx)(N,{children:F(b?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),H.objectName&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:l||H.objectName}),H.resourceId&&(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:we,"aria-label":F(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:A?(0,$.jsx)(Yr,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(li,{className:`h-3 w-3`})})}),(0,$.jsx)(N,{children:A?F(`detail.copied`,{defaultValue:`Copied!`}):F(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[H.recordNavigation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(G,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:H.recordNavigation.currentIndex<=0,onClick:()=>{let e=H.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,$.jsx)(Zr,{className:`h-4 w-4`})})}),(0,$.jsx)(N,{children:F(`detail.previousRecord`)})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:F(`detail.recordOf`,{current:H.recordNavigation.currentIndex+1,total:H.recordNavigation.recordIds.length})}),(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(G,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:H.recordNavigation.currentIndex>=H.recordNavigation.recordIds.length-1,onClick:()=>{let e=H.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,$.jsx)(Qr,{className:`h-4 w-4`})})}),(0,$.jsx)(N,{children:F(`detail.nextRecord`)})]})]}),H.showEdit&&(0,$.jsxs)(Se,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsxs)(G,{variant:`default`,disabled:ye,onClick:()=>{ye||Ee()},className:`gap-2 hidden sm:inline-flex`,children:[(0,$.jsx)(Wi,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:F(`detail.edit`)})]})}),(0,$.jsx)(N,{children:F(`detail.editRecord`)})]}),W.map((e,t)=>(0,$.jsx)(Zn,{schema:lr(e),data:p},`header-action-${t}`))]})]}),Dt(H.header,e=>(0,$.jsx)(`div`,{children:(0,$.jsx)(Zn,{schema:lr(e),data:p})})),H.highlightFields&&H.highlightFields.length>0&&(0,$.jsx)(io,{fields:H.highlightFields,data:p,objectName:H.objectName,objectSchema:O}),o&&H.showHeader===!1&&(()=>{let e=p?.approval_status,n=e===`pending`||e===`in_approval`,r=x?.approvalPending??!1,i=r&&!(x?.locked??!1)?!1:(x?.locked??!1)||n,a=i||r||n,o=a?x?.approvalProgress:void 0,s=!!o&&o.need>0&&o.need<=12;return!a&&!E?null:(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[a&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsxs)(`span`,{role:`status`,className:i?`inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800`:`inline-flex items-center gap-1 rounded-md border border-sky-300 bg-sky-50 px-2 py-1 text-xs text-sky-800`,title:i?x?.lockedReason??F(`detail.lockedTooltip`):F(`detail.approvalPendingTooltip`),children:[i?(0,$.jsx)(Ei,{className:`h-3 w-3`}):(0,$.jsx)(si,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:F(i?`detail.lockedByApproval`:`detail.approvalPendingEditable`)})]}),t?.cancelPendingApproval&&x?.approvalIsSubmitter!==!1&&(0,$.jsxs)(G,{variant:`outline`,size:`sm`,onClick:De,disabled:ne,className:i?`gap-2 border-amber-300 text-amber-800 hover:bg-amber-50`:`gap-2 border-sky-300 text-sky-800 hover:bg-sky-50`,title:F(i?`detail.cancelApprovalTooltip`:`detail.cancelApprovalTooltipUnlocked`),children:[(0,$.jsx)(ta,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:F(ne?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),o&&(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-1 max-w-[16rem]`,children:[(0,$.jsxs)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":o.need,"aria-valuenow":Math.min(o.got,o.need),"aria-label":F(`detail.approvalProgressLabel`),className:`flex items-center gap-2 w-full justify-end`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground whitespace-nowrap`,children:o.behavior===`per_group`?F(`detail.approvalProgressGroups`,{got:o.got,need:o.need}):F(`detail.approvalProgress`,{got:o.got,need:o.need})}),s&&(0,$.jsx)(`span`,{className:`flex items-center gap-1 w-20 shrink-0`,children:Array.from({length:o.need}).map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:U(`h-1.5 flex-1 rounded-full`,t<o.got?`bg-emerald-500`:`bg-muted`)},t))})]}),o.groups&&o.groups.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:o.groups.map(e=>(0,$.jsxs)(`span`,{title:`${e.got}/${e.need}`,className:U(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px]`,e.satisfied?`border-emerald-300 text-emerald-700`:`border-border text-muted-foreground`),children:[e.satisfied?(0,$.jsx)(Yr,{className:`h-3 w-3`}):(0,$.jsx)(ai,{className:`h-2.5 w-2.5`}),(0,$.jsx)(`span`,{children:`${e.group} ${e.got}/${e.need}`})]},e.group))})]}),E&&(0,$.jsx)(`div`,{role:`alert`,className:`text-xs text-destructive bg-destructive/10 border border-destructive/20 rounded-md px-2 py-1 max-w-md text-right`,children:E})]})})(),H.autoTabs&&!H.tabs?.length?(()=>{let e=!!H.activities&&H.activities.length>0,n=!!s,r=!!H.history,i=[`details`,...e?[`activity`]:[],...n?[`discussion`]:[],...r?[`history`]:[]],a=H.defaultTab,c=a&&i.includes(a)?a:`details`,l=H.onTabChange,u=(0,$.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[H.sectionGroups&&H.sectionGroups.length>0&&H.sectionGroups.map((e,n)=>(0,$.jsx)(ro,{group:e,data:{...p,...w},objectSchema:O,objectName:H.objectName,isEditing:S,onFieldChange:je,onEnterInlineEdit:o?Ne:void 0,autoFocusField:T,dataSource:t},n)),H.sections&&H.sections.length>0&&H.sections.map((e,n)=>(0,$.jsx)(Ho,{section:e,index:n,children:(0,$.jsx)(to,{section:e,data:{...p,...w},objectSchema:O,objectName:H.objectName,isEditing:S,onFieldChange:je,onEnterInlineEdit:o?Ne:void 0,autoFocusField:T,dataSource:t})},n)),H.fields&&H.fields.length>0&&!H.sections?.length&&(0,$.jsx)(to,{section:{fields:H.fields,columns:H.columns},data:{...p,...w},objectSchema:O,objectName:H.objectName,isEditing:S,onFieldChange:je,onEnterInlineEdit:o?Ne:void 0,autoFocusField:T,dataSource:t}),H.comments&&(0,$.jsx)(oo,{comments:H.comments,onAddComment:H.onAddComment})]});return!e&&!n&&!r?(0,$.jsx)(`div`,{className:`mt-2`,children:u}):(0,$.jsxs)(_e,{defaultValue:c,onValueChange:l,className:`w-full`,children:[(0,$.jsxs)(Be,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,$.jsx)(xt,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:F(`detail.details`)}),e&&(0,$.jsx)(xt,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[F(`detail.activity`),(0,$.jsx)(Qe,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:H.activities.length})]})}),n&&(0,$.jsx)(xt,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:F(`detail.discussion`,{defaultValue:`Discussion`})}),r&&(0,$.jsx)(xt,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[F(`detail.history`,{defaultValue:`History`}),!H.history.loading&&H.history.entries.length>0&&(0,$.jsx)(Qe,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:H.history.entries.length})]})})]}),(0,$.jsx)(C,{value:`details`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:u}),e&&(0,$.jsx)(C,{value:`activity`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,$.jsx)(mo,{activities:H.activities})}),n&&(0,$.jsx)(C,{value:`discussion`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:s}),r&&(0,$.jsx)(C,{value:`history`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,$.jsx)(xo,{entries:H.history.entries,loading:H.history.loading,emptyText:H.history.emptyText??F(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,$.jsxs)($.Fragment,{children:[H.sectionGroups&&H.sectionGroups.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:H.sectionGroups.map((e,n)=>(0,$.jsx)(ro,{group:e,data:{...p,...w},objectSchema:O,objectName:H.objectName,isEditing:S,onFieldChange:je,onEnterInlineEdit:o?Ne:void 0,autoFocusField:T,dataSource:t},n))}),H.sections&&H.sections.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:H.sections.map((e,n)=>(0,$.jsx)(Ho,{section:e,index:n,children:(0,$.jsx)(to,{section:e,data:{...p,...w},objectSchema:O,objectName:H.objectName,isEditing:S,onFieldChange:je,onEnterInlineEdit:o?Ne:void 0,autoFocusField:T,dataSource:t})},n))}),H.fields&&H.fields.length>0&&!H.sections?.length&&(0,$.jsx)(to,{section:{fields:H.fields,columns:H.columns},data:{...p,...w},objectSchema:O,objectName:H.objectName,isEditing:S,onFieldChange:je,onEnterInlineEdit:o?Ne:void 0,autoFocusField:T,dataSource:t}),H.tabs&&H.tabs.length>0&&(0,$.jsx)(no,{tabs:H.tabs,data:p}),H.comments&&(0,$.jsx)(oo,{comments:H.comments,onAddComment:H.onAddComment}),H.activities&&H.activities.length>0&&(0,$.jsx)(mo,{activities:H.activities})]}),(0,$.jsx)(ko,{data:{...p,...w},objectSchema:O,objectName:H.objectName}),Dt(H.footer,e=>(0,$.jsx)(`div`,{children:(0,$.jsx)(Zn,{schema:lr(e),data:p})}))]})})},Wo=new Set([`title`,`description`,`icon`,`fields`,`collapsible`,`defaultCollapsed`,`columns`,`showBorder`,`headerColor`,`hideEmpty`]),Go=e=>{let t={},n={};for(let[r,i]of Object.entries(e))(Wo.has(r)?t:n)[r]=i;return(0,$.jsx)(to,{...n,section:t})};Go.displayName=`DetailSectionNode(DetailSection)`;function Ko(e){return ae(e)??Si}function qo(e,t){let n=e?.id??e?._id;if(t){let r=Xt(t,e),i=r===`Untitled`||n!=null&&r===`Record #${n}`;if(r&&!i)return r}return e?.full_name||e?.fullname||e?.display_name||e?.name||e?.subject||e?.title||e?.label||e?.code||e?.email||(n==null?void 0:String(n))}function Jo(e){if(!e)return[];if(typeof e==`string`){let t=e.trim();return t?t.startsWith(`-`)?[{field:t.slice(1),order:`desc`}]:[{field:t,order:`asc`}]:[]}return e.filter(e=>!!e?.field)}var Yo=`image`;function Xo(e){return Q.createElement(gt,{value:e})}function Zo(e){let t=e?.accessorKey||bn(e);return t?String(t):void 0}function Qo(e){return JSON.parse(e)}function $o(e,t,n){return!t?.isLoaded||!n?e:e.filter(e=>{let r=Zo(e);return!r||t.checkField(n,r,`read`)})}function es(e,t){return t?e.filter(e=>Zo(e)!==t):e}function ts(e,t){return t.size===0?e:e.filter(e=>{let n=Zo(e);return!(n&&t.has(n))})}var ns=({action:e,onToolbarAction:t})=>{let n=e.visible,r=mn(cr(n),void 0,{throwOnError:!0,label:`related-list toolbar action "${e.name}" (visible)`});if(ir(n)&&!r)return null;let i=e.icon?Ko(e.icon):null;return(0,$.jsxs)(G,{variant:e.variant===`primary`?`default`:`outline`,size:`sm`,onClick:n=>{n.stopPropagation(),t(e)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,"data-testid":`related-toolbar-action-${e.name}`,children:[i&&(0,$.jsx)(i,{className:`h-3.5 w-3.5`}),e.label||e.name]})},rs=({title:e,type:t,api:n,data:r,schema:i,columns:a,className:o,dataSource:s,objectName:c,onNew:l,newDisabled:u,onViewAll:d,onRowEdit:f,onRowDelete:p,onRowClick:m,rowActions:h,onRowAction:g,toolbarActions:_,onToolbarAction:v,add:y,redactFields:b,maxColumns:x=6,pageSize:S,defaultSort:C,sortable:w=!1,filter:E,filterable:D=!1,collapsible:O=!1,defaultCollapsed:k=!1,referenceField:A,parentId:j,icon:M})=>{let N=r!==void 0,ee=r??[],[P,te]=Q.useState(ee),[ne,F]=Q.useState(()=>!!n&&!N),[I,R]=Q.useState(0),[z,ae]=Q.useState(null),[oe,se]=Q.useState(`asc`),[ce,le]=Q.useState(``),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(!1),{ready:me,def:V}=Dr(n??``,s),[he,ge]=Q.useState(k),[_e,ve]=Q.useState(!1),[ye,be]=Q.useState(!1),[H,xe]=Q.useState(null),[Se,Ce]=Q.useState(0),[we,Te]=Q.useState({}),{t:De}=ka(),{fieldLabel:ke}=Fr(),Ae=He(),Me=wn(),Ne=Q.useMemo(()=>(_??[]).filter(e=>Me(e?.requiredPermissions)),[_,Me]),W=S&&S>0?S:0,Fe=D&&ce!==``,K=!N&&!!n&&W>0&&!!s&&typeof s.find==`function`&&!Fe,Ie=K?I:0,Le=K?z:null,Be=K?oe:`asc`,Ve=JSON.stringify(C??null),Ue=Q.useMemo(()=>Jo(C),[Ve]),Ge=gr(),Je=Kn(E,Ge),Xe=JSON.stringify(Je??null),Ze=Q.useMemo(()=>Cr(Je),[Xe]),q=Ze.ok?void 0:Ze.refusal,$e=Ze.ok?Ze.node:void 0,et=Q.useMemo(()=>{let e=Array.isArray(a)?a.map(e=>typeof e==`string`?e:e?.accessorKey||bn(e)).filter(e=>typeof e==`string`&&e.length>0):[],t=Pn(V?.fields,e.length>0?e:void 0).filter(e=>e!==A),r=c||n||``;return!Ae?.isLoaded||!r?t:t.filter(e=>Ae.checkField(r,e,`read`))},[a,V,A,c,n,Ae]),nt=et.join(`,`),J=Q.useMemo(()=>new Set((Array.isArray(b)?b:[]).filter(e=>typeof e==`string`&&e.length>0)),[b]),rt=Q.useMemo(()=>{let e=ts(Array.isArray(a)?a:[],J);if(e.length===0)return;let t=c||n||``,r=new Set([`id`]);for(let n of $o(es(e,A),Ae,t)){let e=Zo(n);e&&r.add(e)}for(let e of et)r.add(e);let i=V?.fields;if(i&&typeof i==`object`){let e=e=>!Ae?.isLoaded||!t||Ae.checkField(t,e,`read`),n=on(Nn({rowActionDefs:h,objectActions:V?.actions,userActions:V?.userActions}));for(let t of n){let n=Lt(i,t)!==void 0;(n||vr.has(t))&&(!n||e(t))&&r.add(t)}Lt(i,Yo)!==void 0&&e(Yo)&&r.add(Yo)}return Array.from(r)},[a,J,A,c,n,Ae,et,V,h]),Y=rt?rt.join(`,`):``;Q.useEffect(()=>{N&&te(r??[])},[r,N]);let it=Q.useMemo(()=>xn(V?.fields,A),[V,A]),X=y?.picker?.object,[ot,st]=Q.useState(null);Q.useEffect(()=>{if(!_e||!X||ot||!s?.getObjectSchema)return;let e=!1;return s.getObjectSchema(X).then(t=>{e||st(t)}).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${X}:`,e)}),()=>{e=!0}},[_e,X,ot,s]);let ct=y?.picker?.labelField||`name`,lt=Q.useMemo(()=>{let e=ie(ot,{displayField:ct});return e.length>0?e:void 0},[ot,ct]);Q.useEffect(()=>{y&&!X&&console.warn(`[RelatedList] "${n||c||`related list`}" declares add without add.picker.object — the Add affordance is not rendered. add.picker is required by the spec (RecordRelatedListProps.add): set add.picker.object to the object the picker should list.`)},[y,X,n,c]),Q.useEffect(()=>{let e=!1;if(q){F(!1);return}if(n&&!N){if(!(A&&j!=null&&j!==``)){n&&(j==null||j===``)&&!A&&console.warn(`[RelatedList] "${n}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),te([]),de(null),pe(!1),F(!1);return}if(F(!0),!me)return;let t=Ln(A,j,V?.fields),r=$e===void 0?t:Vn(t,$e);if(s&&typeof s.find==`function`){let t={$filter:r};if(et.length>0&&(t.$expand=et),rt&&(t.$select=rt),K){t.$top=W,t.$skip=Ie*W;let e=Le?[{field:Le,order:Be}]:Ue;e.length>0&&(t.$orderby=e)}s.find(n,t).then(t=>{if(e)return;let n=Array.isArray(t),r=n?t:Array.isArray(t?.data)?t.data:[];if(te(r),K){let e=!n&&typeof t?.total==`number`?t.total:null;de(e),pe(!n&&typeof t?.hasMore==`boolean`?t.hasMore:r.length===W)}else de(null),pe(!1);F(!1)}).catch(t=>{console.error(`Failed to fetch related data:`,t),e||F(!1)})}else if($e!==void 0)console.warn(`[RelatedList] "${n}" declares a filter but has no dataSource adapter — the raw-URL fallback cannot express it, so no rows are fetched. Pass a dataSource (RecordContext) to use a filtered related list.`),te([]),de(null),pe(!1),F(!1);else if(it)console.warn(`[RelatedList] "${n}" relates through the multi-value field "${A}" but has no dataSource adapter — the raw-URL fallback's \`filter[<field>]=<value>\` grammar has no membership operator, so no rows are fetched. Pass a dataSource (RecordContext) to use a related list on a multi-value relationship field.`),te([]),de(null),pe(!1),F(!1);else{let t=new URLSearchParams({[`filter[${A}]`]:String(j)}).toString();fetch(`${n}?${t}`).then(e=>e.json()).then(t=>{if(e)return;let n=Array.isArray(t)?t:t?.data||[];te(n),de(null),pe(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>{e||F(!1)})}}return()=>{e=!0}},[n,N,s,A,it,j,Se,K,W,Ie,Le,Be,Ve,Xe,nt,Y,me]),Q.useEffect(()=>{K&&!ne&&I>0&&P.length===0&&R(e=>Math.max(0,e-1))},[K,ne,P,I]),Q.useEffect(()=>{R(0)},[n,A,j,Xe]),Q.useEffect(()=>{if(!n||N)return;let e=e=>{let t=e.detail||{};t.objectName&&t.objectName!==`*`&&t.objectName!==n||Ce(e=>e+1)};return window.addEventListener(`objectui:related-changed`,e),()=>window.removeEventListener(`objectui:related-changed`,e)},[n,N]),Q.useEffect(()=>{if(!s?.find||!V?.fields||!P.length)return;let e=V.fields,t=[];for(let[n,r]of Object.entries(e)){if(!Mn(r))continue;let e=r.reference;if(!e)continue;let i=new Set;for(let e of P){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=we[n]||{},o=Array.from(i).filter(e=>!(e in a));o.length>0&&t.push({fieldName:n,target:e,ids:o})}if(t.length===0)return;let n=!1;return Promise.all(t.map(({fieldName:e,target:t,ids:n})=>Promise.all([s.find(t,{$filter:{id:{$in:n}},$top:n.length}),typeof s.getObjectSchema==`function`?s.getObjectSchema(t).catch(()=>void 0):Promise.resolve(void 0)]).then(([t,n])=>{let r=Array.isArray(t)?t:t?.data||[],i={};for(let e of r){let t=e?.id||e?._id;t&&(i[String(t)]=qo(e,n)??String(t))}return{fieldName:e,map:i}}).catch(t=>(console.warn(`[RelatedList] Failed to resolve lookups for ${e}:`,t),{fieldName:e,map:{}})))).then(e=>{n||Te(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[s,V,P]);let[ut,ft]=Q.useState(null),pt=Q.useCallback(e=>{ft(e)},[]),mt=Q.useCallback(async()=>{if(ut)try{await p?.(ut),Ce(e=>e+1)}catch(e){console.error(`[RelatedList] remove failed`,e)}ft(null)},[ut,p]),ht=Q.useCallback(async e=>{if(!y||!s||!n||A==null||j==null)return;let t=y.picker.valueField||`id`;be(!0),xe(null);try{for(let r of e||[]){let e=r?.[t]??r?.id;e!=null&&(y.linkField?await s.create?.(n,{[A]:j,[y.linkField]:e}):await s.update?.(y.picker.object,String(e),{[A]:j}))}Ce(e=>e+1)}catch(e){let t=e?.body?.error??e?.error??e?.message??String(e);xe(typeof t==`string`?t:`Failed to add`)}finally{be(!1),ve(!1)}},[y,s,n,A,j]),gt=Q.useMemo(()=>{let e=c||n||``,t=t=>$o(t,Ae,e),r=e=>es(e,A),i=e=>J.size>0&&!!e&&J.has(String(e)),o=e=>ts(e,J),s=e=>It(e)||typeof e==`string`&&e.trim()===``,l=e=>P.length?e.filter(e=>{let t=e?.accessorKey||bn(e);return!t||P.some(e=>!s(e?.[t]))}):e,u=(e,t)=>{if(!t?.type)return;let n=Ke({type:t.type,format:t.format})||t.type,r=Re(n);if(!r)return;let i=t.type===`lookup`||t.type===`master_detail`,a=Mn(t)?we[e]:void 0,o=i&&a&&Object.keys(a).length>0?Object.entries(a).map(([e,t])=>({value:e,label:t})):void 0,c=e=>{if(t.type!==`user`||!a||typeof e!=`string`&&typeof e!=`number`)return e;let n=a[String(e)];return n?{name:n}:e},l={name:e,label:t.label||e,type:t.type,...(o||t.options)&&{options:o||t.options},...t.currency&&{currency:t.currency},...t.precision!==void 0&&{precision:t.precision},...t.scale!==void 0&&{scale:t.scale},...t.useGrouping!==void 0&&{useGrouping:t.useGrouping},...t.max!==void 0&&{max:t.max},...t.format&&{format:t.format},...t.reference&&{reference:t.reference},...t.reference_field&&{reference_field:t.reference_field}};return e=>s(e)?Q.createElement(tt):Q.createElement(r,{value:c(e),field:l})},d=t=>{if(typeof t!=`string`){let e=t?.accessorKey||bn(t);if(!t||!e)return t;let n={};if(t.accessorKey||(n.accessorKey=e),!t.header){let e=In(t);e&&(n.header=e)}if(!t.cell&&!t.render){let t=V?.fields?.[e],r=t?u(String(e),t):void 0;r&&(n.cell=r)}return Object.keys(n).length>0?{...t,...n}:t}let n=V?.fields?.[t],r={accessorKey:t,header:n?.label||ke(e,t,n)||t,fieldDef:n,fieldType:n?.type},i=n?u(t,n):void 0;return i&&(r.cell=i),r};if(a&&a.length>0){let e=o(a.map(d));if(e.length>0)return l(t(r(e)))}if(!V?.fields)return[];let f=Array.isArray(V.highlightFields)?V.highlightFields.filter(e=>typeof e==`string`&&e.length>0):[];if(f.length>0){let e=l(t(r(o(f.map(d)))));if(e.length>0)return e.slice(0,Math.max(1,x))}let p=e,m=new Set([`richtext`,`markdown`,`html`,`json`]),h=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],g=Object.entries(V.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===A||t?.hidden||t?.type&&m.has(t.type)||i(e)||Ae?.isLoaded&&p&&!Ae.checkField(p,e,`read`))),_=new Set([`created_at`,`updated_at`,`created_by`,`updated_by`,`owner_id`,`organization_id`]);return g.sort(([e,t],[n,r])=>{let i=_.has(e);if(i!==_.has(n))return i?1:-1;let a=h.indexOf(e),o=h.indexOf(n),s=a>=0?a:100,c=o>=0?o:100;if(s!==c)return s-c;let l=t?.type===`select`||e.includes(`status`);return l===(r?.type===`select`||n.includes(`status`))?0:l?-1:1}),l(g.map(([e,t])=>{let n={accessorKey:e,header:ke(p,e,t.label||e)};if(t.type){let r=u(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,x))},[a,V,c,n,ke,A,P,x,we,Ae,J]),_t=en(V),vt=Q.useCallback((e,t)=>Mn(t)?!0:_t?!An(_t,e):jn(t),[_t]),yt=Q.useMemo(()=>K?gt.map(e=>{let t=e.accessorKey||bn(e),n=t?V?.fields?.[t]:void 0;return vt(t,n)?{...e,sortable:!1}:e}):gt,[gt,K,V,vt]),bt=!!n&&typeof s?.getObjectSchema==`function`&&!V?.fields,xt=Q.useMemo(()=>{let e=yt.map(e=>{if(!e||typeof e!=`object`)return e;let t=e.accessorKey||bn(e),n=t?V?.fields?.[t]:void 0,r=bt||za(e.type,n?.type);return bt&&typeof e.cell!=`function`?{...e,masked:!0,cell:Xo}:r&&e.masked!==!0?{...e,masked:!0}:e});return e.every((e,t)=>e===yt[t])?yt:e},[yt,V,bt]),St=Q.useMemo(()=>JSON.stringify(xt.flatMap(e=>{if(!e||typeof e!=`object`||e.masked===!0)return[];let t=Zo(e);return t?[t]:[]})),[xt]),Ct=Qo(St),wt=Q.useMemo(()=>{if(K||!ce)return P;let e=ce.toLowerCase(),t=Qo(St);return P.filter(n=>t.some(t=>{let r=n?.[t];return r!=null&&String(r).toLowerCase().includes(e)}))},[P,ce,K,St]),Tt=Q.useMemo(()=>{if(K||!z||!Qo(St).includes(z))return wt;let e=we[z],t=wt.map(t=>({row:t,key:nr(t[z],{labels:e})}));return t.sort((e,t)=>{let n=Rt(e.key,t.key);return oe===`asc`?n:-n}),t.map(e=>e.row)},[wt,z,oe,K,we,St]),Dt=W&&!K?Tt.slice(I*W,(I+1)*W):Tt,Ot=W?K?ue==null?I+(fe?2:1):Math.max(1,Math.ceil(ue/W)):Math.max(1,Math.ceil(Tt.length/W)):1,kt=K?ue==null?fe:(I+1)*W<ue:I<Ot-1,At=W>0&&(K?I>0||kt:Tt.length>W);Q.useEffect(()=>{R(0)},[ce,z,oe]);let jt=Q.useCallback(e=>{Qo(St).includes(e)&&(R(0),z===e?se(e=>e===`asc`?`desc`:`asc`):(ae(e),se(`asc`)))},[z,St]),Mt=Q.useMemo(()=>z?[{field:z,order:oe}]:Ue,[z,oe,Ue]),Nt=Q.useCallback(e=>{let t=e[0];t&&Qo(St).includes(t.field)&&(R(0),ae(t.field),se(t.order))},[St]),Pt=!i&&(t===`grid`||t===`table`),Ft=Array.isArray(h)&&h.length>0,zt=!!f||!!p||Ft,Bt=T(),Vt=Q.useMemo(()=>{if(i)return i;if(Bt&&(t===`grid`||t===`table`)){let e=gt[0]?.accessorKey||bn(gt[0]),t=gt.slice(1,4).map(e=>e.accessorKey||bn(e)).filter(Boolean);return{type:`object-gallery`,data:Dt,objectName:n,gallery:{titleField:e||`name`,visibleFields:t,coverField:Yo,cardSize:`medium`},onRowClick:m}}let e=Hn(V?.userActions?.edit),r=Hn(V?.userActions?.delete);switch(t){case`grid`:case`table`:return{type:`data-table`,data:Dt,columns:xt,pagination:!1,pageSize:W||10,searchable:!1,exportable:!1,manualSorting:!0,sort:Mt,onSortChange:Nt,rowActions:zt,onRowEdit:f,onRowDelete:p?pt:void 0,rowEditPredicates:e,rowDeletePredicates:r,onRowClick:m,rowActionDefs:Ft?h:void 0,onRowActionDef:Ft?g:void 0};case`list`:return{type:`data-list`,data:Dt};default:return{type:`div`,children:`No view configured`}}},[t,Dt,xt,gt,i,W,zt,Ft,h,g,f,p,pt,m,Bt,n,V,Mt,Nt]),Ht=O?`cursor-pointer select-none`:void 0,Ut=O?()=>ge(e=>!e):void 0,Wt=Ko(M),Gt=K&&ue!=null?ue:P.length,Kt=!ne&&P.length===0&&(!K||I===0),qt=D;return q?(0,$.jsxs)(Ee,{className:U(`shadow-none border-border/60 bg-transparent`,o),children:[(0,$.jsx)(Oe,{className:`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,children:(0,$.jsxs)(re,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,$.jsx)(Wt,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e})]})}),(0,$.jsx)(L,{className:`pt-0 pb-4 px-4`,children:(0,$.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-amber-300 bg-amber-50 p-3 text-sm text-amber-800`,"data-testid":`related-list-malformed-filter`,children:[(0,$.jsx)(`p`,{className:`font-medium`,"data-testid":`related-list-malformed-filter-subject`,children:De(`view.malformedFilter`,{subject:er(q)??``})}),(0,$.jsx)(`p`,{className:`mt-1 text-xs opacity-80`,children:q.message})]})})]}):(0,$.jsxs)(Ee,{className:U(`shadow-none border-border/60 bg-transparent`,Kt&&`bg-muted/10`,o),children:[(0,$.jsx)(Oe,{className:U(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,Ht),onClick:Ut,children:(0,$.jsxs)(re,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[O&&(he?(0,$.jsx)(Qr,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,$.jsx)(Xr,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,$.jsx)(Wt,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:U(`truncate`,Kt&&`text-muted-foreground font-medium`),children:e}),(0,$.jsx)(Qe,{variant:`secondary`,className:U(`text-xs font-normal h-5 px-1.5`,Gt===0&&`bg-muted text-muted-foreground`),"aria-label":`${Gt} records`,children:Gt}),Kt&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:De(`detail.noRelatedRecords`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[v&&Ne.map(e=>(0,$.jsx)(ns,{action:e,onToolbarAction:v},e.name)),y&&X&&s&&(0,$.jsxs)(G,{variant:Kt?`ghost`:`outline`,size:`sm`,disabled:ye,onClick:e=>{e.stopPropagation(),xe(null),ve(!0)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,$.jsx)(Fi,{className:`h-3.5 w-3.5`}),y.label||De(`detail.add`,{defaultValue:`Add`})]}),l&&(0,$.jsxs)(G,{variant:Kt?`ghost`:`outline`,size:`sm`,disabled:u,"data-testid":`related-list-new`,onClick:e=>{e.stopPropagation(),l()},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,$.jsx)(Fi,{className:`h-3.5 w-3.5`}),De(`detail.new`)]})]})]})}),!he&&!Kt&&(0,$.jsxs)(L,{className:U(`pt-0 pb-4 px-4`),children:[qt&&(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(je,{placeholder:De(`detail.filterPlaceholder`),value:ce,onChange:e=>le(e.target.value),className:`h-8 text-sm`})}),w&&!Pt&>&>.length>0&&P.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:gt.map(e=>{let t=e.accessorKey||bn(e);if(!t)return null;let n=V?.fields?.[t];if(K&&vt(t,n)||!Ct.includes(t))return null;let r=e.header||e.label||t,i=z===t;return(0,$.jsxs)(G,{variant:i?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>jt(t),children:[(0,$.jsx)(Hr,{className:`h-3 w-3`}),r,i&&(oe===`asc`?` ↑`:` ↓`)]},t)})}),ne&&P.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:De(`detail.loading`)}):(0,$.jsx)(`div`,{className:U(ne&&`opacity-60 pointer-events-none transition-opacity`),children:(0,$.jsx)(Zn,{schema:Vt})}),At&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,$.jsxs)(G,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:I===0,onClick:()=>R(e=>Math.max(0,e-1)),children:[(0,$.jsx)(Zr,{className:`h-3 w-3`}),De(`detail.previousPage`)]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:De(`detail.pageOf`,{current:I+1,total:Ot})}),(0,$.jsxs)(G,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:!kt,onClick:()=>R(e=>kt?e+1:e),children:[De(`detail.nextPage`),(0,$.jsx)(Qr,{className:`h-3 w-3`})]})]}),d&&!Kt&&At&&(0,$.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),d()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[De(`detail.viewAll`),(0,$.jsx)(fi,{className:`h-3 w-3`})]})})]}),(0,$.jsx)(ze,{open:ut!==null,onOpenChange:e=>{e||ft(null)},children:(0,$.jsxs)(at,{children:[(0,$.jsxs)(Pe,{children:[(0,$.jsx)(Et,{children:De(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,$.jsx)(Ye,{children:De(`detail.deleteRowConfirmation`)})]}),(0,$.jsxs)(qe,{children:[(0,$.jsx)(dt,{children:De(`detail.cancel`,{defaultValue:`Cancel`})}),(0,$.jsx)(We,{onClick:mt,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:De(`detail.delete`,{defaultValue:`Delete`})})]})]})}),H&&(0,$.jsx)(`div`,{className:`mx-4 mb-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,role:`alert`,children:H}),y&&X&&s&&(0,$.jsx)(B,{open:_e,onOpenChange:e=>ve(e),multiple:!0,dataSource:s,objectName:X,title:y.label||De(`detail.add`,{defaultValue:`Add`}),displayField:ct,columns:lt,cellRenderer:Re,fieldsMeta:ot?.fields,baseFilter:y.picker.filter,onSelect:()=>{},onSelectRecords:e=>{ht(e)}})]})};b();function is(e){return e==null?[]:Array.isArray(e)?e.filter(e=>e!=null):[e]}function as(e,t={}){let n={};for(let e of Object.keys(t))t[e]!==void 0&&(n[e]=t[e]);return Object.keys(n).length>0?{type:e,properties:n}:{type:e}}function os(e,t){if(!e||!t)return null;let n=e.fields?.[t]?.options;return!Array.isArray(n)||n.length===0?null:n.map(e=>({value:e.value,label:e.label}))}function ss(e){return Sn(e)??null}function cs(e,t,n=4){if(!e)return[];let r=Array.isArray(e.highlightFields)&&e.highlightFields.length>0?e.highlightFields:null;if(r){let t=ss(e);return r.filter(e=>typeof e==`string`&&e.length>0&&e!==t).slice(0,n)}let i=new Set([`id`,`_id`,`created_at`,`updated_at`,`deleted_at`,`created_by`,`updated_by`,`deleted_by`,`organization_id`,`workspace_id`,`tenant_id`,`org_id`]);t&&i.add(t);for(let t of[`name`,`full_name`,`title`,`subject`,`display_name`])t in(e.fields||{})&&i.add(t);let a=[`owner`,`owner_id`,`amount`,`rating`,`source`,`priority`,`industry`,`phone`,`email`,`close_date`,`due_date`,`start_date`,`expected_close_date`,`account`,`account_id`,`contact`,`contact_id`],o=new Set([`currency`,`number`,`integer`,`decimal`,`percent`,`date`,`datetime`,`time`,`reference`,`lookup`,`user`,`select`,`enum`,`multiselect`,`status`,`email`,`phone`,`url`,`text`,`string`]),s=[],c=e.fields||{},l=e=>{let t=c[e]?.type;return typeof t!=`string`||!cn(t)?!1:(_r(t),!0)},u=ss(e);u&&(l(u),i.add(u));for(let e of a)if(e in c&&!i.has(e)&&!l(e)&&s.push(e),s.length>=n)return s;for(let e of Object.keys(c)){if(s.includes(e)||i.has(e)||l(e))continue;let t=c[e]?.type;if((!t||o.has(t))&&(s.push(e),s.length>=n))break}return s}function ls(e,t={}){return as(`page:header`,{recordChrome:t.recordChrome!==!1,...Array.isArray(t.actions)&&t.actions.length>0?{actions:t.actions}:{}})}function us(e,t={}){let n=t.statusField??Qt(e),r=t.stages??(n?os(e,n):null),i=t.highlightFields??cs(e,n),a=[];return!t.hideHighlights&&i.length>0&&a.push(as(`record:highlights`,{fields:i})),!t.hidePath&&n&&r&&r.length>0&&a.push(as(`record:path`,{statusField:n,stages:r})),a}function ds(e){if(!e)return null;let t=g(e);if(!t)return null;let n=e.fields||{},r=e=>{let t=n[e]||{};return{name:e,label:t.label||e,type:t.type||`text`,...t.options?{options:t.options}:{},...t.reference?{reference:t.reference}:{},...t.reference_field?{reference_field:t.reference_field}:{},...t.currency?{currency:t.currency}:{},...t.currencyConfig?{currencyConfig:t.currencyConfig}:{}}},i=Ea(t.reduce((e,t)=>e+t.fields.length,0));return t.map(e=>({...e.key===void 0?{}:{name:e.key,label:e.label??e.key},...e.icon?{icon:e.icon}:{},...e.description?{description:e.description}:{},...e.collapse===`none`?{}:{collapsible:!0},...e.collapse===`collapsed`?{defaultCollapsed:!0}:{},columns:i,fields:e.fields.map(r)}))}function fs(e,t){return Array.isArray(t)&&t.length>0?t:ds(e)??void 0}function ps(e,t,n){return as(`record:details`,{sections:fs(e,t),...n&&n.length>0?{hideFields:n}:{}})}function ms(e,t={}){let n=t.statusField??Qt(e),r=t.highlightFields??cs(e,n),i=[{label:`Details`,value:`details`,children:[ps(e,t.sections,r)]}];if(!t.hideRelatedTab&&Array.isArray(t.related)&&t.related.length>0){let e=e=>as(`record:related_list`,{title:e.title,objectName:e.objectName,relationshipField:e.relationshipField,...e.columns?{columns:e.columns}:{},...e.limit?{limit:e.limit}:{},...e.icon?{icon:e.icon}:{},...e.sort?{sort:e.sort}:{},...e.filter?{filter:e.filter}:{}}),n=t=>({label:t.title||t.objectName,value:`related:${t.objectName}`,...t.icon?{icon:t.icon}:{},children:[e(t)]});if(t.relatedLayout===`tabs`)for(let e of t.related)i.push(n(e));else if(t.relatedLayout===`stack`)i.push({label:`Related`,value:`related`,children:t.related.map(e)});else{let r=t.related.filter(e=>e.isPrimary),a=t.related.filter(e=>!e.isPrimary);for(let e of r)i.push(n(e));a.length>0&&i.push({label:`Related`,value:`related`,children:a.map(e)})}}return t.approvals&&i.push({label:`Approvals`,value:`approvals`,...t.approvals.count==null?{}:{count:t.approvals.count},children:[as(`record:approvals`,{...t.approvals.node||{}})]}),e?.enable?.files===!0&&!t.hideAttachments&&i.push({label:`Attachments`,value:`attachments`,children:[gs()]}),t.showActivity&&i.push({label:`Activity`,value:`activity`,children:[as(`record:activity`)]}),t.history&&i.push({label:`History`,value:`history`,children:[as(`record:history`,{entries:t.history.entries,loading:t.history.loading,emptyText:t.history.emptyText,unknownUserText:t.history.unknownUserText})]}),as(`page:tabs`,{items:i})}function hs(){return as(`record:discussion`)}function gs(){return as(`record:attachments`)}function _s(e,t={}){let n=t.slots||{},r=[];`header`in n&&n.header!==void 0?r.push(...is(n.header)):r.push(ls(e,{recordChrome:t.recordChrome,actions:t.headerActions})),`actions`in n&&n.actions!==void 0&&r.push(...is(n.actions)),`alerts`in n&&n.alerts!==void 0&&r.push(...is(n.alerts)),`highlights`in n&&n.highlights!==void 0?r.push(...is(n.highlights)):r.push(...us(e,{highlightFields:t.highlightFields,statusField:t.statusField,stages:t.stages,hideHighlights:t.hideHighlights,hidePath:t.hidePath}));let i=t.showReferenceRail===!0&&!t.hideReferenceRail&&Array.isArray(t.related)&&t.related.length>=2,a=t.hideRelatedTab??i;if(`tabs`in n&&n.tabs!==void 0)r.push(...is(n.tabs));else if(`details`in n&&n.details!==void 0){let i=is(n.details),o=ms(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,approvals:t.approvals,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a,relatedLayout:t.relatedLayout,hideAttachments:t.hideAttachments}),s=o.properties?.items;Array.isArray(s)&&s.length>0&&(s[0]={...s[0],children:i}),r.push(o)}else r.push(ms(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,approvals:t.approvals,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a,relatedLayout:t.relatedLayout,hideAttachments:t.hideAttachments}));`discussion`in n&&n.discussion!==void 0?r.push(...is(n.discussion)):t.hideDiscussion||r.push(hs());let o=[{name:`main`,width:`full`,components:r}],s=is(n.rightRail);if(i||s.length>0){let e=[];i&&e.push(as(`record:reference_rail`,{entries:t.related.map(e=>({objectName:e.objectName,relationshipField:e.relationshipField,title:e.title,displayField:e.displayField,limit:3}))})),s.length>0&&e.push(...s),o.push({name:`aside`,width:`small`,className:`hidden xl:flex flex-col gap-4`,components:e})}return{type:`record`,pageType:`record`,object:e?.name,template:`full-width`,regions:o}}function vs(e,t){return!e||t?.label===void 0?null:`[ObjectUI] ${e} accessible name: \`aria.label\` is not read. The spec's AriaPropsSchema refuses that spelling (it is the alias of \`aria.ariaLabel\`), so this block announces its \`aria.ariaLabel\` when one is declared and its default name otherwise. Declare the name as \`aria.ariaLabel\`.`}function ys(e,t){let n=vs(e,t);(0,Q.useEffect)(()=>{n&&console.warn(n)},[n])}function bs(e,{defaultRole:t,defaultLabel:n,block:r}={}){let i=Ir();ys(r,e);let a=Wn(e,i),o=a[`aria-label`]||n,s=a[`aria-describedby`],c=a.role||t||(o||s?`region`:void 0);return{...o?{"aria-label":o}:{},...s?{"aria-describedby":s}:{},...c?{role:c}:{}}}var xs=e=>bn(e)??null;function Ss(e){return e===void 0?void 0:Number(e)}var Cs=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},ws=new Set;function Ts(e,t){let n=`${e}.${t}`;ws.has(n)||(ws.add(n),console.error(`[record:details] section group "${t}" is not declared in fieldGroups on object "${e}" — the section renders nothing. Declare the group on the object, or enumerate \`fields\` on the section. (\`@objectstack/lint\` reports this as \`page-section-group-unknown\`.)`))}var Es=({schema:e={},className:t,...n})=>{let r=Jt(),{designer:i}=Cs(n),a=bs(e.aria),o=r?.objectName||``,s=He(),{readableFields:c}=x(o),{sectionLabel:l}=Fr(),{language:u}=Lr(),d=Dn();if(!r)return(0,$.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...i,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:details — bind a record to preview`})});let f=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(f.length>0&&!s.hasCapabilities(f))return(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let p=e.enforceFieldSecurity===!0,m=Array.isArray(e.redactFields)?e.redactFields:[],h=e=>{if(!e||!p&&m.length===0)return e;let t=e.map(xs).filter(e=>!!e),n=new Set((p&&o?c(t):t).filter(e=>!m.includes(e)));return e.filter(e=>{let t=xs(e);return t?n.has(t):!1})},g=r.objectSchema,_=g?.fields,v=e=>{if(!e||typeof e!=`object`||typeof e.name!=`string`||e.label!==void 0)return e;let t=_?.[e.name]?.label;if(t==null)return e;let n=Pr(t,u);return n?{...e,label:n}:e},y=e=>typeof e==`string`?v({name:e}):e&&typeof e==`object`&&!e.name&&e.field?v({...e,name:e.field}):v(e),b=e=>Array.isArray(e)?e.map(y):e,S=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:xs(e)).filter(e=>!!e));for(let e of d)S.add(e);let C=qn(r.data??{},s,o),w=[Sn(g),pn(g),`name`,`full_name`,`title`,`subject`,`display_name`,`label`].filter(e=>typeof e==`string`&&e.length>0),T=fn(g);if(un(C,T)!==void 0)S.add(T);else{let e=g?.titleFormat,t=vn(e,C);if(t){let n=e=>un(C,e)===t,r=w.find(n)??Object.keys(C).find(r=>n(r)&&vn(e,{...C,[r]:void 0})!==t);r&&S.add(r)}else for(let e of w)if(un(C,e)!==void 0){S.add(e);break}}let E=e=>!e||S.size===0?e:e.filter(e=>{let t=xs(e);return!t||!S.has(t)}),D=E(b(h(e.fields))),O=Array.isArray(e.sections)?e.sections:[],k=new Map;if(O.some(e=>e&&typeof e==`object`&&typeof e.group==`string`))for(let e of ds(g)??[])typeof e.name==`string`&&k.set(e.name,e);let A=Array.isArray(e.sections)?e.sections.map(e=>{if(!e||typeof e!=`object`||typeof e.group!=`string`)return e;let t=k.get(e.group);if(!t)return Ts(o,e.group),null;let{group:n,...r}=e;return{...t,...r}}).filter(e=>e!=null).map(e=>{let t=e.label,n=t==null?void 0:Pr(t,u),r=e.name&&o?l(o,e.name,n??e.name):n;return{...e,title:r,showBorder:e.showBorder??!!r,hideEmpty:e.hideEmpty??!0,fields:E(b(h(e.fields)))}}):e.sections,j=br(g,s?.getObjectApiOperations?.(o)),M=(e.inlineEdit??!0)&&j,N={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:`vertical`,columns:Ss(e.columns),sections:A,fields:D,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:M};return(0,$.jsx)(`div`,{className:t,...i,...a,children:(0,$.jsx)(Uo,{schema:N,dataSource:r.dataSource,inlineEdit:M})})},Ds=e=>({toolbar:[],row:[],refused:e});function Os(e){if(!Array.isArray(e))return!1;let t=qt(e,void 0);return t.kind===`ids`&&t.ids.length>0}function ks(e,t){if(!Array.isArray(e))return Ds([{kind:`array`,message:"`actions` is not an array; it is a list of action ids"}]);let n=qt(e,t);if(n.kind===`refused`)return Ds([{kind:`array`,message:`${n.message} (on this block: action ids only)`}]);if(n.kind===`objects`)return e.length===0?Ds([]):Ds([{kind:`array`,message:"`actions` holds inline action objects; it is a list of action ids, each the `name` of an action declared on the related object's own `actions`"}]);let r=[],i=[],a=n.unresolved.map(({id:e})=>({kind:`unresolved`,id:e})),o=new Set;for(let e of n.actions){if(o.has(e.name))continue;o.add(e.name);let t={locations:Array.isArray(e.locations)?e.locations:void 0},n=Tn(t,`list_toolbar`),s=Tn(t,`list_item`)||Tn(t,`record_related`);n&&r.push(e),s&&i.push(e),!n&&!s&&a.push({kind:`unplaced`,id:String(e.name)})}return{toolbar:r,row:i,refused:a}}function As(e,t,n){return`record:related_list — actions refused: ${e.map(e=>e.kind===`array`?e.message:e.kind===`unplaced`?`"${e.id}" declares none of list_toolbar (header), list_item (row menu) or record_related (row menu inside a record) in its locations, so this list has nowhere to draw it`:n?`"${e.id}" is not an action of "${t}"`:`"${e.id}" could not be resolved: no metadata for "${t}" was found`).join(`; `)}.`}var js=e=>bn(e)||(e&&typeof e==`object`?e.key:null)||null;function Ms(e,t){let n=null;for(let r=0;r<e.length;r++){let i=e[r],a=i&&typeof i==`object`?i.label:void 0;typeof a==`object`&&a&&(n??=[...e],n[r]={...i,label:Pr(a,t)})}return n??e}var Ns=e=>e?.id??e?._id??null,Ps=5,Fs=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Is=({schema:e={},className:t,...n})=>{let r=Jt(),{designer:i}=Fs(n),a=bs(e.aria),o=Fr(),{language:s}=Lr(),c=e.objectName,l=c&&o.objectLabel?o.objectLabel({name:c,label:Cn(c)}):c?Cn(c):``,u=Pr(e.title,s)||l||`Related`,d=He(),{readableFields:f}=x(c||``),p=e.relationshipValueField||`id`,m=p===`id`?r?.recordId??null:r?.data?.[p]??null,h=or(),g=Q.useMemo(()=>c?h?.resolve({objectName:c,relationshipField:e.relationshipField,parentId:m})??null:null,[h,c,e.relationshipField,m]),_=e.actions,v=_!==void 0,y=!!c&&Os(_),{item:b,loading:S}=sn(`object`,y?c:null),C=Kt(),w=Q.useMemo(()=>{if(!v)return null;if(y&&S)return{toolbar:[],row:[],refused:[]};let e=Array.isArray(b?.actions)?b.actions:[],t=ks(_,e),n=e=>C(c||void 0,e);return{toolbar:t.toolbar.map(n),row:t.row.map(n),refused:t.refused}},[v,_,y,b,S,c,C]);if(!c)return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});if(d.isLoaded&&!d.can(c,`read`))return null;let T=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(T.length>0&&!d.hasCapabilities(T))return(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let E=e.enforceFieldSecurity===!0,D=Array.isArray(e.redactFields)?e.redactFields:[],O=Array.isArray(e.columns)?e.columns:[],k=O;if(E||D.length>0){let e=O.map(js).filter(e=>!!e),t=new Set((E?f(e):e).filter(e=>!D.includes(e)));k=O.filter(e=>{let n=js(e);return n?t.has(n):!1})}let A=w?g?.onToolbarAction&&w.toolbar.length>0?w.toolbar:void 0:g?.toolbarActions,j=w?g?.onRowAction&&w.row.length>0?w.row:void 0:g?.rowActions,M=w?.refused??[];return(0,$.jsxs)(`div`,{className:t,...i,...a,children:[M.length>0&&(0,$.jsx)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`record-related-list-actions-refused`,className:`mb-2 text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:As(M,c,!!b)}),(0,$.jsx)(rs,{title:u,type:`table`,api:c,objectName:c,referenceField:e.relationshipField,parentId:m,columns:Ms(k,s),redactFields:D.length>0?D:void 0,pageSize:typeof e.limit==`number`&&e.limit>0?e.limit:Ps,defaultSort:e.sort,filter:e.filter,dataSource:r?.dataSource,add:e.add?{...e.add,label:Pr(e.add.label,s)||void 0}:void 0,rowActions:j,onRowAction:g?.onRowAction,toolbarActions:A,onToolbarAction:g?.onToolbarAction,onNew:g?.onCreate,newDisabled:g?.createDisabled,onRowClick:g?.onView?e=>{let t=Ns(e);t!=null&&g.onView(t,e)}:void 0,onRowEdit:g?.onEdit?e=>{let t=Ns(e);t!=null&&g.onEdit(t,e)}:void 0,onRowDelete:g?.onDelete?e=>{let t=Ns(e);if(t!=null)return g.onDelete(t,e)}:e.add&&r?.dataSource?async e=>{let t=e?.id??e?._id;t!=null&&await r?.dataSource?.delete?.(c,String(t))}:void 0})]})},Ls={columns:!0,filter:!0,sort:!0,limit:`limit`},Rs={},zs=Ft(e=>{let t=Jt();return(0,$.jsx)(Tr,{schema:e.schema??Rs,mapping:Ls,dataSource:t?.dataSource,testId:`record-related-list`,errorTitle:`This related list’s data source could not be resolved`,children:t=>(0,$.jsx)(Is,{...e,schema:t})})}),Bs=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Vs=({schema:e={},className:t,...n})=>{let r=Jt(),{designer:i}=Bs(n),a=bs(e.aria),o=r?.objectName||``,s=He(),{readableFields:c}=x(o),l=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[],u=l.length===0||s.hasCapabilities(l),d=(Array.isArray(e.fields)?e.fields:[]).map(e=>typeof e==`string`?{name:e}:{name:e?.name,label:e?.label,type:e?.type,readonly:e?.readonly===!0}).filter(e=>typeof e.name==`string`&&e.name.length>0),f=e.enforceFieldSecurity===!0,p=Array.isArray(e.redactFields)?e.redactFields:[],m=f&&o?new Set(c(d.map(e=>e.name))):null,h=d.filter(e=>!(p.includes(e.name)||m&&!m.has(e.name))),g=Q.useId();return Gt(g,u?h.map(e=>e.name):[]),u?(0,$.jsx)(`div`,{className:t,...i,...a,children:(0,$.jsx)(io,{fields:h,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema,dataSource:r?.dataSource})}):(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})})},Hs=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),r=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),i=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,$.jsxs)(`div`,{className:U(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,$.jsx)(Vr,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`text-foreground`,children:i})]})},Us=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],Ws=({reactions:e,onToggleReaction:t,emojiOptions:n=Us,className:r})=>{let[i,a]=Q.useState(!1),{t:o}=ka(),s=Q.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,$.jsxs)(`div`,{className:U(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>{let n=o(`detail.reactionCount`,{emoji:e.emoji,count:e.count});return(0,$.jsxs)(`button`,{type:`button`,className:U(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors`,e.reacted?`bg-primary/10 border-primary/30 text-primary`:`bg-muted border-border text-muted-foreground hover:bg-muted/80`),onClick:()=>s(e.emoji),disabled:!t,"aria-label":n,children:[(0,$.jsx)(`span`,{children:e.emoji}),(0,$.jsx)(`span`,{children:e.count})]},e.emoji)}),t&&(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":o(`detail.addReaction`),children:(0,$.jsx)(hi,{className:`h-3.5 w-3.5`})}),i&&(0,$.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":o(`detail.emojiPicker`),children:n.map(t=>(0,$.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>s(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function Gs(e,t,n){try{let r=new Date(e),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4);if(a<1)return t(`detail.justNow`);if(a<60)return t(`detail.minutesAgo`,{count:a});let o=Math.floor(a/60);if(o<24)return t(`detail.hoursAgo`,{count:o});let s=Math.floor(o/24);return s<7?t(`detail.daysAgo`,{count:s}):r.toLocaleDateString(n)}catch{return e}}var Ks=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=ka(),o=Ir(),[s,c]=Q.useState(!1),[l,u]=Q.useState(``),[d,f]=Q.useState(!1),p=Q.useCallback(async()=>{let t=l.trim();if(t&&n){f(!0);try{await n(e.id,t),u(``)}catch{}finally{f(!1)}}},[l,n,e.id]),m=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),p())},[p]);return t.length===0&&!r?null:(0,$.jsxs)(`div`,{className:U(`ml-10 mt-1`,i),children:[t.length>0&&(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>c(!s),"aria-expanded":s,children:[s?(0,$.jsx)(Xr,{className:`h-3 w-3`}):(0,$.jsx)(Qr,{className:`h-3 w-3`}),(0,$.jsx)(Oi,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:a(`detail.replyCount`,{count:t.length})})]}),s&&(0,$.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,$.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,$.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground`,children:e.actor.charAt(0).toUpperCase()})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gs(e.createdAt,a,o)})]}),(0,$.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,$.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,$.jsx)(`input`,{className:`flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.replyPlaceholder`),value:l,onChange:e=>u(e.target.value),onKeyDown:m,disabled:d}),(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:p,disabled:!l.trim()||d,"aria-label":`Send reply`,children:(0,$.jsx)(Vi,{className:`h-3 w-3`})})]})]})},qs=({subscription:e,onToggle:t,className:n})=>{let{t:r}=ka(),[i,a]=Q.useState(!1),o=Q.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:U(`h-8 w-8`,n),onClick:o,disabled:i||!t,"aria-label":e.subscribed?r(`detail.unsubscribeAriaLabel`):r(`detail.subscribeAriaLabel`),title:e.subscribed?r(`detail.subscribedTooltip`):r(`detail.unsubscribedTooltip`),children:e.subscribed?(0,$.jsx)(Kr,{className:`h-4 w-4 text-primary`}):(0,$.jsx)(Gr,{className:`h-4 w-4 text-muted-foreground`})})};function Js(e){let t=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/```([\s\S]*?)```/g,`<pre class="bg-muted rounded p-2 text-xs font-mono my-1 overflow-x-auto">$1</pre>`).replace(/`([^`]+)`/g,`<code class="bg-muted rounded px-1 py-0.5 text-xs font-mono">$1</code>`).replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`).replace(/\*(.+?)\*/g,`<em>$1</em>`).replace(/@(\w+)/g,`<span class="text-primary font-medium">@$1</span>`).replace(/^- (.+)$/gm,`<li class="ml-4 list-disc">$1</li>`).replace(/\n/g,`<br/>`);return t=t.replace(/(<li[^>]*>.*?<\/li>(?:<br\/>)?)+/g,e=>`<ul class="my-1">${e.replace(/<br\/>/g,``)}</ul>`),t}var Ys=({value:e,onChange:t,onSubmit:n,mentionSuggestions:r=[],placeholder:i,className:a,disabled:o=!1,extraSlot:s,canSubmitEmpty:c=!1})=>{let{t:l}=ka(),[u,d]=Q.useState(!1),[f,p]=Q.useState(!1),[m,h]=Q.useState(``),[g,_]=Q.useState(0),v=Q.useRef(null),y=Q.useMemo(()=>{if(!m)return r;let e=m.toLowerCase();return r.filter(t=>t.label.toLowerCase().includes(e))},[m,r]),b=Q.useCallback((n,r=``)=>{let i=v.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);t(e.slice(0,a)+n+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+n.length+s.length;i.setSelectionRange(e,e)})},[e,t]),x=Q.useCallback(()=>b(`**`,`**`),[b]),S=Q.useCallback(()=>b(`*`,`*`),[b]),C=Q.useCallback(()=>b(`
|
|
2
|
+
- `,``),[b]),w=Q.useCallback(()=>b("`","`"),[b]),T=Q.useCallback(()=>{b(`@`,``),p(!0),h(``),_(0)},[b]),E=Q.useCallback(n=>{let r=v.current;if(!r)return;let i=r.selectionStart,a=e.slice(0,i).lastIndexOf(`@`);a!==-1&&t(e.slice(0,a)+`@${n.label} `+e.slice(i)),p(!1),h(``),requestAnimationFrame(()=>r.focus())},[e,t]),D=Q.useCallback(e=>{let n=e.target.value;t(n);let r=e.target.selectionStart,i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a!==-1){let e=i.slice(a+1),t=a>0?i[a-1]:` `;if(/\s/.test(t)&&!/\s/.test(e)){p(!0),h(e),_(0);return}}p(!1)},[t]),O=Q.useCallback(e=>{if(f&&y.length>0){if(e.key===`ArrowDown`){e.preventDefault(),_(e=>e<y.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),_(e=>e>0?e-1:y.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),E(y[g]);return}if(e.key===`Escape`){p(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),n?.())},[f,y,g,E,n]);return(0,$.jsxs)(`div`,{className:U(`border rounded-md`,a),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:x,disabled:o||u,title:l(`detail.bold`),children:(0,$.jsx)(qr,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:S,disabled:o||u,title:l(`detail.italic`),children:(0,$.jsx)(Ci,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:C,disabled:o||u,title:l(`detail.listFormat`),children:(0,$.jsx)(wi,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:o||u,title:l(`detail.inlineCode`),children:(0,$.jsx)(ci,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:o||u,title:l(`detail.mentionSomeone`),children:(0,$.jsx)(Ur,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>d(!u),title:l(u?`detail.edit`:`detail.preview`),children:u?(0,$.jsx)(Wi,{className:`h-3.5 w-3.5`}):(0,$.jsx)(mi,{className:`h-3.5 w-3.5`})}),n&&(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:n,disabled:o||!c&&!e.trim(),title:l(`detail.submitComment`),children:(0,$.jsx)(Vi,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`relative`,children:u?(0,$.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:Js(e)}}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`textarea`,{ref:v,className:`w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground`,placeholder:i??l(`detail.writeComment`),value:e,onChange:D,onKeyDown:O,disabled:o}),f&&y.length>0&&(0,$.jsx)(`div`,{className:`absolute left-2 bottom-full mb-1 w-56 bg-popover border rounded-md shadow-md z-50 max-h-40 overflow-y-auto`,children:y.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:U(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===g&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),E(e)},children:[e.avatarUrl?(0,$.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,$.jsx)(`div`,{className:`h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium`,children:e.label.charAt(0).toUpperCase()}),(0,$.jsx)(`span`,{children:e.label})]},e.id))})]})}),s&&(0,$.jsx)(`div`,{className:`border-t px-2 py-2 bg-muted/20`,children:s})]})};function Xs(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Zs(e){return e.startsWith(`image/`)}function Qs(e){return Zs(e)?xi:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?vi:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?gi:yi}var $s=({attachments:e,onUpload:t,onRemove:n,className:r,readOnly:i=!1})=>{let{t:a}=ka(),[o,s]=Q.useState(!1),c=Q.useRef(null),l=Q.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!0)},[]),u=Q.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1)},[]),d=Q.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),f=Q.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,$.jsxs)(`div`,{className:U(`space-y-2`,r),children:[t&&!i&&(0,$.jsxs)(`div`,{className:U(`border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer`,o?`border-primary bg-primary/5`:`border-muted-foreground/25 hover:border-muted-foreground/40`),onDragOver:l,onDragLeave:u,onDrop:d,onClick:()=>c.current?.click(),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c.current?.click())},children:[(0,$.jsx)($i,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`detail.dropFilesToUpload`)}),(0,$.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:f})]}),e.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(ji,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:a(`detail.attachmentCount`,{count:e.length})})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=Zs(e.type),r=Qs(e.type);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-2.5 py-2 bg-muted/30 group`,children:[t&&(e.thumbnailUrl||e.url)?(0,$.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,$.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,$.jsx)(r,{className:`h-5 w-5 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:Xs(e.size)})]}),n&&!i&&(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>n(e.id),title:a(`detail.removeAttachment`),children:(0,$.jsx)(ta,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},ec={comment:Oi,field_change:Wi,task:Ui,event:Jr,system:na,email:Di,call:Ni,note:Ki,file:vi,sharing:Hi,record_create:ri,record_delete:Yi,approval:Wr},tc={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`,note:`bg-yellow-100 text-yellow-700`,file:`bg-slate-100 text-slate-600`,sharing:`bg-sky-100 text-sky-600`,record_create:`bg-emerald-100 text-emerald-600`,record_delete:`bg-red-100 text-red-600`,approval:`bg-violet-100 text-violet-600`};function nc(e){return[{value:`all`,label:e(`detail.allActivity`)},{value:`comments_only`,label:e(`detail.commentsOnly`)},{value:`changes_only`,label:e(`detail.fieldChangesFilter`)},{value:`tasks_only`,label:e(`detail.tasksOnly`)}]}function rc(e,t,n){try{let r=new Date(e),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4);if(a<1)return t(`detail.justNow`);if(a<60)return t(`detail.minutesAgo`,{count:a});let o=Math.floor(a/60);if(o<24)return t(`detail.hoursAgo`,{count:o});let s=Math.floor(o/24);return s<7?t(`detail.daysAgo`,{count:s}):r.toLocaleDateString(n)}catch{return e}}function ic(e){return e.type===`comment`}function ac(e,t){switch(t){case`comments_only`:return e.filter(e=>e.type===`comment`);case`changes_only`:return e.filter(e=>e.type===`field_change`);case`tasks_only`:return e.filter(e=>e.type===`task`);default:return e}}var oc=({items:e,config:t,filterMode:n,onFilterChange:r,hasMore:i=!1,onLoadMore:a,loading:o=!1,onAddComment:s,onAddReply:c,onToggleReaction:l,subscription:u,onToggleSubscription:d,collapseWhenEmpty:f=!1,mentionSuggestions:p,onUploadAttachments:m,titleLabel:h,emptyLabel:g,activityDenied:_=!1,commentsDenied:v=!1,className:y})=>{let{t:b}=ka(),x=Ir(),[S,C]=Q.useState(`all`),[w,T]=Q.useState(``),[E,O]=Q.useState(!1),[k,A]=Q.useState(!1),[j,M]=Q.useState([]),[N,ee]=Q.useState(!1),P=h??b(`detail.activity`),te=_||v?(0,$.jsxs)(`div`,{role:`status`,"data-testid":`activity-access-denied`,className:`flex flex-col gap-2 py-4 text-sm text-muted-foreground`,children:[_&&(0,$.jsxs)(`p`,{"data-denied-source":`activity`,className:`flex items-center gap-2`,children:[(0,$.jsx)(Ei,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:b(`detail.activityAccessDenied`)})]}),v&&(0,$.jsxs)(`p`,{"data-denied-source":`comments`,className:`flex items-center gap-2`,children:[(0,$.jsx)(Ei,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:b(`detail.commentsAccessDenied`)})]})]}):null,ne=n??S,re=t?.showFilterToggle!==!1,F=t?.showCommentInput!==!1&&!!s,I=t?.enableReactions??!1,L=t?.enableThreading??!1,ie=t?.showSubscriptionToggle??!1,R=Q.useMemo(()=>ac(e,ne),[e,ne]),z=Q.useMemo(()=>L?R.filter(e=>!e.parentId):R,[R,L]),ae=Q.useMemo(()=>{if(!L)return new Map;let e=new Map;for(let t of R)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[R,L]),oe=Q.useCallback(e=>{r?r(e):C(e)},[r]),B=Q.useCallback(async()=>{let e=w.trim();if(s&&(e||j.length!==0)){O(!0);try{await s(e,j.length>0?j:void 0),T(``),M([])}catch{}finally{O(!1)}}},[w,j,s]),ce=Q.useCallback(async e=>{if(m&&e.length!==0){ee(!0);try{let t=await m(e);Array.isArray(t)&&t.length>0&&M(e=>[...e,...t])}finally{ee(!1)}}},[m]),le=Q.useCallback(e=>{M(t=>t.filter(t=>t.id!==e))},[]),ue=Q.useCallback(async()=>{if(a){A(!0);try{await a()}finally{A(!1)}}},[a]);return(0,$.jsxs)(`section`,{className:U(`border-t border-border/60 pt-5`,y),"aria-label":P,children:[(0,$.jsx)(`header`,{className:`mb-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold leading-none tracking-tight`,children:[(0,$.jsx)(Rr,{className:`h-4 w-4`}),P,(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,R.length,`)`]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:ie&&u&&(0,$.jsx)(qs,{subscription:u,onToggle:d})})]})}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[re&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(se,{value:ne,onValueChange:e=>oe(e),children:[(0,$.jsx)(D,{"aria-label":b(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,$.jsx)(Te,{})}),(0,$.jsx)(ye,{children:nc(b).map(e=>(0,$.jsx)(Nt,{value:e.value,children:e.label},e.value))})]})}),F&&(0,$.jsx)(Ys,{value:w,onChange:T,onSubmit:B,mentionSuggestions:p,placeholder:b(`detail.leaveCommentPlaceholder`),disabled:E,canSubmitEmpty:j.length>0,extraSlot:m?(0,$.jsx)($s,{attachments:j,onUpload:ce,onRemove:le,readOnly:E||N}):j.length>0?(0,$.jsx)($s,{attachments:j,onRemove:le,readOnly:E}):void 0}),R.length>0&&te,o&&R.length===0?(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`activity-loading`,className:`flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground`,children:[(0,$.jsx)(Ti,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:b(`detail.loading`)})]}):(_||v)&&R.length===0?te:R.length===0?f?null:(0,$.jsx)(ft,{title:g??b(`detail.noActivity`),className:`py-6`}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,$.jsx)(`div`,{className:`space-y-4`,children:z.map(e=>{let t=ec[e.type]||na,n=tc[e.type]||`bg-gray-100 text-gray-600`,r=ae.get(e.id)??[],i=I&&l&&ic(e)?t=>l(e.id,t):void 0;return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:U(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,$.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:b(`detail.via`,{source:e.source})}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:rc(e.createdAt,b,x)}),e.edited&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:b(`detail.edited`)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,b(`detail.pinned`)]})]}),e.body&&(0,$.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.sourceObject&&e.sourceId!=null&&(0,$.jsxs)(`a`,{href:`/objects/${e.sourceObject}/${e.sourceId}`,className:`mt-1 inline-flex items-center gap-1 text-xs text-primary hover:underline`,"data-testid":`activity-source-link`,children:[b(`detail.viewSource`),(0,$.jsx)(`span`,{"aria-hidden":!0,children:`→`})]}),e.type===`field_change`&&e.fieldChanges&&(0,$.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,$.jsx)(Hs,{change:e},t))}),I&&e.reactions&&e.reactions.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(Ws,{reactions:e.reactions,onToggleReaction:i})}),(!e.reactions||e.reactions.length===0)&&i&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(Ws,{reactions:[],onToggleReaction:i})})]})]}),L&&(e.replyCount??0)>0&&(0,$.jsx)(Ks,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,$.jsx)(`div`,{className:`text-center pt-2`,children:(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,onClick:ue,disabled:k,"aria-label":b(`detail.loadMore`),children:[k?(0,$.jsx)(Ti,{className:`h-4 w-4 animate-spin mr-1`}):(0,$.jsx)(Xr,{className:`h-4 w-4 mr-1`}),b(`detail.loadMore`)]})})]})]})};b();var sc=m.options,cc=u.options,lc={created:`field_change`,updated:`field_change`,deleted:`field_change`,assigned:`field_change`,shared:`field_change`,system:`system`,completed:`task`,scheduled:`event`,commented:void 0,mentioned:void 0,login:void 0,logout:void 0},uc=`system`,dc=[`comment`],fc=[`record_create`,`record_delete`,`sharing`],pc=new Set([...Object.values(lc).filter(e=>!!e),uc,...dc]),mc=new Set([`task`]);function hc(e,t,n,r){let i=n.filter(n=>!e.has(JSON.stringify([t,n])));if(i.length!==0){for(let n of i)e.add(JSON.stringify([t,n]));console.warn(r(i))}}var gc=new Set,_c=new Set,vc=new Set;function yc(e,t){if(typeof e==`string`&&sc.includes(e))return e;if(e!=null){let n=typeof e==`string`?`"${e}"`:typeof e;hc(vc,t,[typeof e==`string`?e:`non-string ${n}`],()=>`[${t}] ignoring an unrecognised \`filterMode\` (${n}) and opening on "all" instead — the WIDEST mode, which shows EVERY activity rather than the slice that was asked for. No declared filter mode matches it. The fallback is kept rather than passing the value through because a dropdown handed a value with no matching item renders blank (objectui#3151), so this is a diagnostic, not a refusal. Declared filter modes: ${sc.join(`, `)}.`)}return`all`}function bc(e,t){let n=e.filter(e=>!pc.has(e));n.length!==0&&hc(_c,t,n,e=>{let n=e=>e.map(e=>`"${e}"`).join(`, `),r=e.filter(e=>fc.includes(e)),i=e.filter(e=>!fc.includes(e)),a=`[${t}] \`types\` names ${e.length} declared feed item type${e.length===1?``:`s`} that NO ObjectUI producer emits, so ${e.length===1?`it selects`:`they select`} nothing: ${n(e)}. The entr${e.length===1?`y is`:`ies are`} honoured as authored — nothing is dropped or widened — but a timeline filtered to ${e.length===1?`it`:`them`} alone renders permanently empty, which is the thing that used to happen with no diagnostic at all.`;return r.length>0&&(a+=` DELIBERATELY NOT ADOPTED, a decision rather than a gap: ${n(r)} — \`created\` / \`deleted\` / \`shared\` activity is mapped to \`field_change\` on purpose, because the record page and this block have to agree about what a \`created\` row IS before either can move to the richer kind. Adopting them is a change to that shared map (ACTIVITY_TYPE_TO_FEED_TYPE, @object-ui/plugin-detail), not to one block.`),i.length>0&&(a+=` NO PRODUCER on any ObjectUI surface: ${n(i)} — @objectstack/spec declares the kind and nothing here emits it. Whether that is a gap or a decision nobody wrote down is not recorded anywhere this diagnostic can read, so it reports the measurement and stops there.`),a+=` Feed item types ObjectUI produces today: ${[...pc].sort().join(`, `)}. If your HOST supplies the feed — \`items\` on the node, or a DiscussionContext it mounts — it may produce kinds this census cannot see, and this warning does not apply to them.`,a})}function xc(e,t){if(e==null)return;if(!Array.isArray(e)){let n=typeof e==`string`?`"${e}"`:typeof e;return hc(gc,t,[`non-array ${n}`],()=>`[${t}] ignoring an authored \`types\` that is not an array (${n}). \`types\` must be a LIST of feed item types. The timeline renders empty rather than falling back to every kind, because a filter that cannot be read is not a request to remove the filter. Declared feed item types: ${cc.join(`, `)}.`),[]}let n=[],r=[];for(let t of e)typeof t==`string`&&cc.includes(t)?n.push(t):r.push(typeof t==`string`?t:String(t));return r.length>0&&hc(gc,t,r,e=>`[${t}] ignoring ${e.length} unrecognised \`types\` entr${e.length===1?`y`:`ies`}: ${e.map(e=>`"${e}"`).join(`, `)}. No declared feed item type matches, so they select nothing; only the recognised entries narrow the timeline, and a list with NO recognised entry renders an EMPTY timeline rather than every kind. Declared feed item types: ${cc.join(`, `)}.`),bc(n,t),n}function Sc(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function Cc(e){return Sc(e)?e:20}function wc(e){if(typeof e==`number`)return String(e);if(typeof e==`string`)return JSON.stringify(e);try{let t=JSON.stringify(e);if(t!==void 0)return t}catch{}return String(e)}function Tc(e,t){return t==null||Sc(t)?null:`[ObjectUI] ${e} row cap: declared limit: ${wc(t)} (${Array.isArray(t)?`array`:typeof t}), which is not a positive integer number. The spec declares \`limit\` as z.number().int().positive() and refuses strings, booleans, fractions, zero and negatives, so it was ignored and this block fell back to its default row cap (20).`}function Ec(e){let t=e.timestamp;return String(!t||t===`NOW()`||Number.isNaN(Date.parse(String(t)))?e.created_at??``:t)}var Dc=new Set;function Oc(e){hc(Dc,``,[e],()=>`[record:activity] rendered a sys_activity row with type "${e}" through the generic "${uc}" presentation: no feed item type is mapped for it. \`sys_activity.type\` is author-extensible (ruled 2026-08-24) and is not validated on write, so a producer can store a value the platform never declared — the row is shown rather than dropped. Map it in ACTIVITY_TYPE_TO_FEED_TYPE (@object-ui/plugin-detail) to give it its own presentation.`)}function kc(e,t){let n=String(e?.type),r=Object.prototype.hasOwnProperty.call(lc,n);r||Oc(n);let i=r?lc[n]:uc;return i?{id:e.id,type:i,actor:e.actor_name??t,actorAvatarUrl:e.actor_avatar_url??void 0,body:e.summary??``,createdAt:Ec(e),sourceObject:e.source_object??void 0,sourceId:e.source_id??void 0}:null}function Ac(e,t,n,r){let i=e.slice();t.unifiedTimeline===!1&&(i=i.filter(e=>e.type!==`field_change`)),t.showCompleted!==!0&&(i=i.filter(e=>!mc.has(e.type)));let a=xc(t.types,r);if(a!==void 0){let e=new Set(a);i=i.filter(t=>e.has(t.type))}let o=i.length,s=Math.max(1,Math.floor(n)||20);return{items:o>s?i.slice(o-s):i,total:o,hasMore:o>s}}function jc(...e){let t=new Map;for(let n of e)for(let e of n)t.set(String(e.id),e);return Array.from(t.values()).sort((e,t)=>{let n=e.createdAt?Date.parse(e.createdAt):0,r=t.createdAt?Date.parse(t.createdAt):0;return(Number.isNaN(n)?0:n)-(Number.isNaN(r)?0:r)})}function Mc(e){let t=yr(e);return t===`forbidden`||t===`unauthorized`}var Nc=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Pc=`record:activity`,Fc=({schema:e={},className:t,...n})=>{let{designer:r}=Nc(n),i=bs(e.aria),a=Jt(),o=Or(),s=Ar(),c=e.properties??{},l=t=>e[t]??c[t],u=l(`limit`),d=Cc(u),f=Tc(Pc,u);Q.useEffect(()=>{f&&console.warn(f)},[f]);let p=yc(l(`filterMode`),Pc),m=l(`types`),h=l(`showCompleted`),g=l(`unifiedTimeline`),_={types:m,filterMode:p,showFilterToggle:l(`showFilterToggle`),limit:d,showCompleted:h,unifiedTimeline:g,showCommentInput:l(`showCommentInput`),enableMentions:l(`enableMentions`),enableReactions:l(`enableReactions`),enableThreading:l(`enableThreading`),showSubscriptionToggle:l(`showSubscriptionToggle`)},v=Array.isArray(e.items)?e.items:Array.isArray(c.items)?c.items:void 0,y=e.loading??c.loading,b=a?.objectName,x=a?.data?.id??a?.data?._id??a?.recordId,S=a?.dataSource,C=v===void 0&&!o&&typeof S?.find==`function`&&!!b&&x!=null,[w,T]=Q.useState(0),E=d*(w+1),[D,O]=Q.useState(null),[k,A]=Q.useState(!1),[j,M]=Q.useState(!1),[N,ee]=Q.useState(!1),P=s(`detail.systemActor`,`System`);Q.useEffect(()=>{if(!C)return;let e=!1;return M(!0),Promise.resolve(S.find(`sys_activity`,{$filter:{object_name:b,record_id:x},$orderby:{timestamp:`desc`},$top:Math.max(1,E)+1})).then(t=>{if(e)return;let n=t?.data??[],r=Array.isArray(n)?n:[],i=[];for(let e of r){let t=kc(e,P);t&&i.push(t)}A(r.length>Math.max(1,E)),O(jc(i)),ee(!1)}).catch(t=>{e||(O([]),A(!1),ee(Mc(t)))}).finally(()=>{e||M(!1)}),()=>{e=!0}},[C,S,b,x,E,P]);let te=o?.items,ne=Q.useMemo(()=>Ac(v??te??D??[],{types:m,showCompleted:h,unifiedTimeline:g},E,Pc),[v,te,D,m,h,g,E]),re=ne.items,F=ne.hasMore||C&&k,I=y??o?.loading??(C&&D===null?!0:j),L=v===void 0?o?!!o.activityDenied:C&&N:!1,ie=v===void 0&&!!o?.commentsDenied,[R,z]=Q.useState(p);Q.useEffect(()=>{z(p)},[p]);let ae=Q.useCallback(()=>{T(e=>e+1)},[]),oe=_.enableMentions!==!1;return(0,$.jsx)(`div`,{className:t,...r,...i,children:(0,$.jsx)(oc,{items:re,config:_,loading:I,filterMode:R,onFilterChange:z,hasMore:F,onLoadMore:ae,onAddComment:o?.onAddComment,onAddReply:o?.onAddReply,onToggleReaction:o?.onToggleReaction,mentionSuggestions:oe?o?.mentionSuggestions:void 0,onUploadAttachments:o?.onUploadAttachments,activityDenied:L,commentsDenied:ie})})},Ic=({config:e,items:t,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f=!1,mentionSuggestions:p,onUploadAttachments:m,activityDenied:h,commentsDenied:g,className:_})=>{let v=e?.position??`right`,y=e?.width??`360px`,b=e?.collapsible??!0,x=f&&t.length===0||(e?.defaultCollapsed??!1),{t:S}=ka(),[C,w]=Q.useState(x),T=bs(e?.feed?.aria);return v===`right`||v===`left`?C&&b?(0,$.jsx)(`div`,{className:U(`flex items-start pt-4`,v===`right`?`border-l`:`border-r`,_),children:(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>w(!1),"aria-label":S(`detail.openDiscussion`),children:(0,$.jsx)(Ai,{className:`h-4 w-4`})})}):(0,$.jsxs)(`div`,{className:U(`flex flex-col overflow-hidden`,v===`right`?`border-l`:`border-r`,_),style:{width:y,minWidth:y},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Oi,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:S(`detail.discussion`)})]}),b&&(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>w(!0),"aria-label":S(`detail.closeDiscussion`),children:(0,$.jsx)(ta,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,$.jsx)(`div`,{...T,children:(0,$.jsx)(oc,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,mentionSuggestions:p,onUploadAttachments:m,titleLabel:S(`detail.discussion`),emptyLabel:S(`detail.noCommentsYet`),activityDenied:h,commentsDenied:g,className:`border-0 shadow-none`})})})]}):(0,$.jsx)(`div`,{className:U(``,_),children:b&&C?(0,$.jsxs)(G,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>w(!1),"aria-label":S(`detail.showDiscussion`,{count:t.length}),children:[(0,$.jsx)(Oi,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:S(`detail.showDiscussion`,{count:t.length})})]}):(0,$.jsxs)(`div`,{children:[b&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(Oi,{className:`h-4 w-4`}),S(`detail.discussion`)]}),(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>w(!0),"aria-label":S(`detail.hideDiscussion`),children:(0,$.jsx)(ki,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{...T,children:(0,$.jsx)(oc,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,mentionSuggestions:p,onUploadAttachments:m,titleLabel:S(`detail.discussion`),emptyLabel:S(`detail.noCommentsYet`),activityDenied:h,commentsDenied:g})})]})})},Lc=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Rc=({schema:e={},className:t,...n})=>{Jt();let r=Or(),{designer:i}=Lc(n),a=bs(e.aria),o={position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0},...e},s=o.feed,[c,l]=Q.useState(0),u=Cc(s?.limit),d=typeof e.type==`string`&&e.type?e.type:`record:chatter`,f=Tc(`${d} feed`,s?.limit);Q.useEffect(()=>{f&&console.warn(f)},[f]);let p=u*(c+1),m=yc(s?.filterMode,d),[h,g]=Q.useState(m);Q.useEffect(()=>{g(m)},[m]);let _=r?.items,v=Q.useMemo(()=>Ac(_??[],{types:s?.types,showCompleted:s?.showCompleted,unifiedTimeline:s?.unifiedTimeline},p,d),[_,s?.types,s?.showCompleted,s?.unifiedTimeline,p,d]),y=Q.useCallback(()=>{l(e=>e+1)},[l]),b=s?.enableMentions!==!1;return(0,$.jsx)(`div`,{className:t,...i,...a,children:(0,$.jsx)(Ic,{items:v.items,config:o,hasMore:v.hasMore,onLoadMore:y,loading:r?.loading,filterMode:h,onFilterChange:g,onAddComment:r?.onAddComment,onAddReply:r?.onAddReply,onToggleReaction:r?.onToggleReaction,mentionSuggestions:b?r?.mentionSuggestions:void 0,onUploadAttachments:r?.onUploadAttachments,activityDenied:r?.activityDenied,commentsDenied:r?.commentsDenied})})},zc=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}};function Bc(e,t){if(!Array.isArray(e))return[];let n=null;for(let r=0;r<e.length;r++){let i=e[r],a=i?.label;typeof a==`object`&&a&&(n??=[...e],n[r]={...i,label:Pr(a,t)})}return n??e}var Vc=({schema:e={},className:t,...n})=>{let r=Jt(),{translateOptions:i}=Fr(),{t:a}=ka(),{designer:o}=zc(n),s=bs(e.aria,{defaultRole:`list`,defaultLabel:a(`detail.pathLabel`),block:`record:path`}),{language:c}=Lr(),l=e.statusField,u=e.stages,d=u===void 0,f=r?.objectSchema,p=Q.useMemo(()=>Bc(d?os(f,l??null):u,c),[d,u,f,l,c]),m=Q.useMemo(()=>{if(p.length===0||!l||!r?.objectName)return p;let e=i(r.objectName,l,p);return Array.isArray(e)&&e.length===p.length?p.map((t,n)=>({...t,label:e[n]?.label??t.label})):p},[p,l,r?.objectName,i]),h=l&&r?.data?r.data[l]:void 0,g=/(^|[_-\s])(closed_)?(lost|failed?|cancell?ed|失败|流失|丢单|败)([_-\s]|$)/i,_=/(^|[_-\s])(closed_)?(won|success|成交|赢|完成)([_-\s]|$)/i,v=m.map(e=>{if(e.terminal)return e.terminal;let t=`${String(e.value??``)} ${String(e.label??``)}`;if(g.test(t))return`lost`;if(_.test(t))return`won`}),y=v.findIndex(e=>e===`lost`),b=y===-1?m:m.slice(0,y),x=y===-1?[]:m.slice(y),S=b.length-1,C=v.map((e,t)=>e===`won`?t===S?`won`:void 0:e),w=m.findIndex(e=>e.value===h);w<0&&(w=-1);let T=y!==-1&&w>=y;if(m.length===0){let e=d&&!!l&&f!=null;return(0,$.jsx)(`div`,{className:t,...o,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:e?`record:path — no stages configured, and field "${l}" has no picklist options to derive them from`:`record:path — no stages configured`})})}let E=(e,t)=>U(`h-1.5 w-full rounded-full`,t===`lost`&&(e===`current`?`bg-destructive`:`bg-destructive/25`),t!==`lost`&&e===`current`&&`bg-primary`,t!==`lost`&&e===`completed`&&`bg-emerald-500`,t!==`lost`&&e===`upcoming`&&(t===`won`?`bg-emerald-500/30`:`bg-muted`)),D=(e,t)=>U(`block min-w-0 text-xs`,e===`current`&&(t===`lost`?`font-semibold text-destructive`:`font-semibold text-foreground`),e===`completed`&&`font-normal text-muted-foreground`,e===`upcoming`&&`font-normal text-muted-foreground`),O=(e,t,n)=>a(n===`lost`?t===`current`?`detail.pathStageLostCurrent`:`detail.pathStageLostUpcoming`:n===`won`&&t===`upcoming`?`detail.pathStageWonUpcoming`:t===`current`?`detail.pathStageCurrent`:t===`completed`?`detail.pathStageCompleted`:`detail.pathStageUpcoming`,{stage:e}),k=e=>(0,$.jsxs)(`div`,{role:`listitem`,"data-stage-state":e.state,"data-stage-terminal":e.terminal,"aria-current":e.state===`current`?`step`:void 0,"aria-label":O(e.stage.label,e.state,e.terminal),className:U(`flex flex-col gap-1.5`,e.className),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-stage-rail":``,className:E(e.state,e.terminal)}),(0,$.jsxs)(`span`,{className:U(D(e.state,e.terminal),e.labelClassName),children:[e.terminal===`lost`&&(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1 opacity-70`,children:`✗`}),e.terminal!==`lost`&&e.state===`completed`&&(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1 text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),e.stage.label]})]},e.key);return(0,$.jsxs)(`div`,{className:U(`w-full`,t),...o,children:[(0,$.jsxs)(`div`,{className:`hidden sm:flex w-full items-start gap-2`,...s,children:[(0,$.jsx)(`div`,{className:`flex flex-1 items-start gap-1.5`,children:b.map((e,t)=>{let n=!T&&w>=0&&t<w,r=!T&&t===w;return k({key:`${e.value}-${t}`,stage:e,state:r?`current`:n?`completed`:`upcoming`,terminal:C[t],className:`flex-1 min-w-0`,labelClassName:`text-center truncate`})})}),x.length>0&&(0,$.jsx)(`div`,{className:`flex items-start gap-1.5 pl-2 border-l border-border/40`,children:x.map((e,t)=>{let n=y+t;return k({key:`${e.value}-lost-${t}`,stage:e,state:n===w?`current`:`upcoming`,terminal:C[n],className:`shrink-0`,labelClassName:`text-center whitespace-nowrap`})})})]}),(0,$.jsx)(`div`,{className:`flex sm:hidden w-full items-start gap-2 overflow-x-auto pb-1 -mx-1 px-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,...s,children:m.map((e,t)=>{let n=C[t],r=n!==`lost`&&!T&&w>=0&&t<w,i=t===w;return k({key:`${e.value}-${t}-m`,stage:e,state:i?`current`:r?`completed`:`upcoming`,terminal:n,className:`shrink-0`,labelClassName:`whitespace-nowrap`})})})]})},Hc=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Uc=Object.freeze([]),Wc=new Set;function Gc(e,t,n){let r=`${e}::${t}::${n.index}::${n.message}`;Wc.has(r)||(Wc.add(r),console.error(`[record:quick_actions] ${t} refused at index ${n.index} — ${n.message}. None of the authored actions is rendered. \`actionNames\` is a list of ACTION IDS resolved from the object's own \`actions\`; an inline action object is the host's runtime channel and must not share an array with ids.`))}var Kc=({schema:e={},className:t,...n})=>{let r=Jt(),{designer:i}=Hc(n),a=bs(e.aria,{defaultRole:`toolbar`,defaultLabel:`Quick actions`,block:`record:quick_actions`}),o=He(),s=Kt(),c=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:Uc,l=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:Uc,u=r?.objectName||``,d=l.length>0?`actionNames`:`actions`,f=l.length>0?l:c,p=qt(f,void 0),m=p.kind===`ids`&&p.ids.length>0&&!!u,{item:h}=sn(`object`,m?u:null),g=qt(f,Array.isArray(h?.actions)?h.actions:[]);g.kind===`refused`&&Gc(u,d,g);let _=(g.kind===`refused`?[]:g.actions).map((e,t)=>s(u||void 0,e,{fallbackLabel:`Action ${t+1}`})),v=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[],y=e.location||`record_header`,{getActionsForLocation:b,executeAction:x}=Wt({actions:_,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}});if(v.length>0&&!o.hasCapabilities(v))return(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view quick actions.`})});let S=_.length>0?b(y):[];if(S.length===0)return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:g.kind===`refused`?`record:quick_actions — ${d} refused at index ${g.index} (see console)`:`record:quick_actions — no actions configured`})});let C=e.align||`end`,w=C===`start`?`justify-start`:C===`center`?`justify-center`:`justify-end`,T=y===`record_header`&&!e.inline;return(0,$.jsx)(`div`,{className:U(`flex flex-wrap items-center gap-2`,T&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,w,t),...a,...i,children:S.map((t,n)=>(0,$.jsx)(qc,{action:t,record:r?.data,variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,label:t.label||`Action ${n+1}`,onRun:async()=>{typeof t.onClick==`function`?await t.onClick():t.name&&await x(t.name)}},t.name||`qa-${n}`))})};function qc({action:e,record:t,variant:n,size:r,label:i,onRun:a}){let[o,s]=Q.useState(!1),c=Q.useMemo(()=>({record:t||{}}),[t]),l=mn(cr(e.disabled),c),u=(ir(e.disabled)?l:!1)||o;return(0,$.jsxs)(G,{variant:n,size:r,disabled:u,onClick:async()=>{s(!0);try{await a()}finally{s(!1)}},children:[o&&(0,$.jsx)(Ti,{className:`mr-2 h-4 w-4 animate-spin`}),i]})}var Jc=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Yc=new Set([`created`,`updated`,`assigned`,`shared`,`deleted`]),Xc=50;function Zc(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function Qc(e){return Zc(e)?e:Xc}function $c(e){if(typeof e==`number`)return String(e);if(typeof e==`string`)return JSON.stringify(e);try{let t=JSON.stringify(e);if(t!==void 0)return t}catch{}return String(e)}function el(e){return e==null||Zc(e)?null:`[ObjectUI] record:history row cap: declared limit: ${$c(e)} (${Array.isArray(e)?`array`:typeof e}), which is not a positive integer number. The spec declares \`limit\` as z.number().int().positive() and refuses strings, booleans, fractions, zero and negatives, so it was ignored and this block fell back to its default row cap (${Xc}).`}var tl=({schema:e={},className:t,...n})=>{let{designer:r}=Jc(n),i=Jt(),a=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:void 0,o=e.loading??e.properties?.loading,s=e.emptyText??e.properties?.emptyText,c=e.unknownUserText??e.properties?.unknownUserText,l=e.limit??e.properties?.limit,u=Qc(l),d=el(l);Q.useEffect(()=>{d&&console.warn(d)},[d]);let f=i?.objectName,p=i?.data?.id??i?.data?._id??i?.recordId,m=i?.dataSource,h=a===void 0&&!!m?.find&&!!f&&p!=null,[g,_]=Q.useState(null),[v,y]=Q.useState(!1);Q.useEffect(()=>{if(!h)return;let e=!1;return y(!0),Promise.resolve(m.find(`sys_activity`,{$filter:{object_name:f,record_id:p},$orderby:{timestamp:`desc`},$top:u})).then(t=>{if(e)return;let n=(t?.data??[]).filter(e=>Yc.has(e?.type)).map(e=>{let t=e.timestamp;return(!t||t===`NOW()`||Number.isNaN(Date.parse(t)))&&(t=e.created_at),{id:e.id,created_at:t,action:e.type,user_name:e.actor_name??null,user_avatar:e.actor_avatar_url??null,summary:e.summary??null}});_(n)}).catch(()=>{e||_([])}).finally(()=>{e||y(!1)}),()=>{e=!0}},[h,m,f,p,u]);let b=a??g??[],x=o??(h&&g===null?v||!0:!1);return(0,$.jsx)(`div`,{className:t,...r,children:(0,$.jsx)(xo,{entries:b,loading:x,emptyText:s,unknownUserText:c})})},nl=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}};function rl(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function il(e,t){return rl(e)?e:t}function al(e,t){return e==null||rl(e)?null:`[ObjectUI] RecordReferenceRail row cap: ${typeof t==`string`&&t?`record:reference_rail entry for ${t}`:`record:reference_rail entry`} declared limit: ${String(e)}, which is not a positive integer. A row cap must be a positive integer (the spec refuses zero and negative values), so it was ignored and this entry fell back to its default preview-row cap (3).`}var ol=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),sl=(e,t)=>t&&e?.[t]!=null&&e[t]!==``?String(e[t]):e?.name||e?.title||e?.subject||e?.label||e?.email||e?.username||e?.code||e?.slug||e?.provider_id||e?.user_agent||e?.ip_address||e?.id||`—`,cl=({schema:e={},className:t,...n})=>{let a=Jt(),o=Fr(),{t:s}=ka(),{designer:c}=nl(n),l=r().appName,u=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],d=a?.recordId,f=a?.dataSource,[p,m]=Q.useState({}),h=Q.useRef(null),[g,_]=Q.useState(!1),v=Q.useRef(!0);Q.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);let y=Q.useRef(``);Q.useEffect(()=>{if(g)return;let e=h.current;if(!e||typeof IntersectionObserver>`u`){_(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&_(!0)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[g]);let[b,x]=Q.useState({}),S=Q.useRef(new Set),C=Q.useRef(new Set),w=JSON.stringify(u.map(e=>`${e.objectName}:${e.relationshipField}:${il(e.limit,3)}`)),T=JSON.stringify(u.map(e=>[e.objectName,e.limit??null]));Q.useEffect(()=>{for(let e of u){let t=al(e.limit,e.objectName);if(!t)continue;let n=`${e.objectName}:${String(e.limit)}`;C.current.has(n)||(C.current.add(n),console.warn(t))}},[T]),Q.useEffect(()=>{if(!g||!f?.find||!d||u.length===0)return;let e=`${d}::${w}`;if(y.current===e)return;y.current=e;let t=()=>v.current&&y.current===e;m(e=>{let t={...e};for(let n of u)t[n.objectName]={loading:!0,total:0,items:e[n.objectName]?.items||[]};return t});let n=async(e,n)=>{let r=e.objectName;try{let i=await f.find(e.objectName,{$filter:Ln(e.relationshipField,d,n),$top:il(e.limit,3),$count:!0});if(!t())return;let a=Array.isArray(i)?i:i?.data||[],o=typeof i?.total==`number`?i.total:a.length;m(e=>({...e,[r]:{loading:!1,total:o,items:a}}))}catch(e){if(!t())return;m(t=>({...t,[r]:{loading:!1,total:0,items:[],error:String(e?.message||e)}}))}};(async()=>{let e=new Map;if(typeof f.getObjectSchema==`function`&&await Promise.all(Array.from(new Set(u.map(e=>e.objectName))).map(async t=>{try{e.set(t,(await f.getObjectSchema(t))?.fields)}catch{}})),!t())return;x(Object.fromEntries(e));for(let t of u){if(!xn(e.get(t.objectName),t.relationshipField))continue;let n=`${t.objectName}.${t.relationshipField}`;S.current.has(n)||(S.current.add(n),console.warn(`[RecordReferenceRail] "${t.objectName}" relates through the multi-value field "${t.relationshipField}", so the "View All" link is suppressed for it. The console list URL's \`filter[<field>]=<value>\` grammar has no membership operator and no unrecognised suffix narrows it, so the link would open the entire child table dressed as this parent's related records. The rail's own rows are still scoped correctly.`))}let r=[...u],i=async()=>{for(;v.current;){let t=r.shift();if(!t)return;await n(t,e.get(t.objectName))}};await Promise.all(Array.from({length:Math.min(3,r.length)},()=>i()))})()},[g,f,d,w]);let[E,D]=Q.useState(!1);if(u.length===0)return null;let O=e.hideEmpty!==!1,k=new Set(u.filter(e=>{let t=p[e.objectName];return O&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),A=u.filter(e=>E||!k.has(e.objectName)),j=u.filter(e=>k.has(e.objectName)).map(e=>e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:ol(e.objectName)}):ol(e.objectName)));return(0,$.jsxs)(`div`,{ref:h,className:U(`flex flex-col gap-3`,e.className,t),...c,children:[A.map(e=>{let t=e.objectName,n=p[t]||{loading:!0,total:0,items:[]},r=xn(b[t],e.relationshipField),a=e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:ol(e.objectName)}):ol(e.objectName));return(0,$.jsxs)(Ee,{className:`overflow-hidden`,children:[(0,$.jsxs)(Oe,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,$.jsx)(re,{className:`text-sm font-semibold tracking-tight truncate`,children:a}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!n.loading&&(0,$.jsx)(Qe,{variant:`secondary`,className:`tabular-nums`,children:n.total}),l&&d&&!r&&(0,$.jsx)(i,{to:`/apps/${l}/${e.objectName}?filter%5B${e.relationshipField}%5D=${encodeURIComponent(String(d))}`,className:`text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors`,title:s(`detail.viewAll`,{defaultValue:`View All`}),children:s(`detail.viewAll`,{defaultValue:`View All`})})]})]}),(0,$.jsx)(L,{className:`p-0`,children:n.loading?(0,$.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,$.jsx)(J,{className:`h-3.5 w-4/5`}),(0,$.jsx)(J,{className:`h-3.5 w-3/5`}),(0,$.jsx)(J,{className:`h-3.5 w-2/3`})]}):n.items.length===0?(0,$.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:s(`detail.noRecords`)}):(0,$.jsx)(`ul`,{className:`divide-y`,children:n.items.map(t=>{let n=t.id||t._id,r=sl(t,e.displayField),a=n?`../${e.objectName}/record/${encodeURIComponent(String(n))}`:void 0;return(0,$.jsx)(`li`,{className:`px-4 py-2`,children:a?(0,$.jsxs)(i,{to:a,className:`group flex items-center justify-between gap-2 text-xs hover:text-foreground text-muted-foreground transition-colors`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r}),(0,$.jsx)(Qr,{className:`h-3 w-3 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`})]}):(0,$.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:r})},String(n||r))})})})]},t)}),!E&&j.length>0&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>D(!0),className:`self-start inline-flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2.5 py-1 rounded-md border border-dashed border-border/60 hover:border-border bg-background`,title:j.join(` · `),children:[(0,$.jsx)(`span`,{children:s(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:j.length})}),(0,$.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,j.join(` · `),`)`]})]})]})};function ll(e){let t=Er(e?.properties)?e.properties:{};return{...e,...t}}var ul={info:{wrap:`border-blue-300/60 bg-blue-50 text-blue-900 dark:border-blue-700/40 dark:bg-blue-950/30 dark:text-blue-100 [&>svg]:text-blue-600 dark:[&>svg]:text-blue-300`,icon:`Info`},warning:{wrap:`border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-700/40 dark:bg-amber-950/30 dark:text-amber-100 [&>svg]:text-amber-600 dark:[&>svg]:text-amber-300`,icon:`AlertTriangle`},error:{wrap:`border-destructive/60 bg-destructive/10 text-destructive dark:bg-destructive/20 [&>svg]:text-destructive`,icon:`AlertCircle`},success:{wrap:`border-emerald-300/60 bg-emerald-50 text-emerald-900 dark:border-emerald-700/40 dark:bg-emerald-950/30 dark:text-emerald-100 [&>svg]:text-emerald-600 dark:[&>svg]:text-emerald-300`,icon:`circle-check`}},dl=({schema:e={},className:t})=>{let n=ll(e),r=Jt(),i=r?.data,a=r?.objectName||``,o=r?.recordId??i?.id,{language:s}=Lr(),c=Pr(n.title,s),l=Pr(n.body,s),u=Pr(n.action?.label,s),d=[`info`,`warning`,`error`,`success`].includes(n.severity)?n.severity:`info`,f=ul[d],p=n.icon||f.icon,m=yn(i),h=cr(n.visible),g=!!i&&Object.keys(i).length>0,_=mn(g?h:void 0,m),v=Q.useMemo(()=>{if(!n.dismissible)return null;let e=n.dismissKey||Pr(n.title,`en`)||d;return`os.record-alert:${a}:${o??`_`}:${e}`},[n.dismissible,n.dismissKey,n.title,d,a,o]),[y,b]=Q.useState(()=>{if(!v||typeof window>`u`)return!1;try{return window.localStorage.getItem(v)===`1`}catch{return!1}}),x=n.action?.actionName,{item:S}=sn(`object`,x&&a?a:null),C=Q.useMemo(()=>{let e=qt(x?[x]:[],Array.isArray(S?.actions)?S.actions:void 0);return e.kind===`ids`?e.actions[0]:void 0},[x,S]),w=Q.useMemo(()=>C?[C]:[],[C]),{executeAction:T}=Wt({actions:w,context:{record:i,recordId:o,objectName:a}});return y||!g||h!==void 0&&!_?null:(0,$.jsxs)(Le,{className:U(`relative pr-12`,f.wrap,t),role:d===`error`?`alert`:`status`,"aria-live":d===`error`?`assertive`:`polite`,children:[(0,$.jsx)(ke,{name:p,className:`h-4 w-4`,"aria-hidden":`true`}),c?(0,$.jsx)(wt,{children:c}):null,l||C?(0,$.jsxs)(Y,{children:[l?(0,$.jsx)(`p`,{className:`mb-2 last:mb-0`,children:l}):null,C?(0,$.jsx)(G,{size:`sm`,variant:n.action?.variant||(d===`error`?`destructive`:`default`),onClick:()=>{C?.name&&T(C.name)},children:u||C.label||C.name}):null]}):null,n.dismissible?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(b(!0),v)try{window.localStorage.setItem(v,`1`)}catch{}},"aria-label":`Dismiss`,className:`absolute right-3 top-3 inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/80 hover:bg-foreground/5 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,children:(0,$.jsx)(ke,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},fl=e=>{if(e==null)return`—`;if(typeof e==`string`)return e.length>0?e:`""`;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}},pl=(e,t)=>{if(typeof e!=`string`||e.length===0)return null;let n=/\d{4}-\d{2}-\d{2}[ T]/.test(e)?e.replace(` `,`T`):e,r=new Date(n);if(Number.isNaN(r.getTime()))return null;try{return r.toLocaleString(t)}catch{return r.toISOString()}},ml=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:a=!1})=>{let{t:o}=ka(),s=Ir(),c=t?.label||t?.field||``,l=t?fl(t.pendingValue):``,u=t?fl(t.currentValue):``,d=t?.currentRecord??{},f=(()=>{let e=[d.updated_by_name,d.updated_by_label];for(let t of e)if(typeof t==`string`&&t.length>0)return t;let t=d.updated_by;return typeof t!=`string`||t.length===0||t.length>=16&&!/\s/.test(t)&&/^[A-Za-z0-9_-]+$/.test(t)?null:t})(),p=pl(d.updated_at??t?.currentVersion,s),[m,h]=o(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,$.jsx)(ze,{open:e,onOpenChange:e=>{!e&&!a&&i()},children:(0,$.jsxs)(at,{className:`max-w-lg`,children:[(0,$.jsx)(Pe,{children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`inline-flex h-9 w-9 flex-none items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`,"aria-hidden":`true`,children:(0,$.jsx)(Xi,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Et,{children:o(`detail.concurrentUpdateTitle`)}),(0,$.jsxs)(Ye,{className:`mt-1`,children:[m,(0,$.jsx)(`strong`,{className:`font-semibold`,children:c}),h]})]})]})}),(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,$.jsxs)(`div`,{className:`rounded-md border border-amber-200/70 bg-amber-50/60 p-3 dark:border-amber-500/30 dark:bg-amber-500/10`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-amber-800 dark:text-amber-300`,children:o(`detail.concurrentUpdateYourEdit`)}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:l})]}),(0,$.jsxs)(`div`,{className:`rounded-md border border-sky-200/70 bg-sky-50/60 p-3 dark:border-sky-500/30 dark:bg-sky-500/10`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-sky-800 dark:text-sky-300`,children:o(`detail.concurrentUpdateCurrentValue`)}),(f||p)&&(0,$.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[f&&(0,$.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedBy`,{name:f})}),f&&p&&(0,$.jsx)(`span`,{children:` · `}),p&&(0,$.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedAt`,{when:p})})]})]}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:u})]})]}),(0,$.jsxs)(qe,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:U(kt({variant:`ghost`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateCancel`)}),(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:r,className:U(kt({variant:`outline`}),`mt-2 sm:mt-0 text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),children:o(`detail.concurrentUpdateOverwrite`)}),(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:n,autoFocus:!0,className:U(kt({variant:`default`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateReload`)})]})]})})};function hl(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}function gl(e){let t=e?.message||e?.error||String(e??`Save failed`);return String(t).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``)}function _l(e,t){return Bn(e)||(t?[{field:t,message:fr(e)||gl(e)}]:null)}async function vl(e,t,n,r,i){if(typeof e?.update==`function`)await e.update(t,n,r,i);else if(typeof e?.updateOne==`function`)await e.updateOne(t,n,r,i);else if(typeof e?.patch==`function`)await e.patch(t,n,r,i);else throw Error(`[InlineEditSaveBar] DataSource exposes no update/updateOne/patch method; cannot persist inline edit`)}var yl=({dataSource:e,objectName:t,recordId:n,data:r,refresh:i,fieldLabelFor:a,onFieldSave:o,locked:s=!1,lockedHint:c,className:l})=>{let{t:u}=ka(),d=kn(),[f,p]=Q.useState(null),[m,h]=Q.useState(!1),g=Q.useCallback(e=>a?.(e)||e,[a]),_=!!e&&!!t&&n!=null,v=Q.useCallback((e,t)=>{if(!d)return;let n=_l(e,t);if(!n){d.setFieldErrors(null),d.setError(gl(e));return}let r=e=>a?.(e)||e;d.setFieldErrors(Object.fromEntries(n.map(e=>[e.field,e.message]))),d.setError(n.map(e=>`${r(e.field)}: ${e.message}`).join(`; `))},[d,a]),y=Q.useCallback((e,t)=>{let n=Object.keys(e),r=t?.currentRecord??null;if(n.length===1){let i=n[0];return{field:i,label:a?.(i),pendingValue:e[i],currentValue:r?r[i]:void 0,currentVersion:t?.currentVersion,currentRecord:r}}let i=r?Object.fromEntries(n.map(e=>[e,r[e]])):void 0;return{field:n.join(`, `),label:u(`detail.concurrentUpdateRecordLabel`,{defaultValue:`this record`}),pendingValue:e,currentValue:i,currentVersion:t?.currentVersion,currentRecord:r}},[a,u]),b=Q.useCallback(async()=>{if(!d)return;let a=d.draft,s=Object.entries(a);if(s.length===0){d.reset();return}d.setSaving(!0),d.setError(null),d.setFieldErrors(null);let c;try{if(o){for(let[e,t]of s)c=e,await o(e,t);c=void 0}else if(_){let o=typeof r?.updated_at==`string`?r.updated_at:void 0;await vl(e,t,n,a,o?{ifMatch:o}:void 0),await i?.()}d.reset()}catch(e){hl(e)&&_?p(y(a,e)):v(e,c)}finally{d.setSaving(!1)}},[d,o,_,r,e,t,n,i,y,v]),x=Q.useCallback(()=>{p(null),h(!1)},[]),S=Q.useCallback(async()=>{h(!0);try{await i?.()}finally{d?.reset(),x()}},[i,d,x]),C=Q.useCallback(async()=>{if(!f||!_){x();return}h(!0);try{await vl(e,t,n,d?.draft??{},f.currentVersion?{ifMatch:f.currentVersion}:void 0),await i?.(),d?.reset()}catch(e){v(e)}finally{x()}},[f,_,d,e,t,n,i,x,v]),w=!!d?.editing,T=!!d?.saving,E=d?.cancel,D=!!f;return Q.useEffect(()=>{if(!w)return;let e=e=>{if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){if(T||s||D)return;e.preventDefault(),b();return}if(e.key===`Escape`){if(e.defaultPrevented||T||D||document.querySelector(`[data-radix-popper-content-wrapper], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`))return;e.preventDefault(),E?.()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w,T,s,D,b,E]),!d||!d.editing?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:U(`sticky bottom-0 z-30 mt-4 flex flex-wrap items-center justify-end gap-2 rounded-md border bg-background/95 px-3 py-2 shadow-sm backdrop-blur supports-[backdrop-filter]:bg-background/80`,l),role:`region`,"aria-label":u(`detail.editFieldsInline`),children:[d.error&&(0,$.jsx)(`div`,{role:`alert`,className:`mr-auto max-w-md rounded-md border border-destructive/20 bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:d.fieldErrors?(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:Object.entries(d.fieldErrors).map(([e,t])=>(0,$.jsxs)(`li`,{"data-inline-field-error":e,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:g(e)}),`: `,t]},e))}):d.error}),(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,onClick:d.cancel,disabled:d.saving,className:`gap-2`,children:[(0,$.jsx)(ta,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:u(`detail.cancel`)})]}),(0,$.jsxs)(G,{variant:`default`,size:`sm`,onClick:b,disabled:d.saving||s,className:`gap-2`,title:s?c:void 0,children:[d.saving?(0,$.jsx)(Ti,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(Yr,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:d.saving?u(`detail.saving`):u(`detail.save`)})]})]}),(0,$.jsx)(ml,{open:!!f,conflict:f,busy:m,onCancel:x,onReload:S,onOverwrite:C})]})},bl=new Set(_n);function xl(e,t,n){let r=t?.fields??{};return(Object.keys(r).length?Object.keys(r):Object.keys(e)).filter(e=>!n.has(e)&&!e.startsWith(`__`)).filter(t=>t in e).filter(e=>!r[e]?.hidden).map(e=>{let t=r[e]||{},n=Mn(t);return{name:e,label:t.label,type:t.type,readonly:!!t.readonly||n,options:t.options,currency:t.currency,precision:t.precision,scale:t.scale,useGrouping:t.useGrouping,format:t.format,reference:t.reference,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}})}var Sl=`min(960px, 60vw)`;function Cl({record:e,objectName:t,recordId:n,dataSource:r,objectSchema:i,columns:a=2,systemFields:o=bl,onFieldSave:s,onDelete:c,onClose:l,fullPageHref:u}){let{t:d}=ka(),f=xl(e,i,o);return(0,$.jsxs)(Bt,{canEdit:!!s,children:[(0,$.jsx)(Uo,{dataSource:r,inlineEdit:!!s,schema:{type:`detail-view`,objectName:t,resourceId:String(n),data:e,showDelete:!!c,columns:a,fields:f,actions:u?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:d(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(u,`_blank`,`noopener`)}]}]:void 0},onDelete:c?async()=>{try{await c(),l?.()}catch(e){console.error(`[RecordDetailPanel] delete failed:`,e)}}:void 0}),(0,$.jsx)(yl,{onFieldSave:s?async(e,t)=>{try{await s(e,t)}catch(e){throw console.error(`[RecordDetailPanel] inline field save failed:`,e),e}}:void 0})]})}function wl(e,t){if(typeof window>`u`)return null;let n=window.location.pathname,r=`/${e}`,i=n.indexOf(r);return`${i>=0?n.slice(0,i):n.replace(/\/$/,``)}/${e}/record/${encodeURIComponent(String(t))}`}function Tl(e,t){if(!e||!t.length)return[];let n=[...t].sort((e,t)=>t.label.length-e.label.length),r=e,i=new Set;for(let e of n){if(!e.label)continue;let t=e.label.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}(?![\\p{L}\\p{N}_])`,`gu`);n.test(r)&&(i.add(e.id),r=r.replace(n,e=>` `.repeat(e.length)))}return[...i]}var El=t({DetailView:()=>Uo,DetailViewRenderer:()=>Dl,RECORD_OVERLAY_DEFAULT_WIDTH:()=>Sl,RecordActivityRenderer:()=>Fc,RecordAlertRenderer:()=>dl,RecordChatterRenderer:()=>Rc,RecordDetailsRenderer:()=>Es,RecordHighlightsRenderer:()=>Vs,RecordHistoryRenderer:()=>tl,RecordPathRenderer:()=>Vc,RecordQuickActionsRenderer:()=>Kc,RecordReferenceRailRenderer:()=>cl,RecordRelatedListRenderer:()=>zs,UNMAPPED_ACTIVITY_FEED_TYPE:()=>uc,buildDefaultPageSchema:()=>_s}),Dl=Ft(({schema:e,dataSource:t,...n})=>{let r=hr(t);return(0,$.jsx)(Tr,{schema:e,dataSource:r,testId:`detail-view`,errorTitle:`This detail view’s data source could not be resolved`,requiresDataSource:e?.data==null&&e?.api==null&&typeof e?.objectName==`string`&&e.objectName.length>0,noDataSourceMessage:Jn(`detail-view`,e?.objectName),children:e=>(0,$.jsx)(Uo,{schema:e,dataSource:r,...n})})});Z.register(`detail-view`,Dl,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`},{name:`objectName`,type:`string`},{name:`resourceId`,type:`string`},{name:`api`,type:`string`},{name:`data`,type:`object`},{name:`layout`,type:`enum`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`},{name:`sections`,type:`array`},{name:`fields`,type:`array`},{name:`tabs`,type:`array`},{name:`actions`,type:`array`},{name:`showBack`,type:`boolean`},{name:`backUrl`,type:`string`},{name:`showEdit`,type:`boolean`},{name:`editUrl`,type:`string`},{name:`showDelete`,type:`boolean`},{name:`deleteConfirmation`,type:`string`},{name:`loading`,type:`boolean`},{name:`header`,type:`object`},{name:`footer`,type:`object`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[]}}),Z.register(`detail-section`,Go,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`},{name:`description`,type:`string`},{name:`icon`,type:`string`,description:"Section header icon, drawn before the title: a Lucide icon name such as `map-pin`."},{name:`fields`,type:`array`,required:!0},{name:`collapsible`,type:`boolean`},{name:`defaultCollapsed`,type:`boolean`},{name:`columns`,type:`number`},{name:`showBorder`,type:`boolean`},{name:`headerColor`,type:`enum`,enum:Object.keys(Ya),description:"Header tint, from the design system's closed palette: one of `muted`, `muted/50`, `accent`, `primary/10`, `secondary/10`, `destructive/10`. Any other value is refused — `@object-ui/types` parses this key as that same six-member enum (objectui#6594), matching @objectstack/spec's strict `record:details` section schema. Omit the key for no tint."},{name:`hideEmpty`,type:`boolean`,description:"When every field in the section is empty, `true` hides the whole section (no heading, no skeleton). Omitted or `false`, an all-empty section keeps its heading and label skeleton. Empty fields in a section that still has a filled one are not governed by this key."}]}),Z.register(`detail`,Uo,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`recordId`,type:`string`},{name:`fields`,type:`array`}]}),Z.register(`details`,Es,{namespace:`record`,skipFallback:!0,category:`record`,label:`Record Details`,icon:`FileText`,inputs:[{name:`columns`,type:`enum`,enum:[`1`,`2`,`3`,`4`],description:`Number of columns for field layout (1-4)`},{name:`sections`,type:`array`,of:`object`,description:"Field groups rendered as the detail body, in order. Every entry is an OBJECT — `{ name?, label?, columns?, fields }` — a bare section-id string is NOT accepted (the spec retired that spelling in objectstack#5611, and the renderer reads name/label/fields off each entry, so a string entry renders no fields at all). `fields` are the field names shown in this section, in order — required unless `group` supplies the members instead (the spec refuses a section carrying neither, and refuses one carrying both). `label` is the section heading; omit it for an untitled, borderless section. `name` is a stable snake_case identifier and the i18n anchor — the heading resolves through objects.<object>._sections.<name>.label, so a section without a name shows its authored label in every locale. `columns` (1-4) is THIS section's field-grid width; omit it and the renderer derives the width. Authoring `sections` at all makes it the only source of the detail body; omit it and the body falls back to the object's highlightFields. @objectstack/spec 17.3.0 declares eight more member keys on an entry, and this renderer honours all eight: `icon` (a Lucide name on the section header), `description` (sub-heading copy under the heading), `collapsible` and `defaultCollapsed` (a foldable section and its initial state), `showBorder` (force the Card wrapper on or off, overriding the heading-derived default) and `headerColor` (a header tint from the shared palette) through DetailSection, plus `group` — the ADR-0085 §5 REFERENCE form, the alternative to enumerating `fields`. `{ group: 'contact_info' }` inherits the object's `fieldGroups` entry with that key: its members (every visible field pointing at it, in declaration order) and its presentation (label, icon, description, collapse) all come from the group, so the section restates none of it and the spec refuses those keys beside `group`; `columns`, `showBorder` and `headerColor` stay yours because they are how THIS page lays the section out. A `group` naming no declared group renders nothing and is reported to the console (`@objectstack/lint` flags it as `page-section-group-unknown`). `hideEmpty` is the eighth, and it decides whether an ALL-empty section exists: it defaults to on, so a section whose fields are every one of them empty renders nothing at all — no heading, no skeleton — and `hideEmpty: false` is the spelling that keeps that heading and its label skeleton on a brand-new record. It decides ONLY the all-empty case; the empty rows of a section that still has a filled one belong to DetailSection's auto-hide heuristic plus the reader's show-empty toggle, which no authored value overrides in either polarity (objectui#7129 Q2-C), and inline-edit mode renders the section either way so its fields stay reachable. Restored under objectui#8603 (maintainer 2026-09-15) after objectui#7129 retired it on the premise, since falsified upstream, that the spec refused the key. None of the eight has a designer control yet; they are authorable in source mode only, tracked as a deferred feature."},{name:`fields`,type:`array`,of:`string`,description:`Explicit field list (overrides highlightFields)`},{name:`hideFields`,type:`array`,of:`string`,description:"Field names to omit from the body — applied to the top-level `fields` list AND to every section's `fields`. Bare field names only. Authors rarely need it: the synth pipeline fills it with the fields already shown in `record:highlights`, and hand-authored pages get the same dedup live from HighlightFieldsContext, so its purpose is suppressing a field you do not want repeated (the page H1 title field is dropped for you too). Hiding every field of a section leaves that section out entirely."},{name:`inlineEdit`,type:`boolean`,description:"Offer the per-field double-click / pencil inline-edit affordances in the detail body. On by default, and an OPT-OUT only: the value is combined with the object's own editability (system, engine-owned, append-only and better-auth objects are not user-editable unless they opened userActions.edit) and with the server's effective API operation set for the object, so `false` always wins while `true` cannot open editing the platform refuses. The edit session and the atomic Save bar are hosted by the page, so one draft spans the highlights strip and this body."},{name:`showHeader`,type:`boolean`,description:"Render the detail body's own title / follow-star / copy-id chip above the fields. Off by default because this block is normally composed under a `page:header` that already draws that chrome, and turning it on there shows the record title twice. Set it true only when this block is the whole page."},{name:`enforceFieldSecurity`,type:`boolean`,description:`Fold this block's field list through the caller's FIELD-read permissions before rendering, so a field the permission set denies leaves no empty row behind (renderer default: off). Presentation only: it re-applies the same field-read answer the server already enforced (ADR-0066 D3) and never widens access — with it off a denied field still arrives masked or stripped, and with it on the server still decides every value.`},{name:`redactFields`,type:`array`,of:`string`,description:"Field names this block never renders, whatever the permission answer (renderer default: render everything authored). Presentation only, evaluated in the browser after the record is fetched — the values are still in the page, so this is NOT a data-access control and NOT the object's `publicSharing.redactFields`, which removes them server-side. To keep a value from the caller, gate the field itself (`requiredPermissions` / `maskingRule`, ADR-0066 D3) or the permission set. Neighbours `hideFields`, which is the dedupe channel the renderer also writes to."},{name:`requiredPermissions`,type:`array`,of:`string`,description:"[ADR-0066] Capabilities the user must ALL hold — names that permission sets grant through `systemPermissions`, not object actions: `read` or `update` here is an ordinary capability name, not the object's read or edit permission. When the client has resolved the user's capabilities and any of these is missing, this block does not render its content; wherever it would otherwise render, an insufficient-permissions notice takes its place. Presentation only: it authorises nothing, and the data API still serves the same data to the same user. A client that cannot resolve the user's capabilities (no permission provider, or one that does not report `systemPermissions`) renders this block as if they were held — it fails open."}]}),Z.register(`related_list`,zs,{namespace:`record`,skipFallback:!0,category:`record`,label:`Related List`,icon:`List`,inputs:[{name:`objectName`,type:`string`,required:!0,description:`Related object name (e.g. "task")`},{name:`relationshipField`,type:`string`,required:!0,description:`Field on the related object pointing back to this record`},{name:`relationshipValueField`,type:`string`,description:'Which field OF THIS PARENT record `relationshipField` stores. Defaults to "id"; set it to the field a name-keyed junction points at (e.g. "name" when sys_user_position.position holds sys_position.name). The resolved value drives three things at once — the list filter, the Add-picker link value, and the pre-filled create form — so they cannot drift apart. While the parent record is still loading, a non-"id" field resolves to null and the list holds its fetch rather than querying on an empty value.'},{name:`columns`,type:`array`,of:`string`,description:"Fields to display in the related list. Optional: without it, a `dataSource` binding that names a view supplies that view's columns, and with neither the list derives its columns from the related object (its `highlightFields`, otherwise its listable fields). Authored columns win over both."},{name:`sort`,type:`array`},{name:`limit`,type:`number`,description:`Records to display initially`},{name:`filter`,type:`array`,of:`object`,description:"Additional filter criteria, as spec `ViewFilterRule` entries (`[{ field, operator, value }]`). AND-combined with the parent relationship condition, never a replacement for it: it can only narrow this record's children. Also the key a per-element `dataSource` binding's composed filter lands on."},{name:`title`,type:[`string`,`object`],description:'Heading of the list. Defaults to the related object\'s label (its translation when one is loaded, otherwise the humanized object name). Accepts either a plain string or an inline per-locale map (`{ en: "Open tasks", "zh-CN": "未完成任务" }`) — the `I18nLabel` union the contract admits on this key — and the list resolves the map against the active UI language, falling back through base language, a region-qualified sibling, `default`, then `en`, and finally to any remaining entry.'},{name:`showViewAll`,type:`boolean`},{name:`actions`,type:`array`,of:`string`,description:`Action IDs available for related records`},{name:`add`,type:`object`,description:'Adds an "Add" button that assigns EXISTING records instead of creating one — the m2m/junction case. Shape: `{ picker: { object, valueField?, labelField?, filter? }, linkField?, label? }`. `picker.object` (required) is the object whose records the dialog offers. `picker.valueField` is the field of the picked record used as the link value (default "id"); `picker.labelField` is the column shown in the picker rows (default "name", and the other columns are derived from that object\'s schema). With `linkField` set, selecting records CREATES rows in this list\'s own object as `{ [relationshipField]: parentValue, [linkField]: pickedId }` — the junction case; omit `linkField` and the picked child is RE-PARENTED instead, by setting its own `relationshipField` to this parent. `label` is the button text (default "Add", localizable inline). Setting `add` also enables generic link removal on rows when no host delete handler is wired. `picker.filter` restricts which records the dialog offers — a list of `{ field, operator, value }` rules in the same vocabulary as this list\'s own `filter`, applied as a hard constraint the user cannot widen (it never appears as an editable filter row).'},{name:`enforceFieldSecurity`,type:`boolean`,description:"Fold this list's `columns` through the caller's FIELD-read permissions on the RELATED object before rendering (renderer default: off). Presentation only: it re-applies the same field-read answer the server already enforced (ADR-0066 D3) and never widens access — the rows are fetched either way and the server still decides every value."},{name:`redactFields`,type:`array`,of:`string`,description:"Field names this list never renders, whatever the permission answer (renderer default: render every column authored or derived). Applies to the authored `columns` AND to the columns the list derives for itself when none are authored. Presentation only, evaluated in the browser after the rows are fetched — the values are still in the page, so this is NOT a data-access control and NOT the object's `publicSharing.redactFields`, which removes them server-side. To keep a value from the caller, gate the field itself (`requiredPermissions` / `maskingRule`, ADR-0066 D3) or the permission set."},{name:`requiredPermissions`,type:`array`,of:`string`,description:"[ADR-0066] Capabilities the user must ALL hold — names that permission sets grant through `systemPermissions`, not object actions: `read` or `update` here is an ordinary capability name, not the object's read or edit permission. When the client has resolved the user's capabilities and any of these is missing, this block does not render its content; wherever it would otherwise render, an insufficient-permissions notice takes its place. Presentation only: it authorises nothing, and the data API still serves the same data to the same user. A client that cannot resolve the user's capabilities (no permission provider, or one that does not report `systemPermissions`) renders this block as if they were held — it fails open."}]}),Z.register(`highlights`,Vs,{namespace:`record`,skipFallback:!0,category:`record`,label:`Highlights Panel`,icon:`Star`,inputs:[{name:`fields`,type:`array`,required:!0,description:`Key fields to highlight (1-7), bare names or {name,label?,type?,readonly?}. Set readonly: true on an entry to render that chip read-only — it suppresses the inline-edit affordance and the HeaderHighlight editability gate enforces it. Use it for hook/automation-maintained columns that must not be hand-edited from the record header; marking the OBJECT field readonly instead would also strip the hook's own write-back.`},{name:`layout`,type:`enum`,enum:[`horizontal`,`vertical`],description:`Layout orientation for highlight fields`},{name:`enforceFieldSecurity`,type:`boolean`,description:`Fold this block's highlight chips through the caller's FIELD-read permissions before rendering, so a field the permission set denies leaves no empty chip behind (renderer default: off). Presentation only: it re-applies the same field-read answer the server already enforced (ADR-0066 D3) and never widens access — the record is fetched either way and the server still decides every value.`},{name:`redactFields`,type:`array`,of:`string`,description:"Field names this block never renders as a chip, whatever the permission answer (renderer default: render every field authored). Presentation only, evaluated in the browser after the record is fetched — the values are still in the page, so this is NOT a data-access control and NOT the object's `publicSharing.redactFields`, which removes them server-side. To keep a value from the caller, gate the field itself (`requiredPermissions` / `maskingRule`, ADR-0066 D3) or the permission set."},{name:`requiredPermissions`,type:`array`,of:`string`,description:"[ADR-0066] Capabilities the user must ALL hold — names that permission sets grant through `systemPermissions`, not object actions: `read` or `update` here is an ordinary capability name, not the object's read or edit permission. When the client has resolved the user's capabilities and any of these is missing, this block does not render its content; wherever it would otherwise render, an insufficient-permissions notice takes its place. Presentation only: it authorises nothing, and the data API still serves the same data to the same user. A client that cannot resolve the user's capabilities (no permission provider, or one that does not report `systemPermissions`) renders this block as if they were held — it fails open."}]}),Z.register(`activity`,Fc,{namespace:`record`,skipFallback:!0,category:`record`,label:`Activity Timeline`,icon:`Activity`,inputs:[{name:`types`,type:`array`,of:`string`,description:`Allow-list of feed item types to show (comment, field_change, task, event, email, call, note, file, record_create, record_delete, approval, sharing, system). Omit for all; unrecognised entries are ignored.`},{name:`filterMode`,type:`enum`,enum:[`all`,`comments_only`,`changes_only`,`tasks_only`],description:`Filter the timeline dropdown starts on. The user can still change it; an unrecognised value falls back to "all".`},{name:`showFilterToggle`,type:`boolean`,description:`Expose the activity-type filter dropdown in the panel header`},{name:`limit`,type:`number`,description:`Items per page. Also caps the scoped sys_activity read; "Load more" grows the window by this much.`},{name:`showCompleted`,type:`boolean`,description:`Include completed activities (sys_activity type "completed", which surfaces as a task item). Off by default.`},{name:`unifiedTimeline`,type:`boolean`,description:`Mix field changes and comments in one timeline (Airtable style). Off keeps the panel a discussion stream — field changes stay in record:history.`},{name:`showCommentInput`,type:`boolean`,description:`Show the composer. Requires a host discussion context to persist the comment (record detail pages provide one); without it the feed is read-only.`},{name:`enableMentions`,type:`boolean`,description:`Offer @-mention autocomplete in the composer, from the host discussion context's user list. Off withholds the suggestions.`},{name:`enableReactions`,type:`boolean`,description:`Show emoji reactions on feed items. Toggling one requires a host discussion context; without it existing reactions still render, read-only.`},{name:`enableThreading`,type:`boolean`,description:`Group replies under their parent comment. Posting a reply requires a host discussion context.`},{name:`showSubscriptionToggle`,type:`boolean`,description:`NOT IMPLEMENTED — no record-subscription backend exists yet, so this renders nothing whatever it is set to. Declared for spec parity only (objectui#3165).`}]});var Ol=[{name:`position`,type:`enum`,enum:[`bottom`,`right`,`left`],description:`Where the panel docks relative to the record body`},{name:`width`,type:`string`,description:`Panel width as a CSS value (side positions only)`},{name:`collapsible`,type:`boolean`},{name:`defaultCollapsed`,type:`boolean`},{name:`feed`,type:`object`,description:`Activity-feed configuration nested inside the panel — the same shape as record:activity. The spec declares this key as RecordActivityProps (RecordChatterProps.feed), so its members are the inputs record:activity declares; see that block for what each one does.`}];Z.register(`chatter`,Rc,{namespace:`record`,skipFallback:!0,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`,inputs:Ol}),Z.register(`discussion`,Rc,{namespace:`record`,skipFallback:!0,category:`record`,label:`Discussion`,icon:`MessageSquare`,inputs:Ol}),Z.register(`path`,Vc,{namespace:`record`,skipFallback:!0,category:`record`,label:`Path / Stepper`,icon:`GitBranch`,inputs:[{name:`statusField`,type:`string`,required:!0,description:`Field representing the current status/stage`},{name:`stages`,type:`array`,of:`object`,description:`Explicit stage definitions [{ value, label }] (else derived from field metadata)`}]}),Z.register(`quick_actions`,Kc,{namespace:`record`,skipFallback:!0,category:`record`,label:`Quick Actions`,icon:`Zap`,inputs:[{name:`actionNames`,type:`array`,of:`string`,description:`Action names to expose, in order — resolved from the actions declared on the object. With no names (and no host-supplied actions) nothing is looked up and the bar renders its empty placeholder`},{name:`requiredPermissions`,type:`array`,of:`string`,description:"[ADR-0066] Capabilities the user must ALL hold — names that permission sets grant through `systemPermissions`, not object actions: `read` or `update` here is an ordinary capability name, not the object's read or edit permission. When the client has resolved the user's capabilities and any of these is missing, this block does not render its content; wherever it would otherwise render, an insufficient-permissions notice takes its place. Presentation only: it authorises nothing, and the data API still serves the same data to the same user. A client that cannot resolve the user's capabilities (no permission provider, or one that does not report `systemPermissions`) renders this block as if they were held — it fails open."},{name:`location`,type:`enum`,enum:[...v],description:`Which declared action location this bar renders`},{name:`align`,type:`enum`,enum:[`start`,`center`,`end`]},{name:`inline`,type:`boolean`,description:`Render in the flow instead of folding into the record header`},{name:`variant`,type:`string`,description:`Passed to the Button primitive; a per-action variant overrides it`},{name:`size`,type:`string`,description:`Passed to the Button primitive; a per-action size overrides it`}]}),Z.register(`history`,tl,{namespace:`record`,skipFallback:!0,category:`record`,label:`History Timeline`,icon:`Clock`,inputs:[{name:`limit`,type:`number`,description:`Maximum history entries to display`},{name:`emptyText`,type:`string`,description:`Copy shown when the record has no history`},{name:`unknownUserText`,type:`string`,description:`Copy substituted when an entry has no resolvable actor`}]}),Z.register(`reference_rail`,cl,{namespace:`record`,skipFallback:!0,category:`record`,label:`Reference Rail`,icon:`PanelRight`,inputs:[{name:`hideEmpty`,type:`boolean`,description:`Drop the rail entirely when no entries resolve`}]}),Z.register(`alert`,dl,{namespace:`record`,skipFallback:!0,category:`record`,label:`Alert Banner`,icon:`triangle-alert`,inputs:[{name:`severity`,type:`enum`,enum:[`info`,`warning`,`error`,`success`]},{name:`title`,type:[`string`,`object`],description:`Accepts an inline translation map ({ en, "zh-CN", … })`},{name:`body`,type:[`string`,`object`],description:`Accepts an inline translation map ({ en, "zh-CN", … })`},{name:`visible`,type:[`boolean`,`string`,`object`],description:"Gates the banner against the current record: `true`/`false`, a bare CEL expression, or the `{ dialect: 'cel', source }` envelope"},{name:`icon`,type:`string`,description:`Lucide icon name; defaults to the severity icon`},{name:`action`,type:`object`,description:`{ actionName, label?, variant? } — the action the banner offers`},{name:`dismissible`,type:`boolean`},{name:`dismissKey`,type:`string`,description:`Stable key the dismissal is remembered under`}]}),Z.register(`permission-facet-link`,ge(Ma),{namespace:`field`,skipFallback:!0});var kl={red:`bg-red-100`,green:`bg-green-100`,blue:`bg-blue-100`,yellow:`bg-yellow-100`,orange:`bg-orange-100`,purple:`bg-purple-100`,pink:`bg-pink-100`,gray:`bg-gray-100`,grey:`bg-gray-100`,indigo:`bg-indigo-100`,teal:`bg-teal-100`,cyan:`bg-cyan-100`,amber:`bg-amber-100`,lime:`bg-lime-100`,emerald:`bg-emerald-100`,rose:`bg-rose-100`,sky:`bg-sky-100`,violet:`bg-violet-100`,fuchsia:`bg-fuchsia-100`,slate:`bg-slate-100`,zinc:`bg-zinc-100`,stone:`bg-stone-100`,neutral:`bg-neutral-100`};function Al(e){if(e.startsWith(`bg-`))return e;let t=e.toLowerCase().trim();return Object.prototype.hasOwnProperty.call(kl,t)?kl[t]:void 0}function jl(e){return(0,Q.useCallback)(t=>{if(!e?.field||!e.colors)return;let n=String(t[e.field]??``),r=Object.prototype.hasOwnProperty.call(e.colors,n)?e.colors[n]:void 0;if(r)return Al(r)},[e?.field,e?.colors])}function Ml(e){if(e==null||e===``)return``;if(Array.isArray(e))return e.map(e=>Ml(e)).join(`|`);if(typeof e==`object`){let t=e.id??e._id??e.pk??e.value;if(t!=null&&t!==``)return String(t);let n=e.name??e.label??e.title;if(n!=null&&n!==``)return String(n);try{return JSON.stringify(e)}catch{return``}}return String(e)}function Nl(e,t){return Ml(e[t])}function Pl(e,t,n){if(e==null||e===``)return`(empty)`;if(n){let r=n(t,e);if(r!==void 0&&r!==``)return r}if(Array.isArray(e))return e.map(e=>{if(n){let r=n(t,e);if(r!==void 0&&r!==``)return r}return Pl(e,t)}).join(`, `)||`(empty)`;if(typeof e==`object`){let t=e.name??e.label??e.title??e.display_name??e.displayName??e.fullName??e.full_name;if(t!=null&&t!==``)return String(t);let n=e.id??e._id??e.pk;return n!=null&&n!==``?String(n):`(empty)`}return String(e)}function Fl(e,t){return t.map(({field:t,type:n})=>{if(n===`count_distinct`){let r=new Set;for(let n of e){let e=n[t];e!=null&&e!==``&&r.add(e)}return{field:t,type:n,value:r.size}}if(n===`count`)return{field:t,type:n,value:e.length};let r=e.map(e=>Number(e[t])).filter(e=>Number.isFinite(e)),i;switch(n){case`sum`:i=r.reduce((e,t)=>e+t,0);break;case`avg`:i=r.length>0?r.reduce((e,t)=>e+t,0)/r.length:0;break;case`min`:i=r.length>0?Math.min(...r):0;break;case`max`:i=r.length>0?Math.max(...r):0;break;default:i=0}return{field:t,type:n,value:i}})}function Il(e,t,n){let r=e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`});return n===`desc`?-r:r}function Ll(e){return Array.isArray(e)?e.filter(e=>{if(typeof e!=`object`||!e)return!1;let t=e.field;return typeof t==`string`&&t.trim()!==``}):[]}var Rl={sum:`sum`,count:`count`,avg:`avg`,min:`min`,max:`max`,count_distinct:`count_unique`};function zl(e){return Object.prototype.hasOwnProperty.call(Rl,e)?Rl[e]:void 0}function Bl(e,t){if(!t||t.length===0)return[];let n=[];for(let{field:r,type:i}of t){let t=zl(i);if(!t||typeof r!=`string`||r===``)continue;let a=c(e,t,r);a!==void 0&&n.push({field:r,type:i,value:a===null?null:Number(a)})}return n}function Vl(e,t){let n=e==null,r=t==null;return n||r?n&&r:e===t||String(e)===String(t)}function Hl(e,t,n,r,i){let a=e?.fields,o=(0,Q.useMemo)(()=>Ll(a),[a]),s=o.length>0,[c,l]=(0,Q.useState)({});return{groups:(0,Q.useMemo)(()=>{if(!s)return[];if(i){let e=(t,a,s)=>{if(t>=o.length)return[];let l=o[t],u=o.slice(0,t),d=(i.headers[t]??[]).filter(e=>u.every(t=>Vl(e[t.field],s[t.field]))).map(e=>{let t=e[l.field]??null,n=t===null?void 0:i.keyLabels?.[l.field]?.[String(t)];return{row:e,raw:t,segment:Ml(t),label:n??Pl(t,l.field,r)}}),f=l.order??`asc`;return d.sort((e,t)=>Il(e.label,t.label,f)),d.map(({row:r,raw:i,segment:u,label:d})=>{let f=a?`${a}__${t}:${u}`:`${t}:${u}`,p=!!l.collapsed,m=f in c?c[f]:p,h={...s,[l.field]:i},g=t+1>=o.length,_=Number(r.count);return{key:f,label:d,field:l.field,depth:t,rows:[],count:Number.isFinite(_)?_:0,keyValues:h,collapsed:m,aggregations:Bl(r,n),subgroups:g?[]:e(t+1,f,h)}})};return e(0,``,{})}let e=(t,i,a,s)=>{if(i>=o.length)return[];let l=o[i],u=new Map,d=[];for(let e of t){let t=Nl(e,l.field);u.has(t)||(u.set(t,{label:Pl(e[l.field],l.field,r),rows:[]}),d.push(t)),u.get(t).rows.push(e)}let f=l.order??`asc`;return d.sort((e,t)=>Il(u.get(e)?.label??e,u.get(t)?.label??t,f)),d.map(t=>{let r=u.get(t),d=a?`${a}__${i}:${t}`:`${i}:${t}`,f=!!l.collapsed,p=d in c?c[d]:f,m=n&&n.length>0?Fl(r.rows,n):[],h={...s,[l.field]:r.rows[0]?.[l.field]??null},g=i+1<o.length?e(r.rows,i+1,d,h):[];return{key:d,label:r.label,field:l.field,depth:i,rows:r.rows,count:r.rows.length,keyValues:h,collapsed:p,aggregations:m,subgroups:g}})};return e(t,0,``,{})},[t,o,s,c,n,r,i]),isGrouped:s,toggleGroup:(0,Q.useCallback)(e=>{l(t=>{let n=e.split(`__`).pop()||``,r=/^(\d+):/.exec(n),i=r?Number(r[1]):0,a=!!o[i]?.collapsed;return{...t,[e]:t[e]===void 0?!a:!t[e]}})},[o])}}function Ul(e){let t=[];for(let n of e??[]){if(!n||typeof n.field!=`string`||n.field===``)continue;let e=zl(n.type);e&&t.push({field:n.field,summary:e})}return t}function Wl(e){return{fields:e.map(e=>({field:e.field}))}}var Gl={headers:void 0,keyLabels:{},loading:!1,error:null},Kl={headers:void 0,keyLabels:Gl.keyLabels,loading:!0,error:null},ql={...Gl,question:``};function Jl(e){let t=e?.$search;if(typeof t!=`string`||t===``)return{};let n=e?.$searchFields;return Array.isArray(n)&&n.length>0?{search:t,searchFields:n}:{search:t}}function Yl(e){let{enabled:t,dataSource:n,objectName:r,fields:i,where:a,search:o,searchFields:s,aggregations:c,objectFields:u,reloadKey:d}=e,[f,p]=(0,Q.useState)(ql),m=JSON.stringify(i.map(e=>e.field)),h=JSON.stringify(a??null),g=JSON.stringify(o?{search:o,...s&&s.length>0?{searchFields:[...s]}:{}}:null),_=JSON.stringify(Ul(c)),v=JSON.stringify(i.map(e=>{let t=u?.[e.field];return Mn(t)&&typeof t?.reference==`string`&&t.reference?[t.reference,typeof t.displayField==`string`?t.displayField:null]:null})),y=t&&!!r&&typeof n?.queryGroupHeaders==`function`&&i.length>0,b=JSON.stringify([r??null,m,h,g,_]);return(0,Q.useEffect)(()=>{if(!y||!n||!r){p(e=>e===ql?e:ql);return}let e=!1;p(e=>e.question===b?{...e,loading:!0,error:null}:{...Kl,question:b});let t=JSON.parse(m),i=JSON.parse(v),a=Wl(t.map(e=>({field:e}))),o=JSON.parse(_),s=JSON.parse(h),c=JSON.parse(g);return(async()=>{try{let u=await Promise.all(t.map((e,t)=>{let i=l({grouping:a,columns:o},{...s?{where:s}:{},depth:t+1});return n.queryGroupHeaders(r,c?{...i,...c}:i)})),d={},f=u[u.length-1]??[];await Promise.all(t.map(async(e,t)=>{let r=i[t];if(!r)return;let[a,o]=r,s=[...new Set(f.map(t=>t[e]).filter(e=>e!=null&&e!==``))];if(s.length!==0)try{let t=await n.find(a,{$filter:{id:{$in:s}},$top:s.length}),r={};for(let e of t?.data??[]){let t=e?.id;if(t==null)continue;let n=(o?e[o]:void 0)??e.name??e.label??e.title;n!=null&&n!==``&&(r[String(t)]=String(n))}d[e]=r}catch(t){console.warn(`[ObjectGrid] Failed to resolve group labels for '${e}' (${a}):`,t)}})),e||p({question:b,headers:u,keyLabels:d,loading:!1,error:null})}catch(t){e||p({question:b,headers:void 0,keyLabels:{},loading:!1,error:t instanceof Error?t:Error(String(t))})}})(),()=>{e=!0}},[y,n,r,b,m,h,g,_,v,d]),y?f.question===b?f:Kl:Gl}var Xl={};function Zl(e){let{enabled:t,dataSource:n,objectName:r,fields:i,where:a,baseParams:o,pageSize:s,leaves:c,reloadKey:l}=e,u=JSON.stringify(i.map(e=>e.field)),d=JSON.stringify(a??null),f=JSON.stringify(o??null),m=JSON.stringify(c.map(e=>[e.key,e.keyValues])),h=JSON.stringify([u,d,f,s,l]),g=JSON.stringify([r??null,u,d,Jl(o)]),[_,v]=(0,Q.useState)({question:g,pages:{}}),y=_.question===g?_.pages:Xl,[b,x]=(0,Q.useState)({queryKey:h,pages:{}}),S=b.queryKey===h?b.pages:{},C=t&&!!r&&!!n&&o!==null&&i.length>0,w=JSON.stringify(S);return(0,Q.useEffect)(()=>{if(!C||!n||!r||!o)return;let e=Wl(JSON.parse(u).map(e=>({field:e}))),t=JSON.parse(d),i=JSON.parse(m);for(let[a,c]of i){let i=JSON.parse(w)[a]??1,l=JSON.stringify([h,a,i]);if(y[a]?.signature===l)continue;v(e=>{let t=e.question===g?e.pages:{};return{question:g,pages:{...t,[a]:{rows:t[a]?.rows??[],page:i,loading:!0,error:null,signature:l}}}});let u=p({grouping:e},c,{...t?{where:t}:{},limit:s,offset:(i-1)*s}),{$filter:d,...f}=o,m={...f,$filter:u.where,$top:u.limit,$skip:u.offset},_=e=>e.question===g&&e.pages[a]?.signature===l;n.find(r,m).then(e=>{v(t=>_(t)?{question:g,pages:{...t.pages,[a]:{rows:e?.data??[],page:i,loading:!1,error:null,signature:l}}}:t)}).catch(e=>{v(t=>_(t)?{question:g,pages:{...t.pages,[a]:{rows:[],page:i,loading:!1,error:e instanceof Error?e:Error(String(e)),signature:l}}}:t)})}},[C,n,r,g,u,d,m,w,h,s]),{pages:y,setPage:(0,Q.useCallback)((e,t)=>{x(n=>{let r=n.queryKey===h?n.pages:{};return r[e]===t&&n.queryKey===h?n:{queryKey:h,pages:{...r,[e]:t}}})},[h])}}var Ql=({groupKey:e,label:t,count:n,collapsed:r,aggregations:i,fieldLabel:a,labelColorClass:o,labelColorStyle:s,onToggle:c,children:l})=>{let u=o?U(`inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium`,o):`inline-flex items-center rounded-md bg-muted px-2 py-0.5 text-xs font-medium text-foreground`;return(0,$.jsxs)(`div`,{"data-testid":`group-row-${e}`,className:`group/grouprow`,children:[a&&(0,$.jsx)(`div`,{className:`px-1 pb-1 text-[11px] font-medium text-muted-foreground tracking-wide group-label-caption`,children:a}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-1 py-1 text-sm text-left rounded-md hover:bg-muted/40 transition-colors`,onClick:()=>c(e),"aria-expanded":!r,children:[r?(0,$.jsx)(Qr,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,$.jsx)(Xr,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:U(u,`group-label`),style:s,children:t}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums group-count`,children:n}),i&&i.length>0&&(0,$.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground group-aggregations`,children:i.map(e=>(0,$.jsxs)(`span`,{className:`mr-2`,children:[e.type,`: `,e.value===null?`—`:Number.isInteger(e.value)?e.value:e.value.toFixed(2)]},`${e.field}-${e.type}`))})]}),!r&&(0,$.jsx)(`div`,{className:`mt-1 ml-1.5 pl-3 border-l border-border/60`,children:l})]})};b();var $l=new Set([`count`,`count_empty`,`count_filled`,`count_unique`,`percent_empty`,`percent_filled`]),eu=new Set([`percent_empty`,`percent_filled`]),tu={none:``,count:`grid.summary.count`,count_empty:`grid.summary.countEmpty`,count_filled:`grid.summary.countFilled`,count_unique:`grid.summary.countUnique`,percent_empty:`grid.summary.percentEmpty`,percent_filled:`grid.summary.percentFilled`,sum:`grid.summary.sum`,avg:`grid.summary.avg`,min:`grid.summary.min`,max:`grid.summary.max`},nu=jr({"grid.summary.pattern":`{{label}}: {{value}}`,"grid.summary.count":`Count`,"grid.summary.countEmpty":`Empty`,"grid.summary.countFilled":`Filled`,"grid.summary.countUnique":`Unique`,"grid.summary.percentEmpty":`Empty`,"grid.summary.percentFilled":`Filled`,"grid.summary.sum":`Sum`,"grid.summary.avg":`Avg`,"grid.summary.min":`Min`,"grid.summary.max":`Max`},`grid.summary.sum`),ru=new Set(Object.keys(tu)),iu=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function au(e){if(typeof e==`object`)try{return JSON.stringify(e)??String(e)}catch{return String(e)}return e}function ou(e){return typeof e==`string`?{type:e}:e}function su(e,t){let n=[];for(let r of e){let e=r[t];if(typeof e==`number`&&!isNaN(e))n.push(e);else if(typeof e==`string`){let t=parseFloat(e);isNaN(t)||n.push(t)}}return n}function cu(e){let t=0;for(let n of e){if(!Number.isFinite(n))continue;let[e,r]=String(n).split(`e`),i=e.indexOf(`.`),a=i===-1?0:e.length-i-1;t=Math.max(t,a-(r?Number(r):0))}return Math.min(t,20)}function lu(e,t,n){if($l.has(e)){let r=t.length;if(r===0)return null;switch(e){case`count`:return r;case`count_filled`:return t.filter(e=>!iu(e[n])).length;case`count_empty`:return t.filter(e=>iu(e[n])).length;case`count_unique`:{let e=new Set;for(let r of t){let t=r[n];iu(t)||e.add(au(t))}return e.size}case`percent_filled`:return t.filter(e=>!iu(e[n])).length/r*100;case`percent_empty`:return t.filter(e=>iu(e[n])).length/r*100;default:return null}}let r=su(t,n);if(r.length===0)return null;switch(e){case`sum`:return r.reduce((e,t)=>e+t,0);case`avg`:return r.reduce((e,t)=>e+t,0)/r.length;case`min`:return Math.min(...r);case`max`:return Math.max(...r);default:return null}}var uu=/^[A-Za-z]{3}$/;function du(e,t,n,r,i,a,o){if(t===null)return``;let s=tu[e],c=s?n(s):e,l=e=>n(`grid.summary.pattern`,{label:c,value:e});if(eu.has(e))return l(`${t.toLocaleString(a,{maximumFractionDigits:1})}%`);if($l.has(e))return l(t.toLocaleString(a));let u=r?.type,d;if(u===`currency`){let e=Nr(r,i);d=e&&!uu.test(e)?t.toLocaleString(a):Ae(t,e,a)}else if(u===`percent`){let e=h(r);d=Ie(t,Me(r),e,a)}else if(u===`number`){let e=h(r);d=t.toLocaleString(a,e===void 0?{maximumFractionDigits:o}:{minimumFractionDigits:e,maximumFractionDigits:e})}else d=e===`avg`?t.toLocaleString(a,{maximumFractionDigits:2}):t.toLocaleString(a);return l(d)}function fu(e,t,n){let{currency:r}=Mr(),i=Ir(),{t:a}=nu();return(0,Q.useMemo)(()=>{let o=new Map;if(!e||e.length===0||t.length===0)return{summaries:o,hasSummary:!1};for(let s of e){if(!s.summary)continue;let e=ou(s.summary);if(e.type===`none`||!ru.has(e.type))continue;let c=e.field||s.field,l=lu(e.type,t,c),u=n?.[c],d={type:s.type??u?.type,currency:u?.currency,defaultCurrency:u?.defaultCurrency,currencyConfig:u?.currencyConfig,precision:u?.precision,scale:u?.scale,max:u?.max},f=$l.has(e.type)?0:cu(su(t,c));o.set(s.field,{field:s.field,value:l,label:du(e.type,l,a,d,r,i,f)})}return{summaries:o,hasSummary:o.size>0}},[e,t,n,r,i,a])}function pu(e){let t=tr({managedBy:e.managedBy,userActions:e.userActions},e.effectiveApiOperations),n=t.edit&&e.permissionUpdate!==!1,r=t.delete&&e.permissionDelete!==!1,i=!e.rowActionsDeclared||!!e.wantEditAction,a=!e.rowActionsDeclared||!!e.wantDeleteAction,o=!!(e.operationsUpdate&&i&&e.hasOnEdit)&&n,s=!!(e.operationsDelete&&a&&e.hasOnDelete)&&r;return{canEdit:o,canDelete:s,objectCanDelete:r,editPredicates:o?t.editPredicates:void 0,deletePredicates:s?t.deletePredicates:void 0,objectDeletePredicates:r?t.deletePredicates:void 0}}function mu(e,t){return!!e&&t!==!1}var hu=new Map,gu=(e,t,n,r)=>JSON.stringify([e,t,n,r]),_u;function vu(e){_u!==void 0&&_u!==e&&hu.clear(),_u=e}var yu=new Set;function bu(e){for(let t of Array.from(hu.keys())){let[,n,r]=JSON.parse(t);sr(e,n,r)&&hu.delete(t)}for(let t of yu)for(let n of t.recordIds)sr(e,t.object,n)&&t.staled.add(n)}Yn(bu);var xu=()=>void 0;function Su(e){let{objectName:t,recordIds:n,update:r,delete:i}=e,a=Q.useContext(gn)?.apiFetch,o=He().userId,s=Rn(t),c=JSON.stringify(n),l=Q.useMemo(()=>JSON.parse(c),[c]),[u,d]=Q.useState(()=>new Map);return Q.useEffect(()=>{vu(o);let e=[];if(r&&e.push(`update`),i&&e.push(`delete`),!t||l.length===0||e.length===0){d(new Map);return}let n=!1,s=a??fetch,c=()=>{let n=new Map;for(let r of e)for(let e of l){let i=hu.get(gu(o,t,e,r));typeof i==`boolean`&&n.set(`${r}:${e}`,i)}d(n)};return(async()=>{await Promise.all(e.map(async e=>{let n=l.filter(n=>!hu.has(gu(o,t,n,e)));for(let r=0;r<n.length;r+=200){let i=n.slice(r,r+200),a={object:t,operation:e,recordIds:i},c={object:t,recordIds:i,staled:new Set};yu.add(c);try{let n=await s(`/api/v1/security/explain`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify(a)});if(!n.ok)continue;let r=(await n.json())?.records;if(!Array.isArray(r))continue;i.forEach((n,i)=>{let a=r[i];a&&typeof a.visible==`boolean`&&(typeof a.recordId!=`string`||a.recordId===n)&&(c.staled.has(n)||hu.set(gu(o,t,n,e),a.visible))})}catch{}finally{yu.delete(c)}}})),n||c()})(),c(),()=>{n=!0}},[t,l,r,i,a,o,s]),Q.useMemo(()=>u.size===0?xu:(e,t)=>e==null?void 0:u.get(`${t}:${String(e)}`),[u])}function Cu(e){let t=Array.isArray(e.rowActionDefs)?e.rowActionDefs:[],n=Array.isArray(e.rowActions)?e.rowActions:[];if(n.length===0)return{defs:t,unresolved:[]};let r=Array.isArray(e.objectActions)?e.objectActions:[],i=new Set(t.map(e=>e?.name).filter(e=>typeof e==`string`&&e!==``)),a=[],o=[];for(let e of n){if(typeof e!=`string`||e===``||i.has(e))continue;let t=r.find(t=>t?.name===e);t?(i.add(e),a.push(t)):o.push(e)}return{defs:a.length>0?[...t,...a]:t,unresolved:o}}var wu=Object.freeze([`cell`]),Tu=Object.freeze([`cell`,`lookup-editor`,`user-editor`]),Eu=Object.freeze([`cell`,`lookup-editor`]),Du=Object.freeze([`lookup-editor`,`user-editor`]),Ou=Object.freeze([`lookup-editor`]),ku=new Set([`spec`,`widget-contract`]),Au={reference:{verdict:`spec`,readers:Tu,note:`FieldSchema.reference — the served spelling for a lookup's target object, and since objectui#11070 round 4 the only one any consumer reads.`},reference_field:{verdict:`no-producer`,readers:Tu,note:"Third leg of the display-field chain. Not on FieldSchema; zero occurrences in the producer repo (control: `displayField`, 68 files). objectui#6875."},displayField:{verdict:`spec`,readers:Tu,note:"FieldSchema.displayField. ⭐ Added by objectui#6875 as the only display spelling a spec-compliant producer can emit; objectui#7155 made it the ONLY one read, retiring the `display_field` leg that used to outrank it."},descriptionField:{verdict:`spec`,readers:Ou,note:`FieldSchema.descriptionField. Added by objectui#6875, RETIRED from the copy set by objectui#7166: its only reader is LookupField, which the inline editor feeds from the schema def, so the copy reached nothing. Measured by rendering — the picker's secondary line still appears with this table unchanged.`},lookupColumns:{verdict:`spec`,readers:Ou,note:"FieldSchema.lookupColumns. Added by objectui#6875, RETIRED from the copy set by objectui#7166 on the same measurement as `descriptionField`. Measured by rendering — the declared columns still shape the picker with this table unchanged."},lookup_columns:{verdict:`no-producer`,readers:Ou,note:"Runtime twin of `lookupColumns`, read but never producible. Not on FieldSchema. objectui#6875."},lookupFilters:{verdict:`spec`,readers:Du,note:`FieldSchema.lookupFilters. RETIRED from the copy set by objectui#7166: read off a field meta only by LookupField and UserField, both fed by the editor's schema spread. Measured by rendering — the declared filter still scopes the picker's candidates with this table unchanged.`},idField:{verdict:`widget-contract`,readers:Ou,note:"LookupFieldMetadata.idField — the picker's id column. Absent from FieldSchema, and `id_field` was too: this is a widget-contract key by construction, not a spelling gap. Read only by LookupField, which the inline editor feeds from the schema def, so it stays off the copy set (objectui#7166's measurement, unchanged by the rename)."},multiple:{verdict:`spec`,readers:Ou,note:`FieldSchema.multiple — picker cardinality. Read only by LookupField, which the grid feeds from the schema def, not from this bag: measured accumulating two picks in the inline picker with this table unchanged (objectui#7154).`},allowCreate:{verdict:`spec`,readers:Ou,note:"FieldSchema.allowCreate — picker quick-create affordance. Same route as `multiple`: `allowCreate: false` measured removing the create entry the control column offers (objectui#7154)."},lookupPageSize:{verdict:`spec`,readers:Ou,note:`FieldSchema.lookupPageSize — picker page size. Same route: a declared 3 measured scoping the picker dialog to 3 rows against a control of 10 (objectui#7154).`},dependsOn:{verdict:`spec`,readers:Ou,note:"FieldSchema.dependsOn — cascading picker filter. Same route, and it ARRIVES: the declared column renders the trigger, gated while a named parent is empty. Whether that gate can LIFT here is re-derived by `__tests__/gridDependentValues-7165.test.tsx`, not asserted in this sentence — the grid’s inline editor has supplied the dependent record since objectui#7165/#7188, closing objectui#2215’s grid-side residue (objectui#7154). The bulk action dialog’s half of that residue is objectui#8755."},allow_create:{verdict:`no-producer`,readers:Ou,note:"Runtime twin of `allowCreate`. Not on FieldSchema."},lookup_page_size:{verdict:`no-producer`,readers:Ou,note:"Runtime twin of `lookupPageSize`. Not on FieldSchema."},picker:{verdict:`no-producer`,readers:Du,note:`PeoplePicker variant opt-in. Not on FieldSchema.`},subtitle:{verdict:`no-producer`,readers:Du,note:`PeoplePicker subtitle fields. Not on FieldSchema.`},avatarField:{verdict:`no-producer`,readers:Du,note:`PeoplePicker avatar field. Not on FieldSchema.`},avatar_field:{verdict:`no-producer`,readers:Du,note:"Runtime twin of `avatarField`. Not on FieldSchema."},options:{verdict:`handled-elsewhere`,readers:Eu,note:"Written by generateColumns as `translateOptions(...)`, which localises the labels; a raw copy would undo that."},dataSource:{verdict:`handled-elsewhere`,readers:Ou,note:"Not a schema key — LookupField reads its own `props.dataSource` fallback off the meta bag."}};function ju(e){return e.readers.some(e=>wu.includes(e))}var Mu=Object.freeze(Object.entries(Au).filter(([,e])=>ku.has(e.verdict)&&(ju(e)||e.copiedWithoutCellReader!==void 0)).map(([e])=>e));function Nu(e,t){if(t)for(let n of Mu)t[n]!==void 0&&(e[n]=t[n])}var Pu=new Set([`primary`,`secondary`,`danger`,`ghost`]);function Fu(e){let t=typeof e.name==`string`&&e.name||typeof e.field==`string`&&e.field||``;if(!t)return null;let n={...e,name:t,type:typeof e.type==`string`?e.type:`text`};return typeof e.label==`string`&&(n.label=e.label),typeof e.helpText==`string`&&(n.help=e.helpText),e.defaultValue!==void 0&&(n.default=e.defaultValue),typeof e.reference==`string`&&(n.object=e.reference),n}function Iu(e,t){let n=String(e.name),r=(Array.isArray(e.params)?e.params:[]).map(e=>e&&typeof e==`object`?Fu(e):null).filter(e=>e!==null),i=typeof e.variant==`string`&&Pu.has(e.variant)?e.variant:void 0,a=typeof e.confirmText==`string`?e.confirmText:void 0,o=typeof e.label==`string`?e.label:void 0,s=t?t(n,o??n):o;return{name:n,...s!==void 0&&{label:s},...typeof e.icon==`string`&&{icon:e.icon},...i&&{variant:i},operation:`custom`,...r.length>0&&{params:r},...a!==void 0&&{confirmText:a},...e.visible!=null&&{visible:e.visible},...Array.isArray(e.requiredPermissions)&&{requiredPermissions:e.requiredPermissions},batchSize:25,actionDef:e}}function Lu(e){if(!e||typeof e!=`object`)return!1;let t=e.name;return typeof t==`string`&&t.length>0}function Ru(e){return typeof e==`string`?`'${e}'`:String(e)}function zu({blockType:e,objectName:t,label:n}){let r=typeof e==`string`&&e.length>0?e:`object-grid`,i=[];return typeof t==`string`&&t.length>0?i.push(`objectName: '${t}'`):i.push(`no objectName`),typeof n==`string`&&n.length>0&&i.push(`label: '${n}'`),`${r} (${i.join(`, `)})`}function Bu(e){if(e==null)return`the entry is ${String(e)}, not a def object`;if(typeof e!=`object`){let t=typeof e==`string`&&e.length>0?` Write \`{ name: '${e}', operation: 'custom' }\` here, or move the bare name to \`bulkActions\`, which resolves it against the object's declared actions and promotes the match.`:``;return`the entry is a ${typeof e} (${Ru(e)}), not a def object — this key's members are full \`BulkActionDef\` objects, used as authored.${t}`}let t=e,n=Object.keys(t),r=n.length>0?`keys seen: ${n.map(e=>`\`${e}\``).join(`, `)}`:"the entry is empty `{}`";if(!(`name`in t))return`${r} — no \`name\` key, so the def has no identity.`;let i=t.name;return typeof i==`string`?`${r} — \`name\` is an empty string, so the button would carry no key and no label.`:`${r} — \`name\` is a ${i===null?`null`:typeof i} (${Ru(i)}), and only a non-empty string names an action.`}function Vu(e,t){if(!Array.isArray(e)||e.length===0)return null;let n=e.map((e,t)=>({index:t,member:e})).filter(({member:e})=>!Lu(e));if(n.length===0)return null;let r=e.length-n.length,i=`${n.length} of ${e.length} authored bulk-action def${e.length===1?``:`s`} cannot be rendered and ${n.length===1?`is`:`are`} skipped`,a=r===0?`${i}, so this selection bar offers NO bulk-action buttons`:`${i} (${r} still render)`,o=n.map(({index:e,member:t})=>` • bulkActionDefs[${e}]: ${Bu(t)}`);return`[ObjectUI] ObjectGrid bulkActionDefs: ${zu(t)} — ${a}.\n${o.join(`
|
|
3
|
+
`)}\n A \`bulkActionDefs\` member must be an object with a non-empty string \`name\`: the selection bar uses it as the button's React key AND as the source of its label.`}function Hu(e){let t=Array.isArray(e.bulkActionDefs)?e.bulkActionDefs:[],n=t.every(Lu)?t:t.filter(Lu),r=Array.isArray(e.bulkActions)?e.bulkActions:[],i=Array.isArray(e.objectActions)?e.objectActions:[],a=e=>!!e&&e.execution===`aggregate`&&e.operation===`custom`&&!e.actionDef&&typeof e.name==`string`&&e.name!==``,o=n.some(a)?n.map(t=>{if(!a(t))return t;let n=i.find(e=>e?.name===t.name);if(!n)return t;let{batchSize:r,...o}=Iu(n,e.localizeLabel);return{...o,...t}}):n,s=new Set(o.map(e=>e?.name).filter(e=>typeof e==`string`&&e!==``)),c=[],l=[];for(let t of r){if(typeof t!=`string`||t===``||s.has(t))continue;s.add(t);let n=i.find(e=>e?.name===t);n?c.push(Iu(n,e.localizeLabel)):l.push(t)}return{defs:c.length>0?[...o,...c]:o,unresolved:l}}function Uu(e){return ir(e?.visible)}function Wu(e,t,n={}){return Xn(Uu(e)?e?.visible:void 0,t,{scope:n.scope,fields:n.fields,warnOnError:!0,label:e?.name})}var Gu=`field`,Ku=`label`,qu=[`accessorKey`,`header`];function Ju(e){if(!e||typeof e!=`object`)return!1;let t=e;return!t.hidden&&typeof t.field==`string`&&t.field.length>0}function Yu(e){return!!e&&typeof e==`object`&&!!e.hidden}function Xu(e){return typeof e==`string`?`'${e}'`:String(e)}function Zu(e){if(e==null)return`the entry is ${String(e)}, not a column object`;if(typeof e!=`object`)return`the entry is a ${typeof e} (${Xu(e)}), not a column object — a bare field name only works when EVERY entry is a string (\`columns: ['name', 'amount']\`)`;let t=e,n=Object.keys(t),r=qu.filter(e=>e in t),i=n.length>0?`keys seen: ${n.map(e=>`\`${e}\``).join(`, `)}`:"the entry is empty `{}`";if(r.length>0){let e=t.accessorKey,n=t.header,a=typeof e==`string`&&e.length>0?` Write \`{ ${Gu}: '${e}'${typeof n==`string`&&n.length>0?`, ${Ku}: '${n}'`:``} }\` instead.`:``;return`${i} — ${r.map(e=>`\`${e}\``).join(` / `)} ${r.length>1?`are`:`is`} refused by name and not read here.${a}`}if(!(`field`in t))return`${i} — no \`${Gu}\` key, so the column names no field.`;let a=t[Gu];return typeof a==`string`?a.length===0?`${i} — \`${Gu}\` is an empty string, so the column names no field.`:`${i} — \`${Gu}\` is '${a}', and the column still did not resolve.`:`${i} — \`${Gu}\` is a ${a===null?`null`:typeof a} (${Xu(a)}), and only a non-empty string names a field.`}function Qu(e){if(!Array.isArray(e)||e.length===0||typeof e[0]!=`object`||e[0]===null)return null;let t={resolved:0,hidden:0,unresolved:[]};return e.forEach((e,n)=>{Ju(e)?t.resolved+=1:Yu(e)?t.hidden+=1:t.unresolved.push({index:n,detail:Zu(e)})}),t}function $u({blockType:e,objectName:t,label:n}){let r=typeof e==`string`&&e.length>0?e:`object-grid`,i=[];return typeof t==`string`&&t.length>0?i.push(`objectName: '${t}'`):i.push(`no objectName`),typeof n==`string`&&n.length>0&&i.push(`label: '${n}'`),`${r} (${i.join(`, `)})`}function ed(e,t){let n=Qu(e);if(!n||n.unresolved.length===0)return null;let r=Array.isArray(e)?e.length:0,i=n.unresolved.length,a=n.resolved===0?`${i} of ${r} authored columns resolve to nothing, so this grid renders its row-number column and NO data columns`:`${i} of ${r} authored columns resolve to nothing and are dropped (${n.resolved} still render)`,o=n.unresolved.map(e=>` • columns[${e.index}]: ${e.detail}`);return`[ObjectUI] ObjectGrid columns: ${$u(t)} — ${a}.\n${o.join(`
|
|
4
|
+
`)}\n \`ListColumnSchema\` (@objectstack/spec/ui) declares ONE column spelling: \`${Gu}\` (required — the field name) and \`${Ku}\` (the header). A plain \`string[]\` of field names works too. (objectui#5349)`}var td={"grid.openMenu":`Open menu`,"grid.edit":`Edit`,"grid.delete":`Delete`};function nd(){let{t:e}=Lr();return t=>{let n=e(t);return n===t?td[t]??t:n}}function rd(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function id(e,t,n,r,i){return typeof e==`boolean`?e:e==null||e===``?!1:Qn(e,t??{},{fallback:!1,scope:n,warnOnError:!0,label:r,fields:i})}function ad(e,t,n,r,i){let a=e?.visibleWhen;return a==null||id(a,n,r,`builtin:${t}:visibleWhen`,i)}function od(e){let{row:t,scope:n,objectFields:r}=e,i=!!(e.canEdit&&e.onEdit)&&ad(e.editPredicates,`edit`,t,n,r),a=!!(e.canDelete&&e.onDelete)&&ad(e.deletePredicates,`delete`,t,n,r),o=(e.actionDefs??[]).filter(e=>X(e,t,n,r)),s=o.filter(e=>e.variant===`primary`),c=Math.max(0,e.maxInlineActions??1),l=s.slice(0,c),u=[...s.slice(c),...o.filter(e=>e.variant!==`primary`)],d=[...e.rowActions??[]];return{inline:l,edit:i,remove:a,custom:u,legacy:d,menuCount:+!!i+ +!!a+u.length+d.length}}var sd=({def:e,row:t,objectFields:n,onActionDef:r})=>{let i=Zt(),a=Q.useMemo(()=>X(e,t,i,n),[e,t,i,n]),o=e.disabled,s=rn(o,t,{fallback:!0,warnOnError:!0,label:`${e.name}:disabled`,fields:n}),c=ir(o)&&s;return a?(0,$.jsx)(vt,{disabled:c,onClick:()=>{c||r?.(e,t)},"data-testid":`row-action-${e.name}`,className:e.variant===`danger`?`text-destructive focus:text-destructive`:void 0,children:e.label??rd(e.name)}):null},cd=({name:e,predicates:t,row:n,icon:r,label:i,className:a,objectFields:o,onSelect:s})=>{let c=Zt(),l=Q.useMemo(()=>ad(t,e,n,c,o),[t,e,n,c,o]),u=rn(t?.disabledWhen,n,{fallback:!1,warnOnError:!0,label:`builtin:${e}:disabledWhen`,fields:o});if(!l)return null;let d=t?.disabledWhen!=null&&u;return(0,$.jsxs)(vt,{disabled:d,onClick:()=>{d||s(n)},"data-testid":`row-action-builtin-${e}`,className:a,children:[r,i]})};function ld(e){switch(e){case`danger`:return`destructive`;case`secondary`:return`secondary`;case`ghost`:return`ghost`;case`link`:return`link`;default:return`default`}}var ud=({def:e,row:t,objectFields:n,onActionDef:r})=>{let i=Zt();return Q.useMemo(()=>X(e,t,i,n),[e,t,i,n])?(0,$.jsx)(G,{variant:ld(e.variant),size:`sm`,className:`h-8`,"data-testid":`row-action-inline-${e.name}`,onClick:n=>{n.stopPropagation(),r?.(e,t)},children:e.label??rd(e.name)}):null},dd=({row:e,rowActions:t,rowActionDefs:n,canEdit:r,canDelete:i,editPredicates:a,deletePredicates:o,onEdit:s,onDelete:c,onAction:l,onActionDef:u,maxInlineActions:d=1,objectFields:f})=>{let p=nd(),m=wn(),h=Q.useMemo(()=>(n??[]).filter(e=>m(e?.requiredPermissions)),[n,m]),g=Zt(),_=Q.useMemo(()=>od({row:e,scope:g,actionDefs:h,maxInlineActions:d,rowActions:t,canEdit:r,canDelete:i,onEdit:s,onDelete:c,editPredicates:a,deletePredicates:o,objectFields:f}),[e,g,h,d,t,r,i,s,c,a,o,f]),v=_.menuCount>0;return(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-1 whitespace-nowrap`,onClick:e=>e.stopPropagation(),children:[_.inline.map(t=>(0,$.jsx)(ud,{def:t,row:e,objectFields:f,onActionDef:u},t.name)),v&&(0,$.jsxs)(Ve,{children:[(0,$.jsx)(it,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon`,className:`h-8 w-8 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0`,"data-testid":`row-action-trigger`,children:[(0,$.jsx)(di,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:p(`grid.openMenu`)})]})}),(0,$.jsxs)(St,{align:`end`,onClick:e=>e.stopPropagation(),children:[_.edit&&(0,$.jsx)(cd,{name:`edit`,predicates:a,row:e,icon:(0,$.jsx)(Wi,{className:`mr-2 h-4 w-4`}),label:p(`grid.edit`),objectFields:f,onSelect:e=>s?.(e)}),_.remove&&(0,$.jsx)(cd,{name:`delete`,predicates:o,row:e,icon:(0,$.jsx)(Yi,{className:`mr-2 h-4 w-4`}),label:p(`grid.delete`),objectFields:f,onSelect:e=>c?.(e)}),_.custom.map(t=>(0,$.jsx)(sd,{def:t,row:e,objectFields:f,onActionDef:u},t.name)),_.legacy.map(t=>(0,$.jsx)(vt,{onClick:()=>l?.(t,e),"data-testid":`row-action-${t}`,children:rd(t)},t))]})]})]})},fd=({def:e,selectedRows:t,objectFields:n,onActionDef:r})=>{let i=Zt(),{eligible:a}=Q.useMemo(()=>Wu(e,t,{scope:i,fields:n}),[e,t,i,n]);if(Uu(e)&&a.length===0)return null;let o=e.variant===`danger`||e.operation===`delete`,s=e.icon?ht(e.icon):null;return(0,$.jsxs)(G,{variant:o?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>r?.(e,t),"data-testid":`bulk-action-${e.name}`,children:[s?(0,$.jsx)(ke,{name:s,className:`h-3 w-3`}):o?(0,$.jsx)(Yi,{className:`h-3 w-3`}):null,e.label??rd(e.name)]})},pd=({selectedRows:e,actions:t,actionDefs:n,objectFields:r,onAction:i,onActionDef:a,onClearSelection:o,pageSize:s,totalMatching:c,allMatchingSelected:l,onSelectAllMatching:u})=>{let{t:d}=Lr(),f=wn(),p=Q.useMemo(()=>(n??[]).filter(e=>f(e?.requiredPermissions)),[n,f]),m=p.length>0,h=Array.isArray(t)&&t.length>0;if(e.length===0)return null;let g=!l&&typeof c==`number`&&typeof s==`number`&&s>0&&e.length>=s&&c>s;return(0,$.jsxs)(`div`,{className:`border-t border-primary/30 px-4 py-2 flex flex-col gap-1.5 text-xs bg-primary/10 text-foreground shrink-0 shadow-sm motion-safe:animate-in motion-safe:slide-in-from-bottom-2 motion-safe:fade-in-0 motion-safe:duration-200`,role:`region`,"aria-label":`Bulk actions`,"data-testid":`bulk-actions-bar`,children:[(g||l)&&(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground`,"data-testid":`bulk-cross-page-banner`,children:l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ui,{className:`h-3 w-3 text-primary shrink-0`}),(0,$.jsx)(`span`,{children:d(`grid.bulkAllMatchingSelected`,{count:c,defaultValue:`All {{count}} matching records are selected.`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:d(`grid.bulkAllOnPage`,{count:s,defaultValue:`All {{count}} on this page are selected.`})}),(0,$.jsx)(`button`,{type:`button`,className:`font-medium text-primary underline-offset-2 hover:underline`,onClick:u,"data-testid":`bulk-select-all-matching`,children:d(`grid.bulkSelectAllMatching`,{count:c,defaultValue:`Select all {{count}} matching`})})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ui,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium tabular-nums`,children:(0,$.jsx)(`span`,{className:`inline-block motion-safe:animate-in motion-safe:zoom-in-90 motion-safe:duration-150`,children:l?d(`grid.bulkSelectedAllMatches`,{count:c,defaultValue:`{{count}} selected (all matches)`}):d(`grid.bulkSelected`,{count:e.length,defaultValue:`{{count}} selected`})},l?`all-${c}`:e.length)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:[m&&p.map(t=>(0,$.jsx)(fd,{def:t,selectedRows:e,objectFields:r,onActionDef:a},t.name)),h&&t.map(t=>{let n=String(t).toLowerCase(),r=n.includes(`delete`)||n.includes(`remove`)||n.includes(`destroy`),a=r?Yi:null;return(0,$.jsxs)(G,{variant:r?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>i?.(t,e),"data-testid":`bulk-action-${t}`,children:[a&&(0,$.jsx)(a,{className:`h-3 w-3`}),rd(t)]},t)})]}),(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:o,children:[(0,$.jsx)(ta,{className:`h-3 w-3`}),d(`grid.bulkClear`,{defaultValue:`Clear`})]})]})]})};b();function md(e){return typeof e?.type==`string`&&f(e)}function hd(e,t){if(!t)return e;let n=null;for(let[r,i]of Object.entries(e)){if(i==null||Array.isArray(i)||!md(t[r]))continue;let a=typeof i;(a===`string`||a===`number`||a===`boolean`)&&(n||={...e},n[r]=[i])}return n??e}function gd({resource:e,dataSource:t,objectFields:n,runAction:r,runAggregate:i}){let[a,o]=(0,Q.useState)({total:0,done:0,failed:0,inFlight:!1}),[s,c]=(0,Q.useState)(null),l=(0,Q.useRef)([]),u=(0,Q.useRef)(null),d=(0,Q.useCallback)(()=>{o({total:0,done:0,failed:0,inFlight:!1}),c(null),l.current=[],u.current=null},[]);return{run:(0,Q.useCallback)(async(a,s,d)=>{let f=s.length,p=a.operation===`custom`&&a.execution===`aggregate`&&!!a.actionDef,m=p?Math.max(1,s.length):Math.max(1,a.batchSize??200),h=[],g=0,_=0;c(null),o({total:f,done:0,failed:0,inFlight:!0});let v=()=>hd({...a.patch??{},...d},n),y=[];if(a.operation===`update`){let e=Object.keys(v());for(let t of s){let n=String(t.id??``);if(!n)continue;let r={};for(let n of e)r[n]=t[n];y.push({id:n,prev:r})}}for(let n=0;n<s.length;n+=m){let c=s.slice(n,n+m),l=[];for(let e=0;e<c.length;e+=1){let t=c[e].id==null?``:String(c[e].id);t?l.push(t):(_+=1,h.push({id:`index_${n+e}`,error:`Missing record id`}))}if(l.length===0){o({total:f,done:g,failed:_,inFlight:!0});continue}let u=new Map;for(let e of c){let t=e.id==null?``:String(e.id);t&&u.set(t,e)}let y=l.length>=2||p,b,x=`bulk`,S;p&&i?(b=async e=>{try{return await i(a,e.map(e=>u.get(e)??{id:e}),{...d}),e.length}catch(e){throw S=e,e}},x=`aggregate action`):a.operation===`update`&&typeof t.bulkUpdate==`function`?(b=n=>t.bulkUpdate(e,n,v()),x=`bulk update`):a.operation===`delete`&&typeof t.bulkDelete==`function`&&(b=n=>t.bulkDelete(e,n),x=`bulk delete`);let C=await mr({ids:l,originalSize:c.length,offset:n,allowBulk:y,label:x},{bulkCall:b,perRow:n=>{switch(a.operation){case`delete`:return t.delete(e,n);case`update`:return t.update(e,n,v());case`custom`:return p?Promise.reject(S instanceof Error?S:Error(S===void 0?`Aggregate action ${a.name} has no dispatcher wired`:String(S))):a.actionDef&&r?r(a,u.get(n)??{id:n},{...d}):Promise.resolve();default:return Promise.reject(Error(`Unknown operation: ${a.operation}`))}}});g+=C.succeeded,_+=C.failed,h.push(...C.errors),o({total:f,done:g,failed:_,inFlight:!0})}let b={total:f,succeeded:g,failed:_,errors:h},x=new Set(h.map(e=>e.id));return l.current=y.filter(e=>!x.has(e.id)),u.current={def:a,rows:s,params:d},o({total:f,done:g,failed:_,inFlight:!1}),c(b),g>0&&Ge.invalidate(e),b},[e,t,n,r,i]),undo:(0,Q.useCallback)(async()=>{let n=l.current;if(!n.length)return null;let r=n.length,i=[],a=0,s=0;c(null),o({total:r,done:0,failed:0,inFlight:!0}),(await Promise.allSettled(n.map(n=>t.update(e,n.id,n.prev)))).forEach((e,t)=>{e.status===`fulfilled`?a+=1:(s+=1,i.push({id:n[t].id,error:e.reason instanceof Error?e.reason.message:String(e.reason)}))});let u={total:r,succeeded:a,failed:s,errors:i};return l.current=[],o({total:r,done:a,failed:s,inFlight:!1}),c(u),u},[e,t]),retry:(0,Q.useCallback)(async i=>{let a=u.current;if(!a)return!1;let o=a.rows.find(e=>String(e.id??``)===i);if(!o)return!1;let s=hd({...a.def.patch??{},...a.params},n);try{switch(a.def.operation){case`delete`:await t.delete(e,i);break;case`update`:await t.update(e,i,s);break;case`custom`:if(a.def.execution===`aggregate`)return!1;if(!a.def.actionDef||!r)return!0;await r(a.def,o,{...a.params});break;default:return!1}return c(e=>{if(!e)return e;let t=e.errors.filter(e=>e.id!==i);return{...e,errors:t,succeeded:e.succeeded+1,failed:Math.max(0,e.failed-1)}}),!0}catch{return!1}},[e,t,n,r]),progress:a,result:s,reset:d}}var _d={checkbox:`boolean`,reference:`lookup`,"datetime-local":`datetime`},vd=new Set([`lookup`,`master_detail`]),yd=new Set([`user`]);function bd(e){return an.has(e)}function xd(e){return Ne(_d[e]??e)}function Sd(e){return bd(xd(e.type))}function Cd(e){let t=xd(e.type);return e.object?e.object:yd.has(t)?`sys_user`:void 0}function wd(e,t){let n=xd(e.type);vd.has(n)&&!e.object&&(n=`text`),vd.has(n)&&e.object===`sys_user`&&(n=`user`);let{name:r,label:i,type:a,required:o,help:s,default:c,multiple:l,options:u,object:d,labelField:f,placeholder:p,...m}=e,h={...m,name:r,label:i??r,type:n,required:o,placeholder:p,options:u?.map(e=>({...e,value:String(e.value)})),multiple:t};return bd(n)&&(h.reference=d,typeof f==`string`&&(h.displayField=f)),h}function Td(e){return bd(e.type)}var Ed=({def:e,rows:t,resource:n,dataSource:r,open:i,onClose:a,labelKey:o=`name`,objectFields:s,runAction:c,runAggregate:l,skippedCount:u=0})=>{let{t:d}=Lr(),f=e?.params??[],p=(0,Q.useCallback)(t=>typeof t.multiple==`boolean`?t.multiple:e?.operation===`update`&&md(s?.[t.name]),[e?.operation,s]),m=(0,Q.useMemo)(()=>{let e={};for(let t of f)t.default!==void 0&&(e[t.name]=t.default);return e},[e?.name]),[h,g]=(0,Q.useState)(`params`),[_,v]=(0,Q.useState)(m),[y,b]=(0,Q.useState)({}),{run:x,undo:S,retry:C,progress:w,result:T,reset:E}=gd({resource:n,dataSource:r,objectFields:s,runAction:c,runAggregate:l}),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),N=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(!i)return;let e=()=>{N.current=!!document.querySelector(`[data-radix-popper-content-wrapper] [data-state="open"]`)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[i]),(0,Q.useEffect)(()=>{i&&(E(),v(m),b({}),M(null),A(!1),O(null),g(f.length===0?`confirm`:`params`))},[i,e?.name,m,f.length,E]),(0,Q.useEffect)(()=>{if(h!==`confirm`||typeof r.findOne!=`function`)return;let e=!1;return(async()=>{let t={};for(let e of f){let n=Cd(e);if(!Sd(e)||!n)continue;let i=_[e.name],a=(Array.isArray(i)?i:i==null||i===``?[]:[i]).map(String);for(let i of a)if(!y[e.name]?.[i])try{let a=await r.findOne(n,i);if(!a)continue;let o=typeof e.labelField==`string`?e.labelField:void 0,s=(o?a[o]:void 0)??a.name??a.full_name??a.email;s!=null&&((t[e.name]??={})[i]=String(s))}catch{}}!e&&Object.keys(t).length>0&&b(e=>{let n={...e};for(let[e,r]of Object.entries(t))n[e]={...n[e],...r};return n})})(),()=>{e=!0}},[h]);let ee=(0,Q.useMemo)(()=>{for(let e of f)if(e.required){let t=_[e.name];if(t==null||t===``||Array.isArray(t)&&t.length===0)return!1}return!0},[f,_]),te=(0,Q.useCallback)((e,t)=>{if(t==null||t===``||Array.isArray(t)&&t.length===0)return`—`;if(typeof t==`boolean`)return t?d(`grid.yes`,{defaultValue:`Yes`}):d(`grid.no`,{defaultValue:`No`});let n=e&&Sd(e)?Object.entries(y[e.name]??{}).map(([e,t])=>({value:e,label:t})):(e?.options??[]).map(e=>({value:String(e.value),label:String(e.label)})),r=e=>n.find(t=>t.value===String(e))?.label??String(e);return Array.isArray(t)?t.map(r).join(`, `):r(t)},[d,y]),re=e?.maxRecords??1/0,F=t.length>re,L=t.length===0,ie=(0,Q.useCallback)(async()=>{e&&(g(`running`),await x(e,t,_),g(`result`))},[e,t,_,x]),z=(0,Q.useCallback)(()=>{if(!T?.errors?.length)return;let t=[`record_id,error_message`,...T.errors.map(e=>`${e.id},"${e.error.replace(/"/g,`""`)}"`)].join(`
|
|
5
|
+
`),n=new Blob([t],{type:`text/csv;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`bulk_errors_${e?.name??`action`}_${Date.now()}.csv`,i.click(),URL.revokeObjectURL(r)},[T,e?.name]),ae=!!e&&e.operation===`update`&&!!T&&T.succeeded>0&&j===null,oe=(0,Q.useCallback)(async()=>{A(!0);try{await S()&&M(Date.now())}finally{A(!1)}},[S]),B=(0,Q.useCallback)(async e=>{O(e);try{await C(e)}finally{O(null)}},[C]);if(!e)return null;let se=e.label??e.name,ce=t.slice(0,5),le=Math.max(0,t.length-ce.length);return(0,$.jsx)(et,{open:i,onOpenChange:e=>{e||a(T)},children:(0,$.jsxs)(ue,{className:`max-w-md`,onPointerDownOutside:e=>{N.current&&e.preventDefault()},onInteractOutside:e=>{N.current&&e.preventDefault()},children:[(0,$.jsxs)(P,{children:[(0,$.jsxs)(R,{className:`flex items-center gap-2`,children:[h===`running`&&(0,$.jsx)(Ti,{className:`h-4 w-4 animate-spin`}),se]}),h===`confirm`&&(0,$.jsx)(fe,{children:e.confirmText??d(`grid.bulk.confirmDefault`,{count:t.length,defaultValue:`This will apply to ${t.length} record(s).`})})]}),h===`params`&&(0,$.jsx)(`div`,{className:`space-y-3`,children:f.map(e=>(0,$.jsx)(Od,{param:e,multiple:p(e),value:_[e.name],values:_,dataSource:r,onChange:t=>v(n=>({...n,[e.name]:t}))},e.name))}),h===`confirm`&&(0,$.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[F&&(0,$.jsxs)(`div`,{className:`rounded-md bg-destructive/10 text-destructive px-3 py-2 flex items-start gap-2`,children:[(0,$.jsx)(Xi,{className:`h-4 w-4 mt-0.5 shrink-0`}),(0,$.jsx)(`div`,{children:d(`grid.bulk.overLimit`,{count:t.length,limit:re,defaultValue:`Selection (${t.length}) exceeds the action limit (${re}). Reduce the selection to proceed.`})})]}),(0,$.jsx)(`div`,{className:`text-muted-foreground`,children:d(`grid.bulk.affectedRecords`,{count:t.length,defaultValue:`Affected records (${t.length}):`})}),u>0&&(0,$.jsx)(`div`,{className:`text-muted-foreground text-xs`,"data-testid":`bulk-skipped-notice`,children:d(`grid.bulk.skippedIneligible`,{count:u,defaultValue:`${u} selected record(s) are not eligible for this action and will be skipped.`})}),(0,$.jsx)(I,{className:`max-h-32 rounded border bg-muted/30 p-2`,children:(0,$.jsxs)(`ul`,{className:`text-xs space-y-1`,children:[ce.map((e,t)=>(0,$.jsxs)(`li`,{className:`break-words`,children:[`• `,String(e[o]??e.id??d(`grid.bulk.rowFallback`,{index:t+1,defaultValue:`Row ${t+1}`}))]},String(e.id??t))),le>0&&(0,$.jsx)(`li`,{className:`text-muted-foreground`,children:d(`grid.bulk.andMore`,{count:le,defaultValue:`… and ${le} more`})})]})}),Object.keys(_).length>0&&(0,$.jsx)(`div`,{className:`rounded border bg-muted/30 p-2 text-xs space-y-0.5`,children:Object.entries(_).map(([e,t])=>{let n=f.find(t=>t.name===e);return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[n?.label??e,`:`]}),` `,te(n,t)]},e)})})]}),h===`running`&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(ne,{value:w.total?(w.done+w.failed)/w.total*100:0}),(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center`,children:[d(`grid.bulk.processed`,{count:w.done+w.failed,total:w.total,defaultValue:`${w.done+w.failed} / ${w.total} processed`}),w.failed>0&&d(`grid.bulk.processedFailed`,{count:w.failed,defaultValue:` · ${w.failed} failed`})]})]}),h===`result`&&T&&(0,$.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T.failed===0?(0,$.jsx)(ni,{className:`h-5 w-5 text-emerald-500`}):(0,$.jsx)(Xi,{className:`h-5 w-5 text-amber-500`}),(0,$.jsxs)(`span`,{children:[j===null?``:d(`grid.bulk.undonePrefix`,{defaultValue:`Undone — `}),d(`grid.bulk.succeeded`,{count:T.succeeded,total:T.total,defaultValue:`Succeeded ${T.succeeded} / ${T.total}`}),T.failed>0&&d(`grid.bulk.resultFailed`,{count:T.failed,defaultValue:` · Failed ${T.failed}`})]})]}),T.errors.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{className:`max-h-48 rounded border bg-destructive/5 p-2`,"data-testid":`bulk-error-inspector`,children:(0,$.jsx)(`ul`,{className:`text-xs space-y-1.5`,children:T.errors.map(t=>(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,"data-testid":`bulk-error-row-${t.id}`,children:[(0,$.jsx)(ii,{className:`h-3 w-3 mt-0.5 shrink-0 text-destructive`}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`break-words`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[t.id,`:`]}),` `,t.error]})}),(e.operation!==`custom`||!!e.actionDef)&&e.execution!==`aggregate`&&(0,$.jsx)(G,{variant:`ghost`,size:`sm`,className:`h-5 px-1.5 text-[10px] shrink-0`,onClick:()=>B(t.id),disabled:D===t.id,"data-testid":`bulk-error-retry-${t.id}`,children:D===t.id?`…`:d(`grid.bulk.retry`,{defaultValue:`Retry`})})]},t.id))})}),(0,$.jsx)(G,{variant:`outline`,size:`sm`,onClick:z,children:d(`grid.bulk.downloadErrorCsv`,{defaultValue:`Download error CSV`})})]})]}),(0,$.jsxs)(he,{children:[h===`params`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{variant:`ghost`,onClick:()=>a(),children:d(`grid.bulk.cancel`,{defaultValue:`Cancel`})}),(0,$.jsx)(G,{onClick:()=>g(`confirm`),disabled:!ee,children:d(`grid.bulk.next`,{defaultValue:`Next`})})]}),h===`confirm`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{variant:`ghost`,onClick:()=>f.length?g(`params`):a(),children:f.length?d(`grid.bulk.back`,{defaultValue:`Back`}):d(`grid.bulk.cancel`,{defaultValue:`Cancel`})}),(0,$.jsx)(G,{variant:e.variant===`danger`?`destructive`:`default`,onClick:ie,disabled:F||L,children:e.confirmLabel??d(`grid.bulk.run`,{defaultValue:`Run`})})]}),h===`running`&&(0,$.jsx)(G,{variant:`ghost`,disabled:!0,children:d(`grid.bulk.running`,{defaultValue:`Running…`})}),h===`result`&&(0,$.jsxs)($.Fragment,{children:[ae&&(0,$.jsx)(G,{variant:`outline`,onClick:oe,disabled:k,"data-testid":`bulk-undo-button`,children:k?d(`grid.bulk.undoing`,{defaultValue:`Undoing…`}):d(`grid.bulk.undo`,{defaultValue:`Undo`})}),(0,$.jsx)(G,{onClick:()=>a(T),children:d(`grid.bulk.done`,{defaultValue:`Done`})})]})]})]})})};function Dd(e){return Gn.has(e)||an.has(e)}var Od=({param:e,multiple:t,value:n,onChange:r,dataSource:i,values:a})=>{let o=`bulk-param-${e.name}`,s=(0,Q.useMemo)(()=>wd(e,t),[e,t]),c=(0,Q.useMemo)(()=>Ue(s.type),[s.type]),l=Td(s)?{dataSource:i}:{},u=Dd(s.type)?{dependentValues:a}:{};return(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(S,{htmlFor:o,className:`text-xs`,children:[e.label??e.name,e.required&&(0,$.jsx)(`span`,{className:`text-destructive ml-0.5`,"aria-hidden":`true`,children:`*`})]})}),(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-muted`,"aria-hidden":`true`}),children:(0,$.jsx)(c,{id:o,value:n??null,onChange:r,field:s,"aria-required":e.required||void 0,...l,...u})}),e.help&&(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.help})]})};b();function kd(e,t){return{authored:e,currentUserId:t.currentUserId,currentOrgId:t.currentOrgId,recordId:t.recordId,onUnresolved:t.onUnresolved,resolved:On(e,t)}}var Ad=12;function jd(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Md(e,t,n=0){if(Object.is(e,t))return!0;if(n>=Ad)return!1;if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime();if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>Md(e,t[r],n+1));if(jd(e)&&jd(t)){let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&Md(e[r],t[r],n+1))}return!1}function Nd(e,t){let[n,r]=(0,Q.useState)(()=>kd(e,t));if(n.currentUserId!==t.currentUserId||n.currentOrgId!==t.currentOrgId||n.recordId!==t.recordId||n.onUnresolved!==t.onUnresolved||!Md(n.authored,e)){let n=kd(e,t);return r(n),n.resolved}return n.resolved}function Pd(e){let t=rr(e);if(t)return t.map(e=>`${e.field} ${e.order}`).join(`, `)}function Fd(e){let t=Array.isArray(e)?e:[],n=[];for(let e of t)if(e&&typeof e==`object`&&typeof e.field==`string`){let{field:t,order:r}=e;n.push({field:t,order:String(r).toLowerCase()===`desc`?`desc`:`asc`})}return n}var Id=`text-primary font-medium underline-offset-4 hover:underline cursor-pointer truncate block max-w-full`,Ld=Id.replace(`truncate`,`whitespace-normal break-words`);function Rd(e){let t=e,n=t?.id??t?._id;return typeof n==`string`||typeof n==`number`?n:void 0}var zd=({testId:e,onActivate:t,objectName:n,recordId:r,wrap:i,children:a})=>{let o=or(),s=i?Ld:Id,c=n&&r!=null&&r!==``&&o?.recordHref?o.recordHref(n,r):null;return c?(0,$.jsx)(`a`,{href:c,"data-testid":e,className:s,onClick:e=>{e.stopPropagation(),!(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)&&(e.preventDefault(),t())},onKeyDown:e=>{e.key===` `&&(e.preventDefault(),e.stopPropagation(),t())},children:a}):(0,$.jsx)(`span`,{role:`link`,tabIndex:0,"data-testid":e,className:s,onClick:e=>{e.stopPropagation(),t()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())},children:a})},Bd=jr({"grid.actions":`Actions`,"grid.edit":`Edit`,"grid.delete":`Delete`,"grid.export":`Export`,"grid.exportAs":`Export as {{format}}`,"grid.loading":`Loading grid…`,"grid.errorLoading":`Error loading grid`,"view.malformedFilter":`This view’s filter is malformed, so no records are shown: the {{subject}} condition cannot be applied.`,"grid.pullToRefresh":`Pull to refresh`,"grid.refreshing":`Refreshing…`,"grid.openRecord":`Open record`,"grid.empty":`Empty`,"grid.yes":`Yes`,"grid.no":`No`,"grid.systemFields":`System`,"grid.grouping.needsHeaderQuery":`This view is grouped, but its data source does not implement queryGroupHeaders, so the groups cannot be counted. Remove the grouping to show the records.`,"grid.grouping.needsWholeRows":`Grouping needs every record, but this grid was handed one page of them, so the groups cannot be counted. Hand in every record, or let the grid fetch them from a data source that implements queryGroupHeaders.`,"table.rowsPerPage":`Rows per page`,"table.pageInfo":`Page {{current}} of {{total}}`,"table.noResults":`No results found`,"detail.recordDetail":`Record Detail`,"detail.recordDetailWithLabel":`{{label}} Detail`},`grid.actions`);function Vd(e){if(e!=null)return typeof e==`string`?e:void 0}function Hd(e){return kr(e,`view-data`)}function Ud(e){return e?JSON.stringify(Object.keys(e).sort().map(t=>[t,e[t]??null])):null}function Wd(e){if(e&&e.length!==0)return typeof e[0]==`object`&&e[0],e}function Gd(e){return typeof e!=`string`||!Object.prototype.hasOwnProperty.call(tn,e)?`compact`:e}function Kd(){let e=_.parse({}).pageSize;if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(`[ObjectUI] ObjectGrid: @objectstack/spec no longer declares a positive default for pagination.pageSize (read ${String(e)}); the grid has no display page size to fall back to.`);return e}var qd=Kd(),Jd=50,Yd=`multiple`;function Xd(e){return e.pagination?.pageSize??e.pageSize}function Zd(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function Qd(e,t){let n=Xd(e);return Zd(n)?n:t}function $d(e,t){let n=Xd(e);return n==null||Zd(n)?null:`[ObjectUI] ObjectGrid pagination: ${[typeof t.blockType==`string`?t.blockType:`object-grid`,typeof t.objectName==`string`?t.objectName:void 0].filter(Boolean).join(` on `)} declared pageSize: ${String(n)}, which is not a positive integer. A page size must be a positive integer (the spec refuses zero and negative values), so it was ignored and this grid fell back to its default page size.`}var ef=JSON.stringify({refused:[],warned:[]}),tf=({schema:e,dataSource:t,onEdit:n,onDelete:r,rowOperations:i,onBulkDelete:a,onRowSelect:o,onRowClick:c,onNavigate:l,onCellChange:u,onRowSave:d,onBatchSave:f,onAddRecord:p,data:m,manualPagination:g,rowCount:_,page:v,pageSize:b,onPageChange:x,onPageSizeChange:S,sort:C,onSortChange:w,search:T,onSearchChange:E,findParams:D,onColumnStateChange:O,objectFields:j})=>{let[M,N]=(0,Q.useState)([]),[ee,P]=(0,Q.useState)(!0),[te,ne]=(0,Q.useState)(null),{currency:re}=Mr(),F=Ir(),{t:I}=Bd(),{fieldLabel:L,translateOptions:ie,actionLabel:R}=Fr(),[B,se]=(0,Q.useState)(null),[ce,le]=(0,Q.useState)(!1),[ue,de]=(0,Q.useState)(0),[fe,me]=(0,Q.useState)(!1),[V,he]=(0,Q.useState)(!1),[ge,_e]=(0,Q.useState)(null),[ve,ye]=(0,Q.useState)(Gd(e.rowHeight)),[be,H]=(0,Q.useState)([]),[U,Se]=(0,Q.useState)(!1),[Ce,we]=(0,Q.useState)(0),[Te,Ee]=(0,Q.useState)(void 0),[De,Oe]=(0,Q.useState)(null),[ke,je]=(0,Q.useState)([]),[Ne,Pe]=(0,Q.useState)(0),W=Q.useRef(null),[Fe,Le]=(0,Q.useState)(1),[Re,ze]=(0,Q.useState)(Qd(e,qd));Q.useEffect(()=>{if(!e.rowHeight)return;let t=Gd(e.rowHeight);t!==ve&&ye(t)},[e.rowHeight]);let Be=Q.useMemo(()=>e.id?`grid-columns-${e.objectName}-${e.id}`:`grid-columns-${e.objectName}`,[e.objectName,e.id]),[Ve,Ue]=(0,Q.useState)(()=>{let t=e.columnState;if(t&&typeof t==`object`)return t;try{let e=localStorage.getItem(Be);return e?JSON.parse(e):{}}catch{return{}}}),We=Q.useMemo(()=>JSON.stringify(e.columnState??null),[e.columnState]);Q.useEffect(()=>{let t=e.columnState;t&&typeof t==`object`&&Ue(t)},[We]);let Ge=(0,Q.useCallback)(e=>{Ue(e);try{localStorage.setItem(Be,JSON.stringify(e))}catch(e){console.warn(`Failed to persist column state:`,e)}if(typeof O==`function`)try{O(e)}catch(e){console.warn(`onColumnStateChange threw:`,e)}},[Be,O]),{ref:Ke,isRefreshing:qe,pullDistance:Je}=ga({onRefresh:(0,Q.useCallback)(async()=>{de(e=>e+1)},[]),enabled:!!t&&!!e.objectName});(0,Q.useEffect)(()=>{let e=()=>le(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let Ye=zt(e.bind),Ze=Hd(e),q=Q.useMemo(()=>m&&Array.isArray(m)?{provider:`value`,items:m}:Ye&&Array.isArray(Ye)?{provider:`value`,items:Ye}:Ze,[JSON.stringify(Ze),Ye,m]),$e=q?.provider===`value`,et=g===!0&&typeof _==`number`&&typeof x==`function`,J=Ut(e,q)??e.objectName,Y=B?.fields??j??void 0,it=!!J&&typeof t?.getObjectSchema==`function`&&!Y,X=He(),{getObjectApiOperations:at}=X,ot=J?at(J):void 0,st=J?X.can(J,`update`):void 0,lt=J?X.can(J,`delete`):void 0,ut=J?X.can(J,`create`):void 0,dt=br(B,ot)&&(!J||X.can(J,`update`)),ht=(e.editable??!1)&&dt,_t=(`operations`in e?e.operations:void 0)??{update:!!n,delete:!!r},vt=Array.isArray(e.rowActions),yt=Array.isArray(e.rowActions)?e.rowActions:[],bt=Array.isArray(e.rowActionDefs)?e.rowActionDefs:[],xt=yt.includes(`edit`),St=yt.includes(`delete`),{defs:wt,unresolved:Tt}=Cu({rowActions:yt.filter(e=>e!==`edit`&&e!==`delete`),rowActionDefs:bt,objectActions:B?.actions}),{canEdit:Et,canDelete:Dt,objectCanDelete:Ot,editPredicates:kt,deletePredicates:jt,objectDeletePredicates:Mt}=pu({operationsUpdate:_t?.update,operationsDelete:_t?.delete,wantEditAction:xt,wantDeleteAction:St,rowActionsDeclared:vt,hasOnEdit:!!n,hasOnDelete:!!r,managedBy:B?.managedBy,userActions:B?.userActions,effectiveApiOperations:ot,permissionUpdate:st,permissionDelete:lt}),Nt=Su({objectName:J,recordIds:(0,Q.useMemo)(()=>Array.from(new Set(M.map(Rd).filter(e=>e!=null).map(e=>String(e)))),[M]),update:Et,delete:Dt}),Pt=e.fields,Ft=e.columns,It=(0,Q.useMemo)(()=>JSON.stringify(ln(e.grouping)),[e.grouping]),Lt=e.conditionalFormatting,Rt=e.rowActionDefs,Bt=e.bulkActionDefs,Wt=(0,Q.useMemo)(()=>JSON.stringify(on(Nn({conditionalFormatting:Lt,rowActionDefs:Rt,bulkActionDefs:Bt}))),[Lt,Rt,Bt]),Gt=gr(),Kt=Nd({filter:e.filter,defaultFilters:e.defaultFilters},Gt),qt=Kt.filter,Jt=Kt.defaultFilters,Xt=(0,Q.useMemo)(()=>Cr(qt),[qt]),Qt=Xt.ok?void 0:Xt.refusal,$t=Xt.ok?Xt.node:void 0,tn=e.sort,rn=e.pagination,an=e.pageSize,[sn,cn]=(0,Q.useState)(1),[un,dn]=(0,Q.useState)(Qd(e,qd)),[fn,pn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{pn(null)},[JSON.stringify(e.sort??null)]);let[mn,gn]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{gn(``)},[J]);let _n=et||T!==void 0,vn=_n?T??``:mn,yn=vn.trim()&&e.searchableFields&&e.searchableFields.length>0?JSON.stringify(e.searchableFields):``;(0,Q.useEffect)(()=>{$e&&q?.provider===`value`&&(N(e=>{let t=q.items;return JSON.stringify(e)===JSON.stringify(t)?e:t}),P(!1))},[$e,q]),(0,Q.useEffect)(()=>{if(!$e||!J||!t)return;let e=!1;return(async()=>{try{if(typeof t.getObjectSchema!=`function`)return;let n=await t.getObjectSchema(J);e||se(n)}catch(e){console.warn(`[ObjectGrid] Failed to fetch objectSchema for inline data (objectName: ${J}):`,e)}})(),()=>{e=!0}},[$e,J,t]);let Z=e.grouping?.fields,xn=Q.useMemo(()=>{let t=Wd(e.columns)??[],n=e=>t.find(t=>typeof t==`object`&&!!t&&t.field===e)?.type,r=Ll(Z).map(e=>e.field).filter(e=>oa(n(e),Y?.[e]?.type,it));return JSON.stringify({refused:r,warned:r.filter(e=>oa(n(e),Y?.[e]?.type,!1))})},[Z,e.columns,Y,it]),Sn=Q.useMemo(()=>{let{refused:e}=JSON.parse(xn);return Ll(Z).filter(t=>!e.includes(t.field))},[Z,xn]),wn=xn===ef;(0,Q.useEffect)(()=>{let{warned:t}=JSON.parse(xn);t.length!==0&&console.warn(`[ObjectUI] ObjectGrid grouping: ${e.objectName??`object-grid`} groups by the masked field(s) ${t.join(`, `)}. A masked field cannot be a grouping key: its group labels would show the raw value, and its groups would show which records share it. The entry was ignored.`)},[xn,e.objectName]);let Tn=Q.useMemo(()=>JSON.parse(xn).warned,[xn]),En=e=>!X?.isLoaded||!J||X.checkField(J,e,`read`),Dn=!$e&&!!J&&typeof t?.queryGroupHeaders==`function`&&Ll(Z).some(e=>!Tn.includes(e.field)&&En(e.field)),On=!$e&&!!J&&!!t&&typeof t.queryGroupHeaders!=`function`&&Ll(Z).some(e=>!Tn.includes(e.field)),kn=$e?q?.items:void 0,In=et&&Array.isArray(kn)&&_>kn.length&&Ll(Z).some(e=>!Tn.includes(e.field)),Ln=!Dn&&!On&&Ll(Z).some(e=>!Tn.includes(e.field))?Qd(e,Jd):un,[Bn,Vn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Dn||Vn(null)},[Dn]);let Hn=Rn($e?void 0:J);(0,Q.useEffect)(()=>{if($e||Qt)return;let n=!1;return(async()=>{P(!0),ne(null);try{let r=null,i=Wd(Ft)||Pt;if(J&&t){if(typeof t.getObjectSchema==`function`){let e=await t.getObjectSchema(J);if(n)return;r=e}else r={name:J,fields:{}}}else if(i&&J)r={name:J,fields:{}};else if(J)throw Error(`DataSource required`);else throw Error(`Object name required for data fetching`);if(n||se(r),On)return;if(t&&J){let i=ln(e.grouping),a={$select:(()=>{let t=e=>e.map(e=>bn(e)).includes(`id`)?e:[`id`,...e],n=e=>{if(!X?.isLoaded||!J)return!0;let t=bn(e);return!t||!Object.prototype.hasOwnProperty.call(r?.fields??{},t)||X.checkField(J,t,`read`)},a=r?.fields,o=a?on(Nn({conditionalFormatting:e.conditionalFormatting,rowActionDefs:e.rowActionDefs,bulkActionDefs:e.bulkActionDefs,objectActions:r?.actions,userActions:r?.userActions})).filter(e=>Fn(e,a)).filter(e=>n(e)):[],s=a?i.filter(e=>Fn(e,a)).filter(e=>n(e)):[],c=[...o,...s],l=e=>{if(c.length===0)return e;let t=new Set(e.map(e=>bn(e))),n=new Set,r=c.filter(e=>!t.has(e)&&!n.has(e)&&(n.add(e),!0));return r.length>0?[...e,...r]:e},u=e=>e.filter(n).map(e=>bn(e)).filter(e=>!!e);if(Pt)return l(t(u(Pt)));if(Ft&&Array.isArray(Ft))return l(t(u(Ft)))})(),$top:Ln,$skip:(sn-1)*Ln};if($t!==void 0)a.$filter=$t;else{let e=pr(Jt);e!==void 0&&(a.$filter=e)}if(fn&&fn.length>0)a.$orderby=fn.map(e=>({field:e.field,order:e.order}));else if(tn){if(typeof tn==`string`)hn(tn);else if(Array.isArray(tn)){let e=Pd(tn);e!==void 0&&(a.$orderby=e)}}let o=vn.trim();o&&(a.$search=o,e.searchableFields&&e.searchableFields.length>0&&(a.$searchFields=e.searchableFields));let s=e=>!X?.isLoaded||!J||X.checkField(J,e,`read`),c=Ft??Pt,l=Pn(r?.fields,c?[...c,...i]:void 0).filter(s);if(l.length>0&&(a.$expand=l),Dn){let{$top:e,$skip:t,...n}=a;Vn(n),W.current={...n},Se(!1);return}let u=await t.find(J,a);if(n)return;N(u.data||[]);let d=u.total;Ee(typeof d==`number`?d:void 0),W.current={...a},Se(!1)}}catch(e){n||ne(e)}finally{n||P(!1)}})(),()=>{n=!0}},[J,Pt,Ft,$t,Qt,Jt,tn,fn,vn,rn,an,sn,Ln,t,$e,q,ue,X.isLoaded,It,Wt,yn,Hn,Dn,On]);let Wn=Q.useMemo(()=>Ud(D),[D]);Q.useEffect(()=>{Se(!1)},[Wn]),Q.useEffect(()=>{cn(1)},[J,$t,tn,fn,vn]);let Gn=wr({navigation:e.navigation,objectName:e.objectName,onNavigate:l??e.onNavigate,onRowClick:c}),{anchorRef:Kn,anchorCaptureProps:qn}=k(),{execute:Jn,updateContext:Yn}=Sr();Q.useEffect(()=>(Yn({selectedRecords:be}),()=>{Yn({selectedRecords:[]})}),[be,Yn]);let Qn=jl(e.rowColor),$n=Zt(),tr=(0,Q.useCallback)(t=>{let n=e.conditionalFormatting;if(!n||n.length===0)return;let r=zn(t,n,$n,B?.fields);return Object.keys(r).length>0?r:void 0},[e.conditionalFormatting,$n,B]),nr=Q.useMemo(()=>{let t=Ll(e.grouping?.fields);if(!t.length)return;let n=new Map;for(let r of t){let t=r.field,i=Y?.[t],a=(Wd(e.columns)??[]).find(e=>typeof e==`object`&&!!e&&e.field===t)?.type||i?.type,o=i?.options,s=new Map;if(Array.isArray(o)&&o.length>0){let n=e.objectName?ie(e.objectName,t,o):o;for(let e of n)if(e&&e.value!==void 0&&e.value!==null){let t=e.label;s.set(String(e.value),String(t??e.value))}}n.set(t,{type:a||void 0,options:s.size>0?s:void 0})}return(e,t)=>{let r=n.get(e);if(r){if(r.options){let e=r.options.get(String(t));if(e!==void 0)return e}if(r.type===`boolean`||typeof t==`boolean`){if(t===!0||t===`true`)return I(`grid.yes`,{defaultValue:`Yes`});if(t===!1||t===`false`)return I(`grid.no`,{defaultValue:`No`})}}}},[e.grouping,e.columns,e.objectName,Y,ie,I]),rr=wn||!e.grouping?e.grouping:{...e.grouping,fields:Sn},ir=Dn?JSON.stringify(Ll(rr?.fields).filter(e=>En(e.field)).map(e=>[e.field,e.order??null,e.collapsed??null])):`[]`,ar=Q.useMemo(()=>JSON.parse(ir).map(([e,t,n])=>({field:e,...t?{order:t}:{},...n===null?{}:{collapsed:n}})),[ir]),or=JSON.stringify(Bn),sr=Q.useMemo(()=>{let e=JSON.parse(or)?.$filter;if(e==null)return{};try{let t=s(e);return t===void 0?{error:Error(`[ObjectGrid] The view filter could not be lowered for server-side grouping: ${JSON.stringify(e)}`)}:{where:t}}catch(e){return{error:e instanceof Error?e:Error(String(e))}}},[or]),cr=`${ue}:${Hn}`,lr=Yl({enabled:Dn&&!it&&Bn!==null&&!sr.error,dataSource:t,objectName:J,fields:ar,where:sr.where,...Jl(Bn),aggregations:e.aggregations,objectFields:Y,reloadKey:cr}),fr=lr.headers,mr=lr.keyLabels,hr=Q.useMemo(()=>Dn?{headers:fr??[],keyLabels:mr}:void 0,[Dn,fr,mr]),{groups:_r,isGrouped:vr,toggleGroup:yr}=Hl(Dn?e.grouping?{...e.grouping,fields:ar}:void 0:rr,M,e.aggregations,nr,hr),xr=Q.useMemo(()=>JSON.stringify(e.grouping??null),[e.grouping]);Q.useEffect(()=>{Le(1)},[xr,Re,ue]);let Tr=[];if(Dn){let e=Math.max(1,Math.ceil(_r.length/Re)),t=Math.min(Fe,e),n=e=>{e.collapsed||(e.subgroups.length===0?Tr.push({key:e.key,keyValues:e.keyValues}):e.subgroups.forEach(n))};_r.slice((t-1)*Re,t*Re).forEach(n)}let Er=Zl({enabled:Dn&&!!lr.headers,dataSource:t,objectName:J,fields:ar,where:sr.where,baseParams:Bn,pageSize:un,leaves:Tr,reloadKey:cr}),Dr=JSON.stringify(Tr.map(e=>e.key));(0,Q.useEffect)(()=>{if(!Dn)return;let e=JSON.parse(Dr);N(e.flatMap(e=>Er.pages[e]?.rows??[]))},[Dn,Dr,Er.pages]);let Or=Dn&&lr.headers?(lr.headers[0]??[]).reduce((e,t)=>e+(Number(t.count)||0),0):void 0;(0,Q.useEffect)(()=>{Or!==void 0&&Ee(Or)},[Or]);let{summaries:kr,hasSummary:Ar}=fu(Q.useMemo(()=>{let t=Wd(e.columns);if(t&&t.length>0&&typeof t[0]==`object`)return t},[e.columns]),M,B?.fields),jr=e.type,Pr=e.label??e.title;(0,Q.useEffect)(()=>{let t=ed(e.columns,{blockType:jr,objectName:e.objectName,label:Pr});t&&console.warn(t)},[e.columns,jr,e.objectName,Pr]);let Lr=e.bulkActionDefs;(0,Q.useEffect)(()=>{let t=Vu(Lr,{blockType:jr,objectName:e.objectName,label:Pr});t&&console.warn(t)},[Lr,jr,e.objectName,Pr]);let Rr=e.pagination,zr=e.pageSize;(0,Q.useEffect)(()=>{let t=$d({pagination:Rr,pageSize:zr},{blockType:jr,objectName:e.objectName});t&&console.warn(t)},[Rr,zr,jr,e.objectName]);let Br=(0,Q.useCallback)(()=>{let t=e=>e&&{text:(0,$.jsx)(Zi,{className:`h-3.5 w-3.5`}),number:(0,$.jsx)(bi,{className:`h-3.5 w-3.5`}),currency:(0,$.jsx)(bi,{className:`h-3.5 w-3.5`}),percent:(0,$.jsx)(bi,{className:`h-3.5 w-3.5`}),date:(0,$.jsx)(Jr,{className:`h-3.5 w-3.5`}),datetime:(0,$.jsx)(si,{className:`h-3.5 w-3.5`}),boolean:(0,$.jsx)(Ui,{className:`h-3.5 w-3.5`}),user:(0,$.jsx)(ea,{className:`h-3.5 w-3.5`}),select:(0,$.jsx)(qi,{className:`h-3.5 w-3.5`})}[e]||(0,$.jsx)(Zi,{className:`h-3.5 w-3.5`}),n=e=>{if(e.type)return e.type;let t=e.field.toLowerCase();if([`completed`,`is_completed`,`done`,`active`,`enabled`,`archived`].some(e=>t===e||t===`is_${e}`))return`boolean`;if([`created_time`,`modified_time`,`updated_time`,`created_at`,`updated_at`,`modified_at`,`last_login`,`logged_at`].some(e=>t===e||t.endsWith(`_${e}`)))return`datetime`;if([`date`,`due`,`created`,`updated`,`deadline`,`start`,`end`,`expires`].some(e=>t.includes(e))){if(M.length>0){let t=M.find(t=>t[e.field]!=null)?.[e.field];if(typeof t==`string`&&!isNaN(Date.parse(t)))return`date`}return`date`}if([`probability`,`percent`,`percentage`,`completion`,`progress`,`rate`].some(e=>t.includes(e))&&M.length>0&&typeof M.find(t=>t[e.field]!=null)?.[e.field]==`number`)return`percent`;if([`status`,`priority`,`category`,`stage`,`type`,`severity`,`level`].some(e=>t.includes(e))&&M.length>0){let t=new Set(M.map(t=>t[e.field]).filter(Boolean));if(t.size>0&&t.size<=10)return`select`}if([`assignee`,`owner`,`author`,`reporter`,`creator`,`user`].some(e=>t.includes(e)))return`user`;if([`amount`,`price`,`total`,`revenue`,`cost`,`budget`,`salary`].some(e=>t.includes(e))&&M.length>0&&typeof M.find(t=>t[e.field]!=null)?.[e.field]==`number`)return`currency`;if(M.length>0){let t=M.find(t=>t[e.field]!=null)?.[e.field];if(typeof t==`string`&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(t))return`datetime`}return null},r=Wd(Ft);if(r){let i=t=>{if(!X?.isLoaded||!e.objectName)return!0;let n=bn(t);return!n||!Object.prototype.hasOwnProperty.call(Y??{},n)||X.checkField(e.objectName,n,`read`)};return r.length>0&&typeof r[0]==`object`&&r[0]!==null?r.filter(e=>Ju(e)).filter(e=>i(e)).map((r,i)=>{let a=Vd(r.label)||Vd(Y?.[r.field]?.label)||r.field.charAt(0).toUpperCase()+r.field.slice(1).replace(/_/g,` `),o=e.objectName?L(e.objectName,r.field,a):a,s,c=Y?.[r.field],l=sa(r.type,it),u=l?null:r.type||c?.type||n({field:r.field})||null,d=c?.format,{rendererType:f,Renderer:p}=ra({type:u,format:d}),m=l?gt:f?p:null,h={name:r.field,type:f||`text`};c&&(c.label&&(h.label=c.label),c.currency&&(h.currency=c.currency),c.currencyConfig&&(h.currencyConfig=c.currencyConfig),c.precision!==void 0&&(h.precision=c.precision),c.scale!==void 0&&(h.scale=c.scale),c.useGrouping!==void 0&&(h.useGrouping=c.useGrouping),c.max!==void 0&&(h.max=c.max),c.format&&(h.format=c.format),c.options&&(h.options=ie(e.objectName,r.field,c.options))),Nu(h,c),f===`select`&&!h.options&&(h.options=Array.from(new Set(M.map(e=>e[r.field]).filter(Boolean))).map(e=>({value:e,label:Cn(String(e))})));let g=c?.appearance;g!=null&&(h.appearance=g);let _=i===0&&!r.link&&!r.action,v=r.link||_;s=r.link&&r.action||_&&r.action||v?(t,n)=>{let i=m?(0,$.jsx)(m,{value:t,field:h}):t!=null&&t!==``?String(t):(0,$.jsx)(tt,{});return(0,$.jsx)(zd,{testId:_?`primary-field-link`:`link-cell`,onActivate:()=>Gn.handleClick(n),objectName:e.objectName,recordId:Rd(n),wrap:r.wrap,children:i})}:r.action?(e,t)=>(0,$.jsx)(G,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,"data-testid":`action-cell`,onClick:n=>{n.stopPropagation(),Jn({type:r.action,params:{record:t,field:r.field,value:e}})},children:rd(r.action)}):m?e=>(0,$.jsx)(m,{value:e,field:h}):e=>e!=null&&e!==``?(0,$.jsx)(`span`,{children:String(e)}):(0,$.jsx)(tt,{});let y=r.prefix;if(y?.field){let e=s,t=y.type===`badge`?ia(aa):null;s=(n,r)=>{let i=r[y.field],a=i!=null&&i!==``?t?(0,$.jsx)(t,{value:i,field:{name:y.field,type:aa}}):(0,$.jsx)(`span`,{className:`text-muted-foreground text-xs mr-1.5`,children:String(i)}):null;return(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[a,e(n,r)]})}}let b=[`number`,`currency`,`percent`],x=f||r.type,S=r.align||(x&&b.includes(x)?`right`:void 0),C=i===0;return{header:o,accessorKey:r.field,...u&&{type:u},...e.showColumnTypeIcons&&{headerIcon:t(f)},...!C&&{className:`hidden sm:table-cell`},...r.width&&{width:r.width},...S&&{align:S},sortable:r.sortable!==!1,...r.resizable!==void 0&&{resizable:r.resizable},...s&&{cell:s},...r.pinned&&{pinned:r.pinned},...r.wrap!==void 0&&{wrap:r.wrap}}}):r.filter(e=>typeof e==`string`&&e.trim().length>0).filter(e=>i(e)).map((r,i)=>{let a=Y?.[r],o=sa(void 0,it),s=a?.label||r.charAt(0).toUpperCase()+r.slice(1).replace(/_/g,` `),c=e.objectName?L(e.objectName,r,s):s,{declaredType:l,rendererType:u,Renderer:d}=ra({type:o?null:a?.type||n({field:r}),format:a?.format}),f=o?gt:u?d:null,p={name:r,type:u||`text`};a&&(a.label&&(p.label=a.label),a.currency&&(p.currency=a.currency),a.currencyConfig&&(p.currencyConfig=a.currencyConfig),a.precision!==void 0&&(p.precision=a.precision),a.scale!==void 0&&(p.scale=a.scale),a.useGrouping!==void 0&&(p.useGrouping=a.useGrouping),a.max!==void 0&&(p.max=a.max),a.format&&(p.format=a.format),a.options&&(p.options=ie(e.objectName,r,a.options))),Nu(p,a),u===`select`&&!p.options&&(p.options=Array.from(new Set(M.map(e=>e[r]).filter(Boolean))).map(e=>({value:e,label:Cn(String(e))}))),(u===`select`||u===`status`)&&a?.appearance!=null&&(p.appearance=a.appearance);let m=u&&[`number`,`currency`,`percent`].includes(u)?`right`:void 0,h=i===0,g;return h&&f?g=(t,n)=>{let r=(0,$.jsx)(f,{value:t,field:p});return(0,$.jsx)(zd,{testId:`primary-field-link`,onActivate:()=>Gn.handleClick(n),objectName:e.objectName,recordId:Rd(n),children:r})}:h?g=(t,n)=>(0,$.jsx)(zd,{testId:`primary-field-link`,onActivate:()=>Gn.handleClick(n),objectName:e.objectName,recordId:Rd(n),children:t!=null&&t!==``?String(t):(0,$.jsx)(tt,{})}):f&&(g=e=>(0,$.jsx)(f,{value:e,field:p})),{header:c,accessorKey:r,...l&&{type:l},...e.showColumnTypeIcons&&u&&{headerIcon:t(u)},...m&&{align:m},...g&&{cell:g},sortable:a?.sortable!==!1}})}if($e&&!(!Pt&&J&&B)){let r=q?.provider===`value`?q.items:[];if(r.length>0)return(Pt||Object.keys(r[0])).filter(t=>!X?.isLoaded||!e.objectName||!Object.prototype.hasOwnProperty.call(Y??{},t)||X.checkField(e.objectName,t,`read`)).map(r=>{let i=Y?.[r],a=sa(void 0,it),{declaredType:o,rendererType:s,Renderer:c}=ra({type:a?null:i?.type||n({field:r}),format:i?.format}),l=a?gt:s?c:null,u=i?.label||r.charAt(0).toUpperCase()+r.slice(1).replace(/_/g,` `),d={name:r,type:s||`text`};i&&(i.label&&(d.label=i.label),i.currency&&(d.currency=i.currency),i.currencyConfig&&(d.currencyConfig=i.currencyConfig),i.precision!==void 0&&(d.precision=i.precision),i.scale!==void 0&&(d.scale=i.scale),i.useGrouping!==void 0&&(d.useGrouping=i.useGrouping),i.max!==void 0&&(d.max=i.max),i.format&&(d.format=i.format),i.options&&(d.options=ie(e.objectName,r,i.options))),Nu(d,i),s===`select`&&!d.options&&(d.options=Array.from(new Set(M.map(e=>e[r]).filter(Boolean))).map(e=>({value:e,label:Cn(String(e))}))),(s===`select`||s===`status`)&&i?.appearance!=null&&(d.appearance=i.appearance);let f=s&&[`number`,`currency`,`percent`].includes(s)?`right`:void 0;return{header:u,accessorKey:r,...o&&{type:o},...e.showColumnTypeIcons&&s&&{headerIcon:t(s)},...f&&{align:f},...l&&{cell:e=>(0,$.jsx)(l,{value:e,field:d})},sortable:i?.sortable!==!1}})}if(!B)return[];let i=[],a=B?.highlightFields,o=Object.keys(B.fields||{}),s;if(Pt)s=Pt;else if(a?.length)s=nn(B,a.filter(e=>B.fields?.[e]));else{let e=o.filter(e=>{let t=B.fields?.[e];return!(!t||t.hidden||t.readonly&&Yt(e,t))});s=[...e.filter(e=>!Yt(e,B.fields?.[e])),...e.filter(e=>Yt(e,B.fields?.[e]))]}return s.forEach(t=>{let n=B.fields?.[t];if(!n||X?.isLoaded&&e.objectName&&!X.checkField(e.objectName,t,`read`))return;let{declaredType:r,rendererType:a,Renderer:o}=ra(n),s=[`number`,`currency`,`percent`],c=n.options?{...n,options:ie(e.objectName,t,n.options)}:n;i.push({header:e.objectName?L(e.objectName,t,n.label||t):n.label||t,accessorKey:t,...r&&{type:r},...!!a&&s.includes(a)&&{align:`right`},cell:e=>(0,$.jsx)(o,{value:e,field:c}),sortable:n.sortable!==!1})}),i},[B,Y,it,Pt,Ft,q,$e,J,Gn.handleClick,Jn,M,L,ie,e.objectName,X]),Vr=(0,Q.useMemo)(()=>{let n=e.exportOptions?.formats||[`csv`,`json`],r=typeof t?.exportDownload==`function`&&J&&!$e&&e.exportOptions?.streaming!==!1?[`csv`,`xlsx`,`json`]:[`csv`,`json`];return n.filter(e=>r.includes(e))},[e.exportOptions,t,J,$e]);(0,Q.useEffect)(()=>{let t=e.exportOptions?.formats;if(!t)return;let n=t.filter(e=>!Vr.includes(e));n.length>0&&console.warn(`[ObjectUI] ObjectGrid export: unsupported format(s) hidden from the menu: ${n.join(`, `)}`)},[e.exportOptions,Vr]);let Hr=(0,Q.useCallback)(n=>{if(e.operations?.export===!1||ot&&!ot.includes(`export`))return;let r=e.exportOptions,i=r?.maxRecords||0,a=r?.includeHeaders!==!1,o=t=>dr(t,{prefix:r?.fileNamePrefix,label:B?.label,objectName:J||e.objectName,viewLabel:y(e.label,F)||y(e.title,F)});if((n===`csv`||n===`xlsx`||n===`json`)&&typeof t?.exportDownload==`function`&&J&&!$e&&r?.streaming!==!1){let e=Br().filter(e=>e.accessorKey!==`_actions`).map(e=>e.accessorKey).filter(Boolean),r=Array.isArray($t)?$t:void 0,s=Array.isArray(tn)?tn.filter(e=>e&&e.field).map(e=>({field:e.field,direction:e.order??`asc`})):void 0;_e(null),he(!0),(async()=>{try{let c=await t.exportDownload(J,{format:n,fields:e.length?e:void 0,filter:r,sort:s,includeHeaders:a,limit:i>0?i:void 0}),l=URL.createObjectURL(c),u=document.createElement(`a`);u.href=l,u.download=o(n),u.rel=`noopener`,document.body.appendChild(u),u.click(),u.remove(),URL.revokeObjectURL(l),me(!1)}catch(e){console.error(`ObjectGrid export failed:`,e),_e(e instanceof Error?e.message:String(e))}finally{he(!1)}})();return}let s=i>0?M.slice(0,i):M,c=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)},l=e=>{let t=e==null?``:String(e);return t.includes(`,`)||t.includes(`"`)||t.includes(`
|
|
6
|
+
`)||t.includes(`\r`)?`"${t.replace(/"/g,`""`)}"`:t},u=new Map(Br().map(e=>[e.accessorKey,e.type])),d=e=>oa(u.get(e),Y?.[e]?.type,it);if(n===`csv`){let e=Br().filter(e=>e.accessorKey!==`_actions`&&!d(e.accessorKey)),t=e.map(e=>e.accessorKey),n=e.map(e=>e.header),r=[];a&&r.push(n.join(`,`)),s.forEach(e=>{r.push(t.map(t=>l(e[t])).join(`,`))}),c(new Blob([r.join(`
|
|
7
|
+
`)],{type:`text/csv;charset=utf-8;`}),o(`csv`))}else if(n===`json`){let e=s.map(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!d(e))));c(new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),o(`json`))}me(!1)},[M,e.exportOptions,e.operations?.export,ot,e.objectName,J,B,Y,it,Br,t,$e,$t,tn]),Ur=Qt??(te instanceof ur?te:void 0);if(Ur)return(0,$.jsxs)(`div`,{role:`alert`,className:`p-3 sm:p-4 border border-amber-300 bg-amber-50 rounded-md`,"data-testid":`grid-malformed-filter`,children:[(0,$.jsx)(`h3`,{className:`text-amber-800 font-semibold`,"data-testid":`grid-malformed-filter-subject`,children:I(`view.malformedFilter`,{subject:er(Ur)??``})}),(0,$.jsx)(`p`,{className:`text-amber-700 text-sm mt-1`,children:Ur.message})]});if(In)return(0,$.jsxs)(`div`,{role:`alert`,className:`p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md`,"data-testid":`grid-grouping-needs-whole-rows`,children:[(0,$.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:I(`grid.errorLoading`)}),(0,$.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:I(`grid.grouping.needsWholeRows`)})]});let Wr=te??(Dn?sr.error??lr.error??null:null);if(Wr)return(0,$.jsxs)(`div`,{className:`p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,$.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:I(`grid.errorLoading`)}),(0,$.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:Wr.message})]});let Gr=Dn&&!lr.headers;if(ee&&M.length===0||Gr)return ce?(0,$.jsx)(`div`,{className:`space-y-2 p-2`,children:[1,2,3].map(e=>(0,$.jsxs)(`div`,{className:`border rounded-lg p-3 bg-card animate-pulse`,children:[(0,$.jsx)(`div`,{className:`h-5 bg-muted rounded w-3/4 mb-3`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,$.jsx)(`div`,{className:`h-4 bg-muted rounded w-1/4`}),(0,$.jsx)(`div`,{className:`h-5 bg-muted rounded-full w-20`})]}),(0,$.jsx)(`div`,{className:`h-3 bg-muted rounded w-1/3`})]},e))}):(0,$.jsxs)(`div`,{className:`p-4 sm:p-8 text-center`,children:[(0,$.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-foreground`}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:I(`grid.loading`)})]});if(On)return(0,$.jsxs)(`div`,{role:`alert`,className:`p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md`,"data-testid":`grid-grouping-needs-header-query`,children:[(0,$.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:I(`grid.errorLoading`)}),(0,$.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:I(`grid.grouping.needsHeaderQuery`)})]});let Kr=[...Br().map(e=>{if(!e||e.accessorKey===`_actions`)return e;let t=Y?.[e.accessorKey];if(!t)return e;let n={...e};return n.type==null&&t.type&&(n.type=t.type),n.editable!==!1&&!da(t)&&(n.editable=!1),n}).map(e=>{if(!e)return e;let{type:t,...n}=e,r=oa(t,Y?.[e.accessorKey]?.type,it)?{...n,masked:!0}:n;if(t==null)return r;let i=Vt(t);return i===void 0?r:{...r,type:i}})];if(Ve.widths&&(Kr=Kr.map(e=>{let t=Ve.widths?.[e.accessorKey];return t?{...e,width:t}:e})),Ve.order&&Ve.order.length>0){let e=new Map(Ve.order.map((e,t)=>[e,t]));Kr.sort((t,n)=>(e.get(t.accessorKey)??1/0)-(e.get(n.accessorKey)??1/0))}let qr=!!(_t&&(_t.update||_t.delete)),Yr=Tt.length>0||wt.length>0||xt||St,Xr=qr||Yr?[...Kr,{header:I(`grid.actions`),accessorKey:`_actions`,fitContent:!0,align:`right`,pinned:`right`,cell:(t,a)=>{let o=i?.(a);return(0,$.jsx)(dd,{row:a,rowActions:Tt,rowActionDefs:wt,objectFields:B?.fields,maxInlineActions:e.maxInlineRowActions??1,canEdit:mu(Et&&o?.update!==!1,Nt(Rd(a),`update`)),canDelete:mu(Dt&&o?.delete!==!1,Nt(Rd(a),`delete`)),editPredicates:kt,deletePredicates:jt,onEdit:n,onDelete:r,onAction:(e,t)=>{Jn({type:e,params:{record:t}}).then(e=>{e?.success&&de(e=>e+1)})},onActionDef:(e,t)=>{let{params:n,...r}=e,i={...r};Array.isArray(n)&&n.length>0&&(i.actionParams=n),i.params={_rowRecord:t},Jn(i).then(e=>{e?.success&&de(e=>e+1)})}})},sortable:!1}]:Kr,ti=Xr.filter(e=>e.pinned===`left`),ni=Xr.filter(e=>e.pinned===`right`),ri=Xr.filter(e=>!e.pinned),ii=ti.length>0||ni.length>0,ai=`sticky right-0 z-10 bg-background border-l border-border`,oi=ti.filter(e=>e.accessorKey!==`_actions`).length,ci=oi>0||ni.some(e=>e.accessorKey!==`_actions`),li=ve===`compact`?`px-3 py-1 h-9 text-[13px] leading-tight`:ve===`short`?`px-3 py-1 h-9 text-[13px] leading-normal`:ve===`tall`?`px-3 py-2.5 h-14 text-sm`:ve===`extra_tall`?`px-3 py-3.5 h-16 text-sm leading-relaxed`:`px-3 py-1.5 h-11 text-[13px] leading-normal`,di=e=>({...e,className:[`px-3`,e.className].filter(Boolean).join(` `),cellClassName:[li,e.cellClassName].filter(Boolean).join(` `)}),fi=(!$e&&(!vr||Dn)||et)&&!vr,pi=fi||vr&&Dn,mi=fi,hi=en(B),gi=e=>{if(!pi||e.sortable===!1)return e;let t=B?.fields?.[e.accessorKey];return Mn(t)?{...e,sortable:!1}:hi?An(hi,e.accessorKey)?e:{...e,sortable:!1}:jn(t)?{...e,sortable:!1}:e},_i=e=>gi(di(e)),vi=ii?[...ti.map(_i),...ri.map(_i),...ni.map(e=>({..._i(e),className:[`px-3`,e.className,ai].filter(Boolean).join(` `),cellClassName:[li,e.cellClassName,ai].filter(Boolean).join(` `)}))]:Xr.map(_i),yi=ci?oi:e.frozenColumns??1,xi=e.batchActions??e.bulkActions,Si=Ot?xi:xi?.filter(e=>String(e).toLowerCase()!==`delete`),{defs:Ci,unresolved:wi}=Hu({bulkActions:(Si??[]).filter(e=>String(e).toLowerCase()!==`delete`),bulkActionDefs:Array.isArray(e.bulkActionDefs)?e.bulkActionDefs:[],objectActions:B?.actions,localizeLabel:(t,n)=>R(e.objectName,t,n)}),Ei=Ci.filter(e=>Ot||e?.operation!==`delete`),Di=(Si??[]).filter(e=>String(e).toLowerCase()===`delete`),Oi=Si&&Si.length>0?[...wi,...Di]:Dt&&a&&Ei.length===0?[`delete`]:[],ki=Oi.length>0||Ei.length>0,Ai=!1;if(e.selection!==void 0){let t=e.selection?.type;Ai=t===`none`?!1:t??Yd}else e.selectable===void 0?ki&&(Ai=`multiple`):Ai=e.selectable;let ji=Ai===`single`,Mi=$e?D??null:W.current??null,Ni=!ji&&Mi!==null,Pi=async n=>{if(!U)return n;let r=e.objectName;if(!t||!r||!Mi)return n;let i={...Mi};delete i.$top,delete i.$skip;let a=5e3,o=[],s=0;for(;o.length<a;){let e=(await t.find(r,{...i,$top:500,$skip:s})).data??[];if(e.length===0||(o.push(...e),e.length<500))break;s+=500}return o.slice(0,a)},Fi=()=>{H([]),Se(!1),we(e=>e+1)},zi=()=>({name:`delete`,label:R(e.objectName,`delete`,rd(`delete`)),operation:`delete`,variant:`danger`}),Bi=(e,t)=>{(async()=>{let n=await Pi(t);if(e===`delete`&&a){let{eligible:e,skipped:t}=Xn(Mt?.visibleWhen,n,{scope:$n,fields:B?.fields,label:`delete`});if(t===0){a(e),Fi();return}Oe(zi()),je(e),Pe(t);return}(await Jn({type:e,params:{records:n}}))?.success&&(Fi(),de(e=>e+1))})()},Vi=(e,t)=>{(async()=>{let{eligible:n,skipped:r}=Wu(e,await Pi(t),{scope:$n,fields:B?.fields});Oe(e),je(n),Pe(r)})()},Hi=e=>{let{params:t,actionParams:n,confirmText:r,confirm:i,...a}=e;return a},Wi=async(e,t,n)=>{let r=e.actionDef;if(!r)return;let{resultDialog:i,...a}=Hi(r),o=await Jn({...a,params:{...n,_rowRecord:t},toast:{showOnSuccess:!1,showOnError:!1}});if(!o?.success)throw Error(o?.error||`Action ${e.name} failed`)},Gi=async(e,t,n)=>{let r=e.actionDef;if(!r)return;let i=Hi(r),a=t.map(e=>e.id==null?``:String(e.id)).filter(Boolean);Yn({selectedRecords:t});let o=await Jn({...i,params:{...n,_selectedIds:a},toast:{showOnSuccess:!1,showOnError:!1}});if(!o?.success)throw Error(o?.error||`Action ${e.name} failed`)},Ki=e=>{Oe(null),je([]),Pe(0),e&&e.succeeded>0&&(Fi(),de(e=>e+1))},Yi=e=>e?._id??e?.id,Xi=async(e,n,r)=>{if(!t||!J)throw Error(`Cannot persist inline edit: no dataSource/objectName configured on the grid.`);let i=Yi(r);if(i==null)throw Error(`Cannot persist inline edit: row has no id/_id.`);await t.update(J,i,n),de(e=>e+1)},Qi=async e=>{if(!t||!J)throw Error(`Cannot persist inline edits: no dataSource/objectName configured on the grid.`);await Promise.all(e.map(({changes:e,row:n})=>{let r=Yi(n);if(r==null)throw Error(`Cannot persist inline edit: row has no id/_id.`);return t.update(J,r,e)})),de(e=>e+1)},$i=e.showPagination===!1?!1:e.pagination===void 0?e.showPagination??!0:!0,ta=Qd(e,qd),na=e.searchableFields===void 0?e.showSearch===void 0||e.showSearch:e.searchableFields.length>0,ca=et?_:Te,ua=et?v:sn,fa=et?b??un:un,pa=et?x:cn,ma=et?S:e=>{dn(e),cn(1)},ha=Fd(tn),_a=et?C??[]:fn??ha,va=hi?Ht(_a,hi):_a,ya=et?w:pn,ba=hi&&ya?e=>ya(Ht(e,hi)):ya,xa=vn,Sa=_n?E:gn,Ca={type:`data-table`,caption:y(e.label,F)||y(e.title,F),columns:vi,data:M,pagination:$i,pageSize:fi?fa:ta,pageSizeOptions:e.pagination?.pageSizeOptions,manualPagination:fi,rowCount:fi?ca:void 0,page:fi?ua:void 0,onPageChange:fi?pa:void 0,onPageSizeChange:fi?ma:void 0,manualSorting:pi,sort:pi?va:void 0,onSortChange:pi?ba:void 0,searchable:na,manualSearch:mi,search:mi?xa:void 0,onSearchChange:mi?Sa:void 0,selectable:Ai,showSelectionCount:!1,sortable:!0,exportable:_t?.export,borderless:!0,rowActions:!!(ht&&qr),resizableColumns:e.resizable??e.resizableColumns??!0,reorderableColumns:e.reorderableColumns??!1,editable:ht,renderCellEditor:ht?e=>{let t=B?.fields?.[e.column?.accessorKey];if(!t||!nt(t.type))return null;let n=A.has(t.type),r={name:e.column.accessorKey,...t},i=la(B,e.column.accessorKey,e.value);return i&&Array.isArray(r.options)&&(r={...r,options:r.options.filter(e=>i.has(String(e?.value??e)))}),(0,$.jsx)(pe,{field:r,value:e.value,onChange:t=>n?e.commit(t):e.stage(t),dependentValues:e.pendingRow??e.row})}:void 0,singleClickEdit:e.singleClickEdit??!0,keyboardNavigation:e.keyboardNavigation??ht,className:e.className,cellClassName:ve===`compact`?`px-3 py-1 text-[13px] leading-tight`:ve===`short`?`px-3 py-1 text-[13px] leading-normal`:ve===`tall`?`px-3 py-2.5 text-sm`:ve===`extra_tall`?`px-3 py-3.5 text-sm leading-relaxed`:`px-3 py-1.5 text-[13px] leading-normal`,showRowNumbers:!0,showAddRow:!!_t?.create&&(ut??!0),onAddRecord:p,rowClassName:e.rowColor?(e,t)=>Qn(e):void 0,rowStyle:e.conditionalFormatting?.length?(e,t)=>tr(e):void 0,frozenColumns:yi,onSelectionChange:e=>{H(e),o?.(e)},selectionResetKey:Ce,onRowClick:Gn.handleClick,onCellChange:u,onRowSave:d??Xi,onBatchSave:f??Qi,onColumnResize:(e,t)=>{Ge({...Ve,widths:{...Ve.widths,[e]:t}})},onColumnsReorder:e=>{let t=e.map(e=>e?.accessorKey).filter(e=>typeof e==`string`&&e.length>0);Ge({...Ve,order:t})}},wa={};for(let e of vi){let t=e.accessorKey;if(!t)continue;let n=Ve.widths?.[t];if(n){wa[t]=n;continue}if(e.width){wa[t]=e.width;continue}if(e.fitContent)continue;let r=String(e.header??``).length;for(let e of M.slice(0,50)){let n=e?.[t],i=n==null?0:String(n).length;i>r&&(r=i)}wa[t]=Math.min(400,Math.max(80,r*8+48))}let Ta=(e,t)=>({...Ca,caption:void 0,data:e,pagination:!1,...t?{pagination:t.count>un,manualPagination:!0,rowCount:t.count,page:t.page,pageSize:un,onPageChange:t.onPageChange,onPageSizeChange:e=>{dn(e)}}:{},searchable:!1,borderless:!0,disableInnerScroll:!0,frozenColumns:0,columns:Ca.columns.map(e=>({...e,width:wa[e.accessorKey]??e.width}))}),Ea=y(e.label,F),Da=Ea?I(`detail.recordDetailWithLabel`,{label:Ea}):e.objectName?I(`detail.recordDetailWithLabel`,{label:e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1)}):I(`detail.recordDetail`),Oa={popoverAnchorRef:Kn,storageKey:e.objectName?xe(e.objectName):void 0,legacyStorageKey:e.objectName?At(e.objectName):void 0,width:Gn.width??`min(960px, 60vw)`},ka=n=>{let r=Rd(n),i=!!B?.fields&&Object.keys(B.fields).length>0;if(e.objectName&&r!=null&&i)return(0,$.jsx)(`div`,{className:`px-6 pt-6 pb-6`,"data-testid":`record-detail-panel`,children:(0,$.jsx)(Cl,{record:n,objectName:e.objectName,recordId:r,dataSource:t,objectSchema:B,onClose:Gn.close})});let a=Object.entries(n),o=e=>Y?.[e]?.hidden===!0,s=e=>Yt(e,Y?.[e]),c=a.filter(([e])=>!s(e)&&!o(e)),l=a.filter(([e])=>s(e)&&e!==`_id`&&e!==`id`&&!o(e)),u=e=>e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `),d=(e,t)=>{if(t==null||t===``)return(0,$.jsx)(tt,{className:`text-sm italic`,glyph:I(`grid.empty`)});if(it)return(0,$.jsx)(gt,{value:t});let n=Y?.[e],{rendererType:r,Renderer:i}=ra(n);return r?(0,$.jsx)(i,{value:t,field:n}):typeof t==`boolean`?(0,$.jsx)(Qe,{variant:t?`default`:`outline`,children:I(t?`grid.yes`:`grid.no`)}):typeof t==`string`&&!isNaN(Date.parse(t))&&(e.includes(`date`)||e.includes(`_at`)||e.includes(`time`))?(0,$.jsx)(`span`,{className:`text-sm tabular-nums`,children:Un(t,void 0,{locale:F})}):typeof t==`number`&&[`amount`,`price`,`total`,`revenue`,`cost`,`value`,`budget`,`salary`].some(t=>e.toLowerCase().includes(t))?(0,$.jsx)(`span`,{className:`text-sm tabular-nums font-medium`,children:Ae(t,re,F)}):(0,$.jsx)(`span`,{className:`text-sm break-words`,children:String(pt(t)??``)})};return(0,$.jsxs)(`div`,{className:`space-y-4`,"data-testid":`record-detail-panel`,children:[(0,$.jsx)(`div`,{className:`rounded-lg border bg-card`,children:(0,$.jsx)(`div`,{className:`divide-y`,children:c.map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-4 px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:w-1/3 sm:text-right sm:pt-0.5 uppercase tracking-wide shrink-0`,children:u(e)}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:d(e,t)})]},e))})}),l.length>0&&(0,$.jsxs)(`div`,{className:`rounded-lg border bg-muted/30`,children:[(0,$.jsx)(`div`,{className:`px-4 py-2 border-b`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:I(`grid.systemFields`)})}),(0,$.jsx)(`div`,{className:`divide-y divide-border/50`,children:l.map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex items-center gap-4 px-4 py-2`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground w-1/3 text-right shrink-0`,children:u(e)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1 min-w-0 break-words`,children:it?(0,$.jsx)(gt,{value:t}):String(pt(t)??``)})]},e))})]})]})},Aa=y(e.description,F),ja=Aa?(0,$.jsx)(`p`,{className:`px-3 sm:px-4 pt-1.5 text-xs text-muted-foreground`,"data-testid":`object-grid-description`,children:Aa}):null;if(ce&&M.length>0&&!vr){let t=Br().filter(e=>e.accessorKey!==`_actions`),n=new Map;t.forEach(e=>n.set(e.accessorKey,e));let r=t[0],i=[`amount`,`price`,`total`,`revenue`,`cost`,`value`,`budget`,`salary`],a=[`stage`,`status`,`priority`,`category`,`severity`,`level`],o=[`date`,`due`,`created`,`updated`,`deadline`,`start`,`end`,`expires`],s=[`probability`,`percent`,`rate`,`ratio`,`confidence`,`score`],c=e=>{let t=(e||``).toLowerCase();return t.includes(`won`)||t.includes(`completed`)||t.includes(`done`)||t.includes(`active`)||t===`activated`||t===`success`||t===`approved`||t===`paid`?`bg-green-50 text-green-700 border-green-200 dark:bg-green-950/40 dark:text-green-300 dark:border-green-900/60`:t.includes(`lost`)||t.includes(`cancelled`)||t.includes(`rejected`)||t.includes(`closed lost`)||t===`expired`||t===`terminated`||t===`failed`||t===`overdue`?`bg-red-50 text-red-700 border-red-200 dark:bg-red-950/40 dark:text-red-300 dark:border-red-900/60`:t.includes(`negotiation`)||t.includes(`review`)||t.includes(`in progress`)||t.includes(`approval`)||t===`in_approval`||t===`pending_approval`?`bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-950/40 dark:text-yellow-300 dark:border-yellow-900/60`:t.includes(`proposal`)||t.includes(`pending`)?`bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950/40 dark:text-blue-300 dark:border-blue-900/60`:t.includes(`qualification`)||t.includes(`qualified`)?`bg-indigo-50 text-indigo-700 border-indigo-200 dark:bg-indigo-950/40 dark:text-indigo-300 dark:border-indigo-900/60`:t.includes(`prospecting`)||t.includes(`new`)||t.includes(`open`)?`bg-purple-50 text-purple-700 border-purple-200 dark:bg-purple-950/40 dark:text-purple-300 dark:border-purple-900/60`:t===`draft`||t.includes(`draft`)?`bg-slate-50 text-slate-700 border-slate-200 dark:bg-slate-950/40 dark:text-slate-300 dark:border-slate-900/60`:`bg-muted text-muted-foreground border-border`},l=e=>{let t=(e||``).toLowerCase();return t.includes(`won`)||t.includes(`completed`)||t.includes(`done`)||t.includes(`active`)||t===`activated`?`border-l-green-500`:t.includes(`lost`)||t.includes(`cancelled`)||t.includes(`rejected`)||t===`expired`||t===`terminated`?`border-l-red-500`:t.includes(`negotiation`)||t.includes(`review`)||t.includes(`in progress`)||t.includes(`approval`)?`border-l-yellow-500`:t.includes(`proposal`)||t.includes(`pending`)?`border-l-blue-500`:t.includes(`qualification`)||t.includes(`qualified`)?`border-l-indigo-500`:t.includes(`prospecting`)||t.includes(`new`)||t.includes(`open`)?`border-l-purple-500`:t===`draft`||t.includes(`draft`)?`border-l-slate-400`:`border-l-gray-300`},u=e=>oa(n.get(e)?.type,Y?.[e]?.type,it),d=e=>{if(u(e))return`other`;let t=e.toLowerCase();return i.some(e=>t.includes(e))?`amount`:a.some(e=>t.includes(e))?`stage`:o.some(e=>t.includes(e))?`date`:s.some(e=>t.includes(e))?`percent`:`other`},f=(t,n)=>{let r=B?.fields?.[t]?.options;if(Array.isArray(r)&&r.length>0){let i=(e.objectName?ie(e.objectName,t,r):r).find(e=>e&&String(e.value)===String(n));if(i)return{label:i.label==null?String(n):String(i.label),color:i.color}}let i=String(n);return{label:/^[a-z0-9]+(_[a-z0-9]+)+$/.test(i)?Cn(i):i}};return(0,$.jsxs)($.Fragment,{children:[ja,(0,$.jsx)(`div`,{className:`space-y-2 p-2`,...qn,children:M.map((e,n)=>{let i=t.slice(1,5),a=i.find(e=>d(e.accessorKey)===`amount`),o=i.find(e=>d(e.accessorKey)===`stage`),s=i.filter(e=>d(e.accessorKey)===`date`),p=i.filter(e=>d(e.accessorKey)===`percent`),m=i.filter(e=>e!==a&&e!==o&&!s.includes(e)&&!p.includes(e)),g=o?String(e[o.accessorKey]??``):``,_=g?l(g):``,v=[`border rounded-lg p-2.5 bg-card hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation`,_?`border-l-[3px] ${_}`:``].filter(Boolean).join(` `);return(0,$.jsxs)(`div`,{className:v,onClick:()=>Gn.handleClick(e),children:[r&&(0,$.jsx)(`div`,{className:`font-semibold text-sm truncate mb-1`,children:u(r.accessorKey)?r.cell?.(e[r.accessorKey],e):pt(e[r.accessorKey])??`—`}),(a||o)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[a&&(0,$.jsx)(`span`,{className:`text-sm tabular-nums font-medium`,children:typeof e[a.accessorKey]==`number`?ct(e[a.accessorKey],Nr(B?.fields?.[a.accessorKey],re),F):pt(e[a.accessorKey])??`—`}),o&&e[o.accessorKey]&&(()=>{let t=e[o.accessorKey],n=f(o.accessorKey,t),r=Ct(n.color),i=r?r.className:n.color?rt(n.color,t):c(String(t));return(0,$.jsx)(Qe,{variant:`outline`,className:`text-xs shrink-0 max-w-[140px] truncate ${i}`,style:r?.style,children:n.label})})()]}),(s.length>0||p.length>0)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-0.5 text-xs text-muted-foreground`,children:[s[0]&&(0,$.jsx)(`span`,{className:`tabular-nums`,children:e[s[0].accessorKey]?Un(e[s[0].accessorKey],`short`,{locale:F}):`—`}),p[0]&&e[p[0].accessorKey]!=null&&(()=>{let t=B?.fields?.[p[0].accessorKey];if(t?.type!==`percent`){let{Renderer:n}=ra(t);return(0,$.jsx)(`span`,{className:`tabular-nums`,children:(0,$.jsx)(n,{value:e[p[0].accessorKey],field:t??{name:p[0].accessorKey}})})}let n=h({type:t.type,scale:t.scale});return(0,$.jsx)(`span`,{className:`tabular-nums`,children:Ie(Number(e[p[0].accessorKey]),Me(t),n,F)})})()]}),s.slice(1).map(t=>(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-0.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.header}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:e[t.accessorKey]?Un(e[t.accessorKey],`short`,{locale:F}):`—`})]},t.accessorKey)),m.map(t=>{let n=e[t.accessorKey];return n==null||n===``?null:(0,$.jsxs)(`div`,{className:`flex justify-between items-center py-0.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.header}),(0,$.jsx)(`span`,{className:`text-xs font-medium truncate ml-2 text-right`,children:t.cell?t.cell(n,e):String(pt(n)??``)})]},t.accessorKey)})]},e.id||e._id||n)})}),Gn.isOverlay&&(0,$.jsx)(K,{...Gn,title:Da,...Oa,children:e=>ka(e)})]})}let Ma=()=>{ye(e=>e===`compact`?`short`:e===`short`?`medium`:e===`medium`?`tall`:e===`tall`?`extra_tall`:`compact`)},Na={compact:Ri,short:Li,medium:Ii,tall:Ji,extra_tall:Ji}[ve],Pa=e.rowHeight!==void 0&&!e.hideRowHeightToggle,Fa=!!e.exportOptions&&Vr.length>0&&e.operations?.export!==!1&&(!ot||ot.includes(`export`)),Ia=Fa||Pa?(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-1 px-2 py-1`,children:[Pa&&(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs`,onClick:Ma,title:`Row height: ${ve}`,children:[(0,$.jsx)(Na,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline capitalize`,children:ve})]}),Fa&&(0,$.jsxs)(oe,{open:fe,onOpenChange:me,children:[(0,$.jsx)(z,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs`,children:[(0,$.jsx)(ui,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:I(`grid.export`)})]})}),(0,$.jsx)(mt,{align:`end`,className:`w-48 p-2`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[Vr.map(e=>(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,disabled:V,onClick:()=>Hr(e),children:[V?(0,$.jsx)(Ti,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,$.jsx)(ui,{className:`h-3.5 w-3.5 mr-2`}),I(`grid.exportAs`,{format:e.toUpperCase()})]},e)),ge&&(0,$.jsx)(`div`,{className:`px-2 py-1 text-xs`,style:{color:`var(--destructive, #ef4444)`},role:`alert`,children:ge})]})})]})]}):null,La=Ar?(0,$.jsx)(`div`,{className:`border-t bg-muted/30 px-2 py-1.5`,"data-testid":`column-summary-footer`,children:(0,$.jsx)(`div`,{className:`flex gap-4 text-xs text-muted-foreground font-medium`,children:vi.filter(e=>kr.has(e.accessorKey)).map(e=>{let t=kr.get(e.accessorKey);return(0,$.jsxs)(`span`,{"data-testid":`summary-${e.accessorKey}`,children:[e.header,`: `,t.label]},e.accessorKey)})})}):null,Ra=(t,n)=>{let r=B?.fields?.[t],i=e.objectName?L(e.objectName,t,r?.label||t):r?.label||t,a,o,s=r?.type;if(s===`select`||s===`status`){let i=r?.options?ie(e.objectName,t,r.options):void 0,s=Array.isArray(i)?i.find(e=>String(e.label)===n||String(e.value)===n):void 0,c=Ct(s?.color);a=c?c.className:rt(s?.color,s?.value??n),o=c?.style}return{fieldLabel:i,labelColorClass:a,labelColorStyle:o}},za=e=>{let t=Er.pages[e.key];return t?.error?(0,$.jsx)(`p`,{"data-testid":`group-rows-error-${e.key}`,className:`px-1 py-2 text-xs text-destructive`,children:t.error.message}):!t||t.loading&&t.rows.length===0?(0,$.jsx)(`p`,{"data-testid":`group-rows-loading-${e.key}`,className:`px-1 py-2 text-xs text-muted-foreground`,children:I(`grid.loading`)}):(0,$.jsx)(Zn,{schema:Ta(t.rows,{count:e.count,page:t.page,onPageChange:t=>Er.setPage(e.key,t)})})},Ba=e=>{let{fieldLabel:t,labelColorClass:n,labelColorStyle:r}=Ra(e.field,e.label);return(0,$.jsx)(`div`,{children:(0,$.jsx)(Ql,{groupKey:e.key,label:e.label,count:e.count,collapsed:e.collapsed,aggregations:e.aggregations,fieldLabel:e.depth===0?t:void 0,labelColorClass:n,labelColorStyle:r,onToggle:yr,children:e.subgroups.length>0?(0,$.jsx)(`div`,{className:`space-y-4 mt-2`,children:e.subgroups.map(Ba)}):Dn?za(e):(0,$.jsx)(Zn,{schema:Ta(e.rows)})})},e.key)},Va=Math.max(1,Math.ceil(_r.length/Re)),Ha=Math.min(Fe,Va),Ua=_r.slice((Ha-1)*Re,Ha*Re),Wa=_r.length>0&&Va>1?(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center justify-between gap-2 px-3 sm:px-4 py-2 border-t`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-xs sm:text-sm text-muted-foreground`,children:[I(`table.rowsPerPage`),`:`]}),(0,$.jsx)(`select`,{className:`h-8 rounded-md border border-input bg-background px-2 text-sm`,value:Re,onChange:e=>{ze(Number(e.target.value)),Le(1)},children:Array.from(new Set([5,10,20,50,100,Re])).sort((e,t)=>e-t).map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs sm:text-sm text-muted-foreground`,children:I(`table.pageInfo`,{current:Ha,total:Va})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(G,{variant:`outline`,size:`icon`,onClick:()=>Le(1),disabled:Ha===1,children:(0,$.jsx)($r,{className:`h-4 w-4`})}),(0,$.jsx)(G,{variant:`outline`,size:`icon`,onClick:()=>Le(Math.max(1,Ha-1)),disabled:Ha===1,children:(0,$.jsx)(Zr,{className:`h-4 w-4`})}),(0,$.jsx)(G,{variant:`outline`,size:`icon`,onClick:()=>Le(Math.min(Va,Ha+1)),disabled:Ha===Va,children:(0,$.jsx)(Qr,{className:`h-4 w-4`})}),(0,$.jsx)(G,{variant:`outline`,size:`icon`,onClick:()=>Le(Va),disabled:Ha===Va,children:(0,$.jsx)(ei,{className:`h-4 w-4`})})]})]})]}):null,Ga=vr?(0,$.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto [-webkit-overflow-scrolling:touch]`,children:(0,$.jsx)(`div`,{className:`min-w-max space-y-4 px-3 sm:px-4 pt-2 pb-4`,children:Ua.map(Ba)})}),Wa]}):(0,$.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:(0,$.jsx)(Zn,{schema:Ca})}),La]}),Ka=e.emptyState,qa=y(Ka?.title,F),Ja=y(Ka?.message,F),Ya=mi&&xa.trim()!==``,Xa=Ka!=null&&!ee&&!Ya&&(vr?_r.length===0:M.length===0),Za=Xa?ae(Ka?.icon):null,Qa=Xa?(0,$.jsx)(ft,{"data-testid":`object-grid-empty-state`,className:`flex-1 min-h-[200px]`,icon:Za?(0,$.jsx)(Za,{className:`size-5 text-muted-foreground`}):void 0,title:qa||I(`table.noResults`),description:Ja||void 0}):Ga,$a=(0,$.jsx)(Ed,{def:De,rows:ke,skippedCount:Ne,open:!!De,onClose:Ki,dataSource:t,resource:e.objectName??``,objectFields:B?.fields,runAction:Wi,runAggregate:Gi});return Gn.isOverlay&&Gn.mode===`split`&&Gn.isOpen&&Gn.selectedRecord?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{...Gn,title:Da,...Oa,mainContent:(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[ja,Ia,Qa,(0,$.jsx)(pd,{selectedRows:be,actions:Oi??[],actionDefs:Ei,objectFields:B?.fields,onAction:Bi,onActionDef:Vi,onClearSelection:Fi,pageSize:M.length,totalMatching:Ni?ca:void 0,allMatchingSelected:U,onSelectAllMatching:Ni?()=>Se(!0):void 0})]}),children:e=>ka(e)}),$a]}):(0,$.jsxs)(`div`,{ref:Ke,className:`relative h-full flex flex-col`,...qn,children:[(0,$.jsx)(Xe,{active:ee&&M.length>0,ariaLabel:I(`grid.refreshing`)}),Je>0&&(0,$.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:Je},children:I(qe?`grid.refreshing`:`grid.pullToRefresh`)}),ja,Ia,Qa,(0,$.jsx)(pd,{selectedRows:be,actions:Oi??[],actionDefs:Ei,objectFields:B?.fields,onAction:Bi,onActionDef:Vi,onClearSelection:Fi,pageSize:M.length,totalMatching:Ni?ca:void 0,allMatchingSelected:U,onSelectAllMatching:Ni?()=>Se(!0):void 0}),Gn.isOverlay&&(0,$.jsx)(K,{...Gn,title:Da,...Oa,children:e=>ka(e)}),$a]})};b();var nf=new Set([`true`,`t`,`yes`,`y`,`1`,`on`,`是`,`对`,`✓`,`√`]),rf=new Set([`false`,`f`,`no`,`n`,`0`,`off`,`否`,`错`,`✗`,`×`]),af=new Set([...nf,...rf]),of=new Set([...d,`reference`]),sf={Unsupported:`IMPORT_UNSUPPORTED_FILE`,LegacyXls:`IMPORT_LEGACY_XLS`};function cf(e,t=`,`){let n=[],r=[],i=``,a=!1;for(let o=0;o<e.length;o++){let s=e[o],c=e[o+1];a?s===`"`&&c===`"`?(i+=`"`,o++):s===`"`?a=!1:i+=s:s===`"`?a=!0:s===t?(r.push(i.trim()),i=``):s===`
|
|
8
|
+
`||s===`\r`&&c===`
|
|
9
|
+
`?(r.push(i.trim()),r.some(e=>e!==``)&&n.push(r),r=[],i=``,s===`\r`&&o++):i+=s}return r.push(i.trim()),r.some(e=>e!==``)&&n.push(r),n}function lf(e){if(e==null)return``;if(e instanceof Date){let t=e.toISOString();return t.endsWith(`T00:00:00.000Z`)?t.slice(0,10):t}if(typeof e==`object`){let t=e;return`result`in t?lf(t.result):Array.isArray(t.richText)?t.richText.map(e=>String(e.text??``)).join(``):`text`in t?lf(t.text):`hyperlink`in t?String(t.hyperlink??``):`error`in t?String(t.error??``):``}return String(e)}async function uf(t){let r=await n(()=>import(`./exceljs.min-C1j2HQXe.js`).then(t=>e(t.default,1)),[],import.meta.url),i=new(r.default??r).Workbook;await i.xlsx.load(t);let a=i.worksheets[0];if(!a)return[];let o=a.columnCount,s=[];return a.eachRow({includeEmpty:!1},e=>{let t=[];for(let n=1;n<=o;n++)t.push(lf(e.getCell(n).value).trim());t.some(e=>e!==``)&&s.push(t)}),s}function df(e){let t=new Uint8Array(e);if(t[0]===239&&t[1]===187&&t[2]===191)return new TextDecoder(`utf-8`).decode(t);if(t[0]===255&&t[1]===254)return new TextDecoder(`utf-16le`).decode(t);if(t[0]===254&&t[1]===255)return new TextDecoder(`utf-16be`).decode(t);try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(t)}catch{try{return new TextDecoder(`gb18030`).decode(t)}catch{return new TextDecoder(`utf-8`).decode(t)}}}async function ff(e){let t=e.name.toLowerCase();if(t.endsWith(`.csv`)||t.endsWith(`.tsv`)||t.endsWith(`.txt`))return cf(df(await e.arrayBuffer()),t.endsWith(`.tsv`)?` `:`,`);if(t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`))return uf(await e.arrayBuffer());throw t.endsWith(`.xls`)?Error(sf.LegacyXls):Error(sf.Unsupported)}function pf(e,t){if(e&&/<table[\s>]/i.test(e)&&typeof DOMParser<`u`){let t=mf(e);if(t.length)return t}if(t&&t.trim()){let e=cf(t,t.includes(` `)?` `:`,`);if(e.length)return e}return null}function mf(e){let t=new DOMParser().parseFromString(e,`text/html`).querySelector(`table`);if(!t)return[];let n=[];return t.querySelectorAll(`tr`).forEach(e=>{let t=[];e.querySelectorAll(`th,td`).forEach(e=>t.push((e.textContent??``).trim())),t.some(e=>e!==``)&&n.push(t)}),n}var hf=new Set([`true`,`false`,`yes`,`no`,`y`,`n`,`是`,`否`]),gf=50,_f=e=>e!==``&&!isNaN(Number(e)),vf=e=>hf.has(e.toLowerCase()),yf=e=>/\d{1,2}:\d{2}/.test(e)||/T\d{2}:\d{2}/.test(e),bf=e=>!_f(e)&&!isNaN(Date.parse(e));function xf(e){let t=e.map(e=>(e??``).trim()).filter(e=>e!==``).slice(0,gf);return t.length===0?`text`:t.every(vf)?`boolean`:t.every(_f)?`number`:t.every(bf)?t.some(yf)?`datetime`:`date`:`text`}function Sf(e,t){switch(e){case`number`:return[`number`,`currency`,`percent`].includes(t);case`boolean`:return t===`boolean`;case`date`:case`datetime`:return t===`date`||t===`datetime`;case`text`:return!0;default:return!0}}var Cf=e=>e.toLowerCase().replace(/[\s_\-.]+/g,``).replace(/[()()[\]{}::,,、/**]/g,``);function wf(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase().split(/[\s_\-./()()[\]{}::,,、**]+/).map(e=>e.trim()).filter(Boolean)}var Tf=[[`name`,`fullname`,`displayname`,`姓名`,`名称`,`名字`],[`email`,`emailaddress`,`mail`,`邮箱`,`电子邮箱`,`邮件`],[`phone`,`tel`,`telephone`,`mobile`,`cell`,`手机`,`电话`,`手机号`,`联系电话`],[`date`,`日期`],[`datetime`,`timestamp`,`时间`,`日期时间`],[`amount`,`price`,`total`,`cost`,`金额`,`价格`,`总额`,`总价`,`费用`],[`status`,`state`,`状态`],[`address`,`地址`],[`company`,`organization`,`org`,`公司`,`单位`,`组织`,`企业`],[`description`,`desc`,`note`,`notes`,`remark`,`remarks`,`备注`,`描述`,`说明`],[`id`,`code`,`number`,`no`,`编号`,`编码`,`代码`],[`quantity`,`qty`,`count`,`数量`],[`country`,`国家`],[`city`,`城市`],[`province`,`state`,`省份`,`省`],[`gender`,`sex`,`性别`],[`age`,`年龄`],[`title`,`标题`,`职位`,`头衔`],[`owner`,`assignee`,`assignedto`,`负责人`,`负责`,`所有者`,`归属人`],[`createdat`,`createdon`,`createtime`,`创建时间`],[`updatedat`,`updatedon`,`modifiedtime`,`更新时间`]],Ef=(()=>{let e=new Map;return Tf.forEach((t,n)=>t.forEach(t=>e.set(Cf(t),n))),e})();function Df(e){return e>=.85?`high`:e>=.55?`medium`:e>0?`low`:null}var Of=.4;function kf(e,t){if(e.length===0||t.length===0)return 0;let n=new Set(e),r=new Set(t),i=0;return n.forEach(e=>{r.has(e)&&i++}),i/(n.size+r.size-i)}function Af(e,t,n){let r=[t.name,t.label].filter(e=>!!e),i=Cf(e),a=wf(e),o={score:0,reason:`none`},s=(e,t)=>{e>o.score&&(o.score=e,o.reason=t)};for(let t of r){if(e.trim()===t.trim()){s(1,`exact`);continue}let n=Cf(t);if(i&&n&&i===n){s(.95,`normalized`);continue}i&&n&&(i.includes(n)||n.includes(i))&&s(.5+Math.min(i.length,n.length)/Math.max(i.length,n.length)*.35,`contains`);let r=kf(a,wf(t));r>0&&s(.4+r*.45,`token`)}let c=Ef.get(i);return c!==void 0&&r.some(e=>Ef.get(Cf(e))===c)&&s(.82,`synonym`),o.reason!==`exact`&&o.reason!==`normalized`&&n!==`text`&&o.score>0&&(Sf(n,t.type)?o.score=Math.min(1,o.score+.05):o.score*=.5),{score:o.score,reason:o.reason}}function jf(e,t,n){let r=e.map((e,t)=>xf(n?n.map(e=>e[t]):[])),i=[];e.forEach((e,n)=>{t.forEach(t=>{let{score:a,reason:o}=Af(e,t,r[n]);a>0&&i.push({ci:n,field:t.name,score:a,reason:o})})}),i.sort((e,t)=>t.score-e.score);let a=new Set,o=new Set,s=new Map;for(let e of i)e.score<Of||a.has(e.ci)||o.has(e.field)||(s.set(e.ci,e),a.add(e.ci),o.add(e.field));return e.map((e,t)=>{let n=s.get(t);return n?{columnIndex:t,fieldName:n.field,score:n.score,confidence:Df(n.score),reason:n.reason,inferredType:r[t]}:{columnIndex:t,fieldName:null,score:0,confidence:null,reason:`none`,inferredType:r[t]}})}function Mf(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.name!=`string`||typeof t.targetObject!=`string`||!Array.isArray(t.fieldMapping)?null:t}function Nf(e,t,n){return t.map((t,r)=>{let i=n[r],a={};return e.forEach((e,n)=>{if(!e)return;let r=i&&i[n]!==void 0?i[n]:t[n]??``;a[e]=r}),a})}function Pf(e){return(e.fieldMapping??[]).map(e=>({source:Array.isArray(e.source)?e.source.join(` + `):e.source,target:Array.isArray(e.target)?e.target.join(`, `):e.target,transform:e.transform&&e.transform!==`none`?e.transform:``}))}function Ff(e,t){let n=new Map;t.forEach((e,t)=>{e&&n.set(e.trim().toLowerCase(),t)});let r={};for(let t of e.fieldMapping??[]){if(Array.isArray(t.source)||Array.isArray(t.target)||t.transform===`constant`)continue;let e=n.get(String(t.source).trim().toLowerCase());e!==void 0&&(r[e]=String(t.target))}return r}var If={"grid.import.title":`Import {{object}}`,"grid.import.stepUpload":`Upload`,"grid.import.stepMapping":`Mapping`,"grid.import.stepPreview":`Preview`,"grid.import.uploadDescription":`Upload a CSV or Excel file, or paste from a spreadsheet to get started.`,"grid.import.mappingDescription":`Map columns to object fields.`,"grid.import.previewDescription":`Review data before importing.`,"grid.import.dragDrop":`Drag & drop a CSV or Excel file here, or click to browse`,"grid.import.browseFiles":`Browse Files`,"grid.import.downloadTemplate":`Download template`,"grid.import.downloadTemplateHint":`Get an Excel file of the columns you can import (required fields marked *), with instructions for filling it in.`,"grid.import.templateFileName":`{{object}}-import-template`,"grid.import.templateDownloadFailed":`Could not download the template. Please try again.`,"grid.import.templateNotPermitted":`You do not have permission to create records of this object, so its import template is not available.`,"grid.import.parsing":`Parsing…`,"grid.import.pasteHint":`or paste (Ctrl/⌘+V) rows copied from Excel or Google Sheets`,"grid.import.legacyXls":`Legacy .xls files aren't supported — please re-save as .xlsx.`,"grid.import.unsupportedFile":`Unsupported file type. Use CSV, TSV, or Excel (.xlsx).`,"grid.import.parseFailed":`Could not read this file. Please check the format and try again.`,"grid.import.fileNeedsHeader":`File must contain a header row and at least one data row.`,"grid.import.mappingTemplate":`Mapping template:`,"grid.import.chooseTemplate":`Choose template…`,"grid.import.noSavedTemplates":`No saved templates`,"grid.import.noneOption":`— None —`,"grid.import.saveCurrent":`Save current`,"grid.import.templateName":`Template name`,"grid.import.save":`Save`,"grid.import.deleteTemplate":`Delete template`,"grid.import.savedMapping":`Saved mapping:`,"grid.import.chooseSavedMapping":`Choose a saved mapping…`,"grid.import.manualMapping":`— Map columns manually —`,"grid.import.transform":`Transform`,"grid.import.savedMappingHint":`Mapping “{{name}}” applies rename + transforms + type coercion on the server. Column mapping is read-only.`,"grid.import.savedMappingPreviewNote":`The preview shows your source columns; on import, mapping “{{name}}” applies rename, transforms and type coercion on the server.`,"grid.import.csvColumn":`Column`,"grid.import.mapsTo":`Maps To`,"grid.import.typeMismatch":`Looks like {{type}}`,"grid.import.autoMatched":`Auto-matched`,"grid.import.autoMatchedSummary":`Auto-matched {{count}} column(s) — review and adjust below.`,"grid.import.autoMatchedSummary_one":`Auto-matched {{count}} column — review and adjust below.`,"grid.import.autoMatchedSummary_other":`Auto-matched {{count}} columns — review and adjust below.`,"grid.import.confidence.high":`High confidence`,"grid.import.confidence.medium":`Medium confidence`,"grid.import.confidence.low":`Low confidence`,"grid.import.type.number":`Number`,"grid.import.type.boolean":`Boolean`,"grid.import.type.date":`Date`,"grid.import.type.datetime":`Date & time`,"grid.import.type.text":`Text`,"grid.import.status":`Status`,"grid.import.skipColumn":`Skip column`,"grid.import.skip":`— Skip —`,"grid.import.mapped":`Mapped`,"grid.import.skipped":`Skipped`,"grid.import.rowsWithErrors":`{{count}} row(s) with errors`,"grid.import.rowsWithErrors_one":`{{count}} row with errors`,"grid.import.rowsWithErrors_other":`{{count}} rows with errors`,"grid.import.rowsCorrected":`{{count}} row(s) corrected`,"grid.import.rowsCorrected_one":`{{count}} row corrected`,"grid.import.rowsCorrected_other":`{{count}} rows corrected`,"grid.import.clickToFix":`— click a highlighted cell to fix it inline.`,"grid.import.showingRows":`Showing {{shown}} of {{total}} rows`,"grid.import.importing":`Importing… {{progress}}%`,"grid.import.asyncQueued":`Queued — preparing to import…`,"grid.import.asyncProcessing":`Importing {{processed}} of {{total}} rows… {{progress}}%`,"grid.import.asyncLargeHint":`This file is large, so it will be imported in the background.`,"grid.import.largeSampleNotice":`Previewing the first {{shown}} of {{total}} rows.`,"grid.import.cancelImport":`Cancel import`,"grid.import.importCancelled":`Import cancelled`,"grid.import.resultsTruncated":`Showing the first {{count}} row results (of {{total}}).`,"grid.import.resultsTruncated_one":`Showing the first {{count}} row result (of {{total}}).`,"grid.import.resultsTruncated_other":`Showing the first {{count}} row results (of {{total}}).`,"grid.import.importComplete":`Import Complete`,"grid.import.imported":`{{count}} imported`,"grid.import.createdCount":`{{count}} created`,"grid.import.createdCount_one":`{{count}} created`,"grid.import.createdCount_other":`{{count}} created`,"grid.import.updatedCount":`{{count}} updated`,"grid.import.updatedCount_one":`{{count}} updated`,"grid.import.updatedCount_other":`{{count}} updated`,"grid.import.skippedCount":`{{count}} skipped`,"grid.import.moreErrors":`…and {{count}} more errors`,"grid.import.moreErrors_one":`…and {{count}} more error`,"grid.import.moreErrors_other":`…and {{count}} more errors`,"grid.import.downloadFailed":`Download failed rows`,"grid.import.options":`Import options`,"grid.import.writeMode":`When a row matches an existing record`,"grid.import.writeModeOpt.insert":`Always create new`,"grid.import.writeModeOpt.update":`Update existing (skip if no match)`,"grid.import.writeModeOpt.upsert":`Update if matched, else create`,"grid.import.matchFields":`Match on`,"grid.import.matchFieldsPlaceholder":`Choose match field(s)…`,"grid.import.matchFieldsHint":`Rows are matched to existing records by these field(s).`,"grid.import.needMatchFields":`Select at least one field to match on.`,"grid.import.matchOnlyField":`(match only)`,"grid.import.optCreateOptions":`Keep unknown option values`,"grid.import.optRunAutomations":`Run automations & triggers`,"grid.import.optTreatHistorical":`Import as historical data`,"grid.import.optTreatHistoricalHint":`(import completed records as-is — skip state-machine checks and keep their original timestamps & author instead of stamping now)`,"grid.import.optSkipBlankKey":`Skip rows with a blank match value`,"grid.import.optBackground":`Import in the background`,"grid.import.optBackgroundHint":`(runs as an undoable job)`,"grid.import.validate":`Validate data`,"grid.import.validating":`Validating…`,"grid.import.validateHint":`Check every row against the server before importing.`,"grid.import.validatePassed":`All {{ok}} rows are valid.`,"grid.import.validateFailed":`{{ok}} valid, {{errors}} with errors.`,"grid.import.errorRowPrefix":`Row {{row}}: `,"grid.import.referenceNotFound":`No matching record for "{{value}}"`,"grid.import.referenceAmbiguous":`"{{value}}" matches more than one record — use a unique value or the record id`,"grid.import.invalidBoolean":`"{{value}}" is not a valid true/false value`,"grid.import.invalidNumber":`"{{value}}" is not a valid number`,"grid.import.invalidDate":`"{{value}}" is not a valid date`,"grid.import.invalidOption":`"{{value}}" is not one of the allowed options`,"grid.import.requiredValue":`This field is required`,"grid.import.matchAmbiguous":`Matches more than one existing record — use a unique value or the record id`,"grid.import.history":`History`,"grid.import.historyBack":`Back to import`,"grid.import.historyDescription":`Recent imports for this object.`,"grid.import.historyHint":`Background import jobs, newest first.`,"grid.import.historyRefresh":`Refresh`,"grid.import.historyLoading":`Loading…`,"grid.import.historyEmpty":`No imports yet.`,"grid.import.historyUnsupported":`Import history isn’t available for this data source.`,"grid.import.historyColStatus":`Status`,"grid.import.historyColRows":`Rows`,"grid.import.historyColResult":`Result`,"grid.import.historyColTime":`When`,"grid.import.errorCount":`{{count}} errors`,"grid.import.errorCount_one":`{{count}} error`,"grid.import.errorCount_other":`{{count}} errors`,"grid.import.undoImport":`Undo import`,"grid.import.undoing":`Undoing…`,"grid.import.undoConfirm":`Undo this import? Records it created will be deleted and records it updated will be restored to their previous values.`,"grid.import.reverted":`Undone`,"grid.import.jobStatus.pending":`Pending`,"grid.import.jobStatus.running":`Running`,"grid.import.jobStatus.succeeded":`Succeeded`,"grid.import.jobStatus.failed":`Failed`,"grid.import.jobStatus.cancelled":`Cancelled`,"grid.import.cancel":`Cancel`,"grid.import.back":`Back`,"grid.import.next":`Next`,"grid.import.close":`Close`,"grid.import.importNRows":`Import {{count}} Rows`,"grid.import.importNRows_one":`Import {{count}} Row`,"grid.import.importNRows_other":`Import {{count}} Rows`,"grid.import.importingProgress":`Importing…`,"grid.import.required":`Required`,"grid.import.invalidType":`Invalid {{type}}`,"grid.import.legacyReferenceBlocked":`Import blocked: {{fields}} are relation fields that need the server import route to resolve names into record IDs, and this connection doesn’t support it. Importing them as plain text would corrupt the data. Upgrade the backend/client, or unmap these columns and import them separately.`,"grid.import.missingRequiredHint":`Can’t continue — required field(s) not mapped: {{fields}}. Add a matching column to your file, or go back and upload one that includes it.`,"grid.import.legacyFallbackNotice":`Imported via a compatibility fallback: this connection doesn’t support the server import route, so values were saved as text without server-side type coercion. Upgrade the backend/client for full import support (type coercion and relation lookups).`,"grid.import.notAllowed":`This object is not open for import.`,"grid.import.requiredMark":`*`};function Lf(e,t){if(!t)return e;let n=e;for(let[e,r]of Object.entries(t))n=n.split(`{{${e}}}`).join(String(r));return n}var Rf=new Intl.PluralRules(`en`);function zf(e,t){let n=t?.count;if(typeof n==`number`&&Number.isFinite(n)){let t=If[`${e}_${Rf.select(n)}`];if(t!==void 0)return t}return If[e]}function Bf(){let e=(e,t)=>Lf(zf(e,t)??e,t),t=Lr();return t.t(`grid.import.title`)===`grid.import.title`?{t:e}:{t:(n,r)=>{let i=t.t(n,r);return i===n?e(n,r):i}}}var Vf=10,Hf=5e3,Uf=800,Wf={high:`text-emerald-600`,medium:`text-sky-600`,low:`text-muted-foreground`};function Gf(e,t){let n=new Set(Object.values(e));return t.filter(e=>n.has(e.name)&&of.has(e.type))}function Kf(e){return e?.match(/"([^"]*)"/)?.[1]}function qf(e,t,n,r){let i=e.field?t.get(e.field)??e.field:void 0,a=(n??``).trim()||Kf(e.error)||``;switch(e.code){case`reference_not_found`:return{fieldLabel:i,message:r(`grid.import.referenceNotFound`,{value:a})};case`reference_ambiguous`:return{fieldLabel:i,message:r(`grid.import.referenceAmbiguous`,{value:a})};case`invalid_boolean`:return{fieldLabel:i,message:r(`grid.import.invalidBoolean`,{value:a})};case`invalid_number`:return{fieldLabel:i,message:r(`grid.import.invalidNumber`,{value:a})};case`invalid_date`:return{fieldLabel:i,message:r(`grid.import.invalidDate`,{value:a})};case`invalid_option`:return{fieldLabel:i,message:r(`grid.import.invalidOption`,{value:a})};case`required`:return{fieldLabel:i,message:r(`grid.import.requiredValue`)};case`AMBIGUOUS_MATCH`:return{fieldLabel:i,message:r(`grid.import.matchAmbiguous`)}}let o=(e.error??e.code??``).trim();return e.field&&o.toLowerCase().startsWith(`${e.field.toLowerCase()}:`)&&(o=o.slice(e.field.length+1).trimStart()),{fieldLabel:i,message:o}}function Jf(e){if(e.length===0||e.length>254||/\s/.test(e)||/[^\x20-\x7e]/.test(e))return!1;let t=e.indexOf(`@`);if(t<=0||t!==e.lastIndexOf(`@`)||t===e.length-1)return!1;let n=e.slice(t+1),r=n.lastIndexOf(`.`);return r>0&&r<n.length-1}function Yf(e,t){if(!e)return!0;switch(t){case`number`:case`currency`:case`percent`:return!isNaN(Number(e));case`boolean`:return af.has(e.trim().toLowerCase());case`date`:case`datetime`:return!isNaN(Date.parse(e));case`email`:return Jf(e.trim());default:return!0}}function Xf(e,t,n){let r={};for(let i of jf(e,t,n))i.fieldName&&(r[i.columnIndex]=i.fieldName);return r}function Zf(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Qf(e,t){if(!e)return[];try{let n=e.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?r.filter(e=>e&&e.id&&e.name&&e.mapping):[]}catch{return[]}}function $f(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch{}}function ep(e,t){let n={};return Object.entries(t).forEach(([t,r])=>{let i=e[Number(t)];i&&(n[i.trim().toLowerCase()]=r)}),n}function tp(e,t,n){let r=new Set(n.map(e=>e.name)),i={};return t.forEach((t,n)=>{let a=e.mapping[t.trim().toLowerCase()];a&&r.has(a)&&(i[n]=a)}),i}function np(e,t,n){let r=[],i={};for(let a of t){let t=e[a.csvIdx]??``;if(a.field.required&&!t){r.push({row:n,field:a.field.name,message:`Required field is empty`});continue}if(t&&!Yf(t,a.field.type)){r.push({row:n,field:a.field.name,message:`Invalid ${a.field.type} value: "${t}"`});continue}i[a.field.name]=t}return{record:i,errors:r}}function rp(e,t){return t.mappingName?{format:`json`,rows:e,mappingName:t.mappingName,runAutomations:t.runAutomations,...t.treatAsHistorical?{treatAsHistorical:!0}:{},...t.dryRun?{dryRun:!0}:{}}:{format:`json`,rows:e,writeMode:t.writeMode,...t.writeMode===`insert`?{}:{matchFields:t.matchFields},createMissingOptions:t.createMissingOptions,runAutomations:t.runAutomations,...t.treatAsHistorical?{treatAsHistorical:!0}:{},skipBlankMatchKey:t.skipBlankMatchKey,...t.dryRun?{dryRun:!0}:{}}}function ip(e){if(e?.code===`UNSUPPORTED_OPERATION`)return!0;let t=e instanceof Error?e.message:``;return/does not support data\.import|importRecords is not a function|\.import is not a function/i.test(t)}function ap(e){if(e?.code===`UNSUPPORTED_OPERATION`)return!0;let t=e instanceof Error?e.message:``;return/does not support async import|createImportJob is not a function|import\/jobs|404/i.test(t)}function op(e){if(e?.code===`OBJECT_API_METHOD_NOT_ALLOWED`)return!0;let t=e;if(t?.status===405||t?.statusCode===405||t?.httpStatus===405)return!0;let n=e instanceof Error?e.message:typeof e==`string`?e:``;return/\b405\b|method not allowed/i.test(n)}function sp(e){return{totalRows:e.total,importedRows:e.created+e.updated,skippedRows:e.skipped+e.errors,createdRows:e.created,updatedRows:e.updated,errors:(e.results??[]).filter(e=>!e.ok).map(e=>({row:e.row,field:e.field??``,message:e.error??e.code??`Import failed`,code:e.code})),resultsTruncated:e.resultsTruncated}}function cp(e){return e===`pending`||e===`running`}function lp(e,t){return t&&!!e.undoable&&!e.revertedAt&&!cp(e.status)}function up(e,t,n,r){let i=Object.keys(n).map(Number).sort((e,t)=>e-t),a=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,o=[[...i.map(t=>e[t]??`col${t}`),`_error`].map(a).join(`,`)];for(let[e,n]of r){let r=t[e-1];r&&o.push([...i.map(e=>a(r[e]??``)),a(n)].join(`,`))}return o.join(`
|
|
10
|
+
`)}function dp(e,t){if(typeof document>`u`||typeof URL?.createObjectURL!=`function`)return;let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),0)}function fp(e,t){if(op(e))return t(`grid.import.notAllowed`);let n=e;return n?.code===`PERMISSION_DENIED`||n?.status===403||n?.httpStatus===403?t(`grid.import.templateNotPermitted`):t(`grid.import.templateDownloadFailed`)}function pp(e,t){let n=e instanceof Error?e.message:``;return n===sf.LegacyXls?t(`grid.import.legacyXls`):n===sf.Unsupported?t(`grid.import.unsupportedFile`):t(`grid.import.parseFailed`)}var mp=({onFileLoaded:e,downloadTemplate:t,objectName:n,objectLabel:r})=>{let{t:i}=Bf(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),p=async()=>{if(t){c(null),f(!0);try{let e=await t();dp(`${xr(i(`grid.import.templateFileName`,{object:r||n||`import`}))||`import-template`}.xlsx`,e)}catch(e){c(fp(e,i))}finally{f(!1)}}},m=(0,Q.useCallback)(t=>t.length<2?(c(i(`grid.import.fileNeedsHeader`)),!1):(e(t[0],t.slice(1)),!0),[e,i]),h=(0,Q.useCallback)(async e=>{c(null),u(!0);try{m(await ff(e))}catch(e){c(pp(e,i))}finally{u(!1)}},[m,i]),g=(0,Q.useCallback)(e=>{let t=e.target;if(t&&/^(input|textarea)$/i.test(t.tagName))return;let n=e.clipboardData;if(!n)return;let r=pf(n.getData(`text/html`)||null,n.getData(`text/plain`)||null);r&&(e.preventDefault(),c(null),m(r))},[m]);return(0,Q.useEffect)(()=>(window.addEventListener(`paste`,g),()=>window.removeEventListener(`paste`,g)),[g]),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-6`,children:[(0,$.jsxs)(`div`,{className:U(`flex w-full flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-10 transition-colors`,a?`border-primary bg-primary/5`:`border-muted-foreground/25`,l&&`pointer-events-none opacity-60`),onDragOver:e=>{e.preventDefault(),o(!0)},onDragLeave:()=>o(!1),onDrop:e=>{e.preventDefault(),o(!1);let t=e.dataTransfer.files[0];t&&h(t)},children:[(0,$.jsx)($i,{className:`h-10 w-10 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(l?`grid.import.parsing`:`grid.import.dragDrop`)}),(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`file`,accept:`.csv,.tsv,.txt,.xlsx,.xlsm`,className:`hidden`,disabled:l,onChange:e=>{let t=e.target.files?.[0];t&&h(t)}}),(0,$.jsx)(G,{variant:`outline`,size:`sm`,asChild:!0,children:(0,$.jsx)(`span`,{children:i(`grid.import.browseFiles`)})})]}),(0,$.jsxs)(`p`,{className:`flex items-center gap-1 text-xs text-muted-foreground/80`,children:[(0,$.jsx)(oi,{className:`h-3.5 w-3.5`}),` `,i(`grid.import.pasteHint`)]})]}),t&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,$.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,disabled:d,onClick:()=>{p()},"data-testid":`import-download-template`,children:[(0,$.jsx)(ui,{className:`mr-1 h-4 w-4`}),` `,i(`grid.import.downloadTemplate`)]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:i(`grid.import.downloadTemplateHint`)})]}),s&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1 text-sm text-destructive`,children:[(0,$.jsx)(ti,{className:`h-4 w-4`}),` `,s]})]})},hp=({templates:e,selectedId:t,onSelect:n,onSaveAs:r,onDelete:i,disabled:a})=>{let{t:o}=Bf(),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border bg-muted/30 p-2`,"data-testid":`import-template-bar`,children:[(0,$.jsx)(zi,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:o(`grid.import.mappingTemplate`)}),(0,$.jsxs)(se,{value:t??`__none__`,onValueChange:e=>e!==`__none__`&&n(e),children:[(0,$.jsx)(D,{className:`h-7 w-48 text-xs`,"data-testid":`import-template-select`,children:(0,$.jsx)(Te,{placeholder:e.length?o(`grid.import.chooseTemplate`):o(`grid.import.noSavedTemplates`)})}),(0,$.jsxs)(ye,{children:[(0,$.jsx)(Nt,{value:`__none__`,disabled:e.length===0,children:e.length?o(`grid.import.noneOption`):o(`grid.import.noSavedTemplates`)}),e.map(e=>(0,$.jsx)(Nt,{value:e.id,children:e.name},e.id))]})]}),l?(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(je,{value:s,onChange:e=>c(e.target.value),placeholder:o(`grid.import.templateName`),className:`h-7 w-40 text-xs`,"data-testid":`import-template-name-input`,autoFocus:!0}),(0,$.jsx)(G,{type:`button`,size:`sm`,onClick:()=>{s.trim()&&(r(s.trim()),c(``),u(!1))},disabled:!s.trim()||a,"data-testid":`import-template-confirm-save`,children:o(`grid.import.save`)}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{u(!1),c(``)},children:o(`grid.import.cancel`)})]}):(0,$.jsx)(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(!0),disabled:a,"data-testid":`import-template-save-btn`,children:o(`grid.import.saveCurrent`)}),t&&(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,"aria-label":o(`grid.import.deleteTemplate`),"data-testid":`import-template-delete-btn`,children:(0,$.jsx)(Yi,{className:`h-3.5 w-3.5`})})]})},gp=({mappings:e,activeName:t,onSelect:n,onClear:r})=>{let{t:i}=Bf();return e.length===0?null:(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border bg-muted/30 p-2`,"data-testid":`import-saved-mapping-bar`,children:[(0,$.jsx)(_i,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:i(`grid.import.savedMapping`)}),(0,$.jsxs)(se,{value:t??`__none__`,onValueChange:e=>e===`__none__`?r():n(e),children:[(0,$.jsx)(D,{className:`h-7 w-56 text-xs`,"data-testid":`import-saved-mapping-select`,children:(0,$.jsx)(Te,{placeholder:i(`grid.import.chooseSavedMapping`)})}),(0,$.jsxs)(ye,{children:[(0,$.jsx)(Nt,{value:`__none__`,children:i(`grid.import.manualMapping`)}),e.map(e=>(0,$.jsx)(Nt,{value:e.name,children:e.label||e.name},e.name))]})]})]})},_p=({mapping:e})=>{let{t}=Bf(),n=Pf(e);return(0,$.jsxs)(`div`,{"data-testid":`import-saved-mapping-summary`,children:[(0,$.jsxs)(`p`,{className:`mb-2 flex items-start gap-2 rounded-md border border-border bg-muted/40 p-3 text-xs text-muted-foreground`,children:[(0,$.jsx)(ti,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:t(`grid.import.savedMappingHint`,{name:e.label||e.name})})]}),(0,$.jsx)(`div`,{className:`max-h-[420px] overflow-auto`,children:(0,$.jsxs)(st,{children:[(0,$.jsx)(ut,{children:(0,$.jsxs)(bt,{children:[(0,$.jsx)(Fe,{children:t(`grid.import.csvColumn`)}),(0,$.jsx)(Fe,{children:t(`grid.import.mapsTo`)}),(0,$.jsx)(Fe,{className:`w-32 text-center`,children:t(`grid.import.transform`)})]})}),(0,$.jsx)(_t,{children:n.map((e,t)=>(0,$.jsxs)(bt,{children:[(0,$.jsx)(q,{className:`font-medium`,children:e.source}),(0,$.jsx)(q,{children:e.target}),(0,$.jsx)(q,{className:`text-center`,children:e.transform?(0,$.jsx)(Qe,{variant:`outline`,className:`text-[10px] font-normal`,children:e.transform}):(0,$.jsx)(tt,{})})]},t))})]})})]})},vp=({headers:e,fields:t,mapping:n,onMappingChange:r,inferredTypes:i,suggestions:a,templates:o,selectedTemplateId:s,onSelectTemplate:c,onSaveTemplate:l,onDeleteTemplate:u,savedMappings:d,activeMapping:f,onSelectSavedMapping:p,onClearSavedMapping:m,missingRequired:h})=>{let{t:g}=Bf(),_=(0,Q.useMemo)(()=>new Set(Object.values(n)),[n]),v=(0,Q.useMemo)(()=>{let e=new Map;return a.forEach(t=>e.set(t.columnIndex,t)),e},[a]),y=(0,Q.useMemo)(()=>{let e=0;return v.forEach((t,r)=>{t.fieldName&&n[r]===t.fieldName&&e++}),e},[v,n]),b=(0,Q.useCallback)((e,t)=>{let i={...n};t===`__skip__`?delete i[e]:i[e]=t,r(i)},[n,r]);return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(gp,{mappings:d,activeName:f?.name??null,onSelect:p,onClear:m}),f?(0,$.jsx)(_p,{mapping:f}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hp,{templates:o,selectedId:s,onSelect:c,onSaveAs:l,onDelete:u,disabled:Object.keys(n).length===0}),y>0&&(0,$.jsxs)(`p`,{className:`mb-2 flex items-center gap-1.5 text-xs text-muted-foreground`,"data-testid":`import-automatch-summary`,children:[(0,$.jsx)(ni,{className:`h-3.5 w-3.5 text-emerald-600`}),g(`grid.import.autoMatchedSummary`,{count:y})]}),(0,$.jsx)(`div`,{className:`max-h-[420px] overflow-auto`,children:(0,$.jsxs)(st,{children:[(0,$.jsx)(ut,{children:(0,$.jsxs)(bt,{children:[(0,$.jsx)(Fe,{children:g(`grid.import.csvColumn`)}),(0,$.jsx)(Fe,{children:g(`grid.import.mapsTo`)}),(0,$.jsx)(Fe,{className:`w-24 text-center`,children:g(`grid.import.status`)})]})}),(0,$.jsx)(_t,{children:e.map((e,r)=>{let a=i[r]??`text`,o=n[r]?t.find(e=>e.name===n[r]):void 0,s=!!o&&!Sf(a,o.type),c=v.get(r),l=c?.fieldName&&n[r]===c.fieldName?c.confidence:null;return(0,$.jsxs)(bt,{children:[(0,$.jsx)(q,{className:`font-medium`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{children:e}),a!==`text`&&(0,$.jsx)(Qe,{variant:`outline`,className:`w-fit text-[10px] font-normal text-muted-foreground`,"data-testid":`import-inferred-${r}`,children:g(`grid.import.type.${a}`)})]})}),(0,$.jsxs)(q,{children:[(0,$.jsxs)(se,{value:n[r]??`__skip__`,onValueChange:e=>b(r,e),children:[(0,$.jsx)(D,{className:`h-8 w-56`,children:(0,$.jsx)(Te,{placeholder:g(`grid.import.skipColumn`)})}),(0,$.jsxs)(ye,{children:[(0,$.jsx)(Nt,{value:`__skip__`,children:g(`grid.import.skip`)}),t.map(e=>(0,$.jsxs)(Nt,{value:e.name,disabled:_.has(e.name)&&n[r]!==e.name,children:[e.label,e.required?` *`:``,e.matchOnly?` ${g(`grid.import.matchOnlyField`)}`:``]},e.name))]})]}),l&&(0,$.jsxs)(`p`,{className:U(`mt-1 flex items-center gap-1 text-[11px]`,Wf[l]),"data-testid":`import-automatch-${r}`,children:[(0,$.jsx)(ni,{className:`h-3 w-3`}),` `,g(`grid.import.autoMatched`),` · `,g(`grid.import.confidence.${l}`)]}),s&&(0,$.jsxs)(`p`,{className:`mt-1 flex items-center gap-1 text-[11px] text-amber-600`,"data-testid":`import-type-warn-${r}`,children:[(0,$.jsx)(ti,{className:`h-3 w-3`}),` `,g(`grid.import.typeMismatch`,{type:g(`grid.import.type.${a}`)})]})]}),(0,$.jsx)(q,{className:`text-center`,children:n[r]?(0,$.jsx)(Qe,{variant:`default`,className:`text-xs`,children:g(`grid.import.mapped`)}):(0,$.jsx)(Qe,{variant:`secondary`,className:`text-xs`,children:g(`grid.import.skipped`)})})]},r)})})]})}),h.length>0&&(0,$.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-md border border-amber-400/40 bg-amber-50 p-3 text-xs text-amber-900 dark:bg-amber-950/30 dark:text-amber-200`,"data-testid":`import-missing-required`,children:[(0,$.jsx)(ti,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:g(`grid.import.missingRequiredHint`,{fields:h.map(e=>e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name).join(`, `)})})]})]})]})},yp=({headers:e,rows:t,mapping:n,fields:r,corrections:i,onCorrect:a})=>{let{t:o}=Bf(),s=(0,Q.useMemo)(()=>Object.entries(n).map(([t,n])=>({csvIdx:Number(t),header:e[Number(t)],field:r.find(e=>e.name===n)})),[n,e,r]),c=t.slice(0,Vf),l=(0,Q.useCallback)((e,t)=>{let n=i[e]?.[t];return n===void 0?c[e]?.[t]??``:n},[i,c]),u=(0,Q.useMemo)(()=>c.map((e,t)=>{let n={};for(let e of s){let r=l(t,e.csvIdx);e.field.required&&!r?n[e.csvIdx]=o(`grid.import.required`):r&&!Yf(r,e.field.type)&&(n[e.csvIdx]=o(`grid.import.invalidType`,{type:e.field.type}))}return n}),[c,s,l,o]),d=u.filter(e=>Object.keys(e).length>0).length,f=Object.keys(i).length;return(0,$.jsxs)(`div`,{className:`max-h-[440px] overflow-auto`,children:[(d>0||f>0)&&(0,$.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 text-xs`,"data-testid":`import-preview-status`,children:[d>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-destructive`,children:[(0,$.jsx)(ti,{className:`h-3.5 w-3.5`}),` `,o(`grid.import.rowsWithErrors`,{count:d})]}),f>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-emerald-600`,children:[(0,$.jsx)(ni,{className:`h-3.5 w-3.5`}),` `,o(`grid.import.rowsCorrected`,{count:f})]}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:o(`grid.import.clickToFix`)})]}),(0,$.jsxs)(st,{children:[(0,$.jsx)(ut,{children:(0,$.jsxs)(bt,{children:[(0,$.jsx)(Fe,{className:`w-12`,children:`#`}),s.map(e=>(0,$.jsx)(Fe,{className:`min-w-[140px] whitespace-nowrap`,children:e.field.label},e.csvIdx))]})}),(0,$.jsx)(_t,{children:c.map((e,t)=>{let n=u[t],r=Object.keys(n).length>0,o=i[t]!==void 0;return(0,$.jsxs)(bt,{className:U(r&&`bg-destructive/5`,!r&&o&&`bg-emerald-50 dark:bg-emerald-950/20`),"data-testid":`import-preview-row-${t}`,children:[(0,$.jsx)(q,{className:`text-xs text-muted-foreground`,children:t+1}),s.map(e=>{let r=l(t,e.csvIdx),o=n[e.csvIdx],s=i[t]?.[e.csvIdx]!==void 0;return(0,$.jsx)(q,{className:U(o&&`text-destructive`,s&&!o&&`text-emerald-600`),title:o,children:(0,$.jsx)(je,{value:r,onChange:n=>a(t,e.csvIdx,n.target.value),className:U(`h-7 px-1 text-xs`,o&&`border-destructive`,s&&!o&&`border-emerald-500`),"data-testid":`import-preview-cell-${t}-${e.csvIdx}`,"aria-invalid":o?`true`:`false`,"aria-label":`${e.field.label} for row ${t+1}`})},e.csvIdx)})]},t)})})]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:o(`grid.import.showingRows`,{shown:c.length,total:t.length})})]})},bp=({fields:e,mapping:t,writeMode:n,onWriteMode:r,matchFields:i,onToggleMatchField:a,createMissingOptions:o,onCreateMissingOptions:s,runAutomations:c,onRunAutomations:l,treatAsHistorical:u,onTreatAsHistorical:d,skipBlankMatchKey:f,onSkipBlankMatchKey:p,showBackground:m,backgroundImport:h,onBackgroundImport:g})=>{let{t:_}=Bf(),v=(0,Q.useMemo)(()=>new Set(Object.values(t)),[t]),y=(0,Q.useMemo)(()=>e.filter(e=>v.has(e.name)),[e,v]),b=n!==`insert`;return(0,$.jsxs)(`div`,{className:`mb-3 rounded-md border bg-muted/30 p-3`,"data-testid":`import-options`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:_(`grid.import.options`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(S,{className:`text-xs`,children:_(`grid.import.writeMode`)}),(0,$.jsxs)(se,{value:n,onValueChange:e=>r(e),children:[(0,$.jsx)(D,{className:`h-8 w-72 text-xs`,"data-testid":`import-writemode-select`,children:(0,$.jsx)(Te,{})}),(0,$.jsxs)(ye,{children:[(0,$.jsx)(Nt,{value:`insert`,children:_(`grid.import.writeModeOpt.insert`)}),(0,$.jsx)(Nt,{value:`update`,children:_(`grid.import.writeModeOpt.update`)}),(0,$.jsx)(Nt,{value:`upsert`,children:_(`grid.import.writeModeOpt.upsert`)})]})]})]}),b&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-testid":`import-matchfields`,children:[(0,$.jsx)(S,{className:`text-xs`,children:_(`grid.import.matchFields`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1.5`,children:[y.length===0&&(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:_(`grid.import.matchFieldsPlaceholder`)}),y.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs`,"data-testid":`import-matchfield-${e.name}`,children:[(0,$.jsx)(O,{checked:i.includes(e.name),onCheckedChange:()=>a(e.name)}),e.label]},e.name))]}),(0,$.jsx)(`p`,{className:U(`text-[11px]`,i.length===0?`text-destructive`:`text-muted-foreground`),children:i.length===0?_(`grid.import.needMatchFields`):_(`grid.import.matchFieldsHint`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,"data-testid":`import-opt-create-options`,children:[(0,$.jsx)(O,{checked:o,onCheckedChange:e=>s(e===!0)}),_(`grid.import.optCreateOptions`)]}),b&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,"data-testid":`import-opt-skip-blank`,children:[(0,$.jsx)(O,{checked:f,onCheckedChange:e=>p(e===!0)}),_(`grid.import.optSkipBlankKey`)]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,"data-testid":`import-opt-run-automations`,children:[(0,$.jsx)(O,{checked:c,onCheckedChange:e=>l(e===!0)}),_(`grid.import.optRunAutomations`)]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,"data-testid":`import-opt-treat-historical`,children:[(0,$.jsx)(O,{checked:u,onCheckedChange:e=>d(e===!0)}),(0,$.jsxs)(`span`,{children:[_(`grid.import.optTreatHistorical`),(0,$.jsx)(`span`,{className:`ml-1 text-[11px] text-muted-foreground`,children:_(`grid.import.optTreatHistoricalHint`)})]})]}),m&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,"data-testid":`import-opt-background`,children:[(0,$.jsx)(O,{checked:h,onCheckedChange:e=>g(e===!0)}),(0,$.jsxs)(`span`,{children:[_(`grid.import.optBackground`),(0,$.jsx)(`span`,{className:`ml-1 text-[11px] text-muted-foreground`,children:_(`grid.import.optBackgroundHint`)})]})]})]})]})]})},xp={pending:`outline`,running:`secondary`,succeeded:`default`,failed:`destructive`,cancelled:`outline`};function Sp(e,t){if(!e)return`—`;let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleString(t)}var Cp=({objectName:e,dataSource:t,t:n})=>{let r=Ir(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),f=t,p=typeof f?.listImportJobs==`function`,m=typeof f?.undoImportJob==`function`,h=(0,Q.useCallback)(async()=>{if(typeof f?.listImportJobs==`function`){s(!0),l(null);try{let t=await f.listImportJobs({object:e,limit:50});a(t)}catch(e){l(e instanceof Error?e.message:String(e)),a([])}finally{s(!1)}}},[f,e]);(0,Q.useEffect)(()=>{h()},[h]);let g=(0,Q.useCallback)(async e=>{if(typeof f?.cancelImportJob==`function`){try{await f.cancelImportJob(e)}catch{}h()}},[f,h]),_=(0,Q.useCallback)(async e=>{if(typeof f?.undoImportJob==`function`&&!(typeof window<`u`&&!window.confirm(n(`grid.import.undoConfirm`)))){d(e),l(null);try{await f.undoImportJob(e)}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(null),h()}}},[f,h,n]);return p?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":`import-history`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`grid.import.historyHint`)}),(0,$.jsx)(G,{variant:`outline`,size:`sm`,onClick:()=>void h(),disabled:o,"data-testid":`import-history-refresh`,children:n(o?`grid.import.historyLoading`:`grid.import.historyRefresh`)})]}),c&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,"data-testid":`import-history-error`,children:c}),i&&i.length===0&&!o&&(0,$.jsx)(`p`,{className:`p-6 text-center text-sm text-muted-foreground`,"data-testid":`import-history-empty`,children:n(`grid.import.historyEmpty`)}),i&&i.length>0&&(0,$.jsxs)(st,{children:[(0,$.jsx)(ut,{children:(0,$.jsxs)(bt,{children:[(0,$.jsx)(Fe,{children:n(`grid.import.historyColStatus`)}),(0,$.jsx)(Fe,{className:`text-right`,children:n(`grid.import.historyColRows`)}),(0,$.jsx)(Fe,{className:`text-right`,children:n(`grid.import.historyColResult`)}),(0,$.jsx)(Fe,{children:n(`grid.import.historyColTime`)}),(0,$.jsx)(Fe,{})]})}),(0,$.jsx)(_t,{children:i.map(e=>(0,$.jsxs)(bt,{"data-testid":`import-history-row-${e.jobId}`,children:[(0,$.jsx)(q,{children:(0,$.jsx)(Qe,{variant:xp[e.status],children:n(`grid.import.jobStatus.${e.status}`)})}),(0,$.jsxs)(q,{className:`text-right tabular-nums`,children:[e.processed,`/`,e.total]}),(0,$.jsxs)(q,{className:`text-right tabular-nums text-xs`,children:[(0,$.jsx)(`span`,{className:`text-emerald-600`,children:n(`grid.import.createdCount`,{count:e.created})}),e.updated>0&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,n(`grid.import.updatedCount`,{count:e.updated})]}),e.skipped>0&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,n(`grid.import.skippedCount`,{count:e.skipped})]}),e.errors>0&&(0,$.jsxs)(`span`,{className:`text-destructive`,children:[` · `,n(`grid.import.errorCount`,{count:e.errors})]})]}),(0,$.jsx)(q,{className:`text-xs text-muted-foreground`,children:Sp(e.completedAt??e.createdAt,r)}),(0,$.jsxs)(q,{className:`text-right`,children:[cp(e.status)&&typeof f?.cancelImportJob==`function`&&(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,onClick:()=>void g(e.jobId),"data-testid":`import-history-cancel-${e.jobId}`,children:[(0,$.jsx)(ta,{className:`mr-1 h-3.5 w-3.5`}),` `,n(`grid.import.cancelImport`)]}),e.revertedAt&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`import-history-reverted-${e.jobId}`,children:n(`grid.import.reverted`)}),lp(e,m)&&(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,onClick:()=>void _(e.jobId),disabled:u===e.jobId,"data-testid":`import-history-undo-${e.jobId}`,children:[(0,$.jsx)(Qi,{className:`mr-1 h-3.5 w-3.5`}),u===e.jobId?n(`grid.import.undoing`):n(`grid.import.undoImport`)]})]})]},e.jobId))})]})]}):(0,$.jsx)(`div`,{className:`p-6 text-center text-sm text-muted-foreground`,"data-testid":`import-history-unsupported`,children:n(`grid.import.historyUnsupported`)})},wp=({objectName:e,objectLabel:t,fields:n,dataSource:r,onComplete:i,onCancel:a,open:o,onOpenChange:s,onErrorMode:c=`skip`,templateStorageKey:l,templateStorage:u,savedMappings:d,initialFile:f,extraOptionsContent:p,renderResultExtra:m})=>{let{t:h}=Bf(),[g,_]=(0,Q.useState)(`upload`),[v,y]=(0,Q.useState)([]),[b,x]=(0,Q.useState)([]),[S,C]=(0,Q.useState)({}),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(0),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)({}),[M,N]=(0,Q.useState)(!1),[ee,te]=(0,Q.useState)(null),[re,F]=(0,Q.useState)(null),I=Q.useRef(!1),[L,ie]=(0,Q.useState)(!1),[z,ae]=(0,Q.useState)(null),[oe,B]=(0,Q.useState)(`insert`),[se,ce]=(0,Q.useState)([]),[le,de]=(0,Q.useState)(!1),[pe,me]=(0,Q.useState)(!0),[V,ge]=(0,Q.useState)(!1),[_e,ve]=(0,Q.useState)(!1),[ye,be]=(0,Q.useState)(!1),H=t??e,xe=(0,Q.useMemo)(()=>new Map(n.map(e=>[e.name,e.label])),[n]),Se=(0,Q.useMemo)(()=>{let e=new Map;for(let[t,n]of Object.entries(S))e.has(n)||e.set(n,Number(t));return e},[S]),Ce=(0,Q.useCallback)((e,t)=>{if(!t)return;let n=Se.get(t);if(n===void 0)return;let r=e-1;return A[r]?.[n]??b[r]?.[n]},[Se,A,b]),we=(0,Q.useMemo)(()=>{let e=r;return typeof e?.createImportJob==`function`&&typeof e?.getImportJobProgress==`function`&&typeof e?.getImportJobResults==`function`},[r]),{can:Te}=He(),Ee=r,De=Ee?.downloadImportTemplate,Oe=typeof De==`function`&&Te(e,`create`)?()=>De.call(Ee,e):void 0,ke=(0,Q.useCallback)(e=>{ce(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]);(0,Q.useEffect)(()=>{let e=new Set(Object.values(S));ce(t=>{let n=t.filter(t=>e.has(t));return n.length===t.length?t:n})},[S]);let Ae=(0,Q.useMemo)(()=>u===void 0?Zf():u,[u]),je=l??`objectui:import-templates:${e}`,[Me,Ne]=(0,Q.useState)(()=>Qf(Ae,je)),[Pe,W]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Ne(Qf(Ae,je))},[Ae,je]);let[Fe,K]=(0,Q.useState)([]),[Ie,Le]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(d)return;let t=!0,n=r?.listImportMappings;if(typeof n!=`function`){K([]);return}return Promise.resolve(n.call(r,e)).then(e=>{t&&K((e??[]).map(Mf).filter(e=>e!==null))}).catch(()=>{t&&K([])}),()=>{t=!1}},[r,e,d]);let Re=d??Fe,ze=(0,Q.useMemo)(()=>Re.find(e=>e.name===Ie)??null,[Re,Ie]),Be=(0,Q.useCallback)(e=>{let t=Re.find(t=>t.name===e);t&&(Le(e),W(null),C(Ff(t,v)),(t.mode===`update`||t.mode===`upsert`)&&B(t.mode),Array.isArray(t.upsertKey)&&ce(t.upsertKey.filter(e=>typeof e==`string`)),ae(null))},[Re,v]),Ve=(0,Q.useCallback)(()=>{Le(null),B(`insert`),ce([]),C(Xf(v,n,b)),ae(null)},[v,n,b]),Ue=(0,Q.useCallback)(e=>{let t=Me.find(t=>t.id===e);t&&(W(e),C(tp(t,v,n)))},[Me,v,n]),We=(0,Q.useCallback)(e=>{let t={id:`tpl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,name:e,mapping:ep(v,S),updatedAt:Date.now()},n=[...Me,t];Ne(n),W(t.id),$f(Ae,je,n)},[Me,v,S,Ae,je]),Ge=(0,Q.useCallback)(()=>{if(!Pe)return;let e=Me.filter(e=>e.id!==Pe);Ne(e),W(null),$f(Ae,je,e)},[Me,Pe,Ae,je]),Ke=(0,Q.useCallback)((e,t,n)=>{j(r=>{let i={...r},a={...i[e]??{}};return n===(b[e]?.[t]??``)?delete a[t]:a[t]=n,Object.keys(a).length===0?delete i[e]:i[e]=a,i})},[b]),qe=(0,Q.useMemo)(()=>{let e=new Set(Object.values(S));return n.filter(t=>t.required&&!e.has(t.name))},[n,S]),Je=(0,Q.useCallback)((e,t)=>{y(e),x(t),C(Xf(e,n,t)),j({}),_(`mapping`)},[n]),Ye=Q.useRef(null);(0,Q.useEffect)(()=>{if(!o||!f||Ye.current===f)return;Ye.current=f;let e=!1;return(async()=>{try{let t=await ff(f);if(e||t.length<2)return;Je(t[0],t.slice(1))}catch{}})(),()=>{e=!0}},[o,f,Je]);let Xe=(0,Q.useMemo)(()=>v.map((e,t)=>xf(b.map(e=>e[t]))),[v,b]),Ze=(0,Q.useMemo)(()=>jf(v,n,b),[v,n,b]),q=(0,Q.useCallback)(()=>{let e=Object.entries(S).map(([e,t])=>({csvIdx:Number(e),field:t}));return b.map((t,n)=>{let r=A[n],i={};for(let n of e){let e=r&&r[n.csvIdx]!==void 0?r[n.csvIdx]:t[n.csvIdx]??``;i[n.field]=e}return i})},[b,S,A]),$e=(0,Q.useCallback)(async()=>{let t=Gf(S,n);if(t.length>0){let e={totalRows:b.length,importedRows:0,skippedRows:b.length,errors:[{row:0,field:t.map(e=>e.name).join(`, `),message:h(`grid.import.legacyReferenceBlocked`,{fields:t.map(e=>e.label||e.name).join(`, `)})}]};k(e),T(!1),i?.(e);return}let a=[],o=0,s=0,l=Object.entries(S).map(([e,t])=>({csvIdx:Number(e),field:n.find(e=>e.name===t)}));for(let t=0;t<b.length;t++){let n=b[t],i=A[t],{record:u,errors:d}=np(i?n.map((e,t)=>i[t]===void 0?e:i[t]):n,l,t+1);if(d.length>0){if(s++,a.push(...d),c===`stop`)break}else try{r?.create&&await r.create(e,u),o++}catch(e){s++;let n=e instanceof Error?e.message:`Failed to create record`;if(a.push({row:t+1,field:``,message:n}),c===`stop`)break}D(Math.round((t+1)/b.length*100))}let u={totalRows:b.length,importedRows:o,skippedRows:s,errors:a,degraded:!0};k(u),T(!1),i?.(u)},[b,S,n,r,e,i,c,A,h]),tt=(0,Q.useCallback)(async t=>{let n=r;if(typeof n?.createImportJob!=`function`||typeof n?.getImportJobProgress!=`function`||typeof n?.getImportJobResults!=`function`)return!1;I.current=!1;let a;try{a=await n.createImportJob(e,t)}catch(e){if(op(e))throw e;if(ap(e))return!1;throw e}te(a.jobId),F({processed:0,total:a.total});let o=new Set([`succeeded`,`failed`,`cancelled`]),s=0;for(;;){if(I.current||(await new Promise(e=>setTimeout(e,Uf)),I.current))return!0;let e;try{e=await n.getImportJobProgress(a.jobId),s=0}catch(e){if(++s>=5)throw e;continue}if(F({processed:e.processed,total:e.total}),D(e.percentComplete),!o.has(e.status))continue;if(e.status===`cancelled`){let t={totalRows:e.total,importedRows:e.created+e.updated,skippedRows:e.skipped+e.errors,createdRows:e.created,updatedRows:e.updated,errors:[],cancelled:!0};return k(t),T(!1),i?.(t),!0}let t=sp(await n.getImportJobResults(a.jobId));return e.status===`failed`&&t.errors.length===0&&t.errors.push({row:0,field:``,message:e.error??`Import failed`}),D(100),k(t),T(!1),i?.(t),!0}},[r,e,i]),nt=(0,Q.useCallback)((e=!1)=>rp(Ie?Nf(v,b,A):q(),{writeMode:oe,matchFields:se,createMissingOptions:le,runAutomations:pe,treatAsHistorical:V,skipBlankMatchKey:_e,dryRun:e,...Ie?{mappingName:Ie}:{}}),[q,Ie,v,b,A,oe,se,le,pe,V,_e]),J=(0,Q.useCallback)(async()=>{T(!0),D(0),I.current=!1,te(null),F(null);let t=nt();if(b.length>Hf||ye)try{if(await tt(t))return}catch(e){if(op(e)){let e={totalRows:b.length,importedRows:0,skippedRows:b.length,errors:[{row:0,field:``,message:h(`grid.import.notAllowed`)}]};k(e),T(!1),i?.(e);return}if(!ap(e)){let t=e instanceof Error?e.message:`Import failed`,n={totalRows:b.length,importedRows:0,skippedRows:b.length,errors:[{row:0,field:``,message:t}]};k(n),T(!1),i?.(n);return}}let n=r?.importRecords;if(typeof n==`function`)try{let a=await n.call(r,e,t),o={totalRows:a.total,importedRows:a.ok,skippedRows:a.skipped+a.errors,createdRows:a.created,updatedRows:a.updated,errors:a.results.filter(e=>!e.ok).map(e=>({row:e.row,field:e.field??``,message:e.error??e.code??`Import failed`,code:e.code})),serverResult:a};D(100),k(o),T(!1),i?.(o);return}catch(e){if(op(e)){let e={totalRows:b.length,importedRows:0,skippedRows:b.length,errors:[{row:0,field:``,message:h(`grid.import.notAllowed`)}]};k(e),T(!1),i?.(e);return}if(!ip(e)){let t=e instanceof Error?e.message:`Import failed`,n={totalRows:b.length,importedRows:0,skippedRows:b.length,errors:[{row:0,field:``,message:t}]};k(n),T(!1),i?.(n);return}}await $e()},[r,e,nt,i,b.length,$e,tt,ye,h]),rt=(0,Q.useCallback)(async()=>{let t=r?.importRecords;if(typeof t==`function`){ie(!0);try{let n=await t.call(r,e,nt(!0));ae(n)}catch(t){if(op(t)){ae({object:e,dryRun:!0,writeMode:oe,total:b.length,ok:0,errors:b.length,created:0,updated:0,skipped:0,results:[{row:0,ok:!1,action:`failed`,error:h(`grid.import.notAllowed`)}]});return}if(!ip(t)){let n=t instanceof Error?t.message:`Validation failed`;ae({object:e,dryRun:!0,writeMode:oe,total:b.length,ok:0,errors:b.length,created:0,updated:0,skipped:0,results:[{row:0,ok:!1,action:`failed`,error:n}]})}}finally{ie(!1)}}},[r,e,nt,oe,b.length,h]);(0,Q.useEffect)(()=>{ae(null)},[S,A,oe,se,le,pe,_e]);let Y=(0,Q.useCallback)(async()=>{I.current=!0;let e=ee,t=r;if(e&&typeof t?.cancelImportJob==`function`)try{await t.cancelImportJob(e)}catch{}let n={totalRows:re?.total??b.length,importedRows:0,skippedRows:0,errors:[],cancelled:!0};k(n),T(!1)},[ee,r,re,b.length]),it=(0,Q.useCallback)(()=>{I.current=!1,_(`upload`),y([]),x([]),C({}),D(0),k(null),j({}),W(null),Le(null),B(`insert`),ce([]),de(!1),me(!0),ve(!1),te(null),F(null),ie(!1),ae(null),N(!1)},[]),X=(0,Q.useCallback)(()=>{if(!O||O.errors.length===0)return;let t=new Map;for(let e of O.errors){if(e.row<1)continue;let n=e.field?`${e.field}: `:``,r=t.get(e.row);t.set(e.row,r?`${r}; ${n}${e.message}`:`${n}${e.message}`)}if(t.size===0)return;let n=up(v,b,S,t);try{let t=new Blob([`\uFEFF${n}`],{type:`text/csv;charset=utf-8`}),r=URL.createObjectURL(t),i=document.createElement(`a`);i.href=r,i.download=`${e}-import-errors.csv`,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}catch{}},[O,v,b,S,e]),at=(0,Q.useCallback)(()=>{it(),s?.(!1),a?.()},[it,s,a]);return(0,$.jsx)(et,{open:o,onOpenChange:e=>{e?s?.(e):at()},children:(0,$.jsxs)(ue,{className:`flex max-h-[85vh] flex-col gap-4 overflow-hidden sm:max-w-4xl`,onInteractOutside:e=>e.preventDefault(),children:[(0,$.jsxs)(P,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pr-6`,children:[(0,$.jsxs)(R,{className:`flex items-center gap-2`,children:[(0,$.jsx)(_i,{className:`h-5 w-5`}),` `,h(`grid.import.title`,{object:H})]}),g===`upload`&&!O&&!w&&typeof r?.listImportJobs==`function`&&(0,$.jsx)(G,{variant:`ghost`,size:`sm`,onClick:()=>N(e=>!e),"data-testid":`import-history-toggle`,children:h(M?`grid.import.historyBack`:`grid.import.history`)})]}),(0,$.jsx)(fe,{children:h(M?`grid.import.historyDescription`:g===`upload`?`grid.import.uploadDescription`:g===`mapping`?`grid.import.mappingDescription`:`grid.import.previewDescription`)})]}),!M&&(0,$.jsx)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[`upload`,`mapping`,`preview`].map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0&&(0,$.jsx)(Vr,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{className:U(`rounded-full px-3 py-1`,g===e?`bg-primary text-primary-foreground`:`bg-muted`),children:[t+1,`. `,h(e===`upload`?`grid.import.stepUpload`:e===`mapping`?`grid.import.stepMapping`:`grid.import.stepPreview`)]})]},e))}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:M?(0,$.jsx)(Cp,{objectName:e,dataSource:r,t:h}):O?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-4`,children:[O.cancelled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ta,{className:`h-10 w-10 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-lg font-semibold`,children:h(`grid.import.importCancelled`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ni,{className:`h-10 w-10 text-green-500`}),(0,$.jsx)(`p`,{className:`text-lg font-semibold`,children:h(`grid.import.importComplete`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[O.createdRows!==void 0||O.updatedRows!==void 0?(0,$.jsxs)($.Fragment,{children:[(O.createdRows??0)>0&&(0,$.jsx)(Qe,{variant:`default`,children:h(`grid.import.createdCount`,{count:O.createdRows})}),(O.updatedRows??0)>0&&(0,$.jsx)(Qe,{variant:`default`,children:h(`grid.import.updatedCount`,{count:O.updatedRows})}),(O.createdRows??0)===0&&(O.updatedRows??0)===0&&(0,$.jsx)(Qe,{variant:`default`,children:h(`grid.import.imported`,{count:O.importedRows})})]}):(0,$.jsx)(Qe,{variant:`default`,children:h(`grid.import.imported`,{count:O.importedRows})}),O.skippedRows>0&&(0,$.jsx)(Qe,{variant:`destructive`,children:h(`grid.import.skippedCount`,{count:O.skippedRows})})]}),O.degraded&&!O.cancelled&&(0,$.jsxs)(`div`,{className:`flex w-full items-start gap-2 rounded-md border border-amber-400/40 bg-amber-50 p-3 text-xs text-amber-900 dark:bg-amber-950/30 dark:text-amber-200`,"data-testid":`import-degraded-notice`,children:[(0,$.jsx)(ti,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:h(`grid.import.legacyFallbackNotice`)})]}),m&&(0,$.jsx)(`div`,{className:`w-full`,"data-testid":`import-result-extra`,children:m(O)}),O.errors.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`max-h-32 w-full overflow-auto rounded border p-2 text-xs`,children:[O.errors.slice(0,10).map((e,t)=>{let{fieldLabel:n,message:r}=qf({field:e.field,error:e.message,code:e.code},xe,Ce(e.row,e.field),h);return(0,$.jsxs)(`p`,{className:`text-destructive`,children:[e.row>=1?h(`grid.import.errorRowPrefix`,{row:e.row}):``,n?`${n}: `:``,r]},t)}),O.errors.length>10&&(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:h(`grid.import.moreErrors`,{count:O.errors.length-10})})]}),O.errors.some(e=>e.row>=1)&&(0,$.jsxs)(G,{variant:`outline`,size:`sm`,onClick:X,"data-testid":`import-download-failed`,children:[(0,$.jsx)(ui,{className:`mr-1 h-4 w-4`}),` `,h(`grid.import.downloadFailed`)]})]}),O.resultsTruncated&&(0,$.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:h(`grid.import.resultsTruncated`,{count:O.errors.length,total:O.skippedRows})})]}):(0,$.jsxs)($.Fragment,{children:[g===`upload`&&(0,$.jsx)(mp,{onFileLoaded:Je,downloadTemplate:Oe,objectName:e,objectLabel:H}),g===`mapping`&&(0,$.jsx)(vp,{headers:v,fields:n,mapping:S,onMappingChange:C,inferredTypes:Xe,suggestions:Ze,templates:Me,selectedTemplateId:Pe,onSelectTemplate:Ue,onSaveTemplate:We,onDeleteTemplate:Ge,savedMappings:Re,activeMapping:ze,onSelectSavedMapping:Be,onClearSavedMapping:Ve,missingRequired:qe}),g===`preview`&&(0,$.jsxs)($.Fragment,{children:[p&&(0,$.jsx)(`div`,{"data-testid":`import-extra-options`,children:p}),!ze&&(0,$.jsx)(bp,{fields:n,mapping:S,writeMode:oe,onWriteMode:B,matchFields:se,onToggleMatchField:ke,createMissingOptions:le,onCreateMissingOptions:de,runAutomations:pe,onRunAutomations:me,treatAsHistorical:V,onTreatAsHistorical:ge,skipBlankMatchKey:_e,onSkipBlankMatchKey:ve,showBackground:we&&b.length<=Hf,backgroundImport:ye,onBackgroundImport:be}),ze&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-start gap-2 rounded-md border border-border bg-muted/40 p-3 text-xs text-muted-foreground`,"data-testid":`import-saved-mapping-preview-note`,children:[(0,$.jsx)(ti,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:h(`grid.import.savedMappingPreviewNote`,{name:ze.label||ze.name})})]}),(0,$.jsx)(yp,{headers:v,rows:b,mapping:S,fields:n,corrections:A,onCorrect:Ke}),b.length>Hf&&(0,$.jsxs)(`div`,{className:`mt-2 flex items-start gap-2 rounded-md border border-border bg-muted/40 p-3 text-xs text-muted-foreground`,"data-testid":`import-large-sample-notice`,children:[(0,$.jsx)(ti,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsxs)(`span`,{children:[h(`grid.import.largeSampleNotice`,{shown:Vf,total:b.length}),` `,h(`grid.import.asyncLargeHint`)]})]}),b.length<=Hf&&typeof r?.importRecords==`function`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border p-3`,"data-testid":`import-validate`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`grid.import.validateHint`)}),(0,$.jsx)(G,{variant:`outline`,size:`sm`,onClick:rt,disabled:L,"data-testid":`import-validate-btn`,children:h(L?`grid.import.validating`:`grid.import.validate`)})]}),z&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,"data-testid":`import-validate-result`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium ${z.errors>0?`text-destructive`:`text-emerald-600`}`,children:z.errors>0?h(`grid.import.validateFailed`,{ok:z.ok,errors:z.errors}):h(`grid.import.validatePassed`,{ok:z.ok})}),z.errors>0&&(0,$.jsx)(`ul`,{className:`max-h-32 overflow-auto text-xs text-destructive`,children:z.results.filter(e=>!e.ok).slice(0,20).map((e,t)=>{let{fieldLabel:n,message:r}=qf(e,xe,Ce(e.row,e.field),h);return(0,$.jsxs)(`li`,{children:[e.row>0?h(`grid.import.errorRowPrefix`,{row:e.row}):``,n?`${n}: `:``,r]},t)})})]})]})]}),w&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,$.jsx)(ne,{value:E,className:`h-2 w-full`}),(0,$.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:ee?re?h(`grid.import.asyncProcessing`,{processed:re.processed,total:re.total,progress:E}):h(`grid.import.asyncQueued`):h(`grid.import.importing`,{progress:E})}),ee&&typeof r?.cancelImportJob==`function`&&(0,$.jsxs)(G,{variant:`outline`,size:`sm`,onClick:Y,"data-testid":`import-cancel-async`,children:[(0,$.jsx)(ta,{className:`mr-1 h-4 w-4`}),` `,h(`grid.import.cancelImport`)]})]})]})}),(0,$.jsx)(he,{className:`gap-2 sm:gap-0`,children:M?(0,$.jsxs)(G,{variant:`outline`,onClick:()=>N(!1),children:[(0,$.jsx)(zr,{className:`mr-1 h-4 w-4`}),` `,h(`grid.import.historyBack`)]}):O?(0,$.jsx)(G,{onClick:at,"data-testid":`import-close-btn`,children:h(`grid.import.close`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{variant:`ghost`,onClick:at,disabled:w,children:[(0,$.jsx)(ta,{className:`mr-1 h-4 w-4`}),` `,h(`grid.import.cancel`)]}),(g===`mapping`||g===`preview`)&&(0,$.jsxs)(G,{variant:`outline`,onClick:()=>_(g===`mapping`?`upload`:`mapping`),disabled:w,children:[(0,$.jsx)(zr,{className:`mr-1 h-4 w-4`}),` `,h(`grid.import.back`)]}),g===`mapping`&&(0,$.jsxs)(G,{onClick:()=>_(`preview`),disabled:Ie?!1:Object.keys(S).length===0||qe.length>0,"data-testid":`import-next-btn`,children:[h(`grid.import.next`),` `,(0,$.jsx)(Vr,{className:`ml-1 h-4 w-4`})]}),g===`preview`&&(0,$.jsx)(G,{onClick:J,disabled:w||!Ie&&oe!==`insert`&&se.length===0,"data-testid":`import-run-btn`,children:w?h(`grid.import.importingProgress`):h(`grid.import.importNRows`,{count:b.length})})]})})]})})},Tp=t({ImportWizard:()=>wp,ObjectGrid:()=>tf,ObjectGridRenderer:()=>Op,parseSpreadsheetFile:()=>ff}),Ep={columns:!0,filter:!0,sort:!0,limit:`pagination.pageSize`},Dp=(e,t)=>Array.isArray(t)||e?.bind!=null||e?.data?.provider===`value`||e?.staticData!=null?!1:typeof e?.objectName==`string`&&e.objectName.length>0,Op=Ft(({schema:e,...t})=>{let{dataSource:n,...r}=t,i=hr(n);return(0,$.jsx)(Tr,{schema:e,mapping:Ep,dataSource:i,testId:`object-grid`,errorTitle:`This grid’s data source could not be resolved`,requiresDataSource:Dp(e,r.data),noDataSourceMessage:Jn(`object-grid`,e?.objectName),children:e=>(0,$.jsx)(tf,{schema:e,...r,dataSource:i})})}),kp=[{name:`objectName`,type:`string`,description:"Object this grid lists. Not required: the node's `dataSource` binding can name the object instead, and `dataSource.object` lands on this key, outranking an authored value. With neither, and no inline `data` rows, the grid shows an error saying an object name is required and fetches nothing."},{name:`columns`,type:`array`,description:'Columns to show, either field names (`["name", "email"]`) or column objects (`[{ field: "name", label: "Full Name", width: 200 }]`). The canonical spelling — the deprecated `fields` is only read when this is absent.'},{name:`filter`,type:`array`,description:"Filter criteria in JSON-rules form. The canonical spelling — the deprecated `defaultFilters` is only read when this is absent."},{name:`label`,type:[`string`,`object`],description:'Grid label, used as the table caption, as the export file title and in the record-detail overlay heading. The canonical spelling — the deprecated `title` is only read when this is absent. Accepts either a plain string or an inline per-locale map (`{ en: "Accounts", "zh-CN": "客户" }`) — the `I18nLabel` union the contract admits on this key — and the grid resolves the map against the display locale (the workspace\'s regional default when one is configured, otherwise the active UI language), falling back through base language, a region-qualified sibling, `default`, then `en`, and finally to any remaining entry.'},{name:`description`,type:[`string`,`object`],description:'One line of help text drawn above the grid\'s rows, in muted type. Accepts either a plain string or an inline per-locale map (`{ en: "Everyone you work with", "zh-CN": "你的所有联系人" }`) — the `I18nLabel` union the contract admits on this key — resolved against the display locale the way `label` is. A map with no usable entry draws no line.'},{name:`sort`,type:`array`,description:"Initial sort order, `[{ field, order }]`. The only sort spelling this block reads — the retired single-sort `defaultSort` is refused by the protocol and ignored by the renderer."},{name:`pagination`,type:`object`,description:"Pagination config, `{ pageSize, pageSizeOptions, … }`. Presence enables paging with the object's settings, and an explicit off wins — the deprecated flat `showPagination: false` turns paging off even beside this object, because this object declares no off switch of its own. Prefer it over the deprecated flat `pageSize` / `showPagination` pair."},{name:`searchableFields`,type:`array`,of:`string`,description:"Fields the toolbar search box queries. A non-empty list is what enables search — prefer it over the deprecated boolean `showSearch`, which cannot say WHICH fields to search."},{name:`data`,type:`object`,description:'Data source configuration — a `ViewData` object discriminated by `provider`: `{ provider: "object", object }` (what an omitted `data` falls back to, using `objectName`), `{ provider: "api", read, write }`, `{ provider: "value", items: [...] }` for inline rows that bypass the object query, or `{ provider: "schema", schemaId }`. The canonical spelling — the deprecated `staticData` is the array-only shortcut for the `value` provider, so inline rows go under `items` here rather than in a bare array.'},{name:`rowHeight`,type:`enum`,enum:[`compact`,`short`,`medium`,`tall`,`extra_tall`],description:"Row density. An unrecognised value falls back to `compact` rather than erroring."},{name:`frozenColumns`,type:`number`,description:`How many leading columns stay pinned while the grid scrolls horizontally.`},{name:`resizable`,type:`boolean`,description:"Let users drag column borders to resize. The canonical spelling — the deprecated `resizableColumns` is only read when this is absent."},{name:`reorderableColumns`,type:`boolean`,description:`Let users drag columns into a different order.`},{name:`showColumnTypeIcons`,type:`boolean`,description:`Show a field-type icon in each column header. Off by default — the type is usually obvious from the cell content, and the icons compete with the column labels.`},{name:`rowColor`,type:`object`,description:`Rules that colour whole rows from a field value.`},{name:`conditionalFormatting`,type:`array`,description:"Row style rules, each `{ condition, style }` — a CEL `condition` over the row’s own `record.*` and a CSS `style` map, the rule a list view declares. The first matching rule styles that row. The native `{ field, operator, value }` rule, its `expression`, and a colour written beside `condition` instead of inside `style` are retired (objectui#11533)."},{name:`emptyState`,type:`object`,description:"What the grid draws in place of an empty table, `{ title, message, icon }`: a Lucide `icon` name, a `title` (default: the table's own \"No results found\") and a `message` (default: none). `title` and `message` each accept a plain string or an inline per-locale map, resolved against the display locale. Not drawn when a term typed into the grid's own server-side search box is what emptied it — the table and its search box stay, so the term can be cleared. Leave it out and an empty grid draws the table's own empty row."},{name:`grouping`,type:`object`,description:`Group rows by one or more fields into collapsible sections.`},{name:`aggregations`,type:`array`,description:'Per-group roll-ups shown in group headers, `[{ field, type: "sum" | "count" | "avg" | "min" | "max" | "count_distinct" }]`. Needs `grouping` to have anything to roll up.'},{name:`selection`,type:`object`,description:'Selection config, `{ type: "none" | "single" | "multiple" }`. Presence enables selection — an object with no `type` selects multiple rows — and an explicit off wins: `type: "none"` turns selection off even beside a declared `bulkActions`. The canonical spelling — the deprecated boolean/string `selectable` is only read when this is absent.'},{name:`rowActions`,type:`array`,description:`Names of actions offered on each row’s menu.`},{name:`bulkActions`,type:`array`,description:"Names of actions offered once rows are selected. Needs a multi-row `selection` to be reachable."},{name:`batchActions`,type:`array`,description:"Legacy alias of `bulkActions`, and the one the renderer reads FIRST when both are set. Prefer `bulkActions` in new schemas."},{name:`bulkActionDefs`,type:`array`,description:"Full inline bulk-action definitions, for actions that are not named entries in the object’s action set. Use `bulkActions` when the action already exists."},{name:`editable`,type:`boolean`,description:`Enable inline cell editing (double-click or Enter opens a cell).`},{name:`singleClickEdit`,type:`boolean`,description:"With `editable`, a single click opens the cell instead of a double-click. Has no effect on a non-editable grid."},{name:`keyboardNavigation`,type:`boolean`,description:"Arrow-key cell navigation on the WAI-ARIA grid pattern: the grid's data cells take one place in the Tab order instead of one each (a link or button inside a cell keeps its own), and the arrow keys move focus between them (Home / End to the ends of the row, Ctrl+Home / Ctrl+End to the ends of the page). Enter still opens an editable cell, and an edit ended with Enter or Escape returns focus to its cell. Defaults to on when the grid renders editable; a read-only grid keeps every cell its own Tab stop unless this is `true`, and `false` turns it off on an editable grid."},{name:`navigation`,type:`object`,description:'What a row click does, `{ mode: "page" | "drawer" | "modal" | "split" | "none", … }`.'},{name:`operations`,type:`object`,description:"Toggles for the built-in create/read/update/delete/export/import affordances, e.g. `{ delete: false }`."},{name:`exportOptions`,type:`object`,description:"Export config, `{ formats, maxRecords, includeHeaders, fileNamePrefix, streaming }`. `streaming` (default true) picks server-side streaming vs browser-side assembly for the export — a behaviour fork, not decoration; set it to `false` to force browser-side assembly. Needs `operations.export` to be reachable from the toolbar."}];Z.register(`object-grid`,Op,{namespace:`plugin-grid`,label:`Object Grid`,category:`plugin`,inputs:kp.map(e=>({...e}))}),Z.register(`grid`,Op,{namespace:`view`,skipFallback:!0,label:`Data Grid`,category:`view`,inputs:kp.map(e=>({...e}))});export{Sa as _,Tl as a,Cl as c,Mc as d,_s as f,Ca as g,Fo as h,El as i,yl as l,ss as m,wp as n,wl as o,ds as p,tf as r,Sl as s,Tp as t,kc as u,ga as v};
|