@objectstack/console 17.1.0 → 17.2.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 +120 -0
- package/dist/.objectstack-injection.json +2 -2
- package/dist/.objectui-sha +1 -1
- package/dist/assets/{AdapterProvider-3zTVoQKF.js → AdapterProvider-gULVLpjV.js} +1 -1
- package/dist/assets/AiPendingActionsPage-CyG11hX9.js +1 -0
- package/dist/assets/ApiConsolePage-DYuOp_W4.js +1 -0
- package/dist/assets/{AppDocsIndex-DVrJTsbv.js → AppDocsIndex-BXkNskk1.js} +1 -1
- package/dist/assets/AppManagementPage-BvSxDdA_.js +1 -0
- package/dist/assets/ApprovalsInboxPage-oep3a-Ek.js +1 -0
- package/dist/assets/AuditLogPage-BZZ6tzHu.js +1 -0
- package/dist/assets/ComponentNavView-Cq4wkNUa.js +1 -0
- package/dist/assets/{DashboardView-CTBV4_tx.js → DashboardView-C23ZCS2S.js} +1 -1
- package/dist/assets/{DeveloperHubPage-CWq2uYpr.js → DeveloperHubPage-KEpKc45V.js} +1 -1
- package/dist/assets/DocPage-Y4rWCZ3E.js +1 -0
- package/dist/assets/{DocShell-UFsFTSr-.js → DocShell-DMJHUgE5.js} +1 -1
- package/dist/assets/DocsIndex-Bb5OtPb3.js +1 -0
- package/dist/assets/DocsLayout-CoIVTMH_.js +1 -0
- package/dist/assets/DocsSlug-BARWHmXg.js +1 -0
- package/dist/assets/{ExpressionProvider-X1OAB_O-.js → ExpressionProvider-vGLngw8h.js} +1 -1
- package/dist/assets/FlowRunsPage-BeGa9_ge.js +1 -0
- package/dist/assets/{IntegrationsPage-DdKbqwGE.js → IntegrationsPage-DTXA-Nne.js} +2 -2
- package/dist/assets/{InterfaceListPage-FCdy-_Q-.js → InterfaceListPage-BMvedZyV.js} +1 -1
- package/dist/assets/{ManagedByBadge-Bap9_dqR.js → ManagedByBadge-mKmG0hP7.js} +1 -1
- package/dist/assets/MarketplaceAccessDenied-BBMyNu2w.js +1 -0
- package/dist/assets/{MarketplaceInstalledPage-Cv-qDRNA.js → MarketplaceInstalledPage-B4qrvb7w.js} +1 -1
- package/dist/assets/MarketplacePackagePage-BuVfVeBj.js +4 -0
- package/dist/assets/MarketplacePage-Cmltk5nG.js +1 -0
- package/dist/assets/{MetadataInspector-CNeJqkLQ.js → MetadataInspector-kVAu8vlh.js} +1 -1
- package/dist/assets/{MetadataProvider-DwMR1SMR.js → MetadataProvider-DyFZSNqq.js} +1 -1
- package/dist/assets/ObjectDataPage-BKHEYwXA.js +1 -0
- package/dist/assets/{PageView-XUBdr6tb.js → PageView-CTqS-VD9.js} +1 -1
- package/dist/assets/ProfilePage-CBUxXn5a.js +1 -0
- package/dist/assets/PublicFormsPage-B8Dk8fky.js +1 -0
- package/dist/assets/RecordDetailView-BBNqsNy9.js +11 -0
- package/dist/assets/{RecordFormPage-CLZcT8Z0.js → RecordFormPage-CeUmmc_n.js} +1 -1
- package/dist/assets/ReportDefaultInspector-CRjDi2Er.js +3 -0
- package/dist/assets/ReportView-Cwi_Po4H.js +2 -0
- package/dist/assets/{SearchResultsPage-lgNcs7l7.js → SearchResultsPage-Cg0oq2by.js} +1 -1
- package/dist/assets/{SettingsHub-TQOc7wH3.js → SettingsHub-B5_S9YgI.js} +1 -1
- package/dist/assets/{SettingsView-DAje5pDB.js → SettingsView-Csi1awf-.js} +1 -1
- package/dist/assets/SystemHubPage-CnDri9oU.js +1 -0
- package/dist/assets/{createDerive-xZXxMz1g.js → createDerive-B3AGnDaY.js} +1 -1
- package/dist/assets/dist-Ck19TqqJ.js +5 -0
- package/dist/assets/framework-BwfIhdyz.js +55 -0
- package/dist/assets/getIcon-1ZXs1v-a.js +1 -0
- package/dist/assets/{highlighted-body-OFNGDK62-DUQut-ZU.js → highlighted-body-OFNGDK62-CnGKNo0r.js} +1 -1
- package/dist/assets/i18n-rra-09wp.js +9 -0
- package/dist/assets/index-BLepsDd_.js +19 -0
- package/dist/assets/index-D26gl3rg.css +2 -0
- package/dist/assets/{infrastructure-CerjT_c2.js → infrastructure-BCTDJsqi.js} +2 -2
- package/dist/assets/mermaid-GHXKKRXX-CR9PcY0X.js +1 -0
- package/dist/assets/metadata-admin-BE9_-F_f.js +25 -0
- package/dist/assets/plugin-calendar-BfY9ZunQ.js +1 -0
- package/dist/assets/plugin-charts-CmWL7Og-.js +7 -0
- package/dist/assets/plugin-chatbot-mxoQfkdx.js +120 -0
- package/dist/assets/plugin-dashboard-CzbAW1Rz.js +6 -0
- package/dist/assets/plugin-form-ItAwTFz-.js +1 -0
- package/dist/assets/plugin-gantt-DF5W5xkN.js +64 -0
- package/dist/assets/plugin-grid-B42Photo.js +9 -0
- package/dist/assets/plugin-kanban-Dh3HIJIm.js +1 -0
- package/dist/assets/{plugin-map-CQAe4Yh6.js → plugin-map-C1wSLqlB.js} +1 -1
- package/dist/assets/{plugin-markdown-7fyNN0UM.js → plugin-markdown-DNllWgPM.js} +1 -1
- package/dist/assets/{plugin-report-01bEGHuR.js → plugin-report-yfOfZPQg.js} +3 -3
- package/dist/assets/plugin-timeline-BpuaaqBd.js +1 -0
- package/dist/assets/{plugin-tree-DW0XC55y.js → plugin-tree-BrXE50se.js} +1 -1
- package/dist/assets/plugin-view-Jc0rkk7A.js +1 -0
- package/dist/assets/plugins-views-cOiN-mPq.js +4 -0
- package/dist/assets/{runtime-metadata-persistence-DpS5GXuQ.js → runtime-metadata-persistence-DTOJpVmd.js} +1 -1
- package/dist/assets/{skeletons-DVwGbFUS.js → skeletons-BwA1TSR2.js} +1 -1
- package/dist/assets/src-BLbFBP_B.js +1 -0
- package/dist/assets/{src-ClOOPIkS.js → src-DhAd4aY4.js} +1 -1
- package/dist/assets/ui-components-Dwq5utCl.js +42 -0
- package/dist/assets/ui-layout-DPFlQaQp.js +1 -0
- package/dist/assets/use-book-data-CZc8MJsb.js +1 -0
- package/dist/assets/{useActionModal-Z2yDiihK.js → useActionModal-DYiSBx1G.js} +1 -1
- package/dist/assets/usePackageL10n-D91-102Q.js +1 -0
- package/dist/assets/{useSettingsLabel-CvZKl8CQ.js → useSettingsLabel-CeZ36S4g.js} +1 -1
- package/dist/assets/vendor-objectstack-B1R3ym-9.js +264 -0
- package/dist/eager-closure.json +277 -0
- package/dist/index.html +54 -14
- package/package.json +1 -1
- 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/AuditLogPage-B-2e1YhN.js +0 -1
- package/dist/assets/ComponentNavView-BVbkfJfE.js +0 -1
- package/dist/assets/CreateViewDialog-CW0w7Nxc.js +0 -1
- package/dist/assets/FlowRunsPage-CUhBLwm-.js +0 -1
- package/dist/assets/MarketplaceAccessDenied-CrK7hygV.js +0 -1
- package/dist/assets/MarketplacePackagePage-CMS--SE2.js +0 -4
- package/dist/assets/MarketplacePage-njErv-tN.js +0 -1
- package/dist/assets/ObjectDataPage-BVV4yksz.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/ReportDefaultInspector-DU2azDYd.js +0 -3
- package/dist/assets/ReportView-oFhBKNBE.js +0 -2
- package/dist/assets/SystemHubPage-DUE-2-vc.js +0 -1
- package/dist/assets/componentRegistry-ByxoJqMW.js +0 -1
- package/dist/assets/dist-jor1XT9f.js +0 -5
- package/dist/assets/framework-LCCQTTcs.js +0 -47
- package/dist/assets/getIcon-Bnm_i39L.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/mermaid-GHXKKRXX-DQTMu5TJ.js +0 -1
- package/dist/assets/metadata-admin-C_DEFfDE.js +0 -25
- 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-timeline-Dw4Lj2Rz.js +0 -1
- package/dist/assets/plugin-view-B9yCVdSX.js +0 -1
- package/dist/assets/plugins-views-BaBStVok.js +0 -4
- package/dist/assets/src-BA9h8a8o.js +0 -1
- package/dist/assets/src-Ctj_ivDh.js +0 -19
- 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/usePackageL10n-Cy-u65Zo.js +0 -1
- package/dist/assets/vendor-objectstack-DGpW4oR-.js +0 -158
|
@@ -1,4 +0,0 @@
|
|
|
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-CerjT_c2.js";import{Kt as c,Rt as l,nt as u,on as d,qt as f,un as p}from"./vendor-objectstack-DGpW4oR-.js";import{$ as m,A as h,Ar as g,C as _,Dr as v,Er as y,Et as b,Fr as x,Ft as S,Gr as C,Gt as w,H as T,Ht as E,Ir as D,It as O,J as k,L as A,Lr as j,Mr as M,Mt as N,Nr as P,Or as ee,P as F,Pn as I,Rr as te,Rt as L,S as ne,T as re,Tr as ie,Tt as ae,Ut as oe,Wt as R,X as se,Y as ce,Yt as le,_r as z,d as ue,et as B,h as de,ir as fe,jr as pe,kr as me,n as he,nr as ge,ot as V,qt as _e,sr as ve,tt as ye,vr as H,w as be,wr as U,xt as xe,zr as Se}from"./framework-LCCQTTcs.js";import{$c as Ce,$r as we,A as Te,Aa as Ee,An as De,Ao as Oe,Ar as W,B as ke,Bo as Ae,Br as je,Cn as G,Co as Me,Cs as K,Da as Ne,Dc as q,Dn as Pe,Dr as Fe,Ds as Ie,Dt as Le,En as Re,Er as ze,Es as Be,Et as Ve,F as He,Fa as Ue,Fn as We,G as Ge,Gc as Ke,Gi as J,Gr as qe,H as Je,Hc as Ye,Ho as Xe,Hr as Ze,Ht as Qe,I as $e,In as et,Ir as tt,J as nt,Ji as rt,Jo as it,Jr as at,K as ot,Kr as st,Ks as ct,L as lt,La as ut,Ln as Y,Lr as dt,M as ft,N as pt,Na as mt,Nr as ht,On as gt,Or as _t,Ot as vt,P as yt,Pr as bt,Pt as xt,Qc as St,Qr as X,R as Ct,Rn as wt,Ro as Tt,Rr as Et,Rs as Dt,S as Ot,Si as kt,So as At,T as jt,Ti as Mt,Ts as Nt,Tt as Pt,U as Ft,Ua as It,Uc as Lt,Ur as Rt,Ut as zt,V as Bt,Vc as Vt,Vi as Ht,Vo as Ut,Vr as Wt,Vs as Gt,Vt as Kt,W as qt,Wa as Jt,Wr as Yt,Wt as Xt,X as Zt,Xa as Qt,Xi as $t,Xo as en,Xr as tn,Yr as nn,Z as rn,Zc as an,Zs as on,_c as sn,_n as cn,_o as ln,ai as un,al as dn,bn as fn,bo as pn,ca as mn,ct as hn,da as gn,dl as _n,ei as vn,el as yn,fa as bn,fl as xn,ft as Sn,gc as Cn,gn as wn,hn as Tn,ho as En,i as Dn,ia as On,jr as kn,js as An,kc as jn,kn as Mn,ll as Nn,lt as Pn,m as Fn,ma as In,mn as Ln,mt as Rn,n as zn,oa as Bn,ol as Z,pa as Vn,pl as Hn,ps as Un,q as Wn,qc as Gn,qi as Kn,qr as qn,ra as Jn,rc as Yn,ri as Xn,sa as Zn,t as Qn,uo as $n,us as er,v as tr,vc as nr,vi as rr,vn as ir,w as ar,wn as or,ws as sr,wt as cr,x as lr,xn as ur,xo as dr,y as fr,yc as pr,yn as mr,z as hr,za as gr,zi as _r,zr as vr}from"./ui-components-3mb69z8L.js";import{s as yr}from"./plugin-grid-D49BBhCX.js";var Q=e(r(),1),$=a(),br={grid:(0,$.jsx)(en,{className:`h-4 w-4`}),kanban:(0,$.jsx)(Oe,{className:`h-4 w-4`}),gallery:(0,$.jsx)(Ut,{className:`h-4 w-4`}),calendar:(0,$.jsx)(jn,{className:`h-4 w-4`}),timeline:(0,$.jsx)(dn,{className:`h-4 w-4`}),gantt:(0,$.jsx)(rt,{className:`h-4 w-4`}),map:(0,$.jsx)(En,{className:`h-4 w-4`}),chart:(0,$.jsx)(q,{className:`h-4 w-4`}),tree:(0,$.jsx)(Me,{className:`h-4 w-4`})},xr={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`},Sr=xn({"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 Cr(){let{t:e}=Sr();return Q.useMemo(()=>{let t={};for(let[n,r]of Object.entries(xr))t[n]=e(r);return t},[e])}var wr=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:n,className:r,animated:i=!0})=>{let[a,o]=Q.useState(!1),s=Cr(),c=Q.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,$.jsx)(`div`,{role:`tablist`,"data-testid":`view-switcher-segmented`,className:Z(`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,$.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:Z(`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:[br[t],(0,$.jsx)(`span`,{className:`hidden sm:inline-block`,children:s[t]})]},t)})}):(0,$.jsxs)(We,{open:a,onOpenChange:o,children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"data-testid":`view-switcher-dropdown`,"aria-label":s[e],className:Z(`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:[br[e],(0,$.jsx)(`span`,{className:`hidden sm:inline-block`,children:s[e]}),(0,$.jsx)(nr,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(et,{align:`end`,className:`w-44 p-1`,children:t.map(t=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c(t),"data-state":t===e?`on`:`off`,className:Z(`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:[br[t],(0,$.jsx)(`span`,{className:`flex-1 text-left`,children:s[t]}),t===e&&(0,$.jsx)(pr,{className:`h-3.5 w-3.5`})]},t))})]})};function Tr({title:e,badge:t,onClear:n,clearLabel:r,defaultOpen:i=!0,children:a}){let[o,s]=Q.useState(i);return(0,$.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,$.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,$.jsx)(nr,{className:Z(`h-3.5 w-3.5 transition-transform`,!o&&`-rotate-90`)}),e,typeof t==`number`&&t>0&&(0,$.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,$.jsx)(`button`,{type:`button`,onClick:n,className:`text-[11px] text-muted-foreground hover:text-foreground`,children:r})]}),o&&(0,$.jsx)(`div`,{className:`px-3 pb-3`,children:a})]})}function Er(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]=Q.useState(!1),y=[!!i?.fields?.length,!!s?.field,u&&u.mode!==`compact`,(f?.size??0)>0,!!h].filter(Boolean).length,b=u?.mode===`compact`?gn:u?.mode===`comfortable`?bn:Vn,x=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,$.jsxs)(We,{open:_,onOpenChange:v,children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,"aria-label":x,title:x,className:Z(`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,$.jsx)(Bn,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:x}),y>0&&(0,$.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,$.jsxs)(et,{align:`end`,className:`w-80 p-0`,"data-testid":`view-settings-content`,children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 border-b`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold`,children:x}),(0,$.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`list.viewSettingsHint`,{defaultValue:`Grouping, color, density, and visible fields.`})})]}),r&&a&&(0,$.jsx)(Tr,{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,$.jsx)(Sn,{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,$.jsxs)(Tr,{title:t(`list.rowColor`,{defaultValue:`Row Color`}),onClear:s?()=>c(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),defaultOpen:!!s,children:[(0,$.jsx)(`label`,{className:`block text-[11px] text-muted-foreground mb-1`,children:t(`list.colorByField`,{defaultValue:`Color by field`})}),(0,$.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,$.jsx)(`option`,{value:``,children:t(`list.none`,{defaultValue:`None`})}),n.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]}),l&&u&&(0,$.jsx)(Tr,{title:t(`grid.toolbar.densityMode`,{defaultValue:`Density`}),defaultOpen:u.mode!==`compact`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(X,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:u.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,$.jsx)(b,{className:`h-3.5 w-3.5`}),(0,$.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,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`grid.toolbar.densityCycleShortHint`,{defaultValue:`Click to cycle`})})]})}),m&&g&&(0,$.jsx)(Tr,{title:t(`list.recordEditingTitle`,{defaultValue:`Record editing`}),defaultOpen:!!h,children:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!!h,onChange:()=>g(!h),className:`rounded border-input`,"data-testid":`view-settings-inline-edit`}),(0,$.jsx)(`span`,{children:t(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`})})]})}),d&&f&&p&&(0,$.jsx)(Tr,{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,$.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-0.5`,children:n.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,$.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,$.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.name))})})]})]})}function Dr(){let{t:e}=h(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}var Or=new Set([`lookup`,`master_detail`,`user`,`owner`]),kr={select:`single-choice`,"multi-select":`multi-choice`,boolean:`multi-choice`,"date-range":`range`,text:`text`};function Ar(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,l(e.operator),e.value]):[],default:e.default??e.isDefault}))}function jr({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){switch(e.element){case`dropdown`:return(0,$.jsx)(Nr,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s});case`tabs`:return(0,$.jsx)(Pr,{tabs:Ar(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,$.jsx)(Fr,{fields:e.fields||[],onFilterChange:r,className:a});default:return null}}function Mr(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_to??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 Nr({fields:e,objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){let{fieldLabel:c,translateOptions:l}=re(),u=Dr(),d=t?.name,f=Q.useMemo(()=>new Map(e.map(e=>[e.field,kr[e.type??``]])),[e]),[p,m]=Q.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=Q.useRef({}),g=Q.useMemo(()=>Mr(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]),_=Q.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)};Q.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=Or.has(e.type||``)&&e.options.length===0&&(e.referenceTo||e.type===`user`||e.type===`owner`),s=o?`w-72`:`w-56`;return(0,$.jsxs)(We,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"data-testid":`filter-badge-${e.field}`,className:Z(`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,$.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),i&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:r}),i?(0,$.jsx)(un,{className:`h-3 w-3 opacity-60 hover:opacity-100`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),v(e.field,[])}}):(0,$.jsx)(nr,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(et,{align:`start`,className:Z(s,`p-2`),children:o?(0,$.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,$.jsx)(Ve,{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,$.jsx)(`div`,{className:`space-y-2 p-1`,"data-testid":`filter-range-${e.field}`,children:[0,1].map(n=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`w-8 shrink-0`,children:n===0?`From`:`To`}),(0,$.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,$.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,$.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,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-muted-foreground`,children:`No options`}):e.options.map(n=>(0,$.jsxs)(`label`,{className:Z(`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,$.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,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,$.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,$.jsx)(`div`,{className:Z(`flex items-center gap-0.5 overflow-x-auto`,a),"data-testid":`user-filters-dropdown`,children:g.length===0?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,$.jsxs)($.Fragment,{children:[y.map(x),b.length>0&&(0,$.jsxs)(We,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.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,$.jsx)(`span`,{children:u}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:b.length}),(0,$.jsx)(nr,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(et,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:b.map(x)})})]})]})})}function Pr({tabs:e,showAllRecords:t,allowAddTab:n,onFilterChange:r,className:i,initialTab:a,onSelectionsChange:o}){let[s,c]=Q.useState(()=>a&&(a===`__all__`||e.some(e=>e.id===a))?a:e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),[l,u]=Q.useState([]),[d,f]=Q.useState(!1),[p,m]=Q.useState(``),h=Q.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=Q.useCallback(e=>{c(e),r(h(e)),o?.({_tab:[e]})},[h,r,o]),_=Q.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]),v=Q.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=Q.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 Q.useEffect(()=>{if(s&&s!==`__all__`){let t=e.find(e=>e.id===s);t&&r(t.filters||[])}},[]),(0,$.jsxs)(`div`,{className:Z(`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,$.jsx)(`button`,{type:`button`,"data-testid":`filter-tab-${t}`,onClick:()=>g(t),className:Z(`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,$.jsxs)(`span`,{className:Z(`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,$.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,$.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,$.jsx)(un,{className:`h-3 w-3`})})]},e.id)}),n&&(0,$.jsxs)(We,{open:d,onOpenChange:e=>{f(e),e||m(``)},children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.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,$.jsx)(Ee,{className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(et,{align:`start`,className:`w-64 p-2 space-y-2`,"data-testid":`filter-tab-add-content`,children:[(0,$.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,$.jsx)(wt,{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,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(X,{size:`sm`,className:`h-7 px-2 text-xs`,disabled:!p.trim(),"data-testid":`filter-tab-add-confirm`,onClick:v,children:`Add tab`})})]})]})]})}function Fr({fields:e,onFilterChange:t,className:n}){let[r,i]=Q.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),a=Q.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 Q.useEffect(()=>{r.size>0&&a(r)},[]),(0,$.jsx)(`div`,{className:Z(`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,$.jsx)(X,{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 Ir=[`latitudeField`,`longitudeField`,`locationField`,`titleField`,`descriptionField`,`zoom`,`center`];function Lr(e){if(!e||typeof e!=`object`)return{};let t=e;return Object.fromEntries(Ir.filter(e=>e in t).map(e=>[e,t[e]]))}function Rr(e){switch(e.toLowerCase().replace(/[_\s]/g,``)){case`equals`:case`eq`:return`=`;case`notequals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;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 zr=[],Br=new Set([`nin`,`not_in`,`notIn`,`notin`,`not in`]);function Vr(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)?Vr(e):e)]:n===`in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`=`,r[0]]:[`or`,...r.map(e=>[t,`=`,e])]:Br.has(n)&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`!=`,r[0]]:[`and`,...r.map(e=>[t,`!=`,e])]:e}function Hr(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 Ur(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Wr(e){switch(e){case`bottom`:return{top:!1,bottom:!0};case`both`:return{top:!0,bottom:!0};default:return{top:!0,bottom:!1}}}function Gr(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 Kr(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?Vr(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function qr(e,t,n){let r=Jr(t);return te(e,r.length>0?r:void 0,...Kr(n))}function Jr(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=Kr(e.conditions.filter(e=>Le.has(e.operator)?!0:vt(e.operator,e.value)).map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:Le.has(e.operator)?[e.field,Rr(e.operator),null]:[e.field,Rr(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}var Yr=xn({"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.`,"detail.recordDetail":`Record Detail`,"detail.recordDetailWithLabel":`{{label}} Detail`},`list.recordCount`);function Xr(){let{fieldLabel:e,actionLabel:t,objectLabel:n}=be();return{fieldLabel:e,actionLabel:t,objectLabel:n}}var Zr=Q.forwardRef(({schema:e,className:t,onViewChange:n,onFilterChange:r,onSortChange:i,onSearchChange:a,onHiddenFieldsChange:s,onInlineEditChange:c,onColumnStateChange:l,onRowClick:u,showViewSwitcher:d,userFilterSelections:f,onUserFilterSelectionsChange:p,initialFilters:m,initialSearchTerm:h,..._},v)=>{let y=d??e?.showViewSwitcher??!1,{t:S}=Yr(),{fieldLabel:C,actionLabel:T,objectLabel:O}=Xr(),{translateOptions:k}=re(),j=Q.useMemo(()=>E(e),[e]),M=Q.useCallback((e,t)=>j.objectName?C(j.objectName,e,t):t,[j.objectName,C]),N=Q.useCallback(e=>{let t=Ur(e);return j.objectName&&typeof T==`function`?T(j.objectName,e,t):t},[j.objectName,T]),F=Q.useMemo(()=>{let e=j.userActions,t=j.addRecord?.enabled===!0&&e?.addRecordForm!==!1,n=Wr(j.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:j.compactToolbar===!0,showAddRecord:t,showAddRecordTop:t&&n.top,showAddRecordBottom:t&&n.bottom}},[j.userActions,j.compactToolbar,j.addRecord]),[I,te]=Q.useState(j.viewType),[L,ne]=Q.useState(()=>h??``),[ie,ae]=Q.useState(!1),[se,ce]=Q.useState(!1),[z,ue]=Q.useState(()=>Hr(j.sort)),B=Q.useMemo(()=>JSON.stringify(j.sort||[]),[j.sort]);Q.useEffect(()=>{ue(Hr(j.sort))},[B]);let de=Q.useMemo(()=>Hr(j.sort),[B]),fe=Q.useMemo(()=>z.length!==de.length||z.some((e,t)=>e.field!==de[t].field||e.order!==de[t].order),[z,de]),[me,ge]=Q.useState(!1),[V,ye]=Q.useState(()=>m&&Array.isArray(m.conditions)?m:{id:`root`,logic:`and`,conditions:[]}),H=_.dataSource,[be,U]=Q.useState([]),[Se,Ce]=Q.useState(null),[we,Te]=Q.useState(`network`),[De,Oe]=Q.useState(()=>!(Array.isArray(j.data)||j.data&&typeof j.data==`object`&&j.data.provider===`value`&&Array.isArray(j.data.items)||j.viewType===`gantt`&&j.data&&typeof j.data==`object`&&!Array.isArray(j.data)&&j.data.provider===`api`)),[W,ke]=Q.useState(null),[je,G]=Q.useState(!1),[Me,K]=Q.useState(0),[q,Pe]=Q.useState(!1);Q.useImperativeHandle(v,()=>({refresh:()=>K(e=>e+1)}),[]),Q.useEffect(()=>{if(!(!H?.onMutation||!j.objectName))return H.onMutation(e=>{e.resource===j.objectName&&K(e=>e+1)})},[H,j.objectName]);let[Fe,Ie]=Q.useState(void 0),Le=Fe??j.pagination?.pageSize??100,[Re,ze]=Q.useState(1),[Ve,He]=Q.useState(null),[Ue,Ge]=Q.useState(null),Ke=Q.useMemo(()=>{if(j.grouping?.fields?.length)return j.grouping;let e=typeof j.groupBy==`string`?j.groupBy.trim():``,t=typeof j.groupBy2==`string`?j.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},[j.grouping,j.groupBy,j.groupBy2]),[J,qe]=Q.useState(Ke),[Je,Ye]=Q.useState(!1),Xe=Q.useRef(Ke);Q.useEffect(()=>{Xe.current!==Ke&&(Xe.current=Ke,qe(Ke))},[Ke]);let[Ze,Qe]=Q.useState(j.rowColor),[$e,tt]=Q.useState(!1),[nt,rt]=Q.useState([]),at=Q.useRef(0),[ot,st]=Q.useState([]),ct=Q.useMemo(()=>{let e=j.userFilters;if(!e)return;if(e.element===`tabs`||e.fields&&e.fields.length>0||!W?.fields)return e;let t=new Set([`select`,`multi-select`,`boolean`]),n=[],r=Array.isArray(W.fields)?W.fields.map(e=>[e.name,e]):Object.entries(W.fields);for(let[e,i]of r)(t.has(i.type)||i.options&&!i.type)&&n.push({field:e,label:M(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[j.userFilters,W,M]),[lt,dt]=Q.useState(()=>new Set(j.hiddenFields||[])),ft=Q.useMemo(()=>JSON.stringify(j.hiddenFields||[]),[j.hiddenFields]);Q.useEffect(()=>{dt(new Set(j.hiddenFields||[]))},[ft]);let pt=Q.useCallback(e=>{dt(e),s?.(Array.from(e))},[s]),[mt,ht]=Q.useState(!1),[gt,_t]=Q.useState(()=>!!j.inlineEdit);Q.useEffect(()=>{_t(!!j.inlineEdit)},[j.inlineEdit]);let vt=Q.useCallback(e=>{_t(e),c?.(e)},[c]),[yt,bt]=Q.useState(!1),[xt,St]=Q.useState(!1),[Ct,Tt]=Q.useState(null),{getObjectApiOperations:Et,can:Dt}=o(),Ot=j.objectName?Et(j.objectName):void 0,At=j.allowExport!==!1&&j.operations?.export!==!1&&(!Ot||Ot.includes(`export`)),jt=Q.useMemo(()=>{let e=j.bulkActions;return!e||e.length===0||D(W,Ot).delete&&(!j.objectName||Dt(j.objectName,`delete`))?e:e.filter(e=>String(e).toLowerCase()!==`delete`)},[j.bulkActions,j.objectName,W,Ot,Dt]),Nt=Q.useMemo(()=>j.userActions?.editInline!==!1&&x(W,Ot)&&(!j.objectName||Dt(j.objectName,`update`)),[j.userActions,j.objectName,W,Ot,Dt]),Ft=Q.useMemo(()=>{if(j.exportOptions)return Array.isArray(j.exportOptions)?{formats:j.exportOptions}:j.exportOptions},[j.exportOptions]),It=Q.useMemo(()=>{let e=Ft?.formats||[`csv`,`json`],t=typeof H?.exportDownload==`function`&&j.objectName&&Ft?.streaming!==!1?[`csv`,`xlsx`,`json`]:[`csv`,`json`];return e.filter(e=>t.includes(e))},[Ft,H,j.objectName]);Q.useEffect(()=>{let e=Ft?.formats;if(!e)return;let t=e.filter(e=>!It.includes(e));t.length>0&&console.warn(`[ObjectUI] ListView export: unsupported format(s) hidden from the menu: ${t.join(`, `)}`)},[Ft,It]);let Lt=Q.useMemo(()=>oe(j.rowHeight)??`compact`,[j.rowHeight]),Rt=A(Lt,{onChange:j.onDensityChange}),zt=Q.useMemo(()=>`objectui:gallery:density:${j.objectName??`default`}`,[j.objectName]),[Bt,Vt]=Q.useState(()=>{if(typeof window>`u`)return j.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(zt);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return j.gallery?.cardSize??`medium`}),Ht=Q.useCallback(()=>{Vt(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(zt,t)}catch{}return t})},[zt]),Ut=Q.useCallback(async()=>{K(e=>e+1)},[]),{ref:Wt,isRefreshing:Gt,pullDistance:Kt}=yr({onRefresh:Ut,enabled:!!H&&!!j.objectName}),qt=Q.useMemo(()=>j.id?`listview-${j.objectName}-${j.id}-view`:`listview-${j.objectName}-view`,[j.objectName,j.id]);Q.useEffect(()=>{let e=!0;return G(!1),ke(null),(async()=>{if(!H||!j.objectName){G(!0);return}if(typeof H.getObjectSchema!=`function`){G(!0);return}try{let t=await H.getObjectSchema(j.objectName);e&&ke(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&G(!0)}})(),()=>{e=!1}},[j.objectName,H]);let Jt=Q.useMemo(()=>{let e=Array.isArray(j.columns)?j.columns.map(e=>P(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(j.kanban),n(j.options?.kanban),n(j.calendar),n(j.options?.calendar),n(j.gallery),n(j.options?.gallery),n(j.timeline),n(j.options?.timeline),n(j.gantt),n(j.options?.gantt);let r=t.size>0?Array.from(t):void 0;return pe(W?.fields,r)},[W?.fields,j.columns,j.kanban,j.calendar,j.gallery,j.timeline,j.gantt,j.options]),Yt=o(),Xt=I===`gantt`&&!!j.data&&typeof j.data==`object`&&!Array.isArray(j.data)&&j.data.provider===`api`;Q.useEffect(()=>{let e=!0,t=++at.current;if(j.data&&typeof j.data==`object`&&!Array.isArray(j.data)){let e=j.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)))}U(t),Oe(!1),Pe(!1);return}}if(Array.isArray(j.data)){let e=j.data;if(L){let t=L.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}U(e),Oe(!1),Pe(!1);return}if(Xt){Oe(!1),Pe(!1);return}return je?((async()=>{if(!H||!j.objectName){Oe(!1);return}Oe(!0),Ce(null);try{let n=qr(j.filter,V,ot),r=z.length>0?z.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,i=(()=>{let e=Array.isArray(j.columns)?j.columns.map(e=>P(e)).filter(e=>typeof e==`string`&&e.length>0):[],t=Yt?.isLoaded&&j.objectName?e.filter(e=>Yt.checkField(j.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 Jt)n.add(e);let r=(()=>{let e=W?.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))&&n.add(e)},a=e=>{R.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(j.kanban),o(j.options?.kanban),o(j.calendar),o(j.options?.calendar),o(j.gallery),o(j.options?.gallery),o(j.timeline),o(j.options?.timeline);{let e=j.timeline??j.options?.timeline;e&&!Array.isArray(e.metaFields)&&(i(`status`),i(`priority`))}o(j.gantt),o(j.options?.gantt);for(let e of w(_e({conditionalFormatting:j.conditionalFormatting,rowActionDefs:j.rowActionDefs,bulkActionDefs:j.bulkActionDefs,objectActions:W?.actions,userActions:j.userActions??W?.userActions})))a(e);return Array.from(n)})(),a=n!==void 0,o=I===`grid`&&!J?.fields?.length,s=o?(Re-1)*Le:0,c={...a?{$filter:n}:{},$orderby:r,$top:Le,...s>0?{$skip:s}:{},...i?{$select:i}:{},...Jt.length>0?{$expand:Jt}:{},...L?{$search:L,...j.searchableFields&&j.searchableFields.length>0?{$searchFields:j.searchableFields}:{}}:{}},l=await H.find(j.objectName,c);if(!e||t!==at.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)),U(u);let d=l&&typeof l==`object`?l.total??l.count:void 0,f=typeof d==`number`?d:null;He(o?f:null),Ge(c),Pe(!(o&&f!=null)&&u.length>=Le)}catch(e){t===at.current&&(console.error(`ListView data fetch error:`,e),U([]),Ce(e?.message?String(e.message):String(e??`Unknown error`)),Te(he(e)))}finally{e&&t===at.current&&Oe(!1)}})(),()=>{e=!1}):void 0},[j.objectName,j.data,H,j.filter,Le,z,V,ot,Me,L,j.searchableFields,Jt,je,j.refreshTrigger,Yt,Re,I,J,Xt]);let Zt=JSON.stringify([j.objectName,j.filter,Le,z,V,ot,L,I,J]),en=Q.useRef(Zt);Q.useEffect(()=>{en.current!==Zt&&(en.current=Zt,ze(1))},[Zt]);let tn=Q.useMemo(()=>{let e=[`grid`];(j.kanban?.groupByField||j.kanban?.groupField||j.options?.kanban?.groupField)&&e.push(`kanban`),(j.gallery?.coverField||j.gallery?.imageField||j.options?.gallery?.imageField)&&e.push(`gallery`),(j.calendar?.startDateField||j.options?.calendar?.startDateField)&&e.push(`calendar`),Gr(j).startDateField&&e.push(`timeline`),(j.gantt?.startDateField||j.options?.gantt?.startDateField)&&e.push(`gantt`),(j.options?.map?.locationField||j.options?.map?.latitudeField&&j.options?.map?.longitudeField)&&e.push(`map`),(j.tree?.parentField||j.options?.tree?.parentField||j.viewType===`tree`)&&e.push(`tree`),j.viewType&&!e.includes(j.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`,`tree`].includes(j.viewType)&&e.push(j.viewType);let t=j.appearance?.allowedVisualizations;if(Array.isArray(t)&&t.length>0){let n=t.filter(t=>e.includes(t));return n.length>0?n:[`grid`]}return e},[j.options,j.viewType,j.kanban,j.calendar,j.gantt,j.gallery,j.timeline,j.tree,j.appearance?.allowedVisualizations]);Q.useEffect(()=>{j.viewType&&te(j.viewType)},[j.viewType]);let nn=Q.useCallback(e=>{te(e);try{localStorage.setItem(qt,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}n?.(e)},[qt,n]),rn=Q.useCallback(e=>{ne(e),a?.(e)},[a]),on=xe({navigation:j.navigation,objectName:j.objectName,onNavigate:j.onNavigate,onRowClick:u}),sn=j.label?S(`detail.recordDetailWithLabel`,{label:j.label}):j.objectName?S(`detail.recordDetailWithLabel`,{label:j.objectName.charAt(0).toUpperCase()+j.objectName.slice(1)}):S(`detail.recordDetail`),cn=Q.useMemo(()=>{let e=Array.isArray(j.columns)?j.columns:[];if(Yt?.isLoaded&&j.objectName&&(e=e.filter(e=>{let t=P(e);return!t||Yt.checkField(j.objectName,t,`read`)})),lt.size>0&&(e=e.filter(e=>{let t=P(e);return t!=null&&!lt.has(t)})),j.fieldOrder&&j.fieldOrder.length>0){let t=new Map(j.fieldOrder.map((e,t)=>[e,t]));e=[...e].sort((e,n)=>(t.get(P(e))??1/0)-(t.get(P(n))??1/0))}return e},[j.columns,j.objectName,lt,j.fieldOrder,Yt]),ln=Q.useMemo(()=>{let e=Rt.mode===`compact`?`compact`:Rt.mode===`spacious`?`tall`:`medium`,t={objectName:j.objectName,fields:cn,filter:j.filter,sort:z,className:`h-full w-full`,showSearch:!1,onRowClick:on.handleClick,rowHeight:e,hideRowHeightToggle:!0,...l?{onColumnStateChange:l}:{},...j.columnState?{columnState:j.columnState}:{}};switch(I){default:case`grid`:return{type:`object-grid`,...t,columns:cn,...j.conditionalFormatting?{conditionalFormatting:j.conditionalFormatting}:{},editable:gt&&Nt,...j.wrapHeaders==null?{}:{wrapHeaders:j.wrapHeaders},...j.resizable==null?{}:{resizable:j.resizable},...j.selection?{selection:j.selection}:{},...j.pagination?{pagination:j.pagination}:{},...J?{grouping:J}:{},...Ze?{rowColor:Ze}:{},...j.rowActions?{rowActions:j.rowActions}:{},...j.rowActionDefs?{rowActionDefs:j.rowActionDefs}:{},...j.bulkActions?{batchActions:j.bulkActions}:{},...j.bulkActionDefs?{bulkActionDefs:j.bulkActionDefs}:{},...j.options?.grid||{}};case`kanban`:{let{columns:e,groupByField:n,groupField:r,cardFields:i,titleField:a,...o}={...j.options?.kanban||{},...j.kanban||{}},s=n||r||ve(W)||void 0;return{type:`object-kanban`,...t,groupBy:s,groupField:s,...a?{titleField:a}:{},cardFields:i||e||cn||[],...J?{grouping:J}:{},...o}}case`calendar`:return{type:`object-calendar`,...t,startDateField:j.calendar?.startDateField||j.options?.calendar?.startDateField||`start_date`,endDateField:j.calendar?.endDateField||j.options?.calendar?.endDateField||`end_date`,...j.calendar?.titleField||j.options?.calendar?.titleField?{titleField:j.calendar?.titleField||j.options?.calendar?.titleField}:{},...j.calendar?.defaultView?{defaultView:j.calendar.defaultView}:{},...j.options?.calendar||{},...j.calendar||{}};case`gallery`:{let e={...j.options?.gallery||{},...j.gallery||{},cardSize:Bt};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:j.gallery?.coverField||j.gallery?.imageField||j.options?.gallery?.imageField,titleField:j.gallery?.titleField||j.options?.gallery?.titleField||`name`,...J?{grouping:J}:{}}}case`timeline`:{let e={...j.options?.timeline||{},...j.timeline||{}},n=Gr(j),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,startDateField:n.startDateField||`created_at`,titleField:n.titleField||`name`,...n.endDateField?{endDateField:n.endDateField}:{},...j.timeline?.groupByField?{groupByField:j.timeline.groupByField}:{},...j.timeline?.colorField?{colorField:j.timeline.colorField}:{},...j.timeline?.scale?{scale:j.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,...j.data?{data:j.data}:{},startDateField:j.gantt?.startDateField||j.options?.gantt?.startDateField||`start_date`,endDateField:j.gantt?.endDateField||j.options?.gantt?.endDateField||`end_date`,progressField:j.gantt?.progressField||j.options?.gantt?.progressField||`progress`,dependenciesField:j.gantt?.dependenciesField||j.options?.gantt?.dependenciesField||`dependencies`,...j.gantt?.titleField?{titleField:j.gantt.titleField}:{},...j.options?.gantt||{},...j.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:j.options?.map?.locationField||`location`,...Lr(j.options?.map)};case`tree`:{let e=j.tree||j.options?.tree||{};return{type:`object-tree`,...t,parentField:e.parentField,labelField:e.labelField||e.titleField||`name`,fields:e.fields||cn,defaultExpandedDepth:e.defaultExpandedDepth,...e}}case`chart`:{let e=j.chart||j.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:j.objectName,chartType:e.chartType||`bar`,filter:j.filter,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[I,j,z,cn,J,Ze,on.handleClick,Rt.mode,Bt,gt,Nt,W]),dn=V.conditions&&V.conditions.length>0,fn=Q.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 j.objectName?k(j.objectName,e,n):n};return e=W?.fields?Object.entries(W.fields).map(([e,n])=>({value:e,label:M(e,n.label||e),type:n.type||`text`,options:t(e,n.options),referenceTo:n.reference_to||n.reference,displayField:n.display_field||n.reference_field,idField:n.id_field})):(Array.isArray(j.columns)?j.columns:[]).flatMap(e=>{if(typeof e==`string`)return[{value:e,label:e,type:`text`}];let n=P(e);return n?[{value:n,label:M(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},[W,j.columns,j.objectName,M,k]),pn=Q.useMemo(()=>{if(!j.filterableFields||j.filterableFields.length===0)return fn;let e=new Set(j.filterableFields);return fn.filter(t=>e.has(t.value))},[fn,j.filterableFields]),{sortFields:_n,sortHasRelationalField:yn}=Q.useMemo(()=>{let e=new Set(z.map(e=>e.field).filter(Boolean)),t=!1,n=[];for(let r of fn){let i=g.has(r.type);if(!i&&!ee.has(r.type)){n.push({value:r.value,label:r.label});continue}if(e.has(r.value)){n.push({value:r.value,label:i?`${r.label} ${S(`list.sortByIdSuffix`)}`:r.label});continue}i&&(t=!0)}return{sortFields:n,sortHasRelationalField:t}},[fn,z,S]),xn=Q.useCallback(e=>{let t=e.map(e=>({id:crypto.randomUUID(),field:e.field,order:e.order}));ue(t),ze(1),i?.(t)},[i]),Cn=Q.useCallback(()=>{let e=Hr(j.sort);ue(e),ze(1),i?.(e)},[B,i]),wn=Q.useCallback(e=>{if(!At)return;let t=Ft,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=W?.label&&W?.name&&typeof O==`function`?O(W):W?.label,a=e=>le(e,{prefix:t?.fileNamePrefix,label:i,objectName:j.objectName,viewLabel:j.label||j.title});if((e===`csv`||e===`xlsx`||e===`json`)&&typeof H?.exportDownload==`function`&&j.objectName&&t?.streaming!==!1){let t=cn.map(e=>P(e)).filter(Boolean),i=qr(j.filter,V,ot),o=z.length>0?z.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})):void 0;Tt(null),St(!0),(async()=>{try{let s=await H.exportDownload(j.objectName,{format:e,fields:t.length?t:void 0,filter:i,...L?{search:L,...j.searchableFields&&j.searchableFields.length>0?{searchFields:j.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),bt(!1)}catch(e){console.error(`ListView export failed:`,e),Tt(e instanceof Error?e.message:String(e))}finally{St(!1)}})();return}let o=n>0?be.slice(0,n):be;if(e===`csv`){let e=cn.map(e=>P(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)}bt(!1)},[be,cn,Ft,j.objectName,j.filter,j.searchableFields,At,H,V,ot,z,L,W,O]),Tn=Q.useMemo(()=>(Array.isArray(j.columns)?j.columns:[]).flatMap(e=>{if(typeof e==`string`)return[{name:e,label:M(e,e)}];let t=P(e);return t?[{name:t,label:M(t,e.label||t)}]:[]}),[j.columns,M]);return(0,$.jsxs)(`div`,{ref:Wt,className:Z(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,t),...j.aria?.ariaLabel?{"aria-label":j.aria.ariaLabel}:{},...j.aria?.ariaDescribedBy?{"aria-describedby":j.aria.ariaDescribedBy}:{},...j.aria?.live?{"aria-live":j.aria.live}:{},role:j.aria?.role??`region`,"aria-busy":De||void 0,"data-state":De?`loading`:`idle`,children:[Kt>0&&(0,$.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:Kt},children:S(Gt?`list.refreshing`:`list.pullToRefresh`)}),j.description&&j.appearance?.showDescription!==!1&&(0,$.jsx)(`div`,{className:`px-4 pt-1.5 text-xs text-muted-foreground bg-background`,"data-testid":`view-description`,children:typeof j.description==`string`?j.description:``}),(0,$.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,$.jsx)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:ct&&(0,$.jsx)(`div`,{className:`shrink-0 min-w-0 overflow-x-auto`,"data-testid":`user-filters`,children:(0,$.jsx)(jr,{config:ct,objectDef:W,data:be,onFilterChange:st,maxVisible:3,initialSelections:f,onSelectionsChange:p})})}),(0,$.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:[y&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wr,{currentView:I,availableViews:tn,onViewChange:nn}),(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5`})]}),I===`grid`&&c&&!F.compactToolbar&&Nt&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:()=>vt(!gt),className:Z(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,gt&&`text-primary`),title:S(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`}),"data-testid":`toolbar-inline-edit-toggle`,children:[(0,$.jsx)(ut,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.inlineEditShort`,{defaultValue:`Edit inline`})})]}),F.showHideFields&&!F.compactToolbar&&(0,$.jsxs)(We,{open:mt,onOpenChange:ht,children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,lt.size>0&&`text-primary`),children:[(0,$.jsx)(Be,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.hideFields`)}),lt.size>0&&(0,$.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:lt.size})]})}),(0,$.jsx)(et,{align:`start`,className:`w-64 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.hideFieldsTitle`)}),lt.size>0&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>pt(new Set),children:S(`list.showAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:Tn.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!lt.has(e.name),onChange:()=>{let t=new Set(lt);t.has(e.name)?t.delete(e.name):t.add(e.name),pt(t)},className:`rounded border-input`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),F.showHideFields&&!F.compactToolbar&&(F.showFilters||F.showSort||F.showGroup)&&(0,$.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),F.showFilters&&(0,$.jsxs)(We,{open:me,onOpenChange:ge,children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,dn&&`text-foreground font-medium`),children:[(0,$.jsx)($t,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.filter`)}),dn&&(0,$.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:V.conditions?.length||0})]})}),(0,$.jsx)(et,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.filterRecords`)})}),(0,$.jsx)(Pt,{fields:pn,value:V,extraOperators:zr,onChange:e=>{ye(e),r&&r(e)}})]})})]}),F.showGroup&&!F.compactToolbar&&(0,$.jsxs)(We,{open:Je,onOpenChange:Ye,children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`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,$.jsx)(it,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.group`)}),J&&J.fields?.length>0&&(0,$.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,$.jsx)(et,{align:`start`,className:`w-72 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.groupBy`)}),J&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>qe(void 0),"data-testid":`clear-grouping`,children:S(`list.clear`)})]}),(0,$.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,$.jsx)(Sn,{value:J,fieldOptions:Tn.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:S(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:S(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:S(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>qe(e)})})]})})]}),F.showSort&&(0,$.jsxs)(We,{open:se,onOpenChange:ce,children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`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,$.jsx)(an,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.sort`)}),z.length>0&&(0,$.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,$.jsx)(et,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.sortRecords`)}),de.length>0&&(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted-foreground hover:text-primary`,disabled:!fe,onClick:Cn,"data-testid":`sort-reset-default`,children:S(`list.resetSortToDefault`)})]}),(0,$.jsx)(cr,{fields:_n,value:z,onChange:e=>{ue(e),i&&i(e)}}),yn&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`sort-relational-hint`,children:S(`list.sortRelationalHint`)})]})})]}),!F.compactToolbar&&(F.showFilters||F.showSort||F.showGroup)&&(F.showColor||F.showDensity)&&(0,$.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),F.showColor&&!F.compactToolbar&&(0,$.jsxs)(We,{open:$e,onOpenChange:tt,children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Ze&&`text-foreground font-medium`),children:[(0,$.jsx)(Qt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.color`)})]})}),(0,$.jsx)(et,{align:`start`,className:`w-64 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.rowColor`)}),Ze&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Qe(void 0),"data-testid":`clear-row-color`,children:S(`list.clear`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`color-field-list`,children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:S(`list.colorByField`)}),(0,$.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:Ze?.field||``,onChange:e=>{let t=e.target.value;Qe(t?{field:t,colors:Ze?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,$.jsx)(`option`,{value:``,children:S(`list.none`)}),Tn.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),F.showDensity&&!F.compactToolbar&&I!==`gallery`&&(()=>{let e=Rt.mode===`compact`?gn:Rt.mode===`comfortable`?bn:Vn,t=Rt.mode===`compact`?S(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Rt.mode===`comfortable`?S(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):S(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${S(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=S(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,$.jsx)(X,{variant:`ghost`,size:`sm`,"aria-label":n,className:Z(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,Rt.mode!==`compact`&&`text-foreground font-medium`),onClick:Rt.cycle,title:r,children:(0,$.jsx)(e,{className:`h-3.5 w-3.5`})})})(),F.showDensity&&!F.compactToolbar&&I===`gallery`&&(()=>{let e=Bt===`small`?gn:Bt===`medium`?bn:Vn,t=Bt===`small`?S(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Bt===`medium`?S(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):S(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${S(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=S(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,$.jsx)(X,{variant:`ghost`,size:`sm`,"aria-label":n,className:Z(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,Bt!==`small`&&`text-foreground font-medium`),onClick:Ht,title:r,children:(0,$.jsx)(e,{className:`h-3.5 w-3.5`})})})(),F.compactToolbar&&(F.showGroup||F.showColor||F.showDensity||F.showHideFields)&&(0,$.jsx)(Er,{t:S,allFields:Tn,showGroup:F.showGroup,groupingConfig:J,setGroupingConfig:qe,showColor:F.showColor,rowColorConfig:Ze,setRowColorConfig:Qe,showDensity:F.showDensity,density:Rt,showHideFields:F.showHideFields,hiddenFields:lt,updateHiddenFields:pt,showInlineEdit:I===`grid`&&Nt,inlineEdit:gt,setInlineEdit:vt}),(F.showColor||F.showDensity||F.compactToolbar)&&Ft&&At&&It.length>0&&(0,$.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),F.showRefresh&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,onClick:()=>K(e=>e+1),disabled:De,title:S(`list.refresh`),"aria-label":S(`list.refresh`),"data-testid":`refresh-button`,children:(0,$.jsx)(In,{className:Z(`h-3.5 w-3.5`,De&&`animate-spin`)})}),Ft&&At&&It.length>0&&(0,$.jsxs)(We,{open:yt,onOpenChange:bt,children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,children:[(0,$.jsx)(An,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.export`)})]})}),(0,$.jsx)(et,{align:`start`,className:`w-48 p-2`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[It.map(e=>(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,disabled:xt,onClick:()=>wn(e),children:[xt?(0,$.jsx)(dr,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,$.jsx)(An,{className:`h-3.5 w-3.5 mr-2`}),S(`list.exportAs`,{format:e.toUpperCase()})]},e)),Ct&&(0,$.jsx)(`div`,{className:`px-2 py-1 text-xs`,style:{color:`var(--destructive, #ef4444)`},role:`alert`,children:Ct})]})})]}),j.sharing?.type&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${j.sharing.type}`,"data-testid":`share-button`,children:[(0,$.jsx)(On,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.share`)})]}),j.allowPrinting&&(()=>{let e=S(`common.printDialogHint`);return(0,$.jsxs)(X,{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":`${S(`list.print`)}: ${e}`,title:e,"data-testid":`print-button`,children:[(0,$.jsx)(Ne,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.print`)})]})})(),(()=>{let e=j.allowPrinting||!!j.sharing?.type||Ft&&At&&It.length>0;return F.showSearch&&e?(0,$.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),F.showSearch&&(0,$.jsxs)(We,{open:ie,onOpenChange:ae,children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`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?`${S(`list.search`)}: ${L}`:S(`list.search`),children:[(0,$.jsx)(mn,{className:`h-3.5 w-3.5`}),L&&(0,$.jsx)(`span`,{className:`ml-1.5 max-w-[8rem] truncate text-[11px]`,"data-testid":`search-active-keyword`,children:L})]})}),(0,$.jsx)(et,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-64 p-2`,"data-testid":`search-popover`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(mn,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(wt,{placeholder:S(`table.search`),value:L,onChange:e=>rn(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),L&&(0,$.jsx)(X,{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:()=>rn(``),children:(0,$.jsx)(un,{className:`h-3 w-3`})})]})})]}),F.showAddRecordTop&&(0,$.jsxs)(X,{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:()=>_.onAddRecord?.(),children:[(0,$.jsx)(Ee,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.addRecord`)})]})]})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:[(0,$.jsx)(Pn,{active:De&&be.length>0}),Se&&be.length===0?(0,$.jsx)(hn,{"data-testid":`list-error-state`,"data-error-kind":we,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:we===`network`?(0,$.jsx)(kt,{className:`h-12 w-12 text-destructive/60`}):(0,$.jsx)(Jn,{className:`h-12 w-12 text-destructive/60`}),iconWrapperClassName:`mb-3`,title:S(we===`api-disabled`?`list.loadErrorApiDisabledTitle`:we===`forbidden`?`list.loadErrorForbiddenTitle`:we===`unauthorized`?`list.loadErrorUnauthorizedTitle`:we===`rejected`?`list.loadErrorRejectedTitle`:`list.loadErrorTitle`),description:S(we===`api-disabled`?`list.loadErrorApiDisabledMessage`:we===`forbidden`?`list.loadErrorForbiddenMessage`:we===`unauthorized`?`list.loadErrorUnauthorizedMessage`:we===`rejected`?`list.loadErrorRejectedMessage`:`list.loadErrorMessage`),action:we===`api-disabled`?void 0:(0,$.jsxs)(X,{variant:`outline`,size:`sm`,"data-testid":`list-error-retry`,onClick:()=>K(e=>e+1),children:[(0,$.jsx)(In,{className:`h-4 w-4 mr-1.5`}),S(`list.retry`)]})}):De&&be.length===0?(0,$.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,$.jsx)(`span`,{className:`sr-only`,children:S(`list.loading`)}),[0,1,2,3,4,5].map(e=>(0,$.jsx)(`div`,{className:`h-9 rounded bg-muted/60 animate-pulse`,style:{opacity:Math.max(.25,1-e*.12)}},e))]}):!De&&be.length===0&&I===`grid`?(()=>{let e=j.emptyState?.icon,t=e?vn[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??Ae:Ae,n=Array.isArray(j.filter)?j.filter.length>0:j.filter&&typeof j.filter==`object`?Object.keys(j.filter).length>0:!1,r=!!(L&&L.trim())||n||Array.isArray(ot)&&ot.length>0||Array.isArray(V?.conditions)&&V.conditions.length>0,i=(typeof j.emptyState?.title==`string`?j.emptyState.title:void 0)??S(r?`list.noMatches`:`list.firstRunTitle`),a=(typeof j.emptyState?.message==`string`?j.emptyState.message:void 0)??S(r?`list.noMatchesMessage`:`list.firstRunMessage`);return(0,$.jsx)(hn,{"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,$.jsx)(t,{className:`h-12 w-12 text-muted-foreground/50`}),iconWrapperClassName:`mb-3`,title:i,description:a,action:F.showAddRecord?(0,$.jsxs)(X,{variant:`default`,size:`sm`,"data-testid":`empty-state-add-record`,onClick:()=>_.onAddRecord?.(),children:[(0,$.jsx)(Ee,{className:`h-4 w-4 mr-1.5`}),S(`list.addRecord`)]}):void 0})})():(0,$.jsx)(b,{schema:ln,..._,...Xt?{}:{data:be},loading:De,onRowSelect:rt,...I===`grid`&&!J?.fields?.length&&Ve!=null?{manualPagination:!0,rowCount:Ve,page:Re,pageSize:Le,onPageChange:e=>ze(e),onPageSizeChange:e=>{Ie(e),ze(1)},sort:z,onSortChange:xn,findParams:Ue}:{}})]},I),F.showAddRecordBottom&&(0,$.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,$.jsxs)(X,{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:()=>_.onAddRecord?.(),children:[(0,$.jsx)(Ee,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.addRecord`)})]})}),jt&&jt.length>0&&nt.length>0&&I!==`grid`&&(0,$.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,$.jsx)(Kn,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[nt.length,` `,nt.length===1?`item`:`items`,` selected`]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:jt.map(e=>{let t=String(e).toLowerCase(),n=t.includes(`delete`)||t.includes(`remove`)||t.includes(`destroy`),r=n?Mt:null;return(0,$.jsxs)(X,{variant:n?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>_.onBulkAction?.(e,nt),"data-testid":`bulk-action-${e}`,children:[r&&(0,$.jsx)(r,{className:`h-3 w-3`}),N(e)]},e)})}),(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>rt([]),children:[(0,$.jsx)(un,{className:`h-3 w-3`}),`Clear`]})]}),!De&&be.length>0&&j.showRecordCount!==!1&&(0,$.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,$.jsx)(`span`,{className:`font-medium text-foreground/80`,children:(()=>{let e=Ve??be.length;return S(e===1?`list.recordCountOne`:`list.recordCount`,{count:e})})()}),q&&(0,$.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:S(`list.dataLimitReached`,{limit:Le})}),I!==`grid`&&j.pagination?.pageSizeOptions&&j.pagination.pageSizeOptions.length>0&&(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:S(`table.rowsPerPage`,{defaultValue:`Rows per page`})}),(0,$.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(Le),onChange:e=>{let t=Number(e.target.value);Ie(t),_.onPageSizeChange&&_.onPageSizeChange(t)},children:j.pagination.pageSizeOptions.map(e=>(0,$.jsx)(`option`,{value:String(e),children:e},e))})]})]}),on.isOverlay&&(0,$.jsx)(Rn,{...on,title:sn,children:e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,$.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})});Zr.displayName=`ListView`;var Qr={columns:!0,filter:!0,sort:!0,limit:`pagination.pageSize`,viewType:!0},$r=Q.forwardRef((e,t)=>{let n=(0,Q.useContext)(O),r=(I(e.dataSource)?void 0:e.dataSource)??n?.dataSource;return(0,$.jsx)(ue,{schema:e.schema,mapping:Qr,dataSource:r,testId:`list-view`,errorTitle:`This list view’s data source could not be resolved`,children:n=>(0,$.jsx)(Zr,{ref:t,...e,schema:n,dataSource:r})})});$r.displayName=`ListViewBlock`;var ei={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`},ti={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},ni=new Set([`number`,`currency`,`percent`,`integer`,`decimal`]),ri=[{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 ii(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return ri[Math.abs(t)%ri.length]}var ai=({imageUrl:e,title:t,coverFit:n,aspectClass:r,placeholder:i,hidden:a})=>{let[o,s]=(0,Q.useState)(!1),c=!!e&&!o;return(0,$.jsx)(`div`,{className:Z(`w-full overflow-hidden relative`,r),hidden:a,children:c?n===`contain`?(0,$.jsx)(`div`,{className:Z(`flex h-full w-full items-center justify-center bg-gradient-to-br`,i.bg),children:(0,$.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,$.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,$.jsx)(`div`,{className:Z(`flex h-full w-full items-center justify-center bg-gradient-to-br ring-1 ring-inset`,i.bg,i.ring),children:(0,$.jsx)(`span`,{className:Z(`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,Q.useState)(!1),a=!!e&&!r;return(0,$.jsx)(`div`,{className:Z(`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,$.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,$.jsx)(`span`,{className:Z(`text-base font-semibold`,n.text),children:t[0]?.toUpperCase()})})},si=(e,t)=>{let n=e?.[t];if(n!=null&&n!==``)return Zt(n)[0]?.url};C.register(`object-gallery`,e=>{let{schema:t}=e,n=(0,Q.useContext)(O),r=e.dataSource||n?.dataSource,i=L(t.bind),[a,o]=(0,Q.useState)([]),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),d=xe({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:y,fieldOptionLabel:b}=re(),x=(0,Q.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_to||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=y(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:b(t.objectName,e,r,i)}})),r},[l,t.objectName,y,b]);(0,Q.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,Q.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=pe(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 S=e.data||i||t.data||a||[],C=(0,Q.useMemo)(()=>S.some(e=>!!si(e,p)),[S,p]),w=t.grouping?.fields,T=!!(w&&w.length>0),[E,D]=(0,Q.useState)({}),k=(0,Q.useMemo)(()=>w?w.some(e=>e.collapsed):!1,[w]),A=(0,Q.useCallback)(e=>{D(t=>({...t,[e]:t[e]===void 0?!k:!t[e]}))},[k]),j=(0,Q.useMemo)(()=>{if(!T||!w)return[];let e=new Map,t=[];for(let n of S){let r=w.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=w.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=w[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 E?E[t]:k;return{key:t,label:n.label,items:n.items,collapsed:r}})},[S,w,T,E,k]);if(s&&!S.length)return(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!S.length)return(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let M=e=>!_||_.length===0?null:(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:_.map(t=>{let n=e[t];if(n==null||n===``)return null;let r=x(t),i=fr(r)||r.type||`text`,a=Fn(i),o=r?.label&&String(r.label).trim()?String(r.label):void 0,s=o!=null&&ni.has(i);return(0,$.jsxs)(`div`,{className:Z(`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,$.jsx)(`span`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:o}),(0,$.jsx)(a,{value:n,field:r})]},t)})}),N=(n,r)=>{let i=n.id??n._id??r,a=(g!=null&&n[g]!=null&&n[g]!==``?String(n[g]):void 0)??v(l,n),o=si(n,p),s=ii(String(i)+`|`+a),c=Z(`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 C&&m===`contain`?(0,$.jsxs)(W,{role:`listitem`,className:c,onClick:e=>d.handleClick(n,e),children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:Z(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,$.jsx)(kn,{className:`p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(oi,{imageUrl:o,title:a,placeholder:s}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:a,children:a}),M(n)]})]})})]},i):(0,$.jsxs)(W,{role:`listitem`,className:c,onClick:e=>d.handleClick(n,e),children:[!C&&(0,$.jsx)(`div`,{"aria-hidden":!0,className:Z(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,$.jsx)(ai,{imageUrl:o,title:a,coverFit:m,aspectClass:ti[h],placeholder:s,hidden:!C}),(0,$.jsxs)(kn,{className:Z(`p-3`,C&&`border-t border-border/60`),children:[(0,$.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:a,children:a}),M(n)]})]},i)},P=e=>(0,$.jsx)(`div`,{className:Z(`grid gap-4 p-4 auto-rows-min content-start`,ei[h],t.className),role:`list`,children:e.map((e,t)=>N(e,t))});return(0,$.jsxs)($.Fragment,{children:[T?(0,$.jsx)(`div`,{className:`space-y-2`,children:j.map(e=>(0,$.jsxs)(`div`,{className:`border rounded-md`,children:[(0,$.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:()=>A(e.key),children:[e.collapsed?(0,$.jsx)(Cn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(nr,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.items.length})]}),!e.collapsed&&P(e.items)]},e.key))}):P(S),d.isOverlay&&(0,$.jsx)(Rn,{...d,title:`Gallery Item`,children:e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,$.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},{namespace:`plugin-list`,label:`Gallery View`,category:`view`});var ci=$r;C.register(`list-view`,ci,{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:{}}}),C.register(`list`,ci,{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 li=new Set([`textarea`,`markdown`,`html`,`grid`,`richtext`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:richtext`]);function ui(e){return li.has(e)}function di(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 fi(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&ui(e.type)?{...e,span:t}:e)}function pi(e,t,n){if(t!==void 0)return{fields:fi(e,t),columns:t};let r=di(e.length,n);return{fields:fi(e,r),columns:r}}var mi=xn({"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.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.back`);function hi(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 gi(e){let t=hi(e);return t==null||t===``?0:Array.isArray(t)?t.length:typeof t==`object`?Object.keys(t).length:1}function _i({value:e,field:t}){let{t:r}=mi(),a=B(),{appName:o}=i(),s=t?.name||``,c=a?.data?.name,l=o&&c?`/apps/${o}/metadata/permission/${encodeURIComponent(String(c))}`:null,u=gi(e),d=u===0,f=(()=>{if(d)return(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r(`perm.facet.none`,{defaultValue:`None`})});if(s===`system_permissions`){let t=Te(e),n=t.slice(0,6),i=t.length-n.length;return(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[n.map(e=>(0,$.jsx)(tt,{variant:`outline`,children:e},e)),i>0&&(0,$.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,$.jsx)(`span`,{className:`text-foreground`,children:t})})();return(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[f,l?(0,$.jsx)(n,{to:l,className:`text-primary hover:underline whitespace-nowrap`,children:r(`perm.facet.designInStudio`,{defaultValue:`Design in Studio →`})}):(0,$.jsx)(`span`,{className:`text-muted-foreground/60 whitespace-nowrap`,children:r(`perm.facet.designInStudioHint`,{defaultValue:`Design in Studio`})})]})}var vi=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`]),yi=new Set([`formula`,`summary`,`rollup`,`autonumber`,`auto_number`]);function bi(e,t){return yi.has(e)||yi.has(t)}var xi=new Set([`image`,`avatar`,`signature`,`file`,`video`,`audio`]);function Si(e,t){return Ci(e)||Ci(t)}function Ci(e){return typeof e!=`string`||xi.has(e)?!1:yt(e)}var wi=`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 Ti(e,t){let n={...e};if(!t)return n;!n.type&&t.type&&(n.type=t.type);for(let e of wi){let r=t[e];r!==void 0&&n[e]===void 0&&(n[e]=r)}let r=t.reference_to||t.reference;return r&&n.reference_to===void 0&&(n.reference_to=r),n}var Ei=`inline-plain-text-input`,Di=new Set([`text`,`textarea`,`email`,`phone`,`url`]);function Oi(e){return e?Qn.includes(e)||nt(e)!==`field:text`:!1}function ki(e){let t=e?.type;return!t||Di.has(t)?!0:t===`select`&&!e.multiple}var Ai=({field:e,value:t,onChange:n,dataSource:r,autoFocus:i})=>{let a=e.type;if(e.widget===`permission-facet-link`)return(0,$.jsx)(_i,{value:t,field:e});if(typeof a==`string`&&Wn[a])return(0,$.jsx)(zn,{field:e});let o=a===`multiselect`||!!e.multiple;if((a===`select`||a===`multiselect`)&&Array.isArray(e.options)&&e.options.length>0)return o?(0,$.jsx)(Je,{field:{...e,multiple:!0},value:Array.isArray(t)?t:t==null||t===``?[]:[t],onChange:e=>n(e)}):(0,$.jsx)(Je,{field:e,value:t==null?``:String(t),onChange:e=>n(e)});if(a===`boolean`)return(0,$.jsx)(Ft,{field:e,value:!!t,onChange:e=>n(e)});if(a===`image`)return(0,$.jsx)(ar,{field:e,value:t,onChange:e=>n(e)});if(a===`avatar`)return(0,$.jsx)(Ot,{field:e,value:t,onChange:e=>n(e)});if(a===`signature`)return(0,$.jsx)(lr,{field:e,value:t,onChange:e=>n(e)});if(a===`file`||a===`video`||a===`audio`)return(0,$.jsx)(jt,{field:e,value:t,onChange:e=>n(e)});let s=a===`user`,c=a===`lookup`||a===`master_detail`||a===`tree`||!!e.reference_to&&!yi.has(a);if(s||c)return(0,$.jsx)(s?Ct:hr,{field:e,value:t,onChange:e=>n(e),dataSource:r});if(a===`number`)return(0,$.jsx)(ot,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`currency`)return(0,$.jsx)(Ge,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`percent`)return(0,$.jsx)(qt,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`address`)return(0,$.jsx)(lt,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`location`)return(0,$.jsx)($e,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`geolocation`)return(0,$.jsx)(He,{field:e,value:t,onChange:e=>n(e),autoFocus:i});let l=a===`date`||a===`datetime`;if(!l&&!ki(e)&&Oi(a)&&pt(a))return(0,$.jsx)(ft,{field:e,value:t,onChange:e=>n(e),autoFocus:i});let u=l?`date`:`text`,d=t==null?``:l?(()=>{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`?Dn(t)??``:t);return(0,$.jsx)(`input`,{type:u,"data-testid":l?void 0:Ei,autoFocus:i,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:d,onChange:e=>{let t=e.target.value;n(l&&t?new Date(t+`T00:00:00`).toISOString():t)}})},ji=({name:e})=>/^[a-z0-9][a-z0-9-]*$/i.test(e)?(0,$.jsx)(xt,{name:e,className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e});function Mi(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 Ni=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l,virtualScroll:u})=>{let[d,f]=Q.useState(e.defaultCollapsed??!1),[p,m]=Q.useState(null),[h,g]=Q.useState(void 0),[_,v]=Q.useState(!1),{t:y}=mi(),{fieldLabel:x,translateOptions:S}=re(),C=Q.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{m(e),setTimeout(()=>m(null),2e3)})},[]),w=Q.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),T=Q.useMemo(()=>e.fields.filter(w).length,[e.fields,w]),E=mr(),D=E?3:4,O=E?.2:.25,k=e.fields.length-T,A=!e.hideEmpty&&!a&&e.fields.length>=D&&T/e.fields.length>=O&&k>0,j=!_&&(e.hideEmpty||A)?e.fields.filter(e=>!w(e)):e.fields,{fields:M,columns:N}=pi(j,e.columns),P=Math.min(N,Math.max(1,j.length)),ee=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,$.jsx)(b,{schema:ae(e.render),data:{...t,value:n}});let u=Mi(e.span,P),d=r?.fields?.[e.name],f=Ti(e,d);i&&Array.isArray(f.options)&&f.options.length>0&&(f.options=S(i,e.name,f.options));let m=bi(e.type,d?.type),h=e.readonly===!0||d?.readonly===!0,g=vi.has(e.name),_=Si(e.type,d?.type),v=!h&&!m&&!g&&!_,w=v&&!!s,T=(()=>{if((f.widget||e.widget)===`permission-facet-link`)return(0,$.jsx)(_i,{value:n,field:f});if(n==null||n===``)return(0,$.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=fr(f)||e.type;if(t){let e=Fn(t);if(e)return(0,$.jsx)(e,{value:n,field:f})}return String(n)})(),D=n!=null&&n!==``,O=D&&!w,k=p===e.name,A=x(i||``,e.name,e.label||e.name);return E&&!(a&&v)?(0,$.jsxs)(`div`,{className:Z(`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,$.jsx)(`span`,{className:`text-[15px] text-muted-foreground shrink-0`,children:A}),(0,$.jsx)(`span`,{className:`text-[15px] text-foreground text-right break-words min-w-0 leading-snug`,children:T})]},e.name):(0,$.jsxs)(`div`,{className:Z(`space-y-1.5 group min-w-0`,u),children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:x(i||``,e.name,e.label||e.name)}),a&&v?(0,$.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(0,$.jsx)(Ai,{field:f,value:n,onChange:t=>o?.(e.name,t),dataSource:l,autoFocus:c===e.name})}):(0,$.jsxs)(`div`,{className:Z(`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,$.jsx)(`div`,{className:`text-sm flex-1 min-w-0 break-words py-1`,children:T}),w?(0,$.jsx)(wn,{children:(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,"aria-label":y(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),s?.(e.name)},children:(0,$.jsx)(ut,{className:`h-3 w-3`})})}),(0,$.jsx)(Tn,{children:y(`detail.editInlineHint`)})]})}):D?(0,$.jsx)(wn,{children:(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),C(e.name,n)},children:k?(0,$.jsx)(pr,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(Dt,{className:`h-3 w-3`})})}),(0,$.jsx)(Tn,{children:y(k?`detail.copied`:`detail.copyToClipboard`)})]})}):null]})]},e.name)},F=u?.enabled===!0,I=u?.batchSize??20;if(Q.useEffect(()=>{if(!F){g(void 0);return}if(M.length<=I){g(void 0);return}g(I);let e=setTimeout(()=>g(void 0),100);return()=>clearTimeout(e)},[F,M.length,I]),j.length===0&&T===e.fields.length)return null;let te=h===void 0?M:M.slice(0,h),L=T>0&&(e.hideEmpty||A),ne=(0,$.jsxs)($.Fragment,{children:[E?(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60`,children:te.map(ee)}):(0,$.jsx)(`div`,{className:Z(`grid gap-3 sm:gap-4`,P===1?`grid-cols-1`:P===2?`grid-cols-1 md:grid-cols-2`:P===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:te.map(ee)}),L&&(0,$.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>v(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[_?(0,$.jsx)(Be,{className:`h-3.5 w-3.5 mr-1.5`}):(0,$.jsx)(Nt,{className:`h-3.5 w-3.5 mr-1.5`}),_?y(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):y(`detail.showEmptyFields`,{count:T,defaultValue:`Show ${T} empty field${T===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,$.jsx)(`div`,{className:Z(n),children:ne}):e.collapsible?(0,$.jsx)(ze,{open:!d,onOpenChange:e=>f(!e),className:n,children:(0,$.jsxs)(W,{children:[(0,$.jsx)(_t,{asChild:!0,children:(0,$.jsxs)(ht,{className:Z(`py-3 px-4 sm:py-4 sm:px-6 cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,$.jsxs)(bt,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(ji,{name:e.icon}),(0,$.jsx)(`span`,{children:e.title})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:d?(0,$.jsx)(Cn,{className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(nr,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!d&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,$.jsx)(Fe,{children:(0,$.jsx)(kn,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:ne})})]})}):(0,$.jsxs)(W,{className:Z(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,$.jsxs)(ht,{className:Z(`py-3 px-4 sm:py-4 sm:px-6`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,$.jsx)(bt,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(ji,{name:e.icon}),(0,$.jsx)(`span`,{children:e.title})]})}),e.description&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]}),(0,$.jsx)(kn,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:ne})]})},Pi=({tabs:e,data:t,className:n})=>{let[r,i]=Q.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,$.jsxs)(Kt,{value:r,onValueChange:i,className:n,children:[(0,$.jsx)(zt,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,$.jsx)(Xt,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{children:e.icon}),(0,$.jsx)(`span`,{children:e.label}),e.badge&&(0,$.jsx)(tt,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,$.jsx)(Qe,{value:e.key,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,$.jsx)(Q.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,$.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,$.jsx)(b,{schema:ae(e),data:t},n))}):(0,$.jsx)(b,{schema:ae(e.content),data:t})})},e.key))]})};function Fi(e){if(!e)return Ae;let t=e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return vn[t]||Ae}function Ii(e,t){let n=e?.id??e?._id;if(t){let r=v(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 Li(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 Ri=({action:e,onToolbarAction:t})=>{let n=e.visible,r=N(H(n));if(n&&!r)return null;let i=e.icon?Fi(e.icon):null;return(0,$.jsxs)(X,{variant:e.variant===`primary`?`default`:`outline`,size:`sm`,onClick:n=>{n.stopPropagation(),t(e)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,"data-testid":`related-toolbar-action-${e.name}`,children:[i&&(0,$.jsx)(i,{className:`h-3.5 w-3.5`}),e.label||e.name]})},zi=({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:g,onRowAction:_,toolbarActions:v,onToolbarAction:y,add:x,maxColumns:S=6,pageSize:C,defaultSort:w,sortable:T=!1,filter:E,filterable:D=!1,collapsible:O=!1,defaultCollapsed:k=!1,referenceField:A,parentId:N,icon:ee})=>{let F=r!==void 0,I=r??[],[L,ne]=Q.useState(I),[ae,oe]=Q.useState(()=>!!n&&!F),[R,se]=Q.useState(0),[ce,le]=Q.useState(null),[z,ue]=Q.useState(`asc`),[B,de]=Q.useState(``),[fe,pe]=Q.useState(null),[he,ge]=Q.useState(!1),[V,_e]=Q.useState(null),[ve,ye]=Q.useState(k),[H,be]=Q.useState(!1),[xe,Ce]=Q.useState(!1),[we,Te]=Q.useState(null),[De,Oe]=Q.useState(0),[Ae,je]=Q.useState({}),{t:G}=mi(),{fieldLabel:Me}=re(),K=C&&C>0?C:0,Ne=D&&B!==``,q=!F&&!!n&&K>0&&!!c&&typeof c.find==`function`&&!Ne,Pe=q?R:0,Fe=q?ce:null,Le=q?z:`asc`,Re=JSON.stringify(w??null),ze=Q.useMemo(()=>Li(w),[Re]),Be=JSON.stringify(E??null),Ve=Q.useMemo(()=>Se(E),[Be]);Q.useEffect(()=>{F&&ne(r??[])},[r,F]),Q.useEffect(()=>{n&&c?.getObjectSchema&&c.getObjectSchema(n).then(_e).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,c]);let He=x?.picker?.object,[Ue,We]=Q.useState(null);Q.useEffect(()=>{if(!H||!He||Ue||!c?.getObjectSchema)return;let e=!1;return c.getObjectSchema(He).then(t=>{e||We(t)}).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${He}:`,e)}),()=>{e=!0}},[H,He,Ue,c]);let Ge=x?.picker?.labelField||`name`,Ke=Q.useMemo(()=>{let e=ke(Ue,{displayField:Ge});return e.length>0?e:void 0},[Ue,Ge]);Q.useEffect(()=>{!x||He||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.`)},[x,He,n,l]),Q.useEffect(()=>{let e=!1;if(n&&!F){if(!(A&&N!=null&&N!==``)){n&&(N==null||N===``)&&!A&&console.warn(`[RelatedList] "${n}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),ne([]),pe(null),ge(!1),oe(!1);return}oe(!0);let t={[A]:N},r=Ve===void 0?t:te(t,Ve);if(c&&typeof c.find==`function`){let t={$filter:r};if(q){t.$top=K,t.$skip=Pe*K;let e=Fe?[{field:Fe,order:Le}]:ze;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(ne(r),q){let e=!n&&typeof t?.total==`number`?t.total:null;pe(e),ge(!n&&typeof t?.hasMore==`boolean`?t.hasMore:r.length===K)}else pe(null),ge(!1);oe(!1)}).catch(t=>{console.error(`Failed to fetch related data:`,t),e||oe(!1)})}else if(Ve!==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.`),ne([]),pe(null),ge(!1),oe(!1);else{let t=new URLSearchParams({[`filter[${A}]`]:String(N)}).toString();fetch(`${n}?${t}`).then(e=>e.json()).then(t=>{if(e)return;let n=Array.isArray(t)?t:t?.data||[];ne(n),pe(null),ge(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>{e||oe(!1)})}}return()=>{e=!0}},[n,F,c,A,N,De,q,K,Pe,Fe,Le,ze,Ve]),Q.useEffect(()=>{!q||ae||R>0&&L.length===0&&se(e=>Math.max(0,e-1))},[q,ae,L,R]),Q.useEffect(()=>{se(0)},[n,A,N,Be]),Q.useEffect(()=>{if(!n||F)return;let e=e=>{let t=e.detail||{};t.objectName&&t.objectName!==`*`&&t.objectName!==n||Oe(e=>e+1)};return window.addEventListener(`objectui:related-changed`,e),()=>window.removeEventListener(`objectui:related-changed`,e)},[n,F]),Q.useEffect(()=>{if(!c?.find||!V?.fields||!L.length)return;let e=V.fields,t=[];for(let[n,r]of Object.entries(e)){if(!r||r.type!==`lookup`&&r.type!==`master_detail`)continue;let e=r.reference_to||r.reference;if(!e)continue;let i=new Set;for(let e of L){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=Ae[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)]=Ii(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||je(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[c,V,L]);let J=Q.useMemo(()=>{if(q||!B)return L;let e=B.toLowerCase();return L.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[L,B,q]),Je=Q.useMemo(()=>{if(q||!ce)return J;let e=Ae[ce],t=J.map(t=>({row:t,key:ie(t[ce],{labels:e})}));return t.sort((e,t)=>{let n=U(e.key,t.key);return z===`asc`?n:-n}),t.map(e=>e.row)},[J,ce,z,q,Ae]),Ye=K&&!q?Je.slice(R*K,(R+1)*K):Je,Xe=K?q?fe==null?R+(he?2:1):Math.max(1,Math.ceil(fe/K)):Math.max(1,Math.ceil(Je.length/K)):1,Ze=q?fe==null?he:(R+1)*K<fe:R<Xe-1,Qe=K>0&&(q?R>0||Ze:Je.length>K);Q.useEffect(()=>{se(0)},[B,ce,z]);let $e=Q.useCallback(e=>{se(0),ce===e?ue(e=>e===`asc`?`desc`:`asc`):(le(e),ue(`asc`))},[ce]),et=Q.useMemo(()=>ce?[{field:ce,order:z}]:ze,[ce,z,ze]),nt=Q.useCallback(e=>{let t=e[0];t&&(se(0),le(t.field),ue(t.order))},[]),[rt,it]=Q.useState(null),ot=Q.useCallback(e=>{it(e)},[]),ct=Q.useCallback(async()=>{if(rt)try{await m?.(rt),Oe(e=>e+1)}catch(e){console.error(`[RelatedList] remove failed`,e)}it(null)},[rt,m]),lt=Q.useCallback(async e=>{if(!x||!c||!n||A==null||N==null)return;let t=x.picker.valueField||`id`;Ce(!0),Te(null);try{for(let r of e||[]){let e=r?.[t]??r?.id;e!=null&&(x.linkField?await c.create?.(n,{[A]:N,[x.linkField]:e}):await c.update?.(x.picker.object,String(e),{[A]:N}))}Oe(e=>e+1)}catch(e){let t=e?.body?.error??e?.error??e?.message??String(e);Te(typeof t==`string`?t:`Failed to add`)}finally{Ce(!1),be(!1)}},[x,c,n,A,N]),ut=o(),Y=Q.useMemo(()=>{let e=l||n||``,t=t=>!ut?.isLoaded||!e?t:t.filter(t=>{let n=t?.accessorKey||P(t);return!n||ut.checkField(e,String(n),`read`)}),r=e=>A?e.filter(e=>(e?.accessorKey||P(e))!==A):e,i=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,o=e=>L.length?e.filter(e=>{let t=e?.accessorKey||P(e);return!t||L.some(e=>!i(e?.[t]))}):e,s=(e,t)=>{if(!t?.type)return;let n=fr({type:t.type,format:t.format})||t.type,r=Fn(n);if(!r)return;let i=t.type===`lookup`||t.type===`master_detail`?Ae[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_to||t.reference)&&{reference_to:t.reference_to||t.reference},...t.reference_field&&{reference_field:t.reference_field}};return e=>e==null?Q.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):Q.createElement(r,{value:e,field:o})},c=t=>{if(typeof t!=`string`){let e=t?.accessorKey||P(t);if(!t||!e)return t;let n={};if(t.accessorKey||(n.accessorKey=e),!t.cell&&!t.render){let t=V?.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=V?.fields?.[t],r={accessorKey:t,header:n?.label||Me(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(!V?.fields)return[];let u=Array.isArray(V.highlightFields)?V.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,S))}let d=e,f=new Set([`richtext`,`markdown`,`html`,`json`]),p=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],m=Object.entries(V.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===A||t?.hidden||t?.type&&f.has(t.type)||ut?.isLoaded&&d&&!ut.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:Me(d,e,t.label||e)};if(t.type){let r=s(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,S))},[a,V,l,n,Me,A,L,S,Ae,ut]),dt=Q.useMemo(()=>q?Y.map(e=>{let t=e.accessorKey||P(e),n=t?V?.fields?.[t]:void 0;return M(n)||me(n)?{...e,sortable:!1}:e}):Y,[Y,q,V]),ft=!i&&(t===`grid`||t===`table`),pt=Array.isArray(g)&&g.length>0,mt=!!p||!!m||pt,gt=mr(),_t=Q.useMemo(()=>{if(i)return i;if(gt&&(t===`grid`||t===`table`)){let e=Y[0]?.accessorKey||P(Y[0]),t=Y.slice(1,4).map(e=>e.accessorKey||P(e)).filter(Boolean);return{type:`object-gallery`,data:Ye,objectName:n,gallery:{titleField:e||`name`,visibleFields:t,cardSize:`medium`},onRowClick:h}}let e=j(V?.userActions?.edit),r=j(V?.userActions?.delete);switch(t){case`grid`:case`table`:return{type:`data-table`,data:Ye,columns:dt,pagination:!1,pageSize:K||10,searchable:!1,exportable:!1,manualSorting:!0,sort:et,onSortChange:nt,rowActions:mt,onRowEdit:p,onRowDelete:m?ot:void 0,rowEditPredicates:e,rowDeletePredicates:r,onRowClick:h,rowActionDefs:pt?g:void 0,onRowActionDef:pt?_:void 0};case`list`:return{type:`data-list`,data:Ye};default:return{type:`div`,children:`No view configured`}}},[t,Ye,dt,Y,i,K,mt,pt,g,_,p,m,ot,h,gt,n,V,et,nt]),vt=O?`cursor-pointer select-none`:void 0,yt=O?()=>ye(e=>!e):void 0,xt=Fi(ee),St=q&&fe!=null?fe:L.length,Ct=!ae&&L.length===0&&(!q||R===0),Tt=D;return(0,$.jsxs)(W,{className:Z(`shadow-none border-border/60 bg-transparent`,Ct&&`bg-muted/10`,s),children:[(0,$.jsx)(ht,{className:Z(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,vt),onClick:yt,children:(0,$.jsxs)(bt,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[O&&(ve?(0,$.jsx)(Cn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,$.jsx)(nr,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,$.jsx)(xt,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:Z(`truncate`,Ct&&`text-muted-foreground font-medium`),children:e}),(0,$.jsx)(tt,{variant:`secondary`,className:Z(`text-xs font-normal h-5 px-1.5`,St===0&&`bg-muted text-muted-foreground`),"aria-label":`${St} records`,children:St}),Ct&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:G(`detail.noRelatedRecords`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[y&&(v??[]).map(e=>(0,$.jsx)(Ri,{action:e,onToolbarAction:y},e.name)),x&&He&&c&&(0,$.jsxs)(X,{variant:Ct?`ghost`:`outline`,size:`sm`,disabled:xe,onClick:e=>{e.stopPropagation(),Te(null),be(!0)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,$.jsx)(Ee,{className:`h-3.5 w-3.5`}),x.label||G(`detail.add`,{defaultValue:`Add`})]}),u&&(0,$.jsxs)(X,{variant:Ct?`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,$.jsx)(Ee,{className:`h-3.5 w-3.5`}),G(`detail.new`)]})]})]})}),!ve&&!Ct&&(0,$.jsxs)(kn,{className:Z(`pt-0 pb-4 px-4`),children:[Tt&&(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(wt,{placeholder:G(`detail.filterPlaceholder`),value:B,onChange:e=>de(e.target.value),className:`h-8 text-sm`})}),T&&!ft&&Y&&Y.length>0&&L.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:Y.map(e=>{let t=e.accessorKey||P(e);if(!t)return null;let n=V?.fields?.[t];if(q&&(M(n)||me(n)))return null;let r=e.header||e.label||t,i=ce===t;return(0,$.jsxs)(X,{variant:i?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>$e(t),children:[(0,$.jsx)(an,{className:`h-3 w-3`}),r,i&&(z===`asc`?` ↑`:` ↓`)]},t)})}),ae&&L.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:G(`detail.loading`)}):(0,$.jsx)(`div`,{className:Z(ae&&`opacity-60 pointer-events-none transition-opacity`),children:(0,$.jsx)(b,{schema:_t})}),Qe&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,$.jsxs)(X,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:R===0,onClick:()=>se(e=>Math.max(0,e-1)),children:[(0,$.jsx)(sn,{className:`h-3 w-3`}),G(`detail.previousPage`)]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:G(`detail.pageOf`,{current:R+1,total:Xe})}),(0,$.jsxs)(X,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:!Ze,onClick:()=>se(e=>Ze?e+1:e),children:[G(`detail.nextPage`),(0,$.jsx)(Cn,{className:`h-3 w-3`})]})]}),f&&!Ct&&Qe&&(0,$.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,$.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:[G(`detail.viewAll`),(0,$.jsx)(Ie,{className:`h-3 w-3`})]})})]}),(0,$.jsx)(Rt,{open:rt!==null,onOpenChange:e=>{e||it(null)},children:(0,$.jsxs)(st,{children:[(0,$.jsxs)(nn,{children:[(0,$.jsx)(tn,{children:G(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,$.jsx)(qn,{children:G(`detail.deleteRowConfirmation`)})]}),(0,$.jsxs)(at,{children:[(0,$.jsx)(qe,{children:G(`detail.cancel`,{defaultValue:`Cancel`})}),(0,$.jsx)(Yt,{onClick:ct,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:G(`detail.delete`,{defaultValue:`Delete`})})]})]})}),we&&(0,$.jsx)(`div`,{className:`mx-4 mb-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,role:`alert`,children:we}),x&&He&&c&&(0,$.jsx)(Bt,{open:H,onOpenChange:e=>be(e),multiple:!0,dataSource:c,objectName:He,title:x.label||G(`detail.add`,{defaultValue:`Add`}),displayField:Ge,columns:Ke,cellRenderer:Fn,fieldsMeta:Ue?.fields,baseFilter:x.picker.filter,onSelect:()=>{},onSelectRecords:e=>{lt(e)}})]})},Bi=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l})=>{let u=e.collapsible??!0,[d,f]=Q.useState(e.defaultCollapsed??!1),p=(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,$.jsx)(Ni,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l},n))});return u?(0,$.jsxs)(ze,{open:!d,onOpenChange:e=>f(!e),className:n,children:[(0,$.jsx)(_t,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5`,children:[d?(0,$.jsx)(Cn,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,$.jsx)(nr,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!d&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,$.jsx)(Fe,{children:(0,$.jsx)(`div`,{className:`mt-3`,children:p})})]}):(0,$.jsxs)(`div`,{className:Z(`space-y-3`,n),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),p]})},Vi=({fields:e,data:t,className:n,objectName:r,objectSchema:i,dataSource:a})=>{let{fieldLabel:o}=re(),{t:s}=mi(),c=se(),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,$.jsx)(wn,{children:(0,$.jsx)(`section`,{className:Z(`@container border-b border-border/60 pb-4`,n),"aria-label":`Record highlights`,children:(0,$.jsx)(`div`,{className:Z(`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=Ti({name:e.name,label:e.label,type:f||`text`},d),m=c?.draft?.[e.name],h=m===void 0?n:m,g=bi(e.type,d?.type),_=e.readonly===!0||d?.readonly===!0,v=vi.has(e.name),y=Si(e.type,d?.type),b=u&&!g&&!_&&!v&&!y,x=l&&b,S=Fn(fr(p)||f||`text`),C=f===`number`||f===`integer`||f===`currency`||f===`percent`||f===`decimal`,w=f===`email`||f===`url`||f===`textarea`||f===`reference`||f===`lookup`||f===`master_detail`,T=f===`boolean`,E=h==null||h===``;return(0,$.jsxs)(`div`,{className:Z(`group flex flex-col gap-1 min-w-[7rem] px-5 border-l border-border/60 first:border-l-0 first:pl-0`,w||x?`basis-[16rem] max-w-[24rem]`:`basis-[9rem] max-w-[16rem]`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:o(r||``,e.name,e.label)}),x?(0,$.jsx)(Ai,{field:p,value:h,onChange:t=>c.setField(e.name,t),dataSource:a,autoFocus:c.autoFocusField===e.name}):(0,$.jsxs)(`div`,{className:Z(`flex items-start justify-between gap-1`,b&&`cursor-pointer rounded-md -mx-1.5 px-1.5 hover:bg-muted/40 transition-colors`),onDoubleClick:b?()=>c.enter(e.name):void 0,title:b?s(`detail.editInlineHint`):void 0,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:T?h?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-600 ring-1 ring-inset ring-emerald-500/30 dark:text-emerald-400`,children:[(0,$.jsx)(pr,{className:`h-3 w-3`,"aria-hidden":!0}),`Yes`]}):(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-700 ring-1 ring-inset ring-amber-500/30 dark:text-amber-400`,children:[(0,$.jsx)(un,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):E?(0,$.jsx)(`span`,{className:`block text-sm text-muted-foreground/60 select-none`,"aria-label":s(`detail.noValue`,{defaultValue:`No value`}),children:`—`}):(0,$.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:Z(`block min-w-0 truncate text-sm font-semibold`,C&&`tabular-nums tracking-tight`),children:(0,$.jsx)(S,{value:h,field:p})})}),b&&(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,"aria-label":s(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),c.enter(e.name)},children:(0,$.jsx)(ut,{className:`h-3 w-3`})})}),(0,$.jsx)(Tn,{children:s(`detail.editInlineHint`)})]})]})]},e.name)})})})})};function Hi(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var Ui=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=mi(),[o,s]=Q.useState(``),[c,l]=Q.useState(!1),[u,d]=Q.useState(``),f=Q.useCallback(async()=>{let e=o.trim();if(!(!e||!t)){l(!0);try{await t(e),s(``)}finally{l(!1)}}},[o,t]),p=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]),m=Q.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,$.jsxs)(W,{className:Z(``,i),children:[(0,$.jsx)(ht,{children:(0,$.jsxs)(bt,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)($n,{className:`h-4 w-4`}),a(`detail.comments`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,$.jsxs)(kn,{className:`space-y-4`,children:[r&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(mn,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(`input`,{className:`w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.searchComments`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`detail.searchComments`)}),u&&(0,$.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,$.jsx)(un,{className:`h-3.5 w-3.5`})})]})}),t&&(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:a(`detail.addCommentPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:p,disabled:c}),(0,$.jsx)(X,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,$.jsx)(Zn,{className:`h-4 w-4`})})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:u.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,$.jsx)(`div`,{className:`space-y-3`,children:m.map(e=>(0,$.jsxs)(`div`,{className:Z(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,$.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,$.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground`,children:e.author.charAt(0).toUpperCase()})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Hi(e.createdAt)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,$.jsx)(mt,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,$.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,$.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>n(e.id),"aria-label":e.pinned?a(`detail.unpin`):a(`detail.pin`),children:[(0,$.jsx)(mt,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},Wi={field_change:J,create:Yn,delete:Mt,comment:$n,status_change:Ce},Gi={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 Ki(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function qi(e){return e.description?e.description:e.type===`field_change`&&e.field?`Changed ${e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `)} from "${e.oldValue==null?`(empty)`:String(e.oldValue)}" to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:e.type===`create`?`Created this record`:e.type===`delete`?`Deleted this record`:e.type===`status_change`&&e.field?`Changed status to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:`Updated record`}var Ji={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},Yi=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let[i,a]=Q.useState(n),o=Q.useMemo(()=>i===`all`?e:e.filter(e=>e.type===i),[e,i]);return(0,$.jsxs)(W,{className:Z(``,r),children:[(0,$.jsx)(ht,{children:(0,$.jsxs)(bt,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(dn,{className:`h-4 w-4`}),`Activity`,(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,$.jsxs)(kn,{children:[t&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(Ji).map(e=>(0,$.jsxs)(`button`,{type:`button`,className:Z(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,i===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>a(e),"aria-pressed":i===e,children:[e!==`all`&&Q.createElement(Wi[e]||J,{className:`h-3 w-3`}),Ji[e]]},e))}),o.length===0?(0,$.jsx)(hn,{title:`No activity recorded`,className:`py-6`}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,$.jsx)(`div`,{className:`space-y-4`,children:o.map(e=>{let t=Wi[e.type]||J,n=Gi[e.type]||`bg-gray-100 text-gray-600`;return(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:Z(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:qi(e)})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:Ki(e.timestamp)})]})]},e.id)})})]})]})]})},Xi={create:`default`,update:`secondary`,delete:`destructive`,login:`outline`,logout:`outline`,config_change:`secondary`,import:`outline`};function Zi(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var Qi=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function $i(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 Qi){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return Zi(e)}r/=n}return Zi(e)}function ea(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 na({entries:e,loading:t,emptyText:n,unknownUserText:r,className:i,locale:a}){return t?(0,$.jsx)(`div`,{className:Z(`space-y-3`,i),children:Array.from({length:4}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(ir,{className:`h-8 w-8 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(ir,{className:`h-4 w-1/3`}),(0,$.jsx)(ir,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,$.jsx)(`div`,{className:Z(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,i),children:n??`No history yet`}):(0,$.jsx)(wn,{delayDuration:150,children:(0,$.jsx)(`ol`,{className:Z(`space-y-4`,i),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),i=Xi[n]??`outline`,o=typeof e.user_name==`string`&&e.user_name.trim()||r||`Unknown user`,s=Zi(e.created_at),c=$i(e.created_at,a),l=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,$.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(dt,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[l?(0,$.jsx)(vr,{src:l,alt:o}):null,(0,$.jsx)(Et,{className:`text-[10px] font-medium`,children:ea(e.user_name)})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:o}),e.action&&(0,$.jsx)(tt,{variant:i,className:`text-[10px] uppercase tracking-wide`,children:e.action}),s&&(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":s,children:c||s})}),(0,$.jsx)(Tn,{children:s})]})]}),e.summary&&(0,$.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(n===`create`?(0,$.jsxs)(`details`,{className:`mt-1 group`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer list-none text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 select-none`,children:[(0,$.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▸`}),(0,$.jsx)(`span`,{children:e.changes.length===1?`1 field populated`:`${e.changes.length} fields populated`})]}),(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground pl-4`,children:e.changes.map(e=>(0,$.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,$.jsx)(`span`,{className:`text-foreground`,children:ta(e.to)})]},e.field))})]}):(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,$.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,$.jsx)(`span`,{className:`line-through opacity-70`,children:ta(e.from)}),` → `,(0,$.jsx)(`span`,{className:`text-foreground`,children:ta(e.to)})]},e.field))}))]})]},e.id??t)})})})}var ra=ge;function ia(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 aa(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 oa(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var sa=({value:e,objectSchema:t,fieldName:n})=>{if(e==null||e===``)return null;let r=t?.fields?.[n],i=r?.reference_to||r?.reference||`sys_user`,a={name:n,type:r?.type||`lookup`,reference_to:i,...r?.reference_field&&{reference_field:r.reference_field}},o=fr(a)||a.type;if(o){let t=Fn(o);if(t)return(0,$.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:Q.createElement(t,{value:e,field:a})})}return(0,$.jsx)(`span`,{children:String(e)})},ca=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a})=>{if(!t&&!n)return null;let o=n?(0,$.jsx)(wn,{delayDuration:200,children:(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:aa(n,a)})}),(0,$.jsx)(Tn,{side:`top`,children:oa(n)})]})}):null;return(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,$.jsx)(sa,{value:t,objectSchema:r,fieldName:i}):null,t&&o?(0,$.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,o]})},la=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=mi();if(!e)return null;let a=ia(e[ra.createdAt]),o=ia(e[ra.updatedAt]),s=e[ra.createdBy],c=e[ra.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,$.jsxs)(`div`,{className:Z(`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,$.jsx)(ca,{label:i(s?`detail.createdBy`:`detail.created`),user:s,date:a,objectSchema:t,userField:ra.createdBy,t:i}),d&&(0,$.jsx)(ca,{label:i(c?`detail.updatedBy`:`detail.updated`),user:c,date:o,objectSchema:t,userField:ra.updatedBy,t:i})]})},ua=new Map;function da(e,t,n=`update`,r=!0){let i=e&&t?`${e}:${t}:${n}`:``,[a,o]=Q.useState(()=>i&&ua.has(i)?ua.get(i):!0),s=Q.useContext(O)?.apiFetch;return Q.useEffect(()=>{if(!r||!i){o(!0);return}if(ua.has(i)){o(ua.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;ua.set(i,c),a||o(c)}catch{}})(),()=>{a=!0}},[i,e,t,n,r,s]),a}var fa=5,pa={};function ma(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=y(n?.titleFormat,e);if(r)return r}if(e&&typeof e==`object`){let t=e.id??e._id,r=v(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=v(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 ha=({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]=Q.useState(e.data),[g,_]=Q.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[v,y]=Q.useState(!1),x=f??v,C=se(),w=C?.editing??!1,T=C?.draft??pa,E=C?.autoFocusField??null,[D,O]=Q.useState(null),[k,A]=Q.useState(null),[M,N]=Q.useState(!1),[P,ee]=Q.useState(0),F=de(e.objectName||void 0,e.resourceId==null?void 0:String(e.resourceId)),[I,te]=Q.useState(!1),{t:L}=mi(),{currency:ne}=_n(),{fieldOptionLabel:ie}=re(),oe=mr(),R=o(),ce=Q.useMemo(()=>{if(!R?.isLoaded||!e.objectName)return e;let t=t=>R.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,R]),le=Q.useMemo(()=>!R?.isLoaded||!e.objectName||R.can(e.objectName,`update`),[R,e.objectName]),z=Q.useMemo(()=>!R?.isLoaded||!e.objectName||R.can(e.objectName,`delete`),[R,e.objectName]),ue=e.resourceId==null?void 0:String(e.resourceId),B=da(e.objectName,ue,`update`,le),fe=da(e.objectName,ue,`delete`,z),me=Q.useMemo(()=>j(k?.userActions?.edit),[k]),he=Q.useMemo(()=>j(k?.userActions?.delete),[k]),ge=k?.fields,V=S(me?.visibleWhen??!0,m,{fallback:!1,warnOnError:!0,label:`builtin:edit:visibleWhen`,fields:ge}),_e=S(he?.visibleWhen??!0,m,{fallback:!1,warnOnError:!0,label:`builtin:delete:visibleWhen`,fields:ge}),ve=S(me?.disabledWhen,m,{fallback:!1,warnOnError:!0,label:`builtin:edit:disabledWhen`,fields:ge}),ye=S(he?.disabledWhen,m,{fallback:!1,warnOnError:!0,label:`builtin:delete:disabledWhen`,fields:ge}),H=me?.disabledWhen!=null&&ve,be=he?.disabledWhen!=null&&ye,U=Q.useMemo(()=>({...ce,showEdit:ce.showEdit&&le&&B&&V,showDelete:ce.showDelete&&z&&fe&&_e}),[ce,le,B,V,z,fe,_e]);Q.useEffect(()=>{m&&d&&d(m)},[m,d]);let xe=Q.useMemo(()=>{if(U.summaryFields&&U.summaryFields.length>0)return[];let e=[...U.sections?.flatMap(e=>e.fields)||[],...U.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(k?.fields)for(let[e,n]of Object.entries(k.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>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},[U.summaryFields,U.sections,U.fields,k,m]),Se=U.summaryFields&&U.summaryFields.length>0?U.summaryFields:xe,Ce=Q.useCallback(()=>{U.resourceId&&navigator.clipboard.writeText(String(U.resourceId)).then(()=>{N(!0),setTimeout(()=>N(!1),1500)})},[U.resourceId]);Q.useEffect(()=>{let e=!0;if(U.data)return h(U.data),_(!1),t?.getObjectSchema&&U.objectName&&t.getObjectSchema(U.objectName).then(t=>{e&&A(t)}).catch(()=>{}),()=>{e=!1};if(t&&U.objectName&&U.resourceId){_(!0),A(null),h(null);let n=U.objectName,r=U.resourceId,i=`${n}-`,a=[...U.sections?.flatMap(e=>e.fields)||[],...U.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;A(o);let s=pe(o?.fields,a),c=s.length>0?{$expand:s}:void 0,l=c?t.findOne(n,r,c):t.findOne(n,r),u=()=>{let a=String(r),o=a.startsWith(i)?a.slice(i.length):`${i}${a}`;return(c?t.findOne(n,o,c):t.findOne(n,o)).then(t=>{e&&(h(t),_(!1))}).catch(()=>{e&&(h(null),_(!1))})};return l.catch(()=>null).then(t=>{if(e){if(t){h(t),_(!1);return}return u()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),_(!1))})}else U.api&&U.resourceId&&(_(!0),fetch(`${U.api}/${U.resourceId}`).then(e=>e.json()).then(t=>{e&&h(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&_(!1)}));return()=>{e=!1}},[U.api,U.resourceId,U.objectName,t,U.sections,U.fields,P,F]);let we=Q.useCallback(()=>{if(a)a();else if(U.onNavigate){let e=U.backUrl||(U.objectName?`/${U.objectName}`:`/`);U.onNavigate(e,{replace:!0})}else U.backUrl?window.location.href=U.backUrl:window.history.back()},[a,U]),Te=Q.useCallback(()=>{r?r():U.onNavigate&&U.editUrl?U.onNavigate(U.editUrl):U.onNavigate&&U.objectName&&U.resourceId?U.onNavigate(`/${U.objectName}/${U.resourceId}/edit`):U.editUrl&&(window.location.href=U.editUrl)},[r,U]),Ee=Q.useCallback(async()=>{if(!t?.cancelPendingApproval||!U.objectName||!U.resourceId){O(L(`detail.cancelApprovalUnavailable`));return}te(!0),O(null);try{if(await t.cancelPendingApproval(String(U.objectName),String(U.resourceId)),t.findOne)try{let e=await t.findOne(String(U.objectName),String(U.resourceId));e&&h(e)}catch{}ee(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(U.objectName),recordId:String(U.resourceId),reason:`approval-recalled`}}))}catch{}}catch(e){let t=(e?.message||e?.error||String(e??`Cancel failed`)).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``);O(`${L(`detail.cancelApprovalFailed`)}: ${t}`)}finally{te(!1)}},[t,U.objectName,U.resourceId,L]),De=Q.useCallback(()=>{let e=U.deleteConfirmation||L(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),U.onNavigate&&U.objectName&&U.onNavigate(`/${U.objectName}`,{replace:!0}))},[i,U]),Oe=Q.useCallback(()=>{navigator.share&&U.objectName&&U.resourceId?navigator.share({title:U.title||L(`detail.details`),text:`${U.objectName} #${U.resourceId}`,url:window.location.href}).catch(e=>{console.error(`Share failed:`,e)}):navigator.clipboard.writeText(window.location.href)},[U]),W=Q.useCallback(()=>{let e=!x;p&&p(e),f===void 0&&y(e)},[x,f,p]),ke=C?.setField,Ae=C&&C.canEdit?C.enter:void 0;Q.useEffect(()=>{if(!U.recordNavigation)return;let e=U.recordNavigation,t=t=>{let n=t.target?.tagName;n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable||(t.key===`ArrowLeft`&&e.currentIndex>0?(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex-1])):t.key===`ArrowRight`&&e.currentIndex<e.recordIds.length-1&&(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex+1])))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[U.recordNavigation]);let je=Q.useMemo(()=>U.related??[],[U.related]),G=Q.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:L(`detail.share`),icon:`share-2`,type:`script`,onClick:Oe}),U.showEdit&&e.push({name:`sys_edit_mobile`,label:L(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,...H?{disabled:!0}:null,onClick:Te}),U.showDelete&&e.push({name:`sys_delete`,label:L(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],...be?{disabled:!0}:null,onClick:De}),e},[L,U.showEdit,U.showDelete,H,be,Oe,Te,De]),Me=Q.useMemo(()=>{let e=U.actions??[];if(G.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,...G]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:G}),n},[U.actions,G]);return g||U.loading?(0,$.jsxs)(`div`,{className:Z(`space-y-4`,n),children:[(0,$.jsx)(ir,{className:`h-10 w-full`}),(0,$.jsx)(ir,{className:`h-64 w-full`}),(0,$.jsx)(ir,{className:`h-48 w-full`})]}):!m&&!U.data?(0,$.jsxs)(`div`,{className:Z(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,$.jsx)(`p`,{className:`text-lg font-semibold`,children:L(`detail.recordNotFound`)}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:L(`detail.recordNotFoundDescription`)}),(U.showBack??!0)&&(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:we,className:`mt-4 gap-2`,children:[(0,$.jsx)(yn,{className:`h-4 w-4`}),L(`detail.goBack`)]})]}):(0,$.jsx)(wn,{children:(0,$.jsxs)(`div`,{className:Z(`space-y-6`,n),children:[U.showHeader!==!1&&(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(U.showBack??!0)&&(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,onClick:we,className:`shrink-0 mt-1`,children:(0,$.jsx)(yn,{className:`h-4 w-4`})})}),(0,$.jsx)(Tn,{children:L(`detail.back`)})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,$.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:ma(m,U,k,L(`detail.details`))}),Se.map(e=>{let t=m?.[e];if(t==null||t===``)return null;let n=(U.sections||[]).flatMap(e=>e.fields).concat(U.fields||[]).find(t=>t.name===e),r=k?.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=Nn({...r,...n},ne);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=U.objectName?ie(U.objectName,e,String(t),o):o}}catch{}return o===null?(0,$.jsx)(tt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${e}: ${a}`,children:a},e):(0,$.jsxs)(tt,{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,$.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,$.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${o}%`}})}),a]},e)}),(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:W,"aria-label":L(x?`detail.removeFromFavorites`:`detail.addToFavorites`),children:x?(0,$.jsx)(Ht,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,$.jsx)(Ht,{className:`h-4 w-4 text-muted-foreground`})})}),(0,$.jsx)(Tn,{children:L(x?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),U.objectName&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:u||U.objectName}),U.resourceId&&(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:Ce,"aria-label":L(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:M?(0,$.jsx)(pr,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(Dt,{className:`h-3 w-3`})})}),(0,$.jsx)(Tn,{children:M?L(`detail.copied`,{defaultValue:`Copied!`}):L(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[U.recordNavigation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(X,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:U.recordNavigation.currentIndex<=0,onClick:()=>{let e=U.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,$.jsx)(sn,{className:`h-4 w-4`})})}),(0,$.jsx)(Tn,{children:L(`detail.previousRecord`)})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:L(`detail.recordOf`,{current:U.recordNavigation.currentIndex+1,total:U.recordNavigation.recordIds.length})}),(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(X,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:U.recordNavigation.currentIndex>=U.recordNavigation.recordIds.length-1,onClick:()=>{let e=U.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,$.jsx)(Cn,{className:`h-4 w-4`})})}),(0,$.jsx)(Tn,{children:L(`detail.nextRecord`)})]})]}),U.showEdit&&(0,$.jsxs)(Ln,{children:[(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsxs)(X,{variant:`default`,disabled:H,onClick:()=>{H||Te()},className:`gap-2 hidden sm:inline-flex`,children:[(0,$.jsx)(J,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:L(`detail.edit`)})]})}),(0,$.jsx)(Tn,{children:L(`detail.editRecord`)})]}),Me.map((e,t)=>(0,$.jsx)(b,{schema:ae(e),data:m},`header-action-${t}`))]})]}),U.header&&(0,$.jsx)(`div`,{children:(0,$.jsx)(b,{schema:ae(U.header),data:m})}),U.highlightFields&&U.highlightFields.length>0&&(0,$.jsx)(Vi,{fields:U.highlightFields,data:m,objectName:U.objectName,objectSchema:k}),s&&U.showHeader===!1&&(()=>{let e=m?.approval_status,n=e===`pending`||e===`in_approval`,r=C?.approvalPending??!1,i=r&&!(C?.locked??!1)?!1:(C?.locked??!1)||n,a=i||r||n,o=a?C?.approvalProgress:void 0,s=!!o&&o.need>0&&o.need<=12;return!a&&!D?null:(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[a&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsxs)(`span`,{role:`status`,className:i?`inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800`:`inline-flex items-center gap-1 rounded-md border border-sky-300 bg-sky-50 px-2 py-1 text-xs text-sky-800`,title:i?C?.lockedReason??L(`detail.lockedTooltip`):L(`detail.approvalPendingTooltip`),children:[i?(0,$.jsx)(pn,{className:`h-3 w-3`}):(0,$.jsx)(ct,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:L(i?`detail.lockedByApproval`:`detail.approvalPendingEditable`)})]}),t?.cancelPendingApproval&&(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:Ee,disabled:I,className:i?`gap-2 border-amber-300 text-amber-800 hover:bg-amber-50`:`gap-2 border-sky-300 text-sky-800 hover:bg-sky-50`,title:L(i?`detail.cancelApprovalTooltip`:`detail.cancelApprovalTooltipUnlocked`),children:[(0,$.jsx)(un,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:L(I?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),o&&(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-1 max-w-[16rem]`,children:[(0,$.jsxs)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":o.need,"aria-valuenow":Math.min(o.got,o.need),"aria-label":L(`detail.approvalProgressLabel`),className:`flex items-center gap-2 w-full justify-end`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground whitespace-nowrap`,children:o.behavior===`per_group`?L(`detail.approvalProgressGroups`,{got:o.got,need:o.need}):L(`detail.approvalProgress`,{got:o.got,need:o.need})}),s&&(0,$.jsx)(`span`,{className:`flex items-center gap-1 w-20 shrink-0`,children:Array.from({length:o.need}).map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:Z(`h-1.5 flex-1 rounded-full`,t<o.got?`bg-emerald-500`:`bg-muted`)},t))})]}),o.groups&&o.groups.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:o.groups.map(e=>(0,$.jsxs)(`span`,{title:`${e.got}/${e.need}`,className:Z(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px]`,e.satisfied?`border-emerald-300 text-emerald-700`:`border-border text-muted-foreground`),children:[e.satisfied?(0,$.jsx)(pr,{className:`h-3 w-3`}):(0,$.jsx)(on,{className:`h-2.5 w-2.5`}),(0,$.jsx)(`span`,{children:`${e.group} ${e.got}/${e.need}`})]},e.group))})]}),D&&(0,$.jsx)(`div`,{role:`alert`,className:`text-xs text-destructive bg-destructive/10 border border-destructive/20 rounded-md px-2 py-1 max-w-md text-right`,children:D})]})})(),U.autoTabs&&!U.tabs?.length?(()=>{let e=je.length>0,n=!!U.activities&&U.activities.length>0,r=!!c,i=!!U.history,a=[`details`,...e?[`related`]:[],...n?[`activity`]:[],...r?[`discussion`]:[],...i?[`history`]:[]],o=U.defaultTab,l=o&&a.includes(o)?o:`details`,u=U.onTabChange,d=(0,$.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[U.sectionGroups&&U.sectionGroups.length>0&&U.sectionGroups.map((e,n)=>(0,$.jsx)(Bi,{group:e,data:{...m,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:ke,onEnterInlineEdit:s?Ae:void 0,autoFocusField:E,dataSource:t},n)),U.sections&&U.sections.length>0&&U.sections.map((e,n)=>(0,$.jsx)(Ni,{section:e,data:{...m,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:ke,onEnterInlineEdit:s?Ae:void 0,autoFocusField:E,dataSource:t},n)),U.fields&&U.fields.length>0&&!U.sections?.length&&(0,$.jsx)(Ni,{section:{fields:U.fields,columns:U.columns},data:{...m,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:ke,onEnterInlineEdit:s?Ae:void 0,autoFocusField:E,dataSource:t}),U.comments&&(0,$.jsx)(Ui,{comments:U.comments,onAddComment:U.onAddComment})]});return!e&&!n&&!r&&!i?(0,$.jsx)(`div`,{className:`mt-2`,children:d}):(0,$.jsxs)(Kt,{defaultValue:l,onValueChange:u,className:`w-full`,children:[(0,$.jsxs)(zt,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,$.jsx)(Xt,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:L(`detail.details`)}),e&&(0,$.jsx)(Xt,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[L(`detail.related`),(0,$.jsx)(tt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:je.length})]})}),n&&(0,$.jsx)(Xt,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[L(`detail.activity`),(0,$.jsx)(tt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:U.activities.length})]})}),r&&(0,$.jsx)(Xt,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:L(`detail.discussion`,{defaultValue:`Discussion`})}),i&&(0,$.jsx)(Xt,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[L(`detail.history`,{defaultValue:`History`}),!U.history.loading&&U.history.entries.length>0&&(0,$.jsx)(tt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:U.history.entries.length})]})})]}),(0,$.jsx)(Qe,{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,$.jsx)(Qe,{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,$.jsx)(`div`,{className:`space-y-3`,children:je.map((e,n)=>(0,$.jsx)(zi,{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:fa},n))})}),n&&(0,$.jsx)(Qe,{value:`activity`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,$.jsx)(Yi,{activities:U.activities})}),r&&(0,$.jsx)(Qe,{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,$.jsx)(Qe,{value:`history`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,$.jsx)(na,{entries:U.history.entries,loading:U.history.loading,emptyText:U.history.emptyText??L(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,$.jsxs)($.Fragment,{children:[U.sectionGroups&&U.sectionGroups.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:U.sectionGroups.map((e,n)=>(0,$.jsx)(Bi,{group:e,data:{...m,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:ke,onEnterInlineEdit:s?Ae:void 0,autoFocusField:E,dataSource:t},n))}),U.sections&&U.sections.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:U.sections.map((e,n)=>(0,$.jsx)(Ni,{section:e,data:{...m,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:ke,onEnterInlineEdit:s?Ae:void 0,autoFocusField:E,dataSource:t},n))}),U.fields&&U.fields.length>0&&!U.sections?.length&&(0,$.jsx)(Ni,{section:{fields:U.fields,columns:U.columns},data:{...m,...T},objectSchema:k,objectName:U.objectName,isEditing:w,onFieldChange:ke,onEnterInlineEdit:s?Ae:void 0,autoFocusField:E,dataSource:t}),U.tabs&&U.tabs.length>0&&(0,$.jsx)(Pi,{tabs:U.tabs,data:m}),je.length>0&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:L(`detail.related`)}),je.map((e,n)=>(0,$.jsx)(zi,{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:fa},n))]}),U.comments&&(0,$.jsx)(Ui,{comments:U.comments,onAddComment:U.onAddComment}),U.activities&&U.activities.length>0&&(0,$.jsx)(Yi,{activities:U.activities})]}),(0,$.jsx)(la,{data:{...m,...T},objectSchema:k,objectName:U.objectName}),U.footer&&(0,$.jsx)(`div`,{children:(0,$.jsx)(b,{schema:ae(U.footer),data:m})})]})})},ga=e=>P(e)??null,_a=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}},va=({schema:e={},className:t,...n})=>{let r=B(),{designer:i}=_a(n),a=r?.objectName||``,c=o(),{readableFields:l}=s(a),{sectionLabel:u}=re(),{language:d}=h(),f=m();if(!r)return(0,$.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...i,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:details — bind a record to preview`})});let p=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(p.length>0&&a&&!p.every(e=>c.can(a,e)))return(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let g=e.enforceFieldSecurity===!0,v=Array.isArray(e.redactFields)?e.redactFields:[],y=e=>{if(!e||!g&&v.length===0)return e;let t=e.map(ga).filter(e=>!!e),n=new Set((g&&a?l(t):t).filter(e=>!v.includes(e)));return e.filter(e=>{let t=ga(e);return!t||n.has(t)})},b=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,S=e=>Array.isArray(e)?e.map(b):e,C=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:ga(e)).filter(e=>!!e));for(let e of f)C.add(e);let w=r.objectSchema,T=r.data??{},E=[w?.primaryField,`name`,`full_name`,`title`,`subject`,`display_name`,`label`].filter(e=>typeof e==`string`&&e.length>0);for(let e of E)if(T[e]!==void 0&&T[e]!==null&&T[e]!==``){C.add(e);break}let D=e=>!e||C.size===0?e:e.filter(e=>{let t=ga(e);return!t||!C.has(t)}),O=D(S(y(e.fields))),k=Array.isArray(e.sections)?e.sections.map(e=>{let t=e.title??e.label,n=t==null?void 0:_(t,d),r=e.name&&a?u(a,e.name,n??e.name):n;return{...e,title:r,showBorder:e.showBorder??!!r,hideEmpty:e.hideEmpty??!0,fields:D(S(y(e.fields)))}}):e.sections,A=x(w,c?.getObjectApiOperations?.(a)),j=(e.inlineEdit??!0)&&A,M={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:`vertical`,columns:e.columns,sections:k,fields:O,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:j};return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(ha,{schema:M,dataSource:r.dataSource,inlineEdit:j})})},ya=e=>P(e)||(e&&typeof e==`object`?e.key:null)||null,ba=e=>e?.id??e?._id??null,xa=5,Sa=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}},Ca=({schema:e={},className:t,...n})=>{let r=B(),{designer:i}=Sa(n),a=re(),{language:c}=h(),l=e.objectName,u=l&&a.objectLabel?a.objectLabel({name:l,label:tr(l)}):l?tr(l):``,d=_(e.title,c)||u||`Related`,f=o(),{readableFields:p}=s(l||``),m=e.relationshipValueField||`id`,g=m===`id`?r?.recordId??null:r?.data?.[m]??null,v=T(),y=Q.useMemo(()=>v?.resolve({objectName:l,relationshipField:e.relationshipField,parentId:g})??null,[v,l,e.relationshipField,g]);if(!l)return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});if(f.isLoaded&&!f.can(l,`read`))return null;let b=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(b.length>0&&!b.every(e=>f.can(l,e)))return(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let x=e.enforceFieldSecurity===!0,S=Array.isArray(e.redactFields)?e.redactFields:[],C=Array.isArray(e.columns)?e.columns:[],w=C;if(x||S.length>0){let e=C.map(ya).filter(e=>!!e),t=new Set((x?p(e):e).filter(e=>!S.includes(e)));w=C.filter(e=>{let n=ya(e);return!n||t.has(n)})}return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(zi,{title:d,type:`table`,api:l,objectName:l,referenceField:e.relationshipField,parentId:g,columns:w,pageSize:typeof e.limit==`number`&&e.limit>0?e.limit:xa,defaultSort:e.sort,filter:e.filter,dataSource:r?.dataSource,add:e.add?{...e.add,label:_(e.add.label,c)||void 0}:void 0,rowActions:y?.rowActions,onRowAction:y?.onRowAction,toolbarActions:y?.toolbarActions,onToolbarAction:y?.onToolbarAction,onNew:y?.onCreate,newDisabled:y?.createDisabled,onRowClick:y?.onView?e=>{let t=ba(e);t!=null&&y.onView(t,e)}:void 0,onRowEdit:y?.onEdit?e=>{let t=ba(e);t!=null&&y.onEdit(t,e)}:void 0,onRowDelete:y?.onDelete?e=>{let t=ba(e);if(t!=null)return y.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})})},wa={columns:!0,filter:!0,sort:!0,limit:`limit`},Ta={},Ea=e=>{let t=B();return(0,$.jsx)(ue,{schema:e.schema??Ta,mapping:wa,dataSource:t?.dataSource,testId:`record-related-list`,errorTitle:`This related list’s data source could not be resolved`,children:t=>(0,$.jsx)(Ca,{...e,schema:t})})},Da=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}},Oa=({schema:e={},className:t,...n})=>{let r=B(),{designer:i}=Da(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))),_=Q.useId();return ye(_,d?g.map(e=>e.name):[]),d?(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(Vi,{fields:g,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema,dataSource:r?.dataSource})}):(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})})},ka=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),r=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),i=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,$.jsxs)(`div`,{className:Z(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,$.jsx)(St,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`text-foreground`,children:i})]})},Aa=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],ja=({reactions:e,onToggleReaction:t,emojiOptions:n=Aa,className:r})=>{let[i,a]=Q.useState(!1),{t:o}=mi(),s=Q.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,$.jsxs)(`div`,{className:Z(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>{let n=o(e.count===1?`detail.reactionCountOne`:`detail.reactionCount`,{emoji:e.emoji,count:e.count});return(0,$.jsxs)(`button`,{type:`button`,className:Z(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors`,e.reacted?`bg-primary/10 border-primary/30 text-primary`:`bg-muted border-border text-muted-foreground hover:bg-muted/80`),onClick:()=>s(e.emoji),disabled:!t,"aria-label":n,children:[(0,$.jsx)(`span`,{children:e.emoji}),(0,$.jsx)(`span`,{children:e.count})]},e.emoji)}),t&&(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":o(`detail.addReaction`),children:(0,$.jsx)(sr,{className:`h-3.5 w-3.5`})}),i&&(0,$.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":o(`detail.emojiPicker`),children:n.map(t=>(0,$.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>s(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function Ma(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 Na=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=mi(),[o,s]=Q.useState(!1),[c,l]=Q.useState(``),[u,d]=Q.useState(!1),f=Q.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=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return t.length===0&&!r?null:(0,$.jsxs)(`div`,{className:Z(`ml-10 mt-1`,i),children:[t.length>0&&(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>s(!o),"aria-expanded":o,children:[o?(0,$.jsx)(nr,{className:`h-3 w-3`}):(0,$.jsx)(Cn,{className:`h-3 w-3`}),(0,$.jsx)($n,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{count:t.length})})]}),o&&(0,$.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,$.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,$.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground`,children:e.actor.charAt(0).toUpperCase()})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Ma(e.createdAt,a)})]}),(0,$.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,$.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,$.jsx)(`input`,{className:`flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.replyPlaceholder`),value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:u}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:f,disabled:!c.trim()||u,"aria-label":`Send reply`,children:(0,$.jsx)(Zn,{className:`h-3 w-3`})})]})]})},Pa=({subscription:e,onToggle:t,className:n})=>{let{t:r}=mi(),[i,a]=Q.useState(!1),o=Q.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:Z(`h-8 w-8`,n),onClick:o,disabled:i||!t,"aria-label":e.subscribed?r(`detail.unsubscribeAriaLabel`):r(`detail.subscribeAriaLabel`),title:e.subscribed?r(`detail.subscribedTooltip`):r(`detail.unsubscribedTooltip`),children:e.subscribed?(0,$.jsx)(Ye,{className:`h-4 w-4 text-primary`}):(0,$.jsx)(Lt,{className:`h-4 w-4 text-muted-foreground`})})};function Fa(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 Ia=({value:e,onChange:t,onSubmit:n,mentionSuggestions:r=[],placeholder:i,className:a,disabled:o=!1,extraSlot:s,canSubmitEmpty:c=!1})=>{let{t:l}=mi(),[u,d]=Q.useState(!1),[f,p]=Q.useState(!1),[m,h]=Q.useState(``),[g,_]=Q.useState(0),v=Q.useRef(null),y=Q.useMemo(()=>{if(!m)return r;let e=m.toLowerCase();return r.filter(t=>t.label.toLowerCase().includes(e))},[m,r]),b=Q.useCallback((n,r=``)=>{let i=v.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);t(e.slice(0,a)+n+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+n.length+s.length;i.setSelectionRange(e,e)})},[e,t]),x=Q.useCallback(()=>b(`**`,`**`),[b]),S=Q.useCallback(()=>b(`*`,`*`),[b]),C=Q.useCallback(()=>b(`
|
|
4
|
-
- `,``),[b]),w=Q.useCallback(()=>b("`","`"),[b]),T=Q.useCallback(()=>{b(`@`,``),p(!0),h(``),_(0)},[b]),E=Q.useCallback(n=>{let r=v.current;if(!r)return;let i=r.selectionStart,a=e.slice(0,i).lastIndexOf(`@`);a!==-1&&t(e.slice(0,a)+`@${n.label} `+e.slice(i)),p(!1),h(``),requestAnimationFrame(()=>r.focus())},[e,t]),D=Q.useCallback(e=>{let n=e.target.value;t(n);let r=e.target.selectionStart,i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a!==-1){let e=i.slice(a+1),t=a>0?i[a-1]:` `;if(/\s/.test(t)&&!/\s/.test(e)){p(!0),h(e),_(0);return}}p(!1)},[t]),O=Q.useCallback(e=>{if(f&&y.length>0){if(e.key===`ArrowDown`){e.preventDefault(),_(e=>e<y.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),_(e=>e>0?e-1:y.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),E(y[g]);return}if(e.key===`Escape`){p(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),n?.())},[f,y,g,E,n]);return(0,$.jsxs)(`div`,{className:Z(`border rounded-md`,a),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:x,disabled:o||u,title:l(`detail.bold`),children:(0,$.jsx)(Vt,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:S,disabled:o||u,title:l(`detail.italic`),children:(0,$.jsx)(Tt,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:C,disabled:o||u,title:l(`detail.listFormat`),children:(0,$.jsx)(At,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:o||u,title:l(`detail.inlineCode`),children:(0,$.jsx)(Gt,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:o||u,title:l(`detail.mentionSomeone`),children:(0,$.jsx)(Gn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>d(!u),title:l(u?`detail.edit`:`detail.preview`),children:u?(0,$.jsx)(J,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Nt,{className:`h-3.5 w-3.5`})}),n&&(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:n,disabled:o||!c&&!e.trim(),title:l(`detail.submitComment`),children:(0,$.jsx)(Zn,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`relative`,children:u?(0,$.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:Fa(e)}}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`textarea`,{ref:v,className:`w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground`,placeholder:i??l(`detail.writeComment`),value:e,onChange:D,onKeyDown:O,disabled:o}),f&&y.length>0&&(0,$.jsx)(`div`,{className:`absolute left-2 bottom-full mb-1 w-56 bg-popover border rounded-md shadow-md z-50 max-h-40 overflow-y-auto`,children:y.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:Z(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===g&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),E(e)},children:[e.avatarUrl?(0,$.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,$.jsx)(`div`,{className:`h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium`,children:e.label.charAt(0).toUpperCase()}),(0,$.jsx)(`span`,{children:e.label})]},e.id))})]})}),s&&(0,$.jsx)(`div`,{className:`border-t px-2 py-2 bg-muted/20`,children:s})]})};function La(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Ra(e){return e.startsWith(`image/`)}function za(e){return Ra(e)?Xe:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?Un:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?K:er}var Ba=({attachments:e,onUpload:t,onRemove:n,className:r,readOnly:i=!1})=>{let{t:a}=mi(),[o,s]=Q.useState(!1),c=Q.useRef(null),l=Q.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!0)},[]),u=Q.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1)},[]),d=Q.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),f=Q.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,$.jsxs)(`div`,{className:Z(`space-y-2`,r),children:[t&&!i&&(0,$.jsxs)(`div`,{className:Z(`border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer`,o?`border-primary bg-primary/5`:`border-muted-foreground/25 hover:border-muted-foreground/40`),onDragOver:l,onDragLeave:u,onDrop:d,onClick:()=>c.current?.click(),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c.current?.click())},children:[(0,$.jsx)(rr,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`detail.dropFilesToUpload`)}),(0,$.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:f})]}),e.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(gr,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:e.length===1?a(`detail.attachmentCount`,{count:e.length}):a(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=Ra(e.type),r=za(e.type);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-2.5 py-2 bg-muted/30 group`,children:[t&&(e.thumbnailUrl||e.url)?(0,$.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,$.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,$.jsx)(r,{className:`h-5 w-5 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:La(e.size)})]}),n&&!i&&(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>n(e.id),title:a(`detail.removeAttachment`),children:(0,$.jsx)(un,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},Va={comment:$n,field_change:J,task:Kn,event:jn,system:Xn,email:ln,call:Ue,note:_r,file:Un,sharing:On,record_create:Yn,record_delete:Mt,approval:Ke},Ha={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 Ua(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 Wa(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){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 Ka=({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}=mi(),[y,b]=Q.useState(`all`),[x,S]=Q.useState(``),[C,w]=Q.useState(!1),[T,E]=Q.useState(!1),[D,O]=Q.useState([]),[k,A]=Q.useState(!1),j=n??y,M=t?.showFilterToggle!==!1,N=t?.showCommentInput!==!1&&!!s,P=t?.enableReactions??!1,ee=t?.enableThreading??!1,F=t?.showSubscriptionToggle??!1,I=Q.useMemo(()=>Ga(e,j),[e,j]),te=Q.useMemo(()=>ee?I.filter(e=>!e.parentId):I,[I,ee]),L=Q.useMemo(()=>{if(!ee)return new Map;let e=new Map;for(let t of I)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[I,ee]),ne=Q.useCallback(e=>{r?r(e):b(e)},[r]),re=Q.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]),ie=Q.useCallback(async e=>{if(!(!m||e.length===0)){A(!0);try{let t=await m(e);Array.isArray(t)&&t.length>0&&O(e=>[...e,...t])}finally{A(!1)}}},[m]),ae=Q.useCallback(e=>{O(t=>t.filter(t=>t.id!==e))},[]),oe=Q.useCallback(async()=>{if(a){E(!0);try{await a()}finally{E(!1)}}},[a]);return(0,$.jsxs)(`section`,{className:Z(`border-t border-border/60 pt-5`,_),"aria-label":`Discussion`,children:[(0,$.jsx)(`header`,{className:`mb-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold leading-none tracking-tight`,children:[(0,$.jsx)(dn,{className:`h-4 w-4`}),h??v(`detail.activity`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,I.length,`)`]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:F&&u&&(0,$.jsx)(Pa,{subscription:u,onToggle:d})})]})}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[M&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(Re,{value:j,onValueChange:e=>ne(e),children:[(0,$.jsx)(Mn,{"aria-label":v(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,$.jsx)(De,{})}),(0,$.jsx)(Pe,{children:Ua(v).map(e=>(0,$.jsx)(gt,{value:e.value,children:e.label},e.value))})]})}),N&&(0,$.jsx)(Ia,{value:x,onChange:S,onSubmit:re,mentionSuggestions:p,placeholder:v(`detail.leaveCommentPlaceholder`),disabled:C,canSubmitEmpty:D.length>0,extraSlot:m?(0,$.jsx)(Ba,{attachments:D,onUpload:ie,onRemove:ae,readOnly:C||k}):D.length>0?(0,$.jsx)(Ba,{attachments:D,onRemove:ae,readOnly:C}):void 0}),o&&I.length===0?(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`activity-loading`,className:`flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground`,children:[(0,$.jsx)(dr,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:v(`detail.loading`)})]}):I.length===0?f?null:(0,$.jsx)(hn,{title:g??v(`detail.noActivity`),className:`py-6`}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,$.jsx)(`div`,{className:`space-y-4`,children:te.map(e=>{let t=Va[e.type]||Xn,n=Ha[e.type]||`bg-gray-100 text-gray-600`,r=L.get(e.id)??[];return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:Z(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,$.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`detail.via`,{source:e.source})}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Wa(e.createdAt,v)}),e.edited&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:v(`detail.edited`)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,v(`detail.pinned`)]})]}),e.body&&(0,$.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.sourceObject&&e.sourceId!=null&&(0,$.jsxs)(`a`,{href:`/objects/${e.sourceObject}/${e.sourceId}`,className:`mt-1 inline-flex items-center gap-1 text-xs text-primary hover:underline`,"data-testid":`activity-source-link`,children:[v(`detail.viewSource`),(0,$.jsx)(`span`,{"aria-hidden":!0,children:`→`})]}),e.type===`field_change`&&e.fieldChanges&&(0,$.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,$.jsx)(ka,{change:e},t))}),P&&e.reactions&&e.reactions.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(ja,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),P&&(!e.reactions||e.reactions.length===0)&&l&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(ja,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),ee&&(e.replyCount??0)>0&&(0,$.jsx)(Na,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,$.jsx)(`div`,{className:`text-center pt-2`,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:oe,disabled:T,"aria-label":v(`detail.loadMore`),children:[T?(0,$.jsx)(dr,{className:`h-4 w-4 animate-spin mr-1`}):(0,$.jsx)(nr,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})};p();var qa=c.options,Ja=f.options,Ya={created:`field_change`,updated:`field_change`,deleted:`field_change`,assigned:`field_change`,shared:`field_change`,system:`system`,completed:`task`,commented:void 0,mentioned:void 0,login:void 0,logout:void 0},Xa=new Set([`task`]);function Za(e){return typeof e==`string`&&qa.includes(e)?e:`all`}function Qa(e){if(!Array.isArray(e))return;let t=e.filter(e=>typeof e==`string`&&Ja.includes(e));return t.length>0?t:void 0}function $a(e){let t=Math.floor(Number(e));return Number.isFinite(t)&&t>0?t:20}function eo(e){let t=e.timestamp;return String(!t||t===`NOW()`||Number.isNaN(Date.parse(String(t)))?e.created_at??``:t)}function to(e,t){let n=Ya[String(e?.type)];return n?{id:e.id,type:n,actor:e.actor_name??t,actorAvatarUrl:e.actor_avatar_url??void 0,body:e.summary??``,createdAt:eo(e),sourceObject:e.source_object??void 0,sourceId:e.source_id??void 0}:null}function no(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=>!Xa.has(e.type)));let i=Qa(t.types);if(i){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 ro(...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 io=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}},ao=({schema:e={},className:t,...n})=>{let{designer:r}=io(n),i=B(),a=k(),o=Hn(),s=e.properties??{},c=t=>e[t]??s[t],l=$a(c(`limit`)),u=Za(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,S]=Q.useState(0),C=l*(x+1),[w,T]=Q.useState(null),[E,D]=Q.useState(!1),[O,A]=Q.useState(!1),j=o(`detail.systemActor`,`System`);Q.useEffect(()=>{if(!b)return;let e=!1;return A(!0),Promise.resolve(y.find(`sys_activity`,{$filter:{object_name:_,record_id:v},$orderby:{timestamp:`desc`},$top:Math.max(1,C)+1})).then(t=>{if(e)return;let n=t?.data??t?.records??[],r=Array.isArray(n)?n:[],i=[];for(let e of r){let t=to(e,j);t&&i.push(t)}D(r.length>Math.max(1,C)),T(ro(i))}).catch(()=>{e||(T([]),D(!1))}).finally(()=>{e||A(!1)}),()=>{e=!0}},[b,y,_,v,C,j]);let M=a?.items,N=Q.useMemo(()=>no(h??M??w??[],{types:d,showCompleted:f,unifiedTimeline:p},C),[h,M,w,d,f,p,C]),P=N.items,ee=N.hasMore||b&&E,F=g??a?.loading??(b&&w===null?!0:O),[I,te]=Q.useState(u);Q.useEffect(()=>{te(u)},[u]);let L=Q.useCallback(()=>{S(e=>e+1)},[]),ne=m.enableMentions!==!1;return(0,$.jsx)(`div`,{className:t,...r,children:(0,$.jsx)(Ka,{items:P,config:m,loading:F,filterMode:I,onFilterChange:te,hasMore:ee,onLoadMore:L,onAddComment:a?.onAddComment,onAddReply:a?.onAddReply,onToggleReaction:a?.onToggleReaction,mentionSuggestions:ne?a?.mentionSuggestions:void 0,onUploadAttachments:a?.onUploadAttachments})})},oo=({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}=mi(),[x,S]=Q.useState(y);return g===`right`||g===`left`?x&&v?(0,$.jsx)(`div`,{className:Z(`flex items-start pt-4`,g===`right`?`border-l`:`border-r`,h),children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>S(!1),"aria-label":b(`detail.openDiscussion`),children:(0,$.jsx)(It,{className:`h-4 w-4`})})}):(0,$.jsxs)(`div`,{className:Z(`flex flex-col overflow-hidden`,g===`right`?`border-l`:`border-r`,h),style:{width:_,minWidth:_},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)($n,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:b(`detail.discussion`)})]}),v&&(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.closeDiscussion`),children:(0,$.jsx)(un,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,$.jsx)(Ka,{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,$.jsx)(`div`,{className:Z(``,h),children:v&&x?(0,$.jsxs)(X,{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,$.jsx)($n,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:b(`detail.showDiscussion`,{count:t.length})})]}):(0,$.jsxs)(`div`,{children:[v&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)($n,{className:`h-4 w-4`}),b(`detail.discussion`)]}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.hideDiscussion`),children:(0,$.jsx)(Jt,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(Ka,{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`)})]})})},so=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}},co=({schema:e={},className:t,...n})=>{B();let r=k(),{designer:i}=so(n),a={position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0},...e};return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(oo,{items:r?.items||[],config:a,loading:r?.loading,onAddComment:r?.onAddComment,onAddReply:r?.onAddReply,onToggleReaction:r?.onToggleReaction,mentionSuggestions:r?.mentionSuggestions,onUploadAttachments:r?.onUploadAttachments})})},lo=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}},uo=({schema:e={},className:t,...n})=>{let r=B(),{translateOptions:i}=re(),{designer:a}=lo(n),o=Array.isArray(e.stages)?e.stages:[],s=e.statusField,c=Q.useMemo(()=>{if(o.length===0||!s||!r?.objectName)return o;let e=i(r.objectName,s,o);return Array.isArray(e)&&e.length===o.length?o.map((t,n)=>({...t,label:e[n]?.label??t.label})):o},[o,s,r?.objectName,i]),l=s&&r?.data?r.data[s]:void 0,u=/(^|[_-\s])(closed_)?(lost|failed?|cancell?ed|失败|流失|丢单|败)([_-\s]|$)/i,d=/(^|[_-\s])(closed_)?(won|success|成交|赢|完成)([_-\s]|$)/i,f=c.map(e=>{if(e.terminal)return e.terminal;let t=`${String(e.value??``)} ${String(e.label??``)}`;if(u.test(t))return`lost`;if(d.test(t))return`won`}),p=f.findIndex(e=>e===`lost`),m=p===-1?c:c.slice(0,p),h=p===-1?[]:c.slice(p),g=p===-1?f:f.slice(0,p),_=c.findIndex(e=>e.value===l);_<0&&(_=-1);let v=p!==-1&&_>=p;if(c.length===0)return(0,$.jsx)(`div`,{className:t,...a,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:path — no stages configured`})});let y=m.length-1;return(0,$.jsxs)(`div`,{className:Z(`w-full`,t),...a,children:[(0,$.jsxs)(`div`,{className:`hidden sm:flex w-full items-stretch gap-2`,role:`list`,"aria-label":e.aria?.label||`Record path`,children:[(0,$.jsx)(`div`,{className:`flex flex-1 items-stretch gap-1.5`,children:m.map((e,t)=>{let n=!v&&_>=0&&t<_,r=!v&&t===_,i=g[t]===`won`&&t===y;return(0,$.jsx)(`div`,{role:`listitem`,"aria-current":r?`step`:void 0,className:Z(`relative flex-1 min-w-0 px-4 py-2 text-xs font-medium text-center rounded-xl`,r&&`bg-primary text-primary-foreground shadow-sm`,n&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`,!r&&!n&&i&&`bg-emerald-500/10 text-emerald-700/85 dark:text-emerald-300/85`,!r&&!n&&!i&&`bg-muted text-muted-foreground`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-1.5 truncate`,children:[n&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),i&&!r&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`🏆`}),e.label]})},`${e.value}-${t}`)})}),h.length>0&&(0,$.jsx)(`div`,{className:`flex items-stretch gap-1 pl-2 border-l border-border/40`,"aria-label":`Alternative terminal stages`,children:h.map((e,t)=>{let n=p+t===_;return(0,$.jsx)(`div`,{role:`listitem`,"aria-current":n?`step`:void 0,className:Z(`shrink-0 px-3 py-2 text-xs font-medium rounded-md border whitespace-nowrap`,n&&`bg-destructive text-destructive-foreground border-destructive shadow-sm ring-1 ring-destructive/40`,!n&&`bg-destructive/5 text-destructive/85 border-destructive/20`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`✗`}),e.label]})},`${e.value}-lost-${t}`)})})]}),(0,$.jsx)(`div`,{className:`flex sm:hidden w-full items-stretch gap-1 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||`Record path`,children:c.map((e,t)=>{let n=f[t]===`lost`,r=!n&&!v&&_>=0&&t<_,i=t===_;return(0,$.jsx)(`div`,{role:`listitem`,"aria-current":i?`step`:void 0,className:Z(`shrink-0 px-3 py-1.5 rounded-full text-xs font-medium border whitespace-nowrap`,n&&i&&`bg-destructive text-destructive-foreground border-destructive shadow-sm`,n&&!i&&`bg-destructive/5 text-destructive/85 border-destructive/20`,!n&&i&&`bg-primary text-primary-foreground border-primary shadow-sm ring-1 ring-primary/40`,!n&&r&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 border-emerald-500/30`,!n&&!i&&!r&&`bg-background text-foreground/85 border-border/60`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[n&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`✗`}),!n&&r&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),e.label]})},`${e.value}-${t}-m`)})})]})},fo=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}},po=({schema:e={},className:t,...n})=>{let r=B(),{designer:i}=fo(n),a=o(),s=ne(),c=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:[],l=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:[],u=r?.objectName||``,d=l.length>0?l:Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:[],f=d.length>0&&!!u,{item:p}=V(`object`,f?u:null),m=(f?(()=>{let e=Array.isArray(p?.actions)?p.actions:[],t=new Map(e.map(e=>[e.name,e]));return d.map(e=>t.get(e)).filter(e=>!!e)})():Array.isArray(c)?c:[]).map((e,t)=>s(u||void 0,e,{fallbackLabel:`Action ${t+1}`})),h=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[],g=e.location||`record_header`,{getActionsForLocation:_,executeAction:v}=F({actions:m,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}});if(h.length>0&&u&&!h.every(e=>a.can(u,e)))return(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view quick actions.`})});let y=m.length>0?_(g):[];if(y.length===0)return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:quick_actions — no actions configured`})});let b=e.align||`end`,x=b===`start`?`justify-start`:b===`center`?`justify-center`:`justify-end`,S=g===`record_header`&&!e.inline,C=(e.aria?.ariaLabel??e.aria?.label)||`Quick actions`;return(0,$.jsx)(`div`,{className:Z(`flex flex-wrap items-center gap-2`,S&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,x,t),role:`toolbar`,"aria-label":C,...i,children:y.map((t,n)=>(0,$.jsx)(mo,{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 v(t.name)}},t.name||`qa-${n}`))})};function mo({action:e,record:t,variant:n,size:r,label:i,onRun:a}){let[o,s]=Q.useState(!1),c=Q.useMemo(()=>({record:t||{}}),[t]),l=N(H(e.disabled),c),u=(z(e.disabled)?l:!1)||o;return(0,$.jsxs)(X,{variant:n,size:r,disabled:u,onClick:async()=>{s(!0);try{await a()}finally{s(!1)}},children:[o&&(0,$.jsx)(dr,{className:`mr-2 h-4 w-4 animate-spin`}),i]})}var ho=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}},go=new Set([`created`,`updated`,`assigned`,`shared`,`deleted`]),_o=({schema:e={},className:t,...n})=>{let{designer:r}=ho(n),i=B(),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]=Q.useState(null),[g,_]=Q.useState(!1);Q.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??t?.records??[]).filter(e=>go.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,$.jsx)(`div`,{className:t,...r,children:(0,$.jsx)(na,{entries:v,loading:y,emptyText:s,unknownUserText:c})})},vo=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}},yo=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),bo=(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||`—`,xo=({schema:e={},className:t,...r})=>{let a=B(),o=re(),{t:s}=mi(),{designer:c}=vo(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]=Q.useState({}),h=Q.useRef(null),[g,_]=Q.useState(!1),v=Q.useRef(!0);Q.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);let y=Q.useRef(``);Q.useEffect(()=>{if(g)return;let e=h.current;if(!e||typeof IntersectionObserver>`u`){_(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&_(!0)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[g]);let b=JSON.stringify(u.map(e=>`${e.objectName}:${e.relationshipField}:${e.limit??3}`));Q.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,S]=Q.useState(!1);if(u.length===0)return null;let C=e.hideEmpty!==!1,w=new Set(u.filter(e=>{let t=p[e.objectName];return C&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),T=u.filter(e=>x||!w.has(e.objectName)),E=u.filter(e=>w.has(e.objectName)).map(e=>e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:yo(e.objectName)}):yo(e.objectName)));return(0,$.jsxs)(`div`,{ref:h,className:Z(`flex flex-col gap-3`,e.className,t),...c,children:[T.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:yo(e.objectName)}):yo(e.objectName));return(0,$.jsxs)(W,{className:`overflow-hidden`,children:[(0,$.jsxs)(ht,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,$.jsx)(bt,{className:`text-sm font-semibold tracking-tight truncate`,children:i}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!r.loading&&(0,$.jsx)(tt,{variant:`secondary`,className:`tabular-nums`,children:r.total}),l&&d&&(0,$.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,$.jsx)(kn,{className:`p-0`,children:r.loading?(0,$.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,$.jsx)(ir,{className:`h-3.5 w-4/5`}),(0,$.jsx)(ir,{className:`h-3.5 w-3/5`}),(0,$.jsx)(ir,{className:`h-3.5 w-2/3`})]}):r.items.length===0?(0,$.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:s(`detail.noRecords`)}):(0,$.jsx)(`ul`,{className:`divide-y`,children:r.items.map(t=>{let r=t.id||t._id,i=bo(t,e.displayField),a=r?`../${e.objectName}/record/${encodeURIComponent(String(r))}`:void 0;return(0,$.jsx)(`li`,{className:`px-4 py-2`,children:a?(0,$.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,$.jsx)(`span`,{className:`truncate`,children:i}),(0,$.jsx)(Cn,{className:`h-3 w-3 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`})]}):(0,$.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:i})},String(r||i))})})})]},t)}),!x&&E.length>0&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>S(!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:E.join(` · `),children:[(0,$.jsx)(`span`,{children:s(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:E.length})}),(0,$.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,E.join(` · `),`)`]})]})]})},So={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:`CheckCircle2`}};function Co(e){let t=e?.properties??{};return{...e,...t}}var wo=({schema:e={},className:t})=>{let n=Co(e),r=B(),i=r?.data,a=r?.objectName||``,o=r?.recordId??i?.id,{language:s}=h(),c=_(n.title,s),l=_(n.body,s),u=_(n.action?.label,s),d=[`info`,`warning`,`error`,`success`].includes(n.severity)?n.severity:`info`,f=So[d],p=n.icon||f.icon,m=H(n.visible),g=N(m,{record:i}),v=Q.useMemo(()=>{if(!n.dismissible)return null;let e=n.dismissKey||_(n.title,`en`)||d;return`os.record-alert:${a}:${o??`_`}:${e}`},[n.dismissible,n.dismissKey,n.title,d,a,o]),[y,b]=Q.useState(()=>{if(!v||typeof window>`u`)return!1;try{return window.localStorage.getItem(v)===`1`}catch{return!1}}),x=n.action?.actionName,{item:S}=V(`object`,x&&a?a:null),C=Q.useMemo(()=>{if(!(!x||!S?.actions))return S.actions.find(e=>e.name===x)},[x,S]),w=Q.useMemo(()=>C?[C]:[],[C]),{executeAction:T}=F({actions:w,context:{record:i,recordId:o,objectName:a}});return y||!i||Object.keys(i).length===0||m!==void 0&&!g?null:(0,$.jsxs)(je,{className:Z(`relative pr-12`,f.wrap,t),role:d===`error`?`alert`:`status`,"aria-live":d===`error`?`assertive`:`polite`,children:[(0,$.jsx)(xt,{name:p,className:`h-4 w-4`,"aria-hidden":`true`}),c?(0,$.jsx)(Ze,{children:c}):null,l||C?(0,$.jsxs)(Wt,{children:[l?(0,$.jsx)(`p`,{className:`mb-2 last:mb-0`,children:l}):null,C?(0,$.jsx)(X,{size:`sm`,variant:n.action?.variant||(d===`error`?`destructive`:`default`),onClick:()=>{C?.name&&T(C.name)},children:u||C.label||C.name}):null]}):null,n.dismissible?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(b(!0),v)try{window.localStorage.setItem(v,`1`)}catch{}},"aria-label":`Dismiss`,className:`absolute right-3 top-3 inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/80 hover:bg-foreground/5 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,children:(0,$.jsx)(xt,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},To=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)}},Eo=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()}},Do=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:a=!1})=>{let{t:o}=mi(),s=t?.label||t?.field||``,c=t?To(t.pendingValue):``,l=t?To(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=Eo(u.updated_at??t?.currentVersion),[p,m]=o(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,$.jsx)(Rt,{open:e,onOpenChange:e=>{!e&&!a&&i()},children:(0,$.jsxs)(st,{className:`max-w-lg`,children:[(0,$.jsx)(nn,{children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`inline-flex h-9 w-9 flex-none items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`,"aria-hidden":`true`,children:(0,$.jsx)(kt,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(tn,{children:o(`detail.concurrentUpdateTitle`)}),(0,$.jsxs)(qn,{className:`mt-1`,children:[p,(0,$.jsx)(`strong`,{className:`font-semibold`,children:s}),m]})]})]})}),(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,$.jsxs)(`div`,{className:`rounded-md border border-amber-200/70 bg-amber-50/60 p-3 dark:border-amber-500/30 dark:bg-amber-500/10`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-amber-800 dark:text-amber-300`,children:o(`detail.concurrentUpdateYourEdit`)}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:c})]}),(0,$.jsxs)(`div`,{className:`rounded-md border border-sky-200/70 bg-sky-50/60 p-3 dark:border-sky-500/30 dark:bg-sky-500/10`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-sky-800 dark:text-sky-300`,children:o(`detail.concurrentUpdateCurrentValue`)}),(d||f)&&(0,$.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[d&&(0,$.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedBy`,{name:d})}),d&&f&&(0,$.jsx)(`span`,{children:` · `}),f&&(0,$.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedAt`,{when:f})})]})]}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:l})]})]}),(0,$.jsxs)(at,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:Z(we({variant:`ghost`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateCancel`)}),(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:r,className:Z(we({variant:`outline`}),`mt-2 sm:mt-0 text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),children:o(`detail.concurrentUpdateOverwrite`)}),(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:n,autoFocus:!0,className:Z(we({variant:`default`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateReload`)})]})]})})};function Oo(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}function ko(e){let t=e?.message||e?.error||String(e??`Save failed`);return String(t).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``)}async function Ao(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 jo=({dataSource:e,objectName:t,recordId:n,data:r,refresh:i,fieldLabelFor:a,onFieldSave:o,locked:s=!1,lockedHint:c,className:l})=>{let{t:u}=mi(),d=se(),[f,p]=Q.useState(null),[m,h]=Q.useState(!1),g=!!e&&!!t&&n!=null,_=Q.useCallback((e,t)=>{let n=Object.keys(e),r=t?.currentRecord??null;if(n.length===1){let i=n[0];return{field:i,label:a?.(i),pendingValue:e[i],currentValue:r?r[i]:void 0,currentVersion:t?.currentVersion,currentRecord:r}}let i=r?Object.fromEntries(n.map(e=>[e,r[e]])):void 0;return{field:n.join(`, `),label:u(`detail.concurrentUpdateRecordLabel`,{defaultValue:`this record`}),pendingValue:e,currentValue:i,currentVersion:t?.currentVersion,currentRecord:r}},[a,u]),v=Q.useCallback(async()=>{if(!d)return;let a=d.draft,s=Object.entries(a);if(s.length===0){d.reset();return}d.setSaving(!0),d.setError(null);try{if(o)for(let[e,t]of s)await o(e,t);else if(g){let o=typeof r?.updated_at==`string`?r.updated_at:void 0;await Ao(e,t,n,a,o?{ifMatch:o}:void 0),await i?.()}d.reset()}catch(e){Oo(e)&&g?p(_(a,e)):d.setError(ko(e))}finally{d.setSaving(!1)}},[d,o,g,r,e,t,n,i,_]),y=Q.useCallback(()=>{p(null),h(!1)},[]),b=Q.useCallback(async()=>{h(!0);try{await i?.()}finally{d?.reset(),y()}},[i,d,y]),x=Q.useCallback(async()=>{if(!f||!g){y();return}h(!0);try{await Ao(e,t,n,d?.draft??{},f.currentVersion?{ifMatch:f.currentVersion}:void 0),await i?.(),d?.reset()}catch(e){d?.setError(ko(e))}finally{y()}},[f,g,d,e,t,n,i,y]),S=!!d?.editing,C=!!d?.saving,w=d?.cancel,T=!!f;return Q.useEffect(()=>{if(!S)return;let e=e=>{if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){if(C||s||T)return;e.preventDefault(),v();return}if(e.key===`Escape`){if(e.defaultPrevented||C||T||document.querySelector(`[data-radix-popper-content-wrapper], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`))return;e.preventDefault(),w?.()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,C,s,T,v,w]),!d||!d.editing?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:Z(`sticky bottom-0 z-30 mt-4 flex flex-wrap items-center justify-end gap-2 rounded-md border bg-background/95 px-3 py-2 shadow-sm backdrop-blur supports-[backdrop-filter]:bg-background/80`,l),role:`region`,"aria-label":u(`detail.editFieldsInline`),children:[d.error&&(0,$.jsx)(`div`,{role:`alert`,className:`mr-auto max-w-md rounded-md border border-destructive/20 bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:d.error}),(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:d.cancel,disabled:d.saving,className:`gap-2`,children:[(0,$.jsx)(un,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:u(`detail.cancel`)})]}),(0,$.jsxs)(X,{variant:`default`,size:`sm`,onClick:v,disabled:d.saving||s,className:`gap-2`,title:s?c:void 0,children:[d.saving?(0,$.jsx)(dr,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(pr,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:d.saving?u(`detail.saving`):u(`detail.save`)})]})]}),(0,$.jsx)(Do,{open:!!f,conflict:f,busy:m,onCancel:y,onReload:b,onOverwrite:x})]})},Mo=new Set(fe),No=480,Po=95;function Fo({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=Mo,onFieldSave:d,onDelete:f,resizable:p=!0,fullPageHref:m}){let{t:h}=mi(),g=`objectui.drawerWidth.${i}`,[_,v]=Q.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>=No)return t}}catch{}return null}),y=Q.useMemo(()=>p&&_!=null?`${_}px`:typeof c==`number`?`${c}px`:c,[p,_,c]),b=y?{width:y,maxWidth:y}:void 0,x=Q.useRef(null),S=Q.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*Po/100:1600,i=Math.min(r,Math.max(No,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=t.type===`lookup`||t.type===`master_detail`||t.type===`reference`;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_to??t.reference??t.referenceTo??t.target,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}});return(0,$.jsx)(fn,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(ur,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:b,onOpenAutoFocus:e=>e.preventDefault(),children:[p&&(0,$.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,$.jsx)(G,{className:`sr-only`,children:(0,$.jsx)(or,{children:n})}),(0,$.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,$.jsxs)(ce,{canEdit:!!d,children:[(0,$.jsx)(ha,{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,$.jsx)(jo,{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 Io(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 Lo(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]}p();function Ro(e){return e==null?[]:Array.isArray(e)?e.filter(e=>e!=null):[e]}function zo(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 Bo(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 Vo(e){if(!e)return null;let t=e.fields||{};for(let n of[e.primaryField,e.nameField,e.displayNameField])if(typeof n==`string`&&n.length>0&&n in t)return n;for(let e of[`name`,`full_name`,`title`,`subject`,`display_name`])if(e in t)return e;return null}function Ho(e,t,n=4){if(!e)return[];let r=Array.isArray(e.highlightFields)&&e.highlightFields.length>0?e.highlightFields:null;if(r){let t=Vo(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),e.primaryField&&i.add(e.primaryField),e.nameField&&i.add(e.nameField),e.displayNameField&&i.add(e.displayNameField);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`,`owner`,`select`,`enum`,`multiselect`,`status`,`email`,`phone`,`url`,`text`,`string`]),s=[],c=e.fields||{};for(let e of a)if(e in c&&!i.has(e)&&s.push(e),s.length>=n)return s;for(let e of Object.keys(c)){if(s.includes(e)||i.has(e))continue;let t=c[e]?.type;if(!(t&&!o.has(t))&&(s.push(e),s.length>=n))break}return s}function Uo(e,t={}){return zo(`page:header`,{recordChrome:t.recordChrome!==!1,...Array.isArray(t.actions)&&t.actions.length>0?{actions:t.actions}:{}})}function Wo(e,t={}){let n=t.statusField??ve(e),r=t.stages??(n?Bo(e,n):null),i=t.highlightFields??Ho(e,n),a=[];return!t.hideHighlights&&i.length>0&&a.push(zo(`record:highlights`,{fields:i})),!t.hidePath&&n&&r&&r.length>0&&a.push(zo(`record:path`,{statusField:n,stages:r})),a}function Go(e){if(!e)return null;let t=d(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_to||t.reference?{reference_to:t.reference_to||t.reference}:{},...t.reference_field?{reference_field:t.reference_field}:{},...t.currency?{currency:t.currency}:{},...t.currencyConfig?{currencyConfig:t.currencyConfig}:{}}},i=di(t.reduce((e,t)=>e+t.fields.length,0));return t.map(e=>({...e.key===void 0?{}:{name:e.key,title: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 Ko(e,t){return Array.isArray(t)&&t.length>0?t:Go(e)??void 0}function qo(e,t,n){return zo(`record:details`,{sections:Ko(e,t),...n&&n.length>0?{hideFields:n}:{}})}function Jo(e,t={}){let n=t.statusField??ve(e),r=t.highlightFields??Ho(e,n),i=[{label:`Details`,value:`details`,children:[qo(e,t.sections,r)]}];if(!t.hideRelatedTab&&Array.isArray(t.related)&&t.related.length>0){let e=e=>zo(`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}:{}}),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:[zo(`record:approvals`,{...t.approvals.node||{}})]}),e?.enable?.files===!0&&!t.hideAttachments&&i.push({label:`Attachments`,value:`attachments`,children:[Xo()]}),t.showActivity&&i.push({label:`Activity`,value:`activity`,children:[zo(`record:activity`)]}),t.history&&i.push({label:`History`,value:`history`,children:[zo(`record:history`,{entries:t.history.entries,loading:t.history.loading,emptyText:t.history.emptyText,unknownUserText:t.history.unknownUserText})]}),zo(`page:tabs`,{items:i})}function Yo(){return zo(`record:discussion`)}function Xo(){return zo(`record:attachments`)}function Zo(e,t={}){let n=t.slots||{},r=[];`header`in n&&n.header!==void 0?r.push(...Ro(n.header)):r.push(Uo(e,{recordChrome:t.recordChrome,actions:t.headerActions})),`actions`in n&&n.actions!==void 0&&r.push(...Ro(n.actions)),`alerts`in n&&n.alerts!==void 0&&r.push(...Ro(n.alerts)),`highlights`in n&&n.highlights!==void 0?r.push(...Ro(n.highlights)):r.push(...Wo(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(...Ro(n.tabs));else if(`details`in n&&n.details!==void 0){let i=Ro(n.details),o=Jo(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(Jo(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(...Ro(n.discussion)):t.hideDiscussion||r.push(Yo());let o=[{name:`main`,width:`full`,components:r}],s=Ro(n.rightRail);if(i||s.length>0){let e=[];i&&e.push(zo(`record:reference_rail`,{entries:t.related.map(e=>({objectName:e.objectName,relationshipField:e.relationshipField,title:e.title,icon:e.icon,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 Qo=t({DetailSection:()=>Ni,DetailView:()=>ha,RecordActivityRenderer:()=>ao,RecordAlertRenderer:()=>wo,RecordChatterRenderer:()=>co,RecordDetailsRenderer:()=>va,RecordHighlightsRenderer:()=>Oa,RecordHistoryRenderer:()=>_o,RecordPathRenderer:()=>uo,RecordQuickActionsRenderer:()=>po,RecordReferenceRailRenderer:()=>xo,RecordRelatedListRenderer:()=>Ea,RelatedList:()=>zi,buildDefaultPageSchema:()=>Zo});C.register(`detail-view`,ha,{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:[]}}),C.register(`detail-section`,Ni,{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`}]}),C.register(`related-list`,zi,{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`}]}),C.register(`detail`,ha,{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`}]}),C.register(`details`,va,{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."}]}),C.register(`related_list`,Ea,{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).'}]}),C.register(`highlights`,Oa,{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`}]}),C.register(`activity`,ao,{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 $o=[{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`}];C.register(`chatter`,co,{namespace:`record`,skipFallback:!0,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`,inputs:$o}),C.register(`discussion`,co,{namespace:`record`,skipFallback:!0,category:`record`,label:`Discussion`,icon:`MessageSquare`,inputs:$o}),C.register(`path`,uo,{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)`}]}),C.register(`quick_actions`,po,{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:[...u],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`}]}),C.register(`history`,_o,{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`}]}),C.register(`reference_rail`,xo,{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`}]}),C.register(`alert`,wo,{namespace:`record`,skipFallback:!0,category:`record`,label:`Alert Banner`,icon:`AlertTriangle`,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`}]}),C.register(`permission-facet-link`,rn(_i),{namespace:`field`,skipFallback:!0});export{Lo as a,jo as c,Zr as d,Vo as i,oo as l,Zo as n,Fo as o,Go as r,Io as s,Qo as t,da as u};
|