@object-ui/console 3.0.3 → 3.1.1
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-D711bBuO.js +7 -0
- package/dist/assets/AppManagementPage-D_71FpIH.js +1 -0
- package/dist/assets/AuditLogPage-D3g_VEdE.js +1 -0
- package/dist/assets/AuthPageLayout-9l5xWV_-.js +1 -0
- package/dist/assets/{ChartImpl-2ivTljUi.js → ChartImpl-B9B4Fnbe.js} +1 -1
- package/dist/assets/CreateAppPage-mqt5j4rK.js +1 -0
- package/dist/assets/DashboardDesignPage-Cijb3jeF.js +1 -0
- package/dist/assets/DashboardView-DjhlMHLV.js +1 -0
- package/dist/assets/EditAppPage-BiK_DWcO.js +1 -0
- package/dist/assets/ForgotPasswordPage-Bzady8r_.js +1 -0
- package/dist/assets/KanbanEnhanced-OvdpYe81.js +1 -0
- package/dist/assets/KanbanImpl-EcxwmGw7.js +1 -0
- package/dist/assets/LoginPage-valW4Wu1.js +1 -0
- package/dist/assets/{MarkdownImpl-BshtTFK2.js → MarkdownImpl-C0wRapHT.js} +2 -2
- package/dist/assets/OrgManagementPage-D0d52PdP.js +1 -0
- package/dist/assets/PageDesignPage-hpFLdWCR.js +1 -0
- package/dist/assets/PageView-DxIAf-SB.js +2 -0
- package/dist/assets/PermissionManagementPage-ELCC8HyK.js +1 -0
- package/dist/assets/ProfilePage-Dj1N0mY3.js +1 -0
- package/dist/assets/RecordDetailView-DS9tEr5f.js +1 -0
- package/dist/assets/RegisterPage-DqUU8oW-.js +1 -0
- package/dist/assets/ReportView-CNi0A66t.js +1 -0
- package/dist/assets/RoleManagementPage-DRvuG53j.js +1 -0
- package/dist/assets/SearchResultsPage-nMlMQCb8.js +1 -0
- package/dist/assets/SystemHubPage-CAY-YvG2.js +1 -0
- package/dist/assets/UserManagementPage-fzvfJxav.js +1 -0
- package/dist/assets/data-adapter-rvE3xy2B.js +1 -0
- package/dist/assets/framework-BM176iet.js +10 -0
- package/dist/assets/index-B6cpm7bF.css +1 -0
- package/dist/assets/index-CTBPkbPG.js +9 -0
- package/dist/assets/index-Dv78M4Xq.js +1 -0
- package/dist/assets/infrastructure-n1j_TN6w.js +1 -0
- package/dist/assets/maplibre-gl-DVmJFhI2.js +811 -0
- package/dist/assets/plugins-core-qwgXbAqa.js +8 -0
- package/dist/assets/plugins-views-CveFN6PV.js +62 -0
- package/dist/assets/ui-components-BxvihT61.js +36 -0
- package/dist/assets/ui-components-CRV2BvKI.css +1 -0
- package/dist/assets/ui-layout-C6KWQtRO.js +1 -0
- package/dist/assets/{vendor-charts-CSvoW-yB.js → vendor-charts-BLNOCZWl.js} +2 -2
- package/dist/assets/vendor-dndkit-CX1oDZqy.js +5 -0
- package/dist/assets/vendor-i18n-E3-WitRV.js +9 -0
- package/dist/assets/{vendor-icons-CQ8b-fGy.js → vendor-icons-ndICq8DC.js} +3425 -3535
- package/dist/assets/vendor-objectstack-YKtcdalX.js +34 -0
- package/dist/assets/{vendor-radix-BbeYj_o4.js → vendor-radix-C6qchjxv.js} +1 -1
- package/dist/assets/vendor-react-9M-xu2bR.js +60 -0
- package/dist/assets/vendor-ui-utils-3tkeUVaX.js +1 -0
- package/dist/assets/vendor-zod-DxQVy2_o.js +39 -0
- package/dist/index.html +23 -22
- package/package.json +49 -46
- package/plugin.d.ts +1 -2
- package/plugin.js +1 -2
- package/plugin.ts +1 -2
- 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-DSh9LYBb.js +0 -1
- package/dist/assets/DashboardView-DSh9LYBb.js.br +0 -0
- package/dist/assets/DashboardView-DSh9LYBb.js.gz +0 -0
- package/dist/assets/ForgotPasswordPage-DUfjj-wh.js +0 -1
- package/dist/assets/KanbanEnhanced-ZOndyXyg.js +0 -1
- package/dist/assets/KanbanEnhanced-ZOndyXyg.js.br +0 -0
- package/dist/assets/KanbanEnhanced-ZOndyXyg.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/LoginPage-2CoFvwsL.js +0 -1
- 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-bHvRhycc.js +0 -1
- package/dist/assets/PageView-bHvRhycc.js.br +0 -0
- package/dist/assets/PageView-bHvRhycc.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-Sm8_iQw_.js +0 -1
- package/dist/assets/RecordDetailView-Sm8_iQw_.js.br +0 -0
- package/dist/assets/RecordDetailView-Sm8_iQw_.js.gz +0 -0
- package/dist/assets/RegisterPage-B9itUVYp.js +0 -1
- package/dist/assets/ReportView-B0D9jx4v.js +0 -1
- package/dist/assets/ReportView-B0D9jx4v.js.br +0 -0
- package/dist/assets/ReportView-B0D9jx4v.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-wlC0eLLr.js +0 -1
- package/dist/assets/SearchResultsPage-wlC0eLLr.js.br +0 -0
- package/dist/assets/SearchResultsPage-wlC0eLLr.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-TCaXYb43.js +0 -1
- package/dist/assets/ViewDesignerPage-TCaXYb43.js.br +0 -0
- package/dist/assets/ViewDesignerPage-TCaXYb43.js.gz +0 -0
- package/dist/assets/data-adapter-D15yh-pb.js +0 -1
- package/dist/assets/data-adapter-D15yh-pb.js.br +0 -0
- package/dist/assets/data-adapter-D15yh-pb.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-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/index-RAPqkKVL.js +0 -9
- package/dist/assets/index-RAPqkKVL.js.br +0 -0
- package/dist/assets/index-RAPqkKVL.js.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-Cv2TPt86.js +0 -4
- package/dist/assets/plugins-core-Cv2TPt86.js.br +0 -0
- package/dist/assets/plugins-core-Cv2TPt86.js.gz +0 -0
- package/dist/assets/plugins-views-P3eB-els.css.br +0 -0
- package/dist/assets/plugins-views-P3eB-els.css.gz +0 -0
- package/dist/assets/plugins-views-divN-xXs.js +0 -60
- package/dist/assets/plugins-views-divN-xXs.js.br +0 -0
- package/dist/assets/plugins-views-divN-xXs.js.gz +0 -0
- package/dist/assets/systemObjects-DSpePIIy.js.br +0 -2
- package/dist/assets/systemObjects-DSpePIIy.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-Bifvxvds.js +0 -1
- package/dist/assets/vendor-objectstack-Bifvxvds.js.br +0 -0
- package/dist/assets/vendor-objectstack-Bifvxvds.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-UZPqlszj.js +0 -39
- package/dist/assets/vendor-zod-UZPqlszj.js.br +0 -0
- package/dist/assets/vendor-zod-UZPqlszj.js.gz +0 -0
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/mockServiceWorker.js.br +0 -0
- package/dist/mockServiceWorker.js.gz +0 -0
- package/dist/stats.html +0 -4949
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,j as e}from"./vendor-react-9M-xu2bR.js";import{c as w}from"./infrastructure-n1j_TN6w.js";import{B as p,aa as b,G as v}from"./ui-components-BxvihT61.js";import"./framework-BM176iet.js";import{b as n}from"./vendor-ui-utils-3tkeUVaX.js";import{a as C}from"./index-CTBPkbPG.js";import{s as L}from"./systemObjects-DSpePIIy.js";import{ba as P,m as S,S as k,L as A,l as _}from"./vendor-icons-ndICq8DC.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-charts-BLNOCZWl.js";import"./vendor-objectstack-YKtcdalX.js";import"./vendor-zod-DxQVy2_o.js";import"./plugins-core-qwgXbAqa.js";import"./vendor-dndkit-CX1oDZqy.js";import"./plugins-views-CveFN6PV.js";import"./data-adapter-rvE3xy2B.js";import"./ui-layout-C6KWQtRO.js";const x=L.find(o=>o.name==="sys_permission"),u=x.views[0].columns;function W(){const{user:o}=w(),c=o?.role==="admin",a=C(),[h,f]=r.useState([]),[j,m]=r.useState(!0),[l,g]=r.useState(""),i=r.useCallback(async()=>{if(a){m(!0);try{const s=await a.find("sys_permission");f(s.data||[])}catch{n.error("Failed to load permissions")}finally{m(!1)}}},[a]);r.useEffect(()=>{i()},[i]);const y=r.useCallback(async()=>{if(a)try{await a.create("sys_permission",{name:"New Permission",description:"",resource:"",action:"read"}),n.success("Permission created"),i()}catch{n.error("Failed to create permission")}},[a,i]),N=r.useCallback(async s=>{if(a)try{await a.delete("sys_permission",s),n.success("Permission deleted"),i()}catch{n.error("Failed to delete permission")}},[a,i]),d=h.filter(s=>{if(!l)return!0;const t=l.toLowerCase();return(s.name||"").toLowerCase().includes(t)||(s.resource||"").toLowerCase().includes(t)||(s.action||"").toLowerCase().includes(t)||(s.description||"").toLowerCase().includes(t)});return e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[e.jsx(P,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Permissions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage permission rules and assignments"})]})]}),c&&e.jsxs(p,{onClick:y,"data-testid":"add-permission-btn",children:[e.jsx(S,{className:"h-4 w-4 mr-2"}),"Add Permission"]})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(k,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(b,{placeholder:"Search permissions...",value:l,onChange:s=>g(s.target.value),className:"pl-8","data-testid":"permission-search-input"})]}),j?e.jsxs("div",{className:"flex items-center gap-2 py-8 justify-center text-muted-foreground",children:[e.jsx(A,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading permissions..."})]}):d.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No permissions found."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm","data-testid":"permissions-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left",children:[u.map(s=>e.jsx("th",{className:"py-2 px-3 font-medium text-muted-foreground capitalize",children:x.fields.find(t=>t.name===s)?.label||s},s)),c&&e.jsx("th",{className:"py-2 px-3 font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:d.map(s=>e.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[u.map(t=>e.jsx("td",{className:"py-2 px-3",children:t==="action"?e.jsx(v,{variant:"outline",children:s[t]}):e.jsx("span",{className:"truncate",children:s[t]??"—"})},t)),c&&e.jsx("td",{className:"py-2 px-3",children:e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>N(s.id),children:e.jsx(_,{className:"h-4 w-4"})})})]},s.id))})]})})]})}export{W as PermissionManagementPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,j as e}from"./vendor-react-9M-xu2bR.js";import{c as w,g as C}from"./infrastructure-n1j_TN6w.js";import{C as i,v as u,aR as S,aS as A,aT as E,G as P,s as h,u as p,t as j,bn as g,bo as f,a9 as n,aa as c,B as U}from"./ui-components-BxvihT61.js";import"./framework-BM176iet.js";import"./vendor-ui-utils-3tkeUVaX.js";import{a8 as k,h as I,g as B,ap as D}from"./vendor-icons-ndICq8DC.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-charts-BLNOCZWl.js";import"./vendor-objectstack-YKtcdalX.js";import"./vendor-zod-DxQVy2_o.js";function O(){const{user:s,updateUser:N,isLoading:a}=w(),[m,v]=l.useState(s?.name??""),[b,d]=l.useState(!1),[o,x]=l.useState(null),y=async t=>{t.preventDefault(),x(null),d(!1);try{await N({name:m}),d(!0)}catch(r){x(r instanceof Error?r.message:String(r))}};return s?e.jsxs("div",{className:"flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Profile"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage your account settings"})]}),e.jsx(i,{children:e.jsx(u,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(S,{className:"h-16 w-16",children:[e.jsx(A,{src:s.image??void 0,alt:s.name??"User"}),e.jsx(E,{className:"text-lg bg-primary text-primary-foreground",children:C(s)})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-lg font-semibold truncate",children:s.name??"User"}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:s.email}),e.jsx(P,{variant:"secondary",className:"mt-1",children:s.role??"member"})]})]})})}),e.jsxs(i,{children:[e.jsxs(h,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(p,{className:"text-base sm:text-lg",children:"Personal Information"})]}),e.jsx(j,{children:"Update your name and view account details"})]}),e.jsx(u,{children:e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[o&&e.jsxs(g,{variant:"destructive",children:[e.jsx(I,{className:"h-4 w-4"}),e.jsx(f,{children:o})]}),b&&e.jsxs(g,{children:[e.jsx(B,{className:"h-4 w-4 text-green-600"}),e.jsx(f,{className:"text-green-800 dark:text-green-400",children:"Profile updated successfully."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"profile-name",children:"Name"}),e.jsx(c,{id:"profile-name",type:"text",value:m,onChange:t=>v(t.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"profile-email",children:"Email"}),e.jsx(c,{id:"profile-email",type:"email",value:s.email,disabled:!0,className:"bg-muted text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email cannot be changed."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{children:"Role"}),e.jsx(c,{type:"text",value:s.role??"member",disabled:!0,className:"bg-muted text-muted-foreground"})]}),e.jsx(U,{type:"submit",disabled:a,className:"w-full sm:w-auto",children:a?"Saving...":"Save Changes"})]})})]}),e.jsx(i,{children:e.jsxs(h,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(p,{className:"text-base sm:text-lg",children:"Change Password"})]}),e.jsx(j,{children:"To change your password, use the password reset flow from the login page."})]})})]}):null}export{O as ProfilePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as c,i as ne,h as ae}from"./vendor-react-9M-xu2bR.js";import{D as re,R as le}from"./plugins-views-CveFN6PV.js";import{p as x,be as ie,bf as oe,bg as ce,bh as de,bi as me,bj as ue,bk as fe,bl as he,D as pe,O as xe,l as ge,n as je,o as be,a9 as ye,$ as ve,a0 as we,a1 as Ne,a2 as Ae,a3 as Ce,bm as De,aa as P,U as _e,B as U,b7 as ke,b8 as Ie,b9 as Re}from"./ui-components-BxvihT61.js";import{A as $e}from"./framework-BM176iet.js";import{c as Te,u as Ee}from"./infrastructure-n1j_TN6w.js";import{b as H}from"./vendor-ui-utils-3tkeUVaX.js";import{u as Ve,P as Fe,M as Pe}from"./index-CTBPkbPG.js";import{aQ as Ue,b4 as He}from"./vendor-icons-ndICq8DC.js";import"./vendor-charts-BLNOCZWl.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-objectstack-YKtcdalX.js";import"./vendor-zod-DxQVy2_o.js";import"./plugins-core-qwgXbAqa.js";import"./vendor-dndkit-CX1oDZqy.js";import"./data-adapter-rvE3xy2B.js";import"./ui-layout-C6KWQtRO.js";function Oe({fields:r=8,columns:h=2}){return e.jsxs("div",{className:"w-full space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{className:"h-8 w-8 rounded"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{className:"h-6 w-48"}),e.jsx(x,{className:"h-4 w-32"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-9 w-20"}),e.jsx(x,{className:"h-9 w-20"})]})]}),e.jsx(x,{className:"h-5 w-24"}),e.jsx("div",{className:`grid grid-cols-1 ${h===2?"md:grid-cols-2":""} gap-4`,children:Array.from({length:r}).map((p,i)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{className:"h-4 w-24"}),e.jsx(x,{className:"h-9 w-full"})]},`field-${i}`))}),e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[e.jsx(x,{className:"h-5 w-32"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((p,i)=>e.jsxs("div",{className:"flex items-center gap-3 py-2",children:[e.jsx(x,{className:"h-8 w-8 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(x,{className:"h-4 w-40"}),e.jsx(x,{className:"h-3 w-24"})]})]},`related-${i}`))})]})]})}function Se({state:r,onOpenChange:h}){const p=()=>{r.resolve?.(!0),h(!1)},i=()=>{r.resolve?.(!1),h(!1)};return e.jsx(ie,{open:r.open,onOpenChange:g=>{g||i()},children:e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsx(de,{children:r.options?.title||"Confirm Action"}),e.jsx(me,{children:r.message})]}),e.jsxs(ue,{children:[e.jsx(fe,{onClick:i,children:r.options?.cancelText||"Cancel"}),e.jsx(he,{onClick:p,children:r.options?.confirmText||"Continue"})]})]})})}function Le({state:r,onOpenChange:h}){const[p,i]=c.useState({}),[g,N]=c.useState({});c.useEffect(()=>{if(r.open){const n={};for(const o of r.params)o.defaultValue!==void 0&&(n[o.name]=o.defaultValue);i(n),N({})}},[r.open,r.params]);const v=n=>n==null?!0:typeof n=="string"?n.trim()==="":Array.isArray(n)?n.length===0:!1,A=()=>{const n={};for(const o of r.params)o.required&&v(p[o.name])&&(n[o.name]=!0);if(Object.keys(n).length>0){N(n);return}r.resolve?.(p),h(!1)},C=()=>{r.resolve?.(null),h(!1)},w=(n,o)=>{i(b=>({...b,[n]:o})),N(b=>({...b,[n]:!1}))};return e.jsx(pe,{open:r.open,onOpenChange:n=>{n||C()},children:e.jsxs(xe,{children:[e.jsxs(ge,{children:[e.jsx(je,{children:"Action Parameters"}),e.jsx(be,{children:"Please provide the required information to continue."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:r.params.map(n=>e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(ye,{htmlFor:n.name,children:[n.label,n.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),n.type==="select"&&n.options?e.jsxs(ve,{value:p[n.name]??"",onValueChange:o=>w(n.name,o),children:[e.jsx(we,{id:n.name,className:g[n.name]?"border-destructive":"",children:e.jsx(Ne,{placeholder:n.placeholder||`Select ${n.label}`})}),e.jsx(Ae,{children:n.options.map(o=>e.jsx(Ce,{value:o.value,children:o.label},o.value))})]}):n.type==="textarea"?e.jsx(De,{id:n.name,value:p[n.name]??"",onChange:o=>w(n.name,o.target.value),placeholder:n.placeholder,className:g[n.name]?"border-destructive":""}):n.type==="number"?e.jsx(P,{id:n.name,type:"number",value:p[n.name]??"",onChange:o=>w(n.name,o.target.value===""?void 0:o.target.valueAsNumber),placeholder:n.placeholder,className:g[n.name]?"border-destructive":""}):e.jsx(P,{id:n.name,type:["email","url","date","datetime-local","time","password"].includes(n.type)?n.type:"text",value:p[n.name]??"",onChange:o=>w(n.name,o.target.value),placeholder:n.placeholder,className:g[n.name]?"border-destructive":""}),g[n.name]&&e.jsxs("p",{className:"text-xs text-destructive",children:[n.label," is required"]}),n.helpText&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.helpText})]},n.name))}),e.jsxs(_e,{children:[e.jsx(U,{variant:"outline",onClick:C,children:"Cancel"}),e.jsx(U,{onClick:A,children:"Confirm"})]})]})})}const qe={id:"current-user",name:"Demo User"},Me=["status","stage","priority","category","type","owner","amount"];function ot({dataSource:r,objects:h,onEdit:p}){const{objectName:i,recordId:g}=ne(),{showDebug:N}=Ve(),{user:v}=Te(),A=ae(),{t:C}=Ee(),[w,n]=c.useState(!0),[o,b]=c.useState([]),[I,O]=c.useState([]),[S,L]=c.useState(0),[q,M]=c.useState({}),m=h.find(s=>s.name===i),u=g,[B,R]=c.useState({open:!1,message:""}),[G,$]=c.useState({open:!1,params:[]}),K=c.useCallback((s,t)=>new Promise(a=>{R({open:!0,message:s,options:t,resolve:a})}),[]),z=c.useCallback(s=>new Promise(t=>{$({open:!0,params:s,resolve:t})}),[]),Q=c.useCallback((s,t)=>{t?.type==="error"?H.error(s):H.success(s)},[]),J=c.useCallback((s,t)=>{t?.external||t?.newTab?window.open(s,"_blank","noopener,noreferrer"):A(s)},[A]),W=c.useCallback(async s=>{try{const t=s.target||s.name,a=s.params||{};switch(t){case"opportunity_change_stage":await r.update(i,u,{stage:a.new_stage});break;case"opportunity_mark_won":await r.update(i,u,{stage:"closed_won"});break;case"opportunity_mark_lost":await r.update(i,u,{stage:"closed_lost",loss_reason:a.loss_reason});break;default:Object.keys(a).length>0&&await r.update(i,u,a);break}const l=s.refreshAfter===!0;return l&&L(d=>d+1),{success:!0,reload:l}}catch(t){return{success:!1,error:t.message}}},[r,i,u]),D=c.useMemo(()=>{if(!m||!h)return[];const s=[];for(const t of h)if(t.name!==m.name)for(const[a,l]of Object.entries(t.fields||{}))l&&(l.type==="lookup"||l.type==="master_detail")&&(l.reference_to||l.reference)===m.name&&s.push({childObject:t.name,childLabel:t.label||t.name,referenceField:a});return s},[m,h]);c.useEffect(()=>{if(!r||!u||D.length===0)return;let s=!1;return Promise.all(D.map(({childObject:t,referenceField:a})=>r.find(t,{$filter:{[a]:u}}).then(l=>{const d=Array.isArray(l)?l:l?.data||[];return{childObject:t,items:d}}).catch(l=>(console.warn(`[RecordDetailView] Failed to fetch related ${t}:`,l),{childObject:t,items:[]})))).then(t=>{if(s)return;const a={};for(const{childObject:l,items:d}of t)a[l]=d;M(a)}),()=>{s=!0}},[r,u,D]);const f=v?{id:v.id,name:v.name,avatar:v.image}:qe;c.useEffect(()=>{if(!r||!i||!u)return;const s=`${i}:${u}`;r.find("sys_presence",{$filter:`recordId eq '${u}'`}).then(t=>{t.data?.length&&O(t.data)}).catch(()=>{}),r.find("sys_comment",{$filter:`threadId eq '${s}'`,$orderby:"createdAt asc"}).then(t=>{t.data?.length&&b(t.data.map(a=>({id:a.id,type:"comment",actor:a.author?.name??"Unknown",actorAvatarUrl:a.author?.avatar,body:a.content,createdAt:a.createdAt,updatedAt:a.updatedAt,parentId:a.parentId,reactions:a.reactions?Object.entries(a.reactions).map(([l,d])=>({emoji:l,count:d.length,reacted:d.includes(f.id)})):void 0})))}).catch(()=>{})},[r,i,u,f]);const X=c.useCallback(async s=>{const t={id:crypto.randomUUID(),type:"comment",actor:f.name,actorAvatarUrl:"avatar"in f?f.avatar:void 0,body:s,createdAt:new Date().toISOString()};if(b(a=>[...a,t]),r){const a=`${i}:${u}`;r.create("sys_comment",{id:t.id,threadId:a,author:f,content:s,mentions:[],createdAt:t.createdAt}).catch(()=>{})}},[f,r,i,u]),Y=c.useCallback(async(s,t)=>{const a={id:crypto.randomUUID(),type:"comment",actor:f.name,actorAvatarUrl:"avatar"in f?f.avatar:void 0,body:t,createdAt:new Date().toISOString(),parentId:s};if(b(l=>[...l,a].map(j=>j.id===s?{...j,replyCount:(j.replyCount??0)+1}:j)),r){const l=`${i}:${u}`;r.create("sys_comment",{id:a.id,threadId:l,author:f,content:t,mentions:[],createdAt:a.createdAt,parentId:s}).catch(()=>{})}},[f,r,i,u]),Z=c.useCallback((s,t)=>{b(a=>a.map(l=>{if(l.id!==s)return l;const d=[...l.reactions??[]],j=d.findIndex(y=>y.emoji===t);if(j>=0){const y=d[j];y.reacted?y.count<=1?d.splice(j,1):d[j]={...y,count:y.count-1,reacted:!1}:d[j]={...y,count:y.count+1,reacted:!0}}else d.push({emoji:t,count:1,reacted:!0});const se={...l,reactions:d};return r&&r.update("sys_comment",String(s),{$toggleReaction:{emoji:t,userId:f.id}}).catch(()=>{}),se}))},[f.id,r]);if(c.useEffect(()=>{n(!0),queueMicrotask(()=>n(!1))},[i,g]),w)return e.jsx(Oe,{});if(!m)return e.jsx("div",{className:"flex h-full items-center justify-center p-4",children:e.jsxs(ke,{children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:e.jsx(Ue,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx(Ie,{children:"Object Not Found"}),e.jsxs(Re,{children:['Object "',i,'" definition missing. Check your configuration or navigate back to select a valid object.']})]})});const ee=m.primaryField||Object.keys(m.fields||{}).find(s=>s==="name"||s==="title"),_=m.views?.form?.sections,te=_&&_.length>0?_.map(s=>({title:s.title,collapsible:s.collapsible,defaultCollapsed:s.defaultCollapsed,fields:(s.fields||[]).map(t=>{const a=typeof t=="string"?t:t.name,l=m.fields[a];if(!l)return console.warn(`[RecordDetailView] Field "${a}" not found in ${m.name} definition`),{name:a,label:a};const d=l.reference_to||l.reference;return{name:a,label:l.label||a,type:l.type||"text",...l.options&&{options:l.options},...d&&{reference_to:d},...l.reference_field&&{reference_field:l.reference_field},...l.currency&&{currency:l.currency}}})})):[{title:C("detail.details",{defaultValue:"Details"}),fields:Object.keys(m.fields||{}).map(s=>{const t=m.fields[s],a=t.reference_to||t.reference;return{name:s,label:t.label||s,type:t.type||"text",...t.options&&{options:t.options},...a&&{reference_to:a},...t.reference_field&&{reference_field:t.reference_field},...t.currency&&{currency:t.currency}}})}],T=(()=>{const s=new Set;return(m.actions||[]).filter(t=>t.locations?.includes("record_header")?t.name?s.has(t.name)?!1:(s.add(t.name),!0):!0:!1)})(),E=m.views?.detail?.highlightFields??Object.entries(m.fields||{}).filter(([s])=>Me.includes(s)).map(([s,t])=>({name:s,label:t.label||s,...t.type&&{type:t.type}})),k=m.views?.detail?.sectionGroups??m.views?.form?.sectionGroups,V=D.map(({childObject:s,childLabel:t})=>({title:t,type:"table",api:s,data:q[s]||[]})),F={type:"detail-view",objectName:m.name,resourceId:u,showBack:!0,onBack:"history",showEdit:!0,title:m.label,primaryField:ee,sections:te,autoTabs:!0,autoDiscoverRelated:!0,...V.length>0&&{related:V},...E.length>0&&{highlightFields:E},...k&&k.length>0&&{sectionGroups:k},...T.length>0&&{actions:[{type:"action:bar",location:"record_header",actions:T}]}};return e.jsxs("div",{className:"h-full bg-background overflow-hidden flex flex-col relative",children:[e.jsx("div",{className:"absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2",children:I.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5",title:"Users viewing this record",children:[e.jsx(He,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Fe,{users:I,size:"sm",maxVisible:4,showStatus:!0})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[e.jsxs("div",{className:"flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48",children:[e.jsx($e,{context:{record:{},objectName:i,user:f},onConfirm:K,onToast:Q,onNavigate:J,onParamCollection:z,handlers:{api:W},children:e.jsx(re,{schema:F,dataSource:r,onEdit:()=>{p({_id:u,id:u})}},S)}),e.jsx("div",{className:"mt-6 border-t pt-6",children:e.jsx(le,{config:{position:"bottom",collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:o,onAddComment:X,onAddReply:Y,onToggleReaction:Z})})]}),e.jsx(Pe,{open:N,sections:[{title:"View Schema",data:F}]})]}),e.jsx(Se,{state:B,onOpenChange:s=>{s||R(t=>({...t,open:!1}))}}),e.jsx(Le,{state:G,onOpenChange:s=>{s||$(t=>({...t,open:!1}))}})]})}export{ot as RecordDetailView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as a,j as t,L as o}from"./vendor-react-9M-xu2bR.js";import{u as i,R as n}from"./infrastructure-n1j_TN6w.js";import{A as l}from"./AuthPageLayout-9l5xWV_-.js";import"./vendor-i18n-E3-WitRV.js";const u=({href:r,className:e,children:s})=>t.jsx(o,{to:r,className:e,children:s});function d(){const r=a(),{t:e}=i();return t.jsx(l,{children:t.jsx(n,{onSuccess:()=>r("/"),loginUrl:"/login",title:e("auth.register.title"),description:e("auth.register.description"),linkComponent:u,labels:{nameLabel:e("auth.register.nameLabel"),namePlaceholder:e("auth.register.namePlaceholder"),emailLabel:e("auth.register.emailLabel"),emailPlaceholder:e("auth.register.emailPlaceholder"),passwordLabel:e("auth.register.passwordLabel"),passwordPlaceholder:e("auth.register.passwordPlaceholder"),confirmPasswordLabel:e("auth.register.confirmPasswordLabel"),confirmPasswordPlaceholder:e("auth.register.confirmPasswordPlaceholder"),passwordMismatchError:e("auth.register.passwordMismatchError"),passwordTooShortError:e("auth.register.passwordTooShortError"),submitButton:e("auth.register.submitButton"),submittingButton:e("auth.register.submittingButton"),hasAccountText:e("auth.register.hasAccountText"),signInText:e("auth.register.signInText")}})})}export{d as RegisterPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as q,r as o,j as t}from"./vendor-react-9M-xu2bR.js";import{c as z,d as G}from"./plugins-views-CveFN6PV.js";import{b7 as H,b8 as Q,b9 as U}from"./ui-components-BxvihT61.js";import"./framework-BM176iet.js";import"./vendor-ui-utils-3tkeUVaX.js";import{u as W,a as X,b as Z,M as ee}from"./index-CTBPkbPG.js";import{L as A,aY as te,at as ae}from"./vendor-icons-ndICq8DC.js";import"./infrastructure-n1j_TN6w.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-charts-BLNOCZWl.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-objectstack-YKtcdalX.js";import"./vendor-zod-DxQVy2_o.js";import"./plugins-core-qwgXbAqa.js";import"./vendor-dndkit-CX1oDZqy.js";import"./data-adapter-rvE3xy2B.js";import"./ui-layout-C6KWQtRO.js";const re=[{value:"month",label:"Month",type:"text"},{value:"revenue",label:"Revenue",type:"number"},{value:"count",label:"Count",type:"number"},{value:"region",label:"Region",type:"text"},{value:"product",label:"Product",type:"text"},{value:"source",label:"Lead Source",type:"text"},{value:"stage",label:"Stage",type:"text"},{value:"amount",label:"Amount",type:"number"}];function we({dataSource:f}){const{reportName:h}=q(),{showDebug:R}=W(),b=X(),[j,v]=o.useState(!1),[F,w]=o.useState(0),{reports:D,objects:g,loading:S,refresh:C}=Z(),m=D?.find(r=>r.name===h),[l,M]=o.useState(m),[p,x]=o.useState(null),[k,c]=o.useState([]),[E,y]=o.useState(!1),V=o.useMemo(()=>{const r=p||l,e=r?.objectName||r?.dataSource?.object||r?.dataSource?.resource;if(e&&g?.length){const s=g.find(d=>d.name===e);if(s?.fields){const d=s.fields;return Array.isArray(d)?d.map(n=>typeof n=="string"?{value:n,label:n,type:"text"}:{value:n.name,label:n.label||n.name,type:n.type||"text"}):Object.entries(d).map(([n,i])=>({value:n,label:i.label||n,type:i.type||"text"}))}}return re},[p,l,g]),N=o.useCallback(async r=>{try{b&&(await b.update("sys_report",h,r),C().catch(()=>{}))}catch(e){console.warn("[ReportView] Auto-save failed:",e)}},[b,h,C]),O=o.useCallback(()=>{x(l),v(!0),w(r=>r+1)},[l]),P=o.useCallback(()=>{v(!1)},[]),T=o.useMemo(()=>p||l,[F]),L=o.useCallback(r=>{x(r),N(r),w(e=>e+1)},[N]),$=o.useCallback((r,e)=>{x(s=>({...s,[r]:e}))},[]);o.useEffect(()=>{M(m)},[m]),o.useEffect(()=>{j||x(null)},[m]);const a=p||l,I=o.useMemo(()=>JSON.stringify(a?.filters),[a?.filters]),K=o.useMemo(()=>JSON.stringify(a?.dataSource),[a?.dataSource]),J=o.useMemo(()=>JSON.stringify(a?.data),[a?.data]);if(o.useEffect(()=>{if(!a||!f){c([]);return}if(a.data&&Array.isArray(a.data)){c(a.data);return}if(a.dataSource){(async()=>{y(!0);try{const e=a.dataSource.object||a.dataSource.resource;if(!e){console.warn("ReportView: dataSource missing object/resource property"),c([]);return}const s=await f.find(e,{$filter:a.dataSource.filter,$orderby:a.dataSource.sort,$top:a.dataSource.limit});c(s.data||[])}catch(e){console.error("ReportView: Failed to load data from dataSource",e),c([])}finally{y(!1)}})();return}if(a.objectName){(async()=>{y(!0);try{const e=await f.find(a.objectName,{$filter:a.filters,$orderby:a.sort,$top:a.limit||100});c(e.data||[])}catch(e){console.error("ReportView: Failed to load data from objectName",e),c([])}finally{y(!1)}})();return}c([])},[a?.objectName,a?.limit,I,K,J,f]),S)return t.jsx("div",{className:"h-full flex items-center justify-center p-8",children:t.jsx(A,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(!m||!l)return!S&&!m?t.jsx("div",{className:"h-full flex items-center justify-center p-8",children:t.jsxs(H,{children:[t.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:t.jsx(te,{className:"h-6 w-6 text-muted-foreground"})}),t.jsx(Q,{children:"Report Not Found"}),t.jsxs(U,{children:['The report "',h,'" could not be found. It may have been removed or renamed.']})]})}):t.jsx("div",{className:"h-full flex items-center justify-center p-8",children:t.jsx(A,{className:"h-8 w-8 animate-spin text-muted-foreground"})});const _=r=>{const e={...r};if(!e.title&&e.label&&(e.title=e.label),!e.fields&&Array.isArray(e.columns)&&(e.fields=e.columns.map(s=>({name:s.field||s.name,label:s.label,type:s.type,format:s.format,renderAs:s.renderAs,colorMap:s.colorMap,...s.aggregate?{aggregation:s.aggregate,showInSummary:!0}:{}}))),e.fields&&Array.isArray(e.fields)&&e.fields.length>0){const s=e.fields.some(i=>i.showInSummary||i.aggregation),d=e.reportType||"tabular",n=[];if((d==="summary"||s)&&n.push({type:"summary",title:"Key Metrics"}),n.push({type:"table",title:"Details",columns:e.fields.map(i=>({name:i.name,label:i.label,type:i.type,format:i.format,renderAs:i.renderAs,colorMap:i.colorMap}))}),e.chartConfig?.chartType&&n.push({type:"chart",title:"Chart",chart:{type:"chart",chartType:e.chartConfig.chartType,xAxisField:e.chartConfig.xAxisField,yAxisFields:e.chartConfig.yAxisFields}}),Array.isArray(r.sections)){const i=r.sections.filter(Y=>Y.type==="chart"&&!e.chartConfig?.chartType);n.push(...i)}e.sections=n}else e.sections||(e.sections=[]);return e},u=p||l,B={type:"report-viewer",report:_(u),data:k,showToolbar:!0,allowExport:!0,loading:E};return t.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h1",{className:"text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate",children:u.title||u.label||"Report Viewer"}),u.description&&t.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:u.description})]}),t.jsx("div",{className:"shrink-0 flex items-center gap-1.5",children:t.jsxs("button",{type:"button",onClick:O,className:"inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground","data-testid":"report-edit-button",children:[t.jsx(ae,{className:"h-3.5 w-3.5"}),"Edit"]})})]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col sm:flex-row relative",children:[t.jsx("div",{className:"flex-1 min-w-0 overflow-auto p-4 sm:p-6 lg:p-8 bg-muted/5",children:t.jsx("div",{className:"max-w-5xl mx-auto shadow-sm border rounded-lg sm:rounded-xl bg-background overflow-hidden min-h-150",children:t.jsx(z,{schema:B})})}),t.jsx(G,{open:j,onClose:P,config:T,onSave:L,onFieldChange:$,availableFields:V}),t.jsx(ee,{open:R,sections:[{title:"Report Configuration",data:u}]})]})]})}export{we as ReportView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,j as e}from"./vendor-react-9M-xu2bR.js";import{c as w}from"./infrastructure-n1j_TN6w.js";import{B as x,C as b,v as y,G as v}from"./ui-components-BxvihT61.js";import"./framework-BM176iet.js";import{b as i}from"./vendor-ui-utils-3tkeUVaX.js";import{a as C}from"./index-CTBPkbPG.js";import{s as k}from"./systemObjects-DSpePIIy.js";import{b9 as h,m as R,L as S,l as _}from"./vendor-icons-ndICq8DC.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-charts-BLNOCZWl.js";import"./vendor-objectstack-YKtcdalX.js";import"./vendor-zod-DxQVy2_o.js";import"./plugins-core-qwgXbAqa.js";import"./vendor-dndkit-CX1oDZqy.js";import"./plugins-views-CveFN6PV.js";import"./data-adapter-rvE3xy2B.js";import"./ui-layout-C6KWQtRO.js";const p=k.find(c=>c.name==="sys_role"),o=p.views[0].columns;function Q(){const{user:c}=w(),l=c?.role==="admin",t=C(),[m,u]=r.useState([]),[f,d]=r.useState(!0),a=r.useCallback(async()=>{if(t){d(!0);try{const s=await t.find("sys_role");u(s.data||[])}catch{i.error("Failed to load roles")}finally{d(!1)}}},[t]);r.useEffect(()=>{a()},[a]);const j=r.useCallback(async()=>{if(t)try{await t.create("sys_role",{name:"New Role",description:"",isSystem:!1}),i.success("Role created"),a()}catch{i.error("Failed to create role")}},[t,a]),g=r.useCallback(async s=>{if(t)try{await t.delete("sys_role",s),i.success("Role deleted"),a()}catch{i.error("Failed to delete role")}},[t,a]);return e.jsxs("div",{className:"flex flex-col gap-4 sm:gap-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"bg-primary/10 p-2 rounded-md shrink-0",children:e.jsx(h,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Role Management"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Define roles and assign permissions"})]})]}),l&&e.jsxs(x,{size:"sm",className:"shrink-0 gap-2",onClick:j,children:[e.jsx(R,{className:"h-4 w-4"}),"Add Role"]})]}),e.jsx(b,{children:e.jsx(y,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[o.map(s=>{const n=p.fields.find(N=>N.name===s);return e.jsx("th",{className:"h-10 px-3 sm:px-4 text-left font-medium text-muted-foreground whitespace-nowrap",children:n?.label??s},s)}),l&&e.jsx("th",{className:"h-10 px-3 sm:px-4 text-right font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:f?e.jsx("tr",{children:e.jsx("td",{className:"p-6 text-center",colSpan:o.length+(l?1:0),children:e.jsx(S,{className:"h-6 w-6 animate-spin mx-auto text-muted-foreground"})})}):m.length===0?e.jsx("tr",{children:e.jsx("td",{className:"p-4 sm:p-6 text-center text-sm text-muted-foreground",colSpan:o.length+(l?1:0),children:e.jsxs("div",{className:"flex flex-col items-center gap-2 py-4",children:[e.jsx(h,{className:"h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{children:"No roles found."}),e.jsx(v,{variant:"secondary",className:"text-xs",children:"plugin-grid powered"})]})})}):m.map(s=>e.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[o.map(n=>e.jsx("td",{className:"h-10 px-3 sm:px-4 whitespace-nowrap",children:String(s[n]??"")},n)),l&&e.jsx("td",{className:"h-10 px-3 sm:px-4 text-right",children:e.jsx(x,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>g(s.id||s._id),children:e.jsx(_,{className:"h-3.5 w-3.5 text-destructive"})})})]},s.id||s._id))})]})})})})]})}export{Q as RoleManagementPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as S,k as L,r as m,j as s,L as g}from"./vendor-react-9M-xu2bR.js";import{aa as I,G as f,C as P,v as A}from"./ui-components-BxvihT61.js";import"./framework-BM176iet.js";import"./vendor-ui-utils-3tkeUVaX.js";import{b as T}from"./index-CTBPkbPG.js";import{A as q,S as b,aY as E,ak as M,aX as O,aQ as x}from"./vendor-icons-ndICq8DC.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-charts-BLNOCZWl.js";import"./infrastructure-n1j_TN6w.js";import"./vendor-objectstack-YKtcdalX.js";import"./vendor-zod-DxQVy2_o.js";import"./plugins-core-qwgXbAqa.js";import"./vendor-dndkit-CX1oDZqy.js";import"./plugins-views-CveFN6PV.js";import"./data-adapter-rvE3xy2B.js";import"./ui-layout-C6KWQtRO.js";function N(p){const l=[];for(const o of p)o.type==="group"&&o.children?l.push(...N(o.children)):l.push(o);return l}const j={object:x,dashboard:O,page:M,report:E},R={object:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",dashboard:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",page:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",report:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200"};function se(){const{appName:p}=S(),[l,o]=L(),v=l.get("q")||"",[n,y]=m.useState(v),{apps:w}=T(),h=w||[],u=h.find(t=>t.name===p)||h[0],c=`/apps/${p}`,i=m.useMemo(()=>u?N(u.navigation||[]).map(e=>{let r="#";return e.type==="object"?(r=`${c}/${e.objectName}`,e.viewName&&(r+=`/view/${e.viewName}`)):e.type==="dashboard"?r=`${c}/dashboard/${e.dashboardName}`:e.type==="page"?r=`${c}/page/${e.pageName}`:e.type==="report"&&(r=`${c}/report/${e.reportName}`),{id:e.id,label:e.label||e.objectName||e.dashboardName||e.pageName||e.reportName||"",href:r,type:e.type,description:e.description}}).filter(e=>e.href!=="#"):[],[u,c]),d=m.useMemo(()=>{if(!n.trim())return i;const t=n.toLowerCase();return i.filter(e=>e.label.toLowerCase().includes(t)||e.type.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t))},[i,n]),$=t=>{y(t),o(t?{q:t}:{})},C=m.useMemo(()=>{const t={};for(const e of d)(t[e.type]||=[]).push(e);return t},[d]);return s.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6 max-w-4xl mx-auto",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs(g,{to:c,className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(q,{className:"h-4 w-4"}),"Back"]}),s.jsx("h1",{className:"text-xl font-semibold",children:"Search"})]}),s.jsxs("div",{className:"relative",children:[s.jsx(b,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),s.jsx(I,{value:n,onChange:t=>$(t.target.value),placeholder:"Search objects, dashboards, pages, reports...",className:"pl-10 h-11 text-base",autoFocus:!0})]}),s.jsx("div",{className:"text-sm text-muted-foreground",children:n.trim()?`${d.length} result${d.length!==1?"s":""} for "${n}"`:`${i.length} items available`}),d.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(b,{className:"h-12 w-12 text-muted-foreground/30 mb-4"}),s.jsx("p",{className:"text-lg font-medium text-muted-foreground",children:"No results found"}),s.jsx("p",{className:"text-sm text-muted-foreground/80 mt-1",children:"Try adjusting your search terms"})]}):s.jsx("div",{className:"space-y-6",children:Object.entries(C).map(([t,e])=>{const r=j[t]||x;return s.jsxs("div",{children:[s.jsxs("h2",{className:"text-sm font-medium text-muted-foreground mb-2 flex items-center gap-1.5",children:[s.jsx(r,{className:"h-4 w-4"}),t.charAt(0).toUpperCase()+t.slice(1),"s",s.jsx(f,{variant:"secondary",className:"ml-1 text-xs",children:e.length})]}),s.jsx("div",{className:"grid gap-2",children:e.map(a=>{const k=j[a.type]||x;return s.jsx(g,{to:a.href,children:s.jsx(P,{className:"hover:bg-accent/50 transition-colors cursor-pointer",children:s.jsxs(A,{className:"flex items-center gap-3 p-3",children:[s.jsx("div",{className:`flex h-8 w-8 items-center justify-center rounded ${R[a.type]||""}`,children:s.jsx(k,{className:"h-4 w-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:a.label}),a.description&&s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.description})]}),s.jsx(f,{variant:"outline",className:"text-xs shrink-0",children:a.type})]})})},a.id)})})]},t)})})]})}export{se as SearchResultsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as y,i as b,r as n,j as s}from"./vendor-react-9M-xu2bR.js";import{C as j,s as L,u as N,t as C,v,G as w}from"./ui-components-BxvihT61.js";import"./framework-BM176iet.js";import"./vendor-ui-utils-3tkeUVaX.js";import{a as $,b as S}from"./index-CTBPkbPG.js";import{ai as R,b4 as M,b8 as P,b9 as _,ba as k,bb as z,a8 as A,L as E}from"./vendor-icons-ndICq8DC.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-charts-BLNOCZWl.js";import"./infrastructure-n1j_TN6w.js";import"./vendor-objectstack-YKtcdalX.js";import"./vendor-zod-DxQVy2_o.js";import"./plugins-core-qwgXbAqa.js";import"./vendor-dndkit-CX1oDZqy.js";import"./plugins-views-CveFN6PV.js";import"./data-adapter-rvE3xy2B.js";import"./ui-layout-C6KWQtRO.js";function Z(){const m=y(),{appName:r}=b(),t=r?`/apps/${r}`:"",a=$(),{apps:l}=S(),[i,u]=n.useState({apps:null,users:null,orgs:null,roles:null,permissions:null,auditLogs:null}),[p,c]=n.useState(!0),d=n.useCallback(async()=>{if(a){c(!0);try{const[e,o,h,f,x]=await Promise.all([a.find("sys_user").catch(()=>({data:[]})),a.find("sys_org").catch(()=>({data:[]})),a.find("sys_role").catch(()=>({data:[]})),a.find("sys_permission").catch(()=>({data:[]})),a.find("sys_audit_log").catch(()=>({data:[]}))]);u({apps:l?.length??0,users:e.data?.length??0,orgs:o.data?.length??0,roles:h.data?.length??0,permissions:f.data?.length??0,auditLogs:x.data?.length??0})}catch{}finally{c(!1)}}},[a,l]);n.useEffect(()=>{d()},[d]);const g=[{title:"Applications",description:"Manage all configured applications",icon:R,href:`${t}/system/apps`,countLabel:"apps",count:i.apps},{title:"Users",description:"Manage system users and accounts",icon:M,href:`${t}/system/users`,countLabel:"users",count:i.users},{title:"Organizations",description:"Manage organizations and teams",icon:P,href:`${t}/system/organizations`,countLabel:"organizations",count:i.orgs},{title:"Roles",description:"Configure roles and access levels",icon:_,href:`${t}/system/roles`,countLabel:"roles",count:i.roles},{title:"Permissions",description:"Manage permission rules and assignments",icon:k,href:`${t}/system/permissions`,countLabel:"permissions",count:i.permissions},{title:"Audit Log",description:"View system activity and changes",icon:z,href:`${t}/system/audit-log`,countLabel:"entries",count:i.auditLogs},{title:"Profile",description:"View and edit your account settings",icon:A,href:`${t}/system/profile`,countLabel:"",count:null}];return s.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"System Settings"}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage applications, users, roles, permissions, and system configuration"})]}),p&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(E,{className:"h-4 w-4 animate-spin"}),"Loading statistics..."]}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:g.map(e=>{const o=e.icon;return s.jsxs(j,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>m(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,"-")}`,children:[s.jsxs(L,{className:"flex flex-row items-center gap-3 pb-2",children:[s.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:s.jsx(o,{className:"h-5 w-5"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(N,{className:"text-base",children:e.title}),s.jsx(C,{className:"text-xs",children:e.description})]})]}),s.jsx(v,{className:"pt-0",children:e.count!==null&&s.jsxs(w,{variant:"secondary",children:[e.count," ",e.countLabel]})})]},e.title)})})]})}export{Z as SystemHubPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as a,j as e}from"./vendor-react-9M-xu2bR.js";import{c as w}from"./infrastructure-n1j_TN6w.js";import{B as x,C as b,v as y,G as v}from"./ui-components-BxvihT61.js";import"./framework-BM176iet.js";import{b as n}from"./vendor-ui-utils-3tkeUVaX.js";import{a as C}from"./index-CTBPkbPG.js";import{s as k}from"./systemObjects-DSpePIIy.js";import{b4 as h,m as U,L as S,l as _}from"./vendor-icons-ndICq8DC.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-charts-BLNOCZWl.js";import"./vendor-objectstack-YKtcdalX.js";import"./vendor-zod-DxQVy2_o.js";import"./plugins-core-qwgXbAqa.js";import"./vendor-dndkit-CX1oDZqy.js";import"./plugins-views-CveFN6PV.js";import"./data-adapter-rvE3xy2B.js";import"./ui-layout-C6KWQtRO.js";const u=k.find(m=>m.name==="sys_user"),l=u.views[0].columns;function Q(){const{user:m}=w(),i=m?.role==="admin",t=C(),[d,p]=a.useState([]),[f,o]=a.useState(!0),r=a.useCallback(async()=>{if(t){o(!0);try{const s=await t.find("sys_user");p(s.data||[])}catch{n.error("Failed to load users")}finally{o(!1)}}},[t]);a.useEffect(()=>{r()},[r]);const j=a.useCallback(async()=>{if(t)try{await t.create("sys_user",{name:"New User",email:"",role:"member",status:"active"}),n.success("User created"),r()}catch{n.error("Failed to create user")}},[t,r]),g=a.useCallback(async s=>{if(t)try{await t.delete("sys_user",s),n.success("User deleted"),r()}catch{n.error("Failed to delete user")}},[t,r]);return e.jsxs("div",{className:"flex flex-col gap-4 sm:gap-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"bg-primary/10 p-2 rounded-md shrink-0",children:e.jsx(h,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"User Management"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Manage system users and their roles"})]})]}),i&&e.jsxs(x,{size:"sm",className:"shrink-0 gap-2",onClick:j,children:[e.jsx(U,{className:"h-4 w-4"}),"Add User"]})]}),e.jsx(b,{children:e.jsx(y,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[l.map(s=>{const c=u.fields.find(N=>N.name===s);return e.jsx("th",{className:"h-10 px-3 sm:px-4 text-left font-medium text-muted-foreground whitespace-nowrap",children:c?.label??s},s)}),i&&e.jsx("th",{className:"h-10 px-3 sm:px-4 text-right font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:f?e.jsx("tr",{children:e.jsx("td",{className:"p-6 text-center",colSpan:l.length+(i?1:0),children:e.jsx(S,{className:"h-6 w-6 animate-spin mx-auto text-muted-foreground"})})}):d.length===0?e.jsx("tr",{children:e.jsx("td",{className:"p-4 sm:p-6 text-center text-sm text-muted-foreground",colSpan:l.length+(i?1:0),children:e.jsxs("div",{className:"flex flex-col items-center gap-2 py-4",children:[e.jsx(h,{className:"h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{children:"No users found."}),e.jsx(v,{variant:"secondary",className:"text-xs",children:"plugin-grid powered"})]})})}):d.map(s=>e.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[l.map(c=>e.jsx("td",{className:"h-10 px-3 sm:px-4 whitespace-nowrap",children:String(s[c]??"")},c)),i&&e.jsx("td",{className:"h-10 px-3 sm:px-4 text-right",children:e.jsx(x,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>g(s.id||s._id),children:e.jsx(_,{className:"h-3.5 w-3.5 text-destructive"})})})]},s.id||s._id))})]})})})})]})}export{Q as UserManagementPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{O as S}from"./vendor-objectstack-YKtcdalX.js";import{j as A}from"./framework-BM176iet.js";class O{cache;maxSize;ttl;stats;constructor(t={}){this.cache=new Map,this.maxSize=t.maxSize||100,this.ttl=t.ttl||300*1e3,this.stats={hits:0,misses:0,evictions:0}}async get(t,e){const s=Date.now(),n=this.cache.get(t);if(n){if(s-n.timestamp<this.ttl)return n.accessCount++,n.lastAccessed=s,this.stats.hits++,this.cache.delete(t),this.cache.set(t,n),n.data;this.cache.delete(t)}this.stats.misses++;const r=await e();return this.set(t,r),r}set(t,e){const s=Date.now();this.cache.size>=this.maxSize&&!this.cache.has(t)&&this.evictLRU(),this.cache.set(t,{data:e,timestamp:s,accessCount:1,lastAccessed:s})}evictLRU(){const t=this.cache.keys().next().value;t!==void 0&&(this.cache.delete(t),this.stats.evictions++)}invalidate(t){t?this.cache.delete(t):this.cache.clear()}clear(){this.cache.clear(),this.stats={hits:0,misses:0,evictions:0}}getStats(){const t=this.stats.hits+this.stats.misses,e=t>0?this.stats.hits/t:0;return{size:this.cache.size,maxSize:this.maxSize,hits:this.stats.hits,misses:this.stats.misses,evictions:this.stats.evictions,hitRate:e}}getCachedSync(t){const e=this.cache.get(t);if(e){if(this.ttl>0&&Date.now()-e.timestamp>this.ttl){this.cache.delete(t);return}return this.cache.delete(t),this.cache.set(t,e),this.stats.hits++,e.data}}has(t){const e=this.cache.get(t);return e?Date.now()-e.timestamp>=this.ttl?(this.cache.delete(t),!1):!0:!1}}class g extends Error{constructor(t,e,s,n){super(t),this.code=e,this.statusCode=s,this.details=n,this.name="ObjectStackError",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,details:this.details,stack:this.stack}}}class $ extends g{constructor(t,e){super(`Metadata not found for object: ${t}`,"METADATA_NOT_FOUND",404,{objectName:t,...e}),this.name="MetadataNotFoundError"}}class m extends g{constructor(t,e,s,n,r){super(`Bulk ${t} operation failed: ${e} succeeded, ${s} failed`,"BULK_OPERATION_ERROR",500,{operation:t,successCount:e,failureCount:s,errors:n,...r}),this.successCount=e,this.failureCount=s,this.errors=n,this.name="BulkOperationError"}getSummary(){const t=this.successCount+this.failureCount,e=t>0?this.failureCount/t:0;return{operation:this.details?.operation,total:t,successful:this.successCount,failed:this.failureCount,failureRate:e,errors:this.errors}}}class y extends g{constructor(t,e,s,n){super(`Connection error: ${t}`,"CONNECTION_ERROR",n||503,{url:e,...s}),this.url=e,this.name="ConnectionError"}}class p extends g{constructor(t="Authentication failed",e,s){super(t,"AUTHENTICATION_ERROR",s||401,e),this.name="AuthenticationError"}}class b extends g{constructor(t,e,s,n){super(t,"VALIDATION_ERROR",400,{field:e,validationErrors:s,...n}),this.field=e,this.validationErrors=s,this.name="ValidationError"}getValidationErrors(){return this.validationErrors||[]}}function C(u,t){const e=u?.status||u?.statusCode||500,s=u?.message||u?.statusText||"Unknown error",n={context:t,response:{status:e,data:u?.data,headers:u?.headers}};switch(e){case 401:return new p(s,n,401);case 403:return new p(s,n,403);case 404:if(t?.includes("metadata")||t?.includes("schema")||t?.includes("getObjectSchema")){const r=R(t);return new $(r,n)}return new g(s,"NOT_FOUND",404,n);case 400:return new b(s,void 0,u?.data?.errors,n);case 503:return new y(s,u?.config?.url,n,503);case 504:return new y(s,u?.config?.url,n,504);default:return new g(s,"UNKNOWN_ERROR",e,n)}}function R(u){if(!u)return"unknown";const t=u.match(/\(([^)]+)\)/);return t?t[1]:"unknown"}class k{client;connected=!1;metadataCache;connectionState="disconnected";connectionStateListeners=[];batchProgressListeners=[];autoReconnect;maxReconnectAttempts;reconnectDelay;reconnectAttempts=0;baseUrl;token;fetchImpl;constructor(t){this.client=new S(t),this.metadataCache=new O(t.cache),this.autoReconnect=t.autoReconnect??!0,this.maxReconnectAttempts=t.maxReconnectAttempts??3,this.reconnectDelay=t.reconnectDelay??1e3,this.baseUrl=t.baseUrl,this.token=t.token,this.fetchImpl=t.fetch||globalThis.fetch.bind(globalThis)}async connect(){if(!this.connected){this.setConnectionState("connecting");try{await this.client.connect(),this.connected=!0,this.reconnectAttempts=0,this.setConnectionState("connected")}catch(t){const e=t instanceof Error?t.message:"Failed to connect to ObjectStack server",s=new y(e,void 0,{originalError:t});if(this.setConnectionState("error",s),this.autoReconnect&&this.reconnectAttempts<this.maxReconnectAttempts)await this.attemptReconnect();else throw s}}}async attemptReconnect(){this.reconnectAttempts++,this.setConnectionState("reconnecting");const t=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);await new Promise(e=>setTimeout(e,t)),this.connected=!1,await this.connect()}getConnectionState(){return this.connectionState}isConnected(){return this.connected&&this.connectionState==="connected"}onConnectionStateChange(t){return this.connectionStateListeners.push(t),()=>{const e=this.connectionStateListeners.indexOf(t);e>-1&&this.connectionStateListeners.splice(e,1)}}onBatchProgress(t){return this.batchProgressListeners.push(t),()=>{const e=this.batchProgressListeners.indexOf(t);e>-1&&this.batchProgressListeners.splice(e,1)}}setConnectionState(t,e){this.connectionState=t;const s={state:t,timestamp:Date.now(),error:e};this.connectionStateListeners.forEach(n=>{try{n(s)}catch(r){console.error("Error in connection state listener:",r)}})}emitBatchProgress(t){this.batchProgressListeners.forEach(e=>{try{e(t)}catch(s){console.error("Error in batch progress listener:",s)}})}async find(t,e){if(await this.connect(),e?.$expand&&e.$expand.length>0){const r=await this.rawFindWithPopulate(t,e);return this.normalizeQueryResult(r,e)}const s=this.convertQueryParams(e),n=await this.client.data.find(t,s);return this.normalizeQueryResult(n,e)}async findOne(t,e,s){if(await this.connect(),s?.$expand&&s.$expand.length>0)try{const n={...s,$filter:{_id:String(e)},$top:1},r=await this.rawFindWithPopulate(t,n);if(Array.isArray(r))return r[0]||null;const a=r;return(a.records||a.value||[])[0]||null}catch(n){if(n?.status===404)return null;throw n}try{return(await this.client.data.get(t,String(e))).record}catch(n){if(n?.status===404)return null;throw n}}async create(t,e){return await this.connect(),(await this.client.data.create(t,e)).record}async update(t,e,s){return await this.connect(),(await this.client.data.update(t,String(e),s)).record}async delete(t,e){return await this.connect(),(await this.client.data.delete(t,String(e))).deleted}async bulk(t,e,s){if(await this.connect(),!s||s.length===0)return[];const n=s.length;let r=0,a=0;const c=()=>{this.emitBatchProgress({operation:e,total:n,completed:r,failed:a,percentage:n>0?(r+a)/n*100:0})};try{switch(e){case"create":{c();const i=await this.client.data.createMany(t,s);return r=i.length,a=n-r,c(),i}case"delete":{const i=s.map(h=>h.id).filter(Boolean);if(i.length===0){const h=s.map((o,l)=>({index:l,error:`Missing ID for item at index ${l}`}));throw a=s.length,c(),new m("delete",0,s.length,h)}return c(),await this.client.data.deleteMany(t,i),r=i.length,a=n-r,c(),[]}case"update":{if(typeof this.client.data.updateMany=="function")try{c();const o=this.client.data.updateMany,l=await o(t,s);return r=l.length,a=n-r,c(),l}catch{}const i=[],h=[];for(let o=0;o<s.length;o++){const l=s[o],f=l.id;if(!f){h.push({index:o,error:"Missing ID"}),a++,c();continue}try{const d=await this.client.data.update(t,String(f),l);i.push(d.record),r++,c()}catch(d){const w=d instanceof Error?d.message:String(d);h.push({index:o,error:w}),a++,c()}}if(h.length>0)throw new m("update",i.length,h.length,h,{resource:t,totalRecords:s.length});return i}default:throw new g(`Unsupported bulk operation: ${e}`,"UNSUPPORTED_OPERATION",400)}}catch(i){if(c(),i instanceof m||i instanceof g)throw i;const h=i instanceof Error?i.message:String(i),o=s.map((l,f)=>({index:f,error:h}));throw new m(e,0,s.length,o,{resource:t,originalError:i})}}normalizeQueryResult(t,e){if(Array.isArray(t))return{data:t,total:t.length,page:1,pageSize:t.length,hasMore:!1};const s=t,n=s.records||s.value||[],r=s.total??s.count??n.length;return{data:n,total:r,page:e?.$skip&&e.$top?Math.floor(e.$skip/e.$top)+1:1,pageSize:e?.$top,hasMore:e?.$top?n.length===e.$top:!1}}async rawFindWithPopulate(t,e){const s=new URLSearchParams;if(e.$expand&&e.$expand.length>0&&s.set("populate",e.$expand.join(",")),e.$top!==void 0&&s.set("top",String(e.$top)),e.$skip!==void 0&&s.set("skip",String(e.$skip)),e.$select&&e.$select.length>0&&s.set("select",e.$select.join(",")),e.$orderby)if(Array.isArray(e.$orderby)){const f=e.$orderby.map(d=>{if(typeof d=="string")return d;const w=d.field;return(d.order||"asc")==="desc"?`-${w}`:w}).join(",");s.set("sort",f)}else{const f=Object.entries(e.$orderby).map(([d,w])=>w==="desc"?`-${d}`:d).join(",");s.set("sort",f)}e.$filter&&s.set("filter",JSON.stringify(e.$filter));const n=this.baseUrl.replace(/\/$/,""),r=s.toString(),c=/\/api\/v\d+$/i.test(n)?"/data":"/api/v1/data",i=`${n}${c}/${t}${r?`?${r}`:""}`,h={"Content-Type":"application/json"};this.token&&(h.Authorization=`Bearer ${this.token}`);const o=await this.fetchImpl(i,{method:"GET",headers:h});if(!o.ok){const f=await o.json().catch(()=>({message:o.statusText})),d=new Error(f?.error?.message||f?.message||o.statusText);throw d.status=o.status,d}const l=await o.json();return l&&typeof l.success=="boolean"&&"data"in l?l.data:l}convertQueryParams(t){if(!t)return{};const e={};if(t.$select&&(e.select=t.$select),t.$filter&&(Array.isArray(t.$filter)?e.filters=t.$filter:e.filters=A(t.$filter)),t.$orderby)if(Array.isArray(t.$orderby))e.sort=t.$orderby.map(s=>{if(typeof s=="string")return s;const n=s.field;return(s.order||"asc")==="desc"?`-${n}`:n});else{const s=Object.entries(t.$orderby).map(([n,r])=>r==="desc"?`-${n}`:n);e.sort=s}return t.$skip!==void 0&&(e.skip=t.$skip),t.$top!==void 0&&(e.top=t.$top),e}async getObjectSchema(t){await this.connect();try{return await this.metadataCache.get(t,async()=>{const s=await this.client.meta.getItem("object",t);return s&&s.item?s.item:s})}catch(e){const s=e;throw s?.status===404||s?.statusCode===404?new $(t,{originalError:e}):e instanceof g?e:C(s,`getObjectSchema(${t})`)}}getClient(){return this.client}async getDiscovery(){try{return await this.connect(),this.client.discoveryInfo||null}catch{return null}}async getView(t,e){await this.connect();try{const s=`view:${t}:${e}`;return await this.metadataCache.get(s,async()=>{const n=await this.client.meta.getItem(t,`views/${e}`);return n&&n.item?n.item:n??null})}catch{return null}}async getApp(t){await this.connect();try{const e=`app:${t}`;return await this.metadataCache.get(e,async()=>{const s=await this.client.meta.getItem("apps",t);return s&&s.item?s.item:s??null})}catch{return null}}async getPage(t){await this.connect();try{const e=`page:${t}`;return await this.metadataCache.get(e,async()=>{const s=await this.client.meta.getItem("pages",t);return s&&s.item?s.item:s??null})}catch{return null}}async aggregate(t,e){await this.connect();try{const s={object:t,measures:[{field:e.field,function:e.function}],dimensions:[e.groupBy]};e.filter&&(s.filters=e.filter);const n=await this.client.analytics.query(s);return Array.isArray(n)?n:n?.data&&Array.isArray(n.data)?n.data:n?.results&&Array.isArray(n.results)?n.results:[]}catch{const n=(await this.find(t)).data||[];return n.length===0?[]:this.aggregateClientSide(n,e)}}aggregateClientSide(t,e){const{field:s,function:n,groupBy:r}=e,a={};for(const c of t){const i=String(c[r]??"Unknown");a[i]||(a[i]=[]),a[i].push(c)}return Object.entries(a).map(([c,i])=>{const h=i.map(l=>Number(l[s])||0);let o;switch(n){case"count":o=i.length;break;case"avg":o=h.length>0?h.reduce((l,f)=>l+f,0)/h.length:0;break;case"min":o=h.length>0?Math.min(...h):0;break;case"max":o=h.length>0?Math.max(...h):0;break;case"sum":default:o=h.reduce((l,f)=>l+f,0);break}return{[r]:c,[s]:o}})}async getItems(t,e){return await this.connect(),await Promise.all(e.map(async n=>{const r=`${t}:${n}`;return this.metadataCache.get(r,async()=>{const a=await this.client.meta.getItem(t,n);return a&&a.item?a.item:a})}))}getCached(t){return this.metadataCache.getCachedSync(t)}getCacheStats(){return this.metadataCache.getStats()}invalidateCache(t){this.metadataCache.invalidate(t)}clearCache(){this.metadataCache.clear()}async uploadFile(t,e,s){await this.connect();const n=new FormData;n.append("file",e),s?.recordId&&n.append("recordId",s.recordId),s?.fieldName&&n.append("fieldName",s.fieldName),s?.metadata&&n.append("metadata",JSON.stringify(s.metadata));const r=`${this.baseUrl}/api/data/${encodeURIComponent(t)}/upload`,a=await fetch(r,{method:"POST",body:n,headers:{...this.getAuthHeaders()}});if(!a.ok){const c=await a.json().catch(()=>({message:a.statusText}));throw new g(c.message||`Upload failed with status ${a.status}`,"UPLOAD_ERROR",a.status)}return a.json()}async uploadFiles(t,e,s){await this.connect();const n=new FormData;e.forEach((c,i)=>{n.append("files",c,c.name||`file-${i}`)}),s?.recordId&&n.append("recordId",s.recordId),s?.fieldName&&n.append("fieldName",s.fieldName),s?.metadata&&n.append("metadata",JSON.stringify(s.metadata));const r=`${this.baseUrl}/api/data/${encodeURIComponent(t)}/upload`,a=await fetch(r,{method:"POST",body:n,headers:{...this.getAuthHeaders()}});if(!a.ok){const c=await a.json().catch(()=>({message:a.statusText}));throw new g(c.message||`Upload failed with status ${a.status}`,"UPLOAD_ERROR",a.status)}return a.json()}getAuthHeaders(){const t={};return this.token&&(t.Authorization=`Bearer ${this.token}`),t}}export{k as O};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{r as v,j as Q,R as F}from"./vendor-react-9M-xu2bR.js";import"./vendor-objectstack-YKtcdalX.js";class tr{components=new Map;register(e,t,s){const n=s?.namespace?`${s.namespace}:${e}`:e;s?.namespace||console.warn(`Registering component "${e}" without a namespace is deprecated. Please provide a namespace in the meta parameter.
|
|
2
|
+
|
|
3
|
+
Migration:
|
|
4
|
+
// Before (deprecated):
|
|
5
|
+
registry.register('${e}', MyComponent);
|
|
6
|
+
|
|
7
|
+
// After:
|
|
8
|
+
registry.register('${e}', MyComponent, { namespace: 'my-plugin' });
|
|
9
|
+
|
|
10
|
+
See: https://github.com/objectstack-ai/objectui/blob/main/MIGRATION_GUIDE.md`),this.components.has(n),this.components.set(n,{type:n,component:t,...s}),s?.namespace&&!s?.skipFallback&&this.components.set(e,{type:n,component:t,...s})}get(e,t){if(t){const s=`${t}:${e}`;return this.components.get(s)?.component}return this.components.get(e)?.component}getConfig(e,t){if(t){const s=`${t}:${e}`;return this.components.get(s)}return this.components.get(e)}has(e,t){if(t){const s=`${t}:${e}`;return this.components.has(s)}return this.components.has(e)}getAllTypes(){return Array.from(this.components.keys())}getAllConfigs(){return Array.from(this.components.values())}getNamespaceComponents(e){return Array.from(this.components.values()).filter(t=>t.namespace===e)}}const rr=new tr;function sr(r){return{$eq:"=",$ne:"!=",$gt:">",$gte:">=",$lt:"<",$lte:"<=",$in:"in",$nin:"notin",$notin:"notin",$contains:"contains",$startswith:"startswith",$between:"between"}[r]||null}function ts(r){const e=[];for(const[t,s]of Object.entries(r))if(s!=null)if(typeof s=="object"&&!Array.isArray(s))for(const[n,i]of Object.entries(s)){if(n==="$regex"){console.warn(`[ObjectUI] Warning: $regex operator is not fully supported. Converting to 'contains' which only supports substring matching, not regex patterns. Field: '${t}', Value: ${JSON.stringify(i)}. Consider using $contains or $startswith instead.`),e.push([t,"contains",i]);continue}const o=sr(n);if(o)e.push([t,o,i]);else throw new Error(`[ObjectUI] Unknown filter operator '${n}' for field '${t}'. Supported operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $contains, $startswith, $between. If you need exact object matching, use the value directly without an operator.`)}else e.push([t,"=",s]);return e.length===0?r:e.length===1?e[0]:["and",...e]}function nr(r){switch(r){case"equals":case"eq":return"=";case"notEquals":case"ne":case"neq":return"!=";case"contains":return"contains";case"notContains":return"notcontains";case"greaterThan":case"gt":return">";case"greaterOrEqual":case"gte":return">=";case"lessThan":case"lt":return"<";case"lessOrEqual":case"lte":return"<=";case"in":return"in";case"notIn":return"not in";case"before":return"<";case"after":return">";default:return r}}function ir(r){if("id"in r&&"filters"in r&&r.label&&Array.isArray(r.filters))return r;if("field"in r&&"operator"in r){const e=nr(r.operator);return{id:`${r.field}-${r.operator}-${String(r.value??"")}`,label:r.label||`${r.field} ${r.operator} ${String(r.value??"")}`,filters:[[r.field,e,r.value]],icon:r.icon,defaultActive:r.defaultActive}}return r}function rs(r){if(!(!r||r.length===0))return r.map(ir)}function ss(r){if(Array.isArray(r))return r;if(r&&typeof r=="object"){if(Array.isArray(r.records))return r.records;if(Array.isArray(r.data))return r.data;if(Array.isArray(r.value))return r.value}return[]}function ns(r,e){if(!r||typeof r!="object")return[];const t=[];for(const[s,n]of Object.entries(r))n&&typeof n=="object"&&(n.type==="lookup"||n.type==="master_detail")&&t.push(s);if(t.length===0)return[];if(e&&Array.isArray(e)&&e.length>0){const s=new Set;for(const n of e)if(typeof n=="string")s.add(n);else if(n&&typeof n=="object"){const i=n.field??n.name??n.fieldName;i&&s.add(i)}return t.filter(n=>s.has(n))}return t}class Ae{scopes=[];constructor(e={}){this.scopes.push(new Map(Object.entries(e)))}pushScope(e){this.scopes.push(new Map(Object.entries(e)))}popScope(){this.scopes.length>1&&this.scopes.pop()}get(e){const t=e.split("."),s=t[0];for(let n=this.scopes.length-1;n>=0;n--)if(this.scopes[n].has(s)){let i=this.scopes[n].get(s);for(let o=1;o<t.length;o++)if(i&&typeof i=="object")i=i[t[o]];else return;return i}}set(e,t){this.scopes.length>0&&this.scopes[this.scopes.length-1].set(e,t)}has(e){const t=e.split(".")[0];for(let s=this.scopes.length-1;s>=0;s--)if(this.scopes[s].has(t))return!0;return!1}toObject(){const e={};for(const t of this.scopes)for(const[s,n]of t.entries())e[s]=n;return e}createChild(e={}){const t=new Ae;return t.scopes=[...this.scopes,new Map(Object.entries(e))],t}}class Et{cache=new Map;maxSize;constructor(e=1e3){this.maxSize=e}compile(e,t){const s=`${e}::${t.join(",")}`;if(this.cache.has(s)){const o=this.cache.get(s);return o.hitCount++,o}this.cache.size>=this.maxSize&&this.evictLFU();const i={fn:this.compileExpression(e,t),varNames:[...t],expression:e,compiledAt:Date.now(),hitCount:1};return this.cache.set(s,i),i}compileExpression(e,t){return new Function(...t,`"use strict"; return (${e});`)}evictLFU(){let e=null,t=1/0,s=1/0;for(const[n,i]of this.cache.entries())(i.hitCount<s||i.hitCount===s&&i.compiledAt<t)&&(e=n,t=i.compiledAt,s=i.hitCount);e&&this.cache.delete(e)}has(e,t){const s=`${e}::${t.join(",")}`;return this.cache.has(s)}clear(){this.cache.clear()}getStats(){let e=0;const t=[];for(const s of this.cache.values())e+=s.hitCount,t.push({expression:s.expression,hitCount:s.hitCount});return{size:this.cache.size,maxSize:this.maxSize,totalHits:e,entries:t.sort((s,n)=>n.hitCount-s.hitCount)}}}class Ft{functions=new Map;constructor(){this.registerDefaults()}register(e,t){this.functions.set(e.toUpperCase(),t)}get(e){return this.functions.get(e.toUpperCase())}has(e){return this.functions.has(e.toUpperCase())}getNames(){return Array.from(this.functions.keys())}toObject(){const e={};for(const[t,s]of this.functions)e[t]=s;return e}registerDefaults(){this.registerAggregationFunctions(),this.registerDateFunctions(),this.registerLogicFunctions(),this.registerStringFunctions(),this.registerStringSearchFunctions(),this.registerStatisticalFunctions()}registerAggregationFunctions(){this.register("SUM",(...e)=>ae(e).reduce((s,n)=>s+n,0)),this.register("AVG",(...e)=>{const t=ae(e);return t.length===0?0:t.reduce((s,n)=>s+n,0)/t.length}),this.register("COUNT",(...e)=>Vt(e).filter(s=>s!=null).length),this.register("MIN",(...e)=>{const t=ae(e);return t.length===0?0:Math.min(...t)}),this.register("MAX",(...e)=>{const t=ae(e);return t.length===0?0:Math.max(...t)})}registerDateFunctions(){this.register("TODAY",()=>new Date().toISOString().split("T")[0]),this.register("NOW",()=>new Date().toISOString()),this.register("DATEADD",(e,t,s)=>{const n=new Date(e);if(isNaN(n.getTime()))throw new Error(`DATEADD: Invalid date "${e}"`);switch(String(s).toLowerCase()){case"day":case"days":n.setDate(n.getDate()+t);break;case"month":case"months":n.setMonth(n.getMonth()+t);break;case"year":case"years":n.setFullYear(n.getFullYear()+t);break;case"hour":case"hours":n.setHours(n.getHours()+t);break;case"minute":case"minutes":n.setMinutes(n.getMinutes()+t);break;default:throw new Error(`DATEADD: Unsupported unit "${s}"`)}return n.toISOString()}),this.register("DATEDIFF",(e,t,s)=>{const n=new Date(e),i=new Date(t);if(isNaN(n.getTime()))throw new Error(`DATEDIFF: Invalid date "${e}"`);if(isNaN(i.getTime()))throw new Error(`DATEDIFF: Invalid date "${t}"`);const o=i.getTime()-n.getTime();switch(String(s).toLowerCase()){case"day":case"days":return Math.floor(o/(1e3*60*60*24));case"month":case"months":return(i.getFullYear()-n.getFullYear())*12+(i.getMonth()-n.getMonth());case"year":case"years":return i.getFullYear()-n.getFullYear();case"hour":case"hours":return Math.floor(o/(1e3*60*60));case"minute":case"minutes":return Math.floor(o/(1e3*60));default:throw new Error(`DATEDIFF: Unsupported unit "${s}"`)}}),this.register("DATEFORMAT",(e,t)=>{const s=new Date(e);if(isNaN(s.getTime()))throw new Error(`DATEFORMAT: Invalid date "${e}"`);const n=(i,o=2)=>String(i).padStart(o,"0");return t.replace("YYYY",String(s.getFullYear())).replace("YY",String(s.getFullYear()).slice(-2)).replace("MM",n(s.getMonth()+1)).replace("DD",n(s.getDate())).replace("HH",n(s.getHours())).replace("mm",n(s.getMinutes())).replace("ss",n(s.getSeconds()))})}registerLogicFunctions(){this.register("IF",(e,t,s)=>e?t:s),this.register("AND",(...e)=>e.every(Boolean)),this.register("OR",(...e)=>e.some(Boolean)),this.register("NOT",e=>!e),this.register("SWITCH",(e,...t)=>{for(let s=0;s<t.length-1;s+=2)if(e===t[s])return t[s+1];if(t.length%2===1)return t[t.length-1]})}registerStringFunctions(){this.register("CONCAT",(...e)=>e.map(t=>String(t??"")).join("")),this.register("LEFT",(e,t)=>String(e??"").substring(0,t)),this.register("RIGHT",(e,t)=>{const s=String(e??"");return s.substring(Math.max(0,s.length-t))}),this.register("TRIM",e=>String(e??"").trim()),this.register("UPPER",e=>String(e??"").toUpperCase()),this.register("LOWER",e=>String(e??"").toLowerCase())}registerStringSearchFunctions(){this.register("FIND",(e,t,s)=>String(t??"").indexOf(String(e??""),s??0)),this.register("REPLACE",(e,t,s)=>String(e??"").split(String(t??"")).join(String(s??""))),this.register("SUBSTRING",(e,t,s)=>{const n=String(e??"");return s!==void 0?n.substring(t,t+s):n.substring(t)}),this.register("REGEX",(e,t,s)=>{const n=String(e??"");return new RegExp(t,s).test(n)}),this.register("LEN",e=>String(e??"").length)}registerStatisticalFunctions(){this.register("MEDIAN",(...e)=>{const t=ae(e).sort((n,i)=>n-i);if(t.length===0)return 0;const s=Math.floor(t.length/2);return t.length%2!==0?t[s]:(t[s-1]+t[s])/2}),this.register("STDEV",(...e)=>{const t=ae(e);if(t.length<2)return 0;const s=t.reduce((o,l)=>o+l,0)/t.length,i=t.map(o=>(o-s)**2).reduce((o,l)=>o+l,0)/(t.length-1);return Math.sqrt(i)}),this.register("VARIANCE",(...e)=>{const t=ae(e);if(t.length<2)return 0;const s=t.reduce((i,o)=>i+o,0)/t.length;return t.map(i=>(i-s)**2).reduce((i,o)=>i+o,0)/(t.length-1)}),this.register("PERCENTILE",(e,...t)=>{const s=ae(t).sort((g,k)=>g-k);if(s.length===0)return 0;const i=Math.max(0,Math.min(100,e))/100*(s.length-1),o=Math.floor(i),l=Math.ceil(i);if(o===l)return s[o];const y=i-o;return s[o]+y*(s[l]-s[o])})}}function ae(r){const e=[];for(const t of r)if(Array.isArray(t))e.push(...ae(t));else{const s=Number(t);isNaN(s)||e.push(s)}return e}function Vt(r){const e=[];for(const t of r)Array.isArray(t)?e.push(...Vt(t)):e.push(t);return e}class ye{context;cache;formulas;constructor(e,t,s){e instanceof Ae?this.context=e:this.context=new Ae(e||{}),this.cache=t||new Et,this.formulas=s||new Ft}evaluate(e,t={}){if(typeof e!="string")return e;const{defaultValue:s,throwOnError:n=!1,sanitize:i=!0}=t;try{if(!e.includes("${"))return e;const l=e.match(/^\$\{([^}]+)\}$/);return l?this.evaluateExpression(l[1].trim(),{sanitize:i}):e.replace(/\$\{([^}]+)\}/g,(y,g)=>{try{const k=this.evaluateExpression(g.trim(),{sanitize:i});return String(k??"")}catch(k){if(n)throw k;return console.warn(`Expression evaluation failed for: ${g}`,k),y}})}catch(o){if(n)throw o;return console.warn(`Failed to evaluate expression: ${e}`,o),s??e}}evaluateExpression(e,t={}){const{sanitize:s=!0}=t;if(!(!e||e.trim()==="")){if(s&&this.isDangerous(e))throw new Error(`Potentially dangerous expression detected: ${e}`);try{const n=this.context.toObject(),o={...this.formulas.toObject(),...n},l=Object.keys(o),y=Object.values(o);return this.cache.compile(e,l).fn(...y)}catch(n){throw new Error(`Failed to evaluate expression "${e}": ${n.message}`)}}}isDangerous(e){return[/eval\s*\(/i,/Function\s*\(/i,/setTimeout\s*\(/i,/setInterval\s*\(/i,/import\s*\(/i,/require\s*\(/i,/process\./i,/global\./i,/window\./i,/document\./i,/__proto__/i,/constructor\s*\(/i,/prototype\./i].some(s=>s.test(e))}evaluateCondition(e,t={}){return typeof e=="boolean"?e:e?!!this.evaluate(e,t):!0}updateContext(e){Object.entries(e).forEach(([t,s])=>{this.context.set(t,s)})}getContext(){return this.context}withContext(e){return new ye(this.context.createChild(e),this.cache,this.formulas)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear()}getFormulas(){return this.formulas}registerFunction(e,t){this.formulas.register(e,t)}}const ar=new Et,or=new Ft;function is(r,e){const t=new ye({...e,data:e},ar,or);try{return(/\$\{/.test(r)?t.evaluate(r,{throwOnError:!0}):t.evaluateExpression(r))===!0}catch{return!1}}class Be{handlers=new Map;evaluator;context;confirmHandler;toastHandler;modalHandler;navigationHandler;paramCollectionHandler;constructor(e={}){this.context=e,this.evaluator=new ye(e),this.confirmHandler=async t=>window.confirm(t),this.toastHandler=null,this.modalHandler=null,this.navigationHandler=null,this.paramCollectionHandler=null}setConfirmHandler(e){this.confirmHandler=e}setToastHandler(e){this.toastHandler=e}setModalHandler(e){this.modalHandler=e}setNavigationHandler(e){this.navigationHandler=e}setParamCollectionHandler(e){this.paramCollectionHandler=e}registerHandler(e,t){this.handlers.set(e,t)}unregisterHandler(e){this.handlers.delete(e)}async execute(e){try{const t=e.type||e.actionType||e.name||"";if(e.condition&&!this.evaluator.evaluateCondition(e.condition))return{success:!1,error:"Action condition not met"};if(e.disabled&&(typeof e.disabled=="string"?this.evaluator.evaluateCondition(e.disabled):e.disabled))return{success:!1,error:"Action is disabled"};const s=e.confirm?.message||e.confirmText;if(s&&!await this.confirmHandler(this.evaluator.evaluate(s),e.confirm?{title:e.confirm.title,confirmText:e.confirm.confirmText,cancelText:e.confirm.cancelText}:void 0))return{success:!1,error:"Action cancelled by user"};if(e.actionParams&&Array.isArray(e.actionParams)&&e.actionParams.length>0&&this.paramCollectionHandler){const i=await this.paramCollectionHandler(e.actionParams);if(i===null)return{success:!1,error:"Action cancelled by user (params)"};e.params={...e.params||{},...i}}if(t&&this.handlers.has(t)){const o=await this.handlers.get(t)(e,this.context);return await this.handlePostExecution(e,o),o}let n;switch(t){case"script":n=await this.executeScript(e);break;case"url":n=await this.executeUrl(e);break;case"modal":n=await this.executeModal(e);break;case"flow":n=await this.executeFlow(e);break;case"api":n=await this.executeAPI(e);break;case"navigation":n=await this.executeNavigation(e);break;default:e.navigate?n=await this.executeNavigation(e):e.api||e.endpoint?n=await this.executeAPI(e):e.onClick?(await e.onClick(),n={success:!0}):n=await this.executeActionSchema(e)}return await this.handlePostExecution(e,n),n}catch(t){const s={success:!1,error:t.message};return await this.handlePostExecution(e,s),s}}async executeChain(e,t="sequential"){if(e.length===0)return{success:!0};if(t==="parallel"){const n=await Promise.allSettled(e.map(l=>this.execute(l)));if(n.filter(l=>l.status==="rejected"||l.status==="fulfilled"&&!l.value.success).length>0)return{success:!1,error:n.find(y=>y.status==="fulfilled"&&!y.value.success)?.value?.error||"One or more parallel actions failed"};const o=n[n.length-1];return o.status==="fulfilled"?o.value:{success:!1,error:"Action failed"}}let s={success:!0};for(const n of e)if(s=await this.execute(n),!s.success)return s;return s}async handlePostExecution(e,t){if(this.toastHandler){const s=e.toast??{showOnSuccess:!0,showOnError:!0},n=e.toast?.duration;if(t.success&&s.showOnSuccess!==!1){const i=e.successMessage||"Action completed successfully";this.toastHandler(i,{type:"success",duration:n})}if(!t.success&&s.showOnError!==!1&&t.error){const i=e.errorMessage||t.error;this.toastHandler(i,{type:"error",duration:n})}}if(e.refreshAfter&&t.success&&(t.reload=!0),e.chain&&e.chain.length>0&&t.success){const s=await this.executeChain(e.chain,e.chainMode||"sequential");s.success||(t.success=!1,t.error=s.error),s.data&&(t.data=s.data),s.redirect&&(t.redirect=s.redirect),s.reload&&(t.reload=!0)}if(t.success&&e.onSuccess){const s=Array.isArray(e.onSuccess)?e.onSuccess:[e.onSuccess];await this.executeChain(s,"sequential")}if(!t.success&&e.onFailure){const s=Array.isArray(e.onFailure)?e.onFailure:[e.onFailure];await this.executeChain(s,"sequential")}}async executeScript(e){const t=e.execute||e.target;if(!t)return{success:!1,error:"No script provided for script action"};try{return{success:!0,data:this.evaluator.evaluate(`\${${t}}`)}}catch(s){return{success:!1,error:`Script execution failed: ${s.message}`}}}async executeUrl(e){const t=e.target||e.redirect;if(!t)return{success:!1,error:"No URL provided for url action"};const s=this.evaluator.evaluate(t);if(!this.isValidUrl(s))return{success:!1,error:"Invalid URL scheme. Only http://, https://, and relative URLs are allowed."};const n=s.startsWith("http://")||s.startsWith("https://"),i=e.params?.newTab??n;if(this.navigationHandler)return this.navigationHandler(s,{external:n,newTab:i}),{success:!0};if(i)window.open(s,"_blank","noopener,noreferrer");else return{success:!0,redirect:s};return{success:!0}}async executeModal(e){const t=e.modal||e.target||e.params?.schema;return t?this.modalHandler?await this.modalHandler(t,this.context):{success:!0,modal:t}:{success:!1,error:"No modal schema or target provided for modal action"}}async executeFlow(e){const t=e.target||e.name;return t?this.handlers.has("flow")?await this.handlers.get("flow")(e,this.context):{success:!1,error:`Flow handler not registered. Cannot execute flow: ${t}`}:{success:!1,error:"No flow target provided for flow action"}}async executeActionSchema(e){const t={success:!0};if(e.api||e.endpoint){const s=await this.executeAPI(e);if(!s.success)return s;t.data=s.data}return e.onClick&&await e.onClick(),t.reload=e.reload!==!1,t.close=e.close!==!1,e.redirect&&(t.redirect=this.evaluator.evaluate(e.redirect)),t}async executeNavigation(e){const t=e.navigate||e,s=this.evaluator.evaluate(t.to||t.target);if(!this.isValidUrl(s))return{success:!1,error:"Invalid URL scheme. Only http://, https://, and relative URLs are allowed."};const n=t.external||typeof s=="string"&&(s.startsWith("http://")||s.startsWith("https://"));if(this.navigationHandler)return this.navigationHandler(s,{external:n,newTab:t.newTab??n,replace:t.replace}),{success:!0};if(n)window.open(s,"_blank","noopener,noreferrer");else return{success:!0,redirect:s};return{success:!0}}async executeAPI(e){const t=e.api||e.endpoint||e.target;if(!t)return{success:!1,error:"No API endpoint provided"};try{let s,n,i={"Content-Type":"application/json"},o,l="json";if(typeof t=="string")s=t,n=e.method||"POST",o=JSON.stringify(e.params||this.context.data||{});else{const h=t;if(s=h.url,n=h.method||e.method||"POST",i={...i,...h.headers},l=h.responseType||"json",h.queryParams){const C=new URLSearchParams(h.queryParams);s=`${s}${s.includes("?")?"&":"?"}${C.toString()}`}h.body?o=typeof h.body=="string"?h.body:JSON.stringify(h.body):n!=="GET"&&n!=="HEAD"&&(o=JSON.stringify(e.params||this.context.data||{}))}const y={method:n,headers:i};o&&n!=="GET"&&n!=="HEAD"&&(y.body=o);const g=await fetch(s,y);if(!g.ok)throw new Error(`HTTP ${g.status}: ${g.statusText}`);let k;switch(l){case"text":k=await g.text();break;case"blob":k=await g.blob();break;default:k=await g.json()}return{success:!0,data:k}}catch(s){return{success:!1,error:s.message}}}isValidUrl(e){return typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("./"))}updateContext(e){this.context={...this.context,...e},this.evaluator.updateContext(e)}getContext(){return this.context}getEvaluator(){return this.evaluator}}function dt(r){if(typeof r!="object"||r===null)return!1;const e=r;return typeof e.id=="string"&&typeof e.type=="string"&&typeof e.objectName=="string"&&typeof e.recordId=="string"&&typeof e.timestamp=="number"}class ke{undoStack=[];redoStack=[];maxHistory;listeners=new Set;constructor(e){this.maxHistory=e?.maxHistory??50}push(e){this.undoStack.push(e),this.undoStack.length>this.maxHistory&&this.undoStack.shift(),this.redoStack=[],this.notify()}peekUndo(){return this.undoStack[this.undoStack.length-1]}peekRedo(){return this.redoStack[this.redoStack.length-1]}popUndo(){const e=this.undoStack.pop();return e&&(this.redoStack.push(e),this.notify()),e}popRedo(){const e=this.redoStack.pop();return e&&(this.undoStack.push(e),this.notify()),e}clear(){this.undoStack=[],this.redoStack=[],this.notify()}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}get undoCount(){return this.undoStack.length}get redoCount(){return this.redoStack.length}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}getHistory(){return[...this.undoStack]}getRedoHistory(){return[...this.redoStack]}pushBatch(e){e.length!==0&&(this.undoStack.push(...e),this.undoStack.length>this.maxHistory&&this.undoStack.splice(0,this.undoStack.length-this.maxHistory),this.redoStack=[],this.notify())}popUndoBatch(e){const t=Math.min(e,this.undoStack.length);if(t===0)return[];const s=this.undoStack.splice(this.undoStack.length-t,t);return this.redoStack.push(...s),this.notify(),s}popRedoBatch(e){const t=Math.min(e,this.redoStack.length);if(t===0)return[];const s=this.redoStack.splice(this.redoStack.length-t,t);return this.undoStack.push(...s),this.notify(),s}static STORAGE_KEY="objectui:undo-history";saveToStorage(){try{const e=JSON.stringify({undoStack:this.undoStack,redoStack:this.redoStack});localStorage.setItem(ke.STORAGE_KEY,e)}catch{}}loadFromStorage(){try{if(typeof localStorage>"u")return;const e=localStorage.getItem(ke.STORAGE_KEY);if(!e)return;const t=JSON.parse(e);Array.isArray(t.undoStack)&&(this.undoStack=t.undoStack.filter(dt)),Array.isArray(t.redoStack)&&(this.redoStack=t.redoStack.filter(dt)),this.undoStack.length>this.maxHistory&&this.undoStack.splice(0,this.undoStack.length-this.maxHistory),this.notify()}catch{}}notify(){this.listeners.forEach(e=>e())}}const ue=new ke;var ur={};const ce="__debug";function lr(r){let e=r;if(e===void 0)try{e=typeof window<"u"?window.location.search:""}catch{e=""}const t=new URLSearchParams(e),s=t.has(ce),n=t.has(`${ce}_schema`),i=t.has(`${ce}_perf`),o=t.has(`${ce}_data`),l=t.has(`${ce}_expr`),y=t.has(`${ce}_events`),g=t.has(`${ce}_registry`);return{enabled:s||(n||i||o||l||y||g),...n&&{schema:n},...i&&{perf:i},...o&&{data:o},...l&&{expr:l},...y&&{events:y},...g&&{registry:g}}}function qe(){try{if(typeof window<"u")try{if(lr(window.location.search).enabled)return!0}catch{}const r=typeof globalThis<"u"&&globalThis.OBJECTUI_DEBUG;return r===!0||r==="true"||typeof process<"u"&&ur?.OBJECTUI_DEBUG==="true"}catch{return!1}}function ft(r,e,t){qe()&&(t!==void 0?console.log(`[ObjectUI Debug][${r}] ${e}`,t):console.log(`[ObjectUI Debug][${r}] ${e}`))}const Pe=new Map;function cr(r){qe()&&Pe.set(r,performance.now())}function dr(r){if(!qe())return;const e=Pe.get(r);if(e!==void 0){const t=(performance.now()-e).toFixed(2);console.log(`[ObjectUI Debug][perf] ${r}: ${t}ms`),Pe.delete(r)}}const ht=200;class de{static instance=null;entries=[];subscribers=new Set;static getInstance(){return de.instance||(de.instance=new de),de.instance}static resetInstance(){de.instance=null}addPerf(e){this.push({kind:"perf",data:e})}addExpr(e){this.push({kind:"expr",data:e})}addEvent(e){this.push({kind:"event",data:e})}getEntries(e){return e?this.entries.filter(t=>t.kind===e):this.entries.slice()}clear(){this.entries=[]}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}push(e){this.entries.push(e),this.entries.length>ht&&(this.entries=this.entries.slice(-ht));for(const t of this.subscribers)try{t(e)}catch{}}}const De=v.createContext(null),as=({children:r,dataSource:e,debug:t,debugFlags:s})=>{const n=v.useMemo(()=>({dataSource:e,debug:t,debugFlags:s}),[e,t,s]);return Q.jsx(De.Provider,{value:n,children:r})},os=()=>{const r=v.useContext(De);if(!r)throw new Error("useSchemaContext must be used within a SchemaRendererProvider");return r},us=r=>{const t=v.useContext(De)?.dataSource;if(r&&t)return r.split(".").reduce((s,n)=>s&&s[n],t)};function fr(r){if(r!=null)return typeof r=="string"?r:r.defaultValue||r.key}function hr(r){const e={};return r.ariaLabel&&(e["aria-label"]=fr(r.ariaLabel)),r.ariaDescribedBy&&(e["aria-describedby"]=r.ariaDescribedBy),r.role&&(e.role=r.role),e}class gr extends v.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){if(this.state.hasError&&this.state.error){const e=this.state.error;return Q.jsxs("div",{className:"p-4 border border-orange-400 rounded bg-orange-50 text-orange-700 my-2",role:"alert",children:[Q.jsxs("p",{className:"font-medium",children:["Component",this.props.componentType?` "${this.props.componentType}"`:""," failed to render"]}),Q.jsx("p",{className:"text-sm mt-1",children:e.message}),!1,Q.jsx("button",{onClick:this.handleRetry,className:"mt-2 text-sm underline hover:no-underline",children:"Retry"})]})}return this.props.children}}const yr=v.forwardRef(({schema:r,...e},t)=>{const s=v.useContext(De),n=s?.dataSource||{},i=v.useMemo(()=>{if(!r||typeof r=="string")return r;const H=new ye({data:n}),O={...r};if(O.properties&&Object.assign(O,O.properties),typeof O.content=="string"&&(O.content=H.evaluate(O.content)),O.props){const M={...O.props};for(const[L,z]of Object.entries(M))M[L]=H.evaluate(z);O.props=M}return(O.visible!==void 0?!H.evaluateCondition(O.visible):O.visibleOn!==void 0?!H.evaluateCondition(O.visibleOn):O.hidden!==void 0?H.evaluateCondition(O.hidden):O.hiddenOn!==void 0?H.evaluateCondition(O.hiddenOn):!1)&&(O._hidden=!0),(O.disabled!==void 0?H.evaluateCondition(O.disabled):O.disabledOn!==void 0?H.evaluateCondition(O.disabledOn):!1)&&(O._disabled=!0),O},[r,n]);if(!i||i?._hidden)return null;if(typeof i=="string")return Q.jsx(Q.Fragment,{children:i});ft("schema","Rendering schema node",{type:i.type,id:i.id});const o=rr.get(i.type);if(!o)return ft("schema","Component not found in registry",{type:i.type}),Q.jsxs("div",{className:"p-4 border border-red-500 rounded text-red-500 bg-red-50 my-2",role:"alert",children:[Q.jsxs("p",{className:"font-medium",children:["Unknown component type: ",Q.jsx("strong",{children:i.type})]}),!1,Q.jsx("pre",{className:"text-xs mt-2 overflow-auto",children:JSON.stringify(i,null,2)})]});const{type:l,children:y,body:g,schema:k,visible:h,visibleOn:C,hidden:b,hiddenOn:D,disabled:R,disabledOn:x,_hidden:E,_disabled:S,...V}=i,_=hr(i),A=s?.debug||s?.debugFlags?.enabled,U={};A&&(U["data-debug-type"]=i.type,i.id&&(U["data-debug-id"]=i.id)),cr(`render:${i.type}:${i.id??"anon"}`);const W=A?performance.now():0,te=Q.jsx(gr,{componentType:i.type,children:F.createElement(o,{schema:i,...V,...i.props||{},..._,...U,disabled:S||void 0,className:i.className,"data-obj-id":i.id,"data-obj-type":i.type,...e})});if(dr(`render:${i.type}:${i.id??"anon"}`),A&&W){const H=performance.now()-W;de.getInstance().addPerf({type:i.type,id:i.id,durationMs:H,timestamp:Date.now()})}return te});yr.displayName="SchemaRenderer";function ls(r,e={}){return v.useMemo(()=>new ye(e).evaluateCondition(r),[r,e])}function cs(r={}){const e="context"in r?r:{context:r},{context:t={},onConfirm:s,onToast:n,onModal:i,onNavigate:o}=e,[l,y]=v.useState(!1),[g,k]=v.useState(null),[h,C]=v.useState(null),b=v.useMemo(()=>{const x=new Be(t);return s&&x.setConfirmHandler(s),n&&x.setToastHandler(n),i&&x.setModalHandler(i),o&&x.setNavigationHandler(o),x},[JSON.stringify(t)]),D=v.useCallback(async x=>{y(!0),k(null),C(null);try{const E=await b.execute(x);return C(E),E.success||k(E.error||"Action failed"),E}catch(E){const S=E.message;k(S);const V={success:!1,error:S};return C(V),V}finally{y(!1)}},[b]),R=v.useCallback(x=>{b.updateContext(x)},[b]);return{execute:D,loading:l,error:g,result:h,updateContext:R,runner:b}}function ds(r){const{navigation:e,objectName:t,onNavigate:s,onRowClick:n}=r,[i,o]=v.useState(!1),[l,y]=v.useState(null),g=e?.mode??"page",k=e?.width,h=e?.view,C=g==="drawer"||g==="modal"||g==="split"||g==="popover",b=v.useCallback(()=>{o(!1),y(null)},[]),D=v.useCallback(x=>{y(x),o(!0)},[]),R=v.useCallback(x=>{if(n){n(x);return}if(!e){const E=x._id||x.id;s&&E!=null&&s(E,h??"view");return}if(!(g==="none"||e.preventNavigation)){if(g==="new_window"||e.openNewTab){const E=x._id||x.id;if(s&&E!=null){s(E,"new_window");return}const S=h?`/${h}`:"",V=t?`/${t}/${E}${S}`:`/${E}${S}`;window.open(V,"_blank");return}if(g==="page"){const E=x._id||x.id;s&&E!=null&&s(E,h??"view");return}if(C){y(x),o(!0);return}}},[n,e,g,t,s,C]);return v.useMemo(()=>({isOpen:i,selectedRecord:l,mode:g,close:b,open:D,setIsOpen:o,handleClick:R,width:k,view:h,isOverlay:C}),[i,l,g,b,D,R,k,h,C])}const pr=v.createContext(null);function gt(r){if(!r||r.length===0)return{};const e={};for(const t of r)if(t.defaultValue!==void 0)e[t.name]=t.defaultValue;else switch(t.type){case"number":e[t.name]=0;break;case"boolean":e[t.name]=!1;break;case"object":e[t.name]={};break;case"array":e[t.name]=[];break;case"string":default:e[t.name]="";break}return e}const mr=({definitions:r,children:e})=>{const[t,s]=v.useState(()=>gt(r)),n=v.useCallback((y,g)=>{s(k=>({...k,[y]:g}))},[]),i=v.useCallback(y=>{s(g=>({...g,...y}))},[]),o=v.useCallback(()=>{s(gt(r))},[r]),l=v.useMemo(()=>({variables:t,setVariable:n,setVariables:i,resetVariables:o}),[t,n,i,o]);return Q.jsx(pr.Provider,{value:l,children:e})};mr.displayName="PageVariablesProvider";const br={compact:32,comfortable:40,spacious:52},vr={compact:"py-1 px-2",comfortable:"py-2 px-3",spacious:"py-3 px-4"},wr={compact:"text-xs",comfortable:"text-sm",spacious:"text-base"},Ie=["compact","comfortable","spacious"];function fs(r="comfortable",e){const[t,s]=v.useState(r),n=br,i=vr,o=wr,l=v.useCallback(()=>{s(y=>{const g=Ie.indexOf(y);return Ie[(g+1)%Ie.length]})},[]);return v.useMemo(()=>({mode:t,setMode:s,cycle:l,rowHeight:n[t],paddingClass:i[t],fontSizeClass:o[t]}),[t,l,n,i,o])}v.createContext(null);function Sr(r){return typeof window>"u"?()=>{}:(window.addEventListener("online",r),window.addEventListener("offline",r),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",r)})}function xr(){return typeof navigator<"u"?navigator.onLine:!0}function _r(){return!0}const Dt="objectui-offline-queue";function Cr(){if(typeof localStorage>"u")return[];try{const r=localStorage.getItem(Dt);return r?JSON.parse(r):[]}catch{return[]}}function Ar(r){if(!(typeof localStorage>"u"))try{localStorage.setItem(Dt,JSON.stringify(r))}catch{}}let yt=0;function kr(){return yt+=1,`mut_${Date.now()}_${yt}`}const we={enabled:!0,strategy:"network_first",offlineIndicator:!0,offlineMessage:"You are currently offline. Changes will be synced when reconnected.",queueMaxSize:100};function hs(r={}){const{enabled:e=we.enabled,strategy:t=we.strategy,offlineIndicator:s=we.offlineIndicator,offlineMessage:n=we.offlineMessage,queueMaxSize:i=we.queueMaxSize,sync:o}=r,l=v.useSyncExternalStore(Sr,xr,_r),[y,g]=v.useState(Cr),[k,h]=v.useState("idle"),C=v.useRef(o);C.current=o,v.useEffect(()=>{Ar(y)},[y]),v.useEffect(()=>{e&&(l?k==="offline"&&h("idle"):h("offline"))},[l,e,k]);const b=v.useCallback(x=>{e&&g(E=>{const S={...x,id:kr(),timestamp:Date.now()},V=[...E,S];return V.length>i?V.slice(V.length-i):V})},[e,i]),D=v.useCallback(()=>{g([])},[]),R=v.useCallback(async()=>{if(!(!e||y.length===0)){h("syncing");try{const x=C.current?.batchSize??y.length,E=y.slice(0,x);await new Promise(S=>setTimeout(S,0)),g(S=>S.filter(V=>!E.some(_=>_.id===V.id))),h("idle")}catch{h("error")}}},[e,y]);return v.useEffect(()=>{if(!e||!l||y.length===0)return;const x=setTimeout(()=>{R()},100);return()=>clearTimeout(x)},[l,e]),v.useMemo(()=>({isOnline:l,enabled:e,syncState:k,strategy:t,pendingCount:y.length,queueMutation:b,sync:R,clearQueue:D,showIndicator:s&&!l,offlineMessage:n}),[l,e,k,t,y.length,b,R,D,s,n])}function Ot(){return{canUndo:ue.canUndo,canRedo:ue.canRedo,undoDescription:ue.peekUndo()?.description,redoDescription:ue.peekRedo()?.description,history:ue.getHistory()}}function Er(){return{canUndo:!1,canRedo:!1,undoDescription:void 0,redoDescription:void 0,history:[]}}let Tt=Ot();function Fr(r){return ue.subscribe(()=>{Tt=Ot(),r()})}function Vr(){return Tt}function gs(r={}){const e=v.useRef(r);e.current=r;const t=v.useSyncExternalStore(Fr,Vr,Er),s=v.useCallback(async(o,l,y)=>{const g=e.current.dataSource;if(!g)return;const k=y==="undo"?{create:"delete",update:"update",delete:"create"}[o.type]:o.type;k==="delete"?await g.delete(o.objectName,o.recordId):k==="update"?await g.update(o.objectName,o.recordId,l):await g.create(o.objectName,l)},[]),n=v.useCallback(async()=>{const o=ue.popUndo();o&&(await s(o,o.undoData,"undo"),e.current.onUndo?.(o))},[s]),i=v.useCallback(async()=>{const o=ue.popRedo();o&&(await s(o,o.redoData,"redo"),e.current.onRedo?.(o))},[s]);return v.useEffect(()=>{const o=l=>{!(l.ctrlKey||l.metaKey)||l.key.toLowerCase()!=="z"||(l.preventDefault(),l.shiftKey?i():n())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n,i]),v.useMemo(()=>({...t,undo:n,redo:i}),[t,n,i])}const Rt=v.createContext(null),Dr=({children:r,context:e={},onConfirm:t,onToast:s,onModal:n,onNavigate:i,onParamCollection:o,handlers:l})=>{const[y,g]=v.useState(!1),[k,h]=v.useState(null),[C,b]=v.useState(null),D=v.useMemo(()=>{const V=new Be(e);return t&&V.setConfirmHandler(t),s&&V.setToastHandler(s),n&&V.setModalHandler(n),i&&V.setNavigationHandler(i),o&&V.setParamCollectionHandler(o),l&&Object.entries(l).forEach(([_,A])=>{V.registerHandler(_,A)}),V},[JSON.stringify(e)]),R=v.useCallback(async V=>{g(!0),h(null),b(null);try{const _=await D.execute(V);return b(_),_.success||h(_.error||"Action failed"),_}catch(_){const A=_.message;h(A);const U={success:!1,error:A};return b(U),U}finally{g(!1)}},[D]),x=v.useCallback(async(V,_)=>{g(!0),h(null),b(null);try{const A=await D.executeChain(V,_);return b(A),A.success||h(A.error||"Chain failed"),A}catch(A){const U=A.message;h(U);const W={success:!1,error:U};return b(W),W}finally{g(!1)}},[D]),E=v.useCallback(V=>{D.updateContext(V)},[D]),S=v.useMemo(()=>({execute:R,executeChain:x,loading:y,error:k,result:C,runner:D,updateContext:E}),[R,x,y,k,C,D,E]);return Q.jsx(Rt.Provider,{value:S,children:r})};Dr.displayName="ActionProvider";function ys(){const r=v.useContext(Rt);if(!r){const e=new Be;return{execute:t=>e.execute(t),executeChain:(t,s)=>e.executeChain(t,s),loading:!1,error:null,result:null,runner:e,updateContext:t=>e.updateContext(t)}}return r}v.createContext(null);const Mt=v.createContext(null);function ps(){const r=v.useContext(Mt);if(!r)throw new Error("useDnd must be used within a <DndProvider>. Wrap your app with <DndProvider> to use the drag and drop system.");return r}function ms(){return v.useContext(Mt)!==null}var Ce=r=>r.type==="checkbox",fe=r=>r instanceof Date,K=r=>r==null;const Nt=r=>typeof r=="object";var q=r=>!K(r)&&!Array.isArray(r)&&Nt(r)&&!fe(r),$t=r=>q(r)&&r.target?Ce(r.target)?r.target.checked:r.target.value:r,Or=r=>r.substring(0,r.search(/\.\d+(\.|$)/))||r,It=(r,e)=>r.has(Or(e)),Tr=r=>{const e=r.constructor&&r.constructor.prototype;return q(e)&&e.hasOwnProperty("isPrototypeOf")},ze=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function j(r){if(r instanceof Date)return new Date(r);const e=typeof FileList<"u"&&r instanceof FileList;if(ze&&(r instanceof Blob||e))return r;const t=Array.isArray(r);if(!t&&!(q(r)&&Tr(r)))return r;const s=t?[]:Object.create(Object.getPrototypeOf(r));for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(s[n]=j(r[n]));return s}var Oe=r=>/^\w*$/.test(r),P=r=>r===void 0,We=r=>Array.isArray(r)?r.filter(Boolean):[],Ye=r=>We(r.replace(/["|']|\]/g,"").split(/\.|\[/)),p=(r,e,t)=>{if(!e||!q(r))return t;const s=(Oe(e)?[e]:Ye(e)).reduce((n,i)=>K(n)?n:n[i],r);return P(s)||s===r?P(r[e])?t:r[e]:s},Z=r=>typeof r=="boolean",J=r=>typeof r=="function",I=(r,e,t)=>{let s=-1;const n=Oe(e)?[e]:Ye(e),i=n.length,o=i-1;for(;++s<i;){const l=n[s];let y=t;if(s!==o){const g=r[l];y=q(g)||Array.isArray(g)?g:isNaN(+n[s+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;r[l]=y,r=r[l]}};const Ee={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},se={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ie={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Ge=F.createContext(null);Ge.displayName="HookFormControlContext";const Je=()=>F.useContext(Ge);var Ut=(r,e,t,s=!0)=>{const n={defaultValues:e._defaultValues};for(const i in r)Object.defineProperty(n,i,{get:()=>{const o=i;return e._proxyFormState[o]!==se.all&&(e._proxyFormState[o]=!s||se.all),t&&(t[o]=!0),r[o]}});return n};const Ke=typeof window<"u"?F.useLayoutEffect:F.useEffect;function Rr(r){const e=Je(),{control:t=e,disabled:s,name:n,exact:i}=r||{},[o,l]=F.useState(t._formState),y=F.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Ke(()=>t._subscribe({name:n,formState:y.current,exact:i,callback:g=>{!s&&l({...t._formState,...g})}}),[n,s,i]),F.useEffect(()=>{y.current.isValid&&t._setValid(!0)},[t]),F.useMemo(()=>Ut(o,t,y.current,!1),[o,t])}var ee=r=>typeof r=="string",He=(r,e,t,s,n)=>ee(r)?(s&&e.watch.add(r),p(t,r,n)):Array.isArray(r)?r.map(i=>(s&&e.watch.add(i),p(t,i))):(s&&(e.watchAll=!0),t),Le=r=>K(r)||!Nt(r);function ne(r,e,t=new WeakSet){if(Le(r)||Le(e))return Object.is(r,e);if(fe(r)&&fe(e))return Object.is(r.getTime(),e.getTime());const s=Object.keys(r),n=Object.keys(e);if(s.length!==n.length)return!1;if(t.has(r)||t.has(e))return!0;t.add(r),t.add(e);for(const i of s){const o=r[i];if(!n.includes(i))return!1;if(i!=="ref"){const l=e[i];if(fe(o)&&fe(l)||q(o)&&q(l)||Array.isArray(o)&&Array.isArray(l)?!ne(o,l,t):!Object.is(o,l))return!1}}return!0}function Mr(r){const e=Je(),{control:t=e,name:s,defaultValue:n,disabled:i,exact:o,compute:l}=r||{},y=F.useRef(n),g=F.useRef(l),k=F.useRef(void 0),h=F.useRef(t),C=F.useRef(s);g.current=l;const[b,D]=F.useState(()=>{const _=t._getWatch(s,y.current);return g.current?g.current(_):_}),R=F.useCallback(_=>{const A=He(s,t._names,_||t._formValues,!1,y.current);return g.current?g.current(A):A},[t._formValues,t._names,s]),x=F.useCallback(_=>{if(!i){const A=He(s,t._names,_||t._formValues,!1,y.current);if(g.current){const U=g.current(A);ne(U,k.current)||(D(U),k.current=U)}else D(A)}},[t._formValues,t._names,i,s]);Ke(()=>((h.current!==t||!ne(C.current,s))&&(h.current=t,C.current=s,x()),t._subscribe({name:s,formState:{values:!0},exact:o,callback:_=>{x(_.values)}})),[t,o,s,x]),F.useEffect(()=>t._removeUnmounted());const E=h.current!==t,S=C.current,V=F.useMemo(()=>{if(i)return null;const _=!E&&!ne(S,s);return E||_?R():null},[i,E,s,S,R]);return V!==null?V:b}function Nr(r){const e=Je(),{name:t,disabled:s,control:n=e,shouldUnregister:i,defaultValue:o,exact:l=!0}=r,y=It(n._names.array,t),g=F.useMemo(()=>p(n._formValues,t,p(n._defaultValues,t,o)),[n,t,o]),k=Mr({control:n,name:t,defaultValue:g,exact:l}),h=Rr({control:n,name:t,exact:l}),C=F.useRef(r),b=F.useRef(void 0),D=F.useRef(n.register(t,{...r.rules,value:k,...Z(r.disabled)?{disabled:r.disabled}:{}}));C.current=r;const R=F.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!p(h.errors,t)},isDirty:{enumerable:!0,get:()=>!!p(h.dirtyFields,t)},isTouched:{enumerable:!0,get:()=>!!p(h.touchedFields,t)},isValidating:{enumerable:!0,get:()=>!!p(h.validatingFields,t)},error:{enumerable:!0,get:()=>p(h.errors,t)}}),[h,t]),x=F.useCallback(_=>D.current.onChange({target:{value:$t(_),name:t},type:Ee.CHANGE}),[t]),E=F.useCallback(()=>D.current.onBlur({target:{value:p(n._formValues,t),name:t},type:Ee.BLUR}),[t,n._formValues]),S=F.useCallback(_=>{const A=p(n._fields,t);A&&A._f&&_&&(A._f.ref={focus:()=>J(_.focus)&&_.focus(),select:()=>J(_.select)&&_.select(),setCustomValidity:U=>J(_.setCustomValidity)&&_.setCustomValidity(U),reportValidity:()=>J(_.reportValidity)&&_.reportValidity()})},[n._fields,t]),V=F.useMemo(()=>({name:t,value:k,...Z(s)||h.disabled?{disabled:h.disabled||s}:{},onChange:x,onBlur:E,ref:S}),[t,s,h.disabled,x,E,S,k]);return F.useEffect(()=>{const _=n._options.shouldUnregister||i,A=b.current;A&&A!==t&&!y&&n.unregister(A),n.register(t,{...C.current.rules,...Z(C.current.disabled)?{disabled:C.current.disabled}:{}});const U=(W,te)=>{const H=p(n._fields,W);H&&H._f&&(H._f.mount=te)};if(U(t,!0),_){const W=j(p(n._options.defaultValues,t,C.current.defaultValue));I(n._defaultValues,t,W),P(p(n._formValues,t))&&I(n._formValues,t,W)}return!y&&n.register(t),b.current=t,()=>{(y?_&&!n._state.action:_)?n.unregister(t):U(t,!1)}},[t,n,y,i]),F.useEffect(()=>{n._setDisabledField({disabled:s,name:t})},[s,t,n]),F.useMemo(()=>({field:V,formState:h,fieldState:R}),[V,h,R])}const bs=r=>r.render(Nr(r)),Qe=F.createContext(null);Qe.displayName="HookFormContext";const vs=()=>F.useContext(Qe),ws=r=>{const{children:e,watch:t,getValues:s,getFieldState:n,setError:i,clearErrors:o,setValue:l,trigger:y,formState:g,resetField:k,reset:h,handleSubmit:C,unregister:b,control:D,register:R,setFocus:x,subscribe:E}=r;return F.createElement(Qe.Provider,{value:F.useMemo(()=>({watch:t,getValues:s,getFieldState:n,setError:i,clearErrors:o,setValue:l,trigger:y,formState:g,resetField:k,reset:h,handleSubmit:C,unregister:b,control:D,register:R,setFocus:x,subscribe:E}),[o,D,g,n,s,C,R,h,k,i,x,l,E,y,b,t])},F.createElement(Ge.Provider,{value:D},e))};var $r=(r,e,t,s,n)=>e?{...t[r],types:{...t[r]&&t[r].types?t[r].types:{},[s]:n||!0}}:{},xe=r=>Array.isArray(r)?r:[r],pt=()=>{let r=[];return{get observers(){return r},next:n=>{for(const i of r)i.next&&i.next(n)},subscribe:n=>(r.push(n),{unsubscribe:()=>{r=r.filter(i=>i!==n)}}),unsubscribe:()=>{r=[]}}};function Pt(r,e){const t={};for(const s in r)if(r.hasOwnProperty(s)){const n=r[s],i=e[s];if(n&&q(n)&&i){const o=Pt(n,i);q(o)&&(t[s]=o)}else r[s]&&(t[s]=i)}return t}var G=r=>q(r)&&!Object.keys(r).length,Xe=r=>r.type==="file",Fe=r=>{if(!ze)return!1;const e=r?r.ownerDocument:0;return r instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},Ht=r=>r.type==="select-multiple",Ze=r=>r.type==="radio",Ir=r=>Ze(r)||Ce(r),Ue=r=>Fe(r)&&r.isConnected;function Ur(r,e){const t=e.slice(0,-1).length;let s=0;for(;s<t;)r=P(r)?s++:r[e[s++]];return r}function Pr(r){for(const e in r)if(r.hasOwnProperty(e)&&!P(r[e]))return!1;return!0}function B(r,e){const t=Array.isArray(e)?e:Oe(e)?[e]:Ye(e),s=t.length===1?r:Ur(r,t),n=t.length-1,i=t[n];return s&&delete s[i],n!==0&&(q(s)&&G(s)||Array.isArray(s)&&Pr(s))&&B(r,t.slice(0,-1)),r}var Hr=r=>{for(const e in r)if(J(r[e]))return!0;return!1};function Lt(r){return Array.isArray(r)||q(r)&&!Hr(r)}function je(r,e={}){for(const t in r){const s=r[t];Lt(s)?(e[t]=Array.isArray(s)?[]:{},je(s,e[t])):P(s)||(e[t]=!0)}return e}function ge(r,e,t){t||(t=je(e));for(const s in r){const n=r[s];if(Lt(n))P(e)||Le(t[s])?t[s]=je(n,Array.isArray(n)?[]:{}):ge(n,K(e)?{}:e[s],t[s]);else{const i=e[s];t[s]=!ne(n,i)}}return t}const mt={value:!1,isValid:!1},bt={value:!0,isValid:!0};var jt=r=>{if(Array.isArray(r)){if(r.length>1){const e=r.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:e,isValid:!!e.length}}return r[0].checked&&!r[0].disabled?r[0].attributes&&!P(r[0].attributes.value)?P(r[0].value)||r[0].value===""?bt:{value:r[0].value,isValid:!0}:bt:mt}return mt},Bt=(r,{valueAsNumber:e,valueAsDate:t,setValueAs:s})=>P(r)?r:e?r===""?NaN:r&&+r:t&&ee(r)?new Date(r):s?s(r):r;const vt={isValid:!1,value:null};var qt=r=>Array.isArray(r)?r.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,vt):vt;function wt(r){const e=r.ref;return Xe(e)?e.files:Ze(e)?qt(r.refs).value:Ht(e)?[...e.selectedOptions].map(({value:t})=>t):Ce(e)?jt(r.refs).value:Bt(P(e.value)?r.ref.value:e.value,r)}var Lr=(r,e,t,s)=>{const n={};for(const i of r){const o=p(e,i);o&&I(n,i,o._f)}return{criteriaMode:t,names:[...r],fields:n,shouldUseNativeValidation:s}},Ve=r=>r instanceof RegExp,Se=r=>P(r)?r:Ve(r)?r.source:q(r)?Ve(r.value)?r.value.source:r.value:r,St=r=>({isOnSubmit:!r||r===se.onSubmit,isOnBlur:r===se.onBlur,isOnChange:r===se.onChange,isOnAll:r===se.all,isOnTouch:r===se.onTouched});const xt="AsyncFunction";var jr=r=>!!r&&!!r.validate&&!!(J(r.validate)&&r.validate.constructor.name===xt||q(r.validate)&&Object.values(r.validate).find(e=>e.constructor.name===xt)),Br=r=>r.mount&&(r.required||r.min||r.max||r.maxLength||r.minLength||r.pattern||r.validate),_t=(r,e,t)=>!t&&(e.watchAll||e.watch.has(r)||[...e.watch].some(s=>r.startsWith(s)&&/^\.\w+/.test(r.slice(s.length))));const _e=(r,e,t,s)=>{for(const n of t||Object.keys(r)){const i=p(r,n);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],n)&&!s)return!0;if(o.ref&&e(o.ref,o.name)&&!s)return!0;if(_e(l,e))break}else if(q(l)&&_e(l,e))break}}};function Ct(r,e,t){const s=p(r,t);if(s||Oe(t))return{error:s,name:t};const n=t.split(".");for(;n.length;){const i=n.join("."),o=p(e,i),l=p(r,i);if(o&&!Array.isArray(o)&&t!==i)return{name:t};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};n.pop()}return{name:t}}var qr=(r,e,t,s)=>{t(r);const{name:n,...i}=r;return G(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!s||se.all))},zr=(r,e,t)=>!r||!e||r===e||xe(r).some(s=>s&&(t?s===e:s.startsWith(e)||e.startsWith(s))),Wr=(r,e,t,s,n)=>n.isOnAll?!1:!t&&n.isOnTouch?!(e||r):(t?s.isOnBlur:n.isOnBlur)?!r:(t?s.isOnChange:n.isOnChange)?r:!0,Yr=(r,e)=>!We(p(r,e)).length&&B(r,e),Gr=(r,e,t)=>{const s=xe(p(r,t));return I(s,"root",e[t]),I(r,t,s),r};function At(r,e,t="validate"){if(ee(r)||Array.isArray(r)&&r.every(ee)||Z(r)&&!r)return{type:t,message:ee(r)?r:"",ref:e}}var he=r=>q(r)&&!Ve(r)?r:{value:r,message:""},kt=async(r,e,t,s,n,i)=>{const{ref:o,refs:l,required:y,maxLength:g,minLength:k,min:h,max:C,pattern:b,validate:D,name:R,valueAsNumber:x,mount:E}=r._f,S=p(t,R);if(!E||e.has(R))return{};const V=l?l[0]:o,_=T=>{n&&V.reportValidity&&(V.setCustomValidity(Z(T)?"":T||""),V.reportValidity())},A={},U=Ze(o),W=Ce(o),te=U||W,H=(x||Xe(o))&&P(o.value)&&P(S)||Fe(o)&&o.value===""||S===""||Array.isArray(S)&&!S.length,O=$r.bind(null,R,s,A),pe=(T,M,L,z=ie.maxLength,re=ie.minLength)=>{const X=T?M:L;A[R]={type:T?z:re,message:X,ref:o,...O(T?z:re,X)}};if(i?!Array.isArray(S)||!S.length:y&&(!te&&(H||K(S))||Z(S)&&!S||W&&!jt(l).isValid||U&&!qt(l).isValid)){const{value:T,message:M}=ee(y)?{value:!!y,message:y}:he(y);if(T&&(A[R]={type:ie.required,message:M,ref:V,...O(ie.required,M)},!s))return _(M),A}if(!H&&(!K(h)||!K(C))){let T,M;const L=he(C),z=he(h);if(!K(S)&&!isNaN(S)){const re=o.valueAsNumber||S&&+S;K(L.value)||(T=re>L.value),K(z.value)||(M=re<z.value)}else{const re=o.valueAsDate||new Date(S),X=ve=>new Date(new Date().toDateString()+" "+ve),me=o.type=="time",be=o.type=="week";ee(L.value)&&S&&(T=me?X(S)>X(L.value):be?S>L.value:re>new Date(L.value)),ee(z.value)&&S&&(M=me?X(S)<X(z.value):be?S<z.value:re<new Date(z.value))}if((T||M)&&(pe(!!T,L.message,z.message,ie.max,ie.min),!s))return _(A[R].message),A}if((g||k)&&!H&&(ee(S)||i&&Array.isArray(S))){const T=he(g),M=he(k),L=!K(T.value)&&S.length>+T.value,z=!K(M.value)&&S.length<+M.value;if((L||z)&&(pe(L,T.message,M.message),!s))return _(A[R].message),A}if(b&&!H&&ee(S)){const{value:T,message:M}=he(b);if(Ve(T)&&!S.match(T)&&(A[R]={type:ie.pattern,message:M,ref:o,...O(ie.pattern,M)},!s))return _(M),A}if(D){if(J(D)){const T=await D(S,t),M=At(T,V);if(M&&(A[R]={...M,...O(ie.validate,M.message)},!s))return _(M.message),A}else if(q(D)){let T={};for(const M in D){if(!G(T)&&!s)break;const L=At(await D[M](S,t),V,M);L&&(T={...L,...O(M,L.message)},_(L.message),s&&(A[R]=T))}if(!G(T)&&(A[R]={ref:V,...T},!s))return A}}return _(!0),A};const Jr={mode:se.onSubmit,reValidateMode:se.onChange,shouldFocusError:!0};function Kr(r={}){let e={...Jr,...r},t={submitCount:0,isDirty:!1,isReady:!1,isLoading:J(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},s={},n=q(e.defaultValues)||q(e.values)?j(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:j(n),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},y,g=0;const k={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...k};let C={...h};const b={array:pt(),state:pt()},D=e.criteriaMode===se.all,R=a=>u=>{clearTimeout(g),g=setTimeout(a,u)},x=async a=>{if(!o.keepIsValid&&!e.disabled&&(h.isValid||C.isValid||a)){let u;e.resolver?(u=G((await te()).errors),E()):u=await O(s,!0),u!==t.isValid&&b.state.next({isValid:u})}},E=(a,u)=>{!e.disabled&&(h.isValidating||h.validatingFields||C.isValidating||C.validatingFields)&&((a||Array.from(l.mount)).forEach(c=>{c&&(u?I(t.validatingFields,c,u):B(t.validatingFields,c))}),b.state.next({validatingFields:t.validatingFields,isValidating:!G(t.validatingFields)}))},S=(a,u=[],c,m,f=!0,d=!0)=>{if(m&&c&&!e.disabled){if(o.action=!0,d&&Array.isArray(p(s,a))){const w=c(p(s,a),m.argA,m.argB);f&&I(s,a,w)}if(d&&Array.isArray(p(t.errors,a))){const w=c(p(t.errors,a),m.argA,m.argB);f&&I(t.errors,a,w),Yr(t.errors,a)}if((h.touchedFields||C.touchedFields)&&d&&Array.isArray(p(t.touchedFields,a))){const w=c(p(t.touchedFields,a),m.argA,m.argB);f&&I(t.touchedFields,a,w)}(h.dirtyFields||C.dirtyFields)&&(t.dirtyFields=ge(n,i)),b.state.next({name:a,isDirty:T(a,u),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else I(i,a,u)},V=(a,u)=>{I(t.errors,a,u),b.state.next({errors:t.errors})},_=a=>{t.errors=a,b.state.next({errors:t.errors,isValid:!1})},A=(a,u,c,m)=>{const f=p(s,a);if(f){const d=p(i,a,P(c)?p(n,a):c);P(d)||m&&m.defaultChecked||u?I(i,a,u?d:wt(f._f)):z(a,d),o.mount&&!o.action&&x()}},U=(a,u,c,m,f)=>{let d=!1,w=!1;const N={name:a};if(!e.disabled){if(!c||m){(h.isDirty||C.isDirty)&&(w=t.isDirty,t.isDirty=N.isDirty=T(),d=w!==N.isDirty);const $=ne(p(n,a),u);w=!!p(t.dirtyFields,a),$?B(t.dirtyFields,a):I(t.dirtyFields,a,!0),N.dirtyFields=t.dirtyFields,d=d||(h.dirtyFields||C.dirtyFields)&&w!==!$}if(c){const $=p(t.touchedFields,a);$||(I(t.touchedFields,a,c),N.touchedFields=t.touchedFields,d=d||(h.touchedFields||C.touchedFields)&&$!==c)}d&&f&&b.state.next(N)}return d?N:{}},W=(a,u,c,m)=>{const f=p(t.errors,a),d=(h.isValid||C.isValid)&&Z(u)&&t.isValid!==u;if(e.delayError&&c?(y=R(()=>V(a,c)),y(e.delayError)):(clearTimeout(g),y=null,c?I(t.errors,a,c):B(t.errors,a)),(c?!ne(f,c):f)||!G(m)||d){const w={...m,...d&&Z(u)?{isValid:u}:{},errors:t.errors,name:a};t={...t,...w},b.state.next(w)}},te=async a=>(E(a,!0),await e.resolver(i,e.context,Lr(a||l.mount,s,e.criteriaMode,e.shouldUseNativeValidation))),H=async a=>{const{errors:u}=await te(a);if(E(a),a)for(const c of a){const m=p(u,c);m?I(t.errors,c,m):B(t.errors,c)}else t.errors=u;return u},O=async(a,u,c={valid:!0})=>{for(const m in a){const f=a[m];if(f){const{_f:d,...w}=f;if(d){const N=l.array.has(d.name),$=f._f&&jr(f._f);$&&h.validatingFields&&E([d.name],!0);const Y=await kt(f,l.disabled,i,D,e.shouldUseNativeValidation&&!u,N);if($&&h.validatingFields&&E([d.name]),Y[d.name]&&(c.valid=!1,u||r.shouldUseNativeValidation))break;!u&&(p(Y,d.name)?N?Gr(t.errors,Y,d.name):I(t.errors,d.name,Y[d.name]):B(t.errors,d.name))}!G(w)&&await O(w,u,c)}}return c.valid},pe=()=>{for(const a of l.unMount){const u=p(s,a);u&&(u._f.refs?u._f.refs.every(c=>!Ue(c)):!Ue(u._f.ref))&&Te(a)}l.unMount=new Set},T=(a,u)=>!e.disabled&&(a&&u&&I(i,a,u),!ne(et(),n)),M=(a,u,c)=>He(a,l,{...o.mount?i:P(u)?n:ee(a)?{[a]:u}:u},c,u),L=a=>We(p(o.mount?i:n,a,e.shouldUnregister?p(n,a,[]):[])),z=(a,u,c={})=>{const m=p(s,a);let f=u;if(m){const d=m._f;d&&(!d.disabled&&I(i,a,Bt(u,d)),f=Fe(d.ref)&&K(u)?"":u,Ht(d.ref)?[...d.ref.options].forEach(w=>w.selected=f.includes(w.value)):d.refs?Ce(d.ref)?d.refs.forEach(w=>{(!w.defaultChecked||!w.disabled)&&(Array.isArray(f)?w.checked=!!f.find(N=>N===w.value):w.checked=f===w.value||!!f)}):d.refs.forEach(w=>w.checked=w.value===f):Xe(d.ref)?d.ref.value="":(d.ref.value=f,d.ref.type||b.state.next({name:a,values:j(i)})))}(c.shouldDirty||c.shouldTouch)&&U(a,f,c.shouldTouch,c.shouldDirty,!0),c.shouldValidate&&ve(a)},re=(a,u,c)=>{for(const m in u){if(!u.hasOwnProperty(m))return;const f=u[m],d=a+"."+m,w=p(s,d);(l.array.has(a)||q(f)||w&&!w._f)&&!fe(f)?re(d,f,c):z(d,f,c)}},X=(a,u,c={})=>{const m=p(s,a),f=l.array.has(a),d=j(u);I(i,a,d),f?(b.array.next({name:a,values:j(i)}),(h.isDirty||h.dirtyFields||C.isDirty||C.dirtyFields)&&c.shouldDirty&&b.state.next({name:a,dirtyFields:ge(n,i),isDirty:T(a,d)})):m&&!m._f&&!K(d)?re(a,d,c):z(a,d,c),_t(a,l)?b.state.next({...t,name:a,values:j(i)}):b.state.next({name:o.mount?a:void 0,values:j(i)})},me=async a=>{o.mount=!0;const u=a.target;let c=u.name,m=!0;const f=p(s,c),d=$=>{m=Number.isNaN($)||fe($)&&isNaN($.getTime())||ne($,p(i,c,$))},w=St(e.mode),N=St(e.reValidateMode);if(f){let $,Y;const le=u.type?wt(f._f):$t(a),oe=a.type===Ee.BLUR||a.type===Ee.FOCUS_OUT,Xt=!Br(f._f)&&!e.resolver&&!p(t.errors,c)&&!f._f.deps||Wr(oe,p(t.touchedFields,c),t.isSubmitted,N,w),Ne=_t(c,l,oe);I(i,c,le),oe?(!u||!u.readOnly)&&(f._f.onBlur&&f._f.onBlur(a),y&&y(0)):f._f.onChange&&f._f.onChange(a);const $e=U(c,le,oe),Zt=!G($e)||Ne;if(!oe&&b.state.next({name:c,type:a.type,values:j(i)}),Xt)return(h.isValid||C.isValid)&&(e.mode==="onBlur"?oe&&x():oe||x()),Zt&&b.state.next({name:c,...Ne?{}:$e});if(!oe&&Ne&&b.state.next({...t}),e.resolver){const{errors:lt}=await te([c]);if(E([c]),d(le),m){const er=Ct(t.errors,s,c),ct=Ct(lt,s,er.name||c);$=ct.error,c=ct.name,Y=G(lt)}}else E([c],!0),$=(await kt(f,l.disabled,i,D,e.shouldUseNativeValidation))[c],E([c]),d(le),m&&($?Y=!1:(h.isValid||C.isValid)&&(Y=await O(s,!0)));m&&(f._f.deps&&(!Array.isArray(f._f.deps)||f._f.deps.length>0)&&ve(f._f.deps),W(c,Y,$,$e))}},be=(a,u)=>{if(p(t.errors,u)&&a.focus)return a.focus(),1},ve=async(a,u={})=>{let c,m;const f=xe(a);if(e.resolver){const d=await H(P(a)?a:f);c=G(d),m=a?!f.some(w=>p(d,w)):c}else a?(m=(await Promise.all(f.map(async d=>{const w=p(s,d);return await O(w&&w._f?{[d]:w}:w)}))).every(Boolean),!(!m&&!t.isValid)&&x()):m=c=await O(s);return b.state.next({...!ee(a)||(h.isValid||C.isValid)&&c!==t.isValid?{}:{name:a},...e.resolver||!a?{isValid:c}:{},errors:t.errors}),u.shouldFocus&&!m&&_e(s,be,a?f:l.mount),m},et=(a,u)=>{let c={...o.mount?i:n};return u&&(c=Pt(u.dirtyFields?t.dirtyFields:t.touchedFields,c)),P(a)?c:ee(a)?p(c,a):a.map(m=>p(c,m))},tt=(a,u)=>({invalid:!!p((u||t).errors,a),isDirty:!!p((u||t).dirtyFields,a),error:p((u||t).errors,a),isValidating:!!p(t.validatingFields,a),isTouched:!!p((u||t).touchedFields,a)}),zt=a=>{const u=a?xe(a):void 0;u?.forEach(c=>B(t.errors,c)),u?u.forEach(c=>{b.state.next({name:c,errors:t.errors})}):b.state.next({errors:{}})},rt=(a,u,c)=>{const m=(p(s,a,{_f:{}})._f||{}).ref,f=p(t.errors,a)||{},{ref:d,message:w,type:N,...$}=f;I(t.errors,a,{...$,...u,ref:m}),b.state.next({name:a,errors:t.errors,isValid:!1}),c&&c.shouldFocus&&m&&m.focus&&m.focus()},Wt=(a,u)=>J(a)?b.state.subscribe({next:c=>"values"in c&&a(M(void 0,u),c)}):M(a,u,!0),st=a=>b.state.subscribe({next:u=>{zr(a.name,u.name,a.exact)&&qr(u,a.formState||h,Qt,a.reRenderRoot)&&a.callback({values:{...i},...t,...u,defaultValues:n})}}).unsubscribe,Yt=a=>(o.mount=!0,C={...C,...a.formState},st({...a,formState:{...k,...a.formState}})),Te=(a,u={})=>{for(const c of a?xe(a):l.mount)l.mount.delete(c),l.array.delete(c),u.keepValue||(B(s,c),B(i,c)),!u.keepError&&B(t.errors,c),!u.keepDirty&&B(t.dirtyFields,c),!u.keepTouched&&B(t.touchedFields,c),!u.keepIsValidating&&B(t.validatingFields,c),!e.shouldUnregister&&!u.keepDefaultValue&&B(n,c);b.state.next({values:j(i)}),b.state.next({...t,...u.keepDirty?{isDirty:T()}:{}}),!u.keepIsValid&&x()},nt=({disabled:a,name:u})=>{if(Z(a)&&o.mount||a||l.disabled.has(u)){const f=l.disabled.has(u)!==!!a;a?l.disabled.add(u):l.disabled.delete(u),f&&o.mount&&!o.action&&x()}},Re=(a,u={})=>{let c=p(s,a);const m=Z(u.disabled)||Z(e.disabled);return I(s,a,{...c||{},_f:{...c&&c._f?c._f:{ref:{name:a}},name:a,mount:!0,...u}}),l.mount.add(a),c?nt({disabled:Z(u.disabled)?u.disabled:e.disabled,name:a}):A(a,!0,u.value),{...m?{disabled:u.disabled||e.disabled}:{},...e.progressive?{required:!!u.required,min:Se(u.min),max:Se(u.max),minLength:Se(u.minLength),maxLength:Se(u.maxLength),pattern:Se(u.pattern)}:{},name:a,onChange:me,onBlur:me,ref:f=>{if(f){Re(a,u),c=p(s,a);const d=P(f.value)&&f.querySelectorAll&&f.querySelectorAll("input,select,textarea")[0]||f,w=Ir(d),N=c._f.refs||[];if(w?N.find($=>$===d):d===c._f.ref)return;I(s,a,{_f:{...c._f,...w?{refs:[...N.filter(Ue),d,...Array.isArray(p(n,a))?[{}]:[]],ref:{type:d.type,name:a}}:{ref:d}}}),A(a,!1,void 0,d)}else c=p(s,a,{}),c._f&&(c._f.mount=!1),(e.shouldUnregister||u.shouldUnregister)&&!(It(l.array,a)&&o.action)&&l.unMount.add(a)}}},Me=()=>e.shouldFocusError&&_e(s,be,l.mount),Gt=a=>{Z(a)&&(b.state.next({disabled:a}),_e(s,(u,c)=>{const m=p(s,c);m&&(u.disabled=m._f.disabled||a,Array.isArray(m._f.refs)&&m._f.refs.forEach(f=>{f.disabled=m._f.disabled||a}))},0,!1))},it=(a,u)=>async c=>{let m;c&&(c.preventDefault&&c.preventDefault(),c.persist&&c.persist());let f=j(i);if(b.state.next({isSubmitting:!0}),e.resolver){const{errors:d,values:w}=await te();E(),t.errors=d,f=j(w)}else await O(s);if(l.disabled.size)for(const d of l.disabled)B(f,d);if(B(t.errors,"root"),G(t.errors)){b.state.next({errors:{}});try{await a(f,c)}catch(d){m=d}}else u&&await u({...t.errors},c),Me(),setTimeout(Me);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Jt=(a,u={})=>{p(s,a)&&(P(u.defaultValue)?X(a,j(p(n,a))):(X(a,u.defaultValue),I(n,a,j(u.defaultValue))),u.keepTouched||B(t.touchedFields,a),u.keepDirty||(B(t.dirtyFields,a),t.isDirty=u.defaultValue?T(a,j(p(n,a))):T()),u.keepError||(B(t.errors,a),h.isValid&&x()),b.state.next({...t}))},at=(a,u={})=>{const c=a?j(a):n,m=j(c),f=G(a),d=f?n:m;if(u.keepDefaultValues||(n=c),!u.keepValues){if(u.keepDirtyValues){const w=new Set([...l.mount,...Object.keys(ge(n,i))]);for(const N of Array.from(w)){const $=p(t.dirtyFields,N),Y=p(i,N),le=p(d,N);$&&!P(Y)?I(d,N,Y):!$&&!P(le)&&X(N,le)}}else{if(ze&&P(a))for(const w of l.mount){const N=p(s,w);if(N&&N._f){const $=Array.isArray(N._f.refs)?N._f.refs[0]:N._f.ref;if(Fe($)){const Y=$.closest("form");if(Y){Y.reset();break}}}}if(u.keepFieldsRef)for(const w of l.mount)X(w,p(d,w));else s={}}i=e.shouldUnregister?u.keepDefaultValues?j(n):{}:j(d),b.array.next({values:{...d}}),b.state.next({values:{...d}})}l={mount:u.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!h.isValid||!!u.keepIsValid||!!u.keepDirtyValues||!e.shouldUnregister&&!G(d),o.watch=!!e.shouldUnregister,o.keepIsValid=!!u.keepIsValid,o.action=!1,u.keepErrors||(t.errors={}),b.state.next({submitCount:u.keepSubmitCount?t.submitCount:0,isDirty:f?!1:u.keepDirty?t.isDirty:!!(u.keepDefaultValues&&!ne(a,n)),isSubmitted:u.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:f?{}:u.keepDirtyValues?u.keepDefaultValues&&i?ge(n,i):t.dirtyFields:u.keepDefaultValues&&a?ge(n,a):u.keepDirty?t.dirtyFields:{},touchedFields:u.keepTouched?t.touchedFields:{},errors:u.keepErrors?t.errors:{},isSubmitSuccessful:u.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:n})},ot=(a,u)=>at(J(a)?a(i):a,{...e.resetOptions,...u}),Kt=(a,u={})=>{const c=p(s,a),m=c&&c._f;if(m){const f=m.refs?m.refs[0]:m.ref;f.focus&&setTimeout(()=>{f.focus(),u.shouldSelect&&J(f.select)&&f.select()})}},Qt=a=>{t={...t,...a}},ut={control:{register:Re,unregister:Te,getFieldState:tt,handleSubmit:it,setError:rt,_subscribe:st,_runSchema:te,_updateIsValidating:E,_focusError:Me,_getWatch:M,_getDirty:T,_setValid:x,_setFieldArray:S,_setDisabledField:nt,_setErrors:_,_getFieldArray:L,_reset:at,_resetDefaultValues:()=>J(e.defaultValues)&&e.defaultValues().then(a=>{ot(a,e.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:pe,_disableForm:Gt,_subjects:b,_proxyFormState:h,get _fields(){return s},get _formValues(){return i},get _state(){return o},set _state(a){o=a},get _defaultValues(){return n},get _names(){return l},set _names(a){l=a},get _formState(){return t},get _options(){return e},set _options(a){e={...e,...a}}},subscribe:Yt,trigger:ve,register:Re,handleSubmit:it,watch:Wt,setValue:X,getValues:et,reset:ot,resetField:Jt,clearErrors:zt,unregister:Te,setError:rt,setFocus:Kt,getFieldState:tt};return{...ut,formControl:ut}}function Ss(r={}){const e=F.useRef(void 0),t=F.useRef(void 0),[s,n]=F.useState({isDirty:!1,isValidating:!1,isLoading:J(r.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:r.errors||{},disabled:r.disabled||!1,isReady:!1,defaultValues:J(r.defaultValues)?void 0:r.defaultValues});if(!e.current)if(r.formControl)e.current={...r.formControl,formState:s},r.defaultValues&&!J(r.defaultValues)&&r.formControl.reset(r.defaultValues,r.resetOptions);else{const{formControl:o,...l}=Kr(r);e.current={...l,formState:s}}const i=e.current.control;return i._options=r,Ke(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>n({...i._formState}),reRenderRoot:!0});return n(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),F.useEffect(()=>i._disableForm(r.disabled),[i,r.disabled]),F.useEffect(()=>{r.mode&&(i._options.mode=r.mode),r.reValidateMode&&(i._options.reValidateMode=r.reValidateMode)},[i,r.mode,r.reValidateMode]),F.useEffect(()=>{r.errors&&(i._setErrors(r.errors),i._focusError())},[i,r.errors]),F.useEffect(()=>{r.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,r.shouldUnregister]),F.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==s.isDirty&&i._subjects.state.next({isDirty:o})}},[i,s.isDirty]),F.useEffect(()=>{var o;r.values&&!ne(r.values,t.current)?(i._reset(r.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),t.current=r.values,n(l=>({...l}))):i._resetDefaultValues()},[i,r.values]),F.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),e.current.formState=F.useMemo(()=>Ut(s,i),[i,s]),e.current}function Qr(r,e=0){const t=`migrated_${e}`;return r.type==="separator"?{id:t,type:"separator",label:r.label||""}:r.type==="group"?{id:t,type:"group",label:r.label||"",icon:r.icon,children:(r.children||[]).map((s,n)=>Qr(s,e*100+n)),visible:r.hidden!==void 0?!r.hidden:void 0,badge:r.badge,defaultOpen:!0}:r.href?{id:t,type:"url",label:r.label||"",icon:r.icon,url:r.href,target:"_blank",visible:r.hidden!==void 0?!r.hidden:void 0,badge:r.badge}:{id:t,type:"page",label:r.label||"",icon:r.icon,pageName:r.path||"",visible:r.hidden!==void 0?!r.hidden:void 0,badge:r.badge}}function xs(r){return/^[a-z][a-z0-9]*(_[a-z0-9]+)*$/.test(r)}function _s(r){return{type:"app",name:r.name,title:r.title,label:r.title,description:r.description,icon:r.icon,logo:r.branding.logo,favicon:r.branding.favicon,branding:r.branding,layout:r.layout,navigation:r.navigation}}export{Dr as A,xs as B,rr as C,ye as E,ws as F,mr as P,yr as S,bs as a,Ss as b,us as c,ys as d,ls as e,ds as f,is as g,ns as h,os as i,ts as j,rs as k,fs as l,Qr as m,ir as n,De as o,ms as p,ps as q,fr as r,ss as s,hs as t,vs as u,lr as v,cs as w,gs as x,as as y,_s as z};
|