@objectstack/console 17.5.0 → 17.6.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 +378 -0
- package/dist/.objectstack-injection.json +2 -2
- package/dist/.objectui-sha +1 -1
- package/dist/assets/{ActionResultDialog-CLdIyOW6.js → ActionResultDialog-4kHDGnT3.js} +3 -3
- package/dist/assets/{AiPendingActionsPage-OKYz66yR.js → AiPendingActionsPage-JjOddm0h.js} +1 -1
- package/dist/assets/{ApiConsolePage-CcrKovu8.js → ApiConsolePage-BgS26lbp.js} +1 -1
- package/dist/assets/AppDocsIndex-BDoH5ECM.js +1 -0
- package/dist/assets/{AppManagementPage-D_xz8cTZ.js → AppManagementPage-CCgKmNTj.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-C6S1vk0X.js +1 -0
- package/dist/assets/AuditLogPage-v2dKXMuk.js +1 -0
- package/dist/assets/BookPage-DwFMcTSN.js +1 -0
- package/dist/assets/{ComponentNavView-BxsixSU9.js → ComponentNavView-B5g9c6fx.js} +1 -1
- package/dist/assets/{CreateViewDialog-xyKlpLEW.js → CreateViewDialog-D3l-tYHM.js} +1 -1
- package/dist/assets/DashboardView-BOcovpPd.js +1 -0
- package/dist/assets/DocPage-B6AkH5WI.js +1 -0
- package/dist/assets/{DocsIndex-B2zw_HAp.js → DocsIndex-DwW2QsYY.js} +1 -1
- package/dist/assets/{DocsLayout-DezZ8x7_.js → DocsLayout-D63StSgd.js} +1 -1
- package/dist/assets/DocsSlug-CP9fcabi.js +1 -0
- package/dist/assets/ExpressionProvider-CrL6jhVq.js +1 -0
- package/dist/assets/{FlowRunsPage-CvY3nJMF.js → FlowRunsPage-CxdaiUyk.js} +1 -1
- package/dist/assets/{IntegrationsPage-2leVkVDH.js → IntegrationsPage-DvG0x0Nb.js} +2 -2
- package/dist/assets/{InterfaceListPage-BdECC_i3.js → InterfaceListPage-C4wPYohR.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-EPPHSitW.js → MarketplaceInstalledPage-B7KETQG2.js} +1 -1
- package/dist/assets/MarketplacePackagePage-CfgKDpNH.js +4 -0
- package/dist/assets/{MarketplacePage-BnQKykgv.js → MarketplacePage-DNEyU5AE.js} +1 -1
- package/dist/assets/{MetadataInspector-BWxLkr0O.js → MetadataInspector-EP0I3-Kq.js} +1 -1
- package/dist/assets/{ObjectDataPage-BIzp65Mo.js → ObjectDataPage-CykEm9MD.js} +1 -1
- package/dist/assets/PageView-C6u86tni.js +1 -0
- package/dist/assets/{ProfilePage-D2qGgxPK.js → ProfilePage-C3SjXMzi.js} +1 -1
- package/dist/assets/{PublicFormsPage-DlE6tck_.js → PublicFormsPage-D3uCTR-8.js} +1 -1
- package/dist/assets/RecordDetailView-DgR_zhP4.js +3 -0
- package/dist/assets/RecordFormPage-kiJI-ieF.js +1 -0
- package/dist/assets/ReportDefaultInspector-BIinF0EQ.js +1 -0
- package/dist/assets/{ReportView-GIdKJdOt.js → ReportView-BREO-ADE.js} +1 -1
- package/dist/assets/{RuntimeDraftBar-BbMdi3Kp.js → RuntimeDraftBar-BCWfd2yS.js} +1 -1
- package/dist/assets/SchemaForm-C4uMMZ13.js +3 -0
- package/dist/assets/SearchResultsPage-C6Hw_Lpn.js +1 -0
- package/dist/assets/{SettingsHub-BGKIj-Zq.js → SettingsHub-DP1mrzEN.js} +1 -1
- package/dist/assets/SettingsView-u7mc6pcc.js +1 -0
- package/dist/assets/{SkeletonDetail-C8fMI-Mu.js → SkeletonDetail-DIwlbHTr.js} +1 -1
- package/dist/assets/{af-BfSmLD34.js → af-DPUgkQl0.js} +1 -1
- package/dist/assets/ai-DPBykF2N.js +3 -0
- package/dist/assets/{app-shell-eager-leaves-CDVclng4.js → app-shell-eager-leaves-Cf2bM6uT.js} +1 -1
- package/dist/assets/{ar-B9ttrM75.js → ar-B-6GTIRU.js} +1 -1
- package/dist/assets/{ar-DZ-C1rn-cyl.js → ar-DZ-wEl298ti.js} +1 -1
- package/dist/assets/{ar-EG-BaDxKP_o.js → ar-EG-YBT90_S0.js} +1 -1
- package/dist/assets/{ar-MA-DbxNEcmd.js → ar-MA-3uT-EYh6.js} +1 -1
- package/dist/assets/{ar-SA-DeC5LXcX.js → ar-SA-SiQsjhhc.js} +1 -1
- package/dist/assets/{ar-TN-C9KpTFJz.js → ar-TN-CfzXjKzS.js} +1 -1
- package/dist/assets/{az-cMerDwRO.js → az-BqAfcNza.js} +1 -1
- package/dist/assets/{be-ZTSbszQh.js → be-CQgWXa9_.js} +1 -1
- package/dist/assets/{be-tarask-BXZEUrgX.js → be-tarask-BmNg0Sir.js} +1 -1
- package/dist/assets/{bg-BDogpmn5.js → bg-D3evgRuS.js} +1 -1
- package/dist/assets/{bn-Cz04uxmh.js → bn-uItkARwm.js} +1 -1
- package/dist/assets/{bs-CpFnCl-j.js → bs-DueReOpO.js} +1 -1
- package/dist/assets/{ca-CHC4M52Z.js → ca-Cr3AHktR.js} +1 -1
- package/dist/assets/{ckb-Dxw-RNm8.js → ckb-CTi5BET7.js} +1 -1
- package/dist/assets/contracts-DieHW666.js +1 -0
- package/dist/assets/{createDerive-DvA_JGNq.js → createDerive-CjN1i5vn.js} +1 -1
- package/dist/assets/{cs-DsFaJ5Z7.js → cs-43mFX9jr.js} +1 -1
- package/dist/assets/{cy-FH4JFDTs.js → cy-BBSkg3F8.js} +1 -1
- package/dist/assets/{da-D1pVjaAq.js → da-C5oA5qcs.js} +1 -1
- package/dist/assets/data-adapter-Cymvlczj.js +1 -0
- package/dist/assets/{de-AT-DUMQCisj.js → de-AT-CApxwJzu.js} +1 -1
- package/dist/assets/{de-DKrxSvnP.js → de-CPtbLlAf.js} +1 -1
- package/dist/assets/default-inspector-registry-Bs6GBn00.js +1 -0
- package/dist/assets/dist-BF-ssUpn.js +14 -0
- package/dist/assets/{el-l3-bHySV.js → el-Dto2xBQU.js} +1 -1
- package/dist/assets/en-AU-FVwCiDJO.js +1 -0
- package/dist/assets/{en-CA-DGH5NF0a.js → en-CA-DKuJPN1U.js} +1 -1
- package/dist/assets/en-GB-DQ_y5VbJ.js +1 -0
- package/dist/assets/en-IE-DaXOhsZW.js +1 -0
- package/dist/assets/en-IN-CnRZnAom.js +1 -0
- package/dist/assets/en-NZ-CBZLEToK.js +1 -0
- package/dist/assets/en-ZA-BE59v0wZ.js +1 -0
- package/dist/assets/{eo-CL6CXHZx.js → eo-BL8JXIWd.js} +1 -1
- package/dist/assets/{es-BIJ0rksI.js → es-BnoaNxsu.js} +1 -1
- package/dist/assets/{et-BGgMzjm1.js → et-tPYLNenO.js} +1 -1
- package/dist/assets/{eu-CqvAoRrX.js → eu-CUBG6bT0.js} +1 -1
- package/dist/assets/{fa-IR-DNz3oA1-.js → fa-IR-Rr2d9xSs.js} +1 -1
- package/dist/assets/{fi-DNSfKWuW.js → fi-B0NVIZsV.js} +1 -1
- package/dist/assets/{formatLong-CHb9WA3O.js → formatLong-1-gt9bpo.js} +1 -1
- package/dist/assets/{fr-DYRJCirJ.js → fr-BbhHek8e.js} +1 -1
- package/dist/assets/{fr-CA-CotiswPx.js → fr-CA-CBDvLXFg.js} +1 -1
- package/dist/assets/{fr-CH-CpiEYWpc.js → fr-CH-WPNmwPn7.js} +1 -1
- package/dist/assets/framework-DFR4HNtj.js +35 -0
- package/dist/assets/{fy-B69yM3FE.js → fy-DvOBbvEF.js} +1 -1
- package/dist/assets/{gd-BAy8AsX6.js → gd-BQPiTPX5.js} +1 -1
- package/dist/assets/getIcon-Cfwf-Egt.js +1 -0
- package/dist/assets/{gl-soLn_weL.js → gl-BJCXK8uO.js} +1 -1
- package/dist/assets/{gu-B19Yo9yC.js → gu-CctPRz3V.js} +1 -1
- package/dist/assets/{he-DYTPo33p.js → he-CVFMk6p2.js} +1 -1
- package/dist/assets/{hi-D2dIK7Oy.js → hi-Ba30-RwS.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-CExufvVt.js → highlighted-body-OFNGDK62-BQ57IrBV.js} +1 -1
- package/dist/assets/{hr-BV-VOPMu.js → hr-BZUqTbZs.js} +1 -1
- package/dist/assets/{ht-C7MM4qkS.js → ht-BLe05tPx.js} +1 -1
- package/dist/assets/{hu-Rha1m2Ym.js → hu-2CQ_Mkww.js} +1 -1
- package/dist/assets/{hy-CiTNgbdV.js → hy-CclcPG4H.js} +1 -1
- package/dist/assets/i18n-BnUsCaSC.js +17 -0
- package/dist/assets/i18n-locale-ar-92O_xtDZ.js +4 -0
- package/dist/assets/i18n-locale-de-T5ic3yH9.js +4 -0
- package/dist/assets/i18n-locale-en-rxr7WJYl.js +4 -0
- package/dist/assets/i18n-locale-es-D_WOifJ_.js +4 -0
- package/dist/assets/i18n-locale-fr-3cvyjMkp.js +4 -0
- package/dist/assets/i18n-locale-ja-DXlIkB8I.js +4 -0
- package/dist/assets/i18n-locale-ko-DngRpS45.js +4 -0
- package/dist/assets/i18n-locale-pt-BkPaFCqZ.js +4 -0
- package/dist/assets/i18n-locale-ru-E5wLh-y6.js +4 -0
- package/dist/assets/i18n-locale-zh-BL4_Yand.js +4 -0
- package/dist/assets/{i18n-runtime-CTgAQF4N.js → i18n-runtime-97_bDVjP.js} +1 -1
- package/dist/assets/{id-Cijsfjt-.js → id-6JLB8s-f.js} +1 -1
- package/dist/assets/index-Cadlh4t_.css +2 -0
- package/dist/assets/index-D98sa5GF.js +20 -0
- package/dist/assets/{infrastructure-BHSync5f.js → infrastructure-Cc34lEqb.js} +2 -2
- package/dist/assets/integration-CeAF4JFT.js +1 -0
- package/dist/assets/{is-xS1WTyeC.js → is-to0CWzm1.js} +1 -1
- package/dist/assets/isSameWeek-DBXaA1Gd.js +1 -0
- package/dist/assets/{it-CH-l516ZNXj.js → it-CH-DhdfjP5Z.js} +1 -1
- package/dist/assets/{it-C2i_c9sd.js → it-ea0B8Ujp.js} +1 -1
- package/dist/assets/{ja-D9_ewLny.js → ja-B1bzkgDW.js} +1 -1
- package/dist/assets/{ja-Hira-D_6ExgHw.js → ja-Hira-CMrY5hXO.js} +1 -1
- package/dist/assets/{ka-BYHGyees.js → ka-DKSXLnXP.js} +1 -1
- package/dist/assets/{kk-CbTFtuqb.js → kk-DHwMv8Dn.js} +1 -1
- package/dist/assets/{km-Dr2gwhIn.js → km-tpLG1xNr.js} +1 -1
- package/dist/assets/{kn-CprH8JD7.js → kn-MLreVnHA.js} +1 -1
- package/dist/assets/{ko-CsFS2u5i.js → ko-CI0DBazn.js} +1 -1
- package/dist/assets/{lb-CbFKN7Ob.js → lb-CmL572Xe.js} +1 -1
- package/dist/assets/{lt-Bq0xkLp0.js → lt-DRtUOLdw.js} +1 -1
- package/dist/assets/{lv-Cj6vg6Qo.js → lv-COSHgkOP.js} +1 -1
- package/dist/assets/{match-C_jFGO9e.js → match-B-ergJQb.js} +1 -1
- package/dist/assets/{match-CiPp9BME.js → match-BQoOW8Cj.js} +1 -1
- package/dist/assets/{match-Co4ivumx.js → match-dfBS0YSQ.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-Bb17TtNP.js +1 -0
- package/dist/assets/metadata-admin-CABUxbJl.js +9 -0
- package/dist/assets/{mk-MXFM99YL.js → mk-B0IH_YL_.js} +1 -1
- package/dist/assets/{mn-D5Q9B6Jt.js → mn-P-QdQ2n3.js} +1 -1
- package/dist/assets/{ms-CCzPRldx.js → ms-CtyEOINy.js} +1 -1
- package/dist/assets/{mt-mjJpN6xW.js → mt-DfuZ2HRm.js} +1 -1
- package/dist/assets/{nb-BIlNqdEb.js → nb-2Hp-5Tnt.js} +1 -1
- package/dist/assets/{nl-BE-FwXjQsmV.js → nl-BE-mmxbfNoR.js} +1 -1
- package/dist/assets/{nl-D2uBtIxG.js → nl-CZ_nLREz.js} +1 -1
- package/dist/assets/{nn-B0loJ7SV.js → nn-ccWhYsNa.js} +1 -1
- package/dist/assets/{oc-U7-yH1sO.js → oc-z504BFRV.js} +1 -1
- package/dist/assets/{pl-mTy0JYgi.js → pl-DeQ7ASt-.js} +1 -1
- package/dist/assets/plugin-calendar-Cn5HaZU8.js +1 -0
- package/dist/assets/plugin-charts-B6RcFWbo.js +7 -0
- package/dist/assets/plugin-chatbot-Ck47EhDX.js +122 -0
- package/dist/assets/plugin-dashboard-DjEx8e5Y.js +6 -0
- package/dist/assets/plugin-form-CLDvL0up.js +1 -0
- package/dist/assets/plugin-gantt-CrVrxVdi.js +63 -0
- package/dist/assets/plugin-grid-D2rmQEW_.js +11 -0
- package/dist/assets/plugin-kanban-BUNHFfIC.js +1 -0
- package/dist/assets/plugin-map-y-7RQQC5.js +1 -0
- package/dist/assets/{plugin-markdown-D1nTQc1T.js → plugin-markdown-BOkHcir_.js} +1 -1
- package/dist/assets/plugin-report-mT3jpna0.js +59 -0
- package/dist/assets/plugin-timeline-B1EF83D3.js +1 -0
- package/dist/assets/plugin-tree-MTHUt3_S.js +1 -0
- package/dist/assets/plugin-view-DHJI-ahf.js +1 -0
- package/dist/assets/plugins-views-CfkgqD30.js +3 -0
- package/dist/assets/{pt-BR-2KtO5Js1.js → pt-BR-D80_lPYF.js} +1 -1
- package/dist/assets/{pt-Bet5OOQf.js → pt-CJJ1RmXd.js} +1 -1
- package/dist/assets/{ro-37U6sgzi.js → ro-EuFb2TCj.js} +1 -1
- package/dist/assets/{ru-CyuAY-5E.js → ru-CMaVQScp.js} +1 -1
- package/dist/assets/{runtime-metadata-persistence-afAW-MeD.js → runtime-metadata-persistence-ClOTznqa.js} +1 -1
- package/dist/assets/{se-DeJabuC6.js → se-DsfdKLdF.js} +1 -1
- package/dist/assets/{sk-DWEpjfkR.js → sk-BNV9omI8.js} +1 -1
- package/dist/assets/{sl-4oSvNhIR.js → sl-DJS_nINU.js} +1 -1
- package/dist/assets/{sq-BjkBCaXW.js → sq-HEgjcbHe.js} +1 -1
- package/dist/assets/{sr-Dxm1DsRS.js → sr-CO0CFu4X.js} +1 -1
- package/dist/assets/{sr-Latn-Dawg6oP2.js → sr-Latn-eE1Idzey.js} +1 -1
- package/dist/assets/{src-C8NYjdVm.js → src-BU7L2v4J.js} +1 -1
- package/dist/assets/src-BUtIBFDA.js +1 -0
- package/dist/assets/src-C0eXlKtx.js +16 -0
- package/dist/assets/{studioEntry-nXQP3iL0.js → studioEntry-WeMfaSGn.js} +1 -1
- package/dist/assets/{submitRedirect-jK-cEIbP.js → submitRedirect-C2lfZSHt.js} +1 -1
- package/dist/assets/{sv-CROOGJGz.js → sv-5uTzgQT3.js} +1 -1
- package/dist/assets/{ta-BZnTmFI_.js → ta-BzgdkBZG.js} +1 -1
- package/dist/assets/{te-BN0v0x5t.js → te-Ct_pl7ZJ.js} +1 -1
- package/dist/assets/{th-CBjKhp_U.js → th-DouAlk0-.js} +1 -1
- package/dist/assets/{tr-x0Ne4N4H.js → tr-3XNBsI40.js} +1 -1
- package/dist/assets/types-zod-DXpXw10W.js +1 -0
- package/dist/assets/{ug-sgzNhsKo.js → ug-B9n24h9G.js} +1 -1
- package/dist/assets/ui-components-D6cEVg0T.js +37 -0
- package/dist/assets/ui-layout-DgVDuPEM.js +1 -0
- package/dist/assets/{uk-o_DQ5VHJ.js → uk-DCAenByf.js} +1 -1
- package/dist/assets/use-book-data-CwRldFxP.js +1 -0
- package/dist/assets/{useActionModal-CSvbHkQ7.js → useActionModal-Blp4rhOk.js} +1 -1
- package/dist/assets/useCanAuthorMetadata-BxCMgFRf.js +1 -0
- package/dist/assets/useNavSelDeepLink-67Y4qCNO.js +1 -0
- package/dist/assets/useNavTargetLabel-BOJncjIb.js +1 -0
- package/dist/assets/{useOpenRecordList-B5-qaFUx.js → useOpenRecordList-BrwJFojQ.js} +1 -1
- package/dist/assets/{usePackageL10n-CMx66am-.js → usePackageL10n-Ci9uVkRZ.js} +1 -1
- package/dist/assets/{useSettingsLabel-Kkr2q0Oo.js → useSettingsLabel-CeMnMWsh.js} +1 -1
- package/dist/assets/{uz-Cyrl-DbtkQtz_.js → uz-Cyrl-JSeHEqu-.js} +1 -1
- package/dist/assets/{uz-Be41d4jl.js → uz-DT3s9bZS.js} +1 -1
- package/dist/assets/vendor-objectstack-DFqu45yM.js +138 -0
- package/dist/assets/{vi-84mZmklk.js → vi-D2p-h6bY.js} +1 -1
- package/dist/assets/{zh-CN-DD1reegJ.js → zh-CN-DHOKqAit.js} +1 -1
- package/dist/assets/{zh-HK-B05u30WI.js → zh-HK-D4iIPY7I.js} +1 -1
- package/dist/assets/{zh-TW-Bb-WimPD.js → zh-TW-gORQ_tZh.js} +1 -1
- package/dist/chunk-membership.json +100 -90
- package/dist/eager-closure.json +110 -110
- package/dist/index.html +4 -4
- package/dist/sdui.manifest.json +520 -60
- package/package.json +1 -1
- package/dist/assets/AppDocsIndex-F4zDq2zz.js +0 -1
- package/dist/assets/ApprovalsInboxPage-DrEUmaDb.js +0 -1
- package/dist/assets/AuditLogPage-CoghqsZb.js +0 -1
- package/dist/assets/DashboardView-CGC-_Om8.js +0 -1
- package/dist/assets/DocPage-CIZE5kdj.js +0 -1
- package/dist/assets/DocsSlug-DXdFdwlS.js +0 -1
- package/dist/assets/ExpressionProvider-DZfMwyMs.js +0 -1
- package/dist/assets/MarketplacePackagePage-C7NOu2Ir.js +0 -4
- package/dist/assets/PageView-CVLgCRSF.js +0 -1
- package/dist/assets/RecordDetailView-DQKydU7X.js +0 -3
- package/dist/assets/RecordFormPage-BTjwxJIA.js +0 -1
- package/dist/assets/ReportDefaultInspector-DdsQAkd7.js +0 -1
- package/dist/assets/SchemaForm-C8X1ve4p.js +0 -3
- package/dist/assets/SearchResultsPage-Jwhqsdyo.js +0 -1
- package/dist/assets/SettingsView-D8SMKdrc.js +0 -1
- package/dist/assets/appRoute-DbnWDEa1.js +0 -1
- package/dist/assets/data-adapter-DMbe6Njk.js +0 -1
- package/dist/assets/default-inspector-registry-CpL3fFhl.js +0 -1
- package/dist/assets/dist-BXrEV1ag.js +0 -13
- package/dist/assets/en-AU-C6x7mDhH.js +0 -1
- package/dist/assets/en-GB-0-nho2eK.js +0 -1
- package/dist/assets/en-IE-2fC3BkfV.js +0 -1
- package/dist/assets/en-IN-C1QcFhxn.js +0 -1
- package/dist/assets/en-NZ-C80ptZT7.js +0 -1
- package/dist/assets/en-ZA-ByZDrjeb.js +0 -1
- package/dist/assets/framework-DcWkeiND.js +0 -35
- package/dist/assets/getIcon-BEVyC4y3.js +0 -1
- package/dist/assets/i18n-CEKxYdmD.js +0 -9
- package/dist/assets/i18n-locale-ar-DN7sl3GF.js +0 -4
- package/dist/assets/i18n-locale-de-C40JErvb.js +0 -4
- package/dist/assets/i18n-locale-en-CITPDIHy.js +0 -4
- package/dist/assets/i18n-locale-es-C8DdWN6c.js +0 -4
- package/dist/assets/i18n-locale-fr-COIdEZZl.js +0 -4
- package/dist/assets/i18n-locale-ja-DYF_rU_s.js +0 -4
- package/dist/assets/i18n-locale-ko-B-ODYAtX.js +0 -4
- package/dist/assets/i18n-locale-pt-CK1SyBIm.js +0 -4
- package/dist/assets/i18n-locale-ru-jLzvShMO.js +0 -4
- package/dist/assets/i18n-locale-zh-Bf9Gbbvl.js +0 -4
- package/dist/assets/index-CLyvpiGc.css +0 -2
- package/dist/assets/index-CfnfGw5W.js +0 -20
- package/dist/assets/isSameWeek-DWYeNyh8.js +0 -1
- package/dist/assets/mermaid-GHXKKRXX-DVLc_uym.js +0 -1
- package/dist/assets/metadata-admin-CybaOCdO.js +0 -9
- package/dist/assets/nav-selection-Dzm_mA3C.js +0 -1
- package/dist/assets/plugin-calendar-CKRBcML7.js +0 -1
- package/dist/assets/plugin-charts-DGTJxXCB.js +0 -7
- package/dist/assets/plugin-chatbot-DwtwNA-y.js +0 -122
- package/dist/assets/plugin-dashboard-C1AYKmGX.js +0 -6
- package/dist/assets/plugin-form-CV8ZY04-.js +0 -1
- package/dist/assets/plugin-gantt-BRIb2_8G.js +0 -63
- package/dist/assets/plugin-grid-C9h7mRVv.js +0 -11
- package/dist/assets/plugin-kanban-BcJ0Dhys.js +0 -1
- package/dist/assets/plugin-map-D24ZUOUj.js +0 -1
- package/dist/assets/plugin-report-BfGintAq.js +0 -59
- package/dist/assets/plugin-timeline-CbBRq_qt.js +0 -1
- package/dist/assets/plugin-tree-BNX2A5J5.js +0 -1
- package/dist/assets/plugin-view-DzWQWYyH.js +0 -1
- package/dist/assets/plugins-views-DraK4xz0.js +0 -3
- package/dist/assets/src-B8lv0plz.js +0 -18
- package/dist/assets/src-DoDvT77T.js +0 -1
- package/dist/assets/types-zod-Y2RwUUeJ.js +0 -1
- package/dist/assets/ui-components-BTB1NkUW.js +0 -37
- package/dist/assets/ui-layout-bZfafwJa.js +0 -1
- package/dist/assets/use-book-data-C3eyZJSG.js +0 -1
- package/dist/assets/vendor-objectstack-XuWC71M9.js +0 -266
- package/dist/assets/vendor-zod-CHLW1iCr.js +0 -64
|
@@ -0,0 +1,11 @@
|
|
|
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{Ai as s,Bt as c,In as l,Kt as u,Mi as d,On as f,Vi as p,Vt as m,Wn as h,Zn as g,ki as _,pn as v,qr as y,vn as b}from"./vendor-objectstack-DFqu45yM.js";import{$ as x,$n as S,$t as C,A as w,Ar as T,At as E,B as D,Bn as O,Br as k,C as A,Ci as j,Dn as M,En as N,F as ee,Fr as te,G as ne,Gn as P,H as F,I as re,In as I,Ir as L,J as R,Jn as ie,K as z,Kn as ae,Kt as oe,L as B,Ln as V,Lr as se,M as ce,Mr as le,N as ue,Nr as de,O as fe,On as H,P as pe,Pr as me,Q as he,Qn as ge,Qt as _e,R as ve,Rn as ye,Rr as be,St as xe,Tn as Se,U as Ce,Ur as U,Ut as we,V as Te,Vn as W,Vr as Ee,W as De,Wn as Oe,Wr as ke,Z as Ae,Zt as je,_ as G,_i as Me,ai as Ne,an as K,b as Pe,bi as Fe,bt as Ie,ci as Le,cr as Re,ct as ze,d as Be,di as Ve,dt as He,en as Ue,er as We,f as Ge,fi as Ke,ft as qe,gi as Je,hi as Ye,i as Xe,ii as q,in as J,j as Ze,jr as Qe,k as $e,kn as et,li as tt,m as nt,mi as rt,mt as it,n as at,nn as ot,nr as st,o as ct,oi as lt,on as ut,p as dt,pi as ft,qn as pt,qt as mt,r as ht,ri as gt,rn as _t,s as vt,si as yt,tn as bt,u as xt,ui as St,v as Ct,w as wt,wn as Tt,x as Et,xi as Y,xt as Dt,y as Ot,yi as X,yt as kt,z as At,zn as jt,zr as Mt}from"./ui-components-D6cEVg0T.js";import{$i as Nt,$t as Pt,Ai as Ft,Ar as It,At as Lt,Bi as Rt,Bt as zt,Ci as Bt,D as Vt,Di as Ht,Dt as Ut,E as Wt,Ei as Gt,Er as Kt,Et as qt,F as Jt,Fi as Yt,Fr as Xt,Ft as Zt,Gi as Qt,H as $t,Ht as en,Ii as tn,Ir as nn,It as rn,J as an,Jt as on,Kt as sn,Lr as cn,Mr as ln,Nr as un,Nt as dn,Oi as fn,Ot as pn,Pi as mn,Pr as hn,Pt as gn,Qt as _n,Rr as vn,Rt as yn,Si as bn,T as xn,Ti as Sn,Tt as Cn,U as Z,V as wn,Wn as Tn,Xi as En,Xr as Dn,Xt as On,Yi as kn,Yt as An,Zr as jn,Zt as Mn,_ as Nn,_i as Pn,_r as Fn,a as In,ai as Ln,at as Rn,c as zn,dt as Bn,en as Vn,f as Hn,fi as Un,fr as Wn,g as Gn,gr as Kn,gt as qn,ht as Jn,ia as Yn,jr as Xn,jt as Zn,ki as Qn,kr as $n,ln as er,lt as tr,m as nr,mt as rr,na as ir,nn as ar,o as or,oi as sr,p as cr,pt as lr,qt as ur,r as dr,ra as fr,ri as pr,rn as mr,sr as hr,ta as gr,u as _r,ui as vr,vi as yr,vr as br,vt as xr,wi as Sr,xi as Cr,xr as wr,y as Tr,yi as Er,zr as Dr,zt as Or}from"./framework-DFR4HNtj.js";import{g as kr,h as Ar,i as jr,n as Mr,o as Nr,p as Pr,t as Fr,w as Ir}from"./i18n-runtime-97_bDVjP.js";import{t as Lr}from"./vendor-icon-activity-CkniytwY.js";import{t as Rr}from"./vendor-icon-arrow-left-DmGEbpkA.js";import{t as zr}from"./vendor-icon-arrow-right-left-BH_jvt4r.js";import{t as Br}from"./vendor-icon-arrow-right-RqsZZ458.js";import{t as Vr}from"./vendor-icon-arrow-up-down-DdDqplfV.js";import{t as Hr}from"./vendor-icon-at-sign-B71HJHhC.js";import{t as Ur}from"./vendor-icon-badge-check-SLEl_RQq.js";import{t as Wr}from"./vendor-icon-bell-off-BnernHBj.js";import{t as Gr}from"./vendor-icon-bell-6t8He8Wt.js";import{t as Kr}from"./vendor-icon-bold-C_J_IVlW.js";import{t as qr}from"./vendor-icon-calendar-BsoUBIef.js";import{t as Jr}from"./vendor-icon-check-vpu9Zukp.js";import{t as Yr}from"./vendor-icon-chevron-down-BEf_jTEE.js";import{t as Xr}from"./vendor-icon-chevron-left-KnDcuFH1.js";import{t as Zr}from"./vendor-icon-chevron-right-DbnKwHYQ.js";import{t as Qr}from"./vendor-icon-chevrons-left-gvlDgS8M.js";import{t as $r}from"./vendor-icon-chevrons-right-lic1nOWF.js";import{t as ei}from"./vendor-icon-circle-alert-D1XTr_X9.js";import{t as ti}from"./vendor-icon-circle-check-Bq3OcFQN.js";import{t as ni}from"./vendor-icon-circle-plus-4gej-PPk.js";import{t as ri}from"./vendor-icon-circle-x-Nkh1Yr7N.js";import{t as ii}from"./vendor-icon-circle-5-gUQbxi.js";import{t as ai}from"./vendor-icon-clipboard-paste-DxLRapVV.js";import{t as oi}from"./vendor-icon-clock-CTLnah0r.js";import{t as si}from"./vendor-icon-code-C7LFGCxG.js";import{t as ci}from"./vendor-icon-copy-B5M-KdZo.js";import{t as li}from"./vendor-icon-download-C3csYSaD.js";import{t as ui}from"./vendor-icon-ellipsis-vertical-DwMP57JC.js";import{t as di}from"./vendor-icon-external-link-SBKz5x6R.js";import{t as fi}from"./vendor-icon-eye-off-Dy3GIcvl.js";import{t as pi}from"./vendor-icon-eye-C3HaEGOo.js";import{t as mi}from"./vendor-icon-face-slightly-smiling-plus-BYluVacK.js";import{t as hi}from"./vendor-icon-file-archive-ruJEbEgu.js";import{t as gi}from"./vendor-icon-file-spreadsheet-LZ3f9xT3.js";import{t as _i}from"./vendor-icon-file-text-7BKAVNof.js";import{t as vi}from"./vendor-icon-file-CTChzdTZ.js";import{t as yi}from"./vendor-icon-hash-Lkwzb5Ny.js";import{t as bi}from"./vendor-icon-image-D2YAsa8l.js";import{t as xi}from"./vendor-icon-inbox-ByVQ4l4S.js";import{t as Si}from"./vendor-icon-italic-Dt0-MsYM.js";import{t as Ci}from"./vendor-icon-list-TLz-7vfa.js";import{t as wi}from"./vendor-icon-loader-circle-D3PsuVaD.js";import{t as Ti}from"./vendor-icon-lock-B_psRnly.js";import{t as Ei}from"./vendor-icon-mail-BfkRvgNr.js";import{t as Di}from"./vendor-icon-message-square-BObk9Jes.js";import{t as Oi}from"./vendor-icon-panel-right-close-B1IgPiA5.js";import{t as ki}from"./vendor-icon-panel-right-open-DRcsA0VE.js";import{t as Ai}from"./vendor-icon-paperclip-zxZDBuvr.js";import{t as ji}from"./vendor-icon-pencil-CMubUBjW.js";import{t as Mi}from"./vendor-icon-phone-H1S8HSi1.js";import{t as Ni}from"./vendor-icon-pin-BWwVcO2t.js";import{t as Pi}from"./vendor-icon-plus-BlfcDDsa.js";import{t as Fi}from"./vendor-icon-rows-2-CyEMxks5.js";import{t as Ii}from"./vendor-icon-rows-3-Bl0iGPg_.js";import{t as Li}from"./vendor-icon-rows-4-DVXDgm1n.js";import{t as Ri}from"./vendor-icon-save-CuavGNuU.js";import{t as zi}from"./vendor-icon-search-B2Uqtp_W.js";import{t as Bi}from"./vendor-icon-send-BlZYLCTK.js";import{t as Vi}from"./vendor-icon-share-2-D3bdPyHy.js";import{t as Hi}from"./vendor-icon-square-check-big-B4UVzWzR.js";import{t as Ui}from"./vendor-icon-square-pen-CrYOuw6J.js";import{t as Wi}from"./vendor-icon-star-DfusowFE.js";import{t as Gi}from"./vendor-icon-sticky-note-Bp3ZFMbg.js";import{t as Ki}from"./vendor-icon-tag-iKhUiq-2.js";import{t as qi}from"./vendor-icon-text-align-justify-BknwtpxF.js";import{t as Ji}from"./vendor-icon-trash-BLsWkwB9.js";import{t as Yi}from"./vendor-icon-triangle-alert-D5n0T3q_.js";import{t as Xi}from"./vendor-icon-type-DudTuHpS.js";import{t as Zi}from"./vendor-icon-undo-2-C9MbW2Vb.js";import{t as Qi}from"./vendor-icon-upload-BZ3rElxe.js";import{t as $i}from"./vendor-icon-user-IWwlLQut.js";import{t as ea}from"./vendor-icon-x-CcLtgRNL.js";import{t as ta}from"./vendor-icon-zap-3ulAPCbu.js";var Q=e(o(),1);b();function na(e){let t=e?.type||null,n=t===null?null:Ct({type:t,format:e?.format??void 0});return{declaredType:t,rendererType:n,Renderer:dt(n??``)}}function ra(e){return dt(e)}var ia=`select`;function aa(e,t,n){return sa(e)||sa(t)||oa(e,n)}function oa(e,t){return t&&!(typeof e==`string`&&e.length>0)}function sa(e){return typeof e==`string`&&G(e)}function ca(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 la=new Set([`formula`,`summary`,`rollup`,`autonumber`,`auto_number`,`file`,`image`,`avatar`,`video`,`audio`,`signature`]);function ua(e){return e?e.readonly===!0?!1:typeof e.type!=`string`||!la.has(e.type)&&!ce(e.type):!0}var da={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},fa=[`xs`,`sm`,`md`,`lg`,`xl`,`2xl`];function pa(e){for(let t=fa.length-1;t>=0;t--){let n=fa[t];if(e>=da[n])return n}return`xs`}function ma(){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=pa(e),r=fa.indexOf(n);return{breakpoint:n,width:e,isMobile:r<fa.indexOf(`md`),isTablet:r>=fa.indexOf(`md`)&&r<fa.indexOf(`lg`),isDesktop:r>=fa.indexOf(`lg`),isAbove:t=>e>=da[t],isBelow:t=>e<da[t]}}function ha(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&&ya(t),m.current=e?va(e,p):null)}),(0,Q.useEffect)(()=>()=>{let e=m.current;e&&ya(e),m.current=null},[]),{ref:i,isRefreshing:a,pullDistance:s}}var ga=`data-pull-to-refresh-host`;function _a(e){let t=e.parentElement;return t!==null&&t.closest(`[${ga}]`)!==null}function va(e,t){let n={el:e,start:n=>{_a(e)||t.current.handleTouchStart(n)},move:e=>t.current.handleTouchMove(e),end:()=>{t.current.handleTouchEnd()}};return e.setAttribute(ga,``),e.addEventListener(`touchstart`,n.start,{passive:!0}),e.addEventListener(`touchmove`,n.move,{passive:!0}),e.addEventListener(`touchend`,n.end,{passive:!0}),n}function ya(e){e.el.removeAttribute(ga),e.el.removeEventListener(`touchstart`,e.start),e.el.removeEventListener(`touchmove`,e.move),e.el.removeEventListener(`touchend`,e.end)}var $=a(),ba=(0,Q.createContext)(null);ba.displayName=`MobileContext`;function xa({pwa:e,offline:t,children:n}){let r=ma(),i=(0,Q.useMemo)(()=>({...r,pwa:e,offline:t}),[r,e,t]);return(0,$.jsx)(ba.Provider,{value:i,children:n})}function Sa(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 Ca=new Set([`textarea`,`markdown`,`html`,`grid`,`richtext`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:richtext`]);function wa(e){return Ca.has(e)}function Ta(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 Ea(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&wa(e.type)?{...e,span:t}:e)}function Da(e,t,n){if(t!==void 0)return{fields:Ea(e,t),columns:t};let r=Ta(e.length,n);return{fields:Ea(e,r),columns:r}}var Oa=Ar({"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.reactionCountOne":`{{emoji}} {{count}} reaction`,"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.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.attachmentCountPlural":`{{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.replyCountPlural":`{{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 ka(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 Aa(e){let t=ka(e);return t==null||t===``?0:Array.isArray(t)?t.length:typeof t==`object`?Object.keys(t).length:1}function ja({value:e,field:t}){let{t:n}=Oa(),a=qt(),{appName:o}=r(),s=t?.name||``,c=a?.data?.name,l=o&&c?`/apps/${o}/metadata/permission/${encodeURIComponent(String(c))}`:null,u=Aa(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=fe(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)(gt,{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 Ma=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`]),Na=new Set([`formula`,`summary`,`rollup`,`autonumber`,`auto_number`]);function Pa(e,t){return Na.has(e)||Na.has(t)}var Fa=new Set([`image`,`avatar`,`signature`,`file`,`video`,`audio`]);function Ia(e,t){return La(e)||La(t)}function La(e){return typeof e!=`string`||Fa.has(e)?!1:ce(e)}function Ra(e,t){return za(e)||za(t)}function za(e){return typeof e==`string`&&G(e)}var Ba=`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 Va(e,t){let n={...e};if(!t)return n;!n.type&&t.type&&(n.type=t.type);for(let e of Ba){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 Ha=`inline-plain-text-input`,Ua=new Set([`text`,`textarea`,`email`,`phone`,`url`]);function Wa(e){return e?at.includes(e)||z(e)!==`field:text`:!1}function Ga(e){let t=e?.type;return!t||Ua.has(t)?!0:t===`select`&&!e.multiple}var Ka=({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)(ja,{value:t,field:e});if(typeof s==`string`&&bn[s])return(0,$.jsx)(Xe,{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)(Te,{field:{...e,multiple:!0},value:Array.isArray(t)?t:t==null||t===``?[]:[t],onChange:e=>n(e),error:a,dependentValues:o}):(0,$.jsx)(Te,{field:e,value:t==null?``:String(t),onChange:e=>n(e),error:a,dependentValues:o});if(s===`boolean`)return(0,$.jsx)(F,{field:e,value:!!t,onChange:e=>n(e),error:a});if(s===`image`)return(0,$.jsx)(A,{field:e,value:t,onChange:e=>n(e),error:a});if(s===`avatar`)return(0,$.jsx)(Et,{field:e,value:t,onChange:e=>n(e),error:a});if(s===`signature`)return(0,$.jsx)(Pe,{field:e,value:t,onChange:e=>n(e),error:a});if(s===`file`||s===`video`||s===`audio`)return(0,$.jsx)(wt,{field:e,value:t,onChange:e=>n(e),error:a});let l=s===`user`,u=s===`lookup`||s===`master_detail`||s===`tree`||!!e.reference&&!Na.has(s);if(l||u)return(0,$.jsx)(l?re:B,{field:e,value:t,onChange:e=>n(e),dataSource:r,error:a,dependentValues:o});if(s===`number`)return(0,$.jsx)(ne,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(s===`currency`)return(0,$.jsx)(De,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(s===`percent`)return(0,$.jsx)(Ce,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(s===`address`)return(0,$.jsx)(ee,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(s===`location`)return(0,$.jsx)(pe,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(s===`geolocation`)return(0,$.jsx)(ue,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});let d=s===`date`||s===`datetime`;if(!d&&!Ga(e)&&Wa(s)&&Ze(s))return(0,$.jsx)(w,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a,dependentValues:o});if(d)return(0,$.jsx)(D,{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`?R(t)??``:t);return(0,$.jsx)(`input`,{type:`text`,"data-testid":Ha,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)})},qa=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`}),Ja=qa;function Ya(e){if(!e)return;let t=e.trim();if(t)return t.startsWith(`bg-`)?t:Object.prototype.hasOwnProperty.call(qa,t)?qa[t]:void 0}function Xa(e){return Ft(e)?!1:typeof e==`object`&&e?!0:vn({value:e},`value`)!==void 0}var Za=({name:e})=>/^[a-z0-9][a-z0-9-]*$/i.test(e)?(0,$.jsx)(we,{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 Qa(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 $a=({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}=Oa(),{fieldLabel:b,translateOptions:x}=Pr(),S=Z()?.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=>!Xa(t?.[e.name]??e.value),[t]),T=Q.useMemo(()=>e.fields.filter(w).length,[e.fields,w]),D=et(),O=D?3:4,A=D?.2:.25,j=e.fields.length-T,ee=!a&&e.fields.length>=O&&T/e.fields.length>=A&&j>0,te=e.fields.length>0&&j===0,ne=e.hideEmpty===!0&&te&&!a,P=!_&&(ee||ne)?e.fields.filter(e=>!w(e)):e.fields,{fields:F,columns:re}=Da(P,e.columns),I=Math.min(re,Math.max(1,P.length)),R=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,$.jsx)(qn,{schema:rr(e.render),data:{...t,value:n}});let u=Qa(e.span,I),d=r?.fields?.[e.name],f=Va(e,d);i&&Array.isArray(f.options)&&f.options.length>0&&(f.options=x(i,e.name,f.options));let m=Pa(e.type,d?.type),h=e.readonly===!0||d?.readonly===!0,g=Ma.has(e.name),_=Ia(e.type,d?.type),v=Ra(e.type,d?.type),w=!h&&!m&&!g&&!_,T=w&&!!s,O=(()=>{if((f.widget||e.widget)===`permission-facet-link`)return(0,$.jsx)(ja,{value:n,field:f});if(!Xa(n))return(0,$.jsx)(E,{className:`pointer-events-auto`,title:y(`detail.noValue`,{defaultValue:`No value`})});let t=Ct(f)||e.type;if(t){let e=dt(t);if(e)return(0,$.jsx)(e,{value:n,field:f})}return String(n)})(),k=Xa(n)&&!v,A=k&&!T,j=p===e.name,ee=b(i||``,e.name,e.label||e.name);return D&&!(a&&w)?(0,$.jsxs)(`div`,{className:Y(`flex items-baseline justify-between gap-4 py-2.5 min-h-[44px] group`,k&&`cursor-pointer active:bg-muted/40 transition-colors`),onClick:k?()=>C(e.name,n):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,children:[(0,$.jsx)(`span`,{className:`text-[15px] text-muted-foreground shrink-0`,children:ee}),(0,$.jsx)(`span`,{className:`text-[15px] text-foreground text-right break-words min-w-0 leading-snug`,children:O})]},e.name):(0,$.jsxs)(`div`,{className:Y(`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)(Ka,{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:Y(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,A&&`cursor-pointer active:bg-muted/60 transition-colors`,T&&`cursor-pointer hover:bg-muted/40 transition-colors -mx-1.5 px-1.5`),onClick:A?()=>C(e.name,n):void 0,onDoubleClick:T?()=>s?.(e.name):void 0,onKeyDown:A?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),C(e.name,n))}:void 0,role:A?`button`:void 0,tabIndex:A?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:O}),T?(0,$.jsx)(N,{children:(0,$.jsxs)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsx)(X,{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)(ji,{className:`h-3 w-3`})})}),(0,$.jsx)(Se,{children:y(`detail.editInlineHint`)})]})}):k?(0,$.jsx)(N,{children:(0,$.jsxs)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsx)(X,{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:j?(0,$.jsx)(Jr,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(ci,{className:`h-3 w-3`})})}),(0,$.jsx)(Se,{children:y(j?`detail.copied`:`detail.copyToClipboard`)})]})}):null]})]},e.name)},ie=u?.enabled===!0,z=u?.batchSize??20;if(Q.useEffect(()=>{if(!ie){g(void 0);return}if(F.length<=z){g(void 0);return}g(z);let e=setTimeout(()=>g(void 0),100);return()=>clearTimeout(e)},[ie,F.length,z]),P.length===0&&T===e.fields.length)return null;let ae=h===void 0?F:F.slice(0,h),oe=T>0&&ee,B=(0,$.jsxs)($.Fragment,{children:[D?(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60`,children:ae.map(R)}):(0,$.jsx)(`div`,{className:Y(`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(R)}),oe&&(0,$.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,$.jsxs)(X,{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)(fi,{className:`h-3.5 w-3.5 mr-1.5`}):(0,$.jsx)(pi,{className:`h-3.5 w-3.5 mr-1.5`}),_?y(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):y(`detail.showEmptyFields`,{count:T,defaultValue:`Show {{count}} empty fields`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,$.jsx)(`div`,{className:Y(n),children:B}):e.collapsible?(0,$.jsx)(L,{open:!d,onOpenChange:e=>f(!e),className:n,children:(0,$.jsxs)(k,{className:Y(e.showBorder===!1?`border-none shadow-none`:``),children:[(0,$.jsx)(be,{asChild:!0,children:(0,$.jsxs)(U,{className:Y(`py-3 px-4 sm:py-4 sm:px-6 cursor-pointer hover:bg-muted/50 transition-colors`,Ya(e.headerColor)),children:[(0,$.jsxs)(ke,{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)(Za,{name:e.icon}),(0,$.jsx)(`span`,{children:e.title})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:d?(0,$.jsx)(Zr,{className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Yr,{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)(se,{children:(0,$.jsx)(Ee,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:B})})]})}):(0,$.jsxs)(k,{className:Y(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,$.jsxs)(U,{className:Y(`py-3 px-4 sm:py-4 sm:px-6`,Ya(e.headerColor)),children:[(0,$.jsx)(ke,{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)(Za,{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)(Ee,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:B})]})},eo=({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)(je,{value:r,onValueChange:i,className:n,children:[(0,$.jsx)(C,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,$.jsx)(Ue,{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)(gt,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,$.jsx)(_e,{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)(qn,{schema:rr(e),data:t},n))}):(0,$.jsx)(qn,{schema:rr(e.content),data:t})})},e.key))]})},to=({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)($a,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l},n))});return u?(0,$.jsxs)(L,{open:!d,onOpenChange:e=>f(!e),className:n,children:[(0,$.jsx)(be,{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)(Zr,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,$.jsx)(Yr,{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)(se,{children:(0,$.jsx)(`div`,{className:`mt-3`,children:p})})]}):(0,$.jsxs)(`div`,{className:Y(`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]})},no=({fields:e,data:t,className:n,objectName:r,objectSchema:i,dataSource:a})=>{let{fieldLabel:o}=Pr(),{t:s}=Oa(),c=Z(),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)(N,{children:(0,$.jsx)(`section`,{className:Y(`@container border-b border-border/60 pb-4`,n),"aria-label":s(`detail.highlightsLabel`),children:(0,$.jsx)(`div`,{className:Y(`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=Va({name:e.name,label:e.label,type:p||`text`},d),h=f?f[e.name]:n,g=Pa(e.type,d?.type),_=e.readonly===!0||d?.readonly===!0,v=Ma.has(e.name),y=Ia(e.type,d?.type),b=u&&!g&&!_&&!v&&!y,x=l&&b,S=dt(Ct(m)||p||`text`),C=p===`number`||p===`integer`||p===`currency`||p===`percent`||p===`decimal`,w=p===`email`||p===`url`||p===`textarea`||!!p&&Sn.has(p),T=p===`boolean`,D=!Xa(h);return(0,$.jsxs)(`div`,{className:Y(`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)(Ka,{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:Y(`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)(Jr,{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)(ea,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):D?(0,$.jsx)(E,{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:Y(`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)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsx)(X,{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)(ji,{className:`h-3 w-3`})})}),(0,$.jsx)(Se,{children:s(`detail.editInlineHint`)})]})]})]},e.name)})})})})};function ro(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 io=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=Oa(),o=Fr(),[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)(k,{className:Y(``,i),children:[(0,$.jsx)(U,{children:(0,$.jsxs)(ke,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(Di,{className:`h-4 w-4`}),a(`detail.comments`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,$.jsxs)(Ee,{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)(zi,{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)(ea,{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)(X,{size:`icon`,variant:`default`,onClick:p,disabled:!s.trim()||l,className:`shrink-0 self-end`,children:(0,$.jsx)(Bi,{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:Y(`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:ro(e.createdAt,a,o)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,$.jsx)(Ni,{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)(Ni,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},ao={field_change:Ui,create:ni,delete:Ji,comment:Di,status_change:zr},oo={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 so(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 co(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 lo=[`all`,`field_change`,`create`,`delete`,`comment`,`status_change`];function uo(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 fo=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let{t:i}=Oa(),a=Fr(),[o,s]=Q.useState(n),c=Q.useMemo(()=>o===`all`?e:e.filter(e=>e.type===o),[e,o]);return(0,$.jsxs)(k,{className:Y(``,r),children:[(0,$.jsx)(U,{children:(0,$.jsxs)(ke,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(Lr,{className:`h-4 w-4`}),i(`detail.activity`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,c.length,`)`]})]})}),(0,$.jsxs)(Ee,{children:[t&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":i(`detail.filterActivity`),children:lo.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:Y(`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(ao[e]||Ui,{className:`h-3 w-3`}),uo(e,i)]},e))}),c.length===0?(0,$.jsx)(qe,{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=ao[e.type]||Ui,n=oo[e.type]||`bg-gray-100 text-gray-600`;return(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:Y(`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:co(e,i)})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:so(e.timestamp,i,a)})]})]},e.id)})})]})]})]})},po={create:`default`,update:`secondary`,delete:`destructive`,login:`outline`,logout:`outline`,config_change:`secondary`,import:`outline`};function mo(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 ho=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function go(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 ho){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return mo(e,t)}r/=n}return mo(e,t)}function _o(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 vo(e){if(!Xa(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 yo({entries:e,loading:t,emptyText:n,unknownUserText:r,className:i,locale:a}){let o=Fr(),s=a??o;return t?(0,$.jsx)(`div`,{className:Y(`space-y-3`,i),children:Array.from({length:4}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(H,{className:`h-8 w-8 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(H,{className:`h-4 w-1/3`}),(0,$.jsx)(H,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,$.jsx)(`div`,{className:Y(`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)(N,{delayDuration:150,children:(0,$.jsx)(`ol`,{className:Y(`space-y-4`,i),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),i=po[n]??`outline`,a=typeof e.user_name==`string`&&e.user_name.trim()||r||`Unknown user`,o=mo(e.created_at,s),c=go(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)(q,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[l?(0,$.jsx)(lt,{src:l,alt:a}):null,(0,$.jsx)(Ne,{className:`text-[10px] font-medium`,children:_o(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)(gt,{variant:i,className:`text-[10px] uppercase tracking-wide`,children:e.action}),o&&(0,$.jsxs)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":o,children:c||o})}),(0,$.jsx)(Se,{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:vo(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:vo(e.from)}),` → `,(0,$.jsx)(`span`,{className:`text-foreground`,children:vo(e.to)})]},e.field))}))]})]},e.id??t)})})})}var bo=pr;function xo(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 So(e){return Xa(e)?e:void 0}function Co(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 wo(e,t){try{return new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var To=({value:e,objectSchema:t,fieldName:n})=>{if(!Xa(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=Ct(a)||a.type;if(o){let t=dt(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)})},Eo=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a,locale:o})=>{if(!t&&!n)return null;let s=n?(0,$.jsx)(N,{delayDuration:200,children:(0,$.jsxs)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:Co(n,a)})}),(0,$.jsx)(Se,{side:`top`,children:wo(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)(To,{value:t,objectSchema:r,fieldName:i}):null,t&&s?(0,$.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,s]})},Do=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=Oa(),a=Fr();if(!e)return null;let o=xo(e[bo.createdAt]),s=xo(e[bo.updatedAt]),c=So(e[bo.createdBy]),l=So(e[bo.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:Y(`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)(Eo,{label:i(c?`detail.createdBy`:`detail.created`),user:c,date:o,objectSchema:t,userField:bo.createdBy,t:i,locale:a}),f&&(0,$.jsx)(Eo,{label:i(l?`detail.updatedBy`:`detail.updated`),user:l,date:s,objectSchema:t,userField:bo.updatedBy,t:i,locale:a})]})},Oo=new Map,ko=new Set;function Ao(e){for(let t of Array.from(Oo.keys())){let[,n,r]=JSON.parse(t);nr(e,n,r)&&Oo.delete(t)}for(let t of ko)for(let n of t.recordIds)nr(e,t.object,n)&&t.staled.add(n)}Gn(Ao);var jo;function Mo(e){jo!==void 0&&jo!==e&&Oo.clear(),jo=e}function No(e,t,n=`update`,r=!0){let i=x().userId,a=e&&t?JSON.stringify([i,e,t,n]):``,o=Nn(e,t),[s,c]=Q.useState(()=>a&&Oo.has(a)?Oo.get(a):!0),l=Q.useContext(pn)?.apiFetch;return Q.useEffect(()=>{if(Mo(i),!r||!e||!t){c(!0);return}if(Oo.has(a)){c(Oo.get(a));return}c(!0);let o=!1,s={object:e,recordIds:[t],staled:new Set};return ko.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;Oo.set(a,i),o||c(i)}catch{}finally{ko.delete(s)}})(),()=>{o=!0}},[a,i,e,t,n,r,l,o]),s}var Po=new Set([`select`,`status`,`multiselect`,`radio`,`checkboxes`,`tags`,`user`,`image`,`avatar`,`signature`,`boolean`,`toggle`,`date`,`datetime`,`repeater`,`file`,`video`,`audio`]);function Fo(e){return!Po.has(e)}function Io(e){let t=er(e);return t===e?t:Number(t.toPrecision(12))}var Lo={};function Ro(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=vn(e,un(n));if(r){let t=e.id??e._id;if(!(r===`Untitled`||t!=null&&r===`Record #${t}`))return r}let i=Xt(n?.titleFormat,e);if(i)return i}if(e&&typeof e==`object`){let t=e.id??e._id,r=nn(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=nn(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 zo=e=>(e||[]).flatMap(e=>Array.isArray(e?.fields)?e.fields:[]),Bo=({section:e,index:t,children:n})=>(0,$.jsx)(Jn,{componentType:`record:details section ${e?.name??e?.group??e?.title??e?.label??`#${t+1}`}`,children:n}),Vo=({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,S=Z(),w=S?.editing??!1,T=S?.draft??Lo,E=S?.autoFocusField??null,[D,O]=Q.useState(null),[k,A]=Q.useState(null),[ee,te]=Q.useState(!1),[ne,P]=Q.useState(0),F=Nn(e.objectName||void 0,e.resourceId==null?void 0:String(e.resourceId)),[re,I]=Q.useState(!1),{t:L}=Oa(),{currency:ie}=jr(),z=Fr(),{fieldOptionLabel:ae,fieldLabel:oe}=Pr(),B=x(),V=Q.useMemo(()=>{if(!B?.isLoaded||!e.objectName)return e;let t=t=>B.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,B]),se=Q.useMemo(()=>Vn(p,B,e.objectName),[p,B,e.objectName]),ce=Q.useMemo(()=>!B?.isLoaded||!e.objectName||B.can(e.objectName,`update`),[B,e.objectName]),le=Q.useMemo(()=>!B?.isLoaded||!e.objectName||B.can(e.objectName,`delete`),[B,e.objectName]),ue=e.resourceId==null?void 0:String(e.resourceId),de=No(e.objectName,ue,`update`,ce),fe=No(e.objectName,ue,`delete`,le),pe=Q.useMemo(()=>tn(k?.userActions?.edit),[k]),me=Q.useMemo(()=>tn(k?.userActions?.delete),[k]),he=k?.fields,ge=rn(pe?.visibleWhen??!0,p,{fallback:!1,warnOnError:!0,label:`builtin:edit:visibleWhen`,fields:he}),ve=rn(me?.visibleWhen??!0,p,{fallback:!1,warnOnError:!0,label:`builtin:delete:visibleWhen`,fields:he}),ye=rn(pe?.disabledWhen,p,{fallback:!1,warnOnError:!0,label:`builtin:edit:disabledWhen`,fields:he}),be=rn(me?.disabledWhen,p,{fallback:!1,warnOnError:!0,label:`builtin:delete:disabledWhen`,fields:he}),xe=pe?.disabledWhen!=null&&ye,Ce=me?.disabledWhen!=null&&be,U=Q.useMemo(()=>({...V,showEdit:V.showEdit&&ce&&de&&ge,showDelete:V.showDelete&&le&&fe&&ve}),[V,ce,de,ge,le,fe,ve]);Q.useEffect(()=>{p&&u&&u(p)},[p,u]);let we=Q.useMemo(()=>{if(U.summaryFields&&U.summaryFields.length>0)return[];let e=[...zo(U.sections),...U.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(k?.fields)for(let[e,n]of Object.entries(k.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>Xa(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},[U.summaryFields,U.sections,U.fields,k,p]),Te=U.summaryFields&&U.summaryFields.length>0?U.summaryFields:we,W=Q.useCallback(()=>{U.resourceId&&navigator.clipboard.writeText(String(U.resourceId)).then(()=>{te(!0),setTimeout(()=>te(!1),1500)})},[U.resourceId]);Q.useEffect(()=>{let e=!0;if(U.data)return m(U.data),_(!1),t?.getObjectSchema&&U.objectName&&t.getObjectSchema(U.objectName).then(t=>{e&&A(t)}).catch(()=>{}),()=>{e=!1};if(t&&U.objectName&&U.resourceId){_(!0),A(null),m(null);let n=U.objectName,r=U.resourceId,i=`${n}-`,a=[...zo(U.sections),...U.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;A(o);let s=Gt(o?.fields,a),c=B?.isLoaded?s.filter(e=>B.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 U.api&&U.resourceId&&(_(!0),fetch(`${U.api}/${U.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}},[U.api,U.resourceId,U.objectName,t,U.sections,U.fields,ne,F,B]);let Ee=Q.useCallback(()=>{if(a)a();else if(U.onNavigate){let e=U.backUrl||(U.objectName?`/${U.objectName}`:`/`);U.onNavigate(e,{replace:!0})}else U.backUrl?window.location.href=U.backUrl:window.history.back()},[a,U]),De=Q.useCallback(()=>{r?r():U.onNavigate&&U.editUrl?U.onNavigate(U.editUrl):U.onNavigate&&U.objectName&&U.resourceId?U.onNavigate(`/${U.objectName}/${U.resourceId}/edit`):U.editUrl&&(window.location.href=U.editUrl)},[r,U]),Oe=Q.useCallback(async()=>{if(!t?.cancelPendingApproval||!U.objectName||!U.resourceId){O(L(`detail.cancelApprovalUnavailable`));return}I(!0),O(null);try{if(await t.cancelPendingApproval(String(U.objectName),String(U.resourceId)),t.findOne)try{let e=await t.findOne(String(U.objectName),String(U.resourceId));e&&m(e)}catch{}P(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(U.objectName),recordId:String(U.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*/,``);O(`${L(`detail.cancelApprovalFailed`)}: ${t}`)}finally{I(!1)}},[t,U.objectName,U.resourceId,L]),ke=Q.useCallback(()=>{let e=U.deleteConfirmation||L(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),U.onNavigate&&U.objectName&&U.onNavigate(`/${U.objectName}`,{replace:!0}))},[i,U]),Ae=Q.useCallback(()=>{navigator.share&&U.objectName&&U.resourceId?navigator.share({title:U.title||L(`detail.details`),text:`${U.objectName} #${U.resourceId}`,url:window.location.href}).catch(e=>{console.error(`Share failed:`,e)}):navigator.clipboard.writeText(window.location.href)},[U]),G=Q.useCallback(()=>{let e=!b;f&&f(e),d===void 0&&y(e)},[b,d,f]),Me=S?.setField,Ne=S&&S.canEdit?S.enter:void 0;Q.useEffect(()=>{if(!U.recordNavigation)return;let e=U.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)},[U.recordNavigation]);let K=Q.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:L(`detail.share`),icon:`share-2`,type:`script`,onClick:Ae}),U.showEdit&&e.push({name:`sys_edit_mobile`,label:L(`detail.edit`),icon:`square-pen`,type:`script`,className:`sm:hidden`,...xe?{disabled:!0}:null,onClick:De}),U.showDelete&&e.push({name:`sys_delete`,label:L(`detail.delete`),icon:`trash`,type:`script`,variant:`destructive`,tags:[`separator-before`],...Ce?{disabled:!0}:null,onClick:ke}),e},[L,U.showEdit,U.showDelete,xe,Ce,Ae,De,ke]),Pe=Q.useMemo(()=>{let e=U.actions??[];if(K.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,...K]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:K}),n},[U.actions,K]);return g||U.loading?(0,$.jsxs)(`div`,{className:Y(`space-y-4`,n),children:[(0,$.jsx)(H,{className:`h-10 w-full`}),(0,$.jsx)(H,{className:`h-64 w-full`}),(0,$.jsx)(H,{className:`h-48 w-full`})]}):!p&&!U.data?(0,$.jsxs)(`div`,{className:Y(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,$.jsx)(`p`,{className:`text-lg font-semibold`,children:L(`detail.recordNotFound`)}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:L(`detail.recordNotFoundDescription`)}),(U.showBack??!0)&&(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:Ee,className:`mt-4 gap-2`,children:[(0,$.jsx)(Rr,{className:`h-4 w-4`}),L(`detail.goBack`)]})]}):(0,$.jsx)(N,{children:(0,$.jsxs)(`div`,{className:Y(`space-y-6`,n),children:[U.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:[(U.showBack??!0)&&(0,$.jsxs)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,onClick:Ee,className:`shrink-0 mt-1`,children:(0,$.jsx)(Rr,{className:`h-4 w-4`})})}),(0,$.jsx)(Se,{children:L(`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:Ro(se,U,k,L(`detail.details`))}),Te.map(e=>{let t=p?.[e];if(!Xa(t))return null;let n=zo(U.sections).concat(U.fields||[]).find(t=>t.name===e),r=k?.fields?.[e],i=n?.type||r?.type,a=oe(U.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=Mr({...r,...n},ie);o=t?new Intl.NumberFormat(z,{style:`currency`,currency:t,maximumFractionDigits:0}).format(e):new Intl.NumberFormat(z,{maximumFractionDigits:0}).format(e)}}else if(i===`date`||i===`datetime`){let e=Kt(t);Number.isNaN(e.getTime())||(o=i===`datetime`?e.toLocaleString(z,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(z,{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});o=xt(e,a,z);let c=Io(e);s=Math.max(0,Math.min(100,c))}}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=U.objectName?ae(U.objectName,e,String(t),a):a}}catch{}let c=Va({name:e,label:n?.label,type:i||`text`},r),l=Ct(c)||i||`text`,u=o.includes(`[object Object]`),d=u&&Fo(l)?dt(l):null;return u&&!d&&(o=String(R(t)??``)),d?(0,$.jsxs)(gt,{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)(gt,{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)(gt,{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)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:G,"aria-label":L(b?`detail.removeFromFavorites`:`detail.addToFavorites`),children:b?(0,$.jsx)(Wi,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,$.jsx)(Wi,{className:`h-4 w-4 text-muted-foreground`})})}),(0,$.jsx)(Se,{children:L(b?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),U.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||U.objectName}),U.resourceId&&(0,$.jsxs)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:W,"aria-label":L(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:ee?(0,$.jsx)(Jr,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(ci,{className:`h-3 w-3`})})}),(0,$.jsx)(Se,{children:ee?L(`detail.copied`,{defaultValue:`Copied!`}):L(`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:[U.recordNavigation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,$.jsxs)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsx)(X,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:U.recordNavigation.currentIndex<=0,onClick:()=>{let e=U.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,$.jsx)(Xr,{className:`h-4 w-4`})})}),(0,$.jsx)(Se,{children:L(`detail.previousRecord`)})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:L(`detail.recordOf`,{current:U.recordNavigation.currentIndex+1,total:U.recordNavigation.recordIds.length})}),(0,$.jsxs)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsx)(X,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:U.recordNavigation.currentIndex>=U.recordNavigation.recordIds.length-1,onClick:()=>{let e=U.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,$.jsx)(Zr,{className:`h-4 w-4`})})}),(0,$.jsx)(Se,{children:L(`detail.nextRecord`)})]})]}),U.showEdit&&(0,$.jsxs)(Tt,{children:[(0,$.jsx)(M,{asChild:!0,children:(0,$.jsxs)(X,{variant:`default`,disabled:xe,onClick:()=>{xe||De()},className:`gap-2 hidden sm:inline-flex`,children:[(0,$.jsx)(Ui,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:L(`detail.edit`)})]})}),(0,$.jsx)(Se,{children:L(`detail.editRecord`)})]}),Pe.map((e,t)=>(0,$.jsx)(qn,{schema:rr(e),data:p},`header-action-${t}`))]})]}),j(U.header,e=>(0,$.jsx)(`div`,{children:(0,$.jsx)(qn,{schema:rr(e),data:p})})),U.highlightFields&&U.highlightFields.length>0&&(0,$.jsx)(no,{fields:U.highlightFields,data:p,objectName:U.objectName,objectSchema:k}),o&&U.showHeader===!1&&(()=>{let e=p?.approval_status,n=e===`pending`||e===`in_approval`,r=S?.approvalPending??!1,i=r&&!(S?.locked??!1)?!1:(S?.locked??!1)||n,a=i||r||n,o=a?S?.approvalProgress:void 0,s=!!o&&o.need>0&&o.need<=12;return!a&&!D?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?S?.lockedReason??L(`detail.lockedTooltip`):L(`detail.approvalPendingTooltip`),children:[i?(0,$.jsx)(Ti,{className:`h-3 w-3`}):(0,$.jsx)(oi,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:L(i?`detail.lockedByApproval`:`detail.approvalPendingEditable`)})]}),t?.cancelPendingApproval&&S?.approvalIsSubmitter!==!1&&(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:Oe,disabled:re,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:L(i?`detail.cancelApprovalTooltip`:`detail.cancelApprovalTooltipUnlocked`),children:[(0,$.jsx)(ea,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:L(re?`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":L(`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`?L(`detail.approvalProgressGroups`,{got:o.got,need:o.need}):L(`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:Y(`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:Y(`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)(Jr,{className:`h-3 w-3`}):(0,$.jsx)(ii,{className:`h-2.5 w-2.5`}),(0,$.jsx)(`span`,{children:`${e.group} ${e.got}/${e.need}`})]},e.group))})]}),D&&(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:D})]})})(),U.autoTabs&&!U.tabs?.length?(()=>{let e=!!U.activities&&U.activities.length>0,n=!!s,r=!!U.history,i=[`details`,...e?[`activity`]:[],...n?[`discussion`]:[],...r?[`history`]:[]],a=U.defaultTab,c=a&&i.includes(a)?a:`details`,l=U.onTabChange,u=(0,$.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[U.sectionGroups&&U.sectionGroups.length>0&&U.sectionGroups.map((e,n)=>(0,$.jsx)(to,{group:e,data:{...p,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:Me,onEnterInlineEdit:o?Ne:void 0,autoFocusField:E,dataSource:t},n)),U.sections&&U.sections.length>0&&U.sections.map((e,n)=>(0,$.jsx)(Bo,{section:e,index:n,children:(0,$.jsx)($a,{section:e,data:{...p,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:Me,onEnterInlineEdit:o?Ne:void 0,autoFocusField:E,dataSource:t})},n)),U.fields&&U.fields.length>0&&!U.sections?.length&&(0,$.jsx)($a,{section:{fields:U.fields,columns:U.columns},data:{...p,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:Me,onEnterInlineEdit:o?Ne:void 0,autoFocusField:E,dataSource:t}),U.comments&&(0,$.jsx)(io,{comments:U.comments,onAddComment:U.onAddComment})]});return!e&&!n&&!r?(0,$.jsx)(`div`,{className:`mt-2`,children:u}):(0,$.jsxs)(je,{defaultValue:c,onValueChange:l,className:`w-full`,children:[(0,$.jsxs)(C,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,$.jsx)(Ue,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:L(`detail.details`)}),e&&(0,$.jsx)(Ue,{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:[L(`detail.activity`),(0,$.jsx)(gt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:U.activities.length})]})}),n&&(0,$.jsx)(Ue,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:L(`detail.discussion`,{defaultValue:`Discussion`})}),r&&(0,$.jsx)(Ue,{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:[L(`detail.history`,{defaultValue:`History`}),!U.history.loading&&U.history.entries.length>0&&(0,$.jsx)(gt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:U.history.entries.length})]})})]}),(0,$.jsx)(_e,{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)(_e,{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)(fo,{activities:U.activities})}),n&&(0,$.jsx)(_e,{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)(_e,{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)(yo,{entries:U.history.entries,loading:U.history.loading,emptyText:U.history.emptyText??L(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,$.jsxs)($.Fragment,{children:[U.sectionGroups&&U.sectionGroups.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:U.sectionGroups.map((e,n)=>(0,$.jsx)(to,{group:e,data:{...p,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:Me,onEnterInlineEdit:o?Ne:void 0,autoFocusField:E,dataSource:t},n))}),U.sections&&U.sections.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:U.sections.map((e,n)=>(0,$.jsx)(Bo,{section:e,index:n,children:(0,$.jsx)($a,{section:e,data:{...p,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:Me,onEnterInlineEdit:o?Ne:void 0,autoFocusField:E,dataSource:t})},n))}),U.fields&&U.fields.length>0&&!U.sections?.length&&(0,$.jsx)($a,{section:{fields:U.fields,columns:U.columns},data:{...p,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:Me,onEnterInlineEdit:o?Ne:void 0,autoFocusField:E,dataSource:t}),U.tabs&&U.tabs.length>0&&(0,$.jsx)(eo,{tabs:U.tabs,data:p}),U.comments&&(0,$.jsx)(io,{comments:U.comments,onAddComment:U.onAddComment}),U.activities&&U.activities.length>0&&(0,$.jsx)(fo,{activities:U.activities})]}),(0,$.jsx)(Do,{data:{...p,...T},objectSchema:k,objectName:U.objectName}),j(U.footer,e=>(0,$.jsx)(`div`,{children:(0,$.jsx)(qn,{schema:rr(e),data:p})}))]})})},Ho=new Set([`title`,`description`,`icon`,`fields`,`collapsible`,`defaultCollapsed`,`columns`,`showBorder`,`headerColor`,`hideEmpty`]),Uo=e=>{let t={},n={};for(let[r,i]of Object.entries(e))(Ho.has(r)?t:n)[r]=i;return(0,$.jsx)($a,{...n,section:t})};Uo.displayName=`DetailSectionNode(DetailSection)`;function Wo(e){return mt(e)??xi}function Go(e,t){let n=e?.id??e?._id;if(t){let r=nn(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 Ko(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 qo=`image`;function Jo(e){return Q.createElement(ht,{value:e})}function Yo(e){let t=e?.accessorKey||Qn(e);return t?String(t):void 0}function Xo(e){return JSON.parse(e)}function Zo(e,t,n){return!t?.isLoaded||!n?e:e.filter(e=>{let r=Yo(e);return!r||t.checkField(n,r,`read`)})}function Qo(e,t){return t?e.filter(e=>Yo(e)!==t):e}function $o(e,t){return t.size===0?e:e.filter(e=>{let n=Yo(e);return!(n&&t.has(n))})}var es=({action:e,onToolbarAction:t})=>{let n=e.visible,r=dn(Qt(n),void 0,{throwOnError:!0,label:`related-list toolbar action "${e.name}" (visible)`});if(Rt(n)&&!r)return null;let i=e.icon?Wo(e.icon):null;return(0,$.jsxs)(X,{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]})},ts=({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:S=6,pageSize:C,defaultSort:w,sortable:T=!1,filter:D,filterable:O=!1,collapsible:A=!1,defaultCollapsed:j=!1,referenceField:M,parentId:N,icon:ee})=>{let te=r!==void 0,ne=r??[],[P,F]=Q.useState(ne),[re,I]=Q.useState(()=>!!n&&!te),[L,R]=Q.useState(0),[z,ae]=Q.useState(null),[oe,B]=Q.useState(`asc`),[V,se]=Q.useState(``),[ce,le]=Q.useState(null),[ue,de]=Q.useState(!1),{ready:fe,def:H}=Tr(n??``,s),[pe,me]=Q.useState(j),[he,ge]=Q.useState(!1),[_e,ye]=Q.useState(!1),[be,xe]=Q.useState(null),[Se,Ce]=Q.useState(0),[we,Te]=Q.useState({}),{t:W}=Oa(),{fieldLabel:De}=Pr(),Oe=x(),Ae=xn(),je=Q.useMemo(()=>(_??[]).filter(e=>Ae(e?.requiredPermissions)),[_,Ae]),G=C&&C>0?C:0,Ne=O&&V!==``,K=!te&&!!n&&G>0&&!!s&&typeof s.find==`function`&&!Ne,Pe=K?L:0,Fe=K?z:null,Ie=K?oe:`asc`,Le=JSON.stringify(w??null),Re=Q.useMemo(()=>Ko(w),[Le]),ze=lr(),Be=Bn(D,ze),He=JSON.stringify(Be??null),Ue=Q.useMemo(()=>Yn(Be),[He]),We=Ue.ok?void 0:Ue.refusal,Ge=Ue.ok?Ue.node:void 0,qe=Q.useMemo(()=>{let e=Array.isArray(a)?a.map(e=>typeof e==`string`?e:e?.accessorKey||Qn(e)).filter(e=>typeof e==`string`&&e.length>0):[],t=Gt(H?.fields,e.length>0?e:void 0).filter(e=>e!==M),r=c||n||``;return!Oe?.isLoaded||!r?t:t.filter(e=>Oe.checkField(r,e,`read`))},[a,H,M,c,n,Oe]),Xe=qe.join(`,`),q=Q.useMemo(()=>new Set((Array.isArray(b)?b:[]).filter(e=>typeof e==`string`&&e.length>0)),[b]),J=Q.useMemo(()=>{let e=$o(Array.isArray(a)?a:[],q);if(e.length===0)return;let t=c||n||``,r=new Set([`id`]);for(let n of Zo(Qo(e,M),Oe,t)){let e=Yo(n);e&&r.add(e)}for(let e of qe)r.add(e);let i=H?.fields;if(i&&typeof i==`object`){let e=e=>!Oe?.isLoaded||!t||Oe.checkField(t,e,`read`),n=on(On({rowActionDefs:h,objectActions:H?.actions,userActions:H?.userActions}));for(let t of n){let n=Pt(i,t)!==void 0;(n||ur.has(t))&&(!n||e(t))&&r.add(t)}Pt(i,qo)!==void 0&&e(qo)&&r.add(qo)}return Array.from(r)},[a,q,M,c,n,Oe,qe,H,h]),Ze=J?J.join(`,`):``;Q.useEffect(()=>{te&&F(r??[])},[r,te]);let Qe=Q.useMemo(()=>_n(H?.fields,M),[H,M]),$e=y?.picker?.object,[tt,nt]=Q.useState(null);Q.useEffect(()=>{if(!he||!$e||tt||!s?.getObjectSchema)return;let e=!1;return s.getObjectSchema($e).then(t=>{e||nt(t)}).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${$e}:`,e)}),()=>{e=!0}},[he,$e,tt,s]);let it=y?.picker?.labelField||`name`,at=Q.useMemo(()=>{let e=ve(tt,{displayField:it});return e.length>0?e:void 0},[tt,it]);Q.useEffect(()=>{y&&!$e&&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,$e,n,c]),Q.useEffect(()=>{let e=!1;if(We){I(!1);return}if(n&&!te){if(!(M&&N!=null&&N!==``)){n&&(N==null||N===``)&&!M&&console.warn(`[RelatedList] "${n}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),F([]),le(null),de(!1),I(!1);return}if(I(!0),!fe)return;let t=Mn(M,N,H?.fields),r=Ge===void 0?t:ir(t,Ge);if(s&&typeof s.find==`function`){let t={$filter:r};if(qe.length>0&&(t.$expand=qe),J&&(t.$select=J),K){t.$top=G,t.$skip=Pe*G;let e=Fe?[{field:Fe,order:Ie}]:Re;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(F(r),K){let e=!n&&typeof t?.total==`number`?t.total:null;le(e),de(!n&&typeof t?.hasMore==`boolean`?t.hasMore:r.length===G)}else le(null),de(!1);I(!1)}).catch(t=>{console.error(`Failed to fetch related data:`,t),e||I(!1)})}else if(Ge!==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.`),F([]),le(null),de(!1),I(!1);else if(Qe)console.warn(`[RelatedList] "${n}" relates through the multi-value field "${M}" 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.`),F([]),le(null),de(!1),I(!1);else{let t=new URLSearchParams({[`filter[${M}]`]:String(N)}).toString();fetch(`${n}?${t}`).then(e=>e.json()).then(t=>{if(e)return;let n=Array.isArray(t)?t:t?.data||[];F(n),le(null),de(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>{e||I(!1)})}}return()=>{e=!0}},[n,te,s,M,Qe,N,Se,K,G,Pe,Fe,Ie,Le,He,Xe,Ze,fe]),Q.useEffect(()=>{K&&!re&&L>0&&P.length===0&&R(e=>Math.max(0,e-1))},[K,re,P,L]),Q.useEffect(()=>{R(0)},[n,M,N,He]),Q.useEffect(()=>{if(!n||te)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,te]),Q.useEffect(()=>{if(!s?.find||!H?.fields||!P.length)return;let e=H.fields,t=[];for(let[n,r]of Object.entries(e)){if(!Ht(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)]=Go(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,H,P]);let[ot,st]=Q.useState(null),ct=Q.useCallback(e=>{st(e)},[]),lt=Q.useCallback(async()=>{if(ot)try{await p?.(ot),Ce(e=>e+1)}catch(e){console.error(`[RelatedList] remove failed`,e)}st(null)},[ot,p]),ut=Q.useCallback(async e=>{if(!y||!s||!n||M==null||N==null)return;let t=y.picker.valueField||`id`;ye(!0),xe(null);try{for(let r of e||[]){let e=r?.[t]??r?.id;e!=null&&(y.linkField?await s.create?.(n,{[M]:N,[y.linkField]:e}):await s.update?.(y.picker.object,String(e),{[M]:N}))}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{ye(!1),ge(!1)}},[y,s,n,M,N]),pt=Q.useMemo(()=>{let e=c||n||``,t=t=>Zo(t,Oe,e),r=e=>Qo(e,M),i=e=>q.size>0&&!!e&&q.has(String(e)),o=e=>$o(e,q),s=e=>Ft(e)||typeof e==`string`&&e.trim()===``,l=e=>P.length?e.filter(e=>{let t=e?.accessorKey||Qn(e);return!t||P.some(e=>!s(e?.[t]))}):e,u=(e,t)=>{if(!t?.type)return;let n=Ct({type:t.type,format:t.format})||t.type,r=dt(n);if(!r)return;let i=t.type===`lookup`||t.type===`master_detail`,a=Ht(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.format&&{format:t.format},...t.reference&&{reference:t.reference},...t.reference_field&&{reference_field:t.reference_field}};return e=>s(e)?Q.createElement(E):Q.createElement(r,{value:c(e),field:l})},d=t=>{if(typeof t!=`string`){let e=t?.accessorKey||Qn(t);if(!t||!e)return t;let n={};if(t.accessorKey||(n.accessorKey=e),!t.header){let e=fn(t);e&&(n.header=e)}if(!t.cell&&!t.render){let t=H?.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=H?.fields?.[t],r={accessorKey:t,header:n?.label||De(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(!H?.fields)return[];let f=Array.isArray(H.highlightFields)?H.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,S))}let p=e,m=new Set([`richtext`,`markdown`,`html`,`json`]),h=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],g=Object.entries(H.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===M||t?.hidden||t?.type&&m.has(t.type)||i(e)||Oe?.isLoaded&&p&&!Oe.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:De(p,e,t.label||e)};if(t.type){let r=u(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,S))},[a,H,c,n,De,M,P,S,we,Oe,q]),mt=Er(H),ht=Q.useCallback((e,t)=>Ht(t)?!0:mt?!yr(mt,e):Cr(t),[mt]),_t=Q.useMemo(()=>K?pt.map(e=>{let t=e.accessorKey||Qn(e),n=t?H?.fields?.[t]:void 0;return ht(t,n)?{...e,sortable:!1}:e}):pt,[pt,K,H,ht]),vt=!!n&&typeof s?.getObjectSchema==`function`&&!H?.fields,yt=Q.useMemo(()=>{let e=_t.map(e=>{if(!e||typeof e!=`object`)return e;let t=e.accessorKey||Qn(e),n=t?H?.fields?.[t]:void 0,r=vt||Ra(e.type,n?.type);return vt&&typeof e.cell!=`function`?{...e,masked:!0,cell:Jo}:r&&e.masked!==!0?{...e,masked:!0}:e});return e.every((e,t)=>e===_t[t])?_t:e},[_t,H,vt]),bt=Q.useMemo(()=>JSON.stringify(yt.flatMap(e=>{if(!e||typeof e!=`object`||e.masked===!0)return[];let t=Yo(e);return t?[t]:[]})),[yt]),xt=Xo(bt),wt=Q.useMemo(()=>{if(K||!V)return P;let e=V.toLowerCase(),t=Xo(bt);return P.filter(n=>t.some(t=>{let r=n?.[t];return r!=null&&String(r).toLowerCase().includes(e)}))},[P,V,K,bt]),Tt=Q.useMemo(()=>{if(K||!z||!Xo(bt).includes(z))return wt;let e=we[z],t=wt.map(t=>({row:t,key:ln(t[z],{labels:e})}));return t.sort((e,t)=>{let n=Xn(e.key,t.key);return oe===`asc`?n:-n}),t.map(e=>e.row)},[wt,z,oe,K,we,bt]),Et=G&&!K?Tt.slice(L*G,(L+1)*G):Tt,Dt=G?K?ce==null?L+(ue?2:1):Math.max(1,Math.ceil(ce/G)):Math.max(1,Math.ceil(Tt.length/G)):1,Ot=K?ce==null?ue:(L+1)*G<ce:L<Dt-1,kt=G>0&&(K?L>0||Ot:Tt.length>G);Q.useEffect(()=>{R(0)},[V,z,oe]);let jt=Q.useCallback(e=>{Xo(bt).includes(e)&&(R(0),z===e?B(e=>e===`asc`?`desc`:`asc`):(ae(e),B(`asc`)))},[z,bt]),Mt=Q.useMemo(()=>z?[{field:z,order:oe}]:Re,[z,oe,Re]),Nt=Q.useCallback(e=>{let t=e[0];t&&Xo(bt).includes(t.field)&&(R(0),ae(t.field),B(t.order))},[bt]),It=!i&&(t===`grid`||t===`table`),Lt=Array.isArray(h)&&h.length>0,Rt=!!f||!!p||Lt,zt=et(),Bt=Q.useMemo(()=>{if(i)return i;if(zt&&(t===`grid`||t===`table`)){let e=pt[0]?.accessorKey||Qn(pt[0]),t=pt.slice(1,4).map(e=>e.accessorKey||Qn(e)).filter(Boolean);return{type:`object-gallery`,data:Et,objectName:n,gallery:{titleField:e||`name`,visibleFields:t,coverField:qo,cardSize:`medium`},onRowClick:m}}let e=tn(H?.userActions?.edit),r=tn(H?.userActions?.delete);switch(t){case`grid`:case`table`:return{type:`data-table`,data:Et,columns:yt,pagination:!1,pageSize:G||10,searchable:!1,exportable:!1,manualSorting:!0,sort:Mt,onSortChange:Nt,rowActions:Rt,onRowEdit:f,onRowDelete:p?ct:void 0,rowEditPredicates:e,rowDeletePredicates:r,onRowClick:m,rowActionDefs:Lt?h:void 0,onRowActionDef:Lt?g:void 0};case`list`:return{type:`data-list`,data:Et};default:return{type:`div`,children:`No view configured`}}},[t,Et,yt,pt,i,G,Rt,Lt,h,g,f,p,ct,m,zt,n,H,Mt,Nt]),Vt=A?`cursor-pointer select-none`:void 0,Ut=A?()=>me(e=>!e):void 0,Wt=Wo(ee),Kt=K&&ce!=null?ce:P.length,qt=!re&&P.length===0&&(!K||L===0),Jt=O;return We?(0,$.jsxs)(k,{className:Y(`shadow-none border-border/60 bg-transparent`,o),children:[(0,$.jsx)(U,{className:`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,children:(0,$.jsxs)(ke,{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)(Ee,{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:W(`view.malformedFilter`,{subject:gr(We)??``})}),(0,$.jsx)(`p`,{className:`mt-1 text-xs opacity-80`,children:We.message})]})})]}):(0,$.jsxs)(k,{className:Y(`shadow-none border-border/60 bg-transparent`,qt&&`bg-muted/10`,o),children:[(0,$.jsx)(U,{className:Y(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,Vt),onClick:Ut,children:(0,$.jsxs)(ke,{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:[A&&(pe?(0,$.jsx)(Zr,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,$.jsx)(Yr,{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:Y(`truncate`,qt&&`text-muted-foreground font-medium`),children:e}),(0,$.jsx)(gt,{variant:`secondary`,className:Y(`text-xs font-normal h-5 px-1.5`,Kt===0&&`bg-muted text-muted-foreground`),"aria-label":`${Kt} records`,children:Kt}),qt&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:W(`detail.noRelatedRecords`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[v&&je.map(e=>(0,$.jsx)(es,{action:e,onToolbarAction:v},e.name)),y&&$e&&s&&(0,$.jsxs)(X,{variant:qt?`ghost`:`outline`,size:`sm`,disabled:_e,onClick:e=>{e.stopPropagation(),xe(null),ge(!0)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,$.jsx)(Pi,{className:`h-3.5 w-3.5`}),y.label||W(`detail.add`,{defaultValue:`Add`})]}),l&&(0,$.jsxs)(X,{variant:qt?`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)(Pi,{className:`h-3.5 w-3.5`}),W(`detail.new`)]})]})]})}),!pe&&!qt&&(0,$.jsxs)(Ee,{className:Y(`pt-0 pb-4 px-4`),children:[Jt&&(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(ie,{placeholder:W(`detail.filterPlaceholder`),value:V,onChange:e=>se(e.target.value),className:`h-8 text-sm`})}),T&&!It&&pt&&pt.length>0&&P.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:pt.map(e=>{let t=e.accessorKey||Qn(e);if(!t)return null;let n=H?.fields?.[t];if(K&&ht(t,n)||!xt.includes(t))return null;let r=e.header||e.label||t,i=z===t;return(0,$.jsxs)(X,{variant:i?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>jt(t),children:[(0,$.jsx)(Vr,{className:`h-3 w-3`}),r,i&&(oe===`asc`?` ↑`:` ↓`)]},t)})}),re&&P.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:W(`detail.loading`)}):(0,$.jsx)(`div`,{className:Y(re&&`opacity-60 pointer-events-none transition-opacity`),children:(0,$.jsx)(qn,{schema:Bt})}),kt&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,$.jsxs)(X,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:L===0,onClick:()=>R(e=>Math.max(0,e-1)),children:[(0,$.jsx)(Xr,{className:`h-3 w-3`}),W(`detail.previousPage`)]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(`detail.pageOf`,{current:L+1,total:Dt})}),(0,$.jsxs)(X,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:!Ot,onClick:()=>R(e=>Ot?e+1:e),children:[W(`detail.nextPage`),(0,$.jsx)(Zr,{className:`h-3 w-3`})]})]}),d&&!qt&&kt&&(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:[W(`detail.viewAll`),(0,$.jsx)(di,{className:`h-3 w-3`})]})})]}),(0,$.jsx)(St,{open:ot!==null,onOpenChange:e=>{e||st(null)},children:(0,$.jsxs)(ft,{children:[(0,$.jsxs)(Je,{children:[(0,$.jsx)(Me,{children:W(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,$.jsx)(rt,{children:W(`detail.deleteRowConfirmation`)})]}),(0,$.jsxs)(Ye,{children:[(0,$.jsx)(Ke,{children:W(`detail.cancel`,{defaultValue:`Cancel`})}),(0,$.jsx)(Ve,{onClick:lt,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:W(`detail.delete`,{defaultValue:`Delete`})})]})]})}),be&&(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:be}),y&&$e&&s&&(0,$.jsx)(At,{open:he,onOpenChange:e=>ge(e),multiple:!0,dataSource:s,objectName:$e,title:y.label||W(`detail.add`,{defaultValue:`Add`}),displayField:it,columns:at,cellRenderer:dt,fieldsMeta:tt?.fields,baseFilter:y.picker.filter,onSelect:()=>{},onSelectRecords:e=>{ut(e)}})]})};b();function ns(e){return e==null?[]:Array.isArray(e)?e.filter(e=>e!=null):[e]}function rs(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 is(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 as(e){return Dr(e)??null}function os(e,t,n=4){if(!e)return[];let r=Array.isArray(e.highlightFields)&&e.highlightFields.length>0?e.highlightFields:null;if(r){let t=as(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`||!Bt(t)?!1:(Sr(t),!0)},u=as(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 ss(e,t={}){return rs(`page:header`,{recordChrome:t.recordChrome!==!1,...Array.isArray(t.actions)&&t.actions.length>0?{actions:t.actions}:{}})}function cs(e,t={}){let n=t.statusField??Un(e),r=t.stages??(n?is(e,n):null),i=t.highlightFields??os(e,n),a=[];return!t.hideHighlights&&i.length>0&&a.push(rs(`record:highlights`,{fields:i})),!t.hidePath&&n&&r&&r.length>0&&a.push(rs(`record:path`,{statusField:n,stages:r})),a}function ls(e){if(!e)return null;let t=v(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=Ta(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 us(e,t){return Array.isArray(t)&&t.length>0?t:ls(e)??void 0}function ds(e,t,n){return rs(`record:details`,{sections:us(e,t),...n&&n.length>0?{hideFields:n}:{}})}function fs(e,t={}){let n=t.statusField??Un(e),r=t.highlightFields??os(e,n),i=[{label:`Details`,value:`details`,children:[ds(e,t.sections,r)]}];if(!t.hideRelatedTab&&Array.isArray(t.related)&&t.related.length>0){let e=e=>rs(`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:[rs(`record:approvals`,{...t.approvals.node||{}})]}),e?.enable?.files===!0&&!t.hideAttachments&&i.push({label:`Attachments`,value:`attachments`,children:[ms()]}),t.showActivity&&i.push({label:`Activity`,value:`activity`,children:[rs(`record:activity`)]}),t.history&&i.push({label:`History`,value:`history`,children:[rs(`record:history`,{entries:t.history.entries,loading:t.history.loading,emptyText:t.history.emptyText,unknownUserText:t.history.unknownUserText})]}),rs(`page:tabs`,{items:i})}function ps(){return rs(`record:discussion`)}function ms(){return rs(`record:attachments`)}function hs(e,t={}){let n=t.slots||{},r=[];`header`in n&&n.header!==void 0?r.push(...ns(n.header)):r.push(ss(e,{recordChrome:t.recordChrome,actions:t.headerActions})),`actions`in n&&n.actions!==void 0&&r.push(...ns(n.actions)),`alerts`in n&&n.alerts!==void 0&&r.push(...ns(n.alerts)),`highlights`in n&&n.highlights!==void 0?r.push(...ns(n.highlights)):r.push(...cs(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(...ns(n.tabs));else if(`details`in n&&n.details!==void 0){let i=ns(n.details),o=fs(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(fs(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(...ns(n.discussion)):t.hideDiscussion||r.push(ps());let o=[{name:`main`,width:`full`,components:r}],s=ns(n.rightRail);if(i||s.length>0){let e=[];i&&e.push(rs(`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 gs(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 _s(e,t){let n=gs(e,t);(0,Q.useEffect)(()=>{n&&console.warn(n)},[n])}function vs(e,{defaultRole:t,defaultLabel:n,block:r}={}){let i=Fr();_s(r,e);let a=zn(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 ys=e=>Qn(e)??null;function bs(e){return e===void 0?void 0:Number(e)}var xs=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}},Ss=new Set;function Cs(e,t){let n=`${e}.${t}`;Ss.has(n)||(Ss.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 ws=({schema:e={},className:t,...n})=>{let r=qt(),{designer:i}=xs(n),a=vs(e.aria),o=r?.objectName||``,s=x(),{readableFields:c}=he(o),{sectionLabel:l}=Pr(),{language:u}=Ir(),d=Cn();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(ys).filter(e=>!!e),n=new Set((p&&o?c(t):t).filter(e=>!m.includes(e)));return e.filter(e=>{let t=ys(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=Nr(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:ys(e)).filter(e=>!!e));for(let e of d)S.add(e);let C=Vn(r.data??{},s,o),w=[Dr(g),hn(g),`name`,`full_name`,`title`,`subject`,`display_name`,`label`].filter(e=>typeof e==`string`&&e.length>0),T=un(g);if(vn(C,T)!==void 0)S.add(T);else{let e=g?.titleFormat,t=Xt(e,C);if(t){let n=e=>vn(C,e)===t,r=w.find(n)??Object.keys(C).find(r=>n(r)&&Xt(e,{...C,[r]:void 0})!==t);r&&S.add(r)}else for(let e of w)if(vn(C,e)!==void 0){S.add(e);break}}let E=e=>!e||S.size===0?e:e.filter(e=>{let t=ys(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 ls(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 Cs(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:Nr(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=mn(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:bs(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)(Vo,{schema:N,dataSource:r.dataSource,inlineEdit:M})})},Ts=e=>({toolbar:[],row:[],refused:e});function Es(e){if(!Array.isArray(e))return!1;let t=jn(e,void 0);return t.kind===`ids`&&t.ids.length>0}function Ds(e,t){if(!Array.isArray(e))return Ts([{kind:`array`,message:"`actions` is not an array; it is a list of action ids"}]);let n=jn(e,t);if(n.kind===`refused`)return Ts([{kind:`array`,message:`${n.message} (on this block: action ids only)`}]);if(n.kind===`objects`)return e.length===0?Ts([]):Ts([{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=Dn(t,`list_toolbar`),s=Dn(t,`list_item`)||Dn(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 Os(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 ks=e=>Qn(e)||(e&&typeof e==`object`?e.key:null)||null,As=e=>e?.id??e?._id??null,js=5,Ms=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}},Ns=({schema:e={},className:t,...n})=>{let r=qt(),{designer:i}=Ms(n),a=vs(e.aria),o=Pr(),{language:s}=Ir(),c=e.objectName,l=c&&o.objectLabel?o.objectLabel({name:c,label:yn(c)}):c?yn(c):``,u=Nr(e.title,s)||l||`Related`,d=x(),{readableFields:f}=he(c||``),p=e.relationshipValueField||`id`,m=p===`id`?r?.recordId??null:r?.data?.[p]??null,h=Jt(),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&&Es(_),{item:b,loading:S}=an(`object`,y?c:null),C=Wt(),w=Q.useMemo(()=>{if(!v)return null;if(y&&S)return{toolbar:[],row:[],refused:[]};let e=Array.isArray(b?.actions)?b.actions:[],t=Ds(_,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(ks).filter(e=>!!e),t=new Set((E?f(e):e).filter(e=>!D.includes(e)));k=O.filter(e=>{let n=ks(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:Os(M,c,!!b)}),(0,$.jsx)(ts,{title:u,type:`table`,api:c,objectName:c,referenceField:e.relationshipField,parentId:m,columns:k,redactFields:D.length>0?D:void 0,pageSize:typeof e.limit==`number`&&e.limit>0?e.limit:js,defaultSort:e.sort,filter:e.filter,dataSource:r?.dataSource,add:e.add?{...e.add,label:Nr(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=As(e);t!=null&&g.onView(t,e)}:void 0,onRowEdit:g?.onEdit?e=>{let t=As(e);t!=null&&g.onEdit(t,e)}:void 0,onRowDelete:g?.onDelete?e=>{let t=As(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})]})},Ps={columns:!0,filter:!0,sort:!0,limit:`limit`},Fs={},Is=En(e=>{let t=qt();return(0,$.jsx)(_r,{schema:e.schema??Fs,mapping:Ps,dataSource:t?.dataSource,testId:`record-related-list`,errorTitle:`This related list’s data source could not be resolved`,children:t=>(0,$.jsx)(Ns,{...e,schema:t})})}),Ls=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}},Rs=({schema:e={},className:t,...n})=>{let r=qt(),{designer:i}=Ls(n),a=vs(e.aria),o=r?.objectName||``,s=x(),{readableFields:c}=he(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 Ut(g,u?h.map(e=>e.name):[]),u?(0,$.jsx)(`div`,{className:t,...i,...a,children:(0,$.jsx)(no,{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.`})})},zs=({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:Y(`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)(Br,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`text-foreground`,children:i})]})},Bs=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],Vs=({reactions:e,onToggleReaction:t,emojiOptions:n=Bs,className:r})=>{let[i,a]=Q.useState(!1),{t:o}=Oa(),s=Q.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,$.jsxs)(`div`,{className:Y(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>{let n=o(e.count===1?`detail.reactionCountOne`:`detail.reactionCount`,{emoji:e.emoji,count:e.count});return(0,$.jsxs)(`button`,{type:`button`,className:Y(`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)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":o(`detail.addReaction`),children:(0,$.jsx)(mi,{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 Hs(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 Us=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=Oa(),o=Fr(),[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:Y(`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)(Yr,{className:`h-3 w-3`}):(0,$.jsx)(Zr,{className:`h-3 w-3`}),(0,$.jsx)(Di,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{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:Hs(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)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:p,disabled:!l.trim()||d,"aria-label":`Send reply`,children:(0,$.jsx)(Bi,{className:`h-3 w-3`})})]})]})},Ws=({subscription:e,onToggle:t,className:n})=>{let{t:r}=Oa(),[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)(X,{variant:`ghost`,size:`icon`,className:Y(`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)(Gr,{className:`h-4 w-4 text-primary`}):(0,$.jsx)(Wr,{className:`h-4 w-4 text-muted-foreground`})})};function Gs(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 Ks=({value:e,onChange:t,onSubmit:n,mentionSuggestions:r=[],placeholder:i,className:a,disabled:o=!1,extraSlot:s,canSubmitEmpty:c=!1})=>{let{t:l}=Oa(),[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:Y(`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)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:x,disabled:o||u,title:l(`detail.bold`),children:(0,$.jsx)(Kr,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:S,disabled:o||u,title:l(`detail.italic`),children:(0,$.jsx)(Si,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:C,disabled:o||u,title:l(`detail.listFormat`),children:(0,$.jsx)(Ci,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:o||u,title:l(`detail.inlineCode`),children:(0,$.jsx)(si,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:o||u,title:l(`detail.mentionSomeone`),children:(0,$.jsx)(Hr,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>d(!u),title:l(u?`detail.edit`:`detail.preview`),children:u?(0,$.jsx)(Ui,{className:`h-3.5 w-3.5`}):(0,$.jsx)(pi,{className:`h-3.5 w-3.5`})}),n&&(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:n,disabled:o||!c&&!e.trim(),title:l(`detail.submitComment`),children:(0,$.jsx)(Bi,{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:Gs(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:Y(`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 qs(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Js(e){return e.startsWith(`image/`)}function Ys(e){return Js(e)?bi:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?_i:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?hi:vi}var Xs=({attachments:e,onUpload:t,onRemove:n,className:r,readOnly:i=!1})=>{let{t:a}=Oa(),[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:Y(`space-y-2`,r),children:[t&&!i&&(0,$.jsxs)(`div`,{className:Y(`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)(Qi,{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)(Ai,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:e.length===1?a(`detail.attachmentCount`,{count:e.length}):a(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=Js(e.type),r=Ys(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:qs(e.size)})]}),n&&!i&&(0,$.jsx)(X,{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)(ea,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},Zs={comment:Di,field_change:Ui,task:Hi,event:qr,system:ta,email:Ei,call:Mi,note:Gi,file:_i,sharing:Vi,record_create:ni,record_delete:Ji,approval:Ur},Qs={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 $s(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 ec(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 tc(e){return e.type===`comment`}function nc(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 rc=({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}=Oa(),x=Fr(),[S,C]=Q.useState(`all`),[w,T]=Q.useState(``),[E,D]=Q.useState(!1),[k,A]=Q.useState(!1),[j,M]=Q.useState([]),[N,ee]=Q.useState(!1),te=h??b(`detail.activity`),ne=_||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)(Ti,{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)(Ti,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:b(`detail.commentsAccessDenied`)})]})]}):null,P=n??S,F=t?.showFilterToggle!==!1,re=t?.showCommentInput!==!1&&!!s,L=t?.enableReactions??!1,R=t?.enableThreading??!1,ie=t?.showSubscriptionToggle??!1,z=Q.useMemo(()=>nc(e,P),[e,P]),ae=Q.useMemo(()=>R?z.filter(e=>!e.parentId):z,[z,R]),oe=Q.useMemo(()=>{if(!R)return new Map;let e=new Map;for(let t of z)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[z,R]),B=Q.useCallback(e=>{r?r(e):C(e)},[r]),se=Q.useCallback(async()=>{let e=w.trim();if(s&&(e||j.length!==0)){D(!0);try{await s(e,j.length>0?j:void 0),T(``),M([])}catch{}finally{D(!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:Y(`border-t border-border/60 pt-5`,y),"aria-label":te,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)(Lr,{className:`h-4 w-4`}),te,(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,z.length,`)`]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:ie&&u&&(0,$.jsx)(Ws,{subscription:u,onToggle:d})})]})}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[F&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(I,{value:P,onValueChange:e=>B(e),children:[(0,$.jsx)(jt,{"aria-label":b(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,$.jsx)(O,{})}),(0,$.jsx)(V,{children:$s(b).map(e=>(0,$.jsx)(ye,{value:e.value,children:e.label},e.value))})]})}),re&&(0,$.jsx)(Ks,{value:w,onChange:T,onSubmit:se,mentionSuggestions:p,placeholder:b(`detail.leaveCommentPlaceholder`),disabled:E,canSubmitEmpty:j.length>0,extraSlot:m?(0,$.jsx)(Xs,{attachments:j,onUpload:ce,onRemove:le,readOnly:E||N}):j.length>0?(0,$.jsx)(Xs,{attachments:j,onRemove:le,readOnly:E}):void 0}),z.length>0&&ne,o&&z.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)(wi,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:b(`detail.loading`)})]}):(_||v)&&z.length===0?ne:z.length===0?f?null:(0,$.jsx)(qe,{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:ae.map(e=>{let t=Zs[e.type]||ta,n=Qs[e.type]||`bg-gray-100 text-gray-600`,r=oe.get(e.id)??[],i=L&&l&&tc(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:Y(`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:ec(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)(zs,{change:e},t))}),L&&e.reactions&&e.reactions.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(Vs,{reactions:e.reactions,onToggleReaction:i})}),(!e.reactions||e.reactions.length===0)&&i&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(Vs,{reactions:[],onToggleReaction:i})})]})]}),R&&(e.replyCount??0)>0&&(0,$.jsx)(Us,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,$.jsx)(`div`,{className:`text-center pt-2`,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:ue,disabled:k,"aria-label":b(`detail.loadMore`),children:[k?(0,$.jsx)(wi,{className:`h-4 w-4 animate-spin mr-1`}):(0,$.jsx)(Yr,{className:`h-4 w-4 mr-1`}),b(`detail.loadMore`)]})})]})]})};b();var ic=c.options,ac=m.options,oc={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},sc=`system`,cc=[`comment`],lc=[`record_create`,`record_delete`,`sharing`],uc=new Set([...Object.values(oc).filter(e=>!!e),sc,...cc]),dc=new Set([`task`]);function fc(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 pc=new Set,mc=new Set,hc=new Set;function gc(e,t){if(typeof e==`string`&&ic.includes(e))return e;if(e!=null){let n=typeof e==`string`?`"${e}"`:typeof e;fc(hc,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: ${ic.join(`, `)}.`)}return`all`}function _c(e,t){let n=e.filter(e=>!uc.has(e));n.length!==0&&fc(mc,t,n,e=>{let n=e=>e.map(e=>`"${e}"`).join(`, `),r=e.filter(e=>lc.includes(e)),i=e.filter(e=>!lc.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: ${[...uc].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 vc(e,t){if(e==null)return;if(!Array.isArray(e)){let n=typeof e==`string`?`"${e}"`:typeof e;return fc(pc,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: ${ac.join(`, `)}.`),[]}let n=[],r=[];for(let t of e)typeof t==`string`&&ac.includes(t)?n.push(t):r.push(typeof t==`string`?t:String(t));return r.length>0&&fc(pc,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: ${ac.join(`, `)}.`),_c(n,t),n}function yc(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function bc(e){return yc(e)?e:20}function xc(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 Sc(e,t){return t==null||yc(t)?null:`[ObjectUI] ${e} row cap: declared limit: ${xc(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 Cc(e){let t=e.timestamp;return String(!t||t===`NOW()`||Number.isNaN(Date.parse(String(t)))?e.created_at??``:t)}var wc=new Set;function Tc(e){fc(wc,``,[e],()=>`[record:activity] rendered a sys_activity row with type "${e}" through the generic "${sc}" 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 Ec(e,t){let n=String(e?.type),r=Object.prototype.hasOwnProperty.call(oc,n);r||Tc(n);let i=r?oc[n]:sc;return i?{id:e.id,type:i,actor:e.actor_name??t,actorAvatarUrl:e.actor_avatar_url??void 0,body:e.summary??``,createdAt:Cc(e),sourceObject:e.source_object??void 0,sourceId:e.source_id??void 0}:null}function Dc(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=>!dc.has(e.type)));let a=vc(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 Oc(...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 kc(e){let t=dr(e);return t===`forbidden`||t===`unauthorized`}var Ac=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}},jc=`record:activity`,Mc=({schema:e={},className:t,...n})=>{let{designer:r}=Ac(n),i=vs(e.aria),a=qt(),o=wn(),s=kr(),c=e.properties??{},l=t=>e[t]??c[t],u=l(`limit`),d=bc(u),f=Sc(jc,u);Q.useEffect(()=>{f&&console.warn(f)},[f]);let p=gc(l(`filterMode`),jc),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),te=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=Ec(e,te);t&&i.push(t)}A(r.length>Math.max(1,E)),O(Oc(i)),ee(!1)}).catch(t=>{e||(O([]),A(!1),ee(kc(t)))}).finally(()=>{e||M(!1)}),()=>{e=!0}},[C,S,b,x,E,te]);let ne=o?.items,P=Q.useMemo(()=>Dc(v??ne??D??[],{types:m,showCompleted:h,unifiedTimeline:g},E,jc),[v,ne,D,m,h,g,E]),F=P.items,re=P.hasMore||C&&k,I=y??o?.loading??(C&&D===null?!0:j),L=v===void 0?o?!!o.activityDenied:C&&N:!1,R=v===void 0&&!!o?.commentsDenied,[ie,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)(rc,{items:F,config:_,loading:I,filterMode:ie,onFilterChange:z,hasMore:re,onLoadMore:ae,onAddComment:o?.onAddComment,onAddReply:o?.onAddReply,onToggleReaction:o?.onToggleReaction,mentionSuggestions:oe?o?.mentionSuggestions:void 0,onUploadAttachments:o?.onUploadAttachments,activityDenied:L,commentsDenied:R})})},Nc=({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}=Oa(),[C,w]=Q.useState(x),T=vs(e?.feed?.aria);return v===`right`||v===`left`?C&&b?(0,$.jsx)(`div`,{className:Y(`flex items-start pt-4`,v===`right`?`border-l`:`border-r`,_),children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>w(!1),"aria-label":S(`detail.openDiscussion`),children:(0,$.jsx)(ki,{className:`h-4 w-4`})})}):(0,$.jsxs)(`div`,{className:Y(`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)(Di,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:S(`detail.discussion`)})]}),b&&(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>w(!0),"aria-label":S(`detail.closeDiscussion`),children:(0,$.jsx)(ea,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,$.jsx)(`div`,{...T,children:(0,$.jsx)(rc,{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:Y(``,_),children:b&&C?(0,$.jsxs)(X,{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)(Di,{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)(Di,{className:`h-4 w-4`}),S(`detail.discussion`)]}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>w(!0),"aria-label":S(`detail.hideDiscussion`),children:(0,$.jsx)(Oi,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{...T,children:(0,$.jsx)(rc,{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})})]})})},Pc=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}},Fc=({schema:e={},className:t,...n})=>{qt();let r=wn(),{designer:i}=Pc(n),a=vs(e.aria),o={position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0},...e},s=o.feed,[c,l]=Q.useState(0),u=bc(s?.limit),d=typeof e.type==`string`&&e.type?e.type:`record:chatter`,f=Sc(`${d} feed`,s?.limit);Q.useEffect(()=>{f&&console.warn(f)},[f]);let p=u*(c+1),m=gc(s?.filterMode,d),[h,g]=Q.useState(m);Q.useEffect(()=>{g(m)},[m]);let _=r?.items,v=Q.useMemo(()=>Dc(_??[],{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)(Nc,{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})})},Ic=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 Lc(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:Nr(a,t)})}return n??e}var Rc=({schema:e={},className:t,...n})=>{let r=qt(),{translateOptions:i}=Pr(),{t:a}=Oa(),{designer:o}=Ic(n),s=vs(e.aria,{defaultRole:`list`,defaultLabel:a(`detail.pathLabel`),block:`record:path`}),{language:c}=Ir(),l=e.statusField,u=e.stages,d=u===void 0,f=r?.objectSchema,p=Q.useMemo(()=>Lc(d?is(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)=>Y(`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)=>Y(`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:Y(`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:Y(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:Y(`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`})})})]})},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}},Bc=Object.freeze([]),Vc=new Set;function Hc(e,t,n){let r=`${e}::${t}::${n.index}::${n.message}`;Vc.has(r)||(Vc.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 Uc=({schema:e={},className:t,...n})=>{let r=qt(),{designer:i}=zc(n),a=vs(e.aria,{defaultRole:`toolbar`,defaultLabel:`Quick actions`,block:`record:quick_actions`}),o=x(),s=Wt(),c=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:Bc,l=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:Bc,u=r?.objectName||``,d=l.length>0?`actionNames`:`actions`,f=l.length>0?l:c,p=jn(f,void 0),m=p.kind===`ids`&&p.ids.length>0&&!!u,{item:h}=an(`object`,m?u:null),g=jn(f,Array.isArray(h?.actions)?h.actions:[]);g.kind===`refused`&&Hc(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:S}=Vt({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 C=_.length>0?b(y):[];if(C.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 w=e.align||`end`,T=w===`start`?`justify-start`:w===`center`?`justify-center`:`justify-end`,E=y===`record_header`&&!e.inline;return(0,$.jsx)(`div`,{className:Y(`flex flex-wrap items-center gap-2`,E&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,T,t),...a,...i,children:C.map((t,n)=>(0,$.jsx)(Wc,{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 S(t.name)}},t.name||`qa-${n}`))})};function Wc({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=dn(Qt(e.disabled),c),u=(Rt(e.disabled)?l:!1)||o;return(0,$.jsxs)(X,{variant:n,size:r,disabled:u,onClick:async()=>{s(!0);try{await a()}finally{s(!1)}},children:[o&&(0,$.jsx)(wi,{className:`mr-2 h-4 w-4 animate-spin`}),i]})}var Gc=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}},Kc=new Set([`created`,`updated`,`assigned`,`shared`,`deleted`]),qc=50;function Jc(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function Yc(e){return Jc(e)?e:qc}function Xc(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 Zc(e){return e==null||Jc(e)?null:`[ObjectUI] record:history row cap: declared limit: ${Xc(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 (${qc}).`}var Qc=({schema:e={},className:t,...n})=>{let{designer:r}=Gc(n),i=qt(),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=Yc(l),d=Zc(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=>Kc.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)(yo,{entries:b,loading:x,emptyText:s,unknownUserText:c})})},$c=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 el(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function tl(e,t){return el(e)?e:t}function nl(e,t){return e==null||el(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 rl=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),il=(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||`—`,al=({schema:e={},className:t,...n})=>{let a=qt(),o=Pr(),{t:s}=Oa(),{designer:c}=$c(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}:${tl(e.limit,3)}`)),T=JSON.stringify(u.map(e=>[e.objectName,e.limit??null]));Q.useEffect(()=>{for(let e of u){let t=nl(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:Mn(e.relationshipField,d,n),$top:tl(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(!_n(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,A=new Set(u.filter(e=>{let t=p[e.objectName];return O&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),j=u.filter(e=>E||!A.has(e.objectName)),M=u.filter(e=>A.has(e.objectName)).map(e=>e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:rl(e.objectName)}):rl(e.objectName)));return(0,$.jsxs)(`div`,{ref:h,className:Y(`flex flex-col gap-3`,e.className,t),...c,children:[j.map(e=>{let t=e.objectName,n=p[t]||{loading:!0,total:0,items:[]},r=_n(b[t],e.relationshipField),a=e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:rl(e.objectName)}):rl(e.objectName));return(0,$.jsxs)(k,{className:`overflow-hidden`,children:[(0,$.jsxs)(U,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,$.jsx)(ke,{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)(gt,{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)(Ee,{className:`p-0`,children:n.loading?(0,$.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,$.jsx)(H,{className:`h-3.5 w-4/5`}),(0,$.jsx)(H,{className:`h-3.5 w-3/5`}),(0,$.jsx)(H,{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=il(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)(Zr,{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&&M.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:M.join(` · `),children:[(0,$.jsx)(`span`,{children:s(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:M.length})}),(0,$.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,M.join(` · `),`)`]})]})]})};function ol(e){let t=xr(e?.properties)?e.properties:{};return{...e,...t}}var sl={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`}},cl=({schema:e={},className:t})=>{let n=ol(e),r=qt(),i=r?.data,a=r?.objectName||``,o=r?.recordId??i?.id,{language:s}=Ir(),c=Nr(n.title,s),l=Nr(n.body,s),u=Nr(n.action?.label,s),d=[`info`,`warning`,`error`,`success`].includes(n.severity)?n.severity:`info`,f=sl[d],p=n.icon||f.icon,m=gn(i),h=Qt(n.visible),g=!!i&&Object.keys(i).length>0,_=dn(g?h:void 0,m),v=Q.useMemo(()=>{if(!n.dismissible)return null;let e=n.dismissKey||Nr(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}=an(`object`,x&&a?a:null),C=Q.useMemo(()=>{let e=jn(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}=Vt({actions:w,context:{record:i,recordId:o,objectName:a}});return y||!g||h!==void 0&&!_?null:(0,$.jsxs)(yt,{className:Y(`relative pr-12`,f.wrap,t),role:d===`error`?`alert`:`status`,"aria-live":d===`error`?`assertive`:`polite`,children:[(0,$.jsx)(we,{name:p,className:`h-4 w-4`,"aria-hidden":`true`}),c?(0,$.jsx)(tt,{children:c}):null,l||C?(0,$.jsxs)(Le,{children:[l?(0,$.jsx)(`p`,{className:`mb-2 last:mb-0`,children:l}):null,C?(0,$.jsx)(X,{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)(we,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},ll=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)}},ul=(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()}},dl=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:a=!1})=>{let{t:o}=Oa(),s=Fr(),c=t?.label||t?.field||``,l=t?ll(t.pendingValue):``,u=t?ll(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=ul(d.updated_at??t?.currentVersion,s),[m,h]=o(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,$.jsx)(St,{open:e,onOpenChange:e=>{!e&&!a&&i()},children:(0,$.jsxs)(ft,{className:`max-w-lg`,children:[(0,$.jsx)(Je,{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)(Yi,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Me,{children:o(`detail.concurrentUpdateTitle`)}),(0,$.jsxs)(rt,{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)(Ye,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:Y(Fe({variant:`ghost`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateCancel`)}),(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:r,className:Y(Fe({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:Y(Fe({variant:`default`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateReload`)})]})]})})};function fl(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}function pl(e){let t=e?.message||e?.error||String(e??`Save failed`);return String(t).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``)}function ml(e,t){return In(e)||(t?[{field:t,message:or(e)||pl(e)}]:null)}async function hl(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 gl=({dataSource:e,objectName:t,recordId:n,data:r,refresh:i,fieldLabelFor:a,onFieldSave:o,locked:s=!1,lockedHint:c,className:l})=>{let{t:u}=Oa(),d=Z(),[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=ml(e,t);if(!n){d.setFieldErrors(null),d.setError(pl(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 hl(e,t,n,a,o?{ifMatch:o}:void 0),await i?.()}d.reset()}catch(e){fl(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 hl(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:Y(`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)(X,{variant:`ghost`,size:`sm`,onClick:d.cancel,disabled:d.saving,className:`gap-2`,children:[(0,$.jsx)(ea,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:u(`detail.cancel`)})]}),(0,$.jsxs)(X,{variant:`default`,size:`sm`,onClick:b,disabled:d.saving||s,className:`gap-2`,title:s?c:void 0,children:[d.saving?(0,$.jsx)(wi,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(Jr,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:d.saving?u(`detail.saving`):u(`detail.save`)})]})]}),(0,$.jsx)(dl,{open:!!f,conflict:f,busy:m,onCancel:x,onReload:S,onOverwrite:C})]})},_l=new Set(Ln);function vl(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=Ht(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 yl=`min(960px, 60vw)`;function bl({record:e,objectName:t,recordId:n,dataSource:r,objectSchema:i,columns:a=2,systemFields:o=_l,onFieldSave:s,onDelete:c,onClose:l,fullPageHref:u}){let{t:d}=Oa(),f=vl(e,i,o);return(0,$.jsxs)($t,{canEdit:!!s,children:[(0,$.jsx)(Vo,{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)(gl,{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 xl(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 Sl(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 Cl=t({DetailView:()=>Vo,DetailViewRenderer:()=>wl,RECORD_OVERLAY_DEFAULT_WIDTH:()=>yl,RecordActivityRenderer:()=>Mc,RecordAlertRenderer:()=>cl,RecordChatterRenderer:()=>Fc,RecordDetailsRenderer:()=>ws,RecordHighlightsRenderer:()=>Rs,RecordHistoryRenderer:()=>Qc,RecordPathRenderer:()=>Rc,RecordQuickActionsRenderer:()=>Uc,RecordReferenceRailRenderer:()=>al,RecordRelatedListRenderer:()=>Is,RelatedList:()=>ts,UNMAPPED_ACTIVITY_FEED_TYPE:()=>sc,buildDefaultPageSchema:()=>hs}),wl=En(({schema:e,dataSource:t,...n})=>{let r=cr(t);return(0,$.jsx)(_r,{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:Hn(`detail-view`,e?.objectName),children:e=>(0,$.jsx)(Vo,{schema:e,dataSource:r,...n})})});kn.register(`detail-view`,wl,{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:[]}}),kn.register(`detail-section`,Uo,{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(Ja),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."}]}),kn.register(`related-list`,ts,{namespace:`plugin-detail`,label:`Related List`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,required:!0},{name:`type`,type:`enum`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Table`,value:`table`}]},{name:`api`,type:`string`},{name:`data`,type:`array`},{name:`columns`,type:`array`}]}),kn.register(`detail`,Vo,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`recordId`,type:`string`},{name:`fields`,type:`array`}]}),kn.register(`details`,ws,{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."}]}),kn.register(`related_list`,Is,{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`,required:!0,description:`Fields to display in the related list`},{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."}]}),kn.register(`highlights`,Rs,{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."}]}),kn.register(`activity`,Mc,{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 Tl=[{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.`}];kn.register(`chatter`,Fc,{namespace:`record`,skipFallback:!0,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`,inputs:Tl}),kn.register(`discussion`,Fc,{namespace:`record`,skipFallback:!0,category:`record`,label:`Discussion`,icon:`MessageSquare`,inputs:Tl}),kn.register(`path`,Rc,{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)`}]}),kn.register(`quick_actions`,Uc,{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:[...g],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`}]}),kn.register(`history`,Qc,{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`}]}),kn.register(`reference_rail`,al,{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`}]}),kn.register(`alert`,cl,{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`}]}),kn.register(`permission-facet-link`,Ae(ja),{namespace:`field`,skipFallback:!0});var El={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 Dl(e){if(e.startsWith(`bg-`))return e;let t=e.toLowerCase().trim();return Object.prototype.hasOwnProperty.call(El,t)?El[t]:void 0}function Ol(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 Dl(r)},[e?.field,e?.colors])}function kl(e){if(e==null||e===``)return``;if(Array.isArray(e))return e.map(e=>kl(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 Al(e,t){return kl(e[t])}function jl(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 jl(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 Ml(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 Nl(e,t,n){let r=e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`});return n===`desc`?-r:r}function Pl(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 Fl={sum:`sum`,count:`count`,avg:`avg`,min:`min`,max:`max`,count_distinct:`count_unique`};function Il(e){return Object.prototype.hasOwnProperty.call(Fl,e)?Fl[e]:void 0}function Ll(e,t){if(!t||t.length===0)return[];let n=[];for(let{field:r,type:i}of t){let t=Il(i);if(!t||typeof r!=`string`||r===``)continue;let a=d(e,t,r);a!==void 0&&n.push({field:r,type:i,value:a===null?null:Number(a)})}return n}function Rl(e,t){let n=e==null,r=t==null;return n||r?n&&r:e===t||String(e)===String(t)}function zl(e,t,n,r,i){let a=e?.fields,o=(0,Q.useMemo)(()=>Pl(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=>Rl(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:kl(t),label:n??jl(t,l.field,r)}}),f=l.order??`asc`;return d.sort((e,t)=>Nl(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:Ll(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=Al(e,l.field);u.has(t)||(u.set(t,{label:jl(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)=>Nl(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?Ml(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 Bl(e){let t=[];for(let n of e??[]){if(!n||typeof n.field!=`string`||n.field===``)continue;let e=Il(n.type);e&&t.push({field:n.field,summary:e})}return t}function Vl(e){return{fields:e.map(e=>({field:e.field}))}}var Hl={headers:void 0,keyLabels:{},loading:!1,error:null};function Ul(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 Wl(e){let{enabled:t,dataSource:n,objectName:r,fields:i,where:a,search:o,searchFields:s,aggregations:c,objectFields:l,reloadKey:u}=e,[d,f]=(0,Q.useState)(Hl),p=JSON.stringify(i.map(e=>e.field)),m=JSON.stringify(a??null),h=JSON.stringify(o?{search:o,...s&&s.length>0?{searchFields:[...s]}:{}}:null),g=JSON.stringify(Bl(c)),v=JSON.stringify(i.map(e=>{let t=l?.[e.field];return Ht(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;return(0,Q.useEffect)(()=>{if(!y||!n||!r){f(e=>e===Hl?e:Hl);return}let e=!1;f(e=>({...e,loading:!0,error:null}));let t=JSON.parse(p),i=JSON.parse(v),a=Vl(t.map(e=>({field:e}))),o=JSON.parse(g),s=JSON.parse(m),c=JSON.parse(h);return(async()=>{try{let l=await Promise.all(t.map((e,t)=>{let i=_({grouping:a,columns:o},{...s?{where:s}:{},depth:t+1});return n.queryGroupHeaders(r,c?{...i,...c}:i)})),u={},d=l[l.length-1]??[];await Promise.all(t.map(async(e,t)=>{let r=i[t];if(!r)return;let[a,o]=r,s=[...new Set(d.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))}u[e]=r}catch(t){console.warn(`[ObjectGrid] Failed to resolve group labels for '${e}' (${a}):`,t)}})),e||f({headers:l,keyLabels:u,loading:!1,error:null})}catch(t){e||f({headers:void 0,keyLabels:{},loading:!1,error:t instanceof Error?t:Error(String(t))})}})(),()=>{e=!0}},[y,n,r,p,m,h,g,v,u]),d}function Gl(e){let{enabled:t,dataSource:n,objectName:r,fields:i,where:a,baseParams:o,pageSize:c,leaves:l,reloadKey:u}=e,[d,f]=(0,Q.useState)({}),p=JSON.stringify(i.map(e=>e.field)),m=JSON.stringify(a??null),h=JSON.stringify(o??null),g=JSON.stringify(l.map(e=>[e.key,e.keyValues])),_=JSON.stringify([p,m,h,c,u]),[v,y]=(0,Q.useState)({queryKey:_,pages:{}}),b=v.queryKey===_?v.pages:{},x=t&&!!r&&!!n&&o!==null&&i.length>0,S=JSON.stringify(b);return(0,Q.useEffect)(()=>{if(!x||!n||!r||!o)return;let e=Vl(JSON.parse(p).map(e=>({field:e}))),t=JSON.parse(m),i=JSON.parse(g);for(let[a,l]of i){let i=JSON.parse(S)[a]??1,u=JSON.stringify([_,a,i]);if(d[a]?.signature===u)continue;f(e=>({...e,[a]:{rows:e[a]?.rows??[],page:i,loading:!0,error:null,signature:u}}));let p=s({grouping:e},l,{...t?{where:t}:{},limit:c,offset:(i-1)*c}),{$filter:m,...h}=o,g={...h,$filter:p.where,$top:p.limit,$skip:p.offset};n.find(r,g).then(e=>{f(t=>t[a]?.signature===u?{...t,[a]:{rows:e?.data??[],page:i,loading:!1,error:null,signature:u}}:t)}).catch(e=>{f(t=>t[a]?.signature===u?{...t,[a]:{rows:[],page:i,loading:!1,error:e instanceof Error?e:Error(String(e)),signature:u}}:t)})}},[x,n,r,p,m,g,S,_,c]),{pages:d,setPage:(0,Q.useCallback)((e,t)=>{y(n=>{let r=n.queryKey===_?n.pages:{};return r[e]===t&&n.queryKey===_?n:{queryKey:_,pages:{...r,[e]:t}}})},[_])}}var Kl=({groupKey:e,label:t,count:n,collapsed:r,aggregations:i,fieldLabel:a,labelColorClass:o,labelColorStyle:s,onToggle:c,children:l})=>{let u=o?Y(`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)(Zr,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,$.jsx)(Yr,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:Y(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 ql=new Set([`count`,`count_empty`,`count_filled`,`count_unique`,`percent_empty`,`percent_filled`]),Jl=new Set([`percent_empty`,`percent_filled`]),Yl={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`},Xl=Ar({"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`),Zl=new Set(Object.keys(Yl)),Ql=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function $l(e){if(typeof e==`object`)try{return JSON.stringify(e)??String(e)}catch{return String(e)}return e}function eu(e){return typeof e==`string`?{type:e}:e}function tu(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 nu(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 ru(e,t,n){if(ql.has(e)){let r=t.length;if(r===0)return null;switch(e){case`count`:return r;case`count_filled`:return t.filter(e=>!Ql(e[n])).length;case`count_empty`:return t.filter(e=>Ql(e[n])).length;case`count_unique`:{let e=new Set;for(let r of t){let t=r[n];Ql(t)||e.add($l(t))}return e.size}case`percent_filled`:return t.filter(e=>!Ql(e[n])).length/r*100;case`percent_empty`:return t.filter(e=>Ql(e[n])).length/r*100;default:return null}}let r=tu(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 iu=/^[A-Za-z]{3}$/;function au(e,t,n,r,i,a,o){if(t===null)return``;let s=Yl[e],c=s?n(s):e,l=e=>n(`grid.summary.pattern`,{label:c,value:e});if(Jl.has(e))return l(`${t.toLocaleString(a,{maximumFractionDigits:1})}%`);if(ql.has(e))return l(t.toLocaleString(a));let u=r?.type,d;if(u===`currency`){let e=Mr(r,i);d=e&&!iu.test(e)?t.toLocaleString(a):vt(t,e,a)}else if(u===`percent`){let e=h(r);d=xt(t,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 ou(e,t,n){let{currency:r}=jr(),i=Fr(),{t:a}=Xl();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=eu(s.summary);if(e.type===`none`||!Zl.has(e.type))continue;let c=e.field||s.field,l=ru(e.type,t,c),u=n?.[c],d={type:s.type??u?.type,currency:s.currency??u?.currency,defaultCurrency:s.defaultCurrency??u?.defaultCurrency,currencyConfig:u?.currencyConfig,precision:s.precision??u?.precision,scale:s.scale??u?.scale},f=ql.has(e.type)?0:nu(tu(t,c));o.set(s.field,{field:s.field,value:l,label:au(e.type,l,a,d,r,i,f)})}return{summaries:o,hasSummary:o.size>0}},[e,t,n,r,i,a])}function su(e){let t=Yt({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 cu(e,t){return!!e&&t!==!1}var lu=new Map,uu=(e,t,n,r)=>JSON.stringify([e,t,n,r]),du;function fu(e){du!==void 0&&du!==e&&lu.clear(),du=e}var pu=new Set;function mu(e){for(let t of Array.from(lu.keys())){let[,n,r]=JSON.parse(t);nr(e,n,r)&&lu.delete(t)}for(let t of pu)for(let n of t.recordIds)nr(e,t.object,n)&&t.staled.add(n)}Gn(mu);var hu=()=>void 0;function gu(e){let{objectName:t,recordIds:n,update:r,delete:i}=e,a=Q.useContext(pn)?.apiFetch,o=x().userId,s=Nn(t),c=JSON.stringify(n),l=Q.useMemo(()=>JSON.parse(c),[c]),[u,d]=Q.useState(()=>new Map);return Q.useEffect(()=>{fu(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=lu.get(uu(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=>!lu.has(uu(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};pu.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)||lu.set(uu(o,t,n,e),a.visible))})}catch{}finally{pu.delete(c)}}})),n||c()})(),c(),()=>{n=!0}},[t,l,r,i,a,o,s]),Q.useMemo(()=>u.size===0?hu:(e,t)=>e==null?void 0:u.get(`${t}:${String(e)}`),[u])}function _u(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 vu=Object.freeze([`cell`]),yu=Object.freeze([`cell`,`lookup-editor`,`user-editor`]),bu=Object.freeze([`cell`,`lookup-editor`]),xu=Object.freeze([`lookup-editor`,`user-editor`]),Su=Object.freeze([`lookup-editor`]),Cu=new Set([`spec`,`widget-contract`]),wu={reference:{verdict:`spec`,readers:yu,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:yu,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:yu,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:Su,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:Su,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:Su,note:"Runtime twin of `lookupColumns`, read but never producible. Not on FieldSchema. objectui#6875."},lookupFilters:{verdict:`spec`,readers:xu,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:Su,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:Su,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:Su,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:Su,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:Su,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:Su,note:"Runtime twin of `allowCreate`. Not on FieldSchema."},lookup_page_size:{verdict:`no-producer`,readers:Su,note:"Runtime twin of `lookupPageSize`. Not on FieldSchema."},picker:{verdict:`no-producer`,readers:xu,note:`PeoplePicker variant opt-in. Not on FieldSchema.`},subtitle:{verdict:`no-producer`,readers:xu,note:`PeoplePicker subtitle fields. Not on FieldSchema.`},avatarField:{verdict:`no-producer`,readers:xu,note:`PeoplePicker avatar field. Not on FieldSchema.`},avatar_field:{verdict:`no-producer`,readers:xu,note:"Runtime twin of `avatarField`. Not on FieldSchema."},options:{verdict:`handled-elsewhere`,readers:bu,note:"Written by generateColumns as `translateOptions(...)`, which localises the labels; a raw copy would undo that."},dataSource:{verdict:`handled-elsewhere`,readers:Su,note:"Not a schema key — LookupField reads its own `props.dataSource` fallback off the meta bag."}};function Tu(e){return e.readers.some(e=>vu.includes(e))}var Eu=Object.freeze(Object.entries(wu).filter(([,e])=>Cu.has(e.verdict)&&(Tu(e)||e.copiedWithoutCellReader!==void 0)).map(([e])=>e));function Du(e,t){if(t)for(let n of Eu)t[n]!==void 0&&(e[n]=t[n])}var Ou=new Set([`primary`,`secondary`,`danger`,`ghost`]);function ku(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 Au(e,t){let n=String(e.name),r=(Array.isArray(e.params)?e.params:[]).map(e=>e&&typeof e==`object`?ku(e):null).filter(e=>e!==null),i=typeof e.variant==`string`&&Ou.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 ju(e){if(!e||typeof e!=`object`)return!1;let t=e.name;return typeof t==`string`&&t.length>0}function Mu(e){return typeof e==`string`?`'${e}'`:String(e)}function Nu({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 Pu(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} (${Mu(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} (${Mu(i)}), and only a non-empty string names an action.`}function Fu(e,t){if(!Array.isArray(e)||e.length===0)return null;let n=e.map((e,t)=>({index:t,member:e})).filter(({member:e})=>!ju(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}]: ${Pu(t)}`);return`[ObjectUI] ObjectGrid bulkActionDefs: ${Nu(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 Iu(e){let t=Array.isArray(e.bulkActionDefs)?e.bulkActionDefs:[],n=t.every(ju)?t:t.filter(ju),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}=Au(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(Au(n,e.localizeLabel)):l.push(t)}return{defs:c.length>0?[...o,...c]:o,unresolved:l}}function Lu(e){let t=e?.visible;return t!=null&&t!==``}function Ru(e,t,n={}){return Fn(e?.visible,t,{scope:n.scope,fields:n.fields,warnOnError:!0,label:e?.name})}var zu=`field`,Bu=`label`,Vu=[`accessorKey`,`header`];function Hu(e){if(!e||typeof e!=`object`)return!1;let t=e;return!t.hidden&&typeof t.field==`string`&&t.field.length>0}function Uu(e){return!!e&&typeof e==`object`&&!!e.hidden}function Wu(e){return typeof e==`string`?`'${e}'`:String(e)}function Gu(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} (${Wu(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=Vu.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 \`{ ${zu}: '${e}'${typeof n==`string`&&n.length>0?`, ${Bu}: '${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 \`${zu}\` key, so the column names no field.`;let a=t[zu];return typeof a==`string`?a.length===0?`${i} — \`${zu}\` is an empty string, so the column names no field.`:`${i} — \`${zu}\` is '${a}', and the column still did not resolve.`:`${i} — \`${zu}\` is a ${a===null?`null`:typeof a} (${Wu(a)}), and only a non-empty string names a field.`}function Ku(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)=>{Hu(e)?t.resolved+=1:Uu(e)?t.hidden+=1:t.unresolved.push({index:n,detail:Gu(e)})}),t}function qu({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 Ju(e,t){let n=Ku(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: ${qu(t)} — ${a}.\n${o.join(`
|
|
4
|
+
`)}\n \`ListColumnSchema\` (@objectstack/spec/ui) declares ONE column spelling: \`${zu}\` (required — the field name) and \`${Bu}\` (the header). A plain \`string[]\` of field names works too. (objectui#5349)`}var Yu={"grid.openMenu":`Open menu`,"grid.edit":`Edit`,"grid.delete":`Delete`};function Xu(){let{t:e}=Ir();return t=>{let n=e(t);return n===t?Yu[t]??t:n}}function Zu(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Qu(e,t,n,r,i){return typeof e==`boolean`?e:e==null||e===``?!1:Kn(e,t??{},{fallback:!1,scope:n,warnOnError:!0,label:r,fields:i})}function $u(e,t,n,r,i){let a=e?.visibleWhen;return a==null||Qu(a,n,r,`builtin:${t}:visibleWhen`,i)}function ed(e){let{row:t,scope:n,objectFields:r}=e,i=!!(e.canEdit&&e.onEdit)&&$u(e.editPredicates,`edit`,t,n,r),a=!!(e.canDelete&&e.onDelete)&&$u(e.deletePredicates,`delete`,t,n,r),o=(e.actionDefs??[]).filter(e=>ze(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 td=({def:e,row:t,objectFields:n,onActionDef:r})=>{let i=Zt(),a=Q.useMemo(()=>ze(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=Rt(o)&&s;return a?(0,$.jsx)(st,{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??Zu(e.name)}):null},nd=({name:e,predicates:t,row:n,icon:r,label:i,className:a,objectFields:o,onSelect:s})=>{let c=Zt(),l=Q.useMemo(()=>$u(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)(st,{disabled:d,onClick:()=>{d||s(n)},"data-testid":`row-action-builtin-${e}`,className:a,children:[r,i]})};function rd(e){switch(e){case`danger`:return`destructive`;case`secondary`:return`secondary`;case`ghost`:return`ghost`;case`link`:return`link`;default:return`default`}}var id=({def:e,row:t,objectFields:n,onActionDef:r})=>{let i=Zt();return Q.useMemo(()=>ze(e,t,i,n),[e,t,i,n])?(0,$.jsx)(X,{variant:rd(e.variant),size:`sm`,className:`h-8`,"data-testid":`row-action-inline-${e.name}`,onClick:n=>{n.stopPropagation(),r?.(e,t)},children:e.label??Zu(e.name)}):null},ad=({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=Xu(),m=xn(),h=Q.useMemo(()=>(n??[]).filter(e=>m(e?.requiredPermissions)),[n,m]),g=Zt(),_=Q.useMemo(()=>ed({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)(id,{def:t,row:e,objectFields:f,onActionDef:u},t.name)),v&&(0,$.jsxs)(S,{children:[(0,$.jsx)(Re,{asChild:!0,children:(0,$.jsxs)(X,{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)(ui,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:p(`grid.openMenu`)})]})}),(0,$.jsxs)(We,{align:`end`,onClick:e=>e.stopPropagation(),children:[_.edit&&(0,$.jsx)(nd,{name:`edit`,predicates:a,row:e,icon:(0,$.jsx)(Ui,{className:`mr-2 h-4 w-4`}),label:p(`grid.edit`),objectFields:f,onSelect:e=>s?.(e)}),_.remove&&(0,$.jsx)(nd,{name:`delete`,predicates:o,row:e,icon:(0,$.jsx)(Ji,{className:`mr-2 h-4 w-4`}),label:p(`grid.delete`),objectFields:f,onSelect:e=>c?.(e)}),_.custom.map(t=>(0,$.jsx)(td,{def:t,row:e,objectFields:f,onActionDef:u},t.name)),_.legacy.map(t=>(0,$.jsx)(st,{onClick:()=>l?.(t,e),"data-testid":`row-action-${t}`,children:Zu(t)},t))]})]})]})},od=({def:e,selectedRows:t,objectFields:n,onActionDef:r})=>{let i=Zt(),{eligible:a}=Q.useMemo(()=>Ru(e,t,{scope:i,fields:n}),[e,t,i,n]);if(Lu(e)&&a.length===0)return null;let o=e.variant===`danger`||e.operation===`delete`,s=e.icon?oe(e.icon):null;return(0,$.jsxs)(X,{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)(we,{name:s,className:`h-3 w-3`}):o?(0,$.jsx)(Ji,{className:`h-3 w-3`}):null,e.label??Zu(e.name)]})},sd=({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}=Ir(),f=xn(),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)(Hi,{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)(Hi,{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)(od,{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?Ji:null;return(0,$.jsxs)(X,{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`}),Zu(t)]},t)})]}),(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:o,children:[(0,$.jsx)(ea,{className:`h-3 w-3`}),d(`grid.bulkClear`,{defaultValue:`Clear`})]})]})]})};b();function cd(e){return typeof e?.type==`string`&&f(e)}function ld(e,t){if(!t)return e;let n=null;for(let[r,i]of Object.entries(e)){if(i==null||Array.isArray(i)||!cd(t[r]))continue;let a=typeof i;(a===`string`||a===`number`||a===`boolean`)&&(n||={...e},n[r]=[i])}return n??e}function ud({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=()=>ld({...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 hr({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&&He.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=ld({...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 dd={checkbox:`boolean`,reference:`lookup`,"datetime-local":`datetime`},fd=new Set([`lookup`,`master_detail`]),pd=new Set([`user`]);function md(e){return Sn.has(e)}function hd(e){return Ot(dd[e]??e)}function gd(e){return md(hd(e.type))}function _d(e){let t=hd(e.type);return e.object?e.object:pd.has(t)?`sys_user`:void 0}function vd(e,t){let n=hd(e.type);fd.has(n)&&!e.object&&(n=`text`),fd.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 md(n)&&(h.reference=d,typeof f==`string`&&(h.displayField=f)),h}function yd(e){return md(e.type)}var bd=({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}=Ir(),f=e?.params??[],p=(0,Q.useCallback)(t=>typeof t.multiple==`boolean`?t.multiple:e?.operation===`update`&&cd(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:E,reset:D}=ud({resource:n,dataSource:r,objectFields:s,runAction:c,runAggregate:l}),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),ee=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(!i)return;let e=()=>{ee.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&&(D(),v(m),b({}),N(null),j(!1),k(null),g(f.length===0?`confirm`:`params`))},[i,e?.name,m,f.length,D]),(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=_d(e);if(!gd(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 ne=(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,_]),P=(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&&gd(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]),F=e?.maxRecords??1/0,re=t.length>F,I=t.length===0,L=(0,Q.useCallback)(async()=>{e&&(g(`running`),await x(e,t,_),g(`result`))},[e,t,_,x]),R=(0,Q.useCallback)(()=>{if(!E?.errors?.length)return;let t=[`record_id,error_message`,...E.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)},[E,e?.name]),ie=!!e&&e.operation===`update`&&!!E&&E.succeeded>0&&M===null,z=(0,Q.useCallback)(async()=>{j(!0);try{await S()&&N(Date.now())}finally{j(!1)}},[S]),ae=(0,Q.useCallback)(async e=>{k(e);try{await C(e)}finally{k(null)}},[C]);if(!e)return null;let oe=e.label??e.name,B=t.slice(0,5),V=Math.max(0,t.length-B.length);return(0,$.jsx)(T,{open:i,onOpenChange:e=>{e||a(E)},children:(0,$.jsxs)(Qe,{className:`max-w-md`,onPointerDownOutside:e=>{ee.current&&e.preventDefault()},onInteractOutside:e=>{ee.current&&e.preventDefault()},children:[(0,$.jsxs)(me,{children:[(0,$.jsxs)(te,{className:`flex items-center gap-2`,children:[h===`running`&&(0,$.jsx)(wi,{className:`h-4 w-4 animate-spin`}),oe]}),h===`confirm`&&(0,$.jsx)(le,{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)(Sd,{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:[re&&(0,$.jsxs)(`div`,{className:`rounded-md bg-destructive/10 text-destructive px-3 py-2 flex items-start gap-2`,children:[(0,$.jsx)(Yi,{className:`h-4 w-4 mt-0.5 shrink-0`}),(0,$.jsx)(`div`,{children:d(`grid.bulk.overLimit`,{count:t.length,limit:F,defaultValue:`Selection (${t.length}) exceeds the action limit (${F}). 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)(W,{className:`max-h-32 rounded border bg-muted/30 p-2`,children:(0,$.jsxs)(`ul`,{className:`text-xs space-y-1`,children:[B.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))),V>0&&(0,$.jsx)(`li`,{className:`text-muted-foreground`,children:d(`grid.bulk.andMore`,{count:V,defaultValue:`… and ${V} 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,`:`]}),` `,P(n,t)]},e)})})]}),h===`running`&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Oe,{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`&&E&&(0,$.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E.failed===0?(0,$.jsx)(ti,{className:`h-5 w-5 text-emerald-500`}):(0,$.jsx)(Yi,{className:`h-5 w-5 text-amber-500`}),(0,$.jsxs)(`span`,{children:[M===null?``:d(`grid.bulk.undonePrefix`,{defaultValue:`Undone — `}),d(`grid.bulk.succeeded`,{count:E.succeeded,total:E.total,defaultValue:`Succeeded ${E.succeeded} / ${E.total}`}),E.failed>0&&d(`grid.bulk.resultFailed`,{count:E.failed,defaultValue:` · Failed ${E.failed}`})]})]}),E.errors.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(W,{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:E.errors.map(t=>(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,"data-testid":`bulk-error-row-${t.id}`,children:[(0,$.jsx)(ri,{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)(X,{variant:`ghost`,size:`sm`,className:`h-5 px-1.5 text-[10px] shrink-0`,onClick:()=>ae(t.id),disabled:O===t.id,"data-testid":`bulk-error-retry-${t.id}`,children:O===t.id?`…`:d(`grid.bulk.retry`,{defaultValue:`Retry`})})]},t.id))})}),(0,$.jsx)(X,{variant:`outline`,size:`sm`,onClick:R,children:d(`grid.bulk.downloadErrorCsv`,{defaultValue:`Download error CSV`})})]})]}),(0,$.jsxs)(de,{children:[h===`params`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{variant:`ghost`,onClick:()=>a(),children:d(`grid.bulk.cancel`,{defaultValue:`Cancel`})}),(0,$.jsx)(X,{onClick:()=>g(`confirm`),disabled:!ne,children:d(`grid.bulk.next`,{defaultValue:`Next`})})]}),h===`confirm`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{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)(X,{variant:e.variant===`danger`?`destructive`:`default`,onClick:L,disabled:re||I,children:e.confirmLabel??d(`grid.bulk.run`,{defaultValue:`Run`})})]}),h===`running`&&(0,$.jsx)(X,{variant:`ghost`,disabled:!0,children:d(`grid.bulk.running`,{defaultValue:`Running…`})}),h===`result`&&(0,$.jsxs)($.Fragment,{children:[ie&&(0,$.jsx)(X,{variant:`outline`,onClick:z,disabled:A,"data-testid":`bulk-undo-button`,children:A?d(`grid.bulk.undoing`,{defaultValue:`Undoing…`}):d(`grid.bulk.undo`,{defaultValue:`Undo`})}),(0,$.jsx)(X,{onClick:()=>a(E),children:d(`grid.bulk.done`,{defaultValue:`Done`})})]})]})]})})};function xd(e){return Wn.has(e)||Sn.has(e)}var Sd=({param:e,multiple:t,value:n,onChange:r,dataSource:i,values:a})=>{let o=`bulk-param-${e.name}`,s=(0,Q.useMemo)(()=>vd(e,t),[e,t]),c=(0,Q.useMemo)(()=>nt(s.type),[s.type]),l=yd(s)?{dataSource:i}:{},u=xd(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)(ge,{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 Cd(e,t){return{authored:e,currentUserId:t.currentUserId,currentOrgId:t.currentOrgId,recordId:t.recordId,onUnresolved:t.onUnresolved,resolved:Tn(e,t)}}var wd=12;function Td(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ed(e,t,n=0){if(Object.is(e,t))return!0;if(n>=wd)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)=>Ed(e,t[r],n+1));if(Td(e)&&Td(t)){let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&Ed(e[r],t[r],n+1))}return!1}function Dd(e,t){let[n,r]=(0,Q.useState)(()=>Cd(e,t));if(n.currentUserId!==t.currentUserId||n.currentOrgId!==t.currentOrgId||n.recordId!==t.recordId||n.onUnresolved!==t.onUnresolved||!Ed(n.authored,e)){let n=Cd(e,t);return r(n),n.resolved}return n.resolved}function Od(e){let t=It(e);if(t)return t.map(e=>`${e.field} ${e.order}`).join(`, `)}function kd(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 Ad=`text-primary font-medium underline-offset-4 hover:underline cursor-pointer truncate block max-w-full`,jd=Ad.replace(`truncate`,`whitespace-normal break-words`);function Md(e){let t=e,n=t?.id??t?._id;return typeof n==`string`||typeof n==`number`?n:void 0}var Nd=({testId:e,onActivate:t,objectName:n,recordId:r,wrap:i,children:a})=>{let o=Jt(),s=i?jd:Ad,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})},Pd=Ar({"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 Fd(e){if(e!=null)return typeof e==`string`?e:void 0}function Id(e){return Or(e,`view-data`)}function Ld(e){return e?JSON.stringify(Object.keys(e).sort().map(t=>[t,e[t]??null])):null}function Rd(e){if(e&&e.length!==0)return typeof e[0]==`object`&&e[0],e}function zd(e){return typeof e!=`string`||!Object.prototype.hasOwnProperty.call(en,e)?`compact`:e}function Bd(){let e=y.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 Vd=Bd(),Hd=50,Ud=`multiple`;function Wd(e){return e.pagination?.pageSize??e.pageSize}function Gd(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function Kd(e,t){let n=Wd(e);return Gd(n)?n:t}function qd(e,t){let n=Wd(e);return n==null||Gd(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 Jd=JSON.stringify({refused:[],warned:[]}),Yd=({schema:e,dataSource:t,onEdit:n,onDelete:r,rowOperations:i,onBulkDelete:a,onRowSelect:o,onRowClick:s,onNavigate:c,onCellChange:u,onRowSave:d,onBatchSave:f,onAddRecord:m,data:h,manualPagination:g,rowCount:_,page:v,pageSize:y,onPageChange:b,onPageSizeChange:S,sort:C,onSortChange:T,search:D,onSearchChange:O,findParams:k,onColumnStateChange:A,objectFields:j})=>{let[M,N]=(0,Q.useState)([]),[ee,te]=(0,Q.useState)(!0),[ne,F]=(0,Q.useState)(null),{currency:re}=jr(),I=Fr(),{t:L}=Pd(),{fieldLabel:ie,translateOptions:z,actionLabel:oe}=Pr(),[B,V]=(0,Q.useState)(null),[se,ce]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)(0),[de,fe]=(0,Q.useState)(!1),[H,pe]=(0,Q.useState)(!1),[me,he]=(0,Q.useState)(null),[ge,_e]=(0,Q.useState)(zd(e.rowHeight)),[ve,ye]=(0,Q.useState)([]),[be,Se]=(0,Q.useState)(!1),[Ce,U]=(0,Q.useState)(0),[we,Te]=(0,Q.useState)(void 0),[W,Ee]=(0,Q.useState)(null),[De,Oe]=(0,Q.useState)([]),[ke,Ae]=(0,Q.useState)(0),je=Q.useRef(null),[G,Me]=(0,Q.useState)(1),[Ne,K]=(0,Q.useState)(Kd(e,Vd));Q.useEffect(()=>{if(!e.rowHeight)return;let t=zd(e.rowHeight);t!==ge&&_e(t)},[e.rowHeight]);let Pe=Q.useMemo(()=>e.id?`grid-columns-${e.objectName}-${e.id}`:`grid-columns-${e.objectName}`,[e.objectName,e.id]),[Fe,Le]=(0,Q.useState)(()=>{let t=e.columnState;if(t&&typeof t==`object`)return t;try{let e=localStorage.getItem(Pe);return e?JSON.parse(e):{}}catch{return{}}}),Re=Q.useMemo(()=>JSON.stringify(e.columnState??null),[e.columnState]);Q.useEffect(()=>{let t=e.columnState;t&&typeof t==`object`&&Le(t)},[Re]);let ze=(0,Q.useCallback)(e=>{Le(e);try{localStorage.setItem(Pe,JSON.stringify(e))}catch(e){console.warn(`Failed to persist column state:`,e)}if(typeof A==`function`)try{A(e)}catch(e){console.warn(`onColumnStateChange threw:`,e)}},[Pe,A]),{ref:Ve,isRefreshing:He,pullDistance:Ue}=ha({onRefresh:(0,Q.useCallback)(async()=>{ue(e=>e+1)},[]),enabled:!!t&&!!e.objectName});(0,Q.useEffect)(()=>{let e=()=>ce(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let We=Lt(e.bind),Ke=Id(e),Je=Q.useMemo(()=>h&&Array.isArray(h)?{provider:`value`,items:h}:We&&Array.isArray(We)?{provider:`value`,items:We}:Ke,[JSON.stringify(Ke),We,h]),Ye=Je?.provider===`value`,Xe=g===!0&&typeof _==`number`&&typeof b==`function`,q=zt(e,Je)??e.objectName,J=B?.fields??j??void 0,Qe=!!q&&typeof t?.getObjectSchema==`function`&&!J,et=x(),{getObjectApiOperations:tt}=et,nt=q?tt(q):void 0,rt=q?et.can(q,`update`):void 0,at=q?et.can(q,`delete`):void 0,ot=q?et.can(q,`create`):void 0,st=mn(B,nt)&&(!q||et.can(q,`update`)),lt=(e.editable??!1)&&st,ut=(`operations`in e?e.operations:void 0)??{update:!!n,delete:!!r},dt=Array.isArray(e.rowActions),ft=Array.isArray(e.rowActions)?e.rowActions:[],_t=Array.isArray(e.rowActionDefs)?e.rowActionDefs:[],yt=ft.includes(`edit`),bt=ft.includes(`delete`),{defs:St,unresolved:Ct}=_u({rowActions:ft.filter(e=>e!==`edit`&&e!==`delete`),rowActionDefs:_t,objectActions:B?.actions}),{canEdit:wt,canDelete:Tt,objectCanDelete:Et,editPredicates:Y,deletePredicates:Ot,objectDeletePredicates:At}=su({operationsUpdate:ut?.update,operationsDelete:ut?.delete,wantEditAction:yt,wantDeleteAction:bt,rowActionsDeclared:dt,hasOnEdit:!!n,hasOnDelete:!!r,managedBy:B?.managedBy,userActions:B?.userActions,effectiveApiOperations:nt,permissionUpdate:rt,permissionDelete:at}),jt=gu({objectName:q,recordIds:(0,Q.useMemo)(()=>Array.from(new Set(M.map(Md).filter(e=>e!=null).map(e=>String(e)))),[M]),update:wt,delete:Tt}),Mt=e.fields,Pt=e.columns,Ft=(0,Q.useMemo)(()=>JSON.stringify(sn(e.grouping)),[e.grouping]),It=e.conditionalFormatting,Rt=e.rowActionDefs,Bt=e.bulkActionDefs,Vt=(0,Q.useMemo)(()=>JSON.stringify(on(On({conditionalFormatting:It,rowActionDefs:Rt,bulkActionDefs:Bt}))),[It,Rt,Bt]),Ut=lr(),Wt=Dd({filter:e.filter,defaultFilters:e.defaultFilters},Ut),Kt=Wt.filter,qt=Wt.defaultFilters,Jt=(0,Q.useMemo)(()=>Yn(Kt),[Kt]),Yt=Jt.ok?void 0:Jt.refusal,Xt=Jt.ok?Jt.node:void 0,Qt=e.sort,$t=e.pagination,en=e.pageSize,[tn,nn]=(0,Q.useState)(1),[rn,an]=(0,Q.useState)(Kd(e,Vd)),[ln,un]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{un(null)},[JSON.stringify(e.sort??null)]);let[dn,fn]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{fn(``)},[q]);let pn=Xe||D!==void 0,hn=pn?D??``:dn,gn=hn.trim()&&e.searchableFields&&e.searchableFields.length>0?JSON.stringify(e.searchableFields):``;(0,Q.useEffect)(()=>{Ye&&Je?.provider===`value`&&(N(e=>{let t=Je.items;return JSON.stringify(e)===JSON.stringify(t)?e:t}),te(!1))},[Ye,Je]),(0,Q.useEffect)(()=>{if(!Ye||!q||!t)return;let e=!1;return(async()=>{try{if(typeof t.getObjectSchema!=`function`)return;let n=await t.getObjectSchema(q);e||V(n)}catch(e){console.warn(`[ObjectGrid] Failed to fetch objectSchema for inline data (objectName: ${q}):`,e)}})(),()=>{e=!0}},[Ye,q,t]);let _n=e.grouping?.fields,vn=Q.useMemo(()=>{let t=Rd(e.columns)??[],n=e=>t.find(t=>typeof t==`object`&&!!t&&t.field===e)?.type,r=Pl(_n).map(e=>e.field).filter(e=>aa(n(e),J?.[e]?.type,Qe));return JSON.stringify({refused:r,warned:r.filter(e=>aa(n(e),J?.[e]?.type,!1))})},[_n,e.columns,J,Qe]),bn=Q.useMemo(()=>{let{refused:e}=JSON.parse(vn);return Pl(_n).filter(t=>!e.includes(t.field))},[_n,vn]),xn=vn===Jd;(0,Q.useEffect)(()=>{let{warned:t}=JSON.parse(vn);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.`)},[vn,e.objectName]);let Sn=Q.useMemo(()=>JSON.parse(vn).warned,[vn]),Cn=e=>!et?.isLoaded||!q||et.checkField(q,e,`read`),Z=!Ye&&!!q&&typeof t?.queryGroupHeaders==`function`&&Pl(_n).some(e=>!Sn.includes(e.field)&&Cn(e.field)),wn=!Ye&&!!q&&!!t&&typeof t.queryGroupHeaders!=`function`&&Pl(_n).some(e=>!Sn.includes(e.field)),Tn=Ye?Je?.items:void 0,En=Xe&&Array.isArray(Tn)&&_>Tn.length&&Pl(_n).some(e=>!Sn.includes(e.field)),Dn=!Z&&!wn&&Pl(_n).some(e=>!Sn.includes(e.field))?Kd(e,Hd):rn,[kn,jn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Z||jn(null)},[Z]);let Mn=Nn(Ye?void 0:q);(0,Q.useEffect)(()=>{if(Ye||Yt)return;let n=!1;return(async()=>{te(!0),F(null);try{let r=null,i=Rd(Pt)||Mt;if(q&&t){if(typeof t.getObjectSchema==`function`){let e=await t.getObjectSchema(q);if(n)return;r=e}else r={name:q,fields:{}}}else if(i&&q)r={name:q,fields:{}};else if(q)throw Error(`DataSource required`);else throw Error(`Object name required for data fetching`);if(n||V(r),wn)return;if(t&&q){let i=sn(e.grouping),a={$select:(()=>{let t=e=>e.map(e=>Qn(e)).includes(`id`)?e:[`id`,...e],n=e=>{if(!et?.isLoaded||!q)return!0;let t=Qn(e);return!t||!Object.prototype.hasOwnProperty.call(r?.fields??{},t)||et.checkField(q,t,`read`)},a=r?.fields,o=a?on(On({conditionalFormatting:e.conditionalFormatting,rowActionDefs:e.rowActionDefs,bulkActionDefs:e.bulkActionDefs,objectActions:r?.actions,userActions:r?.userActions})).filter(e=>An(e,a)).filter(e=>n(e)):[],s=a?i.filter(e=>An(e,a)).filter(e=>n(e)):[],c=[...o,...s],l=e=>{if(c.length===0)return e;let t=new Set(e.map(e=>Qn(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=>Qn(e)).filter(e=>!!e);if(Mt)return l(t(u(Mt)));if(Pt&&Array.isArray(Pt))return l(t(u(Pt)))})(),$top:Dn,$skip:(tn-1)*Dn};if(Xt!==void 0)a.$filter=Xt;else{let e=fr(qt);e!==void 0&&(a.$filter=e)}if(ln&&ln.length>0)a.$orderby=ln.map(e=>({field:e.field,order:e.order}));else if(Qt){if(typeof Qt==`string`)$n(Qt);else if(Array.isArray(Qt)){let e=Od(Qt);e!==void 0&&(a.$orderby=e)}}let o=hn.trim();o&&(a.$search=o,e.searchableFields&&e.searchableFields.length>0&&(a.$searchFields=e.searchableFields));let s=e=>!et?.isLoaded||!q||et.checkField(q,e,`read`),c=Pt??Mt,l=Gt(r?.fields,c?[...c,...i]:void 0).filter(s);if(l.length>0&&(a.$expand=l),Z){let{$top:e,$skip:t,...n}=a;jn(n),je.current={...n},Se(!1);return}let u=await t.find(q,a);if(n)return;N(u.data||[]);let d=u.total;Te(typeof d==`number`?d:void 0),je.current={...a},Se(!1)}}catch(e){n||F(e)}finally{n||te(!1)}})(),()=>{n=!0}},[q,Mt,Pt,Xt,Yt,qt,Qt,ln,hn,$t,en,tn,Dn,t,Ye,Je,le,et.isLoaded,Ft,Vt,gn,Mn,Z,wn]);let Fn=Q.useMemo(()=>Ld(k),[k]);Q.useEffect(()=>{Se(!1)},[Fn]),Q.useEffect(()=>{nn(1)},[q,Xt,Qt,ln,hn]);let In=tr({navigation:e.navigation,objectName:e.objectName,onNavigate:c??e.onNavigate,onRowClick:s}),{anchorRef:Ln,anchorCaptureProps:zn}=xe(),{execute:Bn,updateContext:Vn}=Rn();Q.useEffect(()=>(Vn({selectedRecords:ve}),()=>{Vn({selectedRecords:[]})}),[ve,Vn]);let Hn=Ol(e.rowColor),Un=Zt(),Wn=(0,Q.useCallback)(t=>{let n=e.conditionalFormatting;if(!n||n.length===0)return;let r=br(t,n,Un,B?.fields);return Object.keys(r).length>0?r:void 0},[e.conditionalFormatting,Un,B]),Gn=Q.useMemo(()=>{let t=Pl(e.grouping?.fields);if(!t.length)return;let n=new Map;for(let r of t){let t=r.field,i=J?.[t],a=Rd(e.columns)?.find?.(e=>typeof e==`object`&&e?.field===t),o=a?.type||i?.type,s=a?.options||i?.options,c=new Map;if(Array.isArray(s)&&s.length>0){let n=e.objectName?z(e.objectName,t,s):s;for(let e of n)if(e&&e.value!==void 0&&e.value!==null){let t=e.label;c.set(String(e.value),String(t??e.value))}}n.set(t,{type:o||void 0,options:c.size>0?c: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 L(`grid.yes`,{defaultValue:`Yes`});if(t===!1||t===`false`)return L(`grid.no`,{defaultValue:`No`})}}}},[e.grouping,e.columns,e.objectName,J,z,L]),Kn=xn||!e.grouping?e.grouping:{...e.grouping,fields:bn},Jn=Z?JSON.stringify(Pl(Kn?.fields).filter(e=>Cn(e.field)).map(e=>[e.field,e.order??null,e.collapsed??null])):`[]`,Xn=Q.useMemo(()=>JSON.parse(Jn).map(([e,t,n])=>({field:e,...t?{order:t}:{},...n===null?{}:{collapsed:n}})),[Jn]),Zn=JSON.stringify(kn),er=Q.useMemo(()=>{let e=JSON.parse(Zn)?.$filter;if(e==null)return{};try{let t=l(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))}}},[Zn]),nr=`${le}:${Mn}`,rr=Wl({enabled:Z&&!Qe&&kn!==null&&!er.error,dataSource:t,objectName:q,fields:Xn,where:er.where,...Ul(kn),aggregations:e.aggregations,objectFields:J,reloadKey:nr}),ir=rr.headers,or=rr.keyLabels,cr=Q.useMemo(()=>Z?{headers:ir??[],keyLabels:or}:void 0,[Z,ir,or]),{groups:ur,isGrouped:dr,toggleGroup:pr}=zl(Z?e.grouping?{...e.grouping,fields:Xn}:void 0:Kn,M,e.aggregations,Gn,cr),mr=Q.useMemo(()=>JSON.stringify(e.grouping??null),[e.grouping]);Q.useEffect(()=>{Me(1)},[mr,Ne,le]);let hr=[];if(Z){let e=Math.max(1,Math.ceil(ur.length/Ne)),t=Math.min(G,e),n=e=>{e.collapsed||(e.subgroups.length===0?hr.push({key:e.key,keyValues:e.keyValues}):e.subgroups.forEach(n))};ur.slice((t-1)*Ne,t*Ne).forEach(n)}let _r=Gl({enabled:Z&&!!rr.headers,dataSource:t,objectName:q,fields:Xn,where:er.where,baseParams:kn,pageSize:rn,leaves:hr,reloadKey:nr}),xr=JSON.stringify(hr.map(e=>e.key));(0,Q.useEffect)(()=>{if(!Z)return;let e=JSON.parse(xr);N(e.flatMap(e=>_r.pages[e]?.rows??[]))},[Z,xr,_r.pages]);let Sr=Z&&rr.headers?(rr.headers[0]??[]).reduce((e,t)=>e+(Number(t.count)||0),0):void 0;(0,Q.useEffect)(()=>{Sr!==void 0&&Te(Sr)},[Sr]);let{summaries:Tr,hasSummary:Dr}=ou(Q.useMemo(()=>{let t=Rd(e.columns);if(t&&t.length>0&&typeof t[0]==`object`)return t},[e.columns]),M,B?.fields),Or=e.type,kr=e.label??e.title;(0,Q.useEffect)(()=>{let t=Ju(e.columns,{blockType:Or,objectName:e.objectName,label:kr});t&&console.warn(t)},[e.columns,Or,e.objectName,kr]);let Ar=e.bulkActionDefs;(0,Q.useEffect)(()=>{let t=Fu(Ar,{blockType:Or,objectName:e.objectName,label:kr});t&&console.warn(t)},[Ar,Or,e.objectName,kr]);let Nr=e.pagination,Ir=e.pageSize;(0,Q.useEffect)(()=>{let t=qd({pagination:Nr,pageSize:Ir},{blockType:Or,objectName:e.objectName});t&&console.warn(t)},[Nr,Ir,Or,e.objectName]);let Lr=(0,Q.useCallback)(()=>{let t=e=>e&&{text:(0,$.jsx)(Xi,{className:`h-3.5 w-3.5`}),number:(0,$.jsx)(yi,{className:`h-3.5 w-3.5`}),currency:(0,$.jsx)(yi,{className:`h-3.5 w-3.5`}),percent:(0,$.jsx)(yi,{className:`h-3.5 w-3.5`}),date:(0,$.jsx)(qr,{className:`h-3.5 w-3.5`}),datetime:(0,$.jsx)(oi,{className:`h-3.5 w-3.5`}),boolean:(0,$.jsx)(Hi,{className:`h-3.5 w-3.5`}),user:(0,$.jsx)($i,{className:`h-3.5 w-3.5`}),select:(0,$.jsx)(Ki,{className:`h-3.5 w-3.5`})}[e]||(0,$.jsx)(Xi,{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=Rd(Pt);if(r){let i=t=>{if(!et?.isLoaded||!e.objectName)return!0;let n=Qn(t);return!n||!Object.prototype.hasOwnProperty.call(J??{},n)||et.checkField(e.objectName,n,`read`)};return r.length>0&&typeof r[0]==`object`&&r[0]!==null?r.filter(e=>Hu(e)).filter(e=>i(e)).map((r,i)=>{let a=Fd(r.label)||Fd(J?.[r.field]?.label)||r.field.charAt(0).toUpperCase()+r.field.slice(1).replace(/_/g,` `),o=e.objectName?ie(e.objectName,r.field,a):a,s,c=J?.[r.field],l=oa(r.type,Qe),u=l?null:r.type||c?.type||n({field:r.field})||null,d=c?.format,{rendererType:f,Renderer:p}=na({type:u,format:d}),m=l?ht: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.format&&(h.format=c.format),c.options&&(h.options=z(e.objectName,r.field,c.options))),Du(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:yn(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)(E,{});return(0,$.jsx)(Nd,{testId:_?`primary-field-link`:`link-cell`,onActivate:()=>In.handleClick(n),objectName:e.objectName,recordId:Md(n),wrap:r.wrap,children:i})}:r.action?(e,t)=>(0,$.jsx)(X,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,"data-testid":`action-cell`,onClick:n=>{n.stopPropagation(),Bn({type:r.action,params:{record:t,field:r.field,value:e}})},children:Zu(r.action)}):m?e=>(0,$.jsx)(m,{value:e,field:h}):e=>e!=null&&e!==``?(0,$.jsx)(`span`,{children:String(e)}):(0,$.jsx)(E,{});let y=r.prefix;if(y?.field){let e=s,t=y.type===`badge`?ra(ia):null;s=(n,r)=>{let i=r[y.field],a=i!=null&&i!==``?t?(0,$.jsx)(t,{value:i,field:{name:y.field,type:ia}}):(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=J?.[r],o=oa(void 0,Qe),s=a?.label||r.charAt(0).toUpperCase()+r.slice(1).replace(/_/g,` `),c=e.objectName?ie(e.objectName,r,s):s,{declaredType:l,rendererType:u,Renderer:d}=na({type:o?null:a?.type||n({field:r}),format:a?.format}),f=o?ht: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.format&&(p.format=a.format),a.options&&(p.options=z(e.objectName,r,a.options))),Du(p,a),u===`select`&&!p.options&&(p.options=Array.from(new Set(M.map(e=>e[r]).filter(Boolean))).map(e=>({value:e,label:yn(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)(Nd,{testId:`primary-field-link`,onActivate:()=>In.handleClick(n),objectName:e.objectName,recordId:Md(n),children:r})}:h?g=(t,n)=>(0,$.jsx)(Nd,{testId:`primary-field-link`,onActivate:()=>In.handleClick(n),objectName:e.objectName,recordId:Md(n),children:t!=null&&t!==``?String(t):(0,$.jsx)(E,{})}):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(Ye&&!(!Mt&&q&&B)){let r=Je?.provider===`value`?Je.items:[];if(r.length>0)return(Mt||Object.keys(r[0])).filter(t=>!et?.isLoaded||!e.objectName||!Object.prototype.hasOwnProperty.call(J??{},t)||et.checkField(e.objectName,t,`read`)).map(r=>{let i=J?.[r],a=oa(void 0,Qe),{declaredType:o,rendererType:s,Renderer:c}=na({type:a?null:i?.type||n({field:r}),format:i?.format}),l=a?ht: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.format&&(d.format=i.format),i.options&&(d.options=z(e.objectName,r,i.options))),Du(d,i),s===`select`&&!d.options&&(d.options=Array.from(new Set(M.map(e=>e[r]).filter(Boolean))).map(e=>({value:e,label:yn(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(Mt)s=Mt;else if(a?.length)s=cn(B,a.filter(e=>B.fields?.[e]));else{let e=o.filter(e=>{let t=B.fields?.[e];return!(!t||t.hidden||t.readonly&&sr(e,t))});s=[...e.filter(e=>!sr(e,B.fields?.[e])),...e.filter(e=>sr(e,B.fields?.[e]))]}return s.forEach(t=>{let n=B.fields?.[t];if(!n||et?.isLoaded&&e.objectName&&!et.checkField(e.objectName,t,`read`))return;let{declaredType:r,rendererType:a,Renderer:o}=na(n),s=[`number`,`currency`,`percent`],c=n.options?{...n,options:z(e.objectName,t,n.options)}:n;i.push({header:e.objectName?ie(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,J,Qe,Mt,Pt,Je,Ye,q,In.handleClick,Bn,M,ie,z,e.objectName,et]),Rr=(0,Q.useMemo)(()=>{let n=e.exportOptions?.formats||[`csv`,`json`],r=typeof t?.exportDownload==`function`&&q&&!Ye&&e.exportOptions?.streaming!==!1?[`csv`,`xlsx`,`json`]:[`csv`,`json`];return n.filter(e=>r.includes(e))},[e.exportOptions,t,q,Ye]);(0,Q.useEffect)(()=>{let t=e.exportOptions?.formats;if(!t)return;let n=t.filter(e=>!Rr.includes(e));n.length>0&&console.warn(`[ObjectUI] ObjectGrid export: unsupported format(s) hidden from the menu: ${n.join(`, `)}`)},[e.exportOptions,Rr]);let zr=(0,Q.useCallback)(n=>{if(e.operations?.export===!1||nt&&!nt.includes(`export`))return;let r=e.exportOptions,i=r?.maxRecords||0,a=r?.includeHeaders!==!1,o=t=>ar(t,{prefix:r?.fileNamePrefix,label:B?.label,objectName:q||e.objectName,viewLabel:p(e.label,I)||p(e.title,I)});if((n===`csv`||n===`xlsx`||n===`json`)&&typeof t?.exportDownload==`function`&&q&&!Ye&&r?.streaming!==!1){let e=Lr().filter(e=>e.accessorKey!==`_actions`).map(e=>e.accessorKey).filter(Boolean),r=Array.isArray(Xt)?Xt:void 0,s=Array.isArray(Qt)?Qt.filter(e=>e&&e.field).map(e=>({field:e.field,direction:e.order??`asc`})):void 0;he(null),pe(!0),(async()=>{try{let c=await t.exportDownload(q,{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),fe(!1)}catch(e){console.error(`ObjectGrid export failed:`,e),he(e instanceof Error?e.message:String(e))}finally{pe(!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(Lr().map(e=>[e.accessorKey,e.type])),d=e=>aa(u.get(e),J?.[e]?.type,Qe);if(n===`csv`){let e=Lr().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`))}fe(!1)},[M,e.exportOptions,e.operations?.export,nt,e.objectName,q,B,J,Qe,Lr,t,Ye,Xt,Qt]),Br=Yt??(ne instanceof Nt?ne:void 0);if(Br)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:L(`view.malformedFilter`,{subject:gr(Br)??``})}),(0,$.jsx)(`p`,{className:`text-amber-700 text-sm mt-1`,children:Br.message})]});if(En)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:L(`grid.errorLoading`)}),(0,$.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:L(`grid.grouping.needsWholeRows`)})]});let Vr=ne??(Z?er.error??rr.error??null:null);if(Vr)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:L(`grid.errorLoading`)}),(0,$.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:Vr.message})]});let Hr=Z&&!rr.headers;if(ee&&M.length===0||Hr)return se?(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:L(`grid.loading`)})]});if(wn)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:L(`grid.errorLoading`)}),(0,$.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:L(`grid.grouping.needsHeaderQuery`)})]});let Ur=[...Lr().map(e=>{if(!e||e.accessorKey===`_actions`)return e;let t=J?.[e.accessorKey];if(!t)return e;let n={...e};return n.type==null&&t.type&&(n.type=t.type),n.editable!==!1&&!ua(t)&&(n.editable=!1),n}).map(e=>{if(!e)return e;let{type:t,...n}=e,r=aa(t,J?.[e.accessorKey]?.type,Qe)?{...n,masked:!0}:n;if(t==null)return r;let i=vr(t);return i===void 0?r:{...r,type:i}})];if(Fe.widths&&(Ur=Ur.map(e=>{let t=Fe.widths?.[e.accessorKey];return t?{...e,width:t}:e})),Fe.order&&Fe.order.length>0){let e=new Map(Fe.order.map((e,t)=>[e,t]));Ur.sort((t,n)=>(e.get(t.accessorKey)??1/0)-(e.get(n.accessorKey)??1/0))}let Wr=!!(ut&&(ut.update||ut.delete)),Gr=Ct.length>0||St.length>0||yt||bt,Kr=Wr||Gr?[...Ur,{header:L(`grid.actions`),accessorKey:`_actions`,fitContent:!0,align:`right`,pinned:`right`,cell:(t,a)=>{let o=i?.(a);return(0,$.jsx)(ad,{row:a,rowActions:Ct,rowActionDefs:St,objectFields:B?.fields,maxInlineActions:e.maxInlineRowActions??1,canEdit:cu(wt&&o?.update!==!1,jt(Md(a),`update`)),canDelete:cu(Tt&&o?.delete!==!1,jt(Md(a),`delete`)),editPredicates:Y,deletePredicates:Ot,onEdit:n,onDelete:r,onAction:(e,t)=>{Bn({type:e,params:{record:t}}).then(e=>{e?.success&&ue(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},Bn(i).then(e=>{e?.success&&ue(e=>e+1)})}})},sortable:!1}]:Ur,Jr=Kr.filter(e=>e.pinned===`left`),Yr=Kr.filter(e=>e.pinned===`right`),ei=Kr.filter(e=>!e.pinned),ti=Jr.length>0||Yr.length>0,ni=`sticky right-0 z-10 bg-background border-l border-border`,ri=Jr.filter(e=>e.accessorKey!==`_actions`).length,ii=ri>0||Yr.some(e=>e.accessorKey!==`_actions`),ai=ge===`compact`?`px-3 py-1 h-9 text-[13px] leading-tight`:ge===`short`?`px-3 py-1 h-9 text-[13px] leading-normal`:ge===`tall`?`px-3 py-2.5 h-14 text-sm`:ge===`extra_tall`?`px-3 py-3.5 h-16 text-sm leading-relaxed`:`px-3 py-1.5 h-11 text-[13px] leading-normal`,si=e=>({...e,className:[`px-3`,e.className].filter(Boolean).join(` `),cellClassName:[ai,e.cellClassName].filter(Boolean).join(` `)}),ci=(!Ye&&(!dr||Z)||Xe)&&!dr,ui=ci||dr&&Z,di=ci,fi=Er(B),pi=e=>{if(!ui||e.sortable===!1)return e;let t=B?.fields?.[e.accessorKey];return Ht(t)?{...e,sortable:!1}:fi?yr(fi,e.accessorKey)?e:{...e,sortable:!1}:Cr(t)?{...e,sortable:!1}:e},mi=e=>pi(si(e)),hi=ti?[...Jr.map(mi),...ei.map(mi),...Yr.map(e=>({...mi(e),className:[`px-3`,e.className,ni].filter(Boolean).join(` `),cellClassName:[ai,e.cellClassName,ni].filter(Boolean).join(` `)}))]:Kr.map(mi),gi=ii?ri:e.frozenColumns??1,_i=e.batchActions??e.bulkActions,vi=Et?_i:_i?.filter(e=>String(e).toLowerCase()!==`delete`),{defs:bi,unresolved:xi}=Iu({bulkActions:(vi??[]).filter(e=>String(e).toLowerCase()!==`delete`),bulkActionDefs:Array.isArray(e.bulkActionDefs)?e.bulkActionDefs:[],objectActions:B?.actions,localizeLabel:(t,n)=>oe(e.objectName,t,n)}),Si=bi.filter(e=>Et||e?.operation!==`delete`),Ci=(vi??[]).filter(e=>String(e).toLowerCase()===`delete`),Ti=vi&&vi.length>0?[...xi,...Ci]:Tt&&a&&Si.length===0?[`delete`]:[],Ei=Ti.length>0||Si.length>0,Di=!1;if(e.selection!==void 0){let t=e.selection?.type;Di=t===`none`?!1:t??Ud}else e.selectable===void 0?Ei&&(Di=`multiple`):Di=e.selectable;let Oi=Di===`single`,ki=Ye?k??null:je.current??null,Ai=!Oi&&ki!==null,ji=async n=>{if(!be)return n;let r=e.objectName;if(!t||!r||!ki)return n;let i={...ki};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)},Mi=()=>{ye([]),Se(!1),U(e=>e+1)},Ni=()=>({name:`delete`,label:oe(e.objectName,`delete`,Zu(`delete`)),operation:`delete`,variant:`danger`}),Pi=(e,t)=>{(async()=>{let n=await ji(t);if(e===`delete`&&a){let{eligible:e,skipped:t}=Ru({name:`delete`,visible:At?.visibleWhen},n,{scope:Un,fields:B?.fields});if(t===0){a(e),Mi();return}Ee(Ni()),Oe(e),Ae(t);return}(await Bn({type:e,params:{records:n}}))?.success&&(Mi(),ue(e=>e+1))})()},Ri=(e,t)=>{(async()=>{let{eligible:n,skipped:r}=Ru(e,await ji(t),{scope:Un,fields:B?.fields});Ee(e),Oe(n),Ae(r)})()},zi=e=>{let{params:t,actionParams:n,confirmText:r,confirm:i,...a}=e;return a},Bi=async(e,t,n)=>{let r=e.actionDef;if(!r)return;let{resultDialog:i,...a}=zi(r),o=await Bn({...a,params:{...n,_rowRecord:t},toast:{showOnSuccess:!1,showOnError:!1}});if(!o?.success)throw Error(o?.error||`Action ${e.name} failed`)},Vi=async(e,t,n)=>{let r=e.actionDef;if(!r)return;let i=zi(r),a=t.map(e=>e.id==null?``:String(e.id)).filter(Boolean);Vn({selectedRecords:t});let o=await Bn({...i,params:{...n,_selectedIds:a},toast:{showOnSuccess:!1,showOnError:!1}});if(!o?.success)throw Error(o?.error||`Action ${e.name} failed`)},Ui=e=>{Ee(null),Oe([]),Ae(0),e&&e.succeeded>0&&(Mi(),ue(e=>e+1))},Wi=e=>e?._id??e?.id,Gi=async(e,n,r)=>{if(!t||!q)throw Error(`Cannot persist inline edit: no dataSource/objectName configured on the grid.`);let i=Wi(r);if(i==null)throw Error(`Cannot persist inline edit: row has no id/_id.`);await t.update(q,i,n),ue(e=>e+1)},Ji=async e=>{if(!t||!q)throw Error(`Cannot persist inline edits: no dataSource/objectName configured on the grid.`);await Promise.all(e.map(({changes:e,row:n})=>{let r=Wi(n);if(r==null)throw Error(`Cannot persist inline edit: row has no id/_id.`);return t.update(q,r,e)})),ue(e=>e+1)},Yi=e.showPagination===!1?!1:e.pagination===void 0?e.showPagination??!0:!0,Zi=Kd(e,Vd),Qi=e.searchableFields===void 0?e.showSearch===void 0||e.showSearch:e.searchableFields.length>0,ea=Xe?_:we,ta=Xe?v:tn,sa=Xe?y??rn:rn,la=Xe?b:nn,da=Xe?S:e=>{an(e),nn(1)},fa=kd(Qt),pa=Xe?C??[]:ln??fa,ma=fi?Pn(pa,fi):pa,ga=Xe?T:un,_a=fi&&ga?e=>ga(Pn(e,fi)):ga,va=hn,ya=pn?O:fn,ba={type:`data-table`,caption:p(e.label,I)||p(e.title,I),columns:hi,data:M,pagination:Yi,pageSize:ci?sa:Zi,pageSizeOptions:e.pagination?.pageSizeOptions,manualPagination:ci,rowCount:ci?ea:void 0,page:ci?ta:void 0,onPageChange:ci?la:void 0,onPageSizeChange:ci?da:void 0,manualSorting:ui,sort:ui?ma:void 0,onSortChange:ui?_a:void 0,searchable:Qi,manualSearch:di,search:di?va:void 0,onSearchChange:di?ya:void 0,selectable:Di,showSelectionCount:!1,sortable:!0,exportable:ut?.export,borderless:!0,rowActions:!!(lt&&Wr),resizableColumns:e.resizable??e.resizableColumns??!0,reorderableColumns:e.reorderableColumns??!1,editable:lt,renderCellEditor:lt?e=>{let t=B?.fields?.[e.column?.accessorKey];if(!t||!Ze(t.type))return null;let n=$e.has(t.type),r={name:e.column.accessorKey,...t},i=ca(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)(w,{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,className:e.className,cellClassName:ge===`compact`?`px-3 py-1 text-[13px] leading-tight`:ge===`short`?`px-3 py-1 text-[13px] leading-normal`:ge===`tall`?`px-3 py-2.5 text-sm`:ge===`extra_tall`?`px-3 py-3.5 text-sm leading-relaxed`:`px-3 py-1.5 text-[13px] leading-normal`,showRowNumbers:!0,showAddRow:!!ut?.create&&(ot??!0),onAddRecord:m,rowClassName:e.rowColor?(e,t)=>Hn(e):void 0,rowStyle:e.conditionalFormatting?.length?(e,t)=>Wn(e):void 0,frozenColumns:gi,onSelectionChange:e=>{ye(e),o?.(e)},selectionResetKey:Ce,onRowClick:In.handleClick,onCellChange:u,onRowSave:d??Gi,onBatchSave:f??Ji,onColumnResize:(e,t)=>{ze({...Fe,widths:{...Fe.widths,[e]:t}})},onColumnsReorder:e=>{let t=e.map(e=>e?.accessorKey).filter(e=>typeof e==`string`&&e.length>0);ze({...Fe,order:t})}},xa={};for(let e of hi){let t=e.accessorKey;if(!t)continue;let n=Fe.widths?.[t];if(n){xa[t]=n;continue}if(e.width){xa[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)}xa[t]=Math.min(400,Math.max(80,r*8+48))}let Sa=(e,t)=>({...ba,caption:void 0,data:e,pagination:!1,...t?{pagination:t.count>rn,manualPagination:!0,rowCount:t.count,page:t.page,pageSize:rn,onPageChange:t.onPageChange,onPageSizeChange:e=>{an(e)}}:{},searchable:!1,borderless:!0,disableInnerScroll:!0,frozenColumns:0,columns:ba.columns.map(e=>({...e,width:xa[e.accessorKey]??e.width}))}),Ca=p(e.label,I),wa=Ca?L(`detail.recordDetailWithLabel`,{label:Ca}):e.objectName?L(`detail.recordDetailWithLabel`,{label:e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1)}):L(`detail.recordDetail`),Ta={popoverAnchorRef:Ln,storageKey:e.objectName?Dt(e.objectName):void 0,legacyStorageKey:e.objectName?Ie(e.objectName):void 0,width:In.width??`min(960px, 60vw)`},Ea=n=>{let r=Md(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)(bl,{record:n,objectName:e.objectName,recordId:r,dataSource:t,objectSchema:B,onClose:In.close})});let a=Object.entries(n),o=e=>J?.[e]?.hidden===!0,s=e=>sr(e,J?.[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)(E,{className:`text-sm italic`,glyph:L(`grid.empty`)});if(Qe)return(0,$.jsx)(ht,{value:t});let n=J?.[e],{rendererType:r,Renderer:i}=na(n);return r?(0,$.jsx)(i,{value:t,field:n}):typeof t==`boolean`?(0,$.jsx)(gt,{variant:t?`default`:`outline`,children:L(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:wr(t,void 0,{locale:I})}):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:vt(t,re,I)}):(0,$.jsx)(`span`,{className:`text-sm break-words`,children:String(R(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:L(`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:Qe?(0,$.jsx)(ht,{value:t}):String(R(t)??``)})]},e))})]})]})},Da=p(e.description,I),Oa=Da?(0,$.jsx)(`p`,{className:`px-3 sm:px-4 pt-1.5 text-xs text-muted-foreground`,"data-testid":`object-grid-description`,children:Da}):null;if(se&&M.length>0&&!dr){let t=Lr().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=>aa(n.get(e)?.type,J?.[e]?.type,Qe),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?z(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)?yn(i):i}};return(0,$.jsxs)($.Fragment,{children:[Oa,(0,$.jsx)(`div`,{className:`space-y-2 p-2`,...zn,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)),h=o?String(e[o.accessorKey]??``):``,g=h?l(h):``,_=[`border rounded-lg p-2.5 bg-card hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation`,g?`border-l-[3px] ${g}`:``].filter(Boolean).join(` `);return(0,$.jsxs)(`div`,{className:_,onClick:()=>In.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):R(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],Mr(B?.fields?.[a.accessorKey],re),I):R(e[a.accessorKey])??`—`}),o&&e[o.accessorKey]&&(()=>{let t=e[o.accessorKey],n=f(o.accessorKey,t),r=Ge(n.color),i=r?r.className:n.color?Be(n.color,t):c(String(t));return(0,$.jsx)(gt,{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]?wr(e[s[0].accessorKey],`short`,{locale:I}):`—`}),p[0]&&e[p[0].accessorKey]!=null&&(0,$.jsx)(`span`,{className:`tabular-nums`,children:xt(Number(e[p[0].accessorKey]),void 0,I)})]}),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]?wr(e[t.accessorKey],`short`,{locale:I}):`—`})]},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(R(n)??``)})]},t.accessorKey)})]},e.id||e._id||n)})}),In.isOverlay&&(0,$.jsx)(kt,{...In,title:wa,...Ta,children:e=>Ea(e)})]})}let ka=()=>{_e(e=>e===`compact`?`short`:e===`short`?`medium`:e===`medium`?`tall`:e===`tall`?`extra_tall`:`compact`)},Aa={compact:Li,short:Ii,medium:Fi,tall:qi,extra_tall:qi}[ge],ja=e.rowHeight!==void 0&&!e.hideRowHeightToggle,Ma=!!e.exportOptions&&Rr.length>0&&e.operations?.export!==!1&&(!nt||nt.includes(`export`)),Na=Ma||ja?(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-1 px-2 py-1`,children:[ja&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs`,onClick:ka,title:`Row height: ${ge}`,children:[(0,$.jsx)(Aa,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline capitalize`,children:ge})]}),Ma&&(0,$.jsxs)(P,{open:de,onOpenChange:fe,children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs`,children:[(0,$.jsx)(li,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:L(`grid.export`)})]})}),(0,$.jsx)(ae,{align:`end`,className:`w-48 p-2`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[Rr.map(e=>(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,disabled:H,onClick:()=>zr(e),children:[H?(0,$.jsx)(wi,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,$.jsx)(li,{className:`h-3.5 w-3.5 mr-2`}),L(`grid.exportAs`,{format:e.toUpperCase()})]},e)),me&&(0,$.jsx)(`div`,{className:`px-2 py-1 text-xs`,style:{color:`var(--destructive, #ef4444)`},role:`alert`,children:me})]})})]})]}):null,Pa=Dr?(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:hi.filter(e=>Tr.has(e.accessorKey)).map(e=>{let t=Tr.get(e.accessorKey);return(0,$.jsxs)(`span`,{"data-testid":`summary-${e.accessorKey}`,children:[e.header,`: `,t.label]},e.accessorKey)})})}):null,Fa=(t,n)=>{let r=B?.fields?.[t],i=e.objectName?ie(e.objectName,t,r?.label||t):r?.label||t,a,o,s=r?.type;if(s===`select`||s===`status`){let i=r?.options?z(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=Ge(s?.color);a=c?c.className:Be(s?.color,s?.value??n),o=c?.style}return{fieldLabel:i,labelColorClass:a,labelColorStyle:o}},Ia=e=>{let t=_r.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:L(`grid.loading`)}):(0,$.jsx)(qn,{schema:Sa(t.rows,{count:e.count,page:t.page,onPageChange:t=>_r.setPage(e.key,t)})})},La=e=>{let{fieldLabel:t,labelColorClass:n,labelColorStyle:r}=Fa(e.field,e.label);return(0,$.jsx)(`div`,{children:(0,$.jsx)(Kl,{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:pr,children:e.subgroups.length>0?(0,$.jsx)(`div`,{className:`space-y-4 mt-2`,children:e.subgroups.map(La)}):Z?Ia(e):(0,$.jsx)(qn,{schema:Sa(e.rows)})})},e.key)},Ra=Math.max(1,Math.ceil(ur.length/Ne)),za=Math.min(G,Ra),Ba=ur.slice((za-1)*Ne,za*Ne),Va=ur.length>0&&Ra>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:[L(`table.rowsPerPage`),`:`]}),(0,$.jsx)(`select`,{className:`h-8 rounded-md border border-input bg-background px-2 text-sm`,value:Ne,onChange:e=>{K(Number(e.target.value)),Me(1)},children:Array.from(new Set([5,10,20,50,100,Ne])).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:L(`table.pageInfo`,{current:za,total:Ra})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(X,{variant:`outline`,size:`icon`,onClick:()=>Me(1),disabled:za===1,children:(0,$.jsx)(Qr,{className:`h-4 w-4`})}),(0,$.jsx)(X,{variant:`outline`,size:`icon`,onClick:()=>Me(Math.max(1,za-1)),disabled:za===1,children:(0,$.jsx)(Xr,{className:`h-4 w-4`})}),(0,$.jsx)(X,{variant:`outline`,size:`icon`,onClick:()=>Me(Math.min(Ra,za+1)),disabled:za===Ra,children:(0,$.jsx)(Zr,{className:`h-4 w-4`})}),(0,$.jsx)(X,{variant:`outline`,size:`icon`,onClick:()=>Me(Ra),disabled:za===Ra,children:(0,$.jsx)($r,{className:`h-4 w-4`})})]})]})]}):null,Ha=dr?(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:Ba.map(La)})}),Va]}):(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)(qn,{schema:ba})}),Pa]}),Ua=e.emptyState,Wa=di&&va.trim()!==``,Ga=Ua!=null&&!ee&&!Wa&&(dr?ur.length===0:M.length===0),Ka=Ga?mt(Ua?.icon):null,qa=Ga?(0,$.jsx)(qe,{"data-testid":`object-grid-empty-state`,className:`flex-1 min-h-[200px]`,icon:Ka?(0,$.jsx)(Ka,{className:`size-5 text-muted-foreground`}):void 0,title:Ua?.title||L(`table.noResults`),description:Ua?.message||void 0}):Ha,Ja=(0,$.jsx)(bd,{def:W,rows:De,skippedCount:ke,open:!!W,onClose:Ui,dataSource:t,resource:e.objectName??``,objectFields:B?.fields,runAction:Bi,runAggregate:Vi});return In.isOverlay&&In.mode===`split`&&In.isOpen&&In.selectedRecord?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kt,{...In,title:wa,...Ta,mainContent:(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[Oa,Na,qa,(0,$.jsx)(sd,{selectedRows:ve,actions:Ti??[],actionDefs:Si,objectFields:B?.fields,onAction:Pi,onActionDef:Ri,onClearSelection:Mi,pageSize:M.length,totalMatching:Ai?ea:void 0,allMatchingSelected:be,onSelectAllMatching:Ai?()=>Se(!0):void 0})]}),children:e=>Ea(e)}),Ja]}):(0,$.jsxs)(`div`,{ref:Ve,className:`relative h-full flex flex-col`,...zn,children:[(0,$.jsx)(it,{active:ee&&M.length>0,ariaLabel:L(`grid.refreshing`)}),Ue>0&&(0,$.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:Ue},children:L(He?`grid.refreshing`:`grid.pullToRefresh`)}),Oa,Na,qa,(0,$.jsx)(sd,{selectedRows:ve,actions:Ti??[],actionDefs:Si,objectFields:B?.fields,onAction:Pi,onActionDef:Ri,onClearSelection:Mi,pageSize:M.length,totalMatching:Ai?ea:void 0,allMatchingSelected:be,onSelectAllMatching:Ai?()=>Se(!0):void 0}),In.isOverlay&&(0,$.jsx)(kt,{...In,title:wa,...Ta,children:e=>Ea(e)}),Ja]})};b();var Xd=new Set([`true`,`t`,`yes`,`y`,`1`,`on`,`是`,`对`,`✓`,`√`]),Zd=new Set([`false`,`f`,`no`,`n`,`0`,`off`,`否`,`错`,`✗`,`×`]),Qd=new Set([...Xd,...Zd]),$d=new Set([...u,`reference`]),ef={Unsupported:`IMPORT_UNSUPPORTED_FILE`,LegacyXls:`IMPORT_LEGACY_XLS`};function tf(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 nf(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?nf(t.result):Array.isArray(t.richText)?t.richText.map(e=>String(e.text??``)).join(``):`text`in t?nf(t.text):`hyperlink`in t?String(t.hyperlink??``):`error`in t?String(t.error??``):``}return String(e)}async function rf(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(nf(e.getCell(n).value).trim());t.some(e=>e!==``)&&s.push(t)}),s}function af(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 of(e){let t=e.name.toLowerCase();if(t.endsWith(`.csv`)||t.endsWith(`.tsv`)||t.endsWith(`.txt`))return tf(af(await e.arrayBuffer()),t.endsWith(`.tsv`)?` `:`,`);if(t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`))return rf(await e.arrayBuffer());throw t.endsWith(`.xls`)?Error(ef.LegacyXls):Error(ef.Unsupported)}function sf(e,t){if(e&&/<table[\s>]/i.test(e)&&typeof DOMParser<`u`){let t=cf(e);if(t.length)return t}if(t&&t.trim()){let e=tf(t,t.includes(` `)?` `:`,`);if(e.length)return e}return null}function cf(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 lf=new Set([`true`,`false`,`yes`,`no`,`y`,`n`,`是`,`否`]),uf=50,df=e=>e!==``&&!isNaN(Number(e)),ff=e=>lf.has(e.toLowerCase()),pf=e=>/\d{1,2}:\d{2}/.test(e)||/T\d{2}:\d{2}/.test(e),mf=e=>!df(e)&&!isNaN(Date.parse(e));function hf(e){let t=e.map(e=>(e??``).trim()).filter(e=>e!==``).slice(0,uf);return t.length===0?`text`:t.every(ff)?`boolean`:t.every(df)?`number`:t.every(mf)?t.some(pf)?`datetime`:`date`:`text`}function gf(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 _f=e=>e.toLowerCase().replace(/[\s_\-.]+/g,``).replace(/[()()[\]{}::,,、/**]/g,``);function vf(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase().split(/[\s_\-./()()[\]{}::,,、**]+/).map(e=>e.trim()).filter(Boolean)}var yf=[[`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`,`更新时间`]],bf=(()=>{let e=new Map;return yf.forEach((t,n)=>t.forEach(t=>e.set(_f(t),n))),e})();function xf(e){return e>=.85?`high`:e>=.55?`medium`:e>0?`low`:null}var Sf=.4;function Cf(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 wf(e,t,n){let r=[t.name,t.label].filter(e=>!!e),i=_f(e),a=vf(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=_f(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=Cf(a,vf(t));r>0&&s(.4+r*.45,`token`)}let c=bf.get(i);return c!==void 0&&r.some(e=>bf.get(_f(e))===c)&&s(.82,`synonym`),o.reason!==`exact`&&o.reason!==`normalized`&&n!==`text`&&o.score>0&&(gf(n,t.type)?o.score=Math.min(1,o.score+.05):o.score*=.5),{score:o.score,reason:o.reason}}function Tf(e,t,n){let r=e.map((e,t)=>hf(n?n.map(e=>e[t]):[])),i=[];e.forEach((e,n)=>{t.forEach(t=>{let{score:a,reason:o}=wf(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<Sf||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:xf(n.score),reason:n.reason,inferredType:r[t]}:{columnIndex:t,fieldName:null,score:0,confidence:null,reason:`none`,inferredType:r[t]}})}function Ef(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 Df(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 Of(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 kf(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 Af={"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 a CSV with the right columns (required fields marked *).`,"grid.import.templateFileName":`{{object}}-import-template`,"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.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.rowsCorrected":`{{count}} row(s) 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.importComplete":`Import Complete`,"grid.import.imported":`{{count}} imported`,"grid.import.createdCount":`{{count}} created`,"grid.import.updatedCount":`{{count}} updated`,"grid.import.skippedCount":`{{count}} skipped`,"grid.import.moreErrors":`…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.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.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 jf(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}function Mf(){let e=(e,t)=>jf(Af[e]??e,t),t=Ir();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 Nf=10,Pf=5e3,Ff=800,If={high:`text-emerald-600`,medium:`text-sky-600`,low:`text-muted-foreground`};function Lf(e,t){let n=new Set(Object.values(e));return t.filter(e=>n.has(e.name)&&$d.has(e.type))}function Rf(e){return e?.match(/"([^"]*)"/)?.[1]}function zf(e,t,n,r){let i=e.field?t.get(e.field)??e.field:void 0,a=(n??``).trim()||Rf(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 Bf(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 Vf(e,t){if(!e)return!0;switch(t){case`number`:case`currency`:case`percent`:return!isNaN(Number(e));case`boolean`:return Qd.has(e.trim().toLowerCase());case`date`:case`datetime`:return!isNaN(Date.parse(e));case`email`:return Bf(e.trim());default:return!0}}function Hf(e,t,n){let r={};for(let i of Tf(e,t,n))i.fieldName&&(r[i.columnIndex]=i.fieldName);return r}function Uf(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Wf(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 Gf(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch{}}function Kf(e,t){let n={};return Object.entries(t).forEach(([t,r])=>{let i=e[Number(t)];i&&(n[i.trim().toLowerCase()]=r)}),n}function qf(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 Jf(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&&!Vf(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 Yf(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 Xf(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 Zf(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 Qf(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 $f(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 ep(e){return e===`pending`||e===`running`}function tp(e,t){return t&&!!e.undoable&&!e.revertedAt&&!ep(e.status)}function np(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 rp(e){let t=e?.[0];if(t!=null){if(typeof t==`string`)return t;if(t.label)return t.label;if(t.value!==void 0&&t.value!==null)return String(t.value)}}function ip(e){switch(e.type){case`number`:case`currency`:case`percent`:return`0`;case`date`:return`2024-01-31`;case`datetime`:return`2024-01-31 09:00`;case`time`:return`09:00`;case`boolean`:return`true`;case`email`:return`name@example.com`;case`url`:return`https://example.com`;case`select`:case`multiselect`:case`lookup`:case`reference`:return rp(e.options)??``;default:return``}}function ap(e){let t=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,n=e.map(e=>`${e.label}${e.required?` *`:``}`),r=e.map(e=>ip(e));return[n.map(t).join(`,`),r.map(t).join(`,`)].join(`
|
|
11
|
+
`)}function op(e,t,n=`text/csv;charset=utf-8`){if(typeof document>`u`||typeof URL?.createObjectURL!=`function`)return;let r=new Blob([`\uFEFF${t}`],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),URL.revokeObjectURL(i)}function sp(e,t){let n=e instanceof Error?e.message:``;return n===ef.LegacyXls?t(`grid.import.legacyXls`):n===ef.Unsupported?t(`grid.import.unsupportedFile`):t(`grid.import.parseFailed`)}var cp=({onFileLoaded:e,fields:t,objectName:n,objectLabel:r})=>{let{t:i}=Mf(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1),d=(0,Q.useCallback)(t=>t.length<2?(c(i(`grid.import.fileNeedsHeader`)),!1):(e(t[0],t.slice(1)),!0),[e,i]),f=(0,Q.useCallback)(async e=>{c(null),u(!0);try{d(await of(e))}catch(e){c(sp(e,i))}finally{u(!1)}},[d,i]),p=(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=sf(n.getData(`text/html`)||null,n.getData(`text/plain`)||null);r&&(e.preventDefault(),c(null),d(r))},[d]);return(0,Q.useEffect)(()=>(window.addEventListener(`paste`,p),()=>window.removeEventListener(`paste`,p)),[p]),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-6`,children:[(0,$.jsxs)(`div`,{className:Y(`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&&f(t)},children:[(0,$.jsx)(Qi,{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&&f(t)}}),(0,$.jsx)(X,{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)(ai,{className:`h-3.5 w-3.5`}),` `,i(`grid.import.pasteHint`)]})]}),t.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{op(`${mr(i(`grid.import.templateFileName`,{object:r||n||`import`}))||`import-template`}.csv`,ap(t))},"data-testid":`import-download-template`,children:[(0,$.jsx)(li,{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)(ei,{className:`h-4 w-4`}),` `,s]})]})},lp=({templates:e,selectedId:t,onSelect:n,onSaveAs:r,onDelete:i,disabled:a})=>{let{t:o}=Mf(),[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)(Ri,{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)(I,{value:t??`__none__`,onValueChange:e=>e!==`__none__`&&n(e),children:[(0,$.jsx)(jt,{className:`h-7 w-48 text-xs`,"data-testid":`import-template-select`,children:(0,$.jsx)(O,{placeholder:e.length?o(`grid.import.chooseTemplate`):o(`grid.import.noSavedTemplates`)})}),(0,$.jsxs)(V,{children:[(0,$.jsx)(ye,{value:`__none__`,disabled:e.length===0,children:e.length?o(`grid.import.noneOption`):o(`grid.import.noSavedTemplates`)}),e.map(e=>(0,$.jsx)(ye,{value:e.id,children:e.name},e.id))]})]}),l?(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ie,{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)(X,{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)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{u(!1),c(``)},children:o(`grid.import.cancel`)})]}):(0,$.jsx)(X,{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)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,"aria-label":o(`grid.import.deleteTemplate`),"data-testid":`import-template-delete-btn`,children:(0,$.jsx)(Ji,{className:`h-3.5 w-3.5`})})]})},up=({mappings:e,activeName:t,onSelect:n,onClear:r})=>{let{t:i}=Mf();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)(gi,{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)(I,{value:t??`__none__`,onValueChange:e=>e===`__none__`?r():n(e),children:[(0,$.jsx)(jt,{className:`h-7 w-56 text-xs`,"data-testid":`import-saved-mapping-select`,children:(0,$.jsx)(O,{placeholder:i(`grid.import.chooseSavedMapping`)})}),(0,$.jsxs)(V,{children:[(0,$.jsx)(ye,{value:`__none__`,children:i(`grid.import.manualMapping`)}),e.map(e=>(0,$.jsx)(ye,{value:e.name,children:e.label||e.name},e.name))]})]})]})},dp=({mapping:e})=>{let{t}=Mf(),n=Of(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)(ei,{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)(bt,{children:[(0,$.jsx)(K,{children:(0,$.jsxs)(ut,{children:[(0,$.jsx)(J,{children:t(`grid.import.csvColumn`)}),(0,$.jsx)(J,{children:t(`grid.import.mapsTo`)}),(0,$.jsx)(J,{className:`w-32 text-center`,children:t(`grid.import.transform`)})]})}),(0,$.jsx)(ot,{children:n.map((e,t)=>(0,$.jsxs)(ut,{children:[(0,$.jsx)(_t,{className:`font-medium`,children:e.source}),(0,$.jsx)(_t,{children:e.target}),(0,$.jsx)(_t,{className:`text-center`,children:e.transform?(0,$.jsx)(gt,{variant:`outline`,className:`text-[10px] font-normal`,children:e.transform}):(0,$.jsx)(E,{})})]},t))})]})})]})},fp=({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}=Mf(),_=(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)(up,{mappings:d,activeName:f?.name??null,onSelect:p,onClear:m}),f?(0,$.jsx)(dp,{mapping:f}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(lp,{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)(ti,{className:`h-3.5 w-3.5 text-emerald-600`}),g(`grid.import.autoMatchedSummary`,{count:String(y)})]}),(0,$.jsx)(`div`,{className:`max-h-[420px] overflow-auto`,children:(0,$.jsxs)(bt,{children:[(0,$.jsx)(K,{children:(0,$.jsxs)(ut,{children:[(0,$.jsx)(J,{children:g(`grid.import.csvColumn`)}),(0,$.jsx)(J,{children:g(`grid.import.mapsTo`)}),(0,$.jsx)(J,{className:`w-24 text-center`,children:g(`grid.import.status`)})]})}),(0,$.jsx)(ot,{children:e.map((e,r)=>{let a=i[r]??`text`,o=n[r]?t.find(e=>e.name===n[r]):void 0,s=!!o&&!gf(a,o.type),c=v.get(r),l=c?.fieldName&&n[r]===c.fieldName?c.confidence:null;return(0,$.jsxs)(ut,{children:[(0,$.jsx)(_t,{className:`font-medium`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{children:e}),a!==`text`&&(0,$.jsx)(gt,{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)(_t,{children:[(0,$.jsxs)(I,{value:n[r]??`__skip__`,onValueChange:e=>b(r,e),children:[(0,$.jsx)(jt,{className:`h-8 w-56`,children:(0,$.jsx)(O,{placeholder:g(`grid.import.skipColumn`)})}),(0,$.jsxs)(V,{children:[(0,$.jsx)(ye,{value:`__skip__`,children:g(`grid.import.skip`)}),t.map(e=>(0,$.jsxs)(ye,{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:Y(`mt-1 flex items-center gap-1 text-[11px]`,If[l]),"data-testid":`import-automatch-${r}`,children:[(0,$.jsx)(ti,{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)(ei,{className:`h-3 w-3`}),` `,g(`grid.import.typeMismatch`,{type:g(`grid.import.type.${a}`)})]})]}),(0,$.jsx)(_t,{className:`text-center`,children:n[r]?(0,$.jsx)(gt,{variant:`default`,className:`text-xs`,children:g(`grid.import.mapped`)}):(0,$.jsx)(gt,{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)(ei,{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(`, `)})})]})]})]})},pp=({headers:e,rows:t,mapping:n,fields:r,corrections:i,onCorrect:a})=>{let{t:o}=Mf(),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,Nf),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&&!Vf(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)(ei,{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)(ti,{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)(bt,{children:[(0,$.jsx)(K,{children:(0,$.jsxs)(ut,{children:[(0,$.jsx)(J,{className:`w-12`,children:`#`}),s.map(e=>(0,$.jsx)(J,{className:`min-w-[140px] whitespace-nowrap`,children:e.field.label},e.csvIdx))]})}),(0,$.jsx)(ot,{children:c.map((e,t)=>{let n=u[t],r=Object.keys(n).length>0,o=i[t]!==void 0;return(0,$.jsxs)(ut,{className:Y(r&&`bg-destructive/5`,!r&&o&&`bg-emerald-50 dark:bg-emerald-950/20`),"data-testid":`import-preview-row-${t}`,children:[(0,$.jsx)(_t,{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)(_t,{className:Y(o&&`text-destructive`,s&&!o&&`text-emerald-600`),title:o,children:(0,$.jsx)(ie,{value:r,onChange:n=>a(t,e.csvIdx,n.target.value),className:Y(`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})})]})},mp=({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:_}=Mf(),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)(ge,{className:`text-xs`,children:_(`grid.import.writeMode`)}),(0,$.jsxs)(I,{value:n,onValueChange:e=>r(e),children:[(0,$.jsx)(jt,{className:`h-8 w-72 text-xs`,"data-testid":`import-writemode-select`,children:(0,$.jsx)(O,{})}),(0,$.jsxs)(V,{children:[(0,$.jsx)(ye,{value:`insert`,children:_(`grid.import.writeModeOpt.insert`)}),(0,$.jsx)(ye,{value:`update`,children:_(`grid.import.writeModeOpt.update`)}),(0,$.jsx)(ye,{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)(ge,{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)(Mt,{checked:i.includes(e.name),onCheckedChange:()=>a(e.name)}),e.label]},e.name))]}),(0,$.jsx)(`p`,{className:Y(`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)(Mt,{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)(Mt,{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)(Mt,{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)(Mt,{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)(Mt,{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`)})]})]})]})]})]})},hp={pending:`outline`,running:`secondary`,succeeded:`default`,failed:`destructive`,cancelled:`outline`};function gp(e,t){if(!e)return`—`;let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleString(t)}var _p=({objectName:e,dataSource:t,t:n})=>{let r=Fr(),[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)(X,{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)(bt,{children:[(0,$.jsx)(K,{children:(0,$.jsxs)(ut,{children:[(0,$.jsx)(J,{children:n(`grid.import.historyColStatus`)}),(0,$.jsx)(J,{className:`text-right`,children:n(`grid.import.historyColRows`)}),(0,$.jsx)(J,{className:`text-right`,children:n(`grid.import.historyColResult`)}),(0,$.jsx)(J,{children:n(`grid.import.historyColTime`)}),(0,$.jsx)(J,{})]})}),(0,$.jsx)(ot,{children:i.map(e=>(0,$.jsxs)(ut,{"data-testid":`import-history-row-${e.jobId}`,children:[(0,$.jsx)(_t,{children:(0,$.jsx)(gt,{variant:hp[e.status],children:n(`grid.import.jobStatus.${e.status}`)})}),(0,$.jsxs)(_t,{className:`text-right tabular-nums`,children:[e.processed,`/`,e.total]}),(0,$.jsxs)(_t,{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)(_t,{className:`text-xs text-muted-foreground`,children:gp(e.completedAt??e.createdAt,r)}),(0,$.jsxs)(_t,{className:`text-right`,children:[ep(e.status)&&typeof f?.cancelImportJob==`function`&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:()=>void g(e.jobId),"data-testid":`import-history-cancel-${e.jobId}`,children:[(0,$.jsx)(ea,{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`)}),tp(e,m)&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:()=>void _(e.jobId),disabled:u===e.jobId,"data-testid":`import-history-undo-${e.jobId}`,children:[(0,$.jsx)(Zi,{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`)})},vp=({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}=Mf(),[g,_]=(0,Q.useState)(`upload`),[v,y]=(0,Q.useState)([]),[b,x]=(0,Q.useState)([]),[S,C]=(0,Q.useState)({}),[w,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(0),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)({}),[N,ee]=(0,Q.useState)(!1),[ne,P]=(0,Q.useState)(null),[F,re]=(0,Q.useState)(null),I=Q.useRef(!1),[L,R]=(0,Q.useState)(!1),[ie,z]=(0,Q.useState)(null),[ae,oe]=(0,Q.useState)(`insert`),[B,V]=(0,Q.useState)([]),[se,ce]=(0,Q.useState)(!1),[ue,fe]=(0,Q.useState)(!0),[H,pe]=(0,Q.useState)(!1),[he,ge]=(0,Q.useState)(!1),[_e,ve]=(0,Q.useState)(!1),ye=t??e,be=(0,Q.useMemo)(()=>new Map(n.map(e=>[e.name,e.label])),[n]),xe=(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]),Se=(0,Q.useCallback)((e,t)=>{if(!t)return;let n=xe.get(t);if(n===void 0)return;let r=e-1;return j[r]?.[n]??b[r]?.[n]},[xe,j,b]),Ce=(0,Q.useMemo)(()=>{let e=r;return typeof e?.createImportJob==`function`&&typeof e?.getImportJobProgress==`function`&&typeof e?.getImportJobResults==`function`},[r]),U=(0,Q.useCallback)(e=>{V(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]);(0,Q.useEffect)(()=>{let e=new Set(Object.values(S));V(t=>{let n=t.filter(t=>e.has(t));return n.length===t.length?t:n})},[S]);let we=(0,Q.useMemo)(()=>u===void 0?Uf():u,[u]),Te=l??`objectui:import-templates:${e}`,[W,Ee]=(0,Q.useState)(()=>Wf(we,Te)),[De,ke]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Ee(Wf(we,Te))},[we,Te]);let[Ae,je]=(0,Q.useState)([]),[G,Me]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(d)return;let t=!0,n=r?.listImportMappings;if(typeof n!=`function`){je([]);return}return Promise.resolve(n.call(r,e)).then(e=>{t&&je((e??[]).map(Ef).filter(e=>e!==null))}).catch(()=>{t&&je([])}),()=>{t=!1}},[r,e,d]);let Ne=d??Ae,K=(0,Q.useMemo)(()=>Ne.find(e=>e.name===G)??null,[Ne,G]),Pe=(0,Q.useCallback)(e=>{let t=Ne.find(t=>t.name===e);t&&(Me(e),ke(null),C(kf(t,v)),(t.mode===`update`||t.mode===`upsert`)&&oe(t.mode),Array.isArray(t.upsertKey)&&V(t.upsertKey.filter(e=>typeof e==`string`)),z(null))},[Ne,v]),Fe=(0,Q.useCallback)(()=>{Me(null),oe(`insert`),V([]),C(Hf(v,n,b)),z(null)},[v,n,b]),Ie=(0,Q.useCallback)(e=>{let t=W.find(t=>t.id===e);t&&(ke(e),C(qf(t,v,n)))},[W,v,n]),Le=(0,Q.useCallback)(e=>{let t={id:`tpl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,name:e,mapping:Kf(v,S),updatedAt:Date.now()},n=[...W,t];Ee(n),ke(t.id),Gf(we,Te,n)},[W,v,S,we,Te]),Re=(0,Q.useCallback)(()=>{if(!De)return;let e=W.filter(e=>e.id!==De);Ee(e),ke(null),Gf(we,Te,e)},[W,De,we,Te]),ze=(0,Q.useCallback)((e,t,n)=>{M(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]),Be=(0,Q.useMemo)(()=>{let e=new Set(Object.values(S));return n.filter(t=>t.required&&!e.has(t.name))},[n,S]),Ve=(0,Q.useCallback)((e,t)=>{y(e),x(t),C(Hf(e,n,t)),M({}),_(`mapping`)},[n]),He=Q.useRef(null);(0,Q.useEffect)(()=>{if(!o||!f||He.current===f)return;He.current=f;let e=!1;return(async()=>{try{let t=await of(f);if(e||t.length<2)return;Ve(t[0],t.slice(1))}catch{}})(),()=>{e=!0}},[o,f,Ve]);let Ue=(0,Q.useMemo)(()=>v.map((e,t)=>hf(b.map(e=>e[t]))),[v,b]),We=(0,Q.useMemo)(()=>Tf(v,n,b),[v,n,b]),Ge=(0,Q.useCallback)(()=>{let e=Object.entries(S).map(([e,t])=>({csvIdx:Number(e),field:t}));return b.map((t,n)=>{let r=j[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,j]),Ke=(0,Q.useCallback)(async()=>{let t=Lf(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(`, `)})}]};A(e),E(!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=j[t],{record:u,errors:d}=Jf(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}O(Math.round((t+1)/b.length*100))}let u={totalRows:b.length,importedRows:o,skippedRows:s,errors:a,degraded:!0};A(u),E(!1),i?.(u)},[b,S,n,r,e,i,c,j,h]),qe=(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(Qf(e))throw e;if(Zf(e))return!1;throw e}P(a.jobId),re({processed:0,total:a.total});let o=new Set([`succeeded`,`failed`,`cancelled`]),s=0;for(;;){if(I.current||(await new Promise(e=>setTimeout(e,Ff)),I.current))return!0;let e;try{e=await n.getImportJobProgress(a.jobId),s=0}catch(e){if(++s>=5)throw e;continue}if(re({processed:e.processed,total:e.total}),O(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 A(t),E(!1),i?.(t),!0}let t=$f(await n.getImportJobResults(a.jobId));return e.status===`failed`&&t.errors.length===0&&t.errors.push({row:0,field:``,message:e.error??`Import failed`}),O(100),A(t),E(!1),i?.(t),!0}},[r,e,i]),Je=(0,Q.useCallback)((e=!1)=>Yf(G?Df(v,b,j):Ge(),{writeMode:ae,matchFields:B,createMissingOptions:se,runAutomations:ue,treatAsHistorical:H,skipBlankMatchKey:he,dryRun:e,...G?{mappingName:G}:{}}),[Ge,G,v,b,j,ae,B,se,ue,H,he]),Ye=(0,Q.useCallback)(async()=>{E(!0),O(0),I.current=!1,P(null),re(null);let t=Je();if(b.length>Pf||_e)try{if(await qe(t))return}catch(e){if(Qf(e)){let e={totalRows:b.length,importedRows:0,skippedRows:b.length,errors:[{row:0,field:``,message:h(`grid.import.notAllowed`)}]};A(e),E(!1),i?.(e);return}if(!Zf(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}]};A(n),E(!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};O(100),A(o),E(!1),i?.(o);return}catch(e){if(Qf(e)){let e={totalRows:b.length,importedRows:0,skippedRows:b.length,errors:[{row:0,field:``,message:h(`grid.import.notAllowed`)}]};A(e),E(!1),i?.(e);return}if(!Xf(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}]};A(n),E(!1),i?.(n);return}}await Ke()},[r,e,Je,i,b.length,Ke,qe,_e,h]),Xe=(0,Q.useCallback)(async()=>{let t=r?.importRecords;if(typeof t==`function`){R(!0);try{let n=await t.call(r,e,Je(!0));z(n)}catch(t){if(Qf(t)){z({object:e,dryRun:!0,writeMode:ae,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(!Xf(t)){let n=t instanceof Error?t.message:`Validation failed`;z({object:e,dryRun:!0,writeMode:ae,total:b.length,ok:0,errors:b.length,created:0,updated:0,skipped:0,results:[{row:0,ok:!1,action:`failed`,error:n}]})}}finally{R(!1)}}},[r,e,Je,ae,b.length,h]);(0,Q.useEffect)(()=>{z(null)},[S,j,ae,B,se,ue,he]);let q=(0,Q.useCallback)(async()=>{I.current=!0;let e=ne,t=r;if(e&&typeof t?.cancelImportJob==`function`)try{await t.cancelImportJob(e)}catch{}let n={totalRows:F?.total??b.length,importedRows:0,skippedRows:0,errors:[],cancelled:!0};A(n),E(!1)},[ne,r,F,b.length]),J=(0,Q.useCallback)(()=>{I.current=!1,_(`upload`),y([]),x([]),C({}),O(0),A(null),M({}),ke(null),Me(null),oe(`insert`),V([]),ce(!1),fe(!0),ge(!1),P(null),re(null),R(!1),z(null),ee(!1)},[]),Ze=(0,Q.useCallback)(()=>{if(!k||k.errors.length===0)return;let t=new Map;for(let e of k.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=np(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{}},[k,v,b,S,e]),$e=(0,Q.useCallback)(()=>{J(),s?.(!1),a?.()},[J,s,a]);return(0,$.jsx)(T,{open:o,onOpenChange:e=>{e?s?.(e):$e()},children:(0,$.jsxs)(Qe,{className:`flex max-h-[85vh] flex-col gap-4 overflow-hidden sm:max-w-4xl`,onInteractOutside:e=>e.preventDefault(),children:[(0,$.jsxs)(me,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pr-6`,children:[(0,$.jsxs)(te,{className:`flex items-center gap-2`,children:[(0,$.jsx)(gi,{className:`h-5 w-5`}),` `,h(`grid.import.title`,{object:ye})]}),g===`upload`&&!k&&!w&&typeof r?.listImportJobs==`function`&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>ee(e=>!e),"data-testid":`import-history-toggle`,children:h(N?`grid.import.historyBack`:`grid.import.history`)})]}),(0,$.jsx)(le,{children:h(N?`grid.import.historyDescription`:g===`upload`?`grid.import.uploadDescription`:g===`mapping`?`grid.import.mappingDescription`:`grid.import.previewDescription`)})]}),!N&&(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)(Br,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{className:Y(`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:N?(0,$.jsx)(_p,{objectName:e,dataSource:r,t:h}):k?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-4`,children:[k.cancelled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ea,{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)(ti,{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:[k.createdRows!==void 0||k.updatedRows!==void 0?(0,$.jsxs)($.Fragment,{children:[(k.createdRows??0)>0&&(0,$.jsx)(gt,{variant:`default`,children:h(`grid.import.createdCount`,{count:k.createdRows})}),(k.updatedRows??0)>0&&(0,$.jsx)(gt,{variant:`default`,children:h(`grid.import.updatedCount`,{count:k.updatedRows})}),(k.createdRows??0)===0&&(k.updatedRows??0)===0&&(0,$.jsx)(gt,{variant:`default`,children:h(`grid.import.imported`,{count:k.importedRows})})]}):(0,$.jsx)(gt,{variant:`default`,children:h(`grid.import.imported`,{count:k.importedRows})}),k.skippedRows>0&&(0,$.jsx)(gt,{variant:`destructive`,children:h(`grid.import.skippedCount`,{count:k.skippedRows})})]}),k.degraded&&!k.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)(ei,{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(k)}),k.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:[k.errors.slice(0,10).map((e,t)=>{let{fieldLabel:n,message:r}=zf({field:e.field,error:e.message,code:e.code},be,Se(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)}),k.errors.length>10&&(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:h(`grid.import.moreErrors`,{count:k.errors.length-10})})]}),k.errors.some(e=>e.row>=1)&&(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:Ze,"data-testid":`import-download-failed`,children:[(0,$.jsx)(li,{className:`mr-1 h-4 w-4`}),` `,h(`grid.import.downloadFailed`)]})]}),k.resultsTruncated&&(0,$.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:h(`grid.import.resultsTruncated`,{count:k.errors.length,total:k.skippedRows})})]}):(0,$.jsxs)($.Fragment,{children:[g===`upload`&&(0,$.jsx)(cp,{onFileLoaded:Ve,fields:n,objectName:e,objectLabel:ye}),g===`mapping`&&(0,$.jsx)(fp,{headers:v,fields:n,mapping:S,onMappingChange:C,inferredTypes:Ue,suggestions:We,templates:W,selectedTemplateId:De,onSelectTemplate:Ie,onSaveTemplate:Le,onDeleteTemplate:Re,savedMappings:Ne,activeMapping:K,onSelectSavedMapping:Pe,onClearSavedMapping:Fe,missingRequired:Be}),g===`preview`&&(0,$.jsxs)($.Fragment,{children:[p&&(0,$.jsx)(`div`,{"data-testid":`import-extra-options`,children:p}),!K&&(0,$.jsx)(mp,{fields:n,mapping:S,writeMode:ae,onWriteMode:oe,matchFields:B,onToggleMatchField:U,createMissingOptions:se,onCreateMissingOptions:ce,runAutomations:ue,onRunAutomations:fe,treatAsHistorical:H,onTreatAsHistorical:pe,skipBlankMatchKey:he,onSkipBlankMatchKey:ge,showBackground:Ce&&b.length<=Pf,backgroundImport:_e,onBackgroundImport:ve}),K&&(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)(ei,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:h(`grid.import.savedMappingPreviewNote`,{name:K.label||K.name})})]}),(0,$.jsx)(pp,{headers:v,rows:b,mapping:S,fields:n,corrections:j,onCorrect:ze}),b.length>Pf&&(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)(ei,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsxs)(`span`,{children:[h(`grid.import.largeSampleNotice`,{shown:Nf,total:b.length}),` `,h(`grid.import.asyncLargeHint`)]})]}),b.length<=Pf&&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)(X,{variant:`outline`,size:`sm`,onClick:Xe,disabled:L,"data-testid":`import-validate-btn`,children:h(L?`grid.import.validating`:`grid.import.validate`)})]}),ie&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,"data-testid":`import-validate-result`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium ${ie.errors>0?`text-destructive`:`text-emerald-600`}`,children:ie.errors>0?h(`grid.import.validateFailed`,{ok:ie.ok,errors:ie.errors}):h(`grid.import.validatePassed`,{ok:ie.ok})}),ie.errors>0&&(0,$.jsx)(`ul`,{className:`max-h-32 overflow-auto text-xs text-destructive`,children:ie.results.filter(e=>!e.ok).slice(0,20).map((e,t)=>{let{fieldLabel:n,message:r}=zf(e,be,Se(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)(Oe,{value:D,className:`h-2 w-full`}),(0,$.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:ne?F?h(`grid.import.asyncProcessing`,{processed:F.processed,total:F.total,progress:D}):h(`grid.import.asyncQueued`):h(`grid.import.importing`,{progress:D})}),ne&&typeof r?.cancelImportJob==`function`&&(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:q,"data-testid":`import-cancel-async`,children:[(0,$.jsx)(ea,{className:`mr-1 h-4 w-4`}),` `,h(`grid.import.cancelImport`)]})]})]})}),(0,$.jsx)(de,{className:`gap-2 sm:gap-0`,children:N?(0,$.jsxs)(X,{variant:`outline`,onClick:()=>ee(!1),children:[(0,$.jsx)(Rr,{className:`mr-1 h-4 w-4`}),` `,h(`grid.import.historyBack`)]}):k?(0,$.jsx)(X,{onClick:$e,"data-testid":`import-close-btn`,children:h(`grid.import.close`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(X,{variant:`ghost`,onClick:$e,disabled:w,children:[(0,$.jsx)(ea,{className:`mr-1 h-4 w-4`}),` `,h(`grid.import.cancel`)]}),(g===`mapping`||g===`preview`)&&(0,$.jsxs)(X,{variant:`outline`,onClick:()=>_(g===`mapping`?`upload`:`mapping`),disabled:w,children:[(0,$.jsx)(Rr,{className:`mr-1 h-4 w-4`}),` `,h(`grid.import.back`)]}),g===`mapping`&&(0,$.jsxs)(X,{onClick:()=>_(`preview`),disabled:G?!1:Object.keys(S).length===0||Be.length>0,"data-testid":`import-next-btn`,children:[h(`grid.import.next`),` `,(0,$.jsx)(Br,{className:`ml-1 h-4 w-4`})]}),g===`preview`&&(0,$.jsx)(X,{onClick:Ye,disabled:w||!G&&ae!==`insert`&&B.length===0,"data-testid":`import-run-btn`,children:w?h(`grid.import.importingProgress`):h(`grid.import.importNRows`,{count:b.length})})]})})]})})},yp=t({ImportWizard:()=>vp,ObjectGrid:()=>Yd,ObjectGridRenderer:()=>Sp,parseSpreadsheetFile:()=>of}),bp={columns:!0,filter:!0,sort:!0,limit:`pagination.pageSize`},xp=(e,t)=>Array.isArray(t)||e?.bind!=null||e?.data?.provider===`value`||e?.staticData!=null?!1:typeof e?.objectName==`string`&&e.objectName.length>0,Sp=En(({schema:e,...t})=>{let{dataSource:n,...r}=t,i=cr(n);return(0,$.jsx)(_r,{schema:e,mapping:bp,dataSource:i,testId:`object-grid`,errorTitle:`This grid’s data source could not be resolved`,requiresDataSource:xp(e,r.data),noDataSourceMessage:Hn(`object-grid`,e?.objectName),children:e=>(0,$.jsx)(Yd,{schema:e,...r,dataSource:i})})}),Cp=[{name:`objectName`,type:`string`,required:!0},{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:`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/cell styling rules. Accepts both the ObjectUI `{ field, operator, value }` form and the spec expression form `{ condition, style }`."},{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:`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."}];kn.register(`object-grid`,Sp,{namespace:`plugin-grid`,label:`Object Grid`,category:`plugin`,inputs:Cp.map(e=>({...e}))}),kn.register(`grid`,Sp,{namespace:`view`,skipFallback:!0,label:`Data Grid`,category:`view`,inputs:Cp.map(e=>({...e}))}),kn.register(`import-wizard`,({schema:e,...t})=>{let{dataSource:n}=Zn()||{};return(0,$.jsx)(vp,{objectName:e.objectName,objectLabel:e.objectLabel,fields:e.fields??[],dataSource:n,...t})},{namespace:`plugin-grid`,label:`Import Wizard`,category:`plugin`,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`fields`,type:`array`,required:!0}]});export{xa as _,Sl as a,bl as c,kc as d,hs as f,Sa as g,No as h,Cl as i,gl as l,as as m,vp as n,xl as o,ls as p,Yd as r,yl as s,yp as t,Ec as u,ha as v};
|