@objectstack/console 17.1.0 → 17.3.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 +731 -0
- package/README.md +26 -10
- package/dist/.objectstack-injection.json +2 -2
- package/dist/.objectui-sha +1 -1
- package/dist/assets/ActionResultDialog-CQwenjVA.js +9 -0
- package/dist/assets/AiPendingActionsPage-7gZ8zlOy.js +1 -0
- package/dist/assets/ApiConsolePage-DUF0ysH7.js +1 -0
- package/dist/assets/{AppDocsIndex-DVrJTsbv.js → AppDocsIndex-CP_AVG4X.js} +1 -1
- package/dist/assets/AppManagementPage-BJktnoa5.js +1 -0
- package/dist/assets/ApprovalsInboxPage-DlnxY-uy.js +1 -0
- package/dist/assets/{AuditLogPage-B-2e1YhN.js → AuditLogPage-DIJPRjji.js} +1 -1
- package/dist/assets/{ComponentNavView-BVbkfJfE.js → ComponentNavView-C84QByT7.js} +1 -1
- package/dist/assets/CreateViewDialog-Zbd9Cagm.js +1 -0
- package/dist/assets/DashboardView-UyKHklBx.js +1 -0
- package/dist/assets/{DeveloperHubPage-CWq2uYpr.js → DeveloperHubPage-BRyNdrCJ.js} +1 -1
- package/dist/assets/DocPage-Bx8ZXCYt.js +1 -0
- package/dist/assets/{DocShell-UFsFTSr-.js → DocShell-Ipy_IDvh.js} +1 -1
- package/dist/assets/DocsIndex-CmY-7OQR.js +1 -0
- package/dist/assets/DocsLayout-BNsSvaz2.js +1 -0
- package/dist/assets/DocsSlug-Cb_NMM1k.js +1 -0
- package/dist/assets/ExpressionProvider-DqGWVuxV.js +1 -0
- package/dist/assets/FlowRunsPage-B6ustUgi.js +1 -0
- package/dist/assets/{IntegrationsPage-DdKbqwGE.js → IntegrationsPage-chOxmiyU.js} +2 -2
- package/dist/assets/InterfaceListPage-DVETnQm5.js +1 -0
- package/dist/assets/MarketplaceInstalledPage-DA5pjhAz.js +1 -0
- package/dist/assets/MarketplacePackagePage-dCIVHBFi.js +4 -0
- package/dist/assets/MarketplacePage-wJb6g1p7.js +1 -0
- package/dist/assets/MetadataInspector-Cu-n1FYz.js +1 -0
- package/dist/assets/ObjectDataPage-CP-YSZYQ.js +1 -0
- package/dist/assets/PageView-B1_ibRuM.js +1 -0
- package/dist/assets/ProfilePage-DEr5iZVB.js +1 -0
- package/dist/assets/PublicFormsPage-CBcKQbNl.js +1 -0
- package/dist/assets/RecordDetailView-A8bbPnkK.js +3 -0
- package/dist/assets/RecordFormPage-CGQlYWDk.js +1 -0
- package/dist/assets/ReportDefaultInspector-R_p6YStL.js +1 -0
- package/dist/assets/ReportView-BTMrtcGH.js +2 -0
- package/dist/assets/RuntimeDraftBar-agGU39FL.js +1 -0
- package/dist/assets/SchemaForm-DJbupOno.js +3 -0
- package/dist/assets/SearchResultsPage-CHhZUc6L.js +1 -0
- package/dist/assets/SettingsHub-BGLR_gS7.js +1 -0
- package/dist/assets/SettingsView-Bq-7Zkzs.js +1 -0
- package/dist/assets/SkeletonDetail-B4-UKxai.js +1 -0
- package/dist/assets/SystemHubPage-CVZVag1e.js +1 -0
- package/dist/assets/{abnfDiagram-N423BO3Z-DfpQlDUF.js → abnfDiagram-VCTEODGH-DUS5D5dU.js} +1 -1
- package/dist/assets/app-shell-eager-leaves-BB0oaPx6.js +1 -0
- package/dist/assets/{utils-CJ4UwXMF.js → appRoute-DEVGXLLH.js} +1 -1
- package/dist/assets/architecture-7GRP2DOG-kzM7RUjO.js +1 -0
- package/dist/assets/{architectureDiagram-T3A2C74G-Ej_4n3NG.js → architectureDiagram-5GKGNRK7-mGW8P1lC.js} +1 -1
- package/dist/assets/blockDiagram-OSKFZWR5-Bz2hnVmp.js +129 -0
- package/dist/assets/c4Diagram-7LVT6UL2-DU3u1Y6c.js +38 -0
- package/dist/assets/channel-FD4s9EIH.js +1 -0
- package/dist/assets/{chunk-U6XO7XAA-D-dXvZaW.js → chunk-2ZTRR5NV-DXmA5XXf.js} +1 -1
- package/dist/assets/chunk-3NF5O7KM-B8Q7HUio.js +168 -0
- package/dist/assets/{chunk-YOTPTUD7-CDtXQZ13.js → chunk-3Z5EZCMW-D3OlaP15.js} +1 -1
- package/dist/assets/chunk-4HAMMTFA-BPKwX4iB.js +62 -0
- package/dist/assets/{chunk-BIQX33UG-DMScvo0C.js → chunk-5V3GS4D5-sE73jHoi.js} +1 -1
- package/dist/assets/{chunk-MOZMSUNE-DG70Besp.js → chunk-6AZGARVD-dsTIs5yl.js} +1 -1
- package/dist/assets/{chunk-5JV3BV7I-BrKM6vC-.js → chunk-6EIED4P4-BB4xaK3K.js} +1 -1
- package/dist/assets/{chunk-R7FJI6CG-DsJHM8am.js → chunk-6K3QC6MW-DaG1LefG.js} +1 -1
- package/dist/assets/{chunk-OSBZ3O6U-Dch_xyhf.js → chunk-6TQVIW2G-DL8WEcT0.js} +1 -1
- package/dist/assets/{chunk-JG7HCLWE-lCTbN-f1.js → chunk-747NJXEK-Bdie6H1T.js} +1 -1
- package/dist/assets/chunk-75Z2AOVW-CkSdnmiC.js +2 -0
- package/dist/assets/chunk-CLGD4ZFX-BTkDISwp.js +1 -0
- package/dist/assets/chunk-DU6HZSFF-BkY4hAzc.js +127 -0
- package/dist/assets/{chunk-2GRJ4B5K-D1if-ThW.js → chunk-F27PBJKO-DUKg0YWV.js} +1 -1
- package/dist/assets/{chunk-KEIR6QF5-ydf36Hye.js → chunk-FOHPRMQF-C65HoZVt.js} +2 -2
- package/dist/assets/chunk-GMAD6QVW-DZo_NykZ.js +72 -0
- package/dist/assets/chunk-GVQU2GXP-9ELY9S6X.js +1 -0
- package/dist/assets/chunk-H2I77ZZE-vCr_buP7.js +1 -0
- package/dist/assets/{chunk-GF5L2VYU-Dgjjn2FR.js → chunk-HLEWEB6X-iPkY2ESt.js} +1 -1
- package/dist/assets/{chunk-QBLGF6JB-CzQYydMJ.js → chunk-I5DQTOEV-Cz6Y6T9y.js} +1 -1
- package/dist/assets/{chunk-5FCAYU7R-BuOxxvKk.js → chunk-ICYGCRZG-DdtFYQ2l.js} +1 -1
- package/dist/assets/{chunk-CQNSW5MT-CCth14ZS.js → chunk-IH6LHLGP-DybuHD8B.js} +1 -1
- package/dist/assets/{chunk-CYSBUYHQ-DIigEFGo.js → chunk-KI3K4JFJ-CB_CI00L.js} +1 -1
- package/dist/assets/chunk-L3NEJ4N5-Bzz35TZJ.js +1 -0
- package/dist/assets/chunk-LNGE3PJU-DWpGwHrW.js +34 -0
- package/dist/assets/chunk-LQGUR6SS-iVI0GACK.js +1 -0
- package/dist/assets/chunk-OSK3NFVY-DcRwXCQD.js +10 -0
- package/dist/assets/{chunk-5TONJI2A-Bdh0MHqz.js → chunk-OUJLGHUK-TbeyE6CA.js} +1 -1
- package/dist/assets/chunk-P2QGCYS3-nx2-dM5t.js +1 -0
- package/dist/assets/{chunk-KBJHAD2P-DI4-lUt-.js → chunk-POPQ4Y6H-BxLOacOG.js} +1 -1
- package/dist/assets/{chunk-4I5QYGJK-DlrWrdEa.js → chunk-PWAF6VOD-2mst9kZu.js} +1 -1
- package/dist/assets/{chunk-6Q2QTUOP-C2vvuHlO.js → chunk-SVP7TREG-C3BMpr4x.js} +1 -1
- package/dist/assets/{chunk-EMLP6XTP-B4CrDa5p.js → chunk-UY3FDG6J-CDAtW6MI.js} +1 -1
- package/dist/assets/{chunk-5HE753X5-T_shrJhj.js → chunk-XHIXRSVI-CqmtoxrP.js} +1 -1
- package/dist/assets/chunk-XXDRQBXY-iNC8aYmk.js +1 -0
- package/dist/assets/{chunk-5RXB4S5H-JwFhdddt.js → chunk-ZLD2IHE6-ZFqtFJbj.js} +2 -2
- package/dist/assets/classDiagram-CYGNFDIV-D5Pd2TCl.js +1 -0
- package/dist/assets/classDiagram-v2-TLXNO2FR-D5Pd2TCl.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-XP-DnSP5.js → cose-bilkent-JH36ORCC-CPQv9aQH.js} +1 -1
- package/dist/assets/createDerive-Best2JCj.js +2 -0
- package/dist/assets/cynefin-OW5HDTMX-Dtvf1C60.js +1 -0
- package/dist/assets/{cynefinDiagram-MW4NZA55-B8MvpqXe.js → cynefinDiagram-5FMLGOSQ-Lnly8IJd.js} +1 -1
- package/dist/assets/cytoscape.esm-CGd-uY3x.js +321 -0
- package/dist/assets/dagre-OS7QT2EB-CdXLxmTK.js +4 -0
- package/dist/assets/dagre-PrKaheQc.js +1 -0
- package/dist/assets/data-adapter-DL25qpAe.js +5 -0
- package/dist/assets/default-inspector-registry-DeEG98bO.js +1 -0
- package/dist/assets/{diagram-7IWD3JNH-Xj62y5BF.js → diagram-S7CK7UJ4-DE8I3gxQ.js} +4 -4
- package/dist/assets/{diagram-UB23O5K3-bseKIzhv.js → diagram-UQ7AKVKN-D2xQpbEq.js} +1 -1
- package/dist/assets/{diagram-B4RE2ZJO-mI-iOCGl.js → diagram-VSXAHHWV-DnttDSlO.js} +1 -1
- package/dist/assets/{diagram-Q27KOJAE-B98Knrnh.js → diagram-VX7I27RA-BSEwkn7K.js} +1 -1
- package/dist/assets/{diagram-LBJQPF4R-BMTSoZch.js → diagram-Z3DM3KII-BgB9f0Nv.js} +1 -1
- package/dist/assets/dist-BpPy7hlB.js +5 -0
- package/dist/assets/{ebnfDiagram-BXEA7PRR-Bgo10FP1.js → ebnfDiagram-PWID7BFC-32WvKbS2.js} +1 -1
- package/dist/assets/erDiagram-2YWLMYGG-Dwf8uAdl.js +99 -0
- package/dist/assets/eventmodeling-NTZA5JFV-CSwP2CpK.js +1 -0
- package/dist/assets/expressionUser-CASszt1z.js +1 -0
- package/dist/assets/flowDiagram-T62WH6J4-CqVSNJ8T.js +1 -0
- package/dist/assets/framework-BfSv4Kb0.js +36 -0
- package/dist/assets/{ganttDiagram-PKOTCBZU-CrmKcYGt.js → ganttDiagram-EL5Y4UJY-DqYIE0Cu.js} +2 -2
- package/dist/assets/getIcon-CgyYxSEC.js +1 -0
- package/dist/assets/gitGraph-4MIJSDKK--Dc33TN5.js +1 -0
- package/dist/assets/{gitGraphDiagram-DS77QQ5N-COu0mOui.js → gitGraphDiagram-WWUBYQGX-D1dYmoGu.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-DUQut-ZU.js → highlighted-body-OFNGDK62-BxO9mjPI.js} +1 -1
- package/dist/assets/i18n-Cfqor-xb.js +9 -0
- package/dist/assets/i18n-locales-Bz4c8KXc.js +31 -0
- package/dist/assets/index-BU-FzlQ6.js +20 -0
- package/dist/assets/index-_VyGO4ms.css +2 -0
- package/dist/assets/info-A6RAGUB7-DBa3mCQO.js +1 -0
- package/dist/assets/{infoDiagram-6WML65LV-BT0Q6MIs.js → infoDiagram-FKFFQAWI-Cr1-5_Am.js} +1 -1
- package/dist/assets/infrastructure-CIpDEFyQ.js +3 -0
- package/dist/assets/{ishikawaDiagram-WSZJBQD7-kvPjMvBP.js → ishikawaDiagram-5VMMS53U-Bsjx7BsE.js} +1 -1
- package/dist/assets/{journeyDiagram-NVQOT4AX-DhXy7wxt.js → journeyDiagram-EYS64GPL-1scn5Z5c.js} +2 -2
- package/dist/assets/{kanban-definition-27J2QSJJ-CFDavpZY.js → kanban-definition-UXKFOSKX-DjLQAv5U.js} +2 -2
- package/dist/assets/mermaid-GHXKKRXX-NzEcDxBh.js +1 -0
- package/dist/assets/{mermaid-parser.core-Dd2B8Ckv.js → mermaid-parser.core-DUt1FNlO.js} +1 -1
- package/dist/assets/mermaid.core-pW40dd4u.js +10 -0
- package/dist/assets/metadata-admin-pawEBYI9.js +9 -0
- package/dist/assets/{mindmap-definition-FAOFIHXS-ITGoV4nW.js → mindmap-definition-THT77NOG-CUcYMB9H.js} +1 -1
- package/dist/assets/nav-selection-Dzm_mA3C.js +1 -0
- package/dist/assets/packet-AYTQ26CC-CPP93DZD.js +1 -0
- package/dist/assets/{pegDiagram-VL7TDLO6-BoRu9yvl.js → pegDiagram-XKGWAZYB-CT1r3sRa.js} +1 -1
- package/dist/assets/pie-WAS4IAKB-B-zzBvuc.js +1 -0
- package/dist/assets/{pieDiagram-7S7Q4E2Y-DVsM9krU.js → pieDiagram-E7YTZNPT-CSi-V1LQ.js} +3 -3
- package/dist/assets/plugin-calendar-BwiiCIjv.js +1 -0
- package/dist/assets/plugin-charts-CDGkx7z5.js +7 -0
- package/dist/assets/plugin-chatbot-BGnkLzFS.js +122 -0
- package/dist/assets/plugin-dashboard-Bj4ldCX6.js +6 -0
- package/dist/assets/plugin-form-_fjHxKTV.js +1 -0
- package/dist/assets/plugin-gantt-zR8DkpEg.js +63 -0
- package/dist/assets/plugin-grid-kkbz4uec.js +9 -0
- package/dist/assets/plugin-kanban-DA0eW6yj.js +1 -0
- package/dist/assets/plugin-map-DukneTNg.js +1 -0
- package/dist/assets/{plugin-markdown-7fyNN0UM.js → plugin-markdown-B7zwZHmn.js} +1 -1
- package/dist/assets/plugin-report-DaPtlsJr.js +59 -0
- package/dist/assets/plugin-timeline-B6rsNNAK.js +1 -0
- package/dist/assets/plugin-tree-DauauLFc.js +1 -0
- package/dist/assets/plugin-view-5qxxRyZZ.js +1 -0
- package/dist/assets/plugins-views-iYcMmImr.js +4 -0
- package/dist/assets/{quadrantDiagram-CIZ2JOQS-C4VzXHnp.js → quadrantDiagram-AXDQQJYC-DUJ_94hm.js} +1 -1
- package/dist/assets/radar-RG4KPBEZ-DWmbpYEk.js +1 -0
- package/dist/assets/railroad-74A4TZTK-xJ7dMu2F.js +1 -0
- package/dist/assets/railroad-abnf-HS5TGJTU-Cw4KG_nE.js +1 -0
- package/dist/assets/railroad-ebnf-LZEXJU2U-C0cgrfTl.js +1 -0
- package/dist/assets/railroad-peg-WCYAUIDC-DOEGG9oQ.js +1 -0
- package/dist/assets/{railroadDiagram-AXF67PYL-DqZ3yKWv.js → railroadDiagram-O6MQD6OU-CEyfAhzM.js} +1 -1
- package/dist/assets/{requirementDiagram-LRYGKXZP-BeH0P3vD.js → requirementDiagram-IS5BZ75X-CAK7hvBg.js} +2 -2
- package/dist/assets/{runtime-metadata-persistence-DpS5GXuQ.js → runtime-metadata-persistence-DYPxFzHI.js} +1 -1
- package/dist/assets/{sankeyDiagram-W5VNT64P-Bu_tPh-A.js → sankeyDiagram-P5KCCOFB-DgYJh7uz.js} +2 -2
- package/dist/assets/{sequenceDiagram-SI44F4Z6-BWEuLn1a.js → sequenceDiagram-WJ2MYXX4-DsQerPtC.js} +1 -1
- package/dist/assets/{src-CY2xhbXR.js → src-CVJP2nIc.js} +1 -1
- package/dist/assets/src-JX1BkhmR.js +17 -0
- package/dist/assets/{src-ClOOPIkS.js → src-S6pzKItc.js} +1 -1
- package/dist/assets/src-_DxAIBqo.js +1 -0
- package/dist/assets/{stateDiagram-OKZ733FA-Cp7aDYsZ.js → stateDiagram-XQSTLZYL-BJndPKik.js} +1 -1
- package/dist/assets/stateDiagram-v2-IH3M54BS-Bi94bTLl.js +1 -0
- package/dist/assets/studioEntry-C6G8U-LG.js +1 -0
- package/dist/assets/submitRedirect-UXd9NsjL.js +1 -0
- package/dist/assets/swimlanes-V6O3JKXN-BiKyiEJr.js +1 -0
- package/dist/assets/swimlanesDiagram-JKAHXJPX-DKIR852g.js +8 -0
- package/dist/assets/{timeline-definition-Z64GVDOM-BcUiJfLU.js → timeline-definition-24CTP7MA-CW5rY3PX.js} +2 -2
- package/dist/assets/treeView-Q6P3EWNA-BcWCBGcU.js +1 -0
- package/dist/assets/treemap-WGGIJYW6-DMTEJzXV.js +1 -0
- package/dist/assets/ui-components-D2lrjG-t.js +43 -0
- package/dist/assets/ui-layout-UUTFXV6S.js +1 -0
- package/dist/assets/use-book-data-qUZAxIs0.js +1 -0
- package/dist/assets/useActionModal-CkM-zGdy.js +1 -0
- package/dist/assets/usePackageL10n-F9isJ9pn.js +1 -0
- package/dist/assets/useSettingsLabel-CSZBfUiw.js +1 -0
- package/dist/assets/utils-MjUhYVsx.js +1 -0
- package/dist/assets/{vendor-charts-BEGSmcjR.js → vendor-charts-CY9WhhzX.js} +1 -1
- package/dist/assets/vendor-i18n-C1AQDWux.js +1 -0
- package/dist/assets/{vendor-markdown-C_Ip9E_I.js → vendor-markdown-BW_XFZ_b.js} +25 -25
- package/dist/assets/vendor-objectstack-BeKUVjuj.js +270 -0
- package/dist/assets/{vennDiagram-T6HMQDX7-BKJsL5fS.js → vennDiagram-4TSXK5OY-C79cMc25.js} +1 -1
- package/dist/assets/wardley-WFR3VGLG-BRyRizpT.js +1 -0
- package/dist/assets/{wardleyDiagram-T6FBY63Y-CZ0aMbYX.js → wardleyDiagram-VM6X3IG4-BAO0_jUk.js} +1 -1
- package/dist/assets/{xychartDiagram-ELKLHX3M-BpK2RmQ_.js → xychartDiagram-S5SC5T6Z-BIRd7YRo.js} +3 -3
- package/dist/eager-closure.json +318 -0
- package/dist/index.html +271 -15
- package/package.json +2 -2
- package/dist/assets/AdapterProvider-3zTVoQKF.js +0 -3
- package/dist/assets/AiPendingActionsPage-DD5DLXIK.js +0 -1
- package/dist/assets/ApiConsolePage-CSQNdOPN.js +0 -1
- package/dist/assets/AppManagementPage-vRCBT69X.js +0 -1
- package/dist/assets/ApprovalsInboxPage-Bft5QF0I.js +0 -1
- package/dist/assets/CreateViewDialog-CW0w7Nxc.js +0 -1
- package/dist/assets/DashboardView-CTBV4_tx.js +0 -1
- package/dist/assets/ExpressionProvider-X1OAB_O-.js +0 -1
- package/dist/assets/FlowRunsPage-CUhBLwm-.js +0 -1
- package/dist/assets/InterfaceListPage-FCdy-_Q-.js +0 -1
- package/dist/assets/ManagedByBadge-Bap9_dqR.js +0 -1
- package/dist/assets/MarketplaceAccessDenied-CrK7hygV.js +0 -1
- package/dist/assets/MarketplaceInstalledPage-Cv-qDRNA.js +0 -1
- package/dist/assets/MarketplacePackagePage-CMS--SE2.js +0 -4
- package/dist/assets/MarketplacePage-njErv-tN.js +0 -1
- package/dist/assets/MetadataInspector-CNeJqkLQ.js +0 -1
- package/dist/assets/MetadataProvider-DwMR1SMR.js +0 -1
- package/dist/assets/ObjectDataPage-BVV4yksz.js +0 -1
- package/dist/assets/PageView-XUBdr6tb.js +0 -1
- package/dist/assets/ProfilePage-ClU0WVRr.js +0 -1
- package/dist/assets/PublicFormsPage-a_MNzdQw.js +0 -1
- package/dist/assets/RecordDetailView-uf81gH3J.js +0 -11
- package/dist/assets/RecordFormPage-CLZcT8Z0.js +0 -1
- package/dist/assets/ReportDefaultInspector-DU2azDYd.js +0 -3
- package/dist/assets/ReportView-oFhBKNBE.js +0 -2
- package/dist/assets/SearchResultsPage-lgNcs7l7.js +0 -1
- package/dist/assets/SettingsHub-TQOc7wH3.js +0 -1
- package/dist/assets/SettingsView-DAje5pDB.js +0 -1
- package/dist/assets/SystemHubPage-DUE-2-vc.js +0 -1
- package/dist/assets/architecture-TIHT7OUA-B8Ln-u1a.js +0 -1
- package/dist/assets/blockDiagram-VBNYF7ZC-l_P_W7_Y.js +0 -132
- package/dist/assets/c4Diagram-5PPSVZJV-CE82HAlO.js +0 -10
- package/dist/assets/channel-DowAYf9b.js +0 -1
- package/dist/assets/chunk-3NCLNEKW-Z5ckM4mG.js +0 -1
- package/dist/assets/chunk-7BUUIJ7U-Bb538aSH.js +0 -1
- package/dist/assets/chunk-7Z6QIM7H-m6s_oalL.js +0 -10
- package/dist/assets/chunk-I66GZJ75-BsY3mBMx.js +0 -127
- package/dist/assets/chunk-J7OUQ5F2-Cl4FNR_k.js +0 -1
- package/dist/assets/chunk-JQJVKLGR-BApWxqMA.js +0 -156
- package/dist/assets/chunk-NSK5VX7P-BBTxIP6Z.js +0 -2
- package/dist/assets/chunk-QR6OTTB3-DJcD7xr-.js +0 -62
- package/dist/assets/chunk-RYQCIY6F-CnMsR_qh.js +0 -1
- package/dist/assets/chunk-UBXNYLIW-B7z1tp3V.js +0 -1
- package/dist/assets/chunk-W5SLKNZC-BnMc5i0B.js +0 -1
- package/dist/assets/chunk-WRU74C26-MrzCPX2E.js +0 -70
- package/dist/assets/chunk-XXDRQBXY-NKBlW2Dm.js +0 -1
- package/dist/assets/chunk-ZIRB5QZD-O39ZBUk3.js +0 -32
- package/dist/assets/classDiagram-JCYQIIEL-C4ADaKBz.js +0 -1
- package/dist/assets/classDiagram-v2-OCEON4UE-C4ADaKBz.js +0 -1
- package/dist/assets/createDerive-xZXxMz1g.js +0 -1
- package/dist/assets/cynefin-VYW2F7L2-exAq6djZ.js +0 -1
- package/dist/assets/cytoscape.esm-B-NFISlW.js +0 -321
- package/dist/assets/dagre-Buvkdvvj.js +0 -1
- package/dist/assets/dagre-VZM6K2ZE-B5E8-xuM.js +0 -4
- package/dist/assets/dist-jor1XT9f.js +0 -5
- package/dist/assets/erDiagram-JOGREHBK-BU4b8mUv.js +0 -85
- package/dist/assets/eventmodeling-45OFAUF4-DVTVIsGT.js +0 -1
- package/dist/assets/flowDiagram-UKHOOZJN-BDHHPApJ.js +0 -1
- package/dist/assets/framework-LCCQTTcs.js +0 -47
- package/dist/assets/getIcon-Bnm_i39L.js +0 -1
- package/dist/assets/gitGraph-TEB2WS4Q-DizXBl0d.js +0 -1
- package/dist/assets/i18n-DGSduXFT.js +0 -9
- package/dist/assets/index-ZtYnn1PE.css +0 -2
- package/dist/assets/index-mpVXni3j.js +0 -2
- package/dist/assets/info-DKCQHKI2-CfAGND28.js +0 -1
- package/dist/assets/infrastructure-CerjT_c2.js +0 -3
- package/dist/assets/map-BaFkSB1l.js +0 -1
- package/dist/assets/mermaid-GHXKKRXX-DQTMu5TJ.js +0 -1
- package/dist/assets/mermaid.core-BwiBFu_S.js +0 -10
- package/dist/assets/metadata-admin-C_DEFfDE.js +0 -25
- package/dist/assets/packet-7NZHBO7P-DeymwuCa.js +0 -1
- package/dist/assets/pie-RZYD4A2V-C2S5u8nr.js +0 -1
- package/dist/assets/plugin-calendar-ClpbcK3u.js +0 -1
- package/dist/assets/plugin-charts-Cq0LpABN.js +0 -7
- package/dist/assets/plugin-chatbot-Cq7rZtnW.js +0 -120
- package/dist/assets/plugin-dashboard-C8Ohdrxi.js +0 -6
- package/dist/assets/plugin-form-B7CBtYvZ.js +0 -1
- package/dist/assets/plugin-gantt-ChkG9_UG.js +0 -64
- package/dist/assets/plugin-grid-D49BBhCX.js +0 -8
- package/dist/assets/plugin-kanban-BsTsRjoP.js +0 -1
- package/dist/assets/plugin-map-CQAe4Yh6.js +0 -1
- package/dist/assets/plugin-report-01bEGHuR.js +0 -59
- package/dist/assets/plugin-timeline-Dw4Lj2Rz.js +0 -1
- package/dist/assets/plugin-tree-DW0XC55y.js +0 -1
- package/dist/assets/plugin-view-B9yCVdSX.js +0 -1
- package/dist/assets/plugins-views-BaBStVok.js +0 -4
- package/dist/assets/radar-I7S5WNFK-DzcfTC8k.js +0 -1
- package/dist/assets/railroad-3IZDKUUU-DT2-gzup.js +0 -1
- package/dist/assets/railroad-abnf-AHOZXSZD-BvCkhVdg.js +0 -1
- package/dist/assets/railroad-ebnf-EBAXGLYW-rvjxEE4k.js +0 -1
- package/dist/assets/railroad-peg-LSFZ7HO6-BIzZt1tD.js +0 -1
- package/dist/assets/skeletons-DVwGbFUS.js +0 -1
- package/dist/assets/src-BA9h8a8o.js +0 -1
- package/dist/assets/src-Ctj_ivDh.js +0 -19
- package/dist/assets/stateDiagram-v2-UEYNNEHI-DaTg8C5m.js +0 -1
- package/dist/assets/swimlanes-SLNWSIFB-wrx1JN6o.js +0 -1
- package/dist/assets/swimlanesDiagram-ULZ7WXOC-Bqz9GVuM.js +0 -8
- package/dist/assets/treeView-QDETBFTQ-DKZwqlNb.js +0 -1
- package/dist/assets/treemap-6X3UGDF4-Bqsldamv.js +0 -1
- package/dist/assets/ui-components-3mb69z8L.js +0 -42
- package/dist/assets/ui-layout-DpuFph25.js +0 -1
- package/dist/assets/use-book-data-BZg_051K.js +0 -1
- package/dist/assets/useActionModal-Z2yDiihK.js +0 -1
- package/dist/assets/usePackageL10n-Cy-u65Zo.js +0 -1
- package/dist/assets/useSettingsLabel-CvZKl8CQ.js +0 -1
- package/dist/assets/vendor-i18n-Cpia2wlg.js +0 -1
- package/dist/assets/vendor-objectstack-DGpW4oR-.js +0 -158
- package/dist/assets/wardley-OPB4EBWU-C_U_bbc2.js +0 -1
- /package/dist/assets/{sizeCapture-X5ZJPWSS-B0uUizjq.js → sizeCapture-INFHLROL-B0uUizjq.js} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{a as n,b as r,h as i,r as a}from"./vendor-react-CsWFRkED.js";import{n as o,t as s}from"./infrastructure-CIpDEFyQ.js";import{Kt as c,Ot as l,Pn as u,ct as d,jn as f,st as p,wt as m}from"./vendor-objectstack-BeKUVjuj.js";import{f as h,g,h as _,m as v,p as y}from"./data-adapter-DL25qpAe.js";import{$r as b,Ar as x,At as S,Bt as C,Ct as w,D as T,Er as E,Et as D,Fr as O,Gt as ee,H as te,Hr as ne,Ht as re,I as k,Ir as A,It as ie,Jn as ae,Jr as j,Kt as M,Lr as N,Mr as P,Mt as oe,Nr as F,O as I,Pr as se,Pt as L,Qr as R,Rr as ce,Sr as le,Tt as ue,U as de,Ur as fe,Ut as pe,Vr as me,Vt as he,W as z,Y as ge,br as B,ei as _e,g as ve,gr as V,h as ye,ht as be,ir as H,j as xe,jr as Se,jt as U,kt as Ce,l as we,mt as Te,nr as Ee,or as De,p as Oe,qr as ke,rr as W,s as Ae,tr as G,u as je,ut as Me,wt as K,y as Ne,zr as q,zt as Pe}from"./framework-BfSv4Kb0.js";import{a as Fe,d as Ie,i as Le,m as Re,n as ze,p as Be,t as Ve,u as He,y as Ue}from"./i18n-locales-Bz4c8KXc.js";import{A as We,Aa as Ge,B as Ke,Ba as qe,Bc as Je,Br as Ye,Bt as Xe,Cs as Ze,Ct as Qe,D as J,Da as $e,Dc as et,Dn as tt,Do as nt,En as rt,Er as it,F as at,Fn as ot,Fo as st,Fr as ct,Fs as lt,Gc as ut,Go as dt,Gr as ft,H as pt,Hi as mt,Hr as ht,Ht as gt,I as _t,Ia as vt,Ii as yt,In as bt,Ir as xt,Jr as St,Js as Ct,K as wt,Kr as Tt,L as Et,Lo as Dt,Lr as Ot,Lt as kt,M as At,Ma as jt,Mr as Mt,N as Nt,Nn as Pt,On as Ft,Or as It,Os as Lt,P as Rt,Pa as zt,Pn as Bt,Pr as Vt,Qc as Ht,R as Ut,Ri as Wt,Ro as Gt,Rr as Kt,Rs as qt,S as Jt,Si as Yt,Sn as Xt,Ss as Zt,St as Qt,Tc as $t,Tn as en,Tr as tn,Tt as nn,U as rn,Uc as an,Ur as on,Us as sn,V as cn,Va as ln,Vc as un,Vr as dn,Vt as fn,W as pn,Wi as mn,Wr as hn,Xc as gn,Xr as Y,Yc as _n,Zc as vn,Zr as yn,_n as bn,_o as xn,aa as Sn,at as Cn,bo as wn,bs as Tn,ca as En,da as Dn,dt as On,ea as kn,ec as An,ei as jn,f as Mn,fn as Nn,fo as Pn,g as Fn,gc as In,gn as Ln,hc as Rn,hi as zn,hn as Bn,i as Vn,ia as Hn,il as X,it as Un,j as Wn,jr as Gn,jt as Kn,k as qn,kr as Jn,la as Yn,lt as Xn,mc as Zn,mn as Qn,mo as $n,n as er,ni as tr,ot as nr,pc as rr,pn as ir,q as ar,qa as or,qi as sr,qo as cr,qr as lr,ra as ur,rl as dr,so as fr,ss as pr,t as mr,ta as hr,ua as gr,us as _r,v as vr,vn as yr,vo as br,wa as xr,wc as Sr,wn as Cr,wr,ws as Tr,wt as Er,x as Dr,xn as Or,xs as kr,xt as Ar,y as jr,yi as Mr,yn as Nr,yo as Pr,z as Fr,zc as Ir,zo as Lr,zr as Rr,zt as zr}from"./ui-components-D2lrjG-t.js";import{s as Br}from"./plugin-grid-kkbz4uec.js";var Z=e(r(),1),Q=a(),Vr={grid:(0,Q.jsx)(cr,{className:`h-4 w-4`}),kanban:(0,Q.jsx)(nt,{className:`h-4 w-4`}),gallery:(0,Q.jsx)(Gt,{className:`h-4 w-4`}),calendar:(0,Q.jsx)(et,{className:`h-4 w-4`}),timeline:(0,Q.jsx)(dr,{className:`h-4 w-4`}),gantt:(0,Q.jsx)(Sr,{className:`h-4 w-4`}),map:(0,Q.jsx)(Pn,{className:`h-4 w-4`}),chart:(0,Q.jsx)($t,{className:`h-4 w-4`}),tree:(0,Q.jsx)(wn,{className:`h-4 w-4`})},Hr={grid:`console.objectView.viewTypeGrid`,kanban:`console.objectView.viewTypeKanban`,gallery:`console.objectView.viewTypeGallery`,calendar:`console.objectView.viewTypeCalendar`,timeline:`console.objectView.viewTypeTimeline`,gantt:`console.objectView.viewTypeGantt`,map:`console.objectView.viewTypeMap`,chart:`console.objectView.viewTypeChart`,tree:`console.objectView.viewTypeTree`},Ur=Be({"console.objectView.viewTypeGrid":`Grid`,"console.objectView.viewTypeKanban":`Kanban`,"console.objectView.viewTypeGallery":`Gallery`,"console.objectView.viewTypeCalendar":`Calendar`,"console.objectView.viewTypeTimeline":`Timeline`,"console.objectView.viewTypeGantt":`Gantt`,"console.objectView.viewTypeMap":`Map`,"console.objectView.viewTypeChart":`Chart`,"console.objectView.viewTypeTree":`Tree`},`console.objectView.viewTypeGrid`);function Wr(){let{t:e}=Ur();return Z.useMemo(()=>{let t={};for(let[n,r]of Object.entries(Hr))t[n]=e(r);return t},[e])}var Gr=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:n,className:r,animated:i=!0})=>{let[a,o]=Z.useState(!1),s=Wr(),c=Z.useCallback(t=>{o(!1),t!==e&&(i&&typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>n(t)):n(t))},[i,e,n]);return t.length>=2&&t.length<=4?(0,Q.jsx)(`div`,{role:`tablist`,"data-testid":`view-switcher-segmented`,className:X(`inline-flex items-center gap-0.5 rounded-lg bg-muted p-0.5 oui-view-switcher`,r),children:t.map(t=>{let n=t===e;return(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,"aria-label":s[t],title:s[t],"data-state":n?`on`:`off`,onClick:()=>c(t),className:X(`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-[7px] text-xs font-medium transition-all duration-150`,n?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[Vr[t],(0,Q.jsx)(`span`,{className:`hidden sm:inline-block`,children:s[t]})]},t)})}):(0,Q.jsxs)(Pt,{open:a,onOpenChange:o,children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`view-switcher-dropdown`,"aria-label":s[e],className:X(`inline-flex items-center gap-1.5 h-7 px-2 rounded-md text-xs font-medium transition-colors oui-view-switcher`,a?`text-foreground bg-muted`:`text-muted-foreground hover:text-foreground`,r),children:[Vr[e],(0,Q.jsx)(`span`,{className:`hidden sm:inline-block`,children:s[e]}),(0,Q.jsx)(Rn,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(Bt,{align:`end`,className:`w-44 p-1`,children:t.map(t=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(t),"data-state":t===e?`on`:`off`,className:X(`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs transition-colors hover:bg-muted`,t===e?`text-foreground font-medium`:`text-muted-foreground`),children:[Vr[t],(0,Q.jsx)(`span`,{className:`flex-1 text-left`,children:s[t]}),t===e&&(0,Q.jsx)(In,{className:`h-3.5 w-3.5`})]},t))})]})};function Kr({title:e,badge:t,onClear:n,clearLabel:r,defaultOpen:i=!0,children:a}){let[o,s]=Z.useState(i);return(0,Q.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 text-xs font-medium text-foreground/80 hover:text-foreground`,children:[(0,Q.jsx)(Rn,{className:X(`h-3.5 w-3.5 transition-transform`,!o&&`-rotate-90`)}),e,typeof t==`number`&&t>0&&(0,Q.jsx)(`span`,{className:`ml-1 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 px-1 text-[10px] text-primary tabular-nums`,children:t})]}),n&&(0,Q.jsx)(`button`,{type:`button`,onClick:n,className:`text-[11px] text-muted-foreground hover:text-foreground`,children:r})]}),o&&(0,Q.jsx)(`div`,{className:`px-3 pb-3`,children:a})]})}function qr(e){let{t,allFields:n,showGroup:r,groupingConfig:i,setGroupingConfig:a,showColor:o,rowColorConfig:s,setRowColorConfig:c,showDensity:l,density:u,showHideFields:d,hiddenFields:f,updateHiddenFields:p,showInlineEdit:m,inlineEdit:h,setInlineEdit:g}=e,[_,v]=Z.useState(!1),y=[!!i?.fields?.length,!!s?.field,u&&u.mode!==`compact`,(f?.size??0)>0,!!h].filter(Boolean).length,b=u?.mode===`compact`?En:u?.mode===`comfortable`?Yn:gr,x=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,Q.jsxs)(Pt,{open:_,onOpenChange:v,children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,"aria-label":x,title:x,className:X(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,y>0&&`text-foreground font-medium`),"data-testid":`view-settings-trigger`,children:[(0,Q.jsx)(ur,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x}),y>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:y})]})}),(0,Q.jsxs)(Bt,{align:`end`,className:`w-80 p-0`,"data-testid":`view-settings-content`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-2 border-b`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold`,children:x}),(0,Q.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`list.viewSettingsHint`,{defaultValue:`Grouping, color, density, and visible fields. Applies to everyone who uses this view.`})})]}),r&&a&&(0,Q.jsx)(Kr,{title:t(`list.group`,{defaultValue:`Group`}),badge:i?.fields?.length||0,onClear:i?()=>a(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),children:(0,Q.jsx)(Xn,{value:i,fieldOptions:n.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:t(`list.addGroup`,`Add group field`),collapseTitle:t(`list.collapsedByDefault`,`Collapsed by default`),removeTitle:t(`list.removeGroup`,`Remove`)},onChange:e=>a(e)})}),o&&c&&(0,Q.jsxs)(Kr,{title:t(`list.rowColor`,{defaultValue:`Row Color`}),onClear:s?()=>c(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),defaultOpen:!!s,children:[(0,Q.jsx)(`label`,{className:`block text-[11px] text-muted-foreground mb-1`,children:t(`list.colorByField`,{defaultValue:`Color by field`})}),(0,Q.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:s?.field||``,onChange:e=>{let t=e.target.value;c(t?{field:t,colors:s?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,Q.jsx)(`option`,{value:``,children:t(`list.none`,{defaultValue:`None`})}),n.map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]}),l&&u&&(0,Q.jsx)(Kr,{title:t(`grid.toolbar.densityMode`,{defaultValue:`Density`}),defaultOpen:u.mode!==`compact`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:u.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,Q.jsx)(b,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`text-xs`,children:u.mode===`compact`?t(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):u.mode===`comfortable`?t(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):t(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`})})]}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`grid.toolbar.densityCycleShortHint`,{defaultValue:`Click to cycle`})})]})}),m&&g&&(0,Q.jsx)(Kr,{title:t(`list.recordEditingTitle`,{defaultValue:`Record editing`}),defaultOpen:!!h,children:(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!!h,onChange:()=>g(!h),className:`rounded border-input`,"data-testid":`view-settings-inline-edit`}),(0,Q.jsx)(`span`,{children:t(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`})})]})}),d&&f&&p&&(0,Q.jsx)(Kr,{title:t(`list.hideFieldsTitle`,{defaultValue:`Hide Fields`}),badge:f.size,onClear:f.size>0?()=>p(new Set):void 0,clearLabel:t(`list.showAll`,{defaultValue:`Show all`}),defaultOpen:f.size>0,children:(0,Q.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-0.5`,children:n.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!f.has(e.name),onChange:()=>{let t=new Set(f);t.has(e.name)?t.delete(e.name):t.add(e.name),p(t)},className:`rounded border-input`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.name))})})]})]})}function Jr(){let{t:e}=Ue(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}var Yr=new Set([`lookup`,`master_detail`,`user`]),Xr={select:`single-choice`,"multi-select":`multi-choice`,boolean:`multi-choice`,"date-range":`range`,text:`text`};function Zr(e){return(e||[]).filter(e=>e&&(e.id||e.name)).map(e=>({id:e.id??e.name,label:typeof e.label==`string`?e.label:e.label?.toString?.()??e.id??e.name,filters:Array.isArray(e.filters)?e.filters:Array.isArray(e.filter)?e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>[e.field,f(e.operator),e.value]):[],default:e.default??e.isDefault}))}function Qr({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){switch(e.element){case`dropdown`:return(0,Q.jsx)(ei,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s});case`tabs`:return(0,Q.jsx)(ti,{tabs:Zr(e.tabs||[]),showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:a,initialTab:typeof o?._tab?.[0]==`string`?o._tab[0]:void 0,onSelectionsChange:s});case`toggle`:return(0,Q.jsx)(ni,{fields:e.fields||[],onFilterChange:r,className:a});default:return null}}function $r(e,t,n,r){return e.map(e=>{let i=e.options?[...e.options]:[],a=e.type,o,s,c,l;if(t?.fields){let n=Array.isArray(t.fields)?t.fields.find(t=>t.name===e.field):t.fields[e.field];n&&(a||=n.type,l=n.label,o=n.reference,s=n.display_field??n.reference_field,c=n.id_field,i.length===0&&n.options&&(i=Array.isArray(n.options)?n.options.map(e=>({label:e.label??String(e.value??e),value:e.value??e,color:e.color})):Object.entries(n.options).map(([e,t])=>({label:t?.label||e,value:e,color:t?.color}))))}i.length===0&&a===`boolean`&&(i=[{label:`True`,value:!0},{label:`False`,value:!1}]),e.showCount&&n.length>0&&(i=i.map(t=>({...t,count:n.filter(n=>n[e.field]===t.value).length})));let u=e.label??l;if(r?.objectName){i=r.translateOptions(r.objectName,e.field,i);let t=e.label||l,n=r.fieldLabel(r.objectName,e.field,t||e.field);u=n===e.field&&t?t:n}return{...e,label:u,type:a,options:i,referenceTo:o,displayField:s,idField:c}})}function ei({fields:e,objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){let{fieldLabel:c,translateOptions:l}=Ie(),u=Jr(),d=t?.name,f=Z.useMemo(()=>new Map(e.map(e=>[e.field,Xr[e.type??``]])),[e]),[p,m]=Z.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues);let n=o?.[e.field];n&&n.length>0&&(t[e.field]=n),f.get(e.field)===`single-choice`&&(t[e.field]?.length??0)>1&&(t[e.field]=t[e.field].slice(0,1))}),t}),h=Z.useRef({}),g=Z.useMemo(()=>$r(e,t,n,{objectName:d,fieldLabel:c,translateOptions:l}).map(e=>{if(!e.showCount)return e;if((p[e.field]||[]).length===0)return h.current[e.field]=new Map(e.options.map(e=>[String(e.value),e.count??0])),e;let t=h.current[e.field];return t?{...e,options:e.options.map(e=>({...e,count:t.get(String(e.value))??e.count}))}:e}),[e,t,n,d,c,l,p]),_=Z.useCallback(e=>{r(Object.entries(e).flatMap(([e,t])=>{if(t.length===0)return[];switch(f.get(e)){case`range`:{let[n,r]=t,i=[];return n!==void 0&&n!==``&&i.push([e,`>=`,n]),r!==void 0&&r!==``&&i.push([e,`<=`,r]),i}case`text`:{let n=String(t[0]??``).trim();return n?[[e,`contains`,n]]:[]}default:return[[e,`in`,t]]}}))},[r,f]),v=(e,t)=>{let n={...p,[e]:t};m(n),_(n),s?.(n)};Z.useEffect(()=>{let e=p,t={},n=!1;for(let[r,i]of Object.entries(e)){let e=g.find(e=>e.field===r),a=i.map(t=>{if(!e||typeof t!=`string`)return t;let n=e.options.find(e=>String(e.value)===t);return n&&n.value!==t?n.value:e.type===`boolean`&&(t===`true`||t===`false`)?t===`true`:t});t[r]=a,a.some((e,t)=>e!==i[t])&&(n=!0)}n&&(m(t),e=t),Object.values(e).some(e=>e.length>0)&&_(e)},[]);let y=i!==void 0&&i<g.length?g.slice(0,i):g,b=i!==void 0&&i<g.length?g.slice(i):[],x=e=>{let t=p[e.field]||[],n=f.get(e.field),r=t.filter(e=>e!==``&&e!=null).length,i=r>0,a=n===`single-choice`,o=F(e.type);o&&se(e.type);let s=!o&&Yr.has(e.type||``)&&e.options.length===0&&(e.referenceTo||e.type===`user`),c=s?`w-72`:`w-56`;return(0,Q.jsxs)(Pt,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`filter-badge-${e.field}`,className:X(`inline-flex items-center gap-1 h-7 px-2 text-xs transition-colors shrink-0 rounded-md`,i?`text-foreground font-medium`:`text-muted-foreground hover:text-foreground`),children:[(0,Q.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),i&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:r}),i?(0,Q.jsx)(tr,{className:`h-3 w-3 opacity-60 hover:opacity-100`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),v(e.field,[])}}):(0,Q.jsx)(Rn,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(Bt,{align:`start`,className:X(c,`p-2`),children:s?(0,Q.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,Q.jsx)(Qe,{field:{value:e.field,label:e.label||e.field,type:e.type,referenceTo:e.referenceTo,displayField:e.displayField,idField:e.idField},value:t,multiple:!0,onChange:t=>{let n=Array.isArray(t)?t:t==null||t===``?[]:[t];v(e.field,n)}})}):n===`range`?(0,Q.jsx)(`div`,{className:`space-y-2 p-1`,"data-testid":`filter-range-${e.field}`,children:[0,1].map(n=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`w-8 shrink-0`,children:n===0?`From`:`To`}),(0,Q.jsx)(`input`,{type:`date`,"data-testid":`filter-range-${e.field}-${n===0?`from`:`to`}`,value:String(t[n]??``),onChange:r=>{let i=[String(t[0]??``),String(t[1]??``)];i[n]=r.target.value,v(e.field,i[0]===``&&i[1]===``?[]:i)},className:`h-7 flex-1 rounded border border-input bg-background px-2 text-xs text-foreground`})]},n))}):n===`text`?(0,Q.jsx)(`input`,{type:`search`,"data-testid":`filter-text-${e.field}`,defaultValue:String(t[0]??``),placeholder:e.label||e.field,onBlur:t=>{let n=t.target.value.trim();v(e.field,n?[n]:[])},onKeyDown:t=>{if(t.key===`Enter`){let n=t.target.value.trim();v(e.field,n?[n]:[])}},className:`h-8 w-full rounded border border-input bg-background px-2 text-xs text-foreground`}):(0,Q.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-0.5`,"data-testid":`filter-options-${e.field}`,children:e.options.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-muted-foreground`,children:`No options`}):e.options.map(n=>(0,Q.jsxs)(`label`,{className:X(`flex items-center gap-2 text-sm py-1.5 px-2 rounded cursor-pointer`,t.includes(n.value)?`bg-primary/5 text-primary`:`hover:bg-muted`),children:[(0,Q.jsx)(`input`,{type:a?`radio`:`checkbox`,name:a?`user-filter-${e.field}`:void 0,checked:t.includes(n.value),onChange:()=>{let r=a?[n.value]:t.includes(n.value)?t.filter(e=>e!==n.value):[...t,n.value];v(e.field,r)},className:a?`border-input`:`rounded border-input`}),n.color&&(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,Q.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,Q.jsx)(`div`,{className:X(`flex items-center gap-0.5 overflow-x-auto`,a),"data-testid":`user-filters-dropdown`,children:g.length===0?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,Q.jsxs)(Q.Fragment,{children:[y.map(x),b.length>0&&(0,Q.jsxs)(Pt,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`user-filters-more`,className:`inline-flex items-center gap-1 h-7 px-2 text-xs text-muted-foreground hover:text-foreground transition-colors shrink-0 rounded-md`,children:[(0,Q.jsx)(`span`,{children:u}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:b.length}),(0,Q.jsx)(Rn,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(Bt,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,Q.jsx)(`div`,{className:`space-y-1`,children:b.map(x)})})]})]})})}function ti({tabs:e,showAllRecords:t,allowAddTab:n,onFilterChange:r,className:i,initialTab:a,onSelectionsChange:o}){let[s,c]=Z.useState(()=>a&&(a===`__all__`||e.some(e=>e.id===a))?a:e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),[l,u]=Z.useState([]),[d,f]=Z.useState(!1),[p,m]=Z.useState(``),h=Z.useCallback(t=>{if(t===`__all__`)return[];let n=e.find(e=>e.id===t);return n?n.filters||[]:l.find(e=>e.id===t)?.filters||[]},[e,l]),g=Z.useCallback(e=>{c(e),r(h(e)),o?.({_tab:[e]})},[h,r,o]),_=Z.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]),v=Z.useCallback(()=>{let t=p.trim();if(!t)return;let n=new Set([...e.map(e=>e.id??e.name??``),...l.map(e=>e.id)]),i=l.length+1;for(;n.has(`__session_${i}__`);)i+=1;let a=`__session_${i}__`,d=h(s).map(e=>Array.isArray(e)?[...e]:e);u(e=>[...e,{id:a,label:t,filters:d}]),c(a),m(``),f(!1),r(d),o?.({_tab:[a]})},[p,e,l,h,s,r,o]),y=Z.useCallback(n=>{if(u(e=>e.filter(e=>e.id!==n)),s!==n)return;let r=e.find(e=>e.default);g(r?.id||(t?`__all__`:e[0]?.id||``))},[s,e,t,g]);return Z.useEffect(()=>{if(s&&s!==`__all__`){let t=e.find(e=>e.id===s);t&&r(t.filters||[])}},[]),(0,Q.jsxs)(`div`,{className:X(`flex items-center gap-0.5 overflow-x-auto`,i),"data-testid":`user-filters-tabs`,children:[_.map(e=>{let t=e.id??e.name??``;return(0,Q.jsx)(`button`,{type:`button`,"data-testid":`filter-tab-${t}`,onClick:()=>g(t),className:X(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,s===t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},t)}),l.map(e=>{let t=s===e.id;return(0,Q.jsxs)(`span`,{className:X(`inline-flex items-center h-7 rounded-md transition-colors shrink-0`,t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),children:[(0,Q.jsx)(`button`,{type:`button`,"data-testid":`filter-tab-${e.id}`,onClick:()=>g(e.id),className:`inline-flex items-center h-7 pl-3 pr-1 text-xs font-medium rounded-l-md`,children:e.label}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`filter-tab-remove-${e.id}`,onClick:()=>y(e.id),title:`Remove tab`,"aria-label":`Remove tab ${e.label}`,className:`inline-flex items-center h-7 pl-0.5 pr-2 rounded-r-md opacity-60 hover:opacity-100`,children:(0,Q.jsx)(tr,{className:`h-3 w-3`})})]},e.id)}),n&&(0,Q.jsxs)(Pt,{open:d,onOpenChange:e=>{f(e),e||m(``)},children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex items-center justify-center h-7 w-7 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted shrink-0`,"data-testid":`filter-tab-add`,title:`Add filter tab`,children:(0,Q.jsx)($e,{className:`h-3.5 w-3.5`})})}),(0,Q.jsxs)(Bt,{align:`start`,className:`w-64 p-2 space-y-2`,"data-testid":`filter-tab-add-content`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Name this tab. It keeps the filters applied right now, and lives in this session only.`}),(0,Q.jsx)(bt,{autoFocus:!0,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),v())},placeholder:`Tab name`,className:`h-7 text-xs`,"data-testid":`filter-tab-add-input`}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(Y,{size:`sm`,className:`h-7 px-2 text-xs`,disabled:!p.trim(),"data-testid":`filter-tab-add-confirm`,onClick:v,children:`Add tab`})})]})]})]})}function ni({fields:e,onFilterChange:t,className:n}){let[r,i]=Z.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),a=Z.useCallback(n=>{t(Array.from(n).map(t=>{let n=e.find(e=>e.field===t);return n?.defaultValues?[t,`in`,n.defaultValues]:[t,`!=`,null]}))},[e,t]),o=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),a(n),n})};return Z.useEffect(()=>{r.size>0&&a(r)},[]),(0,Q.jsx)(`div`,{className:X(`flex items-center gap-1 overflow-x-auto`,n),"data-testid":`user-filters-toggle`,children:e.map(e=>{let t=r.has(e.field);return(0,Q.jsx)(Y,{variant:t?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs shrink-0`,"data-testid":`filter-toggle-${e.field}`,onClick:()=>o(e.field),children:e.label||e.field},e.field)})})}var ri=[`latitudeField`,`longitudeField`,`locationField`,`titleField`,`descriptionField`,`zoom`,`center`];function ii(e){if(!e||typeof e!=`object`)return{};let t=e;return Object.fromEntries(ri.filter(e=>e in t).map(e=>[e,t[e]]))}function ai(e){return{...ii(e.options?.map),...ii(e.map)}}function oi(e){switch(e.toLowerCase().replace(/[_\s]/g,``)){case`equals`:case`eq`:return`=`;case`notequals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;case`icontains`:return`icontains`;case`notcontains`:return`notcontains`;case`startswith`:return`startswith`;case`endswith`:return`endswith`;case`greaterthan`:case`gt`:return`>`;case`greaterorequal`:case`greaterthanorequal`:case`gte`:return`>=`;case`lessthan`:case`lt`:return`<`;case`lessorequal`:case`lessthanorequal`:case`lte`:return`<=`;case`in`:return`in`;case`notin`:case`nin`:return`nin`;case`before`:return`<`;case`after`:return`>`;case`between`:return`between`;case`isnull`:return`isnull`;case`isnotnull`:return`isnotnull`;default:return e}}var si=[],ci=new Set([`nin`,`not_in`,`notIn`,`notin`,`not in`]);function li(e){if(!Array.isArray(e)||e.length<3)return e;let[t,n,r]=e;return typeof t==`string`&&(t===`and`||t===`or`)?[t,...e.slice(1).map(e=>Array.isArray(e)?li(e):e)]:n===`in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`=`,r[0]]:[`or`,...r.map(e=>[t,`=`,e])]:ci.has(n)&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`!=`,r[0]]:[`and`,...r.map(e=>[t,`!=`,e])]:e}function ui(e){let t=typeof e==`string`?[e]:Array.isArray(e)?e:[],n=[];for(let e of t)if(typeof e==`string`){let t=e.trim().split(/\s+/);if(!t[0])continue;n.push({id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`})}else e&&typeof e==`object`&&typeof e.field==`string`&&n.push({id:crypto.randomUUID(),field:e.field,order:e.order||`asc`});return n}function di(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function fi(e){switch(e){case`bottom`:return{top:!1,bottom:!0};case`both`:return{top:!0,bottom:!0};default:return{top:!0,bottom:!1}}}function pi(e){let t=[e?.timeline,e?.options?.timeline,e?.calendar,e?.options?.calendar],n=e=>{for(let n of t){if(!n)continue;let t=e(n);if(typeof t==`string`&&t)return t}};return{startDateField:n(e=>e.startDateField??e.dateField),endDateField:n(e=>e.endDateField),titleField:n(e=>e.titleField)}}function mi(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?li(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function hi(e,t,n){let r=gi(t);return _(e,r.length>0?r:void 0,...mi(n))}function gi(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=mi(e.conditions.filter(e=>Er.has(e.operator)?!0:nn(e.operator,e.value)).map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:Er.has(e.operator)?[e.field,oi(e.operator),null]:[e.field,oi(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}var _i=Be({"list.recordCount":`{{count}} records`,"list.recordCountOne":`{{count}} record`,"list.noItems":`No items found`,"list.noItemsMessage":`There are no records to display. Try adjusting your filters or adding new data.`,"list.firstRunTitle":`Nothing here yet`,"list.firstRunMessage":`Create your first record to get started.`,"list.noMatches":`No matching records`,"list.noMatchesMessage":`No records match your current filters or search. Try adjusting or clearing them.`,"list.loading":`Loading records…`,"list.loadErrorTitle":`Couldn’t load records`,"list.loadErrorMessage":`Something went wrong while loading this data. Check your connection and try again.`,"list.loadErrorForbiddenTitle":`You don’t have access`,"list.loadErrorForbiddenMessage":`You don’t have permission to view these records. Contact your administrator if you think you should have access.`,"list.loadErrorUnauthorizedTitle":`Sign in required`,"list.loadErrorUnauthorizedMessage":`Your session has expired or you are signed out. Sign in again to view these records.`,"list.loadErrorRejectedTitle":`This view’s query was rejected`,"list.loadErrorRejectedMessage":`The server could not process this view’s filter or query options. Clearing the filters usually fixes it; if the view is saved this way, an administrator needs to correct it.`,"list.loadErrorApiDisabledTitle":`This object isn’t available through the API`,"list.loadErrorApiDisabledMessage":`This page can’t load its records because the object is not exposed through the API. That is a setting on the object itself, not a permission — an administrator has to enable API access for it before this page can work.`,"list.retry":`Retry`,"list.search":`Search`,"table.search":`Search…`,"list.filter":`Filter`,"list.filterRecords":`Filter Records`,"list.sort":`Sort`,"list.sortRecords":`Sort Records`,"list.sortByIdSuffix":`(by ID)`,"list.sortRelationalHint":`Columns that link to another record are not listed: they can only be sorted by the stored ID, not by the name shown in the cell. To sort by that name, denormalize it onto this object as a stored field, written when the source changes, and sort by that. Not a formula field: it is virtual, so no column is stored for it and the server refuses to sort by one.`,"list.resetSortToDefault":`Reset to view default`,"list.group":`Group`,"list.groupBy":`Group By`,"list.export":`Export`,"list.exportAs":`Export as {{format}}`,"list.color":`Color`,"list.rowColor":`Row Color`,"list.colorByField":`Color by field`,"list.clear":`Clear`,"list.none":`None`,"list.hideFields":`Hide fields`,"list.showAll":`Show all`,"list.pullToRefresh":`Pull to refresh`,"list.refresh":`Refresh`,"list.refreshing":`Refreshing…`,"list.dataLimitReached":`Showing first {{limit}} records. More data may be available.`,"list.addRecord":`Add record`,"list.tabs":`Tabs`,"list.allRecords":`All Records`,"list.share":`Share`,"list.print":`Print`,"common.printDialogHint":`Opens your browser’s print dialog (not a PDF export)`,"list.hideFieldsTitle":`Hide Fields`,"table.rowsPerPage":`Rows per page`,"grid.toolbar.densityMode":`Density`,"grid.toolbar.densityCompact":`Compact`,"grid.toolbar.densityComfortable":`Comfortable`,"grid.toolbar.densitySpacious":`Spacious`,"grid.toolbar.densityCycleHint":`{{label}} (click to cycle)`,"grid.toolbar.densityCycleShortHint":`Click to cycle`,"list.viewSettings":`View settings`,"list.viewSettingsHint":`Grouping, color, density, and visible fields. Applies to everyone who uses this view.`,"detail.recordDetail":`Record Detail`,"detail.recordDetailWithLabel":`{{label}} Detail`},`list.recordCount`);function vi(){let{fieldLabel:e,actionLabel:t,objectLabel:n}=He();return{fieldLabel:e,actionLabel:t,objectLabel:n}}var yi=Z.forwardRef(({schema:e,className:t,onViewChange:n,onFilterChange:r,onSortChange:i,onSearchChange:a,onHiddenFieldsChange:s,onInlineEditChange:c,onColumnStateChange:l,onRowClick:d,showViewSwitcher:f,userFilterSelections:p,onUserFilterSelectionsChange:m,initialFilters:g,initialSearchTerm:_,...b},S)=>{let w=f??e?.showViewSwitcher??!1,{t:T}=_i(),{fieldLabel:D,actionLabel:te,objectLabel:k}=vi(),{translateOptions:ie}=Ie(),j=Ve(),N=Z.useMemo(()=>Pe(e),[e]),P=Z.useCallback((e,t)=>N.objectName?D(N.objectName,e,t):t,[N.objectName,D]),oe=Z.useCallback(e=>{let t=di(e);return N.objectName&&typeof te==`function`?te(N.objectName,e,t):t},[N.objectName,te]),F=Z.useMemo(()=>{let e=N.userActions,t=N.addRecord?.enabled===!0&&e?.addRecordForm!==!1,n=fi(N.addRecord?.position);return{showSearch:e?.search!==!1,showSort:e?.sort!==!1,showFilters:e?.filter!==!1,showRefresh:e?.refresh!==!1,showDensity:e?.rowHeight!==!1,showGroup:e?.group!==!1,showHideFields:e?.hideFields===!0,showColor:e?.rowColor===!0,compactToolbar:N.compactToolbar===!0,showAddRecord:t,showAddRecordTop:t&&n.top,showAddRecordBottom:t&&n.bottom}},[N.userActions,N.compactToolbar,N.addRecord]),[I,se]=Z.useState(N.viewType),[L,R]=Z.useState(()=>_??``),[ce,le]=Z.useState(!1),[de,fe]=Z.useState(!1),[z,ge]=Z.useState(()=>ui(N.sort)),B=Z.useMemo(()=>JSON.stringify(N.sort||[]),[N.sort]);Z.useEffect(()=>{ge(ui(N.sort))},[B]);let _e=Z.useMemo(()=>ui(N.sort),[B]),ve=Z.useMemo(()=>z.length!==_e.length||z.some((e,t)=>e.field!==_e[t].field||e.order!==_e[t].order),[z,_e]),[V,ye]=Z.useState(!1),[H,Se]=Z.useState(()=>g&&Array.isArray(g.conditions)?g:{id:`root`,logic:`and`,conditions:[]}),U=b.dataSource,[Ce,we]=Z.useState([]),[Te,Ee]=Z.useState(null),[De,Oe]=Z.useState(`network`),[ke,W]=Z.useState(()=>!(Array.isArray(N.data)||N.data&&typeof N.data==`object`&&N.data.provider===`value`&&Array.isArray(N.data.items)||N.viewType===`gantt`&&N.data&&typeof N.data==`object`&&!Array.isArray(N.data)&&N.data.provider===`api`)),[G,je]=Z.useState(null),[K,Ne]=Z.useState(!1),[Le,Re]=Z.useState(0),[ze,Be]=Z.useState(!1);Z.useImperativeHandle(S,()=>({refresh:()=>Re(e=>e+1)}),[]),Z.useEffect(()=>{if(!(!U?.onMutation||!N.objectName))return U.onMutation(e=>{e.resource===N.objectName&&Re(e=>e+1)})},[U,N.objectName]);let[He,Ue]=Z.useState(void 0),We=He??N.pagination?.pageSize??100,[Ge,Ke]=Z.useState(1),[qe,Je]=Z.useState(null),[Ye,Xe]=Z.useState(null),Qe=Z.useMemo(()=>{if(N.grouping?.fields?.length)return N.grouping;let e=typeof N.groupBy==`string`?N.groupBy.trim():``,t=typeof N.groupBy2==`string`?N.groupBy2.trim():``,n=[];return e&&n.push({field:e,order:`asc`,collapsed:!1}),t&&t!==e&&n.push({field:t,order:`asc`,collapsed:!1}),n.length>0?{fields:n}:void 0},[N.grouping,N.groupBy,N.groupBy2]),[J,et]=Z.useState(Qe),[tt,nt]=Z.useState(!1),rt=Z.useRef(Qe);Z.useEffect(()=>{rt.current!==Qe&&(rt.current=Qe,et(Qe))},[Qe]);let[it,at]=Z.useState(N.rowColor),[st,ct]=Z.useState(!1),[lt,ut]=Z.useState([]),ft=Z.useRef(0),[pt,mt]=Z.useState([]),ht=Z.useMemo(()=>{let e=N.userFilters;if(!e)return;if(e.element===`tabs`||e.fields&&e.fields.length>0||!G?.fields)return e;let t=new Set([`select`,`multi-select`,`boolean`]),n=[],r=Array.isArray(G.fields)?G.fields.map(e=>[e.name,e]):Object.entries(G.fields);for(let[e,i]of r)(t.has(i.type)||i.options&&!i.type)&&n.push({field:e,label:P(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[N.userFilters,G,P]),[gt,_t]=Z.useState(()=>new Set(N.hiddenFields||[])),vt=Z.useMemo(()=>JSON.stringify(N.hiddenFields||[]),[N.hiddenFields]);Z.useEffect(()=>{_t(new Set(N.hiddenFields||[]))},[vt]);let yt=Z.useCallback(e=>{_t(e),s?.(Array.from(e))},[s]),[xt,St]=Z.useState(!1),[Ct,wt]=Z.useState(()=>!!N.inlineEdit);Z.useEffect(()=>{wt(!!N.inlineEdit)},[N.inlineEdit]);let Tt=Z.useCallback(e=>{wt(e),c?.(e)},[c]),[Et,Ot]=Z.useState(!1),[At,jt]=Z.useState(!1),[Mt,Nt]=Z.useState(null),{getObjectApiOperations:Ft,can:It}=o(),Rt=N.objectName?Ft(N.objectName):void 0,Vt=N.allowExport!==!1&&N.operations?.export!==!1&&(!Rt||Rt.includes(`export`)),Ht=Z.useMemo(()=>{let e=N.bulkActions;return!e||e.length===0||ne(G,Rt).delete&&(!N.objectName||It(N.objectName,`delete`))?e:e.filter(e=>String(e).toLowerCase()!==`delete`)},[N.bulkActions,N.objectName,G,Rt,It]),Ut=Z.useMemo(()=>ne(G,Rt).deletePredicates?.visibleWhen,[G,Rt]),Wt=ue(),Gt=Z.useMemo(()=>ae(Ut,lt,{scope:Wt,fields:G?.fields,label:`delete`}),[Ut,lt,Wt,G]),Kt=Z.useMemo(()=>N.userActions?.editInline!==!1&&me(G,Rt)&&(!N.objectName||It(N.objectName,`update`)),[N.userActions,N.objectName,G,Rt,It]),qt=Z.useMemo(()=>{if(N.exportOptions)return Array.isArray(N.exportOptions)?{formats:N.exportOptions}:N.exportOptions},[N.exportOptions]),Jt=Z.useMemo(()=>{let e=qt?.formats||[`csv`,`json`],t=typeof U?.exportDownload==`function`&&N.objectName&&qt?.streaming!==!1?[`csv`,`xlsx`,`json`]:[`csv`,`json`];return e.filter(e=>t.includes(e))},[qt,U,N.objectName]);Z.useEffect(()=>{let e=qt?.formats;if(!e)return;let t=e.filter(e=>!Jt.includes(e));t.length>0&&console.warn(`[ObjectUI] ListView export: unsupported format(s) hidden from the menu: ${t.join(`, `)}`)},[qt,Jt]);let Xt=Z.useMemo(()=>C(N.rowHeight)??`compact`,[N.rowHeight]),Zt=xe(Xt,{onChange:N.onDensityChange}),$t=Z.useMemo(()=>`objectui:gallery:density:${N.objectName??`default`}`,[N.objectName]),[en,tn]=Z.useState(()=>{if(typeof window>`u`)return N.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem($t);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return N.gallery?.cardSize??`medium`}),nn=Z.useCallback(()=>{tn(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem($t,t)}catch{}return t})},[$t]),rn=Z.useCallback(async()=>{Re(e=>e+1)},[]),{ref:an,isRefreshing:on,pullDistance:sn}=Br({onRefresh:rn,enabled:!!U&&!!N.objectName}),cn=Z.useMemo(()=>N.id?`listview-${N.objectName}-${N.id}-view`:`listview-${N.objectName}-view`,[N.objectName,N.id]);Z.useEffect(()=>{let e=!0;return Ne(!1),je(null),(async()=>{if(!U||!N.objectName){Ne(!0);return}if(typeof U.getObjectSchema!=`function`){Ne(!0);return}try{let t=await U.getObjectSchema(N.objectName);e&&je(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&Ne(!0)}})(),()=>{e=!1}},[N.objectName,U]);let ln=o(),un=Z.useMemo(()=>{let e=Array.isArray(N.columns)?N.columns.map(e=>q(e)).filter(e=>typeof e==`string`&&e.length>0):[],t=new Set(e),n=e=>{if(!e)return;let n=[e.groupByField,e.groupField,e.groupBy,e.summarizeField,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.swimlaneField,e.valueField,...Array.isArray(e.columns)?e.columns:[],...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of n)typeof e==`string`&&e&&t.add(e)};n(N.kanban),n(N.options?.kanban),n(N.calendar),n(N.options?.calendar),n(N.gallery),n(N.options?.gallery),n(N.timeline),n(N.options?.timeline),n(N.gantt),n(N.options?.gantt);for(let e of he(J))t.add(e);let r=t.size>0?Array.from(t):void 0,i=A(G?.fields,r);return!ln?.isLoaded||!N.objectName?i:i.filter(e=>ln.checkField(N.objectName,e,`read`))},[G?.fields,J,N.columns,N.kanban,N.calendar,N.gallery,N.timeline,N.gantt,N.options,ln,N.objectName]),dn=I===`gantt`&&!!N.data&&typeof N.data==`object`&&!Array.isArray(N.data)&&N.data.provider===`api`,fn=I!==`gantt`;Z.useEffect(()=>{let e=!0,t=++ft.current;if(N.data&&typeof N.data==`object`&&!Array.isArray(N.data)){let e=N.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(L){let e=L.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}we(t),W(!1),Be(!1);return}}if(Array.isArray(N.data)){let e=N.data;if(L){let t=L.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}we(e),W(!1),Be(!1);return}if(dn){W(!1),Be(!1);return}return K?((async()=>{if(!U||!N.objectName){W(!1);return}W(!0),Ee(null);try{let n=hi(N.filter,H,pt),r=z.length>0?z.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,i=(()=>{let e=Array.isArray(N.columns)?N.columns.map(e=>q(e)).filter(e=>typeof e==`string`&&e.length>0):[],t=ln?.isLoaded&&N.objectName?e.filter(e=>ln.checkField(N.objectName,e,`read`)):e;if(t.length===0)return;let n=new Set([`id`]);for(let e of t)n.add(e);for(let e of un)n.add(e);let r=(()=>{let e=G?.fields;if(!e)return null;let t=Array.isArray(e)?e.map(e=>e?.name).filter(e=>typeof e==`string`):Object.keys(e),n=new Set(t);return n.add(`id`),n.add(`created_at`),n.add(`updated_at`),n})(),i=e=>{typeof e!=`string`||!e||r&&!r.has(e)||ln?.isLoaded&&N.objectName&&r?.has(e)&&!re.has(e)&&!ln.checkField(N.objectName,e,`read`)||n.add(e)},a=e=>{re.has(e)?n.add(e):i(e)},o=e=>{if(!e)return;let t=[e.groupByField,e.groupField,e.groupBy,e.summarizeField,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.swimlaneField,e.valueField,...Array.isArray(e.columns)?e.columns:[],...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of t)i(e)};o(N.kanban),o(N.options?.kanban),o(N.calendar),o(N.options?.calendar),o(N.gallery),o(N.options?.gallery),o(N.timeline),o(N.options?.timeline);{let e=N.timeline??N.options?.timeline;e&&!Array.isArray(e.metaFields)&&(i(`status`),i(`priority`))}o(N.gantt),o(N.options?.gantt);for(let e of he(J))i(e);for(let e of pe(ee({conditionalFormatting:N.conditionalFormatting,rowActionDefs:N.rowActionDefs,bulkActionDefs:N.bulkActionDefs,objectActions:G?.actions,userActions:G?.userActions})))a(e);return Array.from(n)})(),a=n!==void 0,o=I===`grid`&&!J?.fields?.length,s=o?(Ge-1)*We:0,c={...a?{$filter:n}:{},$orderby:r,$top:We,...s>0?{$skip:s}:{},...i?{$select:i}:{},...un.length>0?{$expand:un}:{},...L?{$search:L,...N.searchableFields&&N.searchableFields.length>0?{$searchFields:N.searchableFields}:{}}:{}},l=await U.find(N.objectName,c);if(!e||t!==ft.current)return;let u=[];Array.isArray(l)?u=l:l&&typeof l==`object`&&(Array.isArray(l.data)?u=l.data:Array.isArray(l.records)?u=l.records:Array.isArray(l.value)&&(u=l.value)),we(u);let d=l&&typeof l==`object`?l.total??l.count:void 0,f=typeof d==`number`?d:null;Je(o?f:null),Xe(c),Be(!(o&&f!=null)&&u.length>=We)}catch(e){t===ft.current&&(console.error(`ListView data fetch error:`,e),we([]),Ee(e?.message?String(e.message):String(e??`Unknown error`)),Oe(Ae(e)))}finally{e&&t===ft.current&&W(!1)}})(),()=>{e=!1}):void 0},[N.objectName,N.data,U,N.filter,We,z,H,pt,Le,L,N.searchableFields,N.columns,N.kanban,N.calendar,N.gallery,N.timeline,N.gantt,N.options,G?.fields,K,N.refreshTrigger,ln,Ge,I,J,dn]);let pn=JSON.stringify([N.objectName,N.filter,We,z,H,pt,L,I,J]),hn=Z.useRef(pn);Z.useEffect(()=>{hn.current!==pn&&(hn.current=pn,Ke(1))},[pn]);let gn=Z.useMemo(()=>{let e=[`grid`];(N.kanban?.groupByField||N.kanban?.groupField||N.options?.kanban?.groupField)&&e.push(`kanban`),(N.gallery?.coverField||N.gallery?.imageField||N.options?.gallery?.imageField)&&e.push(`gallery`),(N.calendar?.startDateField||N.options?.calendar?.startDateField)&&e.push(`calendar`),pi(N).startDateField&&e.push(`timeline`),(N.gantt?.startDateField||N.options?.gantt?.startDateField)&&e.push(`gantt`);let t=ai(N);(t.locationField||t.latitudeField&&t.longitudeField)&&e.push(`map`),(N.tree?.parentField||N.options?.tree?.parentField||N.viewType===`tree`)&&e.push(`tree`),N.viewType&&!e.includes(N.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`,`tree`].includes(N.viewType)&&e.push(N.viewType);let n=N.appearance?.allowedVisualizations;if(Array.isArray(n)&&n.length>0){let t=n.filter(t=>e.includes(t));return t.length>0?t:[`grid`]}return e},[N.options,N.viewType,N.kanban,N.calendar,N.gantt,N.gallery,N.timeline,N.map,N.tree,N.appearance?.allowedVisualizations]);Z.useEffect(()=>{N.viewType&&se(N.viewType)},[N.viewType]);let vn=Z.useCallback(e=>{se(e);try{localStorage.setItem(cn,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}n?.(e)},[cn,n]),yn=Z.useCallback(e=>{R(e),a?.(e)},[a]),bn=Me({navigation:N.navigation,objectName:N.objectName,onNavigate:N.onNavigate,onRowClick:d}),xn=N.label?T(`detail.recordDetailWithLabel`,{label:N.label}):N.objectName?T(`detail.recordDetailWithLabel`,{label:N.objectName.charAt(0).toUpperCase()+N.objectName.slice(1)}):T(`detail.recordDetail`),wn=Z.useMemo(()=>{let e=Array.isArray(N.columns)?N.columns:[];if(ln?.isLoaded&&N.objectName&&(e=e.filter(e=>{let t=q(e);return!t||ln.checkField(N.objectName,t,`read`)})),gt.size>0&&(e=e.filter(e=>{let t=q(e);return t!=null&&!gt.has(t)})),N.fieldOrder&&N.fieldOrder.length>0){let t=new Map(N.fieldOrder.map((e,t)=>[e,t]));e=[...e].sort((e,n)=>(t.get(q(e))??1/0)-(t.get(q(n))??1/0))}return e},[N.columns,N.objectName,gt,N.fieldOrder,ln]),Tn=Z.useMemo(()=>Array.isArray(N.columns)&&N.columns.length>0,[N.columns]),An=Z.useMemo(()=>{let e=Zt.mode===`compact`?`compact`:Zt.mode===`spacious`?`tall`:`medium`,t={objectName:N.objectName,fields:wn,filter:N.filter,sort:z,className:`h-full w-full`,showSearch:!1,onRowClick:bn.handleClick,rowHeight:e,hideRowHeightToggle:!0,...l?{onColumnStateChange:l}:{},...N.columnState?{columnState:N.columnState}:{}};switch(I){default:case`grid`:return{type:`object-grid`,...t,...Tn?{columns:wn}:{fields:void 0,columns:void 0},...N.conditionalFormatting?{conditionalFormatting:N.conditionalFormatting}:{},editable:Ct&&Kt,...N.wrapHeaders==null?{}:{wrapHeaders:N.wrapHeaders},...N.resizable==null?{}:{resizable:N.resizable},...N.selection?{selection:N.selection}:{},...N.pagination?{pagination:N.pagination}:{},...J?{grouping:J}:{},...it?{rowColor:it}:{},...N.rowActions?{rowActions:N.rowActions}:{},...N.rowActionDefs?{rowActionDefs:N.rowActionDefs}:{},...N.bulkActions?{batchActions:N.bulkActions}:{},...N.bulkActionDefs?{bulkActionDefs:N.bulkActionDefs}:{},...N.options?.grid||{}};case`kanban`:{let{columns:e,groupByField:n,groupField:r,cardFields:i,titleField:a,...o}={...N.options?.kanban||{},...N.kanban||{}},s=n||r||E(G)||void 0;return{type:`object-kanban`,...t,groupBy:s,groupField:s,...a?{titleField:a}:{},cardFields:i||e||wn||[],...J?{grouping:J}:{},...o}}case`calendar`:{let e=N.calendar?.startDateField||N.options?.calendar?.startDateField,n=N.calendar?.endDateField||N.options?.calendar?.endDateField,r=N.calendar?.titleField||N.options?.calendar?.titleField;return{type:`object-calendar`,...t,...e?{startDateField:e}:{},...n?{endDateField:n}:{},...r?{titleField:r}:{},...N.calendar?.defaultView?{defaultView:N.calendar.defaultView}:{},...N.options?.calendar||{},...N.calendar||{}}}case`gallery`:{let e={...N.options?.gallery||{},...N.gallery||{},cardSize:en};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:N.gallery?.coverField||N.gallery?.imageField||N.options?.gallery?.imageField,titleField:N.gallery?.titleField||N.options?.gallery?.titleField||`name`,...J?{grouping:J}:{}}}case`timeline`:{let e={...N.options?.timeline||{},...N.timeline||{}},n=pi(N),r={...e,...n.startDateField?{startDateField:n.startDateField}:{},...n.endDateField?{endDateField:n.endDateField}:{}};return{type:`object-timeline`,...t,timeline:Object.keys(r).length>0?r:void 0,...n.startDateField?{startDateField:n.startDateField}:{},titleField:n.titleField||`name`,...n.endDateField?{endDateField:n.endDateField}:{},...N.timeline?.groupByField?{groupByField:N.timeline.groupByField}:{},...N.timeline?.colorField?{colorField:N.timeline.colorField}:{},...N.timeline?.scale?{scale:N.timeline.scale}:{}}}case`gantt`:{let e=N.gantt?.startDateField||N.options?.gantt?.startDateField,n=N.gantt?.endDateField||N.options?.gantt?.endDateField;return{type:`object-gantt`,...t,...N.data?{data:N.data}:{},...e?{startDateField:e}:{},...n?{endDateField:n}:{},progressField:N.gantt?.progressField||N.options?.gantt?.progressField||`progress`,dependenciesField:N.gantt?.dependenciesField||N.options?.gantt?.dependenciesField||`dependencies`,...N.gantt?.titleField?{titleField:N.gantt.titleField}:{},...N.options?.gantt||{},...N.gantt||{}}}case`map`:{let e=ai(N);return{type:`object-map`,...t,locationField:e.locationField||`location`,...e}}case`tree`:{let e=N.tree||N.options?.tree||{};return{type:`object-tree`,...t,parentField:e.parentField,labelField:e.labelField||e.titleField||`name`,fields:e.fields||wn,defaultExpandedDepth:e.defaultExpandedDepth,...e}}case`chart`:{let e=N.chart||N.options?.chart||{};if(e.dataset){let t=Array.isArray(e.dimensions)?e.dimensions:[],n=Array.isArray(e.values)?e.values:[];return{type:`object-chart`,dataset:e.dataset,dimensions:t,values:n,chartType:e.chartType||`bar`,xAxisKey:t[0],series:n.map(e=>({dataKey:e,label:e})),className:`h-[400px] w-full`}}let t=Array.isArray(e.yAxisFields)&&e.yAxisFields[0]||e.valueField||`value`,n=e.xAxisField||e.categoryField||`name`;return{type:`object-chart`,objectName:N.objectName,chartType:e.chartType||`bar`,filter:N.filter,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[I,N,z,wn,Tn,J,it,bn.handleClick,Zt.mode,en,Ct,Kt,G]),jn=H.conditions&&H.conditions.length>0,Mn=Z.useMemo(()=>{let e,t=(e,t)=>{if(!t)return;let n=Array.isArray(t)?t.map(e=>({value:e?.value??e,label:e?.label??String(e?.value??e),...e&&typeof e==`object`?e:{}})):Object.entries(t).map(([e,t])=>({value:e,label:t?.label||e,...t}));return N.objectName?ie(N.objectName,e,n):n};return e=G?.fields?Object.entries(G.fields).map(([e,n])=>({value:e,label:P(e,n.label||e),type:n.type||`text`,options:t(e,n.options),referenceTo:n.reference,displayField:n.display_field||n.reference_field,idField:n.id_field})):(Array.isArray(N.columns)?N.columns:[]).flatMap(e=>{if(typeof e==`string`)return[{value:e,label:e,type:`text`}];let n=q(e);return n?[{value:n,label:P(n,e.label||n),type:e.type||`text`,options:t(n,e.options),referenceTo:e.reference_to||e.reference,displayField:e.display_field||e.reference_field,idField:e.id_field}]:[]}),e},[G,N.columns,N.objectName,P,ie]),Nn=Z.useMemo(()=>{if(!N.filterableFields||N.filterableFields.length===0)return Mn;let e=new Set(N.filterableFields);return Mn.filter(t=>e.has(t.value))},[Mn,N.filterableFields]),Pn=Z.useMemo(()=>v(G),[G]),{sortFields:Fn,sortHasRelationalField:In}=Z.useMemo(()=>{let e=new Set(z.map(e=>e.field).filter(Boolean)),t=!1,n=[];for(let r of Mn){let i=O.has(r.type),a=Pn?y(Pn,r.value):!x.has(r.type);if(!i&&a){n.push({value:r.value,label:r.label});continue}if(e.has(r.value)){n.push({value:r.value,label:i?`${r.label} ${T(`list.sortByIdSuffix`)}`:r.label});continue}i&&(t=!0)}return{sortFields:n,sortHasRelationalField:t}},[Mn,z,T,Pn]),Ln=Z.useCallback(e=>{i&&i(Pn?h(e,Pn):e)},[i,Pn]),Rn=Z.useCallback(e=>{let t=e.map(e=>({id:crypto.randomUUID(),field:e.field,order:e.order}));ge(t),Ke(1),Ln(t)},[Ln]),zn=Z.useCallback(()=>{let e=ui(N.sort);ge(e),Ke(1),Ln(e)},[B,Ln]),Bn=Z.useCallback(e=>{if(!Vt)return;let t=qt,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=G?.label&&G?.name&&typeof k==`function`?k(G):G?.label,a=e=>M(e,{prefix:t?.fileNamePrefix,label:i,objectName:N.objectName,viewLabel:N.label||N.title});if((e===`csv`||e===`xlsx`||e===`json`)&&typeof U?.exportDownload==`function`&&N.objectName&&t?.streaming!==!1){let t=wn.map(e=>q(e)).filter(Boolean),i=hi(N.filter,H,pt),o=z.length>0?z.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})):void 0;Nt(null),jt(!0),(async()=>{try{let s=await U.exportDownload(N.objectName,{format:e,fields:t.length?t:void 0,filter:i,...L?{search:L,...N.searchableFields&&N.searchableFields.length>0?{searchFields:N.searchableFields}:{}}:{},sort:o,includeHeaders:r,limit:n>0?n:void 0}),c=URL.createObjectURL(s),l=document.createElement(`a`);l.href=c,l.download=a(e),l.rel=`noopener`,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(c),Ot(!1)}catch(e){console.error(`ListView export failed:`,e),Nt(e instanceof Error?e.message:String(e))}finally{jt(!1)}})();return}let o=n>0?Ce.slice(0,n):Ce;if(e===`csv`){let e=wn.map(e=>q(e)).filter(Boolean),t=[];r&&t.push(e.join(`,`)),o.forEach(n=>{t.push(e.map(e=>{let t=n[e],r;return r=t==null?``:Array.isArray(t)?t.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof t==`object`?JSON.stringify(t):String(t),r.includes(`,`)||r.includes(`"`)||r.includes(`
|
|
2
|
+
`)||r.includes(`\r`)?`"${r.replace(/"/g,`""`)}"`:r}).join(`,`))});let n=new Blob([t.join(`
|
|
3
|
+
`)],{type:`text/csv;charset=utf-8;`}),i=URL.createObjectURL(n),s=document.createElement(`a`);s.href=i,s.download=a(`csv`),s.click(),URL.revokeObjectURL(i)}else if(e===`json`){let e=new Blob([JSON.stringify(o,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=a(`json`),n.click(),URL.revokeObjectURL(t)}Ot(!1)},[Ce,wn,qt,N.objectName,N.filter,N.searchableFields,Vt,U,H,pt,z,L,G,k]),Vn=Z.useMemo(()=>(Array.isArray(N.columns)?N.columns:[]).flatMap(e=>{if(typeof e==`string`)return[{name:e,label:P(e,e)}];let t=q(e);return t?[{name:t,label:P(t,e.label||t)}]:[]}),[N.columns,P]),Hn=u(N.aria?.ariaLabel,j),Wn=Fe(N.description,j);return(0,Q.jsxs)(`div`,{ref:an,className:X(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,t),...Hn?{"aria-label":Hn}:{},...N.aria?.ariaDescribedBy?{"aria-describedby":N.aria.ariaDescribedBy}:{},...N.aria?.live?{"aria-live":N.aria.live}:{},role:N.aria?.role??`region`,"aria-busy":ke||void 0,"data-state":ke?`loading`:`idle`,children:[sn>0&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:sn},children:T(on?`list.refreshing`:`list.pullToRefresh`)}),Wn&&N.appearance?.showDescription!==!1&&(0,Q.jsx)(`div`,{className:`px-4 pt-1.5 text-xs text-muted-foreground bg-background`,"data-testid":`view-description`,children:Wn}),(0,Q.jsxs)(`div`,{className:`border-b px-2 sm:px-4 py-1.5 flex items-center justify-between gap-1 sm:gap-2 bg-background`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:ht&&(0,Q.jsx)(`div`,{className:`shrink-0 min-w-0 overflow-x-auto`,"data-testid":`user-filters`,children:(0,Q.jsx)(Qr,{config:ht,objectDef:G,data:Ce,onFilterChange:mt,maxVisible:3,initialSelections:p,onSelectionsChange:m})})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0 shrink-0 rounded-lg border border-border bg-muted/40 p-0.5 shadow-sm`,"data-print-hide":!0,children:[w&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gr,{currentView:I,availableViews:gn,onViewChange:vn}),(0,Q.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5`})]}),I===`grid`&&c&&!F.compactToolbar&&Kt&&(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:()=>Tt(!Ct),className:X(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Ct&&`text-primary`),title:T(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`}),"data-testid":`toolbar-inline-edit-toggle`,children:[(0,Q.jsx)(zt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.inlineEditShort`,{defaultValue:`Edit inline`})})]}),F.showHideFields&&!F.compactToolbar&&(0,Q.jsxs)(Pt,{open:xt,onOpenChange:St,children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,gt.size>0&&`text-primary`),children:[(0,Q.jsx)(Ze,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.hideFields`)}),gt.size>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:gt.size})]})}),(0,Q.jsx)(Bt,{align:`start`,className:`w-64 p-3`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,Q.jsx)(`h4`,{className:`font-medium text-sm`,children:T(`list.hideFieldsTitle`)}),gt.size>0&&(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>yt(new Set),children:T(`list.showAll`)})]}),(0,Q.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:Vn.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!gt.has(e.name),onChange:()=>{let t=new Set(gt);t.has(e.name)?t.delete(e.name):t.add(e.name),yt(t)},className:`rounded border-input`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),F.showHideFields&&!F.compactToolbar&&(F.showFilters||F.showSort||F.showGroup)&&(0,Q.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),F.showFilters&&(0,Q.jsxs)(Pt,{open:V,onOpenChange:ye,children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,jn&&`text-foreground font-medium`),children:[(0,Q.jsx)(sr,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.filter`)}),jn&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:H.conditions?.length||0})]})}),(0,Q.jsx)(Bt,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,Q.jsx)(`h4`,{className:`font-medium text-sm`,children:T(`list.filterRecords`)})}),(0,Q.jsx)(Qt,{fields:Nn,value:H,extraOperators:si,onChange:e=>{Se(e),r&&r(e)}})]})})]}),F.showGroup&&!F.compactToolbar&&(0,Q.jsxs)(Pt,{open:tt,onOpenChange:nt,children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,J&&`text-foreground font-medium`),children:[(0,Q.jsx)(dt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.group`)}),J&&J.fields?.length>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:J.fields.length})]})}),(0,Q.jsx)(Bt,{align:`start`,className:`w-72 p-3`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,Q.jsx)(`h4`,{className:`font-medium text-sm`,children:T(`list.groupBy`)}),J&&(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>et(void 0),"data-testid":`clear-grouping`,children:T(`list.clear`)})]}),(0,Q.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,Q.jsx)(Xn,{value:J,fieldOptions:Vn.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:T(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:T(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:T(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>et(e)})})]})})]}),F.showSort&&(0,Q.jsxs)(Pt,{open:de,onOpenChange:fe,children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,z.length>0&&`text-foreground font-medium`),children:[(0,Q.jsx)(_n,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.sort`)}),z.length>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:z.length})]})}),(0,Q.jsx)(Bt,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,Q.jsx)(`h4`,{className:`font-medium text-sm`,children:T(`list.sortRecords`)}),_e.length>0&&(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted-foreground hover:text-primary`,disabled:!ve,onClick:zn,"data-testid":`sort-reset-default`,children:T(`list.resetSortToDefault`)})]}),(0,Q.jsx)(Ar,{fields:Fn,value:z,onChange:e=>{ge(e),Ln(e)}}),In&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`sort-relational-hint`,children:T(`list.sortRelationalHint`)})]})})]}),!F.compactToolbar&&(F.showFilters||F.showSort||F.showGroup)&&(F.showColor||F.showDensity)&&(0,Q.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),F.showColor&&!F.compactToolbar&&(0,Q.jsxs)(Pt,{open:st,onOpenChange:ct,children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,it&&`text-foreground font-medium`),children:[(0,Q.jsx)(or,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.color`)})]})}),(0,Q.jsx)(Bt,{align:`start`,className:`w-64 p-3`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,Q.jsx)(`h4`,{className:`font-medium text-sm`,children:T(`list.rowColor`)}),it&&(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>at(void 0),"data-testid":`clear-row-color`,children:T(`list.clear`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,"data-testid":`color-field-list`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:T(`list.colorByField`)}),(0,Q.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:it?.field||``,onChange:e=>{let t=e.target.value;at(t?{field:t,colors:it?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,Q.jsx)(`option`,{value:``,children:T(`list.none`)}),Vn.map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),F.showDensity&&!F.compactToolbar&&I!==`gallery`&&(()=>{let e=Zt.mode===`compact`?En:Zt.mode===`comfortable`?Yn:gr,t=Zt.mode===`compact`?T(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Zt.mode===`comfortable`?T(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):T(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${T(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=T(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,"aria-label":n,className:X(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,Zt.mode!==`compact`&&`text-foreground font-medium`),onClick:Zt.cycle,title:r,children:(0,Q.jsx)(e,{className:`h-3.5 w-3.5`})})})(),F.showDensity&&!F.compactToolbar&&I===`gallery`&&(()=>{let e=en===`small`?En:en===`medium`?Yn:gr,t=en===`small`?T(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):en===`medium`?T(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):T(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${T(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=T(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,"aria-label":n,className:X(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,en!==`small`&&`text-foreground font-medium`),onClick:nn,title:r,children:(0,Q.jsx)(e,{className:`h-3.5 w-3.5`})})})(),F.compactToolbar&&(F.showGroup||F.showColor||F.showDensity||F.showHideFields)&&(0,Q.jsx)(qr,{t:T,allFields:Vn,showGroup:F.showGroup,groupingConfig:J,setGroupingConfig:et,showColor:F.showColor,rowColorConfig:it,setRowColorConfig:at,showDensity:F.showDensity,density:Zt,showHideFields:F.showHideFields,hiddenFields:gt,updateHiddenFields:yt,showInlineEdit:I===`grid`&&Kt,inlineEdit:Ct,setInlineEdit:Tt}),(F.showColor||F.showDensity||F.compactToolbar)&&qt&&Vt&&Jt.length>0&&(0,Q.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),F.showRefresh&&(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,onClick:()=>Re(e=>e+1),disabled:ke,title:T(`list.refresh`),"aria-label":T(`list.refresh`),"data-testid":`refresh-button`,children:(0,Q.jsx)(Dn,{className:X(`h-3.5 w-3.5`,ke&&`animate-spin`)})}),qt&&Vt&&Jt.length>0&&(0,Q.jsxs)(Pt,{open:Et,onOpenChange:Ot,children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,children:[(0,Q.jsx)(Lt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.export`)})]})}),(0,Q.jsx)(Bt,{align:`start`,className:`w-48 p-2`,children:(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[Jt.map(e=>(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,disabled:At,onClick:()=>Bn(e),children:[At?(0,Q.jsx)(br,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,Q.jsx)(Lt,{className:`h-3.5 w-3.5 mr-2`}),T(`list.exportAs`,{format:e.toUpperCase()})]},e)),Mt&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-xs`,style:{color:`var(--destructive, #ef4444)`},role:`alert`,children:Mt})]})})]}),N.sharing?.type&&(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${N.sharing.type}`,"data-testid":`share-button`,children:[(0,Q.jsx)(hr,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.share`)})]}),N.allowPrinting&&(()=>{let e=T(`common.printDialogHint`);return(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,onClick:()=>window.print(),"aria-label":`${T(`list.print`)}: ${e}`,title:e,"data-testid":`print-button`,children:[(0,Q.jsx)(xr,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.print`)})]})})(),(()=>{let e=N.allowPrinting||!!N.sharing?.type||qt&&Vt&&Jt.length>0;return F.showSearch&&e?(0,Q.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),F.showSearch&&(0,Q.jsxs)(Pt,{open:ce,onOpenChange:le,children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`hidden sm:inline-flex h-7 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,L?`px-2 text-foreground font-medium`:`w-7 p-0`),"data-testid":`search-icon-button`,title:L?`${T(`list.search`)}: ${L}`:T(`list.search`),children:[(0,Q.jsx)(Sn,{className:`h-3.5 w-3.5`}),L&&(0,Q.jsx)(`span`,{className:`ml-1.5 max-w-[8rem] truncate text-[11px]`,"data-testid":`search-active-keyword`,children:L})]})}),(0,Q.jsx)(Bt,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-64 p-2`,"data-testid":`search-popover`,children:(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(Sn,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Q.jsx)(bt,{placeholder:T(`table.search`),value:L,onChange:e=>yn(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),L&&(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:`absolute right-0.5 top-1/2 -translate-y-1/2 h-5 w-5 p-0 hover:bg-muted-foreground/20`,onClick:()=>yn(``),children:(0,Q.jsx)(tr,{className:`h-3 w-3`})})]})})]}),F.showAddRecordTop&&(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>b.onAddRecord?.(),children:[(0,Q.jsx)($e,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.addRecord`)})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:[(0,Q.jsx)(nr,{active:ke&&Ce.length>0}),Te&&Ce.length===0?(0,Q.jsx)(Cn,{role:`alert`,"data-testid":`list-error-state`,"data-error-kind":De,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:De===`network`?(0,Q.jsx)(Mr,{className:`h-12 w-12 text-destructive/60`}):(0,Q.jsx)(kn,{className:`h-12 w-12 text-destructive/60`}),iconWrapperClassName:`mb-3`,title:T(De===`api-disabled`?`list.loadErrorApiDisabledTitle`:De===`forbidden`?`list.loadErrorForbiddenTitle`:De===`unauthorized`?`list.loadErrorUnauthorizedTitle`:De===`rejected`?`list.loadErrorRejectedTitle`:`list.loadErrorTitle`),message:T(De===`api-disabled`?`list.loadErrorApiDisabledMessage`:De===`forbidden`?`list.loadErrorForbiddenMessage`:De===`unauthorized`?`list.loadErrorUnauthorizedMessage`:De===`rejected`?`list.loadErrorRejectedMessage`:`list.loadErrorMessage`),children:De===`api-disabled`?null:(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,"data-testid":`list-error-retry`,onClick:()=>Re(e=>e+1),children:[(0,Q.jsx)(Dn,{className:`h-4 w-4 mr-1.5`}),T(`list.retry`)]})}):ke&&Ce.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col h-full min-h-[200px] p-4 gap-2`,"data-testid":`list-loading`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:T(`list.loading`)}),[0,1,2,3,4,5].map(e=>(0,Q.jsx)(`div`,{className:`h-9 rounded bg-muted/60 animate-pulse`,style:{opacity:Math.max(.25,1-e*.12)}},e))]}):!ke&&Ce.length===0&&I===`grid`?(()=>{let e=N.emptyState?.icon,t=kt(e)??Dt,n=Array.isArray(N.filter)?N.filter.length>0:N.filter&&typeof N.filter==`object`?Object.keys(N.filter).length>0:!1,r=!!(L&&L.trim())||n||Array.isArray(pt)&&pt.length>0||Array.isArray(H?.conditions)&&H.conditions.length>0,i=(typeof N.emptyState?.title==`string`?N.emptyState.title:void 0)??T(r?`list.noMatches`:`list.firstRunTitle`),a=(typeof N.emptyState?.message==`string`?N.emptyState.message:void 0)??T(r?`list.noMatchesMessage`:`list.firstRunMessage`);return(0,Q.jsx)(Un,{"data-testid":`empty-state`,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:(0,Q.jsx)(t,{className:`h-12 w-12 text-muted-foreground/50`}),iconWrapperClassName:`mb-3`,title:i,description:a,action:F.showAddRecord?(0,Q.jsxs)(Y,{variant:`default`,size:`sm`,"data-testid":`empty-state-add-record`,onClick:()=>b.onAddRecord?.(),children:[(0,Q.jsx)($e,{className:`h-4 w-4 mr-1.5`}),T(`list.addRecord`)]}):void 0})})():(0,Q.jsx)(be,{schema:An,...b,...dn?{}:{data:Ce},loading:ke,onRowSelect:ut,...I===`grid`&&!J?.fields?.length&&qe!=null?{manualPagination:!0,rowCount:qe,page:Ge,pageSize:We,onPageChange:e=>Ke(e),onPageSizeChange:e=>{Ue(e),Ke(1)},sort:z,onSortChange:Rn,findParams:Ye}:{}})]},I),F.showAddRecordBottom&&(0,Q.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>b.onAddRecord?.(),children:[(0,Q.jsx)($e,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:T(`list.addRecord`)})]})}),Ht&&Ht.length>0&<.length>0&&I!==`grid`&&(0,Q.jsxs)(`div`,{className:`border-t border-primary/30 px-4 py-2 flex items-center gap-2 text-xs bg-primary/10 text-foreground shrink-0 shadow-sm`,role:`region`,"aria-label":`Bulk actions`,"data-testid":`bulk-actions-bar`,children:[(0,Q.jsx)(mn,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[lt.length,` `,lt.length===1?`item`:`items`,` selected`]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:Ht.map(e=>{let t=String(e).toLowerCase(),n=t.includes(`delete`)||t.includes(`remove`)||t.includes(`destroy`),r=n?Yt:null,i=t===`delete`?Gt.eligible:lt;return(0,Q.jsxs)(Y,{variant:n?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>b.onBulkAction?.(e,i),"data-testid":`bulk-action-${e}`,children:[r&&(0,Q.jsx)(r,{className:`h-3 w-3`}),oe(e)]},e)})}),Gt.skipped>0&&Ht.some(e=>String(e).toLowerCase()===`delete`)&&(0,Q.jsx)(`span`,{className:`text-muted-foreground ml-3`,"data-testid":`bulk-skipped-notice`,children:T(`grid.bulk.skippedIneligible`,{count:Gt.skipped,defaultValue:`${Gt.skipped} selected record(s) are not eligible for this action and will be skipped.`})}),(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>ut([]),children:[(0,Q.jsx)(tr,{className:`h-3 w-3`}),`Clear`]})]}),!ke&&Ce.length>0&&fn&&N.showRecordCount!==!1&&(0,Q.jsxs)(`div`,{className:`border-t px-4 py-2 flex items-center gap-3 text-xs text-muted-foreground bg-background shrink-0`,"data-testid":`record-count-bar`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground/80`,children:(()=>{let e=qe??Ce.length;return T(e===1?`list.recordCountOne`:`list.recordCount`,{count:e})})()}),ze&&(0,Q.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:T(`list.dataLimitReached`,{limit:We})}),I!==`grid`&&N.pagination?.pageSizeOptions&&N.pagination.pageSizeOptions.length>0&&(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:T(`table.rowsPerPage`,{defaultValue:`Rows per page`})}),(0,Q.jsx)(`select`,{"data-testid":`page-size-selector`,className:`h-7 w-[72px] px-2 py-1 text-xs rounded-md border border-input bg-background`,value:String(We),onChange:e=>{let t=Number(e.target.value);Ue(t),b.onPageSizeChange&&b.onPageSizeChange(t)},children:N.pagination.pageSizeOptions.map(e=>(0,Q.jsx)(`option`,{value:String(e),children:e},e))})]})]}),bn.isOverlay&&(0,Q.jsx)(On,{...bn,title:xn,children:e=>(0,Q.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Q.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})});yi.displayName=`ListView`;var bi={columns:!0,filter:!0,sort:!0,limit:`pagination.pageSize`,viewType:!0},xi=b(Z.forwardRef((e,t)=>{let n=(0,Z.useContext)(oe),r=(_e(e.dataSource)?void 0:e.dataSource)??n?.dataSource;return(0,Q.jsx)(Oe,{schema:e.schema,mapping:bi,dataSource:r,testId:`list-view`,errorTitle:`This list view’s data source could not be resolved`,children:n=>(0,Q.jsx)(yi,{ref:t,...e,schema:n,dataSource:r})})}));xi.displayName=`ListViewBlock`;var Si={small:`grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6`,medium:`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`,large:`grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3`},Ci={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},wi=new Set([`number`,`currency`,`percent`,`integer`,`decimal`]),Ti=[{bg:`from-indigo-500/15 via-indigo-500/5 to-purple-500/10`,ring:`ring-indigo-500/15`,text:`text-indigo-600/70 dark:text-indigo-300/70`},{bg:`from-sky-500/15 via-sky-500/5 to-cyan-500/10`,ring:`ring-sky-500/15`,text:`text-sky-600/70 dark:text-sky-300/70`},{bg:`from-emerald-500/15 via-emerald-500/5 to-teal-500/10`,ring:`ring-emerald-500/15`,text:`text-emerald-600/70 dark:text-emerald-300/70`},{bg:`from-amber-500/15 via-amber-500/5 to-orange-500/10`,ring:`ring-amber-500/15`,text:`text-amber-600/70 dark:text-amber-300/70`},{bg:`from-rose-500/15 via-rose-500/5 to-pink-500/10`,ring:`ring-rose-500/15`,text:`text-rose-600/70 dark:text-rose-300/70`},{bg:`from-violet-500/15 via-violet-500/5 to-fuchsia-500/10`,ring:`ring-violet-500/15`,text:`text-violet-600/70 dark:text-violet-300/70`}];function Ei(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return Ti[Math.abs(t)%Ti.length]}var Di=({imageUrl:e,title:t,coverFit:n,aspectClass:r,placeholder:i,hidden:a})=>{let[o,s]=(0,Z.useState)(!1),c=!!e&&!o;return(0,Q.jsx)(`div`,{className:X(`w-full overflow-hidden relative`,r),hidden:a,children:c?n===`contain`?(0,Q.jsx)(`div`,{className:X(`flex h-full w-full items-center justify-center bg-gradient-to-br`,i.bg),children:(0,Q.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>s(!0),className:`h-1/2 w-1/2 max-h-24 max-w-24 object-contain transition-transform duration-300 ease-out group-hover:scale-[1.08]`})}):(0,Q.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>s(!0),className:`h-full w-full object-cover transition-transform duration-300 ease-out group-hover:scale-[1.04]`}):(0,Q.jsx)(`div`,{className:X(`flex h-full w-full items-center justify-center bg-gradient-to-br ring-1 ring-inset`,i.bg,i.ring),children:(0,Q.jsx)(`span`,{className:X(`text-5xl font-semibold tracking-tight opacity-90`,i.text),children:t[0]?.toUpperCase()})})})},Oi=({imageUrl:e,title:t,placeholder:n})=>{let[r,i]=(0,Z.useState)(!1),a=!!e&&!r;return(0,Q.jsx)(`div`,{className:X(`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br ring-1 ring-inset`,n.bg,n.ring),children:a?(0,Q.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>i(!0),className:`h-6 w-6 object-contain transition-transform duration-300 ease-out group-hover:scale-110`}):(0,Q.jsx)(`span`,{className:X(`text-base font-semibold`,n.text),children:t[0]?.toUpperCase()})})},ki=(e,t)=>{let n=e?.[t];if(n!=null&&n!==``)return wt(n)[0]?.url};R.register(`object-gallery`,e=>{let{schema:t}=e,n=(0,Z.useContext)(oe),r=e.dataSource||n?.dataSource,i=L(t.bind),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),d=Me({navigation:t.navigation,objectName:t.objectName,onRowClick:e.onRowClick??e.onCardClick}),f=t.gallery,p=f?.coverField??t.imageField??`image`,m=f?.coverFit??`cover`,h=f?.cardSize??`medium`,g=f?.titleField??t.titleField,_=f?.visibleFields,{fieldLabel:v,fieldOptionLabel:y}=Ie(),b=(0,Z.useCallback)(e=>{let n=l?.fields?.[e],r={name:e};if(n){n.type&&(r.type=n.type),n.label&&(r.label=n.label),n.options&&(r.options=n.options),n.currency&&(r.currency=n.currency),n.precision!==void 0&&(r.precision=n.precision),n.format&&(r.format=n.format);let e=n.reference;e&&(r.reference_to=e),n.reference_field&&(r.reference_field=n.reference_field)}if(t.objectName){let n=String(r.label??e);r.label=v(t.objectName,e,n)}return t.objectName&&Array.isArray(r.options)&&(r.options=r.options.map(n=>{let r=String(n?.value??n),i=String(n?.label??r);return{...n,value:r,label:y(t.objectName,e,r,i)}})),r},[l,t.objectName,v,y]);(0,Z.useEffect)(()=>{let e=!0;return(async()=>{if(!(!r||typeof r.getObjectSchema!=`function`||!t.objectName))try{let n=await r.getObjectSchema(t.objectName);e&&u(n)}catch(e){console.warn(`Failed to fetch object def for ObjectGallery`,e)}})(),()=>{e=!1}},[t.objectName,r]),(0,Z.useEffect)(()=>{let n=!0;if(e.data&&Array.isArray(e.data)){o(e.data);return}return t.objectName&&!i&&!t.data&&!e.data&&(async()=>{if(!(!r||typeof r.find!=`function`||!t.objectName)){n&&c(!0);try{let e=A(l?.fields),i=await r.find(t.objectName,{$filter:t.filter,...e.length>0?{$expand:e}:{}}),a=[];if(Array.isArray(i))a=i;else if(i&&typeof i==`object`){let e=i;Array.isArray(e.records)?a=e.records:Array.isArray(e.data)&&(a=e.data)}n&&o(a)}catch(e){console.error(`[ObjectGallery] Fetch error:`,e)}finally{n&&c(!1)}}})(),()=>{n=!1}},[t.objectName,r,i,t.data,t.filter,e.data,l]);let x=e.data||i||t.data||a||[],S=(0,Z.useMemo)(()=>x.some(e=>!!ki(e,p)),[x,p]),C=t.grouping?.fields,w=!!(C&&C.length>0),[T,E]=(0,Z.useState)({}),D=(0,Z.useMemo)(()=>C?C.some(e=>e.collapsed):!1,[C]),O=(0,Z.useCallback)(e=>{E(t=>({...t,[e]:t[e]===void 0?!D:!t[e]}))},[D]),ee=(0,Z.useMemo)(()=>{if(!w||!C)return[];let e=new Map,t=[];for(let n of x){let r=C.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=C.map(e=>{let t=n[e.field];return t!=null&&t!==``?String(t):`(empty)`}).join(` / `);e.set(r,{label:i,items:[]}),t.push(r)}e.get(r).items.push(n)}let n=C[0]?.order??`asc`;return t.sort((e,t)=>{let r=e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`});return n===`desc`?-r:r}),t.map(t=>{let n=e.get(t),r=t in T?T[t]:D;return{key:t,label:n.label,items:n.items,collapsed:r}})},[x,C,w,T,D]);if(s&&!x.length)return(0,Q.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!x.length)return(0,Q.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let te=e=>!_||_.length===0?null:(0,Q.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:_.map(t=>{let n=e[t];if(n==null||n===``)return null;let r=b(t),i=Fn(r)||r.type||`text`,a=Mn(i),o=r?.label&&String(r.label).trim()?String(r.label):void 0,s=o!=null&&wi.has(i);return(0,Q.jsxs)(`div`,{className:X(`text-xs text-muted-foreground truncate [&_*]:!text-xs`,s&&`flex items-baseline gap-1.5`),onClick:e=>{e.target.closest(`a,button`)&&e.stopPropagation()},children:[s&&(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:o}),(0,Q.jsx)(a,{value:n,field:r})]},t)})}),ne=(n,r)=>{let i=n.id??n._id??r,a=(g!=null&&n[g]!=null&&n[g]!==``?String(n[g]):void 0)??H(l,n),o=ki(n,p),s=Ei(String(i)+`|`+a),c=X(`group relative overflow-hidden border-border/60 bg-card`,`transition-all duration-200 ease-out`,`hover:shadow-lg hover:border-border hover:-translate-y-0.5`,(e.onCardClick||e.onRowClick||t.navigation)&&`cursor-pointer`);return S&&m===`contain`?(0,Q.jsxs)(It,{role:`listitem`,className:c,onClick:e=>d.handleClick(n,e),children:[(0,Q.jsx)(`div`,{"aria-hidden":!0,className:X(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,Q.jsx)(Jn,{className:`p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Oi,{imageUrl:o,title:a,placeholder:s}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:a,children:a}),te(n)]})]})})]},i):(0,Q.jsxs)(It,{role:`listitem`,className:c,onClick:e=>d.handleClick(n,e),children:[!S&&(0,Q.jsx)(`div`,{"aria-hidden":!0,className:X(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,Q.jsx)(Di,{imageUrl:o,title:a,coverFit:m,aspectClass:Ci[h],placeholder:s,hidden:!S}),(0,Q.jsxs)(Jn,{className:X(`p-3`,S&&`border-t border-border/60`),children:[(0,Q.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:a,children:a}),te(n)]})]},i)},re=e=>(0,Q.jsx)(`div`,{className:X(`grid gap-4 p-4 auto-rows-min content-start`,Si[h],t.className),role:`list`,children:e.map((e,t)=>ne(e,t))});return(0,Q.jsxs)(Q.Fragment,{children:[w?(0,Q.jsx)(`div`,{className:`space-y-2`,children:ee.map(e=>(0,Q.jsxs)(`div`,{className:`border rounded-md`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors`,onClick:()=>O(e.key),children:[e.collapsed?(0,Q.jsx)(rr,{className:`h-4 w-4 shrink-0`}):(0,Q.jsx)(Rn,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:e.label}),(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.items.length})]}),!e.collapsed&&re(e.items)]},e.key))}):re(x),d.isOverlay&&(0,Q.jsx)(On,{...d,title:`Gallery Item`,children:e=>(0,Q.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Q.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},{namespace:`plugin-list`,label:`Gallery View`,category:`view`});var Ai=xi;R.register(`list-view`,Ai,{namespace:`plugin-list`,label:`List View`,category:`Views`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}],defaultProps:{objectName:``,viewType:`grid`,columns:[],filter:[],sort:[],options:{}}}),R.register(`list`,Ai,{namespace:`view`,skipFallback:!0,category:`view`,label:`List`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}]});var ji=new Set([`textarea`,`markdown`,`html`,`grid`,`richtext`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:richtext`]);function Mi(e){return ji.has(e)}function Ni(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 Pi(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&Mi(e.type)?{...e,span:t}:e)}function Fi(e,t,n){if(t!==void 0)return{fields:Pi(e,t),columns:t};let r=Ni(e.length,n);return{fields:Pi(e,r),columns:r}}var $=Be({"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.related":`Related`,"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.emptyValue":`—`,"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.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.unifiedDiff":`Unified diff`,"detail.sideBySideDiff":`Side-by-side diff`,"detail.noChanges":`No changes`,"detail.previousVersion":`Previous`,"detail.currentVersion":`Current`,"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.firstRecord":`First record (Home)`,"detail.previousRecordKey":`Previous record (←)`,"detail.nextRecordKey":`Next record (→)`,"detail.lastRecord":`Last record (End)`,"detail.noRecords":`No records`,"detail.showEmptyRelated":`+ {{count}} empty`,"detail.showEmptyRelated_one":`+ {{count}} empty`,"detail.showEmptyRelated_other":`+ {{count}} empty`,"detail.searchWhileNavigating":`Search while navigating`,"detail.searchRecords":`Search records…`,"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.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`,"detail.revisionHistory":`Revision History`,"detail.noRevisions":`No revisions recorded`,"detail.revisionFieldsChanged":`{{count}} fields changed`,"detail.revisionFieldsChangedOne":`{{count}} field changed`,"detail.revisionPreview":`Revision Preview`,"detail.revisionSnapshot":`Record state at this point`,"detail.restoreConfirm":`This will restore the record to its state at {{when}}. Continue?`,"detail.restoring":`Restoring…`,"detail.confirmRestore":`Confirm Restore`,"detail.restoreToPoint":`Restore to this point`},`detail.back`);function Ii(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 Li(e){let t=Ii(e);return t==null||t===``?0:Array.isArray(t)?t.length:typeof t==`object`?Object.keys(t).length:1}function Ri({value:e,field:t}){let{t:r}=$(),a=S(),{appName:o}=i(),s=t?.name||``,c=a?.data?.name,l=o&&c?`/apps/${o}/metadata/permission/${encodeURIComponent(String(c))}`:null,u=Li(e),d=u===0,f=(()=>{if(d)return(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:r(`perm.facet.none`,{defaultValue:`None`})});if(s===`system_permissions`){let t=J(e),n=t.slice(0,6),i=t.length-n.length;return(0,Q.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[n.map(e=>(0,Q.jsx)(Vt,{variant:`outline`,children:e},e)),i>0&&(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:r(`perm.facet.more`,{count:i,defaultValue:`+${i} more`})})]})}let t=(()=>{switch(s){case`object_permissions`:return r(`perm.facet.objects`,{count:u,defaultValue:`${u} object${u===1?``:`s`}`});case`field_permissions`:return r(`perm.facet.fields`,{count:u,defaultValue:`${u} field rule${u===1?``:`s`}`});case`row_level_security`:return r(`perm.facet.rls`,{count:u,defaultValue:`${u} RLS polic${u===1?`y`:`ies`}`});case`tab_permissions`:return r(`perm.facet.tabs`,{count:u,defaultValue:`${u} tab rule${u===1?``:`s`}`});case`admin_scope`:return r(`perm.facet.adminScope`,{defaultValue:`Delegated admin configured`});default:return String(u)}})();return(0,Q.jsx)(`span`,{className:`text-foreground`,children:t})})();return(0,Q.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[f,l?(0,Q.jsx)(n,{to:l,className:`text-primary hover:underline whitespace-nowrap`,children:r(`perm.facet.designInStudio`,{defaultValue:`Design in Studio →`})}):(0,Q.jsx)(`span`,{className:`text-muted-foreground/60 whitespace-nowrap`,children:r(`perm.facet.designInStudioHint`,{defaultValue:`Design in Studio`})})]})}var zi=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`]),Bi=new Set([`formula`,`summary`,`rollup`,`autonumber`,`auto_number`]);function Vi(e,t){return Bi.has(e)||Bi.has(t)}var Hi=new Set([`image`,`avatar`,`signature`,`file`,`video`,`audio`]);function Ui(e,t){return Wi(e)||Wi(t)}function Wi(e){return typeof e!=`string`||Hi.has(e)?!1:Wn(e)}var Gi=`options.currency.currencyConfig.precision.scale.min.max.step.format.widget.dueLike.multiple.reference_field.display_field.displayField.description_field.descriptionField.id_field.allow_create.allowCreate.lookup_columns.lookupColumns.lookup_page_size.lookupPageSize.lookup_filters.lookupFilters.picker.subtitle.avatar_field.avatarField.depends_on.dependsOn`.split(`.`);function Ki(e,t){let n={...e};if(!t)return n;!n.type&&t.type&&(n.type=t.type);for(let e of Gi){let r=t[e];r!==void 0&&n[e]===void 0&&(n[e]=r)}let r=t.reference;return r&&n.reference_to===void 0&&(n.reference_to=r),n}var qi=`inline-plain-text-input`,Ji=new Set([`text`,`textarea`,`email`,`phone`,`url`]);function Yi(e){return e?mr.includes(e)||pn(e)!==`field:text`:!1}function Xi(e){let t=e?.type;return!t||Ji.has(t)?!0:t===`select`&&!e.multiple}var Zi=({field:e,value:t,onChange:n,dataSource:r,autoFocus:i,error:a})=>{let o=e.type;if(e.widget===`permission-facet-link`)return(0,Q.jsx)(Ri,{value:t,field:e});if(typeof o==`string`&&P[o])return(0,Q.jsx)(er,{field:e});let s=o===`multiselect`||!!e.multiple;if((o===`select`||o===`multiselect`)&&Array.isArray(e.options)&&e.options.length>0)return s?(0,Q.jsx)(Fr,{field:{...e,multiple:!0},value:Array.isArray(t)?t:t==null||t===``?[]:[t],onChange:e=>n(e),error:a}):(0,Q.jsx)(Fr,{field:e,value:t==null?``:String(t),onChange:e=>n(e),error:a});if(o===`boolean`)return(0,Q.jsx)(Ke,{field:e,value:!!t,onChange:e=>n(e),error:a});if(o===`image`)return(0,Q.jsx)(Dr,{field:e,value:t,onChange:e=>n(e),error:a});if(o===`avatar`)return(0,Q.jsx)(jr,{field:e,value:t,onChange:e=>n(e),error:a});if(o===`signature`)return(0,Q.jsx)(vr,{field:e,value:t,onChange:e=>n(e),error:a});if(o===`file`||o===`video`||o===`audio`)return(0,Q.jsx)(Jt,{field:e,value:t,onChange:e=>n(e),error:a});let c=o===`user`,l=o===`lookup`||o===`master_detail`||o===`tree`||!!e.reference_to&&!Bi.has(o);if(c||l)return(0,Q.jsx)(c?at:_t,{field:e,value:t,onChange:e=>n(e),dataSource:r,error:a});if(o===`number`)return(0,Q.jsx)(rn,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(o===`currency`)return(0,Q.jsx)(pt,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(o===`percent`)return(0,Q.jsx)(cn,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(o===`address`)return(0,Q.jsx)(Rt,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(o===`location`)return(0,Q.jsx)(Nt,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});if(o===`geolocation`)return(0,Q.jsx)(At,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});let u=o===`date`||o===`datetime`;if(!u&&!Xi(e)&&Yi(o)&&We(o))return(0,Q.jsx)(qn,{field:e,value:t,onChange:e=>n(e),autoFocus:i,error:a});let d=u?`date`:`text`,f=t==null?``:u?(()=>{let e=String(t);if(/^\d{4}-\d{2}-\d{2}/.test(e))return e.slice(0,10);let n=new Date(e);return isNaN(n.getTime())?``:n.toLocaleDateString(`en-CA`)})():String(typeof t==`object`?Vn(t)??``:t);return(0,Q.jsx)(`input`,{type:d,"data-testid":u?void 0:qi,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=>{let t=e.target.value;n(u&&t?new Date(t+`T00:00:00`).toISOString():t)}})},Qi=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`});function $i(e){if(!e)return;let t=e.trim();if(t)return t.startsWith(`bg-`)?t:Object.prototype.hasOwnProperty.call(Qi,t)?Qi[t]:void 0}var ea=({name:e})=>/^[a-z0-9][a-z0-9-]*$/i.test(e)?(0,Q.jsx)(Kn,{name:e,className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e});function ta(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 na=({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]=Z.useState(e.defaultCollapsed??!1),[p,m]=Z.useState(null),[h,g]=Z.useState(void 0),[_,v]=Z.useState(!1),{t:y}=$(),{fieldLabel:b,translateOptions:x}=Ie(),S=z()?.fieldErrors??null,C=Z.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{m(e),setTimeout(()=>m(null),2e3)})},[]),w=Z.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),T=Z.useMemo(()=>e.fields.filter(w).length,[e.fields,w]),E=bn(),D=E?3:4,O=E?.2:.25,ee=e.fields.length-T,te=!a&&e.fields.length>=D&&T/e.fields.length>=O&&ee>0,ne=!_&&te?e.fields.filter(e=>!w(e)):e.fields,{fields:re,columns:k}=Fi(ne,e.columns),A=Math.min(k,Math.max(1,ne.length)),ie=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,Q.jsx)(be,{schema:Te(e.render),data:{...t,value:n}});let u=ta(e.span,A),d=r?.fields?.[e.name],f=Ki(e,d);i&&Array.isArray(f.options)&&f.options.length>0&&(f.options=x(i,e.name,f.options));let m=Vi(e.type,d?.type),h=e.readonly===!0||d?.readonly===!0,g=zi.has(e.name),_=Ui(e.type,d?.type),v=!h&&!m&&!g&&!_,w=v&&!!s,T=(()=>{if((f.widget||e.widget)===`permission-facet-link`)return(0,Q.jsx)(Ri,{value:n,field:f});if(n==null||n===``)return(0,Q.jsx)(`span`,{className:`text-muted-foreground/60 text-sm select-none`,"aria-label":y(`detail.noValue`,{defaultValue:`No value`}),title:y(`detail.noValue`,{defaultValue:`No value`}),children:`—`});let t=Fn(f)||e.type;if(t){let e=Mn(t);if(e)return(0,Q.jsx)(e,{value:n,field:f})}return String(n)})(),D=n!=null&&n!==``,O=D&&!w,ee=p===e.name,te=b(i||``,e.name,e.label||e.name);return E&&!(a&&v)?(0,Q.jsxs)(`div`,{className:X(`flex items-baseline justify-between gap-4 py-2.5 min-h-[44px] group`,D&&`cursor-pointer active:bg-muted/40 transition-colors`),onClick:D?()=>C(e.name,n):void 0,onKeyDown:D?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),C(e.name,n))}:void 0,role:D?`button`:void 0,tabIndex:D?0:void 0,children:[(0,Q.jsx)(`span`,{className:`text-[15px] text-muted-foreground shrink-0`,children:te}),(0,Q.jsx)(`span`,{className:`text-[15px] text-foreground text-right break-words min-w-0 leading-snug`,children:T})]},e.name):(0,Q.jsxs)(`div`,{className:X(`space-y-1.5 group min-w-0`,u),children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:b(i||``,e.name,e.label||e.name)}),a&&v?(0,Q.jsxs)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:[(0,Q.jsx)(Zi,{field:f,value:n,onChange:t=>o?.(e.name,t),dataSource:l,autoFocus:c===e.name,error:S?.[e.name]}),S?.[e.name]&&(0,Q.jsx)(`p`,{role:`alert`,"data-inline-field-hint":e.name,className:`mt-1 text-xs text-destructive`,children:S[e.name]})]}):(0,Q.jsxs)(`div`,{className:X(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,O&&`cursor-pointer active:bg-muted/60 transition-colors`,w&&`cursor-pointer hover:bg-muted/40 transition-colors -mx-1.5 px-1.5`),onClick:O?()=>C(e.name,n):void 0,onDoubleClick:w?()=>s?.(e.name):void 0,onKeyDown:O?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),C(e.name,n))}:void 0,role:O?`button`:void 0,tabIndex:O?0:void 0,title:w?y(`detail.editInlineHint`):void 0,children:[(0,Q.jsx)(`div`,{className:`text-sm flex-1 min-w-0 break-words py-1`,children:T}),w?(0,Q.jsx)(Qn,{children:(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsx)(Y,{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,Q.jsx)(zt,{className:`h-3 w-3`})})}),(0,Q.jsx)(ir,{children:y(`detail.editInlineHint`)})]})}):D?(0,Q.jsx)(Qn,{children:(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsx)(Y,{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:ee?(0,Q.jsx)(In,{className:`h-3 w-3 text-green-600`}):(0,Q.jsx)(lt,{className:`h-3 w-3`})})}),(0,Q.jsx)(ir,{children:y(ee?`detail.copied`:`detail.copyToClipboard`)})]})}):null]})]},e.name)},ae=u?.enabled===!0,j=u?.batchSize??20;if(Z.useEffect(()=>{if(!ae){g(void 0);return}if(re.length<=j){g(void 0);return}g(j);let e=setTimeout(()=>g(void 0),100);return()=>clearTimeout(e)},[ae,re.length,j]),ne.length===0&&T===e.fields.length)return null;let M=h===void 0?re:re.slice(0,h),N=T>0&&te,P=(0,Q.jsxs)(Q.Fragment,{children:[E?(0,Q.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60`,children:M.map(ie)}):(0,Q.jsx)(`div`,{className:X(`grid gap-3 sm:gap-4`,A===1?`grid-cols-1`:A===2?`grid-cols-1 md:grid-cols-2`:A===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:M.map(ie)}),N&&(0,Q.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,Q.jsxs)(Y,{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,Q.jsx)(Ze,{className:`h-3.5 w-3.5 mr-1.5`}):(0,Q.jsx)(Zt,{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,Q.jsx)(`div`,{className:X(n),children:P}):e.collapsible?(0,Q.jsx)(wr,{open:!d,onOpenChange:e=>f(!e),className:n,children:(0,Q.jsxs)(It,{children:[(0,Q.jsx)(it,{asChild:!0,children:(0,Q.jsxs)(Gn,{className:X(`py-3 px-4 sm:py-4 sm:px-6 cursor-pointer hover:bg-muted/50 transition-colors`,$i(e.headerColor)),children:[(0,Q.jsxs)(Mt,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,Q.jsx)(ea,{name:e.icon}),(0,Q.jsx)(`span`,{children:e.title})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:d?(0,Q.jsx)(rr,{className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(Rn,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!d&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,Q.jsx)(tn,{children:(0,Q.jsx)(Jn,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:P})})]})}):(0,Q.jsxs)(It,{className:X(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,Q.jsxs)(Gn,{className:X(`py-3 px-4 sm:py-4 sm:px-6`,$i(e.headerColor)),children:[(0,Q.jsx)(Mt,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,Q.jsx)(ea,{name:e.icon}),(0,Q.jsx)(`span`,{children:e.title})]})}),e.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]}),(0,Q.jsx)(Jn,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:P})]})},ra=({tabs:e,data:t,className:n})=>{let[r,i]=Z.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,Q.jsxs)(zr,{value:r,onValueChange:i,className:n,children:[(0,Q.jsx)(fn,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,Q.jsx)(gt,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,Q.jsx)(`span`,{children:e.icon}),(0,Q.jsx)(`span`,{children:e.label}),e.badge&&(0,Q.jsx)(Vt,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,Q.jsx)(Xe,{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,Q.jsx)(Z.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,Q.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,Q.jsx)(be,{schema:Te(e),data:t},n))}):(0,Q.jsx)(be,{schema:Te(e.content),data:t})})},e.key))]})};function ia(e){return kt(e)??Dt}function aa(e,t){let n=e?.id??e?._id;if(t){let r=H(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 oa(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 sa=({action:e,onToolbarAction:t})=>{let n=e.visible,r=w(j(n));if(n&&!r)return null;let i=e.icon?ia(e.icon):null;return(0,Q.jsxs)(Y,{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,Q.jsx)(i,{className:`h-3.5 w-3.5`}),e.label||e.name]})},ca=({title:e,type:t,api:n,data:r,schema:i,columns:a,className:s,dataSource:c,objectName:l,onNew:u,newDisabled:d,onViewAll:f,onRowEdit:p,onRowDelete:m,onRowClick:h,rowActions:b,onRowAction:x,toolbarActions:S,onToolbarAction:C,add:w,maxColumns:T=6,pageSize:E,defaultSort:D,sortable:O=!1,filter:ee,filterable:te=!1,collapsible:ne=!1,defaultCollapsed:re=!1,referenceField:k,parentId:A,icon:ie})=>{let ae=r!==void 0,j=r??[],[M,P]=Z.useState(j),[oe,F]=Z.useState(()=>!!n&&!ae),[I,se]=Z.useState(0),[L,R]=Z.useState(null),[le,ue]=Z.useState(`asc`),[de,pe]=Z.useState(``),[me,he]=Z.useState(null),[z,ge]=Z.useState(!1),[B,_e]=Z.useState(null),[ve,V]=Z.useState(re),[ye,H]=Z.useState(!1),[xe,U]=Z.useState(!1),[Ce,we]=Z.useState(null),[Te,De]=Z.useState(0),[Oe,ke]=Z.useState({}),{t:W}=$(),{fieldLabel:Ae}=Ie(),je=E&&E>0?E:0,Me=te&&de!==``,K=!ae&&!!n&&je>0&&!!c&&typeof c.find==`function`&&!Me,Ne=K?I:0,Pe=K?L:null,Fe=K?le:`asc`,Le=JSON.stringify(D??null),Re=Z.useMemo(()=>oa(D),[Le]),ze=JSON.stringify(ee??null),Be=Z.useMemo(()=>g(ee),[ze]);Z.useEffect(()=>{ae&&P(r??[])},[r,ae]),Z.useEffect(()=>{n&&c?.getObjectSchema&&c.getObjectSchema(n).then(_e).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,c]);let Ve=w?.picker?.object,[He,Ue]=Z.useState(null);Z.useEffect(()=>{if(!ye||!Ve||He||!c?.getObjectSchema)return;let e=!1;return c.getObjectSchema(Ve).then(t=>{e||Ue(t)}).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${Ve}:`,e)}),()=>{e=!0}},[ye,Ve,He,c]);let We=w?.picker?.labelField||`name`,Ge=Z.useMemo(()=>{let e=Et(He,{displayField:We});return e.length>0?e:void 0},[He,We]);Z.useEffect(()=>{!w||Ve||console.warn(`[RelatedList] "${n||l||`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.`)},[w,Ve,n,l]),Z.useEffect(()=>{let e=!1;if(n&&!ae){if(!(k&&A!=null&&A!==``)){n&&(A==null||A===``)&&!k&&console.warn(`[RelatedList] "${n}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),P([]),he(null),ge(!1),F(!1);return}F(!0);let t={[k]:A},r=Be===void 0?t:_(t,Be);if(c&&typeof c.find==`function`){let t={$filter:r};if(K){t.$top=je,t.$skip=Ne*je;let e=Pe?[{field:Pe,order:Fe}]:Re;e.length>0&&(t.$orderby=e)}c.find(n,t).then(t=>{if(e)return;let n=Array.isArray(t),r=n?t:Array.isArray(t?.data)?t.data:[];if(P(r),K){let e=!n&&typeof t?.total==`number`?t.total:null;he(e),ge(!n&&typeof t?.hasMore==`boolean`?t.hasMore:r.length===je)}else he(null),ge(!1);F(!1)}).catch(t=>{console.error(`Failed to fetch related data:`,t),e||F(!1)})}else if(Be!==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.`),P([]),he(null),ge(!1),F(!1);else{let t=new URLSearchParams({[`filter[${k}]`]:String(A)}).toString();fetch(`${n}?${t}`).then(e=>e.json()).then(t=>{if(e)return;let n=Array.isArray(t)?t:t?.data||[];P(n),he(null),ge(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>{e||F(!1)})}}return()=>{e=!0}},[n,ae,c,k,A,Te,K,je,Ne,Pe,Fe,Le,ze]),Z.useEffect(()=>{!K||oe||I>0&&M.length===0&&se(e=>Math.max(0,e-1))},[K,oe,M,I]),Z.useEffect(()=>{se(0)},[n,k,A,ze]),Z.useEffect(()=>{if(!n||ae)return;let e=e=>{let t=e.detail||{};t.objectName&&t.objectName!==`*`&&t.objectName!==n||De(e=>e+1)};return window.addEventListener(`objectui:related-changed`,e),()=>window.removeEventListener(`objectui:related-changed`,e)},[n,ae]),Z.useEffect(()=>{if(!c?.find||!B?.fields||!M.length)return;let e=B.fields,t=[];for(let[n,r]of Object.entries(e)){if(!r||r.type!==`lookup`&&r.type!==`master_detail`)continue;let e=r.reference;if(!e)continue;let i=new Set;for(let e of M){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=Oe[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([c.find(t,{$filter:{id:{$in:n}},$top:n.length}),typeof c.getObjectSchema==`function`?c.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)]=aa(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||ke(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[c,B,M]);let Ke=Z.useMemo(()=>{if(K||!de)return M;let e=de.toLowerCase();return M.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[M,de,K]),qe=Z.useMemo(()=>{if(K||!L)return Ke;let e=Oe[L],t=Ke.map(t=>({row:t,key:Ee(t[L],{labels:e})}));return t.sort((e,t)=>{let n=G(e.key,t.key);return le===`asc`?n:-n}),t.map(e=>e.row)},[Ke,L,le,K,Oe]),Je=je&&!K?qe.slice(I*je,(I+1)*je):qe,Ye=je?K?me==null?I+(z?2:1):Math.max(1,Math.ceil(me/je)):Math.max(1,Math.ceil(qe.length/je)):1,Xe=K?me==null?z:(I+1)*je<me:I<Ye-1,Ze=je>0&&(K?I>0||Xe:qe.length>je);Z.useEffect(()=>{se(0)},[de,L,le]);let Qe=Z.useCallback(e=>{se(0),L===e?ue(e=>e===`asc`?`desc`:`asc`):(R(e),ue(`asc`))},[L]),J=Z.useMemo(()=>L?[{field:L,order:le}]:Re,[L,le,Re]),et=Z.useCallback(e=>{let t=e[0];t&&(se(0),R(t.field),ue(t.order))},[]),[tt,nt]=Z.useState(null),rt=Z.useCallback(e=>{nt(e)},[]),it=Z.useCallback(async()=>{if(tt)try{await m?.(tt),De(e=>e+1)}catch(e){console.error(`[RelatedList] remove failed`,e)}nt(null)},[tt,m]),at=Z.useCallback(async e=>{if(!w||!c||!n||k==null||A==null)return;let t=w.picker.valueField||`id`;U(!0),we(null);try{for(let r of e||[]){let e=r?.[t]??r?.id;e!=null&&(w.linkField?await c.create?.(n,{[k]:A,[w.linkField]:e}):await c.update?.(w.picker.object,String(e),{[k]:A}))}De(e=>e+1)}catch(e){let t=e?.body?.error??e?.error??e?.message??String(e);we(typeof t==`string`?t:`Failed to add`)}finally{U(!1),H(!1)}},[w,c,n,k,A]),ot=o(),st=Z.useMemo(()=>{let e=l||n||``,t=t=>!ot?.isLoaded||!e?t:t.filter(t=>{let n=t?.accessorKey||q(t);return!n||ot.checkField(e,String(n),`read`)}),r=e=>k?e.filter(e=>(e?.accessorKey||q(e))!==k):e,i=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,o=e=>M.length?e.filter(e=>{let t=e?.accessorKey||q(e);return!t||M.some(e=>!i(e?.[t]))}):e,s=(e,t)=>{if(!t?.type)return;let n=Fn({type:t.type,format:t.format})||t.type,r=Mn(n);if(!r)return;let i=t.type===`lookup`||t.type===`master_detail`?Oe[e]:void 0,a=i&&Object.keys(i).length>0?Object.entries(i).map(([e,t])=>({value:e,label:t})):void 0,o={name:e,label:t.label||e,type:t.type,...(a||t.options)&&{options:a||t.options},...t.currency&&{currency:t.currency},...t.precision!==void 0&&{precision:t.precision},...t.scale!==void 0&&{scale:t.scale},...t.format&&{format:t.format},...t.reference&&{reference_to:t.reference},...t.reference_field&&{reference_field:t.reference_field}};return e=>e==null?Z.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):Z.createElement(r,{value:e,field:o})},c=t=>{if(typeof t!=`string`){let e=t?.accessorKey||q(t);if(!t||!e)return t;let n={};if(t.accessorKey||(n.accessorKey=e),!t.header){let e=ce(t);e&&(n.header=e)}if(!t.cell&&!t.render){let t=B?.fields?.[e],r=t?s(String(e),t):void 0;r&&(n.cell=r)}return Object.keys(n).length>0?{...t,...n}:t}let n=B?.fields?.[t],r={accessorKey:t,header:n?.label||Ae(e,t,n)||t,fieldDef:n,fieldType:n?.type},i=n?s(t,n):void 0;return i&&(r.cell=i),r};if(a&&a.length>0)return o(t(r(a.map(c))));if(!B?.fields)return[];let u=Array.isArray(B.highlightFields)?B.highlightFields.filter(e=>typeof e==`string`&&e.length>0):[];if(u.length>0){let e=o(t(r(u.map(c))));if(e.length>0)return e.slice(0,Math.max(1,T))}let d=e,f=new Set([`richtext`,`markdown`,`html`,`json`]),p=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],m=Object.entries(B.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===k||t?.hidden||t?.type&&f.has(t.type)||ot?.isLoaded&&d&&!ot.checkField(d,e,`read`))),h=new Set([`created_at`,`updated_at`,`created_by`,`updated_by`,`owner_id`,`organization_id`]);return m.sort(([e,t],[n,r])=>{let i=h.has(e);if(i!==h.has(n))return i?1:-1;let a=p.indexOf(e),o=p.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}),o(m.map(([e,t])=>{let n={accessorKey:e,header:Ae(d,e,t.label||e)};if(t.type){let r=s(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,T))},[a,B,l,n,Ae,k,M,T,Oe,ot]),ct=v(B),lt=Z.useCallback((e,t)=>N(t)?!0:ct?!y(ct,e):Se(t),[ct]),ut=Z.useMemo(()=>K?st.map(e=>{let t=e.accessorKey||q(e),n=t?B?.fields?.[t]:void 0;return lt(t,n)?{...e,sortable:!1}:e}):st,[st,K,B,lt]),dt=!i&&(t===`grid`||t===`table`),pt=Array.isArray(b)&&b.length>0,mt=!!p||!!m||pt,gt=bn(),_t=Z.useMemo(()=>{if(i)return i;if(gt&&(t===`grid`||t===`table`)){let e=st[0]?.accessorKey||q(st[0]),t=st.slice(1,4).map(e=>e.accessorKey||q(e)).filter(Boolean);return{type:`object-gallery`,data:Je,objectName:n,gallery:{titleField:e||`name`,visibleFields:t,cardSize:`medium`},onRowClick:h}}let e=fe(B?.userActions?.edit),r=fe(B?.userActions?.delete);switch(t){case`grid`:case`table`:return{type:`data-table`,data:Je,columns:ut,pagination:!1,pageSize:je||10,searchable:!1,exportable:!1,manualSorting:!0,sort:J,onSortChange:et,rowActions:mt,onRowEdit:p,onRowDelete:m?rt:void 0,rowEditPredicates:e,rowDeletePredicates:r,onRowClick:h,rowActionDefs:pt?b:void 0,onRowActionDef:pt?x:void 0};case`list`:return{type:`data-list`,data:Je};default:return{type:`div`,children:`No view configured`}}},[t,Je,ut,st,i,je,mt,pt,b,x,p,m,rt,h,gt,n,B,J,et]),vt=ne?`cursor-pointer select-none`:void 0,yt=ne?()=>V(e=>!e):void 0,xt=ia(ie),Ct=K&&me!=null?me:M.length,wt=!oe&&M.length===0&&(!K||I===0),Dt=te;return(0,Q.jsxs)(It,{className:X(`shadow-none border-border/60 bg-transparent`,wt&&`bg-muted/10`,s),children:[(0,Q.jsx)(Gn,{className:X(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,vt),onClick:yt,children:(0,Q.jsxs)(Mt,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[ne&&(ve?(0,Q.jsx)(rr,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Q.jsx)(Rn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,Q.jsx)(xt,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:X(`truncate`,wt&&`text-muted-foreground font-medium`),children:e}),(0,Q.jsx)(Vt,{variant:`secondary`,className:X(`text-xs font-normal h-5 px-1.5`,Ct===0&&`bg-muted text-muted-foreground`),"aria-label":`${Ct} records`,children:Ct}),wt&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:W(`detail.noRelatedRecords`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[C&&(S??[]).map(e=>(0,Q.jsx)(sa,{action:e,onToolbarAction:C},e.name)),w&&Ve&&c&&(0,Q.jsxs)(Y,{variant:wt?`ghost`:`outline`,size:`sm`,disabled:xe,onClick:e=>{e.stopPropagation(),we(null),H(!0)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,Q.jsx)($e,{className:`h-3.5 w-3.5`}),w.label||W(`detail.add`,{defaultValue:`Add`})]}),u&&(0,Q.jsxs)(Y,{variant:wt?`ghost`:`outline`,size:`sm`,disabled:d,"data-testid":`related-list-new`,onClick:e=>{e.stopPropagation(),u()},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,Q.jsx)($e,{className:`h-3.5 w-3.5`}),W(`detail.new`)]})]})]})}),!ve&&!wt&&(0,Q.jsxs)(Jn,{className:X(`pt-0 pb-4 px-4`),children:[Dt&&(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(bt,{placeholder:W(`detail.filterPlaceholder`),value:de,onChange:e=>pe(e.target.value),className:`h-8 text-sm`})}),O&&!dt&&st&&st.length>0&&M.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:st.map(e=>{let t=e.accessorKey||q(e);if(!t)return null;let n=B?.fields?.[t];if(K&<(t,n))return null;let r=e.header||e.label||t,i=L===t;return(0,Q.jsxs)(Y,{variant:i?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>Qe(t),children:[(0,Q.jsx)(_n,{className:`h-3 w-3`}),r,i&&(le===`asc`?` ↑`:` ↓`)]},t)})}),oe&&M.length===0?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:W(`detail.loading`)}):(0,Q.jsx)(`div`,{className:X(oe&&`opacity-60 pointer-events-none transition-opacity`),children:(0,Q.jsx)(be,{schema:_t})}),Ze&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:I===0,onClick:()=>se(e=>Math.max(0,e-1)),children:[(0,Q.jsx)(Zn,{className:`h-3 w-3`}),W(`detail.previousPage`)]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(`detail.pageOf`,{current:I+1,total:Ye})}),(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:!Xe,onClick:()=>se(e=>Xe?e+1:e),children:[W(`detail.nextPage`),(0,Q.jsx)(rr,{className:`h-3 w-3`})]})]}),f&&!wt&&Ze&&(0,Q.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),f()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[W(`detail.viewAll`),(0,Q.jsx)(Tr,{className:`h-3 w-3`})]})})]}),(0,Q.jsx)(dn,{open:tt!==null,onOpenChange:e=>{e||nt(null)},children:(0,Q.jsxs)(hn,{children:[(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(St,{children:W(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,Q.jsx)(ft,{children:W(`detail.deleteRowConfirmation`)})]}),(0,Q.jsxs)(Tt,{children:[(0,Q.jsx)(on,{children:W(`detail.cancel`,{defaultValue:`Cancel`})}),(0,Q.jsx)(ht,{onClick:it,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:W(`detail.delete`,{defaultValue:`Delete`})})]})]})}),Ce&&(0,Q.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:Ce}),w&&Ve&&c&&(0,Q.jsx)(Ut,{open:ye,onOpenChange:e=>H(e),multiple:!0,dataSource:c,objectName:Ve,title:w.label||W(`detail.add`,{defaultValue:`Add`}),displayField:We,columns:Ge,cellRenderer:Mn,fieldsMeta:He?.fields,baseFilter:w.picker.filter,onSelect:()=>{},onSelectRecords:e=>{at(e)}})]})},la=({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]=Z.useState(e.defaultCollapsed??!1),p=(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,Q.jsx)(na,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l},n))});return u?(0,Q.jsxs)(wr,{open:!d,onOpenChange:e=>f(!e),className:n,children:[(0,Q.jsx)(it,{asChild:!0,children:(0,Q.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,Q.jsx)(rr,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(Rn,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!d&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,Q.jsx)(tn,{children:(0,Q.jsx)(`div`,{className:`mt-3`,children:p})})]}):(0,Q.jsxs)(`div`,{className:X(`space-y-3`,n),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),p]})},ua=({fields:e,data:t,className:n,objectName:r,objectSchema:i,dataSource:a})=>{let{fieldLabel:o}=Ie(),{t:s}=$(),c=z(),l=c?.editing??!1,u=c?.canEdit??!1;if(!e.length||!t)return null;let d=l?e:e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return d.length===0?null:(0,Q.jsx)(Qn,{children:(0,Q.jsx)(`section`,{className:X(`@container border-b border-border/60 pb-4`,n),"aria-label":`Record highlights`,children:(0,Q.jsx)(`div`,{className:X(`flex flex-wrap gap-y-4`),children:d.map(e=>{let n=t[e.name],d=i?.fields?.[e.name],f=e.type||d?.type,p=Ki({name:e.name,label:e.label,type:f||`text`},d),m=c?.draft?.[e.name],h=m===void 0?n:m,g=Vi(e.type,d?.type),_=e.readonly===!0||d?.readonly===!0,v=zi.has(e.name),y=Ui(e.type,d?.type),b=u&&!g&&!_&&!v&&!y,x=l&&b,S=Mn(Fn(p)||f||`text`),C=f===`number`||f===`integer`||f===`currency`||f===`percent`||f===`decimal`,w=f===`email`||f===`url`||f===`textarea`||!!f&&O.has(f),T=f===`boolean`,E=h==null||h===``;return(0,Q.jsxs)(`div`,{className:X(`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,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:o(r||``,e.name,e.label)}),x?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Zi,{field:p,value:h,onChange:t=>c.setField(e.name,t),dataSource:a,autoFocus:c.autoFocusField===e.name,error:c.fieldErrors?.[e.name]}),c.fieldErrors?.[e.name]&&(0,Q.jsx)(`p`,{role:`alert`,"data-inline-field-hint":e.name,className:`mt-1 text-xs text-destructive`,children:c.fieldErrors[e.name]})]}):(0,Q.jsxs)(`div`,{className:X(`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,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:T?h?(0,Q.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,Q.jsx)(In,{className:`h-3 w-3`,"aria-hidden":!0}),`Yes`]}):(0,Q.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,Q.jsx)(tr,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):E?(0,Q.jsx)(`span`,{className:`block text-sm text-muted-foreground/60 select-none`,"aria-label":s(`detail.noValue`,{defaultValue:`No value`}),children:`—`}):(0,Q.jsx)(`span`,{title:(Array.isArray(p.options)?p.options.find(e=>e?.value===h)?.label:void 0)??(typeof h==`string`||typeof h==`number`?String(h):void 0),className:X(`block min-w-0 truncate text-sm font-semibold`,C&&`tabular-nums tracking-tight`),children:(0,Q.jsx)(S,{value:h,field:p})})}),b&&(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsx)(Y,{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,Q.jsx)(zt,{className:`h-3 w-3`})})}),(0,Q.jsx)(ir,{children:s(`detail.editInlineHint`)})]})]})]},e.name)})})})})};function da(e,t){try{let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`detail.justNow`);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return t(`detail.hoursAgo`,{count:a});let o=Math.floor(a/24);return o<7?t(`detail.daysAgo`,{count:o}):n.toLocaleDateString()}catch{return e}}var fa=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=$(),[o,s]=Z.useState(``),[c,l]=Z.useState(!1),[u,d]=Z.useState(``),f=Z.useCallback(async()=>{let e=o.trim();if(!(!e||!t)){l(!0);try{await t(e),s(``)}finally{l(!1)}}},[o,t]),p=Z.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]),m=Z.useMemo(()=>[...u.trim()?e.filter(e=>{let t=u.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,u]);return(0,Q.jsxs)(It,{className:X(``,i),children:[(0,Q.jsx)(Gn,{children:(0,Q.jsxs)(Mt,{className:`flex items-center gap-2 text-base`,children:[(0,Q.jsx)(fr,{className:`h-4 w-4`}),a(`detail.comments`),(0,Q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,Q.jsxs)(Jn,{className:`space-y-4`,children:[r&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Q.jsx)(Sn,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Q.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:u,onChange:e=>d(e.target.value),"aria-label":a(`detail.searchComments`)}),u&&(0,Q.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>d(``),"aria-label":a(`detail.clearSearch`),type:`button`,children:(0,Q.jsx)(tr,{className:`h-3.5 w-3.5`})})]})}),t&&(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.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:o,onChange:e=>s(e.target.value),onKeyDown:p,disabled:c}),(0,Q.jsx)(Y,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,Q.jsx)(Hn,{className:`h-4 w-4`})})]}),m.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:u.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:m.map(e=>(0,Q.jsxs)(`div`,{className:X(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,Q.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,Q.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,Q.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,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:da(e.createdAt,a)}),e.pinned&&(0,Q.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,Q.jsx)(Ge,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,Q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,Q.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,Q.jsx)(Ge,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},pa={field_change:mt,create:An,delete:Yt,comment:fr,status_change:vn},ma={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 ha(e,t){try{let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`detail.justNow`);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return t(`detail.hoursAgo`,{count:a});let o=Math.floor(a/24);return o<7?t(`detail.daysAgo`,{count:o}):n.toLocaleDateString()}catch{return e}}function ga(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 _a=[`all`,`field_change`,`create`,`delete`,`comment`,`status_change`];function va(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 ya=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let{t:i}=$(),[a,o]=Z.useState(n),s=Z.useMemo(()=>a===`all`?e:e.filter(e=>e.type===a),[e,a]);return(0,Q.jsxs)(It,{className:X(``,r),children:[(0,Q.jsx)(Gn,{children:(0,Q.jsxs)(Mt,{className:`flex items-center gap-2 text-base`,children:[(0,Q.jsx)(dr,{className:`h-4 w-4`}),i(`detail.activity`),(0,Q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,s.length,`)`]})]})}),(0,Q.jsxs)(Jn,{children:[t&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":i(`detail.filterActivity`),children:_a.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:X(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,a===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>o(e),"aria-pressed":a===e,children:[e!==`all`&&Z.createElement(pa[e]||mt,{className:`h-3 w-3`}),va(e,i)]},e))}),s.length===0?(0,Q.jsx)(Un,{title:i(`detail.noActivity`),className:`py-6`}):(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:s.map(e=>{let t=pa[e.type]||mt,n=ma[e.type]||`bg-gray-100 text-gray-600`;return(0,Q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,Q.jsx)(`div`,{className:X(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:(0,Q.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:ga(e,i)})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:ha(e.timestamp,i)})]})]},e.id)})})]})]})]})},ba={create:`default`,update:`secondary`,delete:`destructive`,login:`outline`,logout:`outline`,config_change:`secondary`,import:`outline`};function xa(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var Sa=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function Ca(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 Sa){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return xa(e)}r/=n}return xa(e)}function wa(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 Ta(e){if(e==null||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 Ea({entries:e,loading:t,emptyText:n,unknownUserText:r,className:i,locale:a}){return t?(0,Q.jsx)(`div`,{className:X(`space-y-3`,i),children:Array.from({length:4}).map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Ln,{className:`h-8 w-8 rounded-full`}),(0,Q.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,Q.jsx)(Ln,{className:`h-4 w-1/3`}),(0,Q.jsx)(Ln,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,Q.jsx)(`div`,{className:X(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,i),children:n??`No history yet`}):(0,Q.jsx)(Qn,{delayDuration:150,children:(0,Q.jsx)(`ol`,{className:X(`space-y-4`,i),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),i=ba[n]??`outline`,o=typeof e.user_name==`string`&&e.user_name.trim()||r||`Unknown user`,s=xa(e.created_at),c=Ca(e.created_at,a),l=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,Q.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(ct,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[l?(0,Q.jsx)(Ot,{src:l,alt:o}):null,(0,Q.jsx)(xt,{className:`text-[10px] font-medium`,children:wa(e.user_name)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:o}),e.action&&(0,Q.jsx)(Vt,{variant:i,className:`text-[10px] uppercase tracking-wide`,children:e.action}),s&&(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":s,children:c||s})}),(0,Q.jsx)(ir,{children:s})]})]}),e.summary&&(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(n===`create`?(0,Q.jsxs)(`details`,{className:`mt-1 group`,children:[(0,Q.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,Q.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▸`}),(0,Q.jsx)(`span`,{children:e.changes.length===1?`1 field populated`:`${e.changes.length} fields populated`})]}),(0,Q.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground pl-4`,children:e.changes.map(e=>(0,Q.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,Q.jsx)(`span`,{className:`text-foreground`,children:Ta(e.to)})]},e.field))})]}):(0,Q.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,Q.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,Q.jsx)(`span`,{className:`line-through opacity-70`,children:Ta(e.from)}),` → `,(0,Q.jsx)(`span`,{className:`text-foreground`,children:Ta(e.to)})]},e.field))}))]})]},e.id??t)})})})}var Da=B;function Oa(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 ka(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 Aa(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var ja=({value:e,objectSchema:t,fieldName:n})=>{if(e==null||e===``)return null;let r=t?.fields?.[n],i=r?.reference||`sys_user`,a={name:n,type:r?.type||`lookup`,reference_to:i,...r?.reference_field&&{reference_field:r.reference_field}},o=Fn(a)||a.type;if(o){let t=Mn(o);if(t)return(0,Q.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:Z.createElement(t,{value:e,field:a})})}return(0,Q.jsx)(`span`,{children:String(e)})},Ma=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a})=>{if(!t&&!n)return null;let o=n?(0,Q.jsx)(Qn,{delayDuration:200,children:(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:ka(n,a)})}),(0,Q.jsx)(ir,{side:`top`,children:Aa(n)})]})}):null;return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,Q.jsx)(ja,{value:t,objectSchema:r,fieldName:i}):null,t&&o?(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,o]})},Na=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=$();if(!e)return null;let a=Oa(e[Da.createdAt]),o=Oa(e[Da.updatedAt]),s=e[Da.createdBy],c=e[Da.updatedBy],l=!!(a||s),u=a&&o&&Math.abs(o.getTime()-a.getTime())<2e3,d=!!(o||c)&&!(u&&(s!=null&&c!=null&&String(s)===String(c)||!c));return!l&&!d?null:(0,Q.jsxs)(`div`,{className:X(`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:[l&&(0,Q.jsx)(Ma,{label:i(s?`detail.createdBy`:`detail.created`),user:s,date:a,objectSchema:t,userField:Da.createdBy,t:i}),d&&(0,Q.jsx)(Ma,{label:i(c?`detail.updatedBy`:`detail.updated`),user:c,date:o,objectSchema:t,userField:Da.updatedBy,t:i})]})},Pa=new Map;function Fa(e,t,n=`update`,r=!0){let i=e&&t?`${e}:${t}:${n}`:``,[a,o]=Z.useState(()=>i&&Pa.has(i)?Pa.get(i):!0),s=Z.useContext(oe)?.apiFetch;return Z.useEffect(()=>{if(!r||!i){o(!0);return}if(Pa.has(i)){o(Pa.get(i));return}let a=!1;return(async()=>{try{let r=await(s??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 c=(await r.json())?.record?.visible;if(typeof c!=`boolean`)return;Pa.set(i,c),a||o(c)}catch{}})(),()=>{a=!0}},[i,e,t,n,r,s]),a}var Ia=5,La={};function Ra(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=W(n?.titleFormat,e);if(r)return r}if(e&&typeof e==`object`){let t=e.id??e._id,r=H(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=H(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 za=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:s=!1,discussionSlot:c,rightRail:l,objectLabel:u,onDataLoaded:d,isFavorite:f,onToggleFavorite:p})=>{let[m,h]=Z.useState(e.data),[g,_]=Z.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[v,y]=Z.useState(!1),b=f??v,x=z(),S=x?.editing??!1,C=x?.draft??La,w=x?.autoFocusField??null,[T,E]=Z.useState(null),[O,ee]=Z.useState(null),[te,ne]=Z.useState(!1),[re,k]=Z.useState(0),ie=Ne(e.objectName||void 0,e.resourceId==null?void 0:String(e.resourceId)),[ae,j]=Z.useState(!1),{t:M}=$(),{currency:N}=Le(),{fieldOptionLabel:P}=Ie(),oe=bn(),F=o(),I=Z.useMemo(()=>{if(!F?.isLoaded||!e.objectName)return e;let t=t=>F.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,F]),se=Z.useMemo(()=>!F?.isLoaded||!e.objectName||F.can(e.objectName,`update`),[F,e.objectName]),L=Z.useMemo(()=>!F?.isLoaded||!e.objectName||F.can(e.objectName,`delete`),[F,e.objectName]),R=e.resourceId==null?void 0:String(e.resourceId),ce=Fa(e.objectName,R,`update`,se),le=Fa(e.objectName,R,`delete`,L),ue=Z.useMemo(()=>fe(O?.userActions?.edit),[O]),de=Z.useMemo(()=>fe(O?.userActions?.delete),[O]),pe=O?.fields,me=D(ue?.visibleWhen??!0,m,{fallback:!1,warnOnError:!0,label:`builtin:edit:visibleWhen`,fields:pe}),he=D(de?.visibleWhen??!0,m,{fallback:!1,warnOnError:!0,label:`builtin:delete:visibleWhen`,fields:pe}),ge=D(ue?.disabledWhen,m,{fallback:!1,warnOnError:!0,label:`builtin:edit:disabledWhen`,fields:pe}),B=D(de?.disabledWhen,m,{fallback:!1,warnOnError:!0,label:`builtin:delete:disabledWhen`,fields:pe}),_e=ue?.disabledWhen!=null&&ge,ve=de?.disabledWhen!=null&&B,V=Z.useMemo(()=>({...I,showEdit:I.showEdit&&se&&ce&&me,showDelete:I.showDelete&&L&&le&&he}),[I,se,ce,me,L,le,he]);Z.useEffect(()=>{m&&d&&d(m)},[m,d]);let ye=Z.useMemo(()=>{if(V.summaryFields&&V.summaryFields.length>0)return[];let e=[...V.sections?.flatMap(e=>e.fields)||[],...V.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(O?.fields)for(let[e,n]of Object.entries(O.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>m?.[e]!==void 0&&m?.[e]!==null&&m?.[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},[V.summaryFields,V.sections,V.fields,O,m]),H=V.summaryFields&&V.summaryFields.length>0?V.summaryFields:ye,xe=Z.useCallback(()=>{V.resourceId&&navigator.clipboard.writeText(String(V.resourceId)).then(()=>{ne(!0),setTimeout(()=>ne(!1),1500)})},[V.resourceId]);Z.useEffect(()=>{let e=!0;if(V.data)return h(V.data),_(!1),t?.getObjectSchema&&V.objectName&&t.getObjectSchema(V.objectName).then(t=>{e&&ee(t)}).catch(()=>{}),()=>{e=!1};if(t&&V.objectName&&V.resourceId){_(!0),ee(null),h(null);let n=V.objectName,r=V.resourceId,i=`${n}-`,a=[...V.sections?.flatMap(e=>e.fields)||[],...V.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;ee(o);let s=A(o?.fields,a),c=F?.isLoaded?s.filter(e=>F.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&&(h(t),_(!1))}).catch(()=>{e&&(h(null),_(!1))})};return u.catch(()=>null).then(t=>{if(e){if(t){h(t),_(!1);return}return d()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),_(!1))})}else V.api&&V.resourceId&&(_(!0),fetch(`${V.api}/${V.resourceId}`).then(e=>e.json()).then(t=>{e&&h(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&_(!1)}));return()=>{e=!1}},[V.api,V.resourceId,V.objectName,t,V.sections,V.fields,re,ie,F]);let Se=Z.useCallback(()=>{if(a)a();else if(V.onNavigate){let e=V.backUrl||(V.objectName?`/${V.objectName}`:`/`);V.onNavigate(e,{replace:!0})}else V.backUrl?window.location.href=V.backUrl:window.history.back()},[a,V]),U=Z.useCallback(()=>{r?r():V.onNavigate&&V.editUrl?V.onNavigate(V.editUrl):V.onNavigate&&V.objectName&&V.resourceId?V.onNavigate(`/${V.objectName}/${V.resourceId}/edit`):V.editUrl&&(window.location.href=V.editUrl)},[r,V]),Ce=Z.useCallback(async()=>{if(!t?.cancelPendingApproval||!V.objectName||!V.resourceId){E(M(`detail.cancelApprovalUnavailable`));return}j(!0),E(null);try{if(await t.cancelPendingApproval(String(V.objectName),String(V.resourceId)),t.findOne)try{let e=await t.findOne(String(V.objectName),String(V.resourceId));e&&h(e)}catch{}k(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(V.objectName),recordId:String(V.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*/,``);E(`${M(`detail.cancelApprovalFailed`)}: ${t}`)}finally{j(!1)}},[t,V.objectName,V.resourceId,M]),we=Z.useCallback(()=>{let e=V.deleteConfirmation||M(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),V.onNavigate&&V.objectName&&V.onNavigate(`/${V.objectName}`,{replace:!0}))},[i,V]),Ee=Z.useCallback(()=>{navigator.share&&V.objectName&&V.resourceId?navigator.share({title:V.title||M(`detail.details`),text:`${V.objectName} #${V.resourceId}`,url:window.location.href}).catch(e=>{console.error(`Share failed:`,e)}):navigator.clipboard.writeText(window.location.href)},[V]),De=Z.useCallback(()=>{let e=!b;p&&p(e),f===void 0&&y(e)},[b,f,p]),Oe=x?.setField,ke=x&&x.canEdit?x.enter:void 0;Z.useEffect(()=>{if(!V.recordNavigation)return;let e=V.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)},[V.recordNavigation]);let W=Z.useMemo(()=>V.related??[],[V.related]),Ae=Z.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:M(`detail.share`),icon:`share-2`,type:`script`,onClick:Ee}),V.showEdit&&e.push({name:`sys_edit_mobile`,label:M(`detail.edit`),icon:`square-pen`,type:`script`,className:`sm:hidden`,..._e?{disabled:!0}:null,onClick:U}),V.showDelete&&e.push({name:`sys_delete`,label:M(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],...ve?{disabled:!0}:null,onClick:we}),e},[M,V.showEdit,V.showDelete,_e,ve,Ee,U,we]),G=Z.useMemo(()=>{let e=V.actions??[];if(Ae.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,...Ae]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:Ae}),n},[V.actions,Ae]);return g||V.loading?(0,Q.jsxs)(`div`,{className:X(`space-y-4`,n),children:[(0,Q.jsx)(Ln,{className:`h-10 w-full`}),(0,Q.jsx)(Ln,{className:`h-64 w-full`}),(0,Q.jsx)(Ln,{className:`h-48 w-full`})]}):!m&&!V.data?(0,Q.jsxs)(`div`,{className:X(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,Q.jsx)(`p`,{className:`text-lg font-semibold`,children:M(`detail.recordNotFound`)}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:M(`detail.recordNotFoundDescription`)}),(V.showBack??!0)&&(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:Se,className:`mt-4 gap-2`,children:[(0,Q.jsx)(Ht,{className:`h-4 w-4`}),M(`detail.goBack`)]})]}):(0,Q.jsx)(Qn,{children:(0,Q.jsxs)(`div`,{className:X(`space-y-6`,n),children:[V.showHeader!==!1&&(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(V.showBack??!0)&&(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,onClick:Se,className:`shrink-0 mt-1`,children:(0,Q.jsx)(Ht,{className:`h-4 w-4`})})}),(0,Q.jsx)(ir,{children:M(`detail.back`)})]}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:Ra(m,V,O,M(`detail.details`))}),H.map(e=>{let t=m?.[e];if(t==null||t===``)return null;let n=(V.sections||[]).flatMap(e=>e.fields).concat(V.fields||[]).find(t=>t.name===e),r=O?.fields?.[e],i=n?.type||r?.type,a=String(t),o=null;try{if(i===`currency`){let e=Number(t);if(!Number.isNaN(e)){let t=ze({...r,...n},N);a=t?new Intl.NumberFormat(void 0,{style:`currency`,currency:t,maximumFractionDigits:0}).format(e):new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)}}else if(i===`date`||i===`datetime`){let e=new Date(t);Number.isNaN(e.getTime())||(a=i===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(i===`percent`){let e=Number(t);if(!Number.isNaN(e)){a=`${e}%`;let t=e<=1?e*100:e;o=Math.max(0,Math.min(100,t))}}else if(i===`select`||i===`status`||i===`multiselect`){let i=n?.options||r?.options,o=String(t);if(Array.isArray(i)){let e=i.find(e=>String(e?.value??e)===String(t));e?.label&&(o=e.label)}else if(i&&typeof i==`object`){let e=i[String(t)];e?.label&&(o=e.label)}a=V.objectName?P(V.objectName,e,String(t),o):o}}catch{}return o===null?(0,Q.jsx)(Vt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${e}: ${a}`,children:a},e):(0,Q.jsxs)(Vt,{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":`${e}: ${a}`,children:[(0,Q.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,Q.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${o}%`}})}),a]},e)}),(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:De,"aria-label":M(b?`detail.removeFromFavorites`:`detail.addToFavorites`),children:b?(0,Q.jsx)(Wt,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,Q.jsx)(Wt,{className:`h-4 w-4 text-muted-foreground`})})}),(0,Q.jsx)(ir,{children:M(b?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),V.objectName&&(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:u||V.objectName}),V.resourceId&&(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:xe,"aria-label":M(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:te?(0,Q.jsx)(In,{className:`h-3 w-3 text-green-600`}):(0,Q.jsx)(lt,{className:`h-3 w-3`})})}),(0,Q.jsx)(ir,{children:te?M(`detail.copied`,{defaultValue:`Copied!`}):M(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[V.recordNavigation&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:V.recordNavigation.currentIndex<=0,onClick:()=>{let e=V.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,Q.jsx)(Zn,{className:`h-4 w-4`})})}),(0,Q.jsx)(ir,{children:M(`detail.previousRecord`)})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:M(`detail.recordOf`,{current:V.recordNavigation.currentIndex+1,total:V.recordNavigation.recordIds.length})}),(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:V.recordNavigation.currentIndex>=V.recordNavigation.recordIds.length-1,onClick:()=>{let e=V.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,Q.jsx)(rr,{className:`h-4 w-4`})})}),(0,Q.jsx)(ir,{children:M(`detail.nextRecord`)})]})]}),V.showEdit&&(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(Bn,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`default`,disabled:_e,onClick:()=>{_e||U()},className:`gap-2 hidden sm:inline-flex`,children:[(0,Q.jsx)(mt,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:M(`detail.edit`)})]})}),(0,Q.jsx)(ir,{children:M(`detail.editRecord`)})]}),G.map((e,t)=>(0,Q.jsx)(be,{schema:Te(e),data:m},`header-action-${t}`))]})]}),V.header&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(be,{schema:Te(V.header),data:m})}),V.highlightFields&&V.highlightFields.length>0&&(0,Q.jsx)(ua,{fields:V.highlightFields,data:m,objectName:V.objectName,objectSchema:O}),s&&V.showHeader===!1&&(()=>{let e=m?.approval_status,n=e===`pending`||e===`in_approval`,r=x?.approvalPending??!1,i=r&&!(x?.locked??!1)?!1:(x?.locked??!1)||n,a=i||r||n,o=a?x?.approvalProgress:void 0,s=!!o&&o.need>0&&o.need<=12;return!a&&!T?null:(0,Q.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[a&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Q.jsxs)(`span`,{role:`status`,className:i?`inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800`:`inline-flex items-center gap-1 rounded-md border border-sky-300 bg-sky-50 px-2 py-1 text-xs text-sky-800`,title:i?x?.lockedReason??M(`detail.lockedTooltip`):M(`detail.approvalPendingTooltip`),children:[i?(0,Q.jsx)(xn,{className:`h-3 w-3`}):(0,Q.jsx)(sn,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:M(i?`detail.lockedByApproval`:`detail.approvalPendingEditable`)})]}),t?.cancelPendingApproval&&x?.approvalIsSubmitter!==!1&&(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:Ce,disabled:ae,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:M(i?`detail.cancelApprovalTooltip`:`detail.cancelApprovalTooltipUnlocked`),children:[(0,Q.jsx)(tr,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:M(ae?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),o&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-end gap-1 max-w-[16rem]`,children:[(0,Q.jsxs)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":o.need,"aria-valuenow":Math.min(o.got,o.need),"aria-label":M(`detail.approvalProgressLabel`),className:`flex items-center gap-2 w-full justify-end`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground whitespace-nowrap`,children:o.behavior===`per_group`?M(`detail.approvalProgressGroups`,{got:o.got,need:o.need}):M(`detail.approvalProgress`,{got:o.got,need:o.need})}),s&&(0,Q.jsx)(`span`,{className:`flex items-center gap-1 w-20 shrink-0`,children:Array.from({length:o.need}).map((e,t)=>(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:X(`h-1.5 flex-1 rounded-full`,t<o.got?`bg-emerald-500`:`bg-muted`)},t))})]}),o.groups&&o.groups.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:o.groups.map(e=>(0,Q.jsxs)(`span`,{title:`${e.got}/${e.need}`,className:X(`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,Q.jsx)(In,{className:`h-3 w-3`}):(0,Q.jsx)(Ct,{className:`h-2.5 w-2.5`}),(0,Q.jsx)(`span`,{children:`${e.group} ${e.got}/${e.need}`})]},e.group))})]}),T&&(0,Q.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:T})]})})(),V.autoTabs&&!V.tabs?.length?(()=>{let e=W.length>0,n=!!V.activities&&V.activities.length>0,r=!!c,i=!!V.history,a=[`details`,...e?[`related`]:[],...n?[`activity`]:[],...r?[`discussion`]:[],...i?[`history`]:[]],o=V.defaultTab,l=o&&a.includes(o)?o:`details`,u=V.onTabChange,d=(0,Q.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[V.sectionGroups&&V.sectionGroups.length>0&&V.sectionGroups.map((e,n)=>(0,Q.jsx)(la,{group:e,data:{...m,...C},objectSchema:O,objectName:V.objectName,isEditing:S,onFieldChange:Oe,onEnterInlineEdit:s?ke:void 0,autoFocusField:w,dataSource:t},n)),V.sections&&V.sections.length>0&&V.sections.map((e,n)=>(0,Q.jsx)(na,{section:e,data:{...m,...C},objectSchema:O,objectName:V.objectName,isEditing:S,onFieldChange:Oe,onEnterInlineEdit:s?ke:void 0,autoFocusField:w,dataSource:t},n)),V.fields&&V.fields.length>0&&!V.sections?.length&&(0,Q.jsx)(na,{section:{fields:V.fields,columns:V.columns},data:{...m,...C},objectSchema:O,objectName:V.objectName,isEditing:S,onFieldChange:Oe,onEnterInlineEdit:s?ke:void 0,autoFocusField:w,dataSource:t}),V.comments&&(0,Q.jsx)(fa,{comments:V.comments,onAddComment:V.onAddComment})]});return!e&&!n&&!r&&!i?(0,Q.jsx)(`div`,{className:`mt-2`,children:d}):(0,Q.jsxs)(zr,{defaultValue:l,onValueChange:u,className:`w-full`,children:[(0,Q.jsxs)(fn,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,Q.jsx)(gt,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:M(`detail.details`)}),e&&(0,Q.jsx)(gt,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[M(`detail.related`),(0,Q.jsx)(Vt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:W.length})]})}),n&&(0,Q.jsx)(gt,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[M(`detail.activity`),(0,Q.jsx)(Vt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:V.activities.length})]})}),r&&(0,Q.jsx)(gt,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:M(`detail.discussion`,{defaultValue:`Discussion`})}),i&&(0,Q.jsx)(gt,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[M(`detail.history`,{defaultValue:`History`}),!V.history.loading&&V.history.entries.length>0&&(0,Q.jsx)(Vt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:V.history.entries.length})]})})]}),(0,Q.jsx)(Xe,{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:d}),e&&(0,Q.jsx)(Xe,{value:`related`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,Q.jsx)(`div`,{className:`space-y-3`,children:W.map((e,n)=>(0,Q.jsx)(ca,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,defaultCollapsed:oe&&n>0,pageSize:Ia},n))})}),n&&(0,Q.jsx)(Xe,{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,Q.jsx)(ya,{activities:V.activities})}),r&&(0,Q.jsx)(Xe,{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:c}),i&&(0,Q.jsx)(Xe,{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,Q.jsx)(Ea,{entries:V.history.entries,loading:V.history.loading,emptyText:V.history.emptyText??M(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,Q.jsxs)(Q.Fragment,{children:[V.sectionGroups&&V.sectionGroups.length>0&&(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:V.sectionGroups.map((e,n)=>(0,Q.jsx)(la,{group:e,data:{...m,...C},objectSchema:O,objectName:V.objectName,isEditing:S,onFieldChange:Oe,onEnterInlineEdit:s?ke:void 0,autoFocusField:w,dataSource:t},n))}),V.sections&&V.sections.length>0&&(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:V.sections.map((e,n)=>(0,Q.jsx)(na,{section:e,data:{...m,...C},objectSchema:O,objectName:V.objectName,isEditing:S,onFieldChange:Oe,onEnterInlineEdit:s?ke:void 0,autoFocusField:w,dataSource:t},n))}),V.fields&&V.fields.length>0&&!V.sections?.length&&(0,Q.jsx)(na,{section:{fields:V.fields,columns:V.columns},data:{...m,...C},objectSchema:O,objectName:V.objectName,isEditing:S,onFieldChange:Oe,onEnterInlineEdit:s?ke:void 0,autoFocusField:w,dataSource:t}),V.tabs&&V.tabs.length>0&&(0,Q.jsx)(ra,{tabs:V.tabs,data:m}),W.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold`,children:M(`detail.related`)}),W.map((e,n)=>(0,Q.jsx)(ca,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,defaultCollapsed:oe&&n>0,pageSize:Ia},n))]}),V.comments&&(0,Q.jsx)(fa,{comments:V.comments,onAddComment:V.onAddComment}),V.activities&&V.activities.length>0&&(0,Q.jsx)(ya,{activities:V.activities})]}),(0,Q.jsx)(Na,{data:{...m,...C},objectSchema:O,objectName:V.objectName}),V.footer&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(be,{schema:Te(V.footer),data:m})})]})})},Ba=e=>q(e)??null,Va=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}},Ha=({schema:e={},className:t,...n})=>{let r=S(),{designer:i}=Va(n),a=r?.objectName||``,c=o(),{readableFields:l}=s(a),{sectionLabel:u}=Ie(),{language:d}=Ue(),f=Ce();if(!r)return(0,Q.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...i,children:(0,Q.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 p=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(p.length>0&&a&&!p.every(e=>c.can(a,e)))return(0,Q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let m=e.enforceFieldSecurity===!0,h=Array.isArray(e.redactFields)?e.redactFields:[],g=e=>{if(!e||!m&&h.length===0)return e;let t=e.map(Ba).filter(e=>!!e),n=new Set((m&&a?l(t):t).filter(e=>!h.includes(e)));return e.filter(e=>{let t=Ba(e);return!t||n.has(t)})},_=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,v=e=>Array.isArray(e)?e.map(_):e,y=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:Ba(e)).filter(e=>!!e));for(let e of f)y.add(e);let b=r.objectSchema,x=r.data??{},C=[b?.primaryField,`name`,`full_name`,`title`,`subject`,`display_name`,`label`].filter(e=>typeof e==`string`&&e.length>0);for(let e of C)if(x[e]!==void 0&&x[e]!==null&&x[e]!==``){y.add(e);break}let w=e=>!e||y.size===0?e:e.filter(e=>{let t=Ba(e);return!t||!y.has(t)}),T=w(v(g(e.fields))),E=Array.isArray(e.sections)?e.sections.map(e=>{let t=e.label,n=t==null?void 0:Fe(t,d),r=e.name&&a?u(a,e.name,n??e.name):n;return{...e,title:r,showBorder:e.showBorder??!!r,fields:w(v(g(e.fields)))}}):e.sections,D=me(b,c?.getObjectApiOperations?.(a)),O=(e.inlineEdit??!0)&&D,ee={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:`vertical`,columns:e.columns,sections:E,fields:T,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:O};return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(za,{schema:ee,dataSource:r.dataSource,inlineEdit:O})})},Ua=e=>q(e)||(e&&typeof e==`object`?e.key:null)||null,Wa=e=>e?.id??e?._id??null,Ga=5,Ka=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}},qa=({schema:e={},className:t,...n})=>{let r=S(),{designer:i}=Ka(n),a=Ie(),{language:c}=Ue(),l=e.objectName,u=l&&a.objectLabel?a.objectLabel({name:l,label:ie(l)}):l?ie(l):``,d=Fe(e.title,c)||u||`Related`,f=o(),{readableFields:p}=s(l||``),m=e.relationshipValueField||`id`,h=m===`id`?r?.recordId??null:r?.data?.[m]??null,g=k(),_=Z.useMemo(()=>g?.resolve({objectName:l,relationshipField:e.relationshipField,parentId:h})??null,[g,l,e.relationshipField,h]);if(!l)return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});if(f.isLoaded&&!f.can(l,`read`))return null;let v=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(v.length>0&&!v.every(e=>f.can(l,e)))return(0,Q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let y=e.enforceFieldSecurity===!0,b=Array.isArray(e.redactFields)?e.redactFields:[],x=Array.isArray(e.columns)?e.columns:[],C=x;if(y||b.length>0){let e=x.map(Ua).filter(e=>!!e),t=new Set((y?p(e):e).filter(e=>!b.includes(e)));C=x.filter(e=>{let n=Ua(e);return!n||t.has(n)})}return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(ca,{title:d,type:`table`,api:l,objectName:l,referenceField:e.relationshipField,parentId:h,columns:C,pageSize:typeof e.limit==`number`&&e.limit>0?e.limit:Ga,defaultSort:e.sort,filter:e.filter,dataSource:r?.dataSource,add:e.add?{...e.add,label:Fe(e.add.label,c)||void 0}:void 0,rowActions:_?.rowActions,onRowAction:_?.onRowAction,toolbarActions:_?.toolbarActions,onToolbarAction:_?.onToolbarAction,onNew:_?.onCreate,newDisabled:_?.createDisabled,onRowClick:_?.onView?e=>{let t=Wa(e);t!=null&&_.onView(t,e)}:void 0,onRowEdit:_?.onEdit?e=>{let t=Wa(e);t!=null&&_.onEdit(t,e)}:void 0,onRowDelete:_?.onDelete?e=>{let t=Wa(e);if(t!=null)return _.onDelete(t,e)}:e.add&&r?.dataSource?async e=>{let t=e?.id??e?._id;t!=null&&await r.dataSource.delete?.(l,String(t))}:void 0})})},Ja={columns:!0,filter:!0,sort:!0,limit:`limit`},Ya={},Xa=b(e=>{let t=S();return(0,Q.jsx)(Oe,{schema:e.schema??Ya,mapping:Ja,dataSource:t?.dataSource,testId:`record-related-list`,errorTitle:`This related list’s data source could not be resolved`,children:t=>(0,Q.jsx)(qa,{...e,schema:t})})}),Za=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}},Qa=({schema:e={},className:t,...n})=>{let r=S(),{designer:i}=Za(n),a=r?.objectName||``,c=o(),{readableFields:l}=s(a),u=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[],d=!(u.length>0&&a)||u.every(e=>c.can(a,e)),f=(Array.isArray(e.fields)?e.fields:[]).map(e=>typeof e==`string`?{name:e}:{name:e?.name,label:e?.label,icon:e?.icon,type:e?.type,readonly:e?.readonly===!0}).filter(e=>typeof e.name==`string`&&e.name.length>0),p=e.enforceFieldSecurity===!0,m=Array.isArray(e.redactFields)?e.redactFields:[],h=p&&a?new Set(l(f.map(e=>e.name))):null,g=f.filter(e=>!(m.includes(e.name)||h&&!h.has(e.name))),_=Z.useId();return U(_,d?g.map(e=>e.name):[]),d?(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(ua,{fields:g,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema,dataSource:r?.dataSource})}):(0,Q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})})},$a=({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,Q.jsxs)(`div`,{className:X(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,Q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,Q.jsx)(gn,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`text-foreground`,children:i})]})},eo=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],to=({reactions:e,onToggleReaction:t,emojiOptions:n=eo,className:r})=>{let[i,a]=Z.useState(!1),{t:o}=$(),s=Z.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,Q.jsxs)(`div`,{className:X(`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,Q.jsxs)(`button`,{type:`button`,className:X(`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,Q.jsx)(`span`,{children:e.emoji}),(0,Q.jsx)(`span`,{children:e.count})]},e.emoji)}),t&&(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":o(`detail.addReaction`),children:(0,Q.jsx)(kr,{className:`h-3.5 w-3.5`})}),i&&(0,Q.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,Q.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 no(e,t){try{let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`detail.justNow`);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return t(`detail.hoursAgo`,{count:a});let o=Math.floor(a/24);return o<7?t(`detail.daysAgo`,{count:o}):n.toLocaleDateString()}catch{return e}}var ro=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=$(),[o,s]=Z.useState(!1),[c,l]=Z.useState(``),[u,d]=Z.useState(!1),f=Z.useCallback(async()=>{let t=c.trim();if(!(!t||!n)){d(!0);try{await n(e.id,t),l(``)}finally{d(!1)}}},[c,n,e.id]),p=Z.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return t.length===0&&!r?null:(0,Q.jsxs)(`div`,{className:X(`ml-10 mt-1`,i),children:[t.length>0&&(0,Q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>s(!o),"aria-expanded":o,children:[o?(0,Q.jsx)(Rn,{className:`h-3 w-3`}):(0,Q.jsx)(rr,{className:`h-3 w-3`}),(0,Q.jsx)(fr,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{count:t.length})})]}),o&&(0,Q.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,Q.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,Q.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,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:no(e.createdAt,a)})]}),(0,Q.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,Q.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,Q.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:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:u}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:f,disabled:!c.trim()||u,"aria-label":`Send reply`,children:(0,Q.jsx)(Hn,{className:`h-3 w-3`})})]})]})},io=({subscription:e,onToggle:t,className:n})=>{let{t:r}=$(),[i,a]=Z.useState(!1),o=Z.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:X(`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,Q.jsx)(Je,{className:`h-4 w-4 text-primary`}):(0,Q.jsx)(un,{className:`h-4 w-4 text-muted-foreground`})})};function ao(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 oo=({value:e,onChange:t,onSubmit:n,mentionSuggestions:r=[],placeholder:i,className:a,disabled:o=!1,extraSlot:s,canSubmitEmpty:c=!1})=>{let{t:l}=$(),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),[m,h]=Z.useState(``),[g,_]=Z.useState(0),v=Z.useRef(null),y=Z.useMemo(()=>{if(!m)return r;let e=m.toLowerCase();return r.filter(t=>t.label.toLowerCase().includes(e))},[m,r]),b=Z.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=Z.useCallback(()=>b(`**`,`**`),[b]),S=Z.useCallback(()=>b(`*`,`*`),[b]),C=Z.useCallback(()=>b(`
|
|
4
|
+
- `,``),[b]),w=Z.useCallback(()=>b("`","`"),[b]),T=Z.useCallback(()=>{b(`@`,``),p(!0),h(``),_(0)},[b]),E=Z.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=Z.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=Z.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,Q.jsxs)(`div`,{className:X(`border rounded-md`,a),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:x,disabled:o||u,title:l(`detail.bold`),children:(0,Q.jsx)(Ir,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:S,disabled:o||u,title:l(`detail.italic`),children:(0,Q.jsx)(st,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:C,disabled:o||u,title:l(`detail.listFormat`),children:(0,Q.jsx)(Pr,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:o||u,title:l(`detail.inlineCode`),children:(0,Q.jsx)(qt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:o||u,title:l(`detail.mentionSomeone`),children:(0,Q.jsx)(ut,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>d(!u),title:l(u?`detail.edit`:`detail.preview`),children:u?(0,Q.jsx)(mt,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Zt,{className:`h-3.5 w-3.5`})}),n&&(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:n,disabled:o||!c&&!e.trim(),title:l(`detail.submitComment`),children:(0,Q.jsx)(Hn,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`relative`,children:u?(0,Q.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:ao(e)}}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.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,Q.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,Q.jsxs)(`button`,{type:`button`,className:X(`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,Q.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,Q.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,Q.jsx)(`span`,{children:e.label})]},e.id))})]})}),s&&(0,Q.jsx)(`div`,{className:`border-t px-2 py-2 bg-muted/20`,children:s})]})};function so(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function co(e){return e.startsWith(`image/`)}function lo(e){return co(e)?Lr:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?_r:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?Tn:pr}var uo=({attachments:e,onUpload:t,onRemove:n,className:r,readOnly:i=!1})=>{let{t:a}=$(),[o,s]=Z.useState(!1),c=Z.useRef(null),l=Z.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!0)},[]),u=Z.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1)},[]),d=Z.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),f=Z.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,Q.jsxs)(`div`,{className:X(`space-y-2`,r),children:[t&&!i&&(0,Q.jsxs)(`div`,{className:X(`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,Q.jsx)(zn,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`detail.dropFilesToUpload`)}),(0,Q.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:f})]}),e.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(vt,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:e.length===1?a(`detail.attachmentCount`,{count:e.length}):a(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=co(e.type),r=lo(e.type);return(0,Q.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,Q.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,Q.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,Q.jsx)(r,{className:`h-5 w-5 text-muted-foreground`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:so(e.size)})]}),n&&!i&&(0,Q.jsx)(Y,{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,Q.jsx)(tr,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},fo={comment:fr,field_change:mt,task:mn,event:et,system:jn,email:$n,call:jt,note:yt,file:_r,sharing:hr,record_create:An,record_delete:Yt,approval:an},po={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 mo(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 ho(e,t){try{let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`detail.justNow`);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return t(`detail.hoursAgo`,{count:a});let o=Math.floor(a/24);return o<7?t(`detail.daysAgo`,{count:o}):n.toLocaleDateString()}catch{return e}}function go(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 _o=({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,className:_})=>{let{t:v}=$(),[y,b]=Z.useState(`all`),[x,S]=Z.useState(``),[C,w]=Z.useState(!1),[T,E]=Z.useState(!1),[D,O]=Z.useState([]),[ee,te]=Z.useState(!1),ne=n??y,re=t?.showFilterToggle!==!1,k=t?.showCommentInput!==!1&&!!s,A=t?.enableReactions??!1,ie=t?.enableThreading??!1,ae=t?.showSubscriptionToggle??!1,j=Z.useMemo(()=>go(e,ne),[e,ne]),M=Z.useMemo(()=>ie?j.filter(e=>!e.parentId):j,[j,ie]),N=Z.useMemo(()=>{if(!ie)return new Map;let e=new Map;for(let t of j)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[j,ie]),P=Z.useCallback(e=>{r?r(e):b(e)},[r]),oe=Z.useCallback(async()=>{let e=x.trim();if(s&&!(!e&&D.length===0)){w(!0);try{await s(e,D.length>0?D:void 0),S(``),O([])}finally{w(!1)}}},[x,D,s]),F=Z.useCallback(async e=>{if(!(!m||e.length===0)){te(!0);try{let t=await m(e);Array.isArray(t)&&t.length>0&&O(e=>[...e,...t])}finally{te(!1)}}},[m]),I=Z.useCallback(e=>{O(t=>t.filter(t=>t.id!==e))},[]),se=Z.useCallback(async()=>{if(a){E(!0);try{await a()}finally{E(!1)}}},[a]);return(0,Q.jsxs)(`section`,{className:X(`border-t border-border/60 pt-5`,_),"aria-label":`Discussion`,children:[(0,Q.jsx)(`header`,{className:`mb-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold leading-none tracking-tight`,children:[(0,Q.jsx)(dr,{className:`h-4 w-4`}),h??v(`detail.activity`),(0,Q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,j.length,`)`]})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:ae&&u&&(0,Q.jsx)(io,{subscription:u,onToggle:d})})]})}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[re&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(Cr,{value:ne,onValueChange:e=>P(e),children:[(0,Q.jsx)(tt,{"aria-label":v(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,Q.jsx)(Ft,{})}),(0,Q.jsx)(en,{children:mo(v).map(e=>(0,Q.jsx)(rt,{value:e.value,children:e.label},e.value))})]})}),k&&(0,Q.jsx)(oo,{value:x,onChange:S,onSubmit:oe,mentionSuggestions:p,placeholder:v(`detail.leaveCommentPlaceholder`),disabled:C,canSubmitEmpty:D.length>0,extraSlot:m?(0,Q.jsx)(uo,{attachments:D,onUpload:F,onRemove:I,readOnly:C||ee}):D.length>0?(0,Q.jsx)(uo,{attachments:D,onRemove:I,readOnly:C}):void 0}),o&&j.length===0?(0,Q.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,Q.jsx)(br,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{children:v(`detail.loading`)})]}):j.length===0?f?null:(0,Q.jsx)(Un,{title:g??v(`detail.noActivity`),className:`py-6`}):(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:M.map(e=>{let t=fo[e.type]||jn,n=po[e.type]||`bg-gray-100 text-gray-600`,r=N.get(e.id)??[];return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,Q.jsx)(`div`,{className:X(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,Q.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,Q.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`detail.via`,{source:e.source})}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ho(e.createdAt,v)}),e.edited&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:v(`detail.edited`)}),e.pinned&&(0,Q.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,v(`detail.pinned`)]})]}),e.body&&(0,Q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.sourceObject&&e.sourceId!=null&&(0,Q.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:[v(`detail.viewSource`),(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`→`})]}),e.type===`field_change`&&e.fieldChanges&&(0,Q.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,Q.jsx)($a,{change:e},t))}),A&&e.reactions&&e.reactions.length>0&&(0,Q.jsx)(`div`,{className:`mt-1.5`,children:(0,Q.jsx)(to,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),A&&(!e.reactions||e.reactions.length===0)&&l&&(0,Q.jsx)(`div`,{className:`mt-1.5`,children:(0,Q.jsx)(to,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),ie&&(e.replyCount??0)>0&&(0,Q.jsx)(ro,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,Q.jsx)(`div`,{className:`text-center pt-2`,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:se,disabled:T,"aria-label":v(`detail.loadMore`),children:[T?(0,Q.jsx)(br,{className:`h-4 w-4 animate-spin mr-1`}):(0,Q.jsx)(Rn,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})};l();var vo=p.options,yo=d.options,bo={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},xo=`system`,So=[`comment`],Co=[`record_create`,`record_delete`,`sharing`],wo=new Set([...Object.values(bo).filter(e=>!!e),xo,...So]),To=new Set([`task`]);function Eo(e,t,n){let r=t.filter(t=>!e.has(t));if(r.length!==0){for(let t of r)e.add(t);console.warn(n(r))}}var Do=new Set,Oo=new Set,ko=new Set;function Ao(e){if(typeof e==`string`&&vo.includes(e))return e;if(e!=null){let t=typeof e==`string`?`"${e}"`:typeof e;Eo(ko,[typeof e==`string`?e:`non-string ${t}`],()=>`[record:activity] ignoring an unrecognised \`filterMode\` (${t}) 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: ${vo.join(`, `)}.`)}return`all`}function jo(e){let t=e.filter(e=>!wo.has(e));t.length!==0&&Eo(Oo,t,e=>{let t=e=>e.map(e=>`"${e}"`).join(`, `),n=e.filter(e=>Co.includes(e)),r=e.filter(e=>!Co.includes(e)),i=`[record:activity] \`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: ${t(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 n.length>0&&(i+=` DELIBERATELY NOT ADOPTED, a decision rather than a gap: ${t(n)} — \`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.`),r.length>0&&(i+=` NO PRODUCER on any ObjectUI surface: ${t(r)} — @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.`),i+=` Feed item types ObjectUI produces today: ${[...wo].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.`,i})}function Mo(e){if(e==null)return;if(!Array.isArray(e)){let t=typeof e==`string`?`"${e}"`:typeof e;return Eo(Do,[`non-array ${t}`],()=>`[record:activity] ignoring an authored \`types\` that is not an array (${t}). \`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: ${yo.join(`, `)}.`),[]}let t=[],n=[];for(let r of e)typeof r==`string`&&yo.includes(r)?t.push(r):n.push(typeof r==`string`?r:String(r));return n.length>0&&Eo(Do,n,e=>`[record:activity] 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: ${yo.join(`, `)}.`),jo(t),t}function No(e){let t=Math.floor(Number(e));return Number.isFinite(t)&&t>0?t:20}function Po(e){let t=e.timestamp;return String(!t||t===`NOW()`||Number.isNaN(Date.parse(String(t)))?e.created_at??``:t)}var Fo=new Set;function Io(e){Eo(Fo,[e],()=>`[record:activity] rendered a sys_activity row with type "${e}" through the generic "${xo}" presentation: no feed item type is mapped for it. \`sys_activity.type\` is author-extensible (objectstack#11507, 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 Lo(e,t){let n=String(e?.type),r=Object.prototype.hasOwnProperty.call(bo,n);r||Io(n);let i=r?bo[n]:xo;return i?{id:e.id,type:i,actor:e.actor_name??t,actorAvatarUrl:e.actor_avatar_url??void 0,body:e.summary??``,createdAt:Po(e),sourceObject:e.source_object??void 0,sourceId:e.source_id??void 0}:null}function Ro(e,t,n){let r=e.slice();t.unifiedTimeline===!1&&(r=r.filter(e=>e.type!==`field_change`)),t.showCompleted!==!0&&(r=r.filter(e=>!To.has(e.type)));let i=Mo(t.types);if(i!==void 0){let e=new Set(i);r=r.filter(t=>e.has(t.type))}let a=r.length,o=Math.max(1,Math.floor(n)||20);return{items:a>o?r.slice(a-o):r,total:a,hasMore:a>o}}function zo(...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)})}var Bo=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}},Vo=({schema:e={},className:t,...n})=>{let{designer:r}=Bo(n),i=S(),a=te(),o=Re(),s=e.properties??{},c=t=>e[t]??s[t],l=No(c(`limit`)),u=Ao(c(`filterMode`)),d=c(`types`),f=c(`showCompleted`),p=c(`unifiedTimeline`),m={types:d,filterMode:u,showFilterToggle:c(`showFilterToggle`),limit:l,showCompleted:f,unifiedTimeline:p,showCommentInput:c(`showCommentInput`),enableMentions:c(`enableMentions`),enableReactions:c(`enableReactions`),enableThreading:c(`enableThreading`),showSubscriptionToggle:c(`showSubscriptionToggle`)},h=Array.isArray(e.items)?e.items:Array.isArray(s.items)?s.items:void 0,g=e.loading??s.loading,_=i?.objectName,v=i?.data?.id??i?.data?._id??i?.recordId,y=i?.dataSource,b=h===void 0&&!a&&typeof y?.find==`function`&&!!_&&v!=null,[x,C]=Z.useState(0),w=l*(x+1),[T,E]=Z.useState(null),[D,O]=Z.useState(!1),[ee,ne]=Z.useState(!1),re=o(`detail.systemActor`,`System`);Z.useEffect(()=>{if(!b)return;let e=!1;return ne(!0),Promise.resolve(y.find(`sys_activity`,{$filter:{object_name:_,record_id:v},$orderby:{timestamp:`desc`},$top:Math.max(1,w)+1})).then(t=>{if(e)return;let n=t?.data??[],r=Array.isArray(n)?n:[],i=[];for(let e of r){let t=Lo(e,re);t&&i.push(t)}O(r.length>Math.max(1,w)),E(zo(i))}).catch(()=>{e||(E([]),O(!1))}).finally(()=>{e||ne(!1)}),()=>{e=!0}},[b,y,_,v,w,re]);let k=a?.items,A=Z.useMemo(()=>Ro(h??k??T??[],{types:d,showCompleted:f,unifiedTimeline:p},w),[h,k,T,d,f,p,w]),ie=A.items,ae=A.hasMore||b&&D,j=g??a?.loading??(b&&T===null?!0:ee),[M,N]=Z.useState(u);Z.useEffect(()=>{N(u)},[u]);let P=Z.useCallback(()=>{C(e=>e+1)},[]),oe=m.enableMentions!==!1;return(0,Q.jsx)(`div`,{className:t,...r,children:(0,Q.jsx)(_o,{items:ie,config:m,loading:j,filterMode:M,onFilterChange:N,hasMore:ae,onLoadMore:P,onAddComment:a?.onAddComment,onAddReply:a?.onAddReply,onToggleReaction:a?.onToggleReaction,mentionSuggestions:oe?a?.mentionSuggestions:void 0,onUploadAttachments:a?.onUploadAttachments})})},Ho=({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,className:h})=>{let g=e?.position??`right`,_=e?.width??`360px`,v=e?.collapsible??!0,y=f&&t.length===0||(e?.defaultCollapsed??!1),{t:b}=$(),[x,S]=Z.useState(y);return g===`right`||g===`left`?x&&v?(0,Q.jsx)(`div`,{className:X(`flex items-start pt-4`,g===`right`?`border-l`:`border-r`,h),children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>S(!1),"aria-label":b(`detail.openDiscussion`),children:(0,Q.jsx)(qe,{className:`h-4 w-4`})})}):(0,Q.jsxs)(`div`,{className:X(`flex flex-col overflow-hidden`,g===`right`?`border-l`:`border-r`,h),style:{width:_,minWidth:_},children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(fr,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:b(`detail.discussion`)})]}),v&&(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.closeDiscussion`),children:(0,Q.jsx)(tr,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,Q.jsx)(_o,{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:b(`detail.discussion`),emptyLabel:b(`detail.noCommentsYet`),className:`border-0 shadow-none`})})]}):(0,Q.jsx)(`div`,{className:X(``,h),children:v&&x?(0,Q.jsxs)(Y,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>S(!1),"aria-label":b(`detail.showDiscussion`,{count:t.length}),children:[(0,Q.jsx)(fr,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:b(`detail.showDiscussion`,{count:t.length})})]}):(0,Q.jsxs)(`div`,{children:[v&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(fr,{className:`h-4 w-4`}),b(`detail.discussion`)]}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.hideDiscussion`),children:(0,Q.jsx)(ln,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(_o,{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:b(`detail.discussion`),emptyLabel:b(`detail.noCommentsYet`)})]})})},Uo=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}},Wo=({schema:e={},className:t,...n})=>{S();let r=te(),{designer:i}=Uo(n),a={position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0},...e};return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(Ho,{items:r?.items||[],config:a,loading:r?.loading,onAddComment:r?.onAddComment,onAddReply:r?.onAddReply,onToggleReaction:r?.onToggleReaction,mentionSuggestions:r?.mentionSuggestions,onUploadAttachments:r?.onUploadAttachments})})},Go=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}},Ko=({schema:e={},className:t,...n})=>{let r=S(),{translateOptions:i}=Ie(),{t:a}=$(),{designer:o}=Go(n),s=Array.isArray(e.stages)?e.stages:[],c=e.statusField,l=Z.useMemo(()=>{if(s.length===0||!c||!r?.objectName)return s;let e=i(r.objectName,c,s);return Array.isArray(e)&&e.length===s.length?s.map((t,n)=>({...t,label:e[n]?.label??t.label})):s},[s,c,r?.objectName,i]),u=c&&r?.data?r.data[c]:void 0,d=/(^|[_-\s])(closed_)?(lost|failed?|cancell?ed|失败|流失|丢单|败)([_-\s]|$)/i,f=/(^|[_-\s])(closed_)?(won|success|成交|赢|完成)([_-\s]|$)/i,p=l.map(e=>{if(e.terminal)return e.terminal;let t=`${String(e.value??``)} ${String(e.label??``)}`;if(d.test(t))return`lost`;if(f.test(t))return`won`}),m=p.findIndex(e=>e===`lost`),h=m===-1?l:l.slice(0,m),g=m===-1?[]:l.slice(m),_=h.length-1,v=p.map((e,t)=>e===`won`?t===_?`won`:void 0:e),y=l.findIndex(e=>e.value===u);y<0&&(y=-1);let b=m!==-1&&y>=m;if(l.length===0)return(0,Q.jsx)(`div`,{className:t,...o,children:(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:path — no stages configured`})});let x=(e,t)=>X(`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`)),C=(e,t)=>X(`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`),w=(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}),T=e=>(0,Q.jsxs)(`div`,{role:`listitem`,"data-stage-state":e.state,"data-stage-terminal":e.terminal,"aria-current":e.state===`current`?`step`:void 0,"aria-label":w(e.stage.label,e.state,e.terminal),className:X(`flex flex-col gap-1.5`,e.className),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-stage-rail":``,className:x(e.state,e.terminal)}),(0,Q.jsxs)(`span`,{className:X(C(e.state,e.terminal),e.labelClassName),children:[e.terminal===`lost`&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1 opacity-70`,children:`✗`}),e.terminal!==`lost`&&e.state===`completed`&&(0,Q.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,Q.jsxs)(`div`,{className:X(`w-full`,t),...o,children:[(0,Q.jsxs)(`div`,{className:`hidden sm:flex w-full items-start gap-2`,role:`list`,"aria-label":e.aria?.label||a(`detail.pathLabel`),children:[(0,Q.jsx)(`div`,{className:`flex flex-1 items-start gap-1.5`,children:h.map((e,t)=>{let n=!b&&y>=0&&t<y,r=!b&&t===y;return T({key:`${e.value}-${t}`,stage:e,state:r?`current`:n?`completed`:`upcoming`,terminal:v[t],className:`flex-1 min-w-0`,labelClassName:`text-center truncate`})})}),g.length>0&&(0,Q.jsx)(`div`,{className:`flex items-start gap-1.5 pl-2 border-l border-border/40`,children:g.map((e,t)=>{let n=m+t;return T({key:`${e.value}-lost-${t}`,stage:e,state:n===y?`current`:`upcoming`,terminal:v[n],className:`shrink-0`,labelClassName:`text-center whitespace-nowrap`})})})]}),(0,Q.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`,role:`list`,"aria-label":e.aria?.label||a(`detail.pathLabel`),children:l.map((e,t)=>{let n=v[t],r=n!==`lost`&&!b&&y>=0&&t<y,i=t===y;return T({key:`${e.value}-${t}-m`,stage:e,state:i?`current`:r?`completed`:`upcoming`,terminal:n,className:`shrink-0`,labelClassName:`whitespace-nowrap`})})})]})},qo=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}},Jo=Object.freeze([]),Yo=new Set;function Xo(e,t,n){let r=`${e}::${t}::${n.index}::${n.message}`;Yo.has(r)||(Yo.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 Zo=({schema:e={},className:t,...n})=>{let r=S(),{designer:i}=qo(n),a=o(),s=T(),c=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:Jo,l=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:Jo,u=r?.objectName||``,d=l.length>0?`actionNames`:`actions`,f=l.length>0?l:c,p=V(f,void 0),m=p.kind===`ids`&&p.ids.length>0&&!!u,{item:h}=ge(`object`,m?u:null),g=V(f,Array.isArray(h?.actions)?h.actions:[]);g.kind===`refused`&&Xo(u,d,g);let _=(g.kind===`refused`?[]:g.actions).map((e,t)=>s(u||void 0,e,{fallbackLabel:`Action ${t+1}`})),v=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[],y=e.location||`record_header`,{getActionsForLocation:b,executeAction:x}=I({actions:_,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}});if(v.length>0&&u&&!v.every(e=>a.can(u,e)))return(0,Q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,Q.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,Q.jsx)(`div`,{className:t,...i,children:(0,Q.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`,E=w===`start`?`justify-start`:w===`center`?`justify-center`:`justify-end`,D=y===`record_header`&&!e.inline,O=(e.aria?.ariaLabel??e.aria?.label)||`Quick actions`;return(0,Q.jsx)(`div`,{className:X(`flex flex-wrap items-center gap-2`,D&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,E,t),role:`toolbar`,"aria-label":O,...i,children:C.map((t,n)=>(0,Q.jsx)(Qo,{action:t,record:r?.data,variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,label:t.label||`Action ${n+1}`,onRun:async()=>{typeof t.onClick==`function`?await t.onClick():t.name&&await x(t.name)}},t.name||`qa-${n}`))})};function Qo({action:e,record:t,variant:n,size:r,label:i,onRun:a}){let[o,s]=Z.useState(!1),c=Z.useMemo(()=>({record:t||{}}),[t]),l=w(j(e.disabled),c),u=(ke(e.disabled)?l:!1)||o;return(0,Q.jsxs)(Y,{variant:n,size:r,disabled:u,onClick:async()=>{s(!0);try{await a()}finally{s(!1)}},children:[o&&(0,Q.jsx)(br,{className:`mr-2 h-4 w-4 animate-spin`}),i]})}var $o=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}},es=new Set([`created`,`updated`,`assigned`,`shared`,`deleted`]),ts=({schema:e={},className:t,...n})=>{let{designer:r}=$o(n),i=S(),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=Number(e.limit??e.properties?.limit??50)||50,u=i?.objectName,d=i?.data?.id??i?.data?._id??i?.recordId,f=i?.dataSource,p=a===void 0&&!!f?.find&&!!u&&d!=null,[m,h]=Z.useState(null),[g,_]=Z.useState(!1);Z.useEffect(()=>{if(!p)return;let e=!1;return _(!0),Promise.resolve(f.find(`sys_activity`,{$filter:{object_name:u,record_id:d},$orderby:{timestamp:`desc`},$top:Math.max(1,l)})).then(t=>{if(e)return;let n=(t?.data??[]).filter(e=>es.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}});h(n)}).catch(()=>{e||h([])}).finally(()=>{e||_(!1)}),()=>{e=!0}},[p,f,u,d,l]);let v=a??m??[],y=o??(p&&m===null?g||!0:!1);return(0,Q.jsx)(`div`,{className:t,...r,children:(0,Q.jsx)(Ea,{entries:v,loading:y,emptyText:s,unknownUserText:c})})},ns=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=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),is=(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||`—`,as=({schema:e={},className:t,...r})=>{let a=S(),o=Ie(),{t:s}=$(),{designer:c}=ns(r),l=i().appName,u=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],d=a?.recordId,f=a?.dataSource,[p,m]=Z.useState({}),h=Z.useRef(null),[g,_]=Z.useState(!1),v=Z.useRef(!0);Z.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);let y=Z.useRef(``);Z.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=JSON.stringify(u.map(e=>`${e.objectName}:${e.relationshipField}:${e.limit??3}`));Z.useEffect(()=>{if(!g||!f?.find||!d||u.length===0)return;let e=`${d}::${b}`;if(y.current===e)return;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 t=async e=>{let t=e.objectName;try{let n=await f.find(e.objectName,{$filter:{[e.relationshipField]:d},$top:e.limit??3,$count:!0});if(!v.current)return;let r=Array.isArray(n)?n:n?.data||[],i=typeof n?.total==`number`?n.total:typeof n?.count==`number`?n.count:r.length;m(e=>({...e,[t]:{loading:!1,total:i,items:r}}))}catch(e){if(!v.current)return;m(n=>({...n,[t]:{loading:!1,total:0,items:[],error:String(e?.message||e)}}))}},n=[...u],r=async()=>{for(;v.current;){let e=n.shift();if(!e)return;await t(e)}},i=Array.from({length:Math.min(3,n.length)},()=>r());Promise.all(i)},[g,f,d,b]);let[x,C]=Z.useState(!1);if(u.length===0)return null;let w=e.hideEmpty!==!1,T=new Set(u.filter(e=>{let t=p[e.objectName];return w&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),E=u.filter(e=>x||!T.has(e.objectName)),D=u.filter(e=>T.has(e.objectName)).map(e=>e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:rs(e.objectName)}):rs(e.objectName)));return(0,Q.jsxs)(`div`,{ref:h,className:X(`flex flex-col gap-3`,e.className,t),...c,children:[E.map(e=>{let t=e.objectName,r=p[t]||{loading:!0,total:0,items:[]},i=e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:rs(e.objectName)}):rs(e.objectName));return(0,Q.jsxs)(It,{className:`overflow-hidden`,children:[(0,Q.jsxs)(Gn,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,Q.jsx)(Mt,{className:`text-sm font-semibold tracking-tight truncate`,children:i}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!r.loading&&(0,Q.jsx)(Vt,{variant:`secondary`,className:`tabular-nums`,children:r.total}),l&&d&&(0,Q.jsx)(n,{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,Q.jsx)(Jn,{className:`p-0`,children:r.loading?(0,Q.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,Q.jsx)(Ln,{className:`h-3.5 w-4/5`}),(0,Q.jsx)(Ln,{className:`h-3.5 w-3/5`}),(0,Q.jsx)(Ln,{className:`h-3.5 w-2/3`})]}):r.items.length===0?(0,Q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:s(`detail.noRecords`)}):(0,Q.jsx)(`ul`,{className:`divide-y`,children:r.items.map(t=>{let r=t.id||t._id,i=is(t,e.displayField),a=r?`../${e.objectName}/record/${encodeURIComponent(String(r))}`:void 0;return(0,Q.jsx)(`li`,{className:`px-4 py-2`,children:a?(0,Q.jsxs)(n,{to:a,className:`group flex items-center justify-between gap-2 text-xs hover:text-foreground text-muted-foreground transition-colors`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:i}),(0,Q.jsx)(rr,{className:`h-3 w-3 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`})]}):(0,Q.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:i})},String(r||i))})})})]},t)}),!x&&D.length>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>C(!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:D.join(` · `),children:[(0,Q.jsx)(`span`,{children:s(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:D.length})}),(0,Q.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,D.join(` · `),`)`]})]})]})},os={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`}};function ss(e){let t=e?.properties??{};return{...e,...t}}var cs=({schema:e={},className:t})=>{let n=ss(e),r=S(),i=r?.data,a=r?.objectName||``,o=r?.recordId??i?.id,{language:s}=Ue(),c=Fe(n.title,s),l=Fe(n.body,s),u=Fe(n.action?.label,s),d=[`info`,`warning`,`error`,`success`].includes(n.severity)?n.severity:`info`,f=os[d],p=n.icon||f.icon,m=K(i),h=j(n.visible),g=!!i&&Object.keys(i).length>0,_=w(g?h:void 0,m),v=Z.useMemo(()=>{if(!n.dismissible)return null;let e=n.dismissKey||Fe(n.title,`en`)||d;return`os.record-alert:${a}:${o??`_`}:${e}`},[n.dismissible,n.dismissKey,n.title,d,a,o]),[y,b]=Z.useState(()=>{if(!v||typeof window>`u`)return!1;try{return window.localStorage.getItem(v)===`1`}catch{return!1}}),x=n.action?.actionName,{item:C}=ge(`object`,x&&a?a:null),T=Z.useMemo(()=>{if(!(!x||!C?.actions))return C.actions.find(e=>e.name===x)},[x,C]),E=Z.useMemo(()=>T?[T]:[],[T]),{executeAction:D}=I({actions:E,context:{record:i,recordId:o,objectName:a}});return y||!g||h!==void 0&&!_?null:(0,Q.jsxs)(Kt,{className:X(`relative pr-12`,f.wrap,t),role:d===`error`?`alert`:`status`,"aria-live":d===`error`?`assertive`:`polite`,children:[(0,Q.jsx)(Kn,{name:p,className:`h-4 w-4`,"aria-hidden":`true`}),c?(0,Q.jsx)(Ye,{children:c}):null,l||T?(0,Q.jsxs)(Rr,{children:[l?(0,Q.jsx)(`p`,{className:`mb-2 last:mb-0`,children:l}):null,T?(0,Q.jsx)(Y,{size:`sm`,variant:n.action?.variant||(d===`error`?`destructive`:`default`),onClick:()=>{T?.name&&D(T.name)},children:u||T.label||T.name}):null]}):null,n.dismissible?(0,Q.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,Q.jsx)(Kn,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},ls=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)}},us=e=>{if(typeof e!=`string`||e.length===0)return null;let t=/\d{4}-\d{2}-\d{2}[ T]/.test(e)?e.replace(` `,`T`):e,n=new Date(t);if(Number.isNaN(n.getTime()))return null;try{return n.toLocaleString()}catch{return n.toISOString()}},ds=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:a=!1})=>{let{t:o}=$(),s=t?.label||t?.field||``,c=t?ls(t.pendingValue):``,l=t?ls(t.currentValue):``,u=t?.currentRecord??{},d=(()=>{let e=[u.updated_by_name,u.updated_by_label];for(let t of e)if(typeof t==`string`&&t.length>0)return t;let t=u.updated_by;return typeof t!=`string`||t.length===0||t.length>=16&&!/\s/.test(t)&&/^[A-Za-z0-9_-]+$/.test(t)?null:t})(),f=us(u.updated_at??t?.currentVersion),[p,m]=o(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,Q.jsx)(dn,{open:e,onOpenChange:e=>{!e&&!a&&i()},children:(0,Q.jsxs)(hn,{className:`max-w-lg`,children:[(0,Q.jsx)(lr,{children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.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,Q.jsx)(Mr,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(St,{children:o(`detail.concurrentUpdateTitle`)}),(0,Q.jsxs)(ft,{className:`mt-1`,children:[p,(0,Q.jsx)(`strong`,{className:`font-semibold`,children:s}),m]})]})]})}),(0,Q.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,Q.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,Q.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-amber-800 dark:text-amber-300`,children:o(`detail.concurrentUpdateYourEdit`)}),(0,Q.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:c})]}),(0,Q.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,Q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-sky-800 dark:text-sky-300`,children:o(`detail.concurrentUpdateCurrentValue`)}),(d||f)&&(0,Q.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[d&&(0,Q.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedBy`,{name:d})}),d&&f&&(0,Q.jsx)(`span`,{children:` · `}),f&&(0,Q.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedAt`,{when:f})})]})]}),(0,Q.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:l})]})]}),(0,Q.jsxs)(Tt,{className:`gap-2 sm:gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:X(yn({variant:`ghost`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateCancel`)}),(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:r,className:X(yn({variant:`outline`}),`mt-2 sm:mt-0 text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),children:o(`detail.concurrentUpdateOverwrite`)}),(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:n,autoFocus:!0,className:X(yn({variant:`default`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateReload`)})]})]})})};function fs(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}function ps(e){let t=e?.message||e?.error||String(e??`Save failed`);return String(t).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``)}function ms(e,t){return we(e)||(t?[{field:t,message:je(e)||ps(e)}]:null)}async function hs(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 gs=({dataSource:e,objectName:t,recordId:n,data:r,refresh:i,fieldLabelFor:a,onFieldSave:o,locked:s=!1,lockedHint:c,className:l})=>{let{t:u}=$(),d=z(),[f,p]=Z.useState(null),[m,h]=Z.useState(!1),g=Z.useCallback(e=>a?.(e)||e,[a]),_=!!e&&!!t&&n!=null,v=Z.useCallback((e,t)=>{if(!d)return;let n=ms(e,t);if(!n){d.setFieldErrors(null),d.setError(ps(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=Z.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=Z.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 hs(e,t,n,a,o?{ifMatch:o}:void 0),await i?.()}d.reset()}catch(e){fs(e)&&_?p(y(a,e)):v(e,c)}finally{d.setSaving(!1)}},[d,o,_,r,e,t,n,i,y,v]),x=Z.useCallback(()=>{p(null),h(!1)},[]),S=Z.useCallback(async()=>{h(!0);try{await i?.()}finally{d?.reset(),x()}},[i,d,x]),C=Z.useCallback(async()=>{if(!f||!_){x();return}h(!0);try{await hs(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 Z.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:X(`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,Q.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,Q.jsx)(`ul`,{className:`space-y-0.5`,children:Object.entries(d.fieldErrors).map(([e,t])=>(0,Q.jsxs)(`li`,{"data-inline-field-error":e,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:g(e)}),`: `,t]},e))}):d.error}),(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:d.cancel,disabled:d.saving,className:`gap-2`,children:[(0,Q.jsx)(tr,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:u(`detail.cancel`)})]}),(0,Q.jsxs)(Y,{variant:`default`,size:`sm`,onClick:b,disabled:d.saving||s,className:`gap-2`,title:s?c:void 0,children:[d.saving?(0,Q.jsx)(br,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(In,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:d.saving?u(`detail.saving`):u(`detail.save`)})]})]}),(0,Q.jsx)(ds,{open:!!f,conflict:f,busy:m,onCancel:x,onReload:S,onOverwrite:C})]})},_s=new Set(le),vs=480,ys=95;function bs({open:e,onClose:t,title:n,record:r,objectName:i,recordId:a,dataSource:o,objectSchema:s,width:c=`min(960px, 60vw)`,columns:l=2,systemFields:u=_s,onFieldSave:d,onDelete:f,resizable:p=!0,fullPageHref:m}){let{t:h}=$(),g=`objectui.drawerWidth.${i}`,[_,v]=Z.useState(()=>{if(typeof window>`u`||!p)return null;try{let e=window.localStorage.getItem(g);if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=vs)return t}}catch{}return null}),y=Z.useMemo(()=>p&&_!=null?`${_}px`:typeof c==`number`?`${c}px`:c,[p,_,c]),b=y?{width:y,maxWidth:y}:void 0,x=Z.useRef(null),S=Z.useCallback(e=>{if(!p)return;e.preventDefault();let t=_??(typeof window<`u`?Math.min(window.innerWidth*.6,960):720);x.current={startX:e.clientX,startWidth:t};let n=e=>{let t=x.current;if(!t)return;let n=t.startX-e.clientX,r=typeof window<`u`?window.innerWidth*ys/100:1600,i=Math.min(r,Math.max(vs,t.startWidth+n));v(Math.round(i))},r=()=>{x.current,x.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{v(e=>(e!=null&&window.localStorage.setItem(g,String(e)),e))}catch{}};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r)},[p,_,g]),C=s?.fields??{},w=(Object.keys(C).length?Object.keys(C):Object.keys(r)).filter(e=>!u.has(e)&&!e.startsWith(`__`)).filter(e=>e in r).filter(e=>!C[e]?.hidden).map(e=>{let t=C[e]||{},n=N(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,format:t.format,reference_to:t.reference,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}});return(0,Q.jsx)(yr,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(Nr,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:b,onOpenAutoFocus:e=>e.preventDefault(),children:[p&&(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":h(`common.resizeDrawer`),onPointerDown:S,className:`hidden sm:block absolute left-0 top-0 h-full w-1.5 cursor-col-resize select-none bg-transparent hover:bg-primary/30 active:bg-primary/50 transition-colors z-10`}),(0,Q.jsx)(Or,{className:`sr-only`,children:(0,Q.jsx)(Xt,{children:n})}),(0,Q.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,Q.jsxs)(de,{canEdit:!!d,children:[(0,Q.jsx)(za,{dataSource:o,inlineEdit:!!d,schema:{type:`detail-view`,objectName:i,resourceId:String(a),data:r,showDelete:!!f,columns:l,fields:w,actions:m?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:h(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(m,`_blank`,`noopener`)}]}]:void 0},onDelete:f?async()=>{try{await f(),t()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}:void 0}),(0,Q.jsx)(gs,{onFieldSave:d?async(e,t)=>{try{await d(e,t)}catch(e){throw console.error(`[RecordDetailDrawer] inline field save failed:`,e),e}}:void 0})]})})]})})}function xs(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 Ss(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]}l();function Cs(e){return e==null?[]:Array.isArray(e)?e.filter(e=>e!=null):[e]}function ws(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 Ts(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 Es(e){return De(e)??null}function Ds(e,t,n=4){if(!e)return[];let r=Array.isArray(e.highlightFields)&&e.highlightFields.length>0?e.highlightFields:null;if(r){let t=Es(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`||!F(t)?!1:(se(t),!0)},u=Es(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 Os(e,t={}){return ws(`page:header`,{recordChrome:t.recordChrome!==!1,...Array.isArray(t.actions)&&t.actions.length>0?{actions:t.actions}:{}})}function ks(e,t={}){let n=t.statusField??E(e),r=t.stages??(n?Ts(e,n):null),i=t.highlightFields??Ds(e,n),a=[];return!t.hideHighlights&&i.length>0&&a.push(ws(`record:highlights`,{fields:i})),!t.hidePath&&n&&r&&r.length>0&&a.push(ws(`record:path`,{statusField:n,stages:r})),a}function As(e){if(!e)return null;let t=m(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_to:t.reference}:{},...t.reference_field?{reference_field:t.reference_field}:{},...t.currency?{currency:t.currency}:{},...t.currencyConfig?{currencyConfig:t.currencyConfig}:{}}},i=Ni(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 js(e,t){return Array.isArray(t)&&t.length>0?t:As(e)??void 0}function Ms(e,t,n){return ws(`record:details`,{sections:js(e,t),...n&&n.length>0?{hideFields:n}:{}})}function Ns(e,t={}){let n=t.statusField??E(e),r=t.highlightFields??Ds(e,n),i=[{label:`Details`,value:`details`,children:[Ms(e,t.sections,r)]}];if(!t.hideRelatedTab&&Array.isArray(t.related)&&t.related.length>0){let e=e=>ws(`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:[ws(`record:approvals`,{...t.approvals.node||{}})]}),e?.enable?.files===!0&&!t.hideAttachments&&i.push({label:`Attachments`,value:`attachments`,children:[Fs()]}),t.showActivity&&i.push({label:`Activity`,value:`activity`,children:[ws(`record:activity`)]}),t.history&&i.push({label:`History`,value:`history`,children:[ws(`record:history`,{entries:t.history.entries,loading:t.history.loading,emptyText:t.history.emptyText,unknownUserText:t.history.unknownUserText})]}),ws(`page:tabs`,{items:i})}function Ps(){return ws(`record:discussion`)}function Fs(){return ws(`record:attachments`)}function Is(e,t={}){let n=t.slots||{},r=[];`header`in n&&n.header!==void 0?r.push(...Cs(n.header)):r.push(Os(e,{recordChrome:t.recordChrome,actions:t.headerActions})),`actions`in n&&n.actions!==void 0&&r.push(...Cs(n.actions)),`alerts`in n&&n.alerts!==void 0&&r.push(...Cs(n.alerts)),`highlights`in n&&n.highlights!==void 0?r.push(...Cs(n.highlights)):r.push(...ks(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(...Cs(n.tabs));else if(`details`in n&&n.details!==void 0){let i=Cs(n.details),o=Ns(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(Ns(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(...Cs(n.discussion)):t.hideDiscussion||r.push(Ps());let o=[{name:`main`,width:`full`,components:r}],s=Cs(n.rightRail);if(i||s.length>0){let e=[];i&&e.push(ws(`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}}var Ls=t({DetailSection:()=>na,DetailView:()=>za,DetailViewRenderer:()=>Rs,RecordActivityRenderer:()=>Vo,RecordAlertRenderer:()=>cs,RecordChatterRenderer:()=>Wo,RecordDetailsRenderer:()=>Ha,RecordHighlightsRenderer:()=>Qa,RecordHistoryRenderer:()=>ts,RecordPathRenderer:()=>Ko,RecordQuickActionsRenderer:()=>Zo,RecordReferenceRailRenderer:()=>as,RecordRelatedListRenderer:()=>Xa,RelatedList:()=>ca,UNMAPPED_ACTIVITY_FEED_TYPE:()=>xo,buildDefaultPageSchema:()=>Is}),Rs=b(({schema:e,dataSource:t,...n})=>{let r=ve(t);return(0,Q.jsx)(Oe,{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:ye(`detail-view`,e?.objectName),children:e=>(0,Q.jsx)(za,{schema:e,dataSource:r,...n})})});R.register(`detail-view`,Rs,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`objectName`,type:`string`,label:`Object Name`},{name:`resourceId`,type:`string`,label:`Resource ID`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`object`,label:`Data`},{name:`layout`,type:`enum`,label:`Layout Mode`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`,label:`Grid Columns`},{name:`sections`,type:`array`,label:`Sections`},{name:`fields`,type:`array`,label:`Fields`},{name:`tabs`,type:`array`,label:`Tabs`},{name:`related`,type:`array`,label:`Related Lists`},{name:`actions`,type:`array`,label:`Actions`},{name:`showBack`,type:`boolean`,label:`Show Back Button`,defaultValue:!0},{name:`backUrl`,type:`string`,label:`Back URL`},{name:`showEdit`,type:`boolean`,label:`Show Edit Button`,defaultValue:!1},{name:`editUrl`,type:`string`,label:`Edit URL`},{name:`showDelete`,type:`boolean`,label:`Show Delete Button`,defaultValue:!1},{name:`deleteConfirmation`,type:`string`,label:`Delete Confirmation Message`},{name:`loading`,type:`boolean`,label:`Show Loading State`},{name:`header`,type:`object`,label:`Custom Header`},{name:`footer`,type:`object`,label:`Custom Footer`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[],related:[]}}),R.register(`detail-section`,na,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Default Collapsed`,defaultValue:!1},{name:`columns`,type:`number`,label:`Columns`,defaultValue:2},{name:`showBorder`,type:`boolean`,label:`Show Border`,defaultValue:!0},{name:`headerColor`,type:`string`,label:`Header Color`}]}),R.register(`related-list`,ca,{namespace:`plugin-detail`,label:`Related List`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`,required:!0},{name:`type`,type:`enum`,label:`Type`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Table`,value:`table`}],defaultValue:`table`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`array`,label:`Data`},{name:`columns`,type:`array`,label:`Columns`}]}),R.register(`detail`,za,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`recordId`,type:`string`,label:`Record ID`},{name:`fields`,type:`array`,label:`Fields`}]}),R.register(`details`,Ha,{namespace:`record`,skipFallback:!0,category:`record`,label:`Record Details`,icon:`FileText`,inputs:[{name:`columns`,type:`enum`,label:`Columns`,enum:[`1`,`2`,`3`,`4`],defaultValue:`2`,description:`Number of columns for field layout (1-4)`},{name:`sections`,type:`array`,label:`Sections`,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` (required) are the field names shown in this section, in order. `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."},{name:`fields`,type:`array`,label:`Fields`,description:`Explicit field list (overrides highlightFields)`},{name:`hideFields`,type:`array`,label:`Hide Fields`,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`,label:`Inline Edit`,defaultValue:!0,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`,label:`Show Body Header`,defaultValue:!1,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."}]}),R.register(`related_list`,Xa,{namespace:`record`,skipFallback:!0,category:`record`,label:`Related List`,icon:`List`,inputs:[{name:`objectName`,type:`string`,label:`Related Object`,required:!0,description:`Related object name (e.g. "task")`},{name:`relationshipField`,type:`string`,label:`Relationship Field`,required:!0,description:`Field on the related object pointing back to this record`},{name:`relationshipValueField`,type:`string`,label:`Relationship Value Field`,defaultValue:`id`,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`,label:`Columns`,required:!0,description:`Fields to display in the related list`},{name:`sort`,type:`array`,label:`Sort`},{name:`limit`,type:`number`,label:`Limit`,defaultValue:5,description:`Records to display initially`},{name:`filter`,type:`array`,label:`Filter`,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`,label:`Title`},{name:`showViewAll`,type:`boolean`,label:`Show "View All"`,defaultValue:!0},{name:`actions`,type:`array`,label:`Actions`,description:`Action IDs available for related records`},{name:`add`,type:`object`,label:`Add Existing`,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).'}]}),R.register(`highlights`,Qa,{namespace:`record`,skipFallback:!0,category:`record`,label:`Highlights Panel`,icon:`Star`,inputs:[{name:`fields`,type:`array`,label:`Fields`,required:!0,description:`Key fields to highlight (1-7), bare names or {name,label?,icon?,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`,label:`Layout`,enum:[`horizontal`,`vertical`],defaultValue:`horizontal`,description:`Layout orientation for highlight fields`}]}),R.register(`activity`,Vo,{namespace:`record`,skipFallback:!0,category:`record`,label:`Activity Timeline`,icon:`Activity`,inputs:[{name:`types`,type:`array`,label:`Activity Types`,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`,label:`Filter Mode`,enum:[`all`,`comments_only`,`changes_only`,`tasks_only`],defaultValue:`all`,description:`Filter the timeline dropdown starts on. The user can still change it; an unrecognised value falls back to "all".`},{name:`showFilterToggle`,type:`boolean`,label:`Show Filter Toggle`,defaultValue:!0,description:`Expose the activity-type filter dropdown in the panel header`},{name:`limit`,type:`number`,label:`Limit`,defaultValue:20,description:`Items per page. Also caps the scoped sys_activity read; "Load more" grows the window by this much.`},{name:`showCompleted`,type:`boolean`,label:`Show Completed`,defaultValue:!1,description:`Include completed activities (sys_activity type "completed", which surfaces as a task item). Off by default.`},{name:`unifiedTimeline`,type:`boolean`,label:`Unified Timeline`,defaultValue:!0,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`,label:`Show Comment Input`,defaultValue:!0,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`,label:`Enable @mentions`,defaultValue:!0,description:`Offer @-mention autocomplete in the composer, from the host discussion context's user list. Off withholds the suggestions.`},{name:`enableReactions`,type:`boolean`,label:`Enable Reactions`,defaultValue:!1,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`,label:`Enable Threaded Replies`,defaultValue:!1,description:`Group replies under their parent comment. Posting a reply requires a host discussion context.`},{name:`showSubscriptionToggle`,type:`boolean`,label:`Show Subscribe Toggle`,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 zs=[{name:`position`,type:`enum`,label:`Position`,enum:[`bottom`,`right`,`left`],defaultValue:`bottom`,description:`Where the panel docks relative to the record body`},{name:`width`,type:`string`,label:`Width`,description:`Panel width as a CSS value (side positions only)`},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Start Collapsed`},{name:`feed`,type:`object`,label:`Feed Options`,description:`Activity-feed config nested inside the panel — same shape as record:activity`}];R.register(`chatter`,Wo,{namespace:`record`,skipFallback:!0,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`,inputs:zs}),R.register(`discussion`,Wo,{namespace:`record`,skipFallback:!0,category:`record`,label:`Discussion`,icon:`MessageSquare`,inputs:zs}),R.register(`path`,Ko,{namespace:`record`,skipFallback:!0,category:`record`,label:`Path / Stepper`,icon:`GitBranch`,inputs:[{name:`statusField`,type:`string`,label:`Status Field`,required:!0,description:`Field representing the current status/stage`},{name:`stages`,type:`array`,label:`Stages`,description:`Explicit stage definitions [{ value, label }] (else derived from field metadata)`}]}),R.register(`quick_actions`,Zo,{namespace:`record`,skipFallback:!0,category:`record`,label:`Quick Actions`,icon:`Zap`,inputs:[{name:`actionNames`,type:`array`,label:`Actions`,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`,label:`Required Permissions`,description:`Hide the whole bar unless the user holds these permissions`},{name:`location`,type:`enum`,label:`Location`,enum:[...c],defaultValue:`record_header`,description:`Which declared action location this bar renders`},{name:`align`,type:`enum`,label:`Align`,enum:[`start`,`center`,`end`],defaultValue:`end`},{name:`inline`,type:`boolean`,label:`Inline`,description:`Render in the flow instead of folding into the record header`},{name:`variant`,type:`string`,label:`Button Variant`,defaultValue:`default`,description:`Passed to the Button primitive; a per-action variant overrides it`},{name:`size`,type:`string`,label:`Button Size`,defaultValue:`sm`,description:`Passed to the Button primitive; a per-action size overrides it`}]}),R.register(`history`,ts,{namespace:`record`,skipFallback:!0,category:`record`,label:`History Timeline`,icon:`Clock`,inputs:[{name:`limit`,type:`number`,label:`Limit`,defaultValue:50,description:`Maximum history entries to display`},{name:`emptyText`,type:`string`,label:`Empty Text`,description:`Copy shown when the record has no history`},{name:`unknownUserText`,type:`string`,label:`Unknown User Text`,description:`Copy substituted when an entry has no resolvable actor`}]}),R.register(`reference_rail`,as,{namespace:`record`,skipFallback:!0,category:`record`,label:`Reference Rail`,icon:`PanelRight`,inputs:[{name:`hideEmpty`,type:`boolean`,label:`Hide When Empty`,defaultValue:!0,description:`Drop the rail entirely when no entries resolve`}]}),R.register(`alert`,cs,{namespace:`record`,skipFallback:!0,category:`record`,label:`Alert Banner`,icon:`triangle-alert`,inputs:[{name:`severity`,type:`enum`,label:`Severity`,enum:[`info`,`warning`,`error`,`success`],defaultValue:`info`},{name:`title`,type:[`string`,`object`],label:`Title`,description:`Accepts an inline translation map ({ en, "zh-CN", … })`},{name:`body`,type:[`string`,`object`],label:`Body`,description:`Accepts an inline translation map ({ en, "zh-CN", … })`},{name:`visible`,type:`string`,label:`Visible When`,description:`Expression gating the banner against the current record`},{name:`icon`,type:`string`,label:`Icon`,description:`Lucide icon name; defaults to the severity icon`},{name:`action`,type:`object`,label:`Call to Action`,description:`{ actionName, label?, variant? } — the action the banner offers`},{name:`dismissible`,type:`boolean`,label:`Dismissible`},{name:`dismissKey`,type:`string`,label:`Dismiss Key`,description:`Stable key the dismissal is remembered under`}]}),R.register(`permission-facet-link`,ar(Ri),{namespace:`field`,skipFallback:!0});export{Ss as a,gs as c,Fa as d,yi as f,Es as i,Ho as l,Is as n,bs as o,As as r,xs as s,Ls as t,Lo as u};
|