@baasix/baasix 0.1.18 → 0.1.20
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/dist/app/404/index.html +1 -1
- package/dist/app/404.html +1 -1
- package/dist/app/_next/static/chunks/3817-c02ad8a1f9e0ca27.js +1 -0
- package/dist/app/_next/static/chunks/{7214-0af3e3c4fd49ea75.js → 7214-317fd668a308b748.js} +1 -1
- package/dist/app/_next/static/chunks/7304-53d85c55adc8f184.js +1 -0
- package/dist/app/_next/static/chunks/{9599-c7ab84cbe752fbd9.js → 9599-c7b77021b3c05e7e.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/all-activity/{page-b2d7c70e4c2c3854.js → page-ff48b4acd0fc42fe.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/email-log/{page-b5a008e807ac76f9.js → page-fa1d9d5e2291811e.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/notifications/{page-eb310d39dc624496.js → page-7b517b1ae290cc0e.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/sessions/{page-6b0bc9114681c0c0.js → page-a267a7efa8bec4f4.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/workflow-executions/{page-15b61ad609e34d4d.js → page-ce2e9cb89b2f5602.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/workflow-logs/{page-ffcb2d29485bc120.js → page-a8347ffa1a172231.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/data-browser/{page-3aaa7ade75c50fc9.js → page-83316eb3328c20a5.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/file-manager/{page-c5a553495c73a627.js → page-e1fa630b92b3bf6e.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/permissions/{page-cc547849884ecf49.js → page-3d5fe31bbd93d286.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/project/{page-4e8939f17ecd5836.js → page-35f7f73a8545dc50.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/roles/{page-0287dc354546001c.js → page-daffea990bfddd85.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/schema/page-e80637a10e44e748.js +1 -0
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/tasks/{page-8f611c9b3339daeb.js → page-36ad1f78b9e98e6e.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/templates/{page-9bfbc7d82950dfc1.js → page-cf00084298675fec.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/tenants/{page-2730a2175225330e.js → page-33c4895d4355cf17.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/users/invites/{page-8cae9d6e08450c72.js → page-1a394b10364eb827.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/users/list/{page-62374eb836cb57e3.js → page-e39a7cb508819983.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/users/{page-0893f3363d7f6b20.js → page-7fd4c1f311e3cec1.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/users/preferences/{page-dd8e0440e35fcefb.js → page-0ef2ed33049757c4.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/users/user-roles/{page-7852a10b11971e84.js → page-b776b7b3d24e97d6.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/workflows/{page-2d6fdf98f3c1f75e.js → page-97844b66676d0717.js} +1 -1
- package/dist/app/_next/static/chunks/app/layout-64ac14a534e2809b.js +1 -0
- package/dist/app/_next/static/chunks/{webpack-a934aa1995f7149a.js → webpack-bf12278c2fb5ba00.js} +1 -1
- package/dist/app/_next/static/css/d08072df3a043c8d.css +3 -0
- package/dist/app/activity-log/all-activity/index.html +1 -1
- package/dist/app/activity-log/all-activity/index.txt +3 -3
- package/dist/app/activity-log/email-log/index.html +1 -1
- package/dist/app/activity-log/email-log/index.txt +3 -3
- package/dist/app/activity-log/index.html +1 -1
- package/dist/app/activity-log/index.txt +2 -2
- package/dist/app/activity-log/notifications/index.html +1 -1
- package/dist/app/activity-log/notifications/index.txt +3 -3
- package/dist/app/activity-log/sessions/index.html +1 -1
- package/dist/app/activity-log/sessions/index.txt +3 -3
- package/dist/app/activity-log/workflow-executions/index.html +1 -1
- package/dist/app/activity-log/workflow-executions/index.txt +3 -3
- package/dist/app/activity-log/workflow-logs/index.html +1 -1
- package/dist/app/activity-log/workflow-logs/index.txt +3 -3
- package/dist/app/change-password/index.html +1 -1
- package/dist/app/change-password/index.txt +2 -2
- package/dist/app/dashboard/index.html +1 -1
- package/dist/app/dashboard/index.txt +2 -2
- package/dist/app/data-browser/index.html +1 -1
- package/dist/app/data-browser/index.txt +3 -3
- package/dist/app/file-manager/index.html +1 -1
- package/dist/app/file-manager/index.txt +3 -3
- package/dist/app/forgot-password/index.html +1 -1
- package/dist/app/forgot-password/index.txt +2 -2
- package/dist/app/index.html +1 -1
- package/dist/app/index.txt +2 -2
- package/dist/app/login/index.html +1 -1
- package/dist/app/login/index.txt +2 -2
- package/dist/app/register/index.html +1 -1
- package/dist/app/register/index.txt +2 -2
- package/dist/app/settings/migrations/index.html +1 -1
- package/dist/app/settings/migrations/index.txt +2 -2
- package/dist/app/settings/permissions/index.html +1 -1
- package/dist/app/settings/permissions/index.txt +3 -3
- package/dist/app/settings/project/index.html +1 -1
- package/dist/app/settings/project/index.txt +3 -3
- package/dist/app/settings/roles/index.html +1 -1
- package/dist/app/settings/roles/index.txt +3 -3
- package/dist/app/settings/schema/index.html +1 -1
- package/dist/app/settings/schema/index.txt +3 -3
- package/dist/app/settings/tasks/index.html +1 -1
- package/dist/app/settings/tasks/index.txt +3 -3
- package/dist/app/settings/templates/edit/index.html +1 -1
- package/dist/app/settings/templates/edit/index.txt +2 -2
- package/dist/app/settings/templates/index.html +1 -1
- package/dist/app/settings/templates/index.txt +3 -3
- package/dist/app/settings/tenants/index.html +1 -1
- package/dist/app/settings/tenants/index.txt +3 -3
- package/dist/app/users/index.html +1 -1
- package/dist/app/users/index.txt +3 -3
- package/dist/app/users/invites/index.html +1 -1
- package/dist/app/users/invites/index.txt +3 -3
- package/dist/app/users/list/index.html +1 -1
- package/dist/app/users/list/index.txt +3 -3
- package/dist/app/users/preferences/index.html +1 -1
- package/dist/app/users/preferences/index.txt +3 -3
- package/dist/app/users/user-roles/index.html +1 -1
- package/dist/app/users/user-roles/index.txt +3 -3
- package/dist/app/workflows/detail/index.html +1 -1
- package/dist/app/workflows/detail/index.txt +2 -2
- package/dist/app/workflows/edit/index.html +1 -1
- package/dist/app/workflows/edit/index.txt +2 -2
- package/dist/app/workflows/execution/index.html +1 -1
- package/dist/app/workflows/execution/index.txt +2 -2
- package/dist/app/workflows/index.html +1 -1
- package/dist/app/workflows/index.txt +3 -3
- package/dist/services/ItemsService.d.ts.map +1 -1
- package/dist/services/ItemsService.js +37 -29
- package/dist/services/ItemsService.js.map +1 -1
- package/package.json +1 -1
- package/dist/app/_next/static/chunks/1303-6e8e0ab420489175.js +0 -1
- package/dist/app/_next/static/chunks/3817-63bd724539f56efe.js +0 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/schema/page-13142acccd5f26b2.js +0 -1
- package/dist/app/_next/static/chunks/app/layout-1af2638eaca64bf1.js +0 -1
- package/dist/app/_next/static/css/089bd567329856e0.css +0 -3
- /package/dist/app/_next/static/{-M-4y4ptAuCLJ3meAo3RA → f5Vrl7yWal5q3WejlGdO1}/_buildManifest.js +0 -0
- /package/dist/app/_next/static/{-M-4y4ptAuCLJ3meAo3RA → f5Vrl7yWal5q3WejlGdO1}/_ssgManifest.js +0 -0
package/dist/app/404/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/admin/_next/static/css/
|
|
1
|
+
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/admin/_next/static/css/d08072df3a043c8d.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/admin/_next/static/chunks/webpack-bf12278c2fb5ba00.js"/><script src="/admin/_next/static/chunks/fd9d1056-54169f07cd680d6c.js" async=""></script><script src="/admin/_next/static/chunks/2117-29b5fa47421595ad.js" async=""></script><script src="/admin/_next/static/chunks/main-app-55bcae20c77aaf0e.js" async=""></script><script src="/admin/_next/static/chunks/6fcbdc68-90be1a5480b8d353.js" async=""></script><script src="/admin/_next/static/chunks/5094-8d53e403235d4ca6.js" async=""></script><script src="/admin/_next/static/chunks/4438-c9a12ca15b6e9160.js" async=""></script><script src="/admin/_next/static/chunks/6530-a91e10cffa4200c4.js" async=""></script><script src="/admin/_next/static/chunks/6241-30d7169d1010e5a4.js" async=""></script><script src="/admin/_next/static/chunks/1668-e3eabd0f6753c780.js" async=""></script><script src="/admin/_next/static/chunks/6869-11b3cd61c78598a7.js" async=""></script><script src="/admin/_next/static/chunks/8473-6598318371eca31b.js" async=""></script><script src="/admin/_next/static/chunks/4883-8a924721bb21b3b0.js" async=""></script><script src="/admin/_next/static/chunks/7304-53d85c55adc8f184.js" async=""></script><script src="/admin/_next/static/chunks/app/layout-64ac14a534e2809b.js" async=""></script><link rel="preload" href="https://www.googletagmanager.com/gtag/js?id=G-FBCW8DT7KT" as="script"/><meta name="robots" content="noindex"/><title>Baasix</title><script src="/admin/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body class="min-h-screen bg-background font-sans antialiased"><!--$--><div class="flex items-center justify-center min-h-screen bg-background"><div class="text-center"><div class="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]"></div><p class="mt-4 text-muted-foreground">Loading...</p></div></div><!--/$--><script src="/admin/_next/static/chunks/webpack-bf12278c2fb5ba00.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/admin/_next/static/css/d08072df3a043c8d.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"2:I[12846,[],\"\"]\n4:I[4707,[],\"\"]\n5:I[36423,[],\"\"]\n6:I[84821,[\"7999\",\"static/chunks/6fcbdc68-90be1a5480b8d353.js\",\"5094\",\"static/chunks/5094-8d53e403235d4ca6.js\",\"4438\",\"static/chunks/4438-c9a12ca15b6e9160.js\",\"6530\",\"static/chunks/6530-a91e10cffa4200c4.js\",\"6241\",\"static/chunks/6241-30d7169d1010e5a4.js\",\"1668\",\"static/chunks/1668-e3eabd0f6753c780.js\",\"6869\",\"static/chunks/6869-11b3cd61c78598a7.js\",\"8473\",\"static/chunks/8473-6598318371eca31b.js\",\"4883\",\"static/chunks/4883-8a924721bb21b3b0.js\",\"7304\",\"static/chunks/7304-53d85c55adc8f184.js\",\"3185\",\"static/chunks/app/layout-64ac14a534e2809b.js\"],\"default\",1]\nc:I[61060,[],\"\"]\n7:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n8:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\n9:{\"display\":\"inline-block\"}\na:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\nd:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L2\",null,{\"buildId\":\"f5Vrl7yWal5q3WejlGdO1\",\"assetPrefix\":\"/admin\",\"urlParts\":[\"\",\"_not-found\",\"\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L3\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null],null],null]},[null,[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/admin/_next/static/css/d08072df3a043c8d.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"$L6\",null,{\"children\":[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$7\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$8\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$9\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$a\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}],\"params\":{}}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$Lb\"],\"globalErrorComponent\":\"$c\",\"missingSlots\":\"$Wd\"}]\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}]]\n3:null\n"])</script></body></html>
|
package/dist/app/404.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/admin/_next/static/css/
|
|
1
|
+
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/admin/_next/static/css/d08072df3a043c8d.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/admin/_next/static/chunks/webpack-bf12278c2fb5ba00.js"/><script src="/admin/_next/static/chunks/fd9d1056-54169f07cd680d6c.js" async=""></script><script src="/admin/_next/static/chunks/2117-29b5fa47421595ad.js" async=""></script><script src="/admin/_next/static/chunks/main-app-55bcae20c77aaf0e.js" async=""></script><script src="/admin/_next/static/chunks/6fcbdc68-90be1a5480b8d353.js" async=""></script><script src="/admin/_next/static/chunks/5094-8d53e403235d4ca6.js" async=""></script><script src="/admin/_next/static/chunks/4438-c9a12ca15b6e9160.js" async=""></script><script src="/admin/_next/static/chunks/6530-a91e10cffa4200c4.js" async=""></script><script src="/admin/_next/static/chunks/6241-30d7169d1010e5a4.js" async=""></script><script src="/admin/_next/static/chunks/1668-e3eabd0f6753c780.js" async=""></script><script src="/admin/_next/static/chunks/6869-11b3cd61c78598a7.js" async=""></script><script src="/admin/_next/static/chunks/8473-6598318371eca31b.js" async=""></script><script src="/admin/_next/static/chunks/4883-8a924721bb21b3b0.js" async=""></script><script src="/admin/_next/static/chunks/7304-53d85c55adc8f184.js" async=""></script><script src="/admin/_next/static/chunks/app/layout-64ac14a534e2809b.js" async=""></script><link rel="preload" href="https://www.googletagmanager.com/gtag/js?id=G-FBCW8DT7KT" as="script"/><meta name="robots" content="noindex"/><title>Baasix</title><script src="/admin/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body class="min-h-screen bg-background font-sans antialiased"><!--$--><div class="flex items-center justify-center min-h-screen bg-background"><div class="text-center"><div class="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]"></div><p class="mt-4 text-muted-foreground">Loading...</p></div></div><!--/$--><script src="/admin/_next/static/chunks/webpack-bf12278c2fb5ba00.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/admin/_next/static/css/d08072df3a043c8d.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"2:I[12846,[],\"\"]\n4:I[4707,[],\"\"]\n5:I[36423,[],\"\"]\n6:I[84821,[\"7999\",\"static/chunks/6fcbdc68-90be1a5480b8d353.js\",\"5094\",\"static/chunks/5094-8d53e403235d4ca6.js\",\"4438\",\"static/chunks/4438-c9a12ca15b6e9160.js\",\"6530\",\"static/chunks/6530-a91e10cffa4200c4.js\",\"6241\",\"static/chunks/6241-30d7169d1010e5a4.js\",\"1668\",\"static/chunks/1668-e3eabd0f6753c780.js\",\"6869\",\"static/chunks/6869-11b3cd61c78598a7.js\",\"8473\",\"static/chunks/8473-6598318371eca31b.js\",\"4883\",\"static/chunks/4883-8a924721bb21b3b0.js\",\"7304\",\"static/chunks/7304-53d85c55adc8f184.js\",\"3185\",\"static/chunks/app/layout-64ac14a534e2809b.js\"],\"default\",1]\nc:I[61060,[],\"\"]\n7:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n8:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\n9:{\"display\":\"inline-block\"}\na:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\nd:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L2\",null,{\"buildId\":\"f5Vrl7yWal5q3WejlGdO1\",\"assetPrefix\":\"/admin\",\"urlParts\":[\"\",\"_not-found\",\"\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L3\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null],null],null]},[null,[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/admin/_next/static/css/d08072df3a043c8d.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"$L6\",null,{\"children\":[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$7\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$8\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$9\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$a\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}],\"params\":{}}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$Lb\"],\"globalErrorComponent\":\"$c\",\"missingSlots\":\"$Wd\"}]\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}]]\n3:null\n"])</script></body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3817],{92322:function(e,l,s){s.d(l,{j:function(){return y}});var t=s(57437),a=s(2265),n=s(29501),r=s(12381),i=s(40279),o=s(75060),c=s(23675),d=s(94589),u=s(51817),m=s(90641),h=s(79622),x=s(5101),p=s(24065);let f=["createdAt","updatedAt","deletedAt","userCreated_Id","userUpdated_Id","userDeleted_Id","userCreated","userUpdated","userDeleted"],g=["UUIDV4","SUID","AUTOINCREMENT","NOW"],v=e=>!!e.defaultValue&&"object"==typeof e.defaultValue&&!!e.defaultValue.type&&g.includes(e.defaultValue.type),j=["createdAt","updatedAt","deletedAt"],y=e=>{let{fields:l,initialValues:s,onSubmit:g,isLoading:y,onCancel:N,disabledFields:b=[]}=e,{register:w,handleSubmit:C,setValue:S,watch:k,reset:T,formState:{errors:D}}=(0,n.cI)({defaultValues:s||{}}),[A,_]=(0,a.useState)(!1),[I,E]=(0,a.useState)(null),[O,F]=(0,a.useState)({});(0,a.useEffect)(()=>{if(s){T(s);let e=l.filter(e=>e.relType),t={};e.forEach(e=>{let l=s[e.name];if(("BelongsTo"===e.relType||"HasOne"===e.relType)&&!l&&e.foreignKey){let t=s[e.foreignKey];t&&(l={id:t})}("BelongsTo"===e.relType||"HasOne"===e.relType)&&l?t[e.name]=l:["HasMany","BelongsToMany","M2M","M2A"].includes(e.relType)&&l&&(t[e.name]=Array.isArray(l)?l:[l])}),F(t)}},[s,T,l]);let Z=s&&Object.keys(s).length>0,z=l.filter(e=>e.relType&&e.foreignKey).map(e=>e.foreignKey),M=l.filter(e=>!(z.includes(e.name)||f.includes(e.name))&&(!e.primaryKey||!Z&&!v(e))),P=M.filter(e=>!e.relType),L=M.filter(e=>e.relType),B=(e,l)=>{if("BelongsTo"===e.relType||"HasOne"===e.relType){let s=l?"string"==typeof l?{id:l}:l:null;if(F(l=>({...l,[e.name]:s})),e.foreignKey){let s="string"==typeof l?l:null==l?void 0:l.id;S(e.foreignKey,s)}}else{let s=(Array.isArray(l)?l:[l]).map(e=>"string"==typeof e?{id:e}:e);F(l=>({...l,[e.name]:s}))}},U=(e,l)=>{"BelongsTo"===e.relType||"HasOne"===e.relType?(F(l=>{let s={...l};return delete s[e.name],s}),e.foreignKey&&S(e.foreignKey,null)):F(s=>({...s,[e.name]:(s[e.name]||[]).filter(e=>e.id!==l)}))},R=e=>{E(e),_(!0)};return(0,t.jsxs)("form",{onSubmit:C(e=>{let s={...e};j.forEach(e=>{delete s[e]}),l.filter(e=>e.relType).forEach(e=>{if("BelongsTo"===e.relType||"HasOne"===e.relType){let l=O[e.name];if(l&&e.foreignKey){let t="string"==typeof l?l:l.id;s[e.foreignKey]=t}delete s[e.name]}else if(["HasMany","BelongsToMany","M2M","M2A"].includes(e.relType)){let l=O[e.name];l&&Array.isArray(l)?s[e.name]=l.map(e=>({id:"string"==typeof e?e:e.id})):delete s[e.name]}}),g(s)}),children:[(0,t.jsx)(m.x,{className:"h-[calc(100vh-200px)] pr-4",children:(0,t.jsxs)("div",{className:"space-y-4",children:[P.map(e=>{let l=k(e.name),s=e.name,a=e.label||s.replace(/_/g," "),n=b.includes(s);switch(e.type){case"Boolean":return(0,t.jsxs)("div",{className:"flex items-center justify-between space-x-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(d.r,{id:s,checked:l||!1,onCheckedChange:e=>S(s,e),disabled:n})]},s);case"Number":case"Integer":case"Float":case"Decimal":case"BigInt":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(i.I,{id:s,type:"number",step:"Integer"===e.type||"BigInt"===e.type?"1":"any",disabled:n,...w(s,{valueAsNumber:!0})})]},s);case"Date":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(i.I,{id:s,type:"date",value:(e=>{if(!e)return"";let l=new Date(e),s=l.getFullYear(),t=String(l.getMonth()+1).padStart(2,"0"),a=String(l.getDate()).padStart(2,"0");return"".concat(s,"-").concat(t,"-").concat(a)})(l),disabled:n,onChange:e=>{S(s,e.target.value||null)}})]},s);case"DateTime":case"DateTime_NO_TZ":case"DATETIME":case"TIMESTAMP":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(i.I,{id:s,type:"datetime-local",value:(e=>{if(!e)return"";let l=new Date(e),s=l.getFullYear(),t=String(l.getMonth()+1).padStart(2,"0"),a=String(l.getDate()).padStart(2,"0"),n=String(l.getHours()).padStart(2,"0"),r=String(l.getMinutes()).padStart(2,"0");return"".concat(s,"-").concat(t,"-").concat(a,"T").concat(n,":").concat(r)})(l),disabled:n,onChange:e=>{S(s,e.target.value?new Date(e.target.value).toISOString():null)}})]},s);case"Time":case"Time_NO_TZ":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(i.I,{id:s,type:"time",value:(e=>{if(!e)return"";if("string"==typeof e){let l=e.match(/^(\d{2}):(\d{2})/);if(l)return"".concat(l[1],":").concat(l[2]);if(e.includes("T")){let l=new Date(e),s=String(l.getHours()).padStart(2,"0"),t=String(l.getMinutes()).padStart(2,"0");return"".concat(s,":").concat(t)}}return e})(l),disabled:n,onChange:e=>{S(s,e.target.value||null)}})]},s);case"Text":case"LONGTEXT":case"MEDIUMTEXT":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(c.g,{id:s,rows:4,disabled:n,...w(s)})]},s);case"JSON":case"JSONB":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.mq,{value:l,onChange:e=>S(s,e),disabled:n})]},s);case"Enum":case"ENUM":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.o_,{value:l||"",onChange:e=>S(s,e),options:e.values||[],placeholder:"Select an option",allowNull:e.allowNull,disabled:n})]},s);case"Email":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(i.I,{id:s,type:"email",disabled:n,...w(s)})]},s);case"URL":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(i.I,{id:s,type:"url",placeholder:"https://",disabled:n,...w(s)})]},s);case"Phone":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(i.I,{id:s,type:"tel",disabled:n,...w(s)})]},s);case"Password":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(i.I,{id:s,type:"password",disabled:n,...w(s)})]},s);case"Array_Integer":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.OF,{value:l||[],onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"number"})]},s);case"Array_String":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.OF,{value:l||[],onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"string"})]},s);case"Array_Double":case"Array_Decimal":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.OF,{value:l||[],onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"number"})]},s);case"Array_UUID":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.OF,{value:l||[],onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"string",placeholder:"Enter UUID values"})]},s);case"Array_Date":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.OF,{value:l||[],onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"date"})]},s);case"Array_DateTime":case"Array_DateTime_NO_TZ":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.OF,{value:l||[],onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"datetime"})]},s);case"Array_Time":case"Array_Time_NO_TZ":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.OF,{value:l||[],onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"time"})]},s);case"Array_Boolean":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.OF,{value:l||[],onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"boolean"})]},s);case"Range_Integer":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.sU,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"integer"})]},s);case"Range_Double":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.sU,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"double"})]},s);case"Range_Decimal":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.sU,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"decimal"})]},s);case"Range_Date":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.sU,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"date"})]},s);case"Range_DateTime":case"Range_DateTime_NO_TZ":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.sU,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"datetime"})]},s);case"Range_Time":case"Range_Time_NO_TZ":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.sU,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"time"})]},s);case"Point":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.XG,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"Point",fieldName:a})]},s);case"Polygon":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.XG,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"Polygon",fieldName:a})]},s);case"LineString":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.XG,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"LineString",fieldName:a})]},s);case"MultiPoint":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.XG,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"MultiPoint",fieldName:a})]},s);case"MultiPolygon":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.XG,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"MultiPolygon",fieldName:a})]},s);case"MultiLineString":return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(h.XG,{value:l,onChange:e=>S(s,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"MultiLineString",fieldName:a})]},s);default:return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{htmlFor:s,children:a}),(0,t.jsx)(i.I,{id:s,type:"text",disabled:n,...w(s)})]},s)}}),L.length>0&&(0,t.jsxs)("div",{className:"space-y-4 pt-4 border-t",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-muted-foreground",children:"Relationships"}),L.map(e=>{let l="BelongsTo"===e.relType||"HasOne"===e.relType?O[e.name]:O[e.name]||[];return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o._,{children:e.label||e.name.replace(/_/g," ")}),(0,t.jsx)(x.q,{value:l,field:e,onClick:()=>R(e),onRemove:l=>U(e,l)})]},e.name)})]})]})}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-4 border-t mt-4",children:[(0,t.jsx)(r.z,{type:"button",variant:"outline",onClick:N,disabled:y,children:"Cancel"}),(0,t.jsxs)(r.z,{type:"submit",disabled:y,children:[y&&(0,t.jsx)(u.Z,{className:"mr-2 h-4 w-4 animate-spin"}),s?"Update":"Create"]})]}),I&&(0,t.jsx)(p.x,{open:A,onClose:()=>{_(!1),setTimeout(()=>E(null),100)},onSelect:e=>{B(I,e)},target:I.target,field:I,selectedItems:"BelongsTo"===I.relType||"HasOne"===I.relType?O[I.name]?[O[I.name]]:[]:O[I.name]||[]})]})}},24065:function(e,l,s){s.d(l,{x:function(){return N}});var t=s(57437),a=s(2265),n=s(29696),r=s(91032),i=s(12381),o=s(69174),c=s(75060),d=s(17168),u=s(99397),m=s(32489),h=s(69658),x=s(17689),p=s(51817),f=s(72337),g=s(92322),v=s(72135),j=s(14438);let y=e=>{if(0===e)return"0 B";let l=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,l)).toFixed(2))+" "+["B","KB","MB","GB"][l]},N=e=>{var l;let{open:s,onClose:N,onSelect:b,target:w,field:C,selectedItems:S=[]}=e,[k,T]=(0,a.useState)(S),[D,A]=(0,a.useState)(!1),[_,I]=(0,a.useState)("select"),[E,O]=(0,a.useState)([]),[F,Z]=(0,a.useState)(!1),[z,M]=(0,a.useState)(0),P=(0,a.useRef)(null),{getFieldsByCollection:L,schemas:B}=(0,n.I_)();(0,v.Ji)();let U="files"===w||"baasix_File"===w,R="HasMany"===C.relType||"BelongsToMany"===C.relType||"M2M"===C.relType||"M2A"===C.relType;(0,a.useEffect)(()=>{s&&(T(S||[]),I("select"),O([]))},[s,S]);let V=L(w),J=null==B?void 0:B.find(e=>e.collectionName===w),q=(0,a.useMemo)(()=>V?Object.entries(V).map(e=>{let[l,s]=e;return{name:l,...s,label:l.replace(/_/g," ").replace(/([A-Z])/g," $1").trim()}}):[],[V]),{mutate:K,isLoading:W}=(0,v.RO)(),G=(0,a.useCallback)(e=>{e.preventDefault(),O(Array.from(e.dataTransfer.files))},[]),H=(0,a.useCallback)(e=>{e.preventDefault()},[]),Y=e=>{O(E.filter((l,s)=>s!==e))},X=async()=>{if(0===E.length)return;Z(!0);let e=[];try{for(let l of E){let s=new FormData;s.append("file",l),await new Promise((t,a)=>{K({resource:"files",values:s},{onSuccess:l=>{let s=null==l?void 0:l.data;s&&e.push(s),t()},onError:e=>{j.Am.error("Failed to upload ".concat(l.name,": ").concat(e.message)),a(e)}})})}if(j.Am.success("".concat(E.length," file(s) uploaded successfully")),Z(!1),e.length>0){if(R){let l=[...k,...e];T(l),b(l),O([]),I("select"),M(e=>e+1)}else{b(e[0]),setTimeout(()=>{N()},50);return}}}catch(e){console.error("Upload error:",e),Z(!1)}},Q=(0,a.useCallback)(e=>{T(e),!R&&e.length>0&&(b(e[0]),N())},[R,b,N]),$=()=>{b(k),N()};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.yo,{open:s,onOpenChange:e=>!e&&N(),children:(0,t.jsx)(r.ue,{className:"w-full sm:w-[900px] sm:max-w-[900px] flex flex-col p-0",hideDefaultClose:!0,children:U?(0,t.jsxs)(d.mQ,{value:_,onValueChange:e=>I(e),className:"flex-1 flex flex-col min-h-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b shrink-0",children:[(0,t.jsx)(r.sw,{asChild:!0,children:(0,t.jsxs)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:[(0,t.jsx)(m.Z,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"sr-only",children:"Close"})]})}),(0,t.jsxs)("span",{className:"font-medium truncate text-sm",children:["Select ",(null==C?void 0:C.label)||(null==C?void 0:C.name)]}),R&&k.length>0&&(0,t.jsx)(o.C,{variant:"secondary",className:"shrink-0",children:k.length}),(0,t.jsxs)(d.dr,{className:"grid grid-cols-2 ml-auto",children:[(0,t.jsxs)(d.SP,{value:"select",className:"text-xs px-3",children:[(0,t.jsx)(h.Z,{className:"mr-1.5 h-3.5 w-3.5"}),"Select"]}),(0,t.jsxs)(d.SP,{value:"upload",className:"text-xs px-3",children:[(0,t.jsx)(x.Z,{className:"mr-1.5 h-3.5 w-3.5"}),"Upload"]})]}),R&&(0,t.jsxs)(i.z,{onClick:$,children:["Done (",k.length,")"]})]}),(0,t.jsx)(d.nU,{value:"select",className:"flex-1 flex flex-col min-h-0 mt-0 data-[state=inactive]:hidden",children:(0,t.jsx)("div",{className:"flex-1 flex flex-col min-h-0 px-3 pb-3",children:w&&(0,t.jsx)(f.DataBrowserInner,{selectedCollection:w,hideTitle:!0,enableSearch:!0,enableFilters:!0,enableCreate:!1,enableView:!1,enableEdit:!1,enableDelete:!1,enableExport:!1,enableImport:!1,enableBulkSelect:!1,enableColumnSettings:!1,showSelectionColumn:!0,selectionMode:R?"multiple":"single",externalSelectedRows:k,onExternalSelectionChange:Q,highlightSelectedRows:!0},z)})}),(0,t.jsx)(d.nU,{value:"upload",className:"flex-1 overflow-auto p-4 mt-0 data-[state=inactive]:hidden",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"border-2 border-dashed rounded-lg p-12 text-center cursor-pointer hover:border-primary transition-colors",onClick:()=>{var e;return null===(e=P.current)||void 0===e?void 0:e.click()},onDrop:G,onDragOver:H,children:[(0,t.jsx)(x.Z,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),(0,t.jsx)("p",{className:"text-lg font-medium",children:"Drag and drop files here"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"or click to browse"}),(0,t.jsx)("input",{ref:P,type:"file",multiple:R,className:"hidden",onChange:e=>{e.target.files&&O(Array.from(e.target.files))}})]}),E.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(c._,{children:"Selected Files"}),(0,t.jsx)("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:E.map((e,l)=>(0,t.jsxs)("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 truncate",children:[(0,t.jsx)(h.Z,{className:"h-5 w-5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate block",children:e.name}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:y(e.size)})]})]}),(0,t.jsx)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>Y(l),children:(0,t.jsx)(m.Z,{className:"h-4 w-4"})})]},l))}),(0,t.jsxs)(i.z,{onClick:X,disabled:F||0===E.length,className:"w-full",children:[F?(0,t.jsx)(p.Z,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(x.Z,{className:"mr-2 h-4 w-4"}),"Upload & Select"]})]})]})})]}):(0,t.jsx)("div",{className:"flex-1 flex flex-col min-h-0 px-3 pb-3 pt-2",children:w&&(0,t.jsx)(f.DataBrowserInner,{selectedCollection:w,hideTitle:!0,enableSearch:!0,enableFilters:!0,enableCreate:!1,enableView:!1,enableEdit:!1,enableDelete:!1,enableExport:!1,enableImport:!1,enableBulkSelect:!1,enableColumnSettings:!1,showSelectionColumn:!0,selectionMode:R?"multiple":"single",externalSelectedRows:k,onExternalSelectionChange:Q,highlightSelectedRows:!0,quickFilters:(0,t.jsxs)("div",{className:"flex items-center gap-2 mr-auto",children:[(0,t.jsx)(r.sw,{asChild:!0,children:(0,t.jsxs)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:[(0,t.jsx)(m.Z,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"sr-only",children:"Close"})]})}),(0,t.jsxs)("span",{className:"font-medium truncate text-sm",children:["Select ",(null==C?void 0:C.label)||(null==C?void 0:C.name)]}),R&&k.length>0&&(0,t.jsx)(o.C,{variant:"secondary",className:"shrink-0",children:k.length})]}),headerActions:(0,t.jsxs)(t.Fragment,{children:[!U&&(0,t.jsx)(i.z,{size:"icon",onClick:()=>A(!0),title:"Create New",children:(0,t.jsx)(u.Z,{className:"h-4 w-4"})}),R&&(0,t.jsxs)(i.z,{onClick:$,children:["Done (",k.length,")"]})]})})})})}),(0,t.jsx)(r.yo,{open:D,onOpenChange:A,children:(0,t.jsxs)(r.ue,{className:"w-full sm:w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,t.jsx)(r.Tu,{children:(0,t.jsxs)(r.bC,{children:["Create New ",(null==J?void 0:null===(l=J.schema)||void 0===l?void 0:l.name)||w]})}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(g.j,{fields:q,onSubmit:e=>{K({resource:w,values:e},{onSuccess:e=>{j.Am.success("Item created successfully"),A(!1),R?T([...k,e.data]):(b(e.data),N())},onError:e=>{j.Am.error("Failed to create: ".concat(e.message))}})},isLoading:W,onCancel:()=>A(!1)})})]})})]})}},5101:function(e,l,s){s.d(l,{q:function(){return o}});var t=s(57437);s(2265);var a=s(12381),n=s(69174),r=s(32489),i=s(73247);let o=e=>{let{value:l,field:s,onClick:o,onRemove:c,placeholder:d}=e,u=e=>{if(!e||"object"!=typeof e)return!1;let l=Object.keys(e);return 0===l.length||l.every(l=>null===e[l]||void 0===e[l])},m=e=>{if(!e||"object"==typeof e&&u(e))return"";if("string"==typeof e||"number"==typeof e)return String(e);if(s.showAs&&Array.isArray(s.showAs)){let l=["-"," ",",","_"," and "," or "],t=[];s.showAs.forEach(s=>{if(l.includes(s))t.push(s);else{let l;if(s.includes(".")){let t=s.split("."),a=e;for(let e of t)if(null==(a=null==a?void 0:a[e]))break;l=a}else l=e[s];null!=l&&""!==l&&t.push(String(l))}});let a=t.filter((e,s)=>{let a=l.includes(e),n=s>0&&l.includes(t[s-1]),r=s===t.length-1;return!a||0!==s&&!r&&!n});return a.length>0?a.join(""):e.id||e.name||""}return e.name||e.title||e.label||e.email||e.id||""};if(Array.isArray(l))return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{onClick:o,className:"cursor-pointer",children:l.length>0?(0,t.jsx)("div",{className:"flex flex-wrap gap-1 p-2 border rounded-md min-h-10 bg-background",children:l.map((e,l)=>(0,t.jsxs)(n.C,{variant:"secondary",className:"flex items-center gap-1",children:[m(e),(0,t.jsx)("button",{type:"button",onClick:l=>{l.stopPropagation(),null==c||c(e)},className:"ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:(0,t.jsx)(r.Z,{className:"h-3 w-3"})})]},e.id||l))}):(0,t.jsxs)("div",{className:"flex items-center gap-2 p-2 border rounded-md min-h-10 bg-background text-muted-foreground cursor-pointer hover:bg-accent",children:[(0,t.jsx)(i.Z,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:d||"Select ".concat(s.label||s.name)})]})}),l.length>0&&(0,t.jsxs)(a.z,{type:"button",variant:"outline",size:"sm",onClick:o,className:"flex items-center gap-1",children:[(0,t.jsx)(i.Z,{className:"h-3 w-3"}),"Add More"]})]});let h=l&&!u(l);return(0,t.jsx)("div",{onClick:o,className:"cursor-pointer",children:(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)("div",{className:"flex-1",children:h?(0,t.jsxs)("div",{className:"flex items-center gap-2 p-2 border rounded-md min-h-10 bg-background",children:[(0,t.jsx)("span",{className:"flex-1",children:m(l)}),(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),null==c||c(l)},className:"text-muted-foreground hover:text-foreground",children:(0,t.jsx)(r.Z,{className:"h-4 w-4"})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2 p-2 border rounded-md min-h-10 bg-background text-muted-foreground hover:bg-accent",children:[(0,t.jsx)(i.Z,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:d||"Select ".concat(s.label||s.name)})]})})})})}},72337:function(e,l,s){s.r(l),s.d(l,{DataBrowser:function(){return eH},DataBrowserInner:function(){return eG},default:function(){return eY}});var t=s(57437),a=s(2265),n=s(99376),r=s(72135),i=s(10795),o=s(93662),c=s(84314),d=s(29696),u=s(63751),m=s(28757),h=s(83434),x=s(79622),p=s(12381),f=s(43368),g=s(79820),v=s(33804),j=s(69174),y=s(91032),N=s(74291),b=s(32060),w=s(15291),C=s(68245),S=s(90740),k=s(98728),T=s(82431),D=s(67782),A=s(92735),_=s(17689),I=s(99397),E=s(41905),O=s(20265),F=s(15051),Z=s(28842),z=s(51817),M=s(42208),P=s(15868),L=s(18930),B=s(92451),U=s(10407),R=s(83774),V=s(40875),J=s(82284),q=s(13781),K=s(7586),W=s(64935),G=s(17168),H=s(23675),Y=s(12749),X=s(90641),Q=s(71096),$=s.n(Q),ee=s(40279),el=s(94589),es=s(46291),et=s(31047),ea=s(91723),en=s(93448),er=s(27107);let ei={text:[{label:"Equals",value:"eq"},{label:"Not Equals",value:"ne"},{label:"Contains",value:"contains"},{label:"Not Contains",value:"ncontains"},{label:"Starts With",value:"startswith"},{label:"Ends With",value:"endswith"},{label:"Is Empty",value:"null"},{label:"Is Not Empty",value:"nnull"}],number:[{label:"Equals",value:"eq"},{label:"Not Equals",value:"ne"},{label:"Greater Than",value:"gt"},{label:"Greater Than or Equal",value:"gte"},{label:"Less Than",value:"lt"},{label:"Less Than or Equal",value:"lte"},{label:"Between",value:"between"},{label:"Is Empty",value:"null"},{label:"Is Not Empty",value:"nnull"}],date:[{label:"Equals",value:"eq"},{label:"Not Equals",value:"ne"},{label:"Greater Than",value:"gt"},{label:"Greater Than or Equal",value:"gte"},{label:"Less Than",value:"lt"},{label:"Less Than or Equal",value:"lte"},{label:"Between",value:"between"},{label:"Is Empty",value:"null"},{label:"Is Not Empty",value:"nnull"}],boolean:[{label:"Is True",value:"true"},{label:"Is False",value:"false"},{label:"Is Empty",value:"null"},{label:"Is Not Empty",value:"nnull"}],relation:[{label:"Equals",value:"eq"},{label:"Not Equals",value:"ne"},{label:"Is Empty",value:"null"},{label:"Is Not Empty",value:"nnull"}],array:[{label:"Contains",value:"contains"},{label:"Not Contains",value:"ncontains"},{label:"Is Empty",value:"null"},{label:"Is Not Empty",value:"nnull"}],json:[{label:"Contains Key",value:"contains"},{label:"Not Contains Key",value:"ncontains"},{label:"Is Empty",value:"null"},{label:"Is Not Empty",value:"nnull"}],geospatial:[{label:"Within",value:"within"},{label:"Contains",value:"containsGEO"},{label:"Intersects",value:"intersects"},{label:"Distance Within",value:"dwithin"},{label:"Is Empty",value:"null"},{label:"Is Not Empty",value:"nnull"}]},eo=e=>{var l;if(!e)return ei.text;if(e.relType)return ei.relation;if(null===(l=e.type)||void 0===l?void 0:l.startsWith("Array_"))return ei.array;switch(e.type){case"Number":case"Integer":case"Float":case"Decimal":case"BigInt":return ei.number;case"Date":case"DateTime":case"DateTime_NO_TZ":case"Time":case"Time_NO_TZ":return ei.date;case"Boolean":return ei.boolean;case"JSON":case"JSONB":return ei.json;case"Point":case"Polygon":case"LineString":return ei.geospatial;default:return ei.text}},ec=(e,l,s)=>{if(null==e)return e;if("null"===l||"nnull"===l||"true"===l)return!0;if("false"===l)return!1;if(s){var t;if("Date"===s.type||"DateTime"===s.type||"DateTime_NO_TZ"===s.type)return"between"===l&&Array.isArray(e)?e.map(e=>e?$()(e).toISOString():null):e?$()(e).toISOString():null;if("Time"===s.type||"Time_NO_TZ"===s.type)return"between"===l&&Array.isArray(e)?e.map(e=>e||null):e||null;if("Number"===s.type||"Integer"===s.type||"Float"===s.type||"Decimal"===s.type||"BigInt"===s.type)return"between"===l&&Array.isArray(e)?e.map(e=>void 0!==e&&""!==e?Number(e):null):void 0!==e&&""!==e?Number(e):null;if("Boolean"===s.type)return!!e;if(null===(t=s.type)||void 0===t?void 0:t.startsWith("Array_"))return Array.isArray(e)?e:[e];if("Point"===s.type||"Polygon"===s.type||"LineString"===s.type)try{return"string"==typeof e?JSON.parse(e):e}catch(e){}}return e},ed=e=>{let{value:l,onChange:s,placeholder:a}=e;return(0,t.jsxs)(Y.J2,{children:[(0,t.jsx)(Y.xo,{asChild:!0,children:(0,t.jsxs)(p.z,{variant:"outline",className:(0,en.cn)("w-full justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[(0,t.jsx)(et.Z,{className:"mr-2 h-4 w-4"}),l?(0,er.WU)(l,"PPP"):a||"Pick a date"]})}),(0,t.jsx)(Y.yk,{className:"w-auto p-0",align:"start",children:(0,t.jsx)(es.f,{mode:"single",selected:l,onSelect:s,initialFocus:!0})})]})},eu=e=>{let{value:l,onChange:s,placeholder:a}=e,n=l?"".concat(String(l.getHours()).padStart(2,"0"),":").concat(String(l.getMinutes()).padStart(2,"0")):"",r=e=>{if(!e)return;let[t,a]=e.split(":").map(Number),n=l?new Date(l):new Date;n.setHours(t,a,0,0),s(n)};return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(Y.J2,{children:[(0,t.jsx)(Y.xo,{asChild:!0,children:(0,t.jsxs)(p.z,{variant:"outline",className:(0,en.cn)("justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[(0,t.jsx)(et.Z,{className:"mr-2 h-4 w-4"}),l?(0,er.WU)(l,"PPP"):a||"Pick a date"]})}),(0,t.jsx)(Y.yk,{className:"w-auto p-0",align:"start",children:(0,t.jsx)(es.f,{mode:"single",selected:l,onSelect:e=>{if(!e){s(void 0);return}l&&e.setHours(l.getHours(),l.getMinutes(),0,0),s(e)},initialFocus:!0})})]}),(0,t.jsx)(ee.I,{type:"time",value:n,onChange:e=>r(e.target.value),className:"w-28"})]})},em=e=>{let{value:l,onChange:s,placeholder:a}=e;return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ea.Z,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)(ee.I,{type:"time",value:(e=>{if(!e)return"";if(e.includes("T")){let l=new Date(e);if(!isNaN(l.getTime()))return"".concat(String(l.getHours()).padStart(2,"0"),":").concat(String(l.getMinutes()).padStart(2,"0"))}return/^\d{2}:\d{2}/.test(e)?e.substring(0,5):e})(l),onChange:e=>s(e.target.value||void 0),placeholder:a||"Select time",className:"w-full"})]})},eh=(e,l,s,a)=>{var n,r,i,o;if("null"===l||"nnull"===l)return null;if(!e)return(0,t.jsx)(ee.I,{placeholder:"Enter value",value:s||"",onChange:e=>a(e.target.value)});if(e.relType)return(0,t.jsxs)(w.Ph,{value:s||"",onValueChange:a,children:[(0,t.jsx)(w.i4,{className:"w-full",children:(0,t.jsx)(w.ki,{placeholder:"Select value"})}),(0,t.jsx)(w.Bw,{})]});if(null===(n=e.type)||void 0===n?void 0:n.startsWith("Array_"))return(0,t.jsx)(ee.I,{placeholder:"Enter values (comma-separated)",value:Array.isArray(s)?s.join(", "):s||"",onChange:e=>{let l=e.target.value.split(",").map(e=>e.trim()).filter(Boolean);a(l.length>0?l:void 0)}});switch(e.type){case"Number":case"Integer":case"Float":case"Decimal":case"BigInt":if("between"===l)return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ee.I,{type:"number",className:"w-24",value:null!==(r=null==s?void 0:s[0])&&void 0!==r?r:"",onChange:e=>a([e.target.value?Number(e.target.value):void 0,null==s?void 0:s[1]]),placeholder:"Min"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"to"}),(0,t.jsx)(ee.I,{type:"number",className:"w-24",value:null!==(i=null==s?void 0:s[1])&&void 0!==i?i:"",onChange:e=>a([null==s?void 0:s[0],e.target.value?Number(e.target.value):void 0]),placeholder:"Max"})]});return(0,t.jsx)(ee.I,{type:"number",value:null!=s?s:"",onChange:e=>a(e.target.value?Number(e.target.value):void 0),className:"w-full"});case"Boolean":return(0,t.jsx)(el.r,{checked:!0===s,onCheckedChange:a});case"Date":if("between"===l)return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ed,{value:(null==s?void 0:s[0])?new Date(s[0]):void 0,onChange:e=>a([null==e?void 0:e.toISOString(),null==s?void 0:s[1]]),placeholder:"From"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"to"}),(0,t.jsx)(ed,{value:(null==s?void 0:s[1])?new Date(s[1]):void 0,onChange:e=>a([null==s?void 0:s[0],null==e?void 0:e.toISOString()]),placeholder:"To"})]});return(0,t.jsx)(ed,{value:s?new Date(s):void 0,onChange:e=>a(null==e?void 0:e.toISOString())});case"DateTime":case"DateTime_NO_TZ":if("between"===l)return(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(eu,{value:(null==s?void 0:s[0])?new Date(s[0]):void 0,onChange:e=>a([null==e?void 0:e.toISOString(),null==s?void 0:s[1]]),placeholder:"From"}),(0,t.jsx)("span",{className:"text-muted-foreground text-center",children:"to"}),(0,t.jsx)(eu,{value:(null==s?void 0:s[1])?new Date(s[1]):void 0,onChange:e=>a([null==s?void 0:s[0],null==e?void 0:e.toISOString()]),placeholder:"To"})]});return(0,t.jsx)(eu,{value:s?new Date(s):void 0,onChange:e=>a(null==e?void 0:e.toISOString())});case"Time":case"Time_NO_TZ":if("between"===l)return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(em,{value:null==s?void 0:s[0],onChange:e=>a([e,null==s?void 0:s[1]]),placeholder:"From"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"to"}),(0,t.jsx)(em,{value:null==s?void 0:s[1],onChange:e=>a([null==s?void 0:s[0],e]),placeholder:"To"})]});return(0,t.jsx)(em,{value:s,onChange:a});case"Enum":case"ENUM":return(0,t.jsxs)(w.Ph,{value:s||"",onValueChange:a,children:[(0,t.jsx)(w.i4,{className:"w-full",children:(0,t.jsx)(w.ki,{placeholder:"Select value"})}),(0,t.jsx)(w.Bw,{children:null===(o=e.values)||void 0===o?void 0:o.map(e=>(0,t.jsx)(w.Ql,{value:e,children:e},e))})]});case"Point":case"Polygon":case"LineString":return(0,t.jsx)(H.g,{placeholder:"Enter GeoJSON",value:"object"==typeof s?JSON.stringify(s):s||"",onChange:e=>a(e.target.value)});default:return(0,t.jsx)(ee.I,{placeholder:"Enter value",value:s||"",onChange:e=>a(e.target.value)})}},ex=e=>e&&"object"==typeof e&&"field"in e&&"operator"in e,ep=e=>{let{fields:l,value:s,onChange:n}=e,{getFieldsByCollection:r}=(0,d.I_)(),[i,o]=(0,a.useState)(new Set),[c,u]=(0,a.useState)(!1),m=(0,a.useCallback)(function(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3;return 0===s?[]:e.map(e=>{let t=l?"".concat(l,".").concat(e.name):e.name,a={name:e.name,path:t,label:e.label||e.name,type:e.type,relType:e.relType,target:e.target};if(e.relType&&e.target){let l=r(e.target);if(l){let e=Object.entries(l).map(e=>{let[l,s]=e;return{name:l,...s,label:l.replace(/_/g," ").replace(/([A-Z])/g," $1").trim()}});a.children=m(e,t,s-1)}}return a})},[r]),h=(0,a.useMemo)(()=>m(l),[l,m]),x=(e,l)=>{l.stopPropagation();let s=new Set(i);s.has(e)?s.delete(e):s.add(e),o(s)},f=e=>{n(e),u(!1)},g=function(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=e.children&&e.children.length>0,n=i.has(e.path),r=s===e.path;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 py-1.5 px-2 cursor-pointer hover:bg-accent rounded-sm ".concat(r?"bg-accent":""),style:{paddingLeft:"".concat(16*l+8,"px")},onClick:()=>f(e.path),children:[a?(0,t.jsx)("button",{type:"button",onClick:l=>x(e.path,l),className:"p-0.5 hover:bg-muted rounded",children:n?(0,t.jsx)(V.Z,{className:"h-3 w-3"}):(0,t.jsx)(U.Z,{className:"h-3 w-3"})}):(0,t.jsx)("span",{className:"w-4"}),(0,t.jsxs)("span",{className:"text-sm truncate flex-1",children:[e.label,e.relType&&(0,t.jsxs)("span",{className:"text-xs text-muted-foreground ml-1",children:["(",e.relType,")"]})]})]}),a&&n&&(0,t.jsx)("div",{children:e.children.map(e=>g(e,l+1))})]},e.path)};return(0,t.jsxs)(Y.J2,{open:c,onOpenChange:u,children:[(0,t.jsx)(Y.xo,{asChild:!0,children:(0,t.jsxs)(p.z,{variant:"outline",role:"combobox","aria-expanded":c,className:"w-full sm:w-[180px] justify-between text-left font-normal",children:[(0,t.jsx)("span",{className:"truncate",children:s?s.split(".").join(" → "):"Select field"}),(0,t.jsx)(V.Z,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,t.jsx)(Y.yk,{className:"w-[280px] p-1",align:"start",onWheel:e=>{e.stopPropagation()},children:(0,t.jsx)(X.x,{className:"h-[300px]",children:h.map(e=>g(e))})})]})},ef=e=>{let{fields:l,onApply:s,initialFilters:n=[],collectionName:r}=e,{getFieldsByCollection:i}=(0,d.I_)(),[o,c]=(0,a.useState)(r),[u,h]=(0,a.useState)("builder"),[x,f]=(0,a.useState)("{}"),[v,j]=(0,a.useState)(""),[y,N]=(0,a.useState)({logic:"and",conditions:[{field:"",operator:"",value:void 0}]});(0,a.useEffect)(()=>{r&&r!==o&&(N({logic:"and",conditions:[{field:"",operator:"",value:void 0}]}),c(r))},[r,o]);let b=(0,a.useCallback)(e=>{if(!e)return null;if(e.includes(".")){let s=e.split("."),t=l,a=null;for(let e=0;e<s.length;e++){let l=s[e];if(!(a=t.find(e=>e.name===l)))return null;if(a.relType&&a.target&&e<s.length-1){let e=i(a.target);if(!e)return null;t=Object.entries(e).map(e=>{let[l,s]=e;return{name:l,...s}})}}return a}return l.find(l=>l.name===e)},[l,i]),C=(0,a.useCallback)(e=>e&&0!==e.length?1===e.length&&"operator"in e[0]&&("and"===e[0].operator||"or"===e[0].operator)&&Array.isArray(e[0].value)?{logic:e[0].operator,conditions:e[0].value.map(e=>"field"in e?{field:e.field,operator:e.operator,value:e.value}:"operator"in e&&("and"===e.operator||"or"===e.operator)&&Array.isArray(e.value)?{logic:e.operator,conditions:e.value.map(e=>"field"in e?{field:e.field,operator:e.operator,value:e.value}:"operator"in e&&("and"===e.operator||"or"===e.operator)&&Array.isArray(e.value)?C([e]):{field:"",operator:"",value:void 0})}:{field:"",operator:"",value:void 0})}:{logic:"and",conditions:e.map(e=>"field"in e?{field:e.field,operator:e.operator,value:e.value}:{field:"",operator:"",value:void 0})}:{logic:"and",conditions:[{field:"",operator:"",value:void 0}]},[]);(0,a.useEffect)(()=>{n.length>0?N(C(n)):N({logic:"and",conditions:[{field:"",operator:"",value:void 0}]})},[n,C]);let S=(0,a.useCallback)(e=>{if(!e||!e.conditions||0===e.conditions.length)return[];let l=e.conditions.filter(e=>ex(e)?e.field&&e.operator&&("null"===e.operator||"nnull"===e.operator||void 0!==e.value):S(e).length>0);if(0===l.length)return[];if(1===l.length&&ex(l[0])){let e=l[0],s=b(e.field);return[{field:e.field,operator:e.operator,value:ec(e.value,e.operator,s)}]}return[{operator:e.logic,value:l.map(e=>{if(ex(e)){let l=b(e.field);return{field:e.field,operator:e.operator,value:ec(e.value,e.operator,l)}}{let l=S(e);return 1===l.length?l[0]:{operator:"and",value:[]}}})}]},[b]);(0,a.useEffect)(()=>{if("json"===u){let e=S(y);f(JSON.stringify((0,m.gm)(e),null,2)),j("")}},[y,u,S]);let k=e=>{f(e);try{JSON.parse(e),j("")}catch(e){j("Invalid JSON format")}},T=()=>{try{let e=JSON.parse(x),l=(0,m.LR)(e);j(""),s(l)}catch(e){j("Invalid JSON format")}},D=e=>JSON.parse(JSON.stringify(e)),A=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=D(y),s=l;for(let l=0;l<e.length;l++){let t=e[l];if(ex(s.conditions[t])){console.error("Invalid path: expected a group but found a condition");return}s=s.conditions[t]}s.conditions.push({field:"",operator:"",value:void 0}),N(l)},_=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=D(y),s=l;for(let l=0;l<e.length;l++){let t=e[l];if(ex(s.conditions[t])){console.error("Invalid path: expected a group but found a condition");return}s=s.conditions[t]}s.conditions.push({logic:"and",conditions:[{field:"",operator:"",value:void 0}]}),N(l)},E=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=arguments.length>1?arguments[1]:void 0,s=D(y),t=s;for(let l=0;l<e.length;l++){let s=e[l];if(ex(t.conditions[s])){console.error("Invalid path: expected a group but found a condition");return}t=t.conditions[s]}if(t.conditions.splice(l,1),0===t.conditions.length){if(0===e.length)t.conditions.push({field:"",operator:"",value:void 0});else{let l=s;for(let s=0;s<e.length-1;s++){let t=e[s];ex(l.conditions[t])||(l=l.conditions[t])}l.conditions.splice(e[e.length-1],1),0===l.conditions.length&&l.conditions.push({field:"",operator:"",value:void 0})}}N(s)},O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(0===e.length)return;let l=D(y),s=l;for(let l=0;l<e.length-1;l++){let t=e[l];if(ex(s.conditions[t])){console.error("Invalid path: expected a group but found a condition");return}s=s.conditions[t]}s.conditions.splice(e[e.length-1],1),0===s.conditions.length&&s.conditions.push({field:"",operator:"",value:void 0}),N(l)},F=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=arguments.length>1?arguments[1]:void 0,s=D(y),t=s;for(let l=0;l<e.length;l++){let s=e[l];if(ex(t.conditions[s])){console.error("Invalid path: expected a group but found a condition");return}t=t.conditions[s]}t.logic=l,N(s)},Z=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=arguments.length>1?arguments[1]:void 0,s=arguments.length>2?arguments[2]:void 0,t=D(y),a=t;for(let l=0;l<e.length;l++){let s=e[l];if(ex(a.conditions[s])){console.error("Invalid path: expected a group but found a condition");return}a=a.conditions[s]}let n=a.conditions[l];ex(n)&&(n.field=s,n.operator="",n.value=void 0),N(t)},z=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=arguments.length>1?arguments[1]:void 0,s=arguments.length>2?arguments[2]:void 0,t=D(y),a=t;for(let l=0;l<e.length;l++){let s=e[l];if(ex(a.conditions[s])){console.error("Invalid path: expected a group but found a condition");return}a=a.conditions[s]}let n=a.conditions[l];ex(n)&&(n.operator=s,"null"===s||"nnull"===s||"true"===s||"false"===s?n.value=!0:n.value=void 0),N(t)},M=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=arguments.length>1?arguments[1]:void 0,s=arguments.length>2?arguments[2]:void 0,t=D(y),a=t;for(let l=0;l<e.length;l++){let s=e[l];if(ex(a.conditions[s])){console.error("Invalid path: expected a group but found a condition");return}a=a.conditions[s]}let n=a.conditions[l];ex(n)&&(n.value=s),N(t)},P=function(e,s){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=b(e.field),i=n?eo(n):[];return(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 mb-2 p-2 sm:p-0 bg-muted/30 sm:bg-transparent rounded-lg",children:[(0,t.jsx)("div",{className:"relative w-full sm:w-auto",children:(0,t.jsx)(ep,{fields:l,value:e.field||"",onChange:e=>Z(a,s,e),collectionName:r})}),(0,t.jsxs)(w.Ph,{value:e.operator||"",onValueChange:e=>z(a,s,e),disabled:!e.field,children:[(0,t.jsx)(w.i4,{className:"w-full sm:w-[180px]",children:(0,t.jsx)(w.ki,{placeholder:"Select operator"})}),(0,t.jsx)(w.Bw,{children:i.map(e=>(0,t.jsx)(w.Ql,{value:e.value,children:e.label},e.value))})]}),e.field&&e.operator&&"null"!==e.operator&&"nnull"!==e.operator&&(0,t.jsx)("div",{className:"w-full sm:w-auto sm:min-w-[180px]",children:eh(n,e.operator,e.value,e=>M(a,s,e))}),(0,t.jsx)(p.z,{type:"button",variant:"ghost",size:"icon",onClick:()=>E(a,s),className:"text-muted-foreground hover:text-destructive self-end sm:self-auto",children:(0,t.jsx)(J.Z,{className:"h-4 w-4"})})]},"condition-".concat(a.join("-"),"-").concat(s))},B=function(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=0===l.length;return(0,t.jsxs)(g.Zb,{className:"".concat(s?"":"ml-4 border-l-2 border-l-primary/30"),children:[(0,t.jsx)(g.Ol,{className:"py-3 px-4",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(g.ll,{className:"text-sm font-medium",children:s?"Filter Conditions":"Nested Group"}),(0,t.jsxs)(w.Ph,{value:e.logic,onValueChange:e=>F(l,e),children:[(0,t.jsx)(w.i4,{className:"w-[80px] h-8",children:(0,t.jsx)(w.ki,{})}),(0,t.jsxs)(w.Bw,{children:[(0,t.jsx)(w.Ql,{value:"and",children:"AND"}),(0,t.jsx)(w.Ql,{value:"or",children:"OR"})]})]}),!s&&(0,t.jsx)(p.z,{type:"button",variant:"ghost",size:"icon",onClick:()=>O(l),className:"text-destructive hover:text-destructive",children:(0,t.jsx)(L.Z,{className:"h-4 w-4"})})]})}),(0,t.jsxs)(g.aY,{className:"py-2 px-4",children:[e.conditions.map((e,s)=>ex(e)?P(e,s,l):B(e,[...l,s])),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[(0,t.jsxs)(p.z,{type:"button",variant:"outline",size:"sm",onClick:()=>A(l),children:[(0,t.jsx)(I.Z,{className:"h-4 w-4 mr-1"}),"Add Condition"]}),(0,t.jsxs)(p.z,{type:"button",variant:"outline",size:"sm",onClick:()=>_(l),children:[(0,t.jsx)(q.Z,{className:"h-4 w-4 mr-1"}),"Add Nested Group"]})]})]})]},"group-".concat(l.join("-")))};return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)(G.mQ,{value:u,onValueChange:e=>{if("json"===e&&"builder"===u){let e=S(y);f(JSON.stringify((0,m.gm)(e),null,2)),j("")}else if("builder"===e&&"json"===u)try{let e=JSON.parse(x),l=(0,m.LR)(e),s=C(l);N(s),j("")}catch(e){}h(e)},children:[(0,t.jsxs)(G.dr,{className:"grid w-full grid-cols-2 max-w-[300px]",children:[(0,t.jsxs)(G.SP,{value:"builder",className:"flex items-center gap-2",children:[(0,t.jsx)(K.Z,{className:"h-4 w-4"}),"Builder"]}),(0,t.jsxs)(G.SP,{value:"json",className:"flex items-center gap-2",children:[(0,t.jsx)(W.Z,{className:"h-4 w-4"}),"JSON"]})]}),(0,t.jsx)(G.nU,{value:"builder",className:"mt-4",children:B(y)}),(0,t.jsx)(G.nU,{value:"json",className:"mt-4",children:(0,t.jsxs)(g.Zb,{children:[(0,t.jsx)(g.Ol,{className:"py-3 px-4",children:(0,t.jsx)(g.ll,{className:"text-sm font-medium",children:"JSON Filter Editor (Baasix Format)"})}),(0,t.jsxs)(g.aY,{className:"py-2 px-4",children:[(0,t.jsx)(H.g,{value:x,onChange:e=>k(e.target.value),placeholder:'{"fieldName": {"eq": "value"}}',className:"font-mono text-sm min-h-[300px]"}),v&&(0,t.jsx)("p",{className:"text-sm text-destructive mt-2",children:v}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-2",children:["Edit filters in Baasix format. Example: ",'{"status": {"eq": "active"}, "AND": [{"price": {"gte": 10}}]}']})]})]})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.z,{type:"button",onClick:()=>{"json"===u?T():s(S(y))},children:"Apply Filters"}),(0,t.jsx)(p.z,{type:"button",variant:"outline",onClick:()=>{N({logic:"and",conditions:[{field:"",operator:"",value:void 0}]}),f("{}"),j(""),s([])},children:"Reset"})]})]})},eg=e=>{let{visible:l,onClose:s,formFields:a,onApply:n,initialFilters:r,collectionName:i}=e;return(0,t.jsx)(y.yo,{open:l,onOpenChange:e=>!e&&s(),children:(0,t.jsxs)(y.ue,{className:"w-full sm:w-[600px] sm:max-w-[600px] md:w-[700px] md:max-w-[700px] lg:w-[800px] lg:max-w-[800px] overflow-y-auto",side:"right",children:[(0,t.jsx)(y.Tu,{children:(0,t.jsx)(y.bC,{children:"Advanced Filters"})}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(ef,{fields:a,onApply:e=>{n(e),s()},initialFilters:r,collectionName:i})})]})})};var ev=s(75060);let ej=e=>{let{nodes:l,selectedColumns:s,onSelectionChange:a,level:n=0,expandedNodes:r,onToggleExpand:i}=e,o=e=>e.children&&0!==e.children.length?e.children.flatMap(o):e.disabled?[]:[e.value],c=e=>{if(!e.disabled){if(e.children&&e.children.length>0){let l=o(e);l.every(e=>s.includes(e))?a(s.filter(e=>!l.includes(e))):a(Array.from(new Set([...s,...l])))}else s.includes(e.value)?a(s.filter(l=>l!==e.value)):a([...s,e.value])}},d=e=>{let l=e.split(".");return l[l.length-1].replace(/_/g," ").replace(/([A-Z])/g," $1").trim()};return(0,t.jsx)("div",{className:"space-y-0.5 ".concat(n>0?"ml-4 pl-2 border-l border-muted":""),children:l.map(e=>{let l=e.children&&e.children.length>0,u=r.has(e.key),m=o(e),h=l?m.length>0&&m.every(e=>s.includes(e)):s.includes(e.value),x=l&&m.some(e=>s.includes(e))&&!m.every(e=>s.includes(e));return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 py-1 hover:bg-muted/50 rounded px-1",children:[l&&(0,t.jsx)("button",{type:"button",onClick:()=>i(e.key),className:"p-0.5 hover:bg-muted rounded",children:u?(0,t.jsx)(V.Z,{className:"h-3.5 w-3.5"}):(0,t.jsx)(U.Z,{className:"h-3.5 w-3.5"})}),!l&&(0,t.jsx)("span",{className:"w-4"}),(0,t.jsx)(C.X,{id:"export-".concat(e.key),checked:h,disabled:e.disabled&&!l,onCheckedChange:()=>c(e),className:(0,en.cn)(x&&"data-[state=unchecked]:bg-primary/30")}),(0,t.jsxs)(ev._,{htmlFor:"export-".concat(e.key),className:(0,en.cn)("text-sm cursor-pointer flex-1",e.disabled&&!l&&"text-muted-foreground"),children:[d(e.title),l&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:"(relation)"})]})]}),l&&u&&(0,t.jsx)(ej,{nodes:e.children,selectedColumns:s,onSelectionChange:a,level:n+1,expandedNodes:r,onToggleExpand:i})]},e.key)})})},ey=e=>{let{visible:l,onClose:s,exportColumns:n,onExportColumnsChange:r,exportLimit:i,onExportLimitChange:o,exportPage:c,onExportPageChange:d,isExporting:u,onExport:m,columnTreeData:h}=e,[f,v]=(0,a.useState)(new Set),[j,N]=(0,a.useState)("tree");return(0,t.jsx)(y.yo,{open:l,onOpenChange:e=>!e&&s(),children:(0,t.jsxs)(y.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto flex flex-col",side:"right",children:[(0,t.jsx)(y.Tu,{children:(0,t.jsx)(y.bC,{children:"Export Data"})}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto py-4 space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ev._,{className:"text-base font-semibold",children:"Select Columns to Export:"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose which columns to include in the export. Expand relational fields to access nested columns."}),(0,t.jsxs)(G.mQ,{value:j,onValueChange:e=>N(e),children:[(0,t.jsxs)(G.dr,{className:"grid w-full grid-cols-2",children:[(0,t.jsx)(G.SP,{value:"tree",children:"Tree Selection"}),(0,t.jsx)(G.SP,{value:"json",children:"JSON"})]}),(0,t.jsx)(G.nU,{value:"tree",className:"mt-2",children:(0,t.jsx)(g.Zb,{className:"max-h-[300px] overflow-y-auto",children:(0,t.jsx)(g.aY,{className:"p-3",children:h.length>0?(0,t.jsx)(ej,{nodes:h,selectedColumns:n,onSelectionChange:r,expandedNodes:f,onToggleExpand:e=>{v(l=>{let s=new Set(l);return s.has(e)?s.delete(e):s.add(e),s})}}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-2",children:"No columns available"})})})}),(0,t.jsxs)(G.nU,{value:"json",className:"mt-2",children:[(0,t.jsx)(x.mq,{value:n,onChange:e=>{Array.isArray(e)&&e.every(e=>"string"==typeof e)?r(e):null===e&&r([])},placeholder:'["id", "name", "user.email"]'}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:'Enter column names as a JSON array. Use dot notation for nested fields (e.g., "user.name").'})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ev._,{className:"text-base font-semibold",children:"Export Limits:"}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ev._,{htmlFor:"exportLimit",children:"Number of Records"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ee.I,{id:"exportLimit",type:"number",value:-1===i?"":i,onChange:e=>{let l=e.target.value;o(""===l?-1:parseInt(l)||0),(""===l||-1===parseInt(l))&&d(1)},placeholder:"Enter number of records",className:"flex-1"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(C.X,{id:"allRecords",checked:-1===i,onCheckedChange:e=>{e&&(o(-1),d(1))}}),(0,t.jsx)(ev._,{htmlFor:"allRecords",className:"text-sm",children:"All Records"})]})]})]}),-1!==i&&i>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ev._,{htmlFor:"exportPage",children:"Page Number"}),(0,t.jsx)(ee.I,{id:"exportPage",type:"number",min:1,value:c,onChange:e=>d(parseInt(e.target.value)||1),placeholder:"Enter page number"}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Records ",(c-1)*i+1," to ",c*i," will be exported"]})]})]})]}),(0,t.jsx)(g.Zb,{children:(0,t.jsxs)(g.aY,{className:"p-4",children:[(0,t.jsx)(ev._,{className:"text-base font-semibold",children:"Export Summary:"}),(0,t.jsxs)("div",{className:"mt-2 space-y-1 text-sm",children:[(0,t.jsxs)("p",{children:["• Columns: ",n.length," selected"]}),(0,t.jsxs)("p",{children:["• Records: ",-1===i?"All records":"".concat(i," records from page ").concat(c)]}),(0,t.jsx)("p",{children:"• Format: CSV"})]})]})})]}),(0,t.jsxs)(y.FF,{className:"pt-4 border-t",children:[(0,t.jsx)(p.z,{variant:"outline",onClick:s,children:"Cancel"}),(0,t.jsx)(p.z,{onClick:m,disabled:0===n.length||u,children:u?"Exporting...":"Export"})]})]})})};var eN=s(48736),eb=s(49322),ew=s(32489),eC=s(14438),eS=s(95937),ek=s(81853);let eT=e=>{var l,s,n,i,o,c;let{visible:d,onClose:u,selectedCollection:m,onImportComplete:h}=e,[x,f]=(0,a.useState)("csv"),[v,j]=(0,a.useState)([]),[N,b]=(0,a.useState)(void 0),[C,S]=(0,a.useState)(!1),k=(0,r.Ji)(),{mutate:T,isLoading:D}=(0,r.uC)(),{data:A}=(0,r.kS)(),{isMultiTenant:I}=(0,ek.PY)(),E=(null==A?void 0:null===(l=A.role)||void 0===l?void 0:l.name)==="administrator",{data:O,isLoading:F}=(0,r.sm)({resource:"baasix_Tenant",queryOptions:{enabled:I&&E}}),Z=(0,a.useCallback)(e=>{f(e),j([])},[]),z=(0,a.useCallback)(e=>("csv"===x?"text/csv"===e.type||e.name.toLowerCase().endsWith(".csv"):"application/json"===e.type||e.name.toLowerCase().endsWith(".json"))?e.size/1024/1024<50||(eC.Am.error("File must be smaller than 50MB"),!1):(eC.Am.error("Please upload a valid ".concat(x.toUpperCase()," file")),!1),[x]),M=(0,a.useCallback)(e=>{if(!e||0===e.length)return;let l=e[0];z(l)&&j([l])},[z]),P=(0,a.useCallback)(e=>{e.preventDefault(),S(!1),M(e.dataTransfer.files)},[M]),L=(0,a.useCallback)(e=>{e.preventDefault(),S(!0)},[]),B=(0,a.useCallback)(e=>{e.preventDefault(),S(!1)},[]),U=(0,a.useCallback)(()=>{if(0===v.length){eC.Am.error("Please select a file to import");return}let e=v[0],l=new FormData;"csv"===x?l.append("csvFile",e):l.append("jsonFile",e),I&&E&&N&&l.append("tenant",N);let s="csv"===x?"items/".concat(m,"/import-csv"):"items/".concat(m,"/import-json");T({url:"".concat(k,"/").concat(s),method:"post",values:l},{onSuccess:e=>{var l;eC.Am.success("Successfully imported ".concat((null==e?void 0:null===(l=e.results)||void 0===l?void 0:l.imported)||0," items")),h(),u(),j([])},onError:e=>{var l,s,t,a,n,r,i,o,c;console.error("Import error:",e);let d="Import failed";if((null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(s=t.data)||void 0===s?void 0:null===(l=s.error)||void 0===l?void 0:l.message)?d=e.response.data.error.message:(null==e?void 0:e.message)&&(d=e.message),(null==e?void 0:null===(c=e.response)||void 0===c?void 0:null===(o=c.data)||void 0===o?void 0:null===(i=o.error)||void 0===i?void 0:null===(r=i.details)||void 0===r?void 0:null===(n=r.results)||void 0===n?void 0:null===(a=n.errors)||void 0===a?void 0:a.length)>0){let l=e.response.data.error.details.results.errors.length;d+=". ".concat(l," rows had errors.")}eC.Am.error(d)}})},[v,x,m,h,u,k,T,E,I,N]),R=(0,a.useCallback)(()=>{j([])},[]),V=(0,a.useCallback)(()=>"csv"===x?{title:"CSV Example",content:'name,email,age,tags,metadata\n"John Doe","john@example.com",30,"[""admin"", ""user""]","{""department"": ""IT""}"\n"Jane Smith","jane@example.com",25,"[""user""]","{""department"": ""HR""}"',description:"CSV files should have headers in the first row. JSON fields should be properly escaped strings."}:{title:"JSON Example",content:'[\n {\n "name": "John Doe",\n "email": "john@example.com", \n "age": 30,\n "tags": ["admin", "user"],\n "metadata": {"department": "IT"}\n },\n {\n "name": "Jane Smith",\n "email": "jane@example.com",\n "age": 25, \n "tags": ["user"],\n "metadata": {"department": "HR"}\n }\n]',description:"JSON files should contain an array of objects. Each object represents a record to import."},[x])();return(0,t.jsx)(y.yo,{open:d,onOpenChange:e=>!e&&u(),children:(0,t.jsxs)(y.ue,{className:"w-[700px] sm:max-w-[700px] overflow-y-auto flex flex-col",side:"right",children:[(0,t.jsx)(y.Tu,{children:(0,t.jsx)(y.bC,{children:"Import Data"})}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto py-4 space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ev._,{className:"text-base font-semibold",children:"Select Import Format:"}),(0,t.jsx)(G.mQ,{value:x,onValueChange:Z,children:(0,t.jsxs)(G.dr,{className:"grid w-full grid-cols-2",children:[(0,t.jsxs)(G.SP,{value:"csv",className:"flex items-center gap-2",children:[(0,t.jsx)(eN.Z,{className:"h-4 w-4"}),"CSV File"]}),(0,t.jsxs)(G.SP,{value:"json",className:"flex items-center gap-2",children:[(0,t.jsx)(W.Z,{className:"h-4 w-4"}),"JSON File"]})]})})]}),I&&E&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ev._,{className:"text-base font-semibold",children:"Select Tenant (Optional):"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Leave empty to import into your current tenant context. Select a specific tenant to import data into that tenant."}),(0,t.jsxs)(w.Ph,{value:N||"",onValueChange:e=>b(e||void 0),children:[(0,t.jsx)(w.i4,{children:(0,t.jsx)(w.ki,{placeholder:F?"Loading...":"Select tenant (optional)"})}),(0,t.jsx)(w.Bw,{children:null==O?void 0:null===(s=O.data)||void 0===s?void 0:s.map(e=>(0,t.jsx)(w.Ql,{value:e.id,children:e.name},e.id))})]})]}),(0,t.jsxs)(eS.bZ,{children:[(0,t.jsx)(eb.Z,{className:"h-4 w-4"}),(0,t.jsx)(eS.Cd,{children:"Important Notes"}),(0,t.jsx)(eS.X,{children:(0,t.jsxs)("ul",{className:"list-disc list-inside mt-2 space-y-1 text-sm",children:[(0,t.jsx)("li",{children:"The import will create new records in the selected collection"}),(0,t.jsx)("li",{children:"If any record fails validation, the entire import will be rolled back"}),(0,t.jsx)("li",{children:"JSON fields should be properly formatted (arrays and objects)"}),(0,t.jsx)("li",{children:"Relational data can be created by providing nested objects"}),(0,t.jsx)("li",{children:"Maximum file size: 50MB"})]})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)(ev._,{className:"text-base font-semibold",children:["Upload ",x.toUpperCase()," File:"]}),0===v.length?(0,t.jsxs)("div",{className:"border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ".concat(C?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50"),onDrop:P,onDragOver:L,onDragLeave:B,onClick:()=>{let e=document.createElement("input");e.type="file",e.accept="csv"===x?".csv,text/csv":".json,application/json",e.onchange=e=>{M(e.target.files)},e.click()},children:[(0,t.jsx)(_.Z,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),(0,t.jsxs)("p",{className:"text-sm font-medium",children:["Click or drag ",x.toUpperCase()," file to this area to upload"]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground mt-1",children:["Support for single ",x.toUpperCase()," file upload"]})]}):(0,t.jsx)(g.Zb,{children:(0,t.jsxs)(g.aY,{className:"p-4 flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:["csv"===x?(0,t.jsx)(eN.Z,{className:"h-8 w-8 text-green-600"}):(0,t.jsx)(W.Z,{className:"h-8 w-8 text-blue-600"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-sm",children:v[0].name}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(v[0].size/1024/1024).toFixed(2)," MB"]})]})]}),(0,t.jsx)(p.z,{variant:"ghost",size:"icon",onClick:R,children:(0,t.jsx)(ew.Z,{className:"h-4 w-4"})})]})})]}),(0,t.jsx)(g.Zb,{children:(0,t.jsxs)(g.aY,{className:"p-4",children:[(0,t.jsx)("h4",{className:"font-semibold mb-2",children:V.title}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-3",children:V.description}),(0,t.jsx)("pre",{className:"bg-muted p-3 rounded text-xs overflow-x-auto max-h-[200px]",children:V.content})]})}),v.length>0&&(0,t.jsx)(g.Zb,{children:(0,t.jsxs)(g.aY,{className:"p-4",children:[(0,t.jsx)(ev._,{className:"text-base font-semibold",children:"Import Summary:"}),(0,t.jsxs)("div",{className:"mt-2 space-y-1 text-sm",children:[(0,t.jsxs)("p",{children:["• Collection: ",m]}),(0,t.jsxs)("p",{children:["• File: ",null===(n=v[0])||void 0===n?void 0:n.name]}),(0,t.jsxs)("p",{children:["• Size: ",((null===(i=v[0])||void 0===i?void 0:i.size)/1024/1024).toFixed(2)," MB"]}),(0,t.jsxs)("p",{children:["• Format: ",x.toUpperCase()]}),E&&(0,t.jsxs)("p",{children:["• Tenant:"," ",N?(null==O?void 0:null===(c=O.data)||void 0===c?void 0:null===(o=c.find(e=>e.id===N))||void 0===o?void 0:o.name)||N:"Current tenant context"]})]})]})})]}),(0,t.jsxs)(y.FF,{className:"pt-4 border-t",children:[(0,t.jsx)(p.z,{variant:"outline",onClick:u,children:"Cancel"}),(0,t.jsx)(p.z,{onClick:U,disabled:0===v.length||D,children:D?"Importing...":"Import Data"})]})]})})};var eD=s(45675),eA=s(29501),e_=s(33245),eI=s(30401),eE=s(71488);let eO=["id","createdAt","updatedAt","deletedAt","userCreated_Id","userUpdated_Id","userDeleted_Id","userCreated","userUpdated","userDeleted"],eF=e=>{let{visible:l,onClose:s,selectedRows:n,selectedCollection:i,onSuccess:o}=e,{getFieldsByCollection:c}=(0,d.I_)(),[u,m]=(0,a.useState)([]),[h,f]=(0,a.useState)(!1),{mutate:g}=(0,r.e)(),{register:v,handleSubmit:j,setValue:y,watch:b,reset:w,formState:{errors:S}}=(0,eA.cI)({defaultValues:{}}),k=(0,a.useMemo)(()=>{let e=c(i);return e?Object.entries(e).filter(e=>{var l,s;let[t,a]=e;return!eO.includes(t)&&!a.primaryKey&&(null===(l=a.defaultValue)||void 0===l?void 0:l.type)!=="AUTOINCREMENT"&&(null===(s=a.defaultValue)||void 0===s?void 0:s.type)!=="UUIDV4"&&!a.virtual&&!a.relType}).map(e=>{let[l,s]=e;return{name:l,...s}}):[]},[i,c]);(0,a.useEffect)(()=>{l||(m([]),w({}))},[l,w]);let T=(e,l)=>{l?m(l=>[...l,e]):(m(l=>l.filter(l=>l!==e)),y(e,void 0))},D=async e=>{if(0===u.length){eC.Am.error("Please select at least one field to update");return}f(!0);let l=n.map(e=>e.id),t={};for(let l of u)void 0!==e[l]&&(t[l]=e[l]);if(0===Object.keys(t).length){eC.Am.error("Please provide values for the selected fields"),f(!1);return}try{await new Promise((e,s)=>{g({resource:i,ids:l,values:t},{onSuccess:()=>e(),onError:e=>s(e)})}),eC.Am.success("".concat(n.length," items updated successfully")),o(),s()}catch(e){console.error("Bulk update error:",e),eC.Am.error((null==e?void 0:e.message)||"Failed to update items")}finally{f(!1)}},A=e=>{var l,s;let a=e.name,n=b(a),r=(null===(l=e.type)||void 0===l?void 0:l.toLowerCase())||"string",i=!u.includes(a);if("enum"===r){let l=e.values||[];return(0,t.jsx)(x.o_,{value:n,onChange:e=>y(a,e),options:l,allowNull:!1!==e.allowNull,disabled:i,placeholder:"Select ".concat(e.name,"...")})}return"boolean"===r?(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(el.r,{checked:n||!1,onCheckedChange:e=>y(a,e),disabled:i}),(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:n?"True":"False"})]}):["integer","bigint","float","decimal","double","real"].includes(r)?(0,t.jsx)(ee.I,{type:"number",...v(a,{valueAsNumber:!0}),disabled:i,placeholder:"Enter ".concat(e.name,"..."),step:["float","decimal","double","real"].includes(r)?"0.01":"1"}):["json","jsonb"].includes(r)?(0,t.jsx)(x.mq,{value:n,onChange:e=>y(a,e),disabled:i}):"array"===r?(0,t.jsx)(x.OF,{value:n||[],onChange:e=>y(a,e),itemType:(null===(s=e.values)||void 0===s?void 0:s.type)||"String",disabled:i}):"text"===r?(0,t.jsx)(H.g,{...v(a),disabled:i,placeholder:"Enter ".concat(e.name,"..."),rows:3}):["date","datetime"].includes(r)?(0,t.jsx)(ee.I,{type:"date"===r?"date":"datetime-local",...v(a),disabled:i}):(0,t.jsx)(ee.I,{...v(a),disabled:i,placeholder:"Enter ".concat(e.name,"...")})};return(0,t.jsx)(N.Vq,{open:l,onOpenChange:e=>!e&&s(),children:(0,t.jsxs)(N.cZ,{className:"sm:max-w-[600px] max-h-[80vh]",children:[(0,t.jsxs)(N.fK,{children:[(0,t.jsx)(N.$N,{children:"Bulk Edit"}),(0,t.jsxs)(N.Be,{children:["Update ",n.length," selected items. Only the fields you select and fill in will be updated."]})]}),(0,t.jsxs)("form",{onSubmit:j(D),children:[(0,t.jsx)(X.x,{className:"h-[400px] pr-4",children:(0,t.jsxs)("div",{className:"space-y-4 py-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg",children:[(0,t.jsx)(e_.Z,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"Select the fields you want to update by checking the checkbox next to each field."})]}),0===k.length?(0,t.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:"No editable fields found for this collection."}):k.map(e=>(0,t.jsx)("div",{className:"p-3 border rounded-lg transition-colors ".concat(u.includes(e.name)?"border-primary bg-primary/5":"border-border"),children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(C.X,{id:"field-".concat(e.name),checked:u.includes(e.name),onCheckedChange:l=>T(e.name,l),className:"mt-1"}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ev._,{htmlFor:"field-".concat(e.name),className:"font-medium cursor-pointer",children:e.name}),(0,t.jsx)(eE.pn,{children:(0,t.jsxs)(eE.u,{children:[(0,t.jsx)(eE.aJ,{asChild:!0,children:(0,t.jsxs)("span",{className:"text-xs px-2 py-0.5 bg-muted rounded text-muted-foreground",children:[e.type,e.relType&&" (".concat(e.relType,")")]})}),(0,t.jsxs)(eE._v,{children:[(0,t.jsxs)("p",{children:["Field type: ",e.type]}),e.relType&&(0,t.jsxs)("p",{children:["Relation: ",e.relType]}),!1===e.allowNull&&(0,t.jsx)("p",{children:"Required field"})]})]})})]}),(0,t.jsx)("div",{className:u.includes(e.name)?"":"opacity-50",children:A(e)})]})]})},e.name))]})}),(0,t.jsx)(N.cN,{className:"mt-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,t.jsxs)("span",{className:"text-sm text-muted-foreground",children:[u.length," field(s) selected"]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(p.z,{type:"button",variant:"outline",onClick:s,disabled:h,children:"Cancel"}),(0,t.jsx)(p.z,{type:"submit",disabled:h||0===u.length,children:h?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(z.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Updating..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eI.Z,{className:"mr-2 h-4 w-4"}),"Update ",n.length," Items"]})})]})]})})]})]})})},eZ=e=>{let{visible:l,onClose:s,selectedRows:n,selectedCollection:i,onClearSelection:o,customActions:c}=e,[d,u]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!1),[x,f]=(0,a.useState)(!1),{mutate:g}=(0,r.F2)();(0,a.useEffect)(()=>{l||(u(!1),h(!1),f(!1))},[l]);let v=async()=>{f(!0);let e=n.length,l=n.map(e=>e.id);try{await new Promise((e,s)=>{g({resource:i,ids:l},{onSuccess:()=>e(),onError:e=>s(e)})}),eC.Am.success("".concat(e," items deleted successfully")),f(!1),u(!1),o(),s()}catch(e){console.error("Bulk delete error:",e),eC.Am.error((null==e?void 0:e.message)||"Failed to delete items"),f(!1)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(N.Vq,{open:l,onOpenChange:e=>!e&&s(),children:(0,t.jsxs)(N.cZ,{className:"sm:max-w-[500px]",children:[(0,t.jsxs)(N.fK,{children:[(0,t.jsx)(N.$N,{children:"Bulk Actions"}),(0,t.jsxs)(N.Be,{children:[n.length," items selected. Choose an action to perform on all selected items."]})]}),(0,t.jsxs)("div",{className:"space-y-3 py-4",children:[(0,t.jsxs)(p.z,{variant:"destructive",className:"w-full justify-start gap-2",onClick:()=>u(!0),children:[(0,t.jsx)(L.Z,{className:"h-4 w-4"}),"Delete Selected (",n.length,")"]}),(0,t.jsxs)(p.z,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{h(!0)},children:[(0,t.jsx)(eD.Z,{className:"h-4 w-4"}),"Edit Selected (",n.length,")"]}),null==c?void 0:c.map((e,l)=>(0,t.jsxs)(p.z,{variant:e.variant||"outline",className:"w-full justify-start gap-2",onClick:()=>e.onClick(n),disabled:e.disabled,children:[e.icon,e.label," (",n.length,")"]},l))]}),(0,t.jsx)(N.cN,{children:(0,t.jsx)(p.z,{variant:"outline",onClick:s,children:"Cancel"})})]})}),(0,t.jsx)(N.Vq,{open:d,onOpenChange:e=>{x||e||u(!1)},children:(0,t.jsxs)(N.cZ,{children:[(0,t.jsxs)(N.fK,{children:[(0,t.jsx)(N.$N,{children:"Delete Selected Items"}),(0,t.jsxs)(N.Be,{children:["Are you sure you want to delete ",n.length," items? This action cannot be undone."]})]}),(0,t.jsxs)(N.cN,{children:[(0,t.jsx)(p.z,{type:"button",variant:"outline",onClick:()=>u(!1),disabled:x,children:"Cancel"}),(0,t.jsx)(p.z,{type:"button",variant:"destructive",onClick:v,disabled:x,children:x?"Deleting...":"Delete"})]})]})}),(0,t.jsx)(eF,{visible:m,onClose:()=>h(!1),selectedRows:n,selectedCollection:i,onSuccess:()=>{o(),s()}})]})},ez=e=>{let{nodes:l,selectedColumns:s,onSelectionChange:a,level:n=0,expandedNodes:r,onToggleExpand:i}=e,o=e=>{if(!e.disabled){if(s.includes(e.value)){let l=e.value+".";a(s.filter(s=>s!==e.value&&!s.startsWith(l)))}else a([...s,e.value])}},c=e=>e.children&&0!==e.children.length?e.children.flatMap(c):e.disabled?[]:[e.value],d=e=>{let l=e.split(".");return l[l.length-1].replace(/_/g," ").replace(/([A-Z])/g," $1").trim()};return(0,t.jsx)("div",{className:"space-y-0.5 ".concat(n>0?"ml-4 pl-2 border-l border-muted":""),children:l.map(e=>{let l=e.children&&e.children.length>0,c=r.has(e.key),u=s.includes(e.value),m=e.value+".",h=l&&s.some(e=>e.startsWith(m)),x=l&&h&&!u;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 py-1 hover:bg-muted/50 rounded px-1",children:[l&&(0,t.jsx)("button",{type:"button",onClick:()=>i(e.key),className:"p-0.5 hover:bg-muted rounded",children:c?(0,t.jsx)(V.Z,{className:"h-3.5 w-3.5"}):(0,t.jsx)(U.Z,{className:"h-3.5 w-3.5"})}),!l&&(0,t.jsx)("span",{className:"w-4"}),(0,t.jsx)(C.X,{id:"col-".concat(e.key),checked:u,disabled:e.disabled,onCheckedChange:()=>o(e),className:(0,en.cn)(x&&"data-[state=unchecked]:bg-primary/30")}),(0,t.jsxs)(ev._,{htmlFor:"col-".concat(e.key),className:(0,en.cn)("text-sm cursor-pointer flex-1",e.disabled&&"text-muted-foreground"),children:[d(e.title),l&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:"(relation)"})]})]}),l&&c&&(0,t.jsx)(ez,{nodes:e.children,selectedColumns:s,onSelectionChange:a,level:n+1,expandedNodes:r,onToggleExpand:i})]},e.key)})})},eM=e=>{let{visible:l,onClose:s,tableDensity:n,onTableDensityChange:r,visibleColumns:i,onVisibleColumnsChange:o,columnTreeData:c}=e,[d,u]=(0,a.useState)(new Set),[m,h]=(0,a.useState)("tree");return(0,t.jsx)(N.Vq,{open:l,onOpenChange:e=>!e&&s(),children:(0,t.jsxs)(N.cZ,{className:"sm:max-w-[500px] max-h-[80vh] flex flex-col",children:[(0,t.jsxs)(N.fK,{children:[(0,t.jsx)(N.$N,{children:"Column Settings"}),(0,t.jsx)(N.Be,{children:"Customize your table display preferences."})]}),(0,t.jsxs)("div",{className:"space-y-6 py-4 flex-1 overflow-y-auto",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ev._,{className:"text-sm font-semibold",children:"Table Density"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(p.z,{size:"sm",variant:"small"===n?"default":"outline",onClick:()=>r("small"),className:(0,en.cn)("small"===n&&"bg-primary text-primary-foreground"),children:"Compact"}),(0,t.jsx)(p.z,{size:"default",variant:"middle"===n?"default":"outline",onClick:()=>r("middle"),className:(0,en.cn)("middle"===n&&"bg-primary text-primary-foreground"),children:"Default"}),(0,t.jsx)(p.z,{size:"lg",variant:"large"===n?"default":"outline",onClick:()=>r("large"),className:(0,en.cn)("large"===n&&"bg-primary text-primary-foreground"),children:"Comfortable"})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ev._,{className:"text-sm font-semibold",children:"Visible Columns"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select columns to display. Expand relational fields to access nested columns."}),(0,t.jsxs)(G.mQ,{value:m,onValueChange:e=>h(e),children:[(0,t.jsxs)(G.dr,{className:"grid w-full grid-cols-2",children:[(0,t.jsx)(G.SP,{value:"tree",children:"Tree Selection"}),(0,t.jsx)(G.SP,{value:"json",children:"JSON"})]}),(0,t.jsx)(G.nU,{value:"tree",className:"mt-2",children:(0,t.jsx)(g.Zb,{className:"max-h-[250px] overflow-y-auto",children:(0,t.jsx)(g.aY,{className:"p-3",children:c.length>0?(0,t.jsx)(ez,{nodes:c,selectedColumns:i,onSelectionChange:o,expandedNodes:d,onToggleExpand:e=>{u(l=>{let s=new Set(l);return s.has(e)?s.delete(e):s.add(e),s})}}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No columns available"})})})}),(0,t.jsxs)(G.nU,{value:"json",className:"mt-2",children:[(0,t.jsx)(x.mq,{value:i,onChange:e=>{Array.isArray(e)&&e.every(e=>"string"==typeof e)?o(e):null===e&&o([])},placeholder:'["id", "name", "user.email"]'}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Enter column names as a JSON array. Use dot notation for nested fields."})]})]})]})]}),(0,t.jsx)(N.cN,{children:(0,t.jsx)(p.z,{variant:"outline",onClick:s,children:"Close"})})]})})};var eP=s(92322),eL=s(2596),eB=s(24156);let eU=e=>{let{value:l,field:s,onSave:n,onCancel:r,isLoading:i=!1}=e,[o,c]=(0,a.useState)(l),[d,u]=(0,a.useState)(""),m=(0,a.useRef)(null),h=(0,a.useRef)(null),x=(0,a.useRef)(l);(0,a.useEffect)(()=>{m.current&&(m.current.focus(),m.current.select())},[]);let f=(0,a.useCallback)(e=>null===x.current||void 0===x.current?null!=e&&""!==e:null==e||""===e?null!==x.current&&void 0!==x.current&&""!==x.current:String(x.current)!==String(e),[]),g=(0,a.useCallback)(e=>{f(e)?n(e):r()},[f,n,r]),v=(0,a.useCallback)(e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key?(e.preventDefault(),r()):"Tab"===e.key&&(e.preventDefault(),g(o)):(e.preventDefault(),g(o))},[o,g,r]),j=(0,a.useCallback)(e=>{var l;null!==(l=h.current)&&void 0!==l&&l.contains(e.relatedTarget)||g(o)},[o,g]);if("Boolean"===s.type||"BOOLEAN"===s.type)return(0,t.jsx)("div",{ref:h,className:"flex items-center justify-center h-full",onKeyDown:v,tabIndex:0,onBlur:j,children:i?(0,t.jsx)(z.Z,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(C.X,{checked:!!o,onCheckedChange:e=>{c(e),!!x.current!=!!e?n(e):r()},autoFocus:!0})});if(("Enum"===s.type||"ENUM"===s.type)&&s.values&&s.values.length>0){let e=s.values||[],l=d.trim()?e.filter(e=>e.toLowerCase().includes(d.toLowerCase())):e,a=d.trim()&&!e.some(e=>e.toLowerCase()===d.trim().toLowerCase()),m=e=>{c(e),u(""),String(x.current||"")!==String(e||"")?n(e):r()},f=()=>{if(d.trim()){let e=d.trim();c(e),u(""),String(x.current||"")!==String(e||"")?n(e):r()}};return(0,t.jsx)("div",{ref:h,className:"w-full",onKeyDown:v,children:i?(0,t.jsx)("div",{className:"flex items-center justify-center h-8",children:(0,t.jsx)(z.Z,{className:"h-4 w-4 animate-spin"})}):(0,t.jsxs)(Y.J2,{open:!0,onOpenChange:e=>!e&&r(),children:[(0,t.jsx)(Y.xo,{asChild:!0,children:(0,t.jsxs)(p.z,{variant:"outline",role:"combobox",className:"h-8 w-full justify-between text-sm font-normal",children:[o||"Select...",(0,t.jsx)(eB.Z,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,t.jsx)(Y.yk,{className:"w-[200px] p-0",align:"start",children:(0,t.jsxs)(eL.mY,{shouldFilter:!1,children:[(0,t.jsx)(eL.sZ,{placeholder:"Search or type custom...",value:d,onValueChange:u}),(0,t.jsxs)(eL.e8,{children:[(0,t.jsx)(eL.rb,{children:d.trim()?(0,t.jsxs)("button",{onClick:f,className:"flex w-full items-center gap-2 px-2 py-1.5 text-sm hover:bg-accent rounded cursor-pointer",children:[(0,t.jsx)(I.Z,{className:"h-4 w-4"}),'Add "',d.trim(),'"']}):"No options found."}),(0,t.jsxs)(eL.fu,{children:[s.allowNull&&(0,t.jsxs)(eL.di,{value:"",onSelect:()=>m(""),children:[(0,t.jsx)(eI.Z,{className:(0,en.cn)("mr-2 h-4 w-4",o?"opacity-0":"opacity-100")}),(0,t.jsx)("span",{className:"text-muted-foreground italic",children:"None"})]}),l.map(e=>(0,t.jsxs)(eL.di,{value:e,onSelect:()=>m(e),children:[(0,t.jsx)(eI.Z,{className:(0,en.cn)("mr-2 h-4 w-4",o===e?"opacity-100":"opacity-0")}),e]},e))]}),a&&l.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eL.zz,{}),(0,t.jsx)(eL.fu,{children:(0,t.jsxs)(eL.di,{value:"add-custom-".concat(d),onSelect:f,children:[(0,t.jsx)(I.Z,{className:"mr-2 h-4 w-4"}),'Add "',d.trim(),'"']})})]})]})]})})]})})}return"Number"===s.type||"Integer"===s.type||"INTEGER"===s.type||"INT"===s.type||"BigInt"===s.type||"BIGINT"===s.type||"SMALLINT"===s.type||"TINYINT"===s.type||"Float"===s.type||"FLOAT"===s.type||"Double"===s.type||"DOUBLE"===s.type||"Decimal"===s.type||"DECIMAL"===s.type?(0,t.jsxs)("div",{ref:h,className:"relative w-full",children:[i&&(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10",children:(0,t.jsx)(z.Z,{className:"h-4 w-4 animate-spin"})}),(0,t.jsx)(ee.I,{ref:m,type:"number",value:null!=o?o:"",onChange:e=>{let l=e.target.value;c(""===l?null:Number(l))},onKeyDown:v,onBlur:j,className:"h-8 text-sm",disabled:i})]}):"Date"===s.type||"DATEONLY"===s.type?(0,t.jsxs)("div",{ref:h,className:"relative w-full",children:[i&&(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10",children:(0,t.jsx)(z.Z,{className:"h-4 w-4 animate-spin"})}),(0,t.jsx)(ee.I,{ref:m,type:"date",value:(e=>{if(!e)return"";let l=new Date(e),s=l.getFullYear(),t=String(l.getMonth()+1).padStart(2,"0"),a=String(l.getDate()).padStart(2,"0");return"".concat(s,"-").concat(t,"-").concat(a)})(o),onChange:e=>c(e.target.value||null),onKeyDown:v,onBlur:j,className:"h-8 text-sm",disabled:i})]}):"DateTime"===s.type||"DateTime_NO_TZ"===s.type||"DATETIME"===s.type||"TIMESTAMP"===s.type?(0,t.jsxs)("div",{ref:h,className:"relative w-full",children:[i&&(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10",children:(0,t.jsx)(z.Z,{className:"h-4 w-4 animate-spin"})}),(0,t.jsx)(ee.I,{ref:m,type:"datetime-local",value:(e=>{if(!e)return"";let l=new Date(e),s=l.getFullYear(),t=String(l.getMonth()+1).padStart(2,"0"),a=String(l.getDate()).padStart(2,"0"),n=String(l.getHours()).padStart(2,"0"),r=String(l.getMinutes()).padStart(2,"0");return"".concat(s,"-").concat(t,"-").concat(a,"T").concat(n,":").concat(r)})(o),onChange:e=>{c(e.target.value?new Date(e.target.value).toISOString():null)},onKeyDown:v,onBlur:j,className:"h-8 text-sm",disabled:i})]}):"Time"===s.type||"Time_NO_TZ"===s.type?(0,t.jsxs)("div",{ref:h,className:"relative w-full",children:[i&&(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10",children:(0,t.jsx)(z.Z,{className:"h-4 w-4 animate-spin"})}),(0,t.jsx)(ee.I,{ref:m,type:"time",value:(e=>{if(!e)return"";if("string"==typeof e){let l=e.match(/^(\d{2}):(\d{2})/);if(l)return"".concat(l[1],":").concat(l[2]);if(e.includes("T")){let l=new Date(e),s=String(l.getHours()).padStart(2,"0"),t=String(l.getMinutes()).padStart(2,"0");return"".concat(s,":").concat(t)}}return e})(o),onChange:e=>c(e.target.value||null),onKeyDown:v,onBlur:j,className:"h-8 text-sm",disabled:i})]}):(0,t.jsxs)("div",{ref:h,className:"relative w-full",children:[i&&(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10",children:(0,t.jsx)(z.Z,{className:"h-4 w-4 animate-spin"})}),(0,t.jsx)(ee.I,{ref:m,type:"text",value:null!=o?o:"",onChange:e=>c(e.target.value||null),onKeyDown:v,onBlur:j,className:"h-8 text-sm",disabled:i})]})},eR=["String","VARCHAR","CHAR","Number","Integer","INTEGER","INT","BigInt","BIGINT","SMALLINT","TINYINT","Float","FLOAT","Double","DOUBLE","Decimal","DECIMAL","Boolean","BOOLEAN","Date","Date_NO_TZ","DATEONLY","DateTime","DateTime_NO_TZ","DATETIME","TIMESTAMP","Time","Time_NO_TZ","Enum","ENUM","Email","URL","Phone"],eV=e=>!e.relType&&!e.primaryKey&&!["createdAt","updatedAt","deletedAt","userCreated","userUpdated","userDeleted","userCreated_Id","userUpdated_Id","userDeleted_Id"].includes(e.name)&&eR.includes(e.type);var eJ=s(59892);let eq=e=>{let{id:l,children:s,className:a,onClick:n,disabled:r=!1}=e,{attributes:i,listeners:c,setNodeRef:d,transform:u,transition:m,isDragging:h}=(0,o.nB)({id:l,disabled:r}),x={transform:eJ.ux.Transform.toString(u),transition:m,opacity:h?.5:1,zIndex:h?1e3:void 0};return r?(0,t.jsx)(v.SC,{className:a,onClick:n,children:s}):(0,t.jsxs)(v.SC,{ref:d,style:x,className:(0,en.cn)(a,h&&"bg-muted shadow-lg"),onClick:n,children:[(0,t.jsx)(v.pj,{className:"w-8 px-2 cursor-grab active:cursor-grabbing",...i,...c,onClick:e=>e.stopPropagation(),children:(0,t.jsx)(E.Z,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})}),s]})};var eK=s(83724);let eW=e=>{let l=e.replace(/\./g," → ").replace(/_/g," ").replace(/([A-Z])/g," $1").trim();return l.charAt(0).toUpperCase()+l.slice(1)},eG=e=>{let{selectedCollection:l,schemaName:s,title:n,hideTitle:V=!1,enableSearch:J=!0,enableFilters:q=!0,enableCreate:K=!0,enableView:W=!1,enableEdit:G=!0,enableDelete:H=!0,enableExport:Y=!0,enableImport:X=!0,enableBulkSelect:Q=!0,enableColumnSettings:$=!0,enableFilePreview:ee=!1,enableInlineEdit:el=!0,headerActions:es,renderRowActions:et,quickFilters:ea,customColumnRenderers:er,defaultVisibleColumns:ei,getDisabledFields:eo,defaultMeta:ec,defaultFilters:ed,permanentFilters:eu,defaultSorters:em,onRecordClick:eh,onRefresh:ex,showSelectionColumn:ep=!1,selectionMode:ef="single",externalSelectedRows:ev,onExternalSelectionChange:ej,highlightSelectedRows:eN=!1,customBulkActions:eb}=e,[ew,eS]=(0,a.useState)(""),[ek,eD]=(0,a.useState)(!1),[eA,e_]=(0,a.useState)(!1),[eI,eE]=(0,a.useState)(!1),[eO,eF]=(0,a.useState)(!1),[ez,eL]=(0,a.useState)(!1),[eB,eR]=(0,a.useState)(null),[eJ,eG]=(0,a.useState)(1),[eH,eY]=(0,a.useState)(10),[eX,eQ]=(0,a.useState)([]),[e$,e0]=(0,a.useState)(ed||[]),e1=(0,a.useCallback)(()=>em&&em.length>0?em:[],[em]),[e2,e4]=(0,a.useState)(e1()),[e5,e3]=(0,a.useState)(!1),[e8,e7]=(0,a.useState)(null),[e6,e9]=(0,a.useState)(""),[le,ll]=(0,a.useState)(""),[ls,lt]=(0,a.useState)(!1),[la,ln]=(0,a.useState)(!1),[lr,li]=(0,a.useState)(!1),[lo,lc]=(0,a.useState)(!1),[ld,lu]=(0,a.useState)([]),[lm,lh]=(0,a.useState)(-1),[lx,lp]=(0,a.useState)(1),[lf,lg]=(0,a.useState)(!1),[lv,lj]=(0,a.useState)("middle"),[ly,lN]=(0,a.useState)(null),[lb,lw]=(0,a.useState)(null),[lC,lS]=(0,a.useState)({}),[lk,lT]=(0,a.useState)(null),[lD,lA]=(0,a.useState)(0),[l_,lI]=(0,a.useState)(0),[lE,lO]=(0,a.useState)(null),[lF,lZ]=(0,a.useState)(!1),lz=(0,r.Ji)(),lM=localStorage.getItem("token"),{getFieldsByCollection:lP,getNestedFields:lL,isSortEnabled:lB}=(0,d.I_)(),lU=lB(l),[lR,lV]=(0,a.useState)(!1),{getColumnPreferences:lJ,saveColumnPreferences:lq,getFilterPreferences:lK,saveFilterPreferences:lW,isInitialized:lG}=(0,u.Gn)(),lH=(0,a.useMemo)(()=>lP(l),[l,lP]),lY=(0,a.useMemo)(()=>{if(!l||!lH)return[];if(ei&&ei.length>0){let e=lJ(l);return e&&e.visibleColumns&&e.visibleColumns.length>0?e.visibleColumns:ei}let e=lJ(l);if(e&&e.visibleColumns&&e.visibleColumns.length>0)return e.visibleColumns;let s=["userCreated_Id","userCreated","userUpdated_Id","userUpdated","userDeleted","userDeleted_Id","createdAt","updatedAt","deletedAt"];return Object.keys(lH).filter(e=>{let l=lH[e];return!s.includes(e)&&!l.relType}).slice(0,5)},[l,lH,lJ,ei]);(0,a.useEffect)(()=>{if(l&&lG){let e=lJ(l);(null==e?void 0:e.columnWidths)?lS(e.columnWidths):lS({})}},[l,lG,lJ]),(0,a.useEffect)(()=>{if(l&&lG&&!ed){let e=lK(l);(null==e?void 0:e.filters)?e0(e.filters):e0([])}},[l,lG,ed]),(0,a.useEffect)(()=>{!lU||(null==em?void 0:em.length)||0!==e2.length||e4([{field:"sort",order:"asc"}])},[lU,em,e2.length]);let lX=(0,a.useMemo)(()=>{if(!lH||!l)return["*"];let e=["id"];return lY.forEach(l=>{if("id"!==l){if(l.includes("."))e.push(l);else{let s=lH[l];s&&(s.relType&&s.showAs?e.push(l+".*"):e.push(l))}}}),e.length>0?e:["*"]},[lH,l,lY]),lQ=(0,a.useMemo)(()=>ew?[{field:"search",operator:"contains",value:ew}]:[],[ew]),l$=(0,a.useMemo)(()=>[...eu||[],...e$,...lQ],[eu,e$,lQ]),l0=!!l&&lX.length>0&&lG,{data:l1,isLoading:l2,refetch:l4}=(0,r.sm)({resource:l,meta:{fields:lX,...ec},queryOptions:{enabled:l0},pagination:{current:eJ,pageSize:eH,mode:"server"},filters:l$,sorters:e2}),l5=(0,a.useCallback)(()=>{l4(),null==ex||ex()},[l4,ex]),l3=(null==l1?void 0:l1.data)||[],l8=(null==l1?void 0:l1.total)||0,l7=Math.ceil(l8/eH),{mutate:l6,isLoading:l9}=(0,r.R2)(),{mutate:se,isLoading:sl}=(0,r.RO)(),{mutate:ss,isLoading:st}=(0,r.PQ)(),sa=null==eB?void 0:eB.id,sn=(0,a.useMemo)(()=>{if(!lH)return["*"];let e=["*"];return Object.entries(lH).forEach(l=>{let[s,t]=l;t.relType&&e.push("".concat(s,".*"))}),e},[lH]),{data:sr,isLoading:si,isFetching:so}=(0,r.rD)({resource:l,id:sa||"",queryOptions:{enabled:!!(sa&&(eI||eO))},meta:{fields:sn}}),sc=null==sr?void 0:sr.data,sd=(0,a.useMemo)(()=>Object.entries(lH||{}).map(e=>{let[l,s]=e;return{name:l,...s,label:l.replace(/_/g," ").replace(/([A-Z])/g," $1").trim()}}),[lH]),su=(0,a.useCallback)((e,l)=>{if(!e)return"-";if("string"==typeof e||"number"==typeof e)return String(e);if(l.showAs&&Array.isArray(l.showAs)){let s=["-"," ",",","_"," and "," or "],t=[];l.showAs.forEach(l=>{if(s.includes(l))t.push(l);else{let s;if(l.includes(".")){let t=l.split("."),a=e;for(let e of t)if(null==(a=null==a?void 0:a[e]))break;s=a}else s=e[l];null!=s&&""!==s&&t.push(String(s))}});let a=t.filter((e,l)=>{let a=s.includes(e),n=l>0&&s.includes(t[l-1]),r=l===t.length-1;return!a||0!==l&&!r&&!n});if(a.length>0)return a.join("")}return e.name||e.title||e.label||e.email||e.id||JSON.stringify(e)},[]);(0,a.useMemo)(()=>lH?Object.keys(lH):[],[lH]);let sm=(0,a.useMemo)(()=>lH?lL(l):[],[lH,l,lL]);(0,a.useEffect)(()=>{l&&lH&&lu(Object.keys(lH).filter(e=>!["userCreated_Id","userCreated","userUpdated_Id","userUpdated","userDeleted","userDeleted_Id","createdAt","updatedAt","deletedAt"].includes(e)))},[l,lH]);let sh=(0,r.x5)(),sx=(0,a.useCallback)((e,l,s)=>{let t=new Blob([[l.map(e=>e.includes(",")||e.includes('"')||e.includes("\n")?'"'.concat(e.replace(/"/g,'""'),'"'):e).join(","),...e.map(e=>l.map(l=>{let s=e;for(let e of l.split("."))s=null==s?void 0:s[e];if(null==s)return"";if("object"==typeof s){let e=JSON.stringify(s);return'"'.concat(e.replace(/"/g,'""'),'"')}return"string"==typeof s&&(s.includes(",")||s.includes('"')||s.includes("\n"))?'"'.concat(s.replace(/"/g,'""'),'"'):s}).join(","))].join("\n")],{type:"text/csv;charset=utf-8;"}),a=document.createElement("a"),n=URL.createObjectURL(t);a.setAttribute("href",n),a.setAttribute("download","".concat(s,"_export_").concat(new Date().toISOString().split("T")[0],".csv")),a.style.visibility="hidden",document.body.appendChild(a),a.click(),document.body.removeChild(a)},[]),sp=(0,a.useCallback)(async()=>{lg(!0);try{let e={resource:l,meta:{fields:ld},filters:l$,dataProviderName:void 0};-1!==lm&&lm>0&&(e.pagination={current:lx,pageSize:lm,mode:"server"});let{data:s}=await sh().getList(e);sx(s,ld,l),lt(!1),eC.Am.success("Export completed successfully")}catch(e){console.error("Export error:",e),eC.Am.error("Export failed")}finally{lg(!1)}},[ld,lm,lx,l,l$,sh,sx]),sf=(0,a.useCallback)(()=>{l5()},[l5]),sg=(0,a.useMemo)(()=>new Set(["JSON","JSONB","VIRTUAL","Array_Integer","Array_String","Array_Double","Array_Decimal","Array_UUID","Array_Date","Array_DateTime","Array_Boolean","Point","Polygon","LineString"]),[]),sv=(0,a.useCallback)((e,l)=>!e||!sg.has(e)&&(null==l?void 0:l.relType)!=="M2A"&&(null==l||!l.alias),[sg]),sj=(0,a.useMemo)(()=>lH?lY.map(e=>{if(e.includes(".")){let[l,...s]=e.split("."),t=lH[l];if(t&&t.relType){let l="BelongsTo"===t.relType||"HasOne"===t.relType||"M2O"===t.relType||"O2O"===t.relType;return{key:e,title:eW(e),field:{name:e,type:"String",relType:null,isNested:!0},sortable:l,isNested:!0}}return null}let l=lH[e];if(!l)return null;let s=!("HasMany"===l.relType||"BelongsToMany"===l.relType)&&sv(l.type,l);return{key:e,title:eW(e),field:{name:e,type:l.type||"String",relType:l.relType,showAs:Array.isArray(l.showAs)?l.showAs:l.showAs?[l.showAs]:void 0,displayFormat:l.displayFormat,displayOptions:l.displayOptions,values:l.values,allowNull:l.allowNull},sortable:s,isNested:!1}}).filter(Boolean):[],[lH,lY,sv]),sy=(0,a.useCallback)(e=>{e4(l=>{let s=l.find(l=>l.field===e);return s?"asc"===s.order?[{field:e,order:"desc"}]:[]:[{field:e,order:"asc"}]})},[]),sN=(0,i.Dy)((0,i.VT)(i.we,{activationConstraint:{distance:8}}),(0,i.VT)(i.Lg,{coordinateGetter:o.is})),sb=(0,a.useCallback)(async e=>{let{active:s,over:t}=e;if(lV(!1),!t||s.id===t.id)return;let a=String(s.id),n=String(t.id),r=l3.findIndex(e=>String(e.id)===a),i=l3.findIndex(e=>String(e.id)===n);if(-1!==r&&-1!==i)try{let e=(0,m.fO)(h.G);await e(l,a,n,r<i?"after":"before"),eC.Am.success("Order updated successfully"),l5()}catch(e){eC.Am.error((null==e?void 0:e.message)||"Failed to update order")}},[l,l5,l3]),sw=(0,a.useCallback)(()=>{lV(!0)},[]),sC=(0,a.useCallback)(e=>{let l=e2.find(l=>l.field===e);return(null==l?void 0:l.order)||null},[e2]),sS=(0,a.useCallback)(async e=>{e0(e),await lW(l,{filters:e,sorters:[]}),eG(1)},[l,lW]);(0,a.useCallback)(async(e,s)=>{let t=s?[...lY,e]:lY.filter(l=>l!==e);await lq(l,{visibleColumns:t,tableDensity:lv,columnWidths:lC})},[l,lY,lq,lv,lC]);let sk=(0,a.useCallback)(async e=>{await lq(l,{visibleColumns:e,tableDensity:lv,columnWidths:lC})},[l,lq,lv,lC]),sT=(0,a.useCallback)(async e=>{lj(e),await lq(l,{visibleColumns:lY,tableDensity:e,columnWidths:lC})},[l,lY,lq,lC]),sD=(0,a.useCallback)((e,l)=>{lN(l),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",l);let s=e.currentTarget;setTimeout(()=>{s.style.opacity="0.5"},0)},[]),sA=(0,a.useCallback)(e=>{e.currentTarget.style.opacity="1",lN(null),lw(null)},[]),s_=(0,a.useCallback)((e,l)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",ly&&l!==ly&&lw(l)},[ly]),sI=(0,a.useCallback)(()=>{lw(null)},[]),sE=(0,a.useCallback)(async(e,s)=>{if(e.preventDefault(),!ly||ly===s){lN(null),lw(null);return}let t=[...lY],a=t.indexOf(ly),n=t.indexOf(s);-1!==a&&-1!==n&&(t.splice(a,1),t.splice(n,0,ly),await lq(l,{visibleColumns:t,tableDensity:lv,columnWidths:lC})),lN(null),lw(null)},[ly,lY,l,lq,lv,lC]),sO=(0,a.useCallback)((e,l)=>{e.preventDefault(),e.stopPropagation(),lT(l),lA(e.clientX),lI(lC[l]||150)},[lC]),sF=(0,a.useCallback)(e=>{if(!lk)return;let l=Math.max(80,l_+(e.clientX-lD));lS(e=>({...e,[lk]:l}))},[lk,lD,l_]),sZ=(0,a.useCallback)(async()=>{lk&&(await lq(l,{visibleColumns:lY,tableDensity:lv,columnWidths:lC}),lT(null))},[lk,l,lY,lv,lC,lq]);(0,a.useEffect)(()=>(lk&&(document.addEventListener("mousemove",sF),document.addEventListener("mouseup",sZ),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",sF),document.removeEventListener("mouseup",sZ),document.body.style.cursor="",document.body.style.userSelect=""}),[lk,sF,sZ]);let sz=(0,a.useCallback)(()=>{eB&&l6({resource:l,id:eB.id},{onSuccess:()=>{eC.Am.success("Record deleted successfully"),eL(!1),eR(null),l5()},onError:e=>{eC.Am.error("Failed to delete record"),console.error(e)}})},[eB,l,l6,l5]),sM=(0,a.useCallback)(e=>{se({resource:l,values:e},{onSuccess:()=>{eC.Am.success("Record created successfully"),e_(!1),l5()},onError:e=>{eC.Am.error("Failed to create record"),console.error(e)}})},[l,se,l5]),sP=(0,a.useCallback)(e=>{eB&&ss({resource:l,id:eB.id,values:e},{onSuccess:()=>{eC.Am.success("Record updated successfully"),eF(!1),eR(null),l5()},onError:e=>{eC.Am.error("Failed to update record"),console.error(e)}})},[eB,l,ss,l5]),sL=(0,a.useCallback)(async(e,s,t)=>(lZ(!0),new Promise((a,n)=>{ss({resource:l,id:e,values:{[s]:t}},{onSuccess:()=>{eC.Am.success("Field updated"),lO(null),lZ(!1),l5(),a()},onError:e=>{eC.Am.error("Failed to update field"),console.error(e),lZ(!1),n(e)}})})),[l,ss,l5]),sB=(0,a.useCallback)(()=>{lO(null)},[]),sU=(0,a.useCallback)(()=>{eX.length===l3.length?eQ([]):eQ(l3.map(e=>e.id))},[eX,l3]),sR=(0,a.useCallback)(e=>{eQ(l=>l.includes(e)?l.filter(l=>l!==e):[...l,e])},[]);return l?(0,t.jsxs)("div",{className:"flex flex-col h-full gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[!V&&(0,t.jsx)("h1",{className:"text-lg font-semibold",children:n||s||l}),(0,t.jsxs)("div",{className:(0,en.cn)("flex items-center gap-2 flex-wrap",V&&"flex-1 justify-end"),children:[ea,J&&(0,t.jsx)(f.t,{value:ew,onChange:eS,placeholder:"Search...",expandedWidth:"w-64"}),q&&(0,t.jsxs)(p.z,{variant:e$.length>0?"default":"outline",size:"icon",onClick:()=>eD(!0),title:"Filters",className:"relative",children:[(0,t.jsx)(S.Z,{className:"h-4 w-4"}),e$.length>0&&(0,t.jsx)(j.C,{variant:"secondary",className:"absolute -top-1 -right-1 h-4 w-4 p-0 flex items-center justify-center text-xs",children:e$.length})]}),$&&(0,t.jsx)(p.z,{variant:"outline",size:"icon",onClick:()=>lc(!0),title:"Settings",children:(0,t.jsx)(k.Z,{className:"h-4 w-4"})}),(0,t.jsx)(p.z,{variant:"outline",size:"icon",onClick:()=>l5(),title:"Refresh",children:(0,t.jsx)(T.Z,{className:"h-4 w-4"})}),(Y||X)&&(0,t.jsxs)(b.h_,{children:[(0,t.jsx)(b.$F,{asChild:!0,children:(0,t.jsx)(p.z,{variant:"outline",size:"icon",title:"More",children:(0,t.jsx)(D.Z,{className:"h-4 w-4"})})}),(0,t.jsxs)(b.AW,{align:"end",children:[(0,t.jsx)(b.Ju,{children:"Data Actions"}),(0,t.jsx)(b.VD,{}),Y&&(0,t.jsxs)(b.Xi,{onClick:()=>lt(!0),children:[(0,t.jsx)(A.Z,{className:"mr-2 h-4 w-4"}),"Export"]}),X&&(0,t.jsxs)(b.Xi,{onClick:()=>ln(!0),children:[(0,t.jsx)(_.Z,{className:"mr-2 h-4 w-4"}),"Import"]})]})]}),es,K&&(0,t.jsx)(p.z,{size:"icon",onClick:()=>e_(!0),title:"Create",children:(0,t.jsx)(I.Z,{className:"h-4 w-4"})})]})]}),Q&&eX.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-2 p-2 bg-muted rounded-md",children:[(0,t.jsxs)("span",{className:"text-sm font-medium",children:[eX.length," row(s) selected"]}),(0,t.jsx)(p.z,{variant:"outline",size:"sm",onClick:()=>li(!0),children:"Bulk Actions"}),(0,t.jsx)(p.z,{variant:"outline",size:"sm",onClick:()=>eQ([]),children:"Clear"})]}),(0,t.jsxs)(g.Zb,{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,t.jsx)("div",{className:"flex-1 overflow-auto relative",children:(0,t.jsxs)("table",{className:"w-full caption-bottom text-sm min-w-max",children:[(0,t.jsx)("thead",{className:"sticky top-0 z-10 bg-background",children:(0,t.jsxs)(v.SC,{className:"border-b",children:[lU&&(0,t.jsx)(v.ss,{className:"w-8 px-2",children:(0,t.jsx)(E.Z,{className:"h-4 w-4 text-muted-foreground"})}),ep&&(0,t.jsx)(v.ss,{className:"w-12 sticky left-0 bg-background z-20",children:"multiple"===ef?"Select":""}),Q&&(0,t.jsx)(v.ss,{className:"w-12 sticky left-0 bg-background z-20",children:(0,t.jsx)(C.X,{checked:l3.length>0&&eX.length===l3.length,onCheckedChange:sU})}),sj.map(e=>{let l=sC(e.key),s=ly===e.key,a=lb===e.key,n=lC[e.key];return(0,t.jsxs)(v.ss,{draggable:!0,onDragStart:l=>sD(l,e.key),onDragEnd:sA,onDragOver:l=>s_(l,e.key),onDragLeave:sI,onDrop:l=>sE(l,e.key),style:{width:n?"".concat(n,"px"):void 0,minWidth:n?"".concat(n,"px"):void 0},className:(0,en.cn)("whitespace-nowrap cursor-grab active:cursor-grabbing relative group/header",e.sortable&&"cursor-pointer select-none",s&&"opacity-50",a&&"border-l-2 border-l-primary"),onClick:()=>e.sortable&&sy(e.key),children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 pr-2",children:[(0,t.jsx)(E.Z,{className:"h-4 w-4 text-muted-foreground opacity-40 hover:opacity-100 cursor-grab flex-shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.title}),e.sortable&&(0,t.jsx)("span",{className:"ml-1 flex-shrink-0",children:"asc"===l?(0,t.jsx)(O.Z,{className:"h-4 w-4"}):"desc"===l?(0,t.jsx)(F.Z,{className:"h-4 w-4"}):(0,t.jsx)(Z.Z,{className:"h-4 w-4 text-muted-foreground"})})]}),(0,t.jsx)("div",{className:(0,en.cn)("absolute right-0 top-0 bottom-0 w-[3px] cursor-col-resize","border-r border-border hover:border-primary hover:bg-primary/20",lk===e.key&&"border-primary bg-primary/30"),onMouseDown:l=>sO(l,e.key),onClick:e=>e.stopPropagation()})]},e.key)}),(et||W||G||H)&&(0,t.jsx)(v.ss,{className:"w-24",children:"Actions"})]})}),(0,t.jsx)(i.LB,{sensors:sN,collisionDetection:i.pE,onDragStart:sw,onDragEnd:sb,modifiers:[c.DL],children:(0,t.jsx)(o.Fo,{items:l3.map(e=>e.id),strategy:o.qw,disabled:!lU,children:(0,t.jsx)("tbody",{className:(0,en.cn)("[&_tr:last-child]:border-0","small"===lv&&"[&_tr]:h-8 [&_td]:py-1 [&_td]:text-xs","middle"===lv&&"[&_tr]:h-12 [&_td]:py-2 [&_td]:text-sm","large"===lv&&"[&_tr]:h-16 [&_td]:py-4"),children:l2?(0,t.jsx)(v.SC,{children:(0,t.jsx)(v.pj,{colSpan:sj.length+(lU?1:0)+(ep?1:0)+(Q?1:0)+(et||W||G||H?1:0),className:"h-48 text-center",children:(0,t.jsx)(z.Z,{className:"h-8 w-8 animate-spin mx-auto"})})}):0===l3.length?(0,t.jsx)(v.SC,{children:(0,t.jsx)(v.pj,{colSpan:sj.length+(lU?1:0)+(ep?1:0)+(Q?1:0)+(et||W||G||H?1:0),className:"h-48 text-center text-muted-foreground",children:"No data available"})}):l3.map((e,l)=>{let s=null==ev?void 0:ev.some(l=>l.id===e.id);return(0,t.jsxs)(eq,{id:e.id,disabled:!lU,className:(0,en.cn)(eh&&"cursor-pointer hover:bg-muted/50",eN&&s&&"bg-primary/10 hover:bg-primary/15"),onClick:()=>null==eh?void 0:eh(e),children:[ep&&(0,t.jsx)(v.pj,{onClick:e=>e.stopPropagation(),className:"sticky left-0 bg-background z-10",children:"multiple"===ef?(0,t.jsx)(C.X,{checked:s||!1,onCheckedChange:l=>{l?null==ej||ej([...ev||[],e]):null==ej||ej((ev||[]).filter(l=>l.id!==e.id))}}):(0,t.jsx)("input",{type:"radio",name:"external-selection",checked:s||!1,onChange:()=>{null==ej||ej([e])},className:"h-4 w-4 text-primary border-border focus:ring-primary"})}),Q&&(0,t.jsx)(v.pj,{onClick:e=>e.stopPropagation(),children:(0,t.jsx)(C.X,{checked:eX.includes(e.id),onCheckedChange:()=>sR(e.id)})}),sj.map(l=>{let s=e;if(l.isNested){for(let e of l.key.split(".")){if(null==s)break;if(Array.isArray(s)){if(0===(s=s.map(l=>null==l?void 0:l[e]).filter(e=>null!=e)).length){s=null;break}}else s=null==s?void 0:s[e]}Array.isArray(s)&&(s=s.join(", "))}else s=e[l.key];if(er&&er[l.key]){let a=lC[l.key];return(0,t.jsx)(v.pj,{style:{width:a?"".concat(a,"px"):void 0,maxWidth:a?"".concat(a,"px"):void 0},className:a?"overflow-hidden":"",children:(0,t.jsx)("div",{className:a?"truncate":"",children:er[l.key](s,e,l.field)})},l.key)}let a=lC[l.key],n=l.isNested&&null!=s&&"object"==typeof s?null:s,r=(null==lE?void 0:lE.recordId)===e.id&&(null==lE?void 0:lE.columnKey)===l.key,i=el&&!l.isNested&&l.field&&eV(l.field);return(0,t.jsx)(v.pj,{style:{width:a?"".concat(a,"px"):void 0,maxWidth:a?"".concat(a,"px"):void 0},className:(0,en.cn)(a?"overflow-hidden":"",i&&!r&&"cursor-cell"),onDoubleClick:s=>{i&&!r&&(s.stopPropagation(),lO({recordId:e.id,columnKey:l.key}))},children:r?(0,t.jsx)(eU,{value:s,field:l.field,onSave:s=>sL(e.id,l.key,s),onCancel:sB,isLoading:lF}):(0,t.jsx)("div",{className:a?"truncate":"",children:l.isNested?(0,t.jsx)("span",{className:"text-sm",children:null!=n?String(n):"-"}):(0,t.jsx)(x.Zl,{field:l.field,value:s,readOnly:!0,size:"small"})})},l.key)}),(et||W||G||H)&&(0,t.jsx)(v.pj,{onClick:e=>e.stopPropagation(),children:et?et({record:e,onView:()=>{eR(e),eE(!0)},onEdit:()=>{eR(e),eF(!0)},onDelete:()=>{eR(e),eL(!0)}}):(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[W&&(0,t.jsx)(p.z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{eR(e),eE(!0)},children:(0,t.jsx)(M.Z,{className:"h-4 w-4"})}),G&&(0,t.jsx)(p.z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{eR(e),eF(!0)},children:(0,t.jsx)(P.Z,{className:"h-4 w-4"})}),H&&(0,t.jsx)(p.z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{eR(e),eL(!0)},children:(0,t.jsx)(L.Z,{className:"h-4 w-4"})})]})})]},e.id||l)})})})})]})}),(0,t.jsxs)("div",{className:"flex items-center justify-between border-t px-3 py-2 gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground hidden sm:block",children:["Showing ",(eJ-1)*eH+1," to"," ",Math.min(eJ*eH,l8)," of ",l8," ","records"]}),(0,t.jsxs)(w.Ph,{value:eH.toString(),onValueChange:e=>{eY(Number(e)),eG(1)},children:[(0,t.jsx)(w.i4,{className:"w-[70px] sm:w-[100px]",children:(0,t.jsx)(w.ki,{})}),(0,t.jsxs)(w.Bw,{children:[(0,t.jsxs)(w.Ql,{value:"10",children:[(0,t.jsx)("span",{className:"sm:hidden",children:"10"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"10 / page"})]}),(0,t.jsxs)(w.Ql,{value:"25",children:[(0,t.jsx)("span",{className:"sm:hidden",children:"25"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"25 / page"})]}),(0,t.jsxs)(w.Ql,{value:"50",children:[(0,t.jsx)("span",{className:"sm:hidden",children:"50"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"50 / page"})]}),(0,t.jsxs)(w.Ql,{value:"100",children:[(0,t.jsx)("span",{className:"sm:hidden",children:"100"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"100 / page"})]})]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 sm:gap-2",children:[(0,t.jsxs)(p.z,{variant:"outline",size:"sm",onClick:()=>eG(e=>Math.max(1,e-1)),disabled:1===eJ,children:[(0,t.jsx)(B.Z,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Previous"})]}),(0,t.jsxs)("span",{className:"text-sm whitespace-nowrap",children:[(0,t.jsxs)("span",{className:"sm:hidden",children:[eJ,"/",l7||1]}),(0,t.jsxs)("span",{className:"hidden sm:inline",children:["Page ",eJ," of ",l7||1]})]}),(0,t.jsxs)(p.z,{variant:"outline",size:"sm",onClick:()=>eG(e=>Math.min(l7,e+1)),disabled:eJ>=l7,children:[(0,t.jsx)("span",{className:"hidden sm:inline",children:"Next"}),(0,t.jsx)(U.Z,{className:"h-4 w-4"})]})]})]})]}),q&&(0,t.jsx)(eg,{visible:ek,onClose:()=>eD(!1),formFields:sd,onApply:sS,initialFilters:e$,collectionName:l}),K&&(0,t.jsx)(y.yo,{open:eA,onOpenChange:e_,children:(0,t.jsxs)(y.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,t.jsx)(y.Tu,{children:(0,t.jsx)(y.bC,{children:"Create New Record"})}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(eP.j,{fields:sd,onSubmit:sM,isLoading:sl,onCancel:()=>e_(!1)})})]})}),W&&(0,t.jsx)(y.yo,{open:eI,onOpenChange:e=>{eE(e),e||eR(null)},children:(0,t.jsxs)(y.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,t.jsx)(y.Tu,{children:(0,t.jsx)(y.bC,{children:"View Record"})}),(0,t.jsx)("div",{className:"mt-4 space-y-4",children:si||so?(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(z.Z,{className:"h-8 w-8 animate-spin"})}):sc?(()=>{let e,l;let s=sd.filter(e=>e.relType&&e.foreignKey).map(e=>e.foreignKey),a=ee&&sc.type&&sc.id?(0,t.jsxs)("div",{className:"mb-4 space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-muted-foreground",children:"Preview"}),(0,t.jsx)("div",{className:"p-3 bg-muted/50 rounded-md flex items-center justify-center",children:(null==(e=sc.type)?void 0:e.startsWith("image/"))?(0,t.jsx)("img",{src:"".concat(lz,"/assets/").concat(sc.id,"?access_token=").concat(lM),alt:sc.title||"Image preview",className:"max-w-full max-h-64 object-contain rounded",onError:e=>{e.target.style.display="none"}}):(null==(l=sc.type)?void 0:l.startsWith("video/"))?(0,t.jsx)("video",{src:"".concat(lz,"/assets/").concat(sc.id,"?access_token=").concat(lM),controls:!0,className:"max-w-full max-h-64 rounded"}):(0,t.jsx)("div",{className:"text-center text-muted-foreground py-4",children:(0,t.jsx)("span",{className:"text-sm",children:"No preview available for this file type"})})})]}):null,n=sd.filter(e=>!s.includes(e.name)).map(e=>{var l,s;let a=sc[e.name],n=e=>!e||"object"==typeof e&&(null===e.id||void 0===e.id);return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-muted-foreground capitalize",children:e.label||e.name.replace(/_/g," ")}),["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon"].includes(e.type)&&a&&(0,t.jsxs)(p.z,{variant:"ghost",size:"sm",className:"h-6 text-xs gap-1",onClick:()=>{e7(a),e9(e.label||e.name),ll(e.type),e3(!0)},children:[(0,t.jsx)(R.Z,{className:"h-3 w-3"}),"View in Map"]})]}),(0,t.jsx)("div",{className:"p-3 bg-muted/50 rounded-md min-h-[40px]",children:(null==er?void 0:er[e.name])?er[e.name](a,sc,e):e.relType?(()=>{if(!a||n(a))return(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"-"});if(Array.isArray(a)){let l=a.filter(e=>!n(e));return 0===l.length?(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"-"}):(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:l.map((l,s)=>(0,t.jsx)(j.C,{variant:"secondary",className:"text-xs",children:su(l,e)},(null==l?void 0:l.id)||s))})}return"object"==typeof a?(0,t.jsx)(j.C,{variant:"secondary",className:"text-xs",children:su(a,e)}):(0,t.jsx)("span",{className:"text-sm",children:String(a)})})():null!=a?["DateTime","DateTime_NO_TZ","DATETIME","TIMESTAMP"].includes(e.type)?(0,t.jsxs)("span",{className:"text-sm",children:[new Date(a).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),(0,t.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",Intl.DateTimeFormat().resolvedOptions().timeZone,")"]})]}):"Date"===e.type?(0,t.jsx)("span",{className:"text-sm",children:new Date(a).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}):["Time","Time_NO_TZ"].includes(e.type)?(0,t.jsx)("span",{className:"text-sm",children:a}):["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon"].includes(e.type)?(0,t.jsx)("pre",{className:"text-sm whitespace-pre-wrap break-all max-h-24 overflow-auto",children:JSON.stringify(a,null,2)}):(null===(l=e.type)||void 0===l?void 0:l.startsWith("Array_"))?(0,t.jsxs)("div",{className:"flex flex-wrap gap-1",children:[Array.isArray(a)&&a.length>0?a.slice(0,10).map((l,s)=>{let a=String(l);if(e.type.includes("Date")||e.type.includes("DateTime")){let s=new Date(l);a=e.type.includes("DateTime")?s.toLocaleString():s.toLocaleDateString()}else e.type.includes("Boolean")&&(a=l?"true":"false");return(0,t.jsx)(j.C,{variant:"secondary",className:"text-xs",children:a},s)}):(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"Empty array"}),Array.isArray(a)&&a.length>10&&(0,t.jsxs)(j.C,{variant:"outline",className:"text-xs",children:["+",a.length-10," more"]})]}):(null===(s=e.type)||void 0===s?void 0:s.startsWith("Range_"))?(()=>{var l,s;if(!a||"object"!=typeof a)return(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"-"});let n=!1!==a.lowerInclusive?"[":"(",r=!1!==a.upperInclusive?"]":")",i=String(null!==(l=a.lower)&&void 0!==l?l:""),o=String(null!==(s=a.upper)&&void 0!==s?s:"");if(e.type.includes("Date")||e.type.includes("DateTime")){if(a.lower){let l=new Date(a.lower);i=e.type.includes("DateTime")?l.toLocaleString():l.toLocaleDateString()}if(a.upper){let l=new Date(a.upper);o=e.type.includes("DateTime")?l.toLocaleString():l.toLocaleDateString()}}return(0,t.jsxs)(j.C,{variant:"secondary",className:"font-mono text-xs",children:[n,i," – ",o,r]})})():"object"==typeof a?(0,t.jsx)("pre",{className:"text-sm whitespace-pre-wrap break-all",children:JSON.stringify(a,null,2)}):(0,t.jsx)("span",{className:"text-sm",children:String(a)}):(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"-"})})]},e.name)});return(0,t.jsxs)(t.Fragment,{children:[a,n]})})():(0,t.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:"No data available"})})]})}),G&&(0,t.jsx)(y.yo,{open:eO,onOpenChange:e=>{eF(e),e||eR(null)},children:(0,t.jsxs)(y.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,t.jsx)(y.Tu,{children:(0,t.jsx)(y.bC,{children:"Edit Record"})}),(0,t.jsx)("div",{className:"mt-4",children:si||so?(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(z.Z,{className:"h-8 w-8 animate-spin"})}):sc?(0,t.jsx)(eP.j,{fields:sd,initialValues:sc,onSubmit:sP,isLoading:st,disabledFields:(null==eo?void 0:eo(sc))||[],onCancel:()=>{eF(!1),eR(null)}}):(0,t.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:"No data available"})})]})}),H&&(0,t.jsx)(N.Vq,{open:ez,onOpenChange:eL,children:(0,t.jsxs)(N.cZ,{children:[(0,t.jsxs)(N.fK,{children:[(0,t.jsx)(N.$N,{children:"Delete Record"}),(0,t.jsx)(N.Be,{children:"Are you sure you want to delete this record? This action cannot be undone."})]}),(0,t.jsxs)(N.cN,{children:[(0,t.jsx)(p.z,{variant:"outline",onClick:()=>{eL(!1),eR(null)},children:"Cancel"}),(0,t.jsxs)(p.z,{variant:"destructive",onClick:sz,disabled:l9,children:[l9&&(0,t.jsx)(z.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete"]})]})]})}),Y&&(0,t.jsx)(ey,{visible:ls,onClose:()=>lt(!1),exportColumns:ld,onExportColumnsChange:lu,exportLimit:lm,onExportLimitChange:lh,exportPage:lx,onExportPageChange:lp,isExporting:lf,onExport:sp,columnTreeData:sm}),X&&(0,t.jsx)(eT,{visible:la,onClose:()=>ln(!1),selectedCollection:l,onImportComplete:sf}),Q&&(0,t.jsx)(eZ,{visible:lr,onClose:()=>li(!1),selectedRows:l3.filter(e=>eX.includes(e.id)),selectedCollection:l,onClearSelection:()=>{eQ([]),l5()},customActions:eb}),$&&(0,t.jsx)(eM,{visible:lo,onClose:()=>lc(!1),tableDensity:lv,onTableDensityChange:sT,visibleColumns:lY,onVisibleColumnsChange:sk,columnTreeData:sm}),(0,t.jsx)(eK.Z,{open:e5,onOpenChange:e3,value:e8,fieldName:e6,fieldType:le})]}):(0,t.jsx)(g.Zb,{children:(0,t.jsxs)(g.aY,{className:"p-8 text-center",children:[(0,t.jsx)("h3",{className:"text-lg font-medium",children:"Please select a collection"}),(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:"Choose a collection from the sidebar to view and manage its data."})]})})},eH=()=>{let e=(0,n.useSearchParams)(),l=e.get("collection")||"",s=e.get("schema")||"",{isLoading:a}=(0,d.I_)(),{isInitialized:r,isLoading:i}=(0,u.Gn)();return a||i||!r?(0,t.jsx)(g.Zb,{children:(0,t.jsxs)(g.aY,{className:"p-8 text-center",children:[(0,t.jsx)(z.Z,{className:"h-8 w-8 animate-spin mx-auto"}),(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}):(0,t.jsx)(eG,{selectedCollection:l,schemaName:s,enableView:!0},l)};var eY=eH},32060:function(e,l,s){s.d(l,{$F:function(){return u},AW:function(){return m},Ju:function(){return x},VD:function(){return p},Xi:function(){return h},h_:function(){return d}});var t=s(57437),a=s(2265),n=s(28119),r=s(10407),i=s(30401),o=s(40519),c=s(93448);let d=n.fC,u=n.xz;n.ZA,n.Uv,n.Tr,n.Ee,a.forwardRef((e,l)=>{let{className:s,inset:a,children:i,...o}=e;return(0,t.jsxs)(n.fF,{ref:l,className:(0,c.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",s),...o,children:[i,(0,t.jsx)(r.Z,{className:"ml-auto h-4 w-4"})]})}).displayName=n.fF.displayName,a.forwardRef((e,l)=>{let{className:s,...a}=e;return(0,t.jsx)(n.tu,{ref:l,className:(0,c.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a})}).displayName=n.tu.displayName;let m=a.forwardRef((e,l)=>{let{className:s,sideOffset:a=4,...r}=e;return(0,t.jsx)(n.Uv,{children:(0,t.jsx)(n.VY,{ref:l,sideOffset:a,className:(0,c.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...r})})});m.displayName=n.VY.displayName;let h=a.forwardRef((e,l)=>{let{className:s,inset:a,...r}=e;return(0,t.jsx)(n.ck,{ref:l,className:(0,c.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",s),...r})});h.displayName=n.ck.displayName,a.forwardRef((e,l)=>{let{className:s,children:a,checked:r,...o}=e;return(0,t.jsxs)(n.oC,{ref:l,className:(0,c.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:r,...o,children:[(0,t.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,t.jsx)(n.wU,{children:(0,t.jsx)(i.Z,{className:"h-4 w-4"})})}),a]})}).displayName=n.oC.displayName,a.forwardRef((e,l)=>{let{className:s,children:a,...r}=e;return(0,t.jsxs)(n.Rk,{ref:l,className:(0,c.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...r,children:[(0,t.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,t.jsx)(n.wU,{children:(0,t.jsx)(o.Z,{className:"h-2 w-2 fill-current"})})}),a]})}).displayName=n.Rk.displayName;let x=a.forwardRef((e,l)=>{let{className:s,inset:a,...r}=e;return(0,t.jsx)(n.__,{ref:l,className:(0,c.cn)("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",s),...r})});x.displayName=n.__.displayName;let p=a.forwardRef((e,l)=>{let{className:s,...a}=e;return(0,t.jsx)(n.Z0,{ref:l,className:(0,c.cn)("-mx-1 my-1 h-px bg-muted",s),...a})});p.displayName=n.Z0.displayName},17168:function(e,l,s){s.d(l,{SP:function(){return c},dr:function(){return o},mQ:function(){return i},nU:function(){return d}});var t=s(57437),a=s(2265),n=s(20271),r=s(93448);let i=n.fC,o=a.forwardRef((e,l)=>{let{className:s,...a}=e;return(0,t.jsx)(n.aV,{ref:l,className:(0,r.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",s),...a})});o.displayName=n.aV.displayName;let c=a.forwardRef((e,l)=>{let{className:s,...a}=e;return(0,t.jsx)(n.xz,{ref:l,className:(0,r.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",s),...a})});c.displayName=n.xz.displayName;let d=a.forwardRef((e,l)=>{let{className:s,...a}=e;return(0,t.jsx)(n.VY,{ref:l,className:(0,r.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...a})});d.displayName=n.VY.displayName},63751:function(e,l,s){s.d(l,{CE:function(){return c},Gn:function(){return o}});var t=s(57437),a=s(2265),n=s(72135),r=s(14438);let i=(0,a.createContext)(void 0),o=()=>{let e=(0,a.useContext)(i);if(!e)throw Error("usePreferences must be used within a PreferencesProvider");return e};function c(e){var l;let{children:s}=e,[o,c]=(0,a.useState)([]),[d,u]=(0,a.useState)(!1),{data:m}=(0,n.kS)(),h=(null==m?void 0:m.id)||(null==m?void 0:null===(l=m.user)||void 0===l?void 0:l.id)||null,{data:x,isLoading:p,refetch:f}=(0,n.sm)({resource:"baasix_UserPreference",queryOptions:{enabled:!!h},filters:h?[{field:"userId",operator:"eq",value:h}]:[],pagination:{pageSize:-1,mode:"off"}}),{mutate:g}=(0,n.RO)({resource:"baasix_UserPreference"}),{mutate:v}=(0,n.PQ)({resource:"baasix_UserPreference"});(0,a.useEffect)(()=>{(null==x?void 0:x.data)?(c(x.data),u(!0)):h&&!p&&(c([]),u(!0))},[x,h,p]);let j=(0,a.useMemo)(()=>{let e={};return o.forEach(l=>{l.isDefault&&(e[l.collectionName]||(e[l.collectionName]={}),e[l.collectionName][l.preferenceType]=l)}),e},[o]),y=(0,a.useCallback)((e,l)=>{var s;return(null===(s=j[e])||void 0===s?void 0:s[l])||null},[j]),N=(0,a.useCallback)(async(e,l,s)=>{if(!h){console.warn("No user ID available for saving preferences");return}let t=y(e,l),a={userId:h,collectionName:e,preferenceType:l,preferenceData:s,isDefault:!0};try{(null==t?void 0:t.id)?await new Promise((e,l)=>{v({id:t.id,values:a,successNotification:!1},{onSuccess:()=>{f(),e()},onError:e=>{console.error("Error updating preference:",e),l(e)}})}):await new Promise((e,l)=>{g({values:a,successNotification:!1},{onSuccess:()=>{f(),e()},onError:e=>{console.error("Error creating preference:",e),l(e)}})})}catch(e){throw r.Am.error("Failed to save preferences"),e}},[h,y,g,v,f]),b=(0,a.useCallback)(e=>{var l;let s=null===(l=j[e])||void 0===l?void 0:l.columns;return s?s.preferenceData:null},[j]),w=(0,a.useCallback)(async(e,l)=>{await N(e,"columns",l)},[N]),C=(0,a.useCallback)(e=>{var l;let s=null===(l=j[e])||void 0===l?void 0:l.filters;return s?s.preferenceData:null},[j]),S=(0,a.useCallback)(async(e,l)=>{await N(e,"filters",l)},[N]),k=(0,a.useCallback)(e=>{var l;let s=null===(l=j[e])||void 0===l?void 0:l.sorting;return s?s.preferenceData:null},[j]),T=(0,a.useCallback)(async(e,l)=>{await N(e,"sorting",l)},[N]),D=(0,a.useCallback)(e=>{var l;let s=null===(l=j[e])||void 0===l?void 0:l.pagination;return s?s.preferenceData:null},[j]),A=(0,a.useCallback)(async(e,l)=>{await N(e,"pagination",l)},[N]);return(0,t.jsx)(i.Provider,{value:{getColumnPreferences:b,saveColumnPreferences:w,getFilterPreferences:C,saveFilterPreferences:S,getSortingPreferences:k,saveSortingPreferences:T,getPaginationPreferences:D,savePaginationPreferences:A,isLoading:p,isInitialized:d,refetchPreferences:f},children:s})}}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7214],{79205:function(e,s,a){a.d(s,{Z:function(){return d}});var l=a(2265);let n=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),r=function(){for(var e=arguments.length,s=Array(e),a=0;a<e;a++)s[a]=arguments[a];return s.filter((e,s,a)=>!!e&&a.indexOf(e)===s).join(" ")};var t={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,l.forwardRef)((e,s)=>{let{color:a="currentColor",size:n=24,strokeWidth:i=2,absoluteStrokeWidth:d,className:c="",children:o,iconNode:u,...h}=e;return(0,l.createElement)("svg",{ref:s,...t,width:n,height:n,stroke:a,strokeWidth:d?24*Number(i)/Number(n):i,className:r("lucide",c),...h},[...u.map(e=>{let[s,a]=e;return(0,l.createElement)(s,a)}),...Array.isArray(o)?o:[o]])}),d=(e,s)=>{let a=(0,l.forwardRef)((a,t)=>{let{className:d,...c}=a;return(0,l.createElement)(i,{ref:t,iconNode:s,className:r("lucide-".concat(n(e)),d),...c})});return a.displayName="".concat(e),a}},54001:function(e,s,a){a.d(s,{Z:function(){return l}});let l=(0,a(79205).Z)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},51817:function(e,s,a){a.d(s,{Z:function(){return l}});let l=(0,a(79205).Z)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},29090:function(e,s,a){a.d(s,{Z:function(){return l}});let l=(0,a(79205).Z)("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]])},88906:function(e,s,a){a.d(s,{Z:function(){return l}});let l=(0,a(79205).Z)("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},65422:function(e,s,a){a.d(s,{t:function(){return P}});var l=a(57437),n=a(2265),r=a(72135),t=a(72337),i=a(74291),d=a(12381),c=a(40279),o=a(75060),u=a(32060),h=a(15291),x=a(12749),m=a(2596),p=a(69174),j=a(67782),v=a(42208),f=a(15868),g=a(29090),N=a(54001),C=a(88906);let w=(0,a(79205).Z)("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);var y=a(40875),k=a(30401),S=a(32489),b=a(14438),I=a(81853),A=a(93448),Z=a(99246);function P(e){let{excludeColumns:s=[]}=e,{isMultiTenant:a}=(0,I.PY)(),[P,_]=(0,n.useState)("all"),[z,L]=(0,n.useState)("all"),[q,E]=(0,n.useState)("all"),[R,V]=(0,n.useState)(""),M=(0,Z.N)(R,300),[O,T]=(0,n.useState)(!1),[B,Q]=(0,n.useState)(null),[F,U]=(0,n.useState)(!1),[$,K]=(0,n.useState)(!1),[X,Y]=(0,n.useState)(!1),[D,W]=(0,n.useState)(!1),[H,J]=(0,n.useState)(""),[G,ee]=(0,n.useState)(""),[es,ea]=(0,n.useState)([]),[el,en]=(0,n.useState)(""),[er,et]=(0,n.useState)(null),[ei,ed]=(0,n.useState)(!1),[ec,eo]=(0,n.useState)(""),[eu,eh]=(0,n.useState)(""),ex=(0,Z.N)(ec,300),{mutate:em}=(0,r.PQ)(),{mutate:ep}=(0,r.uC)(),{data:ej}=(0,r.sm)({resource:"baasix_Role",pagination:{mode:"off"}}),ev=(null==ej?void 0:ej.data)||[],{data:ef,isLoading:eg}=(0,r.sm)({resource:"baasix_Tenant",pagination:{current:1,pageSize:20},filters:M?[{field:"name",operator:"contains",value:M}]:[],queryOptions:{enabled:a}}),eN=(null==ef?void 0:ef.data)||[],{data:eC,isLoading:ew}=(0,r.sm)({resource:"baasix_Tenant",pagination:{current:1,pageSize:20},filters:ex?[{field:"name",operator:"contains",value:ex}]:[],queryOptions:{enabled:a&&ei}}),ey=(null==eC?void 0:eC.data)||[],{data:ek,isLoading:eS,refetch:eb}=(0,r.sm)({resource:"baasix_UserRole",filters:B?[{field:"user_Id",operator:"eq",value:B.id}]:[],pagination:{mode:"off"},queryOptions:{enabled:!!B&&$}}),{data:eI,isLoading:eA}=(0,r.sm)({resource:"baasix_Account",filters:B?[{field:"user_Id",operator:"eq",value:B.id}]:[],pagination:{mode:"off"},queryOptions:{enabled:!!B&&D}}),eZ=(null==eI?void 0:eI.data)||[];(0,n.useEffect)(()=>{(null==ek?void 0:ek.data)&&$&&ea(ek.data.map(e=>({roleId:e.role_Id,tenantId:e.tenant_Id||void 0})).filter(e=>e.roleId))},[ek,$]);let eP=(0,n.useMemo)(()=>{let e=[];return"all"!==P&&e.push({field:"status",operator:"eq",value:P}),"all"!==z&&e.push({field:"userRoles.role_Id",operator:"eq",value:z}),"all"!==q&&e.push({field:"userRoles.tenant_Id",operator:"eq",value:q}),e},[P,z,q]),e_=(0,n.useMemo)(()=>{if("all"===q)return"All Tenants";let e=eN.find(e=>e.id===q);return(null==e?void 0:e.name)||q},[q,eN]),ez=(0,n.useCallback)(e=>{Q(e),J(""),ee(""),U(!0)},[]),eL=(0,n.useCallback)(e=>{Q(e),ea([]),K(!0)},[]),eq=(0,n.useCallback)(e=>{Q(e),W(!0)},[]),eE=(0,n.useCallback)(e=>{Q(e),en(e.status||"active"),Y(!0)},[]),eR=e=>{let s=ev.find(s=>s.id===e);s&&(s.isTenantSpecific&&a?(et({roleId:e,roleName:s.name}),eo(""),ed(!0)):(es.find(s=>s.roleId===e)||ea([...es,{roleId:e}]),eh("")))},eV=e=>{er&&(es.find(s=>s.roleId===er.roleId&&s.tenantId===e)||ea([...es,{roleId:er.roleId,tenantId:e}]),ed(!1),et(null),eh(""))},eM=(e,s)=>{ea(es.filter(a=>!(a.roleId===e&&a.tenantId===s)))},eO=e=>{let s=ev.find(s=>s.id===e);return(null==s?void 0:s.name)||e},eT=e=>{let s=[...eN,...ey].find(s=>s.id===e);return(null==s?void 0:s.name)||e},eB=(0,n.useCallback)(e=>{let{record:s,onView:a,onEdit:n}=e;return(0,l.jsxs)(u.h_,{children:[(0,l.jsx)(u.$F,{asChild:!0,children:(0,l.jsx)(d.z,{variant:"ghost",size:"icon",children:(0,l.jsx)(j.Z,{className:"h-4 w-4"})})}),(0,l.jsxs)(u.AW,{align:"end",children:[(0,l.jsxs)(u.Xi,{onClick:a,children:[(0,l.jsx)(v.Z,{className:"mr-2 h-4 w-4"}),"View"]}),(0,l.jsxs)(u.Xi,{onClick:n,children:[(0,l.jsx)(f.Z,{className:"mr-2 h-4 w-4"}),"Edit"]}),(0,l.jsxs)(u.Xi,{onClick:()=>eq(s),children:[(0,l.jsx)(g.Z,{className:"mr-2 h-4 w-4"}),"Login Methods"]}),(0,l.jsxs)(u.Xi,{onClick:()=>ez(s),children:[(0,l.jsx)(N.Z,{className:"mr-2 h-4 w-4"}),"Change Password"]}),(0,l.jsxs)(u.Xi,{onClick:()=>eL(s),children:[(0,l.jsx)(C.Z,{className:"mr-2 h-4 w-4"}),"Manage Roles"]}),(0,l.jsxs)(u.Xi,{onClick:()=>eE(s),children:[(0,l.jsx)(w,{className:"mr-2 h-4 w-4"}),"Change Status"]})]})]})},[ez,eL,eE,eq]),eQ=(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(h.Ph,{value:P,onValueChange:_,children:[(0,l.jsx)(h.i4,{className:"w-[130px] h-9",children:(0,l.jsx)(h.ki,{placeholder:"Status"})}),(0,l.jsxs)(h.Bw,{children:[(0,l.jsx)(h.Ql,{value:"all",children:"All Status"}),(0,l.jsx)(h.Ql,{value:"active",children:"Active"}),(0,l.jsx)(h.Ql,{value:"inactive",children:"Inactive"}),(0,l.jsx)(h.Ql,{value:"suspended",children:"Suspended"})]})]}),(0,l.jsxs)(h.Ph,{value:z,onValueChange:L,children:[(0,l.jsx)(h.i4,{className:"w-[150px] h-9",children:(0,l.jsx)(h.ki,{placeholder:"Role"})}),(0,l.jsxs)(h.Bw,{children:[(0,l.jsx)(h.Ql,{value:"all",children:"All Roles"}),ev.map(e=>(0,l.jsx)(h.Ql,{value:e.id,children:e.name},e.id))]})]}),a&&(0,l.jsxs)(x.J2,{open:O,onOpenChange:T,children:[(0,l.jsx)(x.xo,{asChild:!0,children:(0,l.jsxs)(d.z,{variant:"outline",role:"combobox","aria-expanded":O,className:"w-[180px] h-9 justify-between",children:[(0,l.jsx)("span",{className:"truncate",children:e_}),(0,l.jsx)(y.Z,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,l.jsx)(x.yk,{className:"w-[200px] p-0",children:(0,l.jsxs)(m.mY,{children:[(0,l.jsx)(m.sZ,{placeholder:"Search tenants...",value:R,onValueChange:V}),(0,l.jsxs)(m.e8,{children:[(0,l.jsx)(m.rb,{children:eg?"Loading...":"No tenants found"}),(0,l.jsxs)(m.fu,{children:[(0,l.jsxs)(m.di,{value:"all",onSelect:()=>{E("all"),T(!1)},children:[(0,l.jsx)(k.Z,{className:(0,A.cn)("mr-2 h-4 w-4","all"===q?"opacity-100":"opacity-0")}),"All Tenants"]}),eN.map(e=>(0,l.jsxs)(m.di,{value:e.name,onSelect:()=>{E(e.id),T(!1)},children:[(0,l.jsx)(k.Z,{className:(0,A.cn)("mr-2 h-4 w-4",q===e.id?"opacity-100":"opacity-0")}),e.name]},e.id))]})]})]})})]})]});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(t.DataBrowserInner,{selectedCollection:"baasix_User",title:"Users",permanentFilters:eP,quickFilters:eQ,renderRowActions:eB,enableView:!0,enableEdit:!0,defaultVisibleColumns:["fullName","email","phone","status","lastAccess","createdAt"]}),(0,l.jsx)(i.Vq,{open:F,onOpenChange:U,children:(0,l.jsxs)(i.cZ,{children:[(0,l.jsxs)(i.fK,{children:[(0,l.jsx)(i.$N,{children:"Change Password"}),(0,l.jsxs)(i.Be,{children:["Change password for ",null==B?void 0:B.email]})]}),(0,l.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,l.jsxs)("div",{className:"grid gap-2",children:[(0,l.jsx)(o._,{htmlFor:"newPassword",children:"New Password"}),(0,l.jsx)(c.I,{id:"newPassword",type:"password",value:H,onChange:e=>J(e.target.value)})]}),(0,l.jsxs)("div",{className:"grid gap-2",children:[(0,l.jsx)(o._,{htmlFor:"confirmPassword",children:"Confirm Password"}),(0,l.jsx)(c.I,{id:"confirmPassword",type:"password",value:G,onChange:e=>ee(e.target.value)})]})]}),(0,l.jsxs)(i.cN,{children:[(0,l.jsx)(d.z,{variant:"outline",onClick:()=>U(!1),children:"Cancel"}),(0,l.jsx)(d.z,{onClick:()=>{if(!H){b.Am.error("Please enter a new password");return}if(H!==G){b.Am.error("Passwords do not match");return}ep({url:"/auth/admin/password/change",method:"post",values:{userId:B.id,newPassword:H}},{onSuccess:()=>{b.Am.success("Password changed successfully"),U(!1),J(""),ee("")},onError:e=>{var s,a,l,n,r;let t=(null==e?void 0:null===(a=e.response)||void 0===a?void 0:null===(s=a.data)||void 0===s?void 0:s.message)||(null==e?void 0:null===(r=e.response)||void 0===r?void 0:null===(n=r.data)||void 0===n?void 0:null===(l=n.error)||void 0===l?void 0:l.message)||(null==e?void 0:e.message)||"Failed to change password";b.Am.error(t)}})},children:"Change Password"})]})]})}),(0,l.jsx)(i.Vq,{open:$,onOpenChange:K,children:(0,l.jsxs)(i.cZ,{className:"max-w-lg",children:[(0,l.jsxs)(i.fK,{children:[(0,l.jsx)(i.$N,{children:"Manage Roles"}),(0,l.jsxs)(i.Be,{children:["Manage roles for ",null==B?void 0:B.email]})]}),(0,l.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,l.jsx)("div",{className:"flex flex-wrap gap-2",children:eS?(0,l.jsx)("span",{className:"text-muted-foreground text-sm",children:"Loading roles..."}):0===es.length?(0,l.jsx)("span",{className:"text-muted-foreground text-sm",children:"No roles assigned"}):es.map((e,s)=>(0,l.jsxs)(p.C,{variant:"secondary",className:"flex items-center gap-1",children:[eO(e.roleId),e.tenantId&&(0,l.jsxs)("span",{className:"text-xs opacity-70",children:["(",eT(e.tenantId),")"]}),(0,l.jsx)("button",{type:"button",onClick:()=>eM(e.roleId,e.tenantId),className:"ml-1 hover:text-destructive",children:(0,l.jsx)(S.Z,{className:"h-3 w-3"})})]},s))}),(0,l.jsxs)("div",{className:"grid gap-2",children:[(0,l.jsx)(o._,{children:"Add Role"}),(0,l.jsxs)(h.Ph,{value:eu,onValueChange:e=>{eh(e),eR(e)},children:[(0,l.jsx)(h.i4,{children:(0,l.jsx)(h.ki,{placeholder:"Select a role to add"})}),(0,l.jsx)(h.Bw,{children:ev.map(e=>(0,l.jsxs)(h.Ql,{value:e.id,children:[e.name,e.isTenantSpecific&&(0,l.jsx)("span",{className:"ml-1 text-xs opacity-70",children:"(Tenant Specific)"})]},e.id))})]})]})]}),(0,l.jsxs)(i.cN,{children:[(0,l.jsx)(d.z,{variant:"outline",onClick:()=>K(!1),children:"Cancel"}),(0,l.jsx)(d.z,{onClick:()=>{let e=es.map(e=>({role_Id:e.roleId,tenant_Id:e.tenantId}));em({resource:"baasix_User",id:B.id,values:{userRoles:e}},{onSuccess:()=>{b.Am.success("Roles updated successfully"),K(!1)},onError:e=>{b.Am.error((null==e?void 0:e.message)||"Failed to update roles")}})},children:"Save Roles"})]})]})}),(0,l.jsx)(i.Vq,{open:ei,onOpenChange:e=>{ed(e),e||(et(null),eh(""))},children:(0,l.jsxs)(i.cZ,{children:[(0,l.jsxs)(i.fK,{children:[(0,l.jsx)(i.$N,{children:"Select Tenant"}),(0,l.jsxs)(i.Be,{children:["Select a tenant for the role: ",null==er?void 0:er.roleName]})]}),(0,l.jsx)("div",{className:"py-4",children:(0,l.jsxs)(m.mY,{children:[(0,l.jsx)(m.sZ,{placeholder:"Search tenants...",value:ec,onValueChange:eo}),(0,l.jsxs)(m.e8,{children:[(0,l.jsx)(m.rb,{children:ew?"Loading...":"No tenants found"}),(0,l.jsx)(m.fu,{children:ey.map(e=>(0,l.jsx)(m.di,{value:e.name,onSelect:()=>eV(e.id),children:e.name},e.id))})]})]})}),(0,l.jsx)(i.cN,{children:(0,l.jsx)(d.z,{variant:"outline",onClick:()=>{ed(!1),et(null),eh("")},children:"Cancel"})})]})}),(0,l.jsx)(i.Vq,{open:D,onOpenChange:W,children:(0,l.jsxs)(i.cZ,{children:[(0,l.jsxs)(i.fK,{children:[(0,l.jsx)(i.$N,{children:"Login Methods"}),(0,l.jsxs)(i.Be,{children:["Connected login methods for ",null==B?void 0:B.email]})]}),(0,l.jsx)("div",{className:"py-4",children:eA?(0,l.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,l.jsx)("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):0===eZ.length?(0,l.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No login methods found"}):(0,l.jsx)("div",{className:"space-y-3",children:eZ.map(e=>(0,l.jsxs)("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:(0,A.cn)("w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium","credential"===e.providerId&&"bg-slate-600","google"===e.providerId&&"bg-red-500","facebook"===e.providerId&&"bg-blue-600","github"===e.providerId&&"bg-gray-800","apple"===e.providerId&&"bg-black",!["credential","google","facebook","github","apple"].includes(e.providerId)&&"bg-purple-500"),children:"credential"===e.providerId?"EP":e.providerId.substring(0,2).toUpperCase()}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-sm font-medium capitalize",children:"credential"===e.providerId?"Email & Password":e.providerId}),(0,l.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Connected ",e.createdAt?new Date(e.createdAt).toLocaleDateString():"N/A"]})]})]}),(0,l.jsx)(p.C,{variant:"outline",className:"capitalize",children:"credential"===e.providerId?"Local":"OAuth"})]},e.id))})}),(0,l.jsx)(i.cN,{children:(0,l.jsx)(d.z,{variant:"outline",onClick:()=>W(!1),children:"Close"})})]})}),(0,l.jsx)(i.Vq,{open:X,onOpenChange:Y,children:(0,l.jsxs)(i.cZ,{children:[(0,l.jsxs)(i.fK,{children:[(0,l.jsx)(i.$N,{children:"Change Status"}),(0,l.jsxs)(i.Be,{children:["Change status for ",null==B?void 0:B.email]})]}),(0,l.jsx)("div",{className:"grid gap-4 py-4",children:(0,l.jsxs)("div",{className:"grid gap-2",children:[(0,l.jsx)(o._,{children:"Status"}),(0,l.jsxs)(h.Ph,{value:el,onValueChange:en,children:[(0,l.jsx)(h.i4,{children:(0,l.jsx)(h.ki,{placeholder:"Select status"})}),(0,l.jsxs)(h.Bw,{children:[(0,l.jsx)(h.Ql,{value:"active",children:"Active"}),(0,l.jsx)(h.Ql,{value:"inactive",children:"Inactive"}),(0,l.jsx)(h.Ql,{value:"suspended",children:"Suspended"})]})]})]})}),(0,l.jsxs)(i.cN,{children:[(0,l.jsx)(d.z,{variant:"outline",onClick:()=>Y(!1),children:"Cancel"}),(0,l.jsx)(d.z,{onClick:()=>{em({resource:"baasix_User",id:B.id,values:{status:el}},{onSuccess:()=>{b.Am.success("Status updated successfully"),Y(!1)},onError:e=>{b.Am.error((null==e?void 0:e.message)||"Failed to update status")}})},children:"Update Status"})]})]})})]})}},99246:function(e,s,a){a.d(s,{N:function(){return n}});var l=a(2265);function n(e,s){let[a,n]=(0,l.useState)(e);return(0,l.useEffect)(()=>{let a=setTimeout(()=>{n(e)},s);return()=>{clearTimeout(a)}},[e,s]),a}},81853:function(e,s,a){a.d(s,{Ml:function(){return i},PY:function(){return t}});var l=a(57437),n=a(2265);let r=(0,n.createContext)({projectSettings:null,isMultiTenant:!1,isLoading:!0,refetch:()=>{}}),t=()=>n.useContext(r)||(console.warn("useProject used outside of ProjectContextProvider, using defaults"),{projectSettings:null,isMultiTenant:!1,isLoading:!1,refetch:()=>{}}),i=e=>{let{children:s,baasixClient:a}=e,[t,i]=(0,n.useState)(null),[d,c]=(0,n.useState)(!0),o=(0,n.useCallback)(async()=>{try{c(!0);let e=await a.server.info();i(null==e?void 0:e.project)}catch(e){console.error("Failed to fetch project settings",e)}finally{c(!1)}},[a]);(0,n.useEffect)(()=>{o()},[o]);let u=(null==t?void 0:t.multitenant)===!0||(null==t?void 0:t.multitenant)==="true";return(0,l.jsx)(r.Provider,{value:{projectSettings:t,isMultiTenant:u,isLoading:d,refetch:o},children:s})}}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7214],{79205:function(e,s,a){a.d(s,{Z:function(){return d}});var l=a(2265);let n=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),r=function(){for(var e=arguments.length,s=Array(e),a=0;a<e;a++)s[a]=arguments[a];return s.filter((e,s,a)=>!!e&&a.indexOf(e)===s).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let t=(0,l.forwardRef)((e,s)=>{let{color:a="currentColor",size:n=24,strokeWidth:t=2,absoluteStrokeWidth:d,className:c="",children:o,iconNode:u,...h}=e;return(0,l.createElement)("svg",{ref:s,...i,width:n,height:n,stroke:a,strokeWidth:d?24*Number(t)/Number(n):t,className:r("lucide",c),...h},[...u.map(e=>{let[s,a]=e;return(0,l.createElement)(s,a)}),...Array.isArray(o)?o:[o]])}),d=(e,s)=>{let a=(0,l.forwardRef)((a,i)=>{let{className:d,...c}=a;return(0,l.createElement)(t,{ref:i,iconNode:s,className:r("lucide-".concat(n(e)),d),...c})});return a.displayName="".concat(e),a}},54001:function(e,s,a){a.d(s,{Z:function(){return l}});let l=(0,a(79205).Z)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},51817:function(e,s,a){a.d(s,{Z:function(){return l}});let l=(0,a(79205).Z)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},29090:function(e,s,a){a.d(s,{Z:function(){return l}});let l=(0,a(79205).Z)("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]])},88906:function(e,s,a){a.d(s,{Z:function(){return l}});let l=(0,a(79205).Z)("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},65422:function(e,s,a){a.d(s,{t:function(){return _}});var l=a(57437),n=a(2265),r=a(72135),i=a(72337),t=a(74291),d=a(12381),c=a(40279),o=a(75060),u=a(32060),h=a(15291),x=a(12749),m=a(2596),p=a(69174),j=a(67782),v=a(42208),f=a(15868),g=a(29090),N=a(54001),w=a(88906);let C=(0,a(79205).Z)("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);var y=a(40875),k=a(30401),b=a(32489),S=a(14438),I=a(81853),A=a(93448),Z=a(99246);function _(e){let{excludeColumns:s=[]}=e,{isMultiTenant:a}=(0,I.PY)(),[_,P]=(0,n.useState)("all"),[z,q]=(0,n.useState)("all"),[L,R]=(0,n.useState)("all"),[V,E]=(0,n.useState)(""),O=(0,Z.N)(V,300),[B,M]=(0,n.useState)(!1),[Q,T]=(0,n.useState)(null),[F,U]=(0,n.useState)(!1),[$,K]=(0,n.useState)(!1),[X,D]=(0,n.useState)(!1),[W,Y]=(0,n.useState)(!1),[H,J]=(0,n.useState)(""),[G,ee]=(0,n.useState)(""),[es,ea]=(0,n.useState)([]),[el,en]=(0,n.useState)(""),[er,ei]=(0,n.useState)(null),[et,ed]=(0,n.useState)(!1),[ec,eo]=(0,n.useState)(""),[eu,eh]=(0,n.useState)(""),ex=(0,Z.N)(ec,300),{mutate:em}=(0,r.PQ)(),{mutate:ep}=(0,r.uC)(),{data:ej}=(0,r.sm)({resource:"baasix_Role",pagination:{mode:"off"}}),ev=(null==ej?void 0:ej.data)||[],{data:ef,isLoading:eg}=(0,r.sm)({resource:"baasix_Tenant",pagination:{current:1,pageSize:20},filters:O?[{field:"name",operator:"contains",value:O}]:[],queryOptions:{enabled:a}}),eN=(null==ef?void 0:ef.data)||[],{data:ew,isLoading:eC}=(0,r.sm)({resource:"baasix_Tenant",pagination:{current:1,pageSize:20},filters:ex?[{field:"name",operator:"contains",value:ex}]:[],queryOptions:{enabled:a&&et}}),ey=(null==ew?void 0:ew.data)||[],{data:ek,isLoading:eb,refetch:eS}=(0,r.sm)({resource:"baasix_UserRole",filters:Q?[{field:"user_Id",operator:"eq",value:Q.id}]:[],pagination:{mode:"off"},queryOptions:{enabled:!!Q&&$}}),{data:eI,isLoading:eA}=(0,r.sm)({resource:"baasix_Account",filters:Q?[{field:"user_Id",operator:"eq",value:Q.id}]:[],pagination:{mode:"off"},queryOptions:{enabled:!!Q&&W}}),eZ=(null==eI?void 0:eI.data)||[];(0,n.useEffect)(()=>{(null==ek?void 0:ek.data)&&$&&ea(ek.data.map(e=>({roleId:e.role_Id,tenantId:e.tenant_Id||void 0})).filter(e=>e.roleId))},[ek,$]);let e_=(0,n.useMemo)(()=>{let e=[];return"all"!==_&&e.push({field:"status",operator:"eq",value:_}),"all"!==z&&e.push({field:"userRoles.role_Id",operator:"eq",value:z}),"all"!==L&&e.push({field:"userRoles.tenant_Id",operator:"eq",value:L}),e},[_,z,L]),eP=(0,n.useMemo)(()=>{if("all"===L)return"All Tenants";let e=eN.find(e=>e.id===L);return(null==e?void 0:e.name)||L},[L,eN]),ez=(0,n.useCallback)(e=>{T(e),J(""),ee(""),U(!0)},[]),eq=(0,n.useCallback)(e=>{T(e),ea([]),K(!0)},[]),eL=(0,n.useCallback)(e=>{T(e),Y(!0)},[]),eR=(0,n.useCallback)(e=>{T(e),en(e.status||"active"),D(!0)},[]),eV=e=>{let s=ev.find(s=>s.id===e);s&&(s.isTenantSpecific&&a?(ei({roleId:e,roleName:s.name}),eo(""),ed(!0)):(es.find(s=>s.roleId===e)||ea([...es,{roleId:e}]),eh("")))},eE=e=>{er&&(es.find(s=>s.roleId===er.roleId&&s.tenantId===e)||ea([...es,{roleId:er.roleId,tenantId:e}]),ed(!1),ei(null),eh(""))},eO=(e,s)=>{ea(es.filter(a=>!(a.roleId===e&&a.tenantId===s)))},eB=e=>{let s=ev.find(s=>s.id===e);return(null==s?void 0:s.name)||e},eM=e=>{let s=[...eN,...ey].find(s=>s.id===e);return(null==s?void 0:s.name)||e},eQ=(0,n.useCallback)(e=>{let{record:s,onView:a,onEdit:n}=e;return(0,l.jsxs)(u.h_,{children:[(0,l.jsx)(u.$F,{asChild:!0,children:(0,l.jsx)(d.z,{variant:"ghost",size:"icon",children:(0,l.jsx)(j.Z,{className:"h-4 w-4"})})}),(0,l.jsxs)(u.AW,{align:"end",children:[(0,l.jsxs)(u.Xi,{onClick:a,children:[(0,l.jsx)(v.Z,{className:"mr-2 h-4 w-4"}),"View"]}),(0,l.jsxs)(u.Xi,{onClick:n,children:[(0,l.jsx)(f.Z,{className:"mr-2 h-4 w-4"}),"Edit"]}),(0,l.jsxs)(u.Xi,{onClick:()=>eL(s),children:[(0,l.jsx)(g.Z,{className:"mr-2 h-4 w-4"}),"Login Methods"]}),(0,l.jsxs)(u.Xi,{onClick:()=>ez(s),children:[(0,l.jsx)(N.Z,{className:"mr-2 h-4 w-4"}),"Change Password"]}),(0,l.jsxs)(u.Xi,{onClick:()=>eq(s),children:[(0,l.jsx)(w.Z,{className:"mr-2 h-4 w-4"}),"Manage Roles"]}),(0,l.jsxs)(u.Xi,{onClick:()=>eR(s),children:[(0,l.jsx)(C,{className:"mr-2 h-4 w-4"}),"Change Status"]})]})]})},[ez,eq,eR,eL]),eT=(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(h.Ph,{value:_,onValueChange:P,children:[(0,l.jsx)(h.i4,{className:"w-[130px] h-9",children:(0,l.jsx)(h.ki,{placeholder:"Status"})}),(0,l.jsxs)(h.Bw,{children:[(0,l.jsx)(h.Ql,{value:"all",children:"All Status"}),(0,l.jsx)(h.Ql,{value:"active",children:"Active"}),(0,l.jsx)(h.Ql,{value:"inactive",children:"Inactive"}),(0,l.jsx)(h.Ql,{value:"suspended",children:"Suspended"})]})]}),(0,l.jsxs)(h.Ph,{value:z,onValueChange:q,children:[(0,l.jsx)(h.i4,{className:"w-[150px] h-9",children:(0,l.jsx)(h.ki,{placeholder:"Role"})}),(0,l.jsxs)(h.Bw,{children:[(0,l.jsx)(h.Ql,{value:"all",children:"All Roles"}),ev.map(e=>(0,l.jsx)(h.Ql,{value:e.id,children:e.name},e.id))]})]}),a&&(0,l.jsxs)(x.J2,{open:B,onOpenChange:M,children:[(0,l.jsx)(x.xo,{asChild:!0,children:(0,l.jsxs)(d.z,{variant:"outline",role:"combobox","aria-expanded":B,className:"w-[180px] h-9 justify-between",children:[(0,l.jsx)("span",{className:"truncate",children:eP}),(0,l.jsx)(y.Z,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,l.jsx)(x.yk,{className:"w-[200px] p-0",children:(0,l.jsxs)(m.mY,{children:[(0,l.jsx)(m.sZ,{placeholder:"Search tenants...",value:V,onValueChange:E}),(0,l.jsxs)(m.e8,{children:[(0,l.jsx)(m.rb,{children:eg?"Loading...":"No tenants found"}),(0,l.jsxs)(m.fu,{children:[(0,l.jsxs)(m.di,{value:"all",onSelect:()=>{R("all"),M(!1)},children:[(0,l.jsx)(k.Z,{className:(0,A.cn)("mr-2 h-4 w-4","all"===L?"opacity-100":"opacity-0")}),"All Tenants"]}),eN.map(e=>(0,l.jsxs)(m.di,{value:e.name,onSelect:()=>{R(e.id),M(!1)},children:[(0,l.jsx)(k.Z,{className:(0,A.cn)("mr-2 h-4 w-4",L===e.id?"opacity-100":"opacity-0")}),e.name]},e.id))]})]})]})})]})]});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(i.DataBrowserInner,{selectedCollection:"baasix_User",title:"Users",permanentFilters:e_,quickFilters:eT,renderRowActions:eQ,enableView:!0,enableEdit:!0,defaultVisibleColumns:["fullName","email","phone","status","lastAccess","createdAt"]}),(0,l.jsx)(t.Vq,{open:F,onOpenChange:U,children:(0,l.jsxs)(t.cZ,{children:[(0,l.jsxs)(t.fK,{children:[(0,l.jsx)(t.$N,{children:"Change Password"}),(0,l.jsxs)(t.Be,{children:["Change password for ",null==Q?void 0:Q.email]})]}),(0,l.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,l.jsxs)("div",{className:"grid gap-2",children:[(0,l.jsx)(o._,{htmlFor:"newPassword",children:"New Password"}),(0,l.jsx)(c.I,{id:"newPassword",type:"password",value:H,onChange:e=>J(e.target.value)})]}),(0,l.jsxs)("div",{className:"grid gap-2",children:[(0,l.jsx)(o._,{htmlFor:"confirmPassword",children:"Confirm Password"}),(0,l.jsx)(c.I,{id:"confirmPassword",type:"password",value:G,onChange:e=>ee(e.target.value)})]})]}),(0,l.jsxs)(t.cN,{children:[(0,l.jsx)(d.z,{variant:"outline",onClick:()=>U(!1),children:"Cancel"}),(0,l.jsx)(d.z,{onClick:()=>{if(!H){S.Am.error("Please enter a new password");return}if(H!==G){S.Am.error("Passwords do not match");return}ep({url:"/auth/admin/password/change",method:"post",values:{userId:Q.id,newPassword:H}},{onSuccess:()=>{S.Am.success("Password changed successfully"),U(!1),J(""),ee("")},onError:e=>{var s,a,l,n,r;let i=(null==e?void 0:null===(a=e.response)||void 0===a?void 0:null===(s=a.data)||void 0===s?void 0:s.message)||(null==e?void 0:null===(r=e.response)||void 0===r?void 0:null===(n=r.data)||void 0===n?void 0:null===(l=n.error)||void 0===l?void 0:l.message)||(null==e?void 0:e.message)||"Failed to change password";S.Am.error(i)}})},children:"Change Password"})]})]})}),(0,l.jsx)(t.Vq,{open:$,onOpenChange:K,children:(0,l.jsxs)(t.cZ,{className:"max-w-lg",children:[(0,l.jsxs)(t.fK,{children:[(0,l.jsx)(t.$N,{children:"Manage Roles"}),(0,l.jsxs)(t.Be,{children:["Manage roles for ",null==Q?void 0:Q.email]})]}),(0,l.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,l.jsx)("div",{className:"flex flex-wrap gap-2",children:eb?(0,l.jsx)("span",{className:"text-muted-foreground text-sm",children:"Loading roles..."}):0===es.length?(0,l.jsx)("span",{className:"text-muted-foreground text-sm",children:"No roles assigned"}):es.map((e,s)=>(0,l.jsxs)(p.C,{variant:"secondary",className:"flex items-center gap-1",children:[eB(e.roleId),e.tenantId&&(0,l.jsxs)("span",{className:"text-xs opacity-70",children:["(",eM(e.tenantId),")"]}),(0,l.jsx)("button",{type:"button",onClick:()=>eO(e.roleId,e.tenantId),className:"ml-1 hover:text-destructive",children:(0,l.jsx)(b.Z,{className:"h-3 w-3"})})]},s))}),(0,l.jsxs)("div",{className:"grid gap-2",children:[(0,l.jsx)(o._,{children:"Add Role"}),(0,l.jsxs)(h.Ph,{value:eu,onValueChange:e=>{eh(e),eV(e)},children:[(0,l.jsx)(h.i4,{children:(0,l.jsx)(h.ki,{placeholder:"Select a role to add"})}),(0,l.jsx)(h.Bw,{children:ev.map(e=>(0,l.jsxs)(h.Ql,{value:e.id,children:[e.name,e.isTenantSpecific&&(0,l.jsx)("span",{className:"ml-1 text-xs opacity-70",children:"(Tenant Specific)"})]},e.id))})]})]})]}),(0,l.jsxs)(t.cN,{children:[(0,l.jsx)(d.z,{variant:"outline",onClick:()=>K(!1),children:"Cancel"}),(0,l.jsx)(d.z,{onClick:()=>{let e=es.map(e=>({role_Id:e.roleId,tenant_Id:e.tenantId}));em({resource:"baasix_User",id:Q.id,values:{userRoles:e}},{onSuccess:()=>{S.Am.success("Roles updated successfully"),K(!1)},onError:e=>{S.Am.error((null==e?void 0:e.message)||"Failed to update roles")}})},children:"Save Roles"})]})]})}),(0,l.jsx)(t.Vq,{open:et,onOpenChange:e=>{ed(e),e||(ei(null),eh(""))},children:(0,l.jsxs)(t.cZ,{children:[(0,l.jsxs)(t.fK,{children:[(0,l.jsx)(t.$N,{children:"Select Tenant"}),(0,l.jsxs)(t.Be,{children:["Select a tenant for the role: ",null==er?void 0:er.roleName]})]}),(0,l.jsx)("div",{className:"py-4",children:(0,l.jsxs)(m.mY,{children:[(0,l.jsx)(m.sZ,{placeholder:"Search tenants...",value:ec,onValueChange:eo}),(0,l.jsxs)(m.e8,{children:[(0,l.jsx)(m.rb,{children:eC?"Loading...":"No tenants found"}),(0,l.jsx)(m.fu,{children:ey.map(e=>(0,l.jsx)(m.di,{value:e.name,onSelect:()=>eE(e.id),children:e.name},e.id))})]})]})}),(0,l.jsx)(t.cN,{children:(0,l.jsx)(d.z,{variant:"outline",onClick:()=>{ed(!1),ei(null),eh("")},children:"Cancel"})})]})}),(0,l.jsx)(t.Vq,{open:W,onOpenChange:Y,children:(0,l.jsxs)(t.cZ,{children:[(0,l.jsxs)(t.fK,{children:[(0,l.jsx)(t.$N,{children:"Login Methods"}),(0,l.jsxs)(t.Be,{children:["Connected login methods for ",null==Q?void 0:Q.email]})]}),(0,l.jsx)("div",{className:"py-4",children:eA?(0,l.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,l.jsx)("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):0===eZ.length?(0,l.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No login methods found"}):(0,l.jsx)("div",{className:"space-y-3",children:eZ.map(e=>(0,l.jsxs)("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:(0,A.cn)("w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium","credential"===e.providerId&&"bg-slate-600","google"===e.providerId&&"bg-red-500","facebook"===e.providerId&&"bg-blue-600","github"===e.providerId&&"bg-gray-800","apple"===e.providerId&&"bg-black",!["credential","google","facebook","github","apple"].includes(e.providerId)&&"bg-purple-500"),children:"credential"===e.providerId?"EP":e.providerId.substring(0,2).toUpperCase()}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-sm font-medium capitalize",children:"credential"===e.providerId?"Email & Password":e.providerId}),(0,l.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Connected ",e.createdAt?new Date(e.createdAt).toLocaleDateString():"N/A"]})]})]}),(0,l.jsx)(p.C,{variant:"outline",className:"capitalize",children:"credential"===e.providerId?"Local":"OAuth"})]},e.id))})}),(0,l.jsx)(t.cN,{children:(0,l.jsx)(d.z,{variant:"outline",onClick:()=>Y(!1),children:"Close"})})]})}),(0,l.jsx)(t.Vq,{open:X,onOpenChange:D,children:(0,l.jsxs)(t.cZ,{children:[(0,l.jsxs)(t.fK,{children:[(0,l.jsx)(t.$N,{children:"Change Status"}),(0,l.jsxs)(t.Be,{children:["Change status for ",null==Q?void 0:Q.email]})]}),(0,l.jsx)("div",{className:"grid gap-4 py-4",children:(0,l.jsxs)("div",{className:"grid gap-2",children:[(0,l.jsx)(o._,{children:"Status"}),(0,l.jsxs)(h.Ph,{value:el,onValueChange:en,children:[(0,l.jsx)(h.i4,{children:(0,l.jsx)(h.ki,{placeholder:"Select status"})}),(0,l.jsxs)(h.Bw,{children:[(0,l.jsx)(h.Ql,{value:"active",children:"Active"}),(0,l.jsx)(h.Ql,{value:"inactive",children:"Inactive"}),(0,l.jsx)(h.Ql,{value:"suspended",children:"Suspended"})]})]})]})}),(0,l.jsxs)(t.cN,{children:[(0,l.jsx)(d.z,{variant:"outline",onClick:()=>D(!1),children:"Cancel"}),(0,l.jsx)(d.z,{onClick:()=>{em({resource:"baasix_User",id:Q.id,values:{status:el}},{onSuccess:()=>{S.Am.success("Status updated successfully"),D(!1)},onError:e=>{S.Am.error((null==e?void 0:e.message)||"Failed to update status")}})},children:"Update Status"})]})]})})]})}},99246:function(e,s,a){a.d(s,{N:function(){return n}});var l=a(2265);function n(e,s){let[a,n]=(0,l.useState)(e);return(0,l.useEffect)(()=>{let a=setTimeout(()=>{n(e)},s);return()=>{clearTimeout(a)}},[e,s]),a}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7304],{83434:function(e,t,a){a.d(t,{G:function(){return r}});var s=a(49112);let n="token",i="baasix_access_token",r=(0,s.ql)({url:window.location.origin,authMode:"jwt",autoRefresh:!0,onAuthStateChange:(e,t)=>{console.log("[SDK] Auth state changed:",e,null==t?void 0:t.email)}});{let e=localStorage.getItem(n)||localStorage.getItem(i);e&&(r.setToken(e),localStorage.setItem(n,e),localStorage.setItem(i,e)),window.addEventListener("storage",e=>{(e.key===n||e.key===i)&&(e.newValue?(r.setToken(e.newValue),localStorage.setItem(n,e.newValue),localStorage.setItem(i,e.newValue)):r.setToken(""))})}},28757:function(e,t,a){a.d(t,{DG:function(){return d},LR:function(){return o},fO:function(){return f},gm:function(){return r}});let s=(e,t)=>"collections"===e||"baasix_SchemaDefinition"===e?{type:"schemas"}:"files"===e||"baasix_File"===e?{type:"files"}:"permissions"===e||"baasix_Permission"===e?{type:"permissions"}:"baasix_Settings"===e?{type:"items",collection:"baasix_Settings"}:"roles"===e?{type:"items",collection:"baasix_Role"}:"users"===e?{type:"items",collection:"baasix_User"}:"indexes"===e?{type:"indexes",collectionName:null==t?void 0:t.collectionName}:"relationships"===e?{type:"relationships",collectionName:null==t?void 0:t.collectionName}:{type:"items",collection:e},n={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte",in:"in",nin:"notIn",contains:"like",containss:"iLike",ncontains:"notLike",ncontainss:"notILike",null:"isNull",nnull:"isNotNull",between:"between",nbetween:"notBetween",startswith:"startsWith",startswiths:"startsWiths",nstartswith:"nstartsWith",nstartswiths:"nstartsWiths",endswith:"endsWith",endswiths:"endsWiths",nendswith:"nendsWith",nendswiths:"nendsWiths",or:"OR",and:"AND",intersects:"intersects",nIntersects:"nIntersects",dwithin:"dwithin",containsGEO:"containsGEO",within:"within",true:"eq",false:"eq"},i={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte",in:"in",notIn:"nin",like:"contains",iLike:"containss",notLike:"ncontains",notILike:"ncontainss",isNull:"null",isNotNull:"nnull",between:"between",notBetween:"nbetween",startsWith:"startswith",startsWiths:"startswiths",nstartsWith:"nstartswith",nstartsWiths:"nstartswiths",endsWith:"endswith",endsWiths:"endswiths",nendsWith:"nendswith",nendsWiths:"nendswiths",OR:"or",AND:"and",intersects:"intersects",nIntersects:"nIntersects",dwithin:"dwithin",containsGEO:"containsGEO",within:"within"},r=e=>{if(!e||0===e.length)return{};let t={AND:[]};return(e.forEach(e=>{if("field"in e){let a=n[e.operator]||e.operator;t.AND.push({[e.field]:{[a]:e.value}})}else if("operator"in e&&("and"===e.operator||"or"===e.operator)){let a=n[e.operator]||e.operator,s={[a]:[]};e.value.forEach(e=>{if("field"in e){let t=n[e.operator]||e.operator;s[a].push({[e.field]:{[t]:e.value}})}else if("operator"in e){let t=r([e]);t.AND&&t.AND.length>0?s[a].push(...t.AND):s[a].push(t)}}),t.AND.push(s)}}),1===t.AND.length)?t.AND[0]:t},o=e=>{if(!e||0===Object.keys(e).length)return[];let t=e=>{let a=[];return Object.entries(e).forEach(e=>{let[s,n]=e;if("AND"===s||"OR"===s){let e=i[s]||s.toLowerCase(),r=[];Array.isArray(n)&&n.forEach(e=>{let a=t(e);r.push(...a)}),r.length>0&&a.push({operator:e,value:r})}else"object"==typeof n&&null!==n&&Object.entries(n).forEach(e=>{let[t,n]=e,r=i[t]||t;a.push({field:s,operator:r,value:n})})}),a};return t(e)},l=e=>{if(void 0===e)return null;let{field:t,operator:a,value:s}=e;return{[t]:{[n[a]||a]:s}}},c=e=>{if(void 0===e)return null;let{operator:t,value:a}=e,s=n[t]||t,i={};return i[s]=[],a.forEach(e=>{if("field"in e){let t=l(e);t&&i[s].push(t)}else{let t=c(e);t&&i[s].push(t)}}),i},h=e=>{let t={},a="";return e&&(t.AND=[],e.forEach(e=>{if("or"!==e.operator&&"and"!==e.operator&&"field"in e){let{field:s,value:n}=e;if(n){if("search"===s)a=n;else{let a=l(e);a&&t.AND.push(a)}}}else{let a=c(e);a&&t.AND.push(a)}})),{search:a,filters:t}},u=e=>{if(!e||0===e.length)return;let t={};return e.forEach(e=>{t[e.field]=e.order}),t},d=e=>({getList:async t=>{let{resource:a,pagination:n,filters:i,sorters:r,meta:o}=t,l=s(a,o),c=h(i),d=10;("collections"===a||"baasix_SchemaDefinition"===a)&&(d=50);let f={page:(null==n?void 0:n.current)||1,limit:(null==n?void 0:n.pageSize)||d,filter:c.filters,sort:u(r),...o};c.search&&(f.search=c.search);try{let t;switch(l.type){case"schemas":t=await e.schemas.find(f);break;case"files":t=await e.files.find(f);break;case"permissions":t=await e.permissions.find(f);break;default:t=await e.items(l.collection).find(f)}return{data:t.data||[],total:t.totalCount||0}}catch(e){throw console.error("getList error for ".concat(a,":"),e),e}},getOne:async t=>{let{resource:a,id:n,meta:i}=t,r=s(a,i),o=(null==i?void 0:i.fields)&&Array.isArray(i.fields)?i.fields.filter(e=>"string"==typeof e):["*"];try{let t;switch(r.type){case"schemas":t=await e.schemas.findOne(n);break;case"files":t=await e.files.findOne(n);break;case"permissions":t=await e.permissions.findOne(n);break;default:t=await e.items(r.collection).findOne(n,{fields:o})}return{data:t}}catch(e){throw console.error("getOne error for ".concat(a,"/").concat(n,":"),e),e}},create:async t=>{let{resource:a,variables:n,meta:i}=t,r=s(a,i);try{let t;switch(r.type){case"schemas":t=await e.schemas.create(n);break;case"files":if(n instanceof FormData){let a=n.get("file");if(a)t=await e.files.upload(a);else throw Error("No file provided in FormData")}else t=await e.files.upload(n);break;case"permissions":t=await e.permissions.create(n);break;case"indexes":t=await e.schemas.createIndex(r.collectionName,n);break;case"relationships":t=await e.schemas.createRelationship(r.collectionName,n);break;default:t={id:await e.items(r.collection).create(n)}}return{data:t}}catch(e){throw console.error("create error for ".concat(a,":"),e),e}},update:async t=>{let{resource:a,id:n,variables:i,meta:r}=t,o=s(a,r);try{let t;switch(o.type){case"schemas":t=await e.schemas.update(n,i);break;case"files":t=await e.files.update(n,i);break;case"permissions":t=await e.permissions.update(n,i);break;case"relationships":t=await e.schemas.updateRelationship(o.collectionName,n,i);break;default:await e.items(o.collection).update(n,i),t={id:n}}return{data:t}}catch(e){throw console.error("update error for ".concat(a,"/").concat(n,":"),e),e}},deleteOne:async t=>{let{resource:a,id:n,meta:i}=t,r=s(a,i);try{switch(r.type){case"schemas":await e.schemas.delete(n);break;case"files":await e.files.delete(n);break;case"permissions":await e.permissions.delete(n);break;case"indexes":await e.schemas.deleteIndex(r.collectionName,n);break;case"relationships":await e.schemas.deleteRelationship(r.collectionName,n);break;default:await e.items(r.collection).delete(n)}return{data:{id:n}}}catch(e){throw console.error("deleteOne error for ".concat(a,"/").concat(n,":"),e),e}},getMany:async t=>{let{resource:a,ids:n,meta:i}=t,r=s(a,i),o={id:{in:n}};try{let t;switch(r.type){case"schemas":t=await e.schemas.find({filter:o});break;case"files":t=await e.files.find({filter:o});break;case"permissions":t=await e.permissions.find({filter:o});break;default:t=await e.items(r.collection).find({filter:o})}return{data:t.data||[]}}catch(e){throw console.error("getMany error for ".concat(a,":"),e),e}},createMany:async t=>{let{resource:a,variables:n,meta:i}=t,r=s(a,i);try{if("items"!==r.type)throw Error("createMany not supported for ".concat(r.type));return{data:(await e.items(r.collection).createMany(n)).map(e=>({id:e}))}}catch(e){throw console.error("createMany error for ".concat(a,":"),e),e}},updateMany:async t=>{let{resource:a,ids:n,variables:i,meta:r}=t,o=s(a,r);try{if("items"!==o.type)throw Error("updateMany not supported for ".concat(o.type));return await e.items(o.collection).updateMany(n,i),{data:n.map(e=>({id:e}))}}catch(e){throw console.error("updateMany error for ".concat(a,":"),e),e}},deleteMany:async t=>{let{resource:a,ids:n,meta:i}=t,r=s(a,i);try{if("items"!==r.type)throw Error("deleteMany not supported for ".concat(r.type));return await e.items(r.collection).deleteMany(n),{data:n.map(e=>({id:e}))}}catch(e){throw console.error("deleteMany error for ".concat(a,":"),e),e}},custom:async t=>{let{url:a,method:s,filters:n,sorters:i,payload:r,query:o,headers:l}=t,c=e.request,h={...o,filter:n,sort:i};try{let e;let t=r instanceof FormData;switch(s){case"get":e=await c.get(a,{params:h});break;case"post":e=t?await c.upload(a,r,{params:h}):await c.post(a,r,{params:h});break;case"put":e=await c.put(a,r,{params:h});break;case"patch":e=await c.patch(a,r,{params:h});break;case"delete":e=await c.delete(a,{params:h});break;default:throw Error("Unsupported method: ".concat(s))}return{data:e}}catch(e){throw console.error("custom request error:",e),e}},getApiUrl:()=>window.location.origin}),f=e=>async function(t,a,s){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"before";await e.items(t).sortItem(a,s,n)}},81853:function(e,t,a){a.d(t,{Ml:function(){return o},PY:function(){return r}});var s=a(57437),n=a(2265);let i=(0,n.createContext)({projectSettings:null,isMultiTenant:!1,isLoading:!0,refetch:()=>{}}),r=()=>n.useContext(i)||(console.warn("useProject used outside of ProjectContextProvider, using defaults"),{projectSettings:null,isMultiTenant:!1,isLoading:!1,refetch:()=>{}}),o=e=>{let{children:t,baasixClient:a}=e,[r,o]=(0,n.useState)(null),[l,c]=(0,n.useState)(!0),h=(0,n.useCallback)(async()=>{try{c(!0);let e=await a.server.info();o(null==e?void 0:e.project)}catch(e){console.error("Failed to fetch project settings",e)}finally{c(!1)}},[a]);(0,n.useEffect)(()=>{h()},[h]);let u=(null==r?void 0:r.multitenant)===!0||(null==r?void 0:r.multitenant)==="true";return(0,s.jsx)(i.Provider,{value:{projectSettings:r,isMultiTenant:u,isLoading:l,refetch:h},children:t})}}}]);
|