@object-ui/console 3.0.2 → 3.1.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/README.md +1 -1
- package/dist/assets/AdvancedChartImpl-Q6xhwCd2.js +7 -0
- package/dist/assets/AdvancedChartImpl-Q6xhwCd2.js.br +0 -0
- package/dist/assets/AdvancedChartImpl-Q6xhwCd2.js.gz +0 -0
- package/dist/assets/AppManagementPage-Bqi2RIF_.js +1 -0
- package/dist/assets/AppManagementPage-Bqi2RIF_.js.br +0 -0
- package/dist/assets/AppManagementPage-Bqi2RIF_.js.gz +0 -0
- package/dist/assets/AuditLogPage-Bhvo34U0.js +1 -0
- package/dist/assets/AuditLogPage-Bhvo34U0.js.br +0 -0
- package/dist/assets/AuditLogPage-Bhvo34U0.js.gz +0 -0
- package/dist/assets/{ChartImpl-2ivTljUi.js → ChartImpl-SceZDRuZ.js} +1 -1
- package/dist/assets/ChartImpl-SceZDRuZ.js.br +0 -0
- package/dist/assets/ChartImpl-SceZDRuZ.js.gz +0 -0
- package/dist/assets/CreateAppPage-BBV1-x1E.js +1 -0
- package/dist/assets/CreateAppPage-BBV1-x1E.js.br +0 -0
- package/dist/assets/CreateAppPage-BBV1-x1E.js.gz +0 -0
- package/dist/assets/DashboardDesignPage-Dsve6QAo.js +1 -0
- package/dist/assets/DashboardDesignPage-Dsve6QAo.js.br +0 -0
- package/dist/assets/DashboardDesignPage-Dsve6QAo.js.gz +0 -0
- package/dist/assets/DashboardView-DxpkEpzI.js +1 -0
- package/dist/assets/DashboardView-DxpkEpzI.js.br +0 -0
- package/dist/assets/DashboardView-DxpkEpzI.js.gz +0 -0
- package/dist/assets/EditAppPage-4REKKtym.js +1 -0
- package/dist/assets/EditAppPage-4REKKtym.js.br +0 -0
- package/dist/assets/EditAppPage-4REKKtym.js.gz +0 -0
- package/dist/assets/{ForgotPasswordPage-DUfjj-wh.js → ForgotPasswordPage-_rDOa2Zl.js} +1 -1
- package/dist/assets/KanbanEnhanced-Cy_rTBDD.js +1 -0
- package/dist/assets/KanbanEnhanced-Cy_rTBDD.js.br +0 -0
- package/dist/assets/KanbanEnhanced-Cy_rTBDD.js.gz +0 -0
- package/dist/assets/KanbanImpl-BNUeFn31.js +1 -0
- package/dist/assets/KanbanImpl-BNUeFn31.js.br +0 -0
- package/dist/assets/KanbanImpl-BNUeFn31.js.gz +0 -0
- package/dist/assets/{LoginPage-2CoFvwsL.js → LoginPage-BXP5VJhw.js} +1 -1
- package/dist/assets/{MarkdownImpl-BshtTFK2.js → MarkdownImpl-DQVBgcsA.js} +2 -2
- package/dist/assets/MarkdownImpl-DQVBgcsA.js.br +0 -0
- package/dist/assets/MarkdownImpl-DQVBgcsA.js.gz +0 -0
- package/dist/assets/OrgManagementPage-9aUMu-3n.js +1 -0
- package/dist/assets/OrgManagementPage-9aUMu-3n.js.br +0 -0
- package/dist/assets/OrgManagementPage-9aUMu-3n.js.gz +0 -0
- package/dist/assets/PageDesignPage-bfUbiZI-.js +1 -0
- package/dist/assets/PageDesignPage-bfUbiZI-.js.br +0 -0
- package/dist/assets/PageDesignPage-bfUbiZI-.js.gz +0 -0
- package/dist/assets/PageView-BNyUOHBp.js +2 -0
- package/dist/assets/PageView-BNyUOHBp.js.br +0 -0
- package/dist/assets/PageView-BNyUOHBp.js.gz +0 -0
- package/dist/assets/PermissionManagementPage-CfKXMrSe.js +1 -0
- package/dist/assets/PermissionManagementPage-CfKXMrSe.js.br +0 -0
- package/dist/assets/PermissionManagementPage-CfKXMrSe.js.gz +0 -0
- package/dist/assets/ProfilePage-aGYrzo6-.js +1 -0
- package/dist/assets/ProfilePage-aGYrzo6-.js.br +0 -0
- package/dist/assets/ProfilePage-aGYrzo6-.js.gz +0 -0
- package/dist/assets/RecordDetailView-Cbo06TgT.js +1 -0
- package/dist/assets/RecordDetailView-Cbo06TgT.js.br +0 -0
- package/dist/assets/RecordDetailView-Cbo06TgT.js.gz +0 -0
- package/dist/assets/RegisterPage-By5Xlwoy.js +1 -0
- package/dist/assets/ReportView-DYDYKXxz.js +1 -0
- package/dist/assets/ReportView-DYDYKXxz.js.br +0 -0
- package/dist/assets/ReportView-DYDYKXxz.js.gz +0 -0
- package/dist/assets/RoleManagementPage-DvuObd50.js +1 -0
- package/dist/assets/RoleManagementPage-DvuObd50.js.br +0 -0
- package/dist/assets/RoleManagementPage-DvuObd50.js.gz +0 -0
- package/dist/assets/SearchResultsPage-BXv9faGO.js +1 -0
- package/dist/assets/SearchResultsPage-BXv9faGO.js.br +0 -0
- package/dist/assets/SearchResultsPage-BXv9faGO.js.gz +0 -0
- package/dist/assets/SystemHubPage-DInbGUIC.js +1 -0
- package/dist/assets/SystemHubPage-DInbGUIC.js.br +0 -0
- package/dist/assets/SystemHubPage-DInbGUIC.js.gz +0 -0
- package/dist/assets/UserManagementPage-DfN7rtzx.js +1 -0
- package/dist/assets/UserManagementPage-DfN7rtzx.js.br +0 -0
- package/dist/assets/UserManagementPage-DfN7rtzx.js.gz +0 -0
- package/dist/assets/data-adapter-Cnk_Mp2r.js +1 -0
- package/dist/assets/data-adapter-Cnk_Mp2r.js.br +0 -0
- package/dist/assets/data-adapter-Cnk_Mp2r.js.gz +0 -0
- package/dist/assets/framework-0M39ZRTM.js +10 -0
- package/dist/assets/framework-0M39ZRTM.js.br +0 -0
- package/dist/assets/framework-0M39ZRTM.js.gz +0 -0
- package/dist/assets/index-B5fEfHjB.css +1 -0
- package/dist/assets/index-B5fEfHjB.css.br +0 -0
- package/dist/assets/index-B5fEfHjB.css.gz +0 -0
- package/dist/assets/index-BlrxLcAr.js +1 -0
- package/dist/assets/index-BlrxLcAr.js.br +0 -0
- package/dist/assets/index-BlrxLcAr.js.gz +0 -0
- package/dist/assets/index-o38_J709.js +9 -0
- package/dist/assets/index-o38_J709.js.br +0 -0
- package/dist/assets/index-o38_J709.js.gz +0 -0
- package/dist/assets/infrastructure-CShH4S9_.js +1 -0
- package/dist/assets/infrastructure-CShH4S9_.js.br +0 -0
- package/dist/assets/infrastructure-CShH4S9_.js.gz +0 -0
- package/dist/assets/maplibre-gl-Hx2FX3ON.js +811 -0
- package/dist/assets/maplibre-gl-Hx2FX3ON.js.br +0 -0
- package/dist/assets/maplibre-gl-Hx2FX3ON.js.gz +0 -0
- package/dist/assets/plugins-core-DBl14Uqc.js +8 -0
- package/dist/assets/plugins-core-DBl14Uqc.js.br +0 -0
- package/dist/assets/plugins-core-DBl14Uqc.js.gz +0 -0
- package/dist/assets/plugins-views-g4Cu3W3w.js +62 -0
- package/dist/assets/plugins-views-g4Cu3W3w.js.br +0 -0
- package/dist/assets/plugins-views-g4Cu3W3w.js.gz +0 -0
- package/dist/assets/ui-components-BuNW5g1I.js +36 -0
- package/dist/assets/ui-components-BuNW5g1I.js.br +0 -0
- package/dist/assets/ui-components-BuNW5g1I.js.gz +0 -0
- package/dist/assets/ui-components-D5YXsttd.css +1 -0
- package/dist/assets/ui-components-D5YXsttd.css.br +0 -0
- package/dist/assets/ui-components-D5YXsttd.css.gz +0 -0
- package/dist/assets/ui-layout-BSKYz8QD.js +1 -0
- package/dist/assets/ui-layout-BSKYz8QD.js.br +0 -0
- package/dist/assets/ui-layout-BSKYz8QD.js.gz +0 -0
- package/dist/assets/{vendor-charts-CSvoW-yB.js → vendor-charts-BbkZFaMp.js} +2 -2
- package/dist/assets/vendor-charts-BbkZFaMp.js.br +0 -0
- package/dist/assets/vendor-charts-BbkZFaMp.js.gz +0 -0
- package/dist/assets/vendor-dndkit-D1_B-HIy.js +5 -0
- package/dist/assets/vendor-dndkit-D1_B-HIy.js.br +0 -0
- package/dist/assets/vendor-dndkit-D1_B-HIy.js.gz +0 -0
- package/dist/assets/vendor-i18n-CikIh7Op.js +9 -0
- package/dist/assets/vendor-i18n-CikIh7Op.js.br +0 -0
- package/dist/assets/vendor-i18n-CikIh7Op.js.gz +0 -0
- package/dist/assets/{vendor-icons-CQ8b-fGy.js → vendor-icons-CsQ20zph.js} +3425 -3535
- package/dist/assets/vendor-icons-CsQ20zph.js.br +0 -0
- package/dist/assets/vendor-icons-CsQ20zph.js.gz +0 -0
- package/dist/assets/vendor-objectstack-aMKO1xRi.js +34 -0
- package/dist/assets/vendor-objectstack-aMKO1xRi.js.br +0 -0
- package/dist/assets/vendor-objectstack-aMKO1xRi.js.gz +0 -0
- package/dist/assets/{vendor-radix-BbeYj_o4.js → vendor-radix-CWYRmupg.js} +1 -1
- package/dist/assets/vendor-radix-CWYRmupg.js.br +0 -0
- package/dist/assets/vendor-radix-CWYRmupg.js.gz +0 -0
- package/dist/assets/vendor-react-BEJ2LWyF.js +60 -0
- package/dist/assets/vendor-react-BEJ2LWyF.js.br +0 -0
- package/dist/assets/vendor-react-BEJ2LWyF.js.gz +0 -0
- package/dist/assets/vendor-ui-utils-tMfURc0Z.js +1 -0
- package/dist/assets/vendor-ui-utils-tMfURc0Z.js.br +0 -0
- package/dist/assets/vendor-ui-utils-tMfURc0Z.js.gz +0 -0
- package/dist/assets/vendor-zod-DxQVy2_o.js +39 -0
- package/dist/assets/vendor-zod-DxQVy2_o.js.br +0 -0
- package/dist/assets/vendor-zod-DxQVy2_o.js.gz +0 -0
- package/dist/index.html +23 -22
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/stats.html +37 -36
- package/package.json +49 -46
- package/dist/assets/AdvancedChartImpl-DAS1mU9o.js +0 -7
- package/dist/assets/AdvancedChartImpl-DAS1mU9o.js.br +0 -0
- package/dist/assets/AdvancedChartImpl-DAS1mU9o.js.gz +0 -0
- package/dist/assets/AuditLogPage-CyY7VZJW.js +0 -1
- package/dist/assets/AuditLogPage-CyY7VZJW.js.br +0 -0
- package/dist/assets/AuditLogPage-CyY7VZJW.js.gz +0 -0
- package/dist/assets/ChartImpl-2ivTljUi.js.br +0 -0
- package/dist/assets/ChartImpl-2ivTljUi.js.gz +0 -0
- package/dist/assets/DashboardView-CikFb_lD.js +0 -1
- package/dist/assets/DashboardView-CikFb_lD.js.br +0 -0
- package/dist/assets/DashboardView-CikFb_lD.js.gz +0 -0
- package/dist/assets/KanbanEnhanced-CwlMhI0l.js +0 -1
- package/dist/assets/KanbanEnhanced-CwlMhI0l.js.br +0 -0
- package/dist/assets/KanbanEnhanced-CwlMhI0l.js.gz +0 -0
- package/dist/assets/KanbanImpl-BsMtStI7.js +0 -1
- package/dist/assets/KanbanImpl-BsMtStI7.js.br +0 -0
- package/dist/assets/KanbanImpl-BsMtStI7.js.gz +0 -0
- package/dist/assets/MarkdownImpl-BshtTFK2.js.br +0 -0
- package/dist/assets/MarkdownImpl-BshtTFK2.js.gz +0 -0
- package/dist/assets/OrgManagementPage-BJt5Iiun.js +0 -1
- package/dist/assets/OrgManagementPage-BJt5Iiun.js.br +0 -0
- package/dist/assets/OrgManagementPage-BJt5Iiun.js.gz +0 -0
- package/dist/assets/PageView-CQP2T84v.js +0 -1
- package/dist/assets/PageView-CQP2T84v.js.br +0 -0
- package/dist/assets/PageView-CQP2T84v.js.gz +0 -0
- package/dist/assets/ProfilePage-MVUfKMrp.js +0 -1
- package/dist/assets/ProfilePage-MVUfKMrp.js.br +0 -0
- package/dist/assets/ProfilePage-MVUfKMrp.js.gz +0 -0
- package/dist/assets/RecordDetailView-IO2ShB0a.js +0 -1
- package/dist/assets/RecordDetailView-IO2ShB0a.js.br +0 -0
- package/dist/assets/RecordDetailView-IO2ShB0a.js.gz +0 -0
- package/dist/assets/RegisterPage-B9itUVYp.js +0 -1
- package/dist/assets/ReportView-BfR7RjL9.js +0 -1
- package/dist/assets/ReportView-BfR7RjL9.js.br +0 -0
- package/dist/assets/ReportView-BfR7RjL9.js.gz +0 -0
- package/dist/assets/RoleManagementPage-BRqaeF_L.js +0 -1
- package/dist/assets/RoleManagementPage-BRqaeF_L.js.br +0 -0
- package/dist/assets/RoleManagementPage-BRqaeF_L.js.gz +0 -0
- package/dist/assets/SearchResultsPage-DaxRxhBY.js +0 -1
- package/dist/assets/SearchResultsPage-DaxRxhBY.js.br +0 -0
- package/dist/assets/SearchResultsPage-DaxRxhBY.js.gz +0 -0
- package/dist/assets/UserManagementPage-DOH6ql6-.js +0 -1
- package/dist/assets/UserManagementPage-DOH6ql6-.js.br +0 -0
- package/dist/assets/UserManagementPage-DOH6ql6-.js.gz +0 -0
- package/dist/assets/ViewDesignerPage-BbwrZa9D.js +0 -1
- package/dist/assets/ViewDesignerPage-BbwrZa9D.js.br +0 -0
- package/dist/assets/ViewDesignerPage-BbwrZa9D.js.gz +0 -0
- package/dist/assets/data-adapter-CIsDmDZ2.js +0 -1
- package/dist/assets/data-adapter-CIsDmDZ2.js.br +0 -0
- package/dist/assets/data-adapter-CIsDmDZ2.js.gz +0 -0
- package/dist/assets/framework-mHWN965c.js +0 -10
- package/dist/assets/framework-mHWN965c.js.br +0 -0
- package/dist/assets/framework-mHWN965c.js.gz +0 -0
- package/dist/assets/index-5NGcxsNI.js +0 -56
- package/dist/assets/index-5NGcxsNI.js.br +0 -0
- package/dist/assets/index-5NGcxsNI.js.gz +0 -0
- package/dist/assets/index-CUnVdETN.css +0 -1
- package/dist/assets/index-CUnVdETN.css.br +0 -0
- package/dist/assets/index-CUnVdETN.css.gz +0 -0
- package/dist/assets/infrastructure-Di0WqY4l.js +0 -1
- package/dist/assets/infrastructure-Di0WqY4l.js.br +0 -0
- package/dist/assets/infrastructure-Di0WqY4l.js.gz +0 -0
- package/dist/assets/maplibre-gl-D2AsLM0J.js +0 -811
- package/dist/assets/maplibre-gl-D2AsLM0J.js.br +0 -0
- package/dist/assets/maplibre-gl-D2AsLM0J.js.gz +0 -0
- package/dist/assets/plugins-core-HuzSJDPK.js +0 -4
- package/dist/assets/plugins-core-HuzSJDPK.js.br +0 -0
- package/dist/assets/plugins-core-HuzSJDPK.js.gz +0 -0
- package/dist/assets/plugins-views-JvEQp7xT.js +0 -60
- package/dist/assets/plugins-views-JvEQp7xT.js.br +0 -0
- package/dist/assets/plugins-views-JvEQp7xT.js.gz +0 -0
- package/dist/assets/ui-components-CseD2Dpn.js +0 -31
- package/dist/assets/ui-components-CseD2Dpn.js.br +0 -0
- package/dist/assets/ui-components-CseD2Dpn.js.gz +0 -0
- package/dist/assets/ui-components-GrNdJOi1.css +0 -1
- package/dist/assets/ui-components-GrNdJOi1.css.br +0 -0
- package/dist/assets/ui-components-GrNdJOi1.css.gz +0 -0
- package/dist/assets/ui-layout-CF_1bNSv.js +0 -1
- package/dist/assets/ui-layout-CF_1bNSv.js.br +0 -0
- package/dist/assets/ui-layout-CF_1bNSv.js.gz +0 -0
- package/dist/assets/vendor-charts-CSvoW-yB.js.br +0 -0
- package/dist/assets/vendor-charts-CSvoW-yB.js.gz +0 -0
- package/dist/assets/vendor-dndkit-DRGpK6sP.js +0 -5
- package/dist/assets/vendor-dndkit-DRGpK6sP.js.br +0 -0
- package/dist/assets/vendor-dndkit-DRGpK6sP.js.gz +0 -0
- package/dist/assets/vendor-i18n-D5KbMT7w.js +0 -9
- package/dist/assets/vendor-i18n-D5KbMT7w.js.br +0 -0
- package/dist/assets/vendor-i18n-D5KbMT7w.js.gz +0 -0
- package/dist/assets/vendor-icons-CQ8b-fGy.js.br +0 -0
- package/dist/assets/vendor-icons-CQ8b-fGy.js.gz +0 -0
- package/dist/assets/vendor-objectstack-BbgElG6O.js +0 -37
- package/dist/assets/vendor-objectstack-BbgElG6O.js.br +0 -0
- package/dist/assets/vendor-objectstack-BbgElG6O.js.gz +0 -0
- package/dist/assets/vendor-radix-BbeYj_o4.js.br +0 -0
- package/dist/assets/vendor-radix-BbeYj_o4.js.gz +0 -0
- package/dist/assets/vendor-react-Dy_xkBQQ.js +0 -60
- package/dist/assets/vendor-react-Dy_xkBQQ.js.br +0 -0
- package/dist/assets/vendor-react-Dy_xkBQQ.js.gz +0 -0
- package/dist/assets/vendor-ui-utils-h6yAcIi9.js +0 -1
- package/dist/assets/vendor-ui-utils-h6yAcIi9.js.br +0 -0
- package/dist/assets/vendor-ui-utils-h6yAcIi9.js.gz +0 -0
- package/dist/assets/vendor-zod-Dpl-cylz.js +0 -39
- package/dist/assets/vendor-zod-Dpl-cylz.js.br +0 -0
- package/dist/assets/vendor-zod-Dpl-cylz.js.gz +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{r as l,j as t,B as _e,c as Cn}from"./vendor-react-BEJ2LWyF.js";import{c as Z,b as Ge,m as Ye,T as Yt,a as Jt,d as Qt,e as Sn,B as ne,R as Fn,f as xs,g as kn,S as On,h as Dn,i as En,j as Tn,k as In,D as Xt,M as An,l as Zt,n as es,o as ts,p as hs,q as Vn,r as Rn,C as pt,s as mt,t as Ft,u as bt,v as Lt,w as Bs,x as Ks,y as Us,z as Dt,A as Ze,E as kt,F as zn,G as Ke,H as _t,I as Mn,N as xt,P as ss,J as ns,K as is,L as Ln,O as Ws,Q as _n,U as $n,V as Hs,W as Gs,X as Tt,Y as ht,Z as Ys,_ as gt,$ as jt,a0 as wt,a1 as vt,a2 as Nt,a3 as tt,a4 as Js,a5 as Qs,a6 as Xs,a7 as Zs,a8 as en,a9 as Pn,aa as He,ab as qn,ac as Bn,ad as Kn,ae as gs,af as ys,ag as js,ah as Un,ai as Wn,aj as Hn,ak as et,al as ws,am as Gn,an as Yn,ao as Jn}from"./ui-components-BuNW5g1I.js";import{S as Re,C as Te,c as Qn,f as Xn,d as Zn,g as ei,h as tn,i as sn}from"./framework-0M39ZRTM.js";import{a as dt}from"./vendor-ui-utils-tMfURc0Z.js";import{u as ti,a as vs,K as si,P as ni,b as ii,D as ri,c as li,S as ai,h as oi,d as di,C as ci}from"./vendor-dndkit-D1_B-HIy.js";import{a as rs,C as nn,d as rn,b as ui,L as fi,a1 as pi,z as mi,l as ls,a2 as Ns,a3 as bi,a4 as xi,a5 as hi,y as Cs,a6 as $t,a7 as gi,a8 as yi,a9 as ji,aa as wi,j as It,ab as Pt,ac as vi,c as Ss,g as Ni,X as ln,A as Ci,U as Si,h as an,_ as as,n as Fi,ad as At,m as os,i as ki,ae as Oi,af as Di,ag as Ei,ah as Ti,ai as on,aj as Ii,ak as Ai,al as Vi,am as Fs,an as Ri,ao as zi,ap as Gt,E as Mi,aq as qt,ar as Li,q as _i,as as $i,at as Pi,Q as ks,au as qi,G as Bi,av as Ki}from"./vendor-icons-CsQ20zph.js";import{a as st,u as Ui}from"./infrastructure-CShH4S9_.js";import{u as Wi}from"./plugins-views-g4Cu3W3w.js";const ct=({label:e,description:n,collapsible:s=!1,collapsed:i=!1,columns:r=1,children:d,className:a,gridClassName:o})=>{const[u,b]=l.useState(i),h={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"},c=()=>{s&&b(!u)};return t.jsxs("div",{className:Z("form-section",a),children:[(e||n)&&t.jsxs("div",{className:Z("flex items-start gap-2 mb-4",s&&"cursor-pointer select-none"),onClick:c,role:s?"button":void 0,"aria-expanded":s?!u:void 0,children:[s&&t.jsx("span",{className:"mt-0.5 text-muted-foreground",children:u?t.jsx(rs,{className:"h-4 w-4"}):t.jsx(nn,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex-1",children:[e&&t.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),n&&t.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:n})]})]}),!u&&t.jsx("div",{className:Z("grid gap-4",o||h[r]),children:d})]})},Hi=({schema:e,dataSource:n,className:s})=>{const{fieldLabel:i}=st(),[r,d]=l.useState(null),[a,o]=l.useState({}),[u,b]=l.useState(!0),[h,c]=l.useState(null),[x,y]=l.useState(e.defaultTab||e.sections[0]?.name||e.sections[0]?.label||"tab-0");_e.useEffect(()=>{(async()=>{if(!n){b(!1);return}try{const g=await n.getObjectSchema(e.objectName);d(g)}catch(g){c(g)}})()},[e.objectName,n]),_e.useEffect(()=>{(r||!n)&&(async()=>{if(e.mode==="create"||!e.recordId||!n){o(e.initialData||e.initialValues||{}),b(!1);return}try{const g=await n.findOne(e.objectName,e.recordId);o(g||{})}catch(g){c(g)}finally{b(!1)}})()},[r,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);const w=l.useCallback(D=>{const g=[];for(const p of D.fields){const N=typeof p=="string"?p:p.name;if(typeof p=="object")g.push(p);else if(r?.fields?.[N]){const T=r.fields[N];g.push({name:N,label:i(e.objectName,N,T.label||N),type:Ye(T.type),required:T.required||!1,disabled:e.readOnly||e.mode==="view"||T.readonly,placeholder:T.placeholder,description:T.help||T.description,validation:Ge(T),field:T,options:T.options,multiple:T.multiple})}else g.push({name:N,label:N,type:"input"})}return g},[r,e.readOnly,e.mode]),f=l.useCallback(async D=>{if(!n)return e.onSuccess&&await e.onSuccess(D),D;try{let g;return e.mode==="create"?g=await n.create(e.objectName,D):e.mode==="edit"&&e.recordId&&(g=await n.update(e.objectName,e.recordId,D)),e.onSuccess&&await e.onSuccess(g),g}catch(g){throw e.onError&&e.onError(g),g}},[e,n]),P=l.useCallback(()=>{e.onCancel&&e.onCancel()},[e]),A=(D,g)=>D.name||D.label||`tab-${g}`;if(h)return t.jsxs("div",{className:"p-4 border border-red-300 bg-red-50 rounded-md",children:[t.jsx("h3",{className:"text-red-800 font-semibold",children:"Error loading form"}),t.jsx("p",{className:"text-red-600 text-sm mt-1",children:h.message})]});if(u)return t.jsxs("div",{className:"p-8 text-center",children:[t.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"}),t.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading form..."})]});const H={type:"form",fields:e.sections.flatMap(D=>w(D)),layout:"vertical",defaultValues:a,submitLabel:e.submitText||(e.mode==="create"?"Create":"Update"),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!=="view",showCancel:e.showCancel!==!1,onSubmit:f,onCancel:P},Q=e.tabPosition==="left"||e.tabPosition==="right";return t.jsx("div",{className:Z("w-full",s,e.className),children:t.jsxs(Yt,{value:x,onValueChange:y,orientation:Q?"vertical":"horizontal",className:Z(Q&&"flex gap-4"),children:[t.jsx(Jt,{className:Z(Q?"flex-col h-auto":"",e.tabPosition==="bottom"&&"order-last",e.tabPosition==="right"&&"order-last"),children:e.sections.map((D,g)=>t.jsx(Qt,{value:A(D,g),className:Q?"w-full justify-start":"",children:D.label||`Tab ${g+1}`},A(D,g)))}),t.jsx("div",{className:"flex-1",children:e.sections.map((D,g)=>t.jsx(Sn,{value:A(D,g),className:"mt-0",children:t.jsx(ct,{description:D.description,columns:D.columns||1,children:t.jsx(Re,{schema:{...H,fields:w(D),showSubmit:e.showSubmit!==!1&&e.mode!=="view",showCancel:e.showCancel!==!1}})})},A(D,g)))})]})})},Gi=({schema:e,dataSource:n,className:s})=>{const{fieldLabel:i}=st(),[r,d]=l.useState(null),[a,o]=l.useState({}),[u,b]=l.useState(!0),[h,c]=l.useState(null),[x,y]=l.useState(0),[w,f]=l.useState(new Set),[P,A]=l.useState(!1),v=e.sections.length,H=x===0,Q=x===v-1;_e.useEffect(()=>{(async()=>{if(!n){b(!1);return}try{const V=await n.getObjectSchema(e.objectName);d(V)}catch(V){c(V)}})()},[e.objectName,n]),_e.useEffect(()=>{(r||!n)&&(async()=>{if(e.mode==="create"||!e.recordId||!n){o(e.initialData||e.initialValues||{}),b(!1);return}try{const V=await n.findOne(e.objectName,e.recordId);o(V||{})}catch(V){c(V)}finally{b(!1)}})()},[r,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);const D=l.useCallback(U=>{const V=[];for(const I of U.fields){const z=typeof I=="string"?I:I.name;if(typeof I=="object")V.push(I);else if(r?.fields?.[z]){const B=r.fields[z];V.push({name:z,label:i(e.objectName,z,B.label||z),type:Ye(B.type),required:B.required||!1,disabled:e.readOnly||e.mode==="view"||B.readonly,placeholder:B.placeholder,description:B.help||B.description,validation:Ge(B),field:B,options:B.options,multiple:B.multiple})}else V.push({name:z,label:z,type:"input"})}return V},[r,e.readOnly,e.mode]),g=l.useMemo(()=>x>=0&&x<v?D(e.sections[x]):[],[x,v,e.sections,D]),p=l.useCallback(async U=>{const V={...a,...U};if(o(V),f(I=>new Set(I).add(x)),Q){A(!0);try{if(!n)return e.onSuccess&&await e.onSuccess(V),V;let I;return e.mode==="create"?I=await n.create(e.objectName,V):e.mode==="edit"&&e.recordId&&(I=await n.update(e.objectName,e.recordId,V)),e.onSuccess&&await e.onSuccess(I),I}catch(I){throw e.onError&&e.onError(I),I}finally{A(!1)}}else N(x+1)},[a,x,Q,e,n]),N=l.useCallback(U=>{U>=0&&U<v&&(y(U),e.onStepChange&&e.onStepChange(U))},[v,e]),T=l.useCallback(()=>{N(x-1)},[x,N]),q=l.useCallback(()=>{e.onCancel&&e.onCancel()},[e]),K=l.useCallback(U=>{(e.allowSkip||w.has(U)||U<=x)&&N(U)},[e.allowSkip,w,x,N]);if(h)return t.jsxs("div",{className:"p-4 border border-red-300 bg-red-50 rounded-md",children:[t.jsx("h3",{className:"text-red-800 font-semibold",children:"Error loading form"}),t.jsx("p",{className:"text-red-600 text-sm mt-1",children:h.message})]});if(u)return t.jsxs("div",{className:"p-8 text-center",children:[t.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"}),t.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading form..."})]});const O=e.sections[x];return t.jsxs("div",{className:Z("w-full",s,e.className),children:[e.showStepIndicator!==!1&&t.jsx("nav",{"aria-label":"Progress",className:"mb-8",children:t.jsx("ol",{className:"flex items-center",children:e.sections.map((U,V)=>{const I=V===x,z=w.has(V),B=e.allowSkip||z||V<=x;return t.jsxs("li",{className:Z("relative flex-1",V!==v-1&&"pr-8 sm:pr-12"),children:[V!==v-1&&t.jsx("div",{className:"absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5","aria-hidden":"true",children:t.jsx("div",{className:Z("h-full",z?"bg-primary":"bg-muted")})}),t.jsxs("button",{type:"button",className:Z("group relative flex items-center",B?"cursor-pointer":"cursor-not-allowed"),onClick:()=>K(V),disabled:!B,children:[t.jsx("span",{className:Z("flex h-6 w-6 sm:h-8 sm:w-8 items-center justify-center rounded-full text-xs sm:text-sm font-medium transition-colors",z&&"bg-primary text-primary-foreground",I&&!z&&"border-2 border-primary bg-background text-primary",!I&&!z&&"border-2 border-muted bg-background text-muted-foreground"),children:z?t.jsx(rn,{className:"h-3 w-3 sm:h-4 sm:w-4"}):V+1}),t.jsx("span",{className:"ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",children:t.jsx("span",{className:Z(I?"text-foreground":"text-muted-foreground"),children:U.label||`Step ${V+1}`})})]})]},V)})})}),t.jsx("div",{className:"min-h-[200px]",children:O&&t.jsx(ct,{label:O.label,description:O.description,columns:O.columns||1,children:g.length>0?t.jsx(Re,{schema:{type:"form",fields:g,layout:"vertical",defaultValues:a,showSubmit:!1,showCancel:!1,onSubmit:p}}):t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No fields configured for this step"})})}),t.jsxs("div",{className:"flex items-center justify-between mt-6 pt-4 border-t",children:[t.jsx("div",{children:e.showCancel!==!1&&t.jsx(ne,{variant:"ghost",onClick:q,children:e.cancelText||"Cancel"})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm text-muted-foreground mr-2",children:["Step ",x+1," of ",v]}),!H&&t.jsxs(ne,{variant:"outline",onClick:T,children:[t.jsx(ui,{className:"h-4 w-4 mr-1"}),e.prevText||"Back"]}),Q?t.jsx(ne,{onClick:()=>p(a),disabled:P||e.mode==="view",children:P?"Submitting...":e.submitText||(e.mode==="create"?"Create":"Update")}):t.jsxs(ne,{onClick:()=>p(a),children:[e.nextText||"Next",t.jsx(rs,{className:"h-4 w-4 ml-1"})]})]})]})]})},Yi=({schema:e,dataSource:n,className:s})=>{const{fieldLabel:i}=st(),[r,d]=l.useState(null),[a,o]=l.useState({}),[u,b]=l.useState(!0),[h,c]=l.useState(null);l.useEffect(()=>{(async()=>{if(!n){b(!1);return}try{const g=await n.getObjectSchema(e.objectName);d(g)}catch(g){c(g),b(!1)}})()},[e.objectName,n]),l.useEffect(()=>{(r||!n)&&(async()=>{if(e.mode==="create"||!e.recordId){o(e.initialData||e.initialValues||{}),b(!1);return}if(!n){o(e.initialData||e.initialValues||{}),b(!1);return}try{const g=await n.findOne(e.objectName,e.recordId);o(g||{})}catch(g){c(g)}finally{b(!1)}})()},[r,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);const x=l.useCallback(D=>{const g=[];for(const p of D.fields){const N=typeof p=="string"?p:p.name;if(typeof p=="object")g.push(p);else if(r?.fields?.[N]){const T=r.fields[N];g.push({name:N,label:i(e.objectName,N,T.label||N),type:Ye(T.type),required:T.required||!1,disabled:e.readOnly||e.mode==="view"||T.readonly,placeholder:T.placeholder,description:T.help||T.description,validation:Ge(T),field:T,options:T.options,multiple:T.multiple})}else g.push({name:N,label:N,type:"input"})}return g},[r,e.readOnly,e.mode]),y=l.useCallback(async D=>{if(!n)return e.onSuccess&&await e.onSuccess(D),D;try{let g;return e.mode==="create"?g=await n.create(e.objectName,D):e.mode==="edit"&&e.recordId&&(g=await n.update(e.objectName,e.recordId,D)),e.onSuccess&&await e.onSuccess(g),g}catch(g){throw e.onError&&e.onError(g),g}},[e,n]),w=l.useCallback(()=>{e.onCancel&&e.onCancel()},[e]),f=l.useMemo(()=>e.sections.slice(0,1),[e.sections]),P=l.useMemo(()=>e.sections.slice(1),[e.sections]);l.useMemo(()=>e.sections.flatMap(D=>x(D)),[e.sections,x]);const A=e.splitDirection||"horizontal",v=e.splitSize||50;if(h)return t.jsxs("div",{className:"p-4 border border-red-300 bg-red-50 rounded-md",children:[t.jsx("h3",{className:"text-red-800 font-semibold",children:"Error loading form"}),t.jsx("p",{className:"text-red-600 text-sm mt-1",children:h.message})]});if(u)return t.jsxs("div",{className:"p-8 text-center",children:[t.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"}),t.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading form..."})]});const H={type:"form",layout:"vertical",defaultValues:a,onSubmit:y,onCancel:w},Q=(D,g)=>t.jsx("div",{className:"space-y-4 p-4",children:D.map((p,N)=>t.jsx(ct,{label:p.label,description:p.description,columns:p.columns||1,children:t.jsx(Re,{schema:{...H,fields:x(p),showSubmit:g&&e.showSubmit!==!1&&e.mode!=="view",showCancel:g&&e.showCancel!==!1,submitLabel:e.submitText||(e.mode==="create"?"Create":"Update"),cancelLabel:e.cancelText}})},p.name||p.label||N))});return t.jsx("div",{className:Z("w-full",s,e.className),children:t.jsxs(Fn,{orientation:A,className:"min-h-[300px] rounded-lg border",children:[t.jsx(xs,{defaultSize:v,minSize:20,children:Q(f,P.length===0)}),P.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(kn,{withHandle:e.splitResizable!==!1}),t.jsx(xs,{defaultSize:100-v,minSize:20,children:Q(P,!0)})]})]})})},Ji=new Set(["field:textarea","field:markdown","field:html","field:grid","field:rich-text","textarea","markdown","html","grid","rich-text"]),Qi=new Set(["formula","summary","auto_number","autonumber"]);function Xi(e){return Ji.has(e)}function Zi(e){return Qi.has(e)}function er(e){return e<=3?1:2}function Os(e,n){return n<=1?e:e.map(s=>s.colSpan!==void 0?s:s.type&&Xi(s.type)?{...s,colSpan:n}:s)}function tr(e,n){return n?.fields?e.filter(s=>{const i=n.fields[s.name];return i?!Zi(i.type):!0}):e}function Ds(e){return e<=1?"default":e===2?"lg":e===3?"xl":"full"}function Vt(e,n,s,i){let r=[...e];if(i==="create"&&(r=tr(r,n)),s!==void 0)return r=Os(r,s),{fields:r,columns:s};const d=er(r.length);return r=Os(r,d),{fields:r,columns:d}}const Es={1:void 0,2:"grid gap-4 grid-cols-1 @md:grid-cols-2",3:"grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",4:"grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"},sr=({schema:e,dataSource:n,className:s})=>{const{fieldLabel:i}=st(),[r,d]=l.useState(null),[a,o]=l.useState([]),[u,b]=l.useState({}),[h,c]=l.useState(!0),[x,y]=l.useState(null),w=e.open!==!1,f=e.drawerSide||"right";l.useEffect(()=>{(async()=>{if(!n){c(!1);return}try{const N=await n.getObjectSchema(e.objectName);d(N)}catch(N){y(N),c(!1)}})()},[e.objectName,n]),l.useEffect(()=>{(r||!n)&&(async()=>{if(e.mode==="create"||!e.recordId){b(e.initialData||e.initialValues||{}),c(!1);return}if(!n){b(e.initialData||e.initialValues||{}),c(!1);return}try{const N=await n.findOne(e.objectName,e.recordId);b(N||{})}catch(N){y(N)}finally{c(!1)}})()},[r,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);const P=l.useCallback(p=>{const N=[];for(const T of p.fields){const q=typeof T=="string"?T:T.name;if(typeof T=="object")N.push(T);else if(r?.fields?.[q]){const K=r.fields[q];N.push({name:q,label:i(e.objectName,q,K.label||q),type:Ye(K.type),required:K.required||!1,disabled:e.readOnly||e.mode==="view"||K.readonly,placeholder:K.placeholder,description:K.help||K.description,validation:Ge(K),field:K,options:K.options,multiple:K.multiple})}else N.push({name:q,label:q,type:"input"})}return N},[r,e.readOnly,e.mode]);l.useEffect(()=>{if(!r&&n)return;if(e.customFields?.length){o(e.customFields),c(!1);return}if(e.sections?.length){c(!1);return}if(!r)return;const p=e.fields||Object.keys(r.fields||{}),N=[];for(const T of p){const q=typeof T=="string"?T:T.name;if(!q)continue;const K=r.fields?.[q];K&&N.push({name:q,label:i(e.objectName,q,K.label||q),type:Ye(K.type),required:K.required||!1,disabled:e.readOnly||e.mode==="view"||K.readonly,placeholder:K.placeholder,description:K.help||K.description,validation:Ge(K),field:K,options:K.options,multiple:K.multiple})}o(N),c(!1)},[r,e.fields,e.customFields,e.sections,e.readOnly,e.mode,n]);const A=l.useCallback(async p=>{if(!n)return e.onSuccess&&await e.onSuccess(p),e.onOpenChange?.(!1),p;try{let N;return e.mode==="create"?N=await n.create(e.objectName,p):e.mode==="edit"&&e.recordId&&(N=await n.update(e.objectName,e.recordId,p)),e.onSuccess&&await e.onSuccess(N),e.onOpenChange?.(!1),N}catch(N){throw e.onError&&e.onError(N),N}},[e,n]),v=l.useCallback(()=>{e.onCancel&&e.onCancel(),e.onOpenChange?.(!1)},[e]),H=l.useMemo(()=>e.drawerWidth?f==="left"||f==="right"?{width:e.drawerWidth,maxWidth:e.drawerWidth}:{height:e.drawerWidth,maxHeight:e.drawerWidth}:void 0,[e.drawerWidth,f]),D={type:"form",layout:e.layout==="vertical"||e.layout==="horizontal"?e.layout:"vertical",defaultValues:u,submitLabel:e.submitText||(e.mode==="create"?"Create":"Update"),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!=="view",showCancel:e.showCancel!==!1,onSubmit:A,onCancel:v},g=()=>{if(x)return t.jsxs("div",{className:"p-4 border border-red-300 bg-red-50 rounded-md",children:[t.jsx("h3",{className:"text-red-800 font-semibold",children:"Error loading form"}),t.jsx("p",{className:"text-red-600 text-sm mt-1",children:x.message})]});if(h)return t.jsxs("div",{className:"p-8 text-center",children:[t.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"}),t.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading form..."})]});if(e.sections?.length)return t.jsx("div",{className:"space-y-6",children:e.sections.map((T,q)=>{const K=T.columns||1;return t.jsx(ct,{label:T.label,description:T.description,columns:K,gridClassName:Es[K],children:t.jsx(Re,{schema:{...D,fields:P(T),showSubmit:q===e.sections.length-1&&D.showSubmit,showCancel:q===e.sections.length-1&&D.showCancel}})},T.name||T.label||q)})});const p=Vt(a,r,e.columns,e.mode),N=Es[p.columns||1];return t.jsx(Re,{schema:{...D,fields:p.fields,columns:p.columns,...N?{fieldContainerClass:N}:{}}})};return t.jsx(On,{open:w,onOpenChange:e.onOpenChange,children:t.jsxs(Dn,{side:f,className:Z("overflow-y-auto",s,e.className),style:H,children:[(e.title||e.description)&&t.jsxs(En,{children:[e.title&&t.jsx(Tn,{children:e.title}),e.description&&t.jsx(In,{children:e.description})]}),t.jsx("div",{className:"@container py-4",children:g()})]})})},Ts={sm:"max-w-sm",default:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw] w-full"},Is={1:void 0,2:"grid gap-4 grid-cols-1 @md:grid-cols-2",3:"grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",4:"grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"},nr=({schema:e,dataSource:n,className:s})=>{const{fieldLabel:i}=st(),[r,d]=l.useState(null),[a,o]=l.useState([]),[u,b]=l.useState({}),[h,c]=l.useState(!0),[x,y]=l.useState(null),[w,f]=l.useState(!1),P=e.open!==!1,A=l.useId(),v=l.useMemo(()=>e.sections?.length||e.customFields?.length?null:Vt(a,r,e.columns,e.mode),[a,r,e.columns,e.mode,e.sections,e.customFields]),H=l.useMemo(()=>{if(e.modalSize)return e.modalSize;if(v?.columns&&v.columns>1)return Ds(v.columns);if(e.sections?.length){const z=Math.max(...e.sections.map(B=>Number(B.columns)||1));if(z>1)return Ds(z)}return"default"},[e.modalSize,v,e.sections]),Q=Ts[H]||Ts.default;l.useEffect(()=>{(async()=>{if(!n){c(!1);return}try{const B=await n.getObjectSchema(e.objectName);d(B)}catch(B){y(B),c(!1)}})()},[e.objectName,n]),l.useEffect(()=>{(r||!n)&&(async()=>{if(e.mode==="create"||!e.recordId){b(e.initialData||e.initialValues||{}),c(!1);return}if(!n){b(e.initialData||e.initialValues||{}),c(!1);return}try{const B=await n.findOne(e.objectName,e.recordId);b(B||{})}catch(B){y(B)}finally{c(!1)}})()},[r,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);const D=l.useCallback(z=>{const B=[];for(const W of z.fields){const se=typeof W=="string"?W:W.name;if(typeof W=="object")B.push(W);else if(r?.fields?.[se]){const ee=r.fields[se];B.push({name:se,label:i(e.objectName,se,ee.label||se),type:Ye(ee.type),required:ee.required||!1,disabled:e.readOnly||e.mode==="view"||ee.readonly,placeholder:ee.placeholder,description:ee.help||ee.description,validation:Ge(ee),field:ee,options:ee.options,multiple:ee.multiple})}else B.push({name:se,label:se,type:"input"})}return B},[r,e.readOnly,e.mode]);l.useEffect(()=>{if(!r&&n)return;if(e.customFields?.length){o(e.customFields),c(!1);return}if(e.sections?.length){c(!1);return}if(!r)return;const z=e.fields||Object.keys(r.fields||{}),B=[];for(const W of z){const se=typeof W=="string"?W:W.name;if(!se)continue;const ee=r.fields?.[se];ee&&B.push({name:se,label:i(e.objectName,se,ee.label||se),type:Ye(ee.type),required:ee.required||!1,disabled:e.readOnly||e.mode==="view"||ee.readonly,placeholder:ee.placeholder,description:ee.help||ee.description,validation:Ge(ee),field:ee,options:ee.options,multiple:ee.multiple})}o(B),c(!1)},[r,e.fields,e.customFields,e.sections,e.readOnly,e.mode,n]);const g=l.useCallback(async z=>{f(!0);try{if(!n)return e.onSuccess&&await e.onSuccess(z),e.onOpenChange?.(!1),z;let B;return e.mode==="create"?B=await n.create(e.objectName,z):e.mode==="edit"&&e.recordId&&(B=await n.update(e.objectName,e.recordId,z)),e.onSuccess&&await e.onSuccess(B),e.onOpenChange?.(!1),B}catch(B){throw e.onError&&e.onError(B),B}finally{f(!1)}},[e,n]),p=l.useCallback(()=>{e.onCancel&&e.onCancel(),e.onOpenChange?.(!1)},[e]),N=e.layout==="vertical"||e.layout==="horizontal"?e.layout:"vertical",T=e.showSubmit!==!1&&e.mode!=="view",q=e.showCancel!==!1,K=e.submitText||(e.mode==="create"?"Create":"Update"),O=e.cancelText||"Cancel",U={type:"form",layout:N,defaultValues:u,submitLabel:K,cancelLabel:O,showSubmit:T,showCancel:q,onSubmit:g,onCancel:p,showActions:!1,id:A},V=()=>{if(x)return t.jsxs("div",{className:"p-4 border border-red-300 bg-red-50 rounded-md",children:[t.jsx("h3",{className:"text-red-800 font-semibold",children:"Error loading form"}),t.jsx("p",{className:"text-red-600 text-sm mt-1",children:x.message})]});if(h)return t.jsx("div",{className:"space-y-4","data-testid":"modal-form-skeleton",children:[1,2,3].map(W=>t.jsxs("div",{className:"space-y-2",children:[t.jsx(hs,{className:"h-4 w-24"}),t.jsx(hs,{className:"h-10 w-full"})]},W))});if(e.sections?.length)return t.jsx("div",{className:"space-y-6",children:e.sections.map((W,se)=>{const ee=W.columns||1;return t.jsx(ct,{label:W.label,description:W.description,columns:ee,gridClassName:Is[ee],children:t.jsx(Re,{schema:{...U,fields:D(W)}})},W.name||W.label||se)})});const z=v??Vt(a,r,e.columns,e.mode),B=Is[z.columns||1];return t.jsx(Re,{schema:{...U,fields:z.fields,columns:z.columns,...B?{fieldContainerClass:B}:{}}})},I=!h&&!x&&(T||q);return t.jsx(Xt,{open:P,onOpenChange:e.onOpenChange,children:t.jsxs(An,{className:Z(Q,"flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0",s,e.className),children:[(e.title||e.description)&&t.jsxs(Zt,{className:"shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",children:[e.title&&t.jsx(es,{children:e.title}),e.description&&t.jsx(ts,{children:e.description})]}),t.jsx("div",{className:"@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",children:V()}),I&&t.jsx("div",{className:"shrink-0 border-t px-4 sm:px-6 py-3 bg-background","data-testid":"modal-form-footer",children:t.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:justify-end",children:[q&&t.jsx(ne,{type:"button",variant:"outline",onClick:p,disabled:w,className:"w-full sm:w-auto",children:O}),T&&t.jsxs(ne,{type:"submit",form:A,disabled:w,className:"w-full sm:w-auto",children:[w&&t.jsx(fi,{className:"mr-2 h-4 w-4 animate-spin"}),K]})]})})]})})},yt=({schema:e,dataSource:n})=>{if(e.formType==="tabbed"&&e.sections?.length)return t.jsx(Hi,{schema:{...e,formType:"tabbed",sections:e.sections.map(s=>({name:s.name,label:s.label,description:s.description,columns:s.columns,fields:s.fields})),defaultTab:e.defaultTab,tabPosition:e.tabPosition},dataSource:n,className:e.className});if(e.formType==="wizard"&&e.sections?.length)return t.jsx(Gi,{schema:{...e,formType:"wizard",sections:e.sections.map(s=>({name:s.name,label:s.label,description:s.description,columns:s.columns,fields:s.fields})),allowSkip:e.allowSkip,showStepIndicator:e.showStepIndicator,nextText:e.nextText,prevText:e.prevText,onStepChange:e.onStepChange},dataSource:n,className:e.className});if(e.formType==="split"&&e.sections?.length)return t.jsx(Yi,{schema:{...e,formType:"split",sections:e.sections.map(s=>({name:s.name,label:s.label,description:s.description,columns:s.columns,fields:s.fields})),splitDirection:e.splitDirection,splitSize:e.splitSize,splitResizable:e.splitResizable},dataSource:n,className:e.className});if(e.formType==="drawer"){const{layout:s,...i}=e,r=e.layout==="vertical"||e.layout==="horizontal"?e.layout:void 0;return t.jsx(sr,{schema:{...i,layout:r,formType:"drawer",sections:e.sections?.map(d=>({name:d.name,label:d.label,description:d.description,columns:d.columns,fields:d.fields})),open:e.open,onOpenChange:e.onOpenChange,drawerSide:e.drawerSide,drawerWidth:e.drawerWidth},dataSource:n,className:e.className})}if(e.formType==="modal"){const{layout:s,...i}=e,r=e.layout==="vertical"||e.layout==="horizontal"?e.layout:void 0;return t.jsx(nr,{schema:{...i,layout:r,formType:"modal",sections:e.sections?.map(d=>({name:d.name,label:d.label,description:d.description,columns:d.columns,fields:d.fields})),open:e.open,onOpenChange:e.onOpenChange,modalSize:e.modalSize,modalCloseButton:e.modalCloseButton},dataSource:n,className:e.className})}return t.jsx(ir,{schema:e,dataSource:n})},ir=({schema:e,dataSource:n})=>{const{fieldLabel:s}=st(),[i,r]=l.useState(null),[d,a]=l.useState([]),[o,u]=l.useState(null),[b,h]=l.useState(!0),[c,x]=l.useState(null),y=e.customFields&&e.customFields.length>0;l.useEffect(()=>{y&&(u(e.initialData||e.initialValues||{}),h(!1))},[y,e.initialData,e.initialValues]),l.useEffect(()=>{const g=async()=>{try{if(!n)throw new Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");const p=await n.getObjectSchema(e.objectName);if(!p)throw new Error(`No schema found for object "${e.objectName}"`);r(p)}catch(p){x(p),h(!1)}};y?r({name:e.objectName,fields:{}}):e.objectName&&n?g():y||h(!1)},[e.objectName,n,y]),l.useEffect(()=>{i&&!y&&(async()=>{if(!e.recordId||e.mode==="create"){u(e.initialData||e.initialValues||{}),h(!1);return}if(!y){if(!n){x(new Error("DataSource is required for fetching record data (inline data not provided)")),h(!1);return}h(!0);try{const p=await n.findOne(e.objectName,e.recordId);u(p)}catch(p){console.error("Failed to fetch record:",p),x(p)}finally{h(!1)}}})()},[e.objectName,e.recordId,e.mode,e.initialValues,e.initialData,n,i,y]),l.useEffect(()=>{if(y&&e.customFields){a(e.customFields),h(!1);return}if(!i)return;const g=[],p=e.fields||Object.keys(i.fields||{});(Array.isArray(p)?p:Object.keys(p)).forEach(q=>{const K=typeof q=="string"?q:q.name;if(!K)return;const O=i.fields?.[K];if(!O&&!y)return;const U=!O?.permissions||O?.permissions.write!==!1;if(e.mode!=="view"&&!U)return;const V=e.customFields?.find(I=>I.name===K);if(V)g.push(V);else if(O){const I={name:K,label:s(e.objectName,K,O.label||q),type:Ye(O.type),required:O.required||!1,disabled:e.readOnly||e.mode==="view"||O.readonly,placeholder:O.placeholder,description:O.help||O.description,validation:Ge(O),field:O};if((O.type==="select"||O.type==="lookup"||O.type==="master_detail")&&(I.options=O.options||[],I.multiple=O.multiple),(O.type==="number"||O.type==="currency"||O.type==="percent")&&(I.inputType="number",I.min=O.min,I.max=O.max,I.step=O.precision?Math.pow(10,-O.precision):void 0),O.type==="date"&&(I.inputType="date"),O.type==="datetime"&&(I.inputType="datetime-local"),(O.type==="text"||O.type==="textarea"||O.type==="markdown"||O.type==="html")&&(I.maxLength=O.max_length,I.minLength=O.min_length),(O.type==="file"||O.type==="image")&&(I.inputType="file",I.multiple=O.multiple,I.accept=O.accept?O.accept.join(","):void 0,O.max_size)){const z=`Max size: ${Vn(O.max_size)}`;I.description=I.description?`${I.description} (${z})`:z}O.type==="email"&&(I.inputType="email"),O.type==="phone"&&(I.inputType="tel"),O.type==="url"&&(I.inputType="url"),O.type==="password"&&(I.inputType="password"),O.type==="time"&&(I.inputType="time"),(O.type==="formula"||O.type==="summary"||O.type==="auto_number")&&(I.disabled=!0),O.visible_on&&(I.visible=z=>Rn(O.visible_on,z)),g.push(I)}}),a(g),!y&&e.recordId&&e.mode!=="create"&&n||h(!1)},[i,e.fields,e.customFields,e.readOnly,e.mode,y,e.recordId,n]);const w=l.useCallback(async(g,p)=>{if(g&&(g.nativeEvent||g._reactName==="onSubmit")&&(console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."),p===void 0&&(p=g,g={})),y&&!n)return e.onSuccess&&await e.onSuccess(g),g;if(!n)throw new Error("DataSource is required for form submission (inline mode not configured)");try{let N;if(e.mode==="create")N=await n.create(e.objectName,g);else if(e.mode==="edit"&&e.recordId)N=await n.update(e.objectName,e.recordId,g);else throw new Error("Invalid form mode or missing record ID");return e.onSuccess&&await e.onSuccess(N),N}catch(N){throw console.error("Failed to submit form:",N),e.onError&&e.onError(N),N}},[e,n,y]),f=l.useCallback(()=>{e.onCancel&&e.onCancel()},[e]),A={..._e.useMemo(()=>{if(!i?.fields)return{};const g={};return Object.keys(i.fields).forEach(p=>{const N=i.fields[p];N.defaultValue!==void 0&&(g[p]=N.defaultValue)}),g},[i]),...o};if(c)return t.jsxs("div",{className:"p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",children:[t.jsx("h3",{className:"text-red-800 font-semibold",children:"Error loading form"}),t.jsx("p",{className:"text-red-600 text-sm mt-1",children:c.message})]});if(b)return t.jsxs("div",{className:"p-4 sm:p-8 text-center",children:[t.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"}),t.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading form..."})]});const v=e.layout==="vertical"||e.layout==="horizontal"?e.layout:"vertical";if(e.sections?.length&&(!e.formType||e.formType==="simple"))return t.jsx("div",{className:"w-full space-y-6",children:e.sections.map((g,p)=>{const N=g.fields.map(q=>typeof q=="string"?q:q.name),T=d.filter(q=>N.includes(q.name));return t.jsx(ct,{label:g.label,description:g.description,collapsible:g.collapsible,collapsed:g.collapsed,columns:g.columns,children:t.jsx(Re,{schema:{type:"form",fields:T,layout:v,defaultValues:A,showSubmit:p===e.sections.length-1&&e.showSubmit!==!1&&e.mode!=="view",showCancel:p===e.sections.length-1&&e.showCancel!==!1,submitLabel:e.submitText||(e.mode==="create"?"Create":"Update"),cancelLabel:e.cancelText,onSubmit:w,onCancel:f}})},g.name||g.label||p)})});const Q=e.sections?.length?{fields:d,columns:e.columns}:Vt(d,i,e.columns,e.mode),D={type:"form",fields:Q.fields,layout:v,columns:Q.columns,submitLabel:e.submitText||(e.mode==="create"?"Create":"Update"),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!=="view",showCancel:e.showCancel!==!1,resetOnSubmit:e.showReset,defaultValues:A,onSubmit:w,onCancel:f,className:e.className};return t.jsx("div",{className:"w-full",children:t.jsx(Re,{schema:D})})},rr=({config:e,dataSource:n,prefillParams:s,className:i})=>{const[r,d]=l.useState(!1),[a,o]=l.useState(!1),[u,b]=l.useState(null),h=l.useMemo(()=>{const w={};if(s)for(const[f,P]of Object.entries(s))w[f]=P;return typeof window<"u"&&new URLSearchParams(window.location.search).forEach((P,A)=>{A in w||(w[A]=P)}),Object.keys(w).length>0?w:void 0},[s]),c=l.useCallback(async w=>{o(!0),b(null);try{if(n&&await n.create(e.objectName,w),d(!0),e.thankYouPage?.redirectUrl){const f=e.thankYouPage.redirectDelay??3e3;setTimeout(()=>{window.location.href=e.thankYouPage.redirectUrl},f)}}catch(f){b(f instanceof Error?f.message:"Failed to submit form. Please try again.")}finally{o(!1)}},[n,e]),x=l.useCallback(()=>{d(!1),b(null)},[]),y=l.useMemo(()=>{const w={};return e.branding?.backgroundColor&&(w.backgroundColor=e.branding.backgroundColor),w},[e.branding]);if(r){const w=e.thankYouPage;return t.jsx("div",{className:`min-h-screen flex items-center justify-center p-4 ${i||""}`,style:y,children:t.jsxs("div",{className:"max-w-md w-full bg-card rounded-lg shadow-lg p-8 text-center space-y-4",children:[t.jsx("div",{className:"text-4xl",children:"✓"}),t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:w?.title||"Thank You!"}),t.jsx("p",{className:"text-muted-foreground",children:w?.message||"Your submission has been received successfully."}),e.allowMultiple&&t.jsx("button",{onClick:x,className:"mt-4 px-4 py-2 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors",children:"Submit Another Response"}),w?.redirectUrl&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Redirecting in ",Math.ceil((w.redirectDelay??3e3)/1e3)," seconds..."]})]})})}return t.jsx("div",{className:`min-h-screen flex items-center justify-center p-4 ${i||""}`,style:y,children:t.jsxs("div",{className:"max-w-2xl w-full bg-card rounded-lg shadow-lg overflow-hidden",children:[t.jsxs("div",{className:"p-6 border-b",style:e.branding?.primaryColor?{borderBottomColor:e.branding.primaryColor}:void 0,children:[e.branding?.logo&&t.jsx("img",{src:e.branding.logo,alt:"Logo",className:"h-8 mb-4"}),e.title&&t.jsx("h1",{className:"text-xl font-semibold text-foreground",children:e.title}),e.description&&t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:e.description})]}),t.jsxs("div",{className:"p-6",children:[u&&t.jsx("div",{className:"mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",children:u}),t.jsx(yt,{schema:{type:"object-form",objectName:e.objectName,mode:"create",fields:e.fields,customFields:e.customFields,initialData:h,onSuccess:c,submitLabel:a?"Submitting...":"Submit"},dataSource:n})]}),t.jsx("div",{className:"px-6 py-3 border-t bg-muted/20 text-center",children:t.jsx("p",{className:"text-xs text-muted-foreground",children:"Powered by ObjectStack"})})]})})};function lr(e){return e<60?`${Math.round(e)}s`:e<3600?`${Math.floor(e/60)}m ${Math.round(e%60)}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}const ar=({formId:e,formTitle:n,metrics:s,className:i})=>{const r=l.useMemo(()=>{if(!s.abandonedSubmissions)return 100;const a=s.totalSubmissions+s.abandonedSubmissions;return a===0?0:Math.round(s.totalSubmissions/a*100)},[s.totalSubmissions,s.abandonedSubmissions]),d=l.useMemo(()=>s.dailySubmissions?.length?Math.max(...s.dailySubmissions.map(a=>a.count),1):1,[s.dailySubmissions]);return t.jsxs("div",{className:`space-y-4 ${i||""}`,children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground",children:n||"Form Analytics"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Form ID: ",e]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[t.jsx(pt,{children:t.jsxs(mt,{className:"pb-2",children:[t.jsx(Ft,{children:"Total Submissions"}),t.jsx(bt,{className:"text-2xl",children:s.totalSubmissions.toLocaleString()})]})}),t.jsxs(pt,{children:[t.jsxs(mt,{className:"pb-2",children:[t.jsx(Ft,{children:"Fill Rate"}),t.jsxs(bt,{className:"text-2xl",children:[r,"%"]})]}),t.jsx(Lt,{children:t.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:t.jsx("div",{className:"bg-primary rounded-full h-2 transition-all",style:{width:`${r}%`}})})})]}),t.jsx(pt,{children:t.jsxs(mt,{className:"pb-2",children:[t.jsx(Ft,{children:"Avg. Completion Time"}),t.jsx(bt,{className:"text-2xl",children:s.avgCompletionTime?lr(s.avgCompletionTime):"—"})]})})]}),s.dailySubmissions&&s.dailySubmissions.length>0&&t.jsxs(pt,{children:[t.jsx(mt,{children:t.jsx(bt,{className:"text-sm font-medium",children:"Daily Submissions"})}),t.jsx(Lt,{children:t.jsx("div",{className:"flex items-end gap-1 h-32",children:s.dailySubmissions.map((a,o)=>t.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1",children:[t.jsx("div",{className:"w-full bg-primary/80 rounded-t transition-all hover:bg-primary",style:{height:`${a.count/d*100}%`,minHeight:a.count>0?"4px":"0"},title:`${a.date}: ${a.count} submissions`}),t.jsx("span",{className:"text-[10px] text-muted-foreground truncate w-full text-center",children:a.date.slice(-5)})]},o))})})]}),s.fieldDropOff&&s.fieldDropOff.length>0&&t.jsxs(pt,{children:[t.jsxs(mt,{children:[t.jsx(bt,{className:"text-sm font-medium",children:"Field Completion Rates"}),t.jsx(Ft,{children:"Percentage of users who completed each field"})]}),t.jsx(Lt,{children:t.jsx("div",{className:"space-y-3",children:s.fieldDropOff.map((a,o)=>t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-foreground",children:a.label}),t.jsxs("span",{className:"text-muted-foreground",children:[a.completionRate,"%"]})]}),t.jsx("div",{className:"w-full bg-muted rounded-full h-1.5",children:t.jsx("div",{className:`rounded-full h-1.5 transition-all ${a.completionRate>=80?"bg-green-500":a.completionRate>=50?"bg-yellow-500":"bg-destructive"}`,style:{width:`${a.completionRate}%`}})})]},o))})})]})]})},dn=({schema:e})=>t.jsx(yt,{schema:e});Te.register("object-form",dn,{namespace:"plugin-form",label:"Object Form",category:"plugin",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"fields",type:"array",label:"Fields"},{name:"mode",type:"enum",label:"Mode",enum:["create","edit","view"]},{name:"formType",type:"enum",label:"Form Type",enum:["simple","tabbed","wizard","split","drawer","modal"]},{name:"sections",type:"array",label:"Sections"},{name:"title",type:"string",label:"Title"},{name:"description",type:"string",label:"Description"},{name:"layout",type:"enum",label:"Layout",enum:["vertical","horizontal","inline","grid"]},{name:"columns",type:"number",label:"Columns"},{name:"defaultTab",type:"string",label:"Default Tab"},{name:"tabPosition",type:"enum",label:"Tab Position",enum:["top","bottom","left","right"]},{name:"allowSkip",type:"boolean",label:"Allow Skip Steps"},{name:"showStepIndicator",type:"boolean",label:"Show Step Indicator"},{name:"splitDirection",type:"enum",label:"Split Direction",enum:["horizontal","vertical"]},{name:"splitSize",type:"number",label:"Split Panel Size (%)"},{name:"splitResizable",type:"boolean",label:"Split Resizable"},{name:"drawerSide",type:"enum",label:"Drawer Side",enum:["top","bottom","left","right"]},{name:"drawerWidth",type:"string",label:"Drawer Width"},{name:"modalSize",type:"enum",label:"Modal Size",enum:["sm","default","lg","xl","full"]}]});Te.register("form",dn,{namespace:"view",skipFallback:!0,label:"Data Form View",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"fields",type:"array",label:"Fields"},{name:"mode",type:"enum",label:"Mode",enum:["create","edit","view"]}]});const or=({schema:e})=>t.jsx(rr,{config:e});Te.register("embeddable-form",or,{namespace:"plugin-form",label:"Embeddable Form",category:"plugin",inputs:[{name:"formId",type:"string",label:"Form ID",required:!0},{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"title",type:"string",label:"Form Title"},{name:"description",type:"string",label:"Description"},{name:"fields",type:"array",label:"Fields"},{name:"allowMultiple",type:"boolean",label:"Allow Multiple Submissions"}]});const dr=({schema:e})=>t.jsx(ar,{formId:e.formId,formTitle:e.formTitle,metrics:e.metrics||{totalSubmissions:0}});Te.register("form-analytics",dr,{namespace:"plugin-form",label:"Form Analytics",category:"plugin",inputs:[{name:"formId",type:"string",label:"Form ID",required:!0},{name:"formTitle",type:"string",label:"Form Title"},{name:"metrics",type:"object",label:"Submission Metrics"}]});const cr={red:"bg-red-100",green:"bg-green-100",blue:"bg-blue-100",yellow:"bg-yellow-100",orange:"bg-orange-100",purple:"bg-purple-100",pink:"bg-pink-100",gray:"bg-gray-100",grey:"bg-gray-100",indigo:"bg-indigo-100",teal:"bg-teal-100",cyan:"bg-cyan-100",amber:"bg-amber-100",lime:"bg-lime-100",emerald:"bg-emerald-100",rose:"bg-rose-100",sky:"bg-sky-100",violet:"bg-violet-100",fuchsia:"bg-fuchsia-100",slate:"bg-slate-100",zinc:"bg-zinc-100",stone:"bg-stone-100",neutral:"bg-neutral-100"};function ur(e){if(e.startsWith("bg-"))return e;const n=e.toLowerCase().trim();return cr[n]}function fr(e){return l.useCallback(n=>{if(!e?.field||!e.colors)return;const s=String(n[e.field]??""),i=e.colors[s];if(i)return ur(i)},[e?.field,e?.colors])}function pr(e,n){return n.map(s=>String(e[s.field]??"")).join(" / ")}function mr(e,n){return n.map(s=>{const i=e[s.field];return i!=null&&i!==""?String(i):"(empty)"}).join(" / ")}function br(e,n,s){const i=e.localeCompare(n,void 0,{numeric:!0,sensitivity:"base"});return s==="desc"?-i:i}function xr(e,n,s){const i=e?.fields,r=!!(i&&i.length>0),[d,a]=l.useState({}),o=l.useMemo(()=>i?i.some(h=>h.collapsed):!1,[i]),u=l.useMemo(()=>{if(!r||!i)return[];const h=new Map,c=[];for(const y of n){const w=pr(y,i);h.has(w)||(h.set(w,{label:mr(y,i),rows:[]}),c.push(w)),h.get(w).rows.push(y)}const x=i[0]?.order??"asc";return c.sort((y,w)=>br(y,w,x)),c.map(y=>{const w=h.get(y),f=y in d?d[y]:o,P=[];return{key:y,label:w.label,rows:w.rows,collapsed:f,aggregations:P}})},[n,i,r,d,o,s]),b=l.useCallback(h=>{a(c=>({...c,[h]:c[h]!==void 0?!c[h]:!o}))},[o]);return{groups:u,isGrouped:r,toggleGroup:b}}const hr=({groupKey:e,label:n,count:s,collapsed:i,aggregations:r,onToggle:d,children:a})=>t.jsxs("div",{className:"border rounded-md","data-testid":`group-row-${e}`,children:[t.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:()=>d(e),"aria-expanded":!i,children:[i?t.jsx(rs,{className:"h-4 w-4 shrink-0"}):t.jsx(nn,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"group-label",children:n}),r&&r.length>0&&t.jsx("span",{className:"ml-2 text-xs text-muted-foreground group-aggregations",children:r.map(o=>t.jsxs("span",{className:"mr-2",children:[o.type,": ",Number.isInteger(o.value)?o.value:o.value.toFixed(2)]},`${o.field}-${o.type}`))}),t.jsxs("span",{className:"ml-auto text-xs text-muted-foreground group-count",children:["(",s,")"]})]}),!i&&a]});function gr(e){return typeof e=="string"?{type:e}:e}function yr(e,n){if(n.length===0)return null;switch(e){case"count":return n.length;case"sum":return n.reduce((s,i)=>s+i,0);case"avg":return n.reduce((s,i)=>s+i,0)/n.length;case"min":return Math.min(...n);case"max":return Math.max(...n);default:return null}}function jr(e,n){if(n===null)return"";const i={count:"Count",sum:"Sum",avg:"Avg",min:"Min",max:"Max"}[e]||e,r=e==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString();return`${i}: ${r}`}function wr(e,n){return l.useMemo(()=>{const s=new Map;if(!e||e.length===0||n.length===0)return{summaries:s,hasSummary:!1};for(const i of e){if(!i.summary)continue;const r=gr(i.summary),d=r.field||i.field,a=[];for(const u of n){const b=u[d];if(b!=null&&typeof b=="number"&&!isNaN(b))a.push(b);else if(b!=null&&typeof b=="string"){const h=parseFloat(b);isNaN(h)||a.push(h)}}let o;if(r.type==="count"){const u=n.filter(b=>b[d]!=null&&b[d]!=="").length;o=u>0?u:null}else o=yr(r.type,a);s.set(i.field,{field:i.field,value:o,label:jr(r.type,o)})}return{summaries:s,hasSummary:s.size>0}},[e,n])}function ds(e){return e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}const vr=({row:e,rowActions:n,canEdit:s,canDelete:i,onEdit:r,onDelete:d,onAction:a})=>t.jsxs(Bs,{children:[t.jsx(Ks,{asChild:!0,children:t.jsxs(ne,{variant:"ghost",size:"icon",className:"h-8 w-8 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0","data-testid":"row-action-trigger",children:[t.jsx(pi,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Open menu"})]})}),t.jsxs(Us,{align:"end",children:[s&&r&&t.jsxs(Dt,{onClick:()=>r(e),children:[t.jsx(mi,{className:"mr-2 h-4 w-4"}),"Edit"]}),i&&d&&t.jsxs(Dt,{onClick:()=>d(e),children:[t.jsx(ls,{className:"mr-2 h-4 w-4"}),"Delete"]}),n?.map(o=>t.jsx(Dt,{onClick:()=>a?.(o,e),"data-testid":`row-action-${o}`,children:ds(o)},o))]})]}),As=({selectedRows:e,actions:n,onAction:s,onClearSelection:i})=>!n||n.length===0||e.length===0?null:t.jsxs("div",{className:"border-t px-4 py-1.5 flex items-center gap-2 text-xs bg-primary/5 shrink-0","data-testid":"bulk-actions-bar",children:[t.jsxs("span",{className:"text-muted-foreground font-medium",children:[e.length," selected"]}),t.jsx("div",{className:"flex items-center gap-1 ml-2",children:n.map(r=>t.jsx(ne,{variant:"outline",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>s?.(r,e),"data-testid":`bulk-action-${r}`,children:ds(r)},r))}),t.jsx(ne,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs ml-auto",onClick:i,children:"Clear"})]}),Vs={"grid.actions":"Actions","grid.edit":"Edit","grid.delete":"Delete","grid.export":"Export","grid.exportAs":"Export as {{format}}","grid.loading":"Loading grid...","grid.errorLoading":"Error loading grid","grid.pullToRefresh":"Pull to refresh","grid.refreshing":"Refreshing…","grid.openRecord":"Open record"};function Nr(){try{const e=Ui();return e.t("grid.actions")==="grid.actions"?{t:(s,i)=>{let r=Vs[s]||s;if(i)for(const[d,a]of Object.entries(i))r=r.replace(`{{${d}}}`,String(a));return r}}:{t:e.t}}catch{return{t:(e,n)=>{let s=Vs[e]||e;if(n)for(const[i,r]of Object.entries(n))s=s.replace(`{{${i}}}`,String(r));return s}}}}function Cr(e){return e.data?Array.isArray(e.data)?{provider:"value",items:e.data}:e.data:e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function Bt(e){if(!(!e||e.length===0))return typeof e[0]=="object"&&e[0]!==null,e}const cn=({schema:e,dataSource:n,onEdit:s,onDelete:i,onRowSelect:r,onRowClick:d,onCellChange:a,onRowSave:o,onBatchSave:u,onAddRecord:b,...h})=>{const[c,x]=l.useState([]),[y,w]=l.useState(!0),[f,P]=l.useState(null),{t:A}=Nr(),{fieldLabel:v}=st(),[H,Q]=l.useState(null),[D,g]=l.useState(!1),[p,N]=l.useState(0),[T,q]=l.useState(!1),[K,O]=l.useState(e.rowHeight??"compact"),[U,V]=l.useState([]),I=_e.useMemo(()=>e.id?`grid-columns-${e.objectName}-${e.id}`:`grid-columns-${e.objectName}`,[e.objectName,e.id]),[z,B]=l.useState(()=>{try{const m=localStorage.getItem(I);return m?JSON.parse(m):{}}catch{return{}}}),W=l.useCallback(m=>{B(m);try{localStorage.setItem(I,JSON.stringify(m))}catch(X){console.warn("Failed to persist column state:",X)}},[I]),se=l.useCallback(async()=>{N(m=>m+1)},[]),{ref:ee,isRefreshing:Ie,pullDistance:S}=Wi({onRefresh:se,enabled:!!n&&!!e.objectName});l.useEffect(()=>{const m=()=>g(window.innerWidth<480);return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[]);const je=h.data,ae=Qn(e.bind),ze=Cr(e),de=_e.useMemo(()=>je&&Array.isArray(je)?{provider:"value",items:je}:ae&&Array.isArray(ae)?{provider:"value",items:ae}:ze,[JSON.stringify(ze),ae,je]),Me=de?.provider==="value",ye=de?.provider==="object"&&de&&"object"in de?de.object:e.objectName,ke=e.fields,F=e.columns,ue=e.filter,me=e.sort,he=e.pagination,fe=e.pageSize;l.useEffect(()=>{Me&&de?.provider==="value"&&(x(m=>{const X=de.items;return JSON.stringify(m)!==JSON.stringify(X)?X:m}),w(!1))},[Me,de]),l.useEffect(()=>{if(!Me||!ye||!n)return;let m=!1;return(async()=>{try{const $=await n.getObjectSchema(ye);m||Q($)}catch($){console.warn(`[ObjectGrid] Failed to fetch objectSchema for inline data (objectName: ${ye}):`,$)}})(),()=>{m=!0}},[Me,ye,n]),l.useEffect(()=>{if(Me)return;let m=!1;return(async()=>{w(!0),P(null);try{let $=null;const pe=Bt(F)||ke;if(ye&&n){const Se=await n.getObjectSchema(ye);if(m)return;$=Se}else if(pe&&ye)$={name:ye,fields:{}};else throw ye?new Error("DataSource required"):new Error("Object name required for data fetching");if(m||Q($),n&&ye){const E={$select:(()=>{if(ke)return ke;if(F&&Array.isArray(F))return F.map(R=>typeof R=="string"?R:R.field)})(),$top:he?.pageSize||fe||50};ue&&Array.isArray(ue)?E.$filter=ue:e.defaultFilters&&(E.$filter=e.defaultFilters),me?typeof me=="string"?E.$orderby=me:Array.isArray(me)&&(E.$orderby=me.map(R=>`${R.field} ${R.order}`).join(", ")):e.defaultSort&&(E.$orderby=`${e.defaultSort.field} ${e.defaultSort.order}`);const j=tn($?.fields,F??ke);j.length>0&&(E.$expand=j);const M=await n.find(ye,E);if(m)return;x(M.data||[])}}catch($){m||P($)}finally{m||w(!1)}})(),()=>{m=!0}},[ye,ke,F,ue,me,he,fe,n,Me,de,p]);const be=Xn({navigation:e.navigation,objectName:e.objectName,onNavigate:e.onNavigate,onRowClick:d}),{execute:we}=Zn(),Ct=fr(e.rowColor),nt=l.useCallback(m=>{const X=e.conditionalFormatting;if(!(!X||X.length===0))for(const $ of X){let pe=!1;const Se=("condition"in $?$.condition:void 0)||("expression"in $?$.expression:void 0)||void 0;if(Se)pe=ei(Se,m);else if("field"in $&&"operator"in $&&$.field&&$.operator){const E=$,j=m[E.field];switch(E.operator){case"equals":pe=j===E.value;break;case"not_equals":pe=j!==E.value;break;case"contains":pe=typeof j=="string"&&typeof E.value=="string"&&j.includes(E.value);break;case"greater_than":pe=typeof j=="number"&&typeof E.value=="number"&&j>E.value;break;case"less_than":pe=typeof j=="number"&&typeof E.value=="number"&&j<E.value;break;case"in":pe=Array.isArray(E.value)&&E.value.includes(j);break}}if(pe){const E={};return"style"in $&&$.style&&Object.assign(E,$.style),"backgroundColor"in $&&$.backgroundColor&&(E.backgroundColor=$.backgroundColor),"textColor"in $&&$.textColor&&(E.color=$.textColor),"borderColor"in $&&$.borderColor&&(E.borderColor=$.borderColor),E}}},[e.conditionalFormatting]),{groups:it,isGrouped:Je,toggleGroup:ge}=xr(e.grouping,c),ce=_e.useMemo(()=>{const m=Bt(e.columns);if(m&&m.length>0&&typeof m[0]=="object")return m},[e.columns]),{summaries:$e,hasSummary:ut}=wr(ce,c),Ue=l.useCallback(()=>{const m=E=>E?{text:t.jsx($t,{className:"h-3.5 w-3.5"}),number:t.jsx(Pt,{className:"h-3.5 w-3.5"}),currency:t.jsx(Pt,{className:"h-3.5 w-3.5"}),percent:t.jsx(Pt,{className:"h-3.5 w-3.5"}),date:t.jsx(It,{className:"h-3.5 w-3.5"}),datetime:t.jsx(wi,{className:"h-3.5 w-3.5"}),boolean:t.jsx(ji,{className:"h-3.5 w-3.5"}),user:t.jsx(yi,{className:"h-3.5 w-3.5"}),select:t.jsx(gi,{className:"h-3.5 w-3.5"})}[E]||t.jsx($t,{className:"h-3.5 w-3.5"}):t.jsx($t,{className:"h-3.5 w-3.5"}),X=E=>{if(E.type)return E.type;const j=E.field.toLowerCase();if(["completed","is_completed","done","active","enabled","archived"].some(Y=>j===Y||j===`is_${Y}`))return"boolean";if(["created_time","modified_time","updated_time","created_at","updated_at","modified_at","last_login","logged_at"].some(Y=>j===Y||j.endsWith(`_${Y}`)))return"datetime";if(["date","due","created","updated","deadline","start","end","expires"].some(Y=>j.includes(Y))){if(c.length>0){const Y=c.find(ie=>ie[E.field]!=null)?.[E.field];if(typeof Y=="string"&&!isNaN(Date.parse(Y)))return"date"}return"date"}if(["probability","percent","percentage","completion","progress","rate"].some(Y=>j.includes(Y))&&c.length>0&&typeof c.find(ie=>ie[E.field]!=null)?.[E.field]=="number")return"percent";if(["status","priority","category","stage","type","severity","level"].some(Y=>j.includes(Y))&&c.length>0){const Y=new Set(c.map(ie=>ie[E.field]).filter(Boolean));if(Y.size>0&&Y.size<=10)return"select"}if(["assignee","owner","author","reporter","creator","user"].some(Y=>j.includes(Y)))return"user";if(["amount","price","total","revenue","cost","budget","salary"].some(Y=>j.includes(Y))&&c.length>0&&typeof c.find(ie=>ie[E.field]!=null)?.[E.field]=="number")return"currency";if(c.length>0){const Y=c.find(ie=>ie[E.field]!=null)?.[E.field];if(typeof Y=="string"&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(Y))return"datetime"}return null},$=Bt(F);if($){if($.length>0&&typeof $[0]=="object"&&$[0]!==null){const E=$[0];if("accessorKey"in E)return $.map(j=>{if(j.cell)return j;const M={field:j.accessorKey,label:j.header,type:j.type},R=X(M);if(!R)return j;const te=Ze(R),L={name:j.accessorKey,type:R};if(R==="select"){const C=Array.from(new Set(c.map(J=>J[j.accessorKey]).filter(Boolean)));L.options=C.map(J=>({value:J,label:kt(String(J))}))}return{...j,headerIcon:m(R),cell:C=>t.jsx(te,{value:C,field:L})}});if("field"in E)return $.filter(j=>j?.field&&typeof j.field=="string"&&!j.hidden).map((j,M)=>{const R=j.label||j.field.charAt(0).toUpperCase()+j.field.slice(1).replace(/_/g," "),te=e.objectName?v(e.objectName,j.field,R):R;let L;const C=H?.fields?.[j.field],J=j.type||C?.type||X({field:j.field})||null,re=J?Ze(J):null,Y={name:j.field,type:J||"text"};if(C&&(C.label&&(Y.label=C.label),C.currency&&(Y.currency=C.currency),C.precision!==void 0&&(Y.precision=C.precision),C.format&&(Y.format=C.format),C.options&&(Y.options=C.options)),J==="select"&&!Y.options){const oe=Array.from(new Set(c.map(Ve=>Ve[j.field]).filter(Boolean)));Y.options=oe.map(Ve=>({value:Ve,label:kt(String(Ve))}))}j.options&&(Y.options=j.options);const ie=M===0&&!j.link&&!j.action,Fe=j.link||ie;j.link&&j.action||ie&&j.action?L=(oe,Ve)=>{const Xe=re?t.jsx(re,{value:oe,field:Y}):oe!=null&&oe!==""?String(oe):t.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"});return t.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":ie?"primary-field-link":"link-cell",onClick:at=>{at.stopPropagation(),be.handleClick(Ve)},children:Xe})}:Fe?L=(oe,Ve)=>{const Xe=re?t.jsx(re,{value:oe,field:Y}):oe!=null&&oe!==""?String(oe):t.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"});return t.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":ie?"primary-field-link":"link-cell",onClick:at=>{at.stopPropagation(),be.handleClick(Ve)},children:Xe})}:j.action?L=(oe,Ve)=>t.jsx(ne,{variant:"outline",size:"sm",className:"h-7 text-xs","data-testid":"action-cell",onClick:Xe=>{Xe.stopPropagation(),we({type:j.action,params:{record:Ve,field:j.field,value:oe}})},children:ds(j.action)}):re?L=oe=>t.jsx(re,{value:oe,field:Y}):L=oe=>oe!=null&&oe!==""?t.jsx("span",{children:String(oe)}):t.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"});const Le=j.prefix;if(Le?.field){const oe=L,Ve=Le.type==="badge"?Ze("select"):null;L=(Xe,at)=>{const St=at[Le.field],Nn=St!=null&&St!==""?Ve?t.jsx(Ve,{value:St,field:{name:Le.field,type:"select"}}):t.jsx("span",{className:"text-muted-foreground text-xs mr-1.5",children:String(St)}):null;return t.jsxs("span",{className:"flex items-center gap-1.5",children:[Nn,oe(Xe,at)]})}}const De=["number","currency","percent"],Ee=J||j.type,We=j.align||(Ee&&De.includes(Ee)?"right":void 0),le=M===0||j.essential===!0;return{header:te,accessorKey:j.field,headerIcon:m(J),...!le&&{className:"hidden sm:table-cell"},...j.width&&{width:j.width},...We&&{align:We},sortable:j.sortable!==!1,...j.resizable!==void 0&&{resizable:j.resizable},...j.wrap!==void 0&&{wrap:j.wrap},...L&&{cell:L},...j.pinned&&{pinned:j.pinned}}})}return $.filter(E=>typeof E=="string"&&E.trim().length>0).map((E,j)=>{const M=H?.fields?.[E],te=M?.label||E.charAt(0).toUpperCase()+E.slice(1).replace(/_/g," "),L=e.objectName?v(e.objectName,E,te):te,C=M?.type||X({field:E})||null,J=C?Ze(C):null,re={name:E,type:C||"text"};if(M&&(M.label&&(re.label=M.label),M.currency&&(re.currency=M.currency),M.precision!==void 0&&(re.precision=M.precision),M.format&&(re.format=M.format),M.options&&(re.options=M.options)),C==="select"&&!re.options){const De=Array.from(new Set(c.map(Ee=>Ee[E]).filter(Boolean)));re.options=De.map(Ee=>({value:Ee,label:kt(String(Ee))}))}const ie=C&&["number","currency","percent"].includes(C)?"right":void 0,Fe=j===0;let Le;return Fe&&J?Le=(De,Ee)=>{const We=t.jsx(J,{value:De,field:re});return t.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":"primary-field-link",onClick:le=>{le.stopPropagation(),be.handleClick(Ee)},children:We})}:Fe?Le=(De,Ee)=>t.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":"primary-field-link",onClick:We=>{We.stopPropagation(),be.handleClick(Ee)},children:De!=null&&De!==""?String(De):t.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"})}):J&&(Le=De=>t.jsx(J,{value:De,field:re})),{header:L,accessorKey:E,...C&&{headerIcon:m(C)},...ie&&{align:ie},...Le&&{cell:Le},sortable:M?.sortable!==!1}})}if(Me){const E=de?.provider==="value"?de.items:[];if(E.length>0)return(ke||Object.keys(E[0])).map(M=>{const R=H?.fields?.[M],te=R?.type||X({field:M})||null,L=te?Ze(te):null,C=R?.label||M.charAt(0).toUpperCase()+M.slice(1).replace(/_/g," "),J={name:M,type:te||"text"};if(R&&(R.label&&(J.label=R.label),R.currency&&(J.currency=R.currency),R.precision!==void 0&&(J.precision=R.precision),R.format&&(J.format=R.format),R.options&&(J.options=R.options)),te==="select"&&!J.options){const ie=Array.from(new Set(c.map(Fe=>Fe[M]).filter(Boolean)));J.options=ie.map(Fe=>({value:Fe,label:kt(String(Fe))}))}const Y=te&&["number","currency","percent"].includes(te)?"right":void 0;return{header:C,accessorKey:M,...te&&{headerIcon:m(te)},...Y&&{align:Y},...L&&{cell:ie=>t.jsx(L,{value:ie,field:J})},sortable:R?.sortable!==!1}})}if(!H)return[];const pe=[];return(ke||Object.keys(H.fields||{})).forEach(E=>{const j=H.fields?.[E];if(!j||j.permissions&&j.permissions.read===!1)return;const M=Ze(j.type),R=["number","currency","percent"];pe.push({header:e.objectName?v(e.objectName,E,j.label||E):j.label||E,accessorKey:E,...R.includes(j.type)&&{align:"right"},cell:te=>t.jsx(M,{value:te,field:j}),sortable:j.sortable!==!1})}),pe},[H,ke,F,de,Me,be.handleClick,we,c,v,e.objectName]),Rt=l.useCallback(m=>{const X=e.exportOptions,$=X?.maxRecords||0,pe=X?.includeHeaders!==!1,Se=X?.fileNamePrefix||e.objectName||"export",E=$>0?c.slice(0,$):c,j=(R,te)=>{const L=URL.createObjectURL(R),C=document.createElement("a");C.href=L,C.download=te,C.click(),URL.revokeObjectURL(L)},M=R=>{const te=R==null?"":String(R);return te.includes(",")||te.includes('"')||te.includes(`
|
|
2
|
+
`)||te.includes("\r")?`"${te.replace(/"/g,'""')}"`:te};if(m==="csv"){const R=Ue().filter(J=>J.accessorKey!=="_actions"),te=R.map(J=>J.accessorKey),L=R.map(J=>J.header),C=[];pe&&C.push(L.join(",")),E.forEach(J=>{C.push(te.map(re=>M(J[re])).join(","))}),j(new Blob([C.join(`
|
|
3
|
+
`)],{type:"text/csv;charset=utf-8;"}),`${Se}.csv`)}else m==="json"&&j(new Blob([JSON.stringify(E,null,2)],{type:"application/json"}),`${Se}.json`);q(!1)},[c,e.exportOptions,e.objectName,Ue]);if(f)return t.jsxs("div",{className:"p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",children:[t.jsx("h3",{className:"text-red-800 font-semibold",children:A("grid.errorLoading")}),t.jsx("p",{className:"text-red-600 text-sm mt-1",children:f.message})]});if(y&&c.length===0)return D?t.jsx("div",{className:"space-y-2 p-2",children:[1,2,3].map(m=>t.jsxs("div",{className:"border rounded-lg p-3 bg-card animate-pulse",children:[t.jsx("div",{className:"h-5 bg-muted rounded w-3/4 mb-3"}),t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("div",{className:"h-4 bg-muted rounded w-1/4"}),t.jsx("div",{className:"h-5 bg-muted rounded-full w-20"})]}),t.jsx("div",{className:"h-3 bg-muted rounded w-1/3"})]},m))}):t.jsxs("div",{className:"p-4 sm:p-8 text-center",children:[t.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-foreground"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:A("grid.loading")})]});let Pe=[...Ue()];if(z.widths&&(Pe=Pe.map(m=>{const X=z.widths?.[m.accessorKey];return X?{...m,size:X}:m})),z.order&&z.order.length>0){const m=new Map(z.order.map((X,$)=>[X,$]));Pe.sort((X,$)=>{const pe=m.get(X.accessorKey)??1/0,Se=m.get($.accessorKey)??1/0;return pe-Se})}const qe="operations"in e?e.operations:void 0,ft=qe&&(qe.update||qe.delete),rt=e.rowActions&&e.rowActions.length>0,Qe=ft||rt?[...Pe,{header:A("grid.actions"),accessorKey:"_actions",cell:(m,X)=>t.jsx(vr,{row:X,rowActions:e.rowActions,canEdit:!!(qe?.update&&s),canDelete:!!(qe?.delete&&i),onEdit:s,onDelete:i,onAction:($,pe)=>we({type:$,params:{record:pe}})}),sortable:!1}]:Pe,lt=Qe.filter(m=>m.pinned==="left"),k=Qe.filter(m=>m.pinned==="right"),_=Qe.filter(m=>!m.pinned),G=lt.length>0||k.length>0,Oe="sticky right-0 z-10 bg-background border-l border-border",xe=G?[...lt,..._,...k.map(m=>({...m,className:[m.className,Oe].filter(Boolean).join(" "),cellClassName:[m.cellClassName,Oe].filter(Boolean).join(" ")}))]:Qe,Be=G?lt.length:e.frozenColumns??1,ve=e.batchActions??e.bulkActions,Ne=ve&&ve.length>0;let Ae=!1;e.selection?.type?Ae=e.selection.type==="none"?!1:e.selection.type:e.selectable!==void 0?Ae=e.selectable:Ne&&(Ae="multiple");const Ce=e.pagination!==void 0?!0:e.showPagination!==void 0?e.showPagination:!0,zt=e.pagination?.pageSize||e.pageSize||10,gn=e.searchableFields!==void 0?e.searchableFields.length>0:e.showSearch!==void 0?e.showSearch:!0,us={type:"data-table",caption:e.label||e.title,columns:xe,data:c,pagination:Ce,pageSize:zt,searchable:gn,selectable:Ae,sortable:!0,exportable:qe?.export,rowActions:ft,resizableColumns:e.resizable??e.resizableColumns??!0,reorderableColumns:e.reorderableColumns??!1,editable:e.editable??!1,singleClickEdit:e.singleClickEdit??!0,className:e.className,cellClassName:K==="compact"?"px-3 py-1 text-[13px] leading-tight":K==="short"?"px-3 py-1 text-[13px] leading-normal":K==="tall"?"px-3 py-2.5 text-sm":K==="extra_tall"?"px-3 py-3.5 text-sm leading-relaxed":"px-3 py-1.5 text-[13px] leading-normal",showRowNumbers:!0,showAddRow:!!qe?.create,onAddRecord:b,rowClassName:e.rowColor?(m,X)=>Ct(m):void 0,rowStyle:e.conditionalFormatting?.length?(m,X)=>nt(m):void 0,frozenColumns:Be,onSelectionChange:m=>{V(m),r?.(m)},onRowClick:be.handleClick,onCellChange:a,onRowSave:o,onBatchSave:u,onColumnResize:(m,X)=>{W({...z,widths:{...z.widths,[m]:X}})},onColumnReorder:m=>{W({...z,order:m})}},yn=m=>({...us,caption:void 0,data:m,pagination:!1,searchable:!1}),Mt=e.label?`${e.label} Detail`:e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1)} Detail`:"Record Detail";if(D&&c.length>0&&!Je){const m=Ue().filter(L=>L.accessorKey!=="_actions"),X=new Map;m.forEach(L=>X.set(L.accessorKey,L));const $=m[0],pe=["amount","price","total","revenue","cost","value","budget","salary"],Se=["stage","status","priority","category","severity","level"],E=["date","due","created","updated","deadline","start","end","expires"],j=["probability","percent","rate","ratio","confidence","score"],M=L=>{const C=(L||"").toLowerCase();return C.includes("won")||C.includes("completed")||C.includes("done")||C.includes("active")?"bg-green-100 text-green-800 border-green-300":C.includes("lost")||C.includes("cancelled")||C.includes("rejected")||C.includes("closed lost")?"bg-red-100 text-red-800 border-red-300":C.includes("negotiation")||C.includes("review")||C.includes("in progress")?"bg-yellow-100 text-yellow-800 border-yellow-300":C.includes("proposal")||C.includes("pending")?"bg-blue-100 text-blue-800 border-blue-300":C.includes("qualification")||C.includes("qualified")?"bg-indigo-100 text-indigo-800 border-indigo-300":C.includes("prospecting")||C.includes("new")||C.includes("open")?"bg-purple-100 text-purple-800 border-purple-300":"bg-muted text-muted-foreground border-border"},R=L=>{const C=(L||"").toLowerCase();return C.includes("won")||C.includes("completed")||C.includes("done")||C.includes("active")?"border-l-green-500":C.includes("lost")||C.includes("cancelled")||C.includes("rejected")?"border-l-red-500":C.includes("negotiation")||C.includes("review")||C.includes("in progress")?"border-l-yellow-500":C.includes("proposal")||C.includes("pending")?"border-l-blue-500":C.includes("qualification")||C.includes("qualified")?"border-l-indigo-500":C.includes("prospecting")||C.includes("new")||C.includes("open")?"border-l-purple-500":"border-l-gray-300"},te=L=>{const C=L.toLowerCase();return pe.some(J=>C.includes(J))?"amount":Se.some(J=>C.includes(J))?"stage":E.some(J=>C.includes(J))?"date":j.some(J=>C.includes(J))?"percent":"other"};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"space-y-2 p-2",children:c.map((L,C)=>{const J=m.slice(1,5),re=J.find(le=>te(le.accessorKey)==="amount"),Y=J.find(le=>te(le.accessorKey)==="stage"),ie=J.filter(le=>te(le.accessorKey)==="date"),Fe=J.filter(le=>te(le.accessorKey)==="percent"),Le=J.filter(le=>le!==re&&le!==Y&&!ie.includes(le)&&!Fe.includes(le)),De=Y?String(L[Y.accessorKey]??""):"",Ee=De?R(De):"",We=["border rounded-lg p-2.5 bg-card hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",Ee?`border-l-[3px] ${Ee}`:""].filter(Boolean).join(" ");return t.jsxs("div",{className:We,onClick:()=>be.handleClick(L),children:[$&&t.jsx("div",{className:"font-semibold text-sm truncate mb-1",children:L[$.accessorKey]??"—"}),(re||Y)&&t.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[re&&t.jsx("span",{className:"text-sm tabular-nums font-medium",children:typeof L[re.accessorKey]=="number"?zn(L[re.accessorKey]):L[re.accessorKey]??"—"}),Y&&L[Y.accessorKey]&&t.jsx(Ke,{variant:"outline",className:`text-xs shrink-0 max-w-[140px] truncate ${M(String(L[Y.accessorKey]))}`,children:L[Y.accessorKey]})]}),(ie.length>0||Fe.length>0)&&t.jsxs("div",{className:"flex items-center justify-between py-0.5 text-xs text-muted-foreground",children:[ie[0]&&t.jsx("span",{className:"tabular-nums",children:L[ie[0].accessorKey]?_t(L[ie[0].accessorKey],"short"):"—"}),Fe[0]&&L[Fe[0].accessorKey]!=null&&t.jsx("span",{className:"tabular-nums",children:Mn(Number(L[Fe[0].accessorKey]))})]}),ie.slice(1).map(le=>t.jsxs("div",{className:"flex justify-between items-center py-0.5",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:le.header}),t.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:L[le.accessorKey]?_t(L[le.accessorKey],"short"):"—"})]},le.accessorKey)),Le.map(le=>{const oe=L[le.accessorKey];return oe==null||oe===""?null:t.jsxs("div",{className:"flex justify-between items-center py-0.5",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:le.header}),t.jsx("span",{className:"text-xs font-medium truncate ml-2 text-right",children:le.cell?le.cell(oe,L):String(oe)})]},le.accessorKey)})]},L.id||L._id||C)})}),be.isOverlay&&t.jsx(xt,{...be,title:Mt,children:L=>t.jsx("div",{className:"space-y-3",children:Object.entries(L).map(([C,J])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:C.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(J??"—")})]},C))})})]})}const jn=()=>{O(m=>m==="compact"?"short":m==="short"?"medium":m==="medium"?"tall":m==="tall"?"extra_tall":"compact")},wn={compact:hi,short:xi,medium:bi,tall:Ns,extra_tall:Ns}[K],fs=e.rowHeight!==void 0,ps=e.exportOptions||fs?t.jsxs("div",{className:"flex items-center justify-end gap-1 px-2 py-1",children:[fs&&t.jsxs(ne,{variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-primary text-xs",onClick:jn,title:`Row height: ${K}`,children:[t.jsx(wn,{className:"h-3.5 w-3.5 mr-1.5"}),t.jsx("span",{className:"hidden sm:inline capitalize",children:K})]}),e.exportOptions&&t.jsxs(ss,{open:T,onOpenChange:q,children:[t.jsx(ns,{asChild:!0,children:t.jsxs(ne,{variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-primary text-xs",children:[t.jsx(Cs,{className:"h-3.5 w-3.5 mr-1.5"}),t.jsx("span",{className:"hidden sm:inline",children:A("grid.export")})]})}),t.jsx(is,{align:"end",className:"w-48 p-2",children:t.jsx("div",{className:"space-y-1",children:(e.exportOptions.formats||["csv","json"]).map(m=>t.jsxs(ne,{variant:"ghost",size:"sm",className:"w-full justify-start h-8 text-xs",onClick:()=>Rt(m),children:[t.jsx(Cs,{className:"h-3.5 w-3.5 mr-2"}),A("grid.exportAs",{format:m.toUpperCase()})]},m))})})]})]}):null,ms=m=>{const X=["_id","id","created_at","updated_at","created_by","updated_by"],$=Object.entries(m),pe=$.filter(([M])=>!X.includes(M)),Se=$.filter(([M])=>X.includes(M)&&M!=="_id"&&M!=="id"),E=M=>M.charAt(0).toUpperCase()+M.slice(1).replace(/_/g," "),j=(M,R)=>{if(R==null||R==="")return t.jsx("span",{className:"text-muted-foreground/50 text-sm italic",children:"Empty"});const te=H?.fields?.[M];if(te?.type){const C=Ze(te.type);if(C)return t.jsx(C,{value:R,field:te})}return typeof R=="boolean"?t.jsx(Ke,{variant:R?"default":"outline",children:R?"Yes":"No"}):typeof R=="string"&&!isNaN(Date.parse(R))&&(M.includes("date")||M.includes("_at")||M.includes("time"))?t.jsx("span",{className:"text-sm tabular-nums",children:_t(R)}):typeof R=="number"&&["amount","price","total","revenue","cost","value","budget","salary"].some(C=>M.toLowerCase().includes(C))?t.jsx("span",{className:"text-sm tabular-nums font-medium",children:Ln(R)}):t.jsx("span",{className:"text-sm break-words",children:String(R)})};return t.jsxs("div",{className:"space-y-4","data-testid":"record-detail-panel",children:[t.jsx("div",{className:"rounded-lg border bg-card",children:t.jsx("div",{className:"divide-y",children:pe.map(([M,R])=>t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-4 px-4 py-3",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground sm:w-1/3 sm:text-right sm:pt-0.5 uppercase tracking-wide shrink-0",children:E(M)}),t.jsx("div",{className:"flex-1 min-w-0",children:j(M,R)})]},M))})}),Se.length>0&&t.jsxs("div",{className:"rounded-lg border bg-muted/30",children:[t.jsx("div",{className:"px-4 py-2 border-b",children:t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"System"})}),t.jsx("div",{className:"divide-y divide-border/50",children:Se.map(([M,R])=>t.jsxs("div",{className:"flex items-center gap-4 px-4 py-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground w-1/3 text-right shrink-0",children:E(M)}),t.jsx("span",{className:"text-xs text-muted-foreground flex-1 min-w-0 break-words",children:String(R??"")})]},M))})]})]})},vn=ut?t.jsx("div",{className:"border-t bg-muted/30 px-2 py-1.5","data-testid":"column-summary-footer",children:t.jsx("div",{className:"flex gap-4 text-xs text-muted-foreground font-medium",children:xe.filter(m=>$e.has(m.accessorKey)).map(m=>{const X=$e.get(m.accessorKey);return t.jsxs("span",{"data-testid":`summary-${m.accessorKey}`,children:[m.header,": ",X.label]},m.accessorKey)})})}):null,bs=Je?t.jsx("div",{className:"space-y-2",children:it.map(m=>t.jsx(hr,{groupKey:m.key,label:m.label,count:m.rows.length,collapsed:m.collapsed,aggregations:m.aggregations,onToggle:ge,children:t.jsx(Re,{schema:yn(m.rows)})},m.key))}):t.jsxs(t.Fragment,{children:[t.jsx(Re,{schema:us}),vn]});return be.isOverlay&&be.mode==="split"?t.jsx(xt,{...be,title:Mt,mainContent:t.jsxs(t.Fragment,{children:[ps,bs,t.jsx(As,{selectedRows:U,actions:ve??[],onAction:(m,X)=>we({type:m,params:{records:X}}),onClearSelection:()=>V([])})]}),children:m=>ms(m)}):t.jsxs("div",{ref:ee,className:"relative h-full",children:[S>0&&t.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:S},children:A(Ie?"grid.refreshing":"grid.pullToRefresh")}),ps,bs,t.jsx(As,{selectedRows:U,actions:ve??[],onAction:(m,X)=>we({type:m,params:{records:X}}),onClearSelection:()=>V([])}),be.isOverlay&&t.jsx(xt,{...be,title:Mt,children:m=>ms(m)})]})};function ot(e,n,s){let i=s.initialDeps??[],r,d=!0;function a(){var o,u,b;let h;s.key&&((o=s.debug)!=null&&o.call(s))&&(h=Date.now());const c=e();if(!(c.length!==i.length||c.some((w,f)=>i[f]!==w)))return r;i=c;let y;if(s.key&&((u=s.debug)!=null&&u.call(s))&&(y=Date.now()),r=n(...c),s.key&&((b=s.debug)!=null&&b.call(s))){const w=Math.round((Date.now()-h)*100)/100,f=Math.round((Date.now()-y)*100)/100,P=f/16,A=(v,H)=>{for(v=String(v);v.length<H;)v=" "+v;return v};console.info(`%c⏱ ${A(f,5)} /${A(w,5)} ms`,`
|
|
4
|
+
font-size: .6rem;
|
|
5
|
+
font-weight: bold;
|
|
6
|
+
color: hsl(${Math.max(0,Math.min(120-120*P,120))}deg 100% 31%);`,s?.key)}return s?.onChange&&!(d&&s.skipInitialOnChange)&&s.onChange(r),d=!1,r}return a.updateDeps=o=>{i=o},a}function Rs(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Sr=(e,n)=>Math.abs(e-n)<1.01,Fr=(e,n,s)=>{let i;return function(...r){e.clearTimeout(i),i=e.setTimeout(()=>n.apply(this,r),s)}},zs=e=>{const{offsetWidth:n,offsetHeight:s}=e;return{width:n,height:s}},kr=e=>e,Or=e=>{const n=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1),i=[];for(let r=n;r<=s;r++)i.push(r);return i},Dr=(e,n)=>{const s=e.scrollElement;if(!s)return;const i=e.targetWindow;if(!i)return;const r=a=>{const{width:o,height:u}=a;n({width:Math.round(o),height:Math.round(u)})};if(r(zs(s)),!i.ResizeObserver)return()=>{};const d=new i.ResizeObserver(a=>{const o=()=>{const u=a[0];if(u?.borderBoxSize){const b=u.borderBoxSize[0];if(b){r({width:b.inlineSize,height:b.blockSize});return}}r(zs(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()});return d.observe(s,{box:"border-box"}),()=>{d.unobserve(s)}},Ms={passive:!0},Ls=typeof window>"u"?!0:"onscrollend"in window,Er=(e,n)=>{const s=e.scrollElement;if(!s)return;const i=e.targetWindow;if(!i)return;let r=0;const d=e.options.useScrollendEvent&&Ls?()=>{}:Fr(i,()=>{n(r,!1)},e.options.isScrollingResetDelay),a=h=>()=>{const{horizontal:c,isRtl:x}=e.options;r=c?s.scrollLeft*(x&&-1||1):s.scrollTop,d(),n(r,h)},o=a(!0),u=a(!1);s.addEventListener("scroll",o,Ms);const b=e.options.useScrollendEvent&&Ls;return b&&s.addEventListener("scrollend",u,Ms),()=>{s.removeEventListener("scroll",o),b&&s.removeEventListener("scrollend",u)}},Tr=(e,n,s)=>{if(n?.borderBoxSize){const i=n.borderBoxSize[0];if(i)return Math.round(i[s.options.horizontal?"inlineSize":"blockSize"])}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},Ir=(e,{adjustments:n=0,behavior:s},i)=>{var r,d;const a=e+n;(d=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||d.call(r,{[i.options.horizontal?"left":"top"]:a,behavior:s})};class Ar{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let s=null;const i=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(d=>{const a=()=>{this._measureElement(d.target,d)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),s=null},observe:r=>{var d;return(d=i())==null?void 0:d.observe(r,{box:"border-box"})},unobserve:r=>{var d;return(d=i())==null?void 0:d.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{Object.entries(s).forEach(([i,r])=>{typeof r>"u"&&delete s[i]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:kr,rangeExtractor:Or,onChange:()=>{},measureElement:Tr,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...s}},this.notify=s=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,s)},this.maybeNotify=ot(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,d)=>{this.scrollAdjustments=0,this.scrollDirection=d?this.getScrollOffset()<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=d,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(s,i)=>{const r=new Map,d=new Map;for(let a=i-1;a>=0;a--){const o=s[a];if(r.has(o.lane))continue;const u=d.get(o.lane);if(u==null||o.end>u.end?d.set(o.lane,o):o.end<u.end&&r.set(o.lane,!0),r.size===this.options.lanes)break}return d.size===this.options.lanes?Array.from(d.values()).sort((a,o)=>a.end===o.end?a.index-o.index:a.end-o.end)[0]:void 0},this.getMeasurementOptions=ot(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(s,i,r,d,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:s,paddingStart:i,scrollMargin:r,getItemKey:d,enabled:a,lanes:o}),{key:!1}),this.getMeasurements=ot(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:s,paddingStart:i,scrollMargin:r,getItemKey:d,enabled:a,lanes:o},u)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const x of this.laneAssignments.keys())x>=s&&this.laneAssignments.delete(x);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(x=>{this.itemSizeCache.set(x.key,x.size)}));const b=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1);const h=this.measurementsCache.slice(0,b),c=new Array(o).fill(void 0);for(let x=0;x<b;x++){const y=h[x];y&&(c[y.lane]=x)}for(let x=b;x<s;x++){const y=d(x),w=this.laneAssignments.get(x);let f,P;if(w!==void 0&&this.options.lanes>1){f=w;const Q=c[f],D=Q!==void 0?h[Q]:void 0;P=D?D.end+this.options.gap:i+r}else{const Q=this.options.lanes===1?h[x-1]:this.getFurthestMeasurement(h,x);P=Q?Q.end+this.options.gap:i+r,f=Q?Q.lane:x%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(x,f)}const A=u.get(y),v=typeof A=="number"?A:this.options.estimateSize(x),H=P+v;h[x]={index:x,start:P,size:v,end:H,key:y,lane:f},c[f]=x}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ot(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,i,r,d)=>this.range=s.length>0&&i>0?Vr({measurements:s,outerSize:i,scrollOffset:r,lanes:d}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ot(()=>{let s=null,i=null;const r=this.calculateRange();return r&&(s=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,i]},(s,i,r,d,a)=>d===null||a===null?[]:s({startIndex:d,endIndex:a,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const i=this.options.indexAttribute,r=s.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this._measureElement=(s,i)=>{const r=this.indexFromElement(s),d=this.measurementsCache[r];if(!d)return;const a=d.key,o=this.elementsCache.get(a);o!==s&&(o&&this.observer.unobserve(o),this.observer.observe(s),this.elementsCache.set(a,s)),s.isConnected&&this.resizeItem(r,this.options.measureElement(s,i,this))},this.resizeItem=(s,i)=>{const r=this.measurementsCache[s];if(!r)return;const d=this.itemSizeCache.get(r.key)??r.size,a=i-d;a!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(r,a,this):r.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(r.index),this.itemSizeCache=new Map(this.itemSizeCache.set(r.key,i)),this.notify(!1))},this.measureElement=s=>{if(!s){this.elementsCache.forEach((i,r)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(r))});return}this._measureElement(s,void 0)},this.getVirtualItems=ot(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,i)=>{const r=[];for(let d=0,a=s.length;d<a;d++){const o=s[d],u=i[o];r.push(u)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const i=this.getMeasurements();if(i.length!==0)return Rs(i[un(0,i.length-1,r=>Rs(i[r]).start,s)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(s,i,r=0)=>{if(!this.scrollElement)return 0;const d=this.getSize(),a=this.getScrollOffset();i==="auto"&&(i=s>=a+d?"end":"start"),i==="center"?s+=(r-d)/2:i==="end"&&(s-=d);const o=this.getMaxScrollOffset();return Math.max(Math.min(o,s),0)},this.getOffsetForIndex=(s,i="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.measurementsCache[s];if(!r)return;const d=this.getSize(),a=this.getScrollOffset();if(i==="auto")if(r.end>=a+d-this.options.scrollPaddingEnd)i="end";else if(r.start<=a+this.options.scrollPaddingStart)i="start";else return[a,i];if(i==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),i];const o=i==="end"?r.end+this.options.scrollPaddingEnd:r.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,i,r.size),i]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(s,{align:i="start",behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(s,i),{adjustments:void 0,behavior:r})},this.scrollToIndex=(s,{align:i="auto",behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),s=Math.max(0,Math.min(s,this.options.count-1)),this.currentScrollToIndex=s;let d=0;const a=10,o=b=>{if(!this.targetWindow)return;const h=this.getOffsetForIndex(s,b);if(!h){console.warn("Failed to get offset for index:",s);return}const[c,x]=h;this._scrollToOffset(c,{adjustments:void 0,behavior:r}),this.targetWindow.requestAnimationFrame(()=>{if(!this.targetWindow)return;const y=()=>{if(this.currentScrollToIndex!==s)return;const w=this.getScrollOffset(),f=this.getOffsetForIndex(s,x);if(!f){console.warn("Failed to get offset for index:",s);return}Sr(f[0],w)||u(x)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(y):y()})},u=b=>{this.targetWindow&&this.currentScrollToIndex===s&&(d++,d<a?this.targetWindow.requestAnimationFrame(()=>o(b)):console.warn(`Failed to scroll to index ${s} after ${a} attempts.`))};o(i)},this.scrollBy=(s,{behavior:i}={})=>{i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+s,{adjustments:void 0,behavior:i})},this.getTotalSize=()=>{var s;const i=this.getMeasurements();let r;if(i.length===0)r=this.options.paddingStart;else if(this.options.lanes===1)r=((s=i[i.length-1])==null?void 0:s.end)??0;else{const d=Array(this.options.lanes).fill(null);let a=i.length-1;for(;a>=0&&d.some(o=>o===null);){const o=i[a];d[o.lane]===null&&(d[o.lane]=o.end),a--}r=Math.max(...d.filter(o=>o!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(s,{adjustments:i,behavior:r})=>{this.options.scrollToFn(s,{behavior:r,adjustments:i},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(n)}}const un=(e,n,s,i)=>{for(;e<=n;){const r=(e+n)/2|0,d=s(r);if(d<i)e=r+1;else if(d>i)n=r-1;else return r}return e>0?e-1:0};function Vr({measurements:e,outerSize:n,scrollOffset:s,lanes:i}){const r=e.length-1,d=u=>e[u].start;if(e.length<=i)return{startIndex:0,endIndex:r};let a=un(0,r,d,s),o=a;if(i===1)for(;o<r&&e[o].end<s+n;)o++;else if(i>1){const u=Array(i).fill(0);for(;o<r&&u.some(h=>h<s+n);){const h=e[o];u[h.lane]=h.end,o++}const b=Array(i).fill(s+n);for(;a>=0&&b.some(h=>h>=s);){const h=e[a];b[h.lane]=h.start,a--}a=Math.max(0,a-a%i),o=Math.min(r,o+(i-1-o%i))}return{startIndex:a,endIndex:o}}const _s=typeof document<"u"?l.useLayoutEffect:l.useEffect;function Rr({useFlushSync:e=!0,...n}){const s=l.useReducer(()=>({}),{})[1],i={...n,onChange:(d,a)=>{var o;e&&a?Cn.flushSync(s):s(),(o=n.onChange)==null||o.call(n,d,a)}},[r]=l.useState(()=>new Ar(i));return r.setOptions(i),_s(()=>r._didMount(),[]),_s(()=>r._willUpdate()),r}function Cl(e){return Rr({observeElementRect:Dr,observeElementOffset:Er,scrollToFn:Ir,...e})}const zr=10;function Mr(e){const n=[];let s=[],i="",r=!1;for(let d=0;d<e.length;d++){const a=e[d],o=e[d+1];r?a==='"'&&o==='"'?(i+='"',d++):a==='"'?r=!1:i+=a:a==='"'?r=!0:a===","?(s.push(i.trim()),i=""):a===`
|
|
7
|
+
`||a==="\r"&&o===`
|
|
8
|
+
`?(s.push(i.trim()),s.some(u=>u!=="")&&n.push(s),s=[],i="",a==="\r"&&d++):i+=a}return s.push(i.trim()),s.some(d=>d!=="")&&n.push(s),n}function fn(e,n){if(!e)return!0;switch(n){case"number":case"currency":case"percent":return!isNaN(Number(e));case"boolean":return["true","false","1","0","yes","no"].includes(e.toLowerCase());case"date":case"datetime":return!isNaN(Date.parse(e));default:return!0}}function Lr(e,n){const s={};return e.forEach((i,r)=>{const d=i.toLowerCase().replace(/[_\s-]/g,""),a=n.find(o=>{const u=o.name.toLowerCase().replace(/[_\s-]/g,""),b=o.label.toLowerCase().replace(/[_\s-]/g,"");return u===d||b===d});a&&(s[r]=a.name)}),s}function _r(e,n,s){const i=[],r={};for(const d of n){const a=e[d.csvIdx]??"";if(d.field.required&&!a){i.push({row:s,field:d.field.name,message:"Required field is empty"});continue}if(a&&!fn(a,d.field.type)){i.push({row:s,field:d.field.name,message:`Invalid ${d.field.type} value: "${a}"`});continue}r[d.field.name]=a}return{record:r,errors:i}}const $r=({onFileLoaded:e})=>{const[n,s]=l.useState(!1),[i,r]=l.useState(null),d=l.useCallback(a=>{if(r(null),!a.name.endsWith(".csv")){r("Only CSV files are supported.");return}const o=new FileReader;o.onload=u=>{const b=Mr(u.target?.result);if(b.length<2){r("File must contain a header row and at least one data row.");return}e(b[0],b.slice(1))},o.readAsText(a)},[e]);return t.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[t.jsxs("div",{className:Z("flex w-full flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-10 transition-colors",n?"border-primary bg-primary/5":"border-muted-foreground/25"),onDragOver:a=>{a.preventDefault(),s(!0)},onDragLeave:()=>s(!1),onDrop:a=>{a.preventDefault(),s(!1);const o=a.dataTransfer.files[0];o&&d(o)},children:[t.jsx(Si,{className:"h-10 w-10 text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag & drop a CSV file here, or click to browse"}),t.jsxs("label",{children:[t.jsx("input",{type:"file",accept:".csv",className:"hidden",onChange:a=>{const o=a.target.files?.[0];o&&d(o)}}),t.jsx(ne,{variant:"outline",size:"sm",asChild:!0,children:t.jsx("span",{children:"Browse Files"})})]})]}),i&&t.jsxs("p",{className:"flex items-center gap-1 text-sm text-destructive",children:[t.jsx(an,{className:"h-4 w-4"})," ",i]})]})},Pr=({headers:e,fields:n,mapping:s,onMappingChange:i})=>{const r=l.useMemo(()=>new Set(Object.values(s)),[s]),d=l.useCallback((a,o)=>{const u={...s};o==="__skip__"?delete u[a]:u[a]=o,i(u)},[s,i]);return t.jsx("div",{className:"max-h-[360px] overflow-auto",children:t.jsxs(Hs,{children:[t.jsx(Gs,{children:t.jsxs(Tt,{children:[t.jsx(ht,{children:"CSV Column"}),t.jsx(ht,{children:"Maps To"}),t.jsx(ht,{className:"w-24 text-center",children:"Status"})]})}),t.jsx(Ys,{children:e.map((a,o)=>t.jsxs(Tt,{children:[t.jsx(gt,{className:"font-medium",children:a}),t.jsx(gt,{children:t.jsxs(jt,{value:s[o]??"__skip__",onValueChange:u=>d(o,u),children:[t.jsx(wt,{className:"h-8 w-56",children:t.jsx(vt,{placeholder:"Skip column"})}),t.jsxs(Nt,{children:[t.jsx(tt,{value:"__skip__",children:"— Skip —"}),n.map(u=>t.jsxs(tt,{value:u.name,disabled:r.has(u.name)&&s[o]!==u.name,children:[u.label,u.required?" *":""]},u.name))]})]})}),t.jsx(gt,{className:"text-center",children:s[o]?t.jsx(Ke,{variant:"default",className:"text-xs",children:"Mapped"}):t.jsx(Ke,{variant:"secondary",className:"text-xs",children:"Skipped"})})]},o))})]})})},qr=({headers:e,rows:n,mapping:s,fields:i})=>{const r=l.useMemo(()=>Object.entries(s).map(([u,b])=>({csvIdx:Number(u),header:e[Number(u)],field:i.find(h=>h.name===b)})),[s,e,i]),d=n.slice(0,zr),a=l.useMemo(()=>d.map((u,b)=>{const h={};for(const c of r){const x=u[c.csvIdx]??"";c.field.required&&!x?h[c.csvIdx]="Required":x&&!fn(x,c.field.type)&&(h[c.csvIdx]=`Invalid ${c.field.type}`)}return h}),[d,r]),o=a.filter(u=>Object.keys(u).length>0).length;return t.jsxs("div",{className:"max-h-[360px] overflow-auto",children:[o>0&&t.jsxs("p",{className:"mb-2 flex items-center gap-1 text-xs text-destructive",children:[t.jsx(an,{className:"h-3.5 w-3.5"})," ",o," row(s) with errors in preview"]}),t.jsxs(Hs,{children:[t.jsx(Gs,{children:t.jsxs(Tt,{children:[t.jsx(ht,{className:"w-12",children:"#"}),r.map(u=>t.jsx(ht,{children:u.field.label},u.csvIdx))]})}),t.jsx(Ys,{children:d.map((u,b)=>{const h=a[b],c=Object.keys(h).length>0;return t.jsxs(Tt,{className:Z(c&&"bg-destructive/5"),children:[t.jsx(gt,{className:"text-xs text-muted-foreground",children:b+1}),r.map(x=>{const y=u[x.csvIdx]??"",w=h[x.csvIdx];return t.jsx(gt,{className:Z(w&&"text-destructive"),title:w,children:y||t.jsx("span",{className:"text-muted-foreground/50",children:"—"})},x.csvIdx)})]},b)})})]}),t.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Showing ",d.length," of ",n.length," rows"]})]})},Br=({objectName:e,objectLabel:n,fields:s,dataSource:i,onComplete:r,onCancel:d,open:a,onOpenChange:o,onErrorMode:u="skip"})=>{const[b,h]=l.useState("upload"),[c,x]=l.useState([]),[y,w]=l.useState([]),[f,P]=l.useState({}),[A,v]=l.useState(!1),[H,Q]=l.useState(0),[D,g]=l.useState(null),p=n??e,N=l.useMemo(()=>{const U=new Set(Object.values(f));return s.filter(V=>V.required&&!U.has(V.name))},[s,f]),T=l.useCallback((U,V)=>{x(U),w(V),P(Lr(U,s)),h("mapping")},[s]),q=l.useCallback(async()=>{v(!0),Q(0);const U=[];let V=0,I=0;const z=Object.entries(f).map(([W,se])=>({csvIdx:Number(W),field:s.find(ee=>ee.name===se)}));for(let W=0;W<y.length;W++){const{record:se,errors:ee}=_r(y[W],z,W+1);if(ee.length>0){if(I++,U.push(...ee),u==="stop")break}else try{i?.create&&await i.create(e,se),V++}catch(Ie){I++;const S=Ie instanceof Error?Ie.message:"Failed to create record";if(U.push({row:W+1,field:"",message:S}),u==="stop")break}Q(Math.round((W+1)/y.length*100))}const B={totalRows:y.length,importedRows:V,skippedRows:I,errors:U};g(B),v(!1),r?.(B)},[y,f,s,i,e,r,u]),K=l.useCallback(()=>{h("upload"),x([]),w([]),P({}),Q(0),g(null)},[]),O=l.useCallback(()=>{K(),o?.(!1),d?.()},[K,o,d]);return t.jsx(Xt,{open:a,onOpenChange:U=>{U?o?.(U):O()},children:t.jsxs(Ws,{className:"sm:max-w-2xl",children:[t.jsxs(Zt,{children:[t.jsxs(es,{className:"flex items-center gap-2",children:[t.jsx(vi,{className:"h-5 w-5"})," Import ",p]}),t.jsxs(ts,{children:[b==="upload"&&"Upload a CSV file to get started.",b==="mapping"&&"Map CSV columns to object fields.",b==="preview"&&"Review data before importing."]})]}),t.jsx("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground",children:["upload","mapping","preview"].map((U,V)=>t.jsxs(_e.Fragment,{children:[V>0&&t.jsx(Ss,{className:"h-3 w-3"}),t.jsxs("span",{className:Z("rounded-full px-3 py-1",b===U?"bg-primary text-primary-foreground":"bg-muted"),children:[V+1,". ",U==="upload"?"Upload":U==="mapping"?"Mapping":"Preview"]})]},U))}),D?t.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[t.jsx(Ni,{className:"h-10 w-10 text-green-500"}),t.jsx("p",{className:"text-lg font-semibold",children:"Import Complete"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs(Ke,{variant:"default",children:[D.importedRows," imported"]}),D.skippedRows>0&&t.jsxs(Ke,{variant:"destructive",children:[D.skippedRows," skipped"]})]}),D.errors.length>0&&t.jsxs("div",{className:"max-h-32 w-full overflow-auto rounded border p-2 text-xs",children:[D.errors.slice(0,10).map((U,V)=>t.jsxs("p",{className:"text-destructive",children:["Row ",U.row,U.field?` (${U.field})`:"",": ",U.message]},V)),D.errors.length>10&&t.jsxs("p",{className:"text-muted-foreground",children:["…and ",D.errors.length-10," more errors"]})]})]}):t.jsxs(t.Fragment,{children:[b==="upload"&&t.jsx($r,{onFileLoaded:T}),b==="mapping"&&t.jsx(Pr,{headers:c,fields:s,mapping:f,onMappingChange:P}),b==="preview"&&t.jsx(qr,{headers:c,rows:y,mapping:f,fields:s}),A&&t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(_n,{value:H,className:"h-2"}),t.jsxs("p",{className:"text-center text-xs text-muted-foreground",children:["Importing… ",H,"%"]})]})]}),t.jsx($n,{className:"gap-2 sm:gap-0",children:D?t.jsx(ne,{onClick:O,children:"Close"}):t.jsxs(t.Fragment,{children:[t.jsxs(ne,{variant:"ghost",onClick:O,disabled:A,children:[t.jsx(ln,{className:"mr-1 h-4 w-4"})," Cancel"]}),(b==="mapping"||b==="preview")&&t.jsxs(ne,{variant:"outline",onClick:()=>h(b==="mapping"?"upload":"mapping"),disabled:A,children:[t.jsx(Ci,{className:"mr-1 h-4 w-4"})," Back"]}),b==="mapping"&&t.jsxs(ne,{onClick:()=>h("preview"),disabled:Object.keys(f).length===0||N.length>0,children:["Next ",t.jsx(Ss,{className:"ml-1 h-4 w-4"})]}),b==="preview"&&t.jsx(ne,{onClick:q,disabled:A,children:A?"Importing…":`Import ${y.length} Rows`})]})})]})})},pn=({schema:e,...n})=>{const{dataSource:s}=sn()||{};return t.jsx(cn,{schema:e,dataSource:s,...n})};Te.register("object-grid",pn,{namespace:"plugin-grid",label:"Object Grid",category:"plugin",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"},{name:"filters",type:"array",label:"Filters"}]});Te.register("grid",pn,{namespace:"view",label:"Data Grid",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"},{name:"filters",type:"array",label:"Filters"}]});const Kr=({schema:e,...n})=>{const{dataSource:s}=sn()||{};return t.jsx(Br,{objectName:e.objectName,objectLabel:e.objectLabel,fields:e.fields??[],dataSource:s,...n})};Te.register("import-wizard",Kr,{namespace:"plugin-grid",label:"Import Wizard",category:"plugin",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"fields",type:"array",label:"Fields",required:!0}]});const Ur={list:"List",detail:"Detail",grid:"Grid",kanban:"Kanban",calendar:"Calendar",timeline:"Timeline",map:"Map",gallery:"Gallery",gantt:"Gantt"},Wr={list:Vi,detail:Ai,grid:Ii,kanban:on,calendar:It,timeline:Ti,map:Ei,gallery:Di,gantt:Oi},Hr=dt("flex gap-4",{variants:{position:{top:"flex-col",bottom:"flex-col-reverse",left:"flex-row",right:"flex-row-reverse"}},defaultVariants:{position:"top"}}),Gr=dt("w-full",{variants:{orientation:{horizontal:"w-full",vertical:"w-48"}},defaultVariants:{orientation:"horizontal"}}),Yr=dt("flex gap-2",{variants:{orientation:{horizontal:"flex-row flex-wrap",vertical:"flex-col"}},defaultVariants:{orientation:"horizontal"}}),Jr=dt("",{variants:{orientation:{horizontal:"",vertical:"flex h-auto flex-col items-stretch"}},defaultVariants:{orientation:"horizontal"}});function Qr(e){return e.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}const Xr={Home:"House"};function mn(e){if(!e)return null;const n=Qr(e),s=Xr[n]||n;return ki[s]||null}function Kt(e){return e.label?e.label:Ur[e.type]||e.type}function $s(e){return e.icon?mn(e.icon):Wr[e.type]||null}function Zr(e){return e.activeView?e.activeView:e.defaultView?e.defaultView:e.views?.[0]?.type}const Ps={share:At,settings:Fi,duplicate:as,delete:ls},el={share:"Share",settings:"Settings",duplicate:"Duplicate",delete:"Delete"},bn=({schema:e,className:n,onViewChange:s,onCreateView:i,onViewAction:r,createViewLabel:d="Create view",...a})=>{const o=l.useMemo(()=>e.storageKey?e.storageKey:`view-switcher${e.id?`-${e.id}`:""}`,[e.id,e.storageKey]),[u,b]=l.useState(()=>Zr(e));l.useEffect(()=>{if(e.activeView){b(e.activeView);return}if(e.persistPreference)try{const p=localStorage.getItem(o);if(p){const N=e.views.find(T=>T.type===p)?.type;N&&b(N)}}catch{}},[e.activeView,e.persistPreference,e.views,o]),l.useEffect(()=>{if(!(!e.persistPreference||!u||e.activeView))try{localStorage.setItem(o,u)}catch{}},[u,e.activeView,e.persistPreference,o]);const h=l.useCallback(p=>{s?.(p),e.onViewChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onViewChange,{detail:{view:p}}))},[s,e.onViewChange]),c=l.useCallback(p=>{b(p),h(p)},[h]),x=u||e.views?.[0]?.type,y=x||"",w=e.views.find(p=>p.type===x)||e.views?.[0],f=e.variant||"tabs",P=e.position||"top",A=P==="left"||P==="right",v=A?"vertical":"horizontal",H=e.viewActions&&e.viewActions.length>0?t.jsx("div",{className:"flex items-center gap-1",children:e.viewActions.map((p,N)=>{const T=p.icon&&mn(p.icon)||Ps[p.type];return t.jsx(ne,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>r?.(p.type,x),title:el[p.type]||p.type,children:T?t.jsx(T,{className:"h-3.5 w-3.5"}):null},`action-${p.type}-${N}`)})}):null,Q=e.allowCreateView?t.jsx(ne,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>i?.(),title:d,children:t.jsx(os,{className:"h-3.5 w-3.5"})}):null,D=t.jsxs("div",{className:Z(Gr({orientation:v}),"flex items-center gap-1"),children:[f==="dropdown"&&t.jsxs(jt,{value:y,onValueChange:p=>c(p),children:[t.jsx(wt,{className:Z("w-full",A?"h-10":"h-9"),children:t.jsx(vt,{placeholder:"Select view"})}),t.jsx(Nt,{children:e.views.map((p,N)=>t.jsx(tt,{value:p.type,children:Kt(p)},`${p.type}-${N}`))})]}),f==="buttons"&&t.jsx("div",{className:Z(Yr({orientation:v})),children:e.views.map((p,N)=>{const T=p.type===x,q=$s(p);return t.jsxs(ne,{type:"button",size:"sm",variant:T?"secondary":"ghost",className:Z("justify-start gap-2",A?"w-full":""),onClick:()=>c(p.type),children:[q?t.jsx(q,{className:"h-4 w-4"}):null,t.jsx("span",{children:Kt(p)})]},`${p.type}-${N}`)})}),f==="tabs"&&t.jsx(Yt,{value:y,onValueChange:p=>c(p),children:t.jsx(Jt,{className:Z(Jr({orientation:v})),children:e.views.map((p,N)=>{const T=$s(p);return t.jsxs(Qt,{value:p.type,className:Z("gap-2",A?"justify-start":""),children:[T?t.jsx(T,{className:"h-4 w-4"}):null,t.jsx("span",{children:Kt(p)})]},`${p.type}-${N}`)})})}),H,Q]}),g=w?.schema?Array.isArray(w.schema)?t.jsx("div",{className:"space-y-4",children:w.schema.map((p,N)=>t.jsx(Re,{schema:p,...a},`${w.type}-${N}`))}):t.jsx(Re,{schema:w.schema,...a}):null;return t.jsxs("div",{className:Z(Hr({position:P}),n),children:[t.jsx("div",{className:Z("shrink-0",A?"flex flex-col":"flex"),children:D}),t.jsx("div",{className:"flex-1 min-w-0",children:g})]})};let Et=null;try{Et=require("@object-ui/react").SchemaRenderer||null}catch{}const tl=({schema:e,dataSource:n,className:s,views:i,activeViewId:r,onViewChange:d,onRowClick:a,onEdit:o,renderListView:u,toolbarAddon:b,onCreateView:h,onViewAction:c})=>{const[x,y]=l.useState(null),[w,f]=l.useState(!1),[P,A]=l.useState("create"),[v,H]=l.useState(null),[Q,D]=l.useState(0),[g,p]=l.useState([]),[N,T]=l.useState(!1),[q,K]=l.useState({}),[O,U]=l.useState([]),V=e.listViews,I=V!=null&&Object.keys(V).length>0,[z,B]=l.useState(()=>e.defaultListView&&V?.[e.defaultListView]?e.defaultListView:V&&Object.keys(V)[0]||""),W=l.useMemo(()=>!I||!z?null:V[z]||null,[I,z,V]),se=l.useMemo(()=>i&&i.length>0?i:null,[i]),ee=se!=null&&se.length>0,Ie=r||se?.[0]?.id,S=se?.find(k=>k.id===Ie)||se?.[0],je=l.useMemo(()=>W?.type?W.type:S?.type?S.type:e.defaultViewType||"grid",[W,S,e.defaultViewType]),ae=e.navigation;l.useEffect(()=>{let k=!0;const _=async()=>{try{const G=await n.getObjectSchema(e.objectName);k&&y(G)}catch(G){console.error("Failed to fetch object schema:",G)}};return e.objectName&&n&&_(),()=>{k=!1}},[e.objectName,n]),l.useEffect(()=>{let k=!0;return(async()=>{if(!(je==="grid"&&!u)&&!(!n||!e.objectName)){T(!0);try{const G=W?.filter||S?.filter||e.table?.defaultFilters||[],Oe=Object.entries(q).filter(([,Ce])=>Ce!==void 0&&Ce!==""&&Ce!==null).map(([Ce,zt])=>[Ce,"=",zt]);let xe=[];G.length>0&&Oe.length>0?xe=["and",...G,...Oe]:Oe.length===1?xe=Oe[0]:Oe.length>1?xe=["and",...Oe]:xe=G;const Be=O.length>0?O.map(Ce=>({field:Ce.field,order:Ce.direction})):W?.sort||S?.sort||e.table?.defaultSort||void 0,ve=tn(x?.fields),Ne=await n.find(e.objectName,{$filter:xe.length>0?xe:void 0,$orderby:Be,$top:100,...ve.length>0?{$expand:ve}:{}});let Ae=[];Array.isArray(Ne)?Ae=Ne:Ne&&typeof Ne=="object"&&(Array.isArray(Ne.data)?Ae=Ne.data:Array.isArray(Ne.records)&&(Ae=Ne.records)),k&&p(Ae)}catch(G){console.error("ObjectView data fetch error:",G)}finally{k&&T(!1)}}})(),()=>{k=!1}},[e.objectName,n,je,q,O,Q,W,S,u,x]);const ze=e.layout||"drawer",de=e.operations||e.table?.operations||{create:!0,read:!0,update:!0,delete:!0},Me=l.useCallback(()=>{ze==="page"&&e.onNavigate?e.onNavigate("new","edit"):(A("create"),H(null),f(!0))},[ze,e]),ye=l.useCallback(k=>{if(o){o(k);return}if(ze==="page"&&e.onNavigate){const _=k._id||k.id;e.onNavigate(_,"edit")}else A("edit"),H(k),f(!0)},[ze,e,o]),ke=l.useCallback(k=>{if(ze==="page"&&e.onNavigate){const _=k._id||k.id;e.onNavigate(_,"view")}else A("view"),H(k),f(!0)},[ze,e]),F=l.useCallback(k=>{if(a){a(k);return}if(ae){if(ae.mode==="none"||ae.preventNavigation)return;if(ae.mode==="new_window"||ae.openNewTab){const _=k._id||k.id,G=`/${e.objectName}/${_}`;window.open(G,"_blank");return}if(ae.mode==="drawer"){A("view"),H(k),f(!0);return}if(ae.mode==="modal"){A("view"),H(k),f(!0);return}if(ae.mode==="page"){const _=k._id||k.id;e.onNavigate&&e.onNavigate(_,"view");return}if(ae.mode==="split"||ae.mode==="popover"){A("view"),H(k),f(!0);return}}de.read!==!1&&ke(k)},[a,ae,de.read,ke,e]),ue=l.useCallback(k=>{D(_=>_+1)},[]),me=l.useCallback(k=>{D(_=>_+1)},[]),he=l.useCallback(()=>{f(!1),H(null),D(k=>k+1)},[]),fe=l.useCallback(()=>{f(!1),H(null)},[]);l.useCallback(()=>{D(k=>k+1)},[]);const be=l.useMemo(()=>!ee||!se||se.length<=1?null:{type:"view-switcher",variant:"tabs",position:"top",persistPreference:!0,storageKey:`view-pref-${e.objectName}`,defaultView:S?.type||"grid",activeView:S?.type||"grid",views:se.map(k=>{const _={kanban:"kanban",calendar:"calendar",map:"map",gallery:"layout-grid",timeline:"activity",gantt:"gantt-chart",grid:"table",list:"list",detail:"file-text"};return{type:k.type,label:k.label,icon:_[k.type]||"table"}}),allowCreateView:e.allowCreateView,viewActions:e.viewActions},[ee,se,S,e.objectName,e.allowCreateView,e.viewActions]),we=l.useCallback(k=>{if(!se)return;const _=se.find(G=>G.type===k);_&&d&&d(_.id)},[se,d]),Ct=l.useCallback(k=>{B(k)},[]);l.useMemo(()=>{if(e.showFilters===!1)return null;const k=e.filterableFields,_=x?.fields||{},Oe=(k?k.map(xe=>[xe,_[xe]||{label:xe}]):Object.entries(_).filter(([,xe])=>!xe.hidden).slice(0,8)).map(([xe,Be])=>{const ve=Be.type||"text";let Ne="text",Ae;return ve==="number"||ve==="currency"||ve==="percent"?Ne="number":ve==="boolean"||ve==="toggle"?Ne="boolean":ve==="date"||ve==="datetime"?Ne="date":(ve==="select"||Be.options)&&(Ne="select",Ae=(Be.options||[]).map(Ce=>typeof Ce=="string"?{label:Ce,value:Ce}:{label:Ce.label,value:Ce.value})),{field:xe,label:Be.label||xe,type:Ne,placeholder:`Filter ${Be.label||xe}...`,...Ae?{options:Ae}:{}}});return Oe.length===0?null:{type:"filter-ui",layout:"popover",showClear:!0,showApply:!0,filters:Oe,values:q}},[e.showFilters,e.filterableFields,x,q]);const nt=e.showSort;l.useMemo(()=>{if(nt===!1)return null;const k=x?.fields||{},_=Object.entries(k).filter(([,G])=>!G.hidden).slice(0,10).map(([G,Oe])=>({field:G,label:Oe.label||G}));return _.length===0?null:{type:"sort-ui",variant:"dropdown",multiple:!1,fields:_,sort:O}},[x,O,nt]);const it=l.useCallback(k=>{const _={objectName:e.objectName,fields:W?.columns||S?.columns||e.table?.fields,className:"h-full w-full",showSearch:S?.showSearch??e.showSearch??!1,showSort:S?.showSort??e.showSort??!1,showFilters:S?.showFilters??e.showFilters??!1,striped:S?.striped??!1,bordered:S?.bordered??!1,color:S?.color},G=W?.options||S||{};switch(k){case"kanban":return{type:"object-kanban",..._,groupBy:G.kanban?.groupField||"status",groupField:G.kanban?.groupField||"status",titleField:G.kanban?.titleField||"name",cardFields:_.fields||[],...G.kanban||{}};case"calendar":return{type:"object-calendar",..._,startDateField:G.calendar?.startDateField||"start_date",endDateField:G.calendar?.endDateField||"end_date",titleField:G.calendar?.titleField||"name",...G.calendar||{}};case"gallery":return{type:"object-gallery",..._,imageField:G.gallery?.imageField,titleField:G.gallery?.titleField||"name",subtitleField:G.gallery?.subtitleField,...G.gallery||{}};case"timeline":return{type:"object-timeline",..._,dateField:G.timeline?.dateField||"created_at",titleField:G.timeline?.titleField||"name",...G.timeline||{}};case"gantt":return{type:"object-gantt",..._,startDateField:G.gantt?.startDateField||"start_date",endDateField:G.gantt?.endDateField||"end_date",progressField:G.gantt?.progressField||"progress",dependenciesField:G.gantt?.dependenciesField||"dependencies",...G.gantt||{}};case"map":return{type:"object-map",..._,locationField:G.map?.locationField||"location",...G.map||{}};default:return null}},[e.objectName,e.table?.fields,W,S]),Je=l.useMemo(()=>({type:"object-grid",objectName:e.objectName,title:e.table?.title,description:e.table?.description,fields:W?.columns||S?.columns||e.table?.fields,columns:W?.columns||S?.columns||e.table?.columns,operations:{...de,create:!1},defaultFilters:W?.filter||S?.filter||e.table?.defaultFilters,defaultSort:W?.sort||S?.sort||e.table?.defaultSort,pageSize:e.table?.pageSize,selectable:e.table?.selectable,striped:S?.striped??e.table?.striped,bordered:S?.bordered??e.table?.bordered,className:e.table?.className}),[e,de,W,S]),ge=()=>{const k=v?v._id||v.id:void 0;return{type:"object-form",objectName:e.objectName,mode:P,recordId:k,title:e.form?.title,description:e.form?.description,fields:e.form?.fields,customFields:e.form?.customFields,groups:e.form?.groups,layout:e.form?.layout,columns:e.form?.columns,showSubmit:e.form?.showSubmit,submitText:e.form?.submitText,showCancel:e.form?.showCancel,cancelText:e.form?.cancelText,showReset:e.form?.showReset,initialValues:e.form?.initialValues,readOnly:e.form?.readOnly||P==="view",className:e.form?.className,onSuccess:he,onCancel:fe}},ce=()=>{if(e.form?.title)return e.form.title;const k=x?.label||e.objectName;switch(P){case"create":return`Create ${k}`;case"edit":return`Edit ${k}`;case"view":return`View ${k}`;default:return k}},$e=l.useMemo(()=>{const k=ae?.width;return k?typeof k=="number"?`max-w-[${k}px]`:`max-w-[${k}]`:""},[ae]),ut=()=>t.jsx(Js,{open:w,onOpenChange:f,direction:"right",children:t.jsxs(Qs,{className:Z("w-full sm:max-w-2xl",$e),children:[t.jsxs(Xs,{children:[t.jsx(Zs,{children:ce()}),e.form?.description&&t.jsx(en,{children:e.form.description})]}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:t.jsx(yt,{schema:ge(),dataSource:n})})]})}),Ue=()=>t.jsx(Xt,{open:w,onOpenChange:f,children:t.jsxs(Ws,{className:Z("max-w-2xl max-h-[90vh] overflow-y-auto",$e),children:[t.jsxs(Zt,{children:[t.jsx(es,{children:ce()}),e.form?.description&&t.jsx(ts,{children:e.form.description})]}),t.jsx(yt,{schema:ge(),dataSource:n})]})}),Rt=l.useMemo(()=>Object.keys(q).some(_=>q[_]!==void 0&&q[_]!==""&&q[_]!==null)?Object.entries(q).filter(([,_])=>_!==void 0&&_!==""&&_!==null).map(([_,G])=>({field:_,operator:"equals",value:G})):W?.filter||S?.filter||e.table?.defaultFilters,[q,W,S,e.table?.defaultFilters]),cs=l.useMemo(()=>O.length>0?O:W?.sort||S?.sort||e.table?.defaultSort,[O,W,S,e.table?.defaultSort]),Pe=()=>{const k=`${e.objectName}-${z||S?.id||"default"}-${je}-${Q}`;if(u)return u({schema:{type:"list-view",objectName:e.objectName,viewType:je,fields:W?.columns||S?.columns||e.table?.fields,filters:Rt,sort:cs,rowHeight:S?.rowHeight,densityMode:S?.densityMode,groupBy:S?.groupBy,options:W?.options||S,showSearch:S?.showSearch??e.showSearch,showFilters:S?.showFilters??e.showFilters,showSort:S?.showSort??e.showSort,showHideFields:S?.showHideFields??e.showHideFields,showGroup:S?.showGroup??e.showGroup,showColor:S?.showColor??e.showColor,showDensity:S?.showDensity??e.showDensity,allowExport:S?.allowExport??e.allowExport,striped:S?.striped??e.striped,bordered:S?.bordered??e.bordered,color:S?.color??e.color,inlineEdit:S?.inlineEdit??e.inlineEdit,wrapHeaders:S?.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:S?.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:S?.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:S?.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:S?.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:S?.fieldTextColor??e.fieldTextColor,prefixField:S?.prefixField??e.prefixField,showDescription:S?.showDescription??e.showDescription,navigation:S?.navigation??e.navigation,selection:S?.selection??e.selection,pagination:S?.pagination??e.pagination,searchableFields:S?.searchableFields??e.searchableFields,filterableFields:S?.filterableFields??e.filterableFields,resizable:S?.resizable??e.resizable,hiddenFields:S?.hiddenFields??e.hiddenFields,rowActions:S?.rowActions??e.rowActions,bulkActions:S?.bulkActions??e.bulkActions,sharing:S?.sharing??e.sharing,addRecord:S?.addRecord??e.addRecord,conditionalFormatting:S?.conditionalFormatting??e.conditionalFormatting,quickFilters:S?.quickFilters??e.quickFilters,showRecordCount:S?.showRecordCount??e.showRecordCount,allowPrinting:S?.allowPrinting??e.allowPrinting,virtualScroll:S?.virtualScroll??e.virtualScroll,emptyState:S?.emptyState??e.emptyState,aria:S?.aria??e.aria,tabs:e.tabs},dataSource:n,onEdit:ye,onRowClick:F,className:"h-full"});if(je!=="grid"){const _=it(je);if(_&&Et)return t.jsx(Et,{schema:_,dataSource:n,data:g,loading:N},k);if(!Et)return t.jsx("div",{className:"flex items-center justify-center h-40 text-muted-foreground",children:t.jsxs("p",{children:["SchemaRenderer not available. Install @object-ui/react to render ",je," views."]})})}return t.jsx(cn,{schema:Je,dataSource:n,onRowClick:F,onEdit:de.update!==!1?ye:void 0,onDelete:de.delete!==!1?ue:void 0,onBulkDelete:de.delete!==!1?me:void 0},k)},qe=()=>{if(!I)return null;const k=Object.entries(V);return k.length<=1?null:t.jsx(Yt,{value:z,onValueChange:Ct,className:"w-full",children:t.jsx(Jt,{className:"w-auto",children:k.map(([_,G])=>t.jsx(Qt,{value:_,className:"text-sm",children:G.label||_},_))})})},ft=()=>{const k=e.showCreate!==!1&&de.create!==!1,_=e.showViewSwitcher===!0,G=qe();return!G&&!_&&!k&&!b?null:t.jsxs("div",{className:"flex flex-col gap-3",children:[G,(_||k||b)&&t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsx("div",{className:"flex items-center gap-2",children:_&&be&&t.jsx(bn,{schema:be,onViewChange:we,onCreateView:h,onViewAction:c,className:"overflow-x-auto"})}),t.jsxs("div",{className:"flex items-center gap-2",children:[b,k&&t.jsxs(ne,{size:"sm",onClick:Me,children:[t.jsx(os,{className:"h-4 w-4"}),"Create"]})]})]})]})},rt=ae?.mode==="modal"?"modal":ae?.mode==="drawer"?"drawer":ae?.mode==="split"?"split":ae?.mode==="popover"?"popover":ze,Qe=k=>t.jsx("div",{className:"space-y-3",children:t.jsx(yt,{schema:ge(),dataSource:n})}),lt=l.useCallback(k=>{k||fe()},[fe]);if(rt==="split"){const k=x?.label||e.objectName;return t.jsxs("div",{className:Z("flex flex-col h-full min-w-0 overflow-hidden",s),children:[(e.title||e.description)&&t.jsxs("div",{className:"mb-4 shrink-0",children:[e.title&&t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e.title}),e.description&&t.jsx("p",{className:"text-muted-foreground mt-1",children:e.description})]}),t.jsx("div",{className:"mb-4 shrink-0",children:ft()}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:w&&v?t.jsx(xt,{isOpen:w,selectedRecord:v,mode:"split",close:fe,setIsOpen:lt,width:ae?.width,isOverlay:!0,title:`${k} Detail`,mainContent:t.jsx("div",{className:"h-full overflow-auto",children:Pe()}),children:Qe}):Pe()})]})}return t.jsxs("div",{className:Z("flex flex-col h-full min-w-0 overflow-hidden",s),children:[(e.title||e.description)&&t.jsxs("div",{className:"mb-4 shrink-0",children:[e.title&&t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e.title}),e.description&&t.jsx("p",{className:"text-muted-foreground mt-1",children:e.description})]}),t.jsx("div",{className:"mb-4 shrink-0",children:ft()}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:Pe()}),rt==="drawer"&&ut(),rt==="modal"&&Ue(),rt==="popover"&&w&&v&&t.jsx(xt,{isOpen:w,selectedRecord:v,mode:"popover",close:fe,setIsOpen:lt,width:ae?.width,isOverlay:!0,title:ce(),children:Qe})]})},Ut=dt("flex",{variants:{layout:{inline:"flex-col space-y-4",popover:"items-center",drawer:"items-center"}},defaultVariants:{layout:"inline"}}),sl=e=>e==null||e===""?!0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.values(e).every(n=>n==null||n===""):!1,nl=e=>Array.isArray(e)?{start:e[0]||"",end:e[1]||""}:e&&typeof e=="object"?{start:e.start||"",end:e.end||""}:{start:"",end:""},il=({schema:e,className:n,onChange:s})=>{const[i,r]=l.useState(e.values||{}),[d,a]=l.useState(!1);l.useEffect(()=>{e.values&&r(e.values)},[e.values]);const o=l.useCallback(f=>{s?.(f),e.onChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{values:f}}))},[s,e.onChange]),u=l.useCallback((f,P)=>{const A={...i,[f]:P};r(A),e.showApply||o(A)},[o,e.showApply,i]),b=l.useCallback(()=>{const f={};if(r(f),e.showApply){o(f);return}o(f)},[o,e.showApply]),h=l.useCallback(()=>{o(i),a(!1)},[o,i]),c=l.useMemo(()=>Object.values(i).filter(f=>!sl(f)).length,[i]),x=f=>{const P=f.label||f.field,A=f.placeholder||`Filter by ${P}`;switch(f.type){case"number":return t.jsx(He,{type:"number",value:i[f.field]??"",placeholder:A,onChange:v=>{const H=v.target.value,Q=H===""?"":Number(H);u(f.field,Q)}});case"select":return t.jsxs(jt,{value:i[f.field]!==void 0?String(i[f.field]):"",onValueChange:v=>{const H=f.options?.find(Q=>String(Q.value)===v);u(f.field,H?H.value:v)},children:[t.jsx(wt,{children:t.jsx(vt,{placeholder:A})}),t.jsx(Nt,{children:f.options?.map(v=>t.jsx(tt,{value:String(v.value),children:v.label},String(v.value)))})]});case"date":return t.jsx(He,{type:"date",value:i[f.field]??"",onChange:v=>u(f.field,v.target.value)});case"date-range":{const v=nl(i[f.field]);return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(He,{type:"date",value:v.start??"",onChange:H=>{u(f.field,{...v,start:H.target.value})}}),t.jsx(He,{type:"date",value:v.end??"",onChange:H=>{u(f.field,{...v,end:H.target.value})}})]})}case"boolean":return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qn,{checked:!!i[f.field],onCheckedChange:v=>u(f.field,!!v)}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"Enabled"})]});case"text":default:return t.jsx(He,{value:i[f.field]??"",placeholder:A,onChange:v=>u(f.field,v.target.value)})}},y=t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:e.filters.map(f=>t.jsxs("div",{className:"space-y-2",children:[t.jsx(Pn,{className:"text-xs text-muted-foreground",children:f.label||f.field}),x(f)]},f.field))}),(e.showApply||e.showClear)&&t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t pt-3",children:[e.showClear&&t.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:b,children:"Clear"}),e.showApply&&t.jsx(ne,{type:"button",size:"sm",onClick:h,children:"Apply"})]})]}),w=e.layout||"inline";return w==="popover"?t.jsx("div",{className:Z(Ut({layout:w}),n),children:t.jsxs(ss,{open:d,onOpenChange:a,children:[t.jsx(ns,{asChild:!0,children:t.jsxs(ne,{type:"button",variant:c>0?"secondary":"outline",size:"sm",className:"gap-2",children:[t.jsx(Fs,{className:"h-4 w-4"}),"Filters",c>0&&t.jsx("span",{className:"inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary",children:c})]})}),t.jsx(is,{align:"start",className:"w-[520px] p-4",children:y})]})}):w==="drawer"?t.jsxs("div",{className:Z(Ut({layout:w}),n),children:[t.jsxs(ne,{type:"button",variant:c>0?"secondary":"outline",size:"sm",className:"gap-2",onClick:()=>a(!0),children:[t.jsx(Fs,{className:"h-4 w-4"}),"Filters",c>0&&t.jsx("span",{className:"inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary",children:c})]}),t.jsx(Js,{open:d,onOpenChange:a,children:t.jsxs(Qs,{children:[t.jsxs(Xs,{children:[t.jsx(Zs,{children:"Filters"}),t.jsx(en,{children:"Refine the data with advanced filters."})]}),t.jsx("div",{className:"px-4 pb-6",children:y})]})})]}):t.jsxs("div",{className:Z(Ut({layout:w}),n),children:[y,!e.showApply&&e.showClear&&t.jsxs(ne,{type:"button",variant:"ghost",size:"sm",className:"gap-2",onClick:b,children:[t.jsx(ln,{className:"h-3.5 w-3.5"}),"Clear filters"]})]})},Wt=dt("",{variants:{variant:{buttons:"flex flex-wrap gap-2",dropdown:"flex flex-wrap items-center gap-3",builder:"space-y-3"}},defaultVariants:{variant:"dropdown"}}),Ht=e=>e?e.map(n=>({field:n.field,direction:n.direction})):[],qs=e=>e.map(n=>({id:`${n.field}-${n.direction}`,field:n.field,order:n.direction})),rl=e=>e.filter(n=>n.field).map(n=>({field:n.field,direction:n.order})),ll=({schema:e,className:n,onChange:s})=>{const[i,r]=l.useState(()=>Ht(e.sort)),[d,a]=l.useState(()=>qs(Ht(e.sort)));l.useEffect(()=>{const c=Ht(e.sort);r(c),a(qs(c))},[e.sort]);const o=l.useCallback(c=>{r(c),s?.(c),e.onChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{sort:c}}))},[s,e.onChange]),u=l.useCallback(c=>{const x=i.find(f=>f.field===c),y=!!e.multiple;if(!x){const f=y?[...i,{field:c,direction:"asc"}]:[{field:c,direction:"asc"}];o(f);return}if(x.direction==="asc"){const f=i.map(P=>P.field===c?{...P,direction:"desc"}:P);o(f);return}const w=i.filter(f=>f.field!==c);o(w)},[o,e.multiple,i]);if((e.variant||"dropdown")==="buttons")return t.jsx("div",{className:Z(Wt({variant:"buttons"}),n),children:e.fields.map(c=>{const x=i.find(w=>w.field===c.field),y=x?.direction==="asc"?Ri:zi;return t.jsxs(ne,{type:"button",variant:x?"secondary":"outline",size:"sm",onClick:()=>u(c.field),className:"gap-2",children:[t.jsx("span",{children:c.label||c.field}),x&&t.jsx(y,{className:"h-3.5 w-3.5"})]},c.field)})});if(e.multiple)return t.jsx("div",{className:Z(Wt({variant:"builder"}),n),children:t.jsx(Bn,{fields:e.fields.map(c=>({value:c.field,label:c.label||c.field})),value:d,onChange:c=>{a(c),o(rl(c))}})});const h=i[0];return t.jsxs("div",{className:Z(Wt({variant:"dropdown"}),n),children:[t.jsxs(jt,{value:h?.field||"",onValueChange:c=>{if(!c){o([]);return}o([{field:c,direction:h?.direction||"asc"}])},children:[t.jsx(wt,{className:"w-56",children:t.jsx(vt,{placeholder:"Select field"})}),t.jsx(Nt,{children:e.fields.map(c=>t.jsx(tt,{value:c.field,children:c.label||c.field},c.field))})]}),t.jsxs(jt,{value:h?.direction||"asc",onValueChange:c=>{h?.field&&o([{field:h.field,direction:c}])},children:[t.jsx(wt,{className:"w-36",children:t.jsx(vt,{})}),t.jsxs(Nt,{children:[t.jsx(tt,{value:"asc",children:"Ascending"}),t.jsx(tt,{value:"desc",children:"Descending"})]})]})]})};function al(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)}function ol(e,n,s,i){return`${e}/share/${n}/${s}?mode=readonly&token=${i}`}const dl=({objectName:e,viewId:n="default",baseUrl:s,onShare:i,className:r})=>{const[d,a]=l.useState(null),[o,u]=l.useState(!1),[b,h]=l.useState(!1),[c,x]=l.useState(""),[y,w]=l.useState(""),f=s??(typeof window<"u"?window.location.origin:""),P=l.useCallback(()=>{const v=al(),H=ol(f,e,n,v);a(H),u(!1);const Q=y?new Date(Date.now()+parseInt(y,10)*864e5).toISOString():void 0;i?.(H,{password:c||void 0,expiresAt:Q})},[f,e,n,i,c,y]),A=l.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(d),u(!0),setTimeout(()=>u(!1),2e3)}catch{const v=document.createElement("textarea");v.value=d,document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v),u(!0),setTimeout(()=>u(!1),2e3)}},[d]);return t.jsxs(ss,{open:b,onOpenChange:h,children:[t.jsx(ns,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",className:Z("gap-2",r),children:[t.jsx(At,{className:"h-4 w-4"}),"Share"]})}),t.jsxs(is,{className:"w-96 space-y-4",align:"end",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h4",{className:"text-sm font-medium",children:"Share View"}),t.jsx(Ke,{variant:"secondary",className:"text-xs",children:"Read-only"})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate a public link to share this view. Recipients can view data without logging in."})]}),d?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(He,{value:d,readOnly:!0,className:"h-8 text-xs",onClick:v=>v.target.select()}),t.jsx(ne,{variant:"outline",size:"sm",onClick:A,className:"shrink-0 gap-1",children:o?t.jsx(rn,{className:"h-4 w-4 text-green-500"}):t.jsx(as,{className:"h-4 w-4"})})]}),(c||y)&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c&&t.jsxs(Ke,{variant:"outline",className:"text-xs gap-1",children:[t.jsx(Gt,{className:"h-3 w-3"}),"Password protected"]}),y&&t.jsxs(Ke,{variant:"outline",className:"text-xs gap-1",children:[t.jsx(It,{className:"h-3 w-3"}),"Expires in ",y," day",y!=="1"?"s":""]})]})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-foreground",children:[t.jsx(Gt,{className:"h-3.5 w-3.5"}),"Password protection (optional)"]}),t.jsx(He,{type:"password",value:c,onChange:v=>x(v.target.value),placeholder:"Enter password...",className:"h-8 text-xs"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-foreground",children:[t.jsx(It,{className:"h-3.5 w-3.5"}),"Expires after (optional)"]}),t.jsxs("select",{value:y,onChange:v=>w(v.target.value),className:"w-full h-8 text-xs rounded-md border border-input bg-background px-3",children:[t.jsx("option",{value:"",children:"Never"}),t.jsx("option",{value:"1",children:"1 day"}),t.jsx("option",{value:"7",children:"7 days"}),t.jsx("option",{value:"30",children:"30 days"}),t.jsx("option",{value:"90",children:"90 days"})]})]}),t.jsxs(ne,{onClick:P,className:"w-full gap-2",size:"sm",children:[t.jsx(At,{className:"h-4 w-4"}),"Generate Link"]})]})]})]})},Ot={private:0,team:1,organization:2,public:3},cl=5,ul=({id:e,disabled:n,children:s})=>{const{attributes:i,listeners:r,setNodeRef:d,transform:a,transition:o,isDragging:u}=di({id:e,disabled:n}),b={transform:ci.Transform.toString(a),transition:o,zIndex:u?10:void 0,opacity:u?.5:void 0};return t.jsx(t.Fragment,{children:s({setNodeRef:d,style:b,listeners:r,attributes:i,isDragging:u})})},Sl=({views:e,activeViewId:n,onViewChange:s,viewTypeIcons:i={},config:r={},onAddView:d,onRenameView:a,onDuplicateView:o,onDeleteView:u,onSetDefaultView:b,onShareView:h,onSaveAsView:c,onPinView:x,onReorderViews:y,onChangeViewType:w,onConfigView:f,availableViewTypes:P,hasUnsavedChanges:A=!1,onResetChanges:v,className:H})=>{const{showAddButton:Q=!0,inlineRename:D=!0,contextMenu:g=!0,reorderable:p=!1,maxVisibleTabs:N=6,showIndicators:T=!0,showSaveAsView:q=!0,showPinnedSection:K=!0,showVisibilityGroups:O=!1}=r,[U,V]=l.useState(null),[I,z]=l.useState(""),B=l.useRef(null);l.useEffect(()=>{U&&B.current&&(B.current.focus(),B.current.select())},[U]);const W=l.useCallback(F=>{if(!D||!a)return;const ue=e.find(me=>me.id===F);ue&&(V(F),z(ue.label))},[D,a,e]),se=l.useCallback(()=>{U&&I.trim()&&a&&a(U,I.trim()),V(null),z("")},[U,I,a]),ee=l.useCallback(()=>{V(null),z("")},[]),Ie=l.useMemo(()=>{const F=[...e];return F.sort((ue,me)=>{if(K){const he=ue.isPinned?1:0,fe=me.isPinned?1:0;if(he!==fe)return fe-he}if(O){const he=Ot[ue.visibility||"public"]??Ot.public,fe=Ot[me.visibility||"public"]??Ot.public;if(he!==fe)return he-fe}return 0}),F},[e,K,O]),S=Ie.slice(0,N),je=Ie.slice(N),ae=ti(vs(ni,{activationConstraint:{distance:cl}}),vs(si)),ze=l.useCallback(F=>{const{active:ue,over:me}=F;if(!me||ue.id===me.id||!y)return;const he=Ie.findIndex(we=>we.id===ue.id),fe=Ie.findIndex(we=>we.id===me.id);if(he===-1||fe===-1)return;const be=ii(Ie,he,fe);y(be.map(we=>we.id))},[Ie,y]),de=Li,Me=l.useCallback(F=>{if(!O||F===0)return!1;const ue=S[F-1],me=S[F],he=fe=>fe.visibility==="private";return he(ue)&&!he(me)},[O,S]),ye=(F,ue)=>{const me=F.id===n,he=i[F.type]||de,fe=U===F.id,be=T&&(F.hasActiveFilters||F.hasActiveSort),we=Me(ue),nt=(ge=>O?ge.visibility==="private"?t.jsx(Gt,{"data-testid":`view-tab-visibility-${ge.id}`,className:"h-3 w-3 text-muted-foreground shrink-0"}):ge.visibility?t.jsx($i,{"data-testid":`view-tab-visibility-${ge.id}`,className:"h-3 w-3 text-muted-foreground shrink-0"}):null:null)(F),it=ge=>t.jsxs("button",{"data-testid":`view-tab-${F.id}`,onClick:()=>!fe&&s(F.id),onDoubleClick:()=>W(F.id),className:Z("inline-flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap relative",me?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"),children:[p&&y&&t.jsx("span",{"data-testid":`view-tab-drag-handle-${F.id}`,className:"cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground",...ge?.listeners??{},...ge?.attributes??{},children:t.jsx(Bi,{className:"h-3 w-3"})}),K&&F.isPinned&&t.jsx(qt,{"data-testid":`view-tab-pin-indicator-${F.id}`,className:"h-3 w-3 text-primary shrink-0"}),nt,t.jsx(he,{className:"h-3.5 w-3.5"}),fe?t.jsx(He,{ref:B,"data-testid":`view-tab-rename-input-${F.id}`,value:I,onChange:ce=>z(ce.target.value),onBlur:se,onKeyDown:ce=>{ce.key==="Enter"&&se(),ce.key==="Escape"&&ee()},className:"h-5 w-24 px-1 py-0 text-sm border-none focus-visible:ring-1",onClick:ce=>ce.stopPropagation()}):t.jsx("span",{children:F.label}),be&&t.jsxs(gs,{children:[t.jsx(ys,{asChild:!0,children:t.jsx("span",{"data-testid":`view-tab-indicator-${F.id}`,className:"ml-1 inline-flex items-center justify-center h-4 min-w-[16px] rounded-full bg-primary/15 text-[10px] font-medium text-primary px-1 shrink-0",children:[F.hasActiveFilters&&"F",F.hasActiveSort&&"S"].filter(Boolean).join("")})}),t.jsx(js,{side:"bottom",className:"text-xs",children:[F.hasActiveFilters&&"Active filters",F.hasActiveSort&&"Active sort"].filter(Boolean).join(", ")})]}),F.isDefault&&t.jsx(ks,{className:"h-3 w-3 text-amber-500 fill-amber-500 shrink-0"}),me&&f&&t.jsx("button",{type:"button","data-testid":`view-tab-config-${F.id}`,className:"ml-0.5 h-4 w-4 flex items-center justify-center rounded hover:bg-accent shrink-0 opacity-60 hover:opacity-100 transition-opacity",onClick:ce=>{ce.stopPropagation(),f(F.id)},"aria-label":`Configure ${F.label}`,children:t.jsx(Ki,{className:"h-3 w-3"})})]}),Je=ge=>!g||fe?ge:t.jsxs(Un,{children:[t.jsx(Wn,{asChild:!0,children:ge}),t.jsxs(Hn,{children:[a&&t.jsxs(et,{"data-testid":`context-menu-rename-${F.id}`,onClick:()=>W(F.id),children:[t.jsx(Pi,{className:"h-4 w-4 mr-2"})," Rename"]}),o&&t.jsxs(et,{"data-testid":`context-menu-duplicate-${F.id}`,onClick:()=>o(F.id),children:[t.jsx(as,{className:"h-4 w-4 mr-2"})," Duplicate View"]}),h&&t.jsxs(et,{"data-testid":`context-menu-share-${F.id}`,onClick:()=>h(F.id),children:[t.jsx(At,{className:"h-4 w-4 mr-2"})," Share View"]}),b&&t.jsxs(et,{"data-testid":`context-menu-default-${F.id}`,onClick:()=>b(F.id),children:[t.jsx(ks,{className:"h-4 w-4 mr-2"})," Set as Default"]}),x&&t.jsx(et,{"data-testid":`context-menu-pin-${F.id}`,onClick:()=>x(F.id,!F.isPinned),children:F.isPinned?t.jsxs(t.Fragment,{children:[t.jsx(qi,{className:"h-4 w-4 mr-2"})," Unpin View"]}):t.jsxs(t.Fragment,{children:[t.jsx(qt,{className:"h-4 w-4 mr-2"})," Pin View"]})}),w&&P&&P.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(ws,{}),t.jsxs(Gn,{children:[t.jsxs(Yn,{"data-testid":`context-menu-change-type-${F.id}`,children:[t.jsx(on,{className:"h-4 w-4 mr-2"})," Change View Type"]}),t.jsx(Jn,{"data-testid":`context-menu-type-submenu-${F.id}`,children:P.map(ce=>{const $e=i[ce.type]||de;return t.jsxs(et,{"data-testid":`context-menu-type-${F.id}-${ce.type}`,disabled:ce.type===F.type,onClick:()=>w(F.id,ce.type),children:[t.jsx($e,{className:"h-4 w-4 mr-2"}),t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{children:ce.label}),ce.description&&t.jsx("span",{className:"text-xs text-muted-foreground",children:ce.description})]})]},ce.type)})})]})]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(ws,{}),t.jsxs(et,{"data-testid":`context-menu-delete-${F.id}`,onClick:()=>u(F.id),className:"text-destructive focus:text-destructive",children:[t.jsx(ls,{className:"h-4 w-4 mr-2"})," Delete View"]})]})]})]});return p&&y?t.jsxs(_e.Fragment,{children:[we&&t.jsx("div",{"data-testid":"view-tab-visibility-separator",className:"w-px h-5 bg-border mx-1 self-center shrink-0"}),t.jsx(ul,{id:F.id,children:({setNodeRef:ge,style:ce,listeners:$e,attributes:ut,isDragging:Ue})=>t.jsx("div",{ref:ge,style:ce,className:Z("flex",Ue&&"z-10"),children:Je(it({listeners:$e,attributes:ut}))})})]},F.id):t.jsxs(_e.Fragment,{children:[we&&t.jsx("div",{"data-testid":"view-tab-visibility-separator",className:"w-px h-5 bg-border mx-1 self-center shrink-0"}),Je(it())]},F.id)},ke=t.jsx(t.Fragment,{children:S.map((F,ue)=>ye(F,ue))});return t.jsx(Kn,{children:t.jsxs("div",{"data-testid":"view-tab-bar",className:Z("flex items-center gap-0.5 -mb-px",H),children:[p&&y?t.jsx(ri,{sensors:ae,collisionDetection:li,onDragEnd:ze,children:t.jsx(ai,{items:S.map(F=>F.id),strategy:oi,children:t.jsx("div",{"data-testid":"view-tab-sortable-container",className:"flex items-center gap-0.5",children:ke})})}):ke,je.length>0&&t.jsxs(Bs,{children:[t.jsx(Ks,{asChild:!0,children:t.jsxs("button",{"data-testid":"view-tab-overflow",className:"inline-flex items-center gap-1 px-2 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx(Mi,{className:"h-4 w-4"}),t.jsxs("span",{className:"text-xs",children:[je.length," more"]})]})}),t.jsx(Us,{align:"end",children:je.map(F=>{const ue=i[F.type]||de;return t.jsxs(Dt,{"data-testid":`view-tab-overflow-${F.id}`,onClick:()=>s(F.id),children:[F.isPinned&&t.jsx(qt,{className:"h-3 w-3 mr-1 text-primary shrink-0"}),t.jsx(ue,{className:"h-4 w-4 mr-2"}),F.label,T&&(F.hasActiveFilters||F.hasActiveSort)&&t.jsx("span",{className:"ml-auto inline-flex items-center justify-center h-4 min-w-[16px] rounded-full bg-primary/15 text-[10px] font-medium text-primary px-1",children:[F.hasActiveFilters&&"F",F.hasActiveSort&&"S"].filter(Boolean).join("")})]},F.id)})})]}),Q&&d&&t.jsxs(gs,{children:[t.jsx(ys,{asChild:!0,children:t.jsx("button",{"data-testid":"view-tab-add",onClick:d,className:"inline-flex items-center px-2 py-2 text-muted-foreground hover:text-foreground transition-colors",children:t.jsx(os,{className:"h-4 w-4"})})}),t.jsx(js,{children:"Add View"})]}),q&&A&&t.jsxs("div",{"data-testid":"view-tab-save-as",className:"flex items-center gap-1 ml-2 text-xs text-amber-600 dark:text-amber-400",children:[t.jsx(_i,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"hidden sm:inline",children:"Unsaved changes"}),c&&t.jsx(ne,{variant:"ghost",size:"sm","data-testid":"view-tab-save-as-btn",className:"h-6 px-2 text-xs",onClick:c,children:"Save as View"}),v&&t.jsx(ne,{variant:"ghost",size:"sm","data-testid":"view-tab-reset-btn",className:"h-6 px-2 text-xs",onClick:v,children:"Reset"})]})]})})},fl=_e.createContext(null);let xn=fl;try{const e=require("@object-ui/react");e.SchemaRendererContext&&(xn=e.SchemaRendererContext)}catch{}const hn=({schema:e})=>{const s=l.useContext(xn)?.dataSource??null;return t.jsx(tl,{schema:e,dataSource:s})};Te.register("object-view",hn,{namespace:"plugin-view",label:"Object View",category:"view",icon:"LayoutDashboard",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"title",type:"string",label:"Title"},{name:"description",type:"string",label:"Description"},{name:"layout",type:"enum",label:"Form Layout",enum:["drawer","modal","page"]},{name:"defaultViewType",type:"enum",label:"Default View Type",enum:["grid","kanban","gallery","calendar","timeline","gantt","map"]},{name:"defaultListView",type:"string",label:"Default Named View"},{name:"showSearch",type:"boolean",label:"Show Search"},{name:"showFilters",type:"boolean",label:"Show Filters"},{name:"showCreate",type:"boolean",label:"Show Create Button"},{name:"showRefresh",type:"boolean",label:"Show Refresh Button"},{name:"showViewSwitcher",type:"boolean",label:"Show View Switcher"},{name:"listViews",type:"object",label:"Named List Views"},{name:"navigation",type:"object",label:"Navigation Config"},{name:"searchableFields",type:"array",label:"Searchable Fields"},{name:"filterableFields",type:"array",label:"Filterable Fields"}],defaultProps:{layout:"drawer",defaultViewType:"grid",showSearch:!0,showFilters:!0,showCreate:!0,showRefresh:!0,showViewSwitcher:!0}});Te.register("view",hn,{namespace:"plugin-view",label:"View",category:"view"});Te.register("view-switcher",bn,{namespace:"view",label:"View Switcher",category:"view",icon:"LayoutGrid",inputs:[{name:"views",type:"array",label:"Views",required:!0},{name:"defaultView",type:"string",label:"Default View"},{name:"activeView",type:"string",label:"Active View"},{name:"variant",type:"enum",label:"Variant",enum:["tabs","buttons","dropdown"]},{name:"position",type:"enum",label:"Position",enum:["top","bottom","left","right"]},{name:"persistPreference",type:"boolean",label:"Persist Preference"},{name:"storageKey",type:"string",label:"Storage Key"},{name:"onViewChange",type:"string",label:"On View Change Event"}],defaultProps:{variant:"tabs",position:"top",defaultView:"grid",views:[{type:"grid",label:"Grid",schema:{type:"text",content:"Grid view"}},{type:"list",label:"List",schema:{type:"text",content:"List view"}}]}});Te.register("filter-ui",il,{namespace:"view",label:"Filter UI",category:"view",icon:"SlidersHorizontal",inputs:[{name:"filters",type:"array",label:"Filters",required:!0},{name:"values",type:"object",label:"Values"},{name:"onChange",type:"string",label:"On Change Event"},{name:"showClear",type:"boolean",label:"Show Clear Button"},{name:"showApply",type:"boolean",label:"Show Apply Button"},{name:"layout",type:"enum",label:"Layout",enum:["inline","popover","drawer"]}],defaultProps:{layout:"inline",showApply:!1,showClear:!0,filters:[{field:"name",label:"Name",type:"text",placeholder:"Search name"},{field:"status",label:"Status",type:"select",options:[{label:"Open",value:"open"},{label:"Closed",value:"closed"}]},{field:"created_at",label:"Created",type:"date"}]}});Te.register("sort-ui",ll,{namespace:"view",label:"Sort UI",category:"view",icon:"ArrowUpDown",inputs:[{name:"fields",type:"array",label:"Fields",required:!0},{name:"sort",type:"array",label:"Sort"},{name:"onChange",type:"string",label:"On Change Event"},{name:"multiple",type:"boolean",label:"Allow Multiple"},{name:"variant",type:"enum",label:"Variant",enum:["dropdown","buttons"]}],defaultProps:{variant:"dropdown",multiple:!0,fields:[{field:"name",label:"Name"},{field:"created_at",label:"Created At"}],sort:[{field:"name",direction:"asc"}]}});Te.register("shared-view-link",dl,{namespace:"view",label:"Shared View Link",category:"view",icon:"Share2",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"viewId",type:"string",label:"View ID"},{name:"baseUrl",type:"string",label:"Base URL"}],defaultProps:{objectName:"objects",viewId:"default"}});const pl=({schema:e,className:n,children:s,dataSource:i,...r})=>{const d=e.props?.columns?{display:"grid",gridTemplateColumns:`repeat(${e.props.columns}, 1fr)`,gap:"1rem"}:void 0;return t.jsx("div",{className:n,style:d,...r,children:s})};Te.register("view:simple",pl,{namespace:"plugin-view",label:"Simple View",category:"view"});export{nr as M,tl as O,Sl as V,Cl as u};
|
|
Binary file
|
|
Binary file
|